@hazbase/simplicity 0.1.1 → 0.2.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/README.md +139 -1534
- package/dist/cli.js +1107 -1
- package/dist/client/SimplicityClient.d.ts +30 -3
- package/dist/client/SimplicityClient.js +28 -0
- package/dist/core/lineage.d.ts +18 -0
- package/dist/core/lineage.js +30 -0
- package/dist/core/reporting.d.ts +22 -0
- package/dist/core/reporting.js +40 -0
- package/dist/core/schnorr.d.ts +3 -3
- package/dist/core/schnorr.js +19 -7
- package/dist/core/types.d.ts +251 -5
- package/dist/docs/definitions/fund-capital-call-refund-only.simf +36 -2
- package/dist/docs/definitions/receivable-definition.json +9 -0
- package/dist/docs/definitions/receivable-funding-claim.json +13 -0
- package/dist/docs/definitions/receivable-funding-claim.simf +58 -0
- package/dist/docs/definitions/receivable-repayment-claim.json +13 -0
- package/dist/docs/definitions/receivable-repayment-claim.simf +59 -0
- package/dist/docs/definitions/receivable-state-funded.json +20 -0
- package/dist/docs/definitions/receivable-state-originated.json +19 -0
- package/dist/docs/definitions/receivable-state-repaid.json +20 -0
- package/dist/domain/bond.d.ts +82 -15
- package/dist/domain/bond.js +159 -10
- package/dist/domain/bondValidation.d.ts +31 -1
- package/dist/domain/bondValidation.js +73 -9
- package/dist/domain/fund.d.ts +451 -68
- package/dist/domain/fund.js +460 -88
- package/dist/domain/fundValidation.d.ts +33 -3
- package/dist/domain/fundValidation.js +137 -5
- package/dist/domain/policies.d.ts +13 -0
- package/dist/domain/policies.js +50 -30
- package/dist/domain/receivable.d.ts +824 -0
- package/dist/domain/receivable.js +1375 -0
- package/dist/domain/receivableValidation.d.ts +147 -0
- package/dist/domain/receivableValidation.js +831 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +55 -3
- package/package.json +6 -1
|
@@ -47,13 +47,43 @@ export declare function validateFundCrossChecks(definition: FundDefinition, capi
|
|
|
47
47
|
export declare function verifyLPPositionReceiptEnvelope(input: {
|
|
48
48
|
envelope: LPPositionReceiptEnvelope;
|
|
49
49
|
expectedManagerXonly?: string;
|
|
50
|
-
|
|
50
|
+
previousEnvelope?: LPPositionReceiptEnvelope;
|
|
51
|
+
}): Promise<{
|
|
51
52
|
positionReceiptHashMatch: boolean;
|
|
52
53
|
sequenceMatch: boolean;
|
|
53
54
|
sequenceMonotonic: boolean;
|
|
54
55
|
attestingSignerMatch: boolean;
|
|
55
56
|
attestationVerified: boolean;
|
|
56
|
-
|
|
57
|
+
previousEnvelopeProvided: boolean;
|
|
58
|
+
previousReceiptHashMatch: boolean;
|
|
59
|
+
previousSequenceMatch: boolean;
|
|
60
|
+
continuityVerified: boolean;
|
|
61
|
+
}>;
|
|
62
|
+
export declare function verifyLPPositionReceiptEnvelopeChain(input: {
|
|
63
|
+
envelopes: LPPositionReceiptEnvelope[];
|
|
64
|
+
expectedManagerXonly?: string;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
chainLength: number;
|
|
67
|
+
latestSequence?: number;
|
|
68
|
+
startsAtGenesis: boolean;
|
|
69
|
+
latestSequenceCovered: boolean;
|
|
70
|
+
sequenceContiguous: boolean;
|
|
71
|
+
fundConsistent: boolean;
|
|
72
|
+
positionConsistent: boolean;
|
|
73
|
+
lpConsistent: boolean;
|
|
74
|
+
callConsistent: boolean;
|
|
75
|
+
currencyConsistent: boolean;
|
|
76
|
+
lpXonlyConsistent: boolean;
|
|
77
|
+
attestingSignerConsistent: boolean;
|
|
78
|
+
allPositionReceiptHashMatch: boolean;
|
|
79
|
+
allSequenceMatch: boolean;
|
|
80
|
+
allSequenceMonotonic: boolean;
|
|
81
|
+
allAttestingSignerMatch: boolean;
|
|
82
|
+
allAttestationVerified: boolean;
|
|
83
|
+
allContinuityVerified: boolean;
|
|
84
|
+
fullChainVerified: boolean;
|
|
85
|
+
stepChecks: Awaited<ReturnType<typeof verifyLPPositionReceiptEnvelope>>[];
|
|
86
|
+
}>;
|
|
57
87
|
export declare function signLPPositionReceipt(input: {
|
|
58
88
|
receipt: LPPositionReceipt;
|
|
59
89
|
managerXonly: string;
|
|
@@ -62,7 +92,7 @@ export declare function signLPPositionReceipt(input: {
|
|
|
62
92
|
privkeyHex: string;
|
|
63
93
|
};
|
|
64
94
|
signedAt?: string;
|
|
65
|
-
}): LPPositionReceiptEnvelope
|
|
95
|
+
}): Promise<LPPositionReceiptEnvelope>;
|
|
66
96
|
export declare function validateDistributionAgainstReceipt(receipt: LPPositionReceipt, distribution: DistributionDescriptor): {
|
|
67
97
|
fundIdMatch: boolean;
|
|
68
98
|
lpIdMatch: boolean;
|
|
@@ -16,6 +16,7 @@ exports.validateDistributionDescriptor = validateDistributionDescriptor;
|
|
|
16
16
|
exports.validateFundClosingDescriptor = validateFundClosingDescriptor;
|
|
17
17
|
exports.validateFundCrossChecks = validateFundCrossChecks;
|
|
18
18
|
exports.verifyLPPositionReceiptEnvelope = verifyLPPositionReceiptEnvelope;
|
|
19
|
+
exports.verifyLPPositionReceiptEnvelopeChain = verifyLPPositionReceiptEnvelopeChain;
|
|
19
20
|
exports.signLPPositionReceipt = signLPPositionReceipt;
|
|
20
21
|
exports.validateDistributionAgainstReceipt = validateDistributionAgainstReceipt;
|
|
21
22
|
exports.validateClosingAgainstReceipt = validateClosingAgainstReceipt;
|
|
@@ -29,6 +30,7 @@ exports.reconcileLPPositionReceipt = reconcileLPPositionReceipt;
|
|
|
29
30
|
exports.buildDistributionDescriptor = buildDistributionDescriptor;
|
|
30
31
|
exports.buildFundClosingDescriptor = buildFundClosingDescriptor;
|
|
31
32
|
const errors_1 = require("../core/errors");
|
|
33
|
+
const lineage_1 = require("../core/lineage");
|
|
32
34
|
const summary_1 = require("../core/summary");
|
|
33
35
|
const schnorr_1 = require("../core/schnorr");
|
|
34
36
|
function assertNonEmptyString(value, code, message) {
|
|
@@ -355,7 +357,7 @@ function validateFundCrossChecks(definition, capitalCall) {
|
|
|
355
357
|
}
|
|
356
358
|
return result;
|
|
357
359
|
}
|
|
358
|
-
function verifyLPPositionReceiptEnvelope(input) {
|
|
360
|
+
async function verifyLPPositionReceiptEnvelope(input) {
|
|
359
361
|
const envelope = validateLPPositionReceiptEnvelope(input.envelope);
|
|
360
362
|
const receiptSummary = summarizeLPPositionReceipt(envelope.receipt);
|
|
361
363
|
const digestHex = buildPositionReceiptAttestationMessageHash({
|
|
@@ -374,23 +376,153 @@ function verifyLPPositionReceiptEnvelope(input) {
|
|
|
374
376
|
: true;
|
|
375
377
|
const attestationVerified = positionReceiptHashMatch
|
|
376
378
|
&& sequenceMatch
|
|
377
|
-
&& (0, schnorr_1.schnorrVerifyHex)(envelope.attestation.signature, digestHex, envelope.attestation.managerXonly);
|
|
379
|
+
&& await (0, schnorr_1.schnorrVerifyHex)(envelope.attestation.signature, digestHex, envelope.attestation.managerXonly);
|
|
380
|
+
const previousEnvelopeProvided = Boolean(input.previousEnvelope);
|
|
381
|
+
const previousEnvelope = input.previousEnvelope ? validateLPPositionReceiptEnvelope(input.previousEnvelope) : undefined;
|
|
382
|
+
const previousSummary = previousEnvelope ? summarizeLPPositionReceipt(previousEnvelope.receipt) : undefined;
|
|
383
|
+
const previousReceiptHashMatch = envelope.receipt.sequence === 0
|
|
384
|
+
? !previousEnvelope
|
|
385
|
+
: previousSummary
|
|
386
|
+
? envelope.receipt.previousReceiptHash === previousSummary.hash
|
|
387
|
+
: false;
|
|
388
|
+
const previousSequenceMatch = envelope.receipt.sequence === 0
|
|
389
|
+
? !previousEnvelope
|
|
390
|
+
: previousEnvelope
|
|
391
|
+
? previousEnvelope.receipt.sequence + 1 === envelope.receipt.sequence
|
|
392
|
+
: false;
|
|
393
|
+
const previousAttestingSignerMatch = previousEnvelope && input.expectedManagerXonly
|
|
394
|
+
? previousEnvelope.attestation.managerXonly.toLowerCase() === input.expectedManagerXonly.toLowerCase()
|
|
395
|
+
: true;
|
|
396
|
+
const previousAttestationVerified = previousEnvelope
|
|
397
|
+
? previousEnvelope.attestation.positionReceiptHash === previousSummary?.hash
|
|
398
|
+
&& previousEnvelope.attestation.sequence === previousEnvelope.receipt.sequence
|
|
399
|
+
&& await (0, schnorr_1.schnorrVerifyHex)(previousEnvelope.attestation.signature, buildPositionReceiptAttestationMessageHash({
|
|
400
|
+
fundId: previousEnvelope.receipt.fundId,
|
|
401
|
+
positionId: previousEnvelope.receipt.positionId,
|
|
402
|
+
positionReceiptHash: previousSummary.hash,
|
|
403
|
+
sequence: previousEnvelope.receipt.sequence,
|
|
404
|
+
}), previousEnvelope.attestation.managerXonly)
|
|
405
|
+
: envelope.receipt.sequence === 0;
|
|
406
|
+
const previousSequenceMonotonic = previousEnvelope
|
|
407
|
+
? previousEnvelope.receipt.sequence === 0
|
|
408
|
+
? !previousEnvelope.receipt.previousReceiptHash
|
|
409
|
+
: Boolean(previousEnvelope.receipt.previousReceiptHash)
|
|
410
|
+
: envelope.receipt.sequence === 0;
|
|
411
|
+
const continuityVerified = envelope.receipt.sequence === 0
|
|
412
|
+
? !previousEnvelope
|
|
413
|
+
: previousEnvelopeProvided
|
|
414
|
+
&& previousReceiptHashMatch
|
|
415
|
+
&& previousSequenceMatch
|
|
416
|
+
&& previousAttestingSignerMatch
|
|
417
|
+
&& previousAttestationVerified
|
|
418
|
+
&& previousSequenceMonotonic;
|
|
378
419
|
return {
|
|
379
420
|
positionReceiptHashMatch,
|
|
380
421
|
sequenceMatch,
|
|
381
422
|
sequenceMonotonic,
|
|
382
423
|
attestingSignerMatch,
|
|
383
424
|
attestationVerified,
|
|
425
|
+
previousEnvelopeProvided,
|
|
426
|
+
previousReceiptHashMatch,
|
|
427
|
+
previousSequenceMatch,
|
|
428
|
+
continuityVerified,
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
async function verifyLPPositionReceiptEnvelopeChain(input) {
|
|
432
|
+
if (input.envelopes.length === 0) {
|
|
433
|
+
throw new errors_1.ValidationError("position receipt chain must include at least one envelope", {
|
|
434
|
+
code: "FUND_POSITION_CHAIN_REQUIRED",
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
const envelopes = input.envelopes.map((envelope) => validateLPPositionReceiptEnvelope(envelope));
|
|
438
|
+
const first = envelopes[0];
|
|
439
|
+
const firstSigner = first.attestation.managerXonly.toLowerCase();
|
|
440
|
+
const stepChecks = [];
|
|
441
|
+
for (let index = 0; index < envelopes.length; index += 1) {
|
|
442
|
+
stepChecks.push(await verifyLPPositionReceiptEnvelope({
|
|
443
|
+
envelope: envelopes[index],
|
|
444
|
+
expectedManagerXonly: input.expectedManagerXonly,
|
|
445
|
+
previousEnvelope: index > 0 ? envelopes[index - 1] : undefined,
|
|
446
|
+
}));
|
|
447
|
+
}
|
|
448
|
+
const lineage = (0, lineage_1.verifyHashLinkedLineage)({
|
|
449
|
+
entries: envelopes,
|
|
450
|
+
summarize: (envelope) => summarizeLPPositionReceipt(envelope.receipt),
|
|
451
|
+
getPreviousHash: (envelope) => envelope.receipt.previousReceiptHash,
|
|
452
|
+
isGenesis: (envelope) => envelope.receipt.sequence === 0 && !envelope.receipt.previousReceiptHash,
|
|
453
|
+
consistencyChecks: {
|
|
454
|
+
fundConsistent: (envelope, base) => envelope.receipt.fundId === base.receipt.fundId,
|
|
455
|
+
positionConsistent: (envelope, base) => envelope.receipt.positionId === base.receipt.positionId,
|
|
456
|
+
lpConsistent: (envelope, base) => envelope.receipt.lpId === base.receipt.lpId,
|
|
457
|
+
callConsistent: (envelope, base) => envelope.receipt.callId === base.receipt.callId,
|
|
458
|
+
currencyConsistent: (envelope, base) => envelope.receipt.currencyAssetId === base.receipt.currencyAssetId,
|
|
459
|
+
lpXonlyConsistent: (envelope, base) => envelope.receipt.lpXonly === base.receipt.lpXonly,
|
|
460
|
+
},
|
|
461
|
+
});
|
|
462
|
+
const startsAtGenesis = lineage.startsAtGenesis;
|
|
463
|
+
const latestSequence = envelopes.at(-1)?.receipt.sequence;
|
|
464
|
+
const latestSequenceCovered = latestSequence === envelopes.length - 1;
|
|
465
|
+
const sequenceContiguous = envelopes.every((envelope, index) => envelope.receipt.sequence === first.receipt.sequence + index);
|
|
466
|
+
const fundConsistent = lineage.consistency.fundConsistent;
|
|
467
|
+
const positionConsistent = lineage.consistency.positionConsistent;
|
|
468
|
+
const lpConsistent = lineage.consistency.lpConsistent;
|
|
469
|
+
const callConsistent = lineage.consistency.callConsistent;
|
|
470
|
+
const currencyConsistent = lineage.consistency.currencyConsistent;
|
|
471
|
+
const lpXonlyConsistent = lineage.consistency.lpXonlyConsistent;
|
|
472
|
+
const attestingSignerConsistent = envelopes.every((envelope) => envelope.attestation.managerXonly.toLowerCase() === firstSigner);
|
|
473
|
+
const allPositionReceiptHashMatch = stepChecks.every((check) => check.positionReceiptHashMatch);
|
|
474
|
+
const allSequenceMatch = stepChecks.every((check) => check.sequenceMatch);
|
|
475
|
+
const allSequenceMonotonic = stepChecks.every((check) => check.sequenceMonotonic);
|
|
476
|
+
const allAttestingSignerMatch = stepChecks.every((check) => check.attestingSignerMatch);
|
|
477
|
+
const allAttestationVerified = stepChecks.every((check) => check.attestationVerified);
|
|
478
|
+
const allContinuityVerified = stepChecks.every((check, index) => (index === 0 ? true : check.continuityVerified));
|
|
479
|
+
const fullChainVerified = startsAtGenesis
|
|
480
|
+
&& latestSequenceCovered
|
|
481
|
+
&& sequenceContiguous
|
|
482
|
+
&& fundConsistent
|
|
483
|
+
&& positionConsistent
|
|
484
|
+
&& lpConsistent
|
|
485
|
+
&& callConsistent
|
|
486
|
+
&& currencyConsistent
|
|
487
|
+
&& lpXonlyConsistent
|
|
488
|
+
&& attestingSignerConsistent
|
|
489
|
+
&& allPositionReceiptHashMatch
|
|
490
|
+
&& allSequenceMatch
|
|
491
|
+
&& allSequenceMonotonic
|
|
492
|
+
&& allAttestingSignerMatch
|
|
493
|
+
&& allAttestationVerified
|
|
494
|
+
&& allContinuityVerified;
|
|
495
|
+
return {
|
|
496
|
+
chainLength: envelopes.length,
|
|
497
|
+
latestSequence,
|
|
498
|
+
startsAtGenesis,
|
|
499
|
+
latestSequenceCovered,
|
|
500
|
+
sequenceContiguous,
|
|
501
|
+
fundConsistent,
|
|
502
|
+
positionConsistent,
|
|
503
|
+
lpConsistent,
|
|
504
|
+
callConsistent,
|
|
505
|
+
currencyConsistent,
|
|
506
|
+
lpXonlyConsistent,
|
|
507
|
+
attestingSignerConsistent,
|
|
508
|
+
allPositionReceiptHashMatch,
|
|
509
|
+
allSequenceMatch,
|
|
510
|
+
allSequenceMonotonic,
|
|
511
|
+
allAttestingSignerMatch,
|
|
512
|
+
allAttestationVerified,
|
|
513
|
+
allContinuityVerified,
|
|
514
|
+
fullChainVerified,
|
|
515
|
+
stepChecks,
|
|
384
516
|
};
|
|
385
517
|
}
|
|
386
|
-
function signLPPositionReceipt(input) {
|
|
518
|
+
async function signLPPositionReceipt(input) {
|
|
387
519
|
const receipt = validateLPPositionReceipt(input.receipt);
|
|
388
520
|
if (input.signer.type !== "schnorrPrivkeyHex") {
|
|
389
521
|
throw new errors_1.ValidationError("position receipt attestation signer must be schnorrPrivkeyHex", {
|
|
390
522
|
code: "FUND_POSITION_ATTESTATION_SIGNER_TYPE_INVALID",
|
|
391
523
|
});
|
|
392
524
|
}
|
|
393
|
-
const derivedManagerXonly = (0, schnorr_1.schnorrPublicKeyFromPrivkeyHex)(input.signer.privkeyHex);
|
|
525
|
+
const derivedManagerXonly = await (0, schnorr_1.schnorrPublicKeyFromPrivkeyHex)(input.signer.privkeyHex);
|
|
394
526
|
if (derivedManagerXonly !== input.managerXonly.toLowerCase()) {
|
|
395
527
|
throw new errors_1.ValidationError("position receipt attestation signer does not match managerXonly", {
|
|
396
528
|
code: "FUND_POSITION_ATTESTATION_SIGNER_MISMATCH",
|
|
@@ -414,7 +546,7 @@ function signLPPositionReceipt(input) {
|
|
|
414
546
|
sequence: receipt.sequence,
|
|
415
547
|
managerXonly: derivedManagerXonly,
|
|
416
548
|
signedAt,
|
|
417
|
-
signature: (0, schnorr_1.schnorrSignHex)(digestHex, input.signer.privkeyHex),
|
|
549
|
+
signature: await (0, schnorr_1.schnorrSignHex)(digestHex, input.signer.privkeyHex),
|
|
418
550
|
scheme: "bip340-sha256",
|
|
419
551
|
},
|
|
420
552
|
});
|
|
@@ -91,6 +91,7 @@ export declare function verifyState(sdk: SimplicityClient, input: {
|
|
|
91
91
|
plainExitAllowed: boolean;
|
|
92
92
|
enforcement: "sdk-path" | "conditional-hop" | "direct-hop";
|
|
93
93
|
};
|
|
94
|
+
trustSummary: import("../core/types").VerificationTrustSummary;
|
|
94
95
|
}>;
|
|
95
96
|
export declare function buildPolicyOutputDescriptor(sdk: SimplicityClient, input: {
|
|
96
97
|
nextCompiledContractAddress: string;
|
|
@@ -184,6 +185,7 @@ export declare function prepareTransfer(sdk: SimplicityClient, input: {
|
|
|
184
185
|
plainExitAllowed: boolean;
|
|
185
186
|
enforcement: "sdk-path" | "conditional-hop" | "direct-hop";
|
|
186
187
|
};
|
|
188
|
+
trustSummary: import("../core/types").VerificationTrustSummary;
|
|
187
189
|
};
|
|
188
190
|
nextState: null;
|
|
189
191
|
nextCompiled: null;
|
|
@@ -242,6 +244,7 @@ export declare function prepareTransfer(sdk: SimplicityClient, input: {
|
|
|
242
244
|
plainExitAllowed: boolean;
|
|
243
245
|
enforcement: "sdk-path" | "conditional-hop" | "direct-hop";
|
|
244
246
|
};
|
|
247
|
+
trustSummary: import("../core/types").VerificationTrustSummary;
|
|
245
248
|
};
|
|
246
249
|
nextState: PolicyState;
|
|
247
250
|
nextCompiled: import("..").CompiledContract;
|
|
@@ -336,6 +339,7 @@ export declare function prepareDirectTransfer(sdk: SimplicityClient, input: {
|
|
|
336
339
|
plainExitAllowed: boolean;
|
|
337
340
|
enforcement: "sdk-path" | "conditional-hop" | "direct-hop";
|
|
338
341
|
};
|
|
342
|
+
trustSummary: import("../core/types").VerificationTrustSummary;
|
|
339
343
|
};
|
|
340
344
|
nextState: PolicyState;
|
|
341
345
|
nextCompiled: import("..").CompiledContract;
|
|
@@ -421,6 +425,7 @@ export declare function verifyDirectTransfer(sdk: SimplicityClient, input: {
|
|
|
421
425
|
plainExitAllowed: boolean;
|
|
422
426
|
enforcement: "sdk-path" | "conditional-hop" | "direct-hop";
|
|
423
427
|
};
|
|
428
|
+
trustSummary: import("../core/types").VerificationTrustSummary;
|
|
424
429
|
};
|
|
425
430
|
transfer: PolicyTransferDescriptor | undefined;
|
|
426
431
|
transferSummary: {
|
|
@@ -495,6 +500,7 @@ export declare function inspectDirectTransfer(sdk: SimplicityClient, input: Para
|
|
|
495
500
|
plainExitAllowed: boolean;
|
|
496
501
|
enforcement: "sdk-path" | "conditional-hop" | "direct-hop";
|
|
497
502
|
};
|
|
503
|
+
trustSummary: import("../core/types").VerificationTrustSummary;
|
|
498
504
|
};
|
|
499
505
|
nextState: PolicyState;
|
|
500
506
|
nextCompiled: import("..").CompiledContract;
|
|
@@ -601,6 +607,7 @@ export declare function executeDirectTransfer(sdk: SimplicityClient, input: {
|
|
|
601
607
|
plainExitAllowed: boolean;
|
|
602
608
|
enforcement: "sdk-path" | "conditional-hop" | "direct-hop";
|
|
603
609
|
};
|
|
610
|
+
trustSummary: import("../core/types").VerificationTrustSummary;
|
|
604
611
|
};
|
|
605
612
|
nextState: PolicyState;
|
|
606
613
|
nextCompiled: import("..").CompiledContract;
|
|
@@ -688,6 +695,7 @@ export declare function verifyTransfer(sdk: SimplicityClient, input: {
|
|
|
688
695
|
plainExitAllowed: boolean;
|
|
689
696
|
enforcement: "sdk-path" | "conditional-hop" | "direct-hop";
|
|
690
697
|
};
|
|
698
|
+
trustSummary: import("../core/types").VerificationTrustSummary;
|
|
691
699
|
};
|
|
692
700
|
transfer: PolicyTransferDescriptor | undefined;
|
|
693
701
|
transferSummary: {
|
|
@@ -730,6 +738,7 @@ export declare function verifyTransfer(sdk: SimplicityClient, input: {
|
|
|
730
738
|
propagationMode: PropagationMode;
|
|
731
739
|
nextPolicyRequired: boolean;
|
|
732
740
|
};
|
|
741
|
+
trustSummary: import("../core/types").VerificationTrustSummary;
|
|
733
742
|
}>;
|
|
734
743
|
export declare function inspectTransfer(sdk: SimplicityClient, input: Parameters<typeof executeTransfer>[1] & {
|
|
735
744
|
utxoPolicy?: "smallest_over" | "largest" | "newest";
|
|
@@ -764,6 +773,7 @@ export declare function inspectTransfer(sdk: SimplicityClient, input: Parameters
|
|
|
764
773
|
plainExitAllowed: boolean;
|
|
765
774
|
enforcement: "sdk-path" | "conditional-hop" | "direct-hop";
|
|
766
775
|
};
|
|
776
|
+
trustSummary: import("../core/types").VerificationTrustSummary;
|
|
767
777
|
};
|
|
768
778
|
nextState: null;
|
|
769
779
|
nextCompiled: null;
|
|
@@ -826,6 +836,7 @@ export declare function inspectTransfer(sdk: SimplicityClient, input: Parameters
|
|
|
826
836
|
plainExitAllowed: boolean;
|
|
827
837
|
enforcement: "sdk-path" | "conditional-hop" | "direct-hop";
|
|
828
838
|
};
|
|
839
|
+
trustSummary: import("../core/types").VerificationTrustSummary;
|
|
829
840
|
};
|
|
830
841
|
nextState: PolicyState;
|
|
831
842
|
nextCompiled: import("..").CompiledContract;
|
|
@@ -932,6 +943,7 @@ export declare function executeTransfer(sdk: SimplicityClient, input: {
|
|
|
932
943
|
plainExitAllowed: boolean;
|
|
933
944
|
enforcement: "sdk-path" | "conditional-hop" | "direct-hop";
|
|
934
945
|
};
|
|
946
|
+
trustSummary: import("../core/types").VerificationTrustSummary;
|
|
935
947
|
};
|
|
936
948
|
nextState: null;
|
|
937
949
|
nextCompiled: null;
|
|
@@ -994,6 +1006,7 @@ export declare function executeTransfer(sdk: SimplicityClient, input: {
|
|
|
994
1006
|
plainExitAllowed: boolean;
|
|
995
1007
|
enforcement: "sdk-path" | "conditional-hop" | "direct-hop";
|
|
996
1008
|
};
|
|
1009
|
+
trustSummary: import("../core/types").VerificationTrustSummary;
|
|
997
1010
|
};
|
|
998
1011
|
nextState: PolicyState;
|
|
999
1012
|
nextCompiled: import("..").CompiledContract;
|
package/dist/domain/policies.js
CHANGED
|
@@ -34,6 +34,7 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
34
34
|
const summary_1 = require("../core/summary");
|
|
35
35
|
const errors_1 = require("../core/errors");
|
|
36
36
|
const outputBinding_1 = require("../core/outputBinding");
|
|
37
|
+
const reporting_1 = require("../core/reporting");
|
|
37
38
|
function resolvePolicyDocsAsset(filename) {
|
|
38
39
|
const cwdCandidate = node_path_1.default.resolve(process.cwd(), "docs/definitions", filename);
|
|
39
40
|
if ((0, node_fs_1.existsSync)(cwdCandidate)) {
|
|
@@ -869,6 +870,19 @@ async function verifyState(sdk, input) {
|
|
|
869
870
|
propagationMode: state.propagationMode,
|
|
870
871
|
}).hash;
|
|
871
872
|
const policyHashMatches = expectedPolicyHash === state.policyHash;
|
|
873
|
+
const report = {
|
|
874
|
+
schemaVersion: exports.POLICY_VERIFICATION_REPORT_SCHEMA_VERSION,
|
|
875
|
+
templateTrust: definitionVerification.trust,
|
|
876
|
+
stateTrust: stateVerification.trust,
|
|
877
|
+
propagationMode: state.propagationMode,
|
|
878
|
+
nextPolicyRequired: state.propagationMode === "required",
|
|
879
|
+
nextPolicyPresent: false,
|
|
880
|
+
plainExitAllowed: state.propagationMode !== "required",
|
|
881
|
+
enforcement: resolvePolicyEnforcementMode({
|
|
882
|
+
currentPropagationMode: state.propagationMode,
|
|
883
|
+
nextReceiverMode: state.propagationMode === "required" ? "policy" : undefined,
|
|
884
|
+
}),
|
|
885
|
+
};
|
|
872
886
|
return {
|
|
873
887
|
ok: definitionVerification.ok && stateVerification.ok && policyHashMatches,
|
|
874
888
|
reason: policyHashMatches ? undefined : "Policy hash does not match template + params + recipient",
|
|
@@ -877,19 +891,12 @@ async function verifyState(sdk, input) {
|
|
|
877
891
|
state: stateVerification,
|
|
878
892
|
stateValue: state,
|
|
879
893
|
policyHashMatches,
|
|
880
|
-
report
|
|
881
|
-
|
|
882
|
-
|
|
894
|
+
report,
|
|
895
|
+
trustSummary: (0, reporting_1.buildVerificationTrustSummary)({
|
|
896
|
+
definitionTrust: definitionVerification.trust,
|
|
883
897
|
stateTrust: stateVerification.trust,
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
nextPolicyPresent: false,
|
|
887
|
-
plainExitAllowed: state.propagationMode !== "required",
|
|
888
|
-
enforcement: resolvePolicyEnforcementMode({
|
|
889
|
-
currentPropagationMode: state.propagationMode,
|
|
890
|
-
nextReceiverMode: state.propagationMode === "required" ? "policy" : undefined,
|
|
891
|
-
}),
|
|
892
|
-
},
|
|
898
|
+
bindingMode: "none",
|
|
899
|
+
}),
|
|
893
900
|
};
|
|
894
901
|
}
|
|
895
902
|
async function buildPolicyOutputDescriptor(sdk, input) {
|
|
@@ -1450,6 +1457,24 @@ async function verifyTransfer(sdk, input) {
|
|
|
1450
1457
|
&& transfer.previousStateHash === summarizePolicyState(currentState).hash
|
|
1451
1458
|
&& (!nextState || transfer.nextPolicyHash === nextState.policyHash)
|
|
1452
1459
|
&& (!nextStateSummary || transfer.nextStateHash === nextStateSummary.hash));
|
|
1460
|
+
const verificationReport = {
|
|
1461
|
+
...prepared.report,
|
|
1462
|
+
nextPolicyPresent: Boolean(nextState),
|
|
1463
|
+
plainExitAllowed: currentState.propagationMode !== "required",
|
|
1464
|
+
outputBinding: buildPolicyOutputBindingReport({
|
|
1465
|
+
descriptor: transfer?.outputDescriptor,
|
|
1466
|
+
sdkVerified: ok,
|
|
1467
|
+
supportedForm: outputBindingContext.supportedForm,
|
|
1468
|
+
reasonCode: outputBindingContext.reasonCode,
|
|
1469
|
+
autoDerived: outputBindingContext.autoDerived,
|
|
1470
|
+
fallbackReason: outputBindingContext.fallbackReason,
|
|
1471
|
+
bindingInputs: outputBindingContext.bindingInputs,
|
|
1472
|
+
}),
|
|
1473
|
+
enforcement: resolvePolicyEnforcementMode({
|
|
1474
|
+
currentPropagationMode: currentState.propagationMode,
|
|
1475
|
+
nextReceiverMode: nextState ? "policy" : "plain",
|
|
1476
|
+
}),
|
|
1477
|
+
};
|
|
1453
1478
|
return {
|
|
1454
1479
|
ok,
|
|
1455
1480
|
reason: ok ? undefined : "Policy transfer descriptor does not match current/next policy state",
|
|
@@ -1457,24 +1482,12 @@ async function verifyTransfer(sdk, input) {
|
|
|
1457
1482
|
transfer,
|
|
1458
1483
|
transferSummary: summary,
|
|
1459
1484
|
nextState,
|
|
1460
|
-
verificationReport
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
sdkVerified: ok,
|
|
1467
|
-
supportedForm: outputBindingContext.supportedForm,
|
|
1468
|
-
reasonCode: outputBindingContext.reasonCode,
|
|
1469
|
-
autoDerived: outputBindingContext.autoDerived,
|
|
1470
|
-
fallbackReason: outputBindingContext.fallbackReason,
|
|
1471
|
-
bindingInputs: outputBindingContext.bindingInputs,
|
|
1472
|
-
}),
|
|
1473
|
-
enforcement: resolvePolicyEnforcementMode({
|
|
1474
|
-
currentPropagationMode: currentState.propagationMode,
|
|
1475
|
-
nextReceiverMode: nextState ? "policy" : "plain",
|
|
1476
|
-
}),
|
|
1477
|
-
},
|
|
1485
|
+
verificationReport,
|
|
1486
|
+
trustSummary: (0, reporting_1.buildVerificationTrustSummary)({
|
|
1487
|
+
definitionTrust: verificationReport.templateTrust,
|
|
1488
|
+
stateTrust: verificationReport.stateTrust,
|
|
1489
|
+
bindingMode: verificationReport.outputBinding?.mode ?? "none",
|
|
1490
|
+
}),
|
|
1478
1491
|
};
|
|
1479
1492
|
}
|
|
1480
1493
|
async function inspectTransfer(sdk, input) {
|
|
@@ -1594,6 +1607,13 @@ async function exportEvidence(sdk, input) {
|
|
|
1594
1607
|
state: stateSummary,
|
|
1595
1608
|
...(input.transferDescriptorValue ? { transfer: summarizePolicyTransferDescriptor(input.transferDescriptorValue) } : {}),
|
|
1596
1609
|
report: transferVerification?.verificationReport ?? verified.report,
|
|
1610
|
+
trustSummary: transferVerification?.trustSummary
|
|
1611
|
+
?? verified.trustSummary
|
|
1612
|
+
?? (0, reporting_1.buildVerificationTrustSummary)({
|
|
1613
|
+
definitionTrust: verified.report.templateTrust,
|
|
1614
|
+
stateTrust: verified.report.stateTrust,
|
|
1615
|
+
bindingMode: "none",
|
|
1616
|
+
}),
|
|
1597
1617
|
renderedSourceHash,
|
|
1598
1618
|
sourceVerificationMode: renderedSourceHash ? "source-reloaded" : "artifact-only",
|
|
1599
1619
|
compiled: {
|