@coinbase/agentkit 0.9.1 → 0.10.1

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 (151) hide show
  1. package/README.md +181 -54
  2. package/dist/action-providers/across/acrossActionProvider.js +3 -3
  3. package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +3 -12
  4. package/dist/action-providers/cdp/cdpApiActionProvider.js +2 -79
  5. package/dist/action-providers/cdp/cdpApiActionProvider.test.js +0 -125
  6. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.d.ts +58 -0
  7. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.js +351 -0
  8. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.d.ts +1 -0
  9. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.js +520 -0
  10. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.d.ts +57 -0
  11. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.js +337 -0
  12. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.d.ts +1 -0
  13. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.js +463 -0
  14. package/dist/action-providers/cdp/index.d.ts +3 -0
  15. package/dist/action-providers/cdp/index.js +3 -0
  16. package/dist/action-providers/cdp/schemas.d.ts +38 -9
  17. package/dist/action-providers/cdp/schemas.js +49 -6
  18. package/dist/action-providers/cdp/spendPermissionUtils.d.ts +24 -0
  19. package/dist/action-providers/cdp/spendPermissionUtils.js +66 -0
  20. package/dist/action-providers/cdp/swapUtils.d.ts +32 -0
  21. package/dist/action-providers/cdp/swapUtils.js +142 -0
  22. package/dist/action-providers/clanker/clankerActionProvider.d.ts +43 -0
  23. package/dist/action-providers/clanker/clankerActionProvider.js +130 -0
  24. package/dist/action-providers/clanker/clankerActionProvider.test.d.ts +4 -0
  25. package/dist/action-providers/clanker/clankerActionProvider.test.js +119 -0
  26. package/dist/action-providers/clanker/index.d.ts +2 -0
  27. package/dist/action-providers/clanker/index.js +18 -0
  28. package/dist/action-providers/clanker/schemas.d.ts +56 -0
  29. package/dist/action-providers/clanker/schemas.js +47 -0
  30. package/dist/action-providers/clanker/utils.d.ts +9 -0
  31. package/dist/action-providers/clanker/utils.js +23 -0
  32. package/dist/action-providers/compound/constants.d.ts +1 -1
  33. package/dist/action-providers/compound/constants.js +2 -2
  34. package/dist/action-providers/erc20/constants.d.ts +35 -135
  35. package/dist/action-providers/erc20/constants.js +37 -189
  36. package/dist/action-providers/erc20/erc20ActionProvider.d.ts +9 -1
  37. package/dist/action-providers/erc20/erc20ActionProvider.js +87 -35
  38. package/dist/action-providers/erc20/erc20ActionProvider.test.js +115 -52
  39. package/dist/action-providers/erc20/schemas.d.ts +25 -12
  40. package/dist/action-providers/erc20/schemas.js +34 -6
  41. package/dist/action-providers/erc20/utils.d.ts +19 -0
  42. package/dist/action-providers/erc20/utils.js +54 -0
  43. package/dist/action-providers/flaunch/constants.d.ts +1 -1
  44. package/dist/action-providers/flaunch/constants.js +2 -2
  45. package/dist/action-providers/flaunch/flaunchActionProvider.js +3 -11
  46. package/dist/action-providers/flaunch/flaunchActionProvider.test.js +5 -0
  47. package/dist/action-providers/index.d.ts +4 -0
  48. package/dist/action-providers/index.js +4 -0
  49. package/dist/action-providers/jupiter/schemas.d.ts +1 -1
  50. package/dist/action-providers/moonwell/schemas.d.ts +2 -2
  51. package/dist/action-providers/morpho/morphoActionProvider.js +5 -5
  52. package/dist/action-providers/morpho/schemas.d.ts +2 -2
  53. package/dist/action-providers/pyth/pythActionProvider.js +5 -0
  54. package/dist/action-providers/pyth/pythActionProvider.test.js +5 -1
  55. package/dist/action-providers/superfluid/constants.d.ts +814 -0
  56. package/dist/action-providers/superfluid/constants.js +2826 -0
  57. package/dist/action-providers/superfluid/graphQueries/endpoints.d.ts +2 -0
  58. package/dist/action-providers/superfluid/graphQueries/endpoints.js +5 -0
  59. package/dist/action-providers/superfluid/graphQueries/queries.d.ts +1 -0
  60. package/dist/action-providers/superfluid/graphQueries/queries.js +35 -0
  61. package/dist/action-providers/superfluid/graphQueries/superfluidGraphQueries.d.ts +8 -0
  62. package/dist/action-providers/superfluid/graphQueries/superfluidGraphQueries.js +24 -0
  63. package/dist/action-providers/superfluid/graphQueries/types.d.ts +27 -0
  64. package/dist/action-providers/superfluid/graphQueries/types.js +2 -0
  65. package/dist/action-providers/superfluid/index.d.ts +7 -0
  66. package/dist/action-providers/superfluid/index.js +23 -0
  67. package/dist/action-providers/superfluid/schemas.d.ts +86 -0
  68. package/dist/action-providers/superfluid/schemas.js +103 -0
  69. package/dist/action-providers/superfluid/superfluidActionProvider.d.ts +20 -0
  70. package/dist/action-providers/superfluid/superfluidActionProvider.js +36 -0
  71. package/dist/action-providers/superfluid/superfluidPoolActionProvider.d.ts +46 -0
  72. package/dist/action-providers/superfluid/superfluidPoolActionProvider.js +143 -0
  73. package/dist/action-providers/superfluid/superfluidPoolActionProvider.test.d.ts +1 -0
  74. package/dist/action-providers/superfluid/superfluidPoolActionProvider.test.js +92 -0
  75. package/dist/action-providers/superfluid/superfluidQueryActionProvider.d.ts +27 -0
  76. package/dist/action-providers/superfluid/superfluidQueryActionProvider.js +71 -0
  77. package/dist/action-providers/superfluid/superfluidQueryActionProvider.test.d.ts +1 -0
  78. package/dist/action-providers/superfluid/superfluidQueryActionProvider.test.js +57 -0
  79. package/dist/action-providers/superfluid/superfluidStreamActionProvider.d.ts +56 -0
  80. package/dist/action-providers/superfluid/superfluidStreamActionProvider.js +191 -0
  81. package/dist/action-providers/superfluid/superfluidStreamActionProvider.test.d.ts +1 -0
  82. package/dist/action-providers/superfluid/superfluidStreamActionProvider.test.js +80 -0
  83. package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.d.ts +30 -0
  84. package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.js +108 -0
  85. package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.test.d.ts +1 -0
  86. package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.test.js +75 -0
  87. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.d.ts +32 -0
  88. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.js +101 -0
  89. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.test.d.ts +1 -0
  90. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.test.js +85 -0
  91. package/dist/action-providers/superfluid/utils/parseLogs.d.ts +18 -0
  92. package/dist/action-providers/superfluid/utils/parseLogs.js +78 -0
  93. package/dist/action-providers/truemarkets/truemarketsActionProvider.d.ts +4 -16
  94. package/dist/action-providers/truemarkets/truemarketsActionProvider.js +20 -41
  95. package/dist/action-providers/truemarkets/truemarketsActionProvider.test.js +11 -33
  96. package/dist/action-providers/wallet/walletActionProvider.js +21 -10
  97. package/dist/action-providers/wallet/walletActionProvider.test.js +6 -2
  98. package/dist/action-providers/zerion/constants.d.ts +1 -0
  99. package/dist/action-providers/zerion/constants.js +4 -0
  100. package/dist/action-providers/zerion/index.d.ts +2 -0
  101. package/dist/action-providers/zerion/index.js +18 -0
  102. package/dist/action-providers/zerion/schemas.d.ts +11 -0
  103. package/dist/action-providers/zerion/schemas.js +15 -0
  104. package/dist/action-providers/zerion/types.d.ts +125 -0
  105. package/dist/action-providers/zerion/types.js +16 -0
  106. package/dist/action-providers/zerion/utils.d.ts +3 -0
  107. package/dist/action-providers/zerion/utils.js +45 -0
  108. package/dist/action-providers/zerion/zerionActionProvider.d.ts +57 -0
  109. package/dist/action-providers/zerion/zerionActionProvider.js +159 -0
  110. package/dist/action-providers/zerion/zerionActionProvider.test.d.ts +1 -0
  111. package/dist/action-providers/zerion/zerionActionProvider.test.js +213 -0
  112. package/dist/action-providers/zeroX/index.d.ts +1 -0
  113. package/dist/action-providers/zeroX/index.js +17 -0
  114. package/dist/action-providers/zeroX/schemas.d.ts +51 -0
  115. package/dist/action-providers/zeroX/schemas.js +82 -0
  116. package/dist/action-providers/zeroX/utils.d.ts +23 -0
  117. package/dist/action-providers/zeroX/utils.js +106 -0
  118. package/dist/action-providers/zeroX/zeroXActionProvider.d.ts +57 -0
  119. package/dist/action-providers/zeroX/zeroXActionProvider.js +407 -0
  120. package/dist/action-providers/zeroX/zeroXActionProvider.test.d.ts +1 -0
  121. package/dist/action-providers/zeroX/zeroXActionProvider.test.js +445 -0
  122. package/dist/wallet-providers/cdpEvmWalletProvider.d.ts +20 -2
  123. package/dist/wallet-providers/cdpEvmWalletProvider.js +40 -15
  124. package/dist/wallet-providers/cdpShared.d.ts +9 -0
  125. package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +29 -3
  126. package/dist/wallet-providers/cdpSmartWalletProvider.js +64 -28
  127. package/dist/wallet-providers/cdpSolanaWalletProvider.d.ts +1 -1
  128. package/dist/wallet-providers/cdpSolanaWalletProvider.js +7 -7
  129. package/dist/wallet-providers/cdpSolanaWalletProvider.test.js +15 -12
  130. package/dist/wallet-providers/evmWalletProvider.d.ts +5 -1
  131. package/dist/wallet-providers/legacyCdpSmartWalletProvider.d.ts +9 -2
  132. package/dist/wallet-providers/legacyCdpSmartWalletProvider.js +12 -2
  133. package/dist/wallet-providers/legacyCdpWalletProvider.d.ts +12 -2
  134. package/dist/wallet-providers/legacyCdpWalletProvider.js +11 -2
  135. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.d.ts +10 -2
  136. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.js +12 -3
  137. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.test.js +1 -1
  138. package/dist/wallet-providers/privyEvmWalletProvider.d.ts +2 -0
  139. package/dist/wallet-providers/privyEvmWalletProvider.js +2 -1
  140. package/dist/wallet-providers/privyEvmWalletProvider.test.js +1 -1
  141. package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +1 -1
  142. package/dist/wallet-providers/solanaKeypairWalletProvider.js +3 -4
  143. package/dist/wallet-providers/solanaKeypairWalletProvider.test.js +4 -2
  144. package/dist/wallet-providers/viemWalletProvider.d.ts +12 -2
  145. package/dist/wallet-providers/viemWalletProvider.js +12 -3
  146. package/dist/wallet-providers/viemWalletProvider.test.js +6 -5
  147. package/dist/wallet-providers/walletProvider.d.ts +1 -1
  148. package/dist/wallet-providers/zeroDevWalletProvider.d.ts +10 -2
  149. package/dist/wallet-providers/zeroDevWalletProvider.js +14 -5
  150. package/dist/wallet-providers/zeroDevWalletProvider.test.js +2 -2
  151. package/package.json +4 -2
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _CdpSmartWalletProvider_instances, _CdpSmartWalletProvider_publicClient, _CdpSmartWalletProvider_smartAccount, _CdpSmartWalletProvider_ownerAccount, _CdpSmartWalletProvider_cdp, _CdpSmartWalletProvider_network, _CdpSmartWalletProvider_getCdpSdkNetwork;
13
+ var _CdpSmartWalletProvider_publicClient, _CdpSmartWalletProvider_cdp, _CdpSmartWalletProvider_network, _CdpSmartWalletProvider_paymasterUrl;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.CdpSmartWalletProvider = void 0;
16
16
  const cdp_sdk_1 = require("@coinbase/cdp-sdk");
