@openzeppelin/ui-builder-adapter-stellar 0.10.1 → 0.12.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 +24 -0
- package/dist/index.cjs +393 -196
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +377 -180
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
- package/src/config.ts +5 -0
- package/src/contract/loader.ts +35 -0
- package/src/contract/type.ts +65 -0
- package/src/mapping/field-generator.ts +31 -7
- package/src/networks/mainnet.ts +3 -1
- package/src/networks/testnet.ts +3 -1
- package/src/sac/spec-cache.ts +68 -0
- package/src/sac/spec-source.ts +35 -0
- package/src/sac/xdr.ts +102 -0
package/dist/index.cjs
CHANGED
|
@@ -45,11 +45,11 @@ module.exports = __toCommonJS(index_exports);
|
|
|
45
45
|
|
|
46
46
|
// src/adapter.ts
|
|
47
47
|
var import_ui_builder_types6 = require("@openzeppelin/ui-builder-types");
|
|
48
|
-
var
|
|
48
|
+
var import_ui_builder_utils38 = require("@openzeppelin/ui-builder-utils");
|
|
49
49
|
|
|
50
50
|
// src/contract/loader.ts
|
|
51
51
|
var StellarSdk2 = __toESM(require("@stellar/stellar-sdk"), 1);
|
|
52
|
-
var
|
|
52
|
+
var import_ui_builder_utils16 = require("@openzeppelin/ui-builder-utils");
|
|
53
53
|
|
|
54
54
|
// src/validation/address.ts
|
|
55
55
|
var import_stellar_sdk = require("@stellar/stellar-sdk");
|
|
@@ -1493,9 +1493,163 @@ async function queryStellarViewFunction(contractAddress, functionId, networkConf
|
|
|
1493
1493
|
}
|
|
1494
1494
|
}
|
|
1495
1495
|
|
|
1496
|
+
// src/sac/spec-cache.ts
|
|
1497
|
+
var import_ui_builder_utils14 = require("@openzeppelin/ui-builder-utils");
|
|
1498
|
+
|
|
1499
|
+
// src/sac/spec-source.ts
|
|
1500
|
+
var import_ui_builder_utils12 = require("@openzeppelin/ui-builder-utils");
|
|
1501
|
+
var DEFAULT_SPEC = {
|
|
1502
|
+
repo: "stellar/stellar-asset-contract-spec",
|
|
1503
|
+
path: "refs/heads/main",
|
|
1504
|
+
file: "stellar-asset-spec.json"
|
|
1505
|
+
};
|
|
1506
|
+
function getSacSpecUrl(cfg = {}) {
|
|
1507
|
+
const repo = cfg.repo || DEFAULT_SPEC.repo;
|
|
1508
|
+
const path = cfg.path || DEFAULT_SPEC.path;
|
|
1509
|
+
const file = cfg.file || DEFAULT_SPEC.file;
|
|
1510
|
+
return `https://raw.githubusercontent.com/${repo}/${path}/${file}`;
|
|
1511
|
+
}
|
|
1512
|
+
async function fetchSacSpecJson(cfg = {}) {
|
|
1513
|
+
const url = getSacSpecUrl(cfg);
|
|
1514
|
+
try {
|
|
1515
|
+
const res = await fetch(url);
|
|
1516
|
+
if (!res.ok) {
|
|
1517
|
+
throw new Error(`HTTP ${res.status}`);
|
|
1518
|
+
}
|
|
1519
|
+
return await res.text();
|
|
1520
|
+
} catch (error) {
|
|
1521
|
+
import_ui_builder_utils12.logger.error("stellar:sac:spec-source", "Failed to fetch SAC spec:", url, error);
|
|
1522
|
+
throw new Error("Failed to load Stellar Asset Contract spec. Please try again later.");
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
// src/sac/xdr.ts
|
|
1527
|
+
var import_stellar_sdk10 = require("@stellar/stellar-sdk");
|
|
1528
|
+
var import_lossless_json = require("lossless-json");
|
|
1529
|
+
var import_package = __toESM(require("@stellar/stellar-xdr-json/package.json"), 1);
|
|
1530
|
+
var import_ui_builder_utils13 = require("@openzeppelin/ui-builder-utils");
|
|
1531
|
+
var stellarXdrJsonVersion = import_package.default.version ?? "23.0.0";
|
|
1532
|
+
var CDN_WASM_URL = `https://unpkg.com/@stellar/stellar-xdr-json@${stellarXdrJsonVersion}/stellar_xdr_json_bg.wasm`;
|
|
1533
|
+
var initialized = false;
|
|
1534
|
+
var encode = null;
|
|
1535
|
+
async function ensureXdrJsonInitialized() {
|
|
1536
|
+
if (initialized) return;
|
|
1537
|
+
try {
|
|
1538
|
+
const stellarXdrJson = await import("@stellar/stellar-xdr-json");
|
|
1539
|
+
const init = stellarXdrJson.default;
|
|
1540
|
+
await init(CDN_WASM_URL);
|
|
1541
|
+
encode = stellarXdrJson.encode;
|
|
1542
|
+
initialized = true;
|
|
1543
|
+
} catch (error) {
|
|
1544
|
+
import_ui_builder_utils13.logger.error("stellar:sac:xdr", "Failed to initialize WASM module:", error);
|
|
1545
|
+
throw error;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
async function encodeSacSpecEntries(jsonString) {
|
|
1549
|
+
await ensureXdrJsonInitialized();
|
|
1550
|
+
if (!encode) {
|
|
1551
|
+
throw new Error("WASM module not properly initialized");
|
|
1552
|
+
}
|
|
1553
|
+
try {
|
|
1554
|
+
const jsonData = (0, import_lossless_json.parse)(jsonString);
|
|
1555
|
+
const result = [];
|
|
1556
|
+
for (const entry of jsonData) {
|
|
1557
|
+
const stringified = (0, import_lossless_json.stringify)(entry);
|
|
1558
|
+
if (!stringified) {
|
|
1559
|
+
throw new Error("Failed to stringify SAC spec entry before XDR encoding.");
|
|
1560
|
+
}
|
|
1561
|
+
const encoded = encode("ScSpecEntry", stringified);
|
|
1562
|
+
result.push(encoded);
|
|
1563
|
+
}
|
|
1564
|
+
return result;
|
|
1565
|
+
} catch (error) {
|
|
1566
|
+
import_ui_builder_utils13.logger.error("stellar:sac:xdr", "Failed to encode SAC spec to XDR", error);
|
|
1567
|
+
throw new Error("Failed to process SAC spec.");
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
function toScSpecEntries(base64Entries) {
|
|
1571
|
+
return base64Entries.map((b64) => import_stellar_sdk10.xdr.ScSpecEntry.fromXDR(b64, "base64"));
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
// src/sac/spec-cache.ts
|
|
1575
|
+
var sacSpecCache = /* @__PURE__ */ new Map();
|
|
1576
|
+
var sacSpecInflight = /* @__PURE__ */ new Map();
|
|
1577
|
+
async function getSacSpecArtifacts(cfg = {}) {
|
|
1578
|
+
const cacheKey = getSacSpecUrl(cfg);
|
|
1579
|
+
const cached = sacSpecCache.get(cacheKey);
|
|
1580
|
+
if (cached) {
|
|
1581
|
+
import_ui_builder_utils14.logger.debug("stellar:sac:spec-cache", "Returning cached SAC spec artifacts");
|
|
1582
|
+
return cached;
|
|
1583
|
+
}
|
|
1584
|
+
const inflight = sacSpecInflight.get(cacheKey);
|
|
1585
|
+
if (inflight) {
|
|
1586
|
+
return inflight;
|
|
1587
|
+
}
|
|
1588
|
+
const promise = (async () => {
|
|
1589
|
+
const json = await fetchSacSpecJson(cfg);
|
|
1590
|
+
const base64Entries = await encodeSacSpecEntries(json);
|
|
1591
|
+
const specEntries = toScSpecEntries(base64Entries);
|
|
1592
|
+
const entry = {
|
|
1593
|
+
base64Entries,
|
|
1594
|
+
specEntries
|
|
1595
|
+
};
|
|
1596
|
+
sacSpecCache.set(cacheKey, entry);
|
|
1597
|
+
sacSpecInflight.delete(cacheKey);
|
|
1598
|
+
import_ui_builder_utils14.logger.debug("stellar:sac:spec-cache", "Cached SAC spec artifacts for future re-use");
|
|
1599
|
+
return entry;
|
|
1600
|
+
})().catch((error) => {
|
|
1601
|
+
sacSpecInflight.delete(cacheKey);
|
|
1602
|
+
throw error;
|
|
1603
|
+
});
|
|
1604
|
+
sacSpecInflight.set(cacheKey, promise);
|
|
1605
|
+
return promise;
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
// src/contract/type.ts
|
|
1609
|
+
var import_stellar_sdk11 = require("@stellar/stellar-sdk");
|
|
1610
|
+
var import_ui_builder_utils15 = require("@openzeppelin/ui-builder-utils");
|
|
1611
|
+
function getSorobanRpcServer2(networkConfig) {
|
|
1612
|
+
const customRpcConfig = import_ui_builder_utils15.userRpcConfigService.getUserRpcConfig(networkConfig.id);
|
|
1613
|
+
const rpcUrl = customRpcConfig?.url || networkConfig.sorobanRpcUrl;
|
|
1614
|
+
if (!rpcUrl) {
|
|
1615
|
+
throw new Error(`No Soroban RPC URL available for network ${networkConfig.name}`);
|
|
1616
|
+
}
|
|
1617
|
+
const allowHttp = new URL(rpcUrl).hostname === "localhost";
|
|
1618
|
+
return new import_stellar_sdk11.rpc.Server(rpcUrl, { allowHttp });
|
|
1619
|
+
}
|
|
1620
|
+
async function getStellarContractType(contractId, networkConfig) {
|
|
1621
|
+
try {
|
|
1622
|
+
if (!contractId) {
|
|
1623
|
+
return null;
|
|
1624
|
+
}
|
|
1625
|
+
const rpcServer = getSorobanRpcServer2(networkConfig);
|
|
1626
|
+
const ledgerKey = new import_stellar_sdk11.Contract(contractId).getFootprint();
|
|
1627
|
+
const ledgerEntries = await rpcServer.getLedgerEntries(ledgerKey);
|
|
1628
|
+
const first = ledgerEntries?.entries?.[0]?.val;
|
|
1629
|
+
if (!first) {
|
|
1630
|
+
throw new Error("Could not obtain contract data from server.");
|
|
1631
|
+
}
|
|
1632
|
+
const executable = first.contractData()?.val()?.instance()?.executable();
|
|
1633
|
+
if (!executable) {
|
|
1634
|
+
throw new Error("Could not get executable from contract data.");
|
|
1635
|
+
}
|
|
1636
|
+
const execWasmType = import_stellar_sdk11.xdr.ContractExecutableType.contractExecutableWasm().name;
|
|
1637
|
+
const execStellarAssetType = import_stellar_sdk11.xdr.ContractExecutableType.contractExecutableStellarAsset().name;
|
|
1638
|
+
const detected = executable.switch()?.name;
|
|
1639
|
+
if (detected === execWasmType) return "contractExecutableWasm";
|
|
1640
|
+
if (detected === execStellarAssetType) return "contractExecutableStellarAsset";
|
|
1641
|
+
return null;
|
|
1642
|
+
} catch (error) {
|
|
1643
|
+
import_ui_builder_utils15.logger.error("stellar:contract-type", "Failed to detect contract type:", error);
|
|
1644
|
+
throw new Error(
|
|
1645
|
+
`Something went wrong getting contract type by contract ID. ${error.message}`
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1496
1650
|
// src/contract/loader.ts
|
|
1497
1651
|
async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
1498
|
-
|
|
1652
|
+
import_ui_builder_utils16.logger.info("loadStellarContractFromAddress", "Loading contract:", {
|
|
1499
1653
|
contractAddress,
|
|
1500
1654
|
network: networkConfig.name,
|
|
1501
1655
|
rpcUrl: networkConfig.sorobanRpcUrl,
|
|
@@ -1505,6 +1659,33 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1505
1659
|
if (!StellarSdk2.StrKey.isValidContract(contractAddress)) {
|
|
1506
1660
|
throw new Error(`Invalid contract address: ${contractAddress}`);
|
|
1507
1661
|
}
|
|
1662
|
+
try {
|
|
1663
|
+
const execType = await getStellarContractType(contractAddress, networkConfig);
|
|
1664
|
+
if (execType === "contractExecutableStellarAsset") {
|
|
1665
|
+
const { base64Entries, specEntries: specEntries2 } = await getSacSpecArtifacts();
|
|
1666
|
+
const spec = new StellarSdk2.contract.Spec(base64Entries);
|
|
1667
|
+
const functions2 = await extractFunctionsFromSpec(
|
|
1668
|
+
spec,
|
|
1669
|
+
contractAddress,
|
|
1670
|
+
specEntries2,
|
|
1671
|
+
networkConfig
|
|
1672
|
+
);
|
|
1673
|
+
return {
|
|
1674
|
+
name: `Stellar Asset Contract ${contractAddress.slice(0, 8)}...`,
|
|
1675
|
+
ecosystem: "stellar",
|
|
1676
|
+
functions: functions2,
|
|
1677
|
+
metadata: {
|
|
1678
|
+
specEntries: specEntries2
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1681
|
+
}
|
|
1682
|
+
} catch (e) {
|
|
1683
|
+
import_ui_builder_utils16.logger.warn(
|
|
1684
|
+
"loadStellarContractFromAddress",
|
|
1685
|
+
"SAC detection failed, falling back to regular client:",
|
|
1686
|
+
e
|
|
1687
|
+
);
|
|
1688
|
+
}
|
|
1508
1689
|
let contractClient;
|
|
1509
1690
|
try {
|
|
1510
1691
|
contractClient = await StellarSdk2.contract.Client.from({
|
|
@@ -1516,12 +1697,12 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1516
1697
|
const message = e?.message || String(e);
|
|
1517
1698
|
if (message.includes("Cannot destructure property 'length'")) {
|
|
1518
1699
|
const friendly = "Unable to fetch contract metadata from RPC. The contract appears to have no published Wasm/definition on this network.";
|
|
1519
|
-
|
|
1700
|
+
import_ui_builder_utils16.logger.error("loadStellarContractFromAddress", friendly);
|
|
1520
1701
|
throw new Error(`NO_WASM: ${friendly}`);
|
|
1521
1702
|
}
|
|
1522
1703
|
throw e;
|
|
1523
1704
|
}
|
|
1524
|
-
|
|
1705
|
+
import_ui_builder_utils16.logger.info("loadStellarContractFromAddress", "Contract client created successfully");
|
|
1525
1706
|
let specEntries = [];
|
|
1526
1707
|
try {
|
|
1527
1708
|
if (contractClient.spec && typeof contractClient.spec === "object") {
|
|
@@ -1536,20 +1717,20 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1536
1717
|
try {
|
|
1537
1718
|
specEntries = spec.entries();
|
|
1538
1719
|
} catch (e) {
|
|
1539
|
-
|
|
1720
|
+
import_ui_builder_utils16.logger.warn("loadStellarContractFromAddress", "entries() method failed:", e);
|
|
1540
1721
|
}
|
|
1541
1722
|
}
|
|
1542
1723
|
if (specEntries.length === 0 && typeof spec.entries === "function") {
|
|
1543
1724
|
try {
|
|
1544
1725
|
specEntries = spec.entries();
|
|
1545
1726
|
} catch (e) {
|
|
1546
|
-
|
|
1727
|
+
import_ui_builder_utils16.logger.warn("loadStellarContractFromAddress", "direct entries() method failed:", e);
|
|
1547
1728
|
}
|
|
1548
1729
|
}
|
|
1549
|
-
|
|
1730
|
+
import_ui_builder_utils16.logger.info("loadStellarContractFromAddress", `Found ${specEntries.length} spec entries`);
|
|
1550
1731
|
}
|
|
1551
1732
|
} catch (specError) {
|
|
1552
|
-
|
|
1733
|
+
import_ui_builder_utils16.logger.warn("loadStellarContractFromAddress", "Could not extract spec entries:", specError);
|
|
1553
1734
|
}
|
|
1554
1735
|
const functions = await extractFunctionsFromSpec(
|
|
1555
1736
|
contractClient.spec,
|
|
@@ -1557,7 +1738,7 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1557
1738
|
specEntries,
|
|
1558
1739
|
networkConfig
|
|
1559
1740
|
);
|
|
1560
|
-
|
|
1741
|
+
import_ui_builder_utils16.logger.info(
|
|
1561
1742
|
"loadStellarContractFromAddress",
|
|
1562
1743
|
`Successfully extracted ${functions.length} functions`
|
|
1563
1744
|
);
|
|
@@ -1572,28 +1753,28 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1572
1753
|
} catch (error) {
|
|
1573
1754
|
const msg = error?.message || String(error);
|
|
1574
1755
|
if (msg.startsWith("NO_WASM:")) {
|
|
1575
|
-
|
|
1756
|
+
import_ui_builder_utils16.logger.error("loadStellarContractFromAddress", msg);
|
|
1576
1757
|
throw new Error(msg);
|
|
1577
1758
|
}
|
|
1578
|
-
|
|
1759
|
+
import_ui_builder_utils16.logger.error("loadStellarContractFromAddress", "Failed to load contract:", error);
|
|
1579
1760
|
throw new Error(`Failed to load contract: ${msg}`);
|
|
1580
1761
|
}
|
|
1581
1762
|
}
|
|
1582
1763
|
async function extractFunctionsFromSpec(spec, contractAddress, specEntries, networkConfig) {
|
|
1583
1764
|
try {
|
|
1584
1765
|
const specFunctions = spec.funcs();
|
|
1585
|
-
|
|
1766
|
+
import_ui_builder_utils16.logger.info("extractFunctionsFromSpec", `Found ${specFunctions.length} functions in spec`);
|
|
1586
1767
|
return await Promise.all(
|
|
1587
1768
|
specFunctions.map(async (func, index) => {
|
|
1588
1769
|
try {
|
|
1589
1770
|
const functionName = func.name().toString();
|
|
1590
|
-
|
|
1771
|
+
import_ui_builder_utils16.logger.info("extractFunctionsFromSpec", `Processing function: ${functionName}`);
|
|
1591
1772
|
const inputs = func.inputs().map((input, inputIndex) => {
|
|
1592
1773
|
try {
|
|
1593
1774
|
const inputName = input.name().toString();
|
|
1594
1775
|
const inputType = extractSorobanTypeFromScSpec(input.type());
|
|
1595
1776
|
if (inputType === "unknown") {
|
|
1596
|
-
|
|
1777
|
+
import_ui_builder_utils16.logger.warn(
|
|
1597
1778
|
"extractFunctionsFromSpec",
|
|
1598
1779
|
`Unknown type for parameter "${inputName}" in function "${functionName}"`
|
|
1599
1780
|
);
|
|
@@ -1603,12 +1784,12 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1603
1784
|
const structFields = extractStructFields(specEntries, inputType);
|
|
1604
1785
|
if (structFields && structFields.length > 0) {
|
|
1605
1786
|
components = structFields;
|
|
1606
|
-
|
|
1787
|
+
import_ui_builder_utils16.logger.debug(
|
|
1607
1788
|
"extractFunctionsFromSpec",
|
|
1608
1789
|
`Extracted ${structFields.length} fields for struct type "${inputType}": ${structFields.map((f) => `${f.name}:${f.type}`).join(", ")}`
|
|
1609
1790
|
);
|
|
1610
1791
|
} else {
|
|
1611
|
-
|
|
1792
|
+
import_ui_builder_utils16.logger.warn(
|
|
1612
1793
|
"extractFunctionsFromSpec",
|
|
1613
1794
|
`No fields extracted for struct "${inputType}"`
|
|
1614
1795
|
);
|
|
@@ -1620,7 +1801,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1620
1801
|
...components && { components }
|
|
1621
1802
|
};
|
|
1622
1803
|
} catch (error) {
|
|
1623
|
-
|
|
1804
|
+
import_ui_builder_utils16.logger.warn(
|
|
1624
1805
|
"extractFunctionsFromSpec",
|
|
1625
1806
|
`Failed to parse input ${inputIndex}:`,
|
|
1626
1807
|
error
|
|
@@ -1639,7 +1820,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1639
1820
|
type: outputType
|
|
1640
1821
|
};
|
|
1641
1822
|
} catch (error) {
|
|
1642
|
-
|
|
1823
|
+
import_ui_builder_utils16.logger.warn(
|
|
1643
1824
|
"extractFunctionsFromSpec",
|
|
1644
1825
|
`Failed to parse output ${outputIndex}:`,
|
|
1645
1826
|
error
|
|
@@ -1655,7 +1836,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1655
1836
|
if (networkConfig) {
|
|
1656
1837
|
try {
|
|
1657
1838
|
const inputTypes = inputs.map((input) => input.type);
|
|
1658
|
-
|
|
1839
|
+
import_ui_builder_utils16.logger.debug(
|
|
1659
1840
|
"extractFunctionsFromSpec",
|
|
1660
1841
|
`Checking state mutability for ${functionName} with input types: ${inputTypes.join(", ")}`
|
|
1661
1842
|
);
|
|
@@ -1666,20 +1847,20 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1666
1847
|
inputTypes
|
|
1667
1848
|
);
|
|
1668
1849
|
stateMutability = modifiesState ? "nonpayable" : "view";
|
|
1669
|
-
|
|
1850
|
+
import_ui_builder_utils16.logger.info(
|
|
1670
1851
|
"extractFunctionsFromSpec",
|
|
1671
1852
|
`Function ${functionName} state mutability determined:`,
|
|
1672
1853
|
{ modifiesState, stateMutability }
|
|
1673
1854
|
);
|
|
1674
1855
|
} catch (error) {
|
|
1675
|
-
|
|
1856
|
+
import_ui_builder_utils16.logger.warn(
|
|
1676
1857
|
"extractFunctionsFromSpec",
|
|
1677
1858
|
`Failed to determine state mutability for ${functionName}, assuming it modifies state:`,
|
|
1678
1859
|
error
|
|
1679
1860
|
);
|
|
1680
1861
|
}
|
|
1681
1862
|
} else {
|
|
1682
|
-
|
|
1863
|
+
import_ui_builder_utils16.logger.warn(
|
|
1683
1864
|
"extractFunctionsFromSpec",
|
|
1684
1865
|
`No network config provided for ${functionName}, assuming it modifies state`
|
|
1685
1866
|
);
|
|
@@ -1697,7 +1878,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1697
1878
|
stateMutability
|
|
1698
1879
|
};
|
|
1699
1880
|
} catch (error) {
|
|
1700
|
-
|
|
1881
|
+
import_ui_builder_utils16.logger.error("extractFunctionsFromSpec", `Failed to process function ${index}:`, error);
|
|
1701
1882
|
return {
|
|
1702
1883
|
id: `function_${index}`,
|
|
1703
1884
|
name: `function_${index}`,
|
|
@@ -1713,7 +1894,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1713
1894
|
})
|
|
1714
1895
|
);
|
|
1715
1896
|
} catch (error) {
|
|
1716
|
-
|
|
1897
|
+
import_ui_builder_utils16.logger.error("extractFunctionsFromSpec", "Failed to extract functions from spec:", error);
|
|
1717
1898
|
throw new Error(`Failed to extract functions: ${error.message}`);
|
|
1718
1899
|
}
|
|
1719
1900
|
}
|
|
@@ -2010,19 +2191,19 @@ var StellarRelayerOptions = ({ options, onChange }) => {
|
|
|
2010
2191
|
};
|
|
2011
2192
|
|
|
2012
2193
|
// src/transaction/relayer.ts
|
|
2013
|
-
var
|
|
2194
|
+
var import_stellar_sdk12 = require("@stellar/stellar-sdk");
|
|
2014
2195
|
var import_relayer_sdk = require("@openzeppelin/relayer-sdk");
|
|
2015
|
-
var
|
|
2196
|
+
var import_ui_builder_utils22 = require("@openzeppelin/ui-builder-utils");
|
|
2016
2197
|
|
|
2017
2198
|
// src/wallet/connection.ts
|
|
2018
|
-
var
|
|
2199
|
+
var import_ui_builder_utils21 = require("@openzeppelin/ui-builder-utils");
|
|
2019
2200
|
|
|
2020
2201
|
// src/wallet/utils/stellarWalletImplementationManager.ts
|
|
2021
|
-
var
|
|
2202
|
+
var import_ui_builder_utils18 = require("@openzeppelin/ui-builder-utils");
|
|
2022
2203
|
|
|
2023
2204
|
// src/wallet/implementation/wallets-kit-implementation.ts
|
|
2024
2205
|
var import_stellar_wallets_kit = require("@creit.tech/stellar-wallets-kit");
|
|
2025
|
-
var
|
|
2206
|
+
var import_ui_builder_utils17 = require("@openzeppelin/ui-builder-utils");
|
|
2026
2207
|
var LOG_SYSTEM = "StellarWalletImplementation";
|
|
2027
2208
|
var WalletsKitImplementation = class {
|
|
2028
2209
|
/**
|
|
@@ -2043,7 +2224,7 @@ var WalletsKitImplementation = class {
|
|
|
2043
2224
|
__publicField(this, "currentWalletId", null);
|
|
2044
2225
|
__publicField(this, "connectionStatusListeners", /* @__PURE__ */ new Set());
|
|
2045
2226
|
this.networkConfig = networkConfig || null;
|
|
2046
|
-
|
|
2227
|
+
import_ui_builder_utils17.logger.info(
|
|
2047
2228
|
LOG_SYSTEM,
|
|
2048
2229
|
"Constructor called. Initial anticipated kitName:",
|
|
2049
2230
|
initialUiKitConfig?.kitName,
|
|
@@ -2051,7 +2232,7 @@ var WalletsKitImplementation = class {
|
|
|
2051
2232
|
networkConfig?.name
|
|
2052
2233
|
);
|
|
2053
2234
|
this.initialized = true;
|
|
2054
|
-
|
|
2235
|
+
import_ui_builder_utils17.logger.info(
|
|
2055
2236
|
LOG_SYSTEM,
|
|
2056
2237
|
"StellarWalletImplementation instance initialized (StellarWalletsKit config creation deferred)."
|
|
2057
2238
|
);
|
|
@@ -2061,10 +2242,10 @@ var WalletsKitImplementation = class {
|
|
|
2061
2242
|
* @param config - The Stellar network configuration
|
|
2062
2243
|
*/
|
|
2063
2244
|
setNetworkConfig(config) {
|
|
2064
|
-
|
|
2245
|
+
import_ui_builder_utils17.logger.info(LOG_SYSTEM, "Network config updated:", config.name);
|
|
2065
2246
|
this.networkConfig = config;
|
|
2066
2247
|
if (this.activeStellarKit || this.defaultInstanceKit) {
|
|
2067
|
-
|
|
2248
|
+
import_ui_builder_utils17.logger.info(LOG_SYSTEM, "Active kits detected - may need reconfiguration for new network");
|
|
2068
2249
|
}
|
|
2069
2250
|
}
|
|
2070
2251
|
/**
|
|
@@ -2074,14 +2255,14 @@ var WalletsKitImplementation = class {
|
|
|
2074
2255
|
* @param kit - The StellarWalletsKit object to set as active, or null to clear it.
|
|
2075
2256
|
*/
|
|
2076
2257
|
setActiveStellarKit(kit) {
|
|
2077
|
-
|
|
2258
|
+
import_ui_builder_utils17.logger.info(
|
|
2078
2259
|
LOG_SYSTEM,
|
|
2079
2260
|
"setActiveStellarKit called with kit:",
|
|
2080
2261
|
kit ? "Valid StellarWalletsKit" : "Null"
|
|
2081
2262
|
);
|
|
2082
2263
|
this.activeStellarKit = kit;
|
|
2083
2264
|
if (this.unsubscribeFromStatusChanges) {
|
|
2084
|
-
|
|
2265
|
+
import_ui_builder_utils17.logger.info(LOG_SYSTEM, "Re-establishing connection status monitoring with new kit");
|
|
2085
2266
|
}
|
|
2086
2267
|
}
|
|
2087
2268
|
/**
|
|
@@ -2090,14 +2271,14 @@ var WalletsKitImplementation = class {
|
|
|
2090
2271
|
* @returns A default StellarWalletsKit instance
|
|
2091
2272
|
*/
|
|
2092
2273
|
createDefaultKit() {
|
|
2093
|
-
|
|
2274
|
+
import_ui_builder_utils17.logger.info(LOG_SYSTEM, "Creating default StellarWalletsKit instance");
|
|
2094
2275
|
const network = this.getWalletNetwork();
|
|
2095
2276
|
const kit = new import_stellar_wallets_kit.StellarWalletsKit({
|
|
2096
2277
|
network,
|
|
2097
2278
|
selectedWalletId: void 0,
|
|
2098
2279
|
modules: (0, import_stellar_wallets_kit.allowAllModules)()
|
|
2099
2280
|
});
|
|
2100
|
-
|
|
2281
|
+
import_ui_builder_utils17.logger.info(LOG_SYSTEM, "Default StellarWalletsKit instance created");
|
|
2101
2282
|
return kit;
|
|
2102
2283
|
}
|
|
2103
2284
|
/**
|
|
@@ -2105,7 +2286,7 @@ var WalletsKitImplementation = class {
|
|
|
2105
2286
|
*/
|
|
2106
2287
|
getWalletNetwork() {
|
|
2107
2288
|
if (!this.networkConfig) {
|
|
2108
|
-
|
|
2289
|
+
import_ui_builder_utils17.logger.warn(LOG_SYSTEM, "No network config available, defaulting to TESTNET");
|
|
2109
2290
|
return import_stellar_wallets_kit.WalletNetwork.TESTNET;
|
|
2110
2291
|
}
|
|
2111
2292
|
return this.networkConfig.type === "mainnet" ? import_stellar_wallets_kit.WalletNetwork.PUBLIC : import_stellar_wallets_kit.WalletNetwork.TESTNET;
|
|
@@ -2123,7 +2304,7 @@ var WalletsKitImplementation = class {
|
|
|
2123
2304
|
*/
|
|
2124
2305
|
async getAvailableConnectors() {
|
|
2125
2306
|
if (!this.initialized) {
|
|
2126
|
-
|
|
2307
|
+
import_ui_builder_utils17.logger.warn(LOG_SYSTEM, "getAvailableConnectors called before initialization");
|
|
2127
2308
|
return [];
|
|
2128
2309
|
}
|
|
2129
2310
|
try {
|
|
@@ -2136,10 +2317,10 @@ var WalletsKitImplementation = class {
|
|
|
2136
2317
|
installed: wallet.isAvailable,
|
|
2137
2318
|
type: wallet.type || "browser"
|
|
2138
2319
|
}));
|
|
2139
|
-
|
|
2320
|
+
import_ui_builder_utils17.logger.info(LOG_SYSTEM, `Found ${connectors.length} available wallet connectors`);
|
|
2140
2321
|
return connectors;
|
|
2141
2322
|
} catch (error) {
|
|
2142
|
-
|
|
2323
|
+
import_ui_builder_utils17.logger.error(LOG_SYSTEM, "Failed to get available connectors:", error);
|
|
2143
2324
|
return [];
|
|
2144
2325
|
}
|
|
2145
2326
|
}
|
|
@@ -2155,7 +2336,7 @@ var WalletsKitImplementation = class {
|
|
|
2155
2336
|
try {
|
|
2156
2337
|
const prevStatus = this.getWalletConnectionStatus();
|
|
2157
2338
|
const kit = this.getKitToUse();
|
|
2158
|
-
|
|
2339
|
+
import_ui_builder_utils17.logger.info(LOG_SYSTEM, `Attempting to connect to wallet: ${connectorId}`);
|
|
2159
2340
|
kit.setWallet(connectorId);
|
|
2160
2341
|
const result = await kit.getAddress();
|
|
2161
2342
|
if (result.address) {
|
|
@@ -2163,7 +2344,7 @@ var WalletsKitImplementation = class {
|
|
|
2163
2344
|
this.currentWalletId = connectorId;
|
|
2164
2345
|
const newStatus = this.getWalletConnectionStatus();
|
|
2165
2346
|
this.notifyConnectionListeners(newStatus, prevStatus);
|
|
2166
|
-
|
|
2347
|
+
import_ui_builder_utils17.logger.info(
|
|
2167
2348
|
LOG_SYSTEM,
|
|
2168
2349
|
`Successfully connected to wallet: ${connectorId}, address: ${result.address}`
|
|
2169
2350
|
);
|
|
@@ -2179,7 +2360,7 @@ var WalletsKitImplementation = class {
|
|
|
2179
2360
|
};
|
|
2180
2361
|
}
|
|
2181
2362
|
} catch (error) {
|
|
2182
|
-
|
|
2363
|
+
import_ui_builder_utils17.logger.error(LOG_SYSTEM, `Failed to connect to wallet ${connectorId}:`, error);
|
|
2183
2364
|
return {
|
|
2184
2365
|
connected: false,
|
|
2185
2366
|
error: error instanceof Error ? error.message : "Unknown error occurred"
|
|
@@ -2196,15 +2377,15 @@ var WalletsKitImplementation = class {
|
|
|
2196
2377
|
}
|
|
2197
2378
|
try {
|
|
2198
2379
|
const prevStatus = this.getWalletConnectionStatus();
|
|
2199
|
-
|
|
2380
|
+
import_ui_builder_utils17.logger.info(LOG_SYSTEM, "Disconnecting wallet");
|
|
2200
2381
|
this.currentAddress = null;
|
|
2201
2382
|
this.currentWalletId = null;
|
|
2202
2383
|
const newStatus = this.getWalletConnectionStatus();
|
|
2203
2384
|
this.notifyConnectionListeners(newStatus, prevStatus);
|
|
2204
|
-
|
|
2385
|
+
import_ui_builder_utils17.logger.info(LOG_SYSTEM, "Successfully disconnected wallet");
|
|
2205
2386
|
return { disconnected: true };
|
|
2206
2387
|
} catch (error) {
|
|
2207
|
-
|
|
2388
|
+
import_ui_builder_utils17.logger.error(LOG_SYSTEM, "Failed to disconnect wallet:", error);
|
|
2208
2389
|
return {
|
|
2209
2390
|
disconnected: false,
|
|
2210
2391
|
error: error instanceof Error ? error.message : "Unknown error occurred"
|
|
@@ -2237,15 +2418,15 @@ var WalletsKitImplementation = class {
|
|
|
2237
2418
|
*/
|
|
2238
2419
|
onWalletConnectionChange(callback) {
|
|
2239
2420
|
if (!this.initialized) {
|
|
2240
|
-
|
|
2421
|
+
import_ui_builder_utils17.logger.warn(LOG_SYSTEM, "onWalletConnectionChange called before initialization. No-op.");
|
|
2241
2422
|
return () => {
|
|
2242
2423
|
};
|
|
2243
2424
|
}
|
|
2244
2425
|
this.connectionStatusListeners.add(callback);
|
|
2245
|
-
|
|
2426
|
+
import_ui_builder_utils17.logger.info(LOG_SYSTEM, "Connection status listener added");
|
|
2246
2427
|
return () => {
|
|
2247
2428
|
this.connectionStatusListeners.delete(callback);
|
|
2248
|
-
|
|
2429
|
+
import_ui_builder_utils17.logger.debug(LOG_SYSTEM, "Connection status listener removed");
|
|
2249
2430
|
};
|
|
2250
2431
|
}
|
|
2251
2432
|
/**
|
|
@@ -2274,14 +2455,14 @@ var WalletsKitImplementation = class {
|
|
|
2274
2455
|
* @param address - The account address
|
|
2275
2456
|
* @returns Promise resolving to signed transaction
|
|
2276
2457
|
*/
|
|
2277
|
-
async signTransaction(
|
|
2458
|
+
async signTransaction(xdr13, address) {
|
|
2278
2459
|
if (!this.initialized) {
|
|
2279
2460
|
throw new Error("Wallet implementation not initialized");
|
|
2280
2461
|
}
|
|
2281
2462
|
const kit = this.getKitToUse();
|
|
2282
2463
|
const networkPassphrase = this.getWalletNetwork();
|
|
2283
|
-
|
|
2284
|
-
return await kit.signTransaction(
|
|
2464
|
+
import_ui_builder_utils17.logger.info(LOG_SYSTEM, "Signing transaction with wallet");
|
|
2465
|
+
return await kit.signTransaction(xdr13, {
|
|
2285
2466
|
address,
|
|
2286
2467
|
networkPassphrase
|
|
2287
2468
|
});
|
|
@@ -2294,7 +2475,7 @@ var WalletsKitImplementation = class {
|
|
|
2294
2475
|
try {
|
|
2295
2476
|
listener(currentStatus, previousStatus);
|
|
2296
2477
|
} catch (error) {
|
|
2297
|
-
|
|
2478
|
+
import_ui_builder_utils17.logger.error(LOG_SYSTEM, "Error in connection status listener:", String(error));
|
|
2298
2479
|
}
|
|
2299
2480
|
});
|
|
2300
2481
|
}
|
|
@@ -2307,7 +2488,7 @@ var WalletsKitImplementation = class {
|
|
|
2307
2488
|
this.unsubscribeFromStatusChanges = void 0;
|
|
2308
2489
|
}
|
|
2309
2490
|
this.connectionStatusListeners.clear();
|
|
2310
|
-
|
|
2491
|
+
import_ui_builder_utils17.logger.info(LOG_SYSTEM, "Cleanup completed");
|
|
2311
2492
|
}
|
|
2312
2493
|
};
|
|
2313
2494
|
|
|
@@ -2331,17 +2512,17 @@ async function getStellarWalletImplementation(networkConfig) {
|
|
|
2331
2512
|
}
|
|
2332
2513
|
walletImplementationPromise = (async () => {
|
|
2333
2514
|
try {
|
|
2334
|
-
|
|
2335
|
-
const initialUiKitConfig =
|
|
2515
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM2, "Initializing StellarWalletImplementation singleton (async)...");
|
|
2516
|
+
const initialUiKitConfig = import_ui_builder_utils18.appConfigService.getTypedNestedConfig(
|
|
2336
2517
|
"walletui",
|
|
2337
2518
|
"config"
|
|
2338
2519
|
);
|
|
2339
2520
|
const instance = new WalletsKitImplementation(networkConfig, initialUiKitConfig);
|
|
2340
|
-
|
|
2521
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM2, "WalletsKitImplementation singleton created (async).");
|
|
2341
2522
|
walletImplementationInstance = instance;
|
|
2342
2523
|
return instance;
|
|
2343
2524
|
} catch (error) {
|
|
2344
|
-
|
|
2525
|
+
import_ui_builder_utils18.logger.error(LOG_SYSTEM2, "Failed to initialize WalletsKitImplementation (async):", error);
|
|
2345
2526
|
const fallbackInstance = new WalletsKitImplementation(networkConfig);
|
|
2346
2527
|
walletImplementationInstance = fallbackInstance;
|
|
2347
2528
|
return fallbackInstance;
|
|
@@ -2351,7 +2532,7 @@ async function getStellarWalletImplementation(networkConfig) {
|
|
|
2351
2532
|
}
|
|
2352
2533
|
function getInitializedStellarWalletImplementation() {
|
|
2353
2534
|
if (!walletImplementationInstance) {
|
|
2354
|
-
|
|
2535
|
+
import_ui_builder_utils18.logger.warn(
|
|
2355
2536
|
LOG_SYSTEM2,
|
|
2356
2537
|
"getInitializedStellarWalletImplementation called before instance was ready."
|
|
2357
2538
|
);
|
|
@@ -2361,7 +2542,7 @@ function getInitializedStellarWalletImplementation() {
|
|
|
2361
2542
|
|
|
2362
2543
|
// src/wallet/stellar-wallets-kit/stellarUiKitManager.ts
|
|
2363
2544
|
var import_stellar_wallets_kit2 = require("@creit.tech/stellar-wallets-kit");
|
|
2364
|
-
var
|
|
2545
|
+
var import_ui_builder_utils19 = require("@openzeppelin/ui-builder-utils");
|
|
2365
2546
|
var getInitialState = () => ({
|
|
2366
2547
|
isConfigured: false,
|
|
2367
2548
|
isInitializing: false,
|
|
@@ -2398,13 +2579,13 @@ function setNetworkConfig(config) {
|
|
|
2398
2579
|
}
|
|
2399
2580
|
function getWalletNetwork(networkConfig) {
|
|
2400
2581
|
if (!networkConfig) {
|
|
2401
|
-
|
|
2582
|
+
import_ui_builder_utils19.logger.warn("StellarUiKitManager", "No network config available, defaulting to TESTNET");
|
|
2402
2583
|
return import_stellar_wallets_kit2.WalletNetwork.TESTNET;
|
|
2403
2584
|
}
|
|
2404
2585
|
return networkConfig.type === "mainnet" ? import_stellar_wallets_kit2.WalletNetwork.PUBLIC : import_stellar_wallets_kit2.WalletNetwork.TESTNET;
|
|
2405
2586
|
}
|
|
2406
2587
|
async function configure(newFullUiKitConfig) {
|
|
2407
|
-
|
|
2588
|
+
import_ui_builder_utils19.logger.info(
|
|
2408
2589
|
"StellarUiKitManager:configure",
|
|
2409
2590
|
"Configuring UI kit. New config:",
|
|
2410
2591
|
newFullUiKitConfig
|
|
@@ -2434,7 +2615,7 @@ async function configure(newFullUiKitConfig) {
|
|
|
2434
2615
|
state.kitProviderComponent = null;
|
|
2435
2616
|
state.isKitAssetsLoaded = true;
|
|
2436
2617
|
state.error = null;
|
|
2437
|
-
|
|
2618
|
+
import_ui_builder_utils19.logger.info(
|
|
2438
2619
|
"StellarUiKitManager:configure",
|
|
2439
2620
|
"Stellar Wallets Kit configured with built-in UI and all wallet modules"
|
|
2440
2621
|
);
|
|
@@ -2448,7 +2629,7 @@ async function configure(newFullUiKitConfig) {
|
|
|
2448
2629
|
state.kitProviderComponent = null;
|
|
2449
2630
|
state.isKitAssetsLoaded = true;
|
|
2450
2631
|
state.error = null;
|
|
2451
|
-
|
|
2632
|
+
import_ui_builder_utils19.logger.info(
|
|
2452
2633
|
"StellarUiKitManager:configure",
|
|
2453
2634
|
"Stellar Wallets Kit configured for custom UI components"
|
|
2454
2635
|
);
|
|
@@ -2457,7 +2638,7 @@ async function configure(newFullUiKitConfig) {
|
|
|
2457
2638
|
state.kitProviderComponent = null;
|
|
2458
2639
|
state.isKitAssetsLoaded = false;
|
|
2459
2640
|
state.error = null;
|
|
2460
|
-
|
|
2641
|
+
import_ui_builder_utils19.logger.info("StellarUiKitManager:configure", 'UI kit set to "none", no wallet UI provided');
|
|
2461
2642
|
} else {
|
|
2462
2643
|
throw new Error(`Unknown UI kit name: ${newKitName}`);
|
|
2463
2644
|
}
|
|
@@ -2470,7 +2651,7 @@ async function configure(newFullUiKitConfig) {
|
|
|
2470
2651
|
};
|
|
2471
2652
|
notifyListeners();
|
|
2472
2653
|
} catch (error) {
|
|
2473
|
-
|
|
2654
|
+
import_ui_builder_utils19.logger.error("StellarUiKitManager:configure", "Failed to configure UI kit:", error);
|
|
2474
2655
|
state = {
|
|
2475
2656
|
...state,
|
|
2476
2657
|
isInitializing: false,
|
|
@@ -2574,7 +2755,7 @@ function generateStellarWalletsKitExportables(uiKitConfig) {
|
|
|
2574
2755
|
|
|
2575
2756
|
// src/wallet/stellar-wallets-kit/StellarWalletsKitConnectButton.tsx
|
|
2576
2757
|
var import_react3 = require("react");
|
|
2577
|
-
var
|
|
2758
|
+
var import_ui_builder_utils20 = require("@openzeppelin/ui-builder-utils");
|
|
2578
2759
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2579
2760
|
function StellarWalletsKitConnectButton() {
|
|
2580
2761
|
const containerRef = (0, import_react3.useRef)(null);
|
|
@@ -2582,7 +2763,7 @@ function StellarWalletsKitConnectButton() {
|
|
|
2582
2763
|
const state2 = stellarUiKitManager.getState();
|
|
2583
2764
|
const kit = state2.stellarKitProvider;
|
|
2584
2765
|
if (!kit || !containerRef.current) {
|
|
2585
|
-
|
|
2766
|
+
import_ui_builder_utils20.logger.error(
|
|
2586
2767
|
"StellarWalletsKitConnectButton",
|
|
2587
2768
|
"Kit not initialized or container not available"
|
|
2588
2769
|
);
|
|
@@ -2591,10 +2772,10 @@ function StellarWalletsKitConnectButton() {
|
|
|
2591
2772
|
kit.createButton({
|
|
2592
2773
|
container: containerRef.current,
|
|
2593
2774
|
onConnect: ({ address }) => {
|
|
2594
|
-
|
|
2775
|
+
import_ui_builder_utils20.logger.info("StellarWalletsKitConnectButton", `Connected to address: ${address}`);
|
|
2595
2776
|
},
|
|
2596
2777
|
onDisconnect: () => {
|
|
2597
|
-
|
|
2778
|
+
import_ui_builder_utils20.logger.info("StellarWalletsKitConnectButton", "Disconnected");
|
|
2598
2779
|
},
|
|
2599
2780
|
buttonText: "Connect Wallet"
|
|
2600
2781
|
});
|
|
@@ -2603,10 +2784,10 @@ function StellarWalletsKitConnectButton() {
|
|
|
2603
2784
|
try {
|
|
2604
2785
|
kit.removeButton();
|
|
2605
2786
|
} catch (error) {
|
|
2606
|
-
|
|
2787
|
+
import_ui_builder_utils20.logger.warn("StellarWalletsKitConnectButton", "Error removing button:", error);
|
|
2607
2788
|
}
|
|
2608
2789
|
} else {
|
|
2609
|
-
|
|
2790
|
+
import_ui_builder_utils20.logger.warn(
|
|
2610
2791
|
"StellarWalletsKitConnectButton",
|
|
2611
2792
|
"removeButton method not available on kit instance"
|
|
2612
2793
|
);
|
|
@@ -2635,7 +2816,7 @@ async function disconnectStellarWallet() {
|
|
|
2635
2816
|
function getStellarWalletConnectionStatus() {
|
|
2636
2817
|
const impl = getInitializedStellarWalletImplementation();
|
|
2637
2818
|
if (!impl) {
|
|
2638
|
-
|
|
2819
|
+
import_ui_builder_utils21.logger.warn(
|
|
2639
2820
|
"getStellarWalletConnectionStatus",
|
|
2640
2821
|
"Wallet implementation not ready. Returning default disconnected state."
|
|
2641
2822
|
);
|
|
@@ -2657,7 +2838,7 @@ function getStellarWalletConnectionStatus() {
|
|
|
2657
2838
|
function onStellarWalletConnectionChange(callback) {
|
|
2658
2839
|
const impl = getInitializedStellarWalletImplementation();
|
|
2659
2840
|
if (!impl) {
|
|
2660
|
-
|
|
2841
|
+
import_ui_builder_utils21.logger.warn(
|
|
2661
2842
|
"onStellarWalletConnectionChange",
|
|
2662
2843
|
"Wallet implementation not ready. Returning no-op."
|
|
2663
2844
|
);
|
|
@@ -2680,13 +2861,13 @@ function onStellarWalletConnectionChange(callback) {
|
|
|
2680
2861
|
try {
|
|
2681
2862
|
callback(currentStatus, previousStatus);
|
|
2682
2863
|
} catch (error) {
|
|
2683
|
-
|
|
2864
|
+
import_ui_builder_utils21.logger.error("Error in Stellar connection status listener:", String(error));
|
|
2684
2865
|
}
|
|
2685
2866
|
});
|
|
2686
2867
|
}
|
|
2687
|
-
async function signTransaction(
|
|
2868
|
+
async function signTransaction(xdr13, address) {
|
|
2688
2869
|
const impl = await getStellarWalletImplementation();
|
|
2689
|
-
return impl.signTransaction(
|
|
2870
|
+
return impl.signTransaction(xdr13, address);
|
|
2690
2871
|
}
|
|
2691
2872
|
|
|
2692
2873
|
// src/transaction/relayer.ts
|
|
@@ -2725,7 +2906,7 @@ var RelayerExecutionStrategy = class {
|
|
|
2725
2906
|
* @throws If the API call fails or returns an unsuccessful response.
|
|
2726
2907
|
*/
|
|
2727
2908
|
async getStellarRelayers(serviceUrl, accessToken, networkConfig) {
|
|
2728
|
-
|
|
2909
|
+
import_ui_builder_utils22.logger.info(
|
|
2729
2910
|
"[StellarRelayer] Getting relayers with access token",
|
|
2730
2911
|
accessToken.slice(0, 5).padEnd(accessToken.length, "*")
|
|
2731
2912
|
);
|
|
@@ -2773,7 +2954,7 @@ var RelayerExecutionStrategy = class {
|
|
|
2773
2954
|
* @throws If any API call fails or returns an unsuccessful response.
|
|
2774
2955
|
*/
|
|
2775
2956
|
async getStellarRelayer(serviceUrl, accessToken, relayerId, _networkConfig) {
|
|
2776
|
-
|
|
2957
|
+
import_ui_builder_utils22.logger.info("[StellarRelayer] Getting detailed relayer info", relayerId);
|
|
2777
2958
|
const sdkConfig = new import_relayer_sdk.Configuration({
|
|
2778
2959
|
basePath: serviceUrl,
|
|
2779
2960
|
accessToken
|
|
@@ -2783,11 +2964,11 @@ var RelayerExecutionStrategy = class {
|
|
|
2783
2964
|
const [relayerResponse, balanceResponse, statusResponse] = await Promise.all([
|
|
2784
2965
|
relayersApi.getRelayer(relayerId),
|
|
2785
2966
|
relayersApi.getRelayerBalance(relayerId).catch((err) => {
|
|
2786
|
-
|
|
2967
|
+
import_ui_builder_utils22.logger.warn("[StellarRelayer] Failed to fetch balance", err);
|
|
2787
2968
|
return null;
|
|
2788
2969
|
}),
|
|
2789
2970
|
relayersApi.getRelayerStatus(relayerId).catch((err) => {
|
|
2790
|
-
|
|
2971
|
+
import_ui_builder_utils22.logger.warn("[StellarRelayer] Failed to fetch status", err);
|
|
2791
2972
|
return null;
|
|
2792
2973
|
})
|
|
2793
2974
|
]);
|
|
@@ -2809,7 +2990,7 @@ var RelayerExecutionStrategy = class {
|
|
|
2809
2990
|
const balanceInXlm = balanceInStroops / 1e7;
|
|
2810
2991
|
enhancedDetails.balance = `${balanceInXlm.toFixed(7)} XLM`;
|
|
2811
2992
|
} catch (error) {
|
|
2812
|
-
|
|
2993
|
+
import_ui_builder_utils22.logger.warn("[StellarRelayer] Failed to format balance, using raw value", String(error));
|
|
2813
2994
|
enhancedDetails.balance = String(balanceResponse.data.data.balance);
|
|
2814
2995
|
}
|
|
2815
2996
|
}
|
|
@@ -2828,13 +3009,13 @@ var RelayerExecutionStrategy = class {
|
|
|
2828
3009
|
}
|
|
2829
3010
|
}
|
|
2830
3011
|
}
|
|
2831
|
-
|
|
3012
|
+
import_ui_builder_utils22.logger.info(
|
|
2832
3013
|
"[StellarRelayer] Retrieved enhanced relayer details",
|
|
2833
3014
|
JSON.stringify(enhancedDetails)
|
|
2834
3015
|
);
|
|
2835
3016
|
return enhancedDetails;
|
|
2836
3017
|
} catch (error) {
|
|
2837
|
-
|
|
3018
|
+
import_ui_builder_utils22.logger.error(
|
|
2838
3019
|
"[StellarRelayer] Failed to get relayer details",
|
|
2839
3020
|
error instanceof Error ? error.message : String(error)
|
|
2840
3021
|
);
|
|
@@ -2921,10 +3102,10 @@ var RelayerExecutionStrategy = class {
|
|
|
2921
3102
|
const rpcServer = this.getSorobanRpcServer(stellarConfig);
|
|
2922
3103
|
const connectedAddress = this.getConnectedWalletAddress();
|
|
2923
3104
|
const accountResponse = await rpcServer.getAccount(connectedAddress);
|
|
2924
|
-
const sourceAccount = new
|
|
2925
|
-
const contract2 = new
|
|
2926
|
-
const transactionBuilder = new
|
|
2927
|
-
fee:
|
|
3105
|
+
const sourceAccount = new import_stellar_sdk12.Account(connectedAddress, accountResponse.sequenceNumber());
|
|
3106
|
+
const contract2 = new import_stellar_sdk12.Contract(txData.contractAddress);
|
|
3107
|
+
const transactionBuilder = new import_stellar_sdk12.TransactionBuilder(sourceAccount, {
|
|
3108
|
+
fee: import_stellar_sdk12.BASE_FEE,
|
|
2928
3109
|
networkPassphrase: stellarConfig.networkPassphrase
|
|
2929
3110
|
});
|
|
2930
3111
|
const scValArgs = txData.args.map((arg, index) => {
|
|
@@ -2936,12 +3117,12 @@ var RelayerExecutionStrategy = class {
|
|
|
2936
3117
|
transactionBuilder.setTimeout(30);
|
|
2937
3118
|
let transaction = transactionBuilder.build();
|
|
2938
3119
|
const simulation = await rpcServer.simulateTransaction(transaction);
|
|
2939
|
-
if (
|
|
3120
|
+
if (import_stellar_sdk12.rpc.Api.isSimulationError(simulation)) {
|
|
2940
3121
|
throw new Error(`Transaction simulation failed: ${simulation.error}`);
|
|
2941
3122
|
}
|
|
2942
3123
|
transaction = await rpcServer.prepareTransaction(transaction);
|
|
2943
3124
|
const signResult = await signTransaction(transaction.toXDR(), connectedAddress);
|
|
2944
|
-
const signedTx =
|
|
3125
|
+
const signedTx = import_stellar_sdk12.TransactionBuilder.fromXDR(
|
|
2945
3126
|
signResult.signedTxXdr,
|
|
2946
3127
|
stellarConfig.networkPassphrase
|
|
2947
3128
|
);
|
|
@@ -2959,7 +3140,7 @@ var RelayerExecutionStrategy = class {
|
|
|
2959
3140
|
throw new Error(`No Soroban RPC URL available for network ${networkConfig.name}`);
|
|
2960
3141
|
}
|
|
2961
3142
|
const allowHttp = new URL(rpcUrl).hostname === "localhost";
|
|
2962
|
-
return new
|
|
3143
|
+
return new import_stellar_sdk12.rpc.Server(rpcUrl, { allowHttp });
|
|
2963
3144
|
}
|
|
2964
3145
|
getConnectedWalletAddress() {
|
|
2965
3146
|
const connectionStatus = getStellarWalletConnectionStatus();
|
|
@@ -3090,10 +3271,10 @@ var RelayerExecutionStrategy = class {
|
|
|
3090
3271
|
};
|
|
3091
3272
|
|
|
3092
3273
|
// src/configuration/execution.ts
|
|
3093
|
-
var
|
|
3274
|
+
var import_ui_builder_utils23 = require("@openzeppelin/ui-builder-utils");
|
|
3094
3275
|
var SYSTEM_LOG_TAG7 = "adapter-stellar-execution-config";
|
|
3095
3276
|
async function getStellarSupportedExecutionMethods() {
|
|
3096
|
-
|
|
3277
|
+
import_ui_builder_utils23.logger.warn(
|
|
3097
3278
|
"adapter-stellar-execution-config",
|
|
3098
3279
|
"getStellarSupportedExecutionMethods is using placeholder implementation."
|
|
3099
3280
|
);
|
|
@@ -3119,11 +3300,11 @@ async function getStellarSupportedExecutionMethods() {
|
|
|
3119
3300
|
]);
|
|
3120
3301
|
}
|
|
3121
3302
|
async function _validateMultisigConfig(_config, _walletStatus) {
|
|
3122
|
-
|
|
3303
|
+
import_ui_builder_utils23.logger.info(SYSTEM_LOG_TAG7, "Multisig execution config validation: Not yet fully implemented.");
|
|
3123
3304
|
return true;
|
|
3124
3305
|
}
|
|
3125
3306
|
async function validateStellarExecutionConfig(config, walletStatus) {
|
|
3126
|
-
|
|
3307
|
+
import_ui_builder_utils23.logger.info(SYSTEM_LOG_TAG7, "Validating Stellar execution config:", { config, walletStatus });
|
|
3127
3308
|
switch (config.method) {
|
|
3128
3309
|
case "eoa":
|
|
3129
3310
|
return validateEoaConfig(config, walletStatus);
|
|
@@ -3133,7 +3314,7 @@ async function validateStellarExecutionConfig(config, walletStatus) {
|
|
|
3133
3314
|
return _validateMultisigConfig(config, walletStatus);
|
|
3134
3315
|
default: {
|
|
3135
3316
|
const unknownMethod = config.method;
|
|
3136
|
-
|
|
3317
|
+
import_ui_builder_utils23.logger.warn(
|
|
3137
3318
|
SYSTEM_LOG_TAG7,
|
|
3138
3319
|
`Unsupported execution method type encountered: ${unknownMethod}`
|
|
3139
3320
|
);
|
|
@@ -3143,16 +3324,16 @@ async function validateStellarExecutionConfig(config, walletStatus) {
|
|
|
3143
3324
|
}
|
|
3144
3325
|
|
|
3145
3326
|
// src/configuration/rpc.ts
|
|
3146
|
-
var
|
|
3327
|
+
var import_ui_builder_utils24 = require("@openzeppelin/ui-builder-utils");
|
|
3147
3328
|
function validateStellarRpcEndpoint(rpcConfig) {
|
|
3148
3329
|
try {
|
|
3149
|
-
if (!(0,
|
|
3150
|
-
|
|
3330
|
+
if (!(0, import_ui_builder_utils24.isValidUrl)(rpcConfig.url)) {
|
|
3331
|
+
import_ui_builder_utils24.logger.error("validateStellarRpcEndpoint", `Invalid RPC URL format: ${rpcConfig.url}`);
|
|
3151
3332
|
return false;
|
|
3152
3333
|
}
|
|
3153
3334
|
return true;
|
|
3154
3335
|
} catch (error) {
|
|
3155
|
-
|
|
3336
|
+
import_ui_builder_utils24.logger.error("validateStellarRpcEndpoint", "Error validating RPC endpoint:", error);
|
|
3156
3337
|
return false;
|
|
3157
3338
|
}
|
|
3158
3339
|
}
|
|
@@ -3200,7 +3381,7 @@ async function testStellarRpcConnection(rpcConfig, timeoutMs = 5e3) {
|
|
|
3200
3381
|
}
|
|
3201
3382
|
return { success: true, latency };
|
|
3202
3383
|
} catch (error) {
|
|
3203
|
-
|
|
3384
|
+
import_ui_builder_utils24.logger.error("testStellarRpcConnection", "Connection test failed:", error);
|
|
3204
3385
|
if (error instanceof Error && error.name === "AbortError") {
|
|
3205
3386
|
return {
|
|
3206
3387
|
success: false,
|
|
@@ -3419,11 +3600,11 @@ function getStellarCompatibleFieldTypes(parameterType) {
|
|
|
3419
3600
|
|
|
3420
3601
|
// src/mapping/field-generator.ts
|
|
3421
3602
|
var import_lodash = require("lodash");
|
|
3422
|
-
var
|
|
3603
|
+
var import_ui_builder_utils26 = require("@openzeppelin/ui-builder-utils");
|
|
3423
3604
|
|
|
3424
3605
|
// src/mapping/enum-metadata.ts
|
|
3425
|
-
var
|
|
3426
|
-
var
|
|
3606
|
+
var import_stellar_sdk13 = require("@stellar/stellar-sdk");
|
|
3607
|
+
var import_ui_builder_utils25 = require("@openzeppelin/ui-builder-utils");
|
|
3427
3608
|
function extractEnumVariants(entries, enumName) {
|
|
3428
3609
|
try {
|
|
3429
3610
|
const entry = entries.find((e) => {
|
|
@@ -3437,20 +3618,20 @@ function extractEnumVariants(entries, enumName) {
|
|
|
3437
3618
|
return null;
|
|
3438
3619
|
}
|
|
3439
3620
|
const entryKind = entry.switch();
|
|
3440
|
-
if (entryKind.value ===
|
|
3621
|
+
if (entryKind.value === import_stellar_sdk13.xdr.ScSpecEntryKind.scSpecEntryUdtUnionV0().value) {
|
|
3441
3622
|
const unionUdt = entry.udtUnionV0();
|
|
3442
3623
|
const cases = unionUdt.cases();
|
|
3443
3624
|
const variants = [];
|
|
3444
3625
|
let isUnitOnly = true;
|
|
3445
3626
|
for (const caseEntry of cases) {
|
|
3446
3627
|
const caseKind = caseEntry.switch();
|
|
3447
|
-
if (caseKind.value ===
|
|
3628
|
+
if (caseKind.value === import_stellar_sdk13.xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0().value) {
|
|
3448
3629
|
const voidCase = caseEntry.voidCase();
|
|
3449
3630
|
variants.push({
|
|
3450
3631
|
name: voidCase.name().toString(),
|
|
3451
3632
|
type: "void"
|
|
3452
3633
|
});
|
|
3453
|
-
} else if (caseKind.value ===
|
|
3634
|
+
} else if (caseKind.value === import_stellar_sdk13.xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value) {
|
|
3454
3635
|
const tupleCase = caseEntry.tupleCase();
|
|
3455
3636
|
const payloadTypes = tupleCase.type().map((typeDef) => extractSorobanTypeFromScSpec(typeDef));
|
|
3456
3637
|
variants.push({
|
|
@@ -3467,7 +3648,7 @@ function extractEnumVariants(entries, enumName) {
|
|
|
3467
3648
|
isUnitOnly
|
|
3468
3649
|
};
|
|
3469
3650
|
}
|
|
3470
|
-
if (entryKind.value ===
|
|
3651
|
+
if (entryKind.value === import_stellar_sdk13.xdr.ScSpecEntryKind.scSpecEntryUdtEnumV0().value) {
|
|
3471
3652
|
const enumUdt = entry.udtEnumV0();
|
|
3472
3653
|
const cases = enumUdt.cases();
|
|
3473
3654
|
const variants = [];
|
|
@@ -3487,7 +3668,7 @@ function extractEnumVariants(entries, enumName) {
|
|
|
3487
3668
|
}
|
|
3488
3669
|
return null;
|
|
3489
3670
|
} catch (error) {
|
|
3490
|
-
|
|
3671
|
+
import_ui_builder_utils25.logger.error("extractEnumVariants", `Failed to extract enum variants for ${enumName}:`, error);
|
|
3491
3672
|
return null;
|
|
3492
3673
|
}
|
|
3493
3674
|
}
|
|
@@ -3505,10 +3686,10 @@ function isEnumType(entries, typeName) {
|
|
|
3505
3686
|
return false;
|
|
3506
3687
|
}
|
|
3507
3688
|
const entryKind = entry.switch();
|
|
3508
|
-
const isEnum = entryKind.value ===
|
|
3689
|
+
const isEnum = entryKind.value === import_stellar_sdk13.xdr.ScSpecEntryKind.scSpecEntryUdtUnionV0().value || entryKind.value === import_stellar_sdk13.xdr.ScSpecEntryKind.scSpecEntryUdtEnumV0().value;
|
|
3509
3690
|
return isEnum;
|
|
3510
3691
|
} catch (error) {
|
|
3511
|
-
|
|
3692
|
+
import_ui_builder_utils25.logger.error("isEnumType", `Failed to check if ${typeName} is enum:`, error);
|
|
3512
3693
|
return false;
|
|
3513
3694
|
}
|
|
3514
3695
|
}
|
|
@@ -3521,12 +3702,13 @@ function generateStellarDefaultField(parameter, contractSchema) {
|
|
|
3521
3702
|
const specEntries = contractSchema?.metadata?.specEntries;
|
|
3522
3703
|
const fieldType = mapStellarParameterTypeToFieldType(parameter.type);
|
|
3523
3704
|
if (parameter.type === "unknown") {
|
|
3524
|
-
|
|
3705
|
+
import_ui_builder_utils26.logger.warn(
|
|
3525
3706
|
"adapter-stellar",
|
|
3526
3707
|
`[generateStellarDefaultField] Parameter "${parameter.name}" has type "unknown"`
|
|
3527
3708
|
);
|
|
3528
3709
|
}
|
|
3529
3710
|
let enumMetadata = null;
|
|
3711
|
+
let structComponents = null;
|
|
3530
3712
|
let finalFieldType = fieldType;
|
|
3531
3713
|
let options;
|
|
3532
3714
|
if (isLikelyEnumType(parameter.type)) {
|
|
@@ -3553,6 +3735,12 @@ function generateStellarDefaultField(parameter, contractSchema) {
|
|
|
3553
3735
|
};
|
|
3554
3736
|
}
|
|
3555
3737
|
}
|
|
3738
|
+
if (specEntries && isStructType(specEntries, parameter.type)) {
|
|
3739
|
+
const structFields = extractStructFields(specEntries, parameter.type);
|
|
3740
|
+
if (structFields && structFields.length > 0) {
|
|
3741
|
+
structComponents = structFields;
|
|
3742
|
+
}
|
|
3743
|
+
}
|
|
3556
3744
|
const baseField = {
|
|
3557
3745
|
id: `field-${Math.random().toString(36).substring(2, 9)}`,
|
|
3558
3746
|
name: parameter.name || parameter.type,
|
|
@@ -3561,7 +3749,7 @@ function generateStellarDefaultField(parameter, contractSchema) {
|
|
|
3561
3749
|
type: finalFieldType,
|
|
3562
3750
|
placeholder: enumMetadata ? `Select ${parameter.displayName || parameter.name || parameter.type}` : `Enter ${parameter.displayName || parameter.name || parameter.type}`,
|
|
3563
3751
|
helperText: parameter.description || "",
|
|
3564
|
-
defaultValue: (0,
|
|
3752
|
+
defaultValue: (0, import_ui_builder_utils26.getDefaultValueForType)(finalFieldType),
|
|
3565
3753
|
validation: getDefaultValidationForType(),
|
|
3566
3754
|
width: "full",
|
|
3567
3755
|
options
|
|
@@ -3624,12 +3812,15 @@ function generateStellarDefaultField(parameter, contractSchema) {
|
|
|
3624
3812
|
return mapField;
|
|
3625
3813
|
}
|
|
3626
3814
|
}
|
|
3627
|
-
if (
|
|
3628
|
-
const
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3815
|
+
if (fieldType === "object" || fieldType === "array-object") {
|
|
3816
|
+
const componentsToUse = parameter.components || structComponents;
|
|
3817
|
+
if (componentsToUse) {
|
|
3818
|
+
const result = {
|
|
3819
|
+
...baseField,
|
|
3820
|
+
components: componentsToUse
|
|
3821
|
+
};
|
|
3822
|
+
return result;
|
|
3823
|
+
}
|
|
3633
3824
|
}
|
|
3634
3825
|
if (enumMetadata) {
|
|
3635
3826
|
const result = {
|
|
@@ -3642,11 +3833,11 @@ function generateStellarDefaultField(parameter, contractSchema) {
|
|
|
3642
3833
|
}
|
|
3643
3834
|
|
|
3644
3835
|
// src/transaction/formatter.ts
|
|
3645
|
-
var
|
|
3836
|
+
var import_stellar_sdk14 = require("@stellar/stellar-sdk");
|
|
3646
3837
|
var import_ui_builder_types4 = require("@openzeppelin/ui-builder-types");
|
|
3647
|
-
var
|
|
3838
|
+
var import_ui_builder_utils27 = require("@openzeppelin/ui-builder-utils");
|
|
3648
3839
|
function formatStellarTransactionData(contractSchema, functionId, submittedInputs, fields) {
|
|
3649
|
-
|
|
3840
|
+
import_ui_builder_utils27.logger.info(
|
|
3650
3841
|
"formatStellarTransactionData",
|
|
3651
3842
|
`Formatting Stellar transaction data for function: ${functionId}`
|
|
3652
3843
|
);
|
|
@@ -3664,7 +3855,7 @@ function formatStellarTransactionData(contractSchema, functionId, submittedInput
|
|
|
3664
3855
|
let value;
|
|
3665
3856
|
if (fieldConfig.isHardcoded) {
|
|
3666
3857
|
if (fieldConfig.hardcodedValue === void 0 && fieldConfig.name in submittedInputs) {
|
|
3667
|
-
|
|
3858
|
+
import_ui_builder_utils27.logger.warn(
|
|
3668
3859
|
"formatStellarTransactionData",
|
|
3669
3860
|
`Field '${fieldConfig.name}' is hardcoded with undefined value but has submitted input. Using submitted input instead.`
|
|
3670
3861
|
);
|
|
@@ -3719,7 +3910,7 @@ function formatStellarTransactionData(contractSchema, functionId, submittedInput
|
|
|
3719
3910
|
throw new Error("Contract address is missing or invalid in the provided schema.");
|
|
3720
3911
|
}
|
|
3721
3912
|
try {
|
|
3722
|
-
|
|
3913
|
+
import_stellar_sdk14.Address.fromString(contractSchema.address);
|
|
3723
3914
|
} catch {
|
|
3724
3915
|
throw new Error("Contract address is missing or invalid in the provided schema.");
|
|
3725
3916
|
}
|
|
@@ -3736,7 +3927,7 @@ function formatStellarTransactionData(contractSchema, functionId, submittedInput
|
|
|
3736
3927
|
// For example: fee, timeout, memo, etc.
|
|
3737
3928
|
}
|
|
3738
3929
|
};
|
|
3739
|
-
|
|
3930
|
+
import_ui_builder_utils27.logger.debug(
|
|
3740
3931
|
"formatStellarTransactionData",
|
|
3741
3932
|
"Formatted transaction data:",
|
|
3742
3933
|
stellarTransactionData
|
|
@@ -3745,27 +3936,27 @@ function formatStellarTransactionData(contractSchema, functionId, submittedInput
|
|
|
3745
3936
|
}
|
|
3746
3937
|
|
|
3747
3938
|
// src/transaction/sender.ts
|
|
3748
|
-
var
|
|
3749
|
-
var
|
|
3939
|
+
var import_stellar_sdk16 = require("@stellar/stellar-sdk");
|
|
3940
|
+
var import_ui_builder_utils29 = require("@openzeppelin/ui-builder-utils");
|
|
3750
3941
|
|
|
3751
3942
|
// src/transaction/eoa.ts
|
|
3752
|
-
var
|
|
3753
|
-
var
|
|
3943
|
+
var import_stellar_sdk15 = require("@stellar/stellar-sdk");
|
|
3944
|
+
var import_ui_builder_utils28 = require("@openzeppelin/ui-builder-utils");
|
|
3754
3945
|
var SYSTEM_LOG_TAG8 = "EoaExecutionStrategy";
|
|
3755
|
-
function
|
|
3756
|
-
const customRpcConfig =
|
|
3946
|
+
function getSorobanRpcServer3(networkConfig) {
|
|
3947
|
+
const customRpcConfig = import_ui_builder_utils28.userRpcConfigService.getUserRpcConfig(networkConfig.id);
|
|
3757
3948
|
const rpcUrl = customRpcConfig?.url || networkConfig.sorobanRpcUrl;
|
|
3758
3949
|
if (!rpcUrl) {
|
|
3759
3950
|
throw new Error(`No Soroban RPC URL available for network ${networkConfig.name}`);
|
|
3760
3951
|
}
|
|
3761
3952
|
const allowHttp = new URL(rpcUrl).hostname === "localhost";
|
|
3762
|
-
return new
|
|
3953
|
+
return new import_stellar_sdk15.rpc.Server(rpcUrl, {
|
|
3763
3954
|
allowHttp
|
|
3764
3955
|
});
|
|
3765
3956
|
}
|
|
3766
3957
|
var EoaExecutionStrategy = class {
|
|
3767
3958
|
async execute(transactionData, executionConfig, networkConfig, onStatusChange, _runtimeApiKey) {
|
|
3768
|
-
|
|
3959
|
+
import_ui_builder_utils28.logger.info(SYSTEM_LOG_TAG8, "Using Stellar EOA execution strategy");
|
|
3769
3960
|
if (executionConfig.method !== "eoa") {
|
|
3770
3961
|
throw new Error(`Expected EOA execution config, got: ${executionConfig.method}`);
|
|
3771
3962
|
}
|
|
@@ -3773,19 +3964,19 @@ var EoaExecutionStrategy = class {
|
|
|
3773
3964
|
}
|
|
3774
3965
|
async executeEoaTransaction(txData, stellarConfig, onStatusChange) {
|
|
3775
3966
|
try {
|
|
3776
|
-
const rpcServer =
|
|
3967
|
+
const rpcServer = getSorobanRpcServer3(stellarConfig);
|
|
3777
3968
|
const connectedAddress = this.getConnectedWalletAddress();
|
|
3778
|
-
|
|
3969
|
+
import_ui_builder_utils28.logger.info(SYSTEM_LOG_TAG8, `Connected address: ${connectedAddress}`);
|
|
3779
3970
|
let sourceAccount;
|
|
3780
3971
|
try {
|
|
3781
3972
|
const accountResponse = await rpcServer.getAccount(connectedAddress);
|
|
3782
|
-
sourceAccount = new
|
|
3973
|
+
sourceAccount = new import_stellar_sdk15.Account(connectedAddress, accountResponse.sequenceNumber());
|
|
3783
3974
|
} catch (error) {
|
|
3784
3975
|
throw new Error(`Failed to load account details: ${error.message}`);
|
|
3785
3976
|
}
|
|
3786
|
-
const contract2 = new
|
|
3787
|
-
const transactionBuilder = new
|
|
3788
|
-
fee:
|
|
3977
|
+
const contract2 = new import_stellar_sdk15.Contract(txData.contractAddress);
|
|
3978
|
+
const transactionBuilder = new import_stellar_sdk15.TransactionBuilder(sourceAccount, {
|
|
3979
|
+
fee: import_stellar_sdk15.BASE_FEE,
|
|
3789
3980
|
networkPassphrase: stellarConfig.networkPassphrase
|
|
3790
3981
|
});
|
|
3791
3982
|
const scValArgs = txData.args.map((arg, index) => {
|
|
@@ -3798,7 +3989,7 @@ var EoaExecutionStrategy = class {
|
|
|
3798
3989
|
let transaction = transactionBuilder.build();
|
|
3799
3990
|
try {
|
|
3800
3991
|
const simulation = await rpcServer.simulateTransaction(transaction);
|
|
3801
|
-
if (
|
|
3992
|
+
if (import_stellar_sdk15.rpc.Api.isSimulationError(simulation)) {
|
|
3802
3993
|
throw new Error(`Transaction simulation failed: ${simulation.error}`);
|
|
3803
3994
|
}
|
|
3804
3995
|
transaction = await rpcServer.prepareTransaction(transaction);
|
|
@@ -3808,7 +3999,7 @@ var EoaExecutionStrategy = class {
|
|
|
3808
3999
|
onStatusChange("pendingSignature", {});
|
|
3809
4000
|
try {
|
|
3810
4001
|
const signResult = await signTransaction(transaction.toXDR(), connectedAddress);
|
|
3811
|
-
const signedTx =
|
|
4002
|
+
const signedTx = import_stellar_sdk15.TransactionBuilder.fromXDR(
|
|
3812
4003
|
signResult.signedTxXdr,
|
|
3813
4004
|
stellarConfig.networkPassphrase
|
|
3814
4005
|
);
|
|
@@ -3834,7 +4025,7 @@ var EoaExecutionStrategy = class {
|
|
|
3834
4025
|
throw new Error(`Transaction failed to submit: ${sendResult.status}`);
|
|
3835
4026
|
}
|
|
3836
4027
|
const txHash = sendResult.hash;
|
|
3837
|
-
|
|
4028
|
+
import_ui_builder_utils28.logger.info(SYSTEM_LOG_TAG8, `Transaction submitted successfully: ${txHash}`);
|
|
3838
4029
|
try {
|
|
3839
4030
|
let txResponse;
|
|
3840
4031
|
const MAX_ATTEMPTS = 10;
|
|
@@ -3853,10 +4044,10 @@ var EoaExecutionStrategy = class {
|
|
|
3853
4044
|
}
|
|
3854
4045
|
}
|
|
3855
4046
|
if (attempts >= MAX_ATTEMPTS || txResponse?.status !== "SUCCESS") {
|
|
3856
|
-
|
|
4047
|
+
import_ui_builder_utils28.logger.warn(SYSTEM_LOG_TAG8, `Transaction confirmation timeout for ${txHash}`);
|
|
3857
4048
|
}
|
|
3858
4049
|
} catch (confirmError) {
|
|
3859
|
-
|
|
4050
|
+
import_ui_builder_utils28.logger.error(SYSTEM_LOG_TAG8, "Error waiting for confirmation:", confirmError);
|
|
3860
4051
|
}
|
|
3861
4052
|
onStatusChange("success", {
|
|
3862
4053
|
txHash
|
|
@@ -3864,7 +4055,7 @@ var EoaExecutionStrategy = class {
|
|
|
3864
4055
|
return { txHash };
|
|
3865
4056
|
} catch (error) {
|
|
3866
4057
|
const errorMessage = `Failed to execute Stellar EOA transaction: ${error.message}`;
|
|
3867
|
-
|
|
4058
|
+
import_ui_builder_utils28.logger.error(SYSTEM_LOG_TAG8, errorMessage, error);
|
|
3868
4059
|
onStatusChange("error", {});
|
|
3869
4060
|
throw new Error(errorMessage);
|
|
3870
4061
|
}
|
|
@@ -3881,7 +4072,7 @@ var EoaExecutionStrategy = class {
|
|
|
3881
4072
|
// src/transaction/sender.ts
|
|
3882
4073
|
var SYSTEM_LOG_TAG9 = "adapter-stellar";
|
|
3883
4074
|
async function signAndBroadcastStellarTransaction(transactionData, executionConfig, networkConfig, onStatusChange, runtimeApiKey) {
|
|
3884
|
-
|
|
4075
|
+
import_ui_builder_utils29.logger.info(
|
|
3885
4076
|
SYSTEM_LOG_TAG9,
|
|
3886
4077
|
"Stellar signAndBroadcast called with executionConfig:",
|
|
3887
4078
|
executionConfig
|
|
@@ -3902,7 +4093,7 @@ async function signAndBroadcastStellarTransaction(transactionData, executionConf
|
|
|
3902
4093
|
throw new Error("Multisig execution method not yet implemented for Stellar.");
|
|
3903
4094
|
default: {
|
|
3904
4095
|
const exhaustiveCheck = executionConfig;
|
|
3905
|
-
|
|
4096
|
+
import_ui_builder_utils29.logger.error(SYSTEM_LOG_TAG9, `Unsupported execution method encountered: ${exhaustiveCheck}`);
|
|
3906
4097
|
throw new Error(`Unsupported execution method: ${exhaustiveCheck}`);
|
|
3907
4098
|
}
|
|
3908
4099
|
}
|
|
@@ -3918,7 +4109,7 @@ async function signAndBroadcastStellarTransaction(transactionData, executionConf
|
|
|
3918
4109
|
|
|
3919
4110
|
// src/wallet/components/StellarWalletUiRoot.tsx
|
|
3920
4111
|
var import_react5 = require("react");
|
|
3921
|
-
var
|
|
4112
|
+
var import_ui_builder_utils30 = require("@openzeppelin/ui-builder-utils");
|
|
3922
4113
|
|
|
3923
4114
|
// src/wallet/context/StellarWalletContext.ts
|
|
3924
4115
|
var import_react4 = require("react");
|
|
@@ -3937,9 +4128,9 @@ function StellarWalletUiRoot({ children, uiKitConfig }) {
|
|
|
3937
4128
|
const currentState = stellarUiKitManager.getState();
|
|
3938
4129
|
if (uiKitConfig || !currentState.currentFullUiKitConfig) {
|
|
3939
4130
|
const configToUse = uiKitConfig || { kitName: "custom", kitConfig: {} };
|
|
3940
|
-
|
|
4131
|
+
import_ui_builder_utils30.logger.debug("StellarWalletUiRoot", "Configuring UI kit with:", configToUse);
|
|
3941
4132
|
stellarUiKitManager.configure(configToUse).catch((error) => {
|
|
3942
|
-
|
|
4133
|
+
import_ui_builder_utils30.logger.error("Failed to configure Stellar UI kit:", error);
|
|
3943
4134
|
});
|
|
3944
4135
|
}
|
|
3945
4136
|
}, [uiKitConfig]);
|
|
@@ -3953,7 +4144,7 @@ function StellarWalletUiRoot({ children, uiKitConfig }) {
|
|
|
3953
4144
|
const unsubscribeFromConnectionChanges = onStellarWalletConnectionChange(
|
|
3954
4145
|
(currentStatus, _previousStatus) => {
|
|
3955
4146
|
setAddress(currentStatus.address || null);
|
|
3956
|
-
|
|
4147
|
+
import_ui_builder_utils30.logger.debug(
|
|
3957
4148
|
"StellarWalletUiRoot",
|
|
3958
4149
|
`Connection status changed: ${currentStatus.isConnected ? "connected" : "disconnected"}`,
|
|
3959
4150
|
currentStatus.address
|
|
@@ -3972,7 +4163,7 @@ function StellarWalletUiRoot({ children, uiKitConfig }) {
|
|
|
3972
4163
|
const connectors = await getStellarAvailableConnectors();
|
|
3973
4164
|
setAvailableWallets(connectors);
|
|
3974
4165
|
} catch (error) {
|
|
3975
|
-
|
|
4166
|
+
import_ui_builder_utils30.logger.error("Failed to load available wallets:", String(error));
|
|
3976
4167
|
}
|
|
3977
4168
|
};
|
|
3978
4169
|
if (!uiKitManagerState.isInitializing && uiKitManagerState.stellarKitProvider) {
|
|
@@ -3989,7 +4180,7 @@ function StellarWalletUiRoot({ children, uiKitConfig }) {
|
|
|
3989
4180
|
throw new Error(result.error || "Failed to connect wallet");
|
|
3990
4181
|
}
|
|
3991
4182
|
} catch (error) {
|
|
3992
|
-
|
|
4183
|
+
import_ui_builder_utils30.logger.error("Failed to connect:", String(error));
|
|
3993
4184
|
throw error;
|
|
3994
4185
|
} finally {
|
|
3995
4186
|
setIsConnecting(false);
|
|
@@ -4004,7 +4195,7 @@ function StellarWalletUiRoot({ children, uiKitConfig }) {
|
|
|
4004
4195
|
throw new Error(result.error || "Failed to disconnect wallet");
|
|
4005
4196
|
}
|
|
4006
4197
|
} catch (error) {
|
|
4007
|
-
|
|
4198
|
+
import_ui_builder_utils30.logger.error("Failed to disconnect:", String(error));
|
|
4008
4199
|
throw error;
|
|
4009
4200
|
}
|
|
4010
4201
|
}, []);
|
|
@@ -4123,20 +4314,20 @@ var stellarFacadeHooks = {
|
|
|
4123
4314
|
};
|
|
4124
4315
|
|
|
4125
4316
|
// src/wallet/hooks/useUiKitConfig.ts
|
|
4126
|
-
var
|
|
4317
|
+
var import_ui_builder_utils31 = require("@openzeppelin/ui-builder-utils");
|
|
4127
4318
|
var defaultConfig = {
|
|
4128
4319
|
kitName: "custom",
|
|
4129
4320
|
// Default to using our custom implementation for Stellar
|
|
4130
4321
|
kitConfig: {}
|
|
4131
4322
|
};
|
|
4132
4323
|
function loadInitialConfigFromAppService() {
|
|
4133
|
-
|
|
4324
|
+
import_ui_builder_utils31.logger.debug(
|
|
4134
4325
|
"stellar:useUiKitConfig",
|
|
4135
4326
|
"Attempting to load initial config from AppConfigService..."
|
|
4136
4327
|
);
|
|
4137
|
-
const configObj =
|
|
4328
|
+
const configObj = import_ui_builder_utils31.appConfigService.getWalletUIConfig("stellar");
|
|
4138
4329
|
if (configObj && configObj.kitName) {
|
|
4139
|
-
|
|
4330
|
+
import_ui_builder_utils31.logger.info(
|
|
4140
4331
|
"stellar:useUiKitConfig",
|
|
4141
4332
|
`Loaded initial config from AppConfigService: kitName=${configObj.kitName}`,
|
|
4142
4333
|
configObj.kitConfig
|
|
@@ -4146,7 +4337,7 @@ function loadInitialConfigFromAppService() {
|
|
|
4146
4337
|
kitConfig: { ...defaultConfig.kitConfig, ...configObj.kitConfig || {} }
|
|
4147
4338
|
};
|
|
4148
4339
|
}
|
|
4149
|
-
|
|
4340
|
+
import_ui_builder_utils31.logger.debug(
|
|
4150
4341
|
"stellar:useUiKitConfig",
|
|
4151
4342
|
"No initial config found in AppConfigService, using module default."
|
|
4152
4343
|
);
|
|
@@ -4157,12 +4348,12 @@ function loadInitialConfigFromAppService() {
|
|
|
4157
4348
|
var import_lucide_react2 = require("lucide-react");
|
|
4158
4349
|
var import_react10 = require("react");
|
|
4159
4350
|
var import_ui_builder_ui6 = require("@openzeppelin/ui-builder-ui");
|
|
4160
|
-
var
|
|
4351
|
+
var import_ui_builder_utils33 = require("@openzeppelin/ui-builder-utils");
|
|
4161
4352
|
|
|
4162
4353
|
// src/wallet/components/connect/ConnectorDialog.tsx
|
|
4163
4354
|
var import_react9 = require("react");
|
|
4164
4355
|
var import_ui_builder_ui5 = require("@openzeppelin/ui-builder-ui");
|
|
4165
|
-
var
|
|
4356
|
+
var import_ui_builder_utils32 = require("@openzeppelin/ui-builder-utils");
|
|
4166
4357
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
4167
4358
|
var ConnectorDialog = ({ open, onOpenChange }) => {
|
|
4168
4359
|
const { connect } = useStellarConnect();
|
|
@@ -4177,7 +4368,7 @@ var ConnectorDialog = ({ open, onOpenChange }) => {
|
|
|
4177
4368
|
const availableConnectors = await getStellarAvailableConnectors();
|
|
4178
4369
|
setConnectors(availableConnectors);
|
|
4179
4370
|
} catch (err) {
|
|
4180
|
-
|
|
4371
|
+
import_ui_builder_utils32.logger.error("Failed to load Stellar connectors:", String(err));
|
|
4181
4372
|
setError("Failed to load available wallets");
|
|
4182
4373
|
} finally {
|
|
4183
4374
|
setLoadingConnectors(false);
|
|
@@ -4268,7 +4459,7 @@ var CustomConnectButton = ({
|
|
|
4268
4459
|
return null;
|
|
4269
4460
|
}
|
|
4270
4461
|
const showButtonLoading = isConnecting || isManuallyInitiated;
|
|
4271
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: (0,
|
|
4462
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: (0, import_ui_builder_utils33.cn)("flex items-center", className), children: [
|
|
4272
4463
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4273
4464
|
import_ui_builder_ui6.Button,
|
|
4274
4465
|
{
|
|
@@ -4302,7 +4493,7 @@ var CustomConnectButton = ({
|
|
|
4302
4493
|
// src/wallet/components/account/AccountDisplay.tsx
|
|
4303
4494
|
var import_lucide_react3 = require("lucide-react");
|
|
4304
4495
|
var import_ui_builder_ui7 = require("@openzeppelin/ui-builder-ui");
|
|
4305
|
-
var
|
|
4496
|
+
var import_ui_builder_utils34 = require("@openzeppelin/ui-builder-utils");
|
|
4306
4497
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
4307
4498
|
var CustomAccountDisplay = ({ className }) => {
|
|
4308
4499
|
const { isConnected, address } = useStellarAccount();
|
|
@@ -4310,9 +4501,9 @@ var CustomAccountDisplay = ({ className }) => {
|
|
|
4310
4501
|
if (!isConnected || !address || !disconnect) {
|
|
4311
4502
|
return null;
|
|
4312
4503
|
}
|
|
4313
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: (0,
|
|
4504
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: (0, import_ui_builder_utils34.cn)("flex items-center gap-2", className), children: [
|
|
4314
4505
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col", children: [
|
|
4315
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium", children: (0,
|
|
4506
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium", children: (0, import_ui_builder_utils34.truncateMiddle)(address, 4, 4) }),
|
|
4316
4507
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-[9px] text-muted-foreground -mt-0.5", children: "Stellar Account" })
|
|
4317
4508
|
] }),
|
|
4318
4509
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -4331,18 +4522,18 @@ var CustomAccountDisplay = ({ className }) => {
|
|
|
4331
4522
|
|
|
4332
4523
|
// src/wallet/utils/filterWalletComponents.ts
|
|
4333
4524
|
var import_ui_builder_types5 = require("@openzeppelin/ui-builder-types");
|
|
4334
|
-
var
|
|
4525
|
+
var import_ui_builder_utils35 = require("@openzeppelin/ui-builder-utils");
|
|
4335
4526
|
function filterWalletComponents(allPossibleComponents, exclusions, kitName = "custom") {
|
|
4336
|
-
|
|
4527
|
+
import_ui_builder_utils35.logger.debug(
|
|
4337
4528
|
"filterWalletComponents",
|
|
4338
4529
|
`Filtering components for kit: ${kitName}. Exclusions: ${exclusions.join(", ")}.`
|
|
4339
4530
|
);
|
|
4340
4531
|
if (!allPossibleComponents || Object.keys(allPossibleComponents).length === 0) {
|
|
4341
|
-
|
|
4532
|
+
import_ui_builder_utils35.logger.debug("filterWalletComponents", `No components provided to filter for kit: ${kitName}.`);
|
|
4342
4533
|
return void 0;
|
|
4343
4534
|
}
|
|
4344
4535
|
if (exclusions.length === 0) {
|
|
4345
|
-
|
|
4536
|
+
import_ui_builder_utils35.logger.debug(
|
|
4346
4537
|
"filterWalletComponents",
|
|
4347
4538
|
`Providing all components for kit: ${kitName}.`,
|
|
4348
4539
|
allPossibleComponents
|
|
@@ -4361,14 +4552,14 @@ function filterWalletComponents(allPossibleComponents, exclusions, kitName = "cu
|
|
|
4361
4552
|
}
|
|
4362
4553
|
}
|
|
4363
4554
|
if (componentCount > 0) {
|
|
4364
|
-
|
|
4555
|
+
import_ui_builder_utils35.logger.debug(
|
|
4365
4556
|
"filterWalletComponents",
|
|
4366
4557
|
`Providing filtered components for kit: ${kitName} after exclusions (${exclusions.join(", ")}).`,
|
|
4367
4558
|
filteredComponents
|
|
4368
4559
|
);
|
|
4369
4560
|
return filteredComponents;
|
|
4370
4561
|
}
|
|
4371
|
-
|
|
4562
|
+
import_ui_builder_utils35.logger.debug("filterWalletComponents", `All components were excluded for kit: ${kitName}.`);
|
|
4372
4563
|
return void 0;
|
|
4373
4564
|
}
|
|
4374
4565
|
function getComponentExclusionsFromConfig(kitConfig) {
|
|
@@ -4384,23 +4575,23 @@ function getComponentExclusionsFromConfig(kitConfig) {
|
|
|
4384
4575
|
}
|
|
4385
4576
|
|
|
4386
4577
|
// src/wallet/utils/uiKitService.ts
|
|
4387
|
-
var
|
|
4578
|
+
var import_ui_builder_utils36 = require("@openzeppelin/ui-builder-utils");
|
|
4388
4579
|
function getResolvedWalletComponents(uiKitConfiguration) {
|
|
4389
|
-
|
|
4580
|
+
import_ui_builder_utils36.logger.debug(
|
|
4390
4581
|
"stellar:uiKitService:getResolvedWalletComponents",
|
|
4391
4582
|
"Received uiKitConfiguration:",
|
|
4392
4583
|
JSON.stringify(uiKitConfiguration)
|
|
4393
4584
|
);
|
|
4394
4585
|
const currentKitName = uiKitConfiguration.kitName || "custom";
|
|
4395
4586
|
if (currentKitName === "none") {
|
|
4396
|
-
|
|
4587
|
+
import_ui_builder_utils36.logger.info(
|
|
4397
4588
|
"stellar:uiKitService",
|
|
4398
4589
|
'UI Kit set to "none" for getResolvedWalletComponents, not providing wallet components.'
|
|
4399
4590
|
);
|
|
4400
4591
|
return void 0;
|
|
4401
4592
|
}
|
|
4402
4593
|
const exclusions = getComponentExclusionsFromConfig(uiKitConfiguration.kitConfig);
|
|
4403
|
-
|
|
4594
|
+
import_ui_builder_utils36.logger.debug(
|
|
4404
4595
|
"stellar:uiKitService",
|
|
4405
4596
|
`Extracted component exclusions for ${currentKitName}: ${exclusions.join(", ") || "none"}.`
|
|
4406
4597
|
);
|
|
@@ -4410,7 +4601,7 @@ function getResolvedWalletComponents(uiKitConfiguration) {
|
|
|
4410
4601
|
AccountDisplay: CustomAccountDisplay
|
|
4411
4602
|
// NetworkSwitcher is not included as Stellar doesn't support network switching
|
|
4412
4603
|
};
|
|
4413
|
-
|
|
4604
|
+
import_ui_builder_utils36.logger.info(
|
|
4414
4605
|
"stellar:uiKitService",
|
|
4415
4606
|
`Providing custom Stellar wallet components for kit: ${currentKitName}`
|
|
4416
4607
|
);
|
|
@@ -4422,10 +4613,10 @@ function getResolvedWalletComponents(uiKitConfiguration) {
|
|
|
4422
4613
|
// The kit's native button handles account display internally
|
|
4423
4614
|
AccountDisplay: void 0
|
|
4424
4615
|
};
|
|
4425
|
-
|
|
4616
|
+
import_ui_builder_utils36.logger.info("stellar:uiKitService", "Using Stellar Wallets Kit native button");
|
|
4426
4617
|
return stellarKitComponents;
|
|
4427
4618
|
}
|
|
4428
|
-
|
|
4619
|
+
import_ui_builder_utils36.logger.warn(
|
|
4429
4620
|
"stellar:uiKitService",
|
|
4430
4621
|
`UI Kit "${currentKitName}" for getResolvedWalletComponents not explicitly supported. No components provided.`
|
|
4431
4622
|
);
|
|
@@ -4433,9 +4624,9 @@ function getResolvedWalletComponents(uiKitConfiguration) {
|
|
|
4433
4624
|
}
|
|
4434
4625
|
|
|
4435
4626
|
// src/wallet/services/configResolutionService.ts
|
|
4436
|
-
var
|
|
4627
|
+
var import_ui_builder_utils37 = require("@openzeppelin/ui-builder-utils");
|
|
4437
4628
|
async function resolveFullUiKitConfiguration(programmaticOverrides, initialAppServiceKitName, currentAppServiceConfig, options) {
|
|
4438
|
-
|
|
4629
|
+
import_ui_builder_utils37.logger.debug(
|
|
4439
4630
|
"stellar:configResolutionService:resolveFullUiKitConfiguration",
|
|
4440
4631
|
"Starting resolution with:",
|
|
4441
4632
|
{
|
|
@@ -4446,7 +4637,7 @@ async function resolveFullUiKitConfiguration(programmaticOverrides, initialAppSe
|
|
|
4446
4637
|
}
|
|
4447
4638
|
);
|
|
4448
4639
|
if (options?.loadUiKitNativeConfig) {
|
|
4449
|
-
|
|
4640
|
+
import_ui_builder_utils37.logger.debug(
|
|
4450
4641
|
"stellar:configResolutionService",
|
|
4451
4642
|
"Native config loader provided but not currently supported for Stellar adapter"
|
|
4452
4643
|
);
|
|
@@ -4459,7 +4650,7 @@ async function resolveFullUiKitConfiguration(programmaticOverrides, initialAppSe
|
|
|
4459
4650
|
...programmaticOverrides.kitConfig || {}
|
|
4460
4651
|
}
|
|
4461
4652
|
};
|
|
4462
|
-
|
|
4653
|
+
import_ui_builder_utils37.logger.debug(
|
|
4463
4654
|
"stellar:configResolutionService:resolveFullUiKitConfiguration",
|
|
4464
4655
|
"Resolved finalFullConfig:",
|
|
4465
4656
|
finalFullConfig
|
|
@@ -4478,7 +4669,7 @@ var StellarAdapter = class {
|
|
|
4478
4669
|
this.networkConfig = networkConfig;
|
|
4479
4670
|
stellarUiKitManager.setNetworkConfig(networkConfig);
|
|
4480
4671
|
getStellarWalletImplementation(networkConfig).catch((error) => {
|
|
4481
|
-
|
|
4672
|
+
import_ui_builder_utils38.logger.error(
|
|
4482
4673
|
"StellarAdapter:constructor",
|
|
4483
4674
|
"Failed to initialize wallet implementation:",
|
|
4484
4675
|
error
|
|
@@ -4486,12 +4677,12 @@ var StellarAdapter = class {
|
|
|
4486
4677
|
});
|
|
4487
4678
|
const initialGlobalConfig = loadInitialConfigFromAppService();
|
|
4488
4679
|
this.initialAppServiceKitName = initialGlobalConfig.kitName || "custom";
|
|
4489
|
-
|
|
4680
|
+
import_ui_builder_utils38.logger.info(
|
|
4490
4681
|
"StellarAdapter:constructor",
|
|
4491
4682
|
"Initial kitName from AppConfigService noted:",
|
|
4492
4683
|
this.initialAppServiceKitName
|
|
4493
4684
|
);
|
|
4494
|
-
|
|
4685
|
+
import_ui_builder_utils38.logger.info(
|
|
4495
4686
|
"StellarAdapter",
|
|
4496
4687
|
`Adapter initialized for network: ${networkConfig.name} (ID: ${networkConfig.id})`
|
|
4497
4688
|
);
|
|
@@ -4638,7 +4829,7 @@ var StellarAdapter = class {
|
|
|
4638
4829
|
onWalletConnectionChange(callback) {
|
|
4639
4830
|
const walletImplementation = getInitializedStellarWalletImplementation();
|
|
4640
4831
|
if (!walletImplementation) {
|
|
4641
|
-
|
|
4832
|
+
import_ui_builder_utils38.logger.warn(
|
|
4642
4833
|
"StellarAdapter:onWalletConnectionChange",
|
|
4643
4834
|
"Wallet implementation not ready. Subscription may not work."
|
|
4644
4835
|
);
|
|
@@ -4700,7 +4891,7 @@ var StellarAdapter = class {
|
|
|
4700
4891
|
options
|
|
4701
4892
|
);
|
|
4702
4893
|
await stellarUiKitManager.configure(finalFullConfig);
|
|
4703
|
-
|
|
4894
|
+
import_ui_builder_utils38.logger.info(
|
|
4704
4895
|
"StellarAdapter:configureUiKit",
|
|
4705
4896
|
"StellarUiKitManager configuration requested with final config:",
|
|
4706
4897
|
finalFullConfig
|
|
@@ -4721,7 +4912,7 @@ var StellarAdapter = class {
|
|
|
4721
4912
|
getEcosystemWalletComponents() {
|
|
4722
4913
|
const currentManagerState = stellarUiKitManager.getState();
|
|
4723
4914
|
if (!currentManagerState.currentFullUiKitConfig) {
|
|
4724
|
-
|
|
4915
|
+
import_ui_builder_utils38.logger.debug(
|
|
4725
4916
|
"StellarAdapter:getEcosystemWalletComponents",
|
|
4726
4917
|
"No UI kit configuration available in manager yet. Returning undefined components."
|
|
4727
4918
|
);
|
|
@@ -4734,7 +4925,7 @@ var StellarAdapter = class {
|
|
|
4734
4925
|
* @inheritdoc
|
|
4735
4926
|
*/
|
|
4736
4927
|
getEcosystemReactUiContextProvider() {
|
|
4737
|
-
|
|
4928
|
+
import_ui_builder_utils38.logger.info(
|
|
4738
4929
|
"StellarAdapter:getEcosystemReactUiContextProvider",
|
|
4739
4930
|
"Returning StellarWalletUiRoot."
|
|
4740
4931
|
);
|
|
@@ -4751,7 +4942,7 @@ var StellarAdapter = class {
|
|
|
4751
4942
|
try {
|
|
4752
4943
|
return await relayerStrategy.getStellarRelayers(serviceUrl, accessToken, this.networkConfig);
|
|
4753
4944
|
} catch (error) {
|
|
4754
|
-
|
|
4945
|
+
import_ui_builder_utils38.logger.error("StellarAdapter", "Failed to fetch Stellar relayers:", error);
|
|
4755
4946
|
return Promise.resolve([]);
|
|
4756
4947
|
}
|
|
4757
4948
|
}
|
|
@@ -4765,7 +4956,7 @@ var StellarAdapter = class {
|
|
|
4765
4956
|
this.networkConfig
|
|
4766
4957
|
);
|
|
4767
4958
|
} catch (error) {
|
|
4768
|
-
|
|
4959
|
+
import_ui_builder_utils38.logger.error("StellarAdapter", "Failed to fetch Stellar relayer details:", error);
|
|
4769
4960
|
return Promise.resolve({});
|
|
4770
4961
|
}
|
|
4771
4962
|
}
|
|
@@ -4815,6 +5006,7 @@ var StellarAdapter = class {
|
|
|
4815
5006
|
};
|
|
4816
5007
|
|
|
4817
5008
|
// src/networks/mainnet.ts
|
|
5009
|
+
var import_react11 = require("@web3icons/react");
|
|
4818
5010
|
var stellarPublic = {
|
|
4819
5011
|
id: "stellar-public",
|
|
4820
5012
|
exportConstName: "stellarPublic",
|
|
@@ -4827,10 +5019,11 @@ var stellarPublic = {
|
|
|
4827
5019
|
sorobanRpcUrl: "https://mainnet.sorobanrpc.com",
|
|
4828
5020
|
networkPassphrase: "Public Global Stellar Network ; September 2015",
|
|
4829
5021
|
explorerUrl: "https://stellar.expert/explorer/public",
|
|
4830
|
-
|
|
5022
|
+
iconComponent: import_react11.NetworkStellar
|
|
4831
5023
|
};
|
|
4832
5024
|
|
|
4833
5025
|
// src/networks/testnet.ts
|
|
5026
|
+
var import_react12 = require("@web3icons/react");
|
|
4834
5027
|
var stellarTestnet = {
|
|
4835
5028
|
id: "stellar-testnet",
|
|
4836
5029
|
exportConstName: "stellarTestnet",
|
|
@@ -4843,7 +5036,7 @@ var stellarTestnet = {
|
|
|
4843
5036
|
sorobanRpcUrl: "https://soroban-testnet.stellar.org",
|
|
4844
5037
|
networkPassphrase: "Test SDF Network ; September 2015",
|
|
4845
5038
|
explorerUrl: "https://stellar.expert/explorer/testnet",
|
|
4846
|
-
|
|
5039
|
+
iconComponent: import_react12.NetworkStellar
|
|
4847
5040
|
};
|
|
4848
5041
|
|
|
4849
5042
|
// src/networks/index.ts
|
|
@@ -4865,6 +5058,10 @@ var stellarAdapterConfig = {
|
|
|
4865
5058
|
runtime: {
|
|
4866
5059
|
// Core Stellar libraries
|
|
4867
5060
|
"@stellar/stellar-sdk": "^14.1.1",
|
|
5061
|
+
// SAC (Stellar Asset Contract) support - dynamically loaded from CDN
|
|
5062
|
+
// These are needed for XDR encoding when working with SAC contracts
|
|
5063
|
+
"@stellar/stellar-xdr-json": "^23.0.0",
|
|
5064
|
+
"lossless-json": "^4.0.2",
|
|
4868
5065
|
// Wallet connection and integration
|
|
4869
5066
|
"@creit.tech/stellar-wallets-kit": "^1.9.5",
|
|
4870
5067
|
// OpenZeppelin Relayer integration (optional, for gasless transactions)
|