Skip to content

Commit

Permalink
fix(api): update getting program pages func (#1544)
Browse files Browse the repository at this point in the history
  • Loading branch information
osipov-mit authored May 22, 2024
1 parent e4971f6 commit 41a1b3d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
8 changes: 8 additions & 0 deletions api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.38.1

_05/22/2024_

### Changes
https://github.com/gear-tech/gear-js/pull/1544
- Update getting program pages according to https://github.com/gear-tech/gear/pull/3791

## 0.38.0

_04/26/2024_
Expand Down
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gear-js/api",
"version": "0.38.0",
"version": "0.38.1",
"description": "A JavaScript library that provides functionality to connect GEAR Component APIs.",
"main": "cjs/index.js",
"module": "index.js",
Expand Down
8 changes: 4 additions & 4 deletions api/src/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ export class GearProgramStorage {

const args = this._api.specVersion >= SPEC_VERSION.V1100 ? [programId, program.memoryInfix] : [programId];

for (const page of program.pagesWithData) {
pages[page.toNumber()] = u8aToU8a(
await this._api.provider.send('state_getStorage', [query.key(...args, page), at]),
);
for (const [start, end] of program.pagesWithData.inner) {
for (let page = start.toNumber(); page <= end.toNumber(); page++) {
pages[page] = u8aToU8a(await this._api.provider.send('state_getStorage', [query.key(...args, page), at]));
}
}
return pages;
}
Expand Down
13 changes: 10 additions & 3 deletions api/src/types/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,12 @@ export interface GearCommonProgram extends Enum {
readonly type: 'Active' | 'Exited' | 'Terminated';
}

/** @name GearCommonActiveProgram (581) */
/** @name GearCommonActiveProgram (593) */
export interface GearCommonActiveProgram extends Struct {
readonly allocations: BTreeSet<u32>;
readonly pagesWithData: BTreeSet<u32>;
readonly allocations: {
readonly inner: BTreeMap<u32, u32>;
} & Struct;
readonly pagesWithData: NumeratedTreeIntervalsTree;
readonly memoryInfix: u32;
readonly gasReservationMap: BTreeMap<GearCoreIdsReservationId, GearCoreReservationGasReservationSlot>;
readonly codeHash: H256;
Expand All @@ -576,6 +578,11 @@ export interface GearCommonActiveProgram extends Struct {
readonly expirationBlock: u32;
}

/** @name NumeratedTreeIntervalsTree (598) */
export interface NumeratedTreeIntervalsTree extends Struct {
readonly inner: BTreeMap<u32, u32>;
}

/** @name GearCoreReservationGasReservationSlot (586) */
export interface GearCoreReservationGasReservationSlot extends Struct {
readonly amount: u64;
Expand Down

0 comments on commit 41a1b3d

Please sign in to comment.