@certen.io/sdk 0.9.0 → 0.11.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.
Files changed (170) hide show
  1. package/CHANGELOG.md +153 -0
  2. package/README.md +111 -0
  3. package/dist/address.d.ts +12 -0
  4. package/dist/address.d.ts.map +1 -0
  5. package/dist/address.js +48 -0
  6. package/dist/address.js.map +1 -0
  7. package/dist/agent.d.ts +8 -0
  8. package/dist/agent.d.ts.map +1 -1
  9. package/dist/agent.js +12 -0
  10. package/dist/agent.js.map +1 -1
  11. package/dist/browser.d.ts +47 -0
  12. package/dist/browser.d.ts.map +1 -0
  13. package/dist/browser.js +55 -0
  14. package/dist/browser.js.map +1 -0
  15. package/dist/bytes.d.ts +14 -0
  16. package/dist/bytes.d.ts.map +1 -0
  17. package/dist/bytes.js +47 -0
  18. package/dist/bytes.js.map +1 -0
  19. package/dist/chains.d.ts +218 -0
  20. package/dist/chains.d.ts.map +1 -0
  21. package/dist/chains.js +295 -0
  22. package/dist/chains.js.map +1 -0
  23. package/dist/client.d.ts +17 -2
  24. package/dist/client.d.ts.map +1 -1
  25. package/dist/client.js +54 -8
  26. package/dist/client.js.map +1 -1
  27. package/dist/defaults.d.ts +3 -0
  28. package/dist/defaults.d.ts.map +1 -0
  29. package/dist/defaults.js +3 -0
  30. package/dist/defaults.js.map +1 -0
  31. package/dist/doctor.d.ts +10 -1
  32. package/dist/doctor.d.ts.map +1 -1
  33. package/dist/doctor.js +42 -27
  34. package/dist/doctor.js.map +1 -1
  35. package/dist/effect.d.ts +99 -0
  36. package/dist/effect.d.ts.map +1 -0
  37. package/dist/effect.js +139 -0
  38. package/dist/effect.js.map +1 -0
  39. package/dist/error-codes.d.ts.map +1 -1
  40. package/dist/error-codes.js +17 -0
  41. package/dist/error-codes.js.map +1 -1
  42. package/dist/errors.d.ts +76 -0
  43. package/dist/errors.d.ts.map +1 -1
  44. package/dist/errors.js +108 -0
  45. package/dist/errors.js.map +1 -1
  46. package/dist/evm-rpc.d.ts +55 -0
  47. package/dist/evm-rpc.d.ts.map +1 -0
  48. package/dist/evm-rpc.js +126 -0
  49. package/dist/evm-rpc.js.map +1 -0
  50. package/dist/execution-proof.d.ts.map +1 -1
  51. package/dist/execution-proof.js +2 -1
  52. package/dist/execution-proof.js.map +1 -1
  53. package/dist/funding.d.ts +214 -6
  54. package/dist/funding.d.ts.map +1 -1
  55. package/dist/funding.js +251 -29
  56. package/dist/funding.js.map +1 -1
  57. package/dist/header-fields.d.ts +68 -0
  58. package/dist/header-fields.d.ts.map +1 -0
  59. package/dist/header-fields.js +147 -0
  60. package/dist/header-fields.js.map +1 -0
  61. package/dist/index.d.ts +9 -17
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +11 -26
  64. package/dist/index.js.map +1 -1
  65. package/dist/intent-states.d.ts +75 -0
  66. package/dist/intent-states.d.ts.map +1 -0
  67. package/dist/intent-states.js +66 -0
  68. package/dist/intent-states.js.map +1 -0
  69. package/dist/internal.d.ts +18 -0
  70. package/dist/internal.d.ts.map +1 -1
  71. package/dist/internal.js +44 -0
  72. package/dist/internal.js.map +1 -1
  73. package/dist/key-page.d.ts +67 -0
  74. package/dist/key-page.d.ts.map +1 -0
  75. package/dist/key-page.js +154 -0
  76. package/dist/key-page.js.map +1 -0
  77. package/dist/origin.d.ts +19 -0
  78. package/dist/origin.d.ts.map +1 -0
  79. package/dist/origin.js +80 -0
  80. package/dist/origin.js.map +1 -0
  81. package/dist/random.d.ts +27 -0
  82. package/dist/random.d.ts.map +1 -0
  83. package/dist/random.js +30 -0
  84. package/dist/random.js.map +1 -0
  85. package/dist/readiness.d.ts +133 -0
  86. package/dist/readiness.d.ts.map +1 -0
  87. package/dist/readiness.js +467 -0
  88. package/dist/readiness.js.map +1 -0
  89. package/dist/reason-codes.d.ts +15 -0
  90. package/dist/reason-codes.d.ts.map +1 -0
  91. package/dist/reason-codes.js +30 -0
  92. package/dist/reason-codes.js.map +1 -0
  93. package/dist/receipt.d.ts +233 -0
  94. package/dist/receipt.d.ts.map +1 -0
  95. package/dist/receipt.js +318 -0
  96. package/dist/receipt.js.map +1 -0
  97. package/dist/resources/admin.d.ts +5 -2
  98. package/dist/resources/admin.d.ts.map +1 -1
  99. package/dist/resources/admin.js +8 -3
  100. package/dist/resources/admin.js.map +1 -1
  101. package/dist/resources/billing.d.ts.map +1 -1
  102. package/dist/resources/billing.js +5 -4
  103. package/dist/resources/billing.js.map +1 -1
  104. package/dist/resources/chains.d.ts +10 -0
  105. package/dist/resources/chains.d.ts.map +1 -1
  106. package/dist/resources/chains.js +15 -1
  107. package/dist/resources/chains.js.map +1 -1
  108. package/dist/resources/device.d.ts.map +1 -1
  109. package/dist/resources/device.js +2 -1
  110. package/dist/resources/device.js.map +1 -1
  111. package/dist/resources/execute.d.ts +110 -4
  112. package/dist/resources/execute.d.ts.map +1 -1
  113. package/dist/resources/execute.js +207 -35
  114. package/dist/resources/execute.js.map +1 -1
  115. package/dist/resources/governance.js +3 -3
  116. package/dist/resources/governance.js.map +1 -1
  117. package/dist/resources/identity.js +5 -5
  118. package/dist/resources/identity.js.map +1 -1
  119. package/dist/resources/oauth-clients.d.ts.map +1 -1
  120. package/dist/resources/oauth-clients.js +3 -2
  121. package/dist/resources/oauth-clients.js.map +1 -1
  122. package/dist/resources/proof.d.ts +10 -2
  123. package/dist/resources/proof.d.ts.map +1 -1
  124. package/dist/resources/proof.js +33 -11
  125. package/dist/resources/proof.js.map +1 -1
  126. package/dist/resources/registration-tokens.d.ts.map +1 -1
  127. package/dist/resources/registration-tokens.js +2 -1
  128. package/dist/resources/registration-tokens.js.map +1 -1
  129. package/dist/resources/sign.js +2 -2
  130. package/dist/resources/sign.js.map +1 -1
  131. package/dist/resources/transaction.d.ts.map +1 -1
  132. package/dist/resources/transaction.js +7 -3
  133. package/dist/resources/transaction.js.map +1 -1
  134. package/dist/resources/transparency.d.ts.map +1 -1
  135. package/dist/resources/transparency.js +3 -2
  136. package/dist/resources/transparency.js.map +1 -1
  137. package/dist/resources/webhooks.d.ts +5 -3
  138. package/dist/resources/webhooks.d.ts.map +1 -1
  139. package/dist/resources/webhooks.js +12 -8
  140. package/dist/resources/webhooks.js.map +1 -1
  141. package/dist/sha256.d.ts +10 -0
  142. package/dist/sha256.d.ts.map +1 -0
  143. package/dist/sha256.js +71 -0
  144. package/dist/sha256.js.map +1 -0
  145. package/dist/share-target.d.ts +10 -0
  146. package/dist/share-target.d.ts.map +1 -0
  147. package/dist/share-target.js +25 -0
  148. package/dist/share-target.js.map +1 -0
  149. package/dist/shared-proof.d.ts +1 -5
  150. package/dist/shared-proof.d.ts.map +1 -1
  151. package/dist/shared-proof.js +27 -21
  152. package/dist/shared-proof.js.map +1 -1
  153. package/dist/signing-check.d.ts +66 -0
  154. package/dist/signing-check.d.ts.map +1 -0
  155. package/dist/signing-check.js +171 -0
  156. package/dist/signing-check.js.map +1 -0
  157. package/dist/types.d.ts +139 -0
  158. package/dist/types.d.ts.map +1 -1
  159. package/dist/verify-receipt.d.ts.map +1 -1
  160. package/dist/verify-receipt.js +68 -28
  161. package/dist/verify-receipt.js.map +1 -1
  162. package/dist/verify.d.ts +206 -0
  163. package/dist/verify.d.ts.map +1 -0
  164. package/dist/verify.js +369 -0
  165. package/dist/verify.js.map +1 -0
  166. package/dist/version.d.ts +2 -0
  167. package/dist/version.d.ts.map +1 -0
  168. package/dist/version.js +4 -0
  169. package/dist/version.js.map +1 -0
  170. package/package.json +25 -7
