File tree 3 files changed +20
-1
lines changed
3 files changed +20
-1
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
+ - Remove leading zeros from signature r and s values
8
+
3
9
## v0.6.0 (2025-01-01)
4
10
5
11
### Breaking Changes
Original file line number Diff line number Diff line change @@ -160,6 +160,8 @@ defmodule Ethers.Transaction.Signed do
160
160
end
161
161
162
162
defimpl Transaction.Protocol do
163
+ import Ethers.Utils , only: [ remove_leading_zeros: 1 ]
164
+
163
165
def type_id ( signed_tx ) , do: Transaction.Protocol . type_id ( signed_tx . pyalod )
164
166
165
167
def type_envelope ( signed_tx ) , do: Transaction.Protocol . type_envelope ( signed_tx . payload )
@@ -171,7 +173,11 @@ defmodule Ethers.Transaction.Signed do
171
173
end
172
174
173
175
defp signature_fields ( signed_tx ) do
174
- [ signed_tx . signature_y_parity_or_v , signed_tx . signature_r , signed_tx . signature_s ]
176
+ [
177
+ signed_tx . signature_y_parity_or_v ,
178
+ remove_leading_zeros ( signed_tx . signature_r ) ,
179
+ remove_leading_zeros ( signed_tx . signature_s )
180
+ ]
175
181
end
176
182
end
177
183
end
Original file line number Diff line number Diff line change @@ -540,4 +540,11 @@ defmodule Ethers.Utils do
540
540
raise ArgumentError , "Invalid Ethereum address binary #{ inspect ( address ) } "
541
541
end
542
542
end
543
+
544
+ @ doc """
545
+ Removes leading zeros from a binary.
546
+ """
547
+ @ spec remove_leading_zeros ( binary ( ) ) :: binary ( )
548
+ def remove_leading_zeros ( << 0 , rest :: binary >> ) , do: remove_leading_zeros ( rest )
549
+ def remove_leading_zeros ( bin ) when is_binary ( bin ) , do: bin
543
550
end
You can’t perform that action at this time.
0 commit comments