@solana/web3.js 1.57.1 → 1.58.1

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.iife.js CHANGED
@@ -11087,6 +11087,121 @@ var solanaWeb3 = (function (exports) {
11087
11087
  }
11088
11088
  }
11089
11089
 
11090
+ function assert$1 (condition, message) {
11091
+ if (!condition) {
11092
+ throw new Error(message || 'Assertion failed');
11093
+ }
11094
+ }
11095
+
11096
+ class CompiledKeys {
11097
+ constructor(payer, keyMetaMap) {
11098
+ this.payer = void 0;
11099
+ this.keyMetaMap = void 0;
11100
+ this.payer = payer;
11101
+ this.keyMetaMap = keyMetaMap;
11102
+ }
11103
+
11104
+ static compile(instructions, payer) {
11105
+ const keyMetaMap = new Map();
11106
+
11107
+ const getOrInsertDefault = pubkey => {
11108
+ const address = pubkey.toBase58();
11109
+ let keyMeta = keyMetaMap.get(address);
11110
+
11111
+ if (keyMeta === undefined) {
11112
+ keyMeta = {
11113
+ isSigner: false,
11114
+ isWritable: false,
11115
+ isInvoked: false
11116
+ };
11117
+ keyMetaMap.set(address, keyMeta);
11118
+ }
11119
+
11120
+ return keyMeta;
11121
+ };
11122
+
11123
+ const payerKeyMeta = getOrInsertDefault(payer);
11124
+ payerKeyMeta.isSigner = true;
11125
+ payerKeyMeta.isWritable = true;
11126
+
11127
+ for (const ix of instructions) {
11128
+ getOrInsertDefault(ix.programId).isInvoked = true;
11129
+
11130
+ for (const accountMeta of ix.keys) {
11131
+ const keyMeta = getOrInsertDefault(accountMeta.pubkey);
11132
+ keyMeta.isSigner || (keyMeta.isSigner = accountMeta.isSigner);
11133
+ keyMeta.isWritable || (keyMeta.isWritable = accountMeta.isWritable);
11134
+ }
11135
+ }
11136
+
11137
+ return new CompiledKeys(payer, keyMetaMap);
11138
+ }
11139
+
11140
+ getMessageComponents() {
11141
+ const mapEntries = [...this.keyMetaMap.entries()];
11142
+ assert$1(mapEntries.length <= 256, 'Max static account keys length exceeded');
11143
+ const writableSigners = mapEntries.filter(([, meta]) => meta.isSigner && meta.isWritable);
11144
+ const readonlySigners = mapEntries.filter(([, meta]) => meta.isSigner && !meta.isWritable);
11145
+ const writableNonSigners = mapEntries.filter(([, meta]) => !meta.isSigner && meta.isWritable);
11146
+ const readonlyNonSigners = mapEntries.filter(([, meta]) => !meta.isSigner && !meta.isWritable);
11147
+ const header = {
11148
+ numRequiredSignatures: writableSigners.length + readonlySigners.length,
11149
+ numReadonlySignedAccounts: readonlySigners.length,
11150
+ numReadonlyUnsignedAccounts: readonlyNonSigners.length
11151
+ }; // sanity checks
11152
+
11153
+ {
11154
+ assert$1(writableSigners.length > 0, 'Expected at least one writable signer key');
11155
+ const [payerAddress] = writableSigners[0];
11156
+ assert$1(payerAddress === this.payer.toBase58(), 'Expected first writable signer key to be the fee payer');
11157
+ }
11158
+ const staticAccountKeys = [...writableSigners.map(([address]) => new PublicKey(address)), ...readonlySigners.map(([address]) => new PublicKey(address)), ...writableNonSigners.map(([address]) => new PublicKey(address)), ...readonlyNonSigners.map(([address]) => new PublicKey(address))];
11159
+ return [header, staticAccountKeys];
11160
+ }
11161
+
11162
+ extractTableLookup(lookupTable) {
11163
+ const [writableIndexes, drainedWritableKeys] = this.drainKeysFoundInLookupTable(lookupTable.state.addresses, keyMeta => !keyMeta.isSigner && !keyMeta.isInvoked && keyMeta.isWritable);
11164
+ const [readonlyIndexes, drainedReadonlyKeys] = this.drainKeysFoundInLookupTable(lookupTable.state.addresses, keyMeta => !keyMeta.isSigner && !keyMeta.isInvoked && !keyMeta.isWritable); // Don't extract lookup if no keys were found
11165
+
11166
+ if (writableIndexes.length === 0 && readonlyIndexes.length === 0) {
11167
+ return;
11168
+ }
11169
+
11170
+ return [{
11171
+ accountKey: lookupTable.key,
11172
+ writableIndexes,
11173
+ readonlyIndexes
11174
+ }, {
11175
+ writable: drainedWritableKeys,
11176
+ readonly: drainedReadonlyKeys
11177
+ }];
11178
+ }
11179
+ /** @internal */
11180
+
11181
+
11182
+ drainKeysFoundInLookupTable(lookupTableEntries, keyMetaFilter) {
11183
+ const lookupTableIndexes = new Array();
11184
+ const drainedKeys = new Array();
11185
+
11186
+ for (const [address, keyMeta] of this.keyMetaMap.entries()) {
11187
+ if (keyMetaFilter(keyMeta)) {
11188
+ const key = new PublicKey(address);
11189
+ const lookupTableIndex = lookupTableEntries.findIndex(entry => entry.equals(key));
11190
+
11191
+ if (lookupTableIndex >= 0) {
11192
+ assert$1(lookupTableIndex < 256, 'Max lookup table index exceeded');
11193
+ lookupTableIndexes.push(lookupTableIndex);
11194
+ drainedKeys.push(key);
11195
+ this.keyMetaMap.delete(address);
11196
+ }
11197
+ }
11198
+ }
11199
+
11200
+ return [lookupTableIndexes, drainedKeys];
11201
+ }
11202
+
11203
+ }
11204
+
11090
11205
  const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
