@esseyonsui/sui-mcp-v3 0.1.2 → 0.1.4
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 +25 -12
- package/dist/client.d.ts +3 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +17 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/failure.d.ts +4 -2
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +15 -3
- package/dist/fund.d.ts +21 -0
- package/dist/fund.d.ts.map +1 -0
- package/dist/fund.js +44 -0
- package/dist/io.d.ts +12 -2
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +36 -4
- package/dist/main.js +11 -6
- package/dist/tools-more.d.ts +3 -0
- package/dist/tools-more.d.ts.map +1 -0
- package/dist/tools-more.js +233 -0
- package/dist/tools.d.ts +5 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +10 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,11 +22,14 @@ The server speaks the same hand-written stdio subset as `packages/mcp`: `initial
|
|
|
22
22
|
|
|
23
23
|
`ESSEY_NOTE_KEY_FILE` and `ESSEY_AGENT_KEY_FILE` are mode-600 paths. The note file is 32 raw bytes or 64 hex
|
|
24
24
|
digits; the server passes it to `Essey.connect` and does not put it on the tool context. The agent key file holds
|
|
25
|
-
the `suiprivkey` text `essey-sui-mcp-v3-init` writes
|
|
26
|
-
|
|
27
|
-
the fresh sender the SDK derives from the note key, which then opens
|
|
28
|
-
(`src/agent.ts`)
|
|
29
|
-
|
|
25
|
+
the `suiprivkey` text `essey-sui-mcp-v3-init` writes (or 64 hex digits, as 0.1.x wallets hold); the server loads
|
|
26
|
+
it at startup (`src/keys.ts`) and signs two kinds of transaction with it. Inside `essey_sale_open`, a transfer of
|
|
27
|
+
the item being sold from the agent address to the fresh sender the SDK derives from the note key, which then opens
|
|
28
|
+
the room while the relayer pays (`src/agent.ts`); no tool argument names the recipient. Inside
|
|
29
|
+
`essey_notes_deposit`, `0x2::coin::send_funds` of each deposit piece's value from the agent's own wallet to that
|
|
30
|
+
piece's fresh deposit sender (`src/fund.ts`), which reads the file again for each piece and returns a fixed error
|
|
31
|
+
with no key text when funding fails. The agent address pays the gas of both, so fund it with the coin and some SUI
|
|
32
|
+
before depositing. Every other loan, note and sale call goes through the SDK's relayer. No tool argument is a key,
|
|
30
33
|
a seed, or the invite. `ESSEY_INVITE`, when set, is the
|
|
31
34
|
invite gate for `essey_credential_obtain`. Results drop secret names (`borrowerSk`, `loanKey`, `salt`, and the same words inside a larger name), raw bytes,
|
|
32
35
|
`suiprivkey` text, bare 64-hex seeds, and the invite. An SDK failure returns its error code and a fixed hint,
|
|
@@ -38,15 +41,27 @@ not the SDK's message; a service refusal adds the service's own all-capitals cod
|
|
|
38
41
|
Credential: `essey_credential_obtain`, `essey_credential_status`, `essey_credential_renew`.
|
|
39
42
|
|
|
40
43
|
Notes: `essey_faucet`, `essey_notes_deposit`, `essey_notes_balance` (scan; balance and note count only),
|
|
41
|
-
`essey_notes_withdraw`, `essey_notes_receive_address`, `essey_notes_transfer
|
|
42
|
-
|
|
44
|
+
`essey_notes_withdraw`, `essey_notes_receive_address`, `essey_notes_transfer`, `essey_notes_exit` (every note
|
|
45
|
+
of a coin, at most two, less fees), `essey_notes_recover` (retries a deposit that stopped before it landed).
|
|
46
|
+
`essey_notes_deposit` is paid from the agent wallet (see Keys).
|
|
43
47
|
|
|
44
48
|
Borrower: `essey_loan_open` (collateral coin and amount, loan coin, principal, max rate, term, offer window),
|
|
45
49
|
`essey_loan_settle`, `essey_loan_repay`, `essey_loan_release`, `essey_loan_cancel`, `essey_loan_reclaim_coll`,
|
|
46
|
-
`essey_loan_heartbeat`, `essey_loan_topup`, `essey_loan_collect_surplus
|
|
50
|
+
`essey_loan_heartbeat`, `essey_loan_topup`, `essey_loan_collect_surplus`, `essey_loan_slash` (an offer whose
|
|
51
|
+
sealed copy does not open its commit), `essey_loan_liquidate` and `essey_loan_seize_default` (from this server's
|
|
52
|
+
own terms).
|
|
53
|
+
|
|
54
|
+
Refinance: the borrower calls `essey_loan_refi_open` (new principal, max rate, term, offer window); lenders use
|
|
55
|
+
`essey_loan_request` and `essey_loan_offer`; after the window the borrower calls `essey_loan_refi_settle`, or
|
|
56
|
+
`essey_loan_refi_cancel` to keep the current terms. The old lender takes its payoff with `essey_loan_collect`.
|
|
47
57
|
|
|
48
58
|
Lender: `essey_loan_list`, `essey_loan_request`, `essey_loan_offer` (loan id, rate), `essey_loan_collect`,
|
|
49
|
-
`essey_loan_reclaim`, `essey_loan_collect_seized
|
|
59
|
+
`essey_loan_reclaim`, `essey_loan_collect_seized`, `essey_loan_fault_liquidate` (a loan a keeper marked FAULT).
|
|
60
|
+
|
|
61
|
+
Keeper (a credential from `essey_credential_obtain` with role `keeper`): `essey_keeper_judge` (liquidate, fault
|
|
62
|
+
or skip, sending nothing), `essey_keeper_liquidate`, `essey_keeper_fault`, `essey_keeper_mint_badge`,
|
|
63
|
+
`essey_keeper_badge`. The judge, liquidate and fault tools take `via: "badge"` to use the minted badge instead
|
|
64
|
+
of the keeper pass.
|
|
50
65
|
|
|
51
66
|
Each loan tool calls the SDK's own planner, so the server builds every proof with the circuits `/v3/config`
|
|
52
67
|
pins, reads the chain over Sui GraphQL and seals with the deployment's Seal set (`src/io.ts`). What a later step
|
|
@@ -72,8 +87,6 @@ its public `demo::mint` and transfer to the agent address.
|
|
|
72
87
|
`essey_loan_status` reads one loan's public fields from chain. `essey_loan_view` runs the SDK's `localHealth`
|
|
73
88
|
and `covered` on the public fields in its arguments and reads nothing.
|
|
74
89
|
|
|
75
|
-
There is no refinance tool.
|
|
76
|
-
|
|
77
90
|
Amounts are whole-number strings in the coin's smallest unit.
|
|
78
91
|
|
|
79
92
|
## Configuration
|
|
@@ -84,7 +97,7 @@ Amounts are whole-number strings in the coin's smallest unit.
|
|
|
84
97
|
| `ESSEY_V3_CONFIG` | `https` URL of `GET /v3/config`, or `http` on localhost, or a path to that JSON (required). A URL is what lets the SDK name the v3api. A file has no API origin. |
|
|
85
98
|
| `ESSEY_STATE_FILE` | mode-600 state path the SDK keeps the credential in (required) |
|
|
86
99
|
| `ESSEY_NOTE_KEY_FILE` | mode-600 note seed (required) |
|
|
87
|
-
| `ESSEY_AGENT_KEY_FILE` | mode-600 agent key file (required; signs only the sale item hand-over, see Keys)
|
|
100
|
+
| `ESSEY_AGENT_KEY_FILE` | mode-600 agent key file (required; signs only the sale item hand-over and deposit funding, see Keys) |
|
|
88
101
|
| `ESSEY_INVITE` | optional invite token, 1..256 characters without whitespace |
|
|
89
102
|
| `ESSEY_RELAYER` | `clear` (default) or `onion` |
|
|
90
103
|
| `ESSEY_GRAPHQL` | Sui GraphQL URL, `https` or `http` on localhost (default `https://graphql.testnet.sui.io/graphql`) |
|
package/dist/client.d.ts
CHANGED
|
@@ -11,14 +11,15 @@ export type OpenParams = Extract<Parameters<Loans["open"]>[0], {
|
|
|
11
11
|
*/
|
|
12
12
|
export type DemoClient = {
|
|
13
13
|
credential: Essey["credential"];
|
|
14
|
-
notes: Pick<Essey["notes"], "faucet" | "deposit" | "scan" | "withdraw" | "transfer" | "receiveAddress">;
|
|
15
|
-
loans: Pick<Loans, "request" | "lend" | "accept" | "payBack" | "release" | "collect" | "cancelOwn" | "reclaimCollateral" | "reclaimOffer" | "collectSeized" | "collectSurplus" | "heartbeat" | "topup" | "list" | "view"> & {
|
|
14
|
+
notes: Pick<Essey["notes"], "faucet" | "deposit" | "scan" | "withdraw" | "transfer" | "receiveAddress" | "exit" | "recoverStranded">;
|
|
15
|
+
loans: Pick<Loans, "request" | "lend" | "accept" | "payBack" | "release" | "collect" | "cancelOwn" | "reclaimCollateral" | "reclaimOffer" | "collectSeized" | "collectSurplus" | "heartbeat" | "topup" | "list" | "view" | "openRefi" | "settleRefi" | "cancelRefi" | "slash" | "fault" | "liquidate" | "seizeDefault" | "faultLiquidate" | "keeperLiquidate"> & {
|
|
16
16
|
open(p: OpenParams): Promise<{
|
|
17
17
|
id: string;
|
|
18
18
|
} & Landed>;
|
|
19
19
|
health(loan: PublicLoan): Promise<LoanStatus>;
|
|
20
20
|
};
|
|
21
21
|
sales: Essey["sales"] & SaleChain;
|
|
22
|
+
keeper: Pick<Essey["keeper"], "mintBadge" | "badge" | "judge">;
|
|
22
23
|
};
|
|
23
24
|
/** The agent key's public address and the vault lookup; the key itself stays in `agent.ts`. */
|
|
24
25
|
export type SaleChain = {
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG7D,KAAK,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;AAC5B,KAAK,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACpD,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAEtF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,KAAK,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG7D,KAAK,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;AAC5B,KAAK,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACpD,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAEtF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,KAAK,EAAE,IAAI,CACT,KAAK,CAAC,OAAO,CAAC,EACd,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,gBAAgB,GAAG,MAAM,GAAG,iBAAiB,CACxG,CAAC;IACF,KAAK,EAAE,IAAI,CACT,KAAK,EACH,SAAS,GACT,MAAM,GACN,QAAQ,GACR,SAAS,GACT,SAAS,GACT,SAAS,GACT,WAAW,GACX,mBAAmB,GACnB,cAAc,GACd,eAAe,GACf,gBAAgB,GAChB,WAAW,GACX,OAAO,GACP,MAAM,GACN,MAAM,GACN,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,OAAO,GACP,OAAO,GACP,WAAW,GACX,cAAc,GACd,gBAAgB,GAChB,iBAAiB,CACpB,GAAG;QACF,IAAI,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,GAAG,MAAM,CAAC,CAAC;QACtD,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;KAC/C,CAAC;IACF,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IAClC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC;CAChE,CAAC;AAEF,+FAA+F;AAC/F,MAAM,MAAM,SAAS,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC;AASzF,wBAAgB,QAAQ,CACtB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,SAAS,EAChB,MAAM,GAAE,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,CAA6C,GAChF,UAAU,CA+DZ;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,UAAU,CAShF"}
|
package/dist/client.js
CHANGED
|
@@ -7,7 +7,7 @@ async function openPlanned(essey, p) {
|
|
|
7
7
|
return r;
|
|
8
8
|
}
|
|
9
9
|
export function clientOf(essey, chain, health = (loan) => Promise.resolve(statusOf(loan))) {
|
|
10
|
-
const { loans, notes, sales } = essey;
|
|
10
|
+
const { keeper, loans, notes, sales } = essey;
|
|
11
11
|
return {
|
|
12
12
|
credential: essey.credential,
|
|
13
13
|
notes: {
|
|
@@ -17,6 +17,8 @@ export function clientOf(essey, chain, health = (loan) => Promise.resolve(status
|
|
|
17
17
|
withdraw: (coin, amount, to) => notes.withdraw(coin, amount, to),
|
|
18
18
|
transfer: (coin, amount, to) => notes.transfer(coin, amount, to),
|
|
19
19
|
receiveAddress: () => notes.receiveAddress(),
|
|
20
|
+
exit: (coin, to) => notes.exit(coin, to),
|
|
21
|
+
recoverStranded: () => notes.recoverStranded(),
|
|
20
22
|
},
|
|
21
23
|
loans: {
|
|
22
24
|
open: (p) => openPlanned(essey, p),
|
|
@@ -35,6 +37,15 @@ export function clientOf(essey, chain, health = (loan) => Promise.resolve(status
|
|
|
35
37
|
topup: (p) => loans.topup(p),
|
|
36
38
|
list: () => loans.list(),
|
|
37
39
|
view: (id) => loans.view(id),
|
|
40
|
+
openRefi: (p) => loans.openRefi(p),
|
|
41
|
+
settleRefi: (p) => loans.settleRefi(p),
|
|
42
|
+
cancelRefi: (id) => loans.cancelRefi(id),
|
|
43
|
+
slash: (p) => loans.slash(p),
|
|
44
|
+
fault: (p) => loans.fault(p),
|
|
45
|
+
liquidate: (p) => loans.liquidate(p),
|
|
46
|
+
seizeDefault: (p) => loans.seizeDefault(p),
|
|
47
|
+
faultLiquidate: (p) => loans.faultLiquidate(p),
|
|
48
|
+
keeperLiquidate: (p) => loans.keeperLiquidate(p),
|
|
38
49
|
health,
|
|
39
50
|
},
|
|
40
51
|
sales: {
|
|
@@ -52,6 +63,11 @@ export function clientOf(essey, chain, health = (loan) => Promise.resolve(status
|
|
|
52
63
|
agentAddress: chain.agentAddress,
|
|
53
64
|
vaultOf: (room) => chain.vaultOf(room),
|
|
54
65
|
},
|
|
66
|
+
keeper: {
|
|
67
|
+
mintBadge: () => keeper.mintBadge(),
|
|
68
|
+
badge: () => keeper.badge(),
|
|
69
|
+
judge: (p) => keeper.judge(p),
|
|
70
|
+
},
|
|
55
71
|
};
|
|
56
72
|
}
|
|
57
73
|
/** The invite stays in the server process. Tool arguments cannot replace it or read it back. */
|
package/dist/config.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type McpConfig = {
|
|
|
14
14
|
graphql: string;
|
|
15
15
|
/** Mode-600 note seed. The server passes it to the SDK and does not keep a copy on the tool context. */
|
|
16
16
|
noteKeyFile: string;
|
|
17
|
-
/** Mode-600 agent key file. Signs
|
|
17
|
+
/** Mode-600 agent key file. Signs the sale item hand-over (`agent.ts`) and a deposit's funding transfer (`fund.ts`); never a tool argument. */
|
|
18
18
|
agentKeyFile: string;
|
|
19
19
|
/** Invite gate token. Unset: credential obtain uses the proof-of-work challenge. Never a tool argument. */
|
|
20
20
|
invite: string | null;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,SAAS,CAAC;IACnB,4EAA4E;IAC5E,MAAM,EAAE;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE,iHAAiH;IACjH,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,wGAAwG;IACxG,WAAW,EAAE,MAAM,CAAC;IACpB
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,SAAS,CAAC;IACnB,4EAA4E;IAC5E,MAAM,EAAE;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE,iHAAiH;IACjH,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,wGAAwG;IACxG,WAAW,EAAE,MAAM,CAAC;IACpB,+IAA+I;IAC/I,YAAY,EAAE,MAAM,CAAC;IACrB,2GAA2G;IAC3G,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,eAAe,2CAA2C,CAAC;AAaxE,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,oBAAoB;CAClC;AAWD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,SAAS,CA0B7D"}
|
package/dist/failure.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type Failure = {
|
|
|
5
5
|
error: string;
|
|
6
6
|
hint: string;
|
|
7
7
|
reason?: string;
|
|
8
|
+
message?: string;
|
|
8
9
|
abort?: {
|
|
9
10
|
module: string;
|
|
10
11
|
code: number;
|
|
@@ -20,8 +21,9 @@ export declare class ToolRefusal extends Error {
|
|
|
20
21
|
constructor(hint: string);
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
|
-
* An SDK message can quote a service reply.
|
|
24
|
-
* Anything else, including a lookalike `{ code }` on a plain Error,
|
|
24
|
+
* An SDK message can quote a service reply. A code from the SDK's own list is returned with a fixed hint, and its
|
|
25
|
+
* message only when it is plain prose (`PROSE`). Anything else, including a lookalike `{ code }` on a plain Error,
|
|
26
|
+
* is withheld.
|
|
25
27
|
*/
|
|
26
28
|
export declare function failureOf(err: unknown, secrets?: readonly string[]): Failure;
|
|
27
29
|
export declare const isSdkCode: (err: unknown) => err is EsseyError;
|
package/dist/failure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,UAAU,EAAgB,MAAM,wBAAwB,CAAC;AAIrF,eAAO,MAAM,QAAQ,6DAA6D,CAAC;AAEnF,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C,CAAC;
|
|
1
|
+
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,UAAU,EAAgB,MAAM,wBAAwB,CAAC;AAIrF,eAAO,MAAM,QAAQ,6DAA6D,CAAC;AAEnF,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C,CAAC;AAuCF;;;GAGG;AACH,qBAAa,WAAY,SAAQ,KAAK;IAExB,QAAQ,CAAC,IAAI,EAAE,MAAM;IADjC,QAAQ,CAAC,IAAI,sBAAsB;gBACd,IAAI,EAAE,MAAM;CAGlC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,SAAS,MAAM,EAAO,GAAG,OAAO,CAOhF;AAED,eAAO,MAAM,SAAS,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,UACkC,CAAC;AAEnF,4FAA4F;AAC5F,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAcpD"}
|
package/dist/failure.js
CHANGED
|
@@ -5,6 +5,17 @@ export const WITHHELD = "The tool failed inside a library; its error is withheld
|
|
|
5
5
|
const SERVICE_CODE = /^(?:v3api|relayer) refused: ([A-Z_]{3,40})$/;
|
|
6
6
|
const CODE = /^[A-Z_]{3,40}$/;
|
|
7
7
|
const MODULE = /^[a-z0-9_]{1,40}::[a-z0-9_]{1,40}$/;
|
|
8
|
+
/** The SDK's own refusal wording: lowercase prose, no long token, so no key, salt, id or digest fits it. */
|
|
9
|
+
const PROSE = /^[a-z0-9 :;,.'()/_-]{3,240}$/;
|
|
10
|
+
const LONG_TOKEN = /[a-z0-9]{25,}|[0-9]{7,}/;
|
|
11
|
+
/** These can quote a service reply; their code reaches the caller as `reason` instead. */
|
|
12
|
+
const SERVICE_WORDED = new Set(["SERVICE_REFUSED", "RELAY_REFUSED", "RELAY_FAILED", "RELAY_OUTCOME_UNKNOWN"]);
|
|
13
|
+
function messageOf(err, secrets) {
|
|
14
|
+
if (SERVICE_WORDED.has(err.code))
|
|
15
|
+
return {};
|
|
16
|
+
const text = redactText(err.message, secrets);
|
|
17
|
+
return PROSE.test(text) && !LONG_TOKEN.test(text) ? { message: text } : {};
|
|
18
|
+
}
|
|
8
19
|
/** The relayer's own code (`ServiceDetail.error`) and Move abort, both a fixed shape a key cannot take. */
|
|
9
20
|
function relayReason(err) {
|
|
10
21
|
const { error, abort } = err.detail ?? {};
|
|
@@ -37,15 +48,16 @@ export class ToolRefusal extends Error {
|
|
|
37
48
|
}
|
|
38
49
|
}
|
|
39
50
|
/**
|
|
40
|
-
* An SDK message can quote a service reply.
|
|
41
|
-
* Anything else, including a lookalike `{ code }` on a plain Error,
|
|
51
|
+
* An SDK message can quote a service reply. A code from the SDK's own list is returned with a fixed hint, and its
|
|
52
|
+
* message only when it is plain prose (`PROSE`). Anything else, including a lookalike `{ code }` on a plain Error,
|
|
53
|
+
* is withheld.
|
|
42
54
|
*/
|
|
43
55
|
export function failureOf(err, secrets = []) {
|
|
44
56
|
if (err instanceof ToolRefusal)
|
|
45
57
|
return { ok: false, error: err.code, hint: redactText(err.hint, secrets) };
|
|
46
58
|
if (isEsseyError(err) && ESSEY_ERROR_CODES.includes(err.code)) {
|
|
47
59
|
const hint = `Look up ${err.code} in the sdk/errors reference.`;
|
|
48
|
-
return { ok: false, error: err.code, hint, ...reasonOf(err) };
|
|
60
|
+
return { ok: false, error: err.code, hint, ...reasonOf(err), ...messageOf(err, secrets) };
|
|
49
61
|
}
|
|
50
62
|
return { ok: false, error: "UNEXPECTED", hint: WITHHELD };
|
|
51
63
|
}
|
package/dist/fund.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
|
|
2
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
3
|
+
import type { CoinKey, EsseyIo } from "@esseyonsui/sui-sdk-v3";
|
|
4
|
+
/** Fixed text: whatever the signing or the chain threw is dropped, so no failure can carry the key file. */
|
|
5
|
+
export declare const FUND_FAILED = "the agent wallet did not fund the deposit";
|
|
6
|
+
/** Executes the signed transaction and resolves once it is final. Tests replace it. */
|
|
7
|
+
export type Send = (tx: Transaction, signer: Ed25519Keypair) => Promise<void>;
|
|
8
|
+
export declare function chainSend(url: string): Send;
|
|
9
|
+
/**
|
|
10
|
+
* The only transaction the agent key signs: `0x2::coin::send_funds` of one deposit piece to its fresh sender, as
|
|
11
|
+
* `scripts/v3/live/io.ts` depositFunder does from the sui CLI payer. The key is read for each piece and not kept.
|
|
12
|
+
*/
|
|
13
|
+
export declare function agentFunder(keyFile: string, coinType: (coin: CoinKey) => string | undefined, send: Send): NonNullable<EsseyIo["fundDeposit"]>;
|
|
14
|
+
export declare function agentDepositIo(raw: unknown, keyFile: string, url: string, send?: Send): {
|
|
15
|
+
fundDeposit: (p: {
|
|
16
|
+
coin: CoinKey;
|
|
17
|
+
value: bigint;
|
|
18
|
+
sender: string;
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=fund.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fund.d.ts","sourceRoot":"","sources":["../src/fund.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAmB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAExE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAI/D,4GAA4G;AAC5G,eAAO,MAAM,WAAW,8CAA8C,CAAC;AAEvE,uFAAuF;AACvF,MAAM,MAAM,IAAI,GAAG,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE9E,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAO3C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,EAC/C,IAAI,EAAE,IAAI,GACT,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAmBrC;AAID,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,IAAqB;;;;;;EAGrG"}
|
package/dist/fund.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SuiGraphQLClient } from "@mysten/sui/graphql";
|
|
2
|
+
import { coinWithBalance, Transaction } from "@mysten/sui/transactions";
|
|
3
|
+
import { loadAgentKey } from "./keys.js";
|
|
4
|
+
/** Fixed text: whatever the signing or the chain threw is dropped, so no failure can carry the key file. */
|
|
5
|
+
export const FUND_FAILED = "the agent wallet did not fund the deposit";
|
|
6
|
+
export function chainSend(url) {
|
|
7
|
+
const client = new SuiGraphQLClient({ url, network: "testnet" });
|
|
8
|
+
return async (transaction, signer) => {
|
|
9
|
+
const r = await client.signAndExecuteTransaction({ transaction, signer });
|
|
10
|
+
if (r.$kind !== "Transaction")
|
|
11
|
+
throw new Error("failed");
|
|
12
|
+
await client.waitForTransaction({ result: r });
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The only transaction the agent key signs: `0x2::coin::send_funds` of one deposit piece to its fresh sender, as
|
|
17
|
+
* `scripts/v3/live/io.ts` depositFunder does from the sui CLI payer. The key is read for each piece and not kept.
|
|
18
|
+
*/
|
|
19
|
+
export function agentFunder(keyFile, coinType, send) {
|
|
20
|
+
return async ({ coin, value, sender }) => {
|
|
21
|
+
try {
|
|
22
|
+
const type = coinType(coin);
|
|
23
|
+
if (!type)
|
|
24
|
+
throw new Error("coin");
|
|
25
|
+
const signer = loadAgentKey(keyFile);
|
|
26
|
+
const tx = new Transaction();
|
|
27
|
+
tx.setSender(signer.toSuiAddress());
|
|
28
|
+
const funds = tx.add(coinWithBalance({ type, balance: value }));
|
|
29
|
+
tx.moveCall({
|
|
30
|
+
target: "0x2::coin::send_funds",
|
|
31
|
+
typeArguments: [type],
|
|
32
|
+
arguments: [funds, tx.pure.address(sender)],
|
|
33
|
+
});
|
|
34
|
+
await send(tx, signer);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
throw new Error(FUND_FAILED);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function agentDepositIo(raw, keyFile, url, send = chainSend(url)) {
|
|
42
|
+
const coins = raw.coins ?? {};
|
|
43
|
+
return { fundDeposit: agentFunder(keyFile, (coin) => coins[coin]?.type, send) };
|
|
44
|
+
}
|
package/dist/io.d.ts
CHANGED
|
@@ -3,9 +3,12 @@ import { v3, type EsseyIo } from "@esseyonsui/sui-sdk-v3";
|
|
|
3
3
|
export { TESTNET_GRAPHQL } from "./config.ts";
|
|
4
4
|
type Json = any;
|
|
5
5
|
type Fetch = (url: string, init?: RequestInit) => Promise<Response>;
|
|
6
|
+
type Gql = (query: string, variables: Record<string, unknown>) => Promise<Json>;
|
|
6
7
|
export type ChainIoOptions = {
|
|
7
8
|
graphql: string;
|
|
8
9
|
fetch?: Fetch;
|
|
10
|
+
/** Pause between index polls after a step lands; tests pass 0. */
|
|
11
|
+
indexPauseMs?: number;
|
|
9
12
|
/** Circuit name to local `{ wasm, zkey }` paths, for a circuit `/v3/config` does not serve yet. */
|
|
10
13
|
localArtifacts?: Record<string, {
|
|
11
14
|
wasm: string;
|
|
@@ -21,6 +24,12 @@ export declare function invertReading(spot: bigint, ema: bigint, spotExpo: bigin
|
|
|
21
24
|
ema: bigint;
|
|
22
25
|
expo: bigint;
|
|
23
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* True once public GraphQL serves every object `digest` changed at its new version or later, so the next step's
|
|
29
|
+
* read sees this one. Stress run 2: loan reads lagged a landed step by about 4 s and repay, release, heartbeat
|
|
30
|
+
* and refi_open were refused against the old state. False after `INDEX_POLLS` polls.
|
|
31
|
+
*/
|
|
32
|
+
export declare function waitIndexed(gql: Gql, digest: string, pauseMs: number): Promise<boolean>;
|
|
24
33
|
type SealPackage = "loan" | "sale";
|
|
25
34
|
type SealArg = {
|
|
26
35
|
pure: "vector<u8>" | "u256" | "u64";
|
|
@@ -39,6 +48,7 @@ type SealRequest = {
|
|
|
39
48
|
signer?: Signer;
|
|
40
49
|
};
|
|
41
50
|
export declare function chainIo(config: Json, o: ChainIoOptions): {
|
|
51
|
+
waitIndexed: (digest: string) => Promise<boolean>;
|
|
42
52
|
prover: v3.Prover;
|
|
43
53
|
readPrice: (market: string) => Promise<{
|
|
44
54
|
spot: bigint;
|
|
@@ -54,7 +64,7 @@ export declare function chainIo(config: Json, o: ChainIoOptions): {
|
|
|
54
64
|
publishS: bigint;
|
|
55
65
|
}>;
|
|
56
66
|
readSeizure: (loanId: string) => Promise<{
|
|
57
|
-
readonly mode: "default" | "
|
|
67
|
+
readonly mode: "default" | "fault" | "liquidate";
|
|
58
68
|
readonly pSpot: bigint;
|
|
59
69
|
}>;
|
|
60
70
|
readSettleTime: (loanId: string) => Promise<bigint>;
|
|
@@ -99,7 +109,7 @@ export declare function chainIo(config: Json, o: ChainIoOptions): {
|
|
|
99
109
|
sealDerivedKeys: (r: SealRequest & {
|
|
100
110
|
id: Uint8Array;
|
|
101
111
|
}) => Promise<Map<string, Uint8Array<ArrayBuffer>>>;
|
|
102
|
-
readLoan: (id: string) => Promise<{
|
|
112
|
+
readLoan: (id: string, round?: bigint) => Promise<{
|
|
103
113
|
json: any;
|
|
104
114
|
round: any;
|
|
105
115
|
}>;
|
package/dist/io.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAMvD,OAAO,EAAE,EAAE,EAAE,KAAK,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAQ9C,KAAK,IAAI,GAAG,GAAG,CAAC;AAChB,KAAK,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAMvD,OAAO,EAAE,EAAE,EAAE,KAAK,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAQ9C,KAAK,IAAI,GAAG,GAAG,CAAC;AAChB,KAAK,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AACpE,KAAK,GAAG,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEhF,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mGAAmG;IACnG,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,mFAAmF;IACnF,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CACtC,CAAC;AAsFF,2IAA2I;AAC3I,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;;;;EAMzF;AA0JD;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAwB7F;AAoHD,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAkCnC,KAAK,OAAO,GAAG;IAAE,IAAI,EAAE,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAC3F,KAAK,WAAW,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC;AAEhF,KAAK,WAAW,GAAG;IAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAAC,GAAG,CAAC,EAAE,WAAW,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAmD7G,wBAAgB,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,cAAc;0BAW7B,MAAM;;wBAER,MAAM;;;;;0BACJ,MAAM;gBAzYR,MAAM;gBACL,MAAM;;;;;;0BAyYL,MAAM;;;;6BACH,MAAM;gCACH,MAAM;2BACX,MAAM;0BACP,MAAM;wBACR,MAAM;;;;6BACD,MAAM;;;;wBACX,MAAM;;;;;mBACX,MAAM;;;wBACK,MAAM,GAAG,IAAI;;;;wBACb,MAAM;+BACL,MAAM;oBACX,MAAM;;;qBACL,MAAM;2CApG5B;QACD,EAAE,EAAE,UAAU,CAAC;QACf,IAAI,EAAE,UAAU,CAAC;QACjB,GAAG,CAAC,EAAE,UAAU,CAAC;QACjB,GAAG,CAAC,EAAE,WAAW,CAAC;KACnB;qBAgDgB,WAAW,GAAG;QAAE,MAAM,EAAE,UAAU,CAAA;KAAE;yBAOpC,WAAW,GAAG;QAAE,EAAE,EAAE,UAAU,CAAA;KAAE;mBA4ChC,MAAM,UAAU,MAAM;;;;wBACjB,MAAM,GAAG,IAAI;;;;;;;;;;0BAGL,MAAM;4BAEJ,MAAM;qBACb,MAAM;;;;;;;;EAkBhC"}
|
package/dist/io.js
CHANGED
|
@@ -218,11 +218,42 @@ async function readSaleOpened(gql, digest) {
|
|
|
218
218
|
throw new Error(`transaction ${digest} created no sale room and vault`);
|
|
219
219
|
return { room, vault };
|
|
220
220
|
}
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
const INDEX_POLLS = 20;
|
|
222
|
+
/**
|
|
223
|
+
* True once public GraphQL serves every object `digest` changed at its new version or later, so the next step's
|
|
224
|
+
* read sees this one. Stress run 2: loan reads lagged a landed step by about 4 s and repay, release, heartbeat
|
|
225
|
+
* and refi_open were refused against the old state. False after `INDEX_POLLS` polls.
|
|
226
|
+
*/
|
|
227
|
+
export async function waitIndexed(gql, digest, pauseMs) {
|
|
228
|
+
const pause = () => new Promise((r) => setTimeout(r, pauseMs));
|
|
229
|
+
let changed = null;
|
|
230
|
+
for (let i = 0; i < INDEX_POLLS; i++, await pause()) {
|
|
231
|
+
if (!changed) {
|
|
232
|
+
const d = await gql(`query($d: String!) { transaction(digest: $d) { effects { objectChanges { nodes { address outputState { version } } } } } }`, { d: digest });
|
|
233
|
+
const nodes = d.transaction?.effects?.objectChanges?.nodes;
|
|
234
|
+
if (!nodes)
|
|
235
|
+
continue;
|
|
236
|
+
changed = nodes
|
|
237
|
+
.filter((n) => n.outputState)
|
|
238
|
+
.map((n) => ({ address: n.address, version: Number(n.outputState.version) }));
|
|
239
|
+
}
|
|
240
|
+
const pending = [];
|
|
241
|
+
for (const c of changed) {
|
|
242
|
+
const d = await gql(`query($a: SuiAddress!) { object(address: $a) { version } }`, { a: c.address });
|
|
243
|
+
if (!(Number(d.object?.version) >= c.version))
|
|
244
|
+
pending.push(c);
|
|
245
|
+
}
|
|
246
|
+
changed = pending;
|
|
247
|
+
if (changed.length === 0)
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
/** The loan and its `Round` `round` (the current one when omitted), a `Table<u64, Round>` entry under `rounds`. */
|
|
253
|
+
async function readLoan(gql, id, round) {
|
|
223
254
|
const json = (await objectOf(gql, id)).asMoveObject.contents.json;
|
|
224
255
|
const key = Buffer.alloc(8);
|
|
225
|
-
key.writeBigUInt64LE(BigInt(json.round));
|
|
256
|
+
key.writeBigUInt64LE(round ?? BigInt(json.round));
|
|
226
257
|
const d = await gql(`query($t: SuiAddress!, $k: Base64!) { address(address: $t) { dynamicField(name: { type: "u64", bcs: $k }) { value { ... on MoveValue { json } } } } }`, { t: json.rounds.id, k: key.toString("base64") });
|
|
227
258
|
return { json, round: d.address?.dynamicField?.value?.json };
|
|
228
259
|
}
|
|
@@ -381,6 +412,7 @@ export function chainIo(config, o) {
|
|
|
381
412
|
return v3.loadCircuitArtifacts(fetch, config.circuits, circuit);
|
|
382
413
|
};
|
|
383
414
|
return {
|
|
415
|
+
waitIndexed: (digest) => waitIndexed(gql, digest, o.indexPauseMs ?? 1500),
|
|
384
416
|
prover: v3.groth16Prover(snarkjs.groth16, artifacts),
|
|
385
417
|
readPrice: (market) => readPrice(gql, market),
|
|
386
418
|
readReading: (market) => readReading(gql, market),
|
|
@@ -401,7 +433,7 @@ export function chainIo(config, o) {
|
|
|
401
433
|
sealEncrypt: sealerFor(config, o.graphql, o.garble ?? (() => false)),
|
|
402
434
|
sealDecrypt: unsealerFor(config, o.graphql),
|
|
403
435
|
sealDerivedKeys: deriverFor(config, o.graphql),
|
|
404
|
-
readLoan: (id) => readLoan(gql, id),
|
|
436
|
+
readLoan: (id, round) => readLoan(gql, id, round),
|
|
405
437
|
readLoans: (cursor) => readLoans(gql, config.packageOrigins.loan, cursor),
|
|
406
438
|
priceUpdate: async () => Uint8Array.of(0),
|
|
407
439
|
fundDeposit: o.fundDeposit,
|
package/dist/main.js
CHANGED
|
@@ -5,6 +5,7 @@ import { ESSEY_ERROR_CODES, Essey, isEsseyError, parseConfig as parseDeployment,
|
|
|
5
5
|
import { graphqlExecute, itemHandOver } from "./agent.js";
|
|
6
6
|
import { clientOf, withInvite } from "./client.js";
|
|
7
7
|
import { ConfigError, parseConfig } from "./config.js";
|
|
8
|
+
import { agentDepositIo } from "./fund.js";
|
|
8
9
|
import { chainIo } from "./io.js";
|
|
9
10
|
import { loadAgentKey, loadNoteSeed } from "./keys.js";
|
|
10
11
|
import { serve } from "./protocol.js";
|
|
@@ -17,11 +18,14 @@ const INSTRUCTIONS = "Essey V3 private testnet tools. Note and agent keys are fi
|
|
|
17
18
|
"strings in the coin's smallest unit. The server builds every proof itself and keeps loan terms, offer, seller " +
|
|
18
19
|
"and bid records in its own files; no tool returns them. Borrow: essey_loan_open, wait for the window, " +
|
|
19
20
|
"essey_loan_settle, essey_loan_repay, essey_loan_release. Lend: essey_loan_list, essey_loan_request, " +
|
|
20
|
-
"essey_loan_offer, then essey_loan_collect after repay or essey_loan_reclaim if the offer lost.
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
21
|
+
"essey_loan_offer, then essey_loan_collect after repay or essey_loan_reclaim if the offer lost. Refinance: " +
|
|
22
|
+
"essey_loan_refi_open, lenders offer, essey_loan_refi_settle; the old lender calls essey_loan_collect. Keeper: " +
|
|
23
|
+
"essey_keeper_judge, then essey_keeper_liquidate or essey_keeper_fault, after which the lender calls " +
|
|
24
|
+
"essey_loan_fault_liquidate. essey_notes_deposit is paid from the agent wallet. Sell: put the item at " +
|
|
25
|
+
"essey_agent_address, essey_sale_open, after close essey_sale_finish (essey_sale_slash each bid it names " +
|
|
26
|
+
"first); or essey_sale_cancel before any bid, or essey_sale_expire after the finish window, then " +
|
|
27
|
+
"essey_sale_claim as seller. Buy: essey_sale_list, essey_sale_bid, and once the room ended essey_sale_claim as " +
|
|
28
|
+
"bidder if won and essey_sale_reclaim (residual if won, else the deposit).";
|
|
25
29
|
/**
|
|
26
30
|
* `source` is what `Essey.connect` takes: the URL, which names the v3api, or the parsed file. The io reads the
|
|
27
31
|
* same record as JSON (Seal set, pools, circuit pins).
|
|
@@ -78,7 +82,7 @@ async function start() {
|
|
|
78
82
|
execute: graphqlExecute(cfg.graphql, agent),
|
|
79
83
|
readObjectRef: io.readObjectRef,
|
|
80
84
|
});
|
|
81
|
-
const essey = await Essey.connect({ network: "testnet", statePath: cfg.stateFile, config: source, seed, relayer: cfg.relayer }, { ...io, deliverSaleItem });
|
|
85
|
+
const essey = await Essey.connect({ network: "testnet", statePath: cfg.stateFile, config: source, seed, relayer: cfg.relayer }, { ...io, ...agentDepositIo(raw, cfg.agentKeyFile, cfg.graphql), deliverSaleItem });
|
|
82
86
|
const sale = { agentAddress: agent.toSuiAddress(), vaultOf: io.readVaultOf };
|
|
83
87
|
const client = withInvite(clientOf(essey, sale), cfg.invite);
|
|
84
88
|
const tools = bind({
|
|
@@ -86,6 +90,7 @@ async function start() {
|
|
|
86
90
|
records: fileRecords(dirname(cfg.stateFile)),
|
|
87
91
|
redact: cfg.invite ? [cfg.invite] : [],
|
|
88
92
|
onError: (line) => process.stderr.write(`essey-v3-mcp: ${line}\n`),
|
|
93
|
+
waitIndexed: io.waitIndexed,
|
|
89
94
|
});
|
|
90
95
|
process.stderr.write("essey-v3-mcp: testnet, note key and agent key files accepted\n");
|
|
91
96
|
await serve(tools, { name: "essey-v3", version: VERSION, instructions: INSTRUCTIONS }, process.stdin, process.stdout);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools-more.d.ts","sourceRoot":"","sources":["../src/tools-more.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,YAAY,CAAC;AAwQpD,eAAO,MAAM,IAAI,EAAE,IAAI,EAA6C,CAAC"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { COINS } from "@esseyonsui/sui-sdk-v3";
|
|
2
|
+
import { LOAN_SCHEMA, OPEN_SCHEMA, int, parseAmount, parseCoin, parseLoanId, parsePayee } from "./args.js";
|
|
3
|
+
import { isSdkCode, ToolRefusal } from "./failure.js";
|
|
4
|
+
/** `move/v3/loan/sources/loan.move:40` MAX_OFFERS = 16. */
|
|
5
|
+
const MAX_SEQ = 15;
|
|
6
|
+
const MAX_MS = Number.MAX_SAFE_INTEGER;
|
|
7
|
+
const REQUEST = OPEN_SCHEMA.properties;
|
|
8
|
+
const LOAN = LOAN_SCHEMA.properties.loan;
|
|
9
|
+
const obj = (properties = {}, required = []) => ({
|
|
10
|
+
type: "object",
|
|
11
|
+
properties,
|
|
12
|
+
required,
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
});
|
|
15
|
+
const KEEPER_SCHEMA = obj({
|
|
16
|
+
loan: LOAN,
|
|
17
|
+
via: {
|
|
18
|
+
type: "string",
|
|
19
|
+
enum: ["pass", "badge"],
|
|
20
|
+
description: "Seal read approved by the keeper credential (pass, default) or by essey_keeper_mint_badge's badge",
|
|
21
|
+
},
|
|
22
|
+
}, ["loan"]);
|
|
23
|
+
function bad(msg) {
|
|
24
|
+
throw new ToolRefusal(msg);
|
|
25
|
+
}
|
|
26
|
+
function landed(row) {
|
|
27
|
+
return { ok: true, digest: row.digest, ticket: row.ticket };
|
|
28
|
+
}
|
|
29
|
+
function keeperArgs(args) {
|
|
30
|
+
const loan = parseLoanId(args);
|
|
31
|
+
if (args.via === undefined)
|
|
32
|
+
return { loan };
|
|
33
|
+
if (args.via !== "pass" && args.via !== "badge")
|
|
34
|
+
bad("via must be pass or badge");
|
|
35
|
+
return { loan, via: args.via };
|
|
36
|
+
}
|
|
37
|
+
function own(ctx, loan) {
|
|
38
|
+
const r = ctx.records.loan(loan);
|
|
39
|
+
if (!r.terms || r.borrowerPk === undefined)
|
|
40
|
+
bad("this loan has not settled from this server: call essey_loan_settle first");
|
|
41
|
+
return { loan, terms: r.terms, borrowerPk: r.borrowerPk, collAmt: r.collAmt };
|
|
42
|
+
}
|
|
43
|
+
function recovered(row) {
|
|
44
|
+
const out = { coin: row.coin, value: row.value, outcome: row.outcome };
|
|
45
|
+
if ("digest" in row)
|
|
46
|
+
out.digest = row.digest;
|
|
47
|
+
if ("atMs" in row && row.atMs !== undefined)
|
|
48
|
+
out.atMs = row.atMs;
|
|
49
|
+
if ("error" in row)
|
|
50
|
+
out.error = isSdkCode(row.error) ? row.error.code : "UNEXPECTED";
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
const REFI = [
|
|
54
|
+
{
|
|
55
|
+
name: "essey_loan_refi_open",
|
|
56
|
+
kind: "call",
|
|
57
|
+
description: "Borrower of an active loan settled from this server: open a refinance round for a new principal that pays the " +
|
|
58
|
+
"current lender what is owed. Lenders offer with essey_loan_request and essey_loan_offer as on a new loan. " +
|
|
59
|
+
"Returns the digest, ticket, round and when offers close.",
|
|
60
|
+
inputSchema: obj({
|
|
61
|
+
loan: LOAN,
|
|
62
|
+
principal: {
|
|
63
|
+
...REQUEST.principal,
|
|
64
|
+
description: "new principal; above what is owed now, which it pays with the fee",
|
|
65
|
+
},
|
|
66
|
+
maxRateBps: REQUEST.maxRateBps,
|
|
67
|
+
termMs: REQUEST.termMs,
|
|
68
|
+
offerWindowMs: REQUEST.offerWindowMs,
|
|
69
|
+
}, ["loan", "principal", "maxRateBps", "termMs", "offerWindowMs"]),
|
|
70
|
+
run: async (ctx, args) => {
|
|
71
|
+
const { loan, borrowerPk, collAmt, terms } = own(ctx, parseLoanId(args));
|
|
72
|
+
const principal = parseAmount(args, "principal");
|
|
73
|
+
if (principal <= terms.owed)
|
|
74
|
+
bad("principal must be above what the loan owes now: it pays the current lender and the fee");
|
|
75
|
+
const r = await ctx.client.loans.openRefi({
|
|
76
|
+
loan,
|
|
77
|
+
borrowerPk,
|
|
78
|
+
collAmt,
|
|
79
|
+
principal,
|
|
80
|
+
maxRateBps: int(args, "maxRateBps", 0, 10_000),
|
|
81
|
+
termMs: int(args, "termMs", 1, MAX_MS),
|
|
82
|
+
offerWindowMs: int(args, "offerWindowMs", 1, MAX_MS),
|
|
83
|
+
});
|
|
84
|
+
return { ...landed(r), round: r.round, closeMs: r.closeMs };
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "essey_loan_refi_settle",
|
|
89
|
+
kind: "call",
|
|
90
|
+
description: "Borrower, after the refinance window: take the lowest eligible offer. The old lender is paid and collects with " +
|
|
91
|
+
"essey_loan_collect; this server keeps the new terms. Returns the digest, ticket, rate, amount owed and maturity.",
|
|
92
|
+
inputSchema: LOAN_SCHEMA,
|
|
93
|
+
run: async (ctx, args) => {
|
|
94
|
+
const settled = own(ctx, parseLoanId(args));
|
|
95
|
+
const r = await ctx.client.loans.settleRefi(settled);
|
|
96
|
+
const { loan, collAmt, borrowerPk } = settled;
|
|
97
|
+
ctx.records.saveLoan(loan, { collAmt, terms: r.terms, borrowerPk });
|
|
98
|
+
return { ...landed(r), rateBps: r.rateBps, owed: r.terms.owed, maturityS: r.terms.maturityS };
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "essey_loan_refi_cancel",
|
|
103
|
+
kind: "call",
|
|
104
|
+
description: "Borrower: close an own open refinance round. The loan stays active on its current terms.",
|
|
105
|
+
inputSchema: LOAN_SCHEMA,
|
|
106
|
+
run: async (ctx, args) => landed(await ctx.client.loans.cancelRefi(parseLoanId(args))),
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
const SEIZE = [
|
|
110
|
+
{
|
|
111
|
+
name: "essey_loan_slash",
|
|
112
|
+
kind: "call",
|
|
113
|
+
description: "Borrower, after the offer window closed: mark offer seq inactive when its sealed offer does not open its " +
|
|
114
|
+
"commit. The chain refuses an honest offer. The slashed lender reclaims its lock once the round resolves.",
|
|
115
|
+
inputSchema: obj({
|
|
116
|
+
loan: LOAN,
|
|
117
|
+
seq: { type: "integer", minimum: 0, maximum: MAX_SEQ, description: "offer slot in the round" },
|
|
118
|
+
}, ["loan", "seq"]),
|
|
119
|
+
run: async (ctx, args) => landed(await ctx.client.loans.slash({ loan: parseLoanId(args), seq: int(args, "seq", 0, MAX_SEQ) })),
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "essey_loan_liquidate",
|
|
123
|
+
kind: "call",
|
|
124
|
+
description: "Borrower of a loan settled from this server: seize it while it is underwater, from this server's own terms. " +
|
|
125
|
+
"The lender takes its share with essey_loan_collect_seized, the borrower the rest with essey_loan_collect_surplus.",
|
|
126
|
+
inputSchema: LOAN_SCHEMA,
|
|
127
|
+
run: async (ctx, args) => landed(await ctx.client.loans.liquidate(own(ctx, parseLoanId(args)))),
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "essey_loan_seize_default",
|
|
131
|
+
kind: "call",
|
|
132
|
+
description: "Borrower of a loan settled from this server: seize it once it is past maturity plus grace, from this server's " +
|
|
133
|
+
"own terms. Then essey_loan_collect_seized (lender) and essey_loan_collect_surplus (borrower).",
|
|
134
|
+
inputSchema: LOAN_SCHEMA,
|
|
135
|
+
run: async (ctx, args) => landed(await ctx.client.loans.seizeDefault(own(ctx, parseLoanId(args)))),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "essey_loan_fault_liquidate",
|
|
139
|
+
kind: "call",
|
|
140
|
+
description: "Lender, from the offer this server made, of a loan a keeper marked FAULT with essey_keeper_fault: seize it. " +
|
|
141
|
+
"Then essey_loan_collect_seized.",
|
|
142
|
+
inputSchema: LOAN_SCHEMA,
|
|
143
|
+
run: async (ctx, args) => {
|
|
144
|
+
const loan = parseLoanId(args);
|
|
145
|
+
return landed(await ctx.client.loans.faultLiquidate({ loan, offer: ctx.records.offer(loan) }));
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
];
|
|
149
|
+
const KEEPER = [
|
|
150
|
+
{
|
|
151
|
+
name: "essey_keeper_mint_badge",
|
|
152
|
+
kind: "call",
|
|
153
|
+
description: "Keeper (essey_credential_obtain with role keeper): mint a keeper badge, sponsored by the relayer, for via " +
|
|
154
|
+
"badge. Returns the digest, badge id, holder address and expiry.",
|
|
155
|
+
inputSchema: obj(),
|
|
156
|
+
run: async (ctx) => {
|
|
157
|
+
const r = await ctx.client.keeper.mintBadge();
|
|
158
|
+
return {
|
|
159
|
+
ok: true,
|
|
160
|
+
digest: r.digest,
|
|
161
|
+
badge: r.badge,
|
|
162
|
+
holder: r.holder,
|
|
163
|
+
expiresMs: r.expiresMs,
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "essey_keeper_badge",
|
|
169
|
+
kind: "read",
|
|
170
|
+
description: "The keeper badge this server holds: badge id, holder address and expiry, or badge null.",
|
|
171
|
+
inputSchema: obj(),
|
|
172
|
+
run: async (ctx) => {
|
|
173
|
+
const held = ctx.client.keeper.badge();
|
|
174
|
+
if (!held)
|
|
175
|
+
return { ok: true, badge: null };
|
|
176
|
+
return { ok: true, badge: held.badge, holder: held.holder, expiresMs: held.expiresMs };
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: "essey_keeper_judge",
|
|
181
|
+
kind: "read",
|
|
182
|
+
description: "Keeper: read an active loan's keeper ciphertext through Seal and say what to do, sending nothing. action " +
|
|
183
|
+
"liquidate (essey_keeper_liquidate), fault (essey_keeper_fault), or skip with reason healthy or third-party-ct.",
|
|
184
|
+
inputSchema: KEEPER_SCHEMA,
|
|
185
|
+
run: async (ctx, args) => {
|
|
186
|
+
const v = await ctx.client.keeper.judge(keeperArgs(args));
|
|
187
|
+
if (v.action === "skip")
|
|
188
|
+
return { ok: true, action: v.action, reason: v.reason };
|
|
189
|
+
return { ok: true, action: v.action };
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "essey_keeper_fault",
|
|
194
|
+
kind: "call",
|
|
195
|
+
description: "Keeper: mark an active loan FAULT when its retained borrower keeper ciphertext does not open its lock. The " +
|
|
196
|
+
"chain refuses an honest ciphertext. The lender then calls essey_loan_fault_liquidate.",
|
|
197
|
+
inputSchema: KEEPER_SCHEMA,
|
|
198
|
+
run: async (ctx, args) => landed(await ctx.client.loans.fault(keeperArgs(args))),
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: "essey_keeper_liquidate",
|
|
202
|
+
kind: "call",
|
|
203
|
+
description: "Keeper: seize an underwater loan from its Seal read of the keeper ciphertext. The keeper fee arrives as an own " +
|
|
204
|
+
"note; the lender and borrower collect with essey_loan_collect_seized and essey_loan_collect_surplus.",
|
|
205
|
+
inputSchema: KEEPER_SCHEMA,
|
|
206
|
+
run: async (ctx, args) => landed(await ctx.client.loans.keeperLiquidate(keeperArgs(args))),
|
|
207
|
+
},
|
|
208
|
+
];
|
|
209
|
+
const NOTES = [
|
|
210
|
+
{
|
|
211
|
+
name: "essey_notes_exit",
|
|
212
|
+
kind: "call",
|
|
213
|
+
description: "Withdraw every note of a coin, at most two, less fees, to a 0x address of 64 hex digits. Returns the digest " +
|
|
214
|
+
"and ticket.",
|
|
215
|
+
inputSchema: obj({
|
|
216
|
+
coin: { type: "string", enum: [...COINS] },
|
|
217
|
+
to: { type: "string", pattern: "^0x[0-9a-fA-F]{64}$", description: "recipient address" },
|
|
218
|
+
}, ["coin", "to"]),
|
|
219
|
+
run: async (ctx, args) => landed(await ctx.client.notes.exit(parseCoin(args), parsePayee(args))),
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: "essey_notes_recover",
|
|
223
|
+
kind: "call",
|
|
224
|
+
description: "Retry every deposit this server started that has not landed. One row per record: coin, value and outcome " +
|
|
225
|
+
"(landed, unconfirmed, already landed, record gone, unfunded, retry_after with atMs, failed with an error code).",
|
|
226
|
+
inputSchema: obj(),
|
|
227
|
+
run: async (ctx) => ({
|
|
228
|
+
ok: true,
|
|
229
|
+
recovered: (await ctx.client.notes.recoverStranded()).map(recovered),
|
|
230
|
+
}),
|
|
231
|
+
},
|
|
232
|
+
];
|
|
233
|
+
export const MORE = [...REFI, ...SEIZE, ...KEEPER, ...NOTES];
|
package/dist/tools.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ export type ToolContext = {
|
|
|
9
9
|
redact: readonly string[];
|
|
10
10
|
/** Tool name and error code only. The callback must not be given the error's message. */
|
|
11
11
|
onError?(line: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* After a call lands: true once a chain read shows its digest's changes (`io.ts` waitIndexed). A failed read
|
|
14
|
+
* counts as false: the step landed, so it is never reported as an error.
|
|
15
|
+
*/
|
|
16
|
+
waitIndexed?(digest: string): Promise<boolean>;
|
|
12
17
|
};
|
|
13
18
|
type Args = Record<string, unknown>;
|
|
14
19
|
type ToolKind = "read" | "call";
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAM5C,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB,gGAAgG;IAChG,OAAO,EAAE,OAAO,CAAC;IACjB,8FAA8F;IAC9F,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,yFAAyF;IACzF,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAChD,CAAC;AAEF,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACpC,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAChC,MAAM,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG;IACzC,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrD,CAAC;AA2ZF,eAAO,MAAM,KAAK,EAAE,IAAI,EASvB,CAAC;AAUF,+GAA+G;AAC/G,wBAAgB,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,GAAE,IAAI,EAAU,GAAG,OAAO,EAAE,CA0BvE"}
|
package/dist/tools.js
CHANGED
|
@@ -3,6 +3,7 @@ import { HEARTBEAT_SCHEMA, LIST_SCHEMA, LOAN_SCHEMA, OFFER_SCHEMA, OPEN_SCHEMA,
|
|
|
3
3
|
import { assertNoSecrets, failureOf, ToolRefusal } from "./failure.js";
|
|
4
4
|
import { redact } from "./redact.js";
|
|
5
5
|
import { BADGE_TOOLS } from "./tools-badge.js";
|
|
6
|
+
import { MORE } from "./tools-more.js";
|
|
6
7
|
import { SALE_TOOLS } from "./tools-sales.js";
|
|
7
8
|
const UNITS = "whole-number string in the coin's smallest unit";
|
|
8
9
|
const BIDDING = v3.LOAN_LIFECYCLE.indexOf("bidding");
|
|
@@ -84,7 +85,7 @@ const NOTES = [
|
|
|
84
85
|
name: "essey_notes_deposit",
|
|
85
86
|
kind: "call",
|
|
86
87
|
description: `Deposit ${UNITS} into shielded notes. denominations splits the amount the way the deployment lists; ` +
|
|
87
|
-
"omit it to let the SDK decide.
|
|
88
|
+
"omit it to let the SDK decide. The agent wallet (ESSEY_AGENT_KEY_FILE) pays it in; essey_notes_recover retries one that stopped.",
|
|
88
89
|
inputSchema: obj({
|
|
89
90
|
coin: { type: "string", enum: [...COINS] },
|
|
90
91
|
amount: { type: "string", pattern: "^[1-9][0-9]*$", description: UNITS },
|
|
@@ -378,6 +379,7 @@ export const TOOLS = [
|
|
|
378
379
|
...VIEWS,
|
|
379
380
|
...SALE_TOOLS,
|
|
380
381
|
...BADGE_TOOLS,
|
|
382
|
+
...MORE,
|
|
381
383
|
];
|
|
382
384
|
function assertKnownArgs(tool, args) {
|
|
383
385
|
const schema = tool.inputSchema;
|
|
@@ -401,7 +403,13 @@ export function bind(ctx, tools = TOOLS) {
|
|
|
401
403
|
const fields = redact(await tool.run(ctx, args ?? {}), ctx.redact);
|
|
402
404
|
if (fields === null || typeof fields !== "object" || Array.isArray(fields))
|
|
403
405
|
throw new Error("result");
|
|
404
|
-
|
|
406
|
+
const digest = fields.digest;
|
|
407
|
+
const lagging = tool.kind === "call" &&
|
|
408
|
+
typeof digest === "string" &&
|
|
409
|
+
ctx.waitIndexed &&
|
|
410
|
+
!(await ctx.waitIndexed(digest).catch(() => false));
|
|
411
|
+
const out = lagging ? { ...fields, indexed: false } : fields;
|
|
412
|
+
return { text: JSON.stringify({ ...out, ok: true }, null, 2), isError: false };
|
|
405
413
|
}
|
|
406
414
|
catch (err) {
|
|
407
415
|
const reply = failureOf(err, ctx.redact);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esseyonsui/sui-mcp-v3",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@esseyonsui/sui-sdk-v3": "0.1.
|
|
32
|
+
"@esseyonsui/sui-sdk-v3": "0.1.4",
|
|
33
33
|
"@mysten/seal": "1.5.1",
|
|
34
34
|
"@mysten/sui": "2.37.0",
|
|
35
35
|
"snarkjs": "0.7.6"
|