@coinbase/cdp-sdk 1.5.0 → 1.7.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 +25 -0
- package/README.md +101 -3
- package/_cjs/accounts/evm/toEvmServerAccount.js +21 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +35 -0
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/{types.js.map → evm/types.js.map} +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +41 -0
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -0
- package/_cjs/accounts/solana/types.js +3 -0
- package/_cjs/accounts/solana/types.js.map +1 -0
- package/_cjs/actions/evm/getUserOperation.js +36 -0
- package/_cjs/actions/evm/getUserOperation.js.map +1 -0
- package/_cjs/actions/evm/listTokenBalances.js +33 -0
- package/_cjs/actions/evm/listTokenBalances.js.map +1 -0
- package/_cjs/actions/evm/requestFaucet.js +18 -0
- package/_cjs/actions/evm/requestFaucet.js.map +1 -0
- package/_cjs/actions/evm/sendTransaction.js +29 -0
- package/_cjs/actions/evm/sendTransaction.js.map +1 -0
- package/_cjs/actions/evm/sendUserOperation.js +5 -6
- package/_cjs/actions/evm/sendUserOperation.js.map +1 -1
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js +11 -7
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +13 -8
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_cjs/actions/evm/transfer/transfer.js +7 -3
- package/_cjs/actions/evm/transfer/transfer.js.map +1 -1
- package/_cjs/actions/solana/requestFaucet.js +29 -0
- package/_cjs/actions/solana/requestFaucet.js.map +1 -0
- package/_cjs/actions/solana/signMessage.js +29 -0
- package/_cjs/actions/solana/signMessage.js.map +1 -0
- package/_cjs/actions/solana/signTransaction.js +46 -0
- package/_cjs/actions/solana/signTransaction.js.map +1 -0
- package/_cjs/actions/solana/types.js +3 -0
- package/_cjs/actions/solana/types.js.map +1 -0
- package/_cjs/client/evm/evm.js +10 -52
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/client/solana/solana.js +22 -17
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +59 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +3 -2
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.js +56 -0
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.js.map +1 -0
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +284 -0
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -0
- package/_cjs/openapi-client/index.js +1 -0
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +21 -0
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +35 -0
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/{types.js.map → evm/types.js.map} +1 -1
- package/_esm/accounts/solana/toSolanaAccount.js +38 -0
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -0
- package/_esm/accounts/solana/types.js +2 -0
- package/_esm/accounts/solana/types.js.map +1 -0
- package/_esm/actions/evm/getUserOperation.js +33 -0
- package/_esm/actions/evm/getUserOperation.js.map +1 -0
- package/_esm/actions/evm/listTokenBalances.js +30 -0
- package/_esm/actions/evm/listTokenBalances.js.map +1 -0
- package/_esm/actions/evm/requestFaucet.js +15 -0
- package/_esm/actions/evm/requestFaucet.js.map +1 -0
- package/_esm/actions/evm/sendTransaction.js +26 -0
- package/_esm/actions/evm/sendTransaction.js.map +1 -0
- package/_esm/actions/evm/sendUserOperation.js +5 -6
- package/_esm/actions/evm/sendUserOperation.js.map +1 -1
- package/_esm/actions/evm/transfer/accountTransferStrategy.js +11 -7
- package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +13 -8
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
- package/_esm/actions/evm/transfer/transfer.js +7 -3
- package/_esm/actions/evm/transfer/transfer.js.map +1 -1
- package/_esm/actions/solana/requestFaucet.js +26 -0
- package/_esm/actions/solana/requestFaucet.js.map +1 -0
- package/_esm/actions/solana/signMessage.js +26 -0
- package/_esm/actions/solana/signMessage.js.map +1 -0
- package/_esm/actions/solana/signTransaction.js +43 -0
- package/_esm/actions/solana/signTransaction.js.map +1 -0
- package/_esm/actions/solana/types.js +2 -0
- package/_esm/actions/solana/types.js.map +1 -0
- package/_esm/client/evm/evm.js +10 -52
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/client/solana/solana.js +22 -17
- package/_esm/client/solana/solana.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +58 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/index.msw.js +3 -2
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/generated/policy-engine/policy-engine.js +48 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.js.map +1 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +259 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -0
- package/_esm/openapi-client/index.js +1 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/{types.d.ts → evm/types.d.ts} +5 -5
- package/_types/accounts/evm/types.d.ts.map +1 -0
- package/_types/accounts/solana/toSolanaAccount.d.ts +20 -0
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -0
- package/_types/accounts/solana/types.d.ts +12 -0
- package/_types/accounts/solana/types.d.ts.map +1 -0
- package/_types/actions/evm/getUserOperation.d.ts +22 -0
- package/_types/actions/evm/getUserOperation.d.ts.map +1 -0
- package/_types/actions/evm/listTokenBalances.d.ts +76 -0
- package/_types/actions/evm/listTokenBalances.d.ts.map +1 -0
- package/_types/actions/evm/requestFaucet.d.ts +34 -0
- package/_types/actions/evm/requestFaucet.d.ts.map +1 -0
- package/_types/actions/evm/sendTransaction.d.ts +42 -0
- package/_types/actions/evm/sendTransaction.d.ts.map +1 -0
- package/_types/actions/evm/sendUserOperation.d.ts +4 -3
- package/_types/actions/evm/sendUserOperation.d.ts.map +1 -1
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +1 -1
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +1 -1
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -1
- package/_types/actions/evm/transfer/transfer.d.ts +3 -3
- package/_types/actions/evm/transfer/transfer.d.ts.map +1 -1
- package/_types/actions/evm/transfer/types.d.ts +41 -7
- package/_types/actions/evm/transfer/types.d.ts.map +1 -1
- package/_types/actions/evm/types.d.ts +168 -3
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/actions/solana/requestFaucet.d.ts +23 -0
- package/_types/actions/solana/requestFaucet.d.ts.map +1 -0
- package/_types/actions/solana/signMessage.d.ts +23 -0
- package/_types/actions/solana/signMessage.d.ts.map +1 -0
- package/_types/actions/solana/signTransaction.d.ts +38 -0
- package/_types/actions/solana/signTransaction.d.ts.map +1 -0
- package/_types/actions/solana/types.d.ts +80 -0
- package/_types/actions/solana/types.d.ts.map +1 -0
- package/_types/client/evm/evm.d.ts +6 -3
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +12 -138
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/solana/solana.d.ts +5 -4
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/client/solana/solana.types.d.ts +8 -11
- package/_types/client/solana/solana.types.d.ts.map +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +218 -0
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts +3 -2
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts +43 -0
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts.map +1 -0
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +25 -0
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -0
- package/_types/openapi-client/index.d.ts +1 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmServerAccount.ts +35 -1
- package/accounts/evm/toEvmSmartAccount.ts +63 -1
- package/accounts/{types.ts → evm/types.ts} +5 -5
- package/accounts/solana/toSolanaAccount.ts +59 -0
- package/accounts/solana/types.ts +13 -0
- package/actions/evm/getUserOperation.ts +40 -0
- package/actions/evm/listTokenBalances.ts +107 -0
- package/actions/evm/requestFaucet.ts +46 -0
- package/actions/evm/sendTransaction.ts +73 -0
- package/actions/evm/sendUserOperation.ts +7 -7
- package/actions/evm/transfer/accountTransferStrategy.ts +12 -8
- package/actions/evm/transfer/smartAccountTransferStrategy.ts +14 -9
- package/actions/evm/transfer/transfer.ts +17 -6
- package/actions/evm/transfer/types.ts +55 -12
- package/actions/evm/types.ts +191 -3
- package/actions/solana/requestFaucet.ts +35 -0
- package/actions/solana/signMessage.ts +36 -0
- package/actions/solana/signTransaction.ts +53 -0
- package/actions/solana/types.ts +87 -0
- package/client/evm/evm.ts +28 -77
- package/client/evm/evm.types.ts +25 -151
- package/client/solana/solana.ts +32 -37
- package/client/solana/solana.types.ts +10 -15
- package/index.ts +1 -1
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +274 -0
- package/openapi-client/generated/index.msw.ts +3 -2
- package/openapi-client/generated/policy-engine/policy-engine.msw.ts +404 -0
- package/openapi-client/generated/policy-engine/policy-engine.ts +95 -0
- package/openapi-client/index.ts +1 -0
- package/package.json +1 -1
- package/version.ts +1 -1
- package/_types/accounts/types.d.ts.map +0 -1
- /package/_cjs/accounts/{types.js → evm/types.js} +0 -0
- /package/_esm/accounts/{types.js → evm/types.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# CDP SDK Changelog
|
|
2
2
|
|
|
3
|
+
## 1.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#116](https://github.com/coinbase/cdp-sdk/pull/116) [`97678d6`](https://github.com/coinbase/cdp-sdk/commit/97678d675358bb8d0b6195fd31933a32926cdd44) Thanks [@sddioulde](https://github.com/sddioulde)! - Added getUserOperation smart account action
|
|
8
|
+
|
|
9
|
+
- [#122](https://github.com/coinbase/cdp-sdk/pull/122) [`ee41d98`](https://github.com/coinbase/cdp-sdk/commit/ee41d986406e3e8666d1d1a1b1525e7ff7435a2b) Thanks [@sddioulde](https://github.com/sddioulde)! - Added account actions to Solana
|
|
10
|
+
|
|
11
|
+
- [#103](https://github.com/coinbase/cdp-sdk/pull/103) [`2777cde`](https://github.com/coinbase/cdp-sdk/commit/2777cde93e4f10579a4ca31e140720067799cf66) Thanks [@0xRAG](https://github.com/0xRAG)! - Added additional options to transfer methods:
|
|
12
|
+
|
|
13
|
+
- Added `paymasterUrl` and `waitOptions` to EvmSmartAccount.transfer
|
|
14
|
+
- Added `waitOptions` to EvmAccount.transfer
|
|
15
|
+
|
|
16
|
+
## 1.6.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- [#99](https://github.com/coinbase/cdp-sdk/pull/99) [`0fd6d2b`](https://github.com/coinbase/cdp-sdk/commit/0fd6d2ba56b2da52c96eb19278dc782560b7680b) Thanks [@0xRAG](https://github.com/0xRAG)! - Added actions to EvmAccount and EvmSmartAccount:
|
|
21
|
+
|
|
22
|
+
- listTokenBalances
|
|
23
|
+
- requestFaucet
|
|
24
|
+
- sendTransaction (EvmAccount only)
|
|
25
|
+
- sendUserOperation (EvmSmartAccount only)
|
|
26
|
+
- waitForUserOperation (EvmSmartAccount only)
|
|
27
|
+
|
|
3
28
|
## 1.5.0
|
|
4
29
|
|
|
5
30
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -115,7 +115,7 @@ const account = await cdp.solana.createAccount();
|
|
|
115
115
|
|
|
116
116
|
```typescript
|
|
117
117
|
const account = await cdp.evm.getOrCreateAccount({
|
|
118
|
-
name:
|
|
118
|
+
name: "Account1",
|
|
119
119
|
});
|
|
120
120
|
```
|
|
121
121
|
|
|
@@ -123,7 +123,7 @@ const account = await cdp.evm.getOrCreateAccount({
|
|
|
123
123
|
|
|
124
124
|
```typescript
|
|
125
125
|
const account = await cdp.solana.getOrCreateAccount({
|
|
126
|
-
name:
|
|
126
|
+
name: "Account1",
|
|
127
127
|
});
|
|
128
128
|
```
|
|
129
129
|
|
|
@@ -287,7 +287,7 @@ const userOperation = await cdp.sendUserOperation({
|
|
|
287
287
|
});
|
|
288
288
|
```
|
|
289
289
|
|
|
290
|
-
###
|
|
290
|
+
### Transferring tokens
|
|
291
291
|
|
|
292
292
|
For complete examples, check out [transfer.ts](https://github.com/coinbase/cdp-sdk/blob/main/examples/typescript/evm/transfer.ts) and [transferWithSmartWallet.ts](https://github.com/coinbase/cdp-sdk/blob/main/examples/typescript/evm/transferWithSmartWallet.ts).
|
|
293
293
|
|
|
@@ -320,6 +320,22 @@ const { status } = await sender.transfer({
|
|
|
320
320
|
});
|
|
321
321
|
```
|
|
322
322
|
|
|
323
|
+
Using Smart Accounts, you can also specify a paymaster URL and wait options:
|
|
324
|
+
|
|
325
|
+
```typescript
|
|
326
|
+
const { status } = await sender.transfer({
|
|
327
|
+
to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
|
|
328
|
+
amount: "0.01",
|
|
329
|
+
token: "usdc",
|
|
330
|
+
network: "base-sepolia",
|
|
331
|
+
paymasterUrl: "https://some-paymaster-url.com",
|
|
332
|
+
waitOptions: {
|
|
333
|
+
timeout: 30,
|
|
334
|
+
interval: 2,
|
|
335
|
+
},
|
|
336
|
+
});
|
|
337
|
+
```
|
|
338
|
+
|
|
323
339
|
If you pass a decimal amount in a string, the SDK will parse it into a bigint based on the token's decimals. You can also pass a bigint directly:
|
|
324
340
|
|
|
325
341
|
```typescript
|
|
@@ -356,6 +372,88 @@ const { status } = await sender.transfer({
|
|
|
356
372
|
});
|
|
357
373
|
```
|
|
358
374
|
|
|
375
|
+
You can also pass wait options to the `transfer` function:
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
const { status } = await sender.transfer({
|
|
379
|
+
to: receiver,
|
|
380
|
+
amount: "0.01",
|
|
381
|
+
token: "usdc",
|
|
382
|
+
network: "base-sepolia",
|
|
383
|
+
waitOptions: {
|
|
384
|
+
timeout: 30,
|
|
385
|
+
interval: 2,
|
|
386
|
+
},
|
|
387
|
+
});
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## Account Actions
|
|
391
|
+
|
|
392
|
+
Account objects have actions that can be used to interact with the account. These can be used in place of the `cdp` client.
|
|
393
|
+
|
|
394
|
+
### EVM account actions
|
|
395
|
+
|
|
396
|
+
Here are some examples for actions on EVM accounts.
|
|
397
|
+
|
|
398
|
+
For example, instead of:
|
|
399
|
+
|
|
400
|
+
```typescript
|
|
401
|
+
const balances = await cdp.evm.listTokenBalances({
|
|
402
|
+
address: account.address,
|
|
403
|
+
network: "base-sepolia",
|
|
404
|
+
});
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
You can use the `listTokenBalances` action:
|
|
408
|
+
|
|
409
|
+
```typescript
|
|
410
|
+
const account = await cdp.evm.createAccount();
|
|
411
|
+
const balances = await account.listTokenBalances({ network: "base-sepolia" });
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
EvmAccount supports the following actions:
|
|
415
|
+
|
|
416
|
+
- `listTokenBalances`
|
|
417
|
+
- `requestFaucet`
|
|
418
|
+
- `signTransaction`
|
|
419
|
+
- `sendTransaction`
|
|
420
|
+
- `transfer`
|
|
421
|
+
|
|
422
|
+
EvmSmartAccount supports the following actions:
|
|
423
|
+
|
|
424
|
+
- `listTokenBalances`
|
|
425
|
+
- `requestFaucet`
|
|
426
|
+
- `sendUserOperation`
|
|
427
|
+
- `waitForUserOperation`
|
|
428
|
+
- `getUserOperation`
|
|
429
|
+
- `transfer`
|
|
430
|
+
|
|
431
|
+
### Solana account actions
|
|
432
|
+
|
|
433
|
+
Here are some examples for actions on Solana accounts.
|
|
434
|
+
|
|
435
|
+
```typescript
|
|
436
|
+
const balances = await cdp.solana.signMessage({
|
|
437
|
+
address: account.address,
|
|
438
|
+
message: "Hello, world!",
|
|
439
|
+
});
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
You can use the `signMessage` action:
|
|
443
|
+
|
|
444
|
+
```typescript
|
|
445
|
+
const account = await cdp.solana.createAccount();
|
|
446
|
+
const { signature } = await account.signMessage({
|
|
447
|
+
message: "Hello, world!"
|
|
448
|
+
});
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
SolanaAccount supports the following actions:
|
|
452
|
+
|
|
453
|
+
- `requestFaucet`
|
|
454
|
+
- `signMessage`
|
|
455
|
+
- `signTransaction`
|
|
456
|
+
|
|
359
457
|
## Authentication tools
|
|
360
458
|
|
|
361
459
|
This SDK also contains simple tools for authenticating REST API requests to the [Coinbase Developer Platform (CDP)](https://docs.cdp.coinbase.com/). See the [Auth README](src/auth/README.md) for more details.
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toEvmServerAccount = toEvmServerAccount;
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
|
+
const listTokenBalances_js_1 = require("../../actions/evm/listTokenBalances.js");
|
|
6
|
+
const requestFaucet_js_1 = require("../../actions/evm/requestFaucet.js");
|
|
7
|
+
const sendTransaction_js_1 = require("../../actions/evm/sendTransaction.js");
|
|
5
8
|
const accountTransferStrategy_js_1 = require("../../actions/evm/transfer/accountTransferStrategy.js");
|
|
6
9
|
const transfer_js_1 = require("../../actions/evm/transfer/transfer.js");
|
|
7
10
|
/**
|
|
@@ -40,6 +43,24 @@ function toEvmServerAccount(apiClient, options) {
|
|
|
40
43
|
async transfer(transferArgs) {
|
|
41
44
|
return (0, transfer_js_1.transfer)(apiClient, account, transferArgs, accountTransferStrategy_js_1.accountTransferStrategy);
|
|
42
45
|
},
|
|
46
|
+
async listTokenBalances(options) {
|
|
47
|
+
return (0, listTokenBalances_js_1.listTokenBalances)(apiClient, {
|
|
48
|
+
...options,
|
|
49
|
+
address: this.address,
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
async requestFaucet(options) {
|
|
53
|
+
return (0, requestFaucet_js_1.requestFaucet)(apiClient, {
|
|
54
|
+
...options,
|
|
55
|
+
address: this.address,
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
async sendTransaction(options) {
|
|
59
|
+
return (0, sendTransaction_js_1.sendTransaction)(apiClient, {
|
|
60
|
+
...options,
|
|
61
|
+
address: this.address,
|
|
62
|
+
});
|
|
63
|
+
},
|
|
43
64
|
name: options.account.name,
|
|
44
65
|
type: "evm-server",
|
|
45
66
|
};
|
|
@@ -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":";;AAuCA,gDA4DC;AAnGD,+BAAoF;AAEpF,iFAIgD;AAChD,yEAI4C;AAC5C,6EAAuE;AACvE,sGAAgG;AAChG,wEAAkE;AAgBlE;;;;;;;;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;YACjB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACrC,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;KACnB,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toEvmSmartAccount = toEvmSmartAccount;
|
|
4
|
+
const getUserOperation_js_1 = require("../../actions/evm/getUserOperation.js");
|
|
5
|
+
const listTokenBalances_js_1 = require("../../actions/evm/listTokenBalances.js");
|
|
6
|
+
const requestFaucet_js_1 = require("../../actions/evm/requestFaucet.js");
|
|
7
|
+
const sendUserOperation_js_1 = require("../../actions/evm/sendUserOperation.js");
|
|
4
8
|
const smartAccountTransferStrategy_js_1 = require("../../actions/evm/transfer/smartAccountTransferStrategy.js");
|
|
5
9
|
const transfer_js_1 = require("../../actions/evm/transfer/transfer.js");
|
|
10
|
+
const waitForUserOperation_js_1 = require("../../actions/evm/waitForUserOperation.js");
|
|
6
11
|
/**
|
|
7
12
|
* Creates a EvmSmartAccount instance from an existing EvmSmartAccount and owner.
|
|
8
13
|
* Use this to interact with previously deployed EvmSmartAccounts, rather than creating new ones.
|
|
@@ -22,6 +27,36 @@ function toEvmSmartAccount(apiClient, options) {
|
|
|
22
27
|
async transfer(transferArgs) {
|
|
23
28
|
return (0, transfer_js_1.transfer)(apiClient, account, transferArgs, smartAccountTransferStrategy_js_1.smartAccountTransferStrategy);
|
|
24
29
|
},
|
|
30
|
+
async listTokenBalances(options) {
|
|
31
|
+
return (0, listTokenBalances_js_1.listTokenBalances)(apiClient, {
|
|
32
|
+
...options,
|
|
33
|
+
address: this.address,
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
async sendUserOperation(options) {
|
|
37
|
+
return (0, sendUserOperation_js_1.sendUserOperation)(apiClient, {
|
|
38
|
+
...options,
|
|
39
|
+
smartAccount: account,
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
async waitForUserOperation(options) {
|
|
43
|
+
return (0, waitForUserOperation_js_1.waitForUserOperation)(apiClient, {
|
|
44
|
+
...options,
|
|
45
|
+
smartAccountAddress: account.address,
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
async getUserOperation(options) {
|
|
49
|
+
return (0, getUserOperation_js_1.getUserOperation)(apiClient, {
|
|
50
|
+
...options,
|
|
51
|
+
smartAccount: account,
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
async requestFaucet(options) {
|
|
55
|
+
return (0, requestFaucet_js_1.requestFaucet)(apiClient, {
|
|
56
|
+
...options,
|
|
57
|
+
address: account.address,
|
|
58
|
+
});
|
|
59
|
+
},
|
|
25
60
|
name: options.smartAccount.name,
|
|
26
61
|
type: "evm-smart",
|
|
27
62
|
};
|
|
@@ -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":";;AAuDA,8CAuDC;AA9GD,+EAAyE;AACzE,iFAIgD;AAChD,yEAI4C;AAC5C,iFAIgD;AAChD,gHAA0G;AAC1G,wEAAkE;AAClE,uFAImD;AAqBnD;;;;;;;;;;;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../accounts/evm/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toSolanaAccount = toSolanaAccount;
|
|
4
|
+
const requestFaucet_js_1 = require("../../actions/solana/requestFaucet.js");
|
|
5
|
+
const signMessage_js_1 = require("../../actions/solana/signMessage.js");
|
|
6
|
+
const signTransaction_js_1 = require("../../actions/solana/signTransaction.js");
|
|
7
|
+
/**
|
|
8
|
+
* Creates a Solana account instance with actions from an existing Solana account.
|
|
9
|
+
* Use this to interact with previously deployed Solana accounts, rather than creating new ones.
|
|
10
|
+
*
|
|
11
|
+
* @param {CdpOpenApiClientType} apiClient - The API client.
|
|
12
|
+
* @param {ToSolanaAccountOptions} options - Configuration options.
|
|
13
|
+
* @param {Account} options.account - The Solana account that was previously created.
|
|
14
|
+
* @returns {SolanaAccount} A configured SolanaAccount instance ready for signing.
|
|
15
|
+
*/
|
|
16
|
+
function toSolanaAccount(apiClient, options) {
|
|
17
|
+
const account = {
|
|
18
|
+
address: options.account.address,
|
|
19
|
+
name: options.account.name,
|
|
20
|
+
async requestFaucet(options) {
|
|
21
|
+
return (0, requestFaucet_js_1.requestFaucet)(apiClient, {
|
|
22
|
+
...options,
|
|
23
|
+
address: account.address,
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
async signMessage(options) {
|
|
27
|
+
return (0, signMessage_js_1.signMessage)(apiClient, {
|
|
28
|
+
...options,
|
|
29
|
+
address: account.address,
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
async signTransaction(options) {
|
|
33
|
+
return (0, signTransaction_js_1.signTransaction)(apiClient, {
|
|
34
|
+
...options,
|
|
35
|
+
address: account.address,
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
return account;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=toSolanaAccount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toSolanaAccount.js","sourceRoot":"","sources":["../../../accounts/solana/toSolanaAccount.ts"],"names":[],"mappings":";;AA4BA,0CA8BC;AAzDD,4EAAsE;AACtE,wEAAkE;AAClE,gFAA0E;AAgB1E;;;;;;;;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;KACF,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../accounts/solana/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserOperation = getUserOperation;
|
|
4
|
+
/**
|
|
5
|
+
* Gets a user operation for a smart account by user operation hash.
|
|
6
|
+
*
|
|
7
|
+
* @param {CdpOpenApiClientType} client - The client to use to get the user operation.
|
|
8
|
+
* @param {GetUserOperationOptions} options - Parameters for getting the user operation.
|
|
9
|
+
* @param {SmartAccount} options.smartAccount - The smart account signing the user operation.
|
|
10
|
+
* @param {string} options.userOpHash - The user operation hash.
|
|
11
|
+
*
|
|
12
|
+
* @returns A promise that resolves to the user operation.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const userOp = await getUserOperation(client, {
|
|
17
|
+
* smartAccount,
|
|
18
|
+
* userOpHash: "0x1234567890123456789012345678901234567890123456789012345678901234",
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
async function getUserOperation(client, options) {
|
|
23
|
+
const userOp = await client.getUserOperation(options.smartAccount.address, options.userOpHash);
|
|
24
|
+
return {
|
|
25
|
+
calls: userOp.calls.map(call => ({
|
|
26
|
+
to: call.to,
|
|
27
|
+
value: BigInt(call.value),
|
|
28
|
+
data: call.data,
|
|
29
|
+
})),
|
|
30
|
+
network: userOp.network,
|
|
31
|
+
status: userOp.status,
|
|
32
|
+
transactionHash: userOp.transactionHash,
|
|
33
|
+
userOpHash: userOp.userOpHash,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=getUserOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserOperation.js","sourceRoot":"","sources":["../../../actions/evm/getUserOperation.ts"],"names":[],"mappings":";;AAsBA,4CAiBC;AAnCD;;;;;;;;;;;;;;;;;GAiBG;AACI,KAAK,UAAU,gBAAgB,CACpC,MAA4B,EAC5B,OAAgC;IAEhC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAE/F,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC/B,EAAE,EAAE,IAAI,CAAC,EAAa;YACtB,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;YACzB,IAAI,EAAE,IAAI,CAAC,IAAW;SACvB,CAAC,CAAC;QACH,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,eAAe,EAAE,MAAM,CAAC,eAAkC;QAC1D,UAAU,EAAE,MAAM,CAAC,UAAiB;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listTokenBalances = listTokenBalances;
|
|
4
|
+
/**
|
|
5
|
+
* List the token balances for an EVM account.
|
|
6
|
+
*
|
|
7
|
+
* @param client - The client to use to list the token balances.
|
|
8
|
+
* @param options - The options for listing the token balances.
|
|
9
|
+
* @returns The result of listing the token balances.
|
|
10
|
+
*/
|
|
11
|
+
async function listTokenBalances(client, options) {
|
|
12
|
+
const response = await client.listEvmTokenBalances(options.network, options.address, {
|
|
13
|
+
pageSize: options.pageSize,
|
|
14
|
+
pageToken: options.pageToken,
|
|
15
|
+
});
|
|
16
|
+
const balances = response.balances.map(balance => {
|
|
17
|
+
return {
|
|
18
|
+
token: {
|
|
19
|
+
network: balance.token.network,
|
|
20
|
+
contractAddress: balance.token.contractAddress,
|
|
21
|
+
},
|
|
22
|
+
amount: {
|
|
23
|
+
amount: BigInt(balance.amount.amount),
|
|
24
|
+
decimals: BigInt(balance.amount.decimals),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
balances,
|
|
30
|
+
nextPageToken: response.nextPageToken,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=listTokenBalances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listTokenBalances.js","sourceRoot":"","sources":["../../../actions/evm/listTokenBalances.ts"],"names":[],"mappings":";;AAgFA,8CA0BC;AAjCD;;;;;;GAMG;AACI,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,OAAiC;IAEjC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;QACnF,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QAC/C,OAAO;YACL,KAAK,EAAE;gBACL,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO;gBAC9B,eAAe,EAAE,OAAO,CAAC,KAAK,CAAC,eAA0B;aAC1D;YACD,MAAM,EAAE;gBACN,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;gBACrC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;aAC1C;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ;QACR,aAAa,EAAE,QAAQ,CAAC,aAAa;KACtC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestFaucet = requestFaucet;
|
|
4
|
+
/**
|
|
5
|
+
* Requests funds from an EVM faucet.
|
|
6
|
+
*
|
|
7
|
+
* @param apiClient - The API client.
|
|
8
|
+
* @param options - The options for requesting funds from the EVM faucet.
|
|
9
|
+
*
|
|
10
|
+
* @returns A promise that resolves to the transaction hash.
|
|
11
|
+
*/
|
|
12
|
+
async function requestFaucet(apiClient, options) {
|
|
13
|
+
const { transactionHash } = await apiClient.requestEvmFaucet({ address: options.address, network: options.network, token: options.token }, options.idempotencyKey);
|
|
14
|
+
return {
|
|
15
|
+
transactionHash: transactionHash,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=requestFaucet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestFaucet.js","sourceRoot":"","sources":["../../../actions/evm/requestFaucet.ts"],"names":[],"mappings":";;AAiCA,sCAYC;AApBD;;;;;;;GAOG;AACI,KAAK,UAAU,aAAa,CACjC,SAA+B,EAC/B,OAA6B;IAE7B,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,SAAS,CAAC,gBAAgB,CAC1D,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,EAC5E,OAAO,CAAC,cAAc,CACvB,CAAC;IAEF,OAAO;QACL,eAAe,EAAE,eAAsB;KACxC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendTransaction = sendTransaction;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
/**
|
|
6
|
+
* Sends an EVM transaction.
|
|
7
|
+
*
|
|
8
|
+
* @param apiClient - The API client.
|
|
9
|
+
* @param options - The options for sending the transaction.
|
|
10
|
+
*
|
|
11
|
+
* @returns The result of the transaction.
|
|
12
|
+
*/
|
|
13
|
+
async function sendTransaction(apiClient, options) {
|
|
14
|
+
const { address, network, idempotencyKey } = options;
|
|
15
|
+
let transaction = options.transaction;
|
|
16
|
+
if (typeof transaction !== "string") {
|
|
17
|
+
transaction = (0, viem_1.serializeTransaction)({
|
|
18
|
+
...transaction,
|
|
19
|
+
// chainId is ignored in favor of network
|
|
20
|
+
chainId: 1,
|
|
21
|
+
type: "eip1559",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const result = await apiClient.sendEvmTransaction(address, { transaction, network }, idempotencyKey);
|
|
25
|
+
return {
|
|
26
|
+
transactionHash: result.transactionHash,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=sendTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendTransaction.js","sourceRoot":"","sources":["../../../actions/evm/sendTransaction.ts"],"names":[],"mappings":";;AA+CA,0CAyBC;AAxED,+BAAuE;AAuCvE;;;;;;;GAOG;AACI,KAAK,UAAU,eAAe,CACnC,SAA+B,EAC/B,OAA+B;IAE/B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IACrD,IAAI,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAEtC,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACpC,WAAW,GAAG,IAAA,2BAAoB,EAAC;YACjC,GAAG,WAAW;YACd,yCAAyC;YACzC,OAAO,EAAE,CAAC;YACV,IAAI,EAAE,SAAS;SAChB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,kBAAkB,CAC/C,OAAO,EACP,EAAE,WAAW,EAAE,OAAO,EAAE,EACxB,cAAc,CACf,CAAC;IAEF,OAAO;QACL,eAAe,EAAE,MAAM,CAAC,eAAsB;KAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -39,11 +39,10 @@ const viem_1 = require("viem");
|
|
|
39
39
|
* ```
|
|
40
40
|
*
|
|
41
41
|
* @param {CdpOpenApiClientType} client - The client to use to send the user operation.
|
|
42
|
-
* @param {EvmSmartAccount} smartAccount - The smart account to send the user operation from.
|
|
43
42
|
* @param {SendUserOperationOptions<T>} options - The options for the user operation.
|
|
44
43
|
* @returns {Promise<SendUserOperationReturnType>} The result of the user operation.
|
|
45
44
|
*/
|
|
46
|
-
async function sendUserOperation(client,
|
|
45
|
+
async function sendUserOperation(client, options) {
|
|
47
46
|
const { calls, network, paymasterUrl } = options;
|
|
48
47
|
if (calls.length === 0) {
|
|
49
48
|
throw new Error("Calls array is empty");
|
|
@@ -67,20 +66,20 @@ async function sendUserOperation(client, smartAccount, options) {
|
|
|
67
66
|
value,
|
|
68
67
|
};
|
|
69
68
|
});
|
|
70
|
-
const createOpResponse = await client.prepareUserOperation(smartAccount.address, {
|
|
69
|
+
const createOpResponse = await client.prepareUserOperation(options.smartAccount.address, {
|
|
71
70
|
network,
|
|
72
71
|
calls: encodedCalls,
|
|
73
72
|
paymasterUrl,
|
|
74
73
|
});
|
|
75
|
-
const owner = smartAccount.owners[0];
|
|
74
|
+
const owner = options.smartAccount.owners[0];
|
|
76
75
|
const signature = await owner.sign({
|
|
77
76
|
hash: createOpResponse.userOpHash,
|
|
78
77
|
});
|
|
79
|
-
const broadcastResponse = await client.sendUserOperation(smartAccount.address, createOpResponse.userOpHash, {
|
|
78
|
+
const broadcastResponse = await client.sendUserOperation(options.smartAccount.address, createOpResponse.userOpHash, {
|
|
80
79
|
signature,
|
|
81
80
|
}, options.idempotencyKey);
|
|
82
81
|
return {
|
|
83
|
-
smartAccountAddress: smartAccount.address,
|
|
82
|
+
smartAccountAddress: options.smartAccount.address,
|
|
84
83
|
status: broadcastResponse.status,
|
|
85
84
|
userOpHash: createOpResponse.userOpHash,
|
|
86
85
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../actions/evm/sendUserOperation.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../actions/evm/sendUserOperation.ts"],"names":[],"mappings":";;AAwGA,8CA0DC;AAlKD,+BAA0C;AAgE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACI,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,OAAoC;IAEpC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAEjD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACpC,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAEnD,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,IAAI,cAAc,IAAI,IAAI,EAAE,CAAC;YACxD,OAAO;gBACL,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,IAAI,EAAE,IAAA,yBAAkB,EAAC;oBACvB,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,YAAY,EAAE,IAAI,CAAC,YAAY;oBAC/B,IAAI,EAAE,IAAI,CAAC,IAAI;iBAChB,CAAC;gBACF,KAAK;aACN,CAAC;QACJ,CAAC;QAED,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI;YACvB,KAAK;SACN,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE;QACvF,OAAO;QACP,KAAK,EAAE,YAAY;QACnB,YAAY;KACb,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE7C,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC;QACjC,IAAI,EAAE,gBAAgB,CAAC,UAAiB;KACzC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,MAAM,MAAM,CAAC,iBAAiB,CACtD,OAAO,CAAC,YAAY,CAAC,OAAO,EAC5B,gBAAgB,CAAC,UAAiB,EAClC;QACE,SAAS;KACV,EACD,OAAO,CAAC,cAAc,CACvB,CAAC;IAEF,OAAO;QACL,mBAAmB,EAAE,OAAO,CAAC,YAAY,CAAC,OAAO;QACjD,MAAM,EAAE,iBAAiB,CAAC,MAAM;QAChC,UAAU,EAAE,gBAAgB,CAAC,UAAU;KACT,CAAC;AACnC,CAAC"}
|
|
@@ -5,20 +5,20 @@ const viem_1 = require("viem");
|
|
|
5
5
|
const utils_js_1 = require("./utils.js");
|
|
6
6
|
const serializeTransaction_js_1 = require("../../../utils/serializeTransaction.js");
|
|
7
7
|
exports.accountTransferStrategy = {
|
|
8
|
-
executeTransfer: async ({ apiClient, from,
|
|
8
|
+
executeTransfer: async ({ apiClient, from, to, value, token, network }) => {
|
|
9
9
|
const transactionHash = await (async () => {
|
|
10
|
-
if (
|
|
10
|
+
if (token === "eth") {
|
|
11
11
|
const result = await apiClient.sendEvmTransaction(from.address, {
|
|
12
12
|
transaction: (0, serializeTransaction_js_1.serializeEIP1559Transaction)({
|
|
13
13
|
value,
|
|
14
14
|
to,
|
|
15
15
|
}),
|
|
16
|
-
network
|
|
16
|
+
network,
|
|
17
17
|
});
|
|
18
18
|
return result.transactionHash;
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
const erc20Address = (0, utils_js_1.getErc20Address)(
|
|
21
|
+
const erc20Address = (0, utils_js_1.getErc20Address)(token, network);
|
|
22
22
|
await apiClient.sendEvmTransaction(from.address, {
|
|
23
23
|
transaction: (0, serializeTransaction_js_1.serializeEIP1559Transaction)({
|
|
24
24
|
to: erc20Address,
|
|
@@ -28,7 +28,7 @@ exports.accountTransferStrategy = {
|
|
|
28
28
|
args: [to, value],
|
|
29
29
|
}),
|
|
30
30
|
}),
|
|
31
|
-
network
|
|
31
|
+
network,
|
|
32
32
|
});
|
|
33
33
|
const result = await apiClient.sendEvmTransaction(from.address, {
|
|
34
34
|
transaction: (0, serializeTransaction_js_1.serializeEIP1559Transaction)({
|
|
@@ -39,18 +39,22 @@ exports.accountTransferStrategy = {
|
|
|
39
39
|
args: [to, value],
|
|
40
40
|
}),
|
|
41
41
|
}),
|
|
42
|
-
network
|
|
42
|
+
network,
|
|
43
43
|
});
|
|
44
44
|
return result.transactionHash;
|
|
45
45
|
}
|
|
46
46
|
})();
|
|
47
47
|
return transactionHash;
|
|
48
48
|
},
|
|
49
|
-
waitForResult: async ({ publicClient, hash }) => {
|
|
49
|
+
waitForResult: async ({ publicClient, hash, waitOptions }) => {
|
|
50
50
|
let receipt;
|
|
51
51
|
try {
|
|
52
52
|
receipt = await publicClient.waitForTransactionReceipt({
|
|
53
53
|
hash,
|
|
54
|
+
pollingInterval: waitOptions?.intervalSeconds
|
|
55
|
+
? waitOptions.intervalSeconds * 1000
|
|
56
|
+
: undefined,
|
|
57
|
+
timeout: waitOptions?.timeoutSeconds ? waitOptions.timeoutSeconds * 1000 : undefined,
|
|
54
58
|
});
|
|
55
59
|
}
|
|
56
60
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountTransferStrategy.js","sourceRoot":"","sources":["../../../../actions/evm/transfer/accountTransferStrategy.ts"],"names":[],"mappings":";;;AAAA,+BAMc;AAGd,yCAA6C;AAE7C,oFAAqF;AAExE,QAAA,uBAAuB,GAA0C;IAC5E,eAAe,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"accountTransferStrategy.js","sourceRoot":"","sources":["../../../../actions/evm/transfer/accountTransferStrategy.ts"],"names":[],"mappings":"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"}
|
|
@@ -6,11 +6,13 @@ const utils_js_1 = require("./utils.js");
|
|
|
6
6
|
const sendUserOperation_js_1 = require("../sendUserOperation.js");
|
|
7
7
|
const waitForUserOperation_js_1 = require("../waitForUserOperation.js");
|
|
8
8
|
exports.smartAccountTransferStrategy = {
|
|
9
|
-
executeTransfer: async ({ apiClient, from,
|
|
9
|
+
executeTransfer: async ({ apiClient, from, to, value, token, network, paymasterUrl }) => {
|
|
10
10
|
const userOpHash = await (async () => {
|
|
11
|
-
if (
|
|
12
|
-
const result = await (0, sendUserOperation_js_1.sendUserOperation)(apiClient,
|
|
13
|
-
|
|
11
|
+
if (token === "eth") {
|
|
12
|
+
const result = await (0, sendUserOperation_js_1.sendUserOperation)(apiClient, {
|
|
13
|
+
smartAccount: from,
|
|
14
|
+
paymasterUrl,
|
|
15
|
+
network,
|
|
14
16
|
calls: [
|
|
15
17
|
{
|
|
16
18
|
to,
|
|
@@ -22,9 +24,11 @@ exports.smartAccountTransferStrategy = {
|
|
|
22
24
|
return result.userOpHash;
|
|
23
25
|
}
|
|
24
26
|
else {
|
|
25
|
-
const erc20Address = (0, utils_js_1.getErc20Address)(
|
|
26
|
-
const result = await (0, sendUserOperation_js_1.sendUserOperation)(apiClient,
|
|
27
|
-
|
|
27
|
+
const erc20Address = (0, utils_js_1.getErc20Address)(token, network);
|
|
28
|
+
const result = await (0, sendUserOperation_js_1.sendUserOperation)(apiClient, {
|
|
29
|
+
smartAccount: from,
|
|
30
|
+
paymasterUrl,
|
|
31
|
+
network,
|
|
28
32
|
calls: [
|
|
29
33
|
{
|
|
30
34
|
to: erc20Address,
|
|
@@ -49,10 +53,11 @@ exports.smartAccountTransferStrategy = {
|
|
|
49
53
|
})();
|
|
50
54
|
return userOpHash;
|
|
51
55
|
},
|
|
52
|
-
waitForResult: async ({ apiClient, publicClient, from, hash }) => {
|
|
56
|
+
waitForResult: async ({ apiClient, publicClient, from, hash, waitOptions }) => {
|
|
53
57
|
const result = await (0, waitForUserOperation_js_1.waitForUserOperation)(apiClient, {
|
|
54
58
|
smartAccountAddress: from.address,
|
|
55
59
|
userOpHash: hash,
|
|
60
|
+
waitOptions,
|
|
56
61
|
});
|
|
57
62
|
if (result.status === "complete") {
|
|
58
63
|
return { status: "success", transactionHash: hash };
|