@coinbase/agentkit 0.4.0 → 0.6.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.
Files changed (93) hide show
  1. package/README.md +103 -7
  2. package/dist/action-providers/across/acrossActionProvider.d.ts +50 -0
  3. package/dist/action-providers/across/acrossActionProvider.js +333 -0
  4. package/dist/action-providers/across/acrossActionProvider.test.d.ts +1 -0
  5. package/dist/action-providers/across/acrossActionProvider.test.js +391 -0
  6. package/dist/action-providers/across/constants.d.ts +1 -0
  7. package/dist/action-providers/across/constants.js +2 -0
  8. package/dist/action-providers/across/index.d.ts +1 -0
  9. package/dist/action-providers/across/index.js +17 -0
  10. package/dist/action-providers/across/schemas.d.ts +36 -0
  11. package/dist/action-providers/across/schemas.js +46 -0
  12. package/dist/action-providers/across/utils.d.ts +7 -0
  13. package/dist/action-providers/across/utils.js +25 -0
  14. package/dist/action-providers/erc20/constants.d.ts +2 -0
  15. package/dist/action-providers/erc20/constants.js +12 -1
  16. package/dist/action-providers/erc20/erc20ActionProvider.js +18 -0
  17. package/dist/action-providers/erc20/erc20ActionProvider.test.js +4 -0
  18. package/dist/action-providers/flaunch/constants.d.ts +1078 -0
  19. package/dist/action-providers/flaunch/constants.js +709 -0
  20. package/dist/action-providers/flaunch/flaunchActionProvider.d.ts +102 -0
  21. package/dist/action-providers/flaunch/flaunchActionProvider.js +519 -0
  22. package/dist/action-providers/flaunch/flaunchActionProvider.test.d.ts +1 -0
  23. package/dist/action-providers/flaunch/flaunchActionProvider.test.js +307 -0
  24. package/dist/action-providers/flaunch/index.d.ts +7 -0
  25. package/dist/action-providers/flaunch/index.js +23 -0
  26. package/dist/action-providers/flaunch/schemas.d.ts +77 -0
  27. package/dist/action-providers/flaunch/schemas.js +71 -0
  28. package/dist/action-providers/flaunch/types.d.ts +64 -0
  29. package/dist/action-providers/flaunch/types.js +2 -0
  30. package/dist/action-providers/flaunch/utils.d.ts +60 -0
  31. package/dist/action-providers/flaunch/utils.js +507 -0
  32. package/dist/action-providers/index.d.ts +4 -0
  33. package/dist/action-providers/index.js +4 -0
  34. package/dist/action-providers/messari/constants.d.ts +17 -0
  35. package/dist/action-providers/messari/constants.js +20 -0
  36. package/dist/action-providers/messari/index.d.ts +5 -0
  37. package/dist/action-providers/messari/index.js +21 -0
  38. package/dist/action-providers/messari/messariActionProvider.d.ts +42 -0
  39. package/dist/action-providers/messari/messariActionProvider.js +128 -0
  40. package/dist/action-providers/messari/messariActionProvider.test.d.ts +1 -0
  41. package/dist/action-providers/messari/messariActionProvider.test.js +152 -0
  42. package/dist/action-providers/messari/schemas.d.ts +11 -0
  43. package/dist/action-providers/messari/schemas.js +16 -0
  44. package/dist/action-providers/messari/types.d.ts +40 -0
  45. package/dist/action-providers/messari/types.js +2 -0
  46. package/dist/action-providers/messari/utils.d.ts +22 -0
  47. package/dist/action-providers/messari/utils.js +65 -0
  48. package/dist/action-providers/onramp/index.d.ts +7 -0
  49. package/dist/action-providers/onramp/index.js +23 -0
  50. package/dist/action-providers/onramp/onrampActionProvider.d.ts +56 -0
  51. package/dist/action-providers/onramp/onrampActionProvider.js +109 -0
  52. package/dist/action-providers/onramp/onrampActionProvider.test.d.ts +1 -0
  53. package/dist/action-providers/onramp/onrampActionProvider.test.js +97 -0
  54. package/dist/action-providers/onramp/schemas.d.ts +12 -0
  55. package/dist/action-providers/onramp/schemas.js +15 -0
  56. package/dist/action-providers/onramp/types.d.ts +107 -0
  57. package/dist/action-providers/onramp/types.js +2 -0
  58. package/dist/action-providers/onramp/utils.d.ts +16 -0
  59. package/dist/action-providers/onramp/utils.js +56 -0
  60. package/dist/action-providers/onramp/version.d.ts +2 -0
  61. package/dist/action-providers/onramp/version.js +5 -0
  62. package/dist/wallet-providers/cdpWalletProvider.d.ts +11 -2
  63. package/dist/wallet-providers/cdpWalletProvider.js +44 -10
  64. package/dist/wallet-providers/cdpWalletProvider.test.d.ts +1 -0
  65. package/dist/wallet-providers/cdpWalletProvider.test.js +735 -0
  66. package/dist/wallet-providers/evmWalletProvider.test.d.ts +1 -0
  67. package/dist/wallet-providers/evmWalletProvider.test.js +56 -0
  68. package/dist/wallet-providers/index.d.ts +1 -0
  69. package/dist/wallet-providers/index.js +1 -0
  70. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.d.ts +167 -0
  71. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.js +438 -0
  72. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.test.d.ts +1 -0
  73. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.test.js +280 -0
  74. package/dist/wallet-providers/privyEvmWalletProvider.test.d.ts +1 -0
  75. package/dist/wallet-providers/privyEvmWalletProvider.test.js +331 -0
  76. package/dist/wallet-providers/privyShared.d.ts +9 -0
  77. package/dist/wallet-providers/privyShared.js +16 -5
  78. package/dist/wallet-providers/privySvmWalletProvider.test.d.ts +1 -0
  79. package/dist/wallet-providers/privySvmWalletProvider.test.js +310 -0
  80. package/dist/wallet-providers/privyWalletProvider.d.ts +21 -8
  81. package/dist/wallet-providers/privyWalletProvider.js +39 -7
  82. package/dist/wallet-providers/privyWalletProvider.test.d.ts +1 -0
  83. package/dist/wallet-providers/privyWalletProvider.test.js +124 -0
  84. package/dist/wallet-providers/smartWalletProvider.test.d.ts +1 -0
  85. package/dist/wallet-providers/smartWalletProvider.test.js +388 -0
  86. package/dist/wallet-providers/solanaKeypairWalletProvider.test.js +210 -16
  87. package/dist/wallet-providers/svmWalletProvider.test.d.ts +1 -0
  88. package/dist/wallet-providers/svmWalletProvider.test.js +55 -0
  89. package/dist/wallet-providers/viemWalletProvider.test.d.ts +1 -0
  90. package/dist/wallet-providers/viemWalletProvider.test.js +338 -0
  91. package/dist/wallet-providers/walletProvider.test.d.ts +1 -0
  92. package/dist/wallet-providers/walletProvider.test.js +103 -0
  93. package/package.json +26 -21
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const onrampActionProvider_1 = require("./onrampActionProvider");
4
+ const schemas_1 = require("./schemas");
5
+ describe("OnrampActionProvider", () => {
6
+ const provider = new onrampActionProvider_1.OnrampActionProvider({
7
+ projectId: "test-project-id",
8
+ });
9
+ let mockWalletProvider;
10
+ beforeEach(() => {
11
+ mockWalletProvider = {
12
+ getAddress: jest.fn().mockReturnValue("0x123"),
13
+ getBalance: jest.fn(),
14
+ getName: jest.fn(),
15
+ getNetwork: jest.fn().mockReturnValue({
16
+ protocolFamily: "evm",
17
+ networkId: "base-mainnet",
18
+ }),
19
+ nativeTransfer: jest.fn(),
20
+ };
21
+ });
22
+ describe("network support", () => {
23
+ it("should support valid EVM networks", () => {
24
+ expect(provider.supportsNetwork({
25
+ networkId: "base-mainnet",
26
+ protocolFamily: "evm",
27
+ })).toBe(true);
28
+ });
29
+ it("should not support invalid EVM networks, such as testnets", () => {
30
+ expect(provider.supportsNetwork({
31
+ networkId: "base-sepolia",
32
+ protocolFamily: "evm",
33
+ })).toBe(false);
34
+ });
35
+ it("should not support other protocol families", () => {
36
+ expect(provider.supportsNetwork({
37
+ protocolFamily: "other-protocol-family",
38
+ })).toBe(false);
39
+ });
40
+ it("should handle invalid network objects", () => {
41
+ expect(provider.supportsNetwork({})).toBe(false);
42
+ });
43
+ });
44
+ describe("action validation", () => {
45
+ it("should validate getOnrampBuyUrl schema", () => {
46
+ const validInput = {};
47
+ const parseResult = schemas_1.GetOnrampBuyUrlActionSchema.safeParse(validInput);
48
+ expect(parseResult.success).toBe(true);
49
+ });
50
+ });
51
+ describe("getOnrampBuyUrl", () => {
52
+ beforeEach(() => {
53
+ mockWalletProvider.getAddress.mockReturnValue("0x123");
54
+ });
55
+ /**
56
+ * Parses URL search parameters from a URL string.
57
+ *
58
+ * @param url - The URL string to parse parameters from
59
+ * @returns The parsed URL search parameters
60
+ */
61
+ function parseUrlParams(url) {
62
+ const urlObj = new URL(url);
63
+ return urlObj.searchParams;
64
+ }
65
+ it("should execute getOnrampBuyUrl with wallet provider", async () => {
66
+ const result = await provider.getOnrampBuyUrl(mockWalletProvider, {});
67
+ const url = new URL(result);
68
+ const params = parseUrlParams(result);
69
+ // Verify base URL
70
+ expect(url.origin + url.pathname).toBe("https://pay.coinbase.com/buy");
71
+ // Verify all expected parameters are present with correct values
72
+ expect(params.get("appId")).toBe("test-project-id");
73
+ expect(params.get("defaultNetwork")).toBe("base");
74
+ // Verify address configuration
75
+ const addressConfig = JSON.parse(params.get("addresses") || "{}");
76
+ expect(addressConfig).toEqual({
77
+ "0x123": ["base"],
78
+ });
79
+ expect(mockWalletProvider.getNetwork).toHaveBeenCalled();
80
+ expect(mockWalletProvider.getAddress).toHaveBeenCalled();
81
+ });
82
+ it("should throw error for unsupported network", async () => {
83
+ mockWalletProvider.getNetwork.mockReturnValue({
84
+ protocolFamily: "evm",
85
+ networkId: "unsupported-network",
86
+ });
87
+ await expect(provider.getOnrampBuyUrl(mockWalletProvider, {})).rejects.toThrow("Network ID is not supported. Make sure you are using a supported mainnet network.");
88
+ });
89
+ it("should throw error when network ID is not set", async () => {
90
+ mockWalletProvider.getNetwork.mockReturnValue({
91
+ protocolFamily: "evm",
92
+ networkId: undefined,
93
+ });
94
+ await expect(provider.getOnrampBuyUrl(mockWalletProvider, {})).rejects.toThrow("Network ID is not set");
95
+ });
96
+ });
97
+ });
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Action schemas for the onramp action provider.
4
+ *
5
+ * This file contains the Zod schemas that define the shape and validation
6
+ * rules for action parameters in the onramp action provider.
7
+ */
8
+ /**
9
+ * Example action schema demonstrating various field types and validations.
10
+ * Replace or modify this with your actual action schemas.
11
+ */
12
+ export declare const GetOnrampBuyUrlActionSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetOnrampBuyUrlActionSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Action schemas for the onramp action provider.
7
+ *
8
+ * This file contains the Zod schemas that define the shape and validation
9
+ * rules for action parameters in the onramp action provider.
10
+ */
11
+ /**
12
+ * Example action schema demonstrating various field types and validations.
13
+ * Replace or modify this with your actual action schemas.
14
+ */
15
+ exports.GetOnrampBuyUrlActionSchema = zod_1.z.object({});
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Props used to get an Onramp buy URL by directly providing a CDP project ID.
3
+ * See https://docs.cdp.coinbase.com/onramp/docs/api-initializing#generating-the-coinbase-onramp-buysell-url
4
+ *
5
+ * Note: exported as public Type
6
+ */
7
+ export type GetOnrampUrlWithProjectIdParams = {
8
+ /**
9
+ * The Project ID of your CDP project created at https://portal.cdp.coinbase.com/
10
+ * This must be provided if you don't provide a sessionToken.
11
+ */
12
+ projectId: string;
13
+ sessionToken?: never;
14
+ /**
15
+ * The addresses that the customer's funds should be delivered to.
16
+ *
17
+ * Each entry in the record represents a wallet address and the networks it is valid for. There should only be a
18
+ * single address for each network your app supports. Users will be able to buy/send any asset supported by any of
19
+ * the networks you specify. See the assets param if you want to restrict the available assets.
20
+ *
21
+ * Some common examples:
22
+ *
23
+ * Support all assets that are available for sending on the base network, only on the base network:
24
+ *
25
+ * `{ "0x1": ["base"] }`
26
+ */
27
+ addresses: Record<string, string[]>;
28
+ /**
29
+ * This optional parameter will restrict the assets available for the user to buy/send. It acts as a filter on the
30
+ * networks specified in the {addresses} param.
31
+ *
32
+ * Some common examples:
33
+ *
34
+ * Support only USDC on either the base network or the ethereum network:
35
+ *
36
+ * `addresses: { "0x1": ["base", "ethereum"] }, assets: ["USDC"]`
37
+ *
38
+ * The values in this list can either be asset symbols like BTC, ETH, or asset UUIDs that you can get from the Buy
39
+ * Options API {@link https://docs.cdp.coinbase.com/onramp/docs/api-configurations/#buy-options}.
40
+ */
41
+ assets?: string[];
42
+ } & GetOnrampBuyUrlOptionalProps;
43
+ /**
44
+ * Props used to get an Onramp buy URL using a session token created using the Onramp session token API.
45
+ * See https://docs.cdp.coinbase.com/onramp/docs/api-initializing#getting-an-coinbase-onramp-buysell-session-token
46
+ *
47
+ * Note: exported as public Type
48
+ */
49
+ export type GetOnrampUrlWithSessionTokenParams = {
50
+ /**
51
+ * A session token create using the Onramp session token API. The token will be linked to the project ID, addresses,
52
+ * and assets params provided in the create session token API request.
53
+ */
54
+ sessionToken: string;
55
+ projectId?: never;
56
+ addresses?: never;
57
+ assets?: never;
58
+ } & GetOnrampBuyUrlOptionalProps;
59
+ /**
60
+ * The optional properties that can be used to create an Onramp buy URL.
61
+ */
62
+ type GetOnrampBuyUrlOptionalProps = {
63
+ /**
64
+ * If specified, this asset will be automatically selected for the user in the Onramp UI. Should be a valid asset
65
+ * symbol e.g. BTC, ETH, USDC.
66
+ */
67
+ defaultAsset?: string;
68
+ /**
69
+ * If specified, this network will be automatically selected for the user in the Onramp UI. Should be a valid network
70
+ * name in lower case e.g. ethereum, base.
71
+ */
72
+ defaultNetwork?: string;
73
+ /**
74
+ * A unique identifier that will be associated with any transactions created by the user during their Onramp session.
75
+ * You can use this with the Transaction Status API to check the status of the user's transaction.
76
+ * See https://docs.cdp.coinbase.com/onramp/docs/api-reporting#buy-transaction-status
77
+ */
78
+ partnerUserId?: string;
79
+ /**
80
+ * This amount will be used to pre-fill the amount of crypto the user is buying or sending. The user can choose to
81
+ * change this amount in the UI. Only one of presetCryptoAmount or presetFiatAmount should be provided.
82
+ */
83
+ presetCryptoAmount?: number;
84
+ /**
85
+ * This amount will be used to pre-fill the fiat value of the crypto the user is buying or sending. The user can
86
+ * choose to change this amount in the UI. Only one of presetCryptoAmount or presetFiatAmount should be provided.
87
+ */
88
+ presetFiatAmount?: number;
89
+ /**
90
+ * The default payment method that will be selected for the user in the Onramp UI. Should be one of the payment methods
91
+ */
92
+ defaultPaymentMethod?: string;
93
+ /**
94
+ * The currency code of the fiat amount provided in the presetFiatAmount param e.g. USD, CAD, EUR.
95
+ */
96
+ fiatCurrency?: string;
97
+ /**
98
+ * A URL that the user will be automatically redirected to after a successful buy/send. The domain must match a domain
99
+ * on the domain allowlist in Coinbase Developer Platform (https://portal.cdp.coinbase.com/products/onramp).
100
+ */
101
+ redirectUrl?: string;
102
+ /**
103
+ * The name of the component that is calling the Onramp buy URL. This will be used for analytics.
104
+ */
105
+ originComponentName?: string;
106
+ };
107
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ import type { GetOnrampUrlWithProjectIdParams, GetOnrampUrlWithSessionTokenParams } from "./types";
2
+ /**
3
+ * Builds a Coinbase Onramp buy URL using the provided parameters.
4
+ *
5
+ * @param props - Configuration options for the Onramp buy URL
6
+ * @param props.projectId - A projectId generated in the Coinbase Developer Portal
7
+ * @returns The generated Onramp buy URL
8
+ */
9
+ export declare function getOnrampBuyUrl({ projectId, ...props }: GetOnrampUrlWithProjectIdParams | GetOnrampUrlWithSessionTokenParams): string;
10
+ /**
11
+ * Converts a network ID to an Onramp network ID.
12
+ *
13
+ * @param networkId - The network ID to convert
14
+ * @returns The Onramp network ID or null if the network ID is not supported
15
+ */
16
+ export declare const convertNetworkIdToOnrampNetworkId: (networkId: string) => string | null;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertNetworkIdToOnrampNetworkId = void 0;
4
+ exports.getOnrampBuyUrl = getOnrampBuyUrl;
5
+ const version_1 = require("./version");
6
+ /**
7
+ * Builds a Coinbase Onramp buy URL using the provided parameters.
8
+ *
9
+ * @param props - Configuration options for the Onramp buy URL
10
+ * @param props.projectId - A projectId generated in the Coinbase Developer Portal
11
+ * @returns The generated Onramp buy URL
12
+ */
13
+ function getOnrampBuyUrl({ projectId, ...props }) {
14
+ const url = new URL(version_1.ONRAMP_BUY_URL);
15
+ if (projectId !== undefined) {
16
+ // Coinbase Onramp requires projectId to be passed as appId
17
+ url.searchParams.append("appId", projectId);
18
+ }
19
+ for (const key of Object.keys(props)) {
20
+ const value = props[key];
21
+ if (value !== undefined) {
22
+ if (["string", "number", "boolean"].includes(typeof value)) {
23
+ url.searchParams.append(key, value.toString());
24
+ }
25
+ else {
26
+ url.searchParams.append(key, JSON.stringify(value));
27
+ }
28
+ }
29
+ }
30
+ url.searchParams.append("sdkVersion", `onchainkit@${version_1.VERSION}`);
31
+ url.searchParams.sort();
32
+ return url.toString();
33
+ }
34
+ /**
35
+ * Converts a network ID to an Onramp network ID.
36
+ *
37
+ * @param networkId - The network ID to convert
38
+ * @returns The Onramp network ID or null if the network ID is not supported
39
+ */
40
+ const convertNetworkIdToOnrampNetworkId = (networkId) => {
41
+ switch (networkId) {
42
+ case "base-mainnet":
43
+ return "base";
44
+ case "ethereum-mainnet":
45
+ return "ethereum";
46
+ case "polygon-mainnet":
47
+ return "polygon";
48
+ case "optimism-mainnet":
49
+ return "optimism";
50
+ case "arbitrum-mainnet":
51
+ return "arbitrum";
52
+ default:
53
+ return null;
54
+ }
55
+ };
56
+ exports.convertNetworkIdToOnrampNetworkId = convertNetworkIdToOnrampNetworkId;
@@ -0,0 +1,2 @@
1
+ export declare const VERSION = "0.38.2";
2
+ export declare const ONRAMP_BUY_URL = "https://pay.coinbase.com/buy";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ONRAMP_BUY_URL = exports.VERSION = void 0;
4
+ exports.VERSION = "0.38.2";
5
+ exports.ONRAMP_BUY_URL = "https://pay.coinbase.com/buy";
@@ -1,7 +1,7 @@
1
- import { ReadContractParameters, ReadContractReturnType, TransactionRequest, TransactionSerializable, Abi, ContractFunctionName, ContractFunctionArgs } from "viem";
1
+ import { ReadContractParameters, ReadContractReturnType, TransactionRequest, TransactionSerializable, Abi, ContractFunctionName, ContractFunctionArgs, Address, Hex } from "viem";
2
2
  import { EvmWalletProvider } from "./evmWalletProvider";
