harvester2

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ZeroAddress = common.Address{}

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	GetLastBlockNumber() (uint64, error)
	GetBalance(wallet *common.Address, contract *common.Address, blockNumber uint64) (*big.Int, error)
	GetNFTBalance(block int64, wallet *common.Address, nftContract *common.Address) ([]umid.UMID, error)
	GetStakeBalance(block int64, wallet *common.Address, nftContract *common.Address) (map[umid.UMID]*[3]*big.Int, error)
	GetLogs(fromBlock, toBlock int64, addresses []common.Address) ([]any, error)
	RegisterNewBlockListener(f AdapterListener)
	Run()
	GetInfo() (umid umid.UMID, name BCType, rpcURL string)
}

type AdapterListener

type AdapterListener func(blockNumber uint64)

type Address

type Address common.Address

type BCType

type BCType string

type Callback

type Callback *func(p any)

type Callbacks

type Callbacks struct {
	Mu   sync.RWMutex
	Data map[BCType]map[Event]map[Callback]bool
}

func NewCallbacks

func NewCallbacks() *Callbacks

func (*Callbacks) Add

func (c *Callbacks) Add(bcType BCType, event Event, f Callback)

func (*Callbacks) Remove

func (c *Callbacks) Remove(bcType BCType, event Event, f Callback)

func (*Callbacks) Trigger

func (c *Callbacks) Trigger(bcType BCType, event Event, p any)

type Contract

type Contract Address

type Event

type Event string

type Harvester2

type Harvester2 struct {
	// contains filtered or unexported fields
}

func NewHarvester

func NewHarvester(db *pgxpool.Pool) *Harvester2

func (*Harvester2) AddNFTContract

func (h *Harvester2) AddNFTContract(bcType BCType, contract Address) error

func (*Harvester2) AddNFTListener

func (h *Harvester2) AddNFTListener(bcType BCType, contract Address, event string, listener NFTListener) error

func (*Harvester2) AddStakeContract

func (h *Harvester2) AddStakeContract(bcType BCType, contract Address) error

func (*Harvester2) AddStakeListener

func (h *Harvester2) AddStakeListener(bcType BCType, contract Address, listener StakeListener) error

func (*Harvester2) AddTokenContract

func (h *Harvester2) AddTokenContract(bcType BCType, contract Address) error

func (*Harvester2) AddTokenListener

func (h *Harvester2) AddTokenListener(bcType BCType, contract Address, event string, listener TokenListener) error

func (*Harvester2) AddWallet

func (h *Harvester2) AddWallet(bcType BCType, wallet Address) error

func (*Harvester2) Display

func (h *Harvester2) Display(bcType BCType)

func (*Harvester2) GetWalletNFTData

func (h *Harvester2) GetWalletNFTData(bcType BCType, contract Address, wallet Address) (*NFTData, error)

func (*Harvester2) GetWalletTokenData

func (h *Harvester2) GetWalletTokenData(bcType BCType, contract Address, wallet Address) (*TokenData, error)

func (*Harvester2) RegisterAdapter

func (h *Harvester2) RegisterAdapter(adapter Adapter) error

func (*Harvester2) RemoveNFTContract

func (h *Harvester2) RemoveNFTContract(bcType BCType, contract Address) error

func (*Harvester2) RemoveStakeContract

func (h *Harvester2) RemoveStakeContract(bcType BCType, contract Address) error

func (*Harvester2) RemoveTokenContract

func (h *Harvester2) RemoveTokenContract(bcType BCType, contract Address) error

func (*Harvester2) RemoveWallet

func (h *Harvester2) RemoveWallet(bcType BCType, wallet Address) error

type IHarvester2

type IHarvester2 interface {
	RegisterAdapter(adapter Adapter)

	AddWallet(bcType BCType, wallet Address) error
	RemoveWallet(bcType BCType, wallet Address) error

	AddNFTContract(bcType BCType, contract Address) error
	RemoveNFTContract(bcType BCType, contract Address) error

	AddTokenContract(bcType BCType, contract Address) error
	RemoveTokenContract(bcType BCType, contract Address) error

	AddTokenListener(bcType BCType, contract Address, listener TokenListener) error
	AddNFTListener(bcType BCType, contract Address, listener NFTListener) error
	AddStakeListener(bcType BCType, contract Address, listener StakeListener) error

	GetWalletTokenData(bcType BCType, contract Address, wallet Address) (*TokenData, error)
	GetWalletNFTData(bcType BCType, contract Address, wallet Address) (*NFTData, error)
}

type Matrix

type Matrix struct {
	// contains filtered or unexported fields
}

func NewMatrix

func NewMatrix(db *pgxpool.Pool, adapter Adapter) *Matrix

func (*Matrix) AddNFTContract

func (m *Matrix) AddNFTContract(contract Address) error

func (*Matrix) AddNFTListener

func (m *Matrix) AddNFTListener(contract Address, event string, listener NFTListener) error

