@coinbase/cdp-sdk 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +190 -105
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +7 -0
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js +30 -63
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/transfer.js +2 -39
- package/_cjs/actions/evm/transfer/transfer.js.map +1 -1
- package/_cjs/actions/evm/transfer/utils.js +0 -12
- package/_cjs/actions/evm/transfer/utils.js.map +1 -1
- package/_cjs/actions/solana/constants.js +9 -0
- package/_cjs/actions/solana/constants.js.map +1 -0
- package/_cjs/actions/solana/transfer.js +117 -0
- package/_cjs/actions/solana/transfer.js.map +1 -0
- package/_cjs/actions/solana/utils.js +66 -0
- package/_cjs/actions/solana/utils.js.map +1 -0
- package/_cjs/analytics.js +2 -0
- package/_cjs/analytics.js.map +1 -1
- package/_cjs/client/evm/constants.js +21 -0
- package/_cjs/client/evm/constants.js.map +1 -0
- package/_cjs/client/evm/evm.js +75 -0
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +35 -4
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +14 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js +26 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +121 -36
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
- package/_cjs/policies/schema.js +60 -1
- package/_cjs/policies/schema.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_cjs/version.js.map +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/solana/toSolanaAccount.js +7 -0
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_esm/actions/evm/transfer/accountTransferStrategy.js +31 -64
- package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/transfer.js +2 -39
- package/_esm/actions/evm/transfer/transfer.js.map +1 -1
- package/_esm/actions/evm/transfer/utils.js +0 -11
- package/_esm/actions/evm/transfer/utils.js.map +1 -1
- package/_esm/actions/solana/constants.js +6 -0
- package/_esm/actions/solana/constants.js.map +1 -0
- package/_esm/actions/solana/transfer.js +114 -0
- package/_esm/actions/solana/transfer.js.map +1 -0
- package/_esm/actions/solana/utils.js +61 -0
- package/_esm/actions/solana/utils.js.map +1 -0
- package/_esm/analytics.js +2 -0
- package/_esm/analytics.js.map +1 -1
- package/_esm/client/evm/constants.js +18 -0
- package/_esm/client/evm/constants.js.map +1 -0
- package/_esm/client/evm/evm.js +75 -0
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +34 -3
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +12 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +23 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +116 -35
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
- package/_esm/policies/schema.js +59 -0
- package/_esm/policies/schema.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_esm/version.js.map +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +2 -2
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +2 -2
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/transfer.d.ts +6 -4
- package/_types/actions/evm/transfer/transfer.d.ts.map +1 -1
- package/_types/actions/evm/transfer/types.d.ts +7 -52
- package/_types/actions/evm/transfer/types.d.ts.map +1 -1
- package/_types/actions/evm/transfer/utils.d.ts +0 -619
- package/_types/actions/evm/transfer/utils.d.ts.map +1 -1
- package/_types/actions/evm/types.d.ts +140 -68
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/actions/solana/constants.d.ts +6 -0
- package/_types/actions/solana/constants.d.ts.map +1 -0
- package/_types/actions/solana/transfer.d.ts +36 -0
- package/_types/actions/solana/transfer.d.ts.map +1 -0
- package/_types/actions/solana/types.d.ts +27 -0
- package/_types/actions/solana/types.d.ts.map +1 -1
- package/_types/actions/solana/utils.d.ts +34 -0
- package/_types/actions/solana/utils.d.ts.map +1 -0
- package/_types/analytics.d.ts.map +1 -1
- package/_types/client/evm/constants.d.ts +5 -0
- package/_types/client/evm/constants.d.ts.map +1 -0
- package/_types/client/evm/evm.d.ts +44 -1
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +13 -1
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +106 -17
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +7 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +2 -0
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +5 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts +2 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/policies/schema.d.ts +630 -0
- package/_types/policies/schema.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/_types/version.d.ts.map +1 -1
- package/accounts/evm/toEvmServerAccount.ts +7 -6
- package/accounts/evm/toEvmSmartAccount.ts +1 -2
- package/accounts/solana/toSolanaAccount.ts +7 -0
- package/actions/evm/transfer/accountTransferStrategy.ts +38 -78
- package/actions/evm/transfer/smartAccountTransferStrategy.ts +43 -63
- package/actions/evm/transfer/transfer.ts +10 -51
- package/actions/evm/transfer/types.ts +8 -66
- package/actions/evm/transfer/utils.ts +0 -13
- package/actions/evm/types.ts +143 -78
- package/actions/solana/constants.ts +6 -0
- package/actions/solana/transfer.ts +219 -0
- package/actions/solana/types.ts +28 -0
- package/actions/solana/utils.ts +79 -0
- package/analytics.ts +2 -0
- package/client/evm/constants.ts +17 -0
- package/client/evm/evm.ts +90 -0
- package/client/evm/evm.types.ts +14 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +146 -18
- package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +41 -0
- package/openapi-client/generated/evm-accounts/evm-accounts.ts +20 -0
- package/openapi-client/generated/policy-engine/policy-engine.msw.ts +199 -56
- package/package.json +2 -1
- package/policies/schema.ts +83 -0
- package/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# CDP SDK Changelog
|
|
2
2
|
|
|
3
|
+
## 1.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#148](https://github.com/coinbase/cdp-sdk/pull/148) [`c894aba`](https://github.com/coinbase/cdp-sdk/commit/c894aba9facb6c64a6a7e3a5537592ae591ce7e8) Thanks [@marcin-cb](https://github.com/marcin-cb)! - Added an ImportAccount method to the EVM client
|
|
8
|
+
|
|
9
|
+
## 1.9.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#128](https://github.com/coinbase/cdp-sdk/pull/128) [`bd4d1d6`](https://github.com/coinbase/cdp-sdk/commit/bd4d1d6855627e24bd4b51937e40df27a2595559) Thanks [@0xRAG](https://github.com/0xRAG)! - Added transfer method to Solana account to easily send tokens on Solana
|
|
14
|
+
|
|
15
|
+
- [#133](https://github.com/coinbase/cdp-sdk/pull/133) [`438d967`](https://github.com/coinbase/cdp-sdk/commit/438d967401c06469bfc44c581a6c0994f77c0f9e) Thanks [@0xRAG](https://github.com/0xRAG)! - Updated Transfer API to allow users to wait for receipt and pass in a parsed amount to transfer
|
|
16
|
+
|
|
17
|
+
- [#141](https://github.com/coinbase/cdp-sdk/pull/141) [`c0273f9`](https://github.com/coinbase/cdp-sdk/commit/c0273f96769f74c78cddbbf0b109dc47cc16b7ca) Thanks [@sammccord](https://github.com/sammccord)! - Added SendEvmTransactionRule to Policy Rules
|
|
18
|
+
|
|
3
19
|
## 1.8.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -105,6 +105,14 @@ const cdp = new CdpClient({
|
|
|
105
105
|
```typescript
|
|
106
106
|
const account = await cdp.evm.createAccount();
|
|
107
107
|
```
|
|
108
|
+
#### Import an EVM account as follows:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
const account = await cdp.evm.importAccount({
|
|
112
|
+
privateKey: "0x123456",
|
|
113
|
+
name: "MyAccount",
|
|
114
|
+
});
|
|
115
|
+
```
|
|
108
116
|
|
|
109
117
|
#### Create a Solana account as follows:
|
|
110
118
|
|
|
@@ -137,8 +145,8 @@ const account = await cdp.evm.updateAccount({
|
|
|
137
145
|
addresss: account.address,
|
|
138
146
|
update: {
|
|
139
147
|
name: "Updated name",
|
|
140
|
-
accountPolicy: "1622d4b7-9d60-44a2-9a6a-e9bbb167e412"
|
|
141
|
-
}
|
|
148
|
+
accountPolicy: "1622d4b7-9d60-44a2-9a6a-e9bbb167e412",
|
|
149
|
+
},
|
|
142
150
|
});
|
|
143
151
|
```
|
|
144
152
|
|
|
@@ -149,8 +157,8 @@ const account = await cdp.solana.updateAccount({
|
|
|
149
157
|
addresss: account.address,
|
|
150
158
|
update: {
|
|
151
159
|
name: "Updated name",
|
|
152
|
-
accountPolicy: "1622d4b7-9d60-44a2-9a6a-e9bbb167e412"
|
|
153
|
-
}
|
|
160
|
+
accountPolicy: "1622d4b7-9d60-44a2-9a6a-e9bbb167e412",
|
|
161
|
+
},
|
|
154
162
|
});
|
|
155
163
|
```
|
|
156
164
|
|
|
@@ -316,21 +324,37 @@ const userOperation = await cdp.sendUserOperation({
|
|
|
316
324
|
|
|
317
325
|
### Transferring tokens
|
|
318
326
|
|
|
319
|
-
|
|
327
|
+
#### EVM
|
|
328
|
+
|
|
329
|
+
For complete examples, check out [evm/account.transfer.ts](https://github.com/coinbase/cdp-sdk/blob/main/examples/typescript/evm/account.transfer.ts) and [evm/smartAccount.transfer.ts](https://github.com/coinbase/cdp-sdk/blob/main/examples/typescript/evm/smartAccount.transfer.ts).
|
|
320
330
|
|
|
321
331
|
You can transfer tokens between accounts using the `transfer` function:
|
|
322
332
|
|
|
323
333
|
```typescript
|
|
324
334
|
const sender = await cdp.evm.createAccount({ name: "Sender" });
|
|
325
335
|
|
|
326
|
-
const {
|
|
336
|
+
const { transactionHash } = await sender.transfer({
|
|
327
337
|
to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
328
|
-
amount:
|
|
338
|
+
amount: 10000n, // equivalent to 0.01 USDC
|
|
329
339
|
token: "usdc",
|
|
330
340
|
network: "base-sepolia",
|
|
331
341
|
});
|
|
332
342
|
```
|
|
333
343
|
|
|
344
|
+
You can then [wait for the transaction receipt with a viem Public Client](https://viem.sh/docs/actions/public/waitForTransactionReceipt#waitfortransactionreceipt):
|
|
345
|
+
|
|
346
|
+
```typescript
|
|
347
|
+
import { createPublicClient, http } from "viem";
|
|
348
|
+
import { baseSepolia } from "viem/chains";
|
|
349
|
+
|
|
350
|
+
const publicClient = createPublicClient({
|
|
351
|
+
chain: baseSepolia,
|
|
352
|
+
transport: http(),
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash: transactionHash });
|
|
356
|
+
```
|
|
357
|
+
|
|
334
358
|
Smart Accounts also have a `transfer` function:
|
|
335
359
|
|
|
336
360
|
```typescript
|
|
@@ -339,36 +363,48 @@ const sender = await cdp.evm.createSmartAccount({
|
|
|
339
363
|
});
|
|
340
364
|
console.log("Created smart account", sender);
|
|
341
365
|
|
|
342
|
-
const {
|
|
366
|
+
const { userOpHash } = await sender.transfer({
|
|
343
367
|
to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
344
|
-
amount:
|
|
368
|
+
amount: 10000n, // equivalent to 0.01 USDC
|
|
345
369
|
token: "usdc",
|
|
346
370
|
network: "base-sepolia",
|
|
347
371
|
});
|
|
348
372
|
```
|
|
349
373
|
|
|
350
|
-
|
|
374
|
+
One difference is that the `transfer` function returns the user operation hash, which is different from the transaction hash. You can use the returned user operation hash in a call to `waitForUserOperation` to get the result of the transaction:
|
|
375
|
+
|
|
376
|
+
```typescript
|
|
377
|
+
const receipt = await sender.waitForUserOperation({
|
|
378
|
+
hash: userOpHash,
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
if (receipt.status === "complete") {
|
|
382
|
+
console.log(
|
|
383
|
+
`Transfer successful! Explorer link: https://sepolia.basescan.org/tx/${receipt.userOpHash}`,
|
|
384
|
+
);
|
|
385
|
+
} else {
|
|
386
|
+
console.log(`Something went wrong! User operation hash: ${receipt.userOpHash}`);
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
Using Smart Accounts, you can also specify a paymaster URL:
|
|
351
391
|
|
|
352
392
|
```typescript
|
|
353
|
-
|
|
393
|
+
await sender.transfer({
|
|
354
394
|
to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
355
395
|
amount: "0.01",
|
|
356
396
|
token: "usdc",
|
|
357
397
|
network: "base-sepolia",
|
|
358
398
|
paymasterUrl: "https://some-paymaster-url.com",
|
|
359
|
-
waitOptions: {
|
|
360
|
-
timeout: 30,
|
|
361
|
-
interval: 2,
|
|
362
|
-
},
|
|
363
399
|
});
|
|
364
400
|
```
|
|
365
401
|
|
|
366
|
-
|
|
402
|
+
Transfer amount must be passed as a bigint. To convert common tokens from whole units, you can use utilities such as [`parseEther`](https://viem.sh/docs/utilities/parseEther#parseether) and [`parseUnits`](https://viem.sh/docs/utilities/parseUnits#parseunits) from viem.
|
|
367
403
|
|
|
368
404
|
```typescript
|
|
369
|
-
|
|
405
|
+
await sender.transfer({
|
|
370
406
|
to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
371
|
-
amount:
|
|
407
|
+
amount: parseUnits("0.01", 6), // USDC has 6 decimals
|
|
372
408
|
token: "usdc",
|
|
373
409
|
network: "base-sepolia",
|
|
374
410
|
});
|
|
@@ -377,9 +413,9 @@ const { status } = await sender.transfer({
|
|
|
377
413
|
You can pass `usdc` or `eth` as the token to transfer, or you can pass a contract address directly:
|
|
378
414
|
|
|
379
415
|
```typescript
|
|
380
|
-
|
|
416
|
+
await sender.transfer({
|
|
381
417
|
to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
382
|
-
amount: "0.000001",
|
|
418
|
+
amount: parseUnits("0.000001", 18), // WETH has 18 decimals. equivalent to calling `parseEther("0.000001")`
|
|
383
419
|
token: "0x4200000000000000000000000000000000000006", // WETH on Base Sepolia
|
|
384
420
|
network: "base-sepolia",
|
|
385
421
|
});
|
|
@@ -391,26 +427,77 @@ You can also pass another account as the `to` parameter:
|
|
|
391
427
|
const sender = await cdp.evm.createAccount({ name: "Sender" });
|
|
392
428
|
const receiver = await cdp.evm.createAccount({ name: "Receiver" });
|
|
393
429
|
|
|
394
|
-
|
|
430
|
+
await sender.transfer({
|
|
395
431
|
to: receiver,
|
|
396
|
-
amount:
|
|
432
|
+
amount: 10000n, // equivalent to 0.01 USDC
|
|
397
433
|
token: "usdc",
|
|
398
434
|
network: "base-sepolia",
|
|
399
435
|
});
|
|
400
436
|
```
|
|
401
437
|
|
|
402
|
-
|
|
438
|
+
#### Solana
|
|
439
|
+
|
|
440
|
+
For complete examples, check out [solana/account.transfer.ts](https://github.com/coinbase/cdp-sdk/blob/main/examples/typescript/solana/account.transfer.ts).
|
|
441
|
+
|
|
442
|
+
You can transfer tokens between accounts using the `transfer` function, and wait for the transaction to be confirmed using the `confirmTransaction` function from `@solana/web3.js`:
|
|
403
443
|
|
|
404
444
|
```typescript
|
|
405
|
-
|
|
406
|
-
|
|
445
|
+
import { LAMPORTS_PER_SOL } from "@solana/web3.js";
|
|
446
|
+
|
|
447
|
+
const sender = await cdp.solana.createAccount();
|
|
448
|
+
|
|
449
|
+
const connection = new Connection("https://api.devnet.solana.com");
|
|
450
|
+
|
|
451
|
+
const { signature } = await sender.transfer({
|
|
452
|
+
to: "3KzDtddx4i53FBkvCzuDmRbaMozTZoJBb1TToWhz3JfE",
|
|
453
|
+
amount: 0.01 * LAMPORTS_PER_SOL,
|
|
454
|
+
token: "sol",
|
|
455
|
+
network: connection,
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
459
|
+
|
|
460
|
+
const confirmation = await connection.confirmTransaction(
|
|
461
|
+
{
|
|
462
|
+
signature,
|
|
463
|
+
blockhash,
|
|
464
|
+
lastValidBlockHeight,
|
|
465
|
+
},
|
|
466
|
+
"confirmed",
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
if (confirmation.value.err) {
|
|
470
|
+
console.log(`Something went wrong! Error: ${confirmation.value.err.toString()}`);
|
|
471
|
+
} else {
|
|
472
|
+
console.log(
|
|
473
|
+
`Transaction confirmed: Link: https://explorer.solana.com/tx/${signature}?cluster=devnet`,
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
You can also easily send USDC:
|
|
479
|
+
|
|
480
|
+
```typescript
|
|
481
|
+
const { signature } = await sender.transfer({
|
|
482
|
+
to: "3KzDtddx4i53FBkvCzuDmRbaMozTZoJBb1TToWhz3JfE",
|
|
407
483
|
amount: "0.01",
|
|
408
484
|
token: "usdc",
|
|
409
|
-
network: "
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
485
|
+
network: "devnet",
|
|
486
|
+
});
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
If you want to use your own Connection, you can pass one to the `network` parameter:
|
|
490
|
+
|
|
491
|
+
```typescript
|
|
492
|
+
import { Connection } from "@solana/web3.js";
|
|
493
|
+
|
|
494
|
+
const connection = new Connection("YOUR_RPC_URL");
|
|
495
|
+
|
|
496
|
+
const { signature } = await sender.transfer({
|
|
497
|
+
to: "3KzDtddx4i53FBkvCzuDmRbaMozTZoJBb1TToWhz3JfE",
|
|
498
|
+
amount: "0.01",
|
|
499
|
+
token: "usdc",
|
|
500
|
+
network: connection,
|
|
414
501
|
});
|
|
415
502
|
```
|
|
416
503
|
|
|
@@ -471,7 +558,7 @@ You can use the `signMessage` action:
|
|
|
471
558
|
```typescript
|
|
472
559
|
const account = await cdp.solana.createAccount();
|
|
473
560
|
const { signature } = await account.signMessage({
|
|
474
|
-
message: "Hello, world!"
|
|
561
|
+
message: "Hello, world!",
|
|
475
562
|
});
|
|
476
563
|
```
|
|
477
564
|
|
|
@@ -481,7 +568,6 @@ SolanaAccount supports the following actions:
|
|
|
481
568
|
- `signMessage`
|
|
482
569
|
- `signTransaction`
|
|
483
570
|
|
|
484
|
-
|
|
485
571
|
## Policy Management
|
|
486
572
|
|
|
487
573
|
You can use the policies SDK to manage sets of rules that govern the behavior of accounts and projects, such as enforce allowlists and denylists.
|
|
@@ -493,27 +579,27 @@ This policy will accept any account sending less than a specific amount of ETH t
|
|
|
493
579
|
```typescript
|
|
494
580
|
const policy = await cdp.policies.createPolicy({
|
|
495
581
|
policy: {
|
|
496
|
-
scope:
|
|
497
|
-
description:
|
|
582
|
+
scope: "project",
|
|
583
|
+
description: "Project-wide Allowlist Policy",
|
|
498
584
|
rules: [
|
|
499
585
|
{
|
|
500
|
-
action:
|
|
501
|
-
operation:
|
|
586
|
+
action: "accept",
|
|
587
|
+
operation: "signEvmTransaction",
|
|
502
588
|
criteria: [
|
|
503
589
|
{
|
|
504
|
-
type:
|
|
505
|
-
ethValue:
|
|
506
|
-
operator:
|
|
590
|
+
type: "ethValue",
|
|
591
|
+
ethValue: "1000000000000000000",
|
|
592
|
+
operator: "<=",
|
|
507
593
|
},
|
|
508
594
|
{
|
|
509
|
-
type:
|
|
595
|
+
type: "evmAddress",
|
|
510
596
|
addresses: ["0x000000000000000000000000000000000000dEaD"],
|
|
511
|
-
operator:
|
|
512
|
-
}
|
|
513
|
-
]
|
|
514
|
-
}
|
|
515
|
-
]
|
|
516
|
-
}
|
|
597
|
+
operator: "in",
|
|
598
|
+
},
|
|
599
|
+
],
|
|
600
|
+
},
|
|
601
|
+
],
|
|
602
|
+
},
|
|
517
603
|
});
|
|
518
604
|
```
|
|
519
605
|
|
|
@@ -524,27 +610,27 @@ This policy will accept any transaction with a value less than or equal to 1 ETH
|
|
|
524
610
|
```typescript
|
|
525
611
|
const policy = await cdp.policies.createPolicy({
|
|
526
612
|
policy: {
|
|
527
|
-
scope:
|
|
528
|
-
description:
|
|
613
|
+
scope: "account",
|
|
614
|
+
description: "Account Allowlist Policy",
|
|
529
615
|
rules: [
|
|
530
616
|
{
|
|
531
|
-
action:
|
|
532
|
-
operation:
|
|
617
|
+
action: "accept",
|
|
618
|
+
operation: "signEvmTransaction",
|
|
533
619
|
criteria: [
|
|
534
620
|
{
|
|
535
|
-
type:
|
|
536
|
-
ethValue:
|
|
537
|
-
operator:
|
|
621
|
+
type: "ethValue",
|
|
622
|
+
ethValue: "1000000000000000000",
|
|
623
|
+
operator: "<=",
|
|
538
624
|
},
|
|
539
625
|
{
|
|
540
|
-
type:
|
|
626
|
+
type: "evmAddress",
|
|
541
627
|
addresses: ["0x000000000000000000000000000000000000dEaD"],
|
|
542
|
-
operator:
|
|
543
|
-
}
|
|
544
|
-
]
|
|
545
|
-
}
|
|
546
|
-
]
|
|
547
|
-
}
|
|
628
|
+
operator: "in",
|
|
629
|
+
},
|
|
630
|
+
],
|
|
631
|
+
},
|
|
632
|
+
],
|
|
633
|
+
},
|
|
548
634
|
});
|
|
549
635
|
```
|
|
550
636
|
|
|
@@ -553,22 +639,22 @@ const policy = await cdp.policies.createPolicy({
|
|
|
553
639
|
```typescript
|
|
554
640
|
const policy = await cdp.policies.createPolicy({
|
|
555
641
|
policy: {
|
|
556
|
-
scope:
|
|
557
|
-
description:
|
|
642
|
+
scope: "account",
|
|
643
|
+
description: "Account Allowlist Policy",
|
|
558
644
|
rules: [
|
|
559
645
|
{
|
|
560
|
-
action:
|
|
561
|
-
operation:
|
|
646
|
+
action: "accept",
|
|
647
|
+
operation: "signSolTransaction",
|
|
562
648
|
criteria: [
|
|
563
649
|
{
|
|
564
|
-
type:
|
|
650
|
+
type: "solAddress",
|
|
565
651
|
addresses: ["DtdSSG8ZJRZVv5Jx7K1MeWp7Zxcu19GD5wQRGRpQ9uMF"],
|
|
566
|
-
operator:
|
|
567
|
-
}
|
|
568
|
-
]
|
|
569
|
-
}
|
|
570
|
-
]
|
|
571
|
-
}
|
|
652
|
+
operator: "in",
|
|
653
|
+
},
|
|
654
|
+
],
|
|
655
|
+
},
|
|
656
|
+
],
|
|
657
|
+
},
|
|
572
658
|
});
|
|
573
659
|
```
|
|
574
660
|
|
|
@@ -578,7 +664,7 @@ You can filter by account:
|
|
|
578
664
|
|
|
579
665
|
```typescript
|
|
580
666
|
const policy = await cdp.policies.listPolicies({
|
|
581
|
-
scope:
|
|
667
|
+
scope: "account",
|
|
582
668
|
});
|
|
583
669
|
```
|
|
584
670
|
|
|
@@ -586,7 +672,7 @@ You can also filter by project:
|
|
|
586
672
|
|
|
587
673
|
```typescript
|
|
588
674
|
const policy = await cdp.policies.listPolicies({
|
|
589
|
-
scope:
|
|
675
|
+
scope: "project",
|
|
590
676
|
});
|
|
591
677
|
```
|
|
592
678
|
|
|
@@ -594,7 +680,7 @@ const policy = await cdp.policies.listPolicies({
|
|
|
594
680
|
|
|
595
681
|
```typescript
|
|
596
682
|
const policy = await cdp.policies.getPolicyById({
|
|
597
|
-
id:
|
|
683
|
+
id: "__POLICY_ID__",
|
|
598
684
|
});
|
|
599
685
|
```
|
|
600
686
|
|
|
@@ -604,34 +690,33 @@ This policy will update an existing policy to accept transactions to any address
|
|
|
604
690
|
|
|
605
691
|
```typescript
|
|
606
692
|
const policy = await cdp.policies.updatePolicy({
|
|
607
|
-
id:
|
|
693
|
+
id: "__POLICY_ID__",
|
|
608
694
|
policy: {
|
|
609
|
-
description:
|
|
695
|
+
description: "Updated Account Denylist Policy",
|
|
610
696
|
rules: [
|
|
611
697
|
{
|
|
612
|
-
action:
|
|
613
|
-
operation:
|
|
698
|
+
action: "accept",
|
|
699
|
+
operation: "signEvmTransaction",
|
|
614
700
|
criteria: [
|
|
615
701
|
{
|
|
616
|
-
type:
|
|
702
|
+
type: "evmAddress",
|
|
617
703
|
addresses: ["0x000000000000000000000000000000000000dEaD"],
|
|
618
|
-
operator:
|
|
619
|
-
}
|
|
620
|
-
]
|
|
621
|
-
}
|
|
622
|
-
]
|
|
623
|
-
}
|
|
704
|
+
operator: "not in",
|
|
705
|
+
},
|
|
706
|
+
],
|
|
707
|
+
},
|
|
708
|
+
],
|
|
709
|
+
},
|
|
624
710
|
});
|
|
625
711
|
```
|
|
626
712
|
|
|
627
713
|
### Delete a Policy
|
|
628
714
|
|
|
629
|
-
> [!WARNING]
|
|
630
|
-
> Attempting to delete an account-level policy in-use by at least one account will fail.
|
|
715
|
+
> [!WARNING] Attempting to delete an account-level policy in-use by at least one account will fail.
|
|
631
716
|
|
|
632
717
|
```typescript
|
|
633
718
|
const policy = await cdp.policies.deletePolicy({
|
|
634
|
-
id:
|
|
719
|
+
id: "__POLICY_ID__",
|
|
635
720
|
});
|
|
636
721
|
```
|
|
637
722
|
|
|
@@ -645,35 +730,35 @@ import { CreatePolicyBodySchema, UpdatePolicyBodySchema } from "@coinbase/cdp-sd
|
|
|
645
730
|
// Validate a new Policy with many issues, will throw a ZodError with actionable validation errors
|
|
646
731
|
try {
|
|
647
732
|
CreatePolicyBodySchema.parse({
|
|
648
|
-
description:
|
|
733
|
+
description: "Bad description with !#@ characters, also is wayyyyy toooooo long!!",
|
|
649
734
|
rules: [
|
|
650
735
|
{
|
|
651
|
-
action:
|
|
652
|
-
operation:
|
|
736
|
+
action: "acept",
|
|
737
|
+
operation: "unknownOperation",
|
|
653
738
|
criteria: [
|
|
654
739
|
{
|
|
655
|
-
type:
|
|
656
|
-
ethValue:
|
|
657
|
-
operator:
|
|
740
|
+
type: "ethValue",
|
|
741
|
+
ethValue: "not a number",
|
|
742
|
+
operator: "<=",
|
|
658
743
|
},
|
|
659
744
|
{
|
|
660
|
-
type:
|
|
745
|
+
type: "evmAddress",
|
|
661
746
|
addresses: ["not an address"],
|
|
662
|
-
operator:
|
|
747
|
+
operator: "in",
|
|
663
748
|
},
|
|
664
749
|
{
|
|
665
|
-
type:
|
|
750
|
+
type: "evmAddress",
|
|
666
751
|
addresses: ["not an address"],
|
|
667
|
-
operator:
|
|
668
|
-
}
|
|
669
|
-
]
|
|
752
|
+
operator: "invalid operator",
|
|
753
|
+
},
|
|
754
|
+
],
|
|
670
755
|
},
|
|
671
|
-
]
|
|
672
|
-
})
|
|
673
|
-
} catch(e) {
|
|
674
|
-
console.error(e)
|
|
756
|
+
],
|
|
757
|
+
});
|
|
758
|
+
} catch (e) {
|
|
759
|
+
console.error(e);
|
|
675
760
|
}
|
|
676
|
-
|
|
761
|
+
```
|
|
677
762
|
|
|
678
763
|
## Authentication tools
|
|
679
764
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toEvmServerAccount.js","sourceRoot":"","sources":["../../../accounts/evm/toEvmServerAccount.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"toEvmServerAccount.js","sourceRoot":"","sources":["../../../accounts/evm/toEvmServerAccount.ts"],"names":[],"mappings":";;AAyCA,gDA8DC;AAvGD,+BAA0E;AAE1E,iFAIgD;AAChD,yEAI4C;AAC5C,6EAAuE;AACvE,sGAAgG;AAChG,wEAAkE;AAkBlE;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAChC,SAA+B,EAC/B,OAAkC;IAElC,MAAM,OAAO,GAAqB;QAChC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAkB;QAC3C,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE;YAC3B,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE;gBACrE,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE;aAC5B,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,SAAgB,CAAC;QACjC,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,UAA0B;YACnC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE;gBAClE,IAAI,EAAE,UAAU,CAAC,IAAI;aACtB,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,SAAgB,CAAC;QACjC,CAAC;QAED,KAAK,CAAC,eAAe,CAAC,WAAoC;YACxD,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE;gBACzE,WAAW,EAAE,IAAA,2BAAoB,EAAC,WAAW,CAAC;aAC/C,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,iBAAwB,CAAC;QACzC,CAAC;QAED,KAAK,CAAC,aAAa,CAAC,OAAsB;YACxC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAClF,OAAO,MAAM,CAAC,SAAgB,CAAC;QACjC,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,YAAY;YACzB,OAAO,IAAA,sBAAQ,EAAC,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,oDAAuB,CAAC,CAAC;QAC7E,CAAC;QACD,KAAK,CAAC,iBAAiB,CACrB,OAAkD;YAElD,OAAO,IAAA,wCAAiB,EAAC,SAAS,EAAE;gBAClC,GAAG,OAAO;gBACV,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,aAAa,CACjB,OAA8C;YAE9C,OAAO,IAAA,gCAAa,EAAC,SAAS,EAAE;gBAC9B,GAAG,OAAO;gBACV,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,eAAe,CAAC,OAAgD;YACpE,OAAO,IAAA,oCAAe,EAAC,SAAS,EAAE;gBAChC,GAAG,OAAO;gBACV,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB,CAAC,CAAC;QACL,CAAC;QACD,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;QAC1B,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ;KACnC,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toEvmSmartAccount.js","sourceRoot":"","sources":["../../../accounts/evm/toEvmSmartAccount.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"toEvmSmartAccount.js","sourceRoot":"","sources":["../../../accounts/evm/toEvmSmartAccount.ts"],"names":[],"mappings":";;AAsDA,8CAuDC;AA7GD,+EAAyE;AACzE,iFAIgD;AAChD,yEAI4C;AAC5C,iFAIgD;AAChD,gHAA0G;AAC1G,wEAAkE;AAClE,uFAImD;AAoBnD;;;;;;;;;;;GAWG;AACH,SAAgB,iBAAiB,CAC/B,SAA+B,EAC/B,OAAiC;IAEjC,MAAM,OAAO,GAAoB;QAC/B,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,OAAkB;QAChD,MAAM,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;QACvB,KAAK,CAAC,QAAQ,CAAC,YAAY;YACzB,OAAO,IAAA,sBAAQ,EAAC,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,8DAA4B,CAAC,CAAC;QAClF,CAAC;QACD,KAAK,CAAC,iBAAiB,CACrB,OAAkD;YAElD,OAAO,IAAA,wCAAiB,EAAC,SAAS,EAAE;gBAClC,GAAG,OAAO;gBACV,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,iBAAiB,CACrB,OAAkE;YAElE,OAAO,IAAA,wCAAiB,EAAC,SAAS,EAAE;gBAClC,GAAG,OAAO;gBACV,YAAY,EAAE,OAAO;aACtB,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,oBAAoB,CACxB,OAAiE;YAEjE,OAAO,IAAA,8CAAoB,EAAC,SAAS,EAAE;gBACrC,GAAG,OAAO;gBACV,mBAAmB,EAAE,OAAO,CAAC,OAAO;aACrC,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,gBAAgB,CACpB,OAAsD;YAEtD,OAAO,IAAA,sCAAgB,EAAC,SAAS,EAAE;gBACjC,GAAG,OAAO;gBACV,YAAY,EAAE,OAAO;aACtB,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,aAAa,CACjB,OAA8C;YAE9C,OAAO,IAAA,gCAAa,EAAC,SAAS,EAAE;gBAC9B,GAAG,OAAO;gBACV,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAC;QACL,CAAC;QACD,IAAI,EAAE,OAAO,CAAC,YAAY,CAAC,IAAI;QAC/B,IAAI,EAAE,WAAW;KAClB,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -4,6 +4,7 @@ exports.toSolanaAccount = toSolanaAccount;
|
|
|
4
4
|
const requestFaucet_js_1 = require("../../actions/solana/requestFaucet.js");
|
|
5
5
|
const signMessage_js_1 = require("../../actions/solana/signMessage.js");
|
|
6
6
|
const signTransaction_js_1 = require("../../actions/solana/signTransaction.js");
|
|
7
|
+
const transfer_js_1 = require("../../actions/solana/transfer.js");
|
|
7
8
|
/**
|
|
8
9
|
* Creates a Solana account instance with actions from an existing Solana account.
|
|
9
10
|
* Use this to interact with previously deployed Solana accounts, rather than creating new ones.
|
|
@@ -36,6 +37,12 @@ function toSolanaAccount(apiClient, options) {
|
|
|
36
37
|
});
|
|
37
38
|
},
|
|
38
39
|
policies: options.account.policies,
|
|
40
|
+
async transfer(options) {
|
|
41
|
+
return (0, transfer_js_1.transfer)(apiClient, {
|
|
42
|
+
...options,
|
|
43
|
+
from: account.address,
|
|
44
|
+
});
|
|
45
|
+
},
|
|
39
46
|
};
|
|
40
47
|
return account;
|
|
41
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toSolanaAccount.js","sourceRoot":"","sources":["../../../accounts/solana/toSolanaAccount.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"toSolanaAccount.js","sourceRoot":"","sources":["../../../accounts/solana/toSolanaAccount.ts"],"names":[],"mappings":";;AA6BA,0CAqCC;AAjED,4EAAsE;AACtE,wEAAkE;AAClE,gFAA0E;AAC1E,kEAAkF;AAgBlF;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAC7B,SAA+B,EAC/B,OAA+B;IAE/B,MAAM,OAAO,GAAkB;QAC7B,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO;QAChC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;QAC1B,KAAK,CAAC,aAAa,CAAC,OAA8C;YAChE,OAAO,IAAA,gCAAa,EAAC,SAAS,EAAE;gBAC9B,GAAG,OAAO;gBACV,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,OAA4C;YAC5D,OAAO,IAAA,4BAAW,EAAC,SAAS,EAAE;gBAC5B,GAAG,OAAO;gBACV,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,eAAe,CACnB,OAAgD;YAEhD,OAAO,IAAA,oCAAe,EAAC,SAAS,EAAE;gBAChC,GAAG,OAAO;gBACV,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAC;QACL,CAAC;QACD,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ;QAClC,KAAK,CAAC,QAAQ,CAAC,OAAsC;YACnD,OAAO,IAAA,sBAAQ,EAAC,SAAS,EAAE;gBACzB,GAAG,OAAO;gBACV,IAAI,EAAE,OAAO,CAAC,OAAO;aACtB,CAAC,CAAC;QACL,CAAC;KACF,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -6,71 +6,38 @@ const utils_js_1 = require("./utils.js");
|
|
|
6
6
|
const serializeTransaction_js_1 = require("../../../utils/serializeTransaction.js");
|
|
7
7
|
exports.accountTransferStrategy = {
|
|
8
8
|
executeTransfer: async ({ apiClient, from, to, value, token, network }) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
network,
|
|
17
|
-
});
|
|
18
|
-
return result.transactionHash;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
const erc20Address = (0, utils_js_1.getErc20Address)(token, network);
|
|
22
|
-
await apiClient.sendEvmTransaction(from.address, {
|
|
23
|
-
transaction: (0, serializeTransaction_js_1.serializeEIP1559Transaction)({
|
|
24
|
-
to: erc20Address,
|
|
25
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
26
|
-
abi: viem_1.erc20Abi,
|
|
27
|
-
functionName: "approve",
|
|
28
|
-
args: [to, value],
|
|
29
|
-
}),
|
|
30
|
-
}),
|
|
31
|
-
network,
|
|
32
|
-
});
|
|
33
|
-
const result = await apiClient.sendEvmTransaction(from.address, {
|
|
34
|
-
transaction: (0, serializeTransaction_js_1.serializeEIP1559Transaction)({
|
|
35
|
-
to: erc20Address,
|
|
36
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
37
|
-
abi: viem_1.erc20Abi,
|
|
38
|
-
functionName: "transfer",
|
|
39
|
-
args: [to, value],
|
|
40
|
-
}),
|
|
41
|
-
}),
|
|
42
|
-
network,
|
|
43
|
-
});
|
|
44
|
-
return result.transactionHash;
|
|
45
|
-
}
|
|
46
|
-
})();
|
|
47
|
-
return transactionHash;
|
|
48
|
-
},
|
|
49
|
-
waitForResult: async ({ publicClient, hash, waitOptions }) => {
|
|
50
|
-
let receipt;
|
|
51
|
-
try {
|
|
52
|
-
receipt = await publicClient.waitForTransactionReceipt({
|
|
53
|
-
hash,
|
|
54
|
-
pollingInterval: waitOptions?.intervalSeconds
|
|
55
|
-
? waitOptions.intervalSeconds * 1000
|
|
56
|
-
: undefined,
|
|
57
|
-
timeout: waitOptions?.timeoutSeconds ? waitOptions.timeoutSeconds * 1000 : undefined,
|
|
9
|
+
if (token === "eth") {
|
|
10
|
+
return apiClient.sendEvmTransaction(from.address, {
|
|
11
|
+
transaction: (0, serializeTransaction_js_1.serializeEIP1559Transaction)({
|
|
12
|
+
value,
|
|
13
|
+
to,
|
|
14
|
+
}),
|
|
15
|
+
network,
|
|
58
16
|
});
|
|
59
17
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
18
|
+
const erc20Address = (0, utils_js_1.getErc20Address)(token, network);
|
|
19
|
+
await apiClient.sendEvmTransaction(from.address, {
|
|
20
|
+
transaction: (0, serializeTransaction_js_1.serializeEIP1559Transaction)({
|
|
21
|
+
to: erc20Address,
|
|
22
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
23
|
+
abi: viem_1.erc20Abi,
|
|
24
|
+
functionName: "approve",
|
|
25
|
+
args: [to, value],
|
|
26
|
+
}),
|
|
27
|
+
}),
|
|
28
|
+
network,
|
|
29
|
+
});
|
|
30
|
+
return apiClient.sendEvmTransaction(from.address, {
|
|
31
|
+
transaction: (0, serializeTransaction_js_1.serializeEIP1559Transaction)({
|
|
32
|
+
to: erc20Address,
|
|
33
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
34
|
+
abi: viem_1.erc20Abi,
|
|
35
|
+
functionName: "transfer",
|
|
36
|
+
args: [to, value],
|
|
37
|
+
}),
|
|
38
|
+
}),
|
|
39
|
+
network,
|
|
40
|
+
});
|
|
74
41
|
},
|
|
75
42
|
};
|
|
76
43
|
//# sourceMappingURL=accountTransferStrategy.js.map
|