ox 1.8.16 → 1.8.19
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 +70 -0
- package/dist/core/AbiError.d.ts +3 -3
- package/dist/core/AbiError.js +2 -2
- package/dist/core/AbiEvent.d.ts +3 -3
- package/dist/core/AbiEvent.d.ts.map +1 -1
- package/dist/core/AbiEvent.js +29 -24
- package/dist/core/AbiEvent.js.map +1 -1
- package/dist/core/AbiItem.d.ts.map +1 -1
- package/dist/core/AbiItem.js +15 -5
- package/dist/core/AbiItem.js.map +1 -1
- package/dist/core/AbiParameters.d.ts +1 -1
- package/dist/core/AbiParameters.d.ts.map +1 -1
- package/dist/core/AbiParameters.js +8 -2
- package/dist/core/AbiParameters.js.map +1 -1
- package/dist/core/Authorization.d.ts.map +1 -1
- package/dist/core/Authorization.js +6 -3
- package/dist/core/Authorization.js.map +1 -1
- package/dist/core/Base58.d.ts.map +1 -1
- package/dist/core/Base58.js +16 -4
- package/dist/core/Base58.js.map +1 -1
- package/dist/core/BinaryStateTree.js +3 -1
- package/dist/core/BinaryStateTree.js.map +1 -1
- package/dist/core/Blobs.d.ts +4 -5
- package/dist/core/Blobs.d.ts.map +1 -1
- package/dist/core/Blobs.js +40 -45
- package/dist/core/Blobs.js.map +1 -1
- package/dist/core/Block.d.ts +2 -0
- package/dist/core/Block.d.ts.map +1 -1
- package/dist/core/Block.js +1 -0
- package/dist/core/Block.js.map +1 -1
- package/dist/core/BlockOverrides.d.ts +3 -2
- package/dist/core/BlockOverrides.d.ts.map +1 -1
- package/dist/core/BlockOverrides.js +4 -2
- package/dist/core/BlockOverrides.js.map +1 -1
- package/dist/core/Bytes.d.ts.map +1 -1
- package/dist/core/Bytes.js +10 -2
- package/dist/core/Bytes.js.map +1 -1
- package/dist/core/Cbor.d.ts +13 -6
- package/dist/core/Cbor.d.ts.map +1 -1
- package/dist/core/Cbor.js +31 -18
- package/dist/core/Cbor.js.map +1 -1
- package/dist/core/Ens.d.ts +1 -1
- package/dist/core/Ens.js +3 -3
- package/dist/core/Ens.js.map +1 -1
- package/dist/core/FrameReceipt.d.ts.map +1 -1
- package/dist/core/FrameReceipt.js +4 -1
- package/dist/core/FrameReceipt.js.map +1 -1
- package/dist/core/Hash.d.ts +1 -1
- package/dist/core/Hash.js +1 -1
- package/dist/core/Hex.d.ts.map +1 -1
- package/dist/core/Hex.js +34 -31
- package/dist/core/Hex.js.map +1 -1
- package/dist/core/Rlp.d.ts +1 -1
- package/dist/core/Rlp.d.ts.map +1 -1
- package/dist/core/Rlp.js +107 -0
- package/dist/core/Rlp.js.map +1 -1
- package/dist/core/RpcTransport.d.ts.map +1 -1
- package/dist/core/RpcTransport.js +3 -1
- package/dist/core/RpcTransport.js.map +1 -1
- package/dist/core/Siwe.d.ts +1 -0
- package/dist/core/Siwe.d.ts.map +1 -1
- package/dist/core/Siwe.js +15 -8
- package/dist/core/Siwe.js.map +1 -1
- package/dist/core/Transaction.d.ts.map +1 -1
- package/dist/core/Transaction.js +9 -3
- package/dist/core/Transaction.js.map +1 -1
- package/dist/core/TransactionReceipt.d.ts.map +1 -1
- package/dist/core/TransactionReceipt.js +8 -2
- package/dist/core/TransactionReceipt.js.map +1 -1
- package/dist/core/TypedData.d.ts +2 -2
- package/dist/core/TypedData.d.ts.map +1 -1
- package/dist/core/TypedData.js +16 -4
- package/dist/core/TypedData.js.map +1 -1
- package/dist/core/internal/abiParameters.d.ts +3 -3
- package/dist/core/internal/abiParameters.d.ts.map +1 -1
- package/dist/core/internal/abiParameters.js +93 -68
- package/dist/core/internal/abiParameters.js.map +1 -1
- package/dist/core/internal/base58.d.ts.map +1 -1
- package/dist/core/internal/base58.js +9 -3
- package/dist/core/internal/base58.js.map +1 -1
- package/dist/core/internal/caches.d.ts +6 -0
- package/dist/core/internal/caches.d.ts.map +1 -1
- package/dist/core/internal/caches.js +3 -1
- package/dist/core/internal/caches.js.map +1 -1
- package/dist/core/internal/codec/hex.d.ts +13 -0
- package/dist/core/internal/codec/hex.d.ts.map +1 -1
- package/dist/core/internal/codec/hex.js +25 -2
- package/dist/core/internal/codec/hex.js.map +1 -1
- package/dist/core/internal/codec/int.d.ts.map +1 -1
- package/dist/core/internal/codec/int.js +48 -32
- package/dist/core/internal/codec/int.js.map +1 -1
- package/dist/core/internal/cursor.d.ts +11 -4
- package/dist/core/internal/cursor.d.ts.map +1 -1
- package/dist/core/internal/cursor.js +39 -15
- package/dist/core/internal/cursor.js.map +1 -1
- package/dist/core/internal/lru.d.ts +11 -12
- package/dist/core/internal/lru.d.ts.map +1 -1
- package/dist/core/internal/lru.js +22 -32
- package/dist/core/internal/lru.js.map +1 -1
- package/dist/core/internal/promise.d.ts.map +1 -1
- package/dist/core/internal/promise.js +13 -7
- package/dist/core/internal/promise.js.map +1 -1
- package/dist/erc6492/SignatureErc6492.d.ts +1 -1
- package/dist/erc6492/SignatureErc6492.d.ts.map +1 -1
- package/dist/erc6492/SignatureErc6492.js +1 -1
- package/dist/erc6492/SignatureErc6492.js.map +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.js +7 -41
- package/dist/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/tempo/TransactionReceipt.d.ts.map +1 -1
- package/dist/tempo/TransactionReceipt.js +4 -1
- package/dist/tempo/TransactionReceipt.js.map +1 -1
- package/dist/tempo/ZoneId.d.ts +3 -1
- package/dist/tempo/ZoneId.d.ts.map +1 -1
- package/dist/tempo/ZoneId.js +7 -1
- package/dist/tempo/ZoneId.js.map +1 -1
- package/dist/tempo/internal/virtualMasterPool.d.ts.map +1 -1
- package/dist/tempo/internal/virtualMasterPool.js +17 -6
- package/dist/tempo/internal/virtualMasterPool.js.map +1 -1
- package/dist/tempo/internal/webauthnData.d.ts +23 -0
- package/dist/tempo/internal/webauthnData.d.ts.map +1 -0
- package/dist/tempo/internal/webauthnData.js +75 -0
- package/dist/tempo/internal/webauthnData.js.map +1 -0
- package/dist/zod/Authorization.d.ts +14 -14
- package/dist/zod/Authorization.d.ts.map +1 -1
- package/dist/zod/Authorization.js +9 -2
- package/dist/zod/Authorization.js.map +1 -1
- package/dist/zod/Block.d.ts +12 -6
- package/dist/zod/Block.d.ts.map +1 -1
- package/dist/zod/Block.js +1 -0
- package/dist/zod/Block.js.map +1 -1
- package/dist/zod/BlockOverrides.d.ts.map +1 -1
- package/dist/zod/BlockOverrides.js +15 -4
- package/dist/zod/BlockOverrides.js.map +1 -1
- package/dist/zod/RpcSchema.d.ts +58 -46
- package/dist/zod/RpcSchema.d.ts.map +1 -1
- package/dist/zod/Signature.d.ts.map +1 -1
- package/dist/zod/Signature.js +2 -1
- package/dist/zod/Signature.js.map +1 -1
- package/dist/zod/Transaction.d.ts +12 -12
- package/dist/zod/TransactionEnvelope.d.ts +8 -8
- package/dist/zod/TransactionRequest.d.ts +4 -4
- package/dist/zod/TxEnvelopeEip7702.d.ts +8 -8
- package/dist/zod/TypedData.d.ts +4 -4
- package/dist/zod/internal/rpcSchemas/Eth.d.ts +58 -46
- package/dist/zod/internal/rpcSchemas/Eth.d.ts.map +1 -1
- package/dist/zod/internal/rpcSchemas/Wallet.d.ts +4 -4
- package/dist/zod/tempo/RpcSchemaTempo.d.ts +16 -8
- package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.js +5 -15
- package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/zod/tempo/Transaction.d.ts +6 -6
- package/package.json +2 -2
- package/src/core/AbiError.ts +3 -3
- package/src/core/AbiEvent.bench.ts +45 -0
- package/src/core/AbiEvent.ts +32 -25
- package/src/core/AbiFunction.bench.ts +16 -0
- package/src/core/AbiItem.ts +13 -4
- package/src/core/AbiParameters.bench.ts +33 -0
- package/src/core/AbiParameters.ts +8 -1
- package/src/core/Authorization.ts +6 -3
- package/src/core/Base58.bench.ts +28 -0
- package/src/core/Base58.ts +15 -4
- package/src/core/BinaryStateTree.ts +4 -1
- package/src/core/Blobs.bench.ts +40 -0
- package/src/core/Blobs.ts +49 -57
- package/src/core/Block.ts +3 -0
- package/src/core/BlockOverrides.ts +7 -3
- package/src/core/Bytes.bench.ts +34 -0
- package/src/core/Bytes.ts +10 -2
- package/src/core/Cbor.ts +36 -14
- package/src/core/Ens.ts +3 -3
- package/src/core/FrameReceipt.ts +4 -1
- package/src/core/Hash.ts +1 -1
- package/src/core/Hex.bench.ts +17 -0
- package/src/core/Hex.ts +29 -32
- package/src/core/Rlp.ts +139 -1
- package/src/core/Rlp_tx.bench.ts +55 -0
- package/src/core/RpcTransport.ts +3 -1
- package/src/core/Siwe.ts +18 -8
- package/src/core/Transaction.ts +9 -3
- package/src/core/TransactionReceipt.ts +8 -2
- package/src/core/TypedData.bench.ts +50 -0
- package/src/core/TypedData.ts +16 -4
- package/src/core/_test/AbiEvent.test.ts +83 -0
- package/src/core/_test/AbiFunction.test.ts +7 -6
- package/src/core/_test/AbiParameters.decode.test.ts +34 -1
- package/src/core/_test/AbiParameters.encode.test.ts +10 -0
- package/src/core/_test/AbiParameters.test.ts +15 -0
- package/src/core/_test/Authorization.test.ts +36 -0
- package/src/core/_test/BinaryStateTree.test.ts +35 -0
- package/src/core/_test/Block.test.ts +54 -0
- package/src/core/_test/BlockOverrides.test.ts +14 -1
- package/src/core/_test/Bytes.test.ts +33 -0
- package/src/core/_test/Caches.test.ts +20 -1
- package/src/core/_test/Cbor.test.ts +26 -0
- package/src/core/_test/FrameReceipt.test.ts +13 -0
- package/src/core/_test/Rlp.fuzz.ts +55 -1
- package/src/core/_test/Rlp.test.ts +64 -0
- package/src/core/_test/RpcTransport.test.ts +15 -2
- package/src/core/_test/Siwe.test.ts +126 -1
- package/src/core/_test/Transaction.test.ts +47 -2
- package/src/core/_test/TransactionEnvelopeEip7702.test.ts +2 -2
- package/src/core/_test/TransactionReceipt.test.ts +41 -0
- package/src/core/_test/TypedData.test.ts +19 -0
- package/src/core/_test/internal/cursor.test.ts +42 -6
- package/src/core/internal/abiParameters.ts +117 -80
- package/src/core/internal/base58.ts +9 -3
- package/src/core/internal/caches.ts +3 -1
- package/src/core/internal/codec/hex.ts +27 -2
- package/src/core/internal/codec/int.ts +45 -32
- package/src/core/internal/cursor.ts +52 -23
- package/src/core/internal/lru.ts +21 -35
- package/src/core/internal/promise.ts +11 -5
- package/src/erc4337/_test/UserOperation.test.ts +2 -2
- package/src/erc6492/SignatureErc6492.ts +1 -1
- package/src/erc6492/_test/SignatureErc6492.test.ts +48 -1
- package/src/tempo/SignatureEnvelope.test.ts +89 -1
- package/src/tempo/SignatureEnvelope.ts +7 -43
- package/src/tempo/TransactionReceipt.test.ts +8 -0
- package/src/tempo/TransactionReceipt.ts +4 -1
- package/src/tempo/VirtualMaster.bench.ts +7 -0
- package/src/tempo/ZoneId.test.ts +11 -0
- package/src/tempo/ZoneId.ts +7 -1
- package/src/tempo/internal/virtualMasterPool.ts +20 -6
- package/src/tempo/internal/webauthnData.ts +84 -0
- package/src/version.ts +1 -1
- package/src/zod/Authorization.ts +10 -2
- package/src/zod/Block.ts +1 -0
- package/src/zod/BlockOverrides.ts +26 -7
- package/src/zod/Signature.ts +2 -1
- package/src/zod/_test/Authorization.test.ts +26 -0
- package/src/zod/_test/Block.test-d.ts +6 -0
- package/src/zod/_test/Block.test.ts +5 -0
- package/src/zod/_test/BlockOverrides.test.ts +36 -1
- package/src/zod/_test/Signature.test.ts +12 -0
- package/src/zod/tempo/SignatureEnvelope.ts +7 -16
- package/src/zod/tempo/_test/SignatureEnvelope.test.ts +37 -1
- package/src/core/_test/internal/lru.test.ts +0 -38
- package/src/core/_test/internal/uid.test.ts +0 -7
- package/src/core/internal/uid.ts +0 -15
|
@@ -430,16 +430,59 @@ describe('createMessage', () => {
|
|
|
430
430
|
`)
|
|
431
431
|
})
|
|
432
432
|
|
|
433
|
+
test('behavior: invalid scheme (comma)', () => {
|
|
434
|
+
expect(() => Siwe.createMessage({ ...message, scheme: 'ht,tps' }))
|
|
435
|
+
.toThrowErrorMatchingInlineSnapshot(`
|
|
436
|
+
[Siwe.InvalidMessageFieldError: Invalid Sign-In with Ethereum message field "scheme".
|
|
437
|
+
|
|
438
|
+
- Scheme must be an RFC 3986 URI scheme.
|
|
439
|
+
- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1
|
|
440
|
+
|
|
441
|
+
Provided value: ht,tps]
|
|
442
|
+
`)
|
|
443
|
+
for (const scheme of ['https', 'a+b', 'a-b', 'a.b'])
|
|
444
|
+
expect(() => Siwe.createMessage({ ...message, scheme })).not.toThrow()
|
|
445
|
+
})
|
|
446
|
+
|
|
433
447
|
test('behavior: invalid statement', () => {
|
|
434
448
|
expect(() => Siwe.createMessage({ ...message, statement: 'foo\nbar' }))
|
|
435
449
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
436
450
|
[Siwe.InvalidMessageFieldError: Invalid Sign-In with Ethereum message field "statement".
|
|
437
451
|
|
|
438
|
-
- Statement must not include '\\n'.
|
|
452
|
+
- Statement must not include a line break ('\\n', '\\r', '\\u2028' or '\\u2029').
|
|
439
453
|
|
|
440
454
|
Provided value: foo
|
|
441
455
|
bar]
|
|
442
456
|
`)
|
|
457
|
+
expect(() =>
|
|
458
|
+
Siwe.createMessage({
|
|
459
|
+
...message,
|
|
460
|
+
statement: 'foo\rURI: https://evil.example',
|
|
461
|
+
}),
|
|
462
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
463
|
+
[Siwe.InvalidMessageFieldError: Invalid Sign-In with Ethereum message field "statement".
|
|
464
|
+
|
|
465
|
+
- Statement must not include a line break ('\\n', '\\r', '\\u2028' or '\\u2029').
|
|
466
|
+
|
|
467
|
+
Provided value: foo
|
|
468
|
+
URI: https://evil.example]
|
|
469
|
+
`)
|
|
470
|
+
expect(() => Siwe.createMessage({ ...message, statement: 'foo\u2028bar' }))
|
|
471
|
+
.toThrowErrorMatchingInlineSnapshot(`
|
|
472
|
+
[Siwe.InvalidMessageFieldError: Invalid Sign-In with Ethereum message field "statement".
|
|
473
|
+
|
|
474
|
+
- Statement must not include a line break ('\\n', '\\r', '\\u2028' or '\\u2029').
|
|
475
|
+
|
|
476
|
+
Provided value: foo
bar]
|
|
477
|
+
`)
|
|
478
|
+
expect(() => Siwe.createMessage({ ...message, statement: 'foo\u2029bar' }))
|
|
479
|
+
.toThrowErrorMatchingInlineSnapshot(`
|
|
480
|
+
[Siwe.InvalidMessageFieldError: Invalid Sign-In with Ethereum message field "statement".
|
|
481
|
+
|
|
482
|
+
- Statement must not include a line break ('\\n', '\\r', '\\u2028' or '\\u2029').
|
|
483
|
+
|
|
484
|
+
Provided value: foo
bar]
|
|
485
|
+
`)
|
|
443
486
|
})
|
|
444
487
|
|
|
445
488
|
test('behavior: invalid requestId', () => {
|
|
@@ -492,6 +535,10 @@ describe('createMessage', () => {
|
|
|
492
535
|
// 63 octets: "xn--" plus 59 LDH characters.
|
|
493
536
|
`example.xn--${'a'.repeat(59)}`,
|
|
494
537
|
`example.${'a'.repeat(63)}`,
|
|
538
|
+
'[::cafe]',
|
|
539
|
+
'[::1]:3000',
|
|
540
|
+
'[2001:db8::1]:443',
|
|
541
|
+
'[v1.fe]',
|
|
495
542
|
])('valid domain `%s`', (domain) => {
|
|
496
543
|
expect(
|
|
497
544
|
Siwe.createMessage({
|
|
@@ -517,6 +564,14 @@ describe('createMessage', () => {
|
|
|
517
564
|
// 64 octets: one past the maximum label length.
|
|
518
565
|
`example.xn--${'a'.repeat(60)}`,
|
|
519
566
|
`example.${'a'.repeat(64)}`,
|
|
567
|
+
'[::1',
|
|
568
|
+
'[zzz]',
|
|
569
|
+
'[::300.0.0.0]',
|
|
570
|
+
'[::1]:123456',
|
|
571
|
+
'user@[::1]',
|
|
572
|
+
'[::\t1]',
|
|
573
|
+
'[evil.com@[::1]',
|
|
574
|
+
'[a@[::1]',
|
|
520
575
|
])('invalid domain `%s`', (domain) => {
|
|
521
576
|
expect(() =>
|
|
522
577
|
Siwe.createMessage({
|
|
@@ -599,6 +654,31 @@ describe('isUri', () => {
|
|
|
599
654
|
expect(Siwe.isUri(uri)).toMatchInlineSnapshot(`false`)
|
|
600
655
|
})
|
|
601
656
|
|
|
657
|
+
test('behavior: authority variants with path', () => {
|
|
658
|
+
expect([
|
|
659
|
+
Siwe.isUri('https://[2001:db8::1]/login'),
|
|
660
|
+
Siwe.isUri('https://user:pass@example.com:8080/login'),
|
|
661
|
+
Siwe.isUri('foo://[v1.fe]/p'),
|
|
662
|
+
]).toMatchInlineSnapshot(`
|
|
663
|
+
[
|
|
664
|
+
"https://[2001:db8::1]/login",
|
|
665
|
+
"https://user:pass@example.com:8080/login",
|
|
666
|
+
"foo://[v1.fe]/p",
|
|
667
|
+
]
|
|
668
|
+
`)
|
|
669
|
+
})
|
|
670
|
+
|
|
671
|
+
test.each([
|
|
672
|
+
// https://github.com/spruceid/siwe/blob/main/test/invalid_uris.json
|
|
673
|
+
'uri://[::0.0.0.256]/p/path',
|
|
674
|
+
'uri://[::300.0.0.0]/p/path',
|
|
675
|
+
'https://example.com:bad/login',
|
|
676
|
+
'https://[:::]/login',
|
|
677
|
+
'https://[::1/login',
|
|
678
|
+
])('behavior: invalid authority with path `%s`', (uri) => {
|
|
679
|
+
expect(Siwe.isUri(uri)).toMatchInlineSnapshot(`false`)
|
|
680
|
+
})
|
|
681
|
+
|
|
602
682
|
test('behavior: check for illegal characters', () => {
|
|
603
683
|
expect(Siwe.isUri('^')).toBeFalsy()
|
|
604
684
|
})
|
|
@@ -673,6 +753,30 @@ Issued At: 2023-02-01T00:00:00.000Z`
|
|
|
673
753
|
expect(parsed.scheme).toMatchInlineSnapshot(`"https"`)
|
|
674
754
|
})
|
|
675
755
|
|
|
756
|
+
test('behavior: scheme with a comma', () => {
|
|
757
|
+
const message = `ht,tps://example.com wants you to sign in with your Ethereum account:
|
|
758
|
+
0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
|
|
759
|
+
|
|
760
|
+
URI: https://example.com/path
|
|
761
|
+
Version: 1
|
|
762
|
+
Chain ID: 1
|
|
763
|
+
Nonce: foobarbaz
|
|
764
|
+
Issued At: 2023-02-01T00:00:00.000Z`
|
|
765
|
+
expect(Siwe.parseMessage(message)).toEqual({})
|
|
766
|
+
expect(
|
|
767
|
+
['https', 'a+b', 'a-b', 'a.b'].map(
|
|
768
|
+
(scheme) => Siwe.parseMessage(message.replace('ht,tps', scheme)).scheme,
|
|
769
|
+
),
|
|
770
|
+
).toMatchInlineSnapshot(`
|
|
771
|
+
[
|
|
772
|
+
"https",
|
|
773
|
+
"a+b",
|
|
774
|
+
"a-b",
|
|
775
|
+
"a.b",
|
|
776
|
+
]
|
|
777
|
+
`)
|
|
778
|
+
})
|
|
779
|
+
|
|
676
780
|
test('behavior: domain with port', () => {
|
|
677
781
|
const message = `example.com:8080 wants you to sign in with your Ethereum account:
|
|
678
782
|
0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
|
|
@@ -686,6 +790,22 @@ Issued At: 2023-02-01T00:00:00.000Z`
|
|
|
686
790
|
expect(parsed.domain).toMatchInlineSnapshot(`"example.com:8080"`)
|
|
687
791
|
})
|
|
688
792
|
|
|
793
|
+
test('behavior: ip literal domain', () => {
|
|
794
|
+
// https://github.com/spruceid/siwe/blob/main/test/parsing_positive.json
|
|
795
|
+
const message = `[::cafe] wants you to sign in with your Ethereum account:
|
|
796
|
+
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
URI: https://service.org/login
|
|
800
|
+
Version: 1
|
|
801
|
+
Chain ID: 1
|
|
802
|
+
Nonce: 32891757
|
|
803
|
+
Issued At: 2021-09-30T16:25:24.000Z`
|
|
804
|
+
const parsed = Siwe.parseMessage(message)
|
|
805
|
+
expect(parsed.domain).toMatchInlineSnapshot(`"[::cafe]"`)
|
|
806
|
+
expect(Siwe.createMessage(parsed as Siwe.Message)).toBe(message)
|
|
807
|
+
})
|
|
808
|
+
|
|
689
809
|
test('behavior: with statement', () => {
|
|
690
810
|
const message = `example.com wants you to sign in with your Ethereum account:
|
|
691
811
|
0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
|
|
@@ -1211,6 +1331,11 @@ Issued At: 2023-02-01T00:00:00.000Z`)
|
|
|
1211
1331
|
).toBeFalsy()
|
|
1212
1332
|
})
|
|
1213
1333
|
|
|
1334
|
+
test('behavior: scheme defaults to https when omitted', () => {
|
|
1335
|
+
expect(Siwe.validateMessage({ scheme: 'https', message })).toBeTruthy()
|
|
1336
|
+
expect(Siwe.validateMessage({ scheme: 'http', message })).toBeFalsy()
|
|
1337
|
+
})
|
|
1338
|
+
|
|
1214
1339
|
test('behavior: time is after expirationTime', () => {
|
|
1215
1340
|
expect(
|
|
1216
1341
|
Siwe.validateMessage({
|
|
@@ -13,6 +13,23 @@ import { accounts } from '../../../test/constants/accounts.js'
|
|
|
13
13
|
import { anvilMainnet } from '../../../test/prool.js'
|
|
14
14
|
|
|
15
15
|
describe('fromRpc', () => {
|
|
16
|
+
test('behavior: unknown type named like an `Object.prototype` key', () => {
|
|
17
|
+
const transaction = Transaction.fromRpc({
|
|
18
|
+
blockHash: null,
|
|
19
|
+
blockNumber: null,
|
|
20
|
+
from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
21
|
+
gas: '0x5208',
|
|
22
|
+
hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
|
|
23
|
+
input: '0x',
|
|
24
|
+
nonce: '0x0',
|
|
25
|
+
to: null,
|
|
26
|
+
transactionIndex: null,
|
|
27
|
+
type: 'constructor',
|
|
28
|
+
value: '0x0',
|
|
29
|
+
} as unknown as Transaction.Rpc)
|
|
30
|
+
expect(transaction.type).toMatchInlineSnapshot(`"constructor"`)
|
|
31
|
+
})
|
|
32
|
+
|
|
16
33
|
describe('legacy', () => {
|
|
17
34
|
test('default', () => {
|
|
18
35
|
expect(
|
|
@@ -1182,7 +1199,7 @@ describe('toRpc', () => {
|
|
|
1182
1199
|
"to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
|
|
1183
1200
|
"transactionIndex": "0x2",
|
|
1184
1201
|
"type": "0x0",
|
|
1185
|
-
"v": "
|
|
1202
|
+
"v": "0x0",
|
|
1186
1203
|
"value": "0x0",
|
|
1187
1204
|
"yParity": "0x0",
|
|
1188
1205
|
}
|
|
@@ -1230,7 +1247,7 @@ describe('toRpc', () => {
|
|
|
1230
1247
|
"to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
|
|
1231
1248
|
"transactionIndex": null,
|
|
1232
1249
|
"type": "0x0",
|
|
1233
|
-
"v": "
|
|
1250
|
+
"v": "0x0",
|
|
1234
1251
|
"value": "0xde0b6b3a7640000",
|
|
1235
1252
|
"yParity": "0x0",
|
|
1236
1253
|
}
|
|
@@ -1260,6 +1277,34 @@ describe('toRpc', () => {
|
|
|
1260
1277
|
})
|
|
1261
1278
|
expect(rpc.transactionIndex).toBe('0x0')
|
|
1262
1279
|
})
|
|
1280
|
+
|
|
1281
|
+
test('behavior: eip-155 v above 255', () => {
|
|
1282
|
+
// Polygon (chain ID 137) legacy transaction: `v = 137 * 2 + 35 + 1`.
|
|
1283
|
+
const rpc = {
|
|
1284
|
+
blockHash:
|
|
1285
|
+
'0x330e81a536bc43032035e696a9e5c88630d23e67b12051c0b620b350fbedd63a',
|
|
1286
|
+
blockNumber: '0x5ce8dff',
|
|
1287
|
+
chainId: '0x89',
|
|
1288
|
+
from: '0x58a62fbc2cd2353678784c08cccd73b0dc6d0486',
|
|
1289
|
+
gas: '0xaae60',
|
|
1290
|
+
gasPrice: '0xc23b0a3d0f',
|
|
1291
|
+
hash: '0xfa6c61184fac71fe4caa776aaaac01e73733c797933030ce89cee596f3a63d5d',
|
|
1292
|
+
input: '0xcf1393d9',
|
|
1293
|
+
nonce: '0xa7d2',
|
|
1294
|
+
r: '0xf998579579c97427c7a29412c659b27f31c1e59d27c7a9fbb6feb0b3bb379314',
|
|
1295
|
+
s: '0x2bf54bfd95b30c1390c10cfaccb50b069fff7bee0a89a9234ab7dc06786bb73a',
|
|
1296
|
+
to: '0x5c8138fa7d7a9c1e313931ad44a13969d05e3274',
|
|
1297
|
+
transactionIndex: '0x1',
|
|
1298
|
+
type: '0x0',
|
|
1299
|
+
v: '0x136',
|
|
1300
|
+
value: '0x0',
|
|
1301
|
+
} as const
|
|
1302
|
+
const { yParity, ...rest } = Transaction.toRpc(
|
|
1303
|
+
Transaction.fromRpc(rpc),
|
|
1304
|
+
) as Transaction.LegacyRpc
|
|
1305
|
+
expect(yParity).toBe('0x1')
|
|
1306
|
+
expect(rest).toEqual(rpc)
|
|
1307
|
+
})
|
|
1263
1308
|
})
|
|
1264
1309
|
|
|
1265
1310
|
describe('eip1559', () => {
|
|
@@ -1139,8 +1139,8 @@ describe('toRpc', () => {
|
|
|
1139
1139
|
"address": "0x70997970c51812dc3a010c7d01b50e0d17dc79c8",
|
|
1140
1140
|
"chainId": "0x1",
|
|
1141
1141
|
"nonce": "0x0",
|
|
1142
|
-
"r": "
|
|
1143
|
-
"s": "
|
|
1142
|
+
"r": "0x1",
|
|
1143
|
+
"s": "0x2",
|
|
1144
1144
|
"yParity": "0x0",
|
|
1145
1145
|
},
|
|
1146
1146
|
],
|
|
@@ -4,6 +4,47 @@ import { describe, expect, test } from 'vp/test'
|
|
|
4
4
|
import { anvilMainnet } from '../../../test/prool.js'
|
|
5
5
|
|
|
6
6
|
describe('fromRpc', () => {
|
|
7
|
+
test('behavior: unknown status and type named like `Object.prototype` keys', () => {
|
|
8
|
+
const { frameReceipts, status, type } = TransactionReceipt.fromRpc({
|
|
9
|
+
blockHash:
|
|
10
|
+
'0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
|
|
11
|
+
blockNumber: '0x12f296f',
|
|
12
|
+
contractAddress: null,
|
|
13
|
+
cumulativeGasUsed: '0x82515',
|
|
14
|
+
effectiveGasPrice: '0x21c2f6c09',
|
|
15
|
+
frameReceipts: [
|
|
16
|
+
{
|
|
17
|
+
executionGasUsed: '0x0',
|
|
18
|
+
gasUsed: '0x0',
|
|
19
|
+
logs: [],
|
|
20
|
+
stateGasUsed: '0x0',
|
|
21
|
+
status: 'constructor',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
25
|
+
gasUsed: '0x2abba',
|
|
26
|
+
logs: [],
|
|
27
|
+
logsBloom: '0x',
|
|
28
|
+
status: '__proto__',
|
|
29
|
+
to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
|
|
30
|
+
transactionHash:
|
|
31
|
+
'0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
|
|
32
|
+
transactionIndex: '0x2',
|
|
33
|
+
type: 'toString',
|
|
34
|
+
} as unknown as TransactionReceipt.Rpc)
|
|
35
|
+
expect({
|
|
36
|
+
frameStatus: frameReceipts?.[0]?.status,
|
|
37
|
+
status,
|
|
38
|
+
type,
|
|
39
|
+
}).toMatchInlineSnapshot(`
|
|
40
|
+
{
|
|
41
|
+
"frameStatus": undefined,
|
|
42
|
+
"status": undefined,
|
|
43
|
+
"type": "toString",
|
|
44
|
+
}
|
|
45
|
+
`)
|
|
46
|
+
})
|
|
47
|
+
|
|
7
48
|
test('default', () => {
|
|
8
49
|
const receipt = TransactionReceipt.fromRpc({
|
|
9
50
|
blobGasPrice: '0x42069',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Hex, TypedData } from 'ox'
|
|
2
2
|
import { describe, expect, test } from 'vp/test'
|
|
3
3
|
import * as typedData from '../../../test/constants/typedData.js'
|
|
4
|
+
import { caches } from '../internal/caches.js'
|
|
4
5
|
|
|
5
6
|
describe('assert', () => {
|
|
6
7
|
test('default', () => {
|
|
@@ -1486,6 +1487,24 @@ describe('hashStruct', () => {
|
|
|
1486
1487
|
}),
|
|
1487
1488
|
).toBe(hash)
|
|
1488
1489
|
})
|
|
1490
|
+
|
|
1491
|
+
test('behavior: long encoded types are not kept in the global cache', () => {
|
|
1492
|
+
caches.typeHash.clear()
|
|
1493
|
+
const fields = Array.from({ length: 300 }, (_, i) => ({
|
|
1494
|
+
name: 'field' + i,
|
|
1495
|
+
type: 'uint256',
|
|
1496
|
+
}))
|
|
1497
|
+
const data = Object.fromEntries(fields.map(({ name }) => [name, 1n]))
|
|
1498
|
+
TypedData.hashStruct({ data, primaryType: 'Long', types: { Long: fields } })
|
|
1499
|
+
expect(caches.typeHash.size).toBe(0)
|
|
1500
|
+
|
|
1501
|
+
TypedData.hashStruct({
|
|
1502
|
+
...typedData.basic,
|
|
1503
|
+
primaryType: 'Mail',
|
|
1504
|
+
data: typedData.basic.message,
|
|
1505
|
+
})
|
|
1506
|
+
expect(caches.typeHash.size).toBeGreaterThan(0)
|
|
1507
|
+
})
|
|
1489
1508
|
})
|
|
1490
1509
|
|
|
1491
1510
|
describe('serialize', () => {
|
|
@@ -614,7 +614,7 @@ test('remaining', () => {
|
|
|
614
614
|
describe('readSizeLimit', () => {
|
|
615
615
|
test('default', () => {
|
|
616
616
|
const cursor = Cursor.create(new Uint8Array(generateBytes(420)))
|
|
617
|
-
expect(cursor.readSizeLimit).toMatchInlineSnapshot(`
|
|
617
|
+
expect(cursor.readSizeLimit).toMatchInlineSnapshot(`262984`)
|
|
618
618
|
|
|
619
619
|
cursor.readBytes(420)
|
|
620
620
|
cursor.setPosition(0)
|
|
@@ -626,15 +626,15 @@ describe('readSizeLimit', () => {
|
|
|
626
626
|
const cursor = Cursor.create(new Uint8Array(generateBytes(420)), {
|
|
627
627
|
recursiveReadLimit: 2,
|
|
628
628
|
})
|
|
629
|
-
expect(cursor.readSizeLimit).toMatchInlineSnapshot(`
|
|
629
|
+
expect(cursor.readSizeLimit).toMatchInlineSnapshot(`904`)
|
|
630
630
|
|
|
631
|
-
for (let i = 0; i <
|
|
631
|
+
for (let i = 0; i < 2; i++) {
|
|
632
632
|
cursor.setPosition(i)
|
|
633
633
|
cursor.readBytes(420 - i)
|
|
634
634
|
}
|
|
635
|
-
cursor.setPosition(
|
|
636
|
-
expect(() => cursor.readBytes(
|
|
637
|
-
`[Cursor.ReadSizeLimitExceededError: Read size limit of \`
|
|
635
|
+
cursor.setPosition(2)
|
|
636
|
+
expect(() => cursor.readBytes(418)).toThrowErrorMatchingInlineSnapshot(
|
|
637
|
+
`[Cursor.ReadSizeLimitExceededError: Read size limit of \`904\` bytes exceeded (read size: \`1257\` bytes).]`,
|
|
638
638
|
)
|
|
639
639
|
})
|
|
640
640
|
|
|
@@ -681,4 +681,40 @@ describe('args: recursiveReadLimit', () => {
|
|
|
681
681
|
'[Cursor.RecursiveReadLimitExceededError: Recursive read limit of `2` exceeded (recursive read count: `3`).]',
|
|
682
682
|
)
|
|
683
683
|
})
|
|
684
|
+
|
|
685
|
+
test('behavior: repeated reads at an unaligned position', () => {
|
|
686
|
+
const cursor = Cursor.create(new Uint8Array(generateBytes(420)), {
|
|
687
|
+
recursiveReadLimit: 2,
|
|
688
|
+
})
|
|
689
|
+
|
|
690
|
+
for (let i = 0; i < 3; i++) {
|
|
691
|
+
cursor.setPosition(37)
|
|
692
|
+
cursor.readBytes(10)
|
|
693
|
+
}
|
|
694
|
+
cursor.setPosition(37)
|
|
695
|
+
expect(() => cursor.readBytes(10)).toThrowErrorMatchingInlineSnapshot(
|
|
696
|
+
`[Cursor.RecursiveReadLimitExceededError: Recursive read limit of \`2\` exceeded (recursive read count: \`3\`).]`,
|
|
697
|
+
)
|
|
698
|
+
})
|
|
699
|
+
|
|
700
|
+
test('behavior: repeated reads past the length the data had at creation', () => {
|
|
701
|
+
const buffer = new (ArrayBuffer as any)(32, { maxByteLength: 4096 })
|
|
702
|
+
const bytes = new Uint8Array(buffer)
|
|
703
|
+
const cursor = Cursor.create(bytes, { recursiveReadLimit: 2 })
|
|
704
|
+
|
|
705
|
+
cursor.readBytes(32)
|
|
706
|
+
buffer.resize(4096)
|
|
707
|
+
for (let i = 0; i < 3; i++) {
|
|
708
|
+
cursor.setPosition(2048)
|
|
709
|
+
cursor.readBytes(32)
|
|
710
|
+
}
|
|
711
|
+
cursor.setPosition(2048)
|
|
712
|
+
expect(() => cursor.readBytes(32)).toThrowError(
|
|
713
|
+
'Recursive read limit of ' +
|
|
714
|
+
String.fromCharCode(96) +
|
|
715
|
+
'2' +
|
|
716
|
+
String.fromCharCode(96) +
|
|
717
|
+
' exceeded',
|
|
718
|
+
)
|
|
719
|
+
})
|
|
684
720
|
})
|