func (*Matrix) AddStakeContract

func (m *Matrix) AddStakeContract(contract Address) error

func (*Matrix) AddTokenContract

func (m *Matrix) AddTokenContract(contract Address) error

func (*Matrix) AddTokenListener

func (m *Matrix) AddTokenListener(contract Address, event string, listener TokenListener) error

func (*Matrix) AddWallet

func (m *Matrix) AddWallet(wallet Address) error

func (*Matrix) Display

func (m *Matrix) Display()

func (*Matrix) GetWalletNFTData

func (m *Matrix) GetWalletNFTData(contract Address, wallet Address) (*NFTData, error)

func (*Matrix) GetWalletTokenData

func (m *Matrix) GetWalletTokenData(contract Address, wallet Address) (*TokenData, error)

func (*Matrix) ProcessLogs

func (m *Matrix) ProcessLogs(blockNumber uint64, logs []any)

func (*Matrix) Run

func (m *Matrix) Run()

type NFTCell

type NFTCell struct {
	// contains filtered or unexported fields
}

type NFTData

type NFTData struct {
	Wallet   *Address
	Contract *Address
	TokenIDs []umid.UMID
}

type NFTListener

type NFTListener func(events []*NFTData)

type NftEvent

type NftEvent struct {
	From      string
	To        string
	OdysseyID umid.UMID
	Contract  string
}

type RestakeLog

type RestakeLog struct {
	UserWallet        common.Address
	FromOdysseyID     umid.UMID
	ToOdysseyID       umid.UMID
	Amount            *big.Int
	TokenType         uint8
	TotalStakedToFrom *big.Int
	TotalStakedToTo   *big.Int
	Contract          common.Address
}

*

*
* @param user User address
* @param odyssey_from Odyssey ID that the user is removing stake
* @param odyssey_to Odyssey ID that the user is staking into
* @param amount Amount that's being restaked
* @param token Token used (MOM or DAD)
* @param total_staked_from Total amount of tokens that remains staked on the `odyssey_from`
* @param total_staked_to Total amount of tokens staked on `odyssey_to`

event Restake(address user, bytes16 odyssey_from, bytes16 odyssey_to, uint256 amount, Token token, uint256 total_staked_from, uint256 total_staked_to);

type Stake

type Stake struct {
	TotalAmount    *big.Int
	TotalDADAmount *big.Int
	TotalMOMAmount *big.Int
}

type StakeCell

type StakeCell struct {
	Stakes map[umid.UMID]*Stake
	// contains filtered or unexported fields
}

type StakeData

type StakeData struct {
	Wallet    *Address
	Contract  *Address
	OdysseyID *umid.UMID
	Stake     *Stake
}

type StakeEvent

type StakeEvent struct {
	TxHash    string
	Wallet    string
	OdysseyID umid.UMID
	Amount    *big.Int
}

type StakeListener

type StakeListener func(events []*StakeData)

type StakeLog

type StakeLog struct {
	TxHash       string
	UserWallet   common.Address
	OdysseyID    umid.UMID
	AmountStaked *big.Int
	TokenType    uint8
	TotalStaked  *big.Int
	Contract     common.Address
}

*

*
* @param user User address
* @param odyssey Odyssey ID that's being staked
* @param amount_staked Amount being staked
* @param token Token used (MOM or DAD)
* @param total_staked Total being staked by the user on the Odyssey

event Stake(address user, bytes16 odyssey, uint256 amount_staked, Token token, uint256 total_staked);

type TokenCell

type TokenCell struct {
	// contains filtered or unexported fields
}

type TokenData

type TokenData struct {
	Wallet      *Address
	Contract    *Address
	TotalAmount *big.Int
}

type TokenListener

type TokenListener func(events []*TokenData)

type TransferERC20Log

type TransferERC20Log struct {
	From     common.Address
	To       common.Address
	Value    *big.Int
	Contract common.Address
}

type TransferNFTLog

type TransferNFTLog struct {
	From     common.Address
	To       common.Address
	TokenID  umid.UMID
	Contract common.Address
}

*

  • @dev Emitted when `tokenId` token is transferred from `from` to `to`.

event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

type UnstakeLog

type UnstakeLog struct {
	UserWallet     common.Address
	OdysseyID      umid.UMID
	AmountUnstaked *big.Int
	TokenType      uint8
	TotalStaked    *big.Int
	Contract       common.Address
}

*

*
* @param user User address
* @param odyssey Odyssey ID that's being unstaked
* @param amount_unstaked Amount unstaked
* @param token Token used (MOM or DAD)
* @param total_staked Total remained staked by the user on that Odyssey

event Unstake(address user, bytes16 odyssey, uint256 amount_unstaked, Token token, uint256 total_staked);

type UpdateEvent

type UpdateEvent struct {
	Wallet   string
	Contract string
	Amount   *big.Int
}

type Wallet

type Wallet Address

Directories

Path Synopsis
cmd
nft

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL