@solana/web3.js 1.92.1 → 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 -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 +1 -1
- package/src/errors.ts +35 -19
package/package.json
CHANGED
package/src/errors.ts
CHANGED
|
@@ -4,65 +4,81 @@ import {TransactionSignature} from './transaction';
|
|
|
4
4
|
export class SendTransactionError extends Error {
|
|
5
5
|
private signature: TransactionSignature;
|
|
6
6
|
private transactionMessage: string;
|
|
7
|
-
private
|
|
7
|
+
private transactionLogs: string[] | Promise<string[]> | undefined;
|
|
8
8
|
|
|
9
9
|
constructor({
|
|
10
10
|
action,
|
|
11
11
|
signature,
|
|
12
12
|
transactionMessage,
|
|
13
|
-
logs
|
|
13
|
+
logs,
|
|
14
14
|
}: {
|
|
15
15
|
action: 'send' | 'simulate';
|
|
16
16
|
signature: TransactionSignature;
|
|
17
17
|
transactionMessage: string;
|
|
18
18
|
logs?: string[];
|
|
19
19
|
}) {
|
|
20
|
+
const maybeLogsOutput = logs
|
|
21
|
+
? `Logs: \n${JSON.stringify(logs.slice(-10), null, 2)}. `
|
|
22
|
+
: '';
|
|
23
|
+
const guideText =
|
|
24
|
+
'\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.';
|
|
20
25
|
let message: string;
|
|
21
|
-
|
|
22
26
|
switch (action) {
|
|
23
27
|
case 'send':
|
|
24
28
|
message =
|
|
25
29
|
`Transaction ${signature} resulted in an error. \n` +
|
|
26
30
|
`${transactionMessage}. ` +
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
: '') +
|
|
30
|
-
'\nCatch the SendTransactionError and call `getLogs()` on it for full details.';
|
|
31
|
+
maybeLogsOutput +
|
|
32
|
+
guideText;
|
|
31
33
|
break;
|
|
32
34
|
case 'simulate':
|
|
33
35
|
message =
|
|
34
36
|
`Simulation failed. \nMessage: ${transactionMessage}. \n` +
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
: '') +
|
|
38
|
-
'\nCatch the SendTransactionError and call `getLogs()` on it for full details.';
|
|
37
|
+
maybeLogsOutput +
|
|
38
|
+
guideText;
|
|
39
39
|
break;
|
|
40
|
-
default:
|
|
41
|
-
message =
|
|
40
|
+
default: {
|
|
41
|
+
message = `Unknown action '${((a: never) => a)(action)}'`;
|
|
42
|
+
}
|
|
42
43
|
}
|
|
43
44
|
super(message);
|
|
44
45
|
|
|
45
46
|
this.signature = signature;
|
|
46
47
|
this.transactionMessage = transactionMessage;
|
|
47
|
-
this.
|
|
48
|
+
this.transactionLogs = logs ? logs : undefined;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
get transactionError(): {message: string; logs?: string[]} {
|
|
51
52
|
return {
|
|
52
53
|
message: this.transactionMessage,
|
|
53
|
-
logs: Array.isArray(this.
|
|
54
|
+
logs: Array.isArray(this.transactionLogs)
|
|
55
|
+
? this.transactionLogs
|
|
56
|
+
: undefined,
|
|
54
57
|
};
|
|
55
58
|
}
|
|
56
59
|
|
|
60
|
+
/* @deprecated Use `await getLogs()` instead */
|
|
61
|
+
get logs(): string[] | undefined {
|
|
62
|
+
const cachedLogs = this.transactionLogs;
|
|
63
|
+
if (
|
|
64
|
+
cachedLogs != null &&
|
|
65
|
+
typeof cachedLogs === 'object' &&
|
|
66
|
+
'then' in cachedLogs
|
|
67
|
+
) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return cachedLogs;
|
|
71
|
+
}
|
|
72
|
+
|
|
57
73
|
async getLogs(connection: Connection): Promise<string[]> {
|
|
58
|
-
if (!Array.isArray(this.
|
|
59
|
-
this.
|
|
74
|
+
if (!Array.isArray(this.transactionLogs)) {
|
|
75
|
+
this.transactionLogs = new Promise((resolve, reject) => {
|
|
60
76
|
connection
|
|
61
77
|
.getTransaction(this.signature)
|
|
62
78
|
.then(tx => {
|
|
63
79
|
if (tx && tx.meta && tx.meta.logMessages) {
|
|
64
80
|
const logs = tx.meta.logMessages;
|
|
65
|
-
this.
|
|
81
|
+
this.transactionLogs = logs;
|
|
66
82
|
resolve(logs);
|
|
67
83
|
} else {
|
|
68
84
|
reject(new Error('Log messages not found'));
|
|
@@ -71,7 +87,7 @@ export class SendTransactionError extends Error {
|
|
|
71
87
|
.catch(reject);
|
|
72
88
|
});
|
|
73
89
|
}
|
|
74
|
-
return await this.
|
|
90
|
+
return await this.transactionLogs;
|
|
75
91
|
}
|
|
76
92
|
}
|
|
77
93
|
|