@solana/web3.js 1.92.0 → 1.92.2
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 -14
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +24 -14
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +24 -14
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.esm.js +24 -14
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +24 -14
- 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 -14
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +2 -2
- package/src/errors.ts +38 -22
package/lib/index.d.ts
CHANGED
|
@@ -3755,18 +3755,18 @@ export class BpfLoader {
|
|
|
3755
3755
|
export class SendTransactionError extends Error {
|
|
3756
3756
|
private signature;
|
|
3757
3757
|
private transactionMessage;
|
|
3758
|
-
private transactionLogs
|
|
3759
|
-
|
|
3760
|
-
constructor({ action, signature, transactionMessage, transactionLogs, }: {
|
|
3758
|
+
private transactionLogs;
|
|
3759
|
+
constructor({ action, signature, transactionMessage, logs, }: {
|
|
3761
3760
|
action: 'send' | 'simulate';
|
|
3762
3761
|
signature: TransactionSignature;
|
|
3763
3762
|
transactionMessage: string;
|
|
3764
|
-
|
|
3763
|
+
logs?: string[];
|
|
3765
3764
|
});
|
|
3766
3765
|
get transactionError(): {
|
|
3767
3766
|
message: string;
|
|
3768
3767
|
logs?: string[];
|
|
3769
3768
|
};
|
|
3769
|
+
get logs(): string[] | undefined;
|
|
3770
3770
|
getLogs(connection: Connection): Promise<string[]>;
|
|
3771
3771
|
}
|
|
3772
3772
|
export const SolanaJSONRPCErrorCode: {
|
package/lib/index.esm.js
CHANGED
|
@@ -2130,42 +2130,52 @@ class SendTransactionError extends Error {
|
|
|
2130
2130
|
action,
|
|
2131
2131
|
signature,
|
|
2132
2132
|
transactionMessage,
|
|
2133
|
-
|
|
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
2153
|
this.transactionLogs = void 0;
|
|
2150
|
-
this.resolvedLogs = void 0;
|
|
2151
2154
|
this.signature = signature;
|
|
2152
2155
|
this.transactionMessage = transactionMessage;
|
|
2153
|
-
this.transactionLogs =
|
|
2154
|
-
this.resolvedLogs = transactionLogs ? transactionLogs : undefined;
|
|
2156
|
+
this.transactionLogs = logs ? logs : undefined;
|
|
2155
2157
|
}
|
|
2156
2158
|
get transactionError() {
|
|
2157
2159
|
return {
|
|
2158
2160
|
message: this.transactionMessage,
|
|
2159
|
-
logs: this.transactionLogs
|
|
2161
|
+
logs: Array.isArray(this.transactionLogs) ? this.transactionLogs : undefined
|
|
2160
2162
|
};
|
|
2161
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
|
+
}
|
|
2162
2173
|
async getLogs(connection) {
|
|
2163
|
-
if (this.
|
|
2164
|
-
this.
|
|
2174
|
+
if (!Array.isArray(this.transactionLogs)) {
|
|
2175
|
+
this.transactionLogs = new Promise((resolve, reject) => {
|
|
2165
2176
|
connection.getTransaction(this.signature).then(tx => {
|
|
2166
2177
|
if (tx && tx.meta && tx.meta.logMessages) {
|
|
2167
2178
|
const logs = tx.meta.logMessages;
|
|
2168
|
-
this.resolvedLogs = logs;
|
|
2169
2179
|
this.transactionLogs = logs;
|
|
2170
2180
|
resolve(logs);
|
|
2171
2181
|
} else {
|
|
@@ -2174,7 +2184,7 @@ class SendTransactionError extends Error {
|
|
|
2174
2184
|
}).catch(reject);
|
|
2175
2185
|
});
|
|
2176
2186
|
}
|
|
2177
|
-
return await this.
|
|
2187
|
+
return await this.transactionLogs;
|
|
2178
2188
|
}
|
|
2179
2189
|
}
|
|
2180
2190
|
|
|
@@ -7966,7 +7976,7 @@ class Connection {
|
|
|
7966
7976
|
action: 'simulate',
|
|
7967
7977
|
signature: '',
|
|
7968
7978
|
transactionMessage: res.error.message,
|
|
7969
|
-
|
|
7979
|
+
logs: logs
|
|
7970
7980
|
});
|
|
7971
7981
|
}
|
|
7972
7982
|
return res.result;
|
|
@@ -8076,7 +8086,7 @@ class Connection {
|
|
|
8076
8086
|
action: skipPreflight ? 'send' : 'simulate',
|
|
8077
8087
|
signature: '',
|
|
8078
8088
|
transactionMessage: res.error.message,
|
|
8079
|
-
|
|
8089
|
+
logs: logs
|
|
8080
8090
|
});
|
|
8081
8091
|
}
|
|
8082
8092
|
return res.result;
|