11091
11206
  /**
11092
11207
  * Delegates to `Array#shift`, but throws if the array is zero-length.
@@ -11162,6 +11277,27 @@ var solanaWeb3 = (function (exports) {
11162
11277
  return [];
11163
11278
  }
11164
11279
 
11280
+ getAccountKeys() {
11281
+ return new MessageAccountKeys(this.staticAccountKeys);
11282
+ }
11283
+
11284
+ static compile(args) {
11285
+ const compiledKeys = CompiledKeys.compile(args.instructions, args.payerKey);
11286
+ const [header, staticAccountKeys] = compiledKeys.getMessageComponents();
11287
+ const accountKeys = new MessageAccountKeys(staticAccountKeys);
11288
+ const instructions = accountKeys.compileInstructions(args.instructions).map(ix => ({
11289
+ programIdIndex: ix.programIdIndex,
11290
+ accounts: ix.accountKeyIndexes,
11291
+ data: bs58$1.encode(ix.data)
11292
+ }));
11293
+ return new Message({
11294
+ header,
11295
+ accountKeys: staticAccountKeys,
11296
+ recentBlockhash: args.recentBlockhash,
11297
+ instructions
11298
+ });
11299
+ }
11300
+
11165
11301
  isAccountSigner(index) {
11166
11302
  return index < this.header.numRequiredSignatures;
11167
11303
  }
@@ -11250,7 +11386,7 @@ var solanaWeb3 = (function (exports) {
11250
11386
 
11251
11387
  for (let i = 0; i < accountCount; i++) {
11252
11388
  const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
11253
- accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
11389
+ accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
11254
11390
  }
11255
11391
 
11256
11392
  const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
@@ -11286,141 +11422,87 @@ var solanaWeb3 = (function (exports) {
11286
11422
 
11287
11423
  }
11288
11424
 
11289
- function assert$1 (condition, message) {
11290
- if (!condition) {
11291
- throw new Error(message || 'Assertion failed');
11292
- }
11293
- }
11425
+ /**
11426
+ * Message constructor arguments
11427
+ */
11294
11428
 
