Documentation
¶
Index ¶
- Constants
- type EventAPIResponse
- type POAPAPIResponse
- type POAPConfig
- type POAPHolderProvider
- func (p *POAPHolderProvider) Address(_ []byte) common.Address
- func (p *POAPHolderProvider) BalanceAt(_ context.Context, _ common.Address, _ []byte, _ uint64) (*big.Int, error)
- func (p *POAPHolderProvider) BalanceOf(addr common.Address, id []byte) (*big.Int, error)
- func (p *POAPHolderProvider) BlockRootHash(_ context.Context, _ uint64) ([]byte, error)
- func (p *POAPHolderProvider) BlockTimestamp(_ context.Context, _ uint64) (string, error)
- func (p *POAPHolderProvider) CensusKeys(data map[common.Address]*big.Int) (map[common.Address]*big.Int, error)
- func (p *POAPHolderProvider) ChainID() uint64
- func (p *POAPHolderProvider) Close() error
- func (p *POAPHolderProvider) CreationBlock(_ context.Context, _ []byte) (uint64, error)
- func (p *POAPHolderProvider) Decimals(_ []byte) (uint64, error)
- func (p *POAPHolderProvider) HoldersBalances(_ context.Context, id []byte, delta uint64) (map[common.Address]*big.Int, uint64, uint64, bool, *big.Int, error)
- func (p *POAPHolderProvider) IconURI(id []byte) (string, error)
- func (p *POAPHolderProvider) Init(iconf any) error
- func (p *POAPHolderProvider) IsExternal() bool
- func (p *POAPHolderProvider) IsSynced(externalID []byte) bool
- func (p *POAPHolderProvider) LatestBlockNumber(_ context.Context, id []byte) (uint64, error)
- func (p *POAPHolderProvider) Name(id []byte) (string, error)
- func (p *POAPHolderProvider) SetLastBalances(_ context.Context, id []byte, balances map[common.Address]*big.Int, ...) error
- func (p *POAPHolderProvider) SetLastBlockNumber(_ uint64)
- func (p *POAPHolderProvider) SetRef(_ any) error
- func (p *POAPHolderProvider) Symbol(id []byte) (string, error)
- func (p *POAPHolderProvider) TotalSupply(id []byte) (*big.Int, error)
- func (p *POAPHolderProvider) Type() uint64
- func (p *POAPHolderProvider) TypeName() string
- type POAPSnapshot
Constants ¶
const ( // POAP_SYMBOL_PREFIX is the prefix of the POAP token symbol to be used in // with the eventID to compose the token symbol. POAP_SYMBOL_PREFIX = "POAP" // POAP_MAX_LIMIT is the maximum limit of 300 POAPs per request. // https://documentation.poap.tech/reference/geteventpoaps-2 POAP_MAX_LIMIT = 300 // EVENT_URI is the endpoint to get the event info for an eventID. EVENT_URI = "/events/id/%s" // POAP_URI is the endpoint to get the POAP holders for an eventID. POAP_URI = "/event/%s/poaps" // POAP_CONTRACT_ADDRESS is the address of the POAP contract. POAP_CONTRACT_ADDRESS = "0x22c1f6050e56d2876009903609a2cc3fef83b415" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventAPIResponse ¶
type EventAPIResponse struct { FancyID string `json:"fancy_id"` IconURI string `json:"image_url"` Name string `json:"name"` }
EventAPIResponse is the struct that stores the response of the POAP API endpoint to get the event info for an event ID.
type POAPAPIResponse ¶
type POAPAPIResponse struct { Total int `json:"total"` Tokens []struct { Owner struct { ID string `json:"id"` } `json:"owner"` } `json:"tokens"` }
POAPAPIResponse is the struct that stores the response of the POAP API endpoint to get the list of POAPs for an event ID.
type POAPConfig ¶
type POAPHolderProvider ¶
type POAPHolderProvider struct {
// contains filtered or unexported fields
}
POAPHolderProvider is the struct that implements the HolderProvider interface to get the balances of the POAP token holders for an event ID. It uses the POAP API to get the list of POAPs for an event ID and calculate the balances of the token holders from the last snapshot.
func (*POAPHolderProvider) Address ¶
func (p *POAPHolderProvider) Address(_ []byte) common.Address
Address returns the address of the POAP token.
func (*POAPHolderProvider) BlockRootHash ¶
BlockRootHash method is not implemented in the POAP external provider. By default it returns an empty bytes slice and nil error.
func (*POAPHolderProvider) BlockTimestamp ¶
BlockTimestamp method is not implemented in the POAP external provider. By default it returns an empty string and nil error.
func (*POAPHolderProvider) CensusKeys ¶
func (p *POAPHolderProvider) CensusKeys(data map[common.Address]*big.Int) (map[common.Address]*big.Int, error)
CensusKeys method returns the holders and balances provided transformed. The POAP provider does not need to transform the holders and balances, so it returns the data as is.
func (*POAPHolderProvider) ChainID ¶
func (p *POAPHolderProvider) ChainID() uint64
ChainID method is not implemented in the POAP external provider. By default 1.
func (*POAPHolderProvider) Close ¶
func (p *POAPHolderProvider) Close() error
Close method is not implemented in the POAP external provider. By default it returns nil error.
func (*POAPHolderProvider) CreationBlock ¶
CreationBlock method is not implemented in the POAP external provider. By default it returns 0 and nil error.
func (*POAPHolderProvider) Decimals ¶
func (p *POAPHolderProvider) Decimals(_ []byte) (uint64, error)
Decimals method is not implemented in the POAP external provider. By default it returns 0 and nil error.
func (*POAPHolderProvider) HoldersBalances ¶
func (p *POAPHolderProvider) HoldersBalances(_ context.Context, id []byte, delta uint64) ( map[common.Address]*big.Int, uint64, uint64, bool, *big.Int, error, )
HoldersBalances returns the balances of the token holders for the given id and delta point in time. It requests the list of token holders to the POAP API parsing every POAP holder for the event ID provided and calculate the balances of the token holders from the last snapshot.
func (*POAPHolderProvider) IconURI ¶
func (p *POAPHolderProvider) IconURI(id []byte) (string, error)
IconURI returns the icon uri for the given id. It makes a request to the POAP API endpoint to get the event info for the eventID provided and returns the icon uri.
func (*POAPHolderProvider) Init ¶
func (p *POAPHolderProvider) Init(iconf any) error
Init initializes the POAP external provider with the database provided. It returns an error if the POAP access token or api endpoint uri is not defined.
func (*POAPHolderProvider) IsExternal ¶
func (p *POAPHolderProvider) IsExternal() bool
IsExternal method returns true because the POAP provider is an external provider.
func (*POAPHolderProvider) IsSynced ¶
func (p *POAPHolderProvider) IsSynced(externalID []byte) bool
IsSynced returns true if the POAP external provider has a snapshot for the given id.
func (*POAPHolderProvider) LatestBlockNumber ¶
func (*POAPHolderProvider) Name ¶
func (p *POAPHolderProvider) Name(id []byte) (string, error)
Name returns the name of the POAP token. It makes a request to the POAP API endpoint to get the event info for the eventID provided and returns the name of the event.
func (*POAPHolderProvider) SetLastBalances ¶
func (p *POAPHolderProvider) SetLastBalances(_ context.Context, id []byte, balances map[common.Address]*big.Int, from uint64, ) error
SetLastBalances sets the balances of the token holders for the given id and from point in time and store it in a snapshot.
func (*POAPHolderProvider) SetLastBlockNumber ¶
func (p *POAPHolderProvider) SetLastBlockNumber(_ uint64)
SetLastBlockNumber method is not implemented in the POAP external provider.
func (*POAPHolderProvider) SetRef ¶
func (p *POAPHolderProvider) SetRef(_ any) error
SetRef method is not implemented in the POAP external provider. By default it returns nil error.
func (*POAPHolderProvider) Symbol ¶
func (p *POAPHolderProvider) Symbol(id []byte) (string, error)
Symbol returns the symbol of the POAP token. It makes a request to the POAP API endpoint to get the event info for the eventID provided and returns the symbol of the event, which is composed by the prefix POAP_SYMBOL_PREFIX and the fancyID of the event.
func (*POAPHolderProvider) TotalSupply ¶
func (p *POAPHolderProvider) TotalSupply(id []byte) (*big.Int, error)
TotalSupply method is not implemented in the POAP external provider. By default it returns 0 and nil error.
func (*POAPHolderProvider) Type ¶
func (p *POAPHolderProvider) Type() uint64
Type returns the type of the POAP token. By default it returns the CONTRACT_TYPE_POAP.
func (*POAPHolderProvider) TypeName ¶
func (p *POAPHolderProvider) TypeName() string
TypeName returns the type name of the POAP token. By default it returns the string "POAP".
type POAPSnapshot ¶
type POAPSnapshot struct {
// contains filtered or unexported fields
}
POAPSnapshot is the struct that stores the snapshot of the POAP holders for an event ID and from point in time.