diff --git a/api/.gitignore b/api/.gitignore new file mode 100644 index 000000000..43921afea --- /dev/null +++ b/api/.gitignore @@ -0,0 +1 @@ +accounts.sql* diff --git a/api/backend_test.go b/api/backend_test.go index 22b0c4dca..5f9447de9 100644 --- a/api/backend_test.go +++ b/api/backend_test.go @@ -12,14 +12,11 @@ import ( "sync" "testing" - "github.com/status-im/status-go/account/generator" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" gethcrypto "github.com/ethereum/go-ethereum/crypto" - "github.com/status-im/status-go/account" "github.com/status-im/status-go/connection" "github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/eth-node/types" @@ -169,68 +166,6 @@ func TestBackendGettersConcurrently(t *testing.T) { wg.Wait() } -func TestBackendAccountsConcurrently(t *testing.T) { - utils.Init() - - backend := NewGethStatusBackend() - config, err := utils.MakeTestNodeConfig(params.StatusChainNetworkID) - require.NoError(t, err) - require.NoError(t, backend.AccountManager().InitKeystore(config.KeyStoreDir)) - err = backend.StartNode(config) - require.NoError(t, err) - defer func() { - require.NoError(t, backend.StopNode()) - }() - - var wgCreateAccounts sync.WaitGroup - count := 3 - type AccountData struct { - MasterAccount generator.GeneratedAccountInfo - AccountInfo account.Info - Password string - } - addressCh := make(chan AccountData, count) // use buffered channel to avoid blocking - - // create new accounts concurrently - for i := 0; i < count; i++ { - wgCreateAccounts.Add(1) - go func(pass string) { - MKInfo, accountInfo, _, err := backend.AccountManager().CreateAccount(pass) - assert.NoError(t, err) - addressCh <- AccountData{MKInfo, accountInfo, pass} - wgCreateAccounts.Done() - }("password-00" + fmt.Sprint(i)) - } - - // close addressCh as otherwise for loop never finishes - go func() { wgCreateAccounts.Wait(); close(addressCh) }() - - // select, reselect or logout concurrently - var wg sync.WaitGroup - - for accountData := range addressCh { - wg.Add(1) - go func(accountData AccountData) { - loginParams := account.LoginParams{ - MainAccount: types.HexToAddress(accountData.AccountInfo.WalletAddress), - ChatAddress: types.HexToAddress(accountData.AccountInfo.ChatAddress), - Password: accountData.Password, - MultiAccount: accountData.MasterAccount.ToMultiAccount(), - } - assert.NoError(t, backend.SelectAccount(loginParams)) - wg.Done() - }(accountData) - - wg.Add(1) - go func() { - assert.NoError(t, backend.Logout()) - wg.Done() - }() - } - - wg.Wait() -} - func TestBackendConnectionChangesConcurrently(t *testing.T) { connections := [...]string{connection.Wifi, connection.Cellular, connection.Unknown} backend := NewGethStatusBackend() @@ -529,6 +464,10 @@ func TestLoginWithKey(t *testing.T) { require.NoError(t, b.Logout()) require.NoError(t, b.StopNode()) + require.NoError(t, b.AccountManager().InitKeystore(conf.KeyStoreDir)) + b.UpdateRootDataDir(conf.DataDir) + require.NoError(t, b.OpenAccounts()) + require.NoError(t, b.StartNodeWithKey(main, "test-pass", keyhex)) defer func() { assert.NoError(t, b.Logout()) diff --git a/api/geth_backend.go b/api/geth_backend.go index c8233d9ac..f4dbf3b95 100644 --- a/api/geth_backend.go +++ b/api/geth_backend.go @@ -591,6 +591,7 @@ func (b *GethStatusBackend) startNode(config *params.NodeConfig) (err error) { b.transactor.SetNetworkID(config.NetworkID) b.transactor.SetRPC(b.statusNode.RPCClient(), rpc.DefaultCallTimeout) + b.personalAPI.SetRPC(b.statusNode.RPCClient(), rpc.DefaultCallTimeout) if err = b.registerHandlers(); err != nil { b.log.Error("Handler registration failed", "err", err) diff --git a/node/status_node_services.go b/node/status_node_services.go index 54179180a..a1bb22c18 100644 --- a/node/status_node_services.go +++ b/node/status_node_services.go @@ -470,7 +470,7 @@ func (b *StatusNode) Cleanup() error { } } - if b.Config().WalletConfig.Enabled { + if b.Config() != nil && b.Config().WalletConfig.Enabled { if b.walletSrvc != nil { if b.walletSrvc.IsStarted() { err := b.walletSrvc.Stop() diff --git a/services/local-notifications/core_test.go b/services/local-notifications/core_test.go index ad3a1840c..a6e1c33b5 100644 --- a/services/local-notifications/core_test.go +++ b/services/local-notifications/core_test.go @@ -30,7 +30,7 @@ func TestServiceStartStop(t *testing.T) { defer stop() s := NewService(db, 1777) - require.NoError(t, s.Start(nil)) + require.NoError(t, s.Start()) require.Equal(t, true, s.IsStarted()) require.NoError(t, s.Stop()) @@ -43,7 +43,7 @@ func TestWalletSubscription(t *testing.T) { feed := &event.Feed{} s := NewService(db, 1777) - require.NoError(t, s.Start(nil)) + require.NoError(t, s.Start()) require.Equal(t, true, s.IsStarted()) require.NoError(t, s.SubscribeWallet(feed)) @@ -67,7 +67,7 @@ func TestTransactionNotification(t *testing.T) { defer stop() s := NewService(db, 1777) - require.NoError(t, s.Start(nil)) + require.NoError(t, s.Start()) require.Equal(t, true, s.IsStarted()) var signalEvent []byte diff --git a/services/typeddata/eip712example/example.go b/services/typeddata/eip712example/example.go deleted file mode 100644 index a6bff7b7a..000000000 --- a/services/typeddata/eip712example/example.go +++ /dev/null @@ -1,247 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package eip712example - -import ( - "strings" - - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" -) - -// ExampleABI is the input ABI used to generate the binding from. -const ExampleABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"MAIL\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"v\",\"type\":\"uint8\"},{\"name\":\"r\",\"type\":\"bytes32\"},{\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"verify\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]" - -// ExampleBin is the compiled bytecode used for deploying new contracts. -const ExampleBin = `0x60036101208181527f436f77000000000000000000000000000000000000000000000000000000000061014090815260e091825273cd2a3d9f938e13cd947ec05abc7fe734df8dd8266101005260808281526101a08481527f426f6200000000000000000000000000000000000000000000000000000000006101c05261016090815273bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb6101805260a052610220604052600b6101e09081527f48656c6c6f2c20426f62210000000000000000000000000000000000000000006102005260c05292600092918391620000e8918391620008eb565b506020918201516001919091018054600160a060020a031916600160a060020a03909216919091179055828101518051805191926002850192620001309284920190620008eb565b506020918201516001919091018054600160a060020a031916600160a060020a0390921691909117905560408301518051620001739260048501920190620008eb565b5050503480156200018357600080fd5b506040805160c081018252600a608082019081527f4574686572204d61696c0000000000000000000000000000000000000000000060a083015281528151808301835260018082527f31000000000000000000000000000000000000000000000000000000000000006020838101919091528301919091529181019190915273cccccccccccccccccccccccccccccccccccccccc6060820152620002309064010000000062000463810204565b600555604080516000805460c06020601f60026101006001861615026000190190941693909304928301819004028401810190945260a083018181526200045a9484926060840192859284928491870182828015620002d35780601f10620002a757610100808354040283529160200191620002d3565b820191906000526020600020905b815481529060010190602001808311620002b557829003601f168201915b5050509183525050600191820154600160a060020a0316602091820152918352604080516002868101805461010095811615959095026000190190941604601f810185900485028201606090810184529282018181529590940194909384928491908401828280156200038a5780601f106200035e576101008083540402835291602001916200038a565b820191906000526020600020905b8154815290600101906020018083116200036c57829003601f168201915b5050509183525050600191820154600160a060020a031660209182015291835260048401805460408051600261010095841615959095026000190190921693909304601f810185900485028201850190935282815293830193929091908301828280156200043c5780601f1062000410576101008083540402835291602001916200043c565b820191906000526020600020905b8154815290600101906020018083116200041e57829003601f168201915b50505050508152505062000650640100000000026401000000009004565b60065562000990565b600060405180807f454950373132446f6d61696e28737472696e67206e616d652c737472696e672081526020017f76657273696f6e2c75696e7432353620636861696e49642c616464726573732081526020017f766572696679696e67436f6e74726163742900000000000000000000000000008152506052019050604051809103902082600001516040518082805190602001908083835b602083106200051d5780518252601f199092019160209182019101620004fc565b51815160209384036101000a6000190180199092169116179052604051919093018190038120888401518051919650945090928392508401908083835b602083106200057b5780518252601f1990920191602091820191016200055a565b51815160209384036101000a6000190180199092169116179052604080519290940182900382208a8501516060808d01518585019b909b5284870199909952978301526080820196909652600160a060020a0390961660a0808801919091528251808803909101815260c0909601918290525084519093849350850191508083835b602083106200061e5780518252601f199092019160209182019101620005fd565b5181516020939093036101000a6000190180199091169216919091179052604051920182900390912095945050505050565b604080517f4d61696c28506572736f6e2066726f6d2c506572736f6e20746f2c737472696e81527f6720636f6e74656e747329506572736f6e28737472696e67206e616d652c616460208201527f64726573732077616c6c6574290000000000000000000000000000000000000081830152905190819003604d019020815160009190620006e790640100000000620007c5810204565b620007058460200151620007c5640100000000026401000000009004565b84604001516040518082805190602001908083835b602083106200073b5780518252601f1990920191602091820191016200071a565b51815160001960209485036101000a019081169019919091161790526040805194909201849003842084820199909952838201979097526060830195909552506080808201969096528351808203909601865260a00192839052505082519091829190840190808383602083106200061e5780518252601f199092019160209182019101620005fd565b600060405180807f506572736f6e28737472696e67206e616d652c616464726573732077616c6c6581526020017f74290000000000000000000000000000000000000000000000000000000000008152506022019050604051809103902082600001516040518082805190602001908083835b60208310620008595780518252601f19909201916020918201910162000838565b51815160001960209485036101000a0190811690199190911617905260408051949092018490038420898201518583019890985284830152600160a060020a0390961660608085019190915281518085039091018152608090930190819052825192959094508493508501919050808383602083106200061e5780518252601f199092019160209182019101620005fd565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200092e57805160ff19168380011785556200095e565b828001600101855582156200095e579182015b828111156200095e57825182559160200191906001019062000941565b506200096c92915062000970565b5090565b6200098d91905b808211156200096c576000815560010162000977565b90565b61072180620009a06000396000f3006080604052600436106100565763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633644e515811461005b57806387d093da14610082578063e245452214610097575b600080fd5b34801561006757600080fd5b506100706100cc565b60408051918252519081900360200190f35b34801561008e57600080fd5b506100706100d2565b3480156100a357600080fd5b506100b860ff600435166024356044356100d8565b604080519115158252519081900360200190f35b60055481565b60065481565b600554604080516000805460c06020601f60026000196101006001871615020190941693909304928301819004028401810190945260a0830181815291948594909361030a939092869284926060840192859284929184918701828280156101815780601f1061015657610100808354040283529160200191610181565b820191906000526020600020905b81548152906001019060200180831161016457829003601f168201915b505050918352505060019182015473ffffffffffffffffffffffffffffffffffffffff16602091820152918352604080516002868101805461010095811615959095026000190190941604601f810185900485028201606090810184529282018181529590940194909384928491908401828280156102415780601f1061021657610100808354040283529160200191610241565b820191906000526020600020905b81548152906001019060200180831161022457829003601f168201915b505050918352505060019182015473ffffffffffffffffffffffffffffffffffffffff1660209182015291835260048401805460408051600261010095841615959095026000190190921693909304601f810185900485028201850190935282815293830193929091908301828280156102fc5780601f106102d1576101008083540402835291602001916102fc565b820191906000526020600020905b8154815290600101906020018083116102df57829003601f168201915b50505050508152505061043e565b604080517f19010000000000000000000000000000000000000000000000000000000000006020808301919091526022820194909452604280820193909352815180820390930183526062019081905281519192909182918401908083835b602083106103885780518252601f199092019160209182019101610369565b51815160209384036101000a600019018019909216911617905260408051929094018290038220600080845283830180875282905260ff8d1684870152606084018c9052608084018b905294519097503396506001955060a080840195929450601f198201938290030191865af1158015610407573d6000803e3d6000fd5b5050506020604051035173ffffffffffffffffffffffffffffffffffffffff1614151561043357600080fd5b506001949350505050565b604080517f4d61696c28506572736f6e2066726f6d2c506572736f6e20746f2c737472696e81527f6720636f6e74656e747329506572736f6e28737472696e67206e616d652c616460208201527f64726573732077616c6c6574290000000000000000000000000000000000000081830152905190819003604d0190208151600091906104ca906105c6565b6104d784602001516105c6565b84604001516040518082805190602001908083835b6020831061050b5780518252601f1990920191602091820191016104ec565b51815160001960209485036101000a019081169019919091161790526040805194909201849003842084820199909952838201979097526060830195909552506080808201969096528351808203909601865260a001928390525050825190918291908401908083835b602083106105945780518252601f199092019160209182019101610575565b5181516020939093036101000a6000190180199091169216919091179052604051920182900390912095945050505050565b600060405180807f506572736f6e28737472696e67206e616d652c616464726573732077616c6c6581526020017f74290000000000000000000000000000000000000000000000000000000000008152506022019050604051809103902082600001516040518082805190602001908083835b602083106106585780518252601f199092019160209182019101610639565b51815160001960209485036101000a019081169019919091161790526040805194909201849003842089820151858301989098528483015273ffffffffffffffffffffffffffffffffffffffff90961660608085019190915281518085039091018152608090930190819052825192959094508493508501919050808383602083106105945780518252601f1990920191602091820191016105755600a165627a7a723058207bf5da9df54e2af341db2c954e10c236cac514fb0c6cf892cd4c7e0d609d7ee70029` - -// DeployExample deploys a new Ethereum contract, binding an instance of Example to it. -func DeployExample(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Example, error) { - parsed, err := abi.JSON(strings.NewReader(ExampleABI)) - if err != nil { - return common.Address{}, nil, nil, err - } - address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(ExampleBin), backend) - if err != nil { - return common.Address{}, nil, nil, err - } - return address, tx, &Example{ExampleCaller: ExampleCaller{contract: contract}, ExampleTransactor: ExampleTransactor{contract: contract}, ExampleFilterer: ExampleFilterer{contract: contract}}, nil -} - -// Example is an auto generated Go binding around an Ethereum contract. -type Example struct { - ExampleCaller // Read-only binding to the contract - ExampleTransactor // Write-only binding to the contract - ExampleFilterer // Log filterer for contract events -} - -// ExampleCaller is an auto generated read-only Go binding around an Ethereum contract. -type ExampleCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ExampleTransactor is an auto generated write-only Go binding around an Ethereum contract. -type ExampleTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ExampleFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type ExampleFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ExampleSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type ExampleSession struct { - Contract *Example // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// ExampleCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type ExampleCallerSession struct { - Contract *ExampleCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// ExampleTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type ExampleTransactorSession struct { - Contract *ExampleTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// ExampleRaw is an auto generated low-level Go binding around an Ethereum contract. -type ExampleRaw struct { - Contract *Example // Generic contract binding to access the raw methods on -} - -// ExampleCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type ExampleCallerRaw struct { - Contract *ExampleCaller // Generic read-only contract binding to access the raw methods on -} - -// ExampleTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type ExampleTransactorRaw struct { - Contract *ExampleTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewExample creates a new instance of Example, bound to a specific deployed contract. -func NewExample(address common.Address, backend bind.ContractBackend) (*Example, error) { - contract, err := bindExample(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &Example{ExampleCaller: ExampleCaller{contract: contract}, ExampleTransactor: ExampleTransactor{contract: contract}, ExampleFilterer: ExampleFilterer{contract: contract}}, nil -} - -// NewExampleCaller creates a new read-only instance of Example, bound to a specific deployed contract. -func NewExampleCaller(address common.Address, caller bind.ContractCaller) (*ExampleCaller, error) { - contract, err := bindExample(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &ExampleCaller{contract: contract}, nil -} - -// NewExampleTransactor creates a new write-only instance of Example, bound to a specific deployed contract. -func NewExampleTransactor(address common.Address, transactor bind.ContractTransactor) (*ExampleTransactor, error) { - contract, err := bindExample(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &ExampleTransactor{contract: contract}, nil -} - -// NewExampleFilterer creates a new log filterer instance of Example, bound to a specific deployed contract. -func NewExampleFilterer(address common.Address, filterer bind.ContractFilterer) (*ExampleFilterer, error) { - contract, err := bindExample(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &ExampleFilterer{contract: contract}, nil -} - -// bindExample binds a generic wrapper to an already deployed contract. -func bindExample(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(ExampleABI)) - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_Example *ExampleRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { - return _Example.Contract.ExampleCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_Example *ExampleRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _Example.Contract.ExampleTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_Example *ExampleRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _Example.Contract.ExampleTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_Example *ExampleCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { - return _Example.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_Example *ExampleTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _Example.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_Example *ExampleTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _Example.Contract.contract.Transact(opts, method, params...) -} - -// DOMAINSEPARATOR is a free data retrieval call binding the contract method 0x3644e515. -// -// Solidity: function DOMAIN_SEPARATOR() constant returns(bytes32) -func (_Example *ExampleCaller) DOMAINSEPARATOR(opts *bind.CallOpts) ([32]byte, error) { - var ( - ret0 = new([32]byte) - ) - out := ret0 - err := _Example.contract.Call(opts, out, "DOMAIN_SEPARATOR") - return *ret0, err -} - -// DOMAINSEPARATOR is a free data retrieval call binding the contract method 0x3644e515. -// -// Solidity: function DOMAIN_SEPARATOR() constant returns(bytes32) -func (_Example *ExampleSession) DOMAINSEPARATOR() ([32]byte, error) { - return _Example.Contract.DOMAINSEPARATOR(&_Example.CallOpts) -} - -// DOMAINSEPARATOR is a free data retrieval call binding the contract method 0x3644e515. -// -// Solidity: function DOMAIN_SEPARATOR() constant returns(bytes32) -func (_Example *ExampleCallerSession) DOMAINSEPARATOR() ([32]byte, error) { - return _Example.Contract.DOMAINSEPARATOR(&_Example.CallOpts) -} - -// MAIL is a free data retrieval call binding the contract method 0x87d093da. -// -// Solidity: function MAIL() constant returns(bytes32) -func (_Example *ExampleCaller) MAIL(opts *bind.CallOpts) ([32]byte, error) { - var ( - ret0 = new([32]byte) - ) - out := ret0 - err := _Example.contract.Call(opts, out, "MAIL") - return *ret0, err -} - -// MAIL is a free data retrieval call binding the contract method 0x87d093da. -// -// Solidity: function MAIL() constant returns(bytes32) -func (_Example *ExampleSession) MAIL() ([32]byte, error) { - return _Example.Contract.MAIL(&_Example.CallOpts) -} - -// MAIL is a free data retrieval call binding the contract method 0x87d093da. -// -// Solidity: function MAIL() constant returns(bytes32) -func (_Example *ExampleCallerSession) MAIL() ([32]byte, error) { - return _Example.Contract.MAIL(&_Example.CallOpts) -} - -// Verify is a paid mutator transaction binding the contract method 0xe2454522. -// -// Solidity: function verify(v uint8, r bytes32, s bytes32) returns(bool) -func (_Example *ExampleTransactor) Verify(opts *bind.TransactOpts, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _Example.contract.Transact(opts, "verify", v, r, s) -} - -// Verify is a paid mutator transaction binding the contract method 0xe2454522. -// -// Solidity: function verify(v uint8, r bytes32, s bytes32) returns(bool) -func (_Example *ExampleSession) Verify(v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _Example.Contract.Verify(&_Example.TransactOpts, v, r, s) -} - -// Verify is a paid mutator transaction binding the contract method 0xe2454522. -// -// Solidity: function verify(v uint8, r bytes32, s bytes32) returns(bool) -func (_Example *ExampleTransactorSession) Verify(v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _Example.Contract.Verify(&_Example.TransactOpts, v, r, s) -} diff --git a/services/typeddata/eip712example/example.sol b/services/typeddata/eip712example/example.sol index 8801799b7..790678485 100644 --- a/services/typeddata/eip712example/example.sol +++ b/services/typeddata/eip712example/example.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.8.0; contract Example { @@ -58,7 +58,7 @@ contract Example { MAIL = hash(mail); } - function hash(EIP712Domain eip712Domain) internal pure returns (bytes32) { + function hash(EIP712Domain memory eip712Domain) internal pure returns (bytes32) { return keccak256(abi.encode( EIP712DOMAIN_TYPEHASH, keccak256(bytes(eip712Domain.name)), @@ -68,7 +68,7 @@ contract Example { )); } - function hash(Person person) internal pure returns (bytes32) { + function hash(Person memory person) internal pure returns (bytes32) { return keccak256(abi.encode( PERSON_TYPEHASH, keccak256(bytes(person.name)), @@ -76,12 +76,12 @@ contract Example { )); } - function hash(Mail mail) internal pure returns (bytes32) { + function hash(Mail memory m) internal pure returns (bytes32) { return keccak256(abi.encode( MAIL_TYPEHASH, - hash(mail.from), - hash(mail.to), - keccak256(bytes(mail.contents)) + hash(m.from), + hash(m.to), + keccak256(bytes(m.contents)) )); } diff --git a/services/typeddata/hash_test.go b/services/typeddata/hash_test.go index f77a3aa42..cfcc6517a 100644 --- a/services/typeddata/hash_test.go +++ b/services/typeddata/hash_test.go @@ -74,9 +74,9 @@ func TestEncodeData(t *testing.T) { result func(testCase) common.Hash } - bytes32, _ := abi.NewType("bytes32", nil) - addr, _ := abi.NewType("address", nil) - boolT, _ := abi.NewType("bool", nil) + bytes32, _ := abi.NewType("bytes32", "", nil) + addr, _ := abi.NewType("address", "", nil) + boolT, _ := abi.NewType("bool", "", nil) for _, tc := range []testCase{ { @@ -177,8 +177,8 @@ func TestEncodeData(t *testing.T) { }}, "A", func(tc testCase) common.Hash { - intBig, _ := abi.NewType("int128", nil) - uintBig, _ := abi.NewType("uint128", nil) + intBig, _ := abi.NewType("int128", "", nil) + uintBig, _ := abi.NewType("uint128", "", nil) args := abi.Arguments{{Type: bytes32}, {Type: intBig}, {Type: intBig}, {Type: uintBig}, {Type: uintBig}} typehash := typeHash(tc.target, tc.types) diff --git a/services/typeddata/sign_test.go b/services/typeddata/sign_test.go index f0e0a14b6..e78ef4692 100644 --- a/services/typeddata/sign_test.go +++ b/services/typeddata/sign_test.go @@ -1,21 +1,11 @@ package typeddata import ( - "context" "encoding/json" - "math" "math/big" "testing" "github.com/stretchr/testify/require" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" - "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - - "github.com/status-im/status-go/services/typeddata/eip712example" ) var ( @@ -60,96 +50,3 @@ func TestChainIDValidation(t *testing.T) { }) } } - -func TestInteroparableWithSolidity(t *testing.T) { - key, _ := crypto.GenerateKey() - testaddr := crypto.PubkeyToAddress(key.PublicKey) - genesis := core.GenesisAlloc{ - testaddr: {Balance: new(big.Int).SetInt64(math.MaxInt64)}, - } - backend := backends.NewSimulatedBackend(genesis, math.MaxInt64) - opts := bind.NewKeyedTransactor(key) - _, _, example, err := eip712example.DeployExample(opts, backend) - require.NoError(t, err) - backend.Commit() - - domainSol, err := example.DOMAINSEPARATOR(nil) - require.NoError(t, err) - mailSol, err := example.MAIL(nil) - require.NoError(t, err) - - mytypes := Types{ - eip712Domain: []Field{ - {Name: "name", Type: "string"}, - {Name: "version", Type: "string"}, - {Name: "chainId", Type: "uint256"}, - {Name: "verifyingContract", Type: "address"}, - }, - "Person": []Field{ - {Name: "name", Type: "string"}, - {Name: "wallet", Type: "address"}, - }, - "Mail": []Field{ - {Name: "from", Type: "Person"}, - {Name: "to", Type: "Person"}, - {Name: "contents", Type: "string"}, - }, - } - domain := map[string]json.RawMessage{ - "name": json.RawMessage(`"Ether Mail"`), - "version": json.RawMessage(`"1"`), - "chainId": json.RawMessage("1"), - "verifyingContract": json.RawMessage(`"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"`), - } - domainChainIDAsString := map[string]json.RawMessage{ - "name": json.RawMessage(`"Ether Mail"`), - "version": json.RawMessage(`"1"`), - "chainId": json.RawMessage(`"1"`), - "verifyingContract": json.RawMessage(`"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"`), - } - msg := map[string]json.RawMessage{ - "from": json.RawMessage(fromWallet), - "to": json.RawMessage(toWallet), - "contents": json.RawMessage(`"Hello, Bob!"`), - } - typed := TypedData{ - Types: mytypes, - PrimaryType: "Mail", - Domain: domain, - Message: msg, - } - typedChainIDAsString := TypedData{ - Types: mytypes, - PrimaryType: "Mail", - Domain: domainChainIDAsString, - Message: msg, - } - - domainHash, err := hashStruct(eip712Domain, typed.Domain, typed.Types) - require.NoError(t, err) - require.Equal(t, domainSol[:], domainHash[:]) - - mailHash, err := hashStruct(typed.PrimaryType, typed.Message, typed.Types) - require.NoError(t, err) - require.Equal(t, mailSol[:], mailHash[:]) - - signature, err := Sign(typed, key, big.NewInt(1)) - require.NoError(t, err) - require.Len(t, signature, 65) - - signature2, err := Sign(typedChainIDAsString, key, big.NewInt(1)) - require.NoError(t, err) - require.Equal(t, signature, signature2) - - r := [32]byte{} - copy(r[:], signature[:32]) - s := [32]byte{} - copy(s[:], signature[32:64]) - v := signature[64] - tx, err := example.Verify(opts, v, r, s) - require.NoError(t, err) - backend.Commit() - receipt, err := bind.WaitMined(context.TODO(), backend, tx) - require.NoError(t, err) - require.Equal(t, types.ReceiptStatusSuccessful, receipt.Status) -} diff --git a/services/wallet/erc20/README.md b/services/wallet/erc20/README.md deleted file mode 100644 index ac7a47c5c..000000000 --- a/services/wallet/erc20/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Test contract for Transfer events -================================= - -Emits transfer event defined by ERC20 standart. \ No newline at end of file diff --git a/services/wallet/erc20/doc.go b/services/wallet/erc20/doc.go deleted file mode 100644 index 4d6a26e5b..000000000 --- a/services/wallet/erc20/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -package erc20 - -//go:generate abigen -sol erc20.sol -pkg erc20 -out erc20.go diff --git a/services/wallet/erc20/erc20.go b/services/wallet/erc20/erc20.go deleted file mode 100644 index 2c8e6d201..000000000 --- a/services/wallet/erc20/erc20.go +++ /dev/null @@ -1,404 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package erc20 - -import ( - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = abi.U256 - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription -) - -// ERC20TransferABI is the input ABI used to generate the binding from. -const ERC20TransferABI = "[{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"balances\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}]" - -// ERC20TransferBin is the compiled bytecode used for deploying new contracts. -const ERC20TransferBin = `0x608060405234801561001057600080fd5b50610181806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806327e235e31461004657806370a082311461007e578063a9059cbb146100a4575b600080fd5b61006c6004803603602081101561005c57600080fd5b50356001600160a01b03166100d2565b60408051918252519081900360200190f35b61006c6004803603602081101561009457600080fd5b50356001600160a01b03166100e4565b6100d0600480360360408110156100ba57600080fd5b506001600160a01b0381351690602001356100ff565b005b60006020819052908152604090205481565b6001600160a01b031660009081526020819052604090205490565b6001600160a01b038216600081815260208181526040918290208054850190558151848152915133927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92908290030190a3505056fea165627a7a72305820ce4a8618526aef925c173a7501883068de371638ddfe96d61116807d93bf0e010029` - -// DeployERC20Transfer deploys a new Ethereum contract, binding an instance of ERC20Transfer to it. -func DeployERC20Transfer(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *ERC20Transfer, error) { - parsed, err := abi.JSON(strings.NewReader(ERC20TransferABI)) - if err != nil { - return common.Address{}, nil, nil, err - } - address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(ERC20TransferBin), backend) - if err != nil { - return common.Address{}, nil, nil, err - } - return address, tx, &ERC20Transfer{ERC20TransferCaller: ERC20TransferCaller{contract: contract}, ERC20TransferTransactor: ERC20TransferTransactor{contract: contract}, ERC20TransferFilterer: ERC20TransferFilterer{contract: contract}}, nil -} - -// ERC20Transfer is an auto generated Go binding around an Ethereum contract. -type ERC20Transfer struct { - ERC20TransferCaller // Read-only binding to the contract - ERC20TransferTransactor // Write-only binding to the contract - ERC20TransferFilterer // Log filterer for contract events -} - -// ERC20TransferCaller is an auto generated read-only Go binding around an Ethereum contract. -type ERC20TransferCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ERC20TransferTransactor is an auto generated write-only Go binding around an Ethereum contract. -type ERC20TransferTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ERC20TransferFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type ERC20TransferFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ERC20TransferSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type ERC20TransferSession struct { - Contract *ERC20Transfer // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// ERC20TransferCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type ERC20TransferCallerSession struct { - Contract *ERC20TransferCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// ERC20TransferTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type ERC20TransferTransactorSession struct { - Contract *ERC20TransferTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// ERC20TransferRaw is an auto generated low-level Go binding around an Ethereum contract. -type ERC20TransferRaw struct { - Contract *ERC20Transfer // Generic contract binding to access the raw methods on -} - -// ERC20TransferCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type ERC20TransferCallerRaw struct { - Contract *ERC20TransferCaller // Generic read-only contract binding to access the raw methods on -} - -// ERC20TransferTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type ERC20TransferTransactorRaw struct { - Contract *ERC20TransferTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewERC20Transfer creates a new instance of ERC20Transfer, bound to a specific deployed contract. -func NewERC20Transfer(address common.Address, backend bind.ContractBackend) (*ERC20Transfer, error) { - contract, err := bindERC20Transfer(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &ERC20Transfer{ERC20TransferCaller: ERC20TransferCaller{contract: contract}, ERC20TransferTransactor: ERC20TransferTransactor{contract: contract}, ERC20TransferFilterer: ERC20TransferFilterer{contract: contract}}, nil -} - -// NewERC20TransferCaller creates a new read-only instance of ERC20Transfer, bound to a specific deployed contract. -func NewERC20TransferCaller(address common.Address, caller bind.ContractCaller) (*ERC20TransferCaller, error) { - contract, err := bindERC20Transfer(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &ERC20TransferCaller{contract: contract}, nil -} - -// NewERC20TransferTransactor creates a new write-only instance of ERC20Transfer, bound to a specific deployed contract. -func NewERC20TransferTransactor(address common.Address, transactor bind.ContractTransactor) (*ERC20TransferTransactor, error) { - contract, err := bindERC20Transfer(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &ERC20TransferTransactor{contract: contract}, nil -} - -// NewERC20TransferFilterer creates a new log filterer instance of ERC20Transfer, bound to a specific deployed contract. -func NewERC20TransferFilterer(address common.Address, filterer bind.ContractFilterer) (*ERC20TransferFilterer, error) { - contract, err := bindERC20Transfer(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &ERC20TransferFilterer{contract: contract}, nil -} - -// bindERC20Transfer binds a generic wrapper to an already deployed contract. -func bindERC20Transfer(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(ERC20TransferABI)) - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_ERC20Transfer *ERC20TransferRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { - return _ERC20Transfer.Contract.ERC20TransferCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_ERC20Transfer *ERC20TransferRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ERC20Transfer.Contract.ERC20TransferTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_ERC20Transfer *ERC20TransferRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _ERC20Transfer.Contract.ERC20TransferTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_ERC20Transfer *ERC20TransferCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { - return _ERC20Transfer.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_ERC20Transfer *ERC20TransferTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ERC20Transfer.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_ERC20Transfer *ERC20TransferTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _ERC20Transfer.Contract.contract.Transact(opts, method, params...) -} - -// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. -// -// Solidity: function balanceOf(address account) constant returns(uint256) -func (_ERC20Transfer *ERC20TransferCaller) BalanceOf(opts *bind.CallOpts, account common.Address) (*big.Int, error) { - var ( - ret0 = new(*big.Int) - ) - out := ret0 - err := _ERC20Transfer.contract.Call(opts, out, "balanceOf", account) - return *ret0, err -} - -// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. -// -// Solidity: function balanceOf(address account) constant returns(uint256) -func (_ERC20Transfer *ERC20TransferSession) BalanceOf(account common.Address) (*big.Int, error) { - return _ERC20Transfer.Contract.BalanceOf(&_ERC20Transfer.CallOpts, account) -} - -// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. -// -// Solidity: function balanceOf(address account) constant returns(uint256) -func (_ERC20Transfer *ERC20TransferCallerSession) BalanceOf(account common.Address) (*big.Int, error) { - return _ERC20Transfer.Contract.BalanceOf(&_ERC20Transfer.CallOpts, account) -} - -// Balances is a free data retrieval call binding the contract method 0x27e235e3. -// -// Solidity: function balances(address ) constant returns(uint256) -func (_ERC20Transfer *ERC20TransferCaller) Balances(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) { - var ( - ret0 = new(*big.Int) - ) - out := ret0 - err := _ERC20Transfer.contract.Call(opts, out, "balances", arg0) - return *ret0, err -} - -// Balances is a free data retrieval call binding the contract method 0x27e235e3. -// -// Solidity: function balances(address ) constant returns(uint256) -func (_ERC20Transfer *ERC20TransferSession) Balances(arg0 common.Address) (*big.Int, error) { - return _ERC20Transfer.Contract.Balances(&_ERC20Transfer.CallOpts, arg0) -} - -// Balances is a free data retrieval call binding the contract method 0x27e235e3. -// -// Solidity: function balances(address ) constant returns(uint256) -func (_ERC20Transfer *ERC20TransferCallerSession) Balances(arg0 common.Address) (*big.Int, error) { - return _ERC20Transfer.Contract.Balances(&_ERC20Transfer.CallOpts, arg0) -} - -// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. -// -// Solidity: function transfer(address to, uint256 value) returns() -func (_ERC20Transfer *ERC20TransferTransactor) Transfer(opts *bind.TransactOpts, to common.Address, value *big.Int) (*types.Transaction, error) { - return _ERC20Transfer.contract.Transact(opts, "transfer", to, value) -} - -// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. -// -// Solidity: function transfer(address to, uint256 value) returns() -func (_ERC20Transfer *ERC20TransferSession) Transfer(to common.Address, value *big.Int) (*types.Transaction, error) { - return _ERC20Transfer.Contract.Transfer(&_ERC20Transfer.TransactOpts, to, value) -} - -// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. -// -// Solidity: function transfer(address to, uint256 value) returns() -func (_ERC20Transfer *ERC20TransferTransactorSession) Transfer(to common.Address, value *big.Int) (*types.Transaction, error) { - return _ERC20Transfer.Contract.Transfer(&_ERC20Transfer.TransactOpts, to, value) -} - -// ERC20TransferTransferIterator is returned from FilterTransfer and is used to iterate over the raw logs and unpacked data for Transfer events raised by the ERC20Transfer contract. -type ERC20TransferTransferIterator struct { - Event *ERC20TransferTransfer // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *ERC20TransferTransferIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(ERC20TransferTransfer) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(ERC20TransferTransfer) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *ERC20TransferTransferIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *ERC20TransferTransferIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// ERC20TransferTransfer represents a Transfer event raised by the ERC20Transfer contract. -type ERC20TransferTransfer struct { - From common.Address - To common.Address - Value *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterTransfer is a free log retrieval operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. -// -// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) -func (_ERC20Transfer *ERC20TransferFilterer) FilterTransfer(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*ERC20TransferTransferIterator, error) { - - var fromRule []interface{} - for _, fromItem := range from { - fromRule = append(fromRule, fromItem) - } - var toRule []interface{} - for _, toItem := range to { - toRule = append(toRule, toItem) - } - - logs, sub, err := _ERC20Transfer.contract.FilterLogs(opts, "Transfer", fromRule, toRule) - if err != nil { - return nil, err - } - return &ERC20TransferTransferIterator{contract: _ERC20Transfer.contract, event: "Transfer", logs: logs, sub: sub}, nil -} - -// WatchTransfer is a free log subscription operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. -// -// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) -func (_ERC20Transfer *ERC20TransferFilterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *ERC20TransferTransfer, from []common.Address, to []common.Address) (event.Subscription, error) { - - var fromRule []interface{} - for _, fromItem := range from { - fromRule = append(fromRule, fromItem) - } - var toRule []interface{} - for _, toItem := range to { - toRule = append(toRule, toItem) - } - - logs, sub, err := _ERC20Transfer.contract.WatchLogs(opts, "Transfer", fromRule, toRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(ERC20TransferTransfer) - if err := _ERC20Transfer.contract.UnpackLog(event, "Transfer", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} diff --git a/services/wallet/erc20/erc20.sol b/services/wallet/erc20/erc20.sol deleted file mode 100644 index 08dad1fc1..000000000 --- a/services/wallet/erc20/erc20.sol +++ /dev/null @@ -1,19 +0,0 @@ -pragma solidity ^0.5.0; - -contract ERC20Transfer { - - mapping (address => uint256) public balances; - - constructor() public {} - - event Transfer(address indexed from, address indexed to, uint256 value); - - function transfer(address to, uint256 value) public { - balances[to] += value; - emit Transfer(msg.sender, to, value); - } - - function balanceOf(address account) public view returns (uint256) { - return balances[account]; - } -}