@moon-x/core 0.12.0 → 0.14.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/dist/{chunk-L7GL3PFM.mjs → chunk-7UGU27T3.mjs} +249 -7
- package/dist/{chunk-264CEGDS.mjs → chunk-HAEJD7NC.mjs} +4 -3
- package/dist/chunk-LP55IGPN.mjs +21 -0
- package/dist/{chunk-BJKWC4MG.mjs → chunk-PEIBEYMA.mjs} +3 -3
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -10
- package/dist/index.mjs +5 -5
- package/dist/lib/index.d.mts +40 -4
- package/dist/lib/index.d.ts +40 -4
- package/dist/lib/index.js +258 -10
- package/dist/lib/index.mjs +12 -2
- package/dist/react/ethereum.js +9 -9
- package/dist/react/ethereum.mjs +9 -9
- package/dist/react/index.d.mts +14 -10
- package/dist/react/index.d.ts +14 -10
- package/dist/react/index.js +23 -15
- package/dist/react/index.mjs +16 -16
- package/dist/react/solana.js +6 -6
- package/dist/react/solana.mjs +6 -6
- package/dist/react/tron.d.mts +16 -0
- package/dist/react/tron.d.ts +16 -0
- package/dist/react/tron.js +95 -0
- package/dist/react/tron.mjs +55 -0
- package/dist/sdk/index.d.mts +17 -5
- package/dist/sdk/index.d.ts +17 -5
- package/dist/sdk/index.js +141 -0
- package/dist/sdk/index.mjs +107 -2
- package/dist/types/index.d.mts +98 -8
- package/dist/types/index.d.ts +98 -8
- package/dist/types/index.mjs +1 -1
- package/dist/utils/index.d.mts +3 -3
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +12 -10
- package/dist/utils/index.mjs +4 -4
- package/dist/web/index.js +5 -4
- package/dist/web/index.mjs +2 -2
- package/package.json +6 -1
- package/dist/chunk-GQKIA37O.mjs +0 -20
- /package/dist/{chunk-IMLBIIJ4.mjs → chunk-CEL3U6EI.mjs} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
getMoonXApiUrl
|
|
3
|
+
} from "./chunk-LP55IGPN.mjs";
|
|
4
4
|
|
|
5
5
|
// src/lib/auth/authentication-state.ts
|
|
6
6
|
var AuthenticationState = class {
|
|
@@ -49,7 +49,7 @@ function sanitizeUserData(userData) {
|
|
|
49
49
|
// src/lib/auth/verify-id-token.ts
|
|
50
50
|
var verifyIdToken = async (publishableKey, idToken) => {
|
|
51
51
|
try {
|
|
52
|
-
const apiUrl =
|
|
52
|
+
const apiUrl = getMoonXApiUrl();
|
|
53
53
|
const response = await fetch(
|
|
54
54
|
`${apiUrl}/v1/auth/users/public/id_token/verify`,
|
|
55
55
|
{
|
|
@@ -420,6 +420,9 @@ function isChainSupported(chains, chainId) {
|
|
|
420
420
|
function isEvmEntry(entry) {
|
|
421
421
|
return "chain" in entry;
|
|
422
422
|
}
|
|
423
|
+
function isTronEntry(entry) {
|
|
424
|
+
return !isEvmEntry(entry) && entry.id.split(":")[0].toLowerCase() === "tron";
|
|
425
|
+
}
|
|
423
426
|
function normalizeChainItem(item) {
|
|
424
427
|
if ("chain" in item) return item;
|
|
425
428
|
if (typeof item.id === "number") {
|
|
@@ -448,8 +451,14 @@ function aliasesFor(entry) {
|
|
|
448
451
|
}
|
|
449
452
|
} else {
|
|
450
453
|
keys.push(entry.id);
|
|
451
|
-
const cluster = entry.id.split(":")
|
|
452
|
-
if (cluster)
|
|
454
|
+
const [ns, cluster] = entry.id.split(":");
|
|
455
|
+
if (cluster) {
|
|
456
|
+
if (ns.toLowerCase() === "tron") {
|
|
457
|
+
keys.push(`tron:${cluster}`, `trx:${cluster}`);
|
|
458
|
+
} else {
|
|
459
|
+
keys.push(`solana:${cluster}`, `sol:${cluster}`, cluster);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
453
462
|
}
|
|
454
463
|
return keys;
|
|
455
464
|
}
|
|
@@ -488,10 +497,20 @@ function resolveSolanaChainEntry(chains, selector, defaultSelector) {
|
|
|
488
497
|
const asSolana = (k) => {
|
|
489
498
|
if (k == null) return void 0;
|
|
490
499
|
const e = index.byAlias.get(normalizeChainKey(k));
|
|
491
|
-
return e && !isEvmEntry(e) ? e : void 0;
|
|
500
|
+
return e && !isEvmEntry(e) && !isTronEntry(e) ? e : void 0;
|
|
492
501
|
};
|
|
493
502
|
if (selector != null) return asSolana(selector);
|
|
494
|
-
return asSolana(defaultSelector) ?? index.entries.find((e) => !isEvmEntry(e));
|
|
503
|
+
return asSolana(defaultSelector) ?? index.entries.find((e) => !isEvmEntry(e) && !isTronEntry(e));
|
|
504
|
+
}
|
|
505
|
+
function resolveTronChainEntry(chains, selector, defaultSelector) {
|
|
506
|
+
const index = buildChainIndex(chains ?? []);
|
|
507
|
+
const asTron = (k) => {
|
|
508
|
+
if (k == null) return void 0;
|
|
509
|
+
const e = index.byAlias.get(normalizeChainKey(k));
|
|
510
|
+
return e && isTronEntry(e) ? e : void 0;
|
|
511
|
+
};
|
|
512
|
+
if (selector != null) return asTron(selector);
|
|
513
|
+
return asTron(defaultSelector) ?? index.entries.find(isTronEntry);
|
|
495
514
|
}
|
|
496
515
|
function resolveEvmChainEntry(opts) {
|
|
497
516
|
const index = buildChainIndex(opts.chains ?? []);
|
|
@@ -1427,6 +1446,195 @@ async function getSOLTransfersFromInstructions(base64Transaction, logs, solPrice
|
|
|
1427
1446
|
return transfers;
|
|
1428
1447
|
}
|
|
1429
1448
|
|
|
1449
|
+
// src/lib/tron/tron-address.ts
|
|
1450
|
+
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
1451
|
+
import { keccak_256 } from "@noble/hashes/sha3";
|
|
1452
|
+
import { sha256 } from "@noble/hashes/sha256";
|
|
1453
|
+
async function tronAddressFromPublicKey(publicKeyHex) {
|
|
1454
|
+
const { default: bs58 } = await import("bs58");
|
|
1455
|
+
const clean = publicKeyHex.replace(/^0x/, "");
|
|
1456
|
+
const uncompressed = secp256k1.ProjectivePoint.fromHex(clean).toRawBytes(
|
|
1457
|
+
false
|
|
1458
|
+
);
|
|
1459
|
+
const hash = keccak_256(uncompressed.subarray(1));
|
|
1460
|
+
const payload = new Uint8Array(21);
|
|
1461
|
+
payload[0] = 65;
|
|
1462
|
+
payload.set(hash.subarray(12), 1);
|
|
1463
|
+
const checksum = sha256(sha256(payload)).subarray(0, 4);
|
|
1464
|
+
const full = new Uint8Array(25);
|
|
1465
|
+
full.set(payload);
|
|
1466
|
+
full.set(checksum, 21);
|
|
1467
|
+
return bs58.encode(full);
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
// src/lib/tron/decode-raw-data.ts
|
|
1471
|
+
import { sha256 as sha2562 } from "@noble/hashes/sha256";
|
|
1472
|
+
function readVarint(buf, pos) {
|
|
1473
|
+
let result = BigInt(0);
|
|
1474
|
+
let shift = BigInt(0);
|
|
1475
|
+
for (; ; ) {
|
|
1476
|
+
const b = buf[pos++];
|
|
1477
|
+
if (b === void 0) throw new Error("truncated varint");
|
|
1478
|
+
result |= BigInt(b & 127) << shift;
|
|
1479
|
+
if ((b & 128) === 0) return [result, pos];
|
|
1480
|
+
shift += BigInt(7);
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
function readFields(buf) {
|
|
1484
|
+
const fields = [];
|
|
1485
|
+
let pos = 0;
|
|
1486
|
+
while (pos < buf.length) {
|
|
1487
|
+
const [tag, p1] = readVarint(buf, pos);
|
|
1488
|
+
const num = Number(tag >> BigInt(3));
|
|
1489
|
+
const wire = Number(tag & BigInt(7));
|
|
1490
|
+
pos = p1;
|
|
1491
|
+
if (wire === 0) {
|
|
1492
|
+
const [v, p2] = readVarint(buf, pos);
|
|
1493
|
+
fields.push({ num, wire, varint: v });
|
|
1494
|
+
pos = p2;
|
|
1495
|
+
} else if (wire === 2) {
|
|
1496
|
+
const [len, p2] = readVarint(buf, pos);
|
|
1497
|
+
const end = p2 + Number(len);
|
|
1498
|
+
if (end > buf.length) throw new Error("truncated field");
|
|
1499
|
+
fields.push({ num, wire, bytes: buf.subarray(p2, end) });
|
|
1500
|
+
pos = end;
|
|
1501
|
+
} else if (wire === 5 || wire === 1) {
|
|
1502
|
+
const n = wire === 5 ? 4 : 8;
|
|
1503
|
+
if (pos + n > buf.length) throw new Error("truncated fixed field");
|
|
1504
|
+
fields.push({ num, wire, bytes: buf.subarray(pos, pos + n) });
|
|
1505
|
+
pos += n;
|
|
1506
|
+
} else {
|
|
1507
|
+
throw new Error(`unsupported wire type ${wire}`);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
return fields;
|
|
1511
|
+
}
|
|
1512
|
+
var toHex = (b) => Array.from(b, (x) => x.toString(16).padStart(2, "0")).join("");
|
|
1513
|
+
async function addressFromBytes(b) {
|
|
1514
|
+
const { default: bs58 } = await import("bs58");
|
|
1515
|
+
const checksum = sha2562(sha2562(b)).subarray(0, 4);
|
|
1516
|
+
const full = new Uint8Array(b.length + 4);
|
|
1517
|
+
full.set(b);
|
|
1518
|
+
full.set(checksum, b.length);
|
|
1519
|
+
return bs58.encode(full);
|
|
1520
|
+
}
|
|
1521
|
+
async function fieldValue(f, addressy) {
|
|
1522
|
+
if (f.wire === 0) return f.varint.toString();
|
|
1523
|
+
const b = f.bytes;
|
|
1524
|
+
if (addressy && b.length === 21 && b[0] === 65) return addressFromBytes(b);
|
|
1525
|
+
return toHex(b);
|
|
1526
|
+
}
|
|
1527
|
+
var CONTRACT_TYPES = {
|
|
1528
|
+
0: "AccountCreateContract",
|
|
1529
|
+
1: "TransferContract",
|
|
1530
|
+
2: "TransferAssetContract",
|
|
1531
|
+
4: "VoteWitnessContract",
|
|
1532
|
+
11: "FreezeBalanceContract",
|
|
1533
|
+
12: "UnfreezeBalanceContract",
|
|
1534
|
+
13: "WithdrawBalanceContract",
|
|
1535
|
+
31: "TriggerSmartContract",
|
|
1536
|
+
54: "FreezeBalanceV2Contract",
|
|
1537
|
+
55: "UnfreezeBalanceV2Contract",
|
|
1538
|
+
57: "DelegateResourceContract",
|
|
1539
|
+
58: "UnDelegateResourceContract"
|
|
1540
|
+
};
|
|
1541
|
+
var CONTRACT_FIELDS = {
|
|
1542
|
+
TransferContract: { 1: "owner_address", 2: "to_address", 3: "amount" },
|
|
1543
|
+
TransferAssetContract: {
|
|
1544
|
+
1: "asset_name",
|
|
1545
|
+
2: "owner_address",
|
|
1546
|
+
3: "to_address",
|
|
1547
|
+
4: "amount"
|
|
1548
|
+
},
|
|
1549
|
+
TriggerSmartContract: {
|
|
1550
|
+
1: "owner_address",
|
|
1551
|
+
2: "contract_address",
|
|
1552
|
+
3: "call_value",
|
|
1553
|
+
4: "data",
|
|
1554
|
+
5: "call_token_value",
|
|
1555
|
+
6: "token_id"
|
|
1556
|
+
}
|
|
1557
|
+
};
|
|
1558
|
+
async function decodeContract(buf) {
|
|
1559
|
+
const out = {};
|
|
1560
|
+
let typeName = "";
|
|
1561
|
+
let anyValue;
|
|
1562
|
+
for (const f of readFields(buf)) {
|
|
1563
|
+
if (f.num === 1 && f.wire === 0) {
|
|
1564
|
+
const n = Number(f.varint);
|
|
1565
|
+
typeName = CONTRACT_TYPES[n] ?? `ContractType(${n})`;
|
|
1566
|
+
out.type = typeName;
|
|
1567
|
+
} else if (f.num === 2 && f.bytes) {
|
|
1568
|
+
for (const a of readFields(f.bytes)) {
|
|
1569
|
+
if (a.num === 1 && a.bytes) {
|
|
1570
|
+
out.type_url = new TextDecoder().decode(a.bytes);
|
|
1571
|
+
} else if (a.num === 2 && a.bytes) {
|
|
1572
|
+
anyValue = a.bytes;
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
} else if (f.num === 5) {
|
|
1576
|
+
out.Permission_id = await fieldValue(f, false);
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
if (anyValue) {
|
|
1580
|
+
const names = CONTRACT_FIELDS[typeName];
|
|
1581
|
+
if (names) {
|
|
1582
|
+
const value = {};
|
|
1583
|
+
for (const f of readFields(anyValue)) {
|
|
1584
|
+
const name = names[f.num] ?? `field_${f.num}`;
|
|
1585
|
+
value[name] = await fieldValue(f, name.endsWith("_address"));
|
|
1586
|
+
}
|
|
1587
|
+
out.parameter = value;
|
|
1588
|
+
} else {
|
|
1589
|
+
out.parameter_hex = toHex(anyValue);
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
return out;
|
|
1593
|
+
}
|
|
1594
|
+
async function decodeTronRawData(rawDataHex) {
|
|
1595
|
+
const clean = rawDataHex.replace(/^0x/i, "");
|
|
1596
|
+
if (!/^[0-9a-fA-F]*$/.test(clean) || clean.length % 2 !== 0) {
|
|
1597
|
+
throw new Error("raw_data_hex is not valid hex");
|
|
1598
|
+
}
|
|
1599
|
+
const buf = Uint8Array.from(
|
|
1600
|
+
clean.match(/.{2}/g)?.map((h) => parseInt(h, 16)) ?? []
|
|
1601
|
+
);
|
|
1602
|
+
const out = {};
|
|
1603
|
+
const contracts = [];
|
|
1604
|
+
for (const f of readFields(buf)) {
|
|
1605
|
+
switch (f.num) {
|
|
1606
|
+
case 1:
|
|
1607
|
+
out.ref_block_bytes = toHex(f.bytes);
|
|
1608
|
+
break;
|
|
1609
|
+
case 3:
|
|
1610
|
+
out.ref_block_num = f.varint.toString();
|
|
1611
|
+
break;
|
|
1612
|
+
case 4:
|
|
1613
|
+
out.ref_block_hash = toHex(f.bytes);
|
|
1614
|
+
break;
|
|
1615
|
+
case 8:
|
|
1616
|
+
out.expiration = Number(f.varint);
|
|
1617
|
+
break;
|
|
1618
|
+
case 10:
|
|
1619
|
+
out.data = new TextDecoder().decode(f.bytes);
|
|
1620
|
+
break;
|
|
1621
|
+
case 11:
|
|
1622
|
+
contracts.push(await decodeContract(f.bytes));
|
|
1623
|
+
break;
|
|
1624
|
+
case 14:
|
|
1625
|
+
out.timestamp = Number(f.varint);
|
|
1626
|
+
break;
|
|
1627
|
+
case 18:
|
|
1628
|
+
out.fee_limit = f.varint.toString();
|
|
1629
|
+
break;
|
|
1630
|
+
default:
|
|
1631
|
+
out[`field_${f.num}`] = f.wire === 0 ? f.varint.toString() : toHex(f.bytes);
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
out.contract = contracts;
|
|
1635
|
+
return out;
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1430
1638
|
// src/lib/build-url.ts
|
|
1431
1639
|
var buildUrl = (baseUrl, sdkConfig, enableCaptcha, captchaSitekey) => {
|
|
1432
1640
|
if (!sdkConfig.publishableKey) {
|
|
@@ -1569,11 +1777,40 @@ var broadcastSolanaSigned = async (rpcUrl, signedBase58) => {
|
|
|
1569
1777
|
}
|
|
1570
1778
|
return result.result;
|
|
1571
1779
|
};
|
|
1780
|
+
var broadcastTronSigned = async (rpcUrl, signedTransaction) => {
|
|
1781
|
+
const response = await fetch(
|
|
1782
|
+
`${rpcUrl.replace(/\/$/, "")}/wallet/broadcasttransaction`,
|
|
1783
|
+
{
|
|
1784
|
+
method: "POST",
|
|
1785
|
+
headers: { "Content-Type": "application/json" },
|
|
1786
|
+
body: JSON.stringify(signedTransaction)
|
|
1787
|
+
}
|
|
1788
|
+
);
|
|
1789
|
+
const result = await response.json();
|
|
1790
|
+
if (!result.result) {
|
|
1791
|
+
let message = result.message ?? "";
|
|
1792
|
+
if (/^[0-9a-fA-F]+$/.test(message) && message.length % 2 === 0) {
|
|
1793
|
+
try {
|
|
1794
|
+
message = new TextDecoder().decode(
|
|
1795
|
+
Uint8Array.from(
|
|
1796
|
+
message.match(/.{2}/g).map((h) => parseInt(h, 16))
|
|
1797
|
+
)
|
|
1798
|
+
);
|
|
1799
|
+
} catch {
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
throw new Error(
|
|
1803
|
+
`Tron broadcast failed: ${result.code ?? "UNKNOWN"} ${message}`.trim()
|
|
1804
|
+
);
|
|
1805
|
+
}
|
|
1806
|
+
return result.txid ?? signedTransaction.txID;
|
|
1807
|
+
};
|
|
1572
1808
|
|
|
1573
1809
|
// src/lib/wallet-algorithm.ts
|
|
1574
1810
|
function canonicalAlgorithmFor(chain) {
|
|
1575
1811
|
switch (chain) {
|
|
1576
1812
|
case "ethereum":
|
|
1813
|
+
case "tron":
|
|
1577
1814
|
return "ecdsa";
|
|
1578
1815
|
case "solana":
|
|
1579
1816
|
return "exportable-ed25519";
|
|
@@ -1633,12 +1870,14 @@ export {
|
|
|
1633
1870
|
getChainById,
|
|
1634
1871
|
isChainSupported,
|
|
1635
1872
|
isEvmEntry,
|
|
1873
|
+
isTronEntry,
|
|
1636
1874
|
normalizeChainItem,
|
|
1637
1875
|
entryCaip2,
|
|
1638
1876
|
normalizeChainKey,
|
|
1639
1877
|
buildChainIndex,
|
|
1640
1878
|
resolveChainEntry,
|
|
1641
1879
|
resolveSolanaChainEntry,
|
|
1880
|
+
resolveTronChainEntry,
|
|
1642
1881
|
resolveEvmChainEntry,
|
|
1643
1882
|
resolveRpcUrl,
|
|
1644
1883
|
resolveWsUrl,
|
|
@@ -1653,11 +1892,14 @@ export {
|
|
|
1653
1892
|
getInstructionsForHTML,
|
|
1654
1893
|
getTransferInfoFromInstructions,
|
|
1655
1894
|
getSOLTransfersFromInstructions,
|
|
1895
|
+
tronAddressFromPublicKey,
|
|
1896
|
+
decodeTronRawData,
|
|
1656
1897
|
buildUrl,
|
|
1657
1898
|
DEFAULT_AUTH_URL,
|
|
1658
1899
|
serializeEthereumTransaction,
|
|
1659
1900
|
broadcastEthereumRaw,
|
|
1660
1901
|
broadcastSolanaSigned,
|
|
1902
|
+
broadcastTronSigned,
|
|
1661
1903
|
canonicalAlgorithmFor,
|
|
1662
1904
|
parseDerivationPath,
|
|
1663
1905
|
arrayLikeToBytes,
|
|
@@ -18,15 +18,16 @@ var getIframeUrl = (path = "") => {
|
|
|
18
18
|
/^https?:\/\//,
|
|
19
19
|
""
|
|
20
20
|
).replace(/\/$/, "");
|
|
21
|
-
const iframeProjectName = process.env.NEXT_PUBLIC_MOONKEY_IFRAME_PROJECT_NAME || DEFAULT_IFRAME_PROJECT_NAME;
|
|
21
|
+
const iframeProjectName = process.env.NEXT_PUBLIC_MOONX_IFRAME_PROJECT_NAME || process.env.NEXT_PUBLIC_MOONKEY_IFRAME_PROJECT_NAME || DEFAULT_IFRAME_PROJECT_NAME;
|
|
22
22
|
const iframeUrl = /-git-/.test(vercelUrl) ? vercelUrl.replace(/^[^.]+?-git-/, `${iframeProjectName}-git-`) : (
|
|
23
23
|
// Fallback: legacy `{prefix}-{hash}.vercel.app` style
|
|
24
24
|
vercelUrl.replace(/^[^-]+-/, `${iframeProjectName}-`)
|
|
25
25
|
);
|
|
26
26
|
return withBypass(joinUrl(`https://${iframeUrl}`, path));
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const iframeUrlOverride = process.env.NEXT_PUBLIC_MOONX_IFRAME_URL || process.env.NEXT_PUBLIC_MOONKEY_IFRAME_URL;
|
|
29
|
+
if (iframeUrlOverride) {
|
|
30
|
+
return joinUrl(iframeUrlOverride, path);
|
|
30
31
|
}
|
|
31
32
|
return joinUrl("https://iframe.moonx-dev.com", path);
|
|
32
33
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/utils/get-api-url.ts
|
|
2
|
+
var getMoonXApiUrl = () => {
|
|
3
|
+
const apiUrlOverride = process.env?.NEXT_PUBLIC_MOONX_API_URL || process.env?.NEXT_PUBLIC_MOONKEY_API_URL;
|
|
4
|
+
if (apiUrlOverride) {
|
|
5
|
+
return apiUrlOverride;
|
|
6
|
+
}
|
|
7
|
+
const iframeUrl = process.env?.NEXT_PUBLIC_MOONX_IFRAME_URL || process.env?.NEXT_PUBLIC_MOONKEY_IFRAME_URL;
|
|
8
|
+
if (iframeUrl) {
|
|
9
|
+
if (iframeUrl.includes("staging") || iframeUrl.includes("auth-staging")) {
|
|
10
|
+
return "https://api.moonx-dev.com";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (process.env?.NEXT_PUBLIC_VERCEL_ENV === "preview") {
|
|
14
|
+
return "https://api.moonx-dev.com";
|
|
15
|
+
}
|
|
16
|
+
return "https://api.moonx-dev.com";
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
getMoonXApiUrl
|
|
21
|
+
};
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
var SDKContext = createContext(null);
|
|
4
4
|
var SDKProvider = SDKContext.Provider;
|
|
5
|
-
var
|
|
5
|
+
var useMoonXSDK = () => {
|
|
6
6
|
const sdk = useContext(SDKContext);
|
|
7
7
|
if (!sdk) {
|
|
8
8
|
throw new Error(
|
|
9
|
-
"
|
|
9
|
+
"MoonX hook called outside a <MoonXProvider> \u2014 wrap your app in the provider from @moon-x/react-sdk (web) or @moon-x/react-native-sdk (RN)."
|
|
10
10
|
);
|
|
11
11
|
}
|
|
12
12
|
return sdk;
|
|
@@ -14,5 +14,5 @@ var useMoonKeySDK = () => {
|
|
|
14
14
|
|
|
15
15
|
export {
|
|
16
16
|
SDKProvider,
|
|
17
|
-
|
|
17
|
+
useMoonXSDK
|
|
18
18
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { AccessTokenClaims, AppConfigRequest, AppConfigResponse, AppearanceBackdrop, AppearanceBorderRadius, AppearanceCard, AppearanceColors, AppearanceComponents, AppearanceLogo, AppearanceModeTokens, AppearanceTypography, AttachOAuthTokenRequest, AttachOAuthTokenResponse, AuthAppearance, AuthFlow, AuthFlowComponent, AuthLoginMethod, AuthProviderConfig, BaseGetBalanceParams, BaseGetBalanceResult, BaseGetTokenAccountsParams, BaseSendTransactionParams, BaseSendTransactionResult, BaseSignMessageParams, BaseSignMessageResult, BaseSignTransactionParams, BaseSignTransactionResult, BaseTokenClaims, BaseUIOptions, BaseWalletHooks, BlockExplorer, Chain, ChainConfigItem, ChainEntry, ChainLikeWithId, ComponentStyle, ContractUIOptions, CreateWalletResponse, DefaultFundingMethod, DeleteSessionRequest, DeleteSessionResponse, DetachOAuthTokenRequest, DeviceFingerprint, DisplayMode, EmailOtpConfig, EmailOtpFlowState, EphemeralSigner, EphemeralSignerChain, EphemeralSignerScheme, EphemeralSignerWallet, EthereumFundingConfig, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumGetTokenAccountsByOwnerParams, EthereumGetTokenAccountsByOwnerResult, EthereumSendTransactionParams, EthereumSendTransactionRequest, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSwitchChainParams, EvmChainEntry, ExportKeyConfig, Factor, FlexibleTheme, FundWalletConfig, FundingEvents, FundingMethod, FundingUIConfig, GetCurrentSessionRequest, GetCurrentSessionResponse, Hex, IdentityTokenClaims, IdpProvider, IsAuthenticatedRequest, IsAuthenticatedResponse, ListEphemeralSignersResult, LoginTokenBundle, LogoutRequest, LogoutResponse, MessageTypeProperty, MessageTypes, MoonPaySignRequest, MoonPaySignResponse, MpcKeyShares, NativeCurrency, Network, OAuthRequest, OAuthResponse, OnrampFundingSettings, PasskeyEnrollConfig, PasskeySettings, PreferredCardProvider, PrefillConfig, PresenceTokenClaims, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, PublicEthereumWallet, PublicSessionData, PublicWallet, RefreshSessionRequest, RefreshSessionResponse, RetrieveWalletKeyRequest, RetrieveWalletKeyResponse, RevokeEphemeralSignerParams, RpcConfig, RpcUrls, SdkSettings, SendEmailOtpRequest, SendEmailOtpResponse, SendTransactionConfig, SendTransactionRequest, SessionData, SessionWallet, SharesDeviceRequest, SharesDeviceResponse, Sign7702AuthorizationError, Sign7702AuthorizationParams, Sign7702AuthorizationResponse, Sign7702AuthorizationResult, SignMessageConfig, SignTransactionConfig, SignTypedDataError, SignTypedDataParams, SignTypedDataResponse, SignTypedDataResult, SmsSettings, SolanaChain, SolanaChainEntry, SolanaFundingConfig, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, TransactionCommitment, TransactionEncoding, TransactionUIOptions, TypedMessage, UseFundWalletInterface, UsersMePublicResponse, UsersMeRequest, UsersMeResponse, VerifiedSession, VerifyEmailOtpRequest, VerifyEmailOtpResponse, VerifyEmailOtpUser, VerifyOAuthTokenRequest, VerifyOAuthTokenResponse, VerifySiweWalletRegistrationRequest, WALLET_ERROR_CODES, Wallet, WalletChain, WalletChainType, WalletConnectConfig, WalletCreationError, WalletError, WalletErrorCode, WalletKeyRequest, WalletListEntry, WalletRegistrationNonceRequest, WalletRegistrationNonceResponse, WalletType, WalletVerifyRequest } from './types/index.mjs';
|
|
2
|
-
export { FONT_URLS_KEY, getIframeOrigin, getIframeUrl,
|
|
1
|
+
export { AccessTokenClaims, AppConfigRequest, AppConfigResponse, AppearanceBackdrop, AppearanceBorderRadius, AppearanceCard, AppearanceColors, AppearanceComponents, AppearanceLogo, AppearanceModeTokens, AppearanceTypography, AttachOAuthTokenRequest, AttachOAuthTokenResponse, AuthAppearance, AuthFlow, AuthFlowComponent, AuthLoginMethod, AuthProviderConfig, BaseGetBalanceParams, BaseGetBalanceResult, BaseGetTokenAccountsParams, BaseSendTransactionParams, BaseSendTransactionResult, BaseSignMessageParams, BaseSignMessageResult, BaseSignTransactionParams, BaseSignTransactionResult, BaseTokenClaims, BaseUIOptions, BaseWalletHooks, BlockExplorer, Chain, ChainConfigItem, ChainEntry, ChainLikeWithId, ComponentStyle, ContractUIOptions, CreateWalletResponse, DefaultFundingMethod, DeleteSessionRequest, DeleteSessionResponse, DetachOAuthTokenRequest, DeviceFingerprint, DisplayMode, EmailOtpConfig, EmailOtpFlowState, EphemeralSigner, EphemeralSignerChain, EphemeralSignerScheme, EphemeralSignerWallet, EthereumFundingConfig, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumGetTokenAccountsByOwnerParams, EthereumGetTokenAccountsByOwnerResult, EthereumSendTransactionParams, EthereumSendTransactionRequest, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSwitchChainParams, EvmChainEntry, ExportKeyConfig, Factor, FlexibleTheme, FundWalletConfig, FundingEvents, FundingMethod, FundingUIConfig, GetCurrentSessionRequest, GetCurrentSessionResponse, Hex, IdentityTokenClaims, IdpProvider, IsAuthenticatedRequest, IsAuthenticatedResponse, ListEphemeralSignersResult, LoginTokenBundle, LogoutRequest, LogoutResponse, MessageTypeProperty, MessageTypes, MoonPaySignRequest, MoonPaySignResponse, MpcKeyShares, NativeCurrency, Network, OAuthRequest, OAuthResponse, OnrampFundingSettings, PasskeyEnrollConfig, PasskeySettings, PreferredCardProvider, PrefillConfig, PresenceTokenClaims, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, PublicEthereumWallet, PublicSessionData, PublicWallet, RefreshSessionRequest, RefreshSessionResponse, RetrieveWalletKeyRequest, RetrieveWalletKeyResponse, RevokeEphemeralSignerParams, RpcConfig, RpcUrls, SdkSettings, SendEmailOtpRequest, SendEmailOtpResponse, SendTransactionConfig, SendTransactionRequest, SessionData, SessionWallet, SharesDeviceRequest, SharesDeviceResponse, Sign7702AuthorizationError, Sign7702AuthorizationParams, Sign7702AuthorizationResponse, Sign7702AuthorizationResult, SignMessageConfig, SignTransactionConfig, SignTypedDataError, SignTypedDataParams, SignTypedDataResponse, SignTypedDataResult, SmsSettings, SolanaChain, SolanaChainEntry, SolanaFundingConfig, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, TransactionCommitment, TransactionEncoding, TransactionUIOptions, TronChainEntry, TronGetBalanceParams, TronGetBalanceResult, TronSendTransactionParams, TronSendTransactionResult, TronSignMessageParams, TronSignMessageResult, TronSignTransactionParams, TronSignTransactionResult, TronTransactionJson, TypedMessage, UseFundWalletInterface, UsersMePublicResponse, UsersMeRequest, UsersMeResponse, VerifiedSession, VerifyEmailOtpRequest, VerifyEmailOtpResponse, VerifyEmailOtpUser, VerifyOAuthTokenRequest, VerifyOAuthTokenResponse, VerifySiweWalletRegistrationRequest, WALLET_ERROR_CODES, Wallet, WalletChain, WalletChainType, WalletConnectConfig, WalletCreationError, WalletError, WalletErrorCode, WalletKeyRequest, WalletListEntry, WalletRegistrationNonceRequest, WalletRegistrationNonceResponse, WalletType, WalletVerifyRequest } from './types/index.mjs';
|
|
2
|
+
export { FONT_URLS_KEY, getIframeOrigin, getIframeUrl, getMoonXApiUrl } from './utils/index.mjs';
|
|
3
3
|
export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from './post-message-BR2NClJ5.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { AccessTokenClaims, AppConfigRequest, AppConfigResponse, AppearanceBackdrop, AppearanceBorderRadius, AppearanceCard, AppearanceColors, AppearanceComponents, AppearanceLogo, AppearanceModeTokens, AppearanceTypography, AttachOAuthTokenRequest, AttachOAuthTokenResponse, AuthAppearance, AuthFlow, AuthFlowComponent, AuthLoginMethod, AuthProviderConfig, BaseGetBalanceParams, BaseGetBalanceResult, BaseGetTokenAccountsParams, BaseSendTransactionParams, BaseSendTransactionResult, BaseSignMessageParams, BaseSignMessageResult, BaseSignTransactionParams, BaseSignTransactionResult, BaseTokenClaims, BaseUIOptions, BaseWalletHooks, BlockExplorer, Chain, ChainConfigItem, ChainEntry, ChainLikeWithId, ComponentStyle, ContractUIOptions, CreateWalletResponse, DefaultFundingMethod, DeleteSessionRequest, DeleteSessionResponse, DetachOAuthTokenRequest, DeviceFingerprint, DisplayMode, EmailOtpConfig, EmailOtpFlowState, EphemeralSigner, EphemeralSignerChain, EphemeralSignerScheme, EphemeralSignerWallet, EthereumFundingConfig, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumGetTokenAccountsByOwnerParams, EthereumGetTokenAccountsByOwnerResult, EthereumSendTransactionParams, EthereumSendTransactionRequest, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSwitchChainParams, EvmChainEntry, ExportKeyConfig, Factor, FlexibleTheme, FundWalletConfig, FundingEvents, FundingMethod, FundingUIConfig, GetCurrentSessionRequest, GetCurrentSessionResponse, Hex, IdentityTokenClaims, IdpProvider, IsAuthenticatedRequest, IsAuthenticatedResponse, ListEphemeralSignersResult, LoginTokenBundle, LogoutRequest, LogoutResponse, MessageTypeProperty, MessageTypes, MoonPaySignRequest, MoonPaySignResponse, MpcKeyShares, NativeCurrency, Network, OAuthRequest, OAuthResponse, OnrampFundingSettings, PasskeyEnrollConfig, PasskeySettings, PreferredCardProvider, PrefillConfig, PresenceTokenClaims, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, PublicEthereumWallet, PublicSessionData, PublicWallet, RefreshSessionRequest, RefreshSessionResponse, RetrieveWalletKeyRequest, RetrieveWalletKeyResponse, RevokeEphemeralSignerParams, RpcConfig, RpcUrls, SdkSettings, SendEmailOtpRequest, SendEmailOtpResponse, SendTransactionConfig, SendTransactionRequest, SessionData, SessionWallet, SharesDeviceRequest, SharesDeviceResponse, Sign7702AuthorizationError, Sign7702AuthorizationParams, Sign7702AuthorizationResponse, Sign7702AuthorizationResult, SignMessageConfig, SignTransactionConfig, SignTypedDataError, SignTypedDataParams, SignTypedDataResponse, SignTypedDataResult, SmsSettings, SolanaChain, SolanaChainEntry, SolanaFundingConfig, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, TransactionCommitment, TransactionEncoding, TransactionUIOptions, TypedMessage, UseFundWalletInterface, UsersMePublicResponse, UsersMeRequest, UsersMeResponse, VerifiedSession, VerifyEmailOtpRequest, VerifyEmailOtpResponse, VerifyEmailOtpUser, VerifyOAuthTokenRequest, VerifyOAuthTokenResponse, VerifySiweWalletRegistrationRequest, WALLET_ERROR_CODES, Wallet, WalletChain, WalletChainType, WalletConnectConfig, WalletCreationError, WalletError, WalletErrorCode, WalletKeyRequest, WalletListEntry, WalletRegistrationNonceRequest, WalletRegistrationNonceResponse, WalletType, WalletVerifyRequest } from './types/index.js';
|
|
2
|
-
export { FONT_URLS_KEY, getIframeOrigin, getIframeUrl,
|
|
1
|
+
export { AccessTokenClaims, AppConfigRequest, AppConfigResponse, AppearanceBackdrop, AppearanceBorderRadius, AppearanceCard, AppearanceColors, AppearanceComponents, AppearanceLogo, AppearanceModeTokens, AppearanceTypography, AttachOAuthTokenRequest, AttachOAuthTokenResponse, AuthAppearance, AuthFlow, AuthFlowComponent, AuthLoginMethod, AuthProviderConfig, BaseGetBalanceParams, BaseGetBalanceResult, BaseGetTokenAccountsParams, BaseSendTransactionParams, BaseSendTransactionResult, BaseSignMessageParams, BaseSignMessageResult, BaseSignTransactionParams, BaseSignTransactionResult, BaseTokenClaims, BaseUIOptions, BaseWalletHooks, BlockExplorer, Chain, ChainConfigItem, ChainEntry, ChainLikeWithId, ComponentStyle, ContractUIOptions, CreateWalletResponse, DefaultFundingMethod, DeleteSessionRequest, DeleteSessionResponse, DetachOAuthTokenRequest, DeviceFingerprint, DisplayMode, EmailOtpConfig, EmailOtpFlowState, EphemeralSigner, EphemeralSignerChain, EphemeralSignerScheme, EphemeralSignerWallet, EthereumFundingConfig, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumGetTokenAccountsByOwnerParams, EthereumGetTokenAccountsByOwnerResult, EthereumSendTransactionParams, EthereumSendTransactionRequest, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSwitchChainParams, EvmChainEntry, ExportKeyConfig, Factor, FlexibleTheme, FundWalletConfig, FundingEvents, FundingMethod, FundingUIConfig, GetCurrentSessionRequest, GetCurrentSessionResponse, Hex, IdentityTokenClaims, IdpProvider, IsAuthenticatedRequest, IsAuthenticatedResponse, ListEphemeralSignersResult, LoginTokenBundle, LogoutRequest, LogoutResponse, MessageTypeProperty, MessageTypes, MoonPaySignRequest, MoonPaySignResponse, MpcKeyShares, NativeCurrency, Network, OAuthRequest, OAuthResponse, OnrampFundingSettings, PasskeyEnrollConfig, PasskeySettings, PreferredCardProvider, PrefillConfig, PresenceTokenClaims, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, PublicEthereumWallet, PublicSessionData, PublicWallet, RefreshSessionRequest, RefreshSessionResponse, RetrieveWalletKeyRequest, RetrieveWalletKeyResponse, RevokeEphemeralSignerParams, RpcConfig, RpcUrls, SdkSettings, SendEmailOtpRequest, SendEmailOtpResponse, SendTransactionConfig, SendTransactionRequest, SessionData, SessionWallet, SharesDeviceRequest, SharesDeviceResponse, Sign7702AuthorizationError, Sign7702AuthorizationParams, Sign7702AuthorizationResponse, Sign7702AuthorizationResult, SignMessageConfig, SignTransactionConfig, SignTypedDataError, SignTypedDataParams, SignTypedDataResponse, SignTypedDataResult, SmsSettings, SolanaChain, SolanaChainEntry, SolanaFundingConfig, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, TransactionCommitment, TransactionEncoding, TransactionUIOptions, TronChainEntry, TronGetBalanceParams, TronGetBalanceResult, TronSendTransactionParams, TronSendTransactionResult, TronSignMessageParams, TronSignMessageResult, TronSignTransactionParams, TronSignTransactionResult, TronTransactionJson, TypedMessage, UseFundWalletInterface, UsersMePublicResponse, UsersMeRequest, UsersMeResponse, VerifiedSession, VerifyEmailOtpRequest, VerifyEmailOtpResponse, VerifyEmailOtpUser, VerifyOAuthTokenRequest, VerifyOAuthTokenResponse, VerifySiweWalletRegistrationRequest, WALLET_ERROR_CODES, Wallet, WalletChain, WalletChainType, WalletConnectConfig, WalletCreationError, WalletError, WalletErrorCode, WalletKeyRequest, WalletListEntry, WalletRegistrationNonceRequest, WalletRegistrationNonceResponse, WalletType, WalletVerifyRequest } from './types/index.js';
|
|
2
|
+
export { FONT_URLS_KEY, getIframeOrigin, getIframeUrl, getMoonXApiUrl } from './utils/index.js';
|
|
3
3
|
export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from './post-message-BR2NClJ5.js';
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ __export(src_exports, {
|
|
|
31
31
|
WalletCreationError: () => WalletCreationError,
|
|
32
32
|
getIframeOrigin: () => getIframeOrigin,
|
|
33
33
|
getIframeUrl: () => getIframeUrl,
|
|
34
|
-
|
|
34
|
+
getMoonXApiUrl: () => getMoonXApiUrl
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(src_exports);
|
|
37
37
|
|
|
@@ -67,12 +67,13 @@ var Network = /* @__PURE__ */ ((Network2) => {
|
|
|
67
67
|
})(Network || {});
|
|
68
68
|
|
|
69
69
|
// src/utils/get-api-url.ts
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
var getMoonXApiUrl = () => {
|
|
71
|
+
const apiUrlOverride = process.env?.NEXT_PUBLIC_MOONX_API_URL || process.env?.NEXT_PUBLIC_MOONKEY_API_URL;
|
|
72
|
+
if (apiUrlOverride) {
|
|
73
|
+
return apiUrlOverride;
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
const iframeUrl = process.env?.NEXT_PUBLIC_MOONX_IFRAME_URL || process.env?.NEXT_PUBLIC_MOONKEY_IFRAME_URL;
|
|
76
|
+
if (iframeUrl) {
|
|
76
77
|
if (iframeUrl.includes("staging") || iframeUrl.includes("auth-staging")) {
|
|
77
78
|
return "https://api.moonx-dev.com";
|
|
78
79
|
}
|
|
@@ -103,15 +104,16 @@ var getIframeUrl = (path = "") => {
|
|
|
103
104
|
/^https?:\/\//,
|
|
104
105
|
""
|
|
105
106
|
).replace(/\/$/, "");
|
|
106
|
-
const iframeProjectName = process.env.NEXT_PUBLIC_MOONKEY_IFRAME_PROJECT_NAME || DEFAULT_IFRAME_PROJECT_NAME;
|
|
107
|
+
const iframeProjectName = process.env.NEXT_PUBLIC_MOONX_IFRAME_PROJECT_NAME || process.env.NEXT_PUBLIC_MOONKEY_IFRAME_PROJECT_NAME || DEFAULT_IFRAME_PROJECT_NAME;
|
|
107
108
|
const iframeUrl = /-git-/.test(vercelUrl) ? vercelUrl.replace(/^[^.]+?-git-/, `${iframeProjectName}-git-`) : (
|
|
108
109
|
// Fallback: legacy `{prefix}-{hash}.vercel.app` style
|
|
109
110
|
vercelUrl.replace(/^[^-]+-/, `${iframeProjectName}-`)
|
|
110
111
|
);
|
|
111
112
|
return withBypass(joinUrl(`https://${iframeUrl}`, path));
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
const iframeUrlOverride = process.env.NEXT_PUBLIC_MOONX_IFRAME_URL || process.env.NEXT_PUBLIC_MOONKEY_IFRAME_URL;
|
|
115
|
+
if (iframeUrlOverride) {
|
|
116
|
+
return joinUrl(iframeUrlOverride, path);
|
|
115
117
|
}
|
|
116
118
|
return joinUrl("https://iframe.moonx-dev.com", path);
|
|
117
119
|
};
|
|
@@ -479,5 +481,5 @@ var FONT_URLS_KEY = "__moonxFontUrls";
|
|
|
479
481
|
WalletCreationError,
|
|
480
482
|
getIframeOrigin,
|
|
481
483
|
getIframeUrl,
|
|
482
|
-
|
|
484
|
+
getMoonXApiUrl
|
|
483
485
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
Network,
|
|
3
3
|
WALLET_ERROR_CODES,
|
|
4
4
|
WalletCreationError
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-CEL3U6EI.mjs";
|
|
6
6
|
import {
|
|
7
7
|
FONT_URLS_KEY
|
|
8
8
|
} from "./chunk-527SU2F6.mjs";
|
|
9
9
|
import {
|
|
10
10
|
getIframeOrigin,
|
|
11
11
|
getIframeUrl
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-HAEJD7NC.mjs";
|
|
13
13
|
import {
|
|
14
14
|
FORWARDED_ERROR_FIELDS,
|
|
15
15
|
PostMessageClient,
|
|
@@ -18,8 +18,8 @@ import {
|
|
|
18
18
|
PostMessageType
|
|
19
19
|
} from "./chunk-Z57WM6IO.mjs";
|
|
20
20
|
import {
|
|
21
|
-
|
|
22
|
-
} from "./chunk-
|
|
21
|
+
getMoonXApiUrl
|
|
22
|
+
} from "./chunk-LP55IGPN.mjs";
|
|
23
23
|
export {
|
|
24
24
|
FONT_URLS_KEY,
|
|
25
25
|
FORWARDED_ERROR_FIELDS,
|
|
@@ -32,5 +32,5 @@ export {
|
|
|
32
32
|
WalletCreationError,
|
|
33
33
|
getIframeOrigin,
|
|
34
34
|
getIframeUrl,
|
|
35
|
-
|
|
35
|
+
getMoonXApiUrl
|
|
36
36
|
};
|
package/dist/lib/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { C as CachedAssertion, g as generatePasskeyUserId } from '../passkey-cache-WnDFQ-v4.mjs';
|
|
2
2
|
export { a as PasskeyFormFactor, P as PasskeyMetadata, b as PasskeyMetadataInput, f as formatPasskeyLabel, r as resolvePasskeyMetadata } from '../passkey-metadata-QqFF2SWQ.mjs';
|
|
3
|
-
import { ChainEntry, ChainConfigItem, Chain, EvmChainEntry, SolanaChainEntry, WalletChain } from '../types/index.mjs';
|
|
3
|
+
import { ChainEntry, ChainConfigItem, Chain, EvmChainEntry, TronChainEntry, SolanaChainEntry, WalletChain } from '../types/index.mjs';
|
|
4
4
|
import { SiweMessage } from 'siwe';
|
|
5
5
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
6
6
|
|
|
@@ -28,7 +28,7 @@ declare const authState: AuthenticationState;
|
|
|
28
28
|
declare function sanitizeUserData(userData: any): any;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Verify ID token with
|
|
31
|
+
* Verify ID token with MoonX API and retrieve user info.
|
|
32
32
|
*/
|
|
33
33
|
interface VerifyIdTokenResponse {
|
|
34
34
|
success: boolean;
|
|
@@ -42,7 +42,7 @@ declare const fromB64url: (b64url: string) => Uint8Array;
|
|
|
42
42
|
declare const toB64url: (bytes: Uint8Array) => string;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* Chain utilities for
|
|
45
|
+
* Chain utilities for MoonX
|
|
46
46
|
*/
|
|
47
47
|
|
|
48
48
|
/**
|
|
@@ -131,6 +131,8 @@ declare function getChainById(chains: ChainConfigItem[], chainId: number): Chain
|
|
|
131
131
|
declare function isChainSupported(chains: ChainConfigItem[], chainId: number): boolean;
|
|
132
132
|
/** Type guard: is this normalized entry an EVM entry (carries a viem Chain)? */
|
|
133
133
|
declare function isEvmEntry(entry: ChainEntry): entry is EvmChainEntry;
|
|
134
|
+
/** Type guard: a string-id entry in the "tron" namespace (e.g. "tron:mainnet"). */
|
|
135
|
+
declare function isTronEntry(entry: ChainEntry): entry is TronChainEntry;
|
|
134
136
|
/**
|
|
135
137
|
* Coerce a `ChainConfigItem` to its normalized form. A bare viem `Chain`
|
|
136
138
|
* (numeric `id`) becomes an `EvmChainEntry`; `{ chain, … }` is already one;
|
|
@@ -176,6 +178,12 @@ declare function resolveChainEntry(chains: ChainConfigItem[] | undefined, select
|
|
|
176
178
|
* hooks throw a clear "no RPC URL" error.
|
|
177
179
|
*/
|
|
178
180
|
declare function resolveSolanaChainEntry(chains: ChainConfigItem[] | undefined, selector?: string | number, defaultSelector?: string | number): SolanaChainEntry | undefined;
|
|
181
|
+
/**
|
|
182
|
+
* Resolve a TRON entry, mirroring `resolveSolanaChainEntry`'s precedence and
|
|
183
|
+
* fail-closed semantics: an explicit selector that doesn't name a configured
|
|
184
|
+
* tron entry returns undefined rather than falling through to another chain.
|
|
185
|
+
*/
|
|
186
|
+
declare function resolveTronChainEntry(chains: ChainConfigItem[] | undefined, selector?: string | number, defaultSelector?: string | number): TronChainEntry | undefined;
|
|
179
187
|
/**
|
|
180
188
|
* Resolve the EVM entry to use, honoring (highest priority first):
|
|
181
189
|
* per-call `selector` → tx `requestedChainId` → `walletChainId` →
|
|
@@ -455,6 +463,24 @@ declare function getSOLTransfersFromInstructions(base64Transaction: string, logs
|
|
|
455
463
|
usdValue?: string;
|
|
456
464
|
}>>;
|
|
457
465
|
|
|
466
|
+
/**
|
|
467
|
+
* Derive the base58check Tron address from a secp256k1 public key
|
|
468
|
+
* (compressed or uncompressed hex, with or without 0x):
|
|
469
|
+
* keccak256(uncompressed pubkey body)[12:] prefixed with 0x41, then
|
|
470
|
+
* base58check (double-sha256 checksum).
|
|
471
|
+
*
|
|
472
|
+
* Async because `bs58` is an optional ESM-only peer of `@moon-x/core`
|
|
473
|
+
* and is lazy-imported, same as `bs58ToBytes` in wire-codec.ts.
|
|
474
|
+
*/
|
|
475
|
+
declare function tronAddressFromPublicKey(publicKeyHex: string): Promise<string>;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Decode raw_data_hex (the signed bytes) into a labeled preview object.
|
|
479
|
+
* Throws on malformed input - callers fall back to showing the raw
|
|
480
|
+
* payload rather than a possibly-wrong decode.
|
|
481
|
+
*/
|
|
482
|
+
declare function decodeTronRawData(rawDataHex: string): Promise<Record<string, unknown>>;
|
|
483
|
+
|
|
458
484
|
interface BuildUrlConfig {
|
|
459
485
|
publishableKey: string;
|
|
460
486
|
config?: {
|
|
@@ -470,6 +496,15 @@ declare const DEFAULT_AUTH_URL = "https://iframe.moonx-dev.com";
|
|
|
470
496
|
declare const serializeEthereumTransaction: (transaction: any) => Promise<string>;
|
|
471
497
|
declare const broadcastEthereumRaw: (rpcUrl: string, signedSerialized: string) => Promise<string>;
|
|
472
498
|
declare const broadcastSolanaSigned: (rpcUrl: string, signedBase58: string) => Promise<string>;
|
|
499
|
+
/**
|
|
500
|
+
* Broadcast a signed Tron transaction (TronWeb JSON shape, signature
|
|
501
|
+
* attached) to a fullnode. Returns the txid. Tron reports failures as
|
|
502
|
+
* `{ result: false, code, message }` with `message` hex-encoded ASCII;
|
|
503
|
+
* decode it so callers see "Contract validate error: ..." instead of hex.
|
|
504
|
+
*/
|
|
505
|
+
declare const broadcastTronSigned: (rpcUrl: string, signedTransaction: {
|
|
506
|
+
txID: string;
|
|
507
|
+
} & Record<string, unknown>) => Promise<string>;
|
|
473
508
|
|
|
474
509
|
/**
|
|
475
510
|
* Canonical algorithm name written to `app_user_wallet_keyshares.algorithm`.
|
|
@@ -477,6 +512,7 @@ declare const broadcastSolanaSigned: (rpcUrl: string, signedBase58: string) => P
|
|
|
477
512
|
* Matches Sodot's Vertex API path segment exactly:
|
|
478
513
|
*
|
|
479
514
|
* ethereum → "ecdsa"
|
|
515
|
+
* tron → "ecdsa"
|
|
480
516
|
* solana → "exportable-ed25519"
|
|
481
517
|
*
|
|
482
518
|
* `Algorithm.name.toLowerCase()` from the Sodot SDK would give
|
|
@@ -519,4 +555,4 @@ declare const arrayLikeToBytes: (value: unknown) => Uint8Array;
|
|
|
519
555
|
*/
|
|
520
556
|
declare const bs58ToBytes: (value: unknown) => Promise<Uint8Array>;
|
|
521
557
|
|
|
522
|
-
export { type BuildUrlConfig, type ChainIndex, DEFAULT_AUTH_URL, EthereumSiweMessage, type EthereumSiweMessageProps, type EvmTransactionInput, type EvmTxPrepWallet, type ManualSiweMessageProps, SiwsMessage, SolanaTransactionParser, type VerifyIdTokenResponse, arrayLikeToBytes, authState, broadcastEthereumRaw, broadcastSolanaSigned, bs58ToBytes, buildChainIndex, buildUrl, canonicalAlgorithmFor, createManualSiweMessage, entryCaip2, estimateEvmGas, estimateEvmGasReserve, fromB64url, getChainById, getEvmGasPrice, getEvmMaxPriorityFeePerGas, getEvmNonce, getInstructionsForHTML, getRpcUrl, getSOLTransfersFromInstructions, getTransferInfoFromInstructions, isChainSupported, isEvmEntry, normalizeChainItem, normalizeChainKey, parseDerivationPath, prepareEvmSendTransaction, prepareEvmSignTransaction, resolveChainEntry, resolveEvmChain, resolveEvmChainEntry, resolveRpcUrl, resolveSolanaChainEntry, resolveWsUrl, sanitizeUserData, serializeEthereumTransaction, toB64url, validateChainConfig, verifyIdToken };
|
|
558
|
+
export { type BuildUrlConfig, type ChainIndex, DEFAULT_AUTH_URL, EthereumSiweMessage, type EthereumSiweMessageProps, type EvmTransactionInput, type EvmTxPrepWallet, type ManualSiweMessageProps, SiwsMessage, SolanaTransactionParser, type VerifyIdTokenResponse, arrayLikeToBytes, authState, broadcastEthereumRaw, broadcastSolanaSigned, broadcastTronSigned, bs58ToBytes, buildChainIndex, buildUrl, canonicalAlgorithmFor, createManualSiweMessage, decodeTronRawData, entryCaip2, estimateEvmGas, estimateEvmGasReserve, fromB64url, getChainById, getEvmGasPrice, getEvmMaxPriorityFeePerGas, getEvmNonce, getInstructionsForHTML, getRpcUrl, getSOLTransfersFromInstructions, getTransferInfoFromInstructions, isChainSupported, isEvmEntry, isTronEntry, normalizeChainItem, normalizeChainKey, parseDerivationPath, prepareEvmSendTransaction, prepareEvmSignTransaction, resolveChainEntry, resolveEvmChain, resolveEvmChainEntry, resolveRpcUrl, resolveSolanaChainEntry, resolveTronChainEntry, resolveWsUrl, sanitizeUserData, serializeEthereumTransaction, toB64url, tronAddressFromPublicKey, validateChainConfig, verifyIdToken };
|