@solana/web3.js 1.3.1 → 1.4.1

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.cjs.js CHANGED
@@ -3543,8 +3543,29 @@ class Connection {
3543
3543
  */
3544
3544
 
3545
3545
 
3546
- async getProgramAccounts(programId, commitment) {
3547
- const args = this._buildArgs([programId.toBase58()], commitment, 'base64');
3546
+ async getProgramAccounts(programId, configOrCommitment) {
3547
+ const extra = {};
3548
+ let commitment;
3549
+ let encoding;
3550
+
3551
+ if (configOrCommitment) {
3552
+ if (typeof configOrCommitment === 'string') {
3553
+ commitment = configOrCommitment;
3554
+ } else {
3555
+ commitment = configOrCommitment.commitment;
3556
+ encoding = configOrCommitment.encoding;
3557
+
3558
+ if (configOrCommitment.dataSlice) {
3559
+ extra.dataSlice = configOrCommitment.dataSlice;
3560
+ }
3561
+
3562
+ if (configOrCommitment.filters) {
3563
+ extra.filters = configOrCommitment.filters;
3564
+ }
3565
+ }
3566
+ }
3567
+
3568
+ const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', extra);
3548
3569
 
3549
3570
  const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
3550
3571
  const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedAccountInfoResult)));
@@ -3562,8 +3583,23 @@ class Connection {
3562
3583
  */
3563
3584
 
3564
3585
 
3565
- async getParsedProgramAccounts(programId, commitment) {
3566
- const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed');
3586
+ async getParsedProgramAccounts(programId, configOrCommitment) {
3587
+ const extra = {};
3588
+ let commitment;
3589
+
3590
+ if (configOrCommitment) {
3591
+ if (typeof configOrCommitment === 'string') {
3592
+ commitment = configOrCommitment;
3593
+ } else {
3594
+ commitment = configOrCommitment.commitment;
3595
+
3596
+ if (configOrCommitment.filters) {
3597
+ extra.filters = configOrCommitment.filters;
3598
+ }
3599
+ }
3600
+ }
3601
+
3602
+ const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', extra);
3567
3603
 
3568
3604
  const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
3569
3605
  const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedParsedAccountInfoResult)));