@ledgerhq/revault-sdk 0.26.2 → 0.26.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/lib/bake.cjs +87 -48
- package/lib/bake.cjs.map +1 -1
- package/lib/bake.d.cts +11 -2
- package/lib/bake.d.ts +11 -2
- package/lib/bake.js +87 -49
- package/lib/bake.js.map +1 -1
- package/lib/index.cjs +26 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +10 -3
- package/lib/index.d.ts +10 -3
- package/lib/index.js +25 -1
- package/lib/index.js.map +1 -0
- package/package.json +2 -2
package/lib/bake.js
CHANGED
|
@@ -97,7 +97,12 @@ async function createAndApproveRequest(input, approvers, logger) {
|
|
|
97
97
|
const creator = approvers[0];
|
|
98
98
|
invariant(creator, "Need at least 1 user to create a request");
|
|
99
99
|
logSubStep(`Creating request of type ${input.type}...`);
|
|
100
|
-
|
|
100
|
+
let request = await creator.client.requests.create.mutate({
|
|
101
|
+
request: input,
|
|
102
|
+
waitForChallenges: false
|
|
103
|
+
});
|
|
104
|
+
request = await waitForRequestInflightDone(creator.client, request, logger);
|
|
105
|
+
return approveRequest(request, approvers, logger);
|
|
101
106
|
}
|
|
102
107
|
function stripUndefinedDeep(obj) {
|
|
103
108
|
if (Array.isArray(obj)) return obj.map(stripUndefinedDeep);
|
|
@@ -488,10 +493,14 @@ async function bakeWorkspace(options, logger) {
|
|
|
488
493
|
logSubStep("Completing registration...");
|
|
489
494
|
registration = await userEngine.register(registration);
|
|
490
495
|
logSubStep("Creating request...");
|
|
491
|
-
let req = await admin1.client.requests.create.mutate({
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
496
|
+
let req = await admin1.client.requests.create.mutate({
|
|
497
|
+
request: {
|
|
498
|
+
type: "CREATE_PSD_USER",
|
|
499
|
+
data: { registrationId: registration.id }
|
|
500
|
+
},
|
|
501
|
+
waitForChallenges: false
|
|
502
|
+
});
|
|
503
|
+
req = await waitForRequestInflightDone(admin1.client, req, logger);
|
|
495
504
|
req = await approveRequest(req, [admin1, admin2], logger);
|
|
496
505
|
logSubStep(`${name} has been created`);
|
|
497
506
|
const createdUser = await admin1.client.users.findById.query({ id: req.targetId });
|
|
@@ -509,15 +518,19 @@ async function bakeWorkspace(options, logger) {
|
|
|
509
518
|
}
|
|
510
519
|
logStep(`Creating API user "${apiUser.name}"...`);
|
|
511
520
|
logSubStep("Creating request...");
|
|
512
|
-
let req = await admin1.client.requests.create.mutate({
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
+
let req = await admin1.client.requests.create.mutate({
|
|
522
|
+
request: {
|
|
523
|
+
type: "CREATE_API_USER",
|
|
524
|
+
data: {
|
|
525
|
+
name: apiUser.name,
|
|
526
|
+
role: apiUser.role,
|
|
527
|
+
pubKey,
|
|
528
|
+
viewAll: apiUser.viewAll
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
waitForChallenges: false
|
|
532
|
+
});
|
|
533
|
+
req = await waitForRequestInflightDone(admin1.client, req, logger);
|
|
521
534
|
req = await approveRequest(req, [admin1, admin2], logger);
|
|
522
535
|
logSubStep(`API user "${apiUser.name}" has been created`);
|
|
523
536
|
logSubStep("Generating credentials...");
|
|
@@ -555,10 +568,14 @@ async function bakeWorkspace(options, logger) {
|
|
|
555
568
|
}
|
|
556
569
|
logStep(`Creating group ${group.name}...`);
|
|
557
570
|
logSubStep("Creating request...");
|
|
558
|
-
let request = await admin1.client.requests.create.mutate({
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
571
|
+
let request = await admin1.client.requests.create.mutate({
|
|
572
|
+
request: {
|
|
573
|
+
type: "CREATE_GROUP",
|
|
574
|
+
data: groupData
|
|
575
|
+
},
|
|
576
|
+
waitForChallenges: false
|
|
577
|
+
});
|
|
578
|
+
request = await waitForRequestInflightDone(admin1.client, request, logger);
|
|
562
579
|
request = await approveRequest(request, [admin1, admin2], logger);
|
|
563
580
|
logSubStep(`${group.name} has been created`);
|
|
564
581
|
const createdGroup = await admin1.client.groups.findById.query({ id: request.targetId });
|
|
@@ -593,13 +610,17 @@ async function bakeWorkspace(options, logger) {
|
|
|
593
610
|
}
|
|
594
611
|
logStep(`Creating policy ${policy.name}...`);
|
|
595
612
|
logSubStep("Creating request...");
|
|
596
|
-
let request = await admin1.client.requests.create.mutate({
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
613
|
+
let request = await admin1.client.requests.create.mutate({
|
|
614
|
+
request: {
|
|
615
|
+
type: "CREATE_POLICY",
|
|
616
|
+
data: {
|
|
617
|
+
...policyEditData,
|
|
618
|
+
currency: policy.currency
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
waitForChallenges: false
|
|
622
|
+
});
|
|
623
|
+
request = await waitForRequestInflightDone(admin1.client, request, logger);
|
|
603
624
|
request = await approveRequest(request, [admin1, admin2], logger);
|
|
604
625
|
logSubStep(`${policy.name} has been created`);
|
|
605
626
|
const createdPolicy = await admin1.client.policies.findById.query({ id: request.targetId });
|
|
@@ -672,10 +693,15 @@ async function bakeWorkspace(options, logger) {
|
|
|
672
693
|
arbitration: arbitration.map(tradelinkReviewStepFromManifest)
|
|
673
694
|
};
|
|
674
695
|
logSubStep("Creating request...");
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
696
|
+
let request = await admin1.client.requests.create.mutate({
|
|
697
|
+
request: {
|
|
698
|
+
type: "TRADELINK_CREATE_CUSTODIAN",
|
|
699
|
+
data
|
|
700
|
+
},
|
|
701
|
+
waitForChallenges: false
|
|
702
|
+
});
|
|
703
|
+
request = await waitForRequestInflightDone(admin1.client, request, logger);
|
|
704
|
+
await approveRequest(request, [admin1, admin2], logger);
|
|
679
705
|
logSubStep("Tradelink custodian config has been created");
|
|
680
706
|
existingTradelinkNetwork = await admin1.client.tradelink.getNetwork.query();
|
|
681
707
|
} else logger.info("[SKIPPED] Custodian config already exists");
|
|
@@ -701,17 +727,23 @@ async function bakeWorkspace(options, logger) {
|
|
|
701
727
|
continue;
|
|
702
728
|
}
|
|
703
729
|
logSubStep("Creating request...");
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
730
|
+
let request = await admin1.client.requests.create.mutate({
|
|
731
|
+
request: {
|
|
732
|
+
type: "TRADELINK_CREATE_EXCHANGE",
|
|
733
|
+
data: {
|
|
734
|
+
tradelinkId: exchangeId,
|
|
735
|
+
groups: exchange.groups.map(tradelinkReviewStepFromManifest),
|
|
736
|
+
whitelist: exchange.whitelist
|
|
737
|
+
}
|
|
738
|
+
},
|
|
739
|
+
waitForChallenges: false
|
|
740
|
+
});
|
|
741
|
+
request = await waitForRequestInflightDone(admin1.client, request, logger);
|
|
742
|
+
const loggedExchangeOperators = await Promise.all(exchange.groups.flatMap(({ quorum, members }) => members.slice(0, quorum).map((deviceIndex) => workspaceEngine.withDeviceIndex(deviceIndex).login())));
|
|
743
|
+
await approveRequest(request, [
|
|
712
744
|
admin1,
|
|
713
745
|
admin2,
|
|
714
|
-
...
|
|
746
|
+
...loggedExchangeOperators
|
|
715
747
|
], logger);
|
|
716
748
|
existingTradelinkNetwork = await admin1.client.tradelink.getNetwork.query();
|
|
717
749
|
invariant(existingTradelinkNetwork !== null, "Tradelink network exists");
|
|
@@ -730,17 +762,23 @@ async function bakeWorkspace(options, logger) {
|
|
|
730
762
|
continue;
|
|
731
763
|
}
|
|
732
764
|
logSubStep("Creating request...");
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
765
|
+
let request = await admin1.client.requests.create.mutate({
|
|
766
|
+
request: {
|
|
767
|
+
type: "TRADELINK_CREATE_ASSET_MANAGER",
|
|
768
|
+
data: {
|
|
769
|
+
tradelinkId: assetManagerId,
|
|
770
|
+
groups: assetManager.groups.map(tradelinkReviewStepFromManifest),
|
|
771
|
+
whitelist: assetManager.whitelist
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
waitForChallenges: false
|
|
775
|
+
});
|
|
776
|
+
request = await waitForRequestInflightDone(admin1.client, request, logger);
|
|
777
|
+
const loggedAssetManagerOperators = await Promise.all(assetManager.groups.flatMap(({ quorum, members }) => members.slice(0, quorum).map((deviceIndex) => workspaceEngine.withDeviceIndex(deviceIndex).login())));
|
|
778
|
+
await approveRequest(request, [
|
|
741
779
|
admin1,
|
|
742
780
|
admin2,
|
|
743
|
-
...
|
|
781
|
+
...loggedAssetManagerOperators
|
|
744
782
|
], logger);
|
|
745
783
|
existingTradelinkNetwork = await admin1.client.tradelink.getNetwork.query();
|
|
746
784
|
invariant(existingTradelinkNetwork !== null, "Tradelink network exists");
|
|
@@ -986,7 +1024,7 @@ async function recipeWorkspace(options, logger) {
|
|
|
986
1024
|
"EXECUTE_CONTRACT",
|
|
987
1025
|
"SIGN_MESSAGE",
|
|
988
1026
|
"RECEIVE"
|
|
989
|
-
].includes(value),
|
|
1027
|
+
].includes(value), `Unexpected governance rule type: ${value}`);
|
|
990
1028
|
return value;
|
|
991
1029
|
}
|
|
992
1030
|
function govRuleToManifest(rule) {
|
|
@@ -1258,6 +1296,6 @@ async function bakeManifest(options, logger) {
|
|
|
1258
1296
|
logger.info("Successfully baked");
|
|
1259
1297
|
}
|
|
1260
1298
|
//#endregion
|
|
1261
|
-
export { bakeManifest, bakePledgeAdjustment, createAndApproveRequest, recipeManifest, zManifest, zManifestPolicy };
|
|
1299
|
+
export { bakeManifest, bakePledgeAdjustment, createAndApproveRequest, recipeManifest, waitForRequestInflightDone, zManifest, zManifestPolicy };
|
|
1262
1300
|
|
|
1263
1301
|
//# sourceMappingURL=bake.js.map
|