Documentation ¶
Index ¶
- Constants
- Variables
- type DB
- type FarcasterContracts
- type FarcasterProvider
- func (p *FarcasterProvider) Address(contractType []byte) common.Address
- func (p *FarcasterProvider) BalanceAt(ctx context.Context, addr common.Address, _ []byte, blockNumber uint64) (*big.Int, error)
- func (p *FarcasterProvider) BalanceOf(addr common.Address, _ []byte) (*big.Int, error)
- func (p *FarcasterProvider) BlockRootHash(ctx context.Context, blockNumber uint64) ([]byte, error)
- func (p *FarcasterProvider) BlockTimestamp(ctx context.Context, blockNumber uint64) (string, error)
- func (p *FarcasterProvider) CensusKeys(data map[common.Address]*big.Int) (map[common.Address]*big.Int, error)
- func (p *FarcasterProvider) ChainID() uint64
- func (p *FarcasterProvider) Close() error
- func (p *FarcasterProvider) CreationBlock(ctx context.Context, contractType []byte) (uint64, error)
- func (p *FarcasterProvider) Decimals(_ []byte) (uint64, error)
- func (p *FarcasterProvider) HoldersBalances(ctx context.Context, _ []byte, fromBlock uint64) (map[common.Address]*big.Int, uint64, uint64, bool, *big.Int, error)
- func (p *FarcasterProvider) IconURI(_ []byte) (string, error)
- func (p *FarcasterProvider) Init(iconf any) error
- func (p *FarcasterProvider) IsExternal() bool
- func (p *FarcasterProvider) IsSynced(_ []byte) bool
- func (p *FarcasterProvider) LatestBlockNumber(ctx context.Context, _ []byte) (uint64, error)
- func (p *FarcasterProvider) Name(_ []byte) (string, error)
- func (p *FarcasterProvider) ScanLogsIDRegistry(ctx context.Context, fromBlock, toBlock uint64) (map[uint64]common.Address, uint64, bool, error)
- func (p *FarcasterProvider) ScanLogsKeyRegistry(ctx context.Context, fromBlock, toBlock uint64) (map[uint64][][]byte, map[uint64][][]byte, uint64, bool, error)
- func (p *FarcasterProvider) SetLastBalances(_ context.Context, _ []byte, _ map[common.Address]*big.Int, _ uint64) error
- func (p *FarcasterProvider) SetLastBlockNumber(blockNumber uint64)
- func (p *FarcasterProvider) SetRef(iref any) error
- func (p *FarcasterProvider) Symbol(_ []byte) (string, error)
- func (p *FarcasterProvider) TotalSupply(_ []byte) (*big.Int, error)
- func (p *FarcasterProvider) Type() uint64
- func (p *FarcasterProvider) TypeName() string
- type FarcasterProviderConf
- type FarcasterUserData
Constants ¶
const ( IdRegistryAddress = "0x00000000Fc6c5F01Fc30151999387Bb99A9f489b" KeyRegistryAddress = "0x00000000Fc1237824fb747aBDE0FF18990E59b7e" ChainID = 10 )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type DB ¶
DB struct abstact a safe connection with the database using sqlc queries, sqlite as a database engine and go-sqlite3 as a driver.
type FarcasterContracts ¶
type FarcasterContracts struct {
// contains filtered or unexported fields
}
type FarcasterProvider ¶
type FarcasterProvider struct {
// contains filtered or unexported fields
}
func (*FarcasterProvider) Address ¶
func (p *FarcasterProvider) Address(contractType []byte) common.Address
Address returns the address of the Farcaster contract given the contract type.
func (*FarcasterProvider) BalanceAt ¶
func (p *FarcasterProvider) BalanceAt(ctx context.Context, addr common.Address, _ []byte, blockNumber uint64, ) (*big.Int, error)
BalanceAt is not implemented for Farcaster contracts.
func (*FarcasterProvider) BlockRootHash ¶
BlockRootHash returns the root hash of the given block number for the current farcaster contracts set in the provider. It gets the root hash from the client.
func (*FarcasterProvider) BlockTimestamp ¶
BlockTimestamp returns the timestamp of the given block number for the current token set in the provider. It gets the timestamp from the client.
func (*FarcasterProvider) CensusKeys ¶
func (p *FarcasterProvider) CensusKeys(data map[common.Address]*big.Int) (map[common.Address]*big.Int, error)
CensusKeys method returns the holders and balances provided transformed. The Farcaster resolve the FID of the provided addresses, grouping them by FID and returning the balances of the FID.
func (*FarcasterProvider) ChainID ¶
func (p *FarcasterProvider) ChainID() uint64
ChainID returns the chain ID where the Farcaster contracts are deployed.
func (*FarcasterProvider) Close ¶
func (p *FarcasterProvider) Close() error
Close method is not implemented for Farcaster Key Registry.
func (*FarcasterProvider) CreationBlock ¶
CreationBlock is not implemented for Farcaster contracts.
func (*FarcasterProvider) Decimals ¶
func (p *FarcasterProvider) Decimals(_ []byte) (uint64, error)
Decimals is not implemented for Farcaster contracts.
func (*FarcasterProvider) HoldersBalances ¶
func (p *FarcasterProvider) HoldersBalances(ctx context.Context, _ []byte, fromBlock uint64) ( map[common.Address]*big.Int, uint64, uint64, bool, *big.Int, error, )
HoldersBalances returns the balances of the token holders for the current defined token (using SetRef method). It returns the balances of the holders for this token from the block number provided to the latest posible block number (chosen between the last block number of the network and the maximun number of blocks to scan). It calls to rangeOfLogs to get the logs of the token transfers in the range of blocks and then it iterates the logs to calculate the balances of the holders. It returns the balances, the number of new transfers, the last block scanned, if the provider is synced and an error if it exists.
func (*FarcasterProvider) IconURI ¶
func (p *FarcasterProvider) IconURI(_ []byte) (string, error)
IconURI method is not implemented for Farcaster Key Registry tokens.
func (*FarcasterProvider) Init ¶
func (p *FarcasterProvider) Init(iconf any) error
func (*FarcasterProvider) IsExternal ¶
func (p *FarcasterProvider) IsExternal() bool
IsExternal returns false because the provider is not an external API.
func (*FarcasterProvider) IsSynced ¶
func (p *FarcasterProvider) IsSynced(_ []byte) bool
IsSynced returns true if the current state of the provider is synced. It also receives an external ID but it is not used by the provider. Checks that both Farcaster contracts are synced
func (*FarcasterProvider) LatestBlockNumber ¶
LatestBlockNumber returns the latest block number of the farcaster contracts set in the provider. It gets the latest block number from the client. It also receives an external ID but it is not used by the provider.
func (*FarcasterProvider) Name ¶
func (p *FarcasterProvider) Name(_ []byte) (string, error)
Name returns a predefined name for convenience.
func (*FarcasterProvider) ScanLogsIDRegistry ¶
func (p *FarcasterProvider) ScanLogsIDRegistry(ctx context.Context, fromBlock, toBlock uint64) ( map[uint64]common.Address, uint64, bool, error, )
ScanLogsIDRegistry scans the logs of the Farcaster ID Registry contract
func (*FarcasterProvider) ScanLogsKeyRegistry ¶
func (p *FarcasterProvider) ScanLogsKeyRegistry(ctx context.Context, fromBlock, toBlock uint64) ( map[uint64][][]byte, map[uint64][][]byte, uint64, bool, error, )
ScanLogsKeyRegistry scans the logs of the Farcaster Key Registry contract
func (*FarcasterProvider) SetLastBalances ¶
func (p *FarcasterProvider) SetLastBalances(_ context.Context, _ []byte, _ map[common.Address]*big.Int, _ uint64, ) error
SetLastBalances method is not implemented for Farcaster contracts.
func (*FarcasterProvider) SetLastBlockNumber ¶
func (p *FarcasterProvider) SetLastBlockNumber(blockNumber uint64)
SetLastBlockNumber sets the last block number of the token set in the provider. It is used to calculate the delta balances in the next call to HoldersBalances from the given from point in time. It helps to avoid GetBlockNumber calls to the provider.
func (*FarcasterProvider) SetRef ¶
func (p *FarcasterProvider) SetRef(iref any) error
SetRef sets the reference of the token desired to use to the provider. It receives a Web3ProviderRef struct with the address and chainID of the token to use. It connects to the endpoint and initializes the contract.
func (*FarcasterProvider) Symbol ¶
func (p *FarcasterProvider) Symbol(_ []byte) (string, error)
Symbol is not implemented for Farcaster contracts.
func (*FarcasterProvider) TotalSupply ¶
func (p *FarcasterProvider) TotalSupply(_ []byte) (*big.Int, error)
TotalSupply returns the total number of Farcaster users found in the IDRegistry by calling idCountCounter method.
func (*FarcasterProvider) Type ¶
func (p *FarcasterProvider) Type() uint64
Type returns the type of the current token set in the provider.
func (*FarcasterProvider) TypeName ¶
func (p *FarcasterProvider) TypeName() string
TypeName returns the type name of the current token set in the provider.
type FarcasterProviderConf ¶
type FarcasterProviderConf struct { Endpoints web3.NetworkEndpoints DB *DB }
type FarcasterUserData ¶
type FarcasterUserData struct {
FID uint64
}