Skip to content

Commit

Permalink
fix: read beansOwing correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
samsiegart committed Jun 21, 2023
1 parent a9aee21 commit 9c22de4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
10 changes: 8 additions & 2 deletions wallet/src/rpc/src/batchQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,19 @@ export const batchVstorageQuery = (
}

const value = JSON.parse(data.value);
const latestValueStr = Object.hasOwn(value, 'values')
? value.values[value.values.length - 1]
: value;
const parsed = JSON.parse(latestValueStr);
const unserialized = Object.hasOwn(parsed, 'slots')
? unserialize(parsed)
: parsed;

const latestValueStr = value.values[value.values.length - 1];
return [
pathToKey(paths[index]),
{
blockHeight: value.blockHeight,
value: unserialize(JSON.parse(latestValueStr)),
value: unserialized,
},
];
}),
Expand Down
15 changes: 10 additions & 5 deletions wallet/src/util/WalletBackendAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,14 @@ export const makeWalletBridgeFromFollowers = (
watcher.watchLatest(
[
AgoricChainStoragePathKind.Data,
`published.beansOwing.${smartWalletKey.address}`,
`beansOwing.${smartWalletKey.address}`,
],
value => beansOwingUpdater.updateState(Number(value)),
value => {
beansOwingUpdater.updateState(Number(value));
},
err => {
console.error('error watching beansOwing', err);
},
),
);
};
Expand Down Expand Up @@ -309,7 +314,7 @@ export const makeWalletBridgeFromFollowers = (
);
});

const watchPendingOffers = async () => {
const watchPendingOffers = () => {
stopWatchingHooks.push(
watcher.watchLatest<Partial<CurrentWalletRecord>>(
[
Expand All @@ -328,8 +333,8 @@ export const makeWalletBridgeFromFollowers = (
const fetchCurrent = async () => {
const resolvedFollower = await currentFollower;
await assertHasData(resolvedFollower);
void watchBeansOwing();
void watchPendingOffers();
watchBeansOwing();
watchPendingOffers();
watchChainBalances();

const latestIterable = await E(resolvedFollower).getLatestIterable();
Expand Down

0 comments on commit 9c22de4

Please sign in to comment.