types

package
v0.0.0-...-d163155 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2020 License: Apache-2.0 Imports: 15 Imported by: 5

Documentation

Index

Constants

View Source
const (
	LockText = ClaimType(iota)
	BurnText
)
View Source
const (
	// FlagEthereumChainID flag for passing the Ethereum chain id field
	FlagEthereumChainID string = "ethereum-chain-id"
	// FlagTokenContractAddr flag for passing the token contract address field
	FlagTokenContractAddr string = "token-contract-address"
)
View Source
const (
	// ModuleName is the name of the ethereum bridge module
	ModuleName = "ethbridge"

	// StoreKey is the string store representation
	StoreKey = ModuleName

	// QuerierRoute is the querier route for the ethereum bridge module
	QuerierRoute = ModuleName

	// RouterKey is the msg router key for the ethereum bridge module
	RouterKey = ModuleName
)
View Source
const (
	TestEthereumChainID       = 3
	TestBridgeContractAddress = "0xC4cE93a5699c68241fc2fB503Fb0f21724A624BB"
	TestAddress               = "cosmos1gn8409qq9hnrxde37kuxwx5hrxpfpv8426szuv"
	TestValidator             = "cosmos1xdp5tvt7lxh8rf9xx07wy2xlagzhq24ha48xtq"
	TestNonce                 = 0
	TestTokenContractAddress  = "0x0000000000000000000000000000000000000000"
	TestEthereumAddress       = "0x7B95B6EC7EbD73572298cEf32Bb54FA408207359"
	AltTestEthereumAddress    = "0x7B95B6EC7EbD73572298cEf32Bb54FA408207344"
	TestCoinsAmount           = 10
	TestCoinsSymbol           = "eth"
	TestCoinsLockedSymbol     = "peggyeth"
	AltTestCoinsAmount        = 12
	AltTestCoinsSymbol        = "eth"
)
View Source
const PeggedCoinPrefix = "peggy"
View Source
const (
	QueryEthProphecy = "prophecies"
)

query endpoints supported by the oracle Querier

Variables

View Source
var (
	ErrInvalidEthNonce   = sdkerrors.Register(ModuleName, 1, "invalid ethereum nonce provided, must be >= 0")
	ErrInvalidEthAddress = sdkerrors.Register(ModuleName, 2,
		"invalid ethereum address provided, must be a valid hex-encoded Ethereum address")
	ErrJSONMarshalling  = sdkerrors.Register(ModuleName, 3, "error marshalling JSON for this claim")
	ErrInvalidEthSymbol = sdkerrors.Register(ModuleName, 4,
		"invalid symbol provided, symbol 'eth' must have null address set as token contract address")
	ErrInvalidClaimType       = sdkerrors.Register(ModuleName, 5, "invalid claim type provided")
	ErrInvalidEthereumChainID = sdkerrors.Register(ModuleName, 6, "invalid ethereum chain id")
	ErrInvalidAmount          = sdkerrors.Register(ModuleName, 7, "amount must be a valid integer > 0")
	ErrInvalidSymbol          = sdkerrors.Register(ModuleName, 8, "symbol must be 1 character or more")
	ErrInvalidBurnSymbol      = sdkerrors.Register(ModuleName, 9,
		fmt.Sprintf("symbol of token to burn must be in the form %v{ethereumSymbol}", PeggedCoinPrefix))
)
View Source
var (
	EventTypeCreateClaim    = "create_claim"
	EventTypeProphecyStatus = "prophecy_status"
	EventTypeBurn           = "burn"
	EventTypeLock           = "lock"

	AttributeKeyEthereumSender = "ethereum_sender"
	AttributeKeyCosmosReceiver = "cosmos_receiver"
	AttributeKeyAmount         = "amount"
	AttributeKeySymbol         = "symbol"
	AttributeKeyCoins          = "coins"
	AttributeKeyStatus         = "status"
	AttributeKeyClaimType      = "claim_type"

	AttributeKeyEthereumChainID  = "ethereum_chain_id"
	AttributeKeyTokenContract    = "token_contract_address"
	AttributeKeyCosmosSender     = "cosmos_sender"
	AttributeKeyEthereumReceiver = "ethereum_receiver"

	AttributeValueCategory = ModuleName
)

