Commit graph

12663 commits

Author SHA1 Message Date
Daniel Liu
321bcff620 accounts/usbwallet, signer/core: show accounts from ledger legacy derivation paths (#21517)
* accounts/usbwallet, signer/core: un-hide accounts from ledger legacy derivation paths

* Update accounts/usbwallet/wallet.go

* Update signer/core/api.go

* Update signer/core/api.go
2025-01-24 16:18:29 +08:00
Daniel Liu
c9643e9c90 accounts/abi/bind/backends: clean doc errors (#21514) 2025-01-24 16:18:29 +08:00
Daniel Liu
f4feaebb40 accounts/abi: fix a bug in getTypeSize method (#21501)
* accounts/abi: fix a bug in getTypeSize method

e.g. for "Tuple[2]" type, the element of the array is a tuple type and the size of the tuple may not be 32.

* accounts/abi: add unit test of getTypeSize method
2025-01-24 16:18:29 +08:00
Daniel Liu
089242bb39 accounts/abi/bind/backends: Disallow AdjustTime for non-empty blocks (#21334) 2025-01-24 16:18:29 +08:00
Daniel Liu
25d42fef2c accounts/abi: make GetType public again (#21157) 2025-01-24 16:18:29 +08:00
Daniel Liu
9c5dff2554 accounts/keystore: fix typo in error message (#21200) 2025-01-24 16:18:29 +08:00
Daniel Liu
593fe53519 internal/ethapi: return revert reason for eth_call (#21083) 2025-01-24 16:18:29 +08:00
Daniel Liu
ef80645f90 accounts/abi/bind: fix test 2025-01-24 16:18:29 +08:00
Daniel Liu
5e3755c46a accounts/keystore, cmd/faucet: return old account to allow unlock (#21173) 2025-01-24 16:18:29 +08:00
Daniel Liu
d918e53c8a acounts/keystore, cmd/faucet: fix faucet double import (#21172) 2025-01-24 16:18:29 +08:00
Daniel Liu
afc814b00d accounts: fix typos in comments (#21118) 2025-01-24 16:18:29 +08:00
Daniel Liu
e28727e2c9 accounts: add blockByNumberNoLock() to avoid double-lock (#20983)
* abi/bind/backends: testcase for double-lock

* accounts: add blockByNumberNoLock to avoid double-lock

* backend/simulated: use stateroot, not blockhash for retrieveing state

Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-01-24 16:18:29 +08:00
Daniel Liu
b9bcf17694 accounts/abi: simplify reflection logic (#21058)
* accounts/abi: simplified reflection logic

* accounts/abi: simplified reflection logic

* accounts/abi: removed unpack

* accounts/abi: removed comments

* accounts/abi: removed uneccessary complications

* accounts/abi: minor changes in error messages

* accounts/abi: removed unnused code

* accounts/abi: fixed indexed argument unpacking

* accounts/abi: removed superfluous test cases

This commit removes two test cases. The first one is trivially invalid as we have the same
test cases as passing in packing_test.go L375. The second one passes now,
because we don't need the mapArgNamesToStructFields in unpack_atomic anymore.
Checking for purely underscored arg names generally should not be something we do
as the abi/contract is generally out of the control of the user.

* accounts/abi: removed comments, debug println

* accounts/abi: added commented out code

* accounts/abi: addressed comments

* accounts/abi: remove unnecessary dst.CanSet check

* accounts/abi: added dst.CanSet checks
2025-01-24 16:18:29 +08:00
Daniel Liu
e836f32ba4 accounts/abi: allow overloaded argument names (#21060)
* accounts/abi: allow overloaded argument names

In solidity it is possible to create the following contract:
```
contract Overloader {
    struct F { uint _f; uint __f; uint f; }
    function f(F memory f) public {}
}
```
This however resulted in a panic in the abi package.

* accounts/abi fixed error handling
2025-01-24 16:18:29 +08:00
Daniel Liu
7e3079cedc accounts/abi: move topics to abi package (#21057)
* accounts/abi/bind: added test cases for waitDeployed

* accounts/abi/bind: added test case for boundContract

* accounts/abi/bind: removed unnecessary resolve methods

* accounts/abi: moved topics from /bind to /abi

* accounts/abi/bind: cleaned up format... functions

* accounts/abi: improved log message

* accounts/abi: added type tests

* accounts/abi/bind: remove superfluous template methods
2025-01-24 16:18:29 +08:00
Daniel Liu
f6b6a24093 account/abi: remove superfluous type checking (#21022)
* accounts/abi: added getType func to Type struct

* accounts/abi: fixed tuple unpack

* accounts/abi: removed type.Type

* accounts/abi: added comment

* accounts/abi: removed unused types

* accounts/abi: removed superfluous declarations

* accounts/abi: typo
2025-01-24 16:18:29 +08:00
Daniel Liu
dabda3335a accounts/abi: removed Kind from Type struct (#21009)
* accounts/abi: removed Kind from Type struct

* accounts/abi: removed unused code
2025-01-24 16:18:29 +08:00
Daniel Liu
bca20a692a accounts/abi: added abi test cases, minor bug fixes (#20903)
* accounts/abi: added documentation

* accounts/abi: reduced usage of arguments.LengthNonIndexed

* accounts/abi: simplified reflection logic

* accounts/abi: moved testjson data into global declaration

* accounts/abi: removed duplicate test cases

* accounts/abi: reworked abi tests

* accounts/abi: added more tests for abi packing

* accounts/abi/bind: refactored base tests

* accounts/abi: run pack tests as subtests

* accounts/abi: removed duplicate tests

* accounts/abi: removed unnused arguments.LengthNonIndexed

Due to refactors to the code, we do not need the arguments.LengthNonIndexed function anymore.
You can still get the length by calling len(arguments.NonIndexed())

* accounts/abi: added type test

* accounts/abi: modified unpack test to pack test

* accounts/abi: length check on arrayTy

* accounts/abi: test invalid abi

* accounts/abi: fixed rebase error

* accounts/abi: fixed rebase errors

* accounts/abi: removed unused definition

* accounts/abi: merged packing/unpacking tests

* accounts/abi: fixed [][][32]bytes encoding

* accounts/abi: added tuple test cases

* accounts/abi: renamed getMockLog -> newMockLog

* accounts/abi: removed duplicate test

* accounts/abi: bools -> booleans
2025-01-24 16:18:29 +08:00
Daniel Liu
0d1cd42dc2 accounts/keystore: fix double import race (#20915)
* accounts/keystore: fix race in Import/ImportECDSA

* accounts/keystore: added import/export tests

* cmd/geth: improved TestAccountImport test

* accounts/keystore: added import/export tests

* accounts/keystore: fixed naming

* accounts/keystore: fixed typo

* accounts/keystore: use mutex instead of rwmutex

* accounts: use errors instead of fmt
2025-01-24 16:18:29 +08:00
Daniel Liu
91f6259135 accounts/abi: remove function Unpack2 (#20830) 2025-01-24 16:18:29 +08:00
Daniel Liu
56f9c17817 accounts/abi: Prevent recalculation of internal fields (#20895)
* accounts/abi: prevent recalculation of ID, Sig and String

* accounts/abi: fixed unpacking of no values

* accounts/abi: multiple fixes to arguments

* accounts/abi: refactored methodName and eventName

This commit moves the complicated logic of how we assign method names
and event names if they already exist into their own functions for
better readability.

* accounts/abi: prevent recalculation of internal

In this commit, I changed the way we calculate the string
representations, sig representations and the id's of methods. Before
that these fields would be recalculated everytime someone called .Sig()
.String() or .ID() on a method or an event.

Additionally this commit fixes issue #20856 as we assign names to inputs
with no name (input with name "" becomes "arg0")

* accounts/abi: added unnamed event params test

* accounts/abi: fixed rebasing errors in method sig

* accounts/abi: fixed rebasing errors in method sig

* accounts/abi: addressed comments

* accounts/abi: added FunctionType enumeration

* accounts/abi/bind: added test for unnamed arguments

* accounts/abi: improved readability in NewMethod, nitpicks

* accounts/abi: method/eventName -> overloadedMethodName
2025-01-24 16:18:29 +08:00
Daniel Liu
fd53a433aa accounts/abi: implement new fallback functions (#20764)
* accounts/abi: implement new fackball functions

In Solidity v0.6.0, the original fallback is separated
into two different sub types: fallback and receive.

This PR addes the support for parsing new format abi
and the relevant abigen functionalities.

* accounts/abi: fix unit tests

* accounts/abi: minor fixes

* accounts/abi, mobile: support jave binding

* accounts/abi: address marius's comment

* accounts/abi: Work around the uin64 conversion issue

Co-authored-by: Guillaume Ballet <gballet@gmail.com>
2025-01-24 16:18:29 +08:00
Daniel Liu
296c052c02 accounts/abi/bind: fixed erroneous filtering of negative ints (#20865)
* accounts/abi/bind: fixed erroneous packing of negative ints

* accounts/abi/bind: added test cases for negative ints in topics

* accounts/abi/bind: fixed genIntType for go 1.12

* accounts/abi: minor  nitpick
2025-01-24 16:18:29 +08:00
Daniel Liu
f8b85afec5 accounts/abi/bind: Refactored topics (#20851)
* accounts/abi/bind: refactored topics

* accounts/abi/bind: use store function to remove code duplication

* accounts/abi/bind: removed unused type defs

* accounts/abi/bind: error on tuples in topics

* Cosmetic changes to restart travis build

Co-authored-by: Guillaume Ballet <gballet@gmail.com>
2025-01-24 16:18:29 +08:00
Daniel Liu
601d1c80ea accounts/scwallet: fix unnecessary use of fmt.Sprint 2025-01-24 16:18:29 +08:00
Daniel Liu
6259ce565c accounts/abi faster unpacking of int256 (#20850) 2025-01-24 16:18:29 +08:00
Daniel Liu
219b5ef883 accounts: add walletsNoLock to avoid double read lock (#20655) 2025-01-24 16:18:29 +08:00
Daniel Liu
164d929307 accounts/abi/bind/backends: add support for historical state (#20644) 2025-01-24 16:18:29 +08:00
Daniel Liu
8d4c290cce accounts/abi: fix method constant flag for solidity 6.0 (#20482) 2025-01-24 16:18:29 +08:00
Daniel Liu
0350880af6 accounts/abi/backends/simulated: add more API methods (#5) (#20208)
* Add more functionality to the sim (#5)

* backends: implement more of ethclient in sim

* backends: add BlockByNumber to simulated backend

* backends: make simulated progress function agree with syncprogress interface for client

* backends: add more tests

* backends: add more comments

* backends: fix sim for index in tx and add tests

* backends: add lock back to estimategas

* backends: goimports

* backends: go ci lint

* Add more functionality to the sim (#5)

* backends: implement more of ethclient in sim

* backends: add BlockByNumber to simulated backend

* backends: make simulated progress function agree with syncprogress interface for client

* backends: add more tests

* backends: add more comments

* backends: fix sim for index in tx and add tests

* backends: add lock back to estimategas

* backends: goimports

* backends: go ci lint

* assert errs
2025-01-24 16:18:29 +08:00
Daniel Liu
f7b66c10b3 [#20266] Fix bugs decoding integers and fixed bytes in indexed event fields (#20269)
* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
2025-01-24 16:18:29 +08:00
Daniel Liu
e9f9c19c52 accounts/abi/bind: fix destructive packing of *big.Int (#20412) 2025-01-24 16:18:29 +08:00
Daniel Liu
193ee6d606 accounts/usbwallet: fix staticcheck warnings (#20372) 2025-01-24 16:18:29 +08:00
Daniel Liu
db708e7697 accounts/scwallet: fix staticcheck warnings (#20370) 2025-01-24 16:18:29 +08:00
Daniel Liu
833c851361 accounts/keystore: fix staticcheck warnings (#20373)
* accounts/keystore: fix staticcheck warnings

* review feedback
2025-01-24 16:18:29 +08:00
Daniel Liu
f2fb9f8661 accounts/abi/bind: avoid reclaring structs (#20381) 2025-01-24 16:18:29 +08:00
Daniel Liu
eb628a4f02 accounts/abi: fix staticcheck warnings (#20358)
* accounts/abi: fix staticcheck warnings

* accounts/abi: restore unused field for test
2025-01-24 16:18:29 +08:00
Daniel Liu
575a5cb2e2 accounts/abi/bind/backends: remove unused assignment (#20359) 2025-01-24 16:18:29 +08:00
Daniel Liu
3a320d2c6f accounts/abi/bind, cmd/abigen: implement alias for abigen (#20244) 2025-01-24 16:18:29 +08:00
Daniel Liu
32615fda97 accounts/abi: add internalType information and fix issues (#20179)
* accounts/abi: fix various issues

The fixed issues include:

(1) If there is no return in a call function, unpack should
return nil error

(2) For some functions which have struct array as parameter,
it will also be detected and generate the struct definition

(3) For event, if it has non-indexed parameter, the parameter
name will also be assigned if empty. Also the internal struct
will be detected and generate struct defition if not exist.

(4) Fix annotation generation in event function

* accounts/abi: add new abi field internalType

* accounts: address comments and add tests

* accounts/abi: replace strings.ReplaceAll with strings.Replace
2025-01-24 16:18:29 +08:00
Daniel Liu
e90df44b43 accounts: replace passPHRASE with passWORD in any user interactions (#19932) 2025-01-24 16:18:29 +08:00
Daniel Liu
6a7b539c0e accounts, internal/ethapi: use common Accounts method (#18428)
* accounts/mananger, internal/ethapi/api: Add new function AllAccounts on account manager to remove the duplication code on getting all wallets accounts

* Rename to Accounts

* Rename to AllAccounts
2025-01-24 16:18:29 +08:00
Daniel Liu
5009a3df04 accounts/abi: fix incorrect signature (#19881)
The abi package already supports function overload by adding a suffix to the overloaded function name, but it uses the function name with suffix to calculate signature(both for the event and method).

This PR fixes it by adding a new field named RawName, which can be used to calcuate all signatures but use Name to distinguish different overloaded function.
2025-01-24 16:18:29 +08:00
Daniel Liu
9340a81ce1 accounts/abi/bind: support closing a simulated backend (#19902) 2025-01-24 16:18:29 +08:00
Daniel Liu
6d17a42edb all: replace t.Log(); t.FailNow() with t.Fatal() (#19849) 2025-01-24 16:18:29 +08:00
Daniel Liu
f571689bab signer/core: fix reference issue in key derivation (#19827)
* signer/core: fix reference issue in key derivation

* Review feedback
2025-01-24 16:18:29 +08:00
Daniel Liu
587f6b3438 accounts/abi/bind: fix typo in comments (#19791) 2025-01-24 16:18:29 +08:00
Daniel Liu
0050f84142 accounts/abi: enable struct golang binding generation (#18491)
* accounts/abi, cmd/abigen: support tuple

accounts/abi/bind, cmd/abigen: add objc back

accounts/abi/bind: use byte[24] as function indicator

accounts/abi/bind: resolve struct slice or array

accounts/abi/bind: remove sort logic

accounts: fix issues in abi

* accounts/abi: address comment
2025-01-24 16:18:29 +08:00
Daniel Liu
71e4c0609a accounts/abi: Fix method overwritten by same name methods (#17099)
* accounts/abi: Fix method overwritten by same name methods.

* accounts/abi: Fix method overwritten by same name methods.

* accounts/abi: avoid possible name conflict

Co-authored-by: Guillaume Ballet <gballet@gmail.com>
2025-01-24 16:18:29 +08:00
Daniel Liu
f542e463d3 accounts: implement simple checkpoint syncing (#19543) 2025-01-24 16:18:29 +08:00