@mantleio/viem 0.0.1-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/LICENSE.md +21 -0
- package/README.md +54 -0
- package/dist/cjs/abis.js +3338 -0
- package/dist/cjs/abis.js.map +1 -0
- package/dist/cjs/actions/buildProveWithdrawal.js +55 -0
- package/dist/cjs/actions/buildProveWithdrawal.js.map +1 -0
- package/dist/cjs/actions/depositERC20.js +37 -0
- package/dist/cjs/actions/depositERC20.js.map +1 -0
- package/dist/cjs/actions/depositETH.js +36 -0
- package/dist/cjs/actions/depositETH.js.map +1 -0
- package/dist/cjs/actions/depositMNT.js +35 -0
- package/dist/cjs/actions/depositMNT.js.map +1 -0
- package/dist/cjs/actions/estimateDepositERC20Gas.js +38 -0
- package/dist/cjs/actions/estimateDepositERC20Gas.js.map +1 -0
- package/dist/cjs/actions/estimateDepositETHGas.js +37 -0
- package/dist/cjs/actions/estimateDepositETHGas.js.map +1 -0
- package/dist/cjs/actions/estimateDepositMNTGas.js +36 -0
- package/dist/cjs/actions/estimateDepositMNTGas.js.map +1 -0
- package/dist/cjs/actions/estimateFinalizeWithdrawalGas.js +29 -0
- package/dist/cjs/actions/estimateFinalizeWithdrawalGas.js.map +1 -0
- package/dist/cjs/actions/estimateInitiateERC20WithdrawalGas.js +30 -0
- package/dist/cjs/actions/estimateInitiateERC20WithdrawalGas.js.map +1 -0
- package/dist/cjs/actions/estimateInitiateETHWithdrawalGas.js +29 -0
- package/dist/cjs/actions/estimateInitiateETHWithdrawalGas.js.map +1 -0
- package/dist/cjs/actions/estimateInitiateMNTWithdrawalGas.js +30 -0
- package/dist/cjs/actions/estimateInitiateMNTWithdrawalGas.js.map +1 -0
- package/dist/cjs/actions/estimateProveWithdrawalGas.js +29 -0
- package/dist/cjs/actions/estimateProveWithdrawalGas.js.map +1 -0
- package/dist/cjs/actions/finalizeWithdrawal.js +28 -0
- package/dist/cjs/actions/finalizeWithdrawal.js.map +1 -0
- package/dist/cjs/actions/getL2Output.js +31 -0
- package/dist/cjs/actions/getL2Output.js.map +1 -0
- package/dist/cjs/actions/getPortalVersion.js +24 -0
- package/dist/cjs/actions/getPortalVersion.js.map +1 -0
- package/dist/cjs/actions/getTimeToFinalize.js +46 -0
- package/dist/cjs/actions/getTimeToFinalize.js.map +1 -0
- package/dist/cjs/actions/getTimeToNextL2Output.js +62 -0
- package/dist/cjs/actions/getTimeToNextL2Output.js.map +1 -0
- package/dist/cjs/actions/getTimeToProve.js +12 -0
- package/dist/cjs/actions/getTimeToProve.js.map +1 -0
- package/dist/cjs/actions/getWithdrawalStatus.js +133 -0
- package/dist/cjs/actions/getWithdrawalStatus.js.map +1 -0
- package/dist/cjs/actions/initiateERC20Withdrawal.js +29 -0
- package/dist/cjs/actions/initiateERC20Withdrawal.js.map +1 -0
- package/dist/cjs/actions/initiateETHWithdrawal.js +28 -0
- package/dist/cjs/actions/initiateETHWithdrawal.js.map +1 -0
- package/dist/cjs/actions/initiateMNTWithdrawal.js +29 -0
- package/dist/cjs/actions/initiateMNTWithdrawal.js.map +1 -0
- package/dist/cjs/actions/proveWithdrawal.js +28 -0
- package/dist/cjs/actions/proveWithdrawal.js.map +1 -0
- package/dist/cjs/actions/waitForNextL2Output.js +31 -0
- package/dist/cjs/actions/waitForNextL2Output.js.map +1 -0
- package/dist/cjs/actions/waitToFinalize.js +10 -0
- package/dist/cjs/actions/waitToFinalize.js.map +1 -0
- package/dist/cjs/actions/waitToProve.js +24 -0
- package/dist/cjs/actions/waitToProve.js.map +1 -0
- package/dist/cjs/chainConfig.js +12 -0
- package/dist/cjs/chainConfig.js.map +1 -0
- package/dist/cjs/chains/index.js +8 -0
- package/dist/cjs/chains/index.js.map +1 -0
- package/dist/cjs/chains/mantle.js +53 -0
- package/dist/cjs/chains/mantle.js.map +1 -0
- package/dist/cjs/chains/mantleSepoliaTestnet.js +54 -0
- package/dist/cjs/chains/mantleSepoliaTestnet.js.map +1 -0
- package/dist/cjs/contracts.js +16 -0
- package/dist/cjs/contracts.js.map +1 -0
- package/dist/cjs/decorators/publicL1.js +38 -0
- package/dist/cjs/decorators/publicL1.js.map +1 -0
- package/dist/cjs/decorators/publicL2.js +18 -0
- package/dist/cjs/decorators/publicL2.js.map +1 -0
- package/dist/cjs/decorators/walletL1.js +20 -0
- package/dist/cjs/decorators/walletL1.js.map +1 -0
- package/dist/cjs/decorators/walletL2.js +16 -0
- package/dist/cjs/decorators/walletL2.js.map +1 -0
- package/dist/cjs/errors/utils.js +3 -0
- package/dist/cjs/errors/utils.js.map +1 -0
- package/dist/cjs/errors/withdrawal.js +17 -0
- package/dist/cjs/errors/withdrawal.js.map +1 -0
- package/dist/cjs/formatters.js +51 -0
- package/dist/cjs/formatters.js.map +1 -0
- package/dist/cjs/index.js +59 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/parsers.js +58 -0
- package/dist/cjs/parsers.js.map +1 -0
- package/dist/cjs/serializers.js +53 -0
- package/dist/cjs/serializers.js.map +1 -0
- package/dist/cjs/types/account.js +3 -0
- package/dist/cjs/types/account.js.map +1 -0
- package/dist/cjs/types/block.js +3 -0
- package/dist/cjs/types/block.js.map +1 -0
- package/dist/cjs/types/chain.js +3 -0
- package/dist/cjs/types/chain.js.map +1 -0
- package/dist/cjs/types/contract.js +3 -0
- package/dist/cjs/types/contract.js.map +1 -0
- package/dist/cjs/types/deposit.js +3 -0
- package/dist/cjs/types/deposit.js.map +1 -0
- package/dist/cjs/types/l1Actions.js +8 -0
- package/dist/cjs/types/l1Actions.js.map +1 -0
- package/dist/cjs/types/l2Actions.js +11 -0
- package/dist/cjs/types/l2Actions.js.map +1 -0
- package/dist/cjs/types/transaction.js +3 -0
- package/dist/cjs/types/transaction.js.map +1 -0
- package/dist/cjs/types/withdrawal.js +3 -0
- package/dist/cjs/types/withdrawal.js.map +1 -0
- package/dist/cjs/utils/extractTransactionDepositedLogs.js +13 -0
- package/dist/cjs/utils/extractTransactionDepositedLogs.js.map +1 -0
- package/dist/cjs/utils/extractWithdrawalMessageLogs.js +13 -0
- package/dist/cjs/utils/extractWithdrawalMessageLogs.js.map +1 -0
- package/dist/cjs/utils/getL2TransactionHash.js +29 -0
- package/dist/cjs/utils/getL2TransactionHash.js.map +1 -0
- package/dist/cjs/utils/getL2TransactionHashes.js +10 -0
- package/dist/cjs/utils/getL2TransactionHashes.js.map +1 -0
- package/dist/cjs/utils/getSourceHash.js +17 -0
- package/dist/cjs/utils/getSourceHash.js.map +1 -0
- package/dist/cjs/utils/getWithdrawalHashStorageSlot.js +9 -0
- package/dist/cjs/utils/getWithdrawalHashStorageSlot.js.map +1 -0
- package/dist/cjs/utils/getWithdrawals.js +9 -0
- package/dist/cjs/utils/getWithdrawals.js.map +1 -0
- package/dist/cjs/utils/opaqueDataToDepositData.js +32 -0
- package/dist/cjs/utils/opaqueDataToDepositData.js.map +1 -0
- package/dist/cjs/utils/parseDepositRequest.js +43 -0
- package/dist/cjs/utils/parseDepositRequest.js.map +1 -0
- package/dist/cjs/utils/parseInitWithdrawRequest.js +55 -0
- package/dist/cjs/utils/parseInitWithdrawRequest.js.map +1 -0
- package/dist/cjs/utils/poll.js +26 -0
- package/dist/cjs/utils/poll.js.map +1 -0
- package/dist/cjs/utils/promise/withCache.js +47 -0
- package/dist/cjs/utils/promise/withCache.js.map +1 -0
- package/dist/cjs/utils/wait.js +7 -0
- package/dist/cjs/utils/wait.js.map +1 -0
- package/dist/esm/abis.js +3335 -0
- package/dist/esm/abis.js.map +1 -0
- package/dist/esm/actions/buildProveWithdrawal.js +67 -0
- package/dist/esm/actions/buildProveWithdrawal.js.map +1 -0
- package/dist/esm/actions/depositERC20.js +39 -0
- package/dist/esm/actions/depositERC20.js.map +1 -0
- package/dist/esm/actions/depositETH.js +38 -0
- package/dist/esm/actions/depositETH.js.map +1 -0
- package/dist/esm/actions/depositMNT.js +37 -0
- package/dist/esm/actions/depositMNT.js.map +1 -0
- package/dist/esm/actions/estimateDepositERC20Gas.js +43 -0
- package/dist/esm/actions/estimateDepositERC20Gas.js.map +1 -0
- package/dist/esm/actions/estimateDepositETHGas.js +43 -0
- package/dist/esm/actions/estimateDepositETHGas.js.map +1 -0
- package/dist/esm/actions/estimateDepositMNTGas.js +41 -0
- package/dist/esm/actions/estimateDepositMNTGas.js.map +1 -0
- package/dist/esm/actions/estimateFinalizeWithdrawalGas.js +34 -0
- package/dist/esm/actions/estimateFinalizeWithdrawalGas.js.map +1 -0
- package/dist/esm/actions/estimateInitiateERC20WithdrawalGas.js +35 -0
- package/dist/esm/actions/estimateInitiateERC20WithdrawalGas.js.map +1 -0
- package/dist/esm/actions/estimateInitiateETHWithdrawalGas.js +34 -0
- package/dist/esm/actions/estimateInitiateETHWithdrawalGas.js.map +1 -0
- package/dist/esm/actions/estimateInitiateMNTWithdrawalGas.js +35 -0
- package/dist/esm/actions/estimateInitiateMNTWithdrawalGas.js.map +1 -0
- package/dist/esm/actions/estimateProveWithdrawalGas.js +34 -0
- package/dist/esm/actions/estimateProveWithdrawalGas.js.map +1 -0
- package/dist/esm/actions/finalizeWithdrawal.js +30 -0
- package/dist/esm/actions/finalizeWithdrawal.js.map +1 -0
- package/dist/esm/actions/getL2Output.js +33 -0
- package/dist/esm/actions/getL2Output.js.map +1 -0
- package/dist/esm/actions/getPortalVersion.js +26 -0
- package/dist/esm/actions/getPortalVersion.js.map +1 -0
- package/dist/esm/actions/getTimeToFinalize.js +48 -0
- package/dist/esm/actions/getTimeToFinalize.js.map +1 -0
- package/dist/esm/actions/getTimeToNextL2Output.js +68 -0
- package/dist/esm/actions/getTimeToNextL2Output.js.map +1 -0
- package/dist/esm/actions/getTimeToProve.js +14 -0
- package/dist/esm/actions/getTimeToProve.js.map +1 -0
- package/dist/esm/actions/getWithdrawalStatus.js +138 -0
- package/dist/esm/actions/getWithdrawalStatus.js.map +1 -0
- package/dist/esm/actions/initiateERC20Withdrawal.js +31 -0
- package/dist/esm/actions/initiateERC20Withdrawal.js.map +1 -0
- package/dist/esm/actions/initiateETHWithdrawal.js +30 -0
- package/dist/esm/actions/initiateETHWithdrawal.js.map +1 -0
- package/dist/esm/actions/initiateMNTWithdrawal.js +31 -0
- package/dist/esm/actions/initiateMNTWithdrawal.js.map +1 -0
- package/dist/esm/actions/proveWithdrawal.js +30 -0
- package/dist/esm/actions/proveWithdrawal.js.map +1 -0
- package/dist/esm/actions/waitForNextL2Output.js +33 -0
- package/dist/esm/actions/waitForNextL2Output.js.map +1 -0
- package/dist/esm/actions/waitToFinalize.js +11 -0
- package/dist/esm/actions/waitToFinalize.js.map +1 -0
- package/dist/esm/actions/waitToProve.js +26 -0
- package/dist/esm/actions/waitToProve.js.map +1 -0
- package/dist/esm/chainConfig.js +9 -0
- package/dist/esm/chainConfig.js.map +1 -0
- package/dist/esm/chains/index.js +3 -0
- package/dist/esm/chains/index.js.map +1 -0
- package/dist/esm/chains/mantle.js +50 -0
- package/dist/esm/chains/mantle.js.map +1 -0
- package/dist/esm/chains/mantleSepoliaTestnet.js +51 -0
- package/dist/esm/chains/mantleSepoliaTestnet.js.map +1 -0
- package/dist/esm/contracts.js +13 -0
- package/dist/esm/contracts.js.map +1 -0
- package/dist/esm/decorators/publicL1.js +35 -0
- package/dist/esm/decorators/publicL1.js.map +1 -0
- package/dist/esm/decorators/publicL2.js +15 -0
- package/dist/esm/decorators/publicL2.js.map +1 -0
- package/dist/esm/decorators/walletL1.js +17 -0
- package/dist/esm/decorators/walletL1.js.map +1 -0
- package/dist/esm/decorators/walletL2.js +13 -0
- package/dist/esm/decorators/walletL2.js.map +1 -0
- package/dist/esm/errors/utils.js +2 -0
- package/dist/esm/errors/utils.js.map +1 -0
- package/dist/esm/errors/withdrawal.js +12 -0
- package/dist/esm/errors/withdrawal.js.map +1 -0
- package/dist/esm/formatters.js +48 -0
- package/dist/esm/formatters.js.map +1 -0
- package/dist/esm/index.js +29 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/parsers.js +54 -0
- package/dist/esm/parsers.js.map +1 -0
- package/dist/esm/serializers.js +48 -0
- package/dist/esm/serializers.js.map +1 -0
- package/dist/esm/types/account.js +2 -0
- package/dist/esm/types/account.js.map +1 -0
- package/dist/esm/types/block.js +2 -0
- package/dist/esm/types/block.js.map +1 -0
- package/dist/esm/types/chain.js +2 -0
- package/dist/esm/types/chain.js.map +1 -0
- package/dist/esm/types/contract.js +2 -0
- package/dist/esm/types/contract.js.map +1 -0
- package/dist/esm/types/deposit.js +2 -0
- package/dist/esm/types/deposit.js.map +1 -0
- package/dist/esm/types/l1Actions.js +5 -0
- package/dist/esm/types/l1Actions.js.map +1 -0
- package/dist/esm/types/l2Actions.js +7 -0
- package/dist/esm/types/l2Actions.js.map +1 -0
- package/dist/esm/types/transaction.js +2 -0
- package/dist/esm/types/transaction.js.map +1 -0
- package/dist/esm/types/withdrawal.js +2 -0
- package/dist/esm/types/withdrawal.js.map +1 -0
- package/dist/esm/utils/extractTransactionDepositedLogs.js +10 -0
- package/dist/esm/utils/extractTransactionDepositedLogs.js.map +1 -0
- package/dist/esm/utils/extractWithdrawalMessageLogs.js +10 -0
- package/dist/esm/utils/extractWithdrawalMessageLogs.js.map +1 -0
- package/dist/esm/utils/getL2TransactionHash.js +26 -0
- package/dist/esm/utils/getL2TransactionHash.js.map +1 -0
- package/dist/esm/utils/getL2TransactionHashes.js +7 -0
- package/dist/esm/utils/getL2TransactionHashes.js.map +1 -0
- package/dist/esm/utils/getSourceHash.js +14 -0
- package/dist/esm/utils/getSourceHash.js.map +1 -0
- package/dist/esm/utils/getWithdrawalHashStorageSlot.js +6 -0
- package/dist/esm/utils/getWithdrawalHashStorageSlot.js.map +1 -0
- package/dist/esm/utils/getWithdrawals.js +6 -0
- package/dist/esm/utils/getWithdrawals.js.map +1 -0
- package/dist/esm/utils/opaqueDataToDepositData.js +29 -0
- package/dist/esm/utils/opaqueDataToDepositData.js.map +1 -0
- package/dist/esm/utils/parseDepositRequest.js +39 -0
- package/dist/esm/utils/parseDepositRequest.js.map +1 -0
- package/dist/esm/utils/parseInitWithdrawRequest.js +51 -0
- package/dist/esm/utils/parseInitWithdrawRequest.js.map +1 -0
- package/dist/esm/utils/poll.js +26 -0
- package/dist/esm/utils/poll.js.map +1 -0
- package/dist/esm/utils/promise/withCache.js +57 -0
- package/dist/esm/utils/promise/withCache.js.map +1 -0
- package/dist/esm/utils/wait.js +4 -0
- package/dist/esm/utils/wait.js.map +1 -0
- package/dist/types/abis.d.ts +3110 -0
- package/dist/types/abis.d.ts.map +1 -0
- package/dist/types/actions/buildProveWithdrawal.d.ts +34 -0
- package/dist/types/actions/buildProveWithdrawal.d.ts.map +1 -0
- package/dist/types/actions/depositERC20.d.ts +29 -0
- package/dist/types/actions/depositERC20.d.ts.map +1 -0
- package/dist/types/actions/depositETH.d.ts +29 -0
- package/dist/types/actions/depositETH.d.ts.map +1 -0
- package/dist/types/actions/depositMNT.d.ts +29 -0
- package/dist/types/actions/depositMNT.d.ts.map +1 -0
- package/dist/types/actions/estimateDepositERC20Gas.d.ts +26 -0
- package/dist/types/actions/estimateDepositERC20Gas.d.ts.map +1 -0
- package/dist/types/actions/estimateDepositETHGas.d.ts +26 -0
- package/dist/types/actions/estimateDepositETHGas.d.ts.map +1 -0
- package/dist/types/actions/estimateDepositMNTGas.d.ts +26 -0
- package/dist/types/actions/estimateDepositMNTGas.d.ts.map +1 -0
- package/dist/types/actions/estimateFinalizeWithdrawalGas.d.ts +26 -0
- package/dist/types/actions/estimateFinalizeWithdrawalGas.d.ts.map +1 -0
- package/dist/types/actions/estimateInitiateERC20WithdrawalGas.d.ts +25 -0
- package/dist/types/actions/estimateInitiateERC20WithdrawalGas.d.ts.map +1 -0
- package/dist/types/actions/estimateInitiateETHWithdrawalGas.d.ts +25 -0
- package/dist/types/actions/estimateInitiateETHWithdrawalGas.d.ts.map +1 -0
- package/dist/types/actions/estimateInitiateMNTWithdrawalGas.d.ts +25 -0
- package/dist/types/actions/estimateInitiateMNTWithdrawalGas.d.ts.map +1 -0
- package/dist/types/actions/estimateProveWithdrawalGas.d.ts +35 -0
- package/dist/types/actions/estimateProveWithdrawalGas.d.ts.map +1 -0
- package/dist/types/actions/finalizeWithdrawal.d.ts +29 -0
- package/dist/types/actions/finalizeWithdrawal.d.ts.map +1 -0
- package/dist/types/actions/getL2Output.d.ts +24 -0
- package/dist/types/actions/getL2Output.d.ts.map +1 -0
- package/dist/types/actions/getPortalVersion.d.ts +23 -0
- package/dist/types/actions/getPortalVersion.d.ts.map +1 -0
- package/dist/types/actions/getTimeToFinalize.d.ts +26 -0
- package/dist/types/actions/getTimeToFinalize.d.ts.map +1 -0
- package/dist/types/actions/getTimeToNextL2Output.d.ts +35 -0
- package/dist/types/actions/getTimeToNextL2Output.d.ts.map +1 -0
- package/dist/types/actions/getTimeToProve.d.ts +24 -0
- package/dist/types/actions/getTimeToProve.d.ts.map +1 -0
- package/dist/types/actions/getWithdrawalStatus.d.ts +22 -0
- package/dist/types/actions/getWithdrawalStatus.d.ts.map +1 -0
- package/dist/types/actions/initiateERC20Withdrawal.d.ts +27 -0
- package/dist/types/actions/initiateERC20Withdrawal.d.ts.map +1 -0
- package/dist/types/actions/initiateETHWithdrawal.d.ts +27 -0
- package/dist/types/actions/initiateETHWithdrawal.d.ts.map +1 -0
- package/dist/types/actions/initiateMNTWithdrawal.d.ts +27 -0
- package/dist/types/actions/initiateMNTWithdrawal.d.ts.map +1 -0
- package/dist/types/actions/proveWithdrawal.d.ts +36 -0
- package/dist/types/actions/proveWithdrawal.d.ts.map +1 -0
- package/dist/types/actions/waitForNextL2Output.d.ts +29 -0
- package/dist/types/actions/waitForNextL2Output.d.ts.map +1 -0
- package/dist/types/actions/waitToFinalize.d.ts +14 -0
- package/dist/types/actions/waitToFinalize.d.ts.map +1 -0
- package/dist/types/actions/waitToProve.d.ts +27 -0
- package/dist/types/actions/waitToProve.d.ts.map +1 -0
- package/dist/types/chainConfig.d.ts +43 -0
- package/dist/types/chainConfig.d.ts.map +1 -0
- package/dist/types/chains/index.d.ts +3 -0
- package/dist/types/chains/index.d.ts.map +1 -0
- package/dist/types/chains/mantle.d.ts +299 -0
- package/dist/types/chains/mantle.d.ts.map +1 -0
- package/dist/types/chains/mantleSepoliaTestnet.d.ts +299 -0
- package/dist/types/chains/mantleSepoliaTestnet.d.ts.map +1 -0
- package/dist/types/contracts.d.ts +21 -0
- package/dist/types/contracts.d.ts.map +1 -0
- package/dist/types/decorators/publicL1.d.ts +35 -0
- package/dist/types/decorators/publicL1.d.ts.map +1 -0
- package/dist/types/decorators/publicL2.d.ts +16 -0
- package/dist/types/decorators/publicL2.d.ts.map +1 -0
- package/dist/types/decorators/walletL1.d.ts +17 -0
- package/dist/types/decorators/walletL1.d.ts.map +1 -0
- package/dist/types/decorators/walletL2.d.ts +13 -0
- package/dist/types/decorators/walletL2.d.ts.map +1 -0
- package/dist/types/errors/utils.d.ts +4 -0
- package/dist/types/errors/utils.d.ts.map +1 -0
- package/dist/types/errors/withdrawal.d.ts +17 -0
- package/dist/types/errors/withdrawal.d.ts.map +1 -0
- package/dist/types/formatters.d.ts +20 -0
- package/dist/types/formatters.d.ts.map +1 -0
- package/dist/types/index.d.ts +30 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/parsers.d.ts +8 -0
- package/dist/types/parsers.d.ts.map +1 -0
- package/dist/types/serializers.d.ts +13 -0
- package/dist/types/serializers.d.ts.map +1 -0
- package/dist/types/types/account.d.ts +7 -0
- package/dist/types/types/account.d.ts.map +1 -0
- package/dist/types/types/block.d.ts +13 -0
- package/dist/types/types/block.d.ts.map +1 -0
- package/dist/types/types/chain.d.ts +9 -0
- package/dist/types/types/chain.d.ts.map +1 -0
- package/dist/types/types/contract.d.ts +14 -0
- package/dist/types/types/contract.d.ts.map +1 -0
- package/dist/types/types/deposit.d.ts +35 -0
- package/dist/types/types/deposit.d.ts.map +1 -0
- package/dist/types/types/l1Actions.d.ts +856 -0
- package/dist/types/types/l1Actions.d.ts.map +1 -0
- package/dist/types/types/l2Actions.d.ts +3 -0
- package/dist/types/types/l2Actions.d.ts.map +1 -0
- package/dist/types/types/transaction.d.ts +58 -0
- package/dist/types/types/transaction.d.ts.map +1 -0
- package/dist/types/types/withdrawal.d.ts +39 -0
- package/dist/types/types/withdrawal.d.ts.map +1 -0
- package/dist/types/utils/extractTransactionDepositedLogs.d.ts +450 -0
- package/dist/types/utils/extractTransactionDepositedLogs.d.ts.map +1 -0
- package/dist/types/utils/extractWithdrawalMessageLogs.d.ts +160 -0
- package/dist/types/utils/extractWithdrawalMessageLogs.d.ts.map +1 -0
- package/dist/types/utils/getL2TransactionHash.d.ts +12 -0
- package/dist/types/utils/getL2TransactionHash.d.ts.map +1 -0
- package/dist/types/utils/getL2TransactionHashes.d.ts +11 -0
- package/dist/types/utils/getL2TransactionHashes.d.ts.map +1 -0
- package/dist/types/utils/getSourceHash.d.ts +25 -0
- package/dist/types/utils/getSourceHash.d.ts.map +1 -0
- package/dist/types/utils/getWithdrawalHashStorageSlot.d.ts +10 -0
- package/dist/types/utils/getWithdrawalHashStorageSlot.d.ts.map +1 -0
- package/dist/types/utils/getWithdrawals.d.ts +12 -0
- package/dist/types/utils/getWithdrawals.d.ts.map +1 -0
- package/dist/types/utils/opaqueDataToDepositData.d.ts +16 -0
- package/dist/types/utils/opaqueDataToDepositData.d.ts.map +1 -0
- package/dist/types/utils/parseDepositRequest.d.ts +11 -0
- package/dist/types/utils/parseDepositRequest.d.ts.map +1 -0
- package/dist/types/utils/parseInitWithdrawRequest.d.ts +11 -0
- package/dist/types/utils/parseInitWithdrawRequest.d.ts.map +1 -0
- package/dist/types/utils/poll.d.ts +15 -0
- package/dist/types/utils/poll.d.ts.map +1 -0
- package/dist/types/utils/promise/withCache.d.ts +41 -0
- package/dist/types/utils/promise/withCache.d.ts.map +1 -0
- package/dist/types/utils/wait.d.ts +2 -0
- package/dist/types/utils/wait.d.ts.map +1 -0
- package/package.json +113 -0
- package/src/mantle/abis.ts +3339 -0
- package/src/mantle/actions/buildProveWithdrawal.ts +150 -0
- package/src/mantle/actions/depositERC20.ts +103 -0
- package/src/mantle/actions/depositETH.ts +102 -0
- package/src/mantle/actions/depositMNT.ts +101 -0
- package/src/mantle/actions/estimateDepositERC20Gas.ts +113 -0
- package/src/mantle/actions/estimateDepositETHGas.ts +113 -0
- package/src/mantle/actions/estimateDepositMNTGas.ts +111 -0
- package/src/mantle/actions/estimateFinalizeWithdrawalGas.ts +102 -0
- package/src/mantle/actions/estimateInitiateERC20WithdrawalGas.ts +106 -0
- package/src/mantle/actions/estimateInitiateETHWithdrawalGas.ts +105 -0
- package/src/mantle/actions/estimateInitiateMNTWithdrawalGas.ts +106 -0
- package/src/mantle/actions/estimateProveWithdrawalGas.ts +114 -0
- package/src/mantle/actions/finalizeWithdrawal.ts +95 -0
- package/src/mantle/actions/getL2Output.ts +75 -0
- package/src/mantle/actions/getPortalVersion.ts +57 -0
- package/src/mantle/actions/getTimeToFinalize.ts +85 -0
- package/src/mantle/actions/getTimeToNextL2Output.ts +132 -0
- package/src/mantle/actions/getTimeToProve.ts +58 -0
- package/src/mantle/actions/getWithdrawalStatus.ts +225 -0
- package/src/mantle/actions/initiateERC20Withdrawal.ts +93 -0
- package/src/mantle/actions/initiateETHWithdrawal.ts +90 -0
- package/src/mantle/actions/initiateMNTWithdrawal.ts +91 -0
- package/src/mantle/actions/proveWithdrawal.ts +107 -0
- package/src/mantle/actions/waitForNextL2Output.ts +87 -0
- package/src/mantle/actions/waitToFinalize.ts +33 -0
- package/src/mantle/actions/waitToProve.ts +83 -0
- package/src/mantle/chainConfig.ts +9 -0
- package/src/mantle/chains/index.ts +2 -0
- package/src/mantle/chains/mantle.ts +51 -0
- package/src/mantle/chains/mantleSepoliaTestnet.ts +52 -0
- package/src/mantle/contracts.ts +14 -0
- package/src/mantle/decorators/publicL1.ts +182 -0
- package/src/mantle/decorators/publicL2.ts +96 -0
- package/src/mantle/decorators/walletL1.ts +67 -0
- package/src/mantle/decorators/walletL2.ts +55 -0
- package/src/mantle/errors/utils.ts +1 -0
- package/src/mantle/errors/withdrawal.ts +24 -0
- package/src/mantle/formatters.ts +64 -0
- package/src/mantle/index.ts +179 -0
- package/src/mantle/parsers.ts +97 -0
- package/src/mantle/serializers.ts +106 -0
- package/src/mantle/types/account.ts +25 -0
- package/src/mantle/types/block.ts +34 -0
- package/src/mantle/types/chain.ts +10 -0
- package/src/mantle/types/contract.ts +26 -0
- package/src/mantle/types/deposit.ts +40 -0
- package/src/mantle/types/l1Actions.ts +21 -0
- package/src/mantle/types/l2Actions.ts +6 -0
- package/src/mantle/types/transaction.ts +108 -0
- package/src/mantle/types/withdrawal.ts +45 -0
- package/src/mantle/utils/extractTransactionDepositedLogs.ts +33 -0
- package/src/mantle/utils/extractWithdrawalMessageLogs.ts +33 -0
- package/src/mantle/utils/getL2TransactionHash.ts +51 -0
- package/src/mantle/utils/getL2TransactionHashes.ts +21 -0
- package/src/mantle/utils/getSourceHash.ts +62 -0
- package/src/mantle/utils/getWithdrawalHashStorageSlot.ts +27 -0
- package/src/mantle/utils/getWithdrawals.ts +25 -0
- package/src/mantle/utils/opaqueDataToDepositData.ts +58 -0
- package/src/mantle/utils/parseDepositRequest.ts +67 -0
- package/src/mantle/utils/parseInitWithdrawRequest.ts +68 -0
- package/src/mantle/utils/poll.ts +45 -0
- package/src/mantle/utils/promise/withCache.ts +81 -0
- package/src/mantle/utils/wait.ts +3 -0
@@ -0,0 +1,108 @@
|
|
1
|
+
import type { FeeValuesEIP1559 } from "viem";
|
2
|
+
import type { Hex } from "viem";
|
3
|
+
import type {
|
4
|
+
Index,
|
5
|
+
Quantity,
|
6
|
+
RpcTransaction as RpcTransaction_,
|
7
|
+
RpcTransactionReceipt,
|
8
|
+
} from "viem";
|
9
|
+
import type {
|
10
|
+
Transaction as Transaction_,
|
11
|
+
TransactionBase,
|
12
|
+
TransactionReceipt,
|
13
|
+
TransactionSerializable,
|
14
|
+
TransactionSerializableBase,
|
15
|
+
TransactionSerialized,
|
16
|
+
TransactionType,
|
17
|
+
} from "viem";
|
18
|
+
import type { OneOf } from "viem";
|
19
|
+
|
20
|
+
type RpcTransaction<pending extends boolean = boolean> =
|
21
|
+
RpcTransaction_<pending> & {
|
22
|
+
isSystemTx?: undefined;
|
23
|
+
mint?: undefined;
|
24
|
+
sourceHash?: undefined;
|
25
|
+
};
|
26
|
+
|
27
|
+
export type OpStackRpcDepositTransaction<pending extends boolean = boolean> =
|
28
|
+
Omit<TransactionBase<Quantity, Index, pending>, "typeHex"> &
|
29
|
+
FeeValuesEIP1559<Quantity> & {
|
30
|
+
isSystemTx?: boolean | undefined;
|
31
|
+
mint?: Hex | undefined;
|
32
|
+
sourceHash: Hex;
|
33
|
+
type: "0x7e";
|
34
|
+
};
|
35
|
+
export type OpStackRpcTransaction<pending extends boolean = boolean> = OneOf<
|
36
|
+
RpcTransaction<pending> | OpStackRpcDepositTransaction<pending>
|
37
|
+
>;
|
38
|
+
|
39
|
+
export type OpStackRpcTransactionReceiptOverrides = {
|
40
|
+
l1GasPrice: Hex | null;
|
41
|
+
l1GasUsed: Hex | null;
|
42
|
+
l1Fee: Hex | null;
|
43
|
+
l1FeeScalar: `${number}` | null;
|
44
|
+
};
|
45
|
+
export type OpStackRpcTransactionReceipt = RpcTransactionReceipt &
|
46
|
+
OpStackRpcTransactionReceiptOverrides;
|
47
|
+
|
48
|
+
type Transaction<pending extends boolean = boolean> = Transaction_<
|
49
|
+
bigint,
|
50
|
+
number,
|
51
|
+
pending
|
52
|
+
> & {
|
53
|
+
isSystemTx?: undefined;
|
54
|
+
mint?: undefined;
|
55
|
+
sourceHash?: undefined;
|
56
|
+
};
|
57
|
+
|
58
|
+
export type OpStackDepositTransaction<pending extends boolean = boolean> =
|
59
|
+
TransactionBase<bigint, number, pending> &
|
60
|
+
FeeValuesEIP1559 & {
|
61
|
+
isSystemTx?: boolean;
|
62
|
+
mint?: bigint | undefined;
|
63
|
+
sourceHash: Hex;
|
64
|
+
type: "deposit";
|
65
|
+
};
|
66
|
+
|
67
|
+
export type OpStackTransaction<pending extends boolean = boolean> =
|
68
|
+
| Transaction<pending>
|
69
|
+
| OpStackDepositTransaction<pending>;
|
70
|
+
|
71
|
+
export type OpStackTransactionReceiptOverrides = {
|
72
|
+
l1GasPrice: bigint | null;
|
73
|
+
l1GasUsed: bigint | null;
|
74
|
+
l1Fee: bigint | null;
|
75
|
+
l1FeeScalar: number | null;
|
76
|
+
};
|
77
|
+
export type OpStackTransactionReceipt = TransactionReceipt &
|
78
|
+
OpStackTransactionReceiptOverrides;
|
79
|
+
|
80
|
+
export type OpStackTransactionSerializable = OneOf<
|
81
|
+
TransactionSerializableDeposit | TransactionSerializable
|
82
|
+
>;
|
83
|
+
|
84
|
+
export type OpStackTransactionSerialized<
|
85
|
+
type extends OpStackTransactionType = OpStackTransactionType,
|
86
|
+
> = type extends "deposit"
|
87
|
+
? TransactionSerializedDeposit
|
88
|
+
: TransactionSerialized<type>;
|
89
|
+
|
90
|
+
export type OpStackTransactionType = TransactionType | "deposit";
|
91
|
+
|
92
|
+
export type TransactionSerializableDeposit<
|
93
|
+
quantity = bigint,
|
94
|
+
index = number,
|
95
|
+
> = Omit<
|
96
|
+
TransactionSerializableBase<quantity, index>,
|
97
|
+
"nonce" | "r" | "s" | "v"
|
98
|
+
> & {
|
99
|
+
from: Hex;
|
100
|
+
isSystemTx?: boolean;
|
101
|
+
mint?: bigint | undefined;
|
102
|
+
sourceHash: Hex;
|
103
|
+
type: "deposit";
|
104
|
+
ethValue?: bigint | undefined;
|
105
|
+
ethTxValue?: bigint | undefined;
|
106
|
+
};
|
107
|
+
|
108
|
+
export type TransactionSerializedDeposit = `0x7e${string}`;
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import type { Address } from "viem";
|
2
|
+
import type { Hex } from "viem";
|
3
|
+
|
4
|
+
export type InitialteWithdrawalRequest = {
|
5
|
+
/** L2 Transaction recipient. */
|
6
|
+
// to: Address;
|
7
|
+
amount: bigint;
|
8
|
+
to?: Address;
|
9
|
+
} & (
|
10
|
+
| {
|
11
|
+
type: "mnt" | "eth";
|
12
|
+
l2Token?: undefined;
|
13
|
+
}
|
14
|
+
| {
|
15
|
+
type: "erc20";
|
16
|
+
/** Other ERC20 L2 Token Address. */
|
17
|
+
l2Token: Address;
|
18
|
+
}
|
19
|
+
);
|
20
|
+
|
21
|
+
export type InitiateERC20WithdrawalRequest = {
|
22
|
+
amount: bigint;
|
23
|
+
/** Other ERC20 L2 Token Address. */
|
24
|
+
l2Token: Address;
|
25
|
+
to?: Address;
|
26
|
+
};
|
27
|
+
export type InitiateMNTWithdrawalRequest = {
|
28
|
+
amount: bigint;
|
29
|
+
to?: Address;
|
30
|
+
};
|
31
|
+
export type InitiateETHWithdrawalRequest = {
|
32
|
+
amount: bigint;
|
33
|
+
to?: Address;
|
34
|
+
};
|
35
|
+
|
36
|
+
export type Withdrawal = {
|
37
|
+
nonce: bigint;
|
38
|
+
sender: Hex;
|
39
|
+
target: Hex;
|
40
|
+
mntValue: bigint;
|
41
|
+
ethValue: bigint;
|
42
|
+
gasLimit: bigint;
|
43
|
+
data: Hex;
|
44
|
+
withdrawalHash: Hex;
|
45
|
+
};
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { parseEventLogs, type ParseEventLogsErrorType } from "viem";
|
2
|
+
import type { Log } from "viem";
|
3
|
+
import { portalAbi } from "../abis.js";
|
4
|
+
import type { ErrorType } from "../errors/utils.js";
|
5
|
+
|
6
|
+
export type ExtractTransactionDepositedLogsParameters = {
|
7
|
+
/** An opaque array of logs. */
|
8
|
+
logs: Log[];
|
9
|
+
};
|
10
|
+
|
11
|
+
export type ExtractTransactionDepositedLogsReturnType = Log<
|
12
|
+
bigint,
|
13
|
+
number,
|
14
|
+
false,
|
15
|
+
undefined,
|
16
|
+
true,
|
17
|
+
typeof portalAbi,
|
18
|
+
"TransactionDeposited"
|
19
|
+
>[];
|
20
|
+
|
21
|
+
export type ExtractTransactionDepositedLogsErrorType =
|
22
|
+
| ParseEventLogsErrorType
|
23
|
+
| ErrorType;
|
24
|
+
|
25
|
+
export function extractTransactionDepositedLogs({
|
26
|
+
logs,
|
27
|
+
}: ExtractTransactionDepositedLogsParameters) {
|
28
|
+
return parseEventLogs({
|
29
|
+
abi: portalAbi,
|
30
|
+
eventName: "TransactionDeposited",
|
31
|
+
logs,
|
32
|
+
});
|
33
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { parseEventLogs, type ParseEventLogsErrorType } from "viem";
|
2
|
+
import type { Log } from "viem";
|
3
|
+
import { l2ToL1MessagePasserAbi } from "../abis.js";
|
4
|
+
import type { ErrorType } from "../errors/utils.js";
|
5
|
+
|
6
|
+
export type ExtractWithdrawalMessageLogsParameters = {
|
7
|
+
/** An opaque array of logs. */
|
8
|
+
logs: Log[];
|
9
|
+
};
|
10
|
+
|
11
|
+
export type ExtractWithdrawalMessageLogsReturnType = Log<
|
12
|
+
bigint,
|
13
|
+
number,
|
14
|
+
false,
|
15
|
+
undefined,
|
16
|
+
true,
|
17
|
+
typeof l2ToL1MessagePasserAbi,
|
18
|
+
"MessagePassed"
|
19
|
+
>[];
|
20
|
+
|
21
|
+
export type ExtractWithdrawalMessageLogsErrorType =
|
22
|
+
| ParseEventLogsErrorType
|
23
|
+
| ErrorType;
|
24
|
+
|
25
|
+
export function extractWithdrawalMessageLogs({
|
26
|
+
logs,
|
27
|
+
}: ExtractWithdrawalMessageLogsParameters) {
|
28
|
+
return parseEventLogs({
|
29
|
+
abi: l2ToL1MessagePasserAbi,
|
30
|
+
eventName: "MessagePassed",
|
31
|
+
logs,
|
32
|
+
});
|
33
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { keccak256 } from "viem";
|
2
|
+
import type { Log } from "viem";
|
3
|
+
import type { Hex } from "viem";
|
4
|
+
import type { portalAbi } from "../abis.js";
|
5
|
+
import type { ErrorType } from "../errors/utils.js";
|
6
|
+
import { serializeTransaction } from "../serializers.js";
|
7
|
+
import { getSourceHash } from "./getSourceHash.js";
|
8
|
+
import { opaqueDataToDepositData } from "./opaqueDataToDepositData.js";
|
9
|
+
|
10
|
+
export type GetL2TransactionHashParameters = {
|
11
|
+
/** The "TransactionDeposited" log to compute the L2 hash from. */
|
12
|
+
log: Log<
|
13
|
+
bigint,
|
14
|
+
number,
|
15
|
+
false,
|
16
|
+
undefined,
|
17
|
+
true,
|
18
|
+
typeof portalAbi,
|
19
|
+
"TransactionDeposited"
|
20
|
+
>;
|
21
|
+
};
|
22
|
+
|
23
|
+
export type GetL2TransactionHashReturnType = Hex;
|
24
|
+
|
25
|
+
export type GetL2TransactionHashErrorType = ErrorType;
|
26
|
+
|
27
|
+
export function getL2TransactionHash({ log }: GetL2TransactionHashParameters) {
|
28
|
+
const sourceHash = getSourceHash({
|
29
|
+
domain: "userDeposit",
|
30
|
+
l1BlockHash: log.blockHash,
|
31
|
+
l1LogIndex: log.logIndex,
|
32
|
+
});
|
33
|
+
const { data, gas, isCreation, mint, value, ethValue, ethTxValue } =
|
34
|
+
opaqueDataToDepositData(log.args.opaqueData);
|
35
|
+
|
36
|
+
return keccak256(
|
37
|
+
serializeTransaction({
|
38
|
+
from: log.args.from,
|
39
|
+
to: isCreation ? undefined : log.args.to,
|
40
|
+
sourceHash,
|
41
|
+
data,
|
42
|
+
gas,
|
43
|
+
isSystemTx: false,
|
44
|
+
mint,
|
45
|
+
type: "deposit",
|
46
|
+
value,
|
47
|
+
ethValue,
|
48
|
+
ethTxValue,
|
49
|
+
}),
|
50
|
+
);
|
51
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import type { Log } from "viem";
|
2
|
+
import type { Hex } from "viem";
|
3
|
+
import type { ErrorType } from "../errors/utils.js";
|
4
|
+
import { extractTransactionDepositedLogs } from "./extractTransactionDepositedLogs.js";
|
5
|
+
import { getL2TransactionHash } from "./getL2TransactionHash.js";
|
6
|
+
|
7
|
+
export type GetL2TransactionHashesParameters = {
|
8
|
+
/** The L1 transaction receipt logs. */
|
9
|
+
logs: Log[];
|
10
|
+
};
|
11
|
+
|
12
|
+
export type GetL2TransactionHashesReturnType = Hex[];
|
13
|
+
|
14
|
+
export type GetL2TransactionHashesErrorType = ErrorType;
|
15
|
+
|
16
|
+
export function getL2TransactionHashes({
|
17
|
+
logs,
|
18
|
+
}: GetL2TransactionHashesParameters): GetL2TransactionHashesReturnType {
|
19
|
+
const extractedLogs = extractTransactionDepositedLogs({ logs });
|
20
|
+
return extractedLogs.map((log) => getL2TransactionHash({ log }));
|
21
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import {
|
2
|
+
concat,
|
3
|
+
type ConcatErrorType,
|
4
|
+
keccak256,
|
5
|
+
type Keccak256ErrorType,
|
6
|
+
pad,
|
7
|
+
type PadErrorType,
|
8
|
+
toHex,
|
9
|
+
type ToHexErrorType,
|
10
|
+
} from "viem";
|
11
|
+
import type { Hex } from "viem";
|
12
|
+
import type { ErrorType } from "../errors/utils.js";
|
13
|
+
|
14
|
+
export type GetSourceHashParameters = {
|
15
|
+
/** The L1 block hash. */
|
16
|
+
l1BlockHash: Hex;
|
17
|
+
} & (
|
18
|
+
| {
|
19
|
+
/** Domain of source hash. */
|
20
|
+
domain: "userDeposit";
|
21
|
+
/** The index of the log on the L1. */
|
22
|
+
l1LogIndex: number;
|
23
|
+
/** The sequence number. */
|
24
|
+
sequenceNumber?: undefined;
|
25
|
+
}
|
26
|
+
| {
|
27
|
+
/** Domain of source hash. */
|
28
|
+
domain: "l1InfoDeposit";
|
29
|
+
/** The index of the log on the L1. */
|
30
|
+
l1LogIndex?: undefined;
|
31
|
+
/** The sequence number. */
|
32
|
+
sequenceNumber: number;
|
33
|
+
}
|
34
|
+
);
|
35
|
+
|
36
|
+
export type GetSourceHashReturnType = Hex;
|
37
|
+
|
38
|
+
export type GetSourceHashErrorType =
|
39
|
+
| ConcatErrorType
|
40
|
+
| Keccak256ErrorType
|
41
|
+
| PadErrorType
|
42
|
+
| ToHexErrorType
|
43
|
+
| ErrorType;
|
44
|
+
|
45
|
+
const sourceHashDomainMap = {
|
46
|
+
userDeposit: 0,
|
47
|
+
l1InfoDeposit: 1,
|
48
|
+
} as const;
|
49
|
+
|
50
|
+
export function getSourceHash({
|
51
|
+
domain,
|
52
|
+
l1LogIndex,
|
53
|
+
l1BlockHash,
|
54
|
+
sequenceNumber,
|
55
|
+
}: GetSourceHashParameters) {
|
56
|
+
const marker = toHex(l1LogIndex! ?? sequenceNumber!);
|
57
|
+
const input = concat([l1BlockHash, pad(marker, { size: 32 })]);
|
58
|
+
const depositIdHash = keccak256(input);
|
59
|
+
const domainHex = toHex(sourceHashDomainMap[domain]);
|
60
|
+
const domainInput = concat([pad(domainHex, { size: 32 }), depositIdHash]);
|
61
|
+
return keccak256(domainInput);
|
62
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import {
|
2
|
+
encodeAbiParameters,
|
3
|
+
type EncodeAbiParametersErrorType,
|
4
|
+
keccak256,
|
5
|
+
type Keccak256ErrorType,
|
6
|
+
} from "viem";
|
7
|
+
import type { Hash } from "viem";
|
8
|
+
import type { ErrorType } from "../errors/utils.js";
|
9
|
+
|
10
|
+
export type GetWithdrawalHashStorageSlotParameters = {
|
11
|
+
withdrawalHash: Hash;
|
12
|
+
};
|
13
|
+
export type GetWithdrawalHashStorageSlotReturnType = Hash;
|
14
|
+
export type GetWithdrawalHashStorageSlotErrorType =
|
15
|
+
| EncodeAbiParametersErrorType
|
16
|
+
| Keccak256ErrorType
|
17
|
+
| ErrorType;
|
18
|
+
|
19
|
+
export function getWithdrawalHashStorageSlot({
|
20
|
+
withdrawalHash,
|
21
|
+
}: GetWithdrawalHashStorageSlotParameters) {
|
22
|
+
const data = encodeAbiParameters(
|
23
|
+
[{ type: "bytes32" }, { type: "uint256" }],
|
24
|
+
[withdrawalHash, 0n],
|
25
|
+
);
|
26
|
+
return keccak256(data);
|
27
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import type { Log } from "viem";
|
2
|
+
import type { ErrorType } from "../errors/utils.js";
|
3
|
+
import type { Withdrawal } from "../types/withdrawal.js";
|
4
|
+
import {
|
5
|
+
extractWithdrawalMessageLogs,
|
6
|
+
type ExtractWithdrawalMessageLogsErrorType,
|
7
|
+
} from "./extractWithdrawalMessageLogs.js";
|
8
|
+
|
9
|
+
export type GetWithdrawalsParameters = {
|
10
|
+
/** The L2 transaction receipt logs. */
|
11
|
+
logs: Log[];
|
12
|
+
};
|
13
|
+
|
14
|
+
export type GetWithdrawalsReturnType = Withdrawal[];
|
15
|
+
|
16
|
+
export type GetWithdrawalsErrorType =
|
17
|
+
| ExtractWithdrawalMessageLogsErrorType
|
18
|
+
| ErrorType;
|
19
|
+
|
20
|
+
export function getWithdrawals({
|
21
|
+
logs,
|
22
|
+
}: GetWithdrawalsParameters): GetWithdrawalsReturnType {
|
23
|
+
const extractedLogs = extractWithdrawalMessageLogs({ logs });
|
24
|
+
return extractedLogs.map((log) => log.args);
|
25
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import {
|
2
|
+
hexToBigInt,
|
3
|
+
size,
|
4
|
+
type SizeErrorType,
|
5
|
+
slice,
|
6
|
+
type SliceErrorType,
|
7
|
+
} from "viem";
|
8
|
+
import type { Hex } from "viem";
|
9
|
+
import type { ErrorType } from "../errors/utils.js";
|
10
|
+
|
11
|
+
export type OpaqueDataToDepositDataParameters = Hex;
|
12
|
+
|
13
|
+
export type OpaqueDataToDepositDataReturnType = {
|
14
|
+
mint: bigint;
|
15
|
+
value: bigint;
|
16
|
+
gas: bigint;
|
17
|
+
isCreation: boolean;
|
18
|
+
data: Hex;
|
19
|
+
ethValue: bigint;
|
20
|
+
ethTxValue: bigint;
|
21
|
+
};
|
22
|
+
|
23
|
+
export type OpaqueDataToDepositDataErrorType =
|
24
|
+
| SliceErrorType
|
25
|
+
| SizeErrorType
|
26
|
+
| ErrorType;
|
27
|
+
|
28
|
+
export function opaqueDataToDepositData(
|
29
|
+
opaqueData: Hex,
|
30
|
+
): OpaqueDataToDepositDataReturnType {
|
31
|
+
let offset = 0;
|
32
|
+
const mint = slice(opaqueData, offset, offset + 32);
|
33
|
+
offset += 32;
|
34
|
+
const value = slice(opaqueData, offset, offset + 32);
|
35
|
+
offset += 32;
|
36
|
+
const ethValue = slice(opaqueData, offset, offset + 32);
|
37
|
+
offset += 32;
|
38
|
+
const ethTxValue = slice(opaqueData, offset, offset + 32);
|
39
|
+
offset += 32;
|
40
|
+
const gas = slice(opaqueData, offset, offset + 8);
|
41
|
+
offset += 8;
|
42
|
+
const isCreation =
|
43
|
+
BigInt(slice(opaqueData, offset, offset + 1)) === BigInt(1);
|
44
|
+
offset += 1;
|
45
|
+
const data =
|
46
|
+
offset > size(opaqueData) - 1
|
47
|
+
? "0x"
|
48
|
+
: slice(opaqueData, offset, opaqueData.length);
|
49
|
+
return {
|
50
|
+
mint: hexToBigInt(mint),
|
51
|
+
value: hexToBigInt(value),
|
52
|
+
gas: hexToBigInt(gas),
|
53
|
+
isCreation,
|
54
|
+
data,
|
55
|
+
ethValue: hexToBigInt(ethValue),
|
56
|
+
ethTxValue: hexToBigInt(ethTxValue),
|
57
|
+
};
|
58
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import type { Address, Hex } from "viem";
|
2
|
+
import type { DepositRequest } from "../types/deposit.js";
|
3
|
+
|
4
|
+
export type DepositFunctionName =
|
5
|
+
| "depositETH"
|
6
|
+
| "depositERC20"
|
7
|
+
| "depositMNT"
|
8
|
+
| "depositETHTo"
|
9
|
+
| "depositERC20To"
|
10
|
+
| "depositMNTTo";
|
11
|
+
export type DepositArgs =
|
12
|
+
| [number, Hex]
|
13
|
+
| [Address, Address, bigint, number, Hex]
|
14
|
+
| [bigint, number, Hex]
|
15
|
+
| [Address, number, Hex]
|
16
|
+
| [Address, Address, Address, bigint, number, Hex]
|
17
|
+
| [Address, bigint, number, Hex];
|
18
|
+
type ParseDepositRequestReturnType = {
|
19
|
+
functionName: DepositFunctionName;
|
20
|
+
args: DepositArgs;
|
21
|
+
};
|
22
|
+
|
23
|
+
export const parseDepositRequest = ({
|
24
|
+
type,
|
25
|
+
l1Token,
|
26
|
+
l2Token,
|
27
|
+
amount,
|
28
|
+
to,
|
29
|
+
}: DepositRequest): ParseDepositRequestReturnType => {
|
30
|
+
if (to) {
|
31
|
+
switch (type) {
|
32
|
+
case "eth":
|
33
|
+
return {
|
34
|
+
functionName: "depositETHTo",
|
35
|
+
args: [to, 200000, "0x"],
|
36
|
+
};
|
37
|
+
case "erc20":
|
38
|
+
return {
|
39
|
+
functionName: "depositERC20To",
|
40
|
+
args: [l1Token, l2Token, to, amount, 200000, "0x"],
|
41
|
+
};
|
42
|
+
default:
|
43
|
+
return {
|
44
|
+
functionName: "depositMNTTo",
|
45
|
+
args: [to, amount, 200000, "0x"],
|
46
|
+
};
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
switch (type) {
|
51
|
+
case "eth":
|
52
|
+
return {
|
53
|
+
functionName: "depositETH",
|
54
|
+
args: [200000, "0x"],
|
55
|
+
};
|
56
|
+
case "erc20":
|
57
|
+
return {
|
58
|
+
functionName: "depositERC20",
|
59
|
+
args: [l1Token, l2Token, amount, 200000, "0x"],
|
60
|
+
};
|
61
|
+
default:
|
62
|
+
return {
|
63
|
+
functionName: "depositMNT",
|
64
|
+
args: [amount, 200000, "0x"],
|
65
|
+
};
|
66
|
+
}
|
67
|
+
};
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import type { Address, Hex } from "viem";
|
2
|
+
import type { InitialteWithdrawalRequest } from "../types/withdrawal.js";
|
3
|
+
|
4
|
+
export type InitWithdrawFunctionName = "withdraw" | "withdrawTo";
|
5
|
+
export type WithdrawArgs =
|
6
|
+
| [Address, bigint, number, Hex]
|
7
|
+
| [Address, Address, bigint, number, Hex];
|
8
|
+
type ParseWithdrawRequestReturnType = {
|
9
|
+
functionName: InitWithdrawFunctionName;
|
10
|
+
args: WithdrawArgs;
|
11
|
+
};
|
12
|
+
|
13
|
+
export const parseInitWithdrawequest = ({
|
14
|
+
type,
|
15
|
+
l2Token,
|
16
|
+
amount,
|
17
|
+
to,
|
18
|
+
}: InitialteWithdrawalRequest): ParseWithdrawRequestReturnType => {
|
19
|
+
if (to) {
|
20
|
+
switch (type) {
|
21
|
+
case "eth":
|
22
|
+
return {
|
23
|
+
functionName: "withdrawTo",
|
24
|
+
args: [
|
25
|
+
"0xdeaddeaddeaddeaddeaddeaddeaddeaddead1111",
|
26
|
+
to,
|
27
|
+
amount,
|
28
|
+
0,
|
29
|
+
"0x",
|
30
|
+
],
|
31
|
+
};
|
32
|
+
case "erc20":
|
33
|
+
return {
|
34
|
+
functionName: "withdrawTo",
|
35
|
+
args: [l2Token, to, amount, 0, "0x"],
|
36
|
+
};
|
37
|
+
default:
|
38
|
+
return {
|
39
|
+
functionName: "withdrawTo",
|
40
|
+
args: [
|
41
|
+
"0x0000000000000000000000000000000000000000",
|
42
|
+
to,
|
43
|
+
amount,
|
44
|
+
0,
|
45
|
+
"0x",
|
46
|
+
],
|
47
|
+
};
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
switch (type) {
|
52
|
+
case "eth":
|
53
|
+
return {
|
54
|
+
functionName: "withdraw",
|
55
|
+
args: ["0xdeaddeaddeaddeaddeaddeaddeaddeaddead1111", amount, 0, "0x"],
|
56
|
+
};
|
57
|
+
case "erc20":
|
58
|
+
return {
|
59
|
+
functionName: "withdraw",
|
60
|
+
args: [l2Token, amount, 0, "0x"],
|
61
|
+
};
|
62
|
+
default:
|
63
|
+
return {
|
64
|
+
functionName: "withdraw",
|
65
|
+
args: ["0x0000000000000000000000000000000000000000", amount, 0, "0x"],
|
66
|
+
};
|
67
|
+
}
|
68
|
+
};
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import type { ErrorType } from "../errors/utils.js";
|
2
|
+
import { wait } from "./wait.js";
|
3
|
+
|
4
|
+
type PollOptions<data> = {
|
5
|
+
// Whether or not to emit when the polling starts.
|
6
|
+
emitOnBegin?: boolean | undefined;
|
7
|
+
// The initial wait time (in ms) before polling.
|
8
|
+
initialWaitTime?: ((data: data | void) => Promise<number>) | undefined;
|
9
|
+
// The interval (in ms).
|
10
|
+
interval: number;
|
11
|
+
};
|
12
|
+
|
13
|
+
export type PollErrorType = ErrorType;
|
14
|
+
|
15
|
+
/**
|
16
|
+
* @description Polls a function at a specified interval.
|
17
|
+
*/
|
18
|
+
export function poll<data>(
|
19
|
+
fn: ({ unpoll }: { unpoll: () => void }) => Promise<data | void>,
|
20
|
+
{ emitOnBegin, initialWaitTime, interval }: PollOptions<data>,
|
21
|
+
) {
|
22
|
+
let active = true;
|
23
|
+
|
24
|
+
const unwatch = () => (active = false);
|
25
|
+
|
26
|
+
const watch = async () => {
|
27
|
+
let data: data | void = undefined;
|
28
|
+
if (emitOnBegin) data = await fn({ unpoll: unwatch });
|
29
|
+
|
30
|
+
const initialWait = (await initialWaitTime?.(data)) ?? interval;
|
31
|
+
await wait(initialWait);
|
32
|
+
|
33
|
+
const poll = async () => {
|
34
|
+
if (!active) return;
|
35
|
+
await fn({ unpoll: unwatch });
|
36
|
+
await wait(interval);
|
37
|
+
poll();
|
38
|
+
};
|
39
|
+
|
40
|
+
poll();
|
41
|
+
};
|
42
|
+
watch();
|
43
|
+
|
44
|
+
return unwatch;
|
45
|
+
}
|