@andrewkimjoseph/celina-sdk 0.2.10 → 0.2.12

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.
@@ -0,0 +1,219 @@
1
+ import { expect } from "vitest";
2
+ import type { OperationSpec } from "../types.js";
3
+ import { assertArray, assertHasKeys } from "../../helpers/assert.js";
4
+
5
+ export const governanceOperations: OperationSpec[] = [
6
+ {
7
+ id: "governance.getGovernanceProposals",
8
+ domain: "governance",
9
+ layer: "read",
10
+ sdk: {
11
+ invoke: (client) =>
12
+ client.governance.getGovernanceProposals({ page: 1, pageSize: 5 }),
13
+ },
14
+ mcp: {
15
+ tool: "get_governance_proposals",
16
+ arguments: () => ({ page: 1, pageSize: 5 }),
17
+ },
18
+ assert: (result) => {
19
+ const obj = assertHasKeys(result, ["proposals", "pagination"]);
20
+ expect(Array.isArray(obj.proposals)).toBe(true);
21
+ },
22
+ },
23
+ {
24
+ id: "governance.getProposalDetails",
25
+ domain: "governance",
26
+ layer: "read",
27
+ sdk: {
28
+ invoke: (client, fx) =>
29
+ client.governance.getProposalDetails(fx.proposalId),
30
+ },
31
+ mcp: {
32
+ tool: "get_proposal_details",
33
+ arguments: (fx) => ({ proposalId: fx.proposalId }),
34
+ },
35
+ assert: (result) => {
36
+ assertHasKeys(result, ["proposal"]);
37
+ },
38
+ },
39
+ ];
40
+
41
+ export const stakingOperations: OperationSpec[] = [
42
+ {
43
+ id: "staking.getStakingBalances",
44
+ domain: "staking",
45
+ layer: "read",
46
+ sdk: {
47
+ invoke: (client, fx) => client.staking.getStakingBalances(fx.wallet),
48
+ },
49
+ mcp: {
50
+ tool: "get_staking_balances",
51
+ arguments: (fx) => ({ address: fx.wallet }),
52
+ },
53
+ assert: (result) => {
54
+ assertHasKeys(result, ["address", "groups"]);
55
+ },
56
+ },
57
+ {
58
+ id: "staking.getActivatableStakes",
59
+ domain: "staking",
60
+ layer: "read",
61
+ sdk: {
62
+ invoke: (client, fx) => client.staking.getActivatableStakes(fx.wallet),
63
+ },
64
+ mcp: {
65
+ tool: "get_activatable_stakes",
66
+ arguments: (fx) => ({ address: fx.wallet }),
67
+ },
68
+ assert: (result) => {
69
+ assertHasKeys(result, ["activatableGroups"]);
70
+ },
71
+ },
72
+ {
73
+ id: "staking.getValidatorGroups",
74
+ domain: "staking",
75
+ layer: "read",
76
+ sdk: {
77
+ invoke: (client) =>
78
+ client.staking.getValidatorGroups({ page: 1, pageSize: 5 }),
79
+ },
80
+ mcp: {
81
+ tool: "get_validator_groups",
82
+ arguments: () => ({ page: 1, pageSize: 5 }),
83
+ },
84
+ assert: (result) => {
85
+ const obj = assertHasKeys(result, ["groups"]);
86
+ assertArray(obj.groups);
87
+ },
88
+ },
89
+ {
90
+ id: "staking.getValidatorGroupDetails",
91
+ domain: "staking",
92
+ layer: "read",
93
+ sdk: {
94
+ invoke: (client, fx) =>
95
+ client.staking.getValidatorGroupDetails(fx.validatorGroup),
96
+ },
97
+ mcp: {
98
+ tool: "get_validator_group_details",
99
+ arguments: (fx) => ({ groupAddress: fx.validatorGroup }),
100
+ },
101
+ assert: (result) => {
102
+ assertHasKeys(result, ["address", "name"]);
103
+ },
104
+ },
105
+ {
106
+ id: "staking.getTotalStakingInfo",
107
+ domain: "staking",
108
+ layer: "read",
109
+ sdk: {
110
+ invoke: (client) => client.staking.getTotalStakingInfo(),
111
+ },
112
+ mcp: {
113
+ tool: "get_total_staking_info",
114
+ arguments: () => ({}),
115
+ },
116
+ assert: (result) => {
117
+ assertHasKeys(result, ["totalVotes"]);
118
+ },
119
+ },
120
+ ];
121
+
122
+ export const nftOperations: OperationSpec[] = [
123
+ {
124
+ id: "nft.getNftInfo",
125
+ domain: "nft",
126
+ layer: "read",
127
+ sdk: {
128
+ invoke: (client, fx) =>
129
+ client.nft.getNftInfo(fx.saidContract, fx.saidTokenId),
130
+ },
131
+ mcp: {
132
+ tool: "get_nft_info",
133
+ arguments: (fx) => ({
134
+ contractAddress: fx.saidContract,
135
+ tokenId: fx.saidTokenId,
136
+ }),
137
+ },
138
+ assert: (result) => {
139
+ assertHasKeys(result, ["contractAddress", "tokenId"]);
140
+ },
141
+ },
142
+ {
143
+ id: "nft.getNftBalance",
144
+ domain: "nft",
145
+ layer: "read",
146
+ sdk: {
147
+ invoke: (client, fx) =>
148
+ client.nft.getNftBalance(fx.saidContract, fx.saidOwner),
149
+ },
150
+ mcp: {
151
+ tool: "get_nft_balance",
152
+ arguments: (fx) => ({
153
+ contractAddress: fx.saidContract,
154
+ address: fx.saidOwner,
155
+ }),
156
+ },
157
+ assert: (result) => {
158
+ assertHasKeys(result, ["balance"]);
159
+ },
160
+ },
161
+ ];
162
+
163
+ export const contractOperations: OperationSpec[] = [
164
+ {
165
+ id: "contract.callFunction",
166
+ domain: "contract",
167
+ layer: "read",
168
+ sdk: {
169
+ invoke: (client, fx) =>
170
+ client.contract.callFunction({
171
+ contractAddress: fx.usdm,
172
+ abi: fx.erc20SymbolAbi,
173
+ functionName: "symbol",
174
+ functionArgs: [],
175
+ }),
176
+ },
177
+ mcp: {
178
+ tool: "call_contract_function",
179
+ arguments: (fx) => ({
180
+ contractAddress: fx.usdm,
181
+ abi: fx.erc20SymbolAbi,
182
+ functionName: "symbol",
183
+ functionArgs: [],
184
+ }),
185
+ },
186
+ assert: (result) => {
187
+ assertHasKeys(result, ["result"]);
188
+ },
189
+ },
190
+ {
191
+ id: "contract.estimateGas",
192
+ domain: "contract",
193
+ layer: "read",
194
+ requiresEnv: ["CELO_PRIVATE_KEY"],
195
+ sdk: {
196
+ invoke: (client, fx) =>
197
+ client.contract.estimateGas({
198
+ contractAddress: fx.usdm,
199
+ abi: fx.erc20SymbolAbi,
200
+ functionName: "symbol",
201
+ functionArgs: [],
202
+ fromAddress: fx.signerAddress ?? fx.wallet,
203
+ }),
204
+ },
205
+ mcp: {
206
+ tool: "estimate_contract_gas",
207
+ arguments: (fx) => ({
208
+ contractAddress: fx.usdm,
209
+ abi: fx.erc20SymbolAbi,
210
+ functionName: "symbol",
211
+ functionArgs: [],
212
+ fromAddress: fx.signerAddress ?? fx.wallet,
213
+ }),
214
+ },
215
+ assert: (result) => {
216
+ assertHasKeys(result, ["gasEstimate"]);
217
+ },
218
+ },
219
+ ];
@@ -0,0 +1,264 @@
1
+ import type { OperationSpec } from "../types.js";
2
+ import { assertHasKeys } from "../../helpers/assert.js";
3
+
4
+ function fromAddress(fx: Parameters<OperationSpec["assert"]>[1]): `0x${string}` {
5
+ return fx.signerAddress ?? fx.wallet;
6
+ }
7
+
8
+ export const mentoFxOperations: OperationSpec[] = [
9
+ {
10
+ id: "mentoFx.getFxQuote",
11
+ domain: "mentoFx",
12
+ layer: "read",
13
+ sdk: {
14
+ invoke: (client) => client.mentoFx.getFxQuote("USDm", "EURm", "1"),
15
+ },
16
+ mcp: {
17
+ tool: "get_mento_fx_quote",
18
+ arguments: () => ({
19
+ tokenIn: "USDm",
20
+ tokenOut: "EURm",
21
+ amount: "1",
22
+ }),
23
+ },
24
+ assert: (result) => {
25
+ assertHasKeys(result, ["tokenIn", "tokenOut", "expectedOut"]);
26
+ },
27
+ },
28
+ {
29
+ id: "mentoFx.estimateFx",
30
+ domain: "mentoFx",
31
+ layer: "read",
32
+ requiresEnv: ["CELO_PRIVATE_KEY"],
33
+ sdk: {
34
+ invoke: (client, fx) =>
35
+ client.mentoFx.estimateFx(fromAddress(fx), "USDm", "EURm", "1"),
36
+ },
37
+ mcp: {
38
+ tool: "estimate_mento_fx",
39
+ arguments: () => ({
40
+ tokenIn: "USDm",
41
+ tokenOut: "EURm",
42
+ amount: "1",
43
+ }),
44
+ },
45
+ assert: (result) => {
46
+ assertHasKeys(result, ["fxGas", "expectedOut"]);
47
+ },
48
+ },
49
+ {
50
+ id: "mentoFx.prepareFx",
51
+ domain: "mentoFx",
52
+ layer: "prepare",
53
+ sdk: {
54
+ invoke: (client, fx) =>
55
+ client.mentoFx.prepareFx(fromAddress(fx), "USDm", "EURm", "1"),
56
+ },
57
+ assert: (result) => {
58
+ assertHasKeys(result, ["from", "steps", "summary"]);
59
+ },
60
+ },
61
+ {
62
+ id: "mentoFx.executeFx",
63
+ domain: "mentoFx",
64
+ layer: "write",
65
+ requiresEnv: ["CELO_PRIVATE_KEY"],
66
+ requiresWrites: true,
67
+ mcp: {
68
+ tool: "execute_mento_fx",
69
+ arguments: () => ({
70
+ tokenIn: "USDm",
71
+ tokenOut: "EURm",
72
+ amount: "0.01",
73
+ }),
74
+ },
75
+ assert: (result) => {
76
+ assertHasKeys(result, ["hash"]);
77
+ },
78
+ },
79
+ ];
80
+
81
+ export const uniswapOperations: OperationSpec[] = [
82
+ {
83
+ id: "uniswap.getSwapQuote",
84
+ domain: "uniswap",
85
+ layer: "read",
86
+ sdk: {
87
+ invoke: (client) => client.uniswap.getSwapQuote("CELO", "USDC", "0.001"),
88
+ },
89
+ mcp: {
90
+ tool: "get_uniswap_quote",
91
+ arguments: () => ({
92
+ tokenIn: "CELO",
93
+ tokenOut: "USDC",
94
+ amount: "0.001",
95
+ }),
96
+ },
97
+ assert: (result) => {
98
+ assertHasKeys(result, ["tokenIn", "tokenOut", "expectedOut", "protocol"]);
99
+ },
100
+ },
101
+ {
102
+ id: "uniswap.estimateSwap",
103
+ domain: "uniswap",
104
+ layer: "read",
105
+ requiresEnv: ["CELO_PRIVATE_KEY"],
106
+ sdk: {
107
+ invoke: (client, fx) =>
108
+ client.uniswap.estimateSwap(
109
+ fromAddress(fx),
110
+ "CELO",
111
+ "USDC",
112
+ "0.001",
113
+ ),
114
+ },
115
+ mcp: {
116
+ tool: "estimate_uniswap_swap",
117
+ arguments: () => ({
118
+ tokenIn: "CELO",
119
+ tokenOut: "USDC",
120
+ amount: "0.001",
121
+ }),
122
+ },
123
+ assert: (result) => {
124
+ assertHasKeys(result, ["swapGas", "expectedOut"]);
125
+ },
126
+ },
127
+ {
128
+ id: "uniswap.prepareSwap",
129
+ domain: "uniswap",
130
+ layer: "prepare",
131
+ sdk: {
132
+ invoke: (client, fx) =>
133
+ client.uniswap.prepareSwap(
134
+ fromAddress(fx),
135
+ "CELO",
136
+ "USDC",
137
+ "0.001",
138
+ ),
139
+ },
140
+ assert: (result) => {
141
+ assertHasKeys(result, ["from", "steps", "summary"]);
142
+ },
143
+ },
144
+ {
145
+ id: "uniswap.executeSwap",
146
+ domain: "uniswap",
147
+ layer: "write",
148
+ requiresEnv: ["CELO_PRIVATE_KEY"],
149
+ requiresWrites: true,
150
+ mcp: {
151
+ tool: "execute_uniswap_swap",
152
+ arguments: () => ({
153
+ tokenIn: "CELO",
154
+ tokenOut: "USDC",
155
+ amount: "0.001",
156
+ }),
157
+ },
158
+ assert: (result) => {
159
+ assertHasKeys(result, ["hash"]);
160
+ },
161
+ },
162
+ ];
163
+
164
+ export const aaveOperations: OperationSpec[] = [
165
+ {
166
+ id: "aave.prepareSupply",
167
+ domain: "aave",
168
+ layer: "prepare",
169
+ requiresEnv: ["CELO_PRIVATE_KEY"],
170
+ sdk: {
171
+ invoke: (client, fx) =>
172
+ client.aave.prepareSupply(fromAddress(fx), "USDm", "0.01"),
173
+ },
174
+ assert: (result) => {
175
+ assertHasKeys(result, ["from", "steps"]);
176
+ },
177
+ },
178
+ {
179
+ id: "aave.prepareWithdraw",
180
+ domain: "aave",
181
+ layer: "prepare",
182
+ requiresEnv: ["CELO_PRIVATE_KEY"],
183
+ sdk: {
184
+ invoke: (client, fx) =>
185
+ client.aave.prepareWithdraw(fromAddress(fx), "USDm", "0.01"),
186
+ },
187
+ assert: (result) => {
188
+ assertHasKeys(result, ["from", "steps"]);
189
+ },
190
+ },
191
+ {
192
+ id: "aave.supply",
193
+ domain: "aave",
194
+ layer: "write",
195
+ requiresEnv: ["CELO_PRIVATE_KEY"],
196
+ requiresWrites: true,
197
+ mcp: {
198
+ tool: "supply_aave",
199
+ arguments: () => ({
200
+ token: "USDm",
201
+ amount: "0.01",
202
+ }),
203
+ },
204
+ assert: (result) => {
205
+ assertHasKeys(result, ["hash"]);
206
+ },
207
+ },
208
+ {
209
+ id: "aave.withdraw",
210
+ domain: "aave",
211
+ layer: "write",
212
+ requiresEnv: ["CELO_PRIVATE_KEY"],
213
+ requiresWrites: true,
214
+ mcp: {
215
+ tool: "withdraw_aave",
216
+ arguments: () => ({
217
+ token: "USDm",
218
+ amount: "0.01",
219
+ }),
220
+ },
221
+ assert: (result) => {
222
+ assertHasKeys(result, ["hash"]);
223
+ },
224
+ },
225
+ ];
226
+
227
+ export const ensOperations: OperationSpec[] = [
228
+ {
229
+ id: "ens.resolveEns",
230
+ domain: "ens",
231
+ layer: "read",
232
+ sdk: {
233
+ invoke: (client, fx) => client.ens.resolveEns(fx.ensName, "celo"),
234
+ },
235
+ mcp: {
236
+ tool: "resolve_ens",
237
+ arguments: (fx) => ({
238
+ name: fx.ensName,
239
+ chain: "celo",
240
+ }),
241
+ },
242
+ assert: (result) => {
243
+ assertHasKeys(result, ["name", "address"]);
244
+ },
245
+ },
246
+ ];
247
+
248
+ export const gooddollarOperations: OperationSpec[] = [
249
+ {
250
+ id: "gooddollar.getWhitelistingInfo",
251
+ domain: "gooddollar",
252
+ layer: "read",
253
+ sdk: {
254
+ invoke: (client, fx) => client.gooddollar.getWhitelistingInfo(fx.wallet),
255
+ },
256
+ mcp: {
257
+ tool: "get_gooddollar_whitelisting_info",
258
+ arguments: (fx) => ({ address: fx.wallet }),
259
+ },
260
+ assert: (result) => {
261
+ assertHasKeys(result, ["isCurrentlyWhitelisted"]);
262
+ },
263
+ },
264
+ ];
@@ -0,0 +1,161 @@
1
+ import type { OperationSpec } from "../types.js";
2
+ import { assertHasKeys } from "../../helpers/assert.js";
3
+
4
+ const SELF_DEMO_VERIFY_URL =
5
+ "https://app.ai.self.xyz/api/demo/verify?network=celo-mainnet";
6
+
7
+ export const selfOperations: OperationSpec[] = [
8
+ {
9
+ id: "self.verifySelfAgent",
10
+ domain: "self",
11
+ layer: "read",
12
+ mcp: {
13
+ tool: "verify_self_agent",
14
+ arguments: (fx) => ({
15
+ agent_address: fx.selfAgentAddress,
16
+ }),
17
+ },
18
+ assert: (result) => {
19
+ assertHasKeys(result, ["verified"]);
20
+ },
21
+ },
22
+ {
23
+ id: "self.lookupSelfAgent",
24
+ domain: "self",
25
+ layer: "read",
26
+ mcp: {
27
+ tool: "lookup_self_agent",
28
+ arguments: (fx) => ({
29
+ agent_id: fx.selfAgentId,
30
+ }),
31
+ },
32
+ assert: (result) => {
33
+ assertHasKeys(result, ["agentId"]);
34
+ },
35
+ },
36
+ {
37
+ id: "self.verifySelfRequest",
38
+ domain: "self",
39
+ layer: "read",
40
+ requiresEnv: ["SELF_AGENT_PRIVATE_KEY"],
41
+ mcp: {
42
+ tool: "verify_self_request",
43
+ arguments: (fx) => fx.selfVerifyRequestArgs ?? {},
44
+ },
45
+ skip: () =>
46
+ process.env.CELINA_TEST_SELF_VERIFY === "1"
47
+ ? undefined
48
+ : "Set CELINA_TEST_SELF_VERIFY=1 (MCP suite enriches signed fixture in beforeAll)",
49
+ assert: (result) => {
50
+ assertHasKeys(result, ["valid"]);
51
+ },
52
+ },
53
+ {
54
+ id: "self.registerSelfAgent",
55
+ domain: "self",
56
+ layer: "write",
57
+ requiresDestructive: true,
58
+ mcp: {
59
+ tool: "register_self_agent",
60
+ arguments: () => ({
61
+ mode: "wallet-free",
62
+ agent_name: "celina-test",
63
+ }),
64
+ },
65
+ assert: (result) => {
66
+ assertHasKeys(result, ["sessionId"]);
67
+ },
68
+ },
69
+ {
70
+ id: "self.checkSelfRegistration",
71
+ domain: "self",
72
+ layer: "read",
73
+ mcp: {
74
+ tool: "check_self_registration",
75
+ arguments: () => ({
76
+ session_id: process.env.CELINA_TEST_SELF_SESSION ?? "missing-session",
77
+ }),
78
+ },
79
+ skip: () =>
80
+ process.env.CELINA_TEST_SELF_SESSION
81
+ ? undefined
82
+ : "Set CELINA_TEST_SELF_SESSION to poll a pending Self session",
83
+ assert: (result) => {
84
+ assertHasKeys(result, ["status"]);
85
+ },
86
+ },
87
+ {
88
+ id: "self.getSelfIdentity",
89
+ domain: "self",
90
+ layer: "read",
91
+ requiresEnv: ["SELF_AGENT_PRIVATE_KEY"],
92
+ mcp: {
93
+ tool: "get_self_identity",
94
+ arguments: () => ({}),
95
+ },
96
+ assert: (result) => {
97
+ assertHasKeys(result, ["agentAddress"]);
98
+ },
99
+ },
100
+ {
101
+ id: "self.refreshSelfProof",
102
+ domain: "self",
103
+ layer: "write",
104
+ requiresEnv: ["SELF_AGENT_PRIVATE_KEY"],
105
+ requiresDestructive: true,
106
+ mcp: {
107
+ tool: "refresh_self_proof",
108
+ arguments: () => ({}),
109
+ },
110
+ assert: (result) => {
111
+ assertHasKeys(result, ["sessionId"]);
112
+ },
113
+ },
114
+ {
115
+ id: "self.deregisterSelfAgent",
116
+ domain: "self",
117
+ layer: "write",
118
+ requiresEnv: ["SELF_AGENT_PRIVATE_KEY"],
119
+ requiresDestructive: true,
120
+ mcp: {
121
+ tool: "deregister_self_agent",
122
+ arguments: () => ({}),
123
+ },
124
+ assert: (result) => {
125
+ assertHasKeys(result, ["sessionId"]);
126
+ },
127
+ },
128
+ {
129
+ id: "self.signSelfRequest",
130
+ domain: "self",
131
+ layer: "read",
132
+ requiresEnv: ["SELF_AGENT_PRIVATE_KEY"],
133
+ mcp: {
134
+ tool: "sign_self_request",
135
+ arguments: () => ({
136
+ method: "GET",
137
+ url: SELF_DEMO_VERIFY_URL,
138
+ }),
139
+ },
140
+ assert: (result) => {
141
+ assertHasKeys(result, ["headers"]);
142
+ },
143
+ },
144
+ {
145
+ id: "self.authenticatedSelfFetch",
146
+ domain: "self",
147
+ layer: "read",
148
+ requiresEnv: ["SELF_AGENT_PRIVATE_KEY"],
149
+ mcp: {
150
+ tool: "authenticated_self_fetch",
151
+ arguments: () => ({
152
+ method: "POST",
153
+ url: SELF_DEMO_VERIFY_URL,
154
+ body: JSON.stringify({ ping: true }),
155
+ }),
156
+ },
157
+ assert: (result) => {
158
+ assertHasKeys(result, ["status"]);
159
+ },
160
+ },
161
+ ];
@@ -0,0 +1,74 @@
1
+ import { expect } from "vitest";
2
+ import type { OperationSpec } from "../types.js";
3
+ import { assertHasKeys } from "../../helpers/assert.js";
4
+
5
+ export const tokenOperations: OperationSpec[] = [
6
+ {
7
+ id: "token.getBalances",
8
+ domain: "token",
9
+ layer: "read",
10
+ sdk: {
11
+ invoke: (client, fx) =>
12
+ client.token.getBalances(fx.wallet, ["CELO", "USDm"]),
13
+ },
14
+ mcp: {
15
+ tool: "get_celo_balances",
16
+ arguments: (fx) => ({
17
+ address: fx.wallet,
18
+ tokens: ["CELO", "USDm"],
19
+ }),
20
+ },
21
+ assert: (result) => {
22
+ assertHasKeys(result, ["address", "balances"]);
23
+ },
24
+ },
25
+ {
26
+ id: "token.getStablecoinBalances",
27
+ domain: "token",
28
+ layer: "read",
29
+ sdk: {
30
+ invoke: (client, fx) => client.token.getStablecoinBalances(fx.wallet),
31
+ },
32
+ mcp: {
33
+ tool: "get_stablecoin_balances",
34
+ arguments: (fx) => ({ address: fx.wallet }),
35
+ },
36
+ assert: (result) => {
37
+ assertHasKeys(result, ["address", "stablecoins"]);
38
+ },
39
+ },
40
+ {
41
+ id: "token.getTokenInfo",
42
+ domain: "token",
43
+ layer: "read",
44
+ sdk: {
45
+ invoke: (client) => client.token.getTokenInfo("USDm"),
46
+ },
47
+ mcp: {
48
+ tool: "get_token_info",
49
+ arguments: () => ({ token: "USDm" }),
50
+ },
51
+ assert: (result) => {
52
+ assertHasKeys(result, ["symbol", "decimals"]);
53
+ },
54
+ },
55
+ {
56
+ id: "token.getTokenBalance",
57
+ domain: "token",
58
+ layer: "read",
59
+ sdk: {
60
+ invoke: (client, fx) =>
61
+ client.token.getTokenBalance("USDm", fx.wallet),
62
+ },
63
+ mcp: {
64
+ tool: "get_token_balance",
65
+ arguments: (fx) => ({
66
+ token: "USDm",
67
+ address: fx.wallet,
68
+ }),
69
+ },
70
+ assert: (result) => {
71
+ assertHasKeys(result, ["formatted", "symbol"]);
72
+ },
73
+ },
74
+ ];