@le-space/browser 0.6.23 → 0.6.25
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/index.d.ts +1 -1
- package/index.js +17 -3
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ interface PrepaidVaultSnapshot {
|
|
|
43
43
|
reservedBalance: bigint;
|
|
44
44
|
currentReservation: PrepaidReservation | null;
|
|
45
45
|
}
|
|
46
|
-
type MessageStatus = 'processed' | 'pending' | 'rejected' | 'unknown';
|
|
46
|
+
type MessageStatus = 'processed' | 'pending' | 'rejected' | 'removing' | 'removed' | 'unknown';
|
|
47
47
|
type ReferenceStatus = MessageStatus | 'missing';
|
|
48
48
|
type AlephSenderChain = 'ETH';
|
|
49
49
|
type AlephMessageType = 'INSTANCE' | 'FORGET' | 'AGGREGATE';
|
package/index.js
CHANGED
|
@@ -847,7 +847,7 @@ async function verifyRootfsExists(itemHash, apiHost = DEFAULT_ALEPH_API_HOST) {
|
|
|
847
847
|
function normalizeStatus(status) {
|
|
848
848
|
if (typeof status !== "string") return "unknown";
|
|
849
849
|
const normalized = status.toLowerCase();
|
|
850
|
-
if (normalized === "processed" || normalized === "pending" || normalized === "rejected") {
|
|
850
|
+
if (normalized === "processed" || normalized === "pending" || normalized === "rejected" || normalized === "removing" || normalized === "removed") {
|
|
851
851
|
return normalized;
|
|
852
852
|
}
|
|
853
853
|
return "unknown";
|
|
@@ -872,6 +872,7 @@ function parseCidFromPayload(payload) {
|
|
|
872
872
|
}
|
|
873
873
|
function parseRejectionReason(payload) {
|
|
874
874
|
const errorCode = typeof payload.error_code === "number" ? payload.error_code : null;
|
|
875
|
+
const reason = typeof payload.reason === "string" ? payload.reason.trim() : "";
|
|
875
876
|
const details = payload.details && typeof payload.details === "object" ? payload.details : null;
|
|
876
877
|
const rawErrors = Array.isArray(details?.errors) ? details.errors : [];
|
|
877
878
|
const firstError = rawErrors[0] && typeof rawErrors[0] === "object" ? rawErrors[0] : null;
|
|
@@ -886,6 +887,18 @@ function parseRejectionReason(payload) {
|
|
|
886
887
|
};
|
|
887
888
|
}
|
|
888
889
|
}
|
|
890
|
+
if (reason === "balance_insufficient") {
|
|
891
|
+
return {
|
|
892
|
+
rejectionErrorCode: errorCode,
|
|
893
|
+
rejectionReason: "The rootfs STORE is being removed because its publisher no longer has enough Aleph credits. Your connected MetaMask balance may be sufficient, but this manifest must point to a newly published, processed rootfs STORE."
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
if (reason) {
|
|
897
|
+
return {
|
|
898
|
+
rejectionErrorCode: errorCode,
|
|
899
|
+
rejectionReason: `Aleph marked the rootfs STORE as unavailable: ${reason.replaceAll("_", " ")}.`
|
|
900
|
+
};
|
|
901
|
+
}
|
|
889
902
|
return {
|
|
890
903
|
rejectionErrorCode: errorCode,
|
|
891
904
|
rejectionReason: errorCode != null ? `Rejected by Aleph (error code ${errorCode}).` : null
|
|
@@ -927,11 +940,12 @@ async function resolveRootfsReference(itemHash, apiHost = DEFAULT_ALEPH_API_HOST
|
|
|
927
940
|
const firstMessage = Array.isArray(payload.messages) && payload.messages[0] && typeof payload.messages[0] === "object" ? payload.messages[0] : null;
|
|
928
941
|
const messageObject = payload.message && typeof payload.message === "object" ? payload.message : null;
|
|
929
942
|
const cid = parseCidFromPayload(payload);
|
|
930
|
-
const
|
|
943
|
+
const messageStatus = normalizeStatus(payload.status);
|
|
944
|
+
const rejection = messageStatus === "processed" || messageStatus === "pending" ? { rejectionErrorCode: null, rejectionReason: null } : parseRejectionReason(payload);
|
|
931
945
|
const gateway = cid ? await probeGateway(cid, gatewayBaseUrl) : { gatewayUrl: null, gatewayStatus: "unknown", gatewayError: null };
|
|
932
946
|
return {
|
|
933
947
|
itemHash,
|
|
934
|
-
messageStatus
|
|
948
|
+
messageStatus,
|
|
935
949
|
messageType: String(payload.type || messageObject?.type || firstMessage?.type || "").toUpperCase() || null,
|
|
936
950
|
cid,
|
|
937
951
|
receptionTime: typeof payload.reception_time === "string" ? payload.reception_time : null,
|