|
| 1 | +import { SignatureType } from '@/chains'; |
| 2 | +import { signatureTypes as mainnetSignatureTypes } from '@/chains/mainnet/signatureTypes'; |
| 3 | + |
| 4 | +const txTypeDocs = 'https://developer.arbitrum.io/arbos/geth#transaction-types'; |
| 5 | + |
| 6 | +const arbitrumDepositTx: SignatureType = { |
| 7 | + prefixByte: 0x64, |
| 8 | + description: |
| 9 | + "Represents a user deposit from L1 to L2. This increases the user's balance by the amount deposited on L1.", |
| 10 | + signedData: ['keccak256(0x64 || rlp([chainId, l1RequestId, from, to, value]))'], |
| 11 | + signs: 'transaction', |
| 12 | + references: [ |
| 13 | + txTypeDocs, |
| 14 | + 'https://github.com/OffchainLabs/go-ethereum/blob/master/core/types/transaction.go#L48', |
| 15 | + 'https://github.com/OffchainLabs/go-ethereum/blob/master/core/types/arb_types.go#L338-L344', |
| 16 | + ], |
| 17 | +}; |
| 18 | + |
| 19 | +const arbitrumUnsignedTx: SignatureType = { |
| 20 | + prefixByte: 0x65, |
| 21 | + description: |
| 22 | + "A message from a user on L1 to a contract on L2 that uses the bridge for authentication instead of requiring the user's signature.", |
| 23 | + signedData: [ |
| 24 | + 'keccak256(0x65 || rlp([chainId, from, nonce, maxFeePerGas, gasLimit, to, value, data]))', |
| 25 | + ], |
| 26 | + signs: 'transaction', |
| 27 | + references: [ |
| 28 | + txTypeDocs, |
| 29 | + 'https://github.com/OffchainLabs/go-ethereum/blob/master/core/types/transaction.go#L49', |
| 30 | + 'https://github.com/OffchainLabs/go-ethereum/blob/master/core/types/arb_types.go#L43-L53', |
| 31 | + ], |
| 32 | +}; |
| 33 | + |
| 34 | +const arbitrumContractTx: SignatureType = { |
| 35 | + prefixByte: 0x66, |
| 36 | + description: |
| 37 | + "Similar to an `ArbitrumUnsignedTx` but intended for smart contracts. Uses the bridge's unique, sequential nonce rather than requiring the caller specify their own.", |
| 38 | + signedData: [ |
| 39 | + 'keccak256(0x66 || rlp([chainId, requestId, from, maxFeePerGas, gasLimit, to, value, data]))', |
| 40 | + ], |
| 41 | + signs: 'transaction', |
| 42 | + references: [ |
| 43 | + txTypeDocs, |
| 44 | + 'https://github.com/OffchainLabs/go-ethereum/blob/master/core/types/transaction.go#L50', |
| 45 | + 'https://github.com/OffchainLabs/go-ethereum/blob/master/core/types/arb_types.go#L104-L114', |
| 46 | + ], |
| 47 | +}; |
| 48 | + |
| 49 | +const arbitrumSubmitRetryableTx: SignatureType = { |
| 50 | + prefixByte: 0x69, |
| 51 | + description: 'A retryable submission and may schedule an ArbitrumRetryTx if provided enough gas.', |
| 52 | + signedData: [ |
| 53 | + 'keccak256(0x69 || rlp([chainId, requestId, from, l1BaseFee, depositValue, maxFeePerGas, gasLimit, retryTo, retryValue, beneficiary, maxSubmissionFee, feeRefundAddress, retryData]))', |
| 54 | + ], |
| 55 | + signs: 'transaction', |
| 56 | + references: [ |
| 57 | + txTypeDocs, |
| 58 | + 'https://github.com/OffchainLabs/go-ethereum/blob/master/core/types/transaction.go#L52', |
| 59 | + 'https://github.com/OffchainLabs/go-ethereum/blob/master/core/types/arb_types.go#L232-L247', |
| 60 | + ], |
| 61 | +}; |
| 62 | + |
| 63 | +const arbitrumRetryTx: SignatureType = { |
| 64 | + prefixByte: 0x68, |
| 65 | + description: |
| 66 | + 'Transactions scheduled by calls to the redeem precompile method and via retryable auto-redemption.', |
| 67 | + signedData: [ |
| 68 | + 'keccak256(0x68 || rlp([chainId, nonce, from, maxFeePerGas, gasLimit, to, value, data, ticketId, refundTo, maxRefund, submissionFeeRefund]))', |
| 69 | + ], |
| 70 | + signs: 'transaction', |
| 71 | + references: [ |
| 72 | + txTypeDocs, |
| 73 | + 'https://github.com/OffchainLabs/go-ethereum/blob/master/core/types/transaction.go#L51', |
| 74 | + 'https://github.com/OffchainLabs/go-ethereum/blob/master/core/types/arb_types.go#L161-L176', |
| 75 | + ], |
| 76 | +}; |
| 77 | + |
| 78 | +const arbitrumInternalTx: SignatureType = { |
| 79 | + prefixByte: 0x6a, |
| 80 | + description: 'ArbOS-created transaction to update state between user-generated transactions.', |
| 81 | + signedData: ['keccak256(0x6a || rlp([chainId, data]))'], |
| 82 | + signs: 'transaction', |
| 83 | + references: [ |
| 84 | + txTypeDocs, |
| 85 | + 'https://github.com/OffchainLabs/go-ethereum/blob/master/core/types/transaction.go#L53', |
| 86 | + 'https://github.com/OffchainLabs/go-ethereum/blob/master/core/types/arb_types.go#L387-L390', |
| 87 | + ], |
| 88 | +}; |
| 89 | + |
| 90 | +const arbitrumLegacyTx: SignatureType = { |
| 91 | + prefixByte: 0x78, |
| 92 | + description: 'A legacy transaction', |
| 93 | + signedData: mainnetSignatureTypes[0x00].signedData, |
| 94 | + signs: 'transaction', |
| 95 | + references: [ |
| 96 | + 'https://github.com/OffchainLabs/go-ethereum/blob/a2132df21812259f604855f8ae399745fa9b6de6/core/types/transaction.go#L54', |
| 97 | + ...mainnetSignatureTypes[0x00].references, |
| 98 | + ], |
| 99 | +}; |
| 100 | + |
| 101 | +export const signatureTypes = { |
| 102 | + ...mainnetSignatureTypes, |
| 103 | + ...{ [arbitrumDepositTx.prefixByte]: arbitrumDepositTx }, |
| 104 | + ...{ [arbitrumUnsignedTx.prefixByte]: arbitrumUnsignedTx }, |
| 105 | + ...{ [arbitrumContractTx.prefixByte]: arbitrumContractTx }, |
| 106 | + ...{ [arbitrumSubmitRetryableTx.prefixByte]: arbitrumSubmitRetryableTx }, |
| 107 | + ...{ [arbitrumRetryTx.prefixByte]: arbitrumRetryTx }, |
| 108 | + ...{ [arbitrumInternalTx.prefixByte]: arbitrumInternalTx }, |
| 109 | + ...{ [arbitrumLegacyTx.prefixByte]: arbitrumLegacyTx }, |
| 110 | +}; |
0 commit comments