@coinbase/cdp-sdk 1.8.0 → 1.9.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 +10 -0
- package/README.md +182 -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/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +35 -4
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +3 -3
- package/_cjs/openapi-client/generated/index.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/_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/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +34 -3
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/index.msw.js +3 -3
- package/_esm/openapi-client/generated/index.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/_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/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +95 -17
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts +3 -3
- package/_types/openapi-client/generated/index.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/policies/schema.d.ts +630 -0
- package/_types/policies/schema.d.ts.map +1 -1
- package/_types/version.d.ts +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/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +134 -18
- package/openapi-client/generated/index.msw.ts +3 -3
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../policies/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,oBAAoB,yCAAuC,CAAC;AACzE;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,sBAAsB,6BAA2B,CAAC;AAC/D;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,sBAAsB,6BAA2B,CAAC;AAC/D;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,uBAAuB;IAClC,gFAAgF;;IAEhF;;;OAGG;;IAEH,8FAA8F;;;;;;;;;;EAE9F,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,yBAAyB;IACpC,+EAA+E;;IAE/E;;;;OAIG;;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EH,8FAA8F;;;;;;;;;;;YAS9F,+EAA+E;;YAE/E;;;;eAIG;;YAEH;;;;eAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8JH;;;WAGG;;QAEH;;;WAGG;;QAEH;;;WAGG;;YAvMH,gFAAgF;;YAEhF;;;eAGG;;YAEH,8FAA8F;;;;;;;;;;;YAS9F,+EAA+E;;YAE/E;;;;eAIG;;YAEH;;;;eAIG;;;;;;;;;;;YAkBH,+EAA+E;;YAE/E;;;eAGG;;YAEH;;;;eAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwJH;;;WAGG;;QAEH;;;WAGG;;QAEH;;;WAGG;;YA5JH,kFAAkF;;YAElF;;;eAGG;;YAEH;;;;eAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0NH,CAAC;AACH;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
package/_types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.9.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type TransactionSerializable, serializeTransaction } from "viem";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
listTokenBalances,
|
|
@@ -15,10 +15,12 @@ import { accountTransferStrategy } from "../../actions/evm/transfer/accountTrans
|
|
|
15
15
|
import { transfer } from "../../actions/evm/transfer/transfer.js";
|
|
16
16
|
|
|
17
17
|
import type { EvmServerAccount } from "./types.js";
|
|
18
|
-
import type {
|
|
19
|
-
|
|
18
|
+
import type {
|
|
19
|
+
SendTransactionOptions,
|
|
20
|
+
TransactionResult,
|
|
21
|
+
} from "../../actions/evm/sendTransaction.js";
|
|
20
22
|
import type { CdpOpenApiClientType, EvmAccount } from "../../openapi-client/index.js";
|
|
21
|
-
import type { Address, EIP712Message, Hash } from "../../types/misc.js";
|
|
23
|
+
import type { Address, EIP712Message, Hash, Hex } from "../../types/misc.js";
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* Options for converting a pre-existing EvmAccount to a EvmServerAccount.
|
|
@@ -68,8 +70,7 @@ export function toEvmServerAccount(
|
|
|
68
70
|
const result = await apiClient.signEvmTypedData(options.account.address, message);
|
|
69
71
|
return result.signature as Hex;
|
|
70
72
|
},
|
|
71
|
-
|
|
72
|
-
async transfer(transferArgs): Promise<TransferResult> {
|
|
73
|
+
async transfer(transferArgs): Promise<TransactionResult> {
|
|
73
74
|
return transfer(apiClient, account, transferArgs, accountTransferStrategy);
|
|
74
75
|
},
|
|
75
76
|
async listTokenBalances(
|
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
import { GetUserOperationOptions, UserOperation } from "../../client/evm/evm.types.js";
|
|
25
25
|
|
|
26
26
|
import type { EvmAccount, EvmSmartAccount } from "./types.js";
|
|
27
|
-
import type { TransferResult } from "../../actions/evm/transfer/types.js";
|
|
28
27
|
import type {
|
|
29
28
|
CdpOpenApiClientType,
|
|
30
29
|
EvmSmartAccount as EvmSmartAccountModel,
|
|
@@ -60,7 +59,7 @@ export function toEvmSmartAccount(
|
|
|
60
59
|
const account: EvmSmartAccount = {
|
|
61
60
|
address: options.smartAccount.address as Address,
|
|
62
61
|
owners: [options.owner],
|
|
63
|
-
async transfer(transferArgs): Promise<
|
|
62
|
+
async transfer(transferArgs): Promise<SendUserOperationReturnType> {
|
|
64
63
|
return transfer(apiClient, account, transferArgs, smartAccountTransferStrategy);
|
|
65
64
|
},
|
|
66
65
|
async listTokenBalances(
|
|
@@ -2,6 +2,7 @@ import { Account, SolanaAccount } from "./types.js";
|
|
|
2
2
|
import { requestFaucet } from "../../actions/solana/requestFaucet.js";
|
|
3
3
|
import { signMessage } from "../../actions/solana/signMessage.js";
|
|
4
4
|
import { signTransaction } from "../../actions/solana/signTransaction.js";
|
|
5
|
+
import { transfer, type TransferOptions } from "../../actions/solana/transfer.js";
|
|
5
6
|
import {
|
|
6
7
|
RequestFaucetOptions,
|
|
7
8
|
SignatureResult,
|
|
@@ -54,6 +55,12 @@ export function toSolanaAccount(
|
|
|
54
55
|
});
|
|
55
56
|
},
|
|
56
57
|
policies: options.account.policies,
|
|
58
|
+
async transfer(options: Omit<TransferOptions, "from">): Promise<SignatureResult> {
|
|
59
|
+
return transfer(apiClient, {
|
|
60
|
+
...options,
|
|
61
|
+
from: account.address,
|
|
62
|
+
});
|
|
63
|
+
},
|
|
57
64
|
};
|
|
58
65
|
|
|
59
66
|
return account;
|
|
@@ -1,88 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
encodeFunctionData,
|
|
3
|
-
erc20Abi,
|
|
4
|
-
Hex,
|
|
5
|
-
TransactionReceipt,
|
|
6
|
-
WaitForTransactionReceiptTimeoutError,
|
|
7
|
-
} from "viem";
|
|
1
|
+
import { encodeFunctionData, erc20Abi } from "viem";
|
|
8
2
|
|
|
9
|
-
import { TransferExecutionStrategy } from "./types.js";
|
|
10
3
|
import { getErc20Address } from "./utils.js";
|
|
11
|
-
import { EvmAccount } from "../../../accounts/evm/types.js";
|
|
12
4
|
import { serializeEIP1559Transaction } from "../../../utils/serializeTransaction.js";
|
|
13
5
|
|
|
6
|
+
import type { TransferExecutionStrategy } from "./types.js";
|
|
7
|
+
import type { EvmAccount } from "../../../accounts/evm/types.js";
|
|
8
|
+
import type { TransactionResult } from "../sendTransaction.js";
|
|
9
|
+
|
|
14
10
|
export const accountTransferStrategy: TransferExecutionStrategy<EvmAccount> = {
|
|
15
11
|
executeTransfer: async ({ apiClient, from, to, value, token, network }) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
return result.transactionHash as Hex;
|
|
26
|
-
} else {
|
|
27
|
-
const erc20Address = getErc20Address(token, network);
|
|
28
|
-
|
|
29
|
-
await apiClient.sendEvmTransaction(from.address, {
|
|
30
|
-
transaction: serializeEIP1559Transaction({
|
|
31
|
-
to: erc20Address,
|
|
32
|
-
data: encodeFunctionData({
|
|
33
|
-
abi: erc20Abi,
|
|
34
|
-
functionName: "approve",
|
|
35
|
-
args: [to, value],
|
|
36
|
-
}),
|
|
37
|
-
}),
|
|
38
|
-
network,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const result = await apiClient.sendEvmTransaction(from.address, {
|
|
42
|
-
transaction: serializeEIP1559Transaction({
|
|
43
|
-
to: erc20Address,
|
|
44
|
-
data: encodeFunctionData({
|
|
45
|
-
abi: erc20Abi,
|
|
46
|
-
functionName: "transfer",
|
|
47
|
-
args: [to, value],
|
|
48
|
-
}),
|
|
49
|
-
}),
|
|
50
|
-
network,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
return result.transactionHash as Hex;
|
|
54
|
-
}
|
|
55
|
-
})();
|
|
56
|
-
|
|
57
|
-
return transactionHash;
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
waitForResult: async ({ publicClient, hash, waitOptions }) => {
|
|
61
|
-
let receipt: TransactionReceipt;
|
|
62
|
-
try {
|
|
63
|
-
receipt = await publicClient.waitForTransactionReceipt({
|
|
64
|
-
hash,
|
|
65
|
-
pollingInterval: waitOptions?.intervalSeconds
|
|
66
|
-
? waitOptions.intervalSeconds * 1000
|
|
67
|
-
: undefined,
|
|
68
|
-
timeout: waitOptions?.timeoutSeconds ? waitOptions.timeoutSeconds * 1000 : undefined,
|
|
69
|
-
});
|
|
70
|
-
} catch (error) {
|
|
71
|
-
if (error instanceof WaitForTransactionReceiptTimeoutError) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
`Transaction timed out. Check the transaction on the explorer: ${publicClient.chain.blockExplorers?.default.url}/tx/${hash}`,
|
|
74
|
-
);
|
|
75
|
-
} else {
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
12
|
+
if (token === "eth") {
|
|
13
|
+
return apiClient.sendEvmTransaction(from.address, {
|
|
14
|
+
transaction: serializeEIP1559Transaction({
|
|
15
|
+
value,
|
|
16
|
+
to,
|
|
17
|
+
}),
|
|
18
|
+
network,
|
|
19
|
+
}) as Promise<TransactionResult>;
|
|
78
20
|
}
|
|
79
21
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
22
|
+
const erc20Address = getErc20Address(token, network);
|
|
23
|
+
|
|
24
|
+
await apiClient.sendEvmTransaction(from.address, {
|
|
25
|
+
transaction: serializeEIP1559Transaction({
|
|
26
|
+
to: erc20Address,
|
|
27
|
+
data: encodeFunctionData({
|
|
28
|
+
abi: erc20Abi,
|
|
29
|
+
functionName: "approve",
|
|
30
|
+
args: [to, value],
|
|
31
|
+
}),
|
|
32
|
+
}),
|
|
33
|
+
network,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return apiClient.sendEvmTransaction(from.address, {
|
|
37
|
+
transaction: serializeEIP1559Transaction({
|
|
38
|
+
to: erc20Address,
|
|
39
|
+
data: encodeFunctionData({
|
|
40
|
+
abi: erc20Abi,
|
|
41
|
+
functionName: "transfer",
|
|
42
|
+
args: [to, value],
|
|
43
|
+
}),
|
|
44
|
+
}),
|
|
45
|
+
network,
|
|
46
|
+
}) as Promise<TransactionResult>;
|
|
87
47
|
},
|
|
88
48
|
};
|
|
@@ -1,75 +1,55 @@
|
|
|
1
1
|
import { encodeFunctionData, erc20Abi } from "viem";
|
|
2
2
|
|
|
3
|
-
import { TransferExecutionStrategy } from "./types.js";
|
|
4
3
|
import { getErc20Address } from "./utils.js";
|
|
5
|
-
import { EvmSmartAccount } from "../../../accounts/evm/types.js";
|
|
6
4
|
import { sendUserOperation } from "../sendUserOperation.js";
|
|
7
|
-
|
|
5
|
+
|
|
6
|
+
import type { TransferExecutionStrategy } from "./types.js";
|
|
7
|
+
import type { EvmSmartAccount } from "../../../accounts/evm/types.js";
|
|
8
8
|
|
|
9
9
|
export const smartAccountTransferStrategy: TransferExecutionStrategy<EvmSmartAccount> = {
|
|
10
10
|
executeTransfer: async ({ apiClient, from, to, value, token, network, paymasterUrl }) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const erc20Address = getErc20Address(token, network);
|
|
28
|
-
|
|
29
|
-
const result = await sendUserOperation(apiClient, {
|
|
30
|
-
smartAccount: from,
|
|
31
|
-
paymasterUrl,
|
|
32
|
-
network,
|
|
33
|
-
calls: [
|
|
34
|
-
{
|
|
35
|
-
to: erc20Address,
|
|
36
|
-
data: encodeFunctionData({
|
|
37
|
-
abi: erc20Abi,
|
|
38
|
-
functionName: "approve",
|
|
39
|
-
args: [to, value],
|
|
40
|
-
}),
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
to: erc20Address,
|
|
44
|
-
data: encodeFunctionData({
|
|
45
|
-
abi: erc20Abi,
|
|
46
|
-
functionName: "transfer",
|
|
47
|
-
args: [to, value],
|
|
48
|
-
}),
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
return result.userOpHash;
|
|
54
|
-
}
|
|
55
|
-
})();
|
|
56
|
-
|
|
57
|
-
return userOpHash;
|
|
58
|
-
},
|
|
11
|
+
if (token === "eth") {
|
|
12
|
+
const result = await sendUserOperation(apiClient, {
|
|
13
|
+
smartAccount: from,
|
|
14
|
+
paymasterUrl,
|
|
15
|
+
network,
|
|
16
|
+
calls: [
|
|
17
|
+
{
|
|
18
|
+
to,
|
|
19
|
+
value,
|
|
20
|
+
data: "0x",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
return result;
|
|
25
|
+
} else {
|
|
26
|
+
const erc20Address = getErc20Address(token, network);
|
|
59
27
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
28
|
+
const result = await sendUserOperation(apiClient, {
|
|
29
|
+
smartAccount: from,
|
|
30
|
+
paymasterUrl,
|
|
31
|
+
network,
|
|
32
|
+
calls: [
|
|
33
|
+
{
|
|
34
|
+
to: erc20Address,
|
|
35
|
+
data: encodeFunctionData({
|
|
36
|
+
abi: erc20Abi,
|
|
37
|
+
functionName: "approve",
|
|
38
|
+
args: [to, value],
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
to: erc20Address,
|
|
43
|
+
data: encodeFunctionData({
|
|
44
|
+
abi: erc20Abi,
|
|
45
|
+
functionName: "transfer",
|
|
46
|
+
args: [to, value],
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
});
|
|
66
51
|
|
|
67
|
-
|
|
68
|
-
return { status: "success", transactionHash: hash };
|
|
69
|
-
} else {
|
|
70
|
-
throw new Error(
|
|
71
|
-
`Transaction failed. Check the transaction on the explorer: ${publicClient.chain.blockExplorers?.default.url}/tx/${hash}`,
|
|
72
|
-
);
|
|
52
|
+
return result;
|
|
73
53
|
}
|
|
74
54
|
},
|
|
75
55
|
};
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { createPublicClient, http, erc20Abi, parseUnits, Address, Chain, Transport } from "viem";
|
|
2
|
-
|
|
3
|
-
import { mapNetworkToChain } from "./utils.js";
|
|
4
|
-
import { EvmAccount, EvmSmartAccount } from "../../../accounts/evm/types.js";
|
|
5
|
-
import { CdpOpenApiClientType } from "../../../openapi-client/index.js";
|
|
6
|
-
|
|
7
1
|
import type {
|
|
8
|
-
TransferResult,
|
|
9
2
|
TransferExecutionStrategy,
|
|
10
3
|
SmartAccountTransferOptions,
|
|
11
|
-
|
|
4
|
+
TransferOptions,
|
|
12
5
|
} from "./types.js";
|
|
6
|
+
import type { EvmAccount, EvmSmartAccount } from "../../../accounts/evm/types.js";
|
|
7
|
+
import type { CdpOpenApiClientType } from "../../../openapi-client/index.js";
|
|
8
|
+
import type { Address } from "../../../types/misc.js";
|
|
9
|
+
import type { TransactionResult } from "../sendTransaction.js";
|
|
10
|
+
import type { SendUserOperationReturnType } from "../sendUserOperation.js";
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* Transfer an amount of a token from an account to another account.
|
|
@@ -23,60 +21,21 @@ import type {
|
|
|
23
21
|
export async function transfer<T extends EvmAccount | EvmSmartAccount>(
|
|
24
22
|
apiClient: CdpOpenApiClientType,
|
|
25
23
|
from: T,
|
|
26
|
-
transferArgs: T extends EvmSmartAccount ? SmartAccountTransferOptions :
|
|
24
|
+
transferArgs: T extends EvmSmartAccount ? SmartAccountTransferOptions : TransferOptions,
|
|
27
25
|
transferStrategy: TransferExecutionStrategy<T>,
|
|
28
|
-
): Promise<
|
|
29
|
-
const publicClient = createPublicClient<Transport, Chain>({
|
|
30
|
-
chain: mapNetworkToChain(transferArgs.network),
|
|
31
|
-
transport: http(),
|
|
32
|
-
});
|
|
33
|
-
|
|
26
|
+
): Promise<T extends EvmSmartAccount ? SendUserOperationReturnType : TransactionResult> {
|
|
34
27
|
const to =
|
|
35
28
|
typeof transferArgs.to === "string" ? transferArgs.to : (transferArgs.to.address as Address);
|
|
36
29
|
|
|
37
|
-
const value = await (async () => {
|
|
38
|
-
// user supplied a bigint. otherwise, we need to convert the amount to a bigint
|
|
39
|
-
if (typeof transferArgs.amount !== "string") {
|
|
40
|
-
return transferArgs.amount;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const decimals = await (async () => {
|
|
44
|
-
if (transferArgs.token === "eth") {
|
|
45
|
-
return 18;
|
|
46
|
-
} else if (transferArgs.token === "usdc") {
|
|
47
|
-
return 6;
|
|
48
|
-
} else {
|
|
49
|
-
return publicClient.readContract({
|
|
50
|
-
address: transferArgs.token,
|
|
51
|
-
abi: erc20Abi,
|
|
52
|
-
functionName: "decimals",
|
|
53
|
-
args: [],
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
})();
|
|
57
|
-
|
|
58
|
-
return parseUnits(transferArgs.amount, decimals);
|
|
59
|
-
})();
|
|
60
|
-
|
|
61
30
|
const transfer = {
|
|
62
31
|
apiClient,
|
|
63
32
|
from,
|
|
64
33
|
to,
|
|
65
|
-
value,
|
|
34
|
+
value: transferArgs.amount,
|
|
66
35
|
token: transferArgs.token,
|
|
67
36
|
network: transferArgs.network,
|
|
68
37
|
paymasterUrl: "paymasterUrl" in transferArgs ? transferArgs.paymasterUrl : undefined,
|
|
69
38
|
};
|
|
70
39
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const result = await transferStrategy.waitForResult({
|
|
74
|
-
apiClient,
|
|
75
|
-
publicClient,
|
|
76
|
-
from,
|
|
77
|
-
hash,
|
|
78
|
-
waitOptions: transferArgs.waitOptions,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
return result;
|
|
40
|
+
return transferStrategy.executeTransfer(transfer);
|
|
82
41
|
}
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
TransactionReceipt,
|
|
4
|
-
Address,
|
|
5
|
-
PublicClient,
|
|
6
|
-
Chain,
|
|
7
|
-
Transport,
|
|
8
|
-
WaitForTransactionReceiptParameters,
|
|
9
|
-
} from "viem";
|
|
10
|
-
|
|
11
|
-
import {
|
|
1
|
+
import type { EvmAccount, EvmSmartAccount } from "../../../accounts/evm/types.js";
|
|
2
|
+
import type {
|
|
12
3
|
CdpOpenApiClientType,
|
|
13
4
|
EvmUserOperationNetwork,
|
|
14
5
|
SendEvmTransactionBodyNetwork,
|
|
15
6
|
} from "../../../openapi-client/index.js";
|
|
16
|
-
|
|
17
|
-
import type {
|
|
18
|
-
import type {
|
|
7
|
+
import type { TransactionResult } from "../sendTransaction.js";
|
|
8
|
+
import type { SendUserOperationReturnType } from "../sendUserOperation.js";
|
|
9
|
+
import type { Hex, Address } from "viem";
|
|
19
10
|
|
|
20
11
|
/**
|
|
21
12
|
* The network to transfer the token on.
|
|
@@ -29,51 +20,21 @@ export type TransferOptions = {
|
|
|
29
20
|
/** The account to transfer the token to. */
|
|
30
21
|
to: EvmAccount | Address;
|
|
31
22
|
/**
|
|
32
|
-
* The amount of the token to transfer.
|
|
33
|
-
* If a string is provided, it will be parsed into a bigint based on the token's decimals.
|
|
23
|
+
* The amount of the token to transfer, represented as an atomic value.
|
|
34
24
|
*/
|
|
35
|
-
amount: bigint
|
|
25
|
+
amount: bigint;
|
|
36
26
|
/** The token to transfer. Can be a contract address or a predefined token name. */
|
|
37
27
|
token: "eth" | "usdc" | Hex;
|
|
38
28
|
/** The network to transfer the token on. */
|
|
39
29
|
network: Network;
|
|
40
30
|
};
|
|
41
31
|
|
|
42
|
-
/**
|
|
43
|
-
* The options for the transfer using an account.
|
|
44
|
-
*/
|
|
45
|
-
export type AccountTransferOptions = TransferOptions & {
|
|
46
|
-
/** The options for waiting for the result of the transfer. */
|
|
47
|
-
waitOptions?: {
|
|
48
|
-
/**
|
|
49
|
-
* Polling frequency (in seconds). Defaults to 4 seconds.
|
|
50
|
-
*/
|
|
51
|
-
intervalSeconds?: WaitForTransactionReceiptParameters["pollingInterval"];
|
|
52
|
-
/**
|
|
53
|
-
* Optional timeout (in seconds) to wait before stopping polling. Defaults to 180 seconds.
|
|
54
|
-
*/
|
|
55
|
-
timeoutSeconds?: WaitForTransactionReceiptParameters["timeout"];
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
32
|
/**
|
|
60
33
|
* The options for the transfer using a smart account.
|
|
61
34
|
*/
|
|
62
35
|
export type SmartAccountTransferOptions = TransferOptions & {
|
|
63
36
|
/** The paymaster URL to use for the transfer. */
|
|
64
37
|
paymasterUrl?: string;
|
|
65
|
-
/** The options for waiting for the result of the transfer. */
|
|
66
|
-
waitOptions?: WaitForUserOperationOptions["waitOptions"];
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* The result of the transfer.
|
|
71
|
-
*/
|
|
72
|
-
export type TransferResult = {
|
|
73
|
-
/** The status of the transaction. */
|
|
74
|
-
status: TransactionReceipt["status"];
|
|
75
|
-
/** The transaction hash of the transfer. */
|
|
76
|
-
transactionHash: Hex;
|
|
77
38
|
};
|
|
78
39
|
|
|
79
40
|
/**
|
|
@@ -101,24 +62,5 @@ export interface TransferExecutionStrategy<T extends EvmAccount | EvmSmartAccoun
|
|
|
101
62
|
token: TransferOptions["token"];
|
|
102
63
|
network: TransferOptions["network"];
|
|
103
64
|
} & (T extends EvmSmartAccount ? { paymasterUrl?: string } : object),
|
|
104
|
-
): Promise<
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Waits for the result of the transfer.
|
|
108
|
-
*
|
|
109
|
-
* @param args - The arguments for the transfer.
|
|
110
|
-
* @param args.apiClient - The API client to use for the transfer.
|
|
111
|
-
* @param args.publicClient - The public client to use for the transfer.
|
|
112
|
-
* @param args.from - The account to transfer the token from.
|
|
113
|
-
* @param args.hash - The transaction hash of the transfer.
|
|
114
|
-
* @param args.waitOptions - The options for waiting for the result of the transfer.
|
|
115
|
-
* @returns The result of the transfer.
|
|
116
|
-
*/
|
|
117
|
-
waitForResult(args: {
|
|
118
|
-
apiClient: CdpOpenApiClientType;
|
|
119
|
-
publicClient: PublicClient<Transport, Chain>;
|
|
120
|
-
from: T;
|
|
121
|
-
hash: Hex;
|
|
122
|
-
waitOptions?: WaitForUserOperationOptions["waitOptions"];
|
|
123
|
-
}): Promise<TransferResult>;
|
|
65
|
+
): Promise<T extends EvmSmartAccount ? SendUserOperationReturnType : TransactionResult>;
|
|
124
66
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { base, baseSepolia } from "viem/chains";
|
|
2
|
-
|
|
3
1
|
import { Network } from "./types.js";
|
|
4
2
|
|
|
5
3
|
/**
|
|
@@ -26,14 +24,3 @@ const addressMap = {
|
|
|
26
24
|
export function getErc20Address(token: string, network: Network) {
|
|
27
25
|
return addressMap[network][token] ?? token;
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Map a network to a viem chain.
|
|
32
|
-
* TODO: Add more networks (or dynamically map viem chains).
|
|
33
|
-
*
|
|
34
|
-
* @param network - The network to map to a chain.
|
|
35
|
-
* @returns The chain for the given network.
|
|
36
|
-
*/
|
|
37
|
-
export function mapNetworkToChain(network: Network) {
|
|
38
|
-
return network === "base" ? base : baseSepolia;
|
|
39
|
-
}
|