contract

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: MIT Imports: 10 Imported by: 9

Documentation

Overview

Copyright (c) 2020-2022 Blockwatch Data Inc. Author: alex@blockwatch.cc

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = CallOptions{
	Confirmations: 6,
	TTL:           120,
	MaxFee:        1000000,
}

Functions

This section is empty.

Types

type CallArguments

type CallArguments interface {
	WithSource(tezos.Address)
	WithDestination(tezos.Address)
	WithAmount(tezos.N)
	Encode() *codec.Transaction
	Parameters() *micheline.Parameters
}

type CallOptions added in v1.12.0

type CallOptions struct {
	Confirmations int64         // number of confirmations to wait after broadcast
	TTL           int64         // max number of blocks to wait in total
	Limits        tezos.Limits  // optional gas, storage and fee limits to override estimations
	MaxFee        int64         // max acceptable fee, optional (default = 0)
	Signer        signer.Signer // optional signer interface to use for signing the transaction
	Observer      *rpc.Observer // optional custom block observer for waiting on confirmations
}

type Contract

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

func NewContract

func NewContract(addr tezos.Address, cli *rpc.Client) *Contract

func (Contract) Address

func (c Contract) Address() tezos.Address

func (*Contract) AsFA1

func (c *Contract) AsFA1() *FA1Token

func (*Contract) AsFA2

func (c *Contract) AsFA2(id int64) *FA2Token

func (*Contract) Call

func (c *Contract) Call(ctx context.Context, args CallArguments, opts *CallOptions) (*rpc.Receipt, error)

func (*Contract) CallMulti

func (c *Contract) CallMulti(ctx context.Context, args []CallArguments, opts *CallOptions) (*rpc.Receipt, error)

func (*Contract) DecodeScript

func (c *Contract) DecodeScript(data []byte) error

func (*Contract) DecodeStorage

func (c *Contract) DecodeStorage(data []byte) error

func (*Contract) Deploy

func (c *Contract) Deploy(ctx context.Context, opts *CallOptions) (*rpc.Receipt, error)

func (*Contract) DeployExt

func (c *Contract) DeployExt(ctx context.Context, delegate tezos.Address, balance tezos.N, opts *CallOptions) (*rpc.Receipt, error)

func (*Contract) Entrypoint

func (c *Contract) Entrypoint(name string) (micheline.Entrypoint, bool)

entrypoints and callbacks

func (Contract) IsFA1

func (c Contract) IsFA1() bool

func (Contract) IsFA12

func (c Contract) IsFA12() bool

func (Contract) IsFA2

func (c Contract) IsFA2() bool

func (Contract) IsManagerTz

func (c Contract) IsManagerTz() bool

func (*Contract) Metadata

func (c *Contract) Metadata() *Tz16

func (*Contract) Resolve

func (c *Contract) Resolve(ctx context.Context) error

func (*Contract) ResolveMetadata

func (c *Contract) ResolveMetadata(ctx context.Context) (*Tz16, error)

func (*Contract) RunView

func (c *Contract) RunView(ctx context.Context, name string, args micheline.Prim) (micheline.Prim, error)

Executes TZIP-4 fake views from callback entrypoints

func (*Contract) RunViewExt

func (c *Contract) RunViewExt(ctx context.Context, name string, args micheline.Prim, source, payer tezos.Address, gas int64) (micheline.Prim, error)

func (Contract) Script

func (c Contract) Script() *micheline.Script

func (Contract) Storage

func (c Contract) Storage() *micheline.Prim

func (*Contract) View

func (c *Contract) View(name string) (micheline.View, bool)

on-chain views

func (*Contract) WithScript

func (c *Contract) WithScript(script *micheline.Script) *Contract

func (*Contract) WithStorage

func (c *Contract) WithStorage(store *micheline.Prim) *Contract

type FA1Approval

type FA1Approval struct {
	Spender tezos.Address `json:"spender"`
	Value   tezos.Z       `json:"value"`
}

type FA1ApprovalArgs

type FA1ApprovalArgs struct {
	TxArgs
	Approval FA1Approval `json:"approve"`
}

func (FA1ApprovalArgs) Encode

func (p FA1ApprovalArgs) Encode() *codec.Transaction

func (FA1ApprovalArgs) Parameters

func (a FA1ApprovalArgs) Parameters() *micheline.Parameters

