@alchemy/wallet-apis 5.0.0-beta.28 → 5.0.0-beta.29

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.
Files changed (171) hide show
  1. package/dist/esm/actions/prepareCalls.d.ts +8 -3
  2. package/dist/esm/actions/prepareCalls.js +8 -0
  3. package/dist/esm/actions/prepareCalls.js.map +1 -1
  4. package/dist/esm/actions/requestAccount.d.ts +4 -3
  5. package/dist/esm/actions/requestAccount.js.map +1 -1
  6. package/dist/esm/actions/sendPreparedCalls.d.ts +3 -1
  7. package/dist/esm/actions/sendPreparedCalls.js.map +1 -1
  8. package/dist/esm/actions/signPreparedCalls.js +1 -1
  9. package/dist/esm/actions/signPreparedCalls.js.map +1 -1
  10. package/dist/esm/actions/signSignatureRequest.d.ts +4 -4
  11. package/dist/esm/actions/signSignatureRequest.js +1 -1
  12. package/dist/esm/actions/signSignatureRequest.js.map +1 -1
  13. package/dist/esm/actions/signTypedData.d.ts +14 -4
  14. package/dist/esm/actions/signTypedData.js.map +1 -1
  15. package/dist/esm/actions/solana/getCallsStatus.d.ts +24 -0
  16. package/dist/esm/actions/solana/getCallsStatus.js +44 -0
  17. package/dist/esm/actions/solana/getCallsStatus.js.map +1 -0
  18. package/dist/esm/actions/solana/prepareCalls.d.ts +46 -0
  19. package/dist/esm/actions/solana/prepareCalls.js +70 -0
  20. package/dist/esm/actions/solana/prepareCalls.js.map +1 -0
  21. package/dist/esm/actions/solana/sendCalls.d.ts +34 -0
  22. package/dist/esm/actions/solana/sendCalls.js +44 -0
  23. package/dist/esm/actions/solana/sendCalls.js.map +1 -0
  24. package/dist/esm/actions/solana/sendPreparedCalls.d.ts +24 -0
  25. package/dist/esm/actions/solana/sendPreparedCalls.js +32 -0
  26. package/dist/esm/actions/solana/sendPreparedCalls.js.map +1 -0
  27. package/dist/esm/actions/solana/signPreparedCalls.d.ts +23 -0
  28. package/dist/esm/actions/solana/signPreparedCalls.js +24 -0
  29. package/dist/esm/actions/solana/signPreparedCalls.js.map +1 -0
  30. package/dist/esm/actions/solana/signSignatureRequest.d.ts +10 -0
  31. package/dist/esm/actions/solana/signSignatureRequest.js +33 -0
  32. package/dist/esm/actions/solana/signSignatureRequest.js.map +1 -0
  33. package/dist/esm/actions/solana/waitForCallsStatus.d.ts +24 -0
  34. package/dist/esm/actions/solana/waitForCallsStatus.js +46 -0
  35. package/dist/esm/actions/solana/waitForCallsStatus.js.map +1 -0
  36. package/dist/esm/adapters/SolanaSignerError.d.ts +4 -0
  37. package/dist/esm/adapters/SolanaSignerError.js +13 -0
  38. package/dist/esm/adapters/SolanaSignerError.js.map +1 -0
  39. package/dist/esm/adapters/fromKeypair.d.ts +21 -0
  40. package/dist/esm/adapters/fromKeypair.js +46 -0
  41. package/dist/esm/adapters/fromKeypair.js.map +1 -0
  42. package/dist/esm/adapters/fromKitSigner.d.ts +21 -0
  43. package/dist/esm/adapters/fromKitSigner.js +61 -0
  44. package/dist/esm/adapters/fromKitSigner.js.map +1 -0
  45. package/dist/esm/adapters/fromWalletAdapter.d.ts +26 -0
  46. package/dist/esm/adapters/fromWalletAdapter.js +45 -0
  47. package/dist/esm/adapters/fromWalletAdapter.js.map +1 -0
  48. package/dist/esm/adapters/fromWalletStandard.d.ts +31 -0
  49. package/dist/esm/adapters/fromWalletStandard.js +53 -0
  50. package/dist/esm/adapters/fromWalletStandard.js.map +1 -0
  51. package/dist/esm/adapters/resolveSignerSlot.d.ts +10 -0
  52. package/dist/esm/adapters/resolveSignerSlot.js +39 -0
  53. package/dist/esm/adapters/resolveSignerSlot.js.map +1 -0
  54. package/dist/esm/client.d.ts +29 -14
  55. package/dist/esm/client.js +63 -19
  56. package/dist/esm/client.js.map +1 -1
  57. package/dist/esm/decorators/smartWalletActions.js +2 -2
  58. package/dist/esm/decorators/smartWalletActions.js.map +1 -1
  59. package/dist/esm/decorators/solanaSmartWalletActions.d.ts +16 -0
  60. package/dist/esm/decorators/solanaSmartWalletActions.js +16 -0
  61. package/dist/esm/decorators/solanaSmartWalletActions.js.map +1 -0
  62. package/dist/esm/experimental/actions/requestQuoteV0.d.ts +34 -7
  63. package/dist/esm/experimental/actions/requestQuoteV0.js.map +1 -1
  64. package/dist/esm/exports/index.d.ts +3 -3
  65. package/dist/esm/exports/index.js.map +1 -1
  66. package/dist/esm/exports/solana.d.ts +24 -0
  67. package/dist/esm/exports/solana.js +15 -0
  68. package/dist/esm/exports/solana.js.map +1 -0
  69. package/dist/esm/types.d.ts +28 -4
  70. package/dist/esm/types.js.map +1 -1
  71. package/dist/esm/utils/assertions.d.ts +4 -2
  72. package/dist/esm/utils/assertions.js +6 -0
  73. package/dist/esm/utils/assertions.js.map +1 -1
  74. package/dist/esm/utils/capabilities.d.ts +22 -6
  75. package/dist/esm/utils/capabilities.js +19 -2
  76. package/dist/esm/utils/capabilities.js.map +1 -1
  77. package/dist/esm/utils/format.js +1 -1
  78. package/dist/esm/utils/format.js.map +1 -1
  79. package/dist/esm/utils/schema.d.ts +14 -14
  80. package/dist/esm/utils/schema.js +35 -39
  81. package/dist/esm/utils/schema.js.map +1 -1
  82. package/dist/esm/version.d.ts +1 -1
  83. package/dist/esm/version.js +1 -1
  84. package/dist/esm/version.js.map +1 -1
  85. package/dist/types/actions/prepareCalls.d.ts +8 -3
  86. package/dist/types/actions/prepareCalls.d.ts.map +1 -1
  87. package/dist/types/actions/requestAccount.d.ts +4 -3
  88. package/dist/types/actions/requestAccount.d.ts.map +1 -1
  89. package/dist/types/actions/sendPreparedCalls.d.ts +3 -1
  90. package/dist/types/actions/sendPreparedCalls.d.ts.map +1 -1
  91. package/dist/types/actions/signSignatureRequest.d.ts +4 -4
  92. package/dist/types/actions/signSignatureRequest.d.ts.map +1 -1
  93. package/dist/types/actions/signTypedData.d.ts +14 -4
  94. package/dist/types/actions/signTypedData.d.ts.map +1 -1
  95. package/dist/types/actions/solana/getCallsStatus.d.ts +25 -0
  96. package/dist/types/actions/solana/getCallsStatus.d.ts.map +1 -0
  97. package/dist/types/actions/solana/prepareCalls.d.ts +47 -0
  98. package/dist/types/actions/solana/prepareCalls.d.ts.map +1 -0
  99. package/dist/types/actions/solana/sendCalls.d.ts +35 -0
  100. package/dist/types/actions/solana/sendCalls.d.ts.map +1 -0
  101. package/dist/types/actions/solana/sendPreparedCalls.d.ts +25 -0
  102. package/dist/types/actions/solana/sendPreparedCalls.d.ts.map +1 -0
  103. package/dist/types/actions/solana/signPreparedCalls.d.ts +24 -0
  104. package/dist/types/actions/solana/signPreparedCalls.d.ts.map +1 -0
  105. package/dist/types/actions/solana/signSignatureRequest.d.ts +11 -0
  106. package/dist/types/actions/solana/signSignatureRequest.d.ts.map +1 -0
  107. package/dist/types/actions/solana/waitForCallsStatus.d.ts +25 -0
  108. package/dist/types/actions/solana/waitForCallsStatus.d.ts.map +1 -0
  109. package/dist/types/adapters/SolanaSignerError.d.ts +5 -0
  110. package/dist/types/adapters/SolanaSignerError.d.ts.map +1 -0
  111. package/dist/types/adapters/fromKeypair.d.ts +22 -0
  112. package/dist/types/adapters/fromKeypair.d.ts.map +1 -0
  113. package/dist/types/adapters/fromKitSigner.d.ts +22 -0
  114. package/dist/types/adapters/fromKitSigner.d.ts.map +1 -0
  115. package/dist/types/adapters/fromWalletAdapter.d.ts +27 -0
  116. package/dist/types/adapters/fromWalletAdapter.d.ts.map +1 -0
  117. package/dist/types/adapters/fromWalletStandard.d.ts +32 -0
  118. package/dist/types/adapters/fromWalletStandard.d.ts.map +1 -0
  119. package/dist/types/adapters/resolveSignerSlot.d.ts +11 -0
  120. package/dist/types/adapters/resolveSignerSlot.d.ts.map +1 -0
  121. package/dist/types/client.d.ts +29 -14
  122. package/dist/types/client.d.ts.map +1 -1
  123. package/dist/types/decorators/solanaSmartWalletActions.d.ts +17 -0
  124. package/dist/types/decorators/solanaSmartWalletActions.d.ts.map +1 -0
  125. package/dist/types/experimental/actions/requestQuoteV0.d.ts +34 -7
  126. package/dist/types/experimental/actions/requestQuoteV0.d.ts.map +1 -1
  127. package/dist/types/exports/index.d.ts +3 -3
  128. package/dist/types/exports/index.d.ts.map +1 -1
  129. package/dist/types/exports/solana.d.ts +25 -0
  130. package/dist/types/exports/solana.d.ts.map +1 -0
  131. package/dist/types/types.d.ts +28 -4
  132. package/dist/types/types.d.ts.map +1 -1
  133. package/dist/types/utils/assertions.d.ts +4 -2
  134. package/dist/types/utils/assertions.d.ts.map +1 -1
  135. package/dist/types/utils/capabilities.d.ts +22 -6
  136. package/dist/types/utils/capabilities.d.ts.map +1 -1
  137. package/dist/types/utils/schema.d.ts +14 -14
  138. package/dist/types/utils/schema.d.ts.map +1 -1
  139. package/dist/types/version.d.ts +1 -1
  140. package/package.json +26 -9
  141. package/src/actions/prepareCalls.ts +21 -3
  142. package/src/actions/requestAccount.ts +7 -5
  143. package/src/actions/sendPreparedCalls.ts +4 -1
  144. package/src/actions/signPreparedCalls.ts +1 -1
  145. package/src/actions/signSignatureRequest.ts +8 -8
  146. package/src/actions/signTypedData.ts +15 -12
  147. package/src/actions/solana/getCallsStatus.ts +79 -0
  148. package/src/actions/solana/prepareCalls.ts +120 -0
  149. package/src/actions/solana/sendCalls.ts +66 -0
  150. package/src/actions/solana/sendPreparedCalls.ts +65 -0
  151. package/src/actions/solana/signPreparedCalls.ts +50 -0
  152. package/src/actions/solana/signSignatureRequest.ts +63 -0
  153. package/src/actions/solana/waitForCallsStatus.ts +84 -0
  154. package/src/adapters/SolanaSignerError.ts +5 -0
  155. package/src/adapters/fromKeypair.ts +58 -0
  156. package/src/adapters/fromKitSigner.ts +82 -0
  157. package/src/adapters/fromWalletAdapter.ts +58 -0
  158. package/src/adapters/fromWalletStandard.ts +100 -0
  159. package/src/adapters/resolveSignerSlot.ts +46 -0
  160. package/src/client.ts +131 -18
  161. package/src/decorators/smartWalletActions.ts +2 -2
  162. package/src/decorators/solanaSmartWalletActions.ts +62 -0
  163. package/src/experimental/actions/requestQuoteV0.ts +26 -11
  164. package/src/exports/index.ts +8 -4
  165. package/src/exports/solana.ts +36 -0
  166. package/src/types.ts +38 -7
  167. package/src/utils/assertions.ts +17 -2
  168. package/src/utils/capabilities.ts +40 -8
  169. package/src/utils/format.ts +1 -1
  170. package/src/utils/schema.ts +58 -69
  171. package/src/version.ts +1 -1
