Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
a0acfebf
Commit
a0acfebf
authored
Aug 15, 2023
by
Hamdi Allam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update model & schema
parent
a5a7ab4c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
20 deletions
+20
-20
bridge_transfers.go
indexer/database/bridge_transfers.go
+16
-16
20230523_create_schema.sql
indexer/migrations/20230523_create_schema.sql
+4
-4
No files found.
indexer/database/bridge_transfers.go
View file @
a0acfebf
...
@@ -2,7 +2,6 @@ package database
...
@@ -2,7 +2,6 @@ package database
import
(
import
(
"errors"
"errors"
"math/big"
"gorm.io/gorm"
"gorm.io/gorm"
...
@@ -18,15 +17,19 @@ type TokenPair struct {
...
@@ -18,15 +17,19 @@ type TokenPair struct {
L2TokenAddress
common
.
Address
`gorm:"serializer:json"`
L2TokenAddress
common
.
Address
`gorm:"serializer:json"`
}
}
type
L1BridgeDeposit
struct
{
type
BridgeTransfer
struct
{
TransactionSourceHash
common
.
Hash
`gorm:"primaryKey;serializer:json"`
CrossDomainMessageHash
*
common
.
Hash
CrossDomainMessengerNonce
*
U256
Tx
Transaction
`gorm:"embedded"`
Tx
Transaction
`gorm:"embedded"`
TokenPair
TokenPair
`gorm:"embedded"`
TokenPair
TokenPair
`gorm:"embedded"`
}
}
type
L1BridgeDeposit
struct
{
BridgeTransfer
`gorm:"embedded"`
TransactionSourceHash
common
.
Hash
`gorm:"primaryKey;serializer:json"`
}
type
L1BridgeDepositWithTransactionHashes
struct
{
type
L1BridgeDepositWithTransactionHashes
struct
{
L1BridgeDeposit
L1BridgeDeposit
`gorm:"embedded"`
L1BridgeDeposit
L1BridgeDeposit
`gorm:"embedded"`
...
@@ -35,12 +38,9 @@ type L1BridgeDepositWithTransactionHashes struct {
...
@@ -35,12 +38,9 @@ type L1BridgeDepositWithTransactionHashes struct {
}
}
type
L2BridgeWithdrawal
struct
{
type
L2BridgeWithdrawal
struct
{
TransactionWithdrawalHash
common
.
Hash
`gorm:"primaryKey;serializer:json"`
BridgeTransfer
`gorm:"embedded"`
CrossDomainMessengerNonce
*
U256
Tx
Transaction
`gorm:"embedded"`
TransactionWithdrawalHash
common
.
Hash
`gorm:"primaryKey;serializer:json"`
TokenPair
TokenPair
`gorm:"embedded"`
}
}
type
L2BridgeWithdrawalWithTransactionHashes
struct
{
type
L2BridgeWithdrawalWithTransactionHashes
struct
{
...
@@ -53,11 +53,11 @@ type L2BridgeWithdrawalWithTransactionHashes struct {
...
@@ -53,11 +53,11 @@ type L2BridgeWithdrawalWithTransactionHashes struct {
type
BridgeTransfersView
interface
{
type
BridgeTransfersView
interface
{
L1BridgeDeposit
(
common
.
Hash
)
(
*
L1BridgeDeposit
,
error
)
L1BridgeDeposit
(
common
.
Hash
)
(
*
L1BridgeDeposit
,
error
)
L1BridgeDeposit
ByCrossDomainMessengerNonce
(
*
big
.
Int
)
(
*
L1BridgeDeposit
,
error
)
L1BridgeDeposit
WithFilter
(
BridgeTransfer
)
(
*
L1BridgeDeposit
,
error
)
L1BridgeDepositsByAddress
(
common
.
Address
)
([]
*
L1BridgeDepositWithTransactionHashes
,
error
)
L1BridgeDepositsByAddress
(
common
.
Address
)
([]
*
L1BridgeDepositWithTransactionHashes
,
error
)
L2BridgeWithdrawal
(
common
.
Hash
)
(
*
L2BridgeWithdrawal
,
error
)
L2BridgeWithdrawal
(
common
.
Hash
)
(
*
L2BridgeWithdrawal
,
error
)
L2BridgeWithdrawal
ByCrossDomainMessengerNonce
(
*
big
.
Int
)
(
*
L2BridgeWithdrawal
,
error
)
L2BridgeWithdrawal
WithFilter
(
BridgeTransfer
)
(
*
L2BridgeWithdrawal
,
error
)
L2BridgeWithdrawalsByAddress
(
common
.
Address
)
([]
*
L2BridgeWithdrawalWithTransactionHashes
,
error
)
L2BridgeWithdrawalsByAddress
(
common
.
Address
)
([]
*
L2BridgeWithdrawalWithTransactionHashes
,
error
)
}
}
...
@@ -104,9 +104,9 @@ func (db *bridgeTransfersDB) L1BridgeDeposit(txSourceHash common.Hash) (*L1Bridg
...
@@ -104,9 +104,9 @@ func (db *bridgeTransfersDB) L1BridgeDeposit(txSourceHash common.Hash) (*L1Bridg
// L1BridgeDepositByCrossDomainMessengerNonce retrieves tokens deposited, specified by the associated `L1CrossDomainMessenger` nonce.
// L1BridgeDepositByCrossDomainMessengerNonce retrieves tokens deposited, specified by the associated `L1CrossDomainMessenger` nonce.
// All tokens bridged via the StandardBridge flows through the L1CrossDomainMessenger
// All tokens bridged via the StandardBridge flows through the L1CrossDomainMessenger
func
(
db
*
bridgeTransfersDB
)
L1BridgeDeposit
ByCrossDomainMessengerNonce
(
nonce
*
big
.
Int
)
(
*
L1BridgeDeposit
,
error
)
{
func
(
db
*
bridgeTransfersDB
)
L1BridgeDeposit
WithFilter
(
filter
BridgeTransfer
)
(
*
L1BridgeDeposit
,
error
)
{
var
deposit
L1BridgeDeposit
var
deposit
L1BridgeDeposit
result
:=
db
.
gorm
.
Where
(
&
L1BridgeDeposit
{
CrossDomainMessengerNonce
:
&
U256
{
Int
:
nonce
}}
)
.
Take
(
&
deposit
)
result
:=
db
.
gorm
.
Where
(
&
filter
)
.
Take
(
&
deposit
)
if
result
.
Error
!=
nil
{
if
result
.
Error
!=
nil
{
if
errors
.
Is
(
result
.
Error
,
gorm
.
ErrRecordNotFound
)
{
if
errors
.
Is
(
result
.
Error
,
gorm
.
ErrRecordNotFound
)
{
return
nil
,
nil
return
nil
,
nil
...
@@ -168,9 +168,9 @@ func (db *bridgeTransfersDB) L2BridgeWithdrawal(txWithdrawalHash common.Hash) (*
...
@@ -168,9 +168,9 @@ func (db *bridgeTransfersDB) L2BridgeWithdrawal(txWithdrawalHash common.Hash) (*
// L2BridgeWithdrawalByCrossDomainMessengerNonce retrieves tokens withdrawn, specified by the associated `L2CrossDomainMessenger` nonce.
// L2BridgeWithdrawalByCrossDomainMessengerNonce retrieves tokens withdrawn, specified by the associated `L2CrossDomainMessenger` nonce.
// All tokens bridged via the StandardBridge flows through the L2CrossDomainMessenger
// All tokens bridged via the StandardBridge flows through the L2CrossDomainMessenger
func
(
db
*
bridgeTransfersDB
)
L2BridgeWithdrawal
ByCrossDomainMessengerNonce
(
nonce
*
big
.
Int
)
(
*
L2BridgeWithdrawal
,
error
)
{
func
(
db
*
bridgeTransfersDB
)
L2BridgeWithdrawal
WithFilter
(
filter
BridgeTransfer
)
(
*
L2BridgeWithdrawal
,
error
)
{
var
withdrawal
L2BridgeWithdrawal
var
withdrawal
L2BridgeWithdrawal
result
:=
db
.
gorm
.
Where
(
&
L2BridgeWithdrawal
{
CrossDomainMessengerNonce
:
&
U256
{
Int
:
nonce
}}
)
.
Take
(
&
withdrawal
)
result
:=
db
.
gorm
.
Where
(
filter
)
.
Take
(
&
withdrawal
)
if
result
.
Error
!=
nil
{
if
result
.
Error
!=
nil
{
if
errors
.
Is
(
result
.
Error
,
gorm
.
ErrRecordNotFound
)
{
if
errors
.
Is
(
result
.
Error
,
gorm
.
ErrRecordNotFound
)
{
return
nil
,
nil
return
nil
,
nil
...
...
indexer/migrations/20230523_create_schema.sql
View file @
a0acfebf
...
@@ -188,9 +188,9 @@ CREATE TABLE IF NOT EXISTS l2_bridge_messages(
...
@@ -188,9 +188,9 @@ CREATE TABLE IF NOT EXISTS l2_bridge_messages(
CREATE
TABLE
IF
NOT
EXISTS
l1_bridge_deposits
(
CREATE
TABLE
IF
NOT
EXISTS
l1_bridge_deposits
(
transaction_source_hash
VARCHAR
PRIMARY
KEY
REFERENCES
l1_transaction_deposits
(
source_hash
),
transaction_source_hash
VARCHAR
PRIMARY
KEY
REFERENCES
l1_transaction_deposits
(
source_hash
),
-- We allow the cross_domain_mess
enger_nonce
to be NULL-able to account
-- We allow the cross_domain_mess
age_hash
to be NULL-able to account
-- for scenarios where ETH is simply sent to the OptimismPortal contract
-- for scenarios where ETH is simply sent to the OptimismPortal contract
cross_domain_mess
enger_nonce
UINT256
UNIQUE
REFERENCES
l1_bridge_messages
(
nonce
),
cross_domain_mess
age_hash
VARCHAR
UNIQUE
REFERENCES
l1_bridge_messages
(
nonce
),
-- Deposit information
-- Deposit information
from_address
VARCHAR
NOT
NULL
,
from_address
VARCHAR
NOT
NULL
,
...
@@ -204,9 +204,9 @@ CREATE TABLE IF NOT EXISTS l1_bridge_deposits (
...
@@ -204,9 +204,9 @@ CREATE TABLE IF NOT EXISTS l1_bridge_deposits (
CREATE
TABLE
IF
NOT
EXISTS
l2_bridge_withdrawals
(
CREATE
TABLE
IF
NOT
EXISTS
l2_bridge_withdrawals
(
transaction_withdrawal_hash
VARCHAR
PRIMARY
KEY
REFERENCES
l2_transaction_withdrawals
(
withdrawal_hash
),
transaction_withdrawal_hash
VARCHAR
PRIMARY
KEY
REFERENCES
l2_transaction_withdrawals
(
withdrawal_hash
),
-- We allow the cross_domain_mess
enger_nonce
to be NULL-able to account for
-- We allow the cross_domain_mess
age_hash
to be NULL-able to account for
-- scenarios where ETH is simply sent to the L2ToL1MessagePasser contract
-- scenarios where ETH is simply sent to the L2ToL1MessagePasser contract
cross_domain_mess
enger_nonce
UINT256
UNIQUE
REFERENCES
l2_bridge_messages
(
nonce
),
cross_domain_mess
age_hash
VARCHAR
UNIQUE
REFERENCES
l2_bridge_messages
(
nonce
),
-- Withdrawal information
-- Withdrawal information
from_address
VARCHAR
NOT
NULL
,
from_address
VARCHAR
NOT
NULL
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment