ox 0.14.63 → 0.14.65
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 +42 -0
- package/_cjs/core/AbiError.js +6 -2
- package/_cjs/core/AbiError.js.map +1 -1
- package/_cjs/core/AbiEvent.js +4 -0
- package/_cjs/core/AbiEvent.js.map +1 -1
- package/_cjs/core/AbiFunction.js +2 -2
- package/_cjs/core/AbiFunction.js.map +1 -1
- package/_cjs/core/AbiItem.js +6 -7
- package/_cjs/core/AbiItem.js.map +1 -1
- package/_cjs/core/Base32.js +15 -1
- package/_cjs/core/Base32.js.map +1 -1
- package/_cjs/core/Bytes.js +4 -5
- package/_cjs/core/Bytes.js.map +1 -1
- package/_cjs/core/Cbor.js +13 -2
- package/_cjs/core/Cbor.js.map +1 -1
- package/_cjs/core/Hex.js +2 -3
- package/_cjs/core/Hex.js.map +1 -1
- package/_cjs/core/Rlp.js +49 -8
- package/_cjs/core/Rlp.js.map +1 -1
- package/_cjs/core/RpcTransport.js +9 -4
- package/_cjs/core/RpcTransport.js.map +1 -1
- package/_cjs/core/Siwe.js +4 -0
- package/_cjs/core/Siwe.js.map +1 -1
- package/_cjs/core/TypedData.js +2 -2
- package/_cjs/core/TypedData.js.map +1 -1
- package/_cjs/core/internal/abiItem.js +1 -1
- package/_cjs/core/internal/abiItem.js.map +1 -1
- package/_cjs/erc4337/UserOperation.js +7 -4
- package/_cjs/erc4337/UserOperation.js.map +1 -1
- package/_cjs/erc8021/Attribution.js +13 -3
- package/_cjs/erc8021/Attribution.js.map +1 -1
- package/_cjs/tempo/SignaturePreAuthorized.js +177 -0
- package/_cjs/tempo/SignaturePreAuthorized.js.map +1 -0
- package/_cjs/tempo/Tick.js +3 -2
- package/_cjs/tempo/Tick.js.map +1 -1
- package/_cjs/tempo/index.js +2 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/core/AbiError.js +6 -2
- package/_esm/core/AbiError.js.map +1 -1
- package/_esm/core/AbiEvent.js +5 -0
- package/_esm/core/AbiEvent.js.map +1 -1
- package/_esm/core/AbiFunction.js +2 -2
- package/_esm/core/AbiFunction.js.map +1 -1
- package/_esm/core/AbiItem.js +8 -7
- package/_esm/core/AbiItem.js.map +1 -1
- package/_esm/core/Base32.js +17 -2
- package/_esm/core/Base32.js.map +1 -1
- package/_esm/core/Bytes.js +4 -5
- package/_esm/core/Bytes.js.map +1 -1
- package/_esm/core/Cbor.js +16 -2
- package/_esm/core/Cbor.js.map +1 -1
- package/_esm/core/Hex.js +3 -3
- package/_esm/core/Hex.js.map +1 -1
- package/_esm/core/Rlp.js +56 -8
- package/_esm/core/Rlp.js.map +1 -1
- package/_esm/core/RpcTransport.js +12 -4
- package/_esm/core/RpcTransport.js.map +1 -1
- package/_esm/core/Siwe.js +5 -0
- package/_esm/core/Siwe.js.map +1 -1
- package/_esm/core/TypedData.js +7 -6
- package/_esm/core/TypedData.js.map +1 -1
- package/_esm/core/internal/abiItem.js +2 -1
- package/_esm/core/internal/abiItem.js.map +1 -1
- package/_esm/erc4337/UserOperation.js +10 -4
- package/_esm/erc4337/UserOperation.js.map +1 -1
- package/_esm/erc8021/Attribution.js +15 -3
- package/_esm/erc8021/Attribution.js.map +1 -1
- package/_esm/tempo/SignaturePreAuthorized.js +314 -0
- package/_esm/tempo/SignaturePreAuthorized.js.map +1 -0
- package/_esm/tempo/Tick.js +4 -3
- package/_esm/tempo/Tick.js.map +1 -1
- package/_esm/tempo/index.js +8 -0
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/core/AbiError.d.ts +2 -2
- package/_types/core/AbiError.d.ts.map +1 -1
- package/_types/core/AbiEvent.d.ts.map +1 -1
- package/_types/core/AbiFunction.d.ts +1 -1
- package/_types/core/AbiFunction.d.ts.map +1 -1
- package/_types/core/AbiItem.d.ts.map +1 -1
- package/_types/core/Base32.d.ts +8 -3
- package/_types/core/Base32.d.ts.map +1 -1
- package/_types/core/Bytes.d.ts.map +1 -1
- package/_types/core/Cbor.d.ts.map +1 -1
- package/_types/core/Hex.d.ts.map +1 -1
- package/_types/core/Rlp.d.ts +9 -2
- package/_types/core/Rlp.d.ts.map +1 -1
- package/_types/core/RpcTransport.d.ts.map +1 -1
- package/_types/core/Siwe.d.ts.map +1 -1
- package/_types/core/internal/abiItem.d.ts +3 -1
- package/_types/core/internal/abiItem.d.ts.map +1 -1
- package/_types/erc4337/UserOperation.d.ts +20 -2
- package/_types/erc4337/UserOperation.d.ts.map +1 -1
- package/_types/erc8021/Attribution.d.ts.map +1 -1
- package/_types/package.json +1 -0
- package/_types/tempo/SignatureEnvelope.d.ts +4 -4
- package/_types/tempo/SignaturePreAuthorized.d.ts +192 -0
- package/_types/tempo/SignaturePreAuthorized.d.ts.map +1 -0
- package/_types/tempo/Tick.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +8 -0
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/core/AbiError.ts +33 -22
- package/core/AbiEvent.ts +7 -0
- package/core/AbiFunction.ts +7 -5
- package/core/AbiItem.ts +8 -7
- package/core/Base32.ts +17 -3
- package/core/Bytes.ts +3 -5
- package/core/Cbor.ts +20 -2
- package/core/Hex.ts +4 -4
- package/core/Rlp.ts +55 -5
- package/core/RpcTransport.ts +12 -4
- package/core/Siwe.ts +5 -0
- package/core/TypedData.ts +7 -6
- package/core/internal/abiItem.ts +13 -2
- package/erc4337/UserOperation.ts +37 -3
- package/erc8021/Attribution.ts +11 -7
- package/package.json +11 -1
- package/tempo/AccountSimulation.test.ts +1 -1
- package/tempo/SignatureEnvelope.test.ts +12 -0
- package/tempo/SignatureEnvelope.ts +4 -4
- package/tempo/SignaturePreAuthorized/package.json +6 -0
- package/tempo/SignaturePreAuthorized.test-d/package.json +6 -0
- package/tempo/SignaturePreAuthorized.test-d.ts +29 -0
- package/tempo/SignaturePreAuthorized.test.ts +410 -0
- package/tempo/SignaturePreAuthorized.ts +370 -0
- package/tempo/Tick.test.ts +10 -0
- package/tempo/Tick.ts +5 -3
- package/tempo/index.ts +9 -0
- package/version.ts +1 -1
package/core/TypedData.ts
CHANGED
|
@@ -758,7 +758,7 @@ export class InvalidStructTypeError extends Errors.BaseError {
|
|
|
758
758
|
constructor({ type }: { type: string }) {
|
|
759
759
|
super(`Struct type "${type}" is invalid.`, {
|
|
760
760
|
metaMessages: [
|
|
761
|
-
'Struct type must contain only letters, digits, "_" and "
|
|
761
|
+
'Struct type must contain only letters, digits, "_", "$" and ":", and must not be a Solidity type.',
|
|
762
762
|
],
|
|
763
763
|
})
|
|
764
764
|
}
|
|
@@ -893,7 +893,7 @@ export declare namespace encodeField {
|
|
|
893
893
|
}
|
|
894
894
|
|
|
895
895
|
const arraySuffixRegex = /(\[[0-9]*\])+$/
|
|
896
|
-
const structNameRegex = /^[A-Za-z0-9_
|
|
896
|
+
const structNameRegex = /^[A-Za-z0-9_$:]+$/
|
|
897
897
|
const solidityTypeNameRegex = /^(u?int|bytes)[0-9]*$/
|
|
898
898
|
|
|
899
899
|
/** @internal */
|
|
@@ -945,10 +945,11 @@ function isSolidityType(type: string) {
|
|
|
945
945
|
|
|
946
946
|
/** @internal */
|
|
947
947
|
function validateReference(type: string) {
|
|
948
|
-
// Struct type must contain only letters, digits, `_
|
|
949
|
-
// a Solidity type, so it cannot shadow a Solidity type or an array of
|
|
950
|
-
// struct such as `intent` or `bytesInfo` is valid, while `uint7` or
|
|
951
|
-
// is rejected, since other implementations parse it as a Solidity
|
|
948
|
+
// Struct type must contain only letters, digits, `_`, `$` and `:`, and must
|
|
949
|
+
// not be a Solidity type, so it cannot shadow a Solidity type or an array of
|
|
950
|
+
// one. A struct such as `intent` or `bytesInfo` is valid, while `uint7` or
|
|
951
|
+
// `bytes33` is rejected, since other implementations parse it as a Solidity
|
|
952
|
+
// type.
|
|
952
953
|
if (
|
|
953
954
|
!structNameRegex.test(type) ||
|
|
954
955
|
type === 'address' ||
|
package/core/internal/abiItem.ts
CHANGED
|
@@ -52,7 +52,17 @@ export type ExtractForArgs<
|
|
|
52
52
|
>
|
|
53
53
|
}
|
|
54
54
|
>
|
|
55
|
-
:
|
|
55
|
+
: readonly [] extends args
|
|
56
|
+
? TupleToUnion<abiItems, abi, name, args> extends infer zero
|
|
57
|
+
? Compute<
|
|
58
|
+
zero & {
|
|
59
|
+
readonly overloads: UnionToTuple<
|
|
60
|
+
Exclude<abiItems[number], zero>
|
|
61
|
+
>
|
|
62
|
+
}
|
|
63
|
+
>
|
|
64
|
+
: never
|
|
65
|
+
: TupleToUnion<abiItems, abi, name, args> // convert back to union (removes `never` tuple entries: `['foo', never, 'bar'][number]` => `'foo' | 'bar'`)
|
|
56
66
|
: never
|
|
57
67
|
: abiItem
|
|
58
68
|
: never
|
|
@@ -556,7 +566,8 @@ export function isArgOfType(
|
|
|
556
566
|
return false
|
|
557
567
|
// An overload whose fixed size differs from the value does not match.
|
|
558
568
|
const bytes = abiParameterType.slice(5)
|
|
559
|
-
|
|
569
|
+
// Dynamic `bytes` is hex or raw bytes. A plain string is only `string`.
|
|
570
|
+
if (!bytes) return arg instanceof Uint8Array || Hex.validate(arg)
|
|
560
571
|
if (arg instanceof Uint8Array)
|
|
561
572
|
return arg.length === Number.parseInt(bytes, 10)
|
|
562
573
|
if (!Hex.validate(arg)) return false
|
package/erc4337/UserOperation.ts
CHANGED
|
@@ -601,12 +601,24 @@ export declare namespace hash {
|
|
|
601
601
|
* @param userOperation - The user operation to convert.
|
|
602
602
|
* @returns The init code.
|
|
603
603
|
*/
|
|
604
|
-
export function toInitCode(
|
|
604
|
+
export function toInitCode(
|
|
605
|
+
userOperation: Partial<UserOperation>,
|
|
606
|
+
options: toInitCode.Options = {},
|
|
607
|
+
): Hex.Hex {
|
|
608
|
+
const { forHash } = options
|
|
605
609
|
const { authorization, factory, factoryData } = userOperation
|
|
606
610
|
if (
|
|
607
611
|
factory === '0x7702' ||
|
|
608
612
|
factory === '0x7702000000000000000000000000000000000000'
|
|
609
613
|
) {
|
|
614
|
+
// Onchain, the EntryPoint detects EIP-7702 by the 20-byte `0x7702` marker
|
|
615
|
+
// and reads the initialization data from `initCode[20:]`.
|
|
616
|
+
if (!forHash)
|
|
617
|
+
return Hex.concat(
|
|
618
|
+
'0x7702000000000000000000000000000000000000',
|
|
619
|
+
factoryData ?? '0x',
|
|
620
|
+
)
|
|
621
|
+
// For the hash, the EntryPoint replaces the marker with the delegate.
|
|
610
622
|
if (!authorization) return '0x7702000000000000000000000000000000000000'
|
|
611
623
|
const delegation = authorization.address
|
|
612
624
|
return Hex.concat(delegation, factoryData ?? '0x')
|
|
@@ -615,6 +627,18 @@ export function toInitCode(userOperation: Partial<UserOperation>): Hex.Hex {
|
|
|
615
627
|
return Hex.concat(factory, factoryData ?? '0x')
|
|
616
628
|
}
|
|
617
629
|
|
|
630
|
+
export declare namespace toInitCode {
|
|
631
|
+
type Options = {
|
|
632
|
+
/**
|
|
633
|
+
* Prepares the init code for hashing: replaces the EIP-7702 `0x7702`
|
|
634
|
+
* marker with the delegate address.
|
|
635
|
+
*/
|
|
636
|
+
forHash?: boolean | undefined
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
type ErrorType = Hex.concat.ErrorType | Errors.GlobalErrorType
|
|
640
|
+
}
|
|
641
|
+
|
|
618
642
|
/**
|
|
619
643
|
* Transforms a User Operation into "packed" format.
|
|
620
644
|
*
|
|
@@ -641,6 +665,7 @@ export function toInitCode(userOperation: Partial<UserOperation>): Hex.Hex {
|
|
|
641
665
|
*/
|
|
642
666
|
export function toPacked(
|
|
643
667
|
userOperation: UserOperation<'0.7' | '0.8', true>,
|
|
668
|
+
options: toPacked.Options = {},
|
|
644
669
|
): Packed {
|
|
645
670
|
const {
|
|
646
671
|
callGasLimit,
|
|
@@ -661,7 +686,7 @@ export function toPacked(
|
|
|
661
686
|
Hex.padLeft(Hex.fromNumber(verificationGasLimit || 0n), 16),
|
|
662
687
|
Hex.padLeft(Hex.fromNumber(callGasLimit || 0n), 16),
|
|
663
688
|
)
|
|
664
|
-
const initCode = toInitCode(userOperation)
|
|
689
|
+
const initCode = toInitCode(userOperation, { forHash: options.forHash })
|
|
665
690
|
const gasFees = Hex.concat(
|
|
666
691
|
Hex.padLeft(Hex.fromNumber(maxPriorityFeePerGas || 0n), 16),
|
|
667
692
|
Hex.padLeft(Hex.fromNumber(maxFeePerGas || 0n), 16),
|
|
@@ -690,6 +715,15 @@ export function toPacked(
|
|
|
690
715
|
}
|
|
691
716
|
|
|
692
717
|
export declare namespace toPacked {
|
|
718
|
+
/** Packing options. */
|
|
719
|
+
export type Options = {
|
|
720
|
+
/**
|
|
721
|
+
* Prepares for hashing: replaces the EIP-7702 `initCode` marker with the
|
|
722
|
+
* delegate.
|
|
723
|
+
*/
|
|
724
|
+
forHash?: boolean | undefined
|
|
725
|
+
}
|
|
726
|
+
|
|
693
727
|
export type ErrorType = Errors.GlobalErrorType
|
|
694
728
|
}
|
|
695
729
|
|
|
@@ -905,7 +939,7 @@ export function toTypedData(
|
|
|
905
939
|
): TypedData.Definition<typeof toTypedData.types, 'PackedUserOperation'> {
|
|
906
940
|
const { chainId, entryPointAddress } = options
|
|
907
941
|
|
|
908
|
-
const packedUserOp = toPacked(userOperation)
|
|
942
|
+
const packedUserOp = toPacked(userOperation, { forHash: true })
|
|
909
943
|
|
|
910
944
|
return {
|
|
911
945
|
domain: {
|
package/erc8021/Attribution.ts
CHANGED
|
@@ -319,6 +319,8 @@ export function fromData(data: Hex.Hex): Attribution | undefined {
|
|
|
319
319
|
// Extract codes
|
|
320
320
|
const codesStart = -ercSuffixSize - 2 - codesLength
|
|
321
321
|
const codesEnd = -ercSuffixSize - 2
|
|
322
|
+
// `Hex.slice` clamps a negative start that runs past the beginning of `data`.
|
|
323
|
+
if (Hex.size(data) + codesStart < 0) return undefined
|
|
322
324
|
const codesHex = Hex.slice(data, codesStart, codesEnd)
|
|
323
325
|
const codesString = Hex.toString(codesHex)
|
|
324
326
|
const codes = codesString.length > 0 ? codesString.split(',') : []
|
|
@@ -340,6 +342,8 @@ export function fromData(data: Hex.Hex): Attribution | undefined {
|
|
|
340
342
|
// Extract codes
|
|
341
343
|
const codesStart = -ercSuffixSize - 2 - codesLength
|
|
342
344
|
const codesEnd = -ercSuffixSize - 2
|
|
345
|
+
// `Hex.slice` clamps a negative start that runs past the beginning of `data`.
|
|
346
|
+
if (Hex.size(data) + codesStart < 0) return undefined
|
|
343
347
|
const codesHex = Hex.slice(data, codesStart, codesEnd)
|
|
344
348
|
const codesString = Hex.toString(codesHex)
|
|
345
349
|
const codes = codesString.length > 0 ? codesString.split(',') : []
|
|
@@ -475,16 +479,16 @@ function schema2ToDataSuffix(attribution: AttributionSchemaId2): Hex.Hex {
|
|
|
475
479
|
|
|
476
480
|
function schema2FromData(data: Hex.Hex): AttributionSchemaId2 | undefined {
|
|
477
481
|
// cborLength is 2 bytes before schema ID
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
)
|
|
482
|
+
const cborLengthStart = -ercSuffixSize - 1 - 2
|
|
483
|
+
const cborLengthEnd = -ercSuffixSize - 1
|
|
484
|
+
if (Hex.size(data) + cborLengthStart < 0) return undefined
|
|
485
|
+
const cborLengthHex = Hex.slice(data, cborLengthStart, cborLengthEnd)
|
|
483
486
|
const cborLength = Hex.toNumber(cborLengthHex)
|
|
484
487
|
|
|
485
488
|
// Extract CBOR data
|
|
486
|
-
const cborStart =
|
|
487
|
-
|
|
489
|
+
const cborStart = cborLengthStart - cborLength
|
|
490
|
+
if (Hex.size(data) + cborStart < 0) return undefined
|
|
491
|
+
const cborEnd = cborLengthStart
|
|
488
492
|
const cborHex = Hex.slice(data, cborStart, cborEnd)
|
|
489
493
|
|
|
490
494
|
// Decode CBOR
|
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.65",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
7
7
|
"types": "./_types/index.d.ts",
|
|
@@ -613,6 +613,16 @@
|
|
|
613
613
|
"import": "./_esm/tempo/SignatureEnvelope.js",
|
|
614
614
|
"default": "./_cjs/tempo/SignatureEnvelope.js"
|
|
615
615
|
},
|
|
616
|
+
"./tempo/SignaturePreAuthorized.test-d": {
|
|
617
|
+
"types": "./_types/tempo/SignaturePreAuthorized.test-d.d.ts",
|
|
618
|
+
"import": "./_esm/tempo/SignaturePreAuthorized.test-d.js",
|
|
619
|
+
"default": "./_cjs/tempo/SignaturePreAuthorized.test-d.js"
|
|
620
|
+
},
|
|
621
|
+
"./tempo/SignaturePreAuthorized": {
|
|
622
|
+
"types": "./_types/tempo/SignaturePreAuthorized.d.ts",
|
|
623
|
+
"import": "./_esm/tempo/SignaturePreAuthorized.js",
|
|
624
|
+
"default": "./_cjs/tempo/SignaturePreAuthorized.js"
|
|
625
|
+
},
|
|
616
626
|
"./tempo/TempoAddress": {
|
|
617
627
|
"types": "./_types/tempo/TempoAddress.d.ts",
|
|
618
628
|
"import": "./_esm/tempo/TempoAddress.js",
|
|
@@ -107,7 +107,7 @@ describe('fromRpc', () => {
|
|
|
107
107
|
expect(() =>
|
|
108
108
|
AccountSimulation.fromRpc({ ...rpc, config: noncanonical }),
|
|
109
109
|
).toThrowErrorMatchingInlineSnapshot(
|
|
110
|
-
`[
|
|
110
|
+
`[Rlp.NonCanonicalError: RLP payload is not canonically encoded: single byte \`0x00\` is wrapped in an explicit length prefix instead of being encoded as itself.]`,
|
|
111
111
|
)
|
|
112
112
|
})
|
|
113
113
|
})
|
|
@@ -1043,6 +1043,18 @@ describe('from', () => {
|
|
|
1043
1043
|
expect(envelope.type).toBe('keychain')
|
|
1044
1044
|
})
|
|
1045
1045
|
|
|
1046
|
+
test('behavior: defaults version to v2', () => {
|
|
1047
|
+
const envelope = SignatureEnvelope.from({
|
|
1048
|
+
inner: SignatureEnvelope.from(signature_secp256k1),
|
|
1049
|
+
userAddress: '0x1234567890123456789012345678901234567890',
|
|
1050
|
+
})
|
|
1051
|
+
|
|
1052
|
+
expect(envelope).toMatchObject({ version: 'v2' })
|
|
1053
|
+
expect(
|
|
1054
|
+
Hex.slice(SignatureEnvelope.serialize(envelope), 0, 1),
|
|
1055
|
+
).toMatchInlineSnapshot(`"0x04"`)
|
|
1056
|
+
})
|
|
1057
|
+
|
|
1046
1058
|
test('behavior: computes keyId from p256 inner publicKey', () => {
|
|
1047
1059
|
const envelope = SignatureEnvelope.from({
|
|
1048
1060
|
userAddress: '0x1234567890123456789012345678901234567890',
|
|
@@ -139,7 +139,7 @@ export type GetType<
|
|
|
139
139
|
*
|
|
140
140
|
* - **keychain** (type `0x03` V1, `0x04` V2): Access key signature that wraps an inner signature
|
|
141
141
|
* (secp256k1, p256, or webAuthn). Format: type byte + user_address (20 bytes) + inner signature.
|
|
142
|
-
* V2 binds the signature to the user account via `keccak256(sigHash || userAddress)`.
|
|
142
|
+
* V2 binds the signature to the user account via `keccak256(0x04 || sigHash || userAddress)`.
|
|
143
143
|
* The protocol validates the access key authorization via the AccountKeychain precompile.
|
|
144
144
|
*
|
|
145
145
|
* - **configurable** (type `0x05`): Configurable account signature carrying the account address,
|
|
@@ -181,8 +181,8 @@ export type PrimitiveRpc = OneOf<Secp256k1Rpc | P256Rpc | WebAuthnRpc>
|
|
|
181
181
|
* Keychain signature version.
|
|
182
182
|
*
|
|
183
183
|
* - `'v1'`: Legacy format. Inner signature signs the raw `sig_hash` directly. Deprecated at T1C.
|
|
184
|
-
* - `'v2'`: Inner signature signs `keccak256(sig_hash || user_address)`, binding the
|
|
185
|
-
* to the specific user account.
|
|
184
|
+
* - `'v2'`: Inner signature signs `keccak256(0x04 || sig_hash || user_address)`, binding the
|
|
185
|
+
* signature to the specific user account.
|
|
186
186
|
*/
|
|
187
187
|
export type KeychainVersion = 'v1' | 'v2'
|
|
188
188
|
|
|
@@ -194,7 +194,7 @@ export type Keychain<bigintType = bigint, numberType = number> = {
|
|
|
194
194
|
type: 'keychain'
|
|
195
195
|
/** Root account address that this transaction is being executed for */
|
|
196
196
|
userAddress: Address.Address
|
|
197
|
-
/** Keychain signature version. @default '
|
|
197
|
+
/** Keychain signature version. @default 'v2' */
|
|
198
198
|
version?: KeychainVersion | undefined
|
|
199
199
|
}
|
|
200
200
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { expectTypeOf, test } from 'vitest'
|
|
2
|
+
import type * as Hex from '../core/Hex.js'
|
|
3
|
+
import type * as KeyAuthorization from './KeyAuthorization.js'
|
|
4
|
+
import type * as SignatureEnvelope from './SignatureEnvelope.js'
|
|
5
|
+
import * as SignaturePreAuthorized from './SignaturePreAuthorized.js'
|
|
6
|
+
|
|
7
|
+
test('magicBytes', () => {
|
|
8
|
+
expectTypeOf(
|
|
9
|
+
SignaturePreAuthorized.magicBytes,
|
|
10
|
+
).toEqualTypeOf<'0x1165116511651165116511651165116511651165116511651165116511651165'>()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('unwrap', () => {
|
|
14
|
+
const unwrapped = SignaturePreAuthorized.unwrap('0x')
|
|
15
|
+
expectTypeOf(
|
|
16
|
+
unwrapped.keyAuthorization,
|
|
17
|
+
).toEqualTypeOf<KeyAuthorization.Signed>()
|
|
18
|
+
expectTypeOf(unwrapped.signature).toEqualTypeOf<SignatureEnvelope.Keychain>()
|
|
19
|
+
expectTypeOf(
|
|
20
|
+
SignaturePreAuthorized.from('0x'),
|
|
21
|
+
).toEqualTypeOf<SignaturePreAuthorized.Unwrapped>()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
test('wrap', () => {
|
|
25
|
+
expectTypeOf(SignaturePreAuthorized.wrap).returns.toEqualTypeOf<Hex.Hex>()
|
|
26
|
+
expectTypeOf(SignaturePreAuthorized.wrap)
|
|
27
|
+
.parameter(0)
|
|
28
|
+
.toEqualTypeOf<SignaturePreAuthorized.Unwrapped>()
|
|
29
|
+
})
|