@solana/transactions 2.0.0-experimental.ba21818 → 2.0.0-experimental.ba9b4c7

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.
Files changed (44) hide show
  1. package/dist/index.browser.cjs +164 -149
  2. package/dist/index.browser.cjs.map +1 -1
  3. package/dist/index.browser.js +167 -153
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.development.js +397 -146
  6. package/dist/index.development.js.map +1 -1
  7. package/dist/index.native.js +167 -153
  8. package/dist/index.native.js.map +1 -1
  9. package/dist/index.node.cjs +164 -147
  10. package/dist/index.node.cjs.map +1 -1
  11. package/dist/index.node.js +167 -153
  12. package/dist/index.node.js.map +1 -1
  13. package/dist/index.production.min.js +17 -16
  14. package/dist/types/durable-nonce.d.ts +1 -0
  15. package/dist/types/serializers/address-table-lookup.d.ts +5 -3
  16. package/dist/types/serializers/header.d.ts +4 -2
  17. package/dist/types/serializers/instruction.d.ts +4 -2
  18. package/package.json +10 -8
  19. package/dist/types/accounts.d.ts.map +0 -1
  20. package/dist/types/blockhash.d.ts.map +0 -1
  21. package/dist/types/compile-address-table-lookups.d.ts.map +0 -1
  22. package/dist/types/compile-header.d.ts.map +0 -1
  23. package/dist/types/compile-instructions.d.ts.map +0 -1
  24. package/dist/types/compile-lifetime-token.d.ts.map +0 -1
  25. package/dist/types/compile-static-accounts.d.ts.map +0 -1
  26. package/dist/types/compile-transaction.d.ts.map +0 -1
  27. package/dist/types/create-transaction.d.ts.map +0 -1
  28. package/dist/types/durable-nonce.d.ts.map +0 -1
  29. package/dist/types/fee-payer.d.ts.map +0 -1
  30. package/dist/types/index.d.ts.map +0 -1
  31. package/dist/types/instructions.d.ts.map +0 -1
  32. package/dist/types/message.d.ts.map +0 -1
  33. package/dist/types/serializers/address-table-lookup.d.ts.map +0 -1
  34. package/dist/types/serializers/header.d.ts.map +0 -1
  35. package/dist/types/serializers/index.d.ts.map +0 -1
  36. package/dist/types/serializers/instruction.d.ts.map +0 -1
  37. package/dist/types/serializers/message.d.ts.map +0 -1
  38. package/dist/types/serializers/transaction-version.d.ts.map +0 -1
  39. package/dist/types/serializers/transaction.d.ts.map +0 -1
  40. package/dist/types/serializers/unimplemented.d.ts.map +0 -1
  41. package/dist/types/signatures.d.ts.map +0 -1
  42. package/dist/types/types.d.ts.map +0 -1
  43. package/dist/types/unsigned-transaction.d.ts.map +0 -1
  44. package/dist/types/wire-transaction.d.ts.map +0 -1
@@ -231,16 +231,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
231
231
  }
232
232
  };
233
233
 
234
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
235
- var u8 = (options = {}) => numberFactory({
236
- name: "u8",
237
- size: 1,
238
- range: [0, Number("0xff")],
239
- set: (view, value) => view.setUint8(0, Number(value)),
240
- get: (view) => view.getUint8(0),
241
- options
242
- });
243
-
244
234
  // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
245
235
  var u32 = (options = {}) => numberFactory({
246
236
  name: "u32",
@@ -763,6 +753,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
763
753
  maxSize: encoder.maxSize
764
754
  };
765
755
  }
756
+ function mapDecoder(decoder, map) {
757
+ return {
758
+ decode: (bytes2, offset = 0) => {
759
+ const [value, length] = decoder.decode(bytes2, offset);
760
+ return [map(value, bytes2, offset), length];
761
+ },
762
+ description: decoder.description,
763
+ fixedSize: decoder.fixedSize,
764
+ maxSize: decoder.maxSize
765
+ };
766
+ }
766
767
 
