Documentation
¶
Index ¶
- Constants
- Variables
- func KeyContractResult(txID TxID, txIndex TxIndex) []byte
- func KeyCoordinator(txID TxID) []byte
- func KeyPrefixBytes(prefix uint8) []byte
- func KeyTx(txID TxID, txIndex TxIndex) []byte
- func KeyUnacknowledgedPacket(sourcePort, sourceChannel string, seq uint64) []byte
- func MakeHashFromABCIHeader(header abci.Header) *tmtypes.Header
- func MakeObjectKey(callInfo ContractCallInfo, signers []sdk.AccAddress) []byte
- func RegisterCodec(cdc *codec.Codec)
- func SignersFromContext(ctx sdk.Context) ([]sdk.AccAddress, bool)
- func WithSigners(ctx sdk.Context, signers []sdk.AccAddress) sdk.Context
- type CallResultLink
- type ChannelInfo
- type ChannelKeeper
- type Committer
- type ConstantValueObject
- type ContractCallInfo
- type ContractCallResult
- type ContractHandler
- type ContractHandlerAbortResult
- type ContractHandlerResult
- type ContractRuntimeInfo
- type ContractTransaction
- type ContractTransactionInfo
- type ContractTransactions
- type CoordinatorInfo
- type FakeResolver
- type HexByteArray32
- func (bz HexByteArray32) Bytes() []byte
- func (bz HexByteArray32) Format(s fmt.State, verb rune)
- func (bz *HexByteArray32) FromString(s string) error
- func (bz HexByteArray32) Marshal() ([]byte, error)
- func (bz HexByteArray32) MarshalJSON() ([]byte, error)
- func (bz HexByteArray32) String() string
- func (bz *HexByteArray32) Unmarshal(data []byte) error
- func (bz *HexByteArray32) UnmarshalJSON(data []byte) error
- type Link
- type LinkType
- type Linker
- type MsgInitiate
- type OP
- type OPs
- type Object
- type ObjectResolver
- type ObjectResolverProvider
- type ObjectType
- type PacketAcknowledgement
- type PacketCommitAcknowledgement
- type PacketData
- type PacketDataCommit
- type PacketDataPrepare
- type PacketPrepareAcknowledgement
- type PortKeeper
- type QueryCoordinatorStatusRequest
- type QueryCoordinatorStatusResponse
- type QueryUnacknowledgedPacketsRequest
- type QueryUnacknowledgedPacketsResponse
- type ReturnValue
- type SequentialResolver
- type State
- type StateConstraint
- type StateConstraintType
- type Store
- type TxID
- type TxIndex
- type TxInfo
- type UnacknowledgedPacket
Constants ¶
const ( // ModuleName is the name of the module ModuleName = "cross" // Version defines the current version the Cross // module supports Version = "cross-1" // PortID that Cross module binds to PortID = "cross" // StoreKey to be used when creating the KVStore StoreKey = ModuleName // RouterKey is the msg router key for the IBC module RouterKey string = ModuleName // QuerierRoute is the querier route for Cross QuerierRoute = ModuleName )
const ( TypeInitiate = "cross_initiate" TypePrepare = "cross_prepare" TypePrepareResult = "cross_prepare_result" TypeCommit = "cross_commit" TypeAckCommit = "cross_ack_commit" )
const ( KeyCoordinatorPrefix uint8 = iota KeyTxPrefix KeyContractResultPrefix KeyUnacknowledgedPacketPrefix )
const ( PREPARE_RESULT_OK uint8 = iota + 1 PREPARE_RESULT_FAILED )
const ( QueryCoordinatorStatus = "coordinator_status" QueryUnacknowledgedPackets = "unacknowledged_packets" )
const ( CO_STATUS_NONE uint8 = iota CO_STATUS_INIT CO_STATUS_DECIDED // abort or commit CO_DECISION_NONE uint8 = iota CO_DECISION_COMMIT CO_DECISION_ABORT )
const ( TX_STATUS_PREPARE uint8 = iota + 1 TX_STATUS_COMMIT TX_STATUS_ABORT )
const (
MaxContractTransactoinNum = math.MaxUint8
)
Variables ¶
var ( ErrFailedInitiateTx = sdkerrors.Register(ModuleName, 2, "failed to initiate a transaction") ErrFailedPrepare = sdkerrors.Register(ModuleName, 3, "failed to prepare a commit") ErrFailedRecievePrepareResult = sdkerrors.Register(ModuleName, 4, "failed to receive a PrepareResult") ErrFailedMulticastCommitPacket = sdkerrors.Register(ModuleName, 5, "failed to multicast a CommitPacket") ErrFailedReceiveCommitPacket = sdkerrors.Register(ModuleName, 6, "failed to receive a CommitPacket") ErrFailedSendAckCommitPacket = sdkerrors.Register(ModuleName, 7, "failed to send an AckCommitPacket") ErrFailedReceiveAckCommitPacket = sdkerrors.Register(ModuleName, 8, "failed to receive an AckCommitPacket") ErrCoordinatorNotFound = sdkerrors.Register(ModuleName, 100, "coordinator not found") )
var ModuleCdc = codec.New()
ModuleCdc is the codec for the module
Functions ¶
func KeyContractResult ¶
func KeyCoordinator ¶
func KeyPrefixBytes ¶
KeyPrefixBytes return the key prefix bytes from a URL string format
func KeyUnacknowledgedPacket ¶
func MakeObjectKey ¶ added in v0.0.5
func MakeObjectKey(callInfo ContractCallInfo, signers []sdk.AccAddress) []byte
MakeObjectKey returns a key that can be used to identify a contract call
func RegisterCodec ¶
RegisterCodec registers concrete types on the Amino codec
func SignersFromContext ¶
func SignersFromContext(ctx sdk.Context) ([]sdk.AccAddress, bool)
func WithSigners ¶
Types ¶
type CallResultLink ¶ added in v0.0.5
type CallResultLink struct {
ContractTransactionIndex TxIndex
}
CallResultLink is a link with an object returned from external contract call
func NewCallResultLink ¶ added in v0.0.5
func NewCallResultLink(idx TxIndex) CallResultLink
NewCallResultLink returns CallResultLink
func (CallResultLink) SourceIndex ¶ added in v0.0.5
func (l CallResultLink) SourceIndex() TxIndex
SourceIndex implements Link.SourceIndex
func (CallResultLink) Type ¶ added in v0.0.5
func (l CallResultLink) Type() LinkType
Type implements Link.Type
type ChannelInfo ¶
type ChannelInfo struct {
Port string `json:"port" yaml:"port"` // the port on which the packet will be sent
Channel string `json:"channel" yaml:"channel"` // the channel by which the packet will be sent
}
func NewChannelInfo ¶
func NewChannelInfo(port, channel string) ChannelInfo
func (ChannelInfo) ValidateBasic ¶
func (c ChannelInfo) ValidateBasic() error
type ChannelKeeper ¶
type ChannelKeeper interface {
GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channel.Channel, found bool)
GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool)
SendPacket(ctx sdk.Context, channelCap *capability.Capability, packet channelexported.PacketI) error
PacketExecuted(ctx sdk.Context, chanCap *capability.Capability, packet channelexported.PacketI, acknowledgement []byte) error
}
ChannelKeeper defines the expected IBC channel keeper
type ConstantValueObject ¶ added in v0.0.5
ConstantValueObject is an Object wraps a constant value
func MakeConstantValueObject ¶ added in v0.0.5
func MakeConstantValueObject(key []byte, value []byte) ConstantValueObject
MakeConstantValueObject returns ConstantValueObject
func (ConstantValueObject) Evaluate ¶ added in v0.0.5
func (l ConstantValueObject) Evaluate(bz []byte) ([]byte, error)
Evaluate returns a constant value
func (ConstantValueObject) Key ¶ added in v0.0.5
func (l ConstantValueObject) Key() []byte
Key implements Object.Key
func (ConstantValueObject) Type ¶ added in v0.0.5
func (l ConstantValueObject) Type() ObjectType
Type implements Object.Type
type ContractCallInfo ¶ added in v0.0.3
type ContractCallInfo []byte
type ContractCallResult ¶
type ContractCallResult struct {
ChainID string `json:"chain_id" yaml:"chain_id"`
Height int64 `json:"height" yaml:"height"`
Signers []sdk.AccAddress `json:"signers" yaml:"signers"`
CallInfo ContractCallInfo `json:"call_info" yaml:"call_info"`
StateConstraint StateConstraint `json:"state_constraint" yaml:"state_constraint"`
}
func (ContractCallResult) String ¶
func (r ContractCallResult) String() string
type ContractHandler ¶
type ContractHandler interface {
GetState(ctx sdk.Context, callInfo ContractCallInfo, rtInfo ContractRuntimeInfo) (State, error)
Handle(ctx sdk.Context, callInfo ContractCallInfo, rtInfo ContractRuntimeInfo) (State, ContractHandlerResult, error)
OnCommit(ctx sdk.Context, result ContractHandlerResult) ContractHandlerResult
}
type ContractHandlerAbortResult ¶
type ContractHandlerAbortResult struct{}
func (ContractHandlerAbortResult) GetData ¶
func (ContractHandlerAbortResult) GetData() []byte
func (ContractHandlerAbortResult) GetEvents ¶
func (ContractHandlerAbortResult) GetEvents() sdk.Events
type ContractHandlerResult ¶
type ContractRuntimeInfo ¶ added in v0.0.5
type ContractRuntimeInfo struct {
StateConstraintType StateConstraintType
ExternalObjectResolver ObjectResolver
}
type ContractTransaction ¶
type ContractTransaction struct {
Source ChannelInfo `json:"source" yaml:"source"`
Signers []sdk.AccAddress `json:"signers" yaml:"signers"`
CallInfo ContractCallInfo `json:"call_info" yaml:"call_info"`
StateConstraint StateConstraint `json:"state_constraint" yaml:"state_constraint"`
ReturnValue *ReturnValue `json:"return_value" yaml:"return_value"`
Links []Link `json:"links" yaml:"links"`
}
func NewContractTransaction ¶
func NewContractTransaction(src ChannelInfo, signers []sdk.AccAddress, callInfo ContractCallInfo, sc StateConstraint, rv *ReturnValue, links []Link) ContractTransaction
func (ContractTransaction) ValidateBasic ¶
func (t ContractTransaction) ValidateBasic() error
type ContractTransactionInfo ¶ added in v0.0.5
type ContractTransactionInfo struct {
Transaction ContractTransaction `json:"transaction" yaml:"transaction"`
LinkObjects []Object `json:"link_objects" yaml:"link_objects"`
}
func NewContractTransactionInfo ¶ added in v0.0.5
func NewContractTransactionInfo(tx ContractTransaction, linkObjects []Object) ContractTransactionInfo
func (ContractTransactionInfo) ValidateBasic ¶ added in v0.0.5
func (ti ContractTransactionInfo) ValidateBasic() error
type ContractTransactions ¶
type ContractTransactions = []ContractTransaction
type CoordinatorInfo ¶
type CoordinatorInfo struct {
Transactions []string // {TransactionID => ConnectionID}
Channels []ChannelInfo // {TransactionID => Channel}
Status uint8
Decision uint8
ConfirmedTransactions []TxIndex // [TransactionID]
Acks []TxIndex // [TransactionID]
}
func NewCoordinatorInfo ¶
func NewCoordinatorInfo(status uint8, tss []string, channels []ChannelInfo) CoordinatorInfo
func (*CoordinatorInfo) AddAck ¶
func (ci *CoordinatorInfo) AddAck(txIndex TxIndex) bool
func (*CoordinatorInfo) Confirm ¶
func (ci *CoordinatorInfo) Confirm(txIndex TxIndex, connectionID string) error
func (*CoordinatorInfo) IsCompleted ¶
func (ci *CoordinatorInfo) IsCompleted() bool
func (*CoordinatorInfo) IsReceivedALLAcks ¶
func (ci *CoordinatorInfo) IsReceivedALLAcks() bool
type FakeResolver ¶ added in v0.0.5
type FakeResolver struct{}
FakeResolver is a resolver that always fails to resolve an object
func NewFakeResolver ¶ added in v0.0.5
func NewFakeResolver() FakeResolver
NewFakeResolver returns FakeResolver
type HexByteArray32 ¶
type HexByteArray32 [32]byte
func (HexByteArray32) Bytes ¶
func (bz HexByteArray32) Bytes() []byte
Allow it to fulfill various interfaces in light-client, etc...
func (*HexByteArray32) FromString ¶
func (bz *HexByteArray32) FromString(s string) error
func (HexByteArray32) Marshal ¶
func (bz HexByteArray32) Marshal() ([]byte, error)
Marshal needed for protobuf compatibility
func (HexByteArray32) MarshalJSON ¶
func (bz HexByteArray32) MarshalJSON() ([]byte, error)
This is the point of Bytes.
func (HexByteArray32) String ¶
func (bz HexByteArray32) String() string
func (*HexByteArray32) Unmarshal ¶
func (bz *HexByteArray32) Unmarshal(data []byte) error
Unmarshal needed for protobuf compatibility
func (*HexByteArray32) UnmarshalJSON ¶
func (bz *HexByteArray32) UnmarshalJSON(data []byte) error
This is the point of Bytes.
type Link ¶ added in v0.0.5
Link is a link to an Object that is referenced in the call to the contract
type Linker ¶ added in v0.0.5
type Linker struct {
// contains filtered or unexported fields
}
Linker resolves links that each ContractTransaction has.
func MakeLinker ¶ added in v0.0.5
func MakeLinker(txs ContractTransactions) (*Linker, error)
MakeLinker returns Linker
type MsgInitiate ¶
type MsgInitiate struct {
Sender sdk.AccAddress
ChainID string // chainID of Coordinator node
ContractTransactions []ContractTransaction
TimeoutHeight int64 // Timeout for this msg
Nonce uint64
}
func NewMsgInitiate ¶
func NewMsgInitiate(sender sdk.AccAddress, chainID string, transactions []ContractTransaction, timeoutHeight int64, nonce uint64) MsgInitiate
func (MsgInitiate) GetSignBytes ¶
func (msg MsgInitiate) GetSignBytes() []byte
GetSignBytes implements sdk.Msg
func (MsgInitiate) GetSigners ¶
func (msg MsgInitiate) GetSigners() []sdk.AccAddress
GetSigners implements sdk.Msg GetSigners returns the addresses that must sign the transaction. Addresses are returned in a deterministic order. Duplicate addresses will be omitted.
func (MsgInitiate) ValidateBasic ¶
func (msg MsgInitiate) ValidateBasic() error
ValidateBasic implements sdk.Msg
type Object ¶ added in v0.0.5
type Object interface {
Type() ObjectType
Key() []byte
Evaluate([]byte) ([]byte, error)
}
Object wraps an actual value
type ObjectResolver ¶ added in v0.0.5
ObjectResolver resolves a given key to Object
type ObjectResolverProvider ¶ added in v0.0.5
type ObjectResolverProvider func(libs []Object) (ObjectResolver, error)
ObjectResolverProvider is a provider of ObjectResolver
func DefaultResolverProvider ¶ added in v0.0.5
func DefaultResolverProvider() ObjectResolverProvider
DefaultResolverProvider returns a default implements of ObjectResolver
type ObjectType ¶ added in v0.0.5
type ObjectType = uint8
ObjectType is a type of Object
const ( // ObjectTypeConstantValue is ObjectType indicates a constant value ObjectTypeConstantValue ObjectType = iota + 1 )
type PacketAcknowledgement ¶
type PacketCommitAcknowledgement ¶
type PacketCommitAcknowledgement struct{}
func NewPacketCommitAcknowledgement ¶
func NewPacketCommitAcknowledgement() PacketCommitAcknowledgement
func (PacketCommitAcknowledgement) GetBytes ¶
func (p PacketCommitAcknowledgement) GetBytes() []byte
func (PacketCommitAcknowledgement) Type ¶
func (p PacketCommitAcknowledgement) Type() string
func (PacketCommitAcknowledgement) ValidateBasic ¶
func (p PacketCommitAcknowledgement) ValidateBasic() error
type PacketData ¶
type PacketDataCommit ¶
func NewPacketDataCommit ¶
func NewPacketDataCommit(txID TxID, txIndex TxIndex, isCommittable bool) PacketDataCommit
func (PacketDataCommit) GetBytes ¶
func (p PacketDataCommit) GetBytes() []byte
func (PacketDataCommit) GetTimeoutHeight ¶
func (p PacketDataCommit) GetTimeoutHeight() uint64
func (PacketDataCommit) GetTimeoutTimestamp ¶
func (p PacketDataCommit) GetTimeoutTimestamp() uint64
func (PacketDataCommit) Type ¶
func (p PacketDataCommit) Type() string
func (PacketDataCommit) ValidateBasic ¶
func (p PacketDataCommit) ValidateBasic() error
type PacketDataPrepare ¶
type PacketDataPrepare struct {
Sender sdk.AccAddress
TxID TxID
TxIndex TxIndex
TxInfo ContractTransactionInfo
}
func NewPacketDataPrepare ¶
func NewPacketDataPrepare(sender sdk.AccAddress, txID TxID, txIndex TxIndex, txInfo ContractTransactionInfo) PacketDataPrepare
func (PacketDataPrepare) GetBytes ¶
func (p PacketDataPrepare) GetBytes() []byte
func (PacketDataPrepare) GetTimeoutHeight ¶
func (p PacketDataPrepare) GetTimeoutHeight() uint64
func (PacketDataPrepare) GetTimeoutTimestamp ¶
func (p PacketDataPrepare) GetTimeoutTimestamp() uint64
func (PacketDataPrepare) Type ¶
func (p PacketDataPrepare) Type() string
func (PacketDataPrepare) ValidateBasic ¶
func (p PacketDataPrepare) ValidateBasic() error
type PacketPrepareAcknowledgement ¶
type PacketPrepareAcknowledgement struct {
Status uint8
}
func NewPacketPrepareAcknowledgement ¶
func NewPacketPrepareAcknowledgement(status uint8) PacketPrepareAcknowledgement
func (PacketPrepareAcknowledgement) GetBytes ¶
func (p PacketPrepareAcknowledgement) GetBytes() []byte
func (PacketPrepareAcknowledgement) IsOK ¶
func (p PacketPrepareAcknowledgement) IsOK() bool
func (PacketPrepareAcknowledgement) Type ¶
func (p PacketPrepareAcknowledgement) Type() string
func (PacketPrepareAcknowledgement) ValidateBasic ¶
func (p PacketPrepareAcknowledgement) ValidateBasic() error
type PortKeeper ¶
type PortKeeper interface {
BindPort(ctx sdk.Context, portID string) *capability.Capability
}
PortKeeper defines the expected IBC port keeper
type QueryCoordinatorStatusRequest ¶
type QueryCoordinatorStatusRequest struct {
TxID TxID `json:"tx_id" yaml:"tx_id"`
}
type QueryCoordinatorStatusResponse ¶
type QueryCoordinatorStatusResponse struct {
TxID TxID `json:"tx_id" yaml:"tx_id"`
CoordinatorInfo CoordinatorInfo `json:"coordinator_info" yaml:"coordinator_info"`
Completed bool `json:"completed" yaml:"completed"`
}
type QueryUnacknowledgedPacketsRequest ¶
type QueryUnacknowledgedPacketsRequest struct{}
type QueryUnacknowledgedPacketsResponse ¶
type QueryUnacknowledgedPacketsResponse struct {
Packets []UnacknowledgedPacket `json:"packets" yaml:"packets"`
}
type ReturnValue ¶ added in v0.0.5
type ReturnValue []byte
func NewReturnValue ¶ added in v0.0.5
func NewReturnValue(v []byte) *ReturnValue
func (*ReturnValue) Equal ¶ added in v0.0.5
func (rv *ReturnValue) Equal(bz []byte) bool
func (*ReturnValue) IsNil ¶ added in v0.0.5
func (rv *ReturnValue) IsNil() bool
type SequentialResolver ¶ added in v0.0.5
type SequentialResolver struct {
// contains filtered or unexported fields
}
SequentialResolver is a resolver that resolves an object in sequential
func NewSequentialResolver ¶ added in v0.0.5
func NewSequentialResolver(objects []Object) *SequentialResolver
NewSequentialResolver returns SequentialResolver
type StateConstraint ¶ added in v0.0.3
type StateConstraint struct {
Type StateConstraintType `json:"type" yaml:"type"`
OPs OPs `json:"ops" yaml:"ops"`
}
func NewStateConstraint ¶ added in v0.0.3
func NewStateConstraint(tp StateConstraintType, ops OPs) StateConstraint
type StateConstraintType ¶ added in v0.0.3
type StateConstraintType = uint8
const ( NoStateConstraint StateConstraintType = iota // NoStateConstraint indicates that no constraints on the state before and after the precommit is performed ExactMatchStateConstraint // ExactMatchStateConstraint indicates the constraint on state state before and after the precommit is performed PreStateConstraint // PreStateConstraint indicates the constraint on state before the precommit is performed PostStateConstraint // PostStateConstraint indicates the constraint on state after the precommit is performed )
type Store ¶
type Store interface {
// Get returns nil iff key doesn't exist. Panics on nil key.
Get(key []byte) []byte
// Has checks if a key exists. Panics on nil key.
Has(key []byte) bool
// Set sets the key. Panics on nil key or value.
Set(key, value []byte)
// Delete deletes the key. Panics on nil key.
Delete(key []byte)
}
type TxID ¶
type TxID = HexByteArray32
type TxInfo ¶
type TxInfo struct {
Status uint8 `json:"status" yaml:"status"`
PrepareResult uint8 `json:"prepare_result" yaml:"prepare_result"`
CoordinatorConnectionID string `json:"coordinator_connection_id" yaml:"coordinator_connection_id"`
ContractCallInfo []byte `json:"contract_call_info" yaml:"contract_call_info"`
}
type UnacknowledgedPacket ¶
type UnacknowledgedPacket struct {
Sequence uint64 `json:"sequence" yaml:"sequence"` // number corresponds to the order of sends and receives, where a Packet with an earlier sequence number must be sent and received before a Packet with a later sequence number.
SourcePort string `json:"source_port" yaml:"source_port"` // identifies the port on the sending chain.
SourceChannel string `json:"source_channel" yaml:"source_channel"` // identifies the channel end on the sending chain.
}
func ParseUnacknowledgedPacketKey ¶
func ParseUnacknowledgedPacketKey(key []byte) (*UnacknowledgedPacket, error)