@solana/web3.js 2.0.0-preview.3.20240723085452.02fbfcd5e5ba1910e456cdc81eaa5de36c8c6863 → 2.0.0-preview.3.20240724205420.3a8f0686704a85d0761d8d8db3a260a7452f7122

Sign up to get free protection for your applications and to get access to all the features.
@@ -3950,7 +3950,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3950
3950
  ...config.headers ? normalizeHeaders2(config.headers) : void 0,
3951
3951
  ...{
3952
3952
  // Keep these headers lowercase so they will override any user-supplied headers above.
3953
- "solana-client": (_a = `js/${"2.0.0-preview.3.20240723085452.02fbfcd5e5ba1910e456cdc81eaa5de36c8c6863"}`) != null ? _a : "UNKNOWN"
3953
+ "solana-client": (_a = `js/${"2.0.0-preview.3.20240724205420.3a8f0686704a85d0761d8d8db3a260a7452f7122"}`) != null ? _a : "UNKNOWN"
3954
3954
  }
3955
3955
  }
3956
3956
  }),
@@ -5577,6 +5577,53 @@ this.globalThis.solanaWeb3 = (function (exports) {
5577
5577
  version: transaction.version
5578
5578
  };
5579
5579
  }
5580
+ function findAddressInLookupTables(address2, role, addressesByLookupTableAddress) {
5581
+ for (const [lookupTableAddress, addresses] of Object.entries(addressesByLookupTableAddress)) {
5582
+ for (let i = 0; i < addresses.length; i++) {
5583
+ if (address2 === addresses[i]) {
5584
+ return {
5585
+ address: address2,
5586
+ addressIndex: i,
5587
+ lookupTableAddress,
5588
+ role
5589
+ };
5590
+ }
5591
+ }
5592
+ }
5593
+ }
5594
+ function compressTransactionMessageUsingAddressLookupTables(transactionMessage, addressesByLookupTableAddress) {
5595
+ const lookupTableAddresses = new Set(Object.values(addressesByLookupTableAddress).flatMap((a) => a));
5596
+ const newInstructions = [];
5597
+ let updatedAnyInstructions = false;
5598
+ for (const instruction of transactionMessage.instructions) {
5599
+ if (!instruction.accounts) {
5600
+ newInstructions.push(instruction);
5601
+ continue;
5602
+ }
5603
+ const newAccounts = [];
5604
+ let updatedAnyAccounts = false;
5605
+ for (const account of instruction.accounts) {
5606
+ if ("lookupTableAddress" in account || !lookupTableAddresses.has(account.address) || isSignerRole(account.role)) {
5607
+ newAccounts.push(account);
5608
+ continue;
5609
+ }
5610
+ const lookupMetaAccount = findAddressInLookupTables(
5611
+ account.address,
5612
+ account.role,
5613
+ addressesByLookupTableAddress
5614
+ );
5615
+ newAccounts.push(Object.freeze(lookupMetaAccount));
5616
+ updatedAnyAccounts = true;
5617
+ updatedAnyInstructions = true;
5618
+ }
5619
+ newInstructions.push(
5620
+ Object.freeze(updatedAnyAccounts ? { ...instruction, accounts: newAccounts } : instruction)
5621
+ );
5622
+ }
5623
+ return Object.freeze(
5624
+ updatedAnyInstructions ? { ...transactionMessage, instructions: newInstructions } : transactionMessage
5625
+ );
5626
+ }
5580
5627
  function createTransactionMessage({
5581
5628
  version
5582
5629
  }) {
@@ -7168,6 +7215,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
7168
7215
  exports.commitmentComparator = commitmentComparator;
7169
7216
  exports.compileTransaction = compileTransaction;
7170
7217
  exports.compileTransactionMessage = compileTransactionMessage;
7218
+ exports.compressTransactionMessageUsingAddressLookupTables = compressTransactionMessageUsingAddressLookupTables;
7171
7219
  exports.containsBytes = containsBytes;
7172
7220
  exports.createAddressWithSeed = createAddressWithSeed;
7173
7221
  exports.createCodec = createCodec;