wasabi-solana-ts 1.2.6 → 1.2.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.
|
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getFailingSwapProgram = exports.matchError = exports.parseErrorLogs = exports.parseSimulationError = exports.parseError = exports.parseSendTransactionError = exports.SimulationError = void 0;
|
|
27
27
|
const jupiter_1 = require("./jupiter");
|
|
28
|
+
const titan_1 = require("./titan");
|
|
28
29
|
const web3_js_1 = require("@solana/web3.js");
|
|
29
30
|
const spl_token_1 = require("@solana/spl-token");
|
|
30
31
|
const idl = __importStar(require("../idl/wasabi_solana.json"));
|
|
@@ -52,6 +53,10 @@ const jupiterProgramId = 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4';
|
|
|
52
53
|
const jupiterExpectedErrors = [
|
|
53
54
|
6001 // SlippageToleranceExceeded
|
|
54
55
|
];
|
|
56
|
+
const titanProgramId = 'T1TANpTeScyeqVzzgNViGDNrkQ6qHz9KrSBS4aNXvGT';
|
|
57
|
+
const titanExpectedErrors = [
|
|
58
|
+
6008 // LessThanMinimumAmountOut
|
|
59
|
+
];
|
|
55
60
|
//@ts-ignore
|
|
56
61
|
const raydiumErrors = [
|
|
57
62
|
6028, // Invalid first tick array
|
|
@@ -81,6 +86,18 @@ const jupiterErrorIndex = jupiter_1.IDL.errors.reduce((acc, error) => {
|
|
|
81
86
|
const findJupiterError = (code) => {
|
|
82
87
|
return jupiterErrorIndex[code];
|
|
83
88
|
};
|
|
89
|
+
const titanErrorIndex = titan_1.IDL.errors.reduce((acc, error) => {
|
|
90
|
+
const expected = titanExpectedErrors.includes(error.code);
|
|
91
|
+
acc[error.code] = {
|
|
92
|
+
...error,
|
|
93
|
+
expected,
|
|
94
|
+
program: 'Titan'
|
|
95
|
+
};
|
|
96
|
+
return acc;
|
|
97
|
+
}, {});
|
|
98
|
+
const findTitanError = (code) => {
|
|
99
|
+
return titanErrorIndex[code];
|
|
100
|
+
};
|
|
84
101
|
const parseSendTransactionError = (error, transaction) => {
|
|
85
102
|
const message = error.transactionError.message;
|
|
86
103
|
// Parse error messages like: "Transaction simulation failed: Error processing Instruction 3: custom program error: 0x1771"
|
|
@@ -108,6 +125,9 @@ const parseError = (instructionNumber, errorCode, transaction) => {
|
|
|
108
125
|
else if (programId === jupiterProgramId) {
|
|
109
126
|
return findJupiterError(errorCode);
|
|
110
127
|
}
|
|
128
|
+
else if (programId === titanProgramId) {
|
|
129
|
+
return findTitanError(errorCode);
|
|
130
|
+
}
|
|
111
131
|
return undefined;
|
|
112
132
|
};
|
|
113
133
|
exports.parseError = parseError;
|
|
@@ -153,14 +173,19 @@ const parseErrorLogs = (logs) => {
|
|
|
153
173
|
}
|
|
154
174
|
const match = log.match(/^Program ([a-zA-Z0-9]+) failed: (?:.*?): (0x[0-9a-fA-F]+)$/);
|
|
155
175
|
if (match) {
|
|
156
|
-
|
|
157
|
-
|
|
176
|
+
const [_, failingProgramId, errorHex] = match;
|
|
177
|
+
const errorCode = parseInt(errorHex);
|
|
178
|
+
if (failingProgramId.localeCompare(jupiterProgramId) === 0) {
|
|
179
|
+
return findJupiterError(errorCode);
|
|
180
|
+
}
|
|
181
|
+
else if (failingProgramId.localeCompare(titanProgramId) === 0) {
|
|
182
|
+
return findTitanError(errorCode);
|
|
158
183
|
}
|
|
159
|
-
else if (
|
|
160
|
-
return findWasabiError(
|
|
184
|
+
else if (failingProgramId.localeCompare(wasabiProgramId) === 0) {
|
|
185
|
+
return findWasabiError(errorCode);
|
|
161
186
|
}
|
|
162
|
-
else if (
|
|
163
|
-
return parseSystemError(
|
|
187
|
+
else if (failingProgramId.localeCompare(web3_js_1.SystemProgram.programId.toBase58())) {
|
|
188
|
+
return parseSystemError(errorCode, web3_js_1.SystemProgram.programId.toBase58());
|
|
164
189
|
}
|
|
165
190
|
}
|
|
166
191
|
}
|