kodadot / kodadot/packages

Wrappers for common functions

Open
#30 1 comment 0 reactions 0 assignees View on GitHub
api
Dominant language
TypeScript
Stars
4
Forks
11
PR merge metrics
No merged PRs in 30d

Description

It would be nice to have a wrapper for common functions of ->

```ts
class Query {
static async getNonce(api: ApiPromise, address: string): Promise {
const { nonce } = await api.query.system.account(address)
return nonce.toBn()
}

static async getTokenBalance(
api: ApiPromise,
accountId: string
): Promise {
const { availableBalance } = await api.derive.balances.all(accountId)
return availableBalance.toString()
}

static getChainProperties(api: ApiPromise): ChainProperties {
const { chainSS58, chainDecimals, chainTokens } = api.registry
return {
ss58Format: correctFormat(chainSS58),
tokenDecimals: chainDecimals[0] || 12,
tokenSymbol: chainTokens[0] || 'Unit',
}
}
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the package entry point where a Query wrapper around ApiPromise would belong, then compare the proposed getNonce, getTokenBalance, and getChainProperties methods with existing APIs. Done means the agreed common-function wrappers are implemented with the shown return values and their behavior is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.