@hazbase/simplicity 0.3.2 → 0.4.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/dist/client/SimplicityClient.d.ts +11 -0
- package/dist/client/SimplicityClient.js +12 -0
- package/dist/domain/rwaDvp.d.ts +244 -0
- package/dist/domain/rwaDvp.js +308 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +17 -2
- package/dist/x402/index.js +7 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import { BondEvidenceBundle, OutputBindingSupportEvaluation, OutputBindingSuppor
|
|
|
4
4
|
import { RelayerClient } from "../gasless/RelayerClient";
|
|
5
5
|
import { GaslessTransferInput, GaslessTransferResult, RelayerClientConfig } from "../gasless/types";
|
|
6
6
|
import * as liquidX402 from "../x402";
|
|
7
|
+
import * as rwaDvp from "../domain/rwaDvp";
|
|
7
8
|
import { CompiledContract } from "./ContractFactory";
|
|
8
9
|
import { DeployedContract } from "./DeployedContract";
|
|
9
10
|
import { prepareRedemption, prepareClosing, exportFinalityPayload, buildSettlement, verifySettlement, define, executeClosing, executeRedemption, exportEvidence, inspectClosing, inspectRedemption, issue, load, verify, verifyIssuanceHistory, verifyClosing, verifyRedemption } from "../domain/bond";
|
|
@@ -33,6 +34,16 @@ export declare class SimplicityClient {
|
|
|
33
34
|
describeSupport: () => OutputBindingSupportMatrix;
|
|
34
35
|
evaluateSupport: (input: Parameters<typeof evaluateOutputBindingSupport>[0]) => OutputBindingSupportEvaluation;
|
|
35
36
|
};
|
|
37
|
+
readonly rwaDvp: {
|
|
38
|
+
definePurchase: (input: Parameters<typeof rwaDvp.definePurchase>[1]) => ReturnType<typeof rwaDvp.definePurchase>;
|
|
39
|
+
buildPaymentRequirements: (input: Parameters<typeof rwaDvp.buildPaymentRequirements>[1]) => ReturnType<typeof rwaDvp.buildPaymentRequirements>;
|
|
40
|
+
verifyPaymentPset: (input: Parameters<typeof rwaDvp.verifyPaymentPset>[1]) => ReturnType<typeof rwaDvp.verifyPaymentPset>;
|
|
41
|
+
prepareDeliveryClaim: (input: Parameters<typeof rwaDvp.prepareDeliveryClaim>[1]) => ReturnType<typeof rwaDvp.prepareDeliveryClaim>;
|
|
42
|
+
verifyDeliveryClaim: (input: Parameters<typeof rwaDvp.verifyDeliveryClaim>[1]) => ReturnType<typeof rwaDvp.verifyDeliveryClaim>;
|
|
43
|
+
prepareRefundClaim: (input: Parameters<typeof rwaDvp.prepareRefundClaim>[1]) => ReturnType<typeof rwaDvp.prepareRefundClaim>;
|
|
44
|
+
verifyRefundClaim: (input: Parameters<typeof rwaDvp.verifyRefundClaim>[1]) => ReturnType<typeof rwaDvp.verifyRefundClaim>;
|
|
45
|
+
exportEvidence: (input: Parameters<typeof rwaDvp.exportEvidence>[1]) => ReturnType<typeof rwaDvp.exportEvidence>;
|
|
46
|
+
};
|
|
36
47
|
readonly policies: {
|
|
37
48
|
listTemplates: () => ReturnType<typeof listPolicyTemplates>;
|
|
38
49
|
describeTemplate: (input: Parameters<typeof describePolicyTemplate>[0]) => ReturnType<typeof describePolicyTemplate>;
|
|
@@ -44,6 +44,7 @@ const outputBinding_1 = require("../core/outputBinding");
|
|
|
44
44
|
const rpc_1 = require("../core/rpc");
|
|
45
45
|
const RelayerClient_1 = require("../gasless/RelayerClient");
|
|
46
46
|
const liquidX402 = __importStar(require("../x402"));
|
|
47
|
+
const rwaDvp = __importStar(require("../domain/rwaDvp"));
|
|
47
48
|
const ContractFactory_1 = require("./ContractFactory");
|
|
48
49
|
const DeployedContract_1 = require("./DeployedContract");
|
|
49
50
|
const bond_1 = require("../domain/bond");
|
|
@@ -55,6 +56,7 @@ class SimplicityClient {
|
|
|
55
56
|
rpc;
|
|
56
57
|
payments;
|
|
57
58
|
outputBinding;
|
|
59
|
+
rwaDvp;
|
|
58
60
|
policies;
|
|
59
61
|
bonds;
|
|
60
62
|
funds;
|
|
@@ -82,6 +84,16 @@ class SimplicityClient {
|
|
|
82
84
|
describeSupport: () => (0, outputBinding_1.describeOutputBindingSupport)(),
|
|
83
85
|
evaluateSupport: (input) => (0, outputBinding_1.evaluateOutputBindingSupport)(input),
|
|
84
86
|
};
|
|
87
|
+
this.rwaDvp = {
|
|
88
|
+
definePurchase: (input) => rwaDvp.definePurchase(this, input),
|
|
89
|
+
buildPaymentRequirements: (input) => rwaDvp.buildPaymentRequirements(this, input),
|
|
90
|
+
verifyPaymentPset: (input) => rwaDvp.verifyPaymentPset(this, input),
|
|
91
|
+
prepareDeliveryClaim: (input) => rwaDvp.prepareDeliveryClaim(this, input),
|
|
92
|
+
verifyDeliveryClaim: (input) => rwaDvp.verifyDeliveryClaim(this, input),
|
|
93
|
+
prepareRefundClaim: (input) => rwaDvp.prepareRefundClaim(this, input),
|
|
94
|
+
verifyRefundClaim: (input) => rwaDvp.verifyRefundClaim(this, input),
|
|
95
|
+
exportEvidence: (input) => rwaDvp.exportEvidence(this, input),
|
|
96
|
+
};
|
|
85
97
|
this.policies = {
|
|
86
98
|
listTemplates: () => (0, policies_1.listPolicyTemplates)(),
|
|
87
99
|
describeTemplate: (input) => (0, policies_1.describePolicyTemplate)(input),
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import type { SimplicityClient } from "../client/SimplicityClient";
|
|
2
|
+
import type { BondOutputBindingMode, OutputRawFields } from "../core/types";
|
|
3
|
+
import { type LiquidX402AssetKey, type LiquidX402Network, type LiquidX402PaymentPayload, type LiquidX402PaymentRequirements, type LiquidX402VerifyPaymentResult } from "../x402";
|
|
4
|
+
export declare const RWA_DVP_PURCHASE_SCHEMA_VERSION: "rwa-dvp-purchase/v1";
|
|
5
|
+
export declare const RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION: "rwa-dvp-delivery-claim/v1";
|
|
6
|
+
export declare const RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION: "rwa-dvp-refund-claim/v1";
|
|
7
|
+
export declare const RWA_DVP_VERIFICATION_SCHEMA_VERSION: "rwa-dvp-verification/v1";
|
|
8
|
+
export declare const RWA_DVP_EVIDENCE_SCHEMA_VERSION: "rwa-dvp-evidence/v1";
|
|
9
|
+
export type RwaDvpPaymentAsset = LiquidX402AssetKey;
|
|
10
|
+
export interface RwaDvpEvmLockReference {
|
|
11
|
+
chainId: number;
|
|
12
|
+
lockManager: string;
|
|
13
|
+
orderKey: string;
|
|
14
|
+
token?: string;
|
|
15
|
+
backingOwner?: string;
|
|
16
|
+
classId?: string;
|
|
17
|
+
nonceId?: string;
|
|
18
|
+
amountAtomic: string;
|
|
19
|
+
termsHash?: string;
|
|
20
|
+
lockTxHash?: string;
|
|
21
|
+
consumeTxHash?: string;
|
|
22
|
+
releaseTxHash?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface RwaDvpPurchaseDefinition {
|
|
25
|
+
schemaVersion: typeof RWA_DVP_PURCHASE_SCHEMA_VERSION;
|
|
26
|
+
purchaseId: string;
|
|
27
|
+
network: LiquidX402Network;
|
|
28
|
+
evmLock: RwaDvpEvmLockReference;
|
|
29
|
+
payment: {
|
|
30
|
+
asset: RwaDvpPaymentAsset;
|
|
31
|
+
assetId: string;
|
|
32
|
+
amountAtomic: string;
|
|
33
|
+
escrowAddress: string;
|
|
34
|
+
treasuryAddress: string;
|
|
35
|
+
};
|
|
36
|
+
delivery: {
|
|
37
|
+
assetId: string;
|
|
38
|
+
amountAtomic: string;
|
|
39
|
+
recipientAddress: string;
|
|
40
|
+
};
|
|
41
|
+
refund: {
|
|
42
|
+
recipientAddress: string;
|
|
43
|
+
after: string;
|
|
44
|
+
};
|
|
45
|
+
expiresAt: string;
|
|
46
|
+
metadata?: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
export interface RwaDvpDefinePurchaseInput {
|
|
49
|
+
purchaseId: string;
|
|
50
|
+
network?: LiquidX402Network;
|
|
51
|
+
evmLock: RwaDvpEvmLockReference;
|
|
52
|
+
payment: {
|
|
53
|
+
asset: RwaDvpPaymentAsset;
|
|
54
|
+
assetId?: string;
|
|
55
|
+
amountAtomic: string | number | bigint;
|
|
56
|
+
escrowAddress: string;
|
|
57
|
+
treasuryAddress?: string;
|
|
58
|
+
};
|
|
59
|
+
delivery: {
|
|
60
|
+
assetId: string;
|
|
61
|
+
amountAtomic: string | number | bigint;
|
|
62
|
+
recipientAddress: string;
|
|
63
|
+
};
|
|
64
|
+
refund: {
|
|
65
|
+
recipientAddress: string;
|
|
66
|
+
after: string | Date;
|
|
67
|
+
};
|
|
68
|
+
expiresAt: string | Date;
|
|
69
|
+
metadata?: Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
export interface RwaDvpSummary {
|
|
72
|
+
canonicalJson: string;
|
|
73
|
+
hash: string;
|
|
74
|
+
}
|
|
75
|
+
export interface RwaDvpPreparedPurchase {
|
|
76
|
+
definition: RwaDvpPurchaseDefinition;
|
|
77
|
+
summary: RwaDvpSummary;
|
|
78
|
+
termsHash: string;
|
|
79
|
+
policyHash: string;
|
|
80
|
+
}
|
|
81
|
+
export interface RwaDvpBuildPaymentRequirementsInput {
|
|
82
|
+
purchase: RwaDvpPurchaseDefinition;
|
|
83
|
+
resource: string;
|
|
84
|
+
description?: string;
|
|
85
|
+
mimeType?: string;
|
|
86
|
+
maxTimeoutSeconds?: number;
|
|
87
|
+
maxFeeSat?: string | number | bigint;
|
|
88
|
+
metadata?: Record<string, unknown>;
|
|
89
|
+
}
|
|
90
|
+
export interface RwaDvpVerifyPaymentPsetInput {
|
|
91
|
+
purchase: RwaDvpPurchaseDefinition;
|
|
92
|
+
requirements: LiquidX402PaymentRequirements | Record<string, unknown>;
|
|
93
|
+
paymentPayload: LiquidX402PaymentPayload | Record<string, unknown>;
|
|
94
|
+
now?: Date;
|
|
95
|
+
verifyPsetOutputs?: boolean;
|
|
96
|
+
}
|
|
97
|
+
export interface RwaDvpDeliveryClaimDescriptor {
|
|
98
|
+
schemaVersion: typeof RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION;
|
|
99
|
+
purchaseId: string;
|
|
100
|
+
network: LiquidX402Network;
|
|
101
|
+
termsHash: string;
|
|
102
|
+
policyHash: string;
|
|
103
|
+
mode: "simplicity-multi-asset-claim" | "operator-wallet-delivery-bridge";
|
|
104
|
+
paymentInput?: {
|
|
105
|
+
txid: string;
|
|
106
|
+
vout?: number;
|
|
107
|
+
assetId: string;
|
|
108
|
+
amountAtomic: string;
|
|
109
|
+
};
|
|
110
|
+
operatorRwaInput?: {
|
|
111
|
+
txid?: string;
|
|
112
|
+
vout?: number;
|
|
113
|
+
assetId: string;
|
|
114
|
+
amountAtomic: string;
|
|
115
|
+
reissuanceAllowed?: boolean;
|
|
116
|
+
};
|
|
117
|
+
outputs: {
|
|
118
|
+
paymentToTreasury: {
|
|
119
|
+
recipientAddress: string;
|
|
120
|
+
assetId: string;
|
|
121
|
+
amountAtomic: string;
|
|
122
|
+
outputIndex: number;
|
|
123
|
+
};
|
|
124
|
+
rwaToBuyer: {
|
|
125
|
+
recipientAddress: string;
|
|
126
|
+
assetId: string;
|
|
127
|
+
amountAtomic: string;
|
|
128
|
+
outputIndex: number;
|
|
129
|
+
outputBindingMode: BondOutputBindingMode;
|
|
130
|
+
rawOutput?: Partial<OutputRawFields>;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
fee: {
|
|
134
|
+
asset: "lbtc";
|
|
135
|
+
maxFeeSat: number;
|
|
136
|
+
feeOutputIndex?: number;
|
|
137
|
+
};
|
|
138
|
+
fundingTxid?: string;
|
|
139
|
+
deliveryTxid?: string;
|
|
140
|
+
createdAt: string;
|
|
141
|
+
}
|
|
142
|
+
export interface RwaDvpPrepareDeliveryClaimInput {
|
|
143
|
+
purchase: RwaDvpPurchaseDefinition;
|
|
144
|
+
fundingTxid?: string;
|
|
145
|
+
paymentInput?: RwaDvpDeliveryClaimDescriptor["paymentInput"];
|
|
146
|
+
operatorRwaInput?: RwaDvpDeliveryClaimDescriptor["operatorRwaInput"];
|
|
147
|
+
mode?: RwaDvpDeliveryClaimDescriptor["mode"];
|
|
148
|
+
outputBindingMode?: BondOutputBindingMode;
|
|
149
|
+
nextRawOutput?: Partial<OutputRawFields>;
|
|
150
|
+
paymentOutputIndex?: number;
|
|
151
|
+
deliveryOutputIndex?: number;
|
|
152
|
+
maxFeeSat?: number;
|
|
153
|
+
feeOutputIndex?: number;
|
|
154
|
+
deliveryTxid?: string;
|
|
155
|
+
createdAt?: string | Date;
|
|
156
|
+
}
|
|
157
|
+
export interface RwaDvpRefundClaimDescriptor {
|
|
158
|
+
schemaVersion: typeof RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION;
|
|
159
|
+
purchaseId: string;
|
|
160
|
+
network: LiquidX402Network;
|
|
161
|
+
termsHash: string;
|
|
162
|
+
policyHash: string;
|
|
163
|
+
paymentInput?: {
|
|
164
|
+
txid: string;
|
|
165
|
+
vout?: number;
|
|
166
|
+
assetId: string;
|
|
167
|
+
amountAtomic: string;
|
|
168
|
+
};
|
|
169
|
+
refundOutput: {
|
|
170
|
+
recipientAddress: string;
|
|
171
|
+
assetId: string;
|
|
172
|
+
amountAtomic: string;
|
|
173
|
+
outputIndex: number;
|
|
174
|
+
};
|
|
175
|
+
notBefore: string;
|
|
176
|
+
fee: {
|
|
177
|
+
asset: "lbtc";
|
|
178
|
+
maxFeeSat: number;
|
|
179
|
+
feeOutputIndex?: number;
|
|
180
|
+
};
|
|
181
|
+
refundTxid?: string;
|
|
182
|
+
createdAt: string;
|
|
183
|
+
}
|
|
184
|
+
export interface RwaDvpPrepareRefundClaimInput {
|
|
185
|
+
purchase: RwaDvpPurchaseDefinition;
|
|
186
|
+
paymentInput?: RwaDvpRefundClaimDescriptor["paymentInput"];
|
|
187
|
+
refundOutputIndex?: number;
|
|
188
|
+
maxFeeSat?: number;
|
|
189
|
+
feeOutputIndex?: number;
|
|
190
|
+
refundTxid?: string;
|
|
191
|
+
createdAt?: string | Date;
|
|
192
|
+
}
|
|
193
|
+
export interface RwaDvpVerificationReport {
|
|
194
|
+
schemaVersion: typeof RWA_DVP_VERIFICATION_SCHEMA_VERSION;
|
|
195
|
+
ok: boolean;
|
|
196
|
+
reason?: string;
|
|
197
|
+
purchaseId: string;
|
|
198
|
+
termsHash: string;
|
|
199
|
+
policyHash: string;
|
|
200
|
+
checks: Record<string, boolean>;
|
|
201
|
+
}
|
|
202
|
+
export interface RwaDvpEvidenceBundle {
|
|
203
|
+
schemaVersion: typeof RWA_DVP_EVIDENCE_SCHEMA_VERSION;
|
|
204
|
+
purchase: RwaDvpPurchaseDefinition;
|
|
205
|
+
termsHash: string;
|
|
206
|
+
policyHash: string;
|
|
207
|
+
paymentRequirements?: LiquidX402PaymentRequirements | Record<string, unknown>;
|
|
208
|
+
paymentVerification?: LiquidX402VerifyPaymentResult;
|
|
209
|
+
deliveryClaim?: RwaDvpDeliveryClaimDescriptor;
|
|
210
|
+
deliveryVerification?: RwaDvpVerificationReport;
|
|
211
|
+
refundClaim?: RwaDvpRefundClaimDescriptor;
|
|
212
|
+
refundVerification?: RwaDvpVerificationReport;
|
|
213
|
+
evm?: {
|
|
214
|
+
lockTxHash?: string;
|
|
215
|
+
consumeTxHash?: string;
|
|
216
|
+
releaseTxHash?: string;
|
|
217
|
+
};
|
|
218
|
+
createdAt: string;
|
|
219
|
+
}
|
|
220
|
+
export declare function definePurchase(_sdk: SimplicityClient, input: RwaDvpDefinePurchaseInput): RwaDvpPreparedPurchase;
|
|
221
|
+
export declare function summarizePurchase(purchase: RwaDvpPurchaseDefinition): RwaDvpSummary;
|
|
222
|
+
export declare function buildPaymentRequirements(_sdk: SimplicityClient, input: RwaDvpBuildPaymentRequirementsInput): LiquidX402PaymentRequirements;
|
|
223
|
+
export declare function verifyPaymentPset(sdk: SimplicityClient, input: RwaDvpVerifyPaymentPsetInput): Promise<LiquidX402VerifyPaymentResult>;
|
|
224
|
+
export declare function prepareDeliveryClaim(sdk: SimplicityClient, input: RwaDvpPrepareDeliveryClaimInput): {
|
|
225
|
+
descriptor: RwaDvpDeliveryClaimDescriptor;
|
|
226
|
+
summary: RwaDvpSummary;
|
|
227
|
+
verification: RwaDvpVerificationReport;
|
|
228
|
+
};
|
|
229
|
+
export declare function verifyDeliveryClaim(_sdk: SimplicityClient, input: {
|
|
230
|
+
purchase: RwaDvpPurchaseDefinition;
|
|
231
|
+
descriptor: RwaDvpDeliveryClaimDescriptor;
|
|
232
|
+
}): RwaDvpVerificationReport;
|
|
233
|
+
export declare function prepareRefundClaim(sdk: SimplicityClient, input: RwaDvpPrepareRefundClaimInput): {
|
|
234
|
+
descriptor: RwaDvpRefundClaimDescriptor;
|
|
235
|
+
summary: RwaDvpSummary;
|
|
236
|
+
verification: RwaDvpVerificationReport;
|
|
237
|
+
};
|
|
238
|
+
export declare function verifyRefundClaim(_sdk: SimplicityClient, input: {
|
|
239
|
+
purchase: RwaDvpPurchaseDefinition;
|
|
240
|
+
descriptor: RwaDvpRefundClaimDescriptor;
|
|
241
|
+
}): RwaDvpVerificationReport;
|
|
242
|
+
export declare function exportEvidence(_sdk: SimplicityClient, input: Omit<RwaDvpEvidenceBundle, "schemaVersion" | "createdAt" | "termsHash" | "policyHash"> & {
|
|
243
|
+
createdAt?: string | Date;
|
|
244
|
+
}): RwaDvpEvidenceBundle;
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RWA_DVP_EVIDENCE_SCHEMA_VERSION = exports.RWA_DVP_VERIFICATION_SCHEMA_VERSION = exports.RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION = exports.RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION = exports.RWA_DVP_PURCHASE_SCHEMA_VERSION = void 0;
|
|
4
|
+
exports.definePurchase = definePurchase;
|
|
5
|
+
exports.summarizePurchase = summarizePurchase;
|
|
6
|
+
exports.buildPaymentRequirements = buildPaymentRequirements;
|
|
7
|
+
exports.verifyPaymentPset = verifyPaymentPset;
|
|
8
|
+
exports.prepareDeliveryClaim = prepareDeliveryClaim;
|
|
9
|
+
exports.verifyDeliveryClaim = verifyDeliveryClaim;
|
|
10
|
+
exports.prepareRefundClaim = prepareRefundClaim;
|
|
11
|
+
exports.verifyRefundClaim = verifyRefundClaim;
|
|
12
|
+
exports.exportEvidence = exportEvidence;
|
|
13
|
+
const errors_1 = require("../core/errors");
|
|
14
|
+
const summary_1 = require("../core/summary");
|
|
15
|
+
const x402_1 = require("../x402");
|
|
16
|
+
exports.RWA_DVP_PURCHASE_SCHEMA_VERSION = "rwa-dvp-purchase/v1";
|
|
17
|
+
exports.RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION = "rwa-dvp-delivery-claim/v1";
|
|
18
|
+
exports.RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION = "rwa-dvp-refund-claim/v1";
|
|
19
|
+
exports.RWA_DVP_VERIFICATION_SCHEMA_VERSION = "rwa-dvp-verification/v1";
|
|
20
|
+
exports.RWA_DVP_EVIDENCE_SCHEMA_VERSION = "rwa-dvp-evidence/v1";
|
|
21
|
+
function definePurchase(_sdk, input) {
|
|
22
|
+
const network = input.network ?? "liquidtestnet";
|
|
23
|
+
assertNonEmpty(input.purchaseId, "purchaseId");
|
|
24
|
+
assertNonEmpty(input.payment.escrowAddress, "payment.escrowAddress");
|
|
25
|
+
assertNonEmpty(input.delivery.recipientAddress, "delivery.recipientAddress");
|
|
26
|
+
assertNonEmpty(input.refund.recipientAddress, "refund.recipientAddress");
|
|
27
|
+
assertPositiveInteger(input.payment.amountAtomic, "payment.amountAtomic");
|
|
28
|
+
assertPositiveInteger(input.delivery.amountAtomic, "delivery.amountAtomic");
|
|
29
|
+
assertPositiveInteger(input.evmLock.amountAtomic, "evmLock.amountAtomic");
|
|
30
|
+
assertFutureishDate(input.expiresAt, "expiresAt");
|
|
31
|
+
assertFutureishDate(input.refund.after, "refund.after");
|
|
32
|
+
const assetId = input.payment.assetId ?? (0, x402_1.resolveLiquidX402Asset)(input.payment.asset, network).assetId;
|
|
33
|
+
const definition = {
|
|
34
|
+
schemaVersion: exports.RWA_DVP_PURCHASE_SCHEMA_VERSION,
|
|
35
|
+
purchaseId: input.purchaseId,
|
|
36
|
+
network,
|
|
37
|
+
evmLock: {
|
|
38
|
+
...input.evmLock,
|
|
39
|
+
amountAtomic: normalizeInteger(input.evmLock.amountAtomic),
|
|
40
|
+
},
|
|
41
|
+
payment: {
|
|
42
|
+
asset: input.payment.asset,
|
|
43
|
+
assetId,
|
|
44
|
+
amountAtomic: normalizeInteger(input.payment.amountAtomic),
|
|
45
|
+
escrowAddress: input.payment.escrowAddress,
|
|
46
|
+
treasuryAddress: input.payment.treasuryAddress ?? input.payment.escrowAddress,
|
|
47
|
+
},
|
|
48
|
+
delivery: {
|
|
49
|
+
assetId: input.delivery.assetId,
|
|
50
|
+
amountAtomic: normalizeInteger(input.delivery.amountAtomic),
|
|
51
|
+
recipientAddress: input.delivery.recipientAddress,
|
|
52
|
+
},
|
|
53
|
+
refund: {
|
|
54
|
+
recipientAddress: input.refund.recipientAddress,
|
|
55
|
+
after: normalizeIso(input.refund.after),
|
|
56
|
+
},
|
|
57
|
+
expiresAt: normalizeIso(input.expiresAt),
|
|
58
|
+
...(input.metadata ? { metadata: input.metadata } : {}),
|
|
59
|
+
};
|
|
60
|
+
const summary = summarizePurchase(definition);
|
|
61
|
+
return {
|
|
62
|
+
definition,
|
|
63
|
+
summary,
|
|
64
|
+
termsHash: summary.hash,
|
|
65
|
+
policyHash: summarizePolicy(definition).hash,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function summarizePurchase(purchase) {
|
|
69
|
+
return summarizeCanonical(purchase);
|
|
70
|
+
}
|
|
71
|
+
function buildPaymentRequirements(_sdk, input) {
|
|
72
|
+
const summary = summarizePurchase(input.purchase);
|
|
73
|
+
return (0, x402_1.buildLiquidX402Requirements)({
|
|
74
|
+
paymentRequestId: input.purchase.purchaseId,
|
|
75
|
+
resource: input.resource,
|
|
76
|
+
payTo: input.purchase.payment.escrowAddress,
|
|
77
|
+
amountAtomic: input.purchase.payment.amountAtomic,
|
|
78
|
+
network: input.purchase.network,
|
|
79
|
+
asset: input.purchase.payment.asset,
|
|
80
|
+
description: input.description ?? "Hazbase RWA Liquid delivery-versus-payment",
|
|
81
|
+
mimeType: input.mimeType ?? "application/json",
|
|
82
|
+
maxTimeoutSeconds: input.maxTimeoutSeconds,
|
|
83
|
+
expiresAt: input.purchase.expiresAt,
|
|
84
|
+
maxFeeSat: input.maxFeeSat,
|
|
85
|
+
metadata: {
|
|
86
|
+
...input.metadata,
|
|
87
|
+
purchaseId: input.purchase.purchaseId,
|
|
88
|
+
termsHash: summary.hash,
|
|
89
|
+
policyHash: summarizePolicy(input.purchase).hash,
|
|
90
|
+
deliveryAssetId: input.purchase.delivery.assetId,
|
|
91
|
+
deliveryAmountAtomic: input.purchase.delivery.amountAtomic,
|
|
92
|
+
deliveryRecipientAddress: input.purchase.delivery.recipientAddress,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async function verifyPaymentPset(sdk, input) {
|
|
97
|
+
const rpc = input.verifyPsetOutputs === false ? null : sdk.rpc;
|
|
98
|
+
const result = await (0, x402_1.verifyLiquidX402Payment)(rpc, {
|
|
99
|
+
requirements: input.requirements,
|
|
100
|
+
paymentPayload: input.paymentPayload,
|
|
101
|
+
now: input.now,
|
|
102
|
+
});
|
|
103
|
+
if (!result.isValid)
|
|
104
|
+
return result;
|
|
105
|
+
if (result.paymentRequestId !== input.purchase.purchaseId) {
|
|
106
|
+
return { ...result, isValid: false, invalidReason: "purchase_mismatch" };
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
function prepareDeliveryClaim(sdk, input) {
|
|
111
|
+
const purchaseSummary = summarizePurchase(input.purchase);
|
|
112
|
+
const policy = summarizePolicy(input.purchase);
|
|
113
|
+
const descriptor = {
|
|
114
|
+
schemaVersion: exports.RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION,
|
|
115
|
+
purchaseId: input.purchase.purchaseId,
|
|
116
|
+
network: input.purchase.network,
|
|
117
|
+
termsHash: purchaseSummary.hash,
|
|
118
|
+
policyHash: policy.hash,
|
|
119
|
+
mode: input.mode ?? "simplicity-multi-asset-claim",
|
|
120
|
+
...(input.paymentInput ? { paymentInput: input.paymentInput } : {}),
|
|
121
|
+
operatorRwaInput: input.operatorRwaInput ?? {
|
|
122
|
+
assetId: input.purchase.delivery.assetId,
|
|
123
|
+
amountAtomic: input.purchase.delivery.amountAtomic,
|
|
124
|
+
reissuanceAllowed: true,
|
|
125
|
+
},
|
|
126
|
+
outputs: {
|
|
127
|
+
paymentToTreasury: {
|
|
128
|
+
recipientAddress: input.purchase.payment.treasuryAddress,
|
|
129
|
+
assetId: input.purchase.payment.assetId,
|
|
130
|
+
amountAtomic: input.purchase.payment.amountAtomic,
|
|
131
|
+
outputIndex: input.paymentOutputIndex ?? 0,
|
|
132
|
+
},
|
|
133
|
+
rwaToBuyer: {
|
|
134
|
+
recipientAddress: input.purchase.delivery.recipientAddress,
|
|
135
|
+
assetId: input.purchase.delivery.assetId,
|
|
136
|
+
amountAtomic: input.purchase.delivery.amountAtomic,
|
|
137
|
+
outputIndex: input.deliveryOutputIndex ?? 1,
|
|
138
|
+
outputBindingMode: input.outputBindingMode ?? "descriptor-bound",
|
|
139
|
+
...(input.nextRawOutput ? { rawOutput: input.nextRawOutput } : {}),
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
fee: {
|
|
143
|
+
asset: "lbtc",
|
|
144
|
+
maxFeeSat: input.maxFeeSat ?? sdk.config.defaults?.feeSat ?? 1000,
|
|
145
|
+
...(input.feeOutputIndex !== undefined ? { feeOutputIndex: input.feeOutputIndex } : {}),
|
|
146
|
+
},
|
|
147
|
+
...(input.fundingTxid ? { fundingTxid: input.fundingTxid } : {}),
|
|
148
|
+
...(input.deliveryTxid ? { deliveryTxid: input.deliveryTxid } : {}),
|
|
149
|
+
createdAt: input.createdAt ? normalizeIso(input.createdAt) : new Date().toISOString(),
|
|
150
|
+
};
|
|
151
|
+
const verification = verifyDeliveryClaim(sdk, { purchase: input.purchase, descriptor });
|
|
152
|
+
return {
|
|
153
|
+
descriptor,
|
|
154
|
+
summary: summarizeCanonical(descriptor),
|
|
155
|
+
verification,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function verifyDeliveryClaim(_sdk, input) {
|
|
159
|
+
const termsHash = summarizePurchase(input.purchase).hash;
|
|
160
|
+
const policyHash = summarizePolicy(input.purchase).hash;
|
|
161
|
+
const checks = {
|
|
162
|
+
schemaVersion: input.descriptor.schemaVersion === exports.RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION,
|
|
163
|
+
purchaseId: input.descriptor.purchaseId === input.purchase.purchaseId,
|
|
164
|
+
network: input.descriptor.network === input.purchase.network,
|
|
165
|
+
termsHash: input.descriptor.termsHash === termsHash,
|
|
166
|
+
policyHash: input.descriptor.policyHash === policyHash,
|
|
167
|
+
paymentOutputAsset: input.descriptor.outputs.paymentToTreasury.assetId === input.purchase.payment.assetId,
|
|
168
|
+
paymentOutputAmount: input.descriptor.outputs.paymentToTreasury.amountAtomic === input.purchase.payment.amountAtomic,
|
|
169
|
+
paymentOutputRecipient: input.descriptor.outputs.paymentToTreasury.recipientAddress === input.purchase.payment.treasuryAddress,
|
|
170
|
+
deliveryOutputAsset: input.descriptor.outputs.rwaToBuyer.assetId === input.purchase.delivery.assetId,
|
|
171
|
+
deliveryOutputAmount: input.descriptor.outputs.rwaToBuyer.amountAtomic === input.purchase.delivery.amountAtomic,
|
|
172
|
+
deliveryOutputRecipient: input.descriptor.outputs.rwaToBuyer.recipientAddress === input.purchase.delivery.recipientAddress,
|
|
173
|
+
fee: Number.isInteger(input.descriptor.fee.maxFeeSat) && input.descriptor.fee.maxFeeSat >= 0,
|
|
174
|
+
};
|
|
175
|
+
return report(input.purchase.purchaseId, termsHash, policyHash, checks, "RWA DvP delivery claim descriptor mismatch");
|
|
176
|
+
}
|
|
177
|
+
function prepareRefundClaim(sdk, input) {
|
|
178
|
+
const termsHash = summarizePurchase(input.purchase).hash;
|
|
179
|
+
const policyHash = summarizePolicy(input.purchase).hash;
|
|
180
|
+
const descriptor = {
|
|
181
|
+
schemaVersion: exports.RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION,
|
|
182
|
+
purchaseId: input.purchase.purchaseId,
|
|
183
|
+
network: input.purchase.network,
|
|
184
|
+
termsHash,
|
|
185
|
+
policyHash,
|
|
186
|
+
...(input.paymentInput ? { paymentInput: input.paymentInput } : {}),
|
|
187
|
+
refundOutput: {
|
|
188
|
+
recipientAddress: input.purchase.refund.recipientAddress,
|
|
189
|
+
assetId: input.purchase.payment.assetId,
|
|
190
|
+
amountAtomic: input.purchase.payment.amountAtomic,
|
|
191
|
+
outputIndex: input.refundOutputIndex ?? 0,
|
|
192
|
+
},
|
|
193
|
+
notBefore: input.purchase.refund.after,
|
|
194
|
+
fee: {
|
|
195
|
+
asset: "lbtc",
|
|
196
|
+
maxFeeSat: input.maxFeeSat ?? sdk.config.defaults?.feeSat ?? 1000,
|
|
197
|
+
...(input.feeOutputIndex !== undefined ? { feeOutputIndex: input.feeOutputIndex } : {}),
|
|
198
|
+
},
|
|
199
|
+
...(input.refundTxid ? { refundTxid: input.refundTxid } : {}),
|
|
200
|
+
createdAt: input.createdAt ? normalizeIso(input.createdAt) : new Date().toISOString(),
|
|
201
|
+
};
|
|
202
|
+
const verification = verifyRefundClaim(sdk, { purchase: input.purchase, descriptor });
|
|
203
|
+
return {
|
|
204
|
+
descriptor,
|
|
205
|
+
summary: summarizeCanonical(descriptor),
|
|
206
|
+
verification,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
function verifyRefundClaim(_sdk, input) {
|
|
210
|
+
const termsHash = summarizePurchase(input.purchase).hash;
|
|
211
|
+
const policyHash = summarizePolicy(input.purchase).hash;
|
|
212
|
+
const checks = {
|
|
213
|
+
schemaVersion: input.descriptor.schemaVersion === exports.RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION,
|
|
214
|
+
purchaseId: input.descriptor.purchaseId === input.purchase.purchaseId,
|
|
215
|
+
network: input.descriptor.network === input.purchase.network,
|
|
216
|
+
termsHash: input.descriptor.termsHash === termsHash,
|
|
217
|
+
policyHash: input.descriptor.policyHash === policyHash,
|
|
218
|
+
refundAsset: input.descriptor.refundOutput.assetId === input.purchase.payment.assetId,
|
|
219
|
+
refundAmount: input.descriptor.refundOutput.amountAtomic === input.purchase.payment.amountAtomic,
|
|
220
|
+
refundRecipient: input.descriptor.refundOutput.recipientAddress === input.purchase.refund.recipientAddress,
|
|
221
|
+
notBefore: input.descriptor.notBefore === input.purchase.refund.after,
|
|
222
|
+
fee: Number.isInteger(input.descriptor.fee.maxFeeSat) && input.descriptor.fee.maxFeeSat >= 0,
|
|
223
|
+
};
|
|
224
|
+
return report(input.purchase.purchaseId, termsHash, policyHash, checks, "RWA DvP refund claim descriptor mismatch");
|
|
225
|
+
}
|
|
226
|
+
function exportEvidence(_sdk, input) {
|
|
227
|
+
return {
|
|
228
|
+
schemaVersion: exports.RWA_DVP_EVIDENCE_SCHEMA_VERSION,
|
|
229
|
+
purchase: input.purchase,
|
|
230
|
+
termsHash: summarizePurchase(input.purchase).hash,
|
|
231
|
+
policyHash: summarizePolicy(input.purchase).hash,
|
|
232
|
+
...(input.paymentRequirements ? { paymentRequirements: input.paymentRequirements } : {}),
|
|
233
|
+
...(input.paymentVerification ? { paymentVerification: input.paymentVerification } : {}),
|
|
234
|
+
...(input.deliveryClaim ? { deliveryClaim: input.deliveryClaim } : {}),
|
|
235
|
+
...(input.deliveryVerification ? { deliveryVerification: input.deliveryVerification } : {}),
|
|
236
|
+
...(input.refundClaim ? { refundClaim: input.refundClaim } : {}),
|
|
237
|
+
...(input.refundVerification ? { refundVerification: input.refundVerification } : {}),
|
|
238
|
+
...(input.evm ? { evm: input.evm } : {}),
|
|
239
|
+
createdAt: input.createdAt ? normalizeIso(input.createdAt) : new Date().toISOString(),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
function summarizePolicy(purchase) {
|
|
243
|
+
return summarizeCanonical({
|
|
244
|
+
schemaVersion: "rwa-dvp-policy/v1",
|
|
245
|
+
purchaseId: purchase.purchaseId,
|
|
246
|
+
network: purchase.network,
|
|
247
|
+
evmLock: purchase.evmLock,
|
|
248
|
+
paymentMustFundEscrow: {
|
|
249
|
+
asset: purchase.payment.asset,
|
|
250
|
+
assetId: purchase.payment.assetId,
|
|
251
|
+
amountAtomic: purchase.payment.amountAtomic,
|
|
252
|
+
escrowAddress: purchase.payment.escrowAddress,
|
|
253
|
+
},
|
|
254
|
+
deliveryClaimMustPay: {
|
|
255
|
+
treasuryAddress: purchase.payment.treasuryAddress,
|
|
256
|
+
buyerAddress: purchase.delivery.recipientAddress,
|
|
257
|
+
paymentAssetId: purchase.payment.assetId,
|
|
258
|
+
paymentAmountAtomic: purchase.payment.amountAtomic,
|
|
259
|
+
rwaAssetId: purchase.delivery.assetId,
|
|
260
|
+
rwaAmountAtomic: purchase.delivery.amountAtomic,
|
|
261
|
+
},
|
|
262
|
+
refundAfter: purchase.refund,
|
|
263
|
+
expiresAt: purchase.expiresAt,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function summarizeCanonical(value) {
|
|
267
|
+
const canonicalJson = (0, summary_1.stableStringify)(value);
|
|
268
|
+
return { canonicalJson, hash: (0, summary_1.sha256HexUtf8)(canonicalJson) };
|
|
269
|
+
}
|
|
270
|
+
function report(purchaseId, termsHash, policyHash, checks, reason) {
|
|
271
|
+
const ok = Object.values(checks).every(Boolean);
|
|
272
|
+
return {
|
|
273
|
+
schemaVersion: exports.RWA_DVP_VERIFICATION_SCHEMA_VERSION,
|
|
274
|
+
ok,
|
|
275
|
+
...(ok ? {} : { reason }),
|
|
276
|
+
purchaseId,
|
|
277
|
+
termsHash,
|
|
278
|
+
policyHash,
|
|
279
|
+
checks,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function assertNonEmpty(value, name) {
|
|
283
|
+
if (!value || !value.trim()) {
|
|
284
|
+
throw new errors_1.ValidationError(`${name} must be a non-empty string`, { code: "RWA_DVP_FIELD_REQUIRED", field: name });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function assertPositiveInteger(value, name) {
|
|
288
|
+
normalizeInteger(value);
|
|
289
|
+
if (BigInt(value) <= 0n) {
|
|
290
|
+
throw new errors_1.ValidationError(`${name} must be positive`, { code: "RWA_DVP_AMOUNT_INVALID", field: name });
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function normalizeInteger(value) {
|
|
294
|
+
const text = typeof value === "bigint" ? value.toString() : String(value).trim();
|
|
295
|
+
if (!/^[0-9]+$/u.test(text)) {
|
|
296
|
+
throw new errors_1.ValidationError("amount must be an integer string", { code: "RWA_DVP_AMOUNT_INVALID" });
|
|
297
|
+
}
|
|
298
|
+
return BigInt(text).toString();
|
|
299
|
+
}
|
|
300
|
+
function assertFutureishDate(value, name) {
|
|
301
|
+
const time = new Date(value).getTime();
|
|
302
|
+
if (!Number.isFinite(time)) {
|
|
303
|
+
throw new errors_1.ValidationError(`${name} must be a valid date`, { code: "RWA_DVP_DATE_INVALID", field: name });
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function normalizeIso(value) {
|
|
307
|
+
return new Date(value).toISOString();
|
|
308
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,4 +18,6 @@ export { validateBondDefinition, validateBondIssuanceState, validateBondCrossChe
|
|
|
18
18
|
export { summarizeBondSettlementDescriptor, validateBondSettlementDescriptor, validateBondSettlementMatchesExpected, } from "./domain/bondSettlementValidation";
|
|
19
19
|
export { summarizeFundDefinition, summarizeCapitalCallState, summarizeLPPositionReceipt, summarizeDistributionDescriptor, summarizeFundClosingDescriptor, summarizeFundFinalityPayload, validateFundDefinition, validateCapitalCallState, validateLPPositionReceipt, validateDistributionDescriptor, validateFundClosingDescriptor, validateFundCrossChecks, validateDistributionAgainstReceipt, validateClosingAgainstReceipt, buildClaimedCapitalCallState, buildRefundedCapitalCallState, buildLPPositionReceipt, applyDistributionToReceipt, applyDistributionsToReceipt, buildDistributionDescriptor, buildFundClosingDescriptor, } from "./domain/fundValidation";
|
|
20
20
|
export { applyReceivableRepayment, buildDefaultedReceivableState, buildFundedReceivableState, buildReceivableClosingDescriptor, buildReceivableFundingClaimDescriptor, buildReceivableRepaymentClaimDescriptor, summarizeReceivableClosingDescriptor, summarizeReceivableDefinition, summarizeReceivableFundingClaimDescriptor, summarizeReceivableRepaymentClaimDescriptor, summarizeReceivableState, validateReceivableClosingAgainstState, validateReceivableClosingDescriptor, validateReceivableDefinition, validateReceivableFundingClaimAgainstState, validateReceivableFundingClaimDescriptor, validateReceivableRepaymentClaimAgainstState, validateReceivableRepaymentClaimDescriptor, validateReceivableState, validateReceivableCrossChecks, validateReceivableFundingTransition, validateReceivableRepaymentTransition, validateReceivableWriteOffTransition, verifyReceivableStateHistory as verifyReceivableStateHistoryValidation, } from "./domain/receivableValidation";
|
|
21
|
+
export { RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION, RWA_DVP_EVIDENCE_SCHEMA_VERSION, RWA_DVP_PURCHASE_SCHEMA_VERSION, RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION, RWA_DVP_VERIFICATION_SCHEMA_VERSION, buildPaymentRequirements as buildRwaDvpPaymentRequirements, definePurchase as defineRwaDvpPurchase, exportEvidence as exportRwaDvpEvidence, prepareDeliveryClaim as prepareRwaDvpDeliveryClaim, prepareRefundClaim as prepareRwaDvpRefundClaim, summarizePurchase as summarizeRwaDvpPurchase, verifyDeliveryClaim as verifyRwaDvpDeliveryClaim, verifyPaymentPset as verifyRwaDvpPaymentPset, verifyRefundClaim as verifyRwaDvpRefundClaim, } from "./domain/rwaDvp";
|
|
22
|
+
export type { RwaDvpDefinePurchaseInput, RwaDvpDeliveryClaimDescriptor, RwaDvpEvidenceBundle, RwaDvpEvmLockReference, RwaDvpPaymentAsset, RwaDvpPreparedPurchase, RwaDvpPrepareDeliveryClaimInput, RwaDvpPrepareRefundClaimInput, RwaDvpPurchaseDefinition, RwaDvpRefundClaimDescriptor, RwaDvpSummary, RwaDvpVerificationReport, } from "./domain/rwaDvp";
|
|
21
23
|
export { compilePolicyStateContract, buildPolicyOutputDescriptor, listPolicyTemplates, loadPolicyTemplateManifest, validatePolicyTemplateManifest, describePolicyTemplate, validatePolicyTemplateParams, issue, prepareTransfer, executeTransfer, inspectTransfer, verifyState, verifyTransfer, exportEvidence as exportPolicyEvidence, summarizePolicyState, summarizePolicyOutputDescriptor, summarizePolicyTransferDescriptor, validatePolicyState, validatePolicyOutputDescriptor, validatePolicyTransferDescriptor, } from "./domain/policies";
|
package/dist/index.js
CHANGED
|
@@ -16,8 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.signPositionReceipt = exports.verifyCapitalCall = exports.executeCapitalCallRefund = exports.inspectCapitalCallRefund = exports.executeCapitalCallRollover = exports.inspectCapitalCallRollover = exports.executeCapitalCallClaim = exports.inspectCapitalCallClaim = exports.prepareCapitalCall = exports.loadFund = exports.verifyFund = exports.defineFund = exports.exportFinalityPayload = exports.exportBondEvidence = exports.verifyClosing = exports.executeClosing = exports.inspectClosing = exports.prepareClosing = exports.verifySettlement = exports.buildSettlement = exports.verifyRedemption = exports.executeRedemption = exports.inspectRedemption = exports.prepareRedemption = exports.issueBond = exports.loadBond = exports.verifyIssuanceHistory = exports.verifyBond = exports.defineBond = exports.verifyStateDescriptorAgainstArtifact = exports.verifyStateAgainstArtifact = exports.buildArtifactStateMetadata = exports.loadStateInput = exports.verifyDefinitionDescriptorAgainstArtifact = exports.verifyDefinitionAgainstArtifact = exports.buildArtifactDefinitionMetadata = exports.loadDefinitionInput = exports.evaluateOutputBindingSupport = exports.describeOutputBindingSupport = exports.normalizeArtifact = exports.saveArtifact = exports.loadArtifact = exports.getPresetOrThrow = exports.listPresets = exports.ElementsRpcClient = exports.RelayerClient = exports.DeployedContract = exports.CompiledContract = exports.SimplicityClient = exports.createSimplicityClient = void 0;
|
|
18
18
|
exports.validateFundDefinition = exports.summarizeFundFinalityPayload = exports.summarizeFundClosingDescriptor = exports.summarizeDistributionDescriptor = exports.summarizeLPPositionReceipt = exports.summarizeCapitalCallState = exports.summarizeFundDefinition = exports.validateBondSettlementMatchesExpected = exports.validateBondSettlementDescriptor = exports.summarizeBondSettlementDescriptor = exports.verifyBondIssuanceHistory = exports.summarizeBondIssuanceState = exports.buildRedeemedBondIssuanceState = exports.validateBondStateTransition = exports.validateBondCrossChecks = exports.validateBondIssuanceState = exports.validateBondDefinition = exports.exportReceivableFinalityPayload = exports.exportReceivableEvidence = exports.verifyReceivableStateHistory = exports.verifyReceivableClosing = exports.prepareReceivableClosing = exports.verifyReceivableWriteOff = exports.prepareReceivableWriteOff = exports.verifyReceivableRepaymentClaim = exports.executeReceivableRepaymentClaim = exports.inspectReceivableRepaymentClaim = exports.prepareReceivableRepaymentClaim = exports.verifyReceivableRepayment = exports.prepareReceivableRepayment = exports.verifyReceivableFundingClaim = exports.executeReceivableFundingClaim = exports.inspectReceivableFundingClaim = exports.prepareReceivableFundingClaim = exports.verifyReceivableFunding = exports.prepareReceivableFunding = exports.loadReceivable = exports.verifyReceivable = exports.defineReceivable = exports.exportFundFinalityPayload = exports.exportFundEvidence = exports.verifyFundClosing = exports.prepareFundClosing = exports.verifyDistribution = exports.executeDistributionClaim = exports.inspectDistributionClaim = exports.reconcilePosition = exports.prepareDistribution = exports.verifyPositionReceiptChain = exports.verifyPositionReceipt = void 0;
|
|
19
|
-
exports.
|
|
20
|
-
exports.validatePolicyTransferDescriptor = exports.validatePolicyOutputDescriptor = exports.validatePolicyState = exports.summarizePolicyTransferDescriptor = exports.summarizePolicyOutputDescriptor = exports.summarizePolicyState = exports.exportPolicyEvidence = exports.verifyTransfer = void 0;
|
|
19
|
+
exports.verifyRwaDvpDeliveryClaim = exports.summarizeRwaDvpPurchase = exports.prepareRwaDvpRefundClaim = exports.prepareRwaDvpDeliveryClaim = exports.exportRwaDvpEvidence = exports.defineRwaDvpPurchase = exports.buildRwaDvpPaymentRequirements = exports.RWA_DVP_VERIFICATION_SCHEMA_VERSION = exports.RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION = exports.RWA_DVP_PURCHASE_SCHEMA_VERSION = exports.RWA_DVP_EVIDENCE_SCHEMA_VERSION = exports.RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION = exports.verifyReceivableStateHistoryValidation = exports.validateReceivableWriteOffTransition = exports.validateReceivableRepaymentTransition = exports.validateReceivableFundingTransition = exports.validateReceivableCrossChecks = exports.validateReceivableState = exports.validateReceivableRepaymentClaimDescriptor = exports.validateReceivableRepaymentClaimAgainstState = exports.validateReceivableFundingClaimDescriptor = exports.validateReceivableFundingClaimAgainstState = exports.validateReceivableDefinition = exports.validateReceivableClosingDescriptor = exports.validateReceivableClosingAgainstState = exports.summarizeReceivableState = exports.summarizeReceivableRepaymentClaimDescriptor = exports.summarizeReceivableFundingClaimDescriptor = exports.summarizeReceivableDefinition = exports.summarizeReceivableClosingDescriptor = exports.buildReceivableRepaymentClaimDescriptor = exports.buildReceivableFundingClaimDescriptor = exports.buildReceivableClosingDescriptor = exports.buildFundedReceivableState = exports.buildDefaultedReceivableState = exports.applyReceivableRepayment = exports.buildFundClosingDescriptor = exports.buildDistributionDescriptor = exports.applyDistributionsToReceipt = exports.applyDistributionToReceipt = exports.buildLPPositionReceipt = exports.buildRefundedCapitalCallState = exports.buildClaimedCapitalCallState = exports.validateClosingAgainstReceipt = exports.validateDistributionAgainstReceipt = exports.validateFundCrossChecks = exports.validateFundClosingDescriptor = exports.validateDistributionDescriptor = exports.validateLPPositionReceipt = exports.validateCapitalCallState = void 0;
|
|
20
|
+
exports.validatePolicyTransferDescriptor = exports.validatePolicyOutputDescriptor = exports.validatePolicyState = exports.summarizePolicyTransferDescriptor = exports.summarizePolicyOutputDescriptor = exports.summarizePolicyState = exports.exportPolicyEvidence = exports.verifyTransfer = exports.verifyState = exports.inspectTransfer = exports.executeTransfer = exports.prepareTransfer = exports.issue = exports.validatePolicyTemplateParams = exports.describePolicyTemplate = exports.validatePolicyTemplateManifest = exports.loadPolicyTemplateManifest = exports.listPolicyTemplates = exports.buildPolicyOutputDescriptor = exports.compilePolicyStateContract = exports.verifyRwaDvpRefundClaim = exports.verifyRwaDvpPaymentPset = void 0;
|
|
21
21
|
var SimplicityClient_1 = require("./client/SimplicityClient");
|
|
22
22
|
Object.defineProperty(exports, "createSimplicityClient", { enumerable: true, get: function () { return SimplicityClient_1.createSimplicityClient; } });
|
|
23
23
|
Object.defineProperty(exports, "SimplicityClient", { enumerable: true, get: function () { return SimplicityClient_1.SimplicityClient; } });
|
|
@@ -176,6 +176,21 @@ Object.defineProperty(exports, "validateReceivableFundingTransition", { enumerab
|
|
|
176
176
|
Object.defineProperty(exports, "validateReceivableRepaymentTransition", { enumerable: true, get: function () { return receivableValidation_1.validateReceivableRepaymentTransition; } });
|
|
177
177
|
Object.defineProperty(exports, "validateReceivableWriteOffTransition", { enumerable: true, get: function () { return receivableValidation_1.validateReceivableWriteOffTransition; } });
|
|
178
178
|
Object.defineProperty(exports, "verifyReceivableStateHistoryValidation", { enumerable: true, get: function () { return receivableValidation_1.verifyReceivableStateHistory; } });
|
|
179
|
+
var rwaDvp_1 = require("./domain/rwaDvp");
|
|
180
|
+
Object.defineProperty(exports, "RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION", { enumerable: true, get: function () { return rwaDvp_1.RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION; } });
|
|
181
|
+
Object.defineProperty(exports, "RWA_DVP_EVIDENCE_SCHEMA_VERSION", { enumerable: true, get: function () { return rwaDvp_1.RWA_DVP_EVIDENCE_SCHEMA_VERSION; } });
|
|
182
|
+
Object.defineProperty(exports, "RWA_DVP_PURCHASE_SCHEMA_VERSION", { enumerable: true, get: function () { return rwaDvp_1.RWA_DVP_PURCHASE_SCHEMA_VERSION; } });
|
|
183
|
+
Object.defineProperty(exports, "RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION", { enumerable: true, get: function () { return rwaDvp_1.RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION; } });
|
|
184
|
+
Object.defineProperty(exports, "RWA_DVP_VERIFICATION_SCHEMA_VERSION", { enumerable: true, get: function () { return rwaDvp_1.RWA_DVP_VERIFICATION_SCHEMA_VERSION; } });
|
|
185
|
+
Object.defineProperty(exports, "buildRwaDvpPaymentRequirements", { enumerable: true, get: function () { return rwaDvp_1.buildPaymentRequirements; } });
|
|
186
|
+
Object.defineProperty(exports, "defineRwaDvpPurchase", { enumerable: true, get: function () { return rwaDvp_1.definePurchase; } });
|
|
187
|
+
Object.defineProperty(exports, "exportRwaDvpEvidence", { enumerable: true, get: function () { return rwaDvp_1.exportEvidence; } });
|
|
188
|
+
Object.defineProperty(exports, "prepareRwaDvpDeliveryClaim", { enumerable: true, get: function () { return rwaDvp_1.prepareDeliveryClaim; } });
|
|
189
|
+
Object.defineProperty(exports, "prepareRwaDvpRefundClaim", { enumerable: true, get: function () { return rwaDvp_1.prepareRefundClaim; } });
|
|
190
|
+
Object.defineProperty(exports, "summarizeRwaDvpPurchase", { enumerable: true, get: function () { return rwaDvp_1.summarizePurchase; } });
|
|
191
|
+
Object.defineProperty(exports, "verifyRwaDvpDeliveryClaim", { enumerable: true, get: function () { return rwaDvp_1.verifyDeliveryClaim; } });
|
|
192
|
+
Object.defineProperty(exports, "verifyRwaDvpPaymentPset", { enumerable: true, get: function () { return rwaDvp_1.verifyPaymentPset; } });
|
|
193
|
+
Object.defineProperty(exports, "verifyRwaDvpRefundClaim", { enumerable: true, get: function () { return rwaDvp_1.verifyRefundClaim; } });
|
|
179
194
|
var policies_1 = require("./domain/policies");
|
|
180
195
|
Object.defineProperty(exports, "compilePolicyStateContract", { enumerable: true, get: function () { return policies_1.compilePolicyStateContract; } });
|
|
181
196
|
Object.defineProperty(exports, "buildPolicyOutputDescriptor", { enumerable: true, get: function () { return policies_1.buildPolicyOutputDescriptor; } });
|
package/dist/x402/index.js
CHANGED
|
@@ -306,7 +306,7 @@ async function settleLiquidX402Payment(rpc, input) {
|
|
|
306
306
|
if (mempool[0]?.allowed !== true) {
|
|
307
307
|
return {
|
|
308
308
|
success: false,
|
|
309
|
-
errorCode: mempool[0]
|
|
309
|
+
errorCode: mempoolRejectReason(mempool[0]),
|
|
310
310
|
rawTxHex: finalized.hex,
|
|
311
311
|
summaryHash: payload.summaryHash,
|
|
312
312
|
};
|
|
@@ -431,6 +431,12 @@ function normalizeAddressForComparison(value) {
|
|
|
431
431
|
function normalizeHexForComparison(value) {
|
|
432
432
|
return String(value ?? "").trim().toLowerCase().replace(/^0x/u, "");
|
|
433
433
|
}
|
|
434
|
+
function mempoolRejectReason(result) {
|
|
435
|
+
if (!result || typeof result !== "object")
|
|
436
|
+
return "mempool_rejected";
|
|
437
|
+
const raw = result;
|
|
438
|
+
return String(raw["reject-reason"] ?? raw.reject_reason ?? raw.error ?? "mempool_rejected").trim() || "mempool_rejected";
|
|
439
|
+
}
|
|
434
440
|
function coerceRequirements(value) {
|
|
435
441
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
436
442
|
throw new Error("requirements must be an object");
|