transaction

package
v1.0.0-rc-6 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// L1Commitment calculation has changed from version 0 to version 1.
	// The structure is actually the same, but the L1 commitment in V0
	// refers to an empty state, and in V1 refers to the first initialized
	// state.
	StateMetadataSupportedVersion byte = 1
)

Variables

View Source
var (
	ErrNotEnoughBaseTokens                  = errors.New("not enough base tokens")
	ErrNotEnoughBaseTokensForStorageDeposit = errors.New("not enough base tokens for storage deposit")
	ErrNotEnoughNativeTokens                = errors.New("not enough native tokens")
)
View Source
var ErrNoAliasOutputAtIndex0 = errors.New("origin AliasOutput not found at index 0")

Functions

func AdjustToMinimumStorageDeposit added in v1.0.3

func AdjustToMinimumStorageDeposit[T iotago.Output](out T) T

func AssetsFromOutput added in v0.3.0

func AssetsFromOutput(o iotago.Output) *isc.Assets

func BasicOutputFromPostData added in v0.3.0

func BasicOutputFromPostData(
	senderAddress iotago.Address,
	senderContract isc.ContractIdentity,
	par isc.RequestParameters,
) *iotago.BasicOutput

BasicOutputFromPostData creates extended output object from parameters. It automatically adjusts amount of base tokens required for the storage deposit

func ComputeInputsAndRemainder added in v1.0.3

func ComputeInputsAndRemainder(
	senderAddress iotago.Address,
	baseTokenOut uint64,
	tokensOut map[iotago.NativeTokenID]*big.Int,
	nftsOut map[iotago.NFTID]bool,
	unspentOutputs iotago.OutputSet,
	unspentOutputIDs iotago.OutputIDs,
) (
	iotago.OutputIDs,
	*iotago.BasicOutput,
	error,
)

computeInputsAndRemainder computes inputs and remainder for given outputs balances. Takes into account minimum storage deposit requirements The inputs are consumed one by one in the order provided in the parameters. Consumes only what is needed to cover output balances Returned reminder is nil if not needed

func CreateAndSignTx added in v0.3.0

func CreateAndSignTx(inputs iotago.Inputs, inputsCommitment []byte, outputs iotago.Outputs, wallet *cryptolib.KeyPair, networkID uint64) (*iotago.Transaction, error)

func GetAnchorFromTransaction added in v0.3.0

func GetAnchorFromTransaction(tx *iotago.Transaction) (*isc.StateAnchor, *iotago.AliasOutput, error)

GetAnchorFromTransaction analyzes the output at index 0 and extracts anchor information. Otherwise error

func L1CommitmentFromAliasOutput added in v1.0.3

func L1CommitmentFromAliasOutput(ao *iotago.AliasOutput) (*state.L1Commitment, error)

func MakeAnchorTransaction added in v0.3.0

func MakeAnchorTransaction(essence *iotago.TransactionEssence, sig iotago.Signature) *iotago.Transaction

func MakeBasicOutput added in v0.3.0

func MakeBasicOutput(
	targetAddress iotago.Address,
	senderAddress iotago.Address,
	assets *isc.Assets,
	metadata *isc.RequestMetadata,
	options isc.SendOptions,
) *iotago.BasicOutput

MakeBasicOutput creates new output from input parameters (ignoring storage deposit).

func MakeRequestTransactionOutput added in v1.0.3

func MakeRequestTransactionOutput(par NewRequestTransactionParams) iotago.Output

func MakeSignatureAndAliasUnlockFeatures added in v0.3.0

func MakeSignatureAndAliasUnlockFeatures(totalInputs int, sig iotago.Signature) iotago.Unlocks

func MakeSignatureAndReferenceUnlocks added in v0.3.0

func MakeSignatureAndReferenceUnlocks(totalInputs int, sig iotago.Signature) iotago.Unlocks

func MustL1CommitmentFromAliasOutput added in v1.0.3

func MustL1CommitmentFromAliasOutput(ao *iotago.AliasOutput) *state.L1Commitment

