File tree Expand file tree Collapse file tree 4 files changed +34
-5
lines changed Expand file tree Collapse file tree 4 files changed +34
-5
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## Unreleased
4
+
5
+ ### Bug fixes
6
+
7
+ - Encode integers to hex even when they are part of params
8
+
3
9
## v0.2.0 (2024-01-01)
4
10
5
11
### New Features
12
18
13
19
## v0.1.3 (2023-12-26)
14
20
15
- ## Bug fixes
21
+ ### Bug fixes
16
22
17
23
- unsized integer encoding to hex will now raise if given negative numbers.
18
24
- ` Utils.date_to_block_number/3 ` going to negative block numbers issue fixed.
Original file line number Diff line number Diff line change @@ -37,11 +37,12 @@ defmodule Ethers.TxData do
37
37
end
38
38
39
39
def to_map ( tx_map , overrides ) when is_map ( tx_map ) do
40
- Enum . map ( overrides , fn
40
+ overrides
41
+ |> Enum . into ( tx_map )
42
+ |> Map . new ( fn
41
43
{ k , v } when is_integer ( v ) -> { k , Ethers.Utils . integer_to_hex ( v ) }
42
44
kv -> kv
43
45
end )
44
- |> Enum . into ( tx_map )
45
46
end
46
47
47
48
defp get_tx_map ( % { selector: % { type: :function } } = tx_data ) do
Original file line number Diff line number Diff line change @@ -314,6 +314,24 @@ defmodule EthersTest do
314
314
assert { :ok , "hello local signer" } =
315
315
Ethers . call ( HelloWorldContract . say_hello ( ) , to: address )
316
316
end
317
+
318
+ test "converts all integer params and overrides to hex" do
319
+ assert { :ok , _tx_hash } =
320
+ Ethers . send (
321
+ % { value: 1000 } ,
322
+ rpc_client: Ethers.TestRPCModule ,
323
+ from: @ from ,
324
+ to: "0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC" ,
325
+ rpc_opts: [ send_params_to_pid: self ( ) ]
326
+ )
327
+
328
+ assert_receive % {
329
+ from: "0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1" ,
330
+ gas: "0x119" ,
331
+ to: "0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC" ,
332
+ value: "0x3E8"
333
+ }
334
+ end
317
335
end
318
336
319
337
describe "sign_transaction/2" do
Original file line number Diff line number Diff line change @@ -7,8 +7,12 @@ defmodule Ethers.TestRPCModule do
7
7
{ :ok , "0x100" }
8
8
end
9
9
10
- def eth_send_transaction ( _params , _opts ) do
11
- { :ok , "tx_hash" }
10
+ def eth_send_transaction ( params , opts ) do
11
+ if pid = opts [ :send_params_to_pid ] do
12
+ send ( pid , params )
13
+ end
14
+
15
+ { :ok , opts [ :tx_hash ] || "tx_hash" }
12
16
end
13
17
14
18
def eth_call ( params , block , opts ) do
You can’t perform that action at this time.
0 commit comments