ethereum

package
v5.1.0-beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: Apache-2.0 Imports: 18 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NetworkIDToContractAddresses = map[int]ContractAddresses{

	1: ContractAddresses{
		ERC20Proxy:          common.HexToAddress("0x95e6f48254609a6ee006f7d493c8e5fb97094cef"),
		ERC721Proxy:         common.HexToAddress("0xefc70a1b18c432bdc64b596838b4d138f6bc6cad"),
		ERC1155Proxy:        common.HexToAddress("0x7eefbd48fd63d441ec7435d024ec7c5131019add"),
		Exchange:            common.HexToAddress("0x080bf510fcbf18b91105470639e9561022937712"),
		Coordinator:         common.HexToAddress("0xa14857e8930acd9a882d33ec20559beb5479c8a6"),
		CoordinatorRegistry: common.HexToAddress("0x45797531b873fd5e519477a070a955764c1a5b07"),
		DevUtils:            common.HexToAddress("0x92d9a4d50190ae04e03914db2ee650124af844e6"),
		WETH9:               common.HexToAddress("0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"),
		ZRXToken:            common.HexToAddress("0xe41d2489571d322189246dafa5ebde1f4699f498"),
	},

	3: ContractAddresses{
		ERC20Proxy:          common.HexToAddress("0xb1408f4c245a23c31b98d2c626777d4c0d766caa"),
		ERC721Proxy:         common.HexToAddress("0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4"),
		ERC1155Proxy:        common.HexToAddress("0x19bb6caa3bc34d39e5a23cedfa3e6c7e7f3c931d"),
		Exchange:            common.HexToAddress("0xbff9493f92a3df4b0429b6d00743b3cfb4c85831"),
		Coordinator:         common.HexToAddress("0x2ba02e03ee0029311e0f43715307870a3e701b53"),
		CoordinatorRegistry: common.HexToAddress("0x403cc23e88c17c4652fb904784d1af640a6722d9"),
		DevUtils:            common.HexToAddress("0x3e0b46bad8e374e4a110c12b832cb120dbe4a479"),
		WETH9:               common.HexToAddress("0xc778417e063141139fce010982780140aa0cd5ab"),
		ZRXToken:            common.HexToAddress("0xff67881f8d12f372d91baae9752eb3631ff0ed00"),
	},

	4: ContractAddresses{
		ERC20Proxy:          common.HexToAddress("0x3e809c563c15a295e832e37053798ddc8d6c8dab"),
		ERC721Proxy:         common.HexToAddress("0x8e1ff02637cb5e39f2fa36c14706aa348b065b09"),
		ERC1155Proxy:        common.HexToAddress("0x19bb6caa3bc34d39e5a23cedfa3e6c7e7f3c931d"),
		Exchange:            common.HexToAddress("0xbff9493f92a3df4b0429b6d00743b3cfb4c85831"),
		Coordinator:         common.HexToAddress("0x2ba02e03ee0029311e0f43715307870a3e701b53"),
		CoordinatorRegistry: common.HexToAddress("0x1084b6a398e47907bae43fec3ff4b677db6e4fee"),
		DevUtils:            common.HexToAddress("0x2d4a9abda7b8b3605c8dbd34e3550a7467c78287"),
		WETH9:               common.HexToAddress("0xc778417e063141139fce010982780140aa0cd5ab"),
		ZRXToken:            common.HexToAddress("0x2727e688b8fd40b198cd5fe6e408e00494a06f07"),
	},

	42: ContractAddresses{
		ERC20Proxy:          common.HexToAddress("0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e"),
		ERC721Proxy:         common.HexToAddress("0x2a9127c745688a165106c11cd4d647d2220af821"),
		ERC1155Proxy:        common.HexToAddress("0x64517fa2b480ba3678a2a3c0cf08ef7fd4fad36f"),
		Exchange:            common.HexToAddress("0x30589010550762d2f0d06f650d8e8b6ade6dbf4b"),
		Coordinator:         common.HexToAddress("0x2ba02e03ee0029311e0f43715307870a3e701b53"),
		CoordinatorRegistry: common.HexToAddress("0x09fb99968c016a3ff537bf58fb3d9fe55a7975d5"),
		DevUtils:            common.HexToAddress("0x1e3616bc5144362f95d72de41874395567697e93"),
		WETH9:               common.HexToAddress("0xd0a1e359811322d97991e03f863a0c30c2cf029c"),
		ZRXToken:            common.HexToAddress("0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa"),
	},

	50: ContractAddresses{
		ERC20Proxy:          common.HexToAddress("0x1dc4c1cefef38a777b15aa20260a54e584b16c48"),
		ERC721Proxy:         common.HexToAddress("0x1d7022f5b17d2f8b695918fb48fa1089c9f85401"),
		ERC1155Proxy:        common.HexToAddress("0x6a4a62e5a7ed13c361b176a5f62c2ee620ac0df8"),
		Exchange:            common.HexToAddress("0x48bacb9266a570d521063ef5dd96e61686dbe788"),
		Coordinator:         common.HexToAddress("0x0d8b0dd11f5d34ed41d556def5f841900d5b1c6b"),
		CoordinatorRegistry: common.HexToAddress("0x1941ff73d1154774d87521d2d0aaad5d19c8df60"),
		DevUtils:            common.HexToAddress("0x38ef19fdf8e8415f18c307ed71967e19aac28ba1"),
		WETH9:               common.HexToAddress("0x0b1ba0af832d7c05fd64161e0db78e85978e8082"),
		ZRXToken:            common.HexToAddress("0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c"),
	},
}

