@integraledger/profile-facilitator 0.3.1 → 0.5.0
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 +642 -456
- package/dist/answers.d.ts +11 -4
- package/dist/answers.js +24 -0
- package/dist/core.d.ts +51 -0
- package/dist/core.js +758 -0
- package/dist/http.d.ts +20 -3
- package/dist/http.js +32 -7
- package/dist/index.d.ts +12 -36
- package/dist/index.js +9 -162
- package/dist/module.d.ts +372 -0
- package/dist/module.js +13 -0
- package/dist/modules/algorand/index.d.ts +22 -0
- package/dist/modules/algorand/index.js +247 -0
- package/dist/modules/algorand/own.d.ts +26 -0
- package/dist/modules/algorand/own.js +231 -0
- package/dist/modules/aptos/index.d.ts +23 -0
- package/dist/modules/aptos/index.js +232 -0
- package/dist/modules/cardano/index.d.ts +18 -0
- package/dist/modules/cardano/index.js +124 -0
- package/dist/modules/casper/index.d.ts +120 -0
- package/dist/modules/casper/index.js +442 -0
- package/dist/modules/concordium/index.d.ts +16 -0
- package/dist/modules/concordium/index.js +77 -0
- package/dist/modules/erc7710/index.d.ts +26 -0
- package/dist/modules/erc7710/index.js +220 -0
- package/dist/modules/evm/forms.d.ts +74 -0
- package/dist/modules/evm/forms.js +182 -0
- package/dist/modules/evm/index.d.ts +40 -0
- package/dist/modules/evm/index.js +148 -0
- package/dist/modules/evm/node.d.ts +29 -0
- package/dist/modules/evm/node.js +222 -0
- package/dist/modules/hedera/executor.d.ts +63 -0
- package/dist/modules/hedera/executor.js +343 -0
- package/dist/modules/hedera/index.d.ts +23 -0
- package/dist/modules/hedera/index.js +136 -0
- package/dist/modules/hedera/mirror.d.ts +32 -0
- package/dist/modules/hedera/mirror.js +111 -0
- package/dist/modules/index.d.ts +23 -0
- package/dist/modules/index.js +24 -0
- package/dist/modules/lnbtc/index.d.ts +10 -0
- package/dist/modules/lnbtc/index.js +111 -0
- package/dist/modules/near/index.d.ts +18 -0
- package/dist/modules/near/index.js +246 -0
- package/dist/modules/polkadot/index.d.ts +12 -0
- package/dist/modules/polkadot/index.js +149 -0
- package/dist/modules/polkadot/rail.d.ts +40 -0
- package/dist/{polkadot.js → modules/polkadot/rail.js} +214 -288
- package/dist/modules/solana/index.d.ts +60 -0
- package/dist/modules/solana/index.js +304 -0
- package/dist/modules/solana/reader.d.ts +25 -0
- package/dist/modules/solana/reader.js +194 -0
- package/dist/modules/solana/state.d.ts +6 -0
- package/dist/modules/solana/state.js +103 -0
- package/dist/modules/starknet/index.d.ts +35 -0
- package/dist/modules/starknet/index.js +541 -0
- package/dist/modules/starknet/node.d.ts +78 -0
- package/dist/modules/starknet/node.js +339 -0
- package/dist/modules/stellar/index.d.ts +44 -0
- package/dist/modules/stellar/index.js +481 -0
- package/dist/modules/stellar/node.d.ts +57 -0
- package/dist/modules/stellar/node.js +151 -0
- package/dist/modules/sui/index.d.ts +16 -0
- package/dist/modules/sui/index.js +309 -0
- package/dist/modules/sui/node.d.ts +49 -0
- package/dist/modules/sui/node.js +197 -0
- package/dist/modules/ton/index.d.ts +16 -0
- package/dist/modules/ton/index.js +73 -0
- package/dist/modules/tron/index.d.ts +12 -0
- package/dist/modules/tron/index.js +120 -0
- package/dist/modules/tron/rail.d.ts +32 -0
- package/dist/{tron.js → modules/tron/rail.js} +206 -195
- package/dist/modules/xrpl/index.d.ts +28 -0
- package/dist/modules/xrpl/index.js +299 -0
- package/dist/modules/xrpl/node.d.ts +52 -0
- package/dist/modules/xrpl/node.js +231 -0
- package/dist/modules/xrpl/upto.d.ts +5 -0
- package/dist/modules/xrpl/upto.js +269 -0
- package/dist/record.d.ts +131 -0
- package/dist/record.js +330 -0
- package/dist/unexpected.d.ts +3 -2
- package/dist/unexpected.js +2 -1
- package/dist/wrapper.d.ts +68 -0
- package/dist/wrapper.js +126 -0
- package/package.json +47 -12
- package/dist/polkadot.d.ts +0 -21
- package/dist/store.d.ts +0 -59
- package/dist/store.js +0 -103
- package/dist/tron.d.ts +0 -12
- /package/dist/{base58check.d.ts → modules/tron/base58check.d.ts} +0 -0
- /package/dist/{base58check.js → modules/tron/base58check.js} +0 -0
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a module gives the settler's core, for one scheme on one network. A module is an x402 facilitator for that
|
|
3
|
+
* scheme and network (`SchemeNetworkFacilitator` of `@x402/core`), either a class x402 publishes or the settler's own,
|
|
4
|
+
* with three things alongside it: a descriptor, which the kind's `extra` in `/supported` states; what the record needs to
|
|
5
|
+
* key a payment, keep its row and tell a final answer from a live one; and what a fee budget needs to count the fees
|
|
6
|
+
* the module's key pays.
|
|
7
|
+
*
|
|
8
|
+
* x402's facilitator class dispatches a payment to the first registration whose scheme matches and whose networks hold
|
|
9
|
+
* the payment's network, and gives a registration of several networks of one namespace the pattern `<namespace>:*`, so
|
|
10
|
+
* a registration names exactly one network, and an own module that settles a payer variant a published class refuses is
|
|
11
|
+
* reached through that class's registration, by a claim, never by a second registration.
|
|
12
|
+
*/
|
|
13
|
+
import type { PairingData, PairingId, StatusAnswer } from "@integraledger/lcp";
|
|
14
|
+
import type { PendingSettlementStore } from "@x402/core/facilitator";
|
|
15
|
+
import type { FacilitatorContext, Network, PaymentPayload, PaymentRequirements, SchemeNetworkFacilitator } from "@x402/core/types";
|
|
16
|
+
import type { OperatorLog } from "./answers.js";
|
|
17
|
+
/** The settler's modules, one per chain form, each loaded only where its network is configured. */
|
|
18
|
+
export type ModuleName = "algorand" | "aptos" | "cardano" | "casper" | "concordium" | "erc7710" | "evm" | "hedera" | "lnbtc" | "near" | "polkadot" | "solana" | "starknet" | "stellar" | "sui" | "ton" | "tron" | "xrpl";
|
|
19
|
+
/**
|
|
20
|
+
* `extra.key`: what the module's key signs, where the module is configured with one. `none`: the module holds no key
|
|
21
|
+
* and signs nothing. `relayer`: the key sends the transaction and pays its network fee. `fee-payer`: the key co-signs
|
|
22
|
+
* the payer's transaction as the account that pays its fee. A chain's own name for the role stays in that module's
|
|
23
|
+
* documentation. The key is always the seller's, reaching the module as the signer object its class takes, in the
|
|
24
|
+
* configuration the operator's code passes to the settler's start function.
|
|
25
|
+
*/
|
|
26
|
+
export type KeyPurpose = "none" | "relayer" | "fee-payer";
|
|
27
|
+
/**
|
|
28
|
+
* What the kind states in `/supported`, with the members its x402 facilitator's `getExtra` returns, which are kept
|
|
29
|
+
* unchanged. The fee budget's `extra.feeBudget` is the core's, stated from the operator's configuration.
|
|
30
|
+
*/
|
|
31
|
+
export interface Descriptor {
|
|
32
|
+
readonly name: ModuleName;
|
|
33
|
+
/** `extra.key`. */
|
|
34
|
+
readonly key: KeyPurpose;
|
|
35
|
+
/**
|
|
36
|
+
* `extra.pairings`: the lcp pairing ids the module submits on this scheme and network. A scheme on one network can
|
|
37
|
+
* hold several forms, so the scheme alone does not name them.
|
|
38
|
+
*/
|
|
39
|
+
readonly pairings: readonly PairingId[];
|
|
40
|
+
/**
|
|
41
|
+
* `extra.acceptsZero`: whether the module settles a payment of amount zero, as a seller choosing a zero agreement
|
|
42
|
+
* needs to know. True only where every pairing in `pairings` takes zero.
|
|
43
|
+
*/
|
|
44
|
+
readonly acceptsZero: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Set where the module's `/verify` judges a payment that has already landed, by what the chain shows of it, and does
|
|
47
|
+
* not refuse it for having landed: the core then asks neither its record nor the chain whether the instrument is
|
|
48
|
+
* held before that `/verify`. Every other module's `/verify` refuses an instrument the record or the chain already
|
|
49
|
+
* holds, since `isValid: true` tells the caller that a settle may follow.
|
|
50
|
+
*/
|
|
51
|
+
readonly verifiesLanded?: true;
|
|
52
|
+
/**
|
|
53
|
+
* Set where the module's scheme forbids `/verify`, as x402's `exact` scheme on Lightning does: the core answers
|
|
54
|
+
* `/verify` `unsupported_scheme` before anything else, and `/settle` still runs the module's own checks before it
|
|
55
|
+
* submits.
|
|
56
|
+
*/
|
|
57
|
+
readonly verifyForbidden?: true;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The call a facilitator's `verify` is made for: `verify`, the caller's `/verify`; `settle`, the check `/settle` makes
|
|
61
|
+
* before it submits. A scheme can check the two otherwise: x402's `upto` on XRPL refuses at `/verify` a payload carrying
|
|
62
|
+
* the settlement transaction the resource server adds at `/settle` alone, and at `/settle` checks that transaction,
|
|
63
|
+
* against the maximum the payment authorises rather than the charge.
|
|
64
|
+
*/
|
|
65
|
+
export type Phase = "verify" | "settle";
|
|
66
|
+
/** The key of the extension of x402's `FacilitatorContext` by which the core names the phase of a `verify`. */
|
|
67
|
+
export declare const PHASE = "settler-phase";
|
|
68
|
+
/** The phase a facilitator's `verify` is called in, from the context the core gives it: `verify` where it names none. */
|
|
69
|
+
export declare function phaseOf(context?: FacilitatorContext): Phase;
|
|
70
|
+
/** One payment, as the x402 calls carry it: the payload as presented, and the requirements of the option it answers. */
|
|
71
|
+
export interface X402Payment {
|
|
72
|
+
readonly payload: PaymentPayload;
|
|
73
|
+
readonly requirements: PaymentRequirements;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The instrument a payment is: the record's key, one row for it whichever call claimed it. Never the single-use value
|
|
77
|
+
* alone, which two payers can share, and never a hash that a re-signed copy of the same payment changes.
|
|
78
|
+
*/
|
|
79
|
+
export type Instrument = {
|
|
80
|
+
/** Named by the single-use value its signer signed. */
|
|
81
|
+
readonly by: "single-use";
|
|
82
|
+
readonly network: Network;
|
|
83
|
+
/** The account that signed the single-use value, in the chain's own spelling. */
|
|
84
|
+
readonly signer: string;
|
|
85
|
+
/**
|
|
86
|
+
* The single-use value as signed: an authorization nonce, a sequence number, an account nonce. For an agreement on
|
|
87
|
+
* a pairing whose single-use value is H or H's low bits, the agreement's own value, so that an agreement and a
|
|
88
|
+
* payment of one payer under one H are two instruments.
|
|
89
|
+
*/
|
|
90
|
+
readonly value: string;
|
|
91
|
+
/** The token contract, or the nonce key, within which the value is counted, where the form has one. */
|
|
92
|
+
readonly scope?: string;
|
|
93
|
+
/**
|
|
94
|
+
* The digest of the signed bytes as presented, where the form names the instrument by them, so that a second body
|
|
95
|
+
* under a used value is another instrument.
|
|
96
|
+
*/
|
|
97
|
+
readonly signed?: string;
|
|
98
|
+
} | {
|
|
99
|
+
/** Named by the transaction id, where the chain derives it from the signed content alone, signatures excluded. */
|
|
100
|
+
readonly by: "transaction";
|
|
101
|
+
readonly network: Network;
|
|
102
|
+
readonly transaction: string;
|
|
103
|
+
} | {
|
|
104
|
+
/**
|
|
105
|
+
* Named by the digest of the signed payment, where the form's `nonce` is not `single-use` (a batch settlement, an
|
|
106
|
+
* `upto` claim): each signed settle is its own instrument.
|
|
107
|
+
*/
|
|
108
|
+
readonly by: "digest";
|
|
109
|
+
readonly network: Network;
|
|
110
|
+
readonly digest: string;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* How long the record keeps a final row: at least until the form's lapse or life has passed, and for the settler's life
|
|
114
|
+
* where the form has neither or its `nonce` is not `single-use`.
|
|
115
|
+
*/
|
|
116
|
+
export type Keep = {
|
|
117
|
+
/** Until the time the signed payment itself names, after which it can no longer land: Unix milliseconds. */
|
|
118
|
+
readonly until: "lapse";
|
|
119
|
+
readonly at: number;
|
|
120
|
+
} | {
|
|
121
|
+
/** For the longest the rail lets a signed payment stay payable, counted from the claim: milliseconds. */
|
|
122
|
+
readonly until: "life";
|
|
123
|
+
readonly ms: number;
|
|
124
|
+
} | {
|
|
125
|
+
readonly until: "settler";
|
|
126
|
+
};
|
|
127
|
+
/** What the record keeps for a payment, read from the payment and its requirements alone. */
|
|
128
|
+
export interface Instrumented {
|
|
129
|
+
/** The lcp pairing the payment is. */
|
|
130
|
+
readonly pairing: PairingId;
|
|
131
|
+
readonly instrument: Instrument;
|
|
132
|
+
/**
|
|
133
|
+
* The pairing's `nonce`, as lcp's registry states it: only under `single-use` may a held claim send the identical
|
|
134
|
+
* signed payment again, and only where the read shows the value unconsumed and its validity open.
|
|
135
|
+
*/
|
|
136
|
+
readonly nonce: PairingData["nonce"];
|
|
137
|
+
readonly keep: Keep;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A payment the form's pure checks refuse, with x402's reason; nothing is read and nothing is recorded. `message` is
|
|
141
|
+
* lcp's refusal code where lcp gave one, which the answer carries as x402's `invalidMessage` or `errorMessage`.
|
|
142
|
+
*/
|
|
143
|
+
export interface Refused {
|
|
144
|
+
readonly refused: string;
|
|
145
|
+
readonly message?: string;
|
|
146
|
+
}
|
|
147
|
+
/** An answer of lcp's read, as `status` answers it, its ledger position, marks and search position the pairing's own. */
|
|
148
|
+
export type ReadAnswer = StatusAnswer<unknown, unknown, unknown>;
|
|
149
|
+
/**
|
|
150
|
+
* The answers after which the instrument can never land again: `settled`, a success; `failed`, with a failed result
|
|
151
|
+
* that consumed the single-use value (`transaction-failed`), a value another act consumed (`instrument-consumed`), a
|
|
152
|
+
* validity that passed with the value unconsumed (`instrument-unused`), or an act at or before the position the read
|
|
153
|
+
* was given (`before-position`), which consumed the value before anything the settler sent could land.
|
|
154
|
+
*/
|
|
155
|
+
export type FinalAnswer = Extract<ReadAnswer, {
|
|
156
|
+
readonly state: "settled" | "failed";
|
|
157
|
+
}>;
|
|
158
|
+
/**
|
|
159
|
+
* Every other answer: the instrument may still land (`instrument-live`, `below-mark`), or the read could not tell
|
|
160
|
+
* (`search-incomplete`, `not-found`, `unreadable`). A row whose read is live is not final, and a repeat reads again.
|
|
161
|
+
*/
|
|
162
|
+
export type LiveAnswer = Extract<ReadAnswer, {
|
|
163
|
+
readonly state: "pending" | "unreadable";
|
|
164
|
+
}>;
|
|
165
|
+
/** What the chain shows of an instrument, by lcp's read: final or live, with lcp's answer, which names the transaction. */
|
|
166
|
+
export type ChainRead = {
|
|
167
|
+
readonly outcome: "final";
|
|
168
|
+
readonly answer: FinalAnswer;
|
|
169
|
+
} | {
|
|
170
|
+
readonly outcome: "live";
|
|
171
|
+
readonly answer: LiveAnswer;
|
|
172
|
+
};
|
|
173
|
+
/** Whether lcp's answer is final for the instrument or leaves it live. */
|
|
174
|
+
export declare function outcomeOf(answer: ReadAnswer): ChainRead;
|
|
175
|
+
/** What the record needs of a module, for every payment it claims. */
|
|
176
|
+
export interface RecordNeeds<P = X402Payment> {
|
|
177
|
+
/**
|
|
178
|
+
* The form's pure checks, which read neither the chain nor the clock, and the payment's instrument; or the refusal.
|
|
179
|
+
* The record is read after this and before any check that reads the chain or the clock, a published class's among
|
|
180
|
+
* them.
|
|
181
|
+
*/
|
|
182
|
+
instrument(payment: P): Promise<Instrumented | Refused>;
|
|
183
|
+
/**
|
|
184
|
+
* lcp's read of the payment's instrument, by the pairing's search, at the pairing's final mark: what `/settle` answers
|
|
185
|
+
* where a check or the node shows the single-use value used, and what a claim the record already holds reads before
|
|
186
|
+
* anything is sent again. Called only for a payment `instrument` accepted. Its node calls end by `deadline`, a
|
|
187
|
+
* `performance.now()` time. `search` is the search position an earlier live answer returned, which the read resumes
|
|
188
|
+
* from. `from` is what `position` answered at the payment's claim, where the module gives `position` and the record
|
|
189
|
+
* holds a claim; a read without it searches as the pairing does with no position given. `transaction` is the
|
|
190
|
+
* transaction the record holds for the claim, the one the module's `settle` named (or the instrument's own id), where
|
|
191
|
+
* it holds one, for a pairing whose read reads a transaction its caller names.
|
|
192
|
+
*/
|
|
193
|
+
read(payment: P, at: {
|
|
194
|
+
readonly deadline: number;
|
|
195
|
+
readonly search?: unknown;
|
|
196
|
+
readonly from?: unknown;
|
|
197
|
+
readonly transaction?: string;
|
|
198
|
+
}): Promise<ChainRead>;
|
|
199
|
+
/**
|
|
200
|
+
* Where a pairing's read searches from a position at issue that no x402 call carries (a ledger, a slot, a round): the
|
|
201
|
+
* chain's position for the payment, read from the module's node just before the settler claims it, so that nothing
|
|
202
|
+
* the settler submits can land before it. The core calls it once per claim, keeps what it answers in the row, and
|
|
203
|
+
* gives it back to every later `read` of the payment as `from`. Its node calls end by `deadline`. A failure leaves the
|
|
204
|
+
* row without one.
|
|
205
|
+
*/
|
|
206
|
+
position?(payment: P, at: {
|
|
207
|
+
readonly deadline: number;
|
|
208
|
+
}): Promise<unknown>;
|
|
209
|
+
}
|
|
210
|
+
/** What a fee budget needs of a module, for every payment it claims. */
|
|
211
|
+
export interface FeeNeeds<P = X402Payment> {
|
|
212
|
+
/** Whether the module's key pays the network fee of what it would submit for the payment. */
|
|
213
|
+
paysFee(payment: P): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Whether the payer broadcast the payment itself, so that the module reads it and sends nothing: such a payment is
|
|
216
|
+
* never refused for a spent budget.
|
|
217
|
+
*/
|
|
218
|
+
payerBroadcast(payment: P): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* For a facilitator that sends inside its own `settle` and never calls `FeeMeter.sending`, as a published class does:
|
|
221
|
+
* given the payment and the transaction the facilitator's `settle` named, the fee the chain shows the transaction
|
|
222
|
+
* paid once it is included, or until then the most it can pay as its own fields bound it, in the smallest unit of the
|
|
223
|
+
* network's fee asset. It may read the node; its calls end by `deadline`, a `performance.now()` time its own and
|
|
224
|
+
* not the request's. The core asks it after each such `settle` whose payment `paysFee`, once the answer is stored,
|
|
225
|
+
* and again once the record makes the payment final, and counts what it answers. Before such a `settle` the core
|
|
226
|
+
* refuses the payment `fee_budget_spent` where the network's budget is spent. The core counts only the transactions
|
|
227
|
+
* a `settle` names: one its facilitator sends without naming it (a published class's deployment of the payer's
|
|
228
|
+
* wallet; a send whose wait for its receipt threw) the module counts through its `FeeMeter`, or names. An own module
|
|
229
|
+
* that calls `FeeMeter` leaves it out. A network's fee budget is refused at the settler's start where a module with a
|
|
230
|
+
* key on it neither gives this nor takes its network's meter at its start.
|
|
231
|
+
*/
|
|
232
|
+
charged?(payment: P, sent: {
|
|
233
|
+
readonly transaction: string;
|
|
234
|
+
readonly deadline: number;
|
|
235
|
+
}): Promise<Charged>;
|
|
236
|
+
}
|
|
237
|
+
/** A transaction's fee as `FeeNeeds.charged` answers it. */
|
|
238
|
+
export interface Charged {
|
|
239
|
+
/** In the smallest unit of the network's fee asset. */
|
|
240
|
+
readonly fee: bigint;
|
|
241
|
+
/** True where the chain shows the transaction included and `fee` is what it paid; false where `fee` is its bound. */
|
|
242
|
+
readonly included: boolean;
|
|
243
|
+
}
|
|
244
|
+
/** One transaction a module is about to send whose fee its key pays. */
|
|
245
|
+
export interface Sending {
|
|
246
|
+
readonly network: Network;
|
|
247
|
+
/** Its id, where it is known before it is sent. */
|
|
248
|
+
readonly transaction?: string;
|
|
249
|
+
/** The most it can pay, as its own fields bound it, in the smallest unit of the network's fee asset. */
|
|
250
|
+
readonly bound: bigint;
|
|
251
|
+
}
|
|
252
|
+
/** One transaction the module sent, once the chain shows it included. */
|
|
253
|
+
export interface Included {
|
|
254
|
+
readonly network: Network;
|
|
255
|
+
readonly transaction: string;
|
|
256
|
+
/** The fee the chain shows it paid, in the smallest unit of the network's fee asset. */
|
|
257
|
+
readonly fee: bigint;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* The core's count of the fees a module's key pays on a network, which a module whose key pays fees is given at its
|
|
261
|
+
* start. The module calls `sending` just before it sends such a transaction, the first or the identical payment again,
|
|
262
|
+
* and sends nothing where it resolves false, the network's budget being spent; and calls `included` once the chain shows
|
|
263
|
+
* the transaction included. Until then the count holds the transaction's bound.
|
|
264
|
+
*/
|
|
265
|
+
export interface FeeMeter {
|
|
266
|
+
sending(sending: Sending): Promise<boolean>;
|
|
267
|
+
included(included: Included): void;
|
|
268
|
+
/**
|
|
269
|
+
* Counts a transaction the module's key sent without `sending` before it: one a published class sends inside its own
|
|
270
|
+
* `settle` and does not name in its answer, as x402's EVM classes deploy a payer's ERC-6492 wallet before its payment.
|
|
271
|
+
* `shown` reads what the chain shows of its fee, as `FeeNeeds.charged` answers it, or undefined where the node holds
|
|
272
|
+
* no such transaction; the meter calls it only where the network has a budget, and counts what it answers whatever
|
|
273
|
+
* the budget's state, the transaction being sent. Called again once the chain may show more, it counts again, a paid
|
|
274
|
+
* fee never replaced by a bound.
|
|
275
|
+
*/
|
|
276
|
+
sent(transaction: string, shown: () => Promise<Charged | undefined>): void;
|
|
277
|
+
}
|
|
278
|
+
/** A module: an x402 facilitator for one scheme on one network, and what the core needs with it. */
|
|
279
|
+
export interface Module<P = X402Payment> {
|
|
280
|
+
readonly descriptor: Descriptor;
|
|
281
|
+
/** The network, exactly one. */
|
|
282
|
+
readonly network: Network;
|
|
283
|
+
/**
|
|
284
|
+
* The facilitator, whose `verify` and `settle` run unchanged: a published class, or the module's own. Its `getExtra`
|
|
285
|
+
* gives the kind's own members, and its `getSigners` the address of a key that pays or co-signs a fee.
|
|
286
|
+
*/
|
|
287
|
+
readonly facilitator: SchemeNetworkFacilitator;
|
|
288
|
+
readonly record: RecordNeeds<P>;
|
|
289
|
+
readonly fees: FeeNeeds<P>;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* How an own module claims a payment on the scheme and network of a published class: by a member of the option, where
|
|
293
|
+
* the form is in the option; or by what the payment itself holds, where a payer variant shares its option with the
|
|
294
|
+
* published form. A claim reads neither the chain nor the clock.
|
|
295
|
+
*/
|
|
296
|
+
export type Claim = {
|
|
297
|
+
readonly by: "option";
|
|
298
|
+
claims(requirements: PaymentRequirements): boolean;
|
|
299
|
+
} | {
|
|
300
|
+
readonly by: "payment";
|
|
301
|
+
claims(payload: PaymentPayload, requirements: PaymentRequirements): boolean;
|
|
302
|
+
};
|
|
303
|
+
/** An own module that the wrapper hands the payments it claims, before the published class sees them. */
|
|
304
|
+
export interface Handoff {
|
|
305
|
+
readonly claim: Claim;
|
|
306
|
+
readonly module: Module;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* One registration with x402's facilitator class: one scheme, the facilitator's, on one network. `own` lists the own
|
|
310
|
+
* modules on the same scheme and network, tried in order; a payment none of them claims goes to `module`.
|
|
311
|
+
*/
|
|
312
|
+
export interface Registration {
|
|
313
|
+
readonly network: Network;
|
|
314
|
+
readonly module: Module;
|
|
315
|
+
readonly own: readonly Handoff[];
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Durable state a module keeps in the settler's database, under its own name: a pending settlement, an `upto`
|
|
319
|
+
* channel, a scan position. Each value is JSON, a `bigint` within it kept as one. Every call is bounded as the
|
|
320
|
+
* record's are, and a call that fails rejects.
|
|
321
|
+
*/
|
|
322
|
+
export interface ModuleState {
|
|
323
|
+
get(key: string): Promise<unknown>;
|
|
324
|
+
set(key: string, value: unknown): Promise<void>;
|
|
325
|
+
/**
|
|
326
|
+
* Writes `value` only where the stored value equals `expected` as JSON, `undefined` being no value stored; true where
|
|
327
|
+
* this call wrote it. Two callers that swap from one value never both write.
|
|
328
|
+
*/
|
|
329
|
+
swap(key: string, expected: unknown, value: unknown): Promise<boolean>;
|
|
330
|
+
delete(key: string): Promise<void>;
|
|
331
|
+
/** x402's `PendingSettlementStore` over this state, for a published class that takes one. */
|
|
332
|
+
pendingSettlements(): PendingSettlementStore;
|
|
333
|
+
}
|
|
334
|
+
/** What the core gives a module at its start. */
|
|
335
|
+
export interface Core {
|
|
336
|
+
/** The operator log: what an answer does not carry, one entry per event. */
|
|
337
|
+
readonly log: OperatorLog;
|
|
338
|
+
/** How long a `/settle` waits for the chain before it answers, in milliseconds. */
|
|
339
|
+
readonly settleWaitMs: number;
|
|
340
|
+
/** The module's durable state. */
|
|
341
|
+
readonly state: ModuleState;
|
|
342
|
+
/**
|
|
343
|
+
* The fee meter of `network`, for an own module whose key pays fees there, taken at the module's start: the core
|
|
344
|
+
* refuses a fee budget on a network where a module with a key neither took it nor gives `FeeNeeds.charged`.
|
|
345
|
+
*/
|
|
346
|
+
meter(network: Network): FeeMeter;
|
|
347
|
+
}
|
|
348
|
+
/** An own module offered to the registration another module makes of a scheme on a network. */
|
|
349
|
+
export interface OfferedHandoff {
|
|
350
|
+
readonly scheme: string;
|
|
351
|
+
readonly network: Network;
|
|
352
|
+
readonly handoff: Handoff;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* A module once started: its registrations, one per scheme and network; the own modules it offers to registrations
|
|
356
|
+
* other modules make, which the core puts behind each such registration's own modules, in the order of the modules'
|
|
357
|
+
* list, and refuses at start where no module registers that scheme and network; and what closes what it opened.
|
|
358
|
+
*/
|
|
359
|
+
export interface Started {
|
|
360
|
+
readonly registrations: readonly Registration[];
|
|
361
|
+
readonly handoffs?: readonly OfferedHandoff[];
|
|
362
|
+
close?(): Promise<void>;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* How the core starts a module from configuration alone: the configuration's member named for the module is `C`, and
|
|
366
|
+
* the module's keys reach it inside `C` as the signer objects its classes take. A module whose configuration names no
|
|
367
|
+
* network is not started.
|
|
368
|
+
*/
|
|
369
|
+
export interface ModuleStarter<C> {
|
|
370
|
+
readonly name: ModuleName;
|
|
371
|
+
start(config: C, core: Core): Promise<Started>;
|
|
372
|
+
}
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The key of the extension of x402's `FacilitatorContext` by which the core names the phase of a `verify`. */
|
|
2
|
+
export const PHASE = "settler-phase";
|
|
3
|
+
/** The phase a facilitator's `verify` is called in, from the context the core gives it: `verify` where it names none. */
|
|
4
|
+
export function phaseOf(context) {
|
|
5
|
+
const named = context?.getExtension(PHASE);
|
|
6
|
+
return named?.phase === "settle" ? "settle" : "verify";
|
|
7
|
+
}
|
|
8
|
+
/** Whether lcp's answer is final for the instrument or leaves it live. */
|
|
9
|
+
export function outcomeOf(answer) {
|
|
10
|
+
return answer.state === "settled" || answer.state === "failed"
|
|
11
|
+
? { outcome: "final", answer }
|
|
12
|
+
: { outcome: "live", answer };
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type AlgorandNetwork, type AvmReader } from "@integraledger/lcp/avm";
|
|
2
|
+
import type { FacilitatorAvmSigner } from "@x402/avm";
|
|
3
|
+
import { type ModuleStarter, type Registration } from "../../module.js";
|
|
4
|
+
export interface AlgorandConfig {
|
|
5
|
+
/** The network, exactly one. */
|
|
6
|
+
readonly network: AlgorandNetwork;
|
|
7
|
+
/** The seller's fee-payer key, as `@x402/avm`'s facilitator class takes it, with its algod node. */
|
|
8
|
+
readonly signer: FacilitatorAvmSigner;
|
|
9
|
+
/** The seller's Indexer, following the network's consensus, which lcp's read uses. */
|
|
10
|
+
readonly indexer: string;
|
|
11
|
+
/** Whether that Indexer is archival, holding every round; lcp's read then needs no header read for its history. */
|
|
12
|
+
readonly archival?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** lcp's reader over the Indexer at `url`, its calls ending by `deadline`. */
|
|
15
|
+
export declare function avmReader(c: AlgorandConfig, deadline: number): AvmReader;
|
|
16
|
+
/**
|
|
17
|
+
* The registration of `x402/exact/algorand` on the configured network: the published class, and behind its
|
|
18
|
+
* registration the own path for a rekeyed payer's one key and a Falcon key, claimed by the payment entry's members.
|
|
19
|
+
*/
|
|
20
|
+
export declare function algorandRegistration(c: AlgorandConfig): Registration;
|
|
21
|
+
/** How the core starts the module: the configuration's `algorand` member lists the networks, one entry each. */
|
|
22
|
+
export declare const starter: ModuleStarter<readonly AlgorandConfig[]>;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Algorand module for `x402/exact/algorand` on one network: `@x402/avm` 2.31.0's facilitator class, registered
|
|
3
|
+
* unchanged behind lcp's checks of the pairing. lcp's `bound` refuses, before anything moves, an entry a logic
|
|
4
|
+
* signature authorises and one that names `asnd`, neither being the payer's signed act. The key is the seller's fee
|
|
5
|
+
* payer, which pools the group's fee by its own zero-amount payment in the same atomic group (`extra.key` `fee-payer`);
|
|
6
|
+
* it reaches the module as the `FacilitatorAvmSigner` the class takes, and its address is in `signers` and the class's
|
|
7
|
+
* `extra.feePayer`. A payer the class cannot settle, a rekeyed account signing with its one key (`sig` with `sgnr`) or
|
|
8
|
+
* a Falcon key (`pqsig`), is claimed by the payment entry's own members and settled by the module's own path
|
|
9
|
+
* (`./own.ts`). The read searches by the payment's own id and its validity, so the module gives the core no position.
|
|
10
|
+
*/
|
|
11
|
+
import { isRefusal } from "@integraledger/lcp";
|
|
12
|
+
import { exactAvm } from "@integraledger/lcp/avm";
|
|
13
|
+
import { ExactAvmScheme } from "@x402/avm/exact/facilitator";
|
|
14
|
+
import { isObject } from "../../answers.js";
|
|
15
|
+
import { NODE_MAX_BYTES, NODE_TIMEOUT_MS, NodeError, site } from "../../http.js";
|
|
16
|
+
import { outcomeOf, } from "../../module.js";
|
|
17
|
+
import { feePayerFee, keyEntries, ownAuthority, ownFacilitator } from "./own.js";
|
|
18
|
+
function reasonOf(r) {
|
|
19
|
+
if (r.code === "x402/not-v2")
|
|
20
|
+
return "invalid_x402_version";
|
|
21
|
+
if (r.code.startsWith("x402/option"))
|
|
22
|
+
return "invalid_payment_requirements";
|
|
23
|
+
return "invalid_payload";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The module's checks that read neither the chain nor the clock: its network, lcp's bound and reference, then the fee
|
|
27
|
+
* payer's entry. x402's class and the own path sign every entry of the group that one of the key's addresses sends,
|
|
28
|
+
* whatever the option names, so a group may hold one such entry only, and only where the option's `extra.feePayer`
|
|
29
|
+
* names its sender: with no fee payer in the option the buyer pays its own fee, the choice fixed in what it signs.
|
|
30
|
+
*/
|
|
31
|
+
async function pure(c, payload, requirements) {
|
|
32
|
+
const network = c.network;
|
|
33
|
+
if (requirements.network !== network || payload.accepted?.network !== network)
|
|
34
|
+
return { reason: "invalid_network" };
|
|
35
|
+
const bound = await exactAvm.bound(payload);
|
|
36
|
+
if (isRefusal(bound))
|
|
37
|
+
return { reason: reasonOf(bound), code: bound.code };
|
|
38
|
+
// The requirements arrive as JSON, which lcp's option type names.
|
|
39
|
+
const ref = await exactAvm.reference(payload, requirements);
|
|
40
|
+
if (isRefusal(ref))
|
|
41
|
+
return { reason: reasonOf(ref), code: ref.code };
|
|
42
|
+
const keyed = keyEntries(payload, c.signer.getAddresses()) ?? [];
|
|
43
|
+
if (keyed.length > 1 || (keyed.length === 1 && keyed[0] !== requirements.extra?.["feePayer"])) {
|
|
44
|
+
return { reason: "invalid_exact_avm_invalid_fee_payer" };
|
|
45
|
+
}
|
|
46
|
+
return ref;
|
|
47
|
+
}
|
|
48
|
+
const isRef = (v) => !("reason" in v);
|
|
49
|
+
/** One bounded GET of the Indexer: the JSON answer, or `null` for a 404, the Indexer's answer for what it does not hold. */
|
|
50
|
+
async function getJson(url, deadline) {
|
|
51
|
+
const ms = Math.min(NODE_TIMEOUT_MS, deadline - performance.now());
|
|
52
|
+
if (ms <= 0)
|
|
53
|
+
throw new NodeError("spent", false, site(url));
|
|
54
|
+
let res;
|
|
55
|
+
try {
|
|
56
|
+
res = await fetch(url, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(Math.ceil(ms)) });
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
throw new NodeError("transport", true, e instanceof Error ? e.message : String(e), { cause: e });
|
|
60
|
+
}
|
|
61
|
+
const text = await res.text();
|
|
62
|
+
if (text.length > NODE_MAX_BYTES)
|
|
63
|
+
throw new NodeError("too-large", true, site(url));
|
|
64
|
+
if (res.status === 404)
|
|
65
|
+
return null;
|
|
66
|
+
if (res.status < 200 || res.status > 299)
|
|
67
|
+
throw new NodeError("http-status", true, `status ${res.status}`);
|
|
68
|
+
try {
|
|
69
|
+
return JSON.parse(text);
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
throw new NodeError("malformed", true, "the answer is not JSON", { cause: e });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function round(v) {
|
|
76
|
+
if (typeof v === "number" && Number.isSafeInteger(v) && v >= 0)
|
|
77
|
+
return BigInt(v);
|
|
78
|
+
throw new NodeError("malformed", true, "a round");
|
|
79
|
+
}
|
|
80
|
+
/** A transaction as the Indexer answers it, in lcp's terms. */
|
|
81
|
+
function indexed(t) {
|
|
82
|
+
const sig = isObject(t["signature"]) ? t["signature"] : {};
|
|
83
|
+
const signature = ["sig", "multisig", "logicsig", "pqsig"].find((k) => sig[k] !== undefined) ?? "none";
|
|
84
|
+
const x = t["asset-transfer-transaction"];
|
|
85
|
+
const text = (v) => (typeof v === "string" ? v : null);
|
|
86
|
+
if (typeof t["id"] !== "string" || typeof t["sender"] !== "string" || typeof t["tx-type"] !== "string") {
|
|
87
|
+
throw new NodeError("malformed", true, "a transaction");
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
id: t["id"],
|
|
91
|
+
confirmedRound: round(t["confirmed-round"]),
|
|
92
|
+
type: t["tx-type"],
|
|
93
|
+
sender: t["sender"],
|
|
94
|
+
authAddr: text(t["auth-addr"]),
|
|
95
|
+
signature,
|
|
96
|
+
note: new Uint8Array(Buffer.from(typeof t["note"] === "string" ? t["note"] : "", "base64")),
|
|
97
|
+
transfer: isObject(x)
|
|
98
|
+
? {
|
|
99
|
+
assetId: round(x["asset-id"]),
|
|
100
|
+
receiver: String(x["receiver"]),
|
|
101
|
+
amount: round(x["amount"]),
|
|
102
|
+
closeTo: text(x["close-to"]),
|
|
103
|
+
closeAmount: x["close-amount"] === undefined ? 0n : round(x["close-amount"]),
|
|
104
|
+
assetSender: text(x["sender"]),
|
|
105
|
+
}
|
|
106
|
+
: null,
|
|
107
|
+
inner: Array.isArray(t["inner-txns"]) ? t["inner-txns"].filter(isObject).map((i) => indexed({ id: t["id"], ...i })) : [],
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** lcp's reader over the Indexer at `url`, its calls ending by `deadline`. */
|
|
111
|
+
export function avmReader(c, deadline) {
|
|
112
|
+
const base = c.indexer.replace(/\/+$/, "");
|
|
113
|
+
const get = (path) => getJson(`${base}${path}`, deadline);
|
|
114
|
+
return {
|
|
115
|
+
network: c.network,
|
|
116
|
+
...(c.archival ? { archival: true } : {}),
|
|
117
|
+
async transaction(txid) {
|
|
118
|
+
const a = await get(`/v2/transactions/${encodeURIComponent(txid)}`);
|
|
119
|
+
if (a === null) {
|
|
120
|
+
const health = await get("/health");
|
|
121
|
+
return { currentRound: round(isObject(health) ? health["round"] : undefined), found: null };
|
|
122
|
+
}
|
|
123
|
+
if (!isObject(a) || !isObject(a["transaction"]))
|
|
124
|
+
throw new NodeError("malformed", true, "a transaction lookup");
|
|
125
|
+
return { currentRound: round(a["current-round"]), found: indexed(a["transaction"]) };
|
|
126
|
+
},
|
|
127
|
+
async header(r) {
|
|
128
|
+
return (await get(`/v2/blocks/${r}?header-only=true`)) !== null;
|
|
129
|
+
},
|
|
130
|
+
async accountPage(account, q) {
|
|
131
|
+
const query = new URLSearchParams({ "min-round": String(q.minRound) });
|
|
132
|
+
if (q.maxRound !== undefined)
|
|
133
|
+
query.set("max-round", String(q.maxRound));
|
|
134
|
+
if (q.next !== undefined)
|
|
135
|
+
query.set("next", q.next);
|
|
136
|
+
const a = await get(`/v2/accounts/${encodeURIComponent(account)}/transactions?${query}`);
|
|
137
|
+
if (!isObject(a) || !Array.isArray(a["transactions"]))
|
|
138
|
+
throw new NodeError("malformed", true, "an account page");
|
|
139
|
+
const transactions = a["transactions"].map((t) => {
|
|
140
|
+
try {
|
|
141
|
+
return indexed(t);
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
return { unparseable: true, id: isObject(t) && typeof t["id"] === "string" ? t["id"] : "" };
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
const next = a["next-token"];
|
|
148
|
+
return { currentRound: round(a["current-round"]), transactions, ...(typeof next === "string" ? { next } : {}) };
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/** The published class with the module's pure checks before it on both calls. */
|
|
153
|
+
function behind(cls, c) {
|
|
154
|
+
return {
|
|
155
|
+
scheme: cls.scheme,
|
|
156
|
+
caipFamily: cls.caipFamily,
|
|
157
|
+
getExtra: (n) => cls.getExtra(n),
|
|
158
|
+
getSigners: (n) => cls.getSigners(n),
|
|
159
|
+
async verify(payload, requirements, context) {
|
|
160
|
+
const r = await pure(c, payload, requirements);
|
|
161
|
+
if (isRef(r))
|
|
162
|
+
return cls.verify(payload, requirements, context);
|
|
163
|
+
return { isValid: false, invalidReason: r.reason, ...(r.code ? { invalidMessage: r.code } : {}) };
|
|
164
|
+
},
|
|
165
|
+
async settle(payload, requirements, context) {
|
|
166
|
+
const r = await pure(c, payload, requirements);
|
|
167
|
+
if (isRef(r))
|
|
168
|
+
return cls.settle(payload, requirements, context);
|
|
169
|
+
return { success: false, errorReason: r.reason, ...(r.code ? { errorMessage: r.code } : {}), transaction: "", network: requirements.network };
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/** The record's members, the same on both paths. */
|
|
174
|
+
function recordOf(c) {
|
|
175
|
+
const network = c.network;
|
|
176
|
+
return {
|
|
177
|
+
async instrument(p) {
|
|
178
|
+
const r = await pure(c, p.payload, p.requirements);
|
|
179
|
+
if (!isRef(r))
|
|
180
|
+
return { refused: r.reason, ...(r.code === undefined ? {} : { message: r.code }) };
|
|
181
|
+
return {
|
|
182
|
+
pairing: exactAvm.id,
|
|
183
|
+
// The id is the hash of the transaction's own fields; no signature is in it.
|
|
184
|
+
instrument: { by: "transaction", network, transaction: r.txid },
|
|
185
|
+
nonce: exactAvm.data.nonce,
|
|
186
|
+
// Its life ends at lastValid, a round, which no clock bounds from above.
|
|
187
|
+
keep: { until: "settler" },
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
async read(p, at) {
|
|
191
|
+
const r = await pure(c, p.payload, p.requirements);
|
|
192
|
+
if (!isRef(r))
|
|
193
|
+
return outcomeOf({ state: "unreadable", reason: "unparseable", foreign: [] });
|
|
194
|
+
const search = at.search;
|
|
195
|
+
return outcomeOf(await exactAvm.status(r, avmReader(c, at.deadline), { act: "payment", finality: "final", ...(search ? { search } : {}) }));
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** The fee budget's members, the same on both paths: the key pays the fee its own transaction in the group names. */
|
|
200
|
+
function feesOf(c) {
|
|
201
|
+
return {
|
|
202
|
+
// The key pays where the group holds its zero payment, which the class and the own path sign; the checks admit
|
|
203
|
+
// one, under an option naming it as `extra.feePayer`.
|
|
204
|
+
paysFee: (p) => (keyEntries(p.payload, c.signer.getAddresses()) ?? []).length > 0,
|
|
205
|
+
payerBroadcast: () => false,
|
|
206
|
+
async charged(p, sent) {
|
|
207
|
+
const fee = feePayerFee(c.signer, p.payload);
|
|
208
|
+
const shown = await avmReader(c, sent.deadline).transaction(sent.transaction);
|
|
209
|
+
return { fee, included: shown.found !== null };
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/** The descriptor of `x402/exact/algorand`, one kind for both paths. */
|
|
214
|
+
function descriptor() {
|
|
215
|
+
// lcp's floor is 0: the scheme sets none, the class compares amounts by equality, and a zero transfer needs no opt-in.
|
|
216
|
+
return { name: "algorand", key: "fee-payer", pairings: [exactAvm.id], acceptsZero: true };
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The registration of `x402/exact/algorand` on the configured network: the published class, and behind its
|
|
220
|
+
* registration the own path for a rekeyed payer's one key and a Falcon key, claimed by the payment entry's members.
|
|
221
|
+
*/
|
|
222
|
+
export function algorandRegistration(c) {
|
|
223
|
+
const network = c.network;
|
|
224
|
+
const module = {
|
|
225
|
+
descriptor: descriptor(),
|
|
226
|
+
network,
|
|
227
|
+
facilitator: behind(new ExactAvmScheme(c.signer), c),
|
|
228
|
+
record: recordOf(c),
|
|
229
|
+
fees: feesOf(c),
|
|
230
|
+
};
|
|
231
|
+
const admitted = async (payload, r) => {
|
|
232
|
+
const ref = await pure(c, payload, r);
|
|
233
|
+
return isRef(ref) ? { txid: ref.txid } : ref;
|
|
234
|
+
};
|
|
235
|
+
const own = {
|
|
236
|
+
claim: { by: "payment", claims: (payload) => ownAuthority(payload) !== undefined },
|
|
237
|
+
module: { descriptor: descriptor(), network, facilitator: ownFacilitator(c.signer, admitted), record: recordOf(c), fees: feesOf(c) },
|
|
238
|
+
};
|
|
239
|
+
return { network, module, own: [own] };
|
|
240
|
+
}
|
|
241
|
+
/** How the core starts the module: the configuration's `algorand` member lists the networks, one entry each. */
|
|
242
|
+
export const starter = {
|
|
243
|
+
name: "algorand",
|
|
244
|
+
async start(networks) {
|
|
245
|
+
return { registrations: networks.map(algorandRegistration) };
|
|
246
|
+
},
|
|
247
|
+
};
|