|
| 1 | +package types |
| 2 | + |
| 3 | +import ( |
| 4 | + "math/big" |
| 5 | + |
| 6 | + "github.com/ethereum/go-ethereum/common" |
| 7 | +) |
| 8 | + |
| 9 | +var bigZero = big.NewInt(0) |
| 10 | + |
| 11 | +func (tx *LegacyTx) isFake() bool { return false } |
| 12 | +func (tx *AccessListTx) isFake() bool { return false } |
| 13 | +func (tx *DynamicFeeTx) isFake() bool { return false } |
| 14 | + |
| 15 | +type ArbitrumUnsignedTx struct { |
| 16 | + ChainId *big.Int |
| 17 | + From common.Address |
| 18 | + |
| 19 | + Nonce uint64 // nonce of sender account |
| 20 | + GasPrice *big.Int // wei per gas |
| 21 | + Gas uint64 // gas limit |
| 22 | + To *common.Address `rlp:"nil"` // nil means contract creation |
| 23 | + Value *big.Int // wei amount |
| 24 | + Data []byte // contract invocation input data |
| 25 | +} |
| 26 | + |
| 27 | + |
| 28 | +func (tx *ArbitrumUnsignedTx) txType() byte { return ArbitrumUnsignedTxType } |
| 29 | + |
| 30 | +func (tx *ArbitrumUnsignedTx) copy() TxData { |
| 31 | + cpy := &ArbitrumUnsignedTx{ |
| 32 | + ChainId: new(big.Int), |
| 33 | + Nonce: tx.Nonce, |
| 34 | + GasPrice: new(big.Int), |
| 35 | + Gas: tx.Gas, |
| 36 | + To: nil, |
| 37 | + Value: new(big.Int), |
| 38 | + Data: common.CopyBytes(tx.Data), |
| 39 | + } |
| 40 | + if tx.ChainId != nil { |
| 41 | + cpy.ChainId.Set(tx.ChainId) |
| 42 | + } |
| 43 | + if tx.GasPrice != nil { |
| 44 | + cpy.GasPrice.Set(tx.GasPrice) |
| 45 | + } |
| 46 | + if tx.To != nil { |
| 47 | + tmp := *tx.To |
| 48 | + cpy.To = &tmp |
| 49 | + } |
| 50 | + if tx.Value != nil { |
| 51 | + cpy.Value.Set(tx.Value) |
| 52 | + } |
| 53 | + return cpy |
| 54 | +} |
| 55 | + |
| 56 | +func (tx *ArbitrumUnsignedTx) chainID() *big.Int { return tx.ChainId } |
| 57 | +func (tx *ArbitrumUnsignedTx) accessList() AccessList { return nil } |
| 58 | +func (tx *ArbitrumUnsignedTx) data() []byte { return tx.Data } |
| 59 | +func (tx *ArbitrumUnsignedTx) gas() uint64 { return tx.Gas } |
| 60 | +func (tx *ArbitrumUnsignedTx) gasPrice() *big.Int { return tx.GasPrice } |
| 61 | +func (tx *ArbitrumUnsignedTx) gasTipCap() *big.Int { return tx.GasPrice } |
| 62 | +func (tx *ArbitrumUnsignedTx) gasFeeCap() *big.Int { return tx.GasPrice } |
| 63 | +func (tx *ArbitrumUnsignedTx) value() *big.Int { return tx.Value } |
| 64 | +func (tx *ArbitrumUnsignedTx) nonce() uint64 { return tx.Nonce } |
| 65 | +func (tx *ArbitrumUnsignedTx) to() *common.Address { return tx.To } |
| 66 | +func (tx *ArbitrumUnsignedTx) isFake() bool { return false } |
| 67 | + |
| 68 | +func (tx *ArbitrumUnsignedTx) rawSignatureValues() (v, r, s *big.Int) { |
| 69 | + return bigZero, bigZero, bigZero |
| 70 | +} |
| 71 | + |
| 72 | +func (tx *ArbitrumUnsignedTx) setSignatureValues(chainID, v, r, s *big.Int) { |
| 73 | + |
| 74 | +} |
| 75 | + |
| 76 | +type ArbitrumContractTx struct { |
| 77 | + ChainId *big.Int |
| 78 | + RequestId common.Hash |
| 79 | + From common.Address |
| 80 | + |
| 81 | + GasPrice *big.Int // wei per gas |
| 82 | + Gas uint64 // gas limit |
| 83 | + To *common.Address `rlp:"nil"` // nil means contract creation |
| 84 | + Value *big.Int // wei amount |
| 85 | + Data []byte // contract invocation input data |
| 86 | +} |
| 87 | + |
| 88 | + |
| 89 | +func (tx *ArbitrumContractTx) txType() byte { return ArbitrumContractTxType } |
| 90 | + |
| 91 | +func (tx *ArbitrumContractTx) copy() TxData { |
| 92 | + cpy := &ArbitrumContractTx{ |
| 93 | + ChainId: new(big.Int), |
| 94 | + RequestId: tx.RequestId, |
| 95 | + GasPrice: new(big.Int), |
| 96 | + Gas: tx.Gas, |
| 97 | + To: nil, |
| 98 | + Value: new(big.Int), |
| 99 | + Data: common.CopyBytes(tx.Data), |
| 100 | + } |
| 101 | + if tx.ChainId != nil { |
| 102 | + cpy.ChainId.Set(tx.ChainId) |
| 103 | + } |
| 104 | + if tx.GasPrice != nil { |
| 105 | + cpy.GasPrice.Set(tx.GasPrice) |
| 106 | + } |
| 107 | + if tx.To != nil { |
| 108 | + tmp := *tx.To |
| 109 | + cpy.To = &tmp |
| 110 | + } |
| 111 | + if tx.Value != nil { |
| 112 | + cpy.Value.Set(tx.Value) |
| 113 | + } |
| 114 | + return cpy |
| 115 | +} |
| 116 | + |
| 117 | +func (tx *ArbitrumContractTx) chainID() *big.Int { return tx.ChainId } |
| 118 | +func (tx *ArbitrumContractTx) accessList() AccessList { return nil } |
| 119 | +func (tx *ArbitrumContractTx) data() []byte { return tx.Data } |
| 120 | +func (tx *ArbitrumContractTx) gas() uint64 { return tx.Gas } |
| 121 | +func (tx *ArbitrumContractTx) gasPrice() *big.Int { return tx.GasPrice } |
| 122 | +func (tx *ArbitrumContractTx) gasTipCap() *big.Int { return tx.GasPrice } |
| 123 | +func (tx *ArbitrumContractTx) gasFeeCap() *big.Int { return tx.GasPrice } |
| 124 | +func (tx *ArbitrumContractTx) value() *big.Int { return tx.Value } |
| 125 | +func (tx *ArbitrumContractTx) nonce() uint64 { return 0 } |
| 126 | +func (tx *ArbitrumContractTx) to() *common.Address { return tx.To } |
| 127 | +func (tx *ArbitrumContractTx) rawSignatureValues() (v, r, s *big.Int) { |
| 128 | + return bigZero, bigZero, bigZero |
| 129 | +} |
| 130 | +func (tx *ArbitrumContractTx) setSignatureValues(chainID, v, r, s *big.Int) {} |
| 131 | +func (tx *ArbitrumContractTx) isFake() bool { return true } |
| 132 | + |
| 133 | +type DepositTx struct { |
| 134 | + ChainId *big.Int |
| 135 | + L1RequestId common.Hash |
| 136 | + To common.Address |
| 137 | + Value *big.Int |
| 138 | +} |
| 139 | + |
| 140 | +func (d *DepositTx) txType() byte { |
| 141 | + return ArbitrumDepositTxType |
| 142 | +} |
| 143 | + |
| 144 | +func (d *DepositTx) copy() TxData { |
| 145 | + tx := &DepositTx{ |
| 146 | + ChainId: new(big.Int), |
| 147 | + To: d.To, |
| 148 | + Value: new(big.Int), |
| 149 | + } |
| 150 | + if d.ChainId != nil { |
| 151 | + tx.ChainId.Set(d.ChainId) |
| 152 | + } |
| 153 | + if d.Value != nil { |
| 154 | + tx.Value.Set(d.Value) |
| 155 | + } |
| 156 | + return tx |
| 157 | +} |
| 158 | + |
| 159 | +func (d *DepositTx) chainID() *big.Int { return d.ChainId } |
| 160 | +func (d *DepositTx) accessList() AccessList { return nil } |
| 161 | +func (d *DepositTx) data() []byte { return nil } |
| 162 | +func (d DepositTx) gas() uint64 { return 0 } |
| 163 | +func (d *DepositTx) gasPrice() *big.Int { return bigZero } |
| 164 | +func (d *DepositTx) gasTipCap() *big.Int { return bigZero } |
| 165 | +func (d *DepositTx) gasFeeCap() *big.Int { return bigZero } |
| 166 | +func (d *DepositTx) value() *big.Int { return d.Value } |
| 167 | +func (d *DepositTx) nonce() uint64 { return 0 } |
| 168 | +func (d *DepositTx) to() *common.Address { return &d.To } |
| 169 | +func (d *DepositTx) isFake() bool { return true } |
| 170 | + |
| 171 | +func (d *DepositTx) rawSignatureValues() (v, r, s *big.Int) { |
| 172 | + return bigZero, bigZero, bigZero |
| 173 | +} |
| 174 | + |
| 175 | +func (d *DepositTx) setSignatureValues(chainID, v, r, s *big.Int) { |
| 176 | + |
| 177 | +} |
| 178 | + |
0 commit comments