Skip to content

Commit

Permalink
chore: fix KLY import after upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
bludnic committed Aug 29, 2024
1 parent d913508 commit 7f23667
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/lib/__tests__/lisk/lisk-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Some crypto libs throw errors when using `jsdom` environment

import { KLY_MIN_FEE_PER_BYTE } from '@/lib/klayr'
import { convertBeddowsToKLY } from '@klayr/transactions'
import { convertBeddowsTokly } from '@klayr/transactions'
import { describe, it, expect } from 'vitest'
import { Cryptos } from '@/lib/constants'
import { estimateFee, getAccount } from '@/lib/klayr/klayr-utils'
Expand All @@ -23,7 +23,7 @@ describe('lisk-utils', () => {
const messageFee = BigInt(data.length) * BigInt(KLY_MIN_FEE_PER_BYTE)
const expectedFee = minimalFee + messageFee

expect(estimateFee({ data })).toBe(convertBeddowsToKLY(expectedFee.toString()))
expect(estimateFee({ data })).toBe(convertBeddowsTokly(expectedFee.toString()))
})
})
})
8 changes: 4 additions & 4 deletions src/lib/klayr/klayr-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DecodedTransaction, Transaction } from './types/klayr'
import { codec } from '@klayr/codec'
import * as cryptography from '@klayr/cryptography'
import networks from '@/lib/klayr/networks'
import { convertBeddowsToKLY } from '@klayr/transactions'
import { convertBeddowsTokly } from '@klayr/transactions'
import * as transactions from '@klayr/transactions'
import { Buffer } from 'buffer'
import pbkdf2 from 'pbkdf2'
Expand Down Expand Up @@ -148,8 +148,8 @@ export function createUnsignedTransaction(
nonce: number | string,
data = ''
) {
const amountString = transactions.convertKLYToBeddows((+amount).toFixed(KLY_DECIMALS))
const feeString = transactions.convertKLYToBeddows((+fee).toFixed(KLY_DECIMALS))
const amountString = convertBeddowsTokly((+amount).toFixed(KLY_DECIMALS))
const feeString = convertBeddowsTokly((+fee).toFixed(KLY_DECIMALS))
const nonceString = nonce.toString()

// Adjust the values of the unsigned transaction manually
Expand Down Expand Up @@ -259,5 +259,5 @@ export function estimateFee(params?: EstimateFeeParams) {

const totalFee = fee + transferToNewAccountFee

return convertBeddowsToKLY(totalFee.toString())
return convertBeddowsTokly(totalFee.toString())
}
6 changes: 3 additions & 3 deletions src/lib/nodes/kly-indexer/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getMillisTimestamp } from '@/lib/klayr/klayr-utils'
import { convertBeddowsToKLY } from '@klayr/transactions'
import { convertBeddowsTokly } from '@klayr/transactions'
import { TransactionStatus, TransactionStatusType } from '@/lib/constants'
import { Transaction } from './types/api/transactions/transaction'
import { KlyTransaction } from '@/lib/nodes/types/transaction'
Expand All @@ -19,14 +19,14 @@ export function normalizeTransaction(
return {
id: transaction.id,
hash: transaction.id,
fee: Number(convertBeddowsToKLY(transaction.fee)),
fee: Number(convertBeddowsTokly(transaction.fee)),
status: mapStatus(transaction.executionStatus),
data: transaction.params.data,
timestamp: isFinalized ? getMillisTimestamp(transaction.block.timestamp) : undefined, // block timestamp
direction,
senderId: transaction.sender.address,
recipientId: transaction.params.recipientAddress,
amount: Number(convertBeddowsToKLY(transaction.params.amount)),
amount: Number(convertBeddowsTokly(transaction.params.amount)),
height: isFinalized ? transaction.block.height : undefined,
nonce: transaction.nonce,
module: 'token',
Expand Down
4 changes: 2 additions & 2 deletions src/lib/nodes/kly/KlyClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { convertBeddowsToKLY } from '@klayr/transactions'
import { convertBeddowsTokly } from '@klayr/transactions'
import { KLY_TOKEN_ID } from '@/lib/klayr'
import { RpcMethod, RpcResults } from './types/api'
import { KlyNode } from './KlyNode'
Expand Down Expand Up @@ -38,7 +38,7 @@ export class KlyClient extends Client<KlyNode> {
address
})

return Number(convertBeddowsToKLY(availableBalance))
return Number(convertBeddowsTokly(availableBalance))
}

async getHeight() {
Expand Down

0 comments on commit 7f23667

Please sign in to comment.