@@ -0,0 +1,31 @@
1
+ import type { SolanaSigner } from "../types.js";
2
+ /** Minimal structural shape of a wallet-standard account. */
3
+ export interface WalletStandardAccount {
4
+ address: string;
5
+ publicKey?: Uint8Array;
6
+ chains?: readonly string[];
7
+ features?: readonly string[];
8
+ [key: string]: unknown;
9
+ }
10
+ /** Minimal structural shape of a wallet-standard wallet. */
11
+ export interface WalletStandardWallet {
12
+ features: {
13
+ readonly [name: string]: unknown;
14
+ };
15
+ }
16
+ /**
17
+ * Adapts a Wallet Standard wallet into a {@link SolanaSigner}.
18
+ *
19
+ * Works with any wallet that implements the `solana:signTransaction` feature
20
+ * from the Wallet Standard spec (Phantom, Solflare, etc.). No peer dependency
21
+ * required — the interface uses `Uint8Array` directly.
22
+ *
23
+ * For `@solana/wallet-adapter-react` wallets, use {@link fromWalletAdapter}.
24
+ * For `@solana/kit` signers, use {@link fromKitSigner}. For raw Ed25519
25
+ * keypairs, use {@link fromKeypair}.
26
+ *
27
+ * @param {WalletStandardWallet} wallet - The wallet-standard wallet object
28
+ * @param {WalletStandardAccount} account - The account to sign with
29
+ * @returns {SolanaSigner} A SolanaSigner compatible with `createSmartWalletClient`
30
+ */
31
+ export declare function fromWalletStandard(wallet: WalletStandardWallet, account: WalletStandardAccount): SolanaSigner;
@@ -0,0 +1,53 @@
1
+ import { SolanaSignerError } from "./SolanaSignerError.js";
2
+ const SIGN_TRANSACTION = "solana:signTransaction";
3
+ function isSolanaSignTransactionFeature(feature) {
4
+ return (typeof feature === "object" &&
5
+ feature !== null &&
6
+ "signTransaction" in feature &&
7
+ typeof feature.signTransaction ===
8
+ "function");
9
+ }
10
+ /**
11
+ * Adapts a Wallet Standard wallet into a {@link SolanaSigner}.
12
+ *
13
+ * Works with any wallet that implements the `solana:signTransaction` feature
14
+ * from the Wallet Standard spec (Phantom, Solflare, etc.). No peer dependency
15
+ * required — the interface uses `Uint8Array` directly.
16
+ *
17
+ * For `@solana/wallet-adapter-react` wallets, use {@link fromWalletAdapter}.
18
+ * For `@solana/kit` signers, use {@link fromKitSigner}. For raw Ed25519
19
+ * keypairs, use {@link fromKeypair}.
20
+ *
21
+ * @param {WalletStandardWallet} wallet - The wallet-standard wallet object
22
+ * @param {WalletStandardAccount} account - The account to sign with
23
+ * @returns {SolanaSigner} A SolanaSigner compatible with `createSmartWalletClient`
24
+ */
25
+ export function fromWalletStandard(wallet, account) {
26
+ const feature = wallet.features[SIGN_TRANSACTION];
27
+ if (!isSolanaSignTransactionFeature(feature)) {
28
+ throw new SolanaSignerError(`Wallet does not support the "${SIGN_TRANSACTION}" feature.`);
29
+ }
30
+ if (account.features && !account.features.includes(SIGN_TRANSACTION)) {
31
+ throw new SolanaSignerError(`Account ${account.address} does not support the "${SIGN_TRANSACTION}" feature.`);
32
+ }
33
+ return {
34
+ address: account.address,
35
+ async signTransaction({ transaction }) {
36
+ let output;
37
+ try {
38
+ [output] = await feature.signTransaction({ account, transaction });
39
+ }
40
+ catch (e) {
41
+ throw new SolanaSignerError("Wallet standard wallet failed to sign transaction", { cause: e });
42
+ }
43
+ if (!output) {
44
+ throw new SolanaSignerError("Wallet returned no signed transaction.");
45
+ }
46
+ if (!(output.signedTransaction instanceof Uint8Array)) {
47
+ throw new SolanaSignerError("Wallet returned an invalid signed transaction.");
48
+ }
49
+ return output;
50
+ },
51
+ };
52
+ }
53
+ //# sourceMappingURL=fromWalletStandard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fromWalletStandard.js","sourceRoot":"","sources":["../../../src/adapters/fromWalletStandard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAyBlD,SAAS,8BAA8B,CACrC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BACtD,MAAM,IAAI,iBAAiB,CACzB,gDAAgD,CACjD,CAAC;YACJ,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { SolanaSignerError } from \"./SolanaSignerError.js\";\nimport type { SolanaSigner } from \"../types.js\";\n\nconst SIGN_TRANSACTION = \"solana:signTransaction\";\n\n/** Minimal structural shape of a wallet-standard account. */\nexport interface WalletStandardAccount {\n address: string;\n publicKey?: Uint8Array;\n chains?: readonly string[];\n features?: readonly string[];\n [key: string]: unknown;\n}\n\n/** Minimal structural shape of a wallet-standard wallet. */\nexport interface WalletStandardWallet {\n features: { readonly [name: string]: unknown };\n}\n\ninterface SolanaSignTransactionFeature {\n readonly signTransaction: (\n ...inputs: readonly {\n account: WalletStandardAccount;\n transaction: Uint8Array;\n }[]\n ) => Promise<readonly { signedTransaction: Uint8Array }[]>;\n}\n\nfunction isSolanaSignTransactionFeature(\n feature: unknown,\n): feature is SolanaSignTransactionFeature {\n return (\n typeof feature === \"object\" &&\n feature !== null &&\n \"signTransaction\" in feature &&\n typeof (feature as { signTransaction?: unknown }).signTransaction ===\n \"function\"\n );\n}\n\n/**\n * Adapts a Wallet Standard wallet into a {@link SolanaSigner}.\n *\n * Works with any wallet that implements the `solana:signTransaction` feature\n * from the Wallet Standard spec (Phantom, Solflare, etc.). No peer dependency\n * required — the interface uses `Uint8Array` directly.\n *\n * For `@solana/wallet-adapter-react` wallets, use {@link fromWalletAdapter}.\n * For `@solana/kit` signers, use {@link fromKitSigner}. For raw Ed25519\n * keypairs, use {@link fromKeypair}.\n *\n * @param {WalletStandardWallet} wallet - The wallet-standard wallet object\n * @param {WalletStandardAccount} account - The account to sign with\n * @returns {SolanaSigner} A SolanaSigner compatible with `createSmartWalletClient`\n */\nexport function fromWalletStandard(\n wallet: WalletStandardWallet,\n account: WalletStandardAccount,\n): SolanaSigner {\n const feature = wallet.features[SIGN_TRANSACTION];\n\n if (!isSolanaSignTransactionFeature(feature)) {\n throw new SolanaSignerError(\n `Wallet does not support the \"${SIGN_TRANSACTION}\" feature.`,\n );\n }\n\n if (account.features && !account.features.includes(SIGN_TRANSACTION)) {\n throw new SolanaSignerError(\n `Account ${account.address} does not support the \"${SIGN_TRANSACTION}\" feature.`,\n );\n }\n\n return {\n address: account.address,\n async signTransaction({ transaction }) {\n let output: { signedTransaction: Uint8Array } | undefined;\n try {\n [output] = await feature.signTransaction({ account, transaction });\n } catch (e) {\n throw new SolanaSignerError(\n \"Wallet standard wallet failed to sign transaction\",\n { cause: e as Error },\n );\n }\n\n if (!output) {\n throw new SolanaSignerError(\"Wallet returned no signed transaction.\");\n }\n\n if (!(output.signedTransaction instanceof Uint8Array)) {\n throw new SolanaSignerError(\n \"Wallet returned an invalid signed transaction.\",\n );\n }\n\n return output;\n },\n };\n}\n"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Finds the signature slot index for `signerAddress` by decoding the
3
+ * transaction message and looking up the address in the account keys.
4
+ * Tries `@solana/kit` first, falls back to `@solana/web3.js`.
5
+ *
6
+ * @param {Uint8Array} transaction - The serialized Solana transaction bytes
7
+ * @param {string} signerAddress - The base58-encoded address of the signer
8
+ * @returns {Promise<number>} The slot index, or -1 if the address is not a required signer
9
+ */
10
+ export declare function findSignerSlot(transaction: Uint8Array, signerAddress: string): Promise<number>;
@@ -0,0 +1,39 @@
1
+ import { SolanaSignerError } from "./SolanaSignerError.js";
2
+ /**
3
+ * Finds the signature slot index for `signerAddress` by decoding the
4
+ * transaction message and looking up the address in the account keys.
5
+ * Tries `@solana/kit` first, falls back to `@solana/web3.js`.
6
+ *
7
+ * @param {Uint8Array} transaction - The serialized Solana transaction bytes
8
+ * @param {string} signerAddress - The base58-encoded address of the signer
9
+ * @returns {Promise<number>} The slot index, or -1 if the address is not a required signer
10
+ */
11
+ export async function findSignerSlot(transaction, signerAddress) {
12
+ let accounts;
13
+ let numRequiredSigners;
14
+ try {
15
+ const { getCompiledTransactionMessageDecoder } = await import("@solana/kit");
16
+ const numSigs = transaction[0];
17
+ const messageBytes = transaction.slice(1 + numSigs * 64);
18
+ const decoded = getCompiledTransactionMessageDecoder().decode(messageBytes);
19
+ accounts = decoded.staticAccounts;
20
+ numRequiredSigners = decoded.header.numSignerAccounts;
21
+ }
22
+ catch {
23
+ try {
24
+ const { VersionedTransaction } = await import("@solana/web3.js");
25
+ const vtx = VersionedTransaction.deserialize(transaction);
26
+ accounts = vtx.message.staticAccountKeys.map((k) => k.toBase58());
27
+ numRequiredSigners = vtx.message.header.numRequiredSignatures;
28
+ }
29
+ catch {
30
+ throw new SolanaSignerError("Failed to decode transaction: install @solana/kit or @solana/web3.js");
31
+ }
32
+ }
33
+ const slotIndex = accounts.indexOf(signerAddress);
34
+ if (slotIndex < 0 || slotIndex >= numRequiredSigners) {
35
+ return -1;
36
+ }
37
+ return slotIndex;
38
+ }
39
+ //# sourceMappingURL=resolveSignerSlot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveSignerSlot.js","sourceRoot":"","sources":["../../../src/adapters/resolveSignerSlot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,WAAuB,EACvB,aAAqB;IAErB,IAAI,QAA2B,CAAC;IAChC,IAAI,kBAA0B,CAAC;IAE/B,IAAI,CAAC;QACH,MAAM,EAAE,oCAAoC,EAAE,GAAG,MAAM,MAAM,CAC3D,aAAa,CACd,CAAC;QACF,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,GAAG,OAAO,GAAG,EAAE,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,oCAAoC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC5E,QAAQ,GAAG,OAAO,CAAC,cAAmC,CAAC;QACvD,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,CAAC;YACH,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;YACjE,MAAM,GAAG,GAAG,oBAAoB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YAC1D,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YAClE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAC;QAChE,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,iBAAiB,CACzB,sEAAsE,CACvE,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAClD,IAAI,SAAS,GAAG,CAAC,IAAI,SAAS,IAAI,kBAAkB,EAAE,CAAC;QACrD,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { SolanaSignerError } from \"./SolanaSignerError.js\";\n\n/**\n * Finds the signature slot index for `signerAddress` by decoding the\n * transaction message and looking up the address in the account keys.\n * Tries `@solana/kit` first, falls back to `@solana/web3.js`.\n *\n * @param {Uint8Array} transaction - The serialized Solana transaction bytes\n * @param {string} signerAddress - The base58-encoded address of the signer\n * @returns {Promise<number>} The slot index, or -1 if the address is not a required signer\n */\nexport async function findSignerSlot(\n transaction: Uint8Array,\n signerAddress: string,\n): Promise<number> {\n let accounts: readonly string[];\n let numRequiredSigners: number;\n\n try {\n const { getCompiledTransactionMessageDecoder } = await import(\n \"@solana/kit\"\n );\n const numSigs = transaction[0];\n const messageBytes = transaction.slice(1 + numSigs * 64);\n const decoded = getCompiledTransactionMessageDecoder().decode(messageBytes);\n accounts = decoded.staticAccounts as readonly string[];\n numRequiredSigners = decoded.header.numSignerAccounts;\n } catch {\n try {\n const { VersionedTransaction } = await import(\"@solana/web3.js\");\n const vtx = VersionedTransaction.deserialize(transaction);\n accounts = vtx.message.staticAccountKeys.map((k) => k.toBase58());\n numRequiredSigners = vtx.message.header.numRequiredSignatures;\n } catch {\n throw new SolanaSignerError(\n \"Failed to decode transaction: install @solana/kit or @solana/web3.js\",\n );\n }\n }\n\n const slotIndex = accounts.indexOf(signerAddress);\n if (slotIndex < 0 || slotIndex >= numRequiredSigners) {\n return -1;\n }\n return slotIndex;\n}\n"]}
@@ -1,7 +1,9 @@
1
1
  import { type Address, type Chain } from "viem";
