@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.59.0",
3
+ "version": "1.61.0",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
package/src/connection.ts CHANGED
@@ -1029,6 +1029,8 @@ export type ParsedMessageAccount = {
1029
1029
  signer: boolean;
1030
1030
  /** Indicates if the account is writable for this transaction */
1031
1031
  writable: boolean;
1032
+ /** Indicates if the account key came from the transaction or a lookup table */
1033
+ source?: 'transaction' | 'lookupTable';
1032
1034
  };
1033
1035
 
1034
1036
  /**
@@ -1966,6 +1968,9 @@ const ParsedConfirmedTransactionResult = pick({
1966
1968
  pubkey: PublicKeyFromString,
1967
1969
  signer: boolean(),
1968
1970
  writable: boolean(),
1971
+ source: optional(
1972
+ union([literal('transaction'), literal('lookupTable')]),
1973
+ ),
1969
1974
  }),
1970
1975
  ),
1971
1976
  instructions: array(ParsedOrRawInstruction),
@@ -4827,7 +4832,7 @@ export class Connection {
4827
4832
  signersOrOptions?: Array<Signer> | SendOptions,
4828
4833
  options?: SendOptions,
4829
4834
  ): Promise<TransactionSignature> {
4830
- if ('message' in transaction) {
4835
+ if ('version' in transaction) {
4831
4836
  if (signersOrOptions && Array.isArray(signersOrOptions)) {
4832
4837
  throw new Error('Invalid arguments');
4833
4838
  }
package/src/keypair.ts CHANGED
@@ -88,6 +88,6 @@ export class Keypair {
88
88
  * The raw secret key for this keypair
89
89
  */
90
90
  get secretKey(): Uint8Array {
91
- return this._keypair.secretKey;
91
+ return new Uint8Array(this._keypair.secretKey);
92
92
  }
93
93
  }
@@ -228,6 +228,9 @@ export class ComputeBudgetProgram {
228
228
  'ComputeBudget111111111111111111111111111111',
229
229
  );
230
230
 
231
+ /**
232
+ * @deprecated Instead, call {@link setComputeUnitLimit} and/or {@link setComputeUnitPrice}
233
+ */
231
234
  static requestUnits(params: RequestUnitsParams): TransactionInstruction {
232
235
  const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits;
233
236
  const data = encodeData(type, params);
@@ -1,16 +1,14 @@
1
- import {
2
- AccountKeysFromLookups,
3
- MessageAccountKeys,
4
- } from '../message/account-keys';
1
+ import {AccountKeysFromLookups} from '../message/account-keys';
5
2
  import assert from '../utils/assert';
6
3
  import {toBuffer} from '../utils/to-buffer';
7
4
  import {Blockhash} from '../blockhash';
8
5
  import {Message, MessageV0, VersionedMessage} from '../message';
6
+ import {PublicKey} from '../publickey';
9
7
  import {AddressLookupTableAccount} from '../programs';
10
8
  import {AccountMeta, TransactionInstruction} from './legacy';
11
9
 
12
10
  export type TransactionMessageArgs = {
13
- accountKeys: MessageAccountKeys;
11
+ payerKey: PublicKey;
14
12
  instructions: Array<TransactionInstruction>;
15
13
  recentBlockhash: Blockhash;
16
14
  };
@@ -24,12 +22,12 @@ export type DecompileArgs =
24
22
  };
25
23
 
26
24
  export class TransactionMessage {
27
- accountKeys: MessageAccountKeys;
25
+ payerKey: PublicKey;
28
26
  instructions: Array<TransactionInstruction>;
29
27
  recentBlockhash: Blockhash;
30
28
 
31
29
  constructor(args: TransactionMessageArgs) {
32
- this.accountKeys = args.accountKeys;
30
+ this.payerKey = args.payerKey;
33
31
  this.instructions = args.instructions;
34
32
  this.recentBlockhash = args.recentBlockhash;
35
33
  }
@@ -55,6 +53,13 @@ export class TransactionMessage {
55
53
  assert(numWritableUnsignedAccounts >= 0, 'Message header is invalid');
56
54
 
57
55
  const accountKeys = message.getAccountKeys(args);
56
+ const payerKey = accountKeys.get(0);
57
+ if (payerKey === undefined) {
58
+ throw new Error(
59
+ 'Failed to decompile message because no account keys were found',
60
+ );
61
+ }
62
+
58
63
  const instructions: TransactionInstruction[] = [];
59
64
  for (const compiledIx of compiledInstructions) {
60
65
  const keys: AccountMeta[] = [];
@@ -106,22 +111,15 @@ export class TransactionMessage {
106
111
  }
107
112
 
108
113
  return new TransactionMessage({
109
- accountKeys,
114
+ payerKey,
110
115
  instructions,
111
116
  recentBlockhash,
112
117
  });
113
118
  }
114
119
 
115
120
  compileToLegacyMessage(): Message {
116
- const payerKey = this.accountKeys.get(0);
117
- if (payerKey === undefined) {
118
- throw new Error(
119
- 'Failed to compile message because no account keys were found',
120
- );
121
- }
122
-
123
121
  return Message.compile({
124
- payerKey,
122
+ payerKey: this.payerKey,
125
123
  recentBlockhash: this.recentBlockhash,
126
124
  instructions: this.instructions,
127
125
  });
@@ -130,15 +128,8 @@ export class TransactionMessage {
130
128
  compileToV0Message(
131
129
  addressLookupTableAccounts?: AddressLookupTableAccount[],
132
130
  ): MessageV0 {
133
- const payerKey = this.accountKeys.get(0);
134
- if (payerKey === undefined) {
135
- throw new Error(
136
- 'Failed to compile message because no account keys were found',
137
- );
138
- }
139
-
140
131
  return MessageV0.compile({
141
- payerKey,
132
+ payerKey: this.payerKey,
142
133
  recentBlockhash: this.recentBlockhash,
143
134
  instructions: this.instructions,
144
135
  addressLookupTableAccounts,
@@ -17,6 +17,10 @@ export class VersionedTransaction {
17
17
  signatures: Array<Uint8Array>;
18
18
  message: VersionedMessage;
19
19
 
20
+ get version(): TransactionVersion {
21
+ return this.message.version;
22
+ }
23
+
20
24
  constructor(message: VersionedMessage, signatures?: Array<Uint8Array>) {
21
25
  if (signatures !== undefined) {
22
26
  assert(