@hyperlane-xyz/tron-sdk 21.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/LICENSE.md +195 -0
  2. package/README.md +47 -0
  3. package/dist/abi/DomainRoutingIsm.json +240 -0
  4. package/dist/abi/ERC20.json +293 -0
  5. package/dist/abi/ERC20Test.json +365 -0
  6. package/dist/abi/HypERC20.json +920 -0
  7. package/dist/abi/HypERC20Collateral.json +1556 -0
  8. package/dist/abi/HypNative.json +1561 -0
  9. package/dist/abi/IERC20.json +190 -0
  10. package/dist/abi/IInterchainSecurityModule.json +44 -0
  11. package/dist/abi/IPostDispatchHook.json +81 -0
  12. package/dist/abi/InterchainGasPaymaster.json +518 -0
  13. package/dist/abi/Mailbox.json +686 -0
  14. package/dist/abi/MerkleTreeHook.json +375 -0
  15. package/dist/abi/NoopIsm.json +57 -0
  16. package/dist/abi/PausableHook.json +199 -0
  17. package/dist/abi/ProxyAdmin.json +156 -0
  18. package/dist/abi/StaticMerkleRootMultisigIsm.json +100 -0
  19. package/dist/abi/StaticMessageIdMultisigIsm.json +100 -0
  20. package/dist/abi/StorageGasOracle.json +205 -0
  21. package/dist/abi/TransparentUpgradeableProxy.json +81 -0
  22. package/dist/abi/ValidatorAnnounce.json +299 -0
  23. package/dist/clients/protocol.d.ts +17 -0
  24. package/dist/clients/protocol.d.ts.map +1 -0
  25. package/dist/clients/protocol.js +40 -0
  26. package/dist/clients/protocol.js.map +1 -0
  27. package/dist/clients/provider.d.ts +67 -0
  28. package/dist/clients/provider.d.ts.map +1 -0
  29. package/dist/clients/provider.js +558 -0
  30. package/dist/clients/provider.js.map +1 -0
  31. package/dist/clients/signer.d.ts +46 -0
  32. package/dist/clients/signer.d.ts.map +1 -0
  33. package/dist/clients/signer.js +561 -0
  34. package/dist/clients/signer.js.map +1 -0
  35. package/dist/hook/hook-query.d.ts +41 -0
  36. package/dist/hook/hook-query.d.ts.map +1 -0
  37. package/dist/hook/hook-query.js +79 -0
  38. package/dist/hook/hook-query.js.map +1 -0
  39. package/dist/hook/hook-tx.d.ts +39 -0
  40. package/dist/hook/hook-tx.d.ts.map +1 -0
  41. package/dist/hook/hook-tx.js +95 -0
  42. package/dist/hook/hook-tx.js.map +1 -0
  43. package/dist/index.d.ts +5 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +4 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/ism/ism-query.d.ts +70 -0
  48. package/dist/ism/ism-query.d.ts.map +1 -0
  49. package/dist/ism/ism-query.js +137 -0
  50. package/dist/ism/ism-query.js.map +1 -0
  51. package/dist/ism/ism-tx.d.ts +67 -0
  52. package/dist/ism/ism-tx.d.ts.map +1 -0
  53. package/dist/ism/ism-tx.js +110 -0
  54. package/dist/ism/ism-tx.js.map +1 -0
  55. package/dist/tests/1_interchain_security.e2e-test.d.ts +2 -0
  56. package/dist/tests/1_interchain_security.e2e-test.d.ts.map +1 -0
  57. package/dist/tests/1_interchain_security.e2e-test.js +172 -0
  58. package/dist/tests/1_interchain_security.e2e-test.js.map +1 -0
  59. package/dist/tests/2_core.e2e-test.d.ts +2 -0
  60. package/dist/tests/2_core.e2e-test.d.ts.map +1 -0
  61. package/dist/tests/2_core.e2e-test.js +117 -0
  62. package/dist/tests/2_core.e2e-test.js.map +1 -0
  63. package/dist/tests/3_post_dispatch.e2e-test.d.ts +2 -0
  64. package/dist/tests/3_post_dispatch.e2e-test.d.ts.map +1 -0
  65. package/dist/tests/3_post_dispatch.e2e-test.js +116 -0
  66. package/dist/tests/3_post_dispatch.e2e-test.js.map +1 -0
  67. package/dist/tests/4_warp.e2e-test.d.ts +2 -0
  68. package/dist/tests/4_warp.e2e-test.d.ts.map +1 -0
  69. package/dist/tests/4_warp.e2e-test.js +304 -0
  70. package/dist/tests/4_warp.e2e-test.js.map +1 -0
  71. package/dist/tests/index.e2e-test.d.ts +5 -0
  72. package/dist/tests/index.e2e-test.d.ts.map +1 -0
  73. package/dist/tests/index.e2e-test.js +6 -0
  74. package/dist/tests/index.e2e-test.js.map +1 -0
  75. package/dist/utils/index.d.ts +24 -0
  76. package/dist/utils/index.d.ts.map +1 -0
  77. package/dist/utils/index.js +71 -0
  78. package/dist/utils/index.js.map +1 -0
  79. package/dist/utils/types.d.ts +94 -0
  80. package/dist/utils/types.d.ts.map +1 -0
  81. package/dist/utils/types.js +13 -0
  82. package/dist/utils/types.js.map +1 -0
  83. package/package.json +63 -0
