@solana/web3.js 1.59.0 → 1.61.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/README.md CHANGED
@@ -87,6 +87,24 @@ console.log(solanaWeb3);
87
87
  console.log(solanaWeb3);
88
88
  ```
89
89
 
90
+ ## Compatibility
91
+
92
+ This library requires a JavaScript runtime that supports [`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) and the [exponentiation operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation). Both are supported in the following runtimes:
93
+
94
+ - Browsers, by [release date](https://caniuse.com/bigint):
95
+ - Chrome: May 2018
96
+ - Firefox: July 2019
97
+ - Safari: September 2020
98
+ - Mobile Safari: September 2020
99
+ - Edge: January 2020
100
+ - Opera: June 2018
101
+ - Samsung Internet: April 2019
102
+ - Runtimes, [by version](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt):
103
+ - Deno: >=1.0
104
+ - Node: >=10.4.0
105
+ - React Native:
106
+ - \>=0.7.0 using the [Hermes](https://reactnative.dev/blog/2022/07/08/hermes-as-the-default) engine ([integration guide](https://solanacookbook.com/integrations/react-native.html#how-to-use-solana-web3-js-in-a-react-native-app)):
107
+
90
108
  ## Flow Support (Discontinued)
91
109
 
92
110
  Flow types are no longer supported in new releases. The last release with Flow support is v1.37.2 and its
@@ -1972,10 +1972,10 @@ class Transaction {
1972
1972
 
1973
1973
  class TransactionMessage {
1974
1974
  constructor(args) {
1975
- this.accountKeys = void 0;
1975
+ this.payerKey = void 0;
1976
1976
  this.instructions = void 0;
1977
1977
  this.recentBlockhash = void 0;
1978
- this.accountKeys = args.accountKeys;
1978
+ this.payerKey = args.payerKey;
1979
1979
  this.instructions = args.instructions;
1980
1980
  this.recentBlockhash = args.recentBlockhash;
1981
1981
  }
@@ -1996,6 +1996,12 @@ class TransactionMessage {
1996
1996
  const numWritableUnsignedAccounts = message.staticAccountKeys.length - numReadonlyUnsignedAccounts;
1997
1997
  assert(numWritableUnsignedAccounts >= 0, 'Message header is invalid');
1998
1998
  const accountKeys = message.getAccountKeys(args);
1999
+ const payerKey = accountKeys.get(0);
2000
+
2001
+ if (payerKey === undefined) {
2002
+ throw new Error('Failed to decompile message because no account keys were found');
2003
+ }
2004
+
1999
2005
  const instructions = [];
2000
2006
 
2001
2007
  for (const compiledIx of compiledInstructions) {
@@ -2041,35 +2047,23 @@ class TransactionMessage {
2041
2047
  }
2042
2048
 
2043
2049
  return new TransactionMessage({
2044
- accountKeys,
2050
+ payerKey,
2045
2051
  instructions,
2046
2052
  recentBlockhash
2047
2053
  });
2048
2054
  }
2049
2055
 
2050
2056
  compileToLegacyMessage() {
2051
- const payerKey = this.accountKeys.get(0);
2052
-
2053
- if (payerKey === undefined) {
2054
- throw new Error('Failed to compile message because no account keys were found');
2055
- }
2056
-
2057
2057
  return Message.compile({
2058
- payerKey,
2058
+ payerKey: this.payerKey,
2059
2059
  recentBlockhash: this.recentBlockhash,
2060
2060
  instructions: this.instructions
2061
2061
  });
2062
2062
  }
2063
2063
 
2064
2064
  compileToV0Message(addressLookupTableAccounts) {
2065
- const payerKey = this.accountKeys.get(0);
2066
-
2067
- if (payerKey === undefined) {
2068
- throw new Error('Failed to compile message because no account keys were found');
2069
- }
2070
-
2071
2065
  return MessageV0.compile({
2072
- payerKey,
2066
+ payerKey: this.payerKey,
2073
2067
  recentBlockhash: this.recentBlockhash,
2074
2068
  instructions: this.instructions,
2075
2069
  addressLookupTableAccounts
@@ -2082,6 +2076,10 @@ class TransactionMessage {
2082
2076
  * Versioned transaction class
2083
2077
  */
2084
2078
  class VersionedTransaction {
2079
+ get version() {
2080
+ return this.message.version;
2081
+ }
2082
+
2085
2083
  constructor(message, signatures) {
2086
2084
  this.signatures = void 0;
2087
2085
  this.message = void 0;
@@ -4305,7 +4303,8 @@ const ParsedConfirmedTransactionResult = superstruct.type({
4305
4303
  accountKeys: superstruct.array(superstruct.type({
4306
4304
  pubkey: PublicKeyFromString,
4307
4305
  signer: superstruct.boolean(),
4308
- writable: superstruct.boolean()
4306
+ writable: superstruct.boolean(),
4307
+ source: superstruct.optional(superstruct.union([superstruct.literal('transaction'), superstruct.literal('lookupTable')]))
4309
4308
  })),
4310
4309
  instructions: superstruct.array(ParsedOrRawInstruction),
4311
4310
  recentBlockhash: superstruct.string(),
@@ -6533,7 +6532,7 @@ class Connection {
6533
6532
  */
6534
6533
  // eslint-disable-next-line no-dupe-class-members
6535
6534
  async sendTransaction(transaction, signersOrOptions, options) {
6536
- if ('message' in transaction) {
6535
+ if ('version' in transaction) {
6537
6536
  if (signersOrOptions && Array.isArray(signersOrOptions)) {
6538
6537
  throw new Error('Invalid arguments');
6539
6538
  }
@@ -7481,7 +7480,7 @@ class Keypair {
7481
7480
 
7482
7481
 
7483
7482
  get secretKey() {
7484
- return this._keypair.secretKey;
7483
+ return new Uint8Array(this._keypair.secretKey);
7485
7484
  }
7486
7485
 
7487
7486
  }
@@ -7896,6 +7895,9 @@ class ComputeBudgetProgram {
7896
7895
  */
7897
7896
 
7898
7897
 
7898
+ /**
7899
+ * @deprecated Instead, call {@link setComputeUnitLimit} and/or {@link setComputeUnitPrice}
7900
+ */
7899
7901
  static requestUnits(params) {
7900
7902
  const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits;
7901
7903
  const data = encodeData(type, params);