@hyperlane-xyz/sdk 1.2.2 → 1.3.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 (243) hide show
  1. package/dist/HyperlaneApp.d.ts +11 -7
  2. package/dist/HyperlaneApp.d.ts.map +1 -1
  3. package/dist/HyperlaneApp.js +14 -0
  4. package/dist/HyperlaneApp.js.map +1 -1
  5. package/dist/agents/types.d.ts +56 -0
  6. package/dist/agents/types.d.ts.map +1 -0
  7. package/dist/agents/types.js +43 -0
  8. package/dist/agents/types.js.map +1 -0
  9. package/dist/consts/bytecode.d.ts +11 -0
  10. package/dist/consts/bytecode.d.ts.map +1 -0
  11. package/dist/consts/bytecode.js +15 -0
  12. package/dist/consts/bytecode.js.map +1 -0
  13. package/dist/consts/chainMetadata.d.ts +2 -0
  14. package/dist/consts/chainMetadata.d.ts.map +1 -1
  15. package/dist/consts/chainMetadata.js +6 -3
  16. package/dist/consts/chainMetadata.js.map +1 -1
  17. package/dist/consts/environments/index.d.ts +64 -231
  18. package/dist/consts/environments/index.d.ts.map +1 -1
  19. package/dist/consts/environments/index.js +2 -12
  20. package/dist/consts/environments/index.js.map +1 -1
  21. package/dist/consts/environments/mainnet.json +28 -99
  22. package/dist/consts/environments/test.json +20 -44
  23. package/dist/consts/environments/testnet.json +27 -90
  24. package/dist/consts/multisigIsm.d.ts +4 -0
  25. package/dist/consts/multisigIsm.d.ts.map +1 -0
  26. package/dist/consts/multisigIsm.js +174 -0
  27. package/dist/consts/multisigIsm.js.map +1 -0
  28. package/dist/contracts.d.ts +16 -10
  29. package/dist/contracts.d.ts.map +1 -1
  30. package/dist/contracts.js +32 -43
  31. package/dist/contracts.js.map +1 -1
  32. package/dist/core/HyperlaneCore.d.ts +5 -16
  33. package/dist/core/HyperlaneCore.d.ts.map +1 -1
  34. package/dist/core/HyperlaneCore.js +7 -35
  35. package/dist/core/HyperlaneCore.js.map +1 -1
  36. package/dist/core/HyperlaneCoreChecker.d.ts +0 -6
  37. package/dist/core/HyperlaneCoreChecker.d.ts.map +1 -1
  38. package/dist/core/HyperlaneCoreChecker.js +20 -155
  39. package/dist/core/HyperlaneCoreChecker.js.map +1 -1
  40. package/dist/core/HyperlaneCoreDeployer.d.ts +8 -22
  41. package/dist/core/HyperlaneCoreDeployer.d.ts.map +1 -1
  42. package/dist/core/HyperlaneCoreDeployer.js +14 -141
  43. package/dist/core/HyperlaneCoreDeployer.js.map +1 -1
  44. package/dist/core/TestCoreApp.d.ts +8 -12
  45. package/dist/core/TestCoreApp.d.ts.map +1 -1
  46. package/dist/core/TestCoreApp.js +6 -3
  47. package/dist/core/TestCoreApp.js.map +1 -1
  48. package/dist/core/TestCoreDeployer.d.ts +2 -2
  49. package/dist/core/TestCoreDeployer.d.ts.map +1 -1
  50. package/dist/core/TestCoreDeployer.js +4 -25
  51. package/dist/core/TestCoreDeployer.js.map +1 -1
  52. package/dist/core/contracts.d.ts +3 -22
  53. package/dist/core/contracts.d.ts.map +1 -1
  54. package/dist/core/contracts.js +1 -7
  55. package/dist/core/contracts.js.map +1 -1
  56. package/dist/core/testHyperlaneDeploy.hardhat-test.js +2 -2
  57. package/dist/core/testHyperlaneDeploy.hardhat-test.js.map +1 -1
  58. package/dist/core/types.d.ts +4 -47
  59. package/dist/core/types.d.ts.map +1 -1
  60. package/dist/core/types.js +1 -16
  61. package/dist/core/types.js.map +1 -1
  62. package/dist/deploy/HyperlaneAppChecker.d.ts +2 -4
  63. package/dist/deploy/HyperlaneAppChecker.d.ts.map +1 -1
  64. package/dist/deploy/HyperlaneAppChecker.js +47 -21
  65. package/dist/deploy/HyperlaneAppChecker.js.map +1 -1
  66. package/dist/deploy/HyperlaneDeployer.d.ts +20 -18
  67. package/dist/deploy/HyperlaneDeployer.d.ts.map +1 -1
  68. package/dist/deploy/HyperlaneDeployer.js +120 -94
  69. package/dist/deploy/HyperlaneDeployer.js.map +1 -1
  70. package/dist/deploy/proxy.d.ts +1 -13
  71. package/dist/deploy/proxy.d.ts.map +1 -1
  72. package/dist/deploy/proxy.js +8 -13
  73. package/dist/deploy/proxy.js.map +1 -1
  74. package/dist/deploy/types.d.ts +7 -1
  75. package/dist/deploy/types.d.ts.map +1 -1
  76. package/dist/deploy/types.js +1 -0
  77. package/dist/deploy/types.js.map +1 -1
  78. package/dist/deploy/verify/ContractVerifier.d.ts.map +1 -1
  79. package/dist/deploy/verify/ContractVerifier.js +2 -1
  80. package/dist/deploy/verify/ContractVerifier.js.map +1 -1
  81. package/dist/deploy/verify/utils.d.ts +1 -0
  82. package/dist/deploy/verify/utils.d.ts.map +1 -1
  83. package/dist/deploy/verify/utils.js +9 -4
  84. package/dist/deploy/verify/utils.js.map +1 -1
  85. package/dist/gas/HyperlaneIgp.d.ts +53 -0
  86. package/dist/gas/HyperlaneIgp.d.ts.map +1 -0
  87. package/dist/gas/HyperlaneIgp.js +72 -0
  88. package/dist/gas/HyperlaneIgp.js.map +1 -0
  89. package/dist/gas/HyperlaneIgpChecker.d.ts +14 -0
  90. package/dist/gas/HyperlaneIgpChecker.d.ts.map +1 -0
  91. package/dist/gas/HyperlaneIgpChecker.js +148 -0
  92. package/dist/gas/HyperlaneIgpChecker.js.map +1 -0
  93. package/dist/gas/HyperlaneIgpDeployer.d.ts +22 -0
  94. package/dist/gas/HyperlaneIgpDeployer.d.ts.map +1 -0
  95. package/dist/gas/HyperlaneIgpDeployer.js +113 -0
  96. package/dist/gas/HyperlaneIgpDeployer.js.map +1 -0
  97. package/dist/gas/contracts.d.ts +9 -0
  98. package/dist/gas/contracts.d.ts.map +1 -0
  99. package/dist/gas/contracts.js +11 -0
  100. package/dist/gas/contracts.js.map +1 -0
  101. package/dist/gas/types.d.ts +35 -50
  102. package/dist/gas/types.d.ts.map +1 -1
  103. package/dist/gas/types.js +11 -17
  104. package/dist/gas/types.js.map +1 -1
  105. package/dist/index.d.ts +34 -26
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +68 -43
  108. package/dist/index.js.map +1 -1
  109. package/dist/middleware/MiddlewareRouterChecker.d.ts +8 -0
  110. package/dist/middleware/MiddlewareRouterChecker.d.ts.map +1 -0
  111. package/dist/middleware/MiddlewareRouterChecker.js +26 -0
  112. package/dist/middleware/MiddlewareRouterChecker.js.map +1 -0
  113. package/dist/middleware/MiddlewareRouterDeployer.d.ts +17 -0
  114. package/dist/middleware/MiddlewareRouterDeployer.d.ts.map +1 -0
  115. package/dist/middleware/MiddlewareRouterDeployer.js +62 -0
  116. package/dist/middleware/MiddlewareRouterDeployer.js.map +1 -0
  117. package/dist/middleware/account/InterchainAccount.d.ts +11 -0
  118. package/dist/middleware/account/InterchainAccount.d.ts.map +1 -0
  119. package/dist/middleware/account/InterchainAccount.js +21 -0
  120. package/dist/middleware/account/InterchainAccount.js.map +1 -0
  121. package/dist/middleware/account/InterchainAccountChecker.d.ts +7 -0
  122. package/dist/middleware/account/InterchainAccountChecker.d.ts.map +1 -0
  123. package/dist/middleware/account/InterchainAccountChecker.js +8 -0
  124. package/dist/middleware/account/InterchainAccountChecker.js.map +1 -0
  125. package/dist/middleware/account/InterchainAccountDeployer.d.ts +14 -0
  126. package/dist/middleware/account/InterchainAccountDeployer.d.ts.map +1 -0
  127. package/dist/middleware/account/InterchainAccountDeployer.js +64 -0
  128. package/dist/middleware/account/InterchainAccountDeployer.js.map +1 -0
  129. package/dist/middleware/account/accounts.hardhat-test.d.ts.map +1 -0
  130. package/dist/middleware/{accounts.hardhat-test.js → account/accounts.hardhat-test.js} +21 -24
  131. package/dist/middleware/account/accounts.hardhat-test.js.map +1 -0
  132. package/dist/middleware/account/contracts.d.ts +7 -0
  133. package/dist/middleware/account/contracts.d.ts.map +1 -0
  134. package/dist/middleware/account/contracts.js +9 -0
  135. package/dist/middleware/account/contracts.js.map +1 -0
  136. package/dist/middleware/liquidity-layer/LiquidityLayerApp.d.ts +5 -4
  137. package/dist/middleware/liquidity-layer/LiquidityLayerApp.d.ts.map +1 -1
  138. package/dist/middleware/liquidity-layer/LiquidityLayerApp.js +12 -2
  139. package/dist/middleware/liquidity-layer/LiquidityLayerApp.js.map +1 -1
  140. package/dist/middleware/liquidity-layer/LiquidityLayerRouterDeployer.d.ts +8 -6
  141. package/dist/middleware/liquidity-layer/LiquidityLayerRouterDeployer.d.ts.map +1 -1
  142. package/dist/middleware/liquidity-layer/LiquidityLayerRouterDeployer.js +13 -10
  143. package/dist/middleware/liquidity-layer/LiquidityLayerRouterDeployer.js.map +1 -1
  144. package/dist/middleware/liquidity-layer/contracts.d.ts +5 -8
  145. package/dist/middleware/liquidity-layer/contracts.d.ts.map +1 -1
  146. package/dist/middleware/liquidity-layer/contracts.js +2 -1
  147. package/dist/middleware/liquidity-layer/contracts.js.map +1 -1
  148. package/dist/middleware/liquidity-layer/liquidity-layer.hardhat-test.js +33 -30
  149. package/dist/middleware/liquidity-layer/liquidity-layer.hardhat-test.js.map +1 -1
  150. package/dist/middleware/query/InterchainQuery.d.ts +11 -0
  151. package/dist/middleware/query/InterchainQuery.d.ts.map +1 -0
  152. package/dist/middleware/query/InterchainQuery.js +21 -0
  153. package/dist/middleware/query/InterchainQuery.js.map +1 -0
  154. package/dist/middleware/query/InterchainQueryChecker.d.ts +7 -0
  155. package/dist/middleware/query/InterchainQueryChecker.d.ts.map +1 -0
  156. package/dist/middleware/query/InterchainQueryChecker.js +8 -0
  157. package/dist/middleware/query/InterchainQueryChecker.js.map +1 -0
  158. package/dist/middleware/query/InterchainQueryDeployer.d.ts +12 -0
  159. package/dist/middleware/query/InterchainQueryDeployer.d.ts.map +1 -0
  160. package/dist/middleware/query/InterchainQueryDeployer.js +13 -0
  161. package/dist/middleware/query/InterchainQueryDeployer.js.map +1 -0
  162. package/dist/middleware/query/contracts.d.ts +7 -0
  163. package/dist/middleware/query/contracts.d.ts.map +1 -0
  164. package/dist/middleware/query/contracts.js +9 -0
  165. package/dist/middleware/query/contracts.js.map +1 -0
  166. package/dist/middleware/query/queries.hardhat-test.d.ts.map +1 -0
  167. package/dist/middleware/{queries.hardhat-test.js → query/queries.hardhat-test.js} +21 -12
  168. package/dist/middleware/query/queries.hardhat-test.js.map +1 -0
  169. package/dist/providers/MultiProvider.d.ts +13 -2
  170. package/dist/providers/MultiProvider.d.ts.map +1 -1
  171. package/dist/providers/MultiProvider.js +60 -33
  172. package/dist/providers/MultiProvider.js.map +1 -1
  173. package/dist/router/GasRouterDeployer.d.ts +4 -4
  174. package/dist/router/GasRouterDeployer.d.ts.map +1 -1
  175. package/dist/router/GasRouterDeployer.js +1 -1
  176. package/dist/router/GasRouterDeployer.js.map +1 -1
  177. package/dist/router/HyperlaneRouterChecker.d.ts +3 -5
  178. package/dist/router/HyperlaneRouterChecker.d.ts.map +1 -1
  179. package/dist/router/HyperlaneRouterChecker.js +4 -8
  180. package/dist/router/HyperlaneRouterChecker.js.map +1 -1
  181. package/dist/router/HyperlaneRouterDeployer.d.ts +9 -6
  182. package/dist/router/HyperlaneRouterDeployer.d.ts.map +1 -1
  183. package/dist/router/HyperlaneRouterDeployer.js +13 -28
  184. package/dist/router/HyperlaneRouterDeployer.js.map +1 -1
  185. package/dist/router/RouterApps.d.ts +6 -4
  186. package/dist/router/RouterApps.d.ts.map +1 -1
  187. package/dist/router/RouterApps.js +2 -2
  188. package/dist/router/RouterApps.js.map +1 -1
  189. package/dist/router/types.d.ts +4 -16
  190. package/dist/router/types.d.ts.map +1 -1
  191. package/dist/test/envSubsetDeployer/app.d.ts +18 -11
  192. package/dist/test/envSubsetDeployer/app.d.ts.map +1 -1
  193. package/dist/test/envSubsetDeployer/app.js +14 -15
  194. package/dist/test/envSubsetDeployer/app.js.map +1 -1
  195. package/dist/test/envSubsetDeployer/check-single-chain.js +6 -4
  196. package/dist/test/envSubsetDeployer/check-single-chain.js.map +1 -1
  197. package/dist/test/envSubsetDeployer/deploy-single-chain.js +7 -5
  198. package/dist/test/envSubsetDeployer/deploy-single-chain.js.map +1 -1
  199. package/dist/test/envSubsetDeployer/deploy.hardhat-test.js +12 -13
  200. package/dist/test/envSubsetDeployer/deploy.hardhat-test.js.map +1 -1
  201. package/dist/test/testUtils.d.ts +10 -23
  202. package/dist/test/testUtils.d.ts.map +1 -1
  203. package/dist/test/testUtils.js +45 -60
  204. package/dist/test/testUtils.js.map +1 -1
  205. package/dist/utils/ism.d.ts +2 -0
  206. package/dist/utils/ism.d.ts.map +1 -0
  207. package/dist/utils/ism.js +18 -0
  208. package/dist/utils/ism.js.map +1 -0
  209. package/dist/utils/objects.d.ts +3 -1
  210. package/dist/utils/objects.d.ts.map +1 -1
  211. package/dist/utils/objects.js +35 -2
  212. package/dist/utils/objects.js.map +1 -1
  213. package/package.json +4 -4
  214. package/dist/deploy/utils.d.ts +0 -6
  215. package/dist/deploy/utils.d.ts.map +0 -1
  216. package/dist/deploy/utils.js +0 -13
  217. package/dist/deploy/utils.js.map +0 -1
  218. package/dist/gas/calculator.d.ts +0 -186
  219. package/dist/gas/calculator.d.ts.map +0 -1
  220. package/dist/gas/calculator.hardhat-test.d.ts +0 -2
  221. package/dist/gas/calculator.hardhat-test.d.ts.map +0 -1
  222. package/dist/gas/calculator.hardhat-test.js +0 -59
  223. package/dist/gas/calculator.hardhat-test.js.map +0 -1
  224. package/dist/gas/calculator.js +0 -301
  225. package/dist/gas/calculator.js.map +0 -1
  226. package/dist/gas/calculator.test.d.ts +0 -2
  227. package/dist/gas/calculator.test.d.ts.map +0 -1
  228. package/dist/gas/calculator.test.js +0 -197
  229. package/dist/gas/calculator.test.js.map +0 -1
  230. package/dist/middleware/accounts.hardhat-test.d.ts.map +0 -1
  231. package/dist/middleware/accounts.hardhat-test.js.map +0 -1
  232. package/dist/middleware/deploy.d.ts +0 -28
  233. package/dist/middleware/deploy.d.ts.map +0 -1
  234. package/dist/middleware/deploy.js +0 -68
  235. package/dist/middleware/deploy.js.map +0 -1
  236. package/dist/middleware/queries.hardhat-test.d.ts.map +0 -1
  237. package/dist/middleware/queries.hardhat-test.js.map +0 -1
  238. package/dist/proxy.d.ts +0 -21
  239. package/dist/proxy.d.ts.map +0 -1
  240. package/dist/proxy.js +0 -32
  241. package/dist/proxy.js.map +0 -1
  242. /package/dist/middleware/{accounts.hardhat-test.d.ts → account/accounts.hardhat-test.d.ts} +0 -0
  243. /package/dist/middleware/{queries.hardhat-test.d.ts → query/queries.hardhat-test.d.ts} +0 -0
