utils

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGasLimit = 6721975
View Source
const DefaultGasMultiplier = 1
View Source
const DefaultMaxGasPrice = 20000000000

Variables

View Source
var (
	RelayerAddresses = []common.Address{
		common.HexToAddress(keystore.TestKeyRing.EthereumKeys[keystore.AliceKey].Address()),
		common.HexToAddress(keystore.TestKeyRing.EthereumKeys[keystore.BobKey].Address()),
		common.HexToAddress(keystore.TestKeyRing.EthereumKeys[keystore.CharlieKey].Address()),
		common.HexToAddress(keystore.TestKeyRing.EthereumKeys[keystore.DaveKey].Address()),
		common.HexToAddress(keystore.TestKeyRing.EthereumKeys[keystore.EveKey].Address()),
	}

	ZeroAddress = common.HexToAddress("0x0000000000000000000000000000000000000000")
)
View Source
var ExpectedBlockTime = time.Second
View Source
var StoreFunctionSig = CreateFunctionSignature("store(bytes32)")

Functions

func ApproveErc721

func ApproveErc721(client *Client, contractAddress, recipient common.Address, tokenId *big.Int) error

func ConstructErc20DepositData

func ConstructErc20DepositData(destRecipient []byte, amount *big.Int) []byte

constructErc20Data constructs the data field to be passed into a n erc20 deposit call

func ConstructErc721DepositData

func ConstructErc721DepositData(tokenId *big.Int, destRecipient []byte) []byte

constructErc20Data constructs the data field to be passed into an erc721 deposit call

func ConstructGenericDepositData

func ConstructGenericDepositData(metadata []byte) []byte

func CreateFunctionSignature

func CreateFunctionSignature(sig string) [4]byte

CreateFunctionSignature hashes the function signature and returns the first 4 bytes

func DeployAndMintErc20

func DeployAndMintErc20(client *Client, amount *big.Int) (common.Address, error)

func DeployAssetStore

func DeployAssetStore(client *Client) (common.Address, error)

func DeployErc721

func DeployErc721(client *Client) (common.Address, error)

DeployMintAndApprove deploys a new erc721 contract, mints to the deployer, and approves the erc20 handler to transfer those token.

func DeployMintApproveErc20

func DeployMintApproveErc20(client *Client, erc20Handler common.Address, amount *big.Int) (common.Address, error)

DeployMintAndApprove deploys a new erc20 contract, mints to the deployer, and approves the erc20 handler to transfer those token.

func Erc20AddMinter

func Erc20AddMinter(client *Client, erc20Contract, handler common.Address) error

func Erc20Approve

func Erc20Approve(client *Client, erc20Contract, recipient common.Address, amount *big.Int) error

func Erc20GetAllowance

func Erc20GetAllowance(client *Client, erc20Contract, owner, spender common.Address) (*big.Int, error)

func Erc20GetBalance

func Erc20GetBalance(client *Client, erc20Contract, account common.Address) (*big.Int, error)

func Erc20GetResourceId

func Erc20GetResourceId(client *Client, handler common.Address, rId msg.ResourceId) (common.Address, error)

func Erc20Mint

func Erc20Mint(client *Client, erc20Address, recipient common.Address, amount *big.Int) error

func Erc721AddMinter

func Erc721AddMinter(client *Client, erc721Contract common.Address, minter common.Address) error

func Erc721GetTokenURI

func Erc721GetTokenURI(client *Client, erc721Contract common.Address, tokenId *big.Int) (string, error)

func Erc721Mint

func Erc721Mint(client *Client, erc721Contract common.Address, id *big.Int, metadata []byte) error

func FundErc20Handler

func FundErc20Handler(client *Client, handlerAddress, erc20Address common.Address, amount *big.Int) error

func FundErc721Handler

func FundErc721Handler(client *Client, handlerAddress, erc721Address common.Address, tokenId *big.Int) error

func GetDepositNonce

func GetDepositNonce(client *Client, bridge common.Address, chain msg.ChainId) (uint64, error)

func GetGenericResourceAddress

func GetGenericResourceAddress(client *Client, handler common.Address, rId msg.ResourceId) (common.Address, error)

func Hash

func Hash(data []byte) [32]byte

func HashExists

func HashExists(client *Client, hash [32]byte, contract common.Address) (bool, error)

func IDAndNonce

func IDAndNonce(srcId msg.ChainId, nonce msg.Nonce) *big.Int

func IsActive

func IsActive(status uint8) bool

func IsExecuted

func IsExecuted(status uint8) bool

func IsFinalized

func IsFinalized(status uint8) bool

func OwnerOf

func OwnerOf(client *Client, erc721Contract common.Address, tokenId *big.Int) (common.Address, error)

func RegisterResource

func RegisterResource(client *Client, bridge, handler common.Address, rId msg.ResourceId, addr common.Address) error

func SetBurnable

func SetBurnable(client *Client, bridge, handler, contract common.Address) error

func UpdateNonce

func UpdateNonce(client *Client) error

func WaitForTx

func WaitForTx(client *Client, tx *ethtypes.Transaction) error

WaitForTx will query the chain at ExpectedBlockTime intervals, until a receipt is returned. Returns an error if the tx failed.

Types

type Client

type Client struct {
	Client   *ethclient.Client
	Opts     *bind.TransactOpts
	CallOpts *bind.CallOpts
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string, kp *secp256k1.Keypair) (*Client, error)

func (*Client) LockNonceAndUpdate

func (c *Client) LockNonceAndUpdate() error

func (*Client) UnlockNonce

func (c *Client) UnlockNonce()

type DeployedContracts

type DeployedContracts struct {
	BridgeAddress       common.Address
	ERC20HandlerAddress common.Address
}

func DeployContracts

func DeployContracts(client *Client, chainID uint8, initialRelayerThreshold *big.Int) (*DeployedContracts, error)

DeployContracts deploys Bridge, Relayer, ERC20Handler, ERC721Handler and CentrifugeAssetHandler and returns the addresses

type EventSig

type EventSig string
const (
	Deposit       EventSig = "Deposit(uint8,bytes32,uint64)"
	ProposalEvent EventSig = "ProposalEvent(uint8,uint64,uint8,bytes32)"
	ProposalVote  EventSig = "ProposalVote(uint8,uint64,uint8,bytes32)"
)

func (EventSig) GetTopic

func (es EventSig) GetTopic() common.Hash

type ProposalStatus

type ProposalStatus int
const (
	Inactive ProposalStatus = iota
	Active
	Passed
	Executed
	Cancelled
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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