@solana/web3.js 1.91.9 → 1.92.0
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 +115 -46
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +115 -46
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +115 -46
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +15 -2
- package/lib/index.esm.js +115 -46
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +115 -46
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +115 -46
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +15 -9
- package/src/errors.ts +70 -3
- package/src/utils/send-and-confirm-raw-transaction.ts +8 -0
- package/src/utils/send-and-confirm-transaction.ts +8 -0
package/lib/index.iife.js
CHANGED
|
@@ -13352,6 +13352,94 @@ var solanaWeb3 = (function (exports) {
|
|
|
13352
13352
|
const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
|
|
13353
13353
|
const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
|
|
13354
13354
|
|
|
13355
|
+
class SendTransactionError extends Error {
|
|
13356
|
+
constructor({
|
|
13357
|
+
action,
|
|
13358
|
+
signature,
|
|
13359
|
+
transactionMessage,
|
|
13360
|
+
transactionLogs
|
|
13361
|
+
}) {
|
|
13362
|
+
let message;
|
|
13363
|
+
switch (action) {
|
|
13364
|
+
case 'send':
|
|
13365
|
+
message = `Transaction ${signature} resulted in an error. \n` + `${transactionMessage}. ` + (transactionLogs ? `Logs: \n${JSON.stringify(transactionLogs.slice(-10), null, 2)}. ` : '') + '\nCatch the SendTransactionError and call `getLogs()` on it for full details.';
|
|
13366
|
+
break;
|
|
13367
|
+
case 'simulate':
|
|
13368
|
+
message = `Simulation failed. \nMessage: ${transactionMessage}. \n` + (transactionLogs ? `Logs: \n${JSON.stringify(transactionLogs.slice(-10), null, 2)}. ` : '') + '\nCatch the SendTransactionError and call `getLogs()` on it for full details.';
|
|
13369
|
+
break;
|
|
13370
|
+
default:
|
|
13371
|
+
message = 'Unknown action';
|
|
13372
|
+
}
|
|
13373
|
+
super(message);
|
|
13374
|
+
this.signature = void 0;
|
|
13375
|
+
this.transactionMessage = void 0;
|
|
13376
|
+
this.transactionLogs = void 0;
|
|
13377
|
+
this.resolvedLogs = void 0;
|
|
13378
|
+
this.signature = signature;
|
|
13379
|
+
this.transactionMessage = transactionMessage;
|
|
13380
|
+
this.transactionLogs = transactionLogs;
|
|
13381
|
+
this.resolvedLogs = transactionLogs ? transactionLogs : undefined;
|
|
13382
|
+
}
|
|
13383
|
+
get transactionError() {
|
|
13384
|
+
return {
|
|
13385
|
+
message: this.transactionMessage,
|
|
13386
|
+
logs: this.transactionLogs
|
|
13387
|
+
};
|
|
13388
|
+
}
|
|
13389
|
+
async getLogs(connection) {
|
|
13390
|
+
if (this.resolvedLogs === undefined) {
|
|
13391
|
+
this.resolvedLogs = new Promise((resolve, reject) => {
|
|
13392
|
+
connection.getTransaction(this.signature).then(tx => {
|
|
13393
|
+
if (tx && tx.meta && tx.meta.logMessages) {
|
|
13394
|
+
const logs = tx.meta.logMessages;
|
|
13395
|
+
this.resolvedLogs = logs;
|
|
13396
|
+
this.transactionLogs = logs;
|
|
13397
|
+
resolve(logs);
|
|
13398
|
+
} else {
|
|
13399
|
+
reject(new Error('Log messages not found'));
|
|
13400
|
+
}
|
|
13401
|
+
}).catch(reject);
|
|
13402
|
+
});
|
|
13403
|
+
}
|
|
13404
|
+
return await this.resolvedLogs;
|
|
13405
|
+
}
|
|
13406
|
+
}
|
|
13407
|
+
|
|
13408
|
+
// Keep in sync with client/src/rpc_custom_errors.rs
|
|
13409
|
+
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
13410
|
+
const SolanaJSONRPCErrorCode = {
|
|
13411
|
+
JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001,
|
|
13412
|
+
JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002,
|
|
13413
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003,
|
|
13414
|
+
JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004,
|
|
13415
|
+
JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005,
|
|
13416
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006,
|
|
13417
|
+
JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007,
|
|
13418
|
+
JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008,
|
|
13419
|
+
JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009,
|
|
13420
|
+
JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010,
|
|
13421
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011,
|
|
13422
|
+
JSON_RPC_SCAN_ERROR: -32012,
|
|
13423
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013,
|
|
13424
|
+
JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014,
|
|
13425
|
+
JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015,
|
|
13426
|
+
JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016
|
|
13427
|
+
};
|
|
13428
|
+
class SolanaJSONRPCError extends Error {
|
|
13429
|
+
constructor({
|
|
13430
|
+
code,
|
|
13431
|
+
message,
|
|
13432
|
+
data
|
|
13433
|
+
}, customMessage) {
|
|
13434
|
+
super(customMessage != null ? `${customMessage}: ${message}` : message);
|
|
13435
|
+
this.code = void 0;
|
|
13436
|
+
this.data = void 0;
|
|
13437
|
+
this.code = code;
|
|
13438
|
+
this.data = data;
|
|
13439
|
+
this.name = 'SolanaJSONRPCError';
|
|
13440
|
+
}
|
|
13441
|
+
}
|
|
13442
|
+
|
|
13355
13443
|
/**
|
|
13356
13444
|
* Sign, send and confirm a transaction.
|
|
13357
13445
|
*
|
|
@@ -13398,6 +13486,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
13398
13486
|
status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
13399
13487
|
}
|
|
13400
13488
|
if (status.err) {
|
|
13489
|
+
if (signature != null) {
|
|
13490
|
+
throw new SendTransactionError({
|
|
13491
|
+
action: 'send',
|
|
13492
|
+
signature: signature,
|
|
13493
|
+
transactionMessage: `Status: (${JSON.stringify(status)})`
|
|
13494
|
+
});
|
|
13495
|
+
}
|
|
13401
13496
|
throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
|
|
13402
13497
|
}
|
|
13403
13498
|
return signature;
|
|
@@ -16086,49 +16181,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
16086
16181
|
}
|
|
16087
16182
|
}
|
|
16088
16183
|
|
|
16089
|
-
class SendTransactionError extends Error {
|
|
16090
|
-
constructor(message, logs) {
|
|
16091
|
-
super(message);
|
|
16092
|
-
this.logs = void 0;
|
|
16093
|
-
this.logs = logs;
|
|
16094
|
-
}
|
|
16095
|
-
}
|
|
16096
|
-
|
|
16097
|
-
// Keep in sync with client/src/rpc_custom_errors.rs
|
|
16098
|
-
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
16099
|
-
const SolanaJSONRPCErrorCode = {
|
|
16100
|
-
JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001,
|
|
16101
|
-
JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002,
|
|
16102
|
-
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003,
|
|
16103
|
-
JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004,
|
|
16104
|
-
JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005,
|
|
16105
|
-
JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006,
|
|
16106
|
-
JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007,
|
|
16107
|
-
JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008,
|
|
16108
|
-
JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009,
|
|
16109
|
-
JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010,
|
|
16110
|
-
JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011,
|
|
16111
|
-
JSON_RPC_SCAN_ERROR: -32012,
|
|
16112
|
-
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013,
|
|
16113
|
-
JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014,
|
|
16114
|
-
JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015,
|
|
16115
|
-
JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016
|
|
16116
|
-
};
|
|
16117
|
-
class SolanaJSONRPCError extends Error {
|
|
16118
|
-
constructor({
|
|
16119
|
-
code,
|
|
16120
|
-
message,
|
|
16121
|
-
data
|
|
16122
|
-
}, customMessage) {
|
|
16123
|
-
super(customMessage != null ? `${customMessage}: ${message}` : message);
|
|
16124
|
-
this.code = void 0;
|
|
16125
|
-
this.data = void 0;
|
|
16126
|
-
this.code = code;
|
|
16127
|
-
this.data = data;
|
|
16128
|
-
this.name = 'SolanaJSONRPCError';
|
|
16129
|
-
}
|
|
16130
|
-
}
|
|
16131
|
-
|
|
16132
16184
|
var fetchImpl = globalThis.fetch;
|
|
16133
16185
|
|
|
16134
16186
|
var client = {};
|
|
@@ -20642,7 +20694,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
20642
20694
|
console.error(res.error.message, logTrace);
|
|
20643
20695
|
}
|
|
20644
20696
|
}
|
|
20645
|
-
throw new SendTransactionError(
|
|
20697
|
+
throw new SendTransactionError({
|
|
20698
|
+
action: 'simulate',
|
|
20699
|
+
signature: '',
|
|
20700
|
+
transactionMessage: res.error.message,
|
|
20701
|
+
transactionLogs: logs
|
|
20702
|
+
});
|
|
20646
20703
|
}
|
|
20647
20704
|
return res.result;
|
|
20648
20705
|
}
|
|
@@ -20743,11 +20800,16 @@ var solanaWeb3 = (function (exports) {
|
|
|
20743
20800
|
const unsafeRes = await this._rpcRequest('sendTransaction', args);
|
|
20744
20801
|
const res = create(unsafeRes, SendTransactionRpcResult);
|
|
20745
20802
|
if ('error' in res) {
|
|
20746
|
-
let logs;
|
|
20803
|
+
let logs = undefined;
|
|
20747
20804
|
if ('data' in res.error) {
|
|
20748
20805
|
logs = res.error.data.logs;
|
|
20749
20806
|
}
|
|
20750
|
-
throw new SendTransactionError(
|
|
20807
|
+
throw new SendTransactionError({
|
|
20808
|
+
action: skipPreflight ? 'send' : 'simulate',
|
|
20809
|
+
signature: '',
|
|
20810
|
+
transactionMessage: res.error.message,
|
|
20811
|
+
transactionLogs: logs
|
|
20812
|
+
});
|
|
20751
20813
|
}
|
|
20752
20814
|
return res.result;
|
|
20753
20815
|
}
|
|
@@ -25039,6 +25101,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
25039
25101
|
const confirmationPromise = confirmationStrategy ? connection.confirmTransaction(confirmationStrategy, commitment) : connection.confirmTransaction(signature, commitment);
|
|
25040
25102
|
const status = (await confirmationPromise).value;
|
|
25041
25103
|
if (status.err) {
|
|
25104
|
+
if (signature != null) {
|
|
25105
|
+
throw new SendTransactionError({
|
|
25106
|
+
action: sendOptions?.skipPreflight ? 'send' : 'simulate',
|
|
25107
|
+
signature: signature,
|
|
25108
|
+
transactionMessage: `Status: (${JSON.stringify(status)})`
|
|
25109
|
+
});
|
|
25110
|
+
}
|
|
25042
25111
|
throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
|
|
25043
25112
|
}
|
|
25044
25113
|
return signature;
|