Skip to content

Commit

Permalink
Merge branch '50-cardano-koios-network-fix-bug' into 'dev'
Browse files Browse the repository at this point in the history
fix bug in CardanoKoiosNetwork

Closes #50

See merge request ergo/rosen-bridge/rosen-chains!56
  • Loading branch information
vorujack committed Sep 11, 2023
2 parents 574e084 + fcf185a commit f876ed4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/networks/cardano-koios/lib/CardanoKoiosNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class CardanoKoiosNetwork extends AbstractCardanoNetwork {
throw new UnexpectedApiError(baseError + e.message);
}
});
return boxes.slice(offset, limit);
return boxes.slice(offset, offset + limit);
};

/**
Expand All @@ -326,7 +326,7 @@ class CardanoKoiosNetwork extends AbstractCardanoNetwork {
isBoxUnspentAndValid = async (boxId: string): Promise<boolean> => {
const [txId, index] = boxId.split('.');
const tx = await this.client
.postTxUtxos({ _tx_hashes: [txId] })
.postTxInfo({ _tx_hashes: [txId] })
.then((res) => (res.length === 0 ? undefined : res[0]))
.catch((e) => {
const baseError = `Failed to get transaction [${txId}] UTxOs from Koios: `;
Expand Down Expand Up @@ -401,7 +401,7 @@ class CardanoKoiosNetwork extends AbstractCardanoNetwork {
getUtxo = async (boxId: string): Promise<CardanoUtxo> => {
const [txId, index] = boxId.split('.');
const tx = await this.client
.postTxUtxos({ _tx_hashes: [txId] })
.postTxInfo({ _tx_hashes: [txId] })
.then((res) => res[0])
.catch((e) => {
const baseError = `Failed to get transaction [${txId}] UTxOs from Koios: `;
Expand Down
2 changes: 1 addition & 1 deletion packages/networks/cardano-koios/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rosen-chains/cardano-koios-network",
"version": "0.1.14",
"version": "0.1.15",
"description": "cardano koios network package for rosen cardano chain",
"main": "dist/lib/index.js",
"types": "dist/lib/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ export const mockPostAddressInfo = (utxoSet: AddressInfoItemUtxoSetItem[]) => {
};

/**
* mock `postTxUtxos` and `postCredentialUtxos` of cardano koios client
* mock only inputs and outputs of `postTxInfo` api and `postCredentialUtxos` of cardano koios client
*/
export const mockUtxoValidation = (
txUtxos: TxUtxos | undefined,
credentialUtxos: CredentialUtxos
) => {
jest.mocked(cardanoKoiosClientFactory).mockReturnValueOnce({
postTxUtxos: async () => (txUtxos ? [txUtxos] : []),
postTxInfo: async () => (txUtxos ? [txUtxos] : []),
postCredentialUtxos: async () => credentialUtxos,
} as any);
};
Expand All @@ -162,10 +162,10 @@ export const mockPostAddressInfoNoHistory = () => {
};

/**
* mock `postTxUtxos` of cardano koios client
* mock only inputs and outputs of cardano koios client `postTxInfo` api
*/
export const mockPostTxUtxos = (utxos: TxUtxos) => {
jest.mocked(cardanoKoiosClientFactory).mockReturnValueOnce({
postTxUtxos: async () => [utxos],
postTxInfo: async () => [utxos],
} as any);
};

0 comments on commit f876ed4

Please sign in to comment.