Ethbridge module event types

View Source
var ClaimTypeToString = [...]string{"lock", "burn"}

Functions

func CreateOracleClaimFromEthClaim

func CreateOracleClaimFromEthClaim(cdc *codec.Codec, ethClaim EthBridgeClaim) (oracle.Claim, error)

CreateOracleClaimFromEthClaim converts a specific ethereum bridge claim to a general oracle claim to be used by the oracle module. The oracle module expects every claim for a particular prophecy to have the same id, so this id must be created in a deterministic way that all validators can follow. For this, we use the Nonce an Ethereum Sender provided, as all validators will see this same data from the smart contract.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the Amino codec

Types

type AccountKeeper

type AccountKeeper interface {
	GetAccount(sdk.Context, sdk.AccAddress) authexported.Account
}

AccountKeeper defines the expected account keeper

type ClaimType

type ClaimType int

ClaimType is an enum used to represent the type of claim

func StringToClaimType

func StringToClaimType(text string) (ClaimType, error)

func (ClaimType) MarshalJSON

func (text ClaimType) MarshalJSON() ([]byte, error)

func (ClaimType) String

func (text ClaimType) String() string

func (*ClaimType) UnmarshalJSON

func (text *ClaimType) UnmarshalJSON(b []byte) error

type EthBridgeClaim

type EthBridgeClaim struct {
	EthereumChainID       int             `json:"ethereum_chain_id" yaml:"ethereum_chain_id"`
	BridgeContractAddress EthereumAddress `json:"bridge_registry_contract_address" yaml:"bridge_registry_contract_address"`
	Nonce                 int             `json:"nonce" yaml:"nonce"`
	Symbol                string          `json:"symbol" yaml:"symbol"`
	TokenContractAddress  EthereumAddress `json:"token_contract_address" yaml:"token_contract_address"`
	EthereumSender        EthereumAddress `json:"ethereum_sender" yaml:"ethereum_sender"`
	CosmosReceiver        sdk.AccAddress  `json:"cosmos_receiver" yaml:"cosmos_receiver"`
	ValidatorAddress      sdk.ValAddress  `json:"validator_address" yaml:"validator_address"`
	Amount                int64           `json:"amount" yaml:"amount"`
	ClaimType             ClaimType       `json:"claim_type" yaml:"claim_type"`
}

EthBridgeClaim is a structure that contains all the data for a particular bridge claim

func CreateEthClaimFromOracleString

func CreateEthClaimFromOracleString(
	ethereumChainID int, bridgeContract EthereumAddress, nonce int,
	ethereumAddress EthereumAddress, validator sdk.ValAddress, oracleClaimString string,
) (EthBridgeClaim, error)

CreateEthClaimFromOracleString converts a string from any generic claim from the oracle module into an ethereum bridge specific claim.

func CreateTestEthClaim

func CreateTestEthClaim(
	t *testing.T, testContractAddress EthereumAddress, testTokenAddress EthereumAddress,
	validatorAddress sdk.ValAddress, testEthereumAddress EthereumAddress, amount int64, symbol string, claimType ClaimType,
) EthBridgeClaim

func MapOracleClaimsToEthBridgeClaims

func MapOracleClaimsToEthBridgeClaims(
	ethereumChainID int, bridgeContract EthereumAddress, nonce int, symbol string,
	tokenContract EthereumAddress, ethereumSender EthereumAddress,
	oracleValidatorClaims map[string]string,
	f func(int, EthereumAddress, int, EthereumAddress, sdk.ValAddress, string,
	) (EthBridgeClaim, error),
) ([]EthBridgeClaim, error)

MapOracleClaimsToEthBridgeClaims maps a set of generic oracle claim data into EthBridgeClaim objects

func NewEthBridgeClaim

func NewEthBridgeClaim(ethereumChainID int, bridgeContract EthereumAddress,
	nonce int, symbol string, tokenContact EthereumAddress, ethereumSender EthereumAddress,
	cosmosReceiver sdk.AccAddress, validator sdk.ValAddress, amount int64, claimType ClaimType,
) EthBridgeClaim

