@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
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type CasperNetwork, type CasperReader } from "@integraledger/lcp/casper";
|
|
2
|
+
import type { Network, SchemeNetworkFacilitator } from "@x402/core/types";
|
|
3
|
+
import { type FeeMeter, type Module, type ModuleStarter, type Registration } from "../../module.js";
|
|
4
|
+
/**
|
|
5
|
+
* `@x402/casper`'s `FacilitatorCasperSigner`: the seller's key as the published class takes it, which its own
|
|
6
|
+
* `toFacilitatorCasperSigner` makes from a casper-js-sdk `PrivateKey`.
|
|
7
|
+
*/
|
|
8
|
+
export interface CasperSigner {
|
|
9
|
+
getNetworkConfig(network: Network): Promise<{
|
|
10
|
+
readonly chainName: string;
|
|
11
|
+
readonly rpcUrl: string;
|
|
12
|
+
}>;
|
|
13
|
+
getAddresses(network: Network): string[];
|
|
14
|
+
getPublicKeyHex(network: Network): string;
|
|
15
|
+
getSpeculativeRpcUrl(network: Network): string | undefined;
|
|
16
|
+
signTransaction(transaction: unknown, network: Network): Promise<void>;
|
|
17
|
+
putTransaction(network: Network, transaction: unknown): Promise<string>;
|
|
18
|
+
waitForTransaction(network: Network, transactionHash: string): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The parts of casper-js-sdk 5.1.1 the reader uses, typed here: the module loads `@x402/casper` and casper-js-sdk by
|
|
22
|
+
* names the compiler does not resolve, since casper-js-sdk ships TypeScript sources beside its declarations
|
|
23
|
+
* (`dist/@types/*.ts`, which `dist/index.d.ts` reaches before their `.d.ts`), and a compiler that resolves its types
|
|
24
|
+
* reads them as this package's own sources and refuses them under `verbatimModuleSyntax` (TS1287).
|
|
25
|
+
*/
|
|
26
|
+
interface Decimal {
|
|
27
|
+
toString(): string;
|
|
28
|
+
}
|
|
29
|
+
interface Cl {
|
|
30
|
+
readonly key?: {
|
|
31
|
+
readonly account?: {
|
|
32
|
+
toHex(): string;
|
|
33
|
+
};
|
|
34
|
+
readonly hash?: {
|
|
35
|
+
toHex(): string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly ui8?: Decimal;
|
|
39
|
+
readonly ui64?: Decimal;
|
|
40
|
+
readonly ui256?: Decimal;
|
|
41
|
+
readonly list?: {
|
|
42
|
+
readonly elements: readonly Cl[];
|
|
43
|
+
};
|
|
44
|
+
readonly byteArray?: {
|
|
45
|
+
bytes(): Uint8Array;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** casper-js-sdk's `InfoGetTransactionResult`, as `fromJSON` gives it from a `Version1` transaction or a `Deploy`. */
|
|
49
|
+
interface Parsed {
|
|
50
|
+
readonly transaction: {
|
|
51
|
+
readonly args: {
|
|
52
|
+
getByName(name: string): Cl | undefined;
|
|
53
|
+
};
|
|
54
|
+
readonly target: {
|
|
55
|
+
readonly stored?: {
|
|
56
|
+
readonly id: {
|
|
57
|
+
readonly byPackageHash?: {
|
|
58
|
+
readonly addr: {
|
|
59
|
+
toHex(): string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
readonly entryPoint: {
|
|
66
|
+
readonly customEntryPoint?: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
readonly executionInfo?: {
|
|
70
|
+
readonly blockHeight: number;
|
|
71
|
+
readonly executionResult?: {
|
|
72
|
+
readonly errorMessage?: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** casper-js-sdk's parse of `info_get_transaction`'s result. */
|
|
77
|
+
export type ParseTransaction = (json: unknown) => Parsed | null;
|
|
78
|
+
/** The published class and casper-js-sdk's parse, loaded once a configuration names a Casper network. */
|
|
79
|
+
declare function published(): Promise<{
|
|
80
|
+
readonly Scheme: new (signer: CasperSigner, config: {
|
|
81
|
+
limitedPaymentMotes?: number;
|
|
82
|
+
}) => SchemeNetworkFacilitator;
|
|
83
|
+
readonly defaultMotes: number;
|
|
84
|
+
readonly parse: ParseTransaction;
|
|
85
|
+
}>;
|
|
86
|
+
export interface CasperConfig {
|
|
87
|
+
/**
|
|
88
|
+
* The network, exactly one: `casper:casper-test`. x402's Casper scheme also names `casper:casper`, which the module
|
|
89
|
+
* does not start on until a token there is shown to execute `transfer_with_authorization`.
|
|
90
|
+
*/
|
|
91
|
+
readonly network: CasperNetwork;
|
|
92
|
+
/**
|
|
93
|
+
* The seller's key, as `@x402/casper`'s facilitator class takes it: it signs and sends the transaction that executes
|
|
94
|
+
* the payer's authorization, and pays its gas. Its `getNetworkConfig` must name `rpc` for `network`, and its
|
|
95
|
+
* `getSpeculativeRpcUrl` none or `rpc`.
|
|
96
|
+
*/
|
|
97
|
+
readonly signer: CasperSigner;
|
|
98
|
+
/** The seller's node, its JSON-RPC URL: the class's reads, lcp's read and the fee count. */
|
|
99
|
+
readonly rpc: string;
|
|
100
|
+
/**
|
|
101
|
+
* The most the settlement transaction can pay, in motes, which the class offers as its payment; `@x402/casper`'s
|
|
102
|
+
* default (2.5 CSPR) where left out.
|
|
103
|
+
*/
|
|
104
|
+
readonly paymentMotes?: number;
|
|
105
|
+
}
|
|
106
|
+
/** lcp's reader over the node's JSON-RPC at `url`, its calls ending by `deadline`. */
|
|
107
|
+
export declare function casperReader(network: CasperNetwork, url: string, deadline: number, parse: ParseTransaction): CasperReader;
|
|
108
|
+
/**
|
|
109
|
+
* The module of `x402/exact/casper` on the configured network, over the published class and casper-js-sdk's parse.
|
|
110
|
+
* With `meter`, the network's fee meter, every transaction the class submits is counted.
|
|
111
|
+
*/
|
|
112
|
+
export declare function casperModule(c: CasperConfig, p: Awaited<ReturnType<typeof published>>, meter?: FeeMeter): Module;
|
|
113
|
+
/**
|
|
114
|
+
* The module's registration, once the network is one it serves and the signer is shown to name the configured node,
|
|
115
|
+
* for its reads and for any speculative execution, and the network's chain.
|
|
116
|
+
*/
|
|
117
|
+
export declare function casperRegistration(c: CasperConfig, p: Awaited<ReturnType<typeof published>>, meter?: FeeMeter): Promise<Registration>;
|
|
118
|
+
/** The module's start: one registration of `exact` per configured network, its submissions counted by its fee meter. */
|
|
119
|
+
export declare const starter: ModuleStarter<readonly CasperConfig[]>;
|
|
120
|
+
export {};
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Casper module for `x402/exact/casper` on each configured network: `@x402/casper` 2.31.0's facilitator class,
|
|
3
|
+
* registered unchanged. The payer signs a CEP-3009 `TransferWithAuthorization` whose 32-byte nonce is H (on an
|
|
4
|
+
* agreement, the agreement's own value of H); the seller's key sends the transaction that calls the token package's
|
|
5
|
+
* `transfer_with_authorization` with it, and pays its gas (`extra.key` `relayer`). The key reaches the module as the
|
|
6
|
+
* `FacilitatorCasperSigner` the class takes. The class reads the token's state before it settles from the node its
|
|
7
|
+
* signer names, so that node must be the one the configuration names, the seller's: the module does not start where the
|
|
8
|
+
* signer names another, as `@x402/casper`'s signer does for a network its configuration leaves out, falling back to a
|
|
9
|
+
* public node. Where the signer names a node for speculative execution, the class has the key sign a deploy of the
|
|
10
|
+
* payer's authorization at every check and sends it there, so that node too must be the configured one. lcp's checks of
|
|
11
|
+
* the pairing come first and name the instrument; lcp's read goes through the same node. Every transaction the key
|
|
12
|
+
* submits is counted in the network's fee budget as it is submitted, one the class's answer does not name included.
|
|
13
|
+
* The module serves `casper:casper-test` and does not start on `casper:casper`, where no token has yet been shown to
|
|
14
|
+
* execute `transfer_with_authorization`.
|
|
15
|
+
*/
|
|
16
|
+
import { fromLegalContext, isRefusal } from "@integraledger/lcp";
|
|
17
|
+
import { exactCasper, } from "@integraledger/lcp/casper";
|
|
18
|
+
import { isObject } from "../../answers.js";
|
|
19
|
+
import { NODE_TIMEOUT_MS, NodeError, postJson, site } from "../../http.js";
|
|
20
|
+
import { outcomeOf, } from "../../module.js";
|
|
21
|
+
const load = (name) => import(name);
|
|
22
|
+
/** The published class and casper-js-sdk's parse, loaded once a configuration names a Casper network. */
|
|
23
|
+
async function published() {
|
|
24
|
+
const [facilitator, x402, sdk] = await Promise.all([load("@x402/casper/exact/facilitator"), load("@x402/casper"), load("casper-js-sdk")]);
|
|
25
|
+
const result = (sdk["InfoGetTransactionResult"] ?? sdk["default"]["InfoGetTransactionResult"]);
|
|
26
|
+
return {
|
|
27
|
+
Scheme: facilitator["ExactCasperScheme"],
|
|
28
|
+
defaultMotes: x402["DEFAULT_PAYMENT_MOTES"],
|
|
29
|
+
parse: (json) => result.fromJSON(json),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Casper mainnet, on which no token has yet been shown to execute `transfer_with_authorization`. */
|
|
33
|
+
const CASPER_MAINNET = "casper:casper";
|
|
34
|
+
/** The dictionary in which the token package keeps a used nonce, by the profile `x402/exact/casper`, rule 10. */
|
|
35
|
+
const USED_NONCES = "used_nonces";
|
|
36
|
+
/** The transactions of a block one page of `blockCalls` reads. */
|
|
37
|
+
const PAGE = 64;
|
|
38
|
+
/** The node's error codes the reader tells apart (casper-node's JSON-RPC codes, as casper-js-sdk names them). */
|
|
39
|
+
const NO_SUCH_BLOCK = -32001;
|
|
40
|
+
const QUERY_FAILED = -32003;
|
|
41
|
+
const NO_SUCH_STATE_ROOT = -32012;
|
|
42
|
+
const NO_SUCH_TRANSACTION = -32014;
|
|
43
|
+
/** The x402 reason for one of lcp's refusals: the version, the option, or else the payload. */
|
|
44
|
+
function reasonOf(r) {
|
|
45
|
+
if (r.code === "x402/not-v2")
|
|
46
|
+
return "invalid_x402_version";
|
|
47
|
+
if (r.code.startsWith("x402/option") || r.code === "casper/option-malformed")
|
|
48
|
+
return "invalid_payment_requirements";
|
|
49
|
+
return "invalid_payload";
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* lcp's checks of the payment, which read neither the chain nor the clock, and its read keys; or the refusal. A payment
|
|
53
|
+
* signs H as its nonce. An agreement signs the agreement's own value of H, so where the nonce is not the H the payment
|
|
54
|
+
* echoes, it is the agreement's when it is that H's agreement value (the profile, rule 4).
|
|
55
|
+
*/
|
|
56
|
+
async function checked(p) {
|
|
57
|
+
const bound = await exactCasper.bound(p.payload);
|
|
58
|
+
if (isRefusal(bound))
|
|
59
|
+
return bound;
|
|
60
|
+
// The requirements arrive as JSON, which lcp's option type names.
|
|
61
|
+
const option = p.requirements;
|
|
62
|
+
const ref = await exactCasper.reference(p.payload, option);
|
|
63
|
+
if (!isRefusal(ref))
|
|
64
|
+
return { ref, act: "payment", h: ref.nonce };
|
|
65
|
+
if (ref.code !== "casper/nonce-not-bound")
|
|
66
|
+
return ref;
|
|
67
|
+
const echoed = isObject(p.payload.extensions) ? p.payload.extensions["legalContext"] : undefined;
|
|
68
|
+
const lc = fromLegalContext({ legalContext: isObject(echoed) ? echoed["info"] : undefined });
|
|
69
|
+
if (lc === null)
|
|
70
|
+
return ref;
|
|
71
|
+
const agreed = await exactCasper.reference(p.payload, option, { act: "agreement", h: lc.h });
|
|
72
|
+
return isRefusal(agreed) ? ref : { ref: agreed, act: "agreement", h: lc.h };
|
|
73
|
+
}
|
|
74
|
+
function hex(bytes) {
|
|
75
|
+
return Buffer.from(bytes).toString("hex");
|
|
76
|
+
}
|
|
77
|
+
/** A decimal the node wrote as a number or a string, as a bigint. */
|
|
78
|
+
function whole(v, what) {
|
|
79
|
+
if (typeof v === "number" && Number.isSafeInteger(v) && v >= 0)
|
|
80
|
+
return BigInt(v);
|
|
81
|
+
if (typeof v === "string" && /^\d+$/.test(v))
|
|
82
|
+
return BigInt(v);
|
|
83
|
+
throw new NodeError("malformed", true, what);
|
|
84
|
+
}
|
|
85
|
+
/** `chain_get_block`'s block, a `Version2` block or a `Version1` one. */
|
|
86
|
+
function blockOf(r) {
|
|
87
|
+
const signed = isObject(r) ? r["block_with_signatures"] : undefined;
|
|
88
|
+
const wrapped = isObject(signed) ? signed["block"] : undefined;
|
|
89
|
+
const v2 = isObject(wrapped) ? wrapped["Version2"] : undefined;
|
|
90
|
+
const v1 = isObject(wrapped) ? wrapped["Version1"] : undefined;
|
|
91
|
+
const block = isObject(v2) ? v2 : isObject(v1) ? v1 : undefined;
|
|
92
|
+
const header = isObject(block) ? block["header"] : undefined;
|
|
93
|
+
const body = isObject(block) ? block["body"] : undefined;
|
|
94
|
+
if (!isObject(header) || !isObject(body))
|
|
95
|
+
throw new NodeError("malformed", true, "a block");
|
|
96
|
+
const time = typeof header["timestamp"] === "string" ? Date.parse(header["timestamp"]) : Number.NaN;
|
|
97
|
+
const root = header["state_root_hash"];
|
|
98
|
+
if (!Number.isSafeInteger(time) || typeof root !== "string")
|
|
99
|
+
throw new NodeError("malformed", true, "a block header");
|
|
100
|
+
const transactions = [];
|
|
101
|
+
if (isObject(v2)) {
|
|
102
|
+
// A Version2 block holds its transactions by lane; its order is the lanes' in their ids' order.
|
|
103
|
+
const lanes = isObject(body["transactions"]) ? body["transactions"] : {};
|
|
104
|
+
for (const lane of Object.keys(lanes).sort((a, b) => Number(a) - Number(b))) {
|
|
105
|
+
const list = lanes[lane];
|
|
106
|
+
for (const t of Array.isArray(list) ? list : []) {
|
|
107
|
+
const tag = isObject(t) && typeof t["Version1"] === "string" ? "Version1" : isObject(t) && typeof t["Deploy"] === "string" ? "Deploy" : undefined;
|
|
108
|
+
if (tag === undefined)
|
|
109
|
+
throw new NodeError("malformed", true, "a block's transaction");
|
|
110
|
+
transactions.push({ hash: t[tag].toLowerCase(), tag });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
for (const key of ["deploy_hashes", "transfer_hashes"]) {
|
|
116
|
+
const list = body[key];
|
|
117
|
+
for (const t of Array.isArray(list) ? list : []) {
|
|
118
|
+
if (typeof t !== "string")
|
|
119
|
+
throw new NodeError("malformed", true, "a block's deploy");
|
|
120
|
+
transactions.push({ hash: t.toLowerCase(), tag: "Deploy" });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return { height: whole(header["height"], "a block height"), timestamp: BigInt(time), stateRoot: root, transactions };
|
|
125
|
+
}
|
|
126
|
+
/** An argument's account hash or package hash, as lcp spells an address: its tag, `00` or `01`, then 32 bytes. */
|
|
127
|
+
function addressOf(v) {
|
|
128
|
+
const key = v?.key;
|
|
129
|
+
if (key?.account !== undefined)
|
|
130
|
+
return `00${key.account.toHex()}`.toLowerCase();
|
|
131
|
+
if (key?.hash !== undefined)
|
|
132
|
+
return `01${key.hash.toHex()}`.toLowerCase();
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
function numberOf(v) {
|
|
136
|
+
const n = v?.ui256 ?? v?.ui64;
|
|
137
|
+
const s = n?.toString();
|
|
138
|
+
return s !== undefined && /^\d+$/.test(s) ? BigInt(s) : undefined;
|
|
139
|
+
}
|
|
140
|
+
/** A `List<U8>` or a byte array, as bytes. */
|
|
141
|
+
function bytesOf(v) {
|
|
142
|
+
if (v?.byteArray !== undefined)
|
|
143
|
+
return v.byteArray.bytes();
|
|
144
|
+
const elements = v?.list?.elements;
|
|
145
|
+
if (elements === undefined)
|
|
146
|
+
return undefined;
|
|
147
|
+
const out = elements.map((e) => Number(e.ui8?.toString()));
|
|
148
|
+
return out.every((b) => Number.isInteger(b) && b >= 0 && b <= 255) ? Uint8Array.from(out) : undefined;
|
|
149
|
+
}
|
|
150
|
+
/** One executed transaction's call, as lcp's reader reports it, from `info_get_transaction`'s answer. */
|
|
151
|
+
function callOf(r) {
|
|
152
|
+
const t = r.transaction;
|
|
153
|
+
const info = r.executionInfo;
|
|
154
|
+
const result = info?.executionResult;
|
|
155
|
+
const args = t.args;
|
|
156
|
+
const arg = (name) => args.getByName(name);
|
|
157
|
+
const from = addressOf(arg("from")) ?? addressOf(arg("authorizer"));
|
|
158
|
+
const to = addressOf(arg("to"));
|
|
159
|
+
const value = numberOf(arg("value"));
|
|
160
|
+
const validAfter = numberOf(arg("valid_after"));
|
|
161
|
+
const validBefore = numberOf(arg("valid_before"));
|
|
162
|
+
const nonce = bytesOf(arg("nonce"));
|
|
163
|
+
return {
|
|
164
|
+
executed: result !== undefined,
|
|
165
|
+
blockHeight: info === undefined || result === undefined ? null : BigInt(info.blockHeight),
|
|
166
|
+
error: result?.errorMessage ? result.errorMessage : null,
|
|
167
|
+
packageHash: t.target.stored?.id.byPackageHash?.addr.toHex().toLowerCase() ?? null,
|
|
168
|
+
entryPoint: t.entryPoint.customEntryPoint ?? null,
|
|
169
|
+
args: {
|
|
170
|
+
...(from === undefined ? {} : { from }),
|
|
171
|
+
...(to === undefined ? {} : { to }),
|
|
172
|
+
...(value === undefined ? {} : { value }),
|
|
173
|
+
...(validAfter === undefined ? {} : { validAfter }),
|
|
174
|
+
...(validBefore === undefined ? {} : { validBefore }),
|
|
175
|
+
...(nonce === undefined ? {} : { nonce }),
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/** lcp's reader over the node's JSON-RPC at `url`, its calls ending by `deadline`. */
|
|
180
|
+
export function casperReader(network, url, deadline, parse) {
|
|
181
|
+
let id = 0;
|
|
182
|
+
async function rpc(method, params) {
|
|
183
|
+
const body = { jsonrpc: "2.0", id: ++id, method, ...(params === undefined ? {} : { params }) };
|
|
184
|
+
const a = await postJson(url, body, deadline - performance.now());
|
|
185
|
+
if (!isObject(a))
|
|
186
|
+
throw new NodeError("malformed", true, method);
|
|
187
|
+
const e = a["error"];
|
|
188
|
+
if (isObject(e))
|
|
189
|
+
return { code: typeof e["code"] === "number" ? e["code"] : 0, message: String(e["message"] ?? "") };
|
|
190
|
+
return { result: a["result"] };
|
|
191
|
+
}
|
|
192
|
+
async function answered(method, params) {
|
|
193
|
+
const a = await rpc(method, params);
|
|
194
|
+
if (a.code !== undefined)
|
|
195
|
+
throw new NodeError("http-status", true, `${method} at ${site(url)}: ${a.code} ${a.message}`);
|
|
196
|
+
return a.result;
|
|
197
|
+
}
|
|
198
|
+
/** The block at `height`, or null where the node does not serve it. */
|
|
199
|
+
async function blockAt(height) {
|
|
200
|
+
const a = await rpc("chain_get_block", { block_identifier: { Height: Number(height) } });
|
|
201
|
+
if (a.code === NO_SUCH_BLOCK)
|
|
202
|
+
return null;
|
|
203
|
+
if (a.code !== undefined)
|
|
204
|
+
throw new NodeError("http-status", true, `chain_get_block: ${a.code} ${a.message}`);
|
|
205
|
+
return blockOf(a.result);
|
|
206
|
+
}
|
|
207
|
+
/** The newest enabled contract of the token package, at `stateRoot`. */
|
|
208
|
+
async function activeContract(asset, stateRoot) {
|
|
209
|
+
const r = await answered("query_global_state", { state_identifier: { StateRootHash: stateRoot }, key: `hash-${asset}`, path: [] });
|
|
210
|
+
const stored = isObject(r) ? r["stored_value"] : undefined;
|
|
211
|
+
const pkg = isObject(stored) ? stored["ContractPackage"] : undefined;
|
|
212
|
+
if (!isObject(pkg) || !Array.isArray(pkg["versions"]))
|
|
213
|
+
throw new NodeError("malformed", true, "a contract package");
|
|
214
|
+
const disabled = new Set((Array.isArray(pkg["disabled_versions"]) ? pkg["disabled_versions"] : []).map((d) => JSON.stringify(d)));
|
|
215
|
+
let best;
|
|
216
|
+
for (const v of pkg["versions"]) {
|
|
217
|
+
if (!isObject(v) || typeof v["contract_hash"] !== "string" || !Number.isSafeInteger(v["contract_version"]))
|
|
218
|
+
continue;
|
|
219
|
+
if (disabled.has(JSON.stringify([v["protocol_version_major"], v["contract_version"]])))
|
|
220
|
+
continue;
|
|
221
|
+
if (best === undefined || v["contract_version"] > best.version)
|
|
222
|
+
best = { version: v["contract_version"], hash: v["contract_hash"] };
|
|
223
|
+
}
|
|
224
|
+
if (best === undefined)
|
|
225
|
+
throw new NodeError("malformed", true, "a contract package with no enabled version");
|
|
226
|
+
return `hash-${best.hash.replace(/^(contract-|hash-)/, "")}`;
|
|
227
|
+
}
|
|
228
|
+
/** A transaction by its hash, as a `Version1` transaction and then as a `Deploy`; null where the node knows neither. */
|
|
229
|
+
async function transaction(hash, tags = ["Version1", "Deploy"]) {
|
|
230
|
+
for (const tag of tags) {
|
|
231
|
+
const a = await rpc("info_get_transaction", { transaction_hash: { [tag]: hash }, finalized_approvals: false });
|
|
232
|
+
if (a.code === NO_SUCH_TRANSACTION)
|
|
233
|
+
continue;
|
|
234
|
+
if (a.code !== undefined)
|
|
235
|
+
throw new NodeError("http-status", true, `info_get_transaction: ${a.code} ${a.message}`);
|
|
236
|
+
const parsed = parse(a.result);
|
|
237
|
+
if (parsed === null)
|
|
238
|
+
throw new NodeError("malformed", true, "a transaction");
|
|
239
|
+
return callOf(parsed);
|
|
240
|
+
}
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
network,
|
|
245
|
+
transaction: (hash) => transaction(hash.toLowerCase()),
|
|
246
|
+
async head() {
|
|
247
|
+
const b = blockOf(await answered("chain_get_block"));
|
|
248
|
+
return { height: b.height, timestamp: b.timestamp };
|
|
249
|
+
},
|
|
250
|
+
async lowest() {
|
|
251
|
+
const r = await answered("info_get_status");
|
|
252
|
+
const range = isObject(r) ? r["available_block_range"] : undefined;
|
|
253
|
+
return whole(isObject(range) ? range["low"] : undefined, "available_block_range");
|
|
254
|
+
},
|
|
255
|
+
async nonceUsed(asset, from, nonce, height) {
|
|
256
|
+
const block = await blockAt(height);
|
|
257
|
+
if (block === null)
|
|
258
|
+
return null;
|
|
259
|
+
const contract = await activeContract(asset, block.stateRoot);
|
|
260
|
+
// The item's key: the payer's key as the token serializes it, its tag and 32 bytes, then the nonce's 32 bytes.
|
|
261
|
+
const item = Buffer.concat([Buffer.from(from, "hex"), Buffer.from(nonce)]).toString("base64");
|
|
262
|
+
const a = await rpc("state_get_dictionary_item", {
|
|
263
|
+
state_root_hash: block.stateRoot,
|
|
264
|
+
dictionary_identifier: { ContractNamedKey: { key: contract, dictionary_name: USED_NONCES, dictionary_item_key: item } },
|
|
265
|
+
});
|
|
266
|
+
// The node answers a dictionary item it does not hold with its query's failure; a state root it does not serve
|
|
267
|
+
// with its own code.
|
|
268
|
+
if (a.code === QUERY_FAILED)
|
|
269
|
+
return false;
|
|
270
|
+
if (a.code === NO_SUCH_STATE_ROOT || a.code === NO_SUCH_BLOCK)
|
|
271
|
+
return null;
|
|
272
|
+
if (a.code !== undefined)
|
|
273
|
+
throw new NodeError("http-status", true, `state_get_dictionary_item: ${a.code} ${a.message}`);
|
|
274
|
+
const stored = isObject(a.result) ? a.result["stored_value"] : undefined;
|
|
275
|
+
const cl = isObject(stored) ? stored["CLValue"] : undefined;
|
|
276
|
+
if (!isObject(cl) || typeof cl["parsed"] !== "boolean")
|
|
277
|
+
throw new NodeError("malformed", true, "a used nonce");
|
|
278
|
+
return cl["parsed"];
|
|
279
|
+
},
|
|
280
|
+
async blockCalls(height, start) {
|
|
281
|
+
const block = await blockAt(height);
|
|
282
|
+
if (block === null)
|
|
283
|
+
return null;
|
|
284
|
+
const calls = [];
|
|
285
|
+
for (const t of block.transactions.slice(start, start + PAGE)) {
|
|
286
|
+
const c = await transaction(t.hash, [t.tag]);
|
|
287
|
+
if (c === null)
|
|
288
|
+
throw new NodeError("malformed", true, "a transaction of a block the node serves");
|
|
289
|
+
calls.push({ ...c, transaction: t.hash });
|
|
290
|
+
}
|
|
291
|
+
return { calls, next: start + PAGE < block.transactions.length ? start + PAGE : null };
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* What a transaction the key sent counts in the fee budget: the cost the node shows it paid once executed; until then,
|
|
297
|
+
* or where the node cannot be read, the payment it offered, its bound.
|
|
298
|
+
*/
|
|
299
|
+
async function chargedOf(url, hash, bound, deadline) {
|
|
300
|
+
const cost = await costOf(url, hash, deadline).catch(() => undefined);
|
|
301
|
+
return cost === undefined ? { fee: bound, included: false } : { fee: cost, included: true };
|
|
302
|
+
}
|
|
303
|
+
/** A casper-js-sdk transaction's own hash, known before it is sent. */
|
|
304
|
+
function hashOf(transaction) {
|
|
305
|
+
try {
|
|
306
|
+
const h = transaction?.hash?.toHex?.();
|
|
307
|
+
return typeof h === "string" && /^[0-9a-fA-F]{64}$/.test(h) ? h.toLowerCase() : undefined;
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
return undefined;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* The seller's signer object as the class takes it, each transaction it submits given to the network's fee meter once
|
|
315
|
+
* the submission ends, every other member unchanged. x402's class answers a submission that threw naming no
|
|
316
|
+
* transaction, though the node may have taken it; its hash is known before it is sent, so the meter counts it.
|
|
317
|
+
*/
|
|
318
|
+
function counted(signer, meter, shown) {
|
|
319
|
+
return new Proxy(signer, {
|
|
320
|
+
get(inner, member) {
|
|
321
|
+
const value = Reflect.get(inner, member);
|
|
322
|
+
if (typeof value !== "function")
|
|
323
|
+
return value;
|
|
324
|
+
if (member === "putTransaction") {
|
|
325
|
+
return async (network, transaction) => {
|
|
326
|
+
const hash = hashOf(transaction);
|
|
327
|
+
try {
|
|
328
|
+
return await value.call(inner, network, transaction);
|
|
329
|
+
}
|
|
330
|
+
finally {
|
|
331
|
+
if (hash !== undefined)
|
|
332
|
+
meter.sent(hash, () => shown(hash));
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
return value.bind(inner);
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/** The fee a transaction paid, in motes, where the node shows it executed: its execution result's `cost`. */
|
|
341
|
+
async function costOf(url, hash, deadline) {
|
|
342
|
+
const a = await postJson(url, { jsonrpc: "2.0", id: 1, method: "info_get_transaction", params: { transaction_hash: { Version1: hash }, finalized_approvals: false } }, deadline - performance.now());
|
|
343
|
+
const r = isObject(a) ? a["result"] : undefined;
|
|
344
|
+
const info = isObject(r) ? r["execution_info"] : undefined;
|
|
345
|
+
const result = isObject(info) ? info["execution_result"] : undefined;
|
|
346
|
+
if (!isObject(result))
|
|
347
|
+
return undefined;
|
|
348
|
+
const v2 = result["Version2"];
|
|
349
|
+
if (isObject(v2))
|
|
350
|
+
return whole(v2["cost"], "an execution's cost");
|
|
351
|
+
const v1 = isObject(result["Version1"]) ? result["Version1"] : undefined;
|
|
352
|
+
const outcome = isObject(v1) ? (v1["Success"] ?? v1["Failure"]) : undefined;
|
|
353
|
+
return isObject(outcome) ? whole(outcome["cost"], "an execution's cost") : undefined;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* The module of `x402/exact/casper` on the configured network, over the published class and casper-js-sdk's parse.
|
|
357
|
+
* With `meter`, the network's fee meter, every transaction the class submits is counted.
|
|
358
|
+
*/
|
|
359
|
+
export function casperModule(c, p, meter) {
|
|
360
|
+
const network = c.network;
|
|
361
|
+
const bound = BigInt(c.paymentMotes ?? p.defaultMotes);
|
|
362
|
+
const reader = (deadline) => casperReader(c.network, c.rpc, deadline, p.parse);
|
|
363
|
+
const signer = meter === undefined ? c.signer : counted(c.signer, meter, (hash) => chargedOf(c.rpc, hash, bound, performance.now() + NODE_TIMEOUT_MS));
|
|
364
|
+
return {
|
|
365
|
+
// x402's Casper settler refuses a zero amount, so the kind does not take zero (the profile, rule 24).
|
|
366
|
+
descriptor: { name: "casper", key: "relayer", pairings: [exactCasper.id], acceptsZero: false },
|
|
367
|
+
network,
|
|
368
|
+
facilitator: new p.Scheme(signer, c.paymentMotes === undefined ? {} : { limitedPaymentMotes: c.paymentMotes }),
|
|
369
|
+
record: {
|
|
370
|
+
async instrument(p) {
|
|
371
|
+
const k = await checked(p);
|
|
372
|
+
if (isRefusal(k))
|
|
373
|
+
return { refused: reasonOf(k), message: k.code };
|
|
374
|
+
// An authorization the payee signed is no payment and no agreement (the profile, rule 5): nothing is sent for it.
|
|
375
|
+
if (k.ref.from === k.ref.payee.toLowerCase())
|
|
376
|
+
return { refused: "invalid_payload" };
|
|
377
|
+
return {
|
|
378
|
+
pairing: exactCasper.id,
|
|
379
|
+
// The token keeps a used nonce by (from, nonce) in its own package (the profile, rule 10); an agreement's nonce
|
|
380
|
+
// is its own value of H, so one payer's agreement and payment under one H are two instruments.
|
|
381
|
+
instrument: { by: "single-use", network, signer: k.ref.from, scope: k.ref.asset, value: k.ref.nonce },
|
|
382
|
+
nonce: exactCasper.data.nonce,
|
|
383
|
+
// The authorization can no longer land at or past validBefore, which the payer signed, in Unix seconds.
|
|
384
|
+
keep: { until: "lapse", at: Math.min(k.ref.settleBy * 1000, Number.MAX_SAFE_INTEGER) },
|
|
385
|
+
};
|
|
386
|
+
},
|
|
387
|
+
async position(_p, at) {
|
|
388
|
+
return (await reader(at.deadline).head()).height;
|
|
389
|
+
},
|
|
390
|
+
async read(p, at) {
|
|
391
|
+
const k = await checked(p);
|
|
392
|
+
if (isRefusal(k))
|
|
393
|
+
return outcomeOf({ state: "unreadable", reason: "unparseable", foreign: [] });
|
|
394
|
+
const search = at.search;
|
|
395
|
+
const after = at.from;
|
|
396
|
+
return outcomeOf(await exactCasper.status({ ...k.ref, h: k.h }, reader(at.deadline), {
|
|
397
|
+
act: k.act,
|
|
398
|
+
finality: "finalized",
|
|
399
|
+
...(search === undefined ? {} : { search }),
|
|
400
|
+
...(after === undefined ? {} : { after }),
|
|
401
|
+
}));
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
fees: {
|
|
405
|
+
// The seller's key sends every settlement transaction and pays its gas.
|
|
406
|
+
paysFee: () => true,
|
|
407
|
+
payerBroadcast: () => false,
|
|
408
|
+
charged: (_p, sent) => chargedOf(c.rpc, sent.transaction, bound, sent.deadline),
|
|
409
|
+
},
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* The module's registration, once the network is one it serves and the signer is shown to name the configured node,
|
|
414
|
+
* for its reads and for any speculative execution, and the network's chain.
|
|
415
|
+
*/
|
|
416
|
+
export async function casperRegistration(c, p, meter) {
|
|
417
|
+
if (c.network === CASPER_MAINNET) {
|
|
418
|
+
throw new Error(`casper on ${c.network}: not served, since no token there has yet been shown to execute transfer_with_authorization`);
|
|
419
|
+
}
|
|
420
|
+
const named = await c.signer.getNetworkConfig(c.network);
|
|
421
|
+
if (named.rpcUrl !== c.rpc) {
|
|
422
|
+
throw new Error(`casper on ${c.network}: the signer reads ${site(named.rpcUrl)}, not the configured node ${site(c.rpc)}`);
|
|
423
|
+
}
|
|
424
|
+
const speculative = c.signer.getSpeculativeRpcUrl(c.network);
|
|
425
|
+
if (speculative && speculative !== c.rpc) {
|
|
426
|
+
throw new Error(`casper on ${c.network}: the signer's speculative execution goes to ${site(speculative)}, not the configured node ${site(c.rpc)}`);
|
|
427
|
+
}
|
|
428
|
+
if (`casper:${named.chainName}` !== c.network) {
|
|
429
|
+
throw new Error(`casper on ${c.network}: the signer names the chain ${named.chainName}`);
|
|
430
|
+
}
|
|
431
|
+
return { network: c.network, module: casperModule(c, p, meter), own: [] };
|
|
432
|
+
}
|
|
433
|
+
/** The module's start: one registration of `exact` per configured network, its submissions counted by its fee meter. */
|
|
434
|
+
export const starter = {
|
|
435
|
+
name: "casper",
|
|
436
|
+
async start(config, core) {
|
|
437
|
+
if (config.length === 0)
|
|
438
|
+
return { registrations: [] };
|
|
439
|
+
const p = await published();
|
|
440
|
+
return { registrations: await Promise.all(config.map((c) => casperRegistration(c, p, core.meter(c.network)))) };
|
|
441
|
+
},
|
|
442
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type CcdNetwork, type CcdReader } from "@integraledger/lcp/ccd";
|
|
2
|
+
import type { FacilitatorConcordiumSigner } from "@x402/concordium";
|
|
3
|
+
import { type Module, type ModuleStarter, type Registration } from "../../module.js";
|
|
4
|
+
export interface ConcordiumConfig {
|
|
5
|
+
/** The network, exactly one: the one the signer is connected to. */
|
|
6
|
+
readonly network: CcdNetwork;
|
|
7
|
+
/** The seller's sponsor account and its key, with its node, as `@x402/concordium`'s facilitator class takes them. */
|
|
8
|
+
readonly signer: FacilitatorConcordiumSigner;
|
|
9
|
+
/** lcp's reader over the seller's node for the network (`CcdReader` of `@integraledger/lcp/ccd`). */
|
|
10
|
+
readonly reader: CcdReader;
|
|
11
|
+
}
|
|
12
|
+
/** The module of `x402/exact/ccd` on the configured network. */
|
|
13
|
+
export declare function concordiumModule(c: ConcordiumConfig): Module;
|
|
14
|
+
export declare function concordiumRegistration(c: ConcordiumConfig): Registration;
|
|
15
|
+
/** The module's start: one registration of `exact` per configured network. */
|
|
16
|
+
export declare const starter: ModuleStarter<readonly ConcordiumConfig[]>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Concordium module for `x402/exact/ccd` on each configured network: `@x402/concordium` 2.31.0's facilitator
|
|
3
|
+
* class, registered unchanged, with the network taken from configuration: the class serves the network its signer is
|
|
4
|
+
* connected to. The payer signs a sponsored account transaction; the seller's sponsor co-signs it and pays its energy
|
|
5
|
+
* (`extra.key` `fee-payer`). The sponsor reaches the module as the `FacilitatorConcordiumSigner` the class takes, its
|
|
6
|
+
* account in `signers` and the class's `extra.feePayer`. lcp's checks name the instrument by the digest of what the
|
|
7
|
+
* sender signed, since the pairing's single-use value is not yet shown; lcp's read goes through the reader the
|
|
8
|
+
* configuration gives over the seller's node (gRPC v2), as the class's signer is given over it.
|
|
9
|
+
*/
|
|
10
|
+
import { isRefusal } from "@integraledger/lcp";
|
|
11
|
+
import { exactCcd } from "@integraledger/lcp/ccd";
|
|
12
|
+
import { ExactConcordiumScheme } from "@x402/concordium/exact/facilitator";
|
|
13
|
+
import { outcomeOf } from "../../module.js";
|
|
14
|
+
function reasonOf(r) {
|
|
15
|
+
if (r.code === "x402/not-v2")
|
|
16
|
+
return "invalid_x402_version";
|
|
17
|
+
if (r.code.startsWith("x402/option") || r.code === "ccd/option-malformed")
|
|
18
|
+
return "invalid_payment_requirements";
|
|
19
|
+
return "invalid_payload";
|
|
20
|
+
}
|
|
21
|
+
async function checked(p) {
|
|
22
|
+
const bound = await exactCcd.bound(p.payload);
|
|
23
|
+
if (isRefusal(bound))
|
|
24
|
+
return bound;
|
|
25
|
+
// The requirements arrive as JSON, which lcp's option type names.
|
|
26
|
+
return exactCcd.reference(p.payload, p.requirements);
|
|
27
|
+
}
|
|
28
|
+
/** The module of `x402/exact/ccd` on the configured network. */
|
|
29
|
+
export function concordiumModule(c) {
|
|
30
|
+
const network = c.network;
|
|
31
|
+
if (c.signer.getNetwork() !== network || c.reader.network !== c.network) {
|
|
32
|
+
throw new TypeError(`the Concordium signer and reader must serve ${c.network}`);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
descriptor: { name: "concordium", key: "fee-payer", pairings: [exactCcd.id], acceptsZero: true },
|
|
36
|
+
network,
|
|
37
|
+
facilitator: new ExactConcordiumScheme({ signer: c.signer }),
|
|
38
|
+
record: {
|
|
39
|
+
async instrument(p) {
|
|
40
|
+
const ref = await checked(p);
|
|
41
|
+
if (isRefusal(ref))
|
|
42
|
+
return { refused: reasonOf(ref) };
|
|
43
|
+
// Until a run shows a landed payment refused when sent again, the sender's sequence number is not shown to be
|
|
44
|
+
// single-use (lcp's registry: `nonce`), so each signed payment is its own instrument.
|
|
45
|
+
return {
|
|
46
|
+
pairing: exactCcd.id,
|
|
47
|
+
instrument: { by: "digest", network, digest: ref.signed },
|
|
48
|
+
nonce: exactCcd.data.nonce,
|
|
49
|
+
keep: { until: "settler" },
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
async read(p, at) {
|
|
53
|
+
const ref = await checked(p);
|
|
54
|
+
if (isRefusal(ref))
|
|
55
|
+
return outcomeOf({ state: "unreadable", reason: "unparseable", foreign: [] });
|
|
56
|
+
const search = at.search;
|
|
57
|
+
const named = at.transaction === undefined ? ref : { ...ref, transaction: at.transaction };
|
|
58
|
+
return outcomeOf(await exactCcd.status(named, c.reader, { act: "payment", finality: "finalized", ...(search === undefined ? {} : { search }) }));
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
fees: {
|
|
62
|
+
// The sponsor pays the energy of every transaction it co-signs.
|
|
63
|
+
paysFee: () => true,
|
|
64
|
+
payerBroadcast: () => false,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export function concordiumRegistration(c) {
|
|
69
|
+
return { network: c.network, module: concordiumModule(c), own: [] };
|
|
70
|
+
}
|
|
71
|
+
/** The module's start: one registration of `exact` per configured network. */
|
|
72
|
+
export const starter = {
|
|
73
|
+
name: "concordium",
|
|
74
|
+
async start(config) {
|
|
75
|
+
return { registrations: config.map(concordiumRegistration) };
|
|
76
|
+
},
|
|
77
|
+
};
|