@ledgerhq/revault-sdk 0.22.2 → 0.22.4
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/bake.cjs +76 -27
- package/lib/bake.cjs.map +1 -1
- package/lib/bake.d.cts +59 -2
- package/lib/bake.d.ts +59 -2
- package/lib/bake.js +76 -27
- package/lib/bake.js.map +1 -1
- package/lib/engine.cjs +2 -1
- package/lib/engine.cjs.map +1 -1
- package/lib/engine.d.cts +2 -2
- package/lib/engine.d.ts +2 -2
- package/lib/engine.js +2 -1
- package/lib/engine.js.map +1 -1
- package/lib/onboarding.d.cts +1 -1
- package/lib/onboarding.d.ts +1 -1
- package/lib/{types-XVM9jF-Z.d.ts → types-BTcYWX_0.d.ts} +1 -0
- package/lib/{types-DTc1xNap.d.cts → types-mF8XT2Vl.d.cts} +1 -0
- package/package.json +9 -9
package/lib/bake.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { L as Logger } from './logger-C-TPbnjv.js';
|
|
2
2
|
import z from 'zod';
|
|
3
|
-
import { E as Engine, f as WithWorkspace, c as WithDevice, l as WithPsdAuth } from './types-
|
|
3
|
+
import { E as Engine, f as WithWorkspace, c as WithDevice, l as WithPsdAuth } from './types-BTcYWX_0.js';
|
|
4
4
|
import { VaultRequestResponse } from '@ledgerhq/revault-api';
|
|
5
5
|
import { a as RouterInputs } from './types-CpGEbAxh.js';
|
|
6
6
|
import './types-DJfbanPz.js';
|
|
@@ -93,6 +93,14 @@ declare const zManifestPolicy: z.ZodObject<{
|
|
|
93
93
|
}, z.core.$strict>>;
|
|
94
94
|
}, z.core.$strict>;
|
|
95
95
|
type ManifestPolicy = z.infer<typeof zManifestPolicy>;
|
|
96
|
+
declare const zManifestRawSigningGovernanceRule: z.ZodObject<{
|
|
97
|
+
type: z.ZodLiteral<"SIGN_DIGESTS">;
|
|
98
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
99
|
+
quorum: z.ZodNumber;
|
|
100
|
+
members: z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
101
|
+
}, z.core.$strict>>;
|
|
102
|
+
}, z.core.$strict>;
|
|
103
|
+
type ManifestRawSigningGovernanceRule = z.infer<typeof zManifestRawSigningGovernanceRule>;
|
|
96
104
|
declare const zManifestAccount: z.ZodObject<{
|
|
97
105
|
name: z.ZodString;
|
|
98
106
|
currency: z.ZodString;
|
|
@@ -131,6 +139,15 @@ declare const zManifestAccount: z.ZodObject<{
|
|
|
131
139
|
repledgeAuthorized: z.ZodOptional<z.ZodBoolean>;
|
|
132
140
|
needsAssetManagerApprovalForSettlements: z.ZodOptional<z.ZodBoolean>;
|
|
133
141
|
}, z.core.$strict>>;
|
|
142
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
143
|
+
type: z.ZodLiteral<"RAW_SIGNING">;
|
|
144
|
+
rules: z.ZodArray<z.ZodObject<{
|
|
145
|
+
type: z.ZodLiteral<"SIGN_DIGESTS">;
|
|
146
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
147
|
+
quorum: z.ZodNumber;
|
|
148
|
+
members: z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
149
|
+
}, z.core.$strict>>;
|
|
150
|
+
}, z.core.$strict>>;
|
|
134
151
|
}, z.core.$strict>], "type">;
|
|
135
152
|
}, z.core.$strict>;
|
|
136
153
|
type ManifestAccount = z.infer<typeof zManifestAccount>;
|
|
@@ -216,6 +233,14 @@ declare const zManifestTradelinkNetwork: z.ZodObject<{
|
|
|
216
233
|
}, z.core.$strict>>>;
|
|
217
234
|
}, z.core.$strict>;
|
|
218
235
|
type ManifestTradelinkNetwork = z.infer<typeof zManifestTradelinkNetwork>;
|
|
236
|
+
declare const zManifestWorkspaceRule: z.ZodObject<{
|
|
237
|
+
permission: z.ZodEnum<{
|
|
238
|
+
CREATE_ACCOUNT_WITH_POLICY: "CREATE_ACCOUNT_WITH_POLICY";
|
|
239
|
+
}>;
|
|
240
|
+
quorum: z.ZodNumber;
|
|
241
|
+
members: z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
242
|
+
}, z.core.$strict>;
|
|
243
|
+
type ManifestWorkspaceRule = z.infer<typeof zManifestWorkspaceRule>;
|
|
219
244
|
declare const zManifestWorkspace: z.ZodObject<{
|
|
220
245
|
tradelink: z.ZodOptional<z.ZodObject<{
|
|
221
246
|
networkBlueprint: z.ZodOptional<z.ZodObject<{
|
|
@@ -357,6 +382,15 @@ declare const zManifestWorkspace: z.ZodObject<{
|
|
|
357
382
|
repledgeAuthorized: z.ZodOptional<z.ZodBoolean>;
|
|
358
383
|
needsAssetManagerApprovalForSettlements: z.ZodOptional<z.ZodBoolean>;
|
|
359
384
|
}, z.core.$strict>>;
|
|
385
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
386
|
+
type: z.ZodLiteral<"RAW_SIGNING">;
|
|
387
|
+
rules: z.ZodArray<z.ZodObject<{
|
|
388
|
+
type: z.ZodLiteral<"SIGN_DIGESTS">;
|
|
389
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
390
|
+
quorum: z.ZodNumber;
|
|
391
|
+
members: z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
392
|
+
}, z.core.$strict>>;
|
|
393
|
+
}, z.core.$strict>>;
|
|
360
394
|
}, z.core.$strict>], "type">;
|
|
361
395
|
}, z.core.$strict>>>;
|
|
362
396
|
hederaData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
@@ -369,6 +403,13 @@ declare const zManifestWorkspace: z.ZodObject<{
|
|
|
369
403
|
exchange: z.ZodString;
|
|
370
404
|
amount: z.ZodString;
|
|
371
405
|
}, z.core.$strict>>>;
|
|
406
|
+
workspaceRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
407
|
+
permission: z.ZodEnum<{
|
|
408
|
+
CREATE_ACCOUNT_WITH_POLICY: "CREATE_ACCOUNT_WITH_POLICY";
|
|
409
|
+
}>;
|
|
410
|
+
quorum: z.ZodNumber;
|
|
411
|
+
members: z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
412
|
+
}, z.core.$strict>>>;
|
|
372
413
|
}, z.core.$strict>;
|
|
373
414
|
type ManifestWorkspace = z.infer<typeof zManifestWorkspace>;
|
|
374
415
|
declare const zManifestTradelinkOrg: z.ZodObject<{
|
|
@@ -549,6 +590,15 @@ declare const zManifest: z.ZodObject<{
|
|
|
549
590
|
repledgeAuthorized: z.ZodOptional<z.ZodBoolean>;
|
|
550
591
|
needsAssetManagerApprovalForSettlements: z.ZodOptional<z.ZodBoolean>;
|
|
551
592
|
}, z.core.$strict>>;
|
|
593
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
594
|
+
type: z.ZodLiteral<"RAW_SIGNING">;
|
|
595
|
+
rules: z.ZodArray<z.ZodObject<{
|
|
596
|
+
type: z.ZodLiteral<"SIGN_DIGESTS">;
|
|
597
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
598
|
+
quorum: z.ZodNumber;
|
|
599
|
+
members: z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
600
|
+
}, z.core.$strict>>;
|
|
601
|
+
}, z.core.$strict>>;
|
|
552
602
|
}, z.core.$strict>], "type">;
|
|
553
603
|
}, z.core.$strict>>>;
|
|
554
604
|
hederaData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
@@ -561,6 +611,13 @@ declare const zManifest: z.ZodObject<{
|
|
|
561
611
|
exchange: z.ZodString;
|
|
562
612
|
amount: z.ZodString;
|
|
563
613
|
}, z.core.$strict>>>;
|
|
614
|
+
workspaceRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
615
|
+
permission: z.ZodEnum<{
|
|
616
|
+
CREATE_ACCOUNT_WITH_POLICY: "CREATE_ACCOUNT_WITH_POLICY";
|
|
617
|
+
}>;
|
|
618
|
+
quorum: z.ZodNumber;
|
|
619
|
+
members: z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
620
|
+
}, z.core.$strict>>>;
|
|
564
621
|
}, z.core.$strict>>;
|
|
565
622
|
}, z.core.$strict>;
|
|
566
623
|
type Manifest = z.infer<typeof zManifest>;
|
|
@@ -576,4 +633,4 @@ declare function createAndApproveRequest(input: CreateRequestInput, approvers: E
|
|
|
576
633
|
|
|
577
634
|
declare function bakeManifest(options: BakeOptions, logger: Logger): Promise<void>;
|
|
578
635
|
|
|
579
|
-
export { type BakeOptions, type CreateRequestInput, type Manifest, type ManifestAccount, type ManifestApiUser, type ManifestGovernanceRule, type ManifestGroup, type ManifestHederaData, type ManifestPledgeAdjustment, type ManifestPolicy, type ManifestTradelinkEntity, type ManifestTradelinkGroup, type ManifestTradelinkNetwork, type ManifestTradelinkNetworkBlueprint, type ManifestTradelinkOrg, type ManifestWhitelist, type ManifestWorkspace, bakeManifest, bakePledgeAdjustment, createAndApproveRequest, zManifest, zManifestPolicy };
|
|
636
|
+
export { type BakeOptions, type CreateRequestInput, type Manifest, type ManifestAccount, type ManifestApiUser, type ManifestGovernanceRule, type ManifestGroup, type ManifestHederaData, type ManifestPledgeAdjustment, type ManifestPolicy, type ManifestRawSigningGovernanceRule, type ManifestTradelinkEntity, type ManifestTradelinkGroup, type ManifestTradelinkNetwork, type ManifestTradelinkNetworkBlueprint, type ManifestTradelinkOrg, type ManifestWhitelist, type ManifestWorkspace, type ManifestWorkspaceRule, bakeManifest, bakePledgeAdjustment, createAndApproveRequest, zManifest, zManifestPolicy };
|
package/lib/bake.js
CHANGED
|
@@ -261,6 +261,12 @@ async function bakeWorkspace(options, logger) {
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
|
+
if (workspace.workspaceRules) {
|
|
265
|
+
logTitle("Workspace Rules");
|
|
266
|
+
for (const workspaceRule of workspace.workspaceRules) {
|
|
267
|
+
await createWorkspaceRule(workspaceRule);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
264
270
|
if (workspace.groups) {
|
|
265
271
|
logTitle("Groups");
|
|
266
272
|
for (const group of workspace.groups) {
|
|
@@ -326,40 +332,53 @@ async function bakeWorkspace(options, logger) {
|
|
|
326
332
|
whitelistIds: rule.whitelistNames?.map(whitelistIdFromName)
|
|
327
333
|
};
|
|
328
334
|
}
|
|
335
|
+
function rawSigningRuleFromManifest(rule) {
|
|
336
|
+
return {
|
|
337
|
+
operationType: rule.type,
|
|
338
|
+
// RAW_SIGNING only supports steps with userIds (no groups)
|
|
339
|
+
reviewSteps: rule.steps.map((step) => ({
|
|
340
|
+
quorum: step.quorum,
|
|
341
|
+
userIds: step.members.map(userIdFromDeviceIndexOrName)
|
|
342
|
+
}))
|
|
343
|
+
};
|
|
344
|
+
}
|
|
329
345
|
async function createAccount(account, workspace2) {
|
|
330
346
|
let req = null;
|
|
331
347
|
const existing = existingAccounts.find(
|
|
332
348
|
(a) => a.currency === account.currency && a.index === account.index && (a.contractAddress ?? null) === (account.contractAddress ?? null)
|
|
333
349
|
);
|
|
350
|
+
const governance = account.governance.type === "TRADELINK" ? {
|
|
351
|
+
type: "TRADELINK",
|
|
352
|
+
assetManagerId: assetManagerIdFromName(account.governance.assetManager),
|
|
353
|
+
exchangeConfigs: account.governance.exchanges.map((exchangeConfig) => ({
|
|
354
|
+
exchangeId: exchangeIdFromName(exchangeConfig.name),
|
|
355
|
+
repledgeAuthorized: exchangeConfig.repledgeAuthorized === true,
|
|
356
|
+
needsAssetManagerApprovalForSettlements: exchangeConfig.needsAssetManagerApprovalForSettlements === true
|
|
357
|
+
}))
|
|
358
|
+
} : account.governance.type === "RAW_SIGNING" ? {
|
|
359
|
+
type: "RAW_SIGNING",
|
|
360
|
+
policy: { rules: account.governance.rules.map(rawSigningRuleFromManifest) }
|
|
361
|
+
} : {
|
|
362
|
+
type: "CLASSIC",
|
|
363
|
+
policy: { rules: account.governance.rules.map(govRuleFromManifest) }
|
|
364
|
+
};
|
|
365
|
+
const accountData = {
|
|
366
|
+
name: account.name,
|
|
367
|
+
currency: account.currency,
|
|
368
|
+
contractAddress: account.contractAddress ?? null,
|
|
369
|
+
tokenIdentifier: account.tokenIdentifier ?? null,
|
|
370
|
+
index: account.index,
|
|
371
|
+
governance
|
|
372
|
+
};
|
|
334
373
|
const createInput = {
|
|
335
374
|
type: "CREATE_ACCOUNT",
|
|
336
|
-
data:
|
|
337
|
-
// general fields
|
|
338
|
-
name: account.name,
|
|
339
|
-
currency: account.currency,
|
|
340
|
-
contractAddress: account.contractAddress ?? null,
|
|
341
|
-
tokenIdentifier: account.tokenIdentifier ?? null,
|
|
342
|
-
index: account.index,
|
|
343
|
-
// governance fields
|
|
344
|
-
governance: account.governance.type === "TRADELINK" ? {
|
|
345
|
-
type: "TRADELINK",
|
|
346
|
-
assetManagerId: assetManagerIdFromName(account.governance.assetManager),
|
|
347
|
-
exchangeConfigs: account.governance.exchanges.map((exchangeConfig) => ({
|
|
348
|
-
exchangeId: exchangeIdFromName(exchangeConfig.name),
|
|
349
|
-
repledgeAuthorized: exchangeConfig.repledgeAuthorized === true,
|
|
350
|
-
needsAssetManagerApprovalForSettlements: exchangeConfig.needsAssetManagerApprovalForSettlements === true
|
|
351
|
-
}))
|
|
352
|
-
} : {
|
|
353
|
-
type: "CLASSIC",
|
|
354
|
-
policy: { rules: account.governance.rules.map(govRuleFromManifest) }
|
|
355
|
-
}
|
|
356
|
-
}
|
|
375
|
+
data: accountData
|
|
357
376
|
};
|
|
358
377
|
if (existing) {
|
|
359
378
|
const editInput = {
|
|
360
|
-
...createInput,
|
|
361
379
|
type: "EDIT_ACCOUNT",
|
|
362
|
-
targetId: existing.id
|
|
380
|
+
targetId: existing.id,
|
|
381
|
+
data: { name: accountData.name, governance }
|
|
363
382
|
};
|
|
364
383
|
const previousAccountRequests = await admin1.client.requests.list.query({
|
|
365
384
|
type: ["CREATE_ACCOUNT", "EDIT_ACCOUNT"],
|
|
@@ -375,9 +394,9 @@ async function bakeWorkspace(options, logger) {
|
|
|
375
394
|
"State request should be an edit account request"
|
|
376
395
|
);
|
|
377
396
|
if (_.isEqual(
|
|
378
|
-
stripUndefinedDeep(
|
|
397
|
+
stripUndefinedDeep(accountData.governance),
|
|
379
398
|
stripUndefinedDeep(stateRequest.data.governance)
|
|
380
|
-
) &&
|
|
399
|
+
) && accountData.name === stateRequest.data.name) {
|
|
381
400
|
logger.info(`[SKIPPED] Account "${account.name}" has not changed`);
|
|
382
401
|
await activateHederaAccount(account, workspace2, existing.id);
|
|
383
402
|
return;
|
|
@@ -554,6 +573,21 @@ async function bakeWorkspace(options, logger) {
|
|
|
554
573
|
const createdPolicy = await admin1.client.policies.findById.query({ id: request.targetId });
|
|
555
574
|
existingPolicies.push(createdPolicy);
|
|
556
575
|
}
|
|
576
|
+
async function createWorkspaceRule(workspaceRule) {
|
|
577
|
+
const { permission, quorum, members } = workspaceRule;
|
|
578
|
+
logStep(`Editing workspace rule for ${permission}...`);
|
|
579
|
+
const userIds = members.map(userIdFromDeviceIndexOrName);
|
|
580
|
+
logSubStep("Creating request...");
|
|
581
|
+
const input = {
|
|
582
|
+
type: "EDIT_WORKSPACE_RULE",
|
|
583
|
+
data: {
|
|
584
|
+
permission,
|
|
585
|
+
reviewConfig: [{ quorum, userIds }]
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
await createAndApproveRequest(input, [admin1, admin2], logger);
|
|
589
|
+
logSubStep(`Workspace rule for "${permission}" has been edited`);
|
|
590
|
+
}
|
|
557
591
|
async function createTradelink(tradelink) {
|
|
558
592
|
if (tradelink.custodian) {
|
|
559
593
|
if (existingTradelinkNetwork === null) {
|
|
@@ -818,9 +852,18 @@ var zManifestTradelinkAccountGovernance = z.object({
|
|
|
818
852
|
assetManager: z.string().meta({ description: "Asset manager name" }),
|
|
819
853
|
exchanges: z.array(zManifestTradelinkExchangeConfig)
|
|
820
854
|
}).strict();
|
|
855
|
+
var zManifestRawSigningGovernanceRule = z.object({
|
|
856
|
+
type: z.literal("SIGN_DIGESTS"),
|
|
857
|
+
steps: z.array(zManifestGovernanceStepWithUsers).min(1)
|
|
858
|
+
}).strict();
|
|
859
|
+
var zManifestRawSigningAccountGovernance = z.object({
|
|
860
|
+
type: z.literal("RAW_SIGNING"),
|
|
861
|
+
rules: z.array(zManifestRawSigningGovernanceRule)
|
|
862
|
+
}).strict();
|
|
821
863
|
var zManifestAccountGovernance = z.discriminatedUnion("type", [
|
|
822
864
|
zManifestClassicAccountGovernance,
|
|
823
|
-
zManifestTradelinkAccountGovernance
|
|
865
|
+
zManifestTradelinkAccountGovernance,
|
|
866
|
+
zManifestRawSigningAccountGovernance
|
|
824
867
|
]);
|
|
825
868
|
var zManifestAccount = z.object({
|
|
826
869
|
name: z.string(),
|
|
@@ -872,6 +915,11 @@ var zManifestTradelinkNetwork = z.object({
|
|
|
872
915
|
exchanges: z.array(zManifestTradelinkEntity).optional(),
|
|
873
916
|
assetManagers: z.array(zManifestTradelinkEntity).optional()
|
|
874
917
|
}).strict().meta({ description: "Tradelink network configuration" });
|
|
918
|
+
var zManifestWorkspaceRule = z.object({
|
|
919
|
+
permission: z.enum(["CREATE_ACCOUNT_WITH_POLICY"]),
|
|
920
|
+
quorum: z.number().min(1),
|
|
921
|
+
members: z.array(z.union([zManifestUser, zManifestUserName]))
|
|
922
|
+
}).strict().meta({ description: "Workspace rule for granting permissions" });
|
|
875
923
|
var zManifestWorkspace = z.object({
|
|
876
924
|
tradelink: zManifestTradelinkNetwork.optional(),
|
|
877
925
|
users: z.object({
|
|
@@ -884,7 +932,8 @@ var zManifestWorkspace = z.object({
|
|
|
884
932
|
policies: z.array(zManifestPolicy).optional(),
|
|
885
933
|
accounts: z.array(zManifestAccount).optional(),
|
|
886
934
|
hederaData: z.record(z.string(), z.array(zManifestHederaData)).optional(),
|
|
887
|
-
pledges: z.array(zManifestPledgeAdjustment).optional()
|
|
935
|
+
pledges: z.array(zManifestPledgeAdjustment).optional(),
|
|
936
|
+
workspaceRules: z.array(zManifestWorkspaceRule).optional()
|
|
888
937
|
}).strict().meta({ description: "Workspace configuration" });
|
|
889
938
|
var zManifestTradelinkOrgEntity = z.object({
|
|
890
939
|
name: z.string(),
|