NewEthBridgeClaim is a constructor function for NewEthBridgeClaim

type EthereumAddress

type EthereumAddress gethCommon.Address

EthereumAddress defines a standard ethereum address

func NewEthereumAddress

func NewEthereumAddress(address string) EthereumAddress

NewEthereumAddress is a constructor function for EthereumAddress

func (EthereumAddress) MarshalJSON

func (ethAddr EthereumAddress) MarshalJSON() ([]byte, error)

MarshalJSON marshals the etherum address to JSON

func (EthereumAddress) String

func (ethAddr EthereumAddress) String() string

Route should return the name of the module

func (*EthereumAddress) UnmarshalJSON

func (ethAddr *EthereumAddress) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals an ethereum address

type MsgBurn

type MsgBurn struct {
	CosmosSender     sdk.AccAddress  `json:"cosmos_sender" yaml:"cosmos_sender"`
	Amount           int64           `json:"amount" yaml:"amount"`
	Symbol           string          `json:"symbol" yaml:"symbol"`
	EthereumChainID  int             `json:"ethereum_chain_id" yaml:"ethereum_chain_id"`
	EthereumReceiver EthereumAddress `json:"ethereum_receiver" yaml:"ethereum_receiver"`
}

MsgBurn defines a message for burning coins and triggering a related event

func CreateTestBurnMsg

func CreateTestBurnMsg(t *testing.T, testCosmosSender string, ethereumReceiver EthereumAddress,
	coinsAmount int64, coinsSymbol string) MsgBurn

func NewMsgBurn

func NewMsgBurn(
	ethereumChainID int, cosmosSender sdk.AccAddress,
	ethereumReceiver EthereumAddress, amount int64, symbol string) MsgBurn

NewMsgBurn is a constructor function for MsgBurn

func (MsgBurn) GetSignBytes

func (msg MsgBurn) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgBurn) GetSigners

func (msg MsgBurn) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required

func (MsgBurn) Route

func (msg MsgBurn) Route() string

Route should return the name of the module

func (MsgBurn) Type

func (msg MsgBurn) Type() string

Type should return the action

func (MsgBurn) ValidateBasic

func (msg MsgBurn) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type MsgCreateEthBridgeClaim

type MsgCreateEthBridgeClaim EthBridgeClaim

MsgCreateEthBridgeClaim defines a message for creating claims on the ethereum bridge

func CreateTestEthMsg

func CreateTestEthMsg(t *testing.T, validatorAddress sdk.ValAddress, claimType ClaimType) MsgCreateEthBridgeClaim

Ethereum-bridge specific stuff

func NewMsgCreateEthBridgeClaim

func NewMsgCreateEthBridgeClaim(ethBridgeClaim EthBridgeClaim) MsgCreateEthBridgeClaim

NewMsgCreateEthBridgeClaim is a constructor function for MsgCreateBridgeClaim

func (MsgCreateEthBridgeClaim) GetSignBytes

func (msg MsgCreateEthBridgeClaim) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgCreateEthBridgeClaim) GetSigners

func (msg MsgCreateEthBridgeClaim) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required

func (MsgCreateEthBridgeClaim) Route

func (msg MsgCreateEthBridgeClaim) Route() string

Route should return the name of the module

func (MsgCreateEthBridgeClaim) Type

func (msg MsgCreateEthBridgeClaim) Type() string

Type should return the action

func (MsgCreateEthBridgeClaim) ValidateBasic

func (msg MsgCreateEthBridgeClaim) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type MsgLock

type MsgLock struct {
	CosmosSender     sdk.AccAddress  `json:"cosmos_sender" yaml:"cosmos_sender"`
	Amount           int64           `json:"amount" yaml:"amount"`
	Symbol           string          `json:"symbol" yaml:"symbol"`
	EthereumChainID  int             `json:"ethereum_chain_id" yaml:"ethereum_chain_id"`
	EthereumReceiver EthereumAddress `json:"ethereum_receiver" yaml:"ethereum_receiver"`
}

MsgLock defines a message for locking coins and triggering a related event

func NewMsgLock

func NewMsgLock(
	ethereumChainID int, cosmosSender sdk.AccAddress,
	ethereumReceiver EthereumAddress, amount int64, symbol string) MsgLock