767
768
  // ../codecs-numbers/dist/index.browser.js
768
769
  function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
@@ -821,6 +822,46 @@ this.globalThis.solanaWeb3 = (function (exports) {
821
822
  const bytesLength = length ?? bytes2.byteLength;
822
823
  return bytes2.buffer.slice(bytesOffset, bytesOffset + bytesLength);
823
824
  }
825
+ var getShortU16Encoder = (options = {}) => ({
826
+ description: options.description ?? "shortU16",
827
+ encode: (value) => {
828
+ assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
829
+ const bytes2 = [0];
830
+ for (let ii = 0; ; ii += 1) {
831
+ const alignedValue = value >> ii * 7;
832
+ if (alignedValue === 0) {
833
+ break;
834
+ }
835
+ const nextSevenBits = 127 & alignedValue;
836
+ bytes2[ii] = nextSevenBits;
837
+ if (ii > 0) {
838
+ bytes2[ii - 1] |= 128;
839
+ }
840
+ }
841
+ return new Uint8Array(bytes2);
842
+ },
843
+ fixedSize: null,
844
+ maxSize: 3
845
+ });
846
+ var getShortU16Decoder = (options = {}) => ({
847
+ decode: (bytes2, offset = 0) => {
848
+ let value = 0;
849
+ let byteCount = 0;
850
+ while (++byteCount) {
851
+ const byteIndex = byteCount - 1;
852
+ const currentByte = bytes2[offset + byteIndex];
853
+ const nextSevenBits = 127 & currentByte;
854
+ value |= nextSevenBits << byteIndex * 7;
855
+ if ((currentByte & 128) === 0) {
856
+ break;
857
+ }
858
+ }
859
+ return [value, offset + byteCount];
860
+ },
861
+ description: options.description ?? "shortU16",
862
+ fixedSize: null,
863
+ maxSize: 3
864
+ });
824
865
  var getU32Encoder = (options = {}) => numberEncoderFactory({
825
866
  name: "u32",
826
867
  options,
@@ -834,6 +875,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
834
875
  options,
835
876
  size: 4
836
877
  });
878
+ var getU8Encoder = (options = {}) => numberEncoderFactory({
879
+ name: "u8",
880
+ options,
881
+ range: [0, Number("0xff")],
882
+ set: (view, value) => view.setUint8(0, value),
883
+ size: 1
884
+ });
885
+ var getU8Decoder = (options = {}) => numberDecoderFactory({
886
+ get: (view) => view.getUint8(0),
887
+ name: "u8",
888
+ options,
889
+ size: 1
890
+ });
891
+ var getU8Codec = (options = {}) => combineCodec(getU8Encoder(options), getU8Decoder(options));
837
892
 
838
893
  // ../codecs-strings/dist/index.browser.js
839
894
  function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
@@ -1369,142 +1424,347 @@ this.globalThis.solanaWeb3 = (function (exports) {
1369
1424
  };
1370
1425
  }
1371
1426
 
1372
- // src/serializers/address-table-lookup.ts
1373
- function addressSerializerCompat(compat) {
1374
- const codec = getAddressCodec();
1427
+ // ../codecs-data-structures/dist/index.browser.js
1428
+ function sumCodecSizes(sizes) {
1429
+ return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
1430
+ }
1431
+ function decodeArrayLikeCodecSize(size, childrenSizes, bytes2, offset) {
1432
+ if (typeof size === "number") {
1433
+ return [size, offset];
1434
+ }
1435
+ if (typeof size === "object") {
1436
+ return size.decode(bytes2, offset);
1437
+ }
1438
+ if (size === "remainder") {
1439
+ const childrenSize = sumCodecSizes(childrenSizes);
1440
+ if (childrenSize === null) {
1441
+ throw new Error('Codecs of "remainder" size must have fixed-size items.');
1442
+ }
1443
+ const remainder = bytes2.slice(offset).length;
1444
+ if (remainder % childrenSize !== 0) {
1445
+ throw new Error(
1446
+ `The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${childrenSize} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainder} modulo ${childrenSize} should be equal to zero.`
1447
+ );
1448
+ }
1449
+ return [remainder / childrenSize, offset];
1450
+ }
1451
+ throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
1452
+ }
1453
+ function getArrayLikeCodecSizeDescription(size) {
1454
+ return typeof size === "object" ? size.description : `${size}`;
1455
+ }
1456
+ function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
1457
+ if (typeof size !== "number")
1458
+ return null;
1459
+ if (size === 0)
1460
+ return 0;
1461
+ const childrenSize = sumCodecSizes(childrenSizes);
1462
+ return childrenSize === null ? null : childrenSize * size;
1463
+ }
1464
+ function getArrayLikeCodecSizePrefix(size, realSize) {
1465
+ return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
1466
+ }
1467
+ function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
1468
+ if (expected !== actual) {
1469
+ throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
1470
+ }
1471
+ }
1472
+ function arrayCodecHelper(item, size, description) {
1473
+ if (size === "remainder" && item.fixedSize === null) {
1474
+ throw new Error('Codecs of "remainder" size must have fixed-size items.');
1475
+ }
1375
1476
  return {
1376
- description: compat?.description ?? codec.description,
1377
- deserialize: codec.decode,
1378
- fixedSize: codec.fixedSize,
1379
- maxSize: codec.maxSize,
1380
- serialize: codec.encode
1477
+ description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
1478
+ fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
1479
+ maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
1381
1480
  };
1382
1481
  }
