metadata

package
v0.0.0-...-6729ccb Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InvalidMeta = 1

	IssuingRequestMeta     = 24
	IssuingResponseMeta    = 25
	ContractingRequestMeta = 26
	IssuingETHRequestMeta  = 80
	IssuingETHResponseMeta = 81

	ShardBlockReward             = 36
	AcceptedBlockRewardInfoMeta  = 37
	ShardBlockSalaryResponseMeta = 38
	BeaconRewardRequestMeta      = 39
	BeaconSalaryResponseMeta     = 40
	ReturnStakingMeta            = 41
	IncDAORewardRequestMeta      = 42
	ShardBlockRewardRequestMeta  = 43
	WithDrawRewardRequestMeta    = 44
	WithDrawRewardResponseMeta   = 45

	//statking
	ShardStakingMeta    = 63
	StopAutoStakingMeta = 127
	BeaconStakingMeta   = 64

	// Incognito -> Ethereum bridge
	BeaconSwapConfirmMeta = 70
	BridgeSwapConfirmMeta = 71
	BurningRequestMeta    = 27
	BurningRequestMetaV2  = 240
	BurningConfirmMeta    = 72
	BurningConfirmMetaV2  = 241

	// pde
	PDEContributionMeta                   = 90
	PDETradeRequestMeta                   = 91
	PDETradeResponseMeta                  = 92
	PDEWithdrawalRequestMeta              = 93
	PDEWithdrawalResponseMeta             = 94
	PDEContributionResponseMeta           = 95
	PDEPRVRequiredContributionRequestMeta = 204
	PDECrossPoolTradeRequestMeta          = 205
	PDECrossPoolTradeResponseMeta         = 206
	PDEFeeWithdrawalRequestMeta           = 207
	PDEFeeWithdrawalResponseMeta          = 208
	PDETradingFeesDistributionMeta        = 209

	// portal
	PortalCustodianDepositMeta                  = 100
	PortalRequestPortingMeta                    = 101
	PortalUserRequestPTokenMeta                 = 102
	PortalCustodianDepositResponseMeta          = 103
	PortalUserRequestPTokenResponseMeta         = 104
	PortalExchangeRatesMeta                     = 105
	PortalRedeemRequestMeta                     = 106
	PortalRedeemRequestResponseMeta             = 107
	PortalRequestUnlockCollateralMeta           = 108
	PortalCustodianWithdrawRequestMeta          = 110
	PortalCustodianWithdrawResponseMeta         = 111
	PortalLiquidateCustodianMeta                = 112
	PortalLiquidateCustodianResponseMeta        = 113
	PortalLiquidateTPExchangeRatesMeta          = 114
	PortalExpiredWaitingPortingReqMeta          = 116
	PortalRewardMeta                            = 117
	PortalRequestWithdrawRewardMeta             = 118
	PortalRequestWithdrawRewardResponseMeta     = 119
	PortalRedeemFromLiquidationPoolMeta         = 120
	PortalRedeemFromLiquidationPoolResponseMeta = 121
	PortalCustodianTopupMeta                    = 122
	PortalCustodianTopupResponseMeta            = 123
	PortalTotalRewardCustodianMeta              = 124
	PortalPortingResponseMeta                   = 125
	PortalReqMatchingRedeemMeta                 = 126
	PortalPickMoreCustodianForRedeemMeta        = 128
	PortalCustodianTopupMetaV2                  = 129
	PortalCustodianTopupResponseMetaV2          = 130

	// Portal v3
	PortalCustodianDepositMetaV3                  = 131
	PortalCustodianWithdrawRequestMetaV3          = 132
	PortalRewardMetaV3                            = 133
	PortalRequestUnlockCollateralMetaV3           = 134
	PortalLiquidateCustodianMetaV3                = 135
	PortalLiquidateByRatesMetaV3                  = 136
	PortalRedeemFromLiquidationPoolMetaV3         = 137
	PortalRedeemFromLiquidationPoolResponseMetaV3 = 138
	PortalCustodianTopupMetaV3                    = 139
	PortalTopUpWaitingPortingRequestMetaV3        = 140
	PortalRequestPortingMetaV3                    = 141
	PortalRedeemRequestMetaV3                     = 142
	PortalUnlockOverRateCollateralsMeta           = 143

	// Incognito => Ethereum's SC for portal
	PortalCustodianWithdrawConfirmMetaV3         = 170
	PortalRedeemFromLiquidationPoolConfirmMetaV3 = 171
	PortalLiquidateRunAwayCustodianConfirmMetaV3 = 172

	//Note: don't use this metadata type for others
	PortalResetPortalDBMeta = 199

	// relaying
	RelayingBNBHeaderMeta = 200
	RelayingBTCHeaderMeta = 201

	PortalTopUpWaitingPortingRequestMeta  = 202
	PortalTopUpWaitingPortingResponseMeta = 203

	// incognito mode for smart contract
	BurningForDepositToSCRequestMeta   = 96
	BurningForDepositToSCRequestMetaV2 = 242
	BurningConfirmForDepositToSCMeta   = 97
	BurningConfirmForDepositToSCMetaV2 = 243
)
View Source
const (
	AllShards  = -1
	BeaconOnly = -2
)

