@voltro/plugin-economy 0.0.0-stage → 0.87.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/CHANGELOG.md +24329 -0
- package/LICENSE +61 -0
- package/README.md +2719 -2
- package/SECURITY.md +56 -0
- package/THIRD-PARTY-NOTICES.md +9189 -0
- package/dist/amount.js +21 -0
- package/dist/appleIap.server.js +263 -0
- package/dist/appleIapNotifications.server.js +163 -0
- package/dist/appleIapTrust.server.js +31 -0
- package/dist/bundleValue.server.js +113 -0
- package/dist/canonicalDataJson.js +11 -0
- package/dist/capture.js +54 -0
- package/dist/codePort.fixture.js +124 -0
- package/dist/codeStore.server.js +440 -0
- package/dist/codeTables.entity.js +44 -0
- package/dist/codes.d.ts +150 -0
- package/dist/codes.js +83 -0
- package/dist/components.d.ts +397 -0
- package/dist/components.js +284 -0
- package/dist/consistency.server.js +116 -0
- package/dist/containerStore.server.js +688 -0
- package/dist/containerStore.testFixtures.js +76 -0
- package/dist/containerTables.entity.js +46 -0
- package/dist/containers.d.ts +311 -0
- package/dist/containers.fixture.js +129 -0
- package/dist/containers.js +215 -0
- package/dist/containers.server.js +40 -0
- package/dist/containersPort.fixture.js +75 -0
- package/dist/currency.js +33 -0
- package/dist/declarationFixtures.js +62 -0
- package/dist/economy-app/events/economy.refundReversed.event.ts +1 -0
- package/dist/economy-app/events/economy.refunded.event.ts +1 -0
- package/dist/economyPort.fixture.js +125 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +22 -0
- package/dist/events.d.ts +46 -0
- package/dist/events.js +1 -0
- package/dist/googleIap.server.js +392 -0
- package/dist/googleIapNotifications.server.js +131 -0
- package/dist/googleIapSubscription.server.js +184 -0
- package/dist/iap.d.ts +309 -0
- package/dist/iap.js +304 -0
- package/dist/iap.testFixtures.js +145 -0
- package/dist/iapAccountTables.entity.js +40 -0
- package/dist/iapAccounts.server.js +201 -0
- package/dist/iapBinding.server.js +524 -0
- package/dist/iapCheckout.server.js +98 -0
- package/dist/iapCompletion.server.js +56 -0
- package/dist/iapCurrentState.server.js +108 -0
- package/dist/iapCurrentState.testFixtures.js +23 -0
- package/dist/iapCurrentStatePort.fixture.js +64 -0
- package/dist/iapEntitlements.d.ts +79 -0
- package/dist/iapEntitlements.js +58 -0
- package/dist/iapEntitlements.server.js +49 -0
- package/dist/iapEntitlementsBinding.server.js +106 -0
- package/dist/iapEntitlementsPort.fixture.js +81 -0
- package/dist/iapInstalledEntitlements.testFixtures.js +76 -0
- package/dist/iapInstalledNotifications.testFixtures.js +94 -0
- package/dist/iapInventoryRefunds.server.js +262 -0
- package/dist/iapNotificationCustodyPort.fixture.js +68 -0
- package/dist/iapNotificationPort.fixture.js +74 -0
- package/dist/iapNotificationProcessor.server.js +135 -0
- package/dist/iapNotificationProcessor.testFixtures.js +64 -0
- package/dist/iapNotificationProcessorPort.fixture.js +56 -0
- package/dist/iapNotificationSchedule.server.js +70 -0
- package/dist/iapNotificationStore.server.js +353 -0
- package/dist/iapNotificationStore.testFixtures.js +32 -0
- package/dist/iapNotificationTables.entity.js +49 -0
- package/dist/iapNotificationTarget.server.js +37 -0
- package/dist/iapNotificationTarget.testFixtures.js +30 -0
- package/dist/iapNotifications.d.ts +644 -0
- package/dist/iapNotifications.js +6 -0
- package/dist/iapNotifications.server.js +96 -0
- package/dist/iapNotificationsBinding.server.js +233 -0
- package/dist/iapNotificationsSystemPort.fixture.js +51 -0
- package/dist/iapPlugin.testFixtures.js +60 -0
- package/dist/iapPort.fixture.js +75 -0
- package/dist/iapProviderCapture.server.js +18 -0
- package/dist/iapRecovery.d.ts +146 -0
- package/dist/iapRecovery.js +90 -0
- package/dist/iapRefundEventDelivery.server.js +83 -0
- package/dist/iapRefundEvents.js +45 -0
- package/dist/iapRefundEventsPort.fixture.js +60 -0
- package/dist/iapRefundPort.fixture.js +55 -0
- package/dist/iapRefundTables.entity.js +56 -0
- package/dist/iapRefunds.d.ts +755 -0
- package/dist/iapRefunds.js +6 -0
- package/dist/iapRefunds.server.js +554 -0
- package/dist/iapRefunds.testFixtures.js +65 -0
- package/dist/iapSpendAdmission.server.js +99 -0
- package/dist/iapStore.server.js +741 -0
- package/dist/iapStore.testFixtures.js +128 -0
- package/dist/iapTables.entity.js +81 -0
- package/dist/iapVerification.server.js +121 -0
- package/dist/index.d.ts +2984 -0
- package/dist/index.js +15 -0
- package/dist/intentionRecovery.js +134 -0
- package/dist/ledger.js +78 -0
- package/dist/loyalty.d.ts +274 -0
- package/dist/loyalty.fixture.js +93 -0
- package/dist/loyalty.js +312 -0
- package/dist/loyaltyBinding.server.js +204 -0
- package/dist/loyaltyPort.fixture.js +87 -0
- package/dist/loyaltyShopSource.server.js +91 -0
- package/dist/loyaltyStore.server.js +553 -0
- package/dist/loyaltyStore.testFixtures.js +83 -0
- package/dist/loyaltyTables.entity.js +50 -0
- package/dist/offerMerchandising.fixture.js +115 -0
- package/dist/offerMerchandising.js +283 -0
- package/dist/offerPolicies.d.ts +441 -0
- package/dist/offerPolicies.fixture.js +54 -0
- package/dist/offerPolicies.js +268 -0
- package/dist/piggyBanks.d.ts +272 -0
- package/dist/piggyBanks.fixture.js +71 -0
- package/dist/piggyBanks.js +201 -0
- package/dist/piggyBinding.server.js +205 -0
- package/dist/piggyPort.fixture.js +73 -0
- package/dist/piggyStore.server.js +611 -0
- package/dist/piggyStore.testFixtures.js +98 -0
- package/dist/piggyTables.entity.js +41 -0
- package/dist/plugin.js +1048 -0
- package/dist/port.js +13 -0
- package/dist/price.d.ts +99 -0
- package/dist/price.js +144 -0
- package/dist/purchaseRecovery.js +56 -0
- package/dist/reports.server.js +115 -0
- package/dist/rpc.d.ts +3201 -0
- package/dist/rpc.js +1201 -0
- package/dist/sanctionsTradeAuthority.server.js +80 -0
- package/dist/server.d.ts +3856 -0
- package/dist/server.js +43 -0
- package/dist/shop.d.ts +279 -0
- package/dist/shop.js +196 -0
- package/dist/shop.testFixtures.js +114 -0
- package/dist/shopPort.fixture.js +72 -0
- package/dist/shopPresentation.js +68 -0
- package/dist/shopStore.server.js +624 -0
- package/dist/shopTables.entity.js +63 -0
- package/dist/shopUiCopy.js +57 -0
- package/dist/spendLimits.d.ts +140 -0
- package/dist/spendLimits.fixture.js +53 -0
- package/dist/spendLimits.js +155 -0
- package/dist/spendLimitsPort.fixture.js +120 -0
- package/dist/subscriptionBinding.server.js +211 -0
- package/dist/subscriptionStore.server.js +643 -0
- package/dist/subscriptionStore.testFixtures.js +72 -0
- package/dist/subscriptionTables.entity.js +37 -0
- package/dist/subscriptions.d.ts +394 -0
- package/dist/subscriptions.fixture.js +97 -0
- package/dist/subscriptions.js +213 -0
- package/dist/subscriptionsPort.fixture.js +76 -0
- package/dist/systemFixtures.js +89 -0
- package/dist/tables.entity.js +83 -0
- package/dist/testing.d.ts +4615 -0
- package/dist/testing.js +29 -0
- package/dist/tradeAuthority.server.js +172 -0
- package/dist/tradeBinding.server.js +201 -0
- package/dist/tradeComponents.js +342 -0
- package/dist/tradeEscrow.server.js +232 -0
- package/dist/tradeEscrow.testFixtures.js +133 -0
- package/dist/tradeExpiry.server.js +43 -0
- package/dist/tradeRecovery.js +48 -0
- package/dist/tradeStore.server.js +750 -0
- package/dist/tradeStore.testFixtures.js +73 -0
- package/dist/tradeTables.entity.js +66 -0
- package/dist/tradeUiCopy.js +79 -0
- package/dist/trades.d.ts +246 -0
- package/dist/trades.fixture.js +103 -0
- package/dist/trades.js +289 -0
- package/dist/tradesPort.fixture.js +94 -0
- package/dist/walletEscrow.js +106 -0
- package/dist/walletEscrow.server.js +376 -0
- package/dist/walletKeys.server.js +5 -0
- package/dist/walletStore.js +571 -0
- package/dist/web.d.ts +2257 -0
- package/dist/web.js +9 -0
- package/package.json +161 -4
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { dataList as e } from "./capture.js";
|
|
2
|
+
import { captureShopOrderReceipt as t } from "./shop.js";
|
|
3
|
+
import { captureShopOfferView as n, shopOfferAvailable as r, shopPurchaseTerms as i } from "./shopPresentation.js";
|
|
4
|
+
import { shopUiCopy as a } from "./shopUiCopy.js";
|
|
5
|
+
import { tradeUiCopy as o } from "./tradeUiCopy.js";
|
|
6
|
+
import { TradeAcceptDialog as s, TradeIntentionRecovery as c, TradeList as l, TradeTerms as u } from "./tradeComponents.js";
|
|
7
|
+
import { useEffect as d, useId as f, useRef as p } from "react";
|
|
8
|
+
import { Button as m, Dialog as h, DialogDescription as g, DialogFooter as _, DialogHeader as v, DialogTitle as y } from "@voltro/ui-shadcn";
|
|
9
|
+
import { jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
10
|
+
//#region src/components.tsx
|
|
11
|
+
var S = (e) => e.copy ?? a[e.locale ?? "en"], C = (e, t, n) => e.kind === "free" ? t.free : `${e.amount} ${n?.(e.currency) ?? e.currency}`, w = (e) => {
|
|
12
|
+
let t = S(e), a, o;
|
|
13
|
+
try {
|
|
14
|
+
a = n(e.view), o = r(a, e.at);
|
|
15
|
+
} catch {
|
|
16
|
+
return /* @__PURE__ */ b("article", { children: /* @__PURE__ */ b("p", {
|
|
17
|
+
role: "alert",
|
|
18
|
+
children: t.invalid
|
|
19
|
+
}) });
|
|
20
|
+
}
|
|
21
|
+
let s = a.price.kind === "virtual" ? a.price.options : a.price.kind === "mixed" ? a.price.virtual : [];
|
|
22
|
+
return /* @__PURE__ */ x("article", {
|
|
23
|
+
className: "flex min-w-0 flex-col gap-4 rounded-xl border border-border p-5",
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ b("h3", {
|
|
26
|
+
className: "break-words text-lg font-semibold",
|
|
27
|
+
children: e.title(a.offer.titleKey)
|
|
28
|
+
}),
|
|
29
|
+
e.renderRewards ? e.renderRewards(a) : /* @__PURE__ */ x("ul", {
|
|
30
|
+
className: "space-y-1 text-sm",
|
|
31
|
+
children: [a.offer.items.map((e) => /* @__PURE__ */ x("li", { children: [
|
|
32
|
+
e.qty,
|
|
33
|
+
" × ",
|
|
34
|
+
e.itemId
|
|
35
|
+
] }, e.itemId)), a.offer.currencies.map((t) => /* @__PURE__ */ x("li", {
|
|
36
|
+
className: "tabular-nums",
|
|
37
|
+
children: [
|
|
38
|
+
t.amount,
|
|
39
|
+
" ",
|
|
40
|
+
e.currencyLabel?.(t.currency) ?? t.currency
|
|
41
|
+
]
|
|
42
|
+
}, t.currency))]
|
|
43
|
+
}),
|
|
44
|
+
a.offer.oneTime ? /* @__PURE__ */ b("p", {
|
|
45
|
+
className: "text-sm text-muted-foreground",
|
|
46
|
+
children: t.oneTime
|
|
47
|
+
}) : null,
|
|
48
|
+
o && a.offer.until !== null ? /* @__PURE__ */ b("p", {
|
|
49
|
+
className: "text-sm tabular-nums",
|
|
50
|
+
children: /* @__PURE__ */ b("time", {
|
|
51
|
+
dateTime: new Date(a.offer.until).toISOString(),
|
|
52
|
+
children: t.endsIn(Math.max(0, Math.ceil((a.offer.until - e.at) / 1e3)))
|
|
53
|
+
})
|
|
54
|
+
}) : null,
|
|
55
|
+
o ? null : /* @__PURE__ */ b("p", {
|
|
56
|
+
className: "text-sm text-muted-foreground",
|
|
57
|
+
children: t.closed
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ x("div", {
|
|
60
|
+
className: "mt-auto flex flex-col gap-3",
|
|
61
|
+
children: [a.price.kind === "free" ? /* @__PURE__ */ x(m, {
|
|
62
|
+
type: "button",
|
|
63
|
+
"aria-disabled": !o || e.busy,
|
|
64
|
+
className: "h-auto min-h-11 whitespace-normal",
|
|
65
|
+
onClick: () => {
|
|
66
|
+
o && !e.busy && e.onSelect(a, void 0);
|
|
67
|
+
},
|
|
68
|
+
children: [
|
|
69
|
+
t.choose,
|
|
70
|
+
" · ",
|
|
71
|
+
t.free
|
|
72
|
+
]
|
|
73
|
+
}) : s.map((n) => {
|
|
74
|
+
let r = i(a, {
|
|
75
|
+
offerId: a.offer.id,
|
|
76
|
+
offerVersion: a.offer.version,
|
|
77
|
+
offerDigest: a.offerDigest,
|
|
78
|
+
requestId: "display",
|
|
79
|
+
currency: n.currency
|
|
80
|
+
});
|
|
81
|
+
return /* @__PURE__ */ x("div", {
|
|
82
|
+
className: "space-y-2",
|
|
83
|
+
children: [r.discountPercent > 0 ? /* @__PURE__ */ b("p", {
|
|
84
|
+
className: "text-sm text-muted-foreground",
|
|
85
|
+
children: t.discount(r.discountPercent)
|
|
86
|
+
}) : null, /* @__PURE__ */ x(m, {
|
|
87
|
+
type: "button",
|
|
88
|
+
"aria-disabled": !o || e.busy,
|
|
89
|
+
className: "h-auto min-h-11 w-full whitespace-normal",
|
|
90
|
+
onClick: () => {
|
|
91
|
+
o && !e.busy && e.onSelect(a, n.currency);
|
|
92
|
+
},
|
|
93
|
+
children: [
|
|
94
|
+
t.choose,
|
|
95
|
+
" · ",
|
|
96
|
+
C(r.current, t, e.currencyLabel)
|
|
97
|
+
]
|
|
98
|
+
})]
|
|
99
|
+
}, n.currency);
|
|
100
|
+
}), a.price.kind === "real" ? /* @__PURE__ */ b("p", {
|
|
101
|
+
className: "text-sm text-muted-foreground",
|
|
102
|
+
children: t.providersMissing
|
|
103
|
+
}) : null]
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
});
|
|
107
|
+
}, T = (t) => {
|
|
108
|
+
let r = S(t), i = f(), a, o = !1;
|
|
109
|
+
try {
|
|
110
|
+
a = t.source.data === void 0 ? void 0 : e(t.source.data, 256).map((e) => n(e)), o = a !== void 0 && new Set(a.map((e) => e.offer.id)).size !== a.length;
|
|
111
|
+
} catch {
|
|
112
|
+
o = !0;
|
|
113
|
+
}
|
|
114
|
+
return /* @__PURE__ */ x("section", {
|
|
115
|
+
"aria-labelledby": i,
|
|
116
|
+
className: "min-w-0 space-y-5",
|
|
117
|
+
children: [/* @__PURE__ */ b("h2", {
|
|
118
|
+
id: i,
|
|
119
|
+
className: "text-2xl font-semibold",
|
|
120
|
+
children: r.shop
|
|
121
|
+
}), t.source.error !== void 0 || o ? /* @__PURE__ */ b("p", {
|
|
122
|
+
role: "alert",
|
|
123
|
+
children: r.unavailable
|
|
124
|
+
}) : t.source.loading || a === void 0 ? /* @__PURE__ */ b("p", {
|
|
125
|
+
role: "status",
|
|
126
|
+
children: r.loading
|
|
127
|
+
}) : a.length === 0 ? /* @__PURE__ */ b("p", { children: r.empty }) : /* @__PURE__ */ b("div", {
|
|
128
|
+
className: "grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3",
|
|
129
|
+
children: a.map((e) => /* @__PURE__ */ b(w, {
|
|
130
|
+
view: e,
|
|
131
|
+
at: t.at,
|
|
132
|
+
busy: t.busy,
|
|
133
|
+
locale: t.locale,
|
|
134
|
+
copy: t.copy,
|
|
135
|
+
title: t.title,
|
|
136
|
+
currencyLabel: t.currencyLabel,
|
|
137
|
+
renderRewards: t.renderRewards,
|
|
138
|
+
onSelect: t.onSelect
|
|
139
|
+
}, e.offer.id))
|
|
140
|
+
})]
|
|
141
|
+
});
|
|
142
|
+
}, E = (e) => {
|
|
143
|
+
let t = S(e);
|
|
144
|
+
return e.reference ? /* @__PURE__ */ x("section", {
|
|
145
|
+
"aria-label": t.retry,
|
|
146
|
+
className: "min-w-0 space-y-4 border-y border-border py-5",
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ b("p", {
|
|
149
|
+
role: "status",
|
|
150
|
+
className: "max-w-prose text-sm leading-relaxed",
|
|
151
|
+
children: e.busy ? t.sending : t.uncertain
|
|
152
|
+
}),
|
|
153
|
+
/* @__PURE__ */ x("dl", {
|
|
154
|
+
className: "space-y-2 text-sm",
|
|
155
|
+
children: [/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", {
|
|
156
|
+
className: "text-muted-foreground",
|
|
157
|
+
children: t.originalOffer
|
|
158
|
+
}), /* @__PURE__ */ b("dd", {
|
|
159
|
+
className: "break-all",
|
|
160
|
+
children: e.reference.request.offerId
|
|
161
|
+
})] }), /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", {
|
|
162
|
+
className: "text-muted-foreground",
|
|
163
|
+
children: t.originalRequest
|
|
164
|
+
}), /* @__PURE__ */ b("dd", {
|
|
165
|
+
className: "break-all font-mono",
|
|
166
|
+
children: e.reference.request.requestId
|
|
167
|
+
})] })]
|
|
168
|
+
}),
|
|
169
|
+
e.error === void 0 ? null : /* @__PURE__ */ b("p", {
|
|
170
|
+
role: "alert",
|
|
171
|
+
children: t.uncertain
|
|
172
|
+
}),
|
|
173
|
+
/* @__PURE__ */ b(m, {
|
|
174
|
+
type: "button",
|
|
175
|
+
"aria-disabled": e.busy,
|
|
176
|
+
className: "h-auto min-h-11 whitespace-normal",
|
|
177
|
+
onClick: () => {
|
|
178
|
+
!e.busy && e.reference && e.onRetry(e.reference.request);
|
|
179
|
+
},
|
|
180
|
+
children: t.retry
|
|
181
|
+
})
|
|
182
|
+
]
|
|
183
|
+
}) : null;
|
|
184
|
+
}, D = (e) => {
|
|
185
|
+
let n = S(e), a = p(null), o = f(), s = f();
|
|
186
|
+
d(() => {
|
|
187
|
+
let t = a.current;
|
|
188
|
+
t && (e.open && !t.open ? t.showModal() : !e.open && t.open && t.close());
|
|
189
|
+
}, [e.open]);
|
|
190
|
+
let c;
|
|
191
|
+
try {
|
|
192
|
+
c = i(e.view, e.intention), r(e.view, e.at) || (c = void 0);
|
|
193
|
+
} catch {
|
|
194
|
+
c = void 0;
|
|
195
|
+
}
|
|
196
|
+
let l;
|
|
197
|
+
if (e.receipt !== void 0) try {
|
|
198
|
+
let n = t(e.receipt);
|
|
199
|
+
c && n.offerId === c.request.offerId && n.offerVersion === c.request.offerVersion && n.offerDigest === c.request.offerDigest && n.quantity === c.request.qty && (c.maximum.kind === "free" ? n.pricePaid.kind === "free" : n.pricePaid.kind === "virtual" && n.pricePaid.currency === c.maximum.currency && BigInt(n.pricePaid.amount) <= BigInt(c.maximum.amount)) && (l = n);
|
|
200
|
+
} catch {
|
|
201
|
+
l = void 0;
|
|
202
|
+
}
|
|
203
|
+
let u = c !== void 0 && !e.busy && e.error === void 0 && e.receipt === void 0;
|
|
204
|
+
return /* @__PURE__ */ x(h, {
|
|
205
|
+
ref: a,
|
|
206
|
+
"aria-labelledby": o,
|
|
207
|
+
"aria-describedby": s,
|
|
208
|
+
className: "max-h-[calc(100dvh-2rem)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto motion-reduce:animate-none",
|
|
209
|
+
onCancel: (t) => {
|
|
210
|
+
t.preventDefault(), e.onClose();
|
|
211
|
+
},
|
|
212
|
+
children: [
|
|
213
|
+
/* @__PURE__ */ x(v, { children: [/* @__PURE__ */ b(y, {
|
|
214
|
+
id: o,
|
|
215
|
+
children: e.title(e.view.offer.titleKey)
|
|
216
|
+
}), /* @__PURE__ */ b(g, {
|
|
217
|
+
id: s,
|
|
218
|
+
children: n.pricePolicy
|
|
219
|
+
})] }),
|
|
220
|
+
c ? /* @__PURE__ */ x("dl", {
|
|
221
|
+
className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-x-4 gap-y-3 text-sm",
|
|
222
|
+
children: [
|
|
223
|
+
/* @__PURE__ */ b("dt", { children: n.quantity }),
|
|
224
|
+
/* @__PURE__ */ b("dd", {
|
|
225
|
+
className: "tabular-nums",
|
|
226
|
+
children: c.request.qty
|
|
227
|
+
}),
|
|
228
|
+
/* @__PURE__ */ b("dt", { children: n.currentPrice }),
|
|
229
|
+
/* @__PURE__ */ b("dd", {
|
|
230
|
+
className: "break-words text-right tabular-nums",
|
|
231
|
+
children: C(c.current, n, e.currencyLabel)
|
|
232
|
+
}),
|
|
233
|
+
/* @__PURE__ */ b("dt", {
|
|
234
|
+
className: "font-medium",
|
|
235
|
+
children: n.maximumPrice
|
|
236
|
+
}),
|
|
237
|
+
/* @__PURE__ */ b("dd", {
|
|
238
|
+
className: "break-words text-right font-medium tabular-nums",
|
|
239
|
+
children: C(c.maximum, n, e.currencyLabel)
|
|
240
|
+
})
|
|
241
|
+
]
|
|
242
|
+
}) : /* @__PURE__ */ b("p", {
|
|
243
|
+
role: "alert",
|
|
244
|
+
children: n.invalid
|
|
245
|
+
}),
|
|
246
|
+
e.busy ? /* @__PURE__ */ b("p", {
|
|
247
|
+
role: "status",
|
|
248
|
+
className: "mt-4 text-sm",
|
|
249
|
+
children: n.sending
|
|
250
|
+
}) : null,
|
|
251
|
+
e.error === void 0 ? null : /* @__PURE__ */ b("p", {
|
|
252
|
+
role: "alert",
|
|
253
|
+
className: "mt-4 text-sm",
|
|
254
|
+
children: n.uncertain
|
|
255
|
+
}),
|
|
256
|
+
l ? /* @__PURE__ */ b("p", {
|
|
257
|
+
role: "status",
|
|
258
|
+
className: "mt-4 font-medium",
|
|
259
|
+
children: n.complete
|
|
260
|
+
}) : e.receipt === void 0 ? null : /* @__PURE__ */ b("p", {
|
|
261
|
+
role: "alert",
|
|
262
|
+
className: "mt-4",
|
|
263
|
+
children: n.invalid
|
|
264
|
+
}),
|
|
265
|
+
/* @__PURE__ */ x(_, { children: [/* @__PURE__ */ b(m, {
|
|
266
|
+
type: "button",
|
|
267
|
+
variant: "outline",
|
|
268
|
+
className: "h-auto min-h-11 whitespace-normal",
|
|
269
|
+
onClick: e.onClose,
|
|
270
|
+
children: n.cancel
|
|
271
|
+
}), /* @__PURE__ */ b(m, {
|
|
272
|
+
type: "button",
|
|
273
|
+
"aria-disabled": !u,
|
|
274
|
+
className: "h-auto min-h-11 whitespace-normal",
|
|
275
|
+
onClick: () => {
|
|
276
|
+
u && c && e.onConfirm(c.request);
|
|
277
|
+
},
|
|
278
|
+
children: n.confirm
|
|
279
|
+
})] })
|
|
280
|
+
]
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
//#endregion
|
|
284
|
+
export { w as OfferCard, D as PurchaseDialog, E as PurchaseRecovery, T as ShopGrid, s as TradeAcceptDialog, c as TradeIntentionRecovery, l as TradeList, u as TradeTerms, n as captureShopOfferView, r as shopOfferAvailable, i as shopPurchaseTerms, a as shopUiCopy, o as tradeUiCopy };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { EconomyError as e, economyError as t } from "./errors.js";
|
|
2
|
+
import { captureBoundMethods as n, dataList as r, dataObject as i, identifier as a } from "./capture.js";
|
|
3
|
+
import { nonNegativeAmount as o } from "./amount.js";
|
|
4
|
+
import { captureAccount as s, economyAccountKey as c } from "./ledger.js";
|
|
5
|
+
import { economyLedgerTable as l, economyWalletsTable as u } from "./tables.entity.js";
|
|
6
|
+
import { economyWalletKey as d, readEconomyTransferEvidence as f } from "./walletStore.js";
|
|
7
|
+
import { Effect as p } from "effect";
|
|
8
|
+
import { systemSubject as m } from "@voltro/protocol";
|
|
9
|
+
import { eq as h, queryFor as g } from "@voltro/database";
|
|
10
|
+
import { defineSchedule as _ } from "@voltro/runtime";
|
|
11
|
+
//#region src/consistency.server.ts
|
|
12
|
+
var v = (e) => {
|
|
13
|
+
let n = i(e, [
|
|
14
|
+
"tenantId",
|
|
15
|
+
"maxLedgerRows",
|
|
16
|
+
"maxWallets"
|
|
17
|
+
]), r = n.maxLedgerRows ?? 1e4, o = n.maxWallets ?? 1e3;
|
|
18
|
+
if (typeof r != "number" || !Number.isSafeInteger(r) || r < 2 || r > 1e5 || typeof o != "number" || !Number.isSafeInteger(o) || o < 1 || o > 1e4) throw t("invalid_input");
|
|
19
|
+
return Object.freeze({
|
|
20
|
+
tenantId: a(n.tenantId),
|
|
21
|
+
maxLedgerRows: r,
|
|
22
|
+
maxWallets: o
|
|
23
|
+
});
|
|
24
|
+
}, y = (n, i, m, _, y) => {
|
|
25
|
+
try {
|
|
26
|
+
let b = v(y), x = structuredClone(_), S = new Set(r(m, 128).map((e) => a(e)));
|
|
27
|
+
if (S.size !== m.length) throw t("invalid_input");
|
|
28
|
+
if (x.type !== "system") throw t("forbidden");
|
|
29
|
+
return p.gen(function* () {
|
|
30
|
+
let r = yield* p.tryPromise({
|
|
31
|
+
try: () => n.transactional(async (e) => {
|
|
32
|
+
let n = await e.query(g(l).where(h("tenantId", b.tenantId)).orderBy("id", "asc").limit(b.maxLedgerRows + 1).descriptor), r = await e.query(g(u).where(h("tenantId", b.tenantId)).orderBy("id", "asc").limit(b.maxWallets + 1).descriptor);
|
|
33
|
+
if (n.length > b.maxLedgerRows || r.length > b.maxWallets) throw t("limit_exceeded");
|
|
34
|
+
let i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), p = (e, n, r) => {
|
|
35
|
+
if (!S.has(e)) throw t("invalid_currency");
|
|
36
|
+
let i = s({
|
|
37
|
+
kind: "wallet",
|
|
38
|
+
ownerKind: n,
|
|
39
|
+
ownerId: r
|
|
40
|
+
});
|
|
41
|
+
if (i.kind !== "wallet") throw t("invalid_record");
|
|
42
|
+
if (o.set(JSON.stringify([c(i), e]), {
|
|
43
|
+
account: i,
|
|
44
|
+
currency: e
|
|
45
|
+
}), o.size > b.maxWallets) throw t("limit_exceeded");
|
|
46
|
+
};
|
|
47
|
+
for (let e of n) {
|
|
48
|
+
let t = a(e.currency), n = a(e.txId), r = i.get(t);
|
|
49
|
+
r || (r = /* @__PURE__ */ new Set(), i.set(t, r)), r.add(n);
|
|
50
|
+
}
|
|
51
|
+
for (let [t, n] of i) {
|
|
52
|
+
let r = await f(e, b.tenantId, [...n], t);
|
|
53
|
+
for (let { pair: e } of r.values()) for (let n of e) n.accountKind === "wallet" && n.ownerId !== null && p(t, n.ownerKind, n.ownerId);
|
|
54
|
+
}
|
|
55
|
+
for (let e of r) {
|
|
56
|
+
let n = a(e.currency), r = s({
|
|
57
|
+
kind: "wallet",
|
|
58
|
+
ownerKind: e.ownerKind,
|
|
59
|
+
ownerId: e.ownerId
|
|
60
|
+
});
|
|
61
|
+
if (e.tenantId !== b.tenantId || e.id !== d(b.tenantId, r, n)) throw t("invalid_record");
|
|
62
|
+
p(n, e.ownerKind, e.ownerId);
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
accounts: [...o.entries()].sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([, e]) => e),
|
|
66
|
+
ledgerRows: n.length
|
|
67
|
+
};
|
|
68
|
+
}),
|
|
69
|
+
catch: (n) => n instanceof e ? n : t("unavailable")
|
|
70
|
+
}), m = 0, _ = 0;
|
|
71
|
+
for (let { currency: n, account: a } of r.accounts) {
|
|
72
|
+
let r = yield* i.auditWallet(x, b.tenantId, a, n);
|
|
73
|
+
yield* p.try({
|
|
74
|
+
try: () => {
|
|
75
|
+
let e = o(r.balance), i = o(r.ledgerBalance);
|
|
76
|
+
if (r.currency !== n || typeof r.matches != "boolean" || r.matches !== (e === i) || !Number.isSafeInteger(r.ledgerRows) || r.ledgerRows < 0) throw t("invalid_record");
|
|
77
|
+
},
|
|
78
|
+
catch: (n) => n instanceof e ? n : t("invalid_record")
|
|
79
|
+
}), m++, r.matches || _++;
|
|
80
|
+
}
|
|
81
|
+
return Object.freeze({
|
|
82
|
+
checked: m,
|
|
83
|
+
mismatches: _,
|
|
84
|
+
matches: _ === 0,
|
|
85
|
+
ledgerRows: r.ledgerRows
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
} catch (n) {
|
|
89
|
+
return p.fail(n instanceof e ? n : t("invalid_input"));
|
|
90
|
+
}
|
|
91
|
+
}, b = (e) => {
|
|
92
|
+
let r = i(e, [
|
|
93
|
+
"tenantId",
|
|
94
|
+
"maxLedgerRows",
|
|
95
|
+
"maxWallets",
|
|
96
|
+
"runner",
|
|
97
|
+
"name",
|
|
98
|
+
"cron",
|
|
99
|
+
"timezone"
|
|
100
|
+
]), o = v({
|
|
101
|
+
tenantId: r.tenantId,
|
|
102
|
+
...r.maxLedgerRows === void 0 ? {} : { maxLedgerRows: r.maxLedgerRows },
|
|
103
|
+
...r.maxWallets === void 0 ? {} : { maxWallets: r.maxWallets }
|
|
104
|
+
}), s = n(r.runner, ["checkConsistency"]), c = a(r.name ?? "economy.checkConsistency"), l = r.cron ?? "0 2 * * *", u = r.timezone ?? "UTC";
|
|
105
|
+
if (typeof l != "string" || l.length > 120 || typeof u != "string" || u.length > 120) throw t("invalid_input");
|
|
106
|
+
return _({
|
|
107
|
+
name: c,
|
|
108
|
+
cron: l,
|
|
109
|
+
timezone: u,
|
|
110
|
+
handler: () => p.gen(function* () {
|
|
111
|
+
if (!(yield* s.checkConsistency(m("economy.consistency.schedule"), o)).matches) return yield* p.fail(t("conflict"));
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
//#endregion
|
|
116
|
+
export { v as captureEconomyConsistencyInput, y as checkSqlEconomyConsistency, b as economyConsistencySchedule };
|