@openzeppelin/ui-builder-adapter-stellar 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +467 -309
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -5
- package/dist/index.d.ts +78 -5
- package/dist/index.js +458 -300
- package/dist/index.js.map +1 -1
- package/dist/vite-config.cjs +52 -0
- package/dist/vite-config.cjs.map +1 -0
- package/dist/vite-config.d.cts +46 -0
- package/dist/vite-config.d.ts +46 -0
- package/dist/vite-config.js +27 -0
- package/dist/vite-config.js.map +1 -0
- package/package.json +9 -4
- package/src/adapter.ts +99 -19
- package/src/configuration/__tests__/rpc.test.ts +0 -1
- package/src/configuration/index.ts +1 -0
- package/src/configuration/network-services.ts +51 -0
- package/src/mapping/constants.ts +12 -6
- package/src/mapping/type-mapper.ts +6 -6
- package/src/networks/README.md +1 -1
- package/src/vite-config.ts +67 -0
- package/src/wallet/stellar-wallets-kit/StellarWalletsKitConnectButton.tsx +23 -0
- package/src/wallet/stellar-wallets-kit/config-generator.ts +2 -19
- package/src/wallet/stellar-wallets-kit/stellarUiKitManager.ts +61 -0
package/dist/index.cjs
CHANGED
|
@@ -47,9 +47,150 @@ module.exports = __toCommonJS(index_exports);
|
|
|
47
47
|
var import_ui_builder_types6 = require("@openzeppelin/ui-builder-types");
|
|
48
48
|
var import_ui_builder_utils38 = require("@openzeppelin/ui-builder-utils");
|
|
49
49
|
|
|
50
|
+
// src/configuration/rpc.ts
|
|
51
|
+
var import_ui_builder_utils = require("@openzeppelin/ui-builder-utils");
|
|
52
|
+
function validateStellarRpcEndpoint(rpcConfig) {
|
|
53
|
+
try {
|
|
54
|
+
if (!(0, import_ui_builder_utils.isValidUrl)(rpcConfig.url)) {
|
|
55
|
+
import_ui_builder_utils.logger.error("validateStellarRpcEndpoint", `Invalid RPC URL format: ${rpcConfig.url}`);
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
import_ui_builder_utils.logger.error("validateStellarRpcEndpoint", "Error validating RPC endpoint:", error);
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function testStellarRpcConnection(rpcConfig, timeoutMs = 5e3) {
|
|
65
|
+
if (!rpcConfig.url) {
|
|
66
|
+
return { success: false, error: "Soroban RPC URL is required" };
|
|
67
|
+
}
|
|
68
|
+
const controller = new AbortController();
|
|
69
|
+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
70
|
+
try {
|
|
71
|
+
const startTime = Date.now();
|
|
72
|
+
const response = await fetch(rpcConfig.url, {
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: {
|
|
75
|
+
"Content-Type": "application/json"
|
|
76
|
+
},
|
|
77
|
+
body: JSON.stringify({
|
|
78
|
+
jsonrpc: "2.0",
|
|
79
|
+
id: 1,
|
|
80
|
+
method: "getHealth"
|
|
81
|
+
}),
|
|
82
|
+
signal: controller.signal
|
|
83
|
+
});
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
return { success: false, error: `HTTP error: ${response.status}` };
|
|
86
|
+
}
|
|
87
|
+
const data = await response.json();
|
|
88
|
+
const latency = Date.now() - startTime;
|
|
89
|
+
if (data.error) {
|
|
90
|
+
return {
|
|
91
|
+
success: false,
|
|
92
|
+
error: `Soroban RPC error: ${data.error.message || "Unknown RPC error"}`
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (!data.result) {
|
|
96
|
+
return await testWithFallbackMethod(rpcConfig, controller.signal, startTime);
|
|
97
|
+
}
|
|
98
|
+
const healthStatus = data.result.status;
|
|
99
|
+
if (healthStatus && healthStatus !== "healthy") {
|
|
100
|
+
return {
|
|
101
|
+
success: false,
|
|
102
|
+
error: `Soroban RPC service unhealthy: ${healthStatus}`,
|
|
103
|
+
latency
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return { success: true, latency };
|
|
107
|
+
} catch (error) {
|
|
108
|
+
import_ui_builder_utils.logger.error("testStellarRpcConnection", "Connection test failed:", error);
|
|
109
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
110
|
+
return {
|
|
111
|
+
success: false,
|
|
112
|
+
error: `Connection timeout after ${timeoutMs}ms`
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
return await testWithFallbackMethod(rpcConfig, controller.signal, Date.now());
|
|
117
|
+
} catch {
|
|
118
|
+
return {
|
|
119
|
+
success: false,
|
|
120
|
+
error: error instanceof Error ? error.message : "Connection failed"
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
} finally {
|
|
124
|
+
clearTimeout(timeoutId);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async function testWithFallbackMethod(rpcConfig, signal, startTime) {
|
|
128
|
+
const response = await fetch(rpcConfig.url, {
|
|
129
|
+
method: "POST",
|
|
130
|
+
headers: {
|
|
131
|
+
"Content-Type": "application/json"
|
|
132
|
+
},
|
|
133
|
+
body: JSON.stringify({
|
|
134
|
+
jsonrpc: "2.0",
|
|
135
|
+
id: 1,
|
|
136
|
+
method: "getLatestLedger"
|
|
137
|
+
}),
|
|
138
|
+
signal
|
|
139
|
+
});
|
|
140
|
+
if (!response.ok) {
|
|
141
|
+
return { success: false, error: `HTTP error: ${response.status}` };
|
|
142
|
+
}
|
|
143
|
+
const data = await response.json();
|
|
144
|
+
const latency = Date.now() - startTime;
|
|
145
|
+
if (data.error) {
|
|
146
|
+
return {
|
|
147
|
+
success: false,
|
|
148
|
+
error: `Soroban RPC error: ${data.error.message || "Unknown RPC error"}`
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (data.result && data.result.sequence) {
|
|
152
|
+
return { success: true, latency };
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
success: false,
|
|
156
|
+
error: "Unexpected response format from Soroban RPC endpoint"
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/configuration/network-services.ts
|
|
161
|
+
function getStellarNetworkServiceForms() {
|
|
162
|
+
return [
|
|
163
|
+
{
|
|
164
|
+
id: "rpc",
|
|
165
|
+
label: "RPC Provider",
|
|
166
|
+
fields: [
|
|
167
|
+
{
|
|
168
|
+
id: "stellar-rpc-url",
|
|
169
|
+
name: "sorobanRpcUrl",
|
|
170
|
+
type: "text",
|
|
171
|
+
label: "Soroban RPC URL",
|
|
172
|
+
placeholder: "https://soroban.stellar.org",
|
|
173
|
+
validation: { required: true, pattern: "^https?://.+" },
|
|
174
|
+
width: "full"
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
];
|
|
179
|
+
}
|
|
180
|
+
async function validateStellarNetworkServiceConfig(serviceId, values) {
|
|
181
|
+
if (serviceId !== "rpc") return true;
|
|
182
|
+
const cfg = { url: String(values.sorobanRpcUrl || ""), isCustom: true };
|
|
183
|
+
return validateStellarRpcEndpoint(cfg);
|
|
184
|
+
}
|
|
185
|
+
async function testStellarNetworkServiceConnection(serviceId, values) {
|
|
186
|
+
if (serviceId !== "rpc") return { success: true };
|
|
187
|
+
const cfg = { url: String(values.sorobanRpcUrl || ""), isCustom: true };
|
|
188
|
+
return testStellarRpcConnection(cfg);
|
|
189
|
+
}
|
|
190
|
+
|
|
50
191
|
// src/contract/loader.ts
|
|
51
192
|
var StellarSdk2 = __toESM(require("@stellar/stellar-sdk"), 1);
|
|
52
|
-
var
|
|
193
|
+
var import_ui_builder_utils17 = require("@openzeppelin/ui-builder-utils");
|
|
53
194
|
|
|
54
195
|
// src/validation/address.ts
|
|
55
196
|
var import_stellar_sdk = require("@stellar/stellar-sdk");
|
|
@@ -132,7 +273,7 @@ function isValidAddress(address, addressType) {
|
|
|
132
273
|
}
|
|
133
274
|
|
|
134
275
|
// src/validation/eoa.ts
|
|
135
|
-
var
|
|
276
|
+
var import_ui_builder_utils2 = require("@openzeppelin/ui-builder-utils");
|
|
136
277
|
var SYSTEM_LOG_TAG = "StellarEoaValidator";
|
|
137
278
|
async function validateEoaConfig(config, walletStatus) {
|
|
138
279
|
if (!config.allowAny) {
|
|
@@ -147,7 +288,7 @@ async function validateEoaConfig(config, walletStatus) {
|
|
|
147
288
|
return `Connected wallet address (${walletStatus.address}) does not match the required specific Stellar address (${config.specificAddress}). Please connect the correct wallet.`;
|
|
148
289
|
}
|
|
149
290
|
} else if (walletStatus.isConnected && !walletStatus.address) {
|
|
150
|
-
|
|
291
|
+
import_ui_builder_utils2.logger.warn(
|
|
151
292
|
SYSTEM_LOG_TAG,
|
|
152
293
|
"Wallet is connected but address is unavailable for Stellar EOA validation."
|
|
153
294
|
);
|
|
@@ -187,11 +328,11 @@ function getStellarExplorerTxUrl(txHash, networkConfig) {
|
|
|
187
328
|
|
|
188
329
|
// src/mapping/struct-fields.ts
|
|
189
330
|
var import_stellar_sdk2 = require("@stellar/stellar-sdk");
|
|
190
|
-
var
|
|
331
|
+
var import_ui_builder_utils4 = require("@openzeppelin/ui-builder-utils");
|
|
191
332
|
|
|
192
333
|
// src/utils/type-detection.ts
|
|
193
334
|
var StellarSdk = __toESM(require("@stellar/stellar-sdk"), 1);
|
|
194
|
-
var
|
|
335
|
+
var import_ui_builder_utils3 = require("@openzeppelin/ui-builder-utils");
|
|
195
336
|
function extractSorobanTypeFromScSpec(scSpecType) {
|
|
196
337
|
try {
|
|
197
338
|
const typeSwitch = scSpecType.switch();
|
|
@@ -272,7 +413,7 @@ function extractSorobanTypeFromScSpec(scSpecType) {
|
|
|
272
413
|
return udtType.name().toString();
|
|
273
414
|
}
|
|
274
415
|
default:
|
|
275
|
-
|
|
416
|
+
import_ui_builder_utils3.logger.error("extractSorobanTypeFromScSpec", `\u{1F6A8} MISSING SCSPEC TYPE HANDLER \u{1F6A8}`, {
|
|
276
417
|
typeSwitchValue: typeSwitch.value,
|
|
277
418
|
typeSwitchName: typeSwitch.name,
|
|
278
419
|
rawScSpecType: scSpecType,
|
|
@@ -286,16 +427,16 @@ function extractSorobanTypeFromScSpec(scSpecType) {
|
|
|
286
427
|
value: typeSwitch.value,
|
|
287
428
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
288
429
|
};
|
|
289
|
-
if ((0,
|
|
430
|
+
if ((0, import_ui_builder_utils3.isDevelopmentOrTestEnvironment)()) {
|
|
290
431
|
throw new Error(
|
|
291
432
|
`Missing ScSpec type handler: ${typeSwitch.name} (value: ${typeSwitch.value}). Please add support for this type.`
|
|
292
433
|
);
|
|
293
434
|
}
|
|
294
|
-
|
|
435
|
+
import_ui_builder_utils3.logger.error("STELLAR_ADAPTER_MISSING_TYPE", "Missing ScSpec type handler:", errorReport);
|
|
295
436
|
return "unknown";
|
|
296
437
|
}
|
|
297
438
|
} catch (error) {
|
|
298
|
-
|
|
439
|
+
import_ui_builder_utils3.logger.error("extractSorobanTypeFromScSpec", "Failed to extract type:", error);
|
|
299
440
|
return "unknown";
|
|
300
441
|
}
|
|
301
442
|
}
|
|
@@ -347,7 +488,7 @@ function extractStructFields(entries, structName) {
|
|
|
347
488
|
}
|
|
348
489
|
return null;
|
|
349
490
|
} catch (error) {
|
|
350
|
-
|
|
491
|
+
import_ui_builder_utils4.logger.error(
|
|
351
492
|
"extractStructFields",
|
|
352
493
|
`Failed to extract struct fields for ${structName}:`,
|
|
353
494
|
error
|
|
@@ -372,22 +513,22 @@ function isStructType(entries, typeName) {
|
|
|
372
513
|
const isStruct = entryKind.value === import_stellar_sdk2.xdr.ScSpecEntryKind.scSpecEntryUdtStructV0().value;
|
|
373
514
|
return isStruct;
|
|
374
515
|
} catch (error) {
|
|
375
|
-
|
|
516
|
+
import_ui_builder_utils4.logger.error("isStructType", `Failed to check if ${typeName} is struct:`, error);
|
|
376
517
|
return false;
|
|
377
518
|
}
|
|
378
519
|
}
|
|
379
520
|
|
|
380
521
|
// src/query/handler.ts
|
|
381
522
|
var import_stellar_sdk9 = require("@stellar/stellar-sdk");
|
|
382
|
-
var
|
|
523
|
+
var import_ui_builder_utils12 = require("@openzeppelin/ui-builder-utils");
|
|
383
524
|
|
|
384
525
|
// src/transform/parsers/index.ts
|
|
385
526
|
var import_ui_builder_types3 = require("@openzeppelin/ui-builder-types");
|
|
386
|
-
var
|
|
527
|
+
var import_ui_builder_utils10 = require("@openzeppelin/ui-builder-utils");
|
|
387
528
|
|
|
388
529
|
// src/transform/parsers/generic-parser.ts
|
|
389
530
|
var import_ui_builder_types = require("@openzeppelin/ui-builder-types");
|
|
390
|
-
var
|
|
531
|
+
var import_ui_builder_utils5 = require("@openzeppelin/ui-builder-utils");
|
|
391
532
|
var SYSTEM_LOG_TAG2 = "GenericParser";
|
|
392
533
|
function parseGenericType(typeString) {
|
|
393
534
|
const match = typeString.match(/^(\w+)<(.*)>$/);
|
|
@@ -486,11 +627,11 @@ function parseGeneric(value, parameterType, parseInnerValue) {
|
|
|
486
627
|
return value;
|
|
487
628
|
}
|
|
488
629
|
default:
|
|
489
|
-
|
|
630
|
+
import_ui_builder_utils5.logger.warn(SYSTEM_LOG_TAG2, `Unknown generic type: ${baseType}`);
|
|
490
631
|
return null;
|
|
491
632
|
}
|
|
492
633
|
} catch (error) {
|
|
493
|
-
|
|
634
|
+
import_ui_builder_utils5.logger.error(SYSTEM_LOG_TAG2, `Failed to parse generic type ${parameterType}:`, error);
|
|
494
635
|
throw error;
|
|
495
636
|
}
|
|
496
637
|
}
|
|
@@ -501,7 +642,7 @@ function isGenericType(parameterType) {
|
|
|
501
642
|
|
|
502
643
|
// src/transform/parsers/primitive-parser.ts
|
|
503
644
|
var import_stellar_sdk3 = require("@stellar/stellar-sdk");
|
|
504
|
-
var
|
|
645
|
+
var import_ui_builder_utils6 = require("@openzeppelin/ui-builder-utils");
|
|
505
646
|
var SYSTEM_LOG_TAG3 = "PrimitiveParser";
|
|
506
647
|
function parsePrimitive(value, parameterType) {
|
|
507
648
|
try {
|
|
@@ -522,15 +663,15 @@ function parsePrimitive(value, parameterType) {
|
|
|
522
663
|
case "Bytes":
|
|
523
664
|
if (typeof value === "string") {
|
|
524
665
|
const cleanValue = value.startsWith("0x") ? value.slice(2) : value;
|
|
525
|
-
const encoding = (0,
|
|
526
|
-
return (0,
|
|
666
|
+
const encoding = (0, import_ui_builder_utils6.detectBytesEncoding)(cleanValue);
|
|
667
|
+
return (0, import_ui_builder_utils6.stringToBytes)(cleanValue, encoding);
|
|
527
668
|
}
|
|
528
669
|
throw new Error(`Bytes parameter must be a string, got ${typeof value}`);
|
|
529
670
|
// DataUrl: handle base64 encoded data (similar to Bytes)
|
|
530
671
|
case "DataUrl":
|
|
531
672
|
if (typeof value === "string") {
|
|
532
|
-
const encoding = (0,
|
|
533
|
-
return (0,
|
|
673
|
+
const encoding = (0, import_ui_builder_utils6.detectBytesEncoding)(value);
|
|
674
|
+
return (0, import_ui_builder_utils6.stringToBytes)(value, encoding);
|
|
534
675
|
}
|
|
535
676
|
throw new Error(`DataUrl parameter must be a string, got ${typeof value}`);
|
|
536
677
|
// Address: validate format
|
|
@@ -555,8 +696,8 @@ function parsePrimitive(value, parameterType) {
|
|
|
555
696
|
if (/^BytesN<\d+>$/.test(parameterType)) {
|
|
556
697
|
if (typeof value === "string") {
|
|
557
698
|
const cleanValue = value.startsWith("0x") ? value.slice(2) : value;
|
|
558
|
-
const encoding = (0,
|
|
559
|
-
return (0,
|
|
699
|
+
const encoding = (0, import_ui_builder_utils6.detectBytesEncoding)(cleanValue);
|
|
700
|
+
return (0, import_ui_builder_utils6.stringToBytes)(cleanValue, encoding);
|
|
560
701
|
}
|
|
561
702
|
throw new Error(`Bytes parameter must be a string, got ${typeof value}`);
|
|
562
703
|
}
|
|
@@ -575,7 +716,7 @@ function parsePrimitive(value, parameterType) {
|
|
|
575
716
|
return null;
|
|
576
717
|
}
|
|
577
718
|
} catch (error) {
|
|
578
|
-
|
|
719
|
+
import_ui_builder_utils6.logger.error(SYSTEM_LOG_TAG3, `Failed to parse primitive ${parameterType}:`, error);
|
|
579
720
|
throw error;
|
|
580
721
|
}
|
|
581
722
|
}
|
|
@@ -585,7 +726,7 @@ function isPrimitiveType(parameterType) {
|
|
|
585
726
|
|
|
586
727
|
// src/transform/parsers/complex-parser.ts
|
|
587
728
|
var import_stellar_sdk5 = require("@stellar/stellar-sdk");
|
|
588
|
-
var
|
|
729
|
+
var import_ui_builder_utils8 = require("@openzeppelin/ui-builder-utils");
|
|
589
730
|
|
|
590
731
|
// src/utils/safe-type-parser.ts
|
|
591
732
|
var PARSING_LIMITS = {
|
|
@@ -771,7 +912,7 @@ function convertStellarTypeToScValType(stellarType) {
|
|
|
771
912
|
|
|
772
913
|
// src/utils/input-parsing.ts
|
|
773
914
|
var import_stellar_sdk4 = require("@stellar/stellar-sdk");
|
|
774
|
-
var
|
|
915
|
+
var import_ui_builder_utils7 = require("@openzeppelin/ui-builder-utils");
|
|
775
916
|
var SYSTEM_LOG_TAG4 = "StellarInputParsingUtils";
|
|
776
917
|
function isMapArray(argValue) {
|
|
777
918
|
try {
|
|
@@ -796,13 +937,13 @@ function getScValFromPrimitive(v) {
|
|
|
796
937
|
}
|
|
797
938
|
if (v.type === "bytes") {
|
|
798
939
|
const stringValue = v.value;
|
|
799
|
-
const encoding = (0,
|
|
800
|
-
return (0, import_stellar_sdk4.nativeToScVal)((0,
|
|
940
|
+
const encoding = (0, import_ui_builder_utils7.detectBytesEncoding)(stringValue);
|
|
941
|
+
return (0, import_stellar_sdk4.nativeToScVal)((0, import_ui_builder_utils7.stringToBytes)(stringValue, encoding));
|
|
801
942
|
}
|
|
802
943
|
const typeHint = convertStellarTypeToScValType(v.type);
|
|
803
944
|
return (0, import_stellar_sdk4.nativeToScVal)(v.value, { type: typeHint });
|
|
804
945
|
} catch (error) {
|
|
805
|
-
|
|
946
|
+
import_ui_builder_utils7.logger.error(SYSTEM_LOG_TAG4, `Failed to convert primitive ${v.type}:`, error);
|
|
806
947
|
throw new Error(`Failed to convert primitive value of type ${v.type}: ${error}`);
|
|
807
948
|
}
|
|
808
949
|
}
|
|
@@ -849,7 +990,7 @@ function convertEnumToScVal(obj, scVals) {
|
|
|
849
990
|
const tupleVec = import_stellar_sdk4.xdr.ScVal.scvVec([tagSymbol, ...valuesVal]);
|
|
850
991
|
return tupleVec;
|
|
851
992
|
} catch (error) {
|
|
852
|
-
|
|
993
|
+
import_ui_builder_utils7.logger.error(SYSTEM_LOG_TAG4, "Failed to convert enum:", error);
|
|
853
994
|
throw new Error(`Failed to convert enum: ${error}`);
|
|
854
995
|
}
|
|
855
996
|
}
|
|
@@ -878,7 +1019,7 @@ function convertObjectToMap(mapArray) {
|
|
|
878
1019
|
}, {});
|
|
879
1020
|
return { mapVal, mapType };
|
|
880
1021
|
} catch (error) {
|
|
881
|
-
|
|
1022
|
+
import_ui_builder_utils7.logger.error(SYSTEM_LOG_TAG4, "Failed to convert map:", error);
|
|
882
1023
|
throw new Error(`Failed to convert map: ${error}`);
|
|
883
1024
|
}
|
|
884
1025
|
}
|
|
@@ -889,7 +1030,7 @@ var import_ui_builder_types2 = require("@openzeppelin/ui-builder-types");
|
|
|
889
1030
|
|
|
890
1031
|
// src/transform/parsers/struct-parser.ts
|
|
891
1032
|
var import_stellar_sdk6 = require("@stellar/stellar-sdk");
|
|
892
|
-
var
|
|
1033
|
+
var import_ui_builder_utils9 = require("@openzeppelin/ui-builder-utils");
|
|
893
1034
|
var SYSTEM_LOG_TAG5 = "StructParser";
|
|
894
1035
|
function needsParsing(value, fieldType) {
|
|
895
1036
|
if ((fieldType === "Bytes" || fieldType.startsWith("BytesN<")) && value instanceof Uint8Array) {
|
|
@@ -910,7 +1051,7 @@ function needsParsing(value, fieldType) {
|
|
|
910
1051
|
if (typeof value === "string") {
|
|
911
1052
|
return true;
|
|
912
1053
|
}
|
|
913
|
-
if ((0,
|
|
1054
|
+
if ((0, import_ui_builder_utils9.isPlainObject)(value)) {
|
|
914
1055
|
return true;
|
|
915
1056
|
}
|
|
916
1057
|
return false;
|
|
@@ -966,13 +1107,13 @@ function convertStructToScVal(structObj, parameterType, paramSchema, parseInnerV
|
|
|
966
1107
|
);
|
|
967
1108
|
}
|
|
968
1109
|
}
|
|
969
|
-
|
|
1110
|
+
import_ui_builder_utils9.logger.debug(SYSTEM_LOG_TAG5, "convertStructToScVal final values:", {
|
|
970
1111
|
parameterType,
|
|
971
1112
|
convertedValue,
|
|
972
1113
|
typeHints
|
|
973
1114
|
});
|
|
974
1115
|
const scVal = (0, import_stellar_sdk6.nativeToScVal)(convertedValue, { type: typeHints });
|
|
975
|
-
|
|
1116
|
+
import_ui_builder_utils9.logger.debug(SYSTEM_LOG_TAG5, "convertStructToScVal generated ScVal:", {
|
|
976
1117
|
parameterType,
|
|
977
1118
|
scValType: scVal.switch().name,
|
|
978
1119
|
scValValue: scVal.value()
|
|
@@ -980,7 +1121,7 @@ function convertStructToScVal(structObj, parameterType, paramSchema, parseInnerV
|
|
|
980
1121
|
return scVal;
|
|
981
1122
|
}
|
|
982
1123
|
function isStructType2(value, parameterType) {
|
|
983
|
-
if (!(0,
|
|
1124
|
+
if (!(0, import_ui_builder_utils9.isPlainObject)(value)) {
|
|
984
1125
|
return false;
|
|
985
1126
|
}
|
|
986
1127
|
const genericInfo = parseGenericType(parameterType);
|
|
@@ -1126,7 +1267,7 @@ function parseStellarInput(value, parameterType) {
|
|
|
1126
1267
|
if ((0, import_ui_builder_types3.isEnumValue)(value) && isLikelyEnumType(parameterType)) {
|
|
1127
1268
|
return value;
|
|
1128
1269
|
}
|
|
1129
|
-
if ((0,
|
|
1270
|
+
if ((0, import_ui_builder_utils10.isPlainObject)(value)) {
|
|
1130
1271
|
return value;
|
|
1131
1272
|
}
|
|
1132
1273
|
if (typeof value === "string" || typeof value === "number") {
|
|
@@ -1134,14 +1275,14 @@ function parseStellarInput(value, parameterType) {
|
|
|
1134
1275
|
}
|
|
1135
1276
|
throw new Error(`Unsupported parameter type: ${parameterType} with value type ${typeof value}`);
|
|
1136
1277
|
} catch (error) {
|
|
1137
|
-
|
|
1278
|
+
import_ui_builder_utils10.logger.error(SYSTEM_LOG_TAG6, "Failed to parse Stellar input:", error);
|
|
1138
1279
|
throw error;
|
|
1139
1280
|
}
|
|
1140
1281
|
}
|
|
1141
1282
|
|
|
1142
1283
|
// src/transform/output-formatter.ts
|
|
1143
1284
|
var import_stellar_sdk8 = require("@stellar/stellar-sdk");
|
|
1144
|
-
var
|
|
1285
|
+
var import_ui_builder_utils11 = require("@openzeppelin/ui-builder-utils");
|
|
1145
1286
|
|
|
1146
1287
|
// src/types/artifacts.ts
|
|
1147
1288
|
function isStellarContractArtifacts(obj) {
|
|
@@ -1164,7 +1305,7 @@ function validateAndConvertStellarArtifacts(source) {
|
|
|
1164
1305
|
// src/transform/output-formatter.ts
|
|
1165
1306
|
function formatStellarFunctionResult(result, functionDetails) {
|
|
1166
1307
|
if (!functionDetails.outputs || !Array.isArray(functionDetails.outputs)) {
|
|
1167
|
-
|
|
1308
|
+
import_ui_builder_utils11.logger.warn(
|
|
1168
1309
|
"formatStellarFunctionResult",
|
|
1169
1310
|
`Output definition missing or invalid for function ${functionDetails.name}.`
|
|
1170
1311
|
);
|
|
@@ -1186,7 +1327,7 @@ function formatStellarFunctionResult(result, functionDetails) {
|
|
|
1186
1327
|
valueToFormat = new Uint8Array(valueToFormat);
|
|
1187
1328
|
}
|
|
1188
1329
|
} catch (error) {
|
|
1189
|
-
|
|
1330
|
+
import_ui_builder_utils11.logger.error("formatStellarFunctionResult", "Failed to convert ScVal to native", {
|
|
1190
1331
|
functionName: functionDetails.name,
|
|
1191
1332
|
error
|
|
1192
1333
|
});
|
|
@@ -1204,7 +1345,7 @@ function formatStellarFunctionResult(result, functionDetails) {
|
|
|
1204
1345
|
} else if (typeof valueToFormat === "boolean") {
|
|
1205
1346
|
return String(valueToFormat);
|
|
1206
1347
|
} else if (valueToFormat instanceof Uint8Array) {
|
|
1207
|
-
return (0,
|
|
1348
|
+
return (0, import_ui_builder_utils11.bytesToHex)(valueToFormat, true);
|
|
1208
1349
|
} else if (Array.isArray(valueToFormat)) {
|
|
1209
1350
|
if (valueToFormat.length === 0) {
|
|
1210
1351
|
return "[]";
|
|
@@ -1227,7 +1368,7 @@ function formatStellarFunctionResult(result, functionDetails) {
|
|
|
1227
1368
|
}
|
|
1228
1369
|
} catch (error) {
|
|
1229
1370
|
const errorMessage = `Error formatting result for ${functionDetails.name}: ${error.message}`;
|
|
1230
|
-
|
|
1371
|
+
import_ui_builder_utils11.logger.error("formatStellarFunctionResult", errorMessage, {
|
|
1231
1372
|
functionName: functionDetails.name,
|
|
1232
1373
|
result,
|
|
1233
1374
|
error
|
|
@@ -1259,12 +1400,12 @@ function getStellarWritableFunctions(contractSchema) {
|
|
|
1259
1400
|
|
|
1260
1401
|
// src/query/handler.ts
|
|
1261
1402
|
function getSorobanRpcServer(networkConfig) {
|
|
1262
|
-
const customRpcConfig =
|
|
1403
|
+
const customRpcConfig = import_ui_builder_utils12.userRpcConfigService.getUserRpcConfig(networkConfig.id);
|
|
1263
1404
|
const rpcUrl = customRpcConfig?.url || networkConfig.sorobanRpcUrl;
|
|
1264
1405
|
if (!rpcUrl) {
|
|
1265
1406
|
throw new Error(`No Soroban RPC URL available for network ${networkConfig.name}`);
|
|
1266
1407
|
}
|
|
1267
|
-
|
|
1408
|
+
import_ui_builder_utils12.logger.info(
|
|
1268
1409
|
"getSorobanRpcServer",
|
|
1269
1410
|
`Creating Soroban RPC server for ${networkConfig.name} using RPC: ${rpcUrl}`
|
|
1270
1411
|
);
|
|
@@ -1295,12 +1436,12 @@ async function createSimulationTransaction(contractAddress, functionName, args,
|
|
|
1295
1436
|
}).addOperation(contract2.call(functionName, ...scValArgs)).setTimeout(30);
|
|
1296
1437
|
return transaction;
|
|
1297
1438
|
} catch (error) {
|
|
1298
|
-
|
|
1439
|
+
import_ui_builder_utils12.logger.error("createSimulationTransaction", "Failed to create simulation transaction:", error);
|
|
1299
1440
|
throw new Error(`Failed to create simulation transaction: ${error.message}`);
|
|
1300
1441
|
}
|
|
1301
1442
|
}
|
|
1302
1443
|
async function checkStellarFunctionStateMutability(contractAddress, functionName, networkConfig, inputTypes = []) {
|
|
1303
|
-
|
|
1444
|
+
import_ui_builder_utils12.logger.info(
|
|
1304
1445
|
"checkStellarFunctionStateMutability",
|
|
1305
1446
|
`Checking state mutability for function: ${functionName} on ${contractAddress}`
|
|
1306
1447
|
);
|
|
@@ -1342,7 +1483,7 @@ async function checkStellarFunctionStateMutability(contractAddress, functionName
|
|
|
1342
1483
|
networkConfig
|
|
1343
1484
|
);
|
|
1344
1485
|
const transaction = transactionBuilder.build();
|
|
1345
|
-
|
|
1486
|
+
import_ui_builder_utils12.logger.debug(
|
|
1346
1487
|
"checkStellarFunctionStateMutability",
|
|
1347
1488
|
`[Check ${functionName}] Simulating transaction for state mutability check`
|
|
1348
1489
|
);
|
|
@@ -1350,7 +1491,7 @@ async function checkStellarFunctionStateMutability(contractAddress, functionName
|
|
|
1350
1491
|
try {
|
|
1351
1492
|
simulationResult = await rpcServer.simulateTransaction(transaction);
|
|
1352
1493
|
} catch (simulationError) {
|
|
1353
|
-
|
|
1494
|
+
import_ui_builder_utils12.logger.warn(
|
|
1354
1495
|
"checkStellarFunctionStateMutability",
|
|
1355
1496
|
`[Check ${functionName}] Simulation failed, assuming function modifies state:`,
|
|
1356
1497
|
simulationError
|
|
@@ -1358,7 +1499,7 @@ async function checkStellarFunctionStateMutability(contractAddress, functionName
|
|
|
1358
1499
|
return true;
|
|
1359
1500
|
}
|
|
1360
1501
|
if (import_stellar_sdk9.rpc.Api.isSimulationError(simulationResult)) {
|
|
1361
|
-
|
|
1502
|
+
import_ui_builder_utils12.logger.warn(
|
|
1362
1503
|
"checkStellarFunctionStateMutability",
|
|
1363
1504
|
`[Check ${functionName}] Simulation error, assuming function modifies state:`,
|
|
1364
1505
|
simulationResult.error
|
|
@@ -1366,7 +1507,7 @@ async function checkStellarFunctionStateMutability(contractAddress, functionName
|
|
|
1366
1507
|
return true;
|
|
1367
1508
|
}
|
|
1368
1509
|
const hasStateChanges = simulationResult.stateChanges && simulationResult.stateChanges.length > 0;
|
|
1369
|
-
|
|
1510
|
+
import_ui_builder_utils12.logger.info(
|
|
1370
1511
|
"checkStellarFunctionStateMutability",
|
|
1371
1512
|
`[Check ${functionName}] State mutability check complete:`,
|
|
1372
1513
|
{
|
|
@@ -1377,7 +1518,7 @@ async function checkStellarFunctionStateMutability(contractAddress, functionName
|
|
|
1377
1518
|
);
|
|
1378
1519
|
return Boolean(hasStateChanges);
|
|
1379
1520
|
} catch (error) {
|
|
1380
|
-
|
|
1521
|
+
import_ui_builder_utils12.logger.warn(
|
|
1381
1522
|
"checkStellarFunctionStateMutability",
|
|
1382
1523
|
`Failed to check state mutability for ${functionName}, assuming it modifies state:`,
|
|
1383
1524
|
error
|
|
@@ -1386,7 +1527,7 @@ async function checkStellarFunctionStateMutability(contractAddress, functionName
|
|
|
1386
1527
|
}
|
|
1387
1528
|
}
|
|
1388
1529
|
async function queryStellarViewFunction(contractAddress, functionId, networkConfig, params = [], contractSchema, loadContractFn) {
|
|
1389
|
-
|
|
1530
|
+
import_ui_builder_utils12.logger.info(
|
|
1390
1531
|
"queryStellarViewFunction",
|
|
1391
1532
|
`Querying Stellar view function: ${functionId} on ${contractAddress} (${networkConfig.name})`,
|
|
1392
1533
|
{ params }
|
|
@@ -1428,7 +1569,7 @@ async function queryStellarViewFunction(contractAddress, functionId, networkConf
|
|
|
1428
1569
|
const rawValue = params[index];
|
|
1429
1570
|
return parseStellarInput(rawValue, inputParam.type);
|
|
1430
1571
|
});
|
|
1431
|
-
|
|
1572
|
+
import_ui_builder_utils12.logger.debug("queryStellarViewFunction", "Parsed Args for contract call:", args);
|
|
1432
1573
|
const paramTypes = expectedInputs.map((input) => input.type);
|
|
1433
1574
|
const transactionBuilder = await createSimulationTransaction(
|
|
1434
1575
|
contractAddress,
|
|
@@ -1438,7 +1579,7 @@ async function queryStellarViewFunction(contractAddress, functionId, networkConf
|
|
|
1438
1579
|
stellarConfig
|
|
1439
1580
|
);
|
|
1440
1581
|
const transaction = transactionBuilder.build();
|
|
1441
|
-
|
|
1582
|
+
import_ui_builder_utils12.logger.debug(
|
|
1442
1583
|
"queryStellarViewFunction",
|
|
1443
1584
|
`[Query ${functionDetails.name}] Simulating transaction:`,
|
|
1444
1585
|
transaction.toXDR()
|
|
@@ -1447,7 +1588,7 @@ async function queryStellarViewFunction(contractAddress, functionId, networkConf
|
|
|
1447
1588
|
try {
|
|
1448
1589
|
simulationResult = await rpcServer.simulateTransaction(transaction);
|
|
1449
1590
|
} catch (simulationError) {
|
|
1450
|
-
|
|
1591
|
+
import_ui_builder_utils12.logger.error(
|
|
1451
1592
|
"queryStellarViewFunction",
|
|
1452
1593
|
`[Query ${functionDetails.name}] Simulation failed:`,
|
|
1453
1594
|
simulationError
|
|
@@ -1457,7 +1598,7 @@ async function queryStellarViewFunction(contractAddress, functionId, networkConf
|
|
|
1457
1598
|
);
|
|
1458
1599
|
}
|
|
1459
1600
|
if (import_stellar_sdk9.rpc.Api.isSimulationError(simulationResult)) {
|
|
1460
|
-
|
|
1601
|
+
import_ui_builder_utils12.logger.error(
|
|
1461
1602
|
"queryStellarViewFunction",
|
|
1462
1603
|
`[Query ${functionDetails.name}] Simulation error:`,
|
|
1463
1604
|
simulationResult.error
|
|
@@ -1468,13 +1609,13 @@ async function queryStellarViewFunction(contractAddress, functionId, networkConf
|
|
|
1468
1609
|
throw new Error(`No result returned from contract simulation for ${functionDetails.name}`);
|
|
1469
1610
|
}
|
|
1470
1611
|
const rawResult = simulationResult.result.retval;
|
|
1471
|
-
|
|
1612
|
+
import_ui_builder_utils12.logger.debug(
|
|
1472
1613
|
"queryStellarViewFunction",
|
|
1473
1614
|
`[Query ${functionDetails.name}] Raw simulation result:`,
|
|
1474
1615
|
rawResult
|
|
1475
1616
|
);
|
|
1476
1617
|
const formattedResult = formatStellarFunctionResult(rawResult, functionDetails);
|
|
1477
|
-
|
|
1618
|
+
import_ui_builder_utils12.logger.info(
|
|
1478
1619
|
"queryStellarViewFunction",
|
|
1479
1620
|
`[Query ${functionDetails.name}] Formatted result:`,
|
|
1480
1621
|
formattedResult
|
|
@@ -1482,7 +1623,7 @@ async function queryStellarViewFunction(contractAddress, functionId, networkConf
|
|
|
1482
1623
|
return formattedResult;
|
|
1483
1624
|
} catch (error) {
|
|
1484
1625
|
const errorMessage = `Failed to query Stellar view function ${functionId} on network ${networkConfig.name}: ${error.message}`;
|
|
1485
|
-
|
|
1626
|
+
import_ui_builder_utils12.logger.error("queryStellarViewFunction", errorMessage, {
|
|
1486
1627
|
contractAddress,
|
|
1487
1628
|
functionId,
|
|
1488
1629
|
params,
|
|
@@ -1494,10 +1635,10 @@ async function queryStellarViewFunction(contractAddress, functionId, networkConf
|
|
|
1494
1635
|
}
|
|
1495
1636
|
|
|
1496
1637
|
// src/sac/spec-cache.ts
|
|
1497
|
-
var
|
|
1638
|
+
var import_ui_builder_utils15 = require("@openzeppelin/ui-builder-utils");
|
|
1498
1639
|
|
|
1499
1640
|
// src/sac/spec-source.ts
|
|
1500
|
-
var
|
|
1641
|
+
var import_ui_builder_utils13 = require("@openzeppelin/ui-builder-utils");
|
|
1501
1642
|
var DEFAULT_SPEC = {
|
|
1502
1643
|
repo: "stellar/stellar-asset-contract-spec",
|
|
1503
1644
|
path: "refs/heads/main",
|
|
@@ -1518,7 +1659,7 @@ async function fetchSacSpecJson(cfg = {}) {
|
|
|
1518
1659
|
}
|
|
1519
1660
|
return await res.text();
|
|
1520
1661
|
} catch (error) {
|
|
1521
|
-
|
|
1662
|
+
import_ui_builder_utils13.logger.error("stellar:sac:spec-source", "Failed to fetch SAC spec:", url, error);
|
|
1522
1663
|
throw new Error("Failed to load Stellar Asset Contract spec. Please try again later.");
|
|
1523
1664
|
}
|
|
1524
1665
|
}
|
|
@@ -1527,7 +1668,7 @@ async function fetchSacSpecJson(cfg = {}) {
|
|
|
1527
1668
|
var import_stellar_sdk10 = require("@stellar/stellar-sdk");
|
|
1528
1669
|
var import_lossless_json = require("lossless-json");
|
|
1529
1670
|
var import_package = __toESM(require("@stellar/stellar-xdr-json/package.json"), 1);
|
|
1530
|
-
var
|
|
1671
|
+
var import_ui_builder_utils14 = require("@openzeppelin/ui-builder-utils");
|
|
1531
1672
|
var stellarXdrJsonVersion = import_package.default.version ?? "23.0.0";
|
|
1532
1673
|
var CDN_WASM_URL = `https://unpkg.com/@stellar/stellar-xdr-json@${stellarXdrJsonVersion}/stellar_xdr_json_bg.wasm`;
|
|
1533
1674
|
var initialized = false;
|
|
@@ -1541,7 +1682,7 @@ async function ensureXdrJsonInitialized() {
|
|
|
1541
1682
|
encode = stellarXdrJson.encode;
|
|
1542
1683
|
initialized = true;
|
|
1543
1684
|
} catch (error) {
|
|
1544
|
-
|
|
1685
|
+
import_ui_builder_utils14.logger.error("stellar:sac:xdr", "Failed to initialize WASM module:", error);
|
|
1545
1686
|
throw error;
|
|
1546
1687
|
}
|
|
1547
1688
|
}
|
|
@@ -1563,7 +1704,7 @@ async function encodeSacSpecEntries(jsonString) {
|
|
|
1563
1704
|
}
|
|
1564
1705
|
return result;
|
|
1565
1706
|
} catch (error) {
|
|
1566
|
-
|
|
1707
|
+
import_ui_builder_utils14.logger.error("stellar:sac:xdr", "Failed to encode SAC spec to XDR", error);
|
|
1567
1708
|
throw new Error("Failed to process SAC spec.");
|
|
1568
1709
|
}
|
|
1569
1710
|
}
|
|
@@ -1578,7 +1719,7 @@ async function getSacSpecArtifacts(cfg = {}) {
|
|
|
1578
1719
|
const cacheKey = getSacSpecUrl(cfg);
|
|
1579
1720
|
const cached = sacSpecCache.get(cacheKey);
|
|
1580
1721
|
if (cached) {
|
|
1581
|
-
|
|
1722
|
+
import_ui_builder_utils15.logger.debug("stellar:sac:spec-cache", "Returning cached SAC spec artifacts");
|
|
1582
1723
|
return cached;
|
|
1583
1724
|
}
|
|
1584
1725
|
const inflight = sacSpecInflight.get(cacheKey);
|
|
@@ -1595,7 +1736,7 @@ async function getSacSpecArtifacts(cfg = {}) {
|
|
|
1595
1736
|
};
|
|
1596
1737
|
sacSpecCache.set(cacheKey, entry);
|
|
1597
1738
|
sacSpecInflight.delete(cacheKey);
|
|
1598
|
-
|
|
1739
|
+
import_ui_builder_utils15.logger.debug("stellar:sac:spec-cache", "Cached SAC spec artifacts for future re-use");
|
|
1599
1740
|
return entry;
|
|
1600
1741
|
})().catch((error) => {
|
|
1601
1742
|
sacSpecInflight.delete(cacheKey);
|
|
@@ -1607,9 +1748,9 @@ async function getSacSpecArtifacts(cfg = {}) {
|
|
|
1607
1748
|
|
|
1608
1749
|
// src/contract/type.ts
|
|
1609
1750
|
var import_stellar_sdk11 = require("@stellar/stellar-sdk");
|
|
1610
|
-
var
|
|
1751
|
+
var import_ui_builder_utils16 = require("@openzeppelin/ui-builder-utils");
|
|
1611
1752
|
function getSorobanRpcServer2(networkConfig) {
|
|
1612
|
-
const customRpcConfig =
|
|
1753
|
+
const customRpcConfig = import_ui_builder_utils16.userRpcConfigService.getUserRpcConfig(networkConfig.id);
|
|
1613
1754
|
const rpcUrl = customRpcConfig?.url || networkConfig.sorobanRpcUrl;
|
|
1614
1755
|
if (!rpcUrl) {
|
|
1615
1756
|
throw new Error(`No Soroban RPC URL available for network ${networkConfig.name}`);
|
|
@@ -1640,7 +1781,7 @@ async function getStellarContractType(contractId, networkConfig) {
|
|
|
1640
1781
|
if (detected === execStellarAssetType) return "contractExecutableStellarAsset";
|
|
1641
1782
|
return null;
|
|
1642
1783
|
} catch (error) {
|
|
1643
|
-
|
|
1784
|
+
import_ui_builder_utils16.logger.error("stellar:contract-type", "Failed to detect contract type:", error);
|
|
1644
1785
|
throw new Error(
|
|
1645
1786
|
`Something went wrong getting contract type by contract ID. ${error.message}`
|
|
1646
1787
|
);
|
|
@@ -1649,7 +1790,7 @@ async function getStellarContractType(contractId, networkConfig) {
|
|
|
1649
1790
|
|
|
1650
1791
|
// src/contract/loader.ts
|
|
1651
1792
|
async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
1652
|
-
|
|
1793
|
+
import_ui_builder_utils17.logger.info("loadStellarContractFromAddress", "Loading contract:", {
|
|
1653
1794
|
contractAddress,
|
|
1654
1795
|
network: networkConfig.name,
|
|
1655
1796
|
rpcUrl: networkConfig.sorobanRpcUrl,
|
|
@@ -1680,7 +1821,7 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1680
1821
|
};
|
|
1681
1822
|
}
|
|
1682
1823
|
} catch (e) {
|
|
1683
|
-
|
|
1824
|
+
import_ui_builder_utils17.logger.warn(
|
|
1684
1825
|
"loadStellarContractFromAddress",
|
|
1685
1826
|
"SAC detection failed, falling back to regular client:",
|
|
1686
1827
|
e
|
|
@@ -1697,12 +1838,12 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1697
1838
|
const message = e?.message || String(e);
|
|
1698
1839
|
if (message.includes("Cannot destructure property 'length'")) {
|
|
1699
1840
|
const friendly = "Unable to fetch contract metadata from RPC. The contract appears to have no published Wasm/definition on this network.";
|
|
1700
|
-
|
|
1841
|
+
import_ui_builder_utils17.logger.error("loadStellarContractFromAddress", friendly);
|
|
1701
1842
|
throw new Error(`NO_WASM: ${friendly}`);
|
|
1702
1843
|
}
|
|
1703
1844
|
throw e;
|
|
1704
1845
|
}
|
|
1705
|
-
|
|
1846
|
+
import_ui_builder_utils17.logger.info("loadStellarContractFromAddress", "Contract client created successfully");
|
|
1706
1847
|
let specEntries = [];
|
|
1707
1848
|
try {
|
|
1708
1849
|
if (contractClient.spec && typeof contractClient.spec === "object") {
|
|
@@ -1717,20 +1858,20 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1717
1858
|
try {
|
|
1718
1859
|
specEntries = spec.entries();
|
|
1719
1860
|
} catch (e) {
|
|
1720
|
-
|
|
1861
|
+
import_ui_builder_utils17.logger.warn("loadStellarContractFromAddress", "entries() method failed:", e);
|
|
1721
1862
|
}
|
|
1722
1863
|
}
|
|
1723
1864
|
if (specEntries.length === 0 && typeof spec.entries === "function") {
|
|
1724
1865
|
try {
|
|
1725
1866
|
specEntries = spec.entries();
|
|
1726
1867
|
} catch (e) {
|
|
1727
|
-
|
|
1868
|
+
import_ui_builder_utils17.logger.warn("loadStellarContractFromAddress", "direct entries() method failed:", e);
|
|
1728
1869
|
}
|
|
1729
1870
|
}
|
|
1730
|
-
|
|
1871
|
+
import_ui_builder_utils17.logger.info("loadStellarContractFromAddress", `Found ${specEntries.length} spec entries`);
|
|
1731
1872
|
}
|
|
1732
1873
|
} catch (specError) {
|
|
1733
|
-
|
|
1874
|
+
import_ui_builder_utils17.logger.warn("loadStellarContractFromAddress", "Could not extract spec entries:", specError);
|
|
1734
1875
|
}
|
|
1735
1876
|
const functions = await extractFunctionsFromSpec(
|
|
1736
1877
|
contractClient.spec,
|
|
@@ -1738,7 +1879,7 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1738
1879
|
specEntries,
|
|
1739
1880
|
networkConfig
|
|
1740
1881
|
);
|
|
1741
|
-
|
|
1882
|
+
import_ui_builder_utils17.logger.info(
|
|
1742
1883
|
"loadStellarContractFromAddress",
|
|
1743
1884
|
`Successfully extracted ${functions.length} functions`
|
|
1744
1885
|
);
|
|
@@ -1753,28 +1894,28 @@ async function loadStellarContractFromAddress(contractAddress, networkConfig) {
|
|
|
1753
1894
|
} catch (error) {
|
|
1754
1895
|
const msg = error?.message || String(error);
|
|
1755
1896
|
if (msg.startsWith("NO_WASM:")) {
|
|
1756
|
-
|
|
1897
|
+
import_ui_builder_utils17.logger.error("loadStellarContractFromAddress", msg);
|
|
1757
1898
|
throw new Error(msg);
|
|
1758
1899
|
}
|
|
1759
|
-
|
|
1900
|
+
import_ui_builder_utils17.logger.error("loadStellarContractFromAddress", "Failed to load contract:", error);
|
|
1760
1901
|
throw new Error(`Failed to load contract: ${msg}`);
|
|
1761
1902
|
}
|
|
1762
1903
|
}
|
|
1763
1904
|
async function extractFunctionsFromSpec(spec, contractAddress, specEntries, networkConfig) {
|
|
1764
1905
|
try {
|
|
1765
1906
|
const specFunctions = spec.funcs();
|
|
1766
|
-
|
|
1907
|
+
import_ui_builder_utils17.logger.info("extractFunctionsFromSpec", `Found ${specFunctions.length} functions in spec`);
|
|
1767
1908
|
return await Promise.all(
|
|
1768
1909
|
specFunctions.map(async (func, index) => {
|
|
1769
1910
|
try {
|
|
1770
1911
|
const functionName = func.name().toString();
|
|
1771
|
-
|
|
1912
|
+
import_ui_builder_utils17.logger.info("extractFunctionsFromSpec", `Processing function: ${functionName}`);
|
|
1772
1913
|
const inputs = func.inputs().map((input, inputIndex) => {
|
|
1773
1914
|
try {
|
|
1774
1915
|
const inputName = input.name().toString();
|
|
1775
1916
|
const inputType = extractSorobanTypeFromScSpec(input.type());
|
|
1776
1917
|
if (inputType === "unknown") {
|
|
1777
|
-
|
|
1918
|
+
import_ui_builder_utils17.logger.warn(
|
|
1778
1919
|
"extractFunctionsFromSpec",
|
|
1779
1920
|
`Unknown type for parameter "${inputName}" in function "${functionName}"`
|
|
1780
1921
|
);
|
|
@@ -1784,12 +1925,12 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1784
1925
|
const structFields = extractStructFields(specEntries, inputType);
|
|
1785
1926
|
if (structFields && structFields.length > 0) {
|
|
1786
1927
|
components = structFields;
|
|
1787
|
-
|
|
1928
|
+
import_ui_builder_utils17.logger.debug(
|
|
1788
1929
|
"extractFunctionsFromSpec",
|
|
1789
1930
|
`Extracted ${structFields.length} fields for struct type "${inputType}": ${structFields.map((f) => `${f.name}:${f.type}`).join(", ")}`
|
|
1790
1931
|
);
|
|
1791
1932
|
} else {
|
|
1792
|
-
|
|
1933
|
+
import_ui_builder_utils17.logger.warn(
|
|
1793
1934
|
"extractFunctionsFromSpec",
|
|
1794
1935
|
`No fields extracted for struct "${inputType}"`
|
|
1795
1936
|
);
|
|
@@ -1801,7 +1942,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1801
1942
|
...components && { components }
|
|
1802
1943
|
};
|
|
1803
1944
|
} catch (error) {
|
|
1804
|
-
|
|
1945
|
+
import_ui_builder_utils17.logger.warn(
|
|
1805
1946
|
"extractFunctionsFromSpec",
|
|
1806
1947
|
`Failed to parse input ${inputIndex}:`,
|
|
1807
1948
|
error
|
|
@@ -1820,7 +1961,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1820
1961
|
type: outputType
|
|
1821
1962
|
};
|
|
1822
1963
|
} catch (error) {
|
|
1823
|
-
|
|
1964
|
+
import_ui_builder_utils17.logger.warn(
|
|
1824
1965
|
"extractFunctionsFromSpec",
|
|
1825
1966
|
`Failed to parse output ${outputIndex}:`,
|
|
1826
1967
|
error
|
|
@@ -1836,7 +1977,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1836
1977
|
if (networkConfig) {
|
|
1837
1978
|
try {
|
|
1838
1979
|
const inputTypes = inputs.map((input) => input.type);
|
|
1839
|
-
|
|
1980
|
+
import_ui_builder_utils17.logger.debug(
|
|
1840
1981
|
"extractFunctionsFromSpec",
|
|
1841
1982
|
`Checking state mutability for ${functionName} with input types: ${inputTypes.join(", ")}`
|
|
1842
1983
|
);
|
|
@@ -1847,20 +1988,20 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1847
1988
|
inputTypes
|
|
1848
1989
|
);
|
|
1849
1990
|
stateMutability = modifiesState ? "nonpayable" : "view";
|
|
1850
|
-
|
|
1991
|
+
import_ui_builder_utils17.logger.info(
|
|
1851
1992
|
"extractFunctionsFromSpec",
|
|
1852
1993
|
`Function ${functionName} state mutability determined:`,
|
|
1853
1994
|
{ modifiesState, stateMutability }
|
|
1854
1995
|
);
|
|
1855
1996
|
} catch (error) {
|
|
1856
|
-
|
|
1997
|
+
import_ui_builder_utils17.logger.warn(
|
|
1857
1998
|
"extractFunctionsFromSpec",
|
|
1858
1999
|
`Failed to determine state mutability for ${functionName}, assuming it modifies state:`,
|
|
1859
2000
|
error
|
|
1860
2001
|
);
|
|
1861
2002
|
}
|
|
1862
2003
|
} else {
|
|
1863
|
-
|
|
2004
|
+
import_ui_builder_utils17.logger.warn(
|
|
1864
2005
|
"extractFunctionsFromSpec",
|
|
1865
2006
|
`No network config provided for ${functionName}, assuming it modifies state`
|
|
1866
2007
|
);
|
|
@@ -1878,7 +2019,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1878
2019
|
stateMutability
|
|
1879
2020
|
};
|
|
1880
2021
|
} catch (error) {
|
|
1881
|
-
|
|
2022
|
+
import_ui_builder_utils17.logger.error("extractFunctionsFromSpec", `Failed to process function ${index}:`, error);
|
|
1882
2023
|
return {
|
|
1883
2024
|
id: `function_${index}`,
|
|
1884
2025
|
name: `function_${index}`,
|
|
@@ -1894,7 +2035,7 @@ async function extractFunctionsFromSpec(spec, contractAddress, specEntries, netw
|
|
|
1894
2035
|
})
|
|
1895
2036
|
);
|
|
1896
2037
|
} catch (error) {
|
|
1897
|
-
|
|
2038
|
+
import_ui_builder_utils17.logger.error("extractFunctionsFromSpec", "Failed to extract functions from spec:", error);
|
|
1898
2039
|
throw new Error(`Failed to extract functions: ${error.message}`);
|
|
1899
2040
|
}
|
|
1900
2041
|
}
|
|
@@ -2193,17 +2334,17 @@ var StellarRelayerOptions = ({ options, onChange }) => {
|
|
|
2193
2334
|
// src/transaction/relayer.ts
|
|
2194
2335
|
var import_stellar_sdk12 = require("@stellar/stellar-sdk");
|
|
2195
2336
|
var import_relayer_sdk = require("@openzeppelin/relayer-sdk");
|
|
2196
|
-
var
|
|
2337
|
+
var import_ui_builder_utils23 = require("@openzeppelin/ui-builder-utils");
|
|
2197
2338
|
|
|
2198
2339
|
// src/wallet/connection.ts
|
|
2199
|
-
var
|
|
2340
|
+
var import_ui_builder_utils22 = require("@openzeppelin/ui-builder-utils");
|
|
2200
2341
|
|
|
2201
2342
|
// src/wallet/utils/stellarWalletImplementationManager.ts
|
|
2202
|
-
var
|
|
2343
|
+
var import_ui_builder_utils19 = require("@openzeppelin/ui-builder-utils");
|
|
2203
2344
|
|
|
2204
2345
|
// src/wallet/implementation/wallets-kit-implementation.ts
|
|
2205
2346
|
var import_stellar_wallets_kit = require("@creit.tech/stellar-wallets-kit");
|
|
2206
|
-
var
|
|
2347
|
+
var import_ui_builder_utils18 = require("@openzeppelin/ui-builder-utils");
|
|
2207
2348
|
var LOG_SYSTEM = "StellarWalletImplementation";
|
|
2208
2349
|
var WalletsKitImplementation = class {
|
|
2209
2350
|
/**
|
|
@@ -2224,7 +2365,7 @@ var WalletsKitImplementation = class {
|
|
|
2224
2365
|
__publicField(this, "currentWalletId", null);
|
|
2225
2366
|
__publicField(this, "connectionStatusListeners", /* @__PURE__ */ new Set());
|
|
2226
2367
|
this.networkConfig = networkConfig || null;
|
|
2227
|
-
|
|
2368
|
+
import_ui_builder_utils18.logger.info(
|
|
2228
2369
|
LOG_SYSTEM,
|
|
2229
2370
|
"Constructor called. Initial anticipated kitName:",
|
|
2230
2371
|
initialUiKitConfig?.kitName,
|
|
@@ -2232,7 +2373,7 @@ var WalletsKitImplementation = class {
|
|
|
2232
2373
|
networkConfig?.name
|
|
2233
2374
|
);
|
|
2234
2375
|
this.initialized = true;
|
|
2235
|
-
|
|
2376
|
+
import_ui_builder_utils18.logger.info(
|
|
2236
2377
|
LOG_SYSTEM,
|
|
2237
2378
|
"StellarWalletImplementation instance initialized (StellarWalletsKit config creation deferred)."
|
|
2238
2379
|
);
|
|
@@ -2242,10 +2383,10 @@ var WalletsKitImplementation = class {
|
|
|
2242
2383
|
* @param config - The Stellar network configuration
|
|
2243
2384
|
*/
|
|
2244
2385
|
setNetworkConfig(config) {
|
|
2245
|
-
|
|
2386
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM, "Network config updated:", config.name);
|
|
2246
2387
|
this.networkConfig = config;
|
|
2247
2388
|
if (this.activeStellarKit || this.defaultInstanceKit) {
|
|
2248
|
-
|
|
2389
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM, "Active kits detected - may need reconfiguration for new network");
|
|
2249
2390
|
}
|
|
2250
2391
|
}
|
|
2251
2392
|
/**
|
|
@@ -2255,14 +2396,14 @@ var WalletsKitImplementation = class {
|
|
|
2255
2396
|
* @param kit - The StellarWalletsKit object to set as active, or null to clear it.
|
|
2256
2397
|
*/
|
|
2257
2398
|
setActiveStellarKit(kit) {
|
|
2258
|
-
|
|
2399
|
+
import_ui_builder_utils18.logger.info(
|
|
2259
2400
|
LOG_SYSTEM,
|
|
2260
2401
|
"setActiveStellarKit called with kit:",
|
|
2261
2402
|
kit ? "Valid StellarWalletsKit" : "Null"
|
|
2262
2403
|
);
|
|
2263
2404
|
this.activeStellarKit = kit;
|
|
2264
2405
|
if (this.unsubscribeFromStatusChanges) {
|
|
2265
|
-
|
|
2406
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM, "Re-establishing connection status monitoring with new kit");
|
|
2266
2407
|
}
|
|
2267
2408
|
}
|
|
2268
2409
|
/**
|
|
@@ -2271,14 +2412,14 @@ var WalletsKitImplementation = class {
|
|
|
2271
2412
|
* @returns A default StellarWalletsKit instance
|
|
2272
2413
|
*/
|
|
2273
2414
|
createDefaultKit() {
|
|
2274
|
-
|
|
2415
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM, "Creating default StellarWalletsKit instance");
|
|
2275
2416
|
const network = this.getWalletNetwork();
|
|
2276
2417
|
const kit = new import_stellar_wallets_kit.StellarWalletsKit({
|
|
2277
2418
|
network,
|
|
2278
2419
|
selectedWalletId: void 0,
|
|
2279
2420
|
modules: (0, import_stellar_wallets_kit.allowAllModules)()
|
|
2280
2421
|
});
|
|
2281
|
-
|
|
2422
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM, "Default StellarWalletsKit instance created");
|
|
2282
2423
|
return kit;
|
|
2283
2424
|
}
|
|
2284
2425
|
/**
|
|
@@ -2286,7 +2427,7 @@ var WalletsKitImplementation = class {
|
|
|
2286
2427
|
*/
|
|
2287
2428
|
getWalletNetwork() {
|
|
2288
2429
|
if (!this.networkConfig) {
|
|
2289
|
-
|
|
2430
|
+
import_ui_builder_utils18.logger.warn(LOG_SYSTEM, "No network config available, defaulting to TESTNET");
|
|
2290
2431
|
return import_stellar_wallets_kit.WalletNetwork.TESTNET;
|
|
2291
2432
|
}
|
|
2292
2433
|
return this.networkConfig.type === "mainnet" ? import_stellar_wallets_kit.WalletNetwork.PUBLIC : import_stellar_wallets_kit.WalletNetwork.TESTNET;
|
|
@@ -2304,7 +2445,7 @@ var WalletsKitImplementation = class {
|
|
|
2304
2445
|
*/
|
|
2305
2446
|
async getAvailableConnectors() {
|
|
2306
2447
|
if (!this.initialized) {
|
|
2307
|
-
|
|
2448
|
+
import_ui_builder_utils18.logger.warn(LOG_SYSTEM, "getAvailableConnectors called before initialization");
|
|
2308
2449
|
return [];
|
|
2309
2450
|
}
|
|
2310
2451
|
try {
|
|
@@ -2317,10 +2458,10 @@ var WalletsKitImplementation = class {
|
|
|
2317
2458
|
installed: wallet.isAvailable,
|
|
2318
2459
|
type: wallet.type || "browser"
|
|
2319
2460
|
}));
|
|
2320
|
-
|
|
2461
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM, `Found ${connectors.length} available wallet connectors`);
|
|
2321
2462
|
return connectors;
|
|
2322
2463
|
} catch (error) {
|
|
2323
|
-
|
|
2464
|
+
import_ui_builder_utils18.logger.error(LOG_SYSTEM, "Failed to get available connectors:", error);
|
|
2324
2465
|
return [];
|
|
2325
2466
|
}
|
|
2326
2467
|
}
|
|
@@ -2336,7 +2477,7 @@ var WalletsKitImplementation = class {
|
|
|
2336
2477
|
try {
|
|
2337
2478
|
const prevStatus = this.getWalletConnectionStatus();
|
|
2338
2479
|
const kit = this.getKitToUse();
|
|
2339
|
-
|
|
2480
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM, `Attempting to connect to wallet: ${connectorId}`);
|
|
2340
2481
|
kit.setWallet(connectorId);
|
|
2341
2482
|
const result = await kit.getAddress();
|
|
2342
2483
|
if (result.address) {
|
|
@@ -2344,7 +2485,7 @@ var WalletsKitImplementation = class {
|
|
|
2344
2485
|
this.currentWalletId = connectorId;
|
|
2345
2486
|
const newStatus = this.getWalletConnectionStatus();
|
|
2346
2487
|
this.notifyConnectionListeners(newStatus, prevStatus);
|
|
2347
|
-
|
|
2488
|
+
import_ui_builder_utils18.logger.info(
|
|
2348
2489
|
LOG_SYSTEM,
|
|
2349
2490
|
`Successfully connected to wallet: ${connectorId}, address: ${result.address}`
|
|
2350
2491
|
);
|
|
@@ -2360,7 +2501,7 @@ var WalletsKitImplementation = class {
|
|
|
2360
2501
|
};
|
|
2361
2502
|
}
|
|
2362
2503
|
} catch (error) {
|
|
2363
|
-
|
|
2504
|
+
import_ui_builder_utils18.logger.error(LOG_SYSTEM, `Failed to connect to wallet ${connectorId}:`, error);
|
|
2364
2505
|
return {
|
|
2365
2506
|
connected: false,
|
|
2366
2507
|
error: error instanceof Error ? error.message : "Unknown error occurred"
|
|
@@ -2377,15 +2518,15 @@ var WalletsKitImplementation = class {
|
|
|
2377
2518
|
}
|
|
2378
2519
|
try {
|
|
2379
2520
|
const prevStatus = this.getWalletConnectionStatus();
|
|
2380
|
-
|
|
2521
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM, "Disconnecting wallet");
|
|
2381
2522
|
this.currentAddress = null;
|
|
2382
2523
|
this.currentWalletId = null;
|
|
2383
2524
|
const newStatus = this.getWalletConnectionStatus();
|
|
2384
2525
|
this.notifyConnectionListeners(newStatus, prevStatus);
|
|
2385
|
-
|
|
2526
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM, "Successfully disconnected wallet");
|
|
2386
2527
|
return { disconnected: true };
|
|
2387
2528
|
} catch (error) {
|
|
2388
|
-
|
|
2529
|
+
import_ui_builder_utils18.logger.error(LOG_SYSTEM, "Failed to disconnect wallet:", error);
|
|
2389
2530
|
return {
|
|
2390
2531
|
disconnected: false,
|
|
2391
2532
|
error: error instanceof Error ? error.message : "Unknown error occurred"
|
|
@@ -2418,15 +2559,15 @@ var WalletsKitImplementation = class {
|
|
|
2418
2559
|
*/
|
|
2419
2560
|
onWalletConnectionChange(callback) {
|
|
2420
2561
|
if (!this.initialized) {
|
|
2421
|
-
|
|
2562
|
+
import_ui_builder_utils18.logger.warn(LOG_SYSTEM, "onWalletConnectionChange called before initialization. No-op.");
|
|
2422
2563
|
return () => {
|
|
2423
2564
|
};
|
|
2424
2565
|
}
|
|
2425
2566
|
this.connectionStatusListeners.add(callback);
|
|
2426
|
-
|
|
2567
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM, "Connection status listener added");
|
|
2427
2568
|
return () => {
|
|
2428
2569
|
this.connectionStatusListeners.delete(callback);
|
|
2429
|
-
|
|
2570
|
+
import_ui_builder_utils18.logger.debug(LOG_SYSTEM, "Connection status listener removed");
|
|
2430
2571
|
};
|
|
2431
2572
|
}
|
|
2432
2573
|
/**
|
|
@@ -2461,7 +2602,7 @@ var WalletsKitImplementation = class {
|
|
|
2461
2602
|
}
|
|
2462
2603
|
const kit = this.getKitToUse();
|
|
2463
2604
|
const networkPassphrase = this.getWalletNetwork();
|
|
2464
|
-
|
|
2605
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM, "Signing transaction with wallet");
|
|
2465
2606
|
return await kit.signTransaction(xdr13, {
|
|
2466
2607
|
address,
|
|
2467
2608
|
networkPassphrase
|
|
@@ -2475,7 +2616,7 @@ var WalletsKitImplementation = class {
|
|
|
2475
2616
|
try {
|
|
2476
2617
|
listener(currentStatus, previousStatus);
|
|
2477
2618
|
} catch (error) {
|
|
2478
|
-
|
|
2619
|
+
import_ui_builder_utils18.logger.error(LOG_SYSTEM, "Error in connection status listener:", String(error));
|
|
2479
2620
|
}
|
|
2480
2621
|
});
|
|
2481
2622
|
}
|
|
@@ -2488,7 +2629,7 @@ var WalletsKitImplementation = class {
|
|
|
2488
2629
|
this.unsubscribeFromStatusChanges = void 0;
|
|
2489
2630
|
}
|
|
2490
2631
|
this.connectionStatusListeners.clear();
|
|
2491
|
-
|
|
2632
|
+
import_ui_builder_utils18.logger.info(LOG_SYSTEM, "Cleanup completed");
|
|
2492
2633
|
}
|
|
2493
2634
|
};
|
|
2494
2635
|
|
|
@@ -2512,17 +2653,17 @@ async function getStellarWalletImplementation(networkConfig) {
|
|
|
2512
2653
|
}
|
|
2513
2654
|
walletImplementationPromise = (async () => {
|
|
2514
2655
|
try {
|
|
2515
|
-
|
|
2516
|
-
const initialUiKitConfig =
|
|
2656
|
+
import_ui_builder_utils19.logger.info(LOG_SYSTEM2, "Initializing StellarWalletImplementation singleton (async)...");
|
|
2657
|
+
const initialUiKitConfig = import_ui_builder_utils19.appConfigService.getTypedNestedConfig(
|
|
2517
2658
|
"walletui",
|
|
2518
2659
|
"config"
|
|
2519
2660
|
);
|
|
2520
2661
|
const instance = new WalletsKitImplementation(networkConfig, initialUiKitConfig);
|
|
2521
|
-
|
|
2662
|
+
import_ui_builder_utils19.logger.info(LOG_SYSTEM2, "WalletsKitImplementation singleton created (async).");
|
|
2522
2663
|
walletImplementationInstance = instance;
|
|
2523
2664
|
return instance;
|
|
2524
2665
|
} catch (error) {
|
|
2525
|
-
|
|
2666
|
+
import_ui_builder_utils19.logger.error(LOG_SYSTEM2, "Failed to initialize WalletsKitImplementation (async):", error);
|
|
2526
2667
|
const fallbackInstance = new WalletsKitImplementation(networkConfig);
|
|
2527
2668
|
walletImplementationInstance = fallbackInstance;
|
|
2528
2669
|
return fallbackInstance;
|
|
@@ -2532,7 +2673,7 @@ async function getStellarWalletImplementation(networkConfig) {
|
|
|
2532
2673
|
}
|
|
2533
2674
|
function getInitializedStellarWalletImplementation() {
|
|
2534
2675
|
if (!walletImplementationInstance) {
|
|
2535
|
-
|
|
2676
|
+
import_ui_builder_utils19.logger.warn(
|
|
2536
2677
|
LOG_SYSTEM2,
|
|
2537
2678
|
"getInitializedStellarWalletImplementation called before instance was ready."
|
|
2538
2679
|
);
|
|
@@ -2542,7 +2683,7 @@ function getInitializedStellarWalletImplementation() {
|
|
|
2542
2683
|
|
|
2543
2684
|
// src/wallet/stellar-wallets-kit/stellarUiKitManager.ts
|
|
2544
2685
|
var import_stellar_wallets_kit2 = require("@creit.tech/stellar-wallets-kit");
|
|
2545
|
-
var
|
|
2686
|
+
var import_ui_builder_utils20 = require("@openzeppelin/ui-builder-utils");
|
|
2546
2687
|
var getInitialState = () => ({
|
|
2547
2688
|
isConfigured: false,
|
|
2548
2689
|
isInitializing: false,
|
|
@@ -2579,13 +2720,13 @@ function setNetworkConfig(config) {
|
|
|
2579
2720
|
}
|
|
2580
2721
|
function getWalletNetwork(networkConfig) {
|
|
2581
2722
|
if (!networkConfig) {
|
|
2582
|
-
|
|
2723
|
+
import_ui_builder_utils20.logger.warn("StellarUiKitManager", "No network config available, defaulting to TESTNET");
|
|
2583
2724
|
return import_stellar_wallets_kit2.WalletNetwork.TESTNET;
|
|
2584
2725
|
}
|
|
2585
2726
|
return networkConfig.type === "mainnet" ? import_stellar_wallets_kit2.WalletNetwork.PUBLIC : import_stellar_wallets_kit2.WalletNetwork.TESTNET;
|
|
2586
2727
|
}
|
|
2587
2728
|
async function configure(newFullUiKitConfig) {
|
|
2588
|
-
|
|
2729
|
+
import_ui_builder_utils20.logger.info(
|
|
2589
2730
|
"StellarUiKitManager:configure",
|
|
2590
2731
|
"Configuring UI kit. New config:",
|
|
2591
2732
|
newFullUiKitConfig
|
|
@@ -2615,7 +2756,23 @@ async function configure(newFullUiKitConfig) {
|
|
|
2615
2756
|
state.kitProviderComponent = null;
|
|
2616
2757
|
state.isKitAssetsLoaded = true;
|
|
2617
2758
|
state.error = null;
|
|
2618
|
-
|
|
2759
|
+
if (state.networkConfig) {
|
|
2760
|
+
try {
|
|
2761
|
+
const impl = await getStellarWalletImplementation(state.networkConfig);
|
|
2762
|
+
impl.setActiveStellarKit(kit);
|
|
2763
|
+
import_ui_builder_utils20.logger.debug(
|
|
2764
|
+
"StellarUiKitManager:configure",
|
|
2765
|
+
"Active kit wired into wallet implementation for stellar-wallets-kit"
|
|
2766
|
+
);
|
|
2767
|
+
} catch (error) {
|
|
2768
|
+
import_ui_builder_utils20.logger.warn(
|
|
2769
|
+
"StellarUiKitManager:configure",
|
|
2770
|
+
"Failed to attach active kit to wallet implementation:",
|
|
2771
|
+
error
|
|
2772
|
+
);
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
import_ui_builder_utils20.logger.info(
|
|
2619
2776
|
"StellarUiKitManager:configure",
|
|
2620
2777
|
"Stellar Wallets Kit configured with built-in UI and all wallet modules"
|
|
2621
2778
|
);
|
|
@@ -2629,7 +2786,23 @@ async function configure(newFullUiKitConfig) {
|
|
|
2629
2786
|
state.kitProviderComponent = null;
|
|
2630
2787
|
state.isKitAssetsLoaded = true;
|
|
2631
2788
|
state.error = null;
|
|
2632
|
-
|
|
2789
|
+
if (state.networkConfig) {
|
|
2790
|
+
try {
|
|
2791
|
+
const impl = await getStellarWalletImplementation(state.networkConfig);
|
|
2792
|
+
impl.setActiveStellarKit(kit);
|
|
2793
|
+
import_ui_builder_utils20.logger.debug(
|
|
2794
|
+
"StellarUiKitManager:configure",
|
|
2795
|
+
"Active kit wired into wallet implementation for custom"
|
|
2796
|
+
);
|
|
2797
|
+
} catch (error) {
|
|
2798
|
+
import_ui_builder_utils20.logger.warn(
|
|
2799
|
+
"StellarUiKitManager:configure",
|
|
2800
|
+
"Failed to attach active kit to wallet implementation:",
|
|
2801
|
+
error
|
|
2802
|
+
);
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
import_ui_builder_utils20.logger.info(
|
|
2633
2806
|
"StellarUiKitManager:configure",
|
|
2634
2807
|
"Stellar Wallets Kit configured for custom UI components"
|
|
2635
2808
|
);
|
|
@@ -2638,7 +2811,23 @@ async function configure(newFullUiKitConfig) {
|
|
|
2638
2811
|
state.kitProviderComponent = null;
|
|
2639
2812
|
state.isKitAssetsLoaded = false;
|
|
2640
2813
|
state.error = null;
|
|
2641
|
-
|
|
2814
|
+
if (state.networkConfig) {
|
|
2815
|
+
try {
|
|
2816
|
+
const impl = await getStellarWalletImplementation(state.networkConfig);
|
|
2817
|
+
impl.setActiveStellarKit(null);
|
|
2818
|
+
import_ui_builder_utils20.logger.debug(
|
|
2819
|
+
"StellarUiKitManager:configure",
|
|
2820
|
+
"Active kit cleared from wallet implementation for none"
|
|
2821
|
+
);
|
|
2822
|
+
} catch (error) {
|
|
2823
|
+
import_ui_builder_utils20.logger.warn(
|
|
2824
|
+
"StellarUiKitManager:configure",
|
|
2825
|
+
"Failed to clear active kit from wallet implementation:",
|
|
2826
|
+
error
|
|
2827
|
+
);
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
import_ui_builder_utils20.logger.info("StellarUiKitManager:configure", 'UI kit set to "none", no wallet UI provided');
|
|
2642
2831
|
} else {
|
|
2643
2832
|
throw new Error(`Unknown UI kit name: ${newKitName}`);
|
|
2644
2833
|
}
|
|
@@ -2651,7 +2840,7 @@ async function configure(newFullUiKitConfig) {
|
|
|
2651
2840
|
};
|
|
2652
2841
|
notifyListeners();
|
|
2653
2842
|
} catch (error) {
|
|
2654
|
-
|
|
2843
|
+
import_ui_builder_utils20.logger.error("StellarUiKitManager:configure", "Failed to configure UI kit:", error);
|
|
2655
2844
|
state = {
|
|
2656
2845
|
...state,
|
|
2657
2846
|
isInitializing: false,
|
|
@@ -2685,9 +2874,7 @@ function generateStellarWalletsKitConfigFile(userConfig) {
|
|
|
2685
2874
|
import {
|
|
2686
2875
|
StellarWalletsKit,
|
|
2687
2876
|
WalletNetwork,
|
|
2688
|
-
allowAllModules
|
|
2689
|
-
WalletConnectModule,
|
|
2690
|
-
WalletConnectAllowedMethods
|
|
2877
|
+
allowAllModules
|
|
2691
2878
|
} from '@creit.tech/stellar-wallets-kit';
|
|
2692
2879
|
|
|
2693
2880
|
/**
|
|
@@ -2722,18 +2909,7 @@ export const stellarWalletsKitConfig = {
|
|
|
2722
2909
|
*/
|
|
2723
2910
|
export function createStellarWalletsKit(): StellarWalletsKit {
|
|
2724
2911
|
const modules = [
|
|
2725
|
-
...allowAllModules()
|
|
2726
|
-
${walletConnectProjectId ? `
|
|
2727
|
-
// WalletConnect module with custom configuration
|
|
2728
|
-
new WalletConnectModule({
|
|
2729
|
-
url: window.location.origin,
|
|
2730
|
-
projectId: stellarWalletsKitConfig.walletConnectProjectId,
|
|
2731
|
-
method: WalletConnectAllowedMethods.SIGN,
|
|
2732
|
-
description: stellarWalletsKitConfig.appName,
|
|
2733
|
-
name: stellarWalletsKitConfig.appName,
|
|
2734
|
-
icons: [],
|
|
2735
|
-
network: stellarWalletsKitConfig.network,
|
|
2736
|
-
}),` : ""}
|
|
2912
|
+
...allowAllModules()
|
|
2737
2913
|
];
|
|
2738
2914
|
|
|
2739
2915
|
return new StellarWalletsKit({
|
|
@@ -2755,7 +2931,7 @@ function generateStellarWalletsKitExportables(uiKitConfig) {
|
|
|
2755
2931
|
|
|
2756
2932
|
// src/wallet/stellar-wallets-kit/StellarWalletsKitConnectButton.tsx
|
|
2757
2933
|
var import_react3 = require("react");
|
|
2758
|
-
var
|
|
2934
|
+
var import_ui_builder_utils21 = require("@openzeppelin/ui-builder-utils");
|
|
2759
2935
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2760
2936
|
function StellarWalletsKitConnectButton() {
|
|
2761
2937
|
const containerRef = (0, import_react3.useRef)(null);
|
|
@@ -2763,7 +2939,7 @@ function StellarWalletsKitConnectButton() {
|
|
|
2763
2939
|
const state2 = stellarUiKitManager.getState();
|
|
2764
2940
|
const kit = state2.stellarKitProvider;
|
|
2765
2941
|
if (!kit || !containerRef.current) {
|
|
2766
|
-
|
|
2942
|
+
import_ui_builder_utils21.logger.error(
|
|
2767
2943
|
"StellarWalletsKitConnectButton",
|
|
2768
2944
|
"Kit not initialized or container not available"
|
|
2769
2945
|
);
|
|
@@ -2772,10 +2948,28 @@ function StellarWalletsKitConnectButton() {
|
|
|
2772
2948
|
kit.createButton({
|
|
2773
2949
|
container: containerRef.current,
|
|
2774
2950
|
onConnect: ({ address }) => {
|
|
2775
|
-
|
|
2951
|
+
import_ui_builder_utils21.logger.info("StellarWalletsKitConnectButton", `Connected to address: ${address}`);
|
|
2952
|
+
try {
|
|
2953
|
+
setStellarConnectedAddress(address ?? null);
|
|
2954
|
+
} catch (error) {
|
|
2955
|
+
import_ui_builder_utils21.logger.warn(
|
|
2956
|
+
"StellarWalletsKitConnectButton",
|
|
2957
|
+
"Failed to set connected address in adapter implementation:",
|
|
2958
|
+
error
|
|
2959
|
+
);
|
|
2960
|
+
}
|
|
2776
2961
|
},
|
|
2777
2962
|
onDisconnect: () => {
|
|
2778
|
-
|
|
2963
|
+
import_ui_builder_utils21.logger.info("StellarWalletsKitConnectButton", "Disconnected");
|
|
2964
|
+
try {
|
|
2965
|
+
setStellarConnectedAddress(null);
|
|
2966
|
+
} catch (error) {
|
|
2967
|
+
import_ui_builder_utils21.logger.warn(
|
|
2968
|
+
"StellarWalletsKitConnectButton",
|
|
2969
|
+
"Failed to clear connected address in adapter implementation:",
|
|
2970
|
+
error
|
|
2971
|
+
);
|
|
2972
|
+
}
|
|
2779
2973
|
},
|
|
2780
2974
|
buttonText: "Connect Wallet"
|
|
2781
2975
|
});
|
|
@@ -2784,10 +2978,10 @@ function StellarWalletsKitConnectButton() {
|
|
|
2784
2978
|
try {
|
|
2785
2979
|
kit.removeButton();
|
|
2786
2980
|
} catch (error) {
|
|
2787
|
-
|
|
2981
|
+
import_ui_builder_utils21.logger.warn("StellarWalletsKitConnectButton", "Error removing button:", error);
|
|
2788
2982
|
}
|
|
2789
2983
|
} else {
|
|
2790
|
-
|
|
2984
|
+
import_ui_builder_utils21.logger.warn(
|
|
2791
2985
|
"StellarWalletsKitConnectButton",
|
|
2792
2986
|
"removeButton method not available on kit instance"
|
|
2793
2987
|
);
|
|
@@ -2816,7 +3010,7 @@ async function disconnectStellarWallet() {
|
|
|
2816
3010
|
function getStellarWalletConnectionStatus() {
|
|
2817
3011
|
const impl = getInitializedStellarWalletImplementation();
|
|
2818
3012
|
if (!impl) {
|
|
2819
|
-
|
|
3013
|
+
import_ui_builder_utils22.logger.warn(
|
|
2820
3014
|
"getStellarWalletConnectionStatus",
|
|
2821
3015
|
"Wallet implementation not ready. Returning default disconnected state."
|
|
2822
3016
|
);
|
|
@@ -2835,10 +3029,21 @@ function getStellarWalletConnectionStatus() {
|
|
|
2835
3029
|
walletId: status.walletId
|
|
2836
3030
|
};
|
|
2837
3031
|
}
|
|
3032
|
+
function setStellarConnectedAddress(address, walletId) {
|
|
3033
|
+
const impl = getInitializedStellarWalletImplementation();
|
|
3034
|
+
if (impl) {
|
|
3035
|
+
impl.updateConnectionStatus(address, walletId);
|
|
3036
|
+
} else {
|
|
3037
|
+
import_ui_builder_utils22.logger.warn(
|
|
3038
|
+
"setStellarConnectedAddress",
|
|
3039
|
+
"Wallet implementation not ready. Cannot update connection status."
|
|
3040
|
+
);
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
2838
3043
|
function onStellarWalletConnectionChange(callback) {
|
|
2839
3044
|
const impl = getInitializedStellarWalletImplementation();
|
|
2840
3045
|
if (!impl) {
|
|
2841
|
-
|
|
3046
|
+
import_ui_builder_utils22.logger.warn(
|
|
2842
3047
|
"onStellarWalletConnectionChange",
|
|
2843
3048
|
"Wallet implementation not ready. Returning no-op."
|
|
2844
3049
|
);
|
|
@@ -2861,7 +3066,7 @@ function onStellarWalletConnectionChange(callback) {
|
|
|
2861
3066
|
try {
|
|
2862
3067
|
callback(currentStatus, previousStatus);
|
|
2863
3068
|
} catch (error) {
|
|
2864
|
-
|
|
3069
|
+
import_ui_builder_utils22.logger.error("Error in Stellar connection status listener:", String(error));
|
|
2865
3070
|
}
|
|
2866
3071
|
});
|
|
2867
3072
|
}
|
|
@@ -2906,7 +3111,7 @@ var RelayerExecutionStrategy = class {
|
|
|
2906
3111
|
* @throws If the API call fails or returns an unsuccessful response.
|
|
2907
3112
|
*/
|
|
2908
3113
|
async getStellarRelayers(serviceUrl, accessToken, networkConfig) {
|
|
2909
|
-
|
|
3114
|
+
import_ui_builder_utils23.logger.info(
|
|
2910
3115
|
"[StellarRelayer] Getting relayers with access token",
|
|
2911
3116
|
accessToken.slice(0, 5).padEnd(accessToken.length, "*")
|
|
2912
3117
|
);
|
|
@@ -2954,7 +3159,7 @@ var RelayerExecutionStrategy = class {
|
|
|
2954
3159
|
* @throws If any API call fails or returns an unsuccessful response.
|
|
2955
3160
|
*/
|
|
2956
3161
|
async getStellarRelayer(serviceUrl, accessToken, relayerId, _networkConfig) {
|
|
2957
|
-
|
|
3162
|
+
import_ui_builder_utils23.logger.info("[StellarRelayer] Getting detailed relayer info", relayerId);
|
|
2958
3163
|
const sdkConfig = new import_relayer_sdk.Configuration({
|
|
2959
3164
|
basePath: serviceUrl,
|
|
2960
3165
|
accessToken
|
|
@@ -2964,11 +3169,11 @@ var RelayerExecutionStrategy = class {
|
|
|
2964
3169
|
const [relayerResponse, balanceResponse, statusResponse] = await Promise.all([
|
|
2965
3170
|
relayersApi.getRelayer(relayerId),
|
|
2966
3171
|
relayersApi.getRelayerBalance(relayerId).catch((err) => {
|
|
2967
|
-
|
|
3172
|
+
import_ui_builder_utils23.logger.warn("[StellarRelayer] Failed to fetch balance", err);
|
|
2968
3173
|
return null;
|
|
2969
3174
|
}),
|
|
2970
3175
|
relayersApi.getRelayerStatus(relayerId).catch((err) => {
|
|
2971
|
-
|
|
3176
|
+
import_ui_builder_utils23.logger.warn("[StellarRelayer] Failed to fetch status", err);
|
|
2972
3177
|
return null;
|
|
2973
3178
|
})
|
|
2974
3179
|
]);
|
|
@@ -2990,7 +3195,7 @@ var RelayerExecutionStrategy = class {
|
|
|
2990
3195
|
const balanceInXlm = balanceInStroops / 1e7;
|
|
2991
3196
|
enhancedDetails.balance = `${balanceInXlm.toFixed(7)} XLM`;
|
|
2992
3197
|
} catch (error) {
|
|
2993
|
-
|
|
3198
|
+
import_ui_builder_utils23.logger.warn("[StellarRelayer] Failed to format balance, using raw value", String(error));
|
|
2994
3199
|
enhancedDetails.balance = String(balanceResponse.data.data.balance);
|
|
2995
3200
|
}
|
|
2996
3201
|
}
|
|
@@ -3009,13 +3214,13 @@ var RelayerExecutionStrategy = class {
|
|
|
3009
3214
|
}
|
|
3010
3215
|
}
|
|
3011
3216
|
}
|
|
3012
|
-
|
|
3217
|
+
import_ui_builder_utils23.logger.info(
|
|
3013
3218
|
"[StellarRelayer] Retrieved enhanced relayer details",
|
|
3014
3219
|
JSON.stringify(enhancedDetails)
|
|
3015
3220
|
);
|
|
3016
3221
|
return enhancedDetails;
|
|
3017
3222
|
} catch (error) {
|
|
3018
|
-
|
|
3223
|
+
import_ui_builder_utils23.logger.error(
|
|
3019
3224
|
"[StellarRelayer] Failed to get relayer details",
|
|
3020
3225
|
error instanceof Error ? error.message : String(error)
|
|
3021
3226
|
);
|
|
@@ -3271,10 +3476,10 @@ var RelayerExecutionStrategy = class {
|
|
|
3271
3476
|
};
|
|
3272
3477
|
|
|
3273
3478
|
// src/configuration/execution.ts
|
|
3274
|
-
var
|
|
3479
|
+
var import_ui_builder_utils24 = require("@openzeppelin/ui-builder-utils");
|
|
3275
3480
|
var SYSTEM_LOG_TAG7 = "adapter-stellar-execution-config";
|
|
3276
3481
|
async function getStellarSupportedExecutionMethods() {
|
|
3277
|
-
|
|
3482
|
+
import_ui_builder_utils24.logger.warn(
|
|
3278
3483
|
"adapter-stellar-execution-config",
|
|
3279
3484
|
"getStellarSupportedExecutionMethods is using placeholder implementation."
|
|
3280
3485
|
);
|
|
@@ -3300,11 +3505,11 @@ async function getStellarSupportedExecutionMethods() {
|
|
|
3300
3505
|
]);
|
|
3301
3506
|
}
|
|
3302
3507
|
async function _validateMultisigConfig(_config, _walletStatus) {
|
|
3303
|
-
|
|
3508
|
+
import_ui_builder_utils24.logger.info(SYSTEM_LOG_TAG7, "Multisig execution config validation: Not yet fully implemented.");
|
|
3304
3509
|
return true;
|
|
3305
3510
|
}
|
|
3306
3511
|
async function validateStellarExecutionConfig(config, walletStatus) {
|
|
3307
|
-
|
|
3512
|
+
import_ui_builder_utils24.logger.info(SYSTEM_LOG_TAG7, "Validating Stellar execution config:", { config, walletStatus });
|
|
3308
3513
|
switch (config.method) {
|
|
3309
3514
|
case "eoa":
|
|
3310
3515
|
return validateEoaConfig(config, walletStatus);
|
|
@@ -3314,7 +3519,7 @@ async function validateStellarExecutionConfig(config, walletStatus) {
|
|
|
3314
3519
|
return _validateMultisigConfig(config, walletStatus);
|
|
3315
3520
|
default: {
|
|
3316
3521
|
const unknownMethod = config.method;
|
|
3317
|
-
|
|
3522
|
+
import_ui_builder_utils24.logger.warn(
|
|
3318
3523
|
SYSTEM_LOG_TAG7,
|
|
3319
3524
|
`Unsupported execution method type encountered: ${unknownMethod}`
|
|
3320
3525
|
);
|
|
@@ -3323,116 +3528,6 @@ async function validateStellarExecutionConfig(config, walletStatus) {
|
|
|
3323
3528
|
}
|
|
3324
3529
|
}
|
|
3325
3530
|
|
|
3326
|
-
// src/configuration/rpc.ts
|
|
3327
|
-
var import_ui_builder_utils24 = require("@openzeppelin/ui-builder-utils");
|
|
3328
|
-
function validateStellarRpcEndpoint(rpcConfig) {
|
|
3329
|
-
try {
|
|
3330
|
-
if (!(0, import_ui_builder_utils24.isValidUrl)(rpcConfig.url)) {
|
|
3331
|
-
import_ui_builder_utils24.logger.error("validateStellarRpcEndpoint", `Invalid RPC URL format: ${rpcConfig.url}`);
|
|
3332
|
-
return false;
|
|
3333
|
-
}
|
|
3334
|
-
return true;
|
|
3335
|
-
} catch (error) {
|
|
3336
|
-
import_ui_builder_utils24.logger.error("validateStellarRpcEndpoint", "Error validating RPC endpoint:", error);
|
|
3337
|
-
return false;
|
|
3338
|
-
}
|
|
3339
|
-
}
|
|
3340
|
-
async function testStellarRpcConnection(rpcConfig, timeoutMs = 5e3) {
|
|
3341
|
-
if (!rpcConfig.url) {
|
|
3342
|
-
return { success: false, error: "Soroban RPC URL is required" };
|
|
3343
|
-
}
|
|
3344
|
-
const controller = new AbortController();
|
|
3345
|
-
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
3346
|
-
try {
|
|
3347
|
-
const startTime = Date.now();
|
|
3348
|
-
const response = await fetch(rpcConfig.url, {
|
|
3349
|
-
method: "POST",
|
|
3350
|
-
headers: {
|
|
3351
|
-
"Content-Type": "application/json"
|
|
3352
|
-
},
|
|
3353
|
-
body: JSON.stringify({
|
|
3354
|
-
jsonrpc: "2.0",
|
|
3355
|
-
id: 1,
|
|
3356
|
-
method: "getHealth"
|
|
3357
|
-
}),
|
|
3358
|
-
signal: controller.signal
|
|
3359
|
-
});
|
|
3360
|
-
if (!response.ok) {
|
|
3361
|
-
return { success: false, error: `HTTP error: ${response.status}` };
|
|
3362
|
-
}
|
|
3363
|
-
const data = await response.json();
|
|
3364
|
-
const latency = Date.now() - startTime;
|
|
3365
|
-
if (data.error) {
|
|
3366
|
-
return {
|
|
3367
|
-
success: false,
|
|
3368
|
-
error: `Soroban RPC error: ${data.error.message || "Unknown RPC error"}`
|
|
3369
|
-
};
|
|
3370
|
-
}
|
|
3371
|
-
if (!data.result) {
|
|
3372
|
-
return await testWithFallbackMethod(rpcConfig, controller.signal, startTime);
|
|
3373
|
-
}
|
|
3374
|
-
const healthStatus = data.result.status;
|
|
3375
|
-
if (healthStatus && healthStatus !== "healthy") {
|
|
3376
|
-
return {
|
|
3377
|
-
success: false,
|
|
3378
|
-
error: `Soroban RPC service unhealthy: ${healthStatus}`,
|
|
3379
|
-
latency
|
|
3380
|
-
};
|
|
3381
|
-
}
|
|
3382
|
-
return { success: true, latency };
|
|
3383
|
-
} catch (error) {
|
|
3384
|
-
import_ui_builder_utils24.logger.error("testStellarRpcConnection", "Connection test failed:", error);
|
|
3385
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
3386
|
-
return {
|
|
3387
|
-
success: false,
|
|
3388
|
-
error: `Connection timeout after ${timeoutMs}ms`
|
|
3389
|
-
};
|
|
3390
|
-
}
|
|
3391
|
-
try {
|
|
3392
|
-
return await testWithFallbackMethod(rpcConfig, controller.signal, Date.now());
|
|
3393
|
-
} catch {
|
|
3394
|
-
return {
|
|
3395
|
-
success: false,
|
|
3396
|
-
error: error instanceof Error ? error.message : "Connection failed"
|
|
3397
|
-
};
|
|
3398
|
-
}
|
|
3399
|
-
} finally {
|
|
3400
|
-
clearTimeout(timeoutId);
|
|
3401
|
-
}
|
|
3402
|
-
}
|
|
3403
|
-
async function testWithFallbackMethod(rpcConfig, signal, startTime) {
|
|
3404
|
-
const response = await fetch(rpcConfig.url, {
|
|
3405
|
-
method: "POST",
|
|
3406
|
-
headers: {
|
|
3407
|
-
"Content-Type": "application/json"
|
|
3408
|
-
},
|
|
3409
|
-
body: JSON.stringify({
|
|
3410
|
-
jsonrpc: "2.0",
|
|
3411
|
-
id: 1,
|
|
3412
|
-
method: "getLatestLedger"
|
|
3413
|
-
}),
|
|
3414
|
-
signal
|
|
3415
|
-
});
|
|
3416
|
-
if (!response.ok) {
|
|
3417
|
-
return { success: false, error: `HTTP error: ${response.status}` };
|
|
3418
|
-
}
|
|
3419
|
-
const data = await response.json();
|
|
3420
|
-
const latency = Date.now() - startTime;
|
|
3421
|
-
if (data.error) {
|
|
3422
|
-
return {
|
|
3423
|
-
success: false,
|
|
3424
|
-
error: `Soroban RPC error: ${data.error.message || "Unknown RPC error"}`
|
|
3425
|
-
};
|
|
3426
|
-
}
|
|
3427
|
-
if (data.result && data.result.sequence) {
|
|
3428
|
-
return { success: true, latency };
|
|
3429
|
-
}
|
|
3430
|
-
return {
|
|
3431
|
-
success: false,
|
|
3432
|
-
error: "Unexpected response format from Soroban RPC endpoint"
|
|
3433
|
-
};
|
|
3434
|
-
}
|
|
3435
|
-
|
|
3436
3531
|
// src/mapping/constants.ts
|
|
3437
3532
|
var STELLAR_TYPE_TO_FIELD_TYPE = {
|
|
3438
3533
|
// Address types
|
|
@@ -3443,14 +3538,14 @@ var STELLAR_TYPE_TO_FIELD_TYPE = {
|
|
|
3443
3538
|
ScSymbol: "text",
|
|
3444
3539
|
// Numeric types - unsigned integers
|
|
3445
3540
|
U32: "number",
|
|
3446
|
-
U64: "
|
|
3447
|
-
U128: "
|
|
3448
|
-
U256: "
|
|
3541
|
+
U64: "bigint",
|
|
3542
|
+
U128: "bigint",
|
|
3543
|
+
U256: "bigint",
|
|
3449
3544
|
// Numeric types - signed integers
|
|
3450
3545
|
I32: "number",
|
|
3451
|
-
I64: "
|
|
3452
|
-
I128: "
|
|
3453
|
-
I256: "
|
|
3546
|
+
I64: "bigint",
|
|
3547
|
+
I128: "bigint",
|
|
3548
|
+
I256: "bigint",
|
|
3454
3549
|
// Boolean type
|
|
3455
3550
|
Bool: "checkbox",
|
|
3456
3551
|
// Byte types
|
|
@@ -3549,14 +3644,14 @@ function getStellarCompatibleFieldTypes(parameterType) {
|
|
|
3549
3644
|
Address: ["blockchain-address", "text"],
|
|
3550
3645
|
// Unsigned integers
|
|
3551
3646
|
U32: ["number", "amount", "text"],
|
|
3552
|
-
U64: ["number", "amount", "text"],
|
|
3553
|
-
U128: ["number", "amount", "text"],
|
|
3554
|
-
U256: ["number", "amount", "text"],
|
|
3647
|
+
U64: ["bigint", "number", "amount", "text"],
|
|
3648
|
+
U128: ["bigint", "number", "amount", "text"],
|
|
3649
|
+
U256: ["bigint", "number", "amount", "text"],
|
|
3555
3650
|
// Signed integers
|
|
3556
3651
|
I32: ["number", "amount", "text"],
|
|
3557
|
-
I64: ["
|
|
3558
|
-
I128: ["
|
|
3559
|
-
I256: ["
|
|
3652
|
+
I64: ["bigint", "number", "text"],
|
|
3653
|
+
I128: ["bigint", "number", "text"],
|
|
3654
|
+
I256: ["bigint", "number", "text"],
|
|
3560
3655
|
// Boolean
|
|
3561
3656
|
Bool: ["checkbox", "select", "radio", "text"],
|
|
3562
3657
|
// String types
|
|
@@ -4687,7 +4782,24 @@ var StellarAdapter = class {
|
|
|
4687
4782
|
`Adapter initialized for network: ${networkConfig.name} (ID: ${networkConfig.id})`
|
|
4688
4783
|
);
|
|
4689
4784
|
}
|
|
4690
|
-
|
|
4785
|
+
/**
|
|
4786
|
+
* @inheritdoc
|
|
4787
|
+
*/
|
|
4788
|
+
getNetworkServiceForms() {
|
|
4789
|
+
return getStellarNetworkServiceForms();
|
|
4790
|
+
}
|
|
4791
|
+
/**
|
|
4792
|
+
* @inheritdoc
|
|
4793
|
+
*/
|
|
4794
|
+
async validateNetworkServiceConfig(serviceId, values) {
|
|
4795
|
+
return validateStellarNetworkServiceConfig(serviceId, values);
|
|
4796
|
+
}
|
|
4797
|
+
/**
|
|
4798
|
+
* @inheritdoc
|
|
4799
|
+
*/
|
|
4800
|
+
async testNetworkServiceConnection(serviceId, values) {
|
|
4801
|
+
return testStellarNetworkServiceConnection(serviceId, values);
|
|
4802
|
+
}
|
|
4691
4803
|
/**
|
|
4692
4804
|
* NOTE about artifact inputs (single input with auto-detection):
|
|
4693
4805
|
*
|
|
@@ -4712,6 +4824,9 @@ var StellarAdapter = class {
|
|
|
4712
4824
|
* manual contract definition exactly like the EVM/Midnight flows.
|
|
4713
4825
|
* - Provide clear UI hints about supported formats (JSON spec or Wasm binary).
|
|
4714
4826
|
*/
|
|
4827
|
+
/**
|
|
4828
|
+
* @inheritdoc
|
|
4829
|
+
*/
|
|
4715
4830
|
getContractDefinitionInputs() {
|
|
4716
4831
|
return [
|
|
4717
4832
|
{
|
|
@@ -4750,10 +4865,15 @@ var StellarAdapter = class {
|
|
|
4750
4865
|
throw error;
|
|
4751
4866
|
}
|
|
4752
4867
|
}
|
|
4868
|
+
/**
|
|
4869
|
+
* @inheritdoc
|
|
4870
|
+
*/
|
|
4753
4871
|
getWritableFunctions(contractSchema) {
|
|
4754
4872
|
return getStellarWritableFunctions(contractSchema);
|
|
4755
4873
|
}
|
|
4756
|
-
|
|
4874
|
+
/**
|
|
4875
|
+
* @inheritdoc
|
|
4876
|
+
*/
|
|
4757
4877
|
mapParameterTypeToFieldType(parameterType) {
|
|
4758
4878
|
return mapStellarParameterTypeToFieldType(parameterType);
|
|
4759
4879
|
}
|
|
@@ -4763,7 +4883,9 @@ var StellarAdapter = class {
|
|
|
4763
4883
|
generateDefaultField(parameter, contractSchema) {
|
|
4764
4884
|
return generateStellarDefaultField(parameter, contractSchema);
|
|
4765
4885
|
}
|
|
4766
|
-
|
|
4886
|
+
/**
|
|
4887
|
+
* @inheritdoc
|
|
4888
|
+
*/
|
|
4767
4889
|
formatTransactionData(contractSchema, functionId, submittedInputs, fields) {
|
|
4768
4890
|
return formatStellarTransactionData(contractSchema, functionId, submittedInputs, fields);
|
|
4769
4891
|
}
|
|
@@ -4776,15 +4898,15 @@ var StellarAdapter = class {
|
|
|
4776
4898
|
runtimeApiKey
|
|
4777
4899
|
);
|
|
4778
4900
|
}
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
// async waitForTransactionConfirmation?(...) { ... }
|
|
4783
|
-
// --- View Function Querying --- //
|
|
4901
|
+
/**
|
|
4902
|
+
* @inheritdoc
|
|
4903
|
+
*/
|
|
4784
4904
|
isViewFunction(functionDetails) {
|
|
4785
4905
|
return isStellarViewFunction(functionDetails);
|
|
4786
4906
|
}
|
|
4787
|
-
|
|
4907
|
+
/**
|
|
4908
|
+
* @inheritdoc
|
|
4909
|
+
*/
|
|
4788
4910
|
async queryViewFunction(contractAddress, functionId, params = [], contractSchema) {
|
|
4789
4911
|
return queryStellarViewFunction(
|
|
4790
4912
|
contractAddress,
|
|
@@ -4795,22 +4917,39 @@ var StellarAdapter = class {
|
|
|
4795
4917
|
(address) => this.loadContract({ contractAddress: address })
|
|
4796
4918
|
);
|
|
4797
4919
|
}
|
|
4920
|
+
/**
|
|
4921
|
+
* @inheritdoc
|
|
4922
|
+
*/
|
|
4798
4923
|
formatFunctionResult(decodedValue, functionDetails) {
|
|
4799
4924
|
return formatStellarFunctionResult(decodedValue, functionDetails);
|
|
4800
4925
|
}
|
|
4801
|
-
|
|
4926
|
+
/**
|
|
4927
|
+
* @inheritdoc
|
|
4928
|
+
*/
|
|
4802
4929
|
supportsWalletConnection() {
|
|
4803
4930
|
return supportsStellarWalletConnection();
|
|
4804
4931
|
}
|
|
4932
|
+
/**
|
|
4933
|
+
* @inheritdoc
|
|
4934
|
+
*/
|
|
4805
4935
|
async getAvailableConnectors() {
|
|
4806
4936
|
return getStellarAvailableConnectors();
|
|
4807
4937
|
}
|
|
4938
|
+
/**
|
|
4939
|
+
* @inheritdoc
|
|
4940
|
+
*/
|
|
4808
4941
|
async connectWallet(connectorId) {
|
|
4809
4942
|
return connectStellarWallet(connectorId);
|
|
4810
4943
|
}
|
|
4944
|
+
/**
|
|
4945
|
+
* @inheritdoc
|
|
4946
|
+
*/
|
|
4811
4947
|
async disconnectWallet() {
|
|
4812
4948
|
return disconnectStellarWallet();
|
|
4813
4949
|
}
|
|
4950
|
+
/**
|
|
4951
|
+
* @inheritdoc
|
|
4952
|
+
*/
|
|
4814
4953
|
getWalletConnectionStatus() {
|
|
4815
4954
|
const impl = getInitializedStellarWalletImplementation();
|
|
4816
4955
|
if (!impl) {
|
|
@@ -4842,29 +4981,43 @@ var StellarAdapter = class {
|
|
|
4842
4981
|
}
|
|
4843
4982
|
);
|
|
4844
4983
|
}
|
|
4845
|
-
|
|
4984
|
+
/**
|
|
4985
|
+
* @inheritdoc
|
|
4986
|
+
*/
|
|
4846
4987
|
async getSupportedExecutionMethods() {
|
|
4847
4988
|
return getStellarSupportedExecutionMethods();
|
|
4848
4989
|
}
|
|
4990
|
+
/**
|
|
4991
|
+
* @inheritdoc
|
|
4992
|
+
*/
|
|
4849
4993
|
async validateExecutionConfig(config) {
|
|
4850
4994
|
const walletStatus = this.getWalletConnectionStatus();
|
|
4851
4995
|
return validateStellarExecutionConfig(config, walletStatus);
|
|
4852
4996
|
}
|
|
4853
|
-
|
|
4997
|
+
/**
|
|
4998
|
+
* @inheritdoc
|
|
4999
|
+
*/
|
|
4854
5000
|
getExplorerUrl(address) {
|
|
4855
5001
|
return getStellarExplorerAddressUrl(address, this.networkConfig);
|
|
4856
5002
|
}
|
|
4857
|
-
|
|
5003
|
+
/**
|
|
5004
|
+
* @inheritdoc
|
|
5005
|
+
*/
|
|
4858
5006
|
getExplorerTxUrl(txHash) {
|
|
4859
5007
|
if (getStellarExplorerTxUrl) {
|
|
4860
5008
|
return getStellarExplorerTxUrl(txHash, this.networkConfig);
|
|
4861
5009
|
}
|
|
4862
5010
|
return null;
|
|
4863
5011
|
}
|
|
4864
|
-
|
|
5012
|
+
/**
|
|
5013
|
+
* @inheritdoc
|
|
5014
|
+
*/
|
|
4865
5015
|
isValidAddress(address, addressType) {
|
|
4866
5016
|
return isValidAddress(address, addressType);
|
|
4867
5017
|
}
|
|
5018
|
+
/**
|
|
5019
|
+
* @inheritdoc
|
|
5020
|
+
*/
|
|
4868
5021
|
async getAvailableUiKits() {
|
|
4869
5022
|
return [
|
|
4870
5023
|
{
|
|
@@ -4937,6 +5090,9 @@ var StellarAdapter = class {
|
|
|
4937
5090
|
getEcosystemReactHooks() {
|
|
4938
5091
|
return stellarFacadeHooks;
|
|
4939
5092
|
}
|
|
5093
|
+
/**
|
|
5094
|
+
* @inheritdoc
|
|
5095
|
+
*/
|
|
4940
5096
|
async getRelayers(serviceUrl, accessToken) {
|
|
4941
5097
|
const relayerStrategy = new RelayerExecutionStrategy();
|
|
4942
5098
|
try {
|
|
@@ -4946,6 +5102,9 @@ var StellarAdapter = class {
|
|
|
4946
5102
|
return Promise.resolve([]);
|
|
4947
5103
|
}
|
|
4948
5104
|
}
|
|
5105
|
+
/**
|
|
5106
|
+
* @inheritdoc
|
|
5107
|
+
*/
|
|
4949
5108
|
async getRelayer(serviceUrl, accessToken, relayerId) {
|
|
4950
5109
|
const relayerStrategy = new RelayerExecutionStrategy();
|
|
4951
5110
|
try {
|
|
@@ -4961,8 +5120,7 @@ var StellarAdapter = class {
|
|
|
4961
5120
|
}
|
|
4962
5121
|
}
|
|
4963
5122
|
/**
|
|
4964
|
-
*
|
|
4965
|
-
* @returns The Stellar relayer options component
|
|
5123
|
+
* @inheritdoc
|
|
4966
5124
|
*/
|
|
4967
5125
|
getRelayerOptionsComponent() {
|
|
4968
5126
|
return StellarRelayerOptions;
|