Skip to content

Commit

Permalink
fix: use string type for tx fee
Browse files Browse the repository at this point in the history
  • Loading branch information
Redm4x committed Aug 13, 2024
1 parent 8398797 commit a1a19ff
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1/addresses/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const route = createRoute({
error: z.string().nullable(),
gasUsed: z.number(),
gasWanted: z.number(),
fee: z.number(), // TODO CHECK
fee: z.number(),
memo: z.string().nullable(),
isSigner: z.boolean(),
messages: z.array(
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/services/db/blocksService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function getBlock(height: number) {
hash: tx.hash,
isSuccess: !tx.hasProcessingError,
error: tx.hasProcessingError ? tx.log : null,
fee: tx.fee,
fee: parseInt(tx.fee),
datetime: block.datetime,
messages: tx.messages.map(message => ({
id: message.id,
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/services/db/transactionsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function getTransactions(limit: number) {
error: tx.hasProcessingError ? tx.log : null,
gasUsed: tx.gasUsed,
gasWanted: tx.gasWanted,
fee: tx.fee,
fee: parseInt(tx.fee),
memo: tx.memo,
messages: tx.messages.map(msg => ({
id: msg.id,
Expand Down Expand Up @@ -84,7 +84,7 @@ export async function getTransaction(hash: string): Promise<ApiTransactionRespon
error: tx.hasProcessingError ? tx.log : null,
gasUsed: tx.gasUsed,
gasWanted: tx.gasWanted,
fee: tx.fee,
fee: parseInt(tx.fee),
memo: tx.memo,
messages: messages.map(msg => ({
id: msg.id,
Expand Down Expand Up @@ -138,7 +138,7 @@ export async function getTransactionByAddress(address: string, skip: number, lim
error: tx.hasProcessingError ? tx.log : null,
gasUsed: tx.gasUsed,
gasWanted: tx.gasWanted,
fee: tx.fee,
fee: parseInt(tx.fee),
memo: tx.memo,
isSigner: tx.addressReferences.some(ar => ar.type === "Signer"),
messages: tx.messages.map(msg => ({
Expand Down
7 changes: 5 additions & 2 deletions apps/indexer/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ CREATE INDEX IF NOT EXISTS block_totaluusdspent_is_null

## v1.3.0

Add columns to support multi-denom deployments ([PR #5](https://github.com/akash-network/console/pull/5))
Add columns to support multi-denom deployments ([PR #5](https://github.com/akash-network/console/pull/5)) and change fee type to numeric ([PR #40 in old repo](https://github.com/maxmaxlabs/cloudmos-mono/pull/40))

```
ALTER TABLE public.block ADD COLUMN "totalUUsdcSpent" double precision DEFAULT 0;
Expand All @@ -304,4 +304,7 @@ ALTER TABLE public.deployment ADD COLUMN denom character varying(255) DEFAULT 'u
ALTER TABLE public.deployment ALTER COLUMN denom DROP DEFAULT;
ALTER TABLE public.lease ADD COLUMN denom character varying(255) DEFAULT 'uakt' COLLATE pg_catalog."default" NOT NULL;
ALTER TABLE public.lease ALTER COLUMN denom DROP DEFAULT;
```
ALTER TABLE IF EXISTS public.transaction
ALTER COLUMN "fee" TYPE numeric(30,0);
```
2 changes: 1 addition & 1 deletion apps/indexer/src/chain/chainSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ async function insertBlocks(startHeight: number, endHeight: number) {
height: i,
msgCount: msgs.length,
index: txIndex,
fee: decodedTx.authInfo.fee.amount.length > 0 ? parseInt(decodedTx.authInfo.fee.amount[0].amount) : 0,
fee: decodedTx.authInfo.fee.amount.length > 0 ? decodedTx.authInfo.fee.amount[0].amount : "0",
memo: decodedTx.body.memo,
hasProcessingError: !!txJson.code,
log: txJson.code ? txJson.log : null,
Expand Down
2 changes: 1 addition & 1 deletion packages/database/dbSchemas/base/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Transaction extends Model {
@Column multisigThreshold?: number;
@Required @Column gasUsed: number;
@Required @Column gasWanted: number;
@Required @Column(DataTypes.DECIMAL(30, 0)) fee: number;
@Required @Column(DataTypes.DECIMAL(30, 0)) fee: string;
@Required @Column(DataTypes.TEXT) memo: string;
@Required @Default(false) @Column isProcessed: boolean;
@Required @Default(false) @Column hasProcessingError: boolean;
Expand Down

0 comments on commit a1a19ff

Please sign in to comment.