@@ -28,17 +28,16 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
28
28
  */
29
29
  constructor(config) {
30
30
  super();
31
- _CdpSmartWalletProvider_instances.add(this);
32
31
  _CdpSmartWalletProvider_publicClient.set(this, void 0);
33
- _CdpSmartWalletProvider_smartAccount.set(this, void 0);
34
- _CdpSmartWalletProvider_ownerAccount.set(this, void 0);
35
32
  _CdpSmartWalletProvider_cdp.set(this, void 0);
36
33
  _CdpSmartWalletProvider_network.set(this, void 0);
37
- __classPrivateFieldSet(this, _CdpSmartWalletProvider_smartAccount, config.smartAccount, "f");
38
- __classPrivateFieldSet(this, _CdpSmartWalletProvider_ownerAccount, config.ownerAccount, "f");
34
+ _CdpSmartWalletProvider_paymasterUrl.set(this, void 0);
35
+ this.smartAccount = config.smartAccount;
36
+ this.ownerAccount = config.ownerAccount;
39
37
  __classPrivateFieldSet(this, _CdpSmartWalletProvider_cdp, config.cdp, "f");
40
38
  __classPrivateFieldSet(this, _CdpSmartWalletProvider_publicClient, config.publicClient, "f");
41
39
  __classPrivateFieldSet(this, _CdpSmartWalletProvider_network, config.network, "f");
40
+ __classPrivateFieldSet(this, _CdpSmartWalletProvider_paymasterUrl, config.paymasterUrl, "f");
42
41
  }