NetworkIDToContractAddresses maps networkId to a mapping of contract name to Ethereum address on that given network

Functions

func AddContractAddressesForNetworkID

func AddContractAddressesForNetworkID(networkID int, addresses ContractAddresses) error

Types

type Balance

type Balance struct {
	Address common.Address
	Amount  *big.Int
}

Balance represents a single Ethereum addresses Ether balance

type BlockchainLifecycle

type BlockchainLifecycle struct {
	// contains filtered or unexported fields
}

BlockchainLifecycle is a testing utility for taking snapshots of the blockchain state on Ganache and reverting those snapshots at a later point in time. Ganache supports performing multiple snapshots that can then be reverted in LIFO order.

func NewBlockchainLifecycle

func NewBlockchainLifecycle(rpcClient *rpc.Client) (*BlockchainLifecycle, error)

NewBlockchainLifecycle instantiates a new blockchainLifecycle instance

func (*BlockchainLifecycle) Revert

func (b *BlockchainLifecycle) Revert(t *testing.T)

Revert reverts the latest snapshot of blockchain state created

func (*BlockchainLifecycle) Start

func (b *BlockchainLifecycle) Start(t *testing.T)

Start creates a snapshot of the blockchain state at that point in time and adds it's snapshotId to a stack

type ContractAddresses

type ContractAddresses struct {
	ERC20Proxy          common.Address `json:"erc20Proxy"`
	ERC721Proxy         common.Address `json:"erc721Proxy"`
	ERC1155Proxy        common.Address `json:"erc1155Proxy"`
	Exchange            common.Address `json:"exchange"`
	Coordinator         common.Address `json:"coordinator"`
	CoordinatorRegistry common.Address `json:"coordinatorRegistry"`
	DevUtils            common.Address `json:"devUtils"`
	WETH9               common.Address `json:"weth9"`
	ZRXToken            common.Address `json:"zrxToken"`
}

ContractAddresses maps a contract's name to it's Ethereum address

func GetContractAddressesForNetworkID

func GetContractAddressesForNetworkID(networkID int) (ContractAddresses, error)

GetContractAddressesForNetworkID returns the contract name mapping for the given network. It returns an error if the network doesn't exist.

