Skip to content

Commit 405ed25

Browse files
authored
feat(portfolio-planner): Dump balances for addresses with activity (#11707)
2 parents 48af784 + 66bc9f9 commit 405ed25

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

packages/portfolio-planner/src/cosmos-rest-client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ const CHAIN_CONFIGS: Record<string, ChainConfig> = {
3535
restEndpoint: 'https://noble-api.polkachu.com',
3636
name: 'Noble',
3737
},
38+
agoric: {
39+
chainId: 'agoric-3',
40+
restEndpoint: 'https://main.api.agoric.net',
41+
name: 'Agoric',
42+
},
3843
};
3944

4045
export class CosmosRestClient {

packages/portfolio-planner/src/engine.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="ses" />
22
/* eslint-env node */
3+
import { inspect } from 'node:util';
34
import { q, Fail } from '@endo/errors';
45
import { fromUniqueEntries } from '@agoric/internal';
56
import type { CosmosCommand } from './cosmos-cmd.js';
@@ -123,6 +124,10 @@ export const startEngine = async ({
123124
// Continue with limited functionality
124125
}
125126

127+
const agoricInfo = await cosmosRest.getChainInfo('agoric');
128+
const agoricChainId = (agoricInfo as any)?.default_node_info?.network;
129+
console.warn('Retrieved info for Agoric chain', agoricChainId);
130+
126131
await rpc.opened();
127132
try {
128133
// console.warn('RPC client opened:', rpc);
@@ -152,6 +157,7 @@ export const startEngine = async ({
152157
...(respEvents['transfer.sender'] || []),
153158
]),
154159
];
160+
155161
const eventRecords = Object.entries(respData).flatMap(
156162
([key, value]: [string, any]) => {
157163
// We care about result_begin_block/result_end_block/etc.
@@ -191,7 +197,24 @@ export const startEngine = async ({
191197
return [{ path, value: attributes.value }];
192198
});
193199

194-
console.log({ addrsWithActivity, portfolioVstorageEvents });
200+
const addrBalances = Object.fromEntries(
201+
await Promise.all(
202+
addrsWithActivity.map(async addr => {
203+
const balancesResp = await cosmosRest.getAccountBalances(
204+
'agoric',
205+
addr,
206+
);
207+
return [addr, balancesResp?.balances];
208+
}),
209+
),
210+
);
211+
212+
console.log(
213+
inspect(
214+
{ addrsWithActivity, addrBalances, portfolioVstorageEvents },
215+
{ depth: 10 },
216+
),
217+
);
195218
}
196219
} finally {
197220
console.warn('Terminating...');

0 commit comments

Comments
 (0)