2
- import type { SmartWalletClient, SmartWalletSigner } from "./types.js";
2
+ import type { SmartWalletClient, SmartWalletSigner, SolanaSmartWalletClient, SolanaSigner, SolanaChainDef } from "./types.js";
3
3
  import type { AlchemyWalletTransport } from "./transport.js";
4
- export type CreateSmartWalletClientParams = {
4
+ import type { SolanaChainId } from "@alchemy/wallet-api-types";
5
+ export declare const SOLANA_CHAINS: Record<SolanaChainId, SolanaChainDef>;
6
+ export type CreateEvmSmartWalletClientParams = {
5
7
  signer: SmartWalletSigner;
6
8
  transport: AlchemyWalletTransport;
7
9
  chain: Chain;
@@ -11,19 +13,32 @@ export type CreateSmartWalletClientParams = {
11
13
  policyIds?: string[];
12
14
  };
13
15
  };
16
+ export type CreateSolanaSmartWalletClientParams = {
17
+ signer: SolanaSigner;
18
+ transport: AlchemyWalletTransport;
19
+ chain: SolanaChainId;
20
+ account?: string;
21
+ paymaster?: {
22
+ policyId: string;
23
+ };
24
+ };
25
+ /** Either {@link CreateEvmSmartWalletClientParams} or {@link CreateSolanaSmartWalletClientParams}. */
26
+ export type CreateSmartWalletClientParams = CreateEvmSmartWalletClientParams | CreateSolanaSmartWalletClientParams;
27
+ /**
28
+ * Creates a smart wallet client for EVM chains with actions for preparing,
29
+ * signing, and sending user operations.
30
+ *
31
+ * @param {CreateEvmSmartWalletClientParams} params - EVM client configuration
32
+ * @returns {SmartWalletClient} An EVM smart wallet client with smart wallet actions
33
+ */
34
+ export declare function createSmartWalletClient(params: CreateEvmSmartWalletClientParams): SmartWalletClient;
14
35
  /**
15
- * Creates a smart wallet client with wallet API actions.
36
+ * Creates a smart wallet client for Solana chains with actions for preparing,
37
+ * signing, and sending transactions.
16
38
  *
17
- * By default, the client uses EIP-7702 with the signer's address, allowing you to call
18
- * `prepareCalls` or `sendCalls` directly without first calling `requestAccount`.
19
- * Use `requestAccount` only if you need a non-7702 smart account.
39
+ * Solana-specific adapters are in `@alchemy/wallet-apis/solana`.
20
40
  *
21
- * @param {CreateSmartWalletClientParams} params - Parameters for creating the smart wallet client.
22
- * @param {SmartWalletSigner} params.signer - The signer to use for signing transactions.
23
- * @param {AlchemyWalletTransport} params.transport - The transport to use for RPC calls.
24
- * @param {Chain} params.chain - The blockchain network to connect to.
25
- * @param {AccountParam} [params.account] - Optional account. Can be an address string or an object with an `address` property. Defaults to the signer's address (EIP-7702).
26
- * @param {object} [params.paymaster] - Optional paymaster configuration with policy IDs.
27
- * @returns {SmartWalletClient} A wallet client extended with smart wallet actions.
41
+ * @param {CreateSolanaSmartWalletClientParams} params - Solana client configuration
42
+ * @returns {SolanaSmartWalletClient} A Solana smart wallet client with Solana smart wallet actions
28
43
  */
29
- export declare const createSmartWalletClient: ({ signer, transport, chain, account, paymaster, }: CreateSmartWalletClientParams) => SmartWalletClient;
44
+ export declare function createSmartWalletClient(params: CreateSolanaSmartWalletClientParams): SolanaSmartWalletClient;
@@ -1,25 +1,48 @@
1
- import { createClient } from "viem";
1
+ import { BaseError } from "@alchemy/common";
2
+ import { createClient, defineChain } from "viem";
2
3
  import { smartWalletActions } from "./decorators/smartWalletActions.js";
4
+ import { solanaSmartWalletActions } from "./decorators/solanaSmartWalletActions.js";
3
5
  import { createInternalState } from "./internal.js";
4
6
  import { isLocalAccount } from "./utils/assertions.js";
5
- /**
6
- * Creates a smart wallet client with wallet API actions.
7
- *
8
- * By default, the client uses EIP-7702 with the signer's address, allowing you to call
9
- * `prepareCalls` or `sendCalls` directly without first calling `requestAccount`.
10
- * Use `requestAccount` only if you need a non-7702 smart account.
11
- *
12
- * @param {CreateSmartWalletClientParams} params - Parameters for creating the smart wallet client.
13
- * @param {SmartWalletSigner} params.signer - The signer to use for signing transactions.
14
- * @param {AlchemyWalletTransport} params.transport - The transport to use for RPC calls.
15
- * @param {Chain} params.chain - The blockchain network to connect to.
16
- * @param {AccountParam} [params.account] - Optional account. Can be an address string or an object with an `address` property. Defaults to the signer's address (EIP-7702).
17
- * @param {object} [params.paymaster] - Optional paymaster configuration with policy IDs.
18
- * @returns {SmartWalletClient} A wallet client extended with smart wallet actions.
19
- */
20
- export const createSmartWalletClient = ({ signer, transport, chain, account, paymaster, }) => {
7
+ // ── Solana chain definitions ────────────────────────────────────────────
8
+ const solanaMainnet = {
9
+ ...defineChain({
10
+ id: 0,
11
+ name: "Solana Mainnet",
12
+ nativeCurrency: { name: "SOL", symbol: "SOL", decimals: 9 },
13
+ rpcUrls: { default: { http: [] } },
14
+ }),
15
+ solanaChainId: "solana:mainnet",
16
+ };
17
+ const solanaDevnet = {
18
+ ...defineChain({
19
+ id: 0,
20
+ name: "Solana Devnet",
21
+ nativeCurrency: { name: "SOL", symbol: "SOL", decimals: 9 },
22
+ rpcUrls: { default: { http: [] } },
23
+ }),
24
+ solanaChainId: "solana:devnet",
25
+ };
26
+ export const SOLANA_CHAINS = {
27
+ "solana:mainnet": solanaMainnet,
28
+ "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp": solanaMainnet,
29
+ "solana:devnet": solanaDevnet,
30
+ "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1": solanaDevnet,
31
+ };
32
+ // ── Factory ─────────────────────────────────────────────────────────────
33
+ function isSolanaParams(params) {
34
+ return typeof params.chain === "string" && params.chain.startsWith("solana:");
35
+ }
36
+ export function createSmartWalletClient(params) {
37
+ if (isSolanaParams(params)) {
38
+ return createSolanaClient(params);
39
+ }
40
+ return createEvmClient(params);
41
+ }
42
+ // ── EVM path ────────────────────────────────────────────────────────────
43
+ function createEvmClient({ signer, transport, chain, account, paymaster, }) {
21
44
  const _policyIds = [
22
- ...(paymaster?.policyId ? [paymaster?.policyId] : []),
45
+ ...(paymaster?.policyId ? [paymaster.policyId] : []),
23
46
  ...(paymaster?.policyIds ?? []),
24
47
  ];
25
48
  // If no account address is provided, the client defaults to using the signer's address via EIP-7702.
@@ -37,5 +60,26 @@ export const createSmartWalletClient = ({ signer, transport, chain, account, pay
37
60
  owner: signer,
38
61
  }))
39
62
  .extend(smartWalletActions);
40
- };
63
+ }
64
+ // ── Solana path ─────────────────────────────────────────────────────────
65
+ function createSolanaClient({ signer, transport, chain, account, paymaster, }) {
66
+ const _policyIds = paymaster?.policyId ? [paymaster.policyId] : [];
67
+ const _account = account ?? signer.address;
68
+ const _chain = SOLANA_CHAINS[chain];
69
+ if (!_chain) {
70
+ throw new BaseError(`Unsupported Solana chain: ${chain}`);
71
+ }
72
+ return createClient({
73
+ transport,
74
+ chain: _chain,
75
+ name: "alchemySolanaSmartWalletClient",
76
+ })
77
+ .extend(() => ({
78
+ policyIds: _policyIds,
79
+ internal: createInternalState(),
80
+ owner: signer,
81
+ solanaAccount: _account,
82
+ }))
83
+ .extend(solanaSmartWalletActions);
84
+ }
41
85
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA4B,MAAM,MAAM,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAcvD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EACtC,MAAM,EACN,SAAS,EACT,KAAK,EACL,OAAO,EACP,SAAS,GACqB,EAAqB,EAAE;IACrD,MAAM,UAAU,GAAG;QACjB,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,SAAS,EAAE,SAAS,IAAI,EAAE,CAAC;KAChC,CAAC;IAEF,qGAAqG;IACrG,MAAM,QAAQ,GACZ,OAAO;QACP,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAErE,OAAO,YAAY,CAAC;QAClB,OAAO,EAAE,QAAQ;QACjB,SAAS;QACT,KAAK;QACL,IAAI,EAAE,0BAA0B;KACjC,CAAC;SACC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACb,SAAS,EAAE,UAAU;QACrB,QAAQ,EAAE,mBAAmB,EAAE;QAC/B,KAAK,EAAE,MAAM;KACd,CAAC,CAAC;SACF,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAChC,CAAC,CAAC","sourcesContent":["import { createClient, type Address, type Chain } from \"viem\";\nimport { smartWalletActions } from \"./decorators/smartWalletActions.js\";\nimport type { SmartWalletClient, SmartWalletSigner } from \"./types.js\";\nimport { createInternalState } from \"./internal.js\";\nimport { isLocalAccount } from \"./utils/assertions.js\";\nimport type { AlchemyWalletTransport } from \"./transport.js\";\n\nexport type CreateSmartWalletClientParams = {\n signer: SmartWalletSigner;\n transport: AlchemyWalletTransport;\n chain: Chain;\n account?: Address;\n paymaster?: {\n policyId?: string;\n policyIds?: string[];\n };\n};\n\n/**\n * Creates a smart wallet client with wallet API actions.\n *\n * By default, the client uses EIP-7702 with the signer's address, allowing you to call\n * `prepareCalls` or `sendCalls` directly without first calling `requestAccount`.\n * Use `requestAccount` only if you need a non-7702 smart account.\n *\n * @param {CreateSmartWalletClientParams} params - Parameters for creating the smart wallet client.\n * @param {SmartWalletSigner} params.signer - The signer to use for signing transactions.\n * @param {AlchemyWalletTransport} params.transport - The transport to use for RPC calls.\n * @param {Chain} params.chain - The blockchain network to connect to.\n * @param {AccountParam} [params.account] - Optional account. Can be an address string or an object with an `address` property. Defaults to the signer's address (EIP-7702).\n * @param {object} [params.paymaster] - Optional paymaster configuration with policy IDs.\n * @returns {SmartWalletClient} A wallet client extended with smart wallet actions.\n */\nexport const createSmartWalletClient = ({\n signer,\n transport,\n chain,\n account,\n paymaster,\n}: CreateSmartWalletClientParams): SmartWalletClient => {\n const _policyIds = [\n ...(paymaster?.policyId ? [paymaster?.policyId] : []),\n ...(paymaster?.policyIds ?? []),\n ];\n\n // If no account address is provided, the client defaults to using the signer's address via EIP-7702.\n const _account =\n account ??\n (isLocalAccount(signer) ? signer.address : signer.account.address);\n\n return createClient({\n account: _account,\n transport,\n chain,\n name: \"alchemySmartWalletClient\",\n })\n .extend(() => ({\n policyIds: _policyIds,\n internal: createInternalState(),\n owner: signer,\n }))\n .extend(smartWalletActions);\n};\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,WAAW,EAA4B,MAAM,MAAM,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AAQpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAIvD,2EAA2E;AAE3E,MAAM,aAAa,GAAmB;IACpC,GAAG,WAAW,CAAC;QACb,EAAE,EAAE,CAAC;QACL,IAAI,EAAE,gBAAgB;QACt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,EAAE,mBAAmB,EAAE;QAC/B,KAAK,EAAE,MAAM;QACb,aAAa,EAAE,QAAQ;KACxB,CAAC,CAAC;SACF,MAAM,CAAC,wBAAwB,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { BaseError } from \"@alchemy/common\";\nimport { createClient, defineChain, type Address, type Chain } from \"viem\";\nimport { smartWalletActions } from \"./decorators/smartWalletActions.js\";\nimport { solanaSmartWalletActions } from \"./decorators/solanaSmartWalletActions.js\";\nimport type {\n SmartWalletClient,\n SmartWalletSigner,\n SolanaSmartWalletClient,\n SolanaSigner,\n SolanaChainDef,\n} from \"./types.js\";\nimport { createInternalState } from \"./internal.js\";\nimport { isLocalAccount } from \"./utils/assertions.js\";\nimport type { AlchemyWalletTransport } from \"./transport.js\";\nimport type { SolanaChainId } from \"@alchemy/wallet-api-types\";\n\n// ── Solana chain definitions ────────────────────────────────────────────\n\nconst solanaMainnet: SolanaChainDef = {\n ...defineChain({\n id: 0,\n name: \"Solana Mainnet\",\n nativeCurrency: { name: \"SOL\", symbol: \"SOL\", decimals: 9 },\n rpcUrls: { default: { http: [] } },\n }),\n solanaChainId: \"solana:mainnet\",\n};\n\nconst solanaDevnet: SolanaChainDef = {\n ...defineChain({\n id: 0,\n name: \"Solana Devnet\",\n nativeCurrency: { name: \"SOL\", symbol: \"SOL\", decimals: 9 },\n rpcUrls: { default: { http: [] } },\n }),\n solanaChainId: \"solana:devnet\",\n};\n\nexport const SOLANA_CHAINS: Record<SolanaChainId, SolanaChainDef> = {\n \"solana:mainnet\": solanaMainnet,\n \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\": solanaMainnet,\n \"solana:devnet\": solanaDevnet,\n \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\": solanaDevnet,\n};\n\n// ── Param types ─────────────────────────────────────────────────────────\n\nexport type CreateEvmSmartWalletClientParams = {\n signer: SmartWalletSigner;\n transport: AlchemyWalletTransport;\n chain: Chain;\n account?: Address;\n paymaster?: {\n policyId?: string;\n policyIds?: string[];\n };\n};\n\nexport type CreateSolanaSmartWalletClientParams = {\n signer: SolanaSigner;\n transport: AlchemyWalletTransport;\n chain: SolanaChainId;\n account?: string;\n paymaster?: {\n policyId: string;\n };\n};\n\n/** Either {@link CreateEvmSmartWalletClientParams} or {@link CreateSolanaSmartWalletClientParams}. */\nexport type CreateSmartWalletClientParams =\n | CreateEvmSmartWalletClientParams\n | CreateSolanaSmartWalletClientParams;\n\n// ── Factory ─────────────────────────────────────────────────────────────\n\nfunction isSolanaParams(\n params: CreateSmartWalletClientParams,\n): params is CreateSolanaSmartWalletClientParams {\n return typeof params.chain === \"string\" && params.chain.startsWith(\"solana:\");\n}\n\n/**\n * Creates a smart wallet client for EVM chains with actions for preparing,\n * signing, and sending user operations.\n *\n * @param {CreateEvmSmartWalletClientParams} params - EVM client configuration\n * @returns {SmartWalletClient} An EVM smart wallet client with smart wallet actions\n */\nexport function createSmartWalletClient(\n params: CreateEvmSmartWalletClientParams,\n): SmartWalletClient;\n/**\n * Creates a smart wallet client for Solana chains with actions for preparing,\n * signing, and sending transactions.\n *\n * Solana-specific adapters are in `@alchemy/wallet-apis/solana`.\n *\n * @param {CreateSolanaSmartWalletClientParams} params - Solana client configuration\n * @returns {SolanaSmartWalletClient} A Solana smart wallet client with Solana smart wallet actions\n */\nexport function createSmartWalletClient(\n params: CreateSolanaSmartWalletClientParams,\n): SolanaSmartWalletClient;\nexport function createSmartWalletClient(\n params: CreateSmartWalletClientParams,\n): SmartWalletClient | SolanaSmartWalletClient {\n if (isSolanaParams(params)) {\n return createSolanaClient(params);\n }\n return createEvmClient(params);\n}\n\n// ── EVM path ────────────────────────────────────────────────────────────\n\nfunction createEvmClient({\n signer,\n transport,\n chain,\n account,\n paymaster,\n}: CreateEvmSmartWalletClientParams): SmartWalletClient {\n const _policyIds = [\n ...(paymaster?.policyId ? [paymaster.policyId] : []),\n ...(paymaster?.policyIds ?? []),\n ];\n\n // If no account address is provided, the client defaults to using the signer's address via EIP-7702.\n const _account =\n account ??\n (isLocalAccount(signer) ? signer.address : signer.account.address);\n\n return createClient({\n account: _account,\n transport,\n chain,\n name: \"alchemySmartWalletClient\",\n })\n .extend(() => ({\n policyIds: _policyIds,\n internal: createInternalState(),\n owner: signer,\n }))\n .extend(smartWalletActions);\n}\n\n// ── Solana path ─────────────────────────────────────────────────────────\n\nfunction createSolanaClient({\n signer,\n transport,\n chain,\n account,\n paymaster,\n}: CreateSolanaSmartWalletClientParams): SolanaSmartWalletClient {\n const _policyIds = paymaster?.policyId ? [paymaster.policyId] : [];\n\n const _account = account ?? signer.address;\n\n const _chain = SOLANA_CHAINS[chain];\n if (!_chain) {\n throw new BaseError(`Unsupported Solana chain: ${chain}`);\n }\n\n return createClient({\n transport,\n chain: _chain,\n name: \"alchemySolanaSmartWalletClient\",\n })\n .extend(() => ({\n policyIds: _policyIds,\n internal: createInternalState(),\n owner: signer,\n solanaAccount: _account,\n }))\n .extend(solanaSmartWalletActions);\n}\n"]}
@@ -20,7 +20,7 @@ import { getCallsStatus, waitForCallsStatus, } from "viem/actions";
20
20
  * @returns {SmartWalletActions} An object containing smart wallet action methods