43
42
  /**
44
43
  * Configures a new CdpSmartWalletProvider with a smart wallet.
@@ -52,6 +51,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
52
51
  const apiKeySecret = config.apiKeySecret || process.env.CDP_API_KEY_SECRET;
53
52
  const walletSecret = config.walletSecret || process.env.CDP_WALLET_SECRET;
54
53
  const idempotencyKey = config.idempotencyKey || process.env.IDEMPOTENCY_KEY;
54
+ const paymasterUrl = config.paymasterUrl || process.env.PAYMASTER_URL;
55
55
  if (!apiKeyId || !apiKeySecret || !walletSecret) {
56
56
  throw new Error("Missing required environment variables. CDP_API_KEY_ID, CDP_API_KEY_SECRET, CDP_WALLET_SECRET are required.");
57
57
  }
@@ -90,9 +90,10 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
90
90
  : cdpClient.evm.createSmartAccount({
91
91
  owner: ownerAccount,
92
92
  }));
93
+ const rpcUrl = config.rpcUrl || process.env.RPC_URL;
93
94
  const publicClient = (0, viem_1.createPublicClient)({
94
95
  chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[networkId],
95
- transport: (0, viem_1.http)(),
96
+ transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
96
97
  });
97
98
  return new CdpSmartWalletProvider({
98
99
  publicClient,
@@ -100,6 +101,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
100
101
  smartAccount,
101
102
  ownerAccount,
102
103
  network,
104
+ paymasterUrl,
103
105
  });
104
106
  }
105
107
  /**
@@ -109,9 +111,9 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
109
111
  */
110
112
  async exportWallet() {
111
113
  return {
112
- name: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").name,
113
- address: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").address,
114
- ownerAddress: __classPrivateFieldGet(this, _CdpSmartWalletProvider_ownerAccount, "f").address,
114
+ name: this.smartAccount.name,
115
+ address: this.smartAccount.address,
116
+ ownerAddress: this.ownerAccount.address,
115
117
  };
116
118
  }
117
119
  /**
@@ -132,12 +134,12 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
132
134
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
133
135
  async signTypedData(typedData) {
134
136
  const { domain, types, primaryType, message } = typedData;
135
- return await __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").signTypedData({
137
+ return await this.smartAccount.signTypedData({
136
138
  domain,
137
139
  types,
138
140
  primaryType,
139
141
  message,
140
- network: __classPrivateFieldGet(this, _CdpSmartWalletProvider_instances, "m", _CdpSmartWalletProvider_getCdpSdkNetwork).call(this),
142
+ network: this.getCdpSdkNetwork(),
141
143
  });
142
144
  }
143
145
  /**
@@ -164,9 +166,10 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
164
166
  },
165
167
  ];
166
168
  const userOperation = await __classPrivateFieldGet(this, _CdpSmartWalletProvider_cdp, "f").evm.sendUserOperation({
167
- smartAccount: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f"),
168
- network: __classPrivateFieldGet(this, _CdpSmartWalletProvider_instances, "m", _CdpSmartWalletProvider_getCdpSdkNetwork).call(this),
169
+ smartAccount: this.smartAccount,
170
+ network: this.getCdpSdkNetwork(),
169
171
  calls,
172
+ paymasterUrl: __classPrivateFieldGet(this, _CdpSmartWalletProvider_paymasterUrl, "f"),
170
173
  });
171
174
  return userOperation.userOpHash;
172
175
  }
@@ -176,7 +179,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
176
179
  * @returns The address of the smart wallet.
177
180
  */
178
181
  getAddress() {
179
- return __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").address;
182
+ return this.smartAccount.address;
180
183
  }
