@t2000/sdk 0.8.6 → 0.8.7
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/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +21 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -124,10 +124,25 @@ function mapMoveAbortCode(code) {
|
|
|
124
124
|
7: "Package version mismatch \u2014 upgrade required",
|
|
125
125
|
8: "Timelock is active \u2014 wait for expiry",
|
|
126
126
|
9: "No pending change to execute",
|
|
127
|
-
10: "Already at current version"
|
|
127
|
+
10: "Already at current version",
|
|
128
|
+
// NAVI Protocol abort codes
|
|
129
|
+
1502: "Oracle price is stale \u2014 try again in a moment",
|
|
130
|
+
1600: "Health factor too low \u2014 withdrawal would risk liquidation",
|
|
131
|
+
1605: "Asset borrowing is disabled or at capacity on this protocol"
|
|
128
132
|
};
|
|
129
133
|
return abortMessages[code] ?? `Move abort code: ${code}`;
|
|
130
134
|
}
|
|
135
|
+
function isMoveAbort(msg) {
|
|
136
|
+
return msg.includes("MoveAbort") || msg.includes("MovePrimitiveRuntimeError");
|
|
137
|
+
}
|
|
138
|
+
function parseMoveAbortMessage(msg) {
|
|
139
|
+
const abortMatch = msg.match(/abort code:\s*(\d+)/i) ?? msg.match(/MoveAbort[^,]*,\s*(\d+)/);
|
|
140
|
+
if (abortMatch) {
|
|
141
|
+
const code = parseInt(abortMatch[1], 10);
|
|
142
|
+
return mapMoveAbortCode(code);
|
|
143
|
+
}
|
|
144
|
+
return msg;
|
|
145
|
+
}
|
|
131
146
|
|
|
132
147
|
// src/utils/sui.ts
|
|
133
148
|
var cachedClient = null;
|
|
@@ -2237,7 +2252,11 @@ async function executeWithGas(client, keypair, buildTx) {
|
|
|
2237
2252
|
if (result) return result;
|
|
2238
2253
|
errors.push("self-funded: SUI below threshold");
|
|
2239
2254
|
} catch (err) {
|
|
2240
|
-
|
|
2255
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2256
|
+
if (isMoveAbort(msg)) {
|
|
2257
|
+
throw new T2000Error("TRANSACTION_FAILED", parseMoveAbortMessage(msg));
|
|
2258
|
+
}
|
|
2259
|
+
errors.push(`self-funded: ${msg}`);
|
|
2241
2260
|
}
|
|
2242
2261
|
try {
|
|
2243
2262
|
const tx = await buildTx();
|