21
21
  */
22
22
  export const smartWalletActions = (client) => ({
23
- // Alchemy methods.
23
+ // Alchemy actions.
24
24
  requestAccount: (params) => requestAccount(client, params),
25
25
  prepareCalls: (params) => prepareCalls(client, params),
26
26
  listAccounts: (params) => listAccounts(client, params),
@@ -33,7 +33,7 @@ export const smartWalletActions = (client) => ({
33
33
  grantPermissions: (params) => grantPermissions(client, params),
34
34
  getCapabilities: (params) => getCapabilities(client, params),
35
35
  undelegateAccount: (params) => undelegateAccount(client, params),
36
- // Viem methods.
36
+ // Viem actions.
37
37
  getCallsStatus: (params) => getCallsStatus(client, params),
38
38
  waitForCallsStatus: (params) => waitForCallsStatus(client, params),
39
39
  });
@@ -1 +1 @@
1
- {"version":3,"file":"smartWalletActions.js","sourceRoot":"","sources":["../../../src/decorators/smartWalletActions.ts"],"names":[],"mappings":"AAAA,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AAM,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 methods.\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 methods.\n getCallsStatus: (params) => getCallsStatus(client, params),\n waitForCallsStatus: (params) => waitForCallsStatus(client, params),\n});\n"]}
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,O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AE,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,18 +1,45 @@
1
- import type { Address, Prettify } from "viem";
2
- import type { DistributiveOmit, InnerWalletApiClient } from "../../types.ts";
3
- import { type PrepareCallsCapabilities, type WithCapabilities } from "../../utils/capabilities.js";
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 MethodParams, type MethodResponse } from "../../utils/schema.js";
7
- type BaseRequestQuoteV0Params = MethodParams<typeof MethodSchema>;
6
+ import { type MethodResponse } from "../../utils/schema.js";
8
7
  type RequestQuoteV0Response = MethodResponse<typeof MethodSchema>;
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
+ };
9
33
  /**
10
34
  * Parameters accepted by the experimental `requestQuoteV0` action.
11
35
  */
