@dusk-network/app-core 0.3.0 → 0.3.2
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/CHANGELOG.md +19 -0
- package/README.md +5 -4
- package/package.json +1 -1
- package/src/bridge.d.ts +46 -10
- package/src/bridge.js +708 -231
- package/src/history.d.ts +2 -0
- package/src/history.js +3 -2
package/src/history.d.ts
CHANGED
|
@@ -373,6 +373,8 @@ export type RangeOptions = {
|
|
|
373
373
|
direction?: "in" | "out" | "both";
|
|
374
374
|
/** The most pages to read, 1 by default. */
|
|
375
375
|
pages?: number;
|
|
376
|
+
/** The first page to read, 1 by default: a read of the same range carries on where an earlier one stopped. */
|
|
377
|
+
page?: number;
|
|
376
378
|
};
|
|
377
379
|
|
|
378
380
|
/**
|
package/src/history.js
CHANGED
|
@@ -816,7 +816,7 @@ function nextWindow(window, count) {
|
|
|
816
816
|
* @param {RangeOptions} options
|
|
817
817
|
* @returns {Promise<{ entries: HistoryEntry[], complete: boolean, requests: number }>}
|
|
818
818
|
*/
|
|
819
|
-
export async function historyRange(archive, { account, from = 0, to, direction = "both", pages = 1 }) {
|
|
819
|
+
export async function historyRange(archive, { account, from = 0, to, direction = "both", pages = 1, page: first = 1 }) {
|
|
820
820
|
/** @type {Record<string, ReadonlyArray<"in" | "out">>} */
|
|
821
821
|
const ASKED = { both: ["out", "in"], in: ["in"], out: ["out"] };
|
|
822
822
|
const aliases = Object.hasOwn(ASKED, direction) ? ASKED[direction] : null;
|
|
@@ -827,8 +827,9 @@ export async function historyRange(archive, { account, from = 0, to, direction =
|
|
|
827
827
|
const entries = [];
|
|
828
828
|
let complete = false;
|
|
829
829
|
let requests = 0;
|
|
830
|
+
const start = Math.max(1, Math.floor(Number(first)) || 1);
|
|
830
831
|
|
|
831
|
-
for (let page =
|
|
832
|
+
for (let page = start; page < start + Math.max(1, Math.floor(pages)) && !complete; page += 1) {
|
|
832
833
|
requests += 1;
|
|
833
834
|
|
|
834
835
|
const data = await archive.query(rangeQuery(account, { aliases, from, page, to }));
|