@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/register.cjs
CHANGED
|
@@ -539,13 +539,17 @@ function clampHistoryLimit(limit) {
|
|
|
539
539
|
if (limit === void 0) return DEFAULT_HISTORY_LIMIT;
|
|
540
540
|
return Math.min(Math.max(1, Math.floor(limit)), MAX_HISTORY_LIMIT);
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function collectBuyerAddressesFromEntries(entries) {
|
|
543
|
+
const seen = /* @__PURE__ */ new Set();
|
|
544
|
+
const result = [];
|
|
543
545
|
for (const entry of entries) {
|
|
544
|
-
if (entry.buyerAddress
|
|
545
|
-
|
|
546
|
-
|
|
546
|
+
if (!entry.buyerAddress || !(0, import_viem4.isAddress)(entry.buyerAddress)) continue;
|
|
547
|
+
const key = normalizeAddress2(entry.buyerAddress);
|
|
548
|
+
if (seen.has(key)) continue;
|
|
549
|
+
seen.add(key);
|
|
550
|
+
result.push(key);
|
|
547
551
|
}
|
|
548
|
-
return
|
|
552
|
+
return result;
|
|
549
553
|
}
|
|
550
554
|
function defaultOperatorStatus(payer) {
|
|
551
555
|
const account = normalizeAddress2(payer);
|
|
@@ -609,13 +613,11 @@ async function waitForOperatorConsent(chain, ref) {
|
|
|
609
613
|
}
|
|
610
614
|
async function buildAccountView(payer, backend, chain, options = {}) {
|
|
611
615
|
const normalizedPayer = normalizeAddress2(payer);
|
|
612
|
-
const [credit, outstanding
|
|
616
|
+
const [credit, outstanding] = await Promise.all([
|
|
613
617
|
backend.getAccountCredit(payer),
|
|
614
|
-
backend.getOutstanding(payer)
|
|
615
|
-
backend.getCreditHistory(payer, { limit: MAX_HISTORY_LIMIT, offset: 0 })
|
|
618
|
+
backend.getOutstanding(payer)
|
|
616
619
|
]);
|
|
617
|
-
const
|
|
618
|
-
const buyer = sessionBuyer ?? resolveBuyerAddress(history.items);
|
|
620
|
+
const buyer = options.buyerAddress && (0, import_viem4.isAddress)(options.buyerAddress) ? normalizeAddress2(options.buyerAddress) : null;
|
|
619
621
|
const [operator, withdrawableUsd] = buyer ? await Promise.all([
|
|
620
622
|
chain.getBuyerOperatorStatus({ payer: normalizedPayer, buyer }),
|
|
621
623
|
chain.getWithdrawableUsd(buyer)
|
|
@@ -814,45 +816,386 @@ var init_backendClient = __esm({
|
|
|
814
816
|
}
|
|
815
817
|
});
|
|
816
818
|
|
|
819
|
+
// src/deepLinkParams.ts
|
|
820
|
+
function isValidBuyerAddress(value) {
|
|
821
|
+
return BUYER_ADDRESS_RE.test(value.trim());
|
|
822
|
+
}
|
|
823
|
+
function isValidOperatorSignature(value) {
|
|
824
|
+
return OPERATOR_SIGNATURE_RE.test(value.trim());
|
|
825
|
+
}
|
|
826
|
+
function deepLinkManualFallbackMessage(reason) {
|
|
827
|
+
return `${reason} ${DEEP_LINK_MANUAL_FALLBACK_HINT}`;
|
|
828
|
+
}
|
|
829
|
+
function canUseLocalStorage() {
|
|
830
|
+
return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
|
|
831
|
+
}
|
|
832
|
+
function readStoredDeepLinkParams() {
|
|
833
|
+
if (!canUseLocalStorage()) return null;
|
|
834
|
+
try {
|
|
835
|
+
const raw = window.localStorage.getItem(DEEP_LINK_STORAGE_KEY);
|
|
836
|
+
if (!raw) return null;
|
|
837
|
+
const parsed = JSON.parse(raw);
|
|
838
|
+
const buyerAddress = typeof parsed.buyerAddress === "string" ? parsed.buyerAddress.trim() : "";
|
|
839
|
+
const operatorSignature = typeof parsed.operatorSignature === "string" ? parsed.operatorSignature.trim() : "";
|
|
840
|
+
if (!isValidBuyerAddress(buyerAddress) || !isValidOperatorSignature(operatorSignature)) {
|
|
841
|
+
clearStoredDeepLinkParams();
|
|
842
|
+
return null;
|
|
843
|
+
}
|
|
844
|
+
return { buyerAddress, operatorSignature };
|
|
845
|
+
} catch {
|
|
846
|
+
clearStoredDeepLinkParams();
|
|
847
|
+
return null;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
function storeDeepLinkParams(value) {
|
|
851
|
+
if (!canUseLocalStorage()) return;
|
|
852
|
+
try {
|
|
853
|
+
window.localStorage.setItem(
|
|
854
|
+
DEEP_LINK_STORAGE_KEY,
|
|
855
|
+
JSON.stringify({
|
|
856
|
+
buyerAddress: value.buyerAddress.trim(),
|
|
857
|
+
operatorSignature: value.operatorSignature.trim()
|
|
858
|
+
})
|
|
859
|
+
);
|
|
860
|
+
} catch {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
function clearStoredDeepLinkParams() {
|
|
865
|
+
if (!canUseLocalStorage()) return;
|
|
866
|
+
try {
|
|
867
|
+
window.localStorage.removeItem(DEEP_LINK_STORAGE_KEY);
|
|
868
|
+
} catch {
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
function parseDeepLinkParams(search = typeof window !== "undefined" ? window.location.search : "") {
|
|
873
|
+
const params = typeof search === "string" ? new URLSearchParams(search) : search;
|
|
874
|
+
const buyerAddress = params.get("buyerAddress")?.trim() ?? "";
|
|
875
|
+
const operatorSignature = params.get("operatorSignature")?.trim() ?? "";
|
|
876
|
+
const hasBuyer = buyerAddress.length > 0;
|
|
877
|
+
const hasSignature = operatorSignature.length > 0;
|
|
878
|
+
if (!hasBuyer && !hasSignature) return { status: "absent" };
|
|
879
|
+
if (hasBuyer && !hasSignature) return { status: "partial", present: "buyerAddress" };
|
|
880
|
+
if (!hasBuyer && hasSignature) return { status: "partial", present: "operatorSignature" };
|
|
881
|
+
if (!isValidBuyerAddress(buyerAddress)) {
|
|
882
|
+
return { status: "invalid", reason: "Deep-link buyerAddress is invalid" };
|
|
883
|
+
}
|
|
884
|
+
if (!isValidOperatorSignature(operatorSignature)) {
|
|
885
|
+
return {
|
|
886
|
+
status: "invalid",
|
|
887
|
+
reason: "Deep-link operatorSignature is invalid"
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
return {
|
|
891
|
+
status: "complete",
|
|
892
|
+
source: "url",
|
|
893
|
+
value: {
|
|
894
|
+
buyerAddress,
|
|
895
|
+
operatorSignature
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
function resolveDeepLinkParams(search = typeof window !== "undefined" ? window.location.search : "") {
|
|
900
|
+
const fromUrl = parseDeepLinkParams(search);
|
|
901
|
+
if (fromUrl.status === "complete") {
|
|
902
|
+
storeDeepLinkParams(fromUrl.value);
|
|
903
|
+
return fromUrl;
|
|
904
|
+
}
|
|
905
|
+
if (fromUrl.status === "partial" || fromUrl.status === "invalid") {
|
|
906
|
+
return fromUrl;
|
|
907
|
+
}
|
|
908
|
+
const stored = readStoredDeepLinkParams();
|
|
909
|
+
if (!stored) return { status: "absent" };
|
|
910
|
+
return { status: "complete", source: "storage", value: stored };
|
|
911
|
+
}
|
|
912
|
+
function stripDeepLinkParamsFromUrl() {
|
|
913
|
+
if (typeof window === "undefined") return;
|
|
914
|
+
const url = new URL(window.location.href);
|
|
915
|
+
if (!url.searchParams.has("buyerAddress") && !url.searchParams.has("operatorSignature")) {
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
url.searchParams.delete("buyerAddress");
|
|
919
|
+
url.searchParams.delete("operatorSignature");
|
|
920
|
+
const next = `${url.pathname}${url.search}${url.hash}`;
|
|
921
|
+
window.history.replaceState(window.history.state, "", next);
|
|
922
|
+
}
|
|
923
|
+
function clearDeepLinkArtifacts() {
|
|
924
|
+
clearStoredDeepLinkParams();
|
|
925
|
+
stripDeepLinkParamsFromUrl();
|
|
926
|
+
}
|
|
927
|
+
var BUYER_ADDRESS_RE, OPERATOR_SIGNATURE_RE, DEEP_LINK_STORAGE_KEY, DEEP_LINK_MANUAL_FALLBACK_HINT;
|
|
928
|
+
var init_deepLinkParams = __esm({
|
|
929
|
+
"src/deepLinkParams.ts"() {
|
|
930
|
+
"use strict";
|
|
931
|
+
BUYER_ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
932
|
+
OPERATOR_SIGNATURE_RE = /^0x[0-9a-fA-F]{128}([0-9a-fA-F]{2})?$/;
|
|
933
|
+
DEEP_LINK_STORAGE_KEY = "goodwidget.ai-credits.deepLink";
|
|
934
|
+
DEEP_LINK_MANUAL_FALLBACK_HINT = "Generate or import a signer key manually to continue.";
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
|
|
817
938
|
// src/payerSession.ts
|
|
818
939
|
function payerSessionKey(address) {
|
|
819
940
|
return address.toLowerCase();
|
|
820
941
|
}
|
|
942
|
+
function normalizeBuyerAddress(address) {
|
|
943
|
+
return address.toLowerCase();
|
|
944
|
+
}
|
|
945
|
+
function canUseLocalStorage2() {
|
|
946
|
+
return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
|
|
947
|
+
}
|
|
948
|
+
function formatBuyerAddress(address) {
|
|
949
|
+
const key = normalizeBuyerAddress(address);
|
|
950
|
+
return key.startsWith("0x") ? `0x${key.slice(2)}` : key;
|
|
951
|
+
}
|
|
952
|
+
function emptySession() {
|
|
953
|
+
return {
|
|
954
|
+
buyerKeys: {},
|
|
955
|
+
knownBuyers: [],
|
|
956
|
+
activeBuyerAddress: null,
|
|
957
|
+
derivedBuyerAddress: null
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
function isBuyerKeyEntry(value) {
|
|
961
|
+
if (!value || typeof value !== "object") return false;
|
|
962
|
+
const entry = value;
|
|
963
|
+
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");
|
|
964
|
+
}
|
|
965
|
+
function migrateLegacySession(raw) {
|
|
966
|
+
const session = emptySession();
|
|
967
|
+
const known = /* @__PURE__ */ new Set();
|
|
968
|
+
const trackKnown = (address) => {
|
|
969
|
+
if (!address) return;
|
|
970
|
+
known.add(normalizeBuyerAddress(address));
|
|
971
|
+
};
|
|
972
|
+
if (typeof raw.buyerPubKey === "string" && raw.buyerPubKey) {
|
|
973
|
+
const address = normalizeBuyerAddress(raw.buyerPubKey);
|
|
974
|
+
session.activeBuyerAddress = address;
|
|
975
|
+
session.derivedBuyerAddress = address;
|
|
976
|
+
trackKnown(address);
|
|
977
|
+
if (typeof raw.buyerPrvKey === "string" && raw.buyerPrvKey) {
|
|
978
|
+
session.buyerKeys[address] = { privateKey: raw.buyerPrvKey };
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
if (Array.isArray(raw.buyers)) {
|
|
982
|
+
for (const item of raw.buyers) {
|
|
983
|
+
if (typeof item === "string" && item) {
|
|
984
|
+
trackKnown(item);
|
|
985
|
+
continue;
|
|
986
|
+
}
|
|
987
|
+
if (!item || typeof item !== "object") continue;
|
|
988
|
+
const buyer = item;
|
|
989
|
+
if (typeof buyer.address !== "string" || !buyer.address) continue;
|
|
990
|
+
const address = normalizeBuyerAddress(buyer.address);
|
|
991
|
+
trackKnown(address);
|
|
992
|
+
const entry = {};
|
|
993
|
+
if (typeof buyer.privateKey === "string" && buyer.privateKey) {
|
|
994
|
+
entry.privateKey = buyer.privateKey;
|
|
995
|
+
}
|
|
996
|
+
if (typeof buyer.operatorSignature === "string" && buyer.operatorSignature) {
|
|
997
|
+
entry.operatorSignature = buyer.operatorSignature;
|
|
998
|
+
}
|
|
999
|
+
if (typeof buyer.operatorConsented === "boolean") {
|
|
1000
|
+
entry.operatorConsented = buyer.operatorConsented;
|
|
1001
|
+
}
|
|
1002
|
+
if (entry.privateKey || entry.operatorSignature || entry.operatorConsented !== void 0) {
|
|
1003
|
+
session.buyerKeys[address] = {
|
|
1004
|
+
...session.buyerKeys[address],
|
|
1005
|
+
...entry
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
if (buyer.type === "derived" && entry.privateKey) {
|
|
1009
|
+
session.derivedBuyerAddress = address;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
if (Array.isArray(raw.knownBuyers)) {
|
|
1014
|
+
for (const item of raw.knownBuyers) {
|
|
1015
|
+
if (typeof item === "string" && item) trackKnown(item);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
if (typeof raw.activeBuyerAddress === "string" && raw.activeBuyerAddress) {
|
|
1019
|
+
session.activeBuyerAddress = normalizeBuyerAddress(raw.activeBuyerAddress);
|
|
1020
|
+
trackKnown(session.activeBuyerAddress);
|
|
1021
|
+
}
|
|
1022
|
+
if (typeof raw.derivedBuyerAddress === "string" && raw.derivedBuyerAddress) {
|
|
1023
|
+
session.derivedBuyerAddress = normalizeBuyerAddress(raw.derivedBuyerAddress);
|
|
1024
|
+
trackKnown(session.derivedBuyerAddress);
|
|
1025
|
+
}
|
|
1026
|
+
if (typeof raw.operatorSignature === "string" && raw.operatorSignature && session.activeBuyerAddress) {
|
|
1027
|
+
const active = session.activeBuyerAddress;
|
|
1028
|
+
session.buyerKeys[active] = {
|
|
1029
|
+
...session.buyerKeys[active],
|
|
1030
|
+
operatorSignature: raw.operatorSignature
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
if (raw.buyerKeys && typeof raw.buyerKeys === "object") {
|
|
1034
|
+
for (const [address, entry] of Object.entries(raw.buyerKeys)) {
|
|
1035
|
+
if (!isBuyerKeyEntry(entry)) continue;
|
|
1036
|
+
const key = normalizeBuyerAddress(address);
|
|
1037
|
+
trackKnown(key);
|
|
1038
|
+
session.buyerKeys[key] = {
|
|
1039
|
+
...session.buyerKeys[key],
|
|
1040
|
+
...entry
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
if (typeof raw.operatorConsented === "boolean" && raw.operatorConsented && session.activeBuyerAddress) {
|
|
1045
|
+
const active = session.activeBuyerAddress;
|
|
1046
|
+
session.buyerKeys[active] = {
|
|
1047
|
+
...session.buyerKeys[active],
|
|
1048
|
+
operatorConsented: true
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
session.knownBuyers = [...known].map((key) => formatBuyerAddress(key));
|
|
1052
|
+
return session;
|
|
1053
|
+
}
|
|
1054
|
+
function parseStoredSession(raw) {
|
|
1055
|
+
try {
|
|
1056
|
+
const parsed = JSON.parse(raw);
|
|
1057
|
+
return migrateLegacySession(parsed);
|
|
1058
|
+
} catch {
|
|
1059
|
+
return null;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
function persistSession(address, session) {
|
|
1063
|
+
if (!canUseLocalStorage2()) return;
|
|
1064
|
+
try {
|
|
1065
|
+
window.localStorage.setItem(
|
|
1066
|
+
`${STORAGE_KEY_PREFIX}${payerSessionKey(address)}`,
|
|
1067
|
+
JSON.stringify(session)
|
|
1068
|
+
);
|
|
1069
|
+
} catch {
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
821
1073
|
function readPayerSession(address) {
|
|
822
|
-
if (!address) return null;
|
|
823
|
-
|
|
1074
|
+
if (!address || !canUseLocalStorage2()) return null;
|
|
1075
|
+
try {
|
|
1076
|
+
const raw = window.localStorage.getItem(
|
|
1077
|
+
`${STORAGE_KEY_PREFIX}${payerSessionKey(address)}`
|
|
1078
|
+
);
|
|
1079
|
+
if (!raw) return null;
|
|
1080
|
+
return parseStoredSession(raw);
|
|
1081
|
+
} catch {
|
|
1082
|
+
return null;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
function getBuyerKeyEntry(payer, buyerAddress) {
|
|
1086
|
+
const session = readPayerSession(payer);
|
|
1087
|
+
if (!session) return null;
|
|
1088
|
+
return session.buyerKeys[normalizeBuyerAddress(buyerAddress)] ?? null;
|
|
1089
|
+
}
|
|
1090
|
+
function setBuyerOperatorConsented(payer, buyerAddress, operatorConsented) {
|
|
1091
|
+
upsertBuyerKey(payer, buyerAddress, { operatorConsented }, { setActive: false });
|
|
824
1092
|
}
|
|
825
|
-
function
|
|
826
|
-
const existing = readPayerSession(
|
|
827
|
-
|
|
828
|
-
|
|
1093
|
+
function upsertBuyerKey(payer, buyerAddress, entry, options) {
|
|
1094
|
+
const existing = readPayerSession(payer) ?? emptySession();
|
|
1095
|
+
const key = normalizeBuyerAddress(buyerAddress);
|
|
1096
|
+
const previous = existing.buyerKeys[key] ?? {};
|
|
1097
|
+
const knownBuyers = mergeBuyerAddressList(existing.knownBuyers, key);
|
|
1098
|
+
const next = {
|
|
829
1099
|
...existing,
|
|
830
|
-
|
|
831
|
-
|
|
1100
|
+
knownBuyers,
|
|
1101
|
+
buyerKeys: {
|
|
1102
|
+
...existing.buyerKeys,
|
|
1103
|
+
[key]: {
|
|
1104
|
+
privateKey: entry.privateKey ?? previous.privateKey,
|
|
1105
|
+
operatorSignature: entry.operatorSignature ?? previous.operatorSignature,
|
|
1106
|
+
operatorConsented: entry.operatorConsented !== void 0 ? entry.operatorConsented : previous.operatorConsented
|
|
1107
|
+
}
|
|
1108
|
+
},
|
|
1109
|
+
activeBuyerAddress: options?.setActive === false ? existing.activeBuyerAddress : key,
|
|
1110
|
+
derivedBuyerAddress: options?.setDerived ? key : existing.derivedBuyerAddress
|
|
1111
|
+
};
|
|
1112
|
+
persistSession(payer, next);
|
|
1113
|
+
return next;
|
|
1114
|
+
}
|
|
1115
|
+
function setActiveBuyerAddress(payer, buyerAddress) {
|
|
1116
|
+
const existing = readPayerSession(payer) ?? emptySession();
|
|
1117
|
+
const normalized = buyerAddress ? normalizeBuyerAddress(buyerAddress) : null;
|
|
1118
|
+
const next = {
|
|
1119
|
+
...existing,
|
|
1120
|
+
knownBuyers: normalized ? mergeBuyerAddressList(existing.knownBuyers, normalized) : existing.knownBuyers,
|
|
1121
|
+
activeBuyerAddress: normalized
|
|
1122
|
+
};
|
|
1123
|
+
persistSession(payer, next);
|
|
1124
|
+
return next;
|
|
1125
|
+
}
|
|
1126
|
+
function mergeBuyerAddressList(existingBuyers, ...extras) {
|
|
1127
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1128
|
+
const result = [];
|
|
1129
|
+
for (const address of [...existingBuyers, ...extras]) {
|
|
1130
|
+
if (!address) continue;
|
|
1131
|
+
const key = normalizeBuyerAddress(address);
|
|
1132
|
+
if (seen.has(key)) continue;
|
|
1133
|
+
seen.add(key);
|
|
1134
|
+
result.push(formatBuyerAddress(key));
|
|
1135
|
+
}
|
|
1136
|
+
return result;
|
|
1137
|
+
}
|
|
1138
|
+
function listKnownBuyerAddresses(payer) {
|
|
1139
|
+
const session = readPayerSession(payer);
|
|
1140
|
+
if (!session) return [];
|
|
1141
|
+
return mergeBuyerAddressList(
|
|
1142
|
+
session.knownBuyers,
|
|
1143
|
+
...Object.keys(session.buyerKeys),
|
|
1144
|
+
session.activeBuyerAddress,
|
|
1145
|
+
session.derivedBuyerAddress
|
|
1146
|
+
);
|
|
1147
|
+
}
|
|
1148
|
+
function rememberBuyerAddresses(payer, addresses) {
|
|
1149
|
+
const existing = readPayerSession(payer) ?? emptySession();
|
|
1150
|
+
const knownBuyers = mergeBuyerAddressList(existing.knownBuyers, ...addresses);
|
|
1151
|
+
if (knownBuyers.length === existing.knownBuyers.length && knownBuyers.every(
|
|
1152
|
+
(address, index) => address.toLowerCase() === existing.knownBuyers[index]?.toLowerCase()
|
|
1153
|
+
)) {
|
|
1154
|
+
return listKnownBuyerAddresses(payer);
|
|
1155
|
+
}
|
|
1156
|
+
persistSession(payer, { ...existing, knownBuyers });
|
|
1157
|
+
return listKnownBuyerAddresses(payer);
|
|
1158
|
+
}
|
|
1159
|
+
function buildBuyerStateFields(payer, buyers, selectedAddress) {
|
|
1160
|
+
const session = readPayerSession(payer);
|
|
1161
|
+
const entry = selectedAddress ? getBuyerKeyEntry(payer, selectedAddress) : null;
|
|
1162
|
+
return {
|
|
1163
|
+
buyers,
|
|
1164
|
+
buyerPubKey: selectedAddress,
|
|
1165
|
+
buyerPrvKey: entry?.privateKey ?? null,
|
|
1166
|
+
operatorSignature: entry?.operatorSignature ?? null,
|
|
1167
|
+
operatorConsented: Boolean(entry?.operatorConsented),
|
|
1168
|
+
derivedBuyerAddress: session?.derivedBuyerAddress ?? null
|
|
1169
|
+
};
|
|
832
1170
|
}
|
|
833
1171
|
function patchPayerSessionFields(address) {
|
|
834
1172
|
const session = readPayerSession(address);
|
|
835
1173
|
if (!session) {
|
|
836
1174
|
return {
|
|
1175
|
+
buyerPubKey: null,
|
|
837
1176
|
buyerPrvKey: null,
|
|
838
|
-
|
|
1177
|
+
operatorSignature: null,
|
|
1178
|
+
operatorConsented: false,
|
|
1179
|
+
activeBuyerAddress: null,
|
|
1180
|
+
derivedBuyerAddress: null
|
|
839
1181
|
};
|
|
840
1182
|
}
|
|
1183
|
+
const active = session.activeBuyerAddress;
|
|
1184
|
+
const entry = active ? session.buyerKeys[normalizeBuyerAddress(active)] : void 0;
|
|
841
1185
|
return {
|
|
842
|
-
buyerPubKey:
|
|
843
|
-
buyerPrvKey:
|
|
844
|
-
|
|
1186
|
+
buyerPubKey: active,
|
|
1187
|
+
buyerPrvKey: entry?.privateKey ?? null,
|
|
1188
|
+
operatorSignature: entry?.operatorSignature ?? null,
|
|
1189
|
+
operatorConsented: Boolean(entry?.operatorConsented),
|
|
1190
|
+
activeBuyerAddress: active,
|
|
1191
|
+
derivedBuyerAddress: session.derivedBuyerAddress
|
|
845
1192
|
};
|
|
846
1193
|
}
|
|
847
|
-
|
|
848
|
-
if (!a || !b) return false;
|
|
849
|
-
return payerSessionKey(a) === payerSessionKey(b);
|
|
850
|
-
}
|
|
851
|
-
var payerWalletSessions;
|
|
1194
|
+
var STORAGE_KEY_PREFIX;
|
|
852
1195
|
var init_payerSession = __esm({
|
|
853
1196
|
"src/payerSession.ts"() {
|
|
854
1197
|
"use strict";
|
|
855
|
-
|
|
1198
|
+
STORAGE_KEY_PREFIX = "goodwidget.ai-credits.payerSession.";
|
|
856
1199
|
}
|
|
857
1200
|
});
|
|
858
1201
|
|
|
@@ -1145,7 +1488,7 @@ function getPayDisabledMessage(params) {
|
|
|
1145
1488
|
if (params.validation.streamBelowMin && params.minStreamUsd) {
|
|
1146
1489
|
return `Monthly stream must be at least ${formatMinUsdDisplay(params.minStreamUsd)}.`;
|
|
1147
1490
|
}
|
|
1148
|
-
if (params.status !== "quote_ready") {
|
|
1491
|
+
if (params.status !== "quote_ready" && params.status !== "payment_failed") {
|
|
1149
1492
|
return "Enter a deposit or change the monthly stream amount to continue.";
|
|
1150
1493
|
}
|
|
1151
1494
|
return "Adjust the amounts to continue.";
|
|
@@ -1270,15 +1613,55 @@ var init_vaultMinimums = __esm({
|
|
|
1270
1613
|
});
|
|
1271
1614
|
|
|
1272
1615
|
// src/adapter.ts
|
|
1616
|
+
function resolveLocalBuyers(payer, preferredBuyer, ...extras) {
|
|
1617
|
+
const buyers = rememberBuyerAddresses(payer, [
|
|
1618
|
+
preferredBuyer,
|
|
1619
|
+
...listKnownBuyerAddresses(payer),
|
|
1620
|
+
...extras
|
|
1621
|
+
]);
|
|
1622
|
+
return { buyers, selected: selectPreferredBuyer(buyers, preferredBuyer) };
|
|
1623
|
+
}
|
|
1624
|
+
async function discoverBuyersFromHistory(payer, backend, ...extras) {
|
|
1625
|
+
let historyBuyers = [];
|
|
1626
|
+
try {
|
|
1627
|
+
const history = await backend.getCreditHistory(payer, {
|
|
1628
|
+
limit: BUYER_HISTORY_LOOKUP_LIMIT,
|
|
1629
|
+
offset: 0
|
|
1630
|
+
});
|
|
1631
|
+
historyBuyers = collectBuyerAddressesFromEntries(history.items);
|
|
1632
|
+
} catch {
|
|
1633
|
+
historyBuyers = [];
|
|
1634
|
+
}
|
|
1635
|
+
return rememberBuyerAddresses(payer, [...historyBuyers, ...extras]);
|
|
1636
|
+
}
|
|
1637
|
+
function selectPreferredBuyer(buyers, preferredBuyer) {
|
|
1638
|
+
if (preferredBuyer && buyers.some((item) => item.toLowerCase() === preferredBuyer.toLowerCase())) {
|
|
1639
|
+
return preferredBuyer;
|
|
1640
|
+
}
|
|
1641
|
+
return buyers[0] ?? preferredBuyer ?? null;
|
|
1642
|
+
}
|
|
1273
1643
|
function isNonBuyTab(tab) {
|
|
1274
|
-
return tab === "manage" || tab === "history";
|
|
1644
|
+
return tab === "setup" || tab === "manage" || tab === "history";
|
|
1645
|
+
}
|
|
1646
|
+
function needsWalletConnection(state) {
|
|
1647
|
+
return !state.address || state.status === "disconnected" || state.status === "connecting";
|
|
1648
|
+
}
|
|
1649
|
+
function resolveDefaultActiveTab(payerAddress, totalCreditUsd) {
|
|
1650
|
+
if (hasCreditBalance(totalCreditUsd)) return "manage";
|
|
1651
|
+
if (payerAddress && listKnownBuyerAddresses(payerAddress).length > 0) return "buy";
|
|
1652
|
+
return "setup";
|
|
1275
1653
|
}
|
|
1276
1654
|
function resolveActiveTab(prev, overrides) {
|
|
1277
1655
|
if (overrides.activeTab !== void 0) return overrides.activeTab;
|
|
1656
|
+
const payerAddress = overrides.address !== void 0 ? overrides.address : prev.address;
|
|
1657
|
+
const totalCreditUsd = overrides.totalCreditUsd !== void 0 ? overrides.totalCreditUsd : prev.totalCreditUsd;
|
|
1278
1658
|
if (overrides.totalCreditUsd !== void 0 && overrides.totalCreditUsd !== null) {
|
|
1279
|
-
return
|
|
1659
|
+
return resolveDefaultActiveTab(payerAddress, overrides.totalCreditUsd);
|
|
1280
1660
|
}
|
|
1281
|
-
|
|
1661
|
+
if (overrides.address !== void 0 && overrides.address !== prev.address) {
|
|
1662
|
+
return resolveDefaultActiveTab(payerAddress, totalCreditUsd);
|
|
1663
|
+
}
|
|
1664
|
+
return prev.activeTab ?? resolveDefaultActiveTab(payerAddress, totalCreditUsd);
|
|
1282
1665
|
}
|
|
1283
1666
|
function hasCreditBalance(totalCreditUsd) {
|
|
1284
1667
|
return totalCreditUsd !== null && BigInt(totalCreditUsd) > 0n;
|
|
@@ -1336,7 +1719,7 @@ function mergeStatePreservingNonBuyTab(prev, overrides) {
|
|
|
1336
1719
|
}
|
|
1337
1720
|
const activeTab = isNonBuyTab(nextTab) ? nextTab : prev.activeTab;
|
|
1338
1721
|
const status = deriveStatus({
|
|
1339
|
-
isConnected:
|
|
1722
|
+
isConnected: !needsWalletConnection(prev),
|
|
1340
1723
|
chainId: overrides.chainId ?? prev.chainId,
|
|
1341
1724
|
gBalance: overrides.gBalance ?? prev.gBalance,
|
|
1342
1725
|
buyerPubKey: overrides.buyerPubKey ?? prev.buyerPubKey,
|
|
@@ -1360,31 +1743,15 @@ function viewToStatePatch(view, enriched, prev, options) {
|
|
|
1360
1743
|
isGoodIdVerified: enriched.goodIdVerified,
|
|
1361
1744
|
operatorConsented: operatorAccepted,
|
|
1362
1745
|
operatorAddress: view.operator.operatorAddress ?? null,
|
|
1746
|
+
currentOperator: view.operator.currentOperator ?? null,
|
|
1363
1747
|
withdrawableUsd: view.withdrawableUsd,
|
|
1364
1748
|
totalGdDepositedG: enriched.totalGdDepositedG,
|
|
1365
|
-
monthlyStreamG: enriched.monthlyStreamG
|
|
1366
|
-
...view.buyer ? { buyerPubKey: view.buyer } : {}
|
|
1367
|
-
};
|
|
1368
|
-
}
|
|
1369
|
-
function mergeSessionFields(prev, sessionPatch, accountPatch, accountSwitched) {
|
|
1370
|
-
const buyerPubKey = sessionPatch.buyerPubKey ?? accountPatch.buyerPubKey ?? (accountSwitched ? null : prev.buyerPubKey);
|
|
1371
|
-
const buyerPrvKey = sessionPatch.buyerPrvKey ?? (accountSwitched ? null : prev.buyerPrvKey);
|
|
1372
|
-
const operatorConsented = accountSwitched ? sessionPatch.operatorConsented ?? accountPatch.operatorConsented ?? false : accountPatch.operatorConsented ?? sessionPatch.operatorConsented ?? prev.operatorConsented;
|
|
1373
|
-
return {
|
|
1374
|
-
buyerPubKey,
|
|
1375
|
-
buyerPrvKey,
|
|
1376
|
-
operatorConsented
|
|
1749
|
+
monthlyStreamG: enriched.monthlyStreamG
|
|
1377
1750
|
};
|
|
1378
1751
|
}
|
|
1379
|
-
function
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
}
|
|
1383
|
-
function syncBuyerPubKeySession(address, buyerPubKey) {
|
|
1384
|
-
if (!buyerPubKey) return;
|
|
1385
|
-
const existing = readPayerSession(address);
|
|
1386
|
-
if (existing?.buyerPubKey) return;
|
|
1387
|
-
patchPayerSession(address, { buyerPubKey });
|
|
1752
|
+
function activateBuyerSelection(payer, buyers, selectedAddress) {
|
|
1753
|
+
setActiveBuyerAddress(payer, selectedAddress);
|
|
1754
|
+
return buildBuyerStateFields(payer, buyers, selectedAddress);
|
|
1388
1755
|
}
|
|
1389
1756
|
function useAiCreditsAdapter({
|
|
1390
1757
|
environment = "production",
|
|
@@ -1408,6 +1775,9 @@ function useAiCreditsAdapter({
|
|
|
1408
1775
|
const providerRef = (0, import_react.useRef)(null);
|
|
1409
1776
|
providerRef.current = provider;
|
|
1410
1777
|
const goodIdVerifyPendingRef = (0, import_react.useRef)(false);
|
|
1778
|
+
const pendingDeepLinkRef = (0, import_react.useRef)(null);
|
|
1779
|
+
const deepLinkParseDoneRef = (0, import_react.useRef)(false);
|
|
1780
|
+
const deepLinkApplyInFlightRef = (0, import_react.useRef)(false);
|
|
1411
1781
|
const celoVault = vaultAddress ?? CELO_GD_ANTSEED_VAULT_FALLBACK;
|
|
1412
1782
|
const backendClient = (0, import_react.useMemo)(
|
|
1413
1783
|
() => backendClientOverride ?? createBackendClient(backendUrl),
|
|
@@ -1425,7 +1795,11 @@ function useAiCreditsAdapter({
|
|
|
1425
1795
|
);
|
|
1426
1796
|
(0, import_react.useEffect)(() => {
|
|
1427
1797
|
if (!isConnected || !address) {
|
|
1428
|
-
setState((prev) =>
|
|
1798
|
+
setState((prev) => {
|
|
1799
|
+
if (prev.status === "connecting") return prev;
|
|
1800
|
+
if (!prev.address && prev.status === "disconnected" && prev.error === null) return prev;
|
|
1801
|
+
return { ...INITIAL_STATE };
|
|
1802
|
+
});
|
|
1429
1803
|
return;
|
|
1430
1804
|
}
|
|
1431
1805
|
if (configurationError) {
|
|
@@ -1444,14 +1818,17 @@ function useAiCreditsAdapter({
|
|
|
1444
1818
|
if (prev.status === "payment_pending" || prev.status === "payment_confirmed" || prev.status === "payment_failed") {
|
|
1445
1819
|
return prev;
|
|
1446
1820
|
}
|
|
1447
|
-
const accountSwitched = !addressesMatch(prev.address, address);
|
|
1448
|
-
const buyerFields = mergeSessionFields(prev, sessionPatch, {}, accountSwitched);
|
|
1449
1821
|
return withDerivedStatus(
|
|
1450
1822
|
prev,
|
|
1451
1823
|
{
|
|
1452
1824
|
address,
|
|
1453
1825
|
chainId,
|
|
1454
|
-
|
|
1826
|
+
buyerPubKey: sessionPatch.buyerPubKey,
|
|
1827
|
+
buyerPrvKey: sessionPatch.buyerPrvKey,
|
|
1828
|
+
operatorSignature: sessionPatch.operatorSignature,
|
|
1829
|
+
operatorConsented: sessionPatch.operatorConsented,
|
|
1830
|
+
derivedBuyerAddress: sessionPatch.derivedBuyerAddress,
|
|
1831
|
+
buyers: prev.buyers,
|
|
1455
1832
|
...WALLET_LOADING_STATE,
|
|
1456
1833
|
error: null,
|
|
1457
1834
|
status: "connecting"
|
|
@@ -1474,8 +1851,11 @@ function useAiCreditsAdapter({
|
|
|
1474
1851
|
functionName: "decimals"
|
|
1475
1852
|
})
|
|
1476
1853
|
]);
|
|
1477
|
-
const
|
|
1478
|
-
|
|
1854
|
+
const pendingDeepLink = pendingDeepLinkRef.current;
|
|
1855
|
+
const sessionBuyer = patchPayerSessionFields(address).buyerPubKey;
|
|
1856
|
+
const preferredBuyer = pendingDeepLink?.buyerAddress ?? sessionBuyer ?? null;
|
|
1857
|
+
const accountPromise = pendingDeepLink || deepLinkApplyInFlightRef.current ? Promise.resolve(null) : buildAccountView(address, backendClient, chainClient, {
|
|
1858
|
+
buyerAddress: preferredBuyer
|
|
1479
1859
|
}).then(async (view) => ({
|
|
1480
1860
|
view,
|
|
1481
1861
|
enriched: await enrichAccountView(view, chainClient)
|
|
@@ -1486,13 +1866,25 @@ function useAiCreditsAdapter({
|
|
|
1486
1866
|
}) : fetchVaultPaymentMinimums(publicClient, celoVault, address).catch(() => null);
|
|
1487
1867
|
const gdUsdPerTokenPromise = chainClient.fetchGdUsdPerToken().catch(() => null);
|
|
1488
1868
|
const discountConfigPromise = backendClient.getDiscountConfig().catch(() => null);
|
|
1869
|
+
const buyersPromise = pendingDeepLink ? Promise.resolve(
|
|
1870
|
+
rememberBuyerAddresses(address, [
|
|
1871
|
+
preferredBuyer,
|
|
1872
|
+
...listKnownBuyerAddresses(address)
|
|
1873
|
+
])
|
|
1874
|
+
) : discoverBuyersFromHistory(
|
|
1875
|
+
address,
|
|
1876
|
+
backendClient,
|
|
1877
|
+
preferredBuyer,
|
|
1878
|
+
...listKnownBuyerAddresses(address)
|
|
1879
|
+
);
|
|
1489
1880
|
try {
|
|
1490
|
-
const [[rawBalance, decimals], account, minimums, gdUsdPerToken, discountConfig] = await Promise.all([
|
|
1881
|
+
const [[rawBalance, decimals], account, minimums, gdUsdPerToken, discountConfig, buyers] = await Promise.all([
|
|
1491
1882
|
balancePromise,
|
|
1492
1883
|
accountPromise,
|
|
1493
1884
|
minimumsPromise,
|
|
1494
1885
|
gdUsdPerTokenPromise,
|
|
1495
|
-
discountConfigPromise
|
|
1886
|
+
discountConfigPromise,
|
|
1887
|
+
buyersPromise
|
|
1496
1888
|
]);
|
|
1497
1889
|
if (cancelled) return;
|
|
1498
1890
|
const patch = {
|
|
@@ -1505,41 +1897,54 @@ function useAiCreditsAdapter({
|
|
|
1505
1897
|
depositBonusPercent: discountConfig?.depositBonusPercent ?? DEFAULT_DISCOUNT_CONFIG.depositBonusPercent,
|
|
1506
1898
|
streamBonusPercent: discountConfig?.streamBonusPercent ?? DEFAULT_DISCOUNT_CONFIG.streamBonusPercent
|
|
1507
1899
|
};
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1900
|
+
if (pendingDeepLink || deepLinkApplyInFlightRef.current) {
|
|
1901
|
+
setState(
|
|
1902
|
+
(prev) => withDerivedStatus(
|
|
1903
|
+
prev,
|
|
1904
|
+
{
|
|
1905
|
+
...patch,
|
|
1906
|
+
buyers: mergeBuyerAddressList(prev.buyers, ...buyers)
|
|
1907
|
+
},
|
|
1908
|
+
true
|
|
1909
|
+
)
|
|
1910
|
+
);
|
|
1911
|
+
return;
|
|
1912
|
+
}
|
|
1913
|
+
const selectedBuyer = selectPreferredBuyer(buyers, preferredBuyer);
|
|
1914
|
+
const accountPatch = account ? viewToStatePatch(account.view, account.enriched, INITIAL_STATE, {
|
|
1915
|
+
balanceMode: "always"
|
|
1916
|
+
}) : {};
|
|
1917
|
+
if (selectedBuyer && accountPatch.operatorConsented !== void 0) {
|
|
1918
|
+
setBuyerOperatorConsented(address, selectedBuyer, accountPatch.operatorConsented);
|
|
1919
|
+
}
|
|
1920
|
+
const buyerFields = activateBuyerSelection(address, buyers, selectedBuyer);
|
|
1921
|
+
setState(
|
|
1922
|
+
(prev) => withDerivedStatus(
|
|
1521
1923
|
prev,
|
|
1522
1924
|
{
|
|
1523
1925
|
...patch,
|
|
1524
1926
|
...accountPatch,
|
|
1525
1927
|
...buyerFields,
|
|
1526
|
-
|
|
1928
|
+
operatorConsented: accountPatch.operatorConsented ?? buyerFields.operatorConsented
|
|
1527
1929
|
},
|
|
1528
1930
|
true
|
|
1529
|
-
)
|
|
1530
|
-
|
|
1931
|
+
)
|
|
1932
|
+
);
|
|
1531
1933
|
} catch {
|
|
1532
1934
|
if (cancelled) return;
|
|
1533
1935
|
setState((prev) => {
|
|
1534
|
-
const accountSwitched = !addressesMatch(prev.address, address);
|
|
1535
|
-
const buyerFields = mergeSessionFields(prev, sessionPatch, {}, accountSwitched);
|
|
1536
1936
|
return withDerivedStatus(
|
|
1537
1937
|
prev,
|
|
1538
1938
|
{
|
|
1539
1939
|
address,
|
|
1540
1940
|
chainId,
|
|
1541
1941
|
gBalance: "0",
|
|
1542
|
-
|
|
1942
|
+
buyers: [],
|
|
1943
|
+
derivedBuyerAddress: null,
|
|
1944
|
+
buyerPubKey: null,
|
|
1945
|
+
buyerPrvKey: null,
|
|
1946
|
+
operatorSignature: null,
|
|
1947
|
+
operatorConsented: false,
|
|
1543
1948
|
status: chainId !== null && chainId !== CELO_CHAIN_ID2 ? "unsupported_chain" : "purchase_setup"
|
|
1544
1949
|
},
|
|
1545
1950
|
true
|
|
@@ -1578,14 +1983,32 @@ function useAiCreditsAdapter({
|
|
|
1578
1983
|
setState(
|
|
1579
1984
|
(prev) => withDerivedStatus(
|
|
1580
1985
|
prev,
|
|
1581
|
-
{ error: "Connect your wallet before generating a
|
|
1986
|
+
{ error: "Connect your wallet before generating a signer key" },
|
|
1582
1987
|
true
|
|
1583
1988
|
)
|
|
1584
1989
|
);
|
|
1585
1990
|
return;
|
|
1586
1991
|
}
|
|
1992
|
+
const payerAddress = address;
|
|
1993
|
+
const session = readPayerSession(payerAddress);
|
|
1994
|
+
const derivedAddress = session?.derivedBuyerAddress ?? null;
|
|
1995
|
+
const existingKey = derivedAddress ? getBuyerKeyEntry(payerAddress, derivedAddress) : null;
|
|
1996
|
+
if (derivedAddress && existingKey?.privateKey) {
|
|
1997
|
+
const buyers = mergeBuyerAddressList(
|
|
1998
|
+
listKnownBuyerAddresses(payerAddress),
|
|
1999
|
+
derivedAddress
|
|
2000
|
+
);
|
|
2001
|
+
const buyerFields = activateBuyerSelection(payerAddress, buyers, derivedAddress);
|
|
2002
|
+
setState(
|
|
2003
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2004
|
+
...buyerFields,
|
|
2005
|
+
error: null,
|
|
2006
|
+
...!isNonBuyTab(prev.activeTab) ? { status: "purchase_setup" } : {}
|
|
2007
|
+
})
|
|
2008
|
+
);
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
1587
2011
|
try {
|
|
1588
|
-
const payerAddress = address;
|
|
1589
2012
|
const message = buildBuyerKeyMessage(payerAddress);
|
|
1590
2013
|
const walletClient = (0, import_viem8.createWalletClient)({
|
|
1591
2014
|
account: payerAddress,
|
|
@@ -1597,15 +2020,21 @@ function useAiCreditsAdapter({
|
|
|
1597
2020
|
message
|
|
1598
2021
|
});
|
|
1599
2022
|
const privateKey = deriveBuyerPrivateKeyFromSignature(signature);
|
|
1600
|
-
const
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
2023
|
+
const buyerAccount = (0, import_accounts4.privateKeyToAccount)(privateKey);
|
|
2024
|
+
upsertBuyerKey(
|
|
2025
|
+
payerAddress,
|
|
2026
|
+
buyerAccount.address,
|
|
2027
|
+
{ privateKey },
|
|
2028
|
+
{ setActive: true, setDerived: true }
|
|
2029
|
+
);
|
|
2030
|
+
const buyers = mergeBuyerAddressList(
|
|
2031
|
+
listKnownBuyerAddresses(payerAddress),
|
|
2032
|
+
buyerAccount.address
|
|
2033
|
+
);
|
|
2034
|
+
const buyerFields = buildBuyerStateFields(payerAddress, buyers, buyerAccount.address);
|
|
1605
2035
|
setState(
|
|
1606
2036
|
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
1607
|
-
|
|
1608
|
-
buyerPrvKey: privateKey,
|
|
2037
|
+
...buyerFields,
|
|
1609
2038
|
error: null,
|
|
1610
2039
|
...!isNonBuyTab(prev.activeTab) ? { status: "purchase_setup" } : {}
|
|
1611
2040
|
})
|
|
@@ -1622,64 +2051,332 @@ function useAiCreditsAdapter({
|
|
|
1622
2051
|
);
|
|
1623
2052
|
}
|
|
1624
2053
|
}, [address]);
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1627
|
-
|
|
2054
|
+
const handleSelectBuyer = (0, import_react.useCallback)(
|
|
2055
|
+
async (buyerAddress) => {
|
|
2056
|
+
if (!address) return;
|
|
2057
|
+
const known = listKnownBuyerAddresses(address);
|
|
2058
|
+
if (!known.some((item) => item.toLowerCase() === buyerAddress.toLowerCase())) {
|
|
2059
|
+
return;
|
|
2060
|
+
}
|
|
2061
|
+
const buyers = mergeBuyerAddressList(known, buyerAddress);
|
|
2062
|
+
const buyerFields = activateBuyerSelection(address, buyers, buyerAddress);
|
|
1628
2063
|
setState(
|
|
1629
|
-
(prev) =>
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
2064
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2065
|
+
...buyerFields,
|
|
2066
|
+
operatorAddress: null,
|
|
2067
|
+
currentOperator: null,
|
|
2068
|
+
totalCreditUsd: null,
|
|
2069
|
+
withdrawableUsd: null,
|
|
2070
|
+
totalGdDepositedG: null,
|
|
2071
|
+
monthlyStreamG: null,
|
|
2072
|
+
operatorConsentPending: false,
|
|
2073
|
+
error: null
|
|
2074
|
+
})
|
|
1634
2075
|
);
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
2076
|
+
try {
|
|
2077
|
+
const view = await buildAccountView(address, backendClient, chainClient, {
|
|
2078
|
+
buyerAddress
|
|
2079
|
+
});
|
|
2080
|
+
const enriched = await enrichAccountView(view, chainClient);
|
|
2081
|
+
const accountPatch = viewToStatePatch(view, enriched, INITIAL_STATE, {
|
|
2082
|
+
balanceMode: "always"
|
|
2083
|
+
});
|
|
2084
|
+
if (accountPatch.operatorConsented !== void 0) {
|
|
2085
|
+
setBuyerOperatorConsented(address, buyerAddress, accountPatch.operatorConsented);
|
|
2086
|
+
}
|
|
2087
|
+
const nextBuyerFields = buildBuyerStateFields(address, buyers, buyerAddress);
|
|
2088
|
+
setState(
|
|
2089
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2090
|
+
...accountPatch,
|
|
2091
|
+
...nextBuyerFields,
|
|
2092
|
+
operatorConsented: accountPatch.operatorConsented ?? nextBuyerFields.operatorConsented,
|
|
2093
|
+
error: null
|
|
2094
|
+
})
|
|
2095
|
+
);
|
|
2096
|
+
} catch (err) {
|
|
2097
|
+
setState(
|
|
2098
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2099
|
+
error: err instanceof Error ? err.message : "Could not load buyer account"
|
|
2100
|
+
})
|
|
2101
|
+
);
|
|
1643
2102
|
}
|
|
1644
|
-
|
|
1645
|
-
|
|
2103
|
+
},
|
|
2104
|
+
[address, backendClient, chainClient]
|
|
2105
|
+
);
|
|
2106
|
+
const handleDiscoverBuyers = (0, import_react.useCallback)(
|
|
2107
|
+
(addresses) => {
|
|
2108
|
+
if (!address || addresses.length === 0) return;
|
|
2109
|
+
const buyers = rememberBuyerAddresses(address, addresses);
|
|
2110
|
+
setState((prev) => {
|
|
2111
|
+
const sameLength = buyers.length === prev.buyers.length;
|
|
2112
|
+
const unchanged = sameLength && buyers.every(
|
|
2113
|
+
(item, index) => item.toLowerCase() === prev.buyers[index]?.toLowerCase()
|
|
2114
|
+
);
|
|
2115
|
+
if (unchanged) return prev;
|
|
2116
|
+
return { ...prev, buyers };
|
|
2117
|
+
});
|
|
2118
|
+
},
|
|
2119
|
+
[address]
|
|
2120
|
+
);
|
|
2121
|
+
const handleImportBuyerFromPrivateKey = (0, import_react.useCallback)(
|
|
2122
|
+
async (rawPrivateKey) => {
|
|
2123
|
+
if (!address) {
|
|
2124
|
+
setState(
|
|
2125
|
+
(prev) => withDerivedStatus(prev, { error: "Connect your wallet before importing a signer key" }, true)
|
|
2126
|
+
);
|
|
2127
|
+
return null;
|
|
2128
|
+
}
|
|
2129
|
+
const trimmed = rawPrivateKey.trim();
|
|
2130
|
+
const normalized = trimmed.startsWith("0x") ? trimmed : `0x${trimmed}`;
|
|
2131
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(normalized)) {
|
|
2132
|
+
setState(
|
|
2133
|
+
(prev) => withDerivedStatus(
|
|
2134
|
+
prev,
|
|
2135
|
+
{ error: "Invalid private key format \u2014 expected 0x followed by 64 hex characters" },
|
|
2136
|
+
true
|
|
2137
|
+
)
|
|
2138
|
+
);
|
|
2139
|
+
return null;
|
|
2140
|
+
}
|
|
2141
|
+
try {
|
|
2142
|
+
const privateKey = normalized;
|
|
2143
|
+
const buyerAccount = (0, import_accounts4.privateKeyToAccount)(privateKey);
|
|
2144
|
+
upsertBuyerKey(address, buyerAccount.address, { privateKey }, { setActive: true });
|
|
2145
|
+
const buyers = mergeBuyerAddressList(
|
|
2146
|
+
listKnownBuyerAddresses(address),
|
|
2147
|
+
buyerAccount.address
|
|
2148
|
+
);
|
|
2149
|
+
const buyerFields = buildBuyerStateFields(address, buyers, buyerAccount.address);
|
|
1646
2150
|
setState(
|
|
1647
2151
|
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
1648
|
-
|
|
2152
|
+
...buyerFields,
|
|
2153
|
+
operatorAddress: null,
|
|
2154
|
+
currentOperator: null,
|
|
2155
|
+
totalCreditUsd: null,
|
|
2156
|
+
withdrawableUsd: null,
|
|
2157
|
+
totalGdDepositedG: null,
|
|
2158
|
+
monthlyStreamG: null,
|
|
1649
2159
|
error: null,
|
|
1650
|
-
...!
|
|
2160
|
+
...!isNonBuyTab(prev.activeTab) ? { status: "purchase_setup" } : {}
|
|
1651
2161
|
})
|
|
1652
2162
|
);
|
|
2163
|
+
try {
|
|
2164
|
+
const view = await buildAccountView(address, backendClient, chainClient, {
|
|
2165
|
+
buyerAddress: buyerAccount.address
|
|
2166
|
+
});
|
|
2167
|
+
const enriched = await enrichAccountView(view, chainClient);
|
|
2168
|
+
const accountPatch = viewToStatePatch(view, enriched, INITIAL_STATE, {
|
|
2169
|
+
balanceMode: "always"
|
|
2170
|
+
});
|
|
2171
|
+
if (accountPatch.operatorConsented !== void 0) {
|
|
2172
|
+
setBuyerOperatorConsented(
|
|
2173
|
+
address,
|
|
2174
|
+
buyerAccount.address,
|
|
2175
|
+
accountPatch.operatorConsented
|
|
2176
|
+
);
|
|
2177
|
+
}
|
|
2178
|
+
const nextBuyerFields = buildBuyerStateFields(
|
|
2179
|
+
address,
|
|
2180
|
+
buyers,
|
|
2181
|
+
buyerAccount.address
|
|
2182
|
+
);
|
|
2183
|
+
setState(
|
|
2184
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2185
|
+
...accountPatch,
|
|
2186
|
+
...nextBuyerFields,
|
|
2187
|
+
operatorConsented: accountPatch.operatorConsented ?? nextBuyerFields.operatorConsented,
|
|
2188
|
+
error: null
|
|
2189
|
+
})
|
|
2190
|
+
);
|
|
2191
|
+
} catch {
|
|
2192
|
+
return buyerAccount.address;
|
|
2193
|
+
}
|
|
2194
|
+
return buyerAccount.address;
|
|
2195
|
+
} catch {
|
|
2196
|
+
setState(
|
|
2197
|
+
(prev) => withDerivedStatus(prev, { error: "Could not derive an account from the provided private key" }, true)
|
|
2198
|
+
);
|
|
2199
|
+
return null;
|
|
2200
|
+
}
|
|
2201
|
+
},
|
|
2202
|
+
[address, backendClient, chainClient]
|
|
2203
|
+
);
|
|
2204
|
+
const resolveBuyerList = (0, import_react.useCallback)(
|
|
2205
|
+
(payer, preferredBuyer) => resolveLocalBuyers(payer, preferredBuyer),
|
|
2206
|
+
[]
|
|
2207
|
+
);
|
|
2208
|
+
const handleApplyDeepLinkBuyer = (0, import_react.useCallback)(
|
|
2209
|
+
async (buyerAddress, operatorSignature) => {
|
|
2210
|
+
if (!address) {
|
|
1653
2211
|
return;
|
|
1654
2212
|
}
|
|
1655
|
-
const
|
|
1656
|
-
|
|
1657
|
-
|
|
2213
|
+
const trimmedAddress = buyerAddress.trim();
|
|
2214
|
+
const trimmedSignature = operatorSignature.trim();
|
|
2215
|
+
if (!isValidBuyerAddress(trimmedAddress)) {
|
|
2216
|
+
setState(
|
|
2217
|
+
(prev) => withDerivedStatus(
|
|
2218
|
+
prev,
|
|
2219
|
+
{
|
|
2220
|
+
error: deepLinkManualFallbackMessage("Deep-link buyerAddress is invalid."),
|
|
2221
|
+
activeTab: "buy",
|
|
2222
|
+
status: "purchase_setup"
|
|
2223
|
+
},
|
|
2224
|
+
true
|
|
2225
|
+
)
|
|
2226
|
+
);
|
|
2227
|
+
return;
|
|
1658
2228
|
}
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
2229
|
+
if (!isValidOperatorSignature(trimmedSignature)) {
|
|
2230
|
+
setState(
|
|
2231
|
+
(prev) => withDerivedStatus(
|
|
2232
|
+
prev,
|
|
2233
|
+
{
|
|
2234
|
+
error: deepLinkManualFallbackMessage("Deep-link operatorSignature is invalid."),
|
|
2235
|
+
activeTab: "buy",
|
|
2236
|
+
status: "purchase_setup"
|
|
2237
|
+
},
|
|
2238
|
+
true
|
|
2239
|
+
)
|
|
2240
|
+
);
|
|
2241
|
+
return;
|
|
2242
|
+
}
|
|
2243
|
+
storeDeepLinkParams({
|
|
2244
|
+
buyerAddress: trimmedAddress,
|
|
2245
|
+
operatorSignature: trimmedSignature
|
|
1666
2246
|
});
|
|
1667
|
-
|
|
1668
|
-
|
|
2247
|
+
upsertBuyerKey(
|
|
2248
|
+
address,
|
|
2249
|
+
trimmedAddress,
|
|
2250
|
+
{ operatorSignature: trimmedSignature },
|
|
2251
|
+
{ setActive: true }
|
|
2252
|
+
);
|
|
2253
|
+
const buyers = mergeBuyerAddressList(listKnownBuyerAddresses(address), trimmedAddress);
|
|
2254
|
+
const buyerFields = buildBuyerStateFields(address, buyers, trimmedAddress);
|
|
1669
2255
|
setState(
|
|
1670
2256
|
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2257
|
+
...buyerFields,
|
|
2258
|
+
operatorAddress: null,
|
|
2259
|
+
currentOperator: null,
|
|
2260
|
+
totalCreditUsd: null,
|
|
2261
|
+
withdrawableUsd: null,
|
|
2262
|
+
totalGdDepositedG: null,
|
|
2263
|
+
monthlyStreamG: null,
|
|
2264
|
+
activeTab: "buy",
|
|
2265
|
+
operatorConsentPending: false,
|
|
2266
|
+
error: null
|
|
2267
|
+
})
|
|
2268
|
+
);
|
|
2269
|
+
},
|
|
2270
|
+
[address]
|
|
2271
|
+
);
|
|
2272
|
+
const handleSignOperatorConsent = (0, import_react.useCallback)(async () => {
|
|
2273
|
+
const currentState = state;
|
|
2274
|
+
if (!currentState.address || !currentState.buyerPubKey) {
|
|
2275
|
+
setState(
|
|
2276
|
+
(prev) => withDerivedStatus(
|
|
2277
|
+
prev,
|
|
2278
|
+
{ error: "Select a buyer before authorizing your wallet" },
|
|
2279
|
+
true
|
|
2280
|
+
)
|
|
2281
|
+
);
|
|
2282
|
+
return;
|
|
2283
|
+
}
|
|
2284
|
+
const keyEntry = getBuyerKeyEntry(currentState.address, currentState.buyerPubKey);
|
|
2285
|
+
const storedOperatorSignature = currentState.operatorSignature ?? keyEntry?.operatorSignature ?? null;
|
|
2286
|
+
if (!currentState.buyerPrvKey && !storedOperatorSignature) {
|
|
2287
|
+
setState(
|
|
2288
|
+
(prev) => withDerivedStatus(
|
|
2289
|
+
prev,
|
|
2290
|
+
{ error: "Generate a signer key before authorizing your wallet" },
|
|
2291
|
+
true
|
|
2292
|
+
)
|
|
2293
|
+
);
|
|
2294
|
+
return;
|
|
2295
|
+
}
|
|
2296
|
+
if (currentState.operatorConsentPending) return;
|
|
2297
|
+
const ref = { payer: currentState.address, buyer: currentState.buyerPubKey };
|
|
2298
|
+
const onNonBuyTab = isNonBuyTab(currentState.activeTab);
|
|
2299
|
+
setState((prev) => ({
|
|
2300
|
+
...prev,
|
|
2301
|
+
operatorConsentPending: true,
|
|
2302
|
+
error: null
|
|
2303
|
+
}));
|
|
2304
|
+
try {
|
|
2305
|
+
const operatorStatus = await chainClient.getBuyerOperatorStatus(ref);
|
|
2306
|
+
if (!operatorStatus.enabled) {
|
|
2307
|
+
throw new Error("Operator consent is not available");
|
|
2308
|
+
}
|
|
2309
|
+
const hasDifferentOperator = operatorStatus.currentOperator !== "0x0000000000000000000000000000000000000000" && !operatorStatus.operatorAccepted;
|
|
2310
|
+
if (hasDifferentOperator) {
|
|
2311
|
+
throw new Error(
|
|
2312
|
+
"This signer key is already controlled by another operator. Import a different signer key or generate a new one."
|
|
2313
|
+
);
|
|
2314
|
+
}
|
|
2315
|
+
if (operatorStatus.operatorAccepted) {
|
|
2316
|
+
setBuyerOperatorConsented(currentState.address, currentState.buyerPubKey, true);
|
|
2317
|
+
const buyerList2 = resolveBuyerList(currentState.address, currentState.buyerPubKey);
|
|
2318
|
+
const buyerFields2 = buildBuyerStateFields(
|
|
2319
|
+
currentState.address,
|
|
2320
|
+
buyerList2.buyers,
|
|
2321
|
+
buyerList2.selected
|
|
2322
|
+
);
|
|
2323
|
+
setState(
|
|
2324
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2325
|
+
...buyerFields2,
|
|
2326
|
+
operatorConsented: true,
|
|
2327
|
+
operatorConsentPending: false,
|
|
2328
|
+
error: null,
|
|
2329
|
+
...!onNonBuyTab ? { status: "purchase_setup" } : {}
|
|
2330
|
+
})
|
|
2331
|
+
);
|
|
2332
|
+
clearDeepLinkArtifacts();
|
|
2333
|
+
return;
|
|
2334
|
+
}
|
|
2335
|
+
let buyerSig;
|
|
2336
|
+
if (currentState.buyerPrvKey) {
|
|
2337
|
+
const payload = await chainClient.buildOperatorConsentPayload(ref, operatorStatus);
|
|
2338
|
+
if (!payload.enabled || !payload.typedData) {
|
|
2339
|
+
throw new Error("Operator consent is not available");
|
|
2340
|
+
}
|
|
2341
|
+
buyerSig = await signOperatorConsentFromTypedData(
|
|
2342
|
+
currentState.buyerPrvKey,
|
|
2343
|
+
payload.typedData
|
|
2344
|
+
);
|
|
2345
|
+
} else if (storedOperatorSignature) {
|
|
2346
|
+
buyerSig = storedOperatorSignature;
|
|
2347
|
+
} else {
|
|
2348
|
+
throw new Error("Generate a signer key before authorizing your wallet");
|
|
2349
|
+
}
|
|
2350
|
+
await backendClient.submitOperatorConsent(ref.buyer, {
|
|
2351
|
+
nonce: operatorStatus.consentNonce,
|
|
2352
|
+
signature: buyerSig
|
|
2353
|
+
});
|
|
2354
|
+
await waitForOperatorConsent(chainClient, ref);
|
|
2355
|
+
setBuyerOperatorConsented(currentState.address, currentState.buyerPubKey, true);
|
|
2356
|
+
const buyerList = resolveBuyerList(currentState.address, currentState.buyerPubKey);
|
|
2357
|
+
const buyerFields = buildBuyerStateFields(
|
|
2358
|
+
currentState.address,
|
|
2359
|
+
buyerList.buyers,
|
|
2360
|
+
buyerList.selected
|
|
2361
|
+
);
|
|
2362
|
+
setState(
|
|
2363
|
+
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
2364
|
+
...buyerFields,
|
|
1671
2365
|
operatorConsented: true,
|
|
2366
|
+
operatorConsentPending: false,
|
|
1672
2367
|
error: null,
|
|
1673
2368
|
...!onNonBuyTab ? { status: "purchase_setup" } : {}
|
|
1674
2369
|
})
|
|
1675
2370
|
);
|
|
2371
|
+
clearDeepLinkArtifacts();
|
|
1676
2372
|
} catch (err) {
|
|
1677
2373
|
setState((prev) => ({
|
|
1678
2374
|
...prev,
|
|
2375
|
+
operatorConsentPending: false,
|
|
1679
2376
|
error: err instanceof Error ? err.message : "Operator consent signature rejected"
|
|
1680
2377
|
}));
|
|
1681
2378
|
}
|
|
1682
|
-
}, [state, backendClient, chainClient]);
|
|
2379
|
+
}, [state, backendClient, chainClient, resolveBuyerList]);
|
|
1683
2380
|
const handleSyncOperatorConsentFromChain = (0, import_react.useCallback)(async () => {
|
|
1684
2381
|
const currentState = state;
|
|
1685
2382
|
if (!currentState.address || !currentState.buyerPubKey || currentState.operatorConsented) {
|
|
@@ -1689,7 +2386,7 @@ function useAiCreditsAdapter({
|
|
|
1689
2386
|
const ref = { payer: currentState.address, buyer: currentState.buyerPubKey };
|
|
1690
2387
|
const operatorStatus = await chainClient.getBuyerOperatorStatus(ref);
|
|
1691
2388
|
if (!operatorStatus.operatorAccepted) return;
|
|
1692
|
-
|
|
2389
|
+
setBuyerOperatorConsented(currentState.address, currentState.buyerPubKey, true);
|
|
1693
2390
|
const onNonBuyTab = isNonBuyTab(currentState.activeTab);
|
|
1694
2391
|
setState(
|
|
1695
2392
|
(prev) => mergeStatePreservingNonBuyTab(prev, {
|
|
@@ -1721,7 +2418,7 @@ function useAiCreditsAdapter({
|
|
|
1721
2418
|
async (quote) => {
|
|
1722
2419
|
const currentState = state;
|
|
1723
2420
|
if (!currentState.address || !currentState.buyerPubKey || !providerRef.current) {
|
|
1724
|
-
throw new Error("Connect your wallet and generate a
|
|
2421
|
+
throw new Error("Connect your wallet and generate a signer key before paying");
|
|
1725
2422
|
}
|
|
1726
2423
|
const hasDeposit = Number.parseFloat(quote.depositAmountG) > 0;
|
|
1727
2424
|
const streamChanged = isStreamAmountChanged(quote.streamAmountG, currentState.monthlyStreamG);
|
|
@@ -1827,8 +2524,15 @@ function useAiCreditsAdapter({
|
|
|
1827
2524
|
previousBalance: balanceBefore
|
|
1828
2525
|
});
|
|
1829
2526
|
const creditUsdMicro = (BigInt(totalCreditUsd) - BigInt(balanceBefore || "0")).toString();
|
|
2527
|
+
const buyerList = resolveBuyerList(currentState.address, currentState.buyerPubKey);
|
|
2528
|
+
const buyerFields = buildBuyerStateFields(
|
|
2529
|
+
currentState.address,
|
|
2530
|
+
buyerList.buyers,
|
|
2531
|
+
buyerList.selected
|
|
2532
|
+
);
|
|
1830
2533
|
setState(
|
|
1831
2534
|
(prev) => withDerivedStatus(prev, {
|
|
2535
|
+
...buyerFields,
|
|
1832
2536
|
totalCreditUsd,
|
|
1833
2537
|
error: null,
|
|
1834
2538
|
activeTab: "manage"
|
|
@@ -1863,6 +2567,7 @@ function useAiCreditsAdapter({
|
|
|
1863
2567
|
celoVault,
|
|
1864
2568
|
onPaySuccess,
|
|
1865
2569
|
onPayError,
|
|
2570
|
+
resolveBuyerList,
|
|
1866
2571
|
prepareSettlement,
|
|
1867
2572
|
skipVaultPaymentValidation
|
|
1868
2573
|
]
|
|
@@ -1872,36 +2577,38 @@ function useAiCreditsAdapter({
|
|
|
1872
2577
|
const currentState = state;
|
|
1873
2578
|
if (!currentState.address) return;
|
|
1874
2579
|
try {
|
|
1875
|
-
const
|
|
2580
|
+
const preferredBuyer = currentState.buyerPubKey;
|
|
2581
|
+
const buyerList = resolveBuyerList(currentState.address, preferredBuyer);
|
|
1876
2582
|
const [view, discountConfig] = await Promise.all([
|
|
1877
2583
|
buildAccountView(currentState.address, backendClient, chainClient, {
|
|
1878
|
-
buyerAddress:
|
|
2584
|
+
buyerAddress: preferredBuyer
|
|
1879
2585
|
}),
|
|
1880
2586
|
backendClient.getDiscountConfig().catch(() => null)
|
|
1881
2587
|
]);
|
|
1882
2588
|
const enriched = await enrichAccountView(view, chainClient);
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
accountPatch
|
|
1891
|
-
false
|
|
2589
|
+
const accountPatch = viewToStatePatch(view, enriched, INITIAL_STATE, {
|
|
2590
|
+
balanceMode: "always"
|
|
2591
|
+
});
|
|
2592
|
+
if (preferredBuyer && accountPatch.operatorConsented !== void 0 && currentState.address) {
|
|
2593
|
+
setBuyerOperatorConsented(
|
|
2594
|
+
currentState.address,
|
|
2595
|
+
preferredBuyer,
|
|
2596
|
+
accountPatch.operatorConsented
|
|
1892
2597
|
);
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
2598
|
+
}
|
|
2599
|
+
const buyerFields = buildBuyerStateFields(
|
|
2600
|
+
currentState.address,
|
|
2601
|
+
buyerList.buyers,
|
|
2602
|
+
buyerList.selected
|
|
2603
|
+
);
|
|
2604
|
+
setState((prev) => {
|
|
1899
2605
|
const statusSeed = options?.afterGoodIdVerify && prev.status === "payment_failed" ? "quote_ready" : prev.status === "backend_unavailable" ? "purchase_setup" : prev.status;
|
|
1900
2606
|
return withDerivedStatus(
|
|
1901
2607
|
{ ...prev, status: statusSeed },
|
|
1902
2608
|
{
|
|
1903
2609
|
...accountPatch,
|
|
1904
|
-
...
|
|
2610
|
+
...buyerFields,
|
|
2611
|
+
operatorConsented: accountPatch.operatorConsented ?? buyerFields.operatorConsented,
|
|
1905
2612
|
activeTab: prev.activeTab,
|
|
1906
2613
|
error: null,
|
|
1907
2614
|
depositBonusPercent: discountConfig?.depositBonusPercent ?? prev.depositBonusPercent,
|
|
@@ -1919,7 +2626,7 @@ function useAiCreditsAdapter({
|
|
|
1919
2626
|
);
|
|
1920
2627
|
}
|
|
1921
2628
|
},
|
|
1922
|
-
[state, backendClient, chainClient]
|
|
2629
|
+
[state, backendClient, chainClient, resolveBuyerList]
|
|
1923
2630
|
);
|
|
1924
2631
|
const handleVerifyGoodId = (0, import_react.useCallback)(async () => {
|
|
1925
2632
|
const currentState = state;
|
|
@@ -1990,7 +2697,7 @@ function useAiCreditsAdapter({
|
|
|
1990
2697
|
if (!currentState.buyerPrvKey) {
|
|
1991
2698
|
setState((prev) => ({
|
|
1992
2699
|
...prev,
|
|
1993
|
-
error: "Sign with your payer wallet in
|
|
2700
|
+
error: "Sign with your payer wallet in Signer Key below to generate the buyer private key before closing a channel"
|
|
1994
2701
|
}));
|
|
1995
2702
|
return;
|
|
1996
2703
|
}
|
|
@@ -2027,7 +2734,7 @@ function useAiCreditsAdapter({
|
|
|
2027
2734
|
if (!currentState.buyerPrvKey) {
|
|
2028
2735
|
setState((prev) => ({
|
|
2029
2736
|
...prev,
|
|
2030
|
-
error: "Sign with your payer wallet in
|
|
2737
|
+
error: "Sign with your payer wallet in Signer Key below to generate the buyer private key before withdrawing funds"
|
|
2031
2738
|
}));
|
|
2032
2739
|
return;
|
|
2033
2740
|
}
|
|
@@ -2093,22 +2800,76 @@ function useAiCreditsAdapter({
|
|
|
2093
2800
|
await handleRefresh();
|
|
2094
2801
|
}, [configurationError, handleRefresh]);
|
|
2095
2802
|
const handleSetActiveTab = (0, import_react.useCallback)((tab) => {
|
|
2096
|
-
|
|
2803
|
+
setState((prev) => {
|
|
2804
|
+
if (needsWalletConnection(prev)) {
|
|
2805
|
+
if (tab === "setup") {
|
|
2806
|
+
return mergeStatePreservingNonBuyTab(prev, { activeTab: "setup", error: null });
|
|
2807
|
+
}
|
|
2808
|
+
return prev;
|
|
2809
|
+
}
|
|
2810
|
+
if (tab === "buy") {
|
|
2811
|
+
return withDerivedStatus(prev, { activeTab: "buy", status: "purchase_setup", error: null }, true);
|
|
2812
|
+
}
|
|
2813
|
+
return mergeStatePreservingNonBuyTab(prev, { activeTab: tab, error: null });
|
|
2814
|
+
});
|
|
2815
|
+
}, []);
|
|
2816
|
+
const handleStartPurchase = (0, import_react.useCallback)(() => {
|
|
2817
|
+
handleSetActiveTab("buy");
|
|
2818
|
+
}, [handleSetActiveTab]);
|
|
2819
|
+
(0, import_react.useEffect)(() => {
|
|
2820
|
+
if (typeof window === "undefined" || deepLinkParseDoneRef.current) return;
|
|
2821
|
+
deepLinkParseDoneRef.current = true;
|
|
2822
|
+
const parsed = resolveDeepLinkParams(window.location.search);
|
|
2823
|
+
if (parsed.status === "absent") return;
|
|
2824
|
+
if (parsed.status === "partial") {
|
|
2825
|
+
const missing = parsed.present === "buyerAddress" ? "operatorSignature" : "buyerAddress";
|
|
2826
|
+
setState(
|
|
2827
|
+
(prev) => withDerivedStatus(
|
|
2828
|
+
prev,
|
|
2829
|
+
{
|
|
2830
|
+
error: deepLinkManualFallbackMessage(`Deep link is missing ${missing}.`),
|
|
2831
|
+
activeTab: "buy",
|
|
2832
|
+
status: "purchase_setup"
|
|
2833
|
+
},
|
|
2834
|
+
false
|
|
2835
|
+
)
|
|
2836
|
+
);
|
|
2837
|
+
return;
|
|
2838
|
+
}
|
|
2839
|
+
if (parsed.status === "invalid") {
|
|
2097
2840
|
setState(
|
|
2098
|
-
(prev) => withDerivedStatus(
|
|
2841
|
+
(prev) => withDerivedStatus(
|
|
2842
|
+
prev,
|
|
2843
|
+
{
|
|
2844
|
+
error: deepLinkManualFallbackMessage(`${parsed.reason}.`),
|
|
2845
|
+
activeTab: "buy",
|
|
2846
|
+
status: "purchase_setup"
|
|
2847
|
+
},
|
|
2848
|
+
false
|
|
2849
|
+
)
|
|
2099
2850
|
);
|
|
2100
2851
|
return;
|
|
2101
2852
|
}
|
|
2102
|
-
|
|
2853
|
+
pendingDeepLinkRef.current = parsed.value;
|
|
2103
2854
|
}, []);
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2855
|
+
(0, import_react.useEffect)(() => {
|
|
2856
|
+
const pending = pendingDeepLinkRef.current;
|
|
2857
|
+
if (!address || !pending || deepLinkApplyInFlightRef.current) return;
|
|
2858
|
+
deepLinkApplyInFlightRef.current = true;
|
|
2859
|
+
void handleApplyDeepLinkBuyer(pending.buyerAddress, pending.operatorSignature).finally(() => {
|
|
2860
|
+
deepLinkApplyInFlightRef.current = false;
|
|
2861
|
+
pendingDeepLinkRef.current = null;
|
|
2862
|
+
});
|
|
2863
|
+
}, [address, handleApplyDeepLinkBuyer]);
|
|
2107
2864
|
const actions = (0, import_react.useMemo)(
|
|
2108
2865
|
() => ({
|
|
2109
2866
|
connect: handleConnect,
|
|
2110
2867
|
switchChain: handleSwitchChain,
|
|
2111
2868
|
generateBuyerKey: handleGenerateBuyerKey,
|
|
2869
|
+
selectBuyer: handleSelectBuyer,
|
|
2870
|
+
discoverBuyers: handleDiscoverBuyers,
|
|
2871
|
+
importBuyerFromPrivateKey: handleImportBuyerFromPrivateKey,
|
|
2872
|
+
applyDeepLinkBuyer: handleApplyDeepLinkBuyer,
|
|
2112
2873
|
signOperatorConsent: handleSignOperatorConsent,
|
|
2113
2874
|
syncOperatorConsentFromChain: handleSyncOperatorConsentFromChain,
|
|
2114
2875
|
buildQuote: handleBuildQuote,
|
|
@@ -2125,6 +2886,10 @@ function useAiCreditsAdapter({
|
|
|
2125
2886
|
handleConnect,
|
|
2126
2887
|
handleSwitchChain,
|
|
2127
2888
|
handleGenerateBuyerKey,
|
|
2889
|
+
handleSelectBuyer,
|
|
2890
|
+
handleDiscoverBuyers,
|
|
2891
|
+
handleImportBuyerFromPrivateKey,
|
|
2892
|
+
handleApplyDeepLinkBuyer,
|
|
2128
2893
|
handleSignOperatorConsent,
|
|
2129
2894
|
handleSyncOperatorConsentFromChain,
|
|
2130
2895
|
handleBuildQuote,
|
|
@@ -2140,7 +2905,7 @@ function useAiCreditsAdapter({
|
|
|
2140
2905
|
);
|
|
2141
2906
|
return { state, actions };
|
|
2142
2907
|
}
|
|
2143
|
-
var import_react, import_core, import_viem8, import_accounts4, CELO_CHAIN_ID2, MIN_DEPOSIT_AMOUNT, CELO_GD_ANTSEED_VAULT_FALLBACK, G_TOKEN_ABI, CELO_CHAIN4, INITIAL_STATE, WALLET_LOADING_STATE;
|
|
2908
|
+
var import_react, import_core, import_viem8, import_accounts4, CELO_CHAIN_ID2, MIN_DEPOSIT_AMOUNT, CELO_GD_ANTSEED_VAULT_FALLBACK, G_TOKEN_ABI, CELO_CHAIN4, INITIAL_STATE, WALLET_LOADING_STATE, BUYER_HISTORY_LOOKUP_LIMIT;
|
|
2144
2909
|
var init_adapter = __esm({
|
|
2145
2910
|
"src/adapter.ts"() {
|
|
2146
2911
|
"use strict";
|
|
@@ -2153,6 +2918,7 @@ var init_adapter = __esm({
|
|
|
2153
2918
|
init_backendClient();
|
|
2154
2919
|
init_chainClient();
|
|
2155
2920
|
init_operatorConsent();
|
|
2921
|
+
init_deepLinkParams();
|
|
2156
2922
|
init_payerSession();
|
|
2157
2923
|
init_celoPayment();
|
|
2158
2924
|
init_goodIdVerification();
|
|
@@ -2185,8 +2951,11 @@ var init_adapter = __esm({
|
|
|
2185
2951
|
isGoodIdVerified: false,
|
|
2186
2952
|
buyerPubKey: null,
|
|
2187
2953
|
buyerPrvKey: null,
|
|
2954
|
+
operatorSignature: null,
|
|
2188
2955
|
operatorConsented: false,
|
|
2956
|
+
operatorConsentPending: false,
|
|
2189
2957
|
operatorAddress: null,
|
|
2958
|
+
currentOperator: null,
|
|
2190
2959
|
minDepositUsd: null,
|
|
2191
2960
|
minStreamUsd: null,
|
|
2192
2961
|
totalGdDepositedG: null,
|
|
@@ -2195,7 +2964,9 @@ var init_adapter = __esm({
|
|
|
2195
2964
|
depositBonusPercent: DEFAULT_DISCOUNT_CONFIG.depositBonusPercent,
|
|
2196
2965
|
streamBonusPercent: DEFAULT_DISCOUNT_CONFIG.streamBonusPercent,
|
|
2197
2966
|
error: null,
|
|
2198
|
-
activeTab: "
|
|
2967
|
+
activeTab: "setup",
|
|
2968
|
+
buyers: [],
|
|
2969
|
+
derivedBuyerAddress: null
|
|
2199
2970
|
};
|
|
2200
2971
|
WALLET_LOADING_STATE = {
|
|
2201
2972
|
gBalance: null,
|
|
@@ -2207,8 +2978,10 @@ var init_adapter = __esm({
|
|
|
2207
2978
|
totalGdDepositedG: null,
|
|
2208
2979
|
monthlyStreamG: null,
|
|
2209
2980
|
withdrawableUsd: null,
|
|
2210
|
-
operatorAddress: null
|
|
2981
|
+
operatorAddress: null,
|
|
2982
|
+
currentOperator: null
|
|
2211
2983
|
};
|
|
2984
|
+
BUYER_HISTORY_LOOKUP_LIMIT = 100;
|
|
2212
2985
|
}
|
|
2213
2986
|
});
|
|
2214
2987
|
|
|
@@ -2242,11 +3015,23 @@ function toIsoEndOfDay(dateValue) {
|
|
|
2242
3015
|
if (Number.isNaN(parsed)) return void 0;
|
|
2243
3016
|
return new Date(parsed).toISOString();
|
|
2244
3017
|
}
|
|
3018
|
+
function matchesBuyerFilter(entry, filter) {
|
|
3019
|
+
if (filter === BUYER_FILTER_ALL) return true;
|
|
3020
|
+
return entry.buyerAddress?.toLowerCase() === filter.toLowerCase();
|
|
3021
|
+
}
|
|
2245
3022
|
function useAiCreditsHistory(options) {
|
|
2246
|
-
const {
|
|
3023
|
+
const {
|
|
3024
|
+
address,
|
|
3025
|
+
backendUrl,
|
|
3026
|
+
defaultBuyerFilter = BUYER_FILTER_ALL,
|
|
3027
|
+
environment = "production",
|
|
3028
|
+
backendClient,
|
|
3029
|
+
onBuyersDiscovered
|
|
3030
|
+
} = options;
|
|
2247
3031
|
const defaultRange = (0, import_react2.useMemo)(() => getLast90DaysRange(), []);
|
|
2248
3032
|
const [selectedSources, setSelectedSources] = (0, import_react2.useState)(createDefaultSelectedSources);
|
|
2249
3033
|
const [statusFilter, setStatusFilter] = (0, import_react2.useState)("all");
|
|
3034
|
+
const [buyerAddressFilter, setBuyerAddressFilter] = (0, import_react2.useState)(defaultBuyerFilter);
|
|
2250
3035
|
const [fromDate, setFromDate] = (0, import_react2.useState)(defaultRange.from);
|
|
2251
3036
|
const [toDate, setToDate] = (0, import_react2.useState)(defaultRange.to);
|
|
2252
3037
|
const [entries, setEntries] = (0, import_react2.useState)([]);
|
|
@@ -2255,6 +3040,9 @@ function useAiCreditsHistory(options) {
|
|
|
2255
3040
|
const [loading, setLoading] = (0, import_react2.useState)(false);
|
|
2256
3041
|
const [loadingMore, setLoadingMore] = (0, import_react2.useState)(false);
|
|
2257
3042
|
const [error, setError] = (0, import_react2.useState)(null);
|
|
3043
|
+
(0, import_react2.useEffect)(() => {
|
|
3044
|
+
setBuyerAddressFilter(defaultBuyerFilter);
|
|
3045
|
+
}, [defaultBuyerFilter]);
|
|
2258
3046
|
const activeSources = (0, import_react2.useMemo)(
|
|
2259
3047
|
() => HISTORY_SOURCE_OPTIONS.map((option) => option.id).filter((id) => selectedSources[id]),
|
|
2260
3048
|
[selectedSources]
|
|
@@ -2262,12 +3050,12 @@ function useAiCreditsHistory(options) {
|
|
|
2262
3050
|
const loadHistory = (0, import_react2.useCallback)(
|
|
2263
3051
|
async (nextOffset, append) => {
|
|
2264
3052
|
if (!address) {
|
|
2265
|
-
setEntries([]);
|
|
2266
|
-
setOffset(0);
|
|
2267
|
-
setHasMore(false);
|
|
2268
|
-
setError(null);
|
|
2269
|
-
setLoading(false);
|
|
2270
|
-
setLoadingMore(false);
|
|
3053
|
+
setEntries((prev) => prev.length === 0 ? prev : []);
|
|
3054
|
+
setOffset((prev) => prev === 0 ? prev : 0);
|
|
3055
|
+
setHasMore((prev) => prev ? false : prev);
|
|
3056
|
+
setError((prev) => prev === null ? prev : null);
|
|
3057
|
+
setLoading((prev) => prev ? false : prev);
|
|
3058
|
+
setLoadingMore((prev) => prev ? false : prev);
|
|
2271
3059
|
return;
|
|
2272
3060
|
}
|
|
2273
3061
|
if (activeSources.length === 0) {
|
|
@@ -2285,19 +3073,38 @@ function useAiCreditsHistory(options) {
|
|
|
2285
3073
|
const client = backendClient ?? createBackendClient(backendUrl);
|
|
2286
3074
|
const apiSource = activeSources.length === 1 ? activeSources[0] : void 0;
|
|
2287
3075
|
const fundingStatus = statusFilter === "all" ? void 0 : statusFilter;
|
|
3076
|
+
const filterByBuyer = buyerAddressFilter !== BUYER_FILTER_ALL;
|
|
2288
3077
|
try {
|
|
2289
|
-
const
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
3078
|
+
const collected = [];
|
|
3079
|
+
let cursor = nextOffset;
|
|
3080
|
+
let apiHasMore = true;
|
|
3081
|
+
let pages = 0;
|
|
3082
|
+
while (pages < BUYER_FILTER_FILL_MAX_PAGES && collected.length < HISTORY_PAGE_SIZE && apiHasMore) {
|
|
3083
|
+
const response = await client.getCreditHistory(address, {
|
|
3084
|
+
limit: HISTORY_PAGE_SIZE,
|
|
3085
|
+
offset: cursor,
|
|
3086
|
+
source: apiSource,
|
|
3087
|
+
fundingStatus,
|
|
3088
|
+
from: toIsoStartOfDay(fromDate),
|
|
3089
|
+
to: toIsoEndOfDay(toDate)
|
|
3090
|
+
});
|
|
3091
|
+
const sourceFiltered = activeSources.length === 1 ? response.items : response.items.filter((entry) => selectedSources[entry.source]);
|
|
3092
|
+
const discoveredBuyers = sourceFiltered.map((entry) => entry.buyerAddress).filter((value) => Boolean(value));
|
|
3093
|
+
if (discoveredBuyers.length > 0) {
|
|
3094
|
+
onBuyersDiscovered?.(discoveredBuyers);
|
|
3095
|
+
}
|
|
3096
|
+
const buyerFiltered = sourceFiltered.filter(
|
|
3097
|
+
(entry) => matchesBuyerFilter(entry, buyerAddressFilter)
|
|
3098
|
+
);
|
|
3099
|
+
collected.push(...buyerFiltered);
|
|
3100
|
+
apiHasMore = response.hasMore;
|
|
3101
|
+
cursor = response.offset + response.limit;
|
|
3102
|
+
pages += 1;
|
|
3103
|
+
if (!filterByBuyer) break;
|
|
3104
|
+
}
|
|
3105
|
+
setEntries((prev) => append ? [...prev, ...collected] : collected);
|
|
3106
|
+
setOffset(cursor);
|
|
3107
|
+
setHasMore(apiHasMore);
|
|
2301
3108
|
} catch (err) {
|
|
2302
3109
|
if (!append) setEntries([]);
|
|
2303
3110
|
setHasMore(false);
|
|
@@ -2314,9 +3121,11 @@ function useAiCreditsHistory(options) {
|
|
|
2314
3121
|
backendClient,
|
|
2315
3122
|
activeSources,
|
|
2316
3123
|
statusFilter,
|
|
3124
|
+
buyerAddressFilter,
|
|
2317
3125
|
fromDate,
|
|
2318
3126
|
toDate,
|
|
2319
|
-
selectedSources
|
|
3127
|
+
selectedSources,
|
|
3128
|
+
onBuyersDiscovered
|
|
2320
3129
|
]
|
|
2321
3130
|
);
|
|
2322
3131
|
(0, import_react2.useEffect)(() => {
|
|
@@ -2334,12 +3143,13 @@ function useAiCreditsHistory(options) {
|
|
|
2334
3143
|
await loadHistory(0, false);
|
|
2335
3144
|
}, [loadHistory]);
|
|
2336
3145
|
const loadMore = (0, import_react2.useCallback)(async () => {
|
|
2337
|
-
await loadHistory(offset
|
|
3146
|
+
await loadHistory(offset, true);
|
|
2338
3147
|
}, [loadHistory, offset]);
|
|
2339
3148
|
return {
|
|
2340
3149
|
state: {
|
|
2341
3150
|
selectedSources,
|
|
2342
3151
|
statusFilter,
|
|
3152
|
+
buyerAddressFilter,
|
|
2343
3153
|
fromDate,
|
|
2344
3154
|
toDate,
|
|
2345
3155
|
entries,
|
|
@@ -2353,6 +3163,7 @@ function useAiCreditsHistory(options) {
|
|
|
2353
3163
|
actions: {
|
|
2354
3164
|
setSourceChecked,
|
|
2355
3165
|
setStatusFilter,
|
|
3166
|
+
setBuyerAddressFilter,
|
|
2356
3167
|
setFromDate,
|
|
2357
3168
|
setToDate,
|
|
2358
3169
|
reload,
|
|
@@ -2360,7 +3171,7 @@ function useAiCreditsHistory(options) {
|
|
|
2360
3171
|
}
|
|
2361
3172
|
};
|
|
2362
3173
|
}
|
|
2363
|
-
var import_react2, HISTORY_PAGE_SIZE, HISTORY_LOOKBACK_DAYS, HISTORY_SOURCE_OPTIONS;
|
|
3174
|
+
var import_react2, HISTORY_PAGE_SIZE, HISTORY_LOOKBACK_DAYS, BUYER_FILTER_FILL_MAX_PAGES, BUYER_FILTER_ALL, HISTORY_SOURCE_OPTIONS;
|
|
2364
3175
|
var init_useAiCreditsHistory = __esm({
|
|
2365
3176
|
"src/useAiCreditsHistory.ts"() {
|
|
2366
3177
|
"use strict";
|
|
@@ -2368,6 +3179,8 @@ var init_useAiCreditsHistory = __esm({
|
|
|
2368
3179
|
init_backendClient();
|
|
2369
3180
|
HISTORY_PAGE_SIZE = 10;
|
|
2370
3181
|
HISTORY_LOOKBACK_DAYS = 90;
|
|
3182
|
+
BUYER_FILTER_FILL_MAX_PAGES = 8;
|
|
3183
|
+
BUYER_FILTER_ALL = "all";
|
|
2371
3184
|
HISTORY_SOURCE_OPTIONS = [
|
|
2372
3185
|
{ id: "deposit", label: "Deposit", defaultChecked: true },
|
|
2373
3186
|
{ id: "streamUpdate", label: "Stream update", defaultChecked: true },
|
|
@@ -2487,8 +3300,8 @@ function BuyerKeyPanel({
|
|
|
2487
3300
|
}
|
|
2488
3301
|
const Shell = embedded ? import_ui4.YStack : import_ui4.Card;
|
|
2489
3302
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Shell, { gap: "$3", children: [
|
|
2490
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui4.Heading, { level: 5, children: "
|
|
2491
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui4.Text, { children: "Sign a message with your payer wallet to derive a
|
|
3303
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui4.Heading, { level: 5, children: "Signer Key" }),
|
|
3304
|
+
/* @__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." }),
|
|
2492
3305
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui4.YStack, { gap: "$3", children: [
|
|
2493
3306
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2494
3307
|
import_ui4.Button,
|
|
@@ -2524,6 +3337,7 @@ function BuyerKeyPanel({
|
|
|
2524
3337
|
}
|
|
2525
3338
|
),
|
|
2526
3339
|
buyerPrvKey && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
3340
|
+
/* @__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." }) }),
|
|
2527
3341
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui4.XStack, { justifyContent: "space-between", alignItems: "center", children: [
|
|
2528
3342
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui4.Text, { variant: "label", secondary: true, children: "Private Key \u2014 save this securely" }),
|
|
2529
3343
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -2568,7 +3382,8 @@ function BuyerKeyPanel({
|
|
|
2568
3382
|
)
|
|
2569
3383
|
]
|
|
2570
3384
|
}
|
|
2571
|
-
)
|
|
3385
|
+
),
|
|
3386
|
+
/* @__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." })
|
|
2572
3387
|
] }),
|
|
2573
3388
|
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" }) }),
|
|
2574
3389
|
buyerPubKeySaved && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui4.XStack, { gap: "$2", alignItems: "center", children: [
|
|
@@ -2596,16 +3411,18 @@ var init_BuyerKeyPanel = __esm({
|
|
|
2596
3411
|
function OperatorConsentStep({
|
|
2597
3412
|
buyerPubKey,
|
|
2598
3413
|
buyerPrvKey,
|
|
3414
|
+
operatorSignature = null,
|
|
2599
3415
|
operatorConsented,
|
|
3416
|
+
operatorConsentPending = false,
|
|
2600
3417
|
onSign,
|
|
2601
3418
|
embedded = false
|
|
2602
3419
|
}) {
|
|
2603
|
-
const
|
|
2604
|
-
const
|
|
3420
|
+
const canSign = Boolean(buyerPubKey && (buyerPrvKey || operatorSignature));
|
|
3421
|
+
const isBusy = operatorConsentPending;
|
|
2605
3422
|
const Shell = embedded ? import_ui5.YStack : import_ui5.Card;
|
|
2606
3423
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Shell, { gap: "$3", ...!embedded ? { backgroundColor: "$backgroundHover" } : {}, children: [
|
|
2607
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Heading, { level: 5, children: "Authorize
|
|
2608
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$2", lineHeight: "$3", children: "
|
|
3424
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Heading, { level: 5, children: "Authorize Wallet" }),
|
|
3425
|
+
/* @__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." }),
|
|
2609
3426
|
buyerPubKey && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.Text, { fontSize: "$2", lineHeight: "$2", children: [
|
|
2610
3427
|
"Buyer address:",
|
|
2611
3428
|
" ",
|
|
@@ -2613,32 +3430,28 @@ function OperatorConsentStep({
|
|
|
2613
3430
|
] }),
|
|
2614
3431
|
operatorConsented ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.XStack, { gap: "$2", alignItems: "center", children: [
|
|
2615
3432
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Icon, { name: "check", size: "sm", color: "success" }),
|
|
2616
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { color: "$success", children: "
|
|
3433
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { color: "$success", children: "Wallet authorized \u2014 ready to pay" })
|
|
2617
3434
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2618
3435
|
import_ui5.Button,
|
|
2619
3436
|
{
|
|
2620
3437
|
size: "sm",
|
|
2621
3438
|
...compactButtonProps,
|
|
2622
3439
|
onPress: () => {
|
|
2623
|
-
|
|
2624
|
-
void onSign().finally(() => {
|
|
2625
|
-
setIsSigning(false);
|
|
2626
|
-
});
|
|
3440
|
+
void onSign();
|
|
2627
3441
|
},
|
|
2628
|
-
disabled: !canSign ||
|
|
2629
|
-
children:
|
|
2630
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.ButtonText, { children: "
|
|
3442
|
+
disabled: !canSign || isBusy,
|
|
3443
|
+
children: isBusy ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.XStack, { gap: "$2", alignItems: "center", children: [
|
|
3444
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.ButtonText, { children: "Submitting\u2026" }),
|
|
2631
3445
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Spinner, { size: "sm" })
|
|
2632
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.ButtonText, { children: "
|
|
3446
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.ButtonText, { children: "Authorize Wallet" })
|
|
2633
3447
|
}
|
|
2634
3448
|
)
|
|
2635
3449
|
] });
|
|
2636
3450
|
}
|
|
2637
|
-
var
|
|
3451
|
+
var import_ui5, import_jsx_runtime3;
|
|
2638
3452
|
var init_OperatorConsentStep = __esm({
|
|
2639
3453
|
"src/components/buy/OperatorConsentStep.tsx"() {
|
|
2640
3454
|
"use strict";
|
|
2641
|
-
import_react5 = require("react");
|
|
2642
3455
|
import_ui5 = require("@goodwidget/ui");
|
|
2643
3456
|
init_styles();
|
|
2644
3457
|
import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -2647,7 +3460,7 @@ var init_OperatorConsentStep = __esm({
|
|
|
2647
3460
|
|
|
2648
3461
|
// src/components/shared/tooltips.tsx
|
|
2649
3462
|
function InfoTooltip({ message }) {
|
|
2650
|
-
const [open, setOpen] = (0,
|
|
3463
|
+
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
2651
3464
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2652
3465
|
import_ui6.XStack,
|
|
2653
3466
|
{
|
|
@@ -2692,7 +3505,7 @@ function HoverTooltip({
|
|
|
2692
3505
|
children,
|
|
2693
3506
|
fullWidth = false
|
|
2694
3507
|
}) {
|
|
2695
|
-
const [open, setOpen] = (0,
|
|
3508
|
+
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
2696
3509
|
if (!message) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children });
|
|
2697
3510
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2698
3511
|
import_ui6.XStack,
|
|
@@ -2711,11 +3524,11 @@ function HoverTooltip({
|
|
|
2711
3524
|
}
|
|
2712
3525
|
);
|
|
2713
3526
|
}
|
|
2714
|
-
var
|
|
3527
|
+
var import_react5, import_ui6, import_jsx_runtime4;
|
|
2715
3528
|
var init_tooltips = __esm({
|
|
2716
3529
|
"src/components/shared/tooltips.tsx"() {
|
|
2717
3530
|
"use strict";
|
|
2718
|
-
|
|
3531
|
+
import_react5 = require("react");
|
|
2719
3532
|
import_ui6 = require("@goodwidget/ui");
|
|
2720
3533
|
import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2721
3534
|
}
|
|
@@ -2782,17 +3595,17 @@ function AmountPicker({
|
|
|
2782
3595
|
onVerifyGoodId,
|
|
2783
3596
|
embedded = false
|
|
2784
3597
|
}) {
|
|
2785
|
-
const streamSeed = (0,
|
|
2786
|
-
const [depositAmount, setDepositAmount] = (0,
|
|
2787
|
-
const [streamAmount, setStreamAmount] = (0,
|
|
2788
|
-
const [quote, setQuote] = (0,
|
|
2789
|
-
const [quotePending, setQuotePending] = (0,
|
|
2790
|
-
const [isVerifyingGoodId, setIsVerifyingGoodId] = (0,
|
|
3598
|
+
const streamSeed = (0, import_react6.useMemo)(() => resolveInitialStreamAmount(monthlyStreamG), [monthlyStreamG]);
|
|
3599
|
+
const [depositAmount, setDepositAmount] = (0, import_react6.useState)(DEFAULT_DEPOSIT_AMOUNT);
|
|
3600
|
+
const [streamAmount, setStreamAmount] = (0, import_react6.useState)(streamSeed);
|
|
3601
|
+
const [quote, setQuote] = (0, import_react6.useState)(null);
|
|
3602
|
+
const [quotePending, setQuotePending] = (0, import_react6.useState)(false);
|
|
3603
|
+
const [isVerifyingGoodId, setIsVerifyingGoodId] = (0, import_react6.useState)(false);
|
|
2791
3604
|
const isStreamUpdateFlow = parseGAmount(streamSeed) > 0;
|
|
2792
|
-
(0,
|
|
3605
|
+
(0, import_react6.useEffect)(() => {
|
|
2793
3606
|
setStreamAmount(streamSeed);
|
|
2794
3607
|
}, [streamSeed]);
|
|
2795
|
-
(0,
|
|
3608
|
+
(0, import_react6.useEffect)(() => {
|
|
2796
3609
|
let cancelled = false;
|
|
2797
3610
|
setQuotePending(true);
|
|
2798
3611
|
void buildQuote(depositAmount, streamAmount).then((nextQuote) => {
|
|
@@ -2810,7 +3623,7 @@ function AmountPicker({
|
|
|
2810
3623
|
const streamG = parseGAmount(streamAmount);
|
|
2811
3624
|
const depositBonusLabel = isGoodIdVerified ? `+${depositBonusPercent}% bonus` : `Verify for +${depositBonusPercent}%`;
|
|
2812
3625
|
const streamBonusLabel = isGoodIdVerified ? `+${streamBonusPercent}% bonus` : `Verify for +${streamBonusPercent}%`;
|
|
2813
|
-
const paymentValidation = (0,
|
|
3626
|
+
const paymentValidation = (0, import_react6.useMemo)(
|
|
2814
3627
|
() => getPaymentAmountValidation({
|
|
2815
3628
|
depositAmount,
|
|
2816
3629
|
streamAmount,
|
|
@@ -2824,7 +3637,8 @@ function AmountPicker({
|
|
|
2824
3637
|
[depositAmount, streamAmount, monthlyStreamG, minDepositUsd, minStreamUsd, quote, gdUsdPerToken, gBalance]
|
|
2825
3638
|
);
|
|
2826
3639
|
const minsLoaded = minStreamUsd !== null;
|
|
2827
|
-
const
|
|
3640
|
+
const canRetryAfterFailure = status === "quote_ready" || status === "payment_failed";
|
|
3641
|
+
const canPay = canRetryAfterFailure && minsLoaded && paymentValidation.hasPaymentAction && paymentValidation.vaultMinimumsMet && !paymentValidation.overBalance && !quotePending && quote !== null;
|
|
2828
3642
|
const payDisabledMessage = getPayDisabledMessage({
|
|
2829
3643
|
canPay,
|
|
2830
3644
|
minsLoaded,
|
|
@@ -2966,11 +3780,11 @@ function AmountPicker({
|
|
|
2966
3780
|
) })
|
|
2967
3781
|
] });
|
|
2968
3782
|
}
|
|
2969
|
-
var
|
|
3783
|
+
var import_react6, import_ui7, import_jsx_runtime5, DEFAULT_DEPOSIT_AMOUNT, DEFAULT_STREAM_AMOUNT;
|
|
2970
3784
|
var init_AmountPicker = __esm({
|
|
2971
3785
|
"src/components/buy/AmountPicker.tsx"() {
|
|
2972
3786
|
"use strict";
|
|
2973
|
-
|
|
3787
|
+
import_react6 = require("react");
|
|
2974
3788
|
import_ui7 = require("@goodwidget/ui");
|
|
2975
3789
|
init_quoteMath();
|
|
2976
3790
|
init_vaultMinimums();
|
|
@@ -2983,133 +3797,21 @@ var init_AmountPicker = __esm({
|
|
|
2983
3797
|
}
|
|
2984
3798
|
});
|
|
2985
3799
|
|
|
2986
|
-
// src/components/buy/BuyCreditsFaq.tsx
|
|
2987
|
-
function FaqItem({
|
|
2988
|
-
question,
|
|
2989
|
-
answer,
|
|
2990
|
-
expanded,
|
|
2991
|
-
onToggle
|
|
2992
|
-
}) {
|
|
2993
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.YStack, { gap: "$1", children: [
|
|
2994
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
2995
|
-
import_ui8.XStack,
|
|
2996
|
-
{
|
|
2997
|
-
justifyContent: "space-between",
|
|
2998
|
-
alignItems: "center",
|
|
2999
|
-
gap: "$2",
|
|
3000
|
-
onPress: onToggle,
|
|
3001
|
-
cursor: "pointer",
|
|
3002
|
-
children: [
|
|
3003
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$2", fontWeight: "600", flex: 1, children: question }),
|
|
3004
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Icon, { name: expanded ? "chevron-up" : "chevron-down", size: "xs", color: "muted" })
|
|
3005
|
-
]
|
|
3006
|
-
}
|
|
3007
|
-
),
|
|
3008
|
-
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)) })
|
|
3009
|
-
] });
|
|
3010
|
-
}
|
|
3011
|
-
function BuyCreditsFaq() {
|
|
3012
|
-
const [expandedId, setExpandedId] = (0, import_react8.useState)(null);
|
|
3013
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.Card, { gap: "$3", children: [
|
|
3014
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Heading, { level: 6, children: "FAQ" }),
|
|
3015
|
-
/* @__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: [
|
|
3016
|
-
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Separator, {}),
|
|
3017
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3018
|
-
FaqItem,
|
|
3019
|
-
{
|
|
3020
|
-
question: item.question,
|
|
3021
|
-
answer: item.answer,
|
|
3022
|
-
expanded: expandedId === item.id,
|
|
3023
|
-
onToggle: () => {
|
|
3024
|
-
setExpandedId((current) => current === item.id ? null : item.id);
|
|
3025
|
-
}
|
|
3026
|
-
}
|
|
3027
|
-
)
|
|
3028
|
-
] }, item.id)) })
|
|
3029
|
-
] });
|
|
3030
|
-
}
|
|
3031
|
-
var import_react8, import_ui8, import_jsx_runtime6, FAQ_ITEMS;
|
|
3032
|
-
var init_BuyCreditsFaq = __esm({
|
|
3033
|
-
"src/components/buy/BuyCreditsFaq.tsx"() {
|
|
3034
|
-
"use strict";
|
|
3035
|
-
import_react8 = require("react");
|
|
3036
|
-
import_ui8 = require("@goodwidget/ui");
|
|
3037
|
-
import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3038
|
-
FAQ_ITEMS = [
|
|
3039
|
-
{
|
|
3040
|
-
id: "what-are-credits",
|
|
3041
|
-
question: "What are AI credits?",
|
|
3042
|
-
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."
|
|
3043
|
-
},
|
|
3044
|
-
{
|
|
3045
|
-
id: "how-to-buy",
|
|
3046
|
-
question: "How do I buy credits?",
|
|
3047
|
-
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)."
|
|
3048
|
-
},
|
|
3049
|
-
{
|
|
3050
|
-
id: "deposit-vs-stream",
|
|
3051
|
-
question: "What is a one-time deposit vs a monthly stream?",
|
|
3052
|
-
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."
|
|
3053
|
-
},
|
|
3054
|
-
{
|
|
3055
|
-
id: "minimums",
|
|
3056
|
-
question: "What are the minimum amounts?",
|
|
3057
|
-
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."
|
|
3058
|
-
},
|
|
3059
|
-
{
|
|
3060
|
-
id: "goodid-bonus",
|
|
3061
|
-
question: "How do GoodID bonuses work?",
|
|
3062
|
-
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."
|
|
3063
|
-
},
|
|
3064
|
-
{
|
|
3065
|
-
id: "buyer-key",
|
|
3066
|
-
question: "What is the buyer key?",
|
|
3067
|
-
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."
|
|
3068
|
-
},
|
|
3069
|
-
{
|
|
3070
|
-
id: "operator-consent",
|
|
3071
|
-
question: "Why do I authorize the Gooddollar operator?",
|
|
3072
|
-
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."
|
|
3073
|
-
},
|
|
3074
|
-
{
|
|
3075
|
-
id: "when-credits-arrive",
|
|
3076
|
-
question: "When do credits arrive?",
|
|
3077
|
-
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."
|
|
3078
|
-
},
|
|
3079
|
-
{
|
|
3080
|
-
id: "withdraw",
|
|
3081
|
-
question: "What funds can I withdraw?",
|
|
3082
|
-
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."
|
|
3083
|
-
},
|
|
3084
|
-
{
|
|
3085
|
-
id: "api-setup",
|
|
3086
|
-
question: "What is API setup?",
|
|
3087
|
-
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."
|
|
3088
|
-
},
|
|
3089
|
-
{
|
|
3090
|
-
id: "support",
|
|
3091
|
-
question: "Who do I contact for support?",
|
|
3092
|
-
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"
|
|
3093
|
-
}
|
|
3094
|
-
];
|
|
3095
|
-
}
|
|
3096
|
-
});
|
|
3097
|
-
|
|
3098
3800
|
// src/components/shared/constants.ts
|
|
3099
3801
|
var BUYER_KEY_REQUIRED_CLOSE_TOOLTIP, BUYER_KEY_REQUIRED_WITHDRAW_TOOLTIP, WITHDRAW_TOOLTIP;
|
|
3100
3802
|
var init_constants = __esm({
|
|
3101
3803
|
"src/components/shared/constants.ts"() {
|
|
3102
3804
|
"use strict";
|
|
3103
|
-
BUYER_KEY_REQUIRED_CLOSE_TOOLTIP = "Sign with your payer wallet in
|
|
3104
|
-
BUYER_KEY_REQUIRED_WITHDRAW_TOOLTIP = "Sign with your payer wallet in
|
|
3805
|
+
BUYER_KEY_REQUIRED_CLOSE_TOOLTIP = "Sign with your payer wallet in Signer Key below to generate the buyer private key before closing a channel.";
|
|
3806
|
+
BUYER_KEY_REQUIRED_WITHDRAW_TOOLTIP = "Sign with your payer wallet in Signer Key below to generate the buyer private key before withdrawing funds.";
|
|
3105
3807
|
WITHDRAW_TOOLTIP = "Withdraws principal to your payer wallet (not bonus). Requires the buyer private key from this session.";
|
|
3106
3808
|
}
|
|
3107
3809
|
});
|
|
3108
3810
|
|
|
3109
3811
|
// src/components/manage/CreditsManagementCard.tsx
|
|
3110
3812
|
function StatCell({ label, children }) {
|
|
3111
|
-
return /* @__PURE__ */ (0,
|
|
3112
|
-
|
|
3813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3814
|
+
import_ui8.YStack,
|
|
3113
3815
|
{
|
|
3114
3816
|
flex: 1,
|
|
3115
3817
|
minWidth: "45%",
|
|
@@ -3121,8 +3823,8 @@ function StatCell({ label, children }) {
|
|
|
3121
3823
|
minWidth: "28%"
|
|
3122
3824
|
},
|
|
3123
3825
|
children: [
|
|
3124
|
-
/* @__PURE__ */ (0,
|
|
3125
|
-
/* @__PURE__ */ (0,
|
|
3826
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$1", secondary: true, children: label }),
|
|
3827
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.YStack, { justifyContent: "center", children })
|
|
3126
3828
|
]
|
|
3127
3829
|
}
|
|
3128
3830
|
);
|
|
@@ -3131,7 +3833,7 @@ function StatValueText({
|
|
|
3131
3833
|
children,
|
|
3132
3834
|
color
|
|
3133
3835
|
}) {
|
|
3134
|
-
return /* @__PURE__ */ (0,
|
|
3836
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$2", fontWeight: "700", color, children });
|
|
3135
3837
|
}
|
|
3136
3838
|
function formatCompactAmount(amount) {
|
|
3137
3839
|
const value = Number.parseFloat(amount);
|
|
@@ -3150,16 +3852,16 @@ function formatExactGAmount(amount) {
|
|
|
3150
3852
|
}).format(value)} G$`;
|
|
3151
3853
|
}
|
|
3152
3854
|
function CompactGStatValue({ amount }) {
|
|
3153
|
-
const [open, setOpen] = (0,
|
|
3855
|
+
const [open, setOpen] = (0, import_react7.useState)(false);
|
|
3154
3856
|
const value = Number.parseFloat(amount);
|
|
3155
3857
|
const compact = formatCompactAmount(amount);
|
|
3156
3858
|
const exact = formatExactGAmount(amount);
|
|
3157
3859
|
const needsExact = Number.isFinite(value) && value >= 1e3;
|
|
3158
3860
|
if (!needsExact) {
|
|
3159
|
-
return /* @__PURE__ */ (0,
|
|
3861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StatValueText, { children: compact });
|
|
3160
3862
|
}
|
|
3161
|
-
return /* @__PURE__ */ (0,
|
|
3162
|
-
|
|
3863
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3864
|
+
import_ui8.XStack,
|
|
3163
3865
|
{
|
|
3164
3866
|
position: "relative",
|
|
3165
3867
|
cursor: "help",
|
|
@@ -3172,9 +3874,9 @@ function CompactGStatValue({ amount }) {
|
|
|
3172
3874
|
onBlur: () => setOpen(false),
|
|
3173
3875
|
onPress: () => setOpen((prev) => !prev),
|
|
3174
3876
|
children: [
|
|
3175
|
-
/* @__PURE__ */ (0,
|
|
3176
|
-
open && /* @__PURE__ */ (0,
|
|
3177
|
-
|
|
3877
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StatValueText, { children: compact }),
|
|
3878
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3879
|
+
import_ui8.YStack,
|
|
3178
3880
|
{
|
|
3179
3881
|
position: "absolute",
|
|
3180
3882
|
bottom: "100%",
|
|
@@ -3187,7 +3889,7 @@ function CompactGStatValue({ amount }) {
|
|
|
3187
3889
|
padding: "$2",
|
|
3188
3890
|
zIndex: 100,
|
|
3189
3891
|
pointerEvents: "none",
|
|
3190
|
-
children: /* @__PURE__ */ (0,
|
|
3892
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$1", lineHeight: "$2", color: "$color", whiteSpace: "nowrap", children: exact })
|
|
3191
3893
|
}
|
|
3192
3894
|
)
|
|
3193
3895
|
]
|
|
@@ -3203,10 +3905,10 @@ function formatUsdAmount(usdMicro) {
|
|
|
3203
3905
|
}).format(value);
|
|
3204
3906
|
}
|
|
3205
3907
|
function CreditsManagementCard({ state, actions }) {
|
|
3206
|
-
const [isClosing, setIsClosing] = (0,
|
|
3207
|
-
const [isWithdrawing, setIsWithdrawing] = (0,
|
|
3208
|
-
const [channelId, setChannelId] = (0,
|
|
3209
|
-
const [withdrawAmount, setWithdrawAmount] = (0,
|
|
3908
|
+
const [isClosing, setIsClosing] = (0, import_react7.useState)(false);
|
|
3909
|
+
const [isWithdrawing, setIsWithdrawing] = (0, import_react7.useState)(false);
|
|
3910
|
+
const [channelId, setChannelId] = (0, import_react7.useState)("");
|
|
3911
|
+
const [withdrawAmount, setWithdrawAmount] = (0, import_react7.useState)("");
|
|
3210
3912
|
const {
|
|
3211
3913
|
totalCreditUsd,
|
|
3212
3914
|
totalGdDepositedG,
|
|
@@ -3216,7 +3918,7 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
3216
3918
|
withdrawableUsd,
|
|
3217
3919
|
buyerPrvKey
|
|
3218
3920
|
} = state;
|
|
3219
|
-
const monthlyStreamUsdDisplay = (0,
|
|
3921
|
+
const monthlyStreamUsdDisplay = (0, import_react7.useMemo)(() => {
|
|
3220
3922
|
if (!monthlyStreamG || !gdUsdPerToken) return null;
|
|
3221
3923
|
if (Number.parseFloat(monthlyStreamG) <= 0) return null;
|
|
3222
3924
|
const quote = { depositAmountG: "0", streamAmountG: monthlyStreamG };
|
|
@@ -3232,34 +3934,34 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
3232
3934
|
const hasWithdrawableBalance = withdrawableUsd !== null && BigInt(withdrawableUsd) > 0n;
|
|
3233
3935
|
const canClose = Boolean(buyerPrvKey) && Boolean(channelId.trim()) && !isClosing;
|
|
3234
3936
|
const canWithdraw = Boolean(buyerPrvKey) && hasWithdrawableBalance && Boolean(withdrawAmount.trim()) && !isWithdrawing;
|
|
3235
|
-
return /* @__PURE__ */ (0,
|
|
3236
|
-
/* @__PURE__ */ (0,
|
|
3237
|
-
/* @__PURE__ */ (0,
|
|
3238
|
-
/* @__PURE__ */ (0,
|
|
3239
|
-
/* @__PURE__ */ (0,
|
|
3240
|
-
totalCreditDisplay !== null ? /* @__PURE__ */ (0,
|
|
3937
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.Card, { gap: "$3", children: [
|
|
3938
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Heading, { level: 6, children: "AI Credits" }),
|
|
3939
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.XStack, { gap: "$4", width: "100%", alignItems: "flex-start", flexWrap: "wrap", children: [
|
|
3940
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.YStack, { gap: "$2", flex: 1, minWidth: 0, children: [
|
|
3941
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$1", secondary: true, children: "Total Credit (US$)" }),
|
|
3942
|
+
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" })
|
|
3241
3943
|
] }),
|
|
3242
|
-
/* @__PURE__ */ (0,
|
|
3243
|
-
/* @__PURE__ */ (0,
|
|
3244
|
-
monthlyStreamUsdDisplay ? /* @__PURE__ */ (0,
|
|
3944
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.YStack, { gap: "$2", flex: 1, minWidth: 0, children: [
|
|
3945
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$1", secondary: true, children: "Est. Monthly Credit (US$)" }),
|
|
3946
|
+
monthlyStreamUsdDisplay ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.Heading, { level: 5, color: "$primary", children: [
|
|
3245
3947
|
"~",
|
|
3246
3948
|
monthlyStreamUsdDisplay
|
|
3247
|
-
] }) : /* @__PURE__ */ (0,
|
|
3949
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Heading, { level: 5, children: "\u2014" })
|
|
3248
3950
|
] })
|
|
3249
3951
|
] }),
|
|
3250
|
-
/* @__PURE__ */ (0,
|
|
3251
|
-
/* @__PURE__ */ (0,
|
|
3252
|
-
/* @__PURE__ */ (0,
|
|
3253
|
-
/* @__PURE__ */ (0,
|
|
3952
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.XStack, { gap: "$2", width: "100%", flexWrap: "wrap", alignItems: "stretch", children: [
|
|
3953
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StatCell, { label: "Total Deposited (G$)", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CompactGStatValue, { amount: totalGdDepositedG ?? "0.00" }) }),
|
|
3954
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StatCell, { label: "Monthly Stream (G$)", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CompactGStatValue, { amount: monthlyStreamG ?? "0.00" }) }),
|
|
3955
|
+
/* @__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" }) })
|
|
3254
3956
|
] }),
|
|
3255
|
-
/* @__PURE__ */ (0,
|
|
3256
|
-
/* @__PURE__ */ (0,
|
|
3257
|
-
/* @__PURE__ */ (0,
|
|
3258
|
-
/* @__PURE__ */ (0,
|
|
3957
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.YStack, { gap: "$1", children: [
|
|
3958
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.XStack, { gap: "$1", alignItems: "center", children: [
|
|
3959
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$1", variant: "label", children: "Withdraw" }),
|
|
3960
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(InfoTooltip, { message: WITHDRAW_TOOLTIP })
|
|
3259
3961
|
] }),
|
|
3260
|
-
/* @__PURE__ */ (0,
|
|
3261
|
-
/* @__PURE__ */ (0,
|
|
3262
|
-
|
|
3962
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.XStack, { gap: "$2", alignItems: "center", children: [
|
|
3963
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.YStack, { flex: 1, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3964
|
+
import_ui8.Input,
|
|
3263
3965
|
{
|
|
3264
3966
|
size: "sm",
|
|
3265
3967
|
value: withdrawAmount,
|
|
@@ -3267,8 +3969,8 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
3267
3969
|
placeholder: hasWithdrawableBalance && withdrawableDisplay ? `Max ${withdrawableDisplay} US$` : "Amount in US$"
|
|
3268
3970
|
}
|
|
3269
3971
|
) }),
|
|
3270
|
-
/* @__PURE__ */ (0,
|
|
3271
|
-
|
|
3972
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HoverTooltip, { message: !buyerPrvKey ? BUYER_KEY_REQUIRED_WITHDRAW_TOOLTIP : null, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3973
|
+
import_ui8.Button,
|
|
3272
3974
|
{
|
|
3273
3975
|
variant: "outline",
|
|
3274
3976
|
size: "sm",
|
|
@@ -3283,16 +3985,16 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
3283
3985
|
setWithdrawAmount("");
|
|
3284
3986
|
});
|
|
3285
3987
|
},
|
|
3286
|
-
children: /* @__PURE__ */ (0,
|
|
3988
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.ButtonText, { children: isWithdrawing ? "Withdrawing\u2026" : "Withdraw" })
|
|
3287
3989
|
}
|
|
3288
3990
|
) })
|
|
3289
3991
|
] })
|
|
3290
3992
|
] }),
|
|
3291
|
-
/* @__PURE__ */ (0,
|
|
3292
|
-
/* @__PURE__ */ (0,
|
|
3293
|
-
/* @__PURE__ */ (0,
|
|
3294
|
-
/* @__PURE__ */ (0,
|
|
3295
|
-
|
|
3993
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.YStack, { gap: "$1", children: [
|
|
3994
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.Text, { fontSize: "$1", variant: "label", children: "Close Channel" }),
|
|
3995
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui8.XStack, { gap: "$2", alignItems: "center", children: [
|
|
3996
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.YStack, { flex: 1, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3997
|
+
import_ui8.Input,
|
|
3296
3998
|
{
|
|
3297
3999
|
size: "sm",
|
|
3298
4000
|
value: channelId,
|
|
@@ -3300,8 +4002,8 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
3300
4002
|
placeholder: "0x\u2026 (64 hex chars)"
|
|
3301
4003
|
}
|
|
3302
4004
|
) }),
|
|
3303
|
-
/* @__PURE__ */ (0,
|
|
3304
|
-
|
|
4005
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HoverTooltip, { message: !buyerPrvKey ? BUYER_KEY_REQUIRED_CLOSE_TOOLTIP : null, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
4006
|
+
import_ui8.Button,
|
|
3305
4007
|
{
|
|
3306
4008
|
variant: "outline",
|
|
3307
4009
|
size: "sm",
|
|
@@ -3316,170 +4018,430 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
3316
4018
|
setChannelId("");
|
|
3317
4019
|
});
|
|
3318
4020
|
},
|
|
3319
|
-
children: /* @__PURE__ */ (0,
|
|
4021
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui8.ButtonText, { children: isClosing ? "Closing\u2026" : "Close" })
|
|
3320
4022
|
}
|
|
3321
4023
|
) })
|
|
3322
4024
|
] })
|
|
3323
4025
|
] })
|
|
3324
4026
|
] });
|
|
3325
4027
|
}
|
|
3326
|
-
var
|
|
4028
|
+
var import_react7, import_ui8, import_jsx_runtime6;
|
|
3327
4029
|
var init_CreditsManagementCard = __esm({
|
|
3328
4030
|
"src/components/manage/CreditsManagementCard.tsx"() {
|
|
3329
4031
|
"use strict";
|
|
3330
|
-
|
|
3331
|
-
|
|
4032
|
+
import_react7 = require("react");
|
|
4033
|
+
import_ui8 = require("@goodwidget/ui");
|
|
3332
4034
|
init_quoteMath();
|
|
3333
4035
|
init_constants();
|
|
3334
4036
|
init_tooltips();
|
|
3335
4037
|
init_styles();
|
|
3336
|
-
|
|
4038
|
+
import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3337
4039
|
}
|
|
3338
4040
|
});
|
|
3339
4041
|
|
|
3340
|
-
// src/components/
|
|
3341
|
-
function
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
4042
|
+
// src/components/setup/SignerKeyPanel.tsx
|
|
4043
|
+
function SignerKeyPanel({
|
|
4044
|
+
state,
|
|
4045
|
+
actions,
|
|
4046
|
+
onProceed,
|
|
4047
|
+
showHeading = true,
|
|
4048
|
+
proceedLabel: proceedLabelOverride,
|
|
4049
|
+
compact = false
|
|
4050
|
+
}) {
|
|
4051
|
+
const [choice, setChoice] = (0, import_react8.useState)(null);
|
|
4052
|
+
const [privateKey, setPrivateKey] = (0, import_react8.useState)("");
|
|
4053
|
+
const [isImporting, setIsImporting] = (0, import_react8.useState)(false);
|
|
4054
|
+
const [keyConfirmed, setKeyConfirmed] = (0, import_react8.useState)(false);
|
|
4055
|
+
const [importedAddress, setImportedAddress] = (0, import_react8.useState)(null);
|
|
4056
|
+
const leaveChoice = () => {
|
|
4057
|
+
setChoice(null);
|
|
4058
|
+
setImportedAddress(null);
|
|
4059
|
+
};
|
|
4060
|
+
const currentOperator = state.currentOperator?.toLowerCase();
|
|
4061
|
+
const expectedOperator = state.operatorAddress?.toLowerCase();
|
|
4062
|
+
const proceedLabel = proceedLabelOverride ?? (state.operatorConsented ? "Done" : "Continue to Authorize Wallet");
|
|
4063
|
+
const hasDifferentOperator = Boolean(currentOperator) && currentOperator !== ZERO_OPERATOR && Boolean(expectedOperator) && currentOperator !== expectedOperator;
|
|
4064
|
+
if (choice === "generate") {
|
|
4065
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$3", children: [
|
|
4066
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Button, { variant: "text", alignSelf: "flex-start", onPress: leaveChoice, children: [
|
|
4067
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Icon, { name: "arrow-left", size: "xs", color: "primary" }),
|
|
4068
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.ButtonText, { children: "Back to Generate / Import" })
|
|
4069
|
+
] }),
|
|
4070
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4071
|
+
BuyerKeyPanel,
|
|
4072
|
+
{
|
|
4073
|
+
embedded: true,
|
|
4074
|
+
buyerPubKey: state.buyerPubKey,
|
|
4075
|
+
buyerPrvKey: state.buyerPrvKey,
|
|
4076
|
+
buyerPubKeySaved: keyConfirmed,
|
|
4077
|
+
onGenerate: actions.generateBuyerKey,
|
|
4078
|
+
onConfirm: () => setKeyConfirmed(true)
|
|
4079
|
+
}
|
|
4080
|
+
),
|
|
4081
|
+
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 }) })
|
|
4082
|
+
] });
|
|
4083
|
+
}
|
|
4084
|
+
if (choice === "import") {
|
|
4085
|
+
const importedSigner = !isImporting && Boolean(importedAddress) && state.buyerPubKey?.toLowerCase() === importedAddress?.toLowerCase();
|
|
4086
|
+
const importedSignerBlocked = importedSigner && hasDifferentOperator;
|
|
4087
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$3", children: [
|
|
4088
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Button, { variant: "text", alignSelf: "flex-start", onPress: leaveChoice, children: [
|
|
4089
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Icon, { name: "arrow-left", size: "xs", color: "primary" }),
|
|
4090
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.ButtonText, { children: "Back to Generate / Import" })
|
|
4091
|
+
] }),
|
|
4092
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Heading, { level: 5, children: "Import Signer Key" }),
|
|
4093
|
+
/* @__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." }),
|
|
4094
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4095
|
+
import_ui9.Input,
|
|
4096
|
+
{
|
|
4097
|
+
size: "sm",
|
|
4098
|
+
value: privateKey,
|
|
4099
|
+
onChangeText: setPrivateKey,
|
|
4100
|
+
placeholder: "0x\u2026",
|
|
4101
|
+
autoCapitalize: "none"
|
|
4102
|
+
}
|
|
4103
|
+
),
|
|
4104
|
+
state.error && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { color: "$error", children: state.error }),
|
|
4105
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4106
|
+
import_ui9.Button,
|
|
4107
|
+
{
|
|
4108
|
+
size: "sm",
|
|
4109
|
+
...compactButtonProps,
|
|
4110
|
+
disabled: !privateKey.trim() || isImporting,
|
|
4111
|
+
onPress: () => {
|
|
4112
|
+
setIsImporting(true);
|
|
4113
|
+
setImportedAddress(null);
|
|
4114
|
+
void actions.importBuyerFromPrivateKey(privateKey.trim()).then((buyerAddress) => setImportedAddress(buyerAddress)).catch(() => setImportedAddress(null)).finally(() => setIsImporting(false));
|
|
4115
|
+
},
|
|
4116
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.ButtonText, { children: isImporting ? "Checking signer\u2026" : "Import Signer Key" })
|
|
4117
|
+
}
|
|
4118
|
+
),
|
|
4119
|
+
importedSignerBlocked ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$2", children: [
|
|
4120
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { color: "$error", fontWeight: "700", children: "Signer key cannot be used" }),
|
|
4121
|
+
/* @__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." })
|
|
4122
|
+
] }) : importedSigner ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$2", children: [
|
|
4123
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { color: "$success", fontWeight: "700", children: "Signer imported" }),
|
|
4124
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Text, { secondary: true, children: [
|
|
4125
|
+
truncateAddress(state.buyerPubKey ?? ""),
|
|
4126
|
+
" is now your active signer."
|
|
4127
|
+
] }),
|
|
4128
|
+
/* @__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." }),
|
|
4129
|
+
/* @__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 }) })
|
|
4130
|
+
] }) : null
|
|
4131
|
+
] });
|
|
4132
|
+
}
|
|
4133
|
+
const choices = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
4134
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4135
|
+
import_ui9.Button,
|
|
3347
4136
|
{
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
4137
|
+
flex: compact ? void 0 : 1,
|
|
4138
|
+
alignSelf: compact ? "stretch" : void 0,
|
|
4139
|
+
size: compact ? "sm" : "lg",
|
|
4140
|
+
variant: "outline",
|
|
4141
|
+
...compactButtonProps,
|
|
4142
|
+
onPress: () => setChoice("generate"),
|
|
3353
4143
|
children: [
|
|
3354
|
-
/* @__PURE__ */ (0,
|
|
3355
|
-
|
|
3356
|
-
{
|
|
3357
|
-
fontSize: "$2",
|
|
3358
|
-
fontFamily: "$mono",
|
|
3359
|
-
flex: 1,
|
|
3360
|
-
numberOfLines: 1,
|
|
3361
|
-
style: monospaceSingleLineStyle,
|
|
3362
|
-
children: truncateAddress(address)
|
|
3363
|
-
}
|
|
3364
|
-
),
|
|
3365
|
-
/* @__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" }) })
|
|
4144
|
+
!compact && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Badge, { type: "success", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.BadgeText, { children: "Recommended" }) }),
|
|
4145
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.ButtonText, { children: "Generate Signer Key" })
|
|
3366
4146
|
]
|
|
3367
4147
|
}
|
|
4148
|
+
),
|
|
4149
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4150
|
+
import_ui9.Button,
|
|
4151
|
+
{
|
|
4152
|
+
flex: compact ? void 0 : 1,
|
|
4153
|
+
alignSelf: compact ? "stretch" : void 0,
|
|
4154
|
+
size: compact ? "sm" : "lg",
|
|
4155
|
+
variant: "outline",
|
|
4156
|
+
...compactButtonProps,
|
|
4157
|
+
onPress: () => setChoice("import"),
|
|
4158
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.ButtonText, { children: "Import Signer Key" })
|
|
4159
|
+
}
|
|
3368
4160
|
)
|
|
3369
4161
|
] });
|
|
4162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$3", children: [
|
|
4163
|
+
showHeading && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Heading, { level: 5, children: "Signer Key" }),
|
|
4164
|
+
!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." }),
|
|
4165
|
+
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 }),
|
|
4166
|
+
!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." })
|
|
4167
|
+
] });
|
|
3370
4168
|
}
|
|
3371
|
-
var
|
|
3372
|
-
var
|
|
3373
|
-
"src/components/
|
|
4169
|
+
var import_react8, import_ui9, import_jsx_runtime7, ZERO_OPERATOR;
|
|
4170
|
+
var init_SignerKeyPanel = __esm({
|
|
4171
|
+
"src/components/setup/SignerKeyPanel.tsx"() {
|
|
3374
4172
|
"use strict";
|
|
3375
|
-
|
|
4173
|
+
import_react8 = require("react");
|
|
4174
|
+
import_ui9 = require("@goodwidget/ui");
|
|
4175
|
+
init_BuyerKeyPanel();
|
|
3376
4176
|
init_styles();
|
|
3377
|
-
|
|
3378
|
-
|
|
4177
|
+
import_jsx_runtime7 = require("react/jsx-runtime");
|
|
4178
|
+
ZERO_OPERATOR = "0x0000000000000000000000000000000000000000";
|
|
3379
4179
|
}
|
|
3380
4180
|
});
|
|
3381
4181
|
|
|
3382
4182
|
// src/components/manage/BuyerOperatorCard.tsx
|
|
3383
|
-
function
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
4183
|
+
function shortAddress(address) {
|
|
4184
|
+
return `${address.slice(0, 6)}\u2026${address.slice(-4)}`;
|
|
4185
|
+
}
|
|
4186
|
+
function DisclosureToggle({
|
|
4187
|
+
open,
|
|
4188
|
+
label,
|
|
4189
|
+
onPress
|
|
4190
|
+
}) {
|
|
4191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4192
|
+
import_ui10.Button,
|
|
4193
|
+
{
|
|
4194
|
+
variant: "text",
|
|
4195
|
+
size: "sm",
|
|
4196
|
+
alignSelf: "flex-start",
|
|
4197
|
+
gap: "$1.5",
|
|
4198
|
+
...compactButtonProps,
|
|
4199
|
+
paddingHorizontal: "$0",
|
|
4200
|
+
"aria-expanded": open,
|
|
4201
|
+
onPress,
|
|
4202
|
+
children: [
|
|
4203
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Icon, { name: open ? "chevron-up" : "chevron-down", size: "xs", color: "primary" }),
|
|
4204
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.ButtonText, { children: label })
|
|
4205
|
+
]
|
|
4206
|
+
}
|
|
4207
|
+
);
|
|
4208
|
+
}
|
|
4209
|
+
function CopyableValue({ value, display }) {
|
|
4210
|
+
const { copied, copy } = useCopyFeedback();
|
|
4211
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4212
|
+
import_ui10.XStack,
|
|
4213
|
+
{
|
|
4214
|
+
backgroundColor: "$backgroundMuted",
|
|
4215
|
+
borderRadius: "$2",
|
|
4216
|
+
padding: "$2",
|
|
4217
|
+
justifyContent: "space-between",
|
|
4218
|
+
alignItems: "center",
|
|
4219
|
+
gap: "$2",
|
|
4220
|
+
children: [
|
|
4221
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { fontSize: "$2", flex: 1, numberOfLines: 1, style: monospaceSingleLineStyle, children: display ?? value }),
|
|
4222
|
+
/* @__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" }) })
|
|
4223
|
+
]
|
|
4224
|
+
}
|
|
4225
|
+
);
|
|
4226
|
+
}
|
|
4227
|
+
function SignerStatus({
|
|
4228
|
+
consented,
|
|
4229
|
+
size = "$1"
|
|
4230
|
+
}) {
|
|
4231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.XStack, { gap: "$1", alignItems: "center", children: [
|
|
4232
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4233
|
+
import_ui10.Icon,
|
|
4234
|
+
{
|
|
4235
|
+
name: consented ? "check" : "alert-triangle",
|
|
4236
|
+
size: "2xs",
|
|
4237
|
+
color: consented ? "success" : "warning"
|
|
4238
|
+
}
|
|
4239
|
+
),
|
|
4240
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { fontSize: size, color: consented ? "$success" : "$warning", children: consented ? "Authorized" : "Not authorized" })
|
|
4241
|
+
] });
|
|
4242
|
+
}
|
|
4243
|
+
function BuyerSelector({
|
|
4244
|
+
buyers,
|
|
4245
|
+
activeBuyerAddress,
|
|
4246
|
+
onSelect
|
|
4247
|
+
}) {
|
|
4248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.YStack, { gap: "$1", children: buyers.map((buyer) => {
|
|
4249
|
+
const isActive = buyer.toLowerCase() === activeBuyerAddress?.toLowerCase();
|
|
4250
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4251
|
+
import_ui10.XStack,
|
|
4252
|
+
{
|
|
4253
|
+
tag: "button",
|
|
4254
|
+
role: "option",
|
|
4255
|
+
"aria-selected": isActive,
|
|
4256
|
+
alignItems: "center",
|
|
4257
|
+
justifyContent: "space-between",
|
|
4258
|
+
gap: "$2",
|
|
4259
|
+
paddingHorizontal: "$2",
|
|
4260
|
+
paddingVertical: "$1.5",
|
|
4261
|
+
borderRadius: "$2",
|
|
4262
|
+
borderWidth: 1,
|
|
4263
|
+
borderColor: isActive ? "$primary" : "$borderColor",
|
|
4264
|
+
backgroundColor: isActive ? "$infoMuted" : "$backgroundDark",
|
|
4265
|
+
cursor: isActive ? "default" : "pointer",
|
|
4266
|
+
hoverStyle: isActive ? {} : { backgroundColor: "$backgroundPress" },
|
|
4267
|
+
onPress: () => {
|
|
4268
|
+
if (!isActive) void onSelect(buyer);
|
|
4269
|
+
},
|
|
4270
|
+
children: [
|
|
4271
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4272
|
+
import_ui10.Text,
|
|
4273
|
+
{
|
|
4274
|
+
fontSize: "$2",
|
|
4275
|
+
fontWeight: isActive ? "700" : "500",
|
|
4276
|
+
color: isActive ? "$primary" : "$color",
|
|
4277
|
+
numberOfLines: 1,
|
|
4278
|
+
flex: 1,
|
|
4279
|
+
style: monospaceSingleLineStyle,
|
|
4280
|
+
children: shortAddress(buyer)
|
|
4281
|
+
}
|
|
4282
|
+
),
|
|
4283
|
+
isActive ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.XStack, { gap: "$1", alignItems: "center", children: [
|
|
4284
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { fontSize: "$1", color: "$primary", children: "active" }),
|
|
4285
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Icon, { name: "check", size: "xs", color: "primary" })
|
|
4286
|
+
] }) : null
|
|
4287
|
+
]
|
|
4288
|
+
},
|
|
4289
|
+
buyer
|
|
4290
|
+
);
|
|
4291
|
+
}) });
|
|
4292
|
+
}
|
|
4293
|
+
function BuyerOperatorCard({ state, actions }) {
|
|
4294
|
+
const {
|
|
4295
|
+
buyerPubKey,
|
|
4296
|
+
buyerPrvKey,
|
|
4297
|
+
operatorSignature,
|
|
4298
|
+
operatorConsented,
|
|
4299
|
+
operatorConsentPending,
|
|
4300
|
+
buyers
|
|
4301
|
+
} = state;
|
|
4302
|
+
const [isExpanded, setIsExpanded] = (0, import_react9.useState)(false);
|
|
4303
|
+
const [showSwitcher, setShowSwitcher] = (0, import_react9.useState)(false);
|
|
4304
|
+
const [showReplacePanel, setShowReplacePanel] = (0, import_react9.useState)(false);
|
|
4305
|
+
const [showPrivateKey, setShowPrivateKey] = (0, import_react9.useState)(false);
|
|
4306
|
+
const [panelInstance, setPanelInstance] = (0, import_react9.useState)(0);
|
|
4307
|
+
const buyerCanSign = Boolean(buyerPrvKey || operatorSignature);
|
|
4308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.Card, { gap: "$3", "data-testid": "signer-key-card", children: [
|
|
4309
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4310
|
+
import_ui10.XStack,
|
|
4311
|
+
{
|
|
4312
|
+
tag: "button",
|
|
4313
|
+
"data-testid": "signer-key-toggle",
|
|
4314
|
+
alignItems: "center",
|
|
4315
|
+
justifyContent: "space-between",
|
|
4316
|
+
gap: "$2",
|
|
4317
|
+
width: "100%",
|
|
4318
|
+
backgroundColor: "transparent",
|
|
4319
|
+
borderWidth: 0,
|
|
4320
|
+
paddingHorizontal: "$0",
|
|
4321
|
+
paddingVertical: "$0",
|
|
4322
|
+
cursor: "pointer",
|
|
4323
|
+
"aria-expanded": isExpanded,
|
|
4324
|
+
onPress: () => setIsExpanded((prev) => !prev),
|
|
4325
|
+
children: [
|
|
4326
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.YStack, { gap: "$1", flex: 1, minWidth: 0, alignItems: "flex-start", children: [
|
|
4327
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Heading, { level: 6, children: "Signer Key" }),
|
|
4328
|
+
buyerPubKey ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.XStack, { alignItems: "center", flexWrap: "wrap", children: [
|
|
4329
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { fontSize: "$1", secondary: true, style: monospaceSingleLineStyle, children: `${truncateAddress(buyerPubKey)} \xB7 ` }),
|
|
4330
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SignerStatus, { consented: operatorConsented })
|
|
4331
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { fontSize: "$1", secondary: true, children: "No signer key yet" })
|
|
4332
|
+
] }),
|
|
4333
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Icon, { name: isExpanded ? "chevron-up" : "chevron-down", size: "sm", color: "muted" })
|
|
4334
|
+
]
|
|
4335
|
+
}
|
|
4336
|
+
),
|
|
4337
|
+
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.YStack, { gap: "$4", children: [
|
|
4338
|
+
buyerPubKey && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.YStack, { gap: "$2", children: [
|
|
4339
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { variant: "label", secondary: true, children: "Active signer" }),
|
|
4340
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4341
|
+
import_ui10.YStack,
|
|
3432
4342
|
{
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
4343
|
+
backgroundColor: "$backgroundDark",
|
|
4344
|
+
borderRadius: "$2",
|
|
4345
|
+
borderWidth: 1,
|
|
4346
|
+
borderColor: "$borderColor",
|
|
4347
|
+
padding: "$2",
|
|
4348
|
+
gap: "$2",
|
|
4349
|
+
children: [
|
|
4350
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CopyableValue, { value: buyerPubKey, display: truncateAddress(buyerPubKey) }),
|
|
4351
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SignerStatus, { consented: operatorConsented, size: "$2" }),
|
|
4352
|
+
!operatorConsented && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4353
|
+
import_ui10.Button,
|
|
4354
|
+
{
|
|
4355
|
+
size: "sm",
|
|
4356
|
+
...compactButtonProps,
|
|
4357
|
+
disabled: operatorConsentPending || !buyerCanSign,
|
|
4358
|
+
onPress: () => {
|
|
4359
|
+
void Promise.resolve(actions.signOperatorConsent());
|
|
4360
|
+
},
|
|
4361
|
+
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" })
|
|
4362
|
+
}
|
|
4363
|
+
)
|
|
4364
|
+
]
|
|
3437
4365
|
}
|
|
3438
4366
|
)
|
|
3439
4367
|
] }),
|
|
3440
|
-
/* @__PURE__ */ (0,
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
4368
|
+
buyers.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.YStack, { gap: "$2", children: [
|
|
4369
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4370
|
+
DisclosureToggle,
|
|
4371
|
+
{
|
|
4372
|
+
open: showSwitcher,
|
|
4373
|
+
label: `Switch signer (${buyers.length})`,
|
|
4374
|
+
onPress: () => setShowSwitcher((prev) => !prev)
|
|
4375
|
+
}
|
|
4376
|
+
),
|
|
4377
|
+
showSwitcher && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4378
|
+
BuyerSelector,
|
|
4379
|
+
{
|
|
4380
|
+
buyers,
|
|
4381
|
+
activeBuyerAddress: buyerPubKey,
|
|
4382
|
+
onSelect: actions.selectBuyer
|
|
4383
|
+
}
|
|
4384
|
+
)
|
|
4385
|
+
] }),
|
|
4386
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.YStack, { gap: "$2", children: [
|
|
4387
|
+
buyerPubKey ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4388
|
+
DisclosureToggle,
|
|
4389
|
+
{
|
|
4390
|
+
open: showReplacePanel,
|
|
4391
|
+
label: "Replace signer key",
|
|
4392
|
+
onPress: () => setShowReplacePanel((prev) => !prev)
|
|
4393
|
+
}
|
|
4394
|
+
) : null,
|
|
4395
|
+
(showReplacePanel || !buyerPubKey) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4396
|
+
SignerKeyPanel,
|
|
4397
|
+
{
|
|
4398
|
+
state,
|
|
4399
|
+
actions,
|
|
4400
|
+
showHeading: false,
|
|
4401
|
+
compact: Boolean(buyerPubKey),
|
|
4402
|
+
proceedLabel: "Done",
|
|
4403
|
+
onProceed: () => setPanelInstance((prev) => prev + 1)
|
|
4404
|
+
},
|
|
4405
|
+
panelInstance
|
|
4406
|
+
)
|
|
4407
|
+
] }),
|
|
4408
|
+
buyerPrvKey && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.YStack, { gap: "$2", children: [
|
|
4409
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui10.XStack, { justifyContent: "space-between", alignItems: "center", gap: "$2", children: [
|
|
4410
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.Text, { variant: "label", secondary: true, children: "Private key" }),
|
|
4411
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4412
|
+
import_ui10.Button,
|
|
4413
|
+
{
|
|
4414
|
+
variant: "text",
|
|
4415
|
+
size: "sm",
|
|
4416
|
+
...compactButtonProps,
|
|
4417
|
+
paddingHorizontal: "$0",
|
|
4418
|
+
onPress: () => setShowPrivateKey((prev) => !prev),
|
|
4419
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui10.ButtonText, { children: showPrivateKey ? "Hide" : "Reveal" })
|
|
4420
|
+
}
|
|
4421
|
+
)
|
|
4422
|
+
] }),
|
|
4423
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4424
|
+
CopyableValue,
|
|
4425
|
+
{
|
|
4426
|
+
value: buyerPrvKey,
|
|
4427
|
+
display: showPrivateKey ? buyerPrvKey : "\u2022".repeat(Math.min(48, buyerPrvKey.length))
|
|
4428
|
+
}
|
|
4429
|
+
),
|
|
4430
|
+
/* @__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." })
|
|
4431
|
+
] })
|
|
3470
4432
|
] })
|
|
3471
4433
|
] });
|
|
3472
4434
|
}
|
|
3473
|
-
var
|
|
4435
|
+
var import_react9, import_ui10, import_jsx_runtime8;
|
|
3474
4436
|
var init_BuyerOperatorCard = __esm({
|
|
3475
4437
|
"src/components/manage/BuyerOperatorCard.tsx"() {
|
|
3476
4438
|
"use strict";
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
4439
|
+
import_react9 = require("react");
|
|
4440
|
+
import_ui10 = require("@goodwidget/ui");
|
|
4441
|
+
init_SignerKeyPanel();
|
|
3480
4442
|
init_styles();
|
|
3481
4443
|
init_useCopyFeedback();
|
|
3482
|
-
|
|
4444
|
+
import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3483
4445
|
}
|
|
3484
4446
|
});
|
|
3485
4447
|
|
|
@@ -3496,21 +4458,21 @@ function buildSetupSnippet() {
|
|
|
3496
4458
|
].join("\n");
|
|
3497
4459
|
}
|
|
3498
4460
|
function SetupSnippet() {
|
|
3499
|
-
const [expanded, setExpanded] = (0,
|
|
3500
|
-
const [copied, setCopied] = (0,
|
|
4461
|
+
const [expanded, setExpanded] = (0, import_react10.useState)(false);
|
|
4462
|
+
const [copied, setCopied] = (0, import_react10.useState)(false);
|
|
3501
4463
|
const snippet = buildSetupSnippet();
|
|
3502
4464
|
const copyText = snippet.replace(/\n\n+/g, "\n").trim();
|
|
3503
4465
|
const lines = snippet.trim().split("\n");
|
|
3504
4466
|
async function handleCopy() {
|
|
3505
|
-
const copied2 = await (0,
|
|
4467
|
+
const copied2 = await (0, import_ui11.copyTextToClipboard)(copyText);
|
|
3506
4468
|
if (!copied2) return;
|
|
3507
4469
|
setCopied(true);
|
|
3508
4470
|
setTimeout(() => setCopied(false), 2e3);
|
|
3509
4471
|
}
|
|
3510
|
-
return /* @__PURE__ */ (0,
|
|
3511
|
-
/* @__PURE__ */ (0,
|
|
3512
|
-
/* @__PURE__ */ (0,
|
|
3513
|
-
|
|
4472
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_ui11.Card, { gap: "$2", children: [
|
|
4473
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_ui11.XStack, { justifyContent: "space-between", alignItems: "center", children: [
|
|
4474
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
4475
|
+
import_ui11.XStack,
|
|
3514
4476
|
{
|
|
3515
4477
|
flex: 1,
|
|
3516
4478
|
justifyContent: "space-between",
|
|
@@ -3518,41 +4480,41 @@ function SetupSnippet() {
|
|
|
3518
4480
|
onPress: () => setExpanded((value) => !value),
|
|
3519
4481
|
cursor: "pointer",
|
|
3520
4482
|
children: [
|
|
3521
|
-
/* @__PURE__ */ (0,
|
|
3522
|
-
/* @__PURE__ */ (0,
|
|
4483
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui11.Text, { fontSize: "$3", fontWeight: "600", children: "API Setup" }),
|
|
4484
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui11.Icon, { name: expanded ? "chevron-up" : "chevron-right", size: "xs", color: "muted" })
|
|
3523
4485
|
]
|
|
3524
4486
|
}
|
|
3525
4487
|
),
|
|
3526
|
-
/* @__PURE__ */ (0,
|
|
4488
|
+
/* @__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" }) })
|
|
3527
4489
|
] }),
|
|
3528
|
-
expanded && /* @__PURE__ */ (0,
|
|
3529
|
-
/* @__PURE__ */ (0,
|
|
3530
|
-
|
|
4490
|
+
expanded && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_ui11.YStack, { gap: "$2", children: [
|
|
4491
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4492
|
+
import_ui11.YStack,
|
|
3531
4493
|
{
|
|
3532
4494
|
backgroundColor: "$backgroundMuted",
|
|
3533
4495
|
borderRadius: "$2",
|
|
3534
4496
|
padding: "$3",
|
|
3535
4497
|
width: "100%",
|
|
3536
4498
|
gap: "$1",
|
|
3537
|
-
children: lines.map((line, index) => /* @__PURE__ */ (0,
|
|
4499
|
+
children: lines.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui11.Text, { color: "$text", style: setupSnippetLineStyle, children: line.length > 0 ? line : " " }, index))
|
|
3538
4500
|
}
|
|
3539
4501
|
),
|
|
3540
|
-
/* @__PURE__ */ (0,
|
|
4502
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_ui11.Text, { fontSize: "$1", secondary: true, children: [
|
|
3541
4503
|
"To connect AI tools to the AntSeed AI provider, see the",
|
|
3542
4504
|
" ",
|
|
3543
|
-
/* @__PURE__ */ (0,
|
|
4505
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui11.Anchor, { href: ANTSEED_API_DOCS_URL, target: "_blank", children: "AntSeed API guide" }),
|
|
3544
4506
|
"."
|
|
3545
4507
|
] })
|
|
3546
4508
|
] })
|
|
3547
4509
|
] });
|
|
3548
4510
|
}
|
|
3549
|
-
var
|
|
4511
|
+
var import_react10, import_ui11, import_jsx_runtime9, ANTSEED_API_DOCS_URL, setupSnippetLineStyle;
|
|
3550
4512
|
var init_SetupSnippet = __esm({
|
|
3551
4513
|
"src/components/manage/SetupSnippet.tsx"() {
|
|
3552
4514
|
"use strict";
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
4515
|
+
import_react10 = require("react");
|
|
4516
|
+
import_ui11 = require("@goodwidget/ui");
|
|
4517
|
+
import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3556
4518
|
ANTSEED_API_DOCS_URL = "https://antseed.com/docs/guides/using-the-api";
|
|
3557
4519
|
setupSnippetLineStyle = {
|
|
3558
4520
|
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
|
|
@@ -3625,10 +4587,10 @@ function entryDetailRows(entry) {
|
|
|
3625
4587
|
return rows;
|
|
3626
4588
|
}
|
|
3627
4589
|
function EntryDetailRow({ label, value }) {
|
|
3628
|
-
return /* @__PURE__ */ (0,
|
|
3629
|
-
/* @__PURE__ */ (0,
|
|
3630
|
-
/* @__PURE__ */ (0,
|
|
3631
|
-
|
|
4590
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.XStack, { gap: "$2", alignItems: "flex-start", width: "100%", children: [
|
|
4591
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$1", fontWeight: "600", secondary: true, minWidth: 72, flexShrink: 0, children: label }),
|
|
4592
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4593
|
+
import_ui12.Text,
|
|
3632
4594
|
{
|
|
3633
4595
|
fontSize: "$1",
|
|
3634
4596
|
flex: 1,
|
|
@@ -3748,9 +4710,9 @@ function CreditHistoryEntryRow({
|
|
|
3748
4710
|
const amounts = amountLines(entry);
|
|
3749
4711
|
const detailRows = entryDetailRows(entry);
|
|
3750
4712
|
const titleColor = entry.fundingStatus === "failed" ? "$error" : "$color";
|
|
3751
|
-
return /* @__PURE__ */ (0,
|
|
3752
|
-
/* @__PURE__ */ (0,
|
|
3753
|
-
|
|
4713
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.Card, { gap: "$2", children: [
|
|
4714
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
4715
|
+
import_ui12.XStack,
|
|
3754
4716
|
{
|
|
3755
4717
|
alignItems: "center",
|
|
3756
4718
|
gap: "$3",
|
|
@@ -3758,8 +4720,8 @@ function CreditHistoryEntryRow({
|
|
|
3758
4720
|
cursor: "pointer",
|
|
3759
4721
|
onPress: onToggle,
|
|
3760
4722
|
children: [
|
|
3761
|
-
/* @__PURE__ */ (0,
|
|
3762
|
-
|
|
4723
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4724
|
+
import_ui12.YStack,
|
|
3763
4725
|
{
|
|
3764
4726
|
width: 40,
|
|
3765
4727
|
height: 40,
|
|
@@ -3768,8 +4730,8 @@ function CreditHistoryEntryRow({
|
|
|
3768
4730
|
justifyContent: "center",
|
|
3769
4731
|
backgroundColor: entryIconBackground(entry),
|
|
3770
4732
|
flexShrink: 0,
|
|
3771
|
-
children: /* @__PURE__ */ (0,
|
|
3772
|
-
|
|
4733
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4734
|
+
import_ui12.Icon,
|
|
3773
4735
|
{
|
|
3774
4736
|
name: entryIconName(entry),
|
|
3775
4737
|
size: "sm",
|
|
@@ -3778,11 +4740,11 @@ function CreditHistoryEntryRow({
|
|
|
3778
4740
|
)
|
|
3779
4741
|
}
|
|
3780
4742
|
),
|
|
3781
|
-
/* @__PURE__ */ (0,
|
|
3782
|
-
/* @__PURE__ */ (0,
|
|
3783
|
-
/* @__PURE__ */ (0,
|
|
3784
|
-
/* @__PURE__ */ (0,
|
|
3785
|
-
|
|
4743
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { flex: 1, gap: "$0.5", minWidth: 0, children: [
|
|
4744
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$3", fontWeight: "700", color: titleColor, children: sourceLabel(entry.source) }),
|
|
4745
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.XStack, { alignItems: "center", gap: "$1", children: [
|
|
4746
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4747
|
+
import_ui12.YStack,
|
|
3786
4748
|
{
|
|
3787
4749
|
width: 6,
|
|
3788
4750
|
height: 6,
|
|
@@ -3790,18 +4752,18 @@ function CreditHistoryEntryRow({
|
|
|
3790
4752
|
backgroundColor: accent
|
|
3791
4753
|
}
|
|
3792
4754
|
),
|
|
3793
|
-
/* @__PURE__ */ (0,
|
|
4755
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$1", fontWeight: "600", color: accent, letterSpacing: 0.4, children: statusLabel(entry.fundingStatus) })
|
|
3794
4756
|
] })
|
|
3795
4757
|
] }),
|
|
3796
|
-
/* @__PURE__ */ (0,
|
|
3797
|
-
amounts?.primary ? /* @__PURE__ */ (0,
|
|
3798
|
-
amounts?.secondary ? /* @__PURE__ */ (0,
|
|
3799
|
-
/* @__PURE__ */ (0,
|
|
4758
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { alignItems: "flex-end", gap: "$0.5", flexShrink: 0, children: [
|
|
4759
|
+
amounts?.primary ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$3", fontWeight: "700", color: amountColor, children: amounts.primary }) : null,
|
|
4760
|
+
amounts?.secondary ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$2", fontWeight: "600", color: amountColor, children: amounts.secondary }) : null,
|
|
4761
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$1", secondary: true, children: formatEntryDate(entry.createdAt) })
|
|
3800
4762
|
] })
|
|
3801
4763
|
]
|
|
3802
4764
|
}
|
|
3803
4765
|
),
|
|
3804
|
-
expanded && detailRows.length > 0 ? /* @__PURE__ */ (0,
|
|
4766
|
+
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
|
|
3805
4767
|
] });
|
|
3806
4768
|
}
|
|
3807
4769
|
function SourceFilterChip({
|
|
@@ -3809,8 +4771,8 @@ function SourceFilterChip({
|
|
|
3809
4771
|
selected,
|
|
3810
4772
|
onPress
|
|
3811
4773
|
}) {
|
|
3812
|
-
return /* @__PURE__ */ (0,
|
|
3813
|
-
|
|
4774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4775
|
+
import_ui12.XStack,
|
|
3814
4776
|
{
|
|
3815
4777
|
tag: "button",
|
|
3816
4778
|
role: "checkbox",
|
|
@@ -3832,8 +4794,8 @@ function SourceFilterChip({
|
|
|
3832
4794
|
},
|
|
3833
4795
|
onPress,
|
|
3834
4796
|
flexShrink: 0,
|
|
3835
|
-
children: /* @__PURE__ */ (0,
|
|
3836
|
-
|
|
4797
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4798
|
+
import_ui12.Text,
|
|
3837
4799
|
{
|
|
3838
4800
|
fontSize: "$2",
|
|
3839
4801
|
fontWeight: selected ? "700" : "500",
|
|
@@ -3849,11 +4811,11 @@ function StatusFilterSelect({
|
|
|
3849
4811
|
value,
|
|
3850
4812
|
onValueChange
|
|
3851
4813
|
}) {
|
|
3852
|
-
const [open, setOpen] = (0,
|
|
4814
|
+
const [open, setOpen] = (0, import_react11.useState)(false);
|
|
3853
4815
|
const selected = STATUS_OPTIONS.find((option) => option.value === value);
|
|
3854
|
-
return /* @__PURE__ */ (0,
|
|
3855
|
-
/* @__PURE__ */ (0,
|
|
3856
|
-
|
|
4816
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { flex: 1, minWidth: 0, position: "relative", zIndex: open ? 20 : 1, children: [
|
|
4817
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
4818
|
+
import_ui12.XStack,
|
|
3857
4819
|
{
|
|
3858
4820
|
tag: "button",
|
|
3859
4821
|
role: "combobox",
|
|
@@ -3869,16 +4831,16 @@ function StatusFilterSelect({
|
|
|
3869
4831
|
cursor: "pointer",
|
|
3870
4832
|
onPress: () => setOpen((current) => !current),
|
|
3871
4833
|
children: [
|
|
3872
|
-
/* @__PURE__ */ (0,
|
|
4834
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.Text, { fontSize: "$2", color: "$placeholderColor", numberOfLines: 1, flex: 1, children: [
|
|
3873
4835
|
"Status: ",
|
|
3874
4836
|
selected?.label ?? "All"
|
|
3875
4837
|
] }),
|
|
3876
|
-
/* @__PURE__ */ (0,
|
|
4838
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Icon, { name: open ? "chevron-up" : "chevron-down", size: "xs", color: "muted" })
|
|
3877
4839
|
]
|
|
3878
4840
|
}
|
|
3879
4841
|
),
|
|
3880
|
-
open ? /* @__PURE__ */ (0,
|
|
3881
|
-
|
|
4842
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4843
|
+
import_ui12.YStack,
|
|
3882
4844
|
{
|
|
3883
4845
|
position: "absolute",
|
|
3884
4846
|
top: "100%",
|
|
@@ -3891,8 +4853,93 @@ function StatusFilterSelect({
|
|
|
3891
4853
|
backgroundColor: "$backgroundDark",
|
|
3892
4854
|
overflow: "hidden",
|
|
3893
4855
|
zIndex: 30,
|
|
3894
|
-
children: STATUS_OPTIONS.map((option) => /* @__PURE__ */ (0,
|
|
3895
|
-
|
|
4856
|
+
children: STATUS_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4857
|
+
import_ui12.XStack,
|
|
4858
|
+
{
|
|
4859
|
+
tag: "button",
|
|
4860
|
+
role: "option",
|
|
4861
|
+
paddingHorizontal: "$3",
|
|
4862
|
+
paddingVertical: "$2",
|
|
4863
|
+
cursor: "pointer",
|
|
4864
|
+
backgroundColor: option.value === value ? "$infoMuted" : "transparent",
|
|
4865
|
+
hoverStyle: { backgroundColor: "$backgroundPress" },
|
|
4866
|
+
onPress: () => {
|
|
4867
|
+
onValueChange(option.value);
|
|
4868
|
+
setOpen(false);
|
|
4869
|
+
},
|
|
4870
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4871
|
+
import_ui12.Text,
|
|
4872
|
+
{
|
|
4873
|
+
fontSize: "$2",
|
|
4874
|
+
fontWeight: option.value === value ? "700" : "500",
|
|
4875
|
+
color: option.value === value ? "$primary" : "$color",
|
|
4876
|
+
children: option.label
|
|
4877
|
+
}
|
|
4878
|
+
)
|
|
4879
|
+
},
|
|
4880
|
+
option.value
|
|
4881
|
+
))
|
|
4882
|
+
}
|
|
4883
|
+
) : null
|
|
4884
|
+
] });
|
|
4885
|
+
}
|
|
4886
|
+
function BuyerFilterSelect({
|
|
4887
|
+
value,
|
|
4888
|
+
buyers,
|
|
4889
|
+
onValueChange
|
|
4890
|
+
}) {
|
|
4891
|
+
const [open, setOpen] = (0, import_react11.useState)(false);
|
|
4892
|
+
if (buyers.length === 0) return null;
|
|
4893
|
+
const options = [
|
|
4894
|
+
{ value: BUYER_FILTER_ALL, label: "All buyers" },
|
|
4895
|
+
...buyers.map((b) => ({
|
|
4896
|
+
value: b.address,
|
|
4897
|
+
label: b.label ?? `${b.address.slice(0, 6)}\u2026${b.address.slice(-4)}`
|
|
4898
|
+
}))
|
|
4899
|
+
];
|
|
4900
|
+
const selected = options.find((o) => o.value === value) ?? options[0];
|
|
4901
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { flex: 1, minWidth: 0, position: "relative", zIndex: open ? 25 : 1, children: [
|
|
4902
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
4903
|
+
import_ui12.XStack,
|
|
4904
|
+
{
|
|
4905
|
+
tag: "button",
|
|
4906
|
+
role: "listbox",
|
|
4907
|
+
height: "$7",
|
|
4908
|
+
alignItems: "center",
|
|
4909
|
+
justifyContent: "space-between",
|
|
4910
|
+
gap: "$2",
|
|
4911
|
+
paddingHorizontal: "$3",
|
|
4912
|
+
borderRadius: "$3",
|
|
4913
|
+
borderWidth: 1,
|
|
4914
|
+
borderColor: "$borderColor",
|
|
4915
|
+
backgroundColor: "$backgroundDark",
|
|
4916
|
+
cursor: "pointer",
|
|
4917
|
+
onPress: () => setOpen((current) => !current),
|
|
4918
|
+
children: [
|
|
4919
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.Text, { fontSize: "$2", color: "$placeholderColor", numberOfLines: 1, flex: 1, children: [
|
|
4920
|
+
"Buyer: ",
|
|
4921
|
+
selected?.label ?? "All buyers"
|
|
4922
|
+
] }),
|
|
4923
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Icon, { name: open ? "chevron-up" : "chevron-down", size: "xs", color: "muted" })
|
|
4924
|
+
]
|
|
4925
|
+
}
|
|
4926
|
+
),
|
|
4927
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4928
|
+
import_ui12.YStack,
|
|
4929
|
+
{
|
|
4930
|
+
position: "absolute",
|
|
4931
|
+
top: "100%",
|
|
4932
|
+
left: 0,
|
|
4933
|
+
right: 0,
|
|
4934
|
+
marginTop: "$1",
|
|
4935
|
+
borderRadius: "$3",
|
|
4936
|
+
borderWidth: 1,
|
|
4937
|
+
borderColor: "$borderColor",
|
|
4938
|
+
backgroundColor: "$backgroundDark",
|
|
4939
|
+
overflow: "hidden",
|
|
4940
|
+
zIndex: 35,
|
|
4941
|
+
children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4942
|
+
import_ui12.XStack,
|
|
3896
4943
|
{
|
|
3897
4944
|
tag: "button",
|
|
3898
4945
|
role: "option",
|
|
@@ -3905,8 +4952,8 @@ function StatusFilterSelect({
|
|
|
3905
4952
|
onValueChange(option.value);
|
|
3906
4953
|
setOpen(false);
|
|
3907
4954
|
},
|
|
3908
|
-
children: /* @__PURE__ */ (0,
|
|
3909
|
-
|
|
4955
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4956
|
+
import_ui12.Text,
|
|
3910
4957
|
{
|
|
3911
4958
|
fontSize: "$2",
|
|
3912
4959
|
fontWeight: option.value === value ? "700" : "500",
|
|
@@ -3921,10 +4968,11 @@ function StatusFilterSelect({
|
|
|
3921
4968
|
) : null
|
|
3922
4969
|
] });
|
|
3923
4970
|
}
|
|
3924
|
-
function HistoryTab({ state, actions }) {
|
|
4971
|
+
function HistoryTab({ state, actions, knownBuyers = [] }) {
|
|
3925
4972
|
const {
|
|
3926
4973
|
selectedSources,
|
|
3927
4974
|
statusFilter,
|
|
4975
|
+
buyerAddressFilter,
|
|
3928
4976
|
fromDate,
|
|
3929
4977
|
toDate,
|
|
3930
4978
|
entries,
|
|
@@ -3934,26 +4982,26 @@ function HistoryTab({ state, actions }) {
|
|
|
3934
4982
|
error,
|
|
3935
4983
|
activeSources
|
|
3936
4984
|
} = state;
|
|
3937
|
-
const [expandedEntryId, setExpandedEntryId] = (0,
|
|
3938
|
-
const defaultRange = (0,
|
|
4985
|
+
const [expandedEntryId, setExpandedEntryId] = (0, import_react11.useState)(null);
|
|
4986
|
+
const defaultRange = (0, import_react11.useMemo)(() => getLast90DaysRange(), []);
|
|
3939
4987
|
const isDefaultRange = fromDate === defaultRange.from && toDate === defaultRange.to;
|
|
3940
4988
|
const rangeSummary = isDefaultRange ? `Last ${HISTORY_LOOKBACK_DAYS} days activity` : `${formatShortDate(fromDate)} \u2013 ${formatShortDate(toDate)}`;
|
|
3941
|
-
const accumulatedG = (0,
|
|
4989
|
+
const accumulatedG = (0, import_react11.useMemo)(
|
|
3942
4990
|
() => formatAccumulatedG(sumFilteredGdWei(entries)),
|
|
3943
4991
|
[entries]
|
|
3944
4992
|
);
|
|
3945
|
-
return /* @__PURE__ */ (0,
|
|
3946
|
-
/* @__PURE__ */ (0,
|
|
3947
|
-
/* @__PURE__ */ (0,
|
|
3948
|
-
/* @__PURE__ */ (0,
|
|
3949
|
-
/* @__PURE__ */ (0,
|
|
4993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { gap: "$3", width: "100%", children: [
|
|
4994
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.Card, { gap: "$3", children: [
|
|
4995
|
+
/* @__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: [
|
|
4996
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Heading, { level: 4, children: "AI Credit History" }),
|
|
4997
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$1", secondary: true, children: rangeSummary })
|
|
3950
4998
|
] }) }),
|
|
3951
|
-
/* @__PURE__ */ (0,
|
|
3952
|
-
/* @__PURE__ */ (0,
|
|
3953
|
-
/* @__PURE__ */ (0,
|
|
4999
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.YStack, { gap: "$1", children: [
|
|
5000
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$1", fontWeight: "600", secondary: true, letterSpacing: 0.6, children: "TOTAL ACCUMULATED" }),
|
|
5001
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$7", fontWeight: "700", color: "$color", children: accumulatedG })
|
|
3954
5002
|
] })
|
|
3955
5003
|
] }),
|
|
3956
|
-
/* @__PURE__ */ (0,
|
|
5004
|
+
/* @__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)(
|
|
3957
5005
|
SourceFilterChip,
|
|
3958
5006
|
{
|
|
3959
5007
|
label: option.label,
|
|
@@ -3962,16 +5010,26 @@ function HistoryTab({ state, actions }) {
|
|
|
3962
5010
|
},
|
|
3963
5011
|
option.id
|
|
3964
5012
|
)) }),
|
|
3965
|
-
/* @__PURE__ */ (0,
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
/* @__PURE__ */ (0,
|
|
3974
|
-
|
|
5013
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.XStack, { gap: "$2", alignItems: "center", width: "100%", children: [
|
|
5014
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
5015
|
+
StatusFilterSelect,
|
|
5016
|
+
{
|
|
5017
|
+
value: statusFilter,
|
|
5018
|
+
onValueChange: actions.setStatusFilter
|
|
5019
|
+
}
|
|
5020
|
+
),
|
|
5021
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
5022
|
+
BuyerFilterSelect,
|
|
5023
|
+
{
|
|
5024
|
+
value: buyerAddressFilter,
|
|
5025
|
+
buyers: knownBuyers,
|
|
5026
|
+
onValueChange: actions.setBuyerAddressFilter
|
|
5027
|
+
}
|
|
5028
|
+
)
|
|
5029
|
+
] }),
|
|
5030
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.XStack, { gap: "$2", width: "100%", children: [
|
|
5031
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.YStack, { flex: 1, minWidth: 0, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
5032
|
+
import_ui12.Input,
|
|
3975
5033
|
{
|
|
3976
5034
|
size: "sm",
|
|
3977
5035
|
type: "date",
|
|
@@ -3980,8 +5038,8 @@ function HistoryTab({ state, actions }) {
|
|
|
3980
5038
|
onChangeText: actions.setFromDate
|
|
3981
5039
|
}
|
|
3982
5040
|
) }),
|
|
3983
|
-
/* @__PURE__ */ (0,
|
|
3984
|
-
|
|
5041
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.YStack, { flex: 1, minWidth: 0, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
5042
|
+
import_ui12.Input,
|
|
3985
5043
|
{
|
|
3986
5044
|
size: "sm",
|
|
3987
5045
|
type: "date",
|
|
@@ -3991,10 +5049,10 @@ function HistoryTab({ state, actions }) {
|
|
|
3991
5049
|
}
|
|
3992
5050
|
) })
|
|
3993
5051
|
] }),
|
|
3994
|
-
/* @__PURE__ */ (0,
|
|
3995
|
-
/* @__PURE__ */ (0,
|
|
3996
|
-
/* @__PURE__ */ (0,
|
|
3997
|
-
|
|
5052
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_ui12.XStack, { alignItems: "center", justifyContent: "space-between", gap: "$2", width: "100%", children: [
|
|
5053
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$1", fontWeight: "700", secondary: true, letterSpacing: 0.6, children: "CREDIT HISTORY" }),
|
|
5054
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
5055
|
+
import_ui12.XStack,
|
|
3998
5056
|
{
|
|
3999
5057
|
tag: "button",
|
|
4000
5058
|
backgroundColor: "transparent",
|
|
@@ -4008,17 +5066,17 @@ function HistoryTab({ state, actions }) {
|
|
|
4008
5066
|
if (entries.length === 0) return;
|
|
4009
5067
|
exportEntriesCsv(entries);
|
|
4010
5068
|
},
|
|
4011
|
-
children: /* @__PURE__ */ (0,
|
|
5069
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$2", fontWeight: "600", color: "$primary", children: "Export CSV" })
|
|
4012
5070
|
}
|
|
4013
5071
|
)
|
|
4014
5072
|
] }),
|
|
4015
|
-
loading ? /* @__PURE__ */ (0,
|
|
4016
|
-
/* @__PURE__ */ (0,
|
|
4017
|
-
/* @__PURE__ */ (0,
|
|
4018
|
-
] }) }) : error ? /* @__PURE__ */ (0,
|
|
4019
|
-
/* @__PURE__ */ (0,
|
|
4020
|
-
/* @__PURE__ */ (0,
|
|
4021
|
-
|
|
5073
|
+
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: [
|
|
5074
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Spinner, { size: "sm" }),
|
|
5075
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { fontSize: "$2", secondary: true, children: "Loading credit history\u2026" })
|
|
5076
|
+
] }) }) : 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: [
|
|
5077
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Text, { color: "$error", fontSize: "$2", children: error }),
|
|
5078
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
5079
|
+
import_ui12.Button,
|
|
4022
5080
|
{
|
|
4023
5081
|
variant: "outline",
|
|
4024
5082
|
size: "sm",
|
|
@@ -4027,10 +5085,10 @@ function HistoryTab({ state, actions }) {
|
|
|
4027
5085
|
onPress: () => {
|
|
4028
5086
|
void actions.reload();
|
|
4029
5087
|
},
|
|
4030
|
-
children: /* @__PURE__ */ (0,
|
|
5088
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.ButtonText, { children: "Retry" })
|
|
4031
5089
|
}
|
|
4032
5090
|
)
|
|
4033
|
-
] }) }) : activeSources.length === 0 ? /* @__PURE__ */ (0,
|
|
5091
|
+
] }) }) : 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)(
|
|
4034
5092
|
CreditHistoryEntryRow,
|
|
4035
5093
|
{
|
|
4036
5094
|
entry,
|
|
@@ -4039,8 +5097,8 @@ function HistoryTab({ state, actions }) {
|
|
|
4039
5097
|
},
|
|
4040
5098
|
entry.id
|
|
4041
5099
|
)) }),
|
|
4042
|
-
!loading && !error && hasMore && /* @__PURE__ */ (0,
|
|
4043
|
-
|
|
5100
|
+
!loading && !error && hasMore && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
5101
|
+
import_ui12.Button,
|
|
4044
5102
|
{
|
|
4045
5103
|
variant: "outline",
|
|
4046
5104
|
size: "sm",
|
|
@@ -4051,23 +5109,23 @@ function HistoryTab({ state, actions }) {
|
|
|
4051
5109
|
void actions.loadMore();
|
|
4052
5110
|
},
|
|
4053
5111
|
children: [
|
|
4054
|
-
loadingMore ? /* @__PURE__ */ (0,
|
|
4055
|
-
/* @__PURE__ */ (0,
|
|
5112
|
+
loadingMore ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.Spinner, { size: "sm" }) : null,
|
|
5113
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui12.ButtonText, { children: loadingMore ? "Loading\u2026" : "Load more" })
|
|
4056
5114
|
]
|
|
4057
5115
|
}
|
|
4058
5116
|
)
|
|
4059
5117
|
] });
|
|
4060
5118
|
}
|
|
4061
|
-
var
|
|
5119
|
+
var import_react11, import_ui12, import_jsx_runtime10, STATUS_OPTIONS, SOURCE_PILL_OPTIONS;
|
|
4062
5120
|
var init_HistoryTab = __esm({
|
|
4063
5121
|
"src/components/history/HistoryTab.tsx"() {
|
|
4064
5122
|
"use strict";
|
|
4065
|
-
|
|
4066
|
-
|
|
5123
|
+
import_react11 = require("react");
|
|
5124
|
+
import_ui12 = require("@goodwidget/ui");
|
|
4067
5125
|
init_quoteMath();
|
|
4068
5126
|
init_styles();
|
|
4069
5127
|
init_useAiCreditsHistory();
|
|
4070
|
-
|
|
5128
|
+
import_jsx_runtime10 = require("react/jsx-runtime");
|
|
4071
5129
|
STATUS_OPTIONS = [
|
|
4072
5130
|
{ label: "All", value: "all" },
|
|
4073
5131
|
{ label: "Funded", value: "funded" },
|
|
@@ -4082,28 +5140,581 @@ var init_HistoryTab = __esm({
|
|
|
4082
5140
|
}
|
|
4083
5141
|
});
|
|
4084
5142
|
|
|
4085
|
-
// src/components/
|
|
4086
|
-
function
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
return null;
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
5143
|
+
// src/components/setup/SetupBonusHighlight.tsx
|
|
5144
|
+
function SetupBonusHighlight({
|
|
5145
|
+
depositBonusPercent,
|
|
5146
|
+
streamBonusPercent,
|
|
5147
|
+
isGoodIdVerified
|
|
5148
|
+
}) {
|
|
5149
|
+
const [isExpanded, setIsExpanded] = (0, import_react12.useState)(false);
|
|
5150
|
+
const maxBonusPercent = Math.max(depositBonusPercent, streamBonusPercent);
|
|
5151
|
+
if (maxBonusPercent <= 0) return null;
|
|
5152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Card, { gap: "$2", padding: "$3", backgroundColor: "$backgroundHover", children: [
|
|
5153
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
5154
|
+
import_ui13.XStack,
|
|
5155
|
+
{
|
|
5156
|
+
gap: "$3",
|
|
5157
|
+
alignItems: "center",
|
|
5158
|
+
cursor: "pointer",
|
|
5159
|
+
accessibilityRole: "button",
|
|
5160
|
+
"aria-expanded": isExpanded,
|
|
5161
|
+
onPress: () => setIsExpanded((previous) => !previous),
|
|
5162
|
+
children: [
|
|
5163
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
5164
|
+
import_ui13.YStack,
|
|
5165
|
+
{
|
|
5166
|
+
width: 34,
|
|
5167
|
+
height: 34,
|
|
5168
|
+
borderRadius: "$2",
|
|
5169
|
+
backgroundColor: "$backgroundPress",
|
|
5170
|
+
alignItems: "center",
|
|
5171
|
+
justifyContent: "center",
|
|
5172
|
+
flexShrink: 0,
|
|
5173
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui13.Icon, { name: "party-popper", size: "sm", color: "primary" })
|
|
5174
|
+
}
|
|
5175
|
+
),
|
|
5176
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.YStack, { flex: 1, gap: 2, children: [
|
|
5177
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Text, { fontSize: "$3", fontWeight: "700", children: [
|
|
5178
|
+
"Up to ",
|
|
5179
|
+
maxBonusPercent,
|
|
5180
|
+
"% more AI credits"
|
|
5181
|
+
] }),
|
|
5182
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Text, { fontSize: "$2", lineHeight: "$3", children: [
|
|
5183
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Text, { fontSize: "$2", fontWeight: "700", color: "$primary", children: [
|
|
5184
|
+
"+",
|
|
5185
|
+
depositBonusPercent,
|
|
5186
|
+
"%"
|
|
5187
|
+
] }),
|
|
5188
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Text, { fontSize: "$2", secondary: true, children: [
|
|
5189
|
+
" ",
|
|
5190
|
+
"on deposits,",
|
|
5191
|
+
" "
|
|
5192
|
+
] }),
|
|
5193
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Text, { fontSize: "$2", fontWeight: "700", color: "$primary", children: [
|
|
5194
|
+
"+",
|
|
5195
|
+
streamBonusPercent,
|
|
5196
|
+
"%"
|
|
5197
|
+
] }),
|
|
5198
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_ui13.Text, { fontSize: "$2", secondary: true, children: [
|
|
5199
|
+
" ",
|
|
5200
|
+
"on streams \u2014 paid with G$"
|
|
5201
|
+
] })
|
|
5202
|
+
] })
|
|
5203
|
+
] }),
|
|
5204
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui13.Icon, { name: isExpanded ? "chevron-up" : "chevron-down", size: "xs", color: "muted" })
|
|
5205
|
+
]
|
|
5206
|
+
}
|
|
5207
|
+
),
|
|
5208
|
+
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: [
|
|
5209
|
+
"Your wallet is",
|
|
5210
|
+
" ",
|
|
5211
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui13.Text, { fontSize: "$2", fontWeight: "700", children: "GoodID verified" }),
|
|
5212
|
+
", so the bonus is applied automatically to deposits and streams."
|
|
5213
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
5214
|
+
"Bonus applies to",
|
|
5215
|
+
" ",
|
|
5216
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui13.Text, { fontSize: "$2", fontWeight: "700", children: "verified GoodDollar wallets" }),
|
|
5217
|
+
" ",
|
|
5218
|
+
"only. Not verified? Claim UBI first via GoodWallet or GoodDapp \u2014 takes a minute, then this kicks in automatically."
|
|
5219
|
+
] }) }) })
|
|
5220
|
+
] });
|
|
5221
|
+
}
|
|
5222
|
+
var import_react12, import_ui13, import_jsx_runtime11;
|
|
5223
|
+
var init_SetupBonusHighlight = __esm({
|
|
5224
|
+
"src/components/setup/SetupBonusHighlight.tsx"() {
|
|
5225
|
+
"use strict";
|
|
5226
|
+
import_react12 = require("react");
|
|
5227
|
+
import_ui13 = require("@goodwidget/ui");
|
|
5228
|
+
import_jsx_runtime11 = require("react/jsx-runtime");
|
|
5229
|
+
}
|
|
5230
|
+
});
|
|
5231
|
+
|
|
5232
|
+
// src/components/setup/SetupGuidanceCard.tsx
|
|
5233
|
+
function SetupGuidanceCard({
|
|
5234
|
+
onHowToUse,
|
|
5235
|
+
onFaq,
|
|
5236
|
+
activeHelpView,
|
|
5237
|
+
depositBonusPercent,
|
|
5238
|
+
streamBonusPercent,
|
|
5239
|
+
isGoodIdVerified
|
|
5240
|
+
}) {
|
|
5241
|
+
return (
|
|
5242
|
+
// Rendered flush on the widget background — no card surface, so it reads as
|
|
5243
|
+
// part of the header rather than a separate panel.
|
|
5244
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.YStack, { gap: "$3", paddingHorizontal: "$1", children: [
|
|
5245
|
+
/* @__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." }),
|
|
5246
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5247
|
+
SetupBonusHighlight,
|
|
5248
|
+
{
|
|
5249
|
+
depositBonusPercent,
|
|
5250
|
+
streamBonusPercent,
|
|
5251
|
+
isGoodIdVerified
|
|
5252
|
+
}
|
|
5253
|
+
),
|
|
5254
|
+
/* @__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:" }) }),
|
|
5255
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.YStack, { gap: "$3", children: [
|
|
5256
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.XStack, { gap: "$3", alignItems: "flex-start", children: [
|
|
5257
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5258
|
+
import_ui14.YStack,
|
|
5259
|
+
{
|
|
5260
|
+
width: 22,
|
|
5261
|
+
height: 22,
|
|
5262
|
+
borderRadius: "$full",
|
|
5263
|
+
backgroundColor: "$backgroundHover",
|
|
5264
|
+
alignItems: "center",
|
|
5265
|
+
justifyContent: "center",
|
|
5266
|
+
flexShrink: 0,
|
|
5267
|
+
marginTop: 2,
|
|
5268
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.Text, { fontSize: "$1", fontWeight: "700", color: "$secondary", children: "1" })
|
|
5269
|
+
}
|
|
5270
|
+
),
|
|
5271
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.Text, { fontSize: "$2", flex: 1, lineHeight: "$3", children: [
|
|
5272
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.Text, { fontSize: "$2", fontWeight: "700", children: [
|
|
5273
|
+
"Get G$",
|
|
5274
|
+
" "
|
|
5275
|
+
] }),
|
|
5276
|
+
/* @__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" })
|
|
5277
|
+
] })
|
|
5278
|
+
] }),
|
|
5279
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.XStack, { gap: "$3", alignItems: "flex-start", children: [
|
|
5280
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5281
|
+
import_ui14.YStack,
|
|
5282
|
+
{
|
|
5283
|
+
width: 22,
|
|
5284
|
+
height: 22,
|
|
5285
|
+
borderRadius: "$full",
|
|
5286
|
+
backgroundColor: "$backgroundHover",
|
|
5287
|
+
alignItems: "center",
|
|
5288
|
+
justifyContent: "center",
|
|
5289
|
+
flexShrink: 0,
|
|
5290
|
+
marginTop: 2,
|
|
5291
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.Text, { fontSize: "$1", fontWeight: "700", color: "$secondary", children: "2" })
|
|
5292
|
+
}
|
|
5293
|
+
),
|
|
5294
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.Text, { fontSize: "$2", flex: 1, lineHeight: "$3", children: [
|
|
5295
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.Text, { fontSize: "$2", fontWeight: "700", children: [
|
|
5296
|
+
"Download Antseed",
|
|
5297
|
+
" "
|
|
5298
|
+
] }),
|
|
5299
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.Text, { fontSize: "$2", secondary: true, children: "\u2014 the free desktop app that runs your credits locally" })
|
|
5300
|
+
] })
|
|
5301
|
+
] })
|
|
5302
|
+
] }),
|
|
5303
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.Separator, {}),
|
|
5304
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui14.XStack, { gap: "$2", flexWrap: "wrap", children: [
|
|
5305
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5306
|
+
import_ui14.Button,
|
|
5307
|
+
{
|
|
5308
|
+
flexGrow: 1,
|
|
5309
|
+
flexBasis: "auto",
|
|
5310
|
+
size: "sm",
|
|
5311
|
+
variant: activeHelpView === "how-to-use" ? "default" : "outline",
|
|
5312
|
+
onPress: onHowToUse,
|
|
5313
|
+
borderRadius: "$3",
|
|
5314
|
+
paddingHorizontal: "$2",
|
|
5315
|
+
minWidth: 0,
|
|
5316
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.ButtonText, { numberOfLines: 1, children: "How to use" })
|
|
5317
|
+
}
|
|
5318
|
+
),
|
|
5319
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5320
|
+
import_ui14.Anchor,
|
|
5321
|
+
{
|
|
5322
|
+
href: ANTSEED_SITE_URL,
|
|
5323
|
+
target: "_blank",
|
|
5324
|
+
style: { flexGrow: 1, flexBasis: "auto", textDecorationLine: "none", minWidth: 0 },
|
|
5325
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
5326
|
+
import_ui14.Button,
|
|
5327
|
+
{
|
|
5328
|
+
size: "sm",
|
|
5329
|
+
variant: "outline",
|
|
5330
|
+
width: "100%",
|
|
5331
|
+
borderRadius: "$3",
|
|
5332
|
+
paddingHorizontal: "$2",
|
|
5333
|
+
gap: "$1",
|
|
5334
|
+
children: [
|
|
5335
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.ButtonText, { numberOfLines: 1, children: "Antseed site" }),
|
|
5336
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.Icon, { name: "external-link", size: "xs", color: "muted" })
|
|
5337
|
+
]
|
|
5338
|
+
}
|
|
5339
|
+
)
|
|
5340
|
+
}
|
|
5341
|
+
),
|
|
5342
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5343
|
+
import_ui14.Button,
|
|
5344
|
+
{
|
|
5345
|
+
flexGrow: 1,
|
|
5346
|
+
flexBasis: "auto",
|
|
5347
|
+
size: "sm",
|
|
5348
|
+
variant: activeHelpView === "faq" ? "default" : "outline",
|
|
5349
|
+
onPress: onFaq,
|
|
5350
|
+
borderRadius: "$3",
|
|
5351
|
+
paddingHorizontal: "$2",
|
|
5352
|
+
minWidth: 0,
|
|
5353
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui14.ButtonText, { numberOfLines: 1, children: "FAQs" })
|
|
5354
|
+
}
|
|
5355
|
+
)
|
|
5356
|
+
] })
|
|
5357
|
+
] })
|
|
5358
|
+
);
|
|
5359
|
+
}
|
|
5360
|
+
var import_ui14, import_jsx_runtime12, ANTSEED_SITE_URL;
|
|
5361
|
+
var init_SetupGuidanceCard = __esm({
|
|
5362
|
+
"src/components/setup/SetupGuidanceCard.tsx"() {
|
|
5363
|
+
"use strict";
|
|
5364
|
+
import_ui14 = require("@goodwidget/ui");
|
|
5365
|
+
init_SetupBonusHighlight();
|
|
5366
|
+
import_jsx_runtime12 = require("react/jsx-runtime");
|
|
5367
|
+
ANTSEED_SITE_URL = "https://antseed.com";
|
|
5368
|
+
}
|
|
5369
|
+
});
|
|
5370
|
+
|
|
5371
|
+
// src/components/setup/HowToUseView.tsx
|
|
5372
|
+
function HowToUseView({ onBack }) {
|
|
5373
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.YStack, { gap: "$4", children: [
|
|
5374
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.Button, { variant: "text", alignSelf: "flex-start", onPress: onBack, gap: "$1", children: [
|
|
5375
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Icon, { name: "arrow-left", size: "xs", color: "primary" }),
|
|
5376
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.ButtonText, { color: "$primary", fontSize: "$2", children: "Back to setup" })
|
|
5377
|
+
] }),
|
|
5378
|
+
/* @__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." }),
|
|
5379
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Anchor, { href: VIDEO_URL, target: "_blank", style: { textDecorationLine: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
5380
|
+
import_ui15.Card,
|
|
5381
|
+
{
|
|
5382
|
+
backgroundColor: "$backgroundHover",
|
|
5383
|
+
gap: "$2",
|
|
5384
|
+
paddingVertical: "$4",
|
|
5385
|
+
paddingHorizontal: "$4",
|
|
5386
|
+
hoverStyle: { opacity: 0.9 },
|
|
5387
|
+
children: [
|
|
5388
|
+
/* @__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" }) }) }),
|
|
5389
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.XStack, { justifyContent: "center", paddingVertical: "$6", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
5390
|
+
import_ui15.YStack,
|
|
5391
|
+
{
|
|
5392
|
+
width: 56,
|
|
5393
|
+
height: 56,
|
|
5394
|
+
borderRadius: "$full",
|
|
5395
|
+
backgroundColor: "$background",
|
|
5396
|
+
alignItems: "center",
|
|
5397
|
+
justifyContent: "center",
|
|
5398
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Icon, { name: "play", size: "md", color: "primary" })
|
|
5399
|
+
}
|
|
5400
|
+
) }),
|
|
5401
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.YStack, { gap: "$1", children: [
|
|
5402
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$2", fontWeight: "700", children: "Getting started with AI credits" }),
|
|
5403
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$1", secondary: true, children: "Wallet \u2192 buy credits \u2192 connect Antseed" })
|
|
5404
|
+
] })
|
|
5405
|
+
]
|
|
5406
|
+
}
|
|
5407
|
+
) }),
|
|
5408
|
+
/* @__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: [
|
|
5409
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.XStack, { gap: "$3", alignItems: "center", flex: 1, children: [
|
|
5410
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Icon, { name: "file-text", size: "md", color: "muted" }),
|
|
5411
|
+
/* @__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: [
|
|
5412
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.Text, { fontSize: "$2", fontWeight: "700", children: [
|
|
5413
|
+
"Full written guide",
|
|
5414
|
+
" "
|
|
5415
|
+
] }),
|
|
5416
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$2", secondary: true, children: "Step-by-step walkthrough with screenshots, on Notion" })
|
|
5417
|
+
] }) })
|
|
5418
|
+
] }),
|
|
5419
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Icon, { name: "external-link", size: "xs", color: "muted" })
|
|
5420
|
+
] }) }) }),
|
|
5421
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.YStack, { gap: "$3", children: [
|
|
5422
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { variant: "label", secondary: true, fontSize: "$1", fontWeight: "700", letterSpacing: 1, children: "QUICK SUMMARY" }),
|
|
5423
|
+
/* @__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: [
|
|
5424
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
5425
|
+
import_ui15.YStack,
|
|
5426
|
+
{
|
|
5427
|
+
width: 24,
|
|
5428
|
+
height: 24,
|
|
5429
|
+
borderRadius: "$full",
|
|
5430
|
+
backgroundColor: "$backgroundHover",
|
|
5431
|
+
alignItems: "center",
|
|
5432
|
+
justifyContent: "center",
|
|
5433
|
+
flexShrink: 0,
|
|
5434
|
+
marginTop: 2,
|
|
5435
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$1", fontWeight: "700", color: "$secondary", children: step.index })
|
|
5436
|
+
}
|
|
5437
|
+
),
|
|
5438
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.YStack, { flex: 1, gap: "$1", children: [
|
|
5439
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui15.XStack, { gap: "$2", alignItems: "center", flexWrap: "wrap", children: [
|
|
5440
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$2", fontWeight: "700", children: step.title }),
|
|
5441
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Badge, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.BadgeText, { children: step.tabLabel }) })
|
|
5442
|
+
] }),
|
|
5443
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui15.Text, { fontSize: "$2", secondary: true, lineHeight: "$3", children: step.description })
|
|
5444
|
+
] })
|
|
5445
|
+
] }, step.index)) }),
|
|
5446
|
+
/* @__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." })
|
|
5447
|
+
] })
|
|
5448
|
+
] });
|
|
5449
|
+
}
|
|
5450
|
+
var import_ui15, import_jsx_runtime13, VIDEO_URL, WRITTEN_GUIDE_URL, QUICK_SUMMARY_STEPS;
|
|
5451
|
+
var init_HowToUseView = __esm({
|
|
5452
|
+
"src/components/setup/HowToUseView.tsx"() {
|
|
5453
|
+
"use strict";
|
|
5454
|
+
import_ui15 = require("@goodwidget/ui");
|
|
5455
|
+
import_jsx_runtime13 = require("react/jsx-runtime");
|
|
5456
|
+
VIDEO_URL = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
|
|
5457
|
+
WRITTEN_GUIDE_URL = "https://app.notion.com/p/gooddollar/Full-Setup-Walkthrough-Widget-AntSeed-VPR-3c0f258232f08184bee9cd440cc93059";
|
|
5458
|
+
QUICK_SUMMARY_STEPS = [
|
|
5459
|
+
{
|
|
5460
|
+
index: 1,
|
|
5461
|
+
title: "First, connect your wallet",
|
|
5462
|
+
tabLabel: "Buy",
|
|
5463
|
+
description: "Any wallet holding G$ works. Verified GoodDollar wallets get the bonus automatically."
|
|
5464
|
+
},
|
|
5465
|
+
{
|
|
5466
|
+
index: 2,
|
|
5467
|
+
title: "Then complete the one-time setup",
|
|
5468
|
+
tabLabel: "Buy",
|
|
5469
|
+
description: "Download Antseed, generate your signer key, and authorize your wallet \u2014 three quick taps."
|
|
5470
|
+
},
|
|
5471
|
+
{
|
|
5472
|
+
index: 3,
|
|
5473
|
+
title: "Head to Manage to buy or stream credits",
|
|
5474
|
+
tabLabel: "Manage",
|
|
5475
|
+
description: "Deposit once (+10%) or stream continuously (+20%), then confirm."
|
|
5476
|
+
},
|
|
5477
|
+
{
|
|
5478
|
+
index: 4,
|
|
5479
|
+
title: "Finally, connect Antseed to start using them",
|
|
5480
|
+
tabLabel: "Connect",
|
|
5481
|
+
description: 'Import your signer key \u2014 no separate "start" step, it just works from there.'
|
|
5482
|
+
}
|
|
5483
|
+
];
|
|
5484
|
+
}
|
|
5485
|
+
});
|
|
5486
|
+
|
|
5487
|
+
// src/components/setup/SetupFaqView.tsx
|
|
5488
|
+
function FaqItem({ question, answer, expanded, onToggle }) {
|
|
5489
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_ui16.YStack, { gap: "$1", children: [
|
|
5490
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
5491
|
+
import_ui16.XStack,
|
|
5492
|
+
{
|
|
5493
|
+
justifyContent: "space-between",
|
|
5494
|
+
alignItems: "center",
|
|
5495
|
+
gap: "$2",
|
|
5496
|
+
onPress: onToggle,
|
|
5497
|
+
cursor: "pointer",
|
|
5498
|
+
children: [
|
|
5499
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.Text, { fontSize: "$2", fontWeight: "600", flex: 1, children: question }),
|
|
5500
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.Icon, { name: expanded ? "chevron-up" : "chevron-down", size: "xs", color: "muted" })
|
|
5501
|
+
]
|
|
5502
|
+
}
|
|
5503
|
+
),
|
|
5504
|
+
expanded && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.Text, { fontSize: "$2", secondary: true, lineHeight: "$3", children: answer })
|
|
5505
|
+
] });
|
|
5506
|
+
}
|
|
5507
|
+
function SetupFaqView({ onBack }) {
|
|
5508
|
+
const [expandedId, setExpandedId] = (0, import_react13.useState)(null);
|
|
5509
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_ui16.YStack, { gap: "$4", children: [
|
|
5510
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_ui16.Button, { variant: "text", alignSelf: "flex-start", onPress: onBack, gap: "$1", children: [
|
|
5511
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.Icon, { name: "arrow-left", size: "xs", color: "primary" }),
|
|
5512
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.ButtonText, { color: "$primary", fontSize: "$2", children: "Back to setup" })
|
|
5513
|
+
] }),
|
|
5514
|
+
/* @__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: [
|
|
5515
|
+
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui16.Separator, {}),
|
|
5516
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
5517
|
+
FaqItem,
|
|
5518
|
+
{
|
|
5519
|
+
question: item.question,
|
|
5520
|
+
answer: item.answer,
|
|
5521
|
+
expanded: expandedId === item.id,
|
|
5522
|
+
onToggle: () => {
|
|
5523
|
+
setExpandedId((current) => current === item.id ? null : item.id);
|
|
5524
|
+
}
|
|
5525
|
+
}
|
|
5526
|
+
)
|
|
5527
|
+
] }, item.id)) }) })
|
|
5528
|
+
] });
|
|
5529
|
+
}
|
|
5530
|
+
var import_react13, import_ui16, import_jsx_runtime14, SETUP_FAQ_ITEMS;
|
|
5531
|
+
var init_SetupFaqView = __esm({
|
|
5532
|
+
"src/components/setup/SetupFaqView.tsx"() {
|
|
5533
|
+
"use strict";
|
|
5534
|
+
import_react13 = require("react");
|
|
5535
|
+
import_ui16 = require("@goodwidget/ui");
|
|
5536
|
+
import_jsx_runtime14 = require("react/jsx-runtime");
|
|
5537
|
+
SETUP_FAQ_ITEMS = [
|
|
5538
|
+
{
|
|
5539
|
+
id: "goodwallet-only",
|
|
5540
|
+
question: "I only claim UBI with GoodWallet \u2014 can I still use this?",
|
|
5541
|
+
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."
|
|
5542
|
+
},
|
|
5543
|
+
{
|
|
5544
|
+
id: "ubi-savings",
|
|
5545
|
+
question: "Will this ever touch my daily UBI savings?",
|
|
5546
|
+
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."
|
|
5547
|
+
},
|
|
5548
|
+
{
|
|
5549
|
+
id: "deposit-vs-stream",
|
|
5550
|
+
question: "Deposit or stream \u2014 which should I pick?",
|
|
5551
|
+
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."
|
|
5552
|
+
},
|
|
5553
|
+
{
|
|
5554
|
+
id: "lost-signer-key",
|
|
5555
|
+
question: "What if I lose my signer key?",
|
|
5556
|
+
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.'
|
|
5557
|
+
},
|
|
5558
|
+
{
|
|
5559
|
+
id: "no-code",
|
|
5560
|
+
question: "Do I need to know how to code?",
|
|
5561
|
+
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."
|
|
5562
|
+
},
|
|
5563
|
+
{
|
|
5564
|
+
id: "unused-credits",
|
|
5565
|
+
question: "Can I get unused credits back?",
|
|
5566
|
+
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."
|
|
5567
|
+
},
|
|
5568
|
+
{
|
|
5569
|
+
id: "compatible-tools",
|
|
5570
|
+
question: "Which tools can I actually use my credits with?",
|
|
5571
|
+
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."
|
|
5572
|
+
},
|
|
5573
|
+
{
|
|
5574
|
+
id: "antseed-safe",
|
|
5575
|
+
question: "Is Antseed safe? Can I check it myself?",
|
|
5576
|
+
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."
|
|
5577
|
+
}
|
|
5578
|
+
];
|
|
5579
|
+
}
|
|
5580
|
+
});
|
|
5581
|
+
|
|
5582
|
+
// src/components/setup/SetupOnboardingFlow.tsx
|
|
5583
|
+
function SetupOnboardingFlow({ state, actions }) {
|
|
5584
|
+
const [downloadOpened, setDownloadOpened] = (0, import_react14.useState)(false);
|
|
5585
|
+
const [drawerOpen, setDrawerOpen] = (0, import_react14.useState)(false);
|
|
5586
|
+
const [drawerStep, setDrawerStep] = (0, import_react14.useState)(null);
|
|
5587
|
+
const hasSignerKey = Boolean(state.buyerPubKey);
|
|
5588
|
+
const downloadCompleted = downloadOpened || hasSignerKey;
|
|
5589
|
+
const steps = [
|
|
5590
|
+
{
|
|
5591
|
+
id: "download",
|
|
5592
|
+
title: "Download Antseed",
|
|
5593
|
+
description: "The app that runs your credits locally \u2014 required once",
|
|
5594
|
+
status: downloadCompleted ? "completed" : "ready"
|
|
5595
|
+
},
|
|
5596
|
+
{
|
|
5597
|
+
id: "signer",
|
|
5598
|
+
title: "Signer key",
|
|
5599
|
+
description: "Generate or import \u2014 separate from your wallet",
|
|
5600
|
+
status: !downloadCompleted ? "pending" : hasSignerKey ? "completed" : "ready"
|
|
5601
|
+
},
|
|
5602
|
+
{
|
|
5603
|
+
id: "authorize",
|
|
5604
|
+
title: "Authorize Wallet",
|
|
5605
|
+
description: "One-time permission \u2014 scoped to Base credits",
|
|
5606
|
+
status: !hasSignerKey ? "pending" : state.operatorConsented ? "completed" : "ready"
|
|
5607
|
+
}
|
|
5608
|
+
];
|
|
5609
|
+
const openSignerDrawer = (0, import_react14.useCallback)(() => {
|
|
5610
|
+
setDrawerStep("signer");
|
|
5611
|
+
setDrawerOpen(true);
|
|
5612
|
+
}, []);
|
|
5613
|
+
const handleSignerReady = (0, import_react14.useCallback)(() => {
|
|
5614
|
+
if (state.operatorConsented) {
|
|
5615
|
+
setDrawerOpen(false);
|
|
5616
|
+
setDrawerStep(null);
|
|
5617
|
+
return;
|
|
5618
|
+
}
|
|
5619
|
+
setDrawerStep("authorize");
|
|
5620
|
+
}, [state.operatorConsented]);
|
|
5621
|
+
const handleStepPress = (0, import_react14.useCallback)(
|
|
5622
|
+
(stepId) => {
|
|
5623
|
+
if (stepId === "download") {
|
|
5624
|
+
if (typeof window !== "undefined") {
|
|
5625
|
+
window.open(ANTSEED_DOWNLOAD_URL, "_blank", "noopener,noreferrer");
|
|
5626
|
+
}
|
|
5627
|
+
setDownloadOpened(true);
|
|
5628
|
+
return;
|
|
5629
|
+
}
|
|
5630
|
+
if (stepId === "signer" && downloadCompleted) {
|
|
5631
|
+
openSignerDrawer();
|
|
5632
|
+
}
|
|
5633
|
+
if (stepId === "authorize" && hasSignerKey) {
|
|
5634
|
+
setDrawerStep("authorize");
|
|
5635
|
+
setDrawerOpen(true);
|
|
5636
|
+
}
|
|
5637
|
+
},
|
|
5638
|
+
[downloadCompleted, hasSignerKey, openSignerDrawer]
|
|
5639
|
+
);
|
|
5640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
5641
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
5642
|
+
import_ui17.Stepper,
|
|
5643
|
+
{
|
|
5644
|
+
steps,
|
|
5645
|
+
activeStepId: downloadCompleted ? hasSignerKey ? "authorize" : "signer" : "download",
|
|
5646
|
+
onStepPress: handleStepPress
|
|
5647
|
+
}
|
|
5648
|
+
),
|
|
5649
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
5650
|
+
import_ui17.Drawer,
|
|
5651
|
+
{
|
|
5652
|
+
open: drawerOpen && drawerStep !== null,
|
|
5653
|
+
onClose: () => {
|
|
5654
|
+
setDrawerOpen(false);
|
|
5655
|
+
setDrawerStep(null);
|
|
5656
|
+
},
|
|
5657
|
+
height: "full",
|
|
5658
|
+
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: [
|
|
5659
|
+
drawerStep === "signer" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SignerKeyPanel, { state, actions, onProceed: handleSignerReady }) : null,
|
|
5660
|
+
drawerStep === "authorize" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
5661
|
+
OperatorConsentStep,
|
|
5662
|
+
{
|
|
5663
|
+
embedded: true,
|
|
5664
|
+
buyerPubKey: state.buyerPubKey,
|
|
5665
|
+
buyerPrvKey: state.buyerPrvKey ?? null,
|
|
5666
|
+
operatorSignature: state.operatorSignature ?? null,
|
|
5667
|
+
operatorConsented: state.operatorConsented,
|
|
5668
|
+
operatorConsentPending: state.operatorConsentPending,
|
|
5669
|
+
onSign: actions.signOperatorConsent
|
|
5670
|
+
}
|
|
5671
|
+
) : null
|
|
5672
|
+
] }) })
|
|
5673
|
+
}
|
|
5674
|
+
)
|
|
5675
|
+
] });
|
|
5676
|
+
}
|
|
5677
|
+
var import_react14, import_ui17, import_jsx_runtime15, ANTSEED_DOWNLOAD_URL;
|
|
5678
|
+
var init_SetupOnboardingFlow = __esm({
|
|
5679
|
+
"src/components/setup/SetupOnboardingFlow.tsx"() {
|
|
5680
|
+
"use strict";
|
|
5681
|
+
import_react14 = require("react");
|
|
5682
|
+
import_ui17 = require("@goodwidget/ui");
|
|
5683
|
+
init_SignerKeyPanel();
|
|
5684
|
+
init_OperatorConsentStep();
|
|
5685
|
+
import_jsx_runtime15 = require("react/jsx-runtime");
|
|
5686
|
+
ANTSEED_DOWNLOAD_URL = "https://antseed.com";
|
|
5687
|
+
}
|
|
5688
|
+
});
|
|
5689
|
+
|
|
5690
|
+
// src/components/flow/purchaseFlowUtils.ts
|
|
5691
|
+
function isSelectedDerivedBuyer(state) {
|
|
5692
|
+
if (!state.buyerPubKey || !state.derivedBuyerAddress) return false;
|
|
5693
|
+
return state.buyerPubKey.toLowerCase() === state.derivedBuyerAddress.toLowerCase();
|
|
5694
|
+
}
|
|
5695
|
+
function mapStatusToActiveStep(state, buyerPubKeySaved) {
|
|
5696
|
+
if (state.operatorConsented) return "pay";
|
|
5697
|
+
if (!state.buyerPubKey) return "buyer_key";
|
|
5698
|
+
if (!state.buyerPrvKey && !state.operatorSignature) return "buyer_key";
|
|
5699
|
+
if (isSelectedDerivedBuyer(state) && state.buyerPrvKey && !buyerPubKeySaved) return "buyer_key";
|
|
5700
|
+
if (!state.operatorConsented) return "consent";
|
|
5701
|
+
if (state.status === "purchase_setup" || state.status === "quote_ready" || state.status === "payment_pending" || state.status === "payment_confirmed" || state.status === "payment_failed")
|
|
5702
|
+
return "pay";
|
|
5703
|
+
return null;
|
|
5704
|
+
}
|
|
5705
|
+
function getAiCreditsActiveFlowStep(state, buyerPubKeySaved) {
|
|
5706
|
+
return mapStatusToActiveStep(state, buyerPubKeySaved);
|
|
5707
|
+
}
|
|
5708
|
+
function getActiveFlowStepActionLabel(state, step, buyerPubKeySaved) {
|
|
5709
|
+
if (!step) return null;
|
|
5710
|
+
switch (step) {
|
|
5711
|
+
case "buyer_key":
|
|
5712
|
+
if (!state.buyerPubKey) return "Sign & Generate Key";
|
|
5713
|
+
if (!buyerPubKeySaved) return "Continue Signer Key";
|
|
5714
|
+
return "View Signer Key";
|
|
5715
|
+
case "consent":
|
|
5716
|
+
if (state.operatorConsentPending) return "Submitting Authorization\u2026";
|
|
5717
|
+
return state.operatorConsented ? "View Authorization" : "Authorize Wallet";
|
|
4107
5718
|
case "pay":
|
|
4108
5719
|
return "Set Amounts & Pay";
|
|
4109
5720
|
default:
|
|
@@ -4134,19 +5745,20 @@ function AiCreditsFlowStepper({
|
|
|
4134
5745
|
if (step === "pay" && (state.status === "payment_pending" || state.status === "payment_confirmed")) {
|
|
4135
5746
|
return "active";
|
|
4136
5747
|
}
|
|
5748
|
+
if (step === "consent" && state.operatorConsentPending) return "active";
|
|
4137
5749
|
return "ready";
|
|
4138
5750
|
}
|
|
4139
5751
|
const steps = [
|
|
4140
5752
|
{
|
|
4141
5753
|
id: "buyer_key",
|
|
4142
|
-
title: "
|
|
4143
|
-
description: "Generate or
|
|
5754
|
+
title: "Signer Key",
|
|
5755
|
+
description: "Generate or import your AI credits signer key",
|
|
4144
5756
|
status: getStepStatus("buyer_key")
|
|
4145
5757
|
},
|
|
4146
5758
|
{
|
|
4147
5759
|
id: "consent",
|
|
4148
|
-
title: "
|
|
4149
|
-
description: "
|
|
5760
|
+
title: "Authorize Wallet",
|
|
5761
|
+
description: state.operatorConsentPending ? "Submitting authorization\u2026" : "Authorize GoodDollar to manage your Base credits",
|
|
4150
5762
|
status: getStepStatus("consent")
|
|
4151
5763
|
},
|
|
4152
5764
|
{
|
|
@@ -4161,23 +5773,23 @@ function AiCreditsFlowStepper({
|
|
|
4161
5773
|
if (!step || step.status === "completed" || step.status === "pending") return;
|
|
4162
5774
|
onStepPress?.(stepId);
|
|
4163
5775
|
}
|
|
4164
|
-
return /* @__PURE__ */ (0,
|
|
4165
|
-
|
|
5776
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
5777
|
+
import_ui18.Stepper,
|
|
4166
5778
|
{
|
|
4167
5779
|
steps,
|
|
4168
5780
|
activeStepId: activeStep,
|
|
4169
5781
|
onStepPress: onStepPress ? handleStepPress : void 0,
|
|
4170
|
-
header: /* @__PURE__ */ (0,
|
|
5782
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui18.Heading, { level: 5, secondary: true, children: "Purchase Flow" })
|
|
4171
5783
|
}
|
|
4172
5784
|
);
|
|
4173
5785
|
}
|
|
4174
|
-
var
|
|
5786
|
+
var import_ui18, import_jsx_runtime16, STEP_ORDER;
|
|
4175
5787
|
var init_AiCreditsFlowStepper = __esm({
|
|
4176
5788
|
"src/components/flow/AiCreditsFlowStepper.tsx"() {
|
|
4177
5789
|
"use strict";
|
|
4178
|
-
|
|
5790
|
+
import_ui18 = require("@goodwidget/ui");
|
|
4179
5791
|
init_purchaseFlowUtils();
|
|
4180
|
-
|
|
5792
|
+
import_jsx_runtime16 = require("react/jsx-runtime");
|
|
4181
5793
|
STEP_ORDER = ["buyer_key", "consent", "pay"];
|
|
4182
5794
|
}
|
|
4183
5795
|
});
|
|
@@ -4189,21 +5801,21 @@ function AiCreditsPurchaseFlow({
|
|
|
4189
5801
|
isPending,
|
|
4190
5802
|
onPay
|
|
4191
5803
|
}) {
|
|
4192
|
-
const [buyerPubKeySaved, setBuyerPubKeySaved] = (0,
|
|
5804
|
+
const [buyerPubKeySaved, setBuyerPubKeySaved] = (0, import_react15.useState)(false);
|
|
4193
5805
|
const activeStep = getAiCreditsActiveFlowStep(state, buyerPubKeySaved);
|
|
4194
|
-
const [drawerOpen, setDrawerOpen] = (0,
|
|
4195
|
-
const [drawerStep, setDrawerStep] = (0,
|
|
4196
|
-
const prevActiveStepRef = (0,
|
|
4197
|
-
const goodIdTabPendingRef = (0,
|
|
4198
|
-
(0,
|
|
5806
|
+
const [drawerOpen, setDrawerOpen] = (0, import_react15.useState)(false);
|
|
5807
|
+
const [drawerStep, setDrawerStep] = (0, import_react15.useState)(null);
|
|
5808
|
+
const prevActiveStepRef = (0, import_react15.useRef)(null);
|
|
5809
|
+
const goodIdTabPendingRef = (0, import_react15.useRef)(false);
|
|
5810
|
+
(0, import_react15.useEffect)(() => {
|
|
4199
5811
|
setBuyerPubKeySaved(false);
|
|
4200
5812
|
}, [state.buyerPubKey]);
|
|
4201
|
-
(0,
|
|
5813
|
+
(0, import_react15.useEffect)(() => {
|
|
4202
5814
|
if (activeStep !== "consent" || state.operatorConsented) return;
|
|
4203
5815
|
if (!state.address || !state.buyerPubKey) return;
|
|
4204
5816
|
void actions.syncOperatorConsentFromChain();
|
|
4205
5817
|
}, [activeStep, state.operatorConsented, state.address, state.buyerPubKey, actions]);
|
|
4206
|
-
(0,
|
|
5818
|
+
(0, import_react15.useEffect)(() => {
|
|
4207
5819
|
if (!activeStep) {
|
|
4208
5820
|
setDrawerOpen(false);
|
|
4209
5821
|
setDrawerStep(null);
|
|
@@ -4212,14 +5824,12 @@ function AiCreditsPurchaseFlow({
|
|
|
4212
5824
|
}
|
|
4213
5825
|
const previousStep = prevActiveStepRef.current;
|
|
4214
5826
|
prevActiveStepRef.current = activeStep;
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
setDrawerOpen(false);
|
|
4218
|
-
} else if (previousStep !== activeStep) {
|
|
5827
|
+
if (previousStep != null && previousStep !== activeStep) {
|
|
5828
|
+
setDrawerStep(activeStep);
|
|
4219
5829
|
setDrawerOpen(true);
|
|
4220
5830
|
}
|
|
4221
5831
|
}, [activeStep]);
|
|
4222
|
-
(0,
|
|
5832
|
+
(0, import_react15.useEffect)(() => {
|
|
4223
5833
|
if (typeof window === "undefined") return;
|
|
4224
5834
|
const onFocus = () => {
|
|
4225
5835
|
if (!goodIdTabPendingRef.current) return;
|
|
@@ -4232,7 +5842,7 @@ function AiCreditsPurchaseFlow({
|
|
|
4232
5842
|
window.addEventListener("focus", onFocus);
|
|
4233
5843
|
return () => window.removeEventListener("focus", onFocus);
|
|
4234
5844
|
}, [activeStep]);
|
|
4235
|
-
const handleVerifyGoodId = (0,
|
|
5845
|
+
const handleVerifyGoodId = (0, import_react15.useCallback)(async () => {
|
|
4236
5846
|
try {
|
|
4237
5847
|
const started = await actions.verifyGoodId();
|
|
4238
5848
|
if (started) {
|
|
@@ -4245,7 +5855,7 @@ function AiCreditsPurchaseFlow({
|
|
|
4245
5855
|
}
|
|
4246
5856
|
}
|
|
4247
5857
|
}, [actions, activeStep]);
|
|
4248
|
-
const openDrawer = (0,
|
|
5858
|
+
const openDrawer = (0, import_react15.useCallback)(
|
|
4249
5859
|
(step) => {
|
|
4250
5860
|
if (step !== activeStep && !(step === "pay" && state.status === "payment_failed")) return;
|
|
4251
5861
|
setDrawerStep(step);
|
|
@@ -4253,7 +5863,7 @@ function AiCreditsPurchaseFlow({
|
|
|
4253
5863
|
},
|
|
4254
5864
|
[activeStep, state.status]
|
|
4255
5865
|
);
|
|
4256
|
-
const handleStepPress = (0,
|
|
5866
|
+
const handleStepPress = (0, import_react15.useCallback)(
|
|
4257
5867
|
(stepId) => {
|
|
4258
5868
|
openDrawer(stepId);
|
|
4259
5869
|
},
|
|
@@ -4264,7 +5874,7 @@ function AiCreditsPurchaseFlow({
|
|
|
4264
5874
|
if (!step) return null;
|
|
4265
5875
|
switch (step) {
|
|
4266
5876
|
case "buyer_key":
|
|
4267
|
-
return /* @__PURE__ */ (0,
|
|
5877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4268
5878
|
BuyerKeyPanel,
|
|
4269
5879
|
{
|
|
4270
5880
|
embedded: true,
|
|
@@ -4276,18 +5886,20 @@ function AiCreditsPurchaseFlow({
|
|
|
4276
5886
|
}
|
|
4277
5887
|
);
|
|
4278
5888
|
case "consent":
|
|
4279
|
-
return /* @__PURE__ */ (0,
|
|
5889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4280
5890
|
OperatorConsentStep,
|
|
4281
5891
|
{
|
|
4282
5892
|
embedded: true,
|
|
4283
5893
|
buyerPubKey: state.buyerPubKey,
|
|
4284
5894
|
buyerPrvKey: state.buyerPrvKey ?? null,
|
|
5895
|
+
operatorSignature: state.operatorSignature ?? null,
|
|
4285
5896
|
operatorConsented: state.operatorConsented,
|
|
5897
|
+
operatorConsentPending: state.operatorConsentPending,
|
|
4286
5898
|
onSign: actions.signOperatorConsent
|
|
4287
5899
|
}
|
|
4288
5900
|
);
|
|
4289
5901
|
case "pay":
|
|
4290
|
-
return /* @__PURE__ */ (0,
|
|
5902
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4291
5903
|
AmountPicker,
|
|
4292
5904
|
{
|
|
4293
5905
|
embedded: true,
|
|
@@ -4310,8 +5922,8 @@ function AiCreditsPurchaseFlow({
|
|
|
4310
5922
|
return null;
|
|
4311
5923
|
}
|
|
4312
5924
|
}
|
|
4313
|
-
return /* @__PURE__ */ (0,
|
|
4314
|
-
/* @__PURE__ */ (0,
|
|
5925
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
5926
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4315
5927
|
AiCreditsFlowStepper,
|
|
4316
5928
|
{
|
|
4317
5929
|
state,
|
|
@@ -4319,8 +5931,8 @@ function AiCreditsPurchaseFlow({
|
|
|
4319
5931
|
onStepPress: handleStepPress
|
|
4320
5932
|
}
|
|
4321
5933
|
),
|
|
4322
|
-
!drawerOpen && actionLabel && activeStep && /* @__PURE__ */ (0,
|
|
4323
|
-
|
|
5934
|
+
!drawerOpen && actionLabel && activeStep && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
5935
|
+
import_ui19.Button,
|
|
4324
5936
|
{
|
|
4325
5937
|
fullWidth: true,
|
|
4326
5938
|
size: "sm",
|
|
@@ -4328,35 +5940,35 @@ function AiCreditsPurchaseFlow({
|
|
|
4328
5940
|
onPress: () => {
|
|
4329
5941
|
openDrawer(activeStep);
|
|
4330
5942
|
},
|
|
4331
|
-
children: /* @__PURE__ */ (0,
|
|
5943
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui19.ButtonText, { children: actionLabel })
|
|
4332
5944
|
}
|
|
4333
5945
|
),
|
|
4334
|
-
/* @__PURE__ */ (0,
|
|
4335
|
-
|
|
5946
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
5947
|
+
import_ui19.Drawer,
|
|
4336
5948
|
{
|
|
4337
5949
|
open: drawerOpen && drawerStep !== null,
|
|
4338
5950
|
onClose: () => {
|
|
4339
5951
|
setDrawerOpen(false);
|
|
4340
5952
|
},
|
|
4341
5953
|
height: "full",
|
|
4342
|
-
children: /* @__PURE__ */ (0,
|
|
5954
|
+
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) }) })
|
|
4343
5955
|
}
|
|
4344
5956
|
)
|
|
4345
5957
|
] });
|
|
4346
5958
|
}
|
|
4347
|
-
var
|
|
5959
|
+
var import_react15, import_ui19, import_jsx_runtime17;
|
|
4348
5960
|
var init_AiCreditsPurchaseFlow = __esm({
|
|
4349
5961
|
"src/components/flow/AiCreditsPurchaseFlow.tsx"() {
|
|
4350
5962
|
"use strict";
|
|
4351
|
-
|
|
4352
|
-
|
|
5963
|
+
import_react15 = require("react");
|
|
5964
|
+
import_ui19 = require("@goodwidget/ui");
|
|
4353
5965
|
init_AmountPicker();
|
|
4354
5966
|
init_BuyerKeyPanel();
|
|
4355
5967
|
init_OperatorConsentStep();
|
|
4356
5968
|
init_AiCreditsFlowStepper();
|
|
4357
5969
|
init_purchaseFlowUtils();
|
|
4358
5970
|
init_styles();
|
|
4359
|
-
|
|
5971
|
+
import_jsx_runtime17 = require("react/jsx-runtime");
|
|
4360
5972
|
}
|
|
4361
5973
|
});
|
|
4362
5974
|
|
|
@@ -4366,25 +5978,137 @@ var init_components = __esm({
|
|
|
4366
5978
|
"use strict";
|
|
4367
5979
|
init_cards();
|
|
4368
5980
|
init_AiCreditsHero();
|
|
4369
|
-
init_BuyCreditsFaq();
|
|
4370
5981
|
init_CreditsManagementCard();
|
|
4371
5982
|
init_BuyerOperatorCard();
|
|
4372
5983
|
init_SetupSnippet();
|
|
4373
5984
|
init_HistoryTab();
|
|
5985
|
+
init_SetupGuidanceCard();
|
|
5986
|
+
init_HowToUseView();
|
|
5987
|
+
init_SetupFaqView();
|
|
5988
|
+
init_SetupOnboardingFlow();
|
|
4374
5989
|
init_AiCreditsFlowStepper();
|
|
4375
5990
|
init_AiCreditsPurchaseFlow();
|
|
4376
5991
|
}
|
|
4377
5992
|
});
|
|
4378
5993
|
|
|
5994
|
+
// src/components/shared/WalletChip.tsx
|
|
5995
|
+
function shortAddress2(address) {
|
|
5996
|
+
return `${address.slice(0, 5)}\u2026${address.slice(-3)}`;
|
|
5997
|
+
}
|
|
5998
|
+
function WalletChip({
|
|
5999
|
+
address,
|
|
6000
|
+
onDisconnect,
|
|
6001
|
+
disconnectLabel = "Disconnect",
|
|
6002
|
+
disconnectIcon = "log-out",
|
|
6003
|
+
disabled = false
|
|
6004
|
+
}) {
|
|
6005
|
+
const [isMenuOpen, setIsMenuOpen] = (0, import_react16.useState)(false);
|
|
6006
|
+
const [disconnectMessage, setDisconnectMessage] = (0, import_react16.useState)(null);
|
|
6007
|
+
(0, import_react16.useEffect)(() => {
|
|
6008
|
+
if (disabled) setIsMenuOpen(false);
|
|
6009
|
+
}, [disabled]);
|
|
6010
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_ui20.XStack, { position: "relative", alignItems: "center", opacity: disabled ? 0.5 : 1, children: [
|
|
6011
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
6012
|
+
import_ui20.XStack,
|
|
6013
|
+
{
|
|
6014
|
+
gap: "$1.5",
|
|
6015
|
+
alignItems: "center",
|
|
6016
|
+
paddingHorizontal: "$2",
|
|
6017
|
+
paddingVertical: "$1",
|
|
6018
|
+
borderRadius: "$full",
|
|
6019
|
+
borderWidth: 1,
|
|
6020
|
+
borderColor: "$borderColor",
|
|
6021
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
6022
|
+
onPress: () => {
|
|
6023
|
+
if (disabled) return;
|
|
6024
|
+
setDisconnectMessage(null);
|
|
6025
|
+
setIsMenuOpen((open) => !open);
|
|
6026
|
+
},
|
|
6027
|
+
"aria-label": "Wallet options",
|
|
6028
|
+
"aria-disabled": disabled,
|
|
6029
|
+
children: [
|
|
6030
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_ui20.YStack, { width: 6, height: 6, borderRadius: "$full", backgroundColor: "$success" }),
|
|
6031
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_ui20.Text, { fontSize: "$1", numberOfLines: 1, children: address ? shortAddress2(address) : "" }),
|
|
6032
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_ui20.Icon, { name: "chevron-down", size: "2xs", color: "muted" })
|
|
6033
|
+
]
|
|
6034
|
+
}
|
|
6035
|
+
),
|
|
6036
|
+
isMenuOpen && !disabled && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
6037
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
6038
|
+
import_ui20.XStack,
|
|
6039
|
+
{
|
|
6040
|
+
position: "fixed",
|
|
6041
|
+
top: 0,
|
|
6042
|
+
left: 0,
|
|
6043
|
+
right: 0,
|
|
6044
|
+
bottom: 0,
|
|
6045
|
+
zIndex: 100,
|
|
6046
|
+
onPress: () => setIsMenuOpen(false)
|
|
6047
|
+
}
|
|
6048
|
+
),
|
|
6049
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
6050
|
+
import_ui20.YStack,
|
|
6051
|
+
{
|
|
6052
|
+
position: "absolute",
|
|
6053
|
+
top: "100%",
|
|
6054
|
+
right: 0,
|
|
6055
|
+
marginTop: "$1",
|
|
6056
|
+
backgroundColor: "$background",
|
|
6057
|
+
borderWidth: 1,
|
|
6058
|
+
borderColor: "$borderColor",
|
|
6059
|
+
borderRadius: "$3",
|
|
6060
|
+
padding: "$1",
|
|
6061
|
+
minWidth: 132,
|
|
6062
|
+
zIndex: 101,
|
|
6063
|
+
children: [
|
|
6064
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
6065
|
+
import_ui20.Button,
|
|
6066
|
+
{
|
|
6067
|
+
size: "sm",
|
|
6068
|
+
variant: "list",
|
|
6069
|
+
height: "$6",
|
|
6070
|
+
paddingHorizontal: "$2",
|
|
6071
|
+
gap: "$1.5",
|
|
6072
|
+
onPress: async () => {
|
|
6073
|
+
if (!onDisconnect) {
|
|
6074
|
+
setDisconnectMessage("Disconnect should be done in your wallet's session");
|
|
6075
|
+
return;
|
|
6076
|
+
}
|
|
6077
|
+
setIsMenuOpen(false);
|
|
6078
|
+
await onDisconnect();
|
|
6079
|
+
},
|
|
6080
|
+
children: [
|
|
6081
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_ui20.Icon, { name: disconnectIcon, size: "xs", color: "muted" }),
|
|
6082
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_ui20.ButtonText, { fontSize: "$2", children: disconnectLabel })
|
|
6083
|
+
]
|
|
6084
|
+
}
|
|
6085
|
+
),
|
|
6086
|
+
disconnectMessage && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_ui20.Text, { variant: "caption", tone: "secondary", padding: "$2", children: disconnectMessage })
|
|
6087
|
+
]
|
|
6088
|
+
}
|
|
6089
|
+
)
|
|
6090
|
+
] })
|
|
6091
|
+
] });
|
|
6092
|
+
}
|
|
6093
|
+
var import_react16, import_ui20, import_jsx_runtime18;
|
|
6094
|
+
var init_WalletChip = __esm({
|
|
6095
|
+
"src/components/shared/WalletChip.tsx"() {
|
|
6096
|
+
"use strict";
|
|
6097
|
+
import_react16 = require("react");
|
|
6098
|
+
import_ui20 = require("@goodwidget/ui");
|
|
6099
|
+
import_jsx_runtime18 = require("react/jsx-runtime");
|
|
6100
|
+
}
|
|
6101
|
+
});
|
|
6102
|
+
|
|
4379
6103
|
// src/AiCreditsWidget.tsx
|
|
4380
|
-
function
|
|
6104
|
+
function SetupConnectPrompt({
|
|
4381
6105
|
onConnect,
|
|
4382
6106
|
connecting
|
|
4383
6107
|
}) {
|
|
4384
|
-
return /* @__PURE__ */ (0,
|
|
4385
|
-
/* @__PURE__ */ (0,
|
|
4386
|
-
/* @__PURE__ */ (0,
|
|
4387
|
-
|
|
6108
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.YStack, { gap: "$5", alignItems: "center", paddingVertical: "$6", width: "100%", children: [
|
|
6109
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, center: true, children: "Connect your wallet to get started" }),
|
|
6110
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6111
|
+
import_ui21.CircularActionButton,
|
|
4388
6112
|
{
|
|
4389
6113
|
label: connecting ? "Connecting..." : "Connect Wallet",
|
|
4390
6114
|
pending: connecting,
|
|
@@ -4394,31 +6118,57 @@ function DisconnectedPanel({
|
|
|
4394
6118
|
}
|
|
4395
6119
|
}
|
|
4396
6120
|
)
|
|
4397
|
-
] })
|
|
6121
|
+
] });
|
|
6122
|
+
}
|
|
6123
|
+
function SetupTabPanel({
|
|
6124
|
+
state,
|
|
6125
|
+
actions,
|
|
6126
|
+
onConnect
|
|
6127
|
+
}) {
|
|
6128
|
+
if (needsWalletConnection(state)) {
|
|
6129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6130
|
+
SetupConnectPrompt,
|
|
6131
|
+
{
|
|
6132
|
+
onConnect,
|
|
6133
|
+
connecting: state.status === "connecting"
|
|
6134
|
+
}
|
|
6135
|
+
);
|
|
6136
|
+
}
|
|
6137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.YStack, { gap: "$4", width: "100%", children: [
|
|
6138
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6139
|
+
AiCreditsHero,
|
|
6140
|
+
{
|
|
6141
|
+
gBalance: state.gBalance,
|
|
6142
|
+
isGoodIdVerified: state.isGoodIdVerified
|
|
6143
|
+
}
|
|
6144
|
+
),
|
|
6145
|
+
/* @__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:" }),
|
|
6146
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SetupOnboardingFlow, { state, actions })
|
|
6147
|
+
] });
|
|
4398
6148
|
}
|
|
4399
6149
|
function BuyCreditsPanel({ state, actions, isPending, onPay }) {
|
|
4400
6150
|
let content;
|
|
4401
6151
|
if (state.status === "unsupported_chain") {
|
|
4402
|
-
content = /* @__PURE__ */ (0,
|
|
4403
|
-
/* @__PURE__ */ (0,
|
|
4404
|
-
/* @__PURE__ */ (0,
|
|
4405
|
-
/* @__PURE__ */ (0,
|
|
4406
|
-
|
|
6152
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AiCreditsStatusNotice, { children: [
|
|
6153
|
+
/* @__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" }) }),
|
|
6154
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, children: "Please switch to the Celo network to continue." }),
|
|
6155
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6156
|
+
import_ui21.Button,
|
|
4407
6157
|
{
|
|
4408
6158
|
onPress: () => {
|
|
4409
6159
|
void actions.switchChain();
|
|
4410
6160
|
},
|
|
4411
|
-
children: /* @__PURE__ */ (0,
|
|
6161
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.ButtonText, { children: "Switch to Celo" })
|
|
4412
6162
|
}
|
|
4413
6163
|
)
|
|
4414
6164
|
] });
|
|
4415
6165
|
} else if (state.status === "payment_failed") {
|
|
4416
|
-
content = /* @__PURE__ */ (0,
|
|
4417
|
-
/* @__PURE__ */ (0,
|
|
4418
|
-
/* @__PURE__ */ (0,
|
|
4419
|
-
state.error && /* @__PURE__ */ (0,
|
|
6166
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
6167
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AiCreditsStatusNotice, { children: [
|
|
6168
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$error", fontWeight: "700", children: "Payment Failed" }),
|
|
6169
|
+
state.error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, children: state.error })
|
|
4420
6170
|
] }),
|
|
4421
|
-
/* @__PURE__ */ (0,
|
|
6171
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4422
6172
|
AiCreditsPurchaseFlow,
|
|
4423
6173
|
{
|
|
4424
6174
|
state,
|
|
@@ -4429,57 +6179,61 @@ function BuyCreditsPanel({ state, actions, isPending, onPay }) {
|
|
|
4429
6179
|
)
|
|
4430
6180
|
] });
|
|
4431
6181
|
} else if (state.status === "backend_unavailable") {
|
|
4432
|
-
content = /* @__PURE__ */ (0,
|
|
4433
|
-
/* @__PURE__ */ (0,
|
|
4434
|
-
/* @__PURE__ */ (0,
|
|
4435
|
-
/* @__PURE__ */ (0,
|
|
4436
|
-
|
|
6182
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AiCreditsStatusNotice, { children: [
|
|
6183
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$warning", fontWeight: "700", children: "Service Unavailable" }),
|
|
6184
|
+
/* @__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." }),
|
|
6185
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6186
|
+
import_ui21.Button,
|
|
4437
6187
|
{
|
|
4438
6188
|
onPress: () => {
|
|
4439
6189
|
void actions.retry();
|
|
4440
6190
|
},
|
|
4441
|
-
children: /* @__PURE__ */ (0,
|
|
6191
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.ButtonText, { children: "Retry" })
|
|
4442
6192
|
}
|
|
4443
6193
|
)
|
|
4444
6194
|
] });
|
|
4445
6195
|
} else if (state.status === "insufficient_g_balance") {
|
|
4446
|
-
content = /* @__PURE__ */ (0,
|
|
4447
|
-
/* @__PURE__ */ (0,
|
|
6196
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
6197
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4448
6198
|
AiCreditsHero,
|
|
4449
6199
|
{
|
|
4450
6200
|
gBalance: state.gBalance,
|
|
4451
6201
|
isGoodIdVerified: state.isGoodIdVerified
|
|
4452
6202
|
}
|
|
4453
6203
|
),
|
|
4454
|
-
/* @__PURE__ */ (0,
|
|
4455
|
-
/* @__PURE__ */ (0,
|
|
4456
|
-
/* @__PURE__ */ (0,
|
|
6204
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AiCreditsStatusNotice, { children: [
|
|
6205
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$warning", fontWeight: "700", children: "Insufficient G$ Balance" }),
|
|
6206
|
+
/* @__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." })
|
|
4457
6207
|
] })
|
|
4458
6208
|
] });
|
|
4459
6209
|
} else if (state.status === "payment_pending" || state.status === "payment_confirmed") {
|
|
4460
6210
|
const message = state.status === "payment_pending" ? "Transaction submitted \u2014 waiting for confirmation\u2026" : "Payment confirmed \u2014 settling credits on Base\u2026";
|
|
4461
|
-
content = /* @__PURE__ */ (0,
|
|
4462
|
-
/* @__PURE__ */ (0,
|
|
4463
|
-
/* @__PURE__ */ (0,
|
|
4464
|
-
/* @__PURE__ */ (0,
|
|
6211
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
6212
|
+
/* @__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: [
|
|
6213
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Spinner, { size: "lg" }),
|
|
6214
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { center: true, secondary: true, children: message })
|
|
4465
6215
|
] }) }),
|
|
4466
|
-
/* @__PURE__ */ (0,
|
|
6216
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AiCreditsFlowStepper, { state, buyerPubKeySaved: true })
|
|
4467
6217
|
] });
|
|
4468
6218
|
} else {
|
|
4469
|
-
content = /* @__PURE__ */ (0,
|
|
4470
|
-
state.
|
|
6219
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
6220
|
+
state.error && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AiCreditsStatusNotice, { children: [
|
|
6221
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$error", fontWeight: "700", children: "Deep link unavailable" }),
|
|
6222
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, children: state.error })
|
|
6223
|
+
] }),
|
|
6224
|
+
state.address && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4471
6225
|
AiCreditsHero,
|
|
4472
6226
|
{
|
|
4473
6227
|
gBalance: state.gBalance,
|
|
4474
6228
|
isGoodIdVerified: state.isGoodIdVerified
|
|
4475
6229
|
}
|
|
4476
6230
|
),
|
|
4477
|
-
state.error && /* @__PURE__ */ (0,
|
|
4478
|
-
/* @__PURE__ */ (0,
|
|
4479
|
-
/* @__PURE__ */ (0,
|
|
6231
|
+
state.error && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AiCreditsStatusNotice, { children: [
|
|
6232
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$error", fontWeight: "700", children: "Request Failed" }),
|
|
6233
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { secondary: true, children: state.error })
|
|
4480
6234
|
] }),
|
|
4481
|
-
state.gBalance !== null && Number.parseFloat(state.gBalance) <= 0 && /* @__PURE__ */ (0,
|
|
4482
|
-
/* @__PURE__ */ (0,
|
|
6235
|
+
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." }) }),
|
|
6236
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4483
6237
|
AiCreditsPurchaseFlow,
|
|
4484
6238
|
{
|
|
4485
6239
|
state,
|
|
@@ -4490,16 +6244,13 @@ function BuyCreditsPanel({ state, actions, isPending, onPay }) {
|
|
|
4490
6244
|
)
|
|
4491
6245
|
] });
|
|
4492
6246
|
}
|
|
4493
|
-
return /* @__PURE__ */ (0,
|
|
4494
|
-
content,
|
|
4495
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(BuyCreditsFaq, {})
|
|
4496
|
-
] });
|
|
6247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.YStack, { gap: "$4", children: content });
|
|
4497
6248
|
}
|
|
4498
6249
|
function ManagePanel({
|
|
4499
6250
|
state,
|
|
4500
6251
|
actions
|
|
4501
6252
|
}) {
|
|
4502
|
-
const [refreshing, setRefreshing] =
|
|
6253
|
+
const [refreshing, setRefreshing] = import_react17.default.useState(false);
|
|
4503
6254
|
const handleRefresh = async () => {
|
|
4504
6255
|
setRefreshing(true);
|
|
4505
6256
|
try {
|
|
@@ -4508,15 +6259,15 @@ function ManagePanel({
|
|
|
4508
6259
|
setRefreshing(false);
|
|
4509
6260
|
}
|
|
4510
6261
|
};
|
|
4511
|
-
return /* @__PURE__ */ (0,
|
|
4512
|
-
state.error && /* @__PURE__ */ (0,
|
|
4513
|
-
/* @__PURE__ */ (0,
|
|
4514
|
-
/* @__PURE__ */ (0,
|
|
4515
|
-
/* @__PURE__ */ (0,
|
|
4516
|
-
/* @__PURE__ */ (0,
|
|
4517
|
-
state.error && /* @__PURE__ */ (0,
|
|
4518
|
-
/* @__PURE__ */ (0,
|
|
4519
|
-
|
|
6262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.YStack, { gap: "$3", width: "100%", children: [
|
|
6263
|
+
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 }) }),
|
|
6264
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CreditsManagementCard, { state, actions }),
|
|
6265
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(BuyerOperatorCard, { state, actions }),
|
|
6266
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SetupSnippet, {}),
|
|
6267
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.YStack, { gap: "$2", width: "100%", alignItems: "center", children: [
|
|
6268
|
+
state.error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Text, { color: "$error", fontSize: "$2", textAlign: "center", children: state.error }),
|
|
6269
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
6270
|
+
import_ui21.Button,
|
|
4520
6271
|
{
|
|
4521
6272
|
variant: "outline",
|
|
4522
6273
|
size: "sm",
|
|
@@ -4528,8 +6279,8 @@ function ManagePanel({
|
|
|
4528
6279
|
void handleRefresh();
|
|
4529
6280
|
},
|
|
4530
6281
|
children: [
|
|
4531
|
-
refreshing ? /* @__PURE__ */ (0,
|
|
4532
|
-
/* @__PURE__ */ (0,
|
|
6282
|
+
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" }),
|
|
6283
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.ButtonText, { children: refreshing ? "Refreshing\u2026" : "Refresh Balance" })
|
|
4533
6284
|
]
|
|
4534
6285
|
}
|
|
4535
6286
|
)
|
|
@@ -4547,7 +6298,9 @@ function AiCreditsInner({
|
|
|
4547
6298
|
adapterFactory,
|
|
4548
6299
|
adapterOptions,
|
|
4549
6300
|
onPaySuccess,
|
|
4550
|
-
onPayError
|
|
6301
|
+
onPayError,
|
|
6302
|
+
showWalletControls = false,
|
|
6303
|
+
hasDisconnectOverride = false
|
|
4551
6304
|
}) {
|
|
4552
6305
|
const defaultAdapter = useAiCreditsAdapter({
|
|
4553
6306
|
environment,
|
|
@@ -4564,33 +6317,41 @@ function AiCreditsInner({
|
|
|
4564
6317
|
skipVaultPaymentValidation: adapterOptions?.skipVaultPaymentValidation,
|
|
4565
6318
|
prepareSettlement: adapterOptions?.prepareSettlement
|
|
4566
6319
|
});
|
|
4567
|
-
const
|
|
4568
|
-
() => adapterFactory ? adapterFactory({ environment, backendUrl }) :
|
|
4569
|
-
[adapterFactory, environment, backendUrl
|
|
6320
|
+
const factoryAdapter = (0, import_react17.useMemo)(
|
|
6321
|
+
() => adapterFactory ? adapterFactory({ environment, backendUrl }) : null,
|
|
6322
|
+
[adapterFactory, environment, backendUrl]
|
|
4570
6323
|
);
|
|
6324
|
+
const activeAdapter = factoryAdapter ?? defaultAdapter;
|
|
4571
6325
|
const { state, actions } = activeAdapter;
|
|
6326
|
+
const onBuyersDiscoveredRef = import_react17.default.useRef(actions.discoverBuyers);
|
|
6327
|
+
onBuyersDiscoveredRef.current = actions.discoverBuyers;
|
|
6328
|
+
const onBuyersDiscovered = (0, import_react17.useCallback)((addresses) => {
|
|
6329
|
+
onBuyersDiscoveredRef.current(addresses);
|
|
6330
|
+
}, []);
|
|
4572
6331
|
const history = useAiCreditsHistory({
|
|
4573
6332
|
address: state.address,
|
|
4574
6333
|
backendUrl,
|
|
6334
|
+
defaultBuyerFilter: state.buyerPubKey ?? "all",
|
|
4575
6335
|
environment,
|
|
4576
|
-
backendClient: adapterOptions?.backendClient
|
|
6336
|
+
backendClient: adapterOptions?.backendClient,
|
|
6337
|
+
onBuyersDiscovered
|
|
4577
6338
|
});
|
|
4578
|
-
const handlePay = (0,
|
|
6339
|
+
const handlePay = (0, import_react17.useCallback)(
|
|
4579
6340
|
async (quote) => {
|
|
4580
|
-
const toastId = (0,
|
|
6341
|
+
const toastId = (0, import_ui21.createToast)({
|
|
4581
6342
|
message: "Submitting Celo transaction\u2026",
|
|
4582
6343
|
status: "pending",
|
|
4583
6344
|
duration: 0
|
|
4584
6345
|
});
|
|
4585
6346
|
try {
|
|
4586
6347
|
await actions.pay(quote);
|
|
4587
|
-
(0,
|
|
6348
|
+
(0, import_ui21.updateToast)(toastId, {
|
|
4588
6349
|
message: "Credits added successfully!",
|
|
4589
6350
|
status: "success",
|
|
4590
6351
|
duration: 4e3
|
|
4591
6352
|
});
|
|
4592
6353
|
} catch (err) {
|
|
4593
|
-
(0,
|
|
6354
|
+
(0, import_ui21.updateToast)(toastId, {
|
|
4594
6355
|
message: err instanceof Error ? err.message : state.error ?? "Payment failed. Try again.",
|
|
4595
6356
|
status: "error",
|
|
4596
6357
|
duration: 4e3
|
|
@@ -4599,47 +6360,117 @@ function AiCreditsInner({
|
|
|
4599
6360
|
},
|
|
4600
6361
|
[actions, state.error]
|
|
4601
6362
|
);
|
|
6363
|
+
const [helpView, setHelpView] = (0, import_react17.useState)(null);
|
|
4602
6364
|
const isPending = state.status === "payment_pending" || state.status === "payment_confirmed";
|
|
4603
|
-
const handleTabChange = (0,
|
|
6365
|
+
const handleTabChange = (0, import_react17.useCallback)(
|
|
4604
6366
|
(tabId) => {
|
|
6367
|
+
if (tabId !== "setup") {
|
|
6368
|
+
setHelpView(null);
|
|
6369
|
+
}
|
|
4605
6370
|
actions.setActiveTab(tabId);
|
|
4606
6371
|
},
|
|
4607
6372
|
[actions]
|
|
4608
6373
|
);
|
|
4609
|
-
const
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
6374
|
+
const { disconnect, disconnectLabel, disconnectIcon } = (0, import_core2.useWallet)();
|
|
6375
|
+
const handleDisconnect = (0, import_react17.useCallback)(async () => {
|
|
6376
|
+
await disconnect();
|
|
6377
|
+
setHelpView(null);
|
|
6378
|
+
actions.setActiveTab("setup");
|
|
6379
|
+
}, [actions, disconnect]);
|
|
6380
|
+
const walletRequired = needsWalletConnection(state);
|
|
6381
|
+
const handleHelpViewOpen = (0, import_react17.useCallback)(
|
|
6382
|
+
(view) => {
|
|
6383
|
+
actions.setActiveTab("setup");
|
|
6384
|
+
setHelpView(view);
|
|
6385
|
+
},
|
|
6386
|
+
[actions]
|
|
4619
6387
|
);
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
}
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
6388
|
+
const handleHelpViewClose = (0, import_react17.useCallback)(() => {
|
|
6389
|
+
setHelpView(null);
|
|
6390
|
+
}, []);
|
|
6391
|
+
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 });
|
|
6392
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.YStack, { gap: "$3", padding: "$3", width: "100%", children: [
|
|
6393
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
6394
|
+
import_ui21.XStack,
|
|
6395
|
+
{
|
|
6396
|
+
justifyContent: "space-between",
|
|
6397
|
+
alignItems: "center",
|
|
6398
|
+
gap: "$2",
|
|
6399
|
+
paddingHorizontal: "$1",
|
|
6400
|
+
children: [
|
|
6401
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.Heading, { level: 4, children: "GoodDollar" }),
|
|
6402
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.XStack, { gap: "$2", alignItems: "center", flexShrink: 1, minWidth: 0, children: [
|
|
6403
|
+
/* @__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) }) }),
|
|
6404
|
+
showWalletControls && state.address && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6405
|
+
WalletChip,
|
|
6406
|
+
{
|
|
6407
|
+
address: state.address,
|
|
6408
|
+
onDisconnect: hasDisconnectOverride ? handleDisconnect : void 0,
|
|
6409
|
+
disconnectLabel: hasDisconnectOverride ? disconnectLabel : void 0,
|
|
6410
|
+
disconnectIcon: hasDisconnectOverride ? disconnectIcon : void 0
|
|
6411
|
+
}
|
|
6412
|
+
)
|
|
6413
|
+
] })
|
|
6414
|
+
]
|
|
6415
|
+
}
|
|
6416
|
+
),
|
|
6417
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6418
|
+
SetupGuidanceCard,
|
|
6419
|
+
{
|
|
6420
|
+
activeHelpView: helpView,
|
|
6421
|
+
onHowToUse: () => {
|
|
6422
|
+
handleHelpViewOpen("how-to-use");
|
|
6423
|
+
},
|
|
6424
|
+
onFaq: () => {
|
|
6425
|
+
handleHelpViewOpen("faq");
|
|
6426
|
+
},
|
|
6427
|
+
depositBonusPercent: state.depositBonusPercent,
|
|
6428
|
+
streamBonusPercent: state.streamBonusPercent,
|
|
6429
|
+
isGoodIdVerified: state.isGoodIdVerified
|
|
6430
|
+
}
|
|
6431
|
+
),
|
|
6432
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6433
|
+
import_ui21.WidgetTabs,
|
|
4626
6434
|
{
|
|
4627
6435
|
tabs: [
|
|
6436
|
+
{ id: "setup", label: "Setup" },
|
|
4628
6437
|
{ id: "buy", label: "Buy Credits" },
|
|
4629
6438
|
{ id: "manage", label: "Manage" },
|
|
4630
6439
|
{ id: "history", label: "History" }
|
|
4631
6440
|
],
|
|
4632
|
-
activeTab: state.activeTab,
|
|
6441
|
+
activeTab: walletRequired ? "setup" : state.activeTab,
|
|
4633
6442
|
onTabChange: handleTabChange,
|
|
4634
|
-
|
|
6443
|
+
isTabDisabled: (tabId) => walletRequired && tabId !== "setup",
|
|
6444
|
+
withConnectionStatus: false
|
|
4635
6445
|
}
|
|
4636
6446
|
),
|
|
4637
|
-
state.activeTab === "manage" ? /* @__PURE__ */ (0,
|
|
6447
|
+
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)(
|
|
6448
|
+
HistoryTab,
|
|
6449
|
+
{
|
|
6450
|
+
state: history.state,
|
|
6451
|
+
actions: history.actions,
|
|
6452
|
+
knownBuyers: state.buyers.map((address) => ({ address }))
|
|
6453
|
+
}
|
|
6454
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6455
|
+
BuyCreditsPanel,
|
|
6456
|
+
{
|
|
6457
|
+
state,
|
|
6458
|
+
actions,
|
|
6459
|
+
isPending,
|
|
6460
|
+
onPay: (quote) => {
|
|
6461
|
+
void handlePay(quote);
|
|
6462
|
+
}
|
|
6463
|
+
}
|
|
6464
|
+
)
|
|
4638
6465
|
] });
|
|
4639
6466
|
}
|
|
4640
6467
|
function AiCreditsWidget({
|
|
4641
6468
|
provider,
|
|
4642
6469
|
connectOverride,
|
|
6470
|
+
showWalletControls = false,
|
|
6471
|
+
disconnectOverride,
|
|
6472
|
+
disconnectLabel,
|
|
6473
|
+
disconnectIcon,
|
|
4643
6474
|
environment = "production",
|
|
4644
6475
|
backendUrl,
|
|
4645
6476
|
baseRpcUrl,
|
|
@@ -4656,16 +6487,19 @@ function AiCreditsWidget({
|
|
|
4656
6487
|
adapterOptions,
|
|
4657
6488
|
testId
|
|
4658
6489
|
}) {
|
|
4659
|
-
return /* @__PURE__ */ (0,
|
|
6490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4660
6491
|
import_core2.GoodWidgetProvider,
|
|
4661
6492
|
{
|
|
4662
6493
|
provider,
|
|
4663
6494
|
connectOverride,
|
|
6495
|
+
disconnectOverride,
|
|
6496
|
+
disconnectLabel,
|
|
6497
|
+
disconnectIcon,
|
|
4664
6498
|
config,
|
|
4665
6499
|
themeOverrides,
|
|
4666
6500
|
defaultTheme,
|
|
4667
|
-
children: /* @__PURE__ */ (0,
|
|
4668
|
-
/* @__PURE__ */ (0,
|
|
6501
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_ui21.YStack, { backgroundColor: "$background", width: "100%", "data-testid": testId, children: [
|
|
6502
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4669
6503
|
AiCreditsInner,
|
|
4670
6504
|
{
|
|
4671
6505
|
environment,
|
|
@@ -4678,26 +6512,29 @@ function AiCreditsWidget({
|
|
|
4678
6512
|
adapterFactory,
|
|
4679
6513
|
adapterOptions,
|
|
4680
6514
|
onPaySuccess,
|
|
4681
|
-
onPayError
|
|
6515
|
+
onPayError,
|
|
6516
|
+
showWalletControls,
|
|
6517
|
+
hasDisconnectOverride: Boolean(disconnectOverride)
|
|
4682
6518
|
}
|
|
4683
6519
|
),
|
|
4684
|
-
/* @__PURE__ */ (0,
|
|
6520
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.ToastContainer, {})
|
|
4685
6521
|
] })
|
|
4686
6522
|
}
|
|
4687
6523
|
);
|
|
4688
6524
|
}
|
|
4689
|
-
var
|
|
6525
|
+
var import_react17, import_core2, import_ui21, import_jsx_runtime19, CELO_CHAIN_ID3;
|
|
4690
6526
|
var init_AiCreditsWidget = __esm({
|
|
4691
6527
|
"src/AiCreditsWidget.tsx"() {
|
|
4692
6528
|
"use strict";
|
|
4693
|
-
|
|
6529
|
+
import_react17 = __toESM(require("react"), 1);
|
|
4694
6530
|
import_core2 = require("@goodwidget/core");
|
|
4695
|
-
|
|
6531
|
+
import_ui21 = require("@goodwidget/ui");
|
|
4696
6532
|
init_adapter();
|
|
4697
6533
|
init_useAiCreditsHistory();
|
|
4698
6534
|
init_components();
|
|
4699
6535
|
init_styles();
|
|
4700
|
-
|
|
6536
|
+
init_WalletChip();
|
|
6537
|
+
import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4701
6538
|
CELO_CHAIN_ID3 = 42220;
|
|
4702
6539
|
}
|
|
4703
6540
|
});
|