nft

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: MIT Imports: 27 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 (
	// TokenIDLength is the length of an NFT token ID
	TokenIDLength = 32

	// LowEntropyTokenIDMax is the max of a low entropy NFT token ID big integer. Used only for special cases.
	LowEntropyTokenIDMax = "999999999999999"
)
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 */
)

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) (confirmations chan error, err error)
}

API defines set of functions to interact with centrifuge chain

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
	GetLowEntropyNFTTokenEnabled() bool
}

Config is the config interface for nft package

type MintNFTRequest

type MintNFTRequest struct {
	DocumentID               []byte
	RegistryAddress          common.Address
	DepositAddress           common.Address
	AssetManagerAddress      common.Address
	ProofFields              []string
	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

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

	// static proofs 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 Service added in v1.0.0

type Service interface {
	// MintNFT mints an NFT
	MintNFT(ctx context.Context, request MintNFTRequest) (*TokenResponse, chan error, error)
	// TransferFrom transfers an NFT to another address
	TransferFrom(ctx context.Context, registry common.Address, to common.Address, tokenID TokenID) (*TokenResponse, chan error, error)
	// OwnerOf returns the owner of an NFT
	OwnerOf(registry common.Address, tokenID []byte) (owner common.Address, err 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 NewLowEntropyTokenID

func NewLowEntropyTokenID() TokenID

NewLowEntropyTokenID returns a new low entropy(less than LowEntropyTokenIDMax) TokenID. The Dharma NFT Collateralizer and other contracts require tokenIds that are shorter than the ERC721 standard bytes32. This option reduces the maximum integer of the tokenId to 999,999,999,999,999. There are security implications of doing this. Specifically the risk of two users picking the same token id and minting it at the same time goes up and it theoretically could lead to a loss of an NFT with large enough NFTRegistries (>100'000 tokens). It is not recommended to use this option.

func NewTokenID

func NewTokenID() TokenID

NewTokenID returns a new random TokenID

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.

Jump to

Keyboard shortcuts

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