type FA1Token

type FA1Token struct {
	Address tezos.Address
	// contains filtered or unexported fields
}

Represents a generic FA1 (tzip5) or FA1.2 (tzip7) token

func NewFA1Token

func NewFA1Token(addr tezos.Address, cli *rpc.Client) *FA1Token

func (FA1Token) Contract

func (t FA1Token) Contract() *Contract

func (FA1Token) Equal

func (t FA1Token) Equal(v FA1Token) bool

func (FA1Token) GetAllowance

func (t FA1Token) GetAllowance(ctx context.Context, owner, spender tezos.Address) (tezos.Z, error)

func (FA1Token) GetBalance

func (t FA1Token) GetBalance(ctx context.Context, owner tezos.Address) (tezos.Z, error)

func (FA1Token) GetMetadata added in v1.12.0

func (t FA1Token) GetMetadata(ctx context.Context) (TokenMetadata, error)

func (FA1Token) GetTotalSupply

func (t FA1Token) GetTotalSupply(ctx context.Context) (tezos.Z, error)

type FA1Transfer

type FA1Transfer struct {
	From   tezos.Address `json:"from"`
	To     tezos.Address `json:"to"`
	Amount tezos.Z       `json:"value"`
}

func (*FA1Transfer) UnmarshalJSON

func (t *FA1Transfer) UnmarshalJSON(data []byte) error

compatible with micheline.Value.Unmarshal()

type FA1TransferArgs

type FA1TransferArgs struct {
	TxArgs
	Transfer FA1Transfer
}

func (FA1TransferArgs) Encode

func (p FA1TransferArgs) Encode() *codec.Transaction

func (FA1TransferArgs) Parameters

func (t FA1TransferArgs) Parameters() *micheline.Parameters

type FA1TransferReceipt

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

func NewFA1TransferReceipt

func NewFA1TransferReceipt(tx *rpc.Transaction) (*FA1TransferReceipt, error)

func (FA1TransferReceipt) BalanceUpdates

func (r FA1TransferReceipt) BalanceUpdates() []TokenBalance

func (FA1TransferReceipt) Costs

func (r FA1TransferReceipt) Costs() tezos.Costs

func (FA1TransferReceipt) IsSuccess

func (r FA1TransferReceipt) IsSuccess() bool

func (FA1TransferReceipt) Request

func (r FA1TransferReceipt) Request() FA1Transfer

func (FA1TransferReceipt) Result

func (r FA1TransferReceipt) Result() *rpc.Transaction

type FA2Approval

type FA2Approval struct {
	Owner    tezos.Address `json:"owner"`
	Operator tezos.Address `json:"operator"`
	TokenId  tezos.Z       `json:"token_id"`
	Add      bool          `json:"-"`
}

func (*FA2Approval) UnmarshalJSON

func (p *FA2Approval) UnmarshalJSON(data []byte) error

type FA2ApprovalArgs

type FA2ApprovalArgs struct {
	TxArgs
	Approvals []FA2Approval `json:"update_operators"`
}

func NewFA2ApprovalArgs

func NewFA2ApprovalArgs() *FA2ApprovalArgs

func (*FA2ApprovalArgs) AddOperator

func (p *FA2ApprovalArgs) AddOperator(owner, operator tezos.Address, id tezos.Z) *FA2ApprovalArgs

func (FA2ApprovalArgs) Encode

func (p FA2ApprovalArgs) Encode() *codec.Transaction

func (FA2ApprovalArgs) Parameters

func (p FA2ApprovalArgs) Parameters() *micheline.Parameters

func (*FA2ApprovalArgs) RemoveOperator

func (p *FA2ApprovalArgs) RemoveOperator(owner, operator tezos.Address, id tezos.Z) *FA2ApprovalArgs

type FA2BalanceRequest

type FA2BalanceRequest struct {
	Owner   tezos.Address `json:"owner"`
	TokenId tezos.Z       `json:"token_id"`
}

type FA2BalanceResponse

type FA2BalanceResponse struct {
	Request FA2BalanceRequest `json:"request"`
	Balance tezos.Z           `json:"balance"`
}

type FA2Token

type FA2Token struct {
	Address tezos.Address
	TokenId tezos.Z
	// contains filtered or unexported fields
}

Represents a generic FA2 (tzip12) token