1383
- function getAddressTableLookupCodec() {
1384
- return struct(
1385
- [
1482
+ function getArrayEncoder(item, options = {}) {
1483
+ const size = options.size ?? getU32Encoder();
1484
+ return {
1485
+ ...arrayCodecHelper(item, size, options.description),
1486
+ encode: (value) => {
1487
+ if (typeof size === "number") {
1488
+ assertValidNumberOfItemsForCodec("array", size, value.length);
1489
+ }
1490
+ return mergeBytes2([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
1491
+ }
1492
+ };
1493
+ }
1494
+ function getArrayDecoder(item, options = {}) {
1495
+ const size = options.size ?? getU32Decoder();
1496
+ return {
1497
+ ...arrayCodecHelper(item, size, options.description),
1498
+ decode: (bytes2, offset = 0) => {
1499
+ if (typeof size === "object" && bytes2.slice(offset).length === 0) {
1500
+ return [[], offset];
1501
+ }
1502
+ const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes2, offset);
1503
+ offset = newOffset;
1504
+ const values = [];
1505
+ for (let i = 0; i < resolvedSize; i += 1) {
1506
+ const [value, newOffset2] = item.decode(bytes2, offset);
1507
+ values.push(value);
1508
+ offset = newOffset2;
1509
+ }
1510
+ return [values, offset];
1511
+ }
1512
+ };
1513
+ }
1514
+ function getBytesEncoder(options = {}) {
1515
+ const size = options.size ?? "variable";
1516
+ const sizeDescription = typeof size === "object" ? size.description : `${size}`;
1517
+ const description = options.description ?? `bytes(${sizeDescription})`;
1518
+ const byteEncoder = {
1519
+ description,
1520
+ encode: (value) => value,
1521
+ fixedSize: null,
1522
+ maxSize: null
1523
+ };
1524
+ if (size === "variable") {
1525
+ return byteEncoder;
1526
+ }
1527
+ if (typeof size === "number") {
1528
+ return fixEncoder(byteEncoder, size, description);
1529
+ }
1530
+ return {
1531
+ ...byteEncoder,
1532
+ encode: (value) => {
1533
+ const contentBytes = byteEncoder.encode(value);
1534
+ const lengthBytes = size.encode(contentBytes.length);
1535
+ return mergeBytes2([lengthBytes, contentBytes]);
1536
+ }
1537
+ };
1538
+ }
1539
+ function getBytesDecoder(options = {}) {
1540
+ const size = options.size ?? "variable";
1541
+ const sizeDescription = typeof size === "object" ? size.description : `${size}`;
1542
+ const description = options.description ?? `bytes(${sizeDescription})`;
1543
+ const byteDecoder = {
1544
+ decode: (bytes2, offset = 0) => {
1545
+ const slice = bytes2.slice(offset);
1546
+ return [slice, offset + slice.length];
1547
+ },
1548
+ description,
1549
+ fixedSize: null,
1550
+ maxSize: null
1551
+ };
1552
+ if (size === "variable") {
1553
+ return byteDecoder;
1554
+ }
1555
+ if (typeof size === "number") {
1556
+ return fixDecoder(byteDecoder, size, description);
1557
+ }
1558
+ return {
1559
+ ...byteDecoder,
1560
+ decode: (bytes2, offset = 0) => {
1561
+ assertByteArrayIsNotEmptyForCodec("bytes", bytes2, offset);
1562
+ const [lengthBigInt, lengthOffset] = size.decode(bytes2, offset);
1563
+ const length = Number(lengthBigInt);
1564
+ offset = lengthOffset;
1565
+ const contentBytes = bytes2.slice(offset, offset + length);
1566
+ assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
1567
+ const [value, contentOffset] = byteDecoder.decode(contentBytes);
1568
+ offset += contentOffset;
1569
+ return [value, offset];
1570
+ }
1571
+ };
1572
+ }
1573
+ function structCodecHelper(fields, description) {
1574
+ const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
1575
+ return {
1576
+ description: description ?? `struct(${fieldDescriptions})`,
1577
+ fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
1578
+ maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
1579
+ };
1580
+ }
1581
+ function getStructEncoder(fields, options = {}) {
1582
+ return {
1583
+ ...structCodecHelper(fields, options.description),
1584
+ encode: (struct2) => {
1585
+ const fieldBytes = fields.map(([key, codec]) => codec.encode(struct2[key]));
1586
+ return mergeBytes2(fieldBytes);
1587
+ }
1588
+ };
1589
+ }
1590
+ function getStructDecoder(fields, options = {}) {
1591
+ return {
1592
+ ...structCodecHelper(fields, options.description),
1593
+ decode: (bytes2, offset = 0) => {
1594
+ const struct2 = {};
1595
+ fields.forEach(([key, codec]) => {
1596
+ const [value, newOffset] = codec.decode(bytes2, offset);
1597
+ offset = newOffset;
1598
+ struct2[key] = value;
1599
+ });
1600
+ return [struct2, offset];
1601
+ }
1602
+ };
1603
+ }
1604
+ function getStructCodec(fields, options = {}) {
1605
+ return combineCodec(getStructEncoder(fields, options), getStructDecoder(fields, options));
1606
+ }
1607
+
1608
+ // src/serializers/address-table-lookup.ts
1609
+ var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
1610
+ var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
1611
+ var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ;
1612
+ var addressTableLookupDescription = "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it" ;
1613
+ var memoizedAddressTableLookupEncoder;
1614
+ function getAddressTableLookupEncoder() {
1615
+ if (!memoizedAddressTableLookupEncoder) {
1616
+ memoizedAddressTableLookupEncoder = getStructEncoder(
1386
1617
  [
1387
- "lookupTableAddress",
1388
- addressSerializerCompat(
1389
- {
1390
- description: "The address of the address lookup table account from which instruction addresses should be looked up"
1391
- }
1392
- )
1618
+ ["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
1619
+ [
1620
+ "writableIndices",
1621
+ getArrayEncoder(getU8Encoder(), {
1622
+ description: writableIndicesDescription,
1623
+ size: getShortU16Encoder()
1624
+ })
1625
+ ],
1626
+ [
1627
+ "readableIndices",
1628
+ getArrayEncoder(getU8Encoder(), {
1629
+ description: readableIndicesDescription,
1630
+ size: getShortU16Encoder()
1631
+ })
1632
+ ]
1393
1633
  ],
1634
+ { description: addressTableLookupDescription }
1635
+ );
1636
+ }
1637
+ return memoizedAddressTableLookupEncoder;
1638
+ }
1639
+ var memoizedAddressTableLookupDecoder;
1640
+ function getAddressTableLookupDecoder() {
1641
+ if (!memoizedAddressTableLookupDecoder) {
1642
+ memoizedAddressTableLookupDecoder = getStructDecoder(
1394
1643
  [
1395
- "writableIndices",
1396
- array(u8(), {
1397
- ...{
1398
- description: "The indices of the accounts in the lookup table that should be loaded as writeable"
1399
- } ,
1400
- size: shortU16()
1401
- })
1644
+ ["lookupTableAddress", getAddressDecoder({ description: lookupTableAddressDescription })],
1645
+ [
1646
+ "writableIndices",
1647
+ getArrayDecoder(getU8Decoder(), {
1648
+ description: writableIndicesDescription,
1649
+ size: getShortU16Decoder()
1650
+ })
1651
+ ],
1652
+ [
1653
+ "readableIndices",
1654
+ getArrayDecoder(getU8Decoder(), {
1655
+ description: readableIndicesDescription,
1656
+ size: getShortU16Decoder()
1657
+ })
1658
+ ]
1402
1659
  ],
1403
- [
1404
- "readableIndices",
1405
- array(u8(), {
1406
- ...{
1407
- description: "The indices of the accounts in the lookup table that should be loaded as read-only"
1408
- } ,
1409
- size: shortU16()
1410
- })
1411
- ]
1412
- ],
1413
- {
1414
- description: "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it"
1415
- }
1416
- );
1660
+ { description: addressTableLookupDescription }
1661
+ );
1662
+ }
1663
+ return memoizedAddressTableLookupDecoder;
1664
+ }
1665
+ function getAddressTableLookupCodec() {
1666
+ return combineCodec(getAddressTableLookupEncoder(), getAddressTableLookupDecoder());
1417
1667
  }
1418
1668
 
1419
1669
  // src/serializers/header.ts
1670
+ var memoizedU8Codec;
1671
+ function getMemoizedU8Codec() {
1672
+ if (!memoizedU8Codec)
1673
+ memoizedU8Codec = getU8Codec();
1674
+ return memoizedU8Codec;
1675
+ }
1676
+ function getMemoizedU8CodecDescription(description) {
1677
+ const codec = getMemoizedU8Codec();
1678
+ return {
1679
+ ...codec,
1680
+ description: description ?? codec.description
1681
+ };
1682
+ }
1683
+ var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
1684
+ var numReadonlySignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable" ;
1685
+ var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
1686
+ var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
1420
1687
  function getMessageHeaderCodec() {
1421
- return struct(
1688
+ return getStructCodec(
1422
1689
  [
1423
- [
1424
- "numSignerAccounts",
1425
- u8(
1426
- {
1427
- description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction"
1428
- }
1429
- )
1430
- ],
1431
- [
1432
- "numReadonlySignerAccounts",
1433
- u8(
1434
- {
1435
- description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable"
1436
- }
1437
- )
1438
- ],
1439
- [
1440
- "numReadonlyNonSignerAccounts",
1441
- u8(
1442
- {
1443
- description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
1444
- }
1445
- )
1446
- ]
1690
+ ["numSignerAccounts", getMemoizedU8CodecDescription(numSignerAccountsDescription)],
1691
+ ["numReadonlySignerAccounts", getMemoizedU8CodecDescription(numReadonlySignerAccountsDescription)],
1692
+ ["numReadonlyNonSignerAccounts", getMemoizedU8CodecDescription(numReadonlyNonSignerAccountsDescription)]
1447
1693
  ],
1448
1694
  {
1449
- description: "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses"
1450
- }
1695
+ description: messageHeaderDescription
1696
+ }
1451
1697
  );
1452
1698
  }
1453
1699
 
1454
1700
  // src/serializers/instruction.ts
1455
- function getInstructionCodec() {
1456
- return mapSerializer(
1457
- struct([
1458
- [
1459
- "programAddressIndex",
1460
- u8(
1461
- {
1462
- description: "The index of the program being called, according to the well-ordered accounts list for this transaction"
1463
- }
1464
- )
1465
- ],
1466
- [
1467
- "accountIndices",
1468
- array(
1469
- u8({
1470
- description: "The index of an account, according to the well-ordered accounts list for this transaction"
1471
- }),
1472
- {
1473
- description: "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ,
1474
- size: shortU16()
1475
- }
1476
- )
1477
- ],
1478
- [
1479
- "data",
1480
- bytes({
1481
- description: "An optional buffer of data passed to the instruction" ,
1482
- size: shortU16()
1483
- })
1484
- ]
1485
- ]),
1486
- (value) => {
1487
- if (value.accountIndices !== void 0 && value.data !== void 0) {
1488
- return value;
1701
+ var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
1702
+ var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ;
1703
+ var accountIndicesDescription = "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ;
1704
+ var dataDescription = "An optional buffer of data passed to the instruction" ;
1705
+ var memoizedGetInstructionEncoder;
1706
+ function getInstructionEncoder() {
1707
+ if (!memoizedGetInstructionEncoder) {
1708
+ memoizedGetInstructionEncoder = mapEncoder(
1709
+ getStructEncoder([
1710
+ ["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
1711
+ [
1712
+ "accountIndices",
1713
+ getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
1714
+ description: accountIndicesDescription,
1715
+ size: getShortU16Encoder()
1716
+ })
1717
+ ],
1718
+ ["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
1719
+ ]),
1720
+ // Convert an instruction to have all fields defined
1721
+ (instruction) => {
1722
+ if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
1723
+ return instruction;
1724
+ }
1725
+ return {
1726
+ ...instruction,
1727
+ accountIndices: instruction.accountIndices ?? [],
1728
+ data: instruction.data ?? new Uint8Array(0)
1729
+ };
1489
1730
  }
1490
- return {
1491
- ...value,
1492
- accountIndices: value.accountIndices ?? [],
1493
- data: value.data ?? new Uint8Array(0)
1494
- };
1495
- },
1496
- (value) => {
1497
- if (value.accountIndices.length && value.data.byteLength) {
1498
- return value;
1731
+ );
1732
+ }
1733
+ return memoizedGetInstructionEncoder;
1734
+ }
1735
+ var memoizedGetInstructionDecoder;
1736
+ function getInstructionDecoder() {
1737
+ if (!memoizedGetInstructionDecoder) {
1738
+ memoizedGetInstructionDecoder = mapDecoder(
1739
+ getStructDecoder([
1740
+ ["programAddressIndex", getU8Decoder({ description: programAddressIndexDescription })],
1741
+ [
1742
+ "accountIndices",
1743
+ getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {
1744
+ description: accountIndicesDescription,
1745
+ size: getShortU16Decoder()
1746
+ })
1747
+ ],
1748
+ ["data", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]
1749
+ ]),
1750
+ // Convert an instruction to exclude optional fields if they are empty
1751
+ (instruction) => {
1752
+ if (instruction.accountIndices.length && instruction.data.byteLength) {
1753
+ return instruction;
1754
+ }
1755
+ const { accountIndices, data, ...rest } = instruction;
1756
+ return {
1757
+ ...rest,
1758
+ ...accountIndices.length ? { accountIndices } : null,
1759
+ ...data.byteLength ? { data } : null
1760
+ };
1499
1761
  }
1500
- const { accountIndices, data, ...rest } = value;
1501
- return {
1502
- ...rest,
1503
- ...accountIndices.length ? { accountIndices } : null,
1504
- ...data.byteLength ? { data } : null
1505
- };
1506
- }
1507
- );
1762
+ );
1763
+ }
1764
+ return memoizedGetInstructionDecoder;
1765
+ }
1766
+ function getInstructionCodec() {
1767
+ return combineCodec(getInstructionEncoder(), getInstructionDecoder());
1508
1768
  }
1509
1769
 
1510
1770
  // src/serializers/transaction-version.ts
@@ -1588,18 +1848,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1588
1848
  ).serialize(compiledMessage);
1589
1849
  }
1590
1850
  }
1591
- function addressSerializerCompat2() {
1592
- const codec = getAddressCodec();
1593
- return {
1594
- description: codec.description,
1595
- deserialize: codec.decode,
1596
- fixedSize: codec.fixedSize,
1597
- maxSize: codec.maxSize,
1598
- serialize: codec.encode
1599
- };
1600
- }
1601
- function transactionVersionSerializerCompat() {
1602
- const codec = getTransactionVersionCodec();
1851
+ function toSerializer(codec) {
1603
1852
  return {
1604
1853
  description: codec.description,
1605
1854
  deserialize: codec.decode,
@@ -1610,11 +1859,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
1610
1859
  }
1611
1860
  function getPreludeStructSerializerTuple() {
1612
1861
  return [
1613
- ["version", transactionVersionSerializerCompat()],
1614
- ["header", getMessageHeaderCodec()],
1862
+ ["version", toSerializer(getTransactionVersionCodec())],
1863
+ ["header", toSerializer(getMessageHeaderCodec())],
1615
1864
  [
1616
1865
  "staticAccounts",
1617
- array(addressSerializerCompat2(), {
1866
+ array(toSerializer(getAddressCodec()), {
1618
1867
  description: "A compact-array of static account addresses belonging to this transaction" ,
1619
1868
  size: shortU16()
1620
1869
  })
@@ -1629,7 +1878,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1629
1878
  ],
1630
1879
  [
1631
1880
  "instructions",
1632
- array(getInstructionCodec(), {
1881
+ array(toSerializer(getInstructionCodec()), {
1633
1882
  description: "A compact-array of instructions belonging to this transaction" ,
1634
1883
  size: shortU16()
1635
1884
  })
@@ -1637,7 +1886,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1637
1886
  ];
1638
1887
  }
1639
1888
  function getAddressTableLookupsSerializer() {
1640
- return array(getAddressTableLookupCodec(), {
1889
+ return array(toSerializer(getAddressTableLookupCodec()), {
1641
1890
  ...{ description: "A compact array of address table lookups belonging to this transaction" } ,
1642
1891
  size: shortU16()
1643
1892
  });
@@ -1726,13 +1975,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
1726
1975
  return signature;
1727
1976
  }
1728
1977
  function getSignatureFromTransaction(transaction) {
1729
- const signature = transaction.signatures[transaction.feePayer];
1730
- if (!signature) {
1978
+ const signatureBytes = transaction.signatures[transaction.feePayer];
1979
+ if (!signatureBytes) {
1731
1980
  throw new Error(
1732
1981
  "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
1733
1982
  );
1734
1983
  }
1735
- return signature;
1984
+ const transactionSignature2 = base58.deserialize(signatureBytes)[0];
1985
+ return transactionSignature2;
1736
1986
  }
1737
1987
  async function signTransaction(keyPairs, transaction) {
1738
1988
  const compiledMessage = compileMessage(transaction);
@@ -1776,6 +2026,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1776
2026
  exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
1777
2027
  exports.getSignatureFromTransaction = getSignatureFromTransaction;
1778
2028
  exports.getTransactionEncoder = getTransactionEncoder;
2029
+ exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
1779
2030
  exports.isTransactionSignature = isTransactionSignature;
1780
2031
  exports.prependTransactionInstruction = prependTransactionInstruction;
1781
2032
  exports.setTransactionFeePayer = setTransactionFeePayer;