@certen.io/sdk 0.10.0 → 0.12.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/CHANGELOG.md +100 -0
- package/README.md +57 -2
- package/dist/address.d.ts +12 -0
- package/dist/address.d.ts.map +1 -0
- package/dist/address.js +48 -0
- package/dist/address.js.map +1 -0
- package/dist/browser.d.ts +17 -4
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +14 -2
- package/dist/browser.js.map +1 -1
- package/dist/chains.d.ts +20 -0
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +34 -0
- package/dist/chains.js.map +1 -1
- package/dist/client.d.ts +15 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +17 -3
- package/dist/client.js.map +1 -1
- package/dist/doctor.d.ts +10 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +6 -4
- package/dist/doctor.js.map +1 -1
- package/dist/effect.d.ts +99 -0
- package/dist/effect.d.ts.map +1 -0
- package/dist/effect.js +139 -0
- package/dist/effect.js.map +1 -0
- package/dist/error-codes.d.ts.map +1 -1
- package/dist/error-codes.js +11 -0
- package/dist/error-codes.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +3 -0
- package/dist/errors.js.map +1 -1
- package/dist/evm-rpc.d.ts +55 -0
- package/dist/evm-rpc.d.ts.map +1 -0
- package/dist/evm-rpc.js +126 -0
- package/dist/evm-rpc.js.map +1 -0
- package/dist/funding.d.ts +171 -0
- package/dist/funding.d.ts.map +1 -1
- package/dist/funding.js +190 -8
- package/dist/funding.js.map +1 -1
- package/dist/key-page.d.ts +67 -0
- package/dist/key-page.d.ts.map +1 -0
- package/dist/key-page.js +154 -0
- package/dist/key-page.js.map +1 -0
- package/dist/readiness.d.ts +133 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +467 -0
- package/dist/readiness.js.map +1 -0
- package/dist/receipt.d.ts +233 -0
- package/dist/receipt.d.ts.map +1 -0
- package/dist/receipt.js +318 -0
- package/dist/receipt.js.map +1 -0
- package/dist/resources/chains.d.ts +14 -1
- package/dist/resources/chains.d.ts.map +1 -1
- package/dist/resources/chains.js +21 -0
- package/dist/resources/chains.js.map +1 -1
- package/dist/resources/execute.d.ts +62 -1
- package/dist/resources/execute.d.ts.map +1 -1
- package/dist/resources/execute.js +102 -9
- package/dist/resources/execute.js.map +1 -1
- package/dist/resources/identity.d.ts +47 -2
- package/dist/resources/identity.d.ts.map +1 -1
- package/dist/resources/identity.js +63 -1
- package/dist/resources/identity.js.map +1 -1
- package/dist/resources/transaction.d.ts +12 -1
- package/dist/resources/transaction.d.ts.map +1 -1
- package/dist/resources/transaction.js +14 -0
- package/dist/resources/transaction.js.map +1 -1
- package/dist/shared-proof.d.ts.map +1 -1
- package/dist/shared-proof.js +21 -1
- package/dist/shared-proof.js.map +1 -1
- package/dist/types.d.ts +207 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/verify.d.ts +126 -2
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +191 -2
- package/dist/verify.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpB,MAAM,CAAS;IACf,IAAI,CAAS;IACb,SAAS,CAAU;IACnB,OAAO,CAAW;IAClC;;;;;;;OAOG;IACa,IAAI,CAAW;IAE/B,YACE,OAAe,EACf,MAAc,EACd,IAAY,EACZ,OAAkE,EAAE;QAEpE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAA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|
2
|
+
* Ask an EVM node a few questions, as a caller who does not want to take CERTEN's word for what happened on a chain.
|
|
3
|
+
*
|
|
4
|
+
* The receipt's effect check and the proof's execution layer both reduce to "what does MY node say": the recipient's balance before and
|
|
5
|
+
* after, and the block header the bundle's receipts root must match. Both go through here so they are hardened the same way as the
|
|
6
|
+
* Accumulate key page read (`key-page.ts`), and for the same reasons:
|
|
7
|
+
*
|
|
8
|
+
* - The endpoint is the CALLER's. It is http(s) only, it follows no redirect (a node that redirects is not the node that was named), the
|
|
9
|
+
* reply is bounded in size and time, and no CERTEN credential is ever sent to it.
|
|
10
|
+
* - **The URL is a secret.** Hosted node providers put the API key in the path (`.../v2/<key>`). Every message names the HOST and never the
|
|
11
|
+
* URL, so the key cannot end up in a log, a receipt or a pasted error.
|
|
12
|
+
* - **The chain is checked, not assumed.** `eth_chainId` must equal the chain the caller named before anything else is believed. A node for
|
|
13
|
+
* another network answers every question happily, and a balance from the wrong chain is worse than none.
|
|
14
|
+
*
|
|
15
|
+
* Unreadable is an error with a code the caller can branch on, never a zero: the effect check turns it into "unreadable", not "not observed".
|
|
16
|
+
*/
|
|
17
|
+
export interface EvmRpcOptions {
|
|
18
|
+
/** The node's JSON-RPC endpoint. */
|
|
19
|
+
rpc: string;
|
|
20
|
+
/** Injectable for tests; defaults to the platform `fetch`. */
|
|
21
|
+
fetch?: typeof fetch;
|
|
22
|
+
/** Default 10 seconds. */
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Validate an endpoint and name its host.
|
|
27
|
+
*
|
|
28
|
+
* @throws CertenError `EVM_RPC_INVALID` for something that is not an http(s) URL, or that carries a username or password (a credential in the
|
|
29
|
+
* URL would be sent on to whoever answers). A key in the PATH is allowed: it is how hosted nodes are addressed, and it is why only the host is
|
|
30
|
+
* ever reported.
|
|
31
|
+
*/
|
|
32
|
+
export declare function checkEvmRpcEndpoint(rpc: string): {
|
|
33
|
+
url: string;
|
|
34
|
+
host: string;
|
|
35
|
+
};
|
|
36
|
+
/** One JSON-RPC call. The result is whatever the node returned under `result`; an `error` member, a non-200 or a non-JSON reply throws. */
|
|
37
|
+
export declare function evmRpcCall(options: EvmRpcOptions, method: string, params: unknown[]): Promise<unknown>;
|
|
38
|
+
/** The node's chain id (`eth_chainId`). */
|
|
39
|
+
export declare function readEvmChainId(options: EvmRpcOptions): Promise<number>;
|
|
40
|
+
/**
|
|
41
|
+
* Refuse a node that is not on the named chain.
|
|
42
|
+
*
|
|
43
|
+
* @throws CertenError `EVM_RPC_CHAIN_UNKNOWN` (the chain is not in the catalogue, so there is nothing to compare with) or
|
|
44
|
+
* `EVM_RPC_WRONG_CHAIN` (the node says it is another network; `details` has `expected` and `actual`).
|
|
45
|
+
*/
|
|
46
|
+
export declare function assertRpcChain(options: EvmRpcOptions, chain: string | number): Promise<void>;
|
|
47
|
+
/** An address's native balance in base units at a block (`'latest'` or a number). Needs a node that still holds that block's state. */
|
|
48
|
+
export declare function readEvmBalance(options: EvmRpcOptions, address: string, block?: 'latest' | number): Promise<bigint>;
|
|
49
|
+
/** The header of a block: number, hash and receipts root, as the node reports them. Undefined when the node has no such block. */
|
|
50
|
+
export declare function readEvmBlockHeader(options: EvmRpcOptions, block: number): Promise<{
|
|
51
|
+
number: string;
|
|
52
|
+
hash?: string;
|
|
53
|
+
receiptsRoot?: string;
|
|
54
|
+
} | undefined>;
|
|
55
|
+
//# sourceMappingURL=evm-rpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm-rpc.d.ts","sourceRoot":"","sources":["../src/evm-rpc.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,aAAa;IAC5B,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,8DAA8D;IAC9D,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAUD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAc9E;AAED,2IAA2I;AAC3I,wBAAsB,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CA2C5G;AASD,2CAA2C;AAC3C,wBAAsB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAI5E;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYlG;AAED,uIAAuI;AACvI,wBAAsB,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,QAAQ,GAAG,MAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAKlI;AAED,kIAAkI;AAClI,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC,CAK/E"}
|
package/dist/evm-rpc.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { CertenError } from './errors.js';
|
|
2
|
+
import { chainInfo, chainSlug } from './chains.js';
|
|
3
|
+
const DEFAULT_TIMEOUT_MS = 10_000;
|
|
4
|
+
/** Every answer this module asks for is a few hundred bytes. Anything past this is not one, and is not read to the end. */
|
|
5
|
+
const MAX_RESPONSE_CHARS = 200_000;
|
|
6
|
+
function fail(message, code, details) {
|
|
7
|
+
throw new CertenError(message, 0, code, details ? { details } : undefined);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Validate an endpoint and name its host.
|
|
11
|
+
*
|
|
12
|
+
* @throws CertenError `EVM_RPC_INVALID` for something that is not an http(s) URL, or that carries a username or password (a credential in the
|
|
13
|
+
* URL would be sent on to whoever answers). A key in the PATH is allowed: it is how hosted nodes are addressed, and it is why only the host is
|
|
14
|
+
* ever reported.
|
|
15
|
+
*/
|
|
16
|
+
export function checkEvmRpcEndpoint(rpc) {
|
|
17
|
+
let u;
|
|
18
|
+
try {
|
|
19
|
+
u = new URL(rpc);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return fail('certen: the RPC endpoint is not a URL.', 'EVM_RPC_INVALID');
|
|
23
|
+
}
|
|
24
|
+
if (u.protocol !== 'https:' && u.protocol !== 'http:') {
|
|
25
|
+
fail(`certen: the RPC endpoint must be http or https, not ${u.protocol}`, 'EVM_RPC_INVALID');
|
|
26
|
+
}
|
|
27
|
+
if (u.username || u.password) {
|
|
28
|
+
fail('certen: the RPC endpoint must not carry a username or password in the URL.', 'EVM_RPC_INVALID');
|
|
29
|
+
}
|
|
30
|
+
return { url: u.toString(), host: u.host };
|
|
31
|
+
}
|
|
32
|
+
/** One JSON-RPC call. The result is whatever the node returned under `result`; an `error` member, a non-200 or a non-JSON reply throws. */
|
|
33
|
+
export async function evmRpcCall(options, method, params) {
|
|
34
|
+
const { url, host } = checkEvmRpcEndpoint(options.rpc);
|
|
35
|
+
const doFetch = options.fetch ?? (typeof fetch === 'function' ? fetch : undefined);
|
|
36
|
+
if (!doFetch)
|
|
37
|
+
fail('certen: this environment has no fetch, so the node cannot be asked.', 'EVM_RPC_UNREADABLE');
|
|
38
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
39
|
+
const controller = new AbortController();
|
|
40
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
41
|
+
let text;
|
|
42
|
+
try {
|
|
43
|
+
const res = await doFetch(url, {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: { 'content-type': 'application/json' },
|
|
46
|
+
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
|
|
47
|
+
redirect: 'error',
|
|
48
|
+
signal: controller.signal,
|
|
49
|
+
});
|
|
50
|
+
if (!res.ok)
|
|
51
|
+
fail(`certen: the node at ${host} answered HTTP ${res.status} to ${method}.`, 'EVM_RPC_UNREADABLE', { host, method, status: res.status });
|
|
52
|
+
text = await res.text();
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
if (err instanceof CertenError)
|
|
56
|
+
throw err;
|
|
57
|
+
// fetch's own messages can contain the URL, and the URL can contain a key. The reason is reduced to what is safe to repeat.
|
|
58
|
+
const why = controller.signal.aborted ? `did not answer within ${timeoutMs / 1000}s` : 'could not be reached';
|
|
59
|
+
return fail(`certen: the node at ${host} ${why} (${method}).`, 'EVM_RPC_UNREADABLE', { host, method });
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
clearTimeout(timer);
|
|
63
|
+
}
|
|
64
|
+
if (text.length > MAX_RESPONSE_CHARS)
|
|
65
|
+
fail(`certen: the node at ${host} sent a reply too large to be an answer to ${method}.`, 'EVM_RPC_UNREADABLE', { host, method });
|
|
66
|
+
let body;
|
|
67
|
+
try {
|
|
68
|
+
body = JSON.parse(text);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return fail(`certen: the node at ${host} did not answer ${method} with JSON.`, 'EVM_RPC_UNREADABLE', { host, method });
|
|
72
|
+
}
|
|
73
|
+
if (body?.error) {
|
|
74
|
+
const message = typeof body.error.message === 'string' ? body.error.message.slice(0, 200) : 'an error';
|
|
75
|
+
fail(`certen: the node at ${host} could not answer ${method}: ${message}`, 'EVM_RPC_ERROR', { host, method });
|
|
76
|
+
}
|
|
77
|
+
if (body === null || typeof body !== 'object' || !('result' in body)) {
|
|
78
|
+
fail(`certen: the node at ${host} returned no result for ${method}.`, 'EVM_RPC_UNREADABLE', { host, method });
|
|
79
|
+
}
|
|
80
|
+
return body.result;
|
|
81
|
+
}
|
|
82
|
+
const hexToBigInt = (value, what, host) => {
|
|
83
|
+
if (typeof value !== 'string' || !/^0x[0-9a-fA-F]+$/.test(value)) {
|
|
84
|
+
return fail(`certen: the node at ${host} returned ${what} that is not a hex quantity.`, 'EVM_RPC_UNREADABLE', { host });
|
|
85
|
+
}
|
|
86
|
+
return BigInt(value);
|
|
87
|
+
};
|
|
88
|
+
/** The node's chain id (`eth_chainId`). */
|
|
89
|
+
export async function readEvmChainId(options) {
|
|
90
|
+
const { host } = checkEvmRpcEndpoint(options.rpc);
|
|
91
|
+
const id = hexToBigInt(await evmRpcCall(options, 'eth_chainId', []), 'a chain id', host);
|
|
92
|
+
return Number(id);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Refuse a node that is not on the named chain.
|
|
96
|
+
*
|
|
97
|
+
* @throws CertenError `EVM_RPC_CHAIN_UNKNOWN` (the chain is not in the catalogue, so there is nothing to compare with) or
|
|
98
|
+
* `EVM_RPC_WRONG_CHAIN` (the node says it is another network; `details` has `expected` and `actual`).
|
|
99
|
+
*/
|
|
100
|
+
export async function assertRpcChain(options, chain) {
|
|
101
|
+
const { host } = checkEvmRpcEndpoint(options.rpc);
|
|
102
|
+
const info = chainInfo(chain);
|
|
103
|
+
if (!info)
|
|
104
|
+
fail(`certen: ${JSON.stringify(String(chain))} is not a chain this client knows, so the node at ${host} cannot be checked to be on it.`, 'EVM_RPC_CHAIN_UNKNOWN');
|
|
105
|
+
const actual = await readEvmChainId(options);
|
|
106
|
+
if (actual !== info.chainId) {
|
|
107
|
+
fail(`certen: the node at ${host} is chain ${actual}, not ${chainSlug(chain)} (${info.chainId}). A balance read from another network would mean nothing here.`, 'EVM_RPC_WRONG_CHAIN', { host, expected: info.chainId, actual });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** An address's native balance in base units at a block (`'latest'` or a number). Needs a node that still holds that block's state. */
|
|
111
|
+
export async function readEvmBalance(options, address, block = 'latest') {
|
|
112
|
+
const { host } = checkEvmRpcEndpoint(options.rpc);
|
|
113
|
+
if (!/^0x[0-9a-fA-F]{40}$/.test(address))
|
|
114
|
+
fail(`certen: ${JSON.stringify(address)} is not an EVM address.`, 'INVALID_ADDRESS');
|
|
115
|
+
const tag = block === 'latest' ? 'latest' : `0x${block.toString(16)}`;
|
|
116
|
+
return hexToBigInt(await evmRpcCall(options, 'eth_getBalance', [address, tag]), 'a balance', host);
|
|
117
|
+
}
|
|
118
|
+
/** The header of a block: number, hash and receipts root, as the node reports them. Undefined when the node has no such block. */
|
|
119
|
+
export async function readEvmBlockHeader(options, block) {
|
|
120
|
+
const result = await evmRpcCall(options, 'eth_getBlockByNumber', [`0x${block.toString(16)}`, false]);
|
|
121
|
+
if (result === null || result === undefined)
|
|
122
|
+
return undefined;
|
|
123
|
+
const h = result;
|
|
124
|
+
return { number: h.number ?? `0x${block.toString(16)}`, ...(h.hash ? { hash: h.hash } : {}), ...(h.receiptsRoot ? { receiptsRoot: h.receiptsRoot } : {}) };
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=evm-rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm-rpc.js","sourceRoot":"","sources":["../src/evm-rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AA4BnD,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,2HAA2H;AAC3H,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEnC,SAAS,IAAI,CAAC,OAAe,EAAE,IAAY,EAAE,OAAiC;IAC5E,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAA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,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC7J,CAAC"}
|
package/dist/funding.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import { CertenError } from './errors.js';
|
|
3
|
+
import type { NativeBalanceReading } from './chains.js';
|
|
3
4
|
/**
|
|
4
5
|
* The unfunded abstract account guard.
|
|
5
6
|
*
|
|
@@ -15,6 +16,9 @@ import { CertenError } from './errors.js';
|
|
|
15
16
|
* **What it refuses, and what it lets through.**
|
|
16
17
|
*
|
|
17
18
|
* - A positively observed zero gas balance is refused ({@link CertenUnfundedAccountError}).
|
|
19
|
+
* - A balance that is positive but cannot cover the amount being moved plus the gas to move it is
|
|
20
|
+
* refused ({@link CertenUnderfundedAccountError}). Zero is the extreme case of this and keeps its
|
|
21
|
+
* own error. The gas half is an ESTIMATE (see {@link assessGas}); the amount half is not.
|
|
18
22
|
* - A gas balance that cannot be IDENTIFIED is refused by name
|
|
19
23
|
* ({@link CertenFundingUnverifiableError}): the chain's gas token is unknown to the catalogue,
|
|
20
24
|
* the gateway reported balances none of which is that token, or it reported the gas row as
|
|
@@ -34,7 +38,84 @@ export declare class CertenUnfundedAccountError extends CertenError {
|
|
|
34
38
|
/** Never. Funding is a human act; retrying changes nothing. */
|
|
35
39
|
get isRetryable(): boolean;
|
|
36
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Thrown instead of submitting a value-moving intent from an account that holds some gas, but not enough: either less than the amount
|
|
43
|
+
* being moved, or too little left over once it is.
|
|
44
|
+
*
|
|
45
|
+
* `kind: 'amount'` is a fact (the account holds less than it is about to send). `kind: 'gas'` is judged against an ESTIMATE of what one
|
|
46
|
+
* execution costs, which is why it is overridable and says so.
|
|
47
|
+
*/
|
|
48
|
+
export declare class CertenUnderfundedAccountError extends CertenError {
|
|
49
|
+
readonly address: string;
|
|
50
|
+
readonly chain: string;
|
|
51
|
+
readonly kind: 'amount' | 'gas';
|
|
52
|
+
/** Whole native units, as strings, so nothing here is a float. */
|
|
53
|
+
readonly balance: string;
|
|
54
|
+
readonly needed: string;
|
|
55
|
+
readonly symbol: string;
|
|
56
|
+
constructor(address: string, chain: string, shortfall: Extract<GasAssessment, {
|
|
57
|
+
state: 'short';
|
|
58
|
+
}>);
|
|
59
|
+
/** Never. Funding is a human act; retrying changes nothing. */
|
|
60
|
+
get isRetryable(): boolean;
|
|
61
|
+
}
|
|
37
62
|
export type FundingUnverifiableReason = 'unknown-native' | 'native-not-reported' | 'unreadable';
|
|
63
|
+
/**
|
|
64
|
+
* What the native balance on an abstract account says about a value-moving intent.
|
|
65
|
+
*
|
|
66
|
+
* One function, used by the SDK's guard, the CLI's guard and `client.readiness()`: three copies of "is there enough" would drift, and the
|
|
67
|
+
* place they would drift is the amount of money at which a refusal starts.
|
|
68
|
+
*
|
|
69
|
+
* - `unknown`: the balance could not be read as a number (not reported yet, the wrong token, unreadable). **Never** a refusal on its own
|
|
70
|
+
* authority: an unknown balance does not block a submission, and is never reported as funded.
|
|
71
|
+
* - `empty`: positively zero.
|
|
72
|
+
* - `short`: positive, but below what is needed. `kind: 'amount'` when it cannot even cover the amount; `kind: 'gas'` when it covers the
|
|
73
|
+
* amount but not the amount plus the gas reserve (or leaves nothing at all for gas).
|
|
74
|
+
* - `sufficient`: enough. `estimated` says whether a gas reserve was part of the judgement; false means the chain has no estimate and only
|
|
75
|
+
* the amount was checked.
|
|
76
|
+
*
|
|
77
|
+
* Every quantity is exact integer arithmetic in base units and reported in whole units.
|
|
78
|
+
*/
|
|
79
|
+
export type GasAssessment = {
|
|
80
|
+
state: 'unknown';
|
|
81
|
+
reading: NativeBalanceReading;
|
|
82
|
+
} | {
|
|
83
|
+
state: 'empty';
|
|
84
|
+
symbol: string;
|
|
85
|
+
balance: string;
|
|
86
|
+
amount: string;
|
|
87
|
+
reserve: string;
|
|
88
|
+
needed: string;
|
|
89
|
+
} | {
|
|
90
|
+
state: 'short';
|
|
91
|
+
kind: 'amount' | 'gas';
|
|
92
|
+
symbol: string;
|
|
93
|
+
balance: string;
|
|
94
|
+
amount: string;
|
|
95
|
+
reserve: string;
|
|
96
|
+
needed: string;
|
|
97
|
+
/** How much more would clear it, or null when only "something left over for gas" would (the whole balance was being moved). */
|
|
98
|
+
shortfall: string | null;
|
|
99
|
+
} | {
|
|
100
|
+
state: 'sufficient';
|
|
101
|
+
symbol: string;
|
|
102
|
+
balance: string;
|
|
103
|
+
amount: string;
|
|
104
|
+
reserve: string;
|
|
105
|
+
needed: string;
|
|
106
|
+
estimated: boolean;
|
|
107
|
+
};
|
|
108
|
+
export declare function assessGas(p: {
|
|
109
|
+
chain: string | number;
|
|
110
|
+
reading: NativeBalanceReading;
|
|
111
|
+
/** The native amount being moved, in whole units. Omit when nothing native moves (a token transfer, or only a readiness check). */
|
|
112
|
+
amount?: string;
|
|
113
|
+
/**
|
|
114
|
+
* The gas reserve in whole units. Undefined takes the catalogue's estimate for the chain; `null` means "no reserve", which is how a caller
|
|
115
|
+
* says it knows better than the catalogue.
|
|
116
|
+
*/
|
|
117
|
+
reserve?: string | null;
|
|
118
|
+
}): GasAssessment;
|
|
38
119
|
/**
|
|
39
120
|
* Thrown instead of submitting a value-moving intent whose gas balance could not be identified.
|
|
40
121
|
*
|
|
@@ -76,5 +157,95 @@ export declare function assertFundedForValue(http: AxiosInstance, params: {
|
|
|
76
157
|
identityId: string;
|
|
77
158
|
chain: string | undefined;
|
|
78
159
|
amount: unknown;
|
|
160
|
+
/**
|
|
161
|
+
* What `amount` is measured in. `whole` (the default) is a transfer's `amount`: "0.0001" ETH. `base` is a contract call's `value`:
|
|
162
|
+
* wei. The same field name has carried both, which is why this is stated rather than guessed from the digits.
|
|
163
|
+
*/
|
|
164
|
+
amountUnit?: 'whole' | 'base';
|
|
165
|
+
/** The token being moved. When it is not the chain's native token the amount is not native, and only the gas is judged. */
|
|
166
|
+
tokenSymbol?: string;
|
|
167
|
+
/** Override the catalogue's gas reserve (whole native units); `null` for none. See {@link assessGas}. */
|
|
168
|
+
gasReserve?: string | null;
|
|
79
169
|
}): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* The part of an intent's amount that is paid in the chain's native token, in whole units, or undefined when none of it is.
|
|
172
|
+
*
|
|
173
|
+
* A token transfer's amount is in the token and does not draw down the gas balance; counting it would refuse an account that holds the
|
|
174
|
+
* token and plenty of gas. A base-unit (wei) value is converted so one comparison serves both spellings.
|
|
175
|
+
*/
|
|
176
|
+
export declare function nativeAmountOf(chain: string, p: {
|
|
177
|
+
amount: unknown;
|
|
178
|
+
amountUnit?: 'whole' | 'base';
|
|
179
|
+
tokenSymbol?: string;
|
|
180
|
+
}): string | undefined;
|
|
181
|
+
/**
|
|
182
|
+
* An EIP-681 payment request for a NATIVE transfer: `ethereum:<address>@<chainId>?value=<wei>`.
|
|
183
|
+
*
|
|
184
|
+
* Opens a wallet with the recipient, the network and the amount already set, which is the only way to move a value from a terminal to a wallet
|
|
185
|
+
* without retyping it. A mistyped recipient is the one error in this product that loses money and cannot be undone, so this builds a link only
|
|
186
|
+
* when every part of it is certain, and says `undefined` otherwise:
|
|
187
|
+
*
|
|
188
|
+
* - the chain must be in the catalogue (a link for a guessed network sends value somewhere nobody chose);
|
|
189
|
+
* - the address must be 20 bytes of hex, and is used exactly as given (the gateway's checksum case is preserved, never re-derived);
|
|
190
|
+
* - the amount is whole units and becomes integer wei by BigInt arithmetic. More decimals than the token has is refused rather than rounded:
|
|
191
|
+
* rounding would change what is paid.
|
|
192
|
+
*
|
|
193
|
+
* The value is a plain integer. EIP-681 also allows `1e15`, but a plain integer is read by more wallets.
|
|
194
|
+
*/
|
|
195
|
+
export declare function nativeTransferUri(p: {
|
|
196
|
+
chain: string | number;
|
|
197
|
+
address: string;
|
|
198
|
+
amount?: string;
|
|
199
|
+
}): string | undefined;
|
|
200
|
+
/**
|
|
201
|
+
* What to tell someone whose abstract account needs gas, and how to know when it has arrived.
|
|
202
|
+
*
|
|
203
|
+
* Funding was a faucet URL and a guess. This is the account, the least that lets a transaction run, how much to send so the next few do not
|
|
204
|
+
* each need another faucet visit, the faucet, a wallet link, and the alternative for a faucet that will not pay a contract address.
|
|
205
|
+
*
|
|
206
|
+
* **Both amounts are planning figures.** `minimum` is what the readiness gas check accepts: the catalogue's gas reserve (an ESTIMATE, there is
|
|
207
|
+
* no published per-execution cost) plus any amount about to be moved. `suggested` is ten executions' worth, enough to stop thinking about it.
|
|
208
|
+
* A chain with no reserve has neither: it says there is no estimate and asks for no number nobody measured, and any positive balance clears
|
|
209
|
+
* it (the check judges the amount alone there).
|
|
210
|
+
*
|
|
211
|
+
* `balance` is what the account holds now, in whole units. Anything that is not a plain decimal is unknown, and unknown is never satisfied.
|
|
212
|
+
*
|
|
213
|
+
* Words only: this module does not know it is being driven by a CLI, so it names no command. A CLI adds its own.
|
|
214
|
+
*/
|
|
215
|
+
export interface GasFundingPlan {
|
|
216
|
+
chain: string;
|
|
217
|
+
symbol: string;
|
|
218
|
+
address: string;
|
|
219
|
+
/** What the account holds now, whole units; null when unknown. */
|
|
220
|
+
balance: string | null;
|
|
221
|
+
/** The least that clears the readiness gas check, whole units; null when the chain has no estimate and no amount was given. */
|
|
222
|
+
minimum: string | null;
|
|
223
|
+
/** What is suggested the account holds: `max(10 x reserve, minimum)`; null when there is no estimate. */
|
|
224
|
+
suggested: string | null;
|
|
225
|
+
/** What to send now to reach `suggested`: the difference from `balance`, or all of it when the balance is unknown. Null when there is no figure. */
|
|
226
|
+
send: string | null;
|
|
227
|
+
/** The least to send now to clear `minimum` (`0` when it is already cleared). Null when there is no figure. */
|
|
228
|
+
least: string | null;
|
|
229
|
+
/** The balance already clears `minimum` (or, with no estimate, is positive). False when unknown. */
|
|
230
|
+
satisfied: boolean;
|
|
231
|
+
/** `minimum` and `suggested` rest on the catalogue's reserve. False when there was none to rest on. */
|
|
232
|
+
estimated: boolean;
|
|
233
|
+
faucet: string | null;
|
|
234
|
+
/** EIP-681 link to send `send` to `address`; the bare address link when there is no figure; null for a chain without an id. */
|
|
235
|
+
paymentUri: string | null;
|
|
236
|
+
/** The instructions, one line each, in words. */
|
|
237
|
+
steps: string[];
|
|
238
|
+
/** The alternative for a faucet that refuses a contract address: a wallet you control, then a transfer from it. Two lines. */
|
|
239
|
+
twoStep: string[];
|
|
240
|
+
}
|
|
241
|
+
export declare function gasFundingPlan(p: {
|
|
242
|
+
chain: string | number;
|
|
243
|
+
address: string;
|
|
244
|
+
/** Whole units as the gateway reports it. Omit, null or anything unreadable for unknown. */
|
|
245
|
+
balance?: string | null;
|
|
246
|
+
/** The native amount about to be moved, whole units. Added to the minimum. */
|
|
247
|
+
amount?: string;
|
|
248
|
+
/** Override the catalogue's gas reserve (whole native units); `null` for none. */
|
|
249
|
+
reserve?: string | null;
|
|
250
|
+
}): GasFundingPlan | undefined;
|
|
80
251
|
//# sourceMappingURL=funding.d.ts.map
|
package/dist/funding.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"funding.d.ts","sourceRoot":"","sources":["../src/funding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C
|
|
1
|
+
{"version":3,"file":"funding.d.ts","sourceRoot":"","sources":["../src/funding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,uEAAuE;AACvE,qBAAa,0BAA2B,SAAQ,WAAW;IACzD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,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