@coinbase/cdp-sdk 1.33.0 → 1.34.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 +6 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js +1 -1
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js +2 -2
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js +2 -2
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_cjs/actions/evm/listSpendPermissions.js +19 -1
- package/_cjs/actions/evm/listSpendPermissions.js.map +1 -1
- package/_cjs/actions/evm/spend-permissions/resolveSpendPermission.js +64 -0
- package/_cjs/actions/evm/spend-permissions/resolveSpendPermission.js.map +1 -0
- package/_cjs/client/evm/evm.js +12 -11
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +45 -2
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +79 -20
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.js +1 -2
- package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +1 -0
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/onchain-data/onchain-data.js +63 -0
- package/_cjs/openapi-client/generated/onchain-data/onchain-data.js.map +1 -0
- package/_cjs/openapi-client/generated/onchain-data/onchain-data.msw.js +139 -0
- package/_cjs/openapi-client/generated/onchain-data/onchain-data.msw.js.map +1 -0
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +48 -4
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
- package/_cjs/openapi-client/index.js +1 -0
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/spend-permissions/utils.js +26 -0
- package/_cjs/spend-permissions/utils.js.map +1 -0
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js +2 -2
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +2 -2
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_esm/actions/evm/listSpendPermissions.js +19 -1
- package/_esm/actions/evm/listSpendPermissions.js.map +1 -1
- package/_esm/actions/evm/spend-permissions/resolveSpendPermission.js +61 -0
- package/_esm/actions/evm/spend-permissions/resolveSpendPermission.js.map +1 -0
- package/_esm/client/evm/evm.js +13 -12
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +43 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +79 -20
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
- package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.js +1 -2
- package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -1
- package/_esm/openapi-client/generated/index.msw.js +1 -0
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/generated/onchain-data/onchain-data.js +57 -0
- package/_esm/openapi-client/generated/onchain-data/onchain-data.js.map +1 -0
- package/_esm/openapi-client/generated/onchain-data/onchain-data.msw.js +129 -0
- package/_esm/openapi-client/generated/onchain-data/onchain-data.msw.js.map +1 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +48 -4
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
- package/_esm/openapi-client/index.js +1 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/spend-permissions/utils.js +23 -0
- package/_esm/spend-permissions/utils.js.map +1 -0
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/types.d.ts +5 -5
- package/_types/accounts/evm/types.d.ts.map +1 -1
- package/_types/actions/evm/listSpendPermissions.d.ts +10 -2
- package/_types/actions/evm/listSpendPermissions.d.ts.map +1 -1
- package/_types/actions/evm/spend-permissions/resolveSpendPermission.d.ts +12 -0
- package/_types/actions/evm/spend-permissions/resolveSpendPermission.d.ts.map +1 -0
- package/_types/actions/evm/spend-permissions/types.d.ts +3 -2
- package/_types/actions/evm/spend-permissions/types.d.ts.map +1 -1
- package/_types/actions/evm/types.d.ts +4 -8
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/client/evm/evm.d.ts +3 -2
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +7 -44
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/index.d.ts +2 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +167 -20
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts +1 -2
- package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts.map +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts +1 -0
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/onchain-data/onchain-data.d.ts +59 -0
- package/_types/openapi-client/generated/onchain-data/onchain-data.d.ts.map +1 -0
- package/_types/openapi-client/generated/onchain-data/onchain-data.msw.d.ts +10 -0
- package/_types/openapi-client/generated/onchain-data/onchain-data.msw.d.ts.map +1 -0
- package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts +1 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/spend-permissions/types.d.ts +40 -5
- package/_types/spend-permissions/types.d.ts.map +1 -1
- package/_types/spend-permissions/utils.d.ts +12 -0
- package/_types/spend-permissions/utils.d.ts.map +1 -0
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmServerAccount.ts +1 -3
- package/accounts/evm/toEvmSmartAccount.ts +1 -1
- package/accounts/evm/toNetworkScopedEvmServerAccount.ts +4 -4
- package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +4 -4
- package/accounts/evm/types.ts +5 -5
- package/actions/evm/listSpendPermissions.ts +42 -3
- package/actions/evm/spend-permissions/resolveSpendPermission.ts +85 -0
- package/actions/evm/spend-permissions/types.ts +3 -2
- package/actions/evm/types.ts +4 -12
- package/client/evm/evm.ts +25 -16
- package/client/evm/evm.types.ts +6 -48
- package/index.ts +2 -1
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +185 -20
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +79 -20
- package/openapi-client/generated/evm-token-balances/evm-token-balances.ts +1 -2
- package/openapi-client/generated/index.msw.ts +1 -0
- package/openapi-client/generated/onchain-data/onchain-data.msw.ts +185 -0
- package/openapi-client/generated/onchain-data/onchain-data.ts +103 -0
- package/openapi-client/generated/policy-engine/policy-engine.msw.ts +48 -4
- package/openapi-client/index.ts +1 -0
- package/package.json +1 -1
- package/spend-permissions/types.ts +46 -16
- package/spend-permissions/utils.ts +35 -0
- package/version.ts +1 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import type {
|
|
9
|
+
AccountTokenAddressesResponse,
|
|
10
|
+
ListDataTokenBalances200,
|
|
11
|
+
ListDataTokenBalancesParams,
|
|
12
|
+
ListEvmTokenBalancesNetwork,
|
|
13
|
+
OnchainDataQuery,
|
|
14
|
+
OnchainDataResult,
|
|
15
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
16
|
+
|
|
17
|
+
import { cdpApiClient } from "../../cdpApiClient.js";
|
|
18
|
+
|
|
19
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Run a read-only SQL query against indexed blockchain data including transactions, events, and decoded logs.
|
|
23
|
+
|
|
24
|
+
This endpoint provides direct SQL access to comprehensive blockchain data across supported networks.
|
|
25
|
+
Queries are executed against optimized data structures for high-performance analytics.
|
|
26
|
+
|
|
27
|
+
### Allowed Queries
|
|
28
|
+
|
|
29
|
+
- Standard SQL syntax (ClickHouse dialect)
|
|
30
|
+
- Read-only queries (SELECT statements)
|
|
31
|
+
- No DDL or DML operations
|
|
32
|
+
- No cartesian products
|
|
33
|
+
|
|
34
|
+
### Supported Tables
|
|
35
|
+
|
|
36
|
+
- `base.events` - Base mainnet decoded event logs with parameters, event signature, topics, and more.
|
|
37
|
+
- `base.transactions` - Base mainnet transaction data including hash, block number, gas usage.
|
|
38
|
+
- `base.blocks` - Base mainnet block information.
|
|
39
|
+
- `base.encoded_logs` - Encoded log data of event logs that aren't able to be decoded by our event decoder (ex: log0 opcode).
|
|
40
|
+
- `base.transfers` - All event logs with event signature `Transfer(address,address,uint256)`. ERC-20, ERC-721, and ERC-1155 transfers are all included.
|
|
41
|
+
|
|
42
|
+
### Query Limits
|
|
43
|
+
|
|
44
|
+
- Maximum result set: 10,000 rows
|
|
45
|
+
- Query timeout: 30 seconds
|
|
46
|
+
- Maximum JOINs: 5
|
|
47
|
+
|
|
48
|
+
* @summary Run SQL Query
|
|
49
|
+
*/
|
|
50
|
+
export const runSQLQuery = (
|
|
51
|
+
onchainDataQuery: OnchainDataQuery,
|
|
52
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
53
|
+
) => {
|
|
54
|
+
return cdpApiClient<OnchainDataResult>(
|
|
55
|
+
{
|
|
56
|
+
url: `/v2/data/query/run`,
|
|
57
|
+
method: "POST",
|
|
58
|
+
headers: { "Content-Type": "application/json" },
|
|
59
|
+
data: onchainDataQuery,
|
|
60
|
+
},
|
|
61
|
+
options,
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Retrieve all ERC-20 token contract addresses that an account has ever received tokens from.
|
|
66
|
+
Analyzes transaction history to discover token interactions.
|
|
67
|
+
|
|
68
|
+
* @summary List token addresses for account
|
|
69
|
+
*/
|
|
70
|
+
export const listTokensForAccount = (
|
|
71
|
+
network: "base" | "base-sepolia",
|
|
72
|
+
address: string,
|
|
73
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
74
|
+
) => {
|
|
75
|
+
return cdpApiClient<AccountTokenAddressesResponse>(
|
|
76
|
+
{ url: `/v2/data/evm/token-ownership/${network}/${address}`, method: "GET" },
|
|
77
|
+
options,
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Lists the token balances of an EVM address on a given network. The balances include ERC-20 tokens and the native gas token (usually ETH). The response is paginated, and by default, returns 20 balances per page.
|
|
82
|
+
|
|
83
|
+
**Note:** This endpoint provides <1 second freshness from chain tip, <500ms response latency for wallets with reasonable token history, and 99.9% uptime for production use.
|
|
84
|
+
* @summary List EVM token balances
|
|
85
|
+
*/
|
|
86
|
+
export const listDataTokenBalances = (
|
|
87
|
+
network: ListEvmTokenBalancesNetwork,
|
|
88
|
+
address: string,
|
|
89
|
+
params?: ListDataTokenBalancesParams,
|
|
90
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
91
|
+
) => {
|
|
92
|
+
return cdpApiClient<ListDataTokenBalances200>(
|
|
93
|
+
{ url: `/v2/data/evm/token-balances/${network}/${address}`, method: "GET", params },
|
|
94
|
+
options,
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
export type RunSQLQueryResult = NonNullable<Awaited<ReturnType<typeof runSQLQuery>>>;
|
|
98
|
+
export type ListTokensForAccountResult = NonNullable<
|
|
99
|
+
Awaited<ReturnType<typeof listTokensForAccount>>
|
|
100
|
+
>;
|
|
101
|
+
export type ListDataTokenBalancesResult = NonNullable<
|
|
102
|
+
Awaited<ReturnType<typeof listDataTokenBalances>>
|
|
103
|
+
>;
|
|
@@ -180,7 +180,18 @@ export const getListPoliciesResponseEvmNetworkCriterionMock = (
|
|
|
180
180
|
): EvmNetworkCriterion => ({
|
|
181
181
|
...{
|
|
182
182
|
type: faker.helpers.arrayElement(["evmNetwork"] as const),
|
|
183
|
-
networks: faker.helpers.arrayElements([
|
|
183
|
+
networks: faker.helpers.arrayElements([
|
|
184
|
+
"base-sepolia",
|
|
185
|
+
"base",
|
|
186
|
+
"ethereum",
|
|
187
|
+
"ethereum-sepolia",
|
|
188
|
+
"avalanche",
|
|
189
|
+
"polygon",
|
|
190
|
+
"optimism",
|
|
191
|
+
"arbitrum",
|
|
192
|
+
"zora",
|
|
193
|
+
"bnb",
|
|
194
|
+
] as const),
|
|
184
195
|
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
185
196
|
},
|
|
186
197
|
...overrideResponse,
|
|
@@ -618,7 +629,18 @@ export const getCreatePolicyResponseEvmNetworkCriterionMock = (
|
|
|
618
629
|
): EvmNetworkCriterion => ({
|
|
619
630
|
...{
|
|
620
631
|
type: faker.helpers.arrayElement(["evmNetwork"] as const),
|
|
621
|
-
networks: faker.helpers.arrayElements([
|
|
632
|
+
networks: faker.helpers.arrayElements([
|
|
633
|
+
"base-sepolia",
|
|
634
|
+
"base",
|
|
635
|
+
"ethereum",
|
|
636
|
+
"ethereum-sepolia",
|
|
637
|
+
"avalanche",
|
|
638
|
+
"polygon",
|
|
639
|
+
"optimism",
|
|
640
|
+
"arbitrum",
|
|
641
|
+
"zora",
|
|
642
|
+
"bnb",
|
|
643
|
+
] as const),
|
|
622
644
|
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
623
645
|
},
|
|
624
646
|
...overrideResponse,
|
|
@@ -1047,7 +1069,18 @@ export const getGetPolicyByIdResponseEvmNetworkCriterionMock = (
|
|
|
1047
1069
|
): EvmNetworkCriterion => ({
|
|
1048
1070
|
...{
|
|
1049
1071
|
type: faker.helpers.arrayElement(["evmNetwork"] as const),
|
|
1050
|
-
networks: faker.helpers.arrayElements([
|
|
1072
|
+
networks: faker.helpers.arrayElements([
|
|
1073
|
+
"base-sepolia",
|
|
1074
|
+
"base",
|
|
1075
|
+
"ethereum",
|
|
1076
|
+
"ethereum-sepolia",
|
|
1077
|
+
"avalanche",
|
|
1078
|
+
"polygon",
|
|
1079
|
+
"optimism",
|
|
1080
|
+
"arbitrum",
|
|
1081
|
+
"zora",
|
|
1082
|
+
"bnb",
|
|
1083
|
+
] as const),
|
|
1051
1084
|
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
1052
1085
|
},
|
|
1053
1086
|
...overrideResponse,
|
|
@@ -1476,7 +1509,18 @@ export const getUpdatePolicyResponseEvmNetworkCriterionMock = (
|
|
|
1476
1509
|
): EvmNetworkCriterion => ({
|
|
1477
1510
|
...{
|
|
1478
1511
|
type: faker.helpers.arrayElement(["evmNetwork"] as const),
|
|
1479
|
-
networks: faker.helpers.arrayElements([
|
|
1512
|
+
networks: faker.helpers.arrayElements([
|
|
1513
|
+
"base-sepolia",
|
|
1514
|
+
"base",
|
|
1515
|
+
"ethereum",
|
|
1516
|
+
"ethereum-sepolia",
|
|
1517
|
+
"avalanche",
|
|
1518
|
+
"polygon",
|
|
1519
|
+
"optimism",
|
|
1520
|
+
"arbitrum",
|
|
1521
|
+
"zora",
|
|
1522
|
+
"bnb",
|
|
1523
|
+
] as const),
|
|
1480
1524
|
operator: faker.helpers.arrayElement(["in", "not in"] as const),
|
|
1481
1525
|
},
|
|
1482
1526
|
...overrideResponse,
|
package/openapi-client/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./generated/faucets/faucets.js";
|
|
|
9
9
|
export * from "./generated/policy-engine/policy-engine.js";
|
|
10
10
|
export * from "./generated/payments-alpha/payments-alpha.js";
|
|
11
11
|
export * from "./generated/onramp/onramp.js";
|
|
12
|
+
export * from "./generated/onchain-data/onchain-data.js";
|
|
12
13
|
|
|
13
14
|
import { configure } from "./cdpApiClient.js";
|
|
14
15
|
import * as evm from "./generated/evm-accounts/evm-accounts.js";
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SpendPermissionNetwork } from "../openapi-client/index.js";
|
|
1
2
|
import type { Address, Hex } from "../types/misc.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -24,19 +25,48 @@ export type SpendPermission = {
|
|
|
24
25
|
extraData: Hex;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
export type SpendPermissionInput = Omit<
|
|
29
|
+
SpendPermission,
|
|
30
|
+
"token" | "salt" | "extraData" | "period" | "start" | "end"
|
|
31
|
+
> & {
|
|
32
|
+
token: "eth" | "usdc" | Address;
|
|
33
|
+
salt?: bigint;
|
|
34
|
+
extraData?: Hex;
|
|
35
|
+
period?: number;
|
|
36
|
+
periodInDays?: number;
|
|
37
|
+
start?: Date;
|
|
38
|
+
end?: Date;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export interface CreateSpendPermissionOptions {
|
|
42
|
+
/** The spend permission. */
|
|
43
|
+
spendPermission: SpendPermissionInput;
|
|
44
|
+
/** The network. */
|
|
45
|
+
network: SpendPermissionNetwork;
|
|
46
|
+
/** The paymaster URL. */
|
|
47
|
+
paymasterUrl?: string;
|
|
48
|
+
/** The idempotency key. */
|
|
49
|
+
idempotencyKey?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ListSpendPermissionsOptions {
|
|
53
|
+
/** The address of the smart account. */
|
|
54
|
+
address: Address;
|
|
55
|
+
/** The page size to paginate through the spend permissions. */
|
|
56
|
+
pageSize?: number;
|
|
57
|
+
/** The page token to paginate through the spend permissions. */
|
|
58
|
+
pageToken?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface RevokeSpendPermissionOptions {
|
|
62
|
+
/** The address of the smart account. */
|
|
63
|
+
address: Address;
|
|
64
|
+
/** The hash of the spend permission to revoke. */
|
|
65
|
+
permissionHash: Hex;
|
|
66
|
+
/** The network. */
|
|
67
|
+
network: SpendPermissionNetwork;
|
|
68
|
+
/** The paymaster URL. */
|
|
69
|
+
paymasterUrl?: string;
|
|
70
|
+
/** The idempotency key. */
|
|
71
|
+
idempotencyKey?: string;
|
|
72
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getErc20Address } from "../actions/evm/transfer/utils.js";
|
|
2
|
+
import { UserInputValidationError } from "../errors.js";
|
|
3
|
+
|
|
4
|
+
import type { Network } from "../actions/evm/transfer/types.js";
|
|
5
|
+
import type { SpendPermissionNetwork } from "../openapi-client/index.js";
|
|
6
|
+
import type { Address } from "../types/misc.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Resolve the address of a token for a given network.
|
|
10
|
+
*
|
|
11
|
+
* @param token - The token symbol or contract address.
|
|
12
|
+
* @param network - The network to get the address for.
|
|
13
|
+
*
|
|
14
|
+
* @returns The address of the token.
|
|
15
|
+
*/
|
|
16
|
+
export function resolveTokenAddress(
|
|
17
|
+
token: "eth" | "usdc" | Address,
|
|
18
|
+
network: SpendPermissionNetwork,
|
|
19
|
+
): Address {
|
|
20
|
+
if (token === "eth") {
|
|
21
|
+
return "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (token === "usdc" && (network === "base" || network === "base-sepolia")) {
|
|
25
|
+
return getErc20Address(token, network as Network);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (token === "usdc") {
|
|
29
|
+
throw new UserInputValidationError(
|
|
30
|
+
`Automatic token address lookup for ${token} is not supported on ${network}. Please provide the token address manually.`,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return token;
|
|
35
|
+
}
|
package/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "1.
|
|
1
|
+
export const version = "1.34.0";
|