181
184
  /**
182
185
  * Gets the network of the wallet.
@@ -202,13 +205,29 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
202
205
  getClient() {
203
206
  return __classPrivateFieldGet(this, _CdpSmartWalletProvider_cdp, "f");
204
207
  }
208
+ /**
209
+ * Gets the paymaster URL for gasless transactions.
210
+ *
211
+ * @returns The paymaster URL if configured, undefined otherwise.
212
+ */
213
+ getPaymasterUrl() {
214
+ return __classPrivateFieldGet(this, _CdpSmartWalletProvider_paymasterUrl, "f");
215
+ }
216
+ /**
217
+ * Gets the Viem PublicClient used for read-only operations.
218
+ *
219
+ * @returns The Viem PublicClient instance used for read-only operations.
220
+ */
221
+ getPublicClient() {
222
+ return __classPrivateFieldGet(this, _CdpSmartWalletProvider_publicClient, "f");
223
+ }
205
224
  /**
206
225
  * Gets the balance of the smart wallet.
207
226
  *
208
227
  * @returns The balance of the wallet in wei
209
228
  */
210
229
  async getBalance() {
211
- return await __classPrivateFieldGet(this, _CdpSmartWalletProvider_publicClient, "f").getBalance({ address: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").address });
230
+ return await __classPrivateFieldGet(this, _CdpSmartWalletProvider_publicClient, "f").getBalance({ address: this.smartAccount.address });
212
231
  }
213
232
  /**
214
233
  * Waits for a user operation receipt.
@@ -222,7 +241,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
222
241
  // This is a simplified implementation - in practice you might want to poll
223
242
  // the CDP API for user operation status
224
243
  return __classPrivateFieldGet(this, _CdpSmartWalletProvider_cdp, "f").evm.waitForUserOperation({
225
- smartAccountAddress: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").address,
244
+ smartAccountAddress: this.smartAccount.address,
226
245
  userOpHash,
227
246
  });
228
247
  }
@@ -239,7 +258,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
239
258
  * Transfer the native asset of the network using smart wallet.
240
259
  *
241
260
  * @param to - The destination address.
242
- * @param value - The amount to transfer in Wei.
261
+ * @param value - The amount to transfer in atomic units (Wei).
243
262
  * @returns The user operation hash.
244
263
  */
245
264
  async nativeTransfer(to, value) {
@@ -249,15 +268,32 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
249
268
  data: "0x",
250
269
  });
251
270
  }
271
+ /**
272
+ * Converts the internal network ID to the format expected by the CDP SDK.
273
+ *
274
+ * @returns The network ID in CDP SDK format
275
+ * @throws Error if the network is not supported
276
+ */
277
+ getCdpSdkNetwork() {
278
+ switch (__classPrivateFieldGet(this, _CdpSmartWalletProvider_network, "f").networkId) {
279
+ case "base-sepolia":
280
+ return "base-sepolia";
281
+ case "base-mainnet":
282
+ return "base";
283
+ case "ethereum-mainnet":
284
+ return "ethereum";
285
+ case "ethereum-sepolia":
286
+ return "ethereum-sepolia";
287
+ case "polygon-mainnet":
288
+ return "polygon";
289
+ case "arbitrum-mainnet":
290
+ return "arbitrum";
291
+ case "optimism-mainnet":
292
+ return "optimism";
293
+ default:
294
+ throw new Error(`Unsupported network for smart wallets: ${__classPrivateFieldGet(this, _CdpSmartWalletProvider_network, "f").networkId}`);
295
+ }
296
+ }
252
297
  }
253
298
  exports.CdpSmartWalletProvider = CdpSmartWalletProvider;
254
- _CdpSmartWalletProvider_publicClient = new WeakMap(), _CdpSmartWalletProvider_smartAccount = new WeakMap(), _CdpSmartWalletProvider_ownerAccount = new WeakMap(), _CdpSmartWalletProvider_cdp = new WeakMap(), _CdpSmartWalletProvider_network = new WeakMap(), _CdpSmartWalletProvider_instances = new WeakSet(), _CdpSmartWalletProvider_getCdpSdkNetwork = function _CdpSmartWalletProvider_getCdpSdkNetwork() {
255
- switch (__classPrivateFieldGet(this, _CdpSmartWalletProvider_network, "f").networkId) {
256
- case "base-sepolia":
257
- return "base-sepolia";
258
- case "base-mainnet":
259
- return "base";
260
- default:
261
- throw new Error(`Unsupported network for smart wallets: ${__classPrivateFieldGet(this, _CdpSmartWalletProvider_network, "f").networkId}`);
262
- }
263
- };
299
+ _CdpSmartWalletProvider_publicClient = new WeakMap(), _CdpSmartWalletProvider_cdp = new WeakMap(), _CdpSmartWalletProvider_network = new WeakMap(), _CdpSmartWalletProvider_paymasterUrl = new WeakMap();
@@ -113,7 +113,7 @@ export declare class CdpSolanaWalletProvider extends SvmWalletProvider implement
113
113
  * Transfer SOL from the wallet to another address
114
114
  *
115
115
  * @param to - The base58 encoded address to transfer the SOL to
116
- * @param value - The amount of SOL to transfer (as a decimal string, e.g. "0.0001")
116
+ * @param value - The amount to transfer in atomic units (Lamports)
117
117
  * @returns The signature
118
118
  */
119
119
  nativeTransfer(to: string, value: string): Promise<string>;