11295
- class CompiledKeys {
11296
- constructor(payer, keyMetaMap) {
11297
- this.payer = void 0;
11298
- this.keyMetaMap = void 0;
11299
- this.payer = payer;
11300
- this.keyMetaMap = keyMetaMap;
11429
+ class MessageV0 {
11430
+ constructor(args) {
11431
+ this.header = void 0;
11432
+ this.staticAccountKeys = void 0;
11433
+ this.recentBlockhash = void 0;
11434
+ this.compiledInstructions = void 0;
11435
+ this.addressTableLookups = void 0;
11436
+ this.header = args.header;
11437
+ this.staticAccountKeys = args.staticAccountKeys;
11438
+ this.recentBlockhash = args.recentBlockhash;
11439
+ this.compiledInstructions = args.compiledInstructions;
11440
+ this.addressTableLookups = args.addressTableLookups;
11301
11441
  }
11302
11442
 
11303
- static compile(instructions, payer) {
11304
- const keyMetaMap = new Map();
11305
-
11306
- const getOrInsertDefault = pubkey => {
11307
- const address = pubkey.toBase58();
11308
- let keyMeta = keyMetaMap.get(address);
11309
-
11310
- if (keyMeta === undefined) {
11311
- keyMeta = {
11312
- isSigner: false,
11313
- isWritable: false,
11314
- isInvoked: false
11315
- };
11316
- keyMetaMap.set(address, keyMeta);
11317
- }
11318
-
11319
- return keyMeta;
11320
- };
11321
-
11322
- const payerKeyMeta = getOrInsertDefault(payer);
11323
- payerKeyMeta.isSigner = true;
11324
- payerKeyMeta.isWritable = true;
11443
+ get version() {
11444
+ return 0;
11445
+ }
11325
11446
 
11326
- for (const ix of instructions) {
11327
- getOrInsertDefault(ix.programId).isInvoked = true;
11447
+ get numAccountKeysFromLookups() {
11448
+ let count = 0;
11328
11449
 
11329
- for (const accountMeta of ix.keys) {
11330
- const keyMeta = getOrInsertDefault(accountMeta.pubkey);
11331
- keyMeta.isSigner || (keyMeta.isSigner = accountMeta.isSigner);
11332
- keyMeta.isWritable || (keyMeta.isWritable = accountMeta.isWritable);
11333
- }
11450
+ for (const lookup of this.addressTableLookups) {
11451
+ count += lookup.readonlyIndexes.length + lookup.writableIndexes.length;
11334
11452
  }
11335
11453
 
11336
- return new CompiledKeys(payer, keyMetaMap);
11454
+ return count;
11337
11455
  }
11338
11456
 
11339
- getMessageComponents() {
11340
- const mapEntries = [...this.keyMetaMap.entries()];
11341
- assert$1(mapEntries.length <= 256, 'Max static account keys length exceeded');
11342
- const writableSigners = mapEntries.filter(([, meta]) => meta.isSigner && meta.isWritable);
11343
- const readonlySigners = mapEntries.filter(([, meta]) => meta.isSigner && !meta.isWritable);
11344
- const writableNonSigners = mapEntries.filter(([, meta]) => !meta.isSigner && meta.isWritable);
11345
- const readonlyNonSigners = mapEntries.filter(([, meta]) => !meta.isSigner && !meta.isWritable);
11346
- const header = {
11347
- numRequiredSignatures: writableSigners.length + readonlySigners.length,
11348
- numReadonlySignedAccounts: readonlySigners.length,
11349
- numReadonlyUnsignedAccounts: readonlyNonSigners.length
11350
- }; // sanity checks
11351
-
11352
- {
11353
- assert$1(writableSigners.length > 0, 'Expected at least one writable signer key');
11354
- const [payerAddress] = writableSigners[0];
11355
- assert$1(payerAddress === this.payer.toBase58(), 'Expected first writable signer key to be the fee payer');
11356
- }
11357
- const staticAccountKeys = [...writableSigners.map(([address]) => new PublicKey(address)), ...readonlySigners.map(([address]) => new PublicKey(address)), ...writableNonSigners.map(([address]) => new PublicKey(address)), ...readonlyNonSigners.map(([address]) => new PublicKey(address))];
11358
- return [header, staticAccountKeys];
11359
- }
11457
+ getAccountKeys(args) {
11458
+ let accountKeysFromLookups;
11360
11459
 
11361
- extractTableLookup(lookupTable) {
11362
- const [writableIndexes, drainedWritableKeys] = this.drainKeysFoundInLookupTable(lookupTable.state.addresses, keyMeta => !keyMeta.isSigner && !keyMeta.isInvoked && keyMeta.isWritable);
11363
- const [readonlyIndexes, drainedReadonlyKeys] = this.drainKeysFoundInLookupTable(lookupTable.state.addresses, keyMeta => !keyMeta.isSigner && !keyMeta.isInvoked && !keyMeta.isWritable); // Don't extract lookup if no keys were found
11460
+ if (args && 'accountKeysFromLookups' in args) {
11461
+ if (this.numAccountKeysFromLookups != args.accountKeysFromLookups.writable.length + args.accountKeysFromLookups.readonly.length) {
11462
+ throw new Error('Failed to get account keys because of a mismatch in the number of account keys from lookups');
11463
+ }
11364
11464
 
11365
- if (writableIndexes.length === 0 && readonlyIndexes.length === 0) {
11366
- return;
11465
+ accountKeysFromLookups = args.accountKeysFromLookups;
11466
+ } else if (args && 'addressLookupTableAccounts' in args) {
11467
+ accountKeysFromLookups = this.resolveAddressTableLookups(args.addressLookupTableAccounts);
11468
+ } else if (this.addressTableLookups.length > 0) {
11469
+ throw new Error('Failed to get account keys because address table lookups were not resolved');
11367
11470
  }
11368
11471
 
11369
- return [{
11370
- accountKey: lookupTable.key,
11371
- writableIndexes,
11372
- readonlyIndexes
11373
- }, {
11374
- writable: drainedWritableKeys,
11375
- readonly: drainedReadonlyKeys
11376
- }];
11472
+ return new MessageAccountKeys(this.staticAccountKeys, accountKeysFromLookups);
11377
11473
  }
11378
- /** @internal */
11379
11474
 
11475
+ resolveAddressTableLookups(addressLookupTableAccounts) {
11476
+ const accountKeysFromLookups = {
11477
+ writable: [],
11478
+ readonly: []
11479
+ };
11380
11480
 
11381
- drainKeysFoundInLookupTable(lookupTableEntries, keyMetaFilter) {
11382
- const lookupTableIndexes = new Array();
11383
- const drainedKeys = new Array();
11481
+ for (const tableLookup of this.addressTableLookups) {
11482
+ const tableAccount = addressLookupTableAccounts.find(account => account.key.equals(tableLookup.accountKey));
11384
11483
 
11385
- for (const [address, keyMeta] of this.keyMetaMap.entries()) {
11386
- if (keyMetaFilter(keyMeta)) {
11387
- const key = new PublicKey(address);
11388
- const lookupTableIndex = lookupTableEntries.findIndex(entry => entry.equals(key));
11484
+ if (!tableAccount) {
11485
+ throw new Error(`Failed to find address lookup table account for table key ${tableLookup.accountKey.toBase58()}`);
11486
+ }
11389
11487
 
11390
- if (lookupTableIndex >= 0) {
11391
- assert$1(lookupTableIndex < 256, 'Max lookup table index exceeded');
11392
- lookupTableIndexes.push(lookupTableIndex);
11393
- drainedKeys.push(key);
11394
- this.keyMetaMap.delete(address);
11488
+ for (const index of tableLookup.writableIndexes) {
11489
+ if (index < tableAccount.state.addresses.length) {
11490
+ accountKeysFromLookups.writable.push(tableAccount.state.addresses[index]);
11491
+ } else {
11492
+ throw new Error(`Failed to find address for index ${index} in address lookup table ${tableLookup.accountKey.toBase58()}`);
11395
11493
  }
11396
11494
  }
11397
- }
11398
-
11399
- return [lookupTableIndexes, drainedKeys];
11400
- }
11401
-
11402
- }
11403
11495
 
11404
- /**
11405
- * Message constructor arguments
11406
- */
11407
-
11408
- class MessageV0 {
11409
- constructor(args) {
11410
- this.header = void 0;
11411
- this.staticAccountKeys = void 0;
11412
- this.recentBlockhash = void 0;
11413
- this.compiledInstructions = void 0;
11414
- this.addressTableLookups = void 0;
11415
- this.header = args.header;
11416
- this.staticAccountKeys = args.staticAccountKeys;
11417
- this.recentBlockhash = args.recentBlockhash;
11418
- this.compiledInstructions = args.compiledInstructions;
11419
- this.addressTableLookups = args.addressTableLookups;
11420
- }
11496
+ for (const index of tableLookup.readonlyIndexes) {
11497
+ if (index < tableAccount.state.addresses.length) {
11498
+ accountKeysFromLookups.readonly.push(tableAccount.state.addresses[index]);
11499
+ } else {
11500
+ throw new Error(`Failed to find address for index ${index} in address lookup table ${tableLookup.accountKey.toBase58()}`);
11501
+ }
11502
+ }
11503
+ }
11421
11504
 
11422
- get version() {
11423
- return 0;
11505
+ return accountKeysFromLookups;
11424
11506
  }
11425
11507
 
11426
11508
  static compile(args) {
@@ -12351,6 +12433,114 @@ var solanaWeb3 = (function (exports) {
12351
12433
 
12352
12434
  }
12353
12435
 
12436
+ class TransactionMessage {
12437
+ constructor(args) {
12438
+ this.accountKeys = void 0;
12439
+ this.instructions = void 0;
12440
+ this.recentBlockhash = void 0;
12441
+ this.accountKeys = args.accountKeys;
12442
+ this.instructions = args.instructions;
12443
+ this.recentBlockhash = args.recentBlockhash;
12444
+ }
12445
+
12446
+ static decompile(message, args) {
12447
+ const {
12448
+ header,
12449
+ compiledInstructions,
12450
+ recentBlockhash
12451
+ } = message;
12452
+ const {
12453
+ numRequiredSignatures,
12454
+ numReadonlySignedAccounts,
12455
+ numReadonlyUnsignedAccounts
12456
+ } = header;
12457
+ const numWritableSignedAccounts = numRequiredSignatures - numReadonlySignedAccounts;
12458
+ assert$1(numWritableSignedAccounts > 0, 'Message header is invalid');
12459
+ const numWritableUnsignedAccounts = message.staticAccountKeys.length - numReadonlyUnsignedAccounts;
12460
+ assert$1(numWritableUnsignedAccounts >= 0, 'Message header is invalid');
12461
+ const accountKeys = message.getAccountKeys(args);
12462
+ const instructions = [];
12463
+
12464
+ for (const compiledIx of compiledInstructions) {
12465
+ const keys = [];
12466
+
12467
+ for (const keyIndex of compiledIx.accountKeyIndexes) {
12468
+ const pubkey = accountKeys.get(keyIndex);
12469
+
12470
+ if (pubkey === undefined) {
12471
+ throw new Error(`Failed to find key for account key index ${keyIndex}`);
12472
+ }
12473
+
12474
+ const isSigner = keyIndex < numRequiredSignatures;
12475
+ let isWritable;
12476
+
12477
+ if (isSigner) {
12478
+ isWritable = keyIndex < numWritableSignedAccounts;
12479
+ } else if (keyIndex < accountKeys.staticAccountKeys.length) {
12480
+ isWritable = keyIndex - numRequiredSignatures < numWritableUnsignedAccounts;
12481
+ } else {
12482
+ isWritable = keyIndex - accountKeys.staticAccountKeys.length < // accountKeysFromLookups cannot be undefined because we already found a pubkey for this index above
12483
+ accountKeys.accountKeysFromLookups.writable.length;
12484
+ }
12485
+
12486
+ keys.push({
12487
+ pubkey,
12488
+ isSigner: keyIndex < header.numRequiredSignatures,
12489
+ isWritable
12490
+ });
12491
+ }
12492
+
12493
+ const programId = accountKeys.get(compiledIx.programIdIndex);
12494
+
12495
+ if (programId === undefined) {
12496
+ throw new Error(`Failed to find program id for program id index ${compiledIx.programIdIndex}`);
12497
+ }
12498
+
12499
+ instructions.push(new TransactionInstruction({
12500
+ programId,
12501
+ data: toBuffer(compiledIx.data),
12502
+ keys
12503
+ }));
12504
+ }
12505
+
12506
+ return new TransactionMessage({
12507
+ accountKeys,
12508
+ instructions,
12509
+ recentBlockhash
12510
+ });
12511
+ }
12512
+
12513
+ compileToLegacyMessage() {
12514
+ const payerKey = this.accountKeys.get(0);
12515
+
12516
+ if (payerKey === undefined) {
12517
+ throw new Error('Failed to compile message because no account keys were found');
12518
+ }
12519
+
12520
+ return Message.compile({
12521
+ payerKey,
12522
+ recentBlockhash: this.recentBlockhash,
12523
+ instructions: this.instructions
12524
+ });
12525
+ }
12526
+
12527
+ compileToV0Message(addressLookupTableAccounts) {
12528
+ const payerKey = this.accountKeys.get(0);
12529
+
12530
+ if (payerKey === undefined) {
12531
+ throw new Error('Failed to compile message because no account keys were found');
12532
+ }
12533
+
12534
+ return MessageV0.compile({
12535
+ payerKey,
12536
+ recentBlockhash: this.recentBlockhash,
12537
+ instructions: this.instructions,
12538
+ addressLookupTableAccounts
12539
+ });
12540
+ }
12541
+
12542
+ }
12543
+
12354
12544
  /**
12355
12545
  * Versioned transaction class
12356
12546
  */
@@ -17959,7 +18149,7 @@ var solanaWeb3 = (function (exports) {
17959
18149
 
17960
18150
  /** @internal */
17961
18151
  const COMMON_HTTP_HEADERS = {
17962
- 'solana-client': `js/${(_process$env$npm_pack = "1.57.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
18152
+ 'solana-client': `js/${(_process$env$npm_pack = "1.58.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
17963
18153
  };
17964
18154
  /**
17965
18155
  * A connection to a fullnode JSON RPC endpoint
@@ -19817,12 +20007,46 @@ var solanaWeb3 = (function (exports) {
19817
20007
 
19818
20008
  return res.result;
19819
20009
  }
20010
+ /**
20011
+ * Simulate a transaction
20012
+ *
20013
+ * @deprecated Instead, call {@link simulateTransaction} with {@link
20014
+ * VersionedTransaction} and {@link SimulateTransactionConfig} parameters
20015
+ */
20016
+
20017
+
19820
20018
  /**
19821
20019
  * Simulate a transaction
19822
20020
  */
20021
+ // eslint-disable-next-line no-dupe-class-members
20022
+ async simulateTransaction(transactionOrMessage, configOrSigners, includeAccounts) {
20023
+ if ('message' in transactionOrMessage) {
20024
+ const versionedTx = transactionOrMessage;
20025
+ const wireTransaction = versionedTx.serialize();
20026
+ const encodedTransaction = buffer.Buffer.from(wireTransaction).toString('base64');
20027
+
20028
+ if (Array.isArray(configOrSigners) || includeAccounts !== undefined) {
20029
+ throw new Error('Invalid arguments');
20030
+ }
20031
+
20032
+ const config = configOrSigners || {};
20033
+ config.encoding = 'base64';
20034
+
20035
+ if (!('commitment' in config)) {
20036
+ config.commitment = this.commitment;
20037
+ }
19823
20038
 
20039
+ const args = [encodedTransaction, config];
20040
+ const unsafeRes = await this._rpcRequest('simulateTransaction', args);
20041
+ const res = create(unsafeRes, SimulatedTransactionResponseStruct);
20042
+
20043
+ if ('error' in res) {
20044
+ throw new Error('failed to simulate transaction: ' + res.error.message);
20045
+ }
20046
+
20047
+ return res.result;
20048
+ }
19824
20049
 
19825
- async simulateTransaction(transactionOrMessage, signers, includeAccounts) {
19826
20050
  let transaction;
19827
20051
 
19828
20052
  if (transactionOrMessage instanceof Transaction) {
@@ -19838,6 +20062,12 @@ var solanaWeb3 = (function (exports) {
19838
20062
  transaction._message = transaction._json = undefined;
19839
20063
  }
19840
20064
 
20065
+ if (configOrSigners !== undefined && !Array.isArray(configOrSigners)) {
20066
+ throw new Error('Invalid arguments');
20067
+ }
20068
+
20069
+ const signers = configOrSigners;
20070
+
19841
20071
  if (transaction.nonceInfo && signers) {
19842
20072
  transaction.sign(...signers);
19843
20073
  } else {
@@ -19920,10 +20150,32 @@ var solanaWeb3 = (function (exports) {
19920
20150
  }
19921
20151
  /**
19922
20152
  * Sign and send a transaction
20153
+ *
20154
+ * @deprecated Instead, call {@link sendTransaction} with a {@link
20155
+ * VersionedTransaction}
19923
20156
  */
19924
20157
 
19925
20158
 
19926
- async sendTransaction(transaction, signers, options) {
20159
+ /**
20160
+ * Sign and send a transaction
20161
+ */
20162
+ // eslint-disable-next-line no-dupe-class-members
20163
+ async sendTransaction(transaction, signersOrOptions, options) {
20164
+ if ('message' in transaction) {
20165
+ if (signersOrOptions && Array.isArray(signersOrOptions)) {
20166
+ throw new Error('Invalid arguments');
20167
+ }
20168
+
20169
+ const wireTransaction = transaction.serialize();
20170
+ return await this.sendRawTransaction(wireTransaction, options);
20171
+ }
20172
+
20173
+ if (signersOrOptions === undefined || !Array.isArray(signersOrOptions)) {
20174
+ throw new Error('Invalid arguments');
20175
+ }
20176
+
20177
+ const signers = signersOrOptions;
20178
+
19927
20179
  if (transaction.nonceInfo) {
19928
20180
  transaction.sign(...signers);
19929
20181
  } else {
@@ -24679,6 +24931,7 @@ var solanaWeb3 = (function (exports) {
24679
24931
  exports.TransactionExpiredBlockheightExceededError = TransactionExpiredBlockheightExceededError;
24680
24932
  exports.TransactionExpiredTimeoutError = TransactionExpiredTimeoutError;
24681
24933
  exports.TransactionInstruction = TransactionInstruction;
24934
+ exports.TransactionMessage = TransactionMessage;
24682
24935
  exports.VALIDATOR_INFO_KEY = VALIDATOR_INFO_KEY;
24683
24936
  exports.VERSION_PREFIX_MASK = VERSION_PREFIX_MASK;
24684
24937
  exports.VOTE_PROGRAM_ID = VOTE_PROGRAM_ID;