@@ -0,0 +1,99 @@
1
+ import { type EvmRpcOptions } from './evm-rpc.js';
2
+ /**
3
+ * Did the value actually arrive?
4
+ *
5
+ * A proof says an execution happened as the bundle shows. It does not say the person on the other end can spend the money, and a person
6
+ * who just sent value wants to know that. So after a native transfer there is a second, plainer question: did the recipient's balance go up
7
+ * by the amount?
8
+ *
9
+ * **Who is asked matters, and the answer says who.**
10
+ * - The recipient is read from a node the CALLER chose (`rpc`), never from CERTEN: the gateway has no read of an arbitrary address, and
11
+ * would not be an independent witness if it had. Without a node the recipient is `unchecked`, and says how to turn the check on. It is
12
+ * never `confirmed` on the strength of anything else.
13
+ * - The sender (the abstract account) is read from the gateway, because that is the only place it can be read from. It is shown as
14
+ * supporting evidence ("the account's balance fell by X, as the gateway reports it") and never decides the verdict on its own.
15
+ *
16
+ * **What the numbers can and cannot show.** A balance difference is a difference between two moments. Other transfers to the same address in
17
+ * between make the rise larger (the verdict says "at least"); a transfer FROM the address in between can make it smaller than the amount
18
+ * even though the value arrived (the verdict says what it saw and names that as a possible reason, and does not call the proof wrong). It is
19
+ * an observation, labelled as one, and the receipt's verdict treats `not_observed` as a reason to look, not as a proven failure.
20
+ */
21
+ export type EffectState = 'confirmed' | 'not_observed' | 'unchecked' | 'unreadable' | 'not_applicable';
22
+ export interface BalanceMove {
23
+ /** `rpc`: the caller's own node. `gateway`: the CERTEN gateway's report. */
24
+ source: 'rpc' | 'gateway';
25
+ /** The node's host (never its URL, which can carry a key). Absent for the gateway. */
26
+ host?: string;
27
+ address: string;
28
+ symbol: string;
29
+ /** Whole-unit decimal strings, or null when that reading was not made. */
30
+ before: string | null;
31
+ after: string | null;
32
+ /** After minus before, signed. Null when either reading is missing. */
33
+ delta: string | null;
34
+ /** The block the `after` reading is at, or `latest`; null for the gateway. */
35
+ at_block: number | 'latest' | null;
36
+ }
37
+ export interface ReceiptEffect {
38
+ kind: 'native_transfer' | 'contract_call' | 'none';
39
+ state: EffectState;
40
+ /** What was found, in words. */
41
+ detail: string;
42
+ /** The amount that was meant to arrive, whole units. */
43
+ amount?: string;
44
+ symbol?: string;
45
+ /** The recipient, read from the caller's own node. Absent when no node was given. */
46
+ recipient?: BalanceMove;
47
+ /** The abstract account, read from the gateway. Supporting evidence only. */
48
+ sender?: BalanceMove;
49
+ /** For a contract call checked with an expected event: whether the proof's receipt carries it. Null when it was not looked for. */
50
+ expected_event?: {
51
+ found: boolean | null;
52
+ };
53
+ }
54
+ /** The recipient's balance taken BEFORE signing, so a later read has something to be compared with. Stored in the receipt. */
55
+ export interface RecipientSnapshot {
56
+ address: string;
57
+ /** Base units, as a decimal string. */
58
+ wei: string;
59
+ host: string;
60
+ chain_id: number;
61
+ taken_at: string;
62
+ }
63
+ /** The effect of something that is not a native transfer and has nothing to compare: said, not skipped. */
64
+ export declare const noEffectToCheck: (detail: string) => ReceiptEffect;
65
+ /**
66
+ * Take the recipient's balance now, from the caller's node, after checking the node is on the chain.
67
+ *
68
+ * Done BEFORE the signature so the rise can be measured. Throws on a wrong chain or an unreadable node: the caller decides whether a node
69
+ * it was told to use and cannot use stops the send (it does: the person asked for an independent check and should not discover it was not made
70
+ * after the value has moved).
71
+ */
72
+ export declare function snapshotRecipient(p: EvmRpcOptions & {
73
+ chain: string;
74
+ address: string;
75
+ now?: () => Date;
76
+ }): Promise<RecipientSnapshot>;
77
+ export interface NativeEffectParams extends Partial<EvmRpcOptions> {
78
+ chain: string;
79
+ recipient: string;
80
+ /** What was meant to arrive, whole units. */
81
+ amount: string;
82
+ /** The block the transfer executed in, from the verified execution proof. */
83
+ atBlock?: number;
84
+ /** The recipient's balance taken before signing (`snapshotRecipient`). Without it, the balance one block earlier is the baseline. */
85
+ before?: RecipientSnapshot;
86
+ /** The abstract account's native balance (whole units) before signing and now, as the gateway reports them. */
87
+ sender?: {
88
+ address: string;
89
+ before: string | null;
90
+ after: string | null;
91
+ };
92
+ }
93
+ /**
94
+ * Judge a native transfer from the recipient's side (and the sender's, as support).
95
+ *
96
+ * Never throws: a node that cannot be read is `unreadable` with the reason, which is a different thing from the balance not having risen.
97
+ */
98
+ export declare function checkNativeTransferEffect(p: NativeEffectParams): Promise<ReceiptEffect>;
99
+ //# sourceMappingURL=effect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuD,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAEvG;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,M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AAEpC;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,aAAa,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAM3I;AAYD,MAAM,WAAW,kBAAmB,SAAQ,OAAO,CAAC,aAAa,CAAC;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qIAAqI;IACrI,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,+GAA+G;IAC/G,MAAM,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CAC3E;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAkG7F"}
package/dist/effect.js ADDED
@@ -0,0 +1,139 @@
1
+ import { CertenError } from './errors.js';
2
+ import { chainInfo, formatUnits, parseUnits } from './chains.js';
3
+ import { assertRpcChain, checkEvmRpcEndpoint, readEvmBalance } from './evm-rpc.js';
4
+ const none = (detail) => ({ kind: 'none', state: 'not_applicable', detail });
5
+ /** The effect of something that is not a native transfer and has nothing to compare: said, not skipped. */
6
+ export const noEffectToCheck = none;
7
+ /**
8
+ * Take the recipient's balance now, from the caller's node, after checking the node is on the chain.
9
+ *
10
+ * Done BEFORE the signature so the rise can be measured. Throws on a wrong chain or an unreadable node: the caller decides whether a node
11
+ * it was told to use and cannot use stops the send (it does: the person asked for an independent check and should not discover it was not made
12
+ * after the value has moved).
13
+ */
14
+ export async function snapshotRecipient(p) {
15
+ const info = chainInfo(p.chain);
16
+ const { host } = checkEvmRpcEndpoint(p.rpc);
17
+ await assertRpcChain(p, p.chain);
18
+ const wei = await readEvmBalance(p, p.address, 'latest');
19
+ return { address: p.address, wei: wei.toString(), host, chain_id: info.chainId, taken_at: (p.now?.() ?? new Date()).toISOString() };
20
+ }
21
+ function move(source, address, symbol, decimals, before, after, atBlock, host) {
22
+ return {
23
+ source, ...(host ? { host } : {}), address, symbol,
24
+ before: before === null ? null : formatUnits(before, decimals),
25
+ after: after === null ? null : formatUnits(after, decimals),
26
+ delta: before === null || after === null ? null : formatUnits(after - before, decimals),
27
+ at_block: atBlock,
28
+ };
29
+ }
30
+ /**
31
+ * Judge a native transfer from the recipient's side (and the sender's, as support).
32
+ *
33
+ * Never throws: a node that cannot be read is `unreadable` with the reason, which is a different thing from the balance not having risen.
34
+ */
35
+ export async function checkNativeTransferEffect(p) {
36
+ const info = chainInfo(p.chain);
37
+ if (!info) {
38
+ return { kind: 'native_transfer', state: 'unchecked', amount: p.amount, detail: `${p.chain} is not a chain this client knows, so what a balance means there cannot be stated.` };
39
+ }
40
+ const { nativeDecimals: decimals, nativeSymbol: symbol } = info;
41
+ const want = parseUnits(p.amount, decimals);
42
+ if (want === undefined) {
43
+ return { kind: 'native_transfer', state: 'unchecked', amount: p.amount, symbol, detail: `The amount ${JSON.stringify(p.amount)} is not one this client can compare a balance with.` };
44
+ }
45
+ // The sender, from the gateway. Supporting only.
46
+ let sender;
47
+ let senderNote = '';
48
+ if (p.sender) {
49
+ const b = parseUnits(p.sender.before ?? undefined, decimals);
50
+ const a = parseUnits(p.sender.after ?? undefined, decimals);
51
+ sender = move('gateway', p.sender.address, symbol, decimals, b ?? null, a ?? null, null);
52
+ if (b !== undefined && a !== undefined) {
53
+ senderNote = b - a >= want
54
+ ? ` The abstract account's balance fell by ${formatUnits(b - a, decimals)} ${symbol} (as the gateway reports it).`
55
+ : b - a > 0n
56
+ ? ` The abstract account's balance fell by ${formatUnits(b - a, decimals)} ${symbol}, less than ${p.amount} (as the gateway reports it).`
57
+ : ' The abstract account\'s balance has not fallen yet (as the gateway reports it; its view can lag).';
58
+ }
59
+ }
60
+ if (!p.rpc) {
61
+ return {
62
+ kind: 'native_transfer', state: 'unchecked', amount: p.amount, symbol, ...(sender ? { sender } : {}),
63
+ detail: `The recipient's balance was not checked: no node of yours was given, and the gateway cannot read another address.${senderNote}`,
64
+ };
65
+ }
66
+ const opts = { rpc: p.rpc, fetch: p.fetch, timeoutMs: p.timeoutMs };
67
+ let host;
68
+ try {
69
+ host = checkEvmRpcEndpoint(p.rpc).host;
70
+ await assertRpcChain(opts, p.chain);
71
+ }
72
+ catch (err) {
73
+ return {
74
+ kind: 'native_transfer', state: 'unreadable', amount: p.amount, symbol, ...(sender ? { sender } : {}),
75
+ detail: `${(err instanceof CertenError ? err.message : String(err)).replace(/^certen: /, '')}${senderNote}`,
76
+ };
77
+ }
78
+ try {
79
+ let before;
80
+ if (p.before) {
81
+ if (p.before.address.toLowerCase() !== p.recipient.toLowerCase() || p.before.chain_id !== info.chainId) {
82
+ return {
83
+ kind: 'native_transfer', state: 'unreadable', amount: p.amount, symbol, ...(sender ? { sender } : {}),
84
+ detail: 'The balance saved before signing is for another address or chain, so it is not a baseline for this one.',
85
+ };
86
+ }
87
+ before = BigInt(p.before.wei);
88
+ }
89
+ else if (p.atBlock !== undefined && p.atBlock > 0) {
90
+ before = await readEvmBalance(opts, p.recipient, p.atBlock - 1);
91
+ }
92
+ else {
93
+ return {
94
+ kind: 'native_transfer', state: 'unreadable', amount: p.amount, symbol, ...(sender ? { sender } : {}),
95
+ detail: `There is no balance from before the transfer and no block to measure it against.${senderNote}`,
96
+ };
97
+ }
98
+ // At the execution block when it is known and the node still has that state; otherwise the latest. Both are labelled.
99
+ let after;
100
+ let at = 'latest';
101
+ if (p.atBlock !== undefined) {
102
+ try {
103
+ after = await readEvmBalance(opts, p.recipient, p.atBlock);
104
+ at = p.atBlock;
105
+ }
106
+ catch {
107
+ after = await readEvmBalance(opts, p.recipient, 'latest');
108
+ }
109
+ }
110
+ else {
111
+ after = await readEvmBalance(opts, p.recipient, 'latest');
112
+ }
113
+ const recipient = move('rpc', p.recipient, symbol, decimals, before, after, at, host);
114
+ const delta = after - before;
115
+ const where = `${at === 'latest' ? 'now' : `at block ${at}`} on the node at ${host}`;
116
+ if (delta >= want) {
117
+ return {
118
+ kind: 'native_transfer', state: 'confirmed', amount: p.amount, symbol, recipient, ...(sender ? { sender } : {}),
119
+ detail: delta === want
120
+ ? `The recipient's balance rose by exactly ${p.amount} ${symbol} (${where}).${senderNote}`
121
+ : `The recipient's balance rose by ${formatUnits(delta, decimals)} ${symbol}, at least the ${p.amount} sent (other transfers to it may be included) (${where}).${senderNote}`,
122
+ };
123
+ }
124
+ return {
125
+ kind: 'native_transfer', state: 'not_observed', amount: p.amount, symbol, recipient, ...(sender ? { sender } : {}),
126
+ detail: `The recipient's balance changed by ${formatUnits(delta, decimals)} ${symbol} (${where}), not the ${p.amount} sent. `
127
+ + `The value may have been spent from that address since, or a block may differ from the one read; the proof is what says what executed.${senderNote}`,
128
+ };
129
+ }
130
+ catch (err) {
131
+ return {
132
+ kind: 'native_transfer', state: 'unreadable', amount: p.amount, symbol, ...(sender ? { sender } : {}),
133
+ // The node's own messages already name the host and never the URL (evm-rpc.ts); anything else is reduced to its class.
134
+ detail: `The recipient's balance could not be read from the node at ${host}: `
135
+ + `${err instanceof CertenError ? err.message.replace(/^certen: the node at \S+ /, '').replace(/^certen: /, '') : 'an unexpected error'}${senderNote}`,
136
+ };
137
+ }
138
+ }
139
+ //# sourceMappingURL=effect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effect.js","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,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,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrG,uHAAuH;YACvH,MAAM,EAAE,8DAA8D,IAAI,IAAI;kBAC1E,GAAG,GAAG,YAAY,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,qBAAqB,GAAG,UAAU,EAAE;SACzJ,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAyCjD,CAAC"}
1
+ {"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EA0DjD,CAAC"}
@@ -11,20 +11,31 @@
11
11
  * matches it exactly, so the two cannot drift without a test failing.
