@hazbase/simplicity 0.4.0 → 0.4.1
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 +12 -0
- package/dist/domain/rwaDvp.js +1 -0
- package/dist/x402/index.d.ts +1 -0
- package/dist/x402/index.js +9 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -152,6 +152,18 @@ Main entrypoints:
|
|
|
152
152
|
Representative example:
|
|
153
153
|
- [show-receivable-business-flow.ts](./examples/show-receivable-business-flow.ts)
|
|
154
154
|
|
|
155
|
+
### RWA DvP and Liquid x402
|
|
156
|
+
|
|
157
|
+
Use `sdk.rwaDvp` when a purchase flow needs a Liquid PSET payment request,
|
|
158
|
+
delivery/refund claim descriptors, and an evidence bundle that ties the Liquid
|
|
159
|
+
payment and delivery to an external lock or allocation record.
|
|
160
|
+
|
|
161
|
+
For standard Liquid assets, `payment.asset` can be `"lbtc"` or `"usdt"`. If a
|
|
162
|
+
testnet issuer or deployment uses a different USDt asset id, set
|
|
163
|
+
`payment.asset: "usdt"` and pass the explicit `payment.assetId`; the generated
|
|
164
|
+
payment requirements will preserve that asset id instead of replacing it with
|
|
165
|
+
the SDK's default registry id.
|
|
166
|
+
|
|
155
167
|
## CLI and Confidence Commands
|
|
156
168
|
|
|
157
169
|
### Validation Surface
|
package/dist/domain/rwaDvp.js
CHANGED
|
@@ -77,6 +77,7 @@ function buildPaymentRequirements(_sdk, input) {
|
|
|
77
77
|
amountAtomic: input.purchase.payment.amountAtomic,
|
|
78
78
|
network: input.purchase.network,
|
|
79
79
|
asset: input.purchase.payment.asset,
|
|
80
|
+
assetId: input.purchase.payment.assetId,
|
|
80
81
|
description: input.description ?? "Hazbase RWA Liquid delivery-versus-payment",
|
|
81
82
|
mimeType: input.mimeType ?? "application/json",
|
|
82
83
|
maxTimeoutSeconds: input.maxTimeoutSeconds,
|
package/dist/x402/index.d.ts
CHANGED
package/dist/x402/index.js
CHANGED
|
@@ -77,6 +77,7 @@ function resolveLiquidX402Asset(asset, network = exports.LIQUID_X402_DEFAULT_NET
|
|
|
77
77
|
function buildLiquidX402Requirements(input) {
|
|
78
78
|
const network = normalizeNetwork(input.network ?? exports.LIQUID_X402_DEFAULT_NETWORK);
|
|
79
79
|
const asset = resolveLiquidX402Asset(input.asset ?? "usdt", network);
|
|
80
|
+
const assetId = resolveLiquidX402AssetId(input.assetId, asset);
|
|
80
81
|
const amountAtomic = normalizeAmountAtomic(input.amountAtomic);
|
|
81
82
|
const expiresAt = normalizeExpiresAt(input.expiresAt, input.maxTimeoutSeconds);
|
|
82
83
|
const description = String(input.description ?? "").trim() || "Unlock resource";
|
|
@@ -100,11 +101,11 @@ function buildLiquidX402Requirements(input) {
|
|
|
100
101
|
mimeType,
|
|
101
102
|
payTo,
|
|
102
103
|
maxTimeoutSeconds,
|
|
103
|
-
asset:
|
|
104
|
+
asset: assetId,
|
|
104
105
|
extra: {
|
|
105
106
|
paymentRequestId,
|
|
106
107
|
asset: asset.key,
|
|
107
|
-
assetId
|
|
108
|
+
assetId,
|
|
108
109
|
decimals: asset.decimals,
|
|
109
110
|
expiresAt,
|
|
110
111
|
feeAsset: "lbtc",
|
|
@@ -585,6 +586,12 @@ function isLiquidAssetAlias(input) {
|
|
|
585
586
|
value === "usdt-liquid" ||
|
|
586
587
|
value === "tether";
|
|
587
588
|
}
|
|
589
|
+
function resolveLiquidX402AssetId(input, asset) {
|
|
590
|
+
const value = String(input ?? "").trim();
|
|
591
|
+
if (!value)
|
|
592
|
+
return asset.assetId;
|
|
593
|
+
return isLiquidAssetAlias(value) ? asset.assetId : value;
|
|
594
|
+
}
|
|
588
595
|
function normalizeAmountAtomic(input) {
|
|
589
596
|
const raw = typeof input === "bigint" ? input.toString() : String(input ?? "").trim();
|
|
590
597
|
if (!/^\d+$/u.test(raw))
|