Skip to content

Commit 67553ff

Browse files
authored
Add utils module with script to display top address balances
* feat: add utils module, get first balances * fix: add dummy node balance for now * fix: consider block height * feat: allow querying node addr balance by block height * feat: query nodes for balances via RPC * feat: calculate absolute balance delta * fix: consider locked node balance * fix: ignore utils dir on main lint config * chore: print usage
1 parent e790109 commit 67553ff

File tree

8 files changed

+690
-2
lines changed

8 files changed

+690
-2
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ src/tests-rosetta-cli/
1515
src/tests-bns/
1616
client/src/
1717
config/
18+
utils/src/

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
ecmaVersion: 2020,
1010
sourceType: 'module',
1111
},
12-
ignorePatterns: ['lib/*', 'client/*'],
12+
ignorePatterns: ['lib/*', 'client/*', 'utils/*'],
1313
rules: {
1414
'prettier/prettier': 'error',
1515

src/core-rpc/client.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface CoreRpcAccountInfo {
88
balance: string;
99
/** Hex-prefixed binary blob. */
1010
balance_proof: string;
11+
locked: string;
1112
nonce: number;
1213
/** Hex-prefixed binary blob. */
1314
nonce_proof: string;
@@ -150,7 +151,11 @@ export class StacksCoreRpcClient {
150151
return result;
151152
}
152153

153-
async getAccount(principal: string, atUnanchoredChainTip = false): Promise<CoreRpcAccountInfo> {
154+
async getAccount(
155+
principal: string,
156+
atUnanchoredChainTip = false,
157+
indexBlockHash?: string
158+
): Promise<CoreRpcAccountInfo> {
154159
const requestOpts: RequestOpts = {
155160
method: 'GET',
156161
queryParams: {
@@ -160,6 +165,8 @@ export class StacksCoreRpcClient {
160165
if (atUnanchoredChainTip) {
161166
const info = await this.getInfo();
162167
requestOpts.queryParams!.tip = info.unanchored_tip;
168+
} else if (indexBlockHash) {
169+
requestOpts.queryParams!.tip = indexBlockHash;
163170
}
164171
const result = await this.fetchJson<CoreRpcAccountInfo>(
165172
`v2/accounts/${principal}`,

utils/.eslintrc.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
root: true,
3+
extends: ['@stacks/eslint-config', 'prettier'],
4+
parser: '@typescript-eslint/parser',
5+
plugins: ['@typescript-eslint', 'prettier'],
6+
parserOptions: {
7+
tsconfigRootDir: __dirname,
8+
project: './tsconfig.json',
9+
ecmaVersion: 2017,
10+
sourceType: 'module',
11+
},
12+
ignorePatterns: ['lib/*', 'test/*', '.eslintrc.js'],
13+
rules: {
14+
'prettier/prettier': 'error',
15+
'@typescript-eslint/no-non-null-assertion': 'off',
16+
'@typescript-eslint/explicit-module-boundary-types': 'off',
17+
'@typescript-eslint/restrict-template-expressions': 'off',
18+
},
19+
};

0 commit comments

Comments
 (0)