func NewFA2Token

func NewFA2Token(addr tezos.Address, id int64, cli *rpc.Client) *FA2Token

func (FA2Token) Contract

func (t FA2Token) Contract() *Contract

func (FA2Token) Equal

func (t FA2Token) Equal(v FA2Token) bool

func (FA2Token) GetBalances

func (t FA2Token) GetBalances(ctx context.Context, req []FA2BalanceRequest) ([]FA2BalanceResponse, error)

func (FA2Token) GetMetadata added in v1.12.0

func (t FA2Token) GetMetadata(ctx context.Context) (TokenMetadata, error)

type FA2Transfer

type FA2Transfer struct {
	From    tezos.Address
	To      tezos.Address
	TokenId tezos.Z
	Amount  tezos.Z
}

func (FA2Transfer) Prim

func (t FA2Transfer) Prim() micheline.Prim

type FA2TransferArgs

type FA2TransferArgs struct {
	TxArgs
	Transfers FA2TransferList
}

func NewFA2TransferArgs

func NewFA2TransferArgs() *FA2TransferArgs

func (FA2TransferArgs) Encode

func (p FA2TransferArgs) Encode() *codec.Transaction

func (*FA2TransferArgs) Optimize

func (p *FA2TransferArgs) Optimize() *FA2TransferArgs

func (FA2TransferArgs) Parameters

func (t FA2TransferArgs) Parameters() *micheline.Parameters

func (*FA2TransferArgs) WithTransfer

func (p *FA2TransferArgs) WithTransfer(from, to tezos.Address, id, amount tezos.Z) *FA2TransferArgs

type FA2TransferList

type FA2TransferList []FA2Transfer

func (FA2TransferList) Len

func (l FA2TransferList) Len() int

func (FA2TransferList) Less

func (l FA2TransferList) Less(i, j int) bool

func (FA2TransferList) Swap

func (l FA2TransferList) Swap(i, j int)

func (*FA2TransferList) UnmarshalJSON

func (t *FA2TransferList) UnmarshalJSON(data []byte) error

compatible with micheline.Value.Unmarshal()

type FA2TransferReceipt

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

TODO: make it work for internal results as well (so we can use it for crawling)

func NewFA2TransferReceipt

func NewFA2TransferReceipt(tx *rpc.Transaction) (*FA2TransferReceipt, error)

func (FA2TransferReceipt) BalanceUpdates

func (r FA2TransferReceipt) BalanceUpdates() []TokenBalance

func (FA2TransferReceipt) Costs

func (r FA2TransferReceipt) Costs() tezos.Costs

func (FA2TransferReceipt) IsSuccess

func (r FA2TransferReceipt) IsSuccess() bool

func (FA2TransferReceipt) Request

func (r FA2TransferReceipt) Request() FA2TransferList

func (FA2TransferReceipt) Result

func (r FA2TransferReceipt) Result() *rpc.Transaction

type NftBalance added in v1.12.0

type NftBalance struct {
	Owner   tezos.Address
	TokenId tezos.Z
	Balance tezos.Z
	// contains filtered or unexported fields
}

func (*NftBalance) UnmarshalPrim added in v1.12.0

func (b *NftBalance) UnmarshalPrim(prim micheline.Prim) error

type NftBalanceTyp1 added in v1.12.0

type NftBalanceTyp1 NftBalance

1 @key: {0: address, 1: nat} @value: nat

func (*NftBalanceTyp1) UnmarshalPrim added in v1.12.0

func (b *NftBalanceTyp1) UnmarshalPrim(prim micheline.Prim) error

type NftBalanceTyp2 added in v1.12.0

type NftBalanceTyp2 NftBalance

2 @key: nat @value: address

func (*NftBalanceTyp2) UnmarshalPrim added in v1.12.0

func (b *NftBalanceTyp2) UnmarshalPrim(prim micheline.Prim) error

type NftBalanceTyp3 added in v1.12.0

type NftBalanceTyp3 NftBalance

3 @key: {0: nat, 1: address} @value: nat

func (*NftBalanceTyp3) UnmarshalPrim added in v1.12.0

func (b *NftBalanceTyp3) UnmarshalPrim(prim micheline.Prim) error

type NftLedger

type NftLedger struct {
	Address tezos.Address
	Schema  NftLedgerSchema
	Bigmap  int64
}

