@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.browser.esm.js +40 -4
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +40 -4
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +53 -2
- package/lib/index.esm.js +40 -4
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +40 -4
- 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 +87 -2
- package/package.json +1 -1
- package/src/connection.ts +101 -3
package/module.flow.js
CHANGED
|
@@ -1321,6 +1321,91 @@ declare module "@solana/web3.js" {
|
|
|
1321
1321
|
...
|
|
1322
1322
|
};
|
|
1323
1323
|
|
|
1324
|
+
/**
|
|
1325
|
+
* Data slice argument for getProgramAccounts
|
|
1326
|
+
*/
|
|
1327
|
+
declare export type DataSlice = {
|
|
1328
|
+
/**
|
|
1329
|
+
* offset of data slice
|
|
1330
|
+
*/
|
|
1331
|
+
offset: number,
|
|
1332
|
+
|
|
1333
|
+
/**
|
|
1334
|
+
* length of data slice
|
|
1335
|
+
*/
|
|
1336
|
+
length: number,
|
|
1337
|
+
...
|
|
1338
|
+
};
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* Memory comparison filter for getProgramAccounts
|
|
1342
|
+
*/
|
|
1343
|
+
declare export type MemcmpFilter = {
|
|
1344
|
+
memcmp: {
|
|
1345
|
+
/**
|
|
1346
|
+
* offset into program account data to start comparison
|
|
1347
|
+
*/
|
|
1348
|
+
offset: number,
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* data to match, as base-58 encoded string and limited to less than 129 bytes
|
|
1352
|
+
*/
|
|
1353
|
+
bytes: string,
|
|
1354
|
+
...
|
|
1355
|
+
},
|
|
1356
|
+
...
|
|
1357
|
+
};
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* Data size comparison filter for getProgramAccounts
|
|
1361
|
+
*/
|
|
1362
|
+
declare export type DataSizeFilter = {
|
|
1363
|
+
/**
|
|
1364
|
+
* Size of data for program account data length comparison
|
|
1365
|
+
*/
|
|
1366
|
+
dataSize: number,
|
|
1367
|
+
...
|
|
1368
|
+
};
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* A filter object for getProgramAccounts
|
|
1372
|
+
*/
|
|
1373
|
+
declare export type GetProgramAccountsFilter = MemcmpFilter | DataSizeFilter;
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* Configuration object for getProgramAccounts requests
|
|
1377
|
+
*/
|
|
1378
|
+
declare export type GetProgramAccountsConfig = {
|
|
1379
|
+
/**
|
|
1380
|
+
* Optional commitment level
|
|
1381
|
+
*/
|
|
1382
|
+
commitment?: Commitment,
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* Optional encoding for account data (default base64)
|
|
1386
|
+
*/
|
|
1387
|
+
encoding?: "base64" | "jsonParsed",
|
|
1388
|
+
|
|
1389
|
+
/**
|
|
1390
|
+
* Optional data slice to limit the returned account data
|
|
1391
|
+
*/
|
|
1392
|
+
dataSlice?: DataSlice,
|
|
1393
|
+
|
|
1394
|
+
/**
|
|
1395
|
+
* Optional array of filters to apply to accounts
|
|
1396
|
+
*/
|
|
1397
|
+
filters?: GetProgramAccountsFilter[],
|
|
1398
|
+
...
|
|
1399
|
+
};
|
|
1400
|
+
|
|
1401
|
+
/**
|
|
1402
|
+
* Configuration object for getParsedProgramAccounts
|
|
1403
|
+
*/
|
|
1404
|
+
declare export type GetParsedProgramAccountsConfig = Exclude<
|
|
1405
|
+
GetProgramAccountsConfig,
|
|
1406
|
+
"encoding" | "dataSlice"
|
|
1407
|
+
>;
|
|
1408
|
+
|
|
1324
1409
|
/**
|
|
1325
1410
|
* Information describing an account
|
|
1326
1411
|
*/
|
|
@@ -1695,7 +1780,7 @@ account: AccountInfo<Buffer>,...
|
|
|
1695
1780
|
*/
|
|
1696
1781
|
getProgramAccounts(
|
|
1697
1782
|
programId: PublicKey,
|
|
1698
|
-
|
|
1783
|
+
configOrCommitment?: GetProgramAccountsConfig | Commitment
|
|
1699
1784
|
): Promise<
|
|
1700
1785
|
Array<{
|
|
1701
1786
|
pubkey: PublicKey,
|
|
@@ -1713,7 +1798,7 @@ account: AccountInfo<Buffer | ParsedAccountData>,...
|
|
|
1713
1798
|
*/
|
|
1714
1799
|
getParsedProgramAccounts(
|
|
1715
1800
|
programId: PublicKey,
|
|
1716
|
-
|
|
1801
|
+
configOrCommitment?: GetParsedProgramAccountsConfig | Commitment
|
|
1717
1802
|
): Promise<
|
|
1718
1803
|
Array<{
|
|
1719
1804
|
pubkey: PublicKey,
|
package/package.json
CHANGED
package/src/connection.ts
CHANGED
|
@@ -1368,6 +1368,63 @@ export type StakeActivationData = {
|
|
|
1368
1368
|
inactive: number;
|
|
1369
1369
|
};
|
|
1370
1370
|
|
|
1371
|
+
/**
|
|
1372
|
+
* Data slice argument for getProgramAccounts
|
|
1373
|
+
*/
|
|
1374
|
+
export type DataSlice = {
|
|
1375
|
+
/** offset of data slice */
|
|
1376
|
+
offset: number;
|
|
1377
|
+
/** length of data slice */
|
|
1378
|
+
length: number;
|
|
1379
|
+
};
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* Memory comparison filter for getProgramAccounts
|
|
1383
|
+
*/
|
|
1384
|
+
export type MemcmpFilter = {
|
|
1385
|
+
memcmp: {
|
|
1386
|
+
/** offset into program account data to start comparison */
|
|
1387
|
+
offset: number;
|
|
1388
|
+
/** data to match, as base-58 encoded string and limited to less than 129 bytes */
|
|
1389
|
+
bytes: string;
|
|
1390
|
+
};
|
|
1391
|
+
};
|
|
1392
|
+
|
|
1393
|
+
/**
|
|
1394
|
+
* Data size comparison filter for getProgramAccounts
|
|
1395
|
+
*/
|
|
1396
|
+
export type DataSizeFilter = {
|
|
1397
|
+
/** Size of data for program account data length comparison */
|
|
1398
|
+
dataSize: number;
|
|
1399
|
+
};
|
|
1400
|
+
|
|
1401
|
+
/**
|
|
1402
|
+
* A filter object for getProgramAccounts
|
|
1403
|
+
*/
|
|
1404
|
+
export type GetProgramAccountsFilter = MemcmpFilter | DataSizeFilter;
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* Configuration object for getProgramAccounts requests
|
|
1408
|
+
*/
|
|
1409
|
+
export type GetProgramAccountsConfig = {
|
|
1410
|
+
/** Optional commitment level */
|
|
1411
|
+
commitment?: Commitment;
|
|
1412
|
+
/** Optional encoding for account data (default base64) */
|
|
1413
|
+
encoding?: 'base64' | 'jsonParsed';
|
|
1414
|
+
/** Optional data slice to limit the returned account data */
|
|
1415
|
+
dataSlice?: DataSlice;
|
|
1416
|
+
/** Optional array of filters to apply to accounts */
|
|
1417
|
+
filters?: GetProgramAccountsFilter[];
|
|
1418
|
+
};
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* Configuration object for getParsedProgramAccounts
|
|
1422
|
+
*/
|
|
1423
|
+
export type GetParsedProgramAccountsConfig = Exclude<
|
|
1424
|
+
GetProgramAccountsConfig,
|
|
1425
|
+
'encoding' | 'dataSlice'
|
|
1426
|
+
>;
|
|
1427
|
+
|
|
1371
1428
|
/**
|
|
1372
1429
|
* Information describing an account
|
|
1373
1430
|
*/
|
|
@@ -2080,9 +2137,34 @@ export class Connection {
|
|
|
2080
2137
|
*/
|
|
2081
2138
|
async getProgramAccounts(
|
|
2082
2139
|
programId: PublicKey,
|
|
2083
|
-
|
|
2140
|
+
configOrCommitment?: GetProgramAccountsConfig | Commitment,
|
|
2084
2141
|
): Promise<Array<{pubkey: PublicKey; account: AccountInfo<Buffer>}>> {
|
|
2085
|
-
const
|
|
2142
|
+
const extra: Pick<GetProgramAccountsConfig, 'dataSlice' | 'filters'> = {};
|
|
2143
|
+
|
|
2144
|
+
let commitment;
|
|
2145
|
+
let encoding;
|
|
2146
|
+
if (configOrCommitment) {
|
|
2147
|
+
if (typeof configOrCommitment === 'string') {
|
|
2148
|
+
commitment = configOrCommitment;
|
|
2149
|
+
} else {
|
|
2150
|
+
commitment = configOrCommitment.commitment;
|
|
2151
|
+
encoding = configOrCommitment.encoding;
|
|
2152
|
+
|
|
2153
|
+
if (configOrCommitment.dataSlice) {
|
|
2154
|
+
extra.dataSlice = configOrCommitment.dataSlice;
|
|
2155
|
+
}
|
|
2156
|
+
if (configOrCommitment.filters) {
|
|
2157
|
+
extra.filters = configOrCommitment.filters;
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
const args = this._buildArgs(
|
|
2163
|
+
[programId.toBase58()],
|
|
2164
|
+
commitment,
|
|
2165
|
+
encoding || 'base64',
|
|
2166
|
+
extra,
|
|
2167
|
+
);
|
|
2086
2168
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
2087
2169
|
const res = create(unsafeRes, jsonRpcResult(array(KeyedAccountInfoResult)));
|
|
2088
2170
|
if ('error' in res) {
|
|
@@ -2103,17 +2185,33 @@ export class Connection {
|
|
|
2103
2185
|
*/
|
|
2104
2186
|
async getParsedProgramAccounts(
|
|
2105
2187
|
programId: PublicKey,
|
|
2106
|
-
|
|
2188
|
+
configOrCommitment?: GetParsedProgramAccountsConfig | Commitment,
|
|
2107
2189
|
): Promise<
|
|
2108
2190
|
Array<{
|
|
2109
2191
|
pubkey: PublicKey;
|
|
2110
2192
|
account: AccountInfo<Buffer | ParsedAccountData>;
|
|
2111
2193
|
}>
|
|
2112
2194
|
> {
|
|
2195
|
+
const extra: Pick<GetParsedProgramAccountsConfig, 'filters'> = {};
|
|
2196
|
+
|
|
2197
|
+
let commitment;
|
|
2198
|
+
if (configOrCommitment) {
|
|
2199
|
+
if (typeof configOrCommitment === 'string') {
|
|
2200
|
+
commitment = configOrCommitment;
|
|
2201
|
+
} else {
|
|
2202
|
+
commitment = configOrCommitment.commitment;
|
|
2203
|
+
|
|
2204
|
+
if (configOrCommitment.filters) {
|
|
2205
|
+
extra.filters = configOrCommitment.filters;
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2113
2210
|
const args = this._buildArgs(
|
|
2114
2211
|
[programId.toBase58()],
|
|
2115
2212
|
commitment,
|
|
2116
2213
|
'jsonParsed',
|
|
2214
|
+
extra,
|
|
2117
2215
|
);
|
|
2118
2216
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
2119
2217
|
const res = create(
|