multichain

package
v0.0.0-...-d2b7839 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AutoglyphContract               = persist.ContractIdentifiers{ContractAddress: "0xd4e4078ca3495de5b1d4db434bebc5a986197782", Chain: persist.ChainETH}
	ColorglyphContract              = persist.ContractIdentifiers{ContractAddress: "0x60f3680350f65beb2752788cb48abfce84a4759e", Chain: persist.ChainETH}
	EnsContract                     = persist.ContractIdentifiers{ContractAddress: eth.EnsAddress, Chain: persist.ChainETH}
	CryptopunkContract              = persist.ContractIdentifiers{ContractAddress: "0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb", Chain: persist.ChainETH}
	ZoraContract                    = persist.ContractIdentifiers{ContractAddress: "0xabefbc9fd2f806065b4f3c237d4b59d9a97bcac7", Chain: persist.ChainETH}
	OpenseaSharedStorefrontContract = persist.ContractIdentifiers{ContractAddress: "0x495f947276749ce646f68ac8c248420045cb7b5e", Chain: persist.ChainETH}
)

Functions

This section is empty.

Types

type ChainAgnosticContract

type ChainAgnosticContract struct {
	Descriptors ChainAgnosticContractDescriptors `json:"descriptors"`
	Address     persist.Address                  `json:"address"`
	IsSpam      *bool                            `json:"is_spam"`
	LatestBlock persist.BlockNumber              `json:"latest_block"`
}

ChainAgnosticContract is a contract that is agnostic to the chain it is on

type ChainAgnosticContractDescriptors

type ChainAgnosticContractDescriptors struct {
	Symbol          string          `json:"symbol"`
	Name            string          `json:"name"`
	Description     string          `json:"description"`
	ProfileImageURL string          `json:"profile_image_url"`
	OwnerAddress    persist.Address `json:"owner_address"`
}

type ChainAgnosticIdentifiers

type ChainAgnosticIdentifiers struct {
	ContractAddress persist.Address    `json:"contract_address"`
	TokenID         persist.HexTokenID `json:"token_id"`
}

ChainAgnosticIdentifiers identify tokens despite their chain

func (ChainAgnosticIdentifiers) String

func (t ChainAgnosticIdentifiers) String() string

type ChainAgnosticToken

type ChainAgnosticToken struct {
	Descriptors     ChainAgnosticTokenDescriptors `json:"descriptors"`
	TokenType       persist.TokenType             `json:"token_type"`
	TokenURI        persist.TokenURI              `json:"token_uri"`
	TokenID         persist.HexTokenID            `json:"token_id"`
	Quantity        persist.HexString             `json:"quantity"`
	OwnerAddress    persist.Address               `json:"owner_address"`
	TokenMetadata   persist.TokenMetadata         `json:"metadata"`
	ContractAddress persist.Address               `json:"contract_address"`
	FallbackMedia   persist.FallbackMedia         `json:"fallback_media"`
	ExternalURL     string                        `json:"external_url"`
	BlockNumber     persist.BlockNumber           `json:"block_number"`
	IsSpam          *bool                         `json:"is_spam"`
}

ChainAgnosticToken is a token that is agnostic to the chain it is on

type ChainAgnosticTokenDescriptors

type ChainAgnosticTokenDescriptors struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

ChainAgnosticTokenDescriptors are the fields that describe a token but cannot be used to uniquely identify it

type ChainAgnosticTokensAndContracts

type ChainAgnosticTokensAndContracts struct {
	Tokens    []ChainAgnosticToken    `json:"tokens"`
	Contracts []ChainAgnosticContract `json:"contracts"`
}

type ChainProvider

type ChainProvider struct {
	Ethereum *EthereumProvider
	Tezos    *TezosProvider
	Optimism *OptimismProvider
	Arbitrum *ArbitrumProvider
	Poap     *PoapProvider
	Zora     *ZoraProvider
	Base     *BaseProvider
	Polygon  *PolygonProvider
}

type ContractFetcher

type ContractFetcher interface {
	GetContractByAddress(ctx context.Context, contract persist.Address) (ChainAgnosticContract, error)
}

type ContractOwnerResult

type ContractOwnerResult struct {
	Contracts []ChainAgnosticContract
	Chain     persist.Chain
}

type ContractsCreatorFetcher

type ContractsCreatorFetcher interface {
	GetContractsByCreatorAddress(ctx context.Context, owner persist.Address) ([]ChainAgnosticContract, error)
}

type CustomMetadataHandlers

