@argonprotocol/testing 1.5.2-dev.9c5eb2c8 → 1.5.2-dev.cdfb6ab4

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/lib/index.cjs CHANGED
@@ -1309,7 +1309,7 @@ async function waitForExecutionReceipt2(ethereum, transactionHash) {
1309
1309
  [transactionHash]
1310
1310
  );
1311
1311
  if (receipt) {
1312
- return receipt;
1312
+ return (0, import_viem2.formatTransactionReceipt)(receipt);
1313
1313
  }
1314
1314
  } catch (error) {
1315
1315
  const errorText = error instanceof Error ? [
@@ -1707,7 +1707,6 @@ var EthereumProofE2eHarness = class _EthereumProofE2eHarness {
1707
1707
  }
1708
1708
  });
1709
1709
  this.publicClient = (0, import_viem4.createPublicClient)({
1710
- chain: this.chain,
1711
1710
  transport: (0, import_viem4.http)(endpoints.executionRpcUrl)
1712
1711
  });
1713
1712
  this.walletClient = (0, import_viem4.createWalletClient)({
@@ -1773,24 +1772,54 @@ var EthereumProofE2eHarness = class _EthereumProofE2eHarness {
1773
1772
  minimumExecutionBlockNumber
1774
1773
  );
1775
1774
  }
1776
- async proveGatewayActivity(gatewayAddress, throughExecutionBlockNumber) {
1777
- const payload = await (0, import_mainchain8.buildGatewayActivityProofPayload)(this.mainchainClient, {
1775
+ async proveGatewayActivities(gatewayAddress, throughExecutionBlockNumber) {
1776
+ const argonFinalizedExecutionHeader = await (0, import_mainchain8.getLatestArgonFinalizedExecutionHeader)(
1777
+ this.mainchainClient
1778
+ );
1779
+ const currentGatewayState = await this.mainchainClient.query.crosschainTransfer.gatewayStateBySourceChain("Ethereum");
1780
+ const minimumGatewayActivityNonce = currentGatewayState.isSome ? currentGatewayState.unwrap().gatewayActivityNonce.toBigInt() + 1n : 1n;
1781
+ const collectedLocators = await (0, import_mainchain8.discoverMissingGatewayActivityLocators)({
1782
+ finalizedExecutionBlockNumber: argonFinalizedExecutionHeader.blockNumber,
1778
1783
  executionRpcUrl: this.endpoints.executionRpcUrl,
1779
1784
  gatewayAddress,
1780
- throughExecutionBlockNumber
1785
+ minimumGatewayActivityNonce
1781
1786
  });
1782
- if (!payload) {
1787
+ const locators = collectedLocators.filter(
1788
+ (locator) => locator.blockNumber <= throughExecutionBlockNumber
1789
+ );
1790
+ if (locators.length === 0) {
1783
1791
  throw new Error("Expected uncovered gateway activity to prove");
1784
1792
  }
1785
- const result = await this.submit(
1786
- this.mainchainClient.tx.crosschainTransfer.proveGatewayActivity(
1787
- "Ethereum",
1788
- payload.previousGatewayActivityNonce,
1789
- payload.proof
1790
- ),
1791
- this.proofRelayer
1792
- );
1793
- return { payload, result };
1793
+ const executionBlock = await this.publicClient.getBlock({
1794
+ blockNumber: argonFinalizedExecutionHeader.blockNumber
1795
+ });
1796
+ const captures = await (0, import_mainchain8.captureGatewayActivityStorageProofs)({
1797
+ executionRpcUrl: this.endpoints.executionRpcUrl,
1798
+ executionBlock,
1799
+ gatewayAddress,
1800
+ locators
1801
+ });
1802
+ const { payloads } = await (0, import_mainchain8.buildGatewayActivityStorageProofs)(this.mainchainClient, {
1803
+ executionRpcUrl: this.endpoints.executionRpcUrl,
1804
+ gatewayAddress,
1805
+ locators: captures
1806
+ });
1807
+ if (payloads.length === 0) {
1808
+ throw new Error("Expected uncovered gateway activity to prove");
1809
+ }
1810
+ const results = [];
1811
+ for (const payload of payloads) {
1812
+ const result = await this.submit(
1813
+ this.mainchainClient.tx.crosschainTransfer.proveGatewayActivityStorage(
1814
+ "Ethereum",
1815
+ payload.previousGatewayActivityNonce,
1816
+ payload.proof
1817
+ ),
1818
+ this.proofRelayer
1819
+ );
1820
+ results.push(result);
1821
+ }
1822
+ return { payloads, results };
1794
1823
  }
1795
1824
  async configureEthereumRuntime(gateway, mode) {
1796
1825
  const calls = [
@@ -1907,6 +1936,24 @@ var TestMintingGateway = class _TestMintingGateway {
1907
1936
  nonce: permitNonce,
1908
1937
  deadline: permitDeadline
1909
1938
  });
1939
+ const data = (0, import_viem4.encodeFunctionData)({
1940
+ abi: mintingGatewayAbi2,
1941
+ functionName: "startTransferToArgon",
1942
+ args: [
1943
+ this.argonTokenAddress,
1944
+ args.amountRuntimeUnits,
1945
+ args.recipientArgonAddress,
1946
+ permitDeadline,
1947
+ permitSignature.v,
1948
+ permitSignature.r,
1949
+ permitSignature.s
1950
+ ]
1951
+ });
1952
+ const estimatedGas = await this.harness.publicClient.estimateGas({
1953
+ account: args.account,
1954
+ to: this.gatewayAddress,
1955
+ data
1956
+ });
1910
1957
  const transactionHash = await (0, import_viem4.createWalletClient)({
1911
1958
  account: args.account,
1912
1959
  chain: this.harness.chain,
@@ -1915,25 +1962,20 @@ var TestMintingGateway = class _TestMintingGateway {
1915
1962
  account: args.account,
1916
1963
  chain: this.harness.chain,
1917
1964
  to: this.gatewayAddress,
1918
- data: (0, import_viem4.encodeFunctionData)({
1919
- abi: mintingGatewayAbi2,
1920
- functionName: "startTransferToArgon",
1921
- args: [
1922
- this.argonTokenAddress,
1923
- args.amountRuntimeUnits,
1924
- args.recipientArgonAddress,
1925
- permitDeadline,
1926
- permitSignature.v,
1927
- permitSignature.r,
1928
- permitSignature.s
1929
- ]
1930
- })
1965
+ data,
1966
+ // Estimation may append to this block's locator; mining in a new block creates storage slots.
1967
+ gas: estimatedGas * 2n
1931
1968
  });
1932
- return waitForExecutionReceipt2(this.harness.ethereum, transactionHash);
1969
+ const receipt = await waitForExecutionReceipt2(this.harness.ethereum, transactionHash);
1970
+ if (receipt.status !== "success") {
1971
+ throw new Error(`Transfer to Argon reverted: ${transactionHash}`);
1972
+ }
1973
+ return receipt;
1933
1974
  }
1934
1975
  async forceUpdateActiveCouncil(replacementCouncil, nextMicrogonsPerArgonot) {
1935
- return this.harness.publicClient.waitForTransactionReceipt({
1936
- hash: await this.harness.walletClient.writeContract({
1976
+ return waitForExecutionReceipt2(
1977
+ this.harness.ethereum,
1978
+ await this.harness.walletClient.writeContract({
1937
1979
  account: this.harness.deployer,
1938
1980
  chain: this.harness.chain,
1939
1981
  address: this.gatewayAddress,
@@ -1941,11 +1983,12 @@ var TestMintingGateway = class _TestMintingGateway {
1941
1983
  functionName: "forceUpdateActiveCouncil",
1942
1984
  args: [replacementCouncil, nextMicrogonsPerArgonot]
1943
1985
  })
1944
- });
1986
+ );
1945
1987
  }
1946
1988
  async relayReadyApprovals(batch, operatorAddress) {
1947
- return this.harness.publicClient.waitForTransactionReceipt({
1948
- hash: await this.harness.walletClient.writeContract({
1989
+ return waitForExecutionReceipt2(
1990
+ this.harness.ethereum,
1991
+ await this.harness.walletClient.writeContract({
1949
1992
  account: this.harness.deployer,
1950
1993
  chain: this.harness.chain,
1951
1994
  address: this.gatewayAddress,
@@ -1957,17 +2000,17 @@ var TestMintingGateway = class _TestMintingGateway {
1957
2000
  (0, import_viem4.toHex)((0, import_mainchain8.decodeAddress)(operatorAddress), { size: 32 })
1958
2001
  ]
1959
2002
  })
1960
- });
2003
+ );
1961
2004
  }
1962
2005
  async argonApprovalsNonce() {
1963
- return await this.harness.publicClient.readContract({
2006
+ return this.harness.publicClient.readContract({
1964
2007
  address: this.gatewayAddress,
1965
2008
  abi: mintingGatewayAbi2,
1966
2009
  functionName: "argonApprovalsNonce"
1967
2010
  });
1968
2011
  }
1969
2012
  async globalIssuanceCouncil() {
1970
- return await this.harness.publicClient.readContract({
2013
+ return this.harness.publicClient.readContract({
1971
2014
  address: this.gatewayAddress,
1972
2015
  abi: mintingGatewayAbi2,
1973
2016
  functionName: "globalIssuanceCouncil"
@@ -1982,8 +2025,9 @@ var TestMintingGateway = class _TestMintingGateway {
1982
2025
  });
1983
2026
  }
1984
2027
  async finalizeTransferOut(args) {
1985
- return this.harness.publicClient.waitForTransactionReceipt({
1986
- hash: await this.harness.walletClient.writeContract({
2028
+ return waitForExecutionReceipt2(
2029
+ this.harness.ethereum,
2030
+ await this.harness.walletClient.writeContract({
1987
2031
  account: this.harness.deployer,
1988
2032
  chain: this.harness.chain,
1989
2033
  address: this.gatewayAddress,
@@ -2002,10 +2046,10 @@ var TestMintingGateway = class _TestMintingGateway {
2002
2046
  }
2003
2047
  ]
2004
2048
  })
2005
- });
2049
+ );
2006
2050
  }
2007
2051
  async isFinalizedTransferOut(transferRequest) {
2008
- return await this.harness.publicClient.readContract({
2052
+ return this.harness.publicClient.readContract({
2009
2053
  address: this.gatewayAddress,
2010
2054
  abi: mintingGatewayAbi2,
2011
2055
  functionName: "finalizedTransferOutOfArgonIds",
@@ -2013,7 +2057,7 @@ var TestMintingGateway = class _TestMintingGateway {
2013
2057
  });
2014
2058
  }
2015
2059
  async argonBalance(address) {
2016
- return await this.harness.publicClient.readContract({
2060
+ return this.harness.publicClient.readContract({
2017
2061
  address: this.argonTokenAddress,
2018
2062
  abi: argonTokenAbi,
2019
2063
  functionName: "balanceOf",
@@ -2021,14 +2065,15 @@ var TestMintingGateway = class _TestMintingGateway {
2021
2065
  });
2022
2066
  }
2023
2067
  async fundExecutionAccount(address, value) {
2024
- return this.harness.publicClient.waitForTransactionReceipt({
2025
- hash: await this.harness.walletClient.sendTransaction({
2068
+ return waitForExecutionReceipt2(
2069
+ this.harness.ethereum,
2070
+ await this.harness.walletClient.sendTransaction({
2026
2071
  account: this.harness.deployer,
2027
2072
  chain: this.harness.chain,
2028
2073
  to: address,
2029
2074
  value
2030
2075
  })
2031
- });
2076
+ );
2032
2077
  }
2033
2078
  };
2034
2079
  var TestMintingAuthorityActor = class {