@solana/transactions 2.0.0-experimental.cc545f9 → 2.0.0-experimental.ce145c8
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/dist/index.browser.cjs +201 -149
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +203 -152
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +820 -162
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +203 -152
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +203 -147
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +203 -152
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +17 -16
- package/dist/types/durable-nonce.d.ts +1 -0
- package/dist/types/serializers/address-table-lookup.d.ts +5 -3
- package/dist/types/serializers/header.d.ts +4 -2
- package/dist/types/serializers/instruction.d.ts +4 -2
- package/dist/types/serializers/transaction-version.d.ts +4 -4
- package/package.json +10 -7
- package/dist/types/accounts.d.ts.map +0 -1
- package/dist/types/blockhash.d.ts.map +0 -1
- package/dist/types/compile-address-table-lookups.d.ts.map +0 -1
- package/dist/types/compile-header.d.ts.map +0 -1
- package/dist/types/compile-instructions.d.ts.map +0 -1
- package/dist/types/compile-lifetime-token.d.ts.map +0 -1
- package/dist/types/compile-static-accounts.d.ts.map +0 -1
- package/dist/types/compile-transaction.d.ts.map +0 -1
- package/dist/types/create-transaction.d.ts.map +0 -1
- package/dist/types/durable-nonce.d.ts.map +0 -1
- package/dist/types/fee-payer.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/instructions.d.ts.map +0 -1
- package/dist/types/message.d.ts.map +0 -1
- package/dist/types/serializers/address-table-lookup.d.ts.map +0 -1
- package/dist/types/serializers/header.d.ts.map +0 -1
- package/dist/types/serializers/index.d.ts.map +0 -1
- package/dist/types/serializers/instruction.d.ts.map +0 -1
- package/dist/types/serializers/message.d.ts.map +0 -1
- package/dist/types/serializers/transaction-version.d.ts.map +0 -1
- package/dist/types/serializers/transaction.d.ts.map +0 -1
- package/dist/types/serializers/unimplemented.d.ts.map +0 -1
- package/dist/types/signatures.d.ts.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/unsigned-transaction.d.ts.map +0 -1
- 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",
|
|
@@ -522,9 +512,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
522
512
|
if (numBytes !== 32) {
|
|
523
513
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
524
514
|
}
|
|
525
|
-
} catch (
|
|
515
|
+
} catch (e2) {
|
|
526
516
|
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
|
|
527
|
-
cause:
|
|
517
|
+
cause: e2
|
|
528
518
|
});
|
|
529
519
|
}
|
|
530
520
|
}
|
|
@@ -665,6 +655,388 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
665
655
|
return out;
|
|
666
656
|
}
|
|
667
657
|
|
|
658
|
+
// ../codecs-core/dist/index.browser.js
|
|
659
|
+
function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes2, offset = 0) {
|
|
660
|
+
if (bytes2.length - offset <= 0) {
|
|
661
|
+
throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes2, offset = 0) {
|
|
665
|
+
const bytesLength = bytes2.length - offset;
|
|
666
|
+
if (bytesLength < expected) {
|
|
667
|
+
throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
var mergeBytes2 = (byteArrays) => {
|
|
671
|
+
const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);
|
|
672
|
+
if (nonEmptyByteArrays.length === 0) {
|
|
673
|
+
return byteArrays.length ? byteArrays[0] : new Uint8Array();
|
|
674
|
+
}
|
|
675
|
+
if (nonEmptyByteArrays.length === 1) {
|
|
676
|
+
return nonEmptyByteArrays[0];
|
|
677
|
+
}
|
|
678
|
+
const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);
|
|
679
|
+
const result = new Uint8Array(totalLength);
|
|
680
|
+
let offset = 0;
|
|
681
|
+
nonEmptyByteArrays.forEach((arr) => {
|
|
682
|
+
result.set(arr, offset);
|
|
683
|
+
offset += arr.length;
|
|
684
|
+
});
|
|
685
|
+
return result;
|
|
686
|
+
};
|
|
687
|
+
var padBytes2 = (bytes2, length) => {
|
|
688
|
+
if (bytes2.length >= length)
|
|
689
|
+
return bytes2;
|
|
690
|
+
const paddedBytes = new Uint8Array(length).fill(0);
|
|
691
|
+
paddedBytes.set(bytes2);
|
|
692
|
+
return paddedBytes;
|
|
693
|
+
};
|
|
694
|
+
var fixBytes2 = (bytes2, length) => padBytes2(bytes2.length <= length ? bytes2 : bytes2.slice(0, length), length);
|
|
695
|
+
function combineCodec(encoder, decoder, description) {
|
|
696
|
+
if (encoder.fixedSize !== decoder.fixedSize) {
|
|
697
|
+
throw new Error(
|
|
698
|
+
`Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
if (encoder.maxSize !== decoder.maxSize) {
|
|
702
|
+
throw new Error(
|
|
703
|
+
`Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
if (description === void 0 && encoder.description !== decoder.description) {
|
|
707
|
+
throw new Error(
|
|
708
|
+
`Encoder and decoder must have the same description, got [${encoder.description}] and [${decoder.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
return {
|
|
712
|
+
decode: decoder.decode,
|
|
713
|
+
description: description ?? encoder.description,
|
|
714
|
+
encode: encoder.encode,
|
|
715
|
+
fixedSize: encoder.fixedSize,
|
|
716
|
+
maxSize: encoder.maxSize
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
function fixCodecHelper(data, fixedBytes, description) {
|
|
720
|
+
return {
|
|
721
|
+
description: description ?? `fixed(${fixedBytes}, ${data.description})`,
|
|
722
|
+
fixedSize: fixedBytes,
|
|
723
|
+
maxSize: fixedBytes
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
function fixEncoder(encoder, fixedBytes, description) {
|
|
727
|
+
return {
|
|
728
|
+
...fixCodecHelper(encoder, fixedBytes, description),
|
|
729
|
+
encode: (value) => fixBytes2(encoder.encode(value), fixedBytes)
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
function fixDecoder(decoder, fixedBytes, description) {
|
|
733
|
+
return {
|
|
734
|
+
...fixCodecHelper(decoder, fixedBytes, description),
|
|
735
|
+
decode: (bytes2, offset = 0) => {
|
|
736
|
+
assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes2, offset);
|
|
737
|
+
if (offset > 0 || bytes2.length > fixedBytes) {
|
|
738
|
+
bytes2 = bytes2.slice(offset, offset + fixedBytes);
|
|
739
|
+
}
|
|
740
|
+
if (decoder.fixedSize !== null) {
|
|
741
|
+
bytes2 = fixBytes2(bytes2, decoder.fixedSize);
|
|
742
|
+
}
|
|
743
|
+
const [value] = decoder.decode(bytes2, 0);
|
|
744
|
+
return [value, offset + fixedBytes];
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
function mapEncoder(encoder, unmap) {
|
|
749
|
+
return {
|
|
750
|
+
description: encoder.description,
|
|
751
|
+
encode: (value) => encoder.encode(unmap(value)),
|
|
752
|
+
fixedSize: encoder.fixedSize,
|
|
753
|
+
maxSize: encoder.maxSize
|
|
754
|
+
};
|
|
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
|
+
}
|
|
767
|
+
|
|
768
|
+
// ../codecs-numbers/dist/index.browser.js
|
|
769
|
+
function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
|
|
770
|
+
if (value < min || value > max) {
|
|
771
|
+
throw new Error(
|
|
772
|
+
`Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
function sharedNumberFactory(input) {
|
|
777
|
+
let littleEndian;
|
|
778
|
+
let defaultDescription = input.name;
|
|
779
|
+
if (input.size > 1) {
|
|
780
|
+
littleEndian = !("endian" in input.options) || input.options.endian === 0;
|
|
781
|
+
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
782
|
+
}
|
|
783
|
+
return {
|
|
784
|
+
description: input.options.description ?? defaultDescription,
|
|
785
|
+
fixedSize: input.size,
|
|
786
|
+
littleEndian,
|
|
787
|
+
maxSize: input.size
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
function numberEncoderFactory(input) {
|
|
791
|
+
const codecData = sharedNumberFactory(input);
|
|
792
|
+
return {
|
|
793
|
+
description: codecData.description,
|
|
794
|
+
encode(value) {
|
|
795
|
+
if (input.range) {
|
|
796
|
+
assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
|
|
797
|
+
}
|
|
798
|
+
const arrayBuffer = new ArrayBuffer(input.size);
|
|
799
|
+
input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
|
|
800
|
+
return new Uint8Array(arrayBuffer);
|
|
801
|
+
},
|
|
802
|
+
fixedSize: codecData.fixedSize,
|
|
803
|
+
maxSize: codecData.maxSize
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
function numberDecoderFactory(input) {
|
|
807
|
+
const codecData = sharedNumberFactory(input);
|
|
808
|
+
return {
|
|
809
|
+
decode(bytes2, offset = 0) {
|
|
810
|
+
assertByteArrayIsNotEmptyForCodec(codecData.description, bytes2, offset);
|
|
811
|
+
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes2, offset);
|
|
812
|
+
const view = new DataView(toArrayBuffer2(bytes2, offset, input.size));
|
|
813
|
+
return [input.get(view, codecData.littleEndian), offset + input.size];
|
|
814
|
+
},
|
|
815
|
+
description: codecData.description,
|
|
816
|
+
fixedSize: codecData.fixedSize,
|
|
817
|
+
maxSize: codecData.maxSize
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
function toArrayBuffer2(bytes2, offset, length) {
|
|
821
|
+
const bytesOffset = bytes2.byteOffset + (offset ?? 0);
|
|
822
|
+
const bytesLength = length ?? bytes2.byteLength;
|
|
823
|
+
return bytes2.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
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
|
+
});
|
|
865
|
+
var getU32Encoder = (options = {}) => numberEncoderFactory({
|
|
866
|
+
name: "u32",
|
|
867
|
+
options,
|
|
868
|
+
range: [0, Number("0xffffffff")],
|
|
869
|
+
set: (view, value, le) => view.setUint32(0, value, le),
|
|
870
|
+
size: 4
|
|
871
|
+
});
|
|
872
|
+
var getU32Decoder = (options = {}) => numberDecoderFactory({
|
|
873
|
+
get: (view, le) => view.getUint32(0, le),
|
|
874
|
+
name: "u32",
|
|
875
|
+
options,
|
|
876
|
+
size: 4
|
|
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));
|
|
892
|
+
|
|
893
|
+
// ../codecs-strings/dist/index.browser.js
|
|
894
|
+
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
895
|
+
if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
|
|
896
|
+
throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
var getBaseXEncoder = (alphabet4) => {
|
|
900
|
+
const base = alphabet4.length;
|
|
901
|
+
const baseBigInt = BigInt(base);
|
|
902
|
+
return {
|
|
903
|
+
description: `base${base}`,
|
|
904
|
+
encode(value) {
|
|
905
|
+
assertValidBaseString(alphabet4, value);
|
|
906
|
+
if (value === "")
|
|
907
|
+
return new Uint8Array();
|
|
908
|
+
const chars = [...value];
|
|
909
|
+
let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
|
|
910
|
+
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
911
|
+
const leadingZeroes = Array(trailIndex).fill(0);
|
|
912
|
+
if (trailIndex === chars.length)
|
|
913
|
+
return Uint8Array.from(leadingZeroes);
|
|
914
|
+
const tailChars = chars.slice(trailIndex);
|
|
915
|
+
let base10Number = 0n;
|
|
916
|
+
let baseXPower = 1n;
|
|
917
|
+
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
918
|
+
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
|
|
919
|
+
baseXPower *= baseBigInt;
|
|
920
|
+
}
|
|
921
|
+
const tailBytes = [];
|
|
922
|
+
while (base10Number > 0n) {
|
|
923
|
+
tailBytes.unshift(Number(base10Number % 256n));
|
|
924
|
+
base10Number /= 256n;
|
|
925
|
+
}
|
|
926
|
+
return Uint8Array.from(leadingZeroes.concat(tailBytes));
|
|
927
|
+
},
|
|
928
|
+
fixedSize: null,
|
|
929
|
+
maxSize: null
|
|
930
|
+
};
|
|
931
|
+
};
|
|
932
|
+
var getBaseXDecoder = (alphabet4) => {
|
|
933
|
+
const base = alphabet4.length;
|
|
934
|
+
const baseBigInt = BigInt(base);
|
|
935
|
+
return {
|
|
936
|
+
decode(rawBytes, offset = 0) {
|
|
937
|
+
const bytes2 = offset === 0 ? rawBytes : rawBytes.slice(offset);
|
|
938
|
+
if (bytes2.length === 0)
|
|
939
|
+
return ["", 0];
|
|
940
|
+
let trailIndex = bytes2.findIndex((n) => n !== 0);
|
|
941
|
+
trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
|
|
942
|
+
const leadingZeroes = alphabet4[0].repeat(trailIndex);
|
|
943
|
+
if (trailIndex === bytes2.length)
|
|
944
|
+
return [leadingZeroes, rawBytes.length];
|
|
945
|
+
let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
946
|
+
const tailChars = [];
|
|
947
|
+
while (base10Number > 0n) {
|
|
948
|
+
tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
|
|
949
|
+
base10Number /= baseBigInt;
|
|
950
|
+
}
|
|
951
|
+
return [leadingZeroes + tailChars.join(""), rawBytes.length];
|
|
952
|
+
},
|
|
953
|
+
description: `base${base}`,
|
|
954
|
+
fixedSize: null,
|
|
955
|
+
maxSize: null
|
|
956
|
+
};
|
|
957
|
+
};
|
|
958
|
+
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
959
|
+
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
960
|
+
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
961
|
+
var removeNullCharacters2 = (value) => (
|
|
962
|
+
// eslint-disable-next-line no-control-regex
|
|
963
|
+
value.replace(/\u0000/g, "")
|
|
964
|
+
);
|
|
965
|
+
var e = globalThis.TextDecoder;
|
|
966
|
+
var o = globalThis.TextEncoder;
|
|
967
|
+
var getUtf8Encoder = () => {
|
|
968
|
+
let textEncoder;
|
|
969
|
+
return {
|
|
970
|
+
description: "utf8",
|
|
971
|
+
encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
|
|
972
|
+
fixedSize: null,
|
|
973
|
+
maxSize: null
|
|
974
|
+
};
|
|
975
|
+
};
|
|
976
|
+
var getUtf8Decoder = () => {
|
|
977
|
+
let textDecoder;
|
|
978
|
+
return {
|
|
979
|
+
decode(bytes2, offset = 0) {
|
|
980
|
+
const value = (textDecoder || (textDecoder = new e())).decode(bytes2.slice(offset));
|
|
981
|
+
return [removeNullCharacters2(value), bytes2.length];
|
|
982
|
+
},
|
|
983
|
+
description: "utf8",
|
|
984
|
+
fixedSize: null,
|
|
985
|
+
maxSize: null
|
|
986
|
+
};
|
|
987
|
+
};
|
|
988
|
+
var getStringEncoder = (options = {}) => {
|
|
989
|
+
const size = options.size ?? getU32Encoder();
|
|
990
|
+
const encoding = options.encoding ?? getUtf8Encoder();
|
|
991
|
+
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription2(size)})`;
|
|
992
|
+
if (size === "variable") {
|
|
993
|
+
return { ...encoding, description };
|
|
994
|
+
}
|
|
995
|
+
if (typeof size === "number") {
|
|
996
|
+
return fixEncoder(encoding, size, description);
|
|
997
|
+
}
|
|
998
|
+
return {
|
|
999
|
+
description,
|
|
1000
|
+
encode: (value) => {
|
|
1001
|
+
const contentBytes = encoding.encode(value);
|
|
1002
|
+
const lengthBytes = size.encode(contentBytes.length);
|
|
1003
|
+
return mergeBytes2([lengthBytes, contentBytes]);
|
|
1004
|
+
},
|
|
1005
|
+
fixedSize: null,
|
|
1006
|
+
maxSize: null
|
|
1007
|
+
};
|
|
1008
|
+
};
|
|
1009
|
+
var getStringDecoder = (options = {}) => {
|
|
1010
|
+
const size = options.size ?? getU32Decoder();
|
|
1011
|
+
const encoding = options.encoding ?? getUtf8Decoder();
|
|
1012
|
+
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription2(size)})`;
|
|
1013
|
+
if (size === "variable") {
|
|
1014
|
+
return { ...encoding, description };
|
|
1015
|
+
}
|
|
1016
|
+
if (typeof size === "number") {
|
|
1017
|
+
return fixDecoder(encoding, size, description);
|
|
1018
|
+
}
|
|
1019
|
+
return {
|
|
1020
|
+
decode: (bytes2, offset = 0) => {
|
|
1021
|
+
assertByteArrayIsNotEmptyForCodec("string", bytes2, offset);
|
|
1022
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes2, offset);
|
|
1023
|
+
const length = Number(lengthBigInt);
|
|
1024
|
+
offset = lengthOffset;
|
|
1025
|
+
const contentBytes = bytes2.slice(offset, offset + length);
|
|
1026
|
+
assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
|
|
1027
|
+
const [value, contentOffset] = encoding.decode(contentBytes);
|
|
1028
|
+
offset += contentOffset;
|
|
1029
|
+
return [value, offset];
|
|
1030
|
+
},
|
|
1031
|
+
description,
|
|
1032
|
+
fixedSize: null,
|
|
1033
|
+
maxSize: null
|
|
1034
|
+
};
|
|
1035
|
+
};
|
|
1036
|
+
function getSizeDescription2(size) {
|
|
1037
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
668
1040
|
// ../assertions/dist/index.browser.js
|
|
669
1041
|
function assertIsSecureContext() {
|
|
670
1042
|
if (!globalThis.isSecureContext) {
|
|
@@ -685,13 +1057,65 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
685
1057
|
throw new Error("No signing implementation could be found");
|
|
686
1058
|
}
|
|
687
1059
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
1060
|
+
|
|
1061
|
+
// ../addresses/dist/index.browser.js
|
|
1062
|
+
var memoizedBase58Encoder;
|
|
1063
|
+
var memoizedBase58Decoder;
|
|
1064
|
+
function getMemoizedBase58Encoder() {
|
|
1065
|
+
if (!memoizedBase58Encoder)
|
|
1066
|
+
memoizedBase58Encoder = getBase58Encoder();
|
|
1067
|
+
return memoizedBase58Encoder;
|
|
1068
|
+
}
|
|
1069
|
+
function getMemoizedBase58Decoder() {
|
|
1070
|
+
if (!memoizedBase58Decoder)
|
|
1071
|
+
memoizedBase58Decoder = getBase58Decoder();
|
|
1072
|
+
return memoizedBase58Decoder;
|
|
1073
|
+
}
|
|
1074
|
+
function assertIsAddress(putativeBase58EncodedAddress) {
|
|
1075
|
+
try {
|
|
1076
|
+
if (
|
|
1077
|
+
// Lowest address (32 bytes of zeroes)
|
|
1078
|
+
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
1079
|
+
putativeBase58EncodedAddress.length > 44
|
|
1080
|
+
) {
|
|
1081
|
+
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
1082
|
+
}
|
|
1083
|
+
const base58Encoder = getMemoizedBase58Encoder();
|
|
1084
|
+
const bytes2 = base58Encoder.encode(putativeBase58EncodedAddress);
|
|
1085
|
+
const numBytes = bytes2.byteLength;
|
|
1086
|
+
if (numBytes !== 32) {
|
|
1087
|
+
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
1088
|
+
}
|
|
1089
|
+
} catch (e2) {
|
|
1090
|
+
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
1091
|
+
cause: e2
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
function address(putativeBase58EncodedAddress) {
|
|
1096
|
+
assertIsAddress(putativeBase58EncodedAddress);
|
|
1097
|
+
return putativeBase58EncodedAddress;
|
|
1098
|
+
}
|
|
1099
|
+
function getAddressEncoder(config) {
|
|
1100
|
+
return mapEncoder(
|
|
1101
|
+
getStringEncoder({
|
|
1102
|
+
description: config?.description ?? "Base58EncodedAddress",
|
|
1103
|
+
encoding: getMemoizedBase58Encoder(),
|
|
1104
|
+
size: 32
|
|
1105
|
+
}),
|
|
1106
|
+
(putativeAddress) => address(putativeAddress)
|
|
1107
|
+
);
|
|
1108
|
+
}
|
|
1109
|
+
function getAddressDecoder(config) {
|
|
1110
|
+
return getStringDecoder({
|
|
1111
|
+
description: config?.description ?? "Base58EncodedAddress",
|
|
1112
|
+
encoding: getMemoizedBase58Decoder(),
|
|
692
1113
|
size: 32
|
|
693
1114
|
});
|
|
694
1115
|
}
|
|
1116
|
+
function getAddressCodec(config) {
|
|
1117
|
+
return combineCodec(getAddressEncoder(config), getAddressDecoder(config));
|
|
1118
|
+
}
|
|
695
1119
|
function getAddressComparator() {
|
|
696
1120
|
return new Intl.Collator("en", {
|
|
697
1121
|
caseFirst: "lower",
|
|
@@ -708,13 +1132,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
708
1132
|
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
709
1133
|
}
|
|
710
1134
|
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
711
|
-
const [base58EncodedAddress] =
|
|
1135
|
+
const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
|
|
712
1136
|
return base58EncodedAddress;
|
|
713
1137
|
}
|
|
714
1138
|
|
|
715
1139
|
// src/accounts.ts
|
|
716
|
-
function upsert(addressMap,
|
|
717
|
-
addressMap[
|
|
1140
|
+
function upsert(addressMap, address2, update) {
|
|
1141
|
+
addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole.READONLY });
|
|
718
1142
|
}
|
|
719
1143
|
var TYPE = Symbol("AddressMapTypeProperty");
|
|
720
1144
|
function getAddressMapFromInstructions(feePayer, instructions) {
|
|
@@ -877,8 +1301,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
877
1301
|
} else {
|
|
878
1302
|
return addressComparator(leftAddress, rightAddress);
|
|
879
1303
|
}
|
|
880
|
-
}).map(([
|
|
881
|
-
address,
|
|
1304
|
+
}).map(([address2, addressMeta]) => ({
|
|
1305
|
+
address: address2,
|
|
882
1306
|
...addressMeta
|
|
883
1307
|
}));
|
|
884
1308
|
return orderedAccounts;
|
|
@@ -947,7 +1371,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
947
1371
|
return instructions.map(({ accounts, data, programAddress }) => {
|
|
948
1372
|
return {
|
|
949
1373
|
programAddressIndex: accountIndex[programAddress],
|
|
950
|
-
...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[
|
|
1374
|
+
...accounts ? { accountIndices: accounts.map(({ address: address2 }) => accountIndex[address2]) } : null,
|
|
951
1375
|
...data ? { data } : null
|
|
952
1376
|
};
|
|
953
1377
|
});
|
|
@@ -965,7 +1389,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
965
1389
|
function getCompiledStaticAccounts(orderedAccounts) {
|
|
966
1390
|
const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
|
|
967
1391
|
const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
|
|
968
|
-
return orderedStaticAccounts.map(({ address }) =>
|
|
1392
|
+
return orderedStaticAccounts.map(({ address: address2 }) => address2);
|
|
969
1393
|
}
|
|
970
1394
|
|
|
971
1395
|
// src/message.ts
|
|
@@ -1000,145 +1424,347 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1000
1424
|
};
|
|
1001
1425
|
}
|
|
1002
1426
|
|
|
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
|
+
}
|
|
1476
|
+
return {
|
|
1477
|
+
description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
1478
|
+
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
1479
|
+
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
1480
|
+
};
|
|
1481
|
+
}
|
|
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
|
+
|
|
1003
1608
|
// src/serializers/address-table-lookup.ts
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
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(
|
|
1007
1617
|
[
|
|
1008
|
-
"lookupTableAddress",
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
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
|
+
]
|
|
1014
1633
|
],
|
|
1634
|
+
{ description: addressTableLookupDescription }
|
|
1635
|
+
);
|
|
1636
|
+
}
|
|
1637
|
+
return memoizedAddressTableLookupEncoder;
|
|
1638
|
+
}
|
|
1639
|
+
var memoizedAddressTableLookupDecoder;
|
|
1640
|
+
function getAddressTableLookupDecoder() {
|
|
1641
|
+
if (!memoizedAddressTableLookupDecoder) {
|
|
1642
|
+
memoizedAddressTableLookupDecoder = getStructDecoder(
|
|
1015
1643
|
[
|
|
1016
|
-
"
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
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
|
+
]
|
|
1023
1659
|
],
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
})
|
|
1032
|
-
]
|
|
1033
|
-
],
|
|
1034
|
-
{
|
|
1035
|
-
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"
|
|
1036
|
-
}
|
|
1037
|
-
);
|
|
1660
|
+
{ description: addressTableLookupDescription }
|
|
1661
|
+
);
|
|
1662
|
+
}
|
|
1663
|
+
return memoizedAddressTableLookupDecoder;
|
|
1664
|
+
}
|
|
1665
|
+
function getAddressTableLookupCodec() {
|
|
1666
|
+
return combineCodec(getAddressTableLookupEncoder(), getAddressTableLookupDecoder());
|
|
1038
1667
|
}
|
|
1039
1668
|
|
|
1040
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" ;
|
|
1041
1687
|
function getMessageHeaderCodec() {
|
|
1042
|
-
return
|
|
1688
|
+
return getStructCodec(
|
|
1043
1689
|
[
|
|
1044
|
-
[
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
{
|
|
1048
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction"
|
|
1049
|
-
}
|
|
1050
|
-
)
|
|
1051
|
-
],
|
|
1052
|
-
[
|
|
1053
|
-
"numReadonlySignerAccounts",
|
|
1054
|
-
u8(
|
|
1055
|
-
{
|
|
1056
|
-
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"
|
|
1057
|
-
}
|
|
1058
|
-
)
|
|
1059
|
-
],
|
|
1060
|
-
[
|
|
1061
|
-
"numReadonlyNonSignerAccounts",
|
|
1062
|
-
u8(
|
|
1063
|
-
{
|
|
1064
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
|
|
1065
|
-
}
|
|
1066
|
-
)
|
|
1067
|
-
]
|
|
1690
|
+
["numSignerAccounts", getMemoizedU8CodecDescription(numSignerAccountsDescription)],
|
|
1691
|
+
["numReadonlySignerAccounts", getMemoizedU8CodecDescription(numReadonlySignerAccountsDescription)],
|
|
1692
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8CodecDescription(numReadonlyNonSignerAccountsDescription)]
|
|
1068
1693
|
],
|
|
1069
1694
|
{
|
|
1070
|
-
description:
|
|
1071
|
-
}
|
|
1695
|
+
description: messageHeaderDescription
|
|
1696
|
+
}
|
|
1072
1697
|
);
|
|
1073
1698
|
}
|
|
1074
1699
|
|
|
1075
1700
|
// src/serializers/instruction.ts
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
)
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
)
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
}
|
|
1105
|
-
]
|
|
1106
|
-
]),
|
|
1107
|
-
(value) => {
|
|
1108
|
-
if (value.accountIndices !== void 0 && value.data !== void 0) {
|
|
1109
|
-
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
|
+
};
|
|
1110
1730
|
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
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
|
+
};
|
|
1120
1761
|
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
...accountIndices.length ? { accountIndices } : null,
|
|
1125
|
-
...data.byteLength ? { data } : null
|
|
1126
|
-
};
|
|
1127
|
-
}
|
|
1128
|
-
);
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
// src/serializers/unimplemented.ts
|
|
1132
|
-
function getError(type, name) {
|
|
1133
|
-
const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
|
|
1134
|
-
return new Error(
|
|
1135
|
-
`No ${type} exists for ${name}. Use \`get${functionSuffix}()\` if you need a ${type}, and \`get${name}Codec()\` if you need to both encode and decode ${name}`
|
|
1136
|
-
);
|
|
1762
|
+
);
|
|
1763
|
+
}
|
|
1764
|
+
return memoizedGetInstructionDecoder;
|
|
1137
1765
|
}
|
|
1138
|
-
function
|
|
1139
|
-
return ()
|
|
1140
|
-
throw getError("decoder", name);
|
|
1141
|
-
};
|
|
1766
|
+
function getInstructionCodec() {
|
|
1767
|
+
return combineCodec(getInstructionEncoder(), getInstructionDecoder());
|
|
1142
1768
|
}
|
|
1143
1769
|
|
|
1144
1770
|
// src/serializers/transaction-version.ts
|
|
@@ -1148,7 +1774,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1148
1774
|
fixedSize: null,
|
|
1149
1775
|
maxSize: 1
|
|
1150
1776
|
};
|
|
1151
|
-
function
|
|
1777
|
+
function decode(bytes2, offset = 0) {
|
|
1152
1778
|
const firstByte = bytes2[offset];
|
|
1153
1779
|
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
1154
1780
|
return ["legacy", offset];
|
|
@@ -1157,7 +1783,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1157
1783
|
return [version, offset + 1];
|
|
1158
1784
|
}
|
|
1159
1785
|
}
|
|
1160
|
-
function
|
|
1786
|
+
function encode(value) {
|
|
1161
1787
|
if (value === "legacy") {
|
|
1162
1788
|
return new Uint8Array();
|
|
1163
1789
|
}
|
|
@@ -1166,11 +1792,32 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1166
1792
|
}
|
|
1167
1793
|
return new Uint8Array([value | VERSION_FLAG_MASK]);
|
|
1168
1794
|
}
|
|
1169
|
-
function
|
|
1795
|
+
function getTransactionVersionDecoder() {
|
|
1170
1796
|
return {
|
|
1171
1797
|
...BASE_CONFIG,
|
|
1172
|
-
|
|
1173
|
-
|
|
1798
|
+
decode
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
1801
|
+
function getTransactionVersionEncoder() {
|
|
1802
|
+
return {
|
|
1803
|
+
...BASE_CONFIG,
|
|
1804
|
+
encode
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
function getTransactionVersionCodec() {
|
|
1808
|
+
return combineCodec(getTransactionVersionEncoder(), getTransactionVersionDecoder());
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
// src/serializers/unimplemented.ts
|
|
1812
|
+
function getError(type, name) {
|
|
1813
|
+
const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
|
|
1814
|
+
return new Error(
|
|
1815
|
+
`No ${type} exists for ${name}. Use \`get${functionSuffix}()\` if you need a ${type}, and \`get${name}Codec()\` if you need to both encode and decode ${name}`
|
|
1816
|
+
);
|
|
1817
|
+
}
|
|
1818
|
+
function getUnimplementedDecoder(name) {
|
|
1819
|
+
return () => {
|
|
1820
|
+
throw getError("decoder", name);
|
|
1174
1821
|
};
|
|
1175
1822
|
}
|
|
1176
1823
|
|
|
@@ -1180,7 +1827,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1180
1827
|
fixedSize: null,
|
|
1181
1828
|
maxSize: null
|
|
1182
1829
|
};
|
|
1183
|
-
function
|
|
1830
|
+
function serialize(compiledMessage) {
|
|
1184
1831
|
if (compiledMessage.version === "legacy") {
|
|
1185
1832
|
return struct(getPreludeStructSerializerTuple()).serialize(compiledMessage);
|
|
1186
1833
|
} else {
|
|
@@ -1201,13 +1848,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1201
1848
|
).serialize(compiledMessage);
|
|
1202
1849
|
}
|
|
1203
1850
|
}
|
|
1851
|
+
function toSerializer(codec) {
|
|
1852
|
+
return {
|
|
1853
|
+
description: codec.description,
|
|
1854
|
+
deserialize: codec.decode,
|
|
1855
|
+
fixedSize: codec.fixedSize,
|
|
1856
|
+
maxSize: codec.maxSize,
|
|
1857
|
+
serialize: codec.encode
|
|
1858
|
+
};
|
|
1859
|
+
}
|
|
1204
1860
|
function getPreludeStructSerializerTuple() {
|
|
1205
1861
|
return [
|
|
1206
|
-
["version", getTransactionVersionCodec()],
|
|
1207
|
-
["header", getMessageHeaderCodec()],
|
|
1862
|
+
["version", toSerializer(getTransactionVersionCodec())],
|
|
1863
|
+
["header", toSerializer(getMessageHeaderCodec())],
|
|
1208
1864
|
[
|
|
1209
1865
|
"staticAccounts",
|
|
1210
|
-
array(getAddressCodec(), {
|
|
1866
|
+
array(toSerializer(getAddressCodec()), {
|
|
1211
1867
|
description: "A compact-array of static account addresses belonging to this transaction" ,
|
|
1212
1868
|
size: shortU16()
|
|
1213
1869
|
})
|
|
@@ -1222,7 +1878,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1222
1878
|
],
|
|
1223
1879
|
[
|
|
1224
1880
|
"instructions",
|
|
1225
|
-
array(getInstructionCodec(), {
|
|
1881
|
+
array(toSerializer(getInstructionCodec()), {
|
|
1226
1882
|
description: "A compact-array of instructions belonging to this transaction" ,
|
|
1227
1883
|
size: shortU16()
|
|
1228
1884
|
})
|
|
@@ -1230,7 +1886,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1230
1886
|
];
|
|
1231
1887
|
}
|
|
1232
1888
|
function getAddressTableLookupsSerializer() {
|
|
1233
|
-
return array(getAddressTableLookupCodec(), {
|
|
1889
|
+
return array(toSerializer(getAddressTableLookupCodec()), {
|
|
1234
1890
|
...{ description: "A compact array of address table lookups belonging to this transaction" } ,
|
|
1235
1891
|
size: shortU16()
|
|
1236
1892
|
});
|
|
@@ -1239,7 +1895,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1239
1895
|
return {
|
|
1240
1896
|
...BASE_CONFIG2,
|
|
1241
1897
|
deserialize: getUnimplementedDecoder("CompiledMessage"),
|
|
1242
|
-
serialize
|
|
1898
|
+
serialize
|
|
1243
1899
|
};
|
|
1244
1900
|
}
|
|
1245
1901
|
|
|
@@ -1249,7 +1905,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1249
1905
|
fixedSize: null,
|
|
1250
1906
|
maxSize: null
|
|
1251
1907
|
};
|
|
1252
|
-
function
|
|
1908
|
+
function serialize2(transaction) {
|
|
1253
1909
|
const compiledTransaction = getCompiledTransaction(transaction);
|
|
1254
1910
|
return struct([
|
|
1255
1911
|
[
|
|
@@ -1266,7 +1922,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1266
1922
|
return {
|
|
1267
1923
|
...BASE_CONFIG3,
|
|
1268
1924
|
deserialize: getUnimplementedDecoder("CompiledMessage"),
|
|
1269
|
-
serialize:
|
|
1925
|
+
serialize: serialize2
|
|
1270
1926
|
};
|
|
1271
1927
|
}
|
|
1272
1928
|
|
|
@@ -1292,9 +1948,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1292
1948
|
if (numBytes !== 64) {
|
|
1293
1949
|
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
1294
1950
|
}
|
|
1295
|
-
} catch (
|
|
1951
|
+
} catch (e2) {
|
|
1296
1952
|
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
|
|
1297
|
-
cause:
|
|
1953
|
+
cause: e2
|
|
1298
1954
|
});
|
|
1299
1955
|
}
|
|
1300
1956
|
}
|
|
@@ -1319,13 +1975,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1319
1975
|
return signature;
|
|
1320
1976
|
}
|
|
1321
1977
|
function getSignatureFromTransaction(transaction) {
|
|
1322
|
-
const
|
|
1323
|
-
if (!
|
|
1978
|
+
const signatureBytes = transaction.signatures[transaction.feePayer];
|
|
1979
|
+
if (!signatureBytes) {
|
|
1324
1980
|
throw new Error(
|
|
1325
1981
|
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
1326
1982
|
);
|
|
1327
1983
|
}
|
|
1328
|
-
|
|
1984
|
+
const transactionSignature2 = base58.deserialize(signatureBytes)[0];
|
|
1985
|
+
return transactionSignature2;
|
|
1329
1986
|
}
|
|
1330
1987
|
async function signTransaction(keyPairs, transaction) {
|
|
1331
1988
|
const compiledMessage = compileMessage(transaction);
|
|
@@ -1369,6 +2026,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1369
2026
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
1370
2027
|
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
1371
2028
|
exports.getTransactionEncoder = getTransactionEncoder;
|
|
2029
|
+
exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
|
|
1372
2030
|
exports.isTransactionSignature = isTransactionSignature;
|
|
1373
2031
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
1374
2032
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|