12
- export type RequestQuoteV0Params = Prettify<WithCapabilities<DistributiveOmit<BaseRequestQuoteV0Params, "from" | "chainId"> & {
36
+ export type RequestQuoteV0Params = Prettify<{
37
+ fromToken: Address;
38
+ toToken: Address;
39
+ slippage?: bigint;
13
40
  account?: AccountParam;
14
41
  chainId?: number;
15
- }>>;
42
+ } & SwapAmountParams & SwapChainParams & SwapExecutionParams>;
16
43
  /** The modifiedRequest in client format: `account` instead of `from`, SDK capabilities. */
17
44
  type ClientModifiedRequest = Prettify<Omit<Extract<RequestQuoteV0Response, {
18
45
  type: "paymaster-permit";
@@ -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,GAGlB,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,GAGP,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AA0C1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;G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,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, Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../../types.ts\";\nimport {\n fromRpcCapabilities,\n mergeClientCapabilities,\n toRpcCapabilities,\n type PrepareCallsCapabilities,\n type WithCapabilities,\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 MethodParams,\n type MethodResponse,\n} from \"../../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseRequestQuoteV0Params = MethodParams<typeof MethodSchema>;\ntype RequestQuoteV0Response = MethodResponse<typeof MethodSchema>;\n\n/**\n * Parameters accepted by the experimental `requestQuoteV0` action.\n */\nexport type RequestQuoteV0Params = Prettify<\n WithCapabilities<\n DistributiveOmit<BaseRequestQuoteV0Params, \"from\" | \"chainId\"> & {\n account?: AccountParam;\n chainId?: number;\n }\n >\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
+ {"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,MA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I,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"]}
@@ -26,10 +26,10 @@ export type * from "../actions/signTypedData.js";
26
26
  export { signTypedData } from "../actions/signTypedData.js";
