@coinbase/agentkit 0.6.1 → 0.6.2
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/dist/action-providers/index.d.ts +1 -0
- package/dist/action-providers/index.js +1 -0
- package/dist/action-providers/vaultsfyi/api/actions.d.ts +41 -0
- package/dist/action-providers/vaultsfyi/api/actions.js +28 -0
- package/dist/action-providers/vaultsfyi/api/types.d.ts +34 -0
- package/dist/action-providers/vaultsfyi/api/types.js +2 -0
- package/dist/action-providers/vaultsfyi/api/vaults.d.ts +38 -0
- package/dist/action-providers/vaultsfyi/api/vaults.js +39 -0
- package/dist/action-providers/vaultsfyi/constants.d.ts +12 -0
- package/dist/action-providers/vaultsfyi/constants.js +15 -0
- package/dist/action-providers/vaultsfyi/index.d.ts +7 -0
- package/dist/action-providers/vaultsfyi/index.js +23 -0
- package/dist/action-providers/vaultsfyi/schemas.d.ts +94 -0
- package/dist/action-providers/vaultsfyi/schemas.js +49 -0
- package/dist/action-providers/vaultsfyi/utils.d.ts +34 -0
- package/dist/action-providers/vaultsfyi/utils.js +69 -0
- package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.d.ts +98 -0
- package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.js +383 -0
- package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.test.d.ts +1 -0
- package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.test.js +438 -0
- package/package.json +1 -1
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vaultsfyiActionProvider_1 = require("./vaultsfyiActionProvider");
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const mockFetchResult = (status, data) => {
|
|
6
|
+
return {
|
|
7
|
+
json: async () => data,
|
|
8
|
+
status,
|
|
9
|
+
ok: status >= 200 && status < 300,
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
const mockVault = (num) => ({
|
|
13
|
+
apiResult: {
|
|
14
|
+
address: `0x${num.toString(16).padStart(40, "0")}`,
|
|
15
|
+
network: `network-${num}`,
|
|
16
|
+
name: `vault-${num}`,
|
|
17
|
+
protocol: `protocol-${num}`,
|
|
18
|
+
token: {
|
|
19
|
+
name: `token-${num}`,
|
|
20
|
+
assetAddress: `0x${num.toString(16).padStart(40, "0")}`,
|
|
21
|
+
symbol: `T${num}`,
|
|
22
|
+
decimals: 18,
|
|
23
|
+
},
|
|
24
|
+
tvlDetails: {
|
|
25
|
+
tvlUsd: num.toString(),
|
|
26
|
+
},
|
|
27
|
+
apy: {
|
|
28
|
+
base: {
|
|
29
|
+
"7day": num * 100,
|
|
30
|
+
},
|
|
31
|
+
rewards: {
|
|
32
|
+
"7day": num * 100,
|
|
33
|
+
},
|
|
34
|
+
total: {
|
|
35
|
+
"7day": num * 100,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
isTransactional: true,
|
|
39
|
+
},
|
|
40
|
+
transformedResult: {
|
|
41
|
+
name: `vault-${num}`,
|
|
42
|
+
address: `0x${num.toString(16).padStart(40, "0")}`,
|
|
43
|
+
network: `network-${num}`,
|
|
44
|
+
protocol: `protocol-${num}`,
|
|
45
|
+
tvlInUsd: num,
|
|
46
|
+
token: {
|
|
47
|
+
name: `token-${num}`,
|
|
48
|
+
address: `0x${num.toString(16).padStart(40, "0")}`,
|
|
49
|
+
symbol: `T${num}`,
|
|
50
|
+
},
|
|
51
|
+
apy: {
|
|
52
|
+
base: num,
|
|
53
|
+
rewards: num,
|
|
54
|
+
total: num,
|
|
55
|
+
},
|
|
56
|
+
link: `https://app.vaults.fyi/opportunity/network-${num}/0x${num.toString(16).padStart(40, "0")}`,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
const MOCK_TX_HASH = "0xmock-hash";
|
|
60
|
+
describe("VaultsfyiActionProvider", () => {
|
|
61
|
+
const provider = new vaultsfyiActionProvider_1.VaultsfyiActionProvider({ apiKey: "test-api-key" });
|
|
62
|
+
let mockWalletProvider;
|
|
63
|
+
let mockedFetch;
|
|
64
|
+
const originalFetch = global.fetch;
|
|
65
|
+
beforeAll(() => {
|
|
66
|
+
global.fetch = mockedFetch = jest.fn();
|
|
67
|
+
});
|
|
68
|
+
afterAll(() => {
|
|
69
|
+
global.fetch = originalFetch;
|
|
70
|
+
});
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
mockWalletProvider = {
|
|
73
|
+
getAddress: jest.fn(),
|
|
74
|
+
getBalance: jest.fn(),
|
|
75
|
+
getName: jest.fn(),
|
|
76
|
+
getNetwork: jest.fn().mockReturnValue({
|
|
77
|
+
protocolFamily: "evm",
|
|
78
|
+
networkId: "test-network",
|
|
79
|
+
}),
|
|
80
|
+
nativeTransfer: jest.fn(),
|
|
81
|
+
readContract: jest.fn(() => Promise.resolve(18)), // token decimals
|
|
82
|
+
sendTransaction: jest.fn(() => Promise.resolve(MOCK_TX_HASH)),
|
|
83
|
+
waitForTransactionReceipt: jest.fn(),
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
describe("network support", () => {
|
|
87
|
+
it("should support all vaultsfyi networks", () => {
|
|
88
|
+
Object.keys(constants_1.VAULTSFYI_SUPPORTED_CHAINS).forEach(network => {
|
|
89
|
+
expect(provider.supportsNetwork({
|
|
90
|
+
protocolFamily: "evm",
|
|
91
|
+
chainId: network,
|
|
92
|
+
})).toBe(true);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
it("should not support other protocol families", () => {
|
|
96
|
+
expect(provider.supportsNetwork({
|
|
97
|
+
protocolFamily: "evm",
|
|
98
|
+
chainId: "some-other-chain",
|
|
99
|
+
})).toBe(false);
|
|
100
|
+
});
|
|
101
|
+
it("should handle invalid network objects", () => {
|
|
102
|
+
expect(provider.supportsNetwork({})).toBe(false);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
describe("vaults action", () => {
|
|
106
|
+
it("should return a transformed vault", async () => {
|
|
107
|
+
const mockedVault = mockVault(1);
|
|
108
|
+
mockedFetch.mockResolvedValue(mockFetchResult(200, { data: [mockedVault.apiResult] }));
|
|
109
|
+
const args = {};
|
|
110
|
+
const result = await provider.vaults(mockWalletProvider, args);
|
|
111
|
+
expect(JSON.parse(result)).toStrictEqual({
|
|
112
|
+
totalResults: 1,
|
|
113
|
+
nextPage: false,
|
|
114
|
+
results: [mockedVault.transformedResult],
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
it("should filter by protocol", async () => {
|
|
118
|
+
const mockedVaults = [mockVault(1), mockVault(2)];
|
|
119
|
+
mockedFetch.mockResolvedValue(mockFetchResult(200, { data: mockedVaults.map(v => v.apiResult) }));
|
|
120
|
+
const args = { protocol: "protocol-1" };
|
|
121
|
+
const result = await provider.vaults(mockWalletProvider, args);
|
|
122
|
+
expect(JSON.parse(result)).toStrictEqual({
|
|
123
|
+
totalResults: 1,
|
|
124
|
+
nextPage: false,
|
|
125
|
+
results: [mockedVaults[0].transformedResult],
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
it("should take a limit", async () => {
|
|
129
|
+
const mockedVaults = [mockVault(1), mockVault(2)];
|
|
130
|
+
mockedFetch.mockResolvedValue(mockFetchResult(200, { data: mockedVaults.map(v => v.apiResult) }));
|
|
131
|
+
const args = { take: 1 };
|
|
132
|
+
const result = await provider.vaults(mockWalletProvider, args);
|
|
133
|
+
expect(JSON.parse(result)).toStrictEqual({
|
|
134
|
+
totalResults: 2,
|
|
135
|
+
nextPage: true,
|
|
136
|
+
results: [mockedVaults[0].transformedResult],
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
describe("sorting", () => {
|
|
140
|
+
it("should sort by TVL", async () => {
|
|
141
|
+
const mockedVaults = [mockVault(2), mockVault(1)];
|
|
142
|
+
mockedFetch.mockResolvedValue(mockFetchResult(200, { data: mockedVaults.map(v => v.apiResult) }));
|
|
143
|
+
const args = { sort: { field: "tvl", direction: "asc" } };
|
|
144
|
+
const result = await provider.vaults(mockWalletProvider, args);
|
|
145
|
+
expect(JSON.parse(result)).toStrictEqual({
|
|
146
|
+
totalResults: 2,
|
|
147
|
+
nextPage: false,
|
|
148
|
+
results: [mockedVaults[1].transformedResult, mockedVaults[0].transformedResult],
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
it("should sort by APY", async () => {
|
|
152
|
+
const mockedVaults = [mockVault(2), mockVault(1)];
|
|
153
|
+
mockedFetch.mockResolvedValue(mockFetchResult(200, { data: mockedVaults.map(v => v.apiResult) }));
|
|
154
|
+
const args = { sort: { field: "apy", direction: "asc" } };
|
|
155
|
+
const result = await provider.vaults(mockWalletProvider, args);
|
|
156
|
+
expect(JSON.parse(result)).toStrictEqual({
|
|
157
|
+
totalResults: 2,
|
|
158
|
+
nextPage: false,
|
|
159
|
+
results: [mockedVaults[1].transformedResult, mockedVaults[0].transformedResult],
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
it("should sort by name by default", async () => {
|
|
163
|
+
const mockedVaults = [mockVault(2), mockVault(1)];
|
|
164
|
+
mockedFetch.mockResolvedValue(mockFetchResult(200, { data: mockedVaults.map(v => v.apiResult) }));
|
|
165
|
+
const args = {};
|
|
166
|
+
const result = await provider.vaults(mockWalletProvider, args);
|
|
167
|
+
expect(JSON.parse(result)).toStrictEqual({
|
|
168
|
+
totalResults: 2,
|
|
169
|
+
nextPage: false,
|
|
170
|
+
results: [mockedVaults[1].transformedResult, mockedVaults[0].transformedResult],
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
it("should return an error if the API request fails", async () => {
|
|
175
|
+
mockedFetch.mockResolvedValue(mockFetchResult(500, { error: "Internal Server Error", message: "some more info" }));
|
|
176
|
+
const args = {};
|
|
177
|
+
expect(await provider.vaults(mockWalletProvider, args)).toBe("Failed to fetch vaults: Internal Server Error, some more info");
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
describe("deposit action", () => {
|
|
181
|
+
it("should execute deposit", async () => {
|
|
182
|
+
mockedFetch.mockResolvedValue(mockFetchResult(200, {
|
|
183
|
+
currentActionIndex: 0,
|
|
184
|
+
actions: [
|
|
185
|
+
{
|
|
186
|
+
tx: {
|
|
187
|
+
to: "0x123",
|
|
188
|
+
data: "0x456",
|
|
189
|
+
value: "1",
|
|
190
|
+
chainId: 1,
|
|
191
|
+
},
|
|
192
|
+
description: "Deposit to vault",
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
}));
|
|
196
|
+
const args = {
|
|
197
|
+
vaultAddress: "0x123",
|
|
198
|
+
assetAddress: "0x456",
|
|
199
|
+
network: "mainnet",
|
|
200
|
+
amount: 1,
|
|
201
|
+
};
|
|
202
|
+
const response = await provider.deposit(mockWalletProvider, args);
|
|
203
|
+
expect(response).toBe("Deposit successful");
|
|
204
|
+
expect(mockWalletProvider.sendTransaction).toHaveBeenCalledWith({
|
|
205
|
+
to: "0x123",
|
|
206
|
+
data: "0x456",
|
|
207
|
+
value: 1n,
|
|
208
|
+
chainId: 1,
|
|
209
|
+
});
|
|
210
|
+
expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalledWith(MOCK_TX_HASH);
|
|
211
|
+
});
|
|
212
|
+
it("should execute multiple transactions", async () => {
|
|
213
|
+
mockedFetch.mockResolvedValue(mockFetchResult(200, {
|
|
214
|
+
currentActionIndex: 0,
|
|
215
|
+
actions: [
|
|
216
|
+
{
|
|
217
|
+
tx: {
|
|
218
|
+
to: "0x123",
|
|
219
|
+
data: "0x456",
|
|
220
|
+
value: "1",
|
|
221
|
+
chainId: 1,
|
|
222
|
+
},
|
|
223
|
+
description: "Deposit to vault",
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
tx: {
|
|
227
|
+
to: "0x789",
|
|
228
|
+
data: "0xabc",
|
|
229
|
+
value: "2",
|
|
230
|
+
chainId: 1,
|
|
231
|
+
},
|
|
232
|
+
description: "Deposit to vault",
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
}));
|
|
236
|
+
const args = {
|
|
237
|
+
vaultAddress: "0x123",
|
|
238
|
+
assetAddress: "0x456",
|
|
239
|
+
network: "mainnet",
|
|
240
|
+
amount: 1,
|
|
241
|
+
};
|
|
242
|
+
const response = await provider.deposit(mockWalletProvider, args);
|
|
243
|
+
expect(response).toBe("Deposit successful");
|
|
244
|
+
expect(mockWalletProvider.sendTransaction).toHaveBeenCalledWith({
|
|
245
|
+
to: "0x123",
|
|
246
|
+
data: "0x456",
|
|
247
|
+
value: 1n,
|
|
248
|
+
chainId: 1,
|
|
249
|
+
});
|
|
250
|
+
expect(mockWalletProvider.sendTransaction).toHaveBeenCalledWith({
|
|
251
|
+
to: "0x789",
|
|
252
|
+
data: "0xabc",
|
|
253
|
+
value: 2n,
|
|
254
|
+
chainId: 1,
|
|
255
|
+
});
|
|
256
|
+
expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalledWith(MOCK_TX_HASH);
|
|
257
|
+
});
|
|
258
|
+
it("should return an error if the API request fails", async () => {
|
|
259
|
+
mockedFetch.mockResolvedValue(mockFetchResult(500, { error: "Internal Server Error", message: "some more info" }));
|
|
260
|
+
const args = {
|
|
261
|
+
vaultAddress: "0x123",
|
|
262
|
+
assetAddress: "0x456",
|
|
263
|
+
network: "mainnet",
|
|
264
|
+
amount: 1,
|
|
265
|
+
};
|
|
266
|
+
expect(await provider.deposit(mockWalletProvider, args)).toBe("Failed to fetch deposit transactions: Internal Server Error, some more info");
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
describe("redeem action", () => {
|
|
270
|
+
it("should execute redeem", async () => {
|
|
271
|
+
mockedFetch.mockResolvedValue(mockFetchResult(200, {
|
|
272
|
+
currentActionIndex: 0,
|
|
273
|
+
actions: [
|
|
274
|
+
{
|
|
275
|
+
tx: {
|
|
276
|
+
to: "0x123",
|
|
277
|
+
data: "0x456",
|
|
278
|
+
value: "1",
|
|
279
|
+
chainId: 1,
|
|
280
|
+
},
|
|
281
|
+
description: "Redeem from vault",
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
}));
|
|
285
|
+
const args = {
|
|
286
|
+
vaultAddress: "0x123",
|
|
287
|
+
assetAddress: "0x456",
|
|
288
|
+
network: "mainnet",
|
|
289
|
+
amount: 1,
|
|
290
|
+
};
|
|
291
|
+
const response = await provider.redeem(mockWalletProvider, args);
|
|
292
|
+
expect(response).toBe("Redeem successful");
|
|
293
|
+
expect(mockWalletProvider.sendTransaction).toHaveBeenCalledWith({
|
|
294
|
+
to: "0x123",
|
|
295
|
+
data: "0x456",
|
|
296
|
+
value: 1n,
|
|
297
|
+
chainId: 1,
|
|
298
|
+
});
|
|
299
|
+
expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalledWith(MOCK_TX_HASH);
|
|
300
|
+
});
|
|
301
|
+
it("should return an error if the API request fails", async () => {
|
|
302
|
+
mockedFetch.mockResolvedValue(mockFetchResult(500, { error: "Internal Server Error", message: "some more info" }));
|
|
303
|
+
const args = {
|
|
304
|
+
vaultAddress: "0x123",
|
|
305
|
+
assetAddress: "0x456",
|
|
306
|
+
network: "mainnet",
|
|
307
|
+
amount: 1,
|
|
308
|
+
};
|
|
309
|
+
expect(await provider.redeem(mockWalletProvider, args)).toBe("Failed to fetch redeem transactions: Internal Server Error, some more info");
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
describe("claim rewards action", () => {
|
|
313
|
+
it("should execute claim rewards", async () => {
|
|
314
|
+
mockedFetch.mockResolvedValue(mockFetchResult(200, {
|
|
315
|
+
currentActionIndex: 0,
|
|
316
|
+
actions: [
|
|
317
|
+
{
|
|
318
|
+
tx: {
|
|
319
|
+
to: "0x123",
|
|
320
|
+
data: "0x456",
|
|
321
|
+
value: "1",
|
|
322
|
+
chainId: 1,
|
|
323
|
+
},
|
|
324
|
+
description: "Claim rewards from vault",
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
}));
|
|
328
|
+
const args = {
|
|
329
|
+
vaultAddress: "0x123",
|
|
330
|
+
assetAddress: "0x456",
|
|
331
|
+
network: "mainnet",
|
|
332
|
+
amount: 1,
|
|
333
|
+
};
|
|
334
|
+
const response = await provider.claim(mockWalletProvider, args);
|
|
335
|
+
expect(response).toBe("Claim successful");
|
|
336
|
+
expect(mockWalletProvider.sendTransaction).toHaveBeenCalledWith({
|
|
337
|
+
to: "0x123",
|
|
338
|
+
data: "0x456",
|
|
339
|
+
value: 1n,
|
|
340
|
+
chainId: 1,
|
|
341
|
+
});
|
|
342
|
+
expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalledWith(MOCK_TX_HASH);
|
|
343
|
+
});
|
|
344
|
+
it("should return an error if the API request fails", async () => {
|
|
345
|
+
mockedFetch.mockResolvedValue(mockFetchResult(500, { error: "Internal Server Error", message: "some more info" }));
|
|
346
|
+
const args = {
|
|
347
|
+
vaultAddress: "0x123",
|
|
348
|
+
assetAddress: "0x456",
|
|
349
|
+
network: "mainnet",
|
|
350
|
+
amount: 1,
|
|
351
|
+
};
|
|
352
|
+
expect(await provider.claim(mockWalletProvider, args)).toBe("Failed to fetch claim transactions: Internal Server Error, some more info");
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
describe("wallet balances action", () => {
|
|
356
|
+
it("should strip and transform balances correctly", async () => {
|
|
357
|
+
mockedFetch.mockResolvedValue(mockFetchResult(200, {
|
|
358
|
+
mainnet: [
|
|
359
|
+
{
|
|
360
|
+
address: "0x123",
|
|
361
|
+
name: "token-1",
|
|
362
|
+
symbol: "T1",
|
|
363
|
+
balance: (10 ** 18).toString(),
|
|
364
|
+
decimals: 18,
|
|
365
|
+
somethingElse: "should be stripped",
|
|
366
|
+
},
|
|
367
|
+
],
|
|
368
|
+
}));
|
|
369
|
+
const response = await provider.balances(mockWalletProvider);
|
|
370
|
+
expect(JSON.parse(response)).toStrictEqual({
|
|
371
|
+
mainnet: [
|
|
372
|
+
{
|
|
373
|
+
address: "0x123",
|
|
374
|
+
name: "token-1",
|
|
375
|
+
symbol: "T1",
|
|
376
|
+
balance: 1,
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
it("should return an error if the API request fails", async () => {
|
|
382
|
+
mockedFetch.mockResolvedValue(mockFetchResult(500, { error: "Internal Server Error", message: "some more info" }));
|
|
383
|
+
expect(await provider.balances(mockWalletProvider)).toBe("Failed to fetch wallet balances: Internal Server Error, some more info");
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
describe("wallet positions action", () => {
|
|
387
|
+
it("should strip and transform positions correctly", async () => {
|
|
388
|
+
mockedFetch.mockResolvedValue(mockFetchResult(200, {
|
|
389
|
+
mainnet: [
|
|
390
|
+
{
|
|
391
|
+
vaultName: "vault-1",
|
|
392
|
+
vaultAddress: "0x123",
|
|
393
|
+
asset: {
|
|
394
|
+
assetAddress: "0x456",
|
|
395
|
+
name: "token-1",
|
|
396
|
+
symbol: "T1",
|
|
397
|
+
decimals: 18,
|
|
398
|
+
},
|
|
399
|
+
balanceNative: (10 ** 18).toString(),
|
|
400
|
+
balanceLp: (10 ** 18).toString(),
|
|
401
|
+
unclaimedUsd: "100",
|
|
402
|
+
apy: {
|
|
403
|
+
base: 100,
|
|
404
|
+
rewards: 100,
|
|
405
|
+
total: 100,
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
],
|
|
409
|
+
}));
|
|
410
|
+
const response = await provider.positions(mockWalletProvider);
|
|
411
|
+
expect(JSON.parse(response)).toStrictEqual({
|
|
412
|
+
mainnet: [
|
|
413
|
+
{
|
|
414
|
+
name: "vault-1",
|
|
415
|
+
vaultAddress: "0x123",
|
|
416
|
+
asset: {
|
|
417
|
+
address: "0x456",
|
|
418
|
+
name: "token-1",
|
|
419
|
+
symbol: "T1",
|
|
420
|
+
},
|
|
421
|
+
underlyingTokenBalance: 1,
|
|
422
|
+
lpTokenBalance: 1,
|
|
423
|
+
unclaimedRewards: true,
|
|
424
|
+
apy: {
|
|
425
|
+
base: 1,
|
|
426
|
+
rewards: 1,
|
|
427
|
+
total: 1,
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
],
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
it("should return an error if the API request fails", async () => {
|
|
434
|
+
mockedFetch.mockResolvedValue(mockFetchResult(500, { error: "Internal Server Error", message: "some more info" }));
|
|
435
|
+
expect(await provider.positions(mockWalletProvider)).toBe("Failed to fetch positions: Internal Server Error, some more info");
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
});
|
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.6.
|
|
5
|
+
"version": "0.6.2",
|
|
6
6
|
"author": "Coinbase Inc.",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/index.js",
|