Documentation ¶
Index ¶
- Variables
- type Balance
- type BlockchainLifecycle
- type ContractAddresses
- type ECSignature
- type ETHWatcher
- func (e *ETHWatcher) Add(addresses []common.Address) (addressToBalance map[common.Address]*big.Int, failedAddresses []common.Address)
- func (e *ETHWatcher) GetBalance(address common.Address) (*big.Int, error)
- func (e *ETHWatcher) Receive() <-chan Balance
- func (e *ETHWatcher) Remove(address common.Address)
- func (e *ETHWatcher) Start() error
- func (e *ETHWatcher) Stop()
- type EthRPCSigner
- type LocalSigner
- type Signer
- type TestSigner
Constants ¶
This section is empty.
Variables ¶
var GanacheEthBalanceCheckerAddress = common.HexToAddress("0xaa86dda78e9434aca114b6676fc742a18d15a1cc")
GanacheEthBalanceCheckerAddress is the ganache snapshot EthBalanceChecker contract address
var MainnetEthBalanceCheckerAddress = common.HexToAddress("0x9bc2c6ae8b1a8e3c375b6ccb55eb4273b2c3fbde")
MainnetEthBalanceCheckerAddress is the mainnet EthBalanceChecker contract address
var NetworkIDToContractAddresses = map[int]ContractAddresses{ 1: ContractAddresses{ ERC20Proxy: common.HexToAddress("0x95e6f48254609a6ee006f7d493c8e5fb97094cef"), ERC721Proxy: common.HexToAddress("0xefc70a1b18c432bdc64b596838b4d138f6bc6cad"), Exchange: common.HexToAddress("0x080bf510fcbf18b91105470639e9561022937712"), OrderValidationUtils: common.HexToAddress("0x2dbaf1295a443db13dceb5a0dffed9bc1a0207b0"), EthBalanceChecker: common.HexToAddress("0x9bc2c6ae8b1a8e3c375b6ccb55eb4273b2c3fbde"), Coordinator: common.HexToAddress("0xa14857e8930acd9a882d33ec20559beb5479c8a6"), CoordinatorRegistry: common.HexToAddress("0x45797531b873fd5e519477a070a955764c1a5b07"), }, 3: ContractAddresses{ ERC20Proxy: common.HexToAddress("0xb1408f4c245a23c31b98d2c626777d4c0d766caa"), ERC721Proxy: common.HexToAddress("0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4"), Exchange: common.HexToAddress("0xbff9493f92a3df4b0429b6d00743b3cfb4c85831"), OrderValidationUtils: common.HexToAddress("0x5b749752e39f7f9c8b7f5e4ac58cd6901df8b7ce"), EthBalanceChecker: common.HexToAddress("0xd5d960219af544b6f2f3e14a8bfd03dec12292fa"), Coordinator: common.HexToAddress("0x2ba02e03ee0029311e0f43715307870a3e701b53"), CoordinatorRegistry: common.HexToAddress("0x403cc23e88c17c4652fb904784d1af640a6722d9"), }, 4: ContractAddresses{ ERC20Proxy: common.HexToAddress("0x3e809c563c15a295e832e37053798ddc8d6c8dab"), ERC721Proxy: common.HexToAddress("0x8e1ff02637cb5e39f2fa36c14706aa348b065b09"), Exchange: common.HexToAddress("0xbff9493f92a3df4b0429b6d00743b3cfb4c85831"), OrderValidationUtils: common.HexToAddress("0x51fc4f8ee79b0c86e96f44385161111a676d5f1b"), EthBalanceChecker: common.HexToAddress("0x08b71282431009022eda2dda8af0fbee535e1507"), Coordinator: common.HexToAddress("0x2ba02e03ee0029311e0f43715307870a3e701b53"), CoordinatorRegistry: common.HexToAddress("0x1084b6a398e47907bae43fec3ff4b677db6e4fee"), }, 42: ContractAddresses{ ERC20Proxy: common.HexToAddress("0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e"), ERC721Proxy: common.HexToAddress("0x2a9127c745688a165106c11cd4d647d2220af821"), Exchange: common.HexToAddress("0x30589010550762d2f0d06f650d8e8b6ade6dbf4b"), OrderValidationUtils: common.HexToAddress("0xb3667ce62aa9fabcc352c5b6dac27ea61f1a3e71"), EthBalanceChecker: common.HexToAddress("0x505aa534485bf80ee919339717cff90eb2e3364c"), Coordinator: common.HexToAddress("0x2ba02e03ee0029311e0f43715307870a3e701b53"), CoordinatorRegistry: common.HexToAddress("0x09fb99968c016a3ff537bf58fb3d9fe55a7975d5"), }, 50: ContractAddresses{ ERC20Proxy: common.HexToAddress("0x1dc4c1cefef38a777b15aa20260a54e584b16c48"), ERC721Proxy: common.HexToAddress("0x1d7022f5b17d2f8b695918fb48fa1089c9f85401"), Exchange: common.HexToAddress("0x48bacb9266a570d521063ef5dd96e61686dbe788"), OrderValidationUtils: common.HexToAddress("0x8d42e38980ce74736c21c059b2240df09958d3c8"), EthBalanceChecker: common.HexToAddress("0xa31e64ea55b9b6bbb9d6a676738e9a5b23149f84"), Coordinator: common.HexToAddress("0x4d3d5c850dd5bd9d6f4adda3dd039a3c8054ca29"), CoordinatorRegistry: common.HexToAddress("0xaa86dda78e9434aca114b6676fc742a18d15a1cc"), }, }
NetworkIDToContractAddresses maps networkId to a mapping of contract name to Ethereum address on that given network
Functions ¶
This section is empty.
Types ¶
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(rpcURL string) (*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 ERC721Proxy common.Address OrderValidationUtils common.Address Exchange common.Address EthBalanceChecker common.Address Coordinator common.Address CoordinatorRegistry common.Address }
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 ¶
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) GetBalance ¶
GetBalance returns the Ether balance for a particular Ethereum address
func (*ETHWatcher) Receive ¶
func (e *ETHWatcher) Receive() <-chan Balance
Receive returns a read-only channel that can be used to listen for modified ETH balances
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
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 ¶
NewEthRPCSigner instantiates a new EthRPCSigner
func NewLocalSigner ¶
func NewLocalSigner(privateKey *ecdsa.PrivateKey) Signer
NewLocalSigner 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.