@solana/web3.js 1.53.0 → 1.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.iife.js CHANGED
@@ -11177,6 +11177,11 @@ var solanaWeb3 = (function (exports) {
11177
11177
  */
11178
11178
 
11179
11179
  const MAX_SEED_LENGTH = 32;
11180
+ /**
11181
+ * Size of public key in bytes
11182
+ */
11183
+
11184
+ const PUBLIC_KEY_LENGTH = 32;
11180
11185
  /**
11181
11186
  * Value to be converted into public key
11182
11187
  */
@@ -11207,7 +11212,7 @@ var solanaWeb3 = (function (exports) {
11207
11212
  // assume base 58 encoding by default
11208
11213
  const decoded = bs58$1.decode(value);
11209
11214
 
11210
- if (decoded.length != 32) {
11215
+ if (decoded.length != PUBLIC_KEY_LENGTH) {
11211
11216
  throw new Error(`Invalid public key input`);
11212
11217
  }
11213
11218
 
@@ -11260,7 +11265,7 @@ var solanaWeb3 = (function (exports) {
11260
11265
  toBuffer() {
11261
11266
  const b = this._bn.toArrayLike(buffer.Buffer);
11262
11267
 
11263
- if (b.length === 32) {
11268
+ if (b.length === PUBLIC_KEY_LENGTH) {
11264
11269
  return b;
11265
11270
  }
11266
11271
 
@@ -13771,6 +13776,7 @@ var solanaWeb3 = (function (exports) {
13771
13776
  * 8 bytes is the size of the fragment header
13772
13777
  */
13773
13778
  const PACKET_DATA_SIZE = 1280 - 40 - 8;
13779
+ const VERSION_PREFIX_MASK = 0x7f;
13774
13780
  const SIGNATURE_LENGTH_IN_BYTES = 64;
13775
13781
 
13776
13782
  class TransactionExpiredBlockheightExceededError extends Error {
@@ -13803,6 +13809,13 @@ var solanaWeb3 = (function (exports) {
13803
13809
  const publicKey = (property = 'publicKey') => {
13804
13810
  return blob(32, property);
13805
13811
  };
13812
+ /**
13813
+ * Layout for a signature
13814
+ */
13815
+
13816
+ const signature$2 = (property = 'signature') => {
13817
+ return blob(64, property);
13818
+ };
13806
13819
 
13807
13820
  /**
13808
13821
  * Layout for a Rust String type
@@ -13914,11 +13927,9 @@ var solanaWeb3 = (function (exports) {
13914
13927
  }
13915
13928
  }
13916
13929
 
13917
- const PUBKEY_LENGTH = 32;
13918
13930
  /**
13919
13931
  * List of instructions to be processed atomically
13920
13932
  */
13921
-
13922
13933
  class Message {
13923
13934
  constructor(args) {
13924
13935
  this.header = void 0;
@@ -13933,6 +13944,26 @@ var solanaWeb3 = (function (exports) {
13933
13944
  this.instructions.forEach(ix => this.indexToProgramIds.set(ix.programIdIndex, this.accountKeys[ix.programIdIndex]));
13934
13945
  }
13935
13946
 
13947
+ get version() {
13948
+ return 'legacy';
13949
+ }
13950
+
13951
+ get staticAccountKeys() {
13952
+ return this.accountKeys;
13953
+ }
13954
+
13955
+ get compiledInstructions() {
13956
+ return this.instructions.map(ix => ({
13957
+ programIdIndex: ix.programIdIndex,
13958
+ accountKeyIndexes: ix.accounts,
13959
+ data: bs58$1.decode(ix.data)
13960
+ }));
13961
+ }
13962
+
13963
+ get addressTableLookups() {
13964
+ return [];
13965
+ }
13966
+
13936
13967
  isAccountSigner(index) {
13937
13968
  return index < this.header.numRequiredSignatures;
13938
13969
  }
@@ -14009,19 +14040,24 @@ var solanaWeb3 = (function (exports) {
14009
14040
  // Slice up wire data
14010
14041
  let byteArray = [...buffer$1];
14011
14042
  const numRequiredSignatures = byteArray.shift();
14043
+
14044
+ if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
14045
+ throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
14046
+ }
14047
+
14012
14048
  const numReadonlySignedAccounts = byteArray.shift();
14013
14049
  const numReadonlyUnsignedAccounts = byteArray.shift();
14014
14050
  const accountCount = decodeLength(byteArray);
14015
14051
  let accountKeys = [];
14016
14052
 
14017
14053
  for (let i = 0; i < accountCount; i++) {
14018
- const account = byteArray.slice(0, PUBKEY_LENGTH);
14019
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14054
+ const account = byteArray.slice(0, PUBLIC_KEY_LENGTH);
14055
+ byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
14020
14056
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
14021
14057
  }
14022
14058
 
14023
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
14024
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14059
+ const recentBlockhash = byteArray.slice(0, PUBLIC_KEY_LENGTH);
14060
+ byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
14025
14061
  const instructionCount = decodeLength(byteArray);
14026
14062
  let instructions = [];
14027
14063
 
@@ -14062,6 +14098,182 @@ var solanaWeb3 = (function (exports) {
14062
14098
  }
14063
14099
  }
14064
14100
 
14101
+ /**
14102
+ * Message constructor arguments
14103
+ */
14104
+
14105
+ class MessageV0 {
14106
+ constructor(args) {
14107
+ this.header = void 0;
14108
+ this.staticAccountKeys = void 0;
14109
+ this.recentBlockhash = void 0;
14110
+ this.compiledInstructions = void 0;
14111
+ this.addressTableLookups = void 0;
14112
+ this.header = args.header;
14113
+ this.staticAccountKeys = args.staticAccountKeys;
14114
+ this.recentBlockhash = args.recentBlockhash;
14115
+ this.compiledInstructions = args.compiledInstructions;
14116
+ this.addressTableLookups = args.addressTableLookups;
14117
+ }
14118
+
14119
+ get version() {
14120
+ return 0;
14121
+ }
14122
+
14123
+ serialize() {
14124
+ const encodedStaticAccountKeysLength = Array();
14125
+ encodeLength(encodedStaticAccountKeysLength, this.staticAccountKeys.length);
14126
+ const serializedInstructions = this.serializeInstructions();
14127
+ const encodedInstructionsLength = Array();
14128
+ encodeLength(encodedInstructionsLength, this.compiledInstructions.length);
14129
+ const serializedAddressTableLookups = this.serializeAddressTableLookups();
14130
+ const encodedAddressTableLookupsLength = Array();
14131
+ encodeLength(encodedAddressTableLookupsLength, this.addressTableLookups.length);
14132
+ const messageLayout = struct([u8('prefix'), struct([u8('numRequiredSignatures'), u8('numReadonlySignedAccounts'), u8('numReadonlyUnsignedAccounts')], 'header'), blob(encodedStaticAccountKeysLength.length, 'staticAccountKeysLength'), seq(publicKey(), this.staticAccountKeys.length, 'staticAccountKeys'), publicKey('recentBlockhash'), blob(encodedInstructionsLength.length, 'instructionsLength'), blob(serializedInstructions.length, 'serializedInstructions'), blob(encodedAddressTableLookupsLength.length, 'addressTableLookupsLength'), blob(serializedAddressTableLookups.length, 'serializedAddressTableLookups')]);
14133
+ const serializedMessage = new Uint8Array(PACKET_DATA_SIZE);
14134
+ const MESSAGE_VERSION_0_PREFIX = 1 << 7;
14135
+ const serializedMessageLength = messageLayout.encode({
14136
+ prefix: MESSAGE_VERSION_0_PREFIX,
14137
+ header: this.header,
14138
+ staticAccountKeysLength: new Uint8Array(encodedStaticAccountKeysLength),
14139
+ staticAccountKeys: this.staticAccountKeys.map(key => key.toBytes()),
14140
+ recentBlockhash: bs58$1.decode(this.recentBlockhash),
14141
+ instructionsLength: new Uint8Array(encodedInstructionsLength),
14142
+ serializedInstructions,
14143
+ addressTableLookupsLength: new Uint8Array(encodedAddressTableLookupsLength),
14144
+ serializedAddressTableLookups
14145
+ }, serializedMessage);
14146
+ return serializedMessage.slice(0, serializedMessageLength);
14147
+ }
14148
+
14149
+ serializeInstructions() {
14150
+ let serializedLength = 0;
14151
+ const serializedInstructions = new Uint8Array(PACKET_DATA_SIZE);
14152
+
14153
+ for (const instruction of this.compiledInstructions) {
14154
+ const encodedAccountKeyIndexesLength = Array();
14155
+ encodeLength(encodedAccountKeyIndexesLength, instruction.accountKeyIndexes.length);
14156
+ const encodedDataLength = Array();
14157
+ encodeLength(encodedDataLength, instruction.data.length);
14158
+ const instructionLayout = struct([u8('programIdIndex'), blob(encodedAccountKeyIndexesLength.length, 'encodedAccountKeyIndexesLength'), seq(u8(), instruction.accountKeyIndexes.length, 'accountKeyIndexes'), blob(encodedDataLength.length, 'encodedDataLength'), blob(instruction.data.length, 'data')]);
14159
+ serializedLength += instructionLayout.encode({
14160
+ programIdIndex: instruction.programIdIndex,
14161
+ encodedAccountKeyIndexesLength: new Uint8Array(encodedAccountKeyIndexesLength),
14162
+ accountKeyIndexes: instruction.accountKeyIndexes,
14163
+ encodedDataLength: new Uint8Array(encodedDataLength),
14164
+ data: instruction.data
14165
+ }, serializedInstructions, serializedLength);
14166
+ }
14167
+
14168
+ return serializedInstructions.slice(0, serializedLength);
14169
+ }
14170
+
14171
+ serializeAddressTableLookups() {
14172
+ let serializedLength = 0;
14173
+ const serializedAddressTableLookups = new Uint8Array(PACKET_DATA_SIZE);
14174
+
14175
+ for (const lookup of this.addressTableLookups) {
14176
+ const encodedWritableIndexesLength = Array();
14177
+ encodeLength(encodedWritableIndexesLength, lookup.writableIndexes.length);
14178
+ const encodedReadonlyIndexesLength = Array();
14179
+ encodeLength(encodedReadonlyIndexesLength, lookup.readonlyIndexes.length);
14180
+ const addressTableLookupLayout = struct([publicKey('accountKey'), blob(encodedWritableIndexesLength.length, 'encodedWritableIndexesLength'), seq(u8(), lookup.writableIndexes.length, 'writableIndexes'), blob(encodedReadonlyIndexesLength.length, 'encodedReadonlyIndexesLength'), seq(u8(), lookup.readonlyIndexes.length, 'readonlyIndexes')]);
14181
+ serializedLength += addressTableLookupLayout.encode({
14182
+ accountKey: lookup.accountKey.toBytes(),
14183
+ encodedWritableIndexesLength: new Uint8Array(encodedWritableIndexesLength),
14184
+ writableIndexes: lookup.writableIndexes,
14185
+ encodedReadonlyIndexesLength: new Uint8Array(encodedReadonlyIndexesLength),
14186
+ readonlyIndexes: lookup.readonlyIndexes
14187
+ }, serializedAddressTableLookups, serializedLength);
14188
+ }
14189
+
14190
+ return serializedAddressTableLookups.slice(0, serializedLength);
14191
+ }
14192
+
14193
+ static deserialize(serializedMessage) {
14194
+ let byteArray = [...serializedMessage];
14195
+ const prefix = byteArray.shift();
14196
+ const maskedPrefix = prefix & VERSION_PREFIX_MASK;
14197
+ assert$c(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
14198
+ const version = maskedPrefix;
14199
+ assert$c(version === 0, `Expected versioned message with version 0 but found version ${version}`);
14200
+ const header = {
14201
+ numRequiredSignatures: byteArray.shift(),
14202
+ numReadonlySignedAccounts: byteArray.shift(),
14203
+ numReadonlyUnsignedAccounts: byteArray.shift()
14204
+ };
14205
+ const staticAccountKeys = [];
14206
+ const staticAccountKeysLength = decodeLength(byteArray);
14207
+
14208
+ for (let i = 0; i < staticAccountKeysLength; i++) {
14209
+ staticAccountKeys.push(new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH)));
14210
+ }
14211
+
14212
+ const recentBlockhash = bs58$1.encode(byteArray.splice(0, PUBLIC_KEY_LENGTH));
14213
+ const instructionCount = decodeLength(byteArray);
14214
+ const compiledInstructions = [];
14215
+
14216
+ for (let i = 0; i < instructionCount; i++) {
14217
+ const programIdIndex = byteArray.shift();
14218
+ const accountKeyIndexesLength = decodeLength(byteArray);
14219
+ const accountKeyIndexes = byteArray.splice(0, accountKeyIndexesLength);
14220
+ const dataLength = decodeLength(byteArray);
14221
+ const data = new Uint8Array(byteArray.splice(0, dataLength));
14222
+ compiledInstructions.push({
14223
+ programIdIndex,
14224
+ accountKeyIndexes,
14225
+ data
14226
+ });
14227
+ }
14228
+
14229
+ const addressTableLookupsCount = decodeLength(byteArray);
14230
+ const addressTableLookups = [];
14231
+
14232
+ for (let i = 0; i < addressTableLookupsCount; i++) {
14233
+ const accountKey = new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH));
14234
+ const writableIndexesLength = decodeLength(byteArray);
14235
+ const writableIndexes = byteArray.splice(0, writableIndexesLength);
14236
+ const readonlyIndexesLength = decodeLength(byteArray);
14237
+ const readonlyIndexes = byteArray.splice(0, readonlyIndexesLength);
14238
+ addressTableLookups.push({
14239
+ accountKey,
14240
+ writableIndexes,
14241
+ readonlyIndexes
14242
+ });
14243
+ }
14244
+
14245
+ return new MessageV0({
14246
+ header,
14247
+ staticAccountKeys,
14248
+ recentBlockhash,
14249
+ compiledInstructions,
14250
+ addressTableLookups
14251
+ });
14252
+ }
14253
+
14254
+ }
14255
+
14256
+ // eslint-disable-next-line no-redeclare
14257
+ const VersionedMessage = {
14258
+ deserialize: serializedMessage => {
14259
+ const prefix = serializedMessage[0];
14260
+ const maskedPrefix = prefix & VERSION_PREFIX_MASK; // if the highest bit of the prefix is not set, the message is not versioned
14261
+
14262
+ if (maskedPrefix === prefix) {
14263
+ return Message.from(serializedMessage);
14264
+ } // the lower 7 bits of the prefix indicate the message version
14265
+
14266
+
14267
+ const version = maskedPrefix;
14268
+
14269
+ if (version === 0) {
14270
+ return MessageV0.deserialize(serializedMessage);
14271
+ } else {
14272
+ throw new Error(`Transaction message version ${version} deserialization is not supported`);
14273
+ }
14274
+ }
14275
+ };
14276
+
14065
14277
  exports.TransactionStatus = void 0;
14066
14278
  /**
14067
14279
  * Default (empty) signature
@@ -14790,6 +15002,70 @@ var solanaWeb3 = (function (exports) {
14790
15002
 
14791
15003
  }
14792
15004
 
15005
+ /**
15006
+ * Versioned transaction class
15007
+ */
15008
+ class VersionedTransaction {
15009
+ constructor(message, signatures) {
15010
+ this.signatures = void 0;
15011
+ this.message = void 0;
15012
+
15013
+ if (signatures !== undefined) {
15014
+ assert$c(signatures.length === message.header.numRequiredSignatures, 'Expected signatures length to be equal to the number of required signatures');
15015
+ this.signatures = signatures;
15016
+ } else {
15017
+ const defaultSignatures = [];
15018
+
15019
+ for (let i = 0; i < message.header.numRequiredSignatures; i++) {
15020
+ defaultSignatures.push(new Uint8Array(SIGNATURE_LENGTH_IN_BYTES));
15021
+ }
15022
+
15023
+ this.signatures = defaultSignatures;
15024
+ }
15025
+
15026
+ this.message = message;
15027
+ }
15028
+
15029
+ serialize() {
15030
+ const serializedMessage = this.message.serialize();
15031
+ const encodedSignaturesLength = Array();
15032
+ encodeLength(encodedSignaturesLength, this.signatures.length);
15033
+ const transactionLayout = struct([blob(encodedSignaturesLength.length, 'encodedSignaturesLength'), seq(signature$2(), this.signatures.length, 'signatures'), blob(serializedMessage.length, 'serializedMessage')]);
15034
+ const serializedTransaction = new Uint8Array(2048);
15035
+ const serializedTransactionLength = transactionLayout.encode({
15036
+ encodedSignaturesLength: new Uint8Array(encodedSignaturesLength),
15037
+ signatures: this.signatures,
15038
+ serializedMessage
15039
+ }, serializedTransaction);
15040
+ return serializedTransaction.slice(0, serializedTransactionLength);
15041
+ }
15042
+
15043
+ static deserialize(serializedTransaction) {
15044
+ let byteArray = [...serializedTransaction];
15045
+ const signatures = [];
15046
+ const signaturesLength = decodeLength(byteArray);
15047
+
15048
+ for (let i = 0; i < signaturesLength; i++) {
15049
+ signatures.push(new Uint8Array(byteArray.splice(0, SIGNATURE_LENGTH_IN_BYTES)));
15050
+ }
15051
+
15052
+ const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
15053
+ return new VersionedTransaction(message, signatures);
15054
+ }
15055
+
15056
+ sign(signers) {
15057
+ const messageData = this.message.serialize();
15058
+ const signerPubkeys = this.message.staticAccountKeys.slice(0, this.message.header.numRequiredSignatures);
15059
+
15060
+ for (const signer of signers) {
15061
+ const signerIndex = signerPubkeys.findIndex(pubkey => pubkey.equals(signer.publicKey));
15062
+ assert$c(signerIndex >= 0, `Cannot sign with non signer key ${signer.publicKey.toBase58()}`);
15063
+ this.signatures[signerIndex] = nacl.sign.detached(messageData, signer.secretKey);
15064
+ }
15065
+ }
15066
+
15067
+ }
15068
+
14793
15069
  const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
14794
15070
  const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
14795
15071
  const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
@@ -18484,7 +18760,7 @@ var solanaWeb3 = (function (exports) {
18484
18760
  }
18485
18761
 
18486
18762
  var DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
18487
- var URL$1 = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
18763
+ var URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
18488
18764
  function v35 (name, version, hashfunc) {
18489
18765
  function generateUUID(value, namespace, buf, offset) {
18490
18766
  if (typeof value === 'string') {
@@ -18529,7 +18805,7 @@ var solanaWeb3 = (function (exports) {
18529
18805
 
18530
18806
 
18531
18807
  generateUUID.DNS = DNS;
18532
- generateUUID.URL = URL$1;
18808
+ generateUUID.URL = URL;
18533
18809
  return generateUUID;
18534
18810
  }
18535
18811
 
@@ -19348,24 +19624,26 @@ var solanaWeb3 = (function (exports) {
19348
19624
  seq(publicKey(), offset(u8(), -1), 'authority')])
19349
19625
  };
19350
19626
 
19351
- const URL = globalThis.URL;
19352
-
19627
+ const URL_RE = /^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;
19353
19628
  function makeWebsocketUrl(endpoint) {
19354
- let url = new URL(endpoint);
19355
- const useHttps = url.protocol === 'https:';
19356
- url.protocol = useHttps ? 'wss:' : 'ws:';
19357
- url.host = ''; // Only shift the port by +1 as a convention for ws(s) only if given endpoint
19629
+ const matches = endpoint.match(URL_RE);
19630
+
19631
+ if (matches == null) {
19632
+ throw TypeError(`Failed to validate endpoint URL \`${endpoint}\``);
19633
+ }
19634
+
19635
+ const [_, // eslint-disable-line @typescript-eslint/no-unused-vars
19636
+ hostish, portWithColon, rest] = matches;
19637
+ const protocol = endpoint.startsWith('https:') ? 'wss:' : 'ws:';
19638
+ const startPort = portWithColon == null ? null : parseInt(portWithColon.slice(1), 10);
19639
+ const websocketPort = // Only shift the port by +1 as a convention for ws(s) only if given endpoint
19358
19640
  // is explictly specifying the endpoint port (HTTP-based RPC), assuming
19359
19641
  // we're directly trying to connect to solana-validator's ws listening port.
19360
19642
  // When the endpoint omits the port, we're connecting to the protocol
19361
19643
  // default ports: http(80) or https(443) and it's assumed we're behind a reverse
19362
19644
  // proxy which manages WebSocket upgrade and backend port redirection.
19363
-
19364
- if (url.port !== '') {
19365
- url.port = String(Number(url.port) + 1);
19366
- }
19367
-
19368
- return url.toString();
19645
+ startPort == null ? '' : `:${startPort + 1}`;
19646
+ return `${protocol}//${hostish}${websocketPort}${rest}`;
19369
19647
  }
19370
19648
 
19371
19649
  var _process$env$npm_pack;
@@ -19385,7 +19663,17 @@ var solanaWeb3 = (function (exports) {
19385
19663
  * https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d
19386
19664
  */
19387
19665
 
19666
+ /* @internal */
19667
+ function assertEndpointUrl(putativeUrl) {
19668
+ if (/^https?:/.test(putativeUrl) === false) {
19669
+ throw new TypeError('Endpoint URL must start with `http:` or `https:`.');
19670
+ }
19671
+
19672
+ return putativeUrl;
19673
+ }
19388
19674
  /** @internal */
19675
+
19676
+
19389
19677
  function extractCommitmentFromConfig(commitmentOrConfig) {
19390
19678
  let commitment;
19391
19679
  let config;
@@ -19580,7 +19868,7 @@ var solanaWeb3 = (function (exports) {
19580
19868
  * A performance sample
19581
19869
  */
19582
19870
 
19583
- function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
19871
+ function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
19584
19872
  const fetch = customFetch ? customFetch : fetchImpl;
19585
19873
 
19586
19874
  let fetchWithMiddleware;
@@ -20386,8 +20674,6 @@ var solanaWeb3 = (function (exports) {
20386
20674
  this._subscriptionCallbacksByServerSubscriptionId = {};
20387
20675
  this._subscriptionsByHash = {};
20388
20676
  this._subscriptionsAutoDisposedByRpc = new Set();
20389
- let url = new URL(endpoint);
20390
- const useHttps = url.protocol === 'https:';
20391
20677
  let wsEndpoint;
20392
20678
  let httpHeaders;
20393
20679
  let fetch;
@@ -20406,9 +20692,9 @@ var solanaWeb3 = (function (exports) {
20406
20692
  disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
20407
20693
  }
20408
20694
 
20409
- this._rpcEndpoint = endpoint;
20695
+ this._rpcEndpoint = assertEndpointUrl(endpoint);
20410
20696
  this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
20411
- this._rpcClient = createRpcClient(url.toString(), useHttps, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit);
20697
+ this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit);
20412
20698
  this._rpcRequest = createRpcRequest(this._rpcClient);
20413
20699
  this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
20414
20700
  this._rpcWebSocket = new Client_1(this._rpcWsEndpoint, {
@@ -30542,6 +30828,23 @@ var solanaWeb3 = (function (exports) {
30542
30828
  data
30543
30829
  });
30544
30830
  }
30831
+ /**
30832
+ * Generate a transaction to withdraw safely from a Vote account.
30833
+ *
30834
+ * This function was created as a safeguard for vote accounts running validators, `safeWithdraw`
30835
+ * checks that the withdraw amount will not exceed the specified balance while leaving enough left
30836
+ * to cover rent. If you wish to close the vote account by withdrawing the full amount, call the
30837
+ * `withdraw` method directly.
30838
+ */
30839
+
30840
+
30841
+ static safeWithdraw(params, currentVoteAccountBalance, rentExemptMinimum) {
30842
+ if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {
30843
+ throw new Error('Withdraw will leave vote account with insuffcient funds.');
30844
+ }
30845
+
30846
+ return VoteProgram.withdraw(params);
30847
+ }
30545
30848
 
30546
30849
  }
30547
30850
  VoteProgram.programId = new PublicKey('Vote111111111111111111111111111111111111111');
@@ -30593,15 +30896,14 @@ var solanaWeb3 = (function (exports) {
30593
30896
 
30594
30897
 
30595
30898
  static fromConfigData(buffer$1) {
30596
- const PUBKEY_LENGTH = 32;
30597
30899
  let byteArray = [...buffer$1];
30598
30900
  const configKeyCount = decodeLength(byteArray);
30599
30901
  if (configKeyCount !== 2) return null;
30600
30902
  const configKeys = [];
30601
30903
 
30602
30904
  for (let i = 0; i < 2; i++) {
30603
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
30604
- byteArray = byteArray.slice(PUBKEY_LENGTH);
30905
+ const publicKey = new PublicKey(byteArray.slice(0, PUBLIC_KEY_LENGTH));
30906
+ byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
30605
30907
  const isSigner = byteArray.slice(0, 1)[0] === 1;
30606
30908
  byteArray = byteArray.slice(1);
30607
30909
  configKeys.push({
@@ -30837,9 +31139,11 @@ var solanaWeb3 = (function (exports) {
30837
31139
  exports.Lockup = Lockup;
30838
31140
  exports.MAX_SEED_LENGTH = MAX_SEED_LENGTH;
30839
31141
  exports.Message = Message;
31142
+ exports.MessageV0 = MessageV0;
30840
31143
  exports.NONCE_ACCOUNT_LENGTH = NONCE_ACCOUNT_LENGTH;
30841
31144
  exports.NonceAccount = NonceAccount;
30842
31145
  exports.PACKET_DATA_SIZE = PACKET_DATA_SIZE;
31146
+ exports.PUBLIC_KEY_LENGTH = PUBLIC_KEY_LENGTH;
30843
31147
  exports.PublicKey = PublicKey;
30844
31148
  exports.SIGNATURE_LENGTH_IN_BYTES = SIGNATURE_LENGTH_IN_BYTES;
30845
31149
  exports.SOLANA_SCHEMA = SOLANA_SCHEMA;
@@ -30870,8 +31174,11 @@ var solanaWeb3 = (function (exports) {
30870
31174
  exports.TransactionExpiredTimeoutError = TransactionExpiredTimeoutError;
30871
31175
  exports.TransactionInstruction = TransactionInstruction;
30872
31176
  exports.VALIDATOR_INFO_KEY = VALIDATOR_INFO_KEY;
31177
+ exports.VERSION_PREFIX_MASK = VERSION_PREFIX_MASK;
30873
31178
  exports.VOTE_PROGRAM_ID = VOTE_PROGRAM_ID;
30874
31179
  exports.ValidatorInfo = ValidatorInfo;
31180
+ exports.VersionedMessage = VersionedMessage;
31181
+ exports.VersionedTransaction = VersionedTransaction;
30875
31182
  exports.VoteAccount = VoteAccount;
30876
31183
  exports.VoteAuthorizationLayout = VoteAuthorizationLayout;
30877
31184
  exports.VoteInit = VoteInit;