ox 1.6.2 → 1.7.0
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 +18 -0
- package/dist/core/AesGcm.d.ts +67 -2
- package/dist/core/AesGcm.d.ts.map +1 -1
- package/dist/core/AesGcm.js +79 -10
- package/dist/core/AesGcm.js.map +1 -1
- package/dist/core/Ed25519.d.ts +83 -2
- package/dist/core/Ed25519.d.ts.map +1 -1
- package/dist/core/Ed25519.js +79 -4
- package/dist/core/Ed25519.js.map +1 -1
- package/dist/core/MlDsa44.d.ts +84 -5
- package/dist/core/MlDsa44.d.ts.map +1 -1
- package/dist/core/MlDsa44.js +79 -4
- package/dist/core/MlDsa44.js.map +1 -1
- package/dist/core/P256.d.ts +82 -1
- package/dist/core/P256.d.ts.map +1 -1
- package/dist/core/P256.js +78 -0
- package/dist/core/P256.js.map +1 -1
- package/dist/core/Secp256k1.d.ts +85 -1
- package/dist/core/Secp256k1.d.ts.map +1 -1
- package/dist/core/Secp256k1.js +74 -3
- package/dist/core/Secp256k1.js.map +1 -1
- package/dist/core/internal/keyDerivation.d.ts +13 -0
- package/dist/core/internal/keyDerivation.d.ts.map +1 -0
- package/dist/core/internal/keyDerivation.js +13 -0
- package/dist/core/internal/keyDerivation.js.map +1 -0
- package/dist/tempo/KeyAuthorization.d.ts +16 -12
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorization.js +7 -13
- package/dist/tempo/KeyAuthorization.js.map +1 -1
- package/dist/tempo/MultisigConfig.d.ts +20 -17
- package/dist/tempo/MultisigConfig.d.ts.map +1 -1
- package/dist/tempo/MultisigConfig.js +17 -16
- package/dist/tempo/MultisigConfig.js.map +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts +19 -17
- package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.js +35 -27
- package/dist/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/tempo/index.d.ts +2 -2
- package/dist/tempo/index.js +2 -2
- package/dist/zod/tempo/KeyAuthorization.d.ts +231 -22
- package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.js +10 -2
- package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
- package/dist/zod/tempo/RpcSchemaTempo.d.ts +82 -8
- package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/zod/tempo/Transaction.d.ts +246 -24
- package/dist/zod/tempo/Transaction.d.ts.map +1 -1
- package/dist/zod/tempo/TransactionRequest.d.ts +149 -14
- package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/zod/tempo/TxEnvelopeTempo.d.ts +78 -6
- package/dist/zod/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/AesGcm.ts +137 -30
- package/src/core/Ed25519.ts +135 -4
- package/src/core/MlDsa44.ts +135 -4
- package/src/core/P256.ts +135 -1
- package/src/core/Secp256k1.ts +134 -3
- package/src/core/_test/AesGcm.test-d.ts +19 -0
- package/src/core/_test/AesGcm.test.ts +90 -1
- package/src/core/_test/Ed25519.test-d.ts +24 -0
- package/src/core/_test/Ed25519.test.ts +87 -1
- package/src/core/_test/MlDsa44.test-d.ts +24 -0
- package/src/core/_test/MlDsa44.test.ts +69 -1
- package/src/core/_test/P256.test-d.ts +26 -0
- package/src/core/_test/P256.test.ts +98 -1
- package/src/core/_test/Secp256k1.test-d.ts +27 -0
- package/src/core/_test/Secp256k1.test.ts +112 -1
- package/src/core/internal/keyDerivation.ts +34 -0
- package/src/tempo/KeyAuthorization.test-d.ts +41 -6
- package/src/tempo/KeyAuthorization.test.ts +77 -18
- package/src/tempo/KeyAuthorization.ts +36 -36
- package/src/tempo/MultisigConfig.test.ts +28 -8
- package/src/tempo/MultisigConfig.ts +28 -19
- package/src/tempo/SignatureEnvelope.test.ts +64 -19
- package/src/tempo/SignatureEnvelope.ts +45 -35
- package/src/tempo/index.ts +2 -2
- package/src/tempo/multisig.e2e.test.ts +402 -145
- package/src/version.ts +1 -1
- package/src/zod/tempo/KeyAuthorization.ts +12 -2
- package/src/zod/tempo/_test/KeyAuthorization.test.ts +19 -5
|
@@ -434,12 +434,13 @@ function assertMultisig(envelope: Multisig, depth: number): void {
|
|
|
434
434
|
reason: 'nested multisig owner approvals cannot carry `init`',
|
|
435
435
|
})
|
|
436
436
|
assertMultisig(multisig, depth + 1)
|
|
437
|
-
} else
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
437
|
+
} else {
|
|
438
|
+
assert(inner)
|
|
439
|
+
if (Hex.size(serialize(inner)) > MultisigConfig.maxOwnerSignatureBytes)
|
|
440
|
+
throw new InvalidMultisigApprovalError({
|
|
441
|
+
reason: `multisig owner signature exceeds ${MultisigConfig.maxOwnerSignatureBytes} bytes`,
|
|
442
|
+
})
|
|
443
|
+
}
|
|
443
444
|
}
|
|
444
445
|
}
|
|
445
446
|
|
|
@@ -750,7 +751,10 @@ function deserialize_(
|
|
|
750
751
|
})
|
|
751
752
|
for (const signature of signatures)
|
|
752
753
|
if (
|
|
753
|
-
Hex.size(signature as Hex.Hex) >
|
|
754
|
+
Hex.size(signature as Hex.Hex) >
|
|
755
|
+
MultisigConfig.maxOwnerSignatureBytes &&
|
|
756
|
+
Hex.slice(signature as Hex.Hex, 0, 1) !==
|
|
757
|
+
MultisigConfig.signatureTypeByte
|
|
754
758
|
)
|
|
755
759
|
throw new InvalidSerializedError({
|
|
756
760
|
reason: `multisig owner signature exceeds ${MultisigConfig.maxOwnerSignatureBytes} bytes`,
|
|
@@ -935,17 +939,17 @@ function deserialize_(
|
|
|
935
939
|
* ```
|
|
936
940
|
*
|
|
937
941
|
* @example
|
|
938
|
-
* ### Multisig (from
|
|
942
|
+
* ### Multisig (from initial config)
|
|
939
943
|
*
|
|
940
|
-
* Pass `
|
|
941
|
-
* opt into bootstrap (uses `
|
|
944
|
+
* Pass `initialConfig` to derive `account` automatically. Set `init: true` to
|
|
945
|
+
* opt into bootstrap (uses `initialConfig` as the bootstrap `init`); omit
|
|
942
946
|
* `init` for subsequent (non-bootstrap) transactions.
|
|
943
947
|
*
|
|
944
948
|
* ```ts twoslash
|
|
945
949
|
* import { Secp256k1 } from 'ox'
|
|
946
950
|
* import { MultisigConfig, SignatureEnvelope } from 'ox/tempo'
|
|
947
951
|
*
|
|
948
|
-
* const
|
|
952
|
+
* const initialConfig = MultisigConfig.from({
|
|
949
953
|
* threshold: 1,
|
|
950
954
|
* owners: [
|
|
951
955
|
* {
|
|
@@ -962,14 +966,14 @@ function deserialize_(
|
|
|
962
966
|
*
|
|
963
967
|
* // Bootstrap transaction
|
|
964
968
|
* const bootstrap = SignatureEnvelope.from({
|
|
965
|
-
*
|
|
969
|
+
* initialConfig,
|
|
966
970
|
* signatures: [signature],
|
|
967
971
|
* init: true
|
|
968
972
|
* })
|
|
969
973
|
*
|
|
970
974
|
* // Subsequent (non-bootstrap) transactions
|
|
971
975
|
* const subsequent = SignatureEnvelope.from({
|
|
972
|
-
*
|
|
976
|
+
* initialConfig,
|
|
973
977
|
* signatures: [signature]
|
|
974
978
|
* })
|
|
975
979
|
* ```
|
|
@@ -996,20 +1000,20 @@ export function from<const value extends from.Value>(
|
|
|
996
1000
|
|
|
997
1001
|
if (type === 'multisig') {
|
|
998
1002
|
const multisig = value as Multisig & {
|
|
999
|
-
|
|
1003
|
+
initialConfig?: MultisigConfig.Config | undefined
|
|
1000
1004
|
init?: MultisigConfig.Config | boolean | undefined
|
|
1001
1005
|
}
|
|
1002
|
-
const {
|
|
1003
|
-
// Derive `account` from `
|
|
1006
|
+
const { initialConfig, init, ...rest } = multisig
|
|
1007
|
+
// Derive `account` from `initialConfig` when not provided explicitly.
|
|
1004
1008
|
const account = (() => {
|
|
1005
1009
|
if (rest.account) return rest.account
|
|
1006
|
-
if (
|
|
1010
|
+
if (initialConfig) return MultisigConfig.getAddress(initialConfig)
|
|
1007
1011
|
return rest.account
|
|
1008
1012
|
})()
|
|
1009
|
-
// `init: true` opts into bootstrap using the supplied `
|
|
1013
|
+
// `init: true` opts into bootstrap using the supplied `initialConfig`.
|
|
1010
1014
|
// Otherwise, `init` is treated as the explicit bootstrap config (or
|
|
1011
1015
|
// omitted).
|
|
1012
|
-
const initSource = init === true ?
|
|
1016
|
+
const initSource = init === true ? initialConfig : init || undefined
|
|
1013
1017
|
return {
|
|
1014
1018
|
...rest,
|
|
1015
1019
|
account,
|
|
@@ -1065,13 +1069,13 @@ export declare namespace from {
|
|
|
1065
1069
|
|
|
1066
1070
|
/**
|
|
1067
1071
|
* Multisig envelope input variant where `account` is derived from the
|
|
1068
|
-
* supplied `
|
|
1069
|
-
* `
|
|
1072
|
+
* supplied `initialConfig`. Pass `init: true` to opt into bootstrap (uses
|
|
1073
|
+
* `initialConfig` as the bootstrap `init`); omit `init` for subsequent
|
|
1070
1074
|
* (non-bootstrap) transactions.
|
|
1071
1075
|
*/
|
|
1072
|
-
type
|
|
1076
|
+
type MultisigFromInitialConfig = {
|
|
1073
1077
|
type?: 'multisig' | undefined
|
|
1074
|
-
|
|
1078
|
+
initialConfig: MultisigConfig.Config
|
|
1075
1079
|
signatures: readonly SignatureEnvelope[]
|
|
1076
1080
|
init?: MultisigConfig.Config | boolean | undefined
|
|
1077
1081
|
}
|
|
@@ -1080,7 +1084,7 @@ export declare namespace from {
|
|
|
1080
1084
|
| UnionPartialBy<SignatureEnvelope, 'prehash' | 'type'>
|
|
1081
1085
|
| Secp256k1Flat
|
|
1082
1086
|
| Serialized
|
|
1083
|
-
|
|
|
1087
|
+
| MultisigFromInitialConfig
|
|
1084
1088
|
|
|
1085
1089
|
type ReturnValue<value extends Value> = Compute<
|
|
1086
1090
|
OneOf<
|
|
@@ -1088,7 +1092,7 @@ export declare namespace from {
|
|
|
1088
1092
|
? SignatureEnvelope
|
|
1089
1093
|
: value extends Secp256k1Flat
|
|
1090
1094
|
? Secp256k1
|
|
1091
|
-
: value extends
|
|
1095
|
+
: value extends MultisigFromInitialConfig
|
|
1092
1096
|
? Multisig
|
|
1093
1097
|
: IsNarrowable<value, SignatureEnvelope> extends true
|
|
1094
1098
|
? SignatureEnvelope
|
|
@@ -1315,7 +1319,7 @@ export function getType<
|
|
|
1315
1319
|
// Detect Multisig signature
|
|
1316
1320
|
if (
|
|
1317
1321
|
('account' in envelope ||
|
|
1318
|
-
'
|
|
1322
|
+
'initialConfig' in envelope ||
|
|
1319
1323
|
'init' in envelope) &&
|
|
1320
1324
|
'signatures' in envelope
|
|
1321
1325
|
)
|
|
@@ -1470,7 +1474,7 @@ export declare namespace serialize {
|
|
|
1470
1474
|
* recovered owner address. Works for any owner key type (secp256k1, p256,
|
|
1471
1475
|
* webAuthn).
|
|
1472
1476
|
*
|
|
1473
|
-
* Config updates never change `account`, so the
|
|
1477
|
+
* Config updates never change `account`, so the initial config is the correct
|
|
1474
1478
|
* input even for post-update transactions.
|
|
1475
1479
|
*
|
|
1476
1480
|
* @example
|
|
@@ -1482,7 +1486,7 @@ export declare namespace serialize {
|
|
|
1482
1486
|
* TxEnvelopeTempo
|
|
1483
1487
|
* } from 'ox/tempo'
|
|
1484
1488
|
*
|
|
1485
|
-
* const
|
|
1489
|
+
* const initialConfig = MultisigConfig.from({
|
|
1486
1490
|
* threshold: 2,
|
|
1487
1491
|
* owners: [
|
|
1488
1492
|
* {
|
|
@@ -1505,7 +1509,7 @@ export declare namespace serialize {
|
|
|
1505
1509
|
* ]
|
|
1506
1510
|
* const digest = MultisigConfig.getSignPayload({
|
|
1507
1511
|
* payload,
|
|
1508
|
-
*
|
|
1512
|
+
* initialConfig
|
|
1509
1513
|
* })
|
|
1510
1514
|
* const signatures = privateKeys.map((privateKey) =>
|
|
1511
1515
|
* SignatureEnvelope.from(
|
|
@@ -1515,7 +1519,7 @@ export declare namespace serialize {
|
|
|
1515
1519
|
*
|
|
1516
1520
|
* const ordered = SignatureEnvelope.sortMultisigApprovals({
|
|
1517
1521
|
* // [!code focus]
|
|
1518
|
-
*
|
|
1522
|
+
* initialConfig, // [!code focus]
|
|
1519
1523
|
* payload, // [!code focus]
|
|
1520
1524
|
* signatures // [!code focus]
|
|
1521
1525
|
* }) // [!code focus]
|
|
@@ -1527,11 +1531,15 @@ export declare namespace serialize {
|
|
|
1527
1531
|
export function sortMultisigApprovals(
|
|
1528
1532
|
value: sortMultisigApprovals.Value,
|
|
1529
1533
|
): readonly SignatureEnvelope[] {
|
|
1530
|
-
const { payload, signatures } = value
|
|
1534
|
+
const { payload, signatures, version = 0n } = value
|
|
1531
1535
|
const digest = MultisigConfig.getSignPayload(
|
|
1532
|
-
'
|
|
1533
|
-
? { payload,
|
|
1534
|
-
: {
|
|
1536
|
+
'initialConfig' in value && value.initialConfig
|
|
1537
|
+
? { payload, initialConfig: value.initialConfig, version }
|
|
1538
|
+
: {
|
|
1539
|
+
payload,
|
|
1540
|
+
account: (value as { account: Address.Address }).account,
|
|
1541
|
+
version,
|
|
1542
|
+
},
|
|
1535
1543
|
)
|
|
1536
1544
|
// Recover each signer once (decorate–sort–undecorate) rather than inside the
|
|
1537
1545
|
// comparator.
|
|
@@ -1550,6 +1558,8 @@ export declare namespace sortMultisigApprovals {
|
|
|
1550
1558
|
payload: Hex.Hex | Bytes.Bytes
|
|
1551
1559
|
/** The owner approvals to order. */
|
|
1552
1560
|
signatures: readonly SignatureEnvelope[]
|
|
1561
|
+
/** Current multisig config version. Defaults to `0n`. */
|
|
1562
|
+
version?: bigint | undefined
|
|
1553
1563
|
} & OneOf<
|
|
1554
1564
|
| {
|
|
1555
1565
|
/** The native multisig account address. */
|
|
@@ -1560,7 +1570,7 @@ export declare namespace sortMultisigApprovals {
|
|
|
1560
1570
|
* The initial multisig config (the bootstrap config that derived the
|
|
1561
1571
|
* permanent `account`). Used to derive the account automatically.
|
|
1562
1572
|
*/
|
|
1563
|
-
|
|
1573
|
+
initialConfig: MultisigConfig.Config
|
|
1564
1574
|
}
|
|
1565
1575
|
>
|
|
1566
1576
|
|
package/src/tempo/index.ts
CHANGED
|
@@ -153,7 +153,7 @@ export * as KeyAuthorization from './KeyAuthorization.js'
|
|
|
153
153
|
* ```ts twoslash
|
|
154
154
|
* import { MultisigConfig } from 'ox/tempo'
|
|
155
155
|
*
|
|
156
|
-
* const
|
|
156
|
+
* const initialConfig = MultisigConfig.from({
|
|
157
157
|
* threshold: 2,
|
|
158
158
|
* owners: [
|
|
159
159
|
* {
|
|
@@ -167,7 +167,7 @@ export * as KeyAuthorization from './KeyAuthorization.js'
|
|
|
167
167
|
* ]
|
|
168
168
|
* })
|
|
169
169
|
*
|
|
170
|
-
* const account = MultisigConfig.getAddress(
|
|
170
|
+
* const account = MultisigConfig.getAddress(initialConfig)
|
|
171
171
|
* ```
|
|
172
172
|
*
|
|
173
173
|
* @category Reference
|