@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.js
CHANGED
|
@@ -4,11 +4,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4
4
|
|
|
5
5
|
// src/adapter.ts
|
|
6
6
|
import { isStellarNetworkConfig } from "@openzeppelin/ui-builder-types";
|
|
7
|
-
import { logger as
|
|
7
|
+
import { logger as logger35 } from "@openzeppelin/ui-builder-utils";
|
|
8
8
|
|
|
9
9
|
// src/contract/loader.ts
|
|
10
10
|
import * as StellarSdk2 from "@stellar/stellar-sdk";
|
|
11
|
-
import { logger as
|
|
11
|
+
import { logger as logger15 } from "@openzeppelin/ui-builder-utils";
|
|
12
12
|
|
|
13
13
|
// src/validation/address.ts
|
|
14
14
|
import { StrKey } from "@stellar/stellar-sdk";
|
|
@@ -1461,9 +1461,163 @@ async function queryStellarViewFunction(contractAddress, functionId, networkConf
|
|
|
1461
1461
|
}
|
|
1462
1462
|
}
|
|
1463
1463
|
|
|
1464
|
+
// src/sac/spec-cache.ts
|
|
1465
|
+
import { logger as logger13 } from "@openzeppelin/ui-builder-utils";
|
|
1466
|
+
|
|
1467
|
+
// src/sac/spec-source.ts
|
|
1468
|
+
import { logger as logger11 } from "@openzeppelin/ui-builder-utils";
|
|
1469
|
+
var DEFAULT_SPEC = {
|
|
1470
|
+
repo: "stellar/stellar-asset-contract-spec",
|
|
1471
|
+
path: "refs/heads/main",
|
|
1472
|
+
file: "stellar-asset-spec.json"
|
|
1473
|
+
};
|
|
1474
|
+
function getSacSpecUrl(cfg = {}) {
|
|
1475
|
+
const repo = cfg.repo || DEFAULT_SPEC.repo;
|
|
1476
|
+
const path = cfg.path || DEFAULT_SPEC.path;
|
|
1477
|
+
const file = cfg.file || DEFAULT_SPEC.file;
|
|
1478
|
+
return `https://raw.githubusercontent.com/${repo}/${path}/${file}`;
|
|
1479
|
+
}
|
|
1480
|
+
async function fetchSacSpecJson(cfg = {}) {
|
|
1481
|
+
const url = getSacSpecUrl(cfg);
|
|
1482
|
+
try {
|
|
1483
|
+
const res = await fetch(url);
|
|
1484
|
+
if (!res.ok) {
|
|
1485
|
+
throw new Error(`HTTP ${res.status}`);
|
|
1486
|
+
}
|
|
1487
|
+
return await res.text();
|
|
1488
|
+
} catch (error) {
|
|
1489
|
+
logger11.error("stellar:sac:spec-source", "Failed to fetch SAC spec:", url, error);
|
|
1490
|
+
throw new Error("Failed to load Stellar Asset Contract spec. Please try again later.");
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
// src/sac/xdr.ts
|
|
1495
|
+
import { xdr as xdr8 } from "@stellar/stellar-sdk";
|
|
1496
|
+
import { parse, stringify } from "lossless-json";
|
|
1497
|
+
import stellarXdrJsonPackage from "@stellar/stellar-xdr-json/package.json";
|
|
1498
|
+
import { logger as logger12 } from "@openzeppelin/ui-builder-utils";
|
|
1499
|
+
var stellarXdrJsonVersion = stellarXdrJsonPackage.version ?? "23.0.0";
|
|
1500
|
+
var CDN_WASM_URL = `https://unpkg.com/@stellar/stellar-xdr-json@${stellarXdrJsonVersion}/stellar_xdr_json_bg.wasm`;
|
|
1501
|
+
var initialized = false;
|
|
1502
|
+
var encode = null;
|
|
1503
|
+
async function ensureXdrJsonInitialized() {
|
|
1504
|
+
if (initialized) return;
|
|
1505
|
+
try {
|
|
1506
|
+
const stellarXdrJson = await import("@stellar/stellar-xdr-json");
|
|
1507
|
+
const init = stellarXdrJson.default;
|
|
1508
|
+
await init(CDN_WASM_URL);
|
|
1509
|
+
encode = stellarXdrJson.encode;
|
|
1510
|
+
initialized = true;
|
|
1511
|
+
} catch (error) {
|
|
1512
|
+
logger12.error("stellar:sac:xdr", "Failed to initialize WASM module:", error);
|
|
1513
|
+
throw error;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
async function encodeSacSpecEntries(jsonString) {
|
|
1517
|
+
await ensureXdrJsonInitialized();
|
|
1518
|
+
if (!encode) {
|
|
1519
|
+
throw new Error("WASM module not properly initialized");
|
|
1520
|
+
}
|
|
1521
|
+
try {
|
|
1522
|
+
const jsonData = parse(jsonString);
|
|
1523
|
+
const result = [];
|
|
1524
|
+
for (const entry of jsonData) {
|
|
1525
|
+
const stringified = stringify(entry);
|
|
1526
|
+
if (!stringified) {
|
|
1527
|
+
throw new Error("Failed to stringify SAC spec entry before XDR encoding.");
|
|
1528
|
+
}
|
|
1529
|
+
const encoded = encode("ScSpecEntry", stringified);
|
|
1530
|
+
result.push(encoded);
|
|
1531
|
+
}
|
|
1532
|
+
return result;
|
|
1533
|
+
} catch (error) {
|
|
1534
|
+
logger12.error("stellar:sac:xdr", "Failed to encode SAC spec to XDR", error);
|
|
1535
|
+
throw new Error("Failed to process SAC spec.");
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
function toScSpecEntries(base64Entries) {
|
|
1539
|
+
return base64Entries.map((b64) => xdr8.ScSpecEntry.fromXDR(b64, "base64"));
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
// src/sac/spec-cache.ts
|
|
1543
|
+
var sacSpecCache = /* @__PURE__ */ new Map();
|
|
1544
|
+
var sacSpecInflight = /* @__PURE__ */ new Map();
|
|
1545
|
+
async function getSacSpecArtifacts(cfg = {}) {
|
|
1546
|
+
const cacheKey = getSacSpecUrl(cfg);
|
|
1547
|
+
const cached = sacSpecCache.get(cacheKey);
|
|
1548
|
+
if (cached) {
|
|
1549
|
+
logger13.debug("stellar:sac:spec-cache", "Returning cached SAC spec artifacts");
|
|
1550
|
+
return cached;
|
|
1551
|
+
}
|
|
1552
|
+
const inflight = sacSpecInflight.get(cacheKey);
|
|
1553
|
+
if (inflight) {
|
|
1554
|
+
return inflight;
|
|
1555
|
+
}
|
|
1556
|
+
const promise = (async () => {
|
|
1557
|
+
const json = await fetchSacSpecJson(cfg);
|
|
1558
|
+
const base64Entries = await encodeSacSpecEntries(json);
|
|
1559
|
+
const specEntries = toScSpecEntries(base64Entries);
|
|
1560
|
+
const entry = {
|
|
1561
|
+
base64Entries,
|
|
1562
|
+
specEntries
|
|
1563
|
+
};
|
|
1564
|
+
sacSpecCache.set(cacheKey, entry);
|
|
1565
|
+
sacSpecInflight.delete(cacheKey);
|
|
1566
|
+
logger13.debug("stellar:sac:spec-cache", "Cached SAC spec artifacts for future re-use");
|
|
1567
|
+
return entry;
|
|
1568
|
+
})().catch((error) => {
|
|
1569
|
+
sacSpecInflight.delete(cacheKey);
|
|
1570
|
+
throw error;
|
|
1571
|
+
});
|
|
1572
|
+
sacSpecInflight.set(cacheKey, promise);
|
|
1573
|
+
return promise;
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
// src/contract/type.ts
|
|
1577
|
+
import { Contract as Contract2, rpc as StellarRpc2, xdr as xdr9 } from "@stellar/stellar-sdk";
|
|
1578
|
+
import { logger as logger14, userRpcConfigService as userRpcConfigService2 } from "@openzeppelin/ui-builder-utils";
|
|
1579
|
+
function getSorobanRpcServer2(networkConfig) {
|
|
1580
|
+
const customRpcConfig = userRpcConfigService2.getUserRpcConfig(networkConfig.id);
|
|
1581
|
+
const rpcUrl = customRpcConfig?.url || networkConfig.sorobanRpcUrl;
|
|
1582
|
+
if (!rpcUrl) {
|
|
1583
|
+
throw new Error(`No Soroban RPC URL available for network ${networkConfig.name}`);
|
|
1584
|
+
}
|
|
1585
|
+
const allowHttp = new URL(rpcUrl).hostname === "localhost";
|
|
1586
|
+
return new StellarRpc2.Server(rpcUrl, { allowHttp });
|
|
1587
|
+
}
|
|
1588
|
+
async function getStellarContractType(contractId, networkConfig) {
|
|
1589
|
+
try {
|
|
1590
|
+
if (!contractId) {
|
|
1591
|
+
return null;
|
|
1592
|
+
}
|
|
1593
|
+
const rpcServer = getSorobanRpcServer2(networkConfig);
|
|
1594
|
+
const ledgerKey = new Contract2(contractId).getFootprint();
|
|
1595
|
+
const ledgerEntries = await rpcServer.getLedgerEntries(ledgerKey);
|
|
1596
|
+
const first = ledgerEntries?.entries?.[0]?.val;
|
|
1597
|
+
if (!first) {
|
|
1598
|
+
throw new Error("Could not obtain contract data from server.");
|
|
1599
|
+
}
|
|
1600
|
+
const executable = first.contractData()?.val()?.instance()?.executable();
|
|
1601
|
+
if (!executable) {
|
|
1602
|
+
throw new Error("Could not get executable from contract data.");
|
|
1603
|
+
}
|
|
1604
|
+
const execWasmType = xdr9.ContractExecutableType.contractExecutableWasm().name;
|
|
1605
|
+
const execStellarAssetType = xdr9.ContractExecutableType.contractExecutableStellarAsset().name;
|
|
1606
|
+
const detected = executable.switch()?.name;
|
|
1607
|
+
if (detected === execWasmType) return "contractExecutableWasm";
|
|
1608
|
+
if (detected === execStellarAssetType) return "contractExecutableStellarAsset";
|
|
1609
|
+
return null;
|
|
1610
|
+
} catch (error) {
|
|
1611
|
+
logger14.error("stellar:contract-type", "Failed to detect contract type:", error);
|
|
1612
|
+
throw new Error(
|
|
1613
|
+
`Something went wrong getting contract type by contract ID. ${error.message}`
|
|
1614
|
+
);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1464
1618
|
// src/contract/loader.ts
|
|
1465
1619
|
async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
1466
|
-
|
|
1620
|
+
logger15.info("loadStellarContractFromAddress", "Loading contract:", {
|
|
1467
1621
|
contractAddress,
|
|
1468
1622
|
network: networkConfig.name,
|
|
1469
1623
|
rpcUrl: networkConfig.sorobanRpcUrl,
|
|
@@ -1473,6 +1627,33 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1473
1627
|
if (!StellarSdk2.StrKey.isValidContract(contractAddress)) {
|
|
1474
1628
|
throw new Error(`Invalid contract address: ${contractAddress}`);
|
|
1475
1629
|
}
|
|
1630
|
+
try {
|
|
1631
|
+
const execType = await getStellarContractType(contractAddress, networkConfig);
|
|
1632
|
+
if (execType === "contractExecutableStellarAsset") {
|
|
1633
|
+
const { base64Entries, specEntries: specEntries2 } = await getSacSpecArtifacts();
|
|
1634
|
+
const spec = new StellarSdk2.contract.Spec(base64Entries);
|
|
1635
|
+
const functions2 = await extractFunctionsFromSpec(
|
|
1636
|
+
spec,
|
|
1637
|
+
contractAddress,
|
|
1638
|
+
specEntries2,
|
|
1639
|
+
networkConfig
|
|
1640
|
+
);
|
|
1641
|
+
return {
|
|
1642
|
+
name: `Stellar Asset Contract ${contractAddress.slice(0, 8)}...`,
|
|
1643
|
+
ecosystem: "stellar",
|
|
1644
|
+
functions: functions2,
|
|
1645
|
+
metadata: {
|
|
1646
|
+
specEntries: specEntries2
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
} catch (e) {
|
|
1651
|
+
logger15.warn(
|
|
1652
|
+
"loadStellarContractFromAddress",
|
|
1653
|
+
"SAC detection failed, falling back to regular client:",
|
|
1654
|
+
e
|
|
1655
|
+
);
|
|
1656
|
+
}
|
|
1476
1657
|
let contractClient;
|
|
1477
1658
|
try {
|
|
1478
1659
|
contractClient = await StellarSdk2.contract.Client.from({
|
|
@@ -1484,12 +1665,12 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1484
1665
|
const message = e?.message || String(e);
|
|
1485
1666
|
if (message.includes("Cannot destructure property 'length'")) {
|
|
1486
1667
|
const friendly = "Unable to fetch contract metadata from RPC. The contract appears to have no published Wasm/definition on this network.";
|
|
1487
|
-
|
|
1668
|
+
logger15.error("loadStellarContractFromAddress", friendly);
|
|
1488
1669
|
throw new Error(`NO_WASM: ${friendly}`);
|
|
1489
1670
|
}
|
|
1490
1671
|
throw e;
|
|
1491
1672
|
}
|
|
1492
|
-
|
|
1673
|
+
logger15.info("loadStellarContractFromAddress", "Contract client created successfully");
|
|
1493
1674
|
let specEntries = [];
|
|
1494
1675
|
try {
|
|
1495
1676
|
if (contractClient.spec && typeof contractClient.spec === "object") {
|
|
@@ -1504,20 +1685,20 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1504
1685
|
try {
|
|
1505
1686
|
specEntries = spec.entries();
|
|
1506
1687
|
} catch (e) {
|
|
1507
|
-
|
|
1688
|
+
logger15.warn("loadStellarContractFromAddress", "entries() method failed:", e);
|
|
1508
1689
|
}
|
|
1509
1690
|
}
|
|
1510
1691
|
if (specEntries.length === 0 && typeof spec.entries === "function") {
|
|
1511
1692
|
try {
|
|
1512
1693
|
specEntries = spec.entries();
|
|
1513
1694
|
} catch (e) {
|
|
1514
|
-
|
|
1695
|
+
logger15.warn("loadStellarContractFromAddress", "direct entries() method failed:", e);
|
|
1515
1696
|
}
|
|
1516
1697
|
}
|
|
1517
|
-
|
|
1698
|
+
logger15.info("loadStellarContractFromAddress", `Found ${specEntries.length} spec entries`);
|
|
1518
1699
|
}
|
|
1519
1700
|
} catch (specError) {
|
|
1520
|
-
|
|
1701
|
+
logger15.warn("loadStellarContractFromAddress", "Could not extract spec entries:", specError);
|
|
1521
1702
|
}
|
|
1522
1703
|
const functions = await extractFunctionsFromSpec(
|
|
1523
1704
|
contractClient.spec,
|
|
@@ -1525,7 +1706,7 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1525
1706
|
specEntries,
|
|
1526
1707
|
networkConfig
|
|
1527
1708
|
);
|
|
1528
|
-
|
|
1709
|
+
logger15.info(
|
|
1529
1710
|
"loadStellarContractFromAddress",
|
|
1530
1711
|
`Successfully extracted ${functions.length} functions`
|
|
1531
1712
|
);
|
|
@@ -1540,28 +1721,28 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1540
1721
|
} catch (error) {
|
|
1541
1722
|
const msg = error?.message || String(error);
|
|
1542
1723
|
if (msg.startsWith("NO_WASM:")) {
|
|
1543
|
-
|
|
1724
|
+
logger15.error("loadStellarContractFromAddress", msg);
|
|
1544
1725
|
throw new Error(msg);
|
|
1545
1726
|
}
|
|
1546
|
-
|
|
1727
|
+
logger15.error("loadStellarContractFromAddress", "Failed to load contract:", error);
|
|
1547
1728
|
throw new Error(`Failed to load contract: ${msg}`);
|
|
1548
1729
|
}
|
|
1549
1730
|
}
|
|
1550
1731
|
async function extractFunctionsFromSpec(spec, contractAddress, specEntries, networkConfig) {
|
|
1551
1732
|
try {
|
|
1552
1733
|
const specFunctions = spec.funcs();
|
|
1553
|
-
|
|
1734
|
+
logger15.info("extractFunctionsFromSpec", `Found ${specFunctions.length} functions in spec`);
|
|
1554
1735
|
return await Promise.all(
|
|
1555
1736
|
specFunctions.map(async (func, index) => {
|
|
1556
1737
|
try {
|
|
1557
1738
|
const functionName = func.name().toString();
|
|
1558
|
-
|
|
1739
|
+
logger15.info("extractFunctionsFromSpec", `Processing function: ${functionName}`);
|
|
1559
1740
|
const inputs = func.inputs().map((input, inputIndex) => {
|
|
1560
1741
|
try {
|
|
1561
1742
|
const inputName = input.name().toString();
|
|
1562
1743
|
const inputType = extractSorobanTypeFromScSpec(input.type());
|
|
1563
1744
|
if (inputType === "unknown") {
|
|
1564
|
-
|
|
1745
|
+
logger15.warn(
|
|
1565
1746
|
"extractFunctionsFromSpec",
|
|
1566
1747
|
`Unknown type for parameter "${inputName}" in function "${functionName}"`
|
|
1567
1748
|
);
|
|
@@ -1571,12 +1752,12 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1571
1752
|
const structFields = extractStructFields(specEntries, inputType);
|
|
1572
1753
|
if (structFields && structFields.length > 0) {
|
|
1573
1754
|
components = structFields;
|
|
1574
|
-
|
|
1755
|
+
logger15.debug(
|
|
1575
1756
|
"extractFunctionsFromSpec",
|
|
1576
1757
|
`Extracted ${structFields.length} fields for struct type "${inputType}": ${structFields.map((f) => `${f.name}:${f.type}`).join(", ")}`
|
|
1577
1758
|
);
|
|
1578
1759
|
} else {
|
|
1579
|
-
|
|
1760
|
+
logger15.warn(
|
|
1580
1761
|
"extractFunctionsFromSpec",
|
|
1581
1762
|
`No fields extracted for struct "${inputType}"`
|
|
1582
1763
|
);
|
|
@@ -1588,7 +1769,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1588
1769
|
...components && { components }
|
|
1589
1770
|
};
|
|
1590
1771
|
} catch (error) {
|
|
1591
|
-
|
|
1772
|
+
logger15.warn(
|
|
1592
1773
|
"extractFunctionsFromSpec",
|
|
1593
1774
|
`Failed to parse input ${inputIndex}:`,
|
|
1594
1775
|
error
|
|
@@ -1607,7 +1788,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1607
1788
|
type: outputType
|
|
1608
1789
|
};
|
|
1609
1790
|
} catch (error) {
|
|
1610
|
-
|
|
1791
|
+
logger15.warn(
|
|
1611
1792
|
"extractFunctionsFromSpec",
|
|
1612
1793
|
`Failed to parse output ${outputIndex}:`,
|
|
1613
1794
|
error
|
|
@@ -1623,7 +1804,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1623
1804
|
if (networkConfig) {
|
|
1624
1805
|
try {
|
|
1625
1806
|
const inputTypes = inputs.map((input) => input.type);
|
|
1626
|
-
|
|
1807
|
+
logger15.debug(
|
|
1627
1808
|
"extractFunctionsFromSpec",
|
|
1628
1809
|
`Checking state mutability for ${functionName} with input types: ${inputTypes.join(", ")}`
|
|
1629
1810
|
);
|
|
@@ -1634,20 +1815,20 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1634
1815
|
inputTypes
|
|
1635
1816
|
);
|
|
1636
1817
|
stateMutability = modifiesState ? "nonpayable" : "view";
|
|
1637
|
-
|
|
1818
|
+
logger15.info(
|
|
1638
1819
|
"extractFunctionsFromSpec",
|
|
1639
1820
|
`Function ${functionName} state mutability determined:`,
|
|
1640
1821
|
{ modifiesState, stateMutability }
|
|
1641
1822
|
);
|
|
1642
1823
|
} catch (error) {
|
|
1643
|
-
|
|
1824
|
+
logger15.warn(
|
|
1644
1825
|
"extractFunctionsFromSpec",
|
|
1645
1826
|
`Failed to determine state mutability for ${functionName}, assuming it modifies state:`,
|
|
1646
1827
|
error
|
|
1647
1828
|
);
|
|
1648
1829
|
}
|
|
1649
1830
|
} else {
|
|
1650
|
-
|
|
1831
|
+
logger15.warn(
|
|
1651
1832
|
"extractFunctionsFromSpec",
|
|
1652
1833
|
`No network config provided for ${functionName}, assuming it modifies state`
|
|
1653
1834
|
);
|
|
@@ -1665,7 +1846,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1665
1846
|
stateMutability
|
|
1666
1847
|
};
|
|
1667
1848
|
} catch (error) {
|
|
1668
|
-
|
|
1849
|
+
logger15.error("extractFunctionsFromSpec", `Failed to process function ${index}:`, error);
|
|
1669
1850
|
return {
|
|
1670
1851
|
id: `function_${index}`,
|
|
1671
1852
|
name: `function_${index}`,
|
|
@@ -1681,7 +1862,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1681
1862
|
})
|
|
1682
1863
|
);
|
|
1683
1864
|
} catch (error) {
|
|
1684
|
-
|
|
1865
|
+
logger15.error("extractFunctionsFromSpec", "Failed to extract functions from spec:", error);
|
|
1685
1866
|
throw new Error(`Failed to extract functions: ${error.message}`);
|
|
1686
1867
|
}
|
|
1687
1868
|
}
|
|
@@ -1981,21 +2162,21 @@ var StellarRelayerOptions = ({ options, onChange }) => {
|
|
|
1981
2162
|
import {
|
|
1982
2163
|
Account as Account2,
|
|
1983
2164
|
BASE_FEE as BASE_FEE2,
|
|
1984
|
-
Contract as
|
|
1985
|
-
rpc as
|
|
2165
|
+
Contract as Contract3,
|
|
2166
|
+
rpc as StellarRpc3,
|
|
1986
2167
|
TransactionBuilder as TransactionBuilder2
|
|
1987
2168
|
} from "@stellar/stellar-sdk";
|
|
1988
2169
|
import {
|
|
1989
2170
|
Configuration,
|
|
1990
2171
|
RelayersApi
|
|
1991
2172
|
} from "@openzeppelin/relayer-sdk";
|
|
1992
|
-
import { logger as
|
|
2173
|
+
import { logger as logger21 } from "@openzeppelin/ui-builder-utils";
|
|
1993
2174
|
|
|
1994
2175
|
// src/wallet/connection.ts
|
|
1995
|
-
import { logger as
|
|
2176
|
+
import { logger as logger20 } from "@openzeppelin/ui-builder-utils";
|
|
1996
2177
|
|
|
1997
2178
|
// src/wallet/utils/stellarWalletImplementationManager.ts
|
|
1998
|
-
import { appConfigService, logger as
|
|
2179
|
+
import { appConfigService, logger as logger17 } from "@openzeppelin/ui-builder-utils";
|
|
1999
2180
|
|
|
2000
2181
|
// src/wallet/implementation/wallets-kit-implementation.ts
|
|
2001
2182
|
import {
|
|
@@ -2003,7 +2184,7 @@ import {
|
|
|
2003
2184
|
StellarWalletsKit,
|
|
2004
2185
|
WalletNetwork
|
|
2005
2186
|
} from "@creit.tech/stellar-wallets-kit";
|
|
2006
|
-
import { logger as
|
|
2187
|
+
import { logger as logger16 } from "@openzeppelin/ui-builder-utils";
|
|
2007
2188
|
var LOG_SYSTEM = "StellarWalletImplementation";
|
|
2008
2189
|
var WalletsKitImplementation = class {
|
|
2009
2190
|
/**
|
|
@@ -2024,7 +2205,7 @@ var WalletsKitImplementation = class {
|
|
|
2024
2205
|
__publicField(this, "currentWalletId", null);
|
|
2025
2206
|
__publicField(this, "connectionStatusListeners", /* @__PURE__ */ new Set());
|
|
2026
2207
|
this.networkConfig = networkConfig || null;
|
|
2027
|
-
|
|
2208
|
+
logger16.info(
|
|
2028
2209
|
LOG_SYSTEM,
|
|
2029
2210
|
"Constructor called. Initial anticipated kitName:",
|
|
2030
2211
|
initialUiKitConfig?.kitName,
|
|
@@ -2032,7 +2213,7 @@ var WalletsKitImplementation = class {
|
|
|
2032
2213
|
networkConfig?.name
|
|
2033
2214
|
);
|
|
2034
2215
|
this.initialized = true;
|
|
2035
|
-
|
|
2216
|
+
logger16.info(
|
|
2036
2217
|
LOG_SYSTEM,
|
|
2037
2218
|
"StellarWalletImplementation instance initialized (StellarWalletsKit config creation deferred)."
|
|
2038
2219
|
);
|
|
@@ -2042,10 +2223,10 @@ var WalletsKitImplementation = class {
|
|
|
2042
2223
|
* @param config - The Stellar network configuration
|
|
2043
2224
|
*/
|
|
2044
2225
|
setNetworkConfig(config) {
|
|
2045
|
-
|
|
2226
|
+
logger16.info(LOG_SYSTEM, "Network config updated:", config.name);
|
|
2046
2227
|
this.networkConfig = config;
|
|
2047
2228
|
if (this.activeStellarKit || this.defaultInstanceKit) {
|
|
2048
|
-
|
|
2229
|
+
logger16.info(LOG_SYSTEM, "Active kits detected - may need reconfiguration for new network");
|
|
2049
2230
|
}
|
|
2050
2231
|
}
|
|
2051
2232
|
/**
|
|
@@ -2055,14 +2236,14 @@ var WalletsKitImplementation = class {
|
|
|
2055
2236
|
* @param kit - The StellarWalletsKit object to set as active, or null to clear it.
|
|
2056
2237
|
*/
|
|
2057
2238
|
setActiveStellarKit(kit) {
|
|
2058
|
-
|
|
2239
|
+
logger16.info(
|
|
2059
2240
|
LOG_SYSTEM,
|
|
2060
2241
|
"setActiveStellarKit called with kit:",
|
|
2061
2242
|
kit ? "Valid StellarWalletsKit" : "Null"
|
|
2062
2243
|
);
|
|
2063
2244
|
this.activeStellarKit = kit;
|
|
2064
2245
|
if (this.unsubscribeFromStatusChanges) {
|
|
2065
|
-
|
|
2246
|
+
logger16.info(LOG_SYSTEM, "Re-establishing connection status monitoring with new kit");
|
|
2066
2247
|
}
|
|
2067
2248
|
}
|
|
2068
2249
|
/**
|
|
@@ -2071,14 +2252,14 @@ var WalletsKitImplementation = class {
|
|
|
2071
2252
|
* @returns A default StellarWalletsKit instance
|
|
2072
2253
|
*/
|
|
2073
2254
|
createDefaultKit() {
|
|
2074
|
-
|
|
2255
|
+
logger16.info(LOG_SYSTEM, "Creating default StellarWalletsKit instance");
|
|
2075
2256
|
const network = this.getWalletNetwork();
|
|
2076
2257
|
const kit = new StellarWalletsKit({
|
|
2077
2258
|
network,
|
|
2078
2259
|
selectedWalletId: void 0,
|
|
2079
2260
|
modules: allowAllModules()
|
|
2080
2261
|
});
|
|
2081
|
-
|
|
2262
|
+
logger16.info(LOG_SYSTEM, "Default StellarWalletsKit instance created");
|
|
2082
2263
|
return kit;
|
|
2083
2264
|
}
|
|
2084
2265
|
/**
|
|
@@ -2086,7 +2267,7 @@ var WalletsKitImplementation = class {
|
|
|
2086
2267
|
*/
|
|
2087
2268
|
getWalletNetwork() {
|
|
2088
2269
|
if (!this.networkConfig) {
|
|
2089
|
-
|
|
2270
|
+
logger16.warn(LOG_SYSTEM, "No network config available, defaulting to TESTNET");
|
|
2090
2271
|
return WalletNetwork.TESTNET;
|
|
2091
2272
|
}
|
|
2092
2273
|
return this.networkConfig.type === "mainnet" ? WalletNetwork.PUBLIC : WalletNetwork.TESTNET;
|
|
@@ -2104,7 +2285,7 @@ var WalletsKitImplementation = class {
|
|
|
2104
2285
|
*/
|
|
2105
2286
|
async getAvailableConnectors() {
|
|
2106
2287
|
if (!this.initialized) {
|
|
2107
|
-
|
|
2288
|
+
logger16.warn(LOG_SYSTEM, "getAvailableConnectors called before initialization");
|
|
2108
2289
|
return [];
|
|
2109
2290
|
}
|
|
2110
2291
|
try {
|
|
@@ -2117,10 +2298,10 @@ var WalletsKitImplementation = class {
|
|
|
2117
2298
|
installed: wallet.isAvailable,
|
|
2118
2299
|
type: wallet.type || "browser"
|
|
2119
2300
|
}));
|
|
2120
|
-
|
|
2301
|
+
logger16.info(LOG_SYSTEM, `Found ${connectors.length} available wallet connectors`);
|
|
2121
2302
|
return connectors;
|
|
2122
2303
|
} catch (error) {
|
|
2123
|
-
|
|
2304
|
+
logger16.error(LOG_SYSTEM, "Failed to get available connectors:", error);
|
|
2124
2305
|
return [];
|
|
2125
2306
|
}
|
|
2126
2307
|
}
|
|
@@ -2136,7 +2317,7 @@ var WalletsKitImplementation = class {
|
|
|
2136
2317
|
try {
|
|
2137
2318
|
const prevStatus = this.getWalletConnectionStatus();
|
|
2138
2319
|
const kit = this.getKitToUse();
|
|
2139
|
-
|
|
2320
|
+
logger16.info(LOG_SYSTEM, `Attempting to connect to wallet: ${connectorId}`);
|
|
2140
2321
|
kit.setWallet(connectorId);
|
|
2141
2322
|
const result = await kit.getAddress();
|
|
2142
2323
|
if (result.address) {
|
|
@@ -2144,7 +2325,7 @@ var WalletsKitImplementation = class {
|
|
|
2144
2325
|
this.currentWalletId = connectorId;
|
|
2145
2326
|
const newStatus = this.getWalletConnectionStatus();
|
|
2146
2327
|
this.notifyConnectionListeners(newStatus, prevStatus);
|
|
2147
|
-
|
|
2328
|
+
logger16.info(
|
|
2148
2329
|
LOG_SYSTEM,
|
|
2149
2330
|
`Successfully connected to wallet: ${connectorId}, address: ${result.address}`
|
|
2150
2331
|
);
|
|
@@ -2160,7 +2341,7 @@ var WalletsKitImplementation = class {
|
|
|
2160
2341
|
};
|
|
2161
2342
|
}
|
|
2162
2343
|
} catch (error) {
|
|
2163
|
-
|
|
2344
|
+
logger16.error(LOG_SYSTEM, `Failed to connect to wallet ${connectorId}:`, error);
|
|
2164
2345
|
return {
|
|
2165
2346
|
connected: false,
|
|
2166
2347
|
error: error instanceof Error ? error.message : "Unknown error occurred"
|
|
@@ -2177,15 +2358,15 @@ var WalletsKitImplementation = class {
|
|
|
2177
2358
|
}
|
|
2178
2359
|
try {
|
|
2179
2360
|
const prevStatus = this.getWalletConnectionStatus();
|
|
2180
|
-
|
|
2361
|
+
logger16.info(LOG_SYSTEM, "Disconnecting wallet");
|
|
2181
2362
|
this.currentAddress = null;
|
|
2182
2363
|
this.currentWalletId = null;
|
|
2183
2364
|
const newStatus = this.getWalletConnectionStatus();
|
|
2184
2365
|
this.notifyConnectionListeners(newStatus, prevStatus);
|
|
2185
|
-
|
|
2366
|
+
logger16.info(LOG_SYSTEM, "Successfully disconnected wallet");
|
|
2186
2367
|
return { disconnected: true };
|
|
2187
2368
|
} catch (error) {
|
|
2188
|
-
|
|
2369
|
+
logger16.error(LOG_SYSTEM, "Failed to disconnect wallet:", error);
|
|
2189
2370
|
return {
|
|
2190
2371
|
disconnected: false,
|
|
2191
2372
|
error: error instanceof Error ? error.message : "Unknown error occurred"
|
|
@@ -2218,15 +2399,15 @@ var WalletsKitImplementation = class {
|
|
|
2218
2399
|
*/
|
|
2219
2400
|
onWalletConnectionChange(callback) {
|
|
2220
2401
|
if (!this.initialized) {
|
|
2221
|
-
|
|
2402
|
+
logger16.warn(LOG_SYSTEM, "onWalletConnectionChange called before initialization. No-op.");
|
|
2222
2403
|
return () => {
|
|
2223
2404
|
};
|
|
2224
2405
|
}
|
|
2225
2406
|
this.connectionStatusListeners.add(callback);
|
|
2226
|
-
|
|
2407
|
+
logger16.info(LOG_SYSTEM, "Connection status listener added");
|
|
2227
2408
|
return () => {
|
|
2228
2409
|
this.connectionStatusListeners.delete(callback);
|
|
2229
|
-
|
|
2410
|
+
logger16.debug(LOG_SYSTEM, "Connection status listener removed");
|
|
2230
2411
|
};
|
|
2231
2412
|
}
|
|
2232
2413
|
/**
|
|
@@ -2255,14 +2436,14 @@ var WalletsKitImplementation = class {
|
|
|
2255
2436
|
* @param address - The account address
|
|
2256
2437
|
* @returns Promise resolving to signed transaction
|
|
2257
2438
|
*/
|
|
2258
|
-
async signTransaction(
|
|
2439
|
+
async signTransaction(xdr13, address) {
|
|
2259
2440
|
if (!this.initialized) {
|
|
2260
2441
|
throw new Error("Wallet implementation not initialized");
|
|
2261
2442
|
}
|
|
2262
2443
|
const kit = this.getKitToUse();
|
|
2263
2444
|
const networkPassphrase = this.getWalletNetwork();
|
|
2264
|
-
|
|
2265
|
-
return await kit.signTransaction(
|
|
2445
|
+
logger16.info(LOG_SYSTEM, "Signing transaction with wallet");
|
|
2446
|
+
return await kit.signTransaction(xdr13, {
|
|
2266
2447
|
address,
|
|
2267
2448
|
networkPassphrase
|
|
2268
2449
|
});
|
|
@@ -2275,7 +2456,7 @@ var WalletsKitImplementation = class {
|
|
|
2275
2456
|
try {
|
|
2276
2457
|
listener(currentStatus, previousStatus);
|
|
2277
2458
|
} catch (error) {
|
|
2278
|
-
|
|
2459
|
+
logger16.error(LOG_SYSTEM, "Error in connection status listener:", String(error));
|
|
2279
2460
|
}
|
|
2280
2461
|
});
|
|
2281
2462
|
}
|
|
@@ -2288,7 +2469,7 @@ var WalletsKitImplementation = class {
|
|
|
2288
2469
|
this.unsubscribeFromStatusChanges = void 0;
|
|
2289
2470
|
}
|
|
2290
2471
|
this.connectionStatusListeners.clear();
|
|
2291
|
-
|
|
2472
|
+
logger16.info(LOG_SYSTEM, "Cleanup completed");
|
|
2292
2473
|
}
|
|
2293
2474
|
};
|
|
2294
2475
|
|
|
@@ -2312,17 +2493,17 @@ async function getStellarWalletImplementation(networkConfig) {
|
|
|
2312
2493
|
}
|
|
2313
2494
|
walletImplementationPromise = (async () => {
|
|
2314
2495
|
try {
|
|
2315
|
-
|
|
2496
|
+
logger17.info(LOG_SYSTEM2, "Initializing StellarWalletImplementation singleton (async)...");
|
|
2316
2497
|
const initialUiKitConfig = appConfigService.getTypedNestedConfig(
|
|
2317
2498
|
"walletui",
|
|
2318
2499
|
"config"
|
|
2319
2500
|
);
|
|
2320
2501
|
const instance = new WalletsKitImplementation(networkConfig, initialUiKitConfig);
|
|
2321
|
-
|
|
2502
|
+
logger17.info(LOG_SYSTEM2, "WalletsKitImplementation singleton created (async).");
|
|
2322
2503
|
walletImplementationInstance = instance;
|
|
2323
2504
|
return instance;
|
|
2324
2505
|
} catch (error) {
|
|
2325
|
-
|
|
2506
|
+
logger17.error(LOG_SYSTEM2, "Failed to initialize WalletsKitImplementation (async):", error);
|
|
2326
2507
|
const fallbackInstance = new WalletsKitImplementation(networkConfig);
|
|
2327
2508
|
walletImplementationInstance = fallbackInstance;
|
|
2328
2509
|
return fallbackInstance;
|
|
@@ -2332,7 +2513,7 @@ async function getStellarWalletImplementation(networkConfig) {
|
|
|
2332
2513
|
}
|
|
2333
2514
|
function getInitializedStellarWalletImplementation() {
|
|
2334
2515
|
if (!walletImplementationInstance) {
|
|
2335
|
-
|
|
2516
|
+
logger17.warn(
|
|
2336
2517
|
LOG_SYSTEM2,
|
|
2337
2518
|
"getInitializedStellarWalletImplementation called before instance was ready."
|
|
2338
2519
|
);
|
|
@@ -2342,7 +2523,7 @@ function getInitializedStellarWalletImplementation() {
|
|
|
2342
2523
|
|
|
2343
2524
|
// src/wallet/stellar-wallets-kit/stellarUiKitManager.ts
|
|
2344
2525
|
import { allowAllModules as allowAllModules2, StellarWalletsKit as StellarWalletsKit2, WalletNetwork as WalletNetwork2 } from "@creit.tech/stellar-wallets-kit";
|
|
2345
|
-
import { logger as
|
|
2526
|
+
import { logger as logger18 } from "@openzeppelin/ui-builder-utils";
|
|
2346
2527
|
var getInitialState = () => ({
|
|
2347
2528
|
isConfigured: false,
|
|
2348
2529
|
isInitializing: false,
|
|
@@ -2379,13 +2560,13 @@ function setNetworkConfig(config) {
|
|
|
2379
2560
|
}
|
|
2380
2561
|
function getWalletNetwork(networkConfig) {
|
|
2381
2562
|
if (!networkConfig) {
|
|
2382
|
-
|
|
2563
|
+
logger18.warn("StellarUiKitManager", "No network config available, defaulting to TESTNET");
|
|
2383
2564
|
return WalletNetwork2.TESTNET;
|
|
2384
2565
|
}
|
|
2385
2566
|
return networkConfig.type === "mainnet" ? WalletNetwork2.PUBLIC : WalletNetwork2.TESTNET;
|
|
2386
2567
|
}
|
|
2387
2568
|
async function configure(newFullUiKitConfig) {
|
|
2388
|
-
|
|
2569
|
+
logger18.info(
|
|
2389
2570
|
"StellarUiKitManager:configure",
|
|
2390
2571
|
"Configuring UI kit. New config:",
|
|
2391
2572
|
newFullUiKitConfig
|
|
@@ -2415,7 +2596,7 @@ async function configure(newFullUiKitConfig) {
|
|
|
2415
2596
|
state.kitProviderComponent = null;
|
|
2416
2597
|
state.isKitAssetsLoaded = true;
|
|
2417
2598
|
state.error = null;
|
|
2418
|
-
|
|
2599
|
+
logger18.info(
|
|
2419
2600
|
"StellarUiKitManager:configure",
|
|
2420
2601
|
"Stellar Wallets Kit configured with built-in UI and all wallet modules"
|
|
2421
2602
|
);
|
|
@@ -2429,7 +2610,7 @@ async function configure(newFullUiKitConfig) {
|
|
|
2429
2610
|
state.kitProviderComponent = null;
|
|
2430
2611
|
state.isKitAssetsLoaded = true;
|
|
2431
2612
|
state.error = null;
|
|
2432
|
-
|
|
2613
|
+
logger18.info(
|
|
2433
2614
|
"StellarUiKitManager:configure",
|
|
2434
2615
|
"Stellar Wallets Kit configured for custom UI components"
|
|
2435
2616
|
);
|
|
@@ -2438,7 +2619,7 @@ async function configure(newFullUiKitConfig) {
|
|
|
2438
2619
|
state.kitProviderComponent = null;
|
|
2439
2620
|
state.isKitAssetsLoaded = false;
|
|
2440
2621
|
state.error = null;
|
|
2441
|
-
|
|
2622
|
+
logger18.info("StellarUiKitManager:configure", 'UI kit set to "none", no wallet UI provided');
|
|
2442
2623
|
} else {
|
|
2443
2624
|
throw new Error(`Unknown UI kit name: ${newKitName}`);
|
|
2444
2625
|
}
|
|
@@ -2451,7 +2632,7 @@ async function configure(newFullUiKitConfig) {
|
|
|
2451
2632
|
};
|
|
2452
2633
|
notifyListeners();
|
|
2453
2634
|
} catch (error) {
|
|
2454
|
-
|
|
2635
|
+
logger18.error("StellarUiKitManager:configure", "Failed to configure UI kit:", error);
|
|
2455
2636
|
state = {
|
|
2456
2637
|
...state,
|
|
2457
2638
|
isInitializing: false,
|
|
@@ -2555,7 +2736,7 @@ function generateStellarWalletsKitExportables(uiKitConfig) {
|
|
|
2555
2736
|
|
|
2556
2737
|
// src/wallet/stellar-wallets-kit/StellarWalletsKitConnectButton.tsx
|
|
2557
2738
|
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
2558
|
-
import { logger as
|
|
2739
|
+
import { logger as logger19 } from "@openzeppelin/ui-builder-utils";
|
|
2559
2740
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
2560
2741
|
function StellarWalletsKitConnectButton() {
|
|
2561
2742
|
const containerRef = useRef2(null);
|
|
@@ -2563,7 +2744,7 @@ function StellarWalletsKitConnectButton() {
|
|
|
2563
2744
|
const state2 = stellarUiKitManager.getState();
|
|
2564
2745
|
const kit = state2.stellarKitProvider;
|
|
2565
2746
|
if (!kit || !containerRef.current) {
|
|
2566
|
-
|
|
2747
|
+
logger19.error(
|
|
2567
2748
|
"StellarWalletsKitConnectButton",
|
|
2568
2749
|
"Kit not initialized or container not available"
|
|
2569
2750
|
);
|
|
@@ -2572,10 +2753,10 @@ function StellarWalletsKitConnectButton() {
|
|
|
2572
2753
|
kit.createButton({
|
|
2573
2754
|
container: containerRef.current,
|
|
2574
2755
|
onConnect: ({ address }) => {
|
|
2575
|
-
|
|
2756
|
+
logger19.info("StellarWalletsKitConnectButton", `Connected to address: ${address}`);
|
|
2576
2757
|
},
|
|
2577
2758
|
onDisconnect: () => {
|
|
2578
|
-
|
|
2759
|
+
logger19.info("StellarWalletsKitConnectButton", "Disconnected");
|
|
2579
2760
|
},
|
|
2580
2761
|
buttonText: "Connect Wallet"
|
|
2581
2762
|
});
|
|
@@ -2584,10 +2765,10 @@ function StellarWalletsKitConnectButton() {
|
|
|
2584
2765
|
try {
|
|
2585
2766
|
kit.removeButton();
|
|
2586
2767
|
} catch (error) {
|
|
2587
|
-
|
|
2768
|
+
logger19.warn("StellarWalletsKitConnectButton", "Error removing button:", error);
|
|
2588
2769
|
}
|
|
2589
2770
|
} else {
|
|
2590
|
-
|
|
2771
|
+
logger19.warn(
|
|
2591
2772
|
"StellarWalletsKitConnectButton",
|
|
2592
2773
|
"removeButton method not available on kit instance"
|
|
2593
2774
|
);
|
|
@@ -2616,7 +2797,7 @@ async function disconnectStellarWallet() {
|
|
|
2616
2797
|
function getStellarWalletConnectionStatus() {
|
|
2617
2798
|
const impl = getInitializedStellarWalletImplementation();
|
|
2618
2799
|
if (!impl) {
|
|
2619
|
-
|
|
2800
|
+
logger20.warn(
|
|
2620
2801
|
"getStellarWalletConnectionStatus",
|
|
2621
2802
|
"Wallet implementation not ready. Returning default disconnected state."
|
|
2622
2803
|
);
|
|
@@ -2638,7 +2819,7 @@ function getStellarWalletConnectionStatus() {
|
|
|
2638
2819
|
function onStellarWalletConnectionChange(callback) {
|
|
2639
2820
|
const impl = getInitializedStellarWalletImplementation();
|
|
2640
2821
|
if (!impl) {
|
|
2641
|
-
|
|
2822
|
+
logger20.warn(
|
|
2642
2823
|
"onStellarWalletConnectionChange",
|
|
2643
2824
|
"Wallet implementation not ready. Returning no-op."
|
|
2644
2825
|
);
|
|
@@ -2661,13 +2842,13 @@ function onStellarWalletConnectionChange(callback) {
|
|
|
2661
2842
|
try {
|
|
2662
2843
|
callback(currentStatus, previousStatus);
|
|
2663
2844
|
} catch (error) {
|
|
2664
|
-
|
|
2845
|
+
logger20.error("Error in Stellar connection status listener:", String(error));
|
|
2665
2846
|
}
|
|
2666
2847
|
});
|
|
2667
2848
|
}
|
|
2668
|
-
async function signTransaction(
|
|
2849
|
+
async function signTransaction(xdr13, address) {
|
|
2669
2850
|
const impl = await getStellarWalletImplementation();
|
|
2670
|
-
return impl.signTransaction(
|
|
2851
|
+
return impl.signTransaction(xdr13, address);
|
|
2671
2852
|
}
|
|
2672
2853
|
|
|
2673
2854
|
// src/transaction/relayer.ts
|
|
@@ -2706,7 +2887,7 @@ var RelayerExecutionStrategy = class {
|
|
|
2706
2887
|
* @throws If the API call fails or returns an unsuccessful response.
|
|
2707
2888
|
*/
|
|
2708
2889
|
async getStellarRelayers(serviceUrl, accessToken, networkConfig) {
|
|
2709
|
-
|
|
2890
|
+
logger21.info(
|
|
2710
2891
|
"[StellarRelayer] Getting relayers with access token",
|
|
2711
2892
|
accessToken.slice(0, 5).padEnd(accessToken.length, "*")
|
|
2712
2893
|
);
|
|
@@ -2754,7 +2935,7 @@ var RelayerExecutionStrategy = class {
|
|
|
2754
2935
|
* @throws If any API call fails or returns an unsuccessful response.
|
|
2755
2936
|
*/
|
|
2756
2937
|
async getStellarRelayer(serviceUrl, accessToken, relayerId, _networkConfig) {
|
|
2757
|
-
|
|
2938
|
+
logger21.info("[StellarRelayer] Getting detailed relayer info", relayerId);
|
|
2758
2939
|
const sdkConfig = new Configuration({
|
|
2759
2940
|
basePath: serviceUrl,
|
|
2760
2941
|
accessToken
|
|
@@ -2764,11 +2945,11 @@ var RelayerExecutionStrategy = class {
|
|
|
2764
2945
|
const [relayerResponse, balanceResponse, statusResponse] = await Promise.all([
|
|
2765
2946
|
relayersApi.getRelayer(relayerId),
|
|
2766
2947
|
relayersApi.getRelayerBalance(relayerId).catch((err) => {
|
|
2767
|
-
|
|
2948
|
+
logger21.warn("[StellarRelayer] Failed to fetch balance", err);
|
|
2768
2949
|
return null;
|
|
2769
2950
|
}),
|
|
2770
2951
|
relayersApi.getRelayerStatus(relayerId).catch((err) => {
|
|
2771
|
-
|
|
2952
|
+
logger21.warn("[StellarRelayer] Failed to fetch status", err);
|
|
2772
2953
|
return null;
|
|
2773
2954
|
})
|
|
2774
2955
|
]);
|
|
@@ -2790,7 +2971,7 @@ var RelayerExecutionStrategy = class {
|
|
|
2790
2971
|
const balanceInXlm = balanceInStroops / 1e7;
|
|
2791
2972
|
enhancedDetails.balance = `${balanceInXlm.toFixed(7)} XLM`;
|
|
2792
2973
|
} catch (error) {
|
|
2793
|
-
|
|
2974
|
+
logger21.warn("[StellarRelayer] Failed to format balance, using raw value", String(error));
|
|
2794
2975
|
enhancedDetails.balance = String(balanceResponse.data.data.balance);
|
|
2795
2976
|
}
|
|
2796
2977
|
}
|
|
@@ -2809,13 +2990,13 @@ var RelayerExecutionStrategy = class {
|
|
|
2809
2990
|
}
|
|
2810
2991
|
}
|
|
2811
2992
|
}
|
|
2812
|
-
|
|
2993
|
+
logger21.info(
|
|
2813
2994
|
"[StellarRelayer] Retrieved enhanced relayer details",
|
|
2814
2995
|
JSON.stringify(enhancedDetails)
|
|
2815
2996
|
);
|
|
2816
2997
|
return enhancedDetails;
|
|
2817
2998
|
} catch (error) {
|
|
2818
|
-
|
|
2999
|
+
logger21.error(
|
|
2819
3000
|
"[StellarRelayer] Failed to get relayer details",
|
|
2820
3001
|
error instanceof Error ? error.message : String(error)
|
|
2821
3002
|
);
|
|
@@ -2903,7 +3084,7 @@ var RelayerExecutionStrategy = class {
|
|
|
2903
3084
|
const connectedAddress = this.getConnectedWalletAddress();
|
|
2904
3085
|
const accountResponse = await rpcServer.getAccount(connectedAddress);
|
|
2905
3086
|
const sourceAccount = new Account2(connectedAddress, accountResponse.sequenceNumber());
|
|
2906
|
-
const contract2 = new
|
|
3087
|
+
const contract2 = new Contract3(txData.contractAddress);
|
|
2907
3088
|
const transactionBuilder = new TransactionBuilder2(sourceAccount, {
|
|
2908
3089
|
fee: BASE_FEE2,
|
|
2909
3090
|
networkPassphrase: stellarConfig.networkPassphrase
|
|
@@ -2917,7 +3098,7 @@ var RelayerExecutionStrategy = class {
|
|
|
2917
3098
|
transactionBuilder.setTimeout(30);
|
|
2918
3099
|
let transaction = transactionBuilder.build();
|
|
2919
3100
|
const simulation = await rpcServer.simulateTransaction(transaction);
|
|
2920
|
-
if (
|
|
3101
|
+
if (StellarRpc3.Api.isSimulationError(simulation)) {
|
|
2921
3102
|
throw new Error(`Transaction simulation failed: ${simulation.error}`);
|
|
2922
3103
|
}
|
|
2923
3104
|
transaction = await rpcServer.prepareTransaction(transaction);
|
|
@@ -2940,7 +3121,7 @@ var RelayerExecutionStrategy = class {
|
|
|
2940
3121
|
throw new Error(`No Soroban RPC URL available for network ${networkConfig.name}`);
|
|
2941
3122
|
}
|
|
2942
3123
|
const allowHttp = new URL(rpcUrl).hostname === "localhost";
|
|
2943
|
-
return new
|
|
3124
|
+
return new StellarRpc3.Server(rpcUrl, { allowHttp });
|
|
2944
3125
|
}
|
|
2945
3126
|
getConnectedWalletAddress() {
|
|
2946
3127
|
const connectionStatus = getStellarWalletConnectionStatus();
|
|
@@ -3071,10 +3252,10 @@ var RelayerExecutionStrategy = class {
|
|
|
3071
3252
|
};
|
|
3072
3253
|
|
|
3073
3254
|
// src/configuration/execution.ts
|
|
3074
|
-
import { logger as
|
|
3255
|
+
import { logger as logger22 } from "@openzeppelin/ui-builder-utils";
|
|
3075
3256
|
var SYSTEM_LOG_TAG7 = "adapter-stellar-execution-config";
|
|
3076
3257
|
async function getStellarSupportedExecutionMethods() {
|
|
3077
|
-
|
|
3258
|
+
logger22.warn(
|
|
3078
3259
|
"adapter-stellar-execution-config",
|
|
3079
3260
|
"getStellarSupportedExecutionMethods is using placeholder implementation."
|
|
3080
3261
|
);
|
|
@@ -3100,11 +3281,11 @@ async function getStellarSupportedExecutionMethods() {
|
|
|
3100
3281
|
]);
|
|
3101
3282
|
}
|
|
3102
3283
|
async function _validateMultisigConfig(_config, _walletStatus) {
|
|
3103
|
-
|
|
3284
|
+
logger22.info(SYSTEM_LOG_TAG7, "Multisig execution config validation: Not yet fully implemented.");
|
|
3104
3285
|
return true;
|
|
3105
3286
|
}
|
|
3106
3287
|
async function validateStellarExecutionConfig(config, walletStatus) {
|
|
3107
|
-
|
|
3288
|
+
logger22.info(SYSTEM_LOG_TAG7, "Validating Stellar execution config:", { config, walletStatus });
|
|
3108
3289
|
switch (config.method) {
|
|
3109
3290
|
case "eoa":
|
|
3110
3291
|
return validateEoaConfig(config, walletStatus);
|
|
@@ -3114,7 +3295,7 @@ async function validateStellarExecutionConfig(config, walletStatus) {
|
|
|
3114
3295
|
return _validateMultisigConfig(config, walletStatus);
|
|
3115
3296
|
default: {
|
|
3116
3297
|
const unknownMethod = config.method;
|
|
3117
|
-
|
|
3298
|
+
logger22.warn(
|
|
3118
3299
|
SYSTEM_LOG_TAG7,
|
|
3119
3300
|
`Unsupported execution method type encountered: ${unknownMethod}`
|
|
3120
3301
|
);
|
|
@@ -3127,18 +3308,18 @@ async function validateStellarExecutionConfig(config, walletStatus) {
|
|
|
3127
3308
|
import {
|
|
3128
3309
|
appConfigService as appConfigService2,
|
|
3129
3310
|
isValidUrl,
|
|
3130
|
-
logger as
|
|
3131
|
-
userRpcConfigService as
|
|
3311
|
+
logger as logger23,
|
|
3312
|
+
userRpcConfigService as userRpcConfigService3
|
|
3132
3313
|
} from "@openzeppelin/ui-builder-utils";
|
|
3133
3314
|
function validateStellarRpcEndpoint(rpcConfig) {
|
|
3134
3315
|
try {
|
|
3135
3316
|
if (!isValidUrl(rpcConfig.url)) {
|
|
3136
|
-
|
|
3317
|
+
logger23.error("validateStellarRpcEndpoint", `Invalid RPC URL format: ${rpcConfig.url}`);
|
|
3137
3318
|
return false;
|
|
3138
3319
|
}
|
|
3139
3320
|
return true;
|
|
3140
3321
|
} catch (error) {
|
|
3141
|
-
|
|
3322
|
+
logger23.error("validateStellarRpcEndpoint", "Error validating RPC endpoint:", error);
|
|
3142
3323
|
return false;
|
|
3143
3324
|
}
|
|
3144
3325
|
}
|
|
@@ -3186,7 +3367,7 @@ async function testStellarRpcConnection(rpcConfig, timeoutMs = 5e3) {
|
|
|
3186
3367
|
}
|
|
3187
3368
|
return { success: true, latency };
|
|
3188
3369
|
} catch (error) {
|
|
3189
|
-
|
|
3370
|
+
logger23.error("testStellarRpcConnection", "Connection test failed:", error);
|
|
3190
3371
|
if (error instanceof Error && error.name === "AbortError") {
|
|
3191
3372
|
return {
|
|
3192
3373
|
success: false,
|
|
@@ -3405,11 +3586,11 @@ function getStellarCompatibleFieldTypes(parameterType) {
|
|
|
3405
3586
|
|
|
3406
3587
|
// src/mapping/field-generator.ts
|
|
3407
3588
|
import { startCase } from "lodash";
|
|
3408
|
-
import { getDefaultValueForType, logger as
|
|
3589
|
+
import { getDefaultValueForType, logger as logger25 } from "@openzeppelin/ui-builder-utils";
|
|
3409
3590
|
|
|
3410
3591
|
// src/mapping/enum-metadata.ts
|
|
3411
|
-
import { xdr as
|
|
3412
|
-
import { logger as
|
|
3592
|
+
import { xdr as xdr11 } from "@stellar/stellar-sdk";
|
|
3593
|
+
import { logger as logger24 } from "@openzeppelin/ui-builder-utils";
|
|
3413
3594
|
function extractEnumVariants(entries, enumName) {
|
|
3414
3595
|
try {
|
|
3415
3596
|
const entry = entries.find((e) => {
|
|
@@ -3423,20 +3604,20 @@ function extractEnumVariants(entries, enumName) {
|
|
|
3423
3604
|
return null;
|
|
3424
3605
|
}
|
|
3425
3606
|
const entryKind = entry.switch();
|
|
3426
|
-
if (entryKind.value ===
|
|
3607
|
+
if (entryKind.value === xdr11.ScSpecEntryKind.scSpecEntryUdtUnionV0().value) {
|
|
3427
3608
|
const unionUdt = entry.udtUnionV0();
|
|
3428
3609
|
const cases = unionUdt.cases();
|
|
3429
3610
|
const variants = [];
|
|
3430
3611
|
let isUnitOnly = true;
|
|
3431
3612
|
for (const caseEntry of cases) {
|
|
3432
3613
|
const caseKind = caseEntry.switch();
|
|
3433
|
-
if (caseKind.value ===
|
|
3614
|
+
if (caseKind.value === xdr11.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0().value) {
|
|
3434
3615
|
const voidCase = caseEntry.voidCase();
|
|
3435
3616
|
variants.push({
|
|
3436
3617
|
name: voidCase.name().toString(),
|
|
3437
3618
|
type: "void"
|
|
3438
3619
|
});
|
|
3439
|
-
} else if (caseKind.value ===
|
|
3620
|
+
} else if (caseKind.value === xdr11.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value) {
|
|
3440
3621
|
const tupleCase = caseEntry.tupleCase();
|
|
3441
3622
|
const payloadTypes = tupleCase.type().map((typeDef) => extractSorobanTypeFromScSpec(typeDef));
|
|
3442
3623
|
variants.push({
|
|
@@ -3453,7 +3634,7 @@ function extractEnumVariants(entries, enumName) {
|
|
|
3453
3634
|
isUnitOnly
|
|
3454
3635
|
};
|
|
3455
3636
|
}
|
|
3456
|
-
if (entryKind.value ===
|
|
3637
|
+
if (entryKind.value === xdr11.ScSpecEntryKind.scSpecEntryUdtEnumV0().value) {
|
|
3457
3638
|
const enumUdt = entry.udtEnumV0();
|
|
3458
3639
|
const cases = enumUdt.cases();
|
|
3459
3640
|
const variants = [];
|
|
@@ -3473,7 +3654,7 @@ function extractEnumVariants(entries, enumName) {
|
|
|
3473
3654
|
}
|
|
3474
3655
|
return null;
|
|
3475
3656
|
} catch (error) {
|
|
3476
|
-
|
|
3657
|
+
logger24.error("extractEnumVariants", `Failed to extract enum variants for ${enumName}:`, error);
|
|
3477
3658
|
return null;
|
|
3478
3659
|
}
|
|
3479
3660
|
}
|
|
@@ -3491,10 +3672,10 @@ function isEnumType(entries, typeName) {
|
|
|
3491
3672
|
return false;
|
|
3492
3673
|
}
|
|
3493
3674
|
const entryKind = entry.switch();
|
|
3494
|
-
const isEnum = entryKind.value ===
|
|
3675
|
+
const isEnum = entryKind.value === xdr11.ScSpecEntryKind.scSpecEntryUdtUnionV0().value || entryKind.value === xdr11.ScSpecEntryKind.scSpecEntryUdtEnumV0().value;
|
|
3495
3676
|
return isEnum;
|
|
3496
3677
|
} catch (error) {
|
|
3497
|
-
|
|
3678
|
+
logger24.error("isEnumType", `Failed to check if ${typeName} is enum:`, error);
|
|
3498
3679
|
return false;
|
|
3499
3680
|
}
|
|
3500
3681
|
}
|
|
@@ -3507,12 +3688,13 @@ function generateStellarDefaultField(parameter, contractSchema) {
|
|
|
3507
3688
|
const specEntries = contractSchema?.metadata?.specEntries;
|
|
3508
3689
|
const fieldType = mapStellarParameterTypeToFieldType(parameter.type);
|
|
3509
3690
|
if (parameter.type === "unknown") {
|
|
3510
|
-
|
|
3691
|
+
logger25.warn(
|
|
3511
3692
|
"adapter-stellar",
|
|
3512
3693
|
`[generateStellarDefaultField] Parameter "${parameter.name}" has type "unknown"`
|
|
3513
3694
|
);
|
|
3514
3695
|
}
|
|
3515
3696
|
let enumMetadata = null;
|
|
3697
|
+
let structComponents = null;
|
|
3516
3698
|
let finalFieldType = fieldType;
|
|
3517
3699
|
let options;
|
|
3518
3700
|
if (isLikelyEnumType(parameter.type)) {
|
|
@@ -3539,6 +3721,12 @@ function generateStellarDefaultField(parameter, contractSchema) {
|
|
|
3539
3721
|
};
|
|
3540
3722
|
}
|
|
3541
3723
|
}
|
|
3724
|
+
if (specEntries && isStructType(specEntries, parameter.type)) {
|
|
3725
|
+
const structFields = extractStructFields(specEntries, parameter.type);
|
|
3726
|
+
if (structFields && structFields.length > 0) {
|
|
3727
|
+
structComponents = structFields;
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3542
3730
|
const baseField = {
|
|
3543
3731
|
id: `field-${Math.random().toString(36).substring(2, 9)}`,
|
|
3544
3732
|
name: parameter.name || parameter.type,
|
|
@@ -3610,12 +3798,15 @@ function generateStellarDefaultField(parameter, contractSchema) {
|
|
|
3610
3798
|
return mapField;
|
|
3611
3799
|
}
|
|
3612
3800
|
}
|
|
3613
|
-
if (
|
|
3614
|
-
const
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3801
|
+
if (fieldType === "object" || fieldType === "array-object") {
|
|
3802
|
+
const componentsToUse = parameter.components || structComponents;
|
|
3803
|
+
if (componentsToUse) {
|
|
3804
|
+
const result = {
|
|
3805
|
+
...baseField,
|
|
3806
|
+
components: componentsToUse
|
|
3807
|
+
};
|
|
3808
|
+
return result;
|
|
3809
|
+
}
|
|
3619
3810
|
}
|
|
3620
3811
|
if (enumMetadata) {
|
|
3621
3812
|
const result = {
|
|
@@ -3630,9 +3821,9 @@ function generateStellarDefaultField(parameter, contractSchema) {
|
|
|
3630
3821
|
// src/transaction/formatter.ts
|
|
3631
3822
|
import { Address as Address3 } from "@stellar/stellar-sdk";
|
|
3632
3823
|
import { isEnumValue as isEnumValue3 } from "@openzeppelin/ui-builder-types";
|
|
3633
|
-
import { logger as
|
|
3824
|
+
import { logger as logger26 } from "@openzeppelin/ui-builder-utils";
|
|
3634
3825
|
function formatStellarTransactionData(contractSchema, functionId, submittedInputs, fields) {
|
|
3635
|
-
|
|
3826
|
+
logger26.info(
|
|
3636
3827
|
"formatStellarTransactionData",
|
|
3637
3828
|
`Formatting Stellar transaction data for function: ${functionId}`
|
|
3638
3829
|
);
|
|
@@ -3650,7 +3841,7 @@ function formatStellarTransactionData(contractSchema, functionId, submittedInput
|
|
|
3650
3841
|
let value;
|
|
3651
3842
|
if (fieldConfig.isHardcoded) {
|
|
3652
3843
|
if (fieldConfig.hardcodedValue === void 0 && fieldConfig.name in submittedInputs) {
|
|
3653
|
-
|
|
3844
|
+
logger26.warn(
|
|
3654
3845
|
"formatStellarTransactionData",
|
|
3655
3846
|
`Field '${fieldConfig.name}' is hardcoded with undefined value but has submitted input. Using submitted input instead.`
|
|
3656
3847
|
);
|
|
@@ -3722,7 +3913,7 @@ function formatStellarTransactionData(contractSchema, functionId, submittedInput
|
|
|
3722
3913
|
// For example: fee, timeout, memo, etc.
|
|
3723
3914
|
}
|
|
3724
3915
|
};
|
|
3725
|
-
|
|
3916
|
+
logger26.debug(
|
|
3726
3917
|
"formatStellarTransactionData",
|
|
3727
3918
|
"Formatted transaction data:",
|
|
3728
3919
|
stellarTransactionData
|
|
@@ -3731,33 +3922,33 @@ function formatStellarTransactionData(contractSchema, functionId, submittedInput
|
|
|
3731
3922
|
}
|
|
3732
3923
|
|
|
3733
3924
|
// src/transaction/sender.ts
|
|
3734
|
-
import { rpc as
|
|
3735
|
-
import { logger as
|
|
3925
|
+
import { rpc as StellarRpc5 } from "@stellar/stellar-sdk";
|
|
3926
|
+
import { logger as logger28, userRpcConfigService as userRpcConfigService5 } from "@openzeppelin/ui-builder-utils";
|
|
3736
3927
|
|
|
3737
3928
|
// src/transaction/eoa.ts
|
|
3738
3929
|
import {
|
|
3739
3930
|
Account as Account3,
|
|
3740
3931
|
BASE_FEE as BASE_FEE3,
|
|
3741
|
-
Contract as
|
|
3742
|
-
rpc as
|
|
3932
|
+
Contract as Contract4,
|
|
3933
|
+
rpc as StellarRpc4,
|
|
3743
3934
|
TransactionBuilder as TransactionBuilder3
|
|
3744
3935
|
} from "@stellar/stellar-sdk";
|
|
3745
|
-
import { logger as
|
|
3936
|
+
import { logger as logger27, userRpcConfigService as userRpcConfigService4 } from "@openzeppelin/ui-builder-utils";
|
|
3746
3937
|
var SYSTEM_LOG_TAG8 = "EoaExecutionStrategy";
|
|
3747
|
-
function
|
|
3748
|
-
const customRpcConfig =
|
|
3938
|
+
function getSorobanRpcServer3(networkConfig) {
|
|
3939
|
+
const customRpcConfig = userRpcConfigService4.getUserRpcConfig(networkConfig.id);
|
|
3749
3940
|
const rpcUrl = customRpcConfig?.url || networkConfig.sorobanRpcUrl;
|
|
3750
3941
|
if (!rpcUrl) {
|
|
3751
3942
|
throw new Error(`No Soroban RPC URL available for network ${networkConfig.name}`);
|
|
3752
3943
|
}
|
|
3753
3944
|
const allowHttp = new URL(rpcUrl).hostname === "localhost";
|
|
3754
|
-
return new
|
|
3945
|
+
return new StellarRpc4.Server(rpcUrl, {
|
|
3755
3946
|
allowHttp
|
|
3756
3947
|
});
|
|
3757
3948
|
}
|
|
3758
3949
|
var EoaExecutionStrategy = class {
|
|
3759
3950
|
async execute(transactionData, executionConfig, networkConfig, onStatusChange, _runtimeApiKey) {
|
|
3760
|
-
|
|
3951
|
+
logger27.info(SYSTEM_LOG_TAG8, "Using Stellar EOA execution strategy");
|
|
3761
3952
|
if (executionConfig.method !== "eoa") {
|
|
3762
3953
|
throw new Error(`Expected EOA execution config, got: ${executionConfig.method}`);
|
|
3763
3954
|
}
|
|
@@ -3765,9 +3956,9 @@ var EoaExecutionStrategy = class {
|
|
|
3765
3956
|
}
|
|
3766
3957
|
async executeEoaTransaction(txData, stellarConfig, onStatusChange) {
|
|
3767
3958
|
try {
|
|
3768
|
-
const rpcServer =
|
|
3959
|
+
const rpcServer = getSorobanRpcServer3(stellarConfig);
|
|
3769
3960
|
const connectedAddress = this.getConnectedWalletAddress();
|
|
3770
|
-
|
|
3961
|
+
logger27.info(SYSTEM_LOG_TAG8, `Connected address: ${connectedAddress}`);
|
|
3771
3962
|
let sourceAccount;
|
|
3772
3963
|
try {
|
|
3773
3964
|
const accountResponse = await rpcServer.getAccount(connectedAddress);
|
|
@@ -3775,7 +3966,7 @@ var EoaExecutionStrategy = class {
|
|
|
3775
3966
|
} catch (error) {
|
|
3776
3967
|
throw new Error(`Failed to load account details: ${error.message}`);
|
|
3777
3968
|
}
|
|
3778
|
-
const contract2 = new
|
|
3969
|
+
const contract2 = new Contract4(txData.contractAddress);
|
|
3779
3970
|
const transactionBuilder = new TransactionBuilder3(sourceAccount, {
|
|
3780
3971
|
fee: BASE_FEE3,
|
|
3781
3972
|
networkPassphrase: stellarConfig.networkPassphrase
|
|
@@ -3790,7 +3981,7 @@ var EoaExecutionStrategy = class {
|
|
|
3790
3981
|
let transaction = transactionBuilder.build();
|
|
3791
3982
|
try {
|
|
3792
3983
|
const simulation = await rpcServer.simulateTransaction(transaction);
|
|
3793
|
-
if (
|
|
3984
|
+
if (StellarRpc4.Api.isSimulationError(simulation)) {
|
|
3794
3985
|
throw new Error(`Transaction simulation failed: ${simulation.error}`);
|
|
3795
3986
|
}
|
|
3796
3987
|
transaction = await rpcServer.prepareTransaction(transaction);
|
|
@@ -3826,7 +4017,7 @@ var EoaExecutionStrategy = class {
|
|
|
3826
4017
|
throw new Error(`Transaction failed to submit: ${sendResult.status}`);
|
|
3827
4018
|
}
|
|
3828
4019
|
const txHash = sendResult.hash;
|
|
3829
|
-
|
|
4020
|
+
logger27.info(SYSTEM_LOG_TAG8, `Transaction submitted successfully: ${txHash}`);
|
|
3830
4021
|
try {
|
|
3831
4022
|
let txResponse;
|
|
3832
4023
|
const MAX_ATTEMPTS = 10;
|
|
@@ -3845,10 +4036,10 @@ var EoaExecutionStrategy = class {
|
|
|
3845
4036
|
}
|
|
3846
4037
|
}
|
|
3847
4038
|
if (attempts >= MAX_ATTEMPTS || txResponse?.status !== "SUCCESS") {
|
|
3848
|
-
|
|
4039
|
+
logger27.warn(SYSTEM_LOG_TAG8, `Transaction confirmation timeout for ${txHash}`);
|
|
3849
4040
|
}
|
|
3850
4041
|
} catch (confirmError) {
|
|
3851
|
-
|
|
4042
|
+
logger27.error(SYSTEM_LOG_TAG8, "Error waiting for confirmation:", confirmError);
|
|
3852
4043
|
}
|
|
3853
4044
|
onStatusChange("success", {
|
|
3854
4045
|
txHash
|
|
@@ -3856,7 +4047,7 @@ var EoaExecutionStrategy = class {
|
|
|
3856
4047
|
return { txHash };
|
|
3857
4048
|
} catch (error) {
|
|
3858
4049
|
const errorMessage = `Failed to execute Stellar EOA transaction: ${error.message}`;
|
|
3859
|
-
|
|
4050
|
+
logger27.error(SYSTEM_LOG_TAG8, errorMessage, error);
|
|
3860
4051
|
onStatusChange("error", {});
|
|
3861
4052
|
throw new Error(errorMessage);
|
|
3862
4053
|
}
|
|
@@ -3873,7 +4064,7 @@ var EoaExecutionStrategy = class {
|
|
|
3873
4064
|
// src/transaction/sender.ts
|
|
3874
4065
|
var SYSTEM_LOG_TAG9 = "adapter-stellar";
|
|
3875
4066
|
async function signAndBroadcastStellarTransaction(transactionData, executionConfig, networkConfig, onStatusChange, runtimeApiKey) {
|
|
3876
|
-
|
|
4067
|
+
logger28.info(
|
|
3877
4068
|
SYSTEM_LOG_TAG9,
|
|
3878
4069
|
"Stellar signAndBroadcast called with executionConfig:",
|
|
3879
4070
|
executionConfig
|
|
@@ -3894,7 +4085,7 @@ async function signAndBroadcastStellarTransaction(transactionData, executionConf
|
|
|
3894
4085
|
throw new Error("Multisig execution method not yet implemented for Stellar.");
|
|
3895
4086
|
default: {
|
|
3896
4087
|
const exhaustiveCheck = executionConfig;
|
|
3897
|
-
|
|
4088
|
+
logger28.error(SYSTEM_LOG_TAG9, `Unsupported execution method encountered: ${exhaustiveCheck}`);
|
|
3898
4089
|
throw new Error(`Unsupported execution method: ${exhaustiveCheck}`);
|
|
3899
4090
|
}
|
|
3900
4091
|
}
|
|
@@ -3910,7 +4101,7 @@ async function signAndBroadcastStellarTransaction(transactionData, executionConf
|
|
|
3910
4101
|
|
|
3911
4102
|
// src/wallet/components/StellarWalletUiRoot.tsx
|
|
3912
4103
|
import { useCallback, useEffect as useEffect3, useState as useState2 } from "react";
|
|
3913
|
-
import { logger as
|
|
4104
|
+
import { logger as logger29 } from "@openzeppelin/ui-builder-utils";
|
|
3914
4105
|
|
|
3915
4106
|
// src/wallet/context/StellarWalletContext.ts
|
|
3916
4107
|
import { createContext } from "react";
|
|
@@ -3929,9 +4120,9 @@ function StellarWalletUiRoot({ children, uiKitConfig }) {
|
|
|
3929
4120
|
const currentState = stellarUiKitManager.getState();
|
|
3930
4121
|
if (uiKitConfig || !currentState.currentFullUiKitConfig) {
|
|
3931
4122
|
const configToUse = uiKitConfig || { kitName: "custom", kitConfig: {} };
|
|
3932
|
-
|
|
4123
|
+
logger29.debug("StellarWalletUiRoot", "Configuring UI kit with:", configToUse);
|
|
3933
4124
|
stellarUiKitManager.configure(configToUse).catch((error) => {
|
|
3934
|
-
|
|
4125
|
+
logger29.error("Failed to configure Stellar UI kit:", error);
|
|
3935
4126
|
});
|
|
3936
4127
|
}
|
|
3937
4128
|
}, [uiKitConfig]);
|
|
@@ -3945,7 +4136,7 @@ function StellarWalletUiRoot({ children, uiKitConfig }) {
|
|
|
3945
4136
|
const unsubscribeFromConnectionChanges = onStellarWalletConnectionChange(
|
|
3946
4137
|
(currentStatus, _previousStatus) => {
|
|
3947
4138
|
setAddress(currentStatus.address || null);
|
|
3948
|
-
|
|
4139
|
+
logger29.debug(
|
|
3949
4140
|
"StellarWalletUiRoot",
|
|
3950
4141
|
`Connection status changed: ${currentStatus.isConnected ? "connected" : "disconnected"}`,
|
|
3951
4142
|
currentStatus.address
|
|
@@ -3964,7 +4155,7 @@ function StellarWalletUiRoot({ children, uiKitConfig }) {
|
|
|
3964
4155
|
const connectors = await getStellarAvailableConnectors();
|
|
3965
4156
|
setAvailableWallets(connectors);
|
|
3966
4157
|
} catch (error) {
|
|
3967
|
-
|
|
4158
|
+
logger29.error("Failed to load available wallets:", String(error));
|
|
3968
4159
|
}
|
|
3969
4160
|
};
|
|
3970
4161
|
if (!uiKitManagerState.isInitializing && uiKitManagerState.stellarKitProvider) {
|
|
@@ -3981,7 +4172,7 @@ function StellarWalletUiRoot({ children, uiKitConfig }) {
|
|
|
3981
4172
|
throw new Error(result.error || "Failed to connect wallet");
|
|
3982
4173
|
}
|
|
3983
4174
|
} catch (error) {
|
|
3984
|
-
|
|
4175
|
+
logger29.error("Failed to connect:", String(error));
|
|
3985
4176
|
throw error;
|
|
3986
4177
|
} finally {
|
|
3987
4178
|
setIsConnecting(false);
|
|
@@ -3996,7 +4187,7 @@ function StellarWalletUiRoot({ children, uiKitConfig }) {
|
|
|
3996
4187
|
throw new Error(result.error || "Failed to disconnect wallet");
|
|
3997
4188
|
}
|
|
3998
4189
|
} catch (error) {
|
|
3999
|
-
|
|
4190
|
+
logger29.error("Failed to disconnect:", String(error));
|
|
4000
4191
|
throw error;
|
|
4001
4192
|
}
|
|
4002
4193
|
}, []);
|
|
@@ -4115,20 +4306,20 @@ var stellarFacadeHooks = {
|
|
|
4115
4306
|
};
|
|
4116
4307
|
|
|
4117
4308
|
// src/wallet/hooks/useUiKitConfig.ts
|
|
4118
|
-
import { appConfigService as appConfigService3, logger as
|
|
4309
|
+
import { appConfigService as appConfigService3, logger as logger30 } from "@openzeppelin/ui-builder-utils";
|
|
4119
4310
|
var defaultConfig = {
|
|
4120
4311
|
kitName: "custom",
|
|
4121
4312
|
// Default to using our custom implementation for Stellar
|
|
4122
4313
|
kitConfig: {}
|
|
4123
4314
|
};
|
|
4124
4315
|
function loadInitialConfigFromAppService() {
|
|
4125
|
-
|
|
4316
|
+
logger30.debug(
|
|
4126
4317
|
"stellar:useUiKitConfig",
|
|
4127
4318
|
"Attempting to load initial config from AppConfigService..."
|
|
4128
4319
|
);
|
|
4129
4320
|
const configObj = appConfigService3.getWalletUIConfig("stellar");
|
|
4130
4321
|
if (configObj && configObj.kitName) {
|
|
4131
|
-
|
|
4322
|
+
logger30.info(
|
|
4132
4323
|
"stellar:useUiKitConfig",
|
|
4133
4324
|
`Loaded initial config from AppConfigService: kitName=${configObj.kitName}`,
|
|
4134
4325
|
configObj.kitConfig
|
|
@@ -4138,7 +4329,7 @@ function loadInitialConfigFromAppService() {
|
|
|
4138
4329
|
kitConfig: { ...defaultConfig.kitConfig, ...configObj.kitConfig || {} }
|
|
4139
4330
|
};
|
|
4140
4331
|
}
|
|
4141
|
-
|
|
4332
|
+
logger30.debug(
|
|
4142
4333
|
"stellar:useUiKitConfig",
|
|
4143
4334
|
"No initial config found in AppConfigService, using module default."
|
|
4144
4335
|
);
|
|
@@ -4161,7 +4352,7 @@ import {
|
|
|
4161
4352
|
DialogHeader,
|
|
4162
4353
|
DialogTitle
|
|
4163
4354
|
} from "@openzeppelin/ui-builder-ui";
|
|
4164
|
-
import { logger as
|
|
4355
|
+
import { logger as logger31 } from "@openzeppelin/ui-builder-utils";
|
|
4165
4356
|
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
4166
4357
|
var ConnectorDialog = ({ open, onOpenChange }) => {
|
|
4167
4358
|
const { connect } = useStellarConnect();
|
|
@@ -4176,7 +4367,7 @@ var ConnectorDialog = ({ open, onOpenChange }) => {
|
|
|
4176
4367
|
const availableConnectors = await getStellarAvailableConnectors();
|
|
4177
4368
|
setConnectors(availableConnectors);
|
|
4178
4369
|
} catch (err) {
|
|
4179
|
-
|
|
4370
|
+
logger31.error("Failed to load Stellar connectors:", String(err));
|
|
4180
4371
|
setError("Failed to load available wallets");
|
|
4181
4372
|
} finally {
|
|
4182
4373
|
setLoadingConnectors(false);
|
|
@@ -4330,18 +4521,18 @@ var CustomAccountDisplay = ({ className }) => {
|
|
|
4330
4521
|
|
|
4331
4522
|
// src/wallet/utils/filterWalletComponents.ts
|
|
4332
4523
|
import { ECOSYSTEM_WALLET_COMPONENT_KEYS } from "@openzeppelin/ui-builder-types";
|
|
4333
|
-
import { logger as
|
|
4524
|
+
import { logger as logger32 } from "@openzeppelin/ui-builder-utils";
|
|
4334
4525
|
function filterWalletComponents(allPossibleComponents, exclusions, kitName = "custom") {
|
|
4335
|
-
|
|
4526
|
+
logger32.debug(
|
|
4336
4527
|
"filterWalletComponents",
|
|
4337
4528
|
`Filtering components for kit: ${kitName}. Exclusions: ${exclusions.join(", ")}.`
|
|
4338
4529
|
);
|
|
4339
4530
|
if (!allPossibleComponents || Object.keys(allPossibleComponents).length === 0) {
|
|
4340
|
-
|
|
4531
|
+
logger32.debug("filterWalletComponents", `No components provided to filter for kit: ${kitName}.`);
|
|
4341
4532
|
return void 0;
|
|
4342
4533
|
}
|
|
4343
4534
|
if (exclusions.length === 0) {
|
|
4344
|
-
|
|
4535
|
+
logger32.debug(
|
|
4345
4536
|
"filterWalletComponents",
|
|
4346
4537
|
`Providing all components for kit: ${kitName}.`,
|
|
4347
4538
|
allPossibleComponents
|
|
@@ -4360,14 +4551,14 @@ function filterWalletComponents(allPossibleComponents, exclusions, kitName = "cu
|
|
|
4360
4551
|
}
|
|
4361
4552
|
}
|
|
4362
4553
|
if (componentCount > 0) {
|
|
4363
|
-
|
|
4554
|
+
logger32.debug(
|
|
4364
4555
|
"filterWalletComponents",
|
|
4365
4556
|
`Providing filtered components for kit: ${kitName} after exclusions (${exclusions.join(", ")}).`,
|
|
4366
4557
|
filteredComponents
|
|
4367
4558
|
);
|
|
4368
4559
|
return filteredComponents;
|
|
4369
4560
|
}
|
|
4370
|
-
|
|
4561
|
+
logger32.debug("filterWalletComponents", `All components were excluded for kit: ${kitName}.`);
|
|
4371
4562
|
return void 0;
|
|
4372
4563
|
}
|
|
4373
4564
|
function getComponentExclusionsFromConfig(kitConfig) {
|
|
@@ -4383,23 +4574,23 @@ function getComponentExclusionsFromConfig(kitConfig) {
|
|
|
4383
4574
|
}
|
|
4384
4575
|
|
|
4385
4576
|
// src/wallet/utils/uiKitService.ts
|
|
4386
|
-
import { logger as
|
|
4577
|
+
import { logger as logger33 } from "@openzeppelin/ui-builder-utils";
|
|
4387
4578
|
function getResolvedWalletComponents(uiKitConfiguration) {
|
|
4388
|
-
|
|
4579
|
+
logger33.debug(
|
|
4389
4580
|
"stellar:uiKitService:getResolvedWalletComponents",
|
|
4390
4581
|
"Received uiKitConfiguration:",
|
|
4391
4582
|
JSON.stringify(uiKitConfiguration)
|
|
4392
4583
|
);
|
|
4393
4584
|
const currentKitName = uiKitConfiguration.kitName || "custom";
|
|
4394
4585
|
if (currentKitName === "none") {
|
|
4395
|
-
|
|
4586
|
+
logger33.info(
|
|
4396
4587
|
"stellar:uiKitService",
|
|
4397
4588
|
'UI Kit set to "none" for getResolvedWalletComponents, not providing wallet components.'
|
|
4398
4589
|
);
|
|
4399
4590
|
return void 0;
|
|
4400
4591
|
}
|
|
4401
4592
|
const exclusions = getComponentExclusionsFromConfig(uiKitConfiguration.kitConfig);
|
|
4402
|
-
|
|
4593
|
+
logger33.debug(
|
|
4403
4594
|
"stellar:uiKitService",
|
|
4404
4595
|
`Extracted component exclusions for ${currentKitName}: ${exclusions.join(", ") || "none"}.`
|
|
4405
4596
|
);
|
|
@@ -4409,7 +4600,7 @@ function getResolvedWalletComponents(uiKitConfiguration) {
|
|
|
4409
4600
|
AccountDisplay: CustomAccountDisplay
|
|
4410
4601
|
// NetworkSwitcher is not included as Stellar doesn't support network switching
|
|
4411
4602
|
};
|
|
4412
|
-
|
|
4603
|
+
logger33.info(
|
|
4413
4604
|
"stellar:uiKitService",
|
|
4414
4605
|
`Providing custom Stellar wallet components for kit: ${currentKitName}`
|
|
4415
4606
|
);
|
|
@@ -4421,10 +4612,10 @@ function getResolvedWalletComponents(uiKitConfiguration) {
|
|
|
4421
4612
|
// The kit's native button handles account display internally
|
|
4422
4613
|
AccountDisplay: void 0
|
|
4423
4614
|
};
|
|
4424
|
-
|
|
4615
|
+
logger33.info("stellar:uiKitService", "Using Stellar Wallets Kit native button");
|
|
4425
4616
|
return stellarKitComponents;
|
|
4426
4617
|
}
|
|
4427
|
-
|
|
4618
|
+
logger33.warn(
|
|
4428
4619
|
"stellar:uiKitService",
|
|
4429
4620
|
`UI Kit "${currentKitName}" for getResolvedWalletComponents not explicitly supported. No components provided.`
|
|
4430
4621
|
);
|
|
@@ -4432,9 +4623,9 @@ function getResolvedWalletComponents(uiKitConfiguration) {
|
|
|
4432
4623
|
}
|
|
4433
4624
|
|
|
4434
4625
|
// src/wallet/services/configResolutionService.ts
|
|
4435
|
-
import { logger as
|
|
4626
|
+
import { logger as logger34 } from "@openzeppelin/ui-builder-utils";
|
|
4436
4627
|
async function resolveFullUiKitConfiguration(programmaticOverrides, initialAppServiceKitName, currentAppServiceConfig, options) {
|
|
4437
|
-
|
|
4628
|
+
logger34.debug(
|
|
4438
4629
|
"stellar:configResolutionService:resolveFullUiKitConfiguration",
|
|
4439
4630
|
"Starting resolution with:",
|
|
4440
4631
|
{
|
|
@@ -4445,7 +4636,7 @@ async function resolveFullUiKitConfiguration(programmaticOverrides, initialAppSe
|
|
|
4445
4636
|
}
|
|
4446
4637
|
);
|
|
4447
4638
|
if (options?.loadUiKitNativeConfig) {
|
|
4448
|
-
|
|
4639
|
+
logger34.debug(
|
|
4449
4640
|
"stellar:configResolutionService",
|
|
4450
4641
|
"Native config loader provided but not currently supported for Stellar adapter"
|
|
4451
4642
|
);
|
|
@@ -4458,7 +4649,7 @@ async function resolveFullUiKitConfiguration(programmaticOverrides, initialAppSe
|
|
|
4458
4649
|
...programmaticOverrides.kitConfig || {}
|
|
4459
4650
|
}
|
|
4460
4651
|
};
|
|
4461
|
-
|
|
4652
|
+
logger34.debug(
|
|
4462
4653
|
"stellar:configResolutionService:resolveFullUiKitConfiguration",
|
|
4463
4654
|
"Resolved finalFullConfig:",
|
|
4464
4655
|
finalFullConfig
|
|
@@ -4477,7 +4668,7 @@ var StellarAdapter = class {
|
|
|
4477
4668
|
this.networkConfig = networkConfig;
|
|
4478
4669
|
stellarUiKitManager.setNetworkConfig(networkConfig);
|
|
4479
4670
|
getStellarWalletImplementation(networkConfig).catch((error) => {
|
|
4480
|
-
|
|
4671
|
+
logger35.error(
|
|
4481
4672
|
"StellarAdapter:constructor",
|
|
4482
4673
|
"Failed to initialize wallet implementation:",
|
|
4483
4674
|
error
|
|
@@ -4485,12 +4676,12 @@ var StellarAdapter = class {
|
|
|
4485
4676
|
});
|
|
4486
4677
|
const initialGlobalConfig = loadInitialConfigFromAppService();
|
|
4487
4678
|
this.initialAppServiceKitName = initialGlobalConfig.kitName || "custom";
|
|
4488
|
-
|
|
4679
|
+
logger35.info(
|
|
4489
4680
|
"StellarAdapter:constructor",
|
|
4490
4681
|
"Initial kitName from AppConfigService noted:",
|
|
4491
4682
|
this.initialAppServiceKitName
|
|
4492
4683
|
);
|
|
4493
|
-
|
|
4684
|
+
logger35.info(
|
|
4494
4685
|
"StellarAdapter",
|
|
4495
4686
|
`Adapter initialized for network: ${networkConfig.name} (ID: ${networkConfig.id})`
|
|
4496
4687
|
);
|
|
@@ -4637,7 +4828,7 @@ var StellarAdapter = class {
|
|
|
4637
4828
|
onWalletConnectionChange(callback) {
|
|
4638
4829
|
const walletImplementation = getInitializedStellarWalletImplementation();
|
|
4639
4830
|
if (!walletImplementation) {
|
|
4640
|
-
|
|
4831
|
+
logger35.warn(
|
|
4641
4832
|
"StellarAdapter:onWalletConnectionChange",
|
|
4642
4833
|
"Wallet implementation not ready. Subscription may not work."
|
|
4643
4834
|
);
|
|
@@ -4699,7 +4890,7 @@ var StellarAdapter = class {
|
|
|
4699
4890
|
options
|
|
4700
4891
|
);
|
|
4701
4892
|
await stellarUiKitManager.configure(finalFullConfig);
|
|
4702
|
-
|
|
4893
|
+
logger35.info(
|
|
4703
4894
|
"StellarAdapter:configureUiKit",
|
|
4704
4895
|
"StellarUiKitManager configuration requested with final config:",
|
|
4705
4896
|
finalFullConfig
|
|
@@ -4720,7 +4911,7 @@ var StellarAdapter = class {
|
|
|
4720
4911
|
getEcosystemWalletComponents() {
|
|
4721
4912
|
const currentManagerState = stellarUiKitManager.getState();
|
|
4722
4913
|
if (!currentManagerState.currentFullUiKitConfig) {
|
|
4723
|
-
|
|
4914
|
+
logger35.debug(
|
|
4724
4915
|
"StellarAdapter:getEcosystemWalletComponents",
|
|
4725
4916
|
"No UI kit configuration available in manager yet. Returning undefined components."
|
|
4726
4917
|
);
|
|
@@ -4733,7 +4924,7 @@ var StellarAdapter = class {
|
|
|
4733
4924
|
* @inheritdoc
|
|
4734
4925
|
*/
|
|
4735
4926
|
getEcosystemReactUiContextProvider() {
|
|
4736
|
-
|
|
4927
|
+
logger35.info(
|
|
4737
4928
|
"StellarAdapter:getEcosystemReactUiContextProvider",
|
|
4738
4929
|
"Returning StellarWalletUiRoot."
|
|
4739
4930
|
);
|
|
@@ -4750,7 +4941,7 @@ var StellarAdapter = class {
|
|
|
4750
4941
|
try {
|
|
4751
4942
|
return await relayerStrategy.getStellarRelayers(serviceUrl, accessToken, this.networkConfig);
|
|
4752
4943
|
} catch (error) {
|
|
4753
|
-
|
|
4944
|
+
logger35.error("StellarAdapter", "Failed to fetch Stellar relayers:", error);
|
|
4754
4945
|
return Promise.resolve([]);
|
|
4755
4946
|
}
|
|
4756
4947
|
}
|
|
@@ -4764,7 +4955,7 @@ var StellarAdapter = class {
|
|
|
4764
4955
|
this.networkConfig
|
|
4765
4956
|
);
|
|
4766
4957
|
} catch (error) {
|
|
4767
|
-
|
|
4958
|
+
logger35.error("StellarAdapter", "Failed to fetch Stellar relayer details:", error);
|
|
4768
4959
|
return Promise.resolve({});
|
|
4769
4960
|
}
|
|
4770
4961
|
}
|
|
@@ -4814,6 +5005,7 @@ var StellarAdapter = class {
|
|
|
4814
5005
|
};
|
|
4815
5006
|
|
|
4816
5007
|
// src/networks/mainnet.ts
|
|
5008
|
+
import { NetworkStellar } from "@web3icons/react";
|
|
4817
5009
|
var stellarPublic = {
|
|
4818
5010
|
id: "stellar-public",
|
|
4819
5011
|
exportConstName: "stellarPublic",
|
|
@@ -4826,10 +5018,11 @@ var stellarPublic = {
|
|
|
4826
5018
|
sorobanRpcUrl: "https://mainnet.sorobanrpc.com",
|
|
4827
5019
|
networkPassphrase: "Public Global Stellar Network ; September 2015",
|
|
4828
5020
|
explorerUrl: "https://stellar.expert/explorer/public",
|
|
4829
|
-
|
|
5021
|
+
iconComponent: NetworkStellar
|
|
4830
5022
|
};
|
|
4831
5023
|
|
|
4832
5024
|
// src/networks/testnet.ts
|
|
5025
|
+
import { NetworkStellar as NetworkStellar2 } from "@web3icons/react";
|
|
4833
5026
|
var stellarTestnet = {
|
|
4834
5027
|
id: "stellar-testnet",
|
|
4835
5028
|
exportConstName: "stellarTestnet",
|
|
@@ -4842,7 +5035,7 @@ var stellarTestnet = {
|
|
|
4842
5035
|
sorobanRpcUrl: "https://soroban-testnet.stellar.org",
|
|
4843
5036
|
networkPassphrase: "Test SDF Network ; September 2015",
|
|
4844
5037
|
explorerUrl: "https://stellar.expert/explorer/testnet",
|
|
4845
|
-
|
|
5038
|
+
iconComponent: NetworkStellar2
|
|
4846
5039
|
};
|
|
4847
5040
|
|
|
4848
5041
|
// src/networks/index.ts
|
|
@@ -4864,6 +5057,10 @@ var stellarAdapterConfig = {
|
|
|
4864
5057
|
runtime: {
|
|
4865
5058
|
// Core Stellar libraries
|
|
4866
5059
|
"@stellar/stellar-sdk": "^14.1.1",
|
|
5060
|
+
// SAC (Stellar Asset Contract) support - dynamically loaded from CDN
|
|
5061
|
+
// These are needed for XDR encoding when working with SAC contracts
|
|
5062
|
+
"@stellar/stellar-xdr-json": "^23.0.0",
|
|
5063
|
+
"lossless-json": "^4.0.2",
|
|
4867
5064
|
// Wallet connection and integration
|
|
4868
5065
|
"@creit.tech/stellar-wallets-kit": "^1.9.5",
|
|
4869
5066
|
// OpenZeppelin Relayer integration (optional, for gasless transactions)
|