txs

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EthereumPrivateKey config field which holds the user's private key
	EthereumPrivateKey        = "ETHEREUM_PRIVATE_KEY"
	TestEthereumChainID       = 3
	TestBridgeContractAddress = "0xd88159878c50e4B2b03BB701DD436e4A98D6fBe2"
	TestLockClaimType         = 1
	TestBurnClaimType         = 2
	TestProphecyID            = 20
	TestNonce                 = 19
	TestEthTokenAddress       = "0x0000000000000000000000000000000000000000"
	TestSymbol                = "CETH"
	TestEthereumAddress1      = "0x7B95B6EC7EbD73572298cEf32Bb54FA408207359"
	TestEthereumAddress2      = "0xc230f38FF05860753840e0d7cbC66128ad308B67"
	TestCosmosAddress1        = "cosmos1gn8409qq9hnrxde37kuxwx5hrxpfpv8426szuv"
	TestCosmosAddress2        = "cosmos1l5h2x255pvdy9l4z0hf9tr8zw7k657s97wyz7y"
	TestCosmosValAddress      = "cosmosvaloper1mnfm9c7cdgqnkk66sganp78m0ydmcr4pn7fqfk"
	TestExpectedMessage       = "8d46d2f689aa50a0dde8563f4ab1c90f4f74a80817ad18052ef1aa8bd5a0fd96"
	TestCosmosAddressSequence = 1
	TestExpectedSignature     = "" //nolint:lll
	/* 130-byte string literal not displayed */
	TestAddrHex      = "970e8128ab834e8eac17ab8e3812f010678cf791"
	TestPrivHex      = "289c2857d4598e37fb9647507e47a309d6133539bf21a8b9cb6df88fd5232032"
	TestNullAddress  = "0x0000000000000000000000000000000000000000"
	TestOtherAddress = "0x1000000000000000000000000000000000000000"
)
View Source
const (
	// GasLimit the gas limit in Gwei used for transactions sent with TransactOpts
	GasLimit = uint64(1800000)
)

Variables

This section is empty.

Functions

func AttributesToEthereumBridgeClaim

func AttributesToEthereumBridgeClaim(attributes []abci.EventAttribute) (types.EthereumBridgeClaim, error)

AttributesToEthereumBridgeClaim parses data from event to EthereumBridgeClaim

func BurnLockEventToCosmosMsg

func BurnLockEventToCosmosMsg(claimType types.Event, attributes []abci.EventAttribute, symbolTranslator *symbol_translator.SymbolTranslator, sugaredLogger *zap.SugaredLogger) (types.CosmosMsg, error)

BurnLockEventToCosmosMsg parses data from a Burn/Lock event witnessed on Cosmos into a CosmosMsg struct

func CreateCosmosMsgAttributes

func CreateCosmosMsgAttributes(t *testing.T, claimType types.Event) []abci.EventAttribute

CreateCosmosMsgAttributes creates expected attributes for a MsgBurn/MsgLock for testing purposes

func CreateCosmosMsgIncompleteAttributes

func CreateCosmosMsgIncompleteAttributes(t *testing.T, claimType types.Event) []abci.EventAttribute

CreateCosmosMsgIncompleteAttributes creates a MsgBurn/MsgLock for testing purposes missing some attributes

func CreateEthereumBridgeClaimAttributes

func CreateEthereumBridgeClaimAttributes(t *testing.T) []abci.EventAttribute

CreateEthereumBridgeClaimAttributes creates some attributes for ethereum bridge claim

func CreateInvalidCosmosSenderEthereumBridgeClaimAttributes

func CreateInvalidCosmosSenderEthereumBridgeClaimAttributes(t *testing.T) []abci.EventAttribute

CreateInvalidCosmosSenderEthereumBridgeClaimAttributes creates some invalide attributes for ethereum bridge claim

func CreateInvalidEthereumSenderEthereumBridgeClaimAttributes

func CreateInvalidEthereumSenderEthereumBridgeClaimAttributes(t *testing.T) []abci.EventAttribute

CreateInvalidEthereumSenderEthereumBridgeClaimAttributes creates some attributes for ethereum bridge claim

