@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,103 @@
|
|
|
1
|
+
const channelKey = (network, channelId) => `channel:${network}:${channelId}`;
|
|
2
|
+
const indexKey = (network) => `channels:${network}`;
|
|
3
|
+
function isStored(v) {
|
|
4
|
+
return typeof v === "object" && v !== null && "record" in v && "revertToken" in v;
|
|
5
|
+
}
|
|
6
|
+
/** Writes `next(current)` under `key` once no other writer moved it in between; `current` is undefined or null when absent. */
|
|
7
|
+
async function update(state, key, next) {
|
|
8
|
+
for (;;) {
|
|
9
|
+
const current = await state.get(key);
|
|
10
|
+
const step = next(current);
|
|
11
|
+
if (!("value" in step))
|
|
12
|
+
return step.result;
|
|
13
|
+
if (await state.swap(key, current, step.value))
|
|
14
|
+
return step.result;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** The channel ids stored on `network`, kept as one list, each added once. */
|
|
18
|
+
async function index(state, network, change) {
|
|
19
|
+
await update(state, indexKey(network), (current) => {
|
|
20
|
+
const ids = Array.isArray(current) ? current : [];
|
|
21
|
+
const next = change(ids);
|
|
22
|
+
return next.length === ids.length && next.every((id, i) => id === ids[i]) ? { result: undefined } : { value: next, result: undefined };
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** Whether a stored channel's non-empty binding differs from a requested non-empty one, as x402's reference store asks. */
|
|
26
|
+
function conflicts(requested, stored) {
|
|
27
|
+
const differs = (a, b) => a !== "" && b !== "" && a !== b;
|
|
28
|
+
return differs(requested.receiverAuthorizer, stored.receiverAuthorizer) || differs(requested.callerIdentity, stored.callerIdentity);
|
|
29
|
+
}
|
|
30
|
+
/** x402's `PaymentChannelStorage` over the module's state, with the semantics of its in-memory reference store. */
|
|
31
|
+
export function channelStorage(state) {
|
|
32
|
+
let tokens = 0;
|
|
33
|
+
const token = () => `${process.pid}.${Date.now()}.${++tokens}`;
|
|
34
|
+
return {
|
|
35
|
+
async recordOpen(record) {
|
|
36
|
+
const key = channelKey(record.network, record.channelId);
|
|
37
|
+
const written = await update(state, key, (current) => {
|
|
38
|
+
if (isStored(current)) {
|
|
39
|
+
if (conflicts(record, current.record))
|
|
40
|
+
return { result: { record: { ...current.record }, revertToken: "" } };
|
|
41
|
+
const moved = {
|
|
42
|
+
...current.record,
|
|
43
|
+
expiresAt: Math.max(current.record.expiresAt, record.expiresAt),
|
|
44
|
+
lastActivityAt: Math.max(current.record.lastActivityAt, record.lastActivityAt),
|
|
45
|
+
};
|
|
46
|
+
return { value: { record: moved, revertToken: token() }, result: { record: { ...moved }, revertToken: "" } };
|
|
47
|
+
}
|
|
48
|
+
const made = token();
|
|
49
|
+
return { value: { record: { ...record }, revertToken: made }, result: { record: { ...record }, revertToken: made } };
|
|
50
|
+
});
|
|
51
|
+
await index(state, record.network, (ids) => (ids.includes(record.channelId) ? ids : [...ids, record.channelId]));
|
|
52
|
+
return written;
|
|
53
|
+
},
|
|
54
|
+
async revertOpen(write) {
|
|
55
|
+
if (write.revertToken === "")
|
|
56
|
+
return;
|
|
57
|
+
const key = channelKey(write.record.network, write.record.channelId);
|
|
58
|
+
await update(state, key, (current) => isStored(current) && current.revertToken === write.revertToken ? { value: null, result: undefined } : { result: undefined });
|
|
59
|
+
},
|
|
60
|
+
async recordActivity(...records) {
|
|
61
|
+
for (const record of records) {
|
|
62
|
+
await update(state, channelKey(record.network, record.channelId), (current) => isStored(current)
|
|
63
|
+
? { value: { ...current, record: { ...current.record, lastActivityAt: Math.max(current.record.lastActivityAt, record.lastActivityAt) } }, result: undefined }
|
|
64
|
+
: { value: { record: { ...record }, revertToken: "" }, result: undefined });
|
|
65
|
+
await index(state, record.network, (ids) => (ids.includes(record.channelId) ? ids : [...ids, record.channelId]));
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
async get(network, channelId) {
|
|
69
|
+
const current = await state.get(channelKey(network, channelId));
|
|
70
|
+
return isStored(current) ? { ...current.record } : undefined;
|
|
71
|
+
},
|
|
72
|
+
async list(network) {
|
|
73
|
+
const ids = await state.get(indexKey(network));
|
|
74
|
+
const out = [];
|
|
75
|
+
for (const id of Array.isArray(ids) ? ids : []) {
|
|
76
|
+
const current = await state.get(channelKey(network, id));
|
|
77
|
+
if (isStored(current))
|
|
78
|
+
out.push({ ...current.record });
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
},
|
|
82
|
+
async delete(network, channelId) {
|
|
83
|
+
await update(state, channelKey(network, channelId), (current) => (current === undefined || current === null ? { result: undefined } : { value: null, result: undefined }));
|
|
84
|
+
await index(state, network, (ids) => ids.filter((id) => id !== channelId));
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/** The batch-settlement class's pending signatures over the module's state, its reserve and release each one swap. */
|
|
89
|
+
export function batchPendingStore(state) {
|
|
90
|
+
const named = (key) => `batch-pending:${key}`;
|
|
91
|
+
return {
|
|
92
|
+
async get(key) {
|
|
93
|
+
const v = await state.get(named(key));
|
|
94
|
+
return typeof v === "string" ? v : undefined;
|
|
95
|
+
},
|
|
96
|
+
set: (key, value) => state.set(named(key), value),
|
|
97
|
+
async delete(key) {
|
|
98
|
+
await update(state, named(key), (current) => (typeof current === "string" ? { value: null, result: undefined } : { result: undefined }));
|
|
99
|
+
},
|
|
100
|
+
setIfAbsent: (key, value) => update(state, named(key), (current) => (typeof current === "string" ? { result: false } : { value, result: true })),
|
|
101
|
+
deleteIfEquals: (key, value) => update(state, named(key), (current) => (current === value ? { value: null, result: true } : { result: false })),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type StarknetNetwork } from "@integraledger/lcp/starknet";
|
|
2
|
+
import { type SignerInterface } from "starknet";
|
|
3
|
+
import { type Core, type Module, type ModuleStarter } from "../../module.js";
|
|
4
|
+
/** The configuration's member `starknet`: one entry per network the settler serves. */
|
|
5
|
+
export interface StarknetConfig {
|
|
6
|
+
readonly networks: readonly StarknetNetworkConfig[];
|
|
7
|
+
}
|
|
8
|
+
/** One Starknet network. */
|
|
9
|
+
export interface StarknetNetworkConfig {
|
|
10
|
+
network: StarknetNetwork;
|
|
11
|
+
/** A JSON-RPC node, specification 0.9 or later, that serves `starknet_traceTransaction` and `starknet_simulateTransactions`. */
|
|
12
|
+
rpc: string;
|
|
13
|
+
/**
|
|
14
|
+
* The executor: the account the payer's outside execution names as its `Caller`, stated as `extra.feePayer`, which
|
|
15
|
+
* sends and pays for the transaction that executes it; `signer` signs that transaction (a Cairo 1 account).
|
|
16
|
+
*/
|
|
17
|
+
executor: {
|
|
18
|
+
address: string;
|
|
19
|
+
signer: SignerInterface;
|
|
20
|
+
};
|
|
21
|
+
/** The most one settlement's resource bounds may pay, in the fee token's smallest unit (fri); none where absent. */
|
|
22
|
+
maxFee?: bigint;
|
|
23
|
+
/** The scheme's `skewMargin`, seconds; default 60. */
|
|
24
|
+
skewMarginSeconds?: number;
|
|
25
|
+
/** The scheme's `minSettleMargin`, seconds; default 30. */
|
|
26
|
+
minSettleMarginSeconds?: number;
|
|
27
|
+
}
|
|
28
|
+
/** One module for the configured network, for the scheme `exact`. */
|
|
29
|
+
/** Starts one module per configured network, each its own registration of `exact`. */
|
|
30
|
+
export declare const starter: ModuleStarter<StarknetConfig>;
|
|
31
|
+
/**
|
|
32
|
+
* The module for one network. The settler's wait for the chain is the core's; the fee meter is the network's, which the
|
|
33
|
+
* module tells of each transaction's bound before it sends it and its fee once included.
|
|
34
|
+
*/
|
|
35
|
+
export declare function starknetModule(c: StarknetNetworkConfig, core: Core): Module;
|