@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/module.flow.js
CHANGED
|
@@ -1027,7 +1027,7 @@ declare module "@solana/web3.js" {
|
|
|
1027
1027
|
declare export type SimulatedTransactionResponse = {
|
|
1028
1028
|
err: TransactionError | string | null,
|
|
1029
1029
|
logs: Array<string> | null,
|
|
1030
|
-
accounts?: SimulatedTransactionAccountInfo[] | null,
|
|
1030
|
+
accounts?: (SimulatedTransactionAccountInfo | null)[] | null,
|
|
1031
1031
|
unitsConsumed?: number,
|
|
1032
1032
|
...
|
|
1033
1033
|
};
|
|
@@ -2281,13 +2281,21 @@ account: AccountInfo<ParsedAccountData>,...
|
|
|
2281
2281
|
commitment?: Commitment
|
|
2282
2282
|
): Promise<AccountInfo<Buffer> | null>;
|
|
2283
2283
|
|
|
2284
|
+
/**
|
|
2285
|
+
* Fetch all the account info for multiple accounts specified by an array of public keys, return with context
|
|
2286
|
+
*/
|
|
2287
|
+
getMultipleAccountsInfoAndContext(
|
|
2288
|
+
publicKeys: PublicKey[],
|
|
2289
|
+
commitment?: Commitment
|
|
2290
|
+
): Promise<RpcResponseAndContext<(AccountInfo<Buffer> | null)[]>>;
|
|
2291
|
+
|
|
2284
2292
|
/**
|
|
2285
2293
|
* Fetch all the account info for multiple accounts specified by an array of public keys
|
|
2286
2294
|
*/
|
|
2287
2295
|
getMultipleAccountsInfo(
|
|
2288
2296
|
publicKeys: PublicKey[],
|
|
2289
|
-
|
|
2290
|
-
): Promise<(AccountInfo<Buffer
|
|
2297
|
+
commitment?: Commitment
|
|
2298
|
+
): Promise<(AccountInfo<Buffer> | null)[]>;
|
|
2291
2299
|
|
|
2292
2300
|
/**
|
|
2293
2301
|
* Returns epoch activation information for a stake account that has been delegated
|
|
@@ -3146,6 +3154,19 @@ lastValidBlockHeight: number,...
|
|
|
3146
3154
|
...
|
|
3147
3155
|
};
|
|
3148
3156
|
|
|
3157
|
+
/**
|
|
3158
|
+
* Split with seed transaction params
|
|
3159
|
+
*/
|
|
3160
|
+
declare export type SplitStakeWithSeedParams = {
|
|
3161
|
+
stakePubkey: PublicKey,
|
|
3162
|
+
authorizedPubkey: PublicKey,
|
|
3163
|
+
splitStakePubkey: PublicKey,
|
|
3164
|
+
basePubkey: PublicKey,
|
|
3165
|
+
seed: string,
|
|
3166
|
+
lamports: number,
|
|
3167
|
+
...
|
|
3168
|
+
};
|
|
3169
|
+
|
|
3149
3170
|
/**
|
|
3150
3171
|
* Withdraw stake instruction params
|
|
3151
3172
|
*/
|
|
@@ -3340,6 +3361,12 @@ lastValidBlockHeight: number,...
|
|
|
3340
3361
|
*/
|
|
3341
3362
|
static split(params: SplitStakeParams): Transaction;
|
|
3342
3363
|
|
|
3364
|
+
/**
|
|
3365
|
+
* Generate a Transaction that splits Stake tokens into another account
|
|
3366
|
+
* derived from a base public key and seed
|
|
3367
|
+
*/
|
|
3368
|
+
static splitWithSeed(params: SplitStakeWithSeedParams): Transaction;
|
|
3369
|
+
|
|
3343
3370
|
/**
|
|
3344
3371
|
* Generate a Transaction that merges Stake accounts.
|
|
3345
3372
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/web3.js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.36.0",
|
|
4
4
|
"description": "Solana Javascript API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"browser": {
|
|
23
|
-
"./lib/index.cjs.js": "./lib/index.browser.
|
|
23
|
+
"./lib/index.cjs.js": "./lib/index.browser.cjs.js",
|
|
24
24
|
"./lib/index.esm.js": "./lib/index.browser.esm.js"
|
|
25
25
|
},
|
|
26
26
|
"main": "lib/index.cjs.js",
|
package/src/connection.ts
CHANGED
|
@@ -469,7 +469,7 @@ export type SimulatedTransactionAccountInfo = {
|
|
|
469
469
|
export type SimulatedTransactionResponse = {
|
|
470
470
|
err: TransactionError | string | null;
|
|
471
471
|
logs: Array<string> | null;
|
|
472
|
-
accounts?: SimulatedTransactionAccountInfo[] | null;
|
|
472
|
+
accounts?: (SimulatedTransactionAccountInfo | null)[] | null;
|
|
473
473
|
unitsConsumed?: number;
|
|
474
474
|
};
|
|
475
475
|
|
|
@@ -480,13 +480,15 @@ const SimulatedTransactionResponseStruct = jsonRpcResultAndContext(
|
|
|
480
480
|
accounts: optional(
|
|
481
481
|
nullable(
|
|
482
482
|
array(
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
483
|
+
nullable(
|
|
484
|
+
pick({
|
|
485
|
+
executable: boolean(),
|
|
486
|
+
owner: string(),
|
|
487
|
+
lamports: number(),
|
|
488
|
+
data: array(string()),
|
|
489
|
+
rentEpoch: optional(number()),
|
|
490
|
+
}),
|
|
491
|
+
),
|
|
490
492
|
),
|
|
491
493
|
),
|
|
492
494
|
),
|
|
@@ -2550,38 +2552,39 @@ export class Connection {
|
|
|
2550
2552
|
}
|
|
2551
2553
|
|
|
2552
2554
|
/**
|
|
2553
|
-
* Fetch all the account info for multiple accounts specified by an array of public keys
|
|
2555
|
+
* Fetch all the account info for multiple accounts specified by an array of public keys, return with context
|
|
2554
2556
|
*/
|
|
2555
|
-
async
|
|
2557
|
+
async getMultipleAccountsInfoAndContext(
|
|
2556
2558
|
publicKeys: PublicKey[],
|
|
2557
|
-
|
|
2558
|
-
): Promise<(AccountInfo<Buffer
|
|
2559
|
+
commitment?: Commitment,
|
|
2560
|
+
): Promise<RpcResponseAndContext<(AccountInfo<Buffer> | null)[]>> {
|
|
2559
2561
|
const keys = publicKeys.map(key => key.toBase58());
|
|
2560
|
-
|
|
2561
|
-
let commitment;
|
|
2562
|
-
let encoding: 'base64' | 'jsonParsed' = 'base64';
|
|
2563
|
-
if (configOrCommitment) {
|
|
2564
|
-
if (typeof configOrCommitment === 'string') {
|
|
2565
|
-
commitment = configOrCommitment;
|
|
2566
|
-
encoding = 'base64';
|
|
2567
|
-
} else {
|
|
2568
|
-
commitment = configOrCommitment.commitment;
|
|
2569
|
-
encoding = configOrCommitment.encoding || 'base64';
|
|
2570
|
-
}
|
|
2571
|
-
}
|
|
2572
|
-
|
|
2573
|
-
const args = this._buildArgs([keys], commitment, encoding);
|
|
2562
|
+
const args = this._buildArgs([keys], commitment, 'base64');
|
|
2574
2563
|
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
|
2575
2564
|
const res = create(
|
|
2576
2565
|
unsafeRes,
|
|
2577
|
-
jsonRpcResultAndContext(array(nullable(
|
|
2566
|
+
jsonRpcResultAndContext(array(nullable(AccountInfoResult))),
|
|
2578
2567
|
);
|
|
2579
2568
|
if ('error' in res) {
|
|
2580
2569
|
throw new Error(
|
|
2581
2570
|
'failed to get info for accounts ' + keys + ': ' + res.error.message,
|
|
2582
2571
|
);
|
|
2583
2572
|
}
|
|
2584
|
-
return res.result
|
|
2573
|
+
return res.result;
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
/**
|
|
2577
|
+
* Fetch all the account info for multiple accounts specified by an array of public keys
|
|
2578
|
+
*/
|
|
2579
|
+
async getMultipleAccountsInfo(
|
|
2580
|
+
publicKeys: PublicKey[],
|
|
2581
|
+
commitment?: Commitment,
|
|
2582
|
+
): Promise<(AccountInfo<Buffer> | null)[]> {
|
|
2583
|
+
const res = await this.getMultipleAccountsInfoAndContext(
|
|
2584
|
+
publicKeys,
|
|
2585
|
+
commitment,
|
|
2586
|
+
);
|
|
2587
|
+
return res.value;
|
|
2585
2588
|
}
|
|
2586
2589
|
|
|
2587
2590
|
/**
|
package/src/stake-program.ts
CHANGED
|
@@ -147,6 +147,18 @@ export type SplitStakeParams = {
|
|
|
147
147
|
lamports: number;
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Split with seed transaction params
|
|
152
|
+
*/
|
|
153
|
+
export type SplitStakeWithSeedParams = {
|
|
154
|
+
stakePubkey: PublicKey;
|
|
155
|
+
authorizedPubkey: PublicKey;
|
|
156
|
+
splitStakePubkey: PublicKey;
|
|
157
|
+
basePubkey: PublicKey;
|
|
158
|
+
seed: string;
|
|
159
|
+
lamports: number;
|
|
160
|
+
};
|
|
161
|
+
|
|
150
162
|
/**
|
|
151
163
|
* Withdraw stake instruction params
|
|
152
164
|
*/
|
|
@@ -706,25 +718,13 @@ export class StakeProgram {
|
|
|
706
718
|
}
|
|
707
719
|
|
|
708
720
|
/**
|
|
709
|
-
*
|
|
721
|
+
* @internal
|
|
710
722
|
*/
|
|
711
|
-
static
|
|
723
|
+
static splitInstruction(params: SplitStakeParams): TransactionInstruction {
|
|
712
724
|
const {stakePubkey, authorizedPubkey, splitStakePubkey, lamports} = params;
|
|
713
|
-
|
|
714
|
-
const transaction = new Transaction();
|
|
715
|
-
transaction.add(
|
|
716
|
-
SystemProgram.createAccount({
|
|
717
|
-
fromPubkey: authorizedPubkey,
|
|
718
|
-
newAccountPubkey: splitStakePubkey,
|
|
719
|
-
lamports: 0,
|
|
720
|
-
space: this.space,
|
|
721
|
-
programId: this.programId,
|
|
722
|
-
}),
|
|
723
|
-
);
|
|
724
725
|
const type = STAKE_INSTRUCTION_LAYOUTS.Split;
|
|
725
726
|
const data = encodeData(type, {lamports});
|
|
726
|
-
|
|
727
|
-
return transaction.add({
|
|
727
|
+
return new TransactionInstruction({
|
|
728
728
|
keys: [
|
|
729
729
|
{pubkey: stakePubkey, isSigner: false, isWritable: true},
|
|
730
730
|
{pubkey: splitStakePubkey, isSigner: false, isWritable: true},
|
|
@@ -735,6 +735,56 @@ export class StakeProgram {
|
|
|
735
735
|
});
|
|
736
736
|
}
|
|
737
737
|
|
|
738
|
+
/**
|
|
739
|
+
* Generate a Transaction that splits Stake tokens into another stake account
|
|
740
|
+
*/
|
|
741
|
+
static split(params: SplitStakeParams): Transaction {
|
|
742
|
+
const transaction = new Transaction();
|
|
743
|
+
transaction.add(
|
|
744
|
+
SystemProgram.createAccount({
|
|
745
|
+
fromPubkey: params.authorizedPubkey,
|
|
746
|
+
newAccountPubkey: params.splitStakePubkey,
|
|
747
|
+
lamports: 0,
|
|
748
|
+
space: this.space,
|
|
749
|
+
programId: this.programId,
|
|
750
|
+
}),
|
|
751
|
+
);
|
|
752
|
+
return transaction.add(this.splitInstruction(params));
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Generate a Transaction that splits Stake tokens into another account
|
|
757
|
+
* derived from a base public key and seed
|
|
758
|
+
*/
|
|
759
|
+
static splitWithSeed(params: SplitStakeWithSeedParams): Transaction {
|
|
760
|
+
const {
|
|
761
|
+
stakePubkey,
|
|
762
|
+
authorizedPubkey,
|
|
763
|
+
splitStakePubkey,
|
|
764
|
+
basePubkey,
|
|
765
|
+
seed,
|
|
766
|
+
lamports,
|
|
767
|
+
} = params;
|
|
768
|
+
const transaction = new Transaction();
|
|
769
|
+
transaction.add(
|
|
770
|
+
SystemProgram.allocate({
|
|
771
|
+
accountPubkey: splitStakePubkey,
|
|
772
|
+
basePubkey,
|
|
773
|
+
seed,
|
|
774
|
+
space: this.space,
|
|
775
|
+
programId: this.programId,
|
|
776
|
+
}),
|
|
777
|
+
);
|
|
778
|
+
return transaction.add(
|
|
779
|
+
this.splitInstruction({
|
|
780
|
+
stakePubkey,
|
|
781
|
+
authorizedPubkey,
|
|
782
|
+
splitStakePubkey,
|
|
783
|
+
lamports,
|
|
784
|
+
}),
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
|
|
738
788
|
/**
|
|
739
789
|
* Generate a Transaction that merges Stake accounts.
|
|
740
790
|
*/
|