ox 1.0.1 → 1.0.3
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 +12 -0
- package/dist/tempo/KeyAuthorization.d.ts +22 -16
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorization.js +31 -7
- package/dist/tempo/KeyAuthorization.js.map +1 -1
- package/dist/tempo/MultisigConfig.d.ts +8 -4
- package/dist/tempo/MultisigConfig.d.ts.map +1 -1
- package/dist/tempo/MultisigConfig.js +16 -4
- package/dist/tempo/MultisigConfig.js.map +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts +31 -13
- package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.js +172 -55
- package/dist/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/zod/tempo/AuthorizationTempo.d.ts +70 -60
- package/dist/zod/tempo/AuthorizationTempo.d.ts.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.d.ts +0 -306
- package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.js +2 -2
- package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
- package/dist/zod/tempo/MultisigConfig.d.ts.map +1 -1
- package/dist/zod/tempo/MultisigConfig.js +5 -2
- package/dist/zod/tempo/MultisigConfig.js.map +1 -1
- package/dist/zod/tempo/RpcSchemaTempo.d.ts +28 -132
- package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.d.ts +79 -18
- package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.js +39 -11
- package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/zod/tempo/Transaction.d.ts +84 -396
- package/dist/zod/tempo/Transaction.d.ts.map +1 -1
- package/dist/zod/tempo/TransactionRequest.d.ts +42 -234
- package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/zod/tempo/TxEnvelopeTempo.d.ts +0 -108
- package/dist/zod/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/tempo/KeyAuthorization.test-d.ts +62 -0
- package/src/tempo/KeyAuthorization.test.ts +53 -0
- package/src/tempo/KeyAuthorization.ts +69 -27
- package/src/tempo/MultisigConfig.test.ts +34 -2
- package/src/tempo/MultisigConfig.ts +18 -4
- package/src/tempo/SignatureEnvelope.test-d.ts +97 -0
- package/src/tempo/SignatureEnvelope.test.ts +247 -36
- package/src/tempo/SignatureEnvelope.ts +271 -85
- package/src/tempo/e2e.test.ts +0 -416
- package/src/tempo/multisig.e2e.test.ts +582 -0
- package/src/version.ts +1 -1
- package/src/zod/tempo/KeyAuthorization.ts +2 -2
- package/src/zod/tempo/MultisigConfig.ts +13 -5
- package/src/zod/tempo/SignatureEnvelope.ts +81 -18
- package/src/zod/tempo/_test/KeyAuthorization.test.ts +25 -0
- package/src/zod/tempo/_test/MultisigConfig.test.ts +44 -0
- package/src/zod/tempo/_test/SignatureEnvelope.test-d.ts +9 -0
- package/src/zod/tempo/_test/SignatureEnvelope.test.ts +142 -6
|
@@ -189,24 +189,6 @@ export declare const TxEnvelopeTempo: z.ZodMiniObject<{
|
|
|
189
189
|
s: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
190
190
|
}, z.core.$strip>;
|
|
191
191
|
type: z.ZodMiniLiteral<"webAuthn">;
|
|
192
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
193
|
-
inner: z.ZodMiniLazy<z.ZodMiniType<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown, z.core.$ZodTypeInternals<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown>>>;
|
|
194
|
-
keyId: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
195
|
-
type: z.ZodMiniLiteral<"keychain">;
|
|
196
|
-
userAddress: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
197
|
-
version: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"v1">, z.ZodMiniLiteral<"v2">]>>;
|
|
198
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
199
|
-
account: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
200
|
-
init: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
201
|
-
salt: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
202
|
-
threshold: z.ZodMiniNumber<number>;
|
|
203
|
-
owners: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniObject<{
|
|
204
|
-
owner: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
205
|
-
weight: z.ZodMiniNumber<number>;
|
|
206
|
-
}, z.core.$strip>>>;
|
|
207
|
-
}, z.core.$strip>>;
|
|
208
|
-
signatures: z.ZodMiniLazy<z.ZodMiniType<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown, z.core.$ZodTypeInternals<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown>>>;
|
|
209
|
-
type: z.ZodMiniLiteral<"multisig">;
|
|
210
192
|
}, z.core.$strip>]>;
|
|
211
193
|
type: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"secp256k1">, z.ZodMiniLiteral<"p256">, z.ZodMiniLiteral<"webAuthn">]>;
|
|
212
194
|
witness: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
@@ -258,24 +240,6 @@ export declare const TxEnvelopeTempo: z.ZodMiniObject<{
|
|
|
258
240
|
s: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
259
241
|
}, z.core.$strip>;
|
|
260
242
|
type: z.ZodMiniLiteral<"webAuthn">;
|
|
261
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
262
|
-
inner: z.ZodMiniLazy<z.ZodMiniType<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown, z.core.$ZodTypeInternals<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown>>>;
|
|
263
|
-
keyId: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
264
|
-
type: z.ZodMiniLiteral<"keychain">;
|
|
265
|
-
userAddress: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
266
|
-
version: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"v1">, z.ZodMiniLiteral<"v2">]>>;
|
|
267
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
268
|
-
account: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
269
|
-
init: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
270
|
-
salt: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
271
|
-
threshold: z.ZodMiniNumber<number>;
|
|
272
|
-
owners: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniObject<{
|
|
273
|
-
owner: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
274
|
-
weight: z.ZodMiniNumber<number>;
|
|
275
|
-
}, z.core.$strip>>>;
|
|
276
|
-
}, z.core.$strip>>;
|
|
277
|
-
signatures: z.ZodMiniLazy<z.ZodMiniType<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown, z.core.$ZodTypeInternals<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown>>>;
|
|
278
|
-
type: z.ZodMiniLiteral<"multisig">;
|
|
279
243
|
}, z.core.$strip>]>;
|
|
280
244
|
type: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"secp256k1">, z.ZodMiniLiteral<"p256">, z.ZodMiniLiteral<"webAuthn">]>;
|
|
281
245
|
witness: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
@@ -470,24 +434,6 @@ export declare const Signed: z.ZodMiniObject<{
|
|
|
470
434
|
s: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
471
435
|
}, z.core.$strip>;
|
|
472
436
|
type: z.ZodMiniLiteral<"webAuthn">;
|
|
473
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
474
|
-
inner: z.ZodMiniLazy<z.ZodMiniType<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown, z.core.$ZodTypeInternals<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown>>>;
|
|
475
|
-
keyId: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
476
|
-
type: z.ZodMiniLiteral<"keychain">;
|
|
477
|
-
userAddress: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
478
|
-
version: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"v1">, z.ZodMiniLiteral<"v2">]>>;
|
|
479
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
480
|
-
account: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
481
|
-
init: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
482
|
-
salt: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
483
|
-
threshold: z.ZodMiniNumber<number>;
|
|
484
|
-
owners: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniObject<{
|
|
485
|
-
owner: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
486
|
-
weight: z.ZodMiniNumber<number>;
|
|
487
|
-
}, z.core.$strip>>>;
|
|
488
|
-
}, z.core.$strip>>;
|
|
489
|
-
signatures: z.ZodMiniLazy<z.ZodMiniType<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown, z.core.$ZodTypeInternals<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown>>>;
|
|
490
|
-
type: z.ZodMiniLiteral<"multisig">;
|
|
491
437
|
}, z.core.$strip>]>;
|
|
492
438
|
type: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"secp256k1">, z.ZodMiniLiteral<"p256">, z.ZodMiniLiteral<"webAuthn">]>;
|
|
493
439
|
witness: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
@@ -539,24 +485,6 @@ export declare const Signed: z.ZodMiniObject<{
|
|
|
539
485
|
s: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
540
486
|
}, z.core.$strip>;
|
|
541
487
|
type: z.ZodMiniLiteral<"webAuthn">;
|
|
542
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
543
|
-
inner: z.ZodMiniLazy<z.ZodMiniType<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown, z.core.$ZodTypeInternals<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown>>>;
|
|
544
|
-
keyId: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
545
|
-
type: z.ZodMiniLiteral<"keychain">;
|
|
546
|
-
userAddress: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
547
|
-
version: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"v1">, z.ZodMiniLiteral<"v2">]>>;
|
|
548
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
549
|
-
account: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
550
|
-
init: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
551
|
-
salt: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
552
|
-
threshold: z.ZodMiniNumber<number>;
|
|
553
|
-
owners: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniObject<{
|
|
554
|
-
owner: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
555
|
-
weight: z.ZodMiniNumber<number>;
|
|
556
|
-
}, z.core.$strip>>>;
|
|
557
|
-
}, z.core.$strip>>;
|
|
558
|
-
signatures: z.ZodMiniLazy<z.ZodMiniType<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown, z.core.$ZodTypeInternals<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown>>>;
|
|
559
|
-
type: z.ZodMiniLiteral<"multisig">;
|
|
560
488
|
}, z.core.$strip>]>;
|
|
561
489
|
type: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"secp256k1">, z.ZodMiniLiteral<"p256">, z.ZodMiniLiteral<"webAuthn">]>;
|
|
562
490
|
witness: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
@@ -751,24 +679,6 @@ export declare const serialized: z.ZodMiniCodec<z.ZodMiniTemplateLiteral<`0x${st
|
|
|
751
679
|
s: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
752
680
|
}, z.core.$strip>;
|
|
753
681
|
type: z.ZodMiniLiteral<"webAuthn">;
|
|
754
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
755
|
-
inner: z.ZodMiniLazy<z.ZodMiniType<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown, z.core.$ZodTypeInternals<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown>>>;
|
|
756
|
-
keyId: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
757
|
-
type: z.ZodMiniLiteral<"keychain">;
|
|
758
|
-
userAddress: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
759
|
-
version: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"v1">, z.ZodMiniLiteral<"v2">]>>;
|
|
760
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
761
|
-
account: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
762
|
-
init: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
763
|
-
salt: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
764
|
-
threshold: z.ZodMiniNumber<number>;
|
|
765
|
-
owners: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniObject<{
|
|
766
|
-
owner: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
767
|
-
weight: z.ZodMiniNumber<number>;
|
|
768
|
-
}, z.core.$strip>>>;
|
|
769
|
-
}, z.core.$strip>>;
|
|
770
|
-
signatures: z.ZodMiniLazy<z.ZodMiniType<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown, z.core.$ZodTypeInternals<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown>>>;
|
|
771
|
-
type: z.ZodMiniLiteral<"multisig">;
|
|
772
682
|
}, z.core.$strip>]>;
|
|
773
683
|
type: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"secp256k1">, z.ZodMiniLiteral<"p256">, z.ZodMiniLiteral<"webAuthn">]>;
|
|
774
684
|
witness: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
@@ -820,24 +730,6 @@ export declare const serialized: z.ZodMiniCodec<z.ZodMiniTemplateLiteral<`0x${st
|
|
|
820
730
|
s: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
821
731
|
}, z.core.$strip>;
|
|
822
732
|
type: z.ZodMiniLiteral<"webAuthn">;
|
|
823
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
824
|
-
inner: z.ZodMiniLazy<z.ZodMiniType<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown, z.core.$ZodTypeInternals<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown>>>;
|
|
825
|
-
keyId: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
826
|
-
type: z.ZodMiniLiteral<"keychain">;
|
|
827
|
-
userAddress: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
828
|
-
version: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"v1">, z.ZodMiniLiteral<"v2">]>>;
|
|
829
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
830
|
-
account: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
831
|
-
init: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
832
|
-
salt: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
833
|
-
threshold: z.ZodMiniNumber<number>;
|
|
834
|
-
owners: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniObject<{
|
|
835
|
-
owner: z.ZodMiniTemplateLiteral<`0x${string}`>;
|
|
836
|
-
weight: z.ZodMiniNumber<number>;
|
|
837
|
-
}, z.core.$strip>>>;
|
|
838
|
-
}, z.core.$strip>>;
|
|
839
|
-
signatures: z.ZodMiniLazy<z.ZodMiniType<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown, z.core.$ZodTypeInternals<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown>>>;
|
|
840
|
-
type: z.ZodMiniLiteral<"multisig">;
|
|
841
733
|
}, z.core.$strip>]>;
|
|
842
734
|
type: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"secp256k1">, z.ZodMiniLiteral<"p256">, z.ZodMiniLiteral<"webAuthn">]>;
|
|
843
735
|
witness: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxEnvelopeTempo.d.ts","sourceRoot":"","sources":["../../../src/zod/tempo/TxEnvelopeTempo.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAY7B,8CAA8C;AAC9C,eAAO,MAAM,IAAI,2BAAqB,CAAA;AAEtC,qCAAqC;AACrC,eAAO,MAAM,IAAI;;;;iBAIf,CAAA;AAqBF,yCAAyC;AACzC,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"TxEnvelopeTempo.d.ts","sourceRoot":"","sources":["../../../src/zod/tempo/TxEnvelopeTempo.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAY7B,8CAA8C;AAC9C,eAAO,MAAM,IAAI,2BAAqB,CAAA;AAEtC,qCAAqC;AACrC,eAAO,MAAM,IAAI;;;;iBAIf,CAAA;AAqBF,yCAAyC;AACzC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAG1B,CAAA;AAEF,gDAAgD;AAChD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGjB,CAAA;AAEF,yFAAyF;AACzF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBASrB,CAAA"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "ox",
|
|
3
3
|
"description": "Ethereum Standard Library",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.3",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@noble/hashes": "^2.2.0",
|
|
38
38
|
"@scure/bip32": "^2.0.0",
|
|
39
39
|
"@scure/bip39": "^2.0.0",
|
|
40
|
-
"abitype": "^1.
|
|
40
|
+
"abitype": "^1.3.0",
|
|
41
41
|
"eventemitter3": "5.0.1",
|
|
42
42
|
"zod": "^4.4.3"
|
|
43
43
|
},
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { expectTypeOf, test } from 'vp/test'
|
|
2
|
+
import * as KeyAuthorization from './KeyAuthorization.js'
|
|
3
|
+
import * as SignatureEnvelope from './SignatureEnvelope.js'
|
|
4
|
+
|
|
5
|
+
const authorization = {
|
|
6
|
+
address: '0x1111111111111111111111111111111111111111',
|
|
7
|
+
chainId: 1n,
|
|
8
|
+
type: 'secp256k1',
|
|
9
|
+
} as const satisfies KeyAuthorization.Input
|
|
10
|
+
|
|
11
|
+
const signature = {
|
|
12
|
+
signature: {
|
|
13
|
+
r: '0x01',
|
|
14
|
+
s: '0x02',
|
|
15
|
+
yParity: 0,
|
|
16
|
+
},
|
|
17
|
+
type: 'secp256k1',
|
|
18
|
+
} as const satisfies SignatureEnvelope.Secp256k1
|
|
19
|
+
|
|
20
|
+
const multisig = {
|
|
21
|
+
account: '0x2222222222222222222222222222222222222222',
|
|
22
|
+
signatures: [signature],
|
|
23
|
+
type: 'multisig',
|
|
24
|
+
} as const satisfies SignatureEnvelope.Multisig
|
|
25
|
+
|
|
26
|
+
test('accepts primitive signatures', () => {
|
|
27
|
+
const signed = KeyAuthorization.from(authorization, { signature })
|
|
28
|
+
|
|
29
|
+
expectTypeOf(signed.signature).toMatchTypeOf<
|
|
30
|
+
KeyAuthorization.Signed['signature']
|
|
31
|
+
>()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test('rejects multisig signatures', () => {
|
|
35
|
+
KeyAuthorization.from(authorization, {
|
|
36
|
+
// @ts-expect-error Key authorizations accept only primitive signatures.
|
|
37
|
+
signature: multisig,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const multisigRpc = {
|
|
41
|
+
account: multisig.account,
|
|
42
|
+
signatures: [
|
|
43
|
+
{
|
|
44
|
+
r: '0x01',
|
|
45
|
+
s: '0x02',
|
|
46
|
+
type: 'secp256k1',
|
|
47
|
+
yParity: '0x0',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
} as const satisfies SignatureEnvelope.MultisigRpc
|
|
51
|
+
|
|
52
|
+
const rpc: KeyAuthorization.Rpc = {
|
|
53
|
+
chainId: '0x1',
|
|
54
|
+
expiry: null,
|
|
55
|
+
keyId: authorization.address,
|
|
56
|
+
keyType: authorization.type,
|
|
57
|
+
// @ts-expect-error Key authorizations accept only primitive RPC signatures.
|
|
58
|
+
signature: multisigRpc,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
expectTypeOf(rpc).toEqualTypeOf<KeyAuthorization.Rpc>()
|
|
62
|
+
})
|
|
@@ -53,6 +53,12 @@ const signature_webauthn = SignatureEnvelope.from({
|
|
|
53
53
|
},
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
+
const signature_multisig = SignatureEnvelope.from({
|
|
57
|
+
account: address,
|
|
58
|
+
signatures: [SignatureEnvelope.from(signature_secp256k1)],
|
|
59
|
+
type: 'multisig',
|
|
60
|
+
})
|
|
61
|
+
|
|
56
62
|
describe('from', () => {
|
|
57
63
|
test('default', () => {
|
|
58
64
|
const authorization = KeyAuthorization.from({
|
|
@@ -416,9 +422,56 @@ describe('from', () => {
|
|
|
416
422
|
}
|
|
417
423
|
`)
|
|
418
424
|
})
|
|
425
|
+
|
|
426
|
+
test('rejects a multisig signature', () => {
|
|
427
|
+
const authorization = KeyAuthorization.from({
|
|
428
|
+
address,
|
|
429
|
+
chainId: 1n,
|
|
430
|
+
type: 'secp256k1',
|
|
431
|
+
})
|
|
432
|
+
|
|
433
|
+
expect(() =>
|
|
434
|
+
KeyAuthorization.from(authorization, {
|
|
435
|
+
signature: signature_multisig as never,
|
|
436
|
+
}),
|
|
437
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
438
|
+
`[KeyAuthorization.InvalidSignatureTypeError: Signature type \`multisig\` is invalid for key authorizations; expected \`secp256k1\`, \`p256\`, or \`webAuthn\`.]`,
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
expect(() =>
|
|
442
|
+
KeyAuthorization.from(authorization, {
|
|
443
|
+
signature: SignatureEnvelope.serialize(signature_multisig),
|
|
444
|
+
}),
|
|
445
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
446
|
+
`[KeyAuthorization.InvalidSignatureTypeError: Signature type \`multisig\` is invalid for key authorizations; expected \`secp256k1\`, \`p256\`, or \`webAuthn\`.]`,
|
|
447
|
+
)
|
|
448
|
+
|
|
449
|
+
expect(() =>
|
|
450
|
+
KeyAuthorization.from({
|
|
451
|
+
...authorization,
|
|
452
|
+
signature: signature_multisig,
|
|
453
|
+
} as never),
|
|
454
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
455
|
+
`[KeyAuthorization.InvalidSignatureTypeError: Signature type \`multisig\` is invalid for key authorizations; expected \`secp256k1\`, \`p256\`, or \`webAuthn\`.]`,
|
|
456
|
+
)
|
|
457
|
+
})
|
|
419
458
|
})
|
|
420
459
|
|
|
421
460
|
describe('fromRpc', () => {
|
|
461
|
+
test('rejects a multisig signature', () => {
|
|
462
|
+
expect(() =>
|
|
463
|
+
KeyAuthorization.fromRpc({
|
|
464
|
+
chainId: '0x1',
|
|
465
|
+
expiry: null,
|
|
466
|
+
keyId: address,
|
|
467
|
+
keyType: 'secp256k1',
|
|
468
|
+
signature: SignatureEnvelope.toRpc(signature_multisig),
|
|
469
|
+
} as never),
|
|
470
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
471
|
+
`[KeyAuthorization.InvalidSignatureTypeError: Signature type \`multisig\` is invalid for key authorizations; expected \`secp256k1\`, \`p256\`, or \`webAuthn\`.]`,
|
|
472
|
+
)
|
|
473
|
+
})
|
|
474
|
+
|
|
422
475
|
test('secp256k1', () => {
|
|
423
476
|
const authorization = KeyAuthorization.fromRpc({
|
|
424
477
|
chainId: '0x1',
|
|
@@ -4,7 +4,7 @@ import type * as Errors from '../core/Errors.js'
|
|
|
4
4
|
import * as Hash from '../core/Hash.js'
|
|
5
5
|
import * as Hex from '../core/Hex.js'
|
|
6
6
|
import * as Quantity from '../core/internal/quantity.js'
|
|
7
|
-
import type { Compute, OneOf } from '../core/internal/types.js'
|
|
7
|
+
import type { Compute, OneOf, UnionPartialBy } from '../core/internal/types.js'
|
|
8
8
|
import * as Rlp from '../core/Rlp.js'
|
|
9
9
|
import * as SignatureEnvelope from './SignatureEnvelope.js'
|
|
10
10
|
|
|
@@ -78,9 +78,9 @@ export type KeyAuthorization<
|
|
|
78
78
|
| {}
|
|
79
79
|
> &
|
|
80
80
|
(signed extends true
|
|
81
|
-
? { signature: SignatureEnvelope.
|
|
81
|
+
? { signature: SignatureEnvelope.Primitive<numberType> }
|
|
82
82
|
: {
|
|
83
|
-
signature?: SignatureEnvelope.
|
|
83
|
+
signature?: SignatureEnvelope.Primitive<numberType> | undefined
|
|
84
84
|
})
|
|
85
85
|
|
|
86
86
|
/** Input type for a Key Authorization. */
|
|
@@ -104,8 +104,8 @@ export type Rpc = {
|
|
|
104
104
|
keyType: SignatureEnvelope.Type
|
|
105
105
|
/** Token spending limits. */
|
|
106
106
|
limits?: readonly RpcTokenLimit[] | null | undefined
|
|
107
|
-
/**
|
|
108
|
-
signature: SignatureEnvelope.
|
|
107
|
+
/** Primitive signature authorizing this key. */
|
|
108
|
+
signature: SignatureEnvelope.PrimitiveRpc
|
|
109
109
|
/** Optional 32-byte witness (hex). */
|
|
110
110
|
witness?: Hex.Hex | null | undefined
|
|
111
111
|
}
|
|
@@ -136,6 +136,11 @@ export type Signed<bigintType = bigint, numberType = number> = KeyAuthorization<
|
|
|
136
136
|
numberType
|
|
137
137
|
>
|
|
138
138
|
|
|
139
|
+
type PrimitiveSignatureValue =
|
|
140
|
+
| UnionPartialBy<SignatureEnvelope.Primitive, 'prehash' | 'type'>
|
|
141
|
+
| SignatureEnvelope.Secp256k1Flat
|
|
142
|
+
| SignatureEnvelope.Serialized
|
|
143
|
+
|
|
139
144
|
type BaseTuple = readonly [
|
|
140
145
|
chainId: Hex.Hex,
|
|
141
146
|
keyType: Hex.Hex,
|
|
@@ -415,7 +420,7 @@ export type TokenLimit<bigintType = bigint, numberType = number> = {
|
|
|
415
420
|
*/
|
|
416
421
|
export function from<
|
|
417
422
|
const authorization extends Input | Rpc,
|
|
418
|
-
const signature extends
|
|
423
|
+
const signature extends PrimitiveSignatureValue | undefined = undefined,
|
|
419
424
|
>(
|
|
420
425
|
authorization: authorization | KeyAuthorization,
|
|
421
426
|
options: from.Options<signature> = {},
|
|
@@ -430,6 +435,7 @@ export function from<
|
|
|
430
435
|
}[]
|
|
431
436
|
}
|
|
432
437
|
if (auth.witness !== undefined) assertWitness(auth.witness)
|
|
438
|
+
if (auth.signature) assertSignature(auth.signature)
|
|
433
439
|
const resolved = {
|
|
434
440
|
...auth,
|
|
435
441
|
...(auth.scopes
|
|
@@ -441,39 +447,49 @@ export function from<
|
|
|
441
447
|
}
|
|
442
448
|
: {}),
|
|
443
449
|
}
|
|
444
|
-
if (options.signature)
|
|
450
|
+
if (options.signature) {
|
|
451
|
+
const signature = SignatureEnvelope.from(
|
|
452
|
+
options.signature,
|
|
453
|
+
) as SignatureEnvelope.SignatureEnvelope
|
|
454
|
+
assertSignature(signature)
|
|
445
455
|
return {
|
|
446
456
|
...resolved,
|
|
447
|
-
signature
|
|
457
|
+
signature,
|
|
448
458
|
} as never
|
|
459
|
+
}
|
|
449
460
|
return resolved as never
|
|
450
461
|
}
|
|
451
462
|
|
|
452
463
|
export declare namespace from {
|
|
453
464
|
type Options<
|
|
454
|
-
signature extends
|
|
455
|
-
|
|
|
465
|
+
signature extends PrimitiveSignatureValue | undefined =
|
|
466
|
+
| PrimitiveSignatureValue
|
|
456
467
|
| undefined,
|
|
457
468
|
> = {
|
|
458
|
-
/** The
|
|
459
|
-
signature?: signature | SignatureEnvelope.
|
|
469
|
+
/** The primitive signature to attach to the Key Authorization. */
|
|
470
|
+
signature?: signature | SignatureEnvelope.Primitive | undefined
|
|
460
471
|
}
|
|
461
472
|
|
|
462
473
|
type ReturnType<
|
|
463
474
|
authorization extends KeyAuthorization | Input | Rpc = KeyAuthorization,
|
|
464
|
-
signature extends
|
|
465
|
-
|
|
|
475
|
+
signature extends PrimitiveSignatureValue | undefined =
|
|
476
|
+
| PrimitiveSignatureValue
|
|
466
477
|
| undefined,
|
|
467
478
|
> = Compute<
|
|
468
479
|
authorization extends Rpc
|
|
469
480
|
? Signed
|
|
470
481
|
: authorization &
|
|
471
|
-
(signature extends
|
|
472
|
-
? {
|
|
482
|
+
(signature extends PrimitiveSignatureValue
|
|
483
|
+
? {
|
|
484
|
+
signature: Extract<
|
|
485
|
+
SignatureEnvelope.from.ReturnValue<signature>,
|
|
486
|
+
SignatureEnvelope.Primitive
|
|
487
|
+
>
|
|
488
|
+
}
|
|
473
489
|
: {})
|
|
474
490
|
>
|
|
475
491
|
|
|
476
|
-
type ErrorType = Errors.GlobalErrorType
|
|
492
|
+
type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
|
|
477
493
|
}
|
|
478
494
|
|
|
479
495
|
/**
|
|
@@ -513,6 +529,7 @@ export function fromRpc(authorization: Rpc): Signed {
|
|
|
513
529
|
const isAdmin = authorization.isAdmin ?? undefined
|
|
514
530
|
const account = authorization.account ?? undefined
|
|
515
531
|
const signature = SignatureEnvelope.fromRpc(authorization.signature)
|
|
532
|
+
assertSignature(signature)
|
|
516
533
|
if (witness !== undefined) assertWitness(witness)
|
|
517
534
|
|
|
518
535
|
// Unflatten nested allowedCalls into flat scopes
|
|
@@ -558,7 +575,7 @@ export function fromRpc(authorization: Rpc): Signed {
|
|
|
558
575
|
}
|
|
559
576
|
|
|
560
577
|
export declare namespace fromRpc {
|
|
561
|
-
type ErrorType = Errors.GlobalErrorType
|
|
578
|
+
type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
|
|
562
579
|
}
|
|
563
580
|
|
|
564
581
|
/**
|
|
@@ -700,8 +717,11 @@ export function fromTuple<const tuple extends Tuple>(
|
|
|
700
717
|
...(witness !== undefined ? { witness } : {}),
|
|
701
718
|
...adminPair,
|
|
702
719
|
}
|
|
703
|
-
if (signatureSerialized)
|
|
704
|
-
|
|
720
|
+
if (signatureSerialized) {
|
|
721
|
+
const signature = SignatureEnvelope.deserialize(signatureSerialized)
|
|
722
|
+
assertSignature(signature)
|
|
723
|
+
args.signature = signature
|
|
724
|
+
}
|
|
705
725
|
return from(args) as never
|
|
706
726
|
}
|
|
707
727
|
|
|
@@ -710,7 +730,7 @@ export declare namespace fromTuple {
|
|
|
710
730
|
KeyAuthorization<authorization extends Tuple<true> ? true : false>
|
|
711
731
|
>
|
|
712
732
|
|
|
713
|
-
type ErrorType = Errors.GlobalErrorType
|
|
733
|
+
type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
|
|
714
734
|
}
|
|
715
735
|
|
|
716
736
|
/**
|
|
@@ -928,6 +948,7 @@ export function toRpc(authorization: toRpc.Input): Rpc {
|
|
|
928
948
|
isAdmin,
|
|
929
949
|
account,
|
|
930
950
|
} = authorization
|
|
951
|
+
assertSignature(signature)
|
|
931
952
|
if (witness !== undefined) assertWitness(witness)
|
|
932
953
|
|
|
933
954
|
// Group flat scopes by address into nested allowedCalls wire format
|
|
@@ -966,7 +987,9 @@ export function toRpc(authorization: toRpc.Input): Rpc {
|
|
|
966
987
|
limit: Quantity.fromNumberish(limit),
|
|
967
988
|
...(period ? { period: Quantity.fromNumberish(period) } : {}),
|
|
968
989
|
})),
|
|
969
|
-
signature: SignatureEnvelope.toRpc(
|
|
990
|
+
signature: SignatureEnvelope.toRpc(
|
|
991
|
+
signature,
|
|
992
|
+
) as SignatureEnvelope.PrimitiveRpc,
|
|
970
993
|
...(allowedCalls ? { allowedCalls } : {}),
|
|
971
994
|
...(witness !== undefined ? { witness } : {}),
|
|
972
995
|
...(isAdmin ? { isAdmin: true } : {}),
|
|
@@ -978,7 +1001,7 @@ export declare namespace toRpc {
|
|
|
978
1001
|
/** Numberish input accepted by {@link ox#KeyAuthorization.(toRpc:function)}. */
|
|
979
1002
|
type Input = Signed<Hex.Hex | bigint | number, Hex.Hex | number>
|
|
980
1003
|
|
|
981
|
-
type ErrorType = Errors.GlobalErrorType
|
|
1004
|
+
type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
|
|
982
1005
|
}
|
|
983
1006
|
|
|
984
1007
|
/**
|
|
@@ -1028,9 +1051,11 @@ export function toTuple<const authorization extends KeyAuthorization>(
|
|
|
1028
1051
|
account,
|
|
1029
1052
|
} = authorization
|
|
1030
1053
|
if (witness !== undefined) assertWitness(witness)
|
|
1031
|
-
const signature =
|
|
1032
|
-
|
|
1033
|
-
|
|
1054
|
+
const signature = (() => {
|
|
1055
|
+
if (!authorization.signature) return undefined
|
|
1056
|
+
assertSignature(authorization.signature)
|
|
1057
|
+
return SignatureEnvelope.serialize(authorization.signature)
|
|
1058
|
+
})()
|
|
1034
1059
|
const type = (() => {
|
|
1035
1060
|
switch (authorization.type) {
|
|
1036
1061
|
case 'secp256k1':
|
|
@@ -1126,7 +1151,7 @@ export declare namespace toTuple {
|
|
|
1126
1151
|
type ReturnType<authorization extends KeyAuthorization = KeyAuthorization> =
|
|
1127
1152
|
Compute<Tuple<authorization extends KeyAuthorization<true> ? true : false>>
|
|
1128
1153
|
|
|
1129
|
-
type ErrorType = Errors.GlobalErrorType
|
|
1154
|
+
type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
|
|
1130
1155
|
}
|
|
1131
1156
|
|
|
1132
1157
|
function bigintToHex(value: bigint): Hex.Hex {
|
|
@@ -1164,6 +1189,13 @@ function assertWitness(witness: Hex.Hex): void {
|
|
|
1164
1189
|
if (Hex.size(witness) !== 32) throw new InvalidWitnessSizeError(witness)
|
|
1165
1190
|
}
|
|
1166
1191
|
|
|
1192
|
+
function assertSignature<numberType>(
|
|
1193
|
+
signature: SignatureEnvelope.SignatureEnvelope<numberType>,
|
|
1194
|
+
): asserts signature is SignatureEnvelope.Primitive<numberType> {
|
|
1195
|
+
if (signature.type === 'keychain' || signature.type === 'multisig')
|
|
1196
|
+
throw new InvalidSignatureTypeError(signature.type)
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1167
1199
|
function isAbsent(value: unknown): boolean {
|
|
1168
1200
|
return value === undefined || value === '0x'
|
|
1169
1201
|
}
|
|
@@ -1187,3 +1219,13 @@ export class InvalidAdminMarkerError extends Error {
|
|
|
1187
1219
|
)
|
|
1188
1220
|
}
|
|
1189
1221
|
}
|
|
1222
|
+
|
|
1223
|
+
/** Thrown when a key authorization contains a non-primitive signature. */
|
|
1224
|
+
export class InvalidSignatureTypeError extends Error {
|
|
1225
|
+
override readonly name = 'KeyAuthorization.InvalidSignatureTypeError'
|
|
1226
|
+
constructor(type: SignatureEnvelope.SignatureEnvelope['type']) {
|
|
1227
|
+
super(
|
|
1228
|
+
`Signature type \`${type}\` is invalid for key authorizations; expected \`secp256k1\`, \`p256\`, or \`webAuthn\`.`,
|
|
1229
|
+
)
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
@@ -154,7 +154,12 @@ describe('assert / validate', () => {
|
|
|
154
154
|
owner: `0x${(i + 1).toString(16).padStart(40, '0')}` as `0x${string}`,
|
|
155
155
|
weight: 1,
|
|
156
156
|
}))
|
|
157
|
-
expect(
|
|
157
|
+
expect(
|
|
158
|
+
MultisigConfig.validate({
|
|
159
|
+
threshold: MultisigConfig.maxThreshold,
|
|
160
|
+
owners,
|
|
161
|
+
}),
|
|
162
|
+
).toBe(true)
|
|
158
163
|
})
|
|
159
164
|
|
|
160
165
|
test('too many owners', () => {
|
|
@@ -174,6 +179,24 @@ describe('assert / validate', () => {
|
|
|
174
179
|
).toBe(false)
|
|
175
180
|
})
|
|
176
181
|
|
|
182
|
+
test('threshold exceeds protocol maximum', () => {
|
|
183
|
+
expect(
|
|
184
|
+
MultisigConfig.validate({
|
|
185
|
+
threshold: MultisigConfig.maxThreshold + 1,
|
|
186
|
+
owners: [{ owner: owner1, weight: MultisigConfig.maxThreshold + 1 }],
|
|
187
|
+
}),
|
|
188
|
+
).toBe(false)
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
test('fractional threshold', () => {
|
|
192
|
+
expect(
|
|
193
|
+
MultisigConfig.validate({
|
|
194
|
+
threshold: 1.5,
|
|
195
|
+
owners: [{ owner: owner1, weight: 2 }],
|
|
196
|
+
}),
|
|
197
|
+
).toBe(false)
|
|
198
|
+
})
|
|
199
|
+
|
|
177
200
|
test('threshold exceeds total weight', () => {
|
|
178
201
|
expect(
|
|
179
202
|
MultisigConfig.validate({
|
|
@@ -186,7 +209,7 @@ describe('assert / validate', () => {
|
|
|
186
209
|
test('total weight exceeds u8 max', () => {
|
|
187
210
|
expect(
|
|
188
211
|
MultisigConfig.validate({
|
|
189
|
-
threshold:
|
|
212
|
+
threshold: MultisigConfig.maxThreshold,
|
|
190
213
|
owners: [
|
|
191
214
|
{ owner: owner1, weight: 128 },
|
|
192
215
|
{ owner: owner2, weight: 128 },
|
|
@@ -204,6 +227,15 @@ describe('assert / validate', () => {
|
|
|
204
227
|
).toBe(false)
|
|
205
228
|
})
|
|
206
229
|
|
|
230
|
+
test('fractional owner weight', () => {
|
|
231
|
+
expect(
|
|
232
|
+
MultisigConfig.validate({
|
|
233
|
+
threshold: 1,
|
|
234
|
+
owners: [{ owner: owner1, weight: 1.5 }],
|
|
235
|
+
}),
|
|
236
|
+
).toBe(false)
|
|
237
|
+
})
|
|
238
|
+
|
|
207
239
|
test('zero owner address', () => {
|
|
208
240
|
expect(
|
|
209
241
|
MultisigConfig.validate({
|
|
@@ -8,13 +8,19 @@ import type { Compute, OneOf } from '../core/internal/types.js'
|
|
|
8
8
|
/** Maximum number of owners allowed in a native multisig config. */
|
|
9
9
|
export const maxOwners = 255
|
|
10
10
|
|
|
11
|
+
/** Maximum threshold accepted by a native multisig config. */
|
|
12
|
+
export const maxThreshold = 8
|
|
13
|
+
|
|
14
|
+
/** Maximum number of owner approvals in a native multisig signature. */
|
|
15
|
+
export const maxSignatures = maxThreshold
|
|
16
|
+
|
|
11
17
|
/**
|
|
12
18
|
* Maximum number of native multisig signatures in one nested authorization
|
|
13
19
|
* path, including the top-level transaction signature.
|
|
14
20
|
*/
|
|
15
|
-
export const maxNestingDepth =
|
|
21
|
+
export const maxNestingDepth = 2
|
|
16
22
|
|
|
17
|
-
/** Maximum encoded byte length for one
|
|
23
|
+
/** Maximum encoded byte length for one owner approval. */
|
|
18
24
|
export const maxOwnerSignatureBytes = 2049
|
|
19
25
|
|
|
20
26
|
/** Tempo signature type byte for native multisig signatures. */
|
|
@@ -65,8 +71,8 @@ export type Tuple = readonly [
|
|
|
65
71
|
*
|
|
66
72
|
* Mirrors the Tempo `InitMultisig::validate` rules: owners non-empty and
|
|
67
73
|
* `<= maxOwners`, strictly ascending unique nonzero owner addresses, nonzero
|
|
68
|
-
* owner weights, `threshold
|
|
69
|
-
* `threshold <= total weight`.
|
|
74
|
+
* integer owner weights, integer `threshold` between `1` and `maxThreshold`,
|
|
75
|
+
* total weight `<= 255` (u8 max), and `threshold <= total weight`.
|
|
70
76
|
*
|
|
71
77
|
* @example
|
|
72
78
|
* ```ts twoslash
|
|
@@ -94,14 +100,22 @@ export function assert<numberType = number>(config: Config<numberType>): void {
|
|
|
94
100
|
throw new InvalidConfigError({ reason: 'owners cannot be empty' })
|
|
95
101
|
if (owners.length > maxOwners)
|
|
96
102
|
throw new InvalidConfigError({ reason: 'too many owners' })
|
|
103
|
+
if (!Number.isInteger(Number(threshold)))
|
|
104
|
+
throw new InvalidConfigError({ reason: 'threshold must be an integer' })
|
|
97
105
|
if (Number(threshold) < 1)
|
|
98
106
|
throw new InvalidConfigError({ reason: 'threshold cannot be zero' })
|
|
107
|
+
if (Number(threshold) > maxThreshold)
|
|
108
|
+
throw new InvalidConfigError({ reason: 'threshold exceeds max threshold' })
|
|
99
109
|
|
|
100
110
|
let totalWeight = 0
|
|
101
111
|
let previous: bigint | undefined
|
|
102
112
|
for (const owner of owners) {
|
|
103
113
|
if (!Address.validate(owner.owner) || Hex.toBigInt(owner.owner) === 0n)
|
|
104
114
|
throw new InvalidConfigError({ reason: 'owner cannot be zero' })
|
|
115
|
+
if (!Number.isInteger(Number(owner.weight)))
|
|
116
|
+
throw new InvalidConfigError({
|
|
117
|
+
reason: 'owner weight must be an integer',
|
|
118
|
+
})
|
|
105
119
|
if (Number(owner.weight) < 1)
|
|
106
120
|
throw new InvalidConfigError({ reason: 'owner weight cannot be zero' })
|
|
107
121
|
|