12
12
  */
13
13
  export const VENDORED_ERROR_CODES = [
14
+ 'ADDITIONAL_AUTHORITIES_INVALID',
15
+ 'ADDITIONAL_AUTHORITY_IS_PRINCIPAL_BOOK',
14
16
  'BAD_GATEWAY',
15
17
  'BAD_REQUEST',
16
18
  'BILLING_DISABLED',
19
+ 'CHAIN_NOT_ENABLED',
17
20
  'CHAIN_NOT_PRICEABLE',
18
21
  'CHAIN_SUSPENDED',
19
22
  'CHAIN_UNRESOLVED',
20
23
  'COMMITMENT_EXCEEDED',
21
24
  'CONFLICT',
25
+ 'COST_HISTORY_ASSET_MISMATCH',
26
+ 'DB_CONNECTION_LOST',
22
27
  'ENTITLEMENT_UNAVAILABLE',
28
+ 'EXPIRES_AT_INVALID',
29
+ 'EXPIRES_AT_OUT_OF_RANGE',
23
30
  'FORBIDDEN',
31
+ 'FX_MANUAL_NOT_ALLOWED',
32
+ 'FX_NOT_CORROBORATED',
24
33
  'FX_UNAVAILABLE',
34
+ 'HEADER_AUTHORITY_NOT_EXECUTABLE',
25
35
  'IDEMPOTENCY_KEY_IN_FLIGHT',
26
36
  'IDEMPOTENCY_KEY_MISMATCH',
27
37
  'INSUFFICIENT_BALANCE',
38
+ 'INTENT_EXPIRED',
28
39
  'INTERNAL_ERROR',
29
40
  'LEDGER_ACCOUNT_NOT_LOCKED',
30
41
  'LEDGER_MISSING_ORG',
@@ -33,10 +44,15 @@ export const VENDORED_ERROR_CODES = [
33
44
  'LEDGER_UNEXPECTED_ORG',
34
45
  'LEDGER_ZERO_LEG',
35
46
  'LOG_DIVERGENCE',
47
+ 'LOG_NODES_INCOMPLETE',
48
+ 'NATIVE_ASSET_MISMATCH',
49
+ 'NATIVE_ASSET_UNKNOWN',
36
50
  'NOT_FOUND',
37
51
  'NO_PRICE_BOOK',
38
52
  'PAYMENT_REQUIRED',
39
53
  'PLAN_QUOTA_EXCEEDED',
54
+ 'PROOFS_TENANT_KEY_ORG_REQUIRED',
55
+ 'PROOFS_TENANT_KEY_SECRET_MISSING',
40
56
  'QUOTE_EXPIRED',
41
57
  'QUOTE_MISMATCH',
42
58
  'RATE_LIMIT_EXCEEDED',
@@ -50,6 +66,7 @@ export const VENDORED_ERROR_CODES = [
50
66
  'TIMESTAMP_SERVICE_UNAVAILABLE',
51
67
  'TOO_MANY_REQUESTS',
52
68
  'UNAUTHORIZED',
69
+ 'UNKNOWN_CHAIN',
53
70
  'VALIDATION_ERROR',
54
71
  ];
55
72
  //# sourceMappingURL=error-codes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-codes.js","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,aAAa;IACb,aAAa;IACb,kBAAkB;IAClB,qBAAqB;IACrB,iBAAiB;IACjB,kBAAkB;IAClB,qBAAqB;IACrB,UAAU;IACV,yBAAyB;IACzB,WAAW;IACX,gBAAgB;IAChB,2BAA2B;IAC3B,0BAA0B;IAC1B,sBAAsB;IACtB,gBAAgB;IAChB,2BAA2B;IAC3B,oBAAoB;IACpB,sBAAsB;IACtB,mBAAmB;IACnB,uBAAuB;IACvB,iBAAiB;IACjB,gBAAgB;IAChB,WAAW;IACX,eAAe;IACf,kBAAkB;IAClB,qBAAqB;IACrB,eAAe;IACf,gBAAgB;IAChB,qBAAqB;IACrB,8BAA8B;IAC9B,4BAA4B;IAC5B,yBAAyB;IACzB,mBAAmB;IACnB,4BAA4B;IAC5B,uBAAuB;IACvB,WAAW;IACX,+BAA+B;IAC/B,mBAAmB;IACnB,cAAc;IACd,kBAAkB;CACnB,CAAC"}
1
+ {"version":3,"file":"error-codes.js","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,gCAAgC;IAChC,wCAAwC;IACxC,aAAa;IACb,aAAa;IACb,kBAAkB;IAClB,mBAAmB;IACnB,qBAAqB;IACrB,iBAAiB;IACjB,kBAAkB;IAClB,qBAAqB;IACrB,UAAU;IACV,6BAA6B;IAC7B,oBAAoB;IACpB,yBAAyB;IACzB,oBAAoB;IACpB,yBAAyB;IACzB,WAAW;IACX,uBAAuB;IACvB,qBAAqB;IACrB,gBAAgB;IAChB,iCAAiC;IACjC,2BAA2B;IAC3B,0BAA0B;IAC1B,sBAAsB;IACtB,gBAAgB;IAChB,gBAAgB;IAChB,2BAA2B;IAC3B,oBAAoB;IACpB,sBAAsB;IACtB,mBAAmB;IACnB,uBAAuB;IACvB,iBAAiB;IACjB,gBAAgB;IAChB,sBAAsB;IACtB,uBAAuB;IACvB,sBAAsB;IACtB,WAAW;IACX,eAAe;IACf,kBAAkB;IAClB,qBAAqB;IACrB,gCAAgC;IAChC,kCAAkC;IAClC,eAAe;IACf,gBAAgB;IAChB,qBAAqB;IACrB,8BAA8B;IAC9B,4BAA4B;IAC5B,yBAAyB;IACzB,mBAAmB;IACnB,4BAA4B;IAC5B,uBAAuB;IACvB,WAAW;IACX,+BAA+B;IAC/B,mBAAmB;IACnB,cAAc;IACd,eAAe;IACf,kBAAkB;CACnB,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { IntentStatusClass } from './intent-states.js';
1
2
  /**
2
3
  * Error taxonomy. `CertenError.code` mirrors the gateway's response.code
3
4
  * field; callers can switch on it for typed retries / user-visible
@@ -55,6 +56,81 @@ export declare class CertenBadRequestError extends CertenError {
55
56
  }
56
57
  export declare class CertenServerError extends CertenError {
57
58
  }
59
+ export declare const HEADER_AUTHORITY_NOT_EXECUTABLE = "HEADER_AUTHORITY_NOT_EXECUTABLE";
60
+ /**
61
+ * The gateway refused `additional_authorities` on an intent. HTTP 422.
62
+ *
63
+ * Refused on purpose, and by default: CERTEN's validators do not yet count a signature from a
64
+ * header authority, so an intent carrying one would sit pending, collect every signature, and then
65
+ * never execute. Accepting it would turn a clear error now into a silent failure later.
66
+ *
67
+ * The remedy is not a retry. Make the party that must co-sign an authority on the ACCOUNT (a key
68
+ * book on the account's authority set, e.g. via `governance` `add_authority`), which validators do
69
+ * enforce; or, for a per-payment participant, have it accept in a separate transaction first.
70
+ */
71
+ export declare class CertenHeaderAuthorityNotExecutableError extends CertenBadRequestError {
72
+ /** What to do instead, in one paragraph. */
73
+ get guidance(): string;
74
+ }
75
+ /**
76
+ * An intent reached a failed state while `execute.wait()` was polling it.
77
+ *
78
+ * `reasonCode` says why (`expired`, `expectation_unmet`, `target_reverted`, …). Status 0: no HTTP
79
+ * request failed — the gateway answered, and its answer was that the intent failed.
80
+ */
81
+ export declare class CertenIntentFailedError extends CertenError {
82
+ readonly intentId: string;
83
+ readonly reasonCode: string | null;
84
+ readonly transaction: unknown;
85
+ constructor(message: string, intentId: string, reasonCode: string | null, transaction: unknown);
86
+ }
87
+ /**
88
+ * `execute.wait()` ran out of time before the intent reached the state it was waiting for.
89
+ *
90
+ * Deliberately neither success nor failure: the intent may still complete, and nothing here says otherwise. `lastStatus` and
91
+ * `lastClass` are what the last poll saw (`executed` means the action ran and the proof is still being produced; `unknown` means
92
+ * the gateway sent a status this client does not recognise), and `transaction` is that last response. Status 0: no HTTP request
93
+ * failed.
94
+ */
95
+ export declare class CertenWaitTimeoutError extends CertenError {
96
+ readonly intentId: string;
97
+ readonly timeoutMs: number;
98
+ /** What the last poll saw, or null when no poll completed. */
99
+ readonly lastStatus: string | null;
100
+ readonly lastClass: IntentStatusClass | null;
101
+ readonly transaction: unknown;
102
+ constructor(message: string, intentId: string, timeoutMs: number,
103
+ /** What the last poll saw, or null when no poll completed. */
104
+ lastStatus: string | null, lastClass: IntentStatusClass | null, transaction: unknown);
105
+ }
106
+ /**
107
+ * `execute.proof()` has nothing to fetch for this intent. Status 0: the gateway answered, and the answer is that no proof exists.
108
+ *
109
+ * `reason` says which kind of nothing it is, because the remedies differ:
110
+ * `proof_pending` the action executed and the proof bundle is still being produced - ask again later.
111
+ * `execution_proof_unavailable` the action executed and its proof can never be produced - there is nothing to wait for.
112
+ * `not_assigned` the intent has neither a `proof_id` nor an Accumulate transaction hash (yet).
113
+ */
114
+ export declare class CertenProofNotAvailableError extends CertenError {
115
+ readonly intentId: string;
116
+ readonly reason: 'proof_pending' | 'execution_proof_unavailable' | 'not_assigned';
117
+ readonly transaction: unknown;
118
+ constructor(message: string, intentId: string, reason: 'proof_pending' | 'execution_proof_unavailable' | 'not_assigned', transaction: unknown);
119
+ }
120
+ /**
121
+ * The client refused to send a request to a url outside its own gateway's origin, before anything was sent.
122
+ *
123
+ * Raised for a url a response told the client to follow (`submit_url`), for any request url that resolves to another origin or
124
+ * carries credentials, and for a redirect to another host. `details.url` is the url that was refused, `details.baseUrl` the
125
+ * origin the client is bound to and `details.source` where the url came from. Status 0, not retryable: repeating it would send
126
+ * the same url, and the safe answer is to distrust whatever produced it.
127
+ */
128
+ export declare class CertenForeignOriginError extends CertenError {
129
+ readonly url: string;
130
+ readonly baseUrl: string;
131
+ readonly source: string;
132
+ constructor(message: string, url: string, baseUrl: string, source: string);
133
+ }
58
134
  /** A live way to settle a 402, minted by the gateway with the refusal. */
59
135
  export interface PaymentResolution {
60
136
  /** Reference the deposit is matched by. */
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnC,SAAgB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClC;;;;;;;OAOG;IACH,SAAgB,IAAI,CAAC,EAAE,OAAO,CAAC;gBAG7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAO;IAWtE;;;;;;;;;;;;OAYG;IACH,IAAI,WAAW,IAAI,OAAO,CASzB;IAED,mEAAmE;IACnE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,gEAAgE;IAChE,MAAM,CAAC,SAAS,CACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KA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AM,GAAG,SAAS,CAEnC;IAED;;;;;;OAMG;IACH,IAAI,OAAO,IAAI,MAAM,CAUpB;CACF"}
package/dist/errors.js CHANGED
@@ -70,6 +70,10 @@ export class CertenError extends Error {
70
70
  // "top up" prompt or a validation message.
71
71
  if (status === 402)
72
72
  return new CertenPaymentRequiredError(message, status, code, opts);
73
+ // By code, not status: the refusal has one remedy whatever status a gateway sends it with.
74
+ if (code === HEADER_AUTHORITY_NOT_EXECUTABLE) {
75
+ return new CertenHeaderAuthorityNotExecutableError(message, status, code, opts);
76
+ }
73
77
  if (status >= 500)
74
78
  return new CertenServerError(message, status, code, opts);
75
79
  if (status >= 400)
@@ -90,6 +94,110 @@ export class CertenBadRequestError extends CertenError {
90
94
  }
91
95
  export class CertenServerError extends CertenError {
92
96
  }
97
+ export const HEADER_AUTHORITY_NOT_EXECUTABLE = 'HEADER_AUTHORITY_NOT_EXECUTABLE';
98
+ /**
99
+ * The gateway refused `additional_authorities` on an intent. HTTP 422.
100
+ *
101
+ * Refused on purpose, and by default: CERTEN's validators do not yet count a signature from a
102
+ * header authority, so an intent carrying one would sit pending, collect every signature, and then
103
+ * never execute. Accepting it would turn a clear error now into a silent failure later.
104
+ *
105
+ * The remedy is not a retry. Make the party that must co-sign an authority on the ACCOUNT (a key
106
+ * book on the account's authority set, e.g. via `governance` `add_authority`), which validators do
107
+ * enforce; or, for a per-payment participant, have it accept in a separate transaction first.
108
+ */
109
+ export class CertenHeaderAuthorityNotExecutableError extends CertenBadRequestError {
110
+ /** What to do instead, in one paragraph. */
111
+ get guidance() {
112
+ return 'Header authorities are refused by default because CERTEN validators do not yet execute '
113
+ + 'intents that carry them. Remove additional_authorities, and put the party that must co-sign '
114
+ + 'on the account\'s authorities instead (governance add_authority on the account), or have it '
115
+ + 'accept in a separate transaction before this intent is opened.';
116
+ }
117
+ }
118
+ /**
119
+ * An intent reached a failed state while `execute.wait()` was polling it.
120
+ *
121
+ * `reasonCode` says why (`expired`, `expectation_unmet`, `target_reverted`, …). Status 0: no HTTP
122
+ * request failed — the gateway answered, and its answer was that the intent failed.
123
+ */
124
+ export class CertenIntentFailedError extends CertenError {
125
+ intentId;
126
+ reasonCode;
127
+ transaction;
128
+ constructor(message, intentId, reasonCode, transaction) {
129
+ super(message, 0, 'INTENT_FAILED', { body: transaction });
130
+ this.intentId = intentId;
131
+ this.reasonCode = reasonCode;
132
+ this.transaction = transaction;
133
+ }
134
+ }
135
+ /**
136
+ * `execute.wait()` ran out of time before the intent reached the state it was waiting for.
137
+ *
138
+ * Deliberately neither success nor failure: the intent may still complete, and nothing here says otherwise. `lastStatus` and
139
+ * `lastClass` are what the last poll saw (`executed` means the action ran and the proof is still being produced; `unknown` means
140
+ * the gateway sent a status this client does not recognise), and `transaction` is that last response. Status 0: no HTTP request
141
+ * failed.
142
+ */
143
+ export class CertenWaitTimeoutError extends CertenError {
144
+ intentId;
145
+ timeoutMs;
146
+ lastStatus;
147
+ lastClass;
148
+ transaction;
149
+ constructor(message, intentId, timeoutMs,
150
+ /** What the last poll saw, or null when no poll completed. */
151
+ lastStatus, lastClass, transaction) {
152
+ super(message, 0, 'WAIT_TIMEOUT', { details: { intentId, timeoutMs, lastStatus, lastClass }, body: transaction });
153
+ this.intentId = intentId;
154
+ this.timeoutMs = timeoutMs;
155
+ this.lastStatus = lastStatus;
156
+ this.lastClass = lastClass;
157
+ this.transaction = transaction;
158
+ this.name = 'CertenWaitTimeoutError';
159
+ }
160
+ }
161
+ /**
162
+ * `execute.proof()` has nothing to fetch for this intent. Status 0: the gateway answered, and the answer is that no proof exists.
163
+ *
164
+ * `reason` says which kind of nothing it is, because the remedies differ:
165
+ * `proof_pending` the action executed and the proof bundle is still being produced - ask again later.
166
+ * `execution_proof_unavailable` the action executed and its proof can never be produced - there is nothing to wait for.
167
+ * `not_assigned` the intent has neither a `proof_id` nor an Accumulate transaction hash (yet).
168
+ */
169
+ export class CertenProofNotAvailableError extends CertenError {
170
+ intentId;
171
+ reason;
172
+ transaction;
173
+ constructor(message, intentId, reason, transaction) {
174
+ super(message, 0, 'PROOF_NOT_ASSIGNED', { details: { intentId, reason }, body: transaction });
175
+ this.intentId = intentId;
176
+ this.reason = reason;
177
+ this.transaction = transaction;
178
+ this.name = 'CertenProofNotAvailableError';
179
+ }
180
+ }
181
+ /**
182
+ * The client refused to send a request to a url outside its own gateway's origin, before anything was sent.
183
+ *
184
+ * Raised for a url a response told the client to follow (`submit_url`), for any request url that resolves to another origin or
185
+ * carries credentials, and for a redirect to another host. `details.url` is the url that was refused, `details.baseUrl` the
186
+ * origin the client is bound to and `details.source` where the url came from. Status 0, not retryable: repeating it would send
187
+ * the same url, and the safe answer is to distrust whatever produced it.
188
+ */
189
+ export class CertenForeignOriginError extends CertenError {
190
+ url;
191
+ baseUrl;
192
+ source;
193
+ constructor(message, url, baseUrl, source) {
194
+ super(message, 0, 'FOREIGN_ORIGIN_URL', { details: { url, baseUrl, source } });
195
+ this.url = url;
196
+ this.baseUrl = baseUrl;
197
+ this.source = source;
198
+ this.name = 'CertenForeignOriginError';
199
+ }
200
+ }
93
201
  /**
94
202
  * The account cannot pay for this work. HTTP 402.
95
203
  *
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;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,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,C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C,CAAC,oCAAoC,CAAC;IAC3C,CAAC;CACF"}
@@ -0,0 +1,55 @@
1
+ /**
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,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