@@ -1,301 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.InterchainGasCalculator = void 0;
16
- const coingecko_api_1 = __importDefault(require("coingecko-api"));
17
- const ethers_1 = require("ethers");
18
- const core_1 = require("@hyperlane-xyz/core");
19
- const utils_1 = require("@hyperlane-xyz/utils");
20
- const HyperlaneCore_1 = require("../core/HyperlaneCore");
21
- const number_1 = require("../utils/number");
22
- const token_prices_1 = require("./token-prices");
23
- /**
24
- * A note on arithmetic:
25
- * The ethers.BigNumber implementation behaves very similar to Solidity's
26
- * number handling by not supporting decimals. To avoid adding another big
27
- * number implementation as a dependency, we use ethers.FixedNumber, a
28
- * fixed point implementation intended to model how Solidity's half-supported
29
- * fixed point numbers work, see https://docs.soliditylang.org/en/v0.8.13/types.html#fixed-point-numbers).
30
- *
31
- * Generally, ceiling is used rather than floor here to err on the side of over-
32
- * estimating amounts.
33
- */
34
- // If a chain doesn't specify how many decimals their native token has, 18 is used.
35
- const DEFAULT_TOKEN_DECIMALS = 18;
36
- // Intrinsic gas for a transaction. Does not consider calldata costs or differences in
37
- // intrinsic gas for different chains.
38
- const GAS_INTRINSIC = 21000;
39
- // The gas used to process a message when the quorum size is zero.
40
- // Includes intrinsic gas, mailbox overhead gas, all other gas that does not scale with the
41
- // quorum size. Excludes the cost of the recipient's handle function.
42
- const GAS_OVERHEAD_BASE = 155000;
43
- // The amount of gas used for each signature when a signed checkpoint
44
- // is submitted for verification.
45
- // Really observed to be about 6500, but rounding up for safety.
46
- const GAS_OVERHEAD_PER_SIGNATURE = 7500;
47
- /**
48
- * Calculates interchain gas payments.
49
- */
50
- class InterchainGasCalculator {
51
- constructor(multiProvider, core, config) {
52
- var _a, _b;
53
- this.multiProvider = multiProvider;
54
- this.core = core;
55
- if (config === null || config === void 0 ? void 0 : config.tokenPriceGetter) {
56
- this.tokenPriceGetter = config.tokenPriceGetter;
57
- }
58
- else {
59
- const coinGecko = new coingecko_api_1.default();
60
- this.tokenPriceGetter = new token_prices_1.CoinGeckoTokenPriceGetter(coinGecko);
61
- }
62
- this.paymentEstimateMultiplier = ethers_1.FixedNumber.from((_a = config === null || config === void 0 ? void 0 : config.paymentEstimateMultiplier) !== null && _a !== void 0 ? _a : '1.25');
63
- this.messageGasEstimateBuffer = ethers_1.BigNumber.from((_b = config === null || config === void 0 ? void 0 : config.messageGasEstimateBuffer) !== null && _b !== void 0 ? _b : 50000);
64
- }
65
- static fromEnvironment(env, multiProvider, config) {
66
- const core = HyperlaneCore_1.HyperlaneCore.fromEnvironment(env, multiProvider);
67
- return new InterchainGasCalculator(multiProvider, core, config);
68
- }
69
- /**
70
- * Only intended for IGPs that quote gas payments on-chain.
71
- * Calls the default ISM IGP's `quoteGasPayment` function to get the amount of native tokens
72
- * required to pay for interchain gas.
73
- * The default ISM IGP will add any gas overhead amounts related to the Mailbox
74
- * and default ISM on the destination to the provided gasAmount.
75
- * @param origin The name of the origin chain.
76
- * @param destination The name of the destination chain.
77
- * @param gasAmount The amount of gas to use when calling `quoteGasPayment`.
78
- * The default IGP is expected to add any gas overhead related to the Mailbox
79
- * or ISM, so this gas amount is only required to cover the usage of the `handle`
80
- * function.
81
- * @returns The amount of native tokens required to pay for interchain gas.
82
- */
83
- quoteGasPaymentForDefaultIsmIgp(origin, destination, gasAmount) {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- const igpAddress = this.core.getContracts(origin).defaultIsmInterchainGasPaymaster;
86
- return this.quoteGasPaymentForIGP(origin, destination, gasAmount, igpAddress.address);
87
- });
88
- }
89
- /**
90
- * Only intended for IGPs that quote gas payments on-chain.
91
- * Calls the "base" IGP's `quoteGasPayment` function to get the amount of native tokens
92
- * required to pay for interchain gas.
93
- * This IGP will not apply any overhead gas to the provided gasAmount.
94
- * @param origin The name of the origin chain.
95
- * @param destination The name of the destination chain.
96
- * @param gasAmount The amount of gas to use when calling `quoteGasPayment`.
97
- * This is expected to be the total amount of gas that a transaction would use
98
- * on the destination chain. This should consider intrinsic transaction gas,
99
- * Mailbox overhead gas costs, ISM gas costs, and the recipient's handle function
100
- * gas cost.
101
- * @returns The amount of native tokens required to pay for interchain gas.
102
- */
103
- quoteGasPayment(origin, destination, gasAmount) {
104
- return __awaiter(this, void 0, void 0, function* () {
105
- const igpAddress = this.core.getContracts(origin).interchainGasPaymaster;
106
- return this.quoteGasPaymentForIGP(origin, destination, gasAmount, igpAddress.address);
107
- });
108
- }
109
- /**
110
- * Only intended for IGPs that quote gas payments on-chain.
111
- * Calls the origin's default IGP's `quoteGasPayment` function to get the
112
- * amount of native tokens required to pay for interchain gas.
113
- * The default IGP is expected to add any gas overhead related to the Mailbox
114
- * and ISM to the provided gasAmount.
115
- * @param origin The name of the origin chain.
116
- * @param destination The name of the destination chain.
117
- * @param gasAmount The amount of gas to use when calling `quoteGasPayment`.
118
- * The default IGP is expected to add any gas overhead related to the Mailbox
119
- * or ISM, so this gas amount is only required to cover the usage of the `handle`
120
- * function.
121
- * @returns The amount of native tokens required to pay for interchain gas.
122
- */
123
- quoteGasPaymentForIGP(origin, destination, gasAmount, interchainGasPaymasterAddress) {
124
- return __awaiter(this, void 0, void 0, function* () {
125
- const originProvider = this.multiProvider.getProvider(origin);
126
- const igp = core_1.InterchainGasPaymaster__factory.connect(interchainGasPaymasterAddress, originProvider);
127
- const domainId = this.multiProvider.getDomainId(destination);
128
- return igp.quoteGasPayment(domainId, gasAmount);
129
- });
130
- }
131
- /**
132
- * Only intended for IGPs that do *not* quote gas payments on-chain.
133
- * Given an amount of gas to consume on the destination chain, calculates the
134
- * estimated payment denominated in the native token of the origin chain.
135
- * Considers the exchange rate between the native tokens of the origin and
136
- * destination chains and the suggested gas price of the destination chain.
137
- * @param origin The name of the origin chain.
138
- * @param destination The name of the destination chain.
139
- * @param gas The amount of gas to pay for on the destination chain.
140
- * @returns An estimated amount of origin chain tokens to cover gas costs on the
141
- * destination chain.
142
- */
143
- estimatePaymentForGas(origin, destination, gas) {
144
- return __awaiter(this, void 0, void 0, function* () {
145
- const destinationGasPrice = yield this.getGasPrice(destination);
146
- const destinationGasCost = gas.mul(destinationGasPrice);
147
- const originGasCost = yield this.convertBetweenTokens(destination, origin, destinationGasCost);
148
- // Applies a multiplier
149
- return (0, number_1.mulBigAndFixed)(originGasCost, this.paymentEstimateMultiplier, true);
150
- });
151
- }
152
- /**
153
- * Only intended for IGPs that do *not* quote gas payments on-chain.
154
- * Given an amount of gas the message's recipient `handle` function is expected
155
- * to use, calculates the estimated payment denominated in the native
156
- * token of the origin chain. Considers the exchange rate between the native
157
- * tokens of the origin and destination chains, the suggested gas price on
158
- * the destination chain, gas costs incurred by a relayer when submitting a signed
159
- * checkpoint to the destination chain, and the overhead gas cost in Inbox of processing
160
- * a message.
161
- * @param origin The name of the origin chain.
162
- * @param destination The name of the destination chain.
163
- * @param handleGas The amount of gas the recipient `handle` function
164
- * is estimated to use.
165
- * @returns An estimated amount of origin chain tokens to cover gas costs of the
166
- * message on the destination chain.
167
- */
168
- estimatePaymentForHandleGas(origin, destination, handleGas) {
169
- return __awaiter(this, void 0, void 0, function* () {
170
- const destinationGas = handleGas.add(yield this.estimateGasForProcess(origin, destination));
171
- return this.estimatePaymentForGas(origin, destination, destinationGas);
172
- });
173
- }
174
- /**
175
- * Only intended for IGPs that do *not* quote gas payments on-chain.
176
- * Calculates the estimated payment to process the message on its destination chain,
177
- * denominated in the native token of the origin chain. The gas used by the message's
178
- * recipient handler function is estimated in an eth_estimateGas call to the
179
- * destination chain, and is then used to calculate the payment using
180
- * Currently made private as it does not work properly for Arbitrum.
181
- * {@link estimatePaymentForHandleGasAmount}.
182
- * @param message The parsed message to estimate payment for.
183
- * @returns An estimated amount of origin chain tokens to cover gas costs of the
184
- * message on the destination chain.
185
- */
186
- estimatePaymentForMessage(message) {
187
- return __awaiter(this, void 0, void 0, function* () {
188
- const handleGas = yield this.estimateGasForHandle(message);
189
- return this.estimatePaymentForHandleGas(message.origin, message.destination, handleGas);
190
- });
191
- }
192
- /**
193
- * Using the exchange rates provided by tokenPriceGetter, returns the amount of
194
- * `toChain` native tokens equivalent in value to the provided `fromAmount` of
195
- * `fromChain` native tokens. Accounts for differences in the decimals of the tokens.
196
- * @param fromChain The chain whose native token is being converted from.
197
- * @param toChain The chain whose native token is being converted into.
198
- * @param fromAmount The amount of `fromChain` native tokens to convert from.
199
- * @returns The amount of `toChain` native tokens whose value is equivalent to
200
- * `fromAmount` of `fromChain` native tokens.
201
- */
202
- convertBetweenTokens(fromChain, toChain, value) {
203
- return __awaiter(this, void 0, void 0, function* () {
204
- // Does not factor in differing token decimals.
205
- const exchangeRate = yield this.tokenPriceGetter.getTokenExchangeRate(fromChain, toChain);
206
- // 1/100th of a cent
207
- const PRECISION = 1000;
208
- return (0, number_1.convertDecimalValue)(value.mul(Math.round(exchangeRate * PRECISION)).div(PRECISION), this.tokenDecimals(fromChain), this.tokenDecimals(toChain));
209
- });
210
- }
211
- /**
212
- * Gets a suggested gas price for a chain.
213
- * @param chainName The name of the chain to get the gas price for
214
- * @returns The suggested gas price in wei on the destination chain.
215
- */
216
- getGasPrice(chain) {
217
- return __awaiter(this, void 0, void 0, function* () {
218
- const provider = this.multiProvider.getProvider(chain);
219
- if (provider == undefined) {
220
- throw new Error(`Missing provider for ${chain}`);
221
- }
222
- return provider.getGasPrice();
223
- });
224
- }
225
- /**
226
- * Gets the number of decimals of the provided chain's native token.
227
- * @param chain The chain.
228
- * @returns The number of decimals of `chain`'s native token.
229
- */
230
- tokenDecimals(chain) {
231
- var _a, _b, _c;
232
- return ((_c = (_b = (_a = this.multiProvider.tryGetChainMetadata(chain)) === null || _a === void 0 ? void 0 : _a.nativeToken) === null || _b === void 0 ? void 0 : _b.decimals) !== null && _c !== void 0 ? _c : DEFAULT_TOKEN_DECIMALS);
233
- }
234
- /**
235
- * Estimates the amount of gas used by message's recipient `handle` function
236
- * on its destination chain. This does not assume the Inbox of the destination
237
- * chain has a checkpoint that the message is included in, and does not
238
- * consider intrinsic gas or any "overhead" gas incurred by Inbox.process.
239
- * The estimated gas returned is the sum of:
240
- * 1. The estimated gas consumption of a direct call to the `handle`
241
- * function of the recipient address using the correct parameters and
242
- * setting the `from` address of the transaction to the address of the inbox.
243
- * 2. A buffer to account for inaccuracies in the above estimation.
244
- * @param message The message to estimate recipient `handle` gas usage for.
245
- * @returns The estimated gas required by the message's recipient handle function
246
- * on the destination chain.
247
- */
248
- estimateGasForHandle(message) {
249
- return __awaiter(this, void 0, void 0, function* () {
250
- const provider = this.multiProvider.getProvider(message.destination);
251
- const mailbox = this.core.getContracts(message.destination).mailbox
252
- .contract;
253
- const handlerInterface = new ethers_1.ethers.utils.Interface([
254
- 'function handle(uint32,bytes32,bytes)',
255
- ]);
256
- // Estimates a direct call to the `handle` function of the recipient
257
- // with the `from` address set to the inbox.
258
- // This includes intrinsic gas.
259
- const directHandleCallGas = yield provider.estimateGas({
260
- to: utils_1.utils.bytes32ToAddress(message.recipient),
261
- from: mailbox.address,
262
- data: handlerInterface.encodeFunctionData('handle', [
263
- this.multiProvider.getChainId(message.origin),
264
- utils_1.utils.addressToBytes32(message.sender),
265
- message.body,
266
- ]),
267
- });
268
- // Subtract intrinsic gas, which is included in directHandleCallGas.
269
- // Note the "real" intrinsic gas will always be higher than this.intrinsicGas
270
- // due to calldata costs, but this is desired because subtracting the lower bound
271
- // this.intrinsicGas will result in a more generous final estimate.
272
- return directHandleCallGas
273
- .add(this.messageGasEstimateBuffer)
274
- .sub(this.intrinsicGas());
275
- });
276
- }
277
- /**
278
- * @returns A generous estimation of the gas consumption of all process
279
- * operations within Inbox.sol, including intrinsic gas. Does not include any gas
280
- * consumed within a message's recipient `handle` function.
281
- */
282
- estimateGasForProcess(origin, destination) {
283
- return __awaiter(this, void 0, void 0, function* () {
284
- // TODO: Check the recipient module
285
- const module = this.core.getContracts(destination).multisigIsm;
286
- const threshold = yield module.threshold(this.multiProvider.getDomainId(origin));
287
- return ethers_1.BigNumber.from(threshold)
288
- .mul(GAS_OVERHEAD_PER_SIGNATURE)
289
- .add(GAS_OVERHEAD_BASE);
290
- });
291
- }
292
- /**
293
- * @returns The intrinsic gas of a basic transaction. Note this does not consider calldata
294
- * costs or potentially different intrinsic gas costs for different chains.
295
- */
296
- intrinsicGas() {
297
- return ethers_1.BigNumber.from(GAS_INTRINSIC);
298
- }
299
- }
300
- exports.InterchainGasCalculator = InterchainGasCalculator;
301
- //# sourceMappingURL=calculator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"calculator.js","sourceRoot":"","sources":["../../src/gas/calculator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kEAAsC;AACtC,mCAAwD;AAExD,8CAAsE;AACtE,gDAAoD;AAEpD,yDAAuE;AAGvE,4CAAsE;AAEtE,iDAA6E;AAE7E;;;;;;;;;;GAUG;AAEH,mFAAmF;AACnF,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC,sFAAsF;AACtF,sCAAsC;AACtC,MAAM,aAAa,GAAG,KAAM,CAAC;AAE7B,kEAAkE;AAClE,2FAA2F;AAC3F,qEAAqE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AO,mBAAmB;iBACvB,GAAG,CAAC,IAAI,CAAC,wBAAwB,CAAC;iBAClC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QAC9B,CAAC;KAAA;IAED;;;;OAIG;IACa,qBAAqB,CACnC,MAAiB,EACjB,WAAsB;;YAEtB,mCAAmC;YACnC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC;YAC/D,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,SAAS,CACtC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,CACvC,CAAC;YACF,OAAO,kBAAS,CAAC,IAAI,CAAC,SAAS,CAAC;iBAC7B,GAAG,CAAC,0BAA0B,CAAC;iBAC/B,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC5B,CAAC;KAAA;IAED;;;OAGG;IACO,YAAY;QACpB,OAAO,kBAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACvC,CAAC;CACF;AAlVD,0DAkVC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=calculator.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"calculator.test.d.ts","sourceRoot":"","sources":["../../src/gas/calculator.test.ts"],"names":[],"mappings":""}
@@ -1,197 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const chai_1 = require("chai");
16
- const ethers_1 = require("ethers");
17
- const sinon_1 = __importDefault(require("sinon"));
18
- const chains_1 = require("../consts/chains");
19
- const HyperlaneCore_1 = require("../core/HyperlaneCore");
20
- const MultiProvider_1 = require("../providers/MultiProvider");
21
- const testUtils_1 = require("../test/testUtils");
22
- const calculator_1 = require("./calculator");
23
- const HANDLE_GAS = 100000;
24
- const SUGGESTED_GAS_PRICE = 10;
25
- const INBOX_PROCESS_OVERHEAD_GAS = 100000;
26
- // Exposes protected methods so they can be stubbed.
27
- class TestInterchainGasCalculator extends calculator_1.InterchainGasCalculator {
28
- estimateGasForProcess(origin, destination) {
29
- return super.estimateGasForProcess(origin, destination);
30
- }
31
- estimateGasForHandle(message) {
32
- return super.estimateGasForHandle(message);
33
- }
34
- convertBetweenTokens(fromChain, toChain, fromAmount) {
35
- return super.convertBetweenTokens(fromChain, toChain, fromAmount);
36
- }
37
- tokenDecimals(chain) {
38
- return super.tokenDecimals(chain);
39
- }
40
- getGasPrice(chain) {
41
- return super.getGasPrice(chain);
42
- }
43
- }
44
- describe('InterchainGasCalculator', () => {
45
- const provider = new testUtils_1.MockProvider();
46
- const multiProvider = MultiProvider_1.MultiProvider.createTestMultiProvider({ provider });
47
- const core = HyperlaneCore_1.HyperlaneCore.fromEnvironment('test', multiProvider);
48
- const origin = chains_1.Chains.test1;
49
- const destination = chains_1.Chains.test2;
50
- let tokenPriceGetter;
51
- let calculator;
52
- beforeEach(() => {
53
- tokenPriceGetter = new testUtils_1.MockTokenPriceGetter();
54
- tokenPriceGetter.setTokenPrice(origin, 9.0909);
55
- tokenPriceGetter.setTokenPrice(destination, 5.5);
56
- calculator = new TestInterchainGasCalculator(multiProvider, core, {
57
- tokenPriceGetter,
58
- // A multiplier of 1 makes testing easier to reason about
59
- paymentEstimateMultiplier: '1',
60
- });
61
- });
62
- afterEach(() => {
63
- sinon_1.default.restore();
64
- provider.clearMethodResolveValues();
65
- });
66
- describe('estimatePaymentForGas', () => {
67
- it('estimates origin token payment from a specified destination gas amount', () => __awaiter(void 0, void 0, void 0, function* () {
68
- // Set destination gas price to 10 wei
69
- provider.setMethodResolveValue('getGasPrice', ethers_1.BigNumber.from(SUGGESTED_GAS_PRICE));
70
- const estimatedPayment = yield calculator.estimatePaymentForGas(origin, destination, ethers_1.BigNumber.from(HANDLE_GAS));
71
- // 100k gas * 10 gas price * ($5.5 per destination token / $9.0909 per origin token)
72
- (0, chai_1.expect)(estimatedPayment.toNumber()).to.equal(605000);
73
- }));
74
- });
75
- describe('estimatePaymentForHandleGas', () => {
76
- it('estimates origin token payment from a specified destination handle gas amount', () => __awaiter(void 0, void 0, void 0, function* () {
77
- // Set destination gas price to 10 wei
78
- provider.setMethodResolveValue('getGasPrice', ethers_1.BigNumber.from(SUGGESTED_GAS_PRICE));
79
- // Stub the inbox process overhead gas
80
- sinon_1.default
81
- .stub(calculator, 'estimateGasForProcess')
82
- .returns(Promise.resolve(ethers_1.BigNumber.from(INBOX_PROCESS_OVERHEAD_GAS)));
83
- const estimatedPayment = yield calculator.estimatePaymentForHandleGas(origin, destination, ethers_1.BigNumber.from(HANDLE_GAS));
84
- // (100_000 dest handler gas + 100_000 process overhead gas)
85
- // * 10 gas price * ($5.5 per destination token / $9.0909 per origin token)
86
- (0, chai_1.expect)(estimatedPayment.toNumber()).to.equal(1210000);
87
- }));
88
- });
89
- /*
90
- describe('estimatePaymentForMessage', () => {
91
- it('estimates origin token payment from a specified message', async () => {
92
- // Set destination gas price to 10 wei
93
- provider.setMethodResolveValue(
94
- 'getGasPrice',
95
- BigNumber.from(SUGGESTED_GAS_PRICE),
96
- );
97
- // Set the estimated handle gas
98
- sinon
99
- .stub(calculator, 'estimateGasForHandle')
100
- .returns(Promise.resolve(BigNumber.from(HANDLE_GAS)));
101
- // Stub the inbox process overhead gas
102
- sinon
103
- .stub(calculator, 'estimateGasForProcess')
104
- .returns(Promise.resolve(BigNumber.from(INBOX_PROCESS_OVERHEAD_GAS)));
105
-
106
- const zeroAddressBytes32 = utils.addressToBytes32(
107
- ethers.constants.AddressZero,
108
- );
109
- const message: ParsedMessage<TestChainNames, Chains.test2> = {
110
- origin: origin,
111
- sender: zeroAddressBytes32,
112
- destination: destination,
113
- recipient: zeroAddressBytes32,
114
- body: '0x12345678',
115
- };
116
-
117
- const estimatedPayment = await calculator.estimatePaymentForMessage(
118
- message,
119
- );
120
-
121
- // (100_000 dest handler gas + 100_000 process overhead gas)
122
- // * 10 gas price * ($5.5 per destination token / $9.0909 per origin token)
123
- expect(estimatedPayment.toNumber()).to.equal(1_210_000);
124
- });
125
- });
126
- */
127
- describe('convertBetweenTokens', () => {
128
- const destinationWei = ethers_1.BigNumber.from('1000');
129
- it('converts using the USD value of origin and destination native tokens', () => __awaiter(void 0, void 0, void 0, function* () {
130
- const originWei = yield calculator.convertBetweenTokens(destination, origin, destinationWei);
131
- // 1000 * (5.5 / 9.0909)
132
- (0, chai_1.expect)(originWei.toNumber()).to.equal(605);
133
- }));
134
- it('considers when the origin token decimals > the destination token decimals', () => __awaiter(void 0, void 0, void 0, function* () {
135
- calculator.tokenDecimals = (chain) => {
136
- if (chain === origin) {
137
- return 20;
138
- }
139
- return 18;
140
- };
141
- const originWei = yield calculator.convertBetweenTokens(destination, origin, destinationWei);
142
- // 1000 * (5.5 / 9.0909) * 100
143
- (0, chai_1.expect)(originWei.toNumber()).to.equal(60500);
144
- }));
145
- it('considers when the origin token decimals < the destination token decimals', () => __awaiter(void 0, void 0, void 0, function* () {
146
- sinon_1.default.stub(calculator, 'tokenDecimals').callsFake((chain) => {
147
- if (chain === origin) {
148
- return 16;
149
- }
150
- return 18;
151
- });
152
- const originWei = yield calculator.convertBetweenTokens(destination, origin, destinationWei);
153
- // 1000 * (5.5 / 9.0909) / 100
154
- (0, chai_1.expect)(originWei.toNumber()).to.equal(6);
155
- }));
156
- });
157
- describe('getGasPrice', () => {
158
- it('gets the gas price from the provider', () => __awaiter(void 0, void 0, void 0, function* () {
159
- provider.setMethodResolveValue('getGasPrice', ethers_1.BigNumber.from(SUGGESTED_GAS_PRICE));
160
- (0, chai_1.expect)((yield calculator.getGasPrice(destination)).toNumber()).to.equal(SUGGESTED_GAS_PRICE);
161
- }));
162
- });
163
- describe('estimateGasForProcess', () => {
164
- let threshold;
165
- // Mock the return value of MultisigIsm.threshold
166
- // to return `threshold`. Because the mocking involves a closure,
167
- // changing `threshold` will change the return value of MultisigIsm.threshold.
168
- before(() => {
169
- const getContractsStub = sinon_1.default.stub(core, 'getContracts');
170
- let thresholdStub;
171
- getContractsStub.callsFake((chain) => {
172
- // Get the "real" return value of getContracts.
173
- const contracts = getContractsStub.wrappedMethod.bind(core)(chain);
174
- // Ethers contracts are frozen using Object.freeze, so we make a copy
175
- // of the object so we can stub `threshold`.
176
- const multisigIsm = Object.assign({}, contracts.multisigIsm);
177
- // Because we are stubbing vaidatorManager.threshold when core.getContracts gets called,
178
- // we must ensure we don't try to stub more than once or sinon will complain.
179
- if (!thresholdStub) {
180
- thresholdStub = sinon_1.default
181
- .stub(multisigIsm, 'threshold')
182
- .callsFake(() => Promise.resolve(threshold));
183
- contracts.multisigIsm = multisigIsm;
184
- }
185
- return contracts;
186
- });
187
- });
188
- it('scales the gas cost with the quorum threshold', () => __awaiter(void 0, void 0, void 0, function* () {
189
- threshold = 2;
190
- const gasWithThresholdLow = yield calculator.estimateGasForProcess(origin, destination);
191
- threshold = 3;
192
- const gasWithThresholdHigh = yield calculator.estimateGasForProcess(origin, destination);
193
- (0, chai_1.expect)(gasWithThresholdHigh.gt(gasWithThresholdLow)).to.be.true;
194
- }));
195
- });
196
- });
197
- //# sourceMappingURL=calculator.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"calculator.test.js","sourceRoot":"","sources":["../../src/gas/calculator.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,mCAAmC;AACnC,kDAA0B;AAE1B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oot":"","sources":["../../src/middleware/accounts.hardhat-test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"accounts.hardhat-test.js","sourceRoot":"","sources":["../../src/middleware/accounts.hardhat-test.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,+BAA8B;AAC9B,qCAAiC;AAEjC,8CAG6B;AAC7B,gDAA6C;AAE7C,6CAA0C;AAC1C,qDAAkD;AAClD,+DAA4D;AAC5D,8DAA2D;AAE3D,iDAAuD;AAEvD,8CAAyD;AAEzD,qCAGkB;AAElB,QAAQ,CAAC,yBAAyB,EAAE,GAAS,EAAE;IAC7C,MAAM,UAAU,GAAG,eAAM,CAAC,KAAK,CAAC;IAChC,MAAM,WAAW,GAAG,eAAM,CAAC,KAAK,CAAC;IAEjC,IAAI,MAAyB,CAAC;IAC9B,IAAI,SAA+C,CAAC;IACpD,IAAI,KAA8B,CAAC;IACnC,IAAI,MAA+B,CAAC;IACpC,IAAI,aAA4B,CAAC;IACjC,IAAI,OAAoB,CAAC;IACzB,IAAI,MAA8B,CAAC;IAEnC,MAAM,CAAC,GAAS,EAAE;QAChB,CAAC,MAAM,CAAC,GAAG,MAAM,gBAAM,CAAC,UAAU,EAAE,CAAC;QAErC,aAAa,GAAG,6BAAa,CAAC,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAElE,MAAM,YAAY,GAAG,IAAI,mCAAgB,CAAC,aAAa,CAAC,CAAC;QACzD,MAAM,iBAAiB,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,CAAC;QACtD,OAAO,GAAG,IAAI,yBAAW,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;QAC5D,MAAM,GAAG,OAAO,CAAC,gCAAgC,CAC/C,IAAA,8BAAkB,EAAC,MAAM,CAAC,OAAO,CAAC,CACnC,CAAC;QAEF,MAAM,CAAC,KAAK,CAAC,wBAAwB;YACnC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC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Aa,CAAC,WAAW,CAAC,UAAU,CAAC,EACrC,MAAM,CAAC,OAAO,CACf,CAAC;QAEF,MAAM,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE;YAC3D;gBACE,KAAK,EAAE,EAAE,EAAE,EAAE,aAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE;gBAC9D,KAAK,EAAE,CAAC;aACT;SACF,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;QAChC,IAAA,aAAM,EAAC,MAAM,SAAS,CAAC,eAAe,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC7D,IAAA,aAAM,EAAC,MAAM,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1D,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAA,CAAC,CAAC"}
@@ -1,28 +0,0 @@
1
- import { InterchainAccountRouter, InterchainQueryRouter } from '@hyperlane-xyz/core';
2
- import { MultiProvider } from '../providers/MultiProvider';
3
- import { HyperlaneRouterDeployer } from '../router/HyperlaneRouterDeployer';
4
- import { ProxiedRouterContracts, RouterConfig, RouterFactories } from '../router/types';
5
- import { ChainMap, ChainName } from '../types';
6
- export declare type InterchainAccountFactories = RouterFactories<InterchainAccountRouter>;
7
- export declare const interchainAccountFactories: InterchainAccountFactories;
8
- export declare type InterchainAccountContracts = ProxiedRouterContracts<InterchainAccountRouter>;
9
- export declare type InterchainQueryFactories = RouterFactories<InterchainQueryRouter>;
10
- export declare const interchainQueryFactories: InterchainQueryFactories;
11
- export declare type InterchainQueryContracts = ProxiedRouterContracts<InterchainQueryRouter>;
12
- export declare abstract class MiddlewareRouterDeployer<MiddlewareRouterConfig extends RouterConfig, MiddlewareRouterContracts extends ProxiedRouterContracts, MiddlewareFactories extends RouterFactories> extends HyperlaneRouterDeployer<MiddlewareRouterConfig, MiddlewareRouterContracts, MiddlewareFactories> {
13
- protected create2salt: string;
14
- constructor(multiProvider: MultiProvider, configMap: ChainMap<MiddlewareRouterConfig>, factories: MiddlewareFactories, create2salt?: string);
15
- constructorArgs(_: MiddlewareRouterConfig): Parameters<MiddlewareFactories['router']['deploy']>;
16
- initializeArgs(config: MiddlewareRouterConfig): any;
17
- deployContracts(chain: ChainName, config: MiddlewareRouterConfig): Promise<MiddlewareRouterContracts>;
18
- }
19
- declare type InterchainAccountConfig = RouterConfig;
20
- export declare class InterchainAccountDeployer extends MiddlewareRouterDeployer<InterchainAccountConfig, InterchainAccountContracts, InterchainAccountFactories> {
21
- constructor(multiProvider: MultiProvider, configMap: ChainMap<InterchainAccountConfig>, create2salt?: string);
22
- }
23
- declare type InterchainQueryConfig = RouterConfig;
24
- export declare class InterchainQueryDeployer extends MiddlewareRouterDeployer<InterchainQueryConfig, InterchainQueryContracts, InterchainQueryFactories> {
25
- constructor(multiProvider: MultiProvider, configMap: ChainMap<InterchainQueryConfig>, create2salt?: string);
26
- }
27
- export {};
28
- //# sourceMappingURL=deploy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/middleware/deploy.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,uBAAuB,EAEvB,qBAAqB,EAEtB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,eAAe,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE/C,oBAAY,0BAA0B,GACpC,eAAe,CAAC,uBAAuB,CAAC,CAAC;AAE3C,eAAO,MAAM,0BAA0B,EAAE,0BAExC,CAAC;AAEF,o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AqB,CAAC,EAC1C,WAAW,SAAgB;CAI9B"}
@@ -1,68 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.InterchainQueryDeployer = exports.InterchainAccountDeployer = exports.MiddlewareRouterDeployer = exports.interchainQueryFactories = exports.interchainAccountFactories = void 0;
13
- const ethers_1 = require("ethers");
14
- const core_1 = require("@hyperlane-xyz/core");
15
- const core_2 = require("@hyperlane-xyz/core");
16
- const HyperlaneRouterDeployer_1 = require("../router/HyperlaneRouterDeployer");
17
- exports.interchainAccountFactories = {
18
- router: new core_2.InterchainAccountRouter__factory(),
19
- };
20
- exports.interchainQueryFactories = {
21
- router: new core_2.InterchainQueryRouter__factory(),
22
- };
23
- class MiddlewareRouterDeployer extends HyperlaneRouterDeployer_1.HyperlaneRouterDeployer {
24
- constructor(multiProvider, configMap, factories, create2salt = 'middlewarerouter') {
25
- super(multiProvider, configMap, factories);
26
- this.create2salt = create2salt;
27
- }
28
- constructorArgs(_) {
29
- return [];
30
- }
31
- initializeArgs(config) {
32
- var _a;
33
- return [
34
- config.mailbox,
35
- config.interchainGasPaymaster,
36
- (_a = config.interchainSecurityModule) !== null && _a !== void 0 ? _a : ethers_1.ethers.constants.AddressZero,
37
- config.owner,
38
- ];
39
- }
40
- deployContracts(chain, config) {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- const proxyAdmin = yield this.deployContractFromFactory(chain, new core_1.ProxyAdmin__factory(), 'proxyAdmin', [], { create2Salt: this.create2salt });
43
- const proxiedRouter = yield this.deployProxiedContract(chain, 'router', this.constructorArgs(config), proxyAdmin, this.initializeArgs(config), {
44
- create2Salt: this.create2salt,
45
- });
46
- yield this.multiProvider.handleTx(chain, proxyAdmin.transferOwnership(config.owner));
47
- return {
48
- proxyAdmin,
49
- proxiedRouter,
50
- router: proxiedRouter.contract, // for backwards compatibility
51
- };
52
- });
53
- }
54
- }
55
- exports.MiddlewareRouterDeployer = MiddlewareRouterDeployer;
56
- class InterchainAccountDeployer extends MiddlewareRouterDeployer {
57
- constructor(multiProvider, configMap, create2salt = 'accountsrouter') {
58
- super(multiProvider, configMap, exports.interchainAccountFactories, create2salt);
59
- }
60
- }
61
- exports.InterchainAccountDeployer = InterchainAccountDeployer;
62
- class InterchainQueryDeployer extends MiddlewareRouterDeployer {
63
- constructor(multiProvider, configMap, create2salt = 'queryrouter') {
64
- super(multiProvider, configMap, exports.interchainQueryFactories, create2salt);
65
- }
66
- }
67
- exports.InterchainQueryDeployer = InterchainQueryDeployer;
68
- //# sourceMappingURL=deploy.js.map