@sorandomains/owner 0.10.0 → 0.10.1
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/funding-service.js +10 -1
- package/dist/index.js +24 -2
- package/package.json +4 -1
package/dist/funding-service.js
CHANGED
|
@@ -38,7 +38,16 @@ export class FundingServiceClient {
|
|
|
38
38
|
catch {
|
|
39
39
|
throw new FundingError("Service response unavailable. Keep your quote reference and recover its status before submitting again.", "unavailable");
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
let value;
|
|
42
|
+
try {
|
|
43
|
+
value = (await r.json());
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// A proxy/gateway error page (e.g. a 502 HTML body) is not JSON. A
|
|
47
|
+
// submit's outcome is then unknown, so it reads as pending; anything
|
|
48
|
+
// else simply could not be answered.
|
|
49
|
+
throw new FundingError("Service response was not valid JSON. Keep your quote reference and recover its status before submitting again.", path === "/v1/sponsorship/submit" ? "pending" : "unavailable");
|
|
50
|
+
}
|
|
42
51
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
43
52
|
throw new FundingError("Invalid service response", "unavailable");
|
|
44
53
|
if (!r.ok || value.error)
|
package/dist/index.js
CHANGED
|
@@ -228,6 +228,25 @@ const REGISTRY_ERRORS = {
|
|
|
228
228
|
40: "UpgradeNotApproved",
|
|
229
229
|
41: "PermanentLockDisabled",
|
|
230
230
|
};
|
|
231
|
+
/** Errors for a submit the network REJECTED as a stale sequence: nothing was included, so one retry with a fresh sequence is safe. */
|
|
232
|
+
const BAD_SEQ_REJECTED = new WeakSet();
|
|
233
|
+
function isBadSeqResult(result) {
|
|
234
|
+
try {
|
|
235
|
+
const field = result?.result;
|
|
236
|
+
const inner = (typeof field === "function" ? field.call(result) : field);
|
|
237
|
+
if (inner && typeof inner === "object" && "type" in inner)
|
|
238
|
+
return inner.type === "txBadSeq";
|
|
239
|
+
throw new Error("unrecognised result");
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
try {
|
|
243
|
+
return /txBadSeq|bad_seq/i.test(String(result?.toXDR?.() ?? ""));
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
231
250
|
/**
|
|
232
251
|
* A failed owner operation. When the contract itself rejected the call,
|
|
233
252
|
* `code`/`codeName` carry its typed error (e.g. code 9 / "NotNamespaceOwner"
|
|
@@ -788,7 +807,7 @@ export class SoranOwner {
|
|
|
788
807
|
catch (e) {
|
|
789
808
|
// A stale sequence (another process moved the account) is safe to
|
|
790
809
|
// retry once with a fresh sequence — nothing was included.
|
|
791
|
-
if (!(e instanceof OwnerError && e.txHash) && /txBadSeq|bad_seq/i.test(String(e))) {
|
|
810
|
+
if ((BAD_SEQ_REJECTED.has(e) || (!(e instanceof OwnerError && e.txHash) && /txBadSeq|bad_seq/i.test(String(e))))) {
|
|
792
811
|
return await this.attempt(contractId, fn, args, errNames);
|
|
793
812
|
}
|
|
794
813
|
throw e;
|
|
@@ -864,7 +883,10 @@ export class SoranOwner {
|
|
|
864
883
|
throw new OwnerError(`${fn}: submit failed after signing (${String(e)}) — transaction ${txHash} may or may not have reached the network; check the hash before retrying`, contractId, fn, null, null, txHash);
|
|
865
884
|
}
|
|
866
885
|
if (sent.status === "ERROR") {
|
|
867
|
-
|
|
886
|
+
const rejected = new OwnerError(`${fn}: submit rejected: ${JSON.stringify(sent.errorResult ?? sent.status)}`, contractId, fn, null, null, txHash);
|
|
887
|
+
if (isBadSeqResult(sent.errorResult))
|
|
888
|
+
BAD_SEQ_REJECTED.add(rejected);
|
|
889
|
+
throw rejected;
|
|
868
890
|
}
|
|
869
891
|
if (sent.status === "TRY_AGAIN_LATER") {
|
|
870
892
|
throw new OwnerError(`${fn}: the network did not accept the transaction (TRY_AGAIN_LATER) — it was NOT queued; safe to retry shortly`, contractId, fn, null, null, txHash);
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sorandomains/owner",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Run your Soran namespace on Stellar: configure claims, issue names and manage namespace policies.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=20"
|
|
8
|
+
},
|
|
6
9
|
"main": "./dist/index.js",
|
|
7
10
|
"types": "./dist/index.d.ts",
|
|
8
11
|
"files": [
|