type ECSignature

type ECSignature struct {
	V byte
	R common.Hash
	S common.Hash
}

ECSignature contains the parameters of an elliptic curve signature

type ETHWatcher

type ETHWatcher struct {
	// contains filtered or unexported fields
}

ETHWatcher allows for watching a set of Ethereum addresses for ETH balance changes

func NewETHWatcher

func NewETHWatcher(minPollingInterval time.Duration, ethClient *ethclient.Client, networkID int) (*ETHWatcher, error)

NewETHWatcher creates a new instance of ETHWatcher

func (*ETHWatcher) Add

func (e *ETHWatcher) Add(addresses []common.Address) (addressToBalance map[common.Address]*big.Int, failedAddresses []common.Address)

Add adds new Ethereum addresses we'd like to track for balance changes and returns a map of added address to balance, and an array of addresses that it failed to add due to failed network requests

func (*ETHWatcher) BalanceUpdates

func (e *ETHWatcher) BalanceUpdates() <-chan Balance

BalanceUpdates returns a read-only channel that can be used to listen for balance changes.

func (*ETHWatcher) GetBalance

func (e *ETHWatcher) GetBalance(address common.Address) (*big.Int, error)

GetBalance returns the Ether balance for a particular Ethereum address

func (*ETHWatcher) Remove

func (e *ETHWatcher) Remove(address common.Address)

Remove removes a new Ethereum address we no longer want to track for balance changes

func (*ETHWatcher) Watch

func (e *ETHWatcher) Watch(ctx context.Context) error

Watch starts watching for ETH balance changes. It blocks until there is an error or the given context is canceled.

type EthRPCSigner

type EthRPCSigner struct {
	// contains filtered or unexported fields
}

EthRPCSigner is a signer that uses a call to Ethereum JSON-RPC method `eth_call` to produce a signature

func (*EthRPCSigner) EthSign

func (e *EthRPCSigner) EthSign(message []byte, signerAddress common.Address) (*ECSignature, error)

EthSign signs a message via the `eth_sign` Ethereum JSON-RPC call

type LocalSigner

type LocalSigner struct {
	// contains filtered or unexported fields
}

LocalSigner is a signer that produces an `eth_sign`-compatible signature locally using a private key

func (*LocalSigner) EthSign

func (l *LocalSigner) EthSign(message []byte, signerAddress common.Address) (*ECSignature, error)

EthSign mimicks the signing of `eth_sign` locally its supplied private key

func (*LocalSigner) GetSignerAddress

func (l *LocalSigner) GetSignerAddress() common.Address

GetSignerAddress returns the signerAddress corresponding to LocalSigner's private key

type Signer

type Signer interface {
	EthSign(message []byte, signerAddress common.Address) (*ECSignature, error)
}

Signer defines the methods needed to act as a elliptic curve signer

func NewEthRPCSigner

func NewEthRPCSigner(rpcClient *rpc.Client) Signer

NewEthRPCSigner instantiates a new EthRPCSigner

func NewLocalSigner

func NewLocalSigner(privateKey *ecdsa.PrivateKey) Signer

NewLocalSigner instantiates a new LocalSigner

func NewTestSigner

func NewTestSigner() Signer

NewTestSigner instantiates a new LocalSigner

type TestSigner

type TestSigner struct{}

TestSigner generates `eth_sign` signatures for test accounts available on the test Ethereum node Ganache

func (*TestSigner) EthSign

func (t *TestSigner) EthSign(message []byte, signerAddress common.Address) (*ECSignature, error)

EthSign generates an `eth_sign` equivalent signature using an public/private key pair hard-coded in the constants package.

func (*TestSigner) SignTx

func (t *TestSigner) SignTx(message []byte, signerAddress common.Address) ([]byte, error)

SignTx signs an Ethereum transaction with a public/private key pair hard-coded in the constants package. It returns the transaction signature.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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