@alchemy/wallet-apis 5.0.0-beta.3 → 5.0.0-beta.30
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/README.md +3 -1
- package/dist/esm/actions/prepareCalls.d.ts +8 -3
- package/dist/esm/actions/prepareCalls.js +8 -0
- package/dist/esm/actions/prepareCalls.js.map +1 -1
- package/dist/esm/actions/requestAccount.d.ts +4 -3
- package/dist/esm/actions/requestAccount.js.map +1 -1
- package/dist/esm/actions/sendCalls.d.ts +5 -2
- package/dist/esm/actions/sendCalls.js +5 -2
- package/dist/esm/actions/sendCalls.js.map +1 -1
- package/dist/esm/actions/sendPreparedCalls.d.ts +3 -1
- package/dist/esm/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/actions/signPreparedCalls.d.ts +2 -0
- package/dist/esm/actions/signPreparedCalls.js +14 -1
- package/dist/esm/actions/signPreparedCalls.js.map +1 -1
- package/dist/esm/actions/signSignatureRequest.d.ts +4 -4
- package/dist/esm/actions/signSignatureRequest.js +1 -1
- package/dist/esm/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/actions/signTypedData.d.ts +14 -4
- package/dist/esm/actions/signTypedData.js.map +1 -1
- package/dist/esm/actions/solana/getCallsStatus.d.ts +24 -0
- package/dist/esm/actions/solana/getCallsStatus.js +44 -0
- package/dist/esm/actions/solana/getCallsStatus.js.map +1 -0
- package/dist/esm/actions/solana/prepareCalls.d.ts +46 -0
- package/dist/esm/actions/solana/prepareCalls.js +70 -0
- package/dist/esm/actions/solana/prepareCalls.js.map +1 -0
- package/dist/esm/actions/solana/sendCalls.d.ts +34 -0
- package/dist/esm/actions/solana/sendCalls.js +44 -0
- package/dist/esm/actions/solana/sendCalls.js.map +1 -0
- package/dist/esm/actions/solana/sendPreparedCalls.d.ts +24 -0
- package/dist/esm/actions/solana/sendPreparedCalls.js +32 -0
- package/dist/esm/actions/solana/sendPreparedCalls.js.map +1 -0
- package/dist/esm/actions/solana/signPreparedCalls.d.ts +23 -0
- package/dist/esm/actions/solana/signPreparedCalls.js +24 -0
- package/dist/esm/actions/solana/signPreparedCalls.js.map +1 -0
- package/dist/esm/actions/solana/signSignatureRequest.d.ts +10 -0
- package/dist/esm/actions/solana/signSignatureRequest.js +33 -0
- package/dist/esm/actions/solana/signSignatureRequest.js.map +1 -0
- package/dist/esm/actions/solana/waitForCallsStatus.d.ts +24 -0
- package/dist/esm/actions/solana/waitForCallsStatus.js +46 -0
- package/dist/esm/actions/solana/waitForCallsStatus.js.map +1 -0
- package/dist/esm/actions/undelegateAccount.d.ts +37 -0
- package/dist/esm/actions/undelegateAccount.js +49 -0
- package/dist/esm/actions/undelegateAccount.js.map +1 -0
- package/dist/esm/adapters/SolanaSignerError.d.ts +4 -0
- package/dist/esm/adapters/SolanaSignerError.js +13 -0
- package/dist/esm/adapters/SolanaSignerError.js.map +1 -0
- package/dist/esm/adapters/fromKeypair.d.ts +21 -0
- package/dist/esm/adapters/fromKeypair.js +46 -0
- package/dist/esm/adapters/fromKeypair.js.map +1 -0
- package/dist/esm/adapters/fromKitSigner.d.ts +21 -0
- package/dist/esm/adapters/fromKitSigner.js +61 -0
- package/dist/esm/adapters/fromKitSigner.js.map +1 -0
- package/dist/esm/adapters/fromWalletAdapter.d.ts +26 -0
- package/dist/esm/adapters/fromWalletAdapter.js +45 -0
- package/dist/esm/adapters/fromWalletAdapter.js.map +1 -0
- package/dist/esm/adapters/fromWalletStandard.d.ts +31 -0
- package/dist/esm/adapters/fromWalletStandard.js +53 -0
- package/dist/esm/adapters/fromWalletStandard.js.map +1 -0
- package/dist/esm/adapters/resolveSignerSlot.d.ts +10 -0
- package/dist/esm/adapters/resolveSignerSlot.js +39 -0
- package/dist/esm/adapters/resolveSignerSlot.js.map +1 -0
- package/dist/esm/client.d.ts +29 -14
- package/dist/esm/client.js +63 -19
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/decorators/smartWalletActions.d.ts +2 -0
- package/dist/esm/decorators/smartWalletActions.js +4 -2
- package/dist/esm/decorators/smartWalletActions.js.map +1 -1
- package/dist/esm/decorators/solanaSmartWalletActions.d.ts +16 -0
- package/dist/esm/decorators/solanaSmartWalletActions.js +16 -0
- package/dist/esm/decorators/solanaSmartWalletActions.js.map +1 -0
- package/dist/esm/experimental/actions/requestQuoteV0.d.ts +48 -11
- package/dist/esm/experimental/actions/requestQuoteV0.js +8 -4
- package/dist/esm/experimental/actions/requestQuoteV0.js.map +1 -1
- package/dist/esm/experimental/swapActionsDecorator.d.ts +3 -0
- package/dist/esm/experimental/swapActionsDecorator.js.map +1 -1
- package/dist/esm/exports/index.d.ts +5 -3
- package/dist/esm/exports/index.js +1 -0
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/solana.d.ts +24 -0
- package/dist/esm/exports/solana.js +15 -0
- package/dist/esm/exports/solana.js.map +1 -0
- package/dist/esm/types.d.ts +28 -4
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/assertions.d.ts +4 -2
- package/dist/esm/utils/assertions.js +6 -0
- package/dist/esm/utils/assertions.js.map +1 -1
- package/dist/esm/utils/capabilities.d.ts +22 -6
- package/dist/esm/utils/capabilities.js +19 -2
- package/dist/esm/utils/capabilities.js.map +1 -1
- package/dist/esm/utils/format.d.ts +2 -2
- package/dist/esm/utils/format.js +4 -3
- package/dist/esm/utils/format.js.map +1 -1
- package/dist/esm/utils/schema.d.ts +14 -14
- package/dist/esm/utils/schema.js +35 -39
- package/dist/esm/utils/schema.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/actions/prepareCalls.d.ts +8 -3
- package/dist/types/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/actions/requestAccount.d.ts +4 -3
- package/dist/types/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/actions/sendCalls.d.ts +5 -2
- package/dist/types/actions/sendCalls.d.ts.map +1 -1
- package/dist/types/actions/sendPreparedCalls.d.ts +3 -1
- package/dist/types/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/actions/signPreparedCalls.d.ts +2 -0
- package/dist/types/actions/signPreparedCalls.d.ts.map +1 -1
- package/dist/types/actions/signSignatureRequest.d.ts +4 -4
- package/dist/types/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/actions/signTypedData.d.ts +14 -4
- package/dist/types/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/actions/solana/getCallsStatus.d.ts +25 -0
- package/dist/types/actions/solana/getCallsStatus.d.ts.map +1 -0
- package/dist/types/actions/solana/prepareCalls.d.ts +47 -0
- package/dist/types/actions/solana/prepareCalls.d.ts.map +1 -0
- package/dist/types/actions/solana/sendCalls.d.ts +35 -0
- package/dist/types/actions/solana/sendCalls.d.ts.map +1 -0
- package/dist/types/actions/solana/sendPreparedCalls.d.ts +25 -0
- package/dist/types/actions/solana/sendPreparedCalls.d.ts.map +1 -0
- package/dist/types/actions/solana/signPreparedCalls.d.ts +24 -0
- package/dist/types/actions/solana/signPreparedCalls.d.ts.map +1 -0
- package/dist/types/actions/solana/signSignatureRequest.d.ts +11 -0
- package/dist/types/actions/solana/signSignatureRequest.d.ts.map +1 -0
- package/dist/types/actions/solana/waitForCallsStatus.d.ts +25 -0
- package/dist/types/actions/solana/waitForCallsStatus.d.ts.map +1 -0
- package/dist/types/actions/undelegateAccount.d.ts +38 -0
- package/dist/types/actions/undelegateAccount.d.ts.map +1 -0
- package/dist/types/adapters/SolanaSignerError.d.ts +5 -0
- package/dist/types/adapters/SolanaSignerError.d.ts.map +1 -0
- package/dist/types/adapters/fromKeypair.d.ts +22 -0
- package/dist/types/adapters/fromKeypair.d.ts.map +1 -0
- package/dist/types/adapters/fromKitSigner.d.ts +22 -0
- package/dist/types/adapters/fromKitSigner.d.ts.map +1 -0
- package/dist/types/adapters/fromWalletAdapter.d.ts +27 -0
- package/dist/types/adapters/fromWalletAdapter.d.ts.map +1 -0
- package/dist/types/adapters/fromWalletStandard.d.ts +32 -0
- package/dist/types/adapters/fromWalletStandard.d.ts.map +1 -0
- package/dist/types/adapters/resolveSignerSlot.d.ts +11 -0
- package/dist/types/adapters/resolveSignerSlot.d.ts.map +1 -0
- package/dist/types/client.d.ts +29 -14
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/decorators/smartWalletActions.d.ts +2 -0
- package/dist/types/decorators/smartWalletActions.d.ts.map +1 -1
- package/dist/types/decorators/solanaSmartWalletActions.d.ts +17 -0
- package/dist/types/decorators/solanaSmartWalletActions.d.ts.map +1 -0
- package/dist/types/experimental/actions/requestQuoteV0.d.ts +48 -11
- package/dist/types/experimental/actions/requestQuoteV0.d.ts.map +1 -1
- package/dist/types/experimental/swapActionsDecorator.d.ts +3 -0
- package/dist/types/experimental/swapActionsDecorator.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +5 -3
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/exports/solana.d.ts +25 -0
- package/dist/types/exports/solana.d.ts.map +1 -0
- package/dist/types/types.d.ts +28 -4
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/assertions.d.ts +4 -2
- package/dist/types/utils/assertions.d.ts.map +1 -1
- package/dist/types/utils/capabilities.d.ts +22 -6
- package/dist/types/utils/capabilities.d.ts.map +1 -1
- package/dist/types/utils/format.d.ts +2 -2
- package/dist/types/utils/format.d.ts.map +1 -1
- package/dist/types/utils/schema.d.ts +14 -14
- package/dist/types/utils/schema.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +29 -11
- package/src/actions/prepareCalls.ts +21 -3
- package/src/actions/requestAccount.ts +7 -5
- package/src/actions/sendCalls.ts +5 -2
- package/src/actions/sendPreparedCalls.ts +4 -1
- package/src/actions/signPreparedCalls.ts +15 -2
- package/src/actions/signSignatureRequest.ts +8 -8
- package/src/actions/signTypedData.ts +15 -7
- package/src/actions/solana/getCallsStatus.ts +79 -0
- package/src/actions/solana/prepareCalls.ts +120 -0
- package/src/actions/solana/sendCalls.ts +66 -0
- package/src/actions/solana/sendPreparedCalls.ts +65 -0
- package/src/actions/solana/signPreparedCalls.ts +50 -0
- package/src/actions/solana/signSignatureRequest.ts +63 -0
- package/src/actions/solana/waitForCallsStatus.ts +84 -0
- package/src/actions/undelegateAccount.ts +68 -0
- package/src/adapters/SolanaSignerError.ts +5 -0
- package/src/adapters/fromKeypair.ts +58 -0
- package/src/adapters/fromKitSigner.ts +82 -0
- package/src/adapters/fromWalletAdapter.ts +58 -0
- package/src/adapters/fromWalletStandard.ts +100 -0
- package/src/adapters/resolveSignerSlot.ts +46 -0
- package/src/client.ts +131 -18
- package/src/decorators/smartWalletActions.ts +11 -2
- package/src/decorators/solanaSmartWalletActions.ts +62 -0
- package/src/experimental/actions/requestQuoteV0.ts +40 -15
- package/src/experimental/swapActionsDecorator.ts +3 -0
- package/src/exports/index.ts +10 -4
- package/src/exports/solana.ts +36 -0
- package/src/types.ts +38 -7
- package/src/utils/assertions.ts +17 -2
- package/src/utils/capabilities.ts +40 -8
- package/src/utils/format.ts +8 -3
- package/src/utils/schema.ts +58 -69
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartWalletActions.js","sourceRoot":"","sources":["../../../src/decorators/smartWalletActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,MAAM,CAAC;AAChC,OAAO,EACL,cAAc,GAGf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,YAAY,GAGb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iBAAiB,GAGlB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,SAAS,GAGV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,YAAY,GAGb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,oBAAoB,GAGrB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,iBAAiB,GAGlB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,WAAW,EAA0B,MAAM,2BAA2B,CAAC;AAChF,OAAO,EACL,aAAa,GAEd,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,gBAAgB,GAGjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,eAAe,GAGhB,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"smartWalletActions.js","sourceRoot":"","sources":["../../../src/decorators/smartWalletActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,MAAM,CAAC;AAChC,OAAO,EACL,cAAc,GAGf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,YAAY,GAGb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iBAAiB,GAGlB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,SAAS,GAGV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,YAAY,GAGb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,oBAAoB,GAGrB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,iBAAiB,GAGlB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,WAAW,EAA0B,MAAM,2BAA2B,CAAC;AAChF,OAAO,EACL,aAAa,GAEd,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,gBAAgB,GAGjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,eAAe,GAGhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,iBAAiB,GAGlB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,cAAc,EACd,kBAAkB,GAKnB,MAAM,cAAc,CAAC;AAqCtB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,MAA4B,EACR,EAAE,CAAC,CAAC;IACxB,mBAAmB;IACnB,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC;IAC1D,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;IACtD,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;IACtD,iBAAiB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC;IAChE,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAChD,oBAAoB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC;IACtE,iBAAiB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC;IAChE,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;IACpD,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC;IACxD,gBAAgB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC;IAC9D,eAAe,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC;IAC5D,iBAAiB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC;IAChE,gBAAgB;IAChB,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC;IAC1D,kBAAkB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC;CACnE,CAAC,CAAC","sourcesContent":["import { type Hex } from \"viem\";\nimport {\n requestAccount,\n type RequestAccountParams,\n type RequestAccountResult,\n} from \"../actions/requestAccount.js\";\nimport {\n prepareCalls,\n type PrepareCallsParams,\n type PrepareCallsResult,\n} from \"../actions/prepareCalls.js\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsParams,\n type SendPreparedCallsResult,\n} from \"../actions/sendPreparedCalls.js\";\nimport {\n sendCalls,\n type SendCallsParams,\n type SendCallsResult,\n} from \"../actions/sendCalls.js\";\nimport {\n listAccounts,\n type ListAccountsParams,\n type ListAccountsResult,\n} from \"../actions/listAccounts.js\";\nimport {\n signSignatureRequest,\n type SignSignatureRequestParams,\n type SignSignatureRequestResult,\n} from \"../actions/signSignatureRequest.js\";\nimport {\n signPreparedCalls,\n type SignPreparedCallsParams,\n type SignPreparedCallsResult,\n} from \"../actions/signPreparedCalls.js\";\nimport { signMessage, type SignMessageParams } from \"../actions/signMessage.js\";\nimport {\n signTypedData,\n type SignTypedDataParams,\n} from \"../actions/signTypedData.js\";\nimport {\n grantPermissions,\n type GrantPermissionsParams,\n type GrantPermissionsResult,\n} from \"../actions/grantPermissions.js\";\nimport {\n getCapabilities,\n type GetCapabilitiesParams,\n type GetCapabilitiesResult,\n} from \"../actions/getCapabilities.js\";\nimport {\n undelegateAccount,\n type UndelegateAccountParams,\n type UndelegateAccountResult,\n} from \"../actions/undelegateAccount.js\";\nimport type { InnerWalletApiClient } from \"../types.js\";\nimport {\n getCallsStatus,\n waitForCallsStatus,\n type GetCallsStatusParameters,\n type GetCallsStatusReturnType,\n type WaitForCallsStatusParameters,\n type WaitForCallsStatusReturnType,\n} from \"viem/actions\";\n\nexport type SmartWalletActions = {\n requestAccount: (\n params?: RequestAccountParams,\n ) => Promise<RequestAccountResult>;\n prepareCalls: (params: PrepareCallsParams) => Promise<PrepareCallsResult>;\n sendPreparedCalls: (\n params: SendPreparedCallsParams,\n ) => Promise<SendPreparedCallsResult>;\n sendCalls: (params: SendCallsParams) => Promise<SendCallsResult>;\n listAccounts: (params: ListAccountsParams) => Promise<ListAccountsResult>;\n signSignatureRequest: (\n params: SignSignatureRequestParams,\n ) => Promise<SignSignatureRequestResult>;\n signPreparedCalls: (\n params: SignPreparedCallsParams,\n ) => Promise<SignPreparedCallsResult>;\n signMessage: (params: SignMessageParams) => Promise<Hex>;\n signTypedData: (params: SignTypedDataParams) => Promise<Hex>;\n grantPermissions: (\n params: GrantPermissionsParams,\n ) => Promise<GrantPermissionsResult>;\n getCallsStatus: (\n params: GetCallsStatusParameters,\n ) => Promise<GetCallsStatusReturnType>;\n waitForCallsStatus: (\n params: WaitForCallsStatusParameters,\n ) => Promise<WaitForCallsStatusReturnType>;\n getCapabilities: (\n params?: GetCapabilitiesParams | undefined,\n ) => Promise<GetCapabilitiesResult>;\n undelegateAccount: (\n params?: UndelegateAccountParams,\n ) => Promise<UndelegateAccountResult>;\n};\n\n/**\n * Decorator that adds smart wallet actions to a wallet API client.\n * Provides both Alchemy-specific methods and standard viem wallet actions.\n *\n * @param {InnerWalletApiClient} client The wallet API client instance\n * @returns {SmartWalletActions} An object containing smart wallet action methods\n */\nexport const smartWalletActions = (\n client: InnerWalletApiClient,\n): SmartWalletActions => ({\n // Alchemy actions.\n requestAccount: (params) => requestAccount(client, params),\n prepareCalls: (params) => prepareCalls(client, params),\n listAccounts: (params) => listAccounts(client, params),\n sendPreparedCalls: (params) => sendPreparedCalls(client, params),\n sendCalls: (params) => sendCalls(client, params),\n signSignatureRequest: (params) => signSignatureRequest(client, params),\n signPreparedCalls: (params) => signPreparedCalls(client, params),\n signMessage: (params) => signMessage(client, params),\n signTypedData: (params) => signTypedData(client, params),\n grantPermissions: (params) => grantPermissions(client, params),\n getCapabilities: (params) => getCapabilities(client, params),\n undelegateAccount: (params) => undelegateAccount(client, params),\n // Viem actions.\n getCallsStatus: (params) => getCallsStatus(client, params),\n waitForCallsStatus: (params) => waitForCallsStatus(client, params),\n});\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { InnerSolanaWalletApiClient } from "../types.js";
|
|
2
|
+
import { type SolanaPrepareCallsParams, type SolanaPrepareCallsResult } from "../actions/solana/prepareCalls.js";
|
|
3
|
+
import { type SolanaSignPreparedCallsParams, type SolanaSignPreparedCallsResult } from "../actions/solana/signPreparedCalls.js";
|
|
4
|
+
import { type SolanaSendPreparedCallsParams, type SolanaSendPreparedCallsResult } from "../actions/solana/sendPreparedCalls.js";
|
|
5
|
+
import { type SolanaSendCallsParams, type SolanaSendCallsResult } from "../actions/solana/sendCalls.js";
|
|
6
|
+
import { type SolanaGetCallsStatusParams, type SolanaGetCallsStatusResult } from "../actions/solana/getCallsStatus.js";
|
|
7
|
+
import { type SolanaWaitForCallsStatusParams, type SolanaWaitForCallsStatusResult } from "../actions/solana/waitForCallsStatus.js";
|
|
8
|
+
export type SolanaSmartWalletActions = {
|
|
9
|
+
prepareCalls: (params: SolanaPrepareCallsParams) => Promise<SolanaPrepareCallsResult>;
|
|
10
|
+
signPreparedCalls: (params: SolanaSignPreparedCallsParams) => Promise<SolanaSignPreparedCallsResult>;
|
|
11
|
+
sendPreparedCalls: (params: SolanaSendPreparedCallsParams) => Promise<SolanaSendPreparedCallsResult>;
|
|
12
|
+
sendCalls: (params: SolanaSendCallsParams) => Promise<SolanaSendCallsResult>;
|
|
13
|
+
getCallsStatus: (params: SolanaGetCallsStatusParams) => Promise<SolanaGetCallsStatusResult>;
|
|
14
|
+
waitForCallsStatus: (params: SolanaWaitForCallsStatusParams) => Promise<SolanaWaitForCallsStatusResult>;
|
|
15
|
+
};
|
|
16
|
+
export declare const solanaSmartWalletActions: (client: InnerSolanaWalletApiClient) => SolanaSmartWalletActions;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { prepareCalls, } from "../actions/solana/prepareCalls.js";
|
|
2
|
+
import { signPreparedCalls, } from "../actions/solana/signPreparedCalls.js";
|
|
3
|
+
import { sendPreparedCalls, } from "../actions/solana/sendPreparedCalls.js";
|
|
4
|
+
import { sendCalls, } from "../actions/solana/sendCalls.js";
|
|
5
|
+
import { getCallsStatus, } from "../actions/solana/getCallsStatus.js";
|
|
6
|
+
import { waitForCallsStatus, } from "../actions/solana/waitForCallsStatus.js";
|
|
7
|
+
export const solanaSmartWalletActions = (client) => ({
|
|
8
|
+
prepareCalls: (params) => prepareCalls(client, params),
|
|
9
|
+
signPreparedCalls: (params) => signPreparedCalls(client, params),
|
|
10
|
+
sendPreparedCalls: (params) => sendPreparedCalls(client, params),
|
|
11
|
+
sendCalls: (params) => sendCalls(client, params),
|
|
12
|
+
// Note that status actions from Viem don't work since the chain ID is not hex.
|
|
13
|
+
getCallsStatus: (params) => getCallsStatus(client, params),
|
|
14
|
+
waitForCallsStatus: (params) => waitForCallsStatus(client, params),
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=solanaSmartWalletActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solanaSmartWalletActions.js","sourceRoot":"","sources":["../../../src/decorators/solanaSmartWalletActions.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,GAGb,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,iBAAiB,GAGlB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,iBAAiB,GAGlB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,SAAS,GAGV,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,cAAc,GAGf,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,kBAAkB,GAGnB,MAAM,yCAAyC,CAAC;AAqBjD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,MAAkC,EACR,EAAE,CAAC,CAAC;IAC9B,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;IACtD,iBAAiB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC;IAChE,iBAAiB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC;IAChE,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAChD,+EAA+E;IAC/E,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC;IAC1D,kBAAkB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC;CACnE,CAAC,CAAC","sourcesContent":["import type { InnerSolanaWalletApiClient } from \"../types.js\";\nimport {\n prepareCalls,\n type SolanaPrepareCallsParams,\n type SolanaPrepareCallsResult,\n} from \"../actions/solana/prepareCalls.js\";\nimport {\n signPreparedCalls,\n type SolanaSignPreparedCallsParams,\n type SolanaSignPreparedCallsResult,\n} from \"../actions/solana/signPreparedCalls.js\";\nimport {\n sendPreparedCalls,\n type SolanaSendPreparedCallsParams,\n type SolanaSendPreparedCallsResult,\n} from \"../actions/solana/sendPreparedCalls.js\";\nimport {\n sendCalls,\n type SolanaSendCallsParams,\n type SolanaSendCallsResult,\n} from \"../actions/solana/sendCalls.js\";\nimport {\n getCallsStatus,\n type SolanaGetCallsStatusParams,\n type SolanaGetCallsStatusResult,\n} from \"../actions/solana/getCallsStatus.js\";\nimport {\n waitForCallsStatus,\n type SolanaWaitForCallsStatusParams,\n type SolanaWaitForCallsStatusResult,\n} from \"../actions/solana/waitForCallsStatus.js\";\n\nexport type SolanaSmartWalletActions = {\n prepareCalls: (\n params: SolanaPrepareCallsParams,\n ) => Promise<SolanaPrepareCallsResult>;\n signPreparedCalls: (\n params: SolanaSignPreparedCallsParams,\n ) => Promise<SolanaSignPreparedCallsResult>;\n sendPreparedCalls: (\n params: SolanaSendPreparedCallsParams,\n ) => Promise<SolanaSendPreparedCallsResult>;\n sendCalls: (params: SolanaSendCallsParams) => Promise<SolanaSendCallsResult>;\n getCallsStatus: (\n params: SolanaGetCallsStatusParams,\n ) => Promise<SolanaGetCallsStatusResult>;\n waitForCallsStatus: (\n params: SolanaWaitForCallsStatusParams,\n ) => Promise<SolanaWaitForCallsStatusResult>;\n};\n\nexport const solanaSmartWalletActions = (\n client: InnerSolanaWalletApiClient,\n): SolanaSmartWalletActions => ({\n prepareCalls: (params) => prepareCalls(client, params),\n signPreparedCalls: (params) => signPreparedCalls(client, params),\n sendPreparedCalls: (params) => sendPreparedCalls(client, params),\n sendCalls: (params) => sendCalls(client, params),\n // Note that status actions from Viem don't work since the chain ID is not hex.\n getCallsStatus: (params) => getCallsStatus(client, params),\n waitForCallsStatus: (params) => waitForCallsStatus(client, params),\n});\n"]}
|
|
@@ -1,15 +1,45 @@
|
|
|
1
|
-
import type { Address, Prettify } from "viem";
|
|
2
|
-
import type {
|
|
3
|
-
import { type PrepareCallsCapabilities
|
|
1
|
+
import type { Address, Hex, Prettify } from "viem";
|
|
2
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
3
|
+
import { type PrepareCallsCapabilities } from "../../utils/capabilities.js";
|
|
4
4
|
import { type AccountParam } from "../../utils/resolve.js";
|
|
5
5
|
import { wallet_requestQuote_v0 as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
6
|
-
import { type
|
|
7
|
-
type BaseRequestQuoteV0Params = MethodParams<typeof MethodSchema>;
|
|
6
|
+
import { type MethodResponse } from "../../utils/schema.js";
|
|
8
7
|
type RequestQuoteV0Response = MethodResponse<typeof MethodSchema>;
|
|
9
|
-
|
|
8
|
+
type SwapAmountParams = {
|
|
9
|
+
fromAmount: bigint;
|
|
10
|
+
minimumToAmount?: never;
|
|
11
|
+
} | {
|
|
12
|
+
fromAmount?: never;
|
|
13
|
+
minimumToAmount: bigint;
|
|
14
|
+
};
|
|
15
|
+
type SwapChainParams = {
|
|
16
|
+
toChainId?: never;
|
|
17
|
+
postCalls?: Array<{
|
|
18
|
+
to: Address;
|
|
19
|
+
data?: Hex;
|
|
20
|
+
value?: bigint;
|
|
21
|
+
}>;
|
|
22
|
+
} | {
|
|
23
|
+
toChainId: number;
|
|
24
|
+
postCalls?: never;
|
|
25
|
+
};
|
|
26
|
+
type SwapExecutionParams = {
|
|
27
|
+
returnRawCalls?: false;
|
|
28
|
+
capabilities?: PrepareCallsCapabilities;
|
|
29
|
+
} | {
|
|
30
|
+
returnRawCalls: true;
|
|
31
|
+
capabilities?: never;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Parameters accepted by the experimental `requestQuoteV0` action.
|
|
35
|
+
*/
|
|
36
|
+
export type RequestQuoteV0Params = Prettify<{
|
|
37
|
+
fromToken: Address;
|
|
38
|
+
toToken: Address;
|
|
39
|
+
slippage?: bigint;
|
|
10
40
|
account?: AccountParam;
|
|
11
41
|
chainId?: number;
|
|
12
|
-
}
|
|
42
|
+
} & SwapAmountParams & SwapChainParams & SwapExecutionParams>;
|
|
13
43
|
/** The modifiedRequest in client format: `account` instead of `from`, SDK capabilities. */
|
|
14
44
|
type ClientModifiedRequest = Prettify<Omit<Extract<RequestQuoteV0Response, {
|
|
15
45
|
type: "paymaster-permit";
|
|
@@ -17,6 +47,9 @@ type ClientModifiedRequest = Prettify<Omit<Extract<RequestQuoteV0Response, {
|
|
|
17
47
|
account: Address;
|
|
18
48
|
capabilities?: PrepareCallsCapabilities;
|
|
19
49
|
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Result returned by the experimental `requestQuoteV0` action.
|
|
52
|
+
*/
|
|
20
53
|
export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
|
|
21
54
|
type: "paymaster-permit";
|
|
22
55
|
}> | (Omit<Extract<RequestQuoteV0Response, {
|
|
@@ -32,13 +65,15 @@ export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
|
|
|
32
65
|
* @param {RequestQuoteV0Params} params - Parameters for requesting a swap quote
|
|
33
66
|
* @param {Address} params.fromToken - The address of the token to swap from
|
|
34
67
|
* @param {Address} params.toToken - The address of the token to swap to
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
68
|
+
* @param {bigint} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)
|
|
69
|
+
* @param {bigint} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)
|
|
37
70
|
* @param {AccountParam} [params.account] - The account to execute the swap from. Can be an address string or an object with an `address` property. Defaults to the client's account (signer address via EIP-7702).
|
|
38
|
-
* @param {
|
|
71
|
+
* @param {number} [params.chainId] - The source chain ID. Defaults to the wallet client's chain.
|
|
72
|
+
* @param {number} [params.toChainId] - The destination chain ID for cross-chain swaps. Omit for same-chain swaps.
|
|
73
|
+
* @param {bigint} [params.slippage] - The maximum acceptable slippage in basis points.
|
|
39
74
|
* @param {boolean} [params.returnRawCalls] - Whether to return raw calls for EOA wallets (defaults to false for smart wallets)
|
|
40
75
|
* @param {object} [params.capabilities] - Optional capabilities to include with the request (only available when returnRawCalls is false)
|
|
41
|
-
* @param {Array<{to: Address
|
|
76
|
+
* @param {Array<{ to: Address; data?: Hex; value?: bigint }>} [params.postCalls] - Optional calls to execute after the swap
|
|
42
77
|
* @returns {Promise<RequestQuoteV0Result>} A Promise that resolves to either prepared calls or raw calls depending on returnRawCalls
|
|
43
78
|
*
|
|
44
79
|
* @example
|
|
@@ -48,6 +83,7 @@ export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
|
|
|
48
83
|
* fromToken: "0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
49
84
|
* toToken: "0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
50
85
|
* fromAmount: 1000000000000000000n, // 1 ETH
|
|
86
|
+
* chainId: 42161, // Arbitrum
|
|
51
87
|
* capabilities: {
|
|
52
88
|
* paymaster: { policyId: "your-policy-id" }
|
|
53
89
|
* }
|
|
@@ -58,6 +94,7 @@ export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
|
|
|
58
94
|
* fromToken: "0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
59
95
|
* toToken: "0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
60
96
|
* fromAmount: 1000000000000000000n,
|
|
97
|
+
* chainId: 42161,
|
|
61
98
|
* returnRawCalls: true
|
|
62
99
|
* });
|
|
63
100
|
* ```
|
|
@@ -11,13 +11,15 @@ const schema = methodSchema(MethodSchema);
|
|
|
11
11
|
* @param {RequestQuoteV0Params} params - Parameters for requesting a swap quote
|
|
12
12
|
* @param {Address} params.fromToken - The address of the token to swap from
|
|
13
13
|
* @param {Address} params.toToken - The address of the token to swap to
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
14
|
+
* @param {bigint} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)
|
|
15
|
+
* @param {bigint} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)
|
|
16
16
|
* @param {AccountParam} [params.account] - The account to execute the swap from. Can be an address string or an object with an `address` property. Defaults to the client's account (signer address via EIP-7702).
|
|
17
|
-
* @param {
|
|
17
|
+
* @param {number} [params.chainId] - The source chain ID. Defaults to the wallet client's chain.
|
|
18
|
+
* @param {number} [params.toChainId] - The destination chain ID for cross-chain swaps. Omit for same-chain swaps.
|
|
19
|
+
* @param {bigint} [params.slippage] - The maximum acceptable slippage in basis points.
|
|
18
20
|
* @param {boolean} [params.returnRawCalls] - Whether to return raw calls for EOA wallets (defaults to false for smart wallets)
|
|
19
21
|
* @param {object} [params.capabilities] - Optional capabilities to include with the request (only available when returnRawCalls is false)
|
|
20
|
-
* @param {Array<{to: Address
|
|
22
|
+
* @param {Array<{ to: Address; data?: Hex; value?: bigint }>} [params.postCalls] - Optional calls to execute after the swap
|
|
21
23
|
* @returns {Promise<RequestQuoteV0Result>} A Promise that resolves to either prepared calls or raw calls depending on returnRawCalls
|
|
22
24
|
*
|
|
23
25
|
* @example
|
|
@@ -27,6 +29,7 @@ const schema = methodSchema(MethodSchema);
|
|
|
27
29
|
* fromToken: "0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
28
30
|
* toToken: "0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
29
31
|
* fromAmount: 1000000000000000000n, // 1 ETH
|
|
32
|
+
* chainId: 42161, // Arbitrum
|
|
30
33
|
* capabilities: {
|
|
31
34
|
* paymaster: { policyId: "your-policy-id" }
|
|
32
35
|
* }
|
|
@@ -37,6 +40,7 @@ const schema = methodSchema(MethodSchema);
|
|
|
37
40
|
* fromToken: "0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
38
41
|
* toToken: "0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
39
42
|
* fromAmount: 1000000000000000000n,
|
|
43
|
+
* chainId: 42161,
|
|
40
44
|
* returnRawCalls: true
|
|
41
45
|
* });
|
|
42
46
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestQuoteV0.js","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"requestQuoteV0.js","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,GAElB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAEP,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AA2D1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;QACzB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,YAAY,GAChB,gBAAgB,IAAI,MAAM,IAAI,MAAM,CAAC,cAAc;QACjD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,uBAAuB,CACrB,MAAM,EACN,cAAc,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAC3D,CAAC;IAER,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QACvC,GAAG,IAAI;QACP,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;QAC1C,IAAI;QACJ,GAAG,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC,EAAE,CAAC;KACvE,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,wBAAwB;QAChC,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEjD,+EAA+E;IAC/E,sCAAsC;IACtC,8EAA8E;IAC9E,IAAI,MAAM,IAAI,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QAC7D,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,mBAAmB,EAAE,GAClD,OAAO,CAAC,eAAe,CAAC;QAC1B,OAAO;YACL,GAAG,OAAO;YACV,eAAe,EAAE;gBACf,GAAG,mBAAmB;gBACtB,OAAO,EAAE,IAAI;gBACb,YAAY,EAAE,mBAAmB,CAAC,YAAY,CAAC;aAChD;SACF,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { Address, Hex, Prettify } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport {\n fromRpcCapabilities,\n mergeClientCapabilities,\n toRpcCapabilities,\n type PrepareCallsCapabilities,\n} from \"../../utils/capabilities.js\";\nimport { resolveAddress, type AccountParam } from \"../../utils/resolve.js\";\nimport { wallet_requestQuote_v0 as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodResponse,\n} from \"../../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype RequestQuoteV0Response = MethodResponse<typeof MethodSchema>;\n\ntype SwapAmountParams =\n | { fromAmount: bigint; minimumToAmount?: never }\n | { fromAmount?: never; minimumToAmount: bigint };\n\ntype SwapChainParams =\n | {\n toChainId?: never;\n postCalls?: Array<{ to: Address; data?: Hex; value?: bigint }>;\n }\n | { toChainId: number; postCalls?: never };\n\ntype SwapExecutionParams =\n | { returnRawCalls?: false; capabilities?: PrepareCallsCapabilities }\n | { returnRawCalls: true; capabilities?: never };\n\n/**\n * Parameters accepted by the experimental `requestQuoteV0` action.\n */\nexport type RequestQuoteV0Params = Prettify<\n {\n fromToken: Address;\n toToken: Address;\n slippage?: bigint;\n account?: AccountParam;\n chainId?: number;\n } & SwapAmountParams &\n SwapChainParams &\n SwapExecutionParams\n>;\n\n/** The modifiedRequest in client format: `account` instead of `from`, SDK capabilities. */\ntype ClientModifiedRequest = Prettify<\n Omit<\n Extract<\n RequestQuoteV0Response,\n { type: \"paymaster-permit\" }\n >[\"modifiedRequest\"],\n \"from\" | \"capabilities\"\n > & {\n account: Address;\n capabilities?: PrepareCallsCapabilities;\n }\n>;\n\n/**\n * Result returned by the experimental `requestQuoteV0` action.\n */\nexport type RequestQuoteV0Result =\n | Exclude<RequestQuoteV0Response, { type: \"paymaster-permit\" }>\n | (Omit<\n Extract<RequestQuoteV0Response, { type: \"paymaster-permit\" }>,\n \"modifiedRequest\"\n > & {\n modifiedRequest: ClientModifiedRequest;\n });\n\n/**\n * Requests a quote for a token swap, returning either prepared calls for smart wallets\n * or raw calls for EOA wallets depending on the returnRawCalls parameter.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {RequestQuoteV0Params} params - Parameters for requesting a swap quote\n * @param {Address} params.fromToken - The address of the token to swap from\n * @param {Address} params.toToken - The address of the token to swap to\n * @param {bigint} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)\n * @param {bigint} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)\n * @param {AccountParam} [params.account] - The account to execute the swap from. Can be an address string or an object with an `address` property. Defaults to the client's account (signer address via EIP-7702).\n * @param {number} [params.chainId] - The source chain ID. Defaults to the wallet client's chain.\n * @param {number} [params.toChainId] - The destination chain ID for cross-chain swaps. Omit for same-chain swaps.\n * @param {bigint} [params.slippage] - The maximum acceptable slippage in basis points.\n * @param {boolean} [params.returnRawCalls] - Whether to return raw calls for EOA wallets (defaults to false for smart wallets)\n * @param {object} [params.capabilities] - Optional capabilities to include with the request (only available when returnRawCalls is false)\n * @param {Array<{ to: Address; data?: Hex; value?: bigint }>} [params.postCalls] - Optional calls to execute after the swap\n * @returns {Promise<RequestQuoteV0Result>} A Promise that resolves to either prepared calls or raw calls depending on returnRawCalls\n *\n * @example\n * ```ts twoslash\n * // Request a quote for smart wallet (prepared calls)\n * const quote = await client.requestQuoteV0({\n * fromToken: \"0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * toToken: \"0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * fromAmount: 1000000000000000000n, // 1 ETH\n * chainId: 42161, // Arbitrum\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Request a quote for EOA wallet (raw calls)\n * const rawQuote = await client.requestQuoteV0({\n * fromToken: \"0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * toToken: \"0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * fromAmount: 1000000000000000000n,\n * chainId: 42161,\n * returnRawCalls: true\n * });\n * ```\n */\nexport async function requestQuoteV0(\n client: InnerWalletApiClient,\n params: RequestQuoteV0Params,\n): Promise<RequestQuoteV0Result> {\n const from = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n const capabilities =\n \"returnRawCalls\" in params && params.returnRawCalls\n ? undefined\n : mergeClientCapabilities(\n client,\n \"capabilities\" in params ? params.capabilities : undefined,\n );\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = encode(schema.request, {\n ...rest,\n chainId: params.chainId ?? client.chain.id,\n from,\n ...(capabilities && { capabilities: toRpcCapabilities(capabilities) }),\n });\n\n const rpcResp = await client.request({\n method: \"wallet_requestQuote_v0\",\n params: [rpcParams],\n });\n\n const decoded = decode(schema.response, rpcResp);\n\n // Transform paymaster-permit modifiedRequest from RPC format to client format:\n // - `from` (RPC) → `account` (client)\n // - `capabilities.paymasterService` (RPC) → `capabilities.paymaster` (client)\n if (\"type\" in decoded && decoded.type === \"paymaster-permit\") {\n const { from, capabilities, ...restModifiedRequest } =\n decoded.modifiedRequest;\n return {\n ...decoded,\n modifiedRequest: {\n ...restModifiedRequest,\n account: from,\n capabilities: fromRpcCapabilities(capabilities),\n },\n };\n }\n\n return decoded;\n}\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type RequestQuoteV0Params, type RequestQuoteV0Result } from "./actions/requestQuoteV0.js";
|
|
2
2
|
import type { BaseWalletClient } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Experimental swap actions for wallet API clients.
|
|
5
|
+
*/
|
|
3
6
|
export type SwapActions = {
|
|
4
7
|
requestQuoteV0: (params: RequestQuoteV0Params) => Promise<RequestQuoteV0Result>;
|
|
5
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swapActionsDecorator.js","sourceRoot":"","sources":["../../../src/experimental/swapActionsDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAGf,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"swapActionsDecorator.js","sourceRoot":"","sources":["../../../src/experimental/swapActionsDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAGf,MAAM,6BAA6B,CAAC;AAYrC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAA8C,CACpE,MAAM,EACN,EAAE;IACF,mEAAmE;IACnE,2CAA2C;IAC3C,MAAM,OAAO,GAAG,MAA8B,CAAC;IAC/C,OAAO;QACL,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC;KAC5D,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n requestQuoteV0,\n type RequestQuoteV0Params,\n type RequestQuoteV0Result,\n} from \"./actions/requestQuoteV0.js\";\nimport type { BaseWalletClient, InnerWalletApiClient } from \"../types.js\";\n\n/**\n * Experimental swap actions for wallet API clients.\n */\nexport type SwapActions = {\n requestQuoteV0: (\n params: RequestQuoteV0Params,\n ) => Promise<RequestQuoteV0Result>;\n};\n\n/**\n * This is a decorator that is used to add experimental swap actions to a client.\n *\n * @param {BaseWalletClient} client The wallet client to extend with swap functionality\n * @returns {SwapActions} An object containing swap-related actions\n */\nexport const swapActions: (client: BaseWalletClient) => SwapActions = (\n client,\n) => {\n // This is safe. It's just needed b/c we have an internal decorator\n // that we don't expose on the public type.\n const _client = client as InnerWalletApiClient;\n return {\n requestQuoteV0: (params) => requestQuoteV0(_client, params),\n };\n};\n"]}
|
|
@@ -24,10 +24,12 @@ export type * from "../actions/signSignatureRequest.js";
|
|
|
24
24
|
export { signSignatureRequest } from "../actions/signSignatureRequest.js";
|
|
25
25
|
export type * from "../actions/signTypedData.js";
|
|
26
26
|
export { signTypedData } from "../actions/signTypedData.js";
|
|
27
|
-
export type * from "../
|
|
27
|
+
export type * from "../actions/undelegateAccount.js";
|
|
28
|
+
export { undelegateAccount } from "../actions/undelegateAccount.js";
|
|
29
|
+
export type { SmartWalletActions } from "../decorators/smartWalletActions.js";
|
|
28
30
|
export { smartWalletActions } from "../decorators/smartWalletActions.js";
|
|
29
|
-
export type {
|
|
30
|
-
export type
|
|
31
|
+
export type { SmartWalletClient, SolanaSmartWalletClient, SolanaSigner, } from "../types.js";
|
|
32
|
+
export type { CreateEvmSmartWalletClientParams, CreateSolanaSmartWalletClientParams, CreateSmartWalletClientParams, } from "../client.js";
|
|
31
33
|
export { createSmartWalletClient } from "../client.js";
|
|
32
34
|
export type * from "../transport.js";
|
|
33
35
|
export { alchemyWalletTransport } from "../transport.js";
|
|
@@ -11,6 +11,7 @@ export { signMessage } from "../actions/signMessage.js";
|
|
|
11
11
|
export { signPreparedCalls } from "../actions/signPreparedCalls.js";
|
|
12
12
|
export { signSignatureRequest } from "../actions/signSignatureRequest.js";
|
|
13
13
|
export { signTypedData } from "../actions/signTypedData.js";
|
|
14
|
+
export { undelegateAccount } from "../actions/undelegateAccount.js";
|
|
14
15
|
export { smartWalletActions } from "../decorators/smartWalletActions.js";
|
|
15
16
|
export { createSmartWalletClient } from "../client.js";
|
|
16
17
|
export { alchemyWalletTransport } from "../transport.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAIpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAazE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAIvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["// Actions.\nexport type * from \"../actions/formatSign.js\";\nexport { formatSign } from \"../actions/formatSign.js\";\nexport type * from \"../actions/getCapabilities.js\";\nexport { getCapabilities } from \"../actions/getCapabilities.js\";\nexport type * from \"../actions/grantPermissions.js\";\nexport { grantPermissions } from \"../actions/grantPermissions.js\";\nexport type * from \"../actions/listAccounts.js\";\nexport { listAccounts } from \"../actions/listAccounts.js\";\nexport type * from \"../actions/prepareCalls.js\";\nexport { prepareCalls } from \"../actions/prepareCalls.js\";\nexport type * from \"../actions/prepareSign.js\";\nexport { prepareSign } from \"../actions/prepareSign.js\";\nexport type * from \"../actions/requestAccount.js\";\nexport { requestAccount } from \"../actions/requestAccount.js\";\nexport type * from \"../actions/sendCalls.js\";\nexport { sendCalls } from \"../actions/sendCalls.js\";\nexport type * from \"../actions/sendPreparedCalls.js\";\nexport { sendPreparedCalls } from \"../actions/sendPreparedCalls.js\";\nexport type * from \"../actions/signMessage.js\";\nexport { signMessage } from \"../actions/signMessage.js\";\nexport type * from \"../actions/signPreparedCalls.js\";\nexport { signPreparedCalls } from \"../actions/signPreparedCalls.js\";\nexport type * from \"../actions/signSignatureRequest.js\";\nexport { signSignatureRequest } from \"../actions/signSignatureRequest.js\";\nexport type * from \"../actions/signTypedData.js\";\nexport { signTypedData } from \"../actions/signTypedData.js\";\nexport type * from \"../actions/undelegateAccount.js\";\nexport { undelegateAccount } from \"../actions/undelegateAccount.js\";\n\n// Decorators.\nexport type { SmartWalletActions } from \"../decorators/smartWalletActions.js\";\nexport { smartWalletActions } from \"../decorators/smartWalletActions.js\";\n\n// Client.\nexport type {\n SmartWalletClient,\n SolanaSmartWalletClient,\n SolanaSigner,\n} from \"../types.js\";\nexport type {\n CreateEvmSmartWalletClientParams,\n CreateSolanaSmartWalletClientParams,\n CreateSmartWalletClientParams,\n} from \"../client.js\";\nexport { createSmartWalletClient } from \"../client.js\";\n\n// Transport.\nexport type * from \"../transport.js\";\nexport { alchemyWalletTransport } from \"../transport.js\";\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type * from "../actions/solana/prepareCalls.js";
|
|
2
|
+
export { prepareCalls } from "../actions/solana/prepareCalls.js";
|
|
3
|
+
export type * from "../actions/solana/signPreparedCalls.js";
|
|
4
|
+
export { signPreparedCalls } from "../actions/solana/signPreparedCalls.js";
|
|
5
|
+
export type * from "../actions/solana/sendPreparedCalls.js";
|
|
6
|
+
export { sendPreparedCalls } from "../actions/solana/sendPreparedCalls.js";
|
|
7
|
+
export type * from "../actions/solana/sendCalls.js";
|
|
8
|
+
export { sendCalls } from "../actions/solana/sendCalls.js";
|
|
9
|
+
export type * from "../actions/solana/getCallsStatus.js";
|
|
10
|
+
export { getCallsStatus } from "../actions/solana/getCallsStatus.js";
|
|
11
|
+
export type * from "../actions/solana/waitForCallsStatus.js";
|
|
12
|
+
export { waitForCallsStatus } from "../actions/solana/waitForCallsStatus.js";
|
|
13
|
+
export type { SolanaSmartWalletActions } from "../decorators/solanaSmartWalletActions.js";
|
|
14
|
+
export { solanaSmartWalletActions } from "../decorators/solanaSmartWalletActions.js";
|
|
15
|
+
export { SolanaSignerError } from "../adapters/SolanaSignerError.js";
|
|
16
|
+
export { fromKeypair } from "../adapters/fromKeypair.js";
|
|
17
|
+
export type { SolanaKeypairSigner } from "../adapters/fromKeypair.js";
|
|
18
|
+
export { fromKitSigner } from "../adapters/fromKitSigner.js";
|
|
19
|
+
export type { SolanaTransactionPartialSigner } from "../adapters/fromKitSigner.js";
|
|
20
|
+
export { fromWalletAdapter } from "../adapters/fromWalletAdapter.js";
|
|
21
|
+
export type { WalletAdapterSigner } from "../adapters/fromWalletAdapter.js";
|
|
22
|
+
export { fromWalletStandard } from "../adapters/fromWalletStandard.js";
|
|
23
|
+
export type { WalletStandardWallet, WalletStandardAccount, } from "../adapters/fromWalletStandard.js";
|
|
24
|
+
export type { SolanaSigner, SolanaSmartWalletClient } from "../types.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { prepareCalls } from "../actions/solana/prepareCalls.js";
|
|
2
|
+
export { signPreparedCalls } from "../actions/solana/signPreparedCalls.js";
|
|
3
|
+
export { sendPreparedCalls } from "../actions/solana/sendPreparedCalls.js";
|
|
4
|
+
export { sendCalls } from "../actions/solana/sendCalls.js";
|
|
5
|
+
export { getCallsStatus } from "../actions/solana/getCallsStatus.js";
|
|
6
|
+
export { waitForCallsStatus } from "../actions/solana/waitForCallsStatus.js";
|
|
7
|
+
export { solanaSmartWalletActions } from "../decorators/solanaSmartWalletActions.js";
|
|
8
|
+
// Errors.
|
|
9
|
+
export { SolanaSignerError } from "../adapters/SolanaSignerError.js";
|
|
10
|
+
// Adapters.
|
|
11
|
+
export { fromKeypair } from "../adapters/fromKeypair.js";
|
|
12
|
+
export { fromKitSigner } from "../adapters/fromKitSigner.js";
|
|
13
|
+
export { fromWalletAdapter } from "../adapters/fromWalletAdapter.js";
|
|
14
|
+
export { fromWalletStandard } from "../adapters/fromWalletStandard.js";
|
|
15
|
+
//# sourceMappingURL=solana.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solana.js","sourceRoot":"","sources":["../../../src/exports/solana.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAI7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAErF,UAAU;AACV,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,YAAY;AACZ,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC","sourcesContent":["// Actions.\nexport type * from \"../actions/solana/prepareCalls.js\";\nexport { prepareCalls } from \"../actions/solana/prepareCalls.js\";\nexport type * from \"../actions/solana/signPreparedCalls.js\";\nexport { signPreparedCalls } from \"../actions/solana/signPreparedCalls.js\";\nexport type * from \"../actions/solana/sendPreparedCalls.js\";\nexport { sendPreparedCalls } from \"../actions/solana/sendPreparedCalls.js\";\nexport type * from \"../actions/solana/sendCalls.js\";\nexport { sendCalls } from \"../actions/solana/sendCalls.js\";\nexport type * from \"../actions/solana/getCallsStatus.js\";\nexport { getCallsStatus } from \"../actions/solana/getCallsStatus.js\";\nexport type * from \"../actions/solana/waitForCallsStatus.js\";\nexport { waitForCallsStatus } from \"../actions/solana/waitForCallsStatus.js\";\n\n// Decorator.\nexport type { SolanaSmartWalletActions } from \"../decorators/solanaSmartWalletActions.js\";\nexport { solanaSmartWalletActions } from \"../decorators/solanaSmartWalletActions.js\";\n\n// Errors.\nexport { SolanaSignerError } from \"../adapters/SolanaSignerError.js\";\n\n// Adapters.\nexport { fromKeypair } from \"../adapters/fromKeypair.js\";\nexport type { SolanaKeypairSigner } from \"../adapters/fromKeypair.js\";\nexport { fromKitSigner } from \"../adapters/fromKitSigner.js\";\nexport type { SolanaTransactionPartialSigner } from \"../adapters/fromKitSigner.js\";\nexport { fromWalletAdapter } from \"../adapters/fromWalletAdapter.js\";\nexport type { WalletAdapterSigner } from \"../adapters/fromWalletAdapter.js\";\nexport { fromWalletStandard } from \"../adapters/fromWalletStandard.js\";\nexport type {\n WalletStandardWallet,\n WalletStandardAccount,\n} from \"../adapters/fromWalletStandard.js\";\n\n// Types.\nexport type { SolanaSigner, SolanaSmartWalletClient } from \"../types.js\";\n"]}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
import type { WalletServerViemRpcSchema } from "@alchemy/wallet-api-types/rpc";
|
|
2
|
+
import type { SolanaChainId } from "@alchemy/wallet-api-types";
|
|
2
3
|
import type { Account, Address, Chain, Client, Hex, JsonRpcAccount, Transport, WalletClient, LocalAccount } from "viem";
|
|
3
4
|
import type { InternalState } from "./internal";
|
|
4
5
|
import type { SmartWalletActions } from "./decorators/smartWalletActions";
|
|
6
|
+
import type { SolanaSmartWalletActions } from "./decorators/solanaSmartWalletActions";
|
|
5
7
|
export type BaseWalletClient<TExtend extends {
|
|
6
8
|
[key: string]: unknown;
|
|
7
9
|
} | undefined = {
|
|
8
10
|
[key: string]: unknown;
|
|
9
|
-
} | undefined
|
|
11
|
+
} | undefined, TAccount extends Account | undefined = JsonRpcAccount<Address>> = Client<Transport<"alchemyHttp">, Chain, TAccount, WalletServerViemRpcSchema, TExtend>;
|
|
12
|
+
export type SignerClient = WalletClient<Transport, Chain | undefined, Account>;
|
|
13
|
+
export type SmartWalletSigner = LocalAccount | SignerClient;
|
|
14
|
+
export type SmartWalletClient = BaseWalletClient<SmartWalletActions>;
|
|
15
|
+
export type SolanaSmartWalletClient = BaseWalletClient<SolanaSmartWalletActions & {
|
|
16
|
+
solanaAccount: string;
|
|
17
|
+
}, undefined>;
|
|
18
|
+
/** Solana signer interface. Takes serialized tx bytes, returns signed serialized tx bytes. */
|
|
19
|
+
export interface SolanaSigner {
|
|
20
|
+
address: string;
|
|
21
|
+
signTransaction(input: {
|
|
22
|
+
transaction: Uint8Array;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
signedTransaction: Uint8Array;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
export interface SolanaChainDef extends Chain {
|
|
29
|
+
solanaChainId: SolanaChainId;
|
|
30
|
+
}
|
|
10
31
|
export type InnerWalletApiClient = BaseWalletClient<{
|
|
11
32
|
internal: InternalState | undefined;
|
|
12
33
|
owner: SmartWalletSigner;
|
|
13
34
|
policyIds?: string[];
|
|
14
35
|
}>;
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
export type InnerSolanaWalletApiClient = BaseWalletClient<{
|
|
37
|
+
internal: InternalState | undefined;
|
|
38
|
+
owner: SolanaSigner;
|
|
39
|
+
solanaAccount: string;
|
|
40
|
+
policyIds?: string[];
|
|
41
|
+
}, undefined>;
|
|
18
42
|
export type OptionalChainId<T> = T extends {
|
|
19
43
|
chainId: number;
|
|
20
44
|
} ? Omit<T, "chainId"> & {
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { WalletServerViemRpcSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport type {\n Account,\n Address,\n Chain,\n Client,\n Hex,\n JsonRpcAccount,\n Transport,\n WalletClient,\n LocalAccount,\n} from \"viem\";\nimport type { InternalState } from \"./internal\";\nimport type { SmartWalletActions } from \"./decorators/smartWalletActions\";\n\nexport type BaseWalletClient<\n TExtend extends { [key: string]: unknown } | undefined =\n | { [key: string]: unknown }\n | undefined,\n> = Client<\n Transport<\"alchemyHttp\">,\n Chain,\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { WalletServerViemRpcSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport type { SolanaChainId } from \"@alchemy/wallet-api-types\";\nimport type {\n Account,\n Address,\n Chain,\n Client,\n Hex,\n JsonRpcAccount,\n Transport,\n WalletClient,\n LocalAccount,\n} from \"viem\";\nimport type { InternalState } from \"./internal\";\nimport type { SmartWalletActions } from \"./decorators/smartWalletActions\";\nimport type { SolanaSmartWalletActions } from \"./decorators/solanaSmartWalletActions\";\n\nexport type BaseWalletClient<\n TExtend extends { [key: string]: unknown } | undefined =\n | { [key: string]: unknown }\n | undefined,\n TAccount extends Account | undefined = JsonRpcAccount<Address>,\n> = Client<\n Transport<\"alchemyHttp\">,\n Chain,\n TAccount,\n WalletServerViemRpcSchema,\n TExtend\n>;\n\nexport type SignerClient = WalletClient<Transport, Chain | undefined, Account>;\n\nexport type SmartWalletSigner = LocalAccount | SignerClient;\n\nexport type SmartWalletClient = BaseWalletClient<SmartWalletActions>;\n\nexport type SolanaSmartWalletClient = BaseWalletClient<\n SolanaSmartWalletActions & { solanaAccount: string },\n undefined\n>;\n\n/** Solana signer interface. Takes serialized tx bytes, returns signed serialized tx bytes. */\nexport interface SolanaSigner {\n address: string;\n signTransaction(input: {\n transaction: Uint8Array;\n [key: string]: unknown;\n }): Promise<{ signedTransaction: Uint8Array }>;\n}\n\nexport interface SolanaChainDef extends Chain {\n solanaChainId: SolanaChainId;\n}\n\nexport type InnerWalletApiClient = BaseWalletClient<{\n internal: InternalState | undefined;\n owner: SmartWalletSigner;\n policyIds?: string[];\n}>;\n\nexport type InnerSolanaWalletApiClient = BaseWalletClient<\n {\n internal: InternalState | undefined;\n owner: SolanaSigner;\n solanaAccount: string;\n policyIds?: string[];\n },\n undefined\n>;\n\nexport type OptionalChainId<T> = T extends { chainId: number }\n ? Omit<T, \"chainId\"> & { chainId?: number | undefined }\n : T;\n\nexport type OptionalFrom<T> = T extends { from: Address }\n ? Omit<T, \"from\"> & { from?: Address | undefined }\n : T;\n\nexport type WithoutRawPayload<T> = T extends { rawPayload: Hex }\n ? Omit<T, \"rawPayload\">\n : T;\n\nexport type Expect<T extends true> = T;\n\nexport type DistributiveOmit<T, K extends keyof any> = T extends any\n ? Omit<T, K>\n : never;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Client, LocalAccount } from "viem";
|
|
2
|
-
import type { InnerWalletApiClient, SignerClient } from "../types.js";
|
|
1
|
+
import type { Chain, Client, LocalAccount } from "viem";
|
|
2
|
+
import type { InnerWalletApiClient, InnerSolanaWalletApiClient, SignerClient, SolanaChainDef } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Type guard function to check if a client is an Alchemy Smart Wallet Client.
|
|
5
5
|
*
|
|
@@ -7,6 +7,7 @@ import type { InnerWalletApiClient, SignerClient } from "../types.js";
|
|
|
7
7
|
* @returns {boolean} True if the client is an Alchemy Smart Wallet Client
|
|
8
8
|
*/
|
|
9
9
|
export declare function isSmartWalletClient(client: Client): client is InnerWalletApiClient;
|
|
10
|
+
export declare function isSolanaClient(client: Client): client is InnerSolanaWalletApiClient;
|
|
10
11
|
/**
|
|
11
12
|
* Assertion function that throws an error if the client is not an Alchemy Smart Wallet Client.
|
|
12
13
|
* After this function returns successfully, TypeScript will narrow the client type.
|
|
@@ -16,5 +17,6 @@ export declare function isSmartWalletClient(client: Client): client is InnerWall
|
|
|
16
17
|
* @throws {Error} Throws an error if the client is not an Alchemy Smart Wallet Client
|
|
17
18
|
*/
|
|
18
19
|
export declare function assertSmartWalletClient(client: Client, message?: string): asserts client is InnerWalletApiClient;
|
|
20
|
+
export declare function isSolanaChain(chain: Chain): chain is SolanaChainDef;
|
|
19
21
|
export declare function isLocalAccount(signer: LocalAccount | SignerClient): signer is LocalAccount;
|
|
20
22
|
export declare function isSignerClient(signer: LocalAccount | SignerClient): signer is SignerClient;
|
|
@@ -8,6 +8,9 @@ import { BaseError } from "@alchemy/common";
|
|
|
8
8
|
export function isSmartWalletClient(client) {
|
|
9
9
|
return client.name === "alchemySmartWalletClient" && "owner" in client;
|
|
10
10
|
}
|
|
11
|
+
export function isSolanaClient(client) {
|
|
12
|
+
return client.name === "alchemySolanaSmartWalletClient" && "owner" in client;
|
|
13
|
+
}
|
|
11
14
|
/**
|
|
12
15
|
* Assertion function that throws an error if the client is not an Alchemy Smart Wallet Client.
|
|
13
16
|
* After this function returns successfully, TypeScript will narrow the client type.
|
|
@@ -21,6 +24,9 @@ export function assertSmartWalletClient(client, message = "Expected an Alchemy S
|
|
|
21
24
|
throw new BaseError(message);
|
|
22
25
|
}
|
|
23
26
|
}
|
|
27
|
+
export function isSolanaChain(chain) {
|
|
28
|
+
return "solanaChainId" in chain;
|
|
29
|
+
}
|
|
24
30
|
export function isLocalAccount(signer) {
|
|
25
31
|
return signer.type === "local";
|
|
26
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../../src/utils/assertions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../../src/utils/assertions.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAc;IAEd,OAAO,MAAM,CAAC,IAAI,KAAK,0BAA0B,IAAI,OAAO,IAAI,MAAM,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,MAAc;IAEd,OAAO,MAAM,CAAC,IAAI,KAAK,gCAAgC,IAAI,OAAO,IAAI,MAAM,CAAC;AAC/E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAc,EACd,OAAO,GAAG,yCAAyC;IAEnD,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAY;IACxC,OAAO,eAAe,IAAI,KAAK,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,MAAmC;IAEnC,OAAO,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,MAAmC;IAEnC,OAAO,SAAS,IAAI,MAAM,CAAC;AAC7B,CAAC","sourcesContent":["import type { Chain, Client, LocalAccount } from \"viem\";\nimport type {\n InnerWalletApiClient,\n InnerSolanaWalletApiClient,\n SignerClient,\n SolanaChainDef,\n} from \"../types.js\";\nimport { BaseError } from \"@alchemy/common\";\n\n/**\n * Type guard function to check if a client is an Alchemy Smart Wallet Client.\n *\n * @param {Client} client - The client to check\n * @returns {boolean} True if the client is an Alchemy Smart Wallet Client\n */\nexport function isSmartWalletClient(\n client: Client,\n): client is InnerWalletApiClient {\n return client.name === \"alchemySmartWalletClient\" && \"owner\" in client;\n}\n\nexport function isSolanaClient(\n client: Client,\n): client is InnerSolanaWalletApiClient {\n return client.name === \"alchemySolanaSmartWalletClient\" && \"owner\" in client;\n}\n\n/**\n * Assertion function that throws an error if the client is not an Alchemy Smart Wallet Client.\n * After this function returns successfully, TypeScript will narrow the client type.\n *\n * @param {Client} client - The client to assert\n * @param {string} message - Custom error message if assertion fails\n * @throws {Error} Throws an error if the client is not an Alchemy Smart Wallet Client\n */\nexport function assertSmartWalletClient(\n client: Client,\n message = \"Expected an Alchemy Smart Wallet Client\",\n): asserts client is InnerWalletApiClient {\n if (!isSmartWalletClient(client)) {\n throw new BaseError(message);\n }\n}\n\nexport function isSolanaChain(chain: Chain): chain is SolanaChainDef {\n return \"solanaChainId\" in chain;\n}\n\nexport function isLocalAccount(\n signer: LocalAccount | SignerClient,\n): signer is LocalAccount {\n return signer.type === \"local\";\n}\n\nexport function isSignerClient(\n signer: LocalAccount | SignerClient,\n): signer is SignerClient {\n return \"request\" in signer;\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { PrepareCallsCapabilities as PrepareCallsCapabilitiesSchema, SendPreparedCallsCapabilities as SendPreparedCallsCapabilitiesSchema } from "@alchemy/wallet-api-types/capabilities";
|
|
2
|
-
import type {
|
|
3
|
-
import type { InnerWalletApiClient } from "../types.js";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import type { InnerWalletApiClient, InnerSolanaWalletApiClient } from "../types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Decoded capabilities matching the schema shape (uses `paymasterService` key).
|
|
6
6
|
* `ResolveCapabilities` renames this to `paymaster` for client-facing types.
|
|
7
7
|
*/
|
|
8
|
-
type DecodedPrepareCallsCaps =
|
|
9
|
-
type DecodedSendPreparedCallsCaps =
|
|
8
|
+
type DecodedPrepareCallsCaps = z.output<typeof PrepareCallsCapabilitiesSchema>;
|
|
9
|
+
type DecodedSendPreparedCallsCaps = z.output<typeof SendPreparedCallsCapabilitiesSchema>;
|
|
10
10
|
/**
|
|
11
11
|
* Renames `paymasterService` (RPC) to `paymaster` in a capabilities type. This
|
|
12
12
|
* is because our RPC schema's paymasterService capability does not exactly match
|
|
@@ -31,14 +31,14 @@ export type WithCapabilities<T> = T extends {
|
|
|
31
31
|
} : T;
|
|
32
32
|
/**
|
|
33
33
|
* Converts capabilities (with `paymaster`) to RPC capabilities (with `paymasterService`)
|
|
34
|
-
* for use with
|
|
34
|
+
* for use with `encode` before sending to the RPC.
|
|
35
35
|
*
|
|
36
36
|
* @param {PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined} capabilities - Capabilities object containing a `paymaster` field
|
|
37
37
|
* @returns {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} RPC capabilities with `paymasterService`, or undefined if input is undefined
|
|
38
38
|
*/
|
|
39
39
|
export declare function toRpcCapabilities(capabilities: PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined): DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined;
|
|
40
40
|
/**
|
|
41
|
-
* Converts RPC capabilities (with `paymasterService`) from
|
|
41
|
+
* Converts RPC capabilities (with `paymasterService`) from `decode`
|
|
42
42
|
* to capabilities (with `paymaster`).
|
|
43
43
|
*
|
|
44
44
|
* @param {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} capabilities - RPC capabilities object containing a `paymasterService` field
|
|
@@ -54,6 +54,22 @@ export declare function fromRpcCapabilities(capabilities: DecodedPrepareCallsCap
|
|
|
54
54
|
* @returns {T | undefined} The merged capabilities object, or original capabilities if no capability configuration exists on the client
|
|
55
55
|
*/
|
|
56
56
|
export declare const mergeClientCapabilities: <T extends PrepareCallsCapabilities | SendPreparedCallsCapabilities>(client: InnerWalletApiClient, capabilities: T | undefined) => T | undefined;
|
|
57
|
+
export type SolanaPaymasterCapability = {
|
|
58
|
+
policyId: string;
|
|
59
|
+
webhookData?: string;
|
|
60
|
+
};
|
|
61
|
+
export type SolanaPrepareCallsCapabilities = {
|
|
62
|
+
paymaster?: SolanaPaymasterCapability;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Merges Solana client-level capabilities (policyId from factory) with
|
|
66
|
+
* request-level capabilities. Request-level takes priority if provided.
|
|
67
|
+
*
|
|
68
|
+
* @param {InnerSolanaWalletApiClient} client - The Solana wallet API client
|
|
69
|
+
* @param {SolanaPrepareCallsCapabilities | undefined} capabilities - Request capabilities to merge with
|
|
70
|
+
* @returns {SolanaPrepareCallsCapabilities | undefined} The merged capabilities
|
|
71
|
+
*/
|
|
72
|
+
export declare const mergeSolanaClientCapabilities: (client: InnerSolanaWalletApiClient, capabilities: SolanaPrepareCallsCapabilities | undefined) => SolanaPrepareCallsCapabilities | undefined;
|
|
57
73
|
/**
|
|
58
74
|
* Extracts capabilities from prepareCalls that are usable for sendPreparedCalls.
|
|
59
75
|
* Only permissions and paymaster (policyId/policyIds & webhookData) are supported.
|
|
@@ -7,7 +7,7 @@ function hasNoPaymasterServiceField(value) {
|
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Converts capabilities (with `paymaster`) to RPC capabilities (with `paymasterService`)
|
|
10
|
-
* for use with
|
|
10
|
+
* for use with `encode` before sending to the RPC.
|
|
11
11
|
*
|
|
12
12
|
* @param {PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined} capabilities - Capabilities object containing a `paymaster` field
|
|
13
13
|
* @returns {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} RPC capabilities with `paymasterService`, or undefined if input is undefined
|
|
@@ -24,7 +24,7 @@ export function toRpcCapabilities(capabilities) {
|
|
|
24
24
|
return undefined;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Converts RPC capabilities (with `paymasterService`) from
|
|
27
|
+
* Converts RPC capabilities (with `paymasterService`) from `decode`
|
|
28
28
|
* to capabilities (with `paymaster`).
|
|
29
29
|
*
|
|
30
30
|
* @param {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} capabilities - RPC capabilities object containing a `paymasterService` field
|
|
@@ -65,6 +65,23 @@ export const mergeClientCapabilities = (client, capabilities) => {
|
|
|
65
65
|
: { policyIds: client.policyIds },
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Merges Solana client-level capabilities (policyId from factory) with
|
|
70
|
+
* request-level capabilities. Request-level takes priority if provided.
|
|
71
|
+
*
|
|
72
|
+
* @param {InnerSolanaWalletApiClient} client - The Solana wallet API client
|
|
73
|
+
* @param {SolanaPrepareCallsCapabilities | undefined} capabilities - Request capabilities to merge with
|
|
74
|
+
* @returns {SolanaPrepareCallsCapabilities | undefined} The merged capabilities
|
|
75
|
+
*/
|
|
76
|
+
export const mergeSolanaClientCapabilities = (client, capabilities) => {
|
|
77
|
+
if (!client.policyIds?.length || capabilities?.paymaster) {
|
|
78
|
+
return capabilities;
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
...capabilities,
|
|
82
|
+
paymaster: { policyId: client.policyIds[0] },
|
|
83
|
+
};
|
|
84
|
+
};
|
|
68
85
|
/**
|
|
69
86
|
* Extracts capabilities from prepareCalls that are usable for sendPreparedCalls.
|
|
70
87
|
* Only permissions and paymaster (policyId/policyIds & webhookData) are supported.
|