nft

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ValidateMint is the module call for validate NFT Mint on Centrifuge chain
	ValidateMint = "Nfts.validate_mint"
	// TargetChainID is the target chain where to mint the NFT against - 0 Ethereum
	TargetChainID = 0
)
View Source
const (
	// ErrNFTMinted error for NFT already minted for registry
	ErrNFTMinted = errors.Error("NFT already minted")

	// GenericMintMethodABI constant interface to interact with mint methods
	GenericMintMethodABI = `` /* 485-byte string literal not displayed */

	// AssetStoredEventSignature used for finding events
	AssetStoredEventSignature = "AssetStored(bytes32)"

	// ABI is string abi with required methods to call the NFT registry contract
	ABI = `` /* 612-byte string literal not displayed */
)
View Source
const (
	// TokenIDLength is the length of an NFT token ID
	TokenIDLength = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API added in v1.0.0

type API interface {
	// ValidateNFT validates the Proofs and triggers a bridge event to mint NFT on Ethereum chain.
	ValidateNFT(
		ctx context.Context,
		anchorID [32]byte,
		depositAddress [20]byte,
		proofs []SubstrateProof,
		staticProofs [3][32]byte) (err error)

	// CreateRegistry creates a new nft registry on centrifuge chain
	CreateRegistry(ctx context.Context, info RegistryInfo) (registryID common.Address, err error)

	// MintNFT sends an extrinsic to mint nft in given registry on cent chain
	MintNFT(ctx context.Context, owner types.AccountID, registry types.H160, tokenID types.U256, assetInfo AssetInfo, mintInfo MintInfo) (info centchain.ExtrinsicInfo, err error)

	// TransferNFT transfers nft from current account to destAcc
	TransferNFT(ctx context.Context, registry common.Address, tokenID TokenID, destAcc types.AccountID) (info centchain.ExtrinsicInfo, err error)

	// OwnerOf returns the current owner of the Token
	OwnerOf(registry common.Address, tokenID TokenID) (owner types.AccountID, err error)
}

API defines set of functions to interact with centrifuge chain

type AssetInfo added in v1.3.0

type AssetInfo struct {
	Metadata []byte
}

AssetInfo contains metadata of an nft

type Bootstrapper

type Bootstrapper struct{}

Bootstrapper implements bootstrap.Bootstrapper.

func (*Bootstrapper) Bootstrap

func (*Bootstrapper) Bootstrap(ctx map[string]interface{}) error

Bootstrap initializes the invoice unpaid contract

type Config

type Config interface {
	GetEthereumContextWaitTimeout() time.Duration
}

Config is the config interface for nft package

type MintInfo added in v1.3.0

type MintInfo struct {
	AnchorID     [32]byte
	StaticHashes [3][32]byte
	Proofs       []Proof
}

MintInfo has Proofs to be validated to mint NFT

type MintNFTJob added in v1.3.0

type MintNFTJob struct {
	jobs.Base
	// contains filtered or unexported fields
}

MintNFTJob mints and NFT async. args are as follows accountID, documentID, tokenID, MintNFTRequest

func (*MintNFTJob) New added in v1.3.0

func (m *MintNFTJob) New() gocelery.Runner

New returns a new instance of MintNFTJob

type MintNFTOnCCJob added in v1.3.0

type MintNFTOnCCJob struct {
	jobs.Base
	// contains filtered or unexported fields
}

MintNFTOnCCJob mints and NFT async. args are as follows accountID, tokenID, MintNFTOnCCRequest

func (*MintNFTOnCCJob) New added in v1.3.0

func (m *MintNFTOnCCJob) New() gocelery.Runner

New returns a new instance of MintNFTOnCCJob

type MintNFTOnCCRequest added in v1.3.0

type MintNFTOnCCRequest struct {
	DocumentID         []byte
	ProofFields        []string
	RegistryAddress    common.Address
	DepositAddress     types.AccountID
	GrantNFTReadAccess bool
}

MintNFTOnCCRequest request to mint nft on centrifuge chain.

type MintNFTRequest

type MintNFTRequest struct {
	DocumentID               []byte
	ProofFields              []string
	RegistryAddress          common.Address
	DepositAddress           common.Address
	AssetManagerAddress      common.Address
	GrantNFTReadAccess       bool
	SubmitTokenProof         bool
	SubmitNFTReadAccessProof bool
}

MintNFTRequest holds required fields for minting NFT

type MintRequest

type MintRequest struct {

	// To is the address of the recipient of the minted token
	To common.Address

	// TokenID is the ID for the minted token
	TokenID *big.Int

	// AnchorID is the ID of the document as identified by the set up anchorRepository.
	AnchorID anchors.AnchorID

	// NextAnchorID is the next ID of the document, when updated
	NextAnchorID *big.Int

	// LeftDataRoot of the document
	LeftDataRoot [32]byte

	// RightDataRoot of the document
	RightDataRoot [32]byte

	// SigningRoot of the document
	SigningRoot [32]byte

	// SignaturesRoot of the document
	SignaturesRoot [32]byte

	// Props contains the compact props for readRole and tokenRole
	Props [][]byte

	// Values are the values of the leafs that is being proved Will be converted to string and concatenated for proof
	// verification as outlined in precise-proofs library.
	Values [][]byte

	// Salts are the salts for the field that is being proved Will be concatenated for proof verification as outlined
	// in precise-proofs library.
	Salts [][32]byte

	// Proofs are the documents Proofs that are needed
	Proofs [][][32]byte

	// BundledHash is the keccak hash of to + (props+values+salts)
	BundledHash [32]byte

	// StaticProofs holds data root, sibling root and signature root
	StaticProofs [3][32]byte
}

MintRequest holds the data needed to mint and NFT from a Centrifuge document

func NewMintRequest

func NewMintRequest(
	tokenID TokenID,
	to common.Address,
	anchorID anchors.AnchorID,
	nextAnchorID anchors.AnchorID,
	leftDataRoot, rightDataRoot, signingRoot, signaturesRoot []byte,
	proofs []*proofspb.Proof) (MintRequest, error)

NewMintRequest converts the parameters and returns a struct with needed parameter for minting

type Proof added in v1.3.0

type Proof struct {
	Value    []byte
	Property []byte
	Salt     [32]byte
	Hashes   [][32]byte
}

Proof is single nft proof

type RegistryInfo added in v1.3.0

type RegistryInfo struct {
	OwnerCanBurn bool
	Fields       [][]byte
}

RegistryInfo is used as parameter to create registry on cent chain

type Service added in v1.0.0

type Service interface {
	// MintNFT mints an NFT
	MintNFT(ctx context.Context, request MintNFTRequest) (*TokenResponse, error)
	// TransferFrom transfers an NFT to another address
	TransferFrom(ctx context.Context, registry common.Address, to common.Address, tokenID TokenID) (*TokenResponse, error)
	// OwnerOf returns the owner of an NFT
	OwnerOf(registry common.Address, tokenID []byte) (owner common.Address, err error)
	// MintNFTOnCC mints an NFT on Centrifuge chain
	MintNFTOnCC(ctx context.Context, req MintNFTOnCCRequest) (*TokenResponse, error)
	// OwnerOfOnCC returns the owner of the NFT
	OwnerOfOnCC(registry common.Address, tokenID []byte) (types.AccountID, error)
	// TransferNFT transfers NFT to `to` account
	TransferNFT(ctx context.Context, registry common.Address, tokenID TokenID, to types.AccountID) (*TokenResponse, error)
}

Service defines the NFT service to mint and transfer NFTs.

type SubstrateProof added in v1.0.0

type SubstrateProof struct {
	LeafHash     [32]byte
	SortedHashes [][32]byte
}

SubstrateProof holds a single proof value with specific types that goes hand in hand with types on cent chain

type TokenID

type TokenID [TokenIDLength]byte

TokenID is uint256 in Solidity (256 bits | max value is 2^256-1) tokenID should be random 32 bytes (32 byte = 256 bits)

func NewTokenID

func NewTokenID() TokenID

NewTokenID returns a new random TokenID

func TokenIDFromBytes added in v1.3.0

func TokenIDFromBytes(tokenID []byte) (TokenID, error)

TokenIDFromBytes converts the []byte to TokenID type

func TokenIDFromString

func TokenIDFromString(hexStr string) (TokenID, error)

TokenIDFromString converts given hex string to a TokenID

func (TokenID) BigInt

func (t TokenID) BigInt() *big.Int

BigInt converts tokenID to big int

func (TokenID) MarshalText added in v1.2.0

func (t TokenID) MarshalText() (text []byte, err error)

MarshalText converts the Token to its text form

func (TokenID) String

func (t TokenID) String() string

func (*TokenID) UnmarshalText added in v1.2.0

func (t *TokenID) UnmarshalText(text []byte) error

UnmarshalText converts text to TokenID

type TokenResponse added in v1.0.0

type TokenResponse struct {
	TokenID string
	JobID   string
}

TokenResponse holds tokenID and transaction ID.

type TransferNFTJob added in v1.3.0

type TransferNFTJob struct {
	jobs.Base
	// contains filtered or unexported fields
}

TransferNFTJob is a job runner for transferring NFT ownership args are as follows did(from), to, registry, tokenID

func (*TransferNFTJob) New added in v1.3.0

func (t *TransferNFTJob) New() gocelery.Runner

New returns a new instance of TransferNFTJob

Jump to

Keyboard shortcuts

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