mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-12 15:38:18 -05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9a0de0f16 | ||
|
|
3eb62880fe | ||
|
|
e2612a3d88 |
@@ -346,7 +346,6 @@ func ParseBackendL2EventLogs(logs []types.Log) ([]*orm.CrossMsg, []*orm.RelayedM
|
||||
// ParseBatchInfoFromScrollChain parses ScrollChain events
|
||||
func ParseBatchInfoFromScrollChain(ctx context.Context, client *ethclient.Client, logs []types.Log) ([]*orm.RollupBatch, error) {
|
||||
var rollupBatches []*orm.RollupBatch
|
||||
cache := make(map[string]CachedParsedTxCalldata)
|
||||
for _, vlog := range logs {
|
||||
switch vlog.Topics[0] {
|
||||
case backendabi.L1CommitBatchEventSignature:
|
||||
@@ -356,42 +355,22 @@ func ParseBatchInfoFromScrollChain(ctx context.Context, client *ethclient.Client
|
||||
log.Warn("Failed to unpack CommitBatch event", "err", err)
|
||||
return rollupBatches, err
|
||||
}
|
||||
if _, ok := cache[vlog.TxHash.Hex()]; ok {
|
||||
c := cache[vlog.TxHash.Hex()]
|
||||
c.CallDataIndex++
|
||||
rollupBatches = append(rollupBatches, &orm.RollupBatch{
|
||||
CommitHeight: vlog.BlockNumber,
|
||||
BatchIndex: c.BatchIndices[c.CallDataIndex],
|
||||
BatchHash: event.BatchHash.Hex(),
|
||||
StartBlockNumber: c.StartBlocks[c.CallDataIndex],
|
||||
EndBlockNumber: c.EndBlocks[c.CallDataIndex],
|
||||
})
|
||||
cache[vlog.TxHash.Hex()] = c
|
||||
continue
|
||||
}
|
||||
|
||||
commitTx, isPending, err := client.TransactionByHash(ctx, vlog.TxHash)
|
||||
if err != nil || isPending {
|
||||
log.Warn("Failed to get commit Batch tx receipt or the tx is still pending", "err", err)
|
||||
return rollupBatches, err
|
||||
}
|
||||
indices, startBlocks, endBlocks, err := GetBatchRangeFromCalldataV1(commitTx.Data())
|
||||
index, startBlock, endBlock, err := GetBatchRangeFromCalldataV2(commitTx.Data())
|
||||
if err != nil {
|
||||
log.Warn("Failed to get batch range from calldata", "hash", commitTx.Hash().Hex(), "height", vlog.BlockNumber)
|
||||
return rollupBatches, err
|
||||
}
|
||||
cache[vlog.TxHash.Hex()] = CachedParsedTxCalldata{
|
||||
CallDataIndex: 0,
|
||||
BatchIndices: indices,
|
||||
StartBlocks: startBlocks,
|
||||
EndBlocks: endBlocks,
|
||||
}
|
||||
rollupBatches = append(rollupBatches, &orm.RollupBatch{
|
||||
CommitHeight: vlog.BlockNumber,
|
||||
BatchIndex: indices[0],
|
||||
BatchIndex: index,
|
||||
BatchHash: event.BatchHash.Hex(),
|
||||
StartBlockNumber: startBlocks[0],
|
||||
EndBlockNumber: endBlocks[0],
|
||||
StartBlockNumber: startBlock,
|
||||
EndBlockNumber: endBlock,
|
||||
})
|
||||
|
||||
default:
|
||||
|
||||
@@ -171,9 +171,9 @@ func (r *Layer2Relayer) initializeGenesis() error {
|
||||
|
||||
chunk := &types.Chunk{
|
||||
Blocks: []*types.WrappedBlock{{
|
||||
Header: genesis,
|
||||
Transactions: nil,
|
||||
WithdrawTrieRoot: common.Hash{},
|
||||
Header: genesis,
|
||||
Transactions: nil,
|
||||
WithdrawRoot: common.Hash{},
|
||||
}},
|
||||
}
|
||||
|
||||
|
||||
@@ -169,15 +169,15 @@ func (w *L2WatcherClient) getAndStoreBlockTraces(ctx context.Context, from, to u
|
||||
|
||||
log.Info("retrieved block", "height", block.Header().Number, "hash", block.Header().Hash().String())
|
||||
|
||||
withdrawTrieRoot, err3 := w.StorageAt(ctx, w.messageQueueAddress, w.withdrawTrieRootSlot, big.NewInt(int64(number)))
|
||||
withdrawRoot, err3 := w.StorageAt(ctx, w.messageQueueAddress, w.withdrawTrieRootSlot, big.NewInt(int64(number)))
|
||||
if err3 != nil {
|
||||
return fmt.Errorf("failed to get withdrawTrieRoot: %v. number: %v", err3, number)
|
||||
return fmt.Errorf("failed to get withdrawRoot: %v. number: %v", err3, number)
|
||||
}
|
||||
|
||||
blocks = append(blocks, &types.WrappedBlock{
|
||||
Header: block.Header(),
|
||||
Transactions: txsToTxsData(block.Transactions()),
|
||||
WithdrawTrieRoot: common.BytesToHash(withdrawTrieRoot),
|
||||
Header: block.Header(),
|
||||
Transactions: txsToTxsData(block.Transactions()),
|
||||
WithdrawRoot: common.BytesToHash(withdrawRoot),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ type Batch struct {
|
||||
EndChunkHash string `json:"end_chunk_hash" gorm:"column:end_chunk_hash"`
|
||||
StateRoot string `json:"state_root" gorm:"column:state_root"`
|
||||
WithdrawRoot string `json:"withdraw_root" gorm:"column:withdraw_root"`
|
||||
ParentBatchHash string `json:"parent_batch_hash" gorm:"column:parent_batch_hash"`
|
||||
BatchHeader []byte `json:"batch_header" gorm:"column:batch_header"`
|
||||
|
||||
// proof
|
||||
@@ -258,7 +259,8 @@ func (o *Batch) InsertBatch(ctx context.Context, startChunkIndex, endChunkIndex
|
||||
EndChunkHash: endChunkHash,
|
||||
EndChunkIndex: endChunkIndex,
|
||||
StateRoot: chunks[numChunks-1].Blocks[lastChunkBlockNum-1].Header.Root.Hex(),
|
||||
WithdrawRoot: chunks[numChunks-1].Blocks[lastChunkBlockNum-1].WithdrawTrieRoot.Hex(),
|
||||
WithdrawRoot: chunks[numChunks-1].Blocks[lastChunkBlockNum-1].WithdrawRoot.Hex(),
|
||||
ParentBatchHash: parentBatchHash.Hex(),
|
||||
BatchHeader: batchHeader.Encode(),
|
||||
ChunkProofsStatus: int16(types.ChunkProofsStatusPending),
|
||||
ProvingStatus: int16(types.ProvingTaskUnassigned),
|
||||
|
||||
@@ -26,6 +26,10 @@ type Chunk struct {
|
||||
StartBlockTime uint64 `json:"start_block_time" gorm:"column:start_block_time"`
|
||||
TotalL1MessagesPoppedBefore uint64 `json:"total_l1_messages_popped_before" gorm:"column:total_l1_messages_popped_before"`
|
||||
TotalL1MessagesPoppedInChunk uint32 `json:"total_l1_messages_popped_in_chunk" gorm:"column:total_l1_messages_popped_in_chunk"`
|
||||
ParentChunkHash string `json:"parent_chunk_hash" gorm:"column:parent_chunk_hash"`
|
||||
StateRoot string `json:"state_root" gorm:"column:state_root"`
|
||||
ParentChunkStateRoot string `json:"parent_chunk_state_root" gorm:"column:parent_chunk_state_root"`
|
||||
WithdrawRoot string `json:"withdraw_root" gorm:"column:withdraw_root"`
|
||||
|
||||
// proof
|
||||
ProvingStatus int16 `json:"proving_status" gorm:"column:proving_status;default:1"`
|
||||
@@ -118,6 +122,8 @@ func (o *Chunk) InsertChunk(ctx context.Context, chunk *types.Chunk, dbTX ...*go
|
||||
|
||||
var chunkIndex uint64
|
||||
var totalL1MessagePoppedBefore uint64
|
||||
var parentChunkHash string
|
||||
var parentChunkStateRoot string
|
||||
parentChunk, err := o.GetLatestChunk(ctx)
|
||||
if err != nil && !errors.Is(errors.Unwrap(err), gorm.ErrRecordNotFound) {
|
||||
log.Error("failed to get latest chunk", "err", err)
|
||||
@@ -130,6 +136,8 @@ func (o *Chunk) InsertChunk(ctx context.Context, chunk *types.Chunk, dbTX ...*go
|
||||
if parentChunk != nil {
|
||||
chunkIndex = parentChunk.Index + 1
|
||||
totalL1MessagePoppedBefore = parentChunk.TotalL1MessagesPoppedBefore + uint64(parentChunk.TotalL1MessagesPoppedInChunk)
|
||||
parentChunkHash = parentChunk.Hash
|
||||
parentChunkStateRoot = parentChunk.StateRoot
|
||||
}
|
||||
|
||||
hash, err := chunk.Hash(totalL1MessagePoppedBefore)
|
||||
@@ -164,6 +172,10 @@ func (o *Chunk) InsertChunk(ctx context.Context, chunk *types.Chunk, dbTX ...*go
|
||||
StartBlockTime: chunk.Blocks[0].Header.Time,
|
||||
TotalL1MessagesPoppedBefore: totalL1MessagePoppedBefore,
|
||||
TotalL1MessagesPoppedInChunk: uint32(chunk.NumL1Messages(totalL1MessagePoppedBefore)),
|
||||
ParentChunkHash: parentChunkHash,
|
||||
StateRoot: chunk.Blocks[numBlocks-1].Header.Root.Hex(),
|
||||
ParentChunkStateRoot: parentChunkStateRoot,
|
||||
WithdrawRoot: chunk.Blocks[numBlocks-1].WithdrawRoot.Hex(),
|
||||
ProvingStatus: int16(types.ProvingTaskUnassigned),
|
||||
}
|
||||
|
||||
|
||||
@@ -19,15 +19,16 @@ type L2Block struct {
|
||||
db *gorm.DB `gorm:"column:-"`
|
||||
|
||||
// block
|
||||
Number uint64 `json:"number" gorm:"number"`
|
||||
Hash string `json:"hash" gorm:"hash"`
|
||||
ParentHash string `json:"parent_hash" gorm:"parent_hash"`
|
||||
Header string `json:"header" gorm:"header"`
|
||||
Transactions string `json:"transactions" gorm:"transactions"`
|
||||
WithdrawTrieRoot string `json:"withdraw_trie_root" gorm:"withdraw_trie_root"`
|
||||
TxNum uint32 `json:"tx_num" gorm:"tx_num"`
|
||||
GasUsed uint64 `json:"gas_used" gorm:"gas_used"`
|
||||
BlockTimestamp uint64 `json:"block_timestamp" gorm:"block_timestamp"`
|
||||
Number uint64 `json:"number" gorm:"number"`
|
||||
Hash string `json:"hash" gorm:"hash"`
|
||||
ParentHash string `json:"parent_hash" gorm:"parent_hash"`
|
||||
Header string `json:"header" gorm:"header"`
|
||||
Transactions string `json:"transactions" gorm:"transactions"`
|
||||
WithdrawRoot string `json:"withdraw_root" gorm:"withdraw_root"`
|
||||
StateRoot string `json:"state_root" gorm:"state_root"`
|
||||
TxNum uint32 `json:"tx_num" gorm:"tx_num"`
|
||||
GasUsed uint64 `json:"gas_used" gorm:"gas_used"`
|
||||
BlockTimestamp uint64 `json:"block_timestamp" gorm:"block_timestamp"`
|
||||
|
||||
// chunk
|
||||
ChunkHash string `json:"chunk_hash" gorm:"chunk_hash;default:NULL"`
|
||||
@@ -67,7 +68,7 @@ func (o *L2Block) GetL2BlocksLatestHeight(ctx context.Context) (uint64, error) {
|
||||
func (o *L2Block) GetUnchunkedBlocks(ctx context.Context) ([]*types.WrappedBlock, error) {
|
||||
db := o.db.WithContext(ctx)
|
||||
db = db.Model(&L2Block{})
|
||||
db = db.Select("header, transactions, withdraw_trie_root")
|
||||
db = db.Select("header, transactions, withdraw_root")
|
||||
db = db.Where("chunk_hash IS NULL")
|
||||
db = db.Order("number ASC")
|
||||
|
||||
@@ -89,7 +90,7 @@ func (o *L2Block) GetUnchunkedBlocks(ctx context.Context) ([]*types.WrappedBlock
|
||||
return nil, fmt.Errorf("L2Block.GetUnchunkedBlocks error: %w", err)
|
||||
}
|
||||
|
||||
wrappedBlock.WithdrawTrieRoot = common.HexToHash(v.WithdrawTrieRoot)
|
||||
wrappedBlock.WithdrawRoot = common.HexToHash(v.WithdrawRoot)
|
||||
wrappedBlocks = append(wrappedBlocks, &wrappedBlock)
|
||||
}
|
||||
|
||||
@@ -133,7 +134,7 @@ func (o *L2Block) GetL2BlocksInRange(ctx context.Context, startBlockNumber uint6
|
||||
|
||||
db := o.db.WithContext(ctx)
|
||||
db = db.Model(&L2Block{})
|
||||
db = db.Select("header, transactions, withdraw_trie_root")
|
||||
db = db.Select("header, transactions, withdraw_root")
|
||||
db = db.Where("number >= ? AND number <= ?", startBlockNumber, endBlockNumber)
|
||||
db = db.Order("number ASC")
|
||||
|
||||
@@ -160,7 +161,7 @@ func (o *L2Block) GetL2BlocksInRange(ctx context.Context, startBlockNumber uint6
|
||||
return nil, fmt.Errorf("L2Block.GetL2BlocksInRange error: %w, start block: %v, end block: %v", err, startBlockNumber, endBlockNumber)
|
||||
}
|
||||
|
||||
wrappedBlock.WithdrawTrieRoot = common.HexToHash(v.WithdrawTrieRoot)
|
||||
wrappedBlock.WithdrawRoot = common.HexToHash(v.WithdrawRoot)
|
||||
wrappedBlocks = append(wrappedBlocks, &wrappedBlock)
|
||||
}
|
||||
|
||||
@@ -184,15 +185,16 @@ func (o *L2Block) InsertL2Blocks(ctx context.Context, blocks []*types.WrappedBlo
|
||||
}
|
||||
|
||||
l2Block := L2Block{
|
||||
Number: block.Header.Number.Uint64(),
|
||||
Hash: block.Header.Hash().String(),
|
||||
ParentHash: block.Header.ParentHash.String(),
|
||||
Transactions: string(txs),
|
||||
WithdrawTrieRoot: block.WithdrawTrieRoot.Hex(),
|
||||
TxNum: uint32(len(block.Transactions)),
|
||||
GasUsed: block.Header.GasUsed,
|
||||
BlockTimestamp: block.Header.Time,
|
||||
Header: string(header),
|
||||
Number: block.Header.Number.Uint64(),
|
||||
Hash: block.Header.Hash().String(),
|
||||
ParentHash: block.Header.ParentHash.String(),
|
||||
Transactions: string(txs),
|
||||
WithdrawRoot: block.WithdrawRoot.Hex(),
|
||||
StateRoot: block.Header.Root.Hex(),
|
||||
TxNum: uint32(len(block.Transactions)),
|
||||
GasUsed: block.Header.GasUsed,
|
||||
BlockTimestamp: block.Header.Time,
|
||||
Header: string(header),
|
||||
}
|
||||
l2Blocks = append(l2Blocks, l2Block)
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ contract MockBridgeL1 {
|
||||
|
||||
/// @notice Emitted when a batch is finalized.
|
||||
/// @param batchHash The hash of the batch
|
||||
/// @param stateRoot The state root in layer 2 after this batch.
|
||||
/// @param withdrawRoot The merkle root in layer2 after this batch.
|
||||
/// @param stateRoot The state root on layer 2 after this batch.
|
||||
/// @param withdrawRoot The merkle root on layer2 after this batch.
|
||||
event FinalizeBatch(bytes32 indexed batchHash, bytes32 stateRoot, bytes32 withdrawRoot);
|
||||
|
||||
/***********
|
||||
|
||||
@@ -80,8 +80,8 @@ func testImportL2GasPrice(t *testing.T) {
|
||||
Difficulty: big.NewInt(0),
|
||||
BaseFee: big.NewInt(0),
|
||||
},
|
||||
Transactions: nil,
|
||||
WithdrawTrieRoot: common.Hash{},
|
||||
Transactions: nil,
|
||||
WithdrawRoot: common.Hash{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -45,9 +45,9 @@ func testCommitBatchAndFinalizeBatch(t *testing.T) {
|
||||
BaseFee: big.NewInt(0),
|
||||
}
|
||||
wrappedBlocks = append(wrappedBlocks, &types.WrappedBlock{
|
||||
Header: &header,
|
||||
Transactions: nil,
|
||||
WithdrawTrieRoot: common.Hash{},
|
||||
Header: &header,
|
||||
Transactions: nil,
|
||||
WithdrawRoot: common.Hash{},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@ import (
|
||||
const nonZeroByteGas uint64 = 16
|
||||
const zeroByteGas uint64 = 4
|
||||
|
||||
// WrappedBlock contains the block's Header, Transactions and WithdrawTrieRoot hash.
|
||||
// WrappedBlock contains the block's Header, Transactions and WithdrawRoot hash.
|
||||
type WrappedBlock struct {
|
||||
Header *types.Header `json:"header"`
|
||||
// Transactions is only used for recover types.Transactions, the from of types.TransactionData field is missing.
|
||||
Transactions []*types.TransactionData `json:"transactions"`
|
||||
WithdrawTrieRoot common.Hash `json:"withdraw_trie_root,omitempty"`
|
||||
Transactions []*types.TransactionData `json:"transactions"`
|
||||
WithdrawRoot common.Hash `json:"withdraw_trie_root,omitempty"`
|
||||
}
|
||||
|
||||
// NumL1Messages returns the number of L1 messages in this block.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
var tag = "v4.0.28"
|
||||
var tag = "v4.0.30"
|
||||
|
||||
var commit = func() string {
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
> L1ERC1155Gateway
|
||||
|
||||
The `L1ERC1155Gateway` is used to deposit ERC1155 compatible NFT in layer 1 and finalize withdraw the NFTs from layer 2.
|
||||
The `L1ERC1155Gateway` is used to deposit ERC1155 compatible NFT on layer 1 and finalize withdraw the NFTs from layer 2.
|
||||
|
||||
*The deposited NFTs are held in this gateway. On finalizing withdraw, the corresponding NFT will be transfer to the recipient directly. This will be changed if we have more specific scenarios.*
|
||||
|
||||
@@ -24,7 +24,7 @@ Deposit a list of some ERC1155 NFT to caller's account on layer 2.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC1155 NFT in layer 1. |
|
||||
| _token | address | The address of ERC1155 NFT on layer 1. |
|
||||
| _tokenIds | uint256[] | The list of token ids to deposit. |
|
||||
| _amounts | uint256[] | The list of corresponding number of token to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
@@ -43,8 +43,8 @@ Deposit a list of some ERC1155 NFT to a recipient's account on layer 2.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC1155 NFT in layer 1. |
|
||||
| _to | address | The address of recipient in layer 2. |
|
||||
| _token | address | The address of ERC1155 NFT on layer 1. |
|
||||
| _to | address | The address of recipient on layer 2. |
|
||||
| _tokenIds | uint256[] | The list of token ids to deposit. |
|
||||
| _amounts | uint256[] | The list of corresponding number of token to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
@@ -80,8 +80,8 @@ Deposit some ERC1155 NFT to a recipient's account on layer 2.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC1155 NFT in layer 1. |
|
||||
| _to | address | The address of recipient in layer 2. |
|
||||
| _token | address | The address of ERC1155 NFT on layer 1. |
|
||||
| _to | address | The address of recipient on layer 2. |
|
||||
| _tokenId | uint256 | The token id to deposit. |
|
||||
| _amount | uint256 | The amount of token to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
@@ -100,7 +100,7 @@ Deposit some ERC1155 NFT to caller's account on layer 2.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC1155 NFT in layer 1. |
|
||||
| _token | address | The address of ERC1155 NFT on layer 1. |
|
||||
| _tokenId | uint256 | The token id to deposit. |
|
||||
| _amount | uint256 | The amount of token to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
@@ -111,7 +111,7 @@ Deposit some ERC1155 NFT to caller's account on layer 2.
|
||||
function finalizeBatchWithdrawERC1155(address _l1Token, address _l2Token, address _from, address _to, uint256[] _tokenIds, uint256[] _amounts) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC1155 batch withdraw from layer 2 to layer 1 and send fund to recipient's account in layer 1. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC1155Gateway in layer 2.
|
||||
Complete ERC1155 batch withdraw from layer 2 to layer 1 and send fund to recipient's account on layer 1. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC1155Gateway on layer 2.
|
||||
|
||||
|
||||
|
||||
@@ -121,8 +121,8 @@ Complete ERC1155 batch withdraw from layer 2 to layer 1 and send fund to recipie
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding layer 1 token. |
|
||||
| _l2Token | address | The address of corresponding layer 2 token. |
|
||||
| _from | address | The address of account who withdraw the token in layer 2. |
|
||||
| _to | address | The address of recipient in layer 1 to receive the token. |
|
||||
| _from | address | The address of account who withdraw the token on layer 2. |
|
||||
| _to | address | The address of recipient on layer 1 to receive the token. |
|
||||
| _tokenIds | uint256[] | The list of token ids to withdraw. |
|
||||
| _amounts | uint256[] | The list of corresponding number of token to withdraw. |
|
||||
|
||||
@@ -132,7 +132,7 @@ Complete ERC1155 batch withdraw from layer 2 to layer 1 and send fund to recipie
|
||||
function finalizeWithdrawERC1155(address _l1Token, address _l2Token, address _from, address _to, uint256 _tokenId, uint256 _amount) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC1155 withdraw from layer 2 to layer 1 and send fund to recipient's account in layer 1. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC1155Gateway in layer 2.
|
||||
Complete ERC1155 withdraw from layer 2 to layer 1 and send fund to recipient's account on layer 1. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC1155Gateway on layer 2.
|
||||
|
||||
|
||||
|
||||
@@ -142,8 +142,8 @@ Complete ERC1155 withdraw from layer 2 to layer 1 and send fund to recipient'
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding layer 1 token. |
|
||||
| _l2Token | address | The address of corresponding layer 2 token. |
|
||||
| _from | address | The address of account who withdraw the token in layer 2. |
|
||||
| _to | address | The address of recipient in layer 1 to receive the token. |
|
||||
| _from | address | The address of account who withdraw the token on layer 2. |
|
||||
| _to | address | The address of recipient on layer 1 to receive the token. |
|
||||
| _tokenId | uint256 | The token id to withdraw. |
|
||||
| _amount | uint256 | The amount of token to withdraw. |
|
||||
|
||||
@@ -368,8 +368,8 @@ Update layer 2 to layer 2 token mapping.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding ERC1155 token in layer 2. |
|
||||
| _l2Token | address | undefined |
|
||||
| _l1Token | address | The address of ERC1155 token on layer 1. |
|
||||
| _l2Token | address | The address of corresponding ERC1155 token on layer 2. |
|
||||
|
||||
|
||||
|
||||
@@ -381,7 +381,7 @@ Update layer 2 to layer 2 token mapping.
|
||||
event BatchDepositERC1155(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256[] _tokenIds, uint256[] _amounts)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is batch deposited to gateway in layer 1.
|
||||
Emitted when the ERC1155 NFT is batch deposited to gateway on layer 1.
|
||||
|
||||
|
||||
|
||||
@@ -421,7 +421,7 @@ Emitted when some ERC1155 token is refunded.
|
||||
event DepositERC1155(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256 _tokenId, uint256 _amount)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is deposited to gateway in layer 1.
|
||||
Emitted when the ERC1155 NFT is deposited to gateway on layer 1.
|
||||
|
||||
|
||||
|
||||
@@ -442,7 +442,7 @@ Emitted when the ERC1155 NFT is deposited to gateway in layer 1.
|
||||
event FinalizeBatchWithdrawERC1155(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256[] _tokenIds, uint256[] _amounts)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is batch transfered to recipient in layer 1.
|
||||
Emitted when the ERC1155 NFT is batch transfered to recipient on layer 1.
|
||||
|
||||
|
||||
|
||||
@@ -463,7 +463,7 @@ Emitted when the ERC1155 NFT is batch transfered to recipient in layer 1.
|
||||
event FinalizeWithdrawERC1155(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256 _tokenId, uint256 _amount)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is transfered to recipient in layer 1.
|
||||
Emitted when the ERC1155 NFT is transfered to recipient on layer 1.
|
||||
|
||||
|
||||
|
||||
@@ -544,8 +544,8 @@ Emitted when token mapping for ERC1155 token is updated.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding ERC1155 token in layer 2. |
|
||||
| _l2Token | address | undefined |
|
||||
| _l1Token | address | The address of ERC1155 token on layer 1. |
|
||||
| _l2Token | address | The address of corresponding ERC1155 token on layer 2. |
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
> L1ERC721Gateway
|
||||
|
||||
The `L1ERC721Gateway` is used to deposit ERC721 compatible NFT in layer 1 and finalize withdraw the NFTs from layer 2.
|
||||
The `L1ERC721Gateway` is used to deposit ERC721 compatible NFT on layer 1 and finalize withdraw the NFTs from layer 2.
|
||||
|
||||
*The deposited NFTs are held in this gateway. On finalizing withdraw, the corresponding NFT will be transfer to the recipient directly. This will be changed if we have more specific scenarios.*
|
||||
|
||||
@@ -24,8 +24,8 @@ Deposit a list of some ERC721 NFT to a recipient's account on layer 2.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC721 NFT in layer 1. |
|
||||
| _to | address | The address of recipient in layer 2. |
|
||||
| _token | address | The address of ERC721 NFT on layer 1. |
|
||||
| _to | address | The address of recipient on layer 2. |
|
||||
| _tokenIds | uint256[] | The list of token ids to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
|
||||
@@ -43,7 +43,7 @@ Deposit a list of some ERC721 NFT to caller's account on layer 2.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC721 NFT in layer 1. |
|
||||
| _token | address | The address of ERC721 NFT on layer 1. |
|
||||
| _tokenIds | uint256[] | The list of token ids to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
|
||||
@@ -78,8 +78,8 @@ Deposit some ERC721 NFT to a recipient's account on layer 2.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC721 NFT in layer 1. |
|
||||
| _to | address | The address of recipient in layer 2. |
|
||||
| _token | address | The address of ERC721 NFT on layer 1. |
|
||||
| _to | address | The address of recipient on layer 2. |
|
||||
| _tokenId | uint256 | The token id to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
|
||||
@@ -97,7 +97,7 @@ Deposit some ERC721 NFT to caller's account on layer 2.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC721 NFT in layer 1. |
|
||||
| _token | address | The address of ERC721 NFT on layer 1. |
|
||||
| _tokenId | uint256 | The token id to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
|
||||
@@ -107,9 +107,9 @@ Deposit some ERC721 NFT to caller's account on layer 2.
|
||||
function finalizeBatchWithdrawERC721(address _l1Token, address _l2Token, address _from, address _to, uint256[] _tokenIds) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC721 batch withdraw from layer 2 to layer 1 and send NFT to recipient's account in layer 1.
|
||||
Complete ERC721 batch withdraw from layer 2 to layer 1 and send NFT to recipient's account on layer 1.
|
||||
|
||||
*Requirements: - The function should only be called by L1ScrollMessenger. - The function should also only be called by L2ERC721Gateway in layer 2.*
|
||||
*Requirements: - The function should only be called by L1ScrollMessenger. - The function should also only be called by L2ERC721Gateway on layer 2.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
@@ -117,8 +117,8 @@ Complete ERC721 batch withdraw from layer 2 to layer 1 and send NFT to recipient
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding layer 1 token. |
|
||||
| _l2Token | address | The address of corresponding layer 2 token. |
|
||||
| _from | address | The address of account who withdraw the token in layer 2. |
|
||||
| _to | address | The address of recipient in layer 1 to receive the token. |
|
||||
| _from | address | The address of account who withdraw the token on layer 2. |
|
||||
| _to | address | The address of recipient on layer 1 to receive the token. |
|
||||
| _tokenIds | uint256[] | The list of token ids to withdraw. |
|
||||
|
||||
### finalizeWithdrawERC721
|
||||
@@ -127,9 +127,9 @@ Complete ERC721 batch withdraw from layer 2 to layer 1 and send NFT to recipient
|
||||
function finalizeWithdrawERC721(address _l1Token, address _l2Token, address _from, address _to, uint256 _tokenId) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC721 withdraw from layer 2 to layer 1 and send NFT to recipient's account in layer 1.
|
||||
Complete ERC721 withdraw from layer 2 to layer 1 and send NFT to recipient's account on layer 1.
|
||||
|
||||
*Requirements: - The function should only be called by L1ScrollMessenger. - The function should also only be called by L2ERC721Gateway in layer 2.*
|
||||
*Requirements: - The function should only be called by L1ScrollMessenger. - The function should also only be called by L2ERC721Gateway on layer 2.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
@@ -137,8 +137,8 @@ Complete ERC721 withdraw from layer 2 to layer 1 and send NFT to recipient's
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding layer 1 token. |
|
||||
| _l2Token | address | The address of corresponding layer 2 token. |
|
||||
| _from | address | The address of account who withdraw the token in layer 2. |
|
||||
| _to | address | The address of recipient in layer 1 to receive the token. |
|
||||
| _from | address | The address of account who withdraw the token on layer 2. |
|
||||
| _to | address | The address of recipient on layer 1 to receive the token. |
|
||||
| _tokenId | uint256 | The token id to withdraw. |
|
||||
|
||||
### initialize
|
||||
@@ -313,8 +313,8 @@ Update layer 2 to layer 2 token mapping.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding ERC721 token in layer 2. |
|
||||
| _l2Token | address | undefined |
|
||||
| _l1Token | address | The address of ERC721 token on layer 1. |
|
||||
| _l2Token | address | The address of corresponding ERC721 token on layer 2. |
|
||||
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ Update layer 2 to layer 2 token mapping.
|
||||
event BatchDepositERC721(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256[] _tokenIds)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is batch deposited to gateway in layer 1.
|
||||
Emitted when the ERC721 NFT is batch deposited to gateway on layer 1.
|
||||
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@ Emitted when a batch of ERC721 tokens are refunded.
|
||||
event DepositERC721(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256 _tokenId)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is deposited to gateway in layer 1.
|
||||
Emitted when the ERC721 NFT is deposited to gateway on layer 1.
|
||||
|
||||
|
||||
|
||||
@@ -384,7 +384,7 @@ Emitted when the ERC721 NFT is deposited to gateway in layer 1.
|
||||
event FinalizeBatchWithdrawERC721(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256[] _tokenIds)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is batch transfered to recipient in layer 1.
|
||||
Emitted when the ERC721 NFT is batch transfered to recipient on layer 1.
|
||||
|
||||
|
||||
|
||||
@@ -404,7 +404,7 @@ Emitted when the ERC721 NFT is batch transfered to recipient in layer 1.
|
||||
event FinalizeWithdrawERC721(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256 _tokenId)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is transfered to recipient in layer 1.
|
||||
Emitted when the ERC721 NFT is transfered to recipient on layer 1.
|
||||
|
||||
|
||||
|
||||
@@ -483,8 +483,8 @@ Emitted when token mapping for ERC721 token is updated.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding ERC721 token in layer 2. |
|
||||
| _l2Token | address | undefined |
|
||||
| _l1Token | address | The address of ERC721 token on layer 1. |
|
||||
| _l2Token | address | The address of corresponding ERC721 token on layer 2. |
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
> L1StandardERC20Gateway
|
||||
|
||||
The `L1StandardERC20Gateway` is used to deposit standard ERC20 tokens in layer 1 and finalize withdraw the tokens from layer 2.
|
||||
The `L1StandardERC20Gateway` is used to deposit standard ERC20 tokens on layer 1 and finalize withdraw the tokens from layer 2.
|
||||
|
||||
*The deposited ERC20 tokens are held in this gateway. On finalizing withdraw, the corresponding token will be transfer to the recipient directly. Any ERC20 that requires non-standard functionality should use a separate gateway.*
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
> L1WETHGateway
|
||||
|
||||
The `L1WETHGateway` contract is used to deposit `WETH` token in layer 1 and finalize withdraw `WETH` from layer 2.
|
||||
The `L1WETHGateway` contract is used to deposit `WETH` token on layer 1 and finalize withdraw `WETH` from layer 2.
|
||||
|
||||
*The deposited WETH tokens are not held in the gateway. It will first be unwrapped as Ether and then the Ether will be sent to the `L1ScrollMessenger` contract. On finalizing withdraw, the Ether will be transfered from `L1ScrollMessenger`, then wrapped as WETH and finally transfer to recipient.*
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
> L2ERC1155Gateway
|
||||
|
||||
The `L2ERC1155Gateway` is used to withdraw ERC1155 compatible NFTs in layer 2 and finalize deposit the NFTs from layer 1.
|
||||
The `L2ERC1155Gateway` is used to withdraw ERC1155 compatible NFTs on layer 2 and finalize deposit the NFTs from layer 1.
|
||||
|
||||
*The withdrawn NFTs tokens will be burned directly. On finalizing deposit, the corresponding NFT will be minted and transfered to the recipient. This will be changed if we have more specific scenarios.*
|
||||
|
||||
@@ -72,9 +72,9 @@ The address of corresponding L1/L2 Gateway contract.
|
||||
function finalizeBatchDepositERC1155(address _l1Token, address _l2Token, address _from, address _to, uint256[] _tokenIds, uint256[] _amounts) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC1155 deposit from layer 1 to layer 2 and send NFT to recipient's account in layer 2.
|
||||
Complete ERC1155 deposit from layer 1 to layer 2 and send NFT to recipient's account on layer 2.
|
||||
|
||||
*Requirements: - The function should only be called by L2ScrollMessenger. - The function should also only be called by L1ERC1155Gateway in layer 1.*
|
||||
*Requirements: - The function should only be called by L2ScrollMessenger. - The function should also only be called by L1ERC1155Gateway on layer 1.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
@@ -93,9 +93,9 @@ Complete ERC1155 deposit from layer 1 to layer 2 and send NFT to recipient's
|
||||
function finalizeDepositERC1155(address _l1Token, address _l2Token, address _from, address _to, uint256 _tokenId, uint256 _amount) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC1155 deposit from layer 1 to layer 2 and send NFT to recipient's account in layer 2.
|
||||
Complete ERC1155 deposit from layer 1 to layer 2 and send NFT to recipient's account on layer 2.
|
||||
|
||||
*Requirements: - The function should only be called by L2ScrollMessenger. - The function should also only be called by L1ERC1155Gateway in layer 1.*
|
||||
*Requirements: - The function should only be called by L2ScrollMessenger. - The function should also only be called by L1ERC1155Gateway on layer 1.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
@@ -313,8 +313,8 @@ Update layer 2 to layer 1 token mapping.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l2Token | address | undefined |
|
||||
| _l1Token | address | The address of ERC1155 token in layer 1. |
|
||||
| _l2Token | address | The address of corresponding ERC1155 token on layer 2. |
|
||||
| _l1Token | address | The address of ERC1155 token on layer 1. |
|
||||
|
||||
### withdrawERC1155
|
||||
|
||||
@@ -365,7 +365,7 @@ Withdraw some ERC1155 NFT to caller's account on layer 1.
|
||||
event BatchWithdrawERC1155(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256[] tokenIds, uint256[] amounts)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is batch transfered to gateway in layer 2.
|
||||
Emitted when the ERC1155 NFT is batch transfered to gateway on layer 2.
|
||||
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ Emitted when the ERC1155 NFT is batch transfered to gateway in layer 2.
|
||||
event FinalizeBatchDepositERC1155(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256[] tokenIds, uint256[] amounts)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is batch transfered to recipient in layer 2.
|
||||
Emitted when the ERC1155 NFT is batch transfered to recipient on layer 2.
|
||||
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ Emitted when the ERC1155 NFT is batch transfered to recipient in layer 2.
|
||||
event FinalizeDepositERC1155(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 tokenId, uint256 amount)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is transfered to recipient in layer 2.
|
||||
Emitted when the ERC1155 NFT is transfered to recipient on layer 2.
|
||||
|
||||
|
||||
|
||||
@@ -469,8 +469,8 @@ Emitted when token mapping for ERC1155 token is updated.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l2Token | address | undefined |
|
||||
| _l1Token | address | The address of ERC1155 token in layer 1. |
|
||||
| _l2Token | address | The address of corresponding ERC1155 token on layer 2. |
|
||||
| _l1Token | address | The address of ERC1155 token on layer 1. |
|
||||
|
||||
### WithdrawERC1155
|
||||
|
||||
@@ -478,7 +478,7 @@ Emitted when token mapping for ERC1155 token is updated.
|
||||
event WithdrawERC1155(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 tokenId, uint256 amount)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is transfered to gateway in layer 2.
|
||||
Emitted when the ERC1155 NFT is transfered to gateway on layer 2.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
> L2ERC721Gateway
|
||||
|
||||
The `L2ERC721Gateway` is used to withdraw ERC721 compatible NFTs in layer 2 and finalize deposit the NFTs from layer 1.
|
||||
The `L2ERC721Gateway` is used to withdraw ERC721 compatible NFTs on layer 2 and finalize deposit the NFTs from layer 1.
|
||||
|
||||
*The withdrawn NFTs tokens will be burned directly. On finalizing deposit, the corresponding NFT will be minted and transfered to the recipient. This will be changed if we have more specific scenarios.*
|
||||
|
||||
@@ -70,9 +70,9 @@ The address of corresponding L1/L2 Gateway contract.
|
||||
function finalizeBatchDepositERC721(address _l1Token, address _l2Token, address _from, address _to, uint256[] _tokenIds) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC721 deposit from layer 1 to layer 2 and send NFT to recipient's account in layer 2.
|
||||
Complete ERC721 deposit from layer 1 to layer 2 and send NFT to recipient's account on layer 2.
|
||||
|
||||
*Requirements: - The function should only be called by L2ScrollMessenger. - The function should also only be called by L1ERC721Gateway in layer 1.*
|
||||
*Requirements: - The function should only be called by L2ScrollMessenger. - The function should also only be called by L1ERC721Gateway on layer 1.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
@@ -90,9 +90,9 @@ Complete ERC721 deposit from layer 1 to layer 2 and send NFT to recipient's
|
||||
function finalizeDepositERC721(address _l1Token, address _l2Token, address _from, address _to, uint256 _tokenId) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC721 deposit from layer 1 to layer 2 and send NFT to recipient's account in layer 2.
|
||||
Complete ERC721 deposit from layer 1 to layer 2 and send NFT to recipient's account on layer 2.
|
||||
|
||||
*Requirements: - The function should only be called by L2ScrollMessenger. - The function should also only be called by L1ERC721Gateway in layer 1.*
|
||||
*Requirements: - The function should only be called by L2ScrollMessenger. - The function should also only be called by L1ERC721Gateway on layer 1.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
@@ -260,8 +260,8 @@ Update layer 2 to layer 1 token mapping.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l2Token | address | undefined |
|
||||
| _l1Token | address | The address of ERC721 token in layer 1. |
|
||||
| _l2Token | address | The address of corresponding ERC721 token on layer 2. |
|
||||
| _l1Token | address | The address of ERC721 token on layer 1. |
|
||||
|
||||
### withdrawERC721
|
||||
|
||||
@@ -310,7 +310,7 @@ Withdraw some ERC721 NFT to caller's account on layer 1.
|
||||
event BatchWithdrawERC721(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256[] tokenIds)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is batch transfered to gateway in layer 2.
|
||||
Emitted when the ERC721 NFT is batch transfered to gateway on layer 2.
|
||||
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ Emitted when the ERC721 NFT is batch transfered to gateway in layer 2.
|
||||
event FinalizeBatchDepositERC721(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256[] tokenIds)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is batch transfered to recipient in layer 2.
|
||||
Emitted when the ERC721 NFT is batch transfered to recipient on layer 2.
|
||||
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ Emitted when the ERC721 NFT is batch transfered to recipient in layer 2.
|
||||
event FinalizeDepositERC721(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 tokenId)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is transfered to recipient in layer 2.
|
||||
Emitted when the ERC721 NFT is transfered to recipient on layer 2.
|
||||
|
||||
|
||||
|
||||
@@ -411,8 +411,8 @@ Emitted when token mapping for ERC721 token is updated.
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l2Token | address | undefined |
|
||||
| _l1Token | address | The address of ERC721 token in layer 1. |
|
||||
| _l2Token | address | The address of corresponding ERC721 token on layer 2. |
|
||||
| _l1Token | address | The address of ERC721 token on layer 1. |
|
||||
|
||||
### WithdrawERC721
|
||||
|
||||
@@ -420,7 +420,7 @@ Emitted when token mapping for ERC721 token is updated.
|
||||
event WithdrawERC721(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 tokenId)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is transfered to gateway in layer 2.
|
||||
Emitted when the ERC721 NFT is transfered to gateway on layer 2.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
The `L2ScrollMessenger` contract can: 1. send messages from layer 2 to layer 1; 2. relay messages from layer 1 layer 2; 3. drop expired message due to sequencer problems.
|
||||
|
||||
*It should be a predeployed contract in layer 2 and should hold infinite amount of Ether (Specifically, `uint256(-1)`), which can be initialized in Genesis Block.*
|
||||
*It should be a predeployed contract on layer 2 and should hold infinite amount of Ether (Specifically, `uint256(-1)`), which can be initialized in Genesis Block.*
|
||||
|
||||
## Methods
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
> L2StandardERC20Gateway
|
||||
|
||||
The `L2StandardERC20Gateway` is used to withdraw standard ERC20 tokens in layer 2 and finalize deposit the tokens from layer 1.
|
||||
The `L2StandardERC20Gateway` is used to withdraw standard ERC20 tokens on layer 2 and finalize deposit the tokens from layer 1.
|
||||
|
||||
*The withdrawn ERC20 tokens will be burned directly. On finalizing deposit, the corresponding token will be minted and transfered to the recipient. Any ERC20 that requires non-standard functionality should use a separate gateway.*
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
> L2WETHGateway
|
||||
|
||||
The `L2WETHGateway` contract is used to withdraw `WETH` token in layer 2 and finalize deposit `WETH` from layer 1.
|
||||
The `L2WETHGateway` contract is used to withdraw `WETH` token on layer 2 and finalize deposit `WETH` from layer 1.
|
||||
|
||||
*The WETH tokens are not held in the gateway. It will first be unwrapped as Ether and then the Ether will be sent to the `L2ScrollMessenger` contract. On finalizing deposit, the Ether will be transfered from `L2ScrollMessenger`, then wrapped as WETH and finally transfer to recipient.*
|
||||
|
||||
|
||||
@@ -95,16 +95,16 @@ describe("EnforcedTxGateway.spec", async () => {
|
||||
});
|
||||
});
|
||||
|
||||
context("#setPaused", async () => {
|
||||
context("#setPause", async () => {
|
||||
it("should revert, when non-owner call", async () => {
|
||||
await expect(gateway.connect(signer).setPaused(false)).to.revertedWith("Ownable: caller is not the owner");
|
||||
await expect(gateway.connect(signer).setPause(false)).to.revertedWith("Ownable: caller is not the owner");
|
||||
});
|
||||
|
||||
it("should succeed", async () => {
|
||||
expect(await gateway.paused()).to.eq(false);
|
||||
await expect(gateway.setPaused(true)).to.emit(gateway, "Paused").withArgs(deployer.address);
|
||||
await expect(gateway.setPause(true)).to.emit(gateway, "Paused").withArgs(deployer.address);
|
||||
expect(await gateway.paused()).to.eq(true);
|
||||
await expect(gateway.setPaused(false)).to.emit(gateway, "Unpaused").withArgs(deployer.address);
|
||||
await expect(gateway.setPause(false)).to.emit(gateway, "Unpaused").withArgs(deployer.address);
|
||||
expect(await gateway.paused()).to.eq(false);
|
||||
});
|
||||
});
|
||||
@@ -112,7 +112,7 @@ describe("EnforcedTxGateway.spec", async () => {
|
||||
|
||||
context("#sendTransaction, by EOA", async () => {
|
||||
it("should revert, when contract is paused", async () => {
|
||||
await gateway.setPaused(true);
|
||||
await gateway.setPause(true);
|
||||
await expect(
|
||||
gateway.connect(signer)["sendTransaction(address,uint256,uint256,bytes)"](signer.address, 0, 0, "0x")
|
||||
).to.revertedWith("Pausable: paused");
|
||||
@@ -246,7 +246,7 @@ describe("EnforcedTxGateway.spec", async () => {
|
||||
};
|
||||
|
||||
it("should revert, when contract is paused", async () => {
|
||||
await gateway.setPaused(true);
|
||||
await gateway.setPause(true);
|
||||
await expect(
|
||||
gateway
|
||||
.connect(deployer)
|
||||
|
||||
@@ -182,8 +182,8 @@ contract L1ScrollMessenger is PausableUpgradeable, ScrollMessengerBase, IL1Scrol
|
||||
address _refundAddress
|
||||
) external payable override whenNotPaused notInExecution {
|
||||
// We will use a different `queueIndex` for the replaced message. However, the original `queueIndex` or `nonce`
|
||||
// is encoded in the `_message`. We will check the `xDomainCalldata` in layer 2 to avoid duplicated execution.
|
||||
// So, only one message will succeed in layer 2. If one of the message is executed successfully, the other one
|
||||
// is encoded in the `_message`. We will check the `xDomainCalldata` on layer 2 to avoid duplicated execution.
|
||||
// So, only one message will succeed on layer 2. If one of the message is executed successfully, the other one
|
||||
// will revert with "Message was already successfully executed".
|
||||
address _messageQueue = messageQueue;
|
||||
address _counterpart = counterpart;
|
||||
|
||||
@@ -152,7 +152,7 @@ contract EnforcedTxGateway is OwnableUpgradeable, ReentrancyGuardUpgradeable, Pa
|
||||
|
||||
/// @notice Pause or unpause this contract.
|
||||
/// @param _status Pause this contract if it is true, otherwise unpause this contract.
|
||||
function setPaused(bool _status) external onlyOwner {
|
||||
function setPause(bool _status) external onlyOwner {
|
||||
if (_status) {
|
||||
_pause();
|
||||
} else {
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
pragma solidity ^0.8.16;
|
||||
|
||||
/// @title The interface for the ERC1155 cross chain gateway in layer 1.
|
||||
/// @title The interface for the ERC1155 cross chain gateway on layer 1.
|
||||
interface IL1ERC1155Gateway {
|
||||
/**********
|
||||
* Events *
|
||||
**********/
|
||||
|
||||
/// @notice Emitted when the ERC1155 NFT is transfered to recipient in layer 1.
|
||||
/// @param _l1Token The address of ERC1155 NFT in layer 1.
|
||||
/// @param _l2Token The address of ERC1155 NFT in layer 2.
|
||||
/// @param _from The address of sender in layer 2.
|
||||
/// @param _to The address of recipient in layer 1.
|
||||
/// @notice Emitted when the ERC1155 NFT is transfered to recipient on layer 1.
|
||||
/// @param _l1Token The address of ERC1155 NFT on layer 1.
|
||||
/// @param _l2Token The address of ERC1155 NFT on layer 2.
|
||||
/// @param _from The address of sender on layer 2.
|
||||
/// @param _to The address of recipient on layer 1.
|
||||
/// @param _tokenId The token id of the ERC1155 NFT to withdraw from layer 2.
|
||||
/// @param _amount The number of token to withdraw from layer 2.
|
||||
event FinalizeWithdrawERC1155(
|
||||
@@ -24,11 +24,11 @@ interface IL1ERC1155Gateway {
|
||||
uint256 _amount
|
||||
);
|
||||
|
||||
/// @notice Emitted when the ERC1155 NFT is batch transfered to recipient in layer 1.
|
||||
/// @param _l1Token The address of ERC1155 NFT in layer 1.
|
||||
/// @param _l2Token The address of ERC1155 NFT in layer 2.
|
||||
/// @param _from The address of sender in layer 2.
|
||||
/// @param _to The address of recipient in layer 1.
|
||||
/// @notice Emitted when the ERC1155 NFT is batch transfered to recipient on layer 1.
|
||||
/// @param _l1Token The address of ERC1155 NFT on layer 1.
|
||||
/// @param _l2Token The address of ERC1155 NFT on layer 2.
|
||||
/// @param _from The address of sender on layer 2.
|
||||
/// @param _to The address of recipient on layer 1.
|
||||
/// @param _tokenIds The list of token ids of the ERC1155 NFT to withdraw from layer 2.
|
||||
/// @param _amounts The list of corresponding number of token to withdraw from layer 2.
|
||||
event FinalizeBatchWithdrawERC1155(
|
||||
@@ -40,13 +40,13 @@ interface IL1ERC1155Gateway {
|
||||
uint256[] _amounts
|
||||
);
|
||||
|
||||
/// @notice Emitted when the ERC1155 NFT is deposited to gateway in layer 1.
|
||||
/// @param _l1Token The address of ERC1155 NFT in layer 1.
|
||||
/// @param _l2Token The address of ERC1155 NFT in layer 2.
|
||||
/// @param _from The address of sender in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _tokenId The token id of the ERC1155 NFT to deposit in layer 1.
|
||||
/// @param _amount The number of token to deposit in layer 1.
|
||||
/// @notice Emitted when the ERC1155 NFT is deposited to gateway on layer 1.
|
||||
/// @param _l1Token The address of ERC1155 NFT on layer 1.
|
||||
/// @param _l2Token The address of ERC1155 NFT on layer 2.
|
||||
/// @param _from The address of sender on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenId The token id of the ERC1155 NFT to deposit on layer 1.
|
||||
/// @param _amount The number of token to deposit on layer 1.
|
||||
event DepositERC1155(
|
||||
address indexed _l1Token,
|
||||
address indexed _l2Token,
|
||||
@@ -56,13 +56,13 @@ interface IL1ERC1155Gateway {
|
||||
uint256 _amount
|
||||
);
|
||||
|
||||
/// @notice Emitted when the ERC1155 NFT is batch deposited to gateway in layer 1.
|
||||
/// @param _l1Token The address of ERC1155 NFT in layer 1.
|
||||
/// @param _l2Token The address of ERC1155 NFT in layer 2.
|
||||
/// @param _from The address of sender in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _tokenIds The list of token ids of the ERC1155 NFT to deposit in layer 1.
|
||||
/// @param _amounts The list of corresponding number of token to deposit in layer 1.
|
||||
/// @notice Emitted when the ERC1155 NFT is batch deposited to gateway on layer 1.
|
||||
/// @param _l1Token The address of ERC1155 NFT on layer 1.
|
||||
/// @param _l2Token The address of ERC1155 NFT on layer 2.
|
||||
/// @param _from The address of sender on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenIds The list of token ids of the ERC1155 NFT to deposit on layer 1.
|
||||
/// @param _amounts The list of corresponding number of token to deposit on layer 1.
|
||||
event BatchDepositERC1155(
|
||||
address indexed _l1Token,
|
||||
address indexed _l2Token,
|
||||
@@ -91,7 +91,7 @@ interface IL1ERC1155Gateway {
|
||||
*************************/
|
||||
|
||||
/// @notice Deposit some ERC1155 NFT to caller's account on layer 2.
|
||||
/// @param _token The address of ERC1155 NFT in layer 1.
|
||||
/// @param _token The address of ERC1155 NFT on layer 1.
|
||||
/// @param _tokenId The token id to deposit.
|
||||
/// @param _amount The amount of token to deposit.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the deposit on layer 2.
|
||||
@@ -103,8 +103,8 @@ interface IL1ERC1155Gateway {
|
||||
) external payable;
|
||||
|
||||
/// @notice Deposit some ERC1155 NFT to a recipient's account on layer 2.
|
||||
/// @param _token The address of ERC1155 NFT in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _token The address of ERC1155 NFT on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenId The token id to deposit.
|
||||
/// @param _amount The amount of token to deposit.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the deposit on layer 2.
|
||||
@@ -117,7 +117,7 @@ interface IL1ERC1155Gateway {
|
||||
) external payable;
|
||||
|
||||
/// @notice Deposit a list of some ERC1155 NFT to caller's account on layer 2.
|
||||
/// @param _token The address of ERC1155 NFT in layer 1.
|
||||
/// @param _token The address of ERC1155 NFT on layer 1.
|
||||
/// @param _tokenIds The list of token ids to deposit.
|
||||
/// @param _amounts The list of corresponding number of token to deposit.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the deposit on layer 2.
|
||||
@@ -129,8 +129,8 @@ interface IL1ERC1155Gateway {
|
||||
) external payable;
|
||||
|
||||
/// @notice Deposit a list of some ERC1155 NFT to a recipient's account on layer 2.
|
||||
/// @param _token The address of ERC1155 NFT in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _token The address of ERC1155 NFT on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenIds The list of token ids to deposit.
|
||||
/// @param _amounts The list of corresponding number of token to deposit.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the deposit on layer 2.
|
||||
@@ -142,13 +142,13 @@ interface IL1ERC1155Gateway {
|
||||
uint256 _gasLimit
|
||||
) external payable;
|
||||
|
||||
/// @notice Complete ERC1155 withdraw from layer 2 to layer 1 and send fund to recipient's account in layer 1.
|
||||
/// @notice Complete ERC1155 withdraw from layer 2 to layer 1 and send fund to recipient's account on layer 1.
|
||||
/// The function should only be called by L1ScrollMessenger.
|
||||
/// The function should also only be called by L2ERC1155Gateway in layer 2.
|
||||
/// The function should also only be called by L2ERC1155Gateway on layer 2.
|
||||
/// @param _l1Token The address of corresponding layer 1 token.
|
||||
/// @param _l2Token The address of corresponding layer 2 token.
|
||||
/// @param _from The address of account who withdraw the token in layer 2.
|
||||
/// @param _to The address of recipient in layer 1 to receive the token.
|
||||
/// @param _from The address of account who withdraw the token on layer 2.
|
||||
/// @param _to The address of recipient on layer 1 to receive the token.
|
||||
/// @param _tokenId The token id to withdraw.
|
||||
/// @param _amount The amount of token to withdraw.
|
||||
function finalizeWithdrawERC1155(
|
||||
@@ -160,13 +160,13 @@ interface IL1ERC1155Gateway {
|
||||
uint256 _amount
|
||||
) external;
|
||||
|
||||
/// @notice Complete ERC1155 batch withdraw from layer 2 to layer 1 and send fund to recipient's account in layer 1.
|
||||
/// @notice Complete ERC1155 batch withdraw from layer 2 to layer 1 and send fund to recipient's account on layer 1.
|
||||
/// The function should only be called by L1ScrollMessenger.
|
||||
/// The function should also only be called by L2ERC1155Gateway in layer 2.
|
||||
/// The function should also only be called by L2ERC1155Gateway on layer 2.
|
||||
/// @param _l1Token The address of corresponding layer 1 token.
|
||||
/// @param _l2Token The address of corresponding layer 2 token.
|
||||
/// @param _from The address of account who withdraw the token in layer 2.
|
||||
/// @param _to The address of recipient in layer 1 to receive the token.
|
||||
/// @param _from The address of account who withdraw the token on layer 2.
|
||||
/// @param _to The address of recipient on layer 1 to receive the token.
|
||||
/// @param _tokenIds The list of token ids to withdraw.
|
||||
/// @param _amounts The list of corresponding number of token to withdraw.
|
||||
function finalizeBatchWithdrawERC1155(
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
pragma solidity ^0.8.16;
|
||||
|
||||
/// @title The interface for the ERC721 cross chain gateway in layer 1.
|
||||
/// @title The interface for the ERC721 cross chain gateway on layer 1.
|
||||
interface IL1ERC721Gateway {
|
||||
/**********
|
||||
* Events *
|
||||
**********/
|
||||
|
||||
/// @notice Emitted when the ERC721 NFT is transfered to recipient in layer 1.
|
||||
/// @param _l1Token The address of ERC721 NFT in layer 1.
|
||||
/// @param _l2Token The address of ERC721 NFT in layer 2.
|
||||
/// @param _from The address of sender in layer 2.
|
||||
/// @param _to The address of recipient in layer 1.
|
||||
/// @notice Emitted when the ERC721 NFT is transfered to recipient on layer 1.
|
||||
/// @param _l1Token The address of ERC721 NFT on layer 1.
|
||||
/// @param _l2Token The address of ERC721 NFT on layer 2.
|
||||
/// @param _from The address of sender on layer 2.
|
||||
/// @param _to The address of recipient on layer 1.
|
||||
/// @param _tokenId The token id of the ERC721 NFT to withdraw from layer 2.
|
||||
event FinalizeWithdrawERC721(
|
||||
address indexed _l1Token,
|
||||
@@ -22,11 +22,11 @@ interface IL1ERC721Gateway {
|
||||
uint256 _tokenId
|
||||
);
|
||||
|
||||
/// @notice Emitted when the ERC721 NFT is batch transfered to recipient in layer 1.
|
||||
/// @param _l1Token The address of ERC721 NFT in layer 1.
|
||||
/// @param _l2Token The address of ERC721 NFT in layer 2.
|
||||
/// @param _from The address of sender in layer 2.
|
||||
/// @param _to The address of recipient in layer 1.
|
||||
/// @notice Emitted when the ERC721 NFT is batch transfered to recipient on layer 1.
|
||||
/// @param _l1Token The address of ERC721 NFT on layer 1.
|
||||
/// @param _l2Token The address of ERC721 NFT on layer 2.
|
||||
/// @param _from The address of sender on layer 2.
|
||||
/// @param _to The address of recipient on layer 1.
|
||||
/// @param _tokenIds The list of token ids of the ERC721 NFT to withdraw from layer 2.
|
||||
event FinalizeBatchWithdrawERC721(
|
||||
address indexed _l1Token,
|
||||
@@ -36,12 +36,12 @@ interface IL1ERC721Gateway {
|
||||
uint256[] _tokenIds
|
||||
);
|
||||
|
||||
/// @notice Emitted when the ERC721 NFT is deposited to gateway in layer 1.
|
||||
/// @param _l1Token The address of ERC721 NFT in layer 1.
|
||||
/// @param _l2Token The address of ERC721 NFT in layer 2.
|
||||
/// @param _from The address of sender in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _tokenId The token id of the ERC721 NFT to deposit in layer 1.
|
||||
/// @notice Emitted when the ERC721 NFT is deposited to gateway on layer 1.
|
||||
/// @param _l1Token The address of ERC721 NFT on layer 1.
|
||||
/// @param _l2Token The address of ERC721 NFT on layer 2.
|
||||
/// @param _from The address of sender on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenId The token id of the ERC721 NFT to deposit on layer 1.
|
||||
event DepositERC721(
|
||||
address indexed _l1Token,
|
||||
address indexed _l2Token,
|
||||
@@ -50,12 +50,12 @@ interface IL1ERC721Gateway {
|
||||
uint256 _tokenId
|
||||
);
|
||||
|
||||
/// @notice Emitted when the ERC721 NFT is batch deposited to gateway in layer 1.
|
||||
/// @param _l1Token The address of ERC721 NFT in layer 1.
|
||||
/// @param _l2Token The address of ERC721 NFT in layer 2.
|
||||
/// @param _from The address of sender in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _tokenIds The list of token ids of the ERC721 NFT to deposit in layer 1.
|
||||
/// @notice Emitted when the ERC721 NFT is batch deposited to gateway on layer 1.
|
||||
/// @param _l1Token The address of ERC721 NFT on layer 1.
|
||||
/// @param _l2Token The address of ERC721 NFT on layer 2.
|
||||
/// @param _from The address of sender on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenIds The list of token ids of the ERC721 NFT to deposit on layer 1.
|
||||
event BatchDepositERC721(
|
||||
address indexed _l1Token,
|
||||
address indexed _l2Token,
|
||||
@@ -81,7 +81,7 @@ interface IL1ERC721Gateway {
|
||||
*****************************/
|
||||
|
||||
/// @notice Deposit some ERC721 NFT to caller's account on layer 2.
|
||||
/// @param _token The address of ERC721 NFT in layer 1.
|
||||
/// @param _token The address of ERC721 NFT on layer 1.
|
||||
/// @param _tokenId The token id to deposit.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the deposit on layer 2.
|
||||
function depositERC721(
|
||||
@@ -91,8 +91,8 @@ interface IL1ERC721Gateway {
|
||||
) external payable;
|
||||
|
||||
/// @notice Deposit some ERC721 NFT to a recipient's account on layer 2.
|
||||
/// @param _token The address of ERC721 NFT in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _token The address of ERC721 NFT on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenId The token id to deposit.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the deposit on layer 2.
|
||||
function depositERC721(
|
||||
@@ -103,7 +103,7 @@ interface IL1ERC721Gateway {
|
||||
) external payable;
|
||||
|
||||
/// @notice Deposit a list of some ERC721 NFT to caller's account on layer 2.
|
||||
/// @param _token The address of ERC721 NFT in layer 1.
|
||||
/// @param _token The address of ERC721 NFT on layer 1.
|
||||
/// @param _tokenIds The list of token ids to deposit.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the deposit on layer 2.
|
||||
function batchDepositERC721(
|
||||
@@ -113,8 +113,8 @@ interface IL1ERC721Gateway {
|
||||
) external payable;
|
||||
|
||||
/// @notice Deposit a list of some ERC721 NFT to a recipient's account on layer 2.
|
||||
/// @param _token The address of ERC721 NFT in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _token The address of ERC721 NFT on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenIds The list of token ids to deposit.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the deposit on layer 2.
|
||||
function batchDepositERC721(
|
||||
@@ -124,14 +124,14 @@ interface IL1ERC721Gateway {
|
||||
uint256 _gasLimit
|
||||
) external payable;
|
||||
|
||||
/// @notice Complete ERC721 withdraw from layer 2 to layer 1 and send NFT to recipient's account in layer 1.
|
||||
/// @notice Complete ERC721 withdraw from layer 2 to layer 1 and send NFT to recipient's account on layer 1.
|
||||
/// @dev Requirements:
|
||||
/// - The function should only be called by L1ScrollMessenger.
|
||||
/// - The function should also only be called by L2ERC721Gateway in layer 2.
|
||||
/// - The function should also only be called by L2ERC721Gateway on layer 2.
|
||||
/// @param _l1Token The address of corresponding layer 1 token.
|
||||
/// @param _l2Token The address of corresponding layer 2 token.
|
||||
/// @param _from The address of account who withdraw the token in layer 2.
|
||||
/// @param _to The address of recipient in layer 1 to receive the token.
|
||||
/// @param _from The address of account who withdraw the token on layer 2.
|
||||
/// @param _to The address of recipient on layer 1 to receive the token.
|
||||
/// @param _tokenId The token id to withdraw.
|
||||
function finalizeWithdrawERC721(
|
||||
address _l1Token,
|
||||
@@ -141,14 +141,14 @@ interface IL1ERC721Gateway {
|
||||
uint256 _tokenId
|
||||
) external;
|
||||
|
||||
/// @notice Complete ERC721 batch withdraw from layer 2 to layer 1 and send NFT to recipient's account in layer 1.
|
||||
/// @notice Complete ERC721 batch withdraw from layer 2 to layer 1 and send NFT to recipient's account on layer 1.
|
||||
/// @dev Requirements:
|
||||
/// - The function should only be called by L1ScrollMessenger.
|
||||
/// - The function should also only be called by L2ERC721Gateway in layer 2.
|
||||
/// - The function should also only be called by L2ERC721Gateway on layer 2.
|
||||
/// @param _l1Token The address of corresponding layer 1 token.
|
||||
/// @param _l2Token The address of corresponding layer 2 token.
|
||||
/// @param _from The address of account who withdraw the token in layer 2.
|
||||
/// @param _to The address of recipient in layer 1 to receive the token.
|
||||
/// @param _from The address of account who withdraw the token on layer 2.
|
||||
/// @param _to The address of recipient on layer 1 to receive the token.
|
||||
/// @param _tokenIds The list of token ids to withdraw.
|
||||
function finalizeBatchWithdrawERC721(
|
||||
address _l1Token,
|
||||
|
||||
@@ -14,7 +14,7 @@ import {ScrollGatewayBase} from "../../libraries/gateway/ScrollGatewayBase.sol";
|
||||
import {L1ERC20Gateway} from "./L1ERC20Gateway.sol";
|
||||
|
||||
/// @title L1CustomERC20Gateway
|
||||
/// @notice The `L1CustomERC20Gateway` is used to deposit custom ERC20 compatible tokens in layer 1 and
|
||||
/// @notice The `L1CustomERC20Gateway` is used to deposit custom ERC20 compatible tokens on layer 1 and
|
||||
/// finalize withdraw the tokens from layer 2.
|
||||
/// @dev The deposited tokens are held in this gateway. On finalizing withdraw, the corresponding
|
||||
/// tokens will be transfer to the recipient directly.
|
||||
@@ -26,8 +26,8 @@ contract L1CustomERC20Gateway is OwnableUpgradeable, ScrollGatewayBase, L1ERC20G
|
||||
**********/
|
||||
|
||||
/// @notice Emitted when token mapping for ERC20 token is updated.
|
||||
/// @param _l1Token The address of ERC20 token in layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC20 token in layer 2.
|
||||
/// @param _l1Token The address of ERC20 token on layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC20 token on layer 2.
|
||||
event UpdateTokenMapping(address _l1Token, address _l2Token);
|
||||
|
||||
/*************
|
||||
@@ -74,8 +74,8 @@ contract L1CustomERC20Gateway is OwnableUpgradeable, ScrollGatewayBase, L1ERC20G
|
||||
************************/
|
||||
|
||||
/// @notice Update layer 1 to layer 2 token mapping.
|
||||
/// @param _l1Token The address of ERC20 token in layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC20 token in layer 2.
|
||||
/// @param _l1Token The address of ERC20 token on layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC20 token on layer 2.
|
||||
function updateTokenMapping(address _l1Token, address _l2Token) external onlyOwner {
|
||||
require(_l2Token != address(0), "token address cannot be 0");
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import {IMessageDropCallback} from "../../libraries/callbacks/IMessageDropCallba
|
||||
import {ScrollGatewayBase} from "../../libraries/gateway/ScrollGatewayBase.sol";
|
||||
|
||||
/// @title L1ERC1155Gateway
|
||||
/// @notice The `L1ERC1155Gateway` is used to deposit ERC1155 compatible NFT in layer 1 and
|
||||
/// @notice The `L1ERC1155Gateway` is used to deposit ERC1155 compatible NFT on layer 1 and
|
||||
/// finalize withdraw the NFTs from layer 2.
|
||||
/// @dev The deposited NFTs are held in this gateway. On finalizing withdraw, the corresponding
|
||||
/// NFT will be transfer to the recipient directly.
|
||||
@@ -32,8 +32,8 @@ contract L1ERC1155Gateway is
|
||||
**********/
|
||||
|
||||
/// @notice Emitted when token mapping for ERC1155 token is updated.
|
||||
/// @param _l1Token The address of ERC1155 token in layer 1.
|
||||
/// @param _l1Token The address of corresponding ERC1155 token in layer 2.
|
||||
/// @param _l1Token The address of ERC1155 token on layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC1155 token on layer 2.
|
||||
event UpdateTokenMapping(address _l1Token, address _l2Token);
|
||||
|
||||
/*************
|
||||
@@ -172,8 +172,8 @@ contract L1ERC1155Gateway is
|
||||
************************/
|
||||
|
||||
/// @notice Update layer 2 to layer 2 token mapping.
|
||||
/// @param _l1Token The address of ERC1155 token in layer 1.
|
||||
/// @param _l1Token The address of corresponding ERC1155 token in layer 2.
|
||||
/// @param _l1Token The address of ERC1155 token on layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC1155 token on layer 2.
|
||||
function updateTokenMapping(address _l1Token, address _l2Token) external onlyOwner {
|
||||
require(_l2Token != address(0), "token address cannot be 0");
|
||||
|
||||
@@ -187,8 +187,8 @@ contract L1ERC1155Gateway is
|
||||
**********************/
|
||||
|
||||
/// @dev Internal function to deposit ERC1155 NFT to layer 2.
|
||||
/// @param _token The address of ERC1155 NFT in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _token The address of ERC1155 NFT on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenId The token id to deposit.
|
||||
/// @param _amount The amount of token to deposit.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the deposit on layer 2.
|
||||
@@ -220,8 +220,8 @@ contract L1ERC1155Gateway is
|
||||
}
|
||||
|
||||
/// @dev Internal function to batch deposit ERC1155 NFT to layer 2.
|
||||
/// @param _token The address of ERC1155 NFT in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _token The address of ERC1155 NFT on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenIds The list of token ids to deposit.
|
||||
/// @param _amounts The list of corresponding number of token to deposit.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the deposit on layer 2.
|
||||
|
||||
@@ -14,7 +14,7 @@ import {IMessageDropCallback} from "../../libraries/callbacks/IMessageDropCallba
|
||||
import {ScrollGatewayBase} from "../../libraries/gateway/ScrollGatewayBase.sol";
|
||||
|
||||
/// @title L1ERC721Gateway
|
||||
/// @notice The `L1ERC721Gateway` is used to deposit ERC721 compatible NFT in layer 1 and
|
||||
/// @notice The `L1ERC721Gateway` is used to deposit ERC721 compatible NFT on layer 1 and
|
||||
/// finalize withdraw the NFTs from layer 2.
|
||||
/// @dev The deposited NFTs are held in this gateway. On finalizing withdraw, the corresponding
|
||||
/// NFT will be transfer to the recipient directly.
|
||||
@@ -32,8 +32,8 @@ contract L1ERC721Gateway is
|
||||
**********/
|
||||
|
||||
/// @notice Emitted when token mapping for ERC721 token is updated.
|
||||
/// @param _l1Token The address of ERC721 token in layer 1.
|
||||
/// @param _l1Token The address of corresponding ERC721 token in layer 2.
|
||||
/// @param _l1Token The address of ERC721 token on layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC721 token on layer 2.
|
||||
event UpdateTokenMapping(address _l1Token, address _l2Token);
|
||||
|
||||
/*************
|
||||
@@ -168,8 +168,8 @@ contract L1ERC721Gateway is
|
||||
************************/
|
||||
|
||||
/// @notice Update layer 2 to layer 2 token mapping.
|
||||
/// @param _l1Token The address of ERC721 token in layer 1.
|
||||
/// @param _l1Token The address of corresponding ERC721 token in layer 2.
|
||||
/// @param _l1Token The address of ERC721 token on layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC721 token on layer 2.
|
||||
function updateTokenMapping(address _l1Token, address _l2Token) external onlyOwner {
|
||||
require(_l2Token != address(0), "token address cannot be 0");
|
||||
|
||||
@@ -183,8 +183,8 @@ contract L1ERC721Gateway is
|
||||
**********************/
|
||||
|
||||
/// @dev Internal function to deposit ERC721 NFT to layer 2.
|
||||
/// @param _token The address of ERC721 NFT in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _token The address of ERC721 NFT on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenId The token id to deposit.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the deposit on layer 2.
|
||||
function _depositERC721(
|
||||
@@ -212,8 +212,8 @@ contract L1ERC721Gateway is
|
||||
}
|
||||
|
||||
/// @dev Internal function to batch deposit ERC721 NFT to layer 2.
|
||||
/// @param _token The address of ERC721 NFT in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _token The address of ERC721 NFT on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenIds The list of token ids to deposit.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the deposit on layer 2.
|
||||
function _batchDepositERC721(
|
||||
|
||||
@@ -14,7 +14,7 @@ import {ScrollGatewayBase} from "../../libraries/gateway/ScrollGatewayBase.sol";
|
||||
// solhint-disable avoid-low-level-calls
|
||||
|
||||
/// @title L1ETHGateway
|
||||
/// @notice The `L1ETHGateway` is used to deposit ETH in layer 1 and
|
||||
/// @notice The `L1ETHGateway` is used to deposit ETH on layer 1 and
|
||||
/// finalize withdraw ETH from layer 2.
|
||||
/// @dev The deposited ETH tokens are held in this gateway. On finalizing withdraw, the corresponding
|
||||
/// ETH will be transfer to the recipient directly.
|
||||
|
||||
@@ -16,7 +16,7 @@ import {ScrollGatewayBase} from "../../libraries/gateway/ScrollGatewayBase.sol";
|
||||
import {L1ERC20Gateway} from "./L1ERC20Gateway.sol";
|
||||
|
||||
/// @title L1StandardERC20Gateway
|
||||
/// @notice The `L1StandardERC20Gateway` is used to deposit standard ERC20 tokens in layer 1 and
|
||||
/// @notice The `L1StandardERC20Gateway` is used to deposit standard ERC20 tokens on layer 1 and
|
||||
/// finalize withdraw the tokens from layer 2.
|
||||
/// @dev The deposited ERC20 tokens are held in this gateway. On finalizing withdraw, the corresponding
|
||||
/// token will be transfer to the recipient directly. Any ERC20 that requires non-standard functionality
|
||||
|
||||
@@ -15,7 +15,7 @@ import {ScrollGatewayBase} from "../../libraries/gateway/ScrollGatewayBase.sol";
|
||||
import {L1ERC20Gateway} from "./L1ERC20Gateway.sol";
|
||||
|
||||
/// @title L1WETHGateway
|
||||
/// @notice The `L1WETHGateway` contract is used to deposit `WETH` token in layer 1 and
|
||||
/// @notice The `L1WETHGateway` contract is used to deposit `WETH` token on layer 1 and
|
||||
/// finalize withdraw `WETH` from layer 2.
|
||||
/// @dev The deposited WETH tokens are not held in the gateway. It will first be unwrapped
|
||||
/// as Ether and then the Ether will be sent to the `L1ScrollMessenger` contract.
|
||||
|
||||
@@ -20,8 +20,8 @@ interface IScrollChain {
|
||||
/// @notice Emitted when a batch is finalized.
|
||||
/// @param batchIndex The index of the batch.
|
||||
/// @param batchHash The hash of the batch
|
||||
/// @param stateRoot The state root in layer 2 after this batch.
|
||||
/// @param withdrawRoot The merkle root in layer2 after this batch.
|
||||
/// @param stateRoot The state root on layer 2 after this batch.
|
||||
/// @param withdrawRoot The merkle root on layer2 after this batch.
|
||||
event FinalizeBatch(uint256 indexed batchIndex, bytes32 indexed batchHash, bytes32 stateRoot, bytes32 withdrawRoot);
|
||||
|
||||
/*************************
|
||||
|
||||
@@ -24,7 +24,7 @@ import {ScrollMessengerBase} from "../libraries/ScrollMessengerBase.sol";
|
||||
/// 2. relay messages from layer 1 layer 2;
|
||||
/// 3. drop expired message due to sequencer problems.
|
||||
///
|
||||
/// @dev It should be a predeployed contract in layer 2 and should hold infinite amount
|
||||
/// @dev It should be a predeployed contract on layer 2 and should hold infinite amount
|
||||
/// of Ether (Specifically, `uint256(-1)`), which can be initialized in Genesis Block.
|
||||
contract L2ScrollMessenger is ScrollMessengerBase, PausableUpgradeable, IL2ScrollMessenger {
|
||||
/**********
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
pragma solidity ^0.8.16;
|
||||
|
||||
/// @title The interface for the ERC1155 cross chain gateway in layer 2.
|
||||
/// @title The interface for the ERC1155 cross chain gateway on layer 2.
|
||||
interface IL2ERC1155Gateway {
|
||||
/**********
|
||||
* Events *
|
||||
**********/
|
||||
|
||||
/// @notice Emitted when the ERC1155 NFT is transfered to recipient in layer 2.
|
||||
/// @param l1Token The address of ERC1155 NFT in layer 1.
|
||||
/// @param l2Token The address of ERC1155 NFT in layer 2.
|
||||
/// @param from The address of sender in layer 1.
|
||||
/// @param to The address of recipient in layer 2.
|
||||
/// @param tokenId The token id of the ERC1155 NFT deposited in layer 1.
|
||||
/// @notice Emitted when the ERC1155 NFT is transfered to recipient on layer 2.
|
||||
/// @param l1Token The address of ERC1155 NFT on layer 1.
|
||||
/// @param l2Token The address of ERC1155 NFT on layer 2.
|
||||
/// @param from The address of sender on layer 1.
|
||||
/// @param to The address of recipient on layer 2.
|
||||
/// @param tokenId The token id of the ERC1155 NFT deposited on layer 1.
|
||||
/// @param amount The amount of token deposited.
|
||||
event FinalizeDepositERC1155(
|
||||
address indexed l1Token,
|
||||
@@ -24,12 +24,12 @@ interface IL2ERC1155Gateway {
|
||||
uint256 amount
|
||||
);
|
||||
|
||||
/// @notice Emitted when the ERC1155 NFT is batch transfered to recipient in layer 2.
|
||||
/// @param l1Token The address of ERC1155 NFT in layer 1.
|
||||
/// @param l2Token The address of ERC1155 NFT in layer 2.
|
||||
/// @param from The address of sender in layer 1.
|
||||
/// @param to The address of recipient in layer 2.
|
||||
/// @param tokenIds The list of token ids of the ERC1155 NFT deposited in layer 1.
|
||||
/// @notice Emitted when the ERC1155 NFT is batch transfered to recipient on layer 2.
|
||||
/// @param l1Token The address of ERC1155 NFT on layer 1.
|
||||
/// @param l2Token The address of ERC1155 NFT on layer 2.
|
||||
/// @param from The address of sender on layer 1.
|
||||
/// @param to The address of recipient on layer 2.
|
||||
/// @param tokenIds The list of token ids of the ERC1155 NFT deposited on layer 1.
|
||||
/// @param amounts The list of corresponding amounts deposited.
|
||||
event FinalizeBatchDepositERC1155(
|
||||
address indexed l1Token,
|
||||
@@ -40,12 +40,12 @@ interface IL2ERC1155Gateway {
|
||||
uint256[] amounts
|
||||
);
|
||||
|
||||
/// @notice Emitted when the ERC1155 NFT is transfered to gateway in layer 2.
|
||||
/// @param l1Token The address of ERC1155 NFT in layer 1.
|
||||
/// @param l2Token The address of ERC1155 NFT in layer 2.
|
||||
/// @param from The address of sender in layer 2.
|
||||
/// @param to The address of recipient in layer 1.
|
||||
/// @param tokenId The token id of the ERC1155 NFT to withdraw in layer 2.
|
||||
/// @notice Emitted when the ERC1155 NFT is transfered to gateway on layer 2.
|
||||
/// @param l1Token The address of ERC1155 NFT on layer 1.
|
||||
/// @param l2Token The address of ERC1155 NFT on layer 2.
|
||||
/// @param from The address of sender on layer 2.
|
||||
/// @param to The address of recipient on layer 1.
|
||||
/// @param tokenId The token id of the ERC1155 NFT to withdraw on layer 2.
|
||||
/// @param amount The amount of token to withdraw.
|
||||
event WithdrawERC1155(
|
||||
address indexed l1Token,
|
||||
@@ -56,12 +56,12 @@ interface IL2ERC1155Gateway {
|
||||
uint256 amount
|
||||
);
|
||||
|
||||
/// @notice Emitted when the ERC1155 NFT is batch transfered to gateway in layer 2.
|
||||
/// @param l1Token The address of ERC1155 NFT in layer 1.
|
||||
/// @param l2Token The address of ERC1155 NFT in layer 2.
|
||||
/// @param from The address of sender in layer 2.
|
||||
/// @param to The address of recipient in layer 1.
|
||||
/// @param tokenIds The list of token ids of the ERC1155 NFT to withdraw in layer 2.
|
||||
/// @notice Emitted when the ERC1155 NFT is batch transfered to gateway on layer 2.
|
||||
/// @param l1Token The address of ERC1155 NFT on layer 1.
|
||||
/// @param l2Token The address of ERC1155 NFT on layer 2.
|
||||
/// @param from The address of sender on layer 2.
|
||||
/// @param to The address of recipient on layer 1.
|
||||
/// @param tokenIds The list of token ids of the ERC1155 NFT to withdraw on layer 2.
|
||||
/// @param amounts The list of corresponding amounts to withdraw.
|
||||
event BatchWithdrawERC1155(
|
||||
address indexed l1Token,
|
||||
@@ -77,7 +77,7 @@ interface IL2ERC1155Gateway {
|
||||
*****************************/
|
||||
|
||||
/// @notice Withdraw some ERC1155 NFT to caller's account on layer 1.
|
||||
/// @param token The address of ERC1155 NFT in layer 2.
|
||||
/// @param token The address of ERC1155 NFT on layer 2.
|
||||
/// @param tokenId The token id to withdraw.
|
||||
/// @param amount The amount of token to withdraw.
|
||||
/// @param gasLimit Unused, but included for potential forward compatibility considerations.
|
||||
@@ -89,8 +89,8 @@ interface IL2ERC1155Gateway {
|
||||
) external payable;
|
||||
|
||||
/// @notice Withdraw some ERC1155 NFT to caller's account on layer 1.
|
||||
/// @param token The address of ERC1155 NFT in layer 2.
|
||||
/// @param to The address of recipient in layer 1.
|
||||
/// @param token The address of ERC1155 NFT on layer 2.
|
||||
/// @param to The address of recipient on layer 1.
|
||||
/// @param tokenId The token id to withdraw.
|
||||
/// @param amount The amount of token to withdraw.
|
||||
/// @param gasLimit Unused, but included for potential forward compatibility considerations.
|
||||
@@ -103,7 +103,7 @@ interface IL2ERC1155Gateway {
|
||||
) external payable;
|
||||
|
||||
/// @notice Batch withdraw a list of ERC1155 NFT to caller's account on layer 1.
|
||||
/// @param token The address of ERC1155 NFT in layer 2.
|
||||
/// @param token The address of ERC1155 NFT on layer 2.
|
||||
/// @param tokenIds The list of token ids to withdraw.
|
||||
/// @param amounts The list of corresponding amounts to withdraw.
|
||||
/// @param gasLimit Unused, but included for potential forward compatibility considerations.
|
||||
@@ -115,8 +115,8 @@ interface IL2ERC1155Gateway {
|
||||
) external payable;
|
||||
|
||||
/// @notice Batch withdraw a list of ERC1155 NFT to caller's account on layer 1.
|
||||
/// @param token The address of ERC1155 NFT in layer 2.
|
||||
/// @param to The address of recipient in layer 1.
|
||||
/// @param token The address of ERC1155 NFT on layer 2.
|
||||
/// @param to The address of recipient on layer 1.
|
||||
/// @param tokenIds The list of token ids to withdraw.
|
||||
/// @param amounts The list of corresponding amounts to withdraw.
|
||||
/// @param gasLimit Unused, but included for potential forward compatibility considerations.
|
||||
@@ -128,14 +128,14 @@ interface IL2ERC1155Gateway {
|
||||
uint256 gasLimit
|
||||
) external payable;
|
||||
|
||||
/// @notice Complete ERC1155 deposit from layer 1 to layer 2 and send NFT to recipient's account in layer 2.
|
||||
/// @notice Complete ERC1155 deposit from layer 1 to layer 2 and send NFT to recipient's account on layer 2.
|
||||
/// @dev Requirements:
|
||||
/// - The function should only be called by L2ScrollMessenger.
|
||||
/// - The function should also only be called by L1ERC1155Gateway in layer 1.
|
||||
/// - The function should also only be called by L1ERC1155Gateway on layer 1.
|
||||
/// @param l1Token The address of corresponding layer 1 token.
|
||||
/// @param l2Token The address of corresponding layer 2 token.
|
||||
/// @param from The address of account who deposits the token in layer 1.
|
||||
/// @param to The address of recipient in layer 2 to receive the token.
|
||||
/// @param from The address of account who deposits the token on layer 1.
|
||||
/// @param to The address of recipient on layer 2 to receive the token.
|
||||
/// @param tokenId The token id to deposit.
|
||||
/// @param amount The amount of token to deposit.
|
||||
function finalizeDepositERC1155(
|
||||
@@ -147,14 +147,14 @@ interface IL2ERC1155Gateway {
|
||||
uint256 amount
|
||||
) external;
|
||||
|
||||
/// @notice Complete ERC1155 deposit from layer 1 to layer 2 and send NFT to recipient's account in layer 2.
|
||||
/// @notice Complete ERC1155 deposit from layer 1 to layer 2 and send NFT to recipient's account on layer 2.
|
||||
/// @dev Requirements:
|
||||
/// - The function should only be called by L2ScrollMessenger.
|
||||
/// - The function should also only be called by L1ERC1155Gateway in layer 1.
|
||||
/// - The function should also only be called by L1ERC1155Gateway on layer 1.
|
||||
/// @param l1Token The address of corresponding layer 1 token.
|
||||
/// @param l2Token The address of corresponding layer 2 token.
|
||||
/// @param from The address of account who deposits the token in layer 1.
|
||||
/// @param to The address of recipient in layer 2 to receive the token.
|
||||
/// @param from The address of account who deposits the token on layer 1.
|
||||
/// @param to The address of recipient on layer 2 to receive the token.
|
||||
/// @param tokenIds The list of token ids to deposit.
|
||||
/// @param amounts The list of corresponding amounts to deposit.
|
||||
function finalizeBatchDepositERC1155(
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
pragma solidity ^0.8.16;
|
||||
|
||||
/// @title The interface for the ERC721 cross chain gateway in layer 2.
|
||||
/// @title The interface for the ERC721 cross chain gateway on layer 2.
|
||||
interface IL2ERC721Gateway {
|
||||
/**********
|
||||
* Events *
|
||||
**********/
|
||||
|
||||
/// @notice Emitted when the ERC721 NFT is transfered to recipient in layer 2.
|
||||
/// @param l1Token The address of ERC721 NFT in layer 1.
|
||||
/// @param l2Token The address of ERC721 NFT in layer 2.
|
||||
/// @param from The address of sender in layer 1.
|
||||
/// @param to The address of recipient in layer 2.
|
||||
/// @param tokenId The token id of the ERC721 NFT deposited in layer 1.
|
||||
/// @notice Emitted when the ERC721 NFT is transfered to recipient on layer 2.
|
||||
/// @param l1Token The address of ERC721 NFT on layer 1.
|
||||
/// @param l2Token The address of ERC721 NFT on layer 2.
|
||||
/// @param from The address of sender on layer 1.
|
||||
/// @param to The address of recipient on layer 2.
|
||||
/// @param tokenId The token id of the ERC721 NFT deposited on layer 1.
|
||||
event FinalizeDepositERC721(
|
||||
address indexed l1Token,
|
||||
address indexed l2Token,
|
||||
@@ -22,12 +22,12 @@ interface IL2ERC721Gateway {
|
||||
uint256 tokenId
|
||||
);
|
||||
|
||||
/// @notice Emitted when the ERC721 NFT is batch transfered to recipient in layer 2.
|
||||
/// @param l1Token The address of ERC721 NFT in layer 1.
|
||||
/// @param l2Token The address of ERC721 NFT in layer 2.
|
||||
/// @param from The address of sender in layer 1.
|
||||
/// @param to The address of recipient in layer 2.
|
||||
/// @param tokenIds The list of token ids of the ERC721 NFT deposited in layer 1.
|
||||
/// @notice Emitted when the ERC721 NFT is batch transfered to recipient on layer 2.
|
||||
/// @param l1Token The address of ERC721 NFT on layer 1.
|
||||
/// @param l2Token The address of ERC721 NFT on layer 2.
|
||||
/// @param from The address of sender on layer 1.
|
||||
/// @param to The address of recipient on layer 2.
|
||||
/// @param tokenIds The list of token ids of the ERC721 NFT deposited on layer 1.
|
||||
event FinalizeBatchDepositERC721(
|
||||
address indexed l1Token,
|
||||
address indexed l2Token,
|
||||
@@ -36,12 +36,12 @@ interface IL2ERC721Gateway {
|
||||
uint256[] tokenIds
|
||||
);
|
||||
|
||||
/// @notice Emitted when the ERC721 NFT is transfered to gateway in layer 2.
|
||||
/// @param l1Token The address of ERC721 NFT in layer 1.
|
||||
/// @param l2Token The address of ERC721 NFT in layer 2.
|
||||
/// @param from The address of sender in layer 2.
|
||||
/// @param to The address of recipient in layer 1.
|
||||
/// @param tokenId The token id of the ERC721 NFT to withdraw in layer 2.
|
||||
/// @notice Emitted when the ERC721 NFT is transfered to gateway on layer 2.
|
||||
/// @param l1Token The address of ERC721 NFT on layer 1.
|
||||
/// @param l2Token The address of ERC721 NFT on layer 2.
|
||||
/// @param from The address of sender on layer 2.
|
||||
/// @param to The address of recipient on layer 1.
|
||||
/// @param tokenId The token id of the ERC721 NFT to withdraw on layer 2.
|
||||
event WithdrawERC721(
|
||||
address indexed l1Token,
|
||||
address indexed l2Token,
|
||||
@@ -50,12 +50,12 @@ interface IL2ERC721Gateway {
|
||||
uint256 tokenId
|
||||
);
|
||||
|
||||
/// @notice Emitted when the ERC721 NFT is batch transfered to gateway in layer 2.
|
||||
/// @param l1Token The address of ERC721 NFT in layer 1.
|
||||
/// @param l2Token The address of ERC721 NFT in layer 2.
|
||||
/// @param from The address of sender in layer 2.
|
||||
/// @param to The address of recipient in layer 1.
|
||||
/// @param tokenIds The list of token ids of the ERC721 NFT to withdraw in layer 2.
|
||||
/// @notice Emitted when the ERC721 NFT is batch transfered to gateway on layer 2.
|
||||
/// @param l1Token The address of ERC721 NFT on layer 1.
|
||||
/// @param l2Token The address of ERC721 NFT on layer 2.
|
||||
/// @param from The address of sender on layer 2.
|
||||
/// @param to The address of recipient on layer 1.
|
||||
/// @param tokenIds The list of token ids of the ERC721 NFT to withdraw on layer 2.
|
||||
event BatchWithdrawERC721(
|
||||
address indexed l1Token,
|
||||
address indexed l2Token,
|
||||
@@ -69,7 +69,7 @@ interface IL2ERC721Gateway {
|
||||
*****************************/
|
||||
|
||||
/// @notice Withdraw some ERC721 NFT to caller's account on layer 1.
|
||||
/// @param token The address of ERC721 NFT in layer 2.
|
||||
/// @param token The address of ERC721 NFT on layer 2.
|
||||
/// @param tokenId The token id to withdraw.
|
||||
/// @param gasLimit Unused, but included for potential forward compatibility considerations.
|
||||
function withdrawERC721(
|
||||
@@ -79,8 +79,8 @@ interface IL2ERC721Gateway {
|
||||
) external payable;
|
||||
|
||||
/// @notice Withdraw some ERC721 NFT to caller's account on layer 1.
|
||||
/// @param token The address of ERC721 NFT in layer 2.
|
||||
/// @param to The address of recipient in layer 1.
|
||||
/// @param token The address of ERC721 NFT on layer 2.
|
||||
/// @param to The address of recipient on layer 1.
|
||||
/// @param tokenId The token id to withdraw.
|
||||
/// @param gasLimit Unused, but included for potential forward compatibility considerations.
|
||||
function withdrawERC721(
|
||||
@@ -91,7 +91,7 @@ interface IL2ERC721Gateway {
|
||||
) external payable;
|
||||
|
||||
/// @notice Batch withdraw a list of ERC721 NFT to caller's account on layer 1.
|
||||
/// @param token The address of ERC721 NFT in layer 2.
|
||||
/// @param token The address of ERC721 NFT on layer 2.
|
||||
/// @param tokenIds The list of token ids to withdraw.
|
||||
/// @param gasLimit Unused, but included for potential forward compatibility considerations.
|
||||
function batchWithdrawERC721(
|
||||
@@ -101,8 +101,8 @@ interface IL2ERC721Gateway {
|
||||
) external payable;
|
||||
|
||||
/// @notice Batch withdraw a list of ERC721 NFT to caller's account on layer 1.
|
||||
/// @param token The address of ERC721 NFT in layer 2.
|
||||
/// @param to The address of recipient in layer 1.
|
||||
/// @param token The address of ERC721 NFT on layer 2.
|
||||
/// @param to The address of recipient on layer 1.
|
||||
/// @param tokenIds The list of token ids to withdraw.
|
||||
/// @param gasLimit Unused, but included for potential forward compatibility considerations.
|
||||
function batchWithdrawERC721(
|
||||
@@ -112,14 +112,14 @@ interface IL2ERC721Gateway {
|
||||
uint256 gasLimit
|
||||
) external payable;
|
||||
|
||||
/// @notice Complete ERC721 deposit from layer 1 to layer 2 and send NFT to recipient's account in layer 2.
|
||||
/// @notice Complete ERC721 deposit from layer 1 to layer 2 and send NFT to recipient's account on layer 2.
|
||||
/// @dev Requirements:
|
||||
/// - The function should only be called by L2ScrollMessenger.
|
||||
/// - The function should also only be called by L1ERC721Gateway in layer 1.
|
||||
/// - The function should also only be called by L1ERC721Gateway on layer 1.
|
||||
/// @param l1Token The address of corresponding layer 1 token.
|
||||
/// @param l2Token The address of corresponding layer 2 token.
|
||||
/// @param from The address of account who withdraw the token in layer 1.
|
||||
/// @param to The address of recipient in layer 2 to receive the token.
|
||||
/// @param from The address of account who withdraw the token on layer 1.
|
||||
/// @param to The address of recipient on layer 2 to receive the token.
|
||||
/// @param tokenId The token id to withdraw.
|
||||
function finalizeDepositERC721(
|
||||
address l1Token,
|
||||
@@ -129,14 +129,14 @@ interface IL2ERC721Gateway {
|
||||
uint256 tokenId
|
||||
) external;
|
||||
|
||||
/// @notice Complete ERC721 deposit from layer 1 to layer 2 and send NFT to recipient's account in layer 2.
|
||||
/// @notice Complete ERC721 deposit from layer 1 to layer 2 and send NFT to recipient's account on layer 2.
|
||||
/// @dev Requirements:
|
||||
/// - The function should only be called by L2ScrollMessenger.
|
||||
/// - The function should also only be called by L1ERC721Gateway in layer 1.
|
||||
/// - The function should also only be called by L1ERC721Gateway on layer 1.
|
||||
/// @param l1Token The address of corresponding layer 1 token.
|
||||
/// @param l2Token The address of corresponding layer 2 token.
|
||||
/// @param from The address of account who withdraw the token in layer 1.
|
||||
/// @param to The address of recipient in layer 2 to receive the token.
|
||||
/// @param from The address of account who withdraw the token on layer 1.
|
||||
/// @param to The address of recipient on layer 2 to receive the token.
|
||||
/// @param tokenIds The list of token ids to withdraw.
|
||||
function finalizeBatchDepositERC721(
|
||||
address l1Token,
|
||||
|
||||
@@ -12,7 +12,7 @@ import {ScrollGatewayBase, IScrollGateway} from "../../libraries/gateway/ScrollG
|
||||
import {IScrollERC20} from "../../libraries/token/IScrollERC20.sol";
|
||||
|
||||
/// @title L2ERC20Gateway
|
||||
/// @notice The `L2ERC20Gateway` is used to withdraw custom ERC20 compatible tokens in layer 2 and
|
||||
/// @notice The `L2ERC20Gateway` is used to withdraw custom ERC20 compatible tokens on layer 2 and
|
||||
/// finalize deposit the tokens from layer 1.
|
||||
/// @dev The withdrawn tokens tokens will be burned directly. On finalizing deposit, the corresponding
|
||||
/// tokens will be minted and transfered to the recipient.
|
||||
@@ -22,8 +22,8 @@ contract L2CustomERC20Gateway is OwnableUpgradeable, ScrollGatewayBase, L2ERC20G
|
||||
**********/
|
||||
|
||||
/// @notice Emitted when token mapping for ERC20 token is updated.
|
||||
/// @param _l2Token The address of corresponding ERC20 token in layer 2.
|
||||
/// @param _l1Token The address of ERC20 token in layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC20 token on layer 2.
|
||||
/// @param _l1Token The address of ERC20 token on layer 1.
|
||||
event UpdateTokenMapping(address _l2Token, address _l1Token);
|
||||
|
||||
/*************
|
||||
@@ -95,8 +95,8 @@ contract L2CustomERC20Gateway is OwnableUpgradeable, ScrollGatewayBase, L2ERC20G
|
||||
************************/
|
||||
|
||||
/// @notice Update layer 2 to layer 1 token mapping.
|
||||
/// @param _l2Token The address of corresponding ERC20 token in layer 2.
|
||||
/// @param _l1Token The address of ERC20 token in layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC20 token on layer 2.
|
||||
/// @param _l1Token The address of ERC20 token on layer 1.
|
||||
function updateTokenMapping(address _l2Token, address _l1Token) external onlyOwner {
|
||||
require(_l1Token != address(0), "token address cannot be 0");
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import {ScrollGatewayBase, IScrollGateway} from "../../libraries/gateway/ScrollG
|
||||
import {IScrollERC1155} from "../../libraries/token/IScrollERC1155.sol";
|
||||
|
||||
/// @title L2ERC1155Gateway
|
||||
/// @notice The `L2ERC1155Gateway` is used to withdraw ERC1155 compatible NFTs in layer 2 and
|
||||
/// @notice The `L2ERC1155Gateway` is used to withdraw ERC1155 compatible NFTs on layer 2 and
|
||||
/// finalize deposit the NFTs from layer 1.
|
||||
/// @dev The withdrawn NFTs tokens will be burned directly. On finalizing deposit, the corresponding
|
||||
/// NFT will be minted and transfered to the recipient.
|
||||
@@ -25,8 +25,8 @@ contract L2ERC1155Gateway is OwnableUpgradeable, ERC1155HolderUpgradeable, Scrol
|
||||
**********/
|
||||
|
||||
/// @notice Emitted when token mapping for ERC1155 token is updated.
|
||||
/// @param _l1Token The address of corresponding ERC1155 token in layer 2.
|
||||
/// @param _l1Token The address of ERC1155 token in layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC1155 token on layer 2.
|
||||
/// @param _l1Token The address of ERC1155 token on layer 1.
|
||||
event UpdateTokenMapping(address _l2Token, address _l1Token);
|
||||
|
||||
/*************
|
||||
@@ -137,8 +137,8 @@ contract L2ERC1155Gateway is OwnableUpgradeable, ERC1155HolderUpgradeable, Scrol
|
||||
************************/
|
||||
|
||||
/// @notice Update layer 2 to layer 1 token mapping.
|
||||
/// @param _l1Token The address of corresponding ERC1155 token in layer 2.
|
||||
/// @param _l1Token The address of ERC1155 token in layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC1155 token on layer 2.
|
||||
/// @param _l1Token The address of ERC1155 token on layer 1.
|
||||
function updateTokenMapping(address _l2Token, address _l1Token) external onlyOwner {
|
||||
require(_l1Token != address(0), "token address cannot be 0");
|
||||
|
||||
@@ -152,8 +152,8 @@ contract L2ERC1155Gateway is OwnableUpgradeable, ERC1155HolderUpgradeable, Scrol
|
||||
**********************/
|
||||
|
||||
/// @dev Internal function to withdraw ERC1155 NFT to layer 2.
|
||||
/// @param _token The address of ERC1155 NFT in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _token The address of ERC1155 NFT on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenId The token id to withdraw.
|
||||
/// @param _amount The amount of token to withdraw.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the withdraw on layer 2.
|
||||
@@ -185,8 +185,8 @@ contract L2ERC1155Gateway is OwnableUpgradeable, ERC1155HolderUpgradeable, Scrol
|
||||
}
|
||||
|
||||
/// @dev Internal function to batch withdraw ERC1155 NFT to layer 2.
|
||||
/// @param _token The address of ERC1155 NFT in layer 1.
|
||||
/// @param _to The address of recipient in layer 2.
|
||||
/// @param _token The address of ERC1155 NFT on layer 1.
|
||||
/// @param _to The address of recipient on layer 2.
|
||||
/// @param _tokenIds The list of token ids to withdraw.
|
||||
/// @param _amounts The list of corresponding number of token to withdraw.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the withdraw on layer 1.
|
||||
|
||||
@@ -13,7 +13,7 @@ import {ScrollGatewayBase, IScrollGateway} from "../../libraries/gateway/ScrollG
|
||||
import {IScrollERC721} from "../../libraries/token/IScrollERC721.sol";
|
||||
|
||||
/// @title L2ERC721Gateway
|
||||
/// @notice The `L2ERC721Gateway` is used to withdraw ERC721 compatible NFTs in layer 2 and
|
||||
/// @notice The `L2ERC721Gateway` is used to withdraw ERC721 compatible NFTs on layer 2 and
|
||||
/// finalize deposit the NFTs from layer 1.
|
||||
/// @dev The withdrawn NFTs tokens will be burned directly. On finalizing deposit, the corresponding
|
||||
/// NFT will be minted and transfered to the recipient.
|
||||
@@ -25,8 +25,8 @@ contract L2ERC721Gateway is OwnableUpgradeable, ERC721HolderUpgradeable, ScrollG
|
||||
**********/
|
||||
|
||||
/// @notice Emitted when token mapping for ERC721 token is updated.
|
||||
/// @param _l1Token The address of corresponding ERC721 token in layer 2.
|
||||
/// @param _l1Token The address of ERC721 token in layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC721 token on layer 2.
|
||||
/// @param _l1Token The address of ERC721 token on layer 1.
|
||||
event UpdateTokenMapping(address _l2Token, address _l1Token);
|
||||
|
||||
/*************
|
||||
@@ -132,8 +132,8 @@ contract L2ERC721Gateway is OwnableUpgradeable, ERC721HolderUpgradeable, ScrollG
|
||||
************************/
|
||||
|
||||
/// @notice Update layer 2 to layer 1 token mapping.
|
||||
/// @param _l1Token The address of corresponding ERC721 token in layer 2.
|
||||
/// @param _l1Token The address of ERC721 token in layer 1.
|
||||
/// @param _l2Token The address of corresponding ERC721 token on layer 2.
|
||||
/// @param _l1Token The address of ERC721 token on layer 1.
|
||||
function updateTokenMapping(address _l2Token, address _l1Token) external onlyOwner {
|
||||
require(_l1Token != address(0), "token address cannot be 0");
|
||||
|
||||
@@ -147,8 +147,8 @@ contract L2ERC721Gateway is OwnableUpgradeable, ERC721HolderUpgradeable, ScrollG
|
||||
**********************/
|
||||
|
||||
/// @dev Internal function to withdraw ERC721 NFT to layer 1.
|
||||
/// @param _token The address of ERC721 NFT in layer 2.
|
||||
/// @param _to The address of recipient in layer 1.
|
||||
/// @param _token The address of ERC721 NFT on layer 2.
|
||||
/// @param _to The address of recipient on layer 1.
|
||||
/// @param _tokenId The token id to withdraw.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the withdraw on layer 1.
|
||||
function _withdrawERC721(
|
||||
@@ -178,8 +178,8 @@ contract L2ERC721Gateway is OwnableUpgradeable, ERC721HolderUpgradeable, ScrollG
|
||||
}
|
||||
|
||||
/// @dev Internal function to batch withdraw ERC721 NFT to layer 1.
|
||||
/// @param _token The address of ERC721 NFT in layer 2.
|
||||
/// @param _to The address of recipient in layer 1.
|
||||
/// @param _token The address of ERC721 NFT on layer 2.
|
||||
/// @param _to The address of recipient on layer 1.
|
||||
/// @param _tokenIds The list of token ids to withdraw.
|
||||
/// @param _gasLimit Estimated gas limit required to complete the withdraw on layer 1.
|
||||
function _batchWithdrawERC721(
|
||||
|
||||
@@ -11,7 +11,7 @@ import {IL2ETHGateway} from "./IL2ETHGateway.sol";
|
||||
import {ScrollGatewayBase} from "../../libraries/gateway/ScrollGatewayBase.sol";
|
||||
|
||||
/// @title L2ETHGateway
|
||||
/// @notice The `L2ETHGateway` contract is used to withdraw ETH token in layer 2 and
|
||||
/// @notice The `L2ETHGateway` contract is used to withdraw ETH token on layer 2 and
|
||||
/// finalize deposit ETH from layer 1.
|
||||
/// @dev The ETH are not held in the gateway. The ETH will be sent to the `L2ScrollMessenger` contract.
|
||||
/// On finalizing deposit, the Ether will be transfered from `L2ScrollMessenger`, then transfer to recipient.
|
||||
|
||||
@@ -16,7 +16,7 @@ import {IScrollStandardERC20Factory} from "../../libraries/token/IScrollStandard
|
||||
import {ScrollGatewayBase, IScrollGateway} from "../../libraries/gateway/ScrollGatewayBase.sol";
|
||||
|
||||
/// @title L2StandardERC20Gateway
|
||||
/// @notice The `L2StandardERC20Gateway` is used to withdraw standard ERC20 tokens in layer 2 and
|
||||
/// @notice The `L2StandardERC20Gateway` is used to withdraw standard ERC20 tokens on layer 2 and
|
||||
/// finalize deposit the tokens from layer 1.
|
||||
/// @dev The withdrawn ERC20 tokens will be burned directly. On finalizing deposit, the corresponding
|
||||
/// token will be minted and transfered to the recipient. Any ERC20 that requires non-standard functionality
|
||||
|
||||
@@ -13,7 +13,7 @@ import {IL1ERC20Gateway} from "../../L1/gateways/IL1ERC20Gateway.sol";
|
||||
import {ScrollGatewayBase, IScrollGateway} from "../../libraries/gateway/ScrollGatewayBase.sol";
|
||||
|
||||
/// @title L2WETHGateway
|
||||
/// @notice The `L2WETHGateway` contract is used to withdraw `WETH` token in layer 2 and
|
||||
/// @notice The `L2WETHGateway` contract is used to withdraw `WETH` token on layer 2 and
|
||||
/// finalize deposit `WETH` from layer 1.
|
||||
/// @dev The WETH tokens are not held in the gateway. It will first be unwrapped as Ether and
|
||||
/// then the Ether will be sent to the `L2ScrollMessenger` contract.
|
||||
|
||||
@@ -15,7 +15,7 @@ import {ScrollGatewayBase, IScrollGateway} from "../../../libraries/gateway/Scro
|
||||
import {L2ERC20Gateway} from "../L2ERC20Gateway.sol";
|
||||
|
||||
/// @title L2USDCGateway
|
||||
/// @notice The `L2USDCGateway` contract is used to withdraw `USDC` token in layer 2 and
|
||||
/// @notice The `L2USDCGateway` contract is used to withdraw `USDC` token on layer 2 and
|
||||
/// finalize deposit `USDC` from layer 1.
|
||||
contract L2USDCGateway is OwnableUpgradeable, ScrollGatewayBase, L2ERC20Gateway {
|
||||
using SafeERC20Upgradeable for IERC20Upgradeable;
|
||||
|
||||
@@ -30,6 +30,7 @@ type Batch struct {
|
||||
EndChunkHash string `json:"end_chunk_hash" gorm:"column:end_chunk_hash"`
|
||||
StateRoot string `json:"state_root" gorm:"column:state_root"`
|
||||
WithdrawRoot string `json:"withdraw_root" gorm:"column:withdraw_root"`
|
||||
ParentBatchHash string `json:"parent_batch_hash" gorm:"column:parent_batch_hash"`
|
||||
BatchHeader []byte `json:"batch_header" gorm:"column:batch_header"`
|
||||
|
||||
// proof
|
||||
@@ -48,7 +49,7 @@ type Batch struct {
|
||||
FinalizedAt *time.Time `json:"finalized_at" gorm:"column:finalized_at;default:NULL"`
|
||||
|
||||
// gas oracle
|
||||
OracleStatus int16 `json:"oracle_status" gorm:"column:oracle_status;default:1;default:1"`
|
||||
OracleStatus int16 `json:"oracle_status" gorm:"column:oracle_status;default:1"`
|
||||
OracleTxHash string `json:"oracle_tx_hash" gorm:"column:oracle_tx_hash;default:NULL"`
|
||||
|
||||
// metadata
|
||||
@@ -131,7 +132,7 @@ func (o *Batch) GetLatestBatch(ctx context.Context) (*Batch, error) {
|
||||
|
||||
// InsertBatch inserts a new batch into the database.
|
||||
// for unit test
|
||||
func (o *Batch) InsertBatch(ctx context.Context, startChunkIndex, endChunkIndex uint64, startChunkHash, endChunkHash string, chunks []*types.Chunk) (*Batch, error) {
|
||||
func (o *Batch) InsertBatch(ctx context.Context, startChunkIndex, endChunkIndex uint64, startChunkHash, endChunkHash string, chunks []*types.Chunk, dbTX ...*gorm.DB) (*Batch, error) {
|
||||
if len(chunks) == 0 {
|
||||
return nil, errors.New("invalid args")
|
||||
}
|
||||
@@ -184,14 +185,20 @@ func (o *Batch) InsertBatch(ctx context.Context, startChunkIndex, endChunkIndex
|
||||
EndChunkHash: endChunkHash,
|
||||
EndChunkIndex: endChunkIndex,
|
||||
StateRoot: chunks[numChunks-1].Blocks[lastChunkBlockNum-1].Header.Root.Hex(),
|
||||
WithdrawRoot: chunks[numChunks-1].Blocks[lastChunkBlockNum-1].WithdrawTrieRoot.Hex(),
|
||||
WithdrawRoot: chunks[numChunks-1].Blocks[lastChunkBlockNum-1].WithdrawRoot.Hex(),
|
||||
ParentBatchHash: parentBatchHash.Hex(),
|
||||
BatchHeader: batchHeader.Encode(),
|
||||
ChunkProofsStatus: int16(types.ChunkProofsStatusPending),
|
||||
ProvingStatus: int16(types.ProvingTaskUnassigned),
|
||||
RollupStatus: int16(types.RollupPending),
|
||||
OracleStatus: int16(types.GasOraclePending),
|
||||
}
|
||||
|
||||
db := o.db.WithContext(ctx)
|
||||
db := o.db
|
||||
if len(dbTX) > 0 && dbTX[0] != nil {
|
||||
db = dbTX[0]
|
||||
}
|
||||
db.WithContext(ctx)
|
||||
db = db.Model(&Batch{})
|
||||
|
||||
if err := db.Create(&newBatch).Error; err != nil {
|
||||
|
||||
@@ -27,7 +27,11 @@ type Chunk struct {
|
||||
EndBlockHash string `json:"end_block_hash" gorm:"column:end_block_hash"`
|
||||
StartBlockTime uint64 `json:"start_block_time" gorm:"column:start_block_time"`
|
||||
TotalL1MessagesPoppedBefore uint64 `json:"total_l1_messages_popped_before" gorm:"column:total_l1_messages_popped_before"`
|
||||
TotalL1MessagesPoppedInChunk uint64 `json:"total_l1_messages_popped_in_chunk" gorm:"column:total_l1_messages_popped_in_chunk"`
|
||||
TotalL1MessagesPoppedInChunk uint32 `json:"total_l1_messages_popped_in_chunk" gorm:"column:total_l1_messages_popped_in_chunk"`
|
||||
ParentChunkHash string `json:"parent_chunk_hash" gorm:"column:parent_chunk_hash"`
|
||||
StateRoot string `json:"state_root" gorm:"column:state_root"`
|
||||
ParentChunkStateRoot string `json:"parent_chunk_state_root" gorm:"column:parent_chunk_state_root"`
|
||||
WithdrawRoot string `json:"withdraw_root" gorm:"column:withdraw_root"`
|
||||
|
||||
// proof
|
||||
ProvingStatus int16 `json:"proving_status" gorm:"column:proving_status;default:1"`
|
||||
@@ -177,17 +181,19 @@ func (o *Chunk) GetChunkBatchHash(ctx context.Context, chunkHash string) (string
|
||||
|
||||
// InsertChunk inserts a new chunk into the database.
|
||||
// for unit test
|
||||
func (o *Chunk) InsertChunk(ctx context.Context, chunk *types.Chunk) (*Chunk, error) {
|
||||
func (o *Chunk) InsertChunk(ctx context.Context, chunk *types.Chunk, dbTX ...*gorm.DB) (*Chunk, error) {
|
||||
if chunk == nil || len(chunk.Blocks) == 0 {
|
||||
return nil, errors.New("invalid args")
|
||||
}
|
||||
|
||||
var chunkIndex uint64
|
||||
var totalL1MessagePoppedBefore uint64
|
||||
var parentChunkHash string
|
||||
var parentChunkStateRoot string
|
||||
parentChunk, err := o.GetLatestChunk(ctx)
|
||||
if err != nil && !errors.Is(errors.Unwrap(err), gorm.ErrRecordNotFound) {
|
||||
log.Error("failed to get latest chunk", "err", err)
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("Chunk.InsertChunk error: %w", err)
|
||||
}
|
||||
|
||||
// if parentChunk==nil then err==gorm.ErrRecordNotFound, which means there's
|
||||
@@ -195,13 +201,15 @@ func (o *Chunk) InsertChunk(ctx context.Context, chunk *types.Chunk) (*Chunk, er
|
||||
// if parentChunk!=nil then err=nil, then we fill the parentChunk-related data into the creating chunk
|
||||
if parentChunk != nil {
|
||||
chunkIndex = parentChunk.Index + 1
|
||||
totalL1MessagePoppedBefore = parentChunk.TotalL1MessagesPoppedBefore + parentChunk.TotalL1MessagesPoppedInChunk
|
||||
totalL1MessagePoppedBefore = parentChunk.TotalL1MessagesPoppedBefore + uint64(parentChunk.TotalL1MessagesPoppedInChunk)
|
||||
parentChunkHash = parentChunk.Hash
|
||||
parentChunkStateRoot = parentChunk.StateRoot
|
||||
}
|
||||
|
||||
hash, err := chunk.Hash(totalL1MessagePoppedBefore)
|
||||
if err != nil {
|
||||
log.Error("failed to get chunk hash", "err", err)
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("Chunk.InsertChunk error: %w", err)
|
||||
}
|
||||
|
||||
var totalL2TxGas uint64
|
||||
@@ -229,16 +237,23 @@ func (o *Chunk) InsertChunk(ctx context.Context, chunk *types.Chunk) (*Chunk, er
|
||||
TotalL1CommitGas: totalL1CommitGas,
|
||||
StartBlockTime: chunk.Blocks[0].Header.Time,
|
||||
TotalL1MessagesPoppedBefore: totalL1MessagePoppedBefore,
|
||||
TotalL1MessagesPoppedInChunk: chunk.NumL1Messages(totalL1MessagePoppedBefore),
|
||||
TotalL1MessagesPoppedInChunk: uint32(chunk.NumL1Messages(totalL1MessagePoppedBefore)),
|
||||
ParentChunkHash: parentChunkHash,
|
||||
StateRoot: chunk.Blocks[numBlocks-1].Header.Root.Hex(),
|
||||
ParentChunkStateRoot: parentChunkStateRoot,
|
||||
WithdrawRoot: chunk.Blocks[numBlocks-1].WithdrawRoot.Hex(),
|
||||
ProvingStatus: int16(types.ProvingTaskUnassigned),
|
||||
}
|
||||
|
||||
db := o.db.WithContext(ctx)
|
||||
db := o.db
|
||||
if len(dbTX) > 0 && dbTX[0] != nil {
|
||||
db = dbTX[0]
|
||||
}
|
||||
db = db.WithContext(ctx)
|
||||
db = db.Model(&Chunk{})
|
||||
|
||||
if err := db.Create(&newChunk).Error; err != nil {
|
||||
log.Error("failed to insert chunk", "hash", hash, "err", err)
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("Chunk.InsertChunk error: %w, chunk hash: %v", err, newChunk.Hash)
|
||||
}
|
||||
|
||||
return &newChunk, nil
|
||||
|
||||
@@ -19,15 +19,16 @@ type L2Block struct {
|
||||
db *gorm.DB `gorm:"column:-"`
|
||||
|
||||
// block
|
||||
Number uint64 `json:"number" gorm:"number"`
|
||||
Hash string `json:"hash" gorm:"hash"`
|
||||
ParentHash string `json:"parent_hash" gorm:"parent_hash"`
|
||||
Header string `json:"header" gorm:"header"`
|
||||
Transactions string `json:"transactions" gorm:"transactions"`
|
||||
WithdrawTrieRoot string `json:"withdraw_trie_root" gorm:"withdraw_trie_root"`
|
||||
TxNum uint32 `json:"tx_num" gorm:"tx_num"`
|
||||
GasUsed uint64 `json:"gas_used" gorm:"gas_used"`
|
||||
BlockTimestamp uint64 `json:"block_timestamp" gorm:"block_timestamp"`
|
||||
Number uint64 `json:"number" gorm:"number"`
|
||||
Hash string `json:"hash" gorm:"hash"`
|
||||
ParentHash string `json:"parent_hash" gorm:"parent_hash"`
|
||||
Header string `json:"header" gorm:"header"`
|
||||
Transactions string `json:"transactions" gorm:"transactions"`
|
||||
WithdrawRoot string `json:"withdraw_root" gorm:"withdraw_root"`
|
||||
StateRoot string `json:"state_root" gorm:"state_root"`
|
||||
TxNum uint32 `json:"tx_num" gorm:"tx_num"`
|
||||
GasUsed uint64 `json:"gas_used" gorm:"gas_used"`
|
||||
BlockTimestamp uint64 `json:"block_timestamp" gorm:"block_timestamp"`
|
||||
|
||||
// chunk
|
||||
ChunkHash string `json:"chunk_hash" gorm:"chunk_hash;default:NULL"`
|
||||
@@ -53,7 +54,7 @@ func (*L2Block) TableName() string {
|
||||
func (o *L2Block) GetL2BlocksByChunkHash(ctx context.Context, chunkHash string) ([]*types.WrappedBlock, error) {
|
||||
db := o.db.WithContext(ctx)
|
||||
db = db.Model(&L2Block{})
|
||||
db = db.Select("header, transactions, withdraw_trie_root")
|
||||
db = db.Select("header, transactions, withdraw_root")
|
||||
db = db.Where("chunk_hash = ?", chunkHash)
|
||||
db = db.Order("number ASC")
|
||||
|
||||
@@ -75,7 +76,7 @@ func (o *L2Block) GetL2BlocksByChunkHash(ctx context.Context, chunkHash string)
|
||||
return nil, fmt.Errorf("L2Block.GetL2BlocksByChunkHash error: %w, chunk hash: %v", err, chunkHash)
|
||||
}
|
||||
|
||||
wrappedBlock.WithdrawTrieRoot = common.HexToHash(v.WithdrawTrieRoot)
|
||||
wrappedBlock.WithdrawRoot = common.HexToHash(v.WithdrawRoot)
|
||||
wrappedBlocks = append(wrappedBlocks, &wrappedBlock)
|
||||
}
|
||||
|
||||
@@ -83,31 +84,33 @@ func (o *L2Block) GetL2BlocksByChunkHash(ctx context.Context, chunkHash string)
|
||||
}
|
||||
|
||||
// InsertL2Blocks inserts l2 blocks into the "l2_block" table.
|
||||
// for unit test
|
||||
func (o *L2Block) InsertL2Blocks(ctx context.Context, blocks []*types.WrappedBlock) error {
|
||||
var l2Blocks []L2Block
|
||||
for _, block := range blocks {
|
||||
header, err := json.Marshal(block.Header)
|
||||
if err != nil {
|
||||
log.Error("failed to marshal block header", "hash", block.Header.Hash().String(), "err", err)
|
||||
return fmt.Errorf("L2Block.InsertL2Blocks error: %w, block hash: %v", err, block.Header.Hash().String())
|
||||
return fmt.Errorf("L2Block.InsertL2Blocks error: %w", err)
|
||||
}
|
||||
|
||||
txs, err := json.Marshal(block.Transactions)
|
||||
if err != nil {
|
||||
log.Error("failed to marshal transactions", "hash", block.Header.Hash().String(), "err", err)
|
||||
return fmt.Errorf("L2Block.InsertL2Blocks error: %w, block hash: %v", err, block.Header.Hash().String())
|
||||
return fmt.Errorf("L2Block.InsertL2Blocks error: %w", err)
|
||||
}
|
||||
|
||||
l2Block := L2Block{
|
||||
Number: block.Header.Number.Uint64(),
|
||||
Hash: block.Header.Hash().String(),
|
||||
ParentHash: block.Header.ParentHash.String(),
|
||||
Transactions: string(txs),
|
||||
WithdrawTrieRoot: block.WithdrawTrieRoot.Hex(),
|
||||
TxNum: uint32(len(block.Transactions)),
|
||||
GasUsed: block.Header.GasUsed,
|
||||
BlockTimestamp: block.Header.Time,
|
||||
Header: string(header),
|
||||
Number: block.Header.Number.Uint64(),
|
||||
Hash: block.Header.Hash().String(),
|
||||
ParentHash: block.Header.ParentHash.String(),
|
||||
Transactions: string(txs),
|
||||
WithdrawRoot: block.WithdrawRoot.Hex(),
|
||||
StateRoot: block.Header.Root.Hex(),
|
||||
TxNum: uint32(len(block.Transactions)),
|
||||
GasUsed: block.Header.GasUsed,
|
||||
BlockTimestamp: block.Header.Time,
|
||||
Header: string(header),
|
||||
}
|
||||
l2Blocks = append(l2Blocks, l2Block)
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
type WrappedBlock struct {
|
||||
Header *types.Header `json:"header"`
|
||||
// Transactions is only used for recover types.Transactions, the from of types.TransactionData field is missing.
|
||||
Transactions []*types.TransactionData `json:"transactions"`
|
||||
WithdrawTrieRoot common.Hash `json:"withdraw_trie_root,omitempty"`
|
||||
Transactions []*types.TransactionData `json:"transactions"`
|
||||
WithdrawRoot common.Hash `json:"withdraw_trie_root,omitempty"`
|
||||
}
|
||||
|
||||
// BatchInfo contains the BlockBatch's main info
|
||||
|
||||
@@ -24,13 +24,13 @@ comment
|
||||
on column l1_message.status is 'undefined, pending, submitted, confirmed, failed, expired, relay_failed';
|
||||
|
||||
create unique index l1_message_hash_uindex
|
||||
on l1_message (msg_hash);
|
||||
on l1_message (msg_hash) where deleted_at IS NULL;
|
||||
|
||||
create unique index l1_message_nonce_uindex
|
||||
on l1_message (queue_index);
|
||||
on l1_message (queue_index) where deleted_at IS NULL;
|
||||
|
||||
create index l1_message_height_index
|
||||
on l1_message (height);
|
||||
on l1_message (height) where deleted_at IS NULL;
|
||||
|
||||
-- +goose StatementEnd
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ comment
|
||||
on column l1_block.oracle_status is 'undefined, pending, importing, imported, failed';
|
||||
|
||||
create unique index l1_block_hash_uindex
|
||||
on l1_block (hash);
|
||||
on l1_block (hash) where deleted_at IS NULL;
|
||||
|
||||
create unique index l1_block_number_uindex
|
||||
on l1_block (number);
|
||||
on l1_block (number) where deleted_at IS NULL;
|
||||
|
||||
-- +goose StatementEnd
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ create table l2_block
|
||||
parent_hash VARCHAR NOT NULL,
|
||||
header TEXT NOT NULL,
|
||||
transactions TEXT NOT NULL,
|
||||
withdraw_trie_root VARCHAR NOT NULL,
|
||||
withdraw_root VARCHAR NOT NULL,
|
||||
state_root VARCHAR NOT NULL,
|
||||
tx_num INTEGER NOT NULL,
|
||||
gas_used BIGINT NOT NULL,
|
||||
block_timestamp NUMERIC NOT NULL,
|
||||
@@ -24,13 +25,13 @@ create table l2_block
|
||||
);
|
||||
|
||||
create unique index l2_block_hash_uindex
|
||||
on l2_block (hash);
|
||||
on l2_block (hash) where deleted_at IS NULL;
|
||||
|
||||
create unique index l2_block_number_uindex
|
||||
on l2_block (number);
|
||||
on l2_block (number) where deleted_at IS NULL;
|
||||
|
||||
create index l2_block_chunk_hash_index
|
||||
on l2_block (chunk_hash);
|
||||
on l2_block (chunk_hash) where deleted_at IS NULL;
|
||||
|
||||
-- +goose StatementEnd
|
||||
|
||||
|
||||
@@ -13,6 +13,10 @@ create table chunk
|
||||
total_l1_messages_popped_before BIGINT NOT NULL,
|
||||
total_l1_messages_popped_in_chunk INTEGER NOT NULL,
|
||||
start_block_time BIGINT NOT NULL,
|
||||
parent_chunk_hash VARCHAR NOT NULL,
|
||||
state_root VARCHAR NOT NULL,
|
||||
parent_chunk_state_root VARCHAR NOT NULL,
|
||||
withdraw_root VARCHAR NOT NULL,
|
||||
|
||||
-- proof
|
||||
proving_status SMALLINT NOT NULL DEFAULT 1,
|
||||
@@ -38,13 +42,13 @@ comment
|
||||
on column chunk.proving_status is 'undefined, unassigned, assigned, proved, verified, failed';
|
||||
|
||||
create unique index chunk_index_uindex
|
||||
on chunk (index);
|
||||
on chunk (index) where deleted_at IS NULL;
|
||||
|
||||
create unique index chunk_hash_uindex
|
||||
on chunk (hash);
|
||||
on chunk (hash) where deleted_at IS NULL;
|
||||
|
||||
create index batch_hash_index
|
||||
on chunk (batch_hash);
|
||||
on chunk (batch_hash) where deleted_at IS NULL;
|
||||
|
||||
-- +goose StatementEnd
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ create table batch
|
||||
end_chunk_hash VARCHAR NOT NULL,
|
||||
state_root VARCHAR NOT NULL,
|
||||
withdraw_root VARCHAR NOT NULL,
|
||||
parent_batch_hash VARCHAR NOT NULL,
|
||||
batch_header BYTEA NOT NULL,
|
||||
|
||||
-- proof
|
||||
@@ -40,10 +41,10 @@ create table batch
|
||||
);
|
||||
|
||||
create unique index batch_index_uindex
|
||||
on batch (index);
|
||||
on batch (index) where deleted_at IS NULL;
|
||||
|
||||
create unique index batch_hash_uindex
|
||||
on batch (hash);
|
||||
on batch (hash) where deleted_at IS NULL;
|
||||
|
||||
comment
|
||||
on column batch.chunk_proofs_status is 'undefined, pending, ready';
|
||||
|
||||
Reference in New Issue
Block a user