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