ox 0.14.48 → 0.14.51
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/CHANGELOG.md +31 -0
- package/FrameRequest/package.json +6 -0
- package/_cjs/core/Frame.js +8 -8
- package/_cjs/core/Frame.js.map +1 -1
- package/_cjs/core/FrameReceipt.js +10 -8
- package/_cjs/core/FrameReceipt.js.map +1 -1
- package/_cjs/core/FrameRequest.js +29 -0
- package/_cjs/core/FrameRequest.js.map +1 -0
- package/_cjs/core/FrameSignature.js +38 -21
- package/_cjs/core/FrameSignature.js.map +1 -1
- package/_cjs/core/Siwe.js +3 -3
- package/_cjs/core/Siwe.js.map +1 -1
- package/_cjs/core/TransactionRequest.js +3 -3
- package/_cjs/core/TransactionRequest.js.map +1 -1
- package/_cjs/index.js +3 -2
- package/_cjs/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/core/Frame.js +12 -12
- package/_esm/core/Frame.js.map +1 -1
- package/_esm/core/FrameReceipt.js +15 -11
- package/_esm/core/FrameReceipt.js.map +1 -1
- package/_esm/core/FrameRequest.js +53 -0
- package/_esm/core/FrameRequest.js.map +1 -0
- package/_esm/core/FrameSignature.js +41 -23
- package/_esm/core/FrameSignature.js.map +1 -1
- package/_esm/core/Siwe.js +3 -3
- package/_esm/core/Siwe.js.map +1 -1
- package/_esm/core/TransactionRequest.js +3 -3
- package/_esm/core/TransactionRequest.js.map +1 -1
- package/_esm/index.js +13 -0
- package/_esm/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/core/Frame.d.ts +9 -9
- package/_types/core/Frame.d.ts.map +1 -1
- package/_types/core/FrameReceipt.d.ts +17 -11
- package/_types/core/FrameReceipt.d.ts.map +1 -1
- package/_types/core/FrameRequest.d.ts +44 -0
- package/_types/core/FrameRequest.d.ts.map +1 -0
- package/_types/core/FrameSignature.d.ts +17 -16
- package/_types/core/FrameSignature.d.ts.map +1 -1
- package/_types/core/Siwe.d.ts.map +1 -1
- package/_types/core/TransactionRequest.d.ts +5 -5
- package/_types/core/TransactionRequest.d.ts.map +1 -1
- package/_types/core/internal/rpcSchemas/eth.d.ts +35 -0
- package/_types/core/internal/rpcSchemas/eth.d.ts.map +1 -1
- package/_types/index.d.ts +13 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/core/Frame.ts +20 -17
- package/core/FrameReceipt.ts +21 -13
- package/core/FrameRequest.ts +72 -0
- package/core/FrameSignature.ts +68 -42
- package/core/Siwe.ts +21 -13
- package/core/TransactionRequest.ts +8 -7
- package/core/internal/rpcSchemas/eth.ts +39 -0
- package/index.ts +15 -0
- package/package.json +6 -1
- package/version.ts +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as Frame from './Frame.js'
|
|
2
|
+
import type { Compute, PartialBy } from './internal/types.js'
|
|
3
|
+
|
|
4
|
+
/** A frame request whose omitted gas limits are estimated by the node. */
|
|
5
|
+
export type FrameRequest<bigintType = bigint> = Frame.Frame<bigintType>
|
|
6
|
+
|
|
7
|
+
/** JSON-RPC frame request. Only the execution mode is required. */
|
|
8
|
+
export type Rpc = Compute<
|
|
9
|
+
PartialBy<Frame.Rpc, Exclude<keyof Frame.Rpc, 'mode'>>
|
|
10
|
+
>
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Converts an RPC frame request, preserving omitted gas limits for node estimation.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts twoslash
|
|
17
|
+
* import { FrameRequest } from 'ox'
|
|
18
|
+
*
|
|
19
|
+
* const frame = FrameRequest.fromRpc({ mode: '0x2', stateGas: '0x0' })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param frame - The RPC frame request.
|
|
23
|
+
* @returns The decoded request with omitted gas limits preserved.
|
|
24
|
+
*/
|
|
25
|
+
export function fromRpc(frame: Rpc): FrameRequest {
|
|
26
|
+
const { executionGas, stateGas, ...rest } = Frame.fromRpc({
|
|
27
|
+
...frame,
|
|
28
|
+
data: frame.data ?? '0x',
|
|
29
|
+
executionGas: frame.executionGas ?? '0x0',
|
|
30
|
+
flags: frame.flags ?? '0x0',
|
|
31
|
+
stateGas: frame.stateGas ?? '0x0',
|
|
32
|
+
value: frame.value ?? '0x0',
|
|
33
|
+
})
|
|
34
|
+
return {
|
|
35
|
+
...rest,
|
|
36
|
+
...(frame.executionGas === undefined ? {} : { executionGas }),
|
|
37
|
+
...(frame.stateGas === undefined ? {} : { stateGas }),
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export declare namespace fromRpc {
|
|
42
|
+
type ErrorType = Frame.fromRpc.ErrorType
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Converts a frame request to RPC fields without filling omitted gas limits.
|
|
47
|
+
*
|
|
48
|
+
* Explicit zero limits remain zero. Omitted mode, flags, value, and data use frame defaults.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts twoslash
|
|
52
|
+
* import { FrameRequest } from 'ox'
|
|
53
|
+
*
|
|
54
|
+
* const frame = FrameRequest.toRpc({ mode: 'sender', stateGas: 0n })
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @param frame - The frame request. Gas and value accept hex, bigint, or number values.
|
|
58
|
+
* @returns The RPC request with omitted gas limits preserved.
|
|
59
|
+
*/
|
|
60
|
+
export function toRpc(frame: toRpc.Input): Rpc {
|
|
61
|
+
const { executionGas, stateGas, ...rest } = Frame.toRpc(frame)
|
|
62
|
+
return {
|
|
63
|
+
...rest,
|
|
64
|
+
...(frame.executionGas === undefined ? {} : { executionGas }),
|
|
65
|
+
...(frame.stateGas === undefined ? {} : { stateGas }),
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export declare namespace toRpc {
|
|
70
|
+
type Input = Frame.toRpc.Input
|
|
71
|
+
type ErrorType = Frame.toRpc.ErrorType
|
|
72
|
+
}
|
package/core/FrameSignature.ts
CHANGED
|
@@ -26,19 +26,19 @@ export type Arbitrary = {
|
|
|
26
26
|
signer?: undefined
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/** A
|
|
29
|
+
/** A secp256k1 signature entry. */
|
|
30
30
|
export type Secp256k1 = {
|
|
31
31
|
/** Explicit nonzero digest. Omit or use empty bytes for the transaction signing hash. */
|
|
32
32
|
payload?: Hex.Hex | undefined
|
|
33
33
|
/** secp256k1 verification scheme. */
|
|
34
34
|
scheme: 1 | 'secp256k1'
|
|
35
|
-
/** Recovered signature. Omit for an unsigned entry. */
|
|
36
|
-
signature?: Signature.Signature | undefined
|
|
35
|
+
/** Recovered signature or `Signature.toHex` bytes. Omit or use `0x` for an unsigned entry. */
|
|
36
|
+
signature?: Hex.Hex | Signature.Signature | undefined
|
|
37
37
|
/** Signer address. Omit to use the transaction sender. */
|
|
38
38
|
signer?: Address.Address | undefined
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/** A
|
|
41
|
+
/** A P-256 signature entry. */
|
|
42
42
|
export type P256 = {
|
|
43
43
|
/** Explicit nonzero digest. Omit or use empty bytes for the transaction signing hash. */
|
|
44
44
|
payload?: Hex.Hex | undefined
|
|
@@ -50,14 +50,14 @@ export type P256 = {
|
|
|
50
50
|
| {
|
|
51
51
|
/** Uncompressed P-256 public key. */
|
|
52
52
|
publicKey: PublicKey.PublicKey
|
|
53
|
-
/** P-256 signature. */
|
|
54
|
-
signature: Signature.Signature<false>
|
|
53
|
+
/** P-256 signature or `Signature.toHex` bytes. */
|
|
54
|
+
signature: Hex.Hex | Signature.Signature<false>
|
|
55
55
|
}
|
|
56
56
|
| {
|
|
57
57
|
/** Public key, if already known. Empty wire signatures do not retain it. */
|
|
58
58
|
publicKey?: PublicKey.PublicKey | undefined
|
|
59
|
-
/** Omit for an unsigned entry. */
|
|
60
|
-
signature?: undefined
|
|
59
|
+
/** Omit or use `0x` for an unsigned entry. */
|
|
60
|
+
signature?: '0x' | undefined
|
|
61
61
|
}
|
|
62
62
|
)
|
|
63
63
|
|
|
@@ -67,13 +67,13 @@ export type FrameSignature = Arbitrary | Secp256k1 | P256
|
|
|
67
67
|
/** JSON-RPC representation of a frame signature. */
|
|
68
68
|
export type Rpc = {
|
|
69
69
|
/** Explicit digest, or empty bytes for the transaction signing hash. */
|
|
70
|
-
msg
|
|
70
|
+
msg?: Hex.Hex | undefined
|
|
71
71
|
/** Signature verification scheme. */
|
|
72
|
-
scheme:
|
|
72
|
+
scheme: '0x0' | '0x1' | '0x2'
|
|
73
73
|
/** Encoded signature bytes. */
|
|
74
|
-
signature
|
|
74
|
+
signature?: Hex.Hex | undefined
|
|
75
75
|
/** Signer address; absent for the transaction sender. */
|
|
76
|
-
signer?: Address.Address |
|
|
76
|
+
signer?: Address.Address | '0x' | undefined
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/** RLP-ready signature entry. The payload occupies the specification's `msg` field. */
|
|
@@ -167,27 +167,34 @@ export function assert(
|
|
|
167
167
|
throw new InvalidError('Public key coordinates must fit in 32 bytes.')
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
if (
|
|
170
|
+
if (
|
|
171
|
+
entry.signature !== undefined &&
|
|
172
|
+
entry.signature !== '0x' &&
|
|
173
|
+
entry.publicKey === undefined
|
|
174
|
+
)
|
|
171
175
|
throw new InvalidError('P-256 signatures require a public key.')
|
|
172
176
|
}
|
|
173
|
-
if (entry.signature === undefined) {
|
|
177
|
+
if (entry.signature === undefined || entry.signature === '0x') {
|
|
174
178
|
if (options.signed) throw new InvalidError('Signature is required.')
|
|
175
179
|
return
|
|
176
180
|
}
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
if (typeof entry.signature === 'string')
|
|
182
|
+
Hex.assert(entry.signature, { strict: true })
|
|
183
|
+
const signature =
|
|
184
|
+
typeof entry.signature === 'string'
|
|
185
|
+
? Signature.fromHex(entry.signature)
|
|
186
|
+
: entry.signature
|
|
187
|
+
if (typeof signature.r !== 'bigint' || typeof signature.s !== 'bigint')
|
|
181
188
|
throw new InvalidError('Signature scalars must be bigint.')
|
|
182
189
|
if (
|
|
183
|
-
(scheme === 1 ||
|
|
184
|
-
|
|
185
|
-
|
|
190
|
+
(scheme === 1 || signature.yParity !== undefined) &&
|
|
191
|
+
signature.yParity !== 0 &&
|
|
192
|
+
signature.yParity !== 1
|
|
186
193
|
)
|
|
187
194
|
throw new InvalidError('Signature parity must be 0 or 1.')
|
|
188
|
-
Signature.assert(
|
|
189
|
-
const r =
|
|
190
|
-
const s =
|
|
195
|
+
Signature.assert(signature, { recovered: scheme === 1 })
|
|
196
|
+
const r = signature.r
|
|
197
|
+
const s = signature.s
|
|
191
198
|
const order = scheme === 1 ? secp256k1N : p256N
|
|
192
199
|
if (
|
|
193
200
|
r === 0n ||
|
|
@@ -216,13 +223,15 @@ export declare namespace assert {
|
|
|
216
223
|
| Hex.toBigInt.ErrorType
|
|
217
224
|
| PublicKey.assert.ErrorType
|
|
218
225
|
| Signature.assert.ErrorType
|
|
226
|
+
| Signature.fromHex.ErrorType
|
|
219
227
|
| Errors.GlobalErrorType
|
|
220
228
|
}
|
|
221
229
|
|
|
222
230
|
/**
|
|
223
231
|
* Coerces a value into a {@link ox#FrameSignature.FrameSignature}.
|
|
224
232
|
*
|
|
225
|
-
* Accepts arbitrary signature bytes or a
|
|
233
|
+
* Accepts arbitrary signature bytes or a signature entry. Protocol signatures accept
|
|
234
|
+
* structured objects or `Signature.toHex` bytes. P-256 entries still require a public key. Omitted
|
|
226
235
|
* `scheme` and `payload` default to `'arbitrary'` and `'0x'`, respectively.
|
|
227
236
|
* An empty payload selects the canonical transaction signing hash; an explicit
|
|
228
237
|
* payload must be a nonzero 32-byte digest.
|
|
@@ -346,7 +355,7 @@ export declare namespace from {
|
|
|
346
355
|
*
|
|
347
356
|
* const entry = FrameSignature.fromRpc({
|
|
348
357
|
* msg: '0x',
|
|
349
|
-
* scheme:
|
|
358
|
+
* scheme: '0x0',
|
|
350
359
|
* signature: '0xdeadbeef'
|
|
351
360
|
* })
|
|
352
361
|
* ```
|
|
@@ -356,15 +365,20 @@ export declare namespace from {
|
|
|
356
365
|
*/
|
|
357
366
|
export function fromRpc(entry: Rpc): FrameSignature {
|
|
358
367
|
return fromTuple([
|
|
359
|
-
entry.scheme ===
|
|
368
|
+
entry.scheme === '0x0'
|
|
369
|
+
? '0x'
|
|
370
|
+
: Hex.fromNumber(Hex.toNumber(entry.scheme), { size: 1 }),
|
|
360
371
|
entry.signer ?? '0x',
|
|
361
|
-
entry.msg,
|
|
362
|
-
entry.signature,
|
|
372
|
+
entry.msg ?? '0x',
|
|
373
|
+
entry.signature ?? '0x',
|
|
363
374
|
])
|
|
364
375
|
}
|
|
365
376
|
|
|
366
377
|
export declare namespace fromRpc {
|
|
367
|
-
type ErrorType =
|
|
378
|
+
type ErrorType =
|
|
379
|
+
| fromTuple.ErrorType
|
|
380
|
+
| Hex.fromNumber.ErrorType
|
|
381
|
+
| Hex.toNumber.ErrorType
|
|
368
382
|
}
|
|
369
383
|
|
|
370
384
|
/**
|
|
@@ -387,8 +401,10 @@ export function toRpc(entry: FrameSignature): Rpc {
|
|
|
387
401
|
const [scheme, signer, msg, signature] = toTuple(entry)
|
|
388
402
|
return {
|
|
389
403
|
msg,
|
|
390
|
-
scheme: (scheme === '0x'
|
|
391
|
-
|
|
404
|
+
scheme: (scheme === '0x'
|
|
405
|
+
? '0x0'
|
|
406
|
+
: Hex.fromNumber(Hex.toNumber(scheme))) as Rpc['scheme'],
|
|
407
|
+
...(signature === '0x' && scheme !== '0x' ? {} : { signature }),
|
|
392
408
|
...(signer === '0x' ? {} : { signer }),
|
|
393
409
|
}
|
|
394
410
|
}
|
|
@@ -518,18 +534,28 @@ export function toTuple(entry: FrameSignature): Tuple {
|
|
|
518
534
|
case 'arbitrary':
|
|
519
535
|
return entry.signature
|
|
520
536
|
case 1:
|
|
521
|
-
case 'secp256k1':
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
537
|
+
case 'secp256k1': {
|
|
538
|
+
if (entry.signature === undefined || entry.signature === '0x')
|
|
539
|
+
return '0x'
|
|
540
|
+
const signature =
|
|
541
|
+
typeof entry.signature === 'string'
|
|
542
|
+
? Signature.fromHex(entry.signature)
|
|
543
|
+
: entry.signature
|
|
544
|
+
return Hex.concat(
|
|
545
|
+
Hex.fromNumber(signature.yParity, { size: 1 }),
|
|
546
|
+
Hex.fromNumber(signature.r, { size: 32 }),
|
|
547
|
+
Hex.fromNumber(signature.s, { size: 32 }),
|
|
548
|
+
)
|
|
549
|
+
}
|
|
529
550
|
case 2:
|
|
530
551
|
case 'p256': {
|
|
531
|
-
if (entry.signature === undefined
|
|
532
|
-
|
|
552
|
+
if (entry.signature === undefined || entry.signature === '0x')
|
|
553
|
+
return '0x'
|
|
554
|
+
const publicKey = entry.publicKey!
|
|
555
|
+
const signature =
|
|
556
|
+
typeof entry.signature === 'string'
|
|
557
|
+
? Signature.fromHex(entry.signature)
|
|
558
|
+
: entry.signature
|
|
533
559
|
const s = signature.s
|
|
534
560
|
return Hex.concat(
|
|
535
561
|
Hex.fromNumber(signature.r, { size: 32 }),
|
package/core/Siwe.ts
CHANGED
|
@@ -21,7 +21,7 @@ export const prefixRegex =
|
|
|
21
21
|
|
|
22
22
|
// https://regexr.com/80gf9
|
|
23
23
|
export const suffixRegex =
|
|
24
|
-
/(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId
|
|
24
|
+
/(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.*))?(?:\nResources:(?<resources>(?:\n- .+)*))?/
|
|
25
25
|
|
|
26
26
|
/** [EIP-4361](https://eips.ethereum.org/EIPS/eip-4361) message fields. */
|
|
27
27
|
export type Message = {
|
|
@@ -372,18 +372,26 @@ export function parseMessage(message: string): ExactPartial<Message> {
|
|
|
372
372
|
scheme?: string
|
|
373
373
|
statement?: string
|
|
374
374
|
}
|
|
375
|
-
const {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
375
|
+
const {
|
|
376
|
+
chainId,
|
|
377
|
+
expirationTime,
|
|
378
|
+
issuedAt,
|
|
379
|
+
notBefore,
|
|
380
|
+
requestId,
|
|
381
|
+
resources: resources_,
|
|
382
|
+
...suffix
|
|
383
|
+
} = (message.match(suffixRegex)?.groups ?? {}) as {
|
|
384
|
+
chainId: string
|
|
385
|
+
expirationTime?: string
|
|
386
|
+
issuedAt?: string
|
|
387
|
+
nonce: string
|
|
388
|
+
notBefore?: string
|
|
389
|
+
requestId?: string
|
|
390
|
+
resources?: string
|
|
391
|
+
uri: string
|
|
392
|
+
version: '1'
|
|
393
|
+
}
|
|
394
|
+
const resources = resources_?.split('\n- ').slice(1)
|
|
387
395
|
return {
|
|
388
396
|
...prefix,
|
|
389
397
|
...suffix,
|
|
@@ -2,7 +2,7 @@ import type * as AccessList from './AccessList.js'
|
|
|
2
2
|
import type * as Address from './Address.js'
|
|
3
3
|
import * as Authorization from './Authorization.js'
|
|
4
4
|
import type * as Errors from './Errors.js'
|
|
5
|
-
import * as
|
|
5
|
+
import * as FrameRequest from './FrameRequest.js'
|
|
6
6
|
import * as FrameSignature from './FrameSignature.js'
|
|
7
7
|
import * as Hex from './Hex.js'
|
|
8
8
|
import type { Compute } from './internal/types.js'
|
|
@@ -13,7 +13,7 @@ export type TransactionRequest<
|
|
|
13
13
|
bigintType = bigint,
|
|
14
14
|
numberType = number,
|
|
15
15
|
type extends string = string,
|
|
16
|
-
frame =
|
|
16
|
+
frame = FrameRequest.FrameRequest<bigintType>,
|
|
17
17
|
signature = FrameSignature.FrameSignature,
|
|
18
18
|
> = Compute<{
|
|
19
19
|
/** EIP-2930 Access List. */
|
|
@@ -63,7 +63,7 @@ export type Rpc = TransactionRequest<
|
|
|
63
63
|
Hex.Hex,
|
|
64
64
|
Hex.Hex,
|
|
65
65
|
string,
|
|
66
|
-
|
|
66
|
+
FrameRequest.Rpc,
|
|
67
67
|
FrameSignature.Rpc
|
|
68
68
|
>
|
|
69
69
|
|
|
@@ -92,7 +92,7 @@ export function fromRpc(request: Rpc): TransactionRequest {
|
|
|
92
92
|
)
|
|
93
93
|
if (typeof request.chainId !== 'undefined')
|
|
94
94
|
request_.chainId = Hex.toNumber(request.chainId)
|
|
95
|
-
if (request.frames) request_.frames = request.frames.map(
|
|
95
|
+
if (request.frames) request_.frames = request.frames.map(FrameRequest.fromRpc)
|
|
96
96
|
if (request.signatures)
|
|
97
97
|
request_.signatures = request.signatures.map(FrameSignature.fromRpc)
|
|
98
98
|
if (typeof request.gas !== 'undefined')
|
|
@@ -120,7 +120,7 @@ export function fromRpc(request: Rpc): TransactionRequest {
|
|
|
120
120
|
|
|
121
121
|
export declare namespace fromRpc {
|
|
122
122
|
export type ErrorType =
|
|
123
|
-
|
|
|
123
|
+
| FrameRequest.fromRpc.ErrorType
|
|
124
124
|
| FrameSignature.fromRpc.ErrorType
|
|
125
125
|
| Authorization.fromRpcList.ErrorType
|
|
126
126
|
| Hex.toNumber.ErrorType
|
|
@@ -189,7 +189,8 @@ export function toRpc(request: TransactionRequest): Rpc {
|
|
|
189
189
|
request_rpc.input = request.input
|
|
190
190
|
}
|
|
191
191
|
if (typeof request.from !== 'undefined') request_rpc.from = request.from
|
|
192
|
-
if (request.frames)
|
|
192
|
+
if (request.frames)
|
|
193
|
+
request_rpc.frames = request.frames.map(FrameRequest.toRpc)
|
|
193
194
|
if (request.signatures)
|
|
194
195
|
request_rpc.signatures = request.signatures.map(FrameSignature.toRpc)
|
|
195
196
|
if (typeof request.gas !== 'undefined')
|
|
@@ -224,7 +225,7 @@ export function toRpc(request: TransactionRequest): Rpc {
|
|
|
224
225
|
|
|
225
226
|
export declare namespace toRpc {
|
|
226
227
|
export type ErrorType =
|
|
227
|
-
|
|
|
228
|
+
| FrameRequest.toRpc.ErrorType
|
|
228
229
|
| FrameSignature.toRpc.ErrorType
|
|
229
230
|
| Authorization.toRpcList.ErrorType
|
|
230
231
|
| Hex.fromNumber.ErrorType
|
|
@@ -4,6 +4,7 @@ import type * as Block from '../../Block.js'
|
|
|
4
4
|
import type * as BlockOverrides from '../../BlockOverrides.js'
|
|
5
5
|
import type * as Fee from '../../Fee.js'
|
|
6
6
|
import type * as Filter from '../../Filter.js'
|
|
7
|
+
import type * as FrameReceipt from '../../FrameReceipt.js'
|
|
7
8
|
import type * as Hex from '../../Hex.js'
|
|
8
9
|
import type * as Log from '../../Log.js'
|
|
9
10
|
import type * as RpcSchema from '../../RpcSchema.js'
|
|
@@ -11,6 +12,12 @@ import type * as StateOverrides from '../../StateOverrides.js'
|
|
|
11
12
|
import type * as Transaction from '../../Transaction.js'
|
|
12
13
|
import type * as TransactionReceipt from '../../TransactionReceipt.js'
|
|
13
14
|
import type * as TransactionRequest from '../../TransactionRequest.js'
|
|
15
|
+
import type * as TxEnvelopeEip1559 from '../../TxEnvelopeEip1559.js'
|
|
16
|
+
import type * as TxEnvelopeEip2930 from '../../TxEnvelopeEip2930.js'
|
|
17
|
+
import type * as TxEnvelopeEip4844 from '../../TxEnvelopeEip4844.js'
|
|
18
|
+
import type * as TxEnvelopeEip7702 from '../../TxEnvelopeEip7702.js'
|
|
19
|
+
import type * as TxEnvelopeEip8141 from '../../TxEnvelopeEip8141.js'
|
|
20
|
+
import type * as TxEnvelopeLegacy from '../../TxEnvelopeLegacy.js'
|
|
14
21
|
|
|
15
22
|
/**
|
|
16
23
|
* Union of all JSON-RPC Methods for the `eth_` namespace.
|
|
@@ -217,6 +224,31 @@ export type Eth = RpcSchema.From<
|
|
|
217
224
|
}
|
|
218
225
|
ReturnType: Fee.FeeHistoryRpc
|
|
219
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Fills transaction defaults and returns the unsigned transaction.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```
|
|
232
|
+
* request({ method: 'eth_fillTransaction', params: [{ from: '0x...', to: '0x...', value: '0x...' }] })
|
|
233
|
+
* // { tx: { ... } }
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
| {
|
|
237
|
+
Request: {
|
|
238
|
+
method: 'eth_fillTransaction'
|
|
239
|
+
params: [transaction: TransactionRequest.Rpc]
|
|
240
|
+
}
|
|
241
|
+
ReturnType: {
|
|
242
|
+
tx: (
|
|
243
|
+
| TxEnvelopeLegacy.Rpc<false>
|
|
244
|
+
| TxEnvelopeEip2930.Rpc<false>
|
|
245
|
+
| TxEnvelopeEip1559.Rpc<false>
|
|
246
|
+
| TxEnvelopeEip4844.Rpc<false>
|
|
247
|
+
| TxEnvelopeEip7702.Rpc<false>
|
|
248
|
+
| TxEnvelopeEip8141.Rpc
|
|
249
|
+
) & { from: Address.Address }
|
|
250
|
+
}
|
|
251
|
+
}
|
|
220
252
|
/**
|
|
221
253
|
* Returns the current price of gas expressed in wei
|
|
222
254
|
*
|
|
@@ -772,6 +804,13 @@ export type Eth = RpcSchema.From<
|
|
|
772
804
|
message: string
|
|
773
805
|
}
|
|
774
806
|
| undefined
|
|
807
|
+
frameResults?:
|
|
808
|
+
| readonly (FrameReceipt.Rpc & {
|
|
809
|
+
error?: { code: number; message: string } | undefined
|
|
810
|
+
returnData: Hex.Hex
|
|
811
|
+
})[]
|
|
812
|
+
| undefined
|
|
813
|
+
payer?: Address.Address | undefined
|
|
775
814
|
logs?: readonly Log.Rpc[] | undefined
|
|
776
815
|
gasUsed: Hex.Hex
|
|
777
816
|
returnData: Hex.Hex
|
package/index.ts
CHANGED
|
@@ -1579,6 +1579,21 @@ export * as Frame from './core/Frame.js'
|
|
|
1579
1579
|
* @category Frames (EIP-8141)
|
|
1580
1580
|
*/
|
|
1581
1581
|
export * as FrameReceipt from './core/FrameReceipt.js'
|
|
1582
|
+
|
|
1583
|
+
/**
|
|
1584
|
+
* Convert EIP-8141 frame requests while preserving omitted gas limits for node estimation.
|
|
1585
|
+
*
|
|
1586
|
+
* @example
|
|
1587
|
+
* ```ts twoslash
|
|
1588
|
+
* import { FrameRequest } from 'ox'
|
|
1589
|
+
*
|
|
1590
|
+
* const frame = FrameRequest.toRpc({ mode: 'sender', stateGas: 0n })
|
|
1591
|
+
* ```
|
|
1592
|
+
*
|
|
1593
|
+
* @category Frames (EIP-8141)
|
|
1594
|
+
*/
|
|
1595
|
+
export * as FrameRequest from './core/FrameRequest.js'
|
|
1596
|
+
|
|
1582
1597
|
/**
|
|
1583
1598
|
* Utilities for constructing, validating, and encoding [EIP-8141](https://eips.ethereum.org/EIPS/eip-8141) signature entries.
|
|
1584
1599
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ox",
|
|
3
3
|
"description": "Ethereum Standard Library",
|
|
4
|
-
"version": "0.14.
|
|
4
|
+
"version": "0.14.51",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
7
7
|
"types": "./_types/index.d.ts",
|
|
@@ -232,6 +232,11 @@
|
|
|
232
232
|
"import": "./_esm/core/FrameReceipt.js",
|
|
233
233
|
"default": "./_cjs/core/FrameReceipt.js"
|
|
234
234
|
},
|
|
235
|
+
"./FrameRequest": {
|
|
236
|
+
"types": "./_types/core/FrameRequest.d.ts",
|
|
237
|
+
"import": "./_esm/core/FrameRequest.js",
|
|
238
|
+
"default": "./_cjs/core/FrameRequest.js"
|
|
239
|
+
},
|
|
235
240
|
"./FrameSignature": {
|
|
236
241
|
"types": "./_types/core/FrameSignature.d.ts",
|
|
237
242
|
"import": "./_esm/core/FrameSignature.js",
|
package/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '0.14.
|
|
2
|
+
export const version = '0.14.51'
|