@andrewkimjoseph/celina 0.4.0 → 0.4.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/bin/wrapper.js +2 -0
- package/package.json +5 -44
- package/LICENSE +0 -21
- package/README.md +0 -292
- package/assets/logo-black.png +0 -0
- package/assets/logo-yellow.png +0 -0
- package/assets/logo.png +0 -0
- package/bin/cli.js +0 -2
- package/build/abis/aave-pool.d.ts +0 -37
- package/build/abis/aave-pool.js +0 -26
- package/build/abis/aave-pool.js.map +0 -1
- package/build/abis/gooddollar-identity.d.ts +0 -61
- package/build/abis/gooddollar-identity.js +0 -38
- package/build/abis/gooddollar-identity.js.map +0 -1
- package/build/abis/self-registry.d.ts +0 -194
- package/build/abis/self-registry.js +0 -120
- package/build/abis/self-registry.js.map +0 -1
- package/build/clients/celo-client.d.ts +0 -13
- package/build/clients/celo-client.js +0 -39
- package/build/clients/celo-client.js.map +0 -1
- package/build/clients/ens-client.d.ts +0 -10
- package/build/clients/ens-client.js +0 -23
- package/build/clients/ens-client.js.map +0 -1
- package/build/clients/mento-sdk.d.ts +0 -2
- package/build/clients/mento-sdk.js +0 -9
- package/build/clients/mento-sdk.js.map +0 -1
- package/build/clients/self-api.d.ts +0 -82
- package/build/clients/self-api.js +0 -242
- package/build/clients/self-api.js.map +0 -1
- package/build/config/aave.d.ts +0 -11
- package/build/config/aave.js +0 -55
- package/build/config/aave.js.map +0 -1
- package/build/config/celina-tag.d.ts +0 -1
- package/build/config/celina-tag.js +0 -3
- package/build/config/celina-tag.js.map +0 -1
- package/build/config/chains.d.ts +0 -935
- package/build/config/chains.js +0 -251
- package/build/config/chains.js.map +0 -1
- package/build/config/env.d.ts +0 -7
- package/build/config/env.js +0 -9
- package/build/config/env.js.map +0 -1
- package/build/config/gooddollar.d.ts +0 -1
- package/build/config/gooddollar.js +0 -2
- package/build/config/gooddollar.js.map +0 -1
- package/build/config/load-env.d.ts +0 -1
- package/build/config/load-env.js +0 -4
- package/build/config/load-env.js.map +0 -1
- package/build/config/self.d.ts +0 -22
- package/build/config/self.js +0 -27
- package/build/config/self.js.map +0 -1
- package/build/context/app-context.d.ts +0 -28
- package/build/context/app-context.js +0 -28
- package/build/context/app-context.js.map +0 -1
- package/build/index.d.ts +0 -2
- package/build/index.js +0 -17
- package/build/index.js.map +0 -1
- package/build/schemas/common.d.ts +0 -6
- package/build/schemas/common.js +0 -24
- package/build/schemas/common.js.map +0 -1
- package/build/server/create-server.d.ts +0 -2
- package/build/server/create-server.js +0 -23
- package/build/server/create-server.js.map +0 -1
- package/build/server/instructions.d.ts +0 -1
- package/build/server/instructions.js +0 -22
- package/build/server/instructions.js.map +0 -1
- package/build/services/aave.service.d.ts +0 -29
- package/build/services/aave.service.js +0 -166
- package/build/services/aave.service.js.map +0 -1
- package/build/services/account.service.d.ts +0 -13
- package/build/services/account.service.js +0 -23
- package/build/services/account.service.js.map +0 -1
- package/build/services/blockchain.service.d.ts +0 -40
- package/build/services/blockchain.service.js +0 -81
- package/build/services/blockchain.service.js.map +0 -1
- package/build/services/ens.service.d.ts +0 -30
- package/build/services/ens.service.js +0 -78
- package/build/services/ens.service.js.map +0 -1
- package/build/services/gooddollar.service.d.ts +0 -38
- package/build/services/gooddollar.service.js +0 -127
- package/build/services/gooddollar.service.js.map +0 -1
- package/build/services/mento-fx.service.d.ts +0 -71
- package/build/services/mento-fx.service.js +0 -261
- package/build/services/mento-fx.service.js.map +0 -1
- package/build/services/self-session-store.d.ts +0 -19
- package/build/services/self-session-store.js +0 -28
- package/build/services/self-session-store.js.map +0 -1
- package/build/services/self.service.d.ts +0 -247
- package/build/services/self.service.js +0 -685
- package/build/services/self.service.js.map +0 -1
- package/build/services/token.service.d.ts +0 -54
- package/build/services/token.service.js +0 -147
- package/build/services/token.service.js.map +0 -1
- package/build/services/transaction.service.d.ts +0 -24
- package/build/services/transaction.service.js +0 -112
- package/build/services/transaction.service.js.map +0 -1
- package/build/tools/aave.tools.d.ts +0 -2
- package/build/tools/aave.tools.js +0 -55
- package/build/tools/aave.tools.js.map +0 -1
- package/build/tools/blockchain.tools.d.ts +0 -3
- package/build/tools/blockchain.tools.js +0 -88
- package/build/tools/blockchain.tools.js.map +0 -1
- package/build/tools/ens.tools.d.ts +0 -2
- package/build/tools/ens.tools.js +0 -27
- package/build/tools/ens.tools.js.map +0 -1
- package/build/tools/gooddollar.tools.d.ts +0 -2
- package/build/tools/gooddollar.tools.js +0 -23
- package/build/tools/gooddollar.tools.js.map +0 -1
- package/build/tools/helpers.d.ts +0 -3
- package/build/tools/helpers.js +0 -16
- package/build/tools/helpers.js.map +0 -1
- package/build/tools/index.d.ts +0 -5
- package/build/tools/index.js +0 -25
- package/build/tools/index.js.map +0 -1
- package/build/tools/mento-fx.tools.d.ts +0 -2
- package/build/tools/mento-fx.tools.js +0 -80
- package/build/tools/mento-fx.tools.js.map +0 -1
- package/build/tools/self.tools.d.ts +0 -2
- package/build/tools/self.tools.js +0 -242
- package/build/tools/self.tools.js.map +0 -1
- package/build/tools/token.tools.d.ts +0 -2
- package/build/tools/token.tools.js +0 -62
- package/build/tools/token.tools.js.map +0 -1
- package/build/tools/transaction.tools.d.ts +0 -2
- package/build/tools/transaction.tools.js +0 -49
- package/build/tools/transaction.tools.js.map +0 -1
- package/build/tools/types.d.ts +0 -5
- package/build/tools/types.js +0 -2
- package/build/tools/types.js.map +0 -1
- package/build/utils/erc20-allowance-storage.d.ts +0 -7
- package/build/utils/erc20-allowance-storage.js +0 -44
- package/build/utils/erc20-allowance-storage.js.map +0 -1
- package/build/utils/format-date.d.ts +0 -1
- package/build/utils/format-date.js +0 -12
- package/build/utils/format-date.js.map +0 -1
- package/build/utils/self-format.d.ts +0 -16
- package/build/utils/self-format.js +0 -59
- package/build/utils/self-format.js.map +0 -1
- package/build/utils/self-signing.d.ts +0 -4
- package/build/utils/self-signing.js +0 -38
- package/build/utils/self-signing.js.map +0 -1
package/build/tools/helpers.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function ok(data) {
|
|
2
|
-
const text = JSON.stringify(data, null, 2);
|
|
3
|
-
return {
|
|
4
|
-
content: [{ type: "text", text }],
|
|
5
|
-
structuredContent: typeof data === "object" && data !== null
|
|
6
|
-
? data
|
|
7
|
-
: { value: data },
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export function err(message) {
|
|
11
|
-
return {
|
|
12
|
-
content: [{ type: "text", text: message }],
|
|
13
|
-
isError: true,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/tools/helpers.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,EAAE,CAAC,IAAa;IAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3C,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACjC,iBAAiB,EACf,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;YACvC,CAAC,CAAE,IAAgC;YACnC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE;KACtB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,OAAe;IACjC,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAC1C,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
package/build/tools/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import type { AppContext } from "../context/app-context.js";
|
|
3
|
-
import type { ToolModule } from "./types.js";
|
|
4
|
-
export declare const toolModules: ToolModule[];
|
|
5
|
-
export declare function registerAllTools(server: McpServer, ctx: AppContext): void;
|
package/build/tools/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { accountTools, blockchainTools } from "./blockchain.tools.js";
|
|
2
|
-
import { gooddollarTools } from "./gooddollar.tools.js";
|
|
3
|
-
import { selfTools } from "./self.tools.js";
|
|
4
|
-
import { tokenTools } from "./token.tools.js";
|
|
5
|
-
import { transactionTools } from "./transaction.tools.js";
|
|
6
|
-
import { mentoFxTools } from "./mento-fx.tools.js";
|
|
7
|
-
import { aaveTools } from "./aave.tools.js";
|
|
8
|
-
import { ensTools } from "./ens.tools.js";
|
|
9
|
-
export const toolModules = [
|
|
10
|
-
blockchainTools,
|
|
11
|
-
accountTools,
|
|
12
|
-
ensTools,
|
|
13
|
-
tokenTools,
|
|
14
|
-
transactionTools,
|
|
15
|
-
mentoFxTools,
|
|
16
|
-
aaveTools,
|
|
17
|
-
gooddollarTools,
|
|
18
|
-
selfTools,
|
|
19
|
-
];
|
|
20
|
-
export function registerAllTools(server, ctx) {
|
|
21
|
-
for (const module of toolModules) {
|
|
22
|
-
module.register(server, ctx);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=index.js.map
|
package/build/tools/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,WAAW,GAAiB;IACvC,eAAe;IACf,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,gBAAgB;IAChB,YAAY;IACZ,SAAS;IACT,eAAe;IACf,SAAS;CACV,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,MAAiB,EAAE,GAAe;IACjE,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE,CAAC;QACjC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { addressSchema, tokenSymbolSchema } from "../schemas/common.js";
|
|
3
|
-
import { err, ok } from "./helpers.js";
|
|
4
|
-
const mentoFxInputSchema = z.object({
|
|
5
|
-
tokenIn: tokenSymbolSchema.describe("Input token symbol or address"),
|
|
6
|
-
tokenOut: tokenSymbolSchema.describe("Output token symbol or address"),
|
|
7
|
-
amount: z.string().describe("Human-readable amount of tokenIn, e.g. 100"),
|
|
8
|
-
});
|
|
9
|
-
const mentoFxWalletSchema = mentoFxInputSchema.extend({
|
|
10
|
-
recipient: addressSchema
|
|
11
|
-
.optional()
|
|
12
|
-
.describe("Address that receives output tokens (defaults to signer)"),
|
|
13
|
-
slippageTolerance: z
|
|
14
|
-
.number()
|
|
15
|
-
.min(0)
|
|
16
|
-
.max(20)
|
|
17
|
-
.optional()
|
|
18
|
-
.describe("Max slippage in percent (default 0.5)"),
|
|
19
|
-
deadlineMinutes: z
|
|
20
|
-
.number()
|
|
21
|
-
.int()
|
|
22
|
-
.positive()
|
|
23
|
-
.optional()
|
|
24
|
-
.describe("Transaction deadline in minutes (default 5)"),
|
|
25
|
-
});
|
|
26
|
-
export const mentoFxTools = {
|
|
27
|
-
register(server, ctx) {
|
|
28
|
-
server.registerTool("get_mento_fx_quote", {
|
|
29
|
-
title: "Get Mento FX Quote",
|
|
30
|
-
description: "Get an expected Mento FX conversion output for a token pair on mainnet (e.g. USDm → EURm). Oracle-priced via Mento protocol. Read-only; no wallet required.",
|
|
31
|
-
inputSchema: mentoFxInputSchema,
|
|
32
|
-
annotations: { readOnlyHint: true },
|
|
33
|
-
}, async ({ tokenIn, tokenOut, amount }) => {
|
|
34
|
-
try {
|
|
35
|
-
return ok(await ctx.mentoFx.getFxQuote(tokenIn, tokenOut, amount));
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
server.registerTool("estimate_mento_fx", {
|
|
42
|
-
title: "Estimate Mento FX",
|
|
43
|
-
description: "Estimate gas for a Mento FX conversion on mainnet, including ERC-20 approval if needed. Requires CELO_PRIVATE_KEY in MCP server env.",
|
|
44
|
-
inputSchema: mentoFxWalletSchema,
|
|
45
|
-
annotations: { readOnlyHint: true },
|
|
46
|
-
}, async ({ tokenIn, tokenOut, amount, recipient, slippageTolerance, deadlineMinutes }) => {
|
|
47
|
-
try {
|
|
48
|
-
return ok(await ctx.mentoFx.estimateFx(tokenIn, tokenOut, amount, {
|
|
49
|
-
recipient: recipient,
|
|
50
|
-
slippageTolerance,
|
|
51
|
-
deadlineMinutes,
|
|
52
|
-
}));
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
server.registerTool("execute_mento_fx", {
|
|
59
|
-
title: "Execute Mento FX",
|
|
60
|
-
description: "Execute a Mento FX conversion on mainnet (e.g. USDm → EURm via Mento oracle pools). Sends approval first if needed, then the FX trade. Requires CELO_PRIVATE_KEY in MCP server env.",
|
|
61
|
-
inputSchema: mentoFxWalletSchema,
|
|
62
|
-
annotations: {
|
|
63
|
-
destructiveHint: true,
|
|
64
|
-
openWorldHint: true,
|
|
65
|
-
},
|
|
66
|
-
}, async ({ tokenIn, tokenOut, amount, recipient, slippageTolerance, deadlineMinutes }) => {
|
|
67
|
-
try {
|
|
68
|
-
return ok(await ctx.mentoFx.executeFx(tokenIn, tokenOut, amount, {
|
|
69
|
-
recipient: recipient,
|
|
70
|
-
slippageTolerance,
|
|
71
|
-
deadlineMinutes,
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
//# sourceMappingURL=mento-fx.tools.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mento-fx.tools.js","sourceRoot":"","sources":["../../src/tools/mento-fx.tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,OAAO,EAAE,iBAAiB,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IACpE,QAAQ,EAAE,iBAAiB,CAAC,QAAQ,CAAC,gCAAgC,CAAC;IACtE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;CAC1E,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,MAAM,CAAC;IACpD,SAAS,EAAE,aAAa;SACrB,QAAQ,EAAE;SACV,QAAQ,CAAC,0DAA0D,CAAC;IACvE,iBAAiB,EAAE,CAAC;SACjB,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,EAAE,CAAC;SACP,QAAQ,EAAE;SACV,Q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AE,MAAM,EAAE;oBACtD,SAAS,EAAE,SAAsC;oBACjD,iBAAiB;oBACjB,eAAe;iBAChB,CAAC,CACH,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACrE,CAAC;QACH,CAAC,CACF,CAAC;QAEF,MAAM,CAAC,YAAY,CACjB,kBAAkB,EAClB;YACE,KAAK,EAAE,kBAAkB;YACzB,WAAW,EACT,qLAAqL;YACvL,WAAW,EAAE,mBAAmB;YAChC,WAAW,EAAE;gBACX,eAAe,EAAE,IAAI;gBACrB,aAAa,EAAE,IAAI;aACpB;SACF,EACD,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,eAAe,EAAE,EAAE,EAAE;YACrF,IAAI,CAAC;gBACH,OAAO,EAAE,CACP,MAAM,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE;oBACrD,SAAS,EAAE,SAAsC;oBACjD,iBAAiB;oBACjB,eAAe;iBAChB,CAAC,CACH,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACrE,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { selfDemoUrl } from "../config/self.js";
|
|
3
|
-
import { addressSchema } from "../schemas/common.js";
|
|
4
|
-
import { err, ok } from "./helpers.js";
|
|
5
|
-
const SELF_DEMO_VERIFY_URL = selfDemoUrl("/api/demo/verify");
|
|
6
|
-
const selfRegistrationModeSchema = z
|
|
7
|
-
.enum([
|
|
8
|
-
"linked",
|
|
9
|
-
"wallet-free",
|
|
10
|
-
"smartwallet",
|
|
11
|
-
"self-custody",
|
|
12
|
-
"ed25519",
|
|
13
|
-
"ed25519-linked",
|
|
14
|
-
])
|
|
15
|
-
.optional();
|
|
16
|
-
export const selfTools = {
|
|
17
|
-
register(server, ctx) {
|
|
18
|
-
server.registerTool("verify_self_agent", {
|
|
19
|
-
title: "Verify Self Agent",
|
|
20
|
-
description: "Verify whether an agent address is backed by a real human on Self Agent ID (Celo mainnet). Checks on-chain registration, proof provider, credentials, and proof expiry.",
|
|
21
|
-
inputSchema: z.object({
|
|
22
|
-
agent_address: addressSchema,
|
|
23
|
-
require_age: z
|
|
24
|
-
.union([z.literal(0), z.literal(18), z.literal(21)])
|
|
25
|
-
.optional()
|
|
26
|
-
.default(0),
|
|
27
|
-
require_ofac: z.boolean().optional().default(false),
|
|
28
|
-
require_self_provider: z.boolean().optional().default(true),
|
|
29
|
-
}),
|
|
30
|
-
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
|
|
31
|
-
}, async (args) => {
|
|
32
|
-
try {
|
|
33
|
-
return ok(await ctx.self.verifyAgent({
|
|
34
|
-
agentAddress: args.agent_address,
|
|
35
|
-
requireAge: args.require_age,
|
|
36
|
-
requireOfac: args.require_ofac,
|
|
37
|
-
requireSelfProvider: args.require_self_provider,
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
server.registerTool("lookup_self_agent", {
|
|
45
|
-
title: "Look Up Self Agent",
|
|
46
|
-
description: "Look up a Self Agent ID by numeric on-chain ID via ai.self.xyz, enriched with on-chain proof expiry from the registry.",
|
|
47
|
-
inputSchema: z.object({
|
|
48
|
-
agent_id: z.number().int().positive(),
|
|
49
|
-
}),
|
|
50
|
-
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
|
|
51
|
-
}, async ({ agent_id }) => {
|
|
52
|
-
try {
|
|
53
|
-
return ok(await ctx.self.lookupAgent(agent_id));
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
server.registerTool("verify_self_request", {
|
|
60
|
-
title: "Verify Self Agent Request",
|
|
61
|
-
description: "Verify incoming HTTP request headers signed by a Self Agent (x-self-agent-signature, x-self-agent-timestamp). Recovers signer from signature and checks on-chain registration.",
|
|
62
|
-
inputSchema: z.object({
|
|
63
|
-
agent_signature: z
|
|
64
|
-
.string()
|
|
65
|
-
.regex(/^0x[a-fA-F0-9]+$/, "Invalid signature hex"),
|
|
66
|
-
agent_timestamp: z.string(),
|
|
67
|
-
method: z.string(),
|
|
68
|
-
path: z.string(),
|
|
69
|
-
body: z.string().optional(),
|
|
70
|
-
keytype: z.string().optional(),
|
|
71
|
-
agent_key: z
|
|
72
|
-
.string()
|
|
73
|
-
.regex(/^0x[a-fA-F0-9]+$/, "Invalid agent key hex")
|
|
74
|
-
.optional(),
|
|
75
|
-
}),
|
|
76
|
-
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
77
|
-
}, async (args) => {
|
|
78
|
-
try {
|
|
79
|
-
return ok(await ctx.self.verifyRequest({
|
|
80
|
-
agentSignature: args.agent_signature,
|
|
81
|
-
agentTimestamp: args.agent_timestamp,
|
|
82
|
-
method: args.method,
|
|
83
|
-
path: args.path,
|
|
84
|
-
body: args.body,
|
|
85
|
-
keytype: args.keytype,
|
|
86
|
-
agentKey: args.agent_key,
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
server.registerTool("register_self_agent", {
|
|
94
|
-
title: "Register Self Agent",
|
|
95
|
-
description: "Start Self Agent ID registration. Returns a QR/deep link for the human to scan with the Self app. Poll with check_self_registration.",
|
|
96
|
-
inputSchema: z.object({
|
|
97
|
-
mode: selfRegistrationModeSchema.describe("Registration mode (default wallet-free)"),
|
|
98
|
-
minimum_age: z
|
|
99
|
-
.union([z.literal(0), z.literal(18), z.literal(21)])
|
|
100
|
-
.optional(),
|
|
101
|
-
ofac: z.boolean().optional(),
|
|
102
|
-
human_address: addressSchema.optional(),
|
|
103
|
-
agent_name: z.string().optional(),
|
|
104
|
-
agent_description: z.string().optional(),
|
|
105
|
-
}),
|
|
106
|
-
annotations: {
|
|
107
|
-
destructiveHint: true,
|
|
108
|
-
openWorldHint: true,
|
|
109
|
-
},
|
|
110
|
-
}, async (args) => {
|
|
111
|
-
try {
|
|
112
|
-
return ok(await ctx.self.registerAgent({
|
|
113
|
-
mode: args.mode,
|
|
114
|
-
minimumAge: args.minimum_age,
|
|
115
|
-
ofac: args.ofac,
|
|
116
|
-
humanAddress: args.human_address,
|
|
117
|
-
agentName: args.agent_name,
|
|
118
|
-
agentDescription: args.agent_description,
|
|
119
|
-
}));
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
server.registerTool("check_self_registration", {
|
|
126
|
-
title: "Check Self Registration",
|
|
127
|
-
description: "Poll a pending Self registration, proof refresh, or deregistration session. Returns private_key_hex when registration completes.",
|
|
128
|
-
inputSchema: z.object({
|
|
129
|
-
session_id: z.string(),
|
|
130
|
-
}),
|
|
131
|
-
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
|
|
132
|
-
}, async ({ session_id }) => {
|
|
133
|
-
try {
|
|
134
|
-
return ok(await ctx.self.checkRegistration(session_id));
|
|
135
|
-
}
|
|
136
|
-
catch (error) {
|
|
137
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
server.registerTool("get_self_identity", {
|
|
141
|
-
title: "Get Self Agent Identity",
|
|
142
|
-
description: "Return the configured Self agent's on-chain identity, credentials summary, and proof expiry. Requires SELF_AGENT_PRIVATE_KEY in MCP server env.",
|
|
143
|
-
inputSchema: z.object({}),
|
|
144
|
-
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
145
|
-
}, async () => {
|
|
146
|
-
try {
|
|
147
|
-
return ok(await ctx.self.getIdentity());
|
|
148
|
-
}
|
|
149
|
-
catch (error) {
|
|
150
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
server.registerTool("refresh_self_proof", {
|
|
154
|
-
title: "Refresh Self Proof",
|
|
155
|
-
description: "Start a human proof refresh after on-chain proof expiry (isProofFresh is false). Returns an error while the proof is still fresh. Poll completion with check_self_registration. Self SDK also supports deregister_self_agent then register_self_agent.",
|
|
156
|
-
inputSchema: z.object({
|
|
157
|
-
agent_id: z.number().int().positive().optional(),
|
|
158
|
-
}),
|
|
159
|
-
annotations: { openWorldHint: true },
|
|
160
|
-
}, async ({ agent_id }) => {
|
|
161
|
-
try {
|
|
162
|
-
return ok(await ctx.self.refreshProof({
|
|
163
|
-
agentId: agent_id,
|
|
164
|
-
}));
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
server.registerTool("deregister_self_agent", {
|
|
171
|
-
title: "Deregister Self Agent",
|
|
172
|
-
description: "Start irreversible Self agent deregistration. Human must confirm via Self app QR. Poll with check_self_registration. Requires SELF_AGENT_PRIVATE_KEY in MCP server env.",
|
|
173
|
-
inputSchema: z.object({}),
|
|
174
|
-
annotations: {
|
|
175
|
-
destructiveHint: true,
|
|
176
|
-
openWorldHint: true,
|
|
177
|
-
},
|
|
178
|
-
}, async () => {
|
|
179
|
-
try {
|
|
180
|
-
return ok(await ctx.self.deregisterAgent());
|
|
181
|
-
}
|
|
182
|
-
catch (error) {
|
|
183
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
server.registerTool("sign_self_request", {
|
|
187
|
-
title: "Sign Self Agent Request",
|
|
188
|
-
description: `Sign an HTTP request with the configured Self agent identity. Returns x-self-agent-* headers for gated APIs. For Self demo endpoints on Celo mainnet, use ?network=celo-mainnet (e.g. POST ${SELF_DEMO_VERIFY_URL}).`,
|
|
189
|
-
inputSchema: z.object({
|
|
190
|
-
method: z.enum(["GET", "POST", "PUT", "DELETE"]),
|
|
191
|
-
url: z
|
|
192
|
-
.string()
|
|
193
|
-
.url()
|
|
194
|
-
.refine((u) => u.startsWith("http://") || u.startsWith("https://"), {
|
|
195
|
-
message: "Only http:// and https:// URLs are allowed",
|
|
196
|
-
}),
|
|
197
|
-
body: z.string().optional(),
|
|
198
|
-
}),
|
|
199
|
-
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
200
|
-
}, async ({ method, url, body }) => {
|
|
201
|
-
try {
|
|
202
|
-
return ok(await ctx.self.signRequest({
|
|
203
|
-
method,
|
|
204
|
-
url,
|
|
205
|
-
body,
|
|
206
|
-
}));
|
|
207
|
-
}
|
|
208
|
-
catch (error) {
|
|
209
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
server.registerTool("authenticated_self_fetch", {
|
|
213
|
-
title: "Authenticated Self Fetch",
|
|
214
|
-
description: `Make an HTTP request with Self Agent ID authentication headers applied automatically. For Self demo endpoints on Celo mainnet, use ?network=celo-mainnet (e.g. POST ${SELF_DEMO_VERIFY_URL}).`,
|
|
215
|
-
inputSchema: z.object({
|
|
216
|
-
method: z.enum(["GET", "POST", "PUT", "DELETE"]),
|
|
217
|
-
url: z
|
|
218
|
-
.string()
|
|
219
|
-
.url()
|
|
220
|
-
.refine((u) => u.startsWith("http://") || u.startsWith("https://"), {
|
|
221
|
-
message: "Only http:// and https:// URLs are allowed",
|
|
222
|
-
}),
|
|
223
|
-
body: z.string().optional(),
|
|
224
|
-
content_type: z.string().optional().default("application/json"),
|
|
225
|
-
}),
|
|
226
|
-
annotations: { openWorldHint: true },
|
|
227
|
-
}, async ({ method, url, body, content_type }) => {
|
|
228
|
-
try {
|
|
229
|
-
return ok(await ctx.self.authenticatedFetch({
|
|
230
|
-
method,
|
|
231
|
-
url,
|
|
232
|
-
body,
|
|
233
|
-
contentType: content_type,
|
|
234
|
-
}));
|
|
235
|
-
}
|
|
236
|
-
catch (error) {
|
|
237
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
},
|
|
241
|
-
};
|
|
242
|
-
//# sourceMappingURL=self.tools.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"self.tools.js","sourceRoot":"","sources":["../../src/tools/self.tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,oBAAoB,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAC;AAE7D,MAAM,0BAA0B,GAAG,CAAC;KACjC,IAAI,CAAC;IACJ,QAAQ;IACR,aAAa;IACb,aAAa;IACb,cAAc;IACd,SAAS;IACT,gBAAgB;CACjB,CAAC;KACD,QAAQ,EAAE,CAAC;AAEd,MAAM,CAAC,MAAM,SAAS,GAAe;IACnC,QAAQ,CAAC,MAAiB,EAAE,GAAe;QACzC,MAAM,CAAC,YAAY,CACjB,mBAAmB,EACnB;YACE,KAAK,EAAE,mBAAmB;YAC1B,WAAW,EACT,yKAAyK;YAC3K,WAAW,EAAE,CAAC,CA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AAE,IAAI,EAAE;SACrC,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE;YAC5C,IAAI,CAAC;gBACH,OAAO,EAAE,CACP,MAAM,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC;oBAChC,MAAM;oBACN,GAAG;oBACH,IAAI;oBACJ,WAAW,EAAE,YAAY;iBAC1B,CAAC,CACH,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACrE,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { addressSchema, tokenSymbolSchema } from "../schemas/common.js";
|
|
3
|
-
import { err, ok } from "./helpers.js";
|
|
4
|
-
export const tokenTools = {
|
|
5
|
-
register(server, ctx) {
|
|
6
|
-
server.registerTool("get_celo_balances", {
|
|
7
|
-
title: "Get Celo Balances",
|
|
8
|
-
description: "Returns native CELO and ERC-20 balances for an address on mainnet. Defaults to CELO + USDm.",
|
|
9
|
-
inputSchema: z.object({
|
|
10
|
-
address: addressSchema,
|
|
11
|
-
tokens: z.array(tokenSymbolSchema).optional(),
|
|
12
|
-
}),
|
|
13
|
-
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
14
|
-
}, async ({ address, tokens }) => {
|
|
15
|
-
try {
|
|
16
|
-
return ok(await ctx.token.getBalances(address, tokens));
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
server.registerTool("get_stablecoin_balances", {
|
|
23
|
-
title: "Get Stablecoin Balances",
|
|
24
|
-
description: "Returns balances for Celo mainnet local stablecoins (Mento, USDC, USDT, etc.). Checks all stablecoins by default and omits zero balances.",
|
|
25
|
-
inputSchema: z.object({
|
|
26
|
-
address: addressSchema,
|
|
27
|
-
stablecoins: z
|
|
28
|
-
.array(z.string())
|
|
29
|
-
.optional()
|
|
30
|
-
.describe("Stablecoin symbols to check (e.g. USDm, USDC). Defaults to all mainnet stablecoins."),
|
|
31
|
-
includeZero: z
|
|
32
|
-
.boolean()
|
|
33
|
-
.optional()
|
|
34
|
-
.describe("Include stablecoins with zero balance"),
|
|
35
|
-
}),
|
|
36
|
-
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
37
|
-
}, async ({ address, stablecoins, includeZero }) => {
|
|
38
|
-
try {
|
|
39
|
-
return ok(await ctx.token.getStablecoinBalances(address, { stablecoins, includeZero }));
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
server.registerTool("get_token_info", {
|
|
46
|
-
title: "Get Token Info",
|
|
47
|
-
description: "Returns metadata for a known or custom ERC-20 token on mainnet.",
|
|
48
|
-
inputSchema: z.object({
|
|
49
|
-
token: tokenSymbolSchema,
|
|
50
|
-
}),
|
|
51
|
-
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
52
|
-
}, async ({ token }) => {
|
|
53
|
-
try {
|
|
54
|
-
return ok(await ctx.token.getTokenInfo(token));
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
//# sourceMappingURL=token.tools.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token.tools.js","sourceRoot":"","sources":["../../src/tools/token.tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB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|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { addressOrEnsSchema, tokenSymbolSchema } from "../schemas/common.js";
|
|
3
|
-
import { err, ok } from "./helpers.js";
|
|
4
|
-
export const transactionTools = {
|
|
5
|
-
register(server, ctx) {
|
|
6
|
-
server.registerTool("estimate_send", {
|
|
7
|
-
title: "Estimate Send",
|
|
8
|
-
description: "Estimates gas for sending CELO or an ERC-20 token on mainnet. Accepts a 0x address or ENS name as recipient. Requires CELO_PRIVATE_KEY in MCP server env.",
|
|
9
|
-
inputSchema: z.object({
|
|
10
|
-
to: addressOrEnsSchema,
|
|
11
|
-
token: tokenSymbolSchema.default("CELO"),
|
|
12
|
-
amount: z.string().describe("Human-readable amount, e.g. 1.5"),
|
|
13
|
-
}),
|
|
14
|
-
annotations: { readOnlyHint: true },
|
|
15
|
-
}, async ({ to, token, amount }) => {
|
|
16
|
-
try {
|
|
17
|
-
const { address, ens } = await ctx.ens.resolveAddressOrEns(to);
|
|
18
|
-
const estimate = await ctx.transaction.estimateSend(address, token, amount);
|
|
19
|
-
return ok(ens ? { ...estimate, ens } : estimate);
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
server.registerTool("send_token", {
|
|
26
|
-
title: "Send Token",
|
|
27
|
-
description: "Send CELO or an ERC-20 token on mainnet. Accepts a 0x address or ENS name as recipient. Requires CELO_PRIVATE_KEY in MCP server env.",
|
|
28
|
-
inputSchema: z.object({
|
|
29
|
-
to: addressOrEnsSchema,
|
|
30
|
-
token: tokenSymbolSchema.default("CELO"),
|
|
31
|
-
amount: z.string().describe("Human-readable amount, e.g. 0.01"),
|
|
32
|
-
}),
|
|
33
|
-
annotations: {
|
|
34
|
-
destructiveHint: true,
|
|
35
|
-
openWorldHint: true,
|
|
36
|
-
},
|
|
37
|
-
}, async ({ to, token, amount }) => {
|
|
38
|
-
try {
|
|
39
|
-
const { address, ens } = await ctx.ens.resolveAddressOrEns(to);
|
|
40
|
-
const result = await ctx.transaction.sendToken(address, token, amount);
|
|
41
|
-
return ok(ens ? { ...result, ens } : result);
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
return err(error instanceof Error ? error.message : String(error));
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=transaction.tools.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.tools.js","sourceRoot":"","sources":["../../src/tools/transaction.tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,CAAC,MAAM,gBAAgB,GAAe;IAC1C,QAAQ,CAAC,MAAiB,EAAE,GAAe;QACzC,MAAM,CAAC,YAAY,CACjB,eAAe,EACf;YACE,KAAK,EAAE,eAAe;YACtB,WAAW,EACT,2JAA2J;YAC7J,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;gBACpB,EAAE,EAAE,kBAAkB;gBACtB,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC;gBACxC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;aAC/D,CAAC;YACF,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE;SACpC,EACD,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;YAC9B,IAAI,CAAC;gBACH,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;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CAAC,CAAC,MAAM,CAAC,CAAC;YAC/C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACrE,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/build/tools/types.d.ts
DELETED
package/build/tools/types.js
DELETED
package/build/tools/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type Address, type Hex, type StateOverride } from "viem";
|
|
2
|
-
/** Common base slots for ERC-20 allowance mappings (Mento stablecoins use 7). */
|
|
3
|
-
declare const ALLOWANCE_MAPPING_SLOTS: readonly [7n, 1n, 0n, 2n, 3n, 4n, 5n, 6n, 8n, 9n, 10n, 11n, 12n, 13n, 14n];
|
|
4
|
-
export declare function erc20AllowanceStorageSlot(owner: Address, spender: Address, mappingSlot: bigint): Hex;
|
|
5
|
-
export declare function erc20AllowanceStateOverride(token: Address, owner: Address, spender: Address, amount: bigint, mappingSlot: bigint): StateOverride;
|
|
6
|
-
export declare function isLikelyTransferFailed(error: unknown): boolean;
|
|
7
|
-
export { ALLOWANCE_MAPPING_SLOTS };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { encodeAbiParameters, keccak256, pad, parseAbiParameters, toHex, } from "viem";
|
|
2
|
-
/** Common base slots for ERC-20 allowance mappings (Mento stablecoins use 7). */
|
|
3
|
-
const ALLOWANCE_MAPPING_SLOTS = [
|
|
4
|
-
7n,
|
|
5
|
-
1n,
|
|
6
|
-
0n,
|
|
7
|
-
2n,
|
|
8
|
-
3n,
|
|
9
|
-
4n,
|
|
10
|
-
5n,
|
|
11
|
-
6n,
|
|
12
|
-
8n,
|
|
13
|
-
9n,
|
|
14
|
-
10n,
|
|
15
|
-
11n,
|
|
16
|
-
12n,
|
|
17
|
-
13n,
|
|
18
|
-
14n,
|
|
19
|
-
];
|
|
20
|
-
export function erc20AllowanceStorageSlot(owner, spender, mappingSlot) {
|
|
21
|
-
const ownerSlot = keccak256(encodeAbiParameters(parseAbiParameters("address, uint256"), [owner, mappingSlot]));
|
|
22
|
-
return keccak256(encodeAbiParameters(parseAbiParameters("address, bytes32"), [spender, ownerSlot]));
|
|
23
|
-
}
|
|
24
|
-
export function erc20AllowanceStateOverride(token, owner, spender, amount, mappingSlot) {
|
|
25
|
-
return [
|
|
26
|
-
{
|
|
27
|
-
address: token,
|
|
28
|
-
stateDiff: [
|
|
29
|
-
{
|
|
30
|
-
slot: erc20AllowanceStorageSlot(owner, spender, mappingSlot),
|
|
31
|
-
value: pad(toHex(amount)),
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
}
|
|
37
|
-
export function isLikelyTransferFailed(error) {
|
|
38
|
-
const message = error instanceof Error
|
|
39
|
-
? `${error.message} ${error.cause instanceof Error ? error.cause.message : ""}`
|
|
40
|
-
: String(error);
|
|
41
|
-
return /transfer failed/i.test(message);
|
|
42
|
-
}
|
|
43
|
-
export { ALLOWANCE_MAPPING_SLOTS };
|
|
44
|
-
//# sourceMappingURL=erc20-allowance-storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"erc20-allowance-storage.js","sourceRoot":"","sources":["../../src/utils/erc20-allowance-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,GAAG,EACH,kBAAkB,EAClB,KAAK,GAIN,MAAM,MAAM,CAAC;AAEd,iFAAiF;AACjF,MAAM,uBAAuB,GAAG;IAC9B,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,E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export function formatUnixDate(unixSeconds) {
|
|
2
|
-
const date = new Date(Number(unixSeconds) * 1000);
|
|
3
|
-
return new Intl.DateTimeFormat("en-US", {
|
|
4
|
-
month: "long",
|
|
5
|
-
day: "numeric",
|
|
6
|
-
year: "numeric",
|
|
7
|
-
timeZone: "UTC",
|
|
8
|
-
})
|
|
9
|
-
.format(date)
|
|
10
|
-
.replace(",", "");
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=format-date.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format-date.js","sourceRoot":"","sources":["../../src/utils/format-date.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,WAA4B;IACzD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;IAClD,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;QACtC,KAAK,EAAE,MAAM;QACb,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,KAAK;KAChB,CAAC;SACC,MAAM,CAAC,IAAI,CAAC;SACZ,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACtB,CAAC"}
|