@glacislabs/stablegenie-zerodelta 4.16.0 → 4.17.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-5GVQQIGQ.js} +81 -17
- package/dist/{chunk-7V3XP5D6.js → chunk-TIMSRHXC.js} +1 -1
- package/dist/core/index.cjs +83 -16
- 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 +86 -22
- package/dist/index.js +2 -2
- package/dist/mount.cjs +86 -22
- 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;
|
|
@@ -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",
|
|
@@ -1912,7 +1913,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1912
1913
|
if (refusal(token)) continue;
|
|
1913
1914
|
seen.add(key);
|
|
1914
1915
|
const payKey = symbolKey(token.symbol);
|
|
1915
|
-
const
|
|
1916
|
+
const direct2 = chainId === invoiceChain && payKey === invoiceKey;
|
|
1916
1917
|
options.push({
|
|
1917
1918
|
symbol: token.symbol,
|
|
1918
1919
|
symbolKey: payKey,
|
|
@@ -1925,7 +1926,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1925
1926
|
logoUrl: token.logoUrl,
|
|
1926
1927
|
bridge: routeBridge.get(`${payKey}:${chainId}`) || token.bridge,
|
|
1927
1928
|
sameChain: chainId === invoiceChain,
|
|
1928
|
-
direct
|
|
1929
|
+
direct: direct2
|
|
1929
1930
|
});
|
|
1930
1931
|
}
|
|
1931
1932
|
options.sort((a, b) => {
|
|
@@ -1946,6 +1947,56 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1946
1947
|
return options;
|
|
1947
1948
|
}
|
|
1948
1949
|
|
|
1950
|
+
// src/core/solana-rpc.ts
|
|
1951
|
+
var ATTEMPT_TIMEOUT_MS = 12e3;
|
|
1952
|
+
var REFUSAL_CODES = /* @__PURE__ */ new Set([-32005, -32029, -32052, 403, 429]);
|
|
1953
|
+
function refusesService(body) {
|
|
1954
|
+
const error = body.error;
|
|
1955
|
+
if (!error) return false;
|
|
1956
|
+
if (REFUSAL_CODES.has(error.code)) return true;
|
|
1957
|
+
return error.code === -32602 && /personal token/i.test(String(error.message ?? ""));
|
|
1958
|
+
}
|
|
1959
|
+
function unwrap(body) {
|
|
1960
|
+
if (body.error && solanaLamportShortfall(body.error.data?.logs) !== null) throw new Error(SOL_SHORTFALL_MESSAGE);
|
|
1961
|
+
if (body.error || body.result === void 0) throw new Error(String(body.error?.message || "Invalid Solana RPC response."));
|
|
1962
|
+
return body.result;
|
|
1963
|
+
}
|
|
1964
|
+
async function direct(fetchImpl, url, payload) {
|
|
1965
|
+
const controller = new AbortController();
|
|
1966
|
+
const timer2 = setTimeout(() => controller.abort(), ATTEMPT_TIMEOUT_MS);
|
|
1967
|
+
try {
|
|
1968
|
+
const response = await fetchImpl(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: payload, signal: controller.signal });
|
|
1969
|
+
if (!response.ok) return { refused: `HTTP ${response.status}` };
|
|
1970
|
+
const body = await response.json().catch(() => null);
|
|
1971
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return { refused: "not a JSON-RPC body" };
|
|
1972
|
+
if (refusesService(body)) return { refused: `refused (${String(body.error?.code)})` };
|
|
1973
|
+
return { body };
|
|
1974
|
+
} catch (error) {
|
|
1975
|
+
return { refused: controller.signal.aborted ? "timed out" : error instanceof Error ? error.message : String(error) };
|
|
1976
|
+
} finally {
|
|
1977
|
+
clearTimeout(timer2);
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
function createSolanaRpc(api, fetchImpl = globalThis.fetch?.bind(globalThis), urls = BUNDLED_SOLANA_RPC) {
|
|
1981
|
+
return async (method, params) => {
|
|
1982
|
+
const payload = JSON.stringify({ jsonrpc: "2.0", id: 1, method, params });
|
|
1983
|
+
const refused = [];
|
|
1984
|
+
for (const url of urls) {
|
|
1985
|
+
const attempt = await direct(fetchImpl, url, payload);
|
|
1986
|
+
if ("body" in attempt) return unwrap(attempt.body);
|
|
1987
|
+
refused.push(`${new URL(url).host}: ${attempt.refused}`);
|
|
1988
|
+
}
|
|
1989
|
+
let relayed;
|
|
1990
|
+
try {
|
|
1991
|
+
relayed = await api.apiRequest("/solana-rpc", { method: "POST", body: payload, timeoutMs: 15e3 });
|
|
1992
|
+
} catch (error) {
|
|
1993
|
+
refused.push(`proxy: ${error instanceof Error ? error.message : String(error)}`);
|
|
1994
|
+
throw new Error(`No Solana RPC answered ${method} (${refused.join("; ")}).`);
|
|
1995
|
+
}
|
|
1996
|
+
return unwrap(relayed);
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1999
|
+
|
|
1949
2000
|
// src/core/solana-source.ts
|
|
1950
2001
|
var CANONICAL_SOLANA_PROGRAM = "zd1E5feCJLNYaPPsBAYkCPMKGVnipYf8God9h917W33";
|
|
1951
2002
|
var MAX_ASK_OVER_FINAL_BPS = 200n;
|
|
@@ -2195,18 +2246,6 @@ async function buildSolanaSourcePlan(api, input, quoted) {
|
|
|
2195
2246
|
});
|
|
2196
2247
|
return plan;
|
|
2197
2248
|
}
|
|
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
2249
|
var SolanaSendError = class extends Error {
|
|
2211
2250
|
constructor(message, signature, sentAt) {
|
|
2212
2251
|
super(message);
|
|
@@ -2353,6 +2392,10 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2353
2392
|
try {
|
|
2354
2393
|
solanaKeyBytes(owner);
|
|
2355
2394
|
solanaKeyBytes(mint);
|
|
2395
|
+
} catch {
|
|
2396
|
+
return void 0;
|
|
2397
|
+
}
|
|
2398
|
+
try {
|
|
2356
2399
|
const result = await rpc("getTokenAccountsByOwner", [owner, { mint }, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2357
2400
|
if (!Array.isArray(result.value)) throw new Error("Invalid token accounts.");
|
|
2358
2401
|
let total = 0n, decimals;
|
|
@@ -2363,10 +2406,30 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2363
2406
|
total += BigInt(raw(amount.amount, "token balance"));
|
|
2364
2407
|
}
|
|
2365
2408
|
return total;
|
|
2409
|
+
} catch {
|
|
2410
|
+
}
|
|
2411
|
+
try {
|
|
2412
|
+
return await associatedBalance(rpc, owner, mint);
|
|
2366
2413
|
} catch {
|
|
2367
2414
|
return void 0;
|
|
2368
2415
|
}
|
|
2369
2416
|
}
|
|
2417
|
+
async function associatedBalance(rpc, owner, mint) {
|
|
2418
|
+
const programs = [TOKEN_PROGRAM, TOKEN_2022_PROGRAM];
|
|
2419
|
+
const keys = [...programs.map((p) => associatedTokenAddress(owner, mint, p)), mint];
|
|
2420
|
+
const result = await rpc("getMultipleAccounts", [keys, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2421
|
+
const accounts = result?.value;
|
|
2422
|
+
if (!Array.isArray(accounts) || accounts.length !== keys.length) throw new Error("Invalid token accounts.");
|
|
2423
|
+
if (!accounts[2] || !programs.includes(accounts[2].owner)) throw new Error("Not a token mint.");
|
|
2424
|
+
let total = 0n;
|
|
2425
|
+
for (const [i, account] of accounts.slice(0, 2).entries()) {
|
|
2426
|
+
if (!account) continue;
|
|
2427
|
+
const info = account.data?.parsed?.info;
|
|
2428
|
+
if (account.owner !== programs[i] || info?.mint !== mint) throw new Error("Invalid token account.");
|
|
2429
|
+
total += BigInt(raw(info?.tokenAmount?.amount, "token balance"));
|
|
2430
|
+
}
|
|
2431
|
+
return total;
|
|
2432
|
+
}
|
|
2370
2433
|
function solanaLamportShortfall(logs) {
|
|
2371
2434
|
if (!Array.isArray(logs)) return null;
|
|
2372
2435
|
for (const line of logs) {
|
|
@@ -3581,7 +3644,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
3581
3644
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
3582
3645
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
3583
3646
|
var WIDGET_CHANNEL = "widget";
|
|
3584
|
-
var WIDGET_VERSION = "4.
|
|
3647
|
+
var WIDGET_VERSION = "4.17.0" ;
|
|
3585
3648
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
3586
3649
|
function sanitizeVersion(raw2) {
|
|
3587
3650
|
const v = String(raw2).trim();
|
|
@@ -4623,7 +4686,8 @@ function createEngine(config = {}) {
|
|
|
4623
4686
|
const resolved = resolveConfig(config);
|
|
4624
4687
|
const api = createApiClient(resolved);
|
|
4625
4688
|
const verifier = createVerifier(api, resolved.fetchImpl, resolved.rpcOverrides);
|
|
4626
|
-
const
|
|
4689
|
+
const solanaOverride = resolved.rpcOverrides[SOLANA_CHAIN_ID];
|
|
4690
|
+
const solanaRpc = createSolanaRpc(api, resolved.fetchImpl, solanaOverride && /^https?:\/\//i.test(solanaOverride) ? [solanaOverride] : BUNDLED_SOLANA_RPC);
|
|
4627
4691
|
return {
|
|
4628
4692
|
api,
|
|
4629
4693
|
verifier,
|
|
@@ -7655,7 +7719,7 @@ function QuoteChecks({
|
|
|
7655
7719
|
compliance,
|
|
7656
7720
|
cv,
|
|
7657
7721
|
checks,
|
|
7658
|
-
direct,
|
|
7722
|
+
direct: direct2,
|
|
7659
7723
|
onViewPolicy
|
|
7660
7724
|
}) {
|
|
7661
7725
|
const allPassed = cv.tone === "ok" && checks.length > 0 && checks.every((c) => c.ok);
|
|
@@ -7684,7 +7748,7 @@ function QuoteChecks({
|
|
|
7684
7748
|
] }),
|
|
7685
7749
|
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
7750
|
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
|
-
|
|
7751
|
+
direct2 && checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cp-scope", children: DIRECT_SCOPE_NOTE }) : null
|
|
7688
7752
|
] }),
|
|
7689
7753
|
compliance?.flaggedCategories?.length ? /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cp-card", children: [
|
|
7690
7754
|
/* @__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-TIMSRHXC.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-5GVQQIGQ.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;
|
|
@@ -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",
|
|
@@ -1909,7 +1910,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1909
1910
|
if (refusal(token)) continue;
|
|
1910
1911
|
seen.add(key);
|
|
1911
1912
|
const payKey = symbolKey(token.symbol);
|
|
1912
|
-
const
|
|
1913
|
+
const direct2 = chainId === invoiceChain && payKey === invoiceKey;
|
|
1913
1914
|
options.push({
|
|
1914
1915
|
symbol: token.symbol,
|
|
1915
1916
|
symbolKey: payKey,
|
|
@@ -1922,7 +1923,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1922
1923
|
logoUrl: token.logoUrl,
|
|
1923
1924
|
bridge: routeBridge.get(`${payKey}:${chainId}`) || token.bridge,
|
|
1924
1925
|
sameChain: chainId === invoiceChain,
|
|
1925
|
-
direct
|
|
1926
|
+
direct: direct2
|
|
1926
1927
|
});
|
|
1927
1928
|
}
|
|
1928
1929
|
options.sort((a, b) => {
|
|
@@ -1943,6 +1944,56 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1943
1944
|
return options;
|
|
1944
1945
|
}
|
|
1945
1946
|
|
|
1947
|
+
// src/core/solana-rpc.ts
|
|
1948
|
+
var ATTEMPT_TIMEOUT_MS = 12e3;
|
|
1949
|
+
var REFUSAL_CODES = /* @__PURE__ */ new Set([-32005, -32029, -32052, 403, 429]);
|
|
1950
|
+
function refusesService(body) {
|
|
1951
|
+
const error = body.error;
|
|
1952
|
+
if (!error) return false;
|
|
1953
|
+
if (REFUSAL_CODES.has(error.code)) return true;
|
|
1954
|
+
return error.code === -32602 && /personal token/i.test(String(error.message ?? ""));
|
|
1955
|
+
}
|
|
1956
|
+
function unwrap(body) {
|
|
1957
|
+
if (body.error && solanaLamportShortfall(body.error.data?.logs) !== null) throw new Error(SOL_SHORTFALL_MESSAGE);
|
|
1958
|
+
if (body.error || body.result === void 0) throw new Error(String(body.error?.message || "Invalid Solana RPC response."));
|
|
1959
|
+
return body.result;
|
|
1960
|
+
}
|
|
1961
|
+
async function direct(fetchImpl, url, payload) {
|
|
1962
|
+
const controller = new AbortController();
|
|
1963
|
+
const timer2 = setTimeout(() => controller.abort(), ATTEMPT_TIMEOUT_MS);
|
|
1964
|
+
try {
|
|
1965
|
+
const response = await fetchImpl(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: payload, signal: controller.signal });
|
|
1966
|
+
if (!response.ok) return { refused: `HTTP ${response.status}` };
|
|
1967
|
+
const body = await response.json().catch(() => null);
|
|
1968
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return { refused: "not a JSON-RPC body" };
|
|
1969
|
+
if (refusesService(body)) return { refused: `refused (${String(body.error?.code)})` };
|
|
1970
|
+
return { body };
|
|
1971
|
+
} catch (error) {
|
|
1972
|
+
return { refused: controller.signal.aborted ? "timed out" : error instanceof Error ? error.message : String(error) };
|
|
1973
|
+
} finally {
|
|
1974
|
+
clearTimeout(timer2);
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
function createSolanaRpc(api, fetchImpl = globalThis.fetch?.bind(globalThis), urls = BUNDLED_SOLANA_RPC) {
|
|
1978
|
+
return async (method, params) => {
|
|
1979
|
+
const payload = JSON.stringify({ jsonrpc: "2.0", id: 1, method, params });
|
|
1980
|
+
const refused = [];
|
|
1981
|
+
for (const url of urls) {
|
|
1982
|
+
const attempt = await direct(fetchImpl, url, payload);
|
|
1983
|
+
if ("body" in attempt) return unwrap(attempt.body);
|
|
1984
|
+
refused.push(`${new URL(url).host}: ${attempt.refused}`);
|
|
1985
|
+
}
|
|
1986
|
+
let relayed;
|
|
1987
|
+
try {
|
|
1988
|
+
relayed = await api.apiRequest("/solana-rpc", { method: "POST", body: payload, timeoutMs: 15e3 });
|
|
1989
|
+
} catch (error) {
|
|
1990
|
+
refused.push(`proxy: ${error instanceof Error ? error.message : String(error)}`);
|
|
1991
|
+
throw new Error(`No Solana RPC answered ${method} (${refused.join("; ")}).`);
|
|
1992
|
+
}
|
|
1993
|
+
return unwrap(relayed);
|
|
1994
|
+
};
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1946
1997
|
// src/core/solana-source.ts
|
|
1947
1998
|
var CANONICAL_SOLANA_PROGRAM = "zd1E5feCJLNYaPPsBAYkCPMKGVnipYf8God9h917W33";
|
|
1948
1999
|
var MAX_ASK_OVER_FINAL_BPS = 200n;
|
|
@@ -2192,18 +2243,6 @@ async function buildSolanaSourcePlan(api, input, quoted) {
|
|
|
2192
2243
|
});
|
|
2193
2244
|
return plan;
|
|
2194
2245
|
}
|
|
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
2246
|
var SolanaSendError = class extends Error {
|
|
2208
2247
|
constructor(message, signature, sentAt) {
|
|
2209
2248
|
super(message);
|
|
@@ -2350,6 +2389,10 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2350
2389
|
try {
|
|
2351
2390
|
solanaKeyBytes(owner);
|
|
2352
2391
|
solanaKeyBytes(mint);
|
|
2392
|
+
} catch {
|
|
2393
|
+
return void 0;
|
|
2394
|
+
}
|
|
2395
|
+
try {
|
|
2353
2396
|
const result = await rpc("getTokenAccountsByOwner", [owner, { mint }, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2354
2397
|
if (!Array.isArray(result.value)) throw new Error("Invalid token accounts.");
|
|
2355
2398
|
let total = 0n, decimals;
|
|
@@ -2360,10 +2403,30 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2360
2403
|
total += BigInt(raw(amount.amount, "token balance"));
|
|
2361
2404
|
}
|
|
2362
2405
|
return total;
|
|
2406
|
+
} catch {
|
|
2407
|
+
}
|
|
2408
|
+
try {
|
|
2409
|
+
return await associatedBalance(rpc, owner, mint);
|
|
2363
2410
|
} catch {
|
|
2364
2411
|
return void 0;
|
|
2365
2412
|
}
|
|
2366
2413
|
}
|
|
2414
|
+
async function associatedBalance(rpc, owner, mint) {
|
|
2415
|
+
const programs = [TOKEN_PROGRAM, TOKEN_2022_PROGRAM];
|
|
2416
|
+
const keys = [...programs.map((p) => associatedTokenAddress(owner, mint, p)), mint];
|
|
2417
|
+
const result = await rpc("getMultipleAccounts", [keys, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2418
|
+
const accounts = result?.value;
|
|
2419
|
+
if (!Array.isArray(accounts) || accounts.length !== keys.length) throw new Error("Invalid token accounts.");
|
|
2420
|
+
if (!accounts[2] || !programs.includes(accounts[2].owner)) throw new Error("Not a token mint.");
|
|
2421
|
+
let total = 0n;
|
|
2422
|
+
for (const [i, account] of accounts.slice(0, 2).entries()) {
|
|
2423
|
+
if (!account) continue;
|
|
2424
|
+
const info = account.data?.parsed?.info;
|
|
2425
|
+
if (account.owner !== programs[i] || info?.mint !== mint) throw new Error("Invalid token account.");
|
|
2426
|
+
total += BigInt(raw(info?.tokenAmount?.amount, "token balance"));
|
|
2427
|
+
}
|
|
2428
|
+
return total;
|
|
2429
|
+
}
|
|
2367
2430
|
function solanaLamportShortfall(logs) {
|
|
2368
2431
|
if (!Array.isArray(logs)) return null;
|
|
2369
2432
|
for (const line of logs) {
|
|
@@ -3562,7 +3625,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
3562
3625
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
3563
3626
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
3564
3627
|
var WIDGET_CHANNEL = "widget";
|
|
3565
|
-
var WIDGET_VERSION = "4.
|
|
3628
|
+
var WIDGET_VERSION = "4.17.0" ;
|
|
3566
3629
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
3567
3630
|
function sanitizeVersion(raw2) {
|
|
3568
3631
|
const v = String(raw2).trim();
|
|
@@ -4604,7 +4667,8 @@ function createEngine(config = {}) {
|
|
|
4604
4667
|
const resolved = resolveConfig(config);
|
|
4605
4668
|
const api = createApiClient(resolved);
|
|
4606
4669
|
const verifier = createVerifier(api, resolved.fetchImpl, resolved.rpcOverrides);
|
|
4607
|
-
const
|
|
4670
|
+
const solanaOverride = resolved.rpcOverrides[SOLANA_CHAIN_ID];
|
|
4671
|
+
const solanaRpc = createSolanaRpc(api, resolved.fetchImpl, solanaOverride && /^https?:\/\//i.test(solanaOverride) ? [solanaOverride] : BUNDLED_SOLANA_RPC);
|
|
4608
4672
|
return {
|
|
4609
4673
|
api,
|
|
4610
4674
|
verifier,
|
|
@@ -7636,7 +7700,7 @@ function QuoteChecks({
|
|
|
7636
7700
|
compliance,
|
|
7637
7701
|
cv,
|
|
7638
7702
|
checks,
|
|
7639
|
-
direct,
|
|
7703
|
+
direct: direct2,
|
|
7640
7704
|
onViewPolicy
|
|
7641
7705
|
}) {
|
|
7642
7706
|
const allPassed = cv.tone === "ok" && checks.length > 0 && checks.every((c) => c.ok);
|
|
@@ -7665,7 +7729,7 @@ function QuoteChecks({
|
|
|
7665
7729
|
] }),
|
|
7666
7730
|
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
7731
|
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
|
-
|
|
7732
|
+
direct2 && checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cp-scope", children: DIRECT_SCOPE_NOTE }) : null
|
|
7669
7733
|
] }),
|
|
7670
7734
|
compliance?.flaggedCategories?.length ? /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cp-card", children: [
|
|
7671
7735
|
/* @__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-TIMSRHXC.js';
|
|
2
|
+
import './chunk-5GVQQIGQ.js';
|