type CustomMetadataHandlers struct {
	AutoglyphHandler               metadataHandler
	ColorglyphHandler              metadataHandler
	EnsHandler                     metadataHandler
	CryptopunkHandler              metadataHandler
	ZoraHandler                    metadataHandler
	OpenseaSharedStorefrontHandler metadataHandler
}

func NewCustomMetadataHandlers

func NewCustomMetadataHandlers(ethClient *ethclient.Client, ipfsClient *shell.Shell, arweaveClient *goar.Client) *CustomMetadataHandlers

func (*CustomMetadataHandlers) AddToPage

func (c *CustomMetadataHandlers) AddToPage(ctx context.Context, chain persist.Chain, recCh <-chan ChainAgnosticTokensAndContracts, errIn <-chan error) (<-chan ChainAgnosticTokensAndContracts, <-chan error)

func (*CustomMetadataHandlers) AddToToken

func (*CustomMetadataHandlers) HandlerFor

func (c *CustomMetadataHandlers) HandlerFor(t persist.TokenIdentifiers) metadataHandler

func (*CustomMetadataHandlers) Load

func (*CustomMetadataHandlers) LoadAll

func (*CustomMetadataHandlers) LoadMetadataAll

func (c *CustomMetadataHandlers) LoadMetadataAll(ctx context.Context, chain persist.Chain, tokens []ChainAgnosticToken) []persist.TokenMetadata

type ErrProviderContractNotFound

type ErrProviderContractNotFound struct {
	Contract persist.Address
	Chain    persist.Chain
	Err      error
}

func (ErrProviderContractNotFound) Error

func (ErrProviderContractNotFound) Unwrap

type ErrProviderFailed

type ErrProviderFailed struct{ Err error }

func (ErrProviderFailed) Error

func (e ErrProviderFailed) Error() string

func (ErrProviderFailed) Unwrap

func (e ErrProviderFailed) Unwrap() error

type Provider

type Provider struct {
	Repos     *postgres.Repositories
	Queries   *db.Queries
	Chains    ProviderLookup
	Submitter tokenmanage.Submitter
}

func (*Provider) AddTokensToUserUnchecked

func (p *Provider) AddTokensToUserUnchecked(ctx context.Context, userID persist.DBID, tIDs []persist.TokenUniqueIdentifiers, newQuantities []persist.HexString) ([]op.TokenFullDetails, error)

AddTokensToUserUnchecked adds tokens to a user with the requested quantities. AddTokensToUserUnchecked does not make any effort to validate that the user owns the tokens, only that the tokens exist and are fetchable on chain. This is useful for adding tokens to a user when it's already known beforehand that the user owns the token via a trusted source, skipping the potentially expensive operation of fetching a token by its owner.

func (*Provider) GetTokenMetadataByTokenIdentifiers

func (p *Provider) GetTokenMetadataByTokenIdentifiers(ctx context.Context, contractAddress persist.Address, tokenID persist.HexTokenID, chain persist.Chain) (persist.TokenMetadata, error)

func (*Provider) GetTokenMetadataByTokenIdentifiersBatch

func (p *Provider) GetTokenMetadataByTokenIdentifiersBatch(ctx context.Context, chain persist.Chain, tIDs []ChainAgnosticIdentifiers) ([]persist.TokenMetadata, error)

func (*Provider) GetTokensOfContractForWallet

func (p *Provider) GetTokensOfContractForWallet(ctx context.Context, contractAddress persist.ChainAddress, wallet persist.L1ChainAddress) ([]op.TokenFullDetails, error)

func (*Provider) RefreshContract

func (p *Provider) RefreshContract(ctx context.Context, ci persist.ContractIdentifiers) error

RefreshContract refreshes a contract on the given chain using the chain provider for that chain

func (*Provider) RefreshToken

func (p *Provider) RefreshToken(ctx context.Context, ti persist.TokenIdentifiers) error

RefreshToken refreshes a token on the given chain using the chain provider for that chain

func (*Provider) RefreshTokenDescriptorsByTokenIdentifiers

func (p *Provider) RefreshTokenDescriptorsByTokenIdentifiers(ctx context.Context, ti persist.TokenIdentifiers) (db.TokenDefinition, error)

RefreshTokenDescriptorsByTokenIdentifiers will refresh the token descriptors for a token by its identifiers.

func (*Provider) SyncCreatedTokensForExistingContract

func (p *Provider) SyncCreatedTokensForExistingContract(ctx context.Context, userID persist.DBID, contractID persist.DBID) error

func (*Provider) SyncCreatedTokensForNewContracts

func (p *Provider) SyncCreatedTokensForNewContracts(ctx context.Context, userID persist.DBID, chains []persist.Chain) error

