@solana/web3.js 1.27.1 → 1.28.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
@@ -12472,16 +12472,35 @@ var solanaWeb3 = (function (exports) {
12472
12472
 
12473
12473
  _defineProperty(this, "instructions", void 0);
12474
12474
 
12475
+ _defineProperty(this, "indexToProgramIds", new Map());
12476
+
12475
12477
  this.header = args.header;
12476
12478
  this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
12477
12479
  this.recentBlockhash = args.recentBlockhash;
12478
12480
  this.instructions = args.instructions;
12481
+ this.instructions.forEach(ix => this.indexToProgramIds.set(ix.programIdIndex, this.accountKeys[ix.programIdIndex]));
12482
+ }
12483
+
12484
+ isAccountSigner(index) {
12485
+ return index < this.header.numRequiredSignatures;
12479
12486
  }
12480
12487
 
12481
12488
  isAccountWritable(index) {
12482
12489
  return index < this.header.numRequiredSignatures - this.header.numReadonlySignedAccounts || index >= this.header.numRequiredSignatures && index < this.accountKeys.length - this.header.numReadonlyUnsignedAccounts;
12483
12490
  }
12484
12491
 
12492
+ isProgramId(index) {
12493
+ return this.indexToProgramIds.has(index);
12494
+ }
12495
+
12496
+ programIds() {
12497
+ return [...this.indexToProgramIds.values()];
12498
+ }
12499
+
12500
+ nonProgramIds() {
12501
+ return this.accountKeys.filter((_, index) => !this.isProgramId(index));
12502
+ }
12503
+
12485
12504
  serialize() {
12486
12505
  const numKeys = this.accountKeys.length;
12487
12506
  let keyCount = [];
@@ -13195,7 +13214,7 @@ var solanaWeb3 = (function (exports) {
13195
13214
  */
13196
13215
 
13197
13216
 
13198
- static populate(message, signatures) {
13217
+ static populate(message, signatures = []) {
13199
13218
  const transaction = new Transaction();
13200
13219
  transaction.recentBlockhash = message.recentBlockhash;
13201
13220
 
@@ -13215,7 +13234,7 @@ var solanaWeb3 = (function (exports) {
13215
13234
  const pubkey = message.accountKeys[account];
13216
13235
  return {
13217
13236
  pubkey,
13218
- isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()),
13237
+ isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()) || message.isAccountSigner(account),
13219
13238
  isWritable: message.isAccountWritable(account)
13220
13239
  };
13221
13240
  });
@@ -18272,7 +18291,15 @@ var solanaWeb3 = (function (exports) {
18272
18291
  });
18273
18292
  const SimulatedTransactionResponseStruct = jsonRpcResultAndContext(type({
18274
18293
  err: nullable(union([type({}), string()])),
18275
- logs: nullable(array(string()))
18294
+ logs: nullable(array(string())),
18295
+ accounts: optional(nullable(array(type({
18296
+ executable: boolean(),
18297
+ owner: string(),
18298
+ lamports: number(),
18299
+ data: array(string()),
18300
+ rentEpoch: optional(number())
18301
+ })))),
18302
+ unitsConsumed: optional(number())
18276
18303
  }));
18277
18304
 
18278
18305
  function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit) {
@@ -18998,6 +19025,8 @@ var solanaWeb3 = (function (exports) {
18998
19025
 
18999
19026
  /** @internal */
19000
19027
 
19028
+ /** @internal */
19029
+
19001
19030
  /**
19002
19031
  * Establish a JSON RPC connection
19003
19032
  *
@@ -19007,6 +19036,8 @@ var solanaWeb3 = (function (exports) {
19007
19036
  constructor(endpoint, commitmentOrConfig) {
19008
19037
  _defineProperty(this, "_commitment", void 0);
19009
19038
 
19039
+ _defineProperty(this, "_confirmTransactionInitialTimeout", void 0);
19040
+
19010
19041
  _defineProperty(this, "_rpcEndpoint", void 0);
19011
19042
 
19012
19043
  _defineProperty(this, "_rpcWsEndpoint", void 0);
@@ -19075,6 +19106,7 @@ var solanaWeb3 = (function (exports) {
19075
19106
  this._commitment = commitmentOrConfig;
19076
19107
  } else if (commitmentOrConfig) {
19077
19108
  this._commitment = commitmentOrConfig.commitment;
19109
+ this._confirmTransactionInitialTimeout = commitmentOrConfig.confirmTransactionInitialTimeout;
19078
19110
  wsEndpoint = commitmentOrConfig.wsEndpoint;
19079
19111
  httpHeaders = commitmentOrConfig.httpHeaders;
19080
19112
  fetchMiddleware = commitmentOrConfig.fetchMiddleware;
@@ -19534,7 +19566,7 @@ var solanaWeb3 = (function (exports) {
19534
19566
  reject(err);
19535
19567
  }
19536
19568
  });
19537
- let timeoutMs = 60 * 1000;
19569
+ let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;
19538
19570
 
19539
19571
  switch (subscriptionCommitment) {
19540
19572
  case 'processed':
@@ -19543,7 +19575,7 @@ var solanaWeb3 = (function (exports) {
19543
19575
  case 'confirmed':
19544
19576
  case 'singleGossip':
19545
19577
  {
19546
- timeoutMs = 30 * 1000;
19578
+ timeoutMs = this._confirmTransactionInitialTimeout || 30 * 1000;
19547
19579
  break;
19548
19580
  }
19549
19581
  }
@@ -20330,7 +20362,15 @@ var solanaWeb3 = (function (exports) {
20330
20362
  */
20331
20363
 
20332
20364
 
20333
- async simulateTransaction(transaction, signers) {
20365
+ async simulateTransaction(transactionOrMessage, signers, includeAccounts) {
20366
+ let transaction;
20367
+
20368
+ if (transactionOrMessage instanceof Transaction) {
20369
+ transaction = transactionOrMessage;
20370
+ } else {
20371
+ transaction = Transaction.populate(transactionOrMessage);
20372
+ }
20373
+
20334
20374
  if (transaction.nonceInfo && signers) {
20335
20375
  transaction.sign(...signers);
20336
20376
  } else {
@@ -20363,7 +20403,9 @@ var solanaWeb3 = (function (exports) {
20363
20403
  }
20364
20404
  }
20365
20405
 
20366
- const signData = transaction.serializeMessage();
20406
+ const message = transaction._compile();
20407
+
20408
+ const signData = message.serialize();
20367
20409
 
20368
20410
  const wireTransaction = transaction._serialize(signData);
20369
20411
 
@@ -20373,6 +20415,14 @@ var solanaWeb3 = (function (exports) {
20373
20415
  commitment: this.commitment
20374
20416
  };
20375
20417
 
20418
+ if (includeAccounts) {
20419
+ const addresses = (Array.isArray(includeAccounts) ? includeAccounts : message.nonProgramIds()).map(key => key.toBase58());
20420
+ config['accounts'] = {
20421
+ encoding: 'base64',
20422
+ addresses
20423
+ };
20424
+ }
20425
+
20376
20426
  if (signers) {
20377
20427
  config.sigVerify = true;
20378
20428
  }