@coinbase/cdp-sdk 1.4.0 → 1.5.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 +8 -0
- package/README.md +87 -2
- package/_cjs/accounts/evm/toEvmServerAccount.js +5 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +7 -2
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js +72 -0
- package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -0
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +65 -0
- package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -0
- package/_cjs/actions/evm/transfer/transfer.js +59 -0
- package/_cjs/actions/evm/transfer/transfer.js.map +1 -0
- package/_cjs/actions/evm/transfer/types.js +3 -0
- package/_cjs/actions/evm/transfer/types.js.map +1 -0
- package/_cjs/actions/evm/transfer/utils.js +39 -0
- package/_cjs/actions/evm/transfer/utils.js.map +1 -0
- package/_cjs/actions/evm/types.js +3 -0
- package/_cjs/actions/evm/types.js.map +1 -0
- package/_cjs/client/evm/evm.js +44 -2
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/client/solana/solana.js +42 -0
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/utils/serializeTransaction.js +18 -0
- package/_cjs/utils/serializeTransaction.js.map +1 -0
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +5 -0
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +7 -2
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/actions/evm/transfer/accountTransferStrategy.js +69 -0
- package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -0
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +62 -0
- package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -0
- package/_esm/actions/evm/transfer/transfer.js +56 -0
- package/_esm/actions/evm/transfer/transfer.js.map +1 -0
- package/_esm/actions/evm/transfer/types.js +2 -0
- package/_esm/actions/evm/transfer/types.js.map +1 -0
- package/_esm/actions/evm/transfer/utils.js +35 -0
- package/_esm/actions/evm/transfer/utils.js.map +1 -0
- package/_esm/actions/evm/types.js +2 -0
- package/_esm/actions/evm/types.js.map +1 -0
- package/_esm/client/evm/evm.js +44 -2
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/client/solana/solana.js +42 -0
- package/_esm/client/solana/solana.js.map +1 -1
- package/_esm/utils/serializeTransaction.js +15 -0
- package/_esm/utils/serializeTransaction.js.map +1 -0
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts +2 -2
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts +4 -4
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/types.d.ts +4 -3
- package/_types/accounts/types.d.ts.map +1 -1
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +4 -0
- package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -0
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +4 -0
- package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -0
- package/_types/actions/evm/transfer/transfer.d.ts +14 -0
- package/_types/actions/evm/transfer/transfer.d.ts.map +1 -0
- package/_types/actions/evm/transfer/types.d.ts +71 -0
- package/_types/actions/evm/transfer/types.d.ts.map +1 -0
- package/_types/actions/evm/transfer/utils.d.ts +631 -0
- package/_types/actions/evm/transfer/utils.d.ts.map +1 -0
- package/_types/actions/evm/types.d.ts +88 -0
- package/_types/actions/evm/types.d.ts.map +1 -0
- package/_types/client/evm/evm.d.ts +17 -1
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +10 -1
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/solana/solana.d.ts +17 -1
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/client/solana/solana.types.d.ts +8 -0
- package/_types/client/solana/solana.types.d.ts.map +1 -1
- package/_types/utils/serializeTransaction.d.ts +9 -0
- package/_types/utils/serializeTransaction.d.ts.map +1 -0
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmServerAccount.ts +12 -6
- package/accounts/evm/toEvmSmartAccount.ts +16 -4
- package/accounts/types.ts +20 -16
- package/actions/evm/transfer/accountTransferStrategy.ts +84 -0
- package/actions/evm/transfer/smartAccountTransferStrategy.ts +70 -0
- package/actions/evm/transfer/transfer.ts +71 -0
- package/actions/evm/transfer/types.ts +81 -0
- package/actions/evm/transfer/utils.ts +39 -0
- package/actions/evm/types.ts +88 -0
- package/client/evm/evm.ts +45 -2
- package/client/evm/evm.types.ts +11 -1
- package/client/solana/solana.ts +43 -0
- package/client/solana/solana.types.ts +9 -0
- package/package.json +1 -1
- package/utils/serializeTransaction.ts +17 -0
- package/version.ts +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeEIP1559Transaction = serializeEIP1559Transaction;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
/**
|
|
6
|
+
* Serializes a transaction for the Coinbase API.
|
|
7
|
+
*
|
|
8
|
+
* @param transaction - The transaction to serialize.
|
|
9
|
+
* @returns The serialized transaction.
|
|
10
|
+
*/
|
|
11
|
+
function serializeEIP1559Transaction(transaction) {
|
|
12
|
+
return (0, viem_1.serializeTransaction)({
|
|
13
|
+
...transaction,
|
|
14
|
+
chainId: 1, // ignored by Coinbase API
|
|
15
|
+
type: "eip1559",
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=serializeTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializeTransaction.js","sourceRoot":"","sources":["../../utils/serializeTransaction.ts"],"names":[],"mappings":";;AAUA,kEAMC;AAhBD,+BAA4C;AAI5C;;;;;GAKG;AACH,SAAgB,2BAA2B,CAAC,WAAsC;IAChF,OAAO,IAAA,2BAAoB,EAAC;QAC1B,GAAG,WAAW;QACd,OAAO,EAAE,CAAC,EAAE,0BAA0B;QACtC,IAAI,EAAE,SAAS;KAChB,CAAC,CAAC;AACL,CAAC"}
|
package/_cjs/version.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { serializeTransaction } from "viem";
|
|
2
|
+
import { accountTransferStrategy } from "../../actions/evm/transfer/accountTransferStrategy.js";
|
|
3
|
+
import { transfer } from "../../actions/evm/transfer/transfer.js";
|
|
2
4
|
/**
|
|
3
5
|
* Creates a Server-managed EvmAccount instance from an existing EvmAccount.
|
|
4
6
|
* Use this to interact with previously deployed EvmAccounts, rather than creating new ones.
|
|
@@ -32,6 +34,9 @@ export function toEvmServerAccount(apiClient, options) {
|
|
|
32
34
|
async signTypedData() {
|
|
33
35
|
throw new Error("Not implemented");
|
|
34
36
|
},
|
|
37
|
+
async transfer(transferArgs) {
|
|
38
|
+
return transfer(apiClient, account, transferArgs, accountTransferStrategy);
|
|
39
|
+
},
|
|
35
40
|
name: options.account.name,
|
|
36
41
|
type: "evm-server",
|
|
37
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toEvmServerAccount.js","sourceRoot":"","sources":["../../../accounts/evm/toEvmServerAccount.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"toEvmServerAccount.js","sourceRoot":"","sources":["../../../accounts/evm/toEvmServerAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAEpF,OAAO,EAAE,uBAAuB,EAAE,MAAM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nB,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
+
import { smartAccountTransferStrategy } from "../../actions/evm/transfer/smartAccountTransferStrategy.js";
|
|
2
|
+
import { transfer } from "../../actions/evm/transfer/transfer.js";
|
|
1
3
|
/**
|
|
2
4
|
* Creates a EvmSmartAccount instance from an existing EvmSmartAccount and owner.
|
|
3
5
|
* Use this to interact with previously deployed EvmSmartAccounts, rather than creating new ones.
|
|
4
6
|
*
|
|
5
7
|
* The owner must be the original owner of the evm smart account.
|
|
6
8
|
*
|
|
9
|
+
* @param {CdpOpenApiClientType} apiClient - The API client.
|
|
7
10
|
* @param {ToEvmSmartAccountOptions} options - Configuration options.
|
|
8
11
|
* @param {EvmSmartAccount} options.smartAccount - The deployed evm smart account.
|
|
9
12
|
* @param {EvmAccount} options.owner - The owner which signs for the smart account.
|
|
10
13
|
* @returns {EvmSmartAccount} A configured EvmSmartAccount instance ready for user operation submission.
|
|
11
|
-
* @throws {Error} If the account is not an original owner of the smart account.
|
|
12
14
|
*/
|
|
13
|
-
export function toEvmSmartAccount(options) {
|
|
15
|
+
export function toEvmSmartAccount(apiClient, options) {
|
|
14
16
|
const account = {
|
|
15
17
|
address: options.smartAccount.address,
|
|
16
18
|
owners: [options.owner],
|
|
19
|
+
async transfer(transferArgs) {
|
|
20
|
+
return transfer(apiClient, account, transferArgs, smartAccountTransferStrategy);
|
|
21
|
+
},
|
|
17
22
|
name: options.smartAccount.name,
|
|
18
23
|
type: "evm-smart",
|
|
19
24
|
};
|
|
@@ -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":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,4DAA4D,CAAC;AAC1G,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAoBlE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,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,QAAQ,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,4BAA4B,CAAC,CAAC;QAClF,CAAC;QACD,IAAI,EAAE,OAAO,CAAC,YAAY,CAAC,IAAI;QAC/B,IAAI,EAAE,WAAW;KAClB,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { encodeFunctionData, erc20Abi, WaitForTransactionReceiptTimeoutError, } from "viem";
|
|
2
|
+
import { getErc20Address } from "./utils.js";
|
|
3
|
+
import { serializeEIP1559Transaction } from "../../../utils/serializeTransaction.js";
|
|
4
|
+
export const accountTransferStrategy = {
|
|
5
|
+
executeTransfer: async ({ apiClient, from, transferArgs, to, value }) => {
|
|
6
|
+
const transactionHash = await (async () => {
|
|
7
|
+
if (transferArgs.token === "eth") {
|
|
8
|
+
const result = await apiClient.sendEvmTransaction(from.address, {
|
|
9
|
+
transaction: serializeEIP1559Transaction({
|
|
10
|
+
value,
|
|
11
|
+
to,
|
|
12
|
+
}),
|
|
13
|
+
network: transferArgs.network,
|
|
14
|
+
});
|
|
15
|
+
return result.transactionHash;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const erc20Address = getErc20Address(transferArgs.token, transferArgs.network);
|
|
19
|
+
await apiClient.sendEvmTransaction(from.address, {
|
|
20
|
+
transaction: serializeEIP1559Transaction({
|
|
21
|
+
to: erc20Address,
|
|
22
|
+
data: encodeFunctionData({
|
|
23
|
+
abi: erc20Abi,
|
|
24
|
+
functionName: "approve",
|
|
25
|
+
args: [to, value],
|
|
26
|
+
}),
|
|
27
|
+
}),
|
|
28
|
+
network: transferArgs.network,
|
|
29
|
+
});
|
|
30
|
+
const result = await apiClient.sendEvmTransaction(from.address, {
|
|
31
|
+
transaction: serializeEIP1559Transaction({
|
|
32
|
+
to: erc20Address,
|
|
33
|
+
data: encodeFunctionData({
|
|
34
|
+
abi: erc20Abi,
|
|
35
|
+
functionName: "transfer",
|
|
36
|
+
args: [to, value],
|
|
37
|
+
}),
|
|
38
|
+
}),
|
|
39
|
+
network: transferArgs.network,
|
|
40
|
+
});
|
|
41
|
+
return result.transactionHash;
|
|
42
|
+
}
|
|
43
|
+
})();
|
|
44
|
+
return transactionHash;
|
|
45
|
+
},
|
|
46
|
+
waitForResult: async ({ publicClient, hash }) => {
|
|
47
|
+
let receipt;
|
|
48
|
+
try {
|
|
49
|
+
receipt = await publicClient.waitForTransactionReceipt({
|
|
50
|
+
hash,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (error instanceof WaitForTransactionReceiptTimeoutError) {
|
|
55
|
+
throw new Error(`Transaction timed out. Check the transaction on the explorer: ${publicClient.chain.blockExplorers?.default.url}/tx/${hash}`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (receipt.status === "success") {
|
|
62
|
+
return { status: receipt.status, transactionHash: hash };
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
throw new Error(`Transaction failed. Check the transaction on the explorer: ${publicClient.chain.blockExplorers?.default.url}/tx/${hash}`);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=accountTransferStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountTransferStrategy.js","sourceRoot":"","sources":["../../../../actions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1,62 @@
|
|
|
1
|
+
import { encodeFunctionData, erc20Abi } from "viem";
|
|
2
|
+
import { getErc20Address } from "./utils.js";
|
|
3
|
+
import { sendUserOperation } from "../sendUserOperation.js";
|
|
4
|
+
import { waitForUserOperation } from "../waitForUserOperation.js";
|
|
5
|
+
export const smartAccountTransferStrategy = {
|
|
6
|
+
executeTransfer: async ({ apiClient, from, transferArgs, to, value }) => {
|
|
7
|
+
const userOpHash = await (async () => {
|
|
8
|
+
if (transferArgs.token === "eth") {
|
|
9
|
+
const result = await sendUserOperation(apiClient, from, {
|
|
10
|
+
network: transferArgs.network,
|
|
11
|
+
calls: [
|
|
12
|
+
{
|
|
13
|
+
to,
|
|
14
|
+
value,
|
|
15
|
+
data: "0x",
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
});
|
|
19
|
+
return result.userOpHash;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const erc20Address = getErc20Address(transferArgs.token, transferArgs.network);
|
|
23
|
+
const result = await sendUserOperation(apiClient, from, {
|
|
24
|
+
network: transferArgs.network,
|
|
25
|
+
calls: [
|
|
26
|
+
{
|
|
27
|
+
to: erc20Address,
|
|
28
|
+
data: encodeFunctionData({
|
|
29
|
+
abi: erc20Abi,
|
|
30
|
+
functionName: "approve",
|
|
31
|
+
args: [to, value],
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
to: erc20Address,
|
|
36
|
+
data: encodeFunctionData({
|
|
37
|
+
abi: erc20Abi,
|
|
38
|
+
functionName: "transfer",
|
|
39
|
+
args: [to, value],
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
return result.userOpHash;
|
|
45
|
+
}
|
|
46
|
+
})();
|
|
47
|
+
return userOpHash;
|
|
48
|
+
},
|
|
49
|
+
waitForResult: async ({ apiClient, publicClient, from, hash }) => {
|
|
50
|
+
const result = await waitForUserOperation(apiClient, {
|
|
51
|
+
smartAccountAddress: from.address,
|
|
52
|
+
userOpHash: hash,
|
|
53
|
+
});
|
|
54
|
+
if (result.status === "complete") {
|
|
55
|
+
return { status: "success", transactionHash: hash };
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
throw new Error(`Transaction failed. Check the transaction on the explorer: ${publicClient.chain.blockExplorers?.default.url}/tx/${hash}`);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=smartAccountTransferStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smartAccountTransferStrategy.js","sourceRoot":"","sources":["../../../../actions/evm/transfer/smartAccountTransferStrategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,MAAM,CAAC,MAAM,4BAA4B,GAA+C;IACtF,eAAe,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QACtE,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE;YACnC,IAAI,YAAY,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;gBACjC,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,SAAS,EAAE,IAAI,EAAE;oBACtD,OAAO,EAAE,YAAY,CAAC,OAAO;oBAC7B,KAAK,EAAE;wBACL;4BACE,EAAE;4BACF,KAAK;4BACL,IAAI,EAAE,IAAI;yBACX;qBACF;iBACF,CAAC,CAAC;gBACH,OAAO,MAAM,CAAC,UAAU,CAAC;YAC3B,CAAC;iBAAM,CAAC;gBACN,MAAM,YAAY,GAAG,eAAe,CAA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|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createPublicClient, http, erc20Abi, parseUnits } from "viem";
|
|
2
|
+
import { mapNetworkToChain } from "./utils.js";
|
|
3
|
+
/**
|
|
4
|
+
* Transfer an amount of a token from an account to another account.
|
|
5
|
+
*
|
|
6
|
+
* @param apiClient - The client to use to send the transaction.
|
|
7
|
+
* @param from - The account to send the transaction from.
|
|
8
|
+
* @param transferArgs - The options for the transfer.
|
|
9
|
+
* @param transferStrategy - The strategy to use to execute the transfer.
|
|
10
|
+
* @returns The result of the transfer.
|
|
11
|
+
*/
|
|
12
|
+
export async function transfer(apiClient, from, transferArgs, transferStrategy) {
|
|
13
|
+
const publicClient = createPublicClient({
|
|
14
|
+
chain: mapNetworkToChain(transferArgs.network),
|
|
15
|
+
transport: http(),
|
|
16
|
+
});
|
|
17
|
+
const to = typeof transferArgs.to === "string" ? transferArgs.to : transferArgs.to.address;
|
|
18
|
+
const value = await (async () => {
|
|
19
|
+
// user supplied a bigint. otherwise, we need to convert the amount to a bigint
|
|
20
|
+
if (typeof transferArgs.amount !== "string") {
|
|
21
|
+
return transferArgs.amount;
|
|
22
|
+
}
|
|
23
|
+
const decimals = await (async () => {
|
|
24
|
+
if (transferArgs.token === "eth") {
|
|
25
|
+
return 18;
|
|
26
|
+
}
|
|
27
|
+
else if (transferArgs.token === "usdc") {
|
|
28
|
+
return 6;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return publicClient.readContract({
|
|
32
|
+
address: transferArgs.token,
|
|
33
|
+
abi: erc20Abi,
|
|
34
|
+
functionName: "decimals",
|
|
35
|
+
args: [],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
})();
|
|
39
|
+
return parseUnits(transferArgs.amount, decimals);
|
|
40
|
+
})();
|
|
41
|
+
const hash = await transferStrategy.executeTransfer({
|
|
42
|
+
apiClient,
|
|
43
|
+
from,
|
|
44
|
+
transferArgs,
|
|
45
|
+
to,
|
|
46
|
+
value,
|
|
47
|
+
});
|
|
48
|
+
const result = await transferStrategy.waitForResult({
|
|
49
|
+
apiClient,
|
|
50
|
+
publicClient,
|
|
51
|
+
from,
|
|
52
|
+
hash,
|
|
53
|
+
});
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=transfer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer.js","sourceRoot":"","sources":["../../../../actions/evm/transfer/transfer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAA6B,MAAM,MAAM,CAAC;AAGjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAI/C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,SAA+B,EAC/B,IAAO,EACP,YAA6B,EAC7B,gBAA8C;IAE9C,MAAM,YAAY,GAAG,kBAAkB,CAAmB;QACxD,KAAK,EAAE,iBAAiB,CAAC,YAAY,CAAC,OAAO,CAAC;QAC9C,SAAS,EAAE,IAAI,EAAE;KAClB,CAAC,CAAC;IAEH,MAAM,EAAE,GACN,OAAO,YAAY,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAE,YAAY,CAAC,EAAE,CAAC,OAAmB,CAAC;IAE/F,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE;QAC9B,+EAA+E;QAC/E,IAAI,OAAO,YAAY,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC5C,OAAO,YAAY,CAAC,MAAM,CAAC;QAC7B,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE;YACjC,IAAI,YAAY,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;gBACjC,OAAO,EAAE,CAAC;YACZ,CAAC;iBAAM,IAAI,YAAY,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;gBACzC,OAAO,CAAC,CAAC;YACX,CAAC;iBAAM,CAAC;gBACN,OAAO,YAAY,CAAC,YAAY,CAAC;oBAC/B,OAAO,EAAE,YAAY,CAAC,KAAK;oBAC3B,GAAG,EAAE,QAAQ;oBACb,YAAY,EAAE,UAAU;oBACxB,IAAI,EAAE,EAAE;iBACT,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;QAEL,OAAO,UAAU,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnD,CAAC,CAAC,EAAE,CAAC;IAEL,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,eAAe,CAAC;QAClD,SAAS;QACT,IAAI;QACJ,YAAY;QACZ,EAAE;QACF,KAAK;KACN,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,aAAa,CAAC;QAClD,SAAS;QACT,YAAY;QACZ,IAAI;QACJ,IAAI;KACL,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../actions/evm/transfer/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { base, baseSepolia } from "viem/chains";
|
|
2
|
+
/**
|
|
3
|
+
* The address of an ERC20 token for a given network.
|
|
4
|
+
*/
|
|
5
|
+
const addressMap = {
|
|
6
|
+
base: {
|
|
7
|
+
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
8
|
+
},
|
|
9
|
+
"base-sepolia": {
|
|
10
|
+
usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Get the address of an ERC20 token for a given network.
|
|
15
|
+
* If a contract address is provided, it will not be found in the map and will be returned as is.
|
|
16
|
+
*
|
|
17
|
+
* @param token - The token symbol or contract address.
|
|
18
|
+
* @param network - The network to get the address for.
|
|
19
|
+
*
|
|
20
|
+
* @returns The address of the ERC20 token.
|
|
21
|
+
*/
|
|
22
|
+
export function getErc20Address(token, network) {
|
|
23
|
+
return addressMap[network][token] ?? token;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Map a network to a viem chain.
|
|
27
|
+
* TODO: Add more networks (or dynamically map viem chains).
|
|
28
|
+
*
|
|
29
|
+
* @param network - The network to map to a chain.
|
|
30
|
+
* @returns The chain for the given network.
|
|
31
|
+
*/
|
|
32
|
+
export function mapNetworkToChain(network) {
|
|
33
|
+
return network === "base" ? base : baseSepolia;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../actions/evm/transfer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAIhD;;GAEG;AACH,MAAM,UAAU,GAAG;IACjB,IAAI,EAAE;QACJ,IAAI,EAAE,4CAA4C;KACnD;IACD,cAAc,EAAE;QACd,IAAI,EAAE,4CAA4C;KACnD;CACF,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,OAAgB;IAC7D,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../actions/evm/types.ts"],"names":[],"mappings":""}
|
package/_esm/client/evm/evm.js
CHANGED
|
@@ -3,6 +3,7 @@ import { toEvmServerAccount } from "../../accounts/evm/toEvmServerAccount.js";
|
|
|
3
3
|
import { toEvmSmartAccount } from "../../accounts/evm/toEvmSmartAccount.js";
|
|
4
4
|
import { sendUserOperation, } from "../../actions/evm/sendUserOperation.js";
|
|
5
5
|
import { waitForUserOperation, } from "../../actions/evm/waitForUserOperation.js";
|
|
6
|
+
import { APIError } from "../../openapi-client/errors.js";
|
|
6
7
|
import { CdpOpenApiClient } from "../../openapi-client/index.js";
|
|
7
8
|
/**
|
|
8
9
|
* The namespace containing all EVM methods.
|
|
@@ -99,7 +100,7 @@ export class EvmClient {
|
|
|
99
100
|
const smartAccount = await CdpOpenApiClient.createEvmSmartAccount({
|
|
100
101
|
owners: [options.owner.address],
|
|
101
102
|
}, options.idempotencyKey);
|
|
102
|
-
return toEvmSmartAccount({
|
|
103
|
+
return toEvmSmartAccount(CdpOpenApiClient, {
|
|
103
104
|
smartAccount,
|
|
104
105
|
owner: options.owner,
|
|
105
106
|
});
|
|
@@ -164,11 +165,52 @@ export class EvmClient {
|
|
|
164
165
|
*/
|
|
165
166
|
async getSmartAccount(options) {
|
|
166
167
|
const smartAccount = await CdpOpenApiClient.getEvmSmartAccount(options.address);
|
|
167
|
-
return toEvmSmartAccount({
|
|
168
|
+
return toEvmSmartAccount(CdpOpenApiClient, {
|
|
168
169
|
smartAccount,
|
|
169
170
|
owner: options.owner,
|
|
170
171
|
});
|
|
171
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Gets a CDP EVM account, or creates one if it doesn't exist.
|
|
175
|
+
*
|
|
176
|
+
* @param {GetOrCreateServerAccountOptions} options - Parameters for getting or creating the account.
|
|
177
|
+
* @param {string} [options.name] - The name of the account to get or create.
|
|
178
|
+
*
|
|
179
|
+
* @returns A promise that resolves to the account.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* const account = await cdp.evm.getOrCreateAccount({
|
|
184
|
+
* name: "MyAccount",
|
|
185
|
+
* });
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
async getOrCreateAccount(options) {
|
|
189
|
+
try {
|
|
190
|
+
const account = await this.getAccount(options);
|
|
191
|
+
return account;
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
// If it failed because the account doesn't exist, create it
|
|
195
|
+
const doesAccountNotExist = error instanceof APIError && error.statusCode === 404;
|
|
196
|
+
if (doesAccountNotExist) {
|
|
197
|
+
try {
|
|
198
|
+
const account = await this.createAccount(options);
|
|
199
|
+
return account;
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
// If it failed because the account already exists, throw an error
|
|
203
|
+
const doesAccountAlreadyExist = error instanceof APIError && error.statusCode === 409;
|
|
204
|
+
if (doesAccountAlreadyExist) {
|
|
205
|
+
const account = await this.getAccount(options);
|
|
206
|
+
return account;
|
|
207
|
+
}
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
172
214
|
/**
|
|
173
215
|
* Gets a user operation for a smart account by user operation hash.
|
|
174
216
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm.js","sourceRoot":"","sources":["../../../client/evm/evm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,oBAAoB,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"evm.js","sourceRoot":"","sources":["../../../client/evm/evm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,oBAAoB,EAAE,MAAM,MAAM,CAAC;AA+BrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EACL,iBAAiB,GAElB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,oBAAoB,GAErB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,QAAQ,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ACH,KAAK,CAAC,WAAW,CAAC,OAA2B;QAC3C,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,cAAc,CACrD,OAAO,CAAC,OAAO,EACf;YACE,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,EACD,OAAO,CAAC,cAAc,CACvB,CAAC;QAEF,OAAO;YACL,SAAS,EAAE,SAAS,CAAC,SAAgB;SACtC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,KAAK,CAAC,eAAe,CAAC,OAA+B;QACnD,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,kBAAkB,CACzD,OAAO,CAAC,OAAO,EACf;YACE,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,EACD,OAAO,CAAC,cAAc,CACvB,CAAC;QAEF,OAAO;YACL,SAAS,EAAE,SAAS,CAAC,iBAAwB;SAC9C,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,KAAK,CAAC,oBAAoB,CACxB,OAAoC;QAEpC,OAAO,oBAAoB,CAAC,gBAAgB,EAAE;YAC5C,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { APIError } from "../../openapi-client/errors.js";
|
|
1
2
|
import { CdpOpenApiClient } from "../../openapi-client/index.js";
|
|
2
3
|
/**
|
|
3
4
|
* The namespace containing all Solana methods.
|
|
@@ -70,6 +71,47 @@ export class SolanaClient {
|
|
|
70
71
|
}
|
|
71
72
|
throw new Error("Either address or name must be provided");
|
|
72
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Gets a Solana account by its address.
|
|
76
|
+
*
|
|
77
|
+
* @param {GetOrCreateAccountOptions} options - Parameters for getting or creating the Solana account.
|
|
78
|
+
* @param {string} options.name - The name of the account.
|
|
79
|
+
*
|
|
80
|
+
* @returns A promise that resolves to the account.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const account = await cdp.solana.getOrCreateAccount({
|
|
85
|
+
* name: "MyAccount",
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
async getOrCreateAccount(options) {
|
|
90
|
+
try {
|
|
91
|
+
const account = await this.getAccount(options);
|
|
92
|
+
return account;
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
// If it failed because the account doesn't exist, create it
|
|
96
|
+
const doesAccountNotExist = error instanceof APIError && error.statusCode === 404;
|
|
97
|
+
if (doesAccountNotExist) {
|
|
98
|
+
try {
|
|
99
|
+
const account = await this.createAccount(options);
|
|
100
|
+
return account;
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
// If it failed because the account already exists, throw an error
|
|
104
|
+
const doesAccountAlreadyExist = error instanceof APIError && error.statusCode === 409;
|
|
105
|
+
if (doesAccountAlreadyExist) {
|
|
106
|
+
const account = await this.getAccount(options);
|
|
107
|
+
return account;
|
|
108
|
+
}
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
73
115
|
/**
|
|
74
116
|
* Lists all Solana accounts.
|
|
75
117
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana.js","sourceRoot":"","sources":["../../../client/solana/solana.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"solana.js","sourceRoot":"","sources":["../../../client/solana/solana.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE;;GAEG;AACH,MAAM,OAAO,YAAY;IACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,KAAK,CAAC,aAAa,CAAC,UAAgC,EAAE;QACpD,OAAO,gBAA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AC;QAEF,OAAO;YACL,SAAS,EAAE,SAAS,CAAC,iBAAiB;SACvC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { serializeTransaction } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Serializes a transaction for the Coinbase API.
|
|
4
|
+
*
|
|
5
|
+
* @param transaction - The transaction to serialize.
|
|
6
|
+
* @returns The serialized transaction.
|
|
7
|
+
*/
|
|
8
|
+
export function serializeEIP1559Transaction(transaction) {
|
|
9
|
+
return serializeTransaction({
|
|
10
|
+
...transaction,
|
|
11
|
+
chainId: 1, // ignored by Coinbase API
|
|
12
|
+
type: "eip1559",
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=serializeTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializeTransaction.js","sourceRoot":"","sources":["../../utils/serializeTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAI5C;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,WAAsC;IAChF,OAAO,oBAAoB,CAAC;QAC1B,GAAG,WAAW;QACd,OAAO,EAAE,CAAC,EAAE,0BAA0B;QACtC,IAAI,EAAE,SAAS;KAChB,CAAC,CAAC;AACL,CAAC"}
|
package/_esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = "1.
|
|
1
|
+
export const version = "1.5.0";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CdpOpenApiClientType, EvmAccount } from "../../openapi-client/index.js";
|
|
2
|
-
import { EvmServerAccount } from "../types.js";
|
|
1
|
+
import type { CdpOpenApiClientType, EvmAccount } from "../../openapi-client/index.js";
|
|
2
|
+
import type { EvmServerAccount } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Options for converting a pre-existing EvmAccount to a EvmServerAccount.
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toEvmServerAccount.d.ts","sourceRoot":"","sources":["../../../accounts/evm/toEvmServerAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"toEvmServerAccount.d.ts","sourceRoot":"","sources":["../../../accounts/evm/toEvmServerAccount.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,kDAAkD;IAClD,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,oBAAoB,EAC/B,OAAO,EAAE,yBAAyB,GACjC,gBAAgB,CAmClB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EvmSmartAccount as EvmSmartAccountModel } from "../../openapi-client/index.js";
|
|
2
|
-
import { EvmAccount, EvmSmartAccount } from "../types.js";
|
|
1
|
+
import type { CdpOpenApiClientType, EvmSmartAccount as EvmSmartAccountModel } from "../../openapi-client/index.js";
|
|
2
|
+
import type { EvmAccount, EvmSmartAccount } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Options for converting a pre-existing EvmSmartAccount and owner to a EvmSmartAccount
|
|
5
5
|
*/
|
|
@@ -15,11 +15,11 @@ export type ToEvmSmartAccountOptions = {
|
|
|
15
15
|
*
|
|
16
16
|
* The owner must be the original owner of the evm smart account.
|
|
17
17
|
*
|
|
18
|
+
* @param {CdpOpenApiClientType} apiClient - The API client.
|
|
18
19
|
* @param {ToEvmSmartAccountOptions} options - Configuration options.
|
|
19
20
|
* @param {EvmSmartAccount} options.smartAccount - The deployed evm smart account.
|
|
20
21
|
* @param {EvmAccount} options.owner - The owner which signs for the smart account.
|
|
21
22
|
* @returns {EvmSmartAccount} A configured EvmSmartAccount instance ready for user operation submission.
|
|
22
|
-
* @throws {Error} If the account is not an original owner of the smart account.
|
|
23
23
|
*/
|
|
24
|
-
export declare function toEvmSmartAccount(options: ToEvmSmartAccountOptions): EvmSmartAccount;
|
|
24
|
+
export declare function toEvmSmartAccount(apiClient: CdpOpenApiClientType, options: ToEvmSmartAccountOptions): EvmSmartAccount;
|
|
25
25
|
//# sourceMappingURL=toEvmSmartAccount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toEvmSmartAccount.d.ts","sourceRoot":"","sources":["../../../accounts/evm/toEvmSmartAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"toEvmSmartAccount.d.ts","sourceRoot":"","sources":["../../../accounts/evm/toEvmSmartAccount.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,IAAI,oBAAoB,EACxC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,wCAAwC;IACxC,YAAY,EAAE,oBAAoB,CAAC;IACnC,sCAAsC;IACtC,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,oBAAoB,EAC/B,OAAO,EAAE,wBAAwB,GAChC,eAAe,CAYjB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SignableMessage, TransactionSerializable, TypedData, TypedDataDefinition } from "viem";
|
|
2
|
+
import { Actions } from "../actions/evm/types.js";
|
|
2
3
|
import { Prettify } from "../types/utils.js";
|
|
3
4
|
import type { Hash, Hex, Address } from "../types/misc.js";
|
|
4
5
|
/**
|
|
@@ -24,7 +25,7 @@ export type EvmAccount = {
|
|
|
24
25
|
/**
|
|
25
26
|
* Server-managed ethereum account
|
|
26
27
|
*/
|
|
27
|
-
export type EvmServerAccount = Prettify<EvmAccount & {
|
|
28
|
+
export type EvmServerAccount = Prettify<EvmAccount & Actions & {
|
|
28
29
|
/** Optional name for the server account. */
|
|
29
30
|
name?: string;
|
|
30
31
|
/** Indicates this is a server-managed account. */
|
|
@@ -33,7 +34,7 @@ export type EvmServerAccount = Prettify<EvmAccount & {
|
|
|
33
34
|
/**
|
|
34
35
|
* Ethereum smart account which supports account abstraction features like user operations, batch transactions, and paymaster.
|
|
35
36
|
*/
|
|
36
|
-
export type EvmSmartAccount = {
|
|
37
|
+
export type EvmSmartAccount = Prettify<{
|
|
37
38
|
/** The smart account's address. */
|
|
38
39
|
address: Address;
|
|
39
40
|
/** The name of the smart account. */
|
|
@@ -42,5 +43,5 @@ export type EvmSmartAccount = {
|
|
|
42
43
|
owners: EvmAccount[];
|
|
43
44
|
/** Identifier for the smart account type. */
|
|
44
45
|
type: "evm-smart";
|
|
45
|
-
}
|
|
46
|
+
} & Actions>;
|
|
46
47
|
//# sourceMappingURL=types.d.ts.map
|