crypto-aio 0.2.0 → 1.0.0-rc.1
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 +70 -2
- package/README.md +16 -10
- package/dist/adapters/avalanche/driver.d.ts +4 -0
- package/dist/adapters/avalanche/driver.js.map +1 -1
- package/dist/adapters/avalanche/sdk.d.ts +15 -0
- package/dist/adapters/avalanche/sdk.js.map +1 -1
- package/dist/adapters/evm/plugin.d.ts +1 -0
- package/dist/adapters/evm/plugin.js.map +1 -1
- package/dist/adapters/ton/network.d.ts +1 -0
- package/dist/adapters/ton/network.js +1 -0
- package/dist/adapters/ton/network.js.map +1 -1
- package/dist/adapters/ton/types.d.ts +1 -0
- package/dist/adapters/ton/types.js.map +1 -1
- package/dist/adapters/tron/decode.js +3 -2
- package/dist/adapters/tron/decode.js.map +1 -1
- package/dist/adapters/tron/http.d.ts +6 -0
- package/dist/adapters/tron/http.js +9 -0
- package/dist/adapters/tron/http.js.map +1 -1
- package/dist/adapters/tron/network.d.ts +4 -0
- package/dist/adapters/tron/network.js +4 -0
- package/dist/adapters/tron/network.js.map +1 -1
- package/dist/adapters/tron/proofs.js +6 -2
- package/dist/adapters/tron/proofs.js.map +1 -1
- package/dist/adapters/tron/reader.js +1 -1
- package/dist/adapters/tron/reader.js.map +1 -1
- package/dist/adapters/utxo/driver.d.ts +4 -0
- package/dist/adapters/utxo/driver.js.map +1 -1
- package/dist/adapters/utxo/esplora.d.ts +6 -0
- package/dist/adapters/utxo/esplora.js +20 -3
- package/dist/adapters/utxo/esplora.js.map +1 -1
- package/dist/adapters/utxo/types.d.ts +1 -0
- package/dist/adapters/utxo/types.js.map +1 -1
- package/dist/core/blockchain/handle.d.ts +6 -1
- package/dist/core/blockchain/handle.js +1 -1
- package/dist/core/blockchain/handle.js.map +1 -1
- package/dist/core/config/types.d.ts +64 -0
- package/dist/core/config/types.js.map +1 -1
- package/dist/core/container/container.d.ts +3 -0
- package/dist/core/container/container.js.map +1 -1
- package/dist/core/container/pool.js +12 -0
- package/dist/core/container/pool.js.map +1 -1
- package/dist/core/driver/types.d.ts +124 -7
- package/dist/core/driver/types.js.map +1 -1
- package/dist/core/errors/codes.d.ts +3 -0
- package/dist/core/errors/codes.js.map +1 -1
- package/dist/core/errors/error.d.ts +26 -0
- package/dist/core/errors/error.js +20 -0
- package/dist/core/errors/error.js.map +1 -1
- package/dist/core/events/logger.d.ts +17 -1
- package/dist/core/events/logger.js +5 -1
- package/dist/core/events/logger.js.map +1 -1
- package/dist/core/events/types.d.ts +26 -1
- package/dist/core/events/types.js.map +1 -1
- package/dist/core/lifecycle/engine.d.ts +5 -0
- package/dist/core/lifecycle/engine.js.map +1 -1
- package/dist/core/lifecycle/monitor.d.ts +6 -0
- package/dist/core/lifecycle/monitor.js.map +1 -1
- package/dist/core/lifecycle/views.d.ts +5 -0
- package/dist/core/lifecycle/views.js.map +1 -1
- package/dist/core/lifecycle/workers.d.ts +1 -0
- package/dist/core/lifecycle/workers.js.map +1 -1
- package/dist/core/model/address.d.ts +4 -0
- package/dist/core/model/address.js.map +1 -1
- package/dist/core/model/amount.d.ts +5 -0
- package/dist/core/model/amount.js.map +1 -1
- package/dist/core/model/asset.d.ts +11 -0
- package/dist/core/model/asset.js +2 -0
- package/dist/core/model/asset.js.map +1 -1
- package/dist/core/model/capability.d.ts +6 -0
- package/dist/core/model/capability.js +4 -0
- package/dist/core/model/capability.js.map +1 -1
- package/dist/core/model/chain.d.ts +19 -0
- package/dist/core/model/chain.js +1 -0
- package/dist/core/model/chain.js.map +1 -1
- package/dist/core/model/fee.d.ts +24 -1
- package/dist/core/model/fee.js.map +1 -1
- package/dist/core/model/ids.d.ts +10 -7
- package/dist/core/model/ids.js +1 -0
- package/dist/core/model/ids.js.map +1 -1
- package/dist/core/model/intent.d.ts +13 -0
- package/dist/core/model/intent.js.map +1 -1
- package/dist/core/model/ordering.d.ts +5 -0
- package/dist/core/model/ordering.js.map +1 -1
- package/dist/core/model/transaction.d.ts +39 -0
- package/dist/core/model/transaction.js.map +1 -1
- package/dist/core/observe/scanner.d.ts +10 -1
- package/dist/core/observe/scanner.js +6 -0
- package/dist/core/observe/scanner.js.map +1 -1
- package/dist/core/registry/assets.d.ts +5 -0
- package/dist/core/registry/assets.js.map +1 -1
- package/dist/core/registry/plugin.d.ts +6 -1
- package/dist/core/registry/plugin.js.map +1 -1
- package/dist/core/registry/providers.d.ts +5 -0
- package/dist/core/registry/providers.js.map +1 -1
- package/dist/core/registry/schemes.d.ts +7 -0
- package/dist/core/registry/schemes.js.map +1 -1
- package/dist/core/secret/redact.d.ts +9 -0
- package/dist/core/secret/redact.js +9 -0
- package/dist/core/secret/redact.js.map +1 -1
- package/dist/core/secret/secret.d.ts +4 -0
- package/dist/core/secret/secret.js +4 -0
- package/dist/core/secret/secret.js.map +1 -1
- package/dist/core/signing/callback.d.ts +5 -0
- package/dist/core/signing/callback.js.map +1 -1
- package/dist/core/signing/hd.d.ts +4 -0
- package/dist/core/signing/hd.js.map +1 -1
- package/dist/core/signing/local.d.ts +17 -0
- package/dist/core/signing/local.js +5 -0
- package/dist/core/signing/local.js.map +1 -1
- package/dist/core/signing/types.d.ts +35 -1
- package/dist/core/signing/types.js.map +1 -1
- package/dist/core/store/format.d.ts +3 -3
- package/dist/core/store/format.js +18 -8
- package/dist/core/store/format.js.map +1 -1
- package/dist/core/store/memory.d.ts +11 -0
- package/dist/core/store/memory.js +11 -0
- package/dist/core/store/memory.js.map +1 -1
- package/dist/core/store/types.d.ts +164 -3
- package/dist/core/store/types.js +4 -0
- package/dist/core/store/types.js.map +1 -1
- package/dist/core/transport/http-transport.js +33 -13
- package/dist/core/transport/http-transport.js.map +1 -1
- package/dist/core/transport/types.d.ts +70 -0
- package/dist/core/transport/types.js.map +1 -1
- package/dist/core/util/clock.d.ts +6 -0
- package/dist/core/util/clock.js.map +1 -1
- package/dist/core/util/json.d.ts +6 -0
- package/dist/core/util/json.js +21 -8
- package/dist/core/util/json.js.map +1 -1
- package/dist/testing/contracts/api.d.ts +1 -0
- package/dist/testing/contracts/api.js +1 -0
- package/dist/testing/contracts/api.js.map +1 -1
- package/dist/testing/contracts/cursors.d.ts +5 -0
- package/dist/testing/contracts/cursors.js +4 -0
- package/dist/testing/contracts/cursors.js.map +1 -1
- package/dist/testing/contracts/locks.d.ts +6 -0
- package/dist/testing/contracts/locks.js +5 -0
- package/dist/testing/contracts/locks.js.map +1 -1
- package/dist/testing/contracts/operations.d.ts +11 -0
- package/dist/testing/contracts/operations.js +10 -0
- package/dist/testing/contracts/operations.js.map +1 -1
- package/dist/testing/contracts/sequences.d.ts +5 -0
- package/dist/testing/contracts/sequences.js +4 -0
- package/dist/testing/contracts/sequences.js.map +1 -1
- package/dist/testing/env.d.ts +11 -0
- package/dist/testing/env.js +1 -0
- package/dist/testing/env.js.map +1 -1
- package/dist/testing/fake-chain.d.ts +32 -0
- package/dist/testing/fake-chain.js +11 -0
- package/dist/testing/fake-chain.js.map +1 -1
- package/dist/testing/fake-driver.d.ts +2 -0
- package/dist/testing/fake-driver.js.map +1 -1
- package/dist/testing/fake-fetch.d.ts +6 -0
- package/dist/testing/fake-fetch.js +2 -0
- package/dist/testing/fake-fetch.js.map +1 -1
- package/dist/testing/fake-plugin.d.ts +2 -0
- package/dist/testing/fake-plugin.js +2 -0
- package/dist/testing/fake-plugin.js.map +1 -1
- package/dist/testing/faulty-store.d.ts +2 -0
- package/dist/testing/faulty-store.js +1 -0
- package/dist/testing/faulty-store.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../../src/adapters/tron/decode.ts"],"names":[],"mappings":";;AAkIA,wCAEC;AAGD,oCAMC;AASD,8BA6BC;AA+BD,8CAwGC;AAjSD,iDAAgD;AAChD,+BAA8E;AAC9E,uCAA4C;AAC5C,iCAAkF;AASlF,mFAAmF;AACnF,MAAM,eAAe,GAAgC,IAAI,GAAG,CA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CAAC,CAAC,CAAC,EAAE,CAAC;SAClE;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Chain transactions into `DriverTransaction`s, and the verdict of our own transfers.\n * - General decoding (reads, scans, history) reports execution as the chain does: a TRX\n * transfer is `native`, and so is the TRX a contract call sends; each TRC-20 `Transfer`\n * log is a `token-event` (`log:<i>`); contract execution is `partial` (value may move\n * without a log), a failed transaction moved nothing and is `complete`, and a contract\n * type this model does not carry is `none`.\n * - The verdict of our own Attempts (observe with an ordering, and the proofs) also\n * requires on-chain evidence that value moved: a TRC-20 `transfer(to, amount)` counts\n * only with a `Transfer(owner, to, any positive amount)` log from the called contract.\n * Execution success alone proves nothing: a token can succeed and move nothing, and\n * USDT on Tron returns a zero word from `transfer`.\n * - Verdict fields are read strictly: a missing, ill-typed or contradicting one\n * is a malformed answer (retryable), which decides nothing, never a default. Decoding stays\n * lenient on what the chain accepts: an unknown contract type, a memo of any size or bytes.\n * - `readRaw`'s `timestamp` and `feeLimit` are display only: no verdict or amount uses them.\n * Failure reasons are fixed literals: a node's text can carry addresses or amounts, and a\n * stored reason must never hold either.\n */\nimport type {\n DriverTransaction,\n DriverTransfer,\n DriverTxObservation,\n} from '../../core/driver/types';\nimport type { TxFailure } from '../../core/model/transaction';\nimport { fromHex } from '../../core/util/bytes';\nimport { TRANSFER_TOPIC, decodeTransferCall, decodeTransferLog } from './abi';\nimport { toBase58Address } from './address';\nimport { malformed, notServable, type TronTxInfo, type TronTxJson } from './http';\nimport type { TronCodec, TronContract, TronRawData } from './types';\n\nexport interface TxVerdict {\n readonly success: boolean;\n readonly reason?: string;\n readonly failure?: TxFailure;\n}\n\n/** VM receipt results with a reason of their own; any other failure is generic. */\nconst FAILURE_REASONS: ReadonlyMap<string, string> = new Map([\n ['OUT_OF_ENERGY', 'out of energy'],\n ['REVERT', 'reverted'],\n]);\n\n/** A contract call that also sends TRX or a TRC-10 token: never a plain TRC-20 transfer. */\nfunction carriesValue(contract: TronContract): boolean {\n return (\n contract.type === 'TriggerSmartContract' &&\n (contract.callValue !== undefined ||\n contract.callTokenValue !== undefined ||\n contract.tokenId !== undefined)\n );\n}\n\n/**\n * The chain's own verdict, from strictly read fields (no evidence check). The VM writes a\n * receipt result for every call it runs (`TransactionTrace.setResult`), `ret[0].contractRet`\n * repeats it, and the info's `FAILED` is set exactly when the call did not succeed\n * (`TransactionUtil.buildTransactionInfoInstance`, GreatVoyage-v4.8.2.2 `d5c3d1d1`). Other\n * contracts carry no receipt result: java-tron never includes one whose execution failed,\n * and blocks from 2018 carry no `ret` at all (mainnet block 2,000,000), so inclusion is\n * their success unless the node reports a failure.\n */\nfunction executed(raw: TronRawData | null, tx: TronTxJson, info: TronTxInfo): TxVerdict {\n // Bound to the id asked for: another transaction's receipt decides nothing.\n if (info.id !== tx.id) throw malformed('transaction info');\n const vm = raw\n ? raw.contract.type === 'TriggerSmartContract'\n : info.receiptResult !== undefined;\n if (vm) {\n const result = info.receiptResult;\n if (result === undefined) throw malformed('receipt result');\n if (tx.contractRet !== undefined && tx.contractRet !== result) {\n throw malformed('contractRet');\n }\n if (result !== 'SUCCESS') {\n return {\n success: false,\n reason: FAILURE_REASONS.get(result) ?? 'contract execution failed',\n };\n }\n if (info.failed) throw malformed('result');\n return { success: true };\n }\n if (info.failed || (tx.contractRet !== undefined && tx.contractRet !== 'SUCCESS')) {\n return { success: false, reason: 'execution failed' };\n }\n return { success: true };\n}\n\ntype Evidence = 'landed' | 'absent' | 'unreadable';\n\n/**\n * What the called token logged for a TRC-20 `transfer(to, …)`. `landed`: a `Transfer`\n * from the sender to that recipient of any positive amount, from the called contract.\n * `unreadable`: nothing landed, and the contract logged a `Transfer` event that does not\n * read as one (its value indexed, say).\n * A call with a value, or with data that is not a canonical `transfer`, is `absent`.\n */\nfunction transferEvidence(raw: TronRawData, info: TronTxInfo): Evidence {\n const { contract } = raw;\n if (contract.type !== 'TriggerSmartContract') return 'landed';\n if (carriesValue(contract)) return 'absent';\n const call = decodeTransferCall(contract.data);\n if (call === null) return 'absent';\n const emitter = contract.contract.slice(2);\n let unreadable = false;\n for (const log of info.logs) {\n if (log.address !== emitter) continue;\n const event = decodeTransferLog(log);\n if (event === null) {\n if (log.topics[0] === TRANSFER_TOPIC) unreadable = true;\n } else if (\n event.from === contract.owner &&\n event.to === call.to &&\n event.amount > 0n\n ) {\n return 'landed';\n }\n }\n return unreadable ? 'unreadable' : 'absent';\n}\n\n/**\n * A TRC-20 `transfer(to, …)` counts only if the called token\n * contract logged a `Transfer` from the sender to that recipient. Any positive amount counts:\n * a fee-on-transfer token (Tron USDT has a dormant fee switch) logs less than the call's\n * amount, and requiring the exact amount would prove a transfer that moved `failed`. A call\n * that also sends TRX or a TRC-10 token, or whose data is not a canonical `transfer`, is never\n * a plain TRC-20 transfer. Decoding reports the amounts that actually moved.\n */\nexport function transferLanded(raw: TronRawData, info: TronTxInfo): boolean {\n return transferEvidence(raw, info) === 'landed';\n}\n\n/** The chain's own view of an included transaction (no evidence check: not a verdict). */\nexport function chainVerdict(\n codec: TronCodec,\n tx: TronTxJson,\n info: TronTxInfo,\n): TxVerdict {\n return executed(codec.readRaw(tx.rawHex), tx, info);\n}\n\n/**\n * The verdict of our own included transaction (observe with an ordering, `includedFinal`).\n * The driver built it, so its bytes read, its call is a canonical `transfer` that sends no\n * value, a node's answer for it carries `contractRet`, and a TRX transfer in a block executed;\n * anything else contradicts the signed transaction or the chain's rules and decides nothing\n * (retryable), as does a token `Transfer` event that does not read.\n */\nexport function verdictOf(codec: TronCodec, tx: TronTxJson, info: TronTxInfo): TxVerdict {\n const raw = codec.readRaw(tx.rawHex);\n if (raw === null) throw malformed('raw_data_hex');\n if (tx.contractRet === undefined) throw malformed('contractRet');\n if (carriesValue(raw.contract)) throw malformed('call value');\n // An included TransferContract executed (java-tron never includes one that\n // failed), so any other answer on our own is impossible: a false `failed` on a proof path\n // would invite a second payment. The chain's view reports what the node says.\n if (\n raw.contract.type === 'TransferContract' &&\n (tx.contractRet !== 'SUCCESS' || info.failed)\n ) {\n throw malformed('contractRet');\n }\n // Our own TRC-20 call is a canonical `transfer(to, amount)` (the builder\n // writes nothing else), so other call data contradicts the signed transaction.\n if (\n raw.contract.type === 'TriggerSmartContract' &&\n decodeTransferCall(raw.contract.data) === null\n ) {\n throw malformed('call data');\n }\n const chain = executed(raw, tx, info);\n if (!chain.success) return chain;\n const evidence = transferEvidence(raw, info);\n if (evidence === 'unreadable') throw malformed('Transfer log');\n return evidence === 'landed'\n ? chain\n : { success: false, reason: 'token transfer not evidenced', failure: 'unevidenced' };\n}\n\nconst UTF8 = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });\n\n/**\n * The memo (`raw_data.data`) as text: `undefined` without one, `null` when its bytes are not\n * UTF-8 (replacement characters would make two different memos read the same). Any size the\n * chain accepts reads: the driver's own 256-byte cap applies to what it writes.\n */\nfunction memoOf(raw: TronRawData): string | null | undefined {\n if (raw.data === undefined) return undefined;\n try {\n return UTF8.decode(fromHex(raw.data));\n } catch {\n return null;\n }\n}\n\n/** A canonical `T…` address, or `null` for bytes that are not one (never thrown). */\nfunction base58(hex: string): string | null {\n try {\n return toBase58Address(hex);\n } catch {\n return null;\n }\n}\n\n/**\n * Any transaction as the chain reports it. `info` and `blockHash` come together for an\n * included transaction; `pending` marks one the node holds in its pool.\n */\nexport function decodeTransaction(\n codec: TronCodec,\n tx: TronTxJson,\n info: TronTxInfo | null,\n blockHash: string | undefined,\n pending = false,\n): DriverTransaction {\n if (info !== null && blockHash === undefined) throw notServable();\n const raw = codec.readRaw(tx.rawHex);\n const chain = info ? executed(raw, tx, info) : undefined;\n const observation: DriverTxObservation =\n info && chain && blockHash !== undefined\n ? {\n seen: 'block',\n txHash: tx.id,\n blockHeight: info.blockNumber,\n blockHash,\n success: chain.success,\n ...(chain.reason ? { reason: chain.reason } : {}),\n }\n : pending\n ? { seen: 'mempool', txHash: tx.id }\n : { seen: 'none' };\n const memo = raw ? memoOf(raw) : undefined;\n const owner = raw ? base58(raw.contract.owner) : null;\n const transfers: DriverTransfer[] = [];\n let decoding: DriverTransaction['decoding'] = 'complete';\n /** A movement with the memo; `null` (an address that does not read) is left out. */\n const add = (transfer: Omit<DriverTransfer, 'memo'> | null): void => {\n if (!transfer) decoding = 'partial';\n else transfers.push(typeof memo === 'string' ? { ...transfer, memo } : transfer);\n };\n const native = (to: string, amount: bigint) => {\n const recipient = base58(to);\n add(\n owner && recipient\n ? {\n locator: 'native',\n from: [owner],\n to: recipient,\n asset: 'native',\n amount,\n source: 'native',\n }\n : null,\n );\n };\n if (raw === null) {\n decoding = 'none';\n } else if (!info) {\n decoding = 'partial';\n } else if (chain?.success) {\n if (memo === null) decoding = 'partial';\n const { contract } = raw;\n if (contract.type === 'TransferContract') {\n native(contract.to, contract.amount);\n } else {\n // Value can move without a log (internal transfers), and a TRC-10 value has no asset\n // here: a contract call is partial.\n decoding = 'partial';\n if (contract.callValue !== undefined) native(contract.contract, contract.callValue);\n info.logs.forEach((log, index) => {\n const event = decodeTransferLog(log);\n if (!event) return;\n const from = base58(event.from);\n const to = base58(event.to);\n const token = base58(`41${log.address}`);\n add(\n from && to && token\n ? {\n locator: `log:${index}`,\n from: [from],\n to,\n asset: { standard: 'trc20', contract: token },\n amount: event.amount,\n source: 'token-event',\n }\n : null,\n );\n });\n }\n }\n const call = raw?.contract.type === 'TriggerSmartContract' ? raw.contract : undefined;\n return {\n id: tx.id,\n observation,\n ...(info ? { fee: [{ asset: 'native' as const, amount: info.fee }] } : {}),\n transfers,\n decoding,\n // The block's time: the client-set `raw_data.timestamp` is display only.\n ...(info ? { timestamp: info.blockTimestamp } : {}),\n details: {\n contract: raw?.contract.type ?? 'unknown',\n ...(owner ? { owner } : {}),\n ...(tx.contractRet !== undefined ? { result: tx.contractRet } : {}),\n ...(info?.receiptResult !== undefined ? { receipt: info.receiptResult } : {}),\n ...(raw?.feeLimit !== undefined ? { feeLimit: BigInt(raw.feeLimit) } : {}),\n ...(call?.callValue !== undefined ? { callValue: call.callValue } : {}),\n ...(call?.callTokenValue !== undefined\n ? { callTokenValue: call.callTokenValue }\n : {}),\n ...(call?.tokenId !== undefined ? { tokenId: call.tokenId } : {}),\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../../src/adapters/tron/decode.ts"],"names":[],"mappings":";;AAwIA,wCAEC;AAGD,oCAMC;AASD,8BA6BC;AA+BD,8CAyGC;AAxSD,iDAAgD;AAChD,+BAA8E;AAC9E,uCAA4C;AAC5C,iCAMgB;AAShB,mFAAmF;AACnF,MAAM,eAAe,GAAgC,IAAI,GAAG,CAAC;IAC3D,CAAC,eAAe,EAAE,eAAe,CAAC;IAClC,CAAC,QAAQ,EAAE,UAAU,CAAC;CACvB,CAAC,CAAC;AAEH,4FAA4F;AAC5F,SAAS,YAAY,CAAC,QAAsB;IAC1C,OAAO,CACL,QAAQ,CAAC,IAAI,KAAK,sBAAsB;QACxC,CAAC,QAAQ,CAAC,SAAS,KAAK,SAAS;YAC/B,QAAQ,CAAC,cAAc,KAAK,SAAS;YACrC,QAAQ,CAAC,OAAO,KAAK,SAAS,CAAC,CAClC,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,QAAQ,CAAC,GAAuB,EAAE,EAAc,EAAE,IAAgB;IACzE,4EAA4E;IAC5E,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;QAAE,MAAM,IAAA,gBAAS,EAAC,kBAAkB,CAAC,CAAC;IAC3D,MAAM,EAAE,GAAG,GAAG;QACZ,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,sBAAsB;QAC9C,CAAC,CAAC,IAAI,CAAC,aAAa,KAAK,SAAS,CAAC;IACrC,IAAI,EAAE,EAAE,CAAC;QACP,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC;QAClC,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,IAAA,gBAAS,EAAC,gBAAgB,CAAC,CAAC;QAC5D,IAAI,E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C,CAAC,EAAE,CAAC;YAC1E,GAAG,CAAC,IAAI,EAAE,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvE,GAAG,CAAC,IAAI,EAAE,cAAc,KAAK,SAAS;gBACpC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE;gBACzC,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClE;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Chain transactions into `DriverTransaction`s, and the verdict of our own transfers.\n * - General decoding (reads, scans, history) reports execution as the chain does: a TRX\n * transfer is `native`, and so is the TRX a contract call sends; each TRC-20 `Transfer`\n * log is a `token-event` (`log:<i>`); contract execution is `partial` (value may move\n * without a log), a failed transaction moved nothing and is `complete`, and a contract\n * type this model does not carry is `none`.\n * - The verdict of our own Attempts (observe with an ordering, and the proofs) also\n * requires on-chain evidence that value moved: a TRC-20 `transfer(to, amount)` counts\n * only with a `Transfer(owner, to, any positive amount)` log from the called contract.\n * Execution success alone proves nothing: a token can succeed and move nothing, and\n * USDT on Tron returns a zero word from `transfer`.\n * - Verdict fields are read strictly: a missing, ill-typed or contradicting one\n * is a malformed answer (retryable), which decides nothing, never a default. Decoding stays\n * lenient on what the chain accepts: an unknown contract type, a memo of any size or bytes.\n * - `readRaw`'s `timestamp` and `feeLimit` are display only: no verdict or amount uses them.\n * Failure reasons are fixed literals: a node's text can carry addresses or amounts, and a\n * stored reason must never hold either.\n */\nimport type {\n DriverTransaction,\n DriverTransfer,\n DriverTxObservation,\n} from '../../core/driver/types';\nimport type { TxFailure } from '../../core/model/transaction';\nimport { fromHex } from '../../core/util/bytes';\nimport { TRANSFER_TOPIC, decodeTransferCall, decodeTransferLog } from './abi';\nimport { toBase58Address } from './address';\nimport {\n malformed,\n notServable,\n unixSeconds,\n type TronTxInfo,\n type TronTxJson,\n} from './http';\nimport type { TronCodec, TronContract, TronRawData } from './types';\n\nexport interface TxVerdict {\n readonly success: boolean;\n readonly reason?: string;\n readonly failure?: TxFailure;\n}\n\n/** VM receipt results with a reason of their own; any other failure is generic. */\nconst FAILURE_REASONS: ReadonlyMap<string, string> = new Map([\n ['OUT_OF_ENERGY', 'out of energy'],\n ['REVERT', 'reverted'],\n]);\n\n/** A contract call that also sends TRX or a TRC-10 token: never a plain TRC-20 transfer. */\nfunction carriesValue(contract: TronContract): boolean {\n return (\n contract.type === 'TriggerSmartContract' &&\n (contract.callValue !== undefined ||\n contract.callTokenValue !== undefined ||\n contract.tokenId !== undefined)\n );\n}\n\n/**\n * The chain's own verdict, from strictly read fields (no evidence check). The VM writes a\n * receipt result for every call it runs (`TransactionTrace.setResult`), `ret[0].contractRet`\n * repeats it, and the info's `FAILED` is set exactly when the call did not succeed\n * (`TransactionUtil.buildTransactionInfoInstance`, GreatVoyage-v4.8.2.2 `d5c3d1d1`). Other\n * contracts carry no receipt result: java-tron never includes one whose execution failed,\n * and blocks from 2018 carry no `ret` at all (mainnet block 2,000,000), so inclusion is\n * their success unless the node reports a failure.\n */\nfunction executed(raw: TronRawData | null, tx: TronTxJson, info: TronTxInfo): TxVerdict {\n // Bound to the id asked for: another transaction's receipt decides nothing.\n if (info.id !== tx.id) throw malformed('transaction info');\n const vm = raw\n ? raw.contract.type === 'TriggerSmartContract'\n : info.receiptResult !== undefined;\n if (vm) {\n const result = info.receiptResult;\n if (result === undefined) throw malformed('receipt result');\n if (tx.contractRet !== undefined && tx.contractRet !== result) {\n throw malformed('contractRet');\n }\n if (result !== 'SUCCESS') {\n return {\n success: false,\n reason: FAILURE_REASONS.get(result) ?? 'contract execution failed',\n };\n }\n if (info.failed) throw malformed('result');\n return { success: true };\n }\n if (info.failed || (tx.contractRet !== undefined && tx.contractRet !== 'SUCCESS')) {\n return { success: false, reason: 'execution failed' };\n }\n return { success: true };\n}\n\ntype Evidence = 'landed' | 'absent' | 'unreadable';\n\n/**\n * What the called token logged for a TRC-20 `transfer(to, …)`. `landed`: a `Transfer`\n * from the sender to that recipient of any positive amount, from the called contract.\n * `unreadable`: nothing landed, and the contract logged a `Transfer` event that does not\n * read as one (its value indexed, say).\n * A call with a value, or with data that is not a canonical `transfer`, is `absent`.\n */\nfunction transferEvidence(raw: TronRawData, info: TronTxInfo): Evidence {\n const { contract } = raw;\n if (contract.type !== 'TriggerSmartContract') return 'landed';\n if (carriesValue(contract)) return 'absent';\n const call = decodeTransferCall(contract.data);\n if (call === null) return 'absent';\n const emitter = contract.contract.slice(2);\n let unreadable = false;\n for (const log of info.logs) {\n if (log.address !== emitter) continue;\n const event = decodeTransferLog(log);\n if (event === null) {\n if (log.topics[0] === TRANSFER_TOPIC) unreadable = true;\n } else if (\n event.from === contract.owner &&\n event.to === call.to &&\n event.amount > 0n\n ) {\n return 'landed';\n }\n }\n return unreadable ? 'unreadable' : 'absent';\n}\n\n/**\n * A TRC-20 `transfer(to, …)` counts only if the called token\n * contract logged a `Transfer` from the sender to that recipient. Any positive amount counts:\n * a fee-on-transfer token (Tron USDT has a dormant fee switch) logs less than the call's\n * amount, and requiring the exact amount would prove a transfer that moved `failed`. A call\n * that also sends TRX or a TRC-10 token, or whose data is not a canonical `transfer`, is never\n * a plain TRC-20 transfer. Decoding reports the amounts that actually moved.\n */\nexport function transferLanded(raw: TronRawData, info: TronTxInfo): boolean {\n return transferEvidence(raw, info) === 'landed';\n}\n\n/** The chain's own view of an included transaction (no evidence check: not a verdict). */\nexport function chainVerdict(\n codec: TronCodec,\n tx: TronTxJson,\n info: TronTxInfo,\n): TxVerdict {\n return executed(codec.readRaw(tx.rawHex), tx, info);\n}\n\n/**\n * The verdict of our own included transaction (observe with an ordering, `includedFinal`).\n * The driver built it, so its bytes read, its call is a canonical `transfer` that sends no\n * value, a node's answer for it carries `contractRet`, and a TRX transfer in a block executed;\n * anything else contradicts the signed transaction or the chain's rules and decides nothing\n * (retryable), as does a token `Transfer` event that does not read.\n */\nexport function verdictOf(codec: TronCodec, tx: TronTxJson, info: TronTxInfo): TxVerdict {\n const raw = codec.readRaw(tx.rawHex);\n if (raw === null) throw malformed('raw_data_hex');\n if (tx.contractRet === undefined) throw malformed('contractRet');\n if (carriesValue(raw.contract)) throw malformed('call value');\n // An included TransferContract executed (java-tron never includes one that\n // failed), so any other answer on our own is impossible: a false `failed` on a proof path\n // would invite a second payment. The chain's view reports what the node says.\n if (\n raw.contract.type === 'TransferContract' &&\n (tx.contractRet !== 'SUCCESS' || info.failed)\n ) {\n throw malformed('contractRet');\n }\n // Our own TRC-20 call is a canonical `transfer(to, amount)` (the builder\n // writes nothing else), so other call data contradicts the signed transaction.\n if (\n raw.contract.type === 'TriggerSmartContract' &&\n decodeTransferCall(raw.contract.data) === null\n ) {\n throw malformed('call data');\n }\n const chain = executed(raw, tx, info);\n if (!chain.success) return chain;\n const evidence = transferEvidence(raw, info);\n if (evidence === 'unreadable') throw malformed('Transfer log');\n return evidence === 'landed'\n ? chain\n : { success: false, reason: 'token transfer not evidenced', failure: 'unevidenced' };\n}\n\nconst UTF8 = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });\n\n/**\n * The memo (`raw_data.data`) as text: `undefined` without one, `null` when its bytes are not\n * UTF-8 (replacement characters would make two different memos read the same). Any size the\n * chain accepts reads: the driver's own 256-byte cap applies to what it writes.\n */\nfunction memoOf(raw: TronRawData): string | null | undefined {\n if (raw.data === undefined) return undefined;\n try {\n return UTF8.decode(fromHex(raw.data));\n } catch {\n return null;\n }\n}\n\n/** A canonical `T…` address, or `null` for bytes that are not one (never thrown). */\nfunction base58(hex: string): string | null {\n try {\n return toBase58Address(hex);\n } catch {\n return null;\n }\n}\n\n/**\n * Any transaction as the chain reports it. `info` and `blockHash` come together for an\n * included transaction; `pending` marks one the node holds in its pool.\n */\nexport function decodeTransaction(\n codec: TronCodec,\n tx: TronTxJson,\n info: TronTxInfo | null,\n blockHash: string | undefined,\n pending = false,\n): DriverTransaction {\n if (info !== null && blockHash === undefined) throw notServable();\n const raw = codec.readRaw(tx.rawHex);\n const chain = info ? executed(raw, tx, info) : undefined;\n const observation: DriverTxObservation =\n info && chain && blockHash !== undefined\n ? {\n seen: 'block',\n txHash: tx.id,\n blockHeight: info.blockNumber,\n blockHash,\n success: chain.success,\n ...(chain.reason ? { reason: chain.reason } : {}),\n }\n : pending\n ? { seen: 'mempool', txHash: tx.id }\n : { seen: 'none' };\n const memo = raw ? memoOf(raw) : undefined;\n const owner = raw ? base58(raw.contract.owner) : null;\n const transfers: DriverTransfer[] = [];\n let decoding: DriverTransaction['decoding'] = 'complete';\n /** A movement with the memo; `null` (an address that does not read) is left out. */\n const add = (transfer: Omit<DriverTransfer, 'memo'> | null): void => {\n if (!transfer) decoding = 'partial';\n else transfers.push(typeof memo === 'string' ? { ...transfer, memo } : transfer);\n };\n const native = (to: string, amount: bigint) => {\n const recipient = base58(to);\n add(\n owner && recipient\n ? {\n locator: 'native',\n from: [owner],\n to: recipient,\n asset: 'native',\n amount,\n source: 'native',\n }\n : null,\n );\n };\n if (raw === null) {\n decoding = 'none';\n } else if (!info) {\n decoding = 'partial';\n } else if (chain?.success) {\n if (memo === null) decoding = 'partial';\n const { contract } = raw;\n if (contract.type === 'TransferContract') {\n native(contract.to, contract.amount);\n } else {\n // Value can move without a log (internal transfers), and a TRC-10 value has no asset\n // here: a contract call is partial.\n decoding = 'partial';\n if (contract.callValue !== undefined) native(contract.contract, contract.callValue);\n info.logs.forEach((log, index) => {\n const event = decodeTransferLog(log);\n if (!event) return;\n const from = base58(event.from);\n const to = base58(event.to);\n const token = base58(`41${log.address}`);\n add(\n from && to && token\n ? {\n locator: `log:${index}`,\n from: [from],\n to,\n asset: { standard: 'trc20', contract: token },\n amount: event.amount,\n source: 'token-event',\n }\n : null,\n );\n });\n }\n }\n const call = raw?.contract.type === 'TriggerSmartContract' ? raw.contract : undefined;\n return {\n id: tx.id,\n observation,\n ...(info ? { fee: [{ asset: 'native' as const, amount: info.fee }] } : {}),\n transfers,\n decoding,\n // The block's time, in Unix seconds as every family reports it: the client-set\n // `raw_data.timestamp` is display only.\n ...(info ? { timestamp: unixSeconds(info.blockTimestamp) } : {}),\n details: {\n contract: raw?.contract.type ?? 'unknown',\n ...(owner ? { owner } : {}),\n ...(tx.contractRet !== undefined ? { result: tx.contractRet } : {}),\n ...(info?.receiptResult !== undefined ? { receipt: info.receiptResult } : {}),\n ...(raw?.feeLimit !== undefined ? { feeLimit: BigInt(raw.feeLimit) } : {}),\n ...(call?.callValue !== undefined ? { callValue: call.callValue } : {}),\n ...(call?.callTokenValue !== undefined\n ? { callTokenValue: call.callTokenValue }\n : {}),\n ...(call?.tokenId !== undefined ? { tokenId: call.tokenId } : {}),\n },\n };\n}\n"]}
|
|
@@ -15,6 +15,12 @@ export declare function malformed(field: string): ProviderError;
|
|
|
15
15
|
* its block): neither "not seen" nor a verdict. Retryable; the core keeps its current view.
|
|
16
16
|
*/
|
|
17
17
|
export declare function notServable(): ProviderError;
|
|
18
|
+
/**
|
|
19
|
+
* A time java-tron reports in milliseconds as the Unix seconds every family's blocks and
|
|
20
|
+
* transactions carry (`Block.timestamp`); Tron's own expiration arithmetic keeps
|
|
21
|
+
* milliseconds.
|
|
22
|
+
*/
|
|
23
|
+
export declare function unixSeconds(ms: number): number;
|
|
18
24
|
/** The consensus facts compared under a quorum for `path`, if it has any. */
|
|
19
25
|
export declare const quorumKeyFor: (path: string) => QuorumKey | undefined;
|
|
20
26
|
export interface TronBlockHeader {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TronApi = exports.quorumKeyFor = exports.withSignal = exports.BROADCAST = exports.PROOF = exports.MONITOR = exports.READ = void 0;
|
|
4
4
|
exports.malformed = malformed;
|
|
5
5
|
exports.notServable = notServable;
|
|
6
|
+
exports.unixSeconds = unixSeconds;
|
|
6
7
|
exports.messageText = messageText;
|
|
7
8
|
exports.historyPage = historyPage;
|
|
8
9
|
/**
|
|
@@ -84,6 +85,14 @@ function millis(value, field) {
|
|
|
84
85
|
throw malformed(field);
|
|
85
86
|
return Number(ms);
|
|
86
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* A time java-tron reports in milliseconds as the Unix seconds every family's blocks and
|
|
90
|
+
* transactions carry (`Block.timestamp`); Tron's own expiration arithmetic keeps
|
|
91
|
+
* milliseconds.
|
|
92
|
+
*/
|
|
93
|
+
function unixSeconds(ms) {
|
|
94
|
+
return Math.floor(ms / 1000);
|
|
95
|
+
}
|
|
87
96
|
function hex(value, field, bytes) {
|
|
88
97
|
if (typeof value !== 'string' || !/^(?:[0-9a-fA-F]{2})*$/.test(value)) {
|
|
89
98
|
throw malformed(field);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/adapters/tron/http.ts"],"names":[],"mappings":";;;AA8BA,8BAEC;AAMD,kCAKC;AAsaD,kCAOC;AA2ZD,kCAmEC;AAt7BD;;;;;;;;GAQG;AACH,iDAA8C;AAC9C,mDAAsF;AAEtF,iDAAoE;AAGvD,QAAA,IAAI,GAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACxD,QAAA,OAAO,GAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC9D,QAAA,KAAK,GAAiB,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC3E,QAAA,SAAS,GAAiB;IACrC,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,sBAAsB;CAC9B,CAAC;AAEF,6CAA6C;AACtC,MAAM,UAAU,GAAG,CAAC,IAAkB,EAAE,MAAoB,EAAgB,EAAE,CACn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E,kFAAkF;QAClF,+EAA+E;QAC/E,IAAI,EAAE,KAAK,SAAS,IAAI,eAAe,CAAC,KAAK,CAAC;YAAE,SAAS;QACzD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,OAAO;QACL,GAAG,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACtB,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The driver's only path to the network: one direct transport call per\n * request, carrying the purpose, retry class, quorum, fanout and signal of the driver\n * method that made it. No SDK sits on a request path. Answers are validated here: a\n * malformed answer is a retryable `ProviderError('PROVIDER_UNAVAILABLE')`, never a foreign\n * error, and a node `Error` answer is a retryable `RPC_ERROR` that repeats no node text.\n * On a proof path every refusal decides nothing; on a broadcast, an answer\n * that cannot be read leaves the transaction possibly sent.\n */\nimport { sha256 } from '@noble/hashes/sha256';\nimport { ConfigError, ProviderError, ValidationError } from '../../core/errors/error';\nimport type { CallOptions, HttpRequest, Transport } from '../../core/transport/types';\nimport { bytesToUtf8, fromHex, toHex } from '../../core/util/bytes';\nimport type { TronCallTags, TronResources } from './types';\n\nexport const READ: TronCallTags = { purpose: 'read', retry: 'safe' };\nexport const MONITOR: TronCallTags = { purpose: 'monitor', retry: 'safe' };\nexport const PROOF: TronCallTags = { purpose: 'proof', retry: 'safe', quorum: 'proof' };\nexport const BROADCAST: TronCallTags = {\n purpose: 'broadcast',\n retry: 'ambiguous-on-failure',\n};\n\n/** Adds the caller's signal to a tag set. */\nexport const withSignal = (tags: TronCallTags, signal?: AbortSignal): TronCallTags =>\n signal ? { ...tags, signal } : tags;\n\ntype Json = Record<string, unknown>;\ntype QuorumKey = (result: unknown) => unknown;\n\nexport function malformed(field: string): ProviderError {\n return new ProviderError('PROVIDER_UNAVAILABLE', `malformed ${field} in a Tron answer`);\n}\n\n/**\n * The node indexed a transaction it cannot serve whole yet (its receipt, the transaction or\n * its block): neither \"not seen\" nor a verdict. Retryable; the core keeps its current view.\n */\nexport function notServable(): ProviderError {\n return new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n 'the node indexed a transaction it cannot serve yet',\n );\n}\n\n/** A broadcast answer that cannot be read: the node may hold the transaction. */\nfunction unreadableAfterSend(field: string): ProviderError {\n return new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n `malformed ${field} in a Tron answer`,\n {\n ambiguous: true,\n },\n );\n}\n\nconst isObject = (value: unknown): value is Json =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n\nfunction object(value: unknown, field: string): Json {\n if (!isObject(value)) throw malformed(field);\n return value;\n}\n\n/**\n * A non-negative JSON integer: a bigint under `exactIntegers` when it is outside the\n * safe range, else a safe number. Amounts are never rounded.\n */\nfunction uint(value: unknown, field: string): bigint {\n if (typeof value === 'bigint' && value >= 0n) return value;\n if (typeof value === 'number' && Number.isSafeInteger(value) && value >= 0) {\n return BigInt(value);\n }\n throw malformed(field);\n}\n\n/** Like `uint`, but an absent value is 0 (proto3 JSON omits zero fields). */\nconst uintOr0 = (value: unknown, field: string): bigint =>\n value === undefined ? 0n : uint(value, field);\n\n/** java-tron's `long`: block heights above it are malformed. */\nconst INT64_MAX = 2n ** 63n - 1n;\n\n/** A block height: a non-negative int64. */\nfunction height(value: unknown, field: string): bigint {\n const n = uint(value, field);\n if (n > INT64_MAX) throw malformed(field);\n return n;\n}\n\n/**\n * An integer written into a request body as an exact JSON literal (`JSON.rawJSON`, Node ≥ 22):\n * java-tron reads int64 fields from number literals, and `Number()` would round above 2^53.\n */\nconst exactInteger = (value: bigint): unknown =>\n (JSON as unknown as { rawJSON(text: string): unknown }).rawJSON(value.toString());\n\n/** A block time in milliseconds: a safe non-negative integer, never rounded. */\nfunction millis(value: unknown, field: string): number {\n const ms = uint(value, field);\n if (ms > BigInt(Number.MAX_SAFE_INTEGER)) throw malformed(field);\n return Number(ms);\n}\n\nfunction hex(value: unknown, field: string, bytes?: number): string {\n if (typeof value !== 'string' || !/^(?:[0-9a-fA-F]{2})*$/.test(value)) {\n throw malformed(field);\n }\n if (bytes !== undefined && value.length !== bytes * 2) throw malformed(field);\n return value.toLowerCase();\n}\n\nconst isEmpty = (value: unknown): boolean =>\n isObject(value) && Object.keys(value).length === 0;\n\n/**\n * java-tron refuses a transaction above `TRANSACTION_MAX_BYTE_SIZE` (500 KiB), so\n * longer raw bytes are malformed and never hashed or decoded.\n */\nconst MAX_RAW_HEX = 2 * 500 * 1024;\n\n// ---- consensus keys (quorum) ------------------------------------------------------------\n\nconst lower = (value: unknown): unknown =>\n typeof value === 'string'\n ? value.toLowerCase()\n : Array.isArray(value)\n ? value.map(lower)\n : value;\n\n/**\n * java-tron's HTTP 200 failure (`{ \"Error\": … }`) or a JSON-RPC error, keyed as a flag: it\n * never agrees with a real or an empty answer, and its text is never compared.\n */\nconst ERROR_KEY = { error: true } as const;\n/** java-tron's \"not found\" (`{}`); a non-empty answer without the facts never matches it. */\nconst ABSENT_KEY = { absent: true } as const;\n\nconst isErrorAnswer = (result: unknown): boolean =>\n isObject(result) && (result.Error !== undefined || result.error !== undefined);\n\n/** A REST key: an error answer is the error flag, `{}` is absent, else the `facts`. */\nconst restKey =\n (facts: (answer: Json) => unknown): QuorumKey =>\n (result) => {\n if (!isObject(result)) return result;\n if (isErrorAnswer(result)) return ERROR_KEY;\n if (Object.keys(result).length === 0) return ABSENT_KEY;\n return facts(result);\n };\n\nconst headerKey = restKey((answer) => {\n const header = isObject(answer.block_header) ? answer.block_header : undefined;\n const raw = header && isObject(header.raw_data) ? header.raw_data : undefined;\n return {\n id: lower(answer.blockID ?? null),\n // proto3 JSON omits genesis's number and timestamp: absent and 0 are one fact.\n number: raw ? (raw.number ?? 0) : null,\n parent: lower(raw?.parentHash ?? null),\n timestamp: raw ? (raw.timestamp ?? 0) : null,\n };\n});\n\n/**\n * A proven verdict reads the receipt result and the `Transfer` logs, so the\n * key covers them; hex case and fields nodes format differently do not count.\n */\nconst infoKey = restKey((answer) => {\n const receipt = isObject(answer.receipt) ? answer.receipt : {};\n const logs = Array.isArray(answer.log) ? answer.log : [];\n return {\n id: lower(answer.id ?? null),\n block: answer.blockNumber ?? null,\n // A proof binds the receipt to its block by this time, so it is attested.\n time: answer.blockTimeStamp ?? null,\n result: answer.result ?? null,\n receipt: receipt.result ?? null,\n logs: logs.map((log) =>\n isObject(log)\n ? { a: lower(log.address), t: lower(log.topics), d: lower(log.data) }\n : log,\n ),\n };\n});\n\nconst transactionKey = restKey((answer) => {\n const ret = Array.isArray(answer.ret) && isObject(answer.ret[0]) ? answer.ret[0] : {};\n return {\n id: lower(answer.txID ?? null),\n raw: lower(answer.raw_data_hex ?? null),\n ret: ret.contractRet ?? null,\n };\n});\n\n/** java-tron's answer for an address that holds no contract: its code and exact text. */\nfunction isNoContract(outcome: Json): boolean {\n return (\n outcome.result !== true &&\n outcome.code === 'CONTRACT_VALIDATE_ERROR' &&\n messageText(outcome.message) === 'Smart contract is not exist.'\n );\n}\n\n/**\n * A constant call's verdict, and nothing else. Each node builds the simulated\n * transaction on its own head (reference block, expiration, txID) and meters energy on its\n * own state, so honest nodes never agree on the whole answer. The key compares the outcome\n * (ran, no contract, or any other refusal: one value whose code and text are never\n * compared), whether the VM failed (`ret`), and what the call returned.\n */\nconst constantCallKey = restKey((answer) => {\n const outcome = isObject(answer.result) ? answer.result : {};\n const tx = isObject(answer.transaction) ? answer.transaction : {};\n const ret = Array.isArray(tx.ret) && isObject(tx.ret[0]) ? tx.ret[0].ret : undefined;\n return {\n outcome:\n outcome.result === true ? 'ok' : isNoContract(outcome) ? 'no-contract' : 'refused',\n ret: ret ?? null,\n out: lower(answer.constant_result ?? null),\n };\n});\n\n/** Whether a contract is there, and which: `{}` (none) keys as absent (`restKey`). */\nconst contractKey = restKey((answer) => ({\n contract: lower(answer.contract_address ?? null),\n}));\n\nfunction rpcBlockKey(result: unknown): unknown {\n if (!isObject(result)) return result;\n // An envelope without a result is an error, whatever else it holds.\n if (isErrorAnswer(result) || !Object.hasOwn(result, 'result')) return ERROR_KEY;\n const block = result.result;\n if (!isObject(block)) return block ?? null;\n // The negative scan stops on `timestamp`, so it is compared too: one lying endpoint\n // cannot end the scan early with an old time.\n return {\n number: lower(block.number ?? null),\n hash: lower(block.hash ?? null),\n parent: lower(block.parentHash ?? null),\n timestamp: lower(block.timestamp ?? null),\n transactions: lower(block.transactions ?? null),\n };\n}\n\nconst QUORUM_KEYS: Readonly<Record<string, QuorumKey>> = {\n '/wallet/getblock': headerKey,\n '/walletsolidity/getblock': headerKey,\n '/walletsolidity/gettransactioninfobyid': infoKey,\n '/wallet/gettransactioninfobyid': infoKey,\n '/walletsolidity/gettransactionbyid': transactionKey,\n '/wallet/gettransactionbyid': transactionKey,\n '/wallet/triggerconstantcontract': constantCallKey,\n '/wallet/getcontract': contractKey,\n '/jsonrpc': rpcBlockKey,\n};\n\n/** The consensus facts compared under a quorum for `path`, if it has any. */\nexport const quorumKeyFor = (path: string): QuorumKey | undefined =>\n Object.hasOwn(QUORUM_KEYS, path) ? QUORUM_KEYS[path] : undefined;\n\n/** A caller's key never makes an error answer agree with a real one. */\nconst guarded =\n (key: QuorumKey): QuorumKey =>\n (result) =>\n isErrorAnswer(result) ? ERROR_KEY : key(result);\n\n/**\n * One tagged transport call with exact integers. Under a quorum the caller's\n * `quorumKey` (a monotone predicate) replaces `fallback`; a key never travels\n * without a quorum.\n *\n * On a proof path a definitive refusal decides nothing, so it becomes a retryable\n * `PROVIDER_UNAVAILABLE`: a REST 4xx the quorum agreed on, and a 401 or 403 too. The\n * transport reports both as `PROVIDER_MISCONFIGURED` with no structured status, and TronGrid\n * answers a rate-limit suspension with 403 (\"Rate-limited requests usually return 429 or 403\n * and should be retried with backoff\", developers.tron.network/reference/rate-limits, read\n * 2026-09-27), so a proof cannot tell a bad key from a pause. A bad key still surfaces as\n * `PROVIDER_MISCONFIGURED` through the plain reads (monitor, read), which pass it unchanged:\n * on every endpoint when every key is bad; with one bad endpoint among several, a proof retries\n * until its breaker opens, and then the core reports the quorum unreachable. A caller's\n * abort is never converted. Other purposes see the transport's error unchanged.\n */\nasync function call(\n transport: Transport,\n request: HttpRequest,\n tags: TronCallTags,\n fallback?: QuorumKey,\n): Promise<unknown> {\n const { quorumKey: own, ...rest } = tags;\n const quorumKey = rest.quorum === undefined ? undefined : own ? guarded(own) : fallback;\n const options: CallOptions = {\n ...rest,\n exactIntegers: true,\n ...(quorumKey ? { quorumKey } : {}),\n };\n try {\n return await transport.http(request, options);\n } catch (error) {\n if (\n tags.purpose === 'proof' &&\n !tags.signal?.aborted &&\n error instanceof ProviderError &&\n !error.retryable\n ) {\n throw new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n 'a proof read was refused, which decides nothing',\n { cause: error, context: error.context, retryable: true },\n );\n }\n throw error;\n }\n}\n\n// ---- wire shapes --------------------------------------------------------------------------\n\nexport interface TronBlockHeader {\n readonly number: bigint;\n readonly id: string;\n readonly parentId: string;\n readonly timestamp: number;\n}\n\nexport interface TronLog {\n /** The emitter, 20-byte hex (no `41`). */\n readonly address: string;\n readonly topics: readonly string[];\n readonly data: string;\n}\n\nexport interface TronTxInfo {\n readonly id: string;\n readonly blockNumber: bigint;\n readonly blockTimestamp: number;\n /** Total TRX burned, in sun. */\n readonly fee: bigint;\n /** `receipt.result` of a contract call (`SUCCESS`, `REVERT`, `OUT_OF_ENERGY`, …). */\n readonly receiptResult?: string;\n /** `FAILED` when execution failed. */\n readonly failed: boolean;\n readonly logs: readonly TronLog[];\n}\n\nexport interface TronTxJson {\n readonly id: string;\n readonly rawHex: string;\n /** `ret[0].contractRet`, absent while pending. */\n readonly contractRet?: string;\n}\n\n/** The chain parameters the driver reads: its fees, and one TransferContract rule. */\nconst FEE_PARAMETERS = new Set([\n 'getTransactionFee',\n 'getEnergyFee',\n 'getCreateAccountFee',\n 'getCreateNewAccountFeeInSystemContract',\n 'getCreateNewAccountBandwidthRate',\n 'getMemoFee',\n 'getMaxFeeLimit',\n 'getForbidTransferToContract',\n]);\n\nexport interface ChainParameters {\n readonly transactionFee: bigint;\n readonly energyFee: bigint;\n readonly createAccountFee: bigint;\n readonly createNewAccountFeeInSystemContract: bigint;\n readonly createNewAccountBandwidthRate: bigint;\n readonly memoFee: bigint;\n readonly maxFeeLimit: bigint;\n /**\n * `getForbidTransferToContract` is 1: `TransferActuator` refuses TRX sent to a contract\n * account. 0 (proto3 JSON omits it) on mainnet, Nile and Shasta, read 2026-09-29.\n */\n readonly forbidTransferToContract: boolean;\n}\n\nexport type ConstantCall =\n | { readonly kind: 'ok'; readonly result: string; readonly energy: bigint }\n | { readonly kind: 'failed'; readonly energy: bigint }\n | { readonly kind: 'no-contract' };\n\nexport interface BroadcastAnswer {\n readonly accepted: boolean;\n readonly code?: string;\n /** The node's message, decoded when it is hex. Never stored or logged as is. */\n readonly message?: string;\n}\n\nexport interface RpcBlock {\n readonly number: bigint;\n readonly hash: string;\n readonly parentHash: string;\n readonly timestamp: number;\n readonly transactions: readonly string[];\n}\n\nfunction parseHeader(value: unknown): TronBlockHeader | null {\n if (isEmpty(value)) return null;\n const block = object(value, 'block');\n const raw = object(object(block.block_header, 'block header').raw_data, 'block header');\n // proto3 JSON omits zero fields: genesis has neither number nor timestamp.\n return {\n number: height(raw.number ?? 0, 'block number'),\n id: hex(block.blockID, 'block id', 32),\n parentId: hex(raw.parentHash, 'parent hash', 32),\n timestamp: millis(raw.timestamp ?? 0, 'block timestamp'),\n };\n}\n\nfunction parseTransaction(value: unknown): TronTxJson {\n const tx = object(value, 'transaction');\n const ret =\n Array.isArray(tx.ret) && isObject(tx.ret[0]) ? tx.ret[0].contractRet : undefined;\n if (ret !== undefined && typeof ret !== 'string') throw malformed('contractRet');\n const id = hex(tx.txID, 'txID', 32);\n if (typeof tx.raw_data_hex === 'string' && tx.raw_data_hex.length > MAX_RAW_HEX) {\n throw malformed('raw_data_hex');\n }\n const rawHex = hex(tx.raw_data_hex, 'raw_data_hex');\n // The id is the SHA-256 of the raw bytes: an answer that does not bind them is malformed.\n if (toHex(sha256(fromHex(rawHex))) !== id) throw malformed('raw_data_hex');\n return {\n id,\n rawHex,\n ...(ret !== undefined ? { contractRet: ret } : {}),\n };\n}\n\nfunction parseInfo(value: unknown): TronTxInfo {\n const info = object(value, 'transaction info');\n const receipt = info.receipt === undefined ? {} : object(info.receipt, 'receipt');\n const logs = info.log === undefined ? [] : info.log;\n if (!Array.isArray(logs)) throw malformed('log');\n const receiptResult = receipt.result;\n if (receiptResult !== undefined && typeof receiptResult !== 'string') {\n throw malformed('receipt result');\n }\n if (info.result !== undefined && info.result !== 'FAILED') throw malformed('result');\n return {\n id: hex(info.id, 'transaction id', 32),\n blockNumber: height(info.blockNumber, 'block number'),\n blockTimestamp: millis(info.blockTimeStamp, 'block timestamp'),\n fee: uintOr0(info.fee, 'fee'),\n ...(receiptResult !== undefined ? { receiptResult } : {}),\n failed: info.result === 'FAILED',\n logs: logs.map((entry) => {\n const log = object(entry, 'log');\n if (!Array.isArray(log.topics)) throw malformed('log topics');\n return {\n address: hex(log.address, 'log address', 20),\n topics: log.topics.map((t) => hex(t, 'log topic', 32)),\n data: log.data === undefined ? '' : hex(log.data, 'log data'),\n };\n }),\n };\n}\n\n/** The longest node message kept, in characters: java-tron's texts are far shorter. */\nconst MAX_MESSAGE = 1024;\n\n/**\n * A node's message field: hex-encoded UTF-8 on some paths, plain text on others. At most\n * the first 1 KiB is kept, decoded when the whole field is printable hex.\n */\nexport function messageText(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined;\n if (/^(?:[0-9a-fA-F]{2})+$/.test(value)) {\n const text = bytesToUtf8(fromHex(value.slice(0, 2 * MAX_MESSAGE)));\n if (/^[\\x20-\\x7e]+$/.test(text)) return text;\n }\n return value.slice(0, MAX_MESSAGE);\n}\n\n/** A JSON-RPC 32-byte hash, lower-case without `0x`. */\nfunction rpcHash(value: unknown, field: string): string {\n if (typeof value !== 'string' || !/^0x[0-9a-fA-F]{64}$/.test(value)) {\n throw malformed(field);\n }\n return value.slice(2).toLowerCase();\n}\n\n/** A JSON-RPC quantity of at most 64 bits (bounded before conversion). */\nfunction rpcQuantity(value: unknown, field: string): bigint {\n if (typeof value !== 'string' || !/^0x[0-9a-fA-F]{1,16}$/.test(value)) {\n throw malformed(field);\n }\n return BigInt(value);\n}\n\n// ---- the API ----------------------------------------------------------------------------\n\nexport class TronApi {\n readonly #transport: Transport;\n\n constructor(transport: Transport) {\n this.#transport = transport;\n }\n\n /**\n * One POST to `path`, answered as JSON; a node `Error` answer is a retryable RPC_ERROR\n * (possibly sent, on a broadcast).\n */\n async post(path: string, body: Json, tags: TronCallTags): Promise<unknown> {\n const answer = await call(\n this.#transport,\n { method: 'POST', path, body, route: path },\n tags,\n quorumKeyFor(path),\n );\n if (isObject(answer) && answer.Error !== undefined) {\n throw new ProviderError('RPC_ERROR', `the node answered an error on ${path}`, {\n retryable: true,\n ...(tags.purpose === 'broadcast' ? { ambiguous: true } : {}),\n });\n }\n return answer;\n }\n\n /** The head (`scope: 'full'`) or latest solidified block, or one by height or id. */\n async block(\n scope: 'full' | 'solid',\n ref: bigint | string | undefined,\n tags: TronCallTags,\n ): Promise<TronBlockHeader | null> {\n const path = scope === 'full' ? '/wallet/getblock' : '/walletsolidity/getblock';\n const answer = await this.post(\n path,\n { ...(ref !== undefined ? { id_or_num: ref.toString() } : {}), detail: false },\n tags,\n );\n const header = parseHeader(answer);\n if (header && typeof ref === 'bigint' && header.number !== ref) {\n throw malformed('block number');\n }\n if (header && typeof ref === 'string' && header.id !== ref.toLowerCase()) {\n throw malformed('block id');\n }\n if (ref === undefined && header === null) throw malformed('head block');\n return header;\n }\n\n /**\n * A block with its transactions and their infos (the scanner's read). Block 0 is its\n * header alone: java-tron answers `{}` to `gettransactioninfobyblocknum` there\n * (`GetTransactionInfoByBlockNumServlet`, GreatVoyage-v4.8.2.2; Nile checked 2026-09-27),\n * a malformed answer the scanner would retry for ever, and genesis holds only the chain's\n * initial allocations, which are not reported.\n */\n async blockWithTransactions(\n height: bigint,\n tags: TronCallTags,\n ): Promise<{\n readonly header: TronBlockHeader;\n readonly transactions: readonly TronTxJson[];\n readonly infos: readonly TronTxInfo[];\n } | null> {\n if (height === 0n) {\n const genesis = await this.block('full', 0n, tags);\n return genesis ? { header: genesis, transactions: [], infos: [] } : null;\n }\n const answer = await this.post(\n '/wallet/getblock',\n { id_or_num: height.toString(), detail: true },\n tags,\n );\n const header = parseHeader(answer);\n if (header === null) return null;\n if (header.number !== height) throw malformed('block number');\n const list = (answer as Json).transactions ?? [];\n if (!Array.isArray(list)) throw malformed('transactions');\n const transactions = list.map(parseTransaction);\n const infosAnswer = await this.post(\n '/wallet/gettransactioninfobyblocknum',\n { num: exactInteger(height) },\n tags,\n );\n if (!Array.isArray(infosAnswer)) throw malformed('transaction infos');\n const infos = infosAnswer.map(parseInfo);\n if (infos.some((i) => i.blockNumber !== height)) throw malformed('transaction infos');\n // Two calls can reach two backends behind one URL: the receipts must be exactly this\n // block's, one per transaction.\n const ids = new Set(transactions.map((t) => t.id));\n const receipted = new Set(infos.map((i) => i.id));\n if (\n ids.size !== transactions.length ||\n receipted.size !== infos.length ||\n infos.length !== transactions.length ||\n infos.some((i) => !ids.has(i.id))\n ) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n `block ${height}'s receipts do not match its transactions`,\n { retryable: true },\n );\n }\n return { header, transactions, infos };\n }\n\n async chainParameters(tags: TronCallTags): Promise<ChainParameters> {\n const answer = object(\n await this.post('/wallet/getchainparameters', {}, tags),\n 'parameters',\n );\n const list = answer.chainParameter;\n if (!Array.isArray(list)) throw malformed('chain parameters');\n // Only the parameters the driver reads are validated: others may be negative (e.g.\n // Nile's `getRemoveThePowerOfTheGr` is -1) and must not fail the read.\n const values = new Map<string, bigint>();\n for (const entry of list) {\n const item = object(entry, 'chain parameter');\n if (typeof item.key !== 'string') throw malformed('chain parameter');\n if (FEE_PARAMETERS.has(item.key)) {\n values.set(item.key, uintOr0(item.value, item.key));\n }\n }\n const required = (key: string): bigint => {\n const value = values.get(key);\n if (value === undefined || value === 0n) throw malformed(key);\n return value;\n };\n return {\n transactionFee: required('getTransactionFee'),\n energyFee: required('getEnergyFee'),\n createAccountFee: values.get('getCreateAccountFee') ?? 0n,\n createNewAccountFeeInSystemContract:\n values.get('getCreateNewAccountFeeInSystemContract') ?? 0n,\n createNewAccountBandwidthRate: values.get('getCreateNewAccountBandwidthRate') ?? 1n,\n memoFee: values.get('getMemoFee') ?? 0n,\n maxFeeLimit: required('getMaxFeeLimit'),\n forbidTransferToContract: values.get('getForbidTransferToContract') === 1n,\n };\n }\n\n /** `{ exists: false }` for an account that was never activated. */\n async account(\n addressHex: string,\n tags: TronCallTags,\n ): Promise<{ readonly exists: boolean; readonly balance: bigint }> {\n const answer = object(\n await this.post('/wallet/getaccount', { address: addressHex }, tags),\n 'account',\n );\n if (Object.keys(answer).length === 0) return { exists: false, balance: 0n };\n if (\n typeof answer.address !== 'string' ||\n answer.address.toLowerCase() !== addressHex.toLowerCase()\n ) {\n throw malformed('account address');\n }\n return { exists: true, balance: uintOr0(answer.balance, 'balance') };\n }\n\n async resources(addressHex: string, tags: TronCallTags): Promise<TronResources> {\n const r = object(\n await this.post('/wallet/getaccountresource', { address: addressHex }, tags),\n 'account resources',\n );\n if (Object.keys(r).length === 0) {\n return { activated: false, freeBandwidth: 0n, stakedBandwidth: 0n, energy: 0n };\n }\n const left = (limit: unknown, used: unknown, field: string): bigint => {\n const value = uintOr0(limit, field) - uintOr0(used, field);\n return value > 0n ? value : 0n;\n };\n return {\n activated: true,\n freeBandwidth: left(r.freeNetLimit, r.freeNetUsed, 'free bandwidth'),\n stakedBandwidth: left(r.NetLimit, r.NetUsed, 'bandwidth'),\n energy: left(r.EnergyLimit, r.EnergyUsed, 'energy'),\n };\n }\n\n /**\n * A constant (simulated) contract call. `no-contract` when the address holds no contract;\n * `failed` when the call reverts or the VM fails; any other refusal is a retryable\n * RPC_ERROR.\n */\n async constantCall(\n ownerHex: string,\n contractHex: string,\n data: string,\n tags: TronCallTags,\n ): Promise<ConstantCall> {\n const answer = object(\n await this.post(\n '/wallet/triggerconstantcontract',\n { owner_address: ownerHex, contract_address: contractHex, data },\n tags,\n ),\n 'constant call',\n );\n const result = object(answer.result, 'constant call result');\n if (result.result !== true) {\n if (isNoContract(result)) return { kind: 'no-contract' };\n throw new ProviderError('RPC_ERROR', 'the node refused a contract call', {\n retryable: true,\n });\n }\n const tx =\n answer.transaction === undefined ? {} : object(answer.transaction, 'transaction');\n const ret = Array.isArray(tx.ret) && isObject(tx.ret[0]) ? tx.ret[0].ret : undefined;\n if (ret === 'FAILED') {\n return { kind: 'failed', energy: uintOr0(answer.energy_used, 'energy used') };\n }\n const out = answer.constant_result;\n if (!Array.isArray(out) || out.length !== 1) throw malformed('constant result');\n // A call that ran used energy, and the fee estimate is built on it; a missing or\n // zero `energy_used` is a malformed answer, never 0 (a 0 fee limit fails on chain).\n const energy = uint(answer.energy_used, 'energy used');\n if (energy === 0n) throw malformed('energy used');\n return { kind: 'ok', result: hex(out[0], 'constant result'), energy };\n }\n\n /**\n * Whether `addressHex` holds a contract (`/wallet/getcontract`): java-tron answers `{}`\n * when the account or its contract does not exist (`Wallet.getContract`, GreatVoyage-v4.8.2.2\n * `d5c3d1d1`), else the `SmartContract`. The structural check behind a constant call's\n * \"no contract\" text before anyone caches it; an answer about another address is\n * malformed.\n */\n async contractExists(addressHex: string, tags: TronCallTags): Promise<boolean> {\n const answer = object(\n await this.post('/wallet/getcontract', { value: addressHex }, tags),\n 'contract',\n );\n if (Object.keys(answer).length === 0) return false;\n // java-tron's `SmartContract` always names its address; an answer that\n // names none, or another, is malformed.\n const address = answer.contract_address;\n if (\n typeof address !== 'string' ||\n address.toLowerCase() !== addressHex.toLowerCase()\n ) {\n throw malformed('contract');\n }\n return true;\n }\n\n /**\n * `/wallet/broadcasthex`. java-tron answers refusals with HTTP 200, so the answer is read\n * here; one that cannot be read is possibly sent (the node may hold the bytes).\n */\n async broadcastHex(hexTx: string, tags: TronCallTags): Promise<BroadcastAnswer> {\n const answer = await this.post('/wallet/broadcasthex', { transaction: hexTx }, tags);\n if (!isObject(answer)) throw unreadableAfterSend('broadcast answer');\n if (answer.result === true) return { accepted: true };\n if (typeof answer.code !== 'string') throw unreadableAfterSend('broadcast code');\n const message = messageText(answer.message);\n return { accepted: false, code: answer.code, ...(message ? { message } : {}) };\n }\n\n /** An included transaction (`full`: any block; `solid`: a solidified one), or null. */\n async transaction(\n scope: 'full' | 'solid',\n id: string,\n tags: TronCallTags,\n ): Promise<TronTxJson | null> {\n const path =\n scope === 'full'\n ? '/wallet/gettransactionbyid'\n : '/walletsolidity/gettransactionbyid';\n const answer = await this.post(path, { value: id }, tags);\n if (isEmpty(answer)) return null;\n const tx = parseTransaction(answer);\n if (tx.id !== id.toLowerCase()) throw malformed('transaction id');\n return tx;\n }\n\n async transactionInfo(\n scope: 'full' | 'solid',\n id: string,\n tags: TronCallTags,\n ): Promise<TronTxInfo | null> {\n const path =\n scope === 'full'\n ? '/wallet/gettransactioninfobyid'\n : '/walletsolidity/gettransactioninfobyid';\n const answer = await this.post(path, { value: id }, tags);\n if (isEmpty(answer)) return null;\n const info = parseInfo(answer);\n if (info.id !== id.toLowerCase()) throw malformed('transaction id');\n return info;\n }\n\n /** The transaction if the node holds `id` in its pending pool, else null. */\n async pending(id: string, tags: TronCallTags): Promise<TronTxJson | null> {\n const answer = await this.post(\n '/wallet/gettransactionfrompending',\n { value: id },\n tags,\n );\n if (isEmpty(answer)) return null;\n const tx = parseTransaction(answer);\n if (tx.id !== id.toLowerCase()) throw malformed('transaction id');\n return tx;\n }\n\n /** The node's JSON-RPC block read (transaction ids only), or null when it has none. */\n async rpcBlock(ref: bigint | string, tags: TronCallTags): Promise<RpcBlock | null> {\n const byHash = typeof ref === 'string';\n const answer = object(\n await this.post(\n '/jsonrpc',\n {\n jsonrpc: '2.0',\n id: 1,\n method: byHash ? 'eth_getBlockByHash' : 'eth_getBlockByNumber',\n params: [byHash ? `0x${ref}` : `0x${ref.toString(16)}`, false],\n },\n tags,\n ),\n 'JSON-RPC answer',\n );\n if (answer.error !== undefined) {\n throw new ProviderError('RPC_ERROR', 'the node answered a JSON-RPC error', {\n retryable: true,\n });\n }\n if (answer.result === null) return null;\n const block = object(answer.result, 'JSON-RPC block');\n const txs = block.transactions;\n if (!Array.isArray(txs)) throw malformed('JSON-RPC transactions');\n const seconds = rpcQuantity(block.timestamp, 'JSON-RPC timestamp');\n if (seconds * 1000n > BigInt(Number.MAX_SAFE_INTEGER)) {\n throw malformed('JSON-RPC timestamp');\n }\n const number = rpcQuantity(block.number, 'JSON-RPC number');\n if (number > INT64_MAX) throw malformed('JSON-RPC number');\n const parsed: RpcBlock = {\n number,\n hash: rpcHash(block.hash, 'JSON-RPC hash'),\n parentHash: rpcHash(block.parentHash, 'JSON-RPC parent hash'),\n timestamp: Number(seconds) * 1000,\n transactions: txs.map((t) => rpcHash(t, 'JSON-RPC transaction')),\n };\n if (byHash ? parsed.hash !== ref.toLowerCase() : parsed.number !== ref) {\n throw malformed('JSON-RPC block');\n }\n return parsed;\n }\n}\n\n/**\n * A base58 account address, the only form sent to TronGrid: it becomes a URL path segment,\n * so anything else is refused before any call.\n */\nconst BASE58_ACCOUNT = /^T[1-9A-HJ-NP-Za-km-z]{33}$/;\n\n/**\n * TronGrid's page cursor, bounded in length and charset. Observed on 2026-09-27: 221 to\n * 224 base58 characters; the bound leaves room for base64 forms.\n */\nconst FINGERPRINT = /^[0-9A-Za-z+/=_-]{1,1024}$/;\n\n/** A 32-byte id as TronGrid writes it: 64 hex digits (one class, bounded). */\nconst ID_HEX = /^[0-9a-fA-F]{64}$/;\n\n/** TronGrid's documented internal-transaction entry: its own id and its parent's. */\nconst isInternalEntry = (entry: Json): boolean =>\n typeof entry.internal_tx_id === 'string' &&\n ID_HEX.test(entry.internal_tx_id) &&\n typeof entry.tx_id === 'string' &&\n ID_HEX.test(entry.tx_id);\n\n/**\n * TronGrid `/v1` account history pages (indexer transport), confirmed entries only. Each\n * transaction id is listed once per page: the TRC-20 stream lists a transaction once per\n * transfer it made.\n *\n * Internal transactions are not listed. `search_internal=false` asks TronGrid for none,\n * and an internal entry it mixes in anyway is skipped: TronGrid documents that entry shape\n * (`internal_tx_id`, `tx_id`, `from_address`, `to_address`, `data`, `block_timestamp`; its\n * OpenAPI schema at developers.tron.network/reference/get-transaction-info-by-account-address)\n * and it has no `txID`, so one would make the whole page malformed. Only an entry without\n * an id of its own that carries both documented ids is skipped. Read on 2026-09-27,\n * `GET api.trongrid.io/v1/accounts/TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR/transactions?limit=20`\n * (WTRX) gave only whole transactions (`txID`, `raw_data_hex`, …), each with the internal\n * transfers nested in `internal_transactions[]` (`internal_tx_id`, `data`, `from_address`,\n * `to_address`); five other accounts, internal-TRX recipients among them, looked the same\n * with `search_internal` true or false. A TRX amount an account received only through a\n * contract's internal transfer is therefore not in its history.\n */\nexport async function historyPage(\n transport: Transport,\n address: string,\n kind: 'transactions' | 'trc20',\n options: { readonly limit: number; readonly fingerprint?: string },\n tags: TronCallTags,\n): Promise<{ readonly ids: readonly string[]; readonly next?: string }> {\n if (typeof address !== 'string' || !BASE58_ACCOUNT.test(address)) {\n throw new ValidationError('INVALID_ADDRESS', 'not a Tron address');\n }\n if (options.fingerprint !== undefined && !FINGERPRINT.test(options.fingerprint)) {\n throw new ConfigError('CONFIG_INVALID', 'not a Tron history cursor');\n }\n const suffix = kind === 'trc20' ? '/trc20' : '';\n const answer = object(\n await call(\n transport,\n {\n method: 'GET',\n path: `/v1/accounts/${address}/transactions${suffix}`,\n route: `/v1/accounts/:address/transactions${suffix}`,\n query: {\n limit: String(options.limit),\n only_confirmed: 'true',\n ...(kind === 'transactions' ? { search_internal: 'false' } : {}),\n ...(options.fingerprint !== undefined\n ? { fingerprint: options.fingerprint }\n : {}),\n },\n },\n tags,\n ),\n 'history page',\n );\n // Each listed id costs several node reads, so a page longer than asked\n // for is malformed rather than read.\n if (\n answer.success !== true ||\n !Array.isArray(answer.data) ||\n answer.data.length > options.limit\n ) {\n throw malformed('history page');\n }\n const meta = answer.meta === undefined ? {} : object(answer.meta, 'history meta');\n const next = meta.fingerprint;\n if (\n next !== undefined &&\n next !== '' &&\n (typeof next !== 'string' || !FINGERPRINT.test(next))\n ) {\n throw malformed('history fingerprint');\n }\n const ids: string[] = [];\n for (const item of answer.data) {\n const entry = object(item, 'history item');\n const id = kind === 'trc20' ? entry.transaction_id : entry.txID;\n // An entry is skipped only when its own fields prove it TronGrid's internal entry:\n // no id of its own, and the documented internal and parent ids. Any entry that\n // carries its id is read whatever else it carries, and anything else is malformed\n // (the page is read again), so a schema change never drops a deposit silently.\n if (id === undefined && isInternalEntry(entry)) continue;\n ids.push(hex(id, 'history id', 32));\n }\n return {\n ids: [...new Set(ids)],\n ...(typeof next === 'string' && next !== '' ? { next } : {}),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/adapters/tron/http.ts"],"names":[],"mappings":";;;AA8BA,8BAEC;AAMD,kCAKC;AAkED,kCAEC;AA2WD,kCAOC;AA2ZD,kCAmEC;AA/7BD;;;;;;;;GAQG;AACH,iDAA8C;AAC9C,mDAAsF;AAEtF,iDAAoE;AAGvD,QAAA,IAAI,GAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACxD,QAAA,OAAO,GAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC9D,QAAA,KAAK,GAAiB,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC3E,QAAA,SAAS,GAA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K,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAC3C,MAAM,EAAE,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QAChE,mFAAmF;QACnF,+EAA+E;QAC/E,kFAAkF;QAClF,+EAA+E;QAC/E,IAAI,EAAE,KAAK,SAAS,IAAI,eAAe,CAAC,KAAK,CAAC;YAAE,SAAS;QACzD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,OAAO;QACL,GAAG,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACtB,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The driver's only path to the network: one direct transport call per\n * request, carrying the purpose, retry class, quorum, fanout and signal of the driver\n * method that made it. No SDK sits on a request path. Answers are validated here: a\n * malformed answer is a retryable `ProviderError('PROVIDER_UNAVAILABLE')`, never a foreign\n * error, and a node `Error` answer is a retryable `RPC_ERROR` that repeats no node text.\n * On a proof path every refusal decides nothing; on a broadcast, an answer\n * that cannot be read leaves the transaction possibly sent.\n */\nimport { sha256 } from '@noble/hashes/sha256';\nimport { ConfigError, ProviderError, ValidationError } from '../../core/errors/error';\nimport type { CallOptions, HttpRequest, Transport } from '../../core/transport/types';\nimport { bytesToUtf8, fromHex, toHex } from '../../core/util/bytes';\nimport type { TronCallTags, TronResources } from './types';\n\nexport const READ: TronCallTags = { purpose: 'read', retry: 'safe' };\nexport const MONITOR: TronCallTags = { purpose: 'monitor', retry: 'safe' };\nexport const PROOF: TronCallTags = { purpose: 'proof', retry: 'safe', quorum: 'proof' };\nexport const BROADCAST: TronCallTags = {\n purpose: 'broadcast',\n retry: 'ambiguous-on-failure',\n};\n\n/** Adds the caller's signal to a tag set. */\nexport const withSignal = (tags: TronCallTags, signal?: AbortSignal): TronCallTags =>\n signal ? { ...tags, signal } : tags;\n\ntype Json = Record<string, unknown>;\ntype QuorumKey = (result: unknown) => unknown;\n\nexport function malformed(field: string): ProviderError {\n return new ProviderError('PROVIDER_UNAVAILABLE', `malformed ${field} in a Tron answer`);\n}\n\n/**\n * The node indexed a transaction it cannot serve whole yet (its receipt, the transaction or\n * its block): neither \"not seen\" nor a verdict. Retryable; the core keeps its current view.\n */\nexport function notServable(): ProviderError {\n return new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n 'the node indexed a transaction it cannot serve yet',\n );\n}\n\n/** A broadcast answer that cannot be read: the node may hold the transaction. */\nfunction unreadableAfterSend(field: string): ProviderError {\n return new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n `malformed ${field} in a Tron answer`,\n {\n ambiguous: true,\n },\n );\n}\n\nconst isObject = (value: unknown): value is Json =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n\nfunction object(value: unknown, field: string): Json {\n if (!isObject(value)) throw malformed(field);\n return value;\n}\n\n/**\n * A non-negative JSON integer: a bigint under `exactIntegers` when it is outside the\n * safe range, else a safe number. Amounts are never rounded.\n */\nfunction uint(value: unknown, field: string): bigint {\n if (typeof value === 'bigint' && value >= 0n) return value;\n if (typeof value === 'number' && Number.isSafeInteger(value) && value >= 0) {\n return BigInt(value);\n }\n throw malformed(field);\n}\n\n/** Like `uint`, but an absent value is 0 (proto3 JSON omits zero fields). */\nconst uintOr0 = (value: unknown, field: string): bigint =>\n value === undefined ? 0n : uint(value, field);\n\n/** java-tron's `long`: block heights above it are malformed. */\nconst INT64_MAX = 2n ** 63n - 1n;\n\n/** A block height: a non-negative int64. */\nfunction height(value: unknown, field: string): bigint {\n const n = uint(value, field);\n if (n > INT64_MAX) throw malformed(field);\n return n;\n}\n\n/**\n * An integer written into a request body as an exact JSON literal (`JSON.rawJSON`, Node ≥ 22):\n * java-tron reads int64 fields from number literals, and `Number()` would round above 2^53.\n */\nconst exactInteger = (value: bigint): unknown =>\n (JSON as unknown as { rawJSON(text: string): unknown }).rawJSON(value.toString());\n\n/** A block time in milliseconds: a safe non-negative integer, never rounded. */\nfunction millis(value: unknown, field: string): number {\n const ms = uint(value, field);\n if (ms > BigInt(Number.MAX_SAFE_INTEGER)) throw malformed(field);\n return Number(ms);\n}\n\n/**\n * A time java-tron reports in milliseconds as the Unix seconds every family's blocks and\n * transactions carry (`Block.timestamp`); Tron's own expiration arithmetic keeps\n * milliseconds.\n */\nexport function unixSeconds(ms: number): number {\n return Math.floor(ms / 1000);\n}\n\nfunction hex(value: unknown, field: string, bytes?: number): string {\n if (typeof value !== 'string' || !/^(?:[0-9a-fA-F]{2})*$/.test(value)) {\n throw malformed(field);\n }\n if (bytes !== undefined && value.length !== bytes * 2) throw malformed(field);\n return value.toLowerCase();\n}\n\nconst isEmpty = (value: unknown): boolean =>\n isObject(value) && Object.keys(value).length === 0;\n\n/**\n * java-tron refuses a transaction above `TRANSACTION_MAX_BYTE_SIZE` (500 KiB), so\n * longer raw bytes are malformed and never hashed or decoded.\n */\nconst MAX_RAW_HEX = 2 * 500 * 1024;\n\n// ---- consensus keys (quorum) ------------------------------------------------------------\n\nconst lower = (value: unknown): unknown =>\n typeof value === 'string'\n ? value.toLowerCase()\n : Array.isArray(value)\n ? value.map(lower)\n : value;\n\n/**\n * java-tron's HTTP 200 failure (`{ \"Error\": … }`) or a JSON-RPC error, keyed as a flag: it\n * never agrees with a real or an empty answer, and its text is never compared.\n */\nconst ERROR_KEY = { error: true } as const;\n/** java-tron's \"not found\" (`{}`); a non-empty answer without the facts never matches it. */\nconst ABSENT_KEY = { absent: true } as const;\n\nconst isErrorAnswer = (result: unknown): boolean =>\n isObject(result) && (result.Error !== undefined || result.error !== undefined);\n\n/** A REST key: an error answer is the error flag, `{}` is absent, else the `facts`. */\nconst restKey =\n (facts: (answer: Json) => unknown): QuorumKey =>\n (result) => {\n if (!isObject(result)) return result;\n if (isErrorAnswer(result)) return ERROR_KEY;\n if (Object.keys(result).length === 0) return ABSENT_KEY;\n return facts(result);\n };\n\nconst headerKey = restKey((answer) => {\n const header = isObject(answer.block_header) ? answer.block_header : undefined;\n const raw = header && isObject(header.raw_data) ? header.raw_data : undefined;\n return {\n id: lower(answer.blockID ?? null),\n // proto3 JSON omits genesis's number and timestamp: absent and 0 are one fact.\n number: raw ? (raw.number ?? 0) : null,\n parent: lower(raw?.parentHash ?? null),\n timestamp: raw ? (raw.timestamp ?? 0) : null,\n };\n});\n\n/**\n * A proven verdict reads the receipt result and the `Transfer` logs, so the\n * key covers them; hex case and fields nodes format differently do not count.\n */\nconst infoKey = restKey((answer) => {\n const receipt = isObject(answer.receipt) ? answer.receipt : {};\n const logs = Array.isArray(answer.log) ? answer.log : [];\n return {\n id: lower(answer.id ?? null),\n block: answer.blockNumber ?? null,\n // A proof binds the receipt to its block by this time, so it is attested.\n time: answer.blockTimeStamp ?? null,\n result: answer.result ?? null,\n receipt: receipt.result ?? null,\n logs: logs.map((log) =>\n isObject(log)\n ? { a: lower(log.address), t: lower(log.topics), d: lower(log.data) }\n : log,\n ),\n };\n});\n\nconst transactionKey = restKey((answer) => {\n const ret = Array.isArray(answer.ret) && isObject(answer.ret[0]) ? answer.ret[0] : {};\n return {\n id: lower(answer.txID ?? null),\n raw: lower(answer.raw_data_hex ?? null),\n ret: ret.contractRet ?? null,\n };\n});\n\n/** java-tron's answer for an address that holds no contract: its code and exact text. */\nfunction isNoContract(outcome: Json): boolean {\n return (\n outcome.result !== true &&\n outcome.code === 'CONTRACT_VALIDATE_ERROR' &&\n messageText(outcome.message) === 'Smart contract is not exist.'\n );\n}\n\n/**\n * A constant call's verdict, and nothing else. Each node builds the simulated\n * transaction on its own head (reference block, expiration, txID) and meters energy on its\n * own state, so honest nodes never agree on the whole answer. The key compares the outcome\n * (ran, no contract, or any other refusal: one value whose code and text are never\n * compared), whether the VM failed (`ret`), and what the call returned.\n */\nconst constantCallKey = restKey((answer) => {\n const outcome = isObject(answer.result) ? answer.result : {};\n const tx = isObject(answer.transaction) ? answer.transaction : {};\n const ret = Array.isArray(tx.ret) && isObject(tx.ret[0]) ? tx.ret[0].ret : undefined;\n return {\n outcome:\n outcome.result === true ? 'ok' : isNoContract(outcome) ? 'no-contract' : 'refused',\n ret: ret ?? null,\n out: lower(answer.constant_result ?? null),\n };\n});\n\n/** Whether a contract is there, and which: `{}` (none) keys as absent (`restKey`). */\nconst contractKey = restKey((answer) => ({\n contract: lower(answer.contract_address ?? null),\n}));\n\nfunction rpcBlockKey(result: unknown): unknown {\n if (!isObject(result)) return result;\n // An envelope without a result is an error, whatever else it holds.\n if (isErrorAnswer(result) || !Object.hasOwn(result, 'result')) return ERROR_KEY;\n const block = result.result;\n if (!isObject(block)) return block ?? null;\n // The negative scan stops on `timestamp`, so it is compared too: one lying endpoint\n // cannot end the scan early with an old time.\n return {\n number: lower(block.number ?? null),\n hash: lower(block.hash ?? null),\n parent: lower(block.parentHash ?? null),\n timestamp: lower(block.timestamp ?? null),\n transactions: lower(block.transactions ?? null),\n };\n}\n\nconst QUORUM_KEYS: Readonly<Record<string, QuorumKey>> = {\n '/wallet/getblock': headerKey,\n '/walletsolidity/getblock': headerKey,\n '/walletsolidity/gettransactioninfobyid': infoKey,\n '/wallet/gettransactioninfobyid': infoKey,\n '/walletsolidity/gettransactionbyid': transactionKey,\n '/wallet/gettransactionbyid': transactionKey,\n '/wallet/triggerconstantcontract': constantCallKey,\n '/wallet/getcontract': contractKey,\n '/jsonrpc': rpcBlockKey,\n};\n\n/** The consensus facts compared under a quorum for `path`, if it has any. */\nexport const quorumKeyFor = (path: string): QuorumKey | undefined =>\n Object.hasOwn(QUORUM_KEYS, path) ? QUORUM_KEYS[path] : undefined;\n\n/** A caller's key never makes an error answer agree with a real one. */\nconst guarded =\n (key: QuorumKey): QuorumKey =>\n (result) =>\n isErrorAnswer(result) ? ERROR_KEY : key(result);\n\n/**\n * One tagged transport call with exact integers. Under a quorum the caller's\n * `quorumKey` (a monotone predicate) replaces `fallback`; a key never travels\n * without a quorum.\n *\n * On a proof path a definitive refusal decides nothing, so it becomes a retryable\n * `PROVIDER_UNAVAILABLE`: a REST 4xx the quorum agreed on, and a 401 or 403 too. The\n * transport reports both as `PROVIDER_MISCONFIGURED` with no structured status, and TronGrid\n * answers a rate-limit suspension with 403 (\"Rate-limited requests usually return 429 or 403\n * and should be retried with backoff\", developers.tron.network/reference/rate-limits, read\n * 2026-09-27), so a proof cannot tell a bad key from a pause. A bad key still surfaces as\n * `PROVIDER_MISCONFIGURED` through the plain reads (monitor, read), which pass it unchanged:\n * on every endpoint when every key is bad; with one bad endpoint among several, a proof retries\n * until its breaker opens, and then the core reports the quorum unreachable. A caller's\n * abort is never converted. Other purposes see the transport's error unchanged.\n */\nasync function call(\n transport: Transport,\n request: HttpRequest,\n tags: TronCallTags,\n fallback?: QuorumKey,\n): Promise<unknown> {\n const { quorumKey: own, ...rest } = tags;\n const quorumKey = rest.quorum === undefined ? undefined : own ? guarded(own) : fallback;\n const options: CallOptions = {\n ...rest,\n exactIntegers: true,\n ...(quorumKey ? { quorumKey } : {}),\n };\n try {\n return await transport.http(request, options);\n } catch (error) {\n if (\n tags.purpose === 'proof' &&\n !tags.signal?.aborted &&\n error instanceof ProviderError &&\n !error.retryable\n ) {\n throw new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n 'a proof read was refused, which decides nothing',\n { cause: error, context: error.context, retryable: true },\n );\n }\n throw error;\n }\n}\n\n// ---- wire shapes --------------------------------------------------------------------------\n\nexport interface TronBlockHeader {\n readonly number: bigint;\n readonly id: string;\n readonly parentId: string;\n readonly timestamp: number;\n}\n\nexport interface TronLog {\n /** The emitter, 20-byte hex (no `41`). */\n readonly address: string;\n readonly topics: readonly string[];\n readonly data: string;\n}\n\nexport interface TronTxInfo {\n readonly id: string;\n readonly blockNumber: bigint;\n readonly blockTimestamp: number;\n /** Total TRX burned, in sun. */\n readonly fee: bigint;\n /** `receipt.result` of a contract call (`SUCCESS`, `REVERT`, `OUT_OF_ENERGY`, …). */\n readonly receiptResult?: string;\n /** `FAILED` when execution failed. */\n readonly failed: boolean;\n readonly logs: readonly TronLog[];\n}\n\nexport interface TronTxJson {\n readonly id: string;\n readonly rawHex: string;\n /** `ret[0].contractRet`, absent while pending. */\n readonly contractRet?: string;\n}\n\n/** The chain parameters the driver reads: its fees, and one TransferContract rule. */\nconst FEE_PARAMETERS = new Set([\n 'getTransactionFee',\n 'getEnergyFee',\n 'getCreateAccountFee',\n 'getCreateNewAccountFeeInSystemContract',\n 'getCreateNewAccountBandwidthRate',\n 'getMemoFee',\n 'getMaxFeeLimit',\n 'getForbidTransferToContract',\n]);\n\nexport interface ChainParameters {\n readonly transactionFee: bigint;\n readonly energyFee: bigint;\n readonly createAccountFee: bigint;\n readonly createNewAccountFeeInSystemContract: bigint;\n readonly createNewAccountBandwidthRate: bigint;\n readonly memoFee: bigint;\n readonly maxFeeLimit: bigint;\n /**\n * `getForbidTransferToContract` is 1: `TransferActuator` refuses TRX sent to a contract\n * account. 0 (proto3 JSON omits it) on mainnet, Nile and Shasta, read 2026-09-29.\n */\n readonly forbidTransferToContract: boolean;\n}\n\nexport type ConstantCall =\n | { readonly kind: 'ok'; readonly result: string; readonly energy: bigint }\n | { readonly kind: 'failed'; readonly energy: bigint }\n | { readonly kind: 'no-contract' };\n\nexport interface BroadcastAnswer {\n readonly accepted: boolean;\n readonly code?: string;\n /** The node's message, decoded when it is hex. Never stored or logged as is. */\n readonly message?: string;\n}\n\nexport interface RpcBlock {\n readonly number: bigint;\n readonly hash: string;\n readonly parentHash: string;\n readonly timestamp: number;\n readonly transactions: readonly string[];\n}\n\nfunction parseHeader(value: unknown): TronBlockHeader | null {\n if (isEmpty(value)) return null;\n const block = object(value, 'block');\n const raw = object(object(block.block_header, 'block header').raw_data, 'block header');\n // proto3 JSON omits zero fields: genesis has neither number nor timestamp.\n return {\n number: height(raw.number ?? 0, 'block number'),\n id: hex(block.blockID, 'block id', 32),\n parentId: hex(raw.parentHash, 'parent hash', 32),\n timestamp: millis(raw.timestamp ?? 0, 'block timestamp'),\n };\n}\n\nfunction parseTransaction(value: unknown): TronTxJson {\n const tx = object(value, 'transaction');\n const ret =\n Array.isArray(tx.ret) && isObject(tx.ret[0]) ? tx.ret[0].contractRet : undefined;\n if (ret !== undefined && typeof ret !== 'string') throw malformed('contractRet');\n const id = hex(tx.txID, 'txID', 32);\n if (typeof tx.raw_data_hex === 'string' && tx.raw_data_hex.length > MAX_RAW_HEX) {\n throw malformed('raw_data_hex');\n }\n const rawHex = hex(tx.raw_data_hex, 'raw_data_hex');\n // The id is the SHA-256 of the raw bytes: an answer that does not bind them is malformed.\n if (toHex(sha256(fromHex(rawHex))) !== id) throw malformed('raw_data_hex');\n return {\n id,\n rawHex,\n ...(ret !== undefined ? { contractRet: ret } : {}),\n };\n}\n\nfunction parseInfo(value: unknown): TronTxInfo {\n const info = object(value, 'transaction info');\n const receipt = info.receipt === undefined ? {} : object(info.receipt, 'receipt');\n const logs = info.log === undefined ? [] : info.log;\n if (!Array.isArray(logs)) throw malformed('log');\n const receiptResult = receipt.result;\n if (receiptResult !== undefined && typeof receiptResult !== 'string') {\n throw malformed('receipt result');\n }\n if (info.result !== undefined && info.result !== 'FAILED') throw malformed('result');\n return {\n id: hex(info.id, 'transaction id', 32),\n blockNumber: height(info.blockNumber, 'block number'),\n blockTimestamp: millis(info.blockTimeStamp, 'block timestamp'),\n fee: uintOr0(info.fee, 'fee'),\n ...(receiptResult !== undefined ? { receiptResult } : {}),\n failed: info.result === 'FAILED',\n logs: logs.map((entry) => {\n const log = object(entry, 'log');\n if (!Array.isArray(log.topics)) throw malformed('log topics');\n return {\n address: hex(log.address, 'log address', 20),\n topics: log.topics.map((t) => hex(t, 'log topic', 32)),\n data: log.data === undefined ? '' : hex(log.data, 'log data'),\n };\n }),\n };\n}\n\n/** The longest node message kept, in characters: java-tron's texts are far shorter. */\nconst MAX_MESSAGE = 1024;\n\n/**\n * A node's message field: hex-encoded UTF-8 on some paths, plain text on others. At most\n * the first 1 KiB is kept, decoded when the whole field is printable hex.\n */\nexport function messageText(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined;\n if (/^(?:[0-9a-fA-F]{2})+$/.test(value)) {\n const text = bytesToUtf8(fromHex(value.slice(0, 2 * MAX_MESSAGE)));\n if (/^[\\x20-\\x7e]+$/.test(text)) return text;\n }\n return value.slice(0, MAX_MESSAGE);\n}\n\n/** A JSON-RPC 32-byte hash, lower-case without `0x`. */\nfunction rpcHash(value: unknown, field: string): string {\n if (typeof value !== 'string' || !/^0x[0-9a-fA-F]{64}$/.test(value)) {\n throw malformed(field);\n }\n return value.slice(2).toLowerCase();\n}\n\n/** A JSON-RPC quantity of at most 64 bits (bounded before conversion). */\nfunction rpcQuantity(value: unknown, field: string): bigint {\n if (typeof value !== 'string' || !/^0x[0-9a-fA-F]{1,16}$/.test(value)) {\n throw malformed(field);\n }\n return BigInt(value);\n}\n\n// ---- the API ----------------------------------------------------------------------------\n\nexport class TronApi {\n readonly #transport: Transport;\n\n constructor(transport: Transport) {\n this.#transport = transport;\n }\n\n /**\n * One POST to `path`, answered as JSON; a node `Error` answer is a retryable RPC_ERROR\n * (possibly sent, on a broadcast).\n */\n async post(path: string, body: Json, tags: TronCallTags): Promise<unknown> {\n const answer = await call(\n this.#transport,\n { method: 'POST', path, body, route: path },\n tags,\n quorumKeyFor(path),\n );\n if (isObject(answer) && answer.Error !== undefined) {\n throw new ProviderError('RPC_ERROR', `the node answered an error on ${path}`, {\n retryable: true,\n ...(tags.purpose === 'broadcast' ? { ambiguous: true } : {}),\n });\n }\n return answer;\n }\n\n /** The head (`scope: 'full'`) or latest solidified block, or one by height or id. */\n async block(\n scope: 'full' | 'solid',\n ref: bigint | string | undefined,\n tags: TronCallTags,\n ): Promise<TronBlockHeader | null> {\n const path = scope === 'full' ? '/wallet/getblock' : '/walletsolidity/getblock';\n const answer = await this.post(\n path,\n { ...(ref !== undefined ? { id_or_num: ref.toString() } : {}), detail: false },\n tags,\n );\n const header = parseHeader(answer);\n if (header && typeof ref === 'bigint' && header.number !== ref) {\n throw malformed('block number');\n }\n if (header && typeof ref === 'string' && header.id !== ref.toLowerCase()) {\n throw malformed('block id');\n }\n if (ref === undefined && header === null) throw malformed('head block');\n return header;\n }\n\n /**\n * A block with its transactions and their infos (the scanner's read). Block 0 is its\n * header alone: java-tron answers `{}` to `gettransactioninfobyblocknum` there\n * (`GetTransactionInfoByBlockNumServlet`, GreatVoyage-v4.8.2.2; Nile checked 2026-09-27),\n * a malformed answer the scanner would retry for ever, and genesis holds only the chain's\n * initial allocations, which are not reported.\n */\n async blockWithTransactions(\n height: bigint,\n tags: TronCallTags,\n ): Promise<{\n readonly header: TronBlockHeader;\n readonly transactions: readonly TronTxJson[];\n readonly infos: readonly TronTxInfo[];\n } | null> {\n if (height === 0n) {\n const genesis = await this.block('full', 0n, tags);\n return genesis ? { header: genesis, transactions: [], infos: [] } : null;\n }\n const answer = await this.post(\n '/wallet/getblock',\n { id_or_num: height.toString(), detail: true },\n tags,\n );\n const header = parseHeader(answer);\n if (header === null) return null;\n if (header.number !== height) throw malformed('block number');\n const list = (answer as Json).transactions ?? [];\n if (!Array.isArray(list)) throw malformed('transactions');\n const transactions = list.map(parseTransaction);\n const infosAnswer = await this.post(\n '/wallet/gettransactioninfobyblocknum',\n { num: exactInteger(height) },\n tags,\n );\n if (!Array.isArray(infosAnswer)) throw malformed('transaction infos');\n const infos = infosAnswer.map(parseInfo);\n if (infos.some((i) => i.blockNumber !== height)) throw malformed('transaction infos');\n // Two calls can reach two backends behind one URL: the receipts must be exactly this\n // block's, one per transaction.\n const ids = new Set(transactions.map((t) => t.id));\n const receipted = new Set(infos.map((i) => i.id));\n if (\n ids.size !== transactions.length ||\n receipted.size !== infos.length ||\n infos.length !== transactions.length ||\n infos.some((i) => !ids.has(i.id))\n ) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n `block ${height}'s receipts do not match its transactions`,\n { retryable: true },\n );\n }\n return { header, transactions, infos };\n }\n\n async chainParameters(tags: TronCallTags): Promise<ChainParameters> {\n const answer = object(\n await this.post('/wallet/getchainparameters', {}, tags),\n 'parameters',\n );\n const list = answer.chainParameter;\n if (!Array.isArray(list)) throw malformed('chain parameters');\n // Only the parameters the driver reads are validated: others may be negative (e.g.\n // Nile's `getRemoveThePowerOfTheGr` is -1) and must not fail the read.\n const values = new Map<string, bigint>();\n for (const entry of list) {\n const item = object(entry, 'chain parameter');\n if (typeof item.key !== 'string') throw malformed('chain parameter');\n if (FEE_PARAMETERS.has(item.key)) {\n values.set(item.key, uintOr0(item.value, item.key));\n }\n }\n const required = (key: string): bigint => {\n const value = values.get(key);\n if (value === undefined || value === 0n) throw malformed(key);\n return value;\n };\n return {\n transactionFee: required('getTransactionFee'),\n energyFee: required('getEnergyFee'),\n createAccountFee: values.get('getCreateAccountFee') ?? 0n,\n createNewAccountFeeInSystemContract:\n values.get('getCreateNewAccountFeeInSystemContract') ?? 0n,\n createNewAccountBandwidthRate: values.get('getCreateNewAccountBandwidthRate') ?? 1n,\n memoFee: values.get('getMemoFee') ?? 0n,\n maxFeeLimit: required('getMaxFeeLimit'),\n forbidTransferToContract: values.get('getForbidTransferToContract') === 1n,\n };\n }\n\n /** `{ exists: false }` for an account that was never activated. */\n async account(\n addressHex: string,\n tags: TronCallTags,\n ): Promise<{ readonly exists: boolean; readonly balance: bigint }> {\n const answer = object(\n await this.post('/wallet/getaccount', { address: addressHex }, tags),\n 'account',\n );\n if (Object.keys(answer).length === 0) return { exists: false, balance: 0n };\n if (\n typeof answer.address !== 'string' ||\n answer.address.toLowerCase() !== addressHex.toLowerCase()\n ) {\n throw malformed('account address');\n }\n return { exists: true, balance: uintOr0(answer.balance, 'balance') };\n }\n\n async resources(addressHex: string, tags: TronCallTags): Promise<TronResources> {\n const r = object(\n await this.post('/wallet/getaccountresource', { address: addressHex }, tags),\n 'account resources',\n );\n if (Object.keys(r).length === 0) {\n return { activated: false, freeBandwidth: 0n, stakedBandwidth: 0n, energy: 0n };\n }\n const left = (limit: unknown, used: unknown, field: string): bigint => {\n const value = uintOr0(limit, field) - uintOr0(used, field);\n return value > 0n ? value : 0n;\n };\n return {\n activated: true,\n freeBandwidth: left(r.freeNetLimit, r.freeNetUsed, 'free bandwidth'),\n stakedBandwidth: left(r.NetLimit, r.NetUsed, 'bandwidth'),\n energy: left(r.EnergyLimit, r.EnergyUsed, 'energy'),\n };\n }\n\n /**\n * A constant (simulated) contract call. `no-contract` when the address holds no contract;\n * `failed` when the call reverts or the VM fails; any other refusal is a retryable\n * RPC_ERROR.\n */\n async constantCall(\n ownerHex: string,\n contractHex: string,\n data: string,\n tags: TronCallTags,\n ): Promise<ConstantCall> {\n const answer = object(\n await this.post(\n '/wallet/triggerconstantcontract',\n { owner_address: ownerHex, contract_address: contractHex, data },\n tags,\n ),\n 'constant call',\n );\n const result = object(answer.result, 'constant call result');\n if (result.result !== true) {\n if (isNoContract(result)) return { kind: 'no-contract' };\n throw new ProviderError('RPC_ERROR', 'the node refused a contract call', {\n retryable: true,\n });\n }\n const tx =\n answer.transaction === undefined ? {} : object(answer.transaction, 'transaction');\n const ret = Array.isArray(tx.ret) && isObject(tx.ret[0]) ? tx.ret[0].ret : undefined;\n if (ret === 'FAILED') {\n return { kind: 'failed', energy: uintOr0(answer.energy_used, 'energy used') };\n }\n const out = answer.constant_result;\n if (!Array.isArray(out) || out.length !== 1) throw malformed('constant result');\n // A call that ran used energy, and the fee estimate is built on it; a missing or\n // zero `energy_used` is a malformed answer, never 0 (a 0 fee limit fails on chain).\n const energy = uint(answer.energy_used, 'energy used');\n if (energy === 0n) throw malformed('energy used');\n return { kind: 'ok', result: hex(out[0], 'constant result'), energy };\n }\n\n /**\n * Whether `addressHex` holds a contract (`/wallet/getcontract`): java-tron answers `{}`\n * when the account or its contract does not exist (`Wallet.getContract`, GreatVoyage-v4.8.2.2\n * `d5c3d1d1`), else the `SmartContract`. The structural check behind a constant call's\n * \"no contract\" text before anyone caches it; an answer about another address is\n * malformed.\n */\n async contractExists(addressHex: string, tags: TronCallTags): Promise<boolean> {\n const answer = object(\n await this.post('/wallet/getcontract', { value: addressHex }, tags),\n 'contract',\n );\n if (Object.keys(answer).length === 0) return false;\n // java-tron's `SmartContract` always names its address; an answer that\n // names none, or another, is malformed.\n const address = answer.contract_address;\n if (\n typeof address !== 'string' ||\n address.toLowerCase() !== addressHex.toLowerCase()\n ) {\n throw malformed('contract');\n }\n return true;\n }\n\n /**\n * `/wallet/broadcasthex`. java-tron answers refusals with HTTP 200, so the answer is read\n * here; one that cannot be read is possibly sent (the node may hold the bytes).\n */\n async broadcastHex(hexTx: string, tags: TronCallTags): Promise<BroadcastAnswer> {\n const answer = await this.post('/wallet/broadcasthex', { transaction: hexTx }, tags);\n if (!isObject(answer)) throw unreadableAfterSend('broadcast answer');\n if (answer.result === true) return { accepted: true };\n if (typeof answer.code !== 'string') throw unreadableAfterSend('broadcast code');\n const message = messageText(answer.message);\n return { accepted: false, code: answer.code, ...(message ? { message } : {}) };\n }\n\n /** An included transaction (`full`: any block; `solid`: a solidified one), or null. */\n async transaction(\n scope: 'full' | 'solid',\n id: string,\n tags: TronCallTags,\n ): Promise<TronTxJson | null> {\n const path =\n scope === 'full'\n ? '/wallet/gettransactionbyid'\n : '/walletsolidity/gettransactionbyid';\n const answer = await this.post(path, { value: id }, tags);\n if (isEmpty(answer)) return null;\n const tx = parseTransaction(answer);\n if (tx.id !== id.toLowerCase()) throw malformed('transaction id');\n return tx;\n }\n\n async transactionInfo(\n scope: 'full' | 'solid',\n id: string,\n tags: TronCallTags,\n ): Promise<TronTxInfo | null> {\n const path =\n scope === 'full'\n ? '/wallet/gettransactioninfobyid'\n : '/walletsolidity/gettransactioninfobyid';\n const answer = await this.post(path, { value: id }, tags);\n if (isEmpty(answer)) return null;\n const info = parseInfo(answer);\n if (info.id !== id.toLowerCase()) throw malformed('transaction id');\n return info;\n }\n\n /** The transaction if the node holds `id` in its pending pool, else null. */\n async pending(id: string, tags: TronCallTags): Promise<TronTxJson | null> {\n const answer = await this.post(\n '/wallet/gettransactionfrompending',\n { value: id },\n tags,\n );\n if (isEmpty(answer)) return null;\n const tx = parseTransaction(answer);\n if (tx.id !== id.toLowerCase()) throw malformed('transaction id');\n return tx;\n }\n\n /** The node's JSON-RPC block read (transaction ids only), or null when it has none. */\n async rpcBlock(ref: bigint | string, tags: TronCallTags): Promise<RpcBlock | null> {\n const byHash = typeof ref === 'string';\n const answer = object(\n await this.post(\n '/jsonrpc',\n {\n jsonrpc: '2.0',\n id: 1,\n method: byHash ? 'eth_getBlockByHash' : 'eth_getBlockByNumber',\n params: [byHash ? `0x${ref}` : `0x${ref.toString(16)}`, false],\n },\n tags,\n ),\n 'JSON-RPC answer',\n );\n if (answer.error !== undefined) {\n throw new ProviderError('RPC_ERROR', 'the node answered a JSON-RPC error', {\n retryable: true,\n });\n }\n if (answer.result === null) return null;\n const block = object(answer.result, 'JSON-RPC block');\n const txs = block.transactions;\n if (!Array.isArray(txs)) throw malformed('JSON-RPC transactions');\n const seconds = rpcQuantity(block.timestamp, 'JSON-RPC timestamp');\n if (seconds * 1000n > BigInt(Number.MAX_SAFE_INTEGER)) {\n throw malformed('JSON-RPC timestamp');\n }\n const number = rpcQuantity(block.number, 'JSON-RPC number');\n if (number > INT64_MAX) throw malformed('JSON-RPC number');\n const parsed: RpcBlock = {\n number,\n hash: rpcHash(block.hash, 'JSON-RPC hash'),\n parentHash: rpcHash(block.parentHash, 'JSON-RPC parent hash'),\n timestamp: Number(seconds) * 1000,\n transactions: txs.map((t) => rpcHash(t, 'JSON-RPC transaction')),\n };\n if (byHash ? parsed.hash !== ref.toLowerCase() : parsed.number !== ref) {\n throw malformed('JSON-RPC block');\n }\n return parsed;\n }\n}\n\n/**\n * A base58 account address, the only form sent to TronGrid: it becomes a URL path segment,\n * so anything else is refused before any call.\n */\nconst BASE58_ACCOUNT = /^T[1-9A-HJ-NP-Za-km-z]{33}$/;\n\n/**\n * TronGrid's page cursor, bounded in length and charset. Observed on 2026-09-27: 221 to\n * 224 base58 characters; the bound leaves room for base64 forms.\n */\nconst FINGERPRINT = /^[0-9A-Za-z+/=_-]{1,1024}$/;\n\n/** A 32-byte id as TronGrid writes it: 64 hex digits (one class, bounded). */\nconst ID_HEX = /^[0-9a-fA-F]{64}$/;\n\n/** TronGrid's documented internal-transaction entry: its own id and its parent's. */\nconst isInternalEntry = (entry: Json): boolean =>\n typeof entry.internal_tx_id === 'string' &&\n ID_HEX.test(entry.internal_tx_id) &&\n typeof entry.tx_id === 'string' &&\n ID_HEX.test(entry.tx_id);\n\n/**\n * TronGrid `/v1` account history pages (indexer transport), confirmed entries only. Each\n * transaction id is listed once per page: the TRC-20 stream lists a transaction once per\n * transfer it made.\n *\n * Internal transactions are not listed. `search_internal=false` asks TronGrid for none,\n * and an internal entry it mixes in anyway is skipped: TronGrid documents that entry shape\n * (`internal_tx_id`, `tx_id`, `from_address`, `to_address`, `data`, `block_timestamp`; its\n * OpenAPI schema at developers.tron.network/reference/get-transaction-info-by-account-address)\n * and it has no `txID`, so one would make the whole page malformed. Only an entry without\n * an id of its own that carries both documented ids is skipped. Read on 2026-09-27,\n * `GET api.trongrid.io/v1/accounts/TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR/transactions?limit=20`\n * (WTRX) gave only whole transactions (`txID`, `raw_data_hex`, …), each with the internal\n * transfers nested in `internal_transactions[]` (`internal_tx_id`, `data`, `from_address`,\n * `to_address`); five other accounts, internal-TRX recipients among them, looked the same\n * with `search_internal` true or false. A TRX amount an account received only through a\n * contract's internal transfer is therefore not in its history.\n */\nexport async function historyPage(\n transport: Transport,\n address: string,\n kind: 'transactions' | 'trc20',\n options: { readonly limit: number; readonly fingerprint?: string },\n tags: TronCallTags,\n): Promise<{ readonly ids: readonly string[]; readonly next?: string }> {\n if (typeof address !== 'string' || !BASE58_ACCOUNT.test(address)) {\n throw new ValidationError('INVALID_ADDRESS', 'not a Tron address');\n }\n if (options.fingerprint !== undefined && !FINGERPRINT.test(options.fingerprint)) {\n throw new ConfigError('CONFIG_INVALID', 'not a Tron history cursor');\n }\n const suffix = kind === 'trc20' ? '/trc20' : '';\n const answer = object(\n await call(\n transport,\n {\n method: 'GET',\n path: `/v1/accounts/${address}/transactions${suffix}`,\n route: `/v1/accounts/:address/transactions${suffix}`,\n query: {\n limit: String(options.limit),\n only_confirmed: 'true',\n ...(kind === 'transactions' ? { search_internal: 'false' } : {}),\n ...(options.fingerprint !== undefined\n ? { fingerprint: options.fingerprint }\n : {}),\n },\n },\n tags,\n ),\n 'history page',\n );\n // Each listed id costs several node reads, so a page longer than asked\n // for is malformed rather than read.\n if (\n answer.success !== true ||\n !Array.isArray(answer.data) ||\n answer.data.length > options.limit\n ) {\n throw malformed('history page');\n }\n const meta = answer.meta === undefined ? {} : object(answer.meta, 'history meta');\n const next = meta.fingerprint;\n if (\n next !== undefined &&\n next !== '' &&\n (typeof next !== 'string' || !FINGERPRINT.test(next))\n ) {\n throw malformed('history fingerprint');\n }\n const ids: string[] = [];\n for (const item of answer.data) {\n const entry = object(item, 'history item');\n const id = kind === 'trc20' ? entry.transaction_id : entry.txID;\n // An entry is skipped only when its own fields prove it TronGrid's internal entry:\n // no id of its own, and the documented internal and parent ids. Any entry that\n // carries its id is read whatever else it carries, and anything else is malformed\n // (the page is read again), so a schema change never drops a deposit silently.\n if (id === undefined && isInternalEntry(entry)) continue;\n ids.push(hex(id, 'history id', 32));\n }\n return {\n ids: [...new Set(ids)],\n ...(typeof next === 'string' && next !== '' ? { next } : {}),\n };\n}\n"]}
|
|
@@ -2,8 +2,11 @@ import { type Capability } from '../../core/model/capability';
|
|
|
2
2
|
import type { ChainInfo, NetworkInfo } from '../../core/model/chain';
|
|
3
3
|
/** Every capability of the Tron driver; `address-history` comes with an indexer. */
|
|
4
4
|
export declare const TRON_CAPABILITIES: readonly Capability[];
|
|
5
|
+
/** The capabilities a Tron handle gains when it has an `indexer` (TronGrid's history API). */
|
|
5
6
|
export declare const TRON_INDEXER_CAPABILITIES: readonly Capability[];
|
|
7
|
+
/** The expiration window a Tron transaction gets unless `expirationMs` sets another. */
|
|
6
8
|
export declare const DEFAULT_EXPIRATION_MS = 60000;
|
|
9
|
+
/** The shortest expiration window this driver builds. */
|
|
7
10
|
export declare const MIN_EXPIRATION_MS = 10000;
|
|
8
11
|
/**
|
|
9
12
|
* The longest expiration window this driver builds. The negative inclusion proof does
|
|
@@ -18,6 +21,7 @@ export declare const MAX_EXPIRATION_MS = 300000;
|
|
|
18
21
|
* transaction, and an Attempt's `lastValidHeight` is its reference height plus this window.
|
|
19
22
|
*/
|
|
20
23
|
export declare const TAPOS_WINDOW = 65536n;
|
|
24
|
+
/** How much the energy a TRC-20 transfer's fee limit allows exceeds the estimate, in percent. */
|
|
21
25
|
export declare const DEFAULT_ENERGY_MARGIN_PERCENT = 20;
|
|
22
26
|
/**
|
|
23
27
|
* The largest fee limit a TRC-20 transfer carries unless the handle's `maxFeeLimit` option
|
|
@@ -18,10 +18,13 @@ exports.TRON_CAPABILITIES = Object.freeze([
|
|
|
18
18
|
'hd-public-derivation',
|
|
19
19
|
'expiry',
|
|
20
20
|
]);
|
|
21
|
+
/** The capabilities a Tron handle gains when it has an `indexer` (TronGrid's history API). */
|
|
21
22
|
exports.TRON_INDEXER_CAPABILITIES = Object.freeze([
|
|
22
23
|
'address-history',
|
|
23
24
|
]);
|
|
25
|
+
/** The expiration window a Tron transaction gets unless `expirationMs` sets another. */
|
|
24
26
|
exports.DEFAULT_EXPIRATION_MS = 60_000;
|
|
27
|
+
/** The shortest expiration window this driver builds. */
|
|
25
28
|
exports.MIN_EXPIRATION_MS = 10_000;
|
|
26
29
|
/**
|
|
27
30
|
* The longest expiration window this driver builds. The negative inclusion proof does
|
|
@@ -36,6 +39,7 @@ exports.MAX_EXPIRATION_MS = 300_000;
|
|
|
36
39
|
* transaction, and an Attempt's `lastValidHeight` is its reference height plus this window.
|
|
37
40
|
*/
|
|
38
41
|
exports.TAPOS_WINDOW = 65536n;
|
|
42
|
+
/** How much the energy a TRC-20 transfer's fee limit allows exceeds the estimate, in percent. */
|
|
39
43
|
exports.DEFAULT_ENERGY_MARGIN_PERCENT = 20;
|
|
40
44
|
/**
|
|
41
45
|
* The largest fee limit a TRC-20 transfer carries unless the handle's `maxFeeLimit` option
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/adapters/tron/network.ts"],"names":[],"mappings":";;;AAkJA,8CAwDC;AA1MD;;;;GAIG;AACH,mDAAsD;AACtD,4DAAkF;AAElF,iDAA+D;AAE/D,oFAAoF;AACvE,QAAA,iBAAiB,GAA0B,MAAM,CAAC,MAAM,CAAC;IACpE,QAAQ;IACR,MAAM;IACN,YAAY;IACZ,sBAAsB;IACtB,QAAQ;CACT,CAAC,CAAC;AACU,QAAA,yBAAyB,GAA0B,MAAM,CAAC,MAAM,CAAC;IAC5E,iBAAiB;CAClB,CAAC,CAAC;AAEU,QAAA,qBAAqB,GAAG,MAAM,CAAC;AAC/B,QAAA,iBAAiB,GAAG,MAAM,CAAC;AACxC;;;GAGG;AACU,QAAA,iBAAiB,GAAG,OAAO,CAAC;AACzC;;;;;;GAMG;AACU,QAAA,YAAY,GAAG,MAAO,CAAC;AACvB,QAAA,6BAA6B,GAAG,EAAE,CAAC;AAChD;;;;;;;;GAQG;AACU,QAAA,qBAAqB,GAAG,UAAY,CAAC;AAClD,sEAAsE;AACzD,QAAA,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACvE,sDAAsD;AACzC,QAAA,cAAc,GAAG,GAAG,CAAC;AAWlC;;;;GAIG;AACH,MAAM,WAAW,GAAsB,MAAM,CAAC,MAAM,C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AC,QAAkB;QACpC,YAAY,EACV,OAAO,CAAC,YAAY,KAAK,SAAS;YAChC,CAAC,CAAC,6BAAqB;YACvB,CAAC,CAAC,SAAS,CACP,OAAO,CAAC,YAAY,EACpB,yBAAiB,EACjB,yBAAiB,EACjB,cAAc,EACd,IAAI,CACL;QACP,mBAAmB,EACjB,OAAO,CAAC,mBAAmB,KAAK,SAAS;YACvC,CAAC,CAAC,qCAA6B;YAC/B,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,EAAE,KAAK,EAAE,qBAAqB,EAAE,IAAI,CAAC;QACnF,WAAW;KACZ,CAAC;AACJ,CAAC","sourcesContent":["/**\n * What the Tron driver needs from a network's registry entry and the handle's options,\n * validated once when a driver is created: a custom network or option with\n * inconsistent data fails with `CONFIG_INVALID` instead of misbehaving.\n */\nimport { ConfigError } from '../../core/errors/error';\nimport { KNOWN_CAPABILITIES, type Capability } from '../../core/model/capability';\nimport type { ChainInfo, NetworkInfo } from '../../core/model/chain';\nimport { knownName, unknownName } from '../../core/util/names';\n\n/** Every capability of the Tron driver; `address-history` comes with an indexer. */\nexport const TRON_CAPABILITIES: readonly Capability[] = Object.freeze([\n 'tokens',\n 'memo',\n 'block-scan',\n 'hd-public-derivation',\n 'expiry',\n]);\nexport const TRON_INDEXER_CAPABILITIES: readonly Capability[] = Object.freeze([\n 'address-history',\n]);\n\nexport const DEFAULT_EXPIRATION_MS = 60_000;\nexport const MIN_EXPIRATION_MS = 10_000;\n/**\n * The longest expiration window this driver builds. The negative inclusion proof does\n * not depend on it: it scans from the reference block to the signed expiration.\n */\nexport const MAX_EXPIRATION_MS = 300_000;\n/**\n * TaPoS (java-tron GreatVoyage-v4.8.2.2 `d5c3d1d1`, `Manager.validateTapos` and\n * `updateRecentBlock`): a transaction's reference block must be the one the recent-block\n * store holds under its number's bytes 6..8, and each block overwrites the entry of the block\n * 65,536 below it. So only the 65,536 blocks after the reference block can hold the\n * transaction, and an Attempt's `lastValidHeight` is its reference height plus this window.\n */\nexport const TAPOS_WINDOW = 65_536n;\nexport const DEFAULT_ENERGY_MARGIN_PERCENT = 20;\n/**\n * The largest fee limit a TRC-20 transfer carries unless the handle's `maxFeeLimit` option\n * allows more: 100 TRX, in sun. The network's own maximum (`getMaxFeeLimit`, 15,000\n * TRX on mainnet), the energy price and the simulated energy all come from one endpoint's\n * answer, and a call that fails through an INVALID opcode (a Solidity `assert`) burns its\n * whole fee limit, so this operator bound is the only one no node can raise. It covers a\n * TRC-20 transfer to a new holder (about 130,000 energy) at 420 sun per energy, margin\n * included.\n */\nexport const DEFAULT_MAX_FEE_LIMIT = 100_000_000n;\n/** The largest `fee_limit` the codec writes exactly: 2^53 − 1 sun. */\nexport const MAX_ENCODABLE_FEE_LIMIT = BigInt(Number.MAX_SAFE_INTEGER);\n/** Memo bytes (UTF-8) accepted in `raw_data.data`. */\nexport const MAX_MEMO_BYTES = 256;\n\nexport interface TronNetworkConfig {\n /** The id of block 0, which the identity probe compares. */\n readonly identity: string;\n readonly expirationMs: number;\n readonly energyMarginPercent: number;\n /** The largest fee limit a transfer may carry, in sun: from 1 to 2^53 − 1. */\n readonly maxFeeLimit: bigint;\n}\n\n/**\n * The only driver options (`HandleOptions.options`) the Tron driver reads. Any other key is\n * refused, so a typo such as `expirationMS` fails loudly instead of leaving the default in\n * place.\n */\nconst OPTION_KEYS: readonly string[] = Object.freeze([\n 'expirationMs',\n 'energyMarginPercent',\n 'maxFeeLimit',\n]);\n/**\n * A capability from the network entry as an error may show it: a core capability's\n * name is a fixed word, so it is shown; any other text could be a pasted secret, so it is not.\n */\nconst named = (key: unknown): string =>\n knownName(key, KNOWN_CAPABILITIES, 'an unknown capability');\n\n/**\n * A network's capability overrides, checked against what the Tron driver serves,\n * as `evmNetworkConfig` checks the EVM ones. The handle advertises the manifest's\n * capabilities plus `add`, minus `remove` (the core's order), so that set must stay within\n * the driver's own: no `replace-fee` or `cancel` (no replacement), no `fee-market-1559` (the\n * `tron` fee model), no `finality-tag` (solidified finality), no `batch-transfer`.\n * `address-history` comes with an indexer, never from the network, and `expiry` is how every\n * Tron transaction is ordered: removing it would disable the proof that an Attempt\n * expired. A removal must name a Tron capability, so a typo fails instead of leaving the\n * capability advertised.\n */\nfunction checkCapabilities(network: NetworkInfo, fail: (reason: string) => never): void {\n const add: unknown = network.capabilities?.add ?? [];\n const remove: unknown = network.capabilities?.remove ?? [];\n if (!Array.isArray(add) || !Array.isArray(remove)) {\n return fail('capabilities.add and capabilities.remove must be lists');\n }\n const own = (list: readonly Capability[], c: unknown) => list.includes(c as Capability);\n const advertised = new Set<unknown>([...TRON_CAPABILITIES, ...add]);\n for (const c of remove) {\n if (!own(TRON_CAPABILITIES, c) && !own(TRON_INDEXER_CAPABILITIES, c)) {\n fail(`capabilities.remove: the Tron driver does not have ${named(c)}`);\n }\n advertised.delete(c);\n }\n for (const c of advertised) {\n if (own(TRON_INDEXER_CAPABILITIES, c)) {\n fail(`capabilities.add: ${named(c)} comes with an indexer, never from the network`);\n }\n if (!own(TRON_CAPABILITIES, c)) {\n fail(`capabilities.add: the Tron driver does not have ${named(c)}`);\n }\n }\n if (!advertised.has('expiry')) {\n fail(`capabilities.remove: every Tron transaction expires, so 'expiry' stays`);\n }\n}\n\nfunction integerIn(\n value: unknown,\n min: number,\n max: number,\n name: string,\n fail: (reason: string) => never,\n): number {\n if (\n !Number.isSafeInteger(value) ||\n (value as number) < min ||\n (value as number) > max\n ) {\n fail(`${name} must be an integer from ${min} to ${max}`);\n }\n return value as number;\n}\n\n/** A fee-limit bound: a bigint of sun from 1 to what the codec writes exactly. */\nfunction feeLimitBound(\n value: unknown,\n name: string,\n fail: (reason: string) => never,\n): bigint {\n if (typeof value !== 'bigint' || value < 1n || value > MAX_ENCODABLE_FEE_LIMIT) {\n fail(`${name} must be a bigint of sun from 1 to 2^53 − 1`);\n }\n return value as bigint;\n}\n\nexport function tronNetworkConfig(\n chain: ChainInfo,\n network: NetworkInfo,\n options: Readonly<Record<string, unknown>> = {},\n): TronNetworkConfig {\n const fail = (reason: string): never => {\n throw new ConfigError(\n 'CONFIG_INVALID',\n `Tron network ${chain.id}:${network.id}: ${reason}`,\n );\n };\n if (chain.family !== 'tron' || chain.ordering !== 'expiry') {\n fail(`the chain must be of family 'tron' with 'expiry' ordering`);\n }\n if (network.identity === undefined || !/^[0-9a-f]{64}$/.test(network.identity)) {\n fail('its identity must be the id of block 0 (64 lower-case hex digits)');\n }\n if (network.feeModel !== 'tron') fail(`its fee model must be 'tron'`);\n if (network.finality.kind !== 'solidified') fail(`its finality must be 'solidified'`);\n checkCapabilities(network, fail);\n // The refusal lists the accepted names and shows neither the caller's key, which\n // may be a pasted secret, nor its value.\n for (const key of Object.keys(options)) {\n if (!OPTION_KEYS.includes(key)) {\n fail(unknownName('option', OPTION_KEYS));\n }\n }\n // The handle's option, else the network entry's own, else 100 TRX. A network\n // value is checked even where an option overrides it, so a bad entry fails loudly.\n const ownBound = network.params?.maxFeeLimit;\n const networkBound =\n ownBound === undefined\n ? undefined\n : feeLimitBound(ownBound, 'params.maxFeeLimit', fail);\n const maxFeeLimit =\n options.maxFeeLimit !== undefined\n ? feeLimitBound(options.maxFeeLimit, 'maxFeeLimit', fail)\n : (networkBound ?? DEFAULT_MAX_FEE_LIMIT);\n return {\n identity: network.identity as string,\n expirationMs:\n options.expirationMs === undefined\n ? DEFAULT_EXPIRATION_MS\n : integerIn(\n options.expirationMs,\n MIN_EXPIRATION_MS,\n MAX_EXPIRATION_MS,\n 'expirationMs',\n fail,\n ),\n energyMarginPercent:\n options.energyMarginPercent === undefined\n ? DEFAULT_ENERGY_MARGIN_PERCENT\n : integerIn(options.energyMarginPercent, 0, 1_000, 'energyMarginPercent', fail),\n maxFeeLimit,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/adapters/tron/network.ts"],"names":[],"mappings":";;;AAsJA,8CAwDC;AA9MD;;;;GAIG;AACH,mDAAsD;AACtD,4DAAkF;AA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,\n * validated once when a driver is created: a custom network or option with\n * inconsistent data fails with `CONFIG_INVALID` instead of misbehaving.\n */\nimport { ConfigError } from '../../core/errors/error';\nimport { KNOWN_CAPABILITIES, type Capability } from '../../core/model/capability';\nimport type { ChainInfo, NetworkInfo } from '../../core/model/chain';\nimport { knownName, unknownName } from '../../core/util/names';\n\n/** Every capability of the Tron driver; `address-history` comes with an indexer. */\nexport const TRON_CAPABILITIES: readonly Capability[] = Object.freeze([\n 'tokens',\n 'memo',\n 'block-scan',\n 'hd-public-derivation',\n 'expiry',\n]);\n/** The capabilities a Tron handle gains when it has an `indexer` (TronGrid's history API). */\nexport const TRON_INDEXER_CAPABILITIES: readonly Capability[] = Object.freeze([\n 'address-history',\n]);\n\n/** The expiration window a Tron transaction gets unless `expirationMs` sets another. */\nexport const DEFAULT_EXPIRATION_MS = 60_000;\n/** The shortest expiration window this driver builds. */\nexport const MIN_EXPIRATION_MS = 10_000;\n/**\n * The longest expiration window this driver builds. The negative inclusion proof does\n * not depend on it: it scans from the reference block to the signed expiration.\n */\nexport const MAX_EXPIRATION_MS = 300_000;\n/**\n * TaPoS (java-tron GreatVoyage-v4.8.2.2 `d5c3d1d1`, `Manager.validateTapos` and\n * `updateRecentBlock`): a transaction's reference block must be the one the recent-block\n * store holds under its number's bytes 6..8, and each block overwrites the entry of the block\n * 65,536 below it. So only the 65,536 blocks after the reference block can hold the\n * transaction, and an Attempt's `lastValidHeight` is its reference height plus this window.\n */\nexport const TAPOS_WINDOW = 65_536n;\n/** How much the energy a TRC-20 transfer's fee limit allows exceeds the estimate, in percent. */\nexport const DEFAULT_ENERGY_MARGIN_PERCENT = 20;\n/**\n * The largest fee limit a TRC-20 transfer carries unless the handle's `maxFeeLimit` option\n * allows more: 100 TRX, in sun. The network's own maximum (`getMaxFeeLimit`, 15,000\n * TRX on mainnet), the energy price and the simulated energy all come from one endpoint's\n * answer, and a call that fails through an INVALID opcode (a Solidity `assert`) burns its\n * whole fee limit, so this operator bound is the only one no node can raise. It covers a\n * TRC-20 transfer to a new holder (about 130,000 energy) at 420 sun per energy, margin\n * included.\n */\nexport const DEFAULT_MAX_FEE_LIMIT = 100_000_000n;\n/** The largest `fee_limit` the codec writes exactly: 2^53 − 1 sun. */\nexport const MAX_ENCODABLE_FEE_LIMIT = BigInt(Number.MAX_SAFE_INTEGER);\n/** Memo bytes (UTF-8) accepted in `raw_data.data`. */\nexport const MAX_MEMO_BYTES = 256;\n\nexport interface TronNetworkConfig {\n /** The id of block 0, which the identity probe compares. */\n readonly identity: string;\n readonly expirationMs: number;\n readonly energyMarginPercent: number;\n /** The largest fee limit a transfer may carry, in sun: from 1 to 2^53 − 1. */\n readonly maxFeeLimit: bigint;\n}\n\n/**\n * The only driver options (`HandleOptions.options`) the Tron driver reads. Any other key is\n * refused, so a typo such as `expirationMS` fails loudly instead of leaving the default in\n * place.\n */\nconst OPTION_KEYS: readonly string[] = Object.freeze([\n 'expirationMs',\n 'energyMarginPercent',\n 'maxFeeLimit',\n]);\n/**\n * A capability from the network entry as an error may show it: a core capability's\n * name is a fixed word, so it is shown; any other text could be a pasted secret, so it is not.\n */\nconst named = (key: unknown): string =>\n knownName(key, KNOWN_CAPABILITIES, 'an unknown capability');\n\n/**\n * A network's capability overrides, checked against what the Tron driver serves,\n * as `evmNetworkConfig` checks the EVM ones. The handle advertises the manifest's\n * capabilities plus `add`, minus `remove` (the core's order), so that set must stay within\n * the driver's own: no `replace-fee` or `cancel` (no replacement), no `fee-market-1559` (the\n * `tron` fee model), no `finality-tag` (solidified finality), no `batch-transfer`.\n * `address-history` comes with an indexer, never from the network, and `expiry` is how every\n * Tron transaction is ordered: removing it would disable the proof that an Attempt\n * expired. A removal must name a Tron capability, so a typo fails instead of leaving the\n * capability advertised.\n */\nfunction checkCapabilities(network: NetworkInfo, fail: (reason: string) => never): void {\n const add: unknown = network.capabilities?.add ?? [];\n const remove: unknown = network.capabilities?.remove ?? [];\n if (!Array.isArray(add) || !Array.isArray(remove)) {\n return fail('capabilities.add and capabilities.remove must be lists');\n }\n const own = (list: readonly Capability[], c: unknown) => list.includes(c as Capability);\n const advertised = new Set<unknown>([...TRON_CAPABILITIES, ...add]);\n for (const c of remove) {\n if (!own(TRON_CAPABILITIES, c) && !own(TRON_INDEXER_CAPABILITIES, c)) {\n fail(`capabilities.remove: the Tron driver does not have ${named(c)}`);\n }\n advertised.delete(c);\n }\n for (const c of advertised) {\n if (own(TRON_INDEXER_CAPABILITIES, c)) {\n fail(`capabilities.add: ${named(c)} comes with an indexer, never from the network`);\n }\n if (!own(TRON_CAPABILITIES, c)) {\n fail(`capabilities.add: the Tron driver does not have ${named(c)}`);\n }\n }\n if (!advertised.has('expiry')) {\n fail(`capabilities.remove: every Tron transaction expires, so 'expiry' stays`);\n }\n}\n\nfunction integerIn(\n value: unknown,\n min: number,\n max: number,\n name: string,\n fail: (reason: string) => never,\n): number {\n if (\n !Number.isSafeInteger(value) ||\n (value as number) < min ||\n (value as number) > max\n ) {\n fail(`${name} must be an integer from ${min} to ${max}`);\n }\n return value as number;\n}\n\n/** A fee-limit bound: a bigint of sun from 1 to what the codec writes exactly. */\nfunction feeLimitBound(\n value: unknown,\n name: string,\n fail: (reason: string) => never,\n): bigint {\n if (typeof value !== 'bigint' || value < 1n || value > MAX_ENCODABLE_FEE_LIMIT) {\n fail(`${name} must be a bigint of sun from 1 to 2^53 − 1`);\n }\n return value as bigint;\n}\n\nexport function tronNetworkConfig(\n chain: ChainInfo,\n network: NetworkInfo,\n options: Readonly<Record<string, unknown>> = {},\n): TronNetworkConfig {\n const fail = (reason: string): never => {\n throw new ConfigError(\n 'CONFIG_INVALID',\n `Tron network ${chain.id}:${network.id}: ${reason}`,\n );\n };\n if (chain.family !== 'tron' || chain.ordering !== 'expiry') {\n fail(`the chain must be of family 'tron' with 'expiry' ordering`);\n }\n if (network.identity === undefined || !/^[0-9a-f]{64}$/.test(network.identity)) {\n fail('its identity must be the id of block 0 (64 lower-case hex digits)');\n }\n if (network.feeModel !== 'tron') fail(`its fee model must be 'tron'`);\n if (network.finality.kind !== 'solidified') fail(`its finality must be 'solidified'`);\n checkCapabilities(network, fail);\n // The refusal lists the accepted names and shows neither the caller's key, which\n // may be a pasted secret, nor its value.\n for (const key of Object.keys(options)) {\n if (!OPTION_KEYS.includes(key)) {\n fail(unknownName('option', OPTION_KEYS));\n }\n }\n // The handle's option, else the network entry's own, else 100 TRX. A network\n // value is checked even where an option overrides it, so a bad entry fails loudly.\n const ownBound = network.params?.maxFeeLimit;\n const networkBound =\n ownBound === undefined\n ? undefined\n : feeLimitBound(ownBound, 'params.maxFeeLimit', fail);\n const maxFeeLimit =\n options.maxFeeLimit !== undefined\n ? feeLimitBound(options.maxFeeLimit, 'maxFeeLimit', fail)\n : (networkBound ?? DEFAULT_MAX_FEE_LIMIT);\n return {\n identity: network.identity as string,\n expirationMs:\n options.expirationMs === undefined\n ? DEFAULT_EXPIRATION_MS\n : integerIn(\n options.expirationMs,\n MIN_EXPIRATION_MS,\n MAX_EXPIRATION_MS,\n 'expirationMs',\n fail,\n ),\n energyMarginPercent:\n options.energyMarginPercent === undefined\n ? DEFAULT_ENERGY_MARGIN_PERCENT\n : integerIn(options.energyMarginPercent, 0, 1_000, 'energyMarginPercent', fail),\n maxFeeLimit,\n };\n}\n"]}
|
|
@@ -222,7 +222,11 @@ function createTronProofs(ctx) {
|
|
|
222
222
|
// The unanchored exception: one endpoint's view, trailed by the peer skew, attested.
|
|
223
223
|
const seen = (await api.block('solid', undefined, http_1.MONITOR));
|
|
224
224
|
const head = await solidHeader(seen.number > PEER_SKEW ? seen.number - PEER_SKEW : 0n);
|
|
225
|
-
return {
|
|
225
|
+
return {
|
|
226
|
+
height: head.number,
|
|
227
|
+
hash: head.id,
|
|
228
|
+
timestamp: (0, http_1.unixSeconds)(head.timestamp),
|
|
229
|
+
};
|
|
226
230
|
},
|
|
227
231
|
async includedFinal(ref, ordering) {
|
|
228
232
|
// Bounded before any work; our own Attempt's ref is always a txID.
|
|
@@ -294,7 +298,7 @@ function createTronBlocks(ctx) {
|
|
|
294
298
|
height: header.number,
|
|
295
299
|
hash: header.id,
|
|
296
300
|
parentHash: header.parentId,
|
|
297
|
-
timestamp: header.timestamp,
|
|
301
|
+
timestamp: (0, http_1.unixSeconds)(header.timestamp),
|
|
298
302
|
}
|
|
299
303
|
: null;
|
|
300
304
|
},
|