Special rules for shardID: stored as 2nd param of instruction of BeaconBlock

View Source
const (
	StopAutoStakingAmount = 0
	ETHConfirmationBlocks = 15
)

const (

EthereumLightNodeProtocol = "http"
EthereumLightNodePort     = "8545"

)

Variables

View Source
var AcceptedWithdrawRewardRequestVersion = []int{0, 1}

Functions

func IsETHTxHashUsedInBlock

func IsETHTxHashUsedInBlock(uniqETHTx []byte, uniqETHTxsUsed [][]byte) bool

func ParseETHLogData

func ParseETHLogData(data []byte) (map[string]interface{}, error)

func PickAndParseLogMapFromReceipt

func PickAndParseLogMapFromReceipt(constructedReceipt *types.Receipt, ethContractAddressStr string) (map[string]interface{}, error)

Types

type IssuingETHAcceptedInst

type IssuingETHAcceptedInst struct {
	ShardID         byte        `json:"shardId"`
	IssuingAmount   uint64      `json:"issuingAmount"`
	ReceiverAddrStr string      `json:"receiverAddrStr"`
	IncTokenID      common.Hash `json:"incTokenId"`
	TxReqID         common.Hash `json:"txReqId"`
	UniqETHTx       []byte      `json:"uniqETHTx"`
	ExternalTokenID []byte      `json:"externalTokenId"`
}

type IssuingETHReqAction

type IssuingETHReqAction struct {
	Meta       IssuingETHRequest `json:"meta"`
	TxReqID    common.Hash       `json:"txReqId"`
	ETHReceipt *types.Receipt    `json:"ethReceipt"`
}

func ParseETHIssuingInstContent

func ParseETHIssuingInstContent(instContentStr string) (*IssuingETHReqAction, error)

type IssuingETHRequest

type IssuingETHRequest struct {
	BlockHash  rCommon.Hash
	TxIndex    uint
	ProofStrs  []string
	IncTokenID common.Hash
	MetadataBase
}

func NewIssuingETHRequest

func NewIssuingETHRequest(
	blockHash rCommon.Hash,
	txIndex uint,
	proofStrs []string,
	incTokenID common.Hash,
	metaType int,
) (*IssuingETHRequest, error)

func NewIssuingETHRequestFromMap

func NewIssuingETHRequestFromMap(
	data map[string]interface{},
) (*IssuingETHRequest, error)

func (*IssuingETHRequest) CalculateSize

func (iReq *IssuingETHRequest) CalculateSize() uint64

func (IssuingETHRequest) Hash