3
3
  import { Network } from "../network";
4
- import { CreateERC20Options, CreateTradeOptions, SmartContract, Trade, Wallet, WalletData } from "@coinbase/coinbase-sdk";
4
+ import { Coinbase, CreateERC20Options, CreateTradeOptions, SmartContract, Trade, Wallet, WalletData } from "@coinbase/coinbase-sdk";
5
5
  /**
6
6
  * Configuration options for the CDP Providers.
7
7
  */
@@ -233,5 +233,14 @@ export declare class CdpWalletProvider extends EvmWalletProvider {
233
233
  * @returns The wallet.
234
234
  */
235
235
  getWallet(): Wallet;
236
+ /**
237
+ * ERC20 transfer method
238
+ *
239
+ * @param assetId - The asset ID to transfer. Either USDC, CBBTC or EURC
240
+ * @param destination - The destination address
241
+ * @param amount - The amount to transfer
242
+ * @returns The transaction hash
243
+ */
244
+ gaslessERC20Transfer(assetId: typeof Coinbase.assets.Usdc | typeof Coinbase.assets.Cbbtc | typeof Coinbase.assets.Eurc, destination: Address, amount: bigint): Promise<Hex>;
236
245
  }
237
246
  export {};
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _CdpWalletProvider_cdpWallet, _CdpWalletProvider_address, _CdpWalletProvider_network, _CdpWalletProvider_publicClient, _CdpWalletProvider_gasLimitMultiplier, _CdpWalletProvider_feePerGasMultiplier;
13
+ var _CdpWalletProvider_cdpWallet, _CdpWalletProvider_address, _CdpWalletProvider_network, _CdpWalletProvider_publicClient, _CdpWalletProvider_gasLimitMultiplier, _CdpWalletProvider_feePerGasMultiplier, _CdpWalletProvider_transactionQueue;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.CdpWalletProvider = void 0;
16
16
  const package_json_1 = require("../../package.json");
