/
deposit.go
140 lines (129 loc) · 5.48 KB
/
deposit.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package model
import (
"time"
)
const (
BtcTxTypeTransfer = iota // transfer
)
const (
// b2 rollup status
DepositB2TxStatusSuccess = iota // success
DepositB2TxStatusPending // pending
DepositB2TxStatusFailed // deposit invoke failed
DepositB2TxStatusWaitMinedFailed // deposit wait mined failed
DepositB2TxStatusTxHashExist // tx hash exist, deposit have been called
DepositB2TxStatusWaitMinedStatusFailed // deposit wait mined status failed, status != 1
DepositB2TxStatusInsufficientBalance // deposit insufficient balance
DepositB2TxStatusContextDeadlineExceeded // deposit client context deadline exceeded, Chain transaction is stuck
DepositB2TxStatusFromAccountGasInsufficient // deposit evm from account gas insufficient
DepositB2TxStatusWaitMined // deposit wait mined
DepositB2TxStatusAAAddressNotFound // aa address not found, Start process processing separately
DepositB2TxStatusIsPending
DepositB2TxStatusNonceToLow
)
const (
DepositB2EoaTxStatusSuccess = iota // eoa transfer success
DepositB2EoaTxStatusPending // eoa transfer pending
DepositB2EoaTxStatusFailed // eoa transfer failed
DepositB2EoaTxStatusWaitMinedFailed // eoa transfer wait mined failed
DepositB2EoaTxStatusWaitMined
_
_
DepositB2EoaTxStatusContextDeadlineExceeded // eoa transfer client context deadline exceeded
DepositB2EoaTxStatusUnknown
DepositB2EoaTxStatusNonceToLow
)
const (
CallbackStatusSuccess = iota
CallbackStatusPending
)
const (
ListenerStatusSuccess = iota
ListenerStatusPending
)
const (
B2CheckStatusSuccess = iota
B2CheckStatusPending
B2CheckStatusFailed
)
type Deposit struct {
Base
BtcBlockNumber int64 `json:"btc_block_number" gorm:"index;comment:bitcoin block number"`
BtcTxIndex int64 `json:"btc_tx_index" gorm:"comment:bitcoin tx index"`
BtcTxHash string `json:"btc_tx_hash" gorm:"type:varchar(64);not null;default:'';uniqueIndex;comment:bitcoin tx hash"`
BtcTxType int `json:"btc_tx_type" gorm:"type:SMALLINT;default:0;comment:btc tx type"`
BtcFroms string `json:"btc_froms" gorm:"type:jsonb;comment:bitcoin transfer, from may be multiple"`
BtcFrom string `json:"btc_from" gorm:"type:varchar(64);not null;default:'';index"`
BtcTos string `json:"btc_tos" gorm:"type:jsonb;comment:bitcoin transfer, to may be multiple"`
BtcTo string `json:"btc_to" gorm:"type:varchar(64);not null;default:'';index"`
BtcFromAAAddress string `json:"btc_from_aa_address" gorm:"type:varchar(42);default:'';comment:from aa address"`
BtcValue int64 `json:"btc_value" gorm:"default:0;comment:bitcoin transfer value"`
B2TxFrom string `json:"b2_tx_from" gorm:"type:varchar(42);default:'';comment:from address"`
B2TxHash string `json:"b2_tx_hash" gorm:"type:varchar(66);not null;default:'';index;comment:b2 network tx hash"`
B2TxNonce uint64 `json:"b2_tx_nonce" gorm:"default:0"`
B2TxStatus int `json:"b2_tx_status" gorm:"type:SMALLINT;default:1"`
B2TxRetry int `json:"b2_tx_retry" gorm:"type:SMALLINT;default:0"`
B2EoaTxFrom string `json:"b2_eoa_tx_from" gorm:"type:varchar(42);default:'';comment:from address"`
B2EoaTxNonce uint64 `json:"b2_eoa_tx_nonce" gorm:"default:0"`
B2EoaTxHash string `json:"b2_eoa_tx_hash" gorm:"type:varchar(66);not null;default:'';comment:b2 network eoa tx hash"`
B2EoaTxStatus int `json:"b2_eoa_tx_status" gorm:"type:SMALLINT;default:1"`
BtcBlockTime time.Time `json:"btc_block_time"`
CallbackStatus int `json:"callback_status" gorm:"type:SMALLINT;default:0"`
ListenerStatus int `json:"listener_status" gorm:"type:SMALLINT;default:0"`
B2TxCheck int `json:"b2_tx_check" gorm:"type:SMALLINT;default:1"`
}
type DepositColumns struct {
BtcBlockNumber string
BtcTxIndex string
BtcTxHash string
BtcTxType string
BtcFroms string
BtcFrom string
BtcTos string
BtcTo string
BtcFromAAAddress string
BtcValue string
B2TxFrom string
B2TxHash string
B2TxNonce string
B2TxStatus string
B2TxRetry string
B2EoaTxFrom string
B2EoaTxNonce string
B2EoaTxHash string
B2EoaTxStatus string
BtcBlockTime string
CallbackStatus string
ListenerStatus string
B2TxCheck string
}
func (Deposit) TableName() string {
return "deposit_history"
}
func (Deposit) Column() DepositColumns {
return DepositColumns{
BtcBlockNumber: "btc_block_number",
BtcTxIndex: "btc_tx_index",
BtcTxHash: "btc_tx_hash",
BtcTxType: "btc_tx_type",
BtcFroms: "btc_froms",
BtcFrom: "btc_from",
BtcTos: "btc_tos",
BtcTo: "btc_to",
BtcFromAAAddress: "btc_from_aa_address",
BtcValue: "btc_value",
B2TxFrom: "b2_tx_from",
B2TxHash: "b2_tx_hash",
B2TxNonce: "b2_tx_nonce",
B2TxStatus: "b2_tx_status",
B2EoaTxFrom: "b2_eoa_tx_from",
B2EoaTxNonce: "b2_eoa_tx_nonce",
B2EoaTxHash: "b2_eoa_tx_hash",
B2EoaTxStatus: "b2_eoa_tx_status",
BtcBlockTime: "btc_block_time",
B2TxRetry: "b2_tx_retry",
CallbackStatus: "callback_status",
ListenerStatus: "listener_status",
B2TxCheck: "b2_tx_check",
}
}