NewMsgLock is a constructor function for MsgLock

func (MsgLock) GetSignBytes

func (msg MsgLock) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgLock) GetSigners

func (msg MsgLock) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required

func (MsgLock) Route

func (msg MsgLock) Route() string

Route should return the name of the module

func (MsgLock) Type

func (msg MsgLock) Type() string

Type should return the action

func (MsgLock) ValidateBasic

func (msg MsgLock) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type OracleClaimContent

type OracleClaimContent struct {
	CosmosReceiver       sdk.AccAddress  `json:"cosmos_receiver" yaml:"cosmos_receiver"`
	Amount               int64           `json:"amount" yaml:"amount"`
	Symbol               string          `json:"symbol" yaml:"symbol"`
	TokenContractAddress EthereumAddress `json:"token_contract_address" yaml:"token_contract_address"`
	ClaimType            ClaimType       `json:"claim_type" yaml:"claim_type"`
}

OracleClaimContent is the details of how the content of the claim for each validator will be stored in the oracle

func CreateOracleClaimFromOracleString

func CreateOracleClaimFromOracleString(oracleClaimString string) (OracleClaimContent, error)

CreateOracleClaimFromOracleString converts a JSON string into an OracleClaimContent struct used by this module. In general, it is expected that the oracle module will store claims in this JSON format and so this should be used to convert oracle claims.

func NewOracleClaimContent

func NewOracleClaimContent(
	cosmosReceiver sdk.AccAddress, amount int64, symbol string, tokenContractAddress EthereumAddress, claimType ClaimType,
) OracleClaimContent

NewOracleClaimContent is a constructor function for OracleClaim

type OracleKeeper

type OracleKeeper interface {
	ProcessClaim(ctx sdk.Context, claim oracle.Claim) (oracle.Status, error)
	GetProphecy(ctx sdk.Context, id string) (oracle.Prophecy, bool)
}

OracleKeeper defines the expected oracle keeper

type QueryEthProphecyParams

type QueryEthProphecyParams struct {
	EthereumChainID       int             `json:"ethereum_chain_id"`
	BridgeContractAddress EthereumAddress `json:"bridge_registry_contract_address"`
	Nonce                 int             `json:"nonce"`
	Symbol                string          `json:"symbol"`
	TokenContractAddress  EthereumAddress `json:"token_contract_address"`
	EthereumSender        EthereumAddress `json:"ethereum_sender"`
}

QueryEthProphecyParams defines the params for the following queries: - 'custom/ethbridge/prophecies/'

func NewQueryEthProphecyParams

func NewQueryEthProphecyParams(
	ethereumChainID int, bridgeContractAddress EthereumAddress, nonce int, symbol string,
	tokenContractAddress EthereumAddress, ethereumSender EthereumAddress,
) QueryEthProphecyParams

NewQueryEthProphecyParams creates a new QueryEthProphecyParams

type QueryEthProphecyResponse

type QueryEthProphecyResponse struct {
	ID     string           `json:"id"`
	Status oracle.Status    `json:"status"`
	Claims []EthBridgeClaim `json:"claims"`
}

QueryEthProphecyResponse defines the result payload for an eth prophecy query

func CreateTestQueryEthProphecyResponse

func CreateTestQueryEthProphecyResponse(
	cdc *codec.Codec, t *testing.T, validatorAddress sdk.ValAddress, claimType ClaimType,
) QueryEthProphecyResponse

func NewQueryEthProphecyResponse

func NewQueryEthProphecyResponse(
	id string, status oracle.Status, claims []EthBridgeClaim,
) QueryEthProphecyResponse

NewQueryEthProphecyResponse creates a new QueryEthProphecyResponse instance

func (QueryEthProphecyResponse) String

func (response QueryEthProphecyResponse) String() string

String implements fmt.Stringer interface

type SupplyKeeper

type SupplyKeeper interface {
	SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
	SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
	MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error
	BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error
	SetModuleAccount(sdk.Context, supplyexported.ModuleAccountI)
}

SupplyKeeper defines the expected supply keeper

Jump to

Keyboard shortcuts

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