opensea

package module
v0.0.0-...-e0722c7 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: MIT Imports: 13 Imported by: 0

README

go-opensea

Golang library for OpenSea APIs (https://docs.opensea.io/reference)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHexAddress

func IsHexAddress(s string) bool

Types

type Account

type Account struct {
	User          User    `json:"user"`
	ProfileImgURL string  `json:"profile_img_url"`
	Address       Address `json:"address"`
	Config        string  `json:"config"`
	DiscordID     string  `json:"discord_id"`
}

type Address

type Address string
const NullAddress Address = "0x0000000000000000000000000000000000000000"

func ParseAddress

func ParseAddress(address string) (Address, error)

func (Address) IsNullAddress

func (a Address) IsNullAddress() bool

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

func (Address) String

func (a Address) String() string

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(b []byte) error

type Asset

type Asset struct {
	TokenID              string         `json:"token_id"`
	NumSales             int64          `json:"num_sales"`
	BackgroundColor      string         `json:"background_color"`
	ImageURL             string         `json:"image_url"`
	ImagePreviewURL      string         `json:"image_preview_url"`
	ImageThumbnailURL    string         `json:"image_thumbnail_url"`
	ImageOriginalURL     string         `json:"image_original_url"`
	AnimationURL         string         `json:"animation_url"`
	AnimationOriginalURL string         `json:"animation_original_url"`
	Name                 string         `json:"name"`
	Description          string         `json:"description"`
	ExternalLink         string         `json:"external_link"`
	AssetContract        *AssetContract `json:"asset_contract"`
	Owner                *Account       `json:"owner"`
	Permalink            string         `json:"permalink"`
	// Collection           *Collection    `json:"collection"`
	Decimals int64 `json:"decimals"`
}

type AssetBundle

type AssetBundle struct {
	Maker         *Account       `json:"maker"`
	Slug          string         `json:"slug"`
	Assets        []*Asset       `json:"assets"`
	Name          string         `json:"name"`
	Description   string         `json:"description"`
	ExternalLink  string         `json:"external_link"`
	AssetContract *AssetContract `json:"asset_contract"`
	Permalink     string         `json:"permalink"`
	SellOrders    interface{}    `json:"sell_orders"`
}

type AssetContract

type AssetContract struct {
	Address                     Address     `json:"address"`
	AssetContractType           string      `json:"asset_contract_type"`
	CreatedDate                 string      `json:"created_date"`
	Name                        string      `json:"name"`
	NftVersion                  string      `json:"nft_version"`
	OpenseaVersion              interface{} `json:"opensea_version"`
	Owner                       *Account    `json:"owner"`
	SchemaName                  string      `json:"schema_name"`
	Symbol                      string      `json:"symbol"`
	TotalSupply                 interface{} `json:"total_supply"`
	Description                 string      `json:"description"`
	ExternalLink                string      `json:"external_link"`
	ImageURL                    string      `json:"image_url"`
	DefaultToFiat               bool        `json:"default_to_fiat"`
	DevBuyerFeeBasisPoints      int64       `json:"dev_buyer_fee_basis_points"`
	DevSellerFeeBasisPoints     int64       `json:"dev_seller_fee_basis_points"`
	OnlyProxiedTransfers        bool        `json:"only_proxied_transfers"`
	OpenseaBuyerFeeBasisPoints  int64       `json:"opensea_buyer_fee_basis_points"`
	OpenseaSellerFeeBasisPoints int64       `json:"opensea_seller_fee_basis_points"`
	BuyerFeeBasisPoints         int64       `json:"buyer_fee_basis_points"`
	SellerFeeBasisPoints        int64       `json:"seller_fee_basis_points"`
	PayoutAddress               Address     `json:"payout_address"`
}

type AuctionType

type AuctionType string
const (
	AuctionTypeNone     AuctionType = ""
	AuctionTypeEnglish  AuctionType = "english"
	AuctionTypeDutch    AuctionType = "dutch"
	AuctionTypeMinPrice AuctionType = "min-price"
)

type Bytes

type Bytes []byte

func (Bytes) Bytes32

func (by Bytes) Bytes32() [32]byte

func (Bytes) MarshalJSON

func (by Bytes) MarshalJSON() ([]byte, error)

func (*Bytes) UnmarshalJSON

func (by *Bytes) UnmarshalJSON(b []byte) error

type Contract

type Contract struct {
	// Collection                  Collection  `json:"collection"`
	Address                     Address     `json:"address"`
	AssetContractType           string      `json:"asset_contract_type"`
	CreatedDate                 string      `json:"created_date"`
	Name                        string      `json:"name"`
	NFTVersion                  string      `json:"nft_version"`
	OpenseaVersion              interface{} `json:"opensea_version"`
	Owner                       int64       `json:"owner"`
	SchemaName                  string      `json:"schema_name"`
	Symbol                      string      `json:"symbol"`
	TotalSupply                 interface{} `json:"total_supply"`
	Description                 string      `json:"description"`
	ExternalLink                string      `json:"external_link"`
	ImageURL                    string      `json:"image_url"`
	DefaultToFiat               bool        `json:"default_to_fiat"`
	DevBuyerFeeBasisPoints      int64       `json:"dev_buyer_fee_basis_points"`
	DevSellerFeeBasisPoints     int64       `json:"dev_seller_fee_basis_points"`
	OnlyProxiedTransfers        bool        `json:"only_proxied_transfers"`
	OpenseaBuyerFeeBasisPoints  int64       `json:"opensea_buyer_fee_basis_points"`
	OpenseaSellerFeeBasisPoints int64       `json:"opensea_seller_fee_basis_points"`
	BuyerFeeBasisPoints         int64       `json:"buyer_fee_basis_points"`
	SellerFeeBasisPoints        int64       `json:"seller_fee_basis_points"`
	PayoutAddress               interface{} `json:"payout_address"`
}

type DevFeePaymentEvent

type DevFeePaymentEvent struct {
	EventType      string       `json:"event_type"`
	EventTimestamp string       `json:"event_timestamp"`
	AuctionType    interface{}  `json:"auction_type"`
	TotalPrice     interface{}  `json:"total_price"`
	Transaction    Transaction  `json:"transaction"`
	PaymentToken   PaymentToken `json:"payment_token"`
}

DevFeePaymentEvent is fee transfer event from OpenSea to Dev, It appears to be running in bulk on a regular basis.

type Event

type Event struct {
	ID                  int64               `json:"id"`
	Transaction         *Transaction        `json:"transaction"`
	PaymentToken        *PaymentToken       `json:"payment_token"`
	Asset               *Asset              `json:"asset"`
	AssetBundle         *AssetBundle        `json:"asset_bundle"`
	WinnerAccount       *Account            `json:"winner_account"`
	FromAccount         *Account            `json:"from_account"`
	ToAccount           *Account            `json:"to_account"`
	OwnerAccount        *Account            `json:"owner_account"`
	ApprovedAccount     *Account            `json:"approved_account"`
	Seller              *Account            `json:"seller"`
	DevFeePaymentEvent  *DevFeePaymentEvent `json:"dev_fee_payment_event"`
	CollectionSlug      string              `json:"collection_slug"`
	CreatedDate         TimeNano            `json:"created_date"`
	ModifiedDate        TimeNano            `json:"modified_date"`
	ContractAddress     Address             `json:"contract_address"`
	LogIndex            interface{}         `json:"log_index"`
	EventType           EventType           `json:"event_type"`
	AuctionType         string              `json:"auction_type"`
	StartingPrice       string              `json:"starting_price"`
	EndingPrice         string              `json:"ending_price"`
	Duration            interface{}         `json:"duration"`
	MinPrice            Number              `json:"min_price"`
	OfferedTo           Number              `json:"offered_to"`
	BidAmount           Number              `json:"bid_amount"`
	TotalPrice          Number              `json:"total_price"`
	CustomEventName     interface{}         `json:"custom_event_name"`
	Quantity            string              `json:"quantity"`
	PayoutAmount        interface{}         `json:"payout_amount"`
	EventTimestamp      TimeNano            `json:"event_timestamp"`
	Relayer             string              `json:"relayer"`
	Collection          int64               `json:"collection"`
	PayoutAccount       interface{}         `json:"payout_account"`
	PayoutAssetContract interface{}         `json:"payout_asset_contract"`
	PayoutCollection    interface{}         `json:"payout_collection"`
	BuyOrder            uint64              `json:"buy_order"`
	SellOrder           uint64              `json:"sell_order"`
}

func (Event) IsBundle

func (e Event) IsBundle() bool

type EventType

type EventType string
const (
	EventTypeNone               EventType = ""
	EventTypeCreated            EventType = "created"
	EventTypeSuccessful         EventType = "successful"
	EventTypeCancelled          EventType = "cancelled"
	EventTypeBidEntered         EventType = "bid_entered"
	EventTypeBidWithdrawn       EventType = "bid_withdrawn"
	EventTypeTransfer           EventType = "transfer"
	EventTypeApprove            EventType = "approve"
	EventTypeCompositionCreated EventType = "composition_created"
)

type FeeMethod

type FeeMethod uint8
const (
	ProtocolFee FeeMethod = iota
	SplitFee
)

type HowToCall

type HowToCall uint8
const (
	Call HowToCall = iota
	DelegateCall
)

type Number

type Number string

func (Number) Big

func (n Number) Big() *big.Int

type Opensea

type Opensea struct {
	API    string
	APIKey string
}

func NewOpensea

func NewOpensea(apiKey string) (*Opensea, error)

func NewOpenseaRinkeby

func NewOpenseaRinkeby(apiKey string) (*Opensea, error)

func (Opensea) GetOrders

func (o Opensea) GetOrders(assetContractAddress string, listedAfter int64) ([]*Order, error)

func (Opensea) GetOrdersWithContext

func (o Opensea) GetOrdersWithContext(ctx context.Context, assetContractAddress string, listedAfter int64) (orders []*Order, err error)

func (Opensea) GetSingleAsset

func (o Opensea) GetSingleAsset(assetContractAddress string, tokenID *big.Int) (*Asset, error)

func (Opensea) GetSingleAssetWithContext

func (o Opensea) GetSingleAssetWithContext(ctx context.Context, assetContractAddress string, tokenID *big.Int) (*Asset, error)

func (Opensea) GetSingleContract

func (o Opensea) GetSingleContract(assetContractAddress string) (*Contract, error)

func (Opensea) GetSingleContractWithContext

func (o Opensea) GetSingleContractWithContext(ctx context.Context, assetContractAddress string) (contract *Contract, err error)

func (Opensea) RetrievingEvents

func (o Opensea) RetrievingEvents(params *RetrievingEventsParams) ([]*Event, error)

func (Opensea) RetrievingEventsWithContext

func (o Opensea) RetrievingEventsWithContext(ctx context.Context, params *RetrievingEventsParams) (events []*Event, err error)

type Order

type Order struct {
	ID    int64 `json:"id"`
	Asset Asset `json:"asset"`
	// AssetBundle          interface{}          `json:"asset_bundle"`
	CreatedDate *TimeNano `json:"created_date"`
	ClosingDate *TimeNano `json:"closing_date"`
	// ClosingExtendable bool      `json:"closing_extendable"`
	ExpirationTime int64 `json:"expiration_time"`
	ListingTime    int64 `json:"listing_time"`
	// OrderHash            string               `json:"order_hash"`
	// Metadata Metadata `json:"metadata"`
	Exchange     Address `json:"exchange"`
	Maker        Account `json:"maker"`
	Taker        Account `json:"taker"`
	CurrentPrice Number  `json:"current_price"`
	// CurrentBounty        string               `json:"current_bounty"`
	// BountyMultiple       string               `json:"bounty_multiple"`
	MakerRelayerFee    Number    `json:"maker_relayer_fee"`
	TakerRelayerFee    Number    `json:"taker_relayer_fee"`
	MakerProtocolFee   Number    `json:"maker_protocol_fee"`
	TakerProtocolFee   Number    `json:"taker_protocol_fee"`
	MakerReferrerFee   Number    `json:"maker_referrer_fee"`
	FeeRecipient       Account   `json:"fee_recipient"`
	FeeMethod          FeeMethod `json:"fee_method"`
	Side               Side      `json:"side"` // 0 for buy orders and 1 for sell orders.
	SaleKind           SaleKind  `json:"sale_kind"`
	Target             Address   `json:"target"`
	HowToCall          HowToCall `json:"how_to_call"`
	Calldata           Bytes     `json:"calldata"`
	ReplacementPattern Bytes     `json:"replacement_pattern"`
	StaticTarget       Address   `json:"static_target"`
	StaticExtradata    Bytes     `json:"static_extradata"`
	PaymentToken       Address   `json:"payment_token"`
	// PaymentTokenContract PaymentTokenContract `json:"payment_token_contract"`
	BasePrice       Number `json:"base_price"`
	Extra           Number `json:"extra"`
	Quantity        string `json:"quantity"`
	Salt            Number `json:"salt"`
	V               *uint8 `json:"v"`
	R               *Bytes `json:"r"`
	S               *Bytes `json:"s"`
	ApprovedOnChain bool   `json:"approved_on_chain"`
	Cancelled       bool   `json:"cancelled"`
	Finalized       bool   `json:"finalized"`
	MarkedInvalid   bool   `json:"marked_invalid"`
}

func (Order) IsPrivate

func (o Order) IsPrivate() bool

type PaymentToken

type PaymentToken struct {
	Symbol   string  `json:"symbol"`
	Address  Address `json:"address"`
	ImageURL string  `json:"image_url"`
	Name     string  `json:"name"`
	Decimals int64   `json:"decimals"`
	EthPrice string  `json:"eth_price"`
	UsdPrice string  `json:"usd_price"`
}

type RetrievingEventsParams

type RetrievingEventsParams struct {
	AssetContractAddress Address
	TokenID              int32
	AccountAddress       Address
	EventType            EventType
	OnlyOpensea          bool
	AuctionType          AuctionType
	Offset               int
	Limit                int
	OccurredBefore       int64
	OccurredAfter        int64
}

func NewRetrievingEventsParams

func NewRetrievingEventsParams() *RetrievingEventsParams

func (RetrievingEventsParams) Encode

func (p RetrievingEventsParams) Encode() string

func (*RetrievingEventsParams) SetAccountAddress

func (p *RetrievingEventsParams) SetAccountAddress(addr string) (err error)

func (*RetrievingEventsParams) SetAssetContractAddress

func (p *RetrievingEventsParams) SetAssetContractAddress(addr string) (err error)

type SaleKind

type SaleKind uint8
const (
	FixedOrMinBit SaleKind = iota // 0 for fixed-price sales or min-bid auctions
	DutchAuctions                 // 1 for declining-price Dutch Auctions
)

type Side

type Side uint8
const (
	Buy Side = iota
	Sell
)

type TimeNano

type TimeNano time.Time

func (TimeNano) MarshalJSON

func (t TimeNano) MarshalJSON() ([]byte, error)

func (TimeNano) Time

func (t TimeNano) Time() time.Time

func (*TimeNano) UnmarshalJSON

func (t *TimeNano) UnmarshalJSON(b []byte) error

type Trait

type Trait struct {
	TraitType   string          `json:"trait_type"`
	Value       json.RawMessage `json:"value"`
	DisplayType interface{}     `json:"display_type"`
	MaxValue    interface{}     `json:"max_value"`
	TraitCount  int64           `json:"trait_count"`
	Order       interface{}     `json:"order"`
}

type Transaction

type Transaction struct {
	ID               int64    `json:"id"`
	FromAccount      Account  `json:"from_account"`
	ToAccount        Account  `json:"to_account"`
	CreatedDate      TimeNano `json:"created_date"`
	ModifiedDate     TimeNano `json:"modified_date"`
	TransactionHash  string   `json:"transaction_hash"`
	TransactionIndex string   `json:"transaction_index"`
	BlockNumber      string   `json:"block_number"`
	BlockHash        string   `json:"block_hash"`
	Timestamp        string   `json:"timestamp"`
}

type User

type User struct {
	Username string `json:"username"`
}

type Value

type Value struct {
	Integer *int64
	String  *string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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