func (iReq IssuingETHRequest) Hash() *common.Hash

type Metadata

type Metadata interface {
	GetType() int
	GetSig() []byte
	SetSig([]byte)
	ShouldSignMetaData() bool
	Hash() *common.Hash
	HashWithoutSig() *common.Hash
	CalculateSize() uint64
}

Interface for all types of metadata in tx

type MetadataBase

type MetadataBase struct {
	Type int
	Sig  []byte
}

func NewMetadataBase

func NewMetadataBase(thisType int) *MetadataBase

func (*MetadataBase) CalculateSize

func (mb *MetadataBase) CalculateSize() uint64

func (MetadataBase) GetSig

func (mb MetadataBase) GetSig() []byte

func (MetadataBase) GetType

func (mb MetadataBase) GetType() int

func (MetadataBase) Hash

func (mb MetadataBase) Hash() *common.Hash

func (MetadataBase) HashWithoutSig

func (mb MetadataBase) HashWithoutSig() *common.Hash

func (*MetadataBase) SetSig

func (mb *MetadataBase) SetSig(sig []byte)

func (*MetadataBase) ShouldSignMetaData

func (mb *MetadataBase) ShouldSignMetaData() bool

type PDEContribution

type PDEContribution struct {
	PDEContributionPairID string
	ContributorAddressStr string
	ContributedAmount     uint64 // must be equal to vout value
	TokenIDStr            string
	MetadataBase
}

PDEContribution - privacy dex contribution

func NewPDEContribution

func NewPDEContribution(
	pdeContributionPairID string,
	contributorAddressStr string,
	contributedAmount uint64,
	tokenIDStr string,
	metaType int,
) (*PDEContribution, error)

func (*PDEContribution) CalculateSize

func (pc *PDEContribution) CalculateSize() uint64

func (PDEContribution) Hash

func (pc PDEContribution) Hash() *common.Hash

type PDEContributionAction

type PDEContributionAction struct {
	Meta    PDEContribution
	TxReqID common.Hash
	ShardID byte
}

type PDEContributionStatus

type PDEContributionStatus struct {
	Status             byte
	TokenID1Str        string
	Contributed1Amount uint64
	Returned1Amount    uint64
	TokenID2Str        string
	Contributed2Amount uint64
	Returned2Amount    uint64
}

type PDEMatchedContribution

type PDEMatchedContribution struct {
	PDEContributionPairID string
	ContributorAddressStr string
	ContributedAmount     uint64
	TokenIDStr            string
	TxReqID               common.Hash
}

type PDEMatchedNReturnedContribution

type PDEMatchedNReturnedContribution struct {
	PDEContributionPairID      string
	ContributorAddressStr      string
	ActualContributedAmount    uint64
	ReturnedContributedAmount  uint64
	TokenIDStr                 string
	ShardID                    byte
	TxReqID                    common.Hash
	ActualWaitingContribAmount uint64
}

type PDERefundContribution

type PDERefundContribution struct {
	PDEContributionPairID string
	ContributorAddressStr string
	ContributedAmount     uint64
	TokenIDStr            string
	TxReqID               common.Hash
	ShardID               byte
}

type PDETradeAcceptedContent

type PDETradeAcceptedContent struct {
	TraderAddressStr         string
	TxRandomStr              string
	TokenIDToBuyStr          string
	ReceiveAmount            uint64
	Token1IDStr              string
	Token2IDStr              string
	Token1PoolValueOperation TokenPoolValueOperation
	Token2PoolValueOperation TokenPoolValueOperation
	ShardID                  byte
	RequestedTxID            common.Hash
}

type PDETradeRequest

type PDETradeRequest struct {
	TokenIDToBuyStr     string
	TokenIDToSellStr    string
	SellAmount          uint64 // must be equal to vout value
	MinAcceptableAmount uint64
	TradingFee          uint64
	TraderAddressStr    string
	TxRandomStr         string
	MetadataBase
}

