ox 0.14.67 → 0.14.69
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 +62 -0
- package/_cjs/core/AbiEvent.js +45 -1
- package/_cjs/core/AbiEvent.js.map +1 -1
- package/_cjs/core/AbiParameters.js +6 -2
- package/_cjs/core/AbiParameters.js.map +1 -1
- package/_cjs/core/Address.js +24 -21
- package/_cjs/core/Address.js.map +1 -1
- package/_cjs/core/Authorization.js +2 -0
- package/_cjs/core/Authorization.js.map +1 -1
- package/_cjs/core/Base58.js +14 -4
- package/_cjs/core/Base58.js.map +1 -1
- package/_cjs/core/BinaryStateTree.js +1 -1
- package/_cjs/core/BinaryStateTree.js.map +1 -1
- package/_cjs/core/Blobs.js +26 -34
- package/_cjs/core/Blobs.js.map +1 -1
- package/_cjs/core/Block.js +1 -0
- package/_cjs/core/Block.js.map +1 -1
- package/_cjs/core/BlockOverrides.js +1 -1
- package/_cjs/core/BlockOverrides.js.map +1 -1
- package/_cjs/core/Bytes.js +56 -13
- package/_cjs/core/Bytes.js.map +1 -1
- package/_cjs/core/Cbor.js +33 -18
- package/_cjs/core/Cbor.js.map +1 -1
- package/_cjs/core/FrameReceipt.js +6 -2
- package/_cjs/core/FrameReceipt.js.map +1 -1
- package/_cjs/core/Hex.js +54 -21
- package/_cjs/core/Hex.js.map +1 -1
- package/_cjs/core/Json.js +15 -2
- package/_cjs/core/Json.js.map +1 -1
- package/_cjs/core/Rlp.js +138 -94
- package/_cjs/core/Rlp.js.map +1 -1
- package/_cjs/core/RpcTransport.js +3 -1
- package/_cjs/core/RpcTransport.js.map +1 -1
- package/_cjs/core/Siwe.js +35 -9
- package/_cjs/core/Siwe.js.map +1 -1
- package/_cjs/core/Transaction.js +10 -4
- package/_cjs/core/Transaction.js.map +1 -1
- package/_cjs/core/TransactionReceipt.js +12 -4
- package/_cjs/core/TransactionReceipt.js.map +1 -1
- package/_cjs/core/TransactionRequest.js +6 -2
- package/_cjs/core/TransactionRequest.js.map +1 -1
- package/_cjs/core/TxEnvelopeEip4844.js +1 -1
- package/_cjs/core/TxEnvelopeEip4844.js.map +1 -1
- package/_cjs/core/TypedData.js +19 -8
- package/_cjs/core/TypedData.js.map +1 -1
- package/_cjs/core/internal/abiParameters.js +59 -18
- package/_cjs/core/internal/abiParameters.js.map +1 -1
- package/_cjs/core/internal/address.js +32 -0
- package/_cjs/core/internal/address.js.map +1 -0
- package/_cjs/core/internal/base58.js +11 -9
- package/_cjs/core/internal/base58.js.map +1 -1
- package/_cjs/core/internal/bytes.js +13 -22
- package/_cjs/core/internal/bytes.js.map +1 -1
- package/_cjs/core/internal/caches.js +1 -0
- package/_cjs/core/internal/caches.js.map +1 -1
- package/_cjs/core/internal/cursor.js +32 -10
- package/_cjs/core/internal/cursor.js.map +1 -1
- package/_cjs/core/internal/hex.js +3 -3
- package/_cjs/core/internal/hex.js.map +1 -1
- package/_cjs/core/internal/lru.js +6 -5
- package/_cjs/core/internal/lru.js.map +1 -1
- package/_cjs/core/internal/promise.js +3 -3
- package/_cjs/core/internal/promise.js.map +1 -1
- package/_cjs/erc6492/SignatureErc6492.js +1 -1
- package/_cjs/erc6492/SignatureErc6492.js.map +1 -1
- package/_cjs/tempo/Transaction.js +13 -7
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/TransactionRequest.js +23 -19
- package/_cjs/tempo/TransactionRequest.js.map +1 -1
- package/_cjs/tempo/TxEnvelopeTempo.js +23 -4
- package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_cjs/tempo/ZoneId.js +3 -0
- package/_cjs/tempo/ZoneId.js.map +1 -1
- package/_cjs/tempo/internal/virtualMasterPool.js +12 -3
- package/_cjs/tempo/internal/virtualMasterPool.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/core/AbiError.js +2 -2
- package/_esm/core/AbiEvent.js +71 -2
- package/_esm/core/AbiEvent.js.map +1 -1
- package/_esm/core/AbiParameters.js +8 -2
- package/_esm/core/AbiParameters.js.map +1 -1
- package/_esm/core/Address.js +27 -21
- package/_esm/core/Address.js.map +1 -1
- package/_esm/core/Authorization.js +3 -0
- package/_esm/core/Authorization.js.map +1 -1
- package/_esm/core/Base58.js +16 -4
- package/_esm/core/Base58.js.map +1 -1
- package/_esm/core/BinaryStateTree.js +3 -1
- package/_esm/core/BinaryStateTree.js.map +1 -1
- package/_esm/core/Blobs.js +40 -41
- package/_esm/core/Blobs.js.map +1 -1
- package/_esm/core/Block.js +1 -0
- package/_esm/core/Block.js.map +1 -1
- package/_esm/core/BlockOverrides.js +3 -2
- package/_esm/core/BlockOverrides.js.map +1 -1
- package/_esm/core/Bytes.js +66 -13
- package/_esm/core/Bytes.js.map +1 -1
- package/_esm/core/Cbor.js +33 -17
- package/_esm/core/Cbor.js.map +1 -1
- package/_esm/core/Ens.js +1 -1
- package/_esm/core/FrameReceipt.js +6 -2
- package/_esm/core/FrameReceipt.js.map +1 -1
- package/_esm/core/Hash.js +1 -1
- package/_esm/core/Hex.js +70 -21
- package/_esm/core/Hex.js.map +1 -1
- package/_esm/core/Json.js +21 -2
- package/_esm/core/Json.js.map +1 -1
- package/_esm/core/Rlp.js +146 -97
- package/_esm/core/Rlp.js.map +1 -1
- package/_esm/core/RpcTransport.js +4 -1
- package/_esm/core/RpcTransport.js.map +1 -1
- package/_esm/core/Siwe.js +40 -10
- package/_esm/core/Siwe.js.map +1 -1
- package/_esm/core/Transaction.js +11 -4
- package/_esm/core/Transaction.js.map +1 -1
- package/_esm/core/TransactionReceipt.js +12 -4
- package/_esm/core/TransactionReceipt.js.map +1 -1
- package/_esm/core/TransactionRequest.js +6 -2
- package/_esm/core/TransactionRequest.js.map +1 -1
- package/_esm/core/TxEnvelopeEip4844.js +1 -1
- package/_esm/core/TxEnvelopeEip4844.js.map +1 -1
- package/_esm/core/TypedData.js +26 -10
- package/_esm/core/TypedData.js.map +1 -1
- package/_esm/core/internal/abiParameters.js +78 -18
- package/_esm/core/internal/abiParameters.js.map +1 -1
- package/_esm/core/internal/address.js +41 -0
- package/_esm/core/internal/address.js.map +1 -0
- package/_esm/core/internal/base58.js +15 -9
- package/_esm/core/internal/base58.js.map +1 -1
- package/_esm/core/internal/bytes.js +14 -22
- package/_esm/core/internal/bytes.js.map +1 -1
- package/_esm/core/internal/caches.js +1 -0
- package/_esm/core/internal/caches.js.map +1 -1
- package/_esm/core/internal/cursor.js +37 -10
- package/_esm/core/internal/cursor.js.map +1 -1
- package/_esm/core/internal/hex.js +5 -3
- package/_esm/core/internal/hex.js.map +1 -1
- package/_esm/core/internal/lru.js +7 -5
- package/_esm/core/internal/lru.js.map +1 -1
- package/_esm/core/internal/promise.js +4 -3
- package/_esm/core/internal/promise.js.map +1 -1
- package/_esm/erc6492/SignatureErc6492.js +1 -1
- package/_esm/erc6492/SignatureErc6492.js.map +1 -1
- package/_esm/tempo/Transaction.js +15 -7
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/TransactionRequest.js +25 -19
- package/_esm/tempo/TransactionRequest.js.map +1 -1
- package/_esm/tempo/TxEnvelopeTempo.js +30 -4
- package/_esm/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_esm/tempo/ZoneId.js +7 -1
- package/_esm/tempo/ZoneId.js.map +1 -1
- package/_esm/tempo/internal/virtualMasterPool.js +16 -3
- package/_esm/tempo/internal/virtualMasterPool.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/core/AbiError.d.ts +3 -3
- package/_types/core/AbiEvent.d.ts +38 -3
- package/_types/core/AbiEvent.d.ts.map +1 -1
- package/_types/core/AbiParameters.d.ts +1 -1
- package/_types/core/AbiParameters.d.ts.map +1 -1
- package/_types/core/Address.d.ts.map +1 -1
- package/_types/core/Authorization.d.ts.map +1 -1
- package/_types/core/Base58.d.ts.map +1 -1
- package/_types/core/Blobs.d.ts +4 -5
- package/_types/core/Blobs.d.ts.map +1 -1
- package/_types/core/Block.d.ts +2 -0
- package/_types/core/Block.d.ts.map +1 -1
- package/_types/core/BlockOverrides.d.ts +2 -1
- package/_types/core/BlockOverrides.d.ts.map +1 -1
- package/_types/core/Bytes.d.ts +2 -0
- package/_types/core/Bytes.d.ts.map +1 -1
- package/_types/core/Cbor.d.ts +13 -6
- package/_types/core/Cbor.d.ts.map +1 -1
- package/_types/core/Ens.d.ts +1 -1
- package/_types/core/FrameReceipt.d.ts.map +1 -1
- package/_types/core/Hash.d.ts +1 -1
- package/_types/core/Hex.d.ts +3 -1
- package/_types/core/Hex.d.ts.map +1 -1
- package/_types/core/Json.d.ts.map +1 -1
- package/_types/core/Rlp.d.ts +38 -9
- package/_types/core/Rlp.d.ts.map +1 -1
- package/_types/core/RpcTransport.d.ts.map +1 -1
- package/_types/core/Siwe.d.ts +1 -0
- package/_types/core/Siwe.d.ts.map +1 -1
- package/_types/core/Transaction.d.ts.map +1 -1
- package/_types/core/TransactionReceipt.d.ts.map +1 -1
- package/_types/core/TransactionRequest.d.ts.map +1 -1
- package/_types/core/TypedData.d.ts +2 -2
- package/_types/core/TypedData.d.ts.map +1 -1
- package/_types/core/internal/abiParameters.d.ts +5 -5
- package/_types/core/internal/abiParameters.d.ts.map +1 -1
- package/_types/core/internal/address.d.ts +14 -0
- package/_types/core/internal/address.d.ts.map +1 -0
- package/_types/core/internal/base58.d.ts.map +1 -1
- package/_types/core/internal/bytes.d.ts +1 -10
- package/_types/core/internal/bytes.d.ts.map +1 -1
- package/_types/core/internal/caches.d.ts +1 -0
- package/_types/core/internal/caches.d.ts.map +1 -1
- package/_types/core/internal/cursor.d.ts +7 -2
- package/_types/core/internal/cursor.d.ts.map +1 -1
- package/_types/core/internal/hex.d.ts.map +1 -1
- package/_types/core/internal/lru.d.ts.map +1 -1
- package/_types/core/internal/promise.d.ts.map +1 -1
- package/_types/erc6492/SignatureErc6492.d.ts +1 -1
- package/_types/erc6492/SignatureErc6492.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/TransactionRequest.d.ts.map +1 -1
- package/_types/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/_types/tempo/ZoneId.d.ts +3 -1
- package/_types/tempo/ZoneId.d.ts.map +1 -1
- package/_types/tempo/internal/virtualMasterPool.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/core/AbiError.ts +3 -3
- package/core/AbiEvent.ts +74 -2
- package/core/AbiParameters.ts +8 -1
- package/core/Address.ts +25 -20
- package/core/Authorization.ts +3 -0
- package/core/Base58.ts +15 -4
- package/core/BinaryStateTree.ts +4 -1
- package/core/Blobs.ts +49 -53
- package/core/Block.ts +3 -0
- package/core/BlockOverrides.ts +3 -2
- package/core/Bytes.ts +68 -17
- package/core/Cbor.ts +33 -13
- package/core/Ens.ts +1 -1
- package/core/FrameReceipt.ts +6 -2
- package/core/Hash.ts +1 -1
- package/core/Hex.ts +79 -22
- package/core/Json.ts +23 -2
- package/core/Rlp.ts +184 -94
- package/core/RpcTransport.ts +4 -1
- package/core/Siwe.ts +41 -10
- package/core/Transaction.ts +11 -4
- package/core/TransactionReceipt.ts +13 -4
- package/core/TransactionRequest.ts +10 -6
- package/core/TxEnvelopeEip4844.ts +1 -1
- package/core/TypedData.ts +28 -10
- package/core/internal/abiParameters.ts +82 -23
- package/core/internal/address.ts +38 -0
- package/core/internal/base58.ts +14 -9
- package/core/internal/bytes.ts +13 -23
- package/core/internal/caches.ts +1 -0
- package/core/internal/cursor.ts +44 -16
- package/core/internal/hex.ts +5 -3
- package/core/internal/lru.ts +6 -7
- package/core/internal/promise.ts +5 -3
- package/erc6492/SignatureErc6492.ts +1 -1
- package/package.json +1 -1
- package/tempo/AccountSimulation.test.ts +1 -1
- package/tempo/SignaturePreAuthorized.test.ts +1 -1
- package/tempo/Transaction.ts +15 -9
- package/tempo/TransactionRequest.ts +31 -24
- package/tempo/TxEnvelopeTempo.test.ts +52 -0
- package/tempo/TxEnvelopeTempo.ts +32 -6
- package/tempo/ZoneId.test.ts +11 -0
- package/tempo/ZoneId.ts +7 -1
- package/tempo/internal/virtualMasterPool.ts +18 -4
- package/version.ts +1 -1
- package/_cjs/core/internal/uid.js +0 -17
- package/_cjs/core/internal/uid.js.map +0 -1
- package/_esm/core/internal/uid.js +0 -15
- package/_esm/core/internal/uid.js.map +0 -1
- package/_types/core/internal/uid.d.ts +0 -3
- package/_types/core/internal/uid.d.ts.map +0 -1
- package/core/internal/uid.ts +0 -15
package/core/internal/promise.ts
CHANGED
|
@@ -5,7 +5,7 @@ export function withTimeout<data>(
|
|
|
5
5
|
fn: withTimeout.Fn<data>,
|
|
6
6
|
options: withTimeout.Options,
|
|
7
7
|
): Promise<data> {
|
|
8
|
-
const { errorInstance
|
|
8
|
+
const { errorInstance, timeout, signal } = options
|
|
9
9
|
return new Promise((resolve, reject) => {
|
|
10
10
|
;(async () => {
|
|
11
11
|
let timeoutId: any
|
|
@@ -16,12 +16,14 @@ export function withTimeout<data>(
|
|
|
16
16
|
if (signal) {
|
|
17
17
|
controller.abort()
|
|
18
18
|
} else {
|
|
19
|
-
reject(errorInstance)
|
|
19
|
+
reject(errorInstance ?? new TimeoutError())
|
|
20
20
|
}
|
|
21
21
|
}, timeout) as any
|
|
22
22
|
resolve(await fn({ signal: controller.signal }))
|
|
23
23
|
} catch (err) {
|
|
24
|
-
|
|
24
|
+
// Only build the error once the request has timed out.
|
|
25
|
+
if ((err as Error)?.name === 'AbortError')
|
|
26
|
+
reject(errorInstance ?? new TimeoutError())
|
|
25
27
|
reject(err)
|
|
26
28
|
} finally {
|
|
27
29
|
clearTimeout(timeoutId)
|
|
@@ -28,7 +28,7 @@ export const magicBytes =
|
|
|
28
28
|
* Deployless ERC-6492 signature verification bytecode.
|
|
29
29
|
*/
|
|
30
30
|
export const universalSignatureValidatorBytecode =
|
|
31
|
-
'
|
|
31
|
+
'0x608060405234801561001057600080fd5b506040516106ad3803806106ad83398101604081905261002f91610537565b600061003c848484610048565b9050806000526001601ff35b60007f649264926492649264926492649264926492649264926492649264926492649261007483610425565b036101e7576000606080848060200190518101906100929190610590565b60405192955090935091506000906001600160a01b038516906100b69085906105f6565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b908790600401610612565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d1919061064c565b6001600160e01b0319161494505050505061041e565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e906102279087908790600401610612565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610268919061064c565b6001600160e01b03191614905061041e565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061068d83398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e761043e565b5060208201516040808401518451859392600091859190811061030c5761030c610676565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061068d83398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b604080516000808252602082018084528a905260ff841692820192909252606081018590526080810184905260019060a0016020604051602081039080840390855afa1580156103e0573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906104165750886001600160a01b0316816001600160a01b0316145b955050505050505b9392505050565b600060208251101561043657600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461047157600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b838110156104a557818101518382015260200161048d565b50506000910152565b600082601f8301126104bf57600080fd5b81516001600160401b038111156104d8576104d8610474565b604051601f8201601f19908116603f011681016001600160401b038111828210171561050657610506610474565b60405281815283820160200185101561051e57600080fd5b61052f82602083016020870161048a565b949350505050565b60008060006060848603121561054c57600080fd5b83516105578161045c565b6020850151604086015191945092506001600160401b0381111561057a57600080fd5b610586868287016104ae565b9150509250925092565b6000806000606084860312156105a557600080fd5b83516105b08161045c565b60208501519093506001600160401b038111156105cc57600080fd5b6105d8868287016104ae565b604086015190935090506001600160401b0381111561057a57600080fd5b6000825161060881846020870161048a565b9190910192915050565b828152604060208201526000825180604084015261063781606085016020870161048a565b601f01601f1916919091016060019392505050565b60006020828403121561065e57600080fd5b81516001600160e01b03198116811461041e57600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572'
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* ABI for the ERC-6492 universal deployless signature validator contract.
|
package/package.json
CHANGED
|
@@ -79,7 +79,7 @@ describe('fromRpc', () => {
|
|
|
79
79
|
expect(() =>
|
|
80
80
|
AccountSimulation.fromRpc({ ...rpc, config: `${config}00` }),
|
|
81
81
|
).toThrowErrorMatchingInlineSnapshot(
|
|
82
|
-
`[
|
|
82
|
+
`[Rlp.TrailingBytesError: RLP payload encodes a single item, but \`1\` trailing byte remains.]`,
|
|
83
83
|
)
|
|
84
84
|
})
|
|
85
85
|
|
|
@@ -225,7 +225,7 @@ describe('unwrap', () => {
|
|
|
225
225
|
).toThrowErrorMatchingInlineSnapshot(`
|
|
226
226
|
[SignaturePreAuthorized.InvalidWrappedSignatureError: Value \`0xf8fab85604f39fd6e51aad88f6f4ce6ab8827279cfffb922663dc3ccd3e78382806b81f811192a9afa9f38335c19a3897a2676008ab611d8a61c73da6988f81a2cc37c5c712f67280aeb732e45688c9347458092b772306c6c1cf8a0f85b821079809472989d24e6e1f0bbe29a5f304d0db21a318c012e84713fb300dad99420c00000000000000000000000000000000000018398968080a0e55f870744098e6baf2f15e0faa6f8f9de283280f26f416dee8dcf9189a553c5b841c026ad99f18042ef3ac0d7a88ffbcd910eb4ccaf435b1acf684f6eb63425909642b07095e6f94edbf489ac1909caa41b0e3eee6971862939e8403c1ab4e617ca1b001165116511651165116511651165116511651165116511651165116511651165\` is an invalid pre-authorized signature.
|
|
227
227
|
|
|
228
|
-
Details:
|
|
228
|
+
Details: RLP payload encodes a single item, but \`1\` trailing byte remains.]
|
|
229
229
|
`)
|
|
230
230
|
})
|
|
231
231
|
|
package/tempo/Transaction.ts
CHANGED
|
@@ -193,18 +193,22 @@ export function fromRpc<
|
|
|
193
193
|
): transaction extends Rpc<pending> ? Transaction<pending> : null {
|
|
194
194
|
if (!transaction) return null as never
|
|
195
195
|
|
|
196
|
+
// Leave out `aaAuthorizationList` rather than deleting it afterwards, and
|
|
197
|
+
// only copy the transaction when it is present.
|
|
198
|
+
const { aaAuthorizationList } = transaction
|
|
196
199
|
const transaction_ = ox_Transaction.fromRpc(
|
|
197
|
-
|
|
200
|
+
(aaAuthorizationList
|
|
201
|
+
? (({ aaAuthorizationList: _, ...rest }) => rest)(transaction)
|
|
202
|
+
: transaction) as ox_Transaction.Rpc<pending>,
|
|
198
203
|
) as Transaction<pending>
|
|
199
204
|
|
|
200
|
-
transaction_.type = fromRpcType
|
|
205
|
+
transaction_.type = Object.hasOwn(fromRpcType, transaction.type)
|
|
206
|
+
? fromRpcType[transaction.type as keyof typeof fromRpcType]
|
|
207
|
+
: (undefined as never)
|
|
201
208
|
|
|
202
|
-
if (
|
|
203
|
-
transaction_.authorizationList =
|
|
204
|
-
|
|
205
|
-
)
|
|
206
|
-
delete (transaction_ as any).aaAuthorizationList
|
|
207
|
-
}
|
|
209
|
+
if (aaAuthorizationList)
|
|
210
|
+
transaction_.authorizationList =
|
|
211
|
+
AuthorizationTempo.fromRpcList(aaAuthorizationList)
|
|
208
212
|
if (transaction.calls)
|
|
209
213
|
transaction_.calls = transaction.calls.map((call) => ({
|
|
210
214
|
to: call.to,
|
|
@@ -297,7 +301,9 @@ export function toRpc<pending extends boolean = false>(
|
|
|
297
301
|
transaction as ox_Transaction.Transaction<pending>,
|
|
298
302
|
) as Rpc<pending>
|
|
299
303
|
|
|
300
|
-
rpc.type = toRpcType
|
|
304
|
+
rpc.type = Object.hasOwn(toRpcType, transaction.type)
|
|
305
|
+
? toRpcType[transaction.type as keyof typeof toRpcType]
|
|
306
|
+
: (undefined as never)
|
|
301
307
|
|
|
302
308
|
if (transaction.authorizationList)
|
|
303
309
|
rpc.aaAuthorizationList = AuthorizationTempo.toRpcList(
|
|
@@ -102,9 +102,11 @@ export function fromRpc(request: Rpc): TransactionRequest {
|
|
|
102
102
|
|
|
103
103
|
if (typeof request.type !== 'undefined')
|
|
104
104
|
request_.type =
|
|
105
|
-
Transaction.fromRpcType
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
(Object.hasOwn(Transaction.fromRpcType, request.type) &&
|
|
106
|
+
Transaction.fromRpcType[
|
|
107
|
+
request.type as keyof typeof Transaction.fromRpcType
|
|
108
|
+
]) ||
|
|
109
|
+
request_.type
|
|
108
110
|
|
|
109
111
|
if (request.authorizationList)
|
|
110
112
|
request_.authorizationList = AuthorizationTempo.fromRpcList(
|
|
@@ -208,10 +210,31 @@ export declare namespace fromRpc {
|
|
|
208
210
|
* @returns An RPC request.
|
|
209
211
|
*/
|
|
210
212
|
export function toRpc(request: TransactionRequest): Rpc {
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
const tempo =
|
|
214
|
+
typeof request.accountSimulation !== 'undefined' ||
|
|
215
|
+
typeof request.calls !== 'undefined' ||
|
|
216
|
+
typeof request.feePayer !== 'undefined' ||
|
|
217
|
+
typeof request.feeToken !== 'undefined' ||
|
|
218
|
+
typeof request.keyAuthorization !== 'undefined' ||
|
|
219
|
+
typeof request.nonceKey !== 'undefined' ||
|
|
220
|
+
typeof request.validBefore !== 'undefined' ||
|
|
221
|
+
typeof request.validAfter !== 'undefined' ||
|
|
222
|
+
request.type === 'tempo'
|
|
223
|
+
|
|
224
|
+
// A Tempo request carries `data`, `to` and `value` in `calls`, so leave
|
|
225
|
+
// them out rather than deleting them afterwards.
|
|
226
|
+
const request_rpc = ox_TransactionRequest.toRpc(
|
|
227
|
+
tempo
|
|
228
|
+
? {
|
|
229
|
+
...request,
|
|
230
|
+
authorizationList: undefined,
|
|
231
|
+
data: undefined,
|
|
232
|
+
input: undefined,
|
|
233
|
+
to: undefined,
|
|
234
|
+
value: undefined,
|
|
235
|
+
}
|
|
236
|
+
: { ...request, authorizationList: undefined },
|
|
237
|
+
) as Rpc
|
|
215
238
|
|
|
216
239
|
if (request.authorizationList)
|
|
217
240
|
request_rpc.authorizationList = AuthorizationTempo.toRpcList(
|
|
@@ -258,23 +281,7 @@ export function toRpc(request: TransactionRequest): Rpc {
|
|
|
258
281
|
})()
|
|
259
282
|
if (nonceKey) request_rpc.nonceKey = nonceKey
|
|
260
283
|
|
|
261
|
-
if (
|
|
262
|
-
typeof request.accountSimulation !== 'undefined' ||
|
|
263
|
-
typeof request.calls !== 'undefined' ||
|
|
264
|
-
typeof request.feePayer !== 'undefined' ||
|
|
265
|
-
typeof request.feeToken !== 'undefined' ||
|
|
266
|
-
typeof request.keyAuthorization !== 'undefined' ||
|
|
267
|
-
typeof request.nonceKey !== 'undefined' ||
|
|
268
|
-
typeof request.validBefore !== 'undefined' ||
|
|
269
|
-
typeof request.validAfter !== 'undefined' ||
|
|
270
|
-
request.type === 'tempo'
|
|
271
|
-
) {
|
|
272
|
-
request_rpc.type = Transaction.toRpcType.tempo
|
|
273
|
-
delete request_rpc.data
|
|
274
|
-
delete request_rpc.input
|
|
275
|
-
delete request_rpc.to
|
|
276
|
-
delete request_rpc.value
|
|
277
|
-
}
|
|
284
|
+
if (tempo) request_rpc.type = Transaction.toRpcType.tempo
|
|
278
285
|
|
|
279
286
|
return request_rpc
|
|
280
287
|
}
|
|
@@ -618,6 +618,58 @@ describe('deserialize', () => {
|
|
|
618
618
|
expect(deserialized.feePayerSignature).toEqual(feePayerSig)
|
|
619
619
|
})
|
|
620
620
|
|
|
621
|
+
describe('sender marker', () => {
|
|
622
|
+
const signed = TxEnvelopeTempo.serialize(
|
|
623
|
+
{ ...transaction, feePayerSignature: null },
|
|
624
|
+
{
|
|
625
|
+
signature: Secp256k1.sign({
|
|
626
|
+
payload: TxEnvelopeTempo.getSignPayload({
|
|
627
|
+
...transaction,
|
|
628
|
+
feePayerSignature: null,
|
|
629
|
+
}),
|
|
630
|
+
privateKey,
|
|
631
|
+
}),
|
|
632
|
+
},
|
|
633
|
+
)
|
|
634
|
+
|
|
635
|
+
test('ignores sender and marker after the list', () => {
|
|
636
|
+
const serialized = Hex.concat(
|
|
637
|
+
signed,
|
|
638
|
+
address,
|
|
639
|
+
'0xfeefeefeefee',
|
|
640
|
+
) as TxEnvelopeTempo.Serialized
|
|
641
|
+
expect(TxEnvelopeTempo.deserialize(serialized)).toEqual(
|
|
642
|
+
TxEnvelopeTempo.deserialize(signed),
|
|
643
|
+
)
|
|
644
|
+
})
|
|
645
|
+
|
|
646
|
+
test('behavior: marker after other trailing bytes', () => {
|
|
647
|
+
const serialized = Hex.concat(
|
|
648
|
+
signed,
|
|
649
|
+
'0x00',
|
|
650
|
+
address,
|
|
651
|
+
'0xfeefeefeefee',
|
|
652
|
+
) as TxEnvelopeTempo.Serialized
|
|
653
|
+
expect(() =>
|
|
654
|
+
TxEnvelopeTempo.deserialize(serialized),
|
|
655
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
656
|
+
`[Rlp.TrailingBytesError: RLP payload encodes a single item, but \`27\` trailing bytes remain.]`,
|
|
657
|
+
)
|
|
658
|
+
})
|
|
659
|
+
|
|
660
|
+
test('behavior: marker without a sender', () => {
|
|
661
|
+
const serialized = Hex.concat(
|
|
662
|
+
signed,
|
|
663
|
+
'0xfeefeefeefee',
|
|
664
|
+
) as TxEnvelopeTempo.Serialized
|
|
665
|
+
expect(() =>
|
|
666
|
+
TxEnvelopeTempo.deserialize(serialized),
|
|
667
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
668
|
+
`[Rlp.TrailingBytesError: RLP payload encodes a single item, but \`6\` trailing bytes remain.]`,
|
|
669
|
+
)
|
|
670
|
+
})
|
|
671
|
+
})
|
|
672
|
+
|
|
621
673
|
test('feePayerSignature null', () => {
|
|
622
674
|
const transaction_feePayer = TxEnvelopeTempo.from({
|
|
623
675
|
...transaction,
|
package/tempo/TxEnvelopeTempo.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as AccessList from '../core/AccessList.js'
|
|
2
2
|
import * as Address from '../core/Address.js'
|
|
3
|
+
import * as Bytes from '../core/Bytes.js'
|
|
3
4
|
import * as Errors from '../core/Errors.js'
|
|
4
5
|
import * as Hash from '../core/Hash.js'
|
|
5
6
|
import * as Hex from '../core/Hex.js'
|
|
@@ -276,7 +277,9 @@ export declare namespace assert {
|
|
|
276
277
|
* @returns Deserialized Transaction Envelope.
|
|
277
278
|
*/
|
|
278
279
|
export function deserialize(serialized: Serialized): Compute<TxEnvelopeTempo> {
|
|
279
|
-
const transactionArray = Rlp.toHex(
|
|
280
|
+
const transactionArray = Rlp.toHex(
|
|
281
|
+
withoutSenderMarker(Hex.slice(serialized, 1)),
|
|
282
|
+
)
|
|
280
283
|
|
|
281
284
|
const [
|
|
282
285
|
chainId,
|
|
@@ -388,13 +391,13 @@ export function deserialize(serialized: Serialized): Compute<TxEnvelopeTempo> {
|
|
|
388
391
|
feePayerSignatureOrSender !== '0x' &&
|
|
389
392
|
feePayerSignatureOrSender !== undefined
|
|
390
393
|
) {
|
|
391
|
-
|
|
392
|
-
|
|
394
|
+
// A fee payer signature is a tuple, while a sender is an address string.
|
|
395
|
+
const sender =
|
|
396
|
+
typeof feePayerSignatureOrSender === 'string' &&
|
|
393
397
|
Address.validate(feePayerSignatureOrSender)
|
|
394
|
-
) {
|
|
398
|
+
if (feePayerSignatureOrSender === '0x00' || sender) {
|
|
395
399
|
transaction.feePayerSignature = null
|
|
396
|
-
if (
|
|
397
|
-
transaction.from = feePayerSignatureOrSender
|
|
400
|
+
if (sender) transaction.from = feePayerSignatureOrSender
|
|
398
401
|
} else
|
|
399
402
|
transaction.feePayerSignature = Signature.fromTuple(
|
|
400
403
|
feePayerSignatureOrSender as never,
|
|
@@ -435,6 +438,29 @@ export declare namespace deserialize {
|
|
|
435
438
|
type ErrorType = Errors.GlobalErrorType
|
|
436
439
|
}
|
|
437
440
|
|
|
441
|
+
/** Bytes after the RLP list in `rlp ‖ sender ‖ 0xfeefeefeefee`. */
|
|
442
|
+
const senderMarkerSize = 20 + 6
|
|
443
|
+
|
|
444
|
+
// Removes the `sender ‖ 0xfeefeefeefee` that follows the RLP list when a signed
|
|
445
|
+
// transaction is passed to a fee payer (e.g. by viem). The suffix is removed
|
|
446
|
+
// only when the list ends exactly before it, so any other trailing bytes are
|
|
447
|
+
// still rejected by `Rlp.toHex`.
|
|
448
|
+
function withoutSenderMarker(payload: Hex.Hex): Hex.Hex {
|
|
449
|
+
const size = Hex.size(payload)
|
|
450
|
+
if (size <= senderMarkerSize) return payload
|
|
451
|
+
if (payload.slice(-12).toLowerCase() !== 'feefeefeefee') return payload
|
|
452
|
+
|
|
453
|
+
// Read the list header (a prefix and up to 4 length bytes).
|
|
454
|
+
const header = Bytes.fromHex(Hex.slice(payload, 0, 5))
|
|
455
|
+
const prefix = header[0]!
|
|
456
|
+
if (prefix < 0xc0) return payload
|
|
457
|
+
const cursor = { bytes: header, position: 1 }
|
|
458
|
+
const length = Rlp.readLength(cursor, prefix, 0xc0)
|
|
459
|
+
if (cursor.position + length + senderMarkerSize !== size) return payload
|
|
460
|
+
|
|
461
|
+
return Hex.slice(payload, 0, -senderMarkerSize)
|
|
462
|
+
}
|
|
463
|
+
|
|
438
464
|
/**
|
|
439
465
|
* Converts an arbitrary transaction object into a Tempo Transaction Envelope.
|
|
440
466
|
*
|
package/tempo/ZoneId.test.ts
CHANGED
|
@@ -13,6 +13,17 @@ describe('fromChainId', () => {
|
|
|
13
13
|
)
|
|
14
14
|
})
|
|
15
15
|
|
|
16
|
+
test('other source chains', () => {
|
|
17
|
+
// Source chain 31318, zone 1: 31318 * 2^32 + 1.
|
|
18
|
+
expect(ZoneId.fromChainId(134_509_785_776_129)).toMatchInlineSnapshot(`1`)
|
|
19
|
+
expect(
|
|
20
|
+
ZoneId.fromChainId(134_509_785_776_129, 42_431),
|
|
21
|
+
).toMatchInlineSnapshot(`1`)
|
|
22
|
+
expect(ZoneId.fromChainId(2 ** 32 + 4_294_967_295)).toMatchInlineSnapshot(
|
|
23
|
+
`4294967295`,
|
|
24
|
+
)
|
|
25
|
+
})
|
|
26
|
+
|
|
16
27
|
test('unsupported source id', () => {
|
|
17
28
|
expect(() =>
|
|
18
29
|
// @ts-expect-error Unsupported source ID.
|
package/tempo/ZoneId.ts
CHANGED
|
@@ -13,6 +13,9 @@ const chainIdConfig = {
|
|
|
13
13
|
|
|
14
14
|
const defaultSourceId = 4_217
|
|
15
15
|
|
|
16
|
+
/** Chain IDs at or above this value carry their source chain ID in the high 32 bits. */
|
|
17
|
+
const genericChainIdBase = 2 ** 32
|
|
18
|
+
|
|
16
19
|
/**
|
|
17
20
|
* Base offset for deriving Presto zone chain IDs.
|
|
18
21
|
*/
|
|
@@ -24,7 +27,9 @@ export type SourceId = keyof typeof chainIdConfig
|
|
|
24
27
|
/**
|
|
25
28
|
* Derives a zone ID from a zone chain ID.
|
|
26
29
|
*
|
|
27
|
-
* Zone chain IDs use the base assigned to their Tempo source chain.
|
|
30
|
+
* Zone chain IDs use the base assigned to their Tempo source chain. Zones of other Tempo chains
|
|
31
|
+
* (such as devnets) encode the source chain ID in the high 32 bits and the zone ID in the low 32
|
|
32
|
+
* bits, so the zone ID is read from the chain ID alone.
|
|
28
33
|
*
|
|
29
34
|
* @example
|
|
30
35
|
* ```ts twoslash
|
|
@@ -42,6 +47,7 @@ export function fromChainId(
|
|
|
42
47
|
chainId: number,
|
|
43
48
|
sourceId: SourceId = defaultSourceId,
|
|
44
49
|
): number {
|
|
50
|
+
if (chainId >= genericChainIdBase) return chainId % genericChainIdBase
|
|
45
51
|
return chainId - getChainIdConfig(sourceId).base
|
|
46
52
|
}
|
|
47
53
|
|
|
@@ -26,7 +26,7 @@ export type Pool = {
|
|
|
26
26
|
): { postMessage(data: unknown): void; terminate(): void }
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
let cachedPool: Pool | undefined
|
|
29
|
+
let cachedPool: Promise<Pool | undefined> | undefined
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Whether the current runtime is Node.js.
|
|
@@ -42,10 +42,24 @@ const isNode =
|
|
|
42
42
|
*
|
|
43
43
|
* @internal
|
|
44
44
|
*/
|
|
45
|
-
export
|
|
45
|
+
export function resolve(): Promise<Pool | undefined> {
|
|
46
|
+
// The promise is cached rather than its result, so calls made while the
|
|
47
|
+
// pool resolves share it instead of each building a pool (and, in browsers,
|
|
48
|
+
// a Blob URL that is never revoked). A failed attempt, or one that found no
|
|
49
|
+
// pool, is discarded so a later call can retry.
|
|
46
50
|
if (cachedPool) return cachedPool
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
const promise = (isNode ? resolveNode() : resolveBrowser()).then(
|
|
52
|
+
(pool) => {
|
|
53
|
+
if (!pool && cachedPool === promise) cachedPool = undefined
|
|
54
|
+
return pool
|
|
55
|
+
},
|
|
56
|
+
(error) => {
|
|
57
|
+
if (cachedPool === promise) cachedPool = undefined
|
|
58
|
+
throw error
|
|
59
|
+
},
|
|
60
|
+
)
|
|
61
|
+
cachedPool = promise
|
|
62
|
+
return promise
|
|
49
63
|
}
|
|
50
64
|
|
|
51
65
|
/**
|
package/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '0.14.
|
|
2
|
+
export const version = '0.14.69'
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uid = uid;
|
|
4
|
-
const size = 256;
|
|
5
|
-
let index = size;
|
|
6
|
-
let buffer;
|
|
7
|
-
function uid(length = 11) {
|
|
8
|
-
if (!buffer || index + length > size * 2) {
|
|
9
|
-
buffer = '';
|
|
10
|
-
index = 0;
|
|
11
|
-
for (let i = 0; i < size; i++) {
|
|
12
|
-
buffer += ((256 + Math.random() * 256) | 0).toString(16).substring(1);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return buffer.substring(index, index++ + length);
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=uid.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uid.js","sourceRoot":"","sources":["../../../core/internal/uid.ts"],"names":[],"mappings":";;AAKA,kBASC;AAdD,MAAM,IAAI,GAAG,GAAG,CAAA;AAChB,IAAI,KAAK,GAAG,IAAI,CAAA;AAChB,IAAI,MAAc,CAAA;AAGlB,SAAgB,GAAG,CAAC,MAAM,GAAG,EAAE;IAC7B,IAAI,CAAC,MAAM,IAAI,KAAK,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,GAAG,EAAE,CAAA;QACX,KAAK,GAAG,CAAC,CAAA;QACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9B,MAAM,IAAI,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QACvE,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,CAAA;AAClD,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const size = 256;
|
|
2
|
-
let index = size;
|
|
3
|
-
let buffer;
|
|
4
|
-
/** @internal */
|
|
5
|
-
export function uid(length = 11) {
|
|
6
|
-
if (!buffer || index + length > size * 2) {
|
|
7
|
-
buffer = '';
|
|
8
|
-
index = 0;
|
|
9
|
-
for (let i = 0; i < size; i++) {
|
|
10
|
-
buffer += ((256 + Math.random() * 256) | 0).toString(16).substring(1);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return buffer.substring(index, index++ + length);
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=uid.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uid.js","sourceRoot":"","sources":["../../../core/internal/uid.ts"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,GAAG,CAAA;AAChB,IAAI,KAAK,GAAG,IAAI,CAAA;AAChB,IAAI,MAAc,CAAA;AAElB,gBAAgB;AAChB,MAAM,UAAU,GAAG,CAAC,MAAM,GAAG,EAAE;IAC7B,IAAI,CAAC,MAAM,IAAI,KAAK,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,GAAG,EAAE,CAAA;QACX,KAAK,GAAG,CAAC,CAAA;QACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9B,MAAM,IAAI,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QACvE,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,CAAA;AAClD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uid.d.ts","sourceRoot":"","sources":["../../../core/internal/uid.ts"],"names":[],"mappings":"AAIA,gBAAgB;AAChB,wBAAgB,GAAG,CAAC,MAAM,SAAK,UAS9B"}
|
package/core/internal/uid.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const size = 256
|
|
2
|
-
let index = size
|
|
3
|
-
let buffer: string
|
|
4
|
-
|
|
5
|
-
/** @internal */
|
|
6
|
-
export function uid(length = 11) {
|
|
7
|
-
if (!buffer || index + length > size * 2) {
|
|
8
|
-
buffer = ''
|
|
9
|
-
index = 0
|
|
10
|
-
for (let i = 0; i < size; i++) {
|
|
11
|
-
buffer += ((256 + Math.random() * 256) | 0).toString(16).substring(1)
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return buffer.substring(index, index++ + length)
|
|
15
|
-
}
|