@solana/web3.js 2.0.0-experimental.8936f2f → 2.0.0-experimental.8c9cacd
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 +10 -3
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +1 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +420 -181
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +1 -0
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +10 -3
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +1 -0
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +30 -29
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/rpc-default-config.d.ts.map +1 -0
- package/dist/types/rpc-integer-overflow-error.d.ts.map +1 -0
- package/dist/types/rpc-request-coalescer.d.ts.map +1 -0
- package/dist/types/rpc-request-deduplication.d.ts.map +1 -0
- package/dist/types/rpc-transport.d.ts.map +1 -0
- package/dist/types/rpc.d.ts.map +1 -0
- package/package.json +13 -16
|
@@ -12,8 +12,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
12
12
|
var __esm = (fn, res) => function __init() {
|
|
13
13
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
14
14
|
};
|
|
15
|
-
var __commonJS = (cb,
|
|
16
|
-
return
|
|
15
|
+
var __commonJS = (cb, mod2) => function __require() {
|
|
16
|
+
return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
|
|
17
17
|
};
|
|
18
18
|
var __copyProps = (to, from, except, desc) => {
|
|
19
19
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -23,13 +23,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
23
23
|
}
|
|
24
24
|
return to;
|
|
25
25
|
};
|
|
26
|
-
var __toESM = (
|
|
26
|
+
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
|
|
27
27
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
28
|
// file that has been converted to a CommonJS file using a Babel-
|
|
29
29
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
30
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
-
isNodeMode || !
|
|
32
|
-
|
|
31
|
+
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
|
|
32
|
+
mod2
|
|
33
33
|
));
|
|
34
34
|
var __publicField = (obj, key, value) => {
|
|
35
35
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -122,44 +122,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
122
122
|
// src/index.ts
|
|
123
123
|
init_env_shim();
|
|
124
124
|
|
|
125
|
-
// ../
|
|
126
|
-
init_env_shim();
|
|
127
|
-
var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
|
|
128
|
-
AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
|
|
129
|
-
3] = "WRITABLE_SIGNER";
|
|
130
|
-
AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
|
|
131
|
-
2] = "READONLY_SIGNER";
|
|
132
|
-
AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
|
|
133
|
-
1] = "WRITABLE";
|
|
134
|
-
AccountRole22[AccountRole22["READONLY"] = /* 0 */
|
|
135
|
-
0] = "READONLY";
|
|
136
|
-
return AccountRole22;
|
|
137
|
-
})(AccountRole || {});
|
|
138
|
-
var IS_SIGNER_BITMASK = 2;
|
|
139
|
-
var IS_WRITABLE_BITMASK = 1;
|
|
140
|
-
function downgradeRoleToNonSigner(role) {
|
|
141
|
-
return role & ~IS_SIGNER_BITMASK;
|
|
142
|
-
}
|
|
143
|
-
function downgradeRoleToReadonly(role) {
|
|
144
|
-
return role & ~IS_WRITABLE_BITMASK;
|
|
145
|
-
}
|
|
146
|
-
function isSignerRole(role) {
|
|
147
|
-
return role >= 2;
|
|
148
|
-
}
|
|
149
|
-
function isWritableRole(role) {
|
|
150
|
-
return (role & IS_WRITABLE_BITMASK) !== 0;
|
|
151
|
-
}
|
|
152
|
-
function mergeRoles(roleA, roleB) {
|
|
153
|
-
return roleA | roleB;
|
|
154
|
-
}
|
|
155
|
-
function upgradeRoleToSigner(role) {
|
|
156
|
-
return role | IS_SIGNER_BITMASK;
|
|
157
|
-
}
|
|
158
|
-
function upgradeRoleToWritable(role) {
|
|
159
|
-
return role | IS_WRITABLE_BITMASK;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// ../keys/dist/index.browser.js
|
|
125
|
+
// ../addresses/dist/index.browser.js
|
|
163
126
|
init_env_shim();
|
|
164
127
|
|
|
165
128
|
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/index.mjs
|
|
@@ -685,43 +648,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
685
648
|
}
|
|
686
649
|
};
|
|
687
650
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
// Lowest address (32 bytes of zeroes)
|
|
692
|
-
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
693
|
-
putativeBase58EncodedAddress.length > 44
|
|
694
|
-
) {
|
|
695
|
-
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
696
|
-
}
|
|
697
|
-
const bytes2 = base58.serialize(putativeBase58EncodedAddress);
|
|
698
|
-
const numBytes = bytes2.byteLength;
|
|
699
|
-
if (numBytes !== 32) {
|
|
700
|
-
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
701
|
-
}
|
|
702
|
-
} catch (e2) {
|
|
703
|
-
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
704
|
-
cause: e2
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
function getBase58EncodedAddressCodec(config) {
|
|
709
|
-
return string({
|
|
710
|
-
description: config?.description ?? ("A 32-byte account address" ),
|
|
711
|
-
encoding: base58,
|
|
712
|
-
size: 32
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
|
-
function getBase58EncodedAddressComparator() {
|
|
716
|
-
return new Intl.Collator("en", {
|
|
717
|
-
caseFirst: "lower",
|
|
718
|
-
ignorePunctuation: false,
|
|
719
|
-
localeMatcher: "best fit",
|
|
720
|
-
numeric: false,
|
|
721
|
-
sensitivity: "variant",
|
|
722
|
-
usage: "sort"
|
|
723
|
-
}).compare;
|
|
724
|
-
}
|
|
651
|
+
|
|
652
|
+
// ../assertions/dist/index.browser.js
|
|
653
|
+
init_env_shim();
|
|
725
654
|
function assertIsSecureContext() {
|
|
726
655
|
if (!globalThis.isSecureContext) {
|
|
727
656
|
throw new Error(
|
|
@@ -751,6 +680,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
751
680
|
return await cachedEd25519Decision;
|
|
752
681
|
}
|
|
753
682
|
}
|
|
683
|
+
async function assertDigestCapabilityIsAvailable() {
|
|
684
|
+
assertIsSecureContext();
|
|
685
|
+
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.digest !== "function") {
|
|
686
|
+
throw new Error("No digest implementation could be found");
|
|
687
|
+
}
|
|
688
|
+
}
|
|
754
689
|
async function assertKeyGenerationIsAvailable() {
|
|
755
690
|
assertIsSecureContext();
|
|
756
691
|
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") {
|
|
@@ -780,6 +715,253 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
780
715
|
throw new Error("No signature verification implementation could be found");
|
|
781
716
|
}
|
|
782
717
|
}
|
|
718
|
+
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
719
|
+
try {
|
|
720
|
+
if (
|
|
721
|
+
// Lowest address (32 bytes of zeroes)
|
|
722
|
+
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
723
|
+
putativeBase58EncodedAddress.length > 44
|
|
724
|
+
) {
|
|
725
|
+
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
726
|
+
}
|
|
727
|
+
const bytes2 = base58.serialize(putativeBase58EncodedAddress);
|
|
728
|
+
const numBytes = bytes2.byteLength;
|
|
729
|
+
if (numBytes !== 32) {
|
|
730
|
+
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
731
|
+
}
|
|
732
|
+
} catch (e3) {
|
|
733
|
+
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
734
|
+
cause: e3
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
function getBase58EncodedAddressCodec(config) {
|
|
739
|
+
return string({
|
|
740
|
+
description: config?.description ?? ("A 32-byte account address" ),
|
|
741
|
+
encoding: base58,
|
|
742
|
+
size: 32
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
function getBase58EncodedAddressComparator() {
|
|
746
|
+
return new Intl.Collator("en", {
|
|
747
|
+
caseFirst: "lower",
|
|
748
|
+
ignorePunctuation: false,
|
|
749
|
+
localeMatcher: "best fit",
|
|
750
|
+
numeric: false,
|
|
751
|
+
sensitivity: "variant",
|
|
752
|
+
usage: "sort"
|
|
753
|
+
}).compare;
|
|
754
|
+
}
|
|
755
|
+
var D = 37095705934669439343138083508754565189542113879843219016388785533085940283555n;
|
|
756
|
+
var P = 57896044618658097711785492504343953926634992332820282019728792003956564819949n;
|
|
757
|
+
var RM1 = 19681161376707505956807079304988542015446066515923890162744021073123829784752n;
|
|
758
|
+
function mod(a) {
|
|
759
|
+
const r = a % P;
|
|
760
|
+
return r >= 0n ? r : P + r;
|
|
761
|
+
}
|
|
762
|
+
function pow2(x, power) {
|
|
763
|
+
let r = x;
|
|
764
|
+
while (power-- > 0n) {
|
|
765
|
+
r *= r;
|
|
766
|
+
r %= P;
|
|
767
|
+
}
|
|
768
|
+
return r;
|
|
769
|
+
}
|
|
770
|
+
function pow_2_252_3(x) {
|
|
771
|
+
const x2 = x * x % P;
|
|
772
|
+
const b2 = x2 * x % P;
|
|
773
|
+
const b4 = pow2(b2, 2n) * b2 % P;
|
|
774
|
+
const b5 = pow2(b4, 1n) * x % P;
|
|
775
|
+
const b10 = pow2(b5, 5n) * b5 % P;
|
|
776
|
+
const b20 = pow2(b10, 10n) * b10 % P;
|
|
777
|
+
const b40 = pow2(b20, 20n) * b20 % P;
|
|
778
|
+
const b80 = pow2(b40, 40n) * b40 % P;
|
|
779
|
+
const b160 = pow2(b80, 80n) * b80 % P;
|
|
780
|
+
const b240 = pow2(b160, 80n) * b80 % P;
|
|
781
|
+
const b250 = pow2(b240, 10n) * b10 % P;
|
|
782
|
+
const pow_p_5_8 = pow2(b250, 2n) * x % P;
|
|
783
|
+
return pow_p_5_8;
|
|
784
|
+
}
|
|
785
|
+
function uvRatio(u, v) {
|
|
786
|
+
const v3 = mod(v * v * v);
|
|
787
|
+
const v7 = mod(v3 * v3 * v);
|
|
788
|
+
const pow = pow_2_252_3(u * v7);
|
|
789
|
+
let x = mod(u * v3 * pow);
|
|
790
|
+
const vx2 = mod(v * x * x);
|
|
791
|
+
const root1 = x;
|
|
792
|
+
const root2 = mod(x * RM1);
|
|
793
|
+
const useRoot1 = vx2 === u;
|
|
794
|
+
const useRoot2 = vx2 === mod(-u);
|
|
795
|
+
const noRoot = vx2 === mod(-u * RM1);
|
|
796
|
+
if (useRoot1)
|
|
797
|
+
x = root1;
|
|
798
|
+
if (useRoot2 || noRoot)
|
|
799
|
+
x = root2;
|
|
800
|
+
if ((mod(x) & 1n) === 1n)
|
|
801
|
+
x = mod(-x);
|
|
802
|
+
if (!useRoot1 && !useRoot2) {
|
|
803
|
+
return null;
|
|
804
|
+
}
|
|
805
|
+
return x;
|
|
806
|
+
}
|
|
807
|
+
function pointIsOnCurve(y, lastByte) {
|
|
808
|
+
const y2 = mod(y * y);
|
|
809
|
+
const u = mod(y2 - 1n);
|
|
810
|
+
const v = mod(D * y2 + 1n);
|
|
811
|
+
const x = uvRatio(u, v);
|
|
812
|
+
if (x === null) {
|
|
813
|
+
return false;
|
|
814
|
+
}
|
|
815
|
+
const isLastByteOdd = (lastByte & 128) !== 0;
|
|
816
|
+
if (x === 0n && isLastByteOdd) {
|
|
817
|
+
return false;
|
|
818
|
+
}
|
|
819
|
+
return true;
|
|
820
|
+
}
|
|
821
|
+
function byteToHex(byte) {
|
|
822
|
+
const hexString = byte.toString(16);
|
|
823
|
+
if (hexString.length === 1) {
|
|
824
|
+
return `0${hexString}`;
|
|
825
|
+
} else {
|
|
826
|
+
return hexString;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
function decompressPointBytes(bytes2) {
|
|
830
|
+
const hexString = bytes2.reduce((acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~128 : byte)}${acc}`, "");
|
|
831
|
+
const integerLiteralString = `0x${hexString}`;
|
|
832
|
+
return BigInt(integerLiteralString);
|
|
833
|
+
}
|
|
834
|
+
async function compressedPointBytesAreOnCurve(bytes2) {
|
|
835
|
+
if (bytes2.byteLength !== 32) {
|
|
836
|
+
return false;
|
|
837
|
+
}
|
|
838
|
+
const y = decompressPointBytes(bytes2);
|
|
839
|
+
return pointIsOnCurve(y, bytes2[31]);
|
|
840
|
+
}
|
|
841
|
+
var MAX_SEED_LENGTH = 32;
|
|
842
|
+
var MAX_SEEDS = 16;
|
|
843
|
+
var PDA_MARKER_BYTES = [
|
|
844
|
+
// The string 'ProgramDerivedAddress'
|
|
845
|
+
80,
|
|
846
|
+
114,
|
|
847
|
+
111,
|
|
848
|
+
103,
|
|
849
|
+
114,
|
|
850
|
+
97,
|
|
851
|
+
109,
|
|
852
|
+
68,
|
|
853
|
+
101,
|
|
854
|
+
114,
|
|
855
|
+
105,
|
|
856
|
+
118,
|
|
857
|
+
101,
|
|
858
|
+
100,
|
|
859
|
+
65,
|
|
860
|
+
100,
|
|
861
|
+
100,
|
|
862
|
+
114,
|
|
863
|
+
101,
|
|
864
|
+
115,
|
|
865
|
+
115
|
|
866
|
+
];
|
|
867
|
+
var PointOnCurveError = class extends Error {
|
|
868
|
+
};
|
|
869
|
+
async function createProgramDerivedAddress({ programAddress, seeds }) {
|
|
870
|
+
await assertDigestCapabilityIsAvailable();
|
|
871
|
+
if (seeds.length > MAX_SEEDS) {
|
|
872
|
+
throw new Error(`A maximum of ${MAX_SEEDS} seeds may be supplied when creating an address`);
|
|
873
|
+
}
|
|
874
|
+
let textEncoder;
|
|
875
|
+
const seedBytes = seeds.reduce((acc, seed, ii) => {
|
|
876
|
+
const bytes2 = typeof seed === "string" ? (textEncoder || (textEncoder = new TextEncoder())).encode(seed) : seed;
|
|
877
|
+
if (bytes2.byteLength > MAX_SEED_LENGTH) {
|
|
878
|
+
throw new Error(`The seed at index ${ii} exceeds the maximum length of 32 bytes`);
|
|
879
|
+
}
|
|
880
|
+
acc.push(...bytes2);
|
|
881
|
+
return acc;
|
|
882
|
+
}, []);
|
|
883
|
+
const base58EncodedAddressCodec = getBase58EncodedAddressCodec();
|
|
884
|
+
const programAddressBytes = base58EncodedAddressCodec.serialize(programAddress);
|
|
885
|
+
const addressBytesBuffer = await crypto.subtle.digest(
|
|
886
|
+
"SHA-256",
|
|
887
|
+
new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES])
|
|
888
|
+
);
|
|
889
|
+
const addressBytes = new Uint8Array(addressBytesBuffer);
|
|
890
|
+
if (await compressedPointBytesAreOnCurve(addressBytes)) {
|
|
891
|
+
throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
|
|
892
|
+
}
|
|
893
|
+
return base58EncodedAddressCodec.deserialize(addressBytes)[0];
|
|
894
|
+
}
|
|
895
|
+
async function getProgramDerivedAddress({ programAddress, seeds }) {
|
|
896
|
+
let bumpSeed = 255;
|
|
897
|
+
while (bumpSeed > 0) {
|
|
898
|
+
try {
|
|
899
|
+
return {
|
|
900
|
+
bumpSeed,
|
|
901
|
+
pda: await createProgramDerivedAddress({
|
|
902
|
+
programAddress,
|
|
903
|
+
seeds: [...seeds, new Uint8Array([bumpSeed])]
|
|
904
|
+
})
|
|
905
|
+
};
|
|
906
|
+
} catch (e3) {
|
|
907
|
+
if (e3 instanceof PointOnCurveError) {
|
|
908
|
+
bumpSeed--;
|
|
909
|
+
} else {
|
|
910
|
+
throw e3;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
throw new Error("Unable to find a viable program address bump seed");
|
|
915
|
+
}
|
|
916
|
+
async function getAddressFromPublicKey(publicKey) {
|
|
917
|
+
await assertKeyExporterIsAvailable();
|
|
918
|
+
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
|
|
919
|
+
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
920
|
+
}
|
|
921
|
+
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
922
|
+
const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
|
|
923
|
+
return base58EncodedAddress;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// ../instructions/dist/index.browser.js
|
|
927
|
+
init_env_shim();
|
|
928
|
+
var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
|
|
929
|
+
AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
|
|
930
|
+
3] = "WRITABLE_SIGNER";
|
|
931
|
+
AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
|
|
932
|
+
2] = "READONLY_SIGNER";
|
|
933
|
+
AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
|
|
934
|
+
1] = "WRITABLE";
|
|
935
|
+
AccountRole22[AccountRole22["READONLY"] = /* 0 */
|
|
936
|
+
0] = "READONLY";
|
|
937
|
+
return AccountRole22;
|
|
938
|
+
})(AccountRole || {});
|
|
939
|
+
var IS_SIGNER_BITMASK = 2;
|
|
940
|
+
var IS_WRITABLE_BITMASK = 1;
|
|
941
|
+
function downgradeRoleToNonSigner(role) {
|
|
942
|
+
return role & ~IS_SIGNER_BITMASK;
|
|
943
|
+
}
|
|
944
|
+
function downgradeRoleToReadonly(role) {
|
|
945
|
+
return role & ~IS_WRITABLE_BITMASK;
|
|
946
|
+
}
|
|
947
|
+
function isSignerRole(role) {
|
|
948
|
+
return role >= 2;
|
|
949
|
+
}
|
|
950
|
+
function isWritableRole(role) {
|
|
951
|
+
return (role & IS_WRITABLE_BITMASK) !== 0;
|
|
952
|
+
}
|
|
953
|
+
function mergeRoles(roleA, roleB) {
|
|
954
|
+
return roleA | roleB;
|
|
955
|
+
}
|
|
956
|
+
function upgradeRoleToSigner(role) {
|
|
957
|
+
return role | IS_SIGNER_BITMASK;
|
|
958
|
+
}
|
|
959
|
+
function upgradeRoleToWritable(role) {
|
|
960
|
+
return role | IS_WRITABLE_BITMASK;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// ../keys/dist/index.browser.js
|
|
964
|
+
init_env_shim();
|
|
783
965
|
async function generateKeyPair() {
|
|
784
966
|
await assertKeyGenerationIsAvailable();
|
|
785
967
|
const keyPair = await crypto.subtle.generateKey(
|
|
@@ -794,15 +976,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
794
976
|
);
|
|
795
977
|
return keyPair;
|
|
796
978
|
}
|
|
797
|
-
async function getBase58EncodedAddressFromPublicKey(publicKey) {
|
|
798
|
-
await assertKeyExporterIsAvailable();
|
|
799
|
-
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
|
|
800
|
-
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
801
|
-
}
|
|
802
|
-
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
803
|
-
const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
|
|
804
|
-
return base58EncodedAddress;
|
|
805
|
-
}
|
|
806
979
|
async function signBytes(key, data) {
|
|
807
980
|
await assertSigningCapabilityIsAvailable();
|
|
808
981
|
const signedData = await crypto.subtle.sign("Ed25519", key, data);
|
|
@@ -841,9 +1014,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
841
1014
|
if (numBytes !== 32) {
|
|
842
1015
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
843
1016
|
}
|
|
844
|
-
} catch (
|
|
1017
|
+
} catch (e3) {
|
|
845
1018
|
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
|
|
846
|
-
cause:
|
|
1019
|
+
cause: e3
|
|
847
1020
|
});
|
|
848
1021
|
}
|
|
849
1022
|
}
|
|
@@ -1311,7 +1484,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1311
1484
|
)
|
|
1312
1485
|
],
|
|
1313
1486
|
[
|
|
1314
|
-
"
|
|
1487
|
+
"accountIndices",
|
|
1315
1488
|
array(
|
|
1316
1489
|
u8({
|
|
1317
1490
|
description: "The index of an account, according to the well-ordered accounts list for this transaction"
|
|
@@ -1331,23 +1504,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1331
1504
|
]
|
|
1332
1505
|
]),
|
|
1333
1506
|
(value) => {
|
|
1334
|
-
if (value.
|
|
1507
|
+
if (value.accountIndices !== void 0 && value.data !== void 0) {
|
|
1335
1508
|
return value;
|
|
1336
1509
|
}
|
|
1337
1510
|
return {
|
|
1338
1511
|
...value,
|
|
1339
|
-
|
|
1512
|
+
accountIndices: value.accountIndices ?? [],
|
|
1340
1513
|
data: value.data ?? new Uint8Array(0)
|
|
1341
1514
|
};
|
|
1342
1515
|
},
|
|
1343
1516
|
(value) => {
|
|
1344
|
-
if (value.
|
|
1517
|
+
if (value.accountIndices.length && value.data.byteLength) {
|
|
1345
1518
|
return value;
|
|
1346
1519
|
}
|
|
1347
|
-
const {
|
|
1520
|
+
const { accountIndices, data, ...rest } = value;
|
|
1348
1521
|
return {
|
|
1349
1522
|
...rest,
|
|
1350
|
-
...
|
|
1523
|
+
...accountIndices.length ? { accountIndices } : null,
|
|
1351
1524
|
...data.byteLength ? { data } : null
|
|
1352
1525
|
};
|
|
1353
1526
|
}
|
|
@@ -1470,7 +1643,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1470
1643
|
async function signTransaction(keyPair, transaction) {
|
|
1471
1644
|
const compiledMessage = compileMessage(transaction);
|
|
1472
1645
|
const [signerPublicKey, signature] = await Promise.all([
|
|
1473
|
-
|
|
1646
|
+
getAddressFromPublicKey(keyPair.publicKey),
|
|
1474
1647
|
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1475
1648
|
]);
|
|
1476
1649
|
const nextSignatures = {
|
|
@@ -1563,85 +1736,150 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1563
1736
|
return visitNode(params, [], onIntegerOverflow);
|
|
1564
1737
|
}
|
|
1565
1738
|
var KEYPATH_WILDCARD = {};
|
|
1566
|
-
var
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
"
|
|
1598
|
-
"
|
|
1599
|
-
]
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1739
|
+
var memoizedKeypaths;
|
|
1740
|
+
function getAllowedNumericKeypaths() {
|
|
1741
|
+
if (!memoizedKeypaths) {
|
|
1742
|
+
const jsonParsedTokenAccountsConfigs = [
|
|
1743
|
+
// parsed Token/Token22 token account
|
|
1744
|
+
["data", "parsed", "info", "tokenAmount", "decimals"],
|
|
1745
|
+
["data", "parsed", "info", "tokenAmount", "uiAmount"],
|
|
1746
|
+
["data", "parsed", "info", "rentExemptReserve", "decimals"],
|
|
1747
|
+
["data", "parsed", "info", "rentExemptReserve", "uiAmount"],
|
|
1748
|
+
["data", "parsed", "info", "delegatedAmount", "decimals"],
|
|
1749
|
+
["data", "parsed", "info", "delegatedAmount", "uiAmount"],
|
|
1750
|
+
[
|
|
1751
|
+
"data",
|
|
1752
|
+
"parsed",
|
|
1753
|
+
"info",
|
|
1754
|
+
"extensions",
|
|
1755
|
+
KEYPATH_WILDCARD,
|
|
1756
|
+
"state",
|
|
1757
|
+
"olderTransferFee",
|
|
1758
|
+
"transferFeeBasisPoints"
|
|
1759
|
+
],
|
|
1760
|
+
[
|
|
1761
|
+
"data",
|
|
1762
|
+
"parsed",
|
|
1763
|
+
"info",
|
|
1764
|
+
"extensions",
|
|
1765
|
+
KEYPATH_WILDCARD,
|
|
1766
|
+
"state",
|
|
1767
|
+
"newerTransferFee",
|
|
1768
|
+
"transferFeeBasisPoints"
|
|
1769
|
+
],
|
|
1770
|
+
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
|
|
1771
|
+
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"]
|
|
1772
|
+
];
|
|
1773
|
+
const jsonParsedAccountsConfigs = [
|
|
1774
|
+
...jsonParsedTokenAccountsConfigs,
|
|
1775
|
+
// parsed AddressTableLookup account
|
|
1776
|
+
["data", "parsed", "info", "lastExtendedSlotStartIndex"],
|
|
1777
|
+
// parsed Config account
|
|
1778
|
+
["data", "parsed", "info", "slashPenalty"],
|
|
1779
|
+
["data", "parsed", "info", "warmupCooldownRate"],
|
|
1780
|
+
// parsed Token/Token22 mint account
|
|
1781
|
+
["data", "parsed", "info", "decimals"],
|
|
1782
|
+
// parsed Token/Token22 multisig account
|
|
1783
|
+
["data", "parsed", "info", "numRequiredSigners"],
|
|
1784
|
+
["data", "parsed", "info", "numValidSigners"],
|
|
1785
|
+
// parsed Stake account
|
|
1786
|
+
["data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
|
|
1787
|
+
// parsed Sysvar rent account
|
|
1788
|
+
["data", "parsed", "info", "exemptionThreshold"],
|
|
1789
|
+
["data", "parsed", "info", "burnPercent"],
|
|
1790
|
+
// parsed Vote account
|
|
1791
|
+
["data", "parsed", "info", "commission"],
|
|
1792
|
+
["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
|
|
1793
|
+
];
|
|
1794
|
+
memoizedKeypaths = {
|
|
1795
|
+
getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
|
|
1796
|
+
getBlockTime: [[]],
|
|
1797
|
+
getClusterNodes: [
|
|
1798
|
+
[KEYPATH_WILDCARD, "featureSet"],
|
|
1799
|
+
[KEYPATH_WILDCARD, "shredVersion"]
|
|
1800
|
+
],
|
|
1801
|
+
getInflationGovernor: [["initial"], ["foundation"], ["foundationTerm"], ["taper"], ["terminal"]],
|
|
1802
|
+
getInflationRate: [["foundation"], ["total"], ["validator"]],
|
|
1803
|
+
getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
|
|
1804
|
+
getMultipleAccounts: jsonParsedAccountsConfigs.map((c) => ["value", KEYPATH_WILDCARD, ...c]),
|
|
1805
|
+
getProgramAccounts: jsonParsedAccountsConfigs.flatMap((c) => [
|
|
1806
|
+
["value", KEYPATH_WILDCARD, "account", ...c],
|
|
1807
|
+
[KEYPATH_WILDCARD, "account", ...c]
|
|
1808
|
+
]),
|
|
1809
|
+
getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
|
|
1810
|
+
getTokenAccountBalance: [
|
|
1811
|
+
["value", "decimals"],
|
|
1812
|
+
["value", "uiAmount"]
|
|
1813
|
+
],
|
|
1814
|
+
getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map((c) => [
|
|
1815
|
+
"value",
|
|
1816
|
+
KEYPATH_WILDCARD,
|
|
1817
|
+
"account",
|
|
1818
|
+
...c
|
|
1819
|
+
]),
|
|
1820
|
+
getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map((c) => [
|
|
1821
|
+
"value",
|
|
1822
|
+
KEYPATH_WILDCARD,
|
|
1823
|
+
"account",
|
|
1824
|
+
...c
|
|
1825
|
+
]),
|
|
1826
|
+
getTokenLargestAccounts: [
|
|
1827
|
+
["value", KEYPATH_WILDCARD, "decimals"],
|
|
1828
|
+
["value", KEYPATH_WILDCARD, "uiAmount"]
|
|
1829
|
+
],
|
|
1830
|
+
getTokenSupply: [
|
|
1831
|
+
["value", "decimals"],
|
|
1832
|
+
["value", "uiAmount"]
|
|
1833
|
+
],
|
|
1834
|
+
getTransaction: [
|
|
1835
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
1836
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
1837
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
1838
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
1839
|
+
["meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
1840
|
+
["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
|
|
1841
|
+
["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
|
|
1842
|
+
[
|
|
1843
|
+
"meta",
|
|
1844
|
+
"innerInstructions",
|
|
1845
|
+
KEYPATH_WILDCARD,
|
|
1846
|
+
"instructions",
|
|
1847
|
+
KEYPATH_WILDCARD,
|
|
1848
|
+
"accounts",
|
|
1849
|
+
KEYPATH_WILDCARD
|
|
1850
|
+
],
|
|
1851
|
+
[
|
|
1852
|
+
"transaction",
|
|
1853
|
+
"message",
|
|
1854
|
+
"addressTableLookups",
|
|
1855
|
+
KEYPATH_WILDCARD,
|
|
1856
|
+
"writableIndexes",
|
|
1857
|
+
KEYPATH_WILDCARD
|
|
1858
|
+
],
|
|
1859
|
+
[
|
|
1860
|
+
"transaction",
|
|
1861
|
+
"message",
|
|
1862
|
+
"addressTableLookups",
|
|
1863
|
+
KEYPATH_WILDCARD,
|
|
1864
|
+
"readonlyIndexes",
|
|
1865
|
+
KEYPATH_WILDCARD
|
|
1866
|
+
],
|
|
1867
|
+
["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
|
|
1868
|
+
["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
|
|
1869
|
+
["transaction", "message", "header", "numReadonlySignedAccounts"],
|
|
1870
|
+
["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
|
|
1871
|
+
["transaction", "message", "header", "numRequiredSignatures"]
|
|
1872
|
+
],
|
|
1873
|
+
getVersion: [["feature-set"]],
|
|
1874
|
+
getVoteAccounts: [
|
|
1875
|
+
["current", KEYPATH_WILDCARD, "commission"],
|
|
1876
|
+
["delinquent", KEYPATH_WILDCARD, "commission"]
|
|
1877
|
+
],
|
|
1878
|
+
simulateTransaction: jsonParsedAccountsConfigs.map((c) => ["value", "accounts", KEYPATH_WILDCARD, ...c])
|
|
1879
|
+
};
|
|
1880
|
+
}
|
|
1881
|
+
return memoizedKeypaths;
|
|
1882
|
+
}
|
|
1645
1883
|
function getNextAllowedKeypaths(keyPaths, property) {
|
|
1646
1884
|
return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
|
|
1647
1885
|
}
|
|
@@ -1668,7 +1906,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1668
1906
|
}
|
|
1669
1907
|
}
|
|
1670
1908
|
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
|
|
1671
|
-
const allowedKeypaths = methodName ?
|
|
1909
|
+
const allowedKeypaths = methodName ? getAllowedNumericKeypaths()[methodName] : void 0;
|
|
1672
1910
|
return visitNode2(rawResponse, allowedKeypaths ?? []);
|
|
1673
1911
|
}
|
|
1674
1912
|
function createSolanaRpcApi(config) {
|
|
@@ -1945,14 +2183,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1945
2183
|
if (signal) {
|
|
1946
2184
|
const responsePromise = coalescedRequest.responsePromise;
|
|
1947
2185
|
return await new Promise((resolve, reject) => {
|
|
1948
|
-
const handleAbort = (
|
|
2186
|
+
const handleAbort = (e3) => {
|
|
1949
2187
|
signal.removeEventListener("abort", handleAbort);
|
|
1950
2188
|
coalescedRequest.numConsumers -= 1;
|
|
1951
2189
|
if (coalescedRequest.numConsumers === 0) {
|
|
1952
2190
|
const abortController = coalescedRequest.abortController;
|
|
1953
2191
|
abortController.abort();
|
|
1954
2192
|
}
|
|
1955
|
-
const abortError = new DOMException(
|
|
2193
|
+
const abortError = new DOMException(e3.target.reason, "AbortError");
|
|
1956
2194
|
reject(abortError);
|
|
1957
2195
|
};
|
|
1958
2196
|
signal.addEventListener("abort", handleAbort);
|
|
@@ -2013,10 +2251,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2013
2251
|
exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
|
|
2014
2252
|
exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
|
|
2015
2253
|
exports.generateKeyPair = generateKeyPair;
|
|
2254
|
+
exports.getAddressFromPublicKey = getAddressFromPublicKey;
|
|
2016
2255
|
exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
|
|
2017
2256
|
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
2018
|
-
exports.getBase58EncodedAddressFromPublicKey = getBase58EncodedAddressFromPublicKey;
|
|
2019
2257
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
2258
|
+
exports.getProgramDerivedAddress = getProgramDerivedAddress;
|
|
2020
2259
|
exports.isSignerRole = isSignerRole;
|
|
2021
2260
|
exports.isWritableRole = isWritableRole;
|
|
2022
2261
|
exports.mergeRoles = mergeRoles;
|