func CreateInvalidSequenceEthereumBridgeClaimAttributes

func CreateInvalidSequenceEthereumBridgeClaimAttributes(t *testing.T) []abci.EventAttribute

CreateInvalidSequenceEthereumBridgeClaimAttributes creates some attributes for ethereum bridge claim

func CreateTestCosmosMsg

func CreateTestCosmosMsg(t *testing.T, claimType types.Event) types.CosmosMsg

CreateTestCosmosMsg creates a sample Cosmos Msg for testing purposes

func CreateTestLogEthereumEvent

func CreateTestLogEthereumEvent(t *testing.T) types.EthereumEvent

CreateTestLogEthereumEvent creates a sample EthereumEvent event for testing purposes

func CreateTestProphecyClaimEvent

func CreateTestProphecyClaimEvent(t *testing.T) types.ProphecyClaimEvent

CreateTestProphecyClaimEvent creates a sample ProphecyClaimEvent for testing purposes

func EthereumEventToEthBridgeClaim

func EthereumEventToEthBridgeClaim(valAddr sdk.ValAddress, event types.EthereumEvent, symbolTranslator *symbol_translator.SymbolTranslator, sugaredLogger *zap.SugaredLogger) (ethbridge.EthBridgeClaim, error)

EthereumEventToEthBridgeClaim parses and packages an Ethereum event struct with a validator address in an EthBridgeClaim msg

func GenerateClaimMessage

func GenerateClaimMessage(event types.ProphecyClaimEvent) []byte

GenerateClaimMessage Generates a hashed message containing a ProphecyClaim event's data

func GetAddressFromBridgeRegistry

func GetAddressFromBridgeRegistry(client *ethclient.Client, registry common.Address, target ContractRegistry,
	sugaredLogger *zap.SugaredLogger) (common.Address, error)

GetAddressFromBridgeRegistry queries the requested contract address from the BridgeRegistry contract

func InitRelayConfig

func InitRelayConfig(
	provider string,
	registry common.Address,
	event types.Event,
	key *ecdsa.PrivateKey,
	sugaredLogger *zap.SugaredLogger,
) (
	*ethclient.Client,
	*bind.TransactOpts,
	common.Address,
	error,
)

InitRelayConfig set up Ethereum client, validator's transaction auth, and the target contract's address

func LoadPrivateKey

func LoadPrivateKey() (key *ecdsa.PrivateKey, err error)

LoadPrivateKey loads the validator's private key from environment variables

func LoadSender

func LoadSender() (address common.Address, err error)

LoadSender uses the validator's private key to load the validator's address

func PrefixMsg

func PrefixMsg(msg []byte) []byte

PrefixMsg prefixes a message for verification, mimics behavior of web3.eth.sign

func RelayProphecyClaimToEthereum

func RelayProphecyClaimToEthereum(
	claim types.CosmosMsg,
	sugaredLogger *zap.SugaredLogger,
	client *ethclient.Client,
	auth *bind.TransactOpts,
	cosmosBridgeInstance *cosmosbridge.CosmosBridge,
) error

RelayProphecyClaimToEthereum relays the provided ProphecyClaim to CosmosBridge contract on the Ethereum network

func RelayToCosmos

func RelayToCosmos(factory tx.Factory, claims []*types.EthBridgeClaim, cliCtx client.Context, sugaredLogger *zap.SugaredLogger) error

RelayToCosmos applies validator's signature to an EthBridgeClaim message containing information about an event on the Ethereum blockchain before relaying to the Bridge

func SignClaim

func SignClaim(msg []byte, key *ecdsa.PrivateKey) ([]byte, error)

SignClaim Signs the prepared message with validator's private key

Types

type ContractRegistry

type ContractRegistry byte

ContractRegistry is an enum for the bridge contract types

const (
	// Valset valset contract
	Valset ContractRegistry = iota + 1
	// Oracle oracle contract
	Oracle
	// BridgeBank bridgeBank contract
	BridgeBank
	// CosmosBridge cosmosBridge contract
	CosmosBridge
)

func (ContractRegistry) String

func (d ContractRegistry) String() string

String returns the event type as a string

Jump to

Keyboard shortcuts

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