From 8cb0727e1fda1c5b49b6f7fb715b44c4364e92ba Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Tue, 29 Oct 2024 19:44:01 -0500 Subject: [PATCH 01/15] update to client-api@0.9.20-next.3 Signed-off-by: Jonathan Alvarez --- .../packages/client-sdk/package.json | 4 +- tee-worker/identity/client-sdk/pnpm-lock.yaml | 37 +++++-------------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/package.json b/tee-worker/identity/client-sdk/packages/client-sdk/package.json index f643c864b0..41d2f880bf 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/package.json +++ b/tee-worker/identity/client-sdk/packages/client-sdk/package.json @@ -8,8 +8,8 @@ "@polkadot/rpc-provider": "^10.9.1" }, "peerDependencies": { - "@litentry/parachain-api": "0.9.20-4.1", - "@litentry/sidechain-api": "0.9.20-4", + "@litentry/parachain-api": "0.9.20-next.3", + "@litentry/sidechain-api": "0.9.20-next.3", "@litentry/chaindata": "*", "@polkadot/api": "^10.9.1", "@polkadot/types": "^10.9.1", diff --git a/tee-worker/identity/client-sdk/pnpm-lock.yaml b/tee-worker/identity/client-sdk/pnpm-lock.yaml index f8267a6271..c411cd7d44 100644 --- a/tee-worker/identity/client-sdk/pnpm-lock.yaml +++ b/tee-worker/identity/client-sdk/pnpm-lock.yaml @@ -87,11 +87,11 @@ importers: dependencies: tslib: 2.6.2 - packages/enclave: + packages/client-sdk: specifiers: '@litentry/chaindata': '*' - '@litentry/parachain-api': 0.9.20-4.1 - '@litentry/sidechain-api': 0.9.20-4 + '@litentry/parachain-api': 0.9.20-next.3 + '@litentry/sidechain-api': 0.9.20-next.3 '@polkadot/api': ^10.9.1 '@polkadot/rpc-provider': ^10.9.1 '@polkadot/types': ^10.9.1 @@ -101,8 +101,8 @@ importers: tslib: ^2.3.0 dependencies: '@litentry/chaindata': link:../chaindata - '@litentry/parachain-api': 0.9.20-4.1 - '@litentry/sidechain-api': 0.9.20-4 + '@litentry/parachain-api': 0.9.20-next.3 + '@litentry/sidechain-api': 0.9.20-next.3 '@polkadot/api': 10.13.1 '@polkadot/types': 10.13.1 '@polkadot/types-codec': 10.13.1 @@ -112,25 +112,6 @@ importers: devDependencies: '@polkadot/rpc-provider': 10.13.1 - packages/vc-sdk: - specifiers: - '@litentry/parachain-api': 0.9.20-4.1 - '@litentry/sidechain-api': 0.9.20-4 - '@polkadot/api': ^10.9.1 - '@polkadot/util': ^12.5.1 - '@polkadot/util-crypto': ^12.5.1 - fast-glob: ^3.3.2 - tslib: ^2.3.0 - dependencies: - '@litentry/parachain-api': 0.9.20-4.1 - '@litentry/sidechain-api': 0.9.20-4 - '@polkadot/api': 10.13.1 - '@polkadot/util': 12.6.2 - '@polkadot/util-crypto': 12.6.2_@polkadot+util@12.6.2 - tslib: 2.6.2 - devDependencies: - fast-glob: 3.3.2 - packages: /@aashutoshrathi/word-wrap/1.2.6: @@ -1760,8 +1741,8 @@ packages: '@jridgewell/resolve-uri': 3.1.1 '@jridgewell/sourcemap-codec': 1.4.15 - /@litentry/parachain-api/0.9.20-4.1: - resolution: {integrity: sha512-IL3E86EXlc3YdzHghxHwy0+a+1cWAjyQ8Ynyku4BtD6lL5b/bLgS3tFRmAYhkmmIFfJnx9vLRw2gZ3LVEudcJg==} + /@litentry/parachain-api/0.9.20-next.3: + resolution: {integrity: sha512-7C6RsxTec7rp6kxiQOoNipUS5Gr839is3Z7C/bHiOsA1CXyeYa1V0TtUqkPS5TU7ctNpxx5tZZcwS8nS5DF0VQ==} dependencies: '@polkadot/api': 10.13.1 '@polkadot/api-augment': 10.13.1 @@ -1783,8 +1764,8 @@ packages: - utf-8-validate dev: false - /@litentry/sidechain-api/0.9.20-4: - resolution: {integrity: sha512-wYIS8FStKL7Nw/ViRlRMijSpZgVxJr2OKQlSRO1j9rBdNiCiOw0M5Y5Uo3eeSO7y4R04gPaSm7q0FvjByvGEMw==} + /@litentry/sidechain-api/0.9.20-next.3: + resolution: {integrity: sha512-Uv2DpQQWhGt/jy1I+ZdAVb9butti11ZujEUMn3r40qULSBUiUZEUcxGy06KnaUkqqD7stLvNxTEgWMeABUPqzQ==} dependencies: '@polkadot/api': 10.13.1 '@polkadot/api-augment': 10.13.1 From 388d5958a4446e02d7504b8d46f337d3ca4ca29c Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Tue, 29 Oct 2024 19:44:36 -0500 Subject: [PATCH 02/15] add requestor for intent Signed-off-by: Jonathan Alvarez --- .../src/lib/requests/remark.request.ts | 105 ++++++++++++++++++ .../src/lib/type-creators/request.ts | 38 +++++-- .../src/lib/type-creators/trusted-call.ts | 34 +++++- 3 files changed, 167 insertions(+), 10 deletions(-) create mode 100644 tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/remark.request.ts diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/remark.request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/remark.request.ts new file mode 100644 index 0000000000..84eb995f3f --- /dev/null +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/remark.request.ts @@ -0,0 +1,105 @@ +import { hexToU8a, stringToHex } from '@polkadot/util'; +import { randomAsHex } from '@polkadot/util-crypto'; + +import type { ApiPromise } from '@polkadot/api'; +import type { + LitentryIdentity, + WorkerRpcReturnValue, +} from '@litentry/parachain-api'; + +import { enclave } from '../enclave'; +import { createPayloadToSign } from '../util/create-payload-to-sign'; +import { createTrustedCallType } from '../type-creators/trusted-call'; +import { createRequestType } from '../type-creators/request'; + +import type { JsonRpcRequest } from '../util/types'; + +/** + * OmniAccount: Make a remark + */ +export async function remark( + /** Litentry Parachain API instance from Polkadot.js */ + api: ApiPromise, + data: { + /** The signer's account. Use `createLitentryIdentityType` helper to create this struct */ + signer?: LitentryIdentity; + /** The user's account. Use `createLitentryIdentityType` helper to create this struct */ + who: LitentryIdentity; + /** the message to be sent */ + message: string; + } +): Promise<{ + payloadToSign: string; + txHash: string; + send: (args: { signedPayload: string }) => Promise<{ + response: Array; + txHash: string; + }>; +}> { + const { who, message } = data; + + const shard = await enclave.getShard(api); + const shardU8 = hexToU8a(shard); + const txHash = randomAsHex(); + + // identity to sign the requests + const signer = data.signer || who; + + const { call, key } = await createTrustedCallType(api.registry, { + method: 'request_intent', + params: { + who, + intent: api.createType('Intent', { + SystemRemark: stringToHex(message), + }), + }, + }); + + const nonce = await api.rpc.system.accountNextIndex( + who.asSubstrate.toHex() // who is OmniAccount, thus substrate + ); + + const payloadToSign = createPayloadToSign({ + who, + call, + nonce, + shard: shardU8, + }); + + const send = async (args: { + signedPayload: string; + }): Promise<{ + response: Array; + txHash: string; + }> => { + // prepare and encrypt request + + const request = await createRequestType(api, { + signer: who, + signature: args.signedPayload, + call, + nonce, + shard: shardU8, + }); + + // send the request to the Enclave + const rpcRequest: JsonRpcRequest = { + jsonrpc: '2.0', + method: 'author_submitNativeRequest', + params: [request.toHex()], + }; + + const enclaveResult = await enclave.send(api, rpcRequest); + + return { + txHash, + response: enclaveResult, + }; + }; + + return { + txHash, + payloadToSign, + send, + }; +} diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/request.ts index a4ab6a79d5..5300eb68df 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/request.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/request.ts @@ -48,21 +48,41 @@ export async function createRequestType( signature: signedPayload, }); - const signedCall = api.createType('TrustedCallSigned', { - call, - index: nonce, - signature: signature, - }); + let operationU8a = new Uint8Array(); - const operation = api.createType('TrustedOperation', { - direct_call: signedCall, - }); + if (call.isRequestIntent) { + const callAuthenticated = api.createType('TrustedCallAuthenticated', { + call, + nonce, + authentication: api.createType('TCAuthentication', { + Web3: signature, + }), + }); + + const operation = api.createType('TrustedOperation', { + direct_call: callAuthenticated, + }); + + operationU8a = operation.toU8a(); + } else { + const signedCall = api.createType('TrustedCallSigned', { + call, + index: nonce, + signature: signature, + }); + + const operation = api.createType('TrustedOperation', { + direct_call: signedCall, + }); + + operationU8a = operation.toU8a(); + } // Encrypt the operation call using the client shielding key const encryptionNonce = generateNonce12(); const { ciphertext: encryptedOperation } = await encrypt( { - cleartext: operation.toU8a(), + cleartext: operationU8a, nonce: encryptionNonce, }, encryptionKey diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/trusted-call.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/trusted-call.ts index 3156b4bb4c..aea76a0622 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/trusted-call.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/trusted-call.ts @@ -2,7 +2,7 @@ import { compactAddLength } from '@polkadot/util'; import type { Registry } from '@polkadot/types-codec/types'; -import { trusted_operations } from '@litentry/parachain-api'; +import { trusted_operations, type Intent } from '@litentry/parachain-api'; import type { TrustedCall, LitentryIdentity, @@ -66,6 +66,12 @@ type SetIdentityNetworksParams = { hash: `0x${string}`; }; +// LitentryIdentity, Intent +type RequestIntentParams = { + who: LitentryIdentity; + intent: Intent; +}; + /** * Creates the TrustedCall for the given method and provide the `param's` types expected for them. * @@ -104,6 +110,13 @@ export async function createTrustedCallType( params: RequestBatchVcParams; } ): Promise<{ call: TrustedCall; key: CryptoKey }>; +export async function createTrustedCallType( + registry: Registry, + data: { + method: 'request_intent'; + params: RequestIntentParams; + } +): Promise<{ call: TrustedCall; key: CryptoKey }>; export async function createTrustedCallType( registry: Registry, data: { @@ -219,6 +232,19 @@ export async function createTrustedCallType( return { call, key }; } + if (isRequestIntentCall(method, params)) { + const { who, intent } = params; + + const call = registry.createType('TrustedCall', { + [trustedCallMethodsMap.request_intent]: registry.createType( + trusted_operations.types.TrustedCall._enum.request_intent, + [who, intent] + ), + }) as TrustedCall; + + return { call, key }; + } + throw new Error(`trusted call method: ${data.method} is not supported`); } @@ -253,3 +279,9 @@ function isRequestBatchVcCall( ): params is RequestBatchVcParams { return method === 'request_batch_vc'; } +function isRequestIntentCall( + method: TrustedCallMethod, + params: Record +): params is RequestIntentParams { + return method === 'request_intent'; +} From b4bf388f3ef86715d7a1ce3a8cdd054b8c8dea60 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Tue, 29 Oct 2024 21:42:11 -0500 Subject: [PATCH 03/15] update PalletTeebagEnclave to CorePrimitivesTeebagTypesEnclave Signed-off-by: Jonathan Alvarez --- .../src/lib/requests/get-last-registered-enclave.ts | 11 +++++++---- .../client-sdk/src/lib/vc-validator/validator.ts | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/get-last-registered-enclave.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/get-last-registered-enclave.ts index d903a1a60c..94cad65f97 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/get-last-registered-enclave.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/get-last-registered-enclave.ts @@ -1,8 +1,8 @@ import type { ApiPromise } from '@polkadot/api'; import { AccountId32 } from '@polkadot/types/interfaces'; import type { - PalletTeebagEnclave, - PalletTeebagWorkerType, + CorePrimitivesTeebagTypesEnclave, + CorePrimitivesTeebagTypesWorkerType, } from '@polkadot/types/lookup'; /** @@ -10,8 +10,11 @@ import type { */ export async function getLastRegisteredEnclave( api: ApiPromise, - workerType: PalletTeebagWorkerType['type'] = 'Identity' -): Promise<{ account: AccountId32; enclave: PalletTeebagEnclave }> { + workerType: CorePrimitivesTeebagTypesWorkerType['type'] = 'Identity' +): Promise<{ + account: AccountId32; + enclave: CorePrimitivesTeebagTypesEnclave; +}> { const identifiers = await api.query.teebag.enclaveIdentifier(workerType); const latestEnclaveId = identifiers[identifiers.length - 1]; diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/validator.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/validator.ts index 9df35ad019..70b7764da5 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/validator.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/validator.ts @@ -2,7 +2,7 @@ import { ApiPromise } from '@polkadot/api'; import { hexToU8a, stringToU8a } from '@polkadot/util'; import { base58Decode, signatureVerify } from '@polkadot/util-crypto'; -import type { PalletTeebagEnclave } from '@litentry/parachain-api'; +import type { CorePrimitivesTeebagTypesEnclave } from '@litentry/parachain-api'; import { RUNTIME_ENCLAVE_REGISTRY } from './runtime-enclave-registry'; @@ -298,8 +298,8 @@ export function validateVcWithTrustedTeeDevEnclave( api: ApiPromise, vc: VerifiableCredentialLike ): true | string { - const enclave: PalletTeebagEnclave = api.createType( - 'PalletTeebagEnclave', + const enclave: CorePrimitivesTeebagTypesEnclave = api.createType( + 'CorePrimitivesTeebagTypesEnclave', RUNTIME_ENCLAVE_REGISTRY ); From ee1dfd73793c7efb1ed248615f2cf566b99da813 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Tue, 29 Oct 2024 21:42:54 -0500 Subject: [PATCH 04/15] expose remark Signed-off-by: Jonathan Alvarez --- .../client-sdk/packages/client-sdk/src/lib/requests/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts index 4e974ad5ad..5ee9aaee36 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts @@ -2,6 +2,7 @@ export { createChallengeCode, linkIdentity } from './link-identity.request'; export { linkIdentityCallback } from './link-identity-callback.request'; export { setIdentityNetworks } from './set-identity-networks.request'; export { requestBatchVC } from './request-batch-vc.request'; +export { remark } from './remark.request'; export { getIdGraph } from './get-id-graph.request'; export { getIdGraphHash } from './get-id-graph-hash'; export { getLastRegisteredEnclave } from './get-last-registered-enclave'; From ae1066679b9d78a49e7717948f240d40c938f420 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Wed, 30 Oct 2024 22:58:48 -0500 Subject: [PATCH 05/15] client-sdk: add request.createAccountStore Signed-off-by: Jonathan Alvarez --- .../packages/client-sdk/CHANGELOG.md | 2 + .../packages/client-sdk/package.json | 4 +- .../requests/create-account-store.request.ts | 97 +++++++++++++++++++ .../client-sdk/src/lib/requests/index.ts | 1 + .../src/lib/type-creators/request.ts | 6 +- .../src/lib/type-creators/trusted-call.ts | 31 ++++++ tee-worker/identity/client-sdk/pnpm-lock.yaml | 16 +-- 7 files changed, 146 insertions(+), 11 deletions(-) create mode 100644 tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/create-account-store.request.ts diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md b/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md index 9409c9e713..9ba9ff5b8f 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md +++ b/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- Add a request method for OmniAccount's `Intent` requests. + ## 2024-10-14 Initial version. Merge [@litentry/enclave](https://www.npmjs.com/package/@litentry/enclave) and [@litentry/vc-sdk](https://www.npmjs.com/package/@litentry/vc-sdk) into this one. diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/package.json b/tee-worker/identity/client-sdk/packages/client-sdk/package.json index 41d2f880bf..9215311fb3 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/package.json +++ b/tee-worker/identity/client-sdk/packages/client-sdk/package.json @@ -8,8 +8,8 @@ "@polkadot/rpc-provider": "^10.9.1" }, "peerDependencies": { - "@litentry/parachain-api": "0.9.20-next.3", - "@litentry/sidechain-api": "0.9.20-next.3", + "@litentry/parachain-api": "0.9.20-next.4", + "@litentry/sidechain-api": "0.9.20-next.4", "@litentry/chaindata": "*", "@polkadot/api": "^10.9.1", "@polkadot/types": "^10.9.1", diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/create-account-store.request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/create-account-store.request.ts new file mode 100644 index 0000000000..3932dd96df --- /dev/null +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/create-account-store.request.ts @@ -0,0 +1,97 @@ +import { hexToU8a } from '@polkadot/util'; +import { randomAsHex } from '@polkadot/util-crypto'; + +import type { ApiPromise } from '@polkadot/api'; +import type { + LitentryIdentity, + WorkerRpcReturnValue, +} from '@litentry/parachain-api'; + +import { enclave } from '../enclave'; +import { createPayloadToSign } from '../util/create-payload-to-sign'; +import { createTrustedCallType } from '../type-creators/trusted-call'; +import { createRequestType } from '../type-creators/request'; + +import type { JsonRpcRequest } from '../util/types'; + +/** + * OmniAccount: Create the OmniAccount for the given Identity + */ +export async function createAccountStore( + /** Litentry Parachain API instance from Polkadot.js */ + api: ApiPromise, + data: { + /** The user's OmniAccount. Use `createLitentryIdentityType` helper to create this struct */ + omniAccount: LitentryIdentity; + /** The user's account. Use `createLitentryIdentityType` helper to create this struct */ + who: LitentryIdentity; + } +): Promise<{ + payloadToSign: string; + txHash: string; + send: (args: { signedPayload: string }) => Promise<{ + response: Array; + txHash: string; + }>; +}> { + const { who, omniAccount } = data; + + const shard = await enclave.getShard(api); + const shardU8 = hexToU8a(shard); + const txHash = randomAsHex(); + + const { call } = await createTrustedCallType(api.registry, { + method: 'create_account_store', + params: { + who, + }, + }); + + const nonce = await api.rpc.system.accountNextIndex( + omniAccount.asSubstrate.toHex() + ); + + const payloadToSign = createPayloadToSign({ + who, + call, + nonce, + shard: shardU8, + }); + + const send = async (args: { + signedPayload: string; + }): Promise<{ + response: Array; + txHash: string; + }> => { + // prepare and encrypt request + + const request = await createRequestType(api, { + signer: who, + signature: args.signedPayload, + call, + nonce, + shard: shardU8, + }); + + // send the request to the Enclave + const rpcRequest: JsonRpcRequest = { + jsonrpc: '2.0', + method: 'author_submitNativeRequest', + params: [request.toHex()], + }; + + const enclaveResult = await enclave.send(api, rpcRequest); + + return { + txHash, + response: enclaveResult, + }; + }; + + return { + txHash, + payloadToSign, + send, + }; +} diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts index 5ee9aaee36..cd57d34837 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts @@ -3,6 +3,7 @@ export { linkIdentityCallback } from './link-identity-callback.request'; export { setIdentityNetworks } from './set-identity-networks.request'; export { requestBatchVC } from './request-batch-vc.request'; export { remark } from './remark.request'; +export { createAccountStore } from './create-account-store.request'; export { getIdGraph } from './get-id-graph.request'; export { getIdGraphHash } from './get-id-graph-hash'; export { getLastRegisteredEnclave } from './get-last-registered-enclave'; diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/request.ts index 5300eb68df..8e9074244f 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/request.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/request.ts @@ -50,7 +50,7 @@ export async function createRequestType( let operationU8a = new Uint8Array(); - if (call.isRequestIntent) { + if (isNativeRequest(call)) { const callAuthenticated = api.createType('TrustedCallAuthenticated', { call, nonce, @@ -106,3 +106,7 @@ export async function createRequestType( payload: encryptedPayload, }); } + +function isNativeRequest(call: TrustedCall): boolean { + return call.isRequestIntent || call.isCreateAccountStore; +} diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/trusted-call.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/trusted-call.ts index aea76a0622..e4fdc3b413 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/trusted-call.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/trusted-call.ts @@ -72,6 +72,11 @@ type RequestIntentParams = { intent: Intent; }; +// LitentryIdentity +type RequestCreateAccountStoreParams = { + who: LitentryIdentity; +}; + /** * Creates the TrustedCall for the given method and provide the `param's` types expected for them. * @@ -117,6 +122,13 @@ export async function createTrustedCallType( params: RequestIntentParams; } ): Promise<{ call: TrustedCall; key: CryptoKey }>; +export async function createTrustedCallType( + registry: Registry, + data: { + method: 'create_account_store'; + params: RequestCreateAccountStoreParams; + } +): Promise<{ call: TrustedCall; key: CryptoKey }>; export async function createTrustedCallType( registry: Registry, data: { @@ -245,6 +257,19 @@ export async function createTrustedCallType( return { call, key }; } + if (isRequestCreateAccountStoreParams(method, params)) { + const { who } = params; + + const call = registry.createType('TrustedCall', { + [trustedCallMethodsMap.create_account_store]: registry.createType( + trusted_operations.types.TrustedCall._enum.create_account_store, + who + ), + }) as TrustedCall; + + return { call, key }; + } + throw new Error(`trusted call method: ${data.method} is not supported`); } @@ -285,3 +310,9 @@ function isRequestIntentCall( ): params is RequestIntentParams { return method === 'request_intent'; } +function isRequestCreateAccountStoreParams( + method: TrustedCallMethod, + params: Record +): params is RequestCreateAccountStoreParams { + return method === 'create_account_store'; +} diff --git a/tee-worker/identity/client-sdk/pnpm-lock.yaml b/tee-worker/identity/client-sdk/pnpm-lock.yaml index c411cd7d44..b663abdfb0 100644 --- a/tee-worker/identity/client-sdk/pnpm-lock.yaml +++ b/tee-worker/identity/client-sdk/pnpm-lock.yaml @@ -90,8 +90,8 @@ importers: packages/client-sdk: specifiers: '@litentry/chaindata': '*' - '@litentry/parachain-api': 0.9.20-next.3 - '@litentry/sidechain-api': 0.9.20-next.3 + '@litentry/parachain-api': 0.9.20-next.4 + '@litentry/sidechain-api': 0.9.20-next.4 '@polkadot/api': ^10.9.1 '@polkadot/rpc-provider': ^10.9.1 '@polkadot/types': ^10.9.1 @@ -101,8 +101,8 @@ importers: tslib: ^2.3.0 dependencies: '@litentry/chaindata': link:../chaindata - '@litentry/parachain-api': 0.9.20-next.3 - '@litentry/sidechain-api': 0.9.20-next.3 + '@litentry/parachain-api': 0.9.20-next.4 + '@litentry/sidechain-api': 0.9.20-next.4 '@polkadot/api': 10.13.1 '@polkadot/types': 10.13.1 '@polkadot/types-codec': 10.13.1 @@ -1741,8 +1741,8 @@ packages: '@jridgewell/resolve-uri': 3.1.1 '@jridgewell/sourcemap-codec': 1.4.15 - /@litentry/parachain-api/0.9.20-next.3: - resolution: {integrity: sha512-7C6RsxTec7rp6kxiQOoNipUS5Gr839is3Z7C/bHiOsA1CXyeYa1V0TtUqkPS5TU7ctNpxx5tZZcwS8nS5DF0VQ==} + /@litentry/parachain-api/0.9.20-next.4: + resolution: {integrity: sha512-qMHw4IPhhNrmoL7TXl6EDailkirXL3u3v3RRUMUBjmBHKbpN2XX/2d3c9ITCWkFCIMgKB+E7j6SOQ4AyjWD4hA==} dependencies: '@polkadot/api': 10.13.1 '@polkadot/api-augment': 10.13.1 @@ -1764,8 +1764,8 @@ packages: - utf-8-validate dev: false - /@litentry/sidechain-api/0.9.20-next.3: - resolution: {integrity: sha512-Uv2DpQQWhGt/jy1I+ZdAVb9butti11ZujEUMn3r40qULSBUiUZEUcxGy06KnaUkqqD7stLvNxTEgWMeABUPqzQ==} + /@litentry/sidechain-api/0.9.20-next.4: + resolution: {integrity: sha512-YQ2Ivmzl0v3jElK8sChayLrREcApT3piI4KixNZrjoGwbqz8qeN8OV4GJa6HjAgXGawo2VA9oy6uskZLBkWM1g==} dependencies: '@polkadot/api': 10.13.1 '@polkadot/api-augment': 10.13.1 From 1101b9f7ad7352cc406cc991746d9d557b3346c8 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Wed, 30 Oct 2024 23:00:25 -0500 Subject: [PATCH 06/15] remark: remove unused signer Signed-off-by: Jonathan Alvarez --- .../packages/client-sdk/src/lib/requests/remark.request.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/remark.request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/remark.request.ts index 84eb995f3f..667e53926d 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/remark.request.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/remark.request.ts @@ -21,8 +21,6 @@ export async function remark( /** Litentry Parachain API instance from Polkadot.js */ api: ApiPromise, data: { - /** The signer's account. Use `createLitentryIdentityType` helper to create this struct */ - signer?: LitentryIdentity; /** The user's account. Use `createLitentryIdentityType` helper to create this struct */ who: LitentryIdentity; /** the message to be sent */ @@ -42,10 +40,7 @@ export async function remark( const shardU8 = hexToU8a(shard); const txHash = randomAsHex(); - // identity to sign the requests - const signer = data.signer || who; - - const { call, key } = await createTrustedCallType(api.registry, { + const { call } = await createTrustedCallType(api.registry, { method: 'request_intent', params: { who, From 5405e685bee7fff1c8e556d7b5ae5f4900df152e Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Fri, 1 Nov 2024 17:24:49 -0500 Subject: [PATCH 07/15] remark: use omniAccount Signed-off-by: Jonathan Alvarez --- .../client-sdk/packages/client-sdk/src/index.ts | 4 ++-- .../client-sdk/src/lib/requests/remark.request.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/index.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/index.ts index 714c913dc8..dc81833719 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/index.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/index.ts @@ -19,9 +19,9 @@ export { ID_GRAPH_STRUCT } from './lib/type-creators/id-graph'; // vc export { validateVc, - VerifiableCredentialLike, + type VerifiableCredentialLike, } from './lib/vc-validator/validator'; -export { +export type { ValidationResultDetail, ValidationResult, } from './lib/vc-validator/validator.types'; diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/remark.request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/remark.request.ts index 667e53926d..831354ff7e 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/remark.request.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/remark.request.ts @@ -1,4 +1,4 @@ -import { hexToU8a, stringToHex } from '@polkadot/util'; +import { assert, hexToU8a, stringToHex } from '@polkadot/util'; import { randomAsHex } from '@polkadot/util-crypto'; import type { ApiPromise } from '@polkadot/api'; @@ -21,6 +21,8 @@ export async function remark( /** Litentry Parachain API instance from Polkadot.js */ api: ApiPromise, data: { + /** The user's omniAccount. Use `createLitentryIdentityType` helper to create this struct */ + omniAccount: LitentryIdentity; /** The user's account. Use `createLitentryIdentityType` helper to create this struct */ who: LitentryIdentity; /** the message to be sent */ @@ -34,7 +36,7 @@ export async function remark( txHash: string; }>; }> { - const { who, message } = data; + const { who, message, omniAccount } = data; const shard = await enclave.getShard(api); const shardU8 = hexToU8a(shard); @@ -50,8 +52,10 @@ export async function remark( }, }); + assert(omniAccount.isSubstrate, 'OmniAccount must be a Substrate identity'); + const nonce = await api.rpc.system.accountNextIndex( - who.asSubstrate.toHex() // who is OmniAccount, thus substrate + omniAccount.asSubstrate.toHex() ); const payloadToSign = createPayloadToSign({ From 1117d6317f14ea066c951dc5783b2520470962c1 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Fri, 1 Nov 2024 17:36:48 -0500 Subject: [PATCH 08/15] add request.transferNative Signed-off-by: Jonathan Alvarez --- .../packages/client-sdk/CHANGELOG.md | 2 +- .../client-sdk/src/lib/requests/index.ts | 2 + .../lib/requests/transfer-native.request.ts | 107 ++++++++++++++++++ 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/transfer-native.request.ts diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md b/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md index 9ba9ff5b8f..bb64dd8b14 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md +++ b/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Add a request method for OmniAccount's `Intent` requests. +- Add OmniAccount requestors for `remark`, `transferNative` ## 2024-10-14 diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts index cd57d34837..05f7d534b5 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts @@ -3,6 +3,8 @@ export { linkIdentityCallback } from './link-identity-callback.request'; export { setIdentityNetworks } from './set-identity-networks.request'; export { requestBatchVC } from './request-batch-vc.request'; export { remark } from './remark.request'; +export { transferNative } from './transfer-native.request'; + export { createAccountStore } from './create-account-store.request'; export { getIdGraph } from './get-id-graph.request'; export { getIdGraphHash } from './get-id-graph-hash'; diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/transfer-native.request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/transfer-native.request.ts new file mode 100644 index 0000000000..2a482084d9 --- /dev/null +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/transfer-native.request.ts @@ -0,0 +1,107 @@ +import { assert, hexToU8a } from '@polkadot/util'; +import { randomAsHex } from '@polkadot/util-crypto'; + +import type { ApiPromise } from '@polkadot/api'; +import type { + LitentryIdentity, + WorkerRpcReturnValue, +} from '@litentry/parachain-api'; + +import { enclave } from '../enclave'; +import { createPayloadToSign } from '../util/create-payload-to-sign'; +import { createTrustedCallType } from '../type-creators/trusted-call'; +import { createRequestType } from '../type-creators/request'; + +import type { JsonRpcRequest } from '../util/types'; + +/** + * OmniAccount: Transfer funds within the Litentry Network. + */ +export async function transferNative( + /** Litentry Parachain API instance from Polkadot.js */ + api: ApiPromise, + data: { + /** The user's omniAccount. Use `createLitentryIdentityType` helper to create this struct */ + omniAccount: LitentryIdentity; + /** The user's account. Use `createLitentryIdentityType` helper to create this struct */ + who: LitentryIdentity; + /** Account destination in hex or ss58 formatted address */ + to: string; + /** Amount to send */ + value: bigint; + } +): Promise<{ + payloadToSign: string; + txHash: string; + send: (args: { signedPayload: string }) => Promise<{ + response: Array; + txHash: string; + }>; +}> { + const { who, omniAccount } = data; + + assert(omniAccount.isSubstrate, 'OmniAccount must be a Substrate identity'); + + const shard = await enclave.getShard(api); + const shardU8 = hexToU8a(shard); + const txHash = randomAsHex(); + + const { call } = await createTrustedCallType(api.registry, { + method: 'request_intent', + params: { + who, + intent: api.createType('Intent', { + TransferNative: api.createType('IntentTransferNative', { + to: data.to, + value: data.value, + }), + }), + }, + }); + + const nonce = await api.rpc.system.accountNextIndex(omniAccount.asSubstrate); + + const payloadToSign = createPayloadToSign({ + who, + call, + nonce, + shard: shardU8, + }); + + const send = async (args: { + signedPayload: string; + }): Promise<{ + response: Array; + txHash: string; + }> => { + // prepare and encrypt request + + const request = await createRequestType(api, { + signer: who, + signature: args.signedPayload, + call, + nonce, + shard: shardU8, + }); + + // send the request to the Enclave + const rpcRequest: JsonRpcRequest = { + jsonrpc: '2.0', + method: 'author_submitNativeRequest', + params: [request.toHex()], + }; + + const enclaveResult = await enclave.send(api, rpcRequest); + + return { + txHash, + response: enclaveResult, + }; + }; + + return { + txHash, + payloadToSign, + send, + }; +} From ecaae8f4eac7371ae128a4fd7941bf7af2402bf3 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Fri, 1 Nov 2024 19:17:50 -0500 Subject: [PATCH 09/15] transfer: rename value to amount Signed-off-by: Jonathan Alvarez --- .../client-sdk/src/lib/requests/transfer-native.request.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/transfer-native.request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/transfer-native.request.ts index 2a482084d9..2aff5e2b63 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/transfer-native.request.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/transfer-native.request.ts @@ -28,7 +28,7 @@ export async function transferNative( /** Account destination in hex or ss58 formatted address */ to: string; /** Amount to send */ - value: bigint; + amount: bigint; } ): Promise<{ payloadToSign: string; @@ -53,7 +53,7 @@ export async function transferNative( intent: api.createType('Intent', { TransferNative: api.createType('IntentTransferNative', { to: data.to, - value: data.value, + value: data.amount, }), }), }, From 20ad85ad7c471858f6a374d4d705377fc1138db7 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Tue, 5 Nov 2024 10:39:23 -0500 Subject: [PATCH 10/15] add request.transferEthereum Signed-off-by: Jonathan Alvarez --- .../client-sdk/src/lib/requests/index.ts | 1 + .../lib/requests/transfer-ethereum.request.ts | 107 ++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/transfer-ethereum.request.ts diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts index 05f7d534b5..2e04ec1ccc 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts @@ -4,6 +4,7 @@ export { setIdentityNetworks } from './set-identity-networks.request'; export { requestBatchVC } from './request-batch-vc.request'; export { remark } from './remark.request'; export { transferNative } from './transfer-native.request'; +export { transferEthereum } from './transfer-ethereum.request'; export { createAccountStore } from './create-account-store.request'; export { getIdGraph } from './get-id-graph.request'; diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/transfer-ethereum.request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/transfer-ethereum.request.ts new file mode 100644 index 0000000000..f880b281b7 --- /dev/null +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/transfer-ethereum.request.ts @@ -0,0 +1,107 @@ +import { assert, hexToU8a } from '@polkadot/util'; +import { randomAsHex } from '@polkadot/util-crypto'; + +import type { ApiPromise } from '@polkadot/api'; +import type { + LitentryIdentity, + WorkerRpcReturnValue, +} from '@litentry/parachain-api'; + +import { enclave } from '../enclave'; +import { createPayloadToSign } from '../util/create-payload-to-sign'; +import { createTrustedCallType } from '../type-creators/trusted-call'; +import { createRequestType } from '../type-creators/request'; + +import type { JsonRpcRequest } from '../util/types'; + +/** + * OmniAccount: Transfer funds to Ethereum Network. + */ +export async function transferEthereum( + /** Litentry Parachain API instance from Polkadot.js */ + api: ApiPromise, + data: { + /** The user's omniAccount. Use `createLitentryIdentityType` helper to create this struct */ + omniAccount: LitentryIdentity; + /** The user's account. Use `createLitentryIdentityType` helper to create this struct */ + who: LitentryIdentity; + /** Ethereum address destination */ + to: string; + /** Amount to send */ + amount: bigint; + } +): Promise<{ + payloadToSign: string; + txHash: string; + send: (args: { signedPayload: string }) => Promise<{ + response: Array; + txHash: string; + }>; +}> { + const { who, omniAccount } = data; + + assert(omniAccount.isSubstrate, 'OmniAccount must be a Substrate identity'); + + const shard = await enclave.getShard(api); + const shardU8 = hexToU8a(shard); + const txHash = randomAsHex(); + + const { call } = await createTrustedCallType(api.registry, { + method: 'request_intent', + params: { + who, + intent: api.createType('Intent', { + TransferEthereum: api.createType('IntentTransferEthereum', { + to: data.to, + value: data.amount, + }), + }), + }, + }); + + const nonce = await api.rpc.system.accountNextIndex(omniAccount.asSubstrate); + + const payloadToSign = createPayloadToSign({ + who, + call, + nonce, + shard: shardU8, + }); + + const send = async (args: { + signedPayload: string; + }): Promise<{ + response: Array; + txHash: string; + }> => { + // prepare and encrypt request + + const request = await createRequestType(api, { + signer: who, + signature: args.signedPayload, + call, + nonce, + shard: shardU8, + }); + + // send the request to the Enclave + const rpcRequest: JsonRpcRequest = { + jsonrpc: '2.0', + method: 'author_submitNativeRequest', + params: [request.toHex()], + }; + + const enclaveResult = await enclave.send(api, rpcRequest); + + return { + txHash, + response: enclaveResult, + }; + }; + + return { + txHash, + payloadToSign, + send, + }; +} From fe78dde48cc2053a72e69f1b0d5aafcc2816d86c Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Tue, 5 Nov 2024 10:41:59 -0500 Subject: [PATCH 11/15] add request.callEthereum Signed-off-by: Jonathan Alvarez --- .../src/lib/requests/call-ethereum.request.ts | 108 ++++++++++++++++++ .../client-sdk/src/lib/requests/index.ts | 1 + 2 files changed, 109 insertions(+) create mode 100644 tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/call-ethereum.request.ts diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/call-ethereum.request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/call-ethereum.request.ts new file mode 100644 index 0000000000..ca0ebc7ea0 --- /dev/null +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/call-ethereum.request.ts @@ -0,0 +1,108 @@ +import { assert, hexToU8a } from '@polkadot/util'; +import { randomAsHex } from '@polkadot/util-crypto'; + +import type { ApiPromise } from '@polkadot/api'; +import type { + LitentryIdentity, + WorkerRpcReturnValue, +} from '@litentry/parachain-api'; + +import { enclave } from '../enclave'; +import { createPayloadToSign } from '../util/create-payload-to-sign'; +import { createTrustedCallType } from '../type-creators/trusted-call'; +import { createRequestType } from '../type-creators/request'; + +import type { JsonRpcRequest } from '../util/types'; +import type { U8aLike } from '@polkadot/util/types'; + +/** + * OmniAccount: Call an Ethereum contract. + */ +export async function callEthereum( + /** Litentry Parachain API instance from Polkadot.js */ + api: ApiPromise, + data: { + /** The user's omniAccount. Use `createLitentryIdentityType` helper to create this struct */ + omniAccount: LitentryIdentity; + /** The user's account. Use `createLitentryIdentityType` helper to create this struct */ + who: LitentryIdentity; + /** Ethereum contract address */ + address: string; + /** Contract input data */ + input: U8aLike; + } +): Promise<{ + payloadToSign: string; + txHash: string; + send: (args: { signedPayload: string }) => Promise<{ + response: Array; + txHash: string; + }>; +}> { + const { who, omniAccount } = data; + + assert(omniAccount.isSubstrate, 'OmniAccount must be a Substrate identity'); + + const shard = await enclave.getShard(api); + const shardU8 = hexToU8a(shard); + const txHash = randomAsHex(); + + const { call } = await createTrustedCallType(api.registry, { + method: 'request_intent', + params: { + who, + intent: api.createType('Intent', { + CallEthereum: api.createType('IntentCallEthereum', { + address: data.address, + input: data.input, + }), + }), + }, + }); + + const nonce = await api.rpc.system.accountNextIndex(omniAccount.asSubstrate); + + const payloadToSign = createPayloadToSign({ + who, + call, + nonce, + shard: shardU8, + }); + + const send = async (args: { + signedPayload: string; + }): Promise<{ + response: Array; + txHash: string; + }> => { + // prepare and encrypt request + + const request = await createRequestType(api, { + signer: who, + signature: args.signedPayload, + call, + nonce, + shard: shardU8, + }); + + // send the request to the Enclave + const rpcRequest: JsonRpcRequest = { + jsonrpc: '2.0', + method: 'author_submitNativeRequest', + params: [request.toHex()], + }; + + const enclaveResult = await enclave.send(api, rpcRequest); + + return { + txHash, + response: enclaveResult, + }; + }; + + return { + txHash, + payloadToSign, + send, + }; +} diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts index 2e04ec1ccc..3d08758f77 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts @@ -5,6 +5,7 @@ export { requestBatchVC } from './request-batch-vc.request'; export { remark } from './remark.request'; export { transferNative } from './transfer-native.request'; export { transferEthereum } from './transfer-ethereum.request'; +export { callEthereum } from './call-ethereum.request'; export { createAccountStore } from './create-account-store.request'; export { getIdGraph } from './get-id-graph.request'; From 9928c0ec93d547284a95ec0a2841ea84093ca76c Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Tue, 5 Nov 2024 10:44:27 -0500 Subject: [PATCH 12/15] update changelog Signed-off-by: Jonathan Alvarez --- tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md b/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md index bb64dd8b14..e2db89cd2f 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md +++ b/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Add OmniAccount requestors for `remark`, `transferNative` +- Add OmniAccount requestors for `createAccountStore`, `remark`, `transferNative`, `transferEthereum`, and `callEthereum`. ## 2024-10-14 From 6a6153b49aaea161c82ee676fa8ed8860d6b45aa Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Tue, 5 Nov 2024 10:45:08 -0500 Subject: [PATCH 13/15] bump version to preview .0 Signed-off-by: Jonathan Alvarez --- tee-worker/identity/client-sdk/packages/client-sdk/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/package.json b/tee-worker/identity/client-sdk/packages/client-sdk/package.json index 9215311fb3..7eaa6fb07d 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/package.json +++ b/tee-worker/identity/client-sdk/packages/client-sdk/package.json @@ -1,7 +1,7 @@ { "name": "@litentry/client-sdk", "description": "This package provides helpers for dApps to interact with the Litentry Protocol.", - "version": "1.0.0", + "version": "1.0.0-next.0", "license": "GPL-3.0-or-later", "dependencies": {}, "devDependencies": { From a4e803fad6761225743ac407f9bbb51e2b79aff2 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Tue, 5 Nov 2024 10:47:11 -0500 Subject: [PATCH 14/15] client-api: update readme Signed-off-by: Jonathan Alvarez --- .../identity/client-api/parachain-api/README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tee-worker/identity/client-api/parachain-api/README.md b/tee-worker/identity/client-api/parachain-api/README.md index e301ec6e1d..ee44e92b6b 100644 --- a/tee-worker/identity/client-api/parachain-api/README.md +++ b/tee-worker/identity/client-api/parachain-api/README.md @@ -15,9 +15,15 @@ These types were auto generated using [Polkadot.js Type Generation](https://polk 2. Extend and decorate the API's types with: ```typescript - import { identity, vc, trusted_operations, sidechain } from "parachain-api"; - - const types = { ...identity.types, ...vc.types, ...trusted_operations.types, ...sidechain.types }; + import { identity, vc, trusted_operations, sidechain, omniAccount } from "parachain-api"; + + const types = { + ...identity.types, + ...vc.types, + ...omniAccount.types, + ...trusted_operations.types, + ...sidechain.types, + }; const api = await ApiPromise.create({ provider, From 0c21ef8756a7fbc4179abc41be3fcf45141b8749 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Wed, 6 Nov 2024 12:08:48 -0500 Subject: [PATCH 15/15] use client-api 0.9.20-next.5 Signed-off-by: Jonathan Alvarez --- .../client-sdk/packages/client-sdk/package.json | 4 ++-- tee-worker/identity/client-sdk/pnpm-lock.yaml | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/package.json b/tee-worker/identity/client-sdk/packages/client-sdk/package.json index 7eaa6fb07d..c38531fcfd 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/package.json +++ b/tee-worker/identity/client-sdk/packages/client-sdk/package.json @@ -8,8 +8,8 @@ "@polkadot/rpc-provider": "^10.9.1" }, "peerDependencies": { - "@litentry/parachain-api": "0.9.20-next.4", - "@litentry/sidechain-api": "0.9.20-next.4", + "@litentry/parachain-api": "0.9.20-next.5", + "@litentry/sidechain-api": "0.9.20-next.5", "@litentry/chaindata": "*", "@polkadot/api": "^10.9.1", "@polkadot/types": "^10.9.1", diff --git a/tee-worker/identity/client-sdk/pnpm-lock.yaml b/tee-worker/identity/client-sdk/pnpm-lock.yaml index b663abdfb0..421e70eff3 100644 --- a/tee-worker/identity/client-sdk/pnpm-lock.yaml +++ b/tee-worker/identity/client-sdk/pnpm-lock.yaml @@ -90,8 +90,8 @@ importers: packages/client-sdk: specifiers: '@litentry/chaindata': '*' - '@litentry/parachain-api': 0.9.20-next.4 - '@litentry/sidechain-api': 0.9.20-next.4 + '@litentry/parachain-api': 0.9.20-next.5 + '@litentry/sidechain-api': 0.9.20-next.5 '@polkadot/api': ^10.9.1 '@polkadot/rpc-provider': ^10.9.1 '@polkadot/types': ^10.9.1 @@ -101,8 +101,8 @@ importers: tslib: ^2.3.0 dependencies: '@litentry/chaindata': link:../chaindata - '@litentry/parachain-api': 0.9.20-next.4 - '@litentry/sidechain-api': 0.9.20-next.4 + '@litentry/parachain-api': 0.9.20-next.5 + '@litentry/sidechain-api': 0.9.20-next.5 '@polkadot/api': 10.13.1 '@polkadot/types': 10.13.1 '@polkadot/types-codec': 10.13.1 @@ -1741,8 +1741,8 @@ packages: '@jridgewell/resolve-uri': 3.1.1 '@jridgewell/sourcemap-codec': 1.4.15 - /@litentry/parachain-api/0.9.20-next.4: - resolution: {integrity: sha512-qMHw4IPhhNrmoL7TXl6EDailkirXL3u3v3RRUMUBjmBHKbpN2XX/2d3c9ITCWkFCIMgKB+E7j6SOQ4AyjWD4hA==} + /@litentry/parachain-api/0.9.20-next.5: + resolution: {integrity: sha512-FnK4Jb/i2+sV0V0qy4iT7aswk8JzOXDtyW76VGVFva5vb7IXEz9TC4CmEKFTVE1o0mvBB8+eRbu2HYliq/3i4w==} dependencies: '@polkadot/api': 10.13.1 '@polkadot/api-augment': 10.13.1 @@ -1764,8 +1764,8 @@ packages: - utf-8-validate dev: false - /@litentry/sidechain-api/0.9.20-next.4: - resolution: {integrity: sha512-YQ2Ivmzl0v3jElK8sChayLrREcApT3piI4KixNZrjoGwbqz8qeN8OV4GJa6HjAgXGawo2VA9oy6uskZLBkWM1g==} + /@litentry/sidechain-api/0.9.20-next.5: + resolution: {integrity: sha512-wJTsPq9DJGSD2PSpR4AFdAmta/RDR/L2iAUnMQxYd49H/a1Pl/X6X7Ml50QR9OIftJLfah0SIwlKhdsMaOenvg==} dependencies: '@polkadot/api': 10.13.1 '@polkadot/api-augment': 10.13.1