SyncCreatedTokensForNewContracts syncs tokens for contracts that the user created but does not currently have any tokens for.

func (*Provider) SyncTokenByUserWalletsAndTokenIdentifiersRetry

func (p *Provider) SyncTokenByUserWalletsAndTokenIdentifiersRetry(ctx context.Context, userID persist.DBID, t persist.TokenIdentifiers, r retry.Retry) (token op.TokenFullDetails, err error)

SyncTokenByUserWalletsAndTokenIdentifiersRetry attempts to sync a token for a user by their wallets and token identifiers.

func (*Provider) SyncTokensByUserID

func (p *Provider) SyncTokensByUserID(ctx context.Context, userID persist.DBID, chains []persist.Chain) error

SyncTokensByUserID updates the media for all tokens for a user

func (*Provider) SyncTokensByUserIDAndTokenIdentifiers

func (p *Provider) SyncTokensByUserIDAndTokenIdentifiers(ctx context.Context, userID persist.DBID, tokenIdentifiers []persist.TokenUniqueIdentifiers) ([]op.TokenFullDetails, error)

SyncTokensByUserIDAndTokenIdentifiers updates the media for specific tokens for a user

func (*Provider) TokenExists

func (p *Provider) TokenExists(ctx context.Context, token persist.TokenIdentifiers, r retry.Retry) (td db.TokenDefinition, err error)

TokenExists checks if a token exists according to any provider by its identifiers. It returns nil if the token exists. If a token exists, it will also update its contract and its descriptors in the database.

func (*Provider) VerifySignature

func (p *Provider) VerifySignature(ctx context.Context, pSig string, pMessage string, pChainAddress persist.ChainPubKey, pWalletType persist.WalletType) (bool, error)

VerifySignature verifies a signature for a wallet address

type ProviderLookup

type ProviderLookup map[persist.Chain]any

type TokenDescriptorsFetcher

type TokenDescriptorsFetcher interface {
	GetTokenDescriptorsByTokenIdentifiers(ctx context.Context, ti ChainAgnosticIdentifiers) (ChainAgnosticTokenDescriptors, ChainAgnosticContractDescriptors, error)
}

type TokenIdentifierOwnerFetcher

type TokenIdentifierOwnerFetcher interface {
	GetTokenByTokenIdentifiersAndOwner(context.Context, ChainAgnosticIdentifiers, persist.Address) (ChainAgnosticToken, ChainAgnosticContract, error)
}

type TokenMetadataBatcher

type TokenMetadataBatcher interface {
	GetTokenMetadataByTokenIdentifiersBatch(ctx context.Context, tIDs []ChainAgnosticIdentifiers) ([]persist.TokenMetadata, error)
}

type TokenMetadataFetcher

type TokenMetadataFetcher interface {
	GetTokenMetadataByTokenIdentifiers(ctx context.Context, ti ChainAgnosticIdentifiers) (persist.TokenMetadata, error)
}

TokenMetadataFetcher supports fetching token metadata

type TokensByContractWalletFetcher

type TokensByContractWalletFetcher interface {
	GetTokensByContractWallet(ctx context.Context, contract persist.ChainAddress, wallet persist.Address) ([]ChainAgnosticToken, ChainAgnosticContract, error)
}

type TokensByTokenIdentifiersFetcher

type TokensByTokenIdentifiersFetcher interface {
	GetTokensByTokenIdentifiers(context.Context, ChainAgnosticIdentifiers) ([]ChainAgnosticToken, ChainAgnosticContract, error)
}

type TokensIncrementalContractFetcher

type TokensIncrementalContractFetcher interface {
	// NOTE: implementations MUST close the rec channel
	// maxLimit is not for pagination, it is to make sure we don't fetch a bajilion tokens from an omnibus contract
	GetTokensIncrementallyByContractAddress(ctx context.Context, address persist.Address, maxLimit int) (<-chan ChainAgnosticTokensAndContracts, <-chan error)
}

TokensIncrementalContractFetcher supports fetching tokens by contract for syncing incrementally

type TokensIncrementalOwnerFetcher

type TokensIncrementalOwnerFetcher interface {
	// NOTE: implementation MUST close the rec channel
	GetTokensIncrementallyByWalletAddress(ctx context.Context, address persist.Address) (<-chan ChainAgnosticTokensAndContracts, <-chan error)
}

TokensIncrementalOwnerFetcher supports fetching tokens for syncing incrementally

type Verifier

type Verifier interface {
	VerifySignature(ctx context.Context, pubKey persist.PubKey, walletType persist.WalletType, nonce string, sig string) (bool, error)
}

Verifier can verify that a signature is signed by a given key

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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