@lightprotocol/stateless.js 0.5.1 → 0.7.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/dist/cjs/browser/index.cjs +43 -5
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/node/index.cjs +43 -5
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/es/browser/index.js +42 -5
- package/dist/es/browser/index.js.map +1 -1
- package/dist/types/index.d.ts +34 -7
- package/package.json +3 -3
package/dist/es/browser/index.js
CHANGED
|
@@ -12208,21 +12208,43 @@ class Rpc extends Connection {
|
|
|
12208
12208
|
* Fetch all the compressed accounts owned by the specified public key.
|
|
12209
12209
|
* Owner can be a program or user account
|
|
12210
12210
|
*/
|
|
12211
|
-
async
|
|
12212
|
-
const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressedAccountsByOwner', {
|
|
12211
|
+
async getCompressedAccountsByOwnerWithCursor(owner, config) {
|
|
12212
|
+
const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressedAccountsByOwner', {
|
|
12213
|
+
owner: owner.toBase58(),
|
|
12214
|
+
filters: config?.filters || [],
|
|
12215
|
+
dataSlice: config?.dataSlice,
|
|
12216
|
+
cursor: config?.cursor,
|
|
12217
|
+
limit: config?.limit?.toNumber(),
|
|
12218
|
+
});
|
|
12213
12219
|
const res = create(unsafeRes, jsonRpcResultAndContext(CompressedAccountsByOwnerResult));
|
|
12214
12220
|
if ('error' in res) {
|
|
12215
12221
|
throw new SolanaJSONRPCError(res.error, `failed to get info for compressed accounts owned by ${owner.toBase58()}`);
|
|
12216
12222
|
}
|
|
12217
12223
|
if (res.result.value === null) {
|
|
12218
|
-
return [];
|
|
12224
|
+
return { cursor: null, value: [] };
|
|
12219
12225
|
}
|
|
12220
12226
|
const accounts = [];
|
|
12221
12227
|
res.result.value.items.map(item => {
|
|
12222
12228
|
const account = createCompressedAccountWithMerkleContext(createMerkleContext(item.tree, mockNullifierQueue, item.hash.toArray('be', 32), item.leafIndex), item.owner, bn(item.lamports), item.data ? parseAccountData(item.data) : undefined, item.address || undefined);
|
|
12223
12229
|
accounts.push(account);
|
|
12224
12230
|
});
|
|
12225
|
-
return
|
|
12231
|
+
return {
|
|
12232
|
+
value: accounts.sort((a, b) => b.leafIndex - a.leafIndex),
|
|
12233
|
+
cursor: res.result.value.cursor,
|
|
12234
|
+
};
|
|
12235
|
+
}
|
|
12236
|
+
/**
|
|
12237
|
+
* Fetch all the compressed accounts owned by the specified public key.
|
|
12238
|
+
* Owner can be a program or user account
|
|
12239
|
+
*
|
|
12240
|
+
* To use `config.limit` or `config.cursor`, please use {@link getCompressedAccountsByOwnerWithCursor} instead.
|
|
12241
|
+
*/
|
|
12242
|
+
async getCompressedAccountsByOwner(owner, config) {
|
|
12243
|
+
if (config?.cursor || config?.limit) {
|
|
12244
|
+
throw new Error('To use `limit` and `cursor`, please use getCompressedAccountsByOwnerWithCursor instead.');
|
|
12245
|
+
}
|
|
12246
|
+
const res = await this.getCompressedAccountsByOwnerWithCursor(owner, config);
|
|
12247
|
+
return res.value;
|
|
12226
12248
|
}
|
|
12227
12249
|
/**
|
|
12228
12250
|
* Fetch all the compressed token accounts owned by the specified public
|
|
@@ -18224,10 +18246,25 @@ class TestRpc extends Connection {
|
|
|
18224
18246
|
* Fetch all the compressed accounts owned by the specified public key.
|
|
18225
18247
|
* Owner can be a program or user account
|
|
18226
18248
|
*/
|
|
18227
|
-
async getCompressedAccountsByOwner(owner) {
|
|
18249
|
+
async getCompressedAccountsByOwner(owner, _config) {
|
|
18250
|
+
if (_config) {
|
|
18251
|
+
throw new Error('dataSlice or filters are not supported in test-rpc. Please use rpc.ts instead.');
|
|
18252
|
+
}
|
|
18228
18253
|
const accounts = await getCompressedAccountsByOwnerTest(this, owner);
|
|
18229
18254
|
return accounts;
|
|
18230
18255
|
}
|
|
18256
|
+
/**
|
|
18257
|
+
* Fetch all the compressed accounts owned by the specified public key.
|
|
18258
|
+
* Owner can be a program or user account
|
|
18259
|
+
* Returns with cursor
|
|
18260
|
+
*/
|
|
18261
|
+
async getCompressedAccountsByOwnerWithCursor(owner, _config) {
|
|
18262
|
+
if (_config) {
|
|
18263
|
+
throw new Error('dataSlice or filters are not supported in test-rpc. Please use rpc.ts instead.');
|
|
18264
|
+
}
|
|
18265
|
+
const accounts = await getCompressedAccountsByOwnerTest(this, owner);
|
|
18266
|
+
return { cursor: null, value: accounts };
|
|
18267
|
+
}
|
|
18231
18268
|
/**
|
|
18232
18269
|
* Fetch the latest compression signatures on the cluster. Results are
|
|
18233
18270
|
* paginated.
|