@@ -147,12 +147,13 @@ class CdpSolanaWalletProvider extends svmWalletProvider_1.SvmWalletProvider {
147
147
  async signTransaction(transaction) {
148
148
  const serializedTransaction = transaction.serialize();
149
149
  const encodedSerializedTransaction = Buffer.from(serializedTransaction).toString("base64");
150
- const signedTransaction = await __classPrivateFieldGet(this, _CdpSolanaWalletProvider_cdp, "f").solana.signTransaction({
150
+ const signedTransactionResponse = await __classPrivateFieldGet(this, _CdpSolanaWalletProvider_cdp, "f").solana.signTransaction({
151
151
  transaction: encodedSerializedTransaction,
152
152
  address: __classPrivateFieldGet(this, _CdpSolanaWalletProvider_serverAccount, "f").address,
153
153
  });
154
- transaction.addSignature(this.getPublicKey(), Buffer.from(signedTransaction.signature, "base64"));
155
- return transaction;
154
+ const signedTransactionBytes = Buffer.from(signedTransactionResponse.signedTransaction, "base64");
155
+ const signedTransaction = web3_js_1.VersionedTransaction.deserialize(signedTransactionBytes);
156
+ return signedTransaction;
156
157
  }
157
158
  /**
158
159
  * Send a transaction
@@ -219,16 +220,15 @@ class CdpSolanaWalletProvider extends svmWalletProvider_1.SvmWalletProvider {
219
220
  * Transfer SOL from the wallet to another address
220
221
  *
221
222
  * @param to - The base58 encoded address to transfer the SOL to
222
- * @param value - The amount of SOL to transfer (as a decimal string, e.g. "0.0001")
223
+ * @param value - The amount to transfer in atomic units (Lamports)
223
224
  * @returns The signature
224
225
  */
225
226
  async nativeTransfer(to, value) {
226
227
  const initialBalance = await this.getBalance();
227
- const solAmount = parseFloat(value);
228
- const lamports = BigInt(Math.floor(solAmount * web3_js_1.LAMPORTS_PER_SOL));
228
+ const lamports = BigInt(value);
229
229
  // Check if we have enough balance (including estimated fees)
230
230
  if (initialBalance < lamports + BigInt(5000)) {
231
- throw new Error(`Insufficient balance. Have ${Number(initialBalance) / web3_js_1.LAMPORTS_PER_SOL} SOL, need ${solAmount + 0.000005} SOL (including fees)`);
231
+ throw new Error(`Insufficient balance. Have ${Number(initialBalance)} lamports, need ${Number(lamports) + 5000} lamports (including fees)`);
232
232
  }
233
233
  const toPubkey = new web3_js_1.PublicKey(to);
234
234
  const instructions = [
@@ -29,13 +29,16 @@ jest.mock("@solana/web3.js", () => {
29
29
  };
30
30
  const MockPublicKey = jest.fn(() => mockPublicKey);
31
31
  MockPublicKey.prototype = mockPublicKey;
32
+ const mockVersionedTransaction = {
33
+ serialize: jest.fn(() => Buffer.from("mock-serialized-tx")),
34
+ addSignature: jest.fn(),
35
+ };
36
+ const MockVersionedTransaction = jest.fn(() => mockVersionedTransaction);
37
+ MockVersionedTransaction.deserialize = jest.fn(() => mockVersionedTransaction);
32
38
  return {
33
39
  Connection: jest.fn(() => mockConnection),
34
40
  PublicKey: MockPublicKey,
35
- VersionedTransaction: jest.fn().mockImplementation(() => ({
36
- serialize: jest.fn(() => Buffer.from("mock-serialized-tx")),
37
- addSignature: jest.fn(),
38
- })),
41
+ VersionedTransaction: MockVersionedTransaction,
39
42
  MessageV0: {
40
43
  compile: jest.fn(),
41
44
  },
@@ -69,9 +72,9 @@ jest.mock("@coinbase/cdp-sdk", () => {
69
72
  address: MOCK_ADDRESS,
70
73
  signTransaction: jest.fn().mockResolvedValue({ signature: MOCK_SIGNATURE }),
71
74
  }));
72
- const mockSignTransaction = jest
73
- .fn()
74
- .mockImplementation(async () => ({ signature: MOCK_SIGNATURE }));
75
+ const mockSignTransaction = jest.fn().mockImplementation(async () => ({
76
+ signedTransaction: Buffer.from("mock-signed-transaction").toString("base64"),
77
+ }));
75
78
  const mockSolanaClient = {
76
79
  createAccount: mockCreateAccount,
77
80
  getAccount: jest.fn(),
@@ -122,9 +125,9 @@ describe("CdpSolanaWalletProvider", () => {
122
125
  };
123
126
  // Set up the mock server account for the provider
124
127
  mockCdpClient.solana.createAccount.mockResolvedValue(mockServerAccount);
125
- mockCdpClient.solana.signTransaction = jest
126
- .fn()
127
- .mockResolvedValue({ signature: MOCK_SIGNATURE });
128
+ mockCdpClient.solana.signTransaction = jest.fn().mockResolvedValue({
129
+ signedTransaction: Buffer.from("mock-signed-transaction").toString("base64"),
130
+ });
128
131
  mockConnection.getBalance.mockResolvedValue(Number(MOCK_BALANCE));
129
132
  mockConnection.getLatestBlockhash.mockResolvedValue({
130
133
  blockhash: "test-blockhash",
@@ -285,7 +288,7 @@ describe("CdpSolanaWalletProvider", () => {
285
288
  describe("native transfer", () => {
286
289
  it("should transfer SOL", async () => {
287
290
  const toAddress = "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin";
288
- const amount = "1.0";
291
+ const amount = "1000000000"; // 1 SOL in lamports
289
292
  // Set a balance that's high enough to cover the transfer + fees
290
293
  mockConnection.getBalance.mockResolvedValueOnce(Number(2000000000n)); // 2 SOL
291
294
  const signature = await provider.nativeTransfer(toAddress, amount);
@@ -295,7 +298,7 @@ describe("CdpSolanaWalletProvider", () => {
295
298
  it("should handle insufficient balance", async () => {
296
299
  mockConnection.getBalance.mockResolvedValueOnce(Number(1000000n)); // 0.001 SOL
297
300
  const toAddress = "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin";
298
- const amount = "1.0";
301
+ const amount = "1000000000"; // 1 SOL in lamports
299
302
  await expect(provider.nativeTransfer(toAddress, amount)).rejects.toThrow("Insufficient balance");
300
303
  });
301
304
  it("should handle invalid address", async () => {
@@ -1,5 +1,5 @@
1
1
  import { WalletProvider } from "./walletProvider";
2
- import { TransactionRequest, ReadContractParameters, ReadContractReturnType, ContractFunctionName, Abi, ContractFunctionArgs, Account } from "viem";
2
+ import { TransactionRequest, ReadContractParameters, ReadContractReturnType, ContractFunctionName, Abi, ContractFunctionArgs, Account, PublicClient } from "viem";
3
3
  /**
4
4
  * EvmWalletProvider is the abstract base class for all EVM wallet providers.
5
5
  *
@@ -54,4 +54,8 @@ export declare abstract class EvmWalletProvider extends WalletProvider {
54
54
  * @returns The response from the contract.
55
55
  */
56
56
  abstract readContract<const abi extends Abi | readonly unknown[], functionName extends ContractFunctionName<abi, "pure" | "view">, const args extends ContractFunctionArgs<abi, "pure" | "view", functionName>>(params: ReadContractParameters<abi, functionName, args>): Promise<ReadContractReturnType<abi, functionName, args>>;
57
+ /**
58
+ * Get the underlying Viem PublicClient for read-only blockchain operations.
59
+ */
60
+ abstract getPublicClient(): PublicClient;
57
61
  }
@@ -1,5 +1,5 @@
1
1
  import { SendUserOperationOptions, Signer } from "@coinbase/coinbase-sdk";
2
- import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, ReadContractParameters, ReadContractReturnType, TransactionRequest } from "viem";
2
+ import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, ReadContractParameters, ReadContractReturnType, TransactionRequest, PublicClient as ViemPublicClient } from "viem";
3
3
  import { Network } from "../network";
4
4
  import { EvmWalletProvider } from "./evmWalletProvider";
5
5
  export interface ConfigureLegacyCdpSmartWalletOptions {
@@ -9,6 +9,7 @@ export interface ConfigureLegacyCdpSmartWalletOptions {
9
9
  smartWalletAddress?: Hex;
10
10
  paymasterUrl?: string;
11
11
  signer: Signer;
12
+ rpcUrl?: string;
12
13
  }
13
14
  /**
14
15
  * A wallet provider that uses Smart Wallets from the Coinbase SDK.
@@ -146,6 +147,12 @@ export declare class LegacyCdpSmartWalletProvider extends EvmWalletProvider {
146
147
  * @returns The name of the wallet provider.
147
148
  */
148
149
  getName(): string;
150
+ /**
151
+ * Gets the Viem PublicClient used for read-only operations.
152
+ *
153
+ * @returns The Viem PublicClient instance used for read-only operations.
154
+ */
155
+ getPublicClient(): ViemPublicClient;
149
156
  /**
150
157
  * Gets the balance of the wallet.
151
158
  *
@@ -170,7 +177,7 @@ export declare class LegacyCdpSmartWalletProvider extends EvmWalletProvider {
170
177
  * Transfer the native asset of the network.
171
178
  *
172
179
  * @param to - The destination address.
173
- * @param value - The amount to transfer in Wei.
180
+ * @param value - The amount to transfer in atomic units (Wei).
174
181
  * @returns The transaction hash.
175
182
  */
176
183
  nativeTransfer(to: Address, value: string): Promise<Hex>;
@@ -34,9 +34,10 @@ class LegacyCdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider
34
34
  _LegacyCdpSmartWalletProvider_publicClient.set(this, void 0);
35
35
  __classPrivateFieldSet(this, _LegacyCdpSmartWalletProvider_network, config.network, "f");
36
36
  __classPrivateFieldSet(this, _LegacyCdpSmartWalletProvider_smartWallet, config.smartWallet, "f");
37
+ const rpcUrl = config.rpcUrl || process.env.RPC_URL;
37
38
  __classPrivateFieldSet(this, _LegacyCdpSmartWalletProvider_publicClient, (0, viem_1.createPublicClient)({
38
39
  chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[config.network.networkId],
39
- transport: (0, viem_1.http)(),
40
+ transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
40
41
  }), "f");
41
42
  }
42
43
  /**
@@ -106,6 +107,7 @@ class LegacyCdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider
106
107
  smartWallet: networkScopedSmartWallet,
107
108
  network,
108
109
  chainId: network.chainId,
110
+ rpcUrl: config.rpcUrl,
109
111
  });
110
112
  return legacyCdpSmartWalletProvider;
111
113
  }
@@ -242,6 +244,14 @@ class LegacyCdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider
242
244
  getName() {
243
245
  return "legacy_cdp_smart_wallet_provider";
244
246
  }
247
+ /**
248
+ * Gets the Viem PublicClient used for read-only operations.
249
+ *
250
+ * @returns The Viem PublicClient instance used for read-only operations.
251
+ */
252
+ getPublicClient() {
253
+ return __classPrivateFieldGet(this, _LegacyCdpSmartWalletProvider_publicClient, "f");
254
+ }
245
255
  /**
246
256
  * Gets the balance of the wallet.
247
257
  *
@@ -278,7 +288,7 @@ class LegacyCdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider
278
288
  * Transfer the native asset of the network.
279
289
  *
280
290
  * @param to - The destination address.
281
- * @param value - The amount to transfer in Wei.
291
+ * @param value - The amount to transfer in atomic units (Wei).
282
292
  * @returns The transaction hash.
283
293
  */
284
294
  async nativeTransfer(to, value) {
@@ -1,4 +1,4 @@
1
- import { ReadContractParameters, ReadContractReturnType, TransactionRequest, TransactionSerializable, Abi, ContractFunctionName, ContractFunctionArgs, Address, Hex } from "viem";
1
+ import { ReadContractParameters, ReadContractReturnType, TransactionRequest, TransactionSerializable, PublicClient, Abi, ContractFunctionName, ContractFunctionArgs, Address, Hex } from "viem";
2
2
  import { EvmWalletProvider } from "./evmWalletProvider";
3
3
  import { Network } from "../network";
4
4
  import { Coinbase, CreateERC20Options, CreateTradeOptions, SmartContract, Trade, Wallet, WalletData } from "@coinbase/coinbase-sdk";
@@ -50,6 +50,10 @@ export interface LegacyCdpWalletProviderConfig extends LegacyCdpProviderConfig {
50
50
  */
51
51
  feePerGasMultiplier?: number;
52
52
  };
53
+ /**
54
+ * Optional RPC URL for Viem public client.
55
+ */
56
+ rpcUrl?: string;
53
57
  }
54
58
  /**
55
59
  * Configuration options for the CDP Agentkit with a Wallet.
@@ -148,6 +152,12 @@ export declare class LegacyCdpWalletProvider extends EvmWalletProvider {
148
152
  * @returns The name of the wallet provider.
149
153
  */
150
154
  getName(): string;
155
+ /**
156
+ * Gets the Viem PublicClient used for read-only operations.
157
+ *
158
+ * @returns The Viem PublicClient instance used for read-only operations.
159
+ */
160
+ getPublicClient(): PublicClient;
151
161
  /**
152
162
  * Gets the balance of the wallet.
153
163
  *
@@ -221,7 +231,7 @@ export declare class LegacyCdpWalletProvider extends EvmWalletProvider {
221
231
  * Transfer the native asset of the network.
222
232
  *
223
233
  * @param to - The destination address.
224
- * @param value - The amount to transfer in Wei.
234
+ * @param value - The amount to transfer in atomic units (Wei).
225
235
  * @returns The transaction hash.
226
236
  */
227
237
  nativeTransfer(to: `0x${string}`, value: string): Promise<`0x${string}`>;
@@ -43,9 +43,10 @@ class LegacyCdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
43
43
  __classPrivateFieldSet(this, _LegacyCdpWalletProvider_cdpWallet, config.wallet, "f");
44
44
  __classPrivateFieldSet(this, _LegacyCdpWalletProvider_address, config.address, "f");
45
45
  __classPrivateFieldSet(this, _LegacyCdpWalletProvider_network, config.network, "f");
46
+ const rpcUrl = config.rpcUrl || process.env.RPC_URL;
46
47
  __classPrivateFieldSet(this, _LegacyCdpWalletProvider_publicClient, (0, viem_1.createPublicClient)({
47
48
  chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[config.network.networkId],
48
- transport: (0, viem_1.http)(),
49
+ transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
49
50
  }), "f");
50
51
  __classPrivateFieldSet(this, _LegacyCdpWalletProvider_gasLimitMultiplier, Math.max(config.gas?.gasLimitMultiplier ?? 1.2, 1), "f");
51
52
  __classPrivateFieldSet(this, _LegacyCdpWalletProvider_feePerGasMultiplier, Math.max(config.gas?.feePerGasMultiplier ?? 1, 1), "f");
@@ -268,6 +269,14 @@ class LegacyCdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
268
269
  getName() {
269
270
  return "legacy_cdp_wallet_provider";
270
271
  }
272
+ /**
273
+ * Gets the Viem PublicClient used for read-only operations.
274
+ *
275
+ * @returns The Viem PublicClient instance used for read-only operations.
276
+ */
277
+ getPublicClient() {
278
+ return __classPrivateFieldGet(this, _LegacyCdpWalletProvider_publicClient, "f");
279
+ }
271
280
  /**
272
281
  * Gets the balance of the wallet.
273
282
  *
@@ -363,7 +372,7 @@ class LegacyCdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
363
372
  * Transfer the native asset of the network.
364
373
  *
365
374
  * @param to - The destination address.
366
- * @param value - The amount to transfer in Wei.
375
+ * @param value - The amount to transfer in atomic units (Wei).
367
376
  * @returns The transaction hash.
368
377
  */
369
378
  async nativeTransfer(to, value) {
@@ -1,4 +1,4 @@
1
- import { Abi, ContractFunctionArgs, ContractFunctionName, Hex, ReadContractParameters, ReadContractReturnType, TransactionReceipt, TransactionRequest } from "viem";
1
+ import { Abi, ContractFunctionArgs, ContractFunctionName, Hex, PublicClient, ReadContractParameters, ReadContractReturnType, TransactionReceipt, TransactionRequest } from "viem";
2
2
  import { Network } from "../network";
3
3
  import { PrivyWalletConfig, PrivyWalletExport } from "./privyShared";
4
4
  import { WalletProvider } from "./walletProvider";
@@ -14,6 +14,8 @@ export interface PrivyEvmDelegatedEmbeddedWalletConfig extends PrivyWalletConfig
14
14
  chainId?: string;
15
15
  /** The wallet type to use */
16
16
  walletType: "embedded";
17
+ /** Optional RPC URL for Viem public client */
18
+ rpcUrl?: string;
17
19
  }
18
20
  /**
19
21
  * A wallet provider that uses Privy's embedded wallets with delegation.
@@ -64,6 +66,12 @@ export declare class PrivyEvmDelegatedEmbeddedWalletProvider extends WalletProvi
64
66
  * @returns The name of the wallet provider.
65
67
  */
66
68
  getName(): string;
69
+ /**
70
+ * Gets the Viem PublicClient used for read-only operations.
71
+ *
72
+ * @returns The Viem PublicClient instance used for read-only operations.
73
+ */
74
+ getPublicClient(): PublicClient;
67
75
  /**
68
76
  * Gets the balance of the wallet.
69
77
  *
@@ -132,7 +140,7 @@ export declare class PrivyEvmDelegatedEmbeddedWalletProvider extends WalletProvi
132
140
  * Transfer the native asset of the network.
133
141
  *
134
142
  * @param to - The destination address.
135
- * @param value - The amount to transfer in Wei.
143
+ * @param value - The amount to transfer in atomic units (Wei).
136
144
  * @returns The transaction hash.
137
145
  */
138
146
  nativeTransfer(to: string, value: string): Promise<Hex>;
@@ -59,9 +59,10 @@ class PrivyEvmDelegatedEmbeddedWalletProvider extends walletProvider_1.WalletPro
59
59
  if (!chain) {
60
60
  throw new Error(`Chain with ID ${chainId} not found`);
61
61
  }
62
+ const rpcUrl = config.rpcUrl || process.env.RPC_URL;
62
63
  __classPrivateFieldSet(this, _PrivyEvmDelegatedEmbeddedWalletProvider_publicClient, (0, viem_1.createPublicClient)({
63
64
  chain,
64
- transport: (0, viem_1.http)(),
65
+ transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
65
66
  }), "f");
66
67
  }
67
68
  /**
@@ -142,6 +143,14 @@ class PrivyEvmDelegatedEmbeddedWalletProvider extends walletProvider_1.WalletPro
142
143
  getName() {
143
144
  return "privy_evm_embedded_wallet_provider";
144
145
  }
146
+ /**
147
+ * Gets the Viem PublicClient used for read-only operations.
148
+ *
149
+ * @returns The Viem PublicClient instance used for read-only operations.
150
+ */
151
+ getPublicClient() {
152
+ return __classPrivateFieldGet(this, _PrivyEvmDelegatedEmbeddedWalletProvider_publicClient, "f");
153
+ }
145
154
  /**
146
155
  * Gets the balance of the wallet.
147
156
  *
@@ -306,11 +315,11 @@ class PrivyEvmDelegatedEmbeddedWalletProvider extends walletProvider_1.WalletPro
306
315
  * Transfer the native asset of the network.
307
316
  *
308
317
  * @param to - The destination address.
309
- * @param value - The amount to transfer in Wei.
318
+ * @param value - The amount to transfer in atomic units (Wei).
310
319
  * @returns The transaction hash.
311
320
  */
312
321
  async nativeTransfer(to, value) {
313
- const valueInWei = (0, viem_1.parseEther)(value);
322
+ const valueInWei = BigInt(value);
314
323
  const valueHex = `0x${valueInWei.toString(16)}`;
315
324
  const body = {
316
325
  address: __classPrivateFieldGet(this, _PrivyEvmDelegatedEmbeddedWalletProvider_address, "f"),
@@ -211,7 +211,7 @@ describe("PrivyEvmDelegatedEmbeddedWalletProvider", () => {
211
211
  });
212
212
  });
213
213
  it("should transfer native tokens", async () => {
214
- const result = await provider.nativeTransfer("0x1234567890123456789012345678901234567890", "1.0");
214
+ const result = await provider.nativeTransfer("0x1234567890123456789012345678901234567890", "1000000000000000000");
215
215
  expect(result).toBe(MOCK_TRANSACTION_HASH);
216
216
  });
217
217
  it("should export wallet data", () => {
@@ -8,6 +8,8 @@ import { PrivyWalletConfig, PrivyWalletExport } from "./privyShared";
8
8
  export interface PrivyEvmWalletConfig extends PrivyWalletConfig {
9
9
  /** Optional chain ID to connect to */
10
10
  chainId?: string;
11
+ /** Optional RPC URL override for Viem wallet/public clients */
12
+ rpcUrl?: string;
11
13
  }
12
14
  /**
13
15
  * A wallet provider that uses Privy's server wallet API.
@@ -107,10 +107,11 @@ class PrivyEvmWalletProvider extends viemWalletProvider_1.ViemWalletProvider {
107
107
  if (!chain) {
108
108
  throw new Error(`Chain with ID ${chainId} not found`);
109
109
  }
110
+ const rpcUrl = config.rpcUrl || process.env.RPC_URL;
110
111
  const walletClient = (0, viem_2.createWalletClient)({
111
112
  account,
112
113
  chain,
113
- transport: (0, viem_2.http)(),
114
+ transport: rpcUrl ? (0, viem_2.http)(rpcUrl) : (0, viem_2.http)(),
114
115
  });
115
116
  return new PrivyEvmWalletProvider(walletClient, { ...config, walletId });
116
117
  }
@@ -272,7 +272,7 @@ describe("PrivyEvmWalletProvider", () => {
272
272
  expect(result).toBe("mock_result");
273
273
  });
274
274
  it("should transfer native tokens", async () => {
275
- const result = await provider.nativeTransfer("0x1234567890123456789012345678901234567890", "1.0");
275
+ const result = await provider.nativeTransfer("0x1234567890123456789012345678901234567890", "1000000000000000000");
276
276
  expect(result).toBe(MOCK_TRANSACTION_HASH);
277
277
  });
278
278
  it("should export wallet data", () => {
@@ -129,7 +129,7 @@ export declare class SolanaKeypairWalletProvider extends SvmWalletProvider {
129
129
  * Transfer SOL from the wallet to another address
130
130
  *
131
131
  * @param to - The base58 encoded address to transfer the SOL to
132
- * @param value - The amount of SOL to transfer (as a decimal string, e.g. "0.0001")
132
+ * @param value - The amount to transfer in atomic units (Lamports)
133
133
  * @returns The signature
134
134
  */
135
135
  nativeTransfer(to: string, value: string): Promise<string>;
@@ -231,16 +231,15 @@ class SolanaKeypairWalletProvider extends svmWalletProvider_1.SvmWalletProvider
231
231
  * Transfer SOL from the wallet to another address
232
232
  *
233
233
  * @param to - The base58 encoded address to transfer the SOL to
234
- * @param value - The amount of SOL to transfer (as a decimal string, e.g. "0.0001")
234
+ * @param value - The amount to transfer in atomic units (Lamports)
235
235
  * @returns The signature
236
236
  */
237
237
  async nativeTransfer(to, value) {
238
238
  const initialBalance = await this.getBalance();
239
- const solAmount = parseFloat(value);
240
- const lamports = BigInt(Math.floor(solAmount * web3_js_1.LAMPORTS_PER_SOL));
239
+ const lamports = BigInt(value);
241
240
  // Check if we have enough balance (including estimated fees)
242
241
  if (initialBalance < lamports + BigInt(5000)) {
243
- throw new Error(`Insufficient balance. Have ${Number(initialBalance) / web3_js_1.LAMPORTS_PER_SOL} SOL, need ${solAmount + 0.000005} SOL (including fees)`);
242
+ throw new Error(`Insufficient balance. Have ${Number(initialBalance)} lamports, need ${Number(lamports) + 5000} lamports (including fees)`);
244
243
  }
245
244
  const toPubkey = new web3_js_1.PublicKey(to);
246
245
  const instructions = [