@solana/web3.js 1.92.1 → 1.92.3
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/lib/index.browser.cjs.js +24 -11
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +24 -11
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +24 -11
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.esm.js +24 -11
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +24 -11
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +1 -1
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +24 -11
- package/lib/index.native.js.map +1 -1
- package/package.json +2 -2
- package/src/errors.ts +35 -19
package/lib/index.d.ts
CHANGED
|
@@ -3755,8 +3755,8 @@ export class BpfLoader {
|
|
|
3755
3755
|
export class SendTransactionError extends Error {
|
|
3756
3756
|
private signature;
|
|
3757
3757
|
private transactionMessage;
|
|
3758
|
-
private
|
|
3759
|
-
constructor({ action, signature, transactionMessage, logs
|
|
3758
|
+
private transactionLogs;
|
|
3759
|
+
constructor({ action, signature, transactionMessage, logs, }: {
|
|
3760
3760
|
action: 'send' | 'simulate';
|
|
3761
3761
|
signature: TransactionSignature;
|
|
3762
3762
|
transactionMessage: string;
|
|
@@ -3766,6 +3766,7 @@ export class SendTransactionError extends Error {
|
|
|
3766
3766
|
message: string;
|
|
3767
3767
|
logs?: string[];
|
|
3768
3768
|
};
|
|
3769
|
+
get logs(): string[] | undefined;
|
|
3769
3770
|
getLogs(connection: Connection): Promise<string[]>;
|
|
3770
3771
|
}
|
|
3771
3772
|
export const SolanaJSONRPCErrorCode: {
|
package/lib/index.esm.js
CHANGED
|
@@ -2130,40 +2130,53 @@ class SendTransactionError extends Error {
|
|
|
2130
2130
|
action,
|
|
2131
2131
|
signature,
|
|
2132
2132
|
transactionMessage,
|
|
2133
|
-
logs
|
|
2133
|
+
logs
|
|
2134
2134
|
}) {
|
|
2135
|
+
const maybeLogsOutput = logs ? `Logs: \n${JSON.stringify(logs.slice(-10), null, 2)}. ` : '';
|
|
2136
|
+
const guideText = '\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.';
|
|
2135
2137
|
let message;
|
|
2136
2138
|
switch (action) {
|
|
2137
2139
|
case 'send':
|
|
2138
|
-
message = `Transaction ${signature} resulted in an error. \n` + `${transactionMessage}. ` +
|
|
2140
|
+
message = `Transaction ${signature} resulted in an error. \n` + `${transactionMessage}. ` + maybeLogsOutput + guideText;
|
|
2139
2141
|
break;
|
|
2140
2142
|
case 'simulate':
|
|
2141
|
-
message = `Simulation failed. \nMessage: ${transactionMessage}. \n` +
|
|
2143
|
+
message = `Simulation failed. \nMessage: ${transactionMessage}. \n` + maybeLogsOutput + guideText;
|
|
2142
2144
|
break;
|
|
2143
2145
|
default:
|
|
2144
|
-
|
|
2146
|
+
{
|
|
2147
|
+
message = `Unknown action '${(a => a)(action)}'`;
|
|
2148
|
+
}
|
|
2145
2149
|
}
|
|
2146
2150
|
super(message);
|
|
2147
2151
|
this.signature = void 0;
|
|
2148
2152
|
this.transactionMessage = void 0;
|
|
2149
|
-
this.
|
|
2153
|
+
this.transactionLogs = void 0;
|
|
2150
2154
|
this.signature = signature;
|
|
2151
2155
|
this.transactionMessage = transactionMessage;
|
|
2152
|
-
this.
|
|
2156
|
+
this.transactionLogs = logs ? logs : undefined;
|
|
2153
2157
|
}
|
|
2154
2158
|
get transactionError() {
|
|
2155
2159
|
return {
|
|
2156
2160
|
message: this.transactionMessage,
|
|
2157
|
-
logs: Array.isArray(this.
|
|
2161
|
+
logs: Array.isArray(this.transactionLogs) ? this.transactionLogs : undefined
|
|
2158
2162
|
};
|
|
2159
2163
|
}
|
|
2164
|
+
|
|
2165
|
+
/* @deprecated Use `await getLogs()` instead */
|
|
2166
|
+
get logs() {
|
|
2167
|
+
const cachedLogs = this.transactionLogs;
|
|
2168
|
+
if (cachedLogs != null && typeof cachedLogs === 'object' && 'then' in cachedLogs) {
|
|
2169
|
+
return undefined;
|
|
2170
|
+
}
|
|
2171
|
+
return cachedLogs;
|
|
2172
|
+
}
|
|
2160
2173
|
async getLogs(connection) {
|
|
2161
|
-
if (!Array.isArray(this.
|
|
2162
|
-
this.
|
|
2174
|
+
if (!Array.isArray(this.transactionLogs)) {
|
|
2175
|
+
this.transactionLogs = new Promise((resolve, reject) => {
|
|
2163
2176
|
connection.getTransaction(this.signature).then(tx => {
|
|
2164
2177
|
if (tx && tx.meta && tx.meta.logMessages) {
|
|
2165
2178
|
const logs = tx.meta.logMessages;
|
|
2166
|
-
this.
|
|
2179
|
+
this.transactionLogs = logs;
|
|
2167
2180
|
resolve(logs);
|
|
2168
2181
|
} else {
|
|
2169
2182
|
reject(new Error('Log messages not found'));
|
|
@@ -2171,7 +2184,7 @@ class SendTransactionError extends Error {
|
|
|
2171
2184
|
}).catch(reject);
|
|
2172
2185
|
});
|
|
2173
2186
|
}
|
|
2174
|
-
return await this.
|
|
2187
|
+
return await this.transactionLogs;
|
|
2175
2188
|
}
|
|
2176
2189
|
}
|
|
2177
2190
|
|