@@ -37,6 +37,7 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
37
37
  _CdpWalletProvider_publicClient.set(this, void 0);
38
38
  _CdpWalletProvider_gasLimitMultiplier.set(this, void 0);
39
39
  _CdpWalletProvider_feePerGasMultiplier.set(this, void 0);
40
+ _CdpWalletProvider_transactionQueue.set(this, void 0);
40
41
  __classPrivateFieldSet(this, _CdpWalletProvider_cdpWallet, config.wallet, "f");
41
42
  __classPrivateFieldSet(this, _CdpWalletProvider_address, config.address, "f");
42
43
  __classPrivateFieldSet(this, _CdpWalletProvider_network, config.network, "f");
@@ -165,14 +166,22 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
165
166
  if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
166
167
  throw new Error("Wallet not initialized");
167
168
  }
168
- const preparedTransaction = await this.prepareTransaction(transaction.to, transaction.value, transaction.data);
169
- const signature = await this.signTransaction({
170
- ...preparedTransaction,
171
- });
172
- const signedPayload = await this.addSignatureAndSerialize(preparedTransaction, signature);
173
- const externalAddress = new coinbase_sdk_1.ExternalAddress(__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").getNetworkId(), __classPrivateFieldGet(this, _CdpWalletProvider_address, "f"));
174
- const tx = await externalAddress.broadcastExternalTransaction(signedPayload.slice(2));
175
- return tx.transactionHash;
169
+ const sendPromise = (async () => {
170
+ if (__classPrivateFieldGet(this, _CdpWalletProvider_transactionQueue, "f"))
171
+ await __classPrivateFieldGet(this, _CdpWalletProvider_transactionQueue, "f");
172
+ const preparedTransaction = await this.prepareTransaction(transaction.to, transaction.value, transaction.data);
173
+ const signature = await this.signTransaction({
174
+ ...preparedTransaction,
175
+ });
176
+ const signedPayload = await this.addSignatureAndSerialize(preparedTransaction, signature);
177
+ const externalAddress = new coinbase_sdk_1.ExternalAddress(__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").getNetworkId(), __classPrivateFieldGet(this, _CdpWalletProvider_address, "f"));
178
+ const tx = await externalAddress.broadcastExternalTransaction(signedPayload.slice(2));
179
+ return tx.transactionHash;
180
+ })();
181
+ __classPrivateFieldSet(this, _CdpWalletProvider_transactionQueue, sendPromise
182
+ .then(txHash => this.waitForTransactionReceipt(txHash))
183
+ .catch(() => { }), "f");
184
+ return await sendPromise;
176
185
  }
177
186
  /**
178
187
  * Prepares a transaction.
@@ -188,6 +197,7 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
188
197
  }
189
198
  const nonce = await __classPrivateFieldGet(this, _CdpWalletProvider_publicClient, "f").getTransactionCount({
190
199
  address: __classPrivateFieldGet(this, _CdpWalletProvider_address, "f"),
200
+ blockTag: "pending",
191
201
  });
192
202
  const feeData = await __classPrivateFieldGet(this, _CdpWalletProvider_publicClient, "f").estimateFeesPerGas();
193
203
  const maxFeePerGas = (0, utils_1.applyGasMultiplier)(feeData.maxFeePerGas, __classPrivateFieldGet(this, _CdpWalletProvider_feePerGasMultiplier, "f"));
@@ -392,6 +402,30 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
392
402
  }
393
403
  return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f");
394
404
  }
405
+ /**
406
+ * ERC20 transfer method
407
+ *
408
+ * @param assetId - The asset ID to transfer. Either USDC, CBBTC or EURC
409
+ * @param destination - The destination address
410
+ * @param amount - The amount to transfer
411
+ * @returns The transaction hash
412
+ */
413
+ async gaslessERC20Transfer(assetId, destination, amount) {
414
+ if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
415
+ throw new Error("Wallet not initialized");
416
+ }
417
+ const transferResult = await __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").createTransfer({
418
+ amount,
419
+ assetId,
420
+ destination,
421
+ gasless: true,
422
+ });
423
+ const result = await transferResult.wait();
424
+ if (!result.getTransactionHash()) {
425
+ throw new Error("Transaction hash not found");
426
+ }
427
+ return result.getTransactionHash();
428
+ }
395
429
  }
396
430
  exports.CdpWalletProvider = CdpWalletProvider;
397
- _CdpWalletProvider_cdpWallet = new WeakMap(), _CdpWalletProvider_address = new WeakMap(), _CdpWalletProvider_network = new WeakMap(), _CdpWalletProvider_publicClient = new WeakMap(), _CdpWalletProvider_gasLimitMultiplier = new WeakMap(), _CdpWalletProvider_feePerGasMultiplier = new WeakMap();
431
+ _CdpWalletProvider_cdpWallet = new WeakMap(), _CdpWalletProvider_address = new WeakMap(), _CdpWalletProvider_network = new WeakMap(), _CdpWalletProvider_publicClient = new WeakMap(), _CdpWalletProvider_gasLimitMultiplier = new WeakMap(), _CdpWalletProvider_feePerGasMultiplier = new WeakMap(), _CdpWalletProvider_transactionQueue = new WeakMap();
@@ -0,0 +1 @@
1
+ export {};