PDETradeRequest - privacy dex trade

func NewPDETradeRequest

func NewPDETradeRequest(
	tokenIDToBuyStr string,
	tokenIDToSellStr string,
	sellAmount uint64,
	minAcceptableAmount uint64,
	tradingFee uint64,
	traderAddressStr string,
	txRandomStr string,
	metaType int,
) (*PDETradeRequest, error)

func (*PDETradeRequest) CalculateSize

func (pc *PDETradeRequest) CalculateSize() uint64

func (PDETradeRequest) Hash

func (pc PDETradeRequest) Hash() *common.Hash

type PDETradeRequestAction

type PDETradeRequestAction struct {
	Meta    PDETradeRequest
	TxReqID common.Hash
	ShardID byte
}

type PDEWaitingContribution

type PDEWaitingContribution struct {
	PDEContributionPairID string
	ContributorAddressStr string
	ContributedAmount     uint64
	TokenIDStr            string
	TxReqID               common.Hash
}

type PDEWithdrawalAcceptedContent

type PDEWithdrawalAcceptedContent struct {
	WithdrawalTokenIDStr string
	WithdrawerAddressStr string
	DeductingPoolValue   uint64
	DeductingShares      uint64
	PairToken1IDStr      string
	PairToken2IDStr      string
	TxReqID              common.Hash
	ShardID              byte
}

type PDEWithdrawalRequest

type PDEWithdrawalRequest struct {
	WithdrawerAddressStr  string
	WithdrawalToken1IDStr string
	WithdrawalToken2IDStr string
	WithdrawalShareAmt    uint64
	MetadataBase
}

PDEWithdrawalRequest - privacy dex withdrawal request

func NewPDEWithdrawalRequest

func NewPDEWithdrawalRequest(
	withdrawerAddressStr string,
	withdrawalToken1IDStr string,
	withdrawalToken2IDStr string,
	withdrawalShareAmt uint64,
	metaType int,
) (*PDEWithdrawalRequest, error)

func (*PDEWithdrawalRequest) CalculateSize

func (pc *PDEWithdrawalRequest) CalculateSize() uint64

func (PDEWithdrawalRequest) Hash

func (pc PDEWithdrawalRequest) Hash() *common.Hash

func (PDEWithdrawalRequest) HashWithoutSig

func (pc PDEWithdrawalRequest) HashWithoutSig() *common.Hash

func (*PDEWithdrawalRequest) ShouldSignMetaData

func (*PDEWithdrawalRequest) ShouldSignMetaData() bool

type PDEWithdrawalRequestAction

type PDEWithdrawalRequestAction struct {
	Meta    PDEWithdrawalRequest
	TxReqID common.Hash
	ShardID byte
}

type StakingMetadata

type StakingMetadata struct {
	MetadataBase
	FunderPaymentAddress         string
	RewardReceiverPaymentAddress string
	StakingAmountShard           uint64
	AutoReStaking                bool
	CommitteePublicKey           string
}

func NewStakingMetadata

func NewStakingMetadata(
	stakingType int,
	funderPaymentAddress string,
	rewardReceiverPaymentAddress string,

	stakingAmountShard uint64,
	committeePublicKey string,
	autoReStaking bool,
) (
	*StakingMetadata,
	error,
)

func (*StakingMetadata) CalculateSize

func (stakingMetadata *StakingMetadata) CalculateSize() uint64

func (StakingMetadata) GetType

func (stakingMetadata StakingMetadata) GetType() int

type StopAutoStakingMetadata

type StopAutoStakingMetadata struct {
	MetadataBase
	CommitteePublicKey string
}

func NewStopAutoStakingMetadata

func NewStopAutoStakingMetadata(stopStakingType int, committeePublicKey string) (*StopAutoStakingMetadata, error)

func (*StopAutoStakingMetadata) CalculateSize

