@coinbase/cdp-sdk 1.44.1 → 1.46.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 +28 -2
- package/README.md +164 -43
- package/_cjs/accounts/evm/eip6492.js +49 -0
- package/_cjs/accounts/evm/eip6492.js.map +1 -0
- package/_cjs/accounts/evm/toEvmDelegatedAccount.js +27 -0
- package/_cjs/accounts/evm/toEvmDelegatedAccount.js.map +1 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js +127 -55
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +115 -45
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js +31 -0
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +49 -19
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_cjs/actions/evm/waitForEvmEip7702DelegationStatus.js +37 -0
- package/_cjs/actions/evm/waitForEvmEip7702DelegationStatus.js.map +1 -0
- package/_cjs/actions/solana/transfer.js.map +1 -1
- package/_cjs/actions/solana/utils.js +9 -9
- package/_cjs/actions/solana/utils.js.map +1 -1
- package/_cjs/analytics.js +10 -228
- package/_cjs/analytics.js.map +1 -1
- package/_cjs/auth/utils/http.js +1 -0
- package/_cjs/auth/utils/http.js.map +1 -1
- package/_cjs/client/cdp.js +4 -7
- package/_cjs/client/cdp.js.map +1 -1
- package/_cjs/client/end-user/endUser.js +385 -4
- package/_cjs/client/end-user/endUser.js.map +1 -1
- package/_cjs/client/end-user/toEndUserAccount.js +201 -23
- package/_cjs/client/end-user/toEndUserAccount.js.map +1 -1
- package/_cjs/client/evm/evm.js +482 -227
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/client/policies/policies.js +41 -11
- package/_cjs/client/policies/policies.js.map +1 -1
- package/_cjs/client/solana/solana.js +215 -118
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/index.js +3 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/openapi-client/cdpApiClient.js +32 -0
- package/_cjs/openapi-client/cdpApiClient.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +178 -9
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js +261 -0
- package/_cjs/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +1 -0
- package/_cjs/openapi-client/generated/end-user-accounts/end-user-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +30 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +2 -2
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-swaps/evm-swaps.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -1
- package/_cjs/openapi-client/generated/faucets/faucets.js +6 -5
- package/_cjs/openapi-client/generated/faucets/faucets.js.map +1 -1
- package/_cjs/openapi-client/generated/onchain-data/onchain-data.js.map +1 -1
- package/_cjs/openapi-client/generated/onramp/onramp.js +15 -1
- package/_cjs/openapi-client/generated/onramp/onramp.js.map +1 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.js.map +1 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/solana-token-balances/solana-token-balances.js.map +1 -1
- package/_cjs/openapi-client/generated/sql-api/sql-api.js +75 -0
- package/_cjs/openapi-client/generated/sql-api/sql-api.js.map +1 -0
- package/_cjs/openapi-client/generated/webhooks/webhooks.js.map +1 -1
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -1
- package/_cjs/openapi-client/index.js +4 -1
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/policies/evmSchema.js +127 -1
- package/_cjs/policies/evmSchema.js.map +1 -1
- package/_cjs/policies/solanaSchema.js +102 -1
- package/_cjs/policies/solanaSchema.js.map +1 -1
- package/_cjs/policies/types.js +7 -0
- package/_cjs/policies/types.js.map +1 -1
- package/_cjs/utils/export.js +6 -5
- package/_cjs/utils/export.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/eip6492.js +46 -0
- package/_esm/accounts/evm/eip6492.js.map +1 -0
- package/_esm/accounts/evm/toEvmDelegatedAccount.js +24 -0
- package/_esm/accounts/evm/toEvmDelegatedAccount.js.map +1 -0
- package/_esm/accounts/evm/toEvmServerAccount.js +127 -55
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +115 -45
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +31 -0
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/solana/toSolanaAccount.js +49 -19
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_esm/actions/evm/waitForEvmEip7702DelegationStatus.js +34 -0
- package/_esm/actions/evm/waitForEvmEip7702DelegationStatus.js.map +1 -0
- package/_esm/actions/solana/transfer.js.map +1 -1
- package/_esm/actions/solana/utils.js +9 -9
- package/_esm/actions/solana/utils.js.map +1 -1
- package/_esm/analytics.js +9 -227
- package/_esm/analytics.js.map +1 -1
- package/_esm/auth/utils/http.js +1 -0
- package/_esm/auth/utils/http.js.map +1 -1
- package/_esm/client/cdp.js +4 -7
- package/_esm/client/cdp.js.map +1 -1
- package/_esm/client/end-user/endUser.js +385 -4
- package/_esm/client/end-user/endUser.js.map +1 -1
- package/_esm/client/end-user/toEndUserAccount.js +201 -23
- package/_esm/client/end-user/toEndUserAccount.js.map +1 -1
- package/_esm/client/evm/evm.js +482 -227
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/client/policies/policies.js +41 -11
- package/_esm/client/policies/policies.js.map +1 -1
- package/_esm/client/solana/solana.js +215 -118
- package/_esm/client/solana/solana.js.map +1 -1
- package/_esm/index.js +1 -0
- package/_esm/index.js.map +1 -1
- package/_esm/openapi-client/cdpApiClient.js +32 -0
- package/_esm/openapi-client/cdpApiClient.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +175 -7
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js +243 -0
- package/_esm/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +1 -0
- package/_esm/openapi-client/generated/end-user-accounts/end-user-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +27 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +2 -2
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-swaps/evm-swaps.js.map +1 -1
- package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -1
- package/_esm/openapi-client/generated/faucets/faucets.js +6 -5
- package/_esm/openapi-client/generated/faucets/faucets.js.map +1 -1
- package/_esm/openapi-client/generated/onchain-data/onchain-data.js.map +1 -1
- package/_esm/openapi-client/generated/onramp/onramp.js +13 -0
- package/_esm/openapi-client/generated/onramp/onramp.js.map +1 -1
- package/_esm/openapi-client/generated/policy-engine/policy-engine.js.map +1 -1
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/solana-token-balances/solana-token-balances.js.map +1 -1
- package/_esm/openapi-client/generated/sql-api/sql-api.js +70 -0
- package/_esm/openapi-client/generated/sql-api/sql-api.js.map +1 -0
- package/_esm/openapi-client/generated/webhooks/webhooks.js.map +1 -1
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -1
- package/_esm/openapi-client/index.js +4 -1
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/policies/evmSchema.js +126 -0
- package/_esm/policies/evmSchema.js.map +1 -1
- package/_esm/policies/solanaSchema.js +101 -0
- package/_esm/policies/solanaSchema.js.map +1 -1
- package/_esm/policies/types.js +9 -2
- package/_esm/policies/types.js.map +1 -1
- package/_esm/utils/export.js +6 -5
- package/_esm/utils/export.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/eip6492.d.ts +17 -0
- package/_types/accounts/evm/eip6492.d.ts.map +1 -0
- package/_types/accounts/evm/toEvmDelegatedAccount.d.ts +13 -0
- package/_types/accounts/evm/toEvmDelegatedAccount.d.ts.map +1 -0
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts +4 -4
- package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/types.d.ts +3 -2
- package/_types/accounts/evm/types.d.ts.map +1 -1
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
- package/_types/actions/evm/waitForEvmEip7702DelegationStatus.d.ts +32 -0
- package/_types/actions/evm/waitForEvmEip7702DelegationStatus.d.ts.map +1 -0
- package/_types/actions/solana/transfer.d.ts +3 -4
- package/_types/actions/solana/transfer.d.ts.map +1 -1
- package/_types/actions/solana/types.d.ts +79 -29
- package/_types/actions/solana/types.d.ts.map +1 -1
- package/_types/actions/solana/utils.d.ts +10 -9
- package/_types/actions/solana/utils.d.ts.map +1 -1
- package/_types/analytics.d.ts +5 -38
- package/_types/analytics.d.ts.map +1 -1
- package/_types/auth/utils/http.d.ts.map +1 -1
- package/_types/client/cdp.d.ts +4 -0
- package/_types/client/cdp.d.ts.map +1 -1
- package/_types/client/end-user/endUser.d.ts +272 -1
- package/_types/client/end-user/endUser.d.ts.map +1 -1
- package/_types/client/end-user/endUser.types.d.ts +491 -1
- package/_types/client/end-user/endUser.types.d.ts.map +1 -1
- package/_types/client/end-user/toEndUserAccount.d.ts +4 -1
- package/_types/client/end-user/toEndUserAccount.d.ts.map +1 -1
- package/_types/client/evm/evm.d.ts +54 -1
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +29 -2
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/policies/policies.d.ts.map +1 -1
- package/_types/client/solana/solana.d.ts +38 -12
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/index.d.ts +3 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/cdpApiClient.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +884 -90
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts +163 -0
- package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts.map +1 -0
- package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.d.ts +9 -9
- package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +35 -15
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +14 -14
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-swaps/evm-swaps.d.ts +3 -3
- package/_types/openapi-client/generated/evm-swaps/evm-swaps.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts +2 -2
- package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts.map +1 -1
- package/_types/openapi-client/generated/faucets/faucets.d.ts +9 -8
- package/_types/openapi-client/generated/faucets/faucets.d.ts.map +1 -1
- package/_types/openapi-client/generated/onchain-data/onchain-data.d.ts +3 -3
- package/_types/openapi-client/generated/onchain-data/onchain-data.d.ts.map +1 -1
- package/_types/openapi-client/generated/onramp/onramp.d.ts +12 -5
- package/_types/openapi-client/generated/onramp/onramp.d.ts.map +1 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts +6 -6
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts.map +1 -1
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts +12 -12
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/solana-token-balances/solana-token-balances.d.ts +2 -2
- package/_types/openapi-client/generated/solana-token-balances/solana-token-balances.d.ts.map +1 -1
- package/_types/openapi-client/generated/sql-api/sql-api.d.ts +73 -0
- package/_types/openapi-client/generated/sql-api/sql-api.d.ts.map +1 -0
- package/_types/openapi-client/generated/webhooks/webhooks.d.ts +6 -6
- package/_types/openapi-client/generated/webhooks/webhooks.d.ts.map +1 -1
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts +4 -4
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts +23 -3
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/policies/evmSchema.d.ts +3128 -1064
- package/_types/policies/evmSchema.d.ts.map +1 -1
- package/_types/policies/solanaSchema.d.ts +1411 -47
- package/_types/policies/solanaSchema.d.ts.map +1 -1
- package/_types/policies/types.d.ts +8427 -2942
- package/_types/policies/types.d.ts.map +1 -1
- package/_types/types/contract.d.ts.map +1 -1
- package/_types/utils/export.d.ts +1 -1
- package/_types/utils/export.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/eip6492.ts +60 -0
- package/accounts/evm/toEvmDelegatedAccount.ts +26 -0
- package/accounts/evm/toEvmServerAccount.ts +115 -67
- package/accounts/evm/toEvmSmartAccount.ts +114 -57
- package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +44 -5
- package/accounts/evm/types.ts +8 -3
- package/accounts/solana/toSolanaAccount.ts +44 -24
- package/actions/evm/waitForEvmEip7702DelegationStatus.ts +57 -0
- package/actions/solana/transfer.ts +3 -3
- package/actions/solana/types.ts +79 -29
- package/actions/solana/utils.ts +13 -11
- package/analytics.ts +8 -294
- package/auth/utils/http.ts +1 -0
- package/client/cdp.ts +6 -8
- package/client/end-user/endUser.ts +513 -4
- package/client/end-user/endUser.types.ts +598 -0
- package/client/end-user/toEndUserAccount.ts +330 -26
- package/client/evm/evm.ts +517 -282
- package/client/evm/evm.types.ts +45 -2
- package/client/policies/policies.ts +41 -16
- package/client/solana/solana.ts +233 -153
- package/index.ts +36 -1
- package/openapi-client/cdpApiClient.ts +34 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +1155 -172
- package/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.ts +455 -0
- package/openapi-client/generated/end-user-accounts/end-user-accounts.ts +12 -9
- package/openapi-client/generated/evm-accounts/evm-accounts.ts +66 -14
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +16 -16
- package/openapi-client/generated/evm-swaps/evm-swaps.ts +3 -3
- package/openapi-client/generated/evm-token-balances/evm-token-balances.ts +2 -2
- package/openapi-client/generated/faucets/faucets.ts +9 -8
- package/openapi-client/generated/onchain-data/onchain-data.ts +3 -3
- package/openapi-client/generated/onramp/onramp.ts +28 -4
- package/openapi-client/generated/policy-engine/policy-engine.ts +12 -6
- package/openapi-client/generated/solana-accounts/solana-accounts.ts +12 -12
- package/openapi-client/generated/solana-token-balances/solana-token-balances.ts +2 -2
- package/openapi-client/generated/sql-api/sql-api.ts +92 -0
- package/openapi-client/generated/webhooks/webhooks.ts +6 -6
- package/openapi-client/generated/x402-facilitator/x402-facilitator.ts +6 -4
- package/openapi-client/index.ts +4 -1
- package/package.json +7 -8
- package/policies/evmSchema.ts +164 -0
- package/policies/solanaSchema.ts +130 -0
- package/policies/types.ts +14 -0
- package/types/contract.ts +2 -4
- package/utils/export.ts +6 -5
- package/version.ts +1 -1
- package/_cjs/openapi-client/generated/sql-api-alpha/sql-api-alpha.js +0 -55
- package/_cjs/openapi-client/generated/sql-api-alpha/sql-api-alpha.js.map +0 -1
- package/_esm/openapi-client/generated/sql-api-alpha/sql-api-alpha.js +0 -50
- package/_esm/openapi-client/generated/sql-api-alpha/sql-api-alpha.js.map +0 -1
- package/_types/openapi-client/generated/sql-api-alpha/sql-api-alpha.d.ts +0 -53
- package/_types/openapi-client/generated/sql-api-alpha/sql-api-alpha.d.ts.map +0 -1
- package/openapi-client/generated/sql-api-alpha/sql-api-alpha.ts +0 -72
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createPublicClient, http } from "viem";
|
|
2
|
+
|
|
3
|
+
import { wrapSignatureWithEip6492IfUndeployed } from "./eip6492.js";
|
|
1
4
|
import { resolveNetworkToChain } from "./networkToChainResolver.js";
|
|
2
5
|
import { toNetworkScopedEvmSmartAccount } from "./toNetworkScopedEvmSmartAccount.js";
|
|
3
6
|
import { getUserOperation } from "../../actions/evm/getUserOperation.js";
|
|
@@ -39,7 +42,7 @@ import {
|
|
|
39
42
|
type EvmSmartAccount as EvmSmartAccountModel,
|
|
40
43
|
} from "../../openapi-client/index.js";
|
|
41
44
|
|
|
42
|
-
import type { EvmAccount, EvmSmartAccount, KnownEvmNetworks } from "./types.js";
|
|
45
|
+
import type { EvmAccount, EvmSmartAccount, KnownEvmNetworks, NetworkOrRpcUrl } from "./types.js";
|
|
43
46
|
import type {
|
|
44
47
|
SmartAccountQuoteSwapOptions,
|
|
45
48
|
SmartAccountQuoteSwapResult,
|
|
@@ -86,8 +89,12 @@ export function toEvmSmartAccount(
|
|
|
86
89
|
network: transferArgs.network,
|
|
87
90
|
},
|
|
88
91
|
});
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
try {
|
|
93
|
+
return transfer(apiClient, account, transferArgs, smartAccountTransferStrategy);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
Analytics.trackError(error, "transfer");
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
91
98
|
},
|
|
92
99
|
async listTokenBalances(
|
|
93
100
|
options: Omit<ListTokenBalancesOptions, "address">,
|
|
@@ -99,11 +106,15 @@ export function toEvmSmartAccount(
|
|
|
99
106
|
network: options.network,
|
|
100
107
|
},
|
|
101
108
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
try {
|
|
110
|
+
return listTokenBalances(apiClient, {
|
|
111
|
+
...options,
|
|
112
|
+
address: this.address,
|
|
113
|
+
});
|
|
114
|
+
} catch (error) {
|
|
115
|
+
Analytics.trackError(error, "listTokenBalances");
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
107
118
|
},
|
|
108
119
|
async sendUserOperation(
|
|
109
120
|
options: Omit<SendUserOperationOptions<unknown[]>, "smartAccount">,
|
|
@@ -115,11 +126,15 @@ export function toEvmSmartAccount(
|
|
|
115
126
|
network: options.network,
|
|
116
127
|
},
|
|
117
128
|
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
try {
|
|
130
|
+
return sendUserOperation(apiClient, {
|
|
131
|
+
...options,
|
|
132
|
+
smartAccount: account,
|
|
133
|
+
});
|
|
134
|
+
} catch (error) {
|
|
135
|
+
Analytics.trackError(error, "sendUserOperation");
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
123
138
|
},
|
|
124
139
|
async waitForUserOperation(
|
|
125
140
|
options: Omit<WaitForUserOperationOptions, "smartAccountAddress">,
|
|
@@ -128,11 +143,15 @@ export function toEvmSmartAccount(
|
|
|
128
143
|
action: "wait_for_user_operation",
|
|
129
144
|
accountType: "evm_smart",
|
|
130
145
|
});
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
146
|
+
try {
|
|
147
|
+
return waitForUserOperation(apiClient, {
|
|
148
|
+
...options,
|
|
149
|
+
smartAccountAddress: account.address,
|
|
150
|
+
});
|
|
151
|
+
} catch (error) {
|
|
152
|
+
Analytics.trackError(error, "waitForUserOperation");
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
136
155
|
},
|
|
137
156
|
async getUserOperation(
|
|
138
157
|
options: Omit<GetUserOperationOptions, "smartAccount">,
|
|
@@ -141,11 +160,15 @@ export function toEvmSmartAccount(
|
|
|
141
160
|
action: "get_user_operation",
|
|
142
161
|
accountType: "evm_smart",
|
|
143
162
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
163
|
+
try {
|
|
164
|
+
return getUserOperation(apiClient, {
|
|
165
|
+
...options,
|
|
166
|
+
smartAccount: account,
|
|
167
|
+
});
|
|
168
|
+
} catch (error) {
|
|
169
|
+
Analytics.trackError(error, "getUserOperation");
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
149
172
|
},
|
|
150
173
|
async requestFaucet(
|
|
151
174
|
options: Omit<RequestFaucetOptions, "address">,
|
|
@@ -157,11 +180,15 @@ export function toEvmSmartAccount(
|
|
|
157
180
|
network: options.network,
|
|
158
181
|
},
|
|
159
182
|
});
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
183
|
+
try {
|
|
184
|
+
return requestFaucet(apiClient, {
|
|
185
|
+
...options,
|
|
186
|
+
address: account.address,
|
|
187
|
+
});
|
|
188
|
+
} catch (error) {
|
|
189
|
+
Analytics.trackError(error, "requestFaucet");
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
165
192
|
},
|
|
166
193
|
async quoteSwap(options: SmartAccountQuoteSwapOptions): Promise<SmartAccountQuoteSwapResult> {
|
|
167
194
|
Analytics.trackAction({
|
|
@@ -171,13 +198,17 @@ export function toEvmSmartAccount(
|
|
|
171
198
|
network: options.network,
|
|
172
199
|
},
|
|
173
200
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
201
|
+
try {
|
|
202
|
+
return createSwapQuote(apiClient, {
|
|
203
|
+
...options,
|
|
204
|
+
taker: this.address, // Always use smart account's address as taker
|
|
205
|
+
signerAddress: this.owners[0].address, // Always use owner's address as signer
|
|
206
|
+
smartAccount: account, // Pass smart account for execute method support
|
|
207
|
+
});
|
|
208
|
+
} catch (error) {
|
|
209
|
+
Analytics.trackError(error, "quoteSwap");
|
|
210
|
+
throw error;
|
|
211
|
+
}
|
|
181
212
|
},
|
|
182
213
|
async swap(options: SmartAccountSwapOptions): Promise<SmartAccountSwapResult> {
|
|
183
214
|
Analytics.trackAction({
|
|
@@ -187,13 +218,17 @@ export function toEvmSmartAccount(
|
|
|
187
218
|
network: "network" in options ? options.network : undefined,
|
|
188
219
|
},
|
|
189
220
|
});
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
221
|
+
try {
|
|
222
|
+
return sendSwapOperation(apiClient, {
|
|
223
|
+
...options,
|
|
224
|
+
smartAccount: account,
|
|
225
|
+
taker: this.address, // Always use smart account's address as taker
|
|
226
|
+
signerAddress: this.owners[0].address, // Always use owner's address as signer
|
|
227
|
+
});
|
|
228
|
+
} catch (error) {
|
|
229
|
+
Analytics.trackError(error, "swap");
|
|
230
|
+
throw error;
|
|
231
|
+
}
|
|
197
232
|
},
|
|
198
233
|
async signTypedData(
|
|
199
234
|
options: Omit<SignTypedDataOptions, "address"> & { network: KnownEvmNetworks },
|
|
@@ -205,13 +240,27 @@ export function toEvmSmartAccount(
|
|
|
205
240
|
network: options.network,
|
|
206
241
|
},
|
|
207
242
|
});
|
|
243
|
+
try {
|
|
244
|
+
const chain = resolveNetworkToChain(options.network);
|
|
208
245
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
246
|
+
const result = await signAndWrapTypedDataForSmartAccount(apiClient, {
|
|
247
|
+
chainId: BigInt(chain.id),
|
|
248
|
+
smartAccount: account,
|
|
249
|
+
typedData: options,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
const publicClient = createPublicClient({ chain, transport: http() });
|
|
253
|
+
|
|
254
|
+
return wrapSignatureWithEip6492IfUndeployed(
|
|
255
|
+
publicClient,
|
|
256
|
+
account.address,
|
|
257
|
+
account.owners[0].address,
|
|
258
|
+
result.signature,
|
|
259
|
+
);
|
|
260
|
+
} catch (error) {
|
|
261
|
+
Analytics.trackError(error, "signTypedData");
|
|
262
|
+
throw error;
|
|
263
|
+
}
|
|
215
264
|
},
|
|
216
265
|
async useSpendPermission(
|
|
217
266
|
options: UseSpendPermissionOptions,
|
|
@@ -223,13 +272,17 @@ export function toEvmSmartAccount(
|
|
|
223
272
|
network: options.network,
|
|
224
273
|
},
|
|
225
274
|
});
|
|
226
|
-
|
|
227
|
-
|
|
275
|
+
try {
|
|
276
|
+
return useSpendPermission(apiClient, account, options);
|
|
277
|
+
} catch (error) {
|
|
278
|
+
Analytics.trackError(error, "useSpendPermission");
|
|
279
|
+
throw error;
|
|
280
|
+
}
|
|
228
281
|
},
|
|
229
282
|
|
|
230
283
|
name: options.smartAccount.name,
|
|
231
284
|
type: "evm-smart",
|
|
232
|
-
useNetwork: async <Network extends
|
|
285
|
+
useNetwork: async <Network extends NetworkOrRpcUrl>(network: Network) => {
|
|
233
286
|
Analytics.trackAction({
|
|
234
287
|
action: "use_network",
|
|
235
288
|
accountType: "evm_smart",
|
|
@@ -237,12 +290,16 @@ export function toEvmSmartAccount(
|
|
|
237
290
|
network,
|
|
238
291
|
},
|
|
239
292
|
});
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
293
|
+
try {
|
|
294
|
+
return toNetworkScopedEvmSmartAccount(apiClient, {
|
|
295
|
+
smartAccount: account,
|
|
296
|
+
owner: options.owner,
|
|
297
|
+
network,
|
|
298
|
+
});
|
|
299
|
+
} catch (error) {
|
|
300
|
+
Analytics.trackError(error, "useNetwork");
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
246
303
|
},
|
|
247
304
|
};
|
|
248
305
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { wrapSignatureWithEip6492IfUndeployed } from "./eip6492.js";
|
|
1
2
|
import { getBaseNodeRpcUrl } from "./getBaseNodeRpcUrl.js";
|
|
2
3
|
import { isMethodSupportedOnNetwork } from "./networkCapabilities.js";
|
|
4
|
+
import { resolveViemClients } from "./resolveViemClients.js";
|
|
3
5
|
import { getUserOperation } from "../../actions/evm/getUserOperation.js";
|
|
4
6
|
import { listTokenBalances } from "../../actions/evm/listTokenBalances.js";
|
|
5
7
|
import { requestFaucet } from "../../actions/evm/requestFaucet.js";
|
|
6
8
|
import { sendUserOperation } from "../../actions/evm/sendUserOperation.js";
|
|
9
|
+
import { signAndWrapTypedDataForSmartAccount } from "../../actions/evm/signAndWrapTypedDataForSmartAccount.js";
|
|
7
10
|
import { UseSpendPermissionOptions } from "../../actions/evm/spend-permissions/types.js";
|
|
8
11
|
import { createSwapQuote } from "../../actions/evm/swap/createSwapQuote.js";
|
|
9
12
|
import { sendSwapOperation } from "../../actions/evm/swap/sendSwapOperation.js";
|
|
@@ -15,7 +18,7 @@ import { Analytics } from "../../analytics.js";
|
|
|
15
18
|
import type {
|
|
16
19
|
EvmAccount,
|
|
17
20
|
EvmSmartAccount,
|
|
18
|
-
|
|
21
|
+
NetworkOrRpcUrl,
|
|
19
22
|
NetworkScopedEvmSmartAccount,
|
|
20
23
|
DistributedOmit,
|
|
21
24
|
} from "./types.js";
|
|
@@ -29,7 +32,7 @@ import type {
|
|
|
29
32
|
} from "../../actions/evm/swap/types.js";
|
|
30
33
|
import type { SmartAccountTransferOptions } from "../../actions/evm/transfer/types.js";
|
|
31
34
|
import type { WaitForUserOperationOptions } from "../../actions/evm/waitForUserOperation.js";
|
|
32
|
-
import type { GetUserOperationOptions } from "../../client/evm/evm.types.js";
|
|
35
|
+
import type { GetUserOperationOptions, SignTypedDataOptions } from "../../client/evm/evm.types.js";
|
|
33
36
|
import type {
|
|
34
37
|
CdpOpenApiClientType,
|
|
35
38
|
EvmUserOperationNetwork,
|
|
@@ -43,8 +46,8 @@ import type {
|
|
|
43
46
|
export type ToNetworkScopedEvmSmartAccountOptions = {
|
|
44
47
|
/** The pre-existing EvmSmartAccount. */
|
|
45
48
|
smartAccount: EvmSmartAccount;
|
|
46
|
-
/** The network to scope the smart account object to. */
|
|
47
|
-
network:
|
|
49
|
+
/** The network name or RPC URL to scope the smart account object to. */
|
|
50
|
+
network: NetworkOrRpcUrl;
|
|
48
51
|
/** The owner of the smart account. */
|
|
49
52
|
owner: EvmAccount;
|
|
50
53
|
};
|
|
@@ -62,7 +65,7 @@ export type ToNetworkScopedEvmSmartAccountOptions = {
|
|
|
62
65
|
* @param {KnownEvmNetworks} options.network - The network to scope the smart account to.
|
|
63
66
|
* @returns {NetworkScopedEvmSmartAccount} A configured NetworkScopedEvmSmartAccount instance ready for user operation submission.
|
|
64
67
|
*/
|
|
65
|
-
export async function toNetworkScopedEvmSmartAccount<Network extends
|
|
68
|
+
export async function toNetworkScopedEvmSmartAccount<Network extends NetworkOrRpcUrl>(
|
|
66
69
|
apiClient: CdpOpenApiClientType,
|
|
67
70
|
options: ToNetworkScopedEvmSmartAccountOptions & { network: Network },
|
|
68
71
|
): Promise<NetworkScopedEvmSmartAccount<Network>> {
|
|
@@ -278,5 +281,41 @@ export async function toNetworkScopedEvmSmartAccount<Network extends KnownEvmNet
|
|
|
278
281
|
});
|
|
279
282
|
}
|
|
280
283
|
|
|
284
|
+
Object.assign(account, {
|
|
285
|
+
signTypedData: async (typedDataOptions: Omit<SignTypedDataOptions, "address">) => {
|
|
286
|
+
Analytics.trackAction({
|
|
287
|
+
action: "sign_typed_data",
|
|
288
|
+
accountType: "evm_smart",
|
|
289
|
+
properties: {
|
|
290
|
+
network: options.network,
|
|
291
|
+
managed: true,
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
try {
|
|
296
|
+
const { publicClient, chain } = await resolveViemClients({
|
|
297
|
+
networkOrNodeUrl: options.network,
|
|
298
|
+
account: options.owner,
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
const result = await signAndWrapTypedDataForSmartAccount(apiClient, {
|
|
302
|
+
chainId: BigInt(chain.id),
|
|
303
|
+
smartAccount: options.smartAccount,
|
|
304
|
+
typedData: typedDataOptions,
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
return wrapSignatureWithEip6492IfUndeployed(
|
|
308
|
+
publicClient,
|
|
309
|
+
options.smartAccount.address,
|
|
310
|
+
options.smartAccount.owners[0].address,
|
|
311
|
+
result.signature,
|
|
312
|
+
);
|
|
313
|
+
} catch (error) {
|
|
314
|
+
Analytics.trackError(error, "signTypedData");
|
|
315
|
+
throw error;
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
|
|
281
320
|
return account;
|
|
282
321
|
}
|
package/accounts/evm/types.ts
CHANGED
|
@@ -34,7 +34,11 @@ import {
|
|
|
34
34
|
WaitForUserOperationOptions,
|
|
35
35
|
WaitForUserOperationReturnType,
|
|
36
36
|
} from "../../actions/evm/waitForUserOperation.js";
|
|
37
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
GetUserOperationOptions,
|
|
39
|
+
SignTypedDataOptions,
|
|
40
|
+
UserOperation,
|
|
41
|
+
} from "../../client/evm/evm.types.js";
|
|
38
42
|
import { SpendPermissionNetwork } from "../../openapi-client/index.js";
|
|
39
43
|
|
|
40
44
|
import type {
|
|
@@ -160,7 +164,7 @@ export type EvmSmartAccountProperties = {
|
|
|
160
164
|
* // For custom RPC URLs without type hints (only sendTransaction, transfer and waitForTransactionReceipt methods available):
|
|
161
165
|
* const customAccount = await smartAccount.useNetwork("https://mainnet.base.org");
|
|
162
166
|
*/
|
|
163
|
-
useNetwork: <Network extends
|
|
167
|
+
useNetwork: <Network extends NetworkOrRpcUrl>(
|
|
164
168
|
network: Network,
|
|
165
169
|
) => Promise<NetworkScopedEvmSmartAccount<Network>>;
|
|
166
170
|
};
|
|
@@ -176,7 +180,7 @@ export type EvmSmartAccount = Prettify<EvmSmartAccountProperties & SmartAccountA
|
|
|
176
180
|
* @internal
|
|
177
181
|
*/
|
|
178
182
|
export type NetworkSpecificSmartAccountActions<Network extends string> = Prettify<
|
|
179
|
-
// Always include sendUserOperation, waitForUserOperation and
|
|
183
|
+
// Always include sendUserOperation, waitForUserOperation, getUserOperation and signTypedData
|
|
180
184
|
{
|
|
181
185
|
sendUserOperation: <const callData extends unknown[]>(
|
|
182
186
|
options: Omit<SendUserOperationOptions<callData>, "smartAccount" | "network">,
|
|
@@ -187,6 +191,7 @@ export type NetworkSpecificSmartAccountActions<Network extends string> = Prettif
|
|
|
187
191
|
getUserOperation: (
|
|
188
192
|
options: Omit<GetUserOperationOptions, "smartAccount" | "network">,
|
|
189
193
|
) => Promise<UserOperation>;
|
|
194
|
+
signTypedData: (options: Omit<SignTypedDataOptions, "address">) => Promise<Hex>;
|
|
190
195
|
} & (Network extends TransferNetworks
|
|
191
196
|
? {
|
|
192
197
|
transfer: (
|
|
@@ -43,22 +43,30 @@ export function toSolanaAccount(
|
|
|
43
43
|
action: "request_faucet",
|
|
44
44
|
accountType: "solana",
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
try {
|
|
47
|
+
return requestFaucet(apiClient, {
|
|
48
|
+
...options,
|
|
49
|
+
address: account.address,
|
|
50
|
+
});
|
|
51
|
+
} catch (error) {
|
|
52
|
+
Analytics.trackError(error, "requestFaucet");
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
51
55
|
},
|
|
52
56
|
async signMessage(options: Omit<SignMessageOptions, "address">): Promise<SignatureResult> {
|
|
53
57
|
Analytics.trackAction({
|
|
54
58
|
action: "sign_message",
|
|
55
59
|
accountType: "solana",
|
|
56
60
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
try {
|
|
62
|
+
return signMessage(apiClient, {
|
|
63
|
+
...options,
|
|
64
|
+
address: account.address,
|
|
65
|
+
});
|
|
66
|
+
} catch (error) {
|
|
67
|
+
Analytics.trackError(error, "signMessage");
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
62
70
|
},
|
|
63
71
|
async signTransaction(
|
|
64
72
|
options: Omit<SignTransactionOptions, "address">,
|
|
@@ -67,11 +75,15 @@ export function toSolanaAccount(
|
|
|
67
75
|
action: "sign_transaction",
|
|
68
76
|
accountType: "solana",
|
|
69
77
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
try {
|
|
79
|
+
return signTransaction(apiClient, {
|
|
80
|
+
...options,
|
|
81
|
+
address: account.address,
|
|
82
|
+
});
|
|
83
|
+
} catch (error) {
|
|
84
|
+
Analytics.trackError(error, "signTransaction");
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
75
87
|
},
|
|
76
88
|
async sendTransaction(
|
|
77
89
|
options: Omit<SendTransactionOptions, "address">,
|
|
@@ -80,10 +92,14 @@ export function toSolanaAccount(
|
|
|
80
92
|
action: "send_transaction",
|
|
81
93
|
accountType: "solana",
|
|
82
94
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
95
|
+
try {
|
|
96
|
+
return sendTransaction(apiClient, {
|
|
97
|
+
...options,
|
|
98
|
+
});
|
|
99
|
+
} catch (error) {
|
|
100
|
+
Analytics.trackError(error, "sendTransaction");
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
87
103
|
},
|
|
88
104
|
async transfer(options: Omit<TransferOptions, "from">): Promise<SignatureResult> {
|
|
89
105
|
Analytics.trackAction({
|
|
@@ -93,11 +109,15 @@ export function toSolanaAccount(
|
|
|
93
109
|
network: options.network,
|
|
94
110
|
},
|
|
95
111
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
112
|
+
try {
|
|
113
|
+
return transfer(apiClient, {
|
|
114
|
+
...options,
|
|
115
|
+
from: account.address,
|
|
116
|
+
});
|
|
117
|
+
} catch (error) {
|
|
118
|
+
Analytics.trackError(error, "transfer");
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
101
121
|
},
|
|
102
122
|
};
|
|
103
123
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CdpOpenApiClientType,
|
|
3
|
+
EvmEip7702DelegationOperation,
|
|
4
|
+
EvmEip7702DelegationOperationStatus,
|
|
5
|
+
} from "../../openapi-client/index.js";
|
|
6
|
+
import { wait, WaitOptions } from "../../utils/wait.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Options for waiting for an EIP-7702 delegation operation to complete.
|
|
10
|
+
*/
|
|
11
|
+
export type WaitForEvmEip7702DelegationOperationStatusOptions = {
|
|
12
|
+
/** The delegation operation ID returned by createEvmEip7702Delegation. */
|
|
13
|
+
delegationOperationId: string;
|
|
14
|
+
/** Optional options for the wait operation. */
|
|
15
|
+
waitOptions?: WaitOptions;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Polls getEvmEip7702DelegationOperationById until the status is COMPLETED or FAILED, or a timeout occurs.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { waitForEvmEip7702DelegationOperationStatus } from "@coinbase/cdp-sdk";
|
|
24
|
+
*
|
|
25
|
+
* const operation = await waitForEvmEip7702DelegationOperationStatus(client, {
|
|
26
|
+
* delegationOperationId: "delegation-op-123",
|
|
27
|
+
* waitOptions: {
|
|
28
|
+
* timeoutSeconds: 60,
|
|
29
|
+
* },
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param {CdpOpenApiClientType} client - The client to use.
|
|
34
|
+
* @param {WaitForEvmEip7702DelegationOperationStatusOptions} options - The options for the wait operation.
|
|
35
|
+
* @returns {Promise<EvmEip7702DelegationOperation>} The delegation operation once it reaches a terminal status.
|
|
36
|
+
*/
|
|
37
|
+
export async function waitForEvmEip7702DelegationOperationStatus(
|
|
38
|
+
client: CdpOpenApiClientType,
|
|
39
|
+
options: WaitForEvmEip7702DelegationOperationStatusOptions,
|
|
40
|
+
): Promise<EvmEip7702DelegationOperation> {
|
|
41
|
+
const { delegationOperationId } = options;
|
|
42
|
+
|
|
43
|
+
const reload = async () => {
|
|
44
|
+
return client.getEvmEip7702DelegationOperationById(delegationOperationId);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const isTerminal = (operation: EvmEip7702DelegationOperation): boolean => {
|
|
48
|
+
return (
|
|
49
|
+
operation.status === EvmEip7702DelegationOperationStatus.COMPLETED ||
|
|
50
|
+
operation.status === EvmEip7702DelegationOperationStatus.FAILED
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const waitOptions = options.waitOptions ?? { timeoutSeconds: 60 };
|
|
55
|
+
|
|
56
|
+
return await wait(reload, isTerminal, s => s, waitOptions);
|
|
57
|
+
}
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
createNoopSigner,
|
|
12
12
|
getBase64EncodedWireTransaction,
|
|
13
13
|
} from "@solana/kit";
|
|
14
|
-
import { Connection } from "@solana/web3.js";
|
|
15
14
|
import { getTransferSolInstruction } from "@solana-program/system";
|
|
16
15
|
import {
|
|
17
16
|
findAssociatedTokenPda,
|
|
@@ -29,6 +28,7 @@ import {
|
|
|
29
28
|
getOrCreateConnection,
|
|
30
29
|
getUsdcMintAddress,
|
|
31
30
|
type Network,
|
|
31
|
+
type SolanaRpcClient,
|
|
32
32
|
} from "./utils.js";
|
|
33
33
|
|
|
34
34
|
import type { SignatureResult } from "../../client/solana/solana.types.js";
|
|
@@ -52,9 +52,9 @@ export interface TransferOptions {
|
|
|
52
52
|
*/
|
|
53
53
|
token: "sol" | "usdc" | string;
|
|
54
54
|
/**
|
|
55
|
-
* The network to use which will be used to create an RPC client, otherwise an RPC client can be provided.
|
|
55
|
+
* The network to use which will be used to create an RPC client, otherwise an existing RPC client can be provided.
|
|
56
56
|
*/
|
|
57
|
-
network: Network |
|
|
57
|
+
network: Network | SolanaRpcClient;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|