-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
erc20_balance.go
57 lines (51 loc) · 1.57 KB
/
erc20_balance.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
package eventindexer
import (
"context"
"net/http"
"github.com/morkid/paginate"
)
type ERC20Metadata struct {
ID int `json:"id"`
ChainID int64 `json:"chainID"`
ContractAddress string `json:"contractAddress"`
Symbol string `json:"symbol"`
Decimals uint8 `json:"decimals"`
}
// ERC20Balance
type ERC20Balance struct {
ID int `json:"id"`
ERC20MetadataID int64 `json:"erc20MetadataID"`
ChainID int64 `json:"chainID"`
Address string `json:"address"`
Amount string `json:"amount"`
ContractAddress string `json:"contractAddress"`
Metadata *ERC20Metadata `json:"metadata" gorm:"foreignKey:ERC20MetadataID"`
}
type UpdateERC20BalanceOpts struct {
ERC20MetadataID int64
ChainID int64
Address string
ContractAddress string
Amount string
}
// ERC20BalanceRepository is used to interact with nft balances in the store
type ERC20BalanceRepository interface {
IncreaseAndDecreaseBalancesInTx(
ctx context.Context,
increaseOpts UpdateERC20BalanceOpts,
decreaseOpts UpdateERC20BalanceOpts,
) (increasedBalance *ERC20Balance, decreasedBalance *ERC20Balance, err error)
FindByAddress(ctx context.Context,
req *http.Request,
address string,
chainID string,
) (paginate.Page, error)
FindMetadata(ctx context.Context, chainID int64, contractAddress string) (*ERC20Metadata, error)
CreateMetadata(
ctx context.Context,
chainID int64,
contractAddress string,
symbol string,
decimals uint8,
) (int, error)
}