@integraledger/profile-facilitator 0.4.0 → 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,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The settler's modules, one line each in the order of their names, a blank line between two: the module's name, which
|
|
3
|
+
* is also the member of the configuration that starts it, and the import of its folder, which exports the module's
|
|
4
|
+
* `starter`. A module is imported only where the configuration names it. A line stays commented until its module is
|
|
5
|
+
* built.
|
|
6
|
+
*/
|
|
7
|
+
import type { ModuleName, ModuleStarter } from "../module.js";
|
|
8
|
+
/** One module of the list: its name, and the import of its starter. */
|
|
9
|
+
export interface Listed<N extends ModuleName = ModuleName, C = never> {
|
|
10
|
+
readonly name: N;
|
|
11
|
+
load(): Promise<ModuleStarter<C>>;
|
|
12
|
+
}
|
|
13
|
+
/** A module's line: its name, and the import of its folder, whose `starter` is the module's. */
|
|
14
|
+
export declare function listed<N extends ModuleName, C>(name: N, load: () => Promise<{
|
|
15
|
+
readonly starter: ModuleStarter<C>;
|
|
16
|
+
}>): Listed<N, C>;
|
|
17
|
+
export declare const MODULES: readonly [Listed<"algorand", readonly import("./algorand/index.js").AlgorandConfig[]>, Listed<"aptos", readonly import("./aptos/index.js").AptosConfig[]>, Listed<"cardano", readonly import("./cardano/index.js").CardanoConfig[]>, Listed<"casper", readonly import("./casper/index.js").CasperConfig[]>, Listed<"concordium", readonly import("./concordium/index.js").ConcordiumConfig[]>, Listed<"erc7710", readonly import("./erc7710/index.js").Erc7710Config[]>, Listed<"evm", readonly import("./evm/index.js").EvmConfig[]>, Listed<"hedera", readonly import("./hedera/index.js").HederaConfig[]>, Listed<"lnbtc", import("./lnbtc/index.js").LnbtcConfig>, Listed<"near", readonly import("./near/index.js").NearConfig[]>, Listed<"polkadot", readonly import("./polkadot/rail.js").PolkadotNode[]>, Listed<"solana", readonly import("./solana/index.js").SolanaConfig[]>, Listed<"starknet", import("./starknet/index.js").StarknetConfig>, Listed<"stellar", import("./stellar/index.js").StellarConfig>, Listed<"sui", import("./sui/index.js").SuiConfig>, Listed<"ton", readonly import("./ton/index.js").TonConfig[]>, Listed<"tron", readonly import("./tron/rail.js").TronNode[]>, Listed<"xrpl", readonly import("./xrpl/index.js").XrplConfig[]>];
|
|
18
|
+
/** The configuration a listed module's starter takes. */
|
|
19
|
+
export type ConfigOf<L> = L extends Listed<ModuleName, infer C> ? C : never;
|
|
20
|
+
/** The configuration's members that start modules: one per listed module, named for it. */
|
|
21
|
+
export type ModulesConfig<List extends readonly Listed<ModuleName, never>[] = typeof MODULES> = {
|
|
22
|
+
readonly [L in List[number] as L["name"]]?: ConfigOf<L>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** A module's line: its name, and the import of its folder, whose `starter` is the module's. */
|
|
2
|
+
export function listed(name, load) {
|
|
3
|
+
return { name, load: async () => (await load()).starter };
|
|
4
|
+
}
|
|
5
|
+
export const MODULES = [
|
|
6
|
+
listed("algorand", () => import("./algorand/index.js")),
|
|
7
|
+
listed("aptos", () => import("./aptos/index.js")),
|
|
8
|
+
listed("cardano", () => import("./cardano/index.js")),
|
|
9
|
+
listed("casper", () => import("./casper/index.js")),
|
|
10
|
+
listed("concordium", () => import("./concordium/index.js")),
|
|
11
|
+
listed("erc7710", () => import("./erc7710/index.js")),
|
|
12
|
+
listed("evm", () => import("./evm/index.js")),
|
|
13
|
+
listed("hedera", () => import("./hedera/index.js")),
|
|
14
|
+
listed("lnbtc", () => import("./lnbtc/index.js")),
|
|
15
|
+
listed("near", () => import("./near/index.js")),
|
|
16
|
+
listed("polkadot", () => import("./polkadot/index.js")),
|
|
17
|
+
listed("solana", () => import("./solana/index.js")),
|
|
18
|
+
listed("starknet", () => import("./starknet/index.js")),
|
|
19
|
+
listed("stellar", () => import("./stellar/index.js")),
|
|
20
|
+
listed("sui", () => import("./sui/index.js")),
|
|
21
|
+
listed("ton", () => import("./ton/index.js")),
|
|
22
|
+
listed("tron", () => import("./tron/index.js")),
|
|
23
|
+
listed("xrpl", () => import("./xrpl/index.js")),
|
|
24
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type LnNetwork } from "@integraledger/lcp/lightning";
|
|
2
|
+
import type { ModuleStarter } from "../../module.js";
|
|
3
|
+
/** One network the module settles on. */
|
|
4
|
+
export interface LnbtcNetworkConfig {
|
|
5
|
+
/** x402's `lnbtc` id of Bitcoin mainnet or testnet3. */
|
|
6
|
+
readonly network: LnNetwork;
|
|
7
|
+
}
|
|
8
|
+
/** The module's member of the configuration: one entry per network. */
|
|
9
|
+
export type LnbtcConfig = readonly LnbtcNetworkConfig[];
|
|
10
|
+
export declare const starter: ModuleStarter<LnbtcConfig>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Lightning module: x402's `exact` scheme on the `lnbtc` networks, for lcp's pairing `x402/exact/lnbtc/payment-hash`,
|
|
3
|
+
* written to x402's scheme text (`specs/schemes/exact/scheme_exact_lnbtc.md`) and lcp's profile `x402-exact-lnbtc.md`.
|
|
4
|
+
* The buyer's node paid the invoice before the preimage reached the buyer, so settling moves nothing. The module makes
|
|
5
|
+
* the scheme's whole validation through lcp's `validateExactLnbtc`, the export a resource server also runs before it
|
|
6
|
+
* settles: the invoice's signature, its signer against `payTo`, its `h` against the request hash, its `p` against
|
|
7
|
+
* `extra.paymentHash`, the preimage against `p`, and the paid-but-expired window. It answers the invoice's payment hash
|
|
8
|
+
* as the transaction and names no payer, since Lightning shows none.
|
|
9
|
+
*
|
|
10
|
+
* The settler's record holds the network and the payment hash, the scheme's consumption key, once: a second settle of
|
|
11
|
+
* one hash is answered from the record, never with a second success. The module holds no key, submits nothing and pays
|
|
12
|
+
* no fee. No public ledger shows a Lightning payment and lcp gives the pairing no read, so the module reads nothing: a
|
|
13
|
+
* success is final at once, and the record is what remembers it.
|
|
14
|
+
*
|
|
15
|
+
* x402's scheme forbids `/verify` for this flow; the module's `verify` is the scheme's validation, which `/settle` makes
|
|
16
|
+
* before the record's claim.
|
|
17
|
+
*/
|
|
18
|
+
import { isRefusal } from "@integraledger/lcp";
|
|
19
|
+
import { decodeBolt11, exactLnbtcPaymentHash, validateExactLnbtc, } from "@integraledger/lcp/lightning";
|
|
20
|
+
import { isObject } from "../../answers.js";
|
|
21
|
+
/** The networks lcp's `lnbtc` codec admits, held to its type so that one it adds is a compile error here. */
|
|
22
|
+
const NETWORKS = {
|
|
23
|
+
"lnbtc:000000000019d6689c085ae165831e93": true,
|
|
24
|
+
"lnbtc:000000000933ea01ad0ee984209779ba": true,
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* x402's clock-skew allowance, in seconds, which `validateExactLnbtc` applies by default: a proof passes until the
|
|
28
|
+
* invoice's end plus this (the scheme's Paid-but-expired Policy).
|
|
29
|
+
*/
|
|
30
|
+
const SKEW_SECONDS = 60;
|
|
31
|
+
const HASH = /^[0-9a-f]{64}$/;
|
|
32
|
+
/**
|
|
33
|
+
* lcp gives this pairing no read: no public ledger shows the payment and no node is asked. The read finds nothing, so a
|
|
34
|
+
* claim the record holds stays live and is never sent again.
|
|
35
|
+
*/
|
|
36
|
+
const NOTHING_READ = { outcome: "live", answer: { state: "pending", reason: "not-found", foreign: [] } };
|
|
37
|
+
/** The scheme's validation at the settler's clock, in Unix seconds. */
|
|
38
|
+
function validated(payload, requirements) {
|
|
39
|
+
const v = validateExactLnbtc(payload, requirements, { now: Math.floor(Date.now() / 1000) });
|
|
40
|
+
// Refused only for a time that is not a non-negative safe integer, which the clock never gives.
|
|
41
|
+
if (isRefusal(v))
|
|
42
|
+
throw new TypeError(`the scheme's validation refused its time: ${v.code}`);
|
|
43
|
+
return v;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The latest time the scheme accepts the accepted invoice's proof, its creation time plus its expiry plus the skew, in
|
|
47
|
+
* Unix milliseconds. An invoice that does not decode is refused by the validation before any claim, so no row is kept
|
|
48
|
+
* for it.
|
|
49
|
+
*/
|
|
50
|
+
async function keepOf(payload) {
|
|
51
|
+
const invoice = isObject(payload.accepted?.extra) ? payload.accepted.extra["invoice"] : undefined;
|
|
52
|
+
const b = typeof invoice === "string" ? await decodeBolt11(invoice) : undefined;
|
|
53
|
+
if (b === undefined || isRefusal(b))
|
|
54
|
+
return { until: "settler" };
|
|
55
|
+
return { until: "lapse", at: (b.timestamp + b.expiry + SKEW_SECONDS) * 1000 };
|
|
56
|
+
}
|
|
57
|
+
const facilitator = {
|
|
58
|
+
scheme: "exact",
|
|
59
|
+
caipFamily: "lnbtc:*",
|
|
60
|
+
getExtra: () => undefined,
|
|
61
|
+
getSigners: () => [],
|
|
62
|
+
async verify(payload, requirements) {
|
|
63
|
+
const v = validated(payload, requirements);
|
|
64
|
+
return v.valid ? { isValid: true } : { isValid: false, invalidReason: v.reason };
|
|
65
|
+
},
|
|
66
|
+
async settle(payload, requirements) {
|
|
67
|
+
const v = validated(payload, requirements);
|
|
68
|
+
return v.valid
|
|
69
|
+
? { success: true, transaction: v.paymentHash, network: v.network }
|
|
70
|
+
: { success: false, errorReason: v.reason, transaction: "", network: requirements.network };
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
const record = {
|
|
74
|
+
/**
|
|
75
|
+
* The payment hash the requirements commit, on their network: x402's consumption key. Requirements without one are
|
|
76
|
+
* not this pairing's, whose option always carries it.
|
|
77
|
+
*/
|
|
78
|
+
async instrument({ payload, requirements }) {
|
|
79
|
+
const hash = isObject(requirements.extra) ? requirements.extra["paymentHash"] : undefined;
|
|
80
|
+
if (typeof hash !== "string" || !HASH.test(hash))
|
|
81
|
+
return { refused: "invalid_payment_requirements" };
|
|
82
|
+
return {
|
|
83
|
+
pairing: exactLnbtcPaymentHash.id,
|
|
84
|
+
instrument: { by: "transaction", network: requirements.network, transaction: hash },
|
|
85
|
+
nonce: exactLnbtcPaymentHash.data.nonce,
|
|
86
|
+
keep: await keepOf(payload),
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
read: async () => NOTHING_READ,
|
|
90
|
+
};
|
|
91
|
+
function moduleOn(network) {
|
|
92
|
+
return {
|
|
93
|
+
descriptor: { name: "lnbtc", key: "none", pairings: [exactLnbtcPaymentHash.id], acceptsZero: false, verifyForbidden: true },
|
|
94
|
+
network,
|
|
95
|
+
facilitator,
|
|
96
|
+
record,
|
|
97
|
+
// The payer's node paid the invoice; the module sends nothing.
|
|
98
|
+
fees: { paysFee: () => false, payerBroadcast: () => true },
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export const starter = {
|
|
102
|
+
name: "lnbtc",
|
|
103
|
+
async start(config) {
|
|
104
|
+
const registrations = config.map(({ network }) => {
|
|
105
|
+
if (!Object.hasOwn(NETWORKS, network))
|
|
106
|
+
throw new TypeError(`lnbtc: ${String(network)} is not an lnbtc network`);
|
|
107
|
+
return { network, module: moduleOn(network), own: [] };
|
|
108
|
+
});
|
|
109
|
+
return { registrations };
|
|
110
|
+
},
|
|
111
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type NearNetwork, type NearReader } from "@integraledger/lcp/near";
|
|
2
|
+
import type { FacilitatorNearSigner } from "@x402/near";
|
|
3
|
+
import { type Module, type ModuleStarter, type Registration } from "../../module.js";
|
|
4
|
+
export interface NearConfig {
|
|
5
|
+
/** The network, exactly one. */
|
|
6
|
+
readonly network: NearNetwork;
|
|
7
|
+
/** The seller's relayer account and key, with its RPC node, as `@x402/near`'s facilitator class takes them. */
|
|
8
|
+
readonly signer: FacilitatorNearSigner;
|
|
9
|
+
/** The seller's RPC node, which lcp's read and the fee count use. */
|
|
10
|
+
readonly rpc: string;
|
|
11
|
+
}
|
|
12
|
+
/** lcp's reader over the RPC node at `url`, its calls ending by `deadline`. */
|
|
13
|
+
export declare function nearReader(network: NearNetwork, url: string, deadline: number): NearReader;
|
|
14
|
+
/** The module of `x402/exact/near` on the configured network. */
|
|
15
|
+
export declare function nearModule(c: NearConfig): Module;
|
|
16
|
+
export declare function nearRegistration(c: NearConfig): Registration;
|
|
17
|
+
/** The module's start: one registration of `exact` per configured network. */
|
|
18
|
+
export declare const starter: ModuleStarter<readonly NearConfig[]>;
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The NEAR module for `x402/exact/near` on each configured network: `@x402/near` 2.31.0's facilitator class,
|
|
3
|
+
* registered unchanged. The payer signs a NEP-366 delegate action; the seller's relayer account wraps it in a
|
|
4
|
+
* transaction of its own, which it signs and whose gas and one-yoctoNEAR deposit it pays (`extra.key` `relayer`). The
|
|
5
|
+
* relayer reaches the module as the `FacilitatorNearSigner` the class takes, and its account is in `signers`. lcp's
|
|
6
|
+
* checks name the instrument, the payer's access key and its nonce; lcp's read goes through the seller's RPC node.
|
|
7
|
+
*/
|
|
8
|
+
import { isRefusal } from "@integraledger/lcp";
|
|
9
|
+
import { exactNear, } from "@integraledger/lcp/near";
|
|
10
|
+
import { ExactNearScheme } from "@x402/near/exact/facilitator";
|
|
11
|
+
import { isObject } from "../../answers.js";
|
|
12
|
+
import { NodeError, postJson } from "../../http.js";
|
|
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 === "near/option-malformed")
|
|
18
|
+
return "invalid_payment_requirements";
|
|
19
|
+
return "invalid_payload";
|
|
20
|
+
}
|
|
21
|
+
async function checked(p) {
|
|
22
|
+
const bound = await exactNear.bound(p.payload);
|
|
23
|
+
if (isRefusal(bound))
|
|
24
|
+
return bound;
|
|
25
|
+
// The requirements arrive as JSON, which lcp's option type names.
|
|
26
|
+
return exactNear.reference(p.payload, p.requirements);
|
|
27
|
+
}
|
|
28
|
+
/** The error's cause name, where the RPC answered one: `UNKNOWN_ACCESS_KEY`, `UNKNOWN_BLOCK`, `GARBAGE_COLLECTED_BLOCK`. */
|
|
29
|
+
function causeOf(error) {
|
|
30
|
+
const cause = isObject(error) ? error["cause"] : undefined;
|
|
31
|
+
return isObject(cause) && typeof cause["name"] === "string" ? cause["name"] : undefined;
|
|
32
|
+
}
|
|
33
|
+
function height(v) {
|
|
34
|
+
if (typeof v === "number" && Number.isSafeInteger(v) && v >= 0)
|
|
35
|
+
return BigInt(v);
|
|
36
|
+
throw new NodeError("malformed", true, "a block height");
|
|
37
|
+
}
|
|
38
|
+
/** lcp's reader over the RPC node at `url`, its calls ending by `deadline`. */
|
|
39
|
+
export function nearReader(network, url, deadline) {
|
|
40
|
+
let id = 0;
|
|
41
|
+
async function rpc(method, params) {
|
|
42
|
+
const a = await postJson(url, { jsonrpc: "2.0", id: ++id, method, params }, deadline - performance.now());
|
|
43
|
+
if (!isObject(a))
|
|
44
|
+
throw new NodeError("malformed", true, method);
|
|
45
|
+
// `query` answers some errors inside its result, as `error` beside the block it read.
|
|
46
|
+
const inner = isObject(a["result"]) && typeof a["result"]["error"] === "string" ? { name: a["result"]["error"] } : undefined;
|
|
47
|
+
if (a["error"] !== undefined || inner !== undefined)
|
|
48
|
+
return { error: a["error"] ?? { cause: { name: /does not exist/.test(inner.name) ? "UNKNOWN_ACCESS_KEY" : inner.name } } };
|
|
49
|
+
return { result: a["result"] };
|
|
50
|
+
}
|
|
51
|
+
async function blockHeight(hash) {
|
|
52
|
+
const a = await rpc("block", { block_id: hash });
|
|
53
|
+
const header = isObject(a.result) ? a.result["header"] : undefined;
|
|
54
|
+
return isObject(header) ? height(header["height"]) : undefined;
|
|
55
|
+
}
|
|
56
|
+
/** One block's changes of `type` for the account, or `none` where no block is at the height, `missing` where the node pruned it. */
|
|
57
|
+
async function changesAt(h, params) {
|
|
58
|
+
const a = await rpc("EXPERIMENTAL_changes", { block_id: Number(h), ...params });
|
|
59
|
+
if (a.error !== undefined) {
|
|
60
|
+
const cause = causeOf(a.error);
|
|
61
|
+
if (cause === "GARBAGE_COLLECTED_BLOCK")
|
|
62
|
+
return "missing";
|
|
63
|
+
if (cause === "UNKNOWN_BLOCK")
|
|
64
|
+
return "none";
|
|
65
|
+
throw new NodeError("http-status", true, `changes: ${cause ?? "error"}`);
|
|
66
|
+
}
|
|
67
|
+
const changes = isObject(a.result) && Array.isArray(a.result["changes"]) ? a.result["changes"] : [];
|
|
68
|
+
return changes.filter(isObject).map((c) => {
|
|
69
|
+
const change = isObject(c["change"]) ? c["change"] : {};
|
|
70
|
+
const cause = isObject(c["cause"]) ? c["cause"] : {};
|
|
71
|
+
const key = change["access_key"];
|
|
72
|
+
const nonce = c["type"] === "access_key_deletion" ? null : isObject(key) ? key["nonce"] : undefined;
|
|
73
|
+
if (typeof change["public_key"] !== "string" || (nonce !== null && typeof nonce !== "number"))
|
|
74
|
+
throw new NodeError("malformed", true, "a key change");
|
|
75
|
+
const tx = cause["type"] === "transaction_processing" && typeof cause["tx_hash"] === "string" ? cause["tx_hash"] : undefined;
|
|
76
|
+
return {
|
|
77
|
+
height: h,
|
|
78
|
+
publicKey: change["public_key"],
|
|
79
|
+
nonce: nonce === null ? null : BigInt(nonce),
|
|
80
|
+
...(tx === undefined || typeof change["account_id"] !== "string" ? {} : { transaction: { hash: tx, signer: change["account_id"] } }),
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async function finalHeight() {
|
|
85
|
+
const a = await rpc("block", { finality: "final" });
|
|
86
|
+
const header = isObject(a.result) ? a.result["header"] : undefined;
|
|
87
|
+
if (!isObject(header))
|
|
88
|
+
throw new NodeError("malformed", true, "the final block");
|
|
89
|
+
return height(header["height"]);
|
|
90
|
+
}
|
|
91
|
+
/** Block by block from `from` to `to`, as far as the deadline lets the read go. */
|
|
92
|
+
async function range(from, to, params) {
|
|
93
|
+
const changes = [];
|
|
94
|
+
let through = from - 1n;
|
|
95
|
+
for (let h = from; h <= to; h++) {
|
|
96
|
+
if (deadline - performance.now() <= 0)
|
|
97
|
+
break;
|
|
98
|
+
const at = await changesAt(h, params);
|
|
99
|
+
if (at === "missing" || (at === "none" && h === from)) {
|
|
100
|
+
if (h === from)
|
|
101
|
+
return { history: "missing" };
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (at !== "none")
|
|
105
|
+
changes.push(...at);
|
|
106
|
+
through = h;
|
|
107
|
+
}
|
|
108
|
+
return { changes, through };
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
network,
|
|
112
|
+
async txStatus(txHash, sender) {
|
|
113
|
+
const a = await rpc("EXPERIMENTAL_tx_status", { tx_hash: txHash, ...(sender === undefined ? {} : { sender_account_id: sender }), wait_until: "NONE" });
|
|
114
|
+
if (a.error !== undefined) {
|
|
115
|
+
if (causeOf(a.error) === "UNKNOWN_TRANSACTION")
|
|
116
|
+
return null;
|
|
117
|
+
throw new NodeError("http-status", true, `tx status: ${causeOf(a.error) ?? "error"}`);
|
|
118
|
+
}
|
|
119
|
+
const r = a.result;
|
|
120
|
+
if (!isObject(r))
|
|
121
|
+
throw new NodeError("malformed", true, "a transaction status");
|
|
122
|
+
const tx = isObject(r["transaction"]) ? r["transaction"] : {};
|
|
123
|
+
const action = Array.isArray(tx["actions"]) ? tx["actions"][0] : undefined;
|
|
124
|
+
const d = isObject(action) && isObject(action["Delegate"]) && isObject(action["Delegate"]["delegate_action"]) ? action["Delegate"]["delegate_action"] : undefined;
|
|
125
|
+
const receipts = [];
|
|
126
|
+
for (const o of Array.isArray(r["receipts_outcome"]) ? r["receipts_outcome"].filter(isObject) : []) {
|
|
127
|
+
const outcome = isObject(o["outcome"]) ? o["outcome"] : {};
|
|
128
|
+
const status = isObject(outcome["status"]) ? outcome["status"] : {};
|
|
129
|
+
const state = "Failure" in status ? "failure" : "SuccessValue" in status || "SuccessReceiptId" in status ? "success" : "pending";
|
|
130
|
+
const at = state !== "pending" && typeof o["block_hash"] === "string" ? await blockHeight(o["block_hash"]) : undefined;
|
|
131
|
+
receipts.push({ id: String(o["id"]), executor: String(outcome["executor_id"]), outcome: state, ...(at === undefined ? {} : { height: at }) });
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
status: typeof r["final_execution_status"] === "string" ? r["final_execution_status"] : "",
|
|
135
|
+
delegate: d === undefined
|
|
136
|
+
? null
|
|
137
|
+
: {
|
|
138
|
+
senderId: String(d["sender_id"]),
|
|
139
|
+
publicKey: String(d["public_key"]),
|
|
140
|
+
nonce: BigInt(d["nonce"]),
|
|
141
|
+
maxBlockHeight: BigInt(d["max_block_height"]),
|
|
142
|
+
receiverId: String(d["receiver_id"]),
|
|
143
|
+
actions: (Array.isArray(d["actions"]) ? d["actions"] : []).map((x) => {
|
|
144
|
+
const f = isObject(x) && isObject(x["FunctionCall"]) ? x["FunctionCall"] : undefined;
|
|
145
|
+
return f === undefined
|
|
146
|
+
? null
|
|
147
|
+
: { methodName: String(f["method_name"]), argsBase64: String(f["args"]), gas: BigInt(f["gas"]), deposit: BigInt(String(f["deposit"])) };
|
|
148
|
+
}),
|
|
149
|
+
},
|
|
150
|
+
receipts,
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
finalHeight,
|
|
154
|
+
async accessKeyNonce(account, publicKey, finality) {
|
|
155
|
+
const a = await rpc("query", { request_type: "view_access_key", finality: finality === "final" ? "final" : "optimistic", account_id: account, public_key: publicKey });
|
|
156
|
+
if (a.error !== undefined) {
|
|
157
|
+
if (causeOf(a.error) !== "UNKNOWN_ACCESS_KEY")
|
|
158
|
+
throw new NodeError("http-status", true, `view_access_key: ${causeOf(a.error) ?? "error"}`);
|
|
159
|
+
const at = isObject(a.error) && isObject(a.error["cause"]) && isObject(a.error["cause"]["info"]) ? a.error["cause"]["info"]["block_height"] : undefined;
|
|
160
|
+
return { nonce: null, blockHeight: at === undefined ? await finalHeight() : height(at) };
|
|
161
|
+
}
|
|
162
|
+
const r = a.result;
|
|
163
|
+
if (!isObject(r) || typeof r["nonce"] !== "number")
|
|
164
|
+
throw new NodeError("malformed", true, "an access key");
|
|
165
|
+
return { nonce: BigInt(r["nonce"]), blockHeight: height(r["block_height"]) };
|
|
166
|
+
},
|
|
167
|
+
async accessKeyChanges(account, publicKey, from, to) {
|
|
168
|
+
return range(from, to, { changes_type: "single_access_key_changes", keys: [{ account_id: account, public_key: publicKey }] });
|
|
169
|
+
},
|
|
170
|
+
async accountKeyChanges(account, from, to) {
|
|
171
|
+
return range(from, to, { changes_type: "all_access_key_changes", account_ids: [account] });
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/** The module of `x402/exact/near` on the configured network. */
|
|
176
|
+
export function nearModule(c) {
|
|
177
|
+
const network = c.network;
|
|
178
|
+
return {
|
|
179
|
+
// The standard token refuses a zero ft_transfer, so the kind does not take zero.
|
|
180
|
+
descriptor: { name: "near", key: "relayer", pairings: [exactNear.id], acceptsZero: false },
|
|
181
|
+
network,
|
|
182
|
+
facilitator: new ExactNearScheme(c.signer),
|
|
183
|
+
record: {
|
|
184
|
+
async instrument(p) {
|
|
185
|
+
const ref = await checked(p);
|
|
186
|
+
if (isRefusal(ref))
|
|
187
|
+
return { refused: reasonOf(ref) };
|
|
188
|
+
return {
|
|
189
|
+
pairing: exactNear.id,
|
|
190
|
+
// The access key's nonce is single-use for that key of the sender's account.
|
|
191
|
+
instrument: { by: "single-use", network, signer: ref.payer, scope: ref.publicKey, value: ref.nonce },
|
|
192
|
+
nonce: exactNear.data.nonce,
|
|
193
|
+
// Its life ends at max_block_height, a height, which no clock bounds from above.
|
|
194
|
+
keep: { until: "settler" },
|
|
195
|
+
};
|
|
196
|
+
},
|
|
197
|
+
async position(_p, at) {
|
|
198
|
+
return nearReader(c.network, c.rpc, at.deadline).finalHeight();
|
|
199
|
+
},
|
|
200
|
+
async read(p, at) {
|
|
201
|
+
const ref = await checked(p);
|
|
202
|
+
if (isRefusal(ref))
|
|
203
|
+
return outcomeOf({ state: "unreadable", reason: "unparseable", foreign: [] });
|
|
204
|
+
const search = at.search;
|
|
205
|
+
const after = at.from;
|
|
206
|
+
return outcomeOf(await exactNear.status(at.transaction === undefined ? ref : { ...ref, transaction: at.transaction }, nearReader(c.network, c.rpc, at.deadline), {
|
|
207
|
+
act: "payment",
|
|
208
|
+
finality: "final",
|
|
209
|
+
...(search === undefined ? {} : { search }),
|
|
210
|
+
...(after === undefined ? {} : { after }),
|
|
211
|
+
}));
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
fees: {
|
|
215
|
+
// The relayer pays the gas of every transaction it sends.
|
|
216
|
+
paysFee: () => true,
|
|
217
|
+
payerBroadcast: () => false,
|
|
218
|
+
async charged(_p, sent) {
|
|
219
|
+
// The gas the relayer's transaction burnt, its own and its receipts', as the node's outcome shows it.
|
|
220
|
+
const a = await postJson(c.rpc, { jsonrpc: "2.0", id: 1, method: "EXPERIMENTAL_tx_status", params: { tx_hash: sent.transaction, sender_account_id: c.signer.getRelayerIds()[0], wait_until: "NONE" } }, sent.deadline - performance.now());
|
|
221
|
+
const r = isObject(a) ? a["result"] : undefined;
|
|
222
|
+
const outcomes = isObject(r) ? [r["transaction_outcome"], ...(Array.isArray(r["receipts_outcome"]) ? r["receipts_outcome"] : [])] : [];
|
|
223
|
+
let fee = 0n;
|
|
224
|
+
for (const o of outcomes) {
|
|
225
|
+
const burnt = isObject(o) && isObject(o["outcome"]) ? o["outcome"]["tokens_burnt"] : undefined;
|
|
226
|
+
if (typeof burnt !== "string" || !/^\d+$/.test(burnt))
|
|
227
|
+
throw new NodeError("malformed", true, "tokens_burnt");
|
|
228
|
+
fee += BigInt(burnt);
|
|
229
|
+
}
|
|
230
|
+
if (outcomes.length === 0)
|
|
231
|
+
throw new NodeError("malformed", true, "a transaction status");
|
|
232
|
+
return { fee, included: true };
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
export function nearRegistration(c) {
|
|
238
|
+
return { network: c.network, module: nearModule(c), own: [] };
|
|
239
|
+
}
|
|
240
|
+
/** The module's start: one registration of `exact` per configured network. */
|
|
241
|
+
export const starter = {
|
|
242
|
+
name: "near",
|
|
243
|
+
async start(config) {
|
|
244
|
+
return { registrations: config.map(nearRegistration) };
|
|
245
|
+
},
|
|
246
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type OperatorLog } from "../../answers.js";
|
|
2
|
+
import { type Module, type ModuleStarter } from "../../module.js";
|
|
3
|
+
import { createPolkadot, type PolkadotNode } from "./rail.js";
|
|
4
|
+
export { BLOCK_READS, blockReads, createPolkadot, type PolkadotNode, type PolkadotPosition } from "./rail.js";
|
|
5
|
+
type PolkadotRail = ReturnType<typeof createPolkadot>;
|
|
6
|
+
/** One module per network the rail serves. `log` is the operator log the rail was made with. */
|
|
7
|
+
export declare function polkadotModules(rail: PolkadotRail, log: OperatorLog): Module[];
|
|
8
|
+
/**
|
|
9
|
+
* The Polkadot module, started from the configuration's `polkadot` member: one JSON-RPC node per network, which serves
|
|
10
|
+
* `state_call` and `author_submitExtrinsic`. Its metadata is loaded on the network's first request; `close` ends it.
|
|
11
|
+
*/
|
|
12
|
+
export declare const starter: ModuleStarter<readonly PolkadotNode[]>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Polkadot rail as the settler's modules: one for each configured network, for the scheme `exact` and the pairing
|
|
3
|
+
* `x402/exact/polkadot/lcp-assets-remark`. Its checks, submission, wait and read are the rail's; the payer signs and
|
|
4
|
+
* pays every fee, so the module holds no key. The record of which payments are settled is the settler's, keyed by
|
|
5
|
+
* this module's instrument: the signer and the account nonce it signed, never the extrinsic's hash, which a re-signing
|
|
6
|
+
* at the same nonce changes. The record also holds where lcp's read of the payment searches from, read before the
|
|
7
|
+
* submission: the block the search starts after, and the head at which the chain answered the extrinsic valid, which
|
|
8
|
+
* proves the era's last block, so that a later read, after a restart too, can answer the lapse.
|
|
9
|
+
*/
|
|
10
|
+
import { exactPolkadotRemark, LCP_ASSETS_REMARK, POLKADOT_BOUNDS } from "@integraledger/lcp/polkadot";
|
|
11
|
+
import { isRefusal } from "@integraledger/lcp/core";
|
|
12
|
+
import { failed, invalid, readRequest } from "../../answers.js";
|
|
13
|
+
import { outcomeOf } from "../../module.js";
|
|
14
|
+
import { unexpectedSettle, unexpectedVerify } from "../../unexpected.js";
|
|
15
|
+
import { createPolkadot } from "./rail.js";
|
|
16
|
+
export { BLOCK_READS, blockReads, createPolkadot } from "./rail.js";
|
|
17
|
+
/**
|
|
18
|
+
* The most milliseconds a block of Polkadot Asset Hub takes while the chain produces blocks: 12 s, a relay chain slot
|
|
19
|
+
* of 6 s taken twice, as the settler takes it for the longest an era can keep a payment payable.
|
|
20
|
+
*/
|
|
21
|
+
const SLOW_BLOCK_MS = 12_000;
|
|
22
|
+
/** The x402 facilitator request that carries `payload` and `requirements`, read by the rail's shared shape checks. */
|
|
23
|
+
function requestOf(payload, requirements) {
|
|
24
|
+
return readRequest({ x402Version: 2, paymentPayload: payload, paymentRequirements: requirements });
|
|
25
|
+
}
|
|
26
|
+
function settled(answer) {
|
|
27
|
+
return { ...answer, network: answer.network };
|
|
28
|
+
}
|
|
29
|
+
/** A read position as the record gives it back: each block number a `bigint`. */
|
|
30
|
+
function positionOf(v) {
|
|
31
|
+
if (typeof v !== "object" || v === null)
|
|
32
|
+
return undefined;
|
|
33
|
+
const { after, search } = v;
|
|
34
|
+
if (typeof after !== "bigint" || typeof search !== "object" || search === null)
|
|
35
|
+
return undefined;
|
|
36
|
+
const { next, hits, validated } = search;
|
|
37
|
+
if (typeof next !== "bigint" || !Array.isArray(hits) || !hits.every((h) => typeof h === "string"))
|
|
38
|
+
return undefined;
|
|
39
|
+
if (validated !== undefined && typeof validated !== "bigint")
|
|
40
|
+
return undefined;
|
|
41
|
+
const cursor = { next, hits: hits, ...(validated === undefined ? {} : { validated }) };
|
|
42
|
+
return { after, search: cursor };
|
|
43
|
+
}
|
|
44
|
+
/** One module per network the rail serves. `log` is the operator log the rail was made with. */
|
|
45
|
+
export function polkadotModules(rail, log) {
|
|
46
|
+
/** The signer and the nonce it signed, from the signed bytes by lcp's `reference`; or the refusal. */
|
|
47
|
+
async function keyed(r) {
|
|
48
|
+
const l = await rail.local(r);
|
|
49
|
+
if (typeof l === "string")
|
|
50
|
+
return l;
|
|
51
|
+
const ref = await exactPolkadotRemark.reference(r.paymentPayload, r.paymentRequirements);
|
|
52
|
+
// An immortal era never lapses: the profile's extrinsic is mortal, and the rail submits no other.
|
|
53
|
+
if (isRefusal(ref) || ref.era === "immortal")
|
|
54
|
+
return "invalid_payload";
|
|
55
|
+
return { ...ref, era: ref.era };
|
|
56
|
+
}
|
|
57
|
+
return rail.networks.map((name) => {
|
|
58
|
+
const network = name;
|
|
59
|
+
const facilitator = {
|
|
60
|
+
scheme: "exact",
|
|
61
|
+
caipFamily: "polkadot:*",
|
|
62
|
+
getExtra: () => ({ assetTransferMethod: LCP_ASSETS_REMARK }),
|
|
63
|
+
getSigners: () => [],
|
|
64
|
+
async verify(payload, requirements) {
|
|
65
|
+
const r = requestOf(payload, requirements);
|
|
66
|
+
if (typeof r === "string")
|
|
67
|
+
return invalid(r);
|
|
68
|
+
try {
|
|
69
|
+
return await rail.verify(r);
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
return invalid(unexpectedVerify(log, { event: "verify-error", network: r.paymentRequirements.network }, e));
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
async settle(payload, requirements) {
|
|
76
|
+
const r = requestOf(payload, requirements);
|
|
77
|
+
if (typeof r === "string")
|
|
78
|
+
return settled(failed(r, "", requirements.network));
|
|
79
|
+
try {
|
|
80
|
+
return settled(await rail.settle(r));
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
return settled(unexpectedSettle(log, { event: "settle-error", network: r.paymentRequirements.network }, e));
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
const request = (p) => requestOf(p.payload, p.requirements);
|
|
88
|
+
return {
|
|
89
|
+
descriptor: {
|
|
90
|
+
name: "polkadot",
|
|
91
|
+
key: "none",
|
|
92
|
+
pairings: [exactPolkadotRemark.id],
|
|
93
|
+
// The assets pallet returns early on a transfer of zero and emits no `Transferred` event, so the smallest
|
|
94
|
+
// amount is one base unit (polkadot-sdk `substrate/frame/assets/src/functions.rs`, `do_transfer`).
|
|
95
|
+
acceptsZero: false,
|
|
96
|
+
},
|
|
97
|
+
network,
|
|
98
|
+
facilitator,
|
|
99
|
+
record: {
|
|
100
|
+
async instrument(p) {
|
|
101
|
+
const r = request(p);
|
|
102
|
+
const k = typeof r === "string" ? r : await keyed(r);
|
|
103
|
+
if (typeof k === "string")
|
|
104
|
+
return { refused: k };
|
|
105
|
+
// The extrinsic can land no later than its era's last block, and no later than BlockHashCount + 1 blocks
|
|
106
|
+
// after its era's birth, which is at or below the head the chain validated it at before its submission.
|
|
107
|
+
const blocks = Math.min(k.era.period, POLKADOT_BOUNDS.blockHashCount + 1);
|
|
108
|
+
return {
|
|
109
|
+
pairing: exactPolkadotRemark.id,
|
|
110
|
+
instrument: { by: "single-use", network: k.network, signer: k.signer, value: k.nonce },
|
|
111
|
+
nonce: exactPolkadotRemark.data.nonce,
|
|
112
|
+
keep: { until: "life", ms: blocks * SLOW_BLOCK_MS },
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
async read(p, at) {
|
|
116
|
+
const r = request(p);
|
|
117
|
+
if (typeof r === "string")
|
|
118
|
+
return outcomeOf({ state: "unreadable", reason: "unparseable", foreign: [] });
|
|
119
|
+
return outcomeOf(await rail.status(r, at.deadline, positionOf(at.from), at.search));
|
|
120
|
+
},
|
|
121
|
+
async position(p, at) {
|
|
122
|
+
const r = request(p);
|
|
123
|
+
return typeof r === "string" ? undefined : rail.position(r, at.deadline);
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
fees: {
|
|
127
|
+
paysFee: () => false,
|
|
128
|
+
payerBroadcast: () => false,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function trimmed(url) {
|
|
134
|
+
return url.replace(/\/+$/, "");
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The Polkadot module, started from the configuration's `polkadot` member: one JSON-RPC node per network, which serves
|
|
138
|
+
* `state_call` and `author_submitExtrinsic`. Its metadata is loaded on the network's first request; `close` ends it.
|
|
139
|
+
*/
|
|
140
|
+
export const starter = {
|
|
141
|
+
name: "polkadot",
|
|
142
|
+
async start(nodes, core) {
|
|
143
|
+
const rail = createPolkadot(nodes.map((n) => ({ ...n, rpc: trimmed(n.rpc) })), core.settleWaitMs, core.log);
|
|
144
|
+
return {
|
|
145
|
+
registrations: polkadotModules(rail, core.log).map((module) => ({ network: module.network, module, own: [] })),
|
|
146
|
+
close: () => rail.close(),
|
|
147
|
+
};
|
|
148
|
+
},
|
|
149
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type PolkadotCursor, type PolkadotNetwork, type PolkadotStatus } from "@integraledger/lcp/polkadot";
|
|
2
|
+
import { type FacilitatorRequest, type InvalidReason, type OperatorLog, type SettleAnswer, type VerifyAnswer } from "../../answers.js";
|
|
3
|
+
import { Slots } from "../../http.js";
|
|
4
|
+
/**
|
|
5
|
+
* Where the settler's read of a payment it submitted searches: after `after`, the block before the first that can hold
|
|
6
|
+
* the extrinsic, which lcp's read takes as the position the payment came after; and from `search`, lcp's search
|
|
7
|
+
* position, which holds the head at which the chain answered the extrinsic valid.
|
|
8
|
+
*/
|
|
9
|
+
export interface PolkadotPosition {
|
|
10
|
+
readonly after: bigint;
|
|
11
|
+
readonly search: PolkadotCursor;
|
|
12
|
+
}
|
|
13
|
+
export interface PolkadotNode {
|
|
14
|
+
network: PolkadotNetwork;
|
|
15
|
+
rpc: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* How many `chain_getBlock` reads, each bounded by the runtime's `System.BlockLength`, run at once in this process:
|
|
19
|
+
* for Polkadot Asset Hub's runtime 2005000, at most 4 × 28,504,064 = 114,016,256 bytes of block answers.
|
|
20
|
+
*/
|
|
21
|
+
export declare const BLOCK_READS = 4;
|
|
22
|
+
/** The slots of `BLOCK_READS`, shared by every network and every scan in this process. */
|
|
23
|
+
export declare const blockReads: Slots;
|
|
24
|
+
/** What rule 5 checks from the request alone: the lcp profile, the requirements, and the extrinsic's hash. */
|
|
25
|
+
interface Local {
|
|
26
|
+
node: PolkadotNode;
|
|
27
|
+
extrinsic: string;
|
|
28
|
+
call: string;
|
|
29
|
+
id: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function createPolkadot(nodes: readonly PolkadotNode[], settleWaitMs: number, log: OperatorLog): {
|
|
32
|
+
verify: (r: FacilitatorRequest) => Promise<VerifyAnswer>;
|
|
33
|
+
settle: (r: FacilitatorRequest) => Promise<SettleAnswer>;
|
|
34
|
+
local: (r: FacilitatorRequest) => Promise<Local | InvalidReason>;
|
|
35
|
+
status: (r: FacilitatorRequest, deadline: number, from?: PolkadotPosition, search?: unknown) => Promise<PolkadotStatus>;
|
|
36
|
+
position: (r: FacilitatorRequest, deadline: number) => Promise<PolkadotPosition | undefined>;
|
|
37
|
+
close: () => Promise<void>;
|
|
38
|
+
networks: string[];
|
|
39
|
+
};
|
|
40
|
+
export {};
|