@ledgerhq/revault-api 1.45.0 → 1.46.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/lib/fakes.mjs CHANGED
@@ -3,10 +3,10 @@ import { faker } from '@faker-js/faker';
3
3
  import { ChallengeType, PsdModel, UserRole, UserRegistrationState, AllowedAction, AdminPermission, RequestType, AccountGovernanceType, ActivationStatus, AccountType, MessageType, WhitelistType, UserDeviceType, RequestReviewStatus, RequestState, GateAccountType, GateUserType } from '@prisma/client';
4
4
  import { match, P } from 'ts-pattern';
5
5
  import z14, { z } from 'zod';
6
- import invariant8 from 'invariant';
7
- import elliptic from 'elliptic';
8
- import { omit, times, get, isPlainObject } from 'lodash-es';
6
+ import invariant5 from 'invariant';
9
7
  import 'axios';
8
+ import { omit, times, get, isPlainObject } from 'lodash-es';
9
+ import elliptic from 'elliptic';
10
10
 
11
11
  var zHexString = z.string().regex(/^[0-9a-fA-F]+$/);
12
12
  var zIntString = z.string().nonempty().regex(/^(-?[1-9]\d*|0)$/);
@@ -128,7 +128,7 @@ var zCantonTransferProposal = z14.object({
128
128
  instrumentAdmin: z14.string().meta({ description: "Issuer of the instrument being transferred" }),
129
129
  instrumentId: z14.string().meta({ description: "ID of the instrument being transferred" }),
130
130
  expiresAtMicros: z14.number().int().meta({ description: "Expiration timestamp in microseconds" }),
131
- memo: z14.string().nullable().meta({ description: "Optional note attached to the proposal" }),
131
+ reason: z14.string().nullable().meta({ description: "Optional reason attached to the transfer" }),
132
132
  sender: z14.string().meta({ description: "Party proposing to send the asset" }),
133
133
  recipient: z14.string().meta({ description: "Intended recipient of the proposed transfer" })
134
134
  }).meta({
@@ -151,8 +151,10 @@ var zCantonLikeTransactionType = z14.enum([
151
151
  "CANTON_LIKE_TAP"
152
152
  ]).meta({ description: "Canton-like transaction type" });
153
153
  var zExecuteBeforeSeconds = z14.number().int().positive().optional().meta({ description: "Execute before seconds" });
154
+ var zCantonReason = z14.string().nullable().meta({ description: "Optional reason attached to the onchain operation" });
154
155
  var zCantonLikeSendData = zCommonTransactionData.omit({ maxFee: true }).extend({
155
156
  executeBeforeSeconds: zExecuteBeforeSeconds,
157
+ reason: zCantonReason,
156
158
  type: z14.literal(zCantonLikeTransactionType.enum.CANTON_LIKE_SEND)
157
159
  }).meta({
158
160
  description: "Canton-like send data",
@@ -160,6 +162,7 @@ var zCantonLikeSendData = zCommonTransactionData.omit({ maxFee: true }).extend({
160
162
  });
161
163
  var zCantonLikeSendTokenData = zCommonTransactionData.omit({ maxFee: true }).extend({
162
164
  executeBeforeSeconds: zExecuteBeforeSeconds,
165
+ reason: zCantonReason,
163
166
  type: z14.literal(zCantonLikeTransactionType.enum.CANTON_LIKE_SEND_TOKEN)
164
167
  }).meta({
165
168
  description: "Canton-like send token data",
@@ -218,7 +221,7 @@ var zCantonLikeTransactionData = z14.discriminatedUnion("type", [
218
221
  zCantonLikeTapData
219
222
  ]);
220
223
  var zCantonLikeTransactionResponse = z14.discriminatedUnion("type", [
221
- zCommonTransactionResponse.extend({ type: zCantonLikeTransactionType }).meta({ description: "Canton-like transaction" })
224
+ zCommonTransactionResponse.extend({ type: zCantonLikeTransactionType, reason: zCantonReason }).meta({ description: "Canton-like transaction" })
222
225
  ]);
223
226
 
224
227
  // src/networks/canton/index.ts
@@ -457,6 +460,40 @@ var GENERIC_SPEC = {
457
460
  zEstimatedFees: z14.never(),
458
461
  zTransactionResponse: zGenericTransactionResponse,
459
462
  zStakingFields: z14.never()};
463
+
464
+ // src/errors.ts
465
+ var ValidationError = class extends Error {
466
+ };
467
+
468
+ // src/sync-utils.ts
469
+ var GATE_SYNC_ID_PREFIX = "gate://";
470
+ var buildGateSyncId = (workspaceName, gateType, gateId) => {
471
+ if (gateId <= 0) {
472
+ throw new ValidationError(`Invalid gate ID: ${gateId}`);
473
+ }
474
+ return `${GATE_SYNC_ID_PREFIX}${workspaceName}/${gateType}/${gateId}`;
475
+ };
476
+
477
+ // src/utils.ts
478
+ var isRecord = (value) => isPlainObject(value);
479
+ var randomHex = (length) => {
480
+ const hexBytes = times(length, () => {
481
+ const randomByte = Math.floor(Math.random() * 256);
482
+ return randomByte.toString(16).padStart(2, "0");
483
+ });
484
+ return hexBytes.join("").toUpperCase();
485
+ };
486
+ var genAuthUserId = () => randomHex(20);
487
+ var ensureNonEmptyArray = (values, message) => {
488
+ invariant5(
489
+ values.length > 0,
490
+ `Expected non-empty array but got one with length ${values.length}`
491
+ );
492
+ return values;
493
+ };
494
+ function unreachable(value) {
495
+ throw new Error(`Un-covered: ${value}`);
496
+ }
460
497
  var zHederaLikeAssetFields = z14.object({
461
498
  type: z14.literal(NetworkFamily.HEDERA_LIKE).meta({ description: "Account type" }),
462
499
  address: z14.string().nullable().meta({ description: "Account address" }),
@@ -470,11 +507,18 @@ var zHederaLikeTransactionType = z14.enum([
470
507
  "HEDERA_LIKE_SEND",
471
508
  "HEDERA_LIKE_RECEIVE",
472
509
  "HEDERA_LIKE_SEND_TOKEN",
473
- "HEDERA_LIKE_RECEIVE_TOKEN"
510
+ "HEDERA_LIKE_RECEIVE_TOKEN",
511
+ "HEDERA_LIKE_STAKE"
474
512
  ]).meta({ description: "Hedera-like transaction type" });
475
- var zHederaLikeLiveData = zCommonLiveData.extend({
476
- type: z14.literal(NetworkFamily.HEDERA_LIKE).meta({ description: "Account type" })
477
- }).meta({ description: "Hedera-like" });
513
+ var zHederaLikeStakingData = z14.object({
514
+ totalStaked: z14.string().meta({ description: "Total staked amount" }),
515
+ totalRewards: z14.string().meta({ description: "Total of rewards" })
516
+ }).nullable().meta({ description: "Hedera-like staking data" });
517
+ var zHederaLikeStakingFields = z14.object({
518
+ type: z14.literal(NetworkFamily.HEDERA_LIKE).meta({ description: "Account type" }),
519
+ staking: zHederaLikeStakingData.optional()
520
+ });
521
+ var zHederaLikeLiveData = zCommonLiveData.extend(zHederaLikeStakingFields.shape).meta({ description: "Hedera-like" });
478
522
  var zHederaLikeSendData = zCommonTransactionData.extend({
479
523
  type: z14.literal(zHederaLikeTransactionType.enum.HEDERA_LIKE_SEND),
480
524
  feeStrategy: zFeeStrategy
@@ -489,9 +533,20 @@ var zHederaLikeSendTokenData = zCommonTransactionData.extend({
489
533
  description: "Hedera-like send token data",
490
534
  id: "HederaLikeSendTokenData"
491
535
  });
536
+ var zHederaLikeStakeData = z14.object({
537
+ type: z14.literal(zHederaLikeTransactionType.enum.HEDERA_LIKE_STAKE),
538
+ currency: zCurrencyString.meta({ description: "Transaction currency" }),
539
+ nodeId: zIntString.meta({ description: "Node ID to delegate to" }),
540
+ maxFee: zUnsignedIntString.nullable().meta({ description: "Transaction max fee" }),
541
+ feeStrategy: zFeeStrategy
542
+ }).meta({
543
+ description: "Hedera-like stake data",
544
+ id: "HederaLikeStakeData"
545
+ });
492
546
  var zHederaLikeTransactionData = z14.discriminatedUnion("type", [
493
547
  zHederaLikeSendData,
494
- zHederaLikeSendTokenData
548
+ zHederaLikeSendTokenData,
549
+ zHederaLikeStakeData
495
550
  ]);
496
551
  var zHederaLikeTransactionResponse = z14.discriminatedUnion("type", [
497
552
  zCommonTransactionResponse.extend({
@@ -508,7 +563,7 @@ var HEDERA_SPEC = {
508
563
  zSendTransactionData: zHederaLikeSendData,
509
564
  zEstimatedFees: zHederaLikeEstimatedFees,
510
565
  zTransactionResponse: zHederaLikeTransactionResponse,
511
- zStakingFields: z.never()};
566
+ zStakingFields: zHederaLikeStakingFields};
512
567
  var zPolkadotLikeAssetFields = z14.object({
513
568
  type: z14.literal(NetworkFamily.POLKADOT_LIKE).meta({ description: "Account type" }),
514
569
  address: z14.string().nullable().meta({ description: "Account address" })
@@ -1240,6 +1295,7 @@ var zAccountLiveData = z14.discriminatedUnion("type", [
1240
1295
  z14.discriminatedUnion("type", [
1241
1296
  CARDANO_SPEC.zStakingFields,
1242
1297
  ETHEREUM_SPEC.zStakingFields,
1298
+ HEDERA_SPEC.zStakingFields,
1243
1299
  POLKADOT_SPEC.zStakingFields,
1244
1300
  SOLANA_SPEC.zStakingFields,
1245
1301
  SUI_SPEC.zStakingFields,
@@ -1328,42 +1384,6 @@ var zTransactionResponse = z14.discriminatedUnion("type", [
1328
1384
  ...TEZOS_SPEC.zTransactionResponse.options,
1329
1385
  ...TRON_SPEC.zTransactionResponse.options
1330
1386
  ]);
1331
-
1332
- // src/errors.ts
1333
- var ValidationError = class extends Error {
1334
- };
1335
-
1336
- // src/sync-utils.ts
1337
- var GATE_SYNC_ID_PREFIX = "gate://";
1338
- var buildGateSyncId = (workspaceName, gateType, gateId) => {
1339
- if (gateId <= 0) {
1340
- throw new ValidationError(`Invalid gate ID: ${gateId}`);
1341
- }
1342
- return `${GATE_SYNC_ID_PREFIX}${workspaceName}/${gateType}/${gateId}`;
1343
- };
1344
-
1345
- // src/utils.ts
1346
- var isRecord = (value) => isPlainObject(value);
1347
- var randomHex = (length) => {
1348
- const hexBytes = times(length, () => {
1349
- const randomByte = Math.floor(Math.random() * 256);
1350
- return randomByte.toString(16).padStart(2, "0");
1351
- });
1352
- return hexBytes.join("").toUpperCase();
1353
- };
1354
- var genAuthUserId = () => randomHex(20);
1355
- var ensureNonEmptyArray = (values, message) => {
1356
- invariant8(
1357
- values.length > 0,
1358
- `Expected non-empty array but got one with length ${values.length}`
1359
- );
1360
- return values;
1361
- };
1362
- function unreachable(value) {
1363
- throw new Error(`Un-covered: ${value}`);
1364
- }
1365
-
1366
- // src/__fakes__/faker-utils.ts
1367
1387
  var { ec: EC } = elliptic;
1368
1388
  var fakeUniqueName = (length = 20) => faker.string.alphanumeric({ length, casing: "lower" });
1369
1389
  var fakeHexString = (length, casing = "upper") => faker.string.hexadecimal({ prefix: "", casing, length });
@@ -1402,7 +1422,7 @@ var fakeCantonTransferProposal = (opts) => {
1402
1422
  instrumentAdmin: fakeCantonPartyId(),
1403
1423
  instrumentId: fakeCantonInstrumentId(),
1404
1424
  expiresAtMicros: faker.number.int(),
1405
- memo: faker.lorem.sentence(),
1425
+ reason: faker.lorem.sentence(),
1406
1426
  sender: fakeCantonPartyId(),
1407
1427
  recipient: fakeCantonPartyId(),
1408
1428
  ...opts
@@ -1453,7 +1473,7 @@ var genConsistentAccountType = (opts) => {
1453
1473
  };
1454
1474
  var genAssetFieldsForType = (type) => {
1455
1475
  const currency = faker.helpers.arrayElement(
1456
- type === "RAW_SIGNING" ? ["ethereum", "bitcoin"] : WELL_KNOWN_NETWORKS_BY_FAMILY[type]
1476
+ type === "RAW_SIGNING" ? ["ethereum", "bitcoin", "sui"] : WELL_KNOWN_NETWORKS_BY_FAMILY[type]
1457
1477
  );
1458
1478
  const hsmXpub = fakeHexString(66, "upper");
1459
1479
  const hsmChainCode = fakeHexString(64, "upper");
@@ -1687,16 +1707,46 @@ var genAccount = (opts) => {
1687
1707
  ...rest
1688
1708
  });
1689
1709
  };
1690
- var genSignMessageData = (opts) => ({
1691
- message: {
1692
- type: "EIP191",
1693
- data: fakeHexString(10, "upper")
1694
- },
1695
- accountId: faker.string.uuid(),
1696
- address: faker.finance.ethereumAddress(),
1697
- derivationPath: "44'/60'/0'/0/0",
1698
- ...opts
1699
- });
1710
+ var genSignMessageData = (opts) => getSignMessageDataForType(MessageType.EIP191, opts);
1711
+ var getSignMessageDataForType = (type, opts) => {
1712
+ return {
1713
+ message: type === MessageType.EIP712 ? {
1714
+ type: "EIP712",
1715
+ data: {
1716
+ types: {
1717
+ EIP712Domain: [
1718
+ { name: "name", type: "string" },
1719
+ { name: "version", type: "string" },
1720
+ { name: "chainId", type: "uint256" },
1721
+ { name: "verifyingContract", type: "address" }
1722
+ ],
1723
+ PrimaryType: [
1724
+ { name: "a", type: "int256" },
1725
+ { name: "b", type: "bool" }
1726
+ ]
1727
+ },
1728
+ primaryType: "PrimaryType",
1729
+ domain: {
1730
+ name: "Test Domain",
1731
+ version: "1",
1732
+ chainId: 1,
1733
+ verifyingContract: "0x1234567890123456789012345678901234567890"
1734
+ },
1735
+ message: {
1736
+ a: faker.number.int({ min: 0, max: 1e3 }),
1737
+ b: faker.datatype.boolean()
1738
+ }
1739
+ }
1740
+ } : {
1741
+ type: "EIP191",
1742
+ data: fakeHexString(10, "upper")
1743
+ },
1744
+ accountId: faker.string.uuid(),
1745
+ address: faker.finance.ethereumAddress(),
1746
+ derivationPath: "44'/60'/0'/0/0",
1747
+ ...opts
1748
+ };
1749
+ };
1700
1750
  var genBitcoinLikeSendData = (opts) => {
1701
1751
  return {
1702
1752
  type: "BITCOIN_LIKE_SEND",
@@ -1804,6 +1854,17 @@ var genHederaLikeSendData = (txType) => {
1804
1854
  }
1805
1855
  };
1806
1856
  };
1857
+ var genHederaLikeStakeData = (txType) => {
1858
+ return {
1859
+ type: txType,
1860
+ currency: "hedera",
1861
+ maxFee: faker.number.bigInt({ min: 1 }).toString(),
1862
+ nodeId: faker.number.int({ min: 10, max: 99999999 }).toString(),
1863
+ feeStrategy: {
1864
+ type: faker.helpers.arrayElement(["SLOW", "NORMAL", "FAST"])
1865
+ }
1866
+ };
1867
+ };
1807
1868
  var genPolkadotLikeTxData = (txType) => {
1808
1869
  switch (txType) {
1809
1870
  case "POLKADOT_LIKE_SEND":
@@ -2025,7 +2086,8 @@ var genCantonLikeTxData = (txType) => {
2025
2086
  type: txType,
2026
2087
  currency: "canton_network",
2027
2088
  amount: faker.number.bigInt({ min: 0 }).toString(),
2028
- recipient: fakeCantonPartyId()
2089
+ recipient: fakeCantonPartyId(),
2090
+ reason: faker.helpers.arrayElement([null, faker.lorem.word()])
2029
2091
  };
2030
2092
  case "CANTON_LIKE_WITHDRAW":
2031
2093
  return {
@@ -2106,6 +2168,9 @@ var genCreateTransactionData = (opts) => {
2106
2168
  case "HEDERA_LIKE_SEND_TOKEN":
2107
2169
  transactionDefaults = genHederaLikeSendData(transactionType);
2108
2170
  break;
2171
+ case "HEDERA_LIKE_STAKE":
2172
+ transactionDefaults = genHederaLikeStakeData(transactionType);
2173
+ break;
2109
2174
  case "POLKADOT_LIKE_SEND":
2110
2175
  case "POLKADOT_LIKE_ADDPROXY":
2111
2176
  case "POLKADOT_LIKE_REMOVEPROXY":
@@ -2209,9 +2274,8 @@ var shouldHaveTargetId = (type) => {
2209
2274
  case RequestType.REVOKE_API_KEY:
2210
2275
  return false;
2211
2276
  case RequestType.CREATE_TRANSACTION:
2212
- // TODO: move to True when we resolved the MetaTransaction id being an int
2213
- case RequestType.SIGN_DIGESTS:
2214
2277
  return false;
2278
+ case RequestType.SIGN_DIGESTS:
2215
2279
  case RequestType.UPDATE_QUORUM:
2216
2280
  case RequestType.CREATE_PSD_USER:
2217
2281
  case RequestType.CREATE_API_USER:
@@ -2672,6 +2736,7 @@ var genVaultRequestReview = (opts) => {
2672
2736
  stepIndex: 0,
2673
2737
  userId: faker.string.uuid(),
2674
2738
  pubKey: fakePubKey(),
2739
+ groupName: null,
2675
2740
  challengeType,
2676
2741
  challenge,
2677
2742
  signature,
@@ -2940,7 +3005,6 @@ var zNote = z14.object({
2940
3005
  });
2941
3006
  var zValueTransactionAction = z.enum([
2942
3007
  AllowedAction.SEND,
2943
- AllowedAction.STAKE,
2944
3008
  AllowedAction.DEPLOY_CONTRACT,
2945
3009
  AllowedAction.EXECUTE_CONTRACT,
2946
3010
  AllowedAction.ACTIVATE_TOKEN
@@ -2961,6 +3025,10 @@ var zReceiveIntent = z.object({
2961
3025
  // null means "any value"
2962
3026
  verdict: z.enum(["ACCEPT", "REJECT"])
2963
3027
  });
3028
+ var zStakeAction = z.enum([AllowedAction.STAKE]);
3029
+ var zStakeIntent = z.object({
3030
+ type: zStakeAction
3031
+ });
2964
3032
  var zSigningAction = z.enum([AllowedAction.SIGN_MESSAGE, AllowedAction.SIGN_DIGESTS]);
2965
3033
  var zSigningIntent = z.object({
2966
3034
  type: zSigningAction
@@ -2978,11 +3046,13 @@ z.enum([AllowedAction.SIGN_DIGESTS]);
2978
3046
  var zGovernableAction = z.enum([
2979
3047
  ...zValueTransactionAction.options,
2980
3048
  ...zReceiveAction.options,
3049
+ ...zStakeAction.options,
2981
3050
  ...zSigningAction.options
2982
3051
  ]);
2983
3052
  z.discriminatedUnion("type", [
2984
3053
  zValueTransactionIntent,
2985
3054
  zReceiveIntent,
3055
+ zStakeIntent,
2986
3056
  zSigningIntent
2987
3057
  ]);
2988
3058
 
@@ -3272,6 +3342,10 @@ var zClassicAccountGovernanceFields = z.object({
3272
3342
  type: z.literal(AccountGovernanceType.CLASSIC).meta({ description: "Classic account governance" }),
3273
3343
  policyId: z.string().meta({ description: "Identifier of corresponding governance policy" })
3274
3344
  }).meta({ description: "Classic" });
3345
+ var zRawSigningAccountGovernanceFields = z.object({
3346
+ type: z.literal(AccountGovernanceType.RAW_SIGNING).meta({ description: "Raw signing account governance" }),
3347
+ policyId: z.string().meta({ description: "Identifier of corresponding governance policy" })
3348
+ }).meta({ description: "Raw Signing" });
3275
3349
  var zTradelinkAccountGovernanceFields = z.object({
3276
3350
  type: z.literal(AccountGovernanceType.TRADELINK).meta({ description: "Tradelink account governance" }),
3277
3351
  assetManagerId: z.string().meta({ description: "Identifier of corresponding asset manager" }),
@@ -3279,7 +3353,11 @@ var zTradelinkAccountGovernanceFields = z.object({
3279
3353
  description: "Tradelink exchange configurations"
3280
3354
  })
3281
3355
  }).meta({ description: "Tradelink" });
3282
- var zAccountGovernanceFields = z.discriminatedUnion("type", [zClassicAccountGovernanceFields, zTradelinkAccountGovernanceFields]).meta({ description: "Governance fields" });
3356
+ var zAccountGovernanceFields = z.discriminatedUnion("type", [
3357
+ zClassicAccountGovernanceFields,
3358
+ zRawSigningAccountGovernanceFields,
3359
+ zTradelinkAccountGovernanceFields
3360
+ ]).meta({ description: "Governance fields" });
3283
3361
 
3284
3362
  // src/accounts/types.ts
3285
3363
  var zAccountCommonFields = z14.object({
@@ -3331,7 +3409,7 @@ z14.object({
3331
3409
  })
3332
3410
  });
3333
3411
  z14.enum(["staked", "rewards", "total"]).default("total");
3334
- z14.object({
3412
+ var zBaseStakingValidator = z14.object({
3335
3413
  address: z14.string().meta({ description: "Validator address" }),
3336
3414
  apy: z14.string().nullable().meta({ description: "Validator APY" }),
3337
3415
  balance: z14.string().nullable().meta({ description: "Validator balance" }),
@@ -3341,41 +3419,66 @@ z14.object({
3341
3419
  name: z14.string().nullable().meta({ description: "Validator name" }),
3342
3420
  url: z14.string().nullable().meta({ description: "Validator URL" })
3343
3421
  });
3422
+ var zSuiStakingValidator = zBaseStakingValidator.extend({
3423
+ type: z14.literal(AccountType.SUI_LIKE).meta({ description: "Account type" })
3424
+ });
3425
+ var zHederaStakingValidator = zBaseStakingValidator.extend({
3426
+ type: z14.literal(AccountType.HEDERA_LIKE).meta({ description: "Account type" }),
3427
+ nodeId: zIntString.nullable().meta({ description: "Validator node ID" })
3428
+ });
3429
+ z14.discriminatedUnion("type", [
3430
+ zSuiStakingValidator,
3431
+ zHederaStakingValidator
3432
+ ]);
3344
3433
  z14.enum(["balance"]).default("balance");
3345
- var zMessageType = z14.enum(MessageType).meta({ description: "Type of the message to sign" });
3346
- var zMessageData = zHexString.nonempty().meta({
3347
- description: "Hex data to sign, either a json string for EIP712, or a raw string for other types"
3434
+ z14.enum(MessageType).meta({ description: "Type of the message to sign" });
3435
+ var zMessageHexData = zHexString.nonempty().meta({
3436
+ description: "Hex data string to sign",
3437
+ id: "MessageHexData"
3438
+ });
3439
+ var zEip712Data = z14.object({
3440
+ types: z14.record(z14.string(), z14.array(z14.object({ name: z14.string(), type: z14.string() }))).meta({ description: "EIP-712 types" }),
3441
+ primaryType: z14.string().meta({ description: "EIP-712 primary type" }),
3442
+ domain: z14.record(z14.string(), z14.any()).meta({ description: "EIP-712 domain" }),
3443
+ message: z14.record(z14.string(), z14.any()).meta({ description: "EIP-712 message" })
3444
+ }).meta({
3445
+ description: "EIP-712 data to sign",
3446
+ id: "Eip712Data"
3348
3447
  });
3349
3448
  var zMessage = z14.discriminatedUnion("type", [
3350
3449
  z14.object({
3351
3450
  type: z14.literal("EIP191"),
3352
- data: zMessageData
3451
+ data: zMessageHexData
3353
3452
  }),
3354
3453
  z14.object({
3355
3454
  type: z14.literal("EIP712"),
3356
- data: zMessageData
3357
- // TODO: put a proper EIP712 schema
3455
+ data: zEip712Data
3358
3456
  }),
3359
3457
  z14.object({
3360
3458
  type: z14.literal("CIP8"),
3361
- data: zMessageData,
3362
- signingKey: z14.literal(["PAYMENT", "STAKE"]).meta({ description: "CIP-8 signing key" })
3459
+ data: zMessageHexData,
3460
+ signingKey: z14.enum(["PAYMENT", "STAKE"]).meta({ description: "CIP-8 signing key" })
3363
3461
  }),
3364
3462
  z14.object({
3365
3463
  type: z14.literal("BIP137"),
3366
- data: zMessageData
3464
+ data: zMessageHexData
3367
3465
  })
3368
3466
  ]);
3369
3467
  z14.object({
3370
3468
  id: z14.string().meta({ description: "Unique identifier" }),
3371
- type: zMessageType,
3372
- data: zMessageData,
3373
3469
  address: z14.string().meta({ description: "Address of the signing key" }),
3374
3470
  derivationPath: z14.string().meta({ description: "Derivation path of the signing key" }),
3375
3471
  signature: zHsmSignature.meta({ description: "Signature of the message" }),
3376
3472
  createdById: z14.string().meta({ description: "ID of the creator" }),
3377
3473
  createdAt: z14.coerce.date().meta({ description: "Creation timestamp" })
3378
- }).meta({ description: "Signed message", id: "SignedMessageResponse" });
3474
+ }).and(zMessage).meta({ description: "Signed message", id: "SignedMessageResponse" });
3475
+ var zDigest = z14.object({
3476
+ digest: zHexString.meta({ description: "The hex string digest to sign" }),
3477
+ derivationPath: z14.string().nonempty().meta({ description: "The derivation path with which to sign the digest" })
3478
+ });
3479
+ zDigest.extend({
3480
+ signature: zHsmSignature.meta({ description: "Signature of the digest" })
3481
+ });
3379
3482
  var zCreateTransactionRequestData = z14.object({
3380
3483
  accountId: z14.string().min(1).meta({ description: "Target account id" }),
3381
3484
  transaction: zTransactionData
@@ -3393,16 +3496,15 @@ var zSignMessageUserInputData = zSignMessageRequestData.partial({
3393
3496
  address: true,
3394
3497
  derivationPath: true
3395
3498
  });
3396
- var zDigestData = z14.object({
3397
- digest: zHexString.meta({ description: "The hex string digest to sign" }),
3398
- derivationPath: z14.string().nonempty().meta({ description: "The derivation path with which to sign the digest" })
3399
- });
3400
3499
  var zSignDigestsRequestData = z14.object({
3401
3500
  accountId: z14.string().min(1).meta({ description: "Target account id" }),
3402
- digests: z14.array(zDigestData).meta({ description: "The digests to sign" })
3501
+ digests: z14.array(zDigest).meta({ description: "The digests to sign" })
3403
3502
  });
3404
3503
  z14.object({
3405
- signatures: z14.array(zHsmSignature)
3504
+ // Populated after input data is validated.
3505
+ govRuleHsmId: zHsmObjectId.optional(),
3506
+ // Populated after request is executed -- it holds the digests-signing result.
3507
+ signatures: z14.array(zHsmSignature).optional()
3406
3508
  });
3407
3509
 
3408
3510
  // src/accounts/app-types.ts
@@ -3479,7 +3581,7 @@ var zSignDigestsGovRuleData = z14.object({
3479
3581
  // we need to control for API users only
3480
3582
  }).meta({ description: "Digest signing rule" });
3481
3583
  var zAccountPolicyRequestData = z14.union([
3482
- z14.object({ policyId: z14.string() }).meta({ description: "Account policy" }),
3584
+ z14.object({ policyId: z14.string().min(1) }).meta({ description: "Account policy" }),
3483
3585
  z14.object({ rules: z14.array(zClassicGovRuleData) }).meta({ description: "Account governance rules" })
3484
3586
  ]).meta({ description: "Account policy or governance rules" });
3485
3587
  var zCreateAccountGovernanceData = z14.discriminatedUnion("type", [
@@ -3515,6 +3617,12 @@ var zCreateAccountRequestData = zCreateAccountUserInputData.omit({ index: true }
3515
3617
  description: "Create account request data",
3516
3618
  id: "CreateAccountRequestData"
3517
3619
  });
3620
+ zCreateAccountUserInputData.omit({
3621
+ governance: true
3622
+ }).extend({ policyId: z14.string().min(1).meta({ description: "Account policy" }) }).meta({
3623
+ description: "Create account request data (for API admin only)",
3624
+ id: "CreateClassicAccountWithPolicyIdUserInput"
3625
+ });
3518
3626
  var zEditAccountGovernanceData = z14.discriminatedUnion("type", [
3519
3627
  z14.object({
3520
3628
  type: z14.literal(AccountGovernanceType.CLASSIC),
@@ -3622,11 +3730,15 @@ var getAccountAssetFields = (account) => {
3622
3730
  var getAccountGovernanceFields = (account) => {
3623
3731
  switch (account.governanceType) {
3624
3732
  case AccountGovernanceType.CLASSIC:
3625
- case AccountGovernanceType.RAW_SIGNING:
3626
3733
  return {
3627
3734
  type: AccountGovernanceType.CLASSIC,
3628
3735
  policyId: account.classicGovernanceMixin.policyId
3629
3736
  };
3737
+ case AccountGovernanceType.RAW_SIGNING:
3738
+ return {
3739
+ type: AccountGovernanceType.RAW_SIGNING,
3740
+ policyId: account.classicGovernanceMixin.policyId
3741
+ };
3630
3742
  case AccountGovernanceType.TRADELINK:
3631
3743
  return {
3632
3744
  type: AccountGovernanceType.TRADELINK,
@@ -3933,6 +4045,7 @@ var zRequestReviewResponse = z14.object({
3933
4045
  // Note: Do NOT include `quorum` as it is already available in the request's `reviewSteps` field.
3934
4046
  stepIndex: z14.number().int().meta({ description: "Index of the governance step in the request workflow" }),
3935
4047
  userId: z14.string().meta({ description: "Reviewer id" }),
4048
+ groupName: z14.string().nullable().meta({ description: "Group name if the reviewer was part of an operator group" }),
3936
4049
  status: z14.enum(RequestReviewStatus).meta({ description: "Review status" }),
3937
4050
  createdAt: z14.coerce.date().meta({ description: "Created date" }),
3938
4051
  updatedAt: z14.coerce.date().meta({ description: "Updated date" })
@@ -3972,6 +4085,7 @@ var allowedRequestCreationInputByType = {
3972
4085
  type: z14.literal(RequestType.SIGN_MESSAGE),
3973
4086
  data: zSignMessageUserInputData
3974
4087
  }),
4088
+ [RequestType.SIGN_DIGESTS]: zVaultRequestMixinsByType[RequestType.SIGN_DIGESTS],
3975
4089
  [RequestType.CREATE_POLICY]: zVaultRequestMixinsByType[RequestType.CREATE_POLICY],
3976
4090
  [RequestType.EDIT_POLICY]: zVaultRequestMixinsByType[RequestType.EDIT_POLICY],
3977
4091
  [RequestType.CREATE_ACCOUNT]: z14.object({
@@ -4052,6 +4166,9 @@ z14.object({
4052
4166
  })
4053
4167
  ])
4054
4168
  });
4169
+ z14.object({
4170
+ taskId: z14.string().meta({ description: "Task ID" })
4171
+ });
4055
4172
 
4056
4173
  // src/requests/app-utils/index.ts
4057
4174
  function serializeVaultRequest(request) {