-
Notifications
You must be signed in to change notification settings - Fork 7
/
State.go
39 lines (33 loc) · 1 KB
/
State.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
package zksync
import "math/big"
type AccountState struct {
Address string `json:"address"`
Id uint32 `json:"id"`
Depositing *DepositingState `json:"depositing"`
Committed *State `json:"committed"`
Verified *State `json:"verified"`
}
type DepositingState struct {
Balances map[string]*DepositingBalance `json:"balances"`
}
type DepositingBalance struct {
Amount string `json:"amount"`
ExpectedBlockNumber string `json:"expectedBlockNumber"` // to *big.Int
}
type State struct {
Balances map[string]string `json:"balances"`
Nonce uint32 `json:"nonce"`
PubKeyHash string `json:"pubKeyHash"`
Nfts map[string]*NFT `json:"nfts"`
MintedNfts map[string]*NFT `json:"mintedNfts"`
}
func (s *State) GetBalanceOf(token string) (*big.Int, bool) {
n := new(big.Int)
if v, ok := s.Balances[token]; ok {
if n, ok := n.SetString(v, 10); ok {
return n, true
}
return new(big.Int), false
}
return n, false
}