viem 0.0.0-portable-types-20230518183529 → 0.0.0-portable-types-20230522163654
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/abi/package.json +5 -0
- package/accounts/package.json +5 -0
- package/chains/package.json +5 -0
- package/contract/package.json +5 -0
- package/dist/cjs/actions/ens/getEnsAddress.js +1 -1
- package/dist/cjs/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/cjs/actions/public/waitForTransactionReceipt.js +23 -12
- package/dist/cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/public/watchBlockNumber.js +2 -1
- package/dist/cjs/actions/public/watchBlockNumber.js.map +1 -1
- package/dist/cjs/actions/public/watchBlocks.js +2 -1
- package/dist/cjs/actions/public/watchBlocks.js.map +1 -1
- package/dist/cjs/actions/public/watchContractEvent.js +2 -1
- package/dist/cjs/actions/public/watchContractEvent.js.map +1 -1
- package/dist/cjs/actions/public/watchEvent.js +2 -1
- package/dist/cjs/actions/public/watchEvent.js.map +1 -1
- package/dist/cjs/actions/public/watchPendingTransactions.js +2 -1
- package/dist/cjs/actions/public/watchPendingTransactions.js.map +1 -1
- package/dist/cjs/errors/abi.js +0 -2
- package/dist/cjs/errors/abi.js.map +1 -1
- package/dist/cjs/errors/ccip.js +2 -1
- package/dist/cjs/errors/ccip.js.map +1 -1
- package/dist/cjs/errors/data.js +2 -2
- package/dist/cjs/errors/data.js.map +1 -1
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/utils/abi/decodeAbiParameters.js +22 -14
- package/dist/cjs/utils/abi/decodeAbiParameters.js.map +1 -1
- package/dist/cjs/utils/abi/decodeEventLog.js +5 -5
- package/dist/cjs/utils/abi/decodeEventLog.js.map +1 -1
- package/dist/cjs/utils/data/isHex.js +2 -2
- package/dist/cjs/utils/data/isHex.js.map +1 -1
- package/dist/cjs/utils/data/size.js +1 -1
- package/dist/cjs/utils/data/size.js.map +1 -1
- package/dist/cjs/utils/data/slice.js +36 -12
- package/dist/cjs/utils/data/slice.js.map +1 -1
- package/dist/cjs/utils/data/trim.js +1 -1
- package/dist/cjs/utils/data/trim.js.map +1 -1
- package/dist/cjs/utils/encoding/fromHex.js +2 -2
- package/dist/cjs/utils/encoding/fromHex.js.map +1 -1
- package/dist/cjs/utils/hash/keccak256.js +1 -1
- package/dist/cjs/utils/hash/keccak256.js.map +1 -1
- package/dist/cjs/utils/promise/createBatchScheduler.js.map +1 -1
- package/dist/cjs/utils/rpc.js +49 -40
- package/dist/cjs/utils/rpc.js.map +1 -1
- package/dist/cjs/utils/signature/recoverPublicKey.js +3 -1
- package/dist/cjs/utils/signature/recoverPublicKey.js.map +1 -1
- package/dist/cjs/utils/transaction/serializeTransaction.js +2 -1
- package/dist/cjs/utils/transaction/serializeTransaction.js.map +1 -1
- package/dist/esm/actions/ens/getEnsAddress.js +1 -1
- package/dist/esm/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/esm/actions/public/waitForTransactionReceipt.js +23 -12
- package/dist/esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/public/watchBlockNumber.js +2 -1
- package/dist/esm/actions/public/watchBlockNumber.js.map +1 -1
- package/dist/esm/actions/public/watchBlocks.js +2 -1
- package/dist/esm/actions/public/watchBlocks.js.map +1 -1
- package/dist/esm/actions/public/watchContractEvent.js +2 -1
- package/dist/esm/actions/public/watchContractEvent.js.map +1 -1
- package/dist/esm/actions/public/watchEvent.js +2 -1
- package/dist/esm/actions/public/watchEvent.js.map +1 -1
- package/dist/esm/actions/public/watchPendingTransactions.js +2 -1
- package/dist/esm/actions/public/watchPendingTransactions.js.map +1 -1
- package/dist/esm/errors/abi.js +0 -2
- package/dist/esm/errors/abi.js.map +1 -1
- package/dist/esm/errors/ccip.js +2 -1
- package/dist/esm/errors/ccip.js.map +1 -1
- package/dist/esm/errors/data.js +2 -2
- package/dist/esm/errors/data.js.map +1 -1
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/utils/abi/decodeAbiParameters.js +23 -15
- package/dist/esm/utils/abi/decodeAbiParameters.js.map +1 -1
- package/dist/esm/utils/abi/decodeEventLog.js +5 -5
- package/dist/esm/utils/abi/decodeEventLog.js.map +1 -1
- package/dist/esm/utils/data/isHex.js +2 -2
- package/dist/esm/utils/data/isHex.js.map +1 -1
- package/dist/esm/utils/data/size.js +1 -1
- package/dist/esm/utils/data/size.js.map +1 -1
- package/dist/esm/utils/data/slice.js +36 -12
- package/dist/esm/utils/data/slice.js.map +1 -1
- package/dist/esm/utils/data/trim.js +1 -1
- package/dist/esm/utils/data/trim.js.map +1 -1
- package/dist/esm/utils/encoding/fromHex.js +2 -2
- package/dist/esm/utils/encoding/fromHex.js.map +1 -1
- package/dist/esm/utils/hash/keccak256.js +1 -1
- package/dist/esm/utils/hash/keccak256.js.map +1 -1
- package/dist/esm/utils/promise/createBatchScheduler.js.map +1 -1
- package/dist/esm/utils/rpc.js +49 -40
- package/dist/esm/utils/rpc.js.map +1 -1
- package/dist/esm/utils/signature/recoverPublicKey.js +3 -1
- package/dist/esm/utils/signature/recoverPublicKey.js.map +1 -1
- package/dist/esm/utils/transaction/serializeTransaction.js +2 -1
- package/dist/esm/utils/transaction/serializeTransaction.js.map +1 -1
- package/dist/types/actions/public/getTransactionReceipt.d.ts +1 -1
- package/dist/types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/dist/types/actions/public/watchBlockNumber.d.ts.map +1 -1
- package/dist/types/actions/public/watchBlocks.d.ts.map +1 -1
- package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchPendingTransactions.d.ts.map +1 -1
- package/dist/types/clients/createTestClient.d.ts +2 -2
- package/dist/types/clients/createTestClient.d.ts.map +1 -1
- package/dist/types/errors/abi.d.ts.map +1 -1
- package/dist/types/errors/ccip.d.ts.map +1 -1
- package/dist/types/errors/data.d.ts +2 -1
- package/dist/types/errors/data.d.ts.map +1 -1
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/types/contract.d.ts +7 -33
- package/dist/types/types/contract.d.ts.map +1 -1
- package/dist/types/types/log.d.ts +0 -2
- package/dist/types/types/log.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeAbiParameters.d.ts.map +1 -1
- package/dist/types/utils/data/isHex.d.ts +3 -1
- package/dist/types/utils/data/isHex.d.ts.map +1 -1
- package/dist/types/utils/data/slice.d.ts +9 -3
- package/dist/types/utils/data/slice.d.ts.map +1 -1
- package/dist/types/utils/data/trim.d.ts.map +1 -1
- package/dist/types/utils/encoding/fromHex.d.ts +1 -1
- package/dist/types/utils/hash/keccak256.d.ts.map +1 -1
- package/dist/types/utils/promise/createBatchScheduler.d.ts +6 -4
- package/dist/types/utils/promise/createBatchScheduler.d.ts.map +1 -1
- package/dist/types/utils/rpc.d.ts.map +1 -1
- package/dist/types/utils/signature/recoverPublicKey.d.ts.map +1 -1
- package/dist/types/utils/transaction/serializeTransaction.d.ts.map +1 -1
- package/ens/package.json +5 -0
- package/ethers/package.json +5 -0
- package/package.json +13 -2
- package/public/package.json +5 -0
- package/src/actions/ens/getEnsAddress.ts +1 -1
- package/src/actions/public/getTransactionReceipt.ts +1 -1
- package/src/actions/public/waitForTransactionReceipt.ts +33 -11
- package/src/actions/public/watchBlockNumber.ts +2 -1
- package/src/actions/public/watchBlocks.ts +2 -1
- package/src/actions/public/watchContractEvent.ts +2 -1
- package/src/actions/public/watchEvent.ts +2 -1
- package/src/actions/public/watchPendingTransactions.ts +2 -1
- package/src/clients/createTestClient.ts +2 -2
- package/src/errors/abi.ts +0 -2
- package/src/errors/ccip.ts +2 -1
- package/src/errors/data.ts +8 -2
- package/src/errors/version.ts +1 -1
- package/src/types/contract.ts +11 -87
- package/src/types/log.ts +2 -2
- package/src/utils/abi/decodeAbiParameters.ts +36 -15
- package/src/utils/abi/decodeEventLog.ts +5 -5
- package/src/utils/data/isHex.ts +5 -2
- package/src/utils/data/size.ts +1 -1
- package/src/utils/data/slice.ts +43 -11
- package/src/utils/data/trim.ts +3 -1
- package/src/utils/encoding/fromHex.ts +3 -3
- package/src/utils/hash/keccak256.ts +3 -1
- package/src/utils/promise/createBatchScheduler.ts +24 -7
- package/src/utils/rpc.ts +59 -49
- package/src/utils/signature/recoverPublicKey.ts +2 -1
- package/src/utils/transaction/serializeTransaction.ts +3 -2
- package/test/package.json +5 -0
- package/utils/package.json +5 -0
- package/wallet/package.json +5 -0
- package/window/package.json +5 -0
package/src/utils/data/slice.ts
CHANGED
@@ -19,15 +19,38 @@ export function slice<TValue extends ByteArray | Hex>(
|
|
19
19
|
value: TValue,
|
20
20
|
start?: number,
|
21
21
|
end?: number,
|
22
|
+
{ strict }: { strict?: boolean } = {},
|
22
23
|
): SliceReturnType<TValue> {
|
23
|
-
if (isHex(value))
|
24
|
-
return sliceHex(value as Hex, start, end
|
25
|
-
|
24
|
+
if (isHex(value, { strict: false }))
|
25
|
+
return sliceHex(value as Hex, start, end, {
|
26
|
+
strict,
|
27
|
+
}) as SliceReturnType<TValue>
|
28
|
+
return sliceBytes(value as ByteArray, start, end, {
|
29
|
+
strict,
|
30
|
+
}) as SliceReturnType<TValue>
|
26
31
|
}
|
27
32
|
|
28
33
|
function assertStartOffset(value: Hex | ByteArray, start?: number) {
|
29
34
|
if (typeof start === 'number' && start > 0 && start > size(value) - 1)
|
30
|
-
throw new SliceOffsetOutOfBoundsError({
|
35
|
+
throw new SliceOffsetOutOfBoundsError({
|
36
|
+
offset: start,
|
37
|
+
position: 'start',
|
38
|
+
size: size(value),
|
39
|
+
})
|
40
|
+
}
|
41
|
+
|
42
|
+
function assertEndOffset(value: Hex | ByteArray, start?: number, end?: number) {
|
43
|
+
if (
|
44
|
+
typeof start === 'number' &&
|
45
|
+
typeof end === 'number' &&
|
46
|
+
size(value) !== end - start
|
47
|
+
) {
|
48
|
+
throw new SliceOffsetOutOfBoundsError({
|
49
|
+
offset: end,
|
50
|
+
position: 'end',
|
51
|
+
size: size(value),
|
52
|
+
})
|
53
|
+
}
|
31
54
|
}
|
32
55
|
|
33
56
|
/**
|
@@ -38,12 +61,15 @@ function assertStartOffset(value: Hex | ByteArray, start?: number) {
|
|
38
61
|
* @param end The end offset (in bytes).
|
39
62
|
*/
|
40
63
|
export function sliceBytes(
|
41
|
-
|
64
|
+
value_: ByteArray,
|
42
65
|
start?: number,
|
43
66
|
end?: number,
|
67
|
+
{ strict }: { strict?: boolean } = {},
|
44
68
|
): ByteArray {
|
45
|
-
assertStartOffset(
|
46
|
-
|
69
|
+
assertStartOffset(value_, start)
|
70
|
+
const value = value_.slice(start, end)
|
71
|
+
if (strict) assertEndOffset(value, start, end)
|
72
|
+
return value
|
47
73
|
}
|
48
74
|
|
49
75
|
/**
|
@@ -53,10 +79,16 @@ export function sliceBytes(
|
|
53
79
|
* @param start The start offset (in bytes).
|
54
80
|
* @param end The end offset (in bytes).
|
55
81
|
*/
|
56
|
-
export function sliceHex(
|
82
|
+
export function sliceHex(
|
83
|
+
value_: Hex,
|
84
|
+
start?: number,
|
85
|
+
end?: number,
|
86
|
+
{ strict }: { strict?: boolean } = {},
|
87
|
+
): Hex {
|
57
88
|
assertStartOffset(value_, start)
|
58
|
-
const value = value_
|
89
|
+
const value = `0x${value_
|
59
90
|
.replace('0x', '')
|
60
|
-
.slice((start ?? 0) * 2, (end ?? value_.length) * 2)
|
61
|
-
|
91
|
+
.slice((start ?? 0) * 2, (end ?? value_.length) * 2)}` as const
|
92
|
+
if (strict) assertEndOffset(value, start, end)
|
93
|
+
return value
|
62
94
|
}
|
package/src/utils/data/trim.ts
CHANGED
@@ -27,7 +27,9 @@ export function trim<TValue extends ByteArray | Hex>(
|
|
27
27
|
|
28
28
|
if (typeof hexOrBytes === 'string') {
|
29
29
|
if (data.length === 1 && dir === 'right') data = `${data}0`
|
30
|
-
return `0x${
|
30
|
+
return `0x${
|
31
|
+
data.length % 2 === 1 ? `0${data}` : data
|
32
|
+
}` as TrimReturnType<TValue>
|
31
33
|
}
|
32
34
|
return data as TrimReturnType<TValue>
|
33
35
|
}
|
@@ -140,7 +140,7 @@ export type HexToBoolOpts = {
|
|
140
140
|
*
|
141
141
|
* @example
|
142
142
|
* import { hexToBool } from 'viem'
|
143
|
-
* const data = hexToBool('
|
143
|
+
* const data = hexToBool('0x01')
|
144
144
|
* // true
|
145
145
|
*
|
146
146
|
* @example
|
@@ -154,8 +154,8 @@ export function hexToBool(hex_: Hex, opts: HexToBoolOpts = {}): boolean {
|
|
154
154
|
assertSize(hex, { size: opts.size })
|
155
155
|
hex = trim(hex)
|
156
156
|
}
|
157
|
-
if (trim(hex) === '
|
158
|
-
if (trim(hex) === '
|
157
|
+
if (trim(hex) === '0x00') return false
|
158
|
+
if (trim(hex) === '0x01') return true
|
159
159
|
throw new InvalidHexBooleanError(hex)
|
160
160
|
}
|
161
161
|
|
@@ -16,7 +16,9 @@ export function keccak256<TTo extends To = 'hex'>(
|
|
16
16
|
to_?: TTo,
|
17
17
|
): Keccak256Hash<TTo> {
|
18
18
|
const to = to_ || 'hex'
|
19
|
-
const bytes = keccak_256(
|
19
|
+
const bytes = keccak_256(
|
20
|
+
isHex(value, { strict: false }) ? toBytes(value) : value,
|
21
|
+
)
|
20
22
|
if (to === 'bytes') return bytes as Keccak256Hash<TTo>
|
21
23
|
return toHex(bytes) as Keccak256Hash<TTo>
|
22
24
|
}
|
@@ -10,6 +10,25 @@ type PendingPromise<TReturnType extends readonly unknown[] = any> = {
|
|
10
10
|
|
11
11
|
type SchedulerItem = { args: unknown; pendingPromise: PendingPromise }
|
12
12
|
|
13
|
+
export type CreateBatchSchedulerArguments<
|
14
|
+
TParameters = unknown,
|
15
|
+
TReturnType extends readonly unknown[] = readonly unknown[],
|
16
|
+
> = {
|
17
|
+
fn: (args: TParameters[]) => Promise<TReturnType>
|
18
|
+
id: number | string
|
19
|
+
shouldSplitBatch?: (args: TParameters[]) => boolean
|
20
|
+
wait?: number
|
21
|
+
}
|
22
|
+
export type CreateBatchSchedulerReturnType<
|
23
|
+
TParameters = unknown,
|
24
|
+
TReturnType extends readonly unknown[] = readonly unknown[],
|
25
|
+
> = {
|
26
|
+
flush: () => void
|
27
|
+
schedule: TParameters extends undefined
|
28
|
+
? (args?: TParameters) => Promise<Resolved<TReturnType>>
|
29
|
+
: (args: TParameters) => Promise<Resolved<TReturnType>>
|
30
|
+
}
|
31
|
+
|
13
32
|
const schedulerCache = new Map<number | string, SchedulerItem[]>()
|
14
33
|
|
15
34
|
export function createBatchScheduler<
|
@@ -20,12 +39,10 @@ export function createBatchScheduler<
|
|
20
39
|
id,
|
21
40
|
shouldSplitBatch,
|
22
41
|
wait = 0,
|
23
|
-
}:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
wait?: number
|
28
|
-
}) {
|
42
|
+
}: CreateBatchSchedulerArguments<
|
43
|
+
TParameters,
|
44
|
+
TReturnType
|
45
|
+
>): CreateBatchSchedulerReturnType<TParameters, TReturnType> {
|
29
46
|
const exec = async () => {
|
30
47
|
const scheduler = getScheduler()
|
31
48
|
flush()
|
@@ -78,5 +95,5 @@ export function createBatchScheduler<
|
|
78
95
|
setTimeout(exec, wait)
|
79
96
|
return promise
|
80
97
|
},
|
81
|
-
}
|
98
|
+
} as unknown as CreateBatchSchedulerReturnType<TParameters, TReturnType>
|
82
99
|
}
|
package/src/utils/rpc.ts
CHANGED
@@ -7,6 +7,7 @@ import {
|
|
7
7
|
WebSocketRequestError,
|
8
8
|
} from '../errors/request.js'
|
9
9
|
|
10
|
+
import { createBatchScheduler } from './promise/createBatchScheduler.js'
|
10
11
|
import { withTimeout } from './promise/withTimeout.js'
|
11
12
|
import { stringify } from './stringify.js'
|
12
13
|
|
@@ -146,61 +147,70 @@ export async function getSocket(url_: string) {
|
|
146
147
|
// If the socket already exists, return it.
|
147
148
|
if (socket) return socket
|
148
149
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
150
|
+
const { schedule } = createBatchScheduler<undefined, [Socket]>({
|
151
|
+
id: urlKey,
|
152
|
+
fn: async () => {
|
153
|
+
let WebSocket = await import('isomorphic-ws')
|
154
|
+
// Workaround for Vite.
|
155
|
+
// https://github.com/vitejs/vite/issues/9703
|
156
|
+
// TODO: Remove when issue is resolved.
|
157
|
+
if (
|
158
|
+
(WebSocket as unknown as { default?: typeof WebSocket }).default
|
159
|
+
?.constructor
|
160
|
+
)
|
161
|
+
WebSocket = (WebSocket as unknown as { default: typeof WebSocket })
|
162
|
+
.default
|
163
|
+
else WebSocket = WebSocket.WebSocket
|
164
|
+
|
165
|
+
const webSocket = new WebSocket(url)
|
166
|
+
|
167
|
+
// Set up a cache for incoming "synchronous" requests.
|
168
|
+
const requests = new Map<Id, CallbackFn>()
|
169
|
+
|
170
|
+
// Set up a cache for subscriptions (eth_subscribe).
|
171
|
+
const subscriptions = new Map<Id, CallbackFn>()
|
172
|
+
|
173
|
+
const onMessage: (event: MessageEvent) => void = ({ data }) => {
|
174
|
+
const message: RpcResponse = JSON.parse(data as string)
|
175
|
+
const isSubscription = message.method === 'eth_subscription'
|
176
|
+
const id = isSubscription ? message.params.subscription : message.id
|
177
|
+
const cache = isSubscription ? subscriptions : requests
|
178
|
+
const callback = cache.get(id)
|
179
|
+
if (callback) callback({ data })
|
180
|
+
if (!isSubscription) cache.delete(id)
|
181
|
+
}
|
182
|
+
const onClose = () => {
|
183
|
+
sockets.delete(urlKey)
|
184
|
+
webSocket.removeEventListener('close', onClose)
|
185
|
+
webSocket.removeEventListener('message', onMessage)
|
186
|
+
}
|
164
187
|
|
165
|
-
|
166
|
-
|
188
|
+
// Setup event listeners for RPC & subscription responses.
|
189
|
+
webSocket.addEventListener('close', onClose)
|
190
|
+
webSocket.addEventListener('message', onMessage)
|
167
191
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
}
|
177
|
-
const onClose = () => {
|
178
|
-
sockets.delete(urlKey)
|
179
|
-
webSocket.removeEventListener('close', onClose)
|
180
|
-
webSocket.removeEventListener('message', onMessage)
|
181
|
-
}
|
182
|
-
|
183
|
-
// Setup event listeners for RPC & subscription responses.
|
184
|
-
webSocket.addEventListener('close', onClose)
|
185
|
-
webSocket.addEventListener('message', onMessage)
|
192
|
+
// Wait for the socket to open.
|
193
|
+
if (webSocket.readyState === WebSocket.CONNECTING) {
|
194
|
+
await new Promise((resolve, reject) => {
|
195
|
+
if (!webSocket) return
|
196
|
+
webSocket.onopen = resolve
|
197
|
+
webSocket.onerror = reject
|
198
|
+
})
|
199
|
+
}
|
186
200
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
})
|
194
|
-
}
|
201
|
+
// Create a new socket instance.
|
202
|
+
socket = Object.assign(webSocket, {
|
203
|
+
requests,
|
204
|
+
subscriptions,
|
205
|
+
})
|
206
|
+
sockets.set(urlKey, socket)
|
195
207
|
|
196
|
-
|
197
|
-
|
198
|
-
requests,
|
199
|
-
subscriptions,
|
208
|
+
return [socket]
|
209
|
+
},
|
200
210
|
})
|
201
|
-
sockets.set(urlKey, socket)
|
202
211
|
|
203
|
-
|
212
|
+
const [_, [socket_]] = await schedule()
|
213
|
+
return socket_
|
204
214
|
}
|
205
215
|
|
206
216
|
function webSocket(
|
@@ -18,7 +18,8 @@ export async function recoverPublicKey({
|
|
18
18
|
|
19
19
|
// Derive v = recoveryId + 27 from end of the signature (27 is added when signing the message)
|
20
20
|
// The recoveryId represents the y-coordinate on the secp256k1 elliptic curve and can have a value [0, 1].
|
21
|
-
|
21
|
+
let v = hexToNumber(`0x${signatureHex.slice(130)}`)
|
22
|
+
if (v === 0 || v === 1) v += 27
|
22
23
|
|
23
24
|
const { secp256k1 } = await import('@noble/curves/secp256k1')
|
24
25
|
const publicKey = secp256k1.Signature.fromCompact(
|
@@ -18,6 +18,7 @@ import type {
|
|
18
18
|
} from '../../types/transaction.js'
|
19
19
|
import { isAddress } from '../address/isAddress.js'
|
20
20
|
import { concatHex } from '../data/concat.js'
|
21
|
+
import { trim } from '../data/trim.js'
|
21
22
|
import { toHex } from '../encoding/toHex.js'
|
22
23
|
import { type RecursiveArray, toRlp } from '../encoding/toRlp.js'
|
23
24
|
|
@@ -97,8 +98,8 @@ function serializeTransactionEIP1559(
|
|
97
98
|
if (signature)
|
98
99
|
serializedTransaction.push(
|
99
100
|
signature.v === 27n ? '0x' : toHex(1), // yParity
|
100
|
-
signature.r,
|
101
|
-
signature.s,
|
101
|
+
trim(signature.r),
|
102
|
+
trim(signature.s),
|
102
103
|
)
|
103
104
|
|
104
105
|
return concatHex([
|