@lightprotocol/stateless.js 0.6.0 → 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 +44 -5
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/node/index.cjs +44 -5
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/es/browser/index.js +43 -5
- package/dist/es/browser/index.js.map +1 -1
- package/dist/types/index.d.ts +39 -7
- package/package.json +3 -3
package/dist/es/browser/index.js
CHANGED
|
@@ -11756,6 +11756,7 @@ const LatestNonVotingSignaturesResult = type({
|
|
|
11756
11756
|
signature: string(),
|
|
11757
11757
|
slot: number(),
|
|
11758
11758
|
blockTime: number(),
|
|
11759
|
+
error: nullable(string()),
|
|
11759
11760
|
})),
|
|
11760
11761
|
});
|
|
11761
11762
|
/**
|
|
@@ -12207,21 +12208,43 @@ class Rpc extends Connection {
|
|
|
12207
12208
|
* Fetch all the compressed accounts owned by the specified public key.
|
|
12208
12209
|
* Owner can be a program or user account
|
|
12209
12210
|
*/
|
|
12210
|
-
async
|
|
12211
|
-
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
|
+
});
|
|
12212
12219
|
const res = create(unsafeRes, jsonRpcResultAndContext(CompressedAccountsByOwnerResult));
|
|
12213
12220
|
if ('error' in res) {
|
|
12214
12221
|
throw new SolanaJSONRPCError(res.error, `failed to get info for compressed accounts owned by ${owner.toBase58()}`);
|
|
12215
12222
|
}
|
|
12216
12223
|
if (res.result.value === null) {
|
|
12217
|
-
return [];
|
|
12224
|
+
return { cursor: null, value: [] };
|
|
12218
12225
|
}
|
|
12219
12226
|
const accounts = [];
|
|
12220
12227
|
res.result.value.items.map(item => {
|
|
12221
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);
|
|
12222
12229
|
accounts.push(account);
|
|
12223
12230
|
});
|
|
12224
|
-
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;
|
|
12225
12248
|
}
|
|
12226
12249
|
/**
|
|
12227
12250
|
* Fetch all the compressed token accounts owned by the specified public
|
|
@@ -18223,10 +18246,25 @@ class TestRpc extends Connection {
|
|
|
18223
18246
|
* Fetch all the compressed accounts owned by the specified public key.
|
|
18224
18247
|
* Owner can be a program or user account
|
|
18225
18248
|
*/
|
|
18226
|
-
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
|
+
}
|
|
18227
18253
|
const accounts = await getCompressedAccountsByOwnerTest(this, owner);
|
|
18228
18254
|
return accounts;
|
|
18229
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
|
+
}
|
|
18230
18268
|
/**
|
|
18231
18269
|
* Fetch the latest compression signatures on the cluster. Results are
|
|
18232
18270
|
* paginated.
|