func (NftLedger) DecodeBalance added in v1.12.0

func (l NftLedger) DecodeBalance(prim micheline.Prim) (bal NftBalance, err error)

type NftLedgerSchema

type NftLedgerSchema byte
const (
	NftLedgerSchemaInvalid NftLedgerSchema = iota
	NftLedgerSchema1
	NftLedgerSchema2
	NftLedgerSchema3
)

func DetectNftLedger

func DetectNftLedger(key, val micheline.Prim) NftLedgerSchema

Detect NFT legder schema from bigmap key + value type.

func (NftLedgerSchema) IsValid

func (s NftLedgerSchema) IsValid() bool

type TokenBalance

type TokenBalance struct {
	Owner   tezos.Address
	Token   tezos.Address
	TokenId tezos.Z
	Balance tezos.Z
}

type TokenKind

type TokenKind byte
const (
	TokenKindInvalid TokenKind = iota
	TokenKindFA1
	TokenKindFA1_2
	TokenKindFA2
	TokenKindNFT
)

func (TokenKind) String

func (k TokenKind) String() string

type TokenMetadata

type TokenMetadata struct {
	Name     string `json:"name"`
	Symbol   string `json:"symbol"`
	Decimals int    `json:"decimals"`
}

Represents Tzip12 token metadata used by FA1 and FA2 tokens

type TxArgs

type TxArgs struct {
	Source      tezos.Address
	Destination tezos.Address
	Amount      tezos.N
}

func (*TxArgs) WithAmount

func (a *TxArgs) WithAmount(amount tezos.N)

func (*TxArgs) WithDestination

func (a *TxArgs) WithDestination(addr tezos.Address)

func (*TxArgs) WithSource

func (a *TxArgs) WithSource(addr tezos.Address)

type Tz16

type Tz16 struct {
	Name        string       `json:"name"`
	Description string       `json:"description,omitempty"`
	Version     string       `json:"version,omitempty"`
	License     *Tz16License `json:"license,omitempty"`
	Authors     []string     `json:"authors,omitempty"`
	Homepage    string       `json:"homepage,omitempty"`
	Source      *Tz16Source  `json:"source,omitempty"`
	Interfaces  []string     `json:"interfaces,omitempty"`
	Errors      []Tz16Error  `json:"errors,omitempty"`
	Views       []Tz16View   `json:"views,omitempty"`
}

Represents Tzip16 contract metadata

func (Tz16) HasView

func (t Tz16) HasView(name string) bool

func (Tz16) Validate

func (t Tz16) Validate() []error

type Tz16CodeAnnotation

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

type Tz16Error

type Tz16Error struct {
	Error     *micheline.Prim `json:"error,omitempty"`
	Expansion *micheline.Prim `json:"expansion,omitempty"`
	Languages []string        `json:"languages,omitempty"`
	View      string          `json:"view,omitempty"`
}

type Tz16License

type Tz16License struct {
	Name    string `json:"name"`
	Details string `json:"details,omitempty"`
}

type Tz16RestView

type Tz16RestView struct {
	SpecUri string `json:"specificationUri"`
	BaseUri string `json:"baseUri"`
	Path    string `json:"path"`
	Method  string `json:"method"`
}

type Tz16Source

type Tz16Source struct {
	Tools    []string `json:"tools"`
	Location string   `json:"location,omitempty"`
}

type Tz16StorageView

type Tz16StorageView struct {
	ParamType   *micheline.Prim      `json:"parameter,omitempty"`
	ReturnType  micheline.Prim       `json:"returnType"`
	Code        micheline.Prim       `json:"code"`
	Annotations []Tz16CodeAnnotation `json:"annotations,omitempty"`
	Version     string               `json:"version,omitempty"`
}

type Tz16View

type Tz16View struct {
	Name            string         `json:"name"`
	Description     string         `json:"description,omitempty"`
	Pure            bool           `json:"pure,omitempty"`
	Implementations []Tz16ViewImpl `json:"implementations,omitempty"`
}

type Tz16ViewImpl

type Tz16ViewImpl struct {
	Storage *Tz16StorageView `json:"michelsonStorageView,omitempty"`
	Rest    *Tz16RestView    `json:"restApiQuery,omitempty"`
}

Jump to

Keyboard shortcuts

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