Documentation ¶
Index ¶
- Constants
- Variables
- func CalRewardForRefillVault(v *statedb.BridgeAggVaultState, shieldAmt uint64) (uint64, error)
- func CalUnshieldFeeByBurnAmount(v *statedb.BridgeAggVaultState, burningAmt uint64, percentFeeWithDec uint64, ...) (bool, uint64, map[common.Hash]uint64, error)
- func CalUnshieldFeeByReceivedAmount(v *statedb.BridgeAggVaultState, receivedAmt uint64, percentFeeWithDec uint64) (bool, uint64, error)
- func CalUnshieldFeeByShortageBurnAmount(burnAmount uint64, percentFeeWithDec uint64) (uint64, error)
- func CalUnshieldFeeByShortageReceivedAmount(receivedAmount uint64, percentFeeWithDec uint64) (uint64, error)
- func CalculateIncDecimal(decimal, baseDecimal uint8) uint8
- func ConvertAmountByDecimal(amount *big.Int, decimal uint8, isToUnifiedDecimal bool) (*big.Int, error)
- func DecodeBurnForCallConfirmInst(inst []string) ([]byte, error)
- func GetBridgeTokenIndex(sDB *statedb.StateDB) (map[common.Hash]*rawdbv2.BridgeTokenInfo, map[string]bool, error)
- func GetExternalTokenIDByIncTokenID(incTokenID common.Hash, sDB *statedb.StateDB) ([]byte, error)
- func GetExternalTokenIDByNetworkID(externalTokenID string, networkID uint8) ([]byte, error)
- func GetExternalTokenIDForUnifiedToken() []byte
- func GetInsertTxHashIssuedFuncByNetworkID(networkID uint8) func(*statedb.StateDB, []byte) error
- func GetNetworkIDByPrefix(prefix string) (uint8, error)
- func GetTxIDFromBurningConfirmInst(inst []string) (*common.Hash, error)
- func IsBridgeTxHashUsedInBlock(uniqTx []byte, uniqTxsUsed [][]byte) bool
- func UnmarshalEVMShieldProof(proofBytes []byte, actionData []byte) (*metadataBridge.EVMProof, *types.Receipt, error)
- func ValidateDoubleShieldProof(uniqTx []byte, listTxUsed [][]byte, ...) (bool, []byte, error)
- type BrideAggLogger
- type BridgeAggError
- type ConvertStatus
- type Manager
- func (m *Manager) BuildAddTokenInstruction(beaconHeight uint64, sDBs map[int]*statedb.StateDB, ...) ([][]string, *metadata.AccumulatedValues, error)
- func (m *Manager) BuildInstructions(env StateEnvironment) ([][]string, *metadata.AccumulatedValues, error)
- func (m *Manager) BuildNewUnshieldInstructions(stateDB *statedb.StateDB, beaconHeight uint64, ...) ([][]string, error)
- func (m *Manager) Clone() *Manager
- func (m *Manager) GetDiffState(state *State) (*State, map[common.Hash]bool, error)
- func (m *Manager) InitBridgeAggParamDefault() error
- func (m *Manager) Process(insts [][]string, sDB *statedb.StateDB) (map[string]bool, error)
- func (m *Manager) State() *State
- func (m *Manager) UpdateToDB(sDB *statedb.StateDB, newUnifiedTokens map[common.Hash]bool) error
- type ModifyParamStatus
- type ShieldStatus
- type ShieldStatusData
- type State
- func (s *State) Clone() *State
- func (s *State) CloneNewWaitingUnshieldReqs() map[common.Hash][]*statedb.BridgeAggWaitingUnshieldReq
- func (s *State) CloneUnifiedTokenVaults() map[common.Hash]map[common.Hash]*statedb.BridgeAggVaultState
- func (s *State) CloneVaultsByUnifiedTokenID(unifiedTokenID common.Hash) (map[common.Hash]*statedb.BridgeAggVaultState, error)
- func (s *State) CloneWaitingUnshieldReqs() map[common.Hash][]*statedb.BridgeAggWaitingUnshieldReq
- func (s *State) DeletedWaitingUnshieldReqKeyHashes() []common.Hash
- func (s *State) GetDiff(preState *State) (*State, map[common.Hash]bool, error)
- func (s *State) MarshalJSON() ([]byte, error)
- func (s *State) NewWaitingUnshieldReqs() map[common.Hash][]*statedb.BridgeAggWaitingUnshieldReq
- func (s *State) Param() *statedb.BridgeAggParamState
- func (s *State) UnifiedTokenVaults() map[common.Hash]map[common.Hash]*statedb.BridgeAggVaultState
- func (s *State) UnmarshalJSON(data []byte) error
- func (s *State) WaitingUnshieldReqs() map[common.Hash][]*statedb.BridgeAggWaitingUnshieldReq
- type StateChange
- type StateEnvBuilder
- type StateEnvironment
- type TxBuilder
- type UnshieldActionForProducer
- type UnshieldStatus
- type UnshieldStatusData
- type VaultChange
Constants ¶
View Source
const ( OtherError = iota NotFoundUnifiedTokenIDError InvalidPTokenIDError InvalidNetworkIDError InvalidStatusError InvalidConvertAmountError CalRewardError ProducerUpdateStateError ProcessUpdateStateError UnmarshalShieldProofError ValidateDoubleShieldProofError ShieldProofIsSubmittedError ExtractDataFromReceiptError InvalidTokenPairError CheckVaultUnshieldError StoreShieldExtTxError CheckBridgeTokenExistedError StoreBridgeTokenError InsufficientFundsVaultError NoValidShieldEventError )
Variables ¶
View Source
var ErrCodeMessage = map[int]struct { Code int Message string }{ OtherError: {1, "Other error"}, NotFoundUnifiedTokenIDError: {1000, "Not found punified token id in network"}, InvalidPTokenIDError: {1001, "Invalid ptoken id in punifiedToken"}, InvalidNetworkIDError: {1002, "Invalid networkID"}, InvalidStatusError: {1003, "Invalid instruction status error"}, InvalidConvertAmountError: {1004, "Invalid convert amount"}, CalRewardError: {1005, "Calculate reward error"}, ProducerUpdateStateError: {1006, "Beacon producer update state error"}, ProcessUpdateStateError: {1007, "Beacon process update state error"}, UnmarshalShieldProofError: {1008, "Unmarshal shielding proof error"}, ValidateDoubleShieldProofError: {1009, "Validate double shielding proof error"}, ShieldProofIsSubmittedError: {1010, "Shield proof was submitted"}, ExtractDataFromReceiptError: {1011, "Extract data from shielding receipt error"}, InvalidTokenPairError: {1012, "Invalid token pair"}, CheckVaultUnshieldError: {1013, "Check vaults for new unshielding request error"}, StoreShieldExtTxError: {1014, "Store shield external tx error"}, CheckBridgeTokenExistedError: {1015, "Check bridge token existed error"}, StoreBridgeTokenError: {1016, "Store bridge token error"}, InsufficientFundsVaultError: {1017, "Insufficient funds in Vault"}, NoValidShieldEventError: {1018, "Shielding receipt contains no valid shield event"}, }
View Source
var Logger = BrideAggLogger{}
Global instant to use
Functions ¶
func CalRewardForRefillVault ¶
func CalRewardForRefillVault(v *statedb.BridgeAggVaultState, shieldAmt uint64) (uint64, error)
func CalUnshieldFeeByShortageBurnAmount ¶
func CalUnshieldFeeByShortageBurnAmount(burnAmount uint64, percentFeeWithDec uint64) (uint64, error)
calculate actual received amount and actual fee
func CalUnshieldFeeByShortageReceivedAmount ¶
func CalUnshieldFeeByShortageReceivedAmount(receivedAmount uint64, percentFeeWithDec uint64) (uint64, error)
calculate actual received amount and actual fee
func CalculateIncDecimal ¶
func ConvertAmountByDecimal ¶
func DecodeBurnForCallConfirmInst ¶
DecodeBurnForCallConfirmInst packs the BurnForCall instruction into a byte slice. Instruction layout: [meta(1), shard(1), network(1), extToken(32), extCallAddr(32), amount(32), txID(32), recvToken(32), withdrawAddr(32), redepositAddr(101), extCalldata, beaconHeight(32)].
func GetBridgeTokenIndex ¶
func GetExternalTokenIDForUnifiedToken ¶
func GetExternalTokenIDForUnifiedToken() []byte
func GetNetworkIDByPrefix ¶
func UnmarshalEVMShieldProof ¶
Types ¶
type BrideAggLogger ¶
type BrideAggLogger struct {
// contains filtered or unexported fields
}
func (*BrideAggLogger) Init ¶
func (bridgeAggLogger *BrideAggLogger) Init(logger common.Logger)
type BridgeAggError ¶
type BridgeAggError struct { Code int // The code to send with reject messages Message string // Human readable message of the issue Err error }
func NewBridgeAggErrorWithValue ¶
func NewBridgeAggErrorWithValue(key int, err error, params ...interface{}) *BridgeAggError
func (BridgeAggError) Error ¶
func (e BridgeAggError) Error() string
Error satisfies the error interface and prints human-readable errors.
type ConvertStatus ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager() *Manager
func NewManagerWithValue ¶
func (*Manager) BuildAddTokenInstruction ¶
func (*Manager) BuildInstructions ¶
func (m *Manager) BuildInstructions(env StateEnvironment) ([][]string, *metadata.AccumulatedValues, error)
func (*Manager) BuildNewUnshieldInstructions ¶
func (*Manager) GetDiffState ¶
func (*Manager) InitBridgeAggParamDefault ¶
type ModifyParamStatus ¶
type ShieldStatus ¶
type ShieldStatus struct { Status byte `json:"Status"` Data []ShieldStatusData `json:"Data,omitempty"` ErrorCode int `json:"ErrorCode,omitempty"` }
type ShieldStatusData ¶
type State ¶
type State struct {
// contains filtered or unexported fields
}
func NewStateWithValue ¶
func NewStateWithValue( unifiedTokenInfos map[common.Hash]map[common.Hash]*statedb.BridgeAggVaultState, waitingUnshieldReqs map[common.Hash][]*statedb.BridgeAggWaitingUnshieldReq, param *statedb.BridgeAggParamState, newWaitingUnshieldReqs map[common.Hash][]*statedb.BridgeAggWaitingUnshieldReq, deletedWaitingUnshieldReqKeyHashes []common.Hash, ) *State
func (*State) CloneNewWaitingUnshieldReqs ¶
func (s *State) CloneNewWaitingUnshieldReqs() map[common.Hash][]*statedb.BridgeAggWaitingUnshieldReq
func (*State) CloneUnifiedTokenVaults ¶
func (*State) CloneVaultsByUnifiedTokenID ¶
func (*State) CloneWaitingUnshieldReqs ¶
func (s *State) CloneWaitingUnshieldReqs() map[common.Hash][]*statedb.BridgeAggWaitingUnshieldReq
func (*State) DeletedWaitingUnshieldReqKeyHashes ¶
func (*State) MarshalJSON ¶
func (*State) NewWaitingUnshieldReqs ¶
func (s *State) NewWaitingUnshieldReqs() map[common.Hash][]*statedb.BridgeAggWaitingUnshieldReq
func (*State) Param ¶
func (s *State) Param() *statedb.BridgeAggParamState
func (*State) UnifiedTokenVaults ¶
UnifiedTokenVaults read only function do not write to result of function
func (*State) UnmarshalJSON ¶
func (*State) WaitingUnshieldReqs ¶
func (s *State) WaitingUnshieldReqs() map[common.Hash][]*statedb.BridgeAggWaitingUnshieldReq
WaitingUnshieldReqs read only function do not write to result of function
type StateChange ¶
type StateChange struct {
// contains filtered or unexported fields
}
func NewStateChange ¶
func NewStateChange() *StateChange
type StateEnvBuilder ¶
type StateEnvBuilder interface { BuildAccumulatedValues(*metadata.AccumulatedValues) StateEnvBuilder BuildUnshieldActions([][]string) StateEnvBuilder BuildShieldActions([][]string) StateEnvBuilder BuildConvertActions([][]string) StateEnvBuilder BuildModifyParamActions([][]string) StateEnvBuilder BuildStateDBs(map[int]*statedb.StateDB) StateEnvBuilder BuildBeaconHeight(uint64) StateEnvBuilder Build() StateEnvironment }
func NewStateEnvBuilder ¶
func NewStateEnvBuilder() StateEnvBuilder
type StateEnvironment ¶
type UnshieldActionForProducer ¶
type UnshieldActionForProducer struct { metadataCommon.Action ShardID byte BeaconHeight uint64 }
func BuildUnshieldActionForProducerFromInsts ¶
func BuildUnshieldActionForProducerFromInsts(insts [][]string, shardID byte, beaconHeight uint64) []UnshieldActionForProducer
type UnshieldStatus ¶
type UnshieldStatus struct { Status byte `json:"Status"` Data []UnshieldStatusData `json:"Data,omitempty"` ErrorCode int `json:"ErrorCode,omitempty"` }
type UnshieldStatusData ¶
type VaultChange ¶
type VaultChange struct {
IsChanged bool
}
func NewVaultChange ¶
func NewVaultChange() *VaultChange
Click to show internal directories.
Click to hide internal directories.