@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/package.json
CHANGED
package/src/connection.ts
CHANGED
|
@@ -5787,7 +5787,7 @@ export class Connection {
|
|
|
5787
5787
|
action: 'simulate',
|
|
5788
5788
|
signature: '',
|
|
5789
5789
|
transactionMessage: res.error.message,
|
|
5790
|
-
|
|
5790
|
+
logs: logs,
|
|
5791
5791
|
});
|
|
5792
5792
|
}
|
|
5793
5793
|
return res.result;
|
|
@@ -5928,7 +5928,7 @@ export class Connection {
|
|
|
5928
5928
|
action: skipPreflight ? 'send' : 'simulate',
|
|
5929
5929
|
signature: '',
|
|
5930
5930
|
transactionMessage: res.error.message,
|
|
5931
|
-
|
|
5931
|
+
logs: logs,
|
|
5932
5932
|
});
|
|
5933
5933
|
}
|
|
5934
5934
|
return res.result;
|
package/src/errors.ts
CHANGED
|
@@ -4,64 +4,80 @@ import {TransactionSignature} from './transaction';
|
|
|
4
4
|
export class SendTransactionError extends Error {
|
|
5
5
|
private signature: TransactionSignature;
|
|
6
6
|
private transactionMessage: string;
|
|
7
|
-
private transactionLogs
|
|
8
|
-
private resolvedLogs: string[] | Promise<string[]> | undefined;
|
|
7
|
+
private transactionLogs: string[] | Promise<string[]> | undefined;
|
|
9
8
|
|
|
10
9
|
constructor({
|
|
11
10
|
action,
|
|
12
11
|
signature,
|
|
13
12
|
transactionMessage,
|
|
14
|
-
|
|
13
|
+
logs,
|
|
15
14
|
}: {
|
|
16
15
|
action: 'send' | 'simulate';
|
|
17
16
|
signature: TransactionSignature;
|
|
18
17
|
transactionMessage: string;
|
|
19
|
-
|
|
18
|
+
logs?: string[];
|
|
20
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.';
|
|
21
25
|
let message: string;
|
|
22
|
-
|
|
23
26
|
switch (action) {
|
|
24
27
|
case 'send':
|
|
25
28
|
message =
|
|
26
29
|
`Transaction ${signature} resulted in an error. \n` +
|
|
27
30
|
`${transactionMessage}. ` +
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
: '') +
|
|
31
|
-
'\nCatch the SendTransactionError and call `getLogs()` on it for full details.';
|
|
31
|
+
maybeLogsOutput +
|
|
32
|
+
guideText;
|
|
32
33
|
break;
|
|
33
34
|
case 'simulate':
|
|
34
35
|
message =
|
|
35
36
|
`Simulation failed. \nMessage: ${transactionMessage}. \n` +
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
: '') +
|
|
39
|
-
'\nCatch the SendTransactionError and call `getLogs()` on it for full details.';
|
|
37
|
+
maybeLogsOutput +
|
|
38
|
+
guideText;
|
|
40
39
|
break;
|
|
41
|
-
default:
|
|
42
|
-
message =
|
|
40
|
+
default: {
|
|
41
|
+
message = `Unknown action '${((a: never) => a)(action)}'`;
|
|
42
|
+
}
|
|
43
43
|
}
|
|
44
44
|
super(message);
|
|
45
45
|
|
|
46
46
|
this.signature = signature;
|
|
47
47
|
this.transactionMessage = transactionMessage;
|
|
48
|
-
this.transactionLogs =
|
|
49
|
-
this.resolvedLogs = transactionLogs ? transactionLogs : undefined;
|
|
48
|
+
this.transactionLogs = logs ? logs : undefined;
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
get transactionError(): {message: string; logs?: string[]} {
|
|
53
|
-
return {
|
|
52
|
+
return {
|
|
53
|
+
message: this.transactionMessage,
|
|
54
|
+
logs: Array.isArray(this.transactionLogs)
|
|
55
|
+
? this.transactionLogs
|
|
56
|
+
: undefined,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
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;
|
|
54
71
|
}
|
|
55
72
|
|
|
56
73
|
async getLogs(connection: Connection): Promise<string[]> {
|
|
57
|
-
if (this.
|
|
58
|
-
this.
|
|
74
|
+
if (!Array.isArray(this.transactionLogs)) {
|
|
75
|
+
this.transactionLogs = new Promise((resolve, reject) => {
|
|
59
76
|
connection
|
|
60
77
|
.getTransaction(this.signature)
|
|
61
78
|
.then(tx => {
|
|
62
79
|
if (tx && tx.meta && tx.meta.logMessages) {
|
|
63
80
|
const logs = tx.meta.logMessages;
|
|
64
|
-
this.resolvedLogs = logs;
|
|
65
81
|
this.transactionLogs = logs;
|
|
66
82
|
resolve(logs);
|
|
67
83
|
} else {
|
|
@@ -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
|
|