@glacislabs/stablegenie-zerodelta 4.16.0 → 4.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/{chunk-7FBWRHP2.js → chunk-AEAJKHPP.js} +87 -21
- package/dist/{chunk-7V3XP5D6.js → chunk-CWAEDN4I.js} +1 -1
- package/dist/core/index.cjs +89 -20
- package/dist/core/index.d.cts +17 -2
- package/dist/core/index.d.ts +17 -2
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +92 -26
- package/dist/index.js +2 -2
- package/dist/mount.cjs +92 -26
- package/dist/mount.js +2 -2
- package/dist/standalone.global.js +7 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -677,8 +677,8 @@ var STEP_LABEL = {
|
|
|
677
677
|
delivered: "Delivered"
|
|
678
678
|
};
|
|
679
679
|
var label = (name) => STEP_LABEL[name] ?? name.replace(/_/g, " ");
|
|
680
|
-
function deliveryHeadline(delivery, sourceConfirmed,
|
|
681
|
-
if (
|
|
680
|
+
function deliveryHeadline(delivery, sourceConfirmed, direct2 = false) {
|
|
681
|
+
if (direct2) return sourceConfirmed ? "Delivered" : "Submitted \u2014 awaiting confirmation";
|
|
682
682
|
switch (delivery.phase) {
|
|
683
683
|
case "delivered":
|
|
684
684
|
return "Delivered";
|
|
@@ -697,8 +697,8 @@ function deliveryHeadline(delivery, sourceConfirmed, direct = false) {
|
|
|
697
697
|
return sourceConfirmed ? "Sent \u2014 tracking delivery" : "Submitted \u2014 awaiting confirmation";
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
|
-
function isDelivered(delivery, sourceConfirmed,
|
|
701
|
-
return
|
|
700
|
+
function isDelivered(delivery, sourceConfirmed, direct2 = false) {
|
|
701
|
+
return direct2 ? sourceConfirmed : delivery.phase === "delivered";
|
|
702
702
|
}
|
|
703
703
|
function DeliverySteps(props) {
|
|
704
704
|
const { steps, phase } = props.delivery;
|
|
@@ -717,8 +717,8 @@ function useMergedConfig(local) {
|
|
|
717
717
|
// src/core/constants.ts
|
|
718
718
|
var DEFAULT_WIDGET_API_BASE = "/api/widget/v1";
|
|
719
719
|
var SUPPORTED_CHAIN_IDS = /* @__PURE__ */ new Set([1, 10, 42161, 8453, 57073, 130, 9745, 146, 98866]);
|
|
720
|
-
var EXECUTABLE_STABLE_ASSETS = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE", "USDTB", "AUSD", "PYUSD", "USDG"]);
|
|
721
|
-
var STABLE_ASSETS =
|
|
720
|
+
var EXECUTABLE_STABLE_ASSETS = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE", "USDTB", "AUSD", "PYUSD", "USDG", "USD1", "WM", "USDS", "DAI", "RLUSD"]);
|
|
721
|
+
var STABLE_ASSETS = EXECUTABLE_STABLE_ASSETS;
|
|
722
722
|
var TRADEABLE_RWA_ASSETS = /* @__PURE__ */ new Set([
|
|
723
723
|
"XAUT",
|
|
724
724
|
// Nest vault shares — chained delivery on Plume, sellable from their Ethereum deployment.
|
|
@@ -874,6 +874,7 @@ var BUNDLED_RPC = {
|
|
|
874
874
|
42161: "https://arb1.arbitrum.io/rpc",
|
|
875
875
|
98866: "https://rpc.plume.org"
|
|
876
876
|
};
|
|
877
|
+
var BUNDLED_SOLANA_RPC = ["https://solana-rpc.publicnode.com", "https://api.mainnet-beta.solana.com"];
|
|
877
878
|
var CHAIN_DISPLAY_NAMES = Object.freeze({
|
|
878
879
|
1: "Ethereum",
|
|
879
880
|
10: "Optimism",
|
|
@@ -1824,11 +1825,13 @@ function buildCatalogue(input) {
|
|
|
1824
1825
|
}
|
|
1825
1826
|
const allowed = tokens.filter((token) => token.isEnabled !== false && isChainAddress(token.chainId, token.address) && allowedAssets.has(symbolKey(token.symbol)));
|
|
1826
1827
|
const projectedCatalogue = allowed.filter((token) => {
|
|
1827
|
-
|
|
1828
|
+
const chainId = Number(token.chainId);
|
|
1829
|
+
if (!chainIds.has(chainId)) return false;
|
|
1828
1830
|
if (product === "rwa") return true;
|
|
1831
|
+
if (execution.has(chainId) || token.isChainedDestination === true) return true;
|
|
1829
1832
|
if (!isExecutableBridge(token)) return false;
|
|
1830
1833
|
const key = tokenKey(token.chainId, token.address);
|
|
1831
|
-
return source2.has(key) || destination.has(key)
|
|
1834
|
+
return source2.has(key) || destination.has(key);
|
|
1832
1835
|
});
|
|
1833
1836
|
const ready = chains.length > 0 && routes.length > 0 && projectedCatalogue.length > 0;
|
|
1834
1837
|
const catalogue = ready ? projectedCatalogue : allowed;
|
|
@@ -1912,7 +1915,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1912
1915
|
if (refusal(token)) continue;
|
|
1913
1916
|
seen.add(key);
|
|
1914
1917
|
const payKey = symbolKey(token.symbol);
|
|
1915
|
-
const
|
|
1918
|
+
const direct2 = chainId === invoiceChain && payKey === invoiceKey;
|
|
1916
1919
|
options.push({
|
|
1917
1920
|
symbol: token.symbol,
|
|
1918
1921
|
symbolKey: payKey,
|
|
@@ -1925,7 +1928,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1925
1928
|
logoUrl: token.logoUrl,
|
|
1926
1929
|
bridge: routeBridge.get(`${payKey}:${chainId}`) || token.bridge,
|
|
1927
1930
|
sameChain: chainId === invoiceChain,
|
|
1928
|
-
direct
|
|
1931
|
+
direct: direct2
|
|
1929
1932
|
});
|
|
1930
1933
|
}
|
|
1931
1934
|
options.sort((a, b) => {
|
|
@@ -1946,6 +1949,56 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1946
1949
|
return options;
|
|
1947
1950
|
}
|
|
1948
1951
|
|
|
1952
|
+
// src/core/solana-rpc.ts
|
|
1953
|
+
var ATTEMPT_TIMEOUT_MS = 12e3;
|
|
1954
|
+
var REFUSAL_CODES = /* @__PURE__ */ new Set([-32005, -32029, -32052, 403, 429]);
|
|
1955
|
+
function refusesService(body) {
|
|
1956
|
+
const error = body.error;
|
|
1957
|
+
if (!error) return false;
|
|
1958
|
+
if (REFUSAL_CODES.has(error.code)) return true;
|
|
1959
|
+
return error.code === -32602 && /personal token/i.test(String(error.message ?? ""));
|
|
1960
|
+
}
|
|
1961
|
+
function unwrap(body) {
|
|
1962
|
+
if (body.error && solanaLamportShortfall(body.error.data?.logs) !== null) throw new Error(SOL_SHORTFALL_MESSAGE);
|
|
1963
|
+
if (body.error || body.result === void 0) throw new Error(String(body.error?.message || "Invalid Solana RPC response."));
|
|
1964
|
+
return body.result;
|
|
1965
|
+
}
|
|
1966
|
+
async function direct(fetchImpl, url, payload) {
|
|
1967
|
+
const controller = new AbortController();
|
|
1968
|
+
const timer2 = setTimeout(() => controller.abort(), ATTEMPT_TIMEOUT_MS);
|
|
1969
|
+
try {
|
|
1970
|
+
const response = await fetchImpl(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: payload, signal: controller.signal });
|
|
1971
|
+
if (!response.ok) return { refused: `HTTP ${response.status}` };
|
|
1972
|
+
const body = await response.json().catch(() => null);
|
|
1973
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return { refused: "not a JSON-RPC body" };
|
|
1974
|
+
if (refusesService(body)) return { refused: `refused (${String(body.error?.code)})` };
|
|
1975
|
+
return { body };
|
|
1976
|
+
} catch (error) {
|
|
1977
|
+
return { refused: controller.signal.aborted ? "timed out" : error instanceof Error ? error.message : String(error) };
|
|
1978
|
+
} finally {
|
|
1979
|
+
clearTimeout(timer2);
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
function createSolanaRpc(api, fetchImpl = globalThis.fetch?.bind(globalThis), urls = BUNDLED_SOLANA_RPC) {
|
|
1983
|
+
return async (method, params) => {
|
|
1984
|
+
const payload = JSON.stringify({ jsonrpc: "2.0", id: 1, method, params });
|
|
1985
|
+
const refused = [];
|
|
1986
|
+
for (const url of urls) {
|
|
1987
|
+
const attempt = await direct(fetchImpl, url, payload);
|
|
1988
|
+
if ("body" in attempt) return unwrap(attempt.body);
|
|
1989
|
+
refused.push(`${new URL(url).host}: ${attempt.refused}`);
|
|
1990
|
+
}
|
|
1991
|
+
let relayed;
|
|
1992
|
+
try {
|
|
1993
|
+
relayed = await api.apiRequest("/solana-rpc", { method: "POST", body: payload, timeoutMs: 15e3 });
|
|
1994
|
+
} catch (error) {
|
|
1995
|
+
refused.push(`proxy: ${error instanceof Error ? error.message : String(error)}`);
|
|
1996
|
+
throw new Error(`No Solana RPC answered ${method} (${refused.join("; ")}).`);
|
|
1997
|
+
}
|
|
1998
|
+
return unwrap(relayed);
|
|
1999
|
+
};
|
|
2000
|
+
}
|
|
2001
|
+
|
|
1949
2002
|
// src/core/solana-source.ts
|
|
1950
2003
|
var CANONICAL_SOLANA_PROGRAM = "zd1E5feCJLNYaPPsBAYkCPMKGVnipYf8God9h917W33";
|
|
1951
2004
|
var MAX_ASK_OVER_FINAL_BPS = 200n;
|
|
@@ -2195,18 +2248,6 @@ async function buildSolanaSourcePlan(api, input, quoted) {
|
|
|
2195
2248
|
});
|
|
2196
2249
|
return plan;
|
|
2197
2250
|
}
|
|
2198
|
-
function createSolanaRpc(api) {
|
|
2199
|
-
return async (method, params) => {
|
|
2200
|
-
const body = await api.apiRequest("/solana-rpc", {
|
|
2201
|
-
method: "POST",
|
|
2202
|
-
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
|
|
2203
|
-
timeoutMs: 15e3
|
|
2204
|
-
});
|
|
2205
|
-
if (body.error && solanaLamportShortfall(body.error.data?.logs) !== null) throw new Error(SOL_SHORTFALL_MESSAGE);
|
|
2206
|
-
if (body.error || body.result === void 0) throw new Error(body.error?.message || "Invalid Solana RPC response.");
|
|
2207
|
-
return body.result;
|
|
2208
|
-
};
|
|
2209
|
-
}
|
|
2210
2251
|
var SolanaSendError = class extends Error {
|
|
2211
2252
|
constructor(message, signature, sentAt) {
|
|
2212
2253
|
super(message);
|
|
@@ -2353,6 +2394,10 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2353
2394
|
try {
|
|
2354
2395
|
solanaKeyBytes(owner);
|
|
2355
2396
|
solanaKeyBytes(mint);
|
|
2397
|
+
} catch {
|
|
2398
|
+
return void 0;
|
|
2399
|
+
}
|
|
2400
|
+
try {
|
|
2356
2401
|
const result = await rpc("getTokenAccountsByOwner", [owner, { mint }, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2357
2402
|
if (!Array.isArray(result.value)) throw new Error("Invalid token accounts.");
|
|
2358
2403
|
let total = 0n, decimals;
|
|
@@ -2363,10 +2408,30 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2363
2408
|
total += BigInt(raw(amount.amount, "token balance"));
|
|
2364
2409
|
}
|
|
2365
2410
|
return total;
|
|
2411
|
+
} catch {
|
|
2412
|
+
}
|
|
2413
|
+
try {
|
|
2414
|
+
return await associatedBalance(rpc, owner, mint);
|
|
2366
2415
|
} catch {
|
|
2367
2416
|
return void 0;
|
|
2368
2417
|
}
|
|
2369
2418
|
}
|
|
2419
|
+
async function associatedBalance(rpc, owner, mint) {
|
|
2420
|
+
const programs = [TOKEN_PROGRAM, TOKEN_2022_PROGRAM];
|
|
2421
|
+
const keys = [...programs.map((p) => associatedTokenAddress(owner, mint, p)), mint];
|
|
2422
|
+
const result = await rpc("getMultipleAccounts", [keys, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2423
|
+
const accounts = result?.value;
|
|
2424
|
+
if (!Array.isArray(accounts) || accounts.length !== keys.length) throw new Error("Invalid token accounts.");
|
|
2425
|
+
if (!accounts[2] || !programs.includes(accounts[2].owner)) throw new Error("Not a token mint.");
|
|
2426
|
+
let total = 0n;
|
|
2427
|
+
for (const [i, account] of accounts.slice(0, 2).entries()) {
|
|
2428
|
+
if (!account) continue;
|
|
2429
|
+
const info = account.data?.parsed?.info;
|
|
2430
|
+
if (account.owner !== programs[i] || info?.mint !== mint) throw new Error("Invalid token account.");
|
|
2431
|
+
total += BigInt(raw(info?.tokenAmount?.amount, "token balance"));
|
|
2432
|
+
}
|
|
2433
|
+
return total;
|
|
2434
|
+
}
|
|
2370
2435
|
function solanaLamportShortfall(logs) {
|
|
2371
2436
|
if (!Array.isArray(logs)) return null;
|
|
2372
2437
|
for (const line of logs) {
|
|
@@ -3581,7 +3646,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
3581
3646
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
3582
3647
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
3583
3648
|
var WIDGET_CHANNEL = "widget";
|
|
3584
|
-
var WIDGET_VERSION = "4.
|
|
3649
|
+
var WIDGET_VERSION = "4.18.0" ;
|
|
3585
3650
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
3586
3651
|
function sanitizeVersion(raw2) {
|
|
3587
3652
|
const v = String(raw2).trim();
|
|
@@ -4623,7 +4688,8 @@ function createEngine(config = {}) {
|
|
|
4623
4688
|
const resolved = resolveConfig(config);
|
|
4624
4689
|
const api = createApiClient(resolved);
|
|
4625
4690
|
const verifier = createVerifier(api, resolved.fetchImpl, resolved.rpcOverrides);
|
|
4626
|
-
const
|
|
4691
|
+
const solanaOverride = resolved.rpcOverrides[SOLANA_CHAIN_ID];
|
|
4692
|
+
const solanaRpc = createSolanaRpc(api, resolved.fetchImpl, solanaOverride && /^https?:\/\//i.test(solanaOverride) ? [solanaOverride] : BUNDLED_SOLANA_RPC);
|
|
4627
4693
|
return {
|
|
4628
4694
|
api,
|
|
4629
4695
|
verifier,
|
|
@@ -7655,7 +7721,7 @@ function QuoteChecks({
|
|
|
7655
7721
|
compliance,
|
|
7656
7722
|
cv,
|
|
7657
7723
|
checks,
|
|
7658
|
-
direct,
|
|
7724
|
+
direct: direct2,
|
|
7659
7725
|
onViewPolicy
|
|
7660
7726
|
}) {
|
|
7661
7727
|
const allPassed = cv.tone === "ok" && checks.length > 0 && checks.every((c) => c.ok);
|
|
@@ -7684,7 +7750,7 @@ function QuoteChecks({
|
|
|
7684
7750
|
] }),
|
|
7685
7751
|
checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cp-checks", children: checks.map((check2) => /* @__PURE__ */ jsxRuntime.jsx(CheckRow, { check: check2, onViewPolicy }, check2.id)) }) : null,
|
|
7686
7752
|
orphans.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cp-orphans", children: orphans.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: humanizeComplianceReason(reason) }, reason)) }) : null,
|
|
7687
|
-
|
|
7753
|
+
direct2 && checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cp-scope", children: DIRECT_SCOPE_NOTE }) : null
|
|
7688
7754
|
] }),
|
|
7689
7755
|
compliance?.flaggedCategories?.length ? /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cp-card", children: [
|
|
7690
7756
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cp-card-head", children: [
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { CompliancePanel, PaymentIsland, StableGenieExchange, StableGeniePay, StableGenieProvider, StableGenieRwaExchange, StableGenieSwap, connectSolanaWallet, darkTheme, disconnectSolanaWallet, discoverSolanaWallets, lightTheme, mount, onSolanaAccountChange, resolveTheme, solanaWalletSigner, useSolanaWallet, watchSolanaWallets } from './chunk-
|
|
2
|
-
export { EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, TRADEABLE_RWA_ASSETS, assetClassOf, brokenLaneReason, complianceChecks, complianceControlsLine, complianceView, counterpartTokens, createEngine, destinationAvailability, formatJurisdiction, humanizeComplianceReason, symbolKey } from './chunk-
|
|
1
|
+
export { CompliancePanel, PaymentIsland, StableGenieExchange, StableGeniePay, StableGenieProvider, StableGenieRwaExchange, StableGenieSwap, connectSolanaWallet, darkTheme, disconnectSolanaWallet, discoverSolanaWallets, lightTheme, mount, onSolanaAccountChange, resolveTheme, solanaWalletSigner, useSolanaWallet, watchSolanaWallets } from './chunk-CWAEDN4I.js';
|
|
2
|
+
export { EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, TRADEABLE_RWA_ASSETS, assetClassOf, brokenLaneReason, complianceChecks, complianceControlsLine, complianceView, counterpartTokens, createEngine, destinationAvailability, formatJurisdiction, humanizeComplianceReason, symbolKey } from './chunk-AEAJKHPP.js';
|
package/dist/mount.cjs
CHANGED
|
@@ -677,8 +677,8 @@ var STEP_LABEL = {
|
|
|
677
677
|
delivered: "Delivered"
|
|
678
678
|
};
|
|
679
679
|
var label = (name) => STEP_LABEL[name] ?? name.replace(/_/g, " ");
|
|
680
|
-
function deliveryHeadline(delivery, sourceConfirmed,
|
|
681
|
-
if (
|
|
680
|
+
function deliveryHeadline(delivery, sourceConfirmed, direct2 = false) {
|
|
681
|
+
if (direct2) return sourceConfirmed ? "Delivered" : "Submitted \u2014 awaiting confirmation";
|
|
682
682
|
switch (delivery.phase) {
|
|
683
683
|
case "delivered":
|
|
684
684
|
return "Delivered";
|
|
@@ -697,8 +697,8 @@ function deliveryHeadline(delivery, sourceConfirmed, direct = false) {
|
|
|
697
697
|
return sourceConfirmed ? "Sent \u2014 tracking delivery" : "Submitted \u2014 awaiting confirmation";
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
|
-
function isDelivered(delivery, sourceConfirmed,
|
|
701
|
-
return
|
|
700
|
+
function isDelivered(delivery, sourceConfirmed, direct2 = false) {
|
|
701
|
+
return direct2 ? sourceConfirmed : delivery.phase === "delivered";
|
|
702
702
|
}
|
|
703
703
|
function DeliverySteps(props) {
|
|
704
704
|
const { steps, phase } = props.delivery;
|
|
@@ -714,8 +714,8 @@ function useMergedConfig(local) {
|
|
|
714
714
|
// src/core/constants.ts
|
|
715
715
|
var DEFAULT_WIDGET_API_BASE = "/api/widget/v1";
|
|
716
716
|
var SUPPORTED_CHAIN_IDS = /* @__PURE__ */ new Set([1, 10, 42161, 8453, 57073, 130, 9745, 146, 98866]);
|
|
717
|
-
var EXECUTABLE_STABLE_ASSETS = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE", "USDTB", "AUSD", "PYUSD", "USDG"]);
|
|
718
|
-
var STABLE_ASSETS =
|
|
717
|
+
var EXECUTABLE_STABLE_ASSETS = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE", "USDTB", "AUSD", "PYUSD", "USDG", "USD1", "WM", "USDS", "DAI", "RLUSD"]);
|
|
718
|
+
var STABLE_ASSETS = EXECUTABLE_STABLE_ASSETS;
|
|
719
719
|
var TRADEABLE_RWA_ASSETS = /* @__PURE__ */ new Set([
|
|
720
720
|
"XAUT",
|
|
721
721
|
// Nest vault shares — chained delivery on Plume, sellable from their Ethereum deployment.
|
|
@@ -871,6 +871,7 @@ var BUNDLED_RPC = {
|
|
|
871
871
|
42161: "https://arb1.arbitrum.io/rpc",
|
|
872
872
|
98866: "https://rpc.plume.org"
|
|
873
873
|
};
|
|
874
|
+
var BUNDLED_SOLANA_RPC = ["https://solana-rpc.publicnode.com", "https://api.mainnet-beta.solana.com"];
|
|
874
875
|
var CHAIN_DISPLAY_NAMES = Object.freeze({
|
|
875
876
|
1: "Ethereum",
|
|
876
877
|
10: "Optimism",
|
|
@@ -1821,11 +1822,13 @@ function buildCatalogue(input) {
|
|
|
1821
1822
|
}
|
|
1822
1823
|
const allowed = tokens.filter((token) => token.isEnabled !== false && isChainAddress(token.chainId, token.address) && allowedAssets.has(symbolKey(token.symbol)));
|
|
1823
1824
|
const projectedCatalogue = allowed.filter((token) => {
|
|
1824
|
-
|
|
1825
|
+
const chainId = Number(token.chainId);
|
|
1826
|
+
if (!chainIds.has(chainId)) return false;
|
|
1825
1827
|
if (product === "rwa") return true;
|
|
1828
|
+
if (execution.has(chainId) || token.isChainedDestination === true) return true;
|
|
1826
1829
|
if (!isExecutableBridge(token)) return false;
|
|
1827
1830
|
const key = tokenKey(token.chainId, token.address);
|
|
1828
|
-
return source2.has(key) || destination.has(key)
|
|
1831
|
+
return source2.has(key) || destination.has(key);
|
|
1829
1832
|
});
|
|
1830
1833
|
const ready = chains.length > 0 && routes.length > 0 && projectedCatalogue.length > 0;
|
|
1831
1834
|
const catalogue = ready ? projectedCatalogue : allowed;
|
|
@@ -1909,7 +1912,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1909
1912
|
if (refusal(token)) continue;
|
|
1910
1913
|
seen.add(key);
|
|
1911
1914
|
const payKey = symbolKey(token.symbol);
|
|
1912
|
-
const
|
|
1915
|
+
const direct2 = chainId === invoiceChain && payKey === invoiceKey;
|
|
1913
1916
|
options.push({
|
|
1914
1917
|
symbol: token.symbol,
|
|
1915
1918
|
symbolKey: payKey,
|
|
@@ -1922,7 +1925,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1922
1925
|
logoUrl: token.logoUrl,
|
|
1923
1926
|
bridge: routeBridge.get(`${payKey}:${chainId}`) || token.bridge,
|
|
1924
1927
|
sameChain: chainId === invoiceChain,
|
|
1925
|
-
direct
|
|
1928
|
+
direct: direct2
|
|
1926
1929
|
});
|
|
1927
1930
|
}
|
|
1928
1931
|
options.sort((a, b) => {
|
|
@@ -1943,6 +1946,56 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1943
1946
|
return options;
|
|
1944
1947
|
}
|
|
1945
1948
|
|
|
1949
|
+
// src/core/solana-rpc.ts
|
|
1950
|
+
var ATTEMPT_TIMEOUT_MS = 12e3;
|
|
1951
|
+
var REFUSAL_CODES = /* @__PURE__ */ new Set([-32005, -32029, -32052, 403, 429]);
|
|
1952
|
+
function refusesService(body) {
|
|
1953
|
+
const error = body.error;
|
|
1954
|
+
if (!error) return false;
|
|
1955
|
+
if (REFUSAL_CODES.has(error.code)) return true;
|
|
1956
|
+
return error.code === -32602 && /personal token/i.test(String(error.message ?? ""));
|
|
1957
|
+
}
|
|
1958
|
+
function unwrap(body) {
|
|
1959
|
+
if (body.error && solanaLamportShortfall(body.error.data?.logs) !== null) throw new Error(SOL_SHORTFALL_MESSAGE);
|
|
1960
|
+
if (body.error || body.result === void 0) throw new Error(String(body.error?.message || "Invalid Solana RPC response."));
|
|
1961
|
+
return body.result;
|
|
1962
|
+
}
|
|
1963
|
+
async function direct(fetchImpl, url, payload) {
|
|
1964
|
+
const controller = new AbortController();
|
|
1965
|
+
const timer2 = setTimeout(() => controller.abort(), ATTEMPT_TIMEOUT_MS);
|
|
1966
|
+
try {
|
|
1967
|
+
const response = await fetchImpl(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: payload, signal: controller.signal });
|
|
1968
|
+
if (!response.ok) return { refused: `HTTP ${response.status}` };
|
|
1969
|
+
const body = await response.json().catch(() => null);
|
|
1970
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return { refused: "not a JSON-RPC body" };
|
|
1971
|
+
if (refusesService(body)) return { refused: `refused (${String(body.error?.code)})` };
|
|
1972
|
+
return { body };
|
|
1973
|
+
} catch (error) {
|
|
1974
|
+
return { refused: controller.signal.aborted ? "timed out" : error instanceof Error ? error.message : String(error) };
|
|
1975
|
+
} finally {
|
|
1976
|
+
clearTimeout(timer2);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
function createSolanaRpc(api, fetchImpl = globalThis.fetch?.bind(globalThis), urls = BUNDLED_SOLANA_RPC) {
|
|
1980
|
+
return async (method, params) => {
|
|
1981
|
+
const payload = JSON.stringify({ jsonrpc: "2.0", id: 1, method, params });
|
|
1982
|
+
const refused = [];
|
|
1983
|
+
for (const url of urls) {
|
|
1984
|
+
const attempt = await direct(fetchImpl, url, payload);
|
|
1985
|
+
if ("body" in attempt) return unwrap(attempt.body);
|
|
1986
|
+
refused.push(`${new URL(url).host}: ${attempt.refused}`);
|
|
1987
|
+
}
|
|
1988
|
+
let relayed;
|
|
1989
|
+
try {
|
|
1990
|
+
relayed = await api.apiRequest("/solana-rpc", { method: "POST", body: payload, timeoutMs: 15e3 });
|
|
1991
|
+
} catch (error) {
|
|
1992
|
+
refused.push(`proxy: ${error instanceof Error ? error.message : String(error)}`);
|
|
1993
|
+
throw new Error(`No Solana RPC answered ${method} (${refused.join("; ")}).`);
|
|
1994
|
+
}
|
|
1995
|
+
return unwrap(relayed);
|
|
1996
|
+
};
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1946
1999
|
// src/core/solana-source.ts
|
|
1947
2000
|
var CANONICAL_SOLANA_PROGRAM = "zd1E5feCJLNYaPPsBAYkCPMKGVnipYf8God9h917W33";
|
|
1948
2001
|
var MAX_ASK_OVER_FINAL_BPS = 200n;
|
|
@@ -2192,18 +2245,6 @@ async function buildSolanaSourcePlan(api, input, quoted) {
|
|
|
2192
2245
|
});
|
|
2193
2246
|
return plan;
|
|
2194
2247
|
}
|
|
2195
|
-
function createSolanaRpc(api) {
|
|
2196
|
-
return async (method, params) => {
|
|
2197
|
-
const body = await api.apiRequest("/solana-rpc", {
|
|
2198
|
-
method: "POST",
|
|
2199
|
-
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
|
|
2200
|
-
timeoutMs: 15e3
|
|
2201
|
-
});
|
|
2202
|
-
if (body.error && solanaLamportShortfall(body.error.data?.logs) !== null) throw new Error(SOL_SHORTFALL_MESSAGE);
|
|
2203
|
-
if (body.error || body.result === void 0) throw new Error(body.error?.message || "Invalid Solana RPC response.");
|
|
2204
|
-
return body.result;
|
|
2205
|
-
};
|
|
2206
|
-
}
|
|
2207
2248
|
var SolanaSendError = class extends Error {
|
|
2208
2249
|
constructor(message, signature, sentAt) {
|
|
2209
2250
|
super(message);
|
|
@@ -2350,6 +2391,10 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2350
2391
|
try {
|
|
2351
2392
|
solanaKeyBytes(owner);
|
|
2352
2393
|
solanaKeyBytes(mint);
|
|
2394
|
+
} catch {
|
|
2395
|
+
return void 0;
|
|
2396
|
+
}
|
|
2397
|
+
try {
|
|
2353
2398
|
const result = await rpc("getTokenAccountsByOwner", [owner, { mint }, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2354
2399
|
if (!Array.isArray(result.value)) throw new Error("Invalid token accounts.");
|
|
2355
2400
|
let total = 0n, decimals;
|
|
@@ -2360,10 +2405,30 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2360
2405
|
total += BigInt(raw(amount.amount, "token balance"));
|
|
2361
2406
|
}
|
|
2362
2407
|
return total;
|
|
2408
|
+
} catch {
|
|
2409
|
+
}
|
|
2410
|
+
try {
|
|
2411
|
+
return await associatedBalance(rpc, owner, mint);
|
|
2363
2412
|
} catch {
|
|
2364
2413
|
return void 0;
|
|
2365
2414
|
}
|
|
2366
2415
|
}
|
|
2416
|
+
async function associatedBalance(rpc, owner, mint) {
|
|
2417
|
+
const programs = [TOKEN_PROGRAM, TOKEN_2022_PROGRAM];
|
|
2418
|
+
const keys = [...programs.map((p) => associatedTokenAddress(owner, mint, p)), mint];
|
|
2419
|
+
const result = await rpc("getMultipleAccounts", [keys, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2420
|
+
const accounts = result?.value;
|
|
2421
|
+
if (!Array.isArray(accounts) || accounts.length !== keys.length) throw new Error("Invalid token accounts.");
|
|
2422
|
+
if (!accounts[2] || !programs.includes(accounts[2].owner)) throw new Error("Not a token mint.");
|
|
2423
|
+
let total = 0n;
|
|
2424
|
+
for (const [i, account] of accounts.slice(0, 2).entries()) {
|
|
2425
|
+
if (!account) continue;
|
|
2426
|
+
const info = account.data?.parsed?.info;
|
|
2427
|
+
if (account.owner !== programs[i] || info?.mint !== mint) throw new Error("Invalid token account.");
|
|
2428
|
+
total += BigInt(raw(info?.tokenAmount?.amount, "token balance"));
|
|
2429
|
+
}
|
|
2430
|
+
return total;
|
|
2431
|
+
}
|
|
2367
2432
|
function solanaLamportShortfall(logs) {
|
|
2368
2433
|
if (!Array.isArray(logs)) return null;
|
|
2369
2434
|
for (const line of logs) {
|
|
@@ -3562,7 +3627,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
3562
3627
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
3563
3628
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
3564
3629
|
var WIDGET_CHANNEL = "widget";
|
|
3565
|
-
var WIDGET_VERSION = "4.
|
|
3630
|
+
var WIDGET_VERSION = "4.18.0" ;
|
|
3566
3631
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
3567
3632
|
function sanitizeVersion(raw2) {
|
|
3568
3633
|
const v = String(raw2).trim();
|
|
@@ -4604,7 +4669,8 @@ function createEngine(config = {}) {
|
|
|
4604
4669
|
const resolved = resolveConfig(config);
|
|
4605
4670
|
const api = createApiClient(resolved);
|
|
4606
4671
|
const verifier = createVerifier(api, resolved.fetchImpl, resolved.rpcOverrides);
|
|
4607
|
-
const
|
|
4672
|
+
const solanaOverride = resolved.rpcOverrides[SOLANA_CHAIN_ID];
|
|
4673
|
+
const solanaRpc = createSolanaRpc(api, resolved.fetchImpl, solanaOverride && /^https?:\/\//i.test(solanaOverride) ? [solanaOverride] : BUNDLED_SOLANA_RPC);
|
|
4608
4674
|
return {
|
|
4609
4675
|
api,
|
|
4610
4676
|
verifier,
|
|
@@ -7636,7 +7702,7 @@ function QuoteChecks({
|
|
|
7636
7702
|
compliance,
|
|
7637
7703
|
cv,
|
|
7638
7704
|
checks,
|
|
7639
|
-
direct,
|
|
7705
|
+
direct: direct2,
|
|
7640
7706
|
onViewPolicy
|
|
7641
7707
|
}) {
|
|
7642
7708
|
const allPassed = cv.tone === "ok" && checks.length > 0 && checks.every((c) => c.ok);
|
|
@@ -7665,7 +7731,7 @@ function QuoteChecks({
|
|
|
7665
7731
|
] }),
|
|
7666
7732
|
checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cp-checks", children: checks.map((check2) => /* @__PURE__ */ jsxRuntime.jsx(CheckRow, { check: check2, onViewPolicy }, check2.id)) }) : null,
|
|
7667
7733
|
orphans.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cp-orphans", children: orphans.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: humanizeComplianceReason(reason) }, reason)) }) : null,
|
|
7668
|
-
|
|
7734
|
+
direct2 && checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cp-scope", children: DIRECT_SCOPE_NOTE }) : null
|
|
7669
7735
|
] }),
|
|
7670
7736
|
compliance?.flaggedCategories?.length ? /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cp-card", children: [
|
|
7671
7737
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cp-card-head", children: [
|
package/dist/mount.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { mount } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { mount } from './chunk-CWAEDN4I.js';
|
|
2
|
+
import './chunk-AEAJKHPP.js';
|