Skip to content

Commit 8798344

Browse files
authored
Update client-sdk example code (#3418)
* update version * fix example * update doc * revert version * update package.json
1 parent a3a41c1 commit 8798344

File tree

7 files changed

+5961
-4842
lines changed

7 files changed

+5961
-4842
lines changed

tee-worker/omni-executor/client-sdk/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,8 @@
4848
"nx": {
4949
"includedScripts": []
5050
},
51-
"packageManager": "pnpm@8.7.6"
51+
"packageManager": "pnpm@8.7.6",
52+
"engines": {
53+
"node": "18.x"
54+
}
5255
}

tee-worker/omni-executor/client-sdk/packages/client-sdk/docs/type-aliases/JsonRpcRequest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ Defined in: [utils/types.ts:5](https://github.com/litentry/heima/blob/dev/utils/
4141

4242
### params
4343

44-
> **params**: `string`[] \| `Record`\<`string`, `string`\>
44+
> **params**: `any`
4545
4646
Defined in: [utils/types.ts:6](https://github.com/litentry/heima/blob/dev/utils/types.ts#L6)

tee-worker/omni-executor/client-sdk/packages/client-sdk/docs/type-aliases/JsonRpcResponse.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ Defined in: [utils/types.ts:15](https://github.com/litentry/heima/blob/dev/utils
3030

3131
### result
3232

33-
> **result**: `string`
33+
> **result**: `any`
3434
3535
Defined in: [utils/types.ts:17](https://github.com/litentry/heima/blob/dev/utils/types.ts#L17)

tee-worker/omni-executor/client-sdk/packages/client-sdk/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@types/ws": "^8.5.13"
1515
},
1616
"peerDependencies": {
17-
"@heima-network/chaindata": "*",
17+
"@heima-network/chaindata": "0.0.5",
1818
"@heima-network/parachain-api": "0.9.24-next.7",
1919
"@polkadot/api": "^15.0.2",
2020
"@polkadot/types": "^15.0.2",
@@ -33,4 +33,4 @@
3333
"require": "./dist/index.cjs"
3434
}
3535
}
36-
}
36+
}

tee-worker/omni-executor/client-sdk/packages/client-sdk/src/lib/requests/__test__/pumpx-export-wallet.request.test.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { enclave } from '@lib/enclave';
2+
import { decryptWithAes } from '@lib/utils';
23
import { OmniRpcMethod, PumpxRpcMethod } from '@lib/utils/rpc-method';
34
import { JsonRpcRequest } from '@utils/types';
5+
import { u8aToHex } from "@polkadot/util";
6+
import {AesOutput} from "@heima-network/parachain-api"
7+
8+
const aesRandomKey = globalThis.crypto.getRandomValues(new Uint8Array(32));
49

510
// This test is just an example. It requires receiving email verification codes, which cannot be done by running this unit test.
611
describe.skip('add-export-wallet', () => {
12+
713
// step 1
814
it('request email verification code', async () => {
915
const rpcRequest = {
@@ -16,9 +22,8 @@ describe.skip('add-export-wallet', () => {
1622
await enclave.send(rpcRequest);
1723
});
1824

19-
// step2
20-
it('export wallet should works', async () => {
21-
const aesRandomKey = globalThis.crypto.getRandomValues(new Uint8Array(32));
25+
// step 2
26+
it('export wallet should work', async () => {
2227
const encryptedKey = await enclave.encrypt({ cleartext: aesRandomKey }); // already get shielding key
2328
const rpcRequest: JsonRpcRequest = {
2429
jsonrpc: '2.0',
@@ -36,4 +41,15 @@ describe.skip('add-export-wallet', () => {
3641
};
3742
await enclave.send(rpcRequest);
3843
});
39-
});
44+
45+
// step 3
46+
it('decrypt response', async () => {
47+
const response = {
48+
ciphertext: "0xb0b6126dd7acae085cd4da94185d0707bb19257f6f95cac84c2c4b0ffc0e23995ac656c96f08abd007b32bafae5477f7",
49+
aad: "0x",
50+
nonce: "0xaad559c090dc5195ace3e3eb",
51+
};
52+
const decryptedKey = await decryptWithAes(u8aToHex(aesRandomKey), response as unknown as AesOutput, "hex");
53+
console.log("decryptedKey", decryptedKey);
54+
});
55+
});

tee-worker/omni-executor/client-sdk/packages/client-sdk/src/lib/requests/request-email-verification-code.request.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export async function requestEmailVerificationCode(args: { email: string }, encl
2121
const rpcRequest: JsonRpcRequest = {
2222
jsonrpc: '2.0',
2323
method: 'omni_requestEmailVerificationCode',
24-
params: [email],
24+
params: {
25+
user_email: email,
26+
},
2527
};
2628

2729
await enclaveInstance.send(rpcRequest);

0 commit comments

Comments
 (0)