@solana/web3.js 1.34.0 → 1.36.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.browser.esm.js +65 -30
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +65 -30
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +26 -3
- package/lib/index.esm.js +65 -30
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +65 -30
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +1 -1
- package/lib/index.iife.min.js.map +1 -1
- package/module.flow.js +30 -3
- package/package.json +2 -2
- package/src/connection.ts +31 -28
- package/src/stake-program.ts +65 -15
package/lib/index.d.ts
CHANGED
|
@@ -754,7 +754,7 @@ declare module '@solana/web3.js' {
|
|
|
754
754
|
export type SimulatedTransactionResponse = {
|
|
755
755
|
err: TransactionError | string | null;
|
|
756
756
|
logs: Array<string> | null;
|
|
757
|
-
accounts?: SimulatedTransactionAccountInfo[] | null;
|
|
757
|
+
accounts?: (SimulatedTransactionAccountInfo | null)[] | null;
|
|
758
758
|
unitsConsumed?: number;
|
|
759
759
|
};
|
|
760
760
|
export type ParsedInnerInstruction = {
|
|
@@ -1527,13 +1527,20 @@ declare module '@solana/web3.js' {
|
|
|
1527
1527
|
publicKey: PublicKey,
|
|
1528
1528
|
commitment?: Commitment,
|
|
1529
1529
|
): Promise<AccountInfo<Buffer> | null>;
|
|
1530
|
+
/**
|
|
1531
|
+
* Fetch all the account info for multiple accounts specified by an array of public keys, return with context
|
|
1532
|
+
*/
|
|
1533
|
+
getMultipleAccountsInfoAndContext(
|
|
1534
|
+
publicKeys: PublicKey[],
|
|
1535
|
+
commitment?: Commitment,
|
|
1536
|
+
): Promise<RpcResponseAndContext<(AccountInfo<Buffer> | null)[]>>;
|
|
1530
1537
|
/**
|
|
1531
1538
|
* Fetch all the account info for multiple accounts specified by an array of public keys
|
|
1532
1539
|
*/
|
|
1533
1540
|
getMultipleAccountsInfo(
|
|
1534
1541
|
publicKeys: PublicKey[],
|
|
1535
|
-
|
|
1536
|
-
): Promise<(AccountInfo<Buffer
|
|
1542
|
+
commitment?: Commitment,
|
|
1543
|
+
): Promise<(AccountInfo<Buffer> | null)[]>;
|
|
1537
1544
|
/**
|
|
1538
1545
|
* Returns epoch activation information for a stake account that has been delegated
|
|
1539
1546
|
*/
|
|
@@ -2278,6 +2285,17 @@ declare module '@solana/web3.js' {
|
|
|
2278
2285
|
splitStakePubkey: PublicKey;
|
|
2279
2286
|
lamports: number;
|
|
2280
2287
|
};
|
|
2288
|
+
/**
|
|
2289
|
+
* Split with seed transaction params
|
|
2290
|
+
*/
|
|
2291
|
+
export type SplitStakeWithSeedParams = {
|
|
2292
|
+
stakePubkey: PublicKey;
|
|
2293
|
+
authorizedPubkey: PublicKey;
|
|
2294
|
+
splitStakePubkey: PublicKey;
|
|
2295
|
+
basePubkey: PublicKey;
|
|
2296
|
+
seed: string;
|
|
2297
|
+
lamports: number;
|
|
2298
|
+
};
|
|
2281
2299
|
/**
|
|
2282
2300
|
* Withdraw stake instruction params
|
|
2283
2301
|
*/
|
|
@@ -2439,6 +2457,11 @@ declare module '@solana/web3.js' {
|
|
|
2439
2457
|
* Generate a Transaction that splits Stake tokens into another stake account
|
|
2440
2458
|
*/
|
|
2441
2459
|
static split(params: SplitStakeParams): Transaction;
|
|
2460
|
+
/**
|
|
2461
|
+
* Generate a Transaction that splits Stake tokens into another account
|
|
2462
|
+
* derived from a base public key and seed
|
|
2463
|
+
*/
|
|
2464
|
+
static splitWithSeed(params: SplitStakeWithSeedParams): Transaction;
|
|
2442
2465
|
/**
|
|
2443
2466
|
* Generate a Transaction that merges Stake accounts.
|
|
2444
2467
|
*/
|
package/lib/index.esm.js
CHANGED
|
@@ -4319,13 +4319,13 @@ const VersionResult = type({
|
|
|
4319
4319
|
const SimulatedTransactionResponseStruct = jsonRpcResultAndContext(type({
|
|
4320
4320
|
err: nullable(union([type({}), string()])),
|
|
4321
4321
|
logs: nullable(array(string())),
|
|
4322
|
-
accounts: optional(nullable(array(type({
|
|
4322
|
+
accounts: optional(nullable(array(nullable(type({
|
|
4323
4323
|
executable: boolean(),
|
|
4324
4324
|
owner: string(),
|
|
4325
4325
|
lamports: number(),
|
|
4326
4326
|
data: array(string()),
|
|
4327
4327
|
rentEpoch: optional(number())
|
|
4328
|
-
})))),
|
|
4328
|
+
}))))),
|
|
4329
4329
|
unitsConsumed: optional(number())
|
|
4330
4330
|
}));
|
|
4331
4331
|
|
|
@@ -5474,35 +5474,32 @@ class Connection {
|
|
|
5474
5474
|
}
|
|
5475
5475
|
}
|
|
5476
5476
|
/**
|
|
5477
|
-
* Fetch all the account info for multiple accounts specified by an array of public keys
|
|
5477
|
+
* Fetch all the account info for multiple accounts specified by an array of public keys, return with context
|
|
5478
5478
|
*/
|
|
5479
5479
|
|
|
5480
5480
|
|
|
5481
|
-
async
|
|
5481
|
+
async getMultipleAccountsInfoAndContext(publicKeys, commitment) {
|
|
5482
5482
|
const keys = publicKeys.map(key => key.toBase58());
|
|
5483
|
-
let commitment;
|
|
5484
|
-
let encoding = 'base64';
|
|
5485
|
-
|
|
5486
|
-
if (configOrCommitment) {
|
|
5487
|
-
if (typeof configOrCommitment === 'string') {
|
|
5488
|
-
commitment = configOrCommitment;
|
|
5489
|
-
encoding = 'base64';
|
|
5490
|
-
} else {
|
|
5491
|
-
commitment = configOrCommitment.commitment;
|
|
5492
|
-
encoding = configOrCommitment.encoding || 'base64';
|
|
5493
|
-
}
|
|
5494
|
-
}
|
|
5495
5483
|
|
|
5496
|
-
const args = this._buildArgs([keys], commitment,
|
|
5484
|
+
const args = this._buildArgs([keys], commitment, 'base64');
|
|
5497
5485
|
|
|
5498
5486
|
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
|
5499
|
-
const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(
|
|
5487
|
+
const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(AccountInfoResult))));
|
|
5500
5488
|
|
|
5501
5489
|
if ('error' in res) {
|
|
5502
5490
|
throw new Error('failed to get info for accounts ' + keys + ': ' + res.error.message);
|
|
5503
5491
|
}
|
|
5504
5492
|
|
|
5505
|
-
return res.result
|
|
5493
|
+
return res.result;
|
|
5494
|
+
}
|
|
5495
|
+
/**
|
|
5496
|
+
* Fetch all the account info for multiple accounts specified by an array of public keys
|
|
5497
|
+
*/
|
|
5498
|
+
|
|
5499
|
+
|
|
5500
|
+
async getMultipleAccountsInfo(publicKeys, commitment) {
|
|
5501
|
+
const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitment);
|
|
5502
|
+
return res.value;
|
|
5506
5503
|
}
|
|
5507
5504
|
/**
|
|
5508
5505
|
* Returns epoch activation information for a stake account that has been delegated
|
|
@@ -8230,30 +8227,22 @@ class StakeProgram {
|
|
|
8230
8227
|
});
|
|
8231
8228
|
}
|
|
8232
8229
|
/**
|
|
8233
|
-
*
|
|
8230
|
+
* @internal
|
|
8234
8231
|
*/
|
|
8235
8232
|
|
|
8236
8233
|
|
|
8237
|
-
static
|
|
8234
|
+
static splitInstruction(params) {
|
|
8238
8235
|
const {
|
|
8239
8236
|
stakePubkey,
|
|
8240
8237
|
authorizedPubkey,
|
|
8241
8238
|
splitStakePubkey,
|
|
8242
8239
|
lamports
|
|
8243
8240
|
} = params;
|
|
8244
|
-
const transaction = new Transaction();
|
|
8245
|
-
transaction.add(SystemProgram.createAccount({
|
|
8246
|
-
fromPubkey: authorizedPubkey,
|
|
8247
|
-
newAccountPubkey: splitStakePubkey,
|
|
8248
|
-
lamports: 0,
|
|
8249
|
-
space: this.space,
|
|
8250
|
-
programId: this.programId
|
|
8251
|
-
}));
|
|
8252
8241
|
const type = STAKE_INSTRUCTION_LAYOUTS.Split;
|
|
8253
8242
|
const data = encodeData(type, {
|
|
8254
8243
|
lamports
|
|
8255
8244
|
});
|
|
8256
|
-
return
|
|
8245
|
+
return new TransactionInstruction({
|
|
8257
8246
|
keys: [{
|
|
8258
8247
|
pubkey: stakePubkey,
|
|
8259
8248
|
isSigner: false,
|
|
@@ -8271,6 +8260,52 @@ class StakeProgram {
|
|
|
8271
8260
|
data
|
|
8272
8261
|
});
|
|
8273
8262
|
}
|
|
8263
|
+
/**
|
|
8264
|
+
* Generate a Transaction that splits Stake tokens into another stake account
|
|
8265
|
+
*/
|
|
8266
|
+
|
|
8267
|
+
|
|
8268
|
+
static split(params) {
|
|
8269
|
+
const transaction = new Transaction();
|
|
8270
|
+
transaction.add(SystemProgram.createAccount({
|
|
8271
|
+
fromPubkey: params.authorizedPubkey,
|
|
8272
|
+
newAccountPubkey: params.splitStakePubkey,
|
|
8273
|
+
lamports: 0,
|
|
8274
|
+
space: this.space,
|
|
8275
|
+
programId: this.programId
|
|
8276
|
+
}));
|
|
8277
|
+
return transaction.add(this.splitInstruction(params));
|
|
8278
|
+
}
|
|
8279
|
+
/**
|
|
8280
|
+
* Generate a Transaction that splits Stake tokens into another account
|
|
8281
|
+
* derived from a base public key and seed
|
|
8282
|
+
*/
|
|
8283
|
+
|
|
8284
|
+
|
|
8285
|
+
static splitWithSeed(params) {
|
|
8286
|
+
const {
|
|
8287
|
+
stakePubkey,
|
|
8288
|
+
authorizedPubkey,
|
|
8289
|
+
splitStakePubkey,
|
|
8290
|
+
basePubkey,
|
|
8291
|
+
seed,
|
|
8292
|
+
lamports
|
|
8293
|
+
} = params;
|
|
8294
|
+
const transaction = new Transaction();
|
|
8295
|
+
transaction.add(SystemProgram.allocate({
|
|
8296
|
+
accountPubkey: splitStakePubkey,
|
|
8297
|
+
basePubkey,
|
|
8298
|
+
seed,
|
|
8299
|
+
space: this.space,
|
|
8300
|
+
programId: this.programId
|
|
8301
|
+
}));
|
|
8302
|
+
return transaction.add(this.splitInstruction({
|
|
8303
|
+
stakePubkey,
|
|
8304
|
+
authorizedPubkey,
|
|
8305
|
+
splitStakePubkey,
|
|
8306
|
+
lamports
|
|
8307
|
+
}));
|
|
8308
|
+
}
|
|
8274
8309
|
/**
|
|
8275
8310
|
* Generate a Transaction that merges Stake accounts.
|
|
8276
8311
|
*/
|