@solana/web3.js 1.43.2 → 1.43.5

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.esm.js CHANGED
@@ -2592,13 +2592,6 @@ class Transaction {
2592
2592
  isSigner: false,
2593
2593
  isWritable: false
2594
2594
  });
2595
- }); // Sort. Prioritizing first by signer, then by writable
2596
-
2597
- accountMetas.sort(function (x, y) {
2598
- const pubkeySorting = x.pubkey.toBase58().localeCompare(y.pubkey.toBase58());
2599
- const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
2600
- const checkWritable = x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
2601
- return checkSigner || checkWritable;
2602
2595
  }); // Cull duplicate account metas
2603
2596
 
2604
2597
  const uniqueMetas = [];
@@ -2610,9 +2603,25 @@ class Transaction {
2610
2603
 
2611
2604
  if (uniqueIndex > -1) {
2612
2605
  uniqueMetas[uniqueIndex].isWritable = uniqueMetas[uniqueIndex].isWritable || accountMeta.isWritable;
2606
+ uniqueMetas[uniqueIndex].isSigner = uniqueMetas[uniqueIndex].isSigner || accountMeta.isSigner;
2613
2607
  } else {
2614
2608
  uniqueMetas.push(accountMeta);
2615
2609
  }
2610
+ }); // Sort. Prioritizing first by signer, then by writable
2611
+
2612
+ uniqueMetas.sort(function (x, y) {
2613
+ if (x.isSigner !== y.isSigner) {
2614
+ // Signers always come before non-signers
2615
+ return x.isSigner ? -1 : 1;
2616
+ }
2617
+
2618
+ if (x.isWritable !== y.isWritable) {
2619
+ // Writable accounts always come before read-only accounts
2620
+ return x.isWritable ? -1 : 1;
2621
+ } // Otherwise, sort by pubkey, stringwise.
2622
+
2623
+
2624
+ return x.pubkey.toBase58().localeCompare(y.pubkey.toBase58());
2616
2625
  }); // Move fee payer to the front
2617
2626
 
2618
2627
  const feePayerIndex = uniqueMetas.findIndex(x => {