Skip to content

Commit

Permalink
[DRAFT] Typescript Rush SDK (#7)
Browse files Browse the repository at this point in the history
* feat: Created TS SDK

* refactor: removed the implement and added access modifiers

* feat: added TSSDK params interface

* feat: added new dependencies

* refactor: changed the process and names

* refactor: changed type field names

* fix: package type

* refactor: change class to ask secret key instead

* refactor: changed keypair passing to secret key

* refactor: changed field keypair to secret key

* refactor: changed program_id value to new keypair public key

* Update index.ts

* Revert "Update index.ts"

This reverts commit a2a2aa1.

Revert previous commit -cause: breaking change

* feat: implement migrate function

* Update sdk.ts

revert code

* feat: set up prettier to the project

* add migrate function test

* Add set function implementation

* feat: set up prettier to the project

* fix: finalize and improve org structure && clean up naming convention for coding standard && format all with prettier

* [draft] feat : developing create method

* Add interface_storage.ts for pull request

* Added MemoryAdapter

* fix: fix to keypair

* Update sdk.ts

Added get and delete method

* feat: Working Session Keys

* feat: Working Session Keys Test

* Add solana adapters

* Update storage and sdk modules with new features and tests

* Update sdk.ts

* Update storage.ts and storage.test.ts with delete method tests and validation

* feat: create function

* Add files via upload

* feat: world functions

---------

Co-authored-by: Hurotamo <[email protected]>
Co-authored-by: sceiiya <[email protected]>
Co-authored-by: Avien <[email protected]>
Co-authored-by: Bvin-in <[email protected]>
Co-authored-by: Rjay <[email protected]>
  • Loading branch information
6 people authored Dec 30, 2024
1 parent ffb764f commit 13bf9c1
Show file tree
Hide file tree
Showing 42 changed files with 4,948 additions and 356 deletions.
3 changes: 3 additions & 0 deletions ecs/web/sdk/typescript/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
build
8 changes: 8 additions & 0 deletions ecs/web/sdk/typescript/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"singleQuote": false,
"tabWidth": 4,
"useTabs": true,
"trailingComma": "all",
"bracketSpacing": true
}
27 changes: 23 additions & 4 deletions ecs/web/sdk/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
{
"name": "typescript",
"version": "1.0.0",
"main": "src/index.ts",
"main": "src/sdk.ts",
"scripts": {
"dev": "tsc --watch & nodemon dist/index.js",
"dev": "tsc --watch & nodemon dist/sdk.js",
"format": "prettier --write . # this will format all spacing in the code",
"check": "tsc --noEmit #this will check all type errors",
"build": "npx tsc",
"start": "node dist/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
"minify": "terser dist/sdk.js --compress --mangle --output dist/index.min.js # minify the final build",
"bnm": "npm run build && npm run minify # build and minify",
"start": "node dist/sdk.js",
"test": "jest"
},
"type": "module",
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^8.18.1",
"bs58": "^6.0.0",
"jest": "^29.0.0",
"nodemon": "^3.1.9",
"prettier": "^3.4.2",
"terser": "^5.37.0",
"ts-jest": "^29.0.0",
"typescript": "^5.7.2"
},
"dependencies": {
"@solana-developers/helpers": "^2.5.6",
"@solana/web3.js": "^1.95.8",
"base-x": "^5.0.0",
"esrun": "^3.2.26"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"transform": {
"^.+\\.ts$": "ts-jest"
}
}
}
28 changes: 0 additions & 28 deletions ecs/web/sdk/typescript/src/index.ts

This file was deleted.

43 changes: 43 additions & 0 deletions ecs/web/sdk/typescript/src/modules/blueprint/blueprint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//? this is a placeholder class for BtreeMap, module to be developed? or is it a library?

import { IBluePrint, IBTreeMap } from "../../types/types";

class BTreeMap implements IBTreeMap {
//! should use collections library for this

K;
V;
A;

constructor(K: string = "", V: string = "", A: string = "") {
this.K = K;
this.V = V;
this.A = A;
}
}

export class BluePrint implements IBluePrint {
name;
description;
entities;
regions;
instances;
// description: world_description,
// entities: BTreeMap::new(),
// regions: BTreeMap::new(),
// instances: BTreeMap::new(),

constructor(
name: string,
description: string,
entities: BTreeMap = new BTreeMap(),
regions: BTreeMap = new BTreeMap(),
instances: BTreeMap = new BTreeMap(),
) {
this.name = name;
this.description = description;
this.entities = entities;
this.regions = regions;
this.instances = instances;
}
}
43 changes: 0 additions & 43 deletions ecs/web/sdk/typescript/src/modules/blueprint/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Keypair, PublicKey } from "@solana/web3.js";

export interface Auth {
connectWallet(): Promise<PublicKey>;

// This will create the session keypair and encrypt the data and then store that encrypted data to the class and return the encrypted session keypair (base64 string)
createSession<T>(data: T): string;

// Call this function to add funds to the session
addFunds(
amount: number,
encryptedSessionKeypair: string,
senderPublickey: PublicKey,
): void;

// This will be the validator for overall session like the funds, expiration
validateSession(encryptedSessionKeypair: string): boolean;

// This will encrypt the keypair using the data the user passed when creating a session to be used for creating a hash for encryption.
// encrypt<T>(sessionKeypair: Keypair, data: T): string;

// This will decrypt the encrypted sessionKeypair which is in a base64 string and return it as Keypair
// decrypt<T>(encryptedSessionKeypair: string, data: T): Keypair;

// Refunds the fund stored in the session to the users wallet
refundFunds(
sendTo: PublicKey,
encryptedSessionKeypair: string,
): Promise<void>;

// This will call the refundFunds function to return the funds stored on the session and then revoke the session
revokeSession(encryptedSessionKeypair: string): void;

// This will then be used for every transaction when a session is already been made
createTransaction(
amount: number,
encryptedSessionKeypair: string,
recipient: PublicKey,
): Promise<void>;
}
Loading

0 comments on commit 13bf9c1

Please sign in to comment.