Skip to content

Commit 4bf5e67

Browse files
authored
feat(transactionFees): add transactionByteFee function and schema (#479)
1 parent 384c306 commit 4bf5e67

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

packages/auto-consensus/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export * from './info'
88
export * from './position'
99
export * from './remark'
1010
export * from './staking'
11+
export * from './transactionFees'
1112
export * from './transfer'
1213

1314
export * from './types'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { ApiPromise } from '@polkadot/api'
2+
import { z } from 'zod'
3+
4+
const TransactionByteFeeSchema = z.object({
5+
current: z.number(),
6+
next: z.number(),
7+
})
8+
9+
export const transactionByteFee = async (api: ApiPromise) => {
10+
await api.isReady
11+
12+
// Query transactionFees.transactionByteFee
13+
const transactionByteFee = await api.query.transactionFees
14+
.transactionByteFee()
15+
.then((v) => TransactionByteFeeSchema.parse(v.toJSON()))
16+
17+
return transactionByteFee
18+
}

0 commit comments

Comments
 (0)