diff --git a/src/chains/ergo/ergo.controller.ts b/src/chains/ergo/ergo.controller.ts index 999690a04d..77ee4f7c82 100644 --- a/src/chains/ergo/ergo.controller.ts +++ b/src/chains/ergo/ergo.controller.ts @@ -8,6 +8,8 @@ import { import { AssetsResponse, BalanceRequest, + PollRequest, + PollResponse, PoolRequest, PoolResponse, TransferRequest, @@ -22,7 +24,13 @@ export class ErgoController { return ergo.getPool(req.poolId).info; } + static async poll(ergo: Ergo, req: PollRequest): Promise<PollResponse> { + if (!ergo.ready) { + await ergo.init(); + } + return await ergo.getTx(req.txId); + } static async balances(chain: Ergo, request: BalanceRequest) { if (!chain.ready) { await chain.init(); diff --git a/src/chains/ergo/ergo.ts b/src/chains/ergo/ergo.ts index 0eb9650c9a..30d8d50faf 100644 --- a/src/chains/ergo/ergo.ts +++ b/src/chains/ergo/ergo.ts @@ -650,4 +650,8 @@ export class Ergo { public getPool(id: string): Pool { return <Pool>this.ammPools.find((ammPool) => ammPool.id === id); } + + public async getTx(id: string): Promise<ErgoTx> { + return await this._node.getTxsById(id); + } } diff --git a/src/chains/ergo/interfaces/requests.interface.ts b/src/chains/ergo/interfaces/requests.interface.ts index 9c3974802e..77c0625e78 100644 --- a/src/chains/ergo/interfaces/requests.interface.ts +++ b/src/chains/ergo/interfaces/requests.interface.ts @@ -1,4 +1,4 @@ -import { AssetAmount } from '@patternglobal/ergo-sdk'; +import { AssetAmount, ErgoTx } from '@patternglobal/ergo-sdk'; import { NetworkSelectionRequest } from '../../../services/common-interfaces'; import { ErgoAsset, ErgoBoxAsset } from './ergo.interface'; @@ -16,6 +16,11 @@ export interface PoolResponse { feeDenom: bigint; } +export interface PollResponse extends ErgoTx {} +export interface PollRequest { + txId: string; +} + export interface BalanceRequest extends NetworkSelectionRequest { address: string; // the users public key } diff --git a/src/chains/ergo/node.service.ts b/src/chains/ergo/node.service.ts index 163f89b0b8..a02af4522e 100644 --- a/src/chains/ergo/node.service.ts +++ b/src/chains/ergo/node.service.ts @@ -9,6 +9,7 @@ import { ErgoStateContext, PreHeader, } from 'ergo-lib-wasm-nodejs'; +import { ErgoTx } from '@patternglobal/ergo-sdk'; /** * This class allows you to access elements of a node @@ -102,4 +103,7 @@ export class NodeService { tx, ); } + async getTxsById(id: string): Promise<ErgoTx> { + return this.request<ErgoTx>('GET', `/blockchain/transaction/byId/${id}`); + } }