@getomnichain/omnichain 0.6.2 → 0.7.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 +69 -0
- package/dist/cjs/chain_ids.js +2 -2
- package/dist/cjs/chain_ids.js.map +1 -1
- package/dist/cjs/errors.js +6 -0
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/ton/index.js +12 -0
- package/dist/cjs/ton/index.js.map +1 -1
- package/dist/cjs/ton/ton_address.js +72 -14
- package/dist/cjs/ton/ton_address.js.map +1 -1
- package/dist/cjs/ton/ton_asset.js +21 -0
- package/dist/cjs/ton/ton_asset.js.map +1 -0
- package/dist/cjs/ton/ton_assets.js +10 -0
- package/dist/cjs/ton/ton_assets.js.map +1 -0
- package/dist/cjs/ton/ton_chain.js +483 -0
- package/dist/cjs/ton/ton_chain.js.map +1 -0
- package/dist/cjs/ton/ton_chains.js +21 -0
- package/dist/cjs/ton/ton_chains.js.map +1 -0
- package/dist/cjs/ton/ton_jetton_metadata.js +107 -0
- package/dist/cjs/ton/ton_jetton_metadata.js.map +1 -0
- package/dist/cjs/ton/ton_messages.js +174 -0
- package/dist/cjs/ton/ton_messages.js.map +1 -0
- package/dist/cjs/ton/ton_provider.js +456 -0
- package/dist/cjs/ton/ton_provider.js.map +1 -0
- package/dist/cjs/ton/ton_tonapi.js +243 -0
- package/dist/cjs/ton/ton_tonapi.js.map +1 -0
- package/dist/cjs/ton/ton_toncenter.js +252 -0
- package/dist/cjs/ton/ton_toncenter.js.map +1 -0
- package/dist/cjs/ton/ton_transaction_status.js +231 -0
- package/dist/cjs/ton/ton_transaction_status.js.map +1 -0
- package/dist/cjs/ton/ton_transactions.js +107 -0
- package/dist/cjs/ton/ton_transactions.js.map +1 -0
- package/dist/cjs/ton/ton_wallet.js +285 -0
- package/dist/cjs/ton/ton_wallet.js.map +1 -0
- package/dist/cjs/tron/index.js +1 -0
- package/dist/cjs/tron/index.js.map +1 -1
- package/dist/cjs/tron/tron_chain.js +88 -45
- package/dist/cjs/tron/tron_chain.js.map +1 -1
- package/dist/cjs/tron/tron_memo.js +17 -0
- package/dist/cjs/tron/tron_memo.js.map +1 -0
- package/dist/cjs/tron/tron_raw_data.js +213 -0
- package/dist/cjs/tron/tron_raw_data.js.map +1 -0
- package/dist/cjs/tron/tron_transaction_builder.js +34 -13
- package/dist/cjs/tron/tron_transaction_builder.js.map +1 -1
- package/dist/cjs/tron/tron_transaction_status.js +10 -7
- package/dist/cjs/tron/tron_transaction_status.js.map +1 -1
- package/dist/cjs/tron/tron_transactions.js +1 -1
- package/dist/cjs/tron/tron_transactions.js.map +1 -1
- package/dist/esm/chain_ids.js +2 -2
- package/dist/esm/chain_ids.js.map +1 -1
- package/dist/esm/errors.d.ts +3 -0
- package/dist/esm/errors.d.ts.map +1 -1
- package/dist/esm/errors.js +5 -0
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/ton/index.d.ts +12 -0
- package/dist/esm/ton/index.d.ts.map +1 -1
- package/dist/esm/ton/index.js +12 -0
- package/dist/esm/ton/index.js.map +1 -1
- package/dist/esm/ton/ton_address.d.ts +26 -2
- package/dist/esm/ton/ton_address.d.ts.map +1 -1
- package/dist/esm/ton/ton_address.js +70 -14
- package/dist/esm/ton/ton_address.js.map +1 -1
- package/dist/esm/ton/ton_asset.d.ts +12 -0
- package/dist/esm/ton/ton_asset.d.ts.map +1 -0
- package/dist/esm/ton/ton_asset.js +17 -0
- package/dist/esm/ton/ton_asset.js.map +1 -0
- package/dist/esm/ton/ton_assets.d.ts +6 -0
- package/dist/esm/ton/ton_assets.d.ts.map +1 -0
- package/dist/esm/ton/ton_assets.js +7 -0
- package/dist/esm/ton/ton_assets.js.map +1 -0
- package/dist/esm/ton/ton_chain.d.ts +205 -0
- package/dist/esm/ton/ton_chain.d.ts.map +1 -0
- package/dist/esm/ton/ton_chain.js +479 -0
- package/dist/esm/ton/ton_chain.js.map +1 -0
- package/dist/esm/ton/ton_chains.d.ts +11 -0
- package/dist/esm/ton/ton_chains.d.ts.map +1 -0
- package/dist/esm/ton/ton_chains.js +18 -0
- package/dist/esm/ton/ton_chains.js.map +1 -0
- package/dist/esm/ton/ton_jetton_metadata.d.ts +36 -0
- package/dist/esm/ton/ton_jetton_metadata.d.ts.map +1 -0
- package/dist/esm/ton/ton_jetton_metadata.js +103 -0
- package/dist/esm/ton/ton_jetton_metadata.js.map +1 -0
- package/dist/esm/ton/ton_messages.d.ts +133 -0
- package/dist/esm/ton/ton_messages.d.ts.map +1 -0
- package/dist/esm/ton/ton_messages.js +159 -0
- package/dist/esm/ton/ton_messages.js.map +1 -0
- package/dist/esm/ton/ton_provider.d.ts +261 -0
- package/dist/esm/ton/ton_provider.d.ts.map +1 -0
- package/dist/esm/ton/ton_provider.js +432 -0
- package/dist/esm/ton/ton_provider.js.map +1 -0
- package/dist/esm/ton/ton_tonapi.d.ts +39 -0
- package/dist/esm/ton/ton_tonapi.d.ts.map +1 -0
- package/dist/esm/ton/ton_tonapi.js +239 -0
- package/dist/esm/ton/ton_tonapi.js.map +1 -0
- package/dist/esm/ton/ton_toncenter.d.ts +25 -0
- package/dist/esm/ton/ton_toncenter.d.ts.map +1 -0
- package/dist/esm/ton/ton_toncenter.js +248 -0
- package/dist/esm/ton/ton_toncenter.js.map +1 -0
- package/dist/esm/ton/ton_transaction_status.d.ts +116 -0
- package/dist/esm/ton/ton_transaction_status.d.ts.map +1 -0
- package/dist/esm/ton/ton_transaction_status.js +226 -0
- package/dist/esm/ton/ton_transaction_status.js.map +1 -0
- package/dist/esm/ton/ton_transactions.d.ts +54 -0
- package/dist/esm/ton/ton_transactions.d.ts.map +1 -0
- package/dist/esm/ton/ton_transactions.js +100 -0
- package/dist/esm/ton/ton_transactions.js.map +1 -0
- package/dist/esm/ton/ton_wallet.d.ts +134 -0
- package/dist/esm/ton/ton_wallet.d.ts.map +1 -0
- package/dist/esm/ton/ton_wallet.js +278 -0
- package/dist/esm/ton/ton_wallet.js.map +1 -0
- package/dist/esm/tron/index.d.ts +1 -0
- package/dist/esm/tron/index.d.ts.map +1 -1
- package/dist/esm/tron/index.js +1 -0
- package/dist/esm/tron/index.js.map +1 -1
- package/dist/esm/tron/tron_chain.d.ts +13 -1
- package/dist/esm/tron/tron_chain.d.ts.map +1 -1
- package/dist/esm/tron/tron_chain.js +89 -46
- package/dist/esm/tron/tron_chain.js.map +1 -1
- package/dist/esm/tron/tron_memo.d.ts +2 -0
- package/dist/esm/tron/tron_memo.d.ts.map +1 -0
- package/dist/esm/tron/tron_memo.js +14 -0
- package/dist/esm/tron/tron_memo.js.map +1 -0
- package/dist/esm/tron/tron_raw_data.d.ts +4 -0
- package/dist/esm/tron/tron_raw_data.d.ts.map +1 -0
- package/dist/esm/tron/tron_raw_data.js +209 -0
- package/dist/esm/tron/tron_raw_data.js.map +1 -0
- package/dist/esm/tron/tron_transaction_builder.d.ts +4 -0
- package/dist/esm/tron/tron_transaction_builder.d.ts.map +1 -1
- package/dist/esm/tron/tron_transaction_builder.js +34 -13
- package/dist/esm/tron/tron_transaction_builder.js.map +1 -1
- package/dist/esm/tron/tron_transaction_status.d.ts +16 -2
- package/dist/esm/tron/tron_transaction_status.d.ts.map +1 -1
- package/dist/esm/tron/tron_transaction_status.js +10 -7
- package/dist/esm/tron/tron_transaction_status.js.map +1 -1
- package/dist/esm/tron/tron_transactions.js +1 -1
- package/dist/esm/tron/tron_transactions.js.map +1 -1
- package/docs/README.md +2 -1
- package/docs/ton.md +164 -0
- package/docs/tron.md +21 -11
- package/package.json +5 -1
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { Cell as CoreCell } from '@ton/core';
|
|
2
|
+
import { ChainError, ChainErrorKinds } from "../errors.js";
|
|
3
|
+
import { tonNormalizedExternalHash } from "./ton_messages.js";
|
|
4
|
+
/**
|
|
5
|
+
* A provider failure. `retryable` is true only for failures that say nothing
|
|
6
|
+
* about the answer (transport, timeout, 429, 5xx); the fallback retries those
|
|
7
|
+
* and nothing else.
|
|
8
|
+
*/
|
|
9
|
+
export class TonProviderError extends ChainError {
|
|
10
|
+
retryable;
|
|
11
|
+
constructor(kind, message, retryable, meta, cause) {
|
|
12
|
+
super(kind, message, meta, cause);
|
|
13
|
+
this.name = 'TonProviderError';
|
|
14
|
+
this.retryable = retryable;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A broadcast whose outcome is unknown: a provider failed without an answer,
|
|
19
|
+
* so the message may have reached the network even if another provider then
|
|
20
|
+
* refused it (a refusal can mean it was already accepted). Read the status of
|
|
21
|
+
* `meta.txHash`, or wait until the request is expired, before signing again.
|
|
22
|
+
*/
|
|
23
|
+
export class TonBroadcastUncertainError extends TonProviderError {
|
|
24
|
+
constructor(message, meta, cause) {
|
|
25
|
+
super(ChainErrorKinds.BroadcastUncertain, message, false, meta, cause);
|
|
26
|
+
this.name = 'TonBroadcastUncertainError';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* TON Center v3 first; TonAPI only when TON Center fails without an answer.
|
|
31
|
+
*
|
|
32
|
+
* A definite answer from the primary (not found, a refused emulation, a
|
|
33
|
+
* refused broadcast) is final. A broadcast retried on the fallback sends the
|
|
34
|
+
* same BOC: the wallet's seqno makes a second landing impossible.
|
|
35
|
+
*/
|
|
36
|
+
export class TonFallbackProvider {
|
|
37
|
+
primary;
|
|
38
|
+
fallback;
|
|
39
|
+
onFallback;
|
|
40
|
+
name;
|
|
41
|
+
constructor(primary, fallback, onFallback = () => { }) {
|
|
42
|
+
this.primary = primary;
|
|
43
|
+
this.fallback = fallback;
|
|
44
|
+
this.onFallback = onFallback;
|
|
45
|
+
this.name = fallback === null ? primary.name : `${primary.name}+${fallback.name}`;
|
|
46
|
+
}
|
|
47
|
+
getAccountState(address) {
|
|
48
|
+
return this.call('getAccountState', (p) => p.getAccountState(address));
|
|
49
|
+
}
|
|
50
|
+
getSeqno(address) {
|
|
51
|
+
return this.call('getSeqno', (p) => p.getSeqno(address));
|
|
52
|
+
}
|
|
53
|
+
getJettonWalletAddress(jettonMaster, owner) {
|
|
54
|
+
return this.call('getJettonWalletAddress', (p) => p.getJettonWalletAddress(jettonMaster, owner));
|
|
55
|
+
}
|
|
56
|
+
getJettonBalance(jettonWallet) {
|
|
57
|
+
return this.call('getJettonBalance', (p) => p.getJettonBalance(jettonWallet));
|
|
58
|
+
}
|
|
59
|
+
getJettonContent(jettonMaster) {
|
|
60
|
+
return this.call('getJettonContent', (p) => p.getJettonContent(jettonMaster));
|
|
61
|
+
}
|
|
62
|
+
getJettonWalletData(jettonWallet) {
|
|
63
|
+
return this.call('getJettonWalletData', (p) => p.getJettonWalletData(jettonWallet));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A refusal is definite only when no provider failed before it: once one
|
|
67
|
+
* failed without an answer, the message may already be in flight, and a
|
|
68
|
+
* later refusal may be the network rejecting a duplicate.
|
|
69
|
+
*/
|
|
70
|
+
async sendBoc(boc) {
|
|
71
|
+
try {
|
|
72
|
+
await this.primary.sendBoc(boc);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
if (!(err instanceof TonProviderError) || !err.retryable)
|
|
77
|
+
throw err;
|
|
78
|
+
if (this.fallback === null)
|
|
79
|
+
throw new TonBroadcastUncertainError(`broadcast outcome unknown: ${err.message}`, undefined, err);
|
|
80
|
+
this.onFallback('sendBoc', err);
|
|
81
|
+
try {
|
|
82
|
+
await this.fallback.sendBoc(boc);
|
|
83
|
+
}
|
|
84
|
+
catch (fallbackErr) {
|
|
85
|
+
throw new TonBroadcastUncertainError(`broadcast outcome unknown: ${err.message}; then ${fallbackErr.message}`, undefined, fallbackErr);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
getTrace(hash) {
|
|
90
|
+
return this.call('getTrace', (p) => p.getTrace(hash));
|
|
91
|
+
}
|
|
92
|
+
emulate(boc) {
|
|
93
|
+
return this.call('emulate', (p) => p.emulate(boc));
|
|
94
|
+
}
|
|
95
|
+
getMasterchainHead() {
|
|
96
|
+
return this.call('getMasterchainHead', (p) => p.getMasterchainHead());
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Runs several reads on one provider throughout: the primary, or — when any
|
|
100
|
+
* of them fails without an answer — all of them again on the fallback. Reads
|
|
101
|
+
* that must see the chain at one point never mix providers that lag
|
|
102
|
+
* differently.
|
|
103
|
+
*/
|
|
104
|
+
onOneProvider(method, run) {
|
|
105
|
+
return this.call(method, run);
|
|
106
|
+
}
|
|
107
|
+
async call(method, run) {
|
|
108
|
+
try {
|
|
109
|
+
return await run(this.primary);
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
if (this.fallback === null || !(err instanceof TonProviderError) || !err.retryable)
|
|
113
|
+
throw err;
|
|
114
|
+
this.onFallback(method, err);
|
|
115
|
+
return run(this.fallback);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const DEFAULT_TIMEOUT_MS = 10_000;
|
|
120
|
+
/** Enough of an error reply to keep the lite server's exit code, which follows a long preamble. */
|
|
121
|
+
const ERROR_TEXT_LIMIT = 1_000;
|
|
122
|
+
/** One JSON request; maps every failure to a {@link TonProviderError}. Returns `null` on a 404. */
|
|
123
|
+
export async function tonHttpJson(provider, endpoint, path, init) {
|
|
124
|
+
const url = `${endpoint.url.replace(/\/$/, '')}${path}`;
|
|
125
|
+
let response;
|
|
126
|
+
try {
|
|
127
|
+
response = await fetch(url, {
|
|
128
|
+
method: init.method ?? 'GET',
|
|
129
|
+
headers: { accept: 'application/json', ...(init.body === undefined ? {} : { 'content-type': 'application/json' }), ...init.headers },
|
|
130
|
+
body: init.body === undefined ? undefined : JSON.stringify(init.body),
|
|
131
|
+
signal: AbortSignal.timeout(endpoint.timeoutMs ?? DEFAULT_TIMEOUT_MS),
|
|
132
|
+
redirect: 'error',
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
throw new TonProviderError(ChainErrorKinds.RpcError, `${provider} ${path} request failed: ${err.message}`, true, undefined, err);
|
|
137
|
+
}
|
|
138
|
+
const text = await response.text();
|
|
139
|
+
if (response.status === 404)
|
|
140
|
+
return null;
|
|
141
|
+
if (response.status === 429 || response.status >= 500) {
|
|
142
|
+
throw new TonProviderError(ChainErrorKinds.RpcError, `${provider} ${path} answered HTTP ${response.status}: ${text.slice(0, ERROR_TEXT_LIMIT)}`, true);
|
|
143
|
+
}
|
|
144
|
+
let payload;
|
|
145
|
+
try {
|
|
146
|
+
payload = text.length === 0 ? {} : JSON.parse(text);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
throw new TonProviderError(ChainErrorKinds.RpcError, `${provider} ${path} answered non-JSON (HTTP ${response.status})`, true);
|
|
150
|
+
}
|
|
151
|
+
if (response.status >= 400) {
|
|
152
|
+
const message = errorMessageOf(payload) ?? text.slice(0, ERROR_TEXT_LIMIT);
|
|
153
|
+
throw new TonProviderError(ChainErrorKinds.RpcError, `${provider} ${path} refused (HTTP ${response.status}): ${message}`, false);
|
|
154
|
+
}
|
|
155
|
+
return payload;
|
|
156
|
+
}
|
|
157
|
+
const EXTERNAL_MESSAGE_REFUSED = /cannot apply external message/i;
|
|
158
|
+
const EXTERNAL_MESSAGE_DUPLICATE = /duplicate message/i;
|
|
159
|
+
const REFUSAL_EXIT_CODE = /exit\s*code\s*[=:]?\s*(-?\d+)/i;
|
|
160
|
+
/**
|
|
161
|
+
* The wallets' refusals of an external request, by exit code.
|
|
162
|
+
*
|
|
163
|
+
* W5R1 checks the signature, then the seqno (133), the wallet id, then
|
|
164
|
+
* `valid_until`: a message that already landed fails on the seqno, and only
|
|
165
|
+
* there — every later refusal means the seqno still matched.
|
|
166
|
+
*
|
|
167
|
+
* v3r2 and v4r2 check `valid_until` first (v3r2: 35, which is also its bad
|
|
168
|
+
* signature; v4r2: 36), then the seqno (33), the wallet id (34), the
|
|
169
|
+
* signature (35). An expiry refusal therefore says nothing about whether the
|
|
170
|
+
* message landed earlier.
|
|
171
|
+
*/
|
|
172
|
+
const SEQNO_MOVED_EXIT_CODES = new Set([133, 33]);
|
|
173
|
+
/**
|
|
174
|
+
* The account refused to run the request at all — typically it holds nothing
|
|
175
|
+
* to pay for it, as a wallet that sent everything away does. No check ran, so
|
|
176
|
+
* this says nothing about whether the same request landed earlier.
|
|
177
|
+
*/
|
|
178
|
+
const REFUSED_BEFORE_EXECUTION = /before smart-contract execution/i;
|
|
179
|
+
const MAYBE_LANDED_EXIT_CODES = new Set([35, 36]);
|
|
180
|
+
/**
|
|
181
|
+
* The reply to a broadcast, read for what the lite server said rather than
|
|
182
|
+
* the HTTP status (both answers come as HTTP 500 from TON Center, and from
|
|
183
|
+
* TonAPI as 500 or 406):
|
|
184
|
+
* - "duplicate message": the network already has this exact message, so the
|
|
185
|
+
* broadcast succeeded;
|
|
186
|
+
* - "cannot apply external message": the wallet does not accept it now. On a
|
|
187
|
+
* seqno check (W5 133, v3r2 / v4r2 33) this is `NonceTooLow` — this
|
|
188
|
+
* message or another with its seqno already landed, so read the status
|
|
189
|
+
* before signing again; on a v3r2 / v4r2 expiry (35, 36), or a refusal "before
|
|
190
|
+
* smart-contract execution" (an account that cannot pay to run it), it may
|
|
191
|
+
* have landed earlier, so it is `BroadcastUncertain`; any other refusal is
|
|
192
|
+
* a definite `BroadcastRejected`.
|
|
193
|
+
*/
|
|
194
|
+
export async function tonBroadcastReply(provider, reply) {
|
|
195
|
+
try {
|
|
196
|
+
return await reply;
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
if (!(err instanceof TonProviderError))
|
|
200
|
+
throw err;
|
|
201
|
+
if (EXTERNAL_MESSAGE_DUPLICATE.test(err.message))
|
|
202
|
+
return {};
|
|
203
|
+
if (EXTERNAL_MESSAGE_REFUSED.test(err.message)) {
|
|
204
|
+
if (REFUSED_BEFORE_EXECUTION.test(err.message)) {
|
|
205
|
+
throw new TonBroadcastUncertainError(`${provider} refused the message before running it (the account cannot pay for it); it may be a request that landed earlier: ${err.message}`, undefined, err);
|
|
206
|
+
}
|
|
207
|
+
const exitCode = Number(REFUSAL_EXIT_CODE.exec(err.message)?.[1]);
|
|
208
|
+
if (MAYBE_LANDED_EXIT_CODES.has(exitCode)) {
|
|
209
|
+
throw new TonBroadcastUncertainError(`${provider} refused the message as expired (v3r2 / v4r2 check that first, so it may have landed earlier) or for its signature: ${err.message}`, undefined, err);
|
|
210
|
+
}
|
|
211
|
+
if (SEQNO_MOVED_EXIT_CODES.has(exitCode)) {
|
|
212
|
+
throw new TonProviderError(ChainErrorKinds.NonceTooLow, `${provider} refused the message: the wallet's seqno has moved past it, so it or another request with its seqno landed: ${err.message}`, false, undefined, err);
|
|
213
|
+
}
|
|
214
|
+
throw new TonProviderError(ChainErrorKinds.BroadcastRejected, `${provider} refused the message: ${err.message}`, false, undefined, err);
|
|
215
|
+
}
|
|
216
|
+
throw err;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/** The `error` field some replies carry with a 2xx status. */
|
|
220
|
+
export function errorMessageOf(payload) {
|
|
221
|
+
if (payload === null || typeof payload !== 'object')
|
|
222
|
+
return null;
|
|
223
|
+
const error = payload.error;
|
|
224
|
+
return typeof error === 'string' && error.length > 0 ? error : null;
|
|
225
|
+
}
|
|
226
|
+
export function asRecord(value, what) {
|
|
227
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
|
|
228
|
+
throw new TonProviderError(ChainErrorKinds.RpcError, `Malformed TON provider reply: ${what} is not an object`, false);
|
|
229
|
+
}
|
|
230
|
+
return value;
|
|
231
|
+
}
|
|
232
|
+
export function asBigInt(value, what) {
|
|
233
|
+
if (typeof value === 'bigint')
|
|
234
|
+
return value;
|
|
235
|
+
if ((typeof value === 'number' && Number.isInteger(value)) || (typeof value === 'string' && /^-?(\d+|0x[0-9a-fA-F]+)$/.test(value))) {
|
|
236
|
+
return BigInt(value);
|
|
237
|
+
}
|
|
238
|
+
if (value === undefined || value === null)
|
|
239
|
+
return 0n;
|
|
240
|
+
throw new TonProviderError(ChainErrorKinds.RpcError, `Malformed TON provider reply: ${what} is not an integer`, false);
|
|
241
|
+
}
|
|
242
|
+
/** A required integer field; a reply without one says nothing definite, so the fallback is asked. */
|
|
243
|
+
export function asRequiredInteger(value, what) {
|
|
244
|
+
const parsed = typeof value === 'number' ? value : typeof value === 'string' && /^-?\d+$/.test(value) ? Number(value) : NaN;
|
|
245
|
+
if (!Number.isSafeInteger(parsed)) {
|
|
246
|
+
throw new TonProviderError(ChainErrorKinds.RpcError, `Malformed TON provider reply: ${what} is missing or not an integer`, true);
|
|
247
|
+
}
|
|
248
|
+
return parsed;
|
|
249
|
+
}
|
|
250
|
+
function malformed(what) {
|
|
251
|
+
return new TonProviderError(ChainErrorKinds.RpcError, `Malformed TON provider reply: ${what}`, true);
|
|
252
|
+
}
|
|
253
|
+
/** A required object field; a reply without one says nothing definite, so the fallback is asked. */
|
|
254
|
+
export function asRequiredRecord(value, what) {
|
|
255
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
256
|
+
throw malformed(`${what} is missing or not an object`);
|
|
257
|
+
return value;
|
|
258
|
+
}
|
|
259
|
+
/** A get-method stack entry that is a cell or slice: TON Center gives base64 (`value`), TonAPI hex (`cell`). */
|
|
260
|
+
export function stackCellOf(item, what) {
|
|
261
|
+
const entry = asRequiredRecord(item, what);
|
|
262
|
+
if (entry.type !== 'cell' && entry.type !== 'slice')
|
|
263
|
+
throw malformed(`${what} is not a cell`);
|
|
264
|
+
try {
|
|
265
|
+
if (typeof entry.value === 'string')
|
|
266
|
+
return CoreCell.fromBase64(entry.value);
|
|
267
|
+
if (typeof entry.cell === 'string')
|
|
268
|
+
return CoreCell.fromBoc(Buffer.from(entry.cell, 'hex'))[0];
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
throw malformed(`${what} is not a valid cell`);
|
|
272
|
+
}
|
|
273
|
+
throw malformed(`${what} carries no cell`);
|
|
274
|
+
}
|
|
275
|
+
/** `get_wallet_data`'s stack — balance, owner, master, code — as both providers give it. */
|
|
276
|
+
export function jettonWalletDataOf(stack) {
|
|
277
|
+
if (!Array.isArray(stack) || stack.length < 3)
|
|
278
|
+
throw malformed('get_wallet_data returned a short stack');
|
|
279
|
+
const balanceEntry = asRequiredRecord(stack[0], 'jetton balance');
|
|
280
|
+
const balance = asBigInt(balanceEntry.value ?? balanceEntry.num, 'jetton balance');
|
|
281
|
+
try {
|
|
282
|
+
return {
|
|
283
|
+
balance,
|
|
284
|
+
owner: stackCellOf(stack[1], 'jetton wallet owner').beginParse().loadAddress().toRawString(),
|
|
285
|
+
jettonMaster: stackCellOf(stack[2], 'jetton master').beginParse().loadAddress().toRawString(),
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
catch (err) {
|
|
289
|
+
if (err instanceof TonProviderError)
|
|
290
|
+
throw err;
|
|
291
|
+
throw malformed('get_wallet_data returned no addresses');
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/** A required boolean field; see {@link asRequiredRecord}. */
|
|
295
|
+
export function asRequiredBoolean(value, what) {
|
|
296
|
+
if (typeof value !== 'boolean')
|
|
297
|
+
throw malformed(`${what} is missing or not a boolean`);
|
|
298
|
+
return value;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* A transaction succeeds when its compute phase succeeded — or was skipped
|
|
302
|
+
* only because the account has no code yet — and its action phase, if any,
|
|
303
|
+
* succeeded without skipping a message. Phases that cannot be what the chain
|
|
304
|
+
* recorded (a successful compute phase without an action phase) are a
|
|
305
|
+
* malformed reply, never a success.
|
|
306
|
+
*/
|
|
307
|
+
export function tonTransactionOutcome(phases) {
|
|
308
|
+
const ran = phases.computeSkipped === null;
|
|
309
|
+
if (ran && phases.computeSuccess && phases.action === null)
|
|
310
|
+
throw malformed('a compute phase that succeeded has no action phase');
|
|
311
|
+
if ((!ran || !phases.computeSuccess) && phases.action !== null)
|
|
312
|
+
throw malformed('an action phase follows a compute phase that did not succeed');
|
|
313
|
+
const computeOk = ran ? phases.computeSuccess : phases.computeSkipped === 'no_state';
|
|
314
|
+
const skippedActions = phases.action?.skippedActions ?? 0;
|
|
315
|
+
return {
|
|
316
|
+
success: computeOk && (phases.action === null || (phases.action.success && skippedActions === 0)),
|
|
317
|
+
skippedActions,
|
|
318
|
+
aborted: phases.aborted,
|
|
319
|
+
computeExitCode: ran ? phases.computeExitCode : null,
|
|
320
|
+
actionResultCode: phases.action?.resultCode ?? null,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
/** An account's status as the provider stated it; anything else says nothing definite. */
|
|
324
|
+
export function asStatedAccountStatus(value) {
|
|
325
|
+
if (value === 'active' || value === 'frozen' || value === 'uninit' || value === 'nonexist')
|
|
326
|
+
return value;
|
|
327
|
+
throw new TonProviderError(ChainErrorKinds.RpcError, `Malformed TON provider reply: unknown account status ${String(value)}`, true);
|
|
328
|
+
}
|
|
329
|
+
export function asAccountStatus(value) {
|
|
330
|
+
return value === 'active' || value === 'frozen' || value === 'uninit' || value === 'nonexist' ? value : 'nonexist';
|
|
331
|
+
}
|
|
332
|
+
/** A decoded message in the trace form (raw addresses, opcode from the body). */
|
|
333
|
+
export function tonTraceMessageOf(message) {
|
|
334
|
+
const info = message.info;
|
|
335
|
+
const body = message.body.bits.length === 0 && message.body.refs.length === 0 ? null : message.body;
|
|
336
|
+
return {
|
|
337
|
+
source: info.type === 'external-in' || info.src === null ? null : info.src.toRawString(),
|
|
338
|
+
destination: info.type === 'external-out' ? null : info.dest.toRawString(),
|
|
339
|
+
value: info.type === 'internal' ? info.value.coins : 0n,
|
|
340
|
+
fwdFee: info.type === 'internal' ? info.forwardFee : 0n,
|
|
341
|
+
bounce: info.type === 'internal' && info.bounce,
|
|
342
|
+
bounced: info.type === 'internal' && info.bounced,
|
|
343
|
+
opcode: body !== null && body.bits.length >= 32 ? body.beginParse().loadUint(32) : null,
|
|
344
|
+
createdLt: info.type === 'external-in' ? null : info.createdLt,
|
|
345
|
+
body,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Checks a trace before anything is judged from it. On TON every internal
|
|
350
|
+
* message produces a transaction where it lands, so a provider's trace must
|
|
351
|
+
* hold together:
|
|
352
|
+
* - one root (the first transaction); every other transaction has a parent in
|
|
353
|
+
* the trace and an incoming message. A trace still running may lack a
|
|
354
|
+
* parent, the root included;
|
|
355
|
+
* - every internal message sent names its source and `created_lt`;
|
|
356
|
+
* - every incoming message is one its parent sent: same source, `created_lt`,
|
|
357
|
+
* destination and value;
|
|
358
|
+
* - in a complete trace, every internal message sent has the transaction
|
|
359
|
+
* that received it.
|
|
360
|
+
* A trace that breaks any of these is the provider's error, not the chain's:
|
|
361
|
+
* the error is retryable, so the fallback provider is asked instead, and no
|
|
362
|
+
* gap is ever read as an undelivered message.
|
|
363
|
+
*/
|
|
364
|
+
export function assertTraceConsistent(source, trace) {
|
|
365
|
+
const inconsistent = (detail) => new TonProviderError(ChainErrorKinds.RpcError, `Inconsistent trace from ${source}: ${detail}`, true);
|
|
366
|
+
const byHash = new Map(trace.transactions.map((tx) => [tx.hash, tx]));
|
|
367
|
+
const received = new Set();
|
|
368
|
+
trace.transactions.forEach((tx, index) => {
|
|
369
|
+
const unnamed = tx.outMsgs.find((m) => m.destination !== null && (m.source === null || m.createdLt === null));
|
|
370
|
+
if (unnamed !== undefined)
|
|
371
|
+
throw inconsistent(`transaction ${tx.hash} sent a message to ${unnamed.destination} with no source or created_lt`);
|
|
372
|
+
if (index === 0 && tx.parent === null)
|
|
373
|
+
return;
|
|
374
|
+
if (tx.parent === null)
|
|
375
|
+
throw inconsistent(`transaction ${tx.hash} has no parent but is not the root`);
|
|
376
|
+
if (tx.inMsg === null || tx.inMsg.source === null || tx.inMsg.createdLt === null) {
|
|
377
|
+
throw inconsistent(`transaction ${tx.hash} has no incoming internal message`);
|
|
378
|
+
}
|
|
379
|
+
const parent = byHash.get(tx.parent);
|
|
380
|
+
if (parent === undefined) {
|
|
381
|
+
if (trace.complete)
|
|
382
|
+
throw inconsistent(`transaction ${tx.hash} names a parent ${tx.parent} the trace does not hold`);
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
const inMsg = tx.inMsg;
|
|
386
|
+
const sent = parent.outMsgs.find((m) => m.source === inMsg.source && m.createdLt === inMsg.createdLt);
|
|
387
|
+
if (sent === undefined || sent.destination !== tx.account || sent.value !== inMsg.value) {
|
|
388
|
+
throw inconsistent(`transaction ${tx.hash} received no message its parent ${parent.hash} sent`);
|
|
389
|
+
}
|
|
390
|
+
received.add(`${parent.hash}:${inMsg.createdLt}`);
|
|
391
|
+
});
|
|
392
|
+
if (trace.complete) {
|
|
393
|
+
for (const tx of trace.transactions) {
|
|
394
|
+
const lost = tx.outMsgs.find((m) => m.destination !== null && !received.has(`${tx.hash}:${m.createdLt}`));
|
|
395
|
+
if (lost !== undefined) {
|
|
396
|
+
throw inconsistent(`the trace is complete, but the message ${tx.hash} sent to ${lost.destination} reached no transaction`);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return trace;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* The trace a provider returned for `hash` must be that message's: its root
|
|
404
|
+
* received an external message whose normalized hash is `hash`. A trace still
|
|
405
|
+
* running may not hold its root yet.
|
|
406
|
+
*/
|
|
407
|
+
export function assertTraceOf(source, hash, trace) {
|
|
408
|
+
const root = trace.transactions[0];
|
|
409
|
+
if (root === undefined || root.parent !== null)
|
|
410
|
+
return trace;
|
|
411
|
+
const inMsg = root.inMsg;
|
|
412
|
+
if (inMsg === null || inMsg.source !== null || inMsg.body === null || tonNormalizedExternalHash(root.account, inMsg.body) !== hash) {
|
|
413
|
+
throw new TonProviderError(ChainErrorKinds.RpcError, `${source} returned the trace of another message than ${hash}`, true);
|
|
414
|
+
}
|
|
415
|
+
return trace;
|
|
416
|
+
}
|
|
417
|
+
const TX_HASH_REGEX = /^[0-9a-f]{64}$/;
|
|
418
|
+
/**
|
|
419
|
+
* Refuses anything but a transaction id as the SDK gives it — the normalized
|
|
420
|
+
* external-message hash, 64 lowercase hex characters. A base64 hash or a typo
|
|
421
|
+
* would otherwise find no trace, and "no trace" counts as "never landed".
|
|
422
|
+
*/
|
|
423
|
+
export function assertTonTxHash(hash) {
|
|
424
|
+
if (typeof hash !== 'string' || !TX_HASH_REGEX.test(hash)) {
|
|
425
|
+
throw new TonProviderError(ChainErrorKinds.InvalidArgument, `A TON transaction id is 64 lowercase hex characters, got ${JSON.stringify(hash)}`, false);
|
|
426
|
+
}
|
|
427
|
+
return hash;
|
|
428
|
+
}
|
|
429
|
+
export function definiteError(kind, message) {
|
|
430
|
+
return new TonProviderError(kind, message, false);
|
|
431
|
+
}
|
|
432
|
+
//# sourceMappingURL=ton_provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ton_provider.js","sourceRoot":"","sources":["../../../ton/ton_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,IAAI,IAAI,QAAQ,EAAgB,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,eAAe,EAA4C,MAAM,cAAc,CAAC;AACrG,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAmH9D;;;;GAIG;AACH,MAAM,OAAO,gBAAiB,SAAQ,UAAU;IACrC,SAAS,CAAU;IAE5B,YAAY,IAAoB,EAAE,OAAe,EAAE,SAAkB,EAAE,IAAqB,EAAE,KAAa;QACzG,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QA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IAAI,CAAC,MAAM,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC7D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IACzB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,IAAI,yBAAyB,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;QACnI,MAAM,IAAI,gBAAgB,CAAC,eAAe,CAAC,QAAQ,EAAE,GAAG,MAAM,+CAA+C,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;IAC7H,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAEvC;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,gBAAgB,CACxB,eAAe,CAAC,eAAe,EAC/B,4DAA4D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAClF,KAAK,CACN,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAoB,EAAE,OAAe;IACjE,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Cell } from '@ton/core';
|
|
2
|
+
import { type TonAccountState, type TonHttpEndpoint, type TonJettonWalletData, type TonMasterchainHead, type TonProvider, type TonTrace } from './ton_provider.ts';
|
|
3
|
+
/** TonAPI (`/v2`), the fallback provider. */
|
|
4
|
+
export declare class TonapiProvider implements TonProvider {
|
|
5
|
+
private readonly endpoint;
|
|
6
|
+
readonly name = "TonAPI";
|
|
7
|
+
constructor(endpoint: TonHttpEndpoint);
|
|
8
|
+
getAccountState(address: string): Promise<TonAccountState>;
|
|
9
|
+
getSeqno(address: string): Promise<number>;
|
|
10
|
+
getJettonWalletAddress(jettonMaster: string, owner: string): Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* 0 only for a jetton wallet with no code: TonAPI answers a get-method on
|
|
13
|
+
* one with 404 (or exit code -13), which other failures can also produce, so
|
|
14
|
+
* the account state confirms it. Any other failure throws.
|
|
15
|
+
*/
|
|
16
|
+
getJettonBalance(jettonWallet: string): Promise<bigint>;
|
|
17
|
+
getJettonContent(jettonMaster: string): Promise<Cell>;
|
|
18
|
+
/** `null` only for a jetton wallet with no code, confirmed by the account state as for the balance. */
|
|
19
|
+
getJettonWalletData(jettonWallet: string): Promise<TonJettonWalletData | null>;
|
|
20
|
+
sendBoc(boc: string): Promise<void>;
|
|
21
|
+
getTrace(hash: string): Promise<TonTrace | null>;
|
|
22
|
+
emulate(boc: string): Promise<TonTrace>;
|
|
23
|
+
getMasterchainHead(): Promise<TonMasterchainHead>;
|
|
24
|
+
/**
|
|
25
|
+
* Resolves each transaction's masterchain block: its own block on the
|
|
26
|
+
* masterchain, the shard block's `master_ref` otherwise. TonAPI serves only
|
|
27
|
+
* committed blocks, so a transaction it returns is final; `master_ref` is the
|
|
28
|
+
* masterchain block the shard block points back to, which can be a few
|
|
29
|
+
* blocks before the one TON Center reports as committing it.
|
|
30
|
+
*/
|
|
31
|
+
private withMasterchainSeqnos;
|
|
32
|
+
private masterchainSeqnoOf;
|
|
33
|
+
/** The reply of a get-method that ran, or `null` when the account has no code to run it. */
|
|
34
|
+
private runGetMethod;
|
|
35
|
+
private getMethodPath;
|
|
36
|
+
private get;
|
|
37
|
+
private headers;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=ton_tonapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ton_tonapi.d.ts","sourceRoot":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