func NFTOutputFromPostData added in v0.3.0

func NFTOutputFromPostData(
	senderAddress iotago.Address,
	senderContract isc.ContractIdentity,
	par isc.RequestParameters,
	nft *isc.NFT,
) *iotago.NFTOutput

func NewMintNFTsTransaction added in v1.0.3

func NewMintNFTsTransaction(par MintNFTsTransactionParams) (*iotago.Transaction, error)

func NewRequestTransaction

func NewRequestTransaction(par NewRequestTransactionParams) (*iotago.Transaction, error)

NewRequestTransaction creates a transaction including one or more requests to a chain. Empty assets in the request data defaults to 1 base token, which later is adjusted to the minimum storage deposit Assumes all UnspentOutputs and corresponding UnspentOutputIDs can be used as inputs, i.e. are unlockable for the sender address

func NewRotateChainStateControllerTx added in v0.3.0

func NewRotateChainStateControllerTx(
	aliasID iotago.AliasID,
	newStateController iotago.Address,
	chainOutputID iotago.OutputID,
	chainOutput iotago.Output,
	kp *cryptolib.KeyPair,
) (*iotago.Transaction, error)

func NewTransferTransaction added in v0.3.0

func NewTransferTransaction(params NewTransferTransactionParams) (*iotago.Transaction, error)

NewTransferTransaction creates a basic output transaction that sends L1 Token to another L1 address

func NftOutputFromBasicOutput added in v0.3.0

func NftOutputFromBasicOutput(o *iotago.BasicOutput, nft *isc.NFT) *iotago.NFTOutput

Types

type MintNFTsTransactionParams added in v1.0.3

type MintNFTsTransactionParams struct {
	IssuerKeyPair      *cryptolib.KeyPair
	CollectionOutputID *iotago.OutputID
	Target             iotago.Address
	ImmutableMetadata  [][]byte
	UnspentOutputs     iotago.OutputSet
	UnspentOutputIDs   iotago.OutputIDs
}

type NewRequestTransactionParams

type NewRequestTransactionParams struct {
	SenderKeyPair                   *cryptolib.KeyPair
	SenderAddress                   iotago.Address // might be different from the senderKP address (when sending as NFT or alias)
	UnspentOutputs                  iotago.OutputSet
	UnspentOutputIDs                iotago.OutputIDs
	Request                         *isc.RequestParameters
	NFT                             *isc.NFT
	DisableAutoAdjustStorageDeposit bool // if true, the minimal storage deposit won't be adjusted automatically
}

type NewTransferTransactionParams added in v0.3.0

type NewTransferTransactionParams struct {
	DisableAutoAdjustStorageDeposit bool // if true, the minimal storage deposit won't be adjusted automatically
	FungibleTokens                  *isc.Assets
	SendOptions                     isc.SendOptions
	SenderAddress                   iotago.Address
	SenderKeyPair                   *cryptolib.KeyPair
	TargetAddress                   iotago.Address
	UnspentOutputs                  iotago.OutputSet
	UnspentOutputIDs                iotago.OutputIDs
}

type StateMetadata added in v1.0.3

type StateMetadata struct {
	Version       byte
	L1Commitment  *state.L1Commitment
	GasFeePolicy  *gas.FeePolicy
	SchemaVersion uint32
	PublicURL     string
}

func NewStateMetadata added in v1.0.3

func NewStateMetadata(
	l1Commitment *state.L1Commitment,
	gasFeePolicy *gas.FeePolicy,
	schemaVersion uint32,
	publicURL string,
) *StateMetadata

func StateMetadataFromBytes added in v1.0.3

func StateMetadataFromBytes(data []byte) (*StateMetadata, error)

func (*StateMetadata) Bytes added in v1.0.3

func (s *StateMetadata) Bytes() []byte

func (*StateMetadata) Read added in v1.0.3

func (s *StateMetadata) Read(r io.Reader) error

func (*StateMetadata) Write added in v1.0.3

func (s *StateMetadata) Write(w io.Writer) error

Jump to

Keyboard shortcuts

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