@@ -0,0 +1,79 @@
1
+ import { assert } from '@hyperlane-xyz/utils';
2
+ import IPostDispatchHookAbi from '../abi/IPostDispatchHook.json' with { type: 'json' };
3
+ import InterchainGasPaymasterAbi from '../abi/InterchainGasPaymaster.json' with { type: 'json' };
4
+ import MerkleTreeHookAbi from '../abi/MerkleTreeHook.json' with { type: 'json' };
5
+ import StorageGasOracleAbi from '../abi/StorageGasOracle.json' with { type: 'json' };
6
+ import { TronHookTypes } from '../utils/types.js';
7
+ export async function getHookType(query, hookAddress) {
8
+ const contract = query.contract(IPostDispatchHookAbi.abi, hookAddress);
9
+ const hookType = Number(await contract.hookType().call());
10
+ switch (hookType) {
11
+ case 3:
12
+ return TronHookTypes.MERKLE_TREE;
13
+ case 4:
14
+ return TronHookTypes.INTERCHAIN_GAS_PAYMASTER;
15
+ default:
16
+ throw new Error(`Unknown Hook type for address: ${hookAddress}`);
17
+ }
18
+ }
19
+ /**
20
+ * Query IGP hook configuration from chain.
21
+ *
22
+ * @param query - Query client with PostDispatchExtension
23
+ * @param hookId - ID of the IGP hook to query
24
+ * @returns IGP hook configuration with address, owner, and destination gas configs
25
+ * @throws Error if IGP hook not found
26
+ */
27
+ export async function getIgpHookConfig(query, hookId) {
28
+ try {
29
+ const igp = query.contract(InterchainGasPaymasterAbi.abi, hookId);
30
+ const hookType = await igp.hookType().call();
31
+ assert(Number(hookType) === 4, `hook type does not equal INTERCHAIN_GAS_PAYMASTER`);
32
+ const domainIds = await igp.domains().call();
33
+ const destinationGasConfigs = {};
34
+ for (const domainId of domainIds) {
35
+ const c = await igp.destinationGasConfigs(domainId).call();
36
+ const gasOracle = query.contract(StorageGasOracleAbi.abi, query.address.fromHex(c.gasOracle));
37
+ const { tokenExchangeRate, gasPrice } = await gasOracle
38
+ .remoteGasData(domainId)
39
+ .call();
40
+ destinationGasConfigs[domainId.toString()] = {
41
+ gasOracle: {
42
+ tokenExchangeRate: tokenExchangeRate.toString(),
43
+ gasPrice: gasPrice.toString(),
44
+ },
45
+ gasOverhead: c.gasOverhead.toString(),
46
+ };
47
+ }
48
+ return {
49
+ address: hookId,
50
+ owner: query.address.fromHex(await igp.owner().call()),
51
+ destinationGasConfigs,
52
+ };
53
+ }
54
+ catch (error) {
55
+ throw new Error(`Failed to query IGP hook config at ${hookId}: ${error.message}`);
56
+ }
57
+ }
58
+ /**
59
+ * Query MerkleTree hook configuration from chain.
60
+ *
61
+ * @param query - Query client with PostDispatchExtension
62
+ * @param hookId - ID of the MerkleTree hook to query
63
+ * @returns MerkleTree hook configuration with address
64
+ * @throws Error if MerkleTree hook not found
65
+ */
66
+ export async function getMerkleTreeHookConfig(query, hookId) {
67
+ try {
68
+ const contract = query.contract(MerkleTreeHookAbi.abi, hookId);
69
+ const hookType = await contract.hookType().call();
70
+ assert(Number(hookType) === 3, `hook type does not equal MERKLE_TREE`);
71
+ return {
72
+ address: hookId,
73
+ };
74
+ }
75
+ catch (error) {
76
+ throw new Error(`Failed to query MerkleTree hook config at ${hookId}: ${error.message}`);
77
+ }
78
+ }
79
+ //# sourceMappingURL=hook-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-query.js","sourceRoot":"","sources":["../../src/hook/hook-query.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,oBAAoB,MAAM,+BAA+B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACvF,OAAO,yBAAyB,MAAM,oCAAoC,CAAC,O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AAC,IAAI,EAAE,CAAC;QAClD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,sCAAsC,CAAC,CAAC;QAEvE,OAAO;YACL,OAAO,EAAE,MAAM;SAChB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,6CAA6C,MAAM,KAAM,KAAe,CAAC,OAAO,EAAE,CACnF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { TronWeb } from 'tronweb';
2
+ import { TronTransaction } from '../utils/types.js';
3
+ export declare function getCreateMerkleTreeHookTx(tronweb: Readonly<TronWeb>, fromAddress: string, mailboxAddress: string): Promise<TronTransaction>;
4
+ export declare function getCreateIgpTx(tronweb: Readonly<TronWeb>, fromAddress: string): Promise<TronTransaction>;
5
+ export declare function getCreateProxyTx(tronweb: Readonly<TronWeb>, fromAddress: string, implAddress: string, proxyAdminAddress: string): Promise<TronTransaction>;
6
+ export declare function getInitIgpTx(tronweb: Readonly<TronWeb>, fromAddress: string, config: {
7
+ igpAddress: string;
8
+ }): Promise<TronTransaction>;
9
+ export declare function getCreateOracleTx(tronweb: Readonly<TronWeb>, fromAddress: string): Promise<TronTransaction>;
10
+ export declare function getSetOracleTx(tronweb: Readonly<TronWeb>, fromAddress: string, config: {
11
+ igpAddress: string;
12
+ oracleAddress: string;
13
+ }): Promise<TronTransaction>;
14
+ export declare function getSetRemoteGasTx(tronweb: Readonly<TronWeb>, fromAddress: string, config: {
15
+ igpAddress: string;
16
+ destinationGasConfigs: {
17
+ remoteDomainId: number;
18
+ gasOracle: {
19
+ tokenExchangeRate: string;
20
+ gasPrice: string;
21
+ };
22
+ }[];
23
+ }): Promise<TronTransaction>;
24
+ export declare function getSetIgpOwnerTx(tronweb: Readonly<TronWeb>, fromAddress: string, config: {
25
+ igpAddress: string;
26
+ newOwner: string;
27
+ }): Promise<TronTransaction>;
28
+ export declare function getSetIgpDestinationGasConfigTx(tronweb: Readonly<TronWeb>, fromAddress: string, config: {
29
+ igpAddress: string;
30
+ destinationGasConfigs: {
31
+ remoteDomainId: number;
32
+ gasOverhead: string;
33
+ }[];
34
+ }): Promise<TronTransaction>;
35
+ export declare function getRemoveIgpDestinationGasConfigTx(tronweb: Readonly<TronWeb>, fromAddress: string, config: {
36
+ igpAddress: string;
37
+ remoteDomainIds: number[];
38
+ }): Promise<TronTransaction>;
39
+ //# sourceMappingURL=hook-tx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-tx.d.ts","sourceRoot":"","sources":["../../src/hook/hook-tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AASlC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC1B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,eAAe,CAAC,CAI1B;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC1B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,eAAe,CAAC,CAO1B;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC1B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,eAAe,CAAC,CAO1B;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC1B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE;IACN,UAAU,EAAE,MAAM,CAAC;CACpB,GACA,OAAO,CAAC,eAAe,CAAC,CAmB1B;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC1B,WAAW,EAAE,MAAM,GACl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AAE,CAAC;CAC3B,GACA,OAAO,CAAC,eAAe,CAAC,CAe1B"}
@@ -0,0 +1,95 @@
1
+ import { assert } from '@hyperlane-xyz/utils';
2
+ import InterchainGasPaymasterAbi from '../abi/InterchainGasPaymaster.json' with { type: 'json' };
3
+ import MerkleTreeHookAbi from '../abi/MerkleTreeHook.json' with { type: 'json' };
4
+ import StorageGasOracleAbi from '../abi/StorageGasOracle.json' with { type: 'json' };
5
+ import TransparentUpgradeableProxyAbi from '../abi/TransparentUpgradeableProxy.json' with { type: 'json' };
6
+ import { createDeploymentTransaction } from '../utils/index.js';
7
+ export async function getCreateMerkleTreeHookTx(tronweb, fromAddress, mailboxAddress) {
8
+ return createDeploymentTransaction(tronweb, MerkleTreeHookAbi, fromAddress, [
9
+ mailboxAddress,
10
+ ]);
11
+ }
12
+ export async function getCreateIgpTx(tronweb, fromAddress) {
13
+ return createDeploymentTransaction(tronweb, InterchainGasPaymasterAbi, fromAddress, []);
14
+ }
15
+ export async function getCreateProxyTx(tronweb, fromAddress, implAddress, proxyAdminAddress) {
16
+ return createDeploymentTransaction(tronweb, TransparentUpgradeableProxyAbi, fromAddress, [implAddress, proxyAdminAddress, '0x']);
17
+ }
18
+ export async function getInitIgpTx(tronweb, fromAddress, config) {
19
+ const { transaction } = await tronweb.transactionBuilder.triggerSmartContract(config.igpAddress, 'initialize(address,address)', {}, [
20
+ {
21
+ type: 'address',
22
+ value: fromAddress,
23
+ },
24
+ {
25
+ type: 'address',
26
+ value: fromAddress,
27
+ },
28
+ ], tronweb.address.toHex(fromAddress));
29
+ return transaction;
30
+ }
31
+ export async function getCreateOracleTx(tronweb, fromAddress) {
32
+ return createDeploymentTransaction(tronweb, StorageGasOracleAbi, fromAddress, []);
33
+ }
34
+ export async function getSetOracleTx(tronweb, fromAddress, config) {
35
+ const { transaction } = await tronweb.transactionBuilder.triggerSmartContract(config.igpAddress, 'setGasOracle(address)', {}, [
36
+ {
37
+ type: 'address',
38
+ value: config.oracleAddress,
39
+ },
40
+ ], tronweb.address.toHex(fromAddress));
41
+ return transaction;
42
+ }
43
+ export async function getSetRemoteGasTx(tronweb, fromAddress, config) {
44
+ const igp = tronweb.contract(InterchainGasPaymasterAbi.abi, config.igpAddress);
45
+ const oracleAddress = tronweb.address.fromHex(await igp.gasOracle().call());
46
+ const { transaction } = await tronweb.transactionBuilder.triggerSmartContract(oracleAddress, 'setRemoteGasDataConfigs((uint32,uint128,uint128)[])', {}, [
47
+ {
48
+ type: 'tuple(uint32 remoteDomain, uint128 tokenExchangeRate, uint128 gasPrice)[]',
49
+ value: config.destinationGasConfigs.map((c) => ({
50
+ remoteDomain: c.remoteDomainId,
51
+ tokenExchangeRate: c.gasOracle.tokenExchangeRate,
52
+ gasPrice: c.gasOracle.gasPrice,
53
+ })),
54
+ },
55
+ ], tronweb.address.toHex(fromAddress));
56
+ return transaction;
57
+ }
58
+ export async function getSetIgpOwnerTx(tronweb, fromAddress, config) {
59
+ const { transaction } = await tronweb.transactionBuilder.triggerSmartContract(config.igpAddress, 'transferOwnership(address)', {}, [
60
+ {
61
+ type: 'address',
62
+ value: config.newOwner,
63
+ },
64
+ ], tronweb.address.toHex(fromAddress));
65
+ return transaction;
66
+ }
67
+ export async function getSetIgpDestinationGasConfigTx(tronweb, fromAddress, config) {
68
+ const igp = tronweb.contract(InterchainGasPaymasterAbi.abi, config.igpAddress);
69
+ const hookType = await igp.hookType().call();
70
+ assert(Number(hookType) === 4, `hook type does not equal INTERCHAIN_GAS_PAYMASTER`);
71
+ const gasOracle = await igp.gasOracle().call();
72
+ const { transaction } = await tronweb.transactionBuilder.triggerSmartContract(config.igpAddress, 'setDestinationGasConfigs((uint32,(address,uint96))[])', {}, [
73
+ {
74
+ type: 'tuple(uint32 remoteDomain, tuple(address gasOracle, uint96 gasOverhead) config)[]',
75
+ value: config.destinationGasConfigs.map((c) => ({
76
+ remoteDomain: c.remoteDomainId,
77
+ config: {
78
+ gasOracle: gasOracle.replace('41', '0x'), // tron address format requires 0x prefix here
79
+ gasOverhead: c.gasOverhead,
80
+ },
81
+ })),
82
+ },
83
+ ], tronweb.address.toHex(fromAddress));
84
+ return transaction;
85
+ }
86
+ export async function getRemoveIgpDestinationGasConfigTx(tronweb, fromAddress, config) {
87
+ const { transaction } = await tronweb.transactionBuilder.triggerSmartContract(config.igpAddress, 'removeDestinationGasConfigs(uint32[])', {}, [
88
+ {
89
+ type: 'uint32[]',
90
+ value: config.remoteDomainIds,
91
+ },
92
+ ], tronweb.address.toHex(fromAddress));
93
+ return transaction;
94
+ }
95
+ //# sourceMappingURL=hook-tx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-tx.js","sourceRoot":"","sources":["../../src/hook/hook-tx.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,yBAAyB,MAAM,oCAAoC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACjG,OAAO,iBAAiB,MAAM,4BAA4B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACjF,OAAO,mBAAmB,MAAM,8BAA8B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACrF,OAAO,8BAA8B,MAAM,yCAAyC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC3G,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAGhE,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,OAA0B,EAC1B,WAAmB,EACnB,cAAsB;IAEtB,OAAO,2BAA2B,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE;QAC1E,cAAc;KACf,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAA0B,EAC1B,WAAmB;IAEnB,OAAO,2BAA2B,CAChC,OAAO,EACP,yBAAyB,EACzB,WAAW,EACX,EAAE,CACH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KA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KAAK,CAAC,WAAW,CAAC,CACnC,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { TronProvider } from './clients/provider.js';
2
+ export { TronSigner } from './clients/signer.js';
3
+ export { TronProtocolProvider } from './clients/protocol.js';
4
+ export { TronReceipt, TronTransaction } from './utils/types.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { TronProvider } from './clients/provider.js';
2
+ export { TronSigner } from './clients/signer.js';
3
+ export { TronProtocolProvider } from './clients/protocol.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { TronWeb } from 'tronweb';
2
+ import { TronIsmTypes } from '../utils/types.js';
3
+ /**
4
+ * Type alias for query client with ISM extension.
5
+ * Used throughout ISM readers to ensure type safety.
6
+ */
7
+ export type TronIsmQueryClient = TronWeb;
8
+ /**
9
+ * Query ISM type from address.
10
+ *
11
+ * @param query - Query client
12
+ * @param ismAddress - Address of the ISM to query
13
+ * @returns The AltVM ISM type
14
+ * @throws Error if ISM not found or unknown type
15
+ */
16
+ export declare function getIsmType(query: TronIsmQueryClient, ismAddress: string): Promise<TronIsmTypes>;
17
+ /**
18
+ * Query NoopIsm configuration.
19
+ *
20
+ * @param query - Query client
21
+ * @param ismAddress - Address of the NoopIsm to query
22
+ * @returns NoopIsm configuration with address
23
+ * @throws Error if NoopIsm not found
24
+ */
25
+ export declare function getNoopIsmConfig(query: TronIsmQueryClient, ismAddress: string): Promise<{
26
+ address: string;
27
+ }>;
28
+ /**
29
+ * Query Message ID Multisig ISM configuration.
30
+ *
31
+ * @param query - Query client
32
+ * @param ismAddress - Address of the Message ID Multisig ISM to query
33
+ * @returns Message ID Multisig ISM configuration with address, validators, and threshold
34
+ * @throws Error if Message ID Multisig ISM not found
35
+ */
36
+ export declare function getMessageIdMultisigIsmConfig(query: TronIsmQueryClient, ismAddress: string): Promise<{
37
+ address: string;
38
+ validators: string[];
39
+ threshold: number;
40
+ }>;
41
+ /**
42
+ * Query Merkle Root Multisig ISM configuration.
43
+ *
44
+ * @param query - Query client
45
+ * @param ismAddress - Address of the Merkle Root Multisig ISM to query
46
+ * @returns Merkle Root Multisig ISM configuration with address, validators, and threshold
47
+ * @throws Error if Merkle Root Multisig ISM not found
48
+ */
49
+ export declare function getMerkleRootMultisigIsmConfig(query: TronIsmQueryClient, ismAddress: string): Promise<{
50
+ address: string;
51
+ validators: string[];
52
+ threshold: number;
53
+ }>;
54
+ /**
55
+ * Query routing ISM configuration.
56
+ *
57
+ * @param query - Query client
58
+ * @param ismAddress - Address of the routing ISM to query
59
+ * @returns Routing ISM configuration with address, owner, and routes
60
+ * @throws Error if routing ISM not found
61
+ */
62
+ export declare function getRoutingIsmConfig(query: TronIsmQueryClient, ismAddress: string): Promise<{
63
+ address: string;
64
+ owner: string;
65
+ routes: Array<{
66
+ domainId: number;
67
+ ismAddress: string;
68
+ }>;
69
+ }>;
70
+ //# sourceMappingURL=ism-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ism-query.d.ts","sourceRoot":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-0,0 +1,137 @@
1
+ import { assert } from '@hyperlane-xyz/utils';
2
+ import DomainRoutingIsmAbi from '../abi/DomainRoutingIsm.json' with { type: 'json' };
3
+ import IInterchainSecurityModuleAbi from '../abi/IInterchainSecurityModule.json' with { type: 'json' };
4
+ import NoopIsmAbi from '../abi/NoopIsm.json' with { type: 'json' };
5
+ import StaticMerkleRootMultisigIsmAbi from '../abi/StaticMerkleRootMultisigIsm.json' with { type: 'json' };
6
+ import StaticMessageIdMultisigIsmAbi from '../abi/StaticMessageIdMultisigIsm.json' with { type: 'json' };
7
+ import { TRON_EMPTY_MESSAGE } from '../utils/index.js';
8
+ import { TronIsmTypes } from '../utils/types.js';
9
+ /**
10
+ * Query ISM type from address.
11
+ *
12
+ * @param query - Query client
13
+ * @param ismAddress - Address of the ISM to query
14
+ * @returns The AltVM ISM type
15
+ * @throws Error if ISM not found or unknown type
16
+ */
17
+ export async function getIsmType(query, ismAddress) {
18
+ try {
19
+ const contract = query.contract(IInterchainSecurityModuleAbi.abi, ismAddress);
20
+ const moduleType = Number(await contract.moduleType().call());
21
+ switch (moduleType) {
22
+ case 1:
23
+ return TronIsmTypes.ROUTING_ISM;
24
+ case 4:
25
+ return TronIsmTypes.MERKLE_ROOT_MULTISIG;
26
+ case 5:
27
+ return TronIsmTypes.MESSAGE_ID_MULTISIG;
28
+ case 6:
29
+ return TronIsmTypes.NOOP_ISM;
30
+ default:
31
+ throw new Error(`Unknown ISM type for address: ${ismAddress}`);
32
+ }
33
+ }
34
+ catch (error) {
35
+ throw new Error(`Failed to query ISM type at ${ismAddress}: ${error.message}`);
36
+ }
37
+ }
38
+ /**
39
+ * Query NoopIsm configuration.
40
+ *
41
+ * @param query - Query client
42
+ * @param ismAddress - Address of the NoopIsm to query
43
+ * @returns NoopIsm configuration with address
44
+ * @throws Error if NoopIsm not found
45
+ */
46
+ export async function getNoopIsmConfig(query, ismAddress) {
47
+ try {
48
+ const contract = query.contract(NoopIsmAbi.abi, ismAddress);
49
+ const moduleType = await contract.moduleType().call();
50
+ assert(Number(moduleType) === 6, `module type does not equal NULL_ISM`);
51
+ return {
52
+ address: ismAddress,
53
+ };
54
+ }
55
+ catch (error) {
56
+ throw new Error(`Failed to query NoopIsm config at ${ismAddress}: ${error.message}`);
57
+ }
58
+ }
59
+ /**
60
+ * Query Message ID Multisig ISM configuration.
61
+ *
62
+ * @param query - Query client
63
+ * @param ismAddress - Address of the Message ID Multisig ISM to query
64
+ * @returns Message ID Multisig ISM configuration with address, validators, and threshold
65
+ * @throws Error if Message ID Multisig ISM not found
66
+ */
67
+ export async function getMessageIdMultisigIsmConfig(query, ismAddress) {
68
+ try {
69
+ const contract = query.contract(StaticMessageIdMultisigIsmAbi.abi, ismAddress);
70
+ const [validators, threshold] = await contract
71
+ .validatorsAndThreshold(TRON_EMPTY_MESSAGE)
72
+ .call();
73
+ return {
74
+ address: ismAddress,
75
+ threshold: Number(threshold),
76
+ validators: validators.map((v) => v.replace('41', '0x')),
77
+ };
78
+ }
79
+ catch (error) {
80
+ throw new Error(`Failed to query Message ID Multisig ISM config at ${ismAddress}: ${error.message}`);
81
+ }
82
+ }
83
+ /**
84
+ * Query Merkle Root Multisig ISM configuration.
85
+ *
86
+ * @param query - Query client
87
+ * @param ismAddress - Address of the Merkle Root Multisig ISM to query
88
+ * @returns Merkle Root Multisig ISM configuration with address, validators, and threshold
89
+ * @throws Error if Merkle Root Multisig ISM not found
90
+ */
91
+ export async function getMerkleRootMultisigIsmConfig(query, ismAddress) {
92
+ try {
93
+ const contract = query.contract(StaticMerkleRootMultisigIsmAbi.abi, ismAddress);
94
+ const [validators, threshold] = await contract
95
+ .validatorsAndThreshold(TRON_EMPTY_MESSAGE)
96
+ .call();
97
+ return {
98
+ address: ismAddress,
99
+ threshold: Number(threshold),
100
+ validators: validators.map((v) => v.replace('41', '0x')),
101
+ };
102
+ }
103
+ catch (error) {
104
+ throw new Error(`Failed to query Merkle Root Multisig ISM config at ${ismAddress}: ${error.message}`);
105
+ }
106
+ }
107
+ /**
108
+ * Query routing ISM configuration.
109
+ *
110
+ * @param query - Query client
111
+ * @param ismAddress - Address of the routing ISM to query
112
+ * @returns Routing ISM configuration with address, owner, and routes
113
+ * @throws Error if routing ISM not found
114
+ */
115
+ export async function getRoutingIsmConfig(query, ismAddress) {
116
+ try {
117
+ const contract = query.contract(DomainRoutingIsmAbi.abi, ismAddress);
118
+ const routes = [];
119
+ const domainIds = await contract.domains().call();
120
+ for (const domainId of domainIds) {
121
+ const ismAddress = query.address.fromHex(await contract.module(domainId).call());
122
+ routes.push({
123
+ domainId: Number(domainId),
124
+ ismAddress,
125
+ });
126
+ }
127
+ return {
128
+ address: ismAddress,
129
+ owner: query.address.fromHex(await contract.owner().call()),
130
+ routes,
131
+ };
132
+ }
133
+ catch (error) {
134
+ throw new Error(`Failed to query routing ISM config at ${ismAddress}: ${error.message}`);
135
+ }
136
+ }
137
+ //# sourceMappingURL=ism-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ism-query.js","sourceRoot":"","sources":["../../src/ism/ism-query.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,mBAAmB,MAAM,8BAA8B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACrF,OAAO,4BAA4B,MAAM,uCAAuC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACvG,OAAO,UAAU,MAAM,qBAAqB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACnE,OAAO,8BAA8B,MAAM,yCAAyC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC3G,OAAO,6BAA6B,MAAM,wCAAwC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACzG,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQjD;;;;;;;GAOG;AACH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ateTestIsmTx(tronweb: Readonly<TronWeb>, fromAddress: string): Promise<TronTransaction>;
4
+ /**
5
+ * Deploys StaticMessageIdMultisigIsm implementation contract (deploy once, reuse)
6
+ * @param tronweb - TronWeb instance
7
+ * @param fromAddress - Deployer address
8
+ * @returns Transaction to deploy implementation
9
+ */
10
+ export declare function getCreateMessageIdMultisigIsmImplementationTx(tronweb: Readonly<TronWeb>, fromAddress: string): Promise<TronTransaction>;
11
+ /**
12
+ * Deploys StaticMerkleRootMultisigIsm implementation contract (deploy once, reuse)
13
+ * @param tronweb - TronWeb instance
14
+ * @param fromAddress - Deployer address
15
+ * @returns Transaction to deploy implementation
16
+ */
17
+ export declare function getCreateMerkleRootMultisigIsmImplementationTx(tronweb: Readonly<TronWeb>, fromAddress: string): Promise<TronTransaction>;
18
+ /**
19
+ * Creates transaction to deploy MessageIdMultisigIsm using MetaProxy pattern
20
+ * This embeds config in bytecode rather than constructor, enabling deterministic addresses
21
+ * @param tronweb - TronWeb instance
22
+ * @param fromAddress - Deployer address
23
+ * @param implementationAddress - Address of deployed StaticMessageIdMultisigIsm implementation
24
+ * @param config - Validators and threshold configuration
25
+ * @returns Transaction to deploy MetaProxy ISM
26
+ */
27
+ export declare function getCreateMessageIdMultisigIsmWithMetaProxyTx(tronweb: Readonly<TronWeb>, fromAddress: string, implementationAddress: string, config: {
28
+ validators: string[];
29
+ threshold: number;
30
+ }): Promise<TronTransaction>;
31
+ /**
32
+ * Creates transaction to deploy MerkleRootMultisigIsm using MetaProxy pattern
33
+ * This embeds config in bytecode rather than constructor, enabling deterministic addresses
34
+ * @param tronweb - TronWeb instance
35
+ * @param fromAddress - Deployer address
36
+ * @param implementationAddress - Address of deployed StaticMerkleRootMultisigIsm implementation
37
+ * @param config - Validators and threshold configuration
38
+ * @returns Transaction to deploy MetaProxy ISM
39
+ */
40
+ export declare function getCreateMerkleRootMultisigIsmWithMetaProxyTx(tronweb: Readonly<TronWeb>, fromAddress: string, implementationAddress: string, config: {
41
+ validators: string[];
42
+ threshold: number;
43
+ }): Promise<TronTransaction>;
44
+ export declare function getCreateRoutingIsmTx(tronweb: Readonly<TronWeb>, fromAddress: string): Promise<TronTransaction>;
45
+ export declare function getInitRoutingIsmTx(tronweb: Readonly<TronWeb>, ownerAddress: string, config: {
46
+ ismAddress: string;
47
+ routes: {
48
+ ismAddress: string;
49
+ domainId: number;
50
+ }[];
51
+ }): Promise<TronTransaction>;
52
+ export declare function getSetRoutingIsmRouteTx(tronweb: Readonly<TronWeb>, ownerAddress: string, config: {
53
+ ismAddress: string;
54
+ domainIsm: {
55
+ domainId: number;
56
+ ismAddress: string;
57
+ };
58
+ }): Promise<TronTransaction>;
59
+ export declare function getRemoveRoutingIsmRouteTx(tronweb: Readonly<TronWeb>, ownerAddress: string, config: {
60
+ ismAddress: string;
61
+ domainId: number;
62
+ }): Promise<TronTransaction>;
63
+ export declare function getSetRoutingIsmOwnerTx(tronweb: Readonly<TronWeb>, ownerAddress: string, config: {
64
+ ismAddress: string;
65
+ newOwner: string;
66
+ }): Promise<TronTransaction>;
67
+ //# sourceMappingURL=ism-tx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ism-tx.d.ts","sourceRoot":"","sources":["../../src/ism/ism-tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAWlC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC1B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,eAAe,CAAC,CAE1B;AAED;;;;;GAKG;AACH,wBAAsB,6CAA6C,CACjE,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC1B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,eAAe,CAAC,CAO1B;AAED;;;;;GAKG;AACH,wBAAsB,8CAA8C,CAClE,OAAO,EAAE,QAAQ,CAAC,OAAO,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