27
27
  export type * from "../actions/undelegateAccount.js";
28
28
  export { undelegateAccount } from "../actions/undelegateAccount.js";
29
- export type * from "../decorators/smartWalletActions.js";
29
+ export type { SmartWalletActions } from "../decorators/smartWalletActions.js";
30
30
  export { smartWalletActions } from "../decorators/smartWalletActions.js";
31
- export type { BaseWalletClient, SignerClient, SmartWalletClient, } from "../types.js";
32
- export type * from "../client.js";
31
+ export type { SmartWalletClient, SolanaSmartWalletClient, SolanaSigner, } from "../types.js";
32
+ export type { CreateEvmSmartWalletClientParams, CreateSolanaSmartWalletClientParams, CreateSmartWalletClientParams, } from "../client.js";
33
33
  export { createSmartWalletClient } from "../client.js";
34
34
  export type * from "../transport.js";
35
35
  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;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAIpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AASzE,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 * from \"../decorators/smartWalletActions.js\";\nexport { smartWalletActions } from \"../decorators/smartWalletActions.js\";\n\n// Client.\nexport type {\n BaseWalletClient,\n SignerClient,\n SmartWalletClient,\n} from \"../types.js\";\nexport type * from \"../client.js\";\nexport { createSmartWalletClient } from \"../client.js\";\n\n// Transport.\nexport type * from \"../transport.js\";\nexport { alchemyWalletTransport } from \"../transport.js\";\n"]}
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";