From c5dbd6b242b0fbcfa89a767070a2b35b958e078b Mon Sep 17 00:00:00 2001 From: Faberto Date: Tue, 30 Jan 2024 09:36:29 +0100 Subject: [PATCH] backend --- backend/src/blockchain.ts | 18 +++++++++--------- backend/src/nodecontroller.ts | 4 ++-- backend/tsconfig.json | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/backend/src/blockchain.ts b/backend/src/blockchain.ts index 732efce..85b9465 100644 --- a/backend/src/blockchain.ts +++ b/backend/src/blockchain.ts @@ -3,9 +3,8 @@ import type { CallResult, PartialBlock, Transaction, - Validator, } from 'nimiq-rpc-client-ts'; -import Client from 'nimiq-rpc-client-ts'; +import { Client } from 'nimiq-rpc-client-ts'; import { Buffer } from 'node:buffer'; import { getDollarPriceHistory, lunaToNim } from './pricing.js'; @@ -49,19 +48,19 @@ export function convertAddressForRPC(address: string): Address { * @param address * @returns */ - +/* export async function getValidatorStatus( address: Address, ): Promise { const client = getClient(); const validator: CallResult = - await client.validator.byAddress(address); + await client.blockchain.getValidatorByAddress(address); if (validator.error) return ValidatorStatus.UNKNOWN; if (validator.data.inactivityFlag) return ValidatorStatus.INACTIVE; return ValidatorStatus.ACTIVE; -} +} */ /** * Gets the Block at a specific block number @@ -71,7 +70,7 @@ export async function getValidatorStatus( export async function getBlock(blockNumber: number) { const client = getClient(); const block: CallResult = - await client.block.getByNumber(blockNumber); + await client.blockchain.getBlockByNumber(blockNumber); return block.data; } @@ -104,7 +103,7 @@ export async function getPaymentStatus(address: Address): Promise { // Format extra data: Staqe,NQ61 AE12 FJ43 QNP4 SHBJ F7XJ RH4Y FX3T X2N4 const client = getClient(); const payments: CallResult = - (await client.transaction.getByAddress(paymentReciver)) as any; + (await client.blockchain.getTransactionsByAddress(paymentReciver)) as any; const valdatorPayemnts = []; for (const payment of payments.data) { // Change of .data to .recipientData not yet implemented by the rpc client @@ -144,13 +143,14 @@ export async function getPaymentStatus(address: Address): Promise { export async function getTotalRewards(validatorAddress: Address) { const client = getClient(); - const validator = await client.validator.byAddress(validatorAddress); + const validator = + await client.blockchain.getValidatorByAddress(validatorAddress); if (validator.error) { console.log(`Failed to get Vlaidator ${validatorAddress}`); return 0; } const transactions: CallResult = - (await client.transaction.getByAddress( + (await client.blockchain.getTransactionsByAddress( validator.data.rewardAddress, )) as CallResult; let total = 0; diff --git a/backend/src/nodecontroller.ts b/backend/src/nodecontroller.ts index 65dd45d..3a53672 100644 --- a/backend/src/nodecontroller.ts +++ b/backend/src/nodecontroller.ts @@ -1,6 +1,6 @@ import * as k8s from '@kubernetes/client-node'; import * as yaml from 'js-yaml'; -import Client from 'nimiq-rpc-client-ts'; +import { Client } from 'nimiq-rpc-client-ts'; import * as crypto from 'node:crypto'; import { promises as fs } from 'node:fs'; @@ -140,7 +140,7 @@ export async function removeValidator(address: string) { export async function getConsensusStatus(address: string) { const url = new URL(`http://staqe-node-${kubernetizeAddress(address)}:8648`); const client = new Client(url); - const response = await client.modules.consensus.isConsensusEstablished(); + const response = await client.consensus.isConsensusEstablished(); if (response.data !== undefined) { return response.data ? 'running' : 'creating'; } else { diff --git a/backend/tsconfig.json b/backend/tsconfig.json index 16319fa..aae928a 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -12,8 +12,8 @@ "rootDir": "src", "baseUrl": ".", "paths": { - "*": ["node_modules/*", "src/types/*"] - } + "*": ["node_modules/*", "src/types/*"], + }, }, - "include": ["src/**/*"] + "include": ["src/**/*"], }