@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.cjs.js
CHANGED
|
@@ -4354,13 +4354,13 @@ const VersionResult = superstruct.type({
|
|
|
4354
4354
|
const SimulatedTransactionResponseStruct = jsonRpcResultAndContext(superstruct.type({
|
|
4355
4355
|
err: superstruct.nullable(superstruct.union([superstruct.type({}), superstruct.string()])),
|
|
4356
4356
|
logs: superstruct.nullable(superstruct.array(superstruct.string())),
|
|
4357
|
-
accounts: superstruct.optional(superstruct.nullable(superstruct.array(superstruct.type({
|
|
4357
|
+
accounts: superstruct.optional(superstruct.nullable(superstruct.array(superstruct.nullable(superstruct.type({
|
|
4358
4358
|
executable: superstruct.boolean(),
|
|
4359
4359
|
owner: superstruct.string(),
|
|
4360
4360
|
lamports: superstruct.number(),
|
|
4361
4361
|
data: superstruct.array(superstruct.string()),
|
|
4362
4362
|
rentEpoch: superstruct.optional(superstruct.number())
|
|
4363
|
-
})))),
|
|
4363
|
+
}))))),
|
|
4364
4364
|
unitsConsumed: superstruct.optional(superstruct.number())
|
|
4365
4365
|
}));
|
|
4366
4366
|
|
|
@@ -5509,35 +5509,32 @@ class Connection {
|
|
|
5509
5509
|
}
|
|
5510
5510
|
}
|
|
5511
5511
|
/**
|
|
5512
|
-
* Fetch all the account info for multiple accounts specified by an array of public keys
|
|
5512
|
+
* Fetch all the account info for multiple accounts specified by an array of public keys, return with context
|
|
5513
5513
|
*/
|
|
5514
5514
|
|
|
5515
5515
|
|
|
5516
|
-
async
|
|
5516
|
+
async getMultipleAccountsInfoAndContext(publicKeys, commitment) {
|
|
5517
5517
|
const keys = publicKeys.map(key => key.toBase58());
|
|
5518
|
-
let commitment;
|
|
5519
|
-
let encoding = 'base64';
|
|
5520
|
-
|
|
5521
|
-
if (configOrCommitment) {
|
|
5522
|
-
if (typeof configOrCommitment === 'string') {
|
|
5523
|
-
commitment = configOrCommitment;
|
|
5524
|
-
encoding = 'base64';
|
|
5525
|
-
} else {
|
|
5526
|
-
commitment = configOrCommitment.commitment;
|
|
5527
|
-
encoding = configOrCommitment.encoding || 'base64';
|
|
5528
|
-
}
|
|
5529
|
-
}
|
|
5530
5518
|
|
|
5531
|
-
const args = this._buildArgs([keys], commitment,
|
|
5519
|
+
const args = this._buildArgs([keys], commitment, 'base64');
|
|
5532
5520
|
|
|
5533
5521
|
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
|
5534
|
-
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(
|
|
5522
|
+
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(AccountInfoResult))));
|
|
5535
5523
|
|
|
5536
5524
|
if ('error' in res) {
|
|
5537
5525
|
throw new Error('failed to get info for accounts ' + keys + ': ' + res.error.message);
|
|
5538
5526
|
}
|
|
5539
5527
|
|
|
5540
|
-
return res.result
|
|
5528
|
+
return res.result;
|
|
5529
|
+
}
|
|
5530
|
+
/**
|
|
5531
|
+
* Fetch all the account info for multiple accounts specified by an array of public keys
|
|
5532
|
+
*/
|
|
5533
|
+
|
|
5534
|
+
|
|
5535
|
+
async getMultipleAccountsInfo(publicKeys, commitment) {
|
|
5536
|
+
const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitment);
|
|
5537
|
+
return res.value;
|
|
5541
5538
|
}
|
|
5542
5539
|
/**
|
|
5543
5540
|
* Returns epoch activation information for a stake account that has been delegated
|
|
@@ -8265,30 +8262,22 @@ class StakeProgram {
|
|
|
8265
8262
|
});
|
|
8266
8263
|
}
|
|
8267
8264
|
/**
|
|
8268
|
-
*
|
|
8265
|
+
* @internal
|
|
8269
8266
|
*/
|
|
8270
8267
|
|
|
8271
8268
|
|
|
8272
|
-
static
|
|
8269
|
+
static splitInstruction(params) {
|
|
8273
8270
|
const {
|
|
8274
8271
|
stakePubkey,
|
|
8275
8272
|
authorizedPubkey,
|
|
8276
8273
|
splitStakePubkey,
|
|
8277
8274
|
lamports
|
|
8278
8275
|
} = params;
|
|
8279
|
-
const transaction = new Transaction();
|
|
8280
|
-
transaction.add(SystemProgram.createAccount({
|
|
8281
|
-
fromPubkey: authorizedPubkey,
|
|
8282
|
-
newAccountPubkey: splitStakePubkey,
|
|
8283
|
-
lamports: 0,
|
|
8284
|
-
space: this.space,
|
|
8285
|
-
programId: this.programId
|
|
8286
|
-
}));
|
|
8287
8276
|
const type = STAKE_INSTRUCTION_LAYOUTS.Split;
|
|
8288
8277
|
const data = encodeData(type, {
|
|
8289
8278
|
lamports
|
|
8290
8279
|
});
|
|
8291
|
-
return
|
|
8280
|
+
return new TransactionInstruction({
|
|
8292
8281
|
keys: [{
|
|
8293
8282
|
pubkey: stakePubkey,
|
|
8294
8283
|
isSigner: false,
|
|
@@ -8306,6 +8295,52 @@ class StakeProgram {
|
|
|
8306
8295
|
data
|
|
8307
8296
|
});
|
|
8308
8297
|
}
|
|
8298
|
+
/**
|
|
8299
|
+
* Generate a Transaction that splits Stake tokens into another stake account
|
|
8300
|
+
*/
|
|
8301
|
+
|
|
8302
|
+
|
|
8303
|
+
static split(params) {
|
|
8304
|
+
const transaction = new Transaction();
|
|
8305
|
+
transaction.add(SystemProgram.createAccount({
|
|
8306
|
+
fromPubkey: params.authorizedPubkey,
|
|
8307
|
+
newAccountPubkey: params.splitStakePubkey,
|
|
8308
|
+
lamports: 0,
|
|
8309
|
+
space: this.space,
|
|
8310
|
+
programId: this.programId
|
|
8311
|
+
}));
|
|
8312
|
+
return transaction.add(this.splitInstruction(params));
|
|
8313
|
+
}
|
|
8314
|
+
/**
|
|
8315
|
+
* Generate a Transaction that splits Stake tokens into another account
|
|
8316
|
+
* derived from a base public key and seed
|
|
8317
|
+
*/
|
|
8318
|
+
|
|
8319
|
+
|
|
8320
|
+
static splitWithSeed(params) {
|
|
8321
|
+
const {
|
|
8322
|
+
stakePubkey,
|
|
8323
|
+
authorizedPubkey,
|
|
8324
|
+
splitStakePubkey,
|
|
8325
|
+
basePubkey,
|
|
8326
|
+
seed,
|
|
8327
|
+
lamports
|
|
8328
|
+
} = params;
|
|
8329
|
+
const transaction = new Transaction();
|
|
8330
|
+
transaction.add(SystemProgram.allocate({
|
|
8331
|
+
accountPubkey: splitStakePubkey,
|
|
8332
|
+
basePubkey,
|
|
8333
|
+
seed,
|
|
8334
|
+
space: this.space,
|
|
8335
|
+
programId: this.programId
|
|
8336
|
+
}));
|
|
8337
|
+
return transaction.add(this.splitInstruction({
|
|
8338
|
+
stakePubkey,
|
|
8339
|
+
authorizedPubkey,
|
|
8340
|
+
splitStakePubkey,
|
|
8341
|
+
lamports
|
|
8342
|
+
}));
|
|
8343
|
+
}
|
|
8309
8344
|
/**
|
|
8310
8345
|
* Generate a Transaction that merges Stake accounts.
|
|
8311
8346
|
*/
|