@goodwidget/ai-credits-widget 0.1.5 → 0.1.6
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/{chunk-YIXMIOVW.js → chunk-QNDSSO77.js} +1 -1
- package/dist/{chunk-5ABKU4SW.js → chunk-V7CAVLPS.js} +2571 -731
- package/dist/chunk-V7CAVLPS.js.map +1 -0
- package/dist/element.cjs +2535 -740
- package/dist/element.cjs.map +1 -1
- package/dist/element.js +1 -1
- package/dist/index.cjs +2554 -739
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -4
- package/dist/index.d.ts +42 -4
- package/dist/index.js +22 -2
- package/dist/mocked/index.cjs +2606 -808
- package/dist/mocked/index.cjs.map +1 -1
- package/dist/mocked/index.d.cts +5 -2
- package/dist/mocked/index.d.ts +5 -2
- package/dist/mocked/index.js +7 -4
- package/dist/mocked/index.js.map +1 -1
- package/dist/register.cjs +2597 -760
- package/dist/register.cjs.map +1 -1
- package/dist/{widgetRuntimeContract-BPILUGC4.d.cts → widgetRuntimeContract-DyvLXMBy.d.cts} +59 -2
- package/dist/{widgetRuntimeContract-BPILUGC4.d.ts → widgetRuntimeContract-DyvLXMBy.d.ts} +59 -2
- package/package.json +6 -1
- package/dist/chunk-5ABKU4SW.js.map +0 -1
- /package/dist/{chunk-YIXMIOVW.js.map → chunk-QNDSSO77.js.map} +0 -0
package/dist/mocked/index.cjs
CHANGED
|
@@ -37,7 +37,120 @@ __export(mocked_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(mocked_exports);
|
|
38
38
|
|
|
39
39
|
// src/mocked/AiCreditsMockWidget.tsx
|
|
40
|
-
var
|
|
40
|
+
var import_react18 = require("react");
|
|
41
|
+
|
|
42
|
+
// src/deepLinkParams.ts
|
|
43
|
+
var BUYER_ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
44
|
+
var OPERATOR_SIGNATURE_RE = /^0x[0-9a-fA-F]{128}([0-9a-fA-F]{2})?$/;
|
|
45
|
+
var DEEP_LINK_STORAGE_KEY = "goodwidget.ai-credits.deepLink";
|
|
46
|
+
var DEEP_LINK_MANUAL_FALLBACK_HINT = "Generate or import a signer key manually to continue.";
|
|
47
|
+
function isValidBuyerAddress(value) {
|
|
48
|
+
return BUYER_ADDRESS_RE.test(value.trim());
|
|
49
|
+
}
|
|
50
|
+
function isValidOperatorSignature(value) {
|
|
51
|
+
return OPERATOR_SIGNATURE_RE.test(value.trim());
|
|
52
|
+
}
|
|
53
|
+
function deepLinkManualFallbackMessage(reason) {
|
|
54
|
+
return `${reason} ${DEEP_LINK_MANUAL_FALLBACK_HINT}`;
|
|
55
|
+
}
|
|
56
|
+
function canUseLocalStorage() {
|
|
57
|
+
return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
|
|
58
|
+
}
|
|
59
|
+
function readStoredDeepLinkParams() {
|
|
60
|
+
if (!canUseLocalStorage()) return null;
|
|
61
|
+
try {
|
|
62
|
+
const raw = window.localStorage.getItem(DEEP_LINK_STORAGE_KEY);
|
|
63
|
+
if (!raw) return null;
|
|
64
|
+
const parsed = JSON.parse(raw);
|
|
65
|
+
const buyerAddress = typeof parsed.buyerAddress === "string" ? parsed.buyerAddress.trim() : "";
|
|
66
|
+
const operatorSignature = typeof parsed.operatorSignature === "string" ? parsed.operatorSignature.trim() : "";
|
|
67
|
+
if (!isValidBuyerAddress(buyerAddress) || !isValidOperatorSignature(operatorSignature)) {
|
|
68
|
+
clearStoredDeepLinkParams();
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return { buyerAddress, operatorSignature };
|
|
72
|
+
} catch {
|
|
73
|
+
clearStoredDeepLinkParams();
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function storeDeepLinkParams(value) {
|
|
78
|
+
if (!canUseLocalStorage()) return;
|
|
79
|
+
try {
|
|
80
|
+
window.localStorage.setItem(
|
|
81
|
+
DEEP_LINK_STORAGE_KEY,
|
|
82
|
+
JSON.stringify({
|
|
83
|
+
buyerAddress: value.buyerAddress.trim(),
|
|
84
|
+
operatorSignature: value.operatorSignature.trim()
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
} catch {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function clearStoredDeepLinkParams() {
|
|
92
|
+
if (!canUseLocalStorage()) return;
|
|
93
|
+
try {
|
|
94
|
+
window.localStorage.removeItem(DEEP_LINK_STORAGE_KEY);
|
|
95
|
+
} catch {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function parseDeepLinkParams(search = typeof window !== "undefined" ? window.location.search : "") {
|
|
100
|
+
const params = typeof search === "string" ? new URLSearchParams(search) : search;
|
|
101
|
+
const buyerAddress = params.get("buyerAddress")?.trim() ?? "";
|
|
102
|
+
const operatorSignature = params.get("operatorSignature")?.trim() ?? "";
|
|
103
|
+
const hasBuyer = buyerAddress.length > 0;
|
|
104
|
+
const hasSignature = operatorSignature.length > 0;
|
|
105
|
+
if (!hasBuyer && !hasSignature) return { status: "absent" };
|
|
106
|
+
if (hasBuyer && !hasSignature) return { status: "partial", present: "buyerAddress" };
|
|
107
|
+
if (!hasBuyer && hasSignature) return { status: "partial", present: "operatorSignature" };
|
|
108
|
+
if (!isValidBuyerAddress(buyerAddress)) {
|
|
109
|
+
return { status: "invalid", reason: "Deep-link buyerAddress is invalid" };
|
|
110
|
+
}
|
|
111
|
+
if (!isValidOperatorSignature(operatorSignature)) {
|
|
112
|
+
return {
|
|
113
|
+
status: "invalid",
|
|
114
|
+
reason: "Deep-link operatorSignature is invalid"
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
status: "complete",
|
|
119
|
+
source: "url",
|
|
120
|
+
value: {
|
|
121
|
+
buyerAddress,
|
|
122
|
+
operatorSignature
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function resolveDeepLinkParams(search = typeof window !== "undefined" ? window.location.search : "") {
|
|
127
|
+
const fromUrl = parseDeepLinkParams(search);
|
|
128
|
+
if (fromUrl.status === "complete") {
|
|
129
|
+
storeDeepLinkParams(fromUrl.value);
|
|
130
|
+
return fromUrl;
|
|
131
|
+
}
|
|
132
|
+
if (fromUrl.status === "partial" || fromUrl.status === "invalid") {
|
|
133
|
+
return fromUrl;
|
|
134
|
+
}
|
|
135
|
+
const stored = readStoredDeepLinkParams();
|
|
136
|
+
if (!stored) return { status: "absent" };
|
|
137
|
+
return { status: "complete", source: "storage", value: stored };
|
|
138
|
+
}
|
|
139
|
+
function stripDeepLinkParamsFromUrl() {
|
|
140
|
+
if (typeof window === "undefined") return;
|
|
141
|
+
const url = new URL(window.location.href);
|
|
142
|
+
if (!url.searchParams.has("buyerAddress") && !url.searchParams.has("operatorSignature")) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
url.searchParams.delete("buyerAddress");
|
|
146
|
+
url.searchParams.delete("operatorSignature");
|
|
147
|
+
const next = `${url.pathname}${url.search}${url.hash}`;
|
|
148
|
+
window.history.replaceState(window.history.state, "", next);
|
|
149
|
+
}
|
|
150
|
+
function clearDeepLinkArtifacts() {
|
|
151
|
+
clearStoredDeepLinkParams();
|
|
152
|
+
stripDeepLinkParamsFromUrl();
|
|
153
|
+
}
|
|
41
154
|
|
|
42
155
|
// src/quoteMath.ts
|
|
43
156
|
var import_viem = require("viem");
|
|
@@ -200,13 +313,17 @@ function clampHistoryLimit(limit) {
|
|
|
200
313
|
if (limit === void 0) return DEFAULT_HISTORY_LIMIT;
|
|
201
314
|
return Math.min(Math.max(1, Math.floor(limit)), MAX_HISTORY_LIMIT);
|
|
202
315
|
}
|
|
203
|
-
function
|
|
316
|
+
function collectBuyerAddressesFromEntries(entries) {
|
|
317
|
+
const seen = /* @__PURE__ */ new Set();
|
|
318
|
+
const result = [];
|
|
204
319
|
for (const entry of entries) {
|
|
205
|
-
if (entry.buyerAddress
|
|
206
|
-
|
|
207
|
-
|
|
320
|
+
if (!entry.buyerAddress || !(0, import_viem2.isAddress)(entry.buyerAddress)) continue;
|
|
321
|
+
const key = normalizeAddress(entry.buyerAddress);
|
|
322
|
+
if (seen.has(key)) continue;
|
|
323
|
+
seen.add(key);
|
|
324
|
+
result.push(key);
|
|
208
325
|
}
|
|
209
|
-
return
|
|
326
|
+
return result;
|
|
210
327
|
}
|
|
211
328
|
function defaultOperatorStatus(payer) {
|
|
212
329
|
const account = normalizeAddress(payer);
|
|
@@ -441,13 +558,11 @@ async function waitForOperatorConsent(chain, ref) {
|
|
|
441
558
|
}
|
|
442
559
|
async function buildAccountView(payer, backend, chain, options = {}) {
|
|
443
560
|
const normalizedPayer = normalizeAddress(payer);
|
|
444
|
-
const [credit, outstanding
|
|
561
|
+
const [credit, outstanding] = await Promise.all([
|
|
445
562
|
backend.getAccountCredit(payer),
|
|
446
|
-
backend.getOutstanding(payer)
|
|
447
|
-
backend.getCreditHistory(payer, { limit: MAX_HISTORY_LIMIT, offset: 0 })
|
|
563
|
+
backend.getOutstanding(payer)
|
|
448
564
|
]);
|
|
449
|
-
const
|
|
450
|
-
const buyer = sessionBuyer ?? resolveBuyerAddress(history.items);
|
|
565
|
+
const buyer = options.buyerAddress && (0, import_viem2.isAddress)(options.buyerAddress) ? normalizeAddress(options.buyerAddress) : null;
|
|
451
566
|
const [operator, withdrawableUsd] = buyer ? await Promise.all([
|
|
452
567
|
chain.getBuyerOperatorStatus({ payer: normalizedPayer, buyer }),
|
|
453
568
|
chain.getWithdrawableUsd(buyer)
|
|
@@ -792,40 +907,262 @@ async function signRequestClose(params) {
|
|
|
792
907
|
}
|
|
793
908
|
|
|
794
909
|
// src/payerSession.ts
|
|
795
|
-
var
|
|
910
|
+
var STORAGE_KEY_PREFIX = "goodwidget.ai-credits.payerSession.";
|
|
796
911
|
function payerSessionKey(address) {
|
|
797
912
|
return address.toLowerCase();
|
|
798
913
|
}
|
|
914
|
+
function normalizeBuyerAddress(address) {
|
|
915
|
+
return address.toLowerCase();
|
|
916
|
+
}
|
|
917
|
+
function canUseLocalStorage2() {
|
|
918
|
+
return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
|
|
919
|
+
}
|
|
920
|
+
function formatBuyerAddress(address) {
|
|
921
|
+
const key = normalizeBuyerAddress(address);
|
|
922
|
+
return key.startsWith("0x") ? `0x${key.slice(2)}` : key;
|
|
923
|
+
}
|
|
924
|
+
function emptySession() {
|
|
925
|
+
return {
|
|
926
|
+
buyerKeys: {},
|
|
927
|
+
knownBuyers: [],
|
|
928
|
+
activeBuyerAddress: null,
|
|
929
|
+
derivedBuyerAddress: null
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
function isBuyerKeyEntry(value) {
|
|
933
|
+
if (!value || typeof value !== "object") return false;
|
|
934
|
+
const entry = value;
|
|
935
|
+
return (entry.privateKey === void 0 || typeof entry.privateKey === "string") && (entry.operatorSignature === void 0 || typeof entry.operatorSignature === "string") && (entry.operatorConsented === void 0 || typeof entry.operatorConsented === "boolean");
|
|
936
|
+
}
|
|
937
|
+
function migrateLegacySession(raw) {
|
|
938
|
+
const session = emptySession();
|
|
939
|
+
const known = /* @__PURE__ */ new Set();
|
|
940
|
+
const trackKnown = (address) => {
|
|
941
|
+
if (!address) return;
|
|
942
|
+
known.add(normalizeBuyerAddress(address));
|
|
943
|
+
};
|
|
944
|
+
if (typeof raw.buyerPubKey === "string" && raw.buyerPubKey) {
|
|
945
|
+
const address = normalizeBuyerAddress(raw.buyerPubKey);
|
|
946
|
+
session.activeBuyerAddress = address;
|
|
947
|
+
session.derivedBuyerAddress = address;
|
|
948
|
+
trackKnown(address);
|
|
949
|
+
if (typeof raw.buyerPrvKey === "string" && raw.buyerPrvKey) {
|
|
950
|
+
session.buyerKeys[address] = { privateKey: raw.buyerPrvKey };
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
if (Array.isArray(raw.buyers)) {
|
|
954
|
+
for (const item of raw.buyers) {
|
|
955
|
+
if (typeof item === "string" && item) {
|
|
956
|
+
trackKnown(item);
|
|
957
|
+
continue;
|
|
958
|
+
}
|
|
959
|
+
if (!item || typeof item !== "object") continue;
|
|
960
|
+
const buyer = item;
|
|
961
|
+
if (typeof buyer.address !== "string" || !buyer.address) continue;
|
|
962
|
+
const address = normalizeBuyerAddress(buyer.address);
|
|
963
|
+
trackKnown(address);
|
|
964
|
+
const entry = {};
|
|
965
|
+
if (typeof buyer.privateKey === "string" && buyer.privateKey) {
|
|
966
|
+
entry.privateKey = buyer.privateKey;
|
|
967
|
+
}
|
|
968
|
+
if (typeof buyer.operatorSignature === "string" && buyer.operatorSignature) {
|
|
969
|
+
entry.operatorSignature = buyer.operatorSignature;
|
|
970
|
+
}
|
|
971
|
+
if (typeof buyer.operatorConsented === "boolean") {
|
|
972
|
+
entry.operatorConsented = buyer.operatorConsented;
|
|
973
|
+
}
|
|
974
|
+
if (entry.privateKey || entry.operatorSignature || entry.operatorConsented !== void 0) {
|
|
975
|
+
session.buyerKeys[address] = {
|
|
976
|
+
...session.buyerKeys[address],
|
|
977
|
+
...entry
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
if (buyer.type === "derived" && entry.privateKey) {
|
|
981
|
+
session.derivedBuyerAddress = address;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
if (Array.isArray(raw.knownBuyers)) {
|
|
986
|
+
for (const item of raw.knownBuyers) {
|
|
987
|
+
if (typeof item === "string" && item) trackKnown(item);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
if (typeof raw.activeBuyerAddress === "string" && raw.activeBuyerAddress) {
|
|
991
|
+
session.activeBuyerAddress = normalizeBuyerAddress(raw.activeBuyerAddress);
|
|
992
|
+
trackKnown(session.activeBuyerAddress);
|
|
993
|
+
}
|
|
994
|
+
if (typeof raw.derivedBuyerAddress === "string" && raw.derivedBuyerAddress) {
|
|
995
|
+
session.derivedBuyerAddress = normalizeBuyerAddress(raw.derivedBuyerAddress);
|
|
996
|
+
trackKnown(session.derivedBuyerAddress);
|
|
997
|
+
}
|
|
998
|
+
if (typeof raw.operatorSignature === "string" && raw.operatorSignature && session.activeBuyerAddress) {
|
|
999
|
+
const active = session.activeBuyerAddress;
|
|
1000
|
+
session.buyerKeys[active] = {
|
|
1001
|
+
...session.buyerKeys[active],
|
|
1002
|
+
operatorSignature: raw.operatorSignature
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
if (raw.buyerKeys && typeof raw.buyerKeys === "object") {
|
|
1006
|
+
for (const [address, entry] of Object.entries(raw.buyerKeys)) {
|
|
1007
|
+
if (!isBuyerKeyEntry(entry)) continue;
|
|
1008
|
+
const key = normalizeBuyerAddress(address);
|
|
1009
|
+
trackKnown(key);
|
|
1010
|
+
session.buyerKeys[key] = {
|
|
1011
|
+
...session.buyerKeys[key],
|
|
1012
|
+
...entry
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
if (typeof raw.operatorConsented === "boolean" && raw.operatorConsented && session.activeBuyerAddress) {
|
|
1017
|
+
const active = session.activeBuyerAddress;
|
|
1018
|
+
session.buyerKeys[active] = {
|
|
1019
|
+
...session.buyerKeys[active],
|
|
1020
|
+
operatorConsented: true
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
session.knownBuyers = [...known].map((key) => formatBuyerAddress(key));
|
|
1024
|
+
return session;
|
|
1025
|
+
}
|
|
1026
|
+
function parseStoredSession(raw) {
|
|
1027
|
+
try {
|
|
1028
|
+
const parsed = JSON.parse(raw);
|
|
1029
|
+
return migrateLegacySession(parsed);
|
|
1030
|
+
} catch {
|
|
1031
|
+
return null;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
function persistSession(address, session) {
|
|
1035
|
+
if (!canUseLocalStorage2()) return;
|
|
1036
|
+
try {
|
|
1037
|
+
window.localStorage.setItem(
|
|
1038
|
+
`${STORAGE_KEY_PREFIX}${payerSessionKey(address)}`,
|
|
1039
|
+
JSON.stringify(session)
|
|
1040
|
+
);
|
|
1041
|
+
} catch {
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
799
1045
|
function readPayerSession(address) {
|
|
800
|
-
if (!address) return null;
|
|
801
|
-
|
|
1046
|
+
if (!address || !canUseLocalStorage2()) return null;
|
|
1047
|
+
try {
|
|
1048
|
+
const raw = window.localStorage.getItem(
|
|
1049
|
+
`${STORAGE_KEY_PREFIX}${payerSessionKey(address)}`
|
|
1050
|
+
);
|
|
1051
|
+
if (!raw) return null;
|
|
1052
|
+
return parseStoredSession(raw);
|
|
1053
|
+
} catch {
|
|
1054
|
+
return null;
|
|
1055
|
+
}
|
|
802
1056
|
}
|
|
803
|
-
function
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
|
|
1057
|
+
function getBuyerKeyEntry(payer, buyerAddress) {
|
|
1058
|
+
const session = readPayerSession(payer);
|
|
1059
|
+
if (!session) return null;
|
|
1060
|
+
return session.buyerKeys[normalizeBuyerAddress(buyerAddress)] ?? null;
|
|
1061
|
+
}
|
|
1062
|
+
function setBuyerOperatorConsented(payer, buyerAddress, operatorConsented) {
|
|
1063
|
+
upsertBuyerKey(payer, buyerAddress, { operatorConsented }, { setActive: false });
|
|
1064
|
+
}
|
|
1065
|
+
function upsertBuyerKey(payer, buyerAddress, entry, options) {
|
|
1066
|
+
const existing = readPayerSession(payer) ?? emptySession();
|
|
1067
|
+
const key = normalizeBuyerAddress(buyerAddress);
|
|
1068
|
+
const previous = existing.buyerKeys[key] ?? {};
|
|
1069
|
+
const knownBuyers = mergeBuyerAddressList(existing.knownBuyers, key);
|
|
1070
|
+
const next = {
|
|
807
1071
|
...existing,
|
|
808
|
-
|
|
809
|
-
|
|
1072
|
+
knownBuyers,
|
|
1073
|
+
buyerKeys: {
|
|
1074
|
+
...existing.buyerKeys,
|
|
1075
|
+
[key]: {
|
|
1076
|
+
privateKey: entry.privateKey ?? previous.privateKey,
|
|
1077
|
+
operatorSignature: entry.operatorSignature ?? previous.operatorSignature,
|
|
1078
|
+
operatorConsented: entry.operatorConsented !== void 0 ? entry.operatorConsented : previous.operatorConsented
|
|
1079
|
+
}
|
|
1080
|
+
},
|
|
1081
|
+
activeBuyerAddress: options?.setActive === false ? existing.activeBuyerAddress : key,
|
|
1082
|
+
derivedBuyerAddress: options?.setDerived ? key : existing.derivedBuyerAddress
|
|
1083
|
+
};
|
|
1084
|
+
persistSession(payer, next);
|
|
1085
|
+
return next;
|
|
1086
|
+
}
|
|
1087
|
+
function setActiveBuyerAddress(payer, buyerAddress) {
|
|
1088
|
+
const existing = readPayerSession(payer) ?? emptySession();
|
|
1089
|
+
const normalized = buyerAddress ? normalizeBuyerAddress(buyerAddress) : null;
|
|
1090
|
+
const next = {
|
|
1091
|
+
...existing,
|
|
1092
|
+
knownBuyers: normalized ? mergeBuyerAddressList(existing.knownBuyers, normalized) : existing.knownBuyers,
|
|
1093
|
+
activeBuyerAddress: normalized
|
|
1094
|
+
};
|
|
1095
|
+
persistSession(payer, next);
|
|
1096
|
+
return next;
|
|
1097
|
+
}
|
|
1098
|
+
function mergeBuyerAddressList(existingBuyers, ...extras) {
|
|
1099
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1100
|
+
const result = [];
|
|
1101
|
+
for (const address of [...existingBuyers, ...extras]) {
|
|
1102
|
+
if (!address) continue;
|
|
1103
|
+
const key = normalizeBuyerAddress(address);
|
|
1104
|
+
if (seen.has(key)) continue;
|
|
1105
|
+
seen.add(key);
|
|
1106
|
+
result.push(formatBuyerAddress(key));
|
|
1107
|
+
}
|
|
1108
|
+
return result;
|
|
1109
|
+
}
|
|
1110
|
+
function listKnownBuyerAddresses(payer) {
|
|
1111
|
+
const session = readPayerSession(payer);
|
|
1112
|
+
if (!session) return [];
|
|
1113
|
+
return mergeBuyerAddressList(
|
|
1114
|
+
session.knownBuyers,
|
|
1115
|
+
...Object.keys(session.buyerKeys),
|
|
1116
|
+
session.activeBuyerAddress,
|
|
1117
|
+
session.derivedBuyerAddress
|
|
1118
|
+
);
|
|
1119
|
+
}
|
|
1120
|
+
function rememberBuyerAddresses(payer, addresses) {
|
|
1121
|
+
const existing = readPayerSession(payer) ?? emptySession();
|
|
1122
|
+
const knownBuyers = mergeBuyerAddressList(existing.knownBuyers, ...addresses);
|
|
1123
|
+
if (knownBuyers.length === existing.knownBuyers.length && knownBuyers.every(
|
|
1124
|
+
(address, index) => address.toLowerCase() === existing.knownBuyers[index]?.toLowerCase()
|
|
1125
|
+
)) {
|
|
1126
|
+
return listKnownBuyerAddresses(payer);
|
|
1127
|
+
}
|
|
1128
|
+
persistSession(payer, { ...existing, knownBuyers });
|
|
1129
|
+
return listKnownBuyerAddresses(payer);
|
|
1130
|
+
}
|
|
1131
|
+
function buildBuyerStateFields(payer, buyers, selectedAddress) {
|
|
1132
|
+
const session = readPayerSession(payer);
|
|
1133
|
+
const entry = selectedAddress ? getBuyerKeyEntry(payer, selectedAddress) : null;
|
|
1134
|
+
return {
|
|
1135
|
+
buyers,
|
|
1136
|
+
buyerPubKey: selectedAddress,
|
|
1137
|
+
buyerPrvKey: entry?.privateKey ?? null,
|
|
1138
|
+
operatorSignature: entry?.operatorSignature ?? null,
|
|
1139
|
+
operatorConsented: Boolean(entry?.operatorConsented),
|
|
1140
|
+
derivedBuyerAddress: session?.derivedBuyerAddress ?? null
|
|
1141
|
+
};
|
|
810
1142
|
}
|
|
811
1143
|
function patchPayerSessionFields(address) {
|
|
812
1144
|
const session = readPayerSession(address);
|
|
813
1145
|
if (!session) {
|
|
814
1146
|
return {
|
|
1147
|
+
buyerPubKey: null,
|
|
815
1148
|
buyerPrvKey: null,
|
|
816
|
-
|
|
1149
|
+
operatorSignature: null,
|
|
1150
|
+
operatorConsented: false,
|
|
1151
|
+
activeBuyerAddress: null,
|
|
1152
|
+
derivedBuyerAddress: null
|
|
817
1153
|
};
|
|
818
1154
|
}
|
|
1155
|
+
const active = session.activeBuyerAddress;
|
|
1156
|
+
const entry = active ? session.buyerKeys[normalizeBuyerAddress(active)] : void 0;
|
|
819
1157
|
return {
|
|
820
|
-
buyerPubKey:
|
|
821
|
-
buyerPrvKey:
|
|
822
|
-
|
|
1158
|
+
buyerPubKey: active,
|
|
1159
|
+
buyerPrvKey: entry?.privateKey ?? null,
|
|
1160
|
+
operatorSignature: entry?.operatorSignature ?? null,
|
|
1161
|
+
operatorConsented: Boolean(entry?.operatorConsented),
|
|
1162
|
+
activeBuyerAddress: active,
|
|
1163
|
+
derivedBuyerAddress: session.derivedBuyerAddress
|
|
823
1164
|
};
|
|
824
1165
|
}
|
|
825
|
-
function addressesMatch(a, b) {
|
|
826
|
-
if (!a || !b) return false;
|
|
827
|
-
return payerSessionKey(a) === payerSessionKey(b);
|
|
828
|
-
}
|
|
829
1166
|
|
|
830
1167
|
// src/celoPayment.ts
|
|
831
1168
|
var import_viem5 = require("viem");
|
|
@@ -1105,7 +1442,7 @@ function getPayDisabledMessage(params) {
|
|
|
1105
1442
|
if (params.validation.streamBelowMin && params.minStreamUsd) {
|
|
1106
1443
|
return `Monthly stream must be at least ${formatMinUsdDisplay(params.minStreamUsd)}.`;
|
|
1107
1444
|
}
|
|
1108
|
-
if (params.status !== "quote_ready") {
|
|
1445
|
+
if (params.status !== "quote_ready" && params.status !== "payment_failed") {
|
|
1109
1446
|
return "Enter a deposit or change the monthly stream amount to continue.";
|
|
1110
1447
|
}
|
|
1111
1448
|
return "Adjust the amounts to continue.";
|
|
@@ -1241,8 +1578,11 @@ var INITIAL_STATE = {
|
|
|
1241
1578
|
isGoodIdVerified: false,
|
|
1242
1579
|
buyerPubKey: null,
|
|
1243
1580
|
buyerPrvKey: null,
|
|
1581
|
+
operatorSignature: null,
|
|
1244
1582
|
operatorConsented: false,
|
|
1583
|
+
operatorConsentPending: false,
|
|
1245
1584
|
operatorAddress: null,
|
|
1585
|
+
currentOperator: null,
|
|
1246
1586
|
minDepositUsd: null,
|
|
1247
1587
|
minStreamUsd: null,
|
|
1248
1588
|
totalGdDepositedG: null,
|
|
@@ -1251,7 +1591,9 @@ var INITIAL_STATE = {
|
|
|
1251
1591
|
depositBonusPercent: DEFAULT_DISCOUNT_CONFIG.depositBonusPercent,
|
|
1252
1592
|
streamBonusPercent: DEFAULT_DISCOUNT_CONFIG.streamBonusPercent,
|
|
1253
1593
|
error: null,
|
|
1254
|
-
activeTab: "
|
|
1594
|
+
activeTab: "setup",
|
|
1595
|
+
buyers: [],
|
|
1596
|
+
derivedBuyerAddress: null
|
|
1255
1597
|
};
|
|
1256
1598
|
var WALLET_LOADING_STATE = {
|
|
1257
1599
|
gBalance: null,
|
|
@@ -1263,17 +1605,59 @@ var WALLET_LOADING_STATE = {
|
|
|
1263
1605
|
totalGdDepositedG: null,
|
|
1264
1606
|
monthlyStreamG: null,
|
|
1265
1607
|
withdrawableUsd: null,
|
|
1266
|
-
operatorAddress: null
|
|
1608
|
+
operatorAddress: null,
|
|
1609
|
+
currentOperator: null
|
|
1267
1610
|
};
|
|
1611
|
+
var BUYER_HISTORY_LOOKUP_LIMIT = 100;
|
|
1612
|
+
function resolveLocalBuyers(payer, preferredBuyer, ...extras) {
|
|
1613
|
+
const buyers = rememberBuyerAddresses(payer, [
|
|
1614
|
+
preferredBuyer,
|
|
1615
|
+
...listKnownBuyerAddresses(payer),
|
|
1616
|
+
...extras
|
|
1617
|
+
]);
|
|
1618
|
+
return { buyers, selected: selectPreferredBuyer(buyers, preferredBuyer) };
|
|
1619
|
+
}
|
|
1620
|
+
async function discoverBuyersFromHistory(payer, backend, ...extras) {
|
|
1621
|
+
let historyBuyers = [];
|
|
1622
|
+
try {
|
|
1623
|
+
const history = await backend.getCreditHistory(payer, {
|
|
1624
|
+
limit: BUYER_HISTORY_LOOKUP_LIMIT,
|
|
1625
|
+
offset: 0
|
|
1626
|
+
});
|
|
1627
|
+
historyBuyers = collectBuyerAddressesFromEntries(history.items);
|
|
1628
|
+
} catch {
|
|
1629
|
+
historyBuyers = [];
|
|
1630
|
+
}
|
|
1631
|
+
return rememberBuyerAddresses(payer, [...historyBuyers, ...extras]);
|
|
1632
|
+
}
|
|
1633
|
+
function selectPreferredBuyer(buyers, preferredBuyer) {
|
|
1634
|
+
if (preferredBuyer && buyers.some((item) => item.toLowerCase() === preferredBuyer.toLowerCase())) {
|
|
1635
|
+
return preferredBuyer;
|
|
1636
|
+
}
|
|
1637
|
+
return buyers[0] ?? preferredBuyer ?? null;
|
|
1638
|
+
}
|
|
1268
1639
|
function isNonBuyTab(tab) {
|
|
1269
|
-
return tab === "manage" || tab === "history";
|
|
1640
|
+
return tab === "setup" || tab === "manage" || tab === "history";
|
|
1641
|
+
}
|
|
1642
|
+
function needsWalletConnection(state) {
|
|
1643
|
+
return !state.address || state.status === "disconnected" || state.status === "connecting";
|
|
1644
|
+
}
|
|
1645
|
+
function resolveDefaultActiveTab(payerAddress, totalCreditUsd) {
|
|
1646
|
+
if (hasCreditBalance(totalCreditUsd)) return "manage";
|
|
1647
|
+
if (payerAddress && listKnownBuyerAddresses(payerAddress).length > 0) return "buy";
|
|
1648
|
+
return "setup";
|
|
1270
1649
|
}
|
|
1271
1650
|
function resolveActiveTab(prev, overrides) {
|
|
1272
1651
|
if (overrides.activeTab !== void 0) return overrides.activeTab;
|
|
1652
|
+
const payerAddress = overrides.address !== void 0 ? overrides.address : prev.address;
|
|
1653
|
+
const totalCreditUsd = overrides.totalCreditUsd !== void 0 ? overrides.totalCreditUsd : prev.totalCreditUsd;
|
|
1273
1654
|
if (overrides.totalCreditUsd !== void 0 && overrides.totalCreditUsd !== null) {
|
|
1274
|
-
return
|
|
1655
|
+
return resolveDefaultActiveTab(payerAddress, overrides.totalCreditUsd);
|
|
1656
|
+
}
|
|
1657
|
+
if (overrides.address !== void 0 && overrides.address !== prev.address) {
|
|
1658
|
+
return resolveDefaultActiveTab(payerAddress, totalCreditUsd);
|
|
1275
1659
|
}
|
|
1276
|
-
return prev.activeTab ??
|
|
1660
|
+
return prev.activeTab ?? resolveDefaultActiveTab(payerAddress, totalCreditUsd);
|
|
1277
1661
|
}
|
|
1278
1662
|
function hasCreditBalance(totalCreditUsd) {
|
|
1279
1663
|
return totalCreditUsd !== null && BigInt(totalCreditUsd) > 0n;
|
|
@@ -1331,7 +1715,7 @@ function mergeStatePreservingNonBuyTab(prev, overrides) {
|
|
|
1331
1715
|
}
|
|
1332
1716
|
const activeTab = isNonBuyTab(nextTab) ? nextTab : prev.activeTab;
|
|
1333
1717
|
const status = deriveStatus({
|
|
1334
|
-
isConnected:
|
|
1718
|
+
isConnected: !needsWalletConnection(prev),
|
|
1335
1719
|
chainId: overrides.chainId ?? prev.chainId,
|
|
1336
1720
|
gBalance: overrides.gBalance ?? prev.gBalance,
|
|
1337
1721
|
buyerPubKey: overrides.buyerPubKey ?? prev.buyerPubKey,
|
|
@@ -1355,31 +1739,15 @@ function viewToStatePatch(view, enriched, prev, options) {
|
|
|
1355
1739
|
isGoodIdVerified: enriched.goodIdVerified,
|
|
1356
1740
|
operatorConsented: operatorAccepted,
|
|
1357
1741
|
operatorAddress: view.operator.operatorAddress ?? null,
|
|
1742
|
+
currentOperator: view.operator.currentOperator ?? null,
|
|
1358
1743
|
withdrawableUsd: view.withdrawableUsd,
|
|
1359
1744
|
totalGdDepositedG: enriched.totalGdDepositedG,
|
|
1360
|
-
monthlyStreamG: enriched.monthlyStreamG
|
|
1361
|
-
...view.buyer ? { buyerPubKey: view.buyer } : {}
|
|
1362
|
-
};
|
|
1363
|
-
}
|
|
1364
|
-
function mergeSessionFields(prev, sessionPatch, accountPatch, accountSwitched) {
|
|
1365
|
-
const buyerPubKey = sessionPatch.buyerPubKey ?? accountPatch.buyerPubKey ?? (accountSwitched ? null : prev.buyerPubKey);
|
|
1366
|
-
const buyerPrvKey = sessionPatch.buyerPrvKey ?? (accountSwitched ? null : prev.buyerPrvKey);
|
|
1367
|
-
const operatorConsented = accountSwitched ? sessionPatch.operatorConsented ?? accountPatch.operatorConsented ?? false : accountPatch.operatorConsented ?? sessionPatch.operatorConsented ?? prev.operatorConsented;
|
|
1368
|
-
return {
|
|
1369
|
-
buyerPubKey,
|
|
1370
|
-
buyerPrvKey,
|
|
1371
|
-
operatorConsented
|
|
1745
|
+
monthlyStreamG: enriched.monthlyStreamG
|
|
1372
1746
|
};
|
|
1373
1747
|
}
|
|
1374
|
-
function
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
}
|
|
1378
|
-
function syncBuyerPubKeySession(address, buyerPubKey) {
|
|
1379
|
-
if (!buyerPubKey) return;
|
|
1380
|
-
const existing = readPayerSession(address);
|
|
1381
|
-
if (existing?.buyerPubKey) return;
|
|
1382
|
-
patchPayerSession(address, { buyerPubKey });
|
|
1748
|
+
function activateBuyerSelection(payer, buyers, selectedAddress) {
|
|
1749
|
+
setActiveBuyerAddress(payer, selectedAddress);
|
|
1750
|
+
return buildBuyerStateFields(payer, buyers, selectedAddress);
|
|
1383
1751
|
}
|
|
1384
1752
|
function useAiCreditsAdapter({
|
|
1385
1753
|
environment = "production",
|
|
@@ -1403,6 +1771,9 @@ function useAiCreditsAdapter({
|
|
|
1403
1771
|
const providerRef = (0, import_react.useRef)(null);
|
|
1404
1772
|
providerRef.current = provider;
|
|
1405
1773
|
const goodIdVerifyPendingRef = (0, import_react.useRef)(false);
|
|
1774
|
+
const pendingDeepLinkRef = (0, import_react.useRef)(null);
|
|
1775
|
+
const deepLinkParseDoneRef = (0, import_react.useRef)(false);
|
|
1776
|
+
const deepLinkApplyInFlightRef = (0, import_react.useRef)(false);
|
|
1406
1777
|
const celoVault = vaultAddress ?? CELO_GD_ANTSEED_VAULT_FALLBACK;
|
|
1407
1778
|
const backendClient = (0, import_react.useMemo)(
|
|
1408
1779
|
() => backendClientOverride ?? createBackendClient(backendUrl),
|
|
@@ -1420,7 +1791,11 @@ function useAiCreditsAdapter({
|
|
|
1420
1791
|
);
|
|
1421
1792
|
(0, import_react.useEffect)(() => {
|
|
1422
1793
|
if (!isConnected || !address) {
|
|
1423
|
-
setState((prev) =>
|
|
1794
|
+
setState((prev) => {
|
|
1795
|
+
if (prev.status === "connecting") return prev;
|
|
1796
|
+
if (!prev.address && prev.status === "disconnected" && prev.error === null) return prev;
|
|
1797
|
+
return { ...INITIAL_STATE };
|
|
1798
|
+
});
|
|
1424
1799
|
return;
|
|
1425
1800
|
}
|
|
1426
1801
|
if (configurationError) {
|
|
@@ -1439,14 +1814,17 @@ function useAiCreditsAdapter({
|
|
|
1439
1814
|
if (prev.status === "payment_pending" || prev.status === "payment_confirmed" || prev.status === "payment_failed") {
|
|
1440
1815
|
return prev;
|
|
1441
1816
|
}
|
|
1442
|
-
const accountSwitched = !addressesMatch(prev.address, address);
|
|
1443
|
-
const buyerFields = mergeSessionFields(prev, sessionPatch, {}, accountSwitched);
|
|
1444
1817
|
return withDerivedStatus(
|
|
1445
1818
|
prev,
|
|
1446
1819
|
{
|
|
1447
1820
|
address,
|
|
1448
1821
|
chainId,
|
|
1449
|
-
|
|
1822
|
+
buyerPubKey: sessionPatch.buyerPubKey,
|
|
1823
|
+
buyerPrvKey: sessionPatch.buyerPrvKey,
|
|
1824
|
+
operatorSignature: sessionPatch.operatorSignature,
|
|
1825
|
+
operatorConsented: sessionPatch.operatorConsented,
|
|
1826
|
+
derivedBuyerAddress: sessionPatch.derivedBuyerAddress,
|
|
1827
|
+
buyers: prev.buyers,
|
|
1450
1828
|
...WALLET_LOADING_STATE,
|
|
1451
1829
|
error: null,
|
|
1452
1830
|
status: "connecting"
|
|
@@ -1469,8 +1847,11 @@ function useAiCreditsAdapter({
|
|
|
1469
1847
|
functionName: "decimals"
|
|
1470
1848
|
})
|
|
1471
1849
|
]);
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1850
|
+
const pendingDeepLink = pendingDeepLinkRef.current;
|
|
1851
|
+
const sessionBuyer = patchPayerSessionFields(address).buyerPubKey;
|
|
1852
|
+
const preferredBuyer = pendingDeepLink?.buyerAddress ?? sessionBuyer ?? null;
|
|
1853
|
+
const accountPromise = pendingDeepLink || deepLinkApplyInFlightRef.current ? Promise.resolve(null) : buildAccountView(address, backendClient, chainClient, {
|
|
1854
|
+
buyerAddress: preferredBuyer
|
|
1474
1855
|
}).then(async (view) => ({
|
|
1475
1856
|
view,
|
|
1476
1857
|
enriched: await enrichAccountView(view, chainClient)
|
|
@@ -1481,13 +1862,25 @@ function useAiCreditsAdapter({
|
|
|
1481
1862
|
}) : fetchVaultPaymentMinimums(publicClient, celoVault, address).catch(() => null);
|
|
1482
1863
|
const gdUsdPerTokenPromise = chainClient.fetchGdUsdPerToken().catch(() => null);
|
|
1483
1864
|
const discountConfigPromise = backendClient.getDiscountConfig().catch(() => null);
|
|
1865
|
+
const buyersPromise = pendingDeepLink ? Promise.resolve(
|
|
1866
|
+
rememberBuyerAddresses(address, [
|
|
1867
|
+
preferredBuyer,
|
|
1868
|
+
...listKnownBuyerAddresses(address)
|
|
1869
|
+
])
|
|
1870
|
+
) : discoverBuyersFromHistory(
|
|
1871
|
+
address,
|
|
1872
|
+
backendClient,
|
|
1873
|
+
preferredBuyer,
|
|
1874
|
+
...listKnownBuyerAddresses(address)
|
|
1875
|
+
);
|
|
1484
1876
|
try {
|
|
1485
|
-
const [[rawBalance, decimals], account, minimums, gdUsdPerToken, discountConfig] = await Promise.all([
|
|
1877
|
+
const [[rawBalance, decimals], account, minimums, gdUsdPerToken, discountConfig, buyers] = await Promise.all([
|
|
1486
1878
|
balancePromise,
|
|
1487
1879
|
accountPromise,
|
|
1488
1880
|
minimumsPromise,
|
|
1489
1881
|
gdUsdPerTokenPromise,
|
|
1490
|
-
discountConfigPromise
|
|
1882
|
+
discountConfigPromise,
|
|
1883
|
+
buyersPromise
|
|
1491
1884
|
]);
|
|
1492
1885
|
if (cancelled) return;
|
|
1493
1886
|
const patch = {
|
|
@@ -1500,41 +1893,54 @@ function useAiCreditsAdapter({
|
|
|
1500
1893
|
depositBonusPercent: discountConfig?.depositBonusPercent ?? DEFAULT_DISCOUNT_CONFIG.depositBonusPercent,
|
|
1501
1894
|
streamBonusPercent: discountConfig?.streamBonusPercent ?? DEFAULT_DISCOUNT_CONFIG.streamBonusPercent
|
|
1502
1895
|
};
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1896
|
+
if (pendingDeepLink || deepLinkApplyInFlightRef.current) {
|
|
1897
|
+
setState(
|
|
1898
|
+
(prev) => withDerivedStatus(
|
|
1899
|
+
prev,
|
|
1900
|
+
{
|
|
1901
|
+
...patch,
|
|
1902
|
+
buyers: mergeBuyerAddressList(prev.buyers, ...buyers)
|
|
1903
|
+
},
|
|
1904
|
+
true
|
|
1905
|
+
)
|
|
1906
|
+
);
|
|
1907
|
+
return;
|
|
1908
|
+
}
|
|
1909
|
+
const selectedBuyer = selectPreferredBuyer(buyers, preferredBuyer);
|
|
1910
|
+
const accountPatch = account ? viewToStatePatch(account.view, account.enriched, INITIAL_STATE, {
|
|
1911
|
+
balanceMode: "always"
|
|
1912
|
+
}) : {};
|
|
1913
|
+
if (selectedBuyer && accountPatch.operatorConsented !== void 0) {
|
|
1914
|
+
setBuyerOperatorConsented(address, selectedBuyer, accountPatch.operatorConsented);
|
|
1915
|
+
}
|
|
1916
|
+
const buyerFields = activateBuyerSelection(address, buyers, selectedBuyer);
|
|
1917
|
+
setState(
|
|
1918
|
+
(prev) => withDerivedStatus(
|
|
1516
1919
|
prev,
|
|
1517
1920
|
{
|
|
1518
1921
|
...patch,
|
|
1519
1922
|
...accountPatch,
|
|
1520
1923
|
...buyerFields,
|
|
1521
|
-
|
|
1924
|
+
operatorConsented: accountPatch.operatorConsented ?? buyerFields.operatorConsented
|
|
1522
1925
|
},
|
|
1523
1926
|
true
|
|
1524
|
-
)
|
|
1525
|
-
|
|
1927
|
+
)
|
|
1928
|
+
);
|
|
1526
1929
|
} catch {
|
|
1527
1930
|
if (cancelled) return;
|
|
1528
1931
|
setState((prev) => {
|
|
1529
|
-
const accountSwitched = !addressesMatch(prev.address, address);
|
|
1530
|
-
const buyerFields = mergeSessionFields(prev, sessionPatch, {}, accountSwitched);
|
|
1531
1932
|
return withDerivedStatus(
|
|
1532
1933
|
prev,
|
|
1533
1934
|
{
|
|
1534
1935
|
address,
|
|
1535
1936
|
chainId,
|
|
1536
1937
|
gBalance: "0",
|
|
1537
|
-
|
|
1938
|
+
buyers: [],
|
|
1939
|
+
derivedBuyerAddress: null,
|
|
1940
|
+
buyerPubKey: null,
|
|
1941
|
+
buyerPrvKey: null,
|
|
1942
|
+
operatorSignature: null,
|
|
1943
|
+
operatorConsented: false,
|
|
1538
1944
|
status: chainId !== null && chainId !== CELO_CHAIN_ID2 ? "unsupported_chain" : "purchase_setup"
|
|
1539
1945
|
},
|
|
1540
1946
|
true
|
|
@@ -1573,14 +1979,32 @@ function useAiCreditsAdapter({
|
|
|
1573
1979
|
setState(
|
|
1574
1980
|
(prev) => withDerivedStatus(
|
|
1575
1981
|
prev,
|
|
1576
|
-
{ error: "Connect your wallet before generating a
|
|
1982
|
+
{ error: "Connect your wallet before generating a signer key" },
|
|
1577
1983
|
true
|
|
1578
1984
|
)
|
|
1579
1985
|
);
|
|
1580
1986
|
return;
|
|
1581
1987
|
}
|
|
1988
|
+
const payerAddress = address;
|
|
1989
|
+
const session = readPayerSession(payerAddress);
|
|
1990
|
+
const derivedAddress = session?.derivedBuyerAddress ?? null;
|
|
1991
|
+
const existingKey = derivedAddress ? getBuyerKeyEntry(payerAddress, derivedAddress) : null;
|
|
1992
|
+
if (derivedAddress && existingKey?.privateKey) {
|
|
1993
|
+
const buyers = mergeBuyerAddressList(
|
|
1994
|
+
listKnownBuyerAddresses(payerAddress),
|
|
1995
|
+
derivedAddress
|
|
1996
|
+
);
|
|
1997
|
+
const buyerFields = activateBuyerSelection(payerAddress, buyers, derivedAddress);
|
|
1998
|
+
setState(
|
|
1999
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2000
|
+
...buyerFields,
|
|
2001
|
+
error: null,
|
|
2002
|
+
...!isNonBuyTab(prev.activeTab) ? { status: "purchase_setup" } : {}
|
|
2003
|
+
})
|
|
2004
|
+
);
|
|
2005
|
+
return;
|
|
2006
|
+
}
|
|
1582
2007
|
try {
|
|
1583
|
-
const payerAddress = address;
|
|
1584
2008
|
const message = buildBuyerKeyMessage(payerAddress);
|
|
1585
2009
|
const walletClient = (0, import_viem8.createWalletClient)({
|
|
1586
2010
|
account: payerAddress,
|
|
@@ -1592,15 +2016,21 @@ function useAiCreditsAdapter({
|
|
|
1592
2016
|
message
|
|
1593
2017
|
});
|
|
1594
2018
|
const privateKey = deriveBuyerPrivateKeyFromSignature(signature);
|
|
1595
|
-
const
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
2019
|
+
const buyerAccount = (0, import_accounts4.privateKeyToAccount)(privateKey);
|
|
2020
|
+
upsertBuyerKey(
|
|
2021
|
+
payerAddress,
|
|
2022
|
+
buyerAccount.address,
|
|
2023
|
+
{ privateKey },
|
|
2024
|
+
{ setActive: true, setDerived: true }
|
|
2025
|
+
);
|
|
2026
|
+
const buyers = mergeBuyerAddressList(
|
|
2027
|
+
listKnownBuyerAddresses(payerAddress),
|
|
2028
|
+
buyerAccount.address
|
|
2029
|
+
);
|
|
2030
|
+
const buyerFields = buildBuyerStateFields(payerAddress, buyers, buyerAccount.address);
|
|
1600
2031
|
setState(
|
|
1601
2032
|
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
1602
|
-
|
|
1603
|
-
buyerPrvKey: privateKey,
|
|
2033
|
+
...buyerFields,
|
|
1604
2034
|
error: null,
|
|
1605
2035
|
...!isNonBuyTab(prev.activeTab) ? { status: "purchase_setup" } : {}
|
|
1606
2036
|
})
|
|
@@ -1617,64 +2047,332 @@ function useAiCreditsAdapter({
|
|
|
1617
2047
|
);
|
|
1618
2048
|
}
|
|
1619
2049
|
}, [address]);
|
|
1620
|
-
const
|
|
1621
|
-
|
|
1622
|
-
|
|
2050
|
+
const handleSelectBuyer = (0, import_react.useCallback)(
|
|
2051
|
+
async (buyerAddress) => {
|
|
2052
|
+
if (!address) return;
|
|
2053
|
+
const known = listKnownBuyerAddresses(address);
|
|
2054
|
+
if (!known.some((item) => item.toLowerCase() === buyerAddress.toLowerCase())) {
|
|
2055
|
+
return;
|
|
2056
|
+
}
|
|
2057
|
+
const buyers = mergeBuyerAddressList(known, buyerAddress);
|
|
2058
|
+
const buyerFields = activateBuyerSelection(address, buyers, buyerAddress);
|
|
1623
2059
|
setState(
|
|
1624
|
-
(prev) =>
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
2060
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2061
|
+
...buyerFields,
|
|
2062
|
+
operatorAddress: null,
|
|
2063
|
+
currentOperator: null,
|
|
2064
|
+
totalCreditUsd: null,
|
|
2065
|
+
withdrawableUsd: null,
|
|
2066
|
+
totalGdDepositedG: null,
|
|
2067
|
+
monthlyStreamG: null,
|
|
2068
|
+
operatorConsentPending: false,
|
|
2069
|
+
error: null
|
|
2070
|
+
})
|
|
1629
2071
|
);
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
2072
|
+
try {
|
|
2073
|
+
const view = await buildAccountView(address, backendClient, chainClient, {
|
|
2074
|
+
buyerAddress
|
|
2075
|
+
});
|
|
2076
|
+
const enriched = await enrichAccountView(view, chainClient);
|
|
2077
|
+
const accountPatch = viewToStatePatch(view, enriched, INITIAL_STATE, {
|
|
2078
|
+
balanceMode: "always"
|
|
2079
|
+
});
|
|
2080
|
+
if (accountPatch.operatorConsented !== void 0) {
|
|
2081
|
+
setBuyerOperatorConsented(address, buyerAddress, accountPatch.operatorConsented);
|
|
2082
|
+
}
|
|
2083
|
+
const nextBuyerFields = buildBuyerStateFields(address, buyers, buyerAddress);
|
|
2084
|
+
setState(
|
|
2085
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2086
|
+
...accountPatch,
|
|
2087
|
+
...nextBuyerFields,
|
|
2088
|
+
operatorConsented: accountPatch.operatorConsented ?? nextBuyerFields.operatorConsented,
|
|
2089
|
+
error: null
|
|
2090
|
+
})
|
|
2091
|
+
);
|
|
2092
|
+
} catch (err) {
|
|
2093
|
+
setState(
|
|
2094
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2095
|
+
error: err instanceof Error ? err.message : "Could not load buyer account"
|
|
2096
|
+
})
|
|
2097
|
+
);
|
|
1638
2098
|
}
|
|
1639
|
-
|
|
1640
|
-
|
|
2099
|
+
},
|
|
2100
|
+
[address, backendClient, chainClient]
|
|
2101
|
+
);
|
|
2102
|
+
const handleDiscoverBuyers = (0, import_react.useCallback)(
|
|
2103
|
+
(addresses) => {
|
|
2104
|
+
if (!address || addresses.length === 0) return;
|
|
2105
|
+
const buyers = rememberBuyerAddresses(address, addresses);
|
|
2106
|
+
setState((prev) => {
|
|
2107
|
+
const sameLength = buyers.length === prev.buyers.length;
|
|
2108
|
+
const unchanged = sameLength && buyers.every(
|
|
2109
|
+
(item, index) => item.toLowerCase() === prev.buyers[index]?.toLowerCase()
|
|
2110
|
+
);
|
|
2111
|
+
if (unchanged) return prev;
|
|
2112
|
+
return { ...prev, buyers };
|
|
2113
|
+
});
|
|
2114
|
+
},
|
|
2115
|
+
[address]
|
|
2116
|
+
);
|
|
2117
|
+
const handleImportBuyerFromPrivateKey = (0, import_react.useCallback)(
|
|
2118
|
+
async (rawPrivateKey) => {
|
|
2119
|
+
if (!address) {
|
|
2120
|
+
setState(
|
|
2121
|
+
(prev) => withDerivedStatus(prev, { error: "Connect your wallet before importing a signer key" }, true)
|
|
2122
|
+
);
|
|
2123
|
+
return null;
|
|
2124
|
+
}
|
|
2125
|
+
const trimmed = rawPrivateKey.trim();
|
|
2126
|
+
const normalized = trimmed.startsWith("0x") ? trimmed : `0x${trimmed}`;
|
|
2127
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(normalized)) {
|
|
2128
|
+
setState(
|
|
2129
|
+
(prev) => withDerivedStatus(
|
|
2130
|
+
prev,
|
|
2131
|
+
{ error: "Invalid private key format \u2014 expected 0x followed by 64 hex characters" },
|
|
2132
|
+
true
|
|
2133
|
+
)
|
|
2134
|
+
);
|
|
2135
|
+
return null;
|
|
2136
|
+
}
|
|
2137
|
+
try {
|
|
2138
|
+
const privateKey = normalized;
|
|
2139
|
+
const buyerAccount = (0, import_accounts4.privateKeyToAccount)(privateKey);
|
|
2140
|
+
upsertBuyerKey(address, buyerAccount.address, { privateKey }, { setActive: true });
|
|
2141
|
+
const buyers = mergeBuyerAddressList(
|
|
2142
|
+
listKnownBuyerAddresses(address),
|
|
2143
|
+
buyerAccount.address
|
|
2144
|
+
);
|
|
2145
|
+
const buyerFields = buildBuyerStateFields(address, buyers, buyerAccount.address);
|
|
1641
2146
|
setState(
|
|
1642
2147
|
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
1643
|
-
|
|
2148
|
+
...buyerFields,
|
|
2149
|
+
operatorAddress: null,
|
|
2150
|
+
currentOperator: null,
|
|
2151
|
+
totalCreditUsd: null,
|
|
2152
|
+
withdrawableUsd: null,
|
|
2153
|
+
totalGdDepositedG: null,
|
|
2154
|
+
monthlyStreamG: null,
|
|
1644
2155
|
error: null,
|
|
1645
|
-
...!
|
|
2156
|
+
...!isNonBuyTab(prev.activeTab) ? { status: "purchase_setup" } : {}
|
|
1646
2157
|
})
|
|
1647
2158
|
);
|
|
2159
|
+
try {
|
|
2160
|
+
const view = await buildAccountView(address, backendClient, chainClient, {
|
|
2161
|
+
buyerAddress: buyerAccount.address
|
|
2162
|
+
});
|
|
2163
|
+
const enriched = await enrichAccountView(view, chainClient);
|
|
2164
|
+
const accountPatch = viewToStatePatch(view, enriched, INITIAL_STATE, {
|
|
2165
|
+
balanceMode: "always"
|
|
2166
|
+
});
|
|
2167
|
+
if (accountPatch.operatorConsented !== void 0) {
|
|
2168
|
+
setBuyerOperatorConsented(
|
|
2169
|
+
address,
|
|
2170
|
+
buyerAccount.address,
|
|
2171
|
+
accountPatch.operatorConsented
|
|
2172
|
+
);
|
|
2173
|
+
}
|
|
2174
|
+
const nextBuyerFields = buildBuyerStateFields(
|
|
2175
|
+
address,
|
|
2176
|
+
buyers,
|
|
2177
|
+
buyerAccount.address
|
|
2178
|
+
);
|
|
2179
|
+
setState(
|
|
2180
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2181
|
+
...accountPatch,
|
|
2182
|
+
...nextBuyerFields,
|
|
2183
|
+
operatorConsented: accountPatch.operatorConsented ?? nextBuyerFields.operatorConsented,
|
|
2184
|
+
error: null
|
|
2185
|
+
})
|
|
2186
|
+
);
|
|
2187
|
+
} catch {
|
|
2188
|
+
return buyerAccount.address;
|
|
2189
|
+
}
|
|
2190
|
+
return buyerAccount.address;
|
|
2191
|
+
} catch {
|
|
2192
|
+
setState(
|
|
2193
|
+
(prev) => withDerivedStatus(prev, { error: "Could not derive an account from the provided private key" }, true)
|
|
2194
|
+
);
|
|
2195
|
+
return null;
|
|
2196
|
+
}
|
|
2197
|
+
},
|
|
2198
|
+
[address, backendClient, chainClient]
|
|
2199
|
+
);
|
|
2200
|
+
const resolveBuyerList = (0, import_react.useCallback)(
|
|
2201
|
+
(payer, preferredBuyer) => resolveLocalBuyers(payer, preferredBuyer),
|
|
2202
|
+
[]
|
|
2203
|
+
);
|
|
2204
|
+
const handleApplyDeepLinkBuyer = (0, import_react.useCallback)(
|
|
2205
|
+
async (buyerAddress, operatorSignature) => {
|
|
2206
|
+
if (!address) {
|
|
1648
2207
|
return;
|
|
1649
2208
|
}
|
|
1650
|
-
const
|
|
1651
|
-
|
|
1652
|
-
|
|
2209
|
+
const trimmedAddress = buyerAddress.trim();
|
|
2210
|
+
const trimmedSignature = operatorSignature.trim();
|
|
2211
|
+
if (!isValidBuyerAddress(trimmedAddress)) {
|
|
2212
|
+
setState(
|
|
2213
|
+
(prev) => withDerivedStatus(
|
|
2214
|
+
prev,
|
|
2215
|
+
{
|
|
2216
|
+
error: deepLinkManualFallbackMessage("Deep-link buyerAddress is invalid."),
|
|
2217
|
+
activeTab: "buy",
|
|
2218
|
+
status: "purchase_setup"
|
|
2219
|
+
},
|
|
2220
|
+
true
|
|
2221
|
+
)
|
|
2222
|
+
);
|
|
2223
|
+
return;
|
|
1653
2224
|
}
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
2225
|
+
if (!isValidOperatorSignature(trimmedSignature)) {
|
|
2226
|
+
setState(
|
|
2227
|
+
(prev) => withDerivedStatus(
|
|
2228
|
+
prev,
|
|
2229
|
+
{
|
|
2230
|
+
error: deepLinkManualFallbackMessage("Deep-link operatorSignature is invalid."),
|
|
2231
|
+
activeTab: "buy",
|
|
2232
|
+
status: "purchase_setup"
|
|
2233
|
+
},
|
|
2234
|
+
true
|
|
2235
|
+
)
|
|
2236
|
+
);
|
|
2237
|
+
return;
|
|
2238
|
+
}
|
|
2239
|
+
storeDeepLinkParams({
|
|
2240
|
+
buyerAddress: trimmedAddress,
|
|
2241
|
+
operatorSignature: trimmedSignature
|
|
1661
2242
|
});
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
2243
|
+
upsertBuyerKey(
|
|
2244
|
+
address,
|
|
2245
|
+
trimmedAddress,
|
|
2246
|
+
{ operatorSignature: trimmedSignature },
|
|
2247
|
+
{ setActive: true }
|
|
2248
|
+
);
|
|
2249
|
+
const buyers = mergeBuyerAddressList(listKnownBuyerAddresses(address), trimmedAddress);
|
|
2250
|
+
const buyerFields = buildBuyerStateFields(address, buyers, trimmedAddress);
|
|
2251
|
+
setState(
|
|
2252
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2253
|
+
...buyerFields,
|
|
2254
|
+
operatorAddress: null,
|
|
2255
|
+
currentOperator: null,
|
|
2256
|
+
totalCreditUsd: null,
|
|
2257
|
+
withdrawableUsd: null,
|
|
2258
|
+
totalGdDepositedG: null,
|
|
2259
|
+
monthlyStreamG: null,
|
|
2260
|
+
activeTab: "buy",
|
|
2261
|
+
operatorConsentPending: false,
|
|
2262
|
+
error: null
|
|
2263
|
+
})
|
|
2264
|
+
);
|
|
2265
|
+
},
|
|
2266
|
+
[address]
|
|
2267
|
+
);
|
|
2268
|
+
const handleSignOperatorConsent = (0, import_react.useCallback)(async () => {
|
|
2269
|
+
const currentState = state;
|
|
2270
|
+
if (!currentState.address || !currentState.buyerPubKey) {
|
|
2271
|
+
setState(
|
|
2272
|
+
(prev) => withDerivedStatus(
|
|
2273
|
+
prev,
|
|
2274
|
+
{ error: "Select a buyer before authorizing your wallet" },
|
|
2275
|
+
true
|
|
2276
|
+
)
|
|
2277
|
+
);
|
|
2278
|
+
return;
|
|
2279
|
+
}
|
|
2280
|
+
const keyEntry = getBuyerKeyEntry(currentState.address, currentState.buyerPubKey);
|
|
2281
|
+
const storedOperatorSignature = currentState.operatorSignature ?? keyEntry?.operatorSignature ?? null;
|
|
2282
|
+
if (!currentState.buyerPrvKey && !storedOperatorSignature) {
|
|
2283
|
+
setState(
|
|
2284
|
+
(prev) => withDerivedStatus(
|
|
2285
|
+
prev,
|
|
2286
|
+
{ error: "Generate a signer key before authorizing your wallet" },
|
|
2287
|
+
true
|
|
2288
|
+
)
|
|
2289
|
+
);
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
if (currentState.operatorConsentPending) return;
|
|
2293
|
+
const ref = { payer: currentState.address, buyer: currentState.buyerPubKey };
|
|
2294
|
+
const onNonBuyTab = isNonBuyTab(currentState.activeTab);
|
|
2295
|
+
setState((prev) => ({
|
|
2296
|
+
...prev,
|
|
2297
|
+
operatorConsentPending: true,
|
|
2298
|
+
error: null
|
|
2299
|
+
}));
|
|
2300
|
+
try {
|
|
2301
|
+
const operatorStatus = await chainClient.getBuyerOperatorStatus(ref);
|
|
2302
|
+
if (!operatorStatus.enabled) {
|
|
2303
|
+
throw new Error("Operator consent is not available");
|
|
2304
|
+
}
|
|
2305
|
+
const hasDifferentOperator = operatorStatus.currentOperator !== "0x0000000000000000000000000000000000000000" && !operatorStatus.operatorAccepted;
|
|
2306
|
+
if (hasDifferentOperator) {
|
|
2307
|
+
throw new Error(
|
|
2308
|
+
"This signer key is already controlled by another operator. Import a different signer key or generate a new one."
|
|
2309
|
+
);
|
|
2310
|
+
}
|
|
2311
|
+
if (operatorStatus.operatorAccepted) {
|
|
2312
|
+
setBuyerOperatorConsented(currentState.address, currentState.buyerPubKey, true);
|
|
2313
|
+
const buyerList2 = resolveBuyerList(currentState.address, currentState.buyerPubKey);
|
|
2314
|
+
const buyerFields2 = buildBuyerStateFields(
|
|
2315
|
+
currentState.address,
|
|
2316
|
+
buyerList2.buyers,
|
|
2317
|
+
buyerList2.selected
|
|
2318
|
+
);
|
|
2319
|
+
setState(
|
|
2320
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2321
|
+
...buyerFields2,
|
|
2322
|
+
operatorConsented: true,
|
|
2323
|
+
operatorConsentPending: false,
|
|
2324
|
+
error: null,
|
|
2325
|
+
...!onNonBuyTab ? { status: "purchase_setup" } : {}
|
|
2326
|
+
})
|
|
2327
|
+
);
|
|
2328
|
+
clearDeepLinkArtifacts();
|
|
2329
|
+
return;
|
|
2330
|
+
}
|
|
2331
|
+
let buyerSig;
|
|
2332
|
+
if (currentState.buyerPrvKey) {
|
|
2333
|
+
const payload = await chainClient.buildOperatorConsentPayload(ref, operatorStatus);
|
|
2334
|
+
if (!payload.enabled || !payload.typedData) {
|
|
2335
|
+
throw new Error("Operator consent is not available");
|
|
2336
|
+
}
|
|
2337
|
+
buyerSig = await signOperatorConsentFromTypedData(
|
|
2338
|
+
currentState.buyerPrvKey,
|
|
2339
|
+
payload.typedData
|
|
2340
|
+
);
|
|
2341
|
+
} else if (storedOperatorSignature) {
|
|
2342
|
+
buyerSig = storedOperatorSignature;
|
|
2343
|
+
} else {
|
|
2344
|
+
throw new Error("Generate a signer key before authorizing your wallet");
|
|
2345
|
+
}
|
|
2346
|
+
await backendClient.submitOperatorConsent(ref.buyer, {
|
|
2347
|
+
nonce: operatorStatus.consentNonce,
|
|
2348
|
+
signature: buyerSig
|
|
2349
|
+
});
|
|
2350
|
+
await waitForOperatorConsent(chainClient, ref);
|
|
2351
|
+
setBuyerOperatorConsented(currentState.address, currentState.buyerPubKey, true);
|
|
2352
|
+
const buyerList = resolveBuyerList(currentState.address, currentState.buyerPubKey);
|
|
2353
|
+
const buyerFields = buildBuyerStateFields(
|
|
2354
|
+
currentState.address,
|
|
2355
|
+
buyerList.buyers,
|
|
2356
|
+
buyerList.selected
|
|
2357
|
+
);
|
|
2358
|
+
setState(
|
|
1665
2359
|
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2360
|
+
...buyerFields,
|
|
1666
2361
|
operatorConsented: true,
|
|
2362
|
+
operatorConsentPending: false,
|
|
1667
2363
|
error: null,
|
|
1668
2364
|
...!onNonBuyTab ? { status: "purchase_setup" } : {}
|
|
1669
2365
|
})
|
|
1670
2366
|
);
|
|
2367
|
+
clearDeepLinkArtifacts();
|
|
1671
2368
|
} catch (err) {
|
|
1672
2369
|
setState((prev) => ({
|
|
1673
2370
|
...prev,
|
|
2371
|
+
operatorConsentPending: false,
|
|
1674
2372
|
error: err instanceof Error ? err.message : "Operator consent signature rejected"
|
|
1675
2373
|
}));
|
|
1676
2374
|
}
|
|
1677
|
-
}, [state, backendClient, chainClient]);
|
|
2375
|
+
}, [state, backendClient, chainClient, resolveBuyerList]);
|
|
1678
2376
|
const handleSyncOperatorConsentFromChain = (0, import_react.useCallback)(async () => {
|
|
1679
2377
|
const currentState = state;
|
|
1680
2378
|
if (!currentState.address || !currentState.buyerPubKey || currentState.operatorConsented) {
|
|
@@ -1684,7 +2382,7 @@ function useAiCreditsAdapter({
|
|
|
1684
2382
|
const ref = { payer: currentState.address, buyer: currentState.buyerPubKey };
|
|
1685
2383
|
const operatorStatus = await chainClient.getBuyerOperatorStatus(ref);
|
|
1686
2384
|
if (!operatorStatus.operatorAccepted) return;
|
|
1687
|
-
|
|
2385
|
+
setBuyerOperatorConsented(currentState.address, currentState.buyerPubKey, true);
|
|
1688
2386
|
const onNonBuyTab = isNonBuyTab(currentState.activeTab);
|
|
1689
2387
|
setState(
|
|
1690
2388
|
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
@@ -1716,7 +2414,7 @@ function useAiCreditsAdapter({
|
|
|
1716
2414
|
async (quote) => {
|
|
1717
2415
|
const currentState = state;
|
|
1718
2416
|
if (!currentState.address || !currentState.buyerPubKey || !providerRef.current) {
|
|
1719
|
-
throw new Error("Connect your wallet and generate a
|
|
2417
|
+
throw new Error("Connect your wallet and generate a signer key before paying");
|
|
1720
2418
|
}
|
|
1721
2419
|
const hasDeposit = Number.parseFloat(quote.depositAmountG) > 0;
|
|
1722
2420
|
const streamChanged = isStreamAmountChanged(quote.streamAmountG, currentState.monthlyStreamG);
|
|
@@ -1822,8 +2520,15 @@ function useAiCreditsAdapter({
|
|
|
1822
2520
|
previousBalance: balanceBefore
|
|
1823
2521
|
});
|
|
1824
2522
|
const creditUsdMicro = (BigInt(totalCreditUsd) - BigInt(balanceBefore || "0")).toString();
|
|
2523
|
+
const buyerList = resolveBuyerList(currentState.address, currentState.buyerPubKey);
|
|
2524
|
+
const buyerFields = buildBuyerStateFields(
|
|
2525
|
+
currentState.address,
|
|
2526
|
+
buyerList.buyers,
|
|
2527
|
+
buyerList.selected
|
|
2528
|
+
);
|
|
1825
2529
|
setState(
|
|
1826
2530
|
(prev) => withDerivedStatus(prev, {
|
|
2531
|
+
...buyerFields,
|
|
1827
2532
|
totalCreditUsd,
|
|
1828
2533
|
error: null,
|
|
1829
2534
|
activeTab: "manage"
|
|
@@ -1858,6 +2563,7 @@ function useAiCreditsAdapter({
|
|
|
1858
2563
|
celoVault,
|
|
1859
2564
|
onPaySuccess,
|
|
1860
2565
|
onPayError,
|
|
2566
|
+
resolveBuyerList,
|
|
1861
2567
|
prepareSettlement,
|
|
1862
2568
|
skipVaultPaymentValidation
|
|
1863
2569
|
]
|
|
@@ -1867,36 +2573,38 @@ function useAiCreditsAdapter({
|
|
|
1867
2573
|
const currentState = state;
|
|
1868
2574
|
if (!currentState.address) return;
|
|
1869
2575
|
try {
|
|
1870
|
-
const
|
|
2576
|
+
const preferredBuyer = currentState.buyerPubKey;
|
|
2577
|
+
const buyerList = resolveBuyerList(currentState.address, preferredBuyer);
|
|
1871
2578
|
const [view, discountConfig] = await Promise.all([
|
|
1872
2579
|
buildAccountView(currentState.address, backendClient, chainClient, {
|
|
1873
|
-
buyerAddress:
|
|
2580
|
+
buyerAddress: preferredBuyer
|
|
1874
2581
|
}),
|
|
1875
2582
|
backendClient.getDiscountConfig().catch(() => null)
|
|
1876
2583
|
]);
|
|
1877
2584
|
const enriched = await enrichAccountView(view, chainClient);
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
accountPatch
|
|
1886
|
-
false
|
|
2585
|
+
const accountPatch = viewToStatePatch(view, enriched, INITIAL_STATE, {
|
|
2586
|
+
balanceMode: "always"
|
|
2587
|
+
});
|
|
2588
|
+
if (preferredBuyer && accountPatch.operatorConsented !== void 0 && currentState.address) {
|
|
2589
|
+
setBuyerOperatorConsented(
|
|
2590
|
+
currentState.address,
|
|
2591
|
+
preferredBuyer,
|
|
2592
|
+
accountPatch.operatorConsented
|
|
1887
2593
|
);
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
2594
|
+
}
|
|
2595
|
+
const buyerFields = buildBuyerStateFields(
|
|
2596
|
+
currentState.address,
|
|
2597
|
+
buyerList.buyers,
|
|
2598
|
+
buyerList.selected
|
|
2599
|
+
);
|
|
2600
|
+
setState((prev) => {
|
|
1894
2601
|
const statusSeed = options?.afterGoodIdVerify && prev.status === "payment_failed" ? "quote_ready" : prev.status === "backend_unavailable" ? "purchase_setup" : prev.status;
|
|
1895
2602
|
return withDerivedStatus(
|
|
1896
2603
|
{ ...prev, status: statusSeed },
|
|
1897
2604
|
{
|
|
1898
2605
|
...accountPatch,
|
|
1899
|
-
...
|
|
2606
|
+
...buyerFields,
|
|
2607
|
+
operatorConsented: accountPatch.operatorConsented ?? buyerFields.operatorConsented,
|
|
1900
2608
|
activeTab: prev.activeTab,
|
|
1901
2609
|
error: null,
|
|
1902
2610
|
depositBonusPercent: discountConfig?.depositBonusPercent ?? prev.depositBonusPercent,
|
|
@@ -1914,7 +2622,7 @@ function useAiCreditsAdapter({
|
|
|
1914
2622
|
);
|
|
1915
2623
|
}
|
|
1916
2624
|
},
|
|
1917
|
-
[state, backendClient, chainClient]
|
|
2625
|
+
[state, backendClient, chainClient, resolveBuyerList]
|
|
1918
2626
|
);
|
|
1919
2627
|
const handleVerifyGoodId = (0, import_react.useCallback)(async () => {
|
|
1920
2628
|
const currentState = state;
|
|
@@ -1985,7 +2693,7 @@ function useAiCreditsAdapter({
|
|
|
1985
2693
|
if (!currentState.buyerPrvKey) {
|
|
1986
2694
|
setState((prev) => ({
|
|
1987
2695
|
...prev,
|
|
1988
|
-
error: "Sign with your payer wallet in
|
|
2696
|
+
error: "Sign with your payer wallet in Signer Key below to generate the buyer private key before closing a channel"
|
|
1989
2697
|
}));
|
|
1990
2698
|
return;
|
|
1991
2699
|
}
|
|
@@ -2022,7 +2730,7 @@ function useAiCreditsAdapter({
|
|
|
2022
2730
|
if (!currentState.buyerPrvKey) {
|
|
2023
2731
|
setState((prev) => ({
|
|
2024
2732
|
...prev,
|
|
2025
|
-
error: "Sign with your payer wallet in
|
|
2733
|
+
error: "Sign with your payer wallet in Signer Key below to generate the buyer private key before withdrawing funds"
|
|
2026
2734
|
}));
|
|
2027
2735
|
return;
|
|
2028
2736
|
}
|
|
@@ -2088,22 +2796,76 @@ function useAiCreditsAdapter({
|
|
|
2088
2796
|
await handleRefresh();
|
|
2089
2797
|
}, [configurationError, handleRefresh]);
|
|
2090
2798
|
const handleSetActiveTab = (0, import_react.useCallback)((tab) => {
|
|
2091
|
-
|
|
2799
|
+
setState((prev) => {
|
|
2800
|
+
if (needsWalletConnection(prev)) {
|
|
2801
|
+
if (tab === "setup") {
|
|
2802
|
+
return mergeStatePreservingNonBuyTab(prev, { activeTab: "setup", error: null });
|
|
2803
|
+
}
|
|
2804
|
+
return prev;
|
|
2805
|
+
}
|
|
2806
|
+
if (tab === "buy") {
|
|
2807
|
+
return withDerivedStatus(prev, { activeTab: "buy", status: "purchase_setup", error: null }, true);
|
|
2808
|
+
}
|
|
2809
|
+
return mergeStatePreservingNonBuyTab(prev, { activeTab: tab, error: null });
|
|
2810
|
+
});
|
|
2811
|
+
}, []);
|
|
2812
|
+
const handleStartPurchase = (0, import_react.useCallback)(() => {
|
|
2813
|
+
handleSetActiveTab("buy");
|
|
2814
|
+
}, [handleSetActiveTab]);
|
|
2815
|
+
(0, import_react.useEffect)(() => {
|
|
2816
|
+
if (typeof window === "undefined" || deepLinkParseDoneRef.current) return;
|
|
2817
|
+
deepLinkParseDoneRef.current = true;
|
|
2818
|
+
const parsed = resolveDeepLinkParams(window.location.search);
|
|
2819
|
+
if (parsed.status === "absent") return;
|
|
2820
|
+
if (parsed.status === "partial") {
|
|
2821
|
+
const missing = parsed.present === "buyerAddress" ? "operatorSignature" : "buyerAddress";
|
|
2822
|
+
setState(
|
|
2823
|
+
(prev) => withDerivedStatus(
|
|
2824
|
+
prev,
|
|
2825
|
+
{
|
|
2826
|
+
error: deepLinkManualFallbackMessage(`Deep link is missing ${missing}.`),
|
|
2827
|
+
activeTab: "buy",
|
|
2828
|
+
status: "purchase_setup"
|
|
2829
|
+
},
|
|
2830
|
+
false
|
|
2831
|
+
)
|
|
2832
|
+
);
|
|
2833
|
+
return;
|
|
2834
|
+
}
|
|
2835
|
+
if (parsed.status === "invalid") {
|
|
2092
2836
|
setState(
|
|
2093
|
-
(prev) => withDerivedStatus(
|
|
2837
|
+
(prev) => withDerivedStatus(
|
|
2838
|
+
prev,
|
|
2839
|
+
{
|
|
2840
|
+
error: deepLinkManualFallbackMessage(`${parsed.reason}.`),
|
|
2841
|
+
activeTab: "buy",
|
|
2842
|
+
status: "purchase_setup"
|
|
2843
|
+
},
|
|
2844
|
+
false
|
|
2845
|
+
)
|
|
2094
2846
|
);
|
|
2095
2847
|
return;
|
|
2096
2848
|
}
|
|
2097
|
-
|
|
2849
|
+
pendingDeepLinkRef.current = parsed.value;
|
|
2098
2850
|
}, []);
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2851
|
+
(0, import_react.useEffect)(() => {
|
|
2852
|
+
const pending = pendingDeepLinkRef.current;
|
|
2853
|
+
if (!address || !pending || deepLinkApplyInFlightRef.current) return;
|
|
2854
|
+
deepLinkApplyInFlightRef.current = true;
|
|
2855
|
+
void handleApplyDeepLinkBuyer(pending.buyerAddress, pending.operatorSignature).finally(() => {
|
|
2856
|
+
deepLinkApplyInFlightRef.current = false;
|
|
2857
|
+
pendingDeepLinkRef.current = null;
|
|
2858
|
+
});
|
|
2859
|
+
}, [address, handleApplyDeepLinkBuyer]);
|
|
2102
2860
|
const actions = (0, import_react.useMemo)(
|
|
2103
2861
|
() => ({
|
|
2104
2862
|
connect: handleConnect,
|
|
2105
2863
|
switchChain: handleSwitchChain,
|
|
2106
2864
|
generateBuyerKey: handleGenerateBuyerKey,
|
|
2865
|
+
selectBuyer: handleSelectBuyer,
|
|
2866
|
+
discoverBuyers: handleDiscoverBuyers,
|
|
2867
|
+
importBuyerFromPrivateKey: handleImportBuyerFromPrivateKey,
|
|
2868
|
+
applyDeepLinkBuyer: handleApplyDeepLinkBuyer,
|
|
2107
2869
|
signOperatorConsent: handleSignOperatorConsent,
|
|
2108
2870
|
syncOperatorConsentFromChain: handleSyncOperatorConsentFromChain,
|
|
2109
2871
|
buildQuote: handleBuildQuote,
|
|
@@ -2120,6 +2882,10 @@ function useAiCreditsAdapter({
|
|
|
2120
2882
|
handleConnect,
|
|
2121
2883
|
handleSwitchChain,
|
|
2122
2884
|
handleGenerateBuyerKey,
|
|
2885
|
+
handleSelectBuyer,
|
|
2886
|
+
handleDiscoverBuyers,
|
|
2887
|
+
handleImportBuyerFromPrivateKey,
|
|
2888
|
+
handleApplyDeepLinkBuyer,
|
|
2123
2889
|
handleSignOperatorConsent,
|
|
2124
2890
|
handleSyncOperatorConsentFromChain,
|
|
2125
2891
|
handleBuildQuote,
|
|
@@ -2137,14 +2903,16 @@ function useAiCreditsAdapter({
|
|
|
2137
2903
|
}
|
|
2138
2904
|
|
|
2139
2905
|
// src/AiCreditsWidget.tsx
|
|
2140
|
-
var
|
|
2906
|
+
var import_react17 = __toESM(require("react"), 1);
|
|
2141
2907
|
var import_core2 = require("@goodwidget/core");
|
|
2142
|
-
var
|
|
2908
|
+
var import_ui21 = require("@goodwidget/ui");
|
|
2143
2909
|
|
|
2144
2910
|
// src/useAiCreditsHistory.ts
|
|
2145
2911
|
var import_react2 = require("react");
|
|
2146
2912
|
var HISTORY_PAGE_SIZE = 10;
|
|
2147
2913
|
var HISTORY_LOOKBACK_DAYS = 90;
|
|
2914
|
+
var BUYER_FILTER_FILL_MAX_PAGES = 8;
|
|
2915
|
+
var BUYER_FILTER_ALL = "all";
|
|
2148
2916
|
var HISTORY_SOURCE_OPTIONS = [
|
|
2149
2917
|
{ id: "deposit", label: "Deposit", defaultChecked: true },
|
|
2150
2918
|
{ id: "streamUpdate", label: "Stream update", defaultChecked: true },
|
|
@@ -2180,11 +2948,23 @@ function toIsoEndOfDay(dateValue) {
|
|
|
2180
2948
|
if (Number.isNaN(parsed)) return void 0;
|
|
2181
2949
|
return new Date(parsed).toISOString();
|
|
2182
2950
|
}
|
|
2951
|
+
function matchesBuyerFilter(entry, filter) {
|
|
2952
|
+
if (filter === BUYER_FILTER_ALL) return true;
|
|
2953
|
+
return entry.buyerAddress?.toLowerCase() === filter.toLowerCase();
|
|
2954
|
+
}
|
|
2183
2955
|
function useAiCreditsHistory(options) {
|
|
2184
|
-
const {
|
|
2956
|
+
const {
|
|
2957
|
+
address,
|
|
2958
|
+
backendUrl,
|
|
2959
|
+
defaultBuyerFilter = BUYER_FILTER_ALL,
|
|
2960
|
+
environment = "production",
|
|
2961
|
+
backendClient,
|
|
2962
|
+
onBuyersDiscovered
|
|
2963
|
+
} = options;
|
|
2185
2964
|
const defaultRange = (0, import_react2.useMemo)(() => getLast90DaysRange(), []);
|
|
2186
2965
|
const [selectedSources, setSelectedSources] = (0, import_react2.useState)(createDefaultSelectedSources);
|
|
2187
2966
|
const [statusFilter, setStatusFilter] = (0, import_react2.useState)("all");
|
|
2967
|
+
const [buyerAddressFilter, setBuyerAddressFilter] = (0, import_react2.useState)(defaultBuyerFilter);
|
|
2188
2968
|
const [fromDate, setFromDate] = (0, import_react2.useState)(defaultRange.from);
|
|
2189
2969
|
const [toDate, setToDate] = (0, import_react2.useState)(defaultRange.to);
|
|
2190
2970
|
const [entries, setEntries] = (0, import_react2.useState)([]);
|
|
@@ -2193,6 +2973,9 @@ function useAiCreditsHistory(options) {
|
|
|
2193
2973
|
const [loading, setLoading] = (0, import_react2.useState)(false);
|
|
2194
2974
|
const [loadingMore, setLoadingMore] = (0, import_react2.useState)(false);
|
|
2195
2975
|
const [error, setError] = (0, import_react2.useState)(null);
|
|
2976
|
+
(0, import_react2.useEffect)(() => {
|
|
2977
|
+
setBuyerAddressFilter(defaultBuyerFilter);
|
|
2978
|
+
}, [defaultBuyerFilter]);
|
|
2196
2979
|
const activeSources = (0, import_react2.useMemo)(
|
|
2197
2980
|
() => HISTORY_SOURCE_OPTIONS.map((option) => option.id).filter((id) => selectedSources[id]),
|
|
2198
2981
|
[selectedSources]
|
|
@@ -2200,12 +2983,12 @@ function useAiCreditsHistory(options) {
|
|
|
2200
2983
|
const loadHistory = (0, import_react2.useCallback)(
|
|
2201
2984
|
async (nextOffset, append) => {
|
|
2202
2985
|
if (!address) {
|
|
2203
|
-
setEntries([]);
|
|
2204
|
-
setOffset(0);
|
|
2205
|
-
setHasMore(false);
|
|
2206
|
-
setError(null);
|
|
2207
|
-
setLoading(false);
|
|
2208
|
-
setLoadingMore(false);
|
|
2986
|
+
setEntries((prev) => prev.length === 0 ? prev : []);
|
|
2987
|
+
setOffset((prev) => prev === 0 ? prev : 0);
|
|
2988
|
+
setHasMore((prev) => prev ? false : prev);
|
|
2989
|
+
setError((prev) => prev === null ? prev : null);
|
|
2990
|
+
setLoading((prev) => prev ? false : prev);
|
|
2991
|
+
setLoadingMore((prev) => prev ? false : prev);
|
|
2209
2992
|
return;
|
|
2210
2993
|
}
|
|
2211
2994
|
if (activeSources.length === 0) {
|
|
@@ -2223,19 +3006,38 @@ function useAiCreditsHistory(options) {
|
|
|
2223
3006
|
const client = backendClient ?? createBackendClient(backendUrl);
|
|
2224
3007
|
const apiSource = activeSources.length === 1 ? activeSources[0] : void 0;
|
|
2225
3008
|
const fundingStatus = statusFilter === "all" ? void 0 : statusFilter;
|
|
3009
|
+
const filterByBuyer = buyerAddressFilter !== BUYER_FILTER_ALL;
|
|
2226
3010
|
try {
|
|
2227
|
-
const
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
3011
|
+
const collected = [];
|
|
3012
|
+
let cursor = nextOffset;
|
|
3013
|
+
let apiHasMore = true;
|
|
3014
|
+
let pages = 0;
|
|
3015
|
+
while (pages < BUYER_FILTER_FILL_MAX_PAGES && collected.length < HISTORY_PAGE_SIZE && apiHasMore) {
|
|
3016
|
+
const response = await client.getCreditHistory(address, {
|
|
3017
|
+
limit: HISTORY_PAGE_SIZE,
|
|
3018
|
+
offset: cursor,
|
|
3019
|
+
source: apiSource,
|
|
3020
|
+
fundingStatus,
|
|
3021
|
+
from: toIsoStartOfDay(fromDate),
|
|
3022
|
+
to: toIsoEndOfDay(toDate)
|
|
3023
|
+
});
|
|
3024
|
+
const sourceFiltered = activeSources.length === 1 ? response.items : response.items.filter((entry) => selectedSources[entry.source]);
|
|
3025
|
+
const discoveredBuyers = sourceFiltered.map((entry) => entry.buyerAddress).filter((value) => Boolean(value));
|
|
3026
|
+
if (discoveredBuyers.length > 0) {
|
|
3027
|
+
onBuyersDiscovered?.(discoveredBuyers);
|
|
3028
|
+
}
|
|
3029
|
+
const buyerFiltered = sourceFiltered.filter(
|
|
3030
|
+
(entry) => matchesBuyerFilter(entry, buyerAddressFilter)
|
|
3031
|
+
);
|
|
3032
|
+
collected.push(...buyerFiltered);
|
|
3033
|
+
apiHasMore = response.hasMore;
|
|
3034
|
+
cursor = response.offset + response.limit;
|
|
3035
|
+
pages += 1;
|
|
3036
|
+
if (!filterByBuyer) break;
|
|
3037
|
+
}
|
|
3038
|
+
setEntries((prev) => append ? [...prev, ...collected] : collected);
|
|
3039
|
+
setOffset(cursor);
|
|
3040
|
+
setHasMore(apiHasMore);
|
|
2239
3041
|
} catch (err) {
|
|
2240
3042
|
if (!append) setEntries([]);
|
|
2241
3043
|
setHasMore(false);
|
|
@@ -2252,9 +3054,11 @@ function useAiCreditsHistory(options) {
|
|
|
2252
3054
|
backendClient,
|
|
2253
3055
|
activeSources,
|
|
2254
3056
|
statusFilter,
|
|
3057
|
+
buyerAddressFilter,
|
|
2255
3058
|
fromDate,
|
|
2256
3059
|
toDate,
|
|
2257
|
-
selectedSources
|
|
3060
|
+
selectedSources,
|
|
3061
|
+
onBuyersDiscovered
|
|
2258
3062
|
]
|
|
2259
3063
|
);
|
|
2260
3064
|
(0, import_react2.useEffect)(() => {
|
|
@@ -2272,12 +3076,13 @@ function useAiCreditsHistory(options) {
|
|
|
2272
3076
|
await loadHistory(0, false);
|
|
2273
3077
|
}, [loadHistory]);
|
|
2274
3078
|
const loadMore = (0, import_react2.useCallback)(async () => {
|
|
2275
|
-
await loadHistory(offset
|
|
3079
|
+
await loadHistory(offset, true);
|
|
2276
3080
|
}, [loadHistory, offset]);
|
|
2277
3081
|
return {
|
|
2278
3082
|
state: {
|
|
2279
3083
|
selectedSources,
|
|
2280
3084
|
statusFilter,
|
|
3085
|
+
buyerAddressFilter,
|
|
2281
3086
|
fromDate,
|
|
2282
3087
|
toDate,
|
|
2283
3088
|
entries,
|
|
@@ -2291,6 +3096,7 @@ function useAiCreditsHistory(options) {
|
|
|
2291
3096
|
actions: {
|
|
2292
3097
|
setSourceChecked,
|
|
2293
3098
|
setStatusFilter,
|
|
3099
|
+
setBuyerAddressFilter,
|
|
2294
3100
|
setFromDate,
|
|
2295
3101
|
setToDate,
|
|
2296
3102
|
reload,
|
|
@@ -2389,8 +3195,8 @@ function BuyerKeyPanel({
|
|
|
2389
3195
|
}
|
|
2390
3196
|
const Shell = embedded ? import_ui4.YStack : import_ui4.Card;
|
|
2391
3197
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Shell, { gap: "$3", children: [
|
|
2392
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui4.Heading, { level: 5, children: "
|
|
2393
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui4.Text, { children: "Sign a message with your payer wallet to derive a
|
|
3198
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui4.Heading, { level: 5, children: "Signer Key" }),
|
|
3199
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui4.Text, { children: "Sign a message with your payer wallet to derive a dedicated AntSeed signer key. Save the private key \u2014 you will need it to authenticate from your developer tools." }),
|
|
2394
3200
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui4.YStack, { gap: "$3", children: [
|
|
2395
3201
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2396
3202
|
import_ui4.Button,
|
|
@@ -2426,6 +3232,7 @@ function BuyerKeyPanel({
|
|
|
2426
3232
|
}
|
|
2427
3233
|
),
|
|
2428
3234
|
buyerPrvKey && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
3235
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AiCreditsStatusNotice, { borderColor: "$warning", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui4.Text, { color: "$warning", fontSize: "$2", children: "Back up any existing AntSeed signer key before importing this one. Importing replaces the signer used by your AntSeed account." }) }),
|
|
2429
3236
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui4.XStack, { justifyContent: "space-between", alignItems: "center", children: [
|
|
2430
3237
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui4.Text, { variant: "label", secondary: true, children: "Private Key \u2014 save this securely" }),
|
|
2431
3238
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -2470,7 +3277,8 @@ function BuyerKeyPanel({
|
|
|
2470
3277
|
)
|
|
2471
3278
|
]
|
|
2472
3279
|
}
|
|
2473
|
-
)
|
|
3280
|
+
),
|
|
3281
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui4.Text, { fontSize: "$2", secondary: true, children: "In AntSeed, open Settings \u2192 Signer key and import this private key. The public address above is the signer identity used for AI credits." })
|
|
2474
3282
|
] }),
|
|
2475
3283
|
buyerPrvKey && !buyerPubKeySaved && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui4.Button, { size: "sm", ...compactButtonProps, onPress: onConfirm, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui4.ButtonText, { children: "I've Saved My Private Key" }) }),
|
|
2476
3284
|
buyerPubKeySaved && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui4.XStack, { gap: "$2", alignItems: "center", children: [
|
|
@@ -2483,22 +3291,23 @@ function BuyerKeyPanel({
|
|
|
2483
3291
|
}
|
|
2484
3292
|
|
|
2485
3293
|
// src/components/buy/OperatorConsentStep.tsx
|
|
2486
|
-
var import_react5 = require("react");
|
|
2487
3294
|
var import_ui5 = require("@goodwidget/ui");
|
|
2488
3295
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2489
3296
|
function OperatorConsentStep({
|
|
2490
3297
|
buyerPubKey,
|
|
2491
3298
|
buyerPrvKey,
|
|
3299
|
+
operatorSignature = null,
|
|
2492
3300
|
operatorConsented,
|
|
3301
|
+
operatorConsentPending = false,
|
|
2493
3302
|
onSign,
|
|
2494
3303
|
embedded = false
|
|
2495
3304
|
}) {
|
|
2496
|
-
const
|
|
2497
|
-
const
|
|
3305
|
+
const canSign = Boolean(buyerPubKey && (buyerPrvKey || operatorSignature));
|
|
3306
|
+
const isBusy = operatorConsentPending;
|
|
2498
3307
|
const Shell = embedded ? import_ui5.YStack : import_ui5.Card;
|
|
2499
3308
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Shell, { gap: "$3", ...!embedded ? { backgroundColor: "$backgroundHover" } : {}, children: [
|
|
2500
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Heading, { level: 5, children: "Authorize
|
|
2501
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$2", lineHeight: "$3", children: "
|
|
3309
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Heading, { level: 5, children: "Authorize Wallet" }),
|
|
3310
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$2", lineHeight: "$3", children: "GoodDollar needs this one-time authorization to fund and manage your AI credits on Base after you pay with G$ on Celo. It lets the GoodDollar operator move funds in your separate AI credits account, but never gives access to your payer wallet or G$. Granting this permission means trusting GoodDollar with that scoped Base role; you can revoke it later through the account controls." }),
|
|
2502
3311
|
buyerPubKey && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.Text, { fontSize: "$2", lineHeight: "$2", children: [
|
|
2503
3312
|
"Buyer address:",
|
|
2504
3313
|
" ",
|
|
@@ -2506,38 +3315,35 @@ function OperatorConsentStep({
|
|
|
2506
3315
|
] }),
|
|
2507
3316
|
operatorConsented ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.XStack, { gap: "$2", alignItems: "center", children: [
|
|
2508
3317
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Icon, { name: "check", size: "sm", color: "success" }),
|
|
2509
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { color: "$success", children: "
|
|
3318
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { color: "$success", children: "Wallet authorized \u2014 ready to pay" })
|
|
2510
3319
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2511
3320
|
import_ui5.Button,
|
|
2512
3321
|
{
|
|
2513
3322
|
size: "sm",
|
|
2514
3323
|
...compactButtonProps,
|
|
2515
3324
|
onPress: () => {
|
|
2516
|
-
|
|
2517
|
-
void onSign().finally(() => {
|
|
2518
|
-
setIsSigning(false);
|
|
2519
|
-
});
|
|
3325
|
+
void onSign();
|
|
2520
3326
|
},
|
|
2521
|
-
disabled: !canSign ||
|
|
2522
|
-
children:
|
|
2523
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.ButtonText, { children: "
|
|
3327
|
+
disabled: !canSign || isBusy,
|
|
3328
|
+
children: isBusy ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.XStack, { gap: "$2", alignItems: "center", children: [
|
|
3329
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.ButtonText, { children: "Submitting\u2026" }),
|
|
2524
3330
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Spinner, { size: "sm" })
|
|
2525
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.ButtonText, { children: "
|
|
3331
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.ButtonText, { children: "Authorize Wallet" })
|
|
2526
3332
|
}
|
|
2527
3333
|
)
|
|
2528
3334
|
] });
|
|
2529
3335
|
}
|
|
2530
3336
|
|
|
2531
3337
|
// src/components/buy/AmountPicker.tsx
|
|
2532
|
-
var
|
|
3338
|
+
var import_react6 = require("react");
|
|
2533
3339
|
var import_ui7 = require("@goodwidget/ui");
|
|
2534
3340
|
|
|
2535
3341
|
// src/components/shared/tooltips.tsx
|
|
2536
|
-
var
|
|
3342
|
+
var import_react5 = require("react");
|
|
2537
3343
|
var import_ui6 = require("@goodwidget/ui");
|
|
2538
3344
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2539
3345
|
function InfoTooltip({ message }) {
|
|
2540
|
-
const [open, setOpen] = (0,
|
|
3346
|
+
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
2541
3347
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2542
3348
|
import_ui6.XStack,
|
|
2543
3349
|
{
|
|
@@ -2582,7 +3388,7 @@ function HoverTooltip({
|
|
|
2582
3388
|
children,
|
|
2583
3389
|
fullWidth = false
|
|
2584
3390
|
}) {
|
|
2585
|
-
const [open, setOpen] = (0,
|
|
3391
|
+
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
2586
3392
|
if (!message) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children });
|
|
2587
3393
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2588
3394
|
import_ui6.XStack,
|
|
@@ -2666,17 +3472,17 @@ function AmountPicker({
|
|
|
2666
3472
|
onVerifyGoodId,
|
|
2667
3473
|
embedded = false
|
|
2668
3474
|
}) {
|
|
2669
|
-
const streamSeed = (0,
|
|
2670
|
-
const [depositAmount, setDepositAmount] = (0,
|
|
2671
|
-
const [streamAmount, setStreamAmount] = (0,
|
|
2672
|
-
const [quote, setQuote] = (0,
|
|
2673
|
-
const [quotePending, setQuotePending] = (0,
|
|
2674
|
-
const [isVerifyingGoodId, setIsVerifyingGoodId] = (0,
|
|
3475
|
+
const streamSeed = (0, import_react6.useMemo)(() => resolveInitialStreamAmount(monthlyStreamG), [monthlyStreamG]);
|
|
3476
|
+
const [depositAmount, setDepositAmount] = (0, import_react6.useState)(DEFAULT_DEPOSIT_AMOUNT);
|
|
3477
|
+
const [streamAmount, setStreamAmount] = (0, import_react6.useState)(streamSeed);
|
|
3478
|
+
const [quote, setQuote] = (0, import_react6.useState)(null);
|
|
3479
|
+
const [quotePending, setQuotePending] = (0, import_react6.useState)(false);
|
|
3480
|
+
const [isVerifyingGoodId, setIsVerifyingGoodId] = (0, import_react6.useState)(false);
|
|
2675
3481
|
const isStreamUpdateFlow = parseGAmount(streamSeed) > 0;
|
|
2676
|
-
(0,
|
|
3482
|
+
(0, import_react6.useEffect)(() => {
|
|
2677
3483
|
setStreamAmount(streamSeed);
|
|
2678
3484
|
}, [streamSeed]);
|
|
2679
|
-
(0,
|
|
3485
|
+
(0, import_react6.useEffect)(() => {
|
|
2680
3486
|
let cancelled = false;
|
|
2681
3487
|
setQuotePending(true);
|
|
2682
3488
|
void buildQuote(depositAmount, streamAmount).then((nextQuote) => {
|
|
@@ -2694,7 +3500,7 @@ function AmountPicker({
|
|
|
2694
3500
|
const streamG = parseGAmount(streamAmount);
|
|
2695
3501
|
const depositBonusLabel = isGoodIdVerified ? `+${depositBonusPercent}% bonus` : `Verify for +${depositBonusPercent}%`;
|
|
2696
3502
|
const streamBonusLabel = isGoodIdVerified ? `+${streamBonusPercent}% bonus` : `Verify for +${streamBonusPercent}%`;
|
|
2697
|
-
const paymentValidation = (0,
|
|
3503
|
+
const paymentValidation = (0, import_react6.useMemo)(
|
|
2698
3504
|
() => getPaymentAmountValidation({
|
|
2699
3505
|
depositAmount,
|
|
2700
3506
|
streamAmount,
|
|
@@ -2708,7 +3514,8 @@ function AmountPicker({
|
|
|
2708
3514
|
[depositAmount, streamAmount, monthlyStreamG, minDepositUsd, minStreamUsd, quote, gdUsdPerToken, gBalance]
|
|
2709
3515
|
);
|
|
2710
3516
|
const minsLoaded = minStreamUsd !== null;
|
|
2711
|
-
const
|
|
3517
|
+
const canRetryAfterFailure = status === "quote_ready" || status === "payment_failed";
|
|
3518
|
+
const canPay = canRetryAfterFailure && minsLoaded && paymentValidation.hasPaymentAction && paymentValidation.vaultMinimumsMet && !paymentValidation.overBalance && !quotePending && quote !== null;
|
|
2712
3519
|
const payDisabledMessage = getPayDisabledMessage({
|
|
2713
3520
|
canPay,
|
|
2714
3521
|
minsLoaded,
|
|
@@ -2851,126 +3658,20 @@ function AmountPicker({
|
|
|
2851
3658
|
] });
|
|
2852
3659
|
}
|
|
2853
3660
|
|
|
2854
|
-
// src/components/buy/BuyCreditsFaq.tsx
|
|
2855
|
-
var import_react8 = require("react");
|
|
2856
|
-
var import_ui8 = require("@goodwidget/ui");
|
|
2857
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2858
|
-
var FAQ_ITEMS = [
|
|
2859
|
-
{
|
|
2860
|
-
id: "what-are-credits",
|
|
2861
|
-
question: "What are AI credits?",
|
|
2862
|
-
answer: "AI credits pay for AntSeed-compatible coding tools. GoodDollar only supports purchasing AntSeed AI credits. You buy them with G$ on Celo; AI credits (USD) settle on Base and appear in your Manage tab balance."
|
|
2863
|
-
},
|
|
2864
|
-
{
|
|
2865
|
-
id: "how-to-buy",
|
|
2866
|
-
question: "How do I buy credits?",
|
|
2867
|
-
answer: "Complete the Buy Credits steps: generate a buyer key, sign operator consent, then enter a one-time G$ deposit and/or a monthly G$ stream and confirm one Celo transaction (approve, deposit, and stream changes are batched when needed)."
|
|
2868
|
-
},
|
|
2869
|
-
{
|
|
2870
|
-
id: "deposit-vs-stream",
|
|
2871
|
-
question: "What is a one-time deposit vs a monthly stream?",
|
|
2872
|
-
answer: "A one-time deposit converts G$ into credits right away. A monthly stream sets a G$/month flow rate on Celo; credits are added in real time as G$ streams in, not as a single monthly lump."
|
|
2873
|
-
},
|
|
2874
|
-
{
|
|
2875
|
-
id: "minimums",
|
|
2876
|
-
question: "What are the minimum amounts?",
|
|
2877
|
-
answer: "Your first one-time deposit must be at least US$1.00. If you set a monthly stream, it must be at least US$1.00/month. After your first deposit, there is no minimum for additional one-time deposits.\n\nTo open a new channel to a new provider, you need more than 1 USDC in available credits."
|
|
2878
|
-
},
|
|
2879
|
-
{
|
|
2880
|
-
id: "goodid-bonus",
|
|
2881
|
-
question: "How do GoodID bonuses work?",
|
|
2882
|
-
answer: "With a verified GoodID you receive bonus credits on one-time deposits and monthly streams. The current bonus rates are shown in the Buy Credits form. Without GoodID verification, bonuses do not apply."
|
|
2883
|
-
},
|
|
2884
|
-
{
|
|
2885
|
-
id: "buyer-key",
|
|
2886
|
-
question: "What is the buyer key?",
|
|
2887
|
-
answer: "Your payer wallet pays G$ on Celo. The buyer key is a separate key derived from a payer signature; it manages your AI credits on Base. Save the buyer private key from this session for AI API setup and Manage actions like withdraw."
|
|
2888
|
-
},
|
|
2889
|
-
{
|
|
2890
|
-
id: "operator-consent",
|
|
2891
|
-
question: "Why do I authorize the Gooddollar operator?",
|
|
2892
|
-
answer: "Payer is the wallet that pays G$ on Celo. Buyer is a separate key derived from a payer signature; it owns your AI credit account on Base.\n\nOperator consent is a one-time sign-off so the GoodDollar operator can act as your operator on Base. After you pay G$ on Celo, the operator can fund your credits and handle Base-side actions \u2014 including moving credit funds \u2014 without you paying Base gas. It cannot access your payer wallet or G$ on Celo. Because the operator can act on your Base credit account, you are trusting GoodDollar with that role. You can also withdraw unused principal yourself with your buyer private key."
|
|
2893
|
-
},
|
|
2894
|
-
{
|
|
2895
|
-
id: "when-credits-arrive",
|
|
2896
|
-
question: "When do credits arrive?",
|
|
2897
|
-
answer: "After your Celo payment confirms, credits are funded on Base. Funding usually completes within a short time; check the Manage tab for your updated balance."
|
|
2898
|
-
},
|
|
2899
|
-
{
|
|
2900
|
-
id: "withdraw",
|
|
2901
|
-
question: "What funds can I withdraw?",
|
|
2902
|
-
answer: "You can withdraw unused principal up to the Withdrawable amount shown in Manage. Bonus credits from GoodID are not withdrawable and stay for AI usage only.\n\nWithdrawals are signed with your buyer private key and settled on Base as USD to your payer wallet address \u2014 the same wallet that pays G$ on Celo. Your total credit balance will be higher than the withdrawable amount when bonuses are included."
|
|
2903
|
-
},
|
|
2904
|
-
{
|
|
2905
|
-
id: "api-setup",
|
|
2906
|
-
question: "What is API setup?",
|
|
2907
|
-
answer: "After you have credits, open Manage \u2192 API Setup and copy the commands into your terminal. ANTSEED_IDENTITY_HEX is your buyer private key. it links your purchases to the credit balance your AI tools should use."
|
|
2908
|
-
},
|
|
2909
|
-
{
|
|
2910
|
-
id: "support",
|
|
2911
|
-
question: "Who do I contact for support?",
|
|
2912
|
-
answer: "GoodDollar only supports purchasing AntSeed AI credits through this widget. For post-purchase issues \u2014 including credit usage, channels, providers, or AntSeed tooling \u2014 contact the AntSeed support team on Telegram: https://t.me/antseed"
|
|
2913
|
-
}
|
|
2914
|
-
];
|
|
2915
|
-
function FaqItem({
|
|
2916
|
-
question,
|
|
2917
|
-
answer,
|
|
2918
|
-
expanded,
|
|
2919
|
-
onToggle
|
|
2920
|
-
}) {
|
|
2921
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.YStack, { gap: "$1", children: [
|
|
2922
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
2923
|
-
import_ui8.XStack,
|
|
2924
|
-
{
|
|
2925
|
-
justifyContent: "space-between",
|
|
2926
|
-
alignItems: "center",
|
|
2927
|
-
gap: "$2",
|
|
2928
|
-
onPress: onToggle,
|
|
2929
|
-
cursor: "pointer",
|
|
2930
|
-
children: [
|
|
2931
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$2", fontWeight: "600", flex: 1, children: question }),
|
|
2932
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Icon, { name: expanded ? "chevron-up" : "chevron-down", size: "xs", color: "muted" })
|
|
2933
|
-
]
|
|
2934
|
-
}
|
|
2935
|
-
),
|
|
2936
|
-
expanded && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.YStack, { gap: "$2", children: answer.split("\n\n").map((paragraph, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$2", secondary: true, lineHeight: "$3", children: paragraph }, index)) })
|
|
2937
|
-
] });
|
|
2938
|
-
}
|
|
2939
|
-
function BuyCreditsFaq() {
|
|
2940
|
-
const [expandedId, setExpandedId] = (0, import_react8.useState)(null);
|
|
2941
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.Card, { gap: "$3", children: [
|
|
2942
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Heading, { level: 6, children: "FAQ" }),
|
|
2943
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.YStack, { gap: "$3", children: FAQ_ITEMS.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.YStack, { gap: "$3", children: [
|
|
2944
|
-
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Separator, {}),
|
|
2945
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2946
|
-
FaqItem,
|
|
2947
|
-
{
|
|
2948
|
-
question: item.question,
|
|
2949
|
-
answer: item.answer,
|
|
2950
|
-
expanded: expandedId === item.id,
|
|
2951
|
-
onToggle: () => {
|
|
2952
|
-
setExpandedId((current) => current === item.id ? null : item.id);
|
|
2953
|
-
}
|
|
2954
|
-
}
|
|
2955
|
-
)
|
|
2956
|
-
] }, item.id)) })
|
|
2957
|
-
] });
|
|
2958
|
-
}
|
|
2959
|
-
|
|
2960
3661
|
// src/components/manage/CreditsManagementCard.tsx
|
|
2961
|
-
var
|
|
2962
|
-
var
|
|
3662
|
+
var import_react7 = require("react");
|
|
3663
|
+
var import_ui8 = require("@goodwidget/ui");
|
|
2963
3664
|
|
|
2964
3665
|
// src/components/shared/constants.ts
|
|
2965
|
-
var BUYER_KEY_REQUIRED_CLOSE_TOOLTIP = "Sign with your payer wallet in
|
|
2966
|
-
var BUYER_KEY_REQUIRED_WITHDRAW_TOOLTIP = "Sign with your payer wallet in
|
|
3666
|
+
var BUYER_KEY_REQUIRED_CLOSE_TOOLTIP = "Sign with your payer wallet in Signer Key below to generate the buyer private key before closing a channel.";
|
|
3667
|
+
var BUYER_KEY_REQUIRED_WITHDRAW_TOOLTIP = "Sign with your payer wallet in Signer Key below to generate the buyer private key before withdrawing funds.";
|
|
2967
3668
|
var WITHDRAW_TOOLTIP = "Withdraws principal to your payer wallet (not bonus). Requires the buyer private key from this session.";
|
|
2968
3669
|
|
|
2969
3670
|
// src/components/manage/CreditsManagementCard.tsx
|
|
2970
|
-
var
|
|
3671
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2971
3672
|
function StatCell({ label, children }) {
|
|
2972
|
-
return /* @__PURE__ */ (0,
|
|
2973
|
-
|
|
3673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3674
|
+
import_ui8.YStack,
|
|
2974
3675
|
{
|
|
2975
3676
|
flex: 1,
|
|
2976
3677
|
minWidth: "45%",
|
|
@@ -2982,8 +3683,8 @@ function StatCell({ label, children }) {
|
|
|
2982
3683
|
minWidth: "28%"
|
|
2983
3684
|
},
|
|
2984
3685
|
children: [
|
|
2985
|
-
/* @__PURE__ */ (0,
|
|
2986
|
-
/* @__PURE__ */ (0,
|
|
3686
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$1", secondary: true, children: label }),
|
|
3687
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.YStack, { justifyContent: "center", children })
|
|
2987
3688
|
]
|
|
2988
3689
|
}
|
|
2989
3690
|
);
|
|
@@ -2992,7 +3693,7 @@ function StatValueText({
|
|
|
2992
3693
|
children,
|
|
2993
3694
|
color
|
|
2994
3695
|
}) {
|
|
2995
|
-
return /* @__PURE__ */ (0,
|
|
3696
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$2", fontWeight: "700", color, children });
|
|
2996
3697
|
}
|
|
2997
3698
|
function formatCompactAmount(amount) {
|
|
2998
3699
|
const value = Number.parseFloat(amount);
|
|
@@ -3011,16 +3712,16 @@ function formatExactGAmount(amount) {
|
|
|
3011
3712
|
}).format(value)} G$`;
|
|
3012
3713
|
}
|
|
3013
3714
|
function CompactGStatValue({ amount }) {
|
|
3014
|
-
const [open, setOpen] = (0,
|
|
3715
|
+
const [open, setOpen] = (0, import_react7.useState)(false);
|
|
3015
3716
|
const value = Number.parseFloat(amount);
|
|
3016
3717
|
const compact = formatCompactAmount(amount);
|
|
3017
3718
|
const exact = formatExactGAmount(amount);
|
|
3018
3719
|
const needsExact = Number.isFinite(value) && value >= 1e3;
|
|
3019
3720
|
if (!needsExact) {
|
|
3020
|
-
return /* @__PURE__ */ (0,
|
|
3721
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StatValueText, { children: compact });
|
|
3021
3722
|
}
|
|
3022
|
-
return /* @__PURE__ */ (0,
|
|
3023
|
-
|
|
3723
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3724
|
+
import_ui8.XStack,
|
|
3024
3725
|
{
|
|
3025
3726
|
position: "relative",
|
|
3026
3727
|
cursor: "help",
|
|
@@ -3033,9 +3734,9 @@ function CompactGStatValue({ amount }) {
|
|
|
3033
3734
|
onBlur: () => setOpen(false),
|
|
3034
3735
|
onPress: () => setOpen((prev) => !prev),
|
|
3035
3736
|
children: [
|
|
3036
|
-
/* @__PURE__ */ (0,
|
|
3037
|
-
open && /* @__PURE__ */ (0,
|
|
3038
|
-
|
|
3737
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StatValueText, { children: compact }),
|
|
3738
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3739
|
+
import_ui8.YStack,
|
|
3039
3740
|
{
|
|
3040
3741
|
position: "absolute",
|
|
3041
3742
|
bottom: "100%",
|
|
@@ -3048,7 +3749,7 @@ function CompactGStatValue({ amount }) {
|
|
|
3048
3749
|
padding: "$2",
|
|
3049
3750
|
zIndex: 100,
|
|
3050
3751
|
pointerEvents: "none",
|
|
3051
|
-
children: /* @__PURE__ */ (0,
|
|
3752
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$1", lineHeight: "$2", color: "$color", whiteSpace: "nowrap", children: exact })
|
|
3052
3753
|
}
|
|
3053
3754
|
)
|
|
3054
3755
|
]
|
|
@@ -3064,10 +3765,10 @@ function formatUsdAmount(usdMicro) {
|
|
|
3064
3765
|
}).format(value);
|
|
3065
3766
|
}
|
|
3066
3767
|
function CreditsManagementCard({ state, actions }) {
|
|
3067
|
-
const [isClosing, setIsClosing] = (0,
|
|
3068
|
-
const [isWithdrawing, setIsWithdrawing] = (0,
|
|
3069
|
-
const [channelId, setChannelId] = (0,
|
|
3070
|
-
const [withdrawAmount, setWithdrawAmount] = (0,
|
|
3768
|
+
const [isClosing, setIsClosing] = (0, import_react7.useState)(false);
|
|
3769
|
+
const [isWithdrawing, setIsWithdrawing] = (0, import_react7.useState)(false);
|
|
3770
|
+
const [channelId, setChannelId] = (0, import_react7.useState)("");
|
|
3771
|
+
const [withdrawAmount, setWithdrawAmount] = (0, import_react7.useState)("");
|
|
3071
3772
|
const {
|
|
3072
3773
|
totalCreditUsd,
|
|
3073
3774
|
totalGdDepositedG,
|
|
@@ -3077,7 +3778,7 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
3077
3778
|
withdrawableUsd,
|
|
3078
3779
|
buyerPrvKey
|
|
3079
3780
|
} = state;
|
|
3080
|
-
const monthlyStreamUsdDisplay = (0,
|
|
3781
|
+
const monthlyStreamUsdDisplay = (0, import_react7.useMemo)(() => {
|
|
3081
3782
|
if (!monthlyStreamG || !gdUsdPerToken) return null;
|
|
3082
3783
|
if (Number.parseFloat(monthlyStreamG) <= 0) return null;
|
|
3083
3784
|
const quote = { depositAmountG: "0", streamAmountG: monthlyStreamG };
|
|
@@ -3093,34 +3794,34 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
3093
3794
|
const hasWithdrawableBalance = withdrawableUsd !== null && BigInt(withdrawableUsd) > 0n;
|
|
3094
3795
|
const canClose = Boolean(buyerPrvKey) && Boolean(channelId.trim()) && !isClosing;
|
|
3095
3796
|
const canWithdraw = Boolean(buyerPrvKey) && hasWithdrawableBalance && Boolean(withdrawAmount.trim()) && !isWithdrawing;
|
|
3096
|
-
return /* @__PURE__ */ (0,
|
|
3097
|
-
/* @__PURE__ */ (0,
|
|
3098
|
-
/* @__PURE__ */ (0,
|
|
3099
|
-
/* @__PURE__ */ (0,
|
|
3100
|
-
/* @__PURE__ */ (0,
|
|
3101
|
-
totalCreditDisplay !== null ? /* @__PURE__ */ (0,
|
|
3797
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.Card, { gap: "$3", children: [
|
|
3798
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Heading, { level: 6, children: "AI Credits" }),
|
|
3799
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.XStack, { gap: "$4", width: "100%", alignItems: "flex-start", flexWrap: "wrap", children: [
|
|
3800
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.YStack, { gap: "$2", flex: 1, minWidth: 0, children: [
|
|
3801
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$1", secondary: true, children: "Total Credit (US$)" }),
|
|
3802
|
+
totalCreditDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Heading, { level: 5, children: totalCreditDisplay }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Spinner, { size: "sm" })
|
|
3102
3803
|
] }),
|
|
3103
|
-
/* @__PURE__ */ (0,
|
|
3104
|
-
/* @__PURE__ */ (0,
|
|
3105
|
-
monthlyStreamUsdDisplay ? /* @__PURE__ */ (0,
|
|
3804
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.YStack, { gap: "$2", flex: 1, minWidth: 0, children: [
|
|
3805
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$1", secondary: true, children: "Est. Monthly Credit (US$)" }),
|
|
3806
|
+
monthlyStreamUsdDisplay ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.Heading, { level: 5, color: "$primary", children: [
|
|
3106
3807
|
"~",
|
|
3107
3808
|
monthlyStreamUsdDisplay
|
|
3108
|
-
] }) : /* @__PURE__ */ (0,
|
|
3809
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Heading, { level: 5, children: "\u2014" })
|
|
3109
3810
|
] })
|
|
3110
3811
|
] }),
|
|
3111
|
-
/* @__PURE__ */ (0,
|
|
3112
|
-
/* @__PURE__ */ (0,
|
|
3113
|
-
/* @__PURE__ */ (0,
|
|
3114
|
-
/* @__PURE__ */ (0,
|
|
3812
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.XStack, { gap: "$2", width: "100%", flexWrap: "wrap", alignItems: "stretch", children: [
|
|
3813
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StatCell, { label: "Total Deposited (G$)", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CompactGStatValue, { amount: totalGdDepositedG ?? "0.00" }) }),
|
|
3814
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StatCell, { label: "Monthly Stream (G$)", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CompactGStatValue, { amount: monthlyStreamG ?? "0.00" }) }),
|
|
3815
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StatCell, { label: "Withdrawable (US$)", children: withdrawableDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StatValueText, { children: withdrawableDisplay }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Spinner, { size: "sm" }) })
|
|
3115
3816
|
] }),
|
|
3116
|
-
/* @__PURE__ */ (0,
|
|
3117
|
-
/* @__PURE__ */ (0,
|
|
3118
|
-
/* @__PURE__ */ (0,
|
|
3119
|
-
/* @__PURE__ */ (0,
|
|
3817
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.YStack, { gap: "$1", children: [
|
|
3818
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.XStack, { gap: "$1", alignItems: "center", children: [
|
|
3819
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$1", variant: "label", children: "Withdraw" }),
|
|
3820
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(InfoTooltip, { message: WITHDRAW_TOOLTIP })
|
|
3120
3821
|
] }),
|
|
3121
|
-
/* @__PURE__ */ (0,
|
|
3122
|
-
/* @__PURE__ */ (0,
|
|
3123
|
-
|
|
3822
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.XStack, { gap: "$2", alignItems: "center", children: [
|
|
3823
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.YStack, { flex: 1, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3824
|
+
import_ui8.Input,
|
|
3124
3825
|
{
|
|
3125
3826
|
size: "sm",
|
|
3126
3827
|
value: withdrawAmount,
|
|
@@ -3128,8 +3829,8 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
3128
3829
|
placeholder: hasWithdrawableBalance && withdrawableDisplay ? `Max ${withdrawableDisplay} US$` : "Amount in US$"
|
|
3129
3830
|
}
|
|
3130
3831
|
) }),
|
|
3131
|
-
/* @__PURE__ */ (0,
|
|
3132
|
-
|
|
3832
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HoverTooltip, { message: !buyerPrvKey ? BUYER_KEY_REQUIRED_WITHDRAW_TOOLTIP : null, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3833
|
+
import_ui8.Button,
|
|
3133
3834
|
{
|
|
3134
3835
|
variant: "outline",
|
|
3135
3836
|
size: "sm",
|
|
@@ -3144,16 +3845,16 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
3144
3845
|
setWithdrawAmount("");
|
|
3145
3846
|
});
|
|
3146
3847
|
},
|
|
3147
|
-
children: /* @__PURE__ */ (0,
|
|
3848
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.ButtonText, { children: isWithdrawing ? "Withdrawing\u2026" : "Withdraw" })
|
|
3148
3849
|
}
|
|
3149
3850
|
) })
|
|
3150
3851
|
] })
|
|
3151
3852
|
] }),
|
|
3152
|
-
/* @__PURE__ */ (0,
|
|
3153
|
-
/* @__PURE__ */ (0,
|
|
3154
|
-
/* @__PURE__ */ (0,
|
|
3155
|
-
/* @__PURE__ */ (0,
|
|
3156
|
-
|
|
3853
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.YStack, { gap: "$1", children: [
|
|
3854
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$1", variant: "label", children: "Close Channel" }),
|
|
3855
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.XStack, { gap: "$2", alignItems: "center", children: [
|
|
3856
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.YStack, { flex: 1, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3857
|
+
import_ui8.Input,
|
|
3157
3858
|
{
|
|
3158
3859
|
size: "sm",
|
|
3159
3860
|
value: channelId,
|
|
@@ -3161,8 +3862,8 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
3161
3862
|
placeholder: "0x\u2026 (64 hex chars)"
|
|
3162
3863
|
}
|
|
3163
3864
|
) }),
|
|
3164
|
-
/* @__PURE__ */ (0,
|
|
3165
|
-
|
|
3865
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HoverTooltip, { message: !buyerPrvKey ? BUYER_KEY_REQUIRED_CLOSE_TOOLTIP : null, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3866
|
+
import_ui8.Button,
|
|
3166
3867
|
{
|
|
3167
3868
|
variant: "outline",
|
|
3168
3869
|
size: "sm",
|
|
@@ -3177,7 +3878,7 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
3177
3878
|
setChannelId("");
|
|
3178
3879
|
});
|
|
3179
3880
|
},
|
|
3180
|
-
children: /* @__PURE__ */ (0,
|
|
3881
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.ButtonText, { children: isClosing ? "Closing\u2026" : "Close" })
|
|
3181
3882
|
}
|
|
3182
3883
|
) })
|
|
3183
3884
|
] })
|
|
@@ -3186,140 +3887,400 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
3186
3887
|
}
|
|
3187
3888
|
|
|
3188
3889
|
// src/components/manage/BuyerOperatorCard.tsx
|
|
3189
|
-
var
|
|
3190
|
-
var import_ui11 = require("@goodwidget/ui");
|
|
3191
|
-
|
|
3192
|
-
// src/components/shared/AddressView.tsx
|
|
3890
|
+
var import_react9 = require("react");
|
|
3193
3891
|
var import_ui10 = require("@goodwidget/ui");
|
|
3194
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3195
|
-
function AddressView({ label, address }) {
|
|
3196
|
-
const { copied, copy } = useCopyFeedback();
|
|
3197
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.YStack, { gap: "$1", children: [
|
|
3198
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { fontSize: "$1", secondary: true, children: label }),
|
|
3199
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3200
|
-
import_ui10.XStack,
|
|
3201
|
-
{
|
|
3202
|
-
backgroundColor: "$backgroundMuted",
|
|
3203
|
-
borderRadius: "$2",
|
|
3204
|
-
padding: "$2",
|
|
3205
|
-
justifyContent: "space-between",
|
|
3206
|
-
alignItems: "center",
|
|
3207
|
-
children: [
|
|
3208
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3209
|
-
import_ui10.Text,
|
|
3210
|
-
{
|
|
3211
|
-
fontSize: "$2",
|
|
3212
|
-
fontFamily: "$mono",
|
|
3213
|
-
flex: 1,
|
|
3214
|
-
numberOfLines: 1,
|
|
3215
|
-
style: monospaceSingleLineStyle,
|
|
3216
|
-
children: truncateAddress(address)
|
|
3217
|
-
}
|
|
3218
|
-
),
|
|
3219
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Button, { size: "sm", variant: "ghost", iconSize: "sm", onPress: () => void copy(address), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Icon, { name: copied ? "check" : "copy", size: "xs", color: copied ? "success" : "text" }) })
|
|
3220
|
-
]
|
|
3221
|
-
}
|
|
3222
|
-
)
|
|
3223
|
-
] });
|
|
3224
|
-
}
|
|
3225
3892
|
|
|
3226
|
-
// src/components/
|
|
3227
|
-
var
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3893
|
+
// src/components/setup/SignerKeyPanel.tsx
|
|
3894
|
+
var import_react8 = require("react");
|
|
3895
|
+
var import_ui9 = require("@goodwidget/ui");
|
|
3896
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3897
|
+
var ZERO_OPERATOR = "0x0000000000000000000000000000000000000000";
|
|
3898
|
+
function SignerKeyPanel({
|
|
3899
|
+
state,
|
|
3900
|
+
actions,
|
|
3901
|
+
onProceed,
|
|
3902
|
+
showHeading = true,
|
|
3903
|
+
proceedLabel: proceedLabelOverride,
|
|
3904
|
+
compact = false
|
|
3905
|
+
}) {
|
|
3906
|
+
const [choice, setChoice] = (0, import_react8.useState)(null);
|
|
3907
|
+
const [privateKey, setPrivateKey] = (0, import_react8.useState)("");
|
|
3908
|
+
const [isImporting, setIsImporting] = (0, import_react8.useState)(false);
|
|
3909
|
+
const [keyConfirmed, setKeyConfirmed] = (0, import_react8.useState)(false);
|
|
3910
|
+
const [importedAddress, setImportedAddress] = (0, import_react8.useState)(null);
|
|
3911
|
+
const leaveChoice = () => {
|
|
3912
|
+
setChoice(null);
|
|
3913
|
+
setImportedAddress(null);
|
|
3914
|
+
};
|
|
3915
|
+
const currentOperator = state.currentOperator?.toLowerCase();
|
|
3916
|
+
const expectedOperator = state.operatorAddress?.toLowerCase();
|
|
3917
|
+
const proceedLabel = proceedLabelOverride ?? (state.operatorConsented ? "Done" : "Continue to Authorize Wallet");
|
|
3918
|
+
const hasDifferentOperator = Boolean(currentOperator) && currentOperator !== ZERO_OPERATOR && Boolean(expectedOperator) && currentOperator !== expectedOperator;
|
|
3919
|
+
if (choice === "generate") {
|
|
3920
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$3", children: [
|
|
3921
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Button, { variant: "text", alignSelf: "flex-start", onPress: leaveChoice, children: [
|
|
3922
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Icon, { name: "arrow-left", size: "xs", color: "primary" }),
|
|
3923
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.ButtonText, { children: "Back to Generate / Import" })
|
|
3924
|
+
] }),
|
|
3925
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3926
|
+
BuyerKeyPanel,
|
|
3927
|
+
{
|
|
3928
|
+
embedded: true,
|
|
3929
|
+
buyerPubKey: state.buyerPubKey,
|
|
3930
|
+
buyerPrvKey: state.buyerPrvKey,
|
|
3931
|
+
buyerPubKeySaved: keyConfirmed,
|
|
3932
|
+
onGenerate: actions.generateBuyerKey,
|
|
3933
|
+
onConfirm: () => setKeyConfirmed(true)
|
|
3934
|
+
}
|
|
3935
|
+
),
|
|
3936
|
+
keyConfirmed && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Button, { size: "sm", ...compactButtonProps, onPress: onProceed, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.ButtonText, { children: proceedLabel }) })
|
|
3937
|
+
] });
|
|
3938
|
+
}
|
|
3939
|
+
if (choice === "import") {
|
|
3940
|
+
const importedSigner = !isImporting && Boolean(importedAddress) && state.buyerPubKey?.toLowerCase() === importedAddress?.toLowerCase();
|
|
3941
|
+
const importedSignerBlocked = importedSigner && hasDifferentOperator;
|
|
3942
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$3", children: [
|
|
3943
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Button, { variant: "text", alignSelf: "flex-start", onPress: leaveChoice, children: [
|
|
3944
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Icon, { name: "arrow-left", size: "xs", color: "primary" }),
|
|
3945
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.ButtonText, { children: "Back to Generate / Import" })
|
|
3946
|
+
] }),
|
|
3947
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Heading, { level: 5, children: "Import Signer Key" }),
|
|
3948
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { secondary: true, children: "Paste the private key from AntSeed. It will be checked against the operator configured for this signer before you can continue." }),
|
|
3949
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3950
|
+
import_ui9.Input,
|
|
3241
3951
|
{
|
|
3242
|
-
flex: 1,
|
|
3243
|
-
flexBasis: 0,
|
|
3244
|
-
minWidth: 0,
|
|
3245
3952
|
size: "sm",
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
},
|
|
3251
|
-
disabled: isGenerating,
|
|
3252
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui11.ButtonText, { children: isGenerating ? "Signing\u2026" : "Sign & Generate" })
|
|
3953
|
+
value: privateKey,
|
|
3954
|
+
onChangeText: setPrivateKey,
|
|
3955
|
+
placeholder: "0x\u2026",
|
|
3956
|
+
autoCapitalize: "none"
|
|
3253
3957
|
}
|
|
3254
3958
|
),
|
|
3255
|
-
/* @__PURE__ */ (0,
|
|
3256
|
-
|
|
3959
|
+
state.error && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { color: "$error", children: state.error }),
|
|
3960
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3961
|
+
import_ui9.Button,
|
|
3257
3962
|
{
|
|
3258
|
-
flex: 1,
|
|
3259
|
-
flexBasis: 0,
|
|
3260
|
-
minWidth: 0,
|
|
3261
3963
|
size: "sm",
|
|
3262
3964
|
...compactButtonProps,
|
|
3965
|
+
disabled: !privateKey.trim() || isImporting,
|
|
3263
3966
|
onPress: () => {
|
|
3264
|
-
|
|
3265
|
-
|
|
3967
|
+
setIsImporting(true);
|
|
3968
|
+
setImportedAddress(null);
|
|
3969
|
+
void actions.importBuyerFromPrivateKey(privateKey.trim()).then((buyerAddress) => setImportedAddress(buyerAddress)).catch(() => setImportedAddress(null)).finally(() => setIsImporting(false));
|
|
3266
3970
|
},
|
|
3267
|
-
|
|
3268
|
-
children: isSigning ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui11.Spinner, { size: "sm" }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui11.ButtonText, { children: operatorConsented ? "Consented" : "Sign Consent" })
|
|
3971
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.ButtonText, { children: isImporting ? "Checking signer\u2026" : "Import Signer Key" })
|
|
3269
3972
|
}
|
|
3270
|
-
)
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
/* @__PURE__ */ (0,
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3973
|
+
),
|
|
3974
|
+
importedSignerBlocked ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$2", children: [
|
|
3975
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { color: "$error", fontWeight: "700", children: "Signer key cannot be used" }),
|
|
3976
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { secondary: true, children: "The imported signer key already has another operator configured. Paste a different signer key, or go back and generate a new one." })
|
|
3977
|
+
] }) : importedSigner ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$2", children: [
|
|
3978
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { color: "$success", fontWeight: "700", children: "Signer imported" }),
|
|
3979
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Text, { secondary: true, children: [
|
|
3980
|
+
truncateAddress(state.buyerPubKey ?? ""),
|
|
3981
|
+
" is now your active signer."
|
|
3982
|
+
] }),
|
|
3983
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { secondary: true, children: state.operatorConsented ? "GoodDollar is already configured as the operator." : currentOperator === ZERO_OPERATOR ? "No operator is configured yet. Continue to authorize GoodDollar." : "The configured operator is being checked." }),
|
|
3984
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Button, { size: "sm", ...compactButtonProps, onPress: onProceed, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.ButtonText, { children: proceedLabel }) })
|
|
3985
|
+
] }) : null
|
|
3986
|
+
] });
|
|
3987
|
+
}
|
|
3988
|
+
const choices = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
3989
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3990
|
+
import_ui9.Button,
|
|
3991
|
+
{
|
|
3992
|
+
flex: compact ? void 0 : 1,
|
|
3993
|
+
alignSelf: compact ? "stretch" : void 0,
|
|
3994
|
+
size: compact ? "sm" : "lg",
|
|
3995
|
+
variant: "outline",
|
|
3996
|
+
...compactButtonProps,
|
|
3997
|
+
onPress: () => setChoice("generate"),
|
|
3998
|
+
children: [
|
|
3999
|
+
!compact && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Badge, { type: "success", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.BadgeText, { children: "Recommended" }) }),
|
|
4000
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.ButtonText, { children: "Generate Signer Key" })
|
|
4001
|
+
]
|
|
4002
|
+
}
|
|
4003
|
+
),
|
|
4004
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4005
|
+
import_ui9.Button,
|
|
4006
|
+
{
|
|
4007
|
+
flex: compact ? void 0 : 1,
|
|
4008
|
+
alignSelf: compact ? "stretch" : void 0,
|
|
4009
|
+
size: compact ? "sm" : "lg",
|
|
4010
|
+
variant: "outline",
|
|
4011
|
+
...compactButtonProps,
|
|
4012
|
+
onPress: () => setChoice("import"),
|
|
4013
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.ButtonText, { children: "Import Signer Key" })
|
|
4014
|
+
}
|
|
4015
|
+
)
|
|
4016
|
+
] });
|
|
4017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$3", children: [
|
|
4018
|
+
showHeading && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Heading, { level: 5, children: "Signer Key" }),
|
|
4019
|
+
!compact && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { secondary: true, children: "A dedicated identity used only to buy and spend AI credits \u2014 separate from your wallet." }),
|
|
4020
|
+
compact ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.YStack, { gap: "$2", children: choices }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.XStack, { gap: "$3", children: choices }),
|
|
4021
|
+
!compact && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$2", secondary: true, children: "Generate is recommended for a fresh signer. Either direction uses the same key once it is set up in AntSeed." })
|
|
4022
|
+
] });
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
// src/components/manage/BuyerOperatorCard.tsx
|
|
4026
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
4027
|
+
function shortAddress(address) {
|
|
4028
|
+
return `${address.slice(0, 6)}\u2026${address.slice(-4)}`;
|
|
4029
|
+
}
|
|
4030
|
+
function DisclosureToggle({
|
|
4031
|
+
open,
|
|
4032
|
+
label,
|
|
4033
|
+
onPress
|
|
4034
|
+
}) {
|
|
4035
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4036
|
+
import_ui10.Button,
|
|
4037
|
+
{
|
|
4038
|
+
variant: "text",
|
|
4039
|
+
size: "sm",
|
|
4040
|
+
alignSelf: "flex-start",
|
|
4041
|
+
gap: "$1.5",
|
|
4042
|
+
...compactButtonProps,
|
|
4043
|
+
paddingHorizontal: "$0",
|
|
4044
|
+
"aria-expanded": open,
|
|
4045
|
+
onPress,
|
|
4046
|
+
children: [
|
|
4047
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Icon, { name: open ? "chevron-up" : "chevron-down", size: "xs", color: "primary" }),
|
|
4048
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.ButtonText, { children: label })
|
|
4049
|
+
]
|
|
4050
|
+
}
|
|
4051
|
+
);
|
|
4052
|
+
}
|
|
4053
|
+
function CopyableValue({ value, display }) {
|
|
4054
|
+
const { copied, copy } = useCopyFeedback();
|
|
4055
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4056
|
+
import_ui10.XStack,
|
|
4057
|
+
{
|
|
4058
|
+
backgroundColor: "$backgroundMuted",
|
|
4059
|
+
borderRadius: "$2",
|
|
4060
|
+
padding: "$2",
|
|
4061
|
+
justifyContent: "space-between",
|
|
4062
|
+
alignItems: "center",
|
|
4063
|
+
gap: "$2",
|
|
4064
|
+
children: [
|
|
4065
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { fontSize: "$2", flex: 1, numberOfLines: 1, style: monospaceSingleLineStyle, children: display ?? value }),
|
|
4066
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Button, { size: "sm", variant: "ghost", iconSize: "sm", onPress: () => void copy(value), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Icon, { name: copied ? "check" : "copy", size: "xs", color: copied ? "success" : "text" }) })
|
|
4067
|
+
]
|
|
4068
|
+
}
|
|
4069
|
+
);
|
|
4070
|
+
}
|
|
4071
|
+
function SignerStatus({
|
|
4072
|
+
consented,
|
|
4073
|
+
size = "$1"
|
|
4074
|
+
}) {
|
|
4075
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.XStack, { gap: "$1", alignItems: "center", children: [
|
|
4076
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4077
|
+
import_ui10.Icon,
|
|
4078
|
+
{
|
|
4079
|
+
name: consented ? "check" : "alert-triangle",
|
|
4080
|
+
size: "2xs",
|
|
4081
|
+
color: consented ? "success" : "warning"
|
|
4082
|
+
}
|
|
4083
|
+
),
|
|
4084
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { fontSize: size, color: consented ? "$success" : "$warning", children: consented ? "Authorized" : "Not authorized" })
|
|
4085
|
+
] });
|
|
4086
|
+
}
|
|
4087
|
+
function BuyerSelector({
|
|
4088
|
+
buyers,
|
|
4089
|
+
activeBuyerAddress,
|
|
4090
|
+
onSelect
|
|
4091
|
+
}) {
|
|
4092
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.YStack, { gap: "$1", children: buyers.map((buyer) => {
|
|
4093
|
+
const isActive = buyer.toLowerCase() === activeBuyerAddress?.toLowerCase();
|
|
4094
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4095
|
+
import_ui10.XStack,
|
|
4096
|
+
{
|
|
4097
|
+
tag: "button",
|
|
4098
|
+
role: "option",
|
|
4099
|
+
"aria-selected": isActive,
|
|
4100
|
+
alignItems: "center",
|
|
4101
|
+
justifyContent: "space-between",
|
|
4102
|
+
gap: "$2",
|
|
4103
|
+
paddingHorizontal: "$2",
|
|
4104
|
+
paddingVertical: "$1.5",
|
|
4105
|
+
borderRadius: "$2",
|
|
4106
|
+
borderWidth: 1,
|
|
4107
|
+
borderColor: isActive ? "$primary" : "$borderColor",
|
|
4108
|
+
backgroundColor: isActive ? "$infoMuted" : "$backgroundDark",
|
|
4109
|
+
cursor: isActive ? "default" : "pointer",
|
|
4110
|
+
hoverStyle: isActive ? {} : { backgroundColor: "$backgroundPress" },
|
|
4111
|
+
onPress: () => {
|
|
4112
|
+
if (!isActive) void onSelect(buyer);
|
|
4113
|
+
},
|
|
4114
|
+
children: [
|
|
4115
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4116
|
+
import_ui10.Text,
|
|
4117
|
+
{
|
|
4118
|
+
fontSize: "$2",
|
|
4119
|
+
fontWeight: isActive ? "700" : "500",
|
|
4120
|
+
color: isActive ? "$primary" : "$color",
|
|
4121
|
+
numberOfLines: 1,
|
|
4122
|
+
flex: 1,
|
|
4123
|
+
style: monospaceSingleLineStyle,
|
|
4124
|
+
children: shortAddress(buyer)
|
|
4125
|
+
}
|
|
4126
|
+
),
|
|
4127
|
+
isActive ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.XStack, { gap: "$1", alignItems: "center", children: [
|
|
4128
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { fontSize: "$1", color: "$primary", children: "active" }),
|
|
4129
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Icon, { name: "check", size: "xs", color: "primary" })
|
|
4130
|
+
] }) : null
|
|
4131
|
+
]
|
|
4132
|
+
},
|
|
4133
|
+
buyer
|
|
4134
|
+
);
|
|
4135
|
+
}) });
|
|
4136
|
+
}
|
|
4137
|
+
function BuyerOperatorCard({ state, actions }) {
|
|
4138
|
+
const {
|
|
4139
|
+
buyerPubKey,
|
|
4140
|
+
buyerPrvKey,
|
|
4141
|
+
operatorSignature,
|
|
4142
|
+
operatorConsented,
|
|
4143
|
+
operatorConsentPending,
|
|
4144
|
+
buyers
|
|
4145
|
+
} = state;
|
|
4146
|
+
const [isExpanded, setIsExpanded] = (0, import_react9.useState)(false);
|
|
4147
|
+
const [showSwitcher, setShowSwitcher] = (0, import_react9.useState)(false);
|
|
4148
|
+
const [showReplacePanel, setShowReplacePanel] = (0, import_react9.useState)(false);
|
|
4149
|
+
const [showPrivateKey, setShowPrivateKey] = (0, import_react9.useState)(false);
|
|
4150
|
+
const [panelInstance, setPanelInstance] = (0, import_react9.useState)(0);
|
|
4151
|
+
const buyerCanSign = Boolean(buyerPrvKey || operatorSignature);
|
|
4152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.Card, { gap: "$3", "data-testid": "signer-key-card", children: [
|
|
4153
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4154
|
+
import_ui10.XStack,
|
|
4155
|
+
{
|
|
4156
|
+
tag: "button",
|
|
4157
|
+
"data-testid": "signer-key-toggle",
|
|
4158
|
+
alignItems: "center",
|
|
4159
|
+
justifyContent: "space-between",
|
|
4160
|
+
gap: "$2",
|
|
4161
|
+
width: "100%",
|
|
4162
|
+
backgroundColor: "transparent",
|
|
4163
|
+
borderWidth: 0,
|
|
4164
|
+
paddingHorizontal: "$0",
|
|
4165
|
+
paddingVertical: "$0",
|
|
4166
|
+
cursor: "pointer",
|
|
4167
|
+
"aria-expanded": isExpanded,
|
|
4168
|
+
onPress: () => setIsExpanded((prev) => !prev),
|
|
4169
|
+
children: [
|
|
4170
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.YStack, { gap: "$1", flex: 1, minWidth: 0, alignItems: "flex-start", children: [
|
|
4171
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Heading, { level: 6, children: "Signer Key" }),
|
|
4172
|
+
buyerPubKey ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.XStack, { alignItems: "center", flexWrap: "wrap", children: [
|
|
4173
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { fontSize: "$1", secondary: true, style: monospaceSingleLineStyle, children: `${truncateAddress(buyerPubKey)} \xB7 ` }),
|
|
4174
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SignerStatus, { consented: operatorConsented })
|
|
4175
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { fontSize: "$1", secondary: true, children: "No signer key yet" })
|
|
4176
|
+
] }),
|
|
4177
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Icon, { name: isExpanded ? "chevron-up" : "chevron-down", size: "sm", color: "muted" })
|
|
4178
|
+
]
|
|
4179
|
+
}
|
|
4180
|
+
),
|
|
4181
|
+
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.YStack, { gap: "$4", children: [
|
|
4182
|
+
buyerPubKey && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.YStack, { gap: "$2", children: [
|
|
4183
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { variant: "label", secondary: true, children: "Active signer" }),
|
|
4184
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4185
|
+
import_ui10.YStack,
|
|
4186
|
+
{
|
|
4187
|
+
backgroundColor: "$backgroundDark",
|
|
4188
|
+
borderRadius: "$2",
|
|
4189
|
+
borderWidth: 1,
|
|
4190
|
+
borderColor: "$borderColor",
|
|
4191
|
+
padding: "$2",
|
|
4192
|
+
gap: "$2",
|
|
4193
|
+
children: [
|
|
4194
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CopyableValue, { value: buyerPubKey, display: truncateAddress(buyerPubKey) }),
|
|
4195
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SignerStatus, { consented: operatorConsented, size: "$2" }),
|
|
4196
|
+
!operatorConsented && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4197
|
+
import_ui10.Button,
|
|
4198
|
+
{
|
|
4199
|
+
size: "sm",
|
|
4200
|
+
...compactButtonProps,
|
|
4201
|
+
disabled: operatorConsentPending || !buyerCanSign,
|
|
4202
|
+
onPress: () => {
|
|
4203
|
+
void Promise.resolve(actions.signOperatorConsent());
|
|
4204
|
+
},
|
|
4205
|
+
children: operatorConsentPending ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Spinner, { size: "sm" }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.ButtonText, { children: "Authorize GoodDollar" })
|
|
4206
|
+
}
|
|
4207
|
+
)
|
|
4208
|
+
]
|
|
4209
|
+
}
|
|
4210
|
+
)
|
|
4211
|
+
] }),
|
|
4212
|
+
buyers.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.YStack, { gap: "$2", children: [
|
|
4213
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4214
|
+
DisclosureToggle,
|
|
4215
|
+
{
|
|
4216
|
+
open: showSwitcher,
|
|
4217
|
+
label: `Switch signer (${buyers.length})`,
|
|
4218
|
+
onPress: () => setShowSwitcher((prev) => !prev)
|
|
4219
|
+
}
|
|
4220
|
+
),
|
|
4221
|
+
showSwitcher && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4222
|
+
BuyerSelector,
|
|
4223
|
+
{
|
|
4224
|
+
buyers,
|
|
4225
|
+
activeBuyerAddress: buyerPubKey,
|
|
4226
|
+
onSelect: actions.selectBuyer
|
|
4227
|
+
}
|
|
4228
|
+
)
|
|
4229
|
+
] }),
|
|
4230
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.YStack, { gap: "$2", children: [
|
|
4231
|
+
buyerPubKey ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4232
|
+
DisclosureToggle,
|
|
4233
|
+
{
|
|
4234
|
+
open: showReplacePanel,
|
|
4235
|
+
label: "Replace signer key",
|
|
4236
|
+
onPress: () => setShowReplacePanel((prev) => !prev)
|
|
4237
|
+
}
|
|
4238
|
+
) : null,
|
|
4239
|
+
(showReplacePanel || !buyerPubKey) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4240
|
+
SignerKeyPanel,
|
|
4241
|
+
{
|
|
4242
|
+
state,
|
|
4243
|
+
actions,
|
|
4244
|
+
showHeading: false,
|
|
4245
|
+
compact: Boolean(buyerPubKey),
|
|
4246
|
+
proceedLabel: "Done",
|
|
4247
|
+
onProceed: () => setPanelInstance((prev) => prev + 1)
|
|
4248
|
+
},
|
|
4249
|
+
panelInstance
|
|
4250
|
+
)
|
|
4251
|
+
] }),
|
|
4252
|
+
buyerPrvKey && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.YStack, { gap: "$2", children: [
|
|
4253
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.XStack, { justifyContent: "space-between", alignItems: "center", gap: "$2", children: [
|
|
4254
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { variant: "label", secondary: true, children: "Private key" }),
|
|
4255
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4256
|
+
import_ui10.Button,
|
|
4257
|
+
{
|
|
4258
|
+
variant: "text",
|
|
4259
|
+
size: "sm",
|
|
4260
|
+
...compactButtonProps,
|
|
4261
|
+
paddingHorizontal: "$0",
|
|
4262
|
+
onPress: () => setShowPrivateKey((prev) => !prev),
|
|
4263
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.ButtonText, { children: showPrivateKey ? "Hide" : "Reveal" })
|
|
4264
|
+
}
|
|
4265
|
+
)
|
|
4266
|
+
] }),
|
|
4267
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4268
|
+
CopyableValue,
|
|
4269
|
+
{
|
|
4270
|
+
value: buyerPrvKey,
|
|
4271
|
+
display: showPrivateKey ? buyerPrvKey : "\u2022".repeat(Math.min(48, buyerPrvKey.length))
|
|
4272
|
+
}
|
|
4273
|
+
),
|
|
4274
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { fontSize: "$1", color: "$warning", children: "Treat this like a password \u2014 anyone who has it can spend your credits." })
|
|
4275
|
+
] })
|
|
3315
4276
|
] })
|
|
3316
4277
|
] });
|
|
3317
4278
|
}
|
|
3318
4279
|
|
|
3319
4280
|
// src/components/manage/SetupSnippet.tsx
|
|
3320
|
-
var
|
|
3321
|
-
var
|
|
3322
|
-
var
|
|
4281
|
+
var import_react10 = require("react");
|
|
4282
|
+
var import_ui11 = require("@goodwidget/ui");
|
|
4283
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3323
4284
|
var ANTSEED_API_DOCS_URL = "https://antseed.com/docs/guides/using-the-api";
|
|
3324
4285
|
var setupSnippetLineStyle = {
|
|
3325
4286
|
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
|
|
@@ -3340,21 +4301,21 @@ function buildSetupSnippet() {
|
|
|
3340
4301
|
].join("\n");
|
|
3341
4302
|
}
|
|
3342
4303
|
function SetupSnippet() {
|
|
3343
|
-
const [expanded, setExpanded] = (0,
|
|
3344
|
-
const [copied, setCopied] = (0,
|
|
4304
|
+
const [expanded, setExpanded] = (0, import_react10.useState)(false);
|
|
4305
|
+
const [copied, setCopied] = (0, import_react10.useState)(false);
|
|
3345
4306
|
const snippet = buildSetupSnippet();
|
|
3346
4307
|
const copyText = snippet.replace(/\n\n+/g, "\n").trim();
|
|
3347
4308
|
const lines = snippet.trim().split("\n");
|
|
3348
4309
|
async function handleCopy() {
|
|
3349
|
-
const copied2 = await (0,
|
|
4310
|
+
const copied2 = await (0, import_ui11.copyTextToClipboard)(copyText);
|
|
3350
4311
|
if (!copied2) return;
|
|
3351
4312
|
setCopied(true);
|
|
3352
4313
|
setTimeout(() => setCopied(false), 2e3);
|
|
3353
4314
|
}
|
|
3354
|
-
return /* @__PURE__ */ (0,
|
|
3355
|
-
/* @__PURE__ */ (0,
|
|
3356
|
-
/* @__PURE__ */ (0,
|
|
3357
|
-
|
|
4315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_ui11.Card, { gap: "$2", children: [
|
|
4316
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_ui11.XStack, { justifyContent: "space-between", alignItems: "center", children: [
|
|
4317
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
4318
|
+
import_ui11.XStack,
|
|
3358
4319
|
{
|
|
3359
4320
|
flex: 1,
|
|
3360
4321
|
justifyContent: "space-between",
|
|
@@ -3362,29 +4323,29 @@ function SetupSnippet() {
|
|
|
3362
4323
|
onPress: () => setExpanded((value) => !value),
|
|
3363
4324
|
cursor: "pointer",
|
|
3364
4325
|
children: [
|
|
3365
|
-
/* @__PURE__ */ (0,
|
|
3366
|
-
/* @__PURE__ */ (0,
|
|
4326
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui11.Text, { fontSize: "$3", fontWeight: "600", children: "API Setup" }),
|
|
4327
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui11.Icon, { name: expanded ? "chevron-up" : "chevron-right", size: "xs", color: "muted" })
|
|
3367
4328
|
]
|
|
3368
4329
|
}
|
|
3369
4330
|
),
|
|
3370
|
-
/* @__PURE__ */ (0,
|
|
4331
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui11.Button, { size: "sm", variant: "ghost", iconSize: "sm", onPress: handleCopy, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui11.Icon, { name: copied ? "check" : "copy", size: "xs", color: copied ? "success" : "text" }) })
|
|
3371
4332
|
] }),
|
|
3372
|
-
expanded && /* @__PURE__ */ (0,
|
|
3373
|
-
/* @__PURE__ */ (0,
|
|
3374
|
-
|
|
4333
|
+
expanded && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_ui11.YStack, { gap: "$2", children: [
|
|
4334
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4335
|
+
import_ui11.YStack,
|
|
3375
4336
|
{
|
|
3376
4337
|
backgroundColor: "$backgroundMuted",
|
|
3377
4338
|
borderRadius: "$2",
|
|
3378
4339
|
padding: "$3",
|
|
3379
4340
|
width: "100%",
|
|
3380
4341
|
gap: "$1",
|
|
3381
|
-
children: lines.map((line, index) => /* @__PURE__ */ (0,
|
|
4342
|
+
children: lines.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui11.Text, { color: "$text", style: setupSnippetLineStyle, children: line.length > 0 ? line : " " }, index))
|
|
3382
4343
|
}
|
|
3383
4344
|
),
|
|
3384
|
-
/* @__PURE__ */ (0,
|
|
4345
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_ui11.Text, { fontSize: "$1", secondary: true, children: [
|
|
3385
4346
|
"To connect AI tools to the AntSeed AI provider, see the",
|
|
3386
4347
|
" ",
|
|
3387
|
-
/* @__PURE__ */ (0,
|
|
4348
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui11.Anchor, { href: ANTSEED_API_DOCS_URL, target: "_blank", children: "AntSeed API guide" }),
|
|
3388
4349
|
"."
|
|
3389
4350
|
] })
|
|
3390
4351
|
] })
|
|
@@ -3392,9 +4353,9 @@ function SetupSnippet() {
|
|
|
3392
4353
|
}
|
|
3393
4354
|
|
|
3394
4355
|
// src/components/history/HistoryTab.tsx
|
|
3395
|
-
var
|
|
3396
|
-
var
|
|
3397
|
-
var
|
|
4356
|
+
var import_react11 = require("react");
|
|
4357
|
+
var import_ui12 = require("@goodwidget/ui");
|
|
4358
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3398
4359
|
var STATUS_OPTIONS = [
|
|
3399
4360
|
{ label: "All", value: "all" },
|
|
3400
4361
|
{ label: "Funded", value: "funded" },
|
|
@@ -3466,10 +4427,10 @@ function entryDetailRows(entry) {
|
|
|
3466
4427
|
return rows;
|
|
3467
4428
|
}
|
|
3468
4429
|
function EntryDetailRow({ label, value }) {
|
|
3469
|
-
return /* @__PURE__ */ (0,
|
|
3470
|
-
/* @__PURE__ */ (0,
|
|
3471
|
-
/* @__PURE__ */ (0,
|
|
3472
|
-
|
|
4430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.XStack, { gap: "$2", alignItems: "flex-start", width: "100%", children: [
|
|
4431
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$1", fontWeight: "600", secondary: true, minWidth: 72, flexShrink: 0, children: label }),
|
|
4432
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4433
|
+
import_ui12.Text,
|
|
3473
4434
|
{
|
|
3474
4435
|
fontSize: "$1",
|
|
3475
4436
|
flex: 1,
|
|
@@ -3589,9 +4550,9 @@ function CreditHistoryEntryRow({
|
|
|
3589
4550
|
const amounts = amountLines(entry);
|
|
3590
4551
|
const detailRows = entryDetailRows(entry);
|
|
3591
4552
|
const titleColor = entry.fundingStatus === "failed" ? "$error" : "$color";
|
|
3592
|
-
return /* @__PURE__ */ (0,
|
|
3593
|
-
/* @__PURE__ */ (0,
|
|
3594
|
-
|
|
4553
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.Card, { gap: "$2", children: [
|
|
4554
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
4555
|
+
import_ui12.XStack,
|
|
3595
4556
|
{
|
|
3596
4557
|
alignItems: "center",
|
|
3597
4558
|
gap: "$3",
|
|
@@ -3599,8 +4560,8 @@ function CreditHistoryEntryRow({
|
|
|
3599
4560
|
cursor: "pointer",
|
|
3600
4561
|
onPress: onToggle,
|
|
3601
4562
|
children: [
|
|
3602
|
-
/* @__PURE__ */ (0,
|
|
3603
|
-
|
|
4563
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4564
|
+
import_ui12.YStack,
|
|
3604
4565
|
{
|
|
3605
4566
|
width: 40,
|
|
3606
4567
|
height: 40,
|
|
@@ -3609,8 +4570,8 @@ function CreditHistoryEntryRow({
|
|
|
3609
4570
|
justifyContent: "center",
|
|
3610
4571
|
backgroundColor: entryIconBackground(entry),
|
|
3611
4572
|
flexShrink: 0,
|
|
3612
|
-
children: /* @__PURE__ */ (0,
|
|
3613
|
-
|
|
4573
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4574
|
+
import_ui12.Icon,
|
|
3614
4575
|
{
|
|
3615
4576
|
name: entryIconName(entry),
|
|
3616
4577
|
size: "sm",
|
|
@@ -3619,11 +4580,11 @@ function CreditHistoryEntryRow({
|
|
|
3619
4580
|
)
|
|
3620
4581
|
}
|
|
3621
4582
|
),
|
|
3622
|
-
/* @__PURE__ */ (0,
|
|
3623
|
-
/* @__PURE__ */ (0,
|
|
3624
|
-
/* @__PURE__ */ (0,
|
|
3625
|
-
/* @__PURE__ */ (0,
|
|
3626
|
-
|
|
4583
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { flex: 1, gap: "$0.5", minWidth: 0, children: [
|
|
4584
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$3", fontWeight: "700", color: titleColor, children: sourceLabel(entry.source) }),
|
|
4585
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.XStack, { alignItems: "center", gap: "$1", children: [
|
|
4586
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4587
|
+
import_ui12.YStack,
|
|
3627
4588
|
{
|
|
3628
4589
|
width: 6,
|
|
3629
4590
|
height: 6,
|
|
@@ -3631,18 +4592,18 @@ function CreditHistoryEntryRow({
|
|
|
3631
4592
|
backgroundColor: accent
|
|
3632
4593
|
}
|
|
3633
4594
|
),
|
|
3634
|
-
/* @__PURE__ */ (0,
|
|
4595
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$1", fontWeight: "600", color: accent, letterSpacing: 0.4, children: statusLabel(entry.fundingStatus) })
|
|
3635
4596
|
] })
|
|
3636
4597
|
] }),
|
|
3637
|
-
/* @__PURE__ */ (0,
|
|
3638
|
-
amounts?.primary ? /* @__PURE__ */ (0,
|
|
3639
|
-
amounts?.secondary ? /* @__PURE__ */ (0,
|
|
3640
|
-
/* @__PURE__ */ (0,
|
|
4598
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { alignItems: "flex-end", gap: "$0.5", flexShrink: 0, children: [
|
|
4599
|
+
amounts?.primary ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$3", fontWeight: "700", color: amountColor, children: amounts.primary }) : null,
|
|
4600
|
+
amounts?.secondary ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$2", fontWeight: "600", color: amountColor, children: amounts.secondary }) : null,
|
|
4601
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$1", secondary: true, children: formatEntryDate(entry.createdAt) })
|
|
3641
4602
|
] })
|
|
3642
4603
|
]
|
|
3643
4604
|
}
|
|
3644
4605
|
),
|
|
3645
|
-
expanded && detailRows.length > 0 ? /* @__PURE__ */ (0,
|
|
4606
|
+
expanded && detailRows.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.YStack, { gap: "$1.5", paddingTop: "$1", children: detailRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(EntryDetailRow, { label: row.label, value: row.value }, row.label)) }) : null
|
|
3646
4607
|
] });
|
|
3647
4608
|
}
|
|
3648
4609
|
function SourceFilterChip({
|
|
@@ -3650,8 +4611,8 @@ function SourceFilterChip({
|
|
|
3650
4611
|
selected,
|
|
3651
4612
|
onPress
|
|
3652
4613
|
}) {
|
|
3653
|
-
return /* @__PURE__ */ (0,
|
|
3654
|
-
|
|
4614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4615
|
+
import_ui12.XStack,
|
|
3655
4616
|
{
|
|
3656
4617
|
tag: "button",
|
|
3657
4618
|
role: "checkbox",
|
|
@@ -3673,8 +4634,8 @@ function SourceFilterChip({
|
|
|
3673
4634
|
},
|
|
3674
4635
|
onPress,
|
|
3675
4636
|
flexShrink: 0,
|
|
3676
|
-
children: /* @__PURE__ */ (0,
|
|
3677
|
-
|
|
4637
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4638
|
+
import_ui12.Text,
|
|
3678
4639
|
{
|
|
3679
4640
|
fontSize: "$2",
|
|
3680
4641
|
fontWeight: selected ? "700" : "500",
|
|
@@ -3690,11 +4651,11 @@ function StatusFilterSelect({
|
|
|
3690
4651
|
value,
|
|
3691
4652
|
onValueChange
|
|
3692
4653
|
}) {
|
|
3693
|
-
const [open, setOpen] = (0,
|
|
4654
|
+
const [open, setOpen] = (0, import_react11.useState)(false);
|
|
3694
4655
|
const selected = STATUS_OPTIONS.find((option) => option.value === value);
|
|
3695
|
-
return /* @__PURE__ */ (0,
|
|
3696
|
-
/* @__PURE__ */ (0,
|
|
3697
|
-
|
|
4656
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { flex: 1, minWidth: 0, position: "relative", zIndex: open ? 20 : 1, children: [
|
|
4657
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
4658
|
+
import_ui12.XStack,
|
|
3698
4659
|
{
|
|
3699
4660
|
tag: "button",
|
|
3700
4661
|
role: "combobox",
|
|
@@ -3710,16 +4671,16 @@ function StatusFilterSelect({
|
|
|
3710
4671
|
cursor: "pointer",
|
|
3711
4672
|
onPress: () => setOpen((current) => !current),
|
|
3712
4673
|
children: [
|
|
3713
|
-
/* @__PURE__ */ (0,
|
|
4674
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.Text, { fontSize: "$2", color: "$placeholderColor", numberOfLines: 1, flex: 1, children: [
|
|
3714
4675
|
"Status: ",
|
|
3715
4676
|
selected?.label ?? "All"
|
|
3716
4677
|
] }),
|
|
3717
|
-
/* @__PURE__ */ (0,
|
|
4678
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Icon, { name: open ? "chevron-up" : "chevron-down", size: "xs", color: "muted" })
|
|
3718
4679
|
]
|
|
3719
4680
|
}
|
|
3720
4681
|
),
|
|
3721
|
-
open ? /* @__PURE__ */ (0,
|
|
3722
|
-
|
|
4682
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4683
|
+
import_ui12.YStack,
|
|
3723
4684
|
{
|
|
3724
4685
|
position: "absolute",
|
|
3725
4686
|
top: "100%",
|
|
@@ -3732,8 +4693,93 @@ function StatusFilterSelect({
|
|
|
3732
4693
|
backgroundColor: "$backgroundDark",
|
|
3733
4694
|
overflow: "hidden",
|
|
3734
4695
|
zIndex: 30,
|
|
3735
|
-
children: STATUS_OPTIONS.map((option) => /* @__PURE__ */ (0,
|
|
3736
|
-
|
|
4696
|
+
children: STATUS_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4697
|
+
import_ui12.XStack,
|
|
4698
|
+
{
|
|
4699
|
+
tag: "button",
|
|
4700
|
+
role: "option",
|
|
4701
|
+
paddingHorizontal: "$3",
|
|
4702
|
+
paddingVertical: "$2",
|
|
4703
|
+
cursor: "pointer",
|
|
4704
|
+
backgroundColor: option.value === value ? "$infoMuted" : "transparent",
|
|
4705
|
+
hoverStyle: { backgroundColor: "$backgroundPress" },
|
|
4706
|
+
onPress: () => {
|
|
4707
|
+
onValueChange(option.value);
|
|
4708
|
+
setOpen(false);
|
|
4709
|
+
},
|
|
4710
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4711
|
+
import_ui12.Text,
|
|
4712
|
+
{
|
|
4713
|
+
fontSize: "$2",
|
|
4714
|
+
fontWeight: option.value === value ? "700" : "500",
|
|
4715
|
+
color: option.value === value ? "$primary" : "$color",
|
|
4716
|
+
children: option.label
|
|
4717
|
+
}
|
|
4718
|
+
)
|
|
4719
|
+
},
|
|
4720
|
+
option.value
|
|
4721
|
+
))
|
|
4722
|
+
}
|
|
4723
|
+
) : null
|
|
4724
|
+
] });
|
|
4725
|
+
}
|
|
4726
|
+
function BuyerFilterSelect({
|
|
4727
|
+
value,
|
|
4728
|
+
buyers,
|
|
4729
|
+
onValueChange
|
|
4730
|
+
}) {
|
|
4731
|
+
const [open, setOpen] = (0, import_react11.useState)(false);
|
|
4732
|
+
if (buyers.length === 0) return null;
|
|
4733
|
+
const options = [
|
|
4734
|
+
{ value: BUYER_FILTER_ALL, label: "All buyers" },
|
|
4735
|
+
...buyers.map((b) => ({
|
|
4736
|
+
value: b.address,
|
|
4737
|
+
label: b.label ?? `${b.address.slice(0, 6)}\u2026${b.address.slice(-4)}`
|
|
4738
|
+
}))
|
|
4739
|
+
];
|
|
4740
|
+
const selected = options.find((o) => o.value === value) ?? options[0];
|
|
4741
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { flex: 1, minWidth: 0, position: "relative", zIndex: open ? 25 : 1, children: [
|
|
4742
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
4743
|
+
import_ui12.XStack,
|
|
4744
|
+
{
|
|
4745
|
+
tag: "button",
|
|
4746
|
+
role: "listbox",
|
|
4747
|
+
height: "$7",
|
|
4748
|
+
alignItems: "center",
|
|
4749
|
+
justifyContent: "space-between",
|
|
4750
|
+
gap: "$2",
|
|
4751
|
+
paddingHorizontal: "$3",
|
|
4752
|
+
borderRadius: "$3",
|
|
4753
|
+
borderWidth: 1,
|
|
4754
|
+
borderColor: "$borderColor",
|
|
4755
|
+
backgroundColor: "$backgroundDark",
|
|
4756
|
+
cursor: "pointer",
|
|
4757
|
+
onPress: () => setOpen((current) => !current),
|
|
4758
|
+
children: [
|
|
4759
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.Text, { fontSize: "$2", color: "$placeholderColor", numberOfLines: 1, flex: 1, children: [
|
|
4760
|
+
"Buyer: ",
|
|
4761
|
+
selected?.label ?? "All buyers"
|
|
4762
|
+
] }),
|
|
4763
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Icon, { name: open ? "chevron-up" : "chevron-down", size: "xs", color: "muted" })
|
|
4764
|
+
]
|
|
4765
|
+
}
|
|
4766
|
+
),
|
|
4767
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4768
|
+
import_ui12.YStack,
|
|
4769
|
+
{
|
|
4770
|
+
position: "absolute",
|
|
4771
|
+
top: "100%",
|
|
4772
|
+
left: 0,
|
|
4773
|
+
right: 0,
|
|
4774
|
+
marginTop: "$1",
|
|
4775
|
+
borderRadius: "$3",
|
|
4776
|
+
borderWidth: 1,
|
|
4777
|
+
borderColor: "$borderColor",
|
|
4778
|
+
backgroundColor: "$backgroundDark",
|
|
4779
|
+
overflow: "hidden",
|
|
4780
|
+
zIndex: 35,
|
|
4781
|
+
children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4782
|
+
import_ui12.XStack,
|
|
3737
4783
|
{
|
|
3738
4784
|
tag: "button",
|
|
3739
4785
|
role: "option",
|
|
@@ -3746,8 +4792,8 @@ function StatusFilterSelect({
|
|
|
3746
4792
|
onValueChange(option.value);
|
|
3747
4793
|
setOpen(false);
|
|
3748
4794
|
},
|
|
3749
|
-
children: /* @__PURE__ */ (0,
|
|
3750
|
-
|
|
4795
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4796
|
+
import_ui12.Text,
|
|
3751
4797
|
{
|
|
3752
4798
|
fontSize: "$2",
|
|
3753
4799
|
fontWeight: option.value === value ? "700" : "500",
|
|
@@ -3762,149 +4808,681 @@ function StatusFilterSelect({
|
|
|
3762
4808
|
) : null
|
|
3763
4809
|
] });
|
|
3764
4810
|
}
|
|
3765
|
-
function HistoryTab({ state, actions }) {
|
|
3766
|
-
const {
|
|
3767
|
-
selectedSources,
|
|
3768
|
-
statusFilter,
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
const
|
|
3780
|
-
const
|
|
3781
|
-
const
|
|
3782
|
-
const
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
/* @__PURE__ */ (0,
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
/* @__PURE__ */ (0,
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
4811
|
+
function HistoryTab({ state, actions, knownBuyers = [] }) {
|
|
4812
|
+
const {
|
|
4813
|
+
selectedSources,
|
|
4814
|
+
statusFilter,
|
|
4815
|
+
buyerAddressFilter,
|
|
4816
|
+
fromDate,
|
|
4817
|
+
toDate,
|
|
4818
|
+
entries,
|
|
4819
|
+
hasMore,
|
|
4820
|
+
loading,
|
|
4821
|
+
loadingMore,
|
|
4822
|
+
error,
|
|
4823
|
+
activeSources
|
|
4824
|
+
} = state;
|
|
4825
|
+
const [expandedEntryId, setExpandedEntryId] = (0, import_react11.useState)(null);
|
|
4826
|
+
const defaultRange = (0, import_react11.useMemo)(() => getLast90DaysRange(), []);
|
|
4827
|
+
const isDefaultRange = fromDate === defaultRange.from && toDate === defaultRange.to;
|
|
4828
|
+
const rangeSummary = isDefaultRange ? `Last ${HISTORY_LOOKBACK_DAYS} days activity` : `${formatShortDate(fromDate)} \u2013 ${formatShortDate(toDate)}`;
|
|
4829
|
+
const accumulatedG = (0, import_react11.useMemo)(
|
|
4830
|
+
() => formatAccumulatedG(sumFilteredGdWei(entries)),
|
|
4831
|
+
[entries]
|
|
4832
|
+
);
|
|
4833
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { gap: "$3", width: "100%", children: [
|
|
4834
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.Card, { gap: "$3", children: [
|
|
4835
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.XStack, { alignItems: "flex-start", justifyContent: "space-between", gap: "$2", width: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { flex: 1, gap: "$0.5", minWidth: 0, children: [
|
|
4836
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Heading, { level: 4, children: "AI Credit History" }),
|
|
4837
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$1", secondary: true, children: rangeSummary })
|
|
4838
|
+
] }) }),
|
|
4839
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { gap: "$1", children: [
|
|
4840
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$1", fontWeight: "600", secondary: true, letterSpacing: 0.6, children: "TOTAL ACCUMULATED" }),
|
|
4841
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$7", fontWeight: "700", color: "$color", children: accumulatedG })
|
|
4842
|
+
] })
|
|
4843
|
+
] }),
|
|
4844
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.XStack, { gap: "$2", flexWrap: "wrap", width: "100%", children: SOURCE_PILL_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4845
|
+
SourceFilterChip,
|
|
4846
|
+
{
|
|
4847
|
+
label: option.label,
|
|
4848
|
+
selected: selectedSources[option.id],
|
|
4849
|
+
onPress: () => actions.setSourceChecked(option.id, !selectedSources[option.id])
|
|
4850
|
+
},
|
|
4851
|
+
option.id
|
|
4852
|
+
)) }),
|
|
4853
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.XStack, { gap: "$2", alignItems: "center", width: "100%", children: [
|
|
4854
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4855
|
+
StatusFilterSelect,
|
|
4856
|
+
{
|
|
4857
|
+
value: statusFilter,
|
|
4858
|
+
onValueChange: actions.setStatusFilter
|
|
4859
|
+
}
|
|
4860
|
+
),
|
|
4861
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4862
|
+
BuyerFilterSelect,
|
|
4863
|
+
{
|
|
4864
|
+
value: buyerAddressFilter,
|
|
4865
|
+
buyers: knownBuyers,
|
|
4866
|
+
onValueChange: actions.setBuyerAddressFilter
|
|
4867
|
+
}
|
|
4868
|
+
)
|
|
4869
|
+
] }),
|
|
4870
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.XStack, { gap: "$2", width: "100%", children: [
|
|
4871
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.YStack, { flex: 1, minWidth: 0, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4872
|
+
import_ui12.Input,
|
|
4873
|
+
{
|
|
4874
|
+
size: "sm",
|
|
4875
|
+
type: "date",
|
|
4876
|
+
label: "From",
|
|
4877
|
+
value: fromDate,
|
|
4878
|
+
onChangeText: actions.setFromDate
|
|
4879
|
+
}
|
|
4880
|
+
) }),
|
|
4881
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.YStack, { flex: 1, minWidth: 0, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4882
|
+
import_ui12.Input,
|
|
4883
|
+
{
|
|
4884
|
+
size: "sm",
|
|
4885
|
+
type: "date",
|
|
4886
|
+
label: "To",
|
|
4887
|
+
value: toDate,
|
|
4888
|
+
onChangeText: actions.setToDate
|
|
4889
|
+
}
|
|
4890
|
+
) })
|
|
4891
|
+
] }),
|
|
4892
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.XStack, { alignItems: "center", justifyContent: "space-between", gap: "$2", width: "100%", children: [
|
|
4893
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$1", fontWeight: "700", secondary: true, letterSpacing: 0.6, children: "CREDIT HISTORY" }),
|
|
4894
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4895
|
+
import_ui12.XStack,
|
|
4896
|
+
{
|
|
4897
|
+
tag: "button",
|
|
4898
|
+
backgroundColor: "transparent",
|
|
4899
|
+
borderWidth: 0,
|
|
4900
|
+
padding: 0,
|
|
4901
|
+
cursor: entries.length > 0 ? "pointer" : "default",
|
|
4902
|
+
opacity: entries.length > 0 ? 1 : 0.5,
|
|
4903
|
+
hoverStyle: { opacity: entries.length > 0 ? 0.85 : 0.5 },
|
|
4904
|
+
pressStyle: { opacity: entries.length > 0 ? 0.7 : 0.5 },
|
|
4905
|
+
onPress: () => {
|
|
4906
|
+
if (entries.length === 0) return;
|
|
4907
|
+
exportEntriesCsv(entries);
|
|
4908
|
+
},
|
|
4909
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$2", fontWeight: "600", color: "$primary", children: "Export CSV" })
|
|
4910
|
+
}
|
|
4911
|
+
)
|
|
4912
|
+
] }),
|
|
4913
|
+
loading ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Card, { gap: "$2", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { alignItems: "center", paddingVertical: "$4", gap: "$2", children: [
|
|
4914
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Spinner, { size: "sm" }),
|
|
4915
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$2", secondary: true, children: "Loading credit history\u2026" })
|
|
4916
|
+
] }) }) : error ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Card, { gap: "$2", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { gap: "$2", paddingVertical: "$2", children: [
|
|
4917
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { color: "$error", fontSize: "$2", children: error }),
|
|
4918
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4919
|
+
import_ui12.Button,
|
|
4920
|
+
{
|
|
4921
|
+
variant: "outline",
|
|
4922
|
+
size: "sm",
|
|
4923
|
+
alignSelf: "flex-start",
|
|
4924
|
+
...compactButtonProps,
|
|
4925
|
+
onPress: () => {
|
|
4926
|
+
void actions.reload();
|
|
4927
|
+
},
|
|
4928
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.ButtonText, { children: "Retry" })
|
|
4929
|
+
}
|
|
4930
|
+
)
|
|
4931
|
+
] }) }) : activeSources.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Card, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$2", secondary: true, children: "Select at least one source to view history." }) }) : entries.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Card, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$2", secondary: true, children: "No credit history matches these filters." }) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.YStack, { gap: "$2", width: "100%", children: entries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4932
|
+
CreditHistoryEntryRow,
|
|
4933
|
+
{
|
|
4934
|
+
entry,
|
|
4935
|
+
expanded: expandedEntryId === entry.id,
|
|
4936
|
+
onToggle: () => setExpandedEntryId((current) => current === entry.id ? null : entry.id)
|
|
4937
|
+
},
|
|
4938
|
+
entry.id
|
|
4939
|
+
)) }),
|
|
4940
|
+
!loading && !error && hasMore && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
4941
|
+
import_ui12.Button,
|
|
4942
|
+
{
|
|
4943
|
+
variant: "outline",
|
|
4944
|
+
size: "sm",
|
|
4945
|
+
alignSelf: "center",
|
|
4946
|
+
disabled: loadingMore,
|
|
4947
|
+
...compactButtonProps,
|
|
4948
|
+
onPress: () => {
|
|
4949
|
+
void actions.loadMore();
|
|
4950
|
+
},
|
|
4951
|
+
children: [
|
|
4952
|
+
loadingMore ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Spinner, { size: "sm" }) : null,
|
|
4953
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.ButtonText, { children: loadingMore ? "Loading\u2026" : "Load more" })
|
|
4954
|
+
]
|
|
4955
|
+
}
|
|
4956
|
+
)
|
|
4957
|
+
] });
|
|
4958
|
+
}
|
|
4959
|
+
|
|
4960
|
+
// src/components/setup/SetupGuidanceCard.tsx
|
|
4961
|
+
var import_ui14 = require("@goodwidget/ui");
|
|
4962
|
+
|
|
4963
|
+
// src/components/setup/SetupBonusHighlight.tsx
|
|
4964
|
+
var import_react12 = require("react");
|
|
4965
|
+
var import_ui13 = require("@goodwidget/ui");
|
|
4966
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
4967
|
+
function SetupBonusHighlight({
|
|
4968
|
+
depositBonusPercent,
|
|
4969
|
+
streamBonusPercent,
|
|
4970
|
+
isGoodIdVerified
|
|
4971
|
+
}) {
|
|
4972
|
+
const [isExpanded, setIsExpanded] = (0, import_react12.useState)(false);
|
|
4973
|
+
const maxBonusPercent = Math.max(depositBonusPercent, streamBonusPercent);
|
|
4974
|
+
if (maxBonusPercent <= 0) return null;
|
|
4975
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Card, { gap: "$2", padding: "$3", backgroundColor: "$backgroundHover", children: [
|
|
4976
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
4977
|
+
import_ui13.XStack,
|
|
4978
|
+
{
|
|
4979
|
+
gap: "$3",
|
|
4980
|
+
alignItems: "center",
|
|
4981
|
+
cursor: "pointer",
|
|
4982
|
+
accessibilityRole: "button",
|
|
4983
|
+
"aria-expanded": isExpanded,
|
|
4984
|
+
onPress: () => setIsExpanded((previous) => !previous),
|
|
4985
|
+
children: [
|
|
4986
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
4987
|
+
import_ui13.YStack,
|
|
4988
|
+
{
|
|
4989
|
+
width: 34,
|
|
4990
|
+
height: 34,
|
|
4991
|
+
borderRadius: "$2",
|
|
4992
|
+
backgroundColor: "$backgroundPress",
|
|
4993
|
+
alignItems: "center",
|
|
4994
|
+
justifyContent: "center",
|
|
4995
|
+
flexShrink: 0,
|
|
4996
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui13.Icon, { name: "party-popper", size: "sm", color: "primary" })
|
|
4997
|
+
}
|
|
4998
|
+
),
|
|
4999
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.YStack, { flex: 1, gap: 2, children: [
|
|
5000
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Text, { fontSize: "$3", fontWeight: "700", children: [
|
|
5001
|
+
"Up to ",
|
|
5002
|
+
maxBonusPercent,
|
|
5003
|
+
"% more AI credits"
|
|
5004
|
+
] }),
|
|
5005
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Text, { fontSize: "$2", lineHeight: "$3", children: [
|
|
5006
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Text, { fontSize: "$2", fontWeight: "700", color: "$primary", children: [
|
|
5007
|
+
"+",
|
|
5008
|
+
depositBonusPercent,
|
|
5009
|
+
"%"
|
|
5010
|
+
] }),
|
|
5011
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Text, { fontSize: "$2", secondary: true, children: [
|
|
5012
|
+
" ",
|
|
5013
|
+
"on deposits,",
|
|
5014
|
+
" "
|
|
5015
|
+
] }),
|
|
5016
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Text, { fontSize: "$2", fontWeight: "700", color: "$primary", children: [
|
|
5017
|
+
"+",
|
|
5018
|
+
streamBonusPercent,
|
|
5019
|
+
"%"
|
|
5020
|
+
] }),
|
|
5021
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Text, { fontSize: "$2", secondary: true, children: [
|
|
5022
|
+
" ",
|
|
5023
|
+
"on streams \u2014 paid with G$"
|
|
5024
|
+
] })
|
|
5025
|
+
] })
|
|
5026
|
+
] }),
|
|
5027
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui13.Icon, { name: isExpanded ? "chevron-up" : "chevron-down", size: "xs", color: "muted" })
|
|
5028
|
+
]
|
|
5029
|
+
}
|
|
5030
|
+
),
|
|
5031
|
+
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui13.YStack, { backgroundColor: "$background", borderRadius: "$2", padding: "$3", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui13.Text, { fontSize: "$2", secondary: true, lineHeight: "$3", children: isGoodIdVerified ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
5032
|
+
"Your wallet is",
|
|
5033
|
+
" ",
|
|
5034
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui13.Text, { fontSize: "$2", fontWeight: "700", children: "GoodID verified" }),
|
|
5035
|
+
", so the bonus is applied automatically to deposits and streams."
|
|
5036
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
5037
|
+
"Bonus applies to",
|
|
5038
|
+
" ",
|
|
5039
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui13.Text, { fontSize: "$2", fontWeight: "700", children: "verified GoodDollar wallets" }),
|
|
5040
|
+
" ",
|
|
5041
|
+
"only. Not verified? Claim UBI first via GoodWallet or GoodDapp \u2014 takes a minute, then this kicks in automatically."
|
|
5042
|
+
] }) }) })
|
|
5043
|
+
] });
|
|
5044
|
+
}
|
|
5045
|
+
|
|
5046
|
+
// src/components/setup/SetupGuidanceCard.tsx
|
|
5047
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
5048
|
+
var ANTSEED_SITE_URL = "https://antseed.com";
|
|
5049
|
+
function SetupGuidanceCard({
|
|
5050
|
+
onHowToUse,
|
|
5051
|
+
onFaq,
|
|
5052
|
+
activeHelpView,
|
|
5053
|
+
depositBonusPercent,
|
|
5054
|
+
streamBonusPercent,
|
|
5055
|
+
isGoodIdVerified
|
|
5056
|
+
}) {
|
|
5057
|
+
return (
|
|
5058
|
+
// Rendered flush on the widget background — no card surface, so it reads as
|
|
5059
|
+
// part of the header rather than a separate panel.
|
|
5060
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.YStack, { gap: "$3", paddingHorizontal: "$1", children: [
|
|
5061
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.Text, { fontSize: "$3", secondary: true, lineHeight: "$4", children: "Buy AI credits with G$ for Claude Code, Codex, chat & other AI tools." }),
|
|
5062
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5063
|
+
SetupBonusHighlight,
|
|
5064
|
+
{
|
|
5065
|
+
depositBonusPercent,
|
|
5066
|
+
streamBonusPercent,
|
|
5067
|
+
isGoodIdVerified
|
|
5068
|
+
}
|
|
5069
|
+
),
|
|
5070
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.YStack, { gap: "$1", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.Text, { variant: "label", secondary: true, fontSize: "$1", fontWeight: "700", letterSpacing: 1, children: "WHAT'S INVOLVED:" }) }),
|
|
5071
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.YStack, { gap: "$3", children: [
|
|
5072
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.XStack, { gap: "$3", alignItems: "flex-start", children: [
|
|
5073
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5074
|
+
import_ui14.YStack,
|
|
5075
|
+
{
|
|
5076
|
+
width: 22,
|
|
5077
|
+
height: 22,
|
|
5078
|
+
borderRadius: "$full",
|
|
5079
|
+
backgroundColor: "$backgroundHover",
|
|
5080
|
+
alignItems: "center",
|
|
5081
|
+
justifyContent: "center",
|
|
5082
|
+
flexShrink: 0,
|
|
5083
|
+
marginTop: 2,
|
|
5084
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.Text, { fontSize: "$1", fontWeight: "700", color: "$secondary", children: "1" })
|
|
5085
|
+
}
|
|
5086
|
+
),
|
|
5087
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.Text, { fontSize: "$2", flex: 1, lineHeight: "$3", children: [
|
|
5088
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.Text, { fontSize: "$2", fontWeight: "700", children: [
|
|
5089
|
+
"Get G$",
|
|
5090
|
+
" "
|
|
5091
|
+
] }),
|
|
5092
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.Text, { fontSize: "$2", secondary: true, children: "\u2014 claim UBI via GoodWallet, or buy G$ with your wallet of choice" })
|
|
5093
|
+
] })
|
|
5094
|
+
] }),
|
|
5095
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.XStack, { gap: "$3", alignItems: "flex-start", children: [
|
|
5096
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5097
|
+
import_ui14.YStack,
|
|
5098
|
+
{
|
|
5099
|
+
width: 22,
|
|
5100
|
+
height: 22,
|
|
5101
|
+
borderRadius: "$full",
|
|
5102
|
+
backgroundColor: "$backgroundHover",
|
|
5103
|
+
alignItems: "center",
|
|
5104
|
+
justifyContent: "center",
|
|
5105
|
+
flexShrink: 0,
|
|
5106
|
+
marginTop: 2,
|
|
5107
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.Text, { fontSize: "$1", fontWeight: "700", color: "$secondary", children: "2" })
|
|
5108
|
+
}
|
|
5109
|
+
),
|
|
5110
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.Text, { fontSize: "$2", flex: 1, lineHeight: "$3", children: [
|
|
5111
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.Text, { fontSize: "$2", fontWeight: "700", children: [
|
|
5112
|
+
"Download Antseed",
|
|
5113
|
+
" "
|
|
5114
|
+
] }),
|
|
5115
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.Text, { fontSize: "$2", secondary: true, children: "\u2014 the free desktop app that runs your credits locally" })
|
|
5116
|
+
] })
|
|
5117
|
+
] })
|
|
5118
|
+
] }),
|
|
5119
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.Separator, {}),
|
|
5120
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.XStack, { gap: "$2", flexWrap: "wrap", children: [
|
|
5121
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5122
|
+
import_ui14.Button,
|
|
5123
|
+
{
|
|
5124
|
+
flexGrow: 1,
|
|
5125
|
+
flexBasis: "auto",
|
|
5126
|
+
size: "sm",
|
|
5127
|
+
variant: activeHelpView === "how-to-use" ? "default" : "outline",
|
|
5128
|
+
onPress: onHowToUse,
|
|
5129
|
+
borderRadius: "$3",
|
|
5130
|
+
paddingHorizontal: "$2",
|
|
5131
|
+
minWidth: 0,
|
|
5132
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.ButtonText, { numberOfLines: 1, children: "How to use" })
|
|
5133
|
+
}
|
|
5134
|
+
),
|
|
5135
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5136
|
+
import_ui14.Anchor,
|
|
5137
|
+
{
|
|
5138
|
+
href: ANTSEED_SITE_URL,
|
|
5139
|
+
target: "_blank",
|
|
5140
|
+
style: { flexGrow: 1, flexBasis: "auto", textDecorationLine: "none", minWidth: 0 },
|
|
5141
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
5142
|
+
import_ui14.Button,
|
|
5143
|
+
{
|
|
5144
|
+
size: "sm",
|
|
5145
|
+
variant: "outline",
|
|
5146
|
+
width: "100%",
|
|
5147
|
+
borderRadius: "$3",
|
|
5148
|
+
paddingHorizontal: "$2",
|
|
5149
|
+
gap: "$1",
|
|
5150
|
+
children: [
|
|
5151
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.ButtonText, { numberOfLines: 1, children: "Antseed site" }),
|
|
5152
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.Icon, { name: "external-link", size: "xs", color: "muted" })
|
|
5153
|
+
]
|
|
5154
|
+
}
|
|
5155
|
+
)
|
|
5156
|
+
}
|
|
5157
|
+
),
|
|
5158
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5159
|
+
import_ui14.Button,
|
|
5160
|
+
{
|
|
5161
|
+
flexGrow: 1,
|
|
5162
|
+
flexBasis: "auto",
|
|
5163
|
+
size: "sm",
|
|
5164
|
+
variant: activeHelpView === "faq" ? "default" : "outline",
|
|
5165
|
+
onPress: onFaq,
|
|
5166
|
+
borderRadius: "$3",
|
|
5167
|
+
paddingHorizontal: "$2",
|
|
5168
|
+
minWidth: 0,
|
|
5169
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.ButtonText, { numberOfLines: 1, children: "FAQs" })
|
|
5170
|
+
}
|
|
5171
|
+
)
|
|
5172
|
+
] })
|
|
5173
|
+
] })
|
|
5174
|
+
);
|
|
5175
|
+
}
|
|
5176
|
+
|
|
5177
|
+
// src/components/setup/HowToUseView.tsx
|
|
5178
|
+
var import_ui15 = require("@goodwidget/ui");
|
|
5179
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
5180
|
+
var VIDEO_URL = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
|
|
5181
|
+
var WRITTEN_GUIDE_URL = "https://app.notion.com/p/gooddollar/Full-Setup-Walkthrough-Widget-AntSeed-VPR-3c0f258232f08184bee9cd440cc93059";
|
|
5182
|
+
var QUICK_SUMMARY_STEPS = [
|
|
5183
|
+
{
|
|
5184
|
+
index: 1,
|
|
5185
|
+
title: "First, connect your wallet",
|
|
5186
|
+
tabLabel: "Buy",
|
|
5187
|
+
description: "Any wallet holding G$ works. Verified GoodDollar wallets get the bonus automatically."
|
|
5188
|
+
},
|
|
5189
|
+
{
|
|
5190
|
+
index: 2,
|
|
5191
|
+
title: "Then complete the one-time setup",
|
|
5192
|
+
tabLabel: "Buy",
|
|
5193
|
+
description: "Download Antseed, generate your signer key, and authorize your wallet \u2014 three quick taps."
|
|
5194
|
+
},
|
|
5195
|
+
{
|
|
5196
|
+
index: 3,
|
|
5197
|
+
title: "Head to Manage to buy or stream credits",
|
|
5198
|
+
tabLabel: "Manage",
|
|
5199
|
+
description: "Deposit once (+10%) or stream continuously (+20%), then confirm."
|
|
5200
|
+
},
|
|
5201
|
+
{
|
|
5202
|
+
index: 4,
|
|
5203
|
+
title: "Finally, connect Antseed to start using them",
|
|
5204
|
+
tabLabel: "Connect",
|
|
5205
|
+
description: 'Import your signer key \u2014 no separate "start" step, it just works from there.'
|
|
5206
|
+
}
|
|
5207
|
+
];
|
|
5208
|
+
function HowToUseView({ onBack }) {
|
|
5209
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.YStack, { gap: "$4", children: [
|
|
5210
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.Button, { variant: "text", alignSelf: "flex-start", onPress: onBack, gap: "$1", children: [
|
|
5211
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Icon, { name: "arrow-left", size: "xs", color: "primary" }),
|
|
5212
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.ButtonText, { color: "$primary", fontSize: "$2", children: "Back to setup" })
|
|
5213
|
+
] }),
|
|
5214
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$2", secondary: true, lineHeight: "$3", children: "New here? Start with the 3-minute video \u2014 it covers the whole journey, start to finish." }),
|
|
5215
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Anchor, { href: VIDEO_URL, target: "_blank", style: { textDecorationLine: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
5216
|
+
import_ui15.Card,
|
|
5217
|
+
{
|
|
5218
|
+
backgroundColor: "$backgroundHover",
|
|
5219
|
+
gap: "$2",
|
|
5220
|
+
paddingVertical: "$4",
|
|
5221
|
+
paddingHorizontal: "$4",
|
|
5222
|
+
hoverStyle: { opacity: 0.9 },
|
|
5223
|
+
children: [
|
|
5224
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.XStack, { justifyContent: "flex-end", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Card, { backgroundColor: "$backgroundPress", paddingHorizontal: "$2", paddingVertical: 2, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$1", fontWeight: "700", children: "3:12" }) }) }),
|
|
5225
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.XStack, { justifyContent: "center", paddingVertical: "$6", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
5226
|
+
import_ui15.YStack,
|
|
5227
|
+
{
|
|
5228
|
+
width: 56,
|
|
5229
|
+
height: 56,
|
|
5230
|
+
borderRadius: "$full",
|
|
5231
|
+
backgroundColor: "$background",
|
|
5232
|
+
alignItems: "center",
|
|
5233
|
+
justifyContent: "center",
|
|
5234
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Icon, { name: "play", size: "md", color: "primary" })
|
|
5235
|
+
}
|
|
5236
|
+
) }),
|
|
5237
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.YStack, { gap: "$1", children: [
|
|
5238
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$2", fontWeight: "700", children: "Getting started with AI credits" }),
|
|
5239
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$1", secondary: true, children: "Wallet \u2192 buy credits \u2192 connect Antseed" })
|
|
5240
|
+
] })
|
|
5241
|
+
]
|
|
5242
|
+
}
|
|
5243
|
+
) }),
|
|
5244
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Anchor, { href: WRITTEN_GUIDE_URL, target: "_blank", style: { textDecorationLine: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Card, { backgroundColor: "$backgroundHover", paddingVertical: "$3", paddingHorizontal: "$4", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.XStack, { gap: "$3", alignItems: "center", justifyContent: "space-between", children: [
|
|
5245
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.XStack, { gap: "$3", alignItems: "center", flex: 1, children: [
|
|
5246
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Icon, { name: "file-text", size: "md", color: "muted" }),
|
|
5247
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.YStack, { flex: 1, gap: "$1", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.Text, { fontSize: "$2", lineHeight: "$3", children: [
|
|
5248
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.Text, { fontSize: "$2", fontWeight: "700", children: [
|
|
5249
|
+
"Full written guide",
|
|
5250
|
+
" "
|
|
5251
|
+
] }),
|
|
5252
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$2", secondary: true, children: "Step-by-step walkthrough with screenshots, on Notion" })
|
|
5253
|
+
] }) })
|
|
5254
|
+
] }),
|
|
5255
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Icon, { name: "external-link", size: "xs", color: "muted" })
|
|
5256
|
+
] }) }) }),
|
|
5257
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.YStack, { gap: "$3", children: [
|
|
5258
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { variant: "label", secondary: true, fontSize: "$1", fontWeight: "700", letterSpacing: 1, children: "QUICK SUMMARY" }),
|
|
5259
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.YStack, { gap: "$4", children: QUICK_SUMMARY_STEPS.map((step) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.XStack, { gap: "$3", alignItems: "flex-start", children: [
|
|
5260
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
5261
|
+
import_ui15.YStack,
|
|
5262
|
+
{
|
|
5263
|
+
width: 24,
|
|
5264
|
+
height: 24,
|
|
5265
|
+
borderRadius: "$full",
|
|
5266
|
+
backgroundColor: "$backgroundHover",
|
|
5267
|
+
alignItems: "center",
|
|
5268
|
+
justifyContent: "center",
|
|
5269
|
+
flexShrink: 0,
|
|
5270
|
+
marginTop: 2,
|
|
5271
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$1", fontWeight: "700", color: "$secondary", children: step.index })
|
|
5272
|
+
}
|
|
5273
|
+
),
|
|
5274
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.YStack, { flex: 1, gap: "$1", children: [
|
|
5275
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.XStack, { gap: "$2", alignItems: "center", flexWrap: "wrap", children: [
|
|
5276
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$2", fontWeight: "700", children: step.title }),
|
|
5277
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Badge, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.BadgeText, { children: step.tabLabel }) })
|
|
5278
|
+
] }),
|
|
5279
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$2", secondary: true, lineHeight: "$3", children: step.description })
|
|
5280
|
+
] })
|
|
5281
|
+
] }, step.index)) }),
|
|
5282
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$1", secondary: true, textAlign: "center", paddingTop: "$1", children: "Your G$ wallet is never exposed \u2014 only the scoped signer key." })
|
|
5283
|
+
] })
|
|
5284
|
+
] });
|
|
5285
|
+
}
|
|
5286
|
+
|
|
5287
|
+
// src/components/setup/SetupFaqView.tsx
|
|
5288
|
+
var import_react13 = require("react");
|
|
5289
|
+
var import_ui16 = require("@goodwidget/ui");
|
|
5290
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
5291
|
+
var SETUP_FAQ_ITEMS = [
|
|
5292
|
+
{
|
|
5293
|
+
id: "goodwallet-only",
|
|
5294
|
+
question: "I only claim UBI with GoodWallet \u2014 can I still use this?",
|
|
5295
|
+
answer: "Yes. Any wallet that holds G$ on Celo works. Connect your wallet here, generate a signer key, and you can buy credits just like any other G$ holder."
|
|
5296
|
+
},
|
|
5297
|
+
{
|
|
5298
|
+
id: "ubi-savings",
|
|
5299
|
+
question: "Will this ever touch my daily UBI savings?",
|
|
5300
|
+
answer: "No. Only the G$ amount you explicitly deposit or stream is used. Your UBI balance and savings remain untouched unless you choose to spend them."
|
|
5301
|
+
},
|
|
5302
|
+
{
|
|
5303
|
+
id: "deposit-vs-stream",
|
|
5304
|
+
question: "Deposit or stream \u2014 which should I pick?",
|
|
5305
|
+
answer: "A one-time deposit gives you credits immediately (+10% bonus with GoodID). A monthly stream drips G$ over time and earns a higher +20% bonus \u2014 ideal if you use AI tools regularly. You can combine both."
|
|
5306
|
+
},
|
|
5307
|
+
{
|
|
5308
|
+
id: "lost-signer-key",
|
|
5309
|
+
question: "What if I lose my signer key?",
|
|
5310
|
+
answer: 'Re-connect your payer wallet and click "Sign & Generate Key" again \u2014 it derives the same key deterministically. You can also import a backup private key in the Manage tab.'
|
|
5311
|
+
},
|
|
5312
|
+
{
|
|
5313
|
+
id: "no-code",
|
|
5314
|
+
question: "Do I need to know how to code?",
|
|
5315
|
+
answer: "No. The whole flow \u2014 wallet connect, signer key, credit purchase \u2014 is done in this widget. After that, Antseed provides a desktop app that handles the rest without any command-line steps."
|
|
5316
|
+
},
|
|
5317
|
+
{
|
|
5318
|
+
id: "unused-credits",
|
|
5319
|
+
question: "Can I get unused credits back?",
|
|
5320
|
+
answer: "Yes. The Withdrawable amount shown in the Manage tab can be reclaimed to your payer wallet. Bonus credits (from GoodID) are not withdrawable \u2014 they are for AI usage only."
|
|
5321
|
+
},
|
|
5322
|
+
{
|
|
5323
|
+
id: "compatible-tools",
|
|
5324
|
+
question: "Which tools can I actually use my credits with?",
|
|
5325
|
+
answer: "Any tool that supports AntSeed-compatible AI credits, including Claude Code, Codex, and other AI coding assistants. The Antseed desktop app integrates them without extra configuration."
|
|
5326
|
+
},
|
|
5327
|
+
{
|
|
5328
|
+
id: "antseed-safe",
|
|
5329
|
+
question: "Is Antseed safe? Can I check it myself?",
|
|
5330
|
+
answer: "Antseed is an open-source desktop application. Your G$ wallet private key is never shared with it \u2014 only the scoped signer key is exposed. You can audit the source code on the AntSeed GitHub repository."
|
|
5331
|
+
}
|
|
5332
|
+
];
|
|
5333
|
+
function FaqItem({ question, answer, expanded, onToggle }) {
|
|
5334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_ui16.YStack, { gap: "$1", children: [
|
|
5335
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
5336
|
+
import_ui16.XStack,
|
|
3808
5337
|
{
|
|
3809
|
-
|
|
3810
|
-
|
|
5338
|
+
justifyContent: "space-between",
|
|
5339
|
+
alignItems: "center",
|
|
5340
|
+
gap: "$2",
|
|
5341
|
+
onPress: onToggle,
|
|
5342
|
+
cursor: "pointer",
|
|
5343
|
+
children: [
|
|
5344
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.Text, { fontSize: "$2", fontWeight: "600", flex: 1, children: question }),
|
|
5345
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.Icon, { name: expanded ? "chevron-up" : "chevron-down", size: "xs", color: "muted" })
|
|
5346
|
+
]
|
|
3811
5347
|
}
|
|
3812
|
-
)
|
|
3813
|
-
/* @__PURE__ */ (0,
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
}
|
|
3823
|
-
) }),
|
|
3824
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui13.YStack, { flex: 1, minWidth: 0, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3825
|
-
import_ui13.Input,
|
|
3826
|
-
{
|
|
3827
|
-
size: "sm",
|
|
3828
|
-
type: "date",
|
|
3829
|
-
label: "To",
|
|
3830
|
-
value: toDate,
|
|
3831
|
-
onChangeText: actions.setToDate
|
|
3832
|
-
}
|
|
3833
|
-
) })
|
|
5348
|
+
),
|
|
5349
|
+
expanded && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.Text, { fontSize: "$2", secondary: true, lineHeight: "$3", children: answer })
|
|
5350
|
+
] });
|
|
5351
|
+
}
|
|
5352
|
+
function SetupFaqView({ onBack }) {
|
|
5353
|
+
const [expandedId, setExpandedId] = (0, import_react13.useState)(null);
|
|
5354
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_ui16.YStack, { gap: "$4", children: [
|
|
5355
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_ui16.Button, { variant: "text", alignSelf: "flex-start", onPress: onBack, gap: "$1", children: [
|
|
5356
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.Icon, { name: "arrow-left", size: "xs", color: "primary" }),
|
|
5357
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.ButtonText, { color: "$primary", fontSize: "$2", children: "Back to setup" })
|
|
3834
5358
|
] }),
|
|
3835
|
-
/* @__PURE__ */ (0,
|
|
3836
|
-
/* @__PURE__ */ (0,
|
|
3837
|
-
/* @__PURE__ */ (0,
|
|
3838
|
-
|
|
5359
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.Card, { gap: "$3", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.YStack, { gap: "$3", children: SETUP_FAQ_ITEMS.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_ui16.YStack, { gap: "$3", children: [
|
|
5360
|
+
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.Separator, {}),
|
|
5361
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
5362
|
+
FaqItem,
|
|
3839
5363
|
{
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
hoverStyle: { opacity: entries.length > 0 ? 0.85 : 0.5 },
|
|
3847
|
-
pressStyle: { opacity: entries.length > 0 ? 0.7 : 0.5 },
|
|
3848
|
-
onPress: () => {
|
|
3849
|
-
if (entries.length === 0) return;
|
|
3850
|
-
exportEntriesCsv(entries);
|
|
3851
|
-
},
|
|
3852
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui13.Text, { fontSize: "$2", fontWeight: "600", color: "$primary", children: "Export CSV" })
|
|
5364
|
+
question: item.question,
|
|
5365
|
+
answer: item.answer,
|
|
5366
|
+
expanded: expandedId === item.id,
|
|
5367
|
+
onToggle: () => {
|
|
5368
|
+
setExpandedId((current) => current === item.id ? null : item.id);
|
|
5369
|
+
}
|
|
3853
5370
|
}
|
|
3854
5371
|
)
|
|
3855
|
-
] })
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
5372
|
+
] }, item.id)) }) })
|
|
5373
|
+
] });
|
|
5374
|
+
}
|
|
5375
|
+
|
|
5376
|
+
// src/components/setup/SetupOnboardingFlow.tsx
|
|
5377
|
+
var import_react14 = require("react");
|
|
5378
|
+
var import_ui17 = require("@goodwidget/ui");
|
|
5379
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
5380
|
+
var ANTSEED_DOWNLOAD_URL = "https://antseed.com";
|
|
5381
|
+
function SetupOnboardingFlow({ state, actions }) {
|
|
5382
|
+
const [downloadOpened, setDownloadOpened] = (0, import_react14.useState)(false);
|
|
5383
|
+
const [drawerOpen, setDrawerOpen] = (0, import_react14.useState)(false);
|
|
5384
|
+
const [drawerStep, setDrawerStep] = (0, import_react14.useState)(null);
|
|
5385
|
+
const hasSignerKey = Boolean(state.buyerPubKey);
|
|
5386
|
+
const downloadCompleted = downloadOpened || hasSignerKey;
|
|
5387
|
+
const steps = [
|
|
5388
|
+
{
|
|
5389
|
+
id: "download",
|
|
5390
|
+
title: "Download Antseed",
|
|
5391
|
+
description: "The app that runs your credits locally \u2014 required once",
|
|
5392
|
+
status: downloadCompleted ? "completed" : "ready"
|
|
5393
|
+
},
|
|
5394
|
+
{
|
|
5395
|
+
id: "signer",
|
|
5396
|
+
title: "Signer key",
|
|
5397
|
+
description: "Generate or import \u2014 separate from your wallet",
|
|
5398
|
+
status: !downloadCompleted ? "pending" : hasSignerKey ? "completed" : "ready"
|
|
5399
|
+
},
|
|
5400
|
+
{
|
|
5401
|
+
id: "authorize",
|
|
5402
|
+
title: "Authorize Wallet",
|
|
5403
|
+
description: "One-time permission \u2014 scoped to Base credits",
|
|
5404
|
+
status: !hasSignerKey ? "pending" : state.operatorConsented ? "completed" : "ready"
|
|
5405
|
+
}
|
|
5406
|
+
];
|
|
5407
|
+
const openSignerDrawer = (0, import_react14.useCallback)(() => {
|
|
5408
|
+
setDrawerStep("signer");
|
|
5409
|
+
setDrawerOpen(true);
|
|
5410
|
+
}, []);
|
|
5411
|
+
const handleSignerReady = (0, import_react14.useCallback)(() => {
|
|
5412
|
+
if (state.operatorConsented) {
|
|
5413
|
+
setDrawerOpen(false);
|
|
5414
|
+
setDrawerStep(null);
|
|
5415
|
+
return;
|
|
5416
|
+
}
|
|
5417
|
+
setDrawerStep("authorize");
|
|
5418
|
+
}, [state.operatorConsented]);
|
|
5419
|
+
const handleStepPress = (0, import_react14.useCallback)(
|
|
5420
|
+
(stepId) => {
|
|
5421
|
+
if (stepId === "download") {
|
|
5422
|
+
if (typeof window !== "undefined") {
|
|
5423
|
+
window.open(ANTSEED_DOWNLOAD_URL, "_blank", "noopener,noreferrer");
|
|
3872
5424
|
}
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
5425
|
+
setDownloadOpened(true);
|
|
5426
|
+
return;
|
|
5427
|
+
}
|
|
5428
|
+
if (stepId === "signer" && downloadCompleted) {
|
|
5429
|
+
openSignerDrawer();
|
|
5430
|
+
}
|
|
5431
|
+
if (stepId === "authorize" && hasSignerKey) {
|
|
5432
|
+
setDrawerStep("authorize");
|
|
5433
|
+
setDrawerOpen(true);
|
|
5434
|
+
}
|
|
5435
|
+
},
|
|
5436
|
+
[downloadCompleted, hasSignerKey, openSignerDrawer]
|
|
5437
|
+
);
|
|
5438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
5439
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
5440
|
+
import_ui17.Stepper,
|
|
3876
5441
|
{
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
}
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
import_ui13.Button,
|
|
5442
|
+
steps,
|
|
5443
|
+
activeStepId: downloadCompleted ? hasSignerKey ? "authorize" : "signer" : "download",
|
|
5444
|
+
onStepPress: handleStepPress
|
|
5445
|
+
}
|
|
5446
|
+
),
|
|
5447
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
5448
|
+
import_ui17.Drawer,
|
|
3885
5449
|
{
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
...compactButtonProps,
|
|
3891
|
-
onPress: () => {
|
|
3892
|
-
void actions.loadMore();
|
|
5450
|
+
open: drawerOpen && drawerStep !== null,
|
|
5451
|
+
onClose: () => {
|
|
5452
|
+
setDrawerOpen(false);
|
|
5453
|
+
setDrawerStep(null);
|
|
3893
5454
|
},
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
/* @__PURE__ */ (0,
|
|
3897
|
-
|
|
5455
|
+
height: "full",
|
|
5456
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_ui17.ScrollArea, { width: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_ui17.YStack, { gap: "$3", paddingBottom: "$4", width: "100%", children: [
|
|
5457
|
+
drawerStep === "signer" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SignerKeyPanel, { state, actions, onProceed: handleSignerReady }) : null,
|
|
5458
|
+
drawerStep === "authorize" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
5459
|
+
OperatorConsentStep,
|
|
5460
|
+
{
|
|
5461
|
+
embedded: true,
|
|
5462
|
+
buyerPubKey: state.buyerPubKey,
|
|
5463
|
+
buyerPrvKey: state.buyerPrvKey ?? null,
|
|
5464
|
+
operatorSignature: state.operatorSignature ?? null,
|
|
5465
|
+
operatorConsented: state.operatorConsented,
|
|
5466
|
+
operatorConsentPending: state.operatorConsentPending,
|
|
5467
|
+
onSign: actions.signOperatorConsent
|
|
5468
|
+
}
|
|
5469
|
+
) : null
|
|
5470
|
+
] }) })
|
|
3898
5471
|
}
|
|
3899
5472
|
)
|
|
3900
5473
|
] });
|
|
3901
5474
|
}
|
|
3902
5475
|
|
|
3903
5476
|
// src/components/flow/purchaseFlowUtils.ts
|
|
5477
|
+
function isSelectedDerivedBuyer(state) {
|
|
5478
|
+
if (!state.buyerPubKey || !state.derivedBuyerAddress) return false;
|
|
5479
|
+
return state.buyerPubKey.toLowerCase() === state.derivedBuyerAddress.toLowerCase();
|
|
5480
|
+
}
|
|
3904
5481
|
function mapStatusToActiveStep(state, buyerPubKeySaved) {
|
|
3905
5482
|
if (state.operatorConsented) return "pay";
|
|
3906
|
-
if (!state.buyerPubKey
|
|
3907
|
-
if (!
|
|
5483
|
+
if (!state.buyerPubKey) return "buyer_key";
|
|
5484
|
+
if (!state.buyerPrvKey && !state.operatorSignature) return "buyer_key";
|
|
5485
|
+
if (isSelectedDerivedBuyer(state) && state.buyerPrvKey && !buyerPubKeySaved) return "buyer_key";
|
|
3908
5486
|
if (!state.operatorConsented) return "consent";
|
|
3909
5487
|
if (state.status === "purchase_setup" || state.status === "quote_ready" || state.status === "payment_pending" || state.status === "payment_confirmed" || state.status === "payment_failed")
|
|
3910
5488
|
return "pay";
|
|
@@ -3918,10 +5496,11 @@ function getActiveFlowStepActionLabel(state, step, buyerPubKeySaved) {
|
|
|
3918
5496
|
switch (step) {
|
|
3919
5497
|
case "buyer_key":
|
|
3920
5498
|
if (!state.buyerPubKey) return "Sign & Generate Key";
|
|
3921
|
-
if (!buyerPubKeySaved) return "Continue
|
|
3922
|
-
return "View
|
|
5499
|
+
if (!buyerPubKeySaved) return "Continue Signer Key";
|
|
5500
|
+
return "View Signer Key";
|
|
3923
5501
|
case "consent":
|
|
3924
|
-
|
|
5502
|
+
if (state.operatorConsentPending) return "Submitting Authorization\u2026";
|
|
5503
|
+
return state.operatorConsented ? "View Authorization" : "Authorize Wallet";
|
|
3925
5504
|
case "pay":
|
|
3926
5505
|
return "Set Amounts & Pay";
|
|
3927
5506
|
default:
|
|
@@ -3930,8 +5509,8 @@ function getActiveFlowStepActionLabel(state, step, buyerPubKeySaved) {
|
|
|
3930
5509
|
}
|
|
3931
5510
|
|
|
3932
5511
|
// src/components/flow/AiCreditsFlowStepper.tsx
|
|
3933
|
-
var
|
|
3934
|
-
var
|
|
5512
|
+
var import_ui18 = require("@goodwidget/ui");
|
|
5513
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3935
5514
|
var STEP_ORDER = ["buyer_key", "consent", "pay"];
|
|
3936
5515
|
function AiCreditsFlowStepper({
|
|
3937
5516
|
state,
|
|
@@ -3950,19 +5529,20 @@ function AiCreditsFlowStepper({
|
|
|
3950
5529
|
if (step === "pay" && (state.status === "payment_pending" || state.status === "payment_confirmed")) {
|
|
3951
5530
|
return "active";
|
|
3952
5531
|
}
|
|
5532
|
+
if (step === "consent" && state.operatorConsentPending) return "active";
|
|
3953
5533
|
return "ready";
|
|
3954
5534
|
}
|
|
3955
5535
|
const steps = [
|
|
3956
5536
|
{
|
|
3957
5537
|
id: "buyer_key",
|
|
3958
|
-
title: "
|
|
3959
|
-
description: "Generate or
|
|
5538
|
+
title: "Signer Key",
|
|
5539
|
+
description: "Generate or import your AI credits signer key",
|
|
3960
5540
|
status: getStepStatus("buyer_key")
|
|
3961
5541
|
},
|
|
3962
5542
|
{
|
|
3963
5543
|
id: "consent",
|
|
3964
|
-
title: "
|
|
3965
|
-
description: "
|
|
5544
|
+
title: "Authorize Wallet",
|
|
5545
|
+
description: state.operatorConsentPending ? "Submitting authorization\u2026" : "Authorize GoodDollar to manage your Base credits",
|
|
3966
5546
|
status: getStepStatus("consent")
|
|
3967
5547
|
},
|
|
3968
5548
|
{
|
|
@@ -3977,42 +5557,42 @@ function AiCreditsFlowStepper({
|
|
|
3977
5557
|
if (!step || step.status === "completed" || step.status === "pending") return;
|
|
3978
5558
|
onStepPress?.(stepId);
|
|
3979
5559
|
}
|
|
3980
|
-
return /* @__PURE__ */ (0,
|
|
3981
|
-
|
|
5560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
5561
|
+
import_ui18.Stepper,
|
|
3982
5562
|
{
|
|
3983
5563
|
steps,
|
|
3984
5564
|
activeStepId: activeStep,
|
|
3985
5565
|
onStepPress: onStepPress ? handleStepPress : void 0,
|
|
3986
|
-
header: /* @__PURE__ */ (0,
|
|
5566
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui18.Heading, { level: 5, secondary: true, children: "Purchase Flow" })
|
|
3987
5567
|
}
|
|
3988
5568
|
);
|
|
3989
5569
|
}
|
|
3990
5570
|
|
|
3991
5571
|
// src/components/flow/AiCreditsPurchaseFlow.tsx
|
|
3992
|
-
var
|
|
3993
|
-
var
|
|
3994
|
-
var
|
|
5572
|
+
var import_react15 = require("react");
|
|
5573
|
+
var import_ui19 = require("@goodwidget/ui");
|
|
5574
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3995
5575
|
function AiCreditsPurchaseFlow({
|
|
3996
5576
|
state,
|
|
3997
5577
|
actions,
|
|
3998
5578
|
isPending,
|
|
3999
5579
|
onPay
|
|
4000
5580
|
}) {
|
|
4001
|
-
const [buyerPubKeySaved, setBuyerPubKeySaved] = (0,
|
|
5581
|
+
const [buyerPubKeySaved, setBuyerPubKeySaved] = (0, import_react15.useState)(false);
|
|
4002
5582
|
const activeStep = getAiCreditsActiveFlowStep(state, buyerPubKeySaved);
|
|
4003
|
-
const [drawerOpen, setDrawerOpen] = (0,
|
|
4004
|
-
const [drawerStep, setDrawerStep] = (0,
|
|
4005
|
-
const prevActiveStepRef = (0,
|
|
4006
|
-
const goodIdTabPendingRef = (0,
|
|
4007
|
-
(0,
|
|
5583
|
+
const [drawerOpen, setDrawerOpen] = (0, import_react15.useState)(false);
|
|
5584
|
+
const [drawerStep, setDrawerStep] = (0, import_react15.useState)(null);
|
|
5585
|
+
const prevActiveStepRef = (0, import_react15.useRef)(null);
|
|
5586
|
+
const goodIdTabPendingRef = (0, import_react15.useRef)(false);
|
|
5587
|
+
(0, import_react15.useEffect)(() => {
|
|
4008
5588
|
setBuyerPubKeySaved(false);
|
|
4009
5589
|
}, [state.buyerPubKey]);
|
|
4010
|
-
(0,
|
|
5590
|
+
(0, import_react15.useEffect)(() => {
|
|
4011
5591
|
if (activeStep !== "consent" || state.operatorConsented) return;
|
|
4012
5592
|
if (!state.address || !state.buyerPubKey) return;
|
|
4013
5593
|
void actions.syncOperatorConsentFromChain();
|
|
4014
5594
|
}, [activeStep, state.operatorConsented, state.address, state.buyerPubKey, actions]);
|
|
4015
|
-
(0,
|
|
5595
|
+
(0, import_react15.useEffect)(() => {
|
|
4016
5596
|
if (!activeStep) {
|
|
4017
5597
|
setDrawerOpen(false);
|
|
4018
5598
|
setDrawerStep(null);
|
|
@@ -4021,14 +5601,12 @@ function AiCreditsPurchaseFlow({
|
|
|
4021
5601
|
}
|
|
4022
5602
|
const previousStep = prevActiveStepRef.current;
|
|
4023
5603
|
prevActiveStepRef.current = activeStep;
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
setDrawerOpen(false);
|
|
4027
|
-
} else if (previousStep !== activeStep) {
|
|
5604
|
+
if (previousStep != null && previousStep !== activeStep) {
|
|
5605
|
+
setDrawerStep(activeStep);
|
|
4028
5606
|
setDrawerOpen(true);
|
|
4029
5607
|
}
|
|
4030
5608
|
}, [activeStep]);
|
|
4031
|
-
(0,
|
|
5609
|
+
(0, import_react15.useEffect)(() => {
|
|
4032
5610
|
if (typeof window === "undefined") return;
|
|
4033
5611
|
const onFocus = () => {
|
|
4034
5612
|
if (!goodIdTabPendingRef.current) return;
|
|
@@ -4041,7 +5619,7 @@ function AiCreditsPurchaseFlow({
|
|
|
4041
5619
|
window.addEventListener("focus", onFocus);
|
|
4042
5620
|
return () => window.removeEventListener("focus", onFocus);
|
|
4043
5621
|
}, [activeStep]);
|
|
4044
|
-
const handleVerifyGoodId = (0,
|
|
5622
|
+
const handleVerifyGoodId = (0, import_react15.useCallback)(async () => {
|
|
4045
5623
|
try {
|
|
4046
5624
|
const started = await actions.verifyGoodId();
|
|
4047
5625
|
if (started) {
|
|
@@ -4054,7 +5632,7 @@ function AiCreditsPurchaseFlow({
|
|
|
4054
5632
|
}
|
|
4055
5633
|
}
|
|
4056
5634
|
}, [actions, activeStep]);
|
|
4057
|
-
const openDrawer = (0,
|
|
5635
|
+
const openDrawer = (0, import_react15.useCallback)(
|
|
4058
5636
|
(step) => {
|
|
4059
5637
|
if (step !== activeStep && !(step === "pay" && state.status === "payment_failed")) return;
|
|
4060
5638
|
setDrawerStep(step);
|
|
@@ -4062,7 +5640,7 @@ function AiCreditsPurchaseFlow({
|
|
|
4062
5640
|
},
|
|
4063
5641
|
[activeStep, state.status]
|
|
4064
5642
|
);
|
|
4065
|
-
const handleStepPress = (0,
|
|
5643
|
+
const handleStepPress = (0, import_react15.useCallback)(
|
|
4066
5644
|
(stepId) => {
|
|
4067
5645
|
openDrawer(stepId);
|
|
4068
5646
|
},
|
|
@@ -4073,7 +5651,7 @@ function AiCreditsPurchaseFlow({
|
|
|
4073
5651
|
if (!step) return null;
|
|
4074
5652
|
switch (step) {
|
|
4075
5653
|
case "buyer_key":
|
|
4076
|
-
return /* @__PURE__ */ (0,
|
|
5654
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4077
5655
|
BuyerKeyPanel,
|
|
4078
5656
|
{
|
|
4079
5657
|
embedded: true,
|
|
@@ -4085,18 +5663,20 @@ function AiCreditsPurchaseFlow({
|
|
|
4085
5663
|
}
|
|
4086
5664
|
);
|
|
4087
5665
|
case "consent":
|
|
4088
|
-
return /* @__PURE__ */ (0,
|
|
5666
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4089
5667
|
OperatorConsentStep,
|
|
4090
5668
|
{
|
|
4091
5669
|
embedded: true,
|
|
4092
5670
|
buyerPubKey: state.buyerPubKey,
|
|
4093
5671
|
buyerPrvKey: state.buyerPrvKey ?? null,
|
|
5672
|
+
operatorSignature: state.operatorSignature ?? null,
|
|
4094
5673
|
operatorConsented: state.operatorConsented,
|
|
5674
|
+
operatorConsentPending: state.operatorConsentPending,
|
|
4095
5675
|
onSign: actions.signOperatorConsent
|
|
4096
5676
|
}
|
|
4097
5677
|
);
|
|
4098
5678
|
case "pay":
|
|
4099
|
-
return /* @__PURE__ */ (0,
|
|
5679
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4100
5680
|
AmountPicker,
|
|
4101
5681
|
{
|
|
4102
5682
|
embedded: true,
|
|
@@ -4119,8 +5699,8 @@ function AiCreditsPurchaseFlow({
|
|
|
4119
5699
|
return null;
|
|
4120
5700
|
}
|
|
4121
5701
|
}
|
|
4122
|
-
return /* @__PURE__ */ (0,
|
|
4123
|
-
/* @__PURE__ */ (0,
|
|
5702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
5703
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4124
5704
|
AiCreditsFlowStepper,
|
|
4125
5705
|
{
|
|
4126
5706
|
state,
|
|
@@ -4128,8 +5708,8 @@ function AiCreditsPurchaseFlow({
|
|
|
4128
5708
|
onStepPress: handleStepPress
|
|
4129
5709
|
}
|
|
4130
5710
|
),
|
|
4131
|
-
!drawerOpen && actionLabel && activeStep && /* @__PURE__ */ (0,
|
|
4132
|
-
|
|
5711
|
+
!drawerOpen && actionLabel && activeStep && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
5712
|
+
import_ui19.Button,
|
|
4133
5713
|
{
|
|
4134
5714
|
fullWidth: true,
|
|
4135
5715
|
size: "sm",
|
|
@@ -4137,34 +5717,137 @@ function AiCreditsPurchaseFlow({
|
|
|
4137
5717
|
onPress: () => {
|
|
4138
5718
|
openDrawer(activeStep);
|
|
4139
5719
|
},
|
|
4140
|
-
children: /* @__PURE__ */ (0,
|
|
5720
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui19.ButtonText, { children: actionLabel })
|
|
4141
5721
|
}
|
|
4142
5722
|
),
|
|
4143
|
-
/* @__PURE__ */ (0,
|
|
4144
|
-
|
|
5723
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
5724
|
+
import_ui19.Drawer,
|
|
4145
5725
|
{
|
|
4146
5726
|
open: drawerOpen && drawerStep !== null,
|
|
4147
5727
|
onClose: () => {
|
|
4148
5728
|
setDrawerOpen(false);
|
|
4149
5729
|
},
|
|
4150
5730
|
height: "full",
|
|
4151
|
-
children: /* @__PURE__ */ (0,
|
|
5731
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui19.ScrollArea, { width: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui19.YStack, { gap: "$3", paddingBottom: "$4", width: "100%", children: renderDrawerContent(drawerStep) }) })
|
|
4152
5732
|
}
|
|
4153
5733
|
)
|
|
4154
5734
|
] });
|
|
4155
5735
|
}
|
|
4156
5736
|
|
|
5737
|
+
// src/components/shared/WalletChip.tsx
|
|
5738
|
+
var import_react16 = require("react");
|
|
5739
|
+
var import_ui20 = require("@goodwidget/ui");
|
|
5740
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
5741
|
+
function shortAddress2(address) {
|
|
5742
|
+
return `${address.slice(0, 5)}\u2026${address.slice(-3)}`;
|
|
5743
|
+
}
|
|
5744
|
+
function WalletChip({
|
|
5745
|
+
address,
|
|
5746
|
+
onDisconnect,
|
|
5747
|
+
disconnectLabel = "Disconnect",
|
|
5748
|
+
disconnectIcon = "log-out",
|
|
5749
|
+
disabled = false
|
|
5750
|
+
}) {
|
|
5751
|
+
const [isMenuOpen, setIsMenuOpen] = (0, import_react16.useState)(false);
|
|
5752
|
+
const [disconnectMessage, setDisconnectMessage] = (0, import_react16.useState)(null);
|
|
5753
|
+
(0, import_react16.useEffect)(() => {
|
|
5754
|
+
if (disabled) setIsMenuOpen(false);
|
|
5755
|
+
}, [disabled]);
|
|
5756
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_ui20.XStack, { position: "relative", alignItems: "center", opacity: disabled ? 0.5 : 1, children: [
|
|
5757
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
5758
|
+
import_ui20.XStack,
|
|
5759
|
+
{
|
|
5760
|
+
gap: "$1.5",
|
|
5761
|
+
alignItems: "center",
|
|
5762
|
+
paddingHorizontal: "$2",
|
|
5763
|
+
paddingVertical: "$1",
|
|
5764
|
+
borderRadius: "$full",
|
|
5765
|
+
borderWidth: 1,
|
|
5766
|
+
borderColor: "$borderColor",
|
|
5767
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
5768
|
+
onPress: () => {
|
|
5769
|
+
if (disabled) return;
|
|
5770
|
+
setDisconnectMessage(null);
|
|
5771
|
+
setIsMenuOpen((open) => !open);
|
|
5772
|
+
},
|
|
5773
|
+
"aria-label": "Wallet options",
|
|
5774
|
+
"aria-disabled": disabled,
|
|
5775
|
+
children: [
|
|
5776
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_ui20.YStack, { width: 6, height: 6, borderRadius: "$full", backgroundColor: "$success" }),
|
|
5777
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_ui20.Text, { fontSize: "$1", numberOfLines: 1, children: address ? shortAddress2(address) : "" }),
|
|
5778
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_ui20.Icon, { name: "chevron-down", size: "2xs", color: "muted" })
|
|
5779
|
+
]
|
|
5780
|
+
}
|
|
5781
|
+
),
|
|
5782
|
+
isMenuOpen && !disabled && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
5783
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
5784
|
+
import_ui20.XStack,
|
|
5785
|
+
{
|
|
5786
|
+
position: "fixed",
|
|
5787
|
+
top: 0,
|
|
5788
|
+
left: 0,
|
|
5789
|
+
right: 0,
|
|
5790
|
+
bottom: 0,
|
|
5791
|
+
zIndex: 100,
|
|
5792
|
+
onPress: () => setIsMenuOpen(false)
|
|
5793
|
+
}
|
|
5794
|
+
),
|
|
5795
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
5796
|
+
import_ui20.YStack,
|
|
5797
|
+
{
|
|
5798
|
+
position: "absolute",
|
|
5799
|
+
top: "100%",
|
|
5800
|
+
right: 0,
|
|
5801
|
+
marginTop: "$1",
|
|
5802
|
+
backgroundColor: "$background",
|
|
5803
|
+
borderWidth: 1,
|
|
5804
|
+
borderColor: "$borderColor",
|
|
5805
|
+
borderRadius: "$3",
|
|
5806
|
+
padding: "$1",
|
|
5807
|
+
minWidth: 132,
|
|
5808
|
+
zIndex: 101,
|
|
5809
|
+
children: [
|
|
5810
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
5811
|
+
import_ui20.Button,
|
|
5812
|
+
{
|
|
5813
|
+
size: "sm",
|
|
5814
|
+
variant: "list",
|
|
5815
|
+
height: "$6",
|
|
5816
|
+
paddingHorizontal: "$2",
|
|
5817
|
+
gap: "$1.5",
|
|
5818
|
+
onPress: async () => {
|
|
5819
|
+
if (!onDisconnect) {
|
|
5820
|
+
setDisconnectMessage("Disconnect should be done in your wallet's session");
|
|
5821
|
+
return;
|
|
5822
|
+
}
|
|
5823
|
+
setIsMenuOpen(false);
|
|
5824
|
+
await onDisconnect();
|
|
5825
|
+
},
|
|
5826
|
+
children: [
|
|
5827
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_ui20.Icon, { name: disconnectIcon, size: "xs", color: "muted" }),
|
|
5828
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_ui20.ButtonText, { fontSize: "$2", children: disconnectLabel })
|
|
5829
|
+
]
|
|
5830
|
+
}
|
|
5831
|
+
),
|
|
5832
|
+
disconnectMessage && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_ui20.Text, { variant: "caption", tone: "secondary", padding: "$2", children: disconnectMessage })
|
|
5833
|
+
]
|
|
5834
|
+
}
|
|
5835
|
+
)
|
|
5836
|
+
] })
|
|
5837
|
+
] });
|
|
5838
|
+
}
|
|
5839
|
+
|
|
4157
5840
|
// src/AiCreditsWidget.tsx
|
|
4158
|
-
var
|
|
5841
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4159
5842
|
var CELO_CHAIN_ID3 = 42220;
|
|
4160
|
-
function
|
|
5843
|
+
function SetupConnectPrompt({
|
|
4161
5844
|
onConnect,
|
|
4162
5845
|
connecting
|
|
4163
5846
|
}) {
|
|
4164
|
-
return /* @__PURE__ */ (0,
|
|
4165
|
-
/* @__PURE__ */ (0,
|
|
4166
|
-
/* @__PURE__ */ (0,
|
|
4167
|
-
|
|
5847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.YStack, { gap: "$5", alignItems: "center", paddingVertical: "$6", width: "100%", children: [
|
|
5848
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, center: true, children: "Connect your wallet to get started" }),
|
|
5849
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5850
|
+
import_ui21.CircularActionButton,
|
|
4168
5851
|
{
|
|
4169
5852
|
label: connecting ? "Connecting..." : "Connect Wallet",
|
|
4170
5853
|
pending: connecting,
|
|
@@ -4174,31 +5857,57 @@ function DisconnectedPanel({
|
|
|
4174
5857
|
}
|
|
4175
5858
|
}
|
|
4176
5859
|
)
|
|
4177
|
-
] })
|
|
5860
|
+
] });
|
|
5861
|
+
}
|
|
5862
|
+
function SetupTabPanel({
|
|
5863
|
+
state,
|
|
5864
|
+
actions,
|
|
5865
|
+
onConnect
|
|
5866
|
+
}) {
|
|
5867
|
+
if (needsWalletConnection(state)) {
|
|
5868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5869
|
+
SetupConnectPrompt,
|
|
5870
|
+
{
|
|
5871
|
+
onConnect,
|
|
5872
|
+
connecting: state.status === "connecting"
|
|
5873
|
+
}
|
|
5874
|
+
);
|
|
5875
|
+
}
|
|
5876
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.YStack, { gap: "$4", width: "100%", children: [
|
|
5877
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5878
|
+
AiCreditsHero,
|
|
5879
|
+
{
|
|
5880
|
+
gBalance: state.gBalance,
|
|
5881
|
+
isGoodIdVerified: state.isGoodIdVerified
|
|
5882
|
+
}
|
|
5883
|
+
),
|
|
5884
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, fontSize: "$2", children: "One-time setup, in order \u2014 each step unlocks the next:" }),
|
|
5885
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SetupOnboardingFlow, { state, actions })
|
|
5886
|
+
] });
|
|
4178
5887
|
}
|
|
4179
5888
|
function BuyCreditsPanel({ state, actions, isPending, onPay }) {
|
|
4180
5889
|
let content;
|
|
4181
5890
|
if (state.status === "unsupported_chain") {
|
|
4182
|
-
content = /* @__PURE__ */ (0,
|
|
4183
|
-
/* @__PURE__ */ (0,
|
|
4184
|
-
/* @__PURE__ */ (0,
|
|
4185
|
-
/* @__PURE__ */ (0,
|
|
4186
|
-
|
|
5891
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AiCreditsStatusNotice, { children: [
|
|
5892
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.XStack, { gap: "$2", alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$warning", fontWeight: "700", children: "Wrong Network" }) }),
|
|
5893
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, children: "Please switch to the Celo network to continue." }),
|
|
5894
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5895
|
+
import_ui21.Button,
|
|
4187
5896
|
{
|
|
4188
5897
|
onPress: () => {
|
|
4189
5898
|
void actions.switchChain();
|
|
4190
5899
|
},
|
|
4191
|
-
children: /* @__PURE__ */ (0,
|
|
5900
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.ButtonText, { children: "Switch to Celo" })
|
|
4192
5901
|
}
|
|
4193
5902
|
)
|
|
4194
5903
|
] });
|
|
4195
5904
|
} else if (state.status === "payment_failed") {
|
|
4196
|
-
content = /* @__PURE__ */ (0,
|
|
4197
|
-
/* @__PURE__ */ (0,
|
|
4198
|
-
/* @__PURE__ */ (0,
|
|
4199
|
-
state.error && /* @__PURE__ */ (0,
|
|
5905
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
5906
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AiCreditsStatusNotice, { children: [
|
|
5907
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$error", fontWeight: "700", children: "Payment Failed" }),
|
|
5908
|
+
state.error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, children: state.error })
|
|
4200
5909
|
] }),
|
|
4201
|
-
/* @__PURE__ */ (0,
|
|
5910
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4202
5911
|
AiCreditsPurchaseFlow,
|
|
4203
5912
|
{
|
|
4204
5913
|
state,
|
|
@@ -4209,57 +5918,61 @@ function BuyCreditsPanel({ state, actions, isPending, onPay }) {
|
|
|
4209
5918
|
)
|
|
4210
5919
|
] });
|
|
4211
5920
|
} else if (state.status === "backend_unavailable") {
|
|
4212
|
-
content = /* @__PURE__ */ (0,
|
|
4213
|
-
/* @__PURE__ */ (0,
|
|
4214
|
-
/* @__PURE__ */ (0,
|
|
4215
|
-
/* @__PURE__ */ (0,
|
|
4216
|
-
|
|
5921
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AiCreditsStatusNotice, { children: [
|
|
5922
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$warning", fontWeight: "700", children: "Service Unavailable" }),
|
|
5923
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, children: "The AI credits service is temporarily unavailable. Your wallet has not been charged." }),
|
|
5924
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5925
|
+
import_ui21.Button,
|
|
4217
5926
|
{
|
|
4218
5927
|
onPress: () => {
|
|
4219
5928
|
void actions.retry();
|
|
4220
5929
|
},
|
|
4221
|
-
children: /* @__PURE__ */ (0,
|
|
5930
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.ButtonText, { children: "Retry" })
|
|
4222
5931
|
}
|
|
4223
5932
|
)
|
|
4224
5933
|
] });
|
|
4225
5934
|
} else if (state.status === "insufficient_g_balance") {
|
|
4226
|
-
content = /* @__PURE__ */ (0,
|
|
4227
|
-
/* @__PURE__ */ (0,
|
|
5935
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
5936
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4228
5937
|
AiCreditsHero,
|
|
4229
5938
|
{
|
|
4230
5939
|
gBalance: state.gBalance,
|
|
4231
5940
|
isGoodIdVerified: state.isGoodIdVerified
|
|
4232
5941
|
}
|
|
4233
5942
|
),
|
|
4234
|
-
/* @__PURE__ */ (0,
|
|
4235
|
-
/* @__PURE__ */ (0,
|
|
4236
|
-
/* @__PURE__ */ (0,
|
|
5943
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AiCreditsStatusNotice, { children: [
|
|
5944
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$warning", fontWeight: "700", children: "Insufficient G$ Balance" }),
|
|
5945
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, children: "You need at least 1 G$ to purchase AI credits. Top up your wallet and try again." })
|
|
4237
5946
|
] })
|
|
4238
5947
|
] });
|
|
4239
5948
|
} else if (state.status === "payment_pending" || state.status === "payment_confirmed") {
|
|
4240
5949
|
const message = state.status === "payment_pending" ? "Transaction submitted \u2014 waiting for confirmation\u2026" : "Payment confirmed \u2014 settling credits on Base\u2026";
|
|
4241
|
-
content = /* @__PURE__ */ (0,
|
|
4242
|
-
/* @__PURE__ */ (0,
|
|
4243
|
-
/* @__PURE__ */ (0,
|
|
4244
|
-
/* @__PURE__ */ (0,
|
|
5950
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
5951
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Card, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.YStack, { gap: "$4", alignItems: "center", padding: "$4", children: [
|
|
5952
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Spinner, { size: "lg" }),
|
|
5953
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { center: true, secondary: true, children: message })
|
|
4245
5954
|
] }) }),
|
|
4246
|
-
/* @__PURE__ */ (0,
|
|
5955
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AiCreditsFlowStepper, { state, buyerPubKeySaved: true })
|
|
4247
5956
|
] });
|
|
4248
5957
|
} else {
|
|
4249
|
-
content = /* @__PURE__ */ (0,
|
|
4250
|
-
state.
|
|
5958
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
5959
|
+
state.error && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AiCreditsStatusNotice, { children: [
|
|
5960
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$error", fontWeight: "700", children: "Deep link unavailable" }),
|
|
5961
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, children: state.error })
|
|
5962
|
+
] }),
|
|
5963
|
+
state.address && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4251
5964
|
AiCreditsHero,
|
|
4252
5965
|
{
|
|
4253
5966
|
gBalance: state.gBalance,
|
|
4254
5967
|
isGoodIdVerified: state.isGoodIdVerified
|
|
4255
5968
|
}
|
|
4256
5969
|
),
|
|
4257
|
-
state.error && /* @__PURE__ */ (0,
|
|
4258
|
-
/* @__PURE__ */ (0,
|
|
4259
|
-
/* @__PURE__ */ (0,
|
|
5970
|
+
state.error && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AiCreditsStatusNotice, { children: [
|
|
5971
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$error", fontWeight: "700", children: "Request Failed" }),
|
|
5972
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, children: state.error })
|
|
4260
5973
|
] }),
|
|
4261
|
-
state.gBalance !== null && Number.parseFloat(state.gBalance) <= 0 && /* @__PURE__ */ (0,
|
|
4262
|
-
/* @__PURE__ */ (0,
|
|
5974
|
+
state.gBalance !== null && Number.parseFloat(state.gBalance) <= 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AiCreditsStatusNotice, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, children: "You need G$ before you can buy AI credits." }) }),
|
|
5975
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4263
5976
|
AiCreditsPurchaseFlow,
|
|
4264
5977
|
{
|
|
4265
5978
|
state,
|
|
@@ -4270,16 +5983,13 @@ function BuyCreditsPanel({ state, actions, isPending, onPay }) {
|
|
|
4270
5983
|
)
|
|
4271
5984
|
] });
|
|
4272
5985
|
}
|
|
4273
|
-
return /* @__PURE__ */ (0,
|
|
4274
|
-
content,
|
|
4275
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(BuyCreditsFaq, {})
|
|
4276
|
-
] });
|
|
5986
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.YStack, { gap: "$4", children: content });
|
|
4277
5987
|
}
|
|
4278
5988
|
function ManagePanel({
|
|
4279
5989
|
state,
|
|
4280
5990
|
actions
|
|
4281
5991
|
}) {
|
|
4282
|
-
const [refreshing, setRefreshing] =
|
|
5992
|
+
const [refreshing, setRefreshing] = import_react17.default.useState(false);
|
|
4283
5993
|
const handleRefresh = async () => {
|
|
4284
5994
|
setRefreshing(true);
|
|
4285
5995
|
try {
|
|
@@ -4288,15 +5998,15 @@ function ManagePanel({
|
|
|
4288
5998
|
setRefreshing(false);
|
|
4289
5999
|
}
|
|
4290
6000
|
};
|
|
4291
|
-
return /* @__PURE__ */ (0,
|
|
4292
|
-
state.error && /* @__PURE__ */ (0,
|
|
4293
|
-
/* @__PURE__ */ (0,
|
|
4294
|
-
/* @__PURE__ */ (0,
|
|
4295
|
-
/* @__PURE__ */ (0,
|
|
4296
|
-
/* @__PURE__ */ (0,
|
|
4297
|
-
state.error && /* @__PURE__ */ (0,
|
|
4298
|
-
/* @__PURE__ */ (0,
|
|
4299
|
-
|
|
6001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.YStack, { gap: "$3", width: "100%", children: [
|
|
6002
|
+
state.error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AiCreditsStatusNotice, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$error", fontSize: "$2", children: state.error }) }),
|
|
6003
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CreditsManagementCard, { state, actions }),
|
|
6004
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(BuyerOperatorCard, { state, actions }),
|
|
6005
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SetupSnippet, {}),
|
|
6006
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.YStack, { gap: "$2", width: "100%", alignItems: "center", children: [
|
|
6007
|
+
state.error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$error", fontSize: "$2", textAlign: "center", children: state.error }),
|
|
6008
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
6009
|
+
import_ui21.Button,
|
|
4300
6010
|
{
|
|
4301
6011
|
variant: "outline",
|
|
4302
6012
|
size: "sm",
|
|
@@ -4308,8 +6018,8 @@ function ManagePanel({
|
|
|
4308
6018
|
void handleRefresh();
|
|
4309
6019
|
},
|
|
4310
6020
|
children: [
|
|
4311
|
-
refreshing ? /* @__PURE__ */ (0,
|
|
4312
|
-
/* @__PURE__ */ (0,
|
|
6021
|
+
refreshing ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Spinner, { size: "sm" }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Icon, { name: "refresh", size: "sm", color: "muted" }),
|
|
6022
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.ButtonText, { children: refreshing ? "Refreshing\u2026" : "Refresh Balance" })
|
|
4313
6023
|
]
|
|
4314
6024
|
}
|
|
4315
6025
|
)
|
|
@@ -4327,7 +6037,9 @@ function AiCreditsInner({
|
|
|
4327
6037
|
adapterFactory,
|
|
4328
6038
|
adapterOptions,
|
|
4329
6039
|
onPaySuccess,
|
|
4330
|
-
onPayError
|
|
6040
|
+
onPayError,
|
|
6041
|
+
showWalletControls = false,
|
|
6042
|
+
hasDisconnectOverride = false
|
|
4331
6043
|
}) {
|
|
4332
6044
|
const defaultAdapter = useAiCreditsAdapter({
|
|
4333
6045
|
environment,
|
|
@@ -4344,33 +6056,41 @@ function AiCreditsInner({
|
|
|
4344
6056
|
skipVaultPaymentValidation: adapterOptions?.skipVaultPaymentValidation,
|
|
4345
6057
|
prepareSettlement: adapterOptions?.prepareSettlement
|
|
4346
6058
|
});
|
|
4347
|
-
const
|
|
4348
|
-
() => adapterFactory ? adapterFactory({ environment, backendUrl }) :
|
|
4349
|
-
[adapterFactory, environment, backendUrl
|
|
6059
|
+
const factoryAdapter = (0, import_react17.useMemo)(
|
|
6060
|
+
() => adapterFactory ? adapterFactory({ environment, backendUrl }) : null,
|
|
6061
|
+
[adapterFactory, environment, backendUrl]
|
|
4350
6062
|
);
|
|
6063
|
+
const activeAdapter = factoryAdapter ?? defaultAdapter;
|
|
4351
6064
|
const { state, actions } = activeAdapter;
|
|
6065
|
+
const onBuyersDiscoveredRef = import_react17.default.useRef(actions.discoverBuyers);
|
|
6066
|
+
onBuyersDiscoveredRef.current = actions.discoverBuyers;
|
|
6067
|
+
const onBuyersDiscovered = (0, import_react17.useCallback)((addresses) => {
|
|
6068
|
+
onBuyersDiscoveredRef.current(addresses);
|
|
6069
|
+
}, []);
|
|
4352
6070
|
const history = useAiCreditsHistory({
|
|
4353
6071
|
address: state.address,
|
|
4354
6072
|
backendUrl,
|
|
6073
|
+
defaultBuyerFilter: state.buyerPubKey ?? "all",
|
|
4355
6074
|
environment,
|
|
4356
|
-
backendClient: adapterOptions?.backendClient
|
|
6075
|
+
backendClient: adapterOptions?.backendClient,
|
|
6076
|
+
onBuyersDiscovered
|
|
4357
6077
|
});
|
|
4358
|
-
const handlePay = (0,
|
|
6078
|
+
const handlePay = (0, import_react17.useCallback)(
|
|
4359
6079
|
async (quote) => {
|
|
4360
|
-
const toastId = (0,
|
|
6080
|
+
const toastId = (0, import_ui21.createToast)({
|
|
4361
6081
|
message: "Submitting Celo transaction\u2026",
|
|
4362
6082
|
status: "pending",
|
|
4363
6083
|
duration: 0
|
|
4364
6084
|
});
|
|
4365
6085
|
try {
|
|
4366
6086
|
await actions.pay(quote);
|
|
4367
|
-
(0,
|
|
6087
|
+
(0, import_ui21.updateToast)(toastId, {
|
|
4368
6088
|
message: "Credits added successfully!",
|
|
4369
6089
|
status: "success",
|
|
4370
6090
|
duration: 4e3
|
|
4371
6091
|
});
|
|
4372
6092
|
} catch (err) {
|
|
4373
|
-
(0,
|
|
6093
|
+
(0, import_ui21.updateToast)(toastId, {
|
|
4374
6094
|
message: err instanceof Error ? err.message : state.error ?? "Payment failed. Try again.",
|
|
4375
6095
|
status: "error",
|
|
4376
6096
|
duration: 4e3
|
|
@@ -4379,47 +6099,117 @@ function AiCreditsInner({
|
|
|
4379
6099
|
},
|
|
4380
6100
|
[actions, state.error]
|
|
4381
6101
|
);
|
|
6102
|
+
const [helpView, setHelpView] = (0, import_react17.useState)(null);
|
|
4382
6103
|
const isPending = state.status === "payment_pending" || state.status === "payment_confirmed";
|
|
4383
|
-
const handleTabChange = (0,
|
|
6104
|
+
const handleTabChange = (0, import_react17.useCallback)(
|
|
4384
6105
|
(tabId) => {
|
|
6106
|
+
if (tabId !== "setup") {
|
|
6107
|
+
setHelpView(null);
|
|
6108
|
+
}
|
|
4385
6109
|
actions.setActiveTab(tabId);
|
|
4386
6110
|
},
|
|
4387
6111
|
[actions]
|
|
4388
6112
|
);
|
|
4389
|
-
const
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
6113
|
+
const { disconnect, disconnectLabel, disconnectIcon } = (0, import_core2.useWallet)();
|
|
6114
|
+
const handleDisconnect = (0, import_react17.useCallback)(async () => {
|
|
6115
|
+
await disconnect();
|
|
6116
|
+
setHelpView(null);
|
|
6117
|
+
actions.setActiveTab("setup");
|
|
6118
|
+
}, [actions, disconnect]);
|
|
6119
|
+
const walletRequired = needsWalletConnection(state);
|
|
6120
|
+
const handleHelpViewOpen = (0, import_react17.useCallback)(
|
|
6121
|
+
(view) => {
|
|
6122
|
+
actions.setActiveTab("setup");
|
|
6123
|
+
setHelpView(view);
|
|
6124
|
+
},
|
|
6125
|
+
[actions]
|
|
4399
6126
|
);
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
}
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
6127
|
+
const handleHelpViewClose = (0, import_react17.useCallback)(() => {
|
|
6128
|
+
setHelpView(null);
|
|
6129
|
+
}, []);
|
|
6130
|
+
const setupPanel = helpView === "how-to-use" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(HowToUseView, { onBack: handleHelpViewClose }) : helpView === "faq" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SetupFaqView, { onBack: handleHelpViewClose }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SetupTabPanel, { state, actions, onConnect: actions.connect });
|
|
6131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.YStack, { gap: "$3", padding: "$3", width: "100%", children: [
|
|
6132
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
6133
|
+
import_ui21.XStack,
|
|
6134
|
+
{
|
|
6135
|
+
justifyContent: "space-between",
|
|
6136
|
+
alignItems: "center",
|
|
6137
|
+
gap: "$2",
|
|
6138
|
+
paddingHorizontal: "$1",
|
|
6139
|
+
children: [
|
|
6140
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Heading, { level: 4, children: "GoodDollar" }),
|
|
6141
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.XStack, { gap: "$2", alignItems: "center", flexShrink: 1, minWidth: 0, children: [
|
|
6142
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Badge, { type: "info", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.BadgeText, { children: (0, import_ui21.getChainDisplayName)(state.chainId ?? CELO_CHAIN_ID3) }) }),
|
|
6143
|
+
showWalletControls && state.address && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6144
|
+
WalletChip,
|
|
6145
|
+
{
|
|
6146
|
+
address: state.address,
|
|
6147
|
+
onDisconnect: hasDisconnectOverride ? handleDisconnect : void 0,
|
|
6148
|
+
disconnectLabel: hasDisconnectOverride ? disconnectLabel : void 0,
|
|
6149
|
+
disconnectIcon: hasDisconnectOverride ? disconnectIcon : void 0
|
|
6150
|
+
}
|
|
6151
|
+
)
|
|
6152
|
+
] })
|
|
6153
|
+
]
|
|
6154
|
+
}
|
|
6155
|
+
),
|
|
6156
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6157
|
+
SetupGuidanceCard,
|
|
6158
|
+
{
|
|
6159
|
+
activeHelpView: helpView,
|
|
6160
|
+
onHowToUse: () => {
|
|
6161
|
+
handleHelpViewOpen("how-to-use");
|
|
6162
|
+
},
|
|
6163
|
+
onFaq: () => {
|
|
6164
|
+
handleHelpViewOpen("faq");
|
|
6165
|
+
},
|
|
6166
|
+
depositBonusPercent: state.depositBonusPercent,
|
|
6167
|
+
streamBonusPercent: state.streamBonusPercent,
|
|
6168
|
+
isGoodIdVerified: state.isGoodIdVerified
|
|
6169
|
+
}
|
|
6170
|
+
),
|
|
6171
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6172
|
+
import_ui21.WidgetTabs,
|
|
4406
6173
|
{
|
|
4407
6174
|
tabs: [
|
|
6175
|
+
{ id: "setup", label: "Setup" },
|
|
4408
6176
|
{ id: "buy", label: "Buy Credits" },
|
|
4409
6177
|
{ id: "manage", label: "Manage" },
|
|
4410
6178
|
{ id: "history", label: "History" }
|
|
4411
6179
|
],
|
|
4412
|
-
activeTab: state.activeTab,
|
|
6180
|
+
activeTab: walletRequired ? "setup" : state.activeTab,
|
|
4413
6181
|
onTabChange: handleTabChange,
|
|
4414
|
-
|
|
6182
|
+
isTabDisabled: (tabId) => walletRequired && tabId !== "setup",
|
|
6183
|
+
withConnectionStatus: false
|
|
4415
6184
|
}
|
|
4416
6185
|
),
|
|
4417
|
-
state.activeTab === "manage" ? /* @__PURE__ */ (0,
|
|
6186
|
+
walletRequired || state.activeTab === "setup" ? setupPanel : state.activeTab === "manage" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ManagePanel, { state, actions }) : state.activeTab === "history" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6187
|
+
HistoryTab,
|
|
6188
|
+
{
|
|
6189
|
+
state: history.state,
|
|
6190
|
+
actions: history.actions,
|
|
6191
|
+
knownBuyers: state.buyers.map((address) => ({ address }))
|
|
6192
|
+
}
|
|
6193
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6194
|
+
BuyCreditsPanel,
|
|
6195
|
+
{
|
|
6196
|
+
state,
|
|
6197
|
+
actions,
|
|
6198
|
+
isPending,
|
|
6199
|
+
onPay: (quote) => {
|
|
6200
|
+
void handlePay(quote);
|
|
6201
|
+
}
|
|
6202
|
+
}
|
|
6203
|
+
)
|
|
4418
6204
|
] });
|
|
4419
6205
|
}
|
|
4420
6206
|
function AiCreditsWidget({
|
|
4421
6207
|
provider,
|
|
4422
6208
|
connectOverride,
|
|
6209
|
+
showWalletControls = false,
|
|
6210
|
+
disconnectOverride,
|
|
6211
|
+
disconnectLabel,
|
|
6212
|
+
disconnectIcon,
|
|
4423
6213
|
environment = "production",
|
|
4424
6214
|
backendUrl,
|
|
4425
6215
|
baseRpcUrl,
|
|
@@ -4436,16 +6226,19 @@ function AiCreditsWidget({
|
|
|
4436
6226
|
adapterOptions,
|
|
4437
6227
|
testId
|
|
4438
6228
|
}) {
|
|
4439
|
-
return /* @__PURE__ */ (0,
|
|
6229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4440
6230
|
import_core2.GoodWidgetProvider,
|
|
4441
6231
|
{
|
|
4442
6232
|
provider,
|
|
4443
6233
|
connectOverride,
|
|
6234
|
+
disconnectOverride,
|
|
6235
|
+
disconnectLabel,
|
|
6236
|
+
disconnectIcon,
|
|
4444
6237
|
config,
|
|
4445
6238
|
themeOverrides,
|
|
4446
6239
|
defaultTheme,
|
|
4447
|
-
children: /* @__PURE__ */ (0,
|
|
4448
|
-
/* @__PURE__ */ (0,
|
|
6240
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.YStack, { backgroundColor: "$background", width: "100%", "data-testid": testId, children: [
|
|
6241
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4449
6242
|
AiCreditsInner,
|
|
4450
6243
|
{
|
|
4451
6244
|
environment,
|
|
@@ -4458,10 +6251,12 @@ function AiCreditsWidget({
|
|
|
4458
6251
|
adapterFactory,
|
|
4459
6252
|
adapterOptions,
|
|
4460
6253
|
onPaySuccess,
|
|
4461
|
-
onPayError
|
|
6254
|
+
onPayError,
|
|
6255
|
+
showWalletControls,
|
|
6256
|
+
hasDisconnectOverride: Boolean(disconnectOverride)
|
|
4462
6257
|
}
|
|
4463
6258
|
),
|
|
4464
|
-
/* @__PURE__ */ (0,
|
|
6259
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.ToastContainer, {})
|
|
4465
6260
|
] })
|
|
4466
6261
|
}
|
|
4467
6262
|
);
|
|
@@ -4750,20 +6545,23 @@ var MockAiCreditsBackendClient = class {
|
|
|
4750
6545
|
await sleep2(MOCK_DELAY_MS);
|
|
4751
6546
|
return { account: buyer, amountUsd: body.amount, bridge: { enabled: true, txHash: "0xmock" } };
|
|
4752
6547
|
}
|
|
4753
|
-
async submitOperatorConsent(buyer) {
|
|
6548
|
+
async submitOperatorConsent(buyer, {}) {
|
|
4754
6549
|
await sleep2(MOCK_DELAY_MS);
|
|
4755
6550
|
const normalizedBuyer = normalizeAddress4(buyer);
|
|
4756
6551
|
markMockOperatorConsent(normalizedBuyer);
|
|
4757
|
-
return {
|
|
6552
|
+
return {
|
|
6553
|
+
buyer: normalizedBuyer,
|
|
6554
|
+
bridge: { enabled: true, txHash: "0xmock" }
|
|
6555
|
+
};
|
|
4758
6556
|
}
|
|
4759
6557
|
};
|
|
4760
6558
|
|
|
4761
6559
|
// src/mocked/AiCreditsMockWidget.tsx
|
|
4762
|
-
var
|
|
6560
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
4763
6561
|
function MockAiCreditsWidget(props) {
|
|
4764
|
-
const backendClient = (0,
|
|
4765
|
-
const chainClient = (0,
|
|
4766
|
-
return /* @__PURE__ */ (0,
|
|
6562
|
+
const backendClient = (0, import_react18.useMemo)(() => new MockAiCreditsBackendClient(), []);
|
|
6563
|
+
const chainClient = (0, import_react18.useMemo)(() => new MockAiCreditsChainClient(), []);
|
|
6564
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
4767
6565
|
AiCreditsWidget,
|
|
4768
6566
|
{
|
|
4769
6567
|
...props,
|