@coinbase/agentkit 0.0.0-nightly-20250724210458 → 0.0.0-nightly-20250806210443
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/README.md +22 -0
- package/dist/action-providers/cdp/cdpApiActionProvider.js +2 -0
- package/dist/action-providers/index.d.ts +2 -0
- package/dist/action-providers/index.js +2 -0
- package/dist/action-providers/truemarkets/constants.d.ts +179 -0
- package/dist/action-providers/truemarkets/constants.js +46 -0
- package/dist/action-providers/truemarkets/index.d.ts +1 -0
- package/dist/action-providers/truemarkets/index.js +17 -0
- package/dist/action-providers/truemarkets/schemas.d.ts +21 -0
- package/dist/action-providers/truemarkets/schemas.js +29 -0
- package/dist/action-providers/truemarkets/truemarketsActionProvider.d.ts +51 -0
- package/dist/action-providers/truemarkets/truemarketsActionProvider.js +469 -0
- package/dist/action-providers/truemarkets/truemarketsActionProvider.test.d.ts +1 -0
- package/dist/action-providers/truemarkets/truemarketsActionProvider.test.js +217 -0
- package/dist/action-providers/truemarkets/utils.d.ts +10 -0
- package/dist/action-providers/truemarkets/utils.js +9 -0
- package/dist/action-providers/zora/index.d.ts +3 -0
- package/dist/action-providers/zora/index.js +19 -0
- package/dist/action-providers/zora/schemas.d.ts +29 -0
- package/dist/action-providers/zora/schemas.js +31 -0
- package/dist/action-providers/zora/utils.d.ts +28 -0
- package/dist/action-providers/zora/utils.js +200 -0
- package/dist/action-providers/zora/zoraActionProvider.d.ts +36 -0
- package/dist/action-providers/zora/zoraActionProvider.js +151 -0
- package/dist/action-providers/zora/zoraActionProvider.test.d.ts +1 -0
- package/dist/action-providers/zora/zoraActionProvider.test.js +205 -0
- package/dist/wallet-providers/cdpShared.d.ts +4 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +6 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.js +15 -2
- package/package.json +2 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
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");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var _ZoraActionProvider_pinataJwt;
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.zoraActionProvider = exports.ZoraActionProvider = void 0;
|
|
25
|
+
const zod_1 = require("zod");
|
|
26
|
+
const actionProvider_1 = require("../actionProvider");
|
|
27
|
+
const evmWalletProvider_1 = require("../../wallet-providers/evmWalletProvider");
|
|
28
|
+
const schemas_1 = require("./schemas");
|
|
29
|
+
const actionDecorator_1 = require("../actionDecorator");
|
|
30
|
+
const viem_1 = require("viem");
|
|
31
|
+
const utils_1 = require("./utils");
|
|
32
|
+
const SUPPORTED_NETWORKS = ["base-mainnet", "base-sepolia"];
|
|
33
|
+
/**
|
|
34
|
+
* ZoraActionProvider provides actions for interacting with the Zora protocol.
|
|
35
|
+
*/
|
|
36
|
+
class ZoraActionProvider extends actionProvider_1.ActionProvider {
|
|
37
|
+
/**
|
|
38
|
+
* Constructor for the ZoraActionProvider.
|
|
39
|
+
*/
|
|
40
|
+
constructor() {
|
|
41
|
+
super("zora", []);
|
|
42
|
+
_ZoraActionProvider_pinataJwt.set(this, void 0);
|
|
43
|
+
/**
|
|
44
|
+
* Checks if the Zora action provider supports the given network.
|
|
45
|
+
*
|
|
46
|
+
* @param network - The network to check.
|
|
47
|
+
* @returns True if the Zora action provider supports the network, false otherwise.
|
|
48
|
+
*/
|
|
49
|
+
this.supportsNetwork = (network) => network.protocolFamily === "evm" && SUPPORTED_NETWORKS.includes(network.networkId);
|
|
50
|
+
// Set Pinata JWT
|
|
51
|
+
const pinataJwt = process.env.PINATA_JWT;
|
|
52
|
+
if (!pinataJwt) {
|
|
53
|
+
throw new Error("PINATA_JWT is not configured. Required for IPFS uploads.");
|
|
54
|
+
}
|
|
55
|
+
__classPrivateFieldSet(this, _ZoraActionProvider_pinataJwt, pinataJwt, "f");
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Creates a new Zora coin.
|
|
59
|
+
*
|
|
60
|
+
* @param walletProvider - The wallet provider to use for the transaction.
|
|
61
|
+
* @param args - The input arguments for the action.
|
|
62
|
+
* @returns A message containing the coin creation details.
|
|
63
|
+
*/
|
|
64
|
+
async createCoin(walletProvider, args) {
|
|
65
|
+
try {
|
|
66
|
+
// Generate token URI from local file or URI
|
|
67
|
+
const { uri, imageUri } = await (0, utils_1.generateZoraTokenUri)({
|
|
68
|
+
name: args.name,
|
|
69
|
+
symbol: args.symbol,
|
|
70
|
+
description: args.description,
|
|
71
|
+
image: args.image,
|
|
72
|
+
category: args.category,
|
|
73
|
+
pinataConfig: { jwt: __classPrivateFieldGet(this, _ZoraActionProvider_pinataJwt, "f") },
|
|
74
|
+
});
|
|
75
|
+
// Dynamically import Zora SDK
|
|
76
|
+
const { createCoinCall, DeployCurrency, getCoinCreateFromLogs } = await import("@zoralabs/coins-sdk");
|
|
77
|
+
// Create coin call
|
|
78
|
+
const call = {
|
|
79
|
+
name: args.name,
|
|
80
|
+
symbol: args.symbol,
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
|
+
uri: uri,
|
|
83
|
+
payoutRecipient: args.payoutRecipient || walletProvider.getAddress(),
|
|
84
|
+
platformReferrer: args.platformReferrer || "0x0000000000000000000000000000000000000000",
|
|
85
|
+
currency: args.currency === "ZORA" ? DeployCurrency.ZORA : DeployCurrency.ETH,
|
|
86
|
+
};
|
|
87
|
+
const createCoinRequest = await createCoinCall(call);
|
|
88
|
+
const { abi, functionName, address, args: callArgs, value } = createCoinRequest;
|
|
89
|
+
const data = (0, viem_1.encodeFunctionData)({ abi, functionName, args: callArgs });
|
|
90
|
+
const txRequest = { to: address, data, value };
|
|
91
|
+
// Send transaction
|
|
92
|
+
const hash = await walletProvider.sendTransaction(txRequest);
|
|
93
|
+
const receipt = await walletProvider.waitForTransactionReceipt(hash);
|
|
94
|
+
const deployment = getCoinCreateFromLogs(receipt);
|
|
95
|
+
if (receipt.status === "success") {
|
|
96
|
+
return JSON.stringify({
|
|
97
|
+
success: true,
|
|
98
|
+
transactionHash: hash,
|
|
99
|
+
coinAddress: deployment?.coin,
|
|
100
|
+
imageUri,
|
|
101
|
+
uri,
|
|
102
|
+
deployment,
|
|
103
|
+
...(walletProvider.getNetwork().networkId === "base-mainnet" &&
|
|
104
|
+
deployment?.coin && {
|
|
105
|
+
zoraURL: `https://zora.co/coin/base:${deployment.coin}`,
|
|
106
|
+
}),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
throw new Error("Coin creation transaction reverted");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
return JSON.stringify({
|
|
115
|
+
success: false,
|
|
116
|
+
error: error instanceof Error ? error.message : String(error),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.ZoraActionProvider = ZoraActionProvider;
|
|
122
|
+
_ZoraActionProvider_pinataJwt = new WeakMap();
|
|
123
|
+
__decorate([
|
|
124
|
+
(0, actionDecorator_1.CreateAction)({
|
|
125
|
+
name: "coinIt",
|
|
126
|
+
description: `
|
|
127
|
+
This tool will create a new Zora coin.
|
|
128
|
+
It takes the following parameters:
|
|
129
|
+
- name: The name of the coin
|
|
130
|
+
- symbol: The symbol of the coin
|
|
131
|
+
- image: Local image file path or URI (ipfs:// or https://)
|
|
132
|
+
- description: The description of the coin
|
|
133
|
+
- payoutRecipient: The address that will receive creator earnings (optional, defaults to the wallet address)
|
|
134
|
+
- platformReferrer: The address that will receive platform referrer fees (optional, defaults to 0x0000000000000000000000000000000000000000)
|
|
135
|
+
- category: The category of the coin (optional, defaults to 'social')
|
|
136
|
+
- currency: The currency for deployment, can be 'ZORA' or 'ETH'. Determines which token will be used for the trading pair (optional, defaults to 'ZORA').
|
|
137
|
+
The action will return the transaction hash, coin address, and deployment details upon success.
|
|
138
|
+
`,
|
|
139
|
+
schema: schemas_1.CreateCoinSchema,
|
|
140
|
+
}),
|
|
141
|
+
__metadata("design:type", Function),
|
|
142
|
+
__metadata("design:paramtypes", [evmWalletProvider_1.EvmWalletProvider, void 0]),
|
|
143
|
+
__metadata("design:returntype", Promise)
|
|
144
|
+
], ZoraActionProvider.prototype, "createCoin", null);
|
|
145
|
+
/**
|
|
146
|
+
* Factory function to create a new ZoraActionProvider instance.
|
|
147
|
+
*
|
|
148
|
+
* @returns A new ZoraActionProvider instance
|
|
149
|
+
*/
|
|
150
|
+
const zoraActionProvider = () => new ZoraActionProvider();
|
|
151
|
+
exports.zoraActionProvider = zoraActionProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const zoraActionProvider_1 = require("./zoraActionProvider");
|
|
4
|
+
const schemas_1 = require("./schemas");
|
|
5
|
+
// Mock viem's encodeFunctionData function to prevent ABI errors
|
|
6
|
+
jest.mock("viem", () => {
|
|
7
|
+
const originalModule = jest.requireActual("viem");
|
|
8
|
+
return {
|
|
9
|
+
...originalModule,
|
|
10
|
+
encodeFunctionData: jest.fn().mockReturnValue("0x1234"),
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
// Mock the dynamically imported Zora SDK
|
|
14
|
+
jest.mock("@zoralabs/coins-sdk", () => ({
|
|
15
|
+
createCoinCall: jest.fn().mockResolvedValue({
|
|
16
|
+
abi: [{ name: "createCoin" }], // Add a minimal abi to prevent "function not found" error
|
|
17
|
+
functionName: "createCoin",
|
|
18
|
+
address: "0x1234567890123456789012345678901234567890",
|
|
19
|
+
args: [],
|
|
20
|
+
value: BigInt(0),
|
|
21
|
+
}),
|
|
22
|
+
getCoinCreateFromLogs: jest.fn().mockReturnValue({
|
|
23
|
+
coin: "0x2345678901234567890123456789012345678901",
|
|
24
|
+
}),
|
|
25
|
+
DeployCurrency: {
|
|
26
|
+
ZORA: "ZORA",
|
|
27
|
+
ETH: "ETH",
|
|
28
|
+
},
|
|
29
|
+
}), { virtual: true });
|
|
30
|
+
// Mock the utils module
|
|
31
|
+
jest.mock("./utils", () => ({
|
|
32
|
+
generateZoraTokenUri: jest.fn().mockResolvedValue({
|
|
33
|
+
uri: "ipfs://testCID",
|
|
34
|
+
imageUri: "ipfs://testImageCID",
|
|
35
|
+
}),
|
|
36
|
+
}));
|
|
37
|
+
describe("ZoraActionProvider", () => {
|
|
38
|
+
const MOCK_TX_HASH = "0xabcdef1234567890";
|
|
39
|
+
const MOCK_ADDRESS = "0x9876543210987654321098765432109876543210";
|
|
40
|
+
let provider;
|
|
41
|
+
let mockWalletProvider;
|
|
42
|
+
let originalPinataJwt;
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
// Reset mocks between tests
|
|
45
|
+
jest.clearAllMocks();
|
|
46
|
+
originalPinataJwt = process.env.PINATA_JWT;
|
|
47
|
+
process.env.PINATA_JWT = "test-jwt";
|
|
48
|
+
// Create the provider
|
|
49
|
+
provider = new zoraActionProvider_1.ZoraActionProvider();
|
|
50
|
+
// Set up the mock wallet provider
|
|
51
|
+
mockWalletProvider = {
|
|
52
|
+
getAddress: jest.fn().mockReturnValue(MOCK_ADDRESS),
|
|
53
|
+
getNetwork: jest.fn().mockReturnValue({
|
|
54
|
+
protocolFamily: "evm",
|
|
55
|
+
networkId: "base-sepolia",
|
|
56
|
+
}),
|
|
57
|
+
sendTransaction: jest.fn().mockResolvedValue(MOCK_TX_HASH),
|
|
58
|
+
waitForTransactionReceipt: jest.fn().mockResolvedValue({
|
|
59
|
+
status: "success",
|
|
60
|
+
logs: [],
|
|
61
|
+
}),
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
afterEach(() => {
|
|
65
|
+
process.env.PINATA_JWT = originalPinataJwt;
|
|
66
|
+
});
|
|
67
|
+
describe("constructor", () => {
|
|
68
|
+
it("should throw an error if Pinata JWT is not provided", () => {
|
|
69
|
+
delete process.env.PINATA_JWT;
|
|
70
|
+
expect(() => new zoraActionProvider_1.ZoraActionProvider()).toThrow("PINATA_JWT is not configured. Required for IPFS uploads.");
|
|
71
|
+
});
|
|
72
|
+
it("should create provider with Pinata JWT from environment", () => {
|
|
73
|
+
expect(new zoraActionProvider_1.ZoraActionProvider()).toBeInstanceOf(zoraActionProvider_1.ZoraActionProvider);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe("supportsNetwork", () => {
|
|
77
|
+
const testCases = [
|
|
78
|
+
{ network: { protocolFamily: "evm", networkId: "base-mainnet" }, expected: true },
|
|
79
|
+
{ network: { protocolFamily: "evm", networkId: "base-sepolia" }, expected: true },
|
|
80
|
+
{ network: { protocolFamily: "evm", networkId: "ethereum" }, expected: false },
|
|
81
|
+
{ network: { protocolFamily: "solana", networkId: "base-mainnet" }, expected: false },
|
|
82
|
+
];
|
|
83
|
+
testCases.forEach(({ network, expected }) => {
|
|
84
|
+
it(`should ${expected ? "support" : "not support"} ${network.protocolFamily}/${network.networkId}`, () => {
|
|
85
|
+
expect(provider.supportsNetwork(network)).toBe(expected);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
describe("createCoin", () => {
|
|
90
|
+
it("should validate createCoin schema", () => {
|
|
91
|
+
const validInput = {
|
|
92
|
+
name: "Test Coin",
|
|
93
|
+
symbol: "TEST",
|
|
94
|
+
description: "A test coin",
|
|
95
|
+
image: "https://example.com/image.png",
|
|
96
|
+
category: "social",
|
|
97
|
+
currency: "ZORA",
|
|
98
|
+
};
|
|
99
|
+
const parseResult = schemas_1.CreateCoinSchema.safeParse(validInput);
|
|
100
|
+
expect(parseResult.success).toBe(true);
|
|
101
|
+
});
|
|
102
|
+
it("should reject invalid input", () => {
|
|
103
|
+
const invalidInput = {
|
|
104
|
+
name: "Test Coin",
|
|
105
|
+
symbol: "TEST",
|
|
106
|
+
description: "A test coin",
|
|
107
|
+
image: "https://example.com/image.png",
|
|
108
|
+
category: "social",
|
|
109
|
+
currency: "ZORA",
|
|
110
|
+
payoutRecipient: "invalid-address", // Should be 0x format
|
|
111
|
+
};
|
|
112
|
+
const parseResult = schemas_1.CreateCoinSchema.safeParse(invalidInput);
|
|
113
|
+
expect(parseResult.success).toBe(false);
|
|
114
|
+
});
|
|
115
|
+
it("should successfully create a coin", async () => {
|
|
116
|
+
const args = {
|
|
117
|
+
name: "Test Coin",
|
|
118
|
+
symbol: "TEST",
|
|
119
|
+
description: "A test coin",
|
|
120
|
+
image: "https://example.com/image.png",
|
|
121
|
+
category: "social",
|
|
122
|
+
currency: "ZORA",
|
|
123
|
+
};
|
|
124
|
+
const result = await provider.createCoin(mockWalletProvider, args);
|
|
125
|
+
const parsedResult = JSON.parse(result);
|
|
126
|
+
expect(mockWalletProvider.sendTransaction).toHaveBeenCalled();
|
|
127
|
+
expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalledWith(MOCK_TX_HASH);
|
|
128
|
+
expect(parsedResult.success).toBe(true);
|
|
129
|
+
expect(parsedResult.transactionHash).toBe(MOCK_TX_HASH);
|
|
130
|
+
expect(parsedResult.coinAddress).toBe("0x2345678901234567890123456789012345678901");
|
|
131
|
+
});
|
|
132
|
+
it("should include zoraURL for base-mainnet network", async () => {
|
|
133
|
+
// Mock wallet provider to return base-mainnet network
|
|
134
|
+
mockWalletProvider.getNetwork.mockReturnValue({
|
|
135
|
+
protocolFamily: "evm",
|
|
136
|
+
networkId: "base-mainnet",
|
|
137
|
+
});
|
|
138
|
+
const args = {
|
|
139
|
+
name: "Test Coin",
|
|
140
|
+
symbol: "TEST",
|
|
141
|
+
description: "A test coin",
|
|
142
|
+
image: "https://example.com/image.png",
|
|
143
|
+
category: "social",
|
|
144
|
+
currency: "ZORA",
|
|
145
|
+
};
|
|
146
|
+
const result = await provider.createCoin(mockWalletProvider, args);
|
|
147
|
+
const parsedResult = JSON.parse(result);
|
|
148
|
+
expect(parsedResult.success).toBe(true);
|
|
149
|
+
expect(parsedResult.coinAddress).toBe("0x2345678901234567890123456789012345678901");
|
|
150
|
+
expect(parsedResult.zoraURL).toBe("https://zora.co/coin/base:0x2345678901234567890123456789012345678901");
|
|
151
|
+
});
|
|
152
|
+
it("should not include zoraURL for non-base-mainnet networks", async () => {
|
|
153
|
+
// Keep the default base-sepolia network from beforeEach
|
|
154
|
+
const args = {
|
|
155
|
+
name: "Test Coin",
|
|
156
|
+
symbol: "TEST",
|
|
157
|
+
description: "A test coin",
|
|
158
|
+
image: "https://example.com/image.png",
|
|
159
|
+
category: "social",
|
|
160
|
+
currency: "ZORA",
|
|
161
|
+
};
|
|
162
|
+
const result = await provider.createCoin(mockWalletProvider, args);
|
|
163
|
+
const parsedResult = JSON.parse(result);
|
|
164
|
+
expect(parsedResult.success).toBe(true);
|
|
165
|
+
expect(parsedResult.coinAddress).toBe("0x2345678901234567890123456789012345678901");
|
|
166
|
+
expect(parsedResult.zoraURL).toBeUndefined();
|
|
167
|
+
});
|
|
168
|
+
it("should handle transaction failure", async () => {
|
|
169
|
+
const args = {
|
|
170
|
+
name: "Test Coin",
|
|
171
|
+
symbol: "TEST",
|
|
172
|
+
description: "A test coin",
|
|
173
|
+
image: "https://example.com/image.png",
|
|
174
|
+
category: "social",
|
|
175
|
+
currency: "ZORA",
|
|
176
|
+
};
|
|
177
|
+
// Mock a reverted transaction
|
|
178
|
+
mockWalletProvider.waitForTransactionReceipt.mockResolvedValueOnce({
|
|
179
|
+
status: "reverted",
|
|
180
|
+
logs: [],
|
|
181
|
+
});
|
|
182
|
+
const result = await provider.createCoin(mockWalletProvider, args);
|
|
183
|
+
const parsedResult = JSON.parse(result);
|
|
184
|
+
expect(parsedResult.success).toBe(false);
|
|
185
|
+
expect(parsedResult.error).toBe("Coin creation transaction reverted");
|
|
186
|
+
});
|
|
187
|
+
it("should handle errors", async () => {
|
|
188
|
+
const args = {
|
|
189
|
+
name: "Test Coin",
|
|
190
|
+
symbol: "TEST",
|
|
191
|
+
description: "A test coin",
|
|
192
|
+
image: "https://example.com/image.png",
|
|
193
|
+
category: "social",
|
|
194
|
+
currency: "ZORA",
|
|
195
|
+
};
|
|
196
|
+
// Create an error that will be thrown during the request
|
|
197
|
+
const error = new Error("Failed to create coin");
|
|
198
|
+
mockWalletProvider.sendTransaction.mockRejectedValueOnce(error);
|
|
199
|
+
const result = await provider.createCoin(mockWalletProvider, args);
|
|
200
|
+
const parsedResult = JSON.parse(result);
|
|
201
|
+
expect(parsedResult.success).toBe(false);
|
|
202
|
+
expect(parsedResult.error).toBe("Failed to create coin");
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
});
|
|
@@ -40,6 +40,10 @@ export interface CdpSmartWalletProviderConfig extends CdpWalletProviderConfig {
|
|
|
40
40
|
* The name of the smart wallet.
|
|
41
41
|
*/
|
|
42
42
|
smartAccountName?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The paymaster URL for gasless transactions.
|
|
45
|
+
*/
|
|
46
|
+
paymasterUrl?: string;
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
45
49
|
* A wallet provider that can be used to interact with the CDP.
|
|
@@ -84,6 +84,12 @@ export declare class CdpSmartWalletProvider extends EvmWalletProvider implements
|
|
|
84
84
|
* @returns The CDP client.
|
|
85
85
|
*/
|
|
86
86
|
getClient(): CdpClient;
|
|
87
|
+
/**
|
|
88
|
+
* Gets the paymaster URL for gasless transactions.
|
|
89
|
+
*
|
|
90
|
+
* @returns The paymaster URL if configured, undefined otherwise.
|
|
91
|
+
*/
|
|
92
|
+
getPaymasterUrl(): string | undefined;
|
|
87
93
|
/**
|
|
88
94
|
* Gets the balance of the smart wallet.
|
|
89
95
|
*
|
|
@@ -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 _CdpSmartWalletProvider_instances, _CdpSmartWalletProvider_publicClient, _CdpSmartWalletProvider_smartAccount, _CdpSmartWalletProvider_ownerAccount, _CdpSmartWalletProvider_cdp, _CdpSmartWalletProvider_network, _CdpSmartWalletProvider_getCdpSdkNetwork;
|
|
13
|
+
var _CdpSmartWalletProvider_instances, _CdpSmartWalletProvider_publicClient, _CdpSmartWalletProvider_smartAccount, _CdpSmartWalletProvider_ownerAccount, _CdpSmartWalletProvider_cdp, _CdpSmartWalletProvider_network, _CdpSmartWalletProvider_paymasterUrl, _CdpSmartWalletProvider_getCdpSdkNetwork;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.CdpSmartWalletProvider = void 0;
|
|
16
16
|
const cdp_sdk_1 = require("@coinbase/cdp-sdk");
|
|
@@ -34,11 +34,13 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
|
|
|
34
34
|
_CdpSmartWalletProvider_ownerAccount.set(this, void 0);
|
|
35
35
|
_CdpSmartWalletProvider_cdp.set(this, void 0);
|
|
36
36
|
_CdpSmartWalletProvider_network.set(this, void 0);
|
|
37
|
+
_CdpSmartWalletProvider_paymasterUrl.set(this, void 0);
|
|
37
38
|
__classPrivateFieldSet(this, _CdpSmartWalletProvider_smartAccount, config.smartAccount, "f");
|
|
38
39
|
__classPrivateFieldSet(this, _CdpSmartWalletProvider_ownerAccount, config.ownerAccount, "f");
|
|
39
40
|
__classPrivateFieldSet(this, _CdpSmartWalletProvider_cdp, config.cdp, "f");
|
|
40
41
|
__classPrivateFieldSet(this, _CdpSmartWalletProvider_publicClient, config.publicClient, "f");
|
|
41
42
|
__classPrivateFieldSet(this, _CdpSmartWalletProvider_network, config.network, "f");
|
|
43
|
+
__classPrivateFieldSet(this, _CdpSmartWalletProvider_paymasterUrl, config.paymasterUrl, "f");
|
|
42
44
|
}
|
|
43
45
|
/**
|
|
44
46
|
* Configures a new CdpSmartWalletProvider with a smart wallet.
|
|
@@ -52,6 +54,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
|
|
|
52
54
|
const apiKeySecret = config.apiKeySecret || process.env.CDP_API_KEY_SECRET;
|
|
53
55
|
const walletSecret = config.walletSecret || process.env.CDP_WALLET_SECRET;
|
|
54
56
|
const idempotencyKey = config.idempotencyKey || process.env.IDEMPOTENCY_KEY;
|
|
57
|
+
const paymasterUrl = config.paymasterUrl || process.env.PAYMASTER_URL;
|
|
55
58
|
if (!apiKeyId || !apiKeySecret || !walletSecret) {
|
|
56
59
|
throw new Error("Missing required environment variables. CDP_API_KEY_ID, CDP_API_KEY_SECRET, CDP_WALLET_SECRET are required.");
|
|
57
60
|
}
|
|
@@ -100,6 +103,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
|
|
|
100
103
|
smartAccount,
|
|
101
104
|
ownerAccount,
|
|
102
105
|
network,
|
|
106
|
+
paymasterUrl,
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
109
|
/**
|
|
@@ -167,6 +171,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
|
|
|
167
171
|
smartAccount: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f"),
|
|
168
172
|
network: __classPrivateFieldGet(this, _CdpSmartWalletProvider_instances, "m", _CdpSmartWalletProvider_getCdpSdkNetwork).call(this),
|
|
169
173
|
calls,
|
|
174
|
+
paymasterUrl: __classPrivateFieldGet(this, _CdpSmartWalletProvider_paymasterUrl, "f"),
|
|
170
175
|
});
|
|
171
176
|
return userOperation.userOpHash;
|
|
172
177
|
}
|
|
@@ -202,6 +207,14 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
|
|
|
202
207
|
getClient() {
|
|
203
208
|
return __classPrivateFieldGet(this, _CdpSmartWalletProvider_cdp, "f");
|
|
204
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Gets the paymaster URL for gasless transactions.
|
|
212
|
+
*
|
|
213
|
+
* @returns The paymaster URL if configured, undefined otherwise.
|
|
214
|
+
*/
|
|
215
|
+
getPaymasterUrl() {
|
|
216
|
+
return __classPrivateFieldGet(this, _CdpSmartWalletProvider_paymasterUrl, "f");
|
|
217
|
+
}
|
|
205
218
|
/**
|
|
206
219
|
* Gets the balance of the smart wallet.
|
|
207
220
|
*
|
|
@@ -251,7 +264,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
|
|
|
251
264
|
}
|
|
252
265
|
}
|
|
253
266
|
exports.CdpSmartWalletProvider = CdpSmartWalletProvider;
|
|
254
|
-
_CdpSmartWalletProvider_publicClient = new WeakMap(), _CdpSmartWalletProvider_smartAccount = new WeakMap(), _CdpSmartWalletProvider_ownerAccount = new WeakMap(), _CdpSmartWalletProvider_cdp = new WeakMap(), _CdpSmartWalletProvider_network = new WeakMap(), _CdpSmartWalletProvider_instances = new WeakSet(), _CdpSmartWalletProvider_getCdpSdkNetwork = function _CdpSmartWalletProvider_getCdpSdkNetwork() {
|
|
267
|
+
_CdpSmartWalletProvider_publicClient = new WeakMap(), _CdpSmartWalletProvider_smartAccount = new WeakMap(), _CdpSmartWalletProvider_ownerAccount = new WeakMap(), _CdpSmartWalletProvider_cdp = new WeakMap(), _CdpSmartWalletProvider_network = new WeakMap(), _CdpSmartWalletProvider_paymasterUrl = new WeakMap(), _CdpSmartWalletProvider_instances = new WeakSet(), _CdpSmartWalletProvider_getCdpSdkNetwork = function _CdpSmartWalletProvider_getCdpSdkNetwork() {
|
|
255
268
|
switch (__classPrivateFieldGet(this, _CdpSmartWalletProvider_network, "f").networkId) {
|
|
256
269
|
case "base-sepolia":
|
|
257
270
|
return "base-sepolia";
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@coinbase/agentkit",
|
|
3
3
|
"description": "Coinbase AgentKit core primitives",
|
|
4
4
|
"repository": "https://github.com/coinbase/agentkit",
|
|
5
|
-
"version": "0.0.0-nightly-
|
|
5
|
+
"version": "0.0.0-nightly-20250806210443",
|
|
6
6
|
"author": "Coinbase Inc.",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/index.js",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"@zerodev/ecdsa-validator": "^5.4.5",
|
|
35
35
|
"@zerodev/intent": "^0.0.24",
|
|
36
36
|
"@zerodev/sdk": "^5.4.28",
|
|
37
|
+
"@zoralabs/coins-sdk": "^0.2.8",
|
|
37
38
|
"axios": "^1.9.0",
|
|
38
39
|
"bs58": "^4.0.1",
|
|
39
40
|
"canonicalize": "^2.1.0",
|