@caatinga/client 2.3.0 → 2.4.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 +109 -36
- package/dist/index.js +109 -36
- package/dist/vite.cjs +93 -0
- package/dist/vite.d.cts +8 -0
- package/dist/vite.d.ts +8 -0
- package/dist/vite.js +54 -0
- package/package.json +8 -3
package/dist/index.cjs
CHANGED
|
@@ -279,10 +279,10 @@ function createDefaultBindingAdapter(binding) {
|
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
// src/client/create-caatinga-client.ts
|
|
282
|
-
var
|
|
282
|
+
var import_browser9 = require("@caatinga/core/browser");
|
|
283
283
|
|
|
284
284
|
// src/client/caatinga-contract-client.ts
|
|
285
|
-
var
|
|
285
|
+
var import_browser8 = require("@caatinga/core/browser");
|
|
286
286
|
|
|
287
287
|
// src/xdr/build-xdr.ts
|
|
288
288
|
var import_browser4 = require("@caatinga/core/browser");
|
|
@@ -383,28 +383,62 @@ function splitReadArgsAndOptions(argsOrOptions, maybeOptions) {
|
|
|
383
383
|
var import_browser5 = require("@caatinga/core/browser");
|
|
384
384
|
async function prepareReadTransaction(transaction, contractName, method, rpcUrl) {
|
|
385
385
|
const candidate = transaction;
|
|
386
|
-
if (typeof candidate.prepare
|
|
387
|
-
|
|
386
|
+
if (typeof candidate.prepare === "function") {
|
|
387
|
+
try {
|
|
388
|
+
return await candidate.prepare.call(transaction);
|
|
389
|
+
} catch (error) {
|
|
390
|
+
if (error instanceof import_browser5.CaatingaError) {
|
|
391
|
+
throw error;
|
|
392
|
+
}
|
|
393
|
+
throw new import_browser5.CaatingaError(
|
|
394
|
+
`Failed to prepare XDR for "${contractName}.${method}".`,
|
|
395
|
+
import_browser5.CaatingaErrorCode.XDR_PREPARE_FAILED,
|
|
396
|
+
`RPC: ${rpcUrl}. Check connectivity, simulation errors, and binding compatibility.`,
|
|
397
|
+
error
|
|
398
|
+
);
|
|
399
|
+
}
|
|
388
400
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
401
|
+
if (typeof candidate.simulate === "function") {
|
|
402
|
+
try {
|
|
403
|
+
return await candidate.simulate.call(transaction);
|
|
404
|
+
} catch (error) {
|
|
405
|
+
if (error instanceof import_browser5.CaatingaError) {
|
|
406
|
+
throw error;
|
|
407
|
+
}
|
|
408
|
+
throw new import_browser5.CaatingaError(
|
|
409
|
+
`Failed to simulate "${contractName}.${method}".`,
|
|
410
|
+
import_browser5.CaatingaErrorCode.XDR_PREPARE_FAILED,
|
|
411
|
+
`RPC: ${rpcUrl}. Check connectivity, simulation errors, and binding compatibility.`,
|
|
412
|
+
error
|
|
413
|
+
);
|
|
394
414
|
}
|
|
415
|
+
}
|
|
416
|
+
return transaction;
|
|
417
|
+
}
|
|
418
|
+
function isStellarContractResult(value) {
|
|
419
|
+
return value !== null && typeof value === "object" && typeof value.isOk === "function" && typeof value.unwrap === "function";
|
|
420
|
+
}
|
|
421
|
+
function normalizeSimulationValue(value, contractName, method) {
|
|
422
|
+
if (!isStellarContractResult(value)) {
|
|
423
|
+
return value;
|
|
424
|
+
}
|
|
425
|
+
if (value.isErr()) {
|
|
426
|
+
const err = value.unwrapErr();
|
|
427
|
+
const message = err !== null && typeof err === "object" && "message" in err ? String(err.message) : String(err);
|
|
395
428
|
throw new import_browser5.CaatingaError(
|
|
396
|
-
`
|
|
397
|
-
import_browser5.CaatingaErrorCode.
|
|
398
|
-
|
|
399
|
-
|
|
429
|
+
`Simulation for "${contractName}.${method}" returned a contract error: ${message}.`,
|
|
430
|
+
import_browser5.CaatingaErrorCode.XDR_RESULT_FAILED,
|
|
431
|
+
"Check contract inputs and binding argument encoding.",
|
|
432
|
+
err
|
|
400
433
|
);
|
|
401
434
|
}
|
|
435
|
+
return value.unwrap();
|
|
402
436
|
}
|
|
403
437
|
function readSimulationResult(raw, contractName, method) {
|
|
404
438
|
if (raw !== null && typeof raw === "object" && "result" in raw) {
|
|
405
439
|
const result = raw.result;
|
|
406
440
|
if (result !== void 0) {
|
|
407
|
-
return result;
|
|
441
|
+
return normalizeSimulationValue(result, contractName, method);
|
|
408
442
|
}
|
|
409
443
|
}
|
|
410
444
|
throw new import_browser5.CaatingaError(
|
|
@@ -415,7 +449,38 @@ function readSimulationResult(raw, contractName, method) {
|
|
|
415
449
|
}
|
|
416
450
|
|
|
417
451
|
// src/client/transaction-submit.ts
|
|
452
|
+
var import_browser7 = require("@caatinga/core/browser");
|
|
453
|
+
|
|
454
|
+
// src/client/read-call-error.ts
|
|
418
455
|
var import_browser6 = require("@caatinga/core/browser");
|
|
456
|
+
|
|
457
|
+
// src/client/read-call-pattern.ts
|
|
458
|
+
var READ_CALL_FAILURE_REGEX = /this is a read call|read-only/i;
|
|
459
|
+
|
|
460
|
+
// src/client/read-call-error.ts
|
|
461
|
+
function enrichReadCallInvokeError(error, contractName, method) {
|
|
462
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
463
|
+
const hint = error instanceof import_browser6.CaatingaError ? error.hint ?? "" : "";
|
|
464
|
+
const haystack = `${message}
|
|
465
|
+
${hint}`;
|
|
466
|
+
if (!READ_CALL_FAILURE_REGEX.test(haystack)) {
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
return new import_browser6.CaatingaError(
|
|
470
|
+
`Failed to submit XDR for "${contractName}.${method}".`,
|
|
471
|
+
import_browser6.CaatingaErrorCode.XDR_SUBMIT_FAILED,
|
|
472
|
+
[
|
|
473
|
+
`"${contractName}.${method}" is a read-only contract method.`,
|
|
474
|
+
"Use read() or simulate() instead of invoke():",
|
|
475
|
+
` client.contract("${contractName}").read("${method}")`,
|
|
476
|
+
` client.contract("${contractName}").simulate("${method}")`,
|
|
477
|
+
"Pass method args as the second argument to read() when the contract method takes parameters."
|
|
478
|
+
].join("\n"),
|
|
479
|
+
error
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// src/client/transaction-submit.ts
|
|
419
484
|
async function submitTransaction(transaction, signTransaction, contractName, method, rpcUrl) {
|
|
420
485
|
const candidate = transaction;
|
|
421
486
|
if (typeof candidate.signAndSend === "function") {
|
|
@@ -424,12 +489,16 @@ async function submitTransaction(transaction, signTransaction, contractName, met
|
|
|
424
489
|
assertSubmitResultRecognized(raw, contractName, method);
|
|
425
490
|
return raw;
|
|
426
491
|
} catch (error) {
|
|
427
|
-
if (error instanceof
|
|
492
|
+
if (error instanceof import_browser7.CaatingaError) {
|
|
428
493
|
throw error;
|
|
429
494
|
}
|
|
430
|
-
|
|
495
|
+
const readCallError = enrichReadCallInvokeError(error, contractName, method);
|
|
496
|
+
if (readCallError) {
|
|
497
|
+
throw readCallError;
|
|
498
|
+
}
|
|
499
|
+
throw new import_browser7.CaatingaError(
|
|
431
500
|
`Failed to submit XDR for "${contractName}.${method}".`,
|
|
432
|
-
|
|
501
|
+
import_browser7.CaatingaErrorCode.XDR_SUBMIT_FAILED,
|
|
433
502
|
`RPC: ${rpcUrl}. Check wallet signature and RPC connectivity.`,
|
|
434
503
|
error
|
|
435
504
|
);
|
|
@@ -441,20 +510,24 @@ async function submitTransaction(transaction, signTransaction, contractName, met
|
|
|
441
510
|
assertSubmitResultRecognized(raw, contractName, method);
|
|
442
511
|
return raw;
|
|
443
512
|
} catch (error) {
|
|
444
|
-
if (error instanceof
|
|
513
|
+
if (error instanceof import_browser7.CaatingaError) {
|
|
445
514
|
throw error;
|
|
446
515
|
}
|
|
447
|
-
|
|
516
|
+
const readCallError = enrichReadCallInvokeError(error, contractName, method);
|
|
517
|
+
if (readCallError) {
|
|
518
|
+
throw readCallError;
|
|
519
|
+
}
|
|
520
|
+
throw new import_browser7.CaatingaError(
|
|
448
521
|
`Failed to submit XDR for "${contractName}.${method}".`,
|
|
449
|
-
|
|
522
|
+
import_browser7.CaatingaErrorCode.XDR_SUBMIT_FAILED,
|
|
450
523
|
`RPC: ${rpcUrl}. Check wallet signature and RPC connectivity.`,
|
|
451
524
|
error
|
|
452
525
|
);
|
|
453
526
|
}
|
|
454
527
|
}
|
|
455
|
-
throw new
|
|
528
|
+
throw new import_browser7.CaatingaError(
|
|
456
529
|
`Binding transaction for "${contractName}.${method}" cannot be submitted.`,
|
|
457
|
-
|
|
530
|
+
import_browser7.CaatingaErrorCode.XDR_SUBMIT_FAILED,
|
|
458
531
|
"Regenerate bindings or provide a compatible binding adapter."
|
|
459
532
|
);
|
|
460
533
|
}
|
|
@@ -468,9 +541,9 @@ function assertSubmitResultRecognized(raw, contractName, method) {
|
|
|
468
541
|
if (hasTransactionId || hasResult) {
|
|
469
542
|
return;
|
|
470
543
|
}
|
|
471
|
-
throw new
|
|
544
|
+
throw new import_browser7.CaatingaError(
|
|
472
545
|
`Submit returned an unrecognized payload for "${contractName}.${method}".`,
|
|
473
|
-
|
|
546
|
+
import_browser7.CaatingaErrorCode.XDR_RESULT_FAILED,
|
|
474
547
|
"Expected txHash, transactionHash, hash, sendTransactionResponse.hash, or result on the submit response. Use debugRaw to inspect the binding output."
|
|
475
548
|
);
|
|
476
549
|
}
|
|
@@ -535,20 +608,20 @@ var CaatingaContractClient = class {
|
|
|
535
608
|
})
|
|
536
609
|
);
|
|
537
610
|
} catch (error) {
|
|
538
|
-
if (error instanceof
|
|
611
|
+
if (error instanceof import_browser8.CaatingaError) {
|
|
539
612
|
throw error;
|
|
540
613
|
}
|
|
541
|
-
throw new
|
|
614
|
+
throw new import_browser8.CaatingaError(
|
|
542
615
|
`Failed to sign XDR for "${this.contractName}.${method}".`,
|
|
543
|
-
|
|
616
|
+
import_browser8.CaatingaErrorCode.XDR_SIGN_FAILED,
|
|
544
617
|
"Connect a wallet and approve the transaction.",
|
|
545
618
|
error
|
|
546
619
|
);
|
|
547
620
|
}
|
|
548
621
|
if (typeof signedXdr !== "string" || signedXdr.trim().length === 0) {
|
|
549
|
-
throw new
|
|
622
|
+
throw new import_browser8.CaatingaError(
|
|
550
623
|
`Failed to sign XDR for "${this.contractName}.${method}".`,
|
|
551
|
-
|
|
624
|
+
import_browser8.CaatingaErrorCode.XDR_SIGN_FAILED,
|
|
552
625
|
"Wallet returned an empty or invalid signed XDR. The user may have dismissed the signing prompt.",
|
|
553
626
|
signedXdr
|
|
554
627
|
);
|
|
@@ -563,9 +636,9 @@ var CaatingaContractClient = class {
|
|
|
563
636
|
this.config.network.rpcUrl
|
|
564
637
|
);
|
|
565
638
|
if (typeof transaction.signAndSend === "function" && signedXdr === void 0) {
|
|
566
|
-
throw new
|
|
639
|
+
throw new import_browser8.CaatingaError(
|
|
567
640
|
`Failed to sign XDR for "${this.contractName}.${method}".`,
|
|
568
|
-
|
|
641
|
+
import_browser8.CaatingaErrorCode.XDR_SIGN_FAILED,
|
|
569
642
|
"Wallet returned an empty or invalid signed XDR. The generated transaction did not request a wallet signature."
|
|
570
643
|
);
|
|
571
644
|
}
|
|
@@ -625,12 +698,12 @@ var CaatingaContractClient = class {
|
|
|
625
698
|
() => this.config.wallet.getPublicKey()
|
|
626
699
|
);
|
|
627
700
|
} catch (error) {
|
|
628
|
-
if (error instanceof
|
|
701
|
+
if (error instanceof import_browser8.CaatingaError) {
|
|
629
702
|
throw error;
|
|
630
703
|
}
|
|
631
|
-
throw new
|
|
704
|
+
throw new import_browser8.CaatingaError(
|
|
632
705
|
`Wallet is not connected or the public key is unavailable for "${this.contractName}".`,
|
|
633
|
-
|
|
706
|
+
import_browser8.CaatingaErrorCode.WALLET_NOT_CONNECTED,
|
|
634
707
|
"Connect the wallet and grant account access, then retry.",
|
|
635
708
|
error
|
|
636
709
|
);
|
|
@@ -652,9 +725,9 @@ function createCaatingaClient(config) {
|
|
|
652
725
|
contract(contractName) {
|
|
653
726
|
const registration = config.contracts[contractName];
|
|
654
727
|
if (!registration) {
|
|
655
|
-
throw new
|
|
728
|
+
throw new import_browser9.CaatingaError(
|
|
656
729
|
`Contract "${contractName}" is not registered.`,
|
|
657
|
-
|
|
730
|
+
import_browser9.CaatingaErrorCode.CONTRACT_NOT_FOUND,
|
|
658
731
|
"Add the contract binding to createCaatingaClient()."
|
|
659
732
|
);
|
|
660
733
|
}
|
package/dist/index.js
CHANGED
|
@@ -89,10 +89,10 @@ function createDefaultBindingAdapter(binding) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// src/client/create-caatinga-client.ts
|
|
92
|
-
import { CaatingaError as
|
|
92
|
+
import { CaatingaError as CaatingaError8, CaatingaErrorCode as CaatingaErrorCode8 } from "@caatinga/core/browser";
|
|
93
93
|
|
|
94
94
|
// src/client/caatinga-contract-client.ts
|
|
95
|
-
import { CaatingaError as
|
|
95
|
+
import { CaatingaError as CaatingaError7, CaatingaErrorCode as CaatingaErrorCode7 } from "@caatinga/core/browser";
|
|
96
96
|
|
|
97
97
|
// src/xdr/build-xdr.ts
|
|
98
98
|
import { CaatingaError as CaatingaError3, CaatingaErrorCode as CaatingaErrorCode3 } from "@caatinga/core/browser";
|
|
@@ -193,28 +193,62 @@ function splitReadArgsAndOptions(argsOrOptions, maybeOptions) {
|
|
|
193
193
|
import { CaatingaError as CaatingaError4, CaatingaErrorCode as CaatingaErrorCode4 } from "@caatinga/core/browser";
|
|
194
194
|
async function prepareReadTransaction(transaction, contractName, method, rpcUrl) {
|
|
195
195
|
const candidate = transaction;
|
|
196
|
-
if (typeof candidate.prepare
|
|
197
|
-
|
|
196
|
+
if (typeof candidate.prepare === "function") {
|
|
197
|
+
try {
|
|
198
|
+
return await candidate.prepare.call(transaction);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (error instanceof CaatingaError4) {
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
throw new CaatingaError4(
|
|
204
|
+
`Failed to prepare XDR for "${contractName}.${method}".`,
|
|
205
|
+
CaatingaErrorCode4.XDR_PREPARE_FAILED,
|
|
206
|
+
`RPC: ${rpcUrl}. Check connectivity, simulation errors, and binding compatibility.`,
|
|
207
|
+
error
|
|
208
|
+
);
|
|
209
|
+
}
|
|
198
210
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
211
|
+
if (typeof candidate.simulate === "function") {
|
|
212
|
+
try {
|
|
213
|
+
return await candidate.simulate.call(transaction);
|
|
214
|
+
} catch (error) {
|
|
215
|
+
if (error instanceof CaatingaError4) {
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
throw new CaatingaError4(
|
|
219
|
+
`Failed to simulate "${contractName}.${method}".`,
|
|
220
|
+
CaatingaErrorCode4.XDR_PREPARE_FAILED,
|
|
221
|
+
`RPC: ${rpcUrl}. Check connectivity, simulation errors, and binding compatibility.`,
|
|
222
|
+
error
|
|
223
|
+
);
|
|
204
224
|
}
|
|
225
|
+
}
|
|
226
|
+
return transaction;
|
|
227
|
+
}
|
|
228
|
+
function isStellarContractResult(value) {
|
|
229
|
+
return value !== null && typeof value === "object" && typeof value.isOk === "function" && typeof value.unwrap === "function";
|
|
230
|
+
}
|
|
231
|
+
function normalizeSimulationValue(value, contractName, method) {
|
|
232
|
+
if (!isStellarContractResult(value)) {
|
|
233
|
+
return value;
|
|
234
|
+
}
|
|
235
|
+
if (value.isErr()) {
|
|
236
|
+
const err = value.unwrapErr();
|
|
237
|
+
const message = err !== null && typeof err === "object" && "message" in err ? String(err.message) : String(err);
|
|
205
238
|
throw new CaatingaError4(
|
|
206
|
-
`
|
|
207
|
-
CaatingaErrorCode4.
|
|
208
|
-
|
|
209
|
-
|
|
239
|
+
`Simulation for "${contractName}.${method}" returned a contract error: ${message}.`,
|
|
240
|
+
CaatingaErrorCode4.XDR_RESULT_FAILED,
|
|
241
|
+
"Check contract inputs and binding argument encoding.",
|
|
242
|
+
err
|
|
210
243
|
);
|
|
211
244
|
}
|
|
245
|
+
return value.unwrap();
|
|
212
246
|
}
|
|
213
247
|
function readSimulationResult(raw, contractName, method) {
|
|
214
248
|
if (raw !== null && typeof raw === "object" && "result" in raw) {
|
|
215
249
|
const result = raw.result;
|
|
216
250
|
if (result !== void 0) {
|
|
217
|
-
return result;
|
|
251
|
+
return normalizeSimulationValue(result, contractName, method);
|
|
218
252
|
}
|
|
219
253
|
}
|
|
220
254
|
throw new CaatingaError4(
|
|
@@ -225,7 +259,38 @@ function readSimulationResult(raw, contractName, method) {
|
|
|
225
259
|
}
|
|
226
260
|
|
|
227
261
|
// src/client/transaction-submit.ts
|
|
262
|
+
import { CaatingaError as CaatingaError6, CaatingaErrorCode as CaatingaErrorCode6 } from "@caatinga/core/browser";
|
|
263
|
+
|
|
264
|
+
// src/client/read-call-error.ts
|
|
228
265
|
import { CaatingaError as CaatingaError5, CaatingaErrorCode as CaatingaErrorCode5 } from "@caatinga/core/browser";
|
|
266
|
+
|
|
267
|
+
// src/client/read-call-pattern.ts
|
|
268
|
+
var READ_CALL_FAILURE_REGEX = /this is a read call|read-only/i;
|
|
269
|
+
|
|
270
|
+
// src/client/read-call-error.ts
|
|
271
|
+
function enrichReadCallInvokeError(error, contractName, method) {
|
|
272
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
273
|
+
const hint = error instanceof CaatingaError5 ? error.hint ?? "" : "";
|
|
274
|
+
const haystack = `${message}
|
|
275
|
+
${hint}`;
|
|
276
|
+
if (!READ_CALL_FAILURE_REGEX.test(haystack)) {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
return new CaatingaError5(
|
|
280
|
+
`Failed to submit XDR for "${contractName}.${method}".`,
|
|
281
|
+
CaatingaErrorCode5.XDR_SUBMIT_FAILED,
|
|
282
|
+
[
|
|
283
|
+
`"${contractName}.${method}" is a read-only contract method.`,
|
|
284
|
+
"Use read() or simulate() instead of invoke():",
|
|
285
|
+
` client.contract("${contractName}").read("${method}")`,
|
|
286
|
+
` client.contract("${contractName}").simulate("${method}")`,
|
|
287
|
+
"Pass method args as the second argument to read() when the contract method takes parameters."
|
|
288
|
+
].join("\n"),
|
|
289
|
+
error
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// src/client/transaction-submit.ts
|
|
229
294
|
async function submitTransaction(transaction, signTransaction, contractName, method, rpcUrl) {
|
|
230
295
|
const candidate = transaction;
|
|
231
296
|
if (typeof candidate.signAndSend === "function") {
|
|
@@ -234,12 +299,16 @@ async function submitTransaction(transaction, signTransaction, contractName, met
|
|
|
234
299
|
assertSubmitResultRecognized(raw, contractName, method);
|
|
235
300
|
return raw;
|
|
236
301
|
} catch (error) {
|
|
237
|
-
if (error instanceof
|
|
302
|
+
if (error instanceof CaatingaError6) {
|
|
238
303
|
throw error;
|
|
239
304
|
}
|
|
240
|
-
|
|
305
|
+
const readCallError = enrichReadCallInvokeError(error, contractName, method);
|
|
306
|
+
if (readCallError) {
|
|
307
|
+
throw readCallError;
|
|
308
|
+
}
|
|
309
|
+
throw new CaatingaError6(
|
|
241
310
|
`Failed to submit XDR for "${contractName}.${method}".`,
|
|
242
|
-
|
|
311
|
+
CaatingaErrorCode6.XDR_SUBMIT_FAILED,
|
|
243
312
|
`RPC: ${rpcUrl}. Check wallet signature and RPC connectivity.`,
|
|
244
313
|
error
|
|
245
314
|
);
|
|
@@ -251,20 +320,24 @@ async function submitTransaction(transaction, signTransaction, contractName, met
|
|
|
251
320
|
assertSubmitResultRecognized(raw, contractName, method);
|
|
252
321
|
return raw;
|
|
253
322
|
} catch (error) {
|
|
254
|
-
if (error instanceof
|
|
323
|
+
if (error instanceof CaatingaError6) {
|
|
255
324
|
throw error;
|
|
256
325
|
}
|
|
257
|
-
|
|
326
|
+
const readCallError = enrichReadCallInvokeError(error, contractName, method);
|
|
327
|
+
if (readCallError) {
|
|
328
|
+
throw readCallError;
|
|
329
|
+
}
|
|
330
|
+
throw new CaatingaError6(
|
|
258
331
|
`Failed to submit XDR for "${contractName}.${method}".`,
|
|
259
|
-
|
|
332
|
+
CaatingaErrorCode6.XDR_SUBMIT_FAILED,
|
|
260
333
|
`RPC: ${rpcUrl}. Check wallet signature and RPC connectivity.`,
|
|
261
334
|
error
|
|
262
335
|
);
|
|
263
336
|
}
|
|
264
337
|
}
|
|
265
|
-
throw new
|
|
338
|
+
throw new CaatingaError6(
|
|
266
339
|
`Binding transaction for "${contractName}.${method}" cannot be submitted.`,
|
|
267
|
-
|
|
340
|
+
CaatingaErrorCode6.XDR_SUBMIT_FAILED,
|
|
268
341
|
"Regenerate bindings or provide a compatible binding adapter."
|
|
269
342
|
);
|
|
270
343
|
}
|
|
@@ -278,9 +351,9 @@ function assertSubmitResultRecognized(raw, contractName, method) {
|
|
|
278
351
|
if (hasTransactionId || hasResult) {
|
|
279
352
|
return;
|
|
280
353
|
}
|
|
281
|
-
throw new
|
|
354
|
+
throw new CaatingaError6(
|
|
282
355
|
`Submit returned an unrecognized payload for "${contractName}.${method}".`,
|
|
283
|
-
|
|
356
|
+
CaatingaErrorCode6.XDR_RESULT_FAILED,
|
|
284
357
|
"Expected txHash, transactionHash, hash, sendTransactionResponse.hash, or result on the submit response. Use debugRaw to inspect the binding output."
|
|
285
358
|
);
|
|
286
359
|
}
|
|
@@ -345,20 +418,20 @@ var CaatingaContractClient = class {
|
|
|
345
418
|
})
|
|
346
419
|
);
|
|
347
420
|
} catch (error) {
|
|
348
|
-
if (error instanceof
|
|
421
|
+
if (error instanceof CaatingaError7) {
|
|
349
422
|
throw error;
|
|
350
423
|
}
|
|
351
|
-
throw new
|
|
424
|
+
throw new CaatingaError7(
|
|
352
425
|
`Failed to sign XDR for "${this.contractName}.${method}".`,
|
|
353
|
-
|
|
426
|
+
CaatingaErrorCode7.XDR_SIGN_FAILED,
|
|
354
427
|
"Connect a wallet and approve the transaction.",
|
|
355
428
|
error
|
|
356
429
|
);
|
|
357
430
|
}
|
|
358
431
|
if (typeof signedXdr !== "string" || signedXdr.trim().length === 0) {
|
|
359
|
-
throw new
|
|
432
|
+
throw new CaatingaError7(
|
|
360
433
|
`Failed to sign XDR for "${this.contractName}.${method}".`,
|
|
361
|
-
|
|
434
|
+
CaatingaErrorCode7.XDR_SIGN_FAILED,
|
|
362
435
|
"Wallet returned an empty or invalid signed XDR. The user may have dismissed the signing prompt.",
|
|
363
436
|
signedXdr
|
|
364
437
|
);
|
|
@@ -373,9 +446,9 @@ var CaatingaContractClient = class {
|
|
|
373
446
|
this.config.network.rpcUrl
|
|
374
447
|
);
|
|
375
448
|
if (typeof transaction.signAndSend === "function" && signedXdr === void 0) {
|
|
376
|
-
throw new
|
|
449
|
+
throw new CaatingaError7(
|
|
377
450
|
`Failed to sign XDR for "${this.contractName}.${method}".`,
|
|
378
|
-
|
|
451
|
+
CaatingaErrorCode7.XDR_SIGN_FAILED,
|
|
379
452
|
"Wallet returned an empty or invalid signed XDR. The generated transaction did not request a wallet signature."
|
|
380
453
|
);
|
|
381
454
|
}
|
|
@@ -435,12 +508,12 @@ var CaatingaContractClient = class {
|
|
|
435
508
|
() => this.config.wallet.getPublicKey()
|
|
436
509
|
);
|
|
437
510
|
} catch (error) {
|
|
438
|
-
if (error instanceof
|
|
511
|
+
if (error instanceof CaatingaError7) {
|
|
439
512
|
throw error;
|
|
440
513
|
}
|
|
441
|
-
throw new
|
|
514
|
+
throw new CaatingaError7(
|
|
442
515
|
`Wallet is not connected or the public key is unavailable for "${this.contractName}".`,
|
|
443
|
-
|
|
516
|
+
CaatingaErrorCode7.WALLET_NOT_CONNECTED,
|
|
444
517
|
"Connect the wallet and grant account access, then retry.",
|
|
445
518
|
error
|
|
446
519
|
);
|
|
@@ -462,9 +535,9 @@ function createCaatingaClient(config) {
|
|
|
462
535
|
contract(contractName) {
|
|
463
536
|
const registration = config.contracts[contractName];
|
|
464
537
|
if (!registration) {
|
|
465
|
-
throw new
|
|
538
|
+
throw new CaatingaError8(
|
|
466
539
|
`Contract "${contractName}" is not registered.`,
|
|
467
|
-
|
|
540
|
+
CaatingaErrorCode8.CONTRACT_NOT_FOUND,
|
|
468
541
|
"Add the contract binding to createCaatingaClient()."
|
|
469
542
|
);
|
|
470
543
|
}
|
package/dist/vite.cjs
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/vite.ts
|
|
31
|
+
var vite_exports = {};
|
|
32
|
+
__export(vite_exports, {
|
|
33
|
+
walletStubOverrides: () => walletStubOverrides,
|
|
34
|
+
walletStubPnpmWorkspaceYaml: () => walletStubPnpmWorkspaceYaml,
|
|
35
|
+
walletStubViteAliases: () => walletStubViteAliases
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(vite_exports);
|
|
38
|
+
|
|
39
|
+
// src/vite/wallet-stubs.ts
|
|
40
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
41
|
+
function walletStubOverrides(stubsDir = "./src/stubs") {
|
|
42
|
+
const posixStubsDir = stubsDir.split(import_node_path.default.sep).join("/");
|
|
43
|
+
return {
|
|
44
|
+
uuid: "^14.0.0",
|
|
45
|
+
"@creit.tech/stellar-wallets-kit": {
|
|
46
|
+
"@trezor/connect-web": `file:${posixStubsDir}/empty-wallet-dep`,
|
|
47
|
+
"@trezor/connect-plugin-stellar": `file:${posixStubsDir}/empty-wallet-dep`,
|
|
48
|
+
"@hot-wallet/sdk": `file:${posixStubsDir}/hot-wallet-sdk`
|
|
49
|
+
},
|
|
50
|
+
"@reown/appkit-utils": {
|
|
51
|
+
"@safe-global/safe-apps-sdk": "-",
|
|
52
|
+
"@safe-global/safe-apps-provider": "-"
|
|
53
|
+
},
|
|
54
|
+
"@safe-global/safe-apps-sdk": {
|
|
55
|
+
"@safe-global/safe-gateway-typescript-sdk": "-"
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function walletStubViteAliases(stubsDir) {
|
|
60
|
+
const emptyStub = import_node_path.default.join(stubsDir, "empty-wallet-dep", "index.cjs");
|
|
61
|
+
return {
|
|
62
|
+
"@hot-wallet/sdk": import_node_path.default.join(stubsDir, "hot-wallet.ts"),
|
|
63
|
+
"@trezor/connect-web": emptyStub,
|
|
64
|
+
"@trezor/connect-plugin-stellar": emptyStub,
|
|
65
|
+
"@safe-global/safe-apps-sdk": emptyStub,
|
|
66
|
+
"@safe-global/safe-apps-provider": emptyStub,
|
|
67
|
+
"@safe-global/safe-gateway-typescript-sdk": emptyStub
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function walletStubPnpmWorkspaceYaml() {
|
|
71
|
+
return `allowBuilds:
|
|
72
|
+
esbuild: true
|
|
73
|
+
|
|
74
|
+
ignoredOptionalDependencies:
|
|
75
|
+
- "@safe-global/safe-apps-provider"
|
|
76
|
+
- "@safe-global/safe-apps-sdk"
|
|
77
|
+
|
|
78
|
+
overrides:
|
|
79
|
+
uuid: "^14.0.0"
|
|
80
|
+
"@creit.tech/stellar-wallets-kit>@trezor/connect-web": "-"
|
|
81
|
+
"@creit.tech/stellar-wallets-kit>@trezor/connect-plugin-stellar": "-"
|
|
82
|
+
"@creit.tech/stellar-wallets-kit>@hot-wallet/sdk": "-"
|
|
83
|
+
"@reown/appkit-utils>@safe-global/safe-apps-sdk": "-"
|
|
84
|
+
"@reown/appkit-utils>@safe-global/safe-apps-provider": "-"
|
|
85
|
+
"@safe-global/safe-apps-sdk>@safe-global/safe-gateway-typescript-sdk": "-"
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
walletStubOverrides,
|
|
91
|
+
walletStubPnpmWorkspaceYaml,
|
|
92
|
+
walletStubViteAliases
|
|
93
|
+
});
|
package/dist/vite.d.cts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type WalletStubPaths = {
|
|
2
|
+
stubsDir: string;
|
|
3
|
+
};
|
|
4
|
+
declare function walletStubOverrides(stubsDir?: string): Record<string, unknown>;
|
|
5
|
+
declare function walletStubViteAliases(stubsDir: string): Record<string, string>;
|
|
6
|
+
declare function walletStubPnpmWorkspaceYaml(): string;
|
|
7
|
+
|
|
8
|
+
export { type WalletStubPaths, walletStubOverrides, walletStubPnpmWorkspaceYaml, walletStubViteAliases };
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type WalletStubPaths = {
|
|
2
|
+
stubsDir: string;
|
|
3
|
+
};
|
|
4
|
+
declare function walletStubOverrides(stubsDir?: string): Record<string, unknown>;
|
|
5
|
+
declare function walletStubViteAliases(stubsDir: string): Record<string, string>;
|
|
6
|
+
declare function walletStubPnpmWorkspaceYaml(): string;
|
|
7
|
+
|
|
8
|
+
export { type WalletStubPaths, walletStubOverrides, walletStubPnpmWorkspaceYaml, walletStubViteAliases };
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/vite/wallet-stubs.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
function walletStubOverrides(stubsDir = "./src/stubs") {
|
|
4
|
+
const posixStubsDir = stubsDir.split(path.sep).join("/");
|
|
5
|
+
return {
|
|
6
|
+
uuid: "^14.0.0",
|
|
7
|
+
"@creit.tech/stellar-wallets-kit": {
|
|
8
|
+
"@trezor/connect-web": `file:${posixStubsDir}/empty-wallet-dep`,
|
|
9
|
+
"@trezor/connect-plugin-stellar": `file:${posixStubsDir}/empty-wallet-dep`,
|
|
10
|
+
"@hot-wallet/sdk": `file:${posixStubsDir}/hot-wallet-sdk`
|
|
11
|
+
},
|
|
12
|
+
"@reown/appkit-utils": {
|
|
13
|
+
"@safe-global/safe-apps-sdk": "-",
|
|
14
|
+
"@safe-global/safe-apps-provider": "-"
|
|
15
|
+
},
|
|
16
|
+
"@safe-global/safe-apps-sdk": {
|
|
17
|
+
"@safe-global/safe-gateway-typescript-sdk": "-"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function walletStubViteAliases(stubsDir) {
|
|
22
|
+
const emptyStub = path.join(stubsDir, "empty-wallet-dep", "index.cjs");
|
|
23
|
+
return {
|
|
24
|
+
"@hot-wallet/sdk": path.join(stubsDir, "hot-wallet.ts"),
|
|
25
|
+
"@trezor/connect-web": emptyStub,
|
|
26
|
+
"@trezor/connect-plugin-stellar": emptyStub,
|
|
27
|
+
"@safe-global/safe-apps-sdk": emptyStub,
|
|
28
|
+
"@safe-global/safe-apps-provider": emptyStub,
|
|
29
|
+
"@safe-global/safe-gateway-typescript-sdk": emptyStub
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function walletStubPnpmWorkspaceYaml() {
|
|
33
|
+
return `allowBuilds:
|
|
34
|
+
esbuild: true
|
|
35
|
+
|
|
36
|
+
ignoredOptionalDependencies:
|
|
37
|
+
- "@safe-global/safe-apps-provider"
|
|
38
|
+
- "@safe-global/safe-apps-sdk"
|
|
39
|
+
|
|
40
|
+
overrides:
|
|
41
|
+
uuid: "^14.0.0"
|
|
42
|
+
"@creit.tech/stellar-wallets-kit>@trezor/connect-web": "-"
|
|
43
|
+
"@creit.tech/stellar-wallets-kit>@trezor/connect-plugin-stellar": "-"
|
|
44
|
+
"@creit.tech/stellar-wallets-kit>@hot-wallet/sdk": "-"
|
|
45
|
+
"@reown/appkit-utils>@safe-global/safe-apps-sdk": "-"
|
|
46
|
+
"@reown/appkit-utils>@safe-global/safe-apps-provider": "-"
|
|
47
|
+
"@safe-global/safe-apps-sdk>@safe-global/safe-gateway-typescript-sdk": "-"
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
walletStubOverrides,
|
|
52
|
+
walletStubPnpmWorkspaceYaml,
|
|
53
|
+
walletStubViteAliases
|
|
54
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caatinga/client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Browser and Node client for Soroban smart contracts — connects generated bindings, Caatinga artifacts, and wallet adapters",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"stellar",
|
|
@@ -48,6 +48,11 @@
|
|
|
48
48
|
"types": "./dist/react.d.ts",
|
|
49
49
|
"import": "./dist/react.js",
|
|
50
50
|
"require": "./dist/react.cjs"
|
|
51
|
+
},
|
|
52
|
+
"./vite": {
|
|
53
|
+
"types": "./dist/vite.d.ts",
|
|
54
|
+
"import": "./dist/vite.js",
|
|
55
|
+
"require": "./dist/vite.cjs"
|
|
51
56
|
}
|
|
52
57
|
},
|
|
53
58
|
"files": [
|
|
@@ -56,7 +61,7 @@
|
|
|
56
61
|
"LICENSE"
|
|
57
62
|
],
|
|
58
63
|
"dependencies": {
|
|
59
|
-
"@caatinga/core": "^2.
|
|
64
|
+
"@caatinga/core": "^2.4.0"
|
|
60
65
|
},
|
|
61
66
|
"devDependencies": {
|
|
62
67
|
"tsup": "^8.3.5",
|
|
@@ -87,7 +92,7 @@
|
|
|
87
92
|
}
|
|
88
93
|
},
|
|
89
94
|
"scripts": {
|
|
90
|
-
"build": "tsup src/index.ts src/freighter.ts src/stellar-wallets-kit.ts src/react.ts --format esm,cjs --dts",
|
|
95
|
+
"build": "tsup src/index.ts src/freighter.ts src/stellar-wallets-kit.ts src/react.ts src/vite.ts --format esm,cjs --dts",
|
|
91
96
|
"test": "vitest run --pool=threads",
|
|
92
97
|
"typecheck": "tsc --noEmit"
|
|
93
98
|
}
|