func (stopAutoStakingMetadata *StopAutoStakingMetadata) CalculateSize() uint64

func (StopAutoStakingMetadata) GetType

func (stopAutoStakingMetadata StopAutoStakingMetadata) GetType() int

func (*StopAutoStakingMetadata) Hash

func (meta *StopAutoStakingMetadata) Hash() *common.Hash

func (*StopAutoStakingMetadata) HashWithoutSig

func (meta *StopAutoStakingMetadata) HashWithoutSig() *common.Hash

func (*StopAutoStakingMetadata) ShouldSignMetaData

func (*StopAutoStakingMetadata) ShouldSignMetaData() bool

type TokenPoolValueOperation

type TokenPoolValueOperation struct {
	Operator string
	Value    uint64
}

type Transaction

type Transaction interface {
	// GET/SET FUNCTION
	GetVersion() int8
	SetVersion(int8)
	GetMetadataType() int
	GetType() string
	SetType(string)
	GetLockTime() int64
	SetLockTime(int64)
	GetSenderAddrLastByte() byte
	SetGetSenderAddrLastByte(byte)
	GetTxFee() uint64
	SetTxFee(uint64)
	GetTxFeeToken() uint64
	GetInfo() []byte
	SetInfo([]byte)
	GetSigPubKey() []byte
	SetSigPubKey([]byte)
	GetSig() []byte
	SetSig([]byte)
	GetProof() privacy.Proof
	SetProof(privacy.Proof)
	GetTokenID() *common.Hash
	GetMetadata() Metadata
	SetMetadata(Metadata)

	// =================== FUNCTIONS THAT GET STUFF AND REQUIRE SOME CODING ===================
	GetTxActualSize() uint64
	GetReceivers() ([][]byte, []uint64)
	GetTransferData() (bool, []byte, uint64, *common.Hash)
	GetReceiverData() ([]coin.Coin, error)
	GetTxMintData() (bool, coin.Coin, *common.Hash, error)
	GetTxBurnData() (bool, coin.Coin, *common.Hash, error)
	GetTxFullBurnData() (bool, coin.Coin, coin.Coin, *common.Hash, error)
	ListOTAHashH() []common.Hash
	ListSerialNumbersHashH() []common.Hash
	String() string
	Hash() *common.Hash
	CalculateTxValue() uint64

	// =================== FUNCTION THAT CHECK STUFFS  ===================
	CheckTxVersion(int8) bool
	CheckAuthorizedSender([]byte) (bool, error)
	ShouldSignMetaData() bool
	IsSalaryTx() bool
	IsPrivacy() bool

	// Init Transaction, the input should be params such as: TxPrivacyInitParams
	Init(interface{}) error
}

Interface for all type of transaction

type WithDrawRewardRequest

type WithDrawRewardRequest struct {
	MetadataBase
	PaymentAddress privacy.PaymentAddress
	TokenID        common.Hash
	Version        int
}

func NewWithDrawRewardRequest

func NewWithDrawRewardRequest(tokenIDStr string, paymentAddStr string, version float64, metaType int) (*WithDrawRewardRequest, error)

func (*WithDrawRewardRequest) CalculateSize

func (withDrawRewardRequest *WithDrawRewardRequest) CalculateSize() uint64

func (WithDrawRewardRequest) GetType

func (withDrawRewardRequest WithDrawRewardRequest) GetType() int

func (WithDrawRewardRequest) Hash

func (withDrawRewardRequest WithDrawRewardRequest) Hash() *common.Hash

func (WithDrawRewardRequest) HashWithoutSig

func (withDrawRewardRequest WithDrawRewardRequest) HashWithoutSig() *common.Hash

func (*WithDrawRewardRequest) ShouldSignMetaData

func (*WithDrawRewardRequest) ShouldSignMetaData() bool

func (*WithDrawRewardRequest) UnmarshalJSON

func (withdrawRequestMetadata *WithDrawRewardRequest) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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