@account-kit/wallet-client 0.1.0-alpha.2 → 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/capabilities/index.d.ts +5 -2
- package/dist/esm/capabilities/index.js +1 -1
- package/dist/esm/capabilities/index.js.map +1 -1
- package/dist/esm/capabilities/overrides.js +8 -8
- package/dist/esm/capabilities/overrides.js.map +1 -1
- package/dist/esm/capabilities/permissions/index.d.ts +10 -3
- package/dist/esm/capabilities/permissions/index.js +11 -2
- package/dist/esm/capabilities/permissions/index.js.map +1 -1
- package/dist/esm/capabilities/permissions/mav2.d.ts +2 -2
- package/dist/esm/capabilities/permissions/mav2.js +9 -1
- package/dist/esm/capabilities/permissions/mav2.js.map +1 -1
- package/dist/esm/client/actions/grantPermissions.d.ts +57 -3
- package/dist/esm/client/actions/grantPermissions.js +1 -0
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/requestAccount.js +2 -2
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/actions/signSignatureRequest.d.ts +4 -1
- package/dist/esm/client/actions/signSignatureRequest.js +22 -1
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/client.e2e-test.js +13 -19
- package/dist/esm/client/client.e2e-test.js.map +1 -1
- package/dist/esm/client/index.d.ts +4 -3
- package/dist/esm/client/index.js +2 -2
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/exports/index.d.ts +2 -2
- package/dist/esm/exports/index.js +1 -1
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/isomorphic/actions/createSession.js +25 -7
- package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
- package/dist/esm/isomorphic/actions/prepareCalls.js +35 -12
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +26 -6
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/isomorphic/client.d.ts +11 -5
- package/dist/esm/isomorphic/utils/7702.d.ts +11 -0
- package/dist/esm/isomorphic/utils/7702.js +26 -0
- package/dist/esm/isomorphic/utils/7702.js.map +1 -0
- package/dist/esm/isomorphic/utils/createAccount.d.ts +2 -1
- package/dist/esm/isomorphic/utils/createAccount.js +30 -5
- package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
- package/dist/esm/isomorphic/utils/createDummySigner.js +3 -3
- package/dist/esm/isomorphic/utils/createDummySigner.js.map +1 -1
- package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +2 -1
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js +17 -5
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
- package/dist/esm/local/client.js +2 -1
- package/dist/esm/local/client.js.map +1 -1
- package/dist/esm/remote/client.js +6 -2
- package/dist/esm/remote/client.js.map +1 -1
- package/dist/esm/rpc/examples.d.ts +230 -0
- package/dist/esm/rpc/examples.js +314 -0
- package/dist/esm/rpc/examples.js.map +1 -0
- package/dist/esm/rpc/request.d.ts +48 -17
- package/dist/esm/rpc/request.js +53 -14
- package/dist/esm/rpc/request.js.map +1 -1
- package/dist/esm/rpc/schema.d.ts +42 -11
- package/dist/esm/schemas.d.ts +29 -7
- package/dist/esm/schemas.js +120 -38
- package/dist/esm/schemas.js.map +1 -1
- package/dist/types/capabilities/index.d.ts +5 -2
- package/dist/types/capabilities/index.d.ts.map +1 -1
- package/dist/types/capabilities/overrides.d.ts.map +1 -1
- package/dist/types/capabilities/permissions/index.d.ts +10 -3
- package/dist/types/capabilities/permissions/index.d.ts.map +1 -1
- package/dist/types/capabilities/permissions/mav2.d.ts +2 -2
- package/dist/types/capabilities/permissions/mav2.d.ts.map +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts +57 -3
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts +4 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +4 -3
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +2 -2
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/client.d.ts +11 -5
- package/dist/types/isomorphic/client.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/7702.d.ts +12 -0
- package/dist/types/isomorphic/utils/7702.d.ts.map +1 -0
- package/dist/types/isomorphic/utils/createAccount.d.ts +2 -1
- package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +2 -1
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
- package/dist/types/remote/client.d.ts.map +1 -1
- package/dist/types/rpc/examples.d.ts +231 -0
- package/dist/types/rpc/examples.d.ts.map +1 -0
- package/dist/types/rpc/request.d.ts +48 -17
- package/dist/types/rpc/request.d.ts.map +1 -1
- package/dist/types/rpc/schema.d.ts +42 -11
- package/dist/types/rpc/schema.d.ts.map +1 -1
- package/dist/types/schemas.d.ts +29 -7
- package/dist/types/schemas.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/capabilities/index.ts +5 -8
- package/src/capabilities/overrides.ts +23 -8
- package/src/capabilities/permissions/index.ts +21 -5
- package/src/capabilities/permissions/mav2.ts +12 -2
- package/src/client/actions/grantPermissions.ts +57 -3
- package/src/client/actions/requestAccount.ts +2 -3
- package/src/client/actions/signSignatureRequest.ts +31 -3
- package/src/client/client.e2e-test.ts +14 -21
- package/src/client/index.ts +12 -10
- package/src/exports/index.ts +2 -1
- package/src/isomorphic/actions/createSession.ts +28 -7
- package/src/isomorphic/actions/prepareCalls.ts +38 -11
- package/src/isomorphic/actions/sendPreparedCalls.ts +47 -20
- package/src/isomorphic/utils/7702.ts +58 -0
- package/src/isomorphic/utils/createAccount.ts +38 -6
- package/src/isomorphic/utils/createDummySigner.ts +3 -2
- package/src/isomorphic/utils/parsePermissionsContext.ts +23 -7
- package/src/local/client.ts +2 -3
- package/src/remote/client.ts +12 -2
- package/src/rpc/examples.ts +343 -0
- package/src/rpc/request.ts +75 -26
- package/src/schemas.ts +218 -87
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.e2e-test.js","sourceRoot":"","sources":["../../../src/client/client.e2e-test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAgB,MAAM,MAAM,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,MAAM,SAAS,GAAG,OAAO,CACvB,OAAO,CAAC,GAAG,CAAC,qBAAqB;QAC/B,CAAC,CAAC;YACE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;SAC1C;QACH,CAAC,CAAC;YACE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAqB;SAC1C,CACN,CAAC;IACF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,MAAM,GAAG,kBAAkB,CAAC,yBAAyB,CACzD,oEAAoE,CACrE,CAAC;QAEF,MAAM,MAAM,GAAG,uBAAuB,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D;YACD,EAAE,EAAE;gBACF,IAAI,EAAE,KAAK;gBACX,MAAM,EAAE,4CAA4C;aACrD;YACD,QAAQ,EAAE,aAAa;SACxB;KACO,CAAC;AACb,CAAC,CAAC,CAAC","sourcesContent":["import { LocalAccountSigner } from \"@aa-sdk/core\";\nimport { alchemy, arbitrumSepolia } from \"@account-kit/infra\";\nimport { describe, expect, it } from \"bun:test\";\nimport { createPublicClient, zeroAddress, type Address } from \"viem\";\nimport { signSignatureRequest } from \"./actions/signSignatureRequest.js\";\nimport { createSmartWalletClient } from \"./index.js\";\n\ndescribe(\"Client E2E Tests\", () => {\n const transport = alchemy(\n process.env.ALCHEMY_PROXY_RPC_URL\n ? {\n rpcUrl: process.env.ALCHEMY_PROXY_RPC_URL,\n }\n : {\n apiKey: process.env.TEST_ALCHEMY_API_KEY!,\n },\n );\n describe(\"Local Mode Tests\", () => {\n const signer = LocalAccountSigner.privateKeyToAccountSigner(\n \"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff81\",\n );\n\n const client = createSmartWalletClient({\n transport,\n chain: arbitrumSepolia,\n mode: \"local\",\n signer,\n });\n\n const publicClient = createPublicClient({\n chain: arbitrumSepolia,\n transport,\n });\n\n it(\"should successfully request account with different salt\", async () => {\n const account = await client.requestAccount({\n id: \"2d00c64e-2e55-4925-832e-e288dbf1139e\",\n creationHint: { salt: \"0x1\" },\n });\n\n expect(account.address).toMatchInlineSnapshot(\n `\"0x569bCECaC47Ef9706c4b2370f2891bccd4cdE30c\"`,\n );\n });\n\n it(\"should not cache account if different inputs provided\", async () => {\n const account = await client.requestAccount();\n const account2 = await client.requestAccount({\n id: \"2d00c64e-2e55-4925-832e-e288dbf1139e\",\n creationHint: { salt: \"0x1\" },\n });\n\n expect(account.address).not.toEqual(account2.address);\n });\n\n it(\"should successfully get a counterfactual address\", async () => {\n const account = await client.requestAccount();\n expect(account.address).toMatchInlineSnapshot(\n `\"0x26809de7733F9CcB5c0c61210a4f78d6F1daFc58\"`,\n );\n });\n\n it(\"can correctly sign a message\", async () => {\n const account = await client.requestAccount();\n const message = \"hello world\";\n const signature = await client.signMessage({ message });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message,\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data\", async () => {\n const account = await client.requestAccount();\n const signature = await client.signTypedData(givenTypedData);\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign a message with a different account\", async () => {\n const account = await client.requestAccount({\n id: \"2d00c64e-2e55-4925-832e-e288dbf1139e\",\n creationHint: { salt: \"0x1\" },\n });\n const message = \"hello world\";\n\n const signature = await client.signMessage({\n message,\n account: account.address,\n });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message,\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data with a different account\", async () => {\n const account = await client.requestAccount({\n id: \"2d00c64e-2e55-4925-832e-e288dbf1139e\",\n creationHint: { salt: \"0x1\" },\n });\n\n const signature = await client.signTypedData({\n ...givenTypedData,\n account: account.address,\n });\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"should successfully send a UO with paymaster\", async () => {\n const account = await client.requestAccount();\n const preparedUO = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n },\n });\n\n if (preparedUO.signatureRequest.type !== \"personal_sign\") {\n throw new Error(\"Invalid signature request type\");\n }\n\n const signature = await signer.signMessage(\n preparedUO.signatureRequest.data,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedUO,\n signature: {\n type: \"ecdsa\",\n signature,\n },\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n\n it(\"should successfully create a session with grantPermissions and send a UO\", async () => {\n const account = await client.requestAccount();\n\n const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n\n const permissions = await client.grantPermissions({\n account: account.address,\n expiry: Math.floor(Date.now() / 1000) + 60 * 60,\n key: {\n publicKey: await sessionKey.getAddress(),\n type: \"secp256k1\",\n },\n permissions: [{ type: \"root\" }],\n });\n\n const preparedUO = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n permissions,\n },\n });\n\n const signature = await signSignatureRequest(\n sessionKey,\n preparedUO.signatureRequest,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedUO,\n signature,\n capabilities: {\n permissions,\n },\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n });\n\n describe(\"Remote Mode Tests\", () => {\n const signer = LocalAccountSigner.privateKeyToAccountSigner(\n \"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80\",\n );\n\n const client = createSmartWalletClient({\n transport,\n chain: arbitrumSepolia,\n mode: \"remote\",\n signer,\n });\n\n const publicClient = createPublicClient({\n chain: arbitrumSepolia,\n transport,\n });\n\n it(\"should successfully get a counterfactual address\", async () => {\n const account = await client.requestAccount();\n expect(account.address).toMatchInlineSnapshot(\n `\"0x65b5DE0251f553B2208762a4724303E750294D96\"`,\n );\n });\n\n it(\"should successfully request account with different salt\", async () => {\n const account = await client.requestAccount({\n id: \"8670d2d8-2781-49e9-a75c-1eb980271ca9\",\n creationHint: { salt: \"0x1\" },\n });\n\n expect(account.address).toMatchInlineSnapshot(\n `\"0xC9B8271E44f14be83CecfDE1dDb325e9fa15e9Ff\"`,\n );\n });\n\n it(\"should not cache account if different inputs provided\", async () => {\n const account = await client.requestAccount();\n const account2 = await client.requestAccount({\n id: \"8670d2d8-2781-49e9-a75c-1eb980271ca9\",\n creationHint: { salt: \"0x1\" },\n });\n\n expect(account.address).not.toEqual(account2.address);\n });\n\n it(\"can correctly sign a message\", async () => {\n const account = await client.requestAccount();\n const message = \"hello world\";\n const signature = await client.signMessage({ message });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message: \"hello world\",\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data\", async () => {\n const account = await client.requestAccount();\n const signature = await client.signTypedData(givenTypedData);\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign a message with a different account\", async () => {\n const account = await client.requestAccount({\n id: \"8670d2d8-2781-49e9-a75c-1eb980271ca9\",\n creationHint: { salt: \"0x1\" },\n });\n\n const message = \"hello world\";\n const signature = await client.signMessage({\n message,\n account: account.address,\n });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message: \"hello world\",\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data with a different account\", async () => {\n const account = await client.requestAccount({\n id: \"8670d2d8-2781-49e9-a75c-1eb980271ca9\",\n creationHint: { salt: \"0x1\" },\n });\n\n const signature = await client.signTypedData({\n ...givenTypedData,\n account: account.address,\n });\n\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"should successfully send a UO with paymaster\", async () => {\n const account = await client.requestAccount();\n const preparedUO = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n },\n });\n\n const signature = await client.signSignatureRequest(\n preparedUO.signatureRequest,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedUO,\n signature,\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n\n it(\"should successfully create a session with grantPermissions and send a UO\", async () => {\n const account = await client.requestAccount();\n\n const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n\n const permissions = await client.grantPermissions({\n account: account.address,\n expiry: Math.floor(Date.now() / 1000) + 60 * 60,\n key: {\n publicKey: await sessionKey.getAddress(),\n type: \"secp256k1\",\n },\n permissions: [{ type: \"root\" }],\n });\n\n const preparedUO = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n permissions,\n },\n });\n\n const signature = await signSignatureRequest(\n sessionKey,\n preparedUO.signatureRequest,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedUO,\n signature,\n capabilities: {\n permissions,\n },\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n });\n\n const givenTypedData = {\n types: {\n Person: [\n { name: \"name\", type: \"string\" },\n { name: \"wallet\", type: \"address\" },\n ],\n Mail: [\n { name: \"from\", type: \"Person\" },\n { name: \"to\", type: \"Person\" },\n { name: \"contents\", type: \"string\" },\n ],\n },\n primaryType: \"Mail\" as const,\n domain: {\n name: \"Ether Mail\",\n version: \"1\",\n chainId: 1,\n verifyingContract:\n \"0xbbc68f94D29d52EE8D4994E54d6ED0fEAeb99C2c\" as Address,\n },\n message: {\n from: {\n name: \"Alice\",\n wallet: \"0xFC24e57486116026740634F629ffC4E5C95A6893\",\n },\n to: {\n name: \"Bob\",\n wallet: \"0xe7a26f006EAA562308C5df235C02BFB9a5849177\",\n },\n contents: \"Hello, Bob!\",\n },\n } as const;\n});\n"]}
|
|
1
|
+
{"version":3,"file":"client.e2e-test.js","sourceRoot":"","sources":["../../../src/client/client.e2e-test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,kBAAkB,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AAE;gBAChC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC9B,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE;aACrC;SACF;QACD,WAAW,EAAE,MAAe;QAC5B,MAAM,EAAE;YACN,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,GAAG;YACZ,OAAO,EAAE,CAAC;YACV,iBAAiB,EACf,4CAAuD;SAC1D;QACD,OAAO,EAAE;YACP,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,4CAA4C;aACrD;YACD,EAAE,EAAE;gBACF,IAAI,EAAE,KAAK;gBACX,MAAM,EAAE,4CAA4C;aACrD;YACD,QAAQ,EAAE,aAAa;SACxB;KACO,CAAC;AACb,CAAC,CAAC,CAAC","sourcesContent":["import { LocalAccountSigner } from \"@aa-sdk/core\";\nimport { alchemy, arbitrumSepolia } from \"@account-kit/infra\";\nimport { describe, expect, it } from \"bun:test\";\nimport { createPublicClient, zeroAddress, type Address } from \"viem\";\nimport { signSignatureRequest } from \"./actions/signSignatureRequest.js\";\nimport { createSmartWalletClient } from \"./index.js\";\n\ndescribe(\"Client E2E Tests\", () => {\n const transport = alchemy(\n process.env.ALCHEMY_PROXY_RPC_URL\n ? {\n rpcUrl: process.env.ALCHEMY_PROXY_RPC_URL,\n }\n : {\n apiKey: process.env.TEST_ALCHEMY_API_KEY!,\n },\n );\n describe(\"Local Mode Tests\", () => {\n const signer = LocalAccountSigner.privateKeyToAccountSigner(\n \"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff81\",\n );\n\n const client = createSmartWalletClient({\n transport,\n chain: arbitrumSepolia,\n mode: \"local\",\n signer,\n });\n\n const publicClient = createPublicClient({\n chain: arbitrumSepolia,\n transport,\n });\n\n it(\"should successfully request account with different salt\", async () => {\n const account = await client.requestAccount({\n id: \"2d00c64e-2e55-4925-832e-e288dbf1139e\",\n creationHint: { salt: \"0x1\" },\n });\n\n expect(account.address).toMatchInlineSnapshot(\n `\"0x569bCECaC47Ef9706c4b2370f2891bccd4cdE30c\"`,\n );\n });\n\n it(\"should not cache account if different inputs provided\", async () => {\n const account = await client.requestAccount();\n const account2 = await client.requestAccount({\n id: \"2d00c64e-2e55-4925-832e-e288dbf1139e\",\n creationHint: { salt: \"0x1\" },\n });\n\n expect(account.address).not.toEqual(account2.address);\n });\n\n it(\"should successfully get a counterfactual address\", async () => {\n const account = await client.requestAccount();\n expect(account.address).toMatchInlineSnapshot(\n `\"0x26809de7733F9CcB5c0c61210a4f78d6F1daFc58\"`,\n );\n });\n\n it(\"can correctly sign a message\", async () => {\n const account = await client.requestAccount();\n const message = \"hello world\";\n const signature = await client.signMessage({ message });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message,\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data\", async () => {\n const account = await client.requestAccount();\n const signature = await client.signTypedData(givenTypedData);\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign a message with a different account\", async () => {\n const account = await client.requestAccount({\n id: \"2d00c64e-2e55-4925-832e-e288dbf1139e\",\n creationHint: { salt: \"0x1\" },\n });\n const message = \"hello world\";\n\n const signature = await client.signMessage({\n message,\n account: account.address,\n });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message,\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data with a different account\", async () => {\n const account = await client.requestAccount({\n id: \"2d00c64e-2e55-4925-832e-e288dbf1139e\",\n creationHint: { salt: \"0x1\" },\n });\n\n const signature = await client.signTypedData({\n ...givenTypedData,\n account: account.address,\n });\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"should successfully send a UO with paymaster\", async () => {\n const account = await client.requestAccount();\n const preparedCall = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n },\n });\n\n const signature = await client.signSignatureRequest(\n preparedCall.signatureRequest,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedCall,\n signature,\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n\n it(\"should successfully create a session with grantPermissions and send a UO\", async () => {\n const account = await client.requestAccount();\n\n const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n\n const permissions = await client.grantPermissions({\n account: account.address,\n expiry: Math.floor(Date.now() / 1000) + 60 * 60,\n key: {\n publicKey: await sessionKey.getAddress(),\n type: \"secp256k1\",\n },\n permissions: [{ type: \"root\" }],\n });\n\n const preparedCall = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n permissions,\n },\n });\n\n const signature = await signSignatureRequest(\n sessionKey,\n preparedCall.signatureRequest,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedCall,\n signature,\n capabilities: {\n permissions,\n },\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n });\n\n describe(\"Remote Mode Tests\", () => {\n const signer = LocalAccountSigner.privateKeyToAccountSigner(\n \"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80\",\n );\n\n const client = createSmartWalletClient({\n transport,\n chain: arbitrumSepolia,\n mode: \"remote\",\n signer,\n });\n\n const publicClient = createPublicClient({\n chain: arbitrumSepolia,\n transport,\n });\n\n it(\"should successfully get a counterfactual address\", async () => {\n const account = await client.requestAccount();\n expect(account.address).toMatchInlineSnapshot(\n `\"0x65b5DE0251f553B2208762a4724303E750294D96\"`,\n );\n });\n\n it(\"should successfully request account with different salt\", async () => {\n const account = await client.requestAccount({\n id: \"8670d2d8-2781-49e9-a75c-1eb980271ca9\",\n creationHint: { salt: \"0x1\" },\n });\n\n expect(account.address).toMatchInlineSnapshot(\n `\"0xC9B8271E44f14be83CecfDE1dDb325e9fa15e9Ff\"`,\n );\n });\n\n it(\"should not cache account if different inputs provided\", async () => {\n const account = await client.requestAccount();\n const account2 = await client.requestAccount({\n id: \"8670d2d8-2781-49e9-a75c-1eb980271ca9\",\n creationHint: { salt: \"0x1\" },\n });\n\n expect(account.address).not.toEqual(account2.address);\n });\n\n it(\"can correctly sign a message\", async () => {\n const account = await client.requestAccount();\n const message = \"hello world\";\n const signature = await client.signMessage({ message });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message: \"hello world\",\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data\", async () => {\n const account = await client.requestAccount();\n const signature = await client.signTypedData(givenTypedData);\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign a message with a different account\", async () => {\n const account = await client.requestAccount({\n id: \"8670d2d8-2781-49e9-a75c-1eb980271ca9\",\n creationHint: { salt: \"0x1\" },\n });\n\n const message = \"hello world\";\n const signature = await client.signMessage({\n message,\n account: account.address,\n });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message: \"hello world\",\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data with a different account\", async () => {\n const account = await client.requestAccount({\n id: \"8670d2d8-2781-49e9-a75c-1eb980271ca9\",\n creationHint: { salt: \"0x1\" },\n });\n\n const signature = await client.signTypedData({\n ...givenTypedData,\n account: account.address,\n });\n\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"should successfully send a UO with paymaster\", async () => {\n const account = await client.requestAccount();\n const preparedCall = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n },\n });\n\n const signature = await client.signSignatureRequest(\n preparedCall.signatureRequest,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedCall,\n signature,\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n\n it(\"should successfully create a session with grantPermissions and send a UO\", async () => {\n const account = await client.requestAccount();\n\n const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n\n const permissions = await client.grantPermissions({\n account: account.address,\n expiry: Math.floor(Date.now() / 1000) + 60 * 60,\n key: {\n publicKey: await sessionKey.getAddress(),\n type: \"secp256k1\",\n },\n permissions: [{ type: \"root\" }],\n });\n\n const preparedCall = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n permissions,\n },\n });\n\n const signature = await signSignatureRequest(\n sessionKey,\n preparedCall.signatureRequest,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedCall,\n signature,\n capabilities: {\n permissions,\n },\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n });\n\n const givenTypedData = {\n types: {\n Person: [\n { name: \"name\", type: \"string\" },\n { name: \"wallet\", type: \"address\" },\n ],\n Mail: [\n { name: \"from\", type: \"Person\" },\n { name: \"to\", type: \"Person\" },\n { name: \"contents\", type: \"string\" },\n ],\n },\n primaryType: \"Mail\" as const,\n domain: {\n name: \"Ether Mail\",\n version: \"1\",\n chainId: 1,\n verifyingContract:\n \"0xbbc68f94D29d52EE8D4994E54d6ED0fEAeb99C2c\" as Address,\n },\n message: {\n from: {\n name: \"Alice\",\n wallet: \"0xFC24e57486116026740634F629ffC4E5C95A6893\",\n },\n to: {\n name: \"Bob\",\n wallet: \"0xe7a26f006EAA562308C5df235C02BFB9a5849177\",\n },\n contents: \"Hello, Bob!\",\n },\n } as const;\n});\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
+
import type { AlchemyTransport } from "@account-kit/infra";
|
|
2
3
|
import type { Address, Chain, IsUndefined, JsonRpcAccount, Prettify } from "viem";
|
|
3
4
|
import type { InnerWalletApiClient } from "../types.ts";
|
|
4
5
|
import { type SmartWalletActions } from "./decorator.js";
|
|
5
|
-
import type { AlchemyTransport } from "@account-kit/infra";
|
|
6
6
|
export type SmartWalletClientParams<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined> = Prettify<{
|
|
7
7
|
transport: AlchemyTransport;
|
|
8
8
|
chain: Chain;
|
|
@@ -14,5 +14,6 @@ export type SmartWalletClientParams<TAccount extends JsonRpcAccount<Address> | u
|
|
|
14
14
|
} : {
|
|
15
15
|
account: Address;
|
|
16
16
|
})>;
|
|
17
|
-
export
|
|
18
|
-
export declare function createSmartWalletClient<TAccount extends JsonRpcAccount<Address> = JsonRpcAccount<Address
|
|
17
|
+
export type SmartWalletClient<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined> = InnerWalletApiClient<TAccount> & SmartWalletActions<TAccount>;
|
|
18
|
+
export declare function createSmartWalletClient<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined>(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;
|
|
19
|
+
export declare function createSmartWalletClient<TAccount extends JsonRpcAccount<Address> = JsonRpcAccount<Address>>(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;
|
package/dist/esm/client/index.js
CHANGED
|
@@ -11,13 +11,13 @@ import { smartWalletClientActions, } from "./decorator.js";
|
|
|
11
11
|
* @param {"local" | "remote"} params.mode - The client's mode (local or remote).
|
|
12
12
|
* @param {string} [params.policyId] - The policy ID for gas sponsorship (optional)
|
|
13
13
|
* @param {Address} [params.account] - The smart account address to use (optional)
|
|
14
|
-
* @returns {
|
|
14
|
+
* @returns {SmartWalletClient} - A viem-compatible client
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
18
18
|
* import { alchemy, arbitrumSepolia } from "@account-kit/infra";
|
|
19
19
|
* import { generatePrivateKey } from "viem/accounts";
|
|
20
|
-
* import { createSmartWalletClient } from "@account-kit/wallet-
|
|
20
|
+
* import { createSmartWalletClient } from "@account-kit/wallet-client";
|
|
21
21
|
*
|
|
22
22
|
* const signer = LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey());
|
|
23
23
|
* const transport = alchemy({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EACL,wBAAwB,GAEzB,MAAM,gBAAgB,CAAC;AAsCxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAA+B;IAE/B,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAErE,MAAM,WAAW,GACf,IAAI,KAAK,OAAO;QACd,CAAC,CAAC,iBAAiB,CAAC;YAChB,SAAS;YACT,KAAK;YACL,QAAQ;YACR,OAAO;SACR,CAAC;QACJ,CAAC,CAAC,kBAAkB,CAAC;YACjB,SAAS;YACT,KAAK;YACL,QAAQ;YACR,OAAO;SACR,CAAC,CAAC;IAET,yCAAyC;IACzC,qDAAqD;IACrD,4JAA4J;IAC5J,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CACnC,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,iBAAiB;AACjB,yDAAyD;AACzD,2CAA2C;AAC3C,wBAAwB;AACxB,4CAA4C;AAC5C,mBAAmB;AACnB,MAAM;AAEN,gEAAgE;AAEhE,sDAAsD;AACtD,2CAA2C;AAC3C,wBAAwB;AACxB,4CAA4C;AAC5C,mBAAmB;AACnB,0BAA0B;AAC1B,MAAM;AAEN,6DAA6D","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { AlchemyTransport } from \"@account-kit/infra\";\nimport type {\n Address,\n Chain,\n IsUndefined,\n JsonRpcAccount,\n Prettify,\n} from \"viem\";\nimport { createLocalClient } from \"../local/client.js\";\nimport { createRemoteClient } from \"../remote/client.js\";\nimport type { InnerWalletApiClient } from \"../types.ts\";\nimport {\n smartWalletClientActions,\n type SmartWalletActions,\n} from \"./decorator.js\";\n\nexport type SmartWalletClientParams<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n> = Prettify<\n {\n transport: AlchemyTransport;\n chain: Chain;\n signer: SmartAccountSigner;\n mode: \"local\" | \"remote\";\n policyId?: string;\n } & (IsUndefined<TAccount> extends true\n ? {\n account?: never;\n }\n : {\n account: Address;\n })\n>;\n\nexport type SmartWalletClient<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n> = InnerWalletApiClient<TAccount> & SmartWalletActions<TAccount>;\n\nexport function createSmartWalletClient<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;\n\nexport function createSmartWalletClient<\n TAccount extends JsonRpcAccount<Address> = JsonRpcAccount<Address>,\n>(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;\n\n/**\n * Creates a smart wallet client that can be used to interact with a smart account.\n *\n * @param {SmartWalletClientParams} params - The parameters for creating the smart wallet client\n * @param {AlchemyTransport} params.transport - The Alchemy transport to use\n * @param {Chain} params.chain - The chain to use\n * @param {SmartAccountSigner} params.signer - The signer to use for the smart account\n * @param {\"local\" | \"remote\"} params.mode - The client's mode (local or remote).\n * @param {string} [params.policyId] - The policy ID for gas sponsorship (optional)\n * @param {Address} [params.account] - The smart account address to use (optional)\n * @returns {SmartWalletClient} - A viem-compatible client\n *\n * @example\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { alchemy, arbitrumSepolia } from \"@account-kit/infra\";\n * import { generatePrivateKey } from \"viem/accounts\";\n * import { createSmartWalletClient } from \"@account-kit/wallet-client\";\n *\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey());\n * const transport = alchemy({\n * apiKey: \"your-alchemy-api-key\",\n * });\n * const client = createSmartWalletClient({\n * transport,\n * chain: arbitrumSepolia,\n * mode: \"remote\",\n * signer,\n * });\n */\nexport function createSmartWalletClient(\n params: SmartWalletClientParams,\n): SmartWalletClient {\n const { transport, chain, policyId, mode, account, signer } = params;\n\n const innerClient =\n mode === \"local\"\n ? createLocalClient({\n transport,\n chain,\n policyId,\n account,\n })\n : createRemoteClient({\n transport,\n chain,\n policyId,\n account,\n });\n\n // TODO: we need to do a few things here:\n // 1. decorate the client with the wallet api actions\n // 2. potentially we might want to make this client async and have it use `requestAccount` so that it can create a SCA client with an account attached to it\n return innerClient.extend((client) =>\n smartWalletClientActions(client, signer),\n );\n}\n\n// Example usage:\n// const clientWithoutAccount = createSmartWalletClient({\n// transport: alchemy({ apiKey: \"123\" }),\n// chain: baseSepolia,\n// signer: createDummySigner(zeroAddress),\n// mode: \"local\",\n// });\n\n// const account1 = await clientWithoutAccount.requestAccount();\n\n// const clientWithAccount = createSmartWalletClient({\n// transport: alchemy({ apiKey: \"123\" }),\n// chain: baseSepolia,\n// signer: createDummySigner(zeroAddress),\n// mode: \"local\",\n// account: zeroAddress,\n// });\n\n// const account2 = await clientWithAccount.requestAccount();\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { createSmartWalletClient, type SmartWalletClientParams, } from "../client/index.js";
|
|
1
|
+
export { createSmartWalletClient, type SmartWalletClient, type SmartWalletClientParams, } from "../client/index.js";
|
|
2
2
|
export { WalletServerRpcSchema, type WalletServerRpcSchemaType, type WalletServerViemRpcSchema, } from "../rpc/schema.js";
|
|
3
3
|
export { Capabilities } from "../capabilities/index.js";
|
|
4
4
|
export { PaymasterCapability } from "../capabilities/paymaster.js";
|
|
5
5
|
export { PermissionsArray, PermissionsCapability, PermissionsContext, PermissionsData, } from "../capabilities/permissions/index.js";
|
|
6
6
|
export { createAccount } from "../client/actions/createAccount.js";
|
|
7
7
|
export { getCallsStatus } from "../client/actions/getCallsStatus.js";
|
|
8
|
+
export { grantPermissions } from "../client/actions/grantPermissions.js";
|
|
8
9
|
export { listAccounts } from "../client/actions/listAccounts.js";
|
|
9
10
|
export { prepareCalls } from "../client/actions/prepareCalls.js";
|
|
10
11
|
export { requestAccount } from "../client/actions/requestAccount.js";
|
|
11
12
|
export { signMessage } from "../client/actions/signMessage.js";
|
|
12
13
|
export { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
|
|
13
14
|
export { signTypedData } from "../client/actions/signTypedData.js";
|
|
14
|
-
export { grantPermissions } from "../client/actions/grantPermissions.js";
|
|
@@ -9,11 +9,11 @@ export { PermissionsArray, PermissionsCapability, PermissionsContext, Permission
|
|
|
9
9
|
// client actions
|
|
10
10
|
export { createAccount } from "../client/actions/createAccount.js";
|
|
11
11
|
export { getCallsStatus } from "../client/actions/getCallsStatus.js";
|
|
12
|
+
export { grantPermissions } from "../client/actions/grantPermissions.js";
|
|
12
13
|
export { listAccounts } from "../client/actions/listAccounts.js";
|
|
13
14
|
export { prepareCalls } from "../client/actions/prepareCalls.js";
|
|
14
15
|
export { requestAccount } from "../client/actions/requestAccount.js";
|
|
15
16
|
export { signMessage } from "../client/actions/signMessage.js";
|
|
16
17
|
export { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
|
|
17
18
|
export { signTypedData } from "../client/actions/signTypedData.js";
|
|
18
|
-
export { grantPermissions } from "../client/actions/grantPermissions.js";
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,yDAAyD;AACzD,OAAO,EACL,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,yDAAyD;AACzD,OAAO,EACL,uBAAuB,GAGxB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,qBAAqB,GAGtB,MAAM,kBAAkB,CAAC;AAE1B,0EAA0E;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GAChB,MAAM,sCAAsC,CAAC;AAE9C,iBAAiB;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC","sourcesContent":["// TODO: anything that we want to expose publicly should be exported from `index.ts` files in the subdirectories\n// and we shouldn't export * for the sake of tree-shaking\nexport {\n createSmartWalletClient,\n type SmartWalletClient,\n type SmartWalletClientParams,\n} from \"../client/index.js\";\n\nexport {\n WalletServerRpcSchema,\n type WalletServerRpcSchemaType,\n type WalletServerViemRpcSchema,\n} from \"../rpc/schema.js\";\n\n// capabilities: TODO: should these actually just have the types exported?\nexport { Capabilities } from \"../capabilities/index.js\";\nexport { PaymasterCapability } from \"../capabilities/paymaster.js\";\nexport {\n PermissionsArray,\n PermissionsCapability,\n PermissionsContext,\n PermissionsData,\n} from \"../capabilities/permissions/index.js\";\n\n// client actions\nexport { createAccount } from \"../client/actions/createAccount.js\";\nexport { getCallsStatus } from \"../client/actions/getCallsStatus.js\";\nexport { grantPermissions } from \"../client/actions/grantPermissions.js\";\nexport { listAccounts } from \"../client/actions/listAccounts.js\";\nexport { prepareCalls } from \"../client/actions/prepareCalls.js\";\nexport { requestAccount } from \"../client/actions/requestAccount.js\";\nexport { signMessage } from \"../client/actions/signMessage.js\";\nexport { signSignatureRequest } from \"../client/actions/signSignatureRequest.js\";\nexport { signTypedData } from \"../client/actions/signTypedData.js\";\n"]}
|
|
@@ -6,21 +6,25 @@ import { TypePermission } from "../../capabilities/permissions/index.js";
|
|
|
6
6
|
import { isGlobalValidation } from "../../capabilities/permissions/mav2.js";
|
|
7
7
|
import { createAccount, isModularAccountV2 } from "../utils/createAccount.js";
|
|
8
8
|
import { createDummySigner } from "../utils/createDummySigner.js";
|
|
9
|
+
import { createAuthorization } from "../utils/7702.js";
|
|
10
|
+
import { InvalidRequestError } from "ox/RpcResponse";
|
|
9
11
|
export async function createSession(client, params) {
|
|
10
12
|
if (!client.chain) {
|
|
11
13
|
throw new ChainNotFoundError();
|
|
12
14
|
}
|
|
13
|
-
const { counterfactualInfo } = await client.request({
|
|
15
|
+
const { counterfactualInfo, delegation } = await client.request({
|
|
14
16
|
method: "wallet_requestAccount",
|
|
15
17
|
params: [
|
|
16
18
|
{
|
|
17
|
-
includeCounterfactualInfo: true,
|
|
18
19
|
accountAddress: params.account,
|
|
20
|
+
includeCounterfactualInfo: true,
|
|
19
21
|
},
|
|
20
22
|
],
|
|
21
23
|
});
|
|
22
|
-
if (!counterfactualInfo) {
|
|
23
|
-
throw new
|
|
24
|
+
if (!counterfactualInfo && !delegation) {
|
|
25
|
+
throw new InvalidRequestError({
|
|
26
|
+
message: "No counterfactual info or delegated implementation address found.",
|
|
27
|
+
});
|
|
24
28
|
}
|
|
25
29
|
const account = await createAccount({
|
|
26
30
|
chain: client.chain,
|
|
@@ -28,9 +32,12 @@ export async function createSession(client, params) {
|
|
|
28
32
|
signer: createDummySigner(params.account),
|
|
29
33
|
accountAddress: params.account,
|
|
30
34
|
counterfactualInfo,
|
|
35
|
+
delegation,
|
|
31
36
|
});
|
|
32
37
|
if (!isModularAccountV2(account)) {
|
|
33
|
-
throw new
|
|
38
|
+
throw new InvalidRequestError({
|
|
39
|
+
message: "Sessions are currently only supported by MAv2 accounts.",
|
|
40
|
+
});
|
|
34
41
|
}
|
|
35
42
|
const _client = createSmartAccountClient({
|
|
36
43
|
chain: client.chain,
|
|
@@ -52,12 +59,23 @@ export async function createSession(client, params) {
|
|
|
52
59
|
permissions: params.permissions.map((permission) => Value.Encode(TypePermission, permission)),
|
|
53
60
|
})
|
|
54
61
|
.compileDeferred();
|
|
62
|
+
// If using 7702, we need an Authorization (unless it's already authorized).
|
|
63
|
+
const authorizationRequest = delegation
|
|
64
|
+
? await createAuthorization(client, {
|
|
65
|
+
address: account.address,
|
|
66
|
+
delegation,
|
|
67
|
+
})
|
|
68
|
+
: undefined;
|
|
69
|
+
const signatureRequest = {
|
|
70
|
+
type: "eth_signTypedData_v4",
|
|
71
|
+
data: typedData,
|
|
72
|
+
};
|
|
55
73
|
return {
|
|
56
74
|
sessionId: null, // In remote mode, the server will set this later.
|
|
57
75
|
entityId: toHex(entityId),
|
|
58
76
|
signatureRequest: {
|
|
59
|
-
|
|
60
|
-
|
|
77
|
+
...signatureRequest,
|
|
78
|
+
...(authorizationRequest ? { authorizationRequest } : {}),
|
|
61
79
|
},
|
|
62
80
|
fullPreSignatureDeferredActionDigest,
|
|
63
81
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAGzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,iBAAiB,GAClB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,WAAW,EACX,KAAK,GAIN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAG5E,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAGzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,iBAAiB,GAClB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,WAAW,EACX,KAAK,GAIN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAG5E,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,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C","sourcesContent":["import {\n createSmartAccountClient,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport {\n deferralActions,\n PermissionBuilder,\n} from \"@account-kit/smart-contracts/experimental\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport {\n ChainNotFoundError,\n custom,\n hexToNumber,\n toHex,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { TypePermission } from \"../../capabilities/permissions/index.js\";\nimport { isGlobalValidation } from \"../../capabilities/permissions/mav2.js\";\nimport type { wallet_createSession } from \"../../rpc/request.js\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema.js\";\nimport { createAccount, isModularAccountV2 } from \"../utils/createAccount.js\";\nimport { createDummySigner } from \"../utils/createDummySigner.js\";\nimport { createAuthorization } from \"../utils/7702.js\";\nimport { InvalidRequestError } from \"ox/RpcResponse\";\n\nexport type CreateSessionParams = Omit<\n Static<\n (typeof wallet_createSession)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n> & {\n entityId?: Hex;\n};\n\nexport type CreateSessionResult = Omit<\n Static<(typeof wallet_createSession)[\"properties\"][\"ReturnType\"]>,\n \"sessionId\"\n> & {\n sessionId: Hex | null;\n entityId: Hex;\n fullPreSignatureDeferredActionDigest: Hex;\n};\n\nexport async function createSession(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: CreateSessionParams,\n): Promise<CreateSessionResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const { counterfactualInfo, delegation } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n accountAddress: params.account,\n includeCounterfactualInfo: true,\n },\n ],\n });\n if (!counterfactualInfo && !delegation) {\n throw new InvalidRequestError({\n message:\n \"No counterfactual info or delegated implementation address found.\",\n });\n }\n\n const account = await createAccount({\n chain: client.chain,\n transport: custom(client.transport),\n signer: createDummySigner(params.account),\n accountAddress: params.account,\n counterfactualInfo,\n delegation,\n });\n\n if (!isModularAccountV2(account)) {\n throw new InvalidRequestError({\n message: \"Sessions are currently only supported by MAv2 accounts.\",\n });\n }\n\n const _client = createSmartAccountClient({\n chain: client.chain,\n transport: custom(client.transport),\n account,\n }).extend(deferralActions);\n\n const { entityId, nonce } = await _client.getEntityIdAndNonce({\n entityId: params.entityId ? hexToNumber(params.entityId) : undefined,\n isGlobalValidation: isGlobalValidation(params),\n });\n\n const { typedData, fullPreSignatureDeferredActionDigest } =\n await new PermissionBuilder({\n client: _client,\n key: params.key,\n entityId,\n nonce,\n deadline: params.expiry,\n })\n .addPermissions({\n permissions: params.permissions.map((permission) =>\n Value.Encode(TypePermission, permission),\n ),\n })\n .compileDeferred();\n\n // If using 7702, we need an Authorization (unless it's already authorized).\n const authorizationRequest = delegation\n ? await createAuthorization(client, {\n address: account.address,\n delegation,\n })\n : undefined;\n\n const signatureRequest = {\n type: \"eth_signTypedData_v4\" as const,\n data: typedData,\n };\n\n return {\n sessionId: null, // In remote mode, the server will set this later.\n entityId: toHex(entityId),\n signatureRequest: {\n ...signatureRequest,\n ...(authorizationRequest ? { authorizationRequest } : {}),\n },\n fullPreSignatureDeferredActionDigest,\n };\n}\n"]}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { deepHexlify, } from "@aa-sdk/core";
|
|
2
|
-
import { ChainNotFoundError, custom, fromHex, toHex,
|
|
1
|
+
import { deepHexlify, default7702GasEstimator, } from "@aa-sdk/core";
|
|
2
|
+
import { ChainNotFoundError, custom, fromHex, toHex, } from "viem";
|
|
3
3
|
import { createAccount } from "../utils/createAccount.js";
|
|
4
4
|
import { createDummySigner } from "../utils/createDummySigner.js";
|
|
5
|
-
|
|
5
|
+
import { createAuthorization } from "../utils/7702.js";
|
|
6
|
+
import { InvalidRequestError } from "ox/RpcResponse";
|
|
6
7
|
export async function prepareCalls(client, params) {
|
|
7
8
|
if (!client.chain) {
|
|
8
9
|
throw new ChainNotFoundError();
|
|
9
10
|
}
|
|
10
11
|
// in local mode, we probably want some kind of caching for this
|
|
11
|
-
const { counterfactualInfo } = await client.request({
|
|
12
|
+
const { counterfactualInfo, delegation } = await client.request({
|
|
12
13
|
method: "wallet_requestAccount",
|
|
13
14
|
params: [
|
|
14
15
|
{
|
|
@@ -17,17 +18,31 @@ export async function prepareCalls(client, params) {
|
|
|
17
18
|
},
|
|
18
19
|
],
|
|
19
20
|
});
|
|
20
|
-
if (!counterfactualInfo) {
|
|
21
|
-
throw new
|
|
21
|
+
if (!counterfactualInfo && !delegation) {
|
|
22
|
+
throw new InvalidRequestError({
|
|
23
|
+
message: "No counterfactual info or delegated implementation address found.",
|
|
24
|
+
});
|
|
22
25
|
}
|
|
23
26
|
const account = await createAccount({
|
|
24
27
|
chain: client.chain,
|
|
25
28
|
transport: custom(client.transport),
|
|
26
|
-
signer: createDummySigner(
|
|
29
|
+
signer: createDummySigner(params.from),
|
|
27
30
|
accountAddress: params.from,
|
|
28
31
|
counterfactualInfo,
|
|
29
32
|
capabilities: params.capabilities,
|
|
33
|
+
delegation,
|
|
30
34
|
});
|
|
35
|
+
// If using 7702, we need an Authorization (unless it's already authorized).
|
|
36
|
+
const authorizationRequest = delegation
|
|
37
|
+
? await createAuthorization(client, {
|
|
38
|
+
address: account.address,
|
|
39
|
+
delegation,
|
|
40
|
+
})
|
|
41
|
+
: undefined;
|
|
42
|
+
if (authorizationRequest) {
|
|
43
|
+
// @ts-expect-error - this is available but not typed as public
|
|
44
|
+
client.middleware.gasEstimator = default7702GasEstimator();
|
|
45
|
+
}
|
|
31
46
|
// TODO: oops we don't actually support setting the policyId as an override here
|
|
32
47
|
// if we assume that the the isomorphic client is never used directly, then we can assume that this is handled upstream correctly
|
|
33
48
|
const builtUo = await client.buildUserOperation({
|
|
@@ -39,8 +54,18 @@ export async function prepareCalls(client, params) {
|
|
|
39
54
|
account,
|
|
40
55
|
overrides: params.capabilities?.gasParamsOverride,
|
|
41
56
|
});
|
|
57
|
+
// The eip7702Auth field should never be included in the UO sig
|
|
58
|
+
// request. It's handled by the separate authorization request.
|
|
59
|
+
if ("eip7702Auth" in builtUo) {
|
|
60
|
+
builtUo.eip7702Auth = undefined;
|
|
61
|
+
}
|
|
42
62
|
const uoRequest = deepHexlify(builtUo);
|
|
43
|
-
const
|
|
63
|
+
const signatureRequest = {
|
|
64
|
+
type: "personal_sign",
|
|
65
|
+
data: {
|
|
66
|
+
raw: account.getEntryPoint().getUserOperationHash(uoRequest),
|
|
67
|
+
},
|
|
68
|
+
};
|
|
44
69
|
return {
|
|
45
70
|
type: account.getEntryPoint().version === "0.7.0"
|
|
46
71
|
? "user-operation-v070"
|
|
@@ -48,10 +73,8 @@ export async function prepareCalls(client, params) {
|
|
|
48
73
|
data: uoRequest,
|
|
49
74
|
chainId: toHex(client.chain.id),
|
|
50
75
|
signatureRequest: {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
raw: hash,
|
|
54
|
-
},
|
|
76
|
+
...signatureRequest,
|
|
77
|
+
...(authorizationRequest ? { authorizationRequest } : {}),
|
|
55
78
|
},
|
|
56
79
|
};
|
|
57
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,uBAAuB,GAGxB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,OAAO,EACP,KAAK,GAGN,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EA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AC","sourcesContent":["import {\n deepHexlify,\n default7702GasEstimator,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport {\n ChainNotFoundError,\n custom,\n fromHex,\n toHex,\n type Chain,\n type Transport,\n} from \"viem\";\nimport type { wallet_prepareCalls } from \"../../rpc/request.js\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema.js\";\nimport { createAccount } from \"../utils/createAccount.js\";\nimport { createDummySigner } from \"../utils/createDummySigner.js\";\nimport { createAuthorization } from \"../utils/7702.js\";\nimport { InvalidRequestError } from \"ox/RpcResponse\";\n\nexport type PrepareCallsParams = Omit<\n Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n>;\n\nexport type PrepareCallsResult = Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"ReturnType\"]\n>;\n\nexport async function prepareCalls(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: PrepareCallsParams,\n): Promise<PrepareCallsResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n // in local mode, we probably want some kind of caching for this\n const { counterfactualInfo, delegation } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n accountAddress: params.from,\n includeCounterfactualInfo: true,\n },\n ],\n });\n\n if (!counterfactualInfo && !delegation) {\n throw new InvalidRequestError({\n message:\n \"No counterfactual info or delegated implementation address found.\",\n });\n }\n\n const account = await createAccount({\n chain: client.chain,\n transport: custom(client.transport),\n signer: createDummySigner(params.from),\n accountAddress: params.from,\n counterfactualInfo,\n capabilities: params.capabilities,\n delegation,\n });\n\n // If using 7702, we need an Authorization (unless it's already authorized).\n const authorizationRequest = delegation\n ? await createAuthorization(client, {\n address: account.address,\n delegation,\n })\n : undefined;\n\n if (authorizationRequest) {\n // @ts-expect-error - this is available but not typed as public\n client.middleware.gasEstimator = default7702GasEstimator();\n }\n\n // TODO: oops we don't actually support setting the policyId as an override here\n // if we assume that the the isomorphic client is never used directly, then we can assume that this is handled upstream correctly\n const builtUo = await client.buildUserOperation({\n uo: params.calls.map((x) => ({\n target: x.to,\n data: x.data ?? \"0x\",\n value: x.value ? fromHex(x.value, \"bigint\") : undefined,\n })),\n account,\n overrides: params.capabilities?.gasParamsOverride,\n });\n\n // The eip7702Auth field should never be included in the UO sig\n // request. It's handled by the separate authorization request.\n if (\"eip7702Auth\" in builtUo) {\n builtUo.eip7702Auth = undefined;\n }\n const uoRequest = deepHexlify(builtUo);\n\n const signatureRequest = {\n type: \"personal_sign\" as const,\n data: {\n raw: account.getEntryPoint().getUserOperationHash(uoRequest),\n },\n };\n\n return {\n type:\n account.getEntryPoint().version === \"0.7.0\"\n ? \"user-operation-v070\"\n : \"user-operation-v060\",\n data: uoRequest,\n chainId: toHex(client.chain.id),\n signatureRequest: {\n ...signatureRequest,\n ...(authorizationRequest ? { authorizationRequest } : {}),\n },\n };\n}\n"]}
|
|
@@ -1,27 +1,39 @@
|
|
|
1
1
|
import { getEntryPoint, } from "@aa-sdk/core";
|
|
2
2
|
import { Value } from "@sinclair/typebox/value";
|
|
3
|
-
import { ChainNotFoundError, concat, concatHex, toHex, } from "viem";
|
|
3
|
+
import { BaseError, ChainNotFoundError, concat, concatHex, toHex, } from "viem";
|
|
4
4
|
import { decodePermissionsContext } from "../../capabilities/permissions/mav2.js";
|
|
5
5
|
import { TypeCallId } from "../../schemas.js";
|
|
6
|
+
import { isSupportedImplementationAddress7702 } from "../utils/7702.js";
|
|
7
|
+
import { InvalidRequestError } from "ox/RpcResponse";
|
|
6
8
|
// TODO: this only supports MAv2 right now, we need to fix this
|
|
7
9
|
export async function sendPreparedCalls(client, params) {
|
|
8
10
|
if (!client.chain) {
|
|
9
11
|
throw new ChainNotFoundError();
|
|
10
12
|
}
|
|
13
|
+
// One last safety check to be sure the UO wasn't modified to include an unsupported 7702 delegation address.
|
|
14
|
+
if (params.signedAuthorization &&
|
|
15
|
+
!isSupportedImplementationAddress7702(params.signedAuthorization.address)) {
|
|
16
|
+
throw new InvalidRequestError({
|
|
17
|
+
message: `Unsupported 7702 delegation address: ${params.signedAuthorization.address}`,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
11
20
|
const deferredAction = (() => {
|
|
12
|
-
if (!params.capabilities?.permissions
|
|
21
|
+
if (!params.capabilities?.permissions) {
|
|
13
22
|
return;
|
|
14
23
|
}
|
|
15
|
-
const decodedContext = decodePermissionsContext(params.capabilities.permissions
|
|
24
|
+
const decodedContext = decodePermissionsContext(params.capabilities.permissions);
|
|
16
25
|
if (decodedContext.contextVersion === "REMOTE_MODE_DEFERRED_ACTION") {
|
|
17
|
-
throw new
|
|
26
|
+
throw new InvalidRequestError({
|
|
27
|
+
message: "Remote mode deferred action not supported in isomorphic client",
|
|
28
|
+
});
|
|
18
29
|
}
|
|
19
30
|
return decodedContext.deferredAction;
|
|
20
31
|
})();
|
|
21
32
|
const entryPoint = params.type === "user-operation-v060"
|
|
22
33
|
? getEntryPoint(client.chain, { version: "0.6.0" })
|
|
23
34
|
: getEntryPoint(client.chain, { version: "0.7.0" });
|
|
24
|
-
const hash = await client
|
|
35
|
+
const hash = await client
|
|
36
|
+
.sendRawUserOperation({
|
|
25
37
|
...params.data,
|
|
26
38
|
signature: deferredAction != null
|
|
27
39
|
? concatHex([
|
|
@@ -31,7 +43,15 @@ export async function sendPreparedCalls(client, params) {
|
|
|
31
43
|
params.signature.signature,
|
|
32
44
|
])
|
|
33
45
|
: concat(["0xFF", "0x00", params.signature.signature]),
|
|
34
|
-
|
|
46
|
+
eip7702Auth: params.signedAuthorization,
|
|
47
|
+
}, entryPoint.address)
|
|
48
|
+
.catch((err) => {
|
|
49
|
+
if (err instanceof BaseError &&
|
|
50
|
+
err.details.endsWith("is not a contract and initCode is empty")) {
|
|
51
|
+
throw new BaseError(`${err.details} (If using 7702, be sure you include the 'signedAuthorization' field in the request parameters)`);
|
|
52
|
+
}
|
|
53
|
+
throw err;
|
|
54
|
+
});
|
|
35
55
|
const callId = Value.Encode(TypeCallId, {
|
|
36
56
|
chainId: toHex(client.chain.id),
|
|
37
57
|
hash,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAGd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,KAAK,GAIN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAGlF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAGd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,KAAK,GAIN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAGlF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oCAAoC,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAarD,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAMC,EACD,MAA+B;IAE/B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;I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AAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC1D,WAAW,EAAE,MAAM,CAAC,mBAAmB;KACxC,EACD,UAAU,CAAC,OAAO,CACnB;SACA,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,IACE,GAAG,YAAY,SAAS;YACxB,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,yCAAyC,CAAC,EAC/D,CAAC;YACD,MAAM,IAAI,SAAS,CACjB,GAAG,GAAG,CAAC,OAAO,iGAAiG,CAChH,CAAC;QACJ,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC,CAAC,CAAC;IAEL,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE;QACtC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,IAAI;KACL,CAAC,CAAC;IAEH,OAAO;QACL,eAAe,EAAE,CAAC,MAAM,CAAC;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import {\n getEntryPoint,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static, StaticDecode } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport {\n BaseError,\n ChainNotFoundError,\n concat,\n concatHex,\n toHex,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { decodePermissionsContext } from \"../../capabilities/permissions/mav2.js\";\nimport type { wallet_sendPreparedCalls } from \"../../rpc/request.js\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema.js\";\nimport { TypeCallId } from \"../../schemas.js\";\nimport { isSupportedImplementationAddress7702 } from \"../utils/7702.js\";\nimport { InvalidRequestError } from \"ox/RpcResponse\";\n\nexport type SendPreparedCallsParams = Omit<\n StaticDecode<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n>;\n\nexport type SendPreparedCallsResult = Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"ReturnType\"]\n>;\n\n// TODO: this only supports MAv2 right now, we need to fix this\nexport async function sendPreparedCalls(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n // One last safety check to be sure the UO wasn't modified to include an unsupported 7702 delegation address.\n if (\n params.signedAuthorization &&\n !isSupportedImplementationAddress7702(params.signedAuthorization.address)\n ) {\n throw new InvalidRequestError({\n message: `Unsupported 7702 delegation address: ${params.signedAuthorization.address}`,\n });\n }\n\n const deferredAction: Hex | undefined = (() => {\n if (!params.capabilities?.permissions) {\n return;\n }\n\n const decodedContext = decodePermissionsContext(\n params.capabilities.permissions,\n );\n\n if (decodedContext.contextVersion === \"REMOTE_MODE_DEFERRED_ACTION\") {\n throw new InvalidRequestError({\n message:\n \"Remote mode deferred action not supported in isomorphic client\",\n });\n }\n\n return decodedContext.deferredAction;\n })();\n\n const entryPoint =\n params.type === \"user-operation-v060\"\n ? getEntryPoint(client.chain, { version: \"0.6.0\" })\n : getEntryPoint(client.chain, { version: \"0.7.0\" });\n\n const hash = await client\n .sendRawUserOperation(\n {\n ...params.data,\n signature:\n deferredAction != null\n ? concatHex([\n `0x${deferredAction.slice(68)}`, // Cuts off stuff preprended to the digest (nonce, etc. that we had previously).\n \"0xff\",\n \"0x00\",\n params.signature.signature,\n ])\n : concat([\"0xFF\", \"0x00\", params.signature.signature]),\n eip7702Auth: params.signedAuthorization,\n },\n entryPoint.address,\n )\n .catch((err) => {\n if (\n err instanceof BaseError &&\n err.details.endsWith(\"is not a contract and initCode is empty\")\n ) {\n throw new BaseError(\n `${err.details} (If using 7702, be sure you include the 'signedAuthorization' field in the request parameters)`,\n );\n }\n throw err;\n });\n\n const callId = Value.Encode(TypeCallId, {\n chainId: toHex(client.chain.id),\n hash,\n });\n\n return {\n preparedCallIds: [callId],\n };\n}\n"]}
|
|
@@ -13,7 +13,7 @@ type ClientParams = {
|
|
|
13
13
|
};
|
|
14
14
|
export declare function isomorphicClientActions(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>): {
|
|
15
15
|
prepareCalls: (params: PrepareCallsParams) => Promise<{
|
|
16
|
-
type: "user-operation-
|
|
16
|
+
type: "user-operation-v070" | "user-operation-v060";
|
|
17
17
|
chainId: `0x${string}`;
|
|
18
18
|
data: {
|
|
19
19
|
sender: `0x${string}`;
|
|
@@ -42,7 +42,7 @@ export declare function isomorphicClientActions(client: SmartAccountClient<Trans
|
|
|
42
42
|
maxFeePerGas: `0x${string}`;
|
|
43
43
|
maxPriorityFeePerGas: `0x${string}`;
|
|
44
44
|
};
|
|
45
|
-
signatureRequest: {
|
|
45
|
+
signatureRequest: ({
|
|
46
46
|
type: "personal_sign";
|
|
47
47
|
data: string | {
|
|
48
48
|
raw: `0x${string}`;
|
|
@@ -51,8 +51,8 @@ export declare function isomorphicClientActions(client: SmartAccountClient<Trans
|
|
|
51
51
|
type: "eth_signTypedData_v4";
|
|
52
52
|
data: {
|
|
53
53
|
domain?: {
|
|
54
|
-
salt?: `0x${string}` | undefined;
|
|
55
54
|
chainId?: number | undefined;
|
|
55
|
+
salt?: `0x${string}` | undefined;
|
|
56
56
|
name?: string | undefined;
|
|
57
57
|
verifyingContract?: `0x${string}` | undefined;
|
|
58
58
|
version?: string | undefined;
|
|
@@ -68,6 +68,12 @@ export declare function isomorphicClientActions(client: SmartAccountClient<Trans
|
|
|
68
68
|
[x: string]: unknown;
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
|
+
}) & {
|
|
72
|
+
authorizationRequest?: {
|
|
73
|
+
nonce: number;
|
|
74
|
+
chainId: number;
|
|
75
|
+
address: `0x${string}`;
|
|
76
|
+
} | undefined;
|
|
71
77
|
};
|
|
72
78
|
}>;
|
|
73
79
|
sendPreparedCalls: (params: SendPreparedCallsParams) => Promise<{
|
|
@@ -77,8 +83,8 @@ export declare function isomorphicClientActions(client: SmartAccountClient<Trans
|
|
|
77
83
|
receipts?: {
|
|
78
84
|
status: `0x${string}`;
|
|
79
85
|
logs: {
|
|
80
|
-
data: `0x${string}`;
|
|
81
86
|
address: `0x${string}`;
|
|
87
|
+
data: `0x${string}`;
|
|
82
88
|
topics: `0x${string}`[];
|
|
83
89
|
}[];
|
|
84
90
|
blockHash: `0x${string}`;
|
|
@@ -89,7 +95,7 @@ export declare function isomorphicClientActions(client: SmartAccountClient<Trans
|
|
|
89
95
|
chainId: `0x${string}`;
|
|
90
96
|
id: `0x${string}`;
|
|
91
97
|
atomic: boolean;
|
|
92
|
-
status:
|
|
98
|
+
status: 200 | 100 | 400 | 500 | 600;
|
|
93
99
|
}>;
|
|
94
100
|
createSession: (params: CreateSessionParams) => Promise<import("./actions/createSession.js").CreateSessionResult>;
|
|
95
101
|
};
|