@across-protocol/sdk 4.3.136 → 4.3.137-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/arch/evm/UpgradeUtils.d.ts +2 -0
- package/dist/cjs/src/arch/evm/UpgradeUtils.js +33 -0
- package/dist/cjs/src/arch/evm/UpgradeUtils.js.map +1 -0
- package/dist/cjs/src/arch/evm/index.d.ts +1 -0
- package/dist/cjs/src/arch/evm/index.js +1 -0
- package/dist/cjs/src/arch/evm/index.js.map +1 -1
- package/dist/cjs/src/arch/index.d.ts +1 -0
- package/dist/cjs/src/arch/index.js +2 -1
- package/dist/cjs/src/arch/index.js.map +1 -1
- package/dist/cjs/src/arch/tvm/BlockUtils.d.ts +1 -0
- package/dist/cjs/src/arch/tvm/BlockUtils.js +7 -0
- package/dist/cjs/src/arch/tvm/BlockUtils.js.map +1 -0
- package/dist/cjs/src/arch/tvm/MessageUtils.d.ts +1 -0
- package/dist/cjs/src/arch/tvm/MessageUtils.js +5 -0
- package/dist/cjs/src/arch/tvm/MessageUtils.js.map +1 -0
- package/dist/cjs/src/arch/tvm/ResourceUtils.d.ts +14 -0
- package/dist/cjs/src/arch/tvm/ResourceUtils.js +69 -0
- package/dist/cjs/src/arch/tvm/ResourceUtils.js.map +1 -0
- package/dist/cjs/src/arch/tvm/SpokeUtils.d.ts +12 -0
- package/dist/cjs/src/arch/tvm/SpokeUtils.js +207 -0
- package/dist/cjs/src/arch/tvm/SpokeUtils.js.map +1 -0
- package/dist/cjs/src/arch/tvm/TransactionUtils.d.ts +7 -0
- package/dist/cjs/src/arch/tvm/TransactionUtils.js +43 -0
- package/dist/cjs/src/arch/tvm/TransactionUtils.js.map +1 -0
- package/dist/cjs/src/arch/tvm/index.d.ts +6 -0
- package/dist/cjs/src/arch/tvm/index.js +10 -0
- package/dist/cjs/src/arch/tvm/index.js.map +1 -0
- package/dist/cjs/src/arch/tvm/types.d.ts +2 -0
- package/dist/cjs/src/arch/tvm/types.js +3 -0
- package/dist/cjs/src/arch/tvm/types.js.map +1 -0
- package/dist/cjs/src/arch/tvm/utils/address.d.ts +3 -0
- package/dist/cjs/src/arch/tvm/utils/address.js +17 -0
- package/dist/cjs/src/arch/tvm/utils/address.js.map +1 -0
- package/dist/cjs/src/arch/tvm/utils/index.d.ts +2 -0
- package/dist/cjs/src/arch/tvm/utils/index.js +6 -0
- package/dist/cjs/src/arch/tvm/utils/index.js.map +1 -0
- package/dist/cjs/src/arch/tvm/utils/wait.d.ts +1 -0
- package/dist/cjs/src/arch/tvm/utils/wait.js +5 -0
- package/dist/cjs/src/arch/tvm/utils/wait.js.map +1 -0
- package/dist/cjs/src/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +9 -2
- package/dist/cjs/src/clients/SpokePoolClient/EVMSpokePoolClient.js +33 -12
- package/dist/cjs/src/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/src/clients/SpokePoolClient/TVMSpokePoolClient.d.ts +11 -0
- package/dist/cjs/src/clients/SpokePoolClient/TVMSpokePoolClient.js +47 -0
- package/dist/cjs/src/clients/SpokePoolClient/TVMSpokePoolClient.js.map +1 -0
- package/dist/cjs/src/clients/SpokePoolClient/index.d.ts +3 -0
- package/dist/cjs/src/clients/SpokePoolClient/index.js +7 -1
- package/dist/cjs/src/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/cjs/src/clients/SpokePoolClient/types.d.ts +1 -0
- package/dist/cjs/src/clients/SpokePoolClient/types.js +2 -1
- package/dist/cjs/src/clients/SpokePoolClient/types.js.map +1 -1
- package/dist/cjs/src/gasPriceOracle/adapters/tron.d.ts +4 -0
- package/dist/cjs/src/gasPriceOracle/adapters/tron.js +58 -0
- package/dist/cjs/src/gasPriceOracle/adapters/tron.js.map +1 -0
- package/dist/cjs/src/gasPriceOracle/index.d.ts +1 -1
- package/dist/cjs/src/gasPriceOracle/oracle.d.ts +3 -1
- package/dist/cjs/src/gasPriceOracle/oracle.js +15 -10
- package/dist/cjs/src/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/src/gasPriceOracle/types.d.ts +6 -1
- package/dist/cjs/src/gasPriceOracle/types.js +5 -0
- package/dist/cjs/src/gasPriceOracle/types.js.map +1 -1
- package/dist/cjs/src/relayFeeCalculator/chain-queries/factory.d.ts +81 -152
- package/dist/cjs/src/relayFeeCalculator/chain-queries/factory.js +5 -0
- package/dist/cjs/src/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/src/relayFeeCalculator/chain-queries/index.d.ts +1 -0
- package/dist/cjs/src/relayFeeCalculator/chain-queries/index.js +1 -0
- package/dist/cjs/src/relayFeeCalculator/chain-queries/index.js.map +1 -1
- package/dist/cjs/src/relayFeeCalculator/chain-queries/tvmQuery.d.ts +16 -0
- package/dist/cjs/src/relayFeeCalculator/chain-queries/tvmQuery.js +52 -0
- package/dist/cjs/src/relayFeeCalculator/chain-queries/tvmQuery.js.map +1 -0
- package/dist/cjs/src/relayFeeCalculator/relayFeeCalculator.d.ts +77 -150
- package/dist/cjs/src/utils/Multicall.js +1 -0
- package/dist/cjs/src/utils/Multicall.js.map +1 -1
- package/dist/cjs/src/utils/NetworkUtils.d.ts +1 -0
- package/dist/cjs/src/utils/NetworkUtils.js +9 -3
- package/dist/cjs/src/utils/NetworkUtils.js.map +1 -1
- package/dist/cjs/src/utils/TokenUtils.d.ts +154 -300
- package/dist/cjs/src/utils/TypeGuards.d.ts +3 -1
- package/dist/cjs/src/utils/TypeGuards.js +5 -0
- package/dist/cjs/src/utils/TypeGuards.js.map +1 -1
- package/dist/esm/src/arch/evm/UpgradeUtils.d.ts +9 -0
- package/dist/esm/src/arch/evm/UpgradeUtils.js +37 -0
- package/dist/esm/src/arch/evm/UpgradeUtils.js.map +1 -0
- package/dist/esm/src/arch/evm/index.d.ts +1 -0
- package/dist/esm/src/arch/evm/index.js +1 -0
- package/dist/esm/src/arch/evm/index.js.map +1 -1
- package/dist/esm/src/arch/index.d.ts +1 -0
- package/dist/esm/src/arch/index.js +2 -0
- package/dist/esm/src/arch/index.js.map +1 -1
- package/dist/esm/src/arch/tvm/BlockUtils.d.ts +1 -0
- package/dist/esm/src/arch/tvm/BlockUtils.js +2 -0
- package/dist/esm/src/arch/tvm/BlockUtils.js.map +1 -0
- package/dist/esm/src/arch/tvm/MessageUtils.d.ts +1 -0
- package/dist/esm/src/arch/tvm/MessageUtils.js +2 -0
- package/dist/esm/src/arch/tvm/MessageUtils.js.map +1 -0
- package/dist/esm/src/arch/tvm/ResourceUtils.d.ts +32 -0
- package/dist/esm/src/arch/tvm/ResourceUtils.js +88 -0
- package/dist/esm/src/arch/tvm/ResourceUtils.js.map +1 -0
- package/dist/esm/src/arch/tvm/SpokeUtils.d.ts +48 -0
- package/dist/esm/src/arch/tvm/SpokeUtils.js +237 -0
- package/dist/esm/src/arch/tvm/SpokeUtils.js.map +1 -0
- package/dist/esm/src/arch/tvm/TransactionUtils.d.ts +20 -0
- package/dist/esm/src/arch/tvm/TransactionUtils.js +55 -0
- package/dist/esm/src/arch/tvm/TransactionUtils.js.map +1 -0
- package/dist/esm/src/arch/tvm/index.d.ts +6 -0
- package/dist/esm/src/arch/tvm/index.js +7 -0
- package/dist/esm/src/arch/tvm/index.js.map +1 -0
- package/dist/esm/src/arch/tvm/types.d.ts +2 -0
- package/dist/esm/src/arch/tvm/types.js +2 -0
- package/dist/esm/src/arch/tvm/types.js.map +1 -0
- package/dist/esm/src/arch/tvm/utils/address.d.ts +18 -0
- package/dist/esm/src/arch/tvm/utils/address.js +31 -0
- package/dist/esm/src/arch/tvm/utils/address.js.map +1 -0
- package/dist/esm/src/arch/tvm/utils/index.d.ts +2 -0
- package/dist/esm/src/arch/tvm/utils/index.js +3 -0
- package/dist/esm/src/arch/tvm/utils/index.js.map +1 -0
- package/dist/esm/src/arch/tvm/utils/wait.d.ts +1 -0
- package/dist/esm/src/arch/tvm/utils/wait.js +2 -0
- package/dist/esm/src/arch/tvm/utils/wait.js.map +1 -0
- package/dist/esm/src/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +20 -2
- package/dist/esm/src/clients/SpokePoolClient/EVMSpokePoolClient.js +44 -12
- package/dist/esm/src/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/src/clients/SpokePoolClient/TVMSpokePoolClient.d.ts +32 -0
- package/dist/esm/src/clients/SpokePoolClient/TVMSpokePoolClient.js +66 -0
- package/dist/esm/src/clients/SpokePoolClient/TVMSpokePoolClient.js.map +1 -0
- package/dist/esm/src/clients/SpokePoolClient/index.d.ts +8 -0
- package/dist/esm/src/clients/SpokePoolClient/index.js +10 -1
- package/dist/esm/src/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/esm/src/clients/SpokePoolClient/types.d.ts +1 -0
- package/dist/esm/src/clients/SpokePoolClient/types.js +1 -0
- package/dist/esm/src/clients/SpokePoolClient/types.js.map +1 -1
- package/dist/esm/src/gasPriceOracle/adapters/tron.d.ts +10 -0
- package/dist/esm/src/gasPriceOracle/adapters/tron.js +68 -0
- package/dist/esm/src/gasPriceOracle/adapters/tron.js.map +1 -0
- package/dist/esm/src/gasPriceOracle/index.d.ts +1 -1
- package/dist/esm/src/gasPriceOracle/oracle.d.ts +3 -1
- package/dist/esm/src/gasPriceOracle/oracle.js +17 -11
- package/dist/esm/src/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/src/gasPriceOracle/types.d.ts +6 -1
- package/dist/esm/src/gasPriceOracle/types.js +4 -0
- package/dist/esm/src/gasPriceOracle/types.js.map +1 -1
- package/dist/esm/src/relayFeeCalculator/chain-queries/factory.d.ts +81 -152
- package/dist/esm/src/relayFeeCalculator/chain-queries/factory.js +6 -1
- package/dist/esm/src/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/src/relayFeeCalculator/chain-queries/index.d.ts +1 -0
- package/dist/esm/src/relayFeeCalculator/chain-queries/index.js +1 -0
- package/dist/esm/src/relayFeeCalculator/chain-queries/index.js.map +1 -1
- package/dist/esm/src/relayFeeCalculator/chain-queries/tvmQuery.d.ts +32 -0
- package/dist/esm/src/relayFeeCalculator/chain-queries/tvmQuery.js +65 -0
- package/dist/esm/src/relayFeeCalculator/chain-queries/tvmQuery.js.map +1 -0
- package/dist/esm/src/relayFeeCalculator/relayFeeCalculator.d.ts +77 -150
- package/dist/esm/src/utils/Multicall.js +1 -0
- package/dist/esm/src/utils/Multicall.js.map +1 -1
- package/dist/esm/src/utils/NetworkUtils.d.ts +6 -0
- package/dist/esm/src/utils/NetworkUtils.js +13 -3
- package/dist/esm/src/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/src/utils/TokenUtils.d.ts +154 -300
- package/dist/esm/src/utils/TypeGuards.d.ts +3 -1
- package/dist/esm/src/utils/TypeGuards.js +4 -0
- package/dist/esm/src/utils/TypeGuards.js.map +1 -1
- package/dist/types/src/arch/evm/UpgradeUtils.d.ts +10 -0
- package/dist/types/src/arch/evm/UpgradeUtils.d.ts.map +1 -0
- package/dist/types/src/arch/evm/index.d.ts +1 -0
- package/dist/types/src/arch/evm/index.d.ts.map +1 -1
- package/dist/types/src/arch/index.d.ts +1 -0
- package/dist/types/src/arch/index.d.ts.map +1 -1
- package/dist/types/src/arch/tvm/BlockUtils.d.ts +2 -0
- package/dist/types/src/arch/tvm/BlockUtils.d.ts.map +1 -0
- package/dist/types/src/arch/tvm/MessageUtils.d.ts +2 -0
- package/dist/types/src/arch/tvm/MessageUtils.d.ts.map +1 -0
- package/dist/types/src/arch/tvm/ResourceUtils.d.ts +33 -0
- package/dist/types/src/arch/tvm/ResourceUtils.d.ts.map +1 -0
- package/dist/types/src/arch/tvm/SpokeUtils.d.ts +49 -0
- package/dist/types/src/arch/tvm/SpokeUtils.d.ts.map +1 -0
- package/dist/types/src/arch/tvm/TransactionUtils.d.ts +21 -0
- package/dist/types/src/arch/tvm/TransactionUtils.d.ts.map +1 -0
- package/dist/types/src/arch/tvm/index.d.ts +7 -0
- package/dist/types/src/arch/tvm/index.d.ts.map +1 -0
- package/dist/types/src/arch/tvm/types.d.ts +3 -0
- package/dist/types/src/arch/tvm/types.d.ts.map +1 -0
- package/dist/types/src/arch/tvm/utils/address.d.ts +19 -0
- package/dist/types/src/arch/tvm/utils/address.d.ts.map +1 -0
- package/dist/types/src/arch/tvm/utils/index.d.ts +3 -0
- package/dist/types/src/arch/tvm/utils/index.d.ts.map +1 -0
- package/dist/types/src/arch/tvm/utils/wait.d.ts +2 -0
- package/dist/types/src/arch/tvm/utils/wait.d.ts.map +1 -0
- package/dist/types/src/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +20 -2
- package/dist/types/src/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/src/clients/SpokePoolClient/TVMSpokePoolClient.d.ts +33 -0
- package/dist/types/src/clients/SpokePoolClient/TVMSpokePoolClient.d.ts.map +1 -0
- package/dist/types/src/clients/SpokePoolClient/index.d.ts +8 -0
- package/dist/types/src/clients/SpokePoolClient/index.d.ts.map +1 -1
- package/dist/types/src/clients/SpokePoolClient/types.d.ts +1 -0
- package/dist/types/src/clients/SpokePoolClient/types.d.ts.map +1 -1
- package/dist/types/src/gasPriceOracle/adapters/tron.d.ts +11 -0
- package/dist/types/src/gasPriceOracle/adapters/tron.d.ts.map +1 -0
- package/dist/types/src/gasPriceOracle/index.d.ts +1 -1
- package/dist/types/src/gasPriceOracle/index.d.ts.map +1 -1
- package/dist/types/src/gasPriceOracle/oracle.d.ts +3 -1
- package/dist/types/src/gasPriceOracle/oracle.d.ts.map +1 -1
- package/dist/types/src/gasPriceOracle/types.d.ts +6 -1
- package/dist/types/src/gasPriceOracle/types.d.ts.map +1 -1
- package/dist/types/src/relayFeeCalculator/chain-queries/factory.d.ts +81 -152
- package/dist/types/src/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
- package/dist/types/src/relayFeeCalculator/chain-queries/index.d.ts +1 -0
- package/dist/types/src/relayFeeCalculator/chain-queries/index.d.ts.map +1 -1
- package/dist/types/src/relayFeeCalculator/chain-queries/tvmQuery.d.ts +33 -0
- package/dist/types/src/relayFeeCalculator/chain-queries/tvmQuery.d.ts.map +1 -0
- package/dist/types/src/relayFeeCalculator/relayFeeCalculator.d.ts +77 -150
- package/dist/types/src/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/src/utils/Multicall.d.ts.map +1 -1
- package/dist/types/src/utils/NetworkUtils.d.ts +6 -0
- package/dist/types/src/utils/NetworkUtils.d.ts.map +1 -1
- package/dist/types/src/utils/TokenUtils.d.ts +154 -300
- package/dist/types/src/utils/TokenUtils.d.ts.map +1 -1
- package/dist/types/src/utils/TypeGuards.d.ts +3 -1
- package/dist/types/src/utils/TypeGuards.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/arch/evm/UpgradeUtils.ts +18 -0
- package/src/arch/evm/index.ts +1 -0
- package/src/arch/index.ts +1 -0
- package/src/arch/tvm/BlockUtils.ts +1 -0
- package/src/arch/tvm/MessageUtils.ts +1 -0
- package/src/arch/tvm/ResourceUtils.ts +92 -0
- package/src/arch/tvm/SpokeUtils.ts +225 -0
- package/src/arch/tvm/TransactionUtils.ts +62 -0
- package/src/arch/tvm/index.ts +6 -0
- package/src/arch/tvm/types.ts +2 -0
- package/src/arch/tvm/utils/address.ts +33 -0
- package/src/arch/tvm/utils/index.ts +2 -0
- package/src/arch/tvm/utils/wait.ts +1 -0
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +44 -18
- package/src/clients/SpokePoolClient/TVMSpokePoolClient.ts +65 -0
- package/src/clients/SpokePoolClient/index.ts +12 -1
- package/src/clients/SpokePoolClient/types.ts +1 -0
- package/src/gasPriceOracle/adapters/tron.ts +50 -0
- package/src/gasPriceOracle/index.ts +1 -1
- package/src/gasPriceOracle/oracle.ts +23 -3
- package/src/gasPriceOracle/types.ts +11 -1
- package/src/relayFeeCalculator/chain-queries/factory.ts +18 -3
- package/src/relayFeeCalculator/chain-queries/index.ts +1 -0
- package/src/relayFeeCalculator/chain-queries/tvmQuery.ts +88 -0
- package/src/utils/Multicall.ts +1 -0
- package/src/utils/NetworkUtils.ts +13 -3
- package/src/utils/TypeGuards.ts +6 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SVMProvider } from "../arch/svm/types";
|
|
2
2
|
import { EvmProvider } from "../arch/evm/types";
|
|
3
|
+
import { TronWeb } from "tronweb";
|
|
3
4
|
export declare function isPromiseFulfilled<T>(promiseSettledResult: PromiseSettledResult<T>): promiseSettledResult is PromiseFulfilledResult<T>;
|
|
4
5
|
export declare function isPromiseRejected<T>(promiseSettledResult: PromiseSettledResult<T>): promiseSettledResult is PromiseRejectedResult;
|
|
5
6
|
export declare function isDefined<T>(input: T | null | undefined): input is T;
|
|
6
|
-
export declare function
|
|
7
|
+
export declare function isTvmProvider(provider: EvmProvider | SVMProvider | TronWeb): provider is TronWeb;
|
|
8
|
+
export declare function isEvmProvider(provider: EvmProvider | SVMProvider | TronWeb): provider is EvmProvider;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isPromiseFulfilled = isPromiseFulfilled;
|
|
4
4
|
exports.isPromiseRejected = isPromiseRejected;
|
|
5
5
|
exports.isDefined = isDefined;
|
|
6
|
+
exports.isTvmProvider = isTvmProvider;
|
|
6
7
|
exports.isEvmProvider = isEvmProvider;
|
|
7
8
|
var ethers_1 = require("ethers");
|
|
8
9
|
function isPromiseFulfilled(promiseSettledResult) {
|
|
@@ -14,6 +15,10 @@ function isPromiseRejected(promiseSettledResult) {
|
|
|
14
15
|
function isDefined(input) {
|
|
15
16
|
return input !== null && input !== undefined;
|
|
16
17
|
}
|
|
18
|
+
function isTvmProvider(provider) {
|
|
19
|
+
var _a;
|
|
20
|
+
return typeof ((_a = provider === null || provider === void 0 ? void 0 : provider.trx) === null || _a === void 0 ? void 0 : _a.getEnergyPrices) === "function";
|
|
21
|
+
}
|
|
17
22
|
function isEvmProvider(provider) {
|
|
18
23
|
return provider instanceof ethers_1.providers.Provider;
|
|
19
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeGuards.js","sourceRoot":"","sources":["../../../../src/utils/TypeGuards.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"TypeGuards.js","sourceRoot":"","sources":["../../../../src/utils/TypeGuards.ts"],"names":[],"mappings":";;AAKA,gDAIC;AAED,8CAIC;AAED,8BAEC;AAED,sCAEC;AAED,sCAEC;AAzBD,iCAAmC;AAGnC,SAAgB,kBAAkB,CAChC,oBAA6C;IAE7C,OAAO,oBAAoB,CAAC,MAAM,KAAK,WAAW,CAAC;AACrD,CAAC;AAED,SAAgB,iBAAiB,CAC/B,oBAA6C;IAE7C,OAAO,oBAAoB,CAAC,MAAM,KAAK,UAAU,CAAC;AACpD,CAAC;AAED,SAAgB,SAAS,CAAI,KAA2B;IACtD,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC/C,CAAC;AAED,SAAgB,aAAa,CAAC,QAA6C;;IACzE,OAAO,OAAO,CAAA,MAAC,QAAoB,aAApB,QAAQ,uBAAR,QAAQ,CAAc,GAAG,0CAAE,eAAe,CAAA,KAAK,UAAU,CAAC;AAC3E,CAAC;AAED,SAAgB,aAAa,CAAC,QAA6C;IACzE,OAAO,QAAQ,YAAY,kBAAS,CAAC,QAAQ,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Contract } from "ethers";
|
|
2
|
+
/**
|
|
3
|
+
* Query for EIP-1967 contract upgrade events.
|
|
4
|
+
* @param contract A contract instance (must be a UUPS or transparent proxy that emits the Upgraded event).
|
|
5
|
+
* @param startBlock Optional start of the block range (inclusive). Defaults to 0.
|
|
6
|
+
* @param endBlock Optional end of the block range (inclusive). Defaults to latest.
|
|
7
|
+
* @returns An array of block numbers at which upgrades occurred, sorted ascending.
|
|
8
|
+
*/
|
|
9
|
+
export declare function get1967Upgrades(contract: Contract, startBlock?: number, endBlock?: number): Promise<number[]>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { paginatedEventQuery } from "../../utils";
|
|
3
|
+
/**
|
|
4
|
+
* Query for EIP-1967 contract upgrade events.
|
|
5
|
+
* @param contract A contract instance (must be a UUPS or transparent proxy that emits the Upgraded event).
|
|
6
|
+
* @param startBlock Optional start of the block range (inclusive). Defaults to 0.
|
|
7
|
+
* @param endBlock Optional end of the block range (inclusive). Defaults to latest.
|
|
8
|
+
* @returns An array of block numbers at which upgrades occurred, sorted ascending.
|
|
9
|
+
*/
|
|
10
|
+
export function get1967Upgrades(contract, startBlock, endBlock) {
|
|
11
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12
|
+
var from, to, _a, events;
|
|
13
|
+
return __generator(this, function (_b) {
|
|
14
|
+
switch (_b.label) {
|
|
15
|
+
case 0:
|
|
16
|
+
from = startBlock !== null && startBlock !== void 0 ? startBlock : 0;
|
|
17
|
+
if (!(endBlock !== null && endBlock !== void 0)) return [3 /*break*/, 1];
|
|
18
|
+
_a = endBlock;
|
|
19
|
+
return [3 /*break*/, 3];
|
|
20
|
+
case 1: return [4 /*yield*/, contract.provider.getBlockNumber()];
|
|
21
|
+
case 2:
|
|
22
|
+
_a = (_b.sent());
|
|
23
|
+
_b.label = 3;
|
|
24
|
+
case 3:
|
|
25
|
+
to = _a;
|
|
26
|
+
return [4 /*yield*/, paginatedEventQuery(contract, contract.filters.Upgraded(), { from: from, to: to })];
|
|
27
|
+
case 4:
|
|
28
|
+
events = _b.sent();
|
|
29
|
+
return [2 /*return*/, events.map(function (_a) {
|
|
30
|
+
var blockNumber = _a.blockNumber;
|
|
31
|
+
return blockNumber;
|
|
32
|
+
})];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=UpgradeUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpgradeUtils.js","sourceRoot":"","sources":["../../../../../src/arch/evm/UpgradeUtils.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,UAAgB,eAAe,CAAC,QAAkB,EAAE,UAAmB,EAAE,QAAiB;;;;;;oBACxF,IAAI,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,CAAC,CAAC;0BAClB,QAAQ,aAAR,QAAQ;oBAAR,KAAA,QAAQ,CAAA;;wBAAK,qBAAM,QAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAA;;oBAAzC,KAAA,CAAC,SAAwC,CAAC,CAAA;;;oBAA3D,EAAE,KAAyD;oBAElD,qBAAM,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,MAAA,EAAE,EAAE,IAAA,EAAE,CAAC,EAAA;;oBAAvF,MAAM,GAAG,SAA8E;oBAE7F,sBAAO,MAAM,CAAC,GAAG,CAAC,UAAC,EAAe;gCAAb,WAAW,iBAAA;4BAAO,OAAA,WAAW;wBAAX,CAAW,CAAC,EAAC;;;;CACrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/arch/evm/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/arch/evm/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/arch/index.ts"],"names":[],"mappings":"uBAAqB,OAAO;kBAAhB,GAAG;uBACM,OAAO;kBAAhB,GAAG"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/arch/index.ts"],"names":[],"mappings":"uBAAqB,OAAO;kBAAhB,GAAG;uBACM,OAAO;kBAAhB,GAAG;uBACM,OAAO;kBAAhB,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { averageBlockTime, EVMBlockFinder as TVMBlockFinder } from "../evm/BlockUtils";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockUtils.js","sourceRoot":"","sources":["../../../../../src/arch/tvm/BlockUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../evm/MessageUtils";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageUtils.js","sourceRoot":"","sources":["../../../../../src/arch/tvm/MessageUtils.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TronWeb } from "tronweb";
|
|
2
|
+
import type { ContractFunctionParameter } from "tronweb/lib/esm/types/TransactionBuilder";
|
|
3
|
+
export interface TronResourceEstimate {
|
|
4
|
+
energyRequired: number;
|
|
5
|
+
/** Recommended feeLimit in SUN (1 TRX = 1,000,000 SUN). */
|
|
6
|
+
feeLimit: number;
|
|
7
|
+
}
|
|
8
|
+
export interface TronAccountResources {
|
|
9
|
+
freeNetLimit: number;
|
|
10
|
+
freeNetUsed: number;
|
|
11
|
+
energyLimit: number;
|
|
12
|
+
energyUsed: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Estimate the energy cost and recommended feeLimit for a smart contract call.
|
|
16
|
+
*
|
|
17
|
+
* @param tronWeb An authenticated TronWeb instance.
|
|
18
|
+
* @param contractAddress The target contract address (EVM hex or TRON Base58 format).
|
|
19
|
+
* @param functionSelector The Solidity function selector (e.g., "transfer(address,uint256)").
|
|
20
|
+
* @param parameters The function parameters in TronWeb's ContractFunctionParameter format.
|
|
21
|
+
* @param ownerAddress The address that will execute the transaction (EVM hex or TRON Base58).
|
|
22
|
+
* @returns The estimated energy required and recommended feeLimit in SUN.
|
|
23
|
+
*/
|
|
24
|
+
export declare function estimateTransactionFee(tronWeb: TronWeb, contractAddress: string, functionSelector: string, parameters: ContractFunctionParameter[], ownerAddress: string): Promise<TronResourceEstimate>;
|
|
25
|
+
/**
|
|
26
|
+
* Query the current resource allocation and usage for an account.
|
|
27
|
+
*
|
|
28
|
+
* @param tronWeb A TronWeb instance.
|
|
29
|
+
* @param address The account address (EVM hex or TRON Base58 format).
|
|
30
|
+
* @returns The account's bandwidth and energy limits and usage.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getAccountResources(tronWeb: TronWeb, address: string): Promise<TronAccountResources>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { evmToTronAddress } from "./utils/address";
|
|
3
|
+
// Safety multiplier applied to the estimated fee limit (1.2x).
|
|
4
|
+
var FEE_LIMIT_MULTIPLIER = 1.2;
|
|
5
|
+
/**
|
|
6
|
+
* Query the current energy price in SUN per unit of energy.
|
|
7
|
+
* @param tronWeb A TronWeb instance.
|
|
8
|
+
* @returns The current energy price in SUN.
|
|
9
|
+
*/
|
|
10
|
+
function getEnergyPrice(tronWeb) {
|
|
11
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12
|
+
var pricesStr, entries, lastEntry, price;
|
|
13
|
+
return __generator(this, function (_a) {
|
|
14
|
+
switch (_a.label) {
|
|
15
|
+
case 0: return [4 /*yield*/, tronWeb.trx.getEnergyPrices()];
|
|
16
|
+
case 1:
|
|
17
|
+
pricesStr = _a.sent();
|
|
18
|
+
entries = pricesStr.split(",");
|
|
19
|
+
lastEntry = entries[entries.length - 1];
|
|
20
|
+
price = Number(lastEntry.split(":")[1]);
|
|
21
|
+
if (!Number.isFinite(price) || price <= 0) {
|
|
22
|
+
throw new Error("getEnergyPrice: unexpected energy price: ".concat(lastEntry));
|
|
23
|
+
}
|
|
24
|
+
return [2 /*return*/, price];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Estimate the energy cost and recommended feeLimit for a smart contract call.
|
|
31
|
+
*
|
|
32
|
+
* @param tronWeb An authenticated TronWeb instance.
|
|
33
|
+
* @param contractAddress The target contract address (EVM hex or TRON Base58 format).
|
|
34
|
+
* @param functionSelector The Solidity function selector (e.g., "transfer(address,uint256)").
|
|
35
|
+
* @param parameters The function parameters in TronWeb's ContractFunctionParameter format.
|
|
36
|
+
* @param ownerAddress The address that will execute the transaction (EVM hex or TRON Base58).
|
|
37
|
+
* @returns The estimated energy required and recommended feeLimit in SUN.
|
|
38
|
+
*/
|
|
39
|
+
export function estimateTransactionFee(tronWeb, contractAddress, functionSelector, parameters, ownerAddress) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
41
|
+
var tronContractAddress, tronOwnerAddress, _a, estimate, energyPrice, energyRequired, feeLimit;
|
|
42
|
+
return __generator(this, function (_b) {
|
|
43
|
+
switch (_b.label) {
|
|
44
|
+
case 0:
|
|
45
|
+
tronContractAddress = contractAddress.startsWith("0x") ? evmToTronAddress(contractAddress) : contractAddress;
|
|
46
|
+
tronOwnerAddress = ownerAddress.startsWith("0x") ? evmToTronAddress(ownerAddress) : ownerAddress;
|
|
47
|
+
return [4 /*yield*/, Promise.all([
|
|
48
|
+
tronWeb.transactionBuilder.estimateEnergy(tronContractAddress, functionSelector, {}, parameters, tronOwnerAddress),
|
|
49
|
+
getEnergyPrice(tronWeb),
|
|
50
|
+
])];
|
|
51
|
+
case 1:
|
|
52
|
+
_a = _b.sent(), estimate = _a[0], energyPrice = _a[1];
|
|
53
|
+
energyRequired = estimate.energy_required;
|
|
54
|
+
feeLimit = Math.ceil(energyRequired * energyPrice * FEE_LIMIT_MULTIPLIER);
|
|
55
|
+
return [2 /*return*/, { energyRequired: energyRequired, feeLimit: feeLimit }];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Query the current resource allocation and usage for an account.
|
|
62
|
+
*
|
|
63
|
+
* @param tronWeb A TronWeb instance.
|
|
64
|
+
* @param address The account address (EVM hex or TRON Base58 format).
|
|
65
|
+
* @returns The account's bandwidth and energy limits and usage.
|
|
66
|
+
*/
|
|
67
|
+
export function getAccountResources(tronWeb, address) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
+
var tronAddress, resources;
|
|
70
|
+
var _a, _b, _c, _d;
|
|
71
|
+
return __generator(this, function (_e) {
|
|
72
|
+
switch (_e.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
tronAddress = address.startsWith("0x") ? evmToTronAddress(address) : address;
|
|
75
|
+
return [4 /*yield*/, tronWeb.trx.getAccountResources(tronAddress)];
|
|
76
|
+
case 1:
|
|
77
|
+
resources = _e.sent();
|
|
78
|
+
return [2 /*return*/, {
|
|
79
|
+
freeNetLimit: (_a = resources.freeNetLimit) !== null && _a !== void 0 ? _a : 0,
|
|
80
|
+
freeNetUsed: (_b = resources.freeNetUsed) !== null && _b !== void 0 ? _b : 0,
|
|
81
|
+
energyLimit: (_c = resources.NetLimit) !== null && _c !== void 0 ? _c : 0,
|
|
82
|
+
energyUsed: (_d = resources.NetUsed) !== null && _d !== void 0 ? _d : 0,
|
|
83
|
+
}];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=ResourceUtils.js.map
|
|
@@ -0,0 +1 @@
|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AAkB,CAAC,cAAc,CAAC,mBAAmB,EAAE,gBAAgB,EAAE,EAAE,EAAE,UAAU,EAAE,gBAAgB,CAAC;4BAClH,cAAc,CAAC,OAAO,CAAC;yBACxB,CAAC,EAAA;;oBAHI,KAA0B,SAG9B,EAHK,QAAQ,QAAA,EAAE,WAAW,QAAA;oBAKtB,cAAc,GAAG,QAAQ,CAAC,eAAe,CAAC;oBAG1C,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,GAAG,WAAW,GAAG,oBAAoB,CAAC,CAAC;oBAEhF,sBAAO,EAAE,cAAc,gBAAA,EAAE,QAAQ,UAAA,EAAE,EAAC;;;;CACrC;AAED;;;;;;GAMG;AACH,MAAM,UAAgB,mBAAmB,CAAC,OAAgB,EAAE,OAAe;;;;;;;oBACnE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;oBACjE,qBAAM,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,WAAW,CAAC,EAAA;;oBAA9D,SAAS,GAAG,SAAkD;oBAEpE,sBAAO;4BACL,YAAY,EAAE,MAAA,SAAS,CAAC,YAAY,mCAAI,CAAC;4BACzC,WAAW,EAAE,MAAA,SAAS,CAAC,WAAW,mCAAI,CAAC;4BACvC,WAAW,EAAE,MAAA,SAAS,CAAC,QAAQ,mCAAI,CAAC;4BACpC,UAAU,EAAE,MAAA,SAAS,CAAC,OAAO,mCAAI,CAAC;yBACnC,EAAC;;;;CACH"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Contract, providers } from "ethers";
|
|
2
|
+
import { FillStatus, FillWithBlock, RelayData } from "../../interfaces";
|
|
3
|
+
import { BigNumber } from "../../utils";
|
|
4
|
+
type BlockTag = providers.BlockTag;
|
|
5
|
+
export { populateV3Relay, getTimestampForBlock, fillStatusArray } from "../evm/SpokeUtils";
|
|
6
|
+
/**
|
|
7
|
+
* @notice Retrieve the on-chain time at a specific block number.
|
|
8
|
+
* TRON does not support historical eth_call so block timestamps are used
|
|
9
|
+
* instead of SpokePool.getCurrentTime(). In production these are equivalent.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getTimeAt(spokePool: Contract, blockNumber: number): Promise<number>;
|
|
12
|
+
/**
|
|
13
|
+
* @notice Return the maximum fill deadline buffer across a block range.
|
|
14
|
+
* TRON does not support historical eth_call, so we read the current value.
|
|
15
|
+
* If a contract upgrade (EIP-1967 Upgraded event) occurred within the range,
|
|
16
|
+
* the value may have changed at the upgrade boundary. In that case, return
|
|
17
|
+
* the greater of the current value and a conservative 6-hour fallback.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getMaxFillDeadlineInRange(spokePool: Contract, startBlock: number, endBlock: number): Promise<number>;
|
|
20
|
+
/**
|
|
21
|
+
* @notice Not supported on TVM — callers should use findDepositBlock instead.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getDepositIdAtBlock(_contract: Contract, _blockTag: number): Promise<BigNumber>;
|
|
24
|
+
/**
|
|
25
|
+
* @notice Find the block at which a deposit was created.
|
|
26
|
+
* TRON does not support historical eth_call, so event queries replace the
|
|
27
|
+
* EVM binary-search over numberOfDeposits().
|
|
28
|
+
*/
|
|
29
|
+
export declare function findDepositBlock(spokePool: Contract, depositId: BigNumber, lowBlock: number, highBlock?: number): Promise<number | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* @notice Determine the fill status of a relay at a given block.
|
|
32
|
+
* For "latest" queries, delegates to the EVM implementation (TRON's
|
|
33
|
+
* eth_call works normally for "latest"). For historical queries the
|
|
34
|
+
* status is reconstructed from on-chain events because TRON does not
|
|
35
|
+
* support eth_call with historical blockTags.
|
|
36
|
+
*/
|
|
37
|
+
export declare function relayFillStatus(spokePool: Contract, relayData: RelayData, blockTag?: BlockTag, destinationChainId?: number): Promise<FillStatus>;
|
|
38
|
+
/**
|
|
39
|
+
* @notice Find the block at which a fill was completed.
|
|
40
|
+
* TRON does not support historical eth_call, so event queries replace the
|
|
41
|
+
* EVM binary-search over fillStatuses().
|
|
42
|
+
*/
|
|
43
|
+
export declare function findFillBlock(spokePool: Contract, relayData: RelayData, lowBlockNumber: number, highBlockNumber?: number): Promise<number | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* @notice Find the fill event for a deposit.
|
|
46
|
+
* Queries fill events directly rather than binary-searching then re-querying.
|
|
47
|
+
*/
|
|
48
|
+
export declare function findFillEvent(spokePool: Contract, relayData: RelayData, lowBlockNumber: number, highBlockNumber?: number): Promise<FillWithBlock | undefined>;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import assert from "assert";
|
|
3
|
+
import { CHAIN_IDs } from "../../constants";
|
|
4
|
+
import { FillStatus } from "../../interfaces";
|
|
5
|
+
import { get1967Upgrades } from "../evm/UpgradeUtils";
|
|
6
|
+
import { relayFillStatus as evmRelayFillStatus } from "../evm/SpokeUtils";
|
|
7
|
+
import { getRelayDataHash, isDefined, isUnsafeDepositId, paginatedEventQuery, spreadEventWithBlockNumber, unpackFillEvent, } from "../../utils";
|
|
8
|
+
// Re-export functions that work unchanged on TRON's JSON-RPC.
|
|
9
|
+
export { populateV3Relay, getTimestampForBlock, fillStatusArray } from "../evm/SpokeUtils";
|
|
10
|
+
// Local implementations for functions requiring historical eth_call,
|
|
11
|
+
// which TRON does not support (only "latest" blockTag is accepted).
|
|
12
|
+
/**
|
|
13
|
+
* @notice Retrieve the on-chain time at a specific block number.
|
|
14
|
+
* TRON does not support historical eth_call so block timestamps are used
|
|
15
|
+
* instead of SpokePool.getCurrentTime(). In production these are equivalent.
|
|
16
|
+
*/
|
|
17
|
+
export function getTimeAt(spokePool, blockNumber) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
19
|
+
var block;
|
|
20
|
+
return __generator(this, function (_a) {
|
|
21
|
+
switch (_a.label) {
|
|
22
|
+
case 0: return [4 /*yield*/, spokePool.provider.getBlock(blockNumber)];
|
|
23
|
+
case 1:
|
|
24
|
+
block = _a.sent();
|
|
25
|
+
return [2 /*return*/, block.timestamp];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// Fallback fill deadline buffer (6 hours) used when a contract upgrade is
|
|
31
|
+
// detected in the query range. An upgrade implies fillDeadlineBuffer may
|
|
32
|
+
// have changed and we cannot read historical state on TRON, so we use a
|
|
33
|
+
// conservative upper bound.
|
|
34
|
+
var FALLBACK_FILL_DEADLINE_BUFFER = 21600; // 6 hours in seconds
|
|
35
|
+
/**
|
|
36
|
+
* @notice Return the maximum fill deadline buffer across a block range.
|
|
37
|
+
* TRON does not support historical eth_call, so we read the current value.
|
|
38
|
+
* If a contract upgrade (EIP-1967 Upgraded event) occurred within the range,
|
|
39
|
+
* the value may have changed at the upgrade boundary. In that case, return
|
|
40
|
+
* the greater of the current value and a conservative 6-hour fallback.
|
|
41
|
+
*/
|
|
42
|
+
export function getMaxFillDeadlineInRange(spokePool, startBlock, endBlock) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
var _a, fillDeadlineBuffer, upgrades, currentBuffer;
|
|
45
|
+
return __generator(this, function (_b) {
|
|
46
|
+
switch (_b.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, Promise.all([
|
|
48
|
+
spokePool.fillDeadlineBuffer(),
|
|
49
|
+
get1967Upgrades(spokePool, startBlock, endBlock),
|
|
50
|
+
])];
|
|
51
|
+
case 1:
|
|
52
|
+
_a = _b.sent(), fillDeadlineBuffer = _a[0], upgrades = _a[1];
|
|
53
|
+
currentBuffer = Number(fillDeadlineBuffer);
|
|
54
|
+
if (upgrades.length > 0) {
|
|
55
|
+
return [2 /*return*/, Math.max(currentBuffer, FALLBACK_FILL_DEADLINE_BUFFER)];
|
|
56
|
+
}
|
|
57
|
+
return [2 /*return*/, currentBuffer];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @notice Not supported on TVM — callers should use findDepositBlock instead.
|
|
64
|
+
*/
|
|
65
|
+
export function getDepositIdAtBlock(_contract, _blockTag) {
|
|
66
|
+
throw new Error("getDepositIdAtBlock: not supported on TVM");
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @notice Find the block at which a deposit was created.
|
|
70
|
+
* TRON does not support historical eth_call, so event queries replace the
|
|
71
|
+
* EVM binary-search over numberOfDeposits().
|
|
72
|
+
*/
|
|
73
|
+
export function findDepositBlock(spokePool, depositId, lowBlock, highBlock) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
+
var _a, events;
|
|
76
|
+
return __generator(this, function (_b) {
|
|
77
|
+
switch (_b.label) {
|
|
78
|
+
case 0:
|
|
79
|
+
if (isUnsafeDepositId(depositId)) {
|
|
80
|
+
throw new Error("Cannot search for depositId ".concat(depositId));
|
|
81
|
+
}
|
|
82
|
+
if (!(highBlock !== null && highBlock !== void 0)) return [3 /*break*/, 1];
|
|
83
|
+
_a = highBlock;
|
|
84
|
+
return [3 /*break*/, 3];
|
|
85
|
+
case 1: return [4 /*yield*/, spokePool.provider.getBlockNumber()];
|
|
86
|
+
case 2:
|
|
87
|
+
_a = (highBlock = _b.sent());
|
|
88
|
+
_b.label = 3;
|
|
89
|
+
case 3:
|
|
90
|
+
_a;
|
|
91
|
+
assert(highBlock > lowBlock, "Block numbers out of range (".concat(lowBlock, " >= ").concat(highBlock, ")"));
|
|
92
|
+
return [4 /*yield*/, paginatedEventQuery(spokePool, spokePool.filters.FundsDeposited(null, null, null, null, null, depositId), { from: lowBlock, to: highBlock })];
|
|
93
|
+
case 4:
|
|
94
|
+
events = _b.sent();
|
|
95
|
+
if (events.length === 0) {
|
|
96
|
+
return [2 /*return*/, undefined];
|
|
97
|
+
}
|
|
98
|
+
return [2 /*return*/, events[0].blockNumber];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* @notice Determine the fill status of a relay at a given block.
|
|
105
|
+
* For "latest" queries, delegates to the EVM implementation (TRON's
|
|
106
|
+
* eth_call works normally for "latest"). For historical queries the
|
|
107
|
+
* status is reconstructed from on-chain events because TRON does not
|
|
108
|
+
* support eth_call with historical blockTags.
|
|
109
|
+
*/
|
|
110
|
+
export function relayFillStatus(spokePool_1, relayData_1) {
|
|
111
|
+
return __awaiter(this, arguments, void 0, function (spokePool, relayData, blockTag, destinationChainId) {
|
|
112
|
+
var _a, hash, latestStatus, _b, fromBlock, toBlock, fillEvents, slowFillEvents;
|
|
113
|
+
if (blockTag === void 0) { blockTag = "latest"; }
|
|
114
|
+
return __generator(this, function (_c) {
|
|
115
|
+
switch (_c.label) {
|
|
116
|
+
case 0:
|
|
117
|
+
if (blockTag === "latest") {
|
|
118
|
+
return [2 /*return*/, evmRelayFillStatus(spokePool, relayData, blockTag, destinationChainId)];
|
|
119
|
+
}
|
|
120
|
+
if (!(destinationChainId !== null && destinationChainId !== void 0)) return [3 /*break*/, 1];
|
|
121
|
+
_a = destinationChainId;
|
|
122
|
+
return [3 /*break*/, 3];
|
|
123
|
+
case 1: return [4 /*yield*/, spokePool.chainId()];
|
|
124
|
+
case 2:
|
|
125
|
+
_a = (destinationChainId = _c.sent());
|
|
126
|
+
_c.label = 3;
|
|
127
|
+
case 3:
|
|
128
|
+
_a;
|
|
129
|
+
assert(isDefined(destinationChainId));
|
|
130
|
+
hash = getRelayDataHash(relayData, destinationChainId);
|
|
131
|
+
_b = Number;
|
|
132
|
+
return [4 /*yield*/, spokePool.fillStatuses(hash)];
|
|
133
|
+
case 4:
|
|
134
|
+
latestStatus = _b.apply(void 0, [_c.sent()]);
|
|
135
|
+
if (latestStatus === FillStatus.Unfilled) {
|
|
136
|
+
return [2 /*return*/, FillStatus.Unfilled];
|
|
137
|
+
}
|
|
138
|
+
fromBlock = 0;
|
|
139
|
+
toBlock = Number(blockTag);
|
|
140
|
+
return [4 /*yield*/, paginatedEventQuery(spokePool, spokePool.filters.FilledRelay(null, null, null, null, null, relayData.originChainId, relayData.depositId), { from: fromBlock, to: toBlock })];
|
|
141
|
+
case 5:
|
|
142
|
+
fillEvents = _c.sent();
|
|
143
|
+
if (fillEvents.length > 0) {
|
|
144
|
+
return [2 /*return*/, FillStatus.Filled];
|
|
145
|
+
}
|
|
146
|
+
if (!(latestStatus >= FillStatus.RequestedSlowFill)) return [3 /*break*/, 7];
|
|
147
|
+
return [4 /*yield*/, paginatedEventQuery(spokePool, spokePool.filters.RequestedSlowFill(null, null, null, null, relayData.originChainId, relayData.depositId), { from: fromBlock, to: toBlock })];
|
|
148
|
+
case 6:
|
|
149
|
+
slowFillEvents = _c.sent();
|
|
150
|
+
if (slowFillEvents.length > 0) {
|
|
151
|
+
return [2 /*return*/, FillStatus.RequestedSlowFill];
|
|
152
|
+
}
|
|
153
|
+
_c.label = 7;
|
|
154
|
+
case 7: return [2 /*return*/, FillStatus.Unfilled];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* @notice Find the block at which a fill was completed.
|
|
161
|
+
* TRON does not support historical eth_call, so event queries replace the
|
|
162
|
+
* EVM binary-search over fillStatuses().
|
|
163
|
+
*/
|
|
164
|
+
export function findFillBlock(spokePool, relayData, lowBlockNumber, highBlockNumber) {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
166
|
+
var provider, _a, events;
|
|
167
|
+
return __generator(this, function (_b) {
|
|
168
|
+
switch (_b.label) {
|
|
169
|
+
case 0:
|
|
170
|
+
provider = spokePool.provider;
|
|
171
|
+
if (!(highBlockNumber !== null && highBlockNumber !== void 0)) return [3 /*break*/, 1];
|
|
172
|
+
_a = highBlockNumber;
|
|
173
|
+
return [3 /*break*/, 3];
|
|
174
|
+
case 1: return [4 /*yield*/, provider.getBlockNumber()];
|
|
175
|
+
case 2:
|
|
176
|
+
_a = (highBlockNumber = _b.sent());
|
|
177
|
+
_b.label = 3;
|
|
178
|
+
case 3:
|
|
179
|
+
_a;
|
|
180
|
+
assert(highBlockNumber > lowBlockNumber, "Block numbers out of range (".concat(lowBlockNumber, " >= ").concat(highBlockNumber, ")"));
|
|
181
|
+
return [4 /*yield*/, paginatedEventQuery(spokePool, spokePool.filters.FilledRelay(null, null, null, null, null, relayData.originChainId, relayData.depositId), { from: lowBlockNumber, to: highBlockNumber })];
|
|
182
|
+
case 4:
|
|
183
|
+
events = _b.sent();
|
|
184
|
+
if (events.length === 0) {
|
|
185
|
+
return [2 /*return*/, undefined];
|
|
186
|
+
}
|
|
187
|
+
return [2 /*return*/, events[0].blockNumber];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* @notice Find the fill event for a deposit.
|
|
194
|
+
* Queries fill events directly rather than binary-searching then re-querying.
|
|
195
|
+
*/
|
|
196
|
+
export function findFillEvent(spokePool, relayData, lowBlockNumber, highBlockNumber) {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
+
var provider, _a, events, event, destinationChainId, _b, _c;
|
|
199
|
+
return __generator(this, function (_d) {
|
|
200
|
+
switch (_d.label) {
|
|
201
|
+
case 0:
|
|
202
|
+
provider = spokePool.provider;
|
|
203
|
+
if (!(highBlockNumber !== null && highBlockNumber !== void 0)) return [3 /*break*/, 1];
|
|
204
|
+
_a = highBlockNumber;
|
|
205
|
+
return [3 /*break*/, 3];
|
|
206
|
+
case 1: return [4 /*yield*/, provider.getBlockNumber()];
|
|
207
|
+
case 2:
|
|
208
|
+
_a = (highBlockNumber = _d.sent());
|
|
209
|
+
_d.label = 3;
|
|
210
|
+
case 3:
|
|
211
|
+
_a;
|
|
212
|
+
return [4 /*yield*/, paginatedEventQuery(spokePool, spokePool.filters.FilledRelay(null, null, null, null, null, relayData.originChainId, relayData.depositId), { from: lowBlockNumber, to: highBlockNumber })];
|
|
213
|
+
case 4:
|
|
214
|
+
events = _d.sent();
|
|
215
|
+
if (events.length === 0) {
|
|
216
|
+
return [2 /*return*/, undefined];
|
|
217
|
+
}
|
|
218
|
+
event = events[0];
|
|
219
|
+
if (!Object.values(CHAIN_IDs).includes(relayData.originChainId)) return [3 /*break*/, 6];
|
|
220
|
+
return [4 /*yield*/, spokePool.provider.getNetwork()];
|
|
221
|
+
case 5:
|
|
222
|
+
_b = (_d.sent()).chainId;
|
|
223
|
+
return [3 /*break*/, 8];
|
|
224
|
+
case 6:
|
|
225
|
+
_c = Number;
|
|
226
|
+
return [4 /*yield*/, spokePool.chainId()];
|
|
227
|
+
case 7:
|
|
228
|
+
_b = _c.apply(void 0, [_d.sent()]);
|
|
229
|
+
_d.label = 8;
|
|
230
|
+
case 8:
|
|
231
|
+
destinationChainId = _b;
|
|
232
|
+
return [2 /*return*/, unpackFillEvent(spreadEventWithBlockNumber(event), destinationChainId)];
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=SpokeUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpokeUtils.js","sourceRoot":"","sources":["../../../../../src/arch/tvm/SpokeUtils.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAEL,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,aAAa,CAAC;AAIrB,8DAA8D;AAC9D,OA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AAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,aAAa,EAAE,SAAS,CAAC,SAAS,CAAC,EACzG,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,eAAe,EAAE,CAC9C,EAAA;;oBAJK,MAAM,GAAG,SAId;oBAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;wBACxB,sBAAO,SAAS,EAAC;oBACnB,CAAC;oBAEK,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;yBAIG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,EAA1D,wBAA0D;oBAChF,qBAAM,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAA;;oBAAtC,KAAA,CAAC,SAAqC,CAAC,CAAC,OAAO,CAAA;;;oBAC/C,KAAA,MAAM,CAAA;oBAAC,qBAAM,SAAS,CAAC,OAAO,EAAE,EAAA;;oBAAhC,KAAA,kBAAO,SAAyB,EAAC,CAAA;;;oBAF/B,kBAAkB,KAEa;oBAErC,sBAAO,eAAe,CAAC,0BAA0B,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC,EAAC;;;;CAC/E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TronWeb } from "tronweb";
|
|
2
|
+
import { PopulatedTransaction } from "ethers";
|
|
3
|
+
export interface TronTransactionResult {
|
|
4
|
+
txid: string;
|
|
5
|
+
result: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Submit a populated EVM transaction to TRON via TronWeb.
|
|
9
|
+
*
|
|
10
|
+
* The EVM `populateV3Relay()` already produces correct ABI-encoded calldata.
|
|
11
|
+
* This function extracts `to` and `data` from the PopulatedTransaction,
|
|
12
|
+
* converts the target address to TRON Base58 format, and uses TronWeb's
|
|
13
|
+
* `triggerSmartContract` → `sign` → `sendRawTransaction` pipeline.
|
|
14
|
+
*
|
|
15
|
+
* @param tronWeb An authenticated TronWeb instance (with private key set).
|
|
16
|
+
* @param populatedTx The populated transaction containing `to` and `data`.
|
|
17
|
+
* @param feeLimit The maximum TRX to burn for energy consumption, in SUN (1 TRX = 1,000,000 SUN).
|
|
18
|
+
* @returns The transaction ID and result status.
|
|
19
|
+
*/
|
|
20
|
+
export declare function submitTransaction(tronWeb: TronWeb, populatedTx: PopulatedTransaction, feeLimit: number): Promise<TronTransactionResult>;
|