From fd8992ffd0af77b93bc264e8c067b7f5053f4096 Mon Sep 17 00:00:00 2001 From: HFazelinia Date: Mon, 6 Nov 2023 09:14:44 +0000 Subject: [PATCH 1/5] update CardanoChain to fetch protocol params from network instead of using hard coded params --- package-lock.json | 4 +-- packages/chains/cardano/lib/CardanoChain.ts | 31 +++++++++++++++++-- packages/chains/cardano/lib/constants.ts | 29 +---------------- .../lib/network/AbstractCardanoNetwork.ts | 8 ++++- packages/chains/cardano/lib/types.ts | 11 +++++++ packages/chains/cardano/package.json | 2 +- .../tests/network/TestCardanoNetwork.ts | 6 +++- packages/chains/cardano/tests/testUtils.ts | 10 ++++++ packages/networks/cardano-koios/package.json | 2 +- 9 files changed, 67 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index 834cc66..f4122d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8426,7 +8426,7 @@ }, "packages/chains/cardano": { "name": "@rosen-chains/cardano", - "version": "2.2.1", + "version": "2.3.0", "license": "GPL-3.0", "dependencies": { "@emurgo/cardano-serialization-lib-nodejs": "^11.3.1", @@ -8484,7 +8484,7 @@ }, "packages/networks/cardano-koios": { "name": "@rosen-chains/cardano-koios-network", - "version": "3.0.0", + "version": "3.1.0", "license": "GPL-3.0", "dependencies": { "@emurgo/cardano-serialization-lib-nodejs": "^11.3.1", diff --git a/packages/chains/cardano/lib/CardanoChain.ts b/packages/chains/cardano/lib/CardanoChain.ts index a1cb0a2..d450c11 100644 --- a/packages/chains/cardano/lib/CardanoChain.ts +++ b/packages/chains/cardano/lib/CardanoChain.ts @@ -31,7 +31,7 @@ import JSONBigInt from '@rosen-bridge/json-bigint'; import CardanoTransaction from './CardanoTransaction'; import CardanoUtils from './CardanoUtils'; import cardanoUtils from './CardanoUtils'; -import { CARDANO_CHAIN, txBuilderConfig } from './constants'; +import { CARDANO_CHAIN } from './constants'; import AbstractCardanoNetwork from './network/AbstractCardanoNetwork'; import Serializer from './Serializer'; import { @@ -159,7 +159,9 @@ class CardanoChain extends AbstractUtxoChain { } const bankBoxes = coveredBoxes.boxes; - const txBuilder = CardanoWasm.TransactionBuilder.new(txBuilderConfig); + const txBuilder = CardanoWasm.TransactionBuilder.new( + await this.getTxBuilderConfig() + ); let orderValue = BigNum.zero(); const orderAssets: Map = new Map(); @@ -777,6 +779,31 @@ class CardanoChain extends AbstractUtxoChain { */ PaymentTransactionFromJson = (jsonString: string): CardanoTransaction => CardanoTransaction.fromJson(jsonString); + + /** + * generates transaction builder config using protocol params + * @returns TransactionBuilderConfig + */ + protected getTxBuilderConfig = + async (): Promise => { + const params = await this.network.getProtocolParameters(); + return CardanoWasm.TransactionBuilderConfigBuilder.new() + .fee_algo( + CardanoWasm.LinearFee.new( + CardanoWasm.BigNum.from_str(params.minFeeA.toString()), + CardanoWasm.BigNum.from_str(params.minFeeB.toString()) + ) + ) + .pool_deposit(CardanoWasm.BigNum.from_str(params.poolDeposit)) + .key_deposit(CardanoWasm.BigNum.from_str(params.keyDeposit)) + .coins_per_utxo_byte( + CardanoWasm.BigNum.from_str(params.coinsPerUtxoSize) + ) + .max_value_size(params.maxValueSize) + .max_tx_size(params.maxTxSize) + .prefer_pure_change(true) + .build(); + }; } export default CardanoChain; diff --git a/packages/chains/cardano/lib/constants.ts b/packages/chains/cardano/lib/constants.ts index 11ccc00..e8fdbe8 100644 --- a/packages/chains/cardano/lib/constants.ts +++ b/packages/chains/cardano/lib/constants.ts @@ -1,31 +1,4 @@ -import * as CardanoWasm from '@emurgo/cardano-serialization-lib-nodejs'; - const CARDANO_CHAIN = 'cardano'; const ADA = 'ada'; -const protocolParameters = { - minFeeA: CardanoWasm.BigNum.from_str('44'), - minFeeB: CardanoWasm.BigNum.from_str('155381'), - poolDeposit: CardanoWasm.BigNum.from_str('500000000'), - keyDeposit: CardanoWasm.BigNum.from_str('2000000'), - maxValueSize: 4000, - maxTxSize: 8000, - coinsPerUtxoWord: CardanoWasm.BigNum.from_str('34482'), -}; - -const linearFee = CardanoWasm.LinearFee.new( - protocolParameters.minFeeA, - protocolParameters.minFeeB -); - -const txBuilderConfig: CardanoWasm.TransactionBuilderConfig = - CardanoWasm.TransactionBuilderConfigBuilder.new() - .fee_algo(linearFee) - .pool_deposit(protocolParameters.poolDeposit) - .key_deposit(protocolParameters.keyDeposit) - .max_value_size(protocolParameters.maxValueSize) - .max_tx_size(protocolParameters.maxTxSize) - .coins_per_utxo_word(protocolParameters.coinsPerUtxoWord) - .build(); - -export { txBuilderConfig, CARDANO_CHAIN, ADA }; +export { CARDANO_CHAIN, ADA }; diff --git a/packages/chains/cardano/lib/network/AbstractCardanoNetwork.ts b/packages/chains/cardano/lib/network/AbstractCardanoNetwork.ts index b6a392e..7872012 100644 --- a/packages/chains/cardano/lib/network/AbstractCardanoNetwork.ts +++ b/packages/chains/cardano/lib/network/AbstractCardanoNetwork.ts @@ -1,5 +1,5 @@ import { AbstractUtxoChainNetwork } from '@rosen-chains/abstract-chain'; -import { CardanoTx, CardanoUtxo } from '../types'; +import { CardanoProtocolParams, CardanoTx, CardanoUtxo } from '../types'; import { CardanoRosenExtractor } from '@rosen-bridge/rosen-extractor'; import { Transaction } from '@emurgo/cardano-serialization-lib-nodejs'; @@ -27,6 +27,12 @@ abstract class AbstractCardanoNetwork extends AbstractUtxoChainNetwork< * @returns the utxo in CardanoUtxo format */ abstract getUtxo: (boxId: string) => Promise; + + /** + * gets required parameters of Cardano Protocol + * @returns an object containing required protocol parameters + */ + abstract getProtocolParameters: () => Promise; } export default AbstractCardanoNetwork; diff --git a/packages/chains/cardano/lib/types.ts b/packages/chains/cardano/lib/types.ts index 798e556..e6275be 100644 --- a/packages/chains/cardano/lib/types.ts +++ b/packages/chains/cardano/lib/types.ts @@ -52,6 +52,16 @@ interface CardanoTransactionJsonModel extends PaymentTransactionJsonModel { inputUtxos: Array; } +interface CardanoProtocolParams { + minFeeA: number; + minFeeB: number; + poolDeposit: string; + keyDeposit: string; + maxValueSize: number; + maxTxSize: number; + coinsPerUtxoSize: string; +} + export { CardanoConfigs, CardanoAsset, @@ -61,4 +71,5 @@ export { CardanoTx, UtxoBoxesAssets, CardanoTransactionJsonModel, + CardanoProtocolParams, }; diff --git a/packages/chains/cardano/package.json b/packages/chains/cardano/package.json index 49b3f36..9e5ab68 100644 --- a/packages/chains/cardano/package.json +++ b/packages/chains/cardano/package.json @@ -1,6 +1,6 @@ { "name": "@rosen-chains/cardano", - "version": "2.2.1", + "version": "2.3.0", "description": "this project contains cardano chain for Rosen-bridge", "main": "dist/lib/index.js", "types": "dist/lib/index.d.ts", diff --git a/packages/chains/cardano/tests/network/TestCardanoNetwork.ts b/packages/chains/cardano/tests/network/TestCardanoNetwork.ts index 0ab8c87..7d76e9d 100644 --- a/packages/chains/cardano/tests/network/TestCardanoNetwork.ts +++ b/packages/chains/cardano/tests/network/TestCardanoNetwork.ts @@ -1,7 +1,8 @@ import { AbstractCardanoNetwork } from '../../lib'; import { BlockInfo, ConfirmationStatus } from '@rosen-chains/abstract-chain'; -import { CardanoTx, CardanoUtxo } from '../../lib/types'; +import { CardanoProtocolParams, CardanoTx, CardanoUtxo } from '../../lib/types'; import { CardanoRosenExtractor } from '@rosen-bridge/rosen-extractor'; +import { protocolParameters } from '../testUtils'; class TestCardanoNetwork extends AbstractCardanoNetwork { extractor = new CardanoRosenExtractor( @@ -61,6 +62,9 @@ class TestCardanoNetwork extends AbstractCardanoNetwork { getBlockInfo = (blockId: string): Promise => { throw Error('Not mocked'); }; + + getProtocolParameters = (): Promise => + Promise.resolve(protocolParameters); } export default TestCardanoNetwork; diff --git a/packages/chains/cardano/tests/testUtils.ts b/packages/chains/cardano/tests/testUtils.ts index cc4db88..bbf6fe2 100644 --- a/packages/chains/cardano/tests/testUtils.ts +++ b/packages/chains/cardano/tests/testUtils.ts @@ -115,3 +115,13 @@ export const adaToLovelace = (ada: number): bigint => BigInt((ada * 1000000).toString()); export const generateRandomId = (): string => randomBytes(32).toString('hex'); + +export const protocolParameters = { + minFeeA: 44, + minFeeB: 155381, + poolDeposit: '500000000', + keyDeposit: '2000000', + maxValueSize: 4000, + maxTxSize: 8000, + coinsPerUtxoSize: '4311', +}; diff --git a/packages/networks/cardano-koios/package.json b/packages/networks/cardano-koios/package.json index 7f3bd32..d7342e7 100644 --- a/packages/networks/cardano-koios/package.json +++ b/packages/networks/cardano-koios/package.json @@ -1,6 +1,6 @@ { "name": "@rosen-chains/cardano-koios-network", - "version": "3.0.0", + "version": "3.1.0", "description": "cardano koios network package for rosen cardano chain", "main": "dist/lib/index.js", "types": "dist/lib/index.d.ts", From 92057589e4b5b9c8428a28c12ba9a6b97ef260ce Mon Sep 17 00:00:00 2001 From: HFazelinia Date: Mon, 6 Nov 2023 09:30:11 +0000 Subject: [PATCH 2/5] add getProtocolParameters to cardano-koios --- package-lock.json | 2 +- .../cardano-koios/lib/CardanoKoiosNetwork.ts | 38 +++++++++++++++++++ packages/networks/cardano-koios/package.json | 2 +- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index f4122d9..33195b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8493,7 +8493,7 @@ "@rosen-bridge/rosen-extractor": "^1.0.1", "@rosen-bridge/tokens": "^1.0.0", "@rosen-chains/abstract-chain": "^2.2.1", - "@rosen-chains/cardano": "^2.2.1", + "@rosen-chains/cardano": "^2.3.0", "@rosen-clients/cardano-koios": "^2.0.0" }, "devDependencies": { diff --git a/packages/networks/cardano-koios/lib/CardanoKoiosNetwork.ts b/packages/networks/cardano-koios/lib/CardanoKoiosNetwork.ts index 528adcf..51377a4 100644 --- a/packages/networks/cardano-koios/lib/CardanoKoiosNetwork.ts +++ b/packages/networks/cardano-koios/lib/CardanoKoiosNetwork.ts @@ -10,6 +10,7 @@ import { CardanoUtxo, CardanoTx, CardanoAsset, + CardanoProtocolParams, } from '@rosen-chains/cardano'; import { RosenTokens } from '@rosen-bridge/tokens'; import { @@ -531,6 +532,43 @@ class CardanoKoiosNetwork extends AbstractCardanoNetwork { assets: input.asset_list.map(this.parseAssetList), }; }; + + /** + * gets required parameters of Cardano Protocol + * @returns an object containing required protocol parameters + */ + getProtocolParameters = async (): Promise => { + const allParams = await this.client.getEpochParams(); + const epochParams = allParams[0]; + this.logger.debug( + `requested 'getEpochParams'. index 0: ${JsonBigInt.stringify( + epochParams + )}` + ); + + if ( + !epochParams.min_fee_a || + !epochParams.min_fee_b || + !epochParams.pool_deposit || + !epochParams.key_deposit || + !epochParams.max_val_size || + !epochParams.max_tx_size || + !epochParams.coins_per_utxo_size + ) + throw new KoiosNullValueError( + `Some required Cardano protocol params are undefined or null ` + ); + + return { + minFeeA: epochParams.min_fee_a, + minFeeB: epochParams.min_fee_b, + poolDeposit: epochParams.pool_deposit, + keyDeposit: epochParams.key_deposit, + maxValueSize: epochParams.max_val_size, + maxTxSize: epochParams.max_tx_size, + coinsPerUtxoSize: epochParams.coins_per_utxo_size, + }; + }; } export default CardanoKoiosNetwork; diff --git a/packages/networks/cardano-koios/package.json b/packages/networks/cardano-koios/package.json index d7342e7..4728174 100644 --- a/packages/networks/cardano-koios/package.json +++ b/packages/networks/cardano-koios/package.json @@ -26,7 +26,7 @@ "@rosen-bridge/rosen-extractor": "^1.0.1", "@rosen-bridge/tokens": "^1.0.0", "@rosen-chains/abstract-chain": "^2.2.1", - "@rosen-chains/cardano": "^2.2.1", + "@rosen-chains/cardano": "^2.3.0", "@rosen-clients/cardano-koios": "^2.0.0" }, "devDependencies": { From 5ff5a27e8849f6f0815a0aad5d4990f97135feec Mon Sep 17 00:00:00 2001 From: HFazelinia Date: Tue, 7 Nov 2023 13:46:33 +0000 Subject: [PATCH 3/5] update koios client --- package-lock.json | 8 ++-- packages/networks/cardano-koios/package.json | 2 +- .../tests/CardanoKoiosNetwork.spec.ts | 25 +++++++++++ .../tests/mocked/CardanoKoiosClient.mock.ts | 9 ++++ .../networks/cardano-koios/tests/testData.ts | 45 +++++++++++++++++++ 5 files changed, 84 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 33195b2..dda8662 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2473,9 +2473,9 @@ "link": true }, "node_modules/@rosen-clients/cardano-koios": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@rosen-clients/cardano-koios/-/cardano-koios-2.0.0.tgz", - "integrity": "sha512-sTb8MY990w0GNYpYV9cXfBDsPGOzxbtfXl4tBSFzDskluc4ysaaZGNyzrQmohm1RuMD2Yh/L3CiaXqmBtDpJNA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@rosen-clients/cardano-koios/-/cardano-koios-2.0.1.tgz", + "integrity": "sha512-T910l/YkhAeunV6ubDcRrwMxlJncl1FFG0LZtzuTBATOLzknY/zANQGyKBwRImVj3JmHglSpHDQbstYinV4EnA==", "dependencies": { "@types/json-bigint": "^1.0.1", "axios": "^1.3.4", @@ -8494,7 +8494,7 @@ "@rosen-bridge/tokens": "^1.0.0", "@rosen-chains/abstract-chain": "^2.2.1", "@rosen-chains/cardano": "^2.3.0", - "@rosen-clients/cardano-koios": "^2.0.0" + "@rosen-clients/cardano-koios": "^2.0.1" }, "devDependencies": { "@babel/preset-env": "^7.19.0", diff --git a/packages/networks/cardano-koios/package.json b/packages/networks/cardano-koios/package.json index 4728174..d526563 100644 --- a/packages/networks/cardano-koios/package.json +++ b/packages/networks/cardano-koios/package.json @@ -27,7 +27,7 @@ "@rosen-bridge/tokens": "^1.0.0", "@rosen-chains/abstract-chain": "^2.2.1", "@rosen-chains/cardano": "^2.3.0", - "@rosen-clients/cardano-koios": "^2.0.0" + "@rosen-clients/cardano-koios": "^2.0.1" }, "devDependencies": { "@babel/preset-env": "^7.19.0", diff --git a/packages/networks/cardano-koios/tests/CardanoKoiosNetwork.spec.ts b/packages/networks/cardano-koios/tests/CardanoKoiosNetwork.spec.ts index e01f31f..ac30598 100644 --- a/packages/networks/cardano-koios/tests/CardanoKoiosNetwork.spec.ts +++ b/packages/networks/cardano-koios/tests/CardanoKoiosNetwork.spec.ts @@ -3,6 +3,7 @@ import CardanoKoiosNetwork from '../lib'; import { mockAddressAssets, mockEmptyAddressAssets, + mockGetEpochParams, mockGetTip, mockNoHistoryAddressAssets, mockPostAddressInfo, @@ -603,4 +604,28 @@ describe('CardanoKoiosNetwork', () => { expect(result).toEqual(testData.expectedUtxo); }); }); + + describe('getProtocolParameters', () => { + /** + * @target `CardanoKoiosNetwork.getProtocolParameters` should return required parameters + * @dependencies + * @scenario + * - mock `getEpochParams` of cardano koios client + * - run test + * - check returned value + * @expected + * - it should be mocked slot + */ + it('should return required parameters', async () => { + // mock client response + mockGetEpochParams(); + + // run test + const network = mockNetwork(); + const result = await network.getProtocolParameters(); + + // check returned value + expect(result).toEqual(testData.expectedRequiredParams); + }); + }); }); diff --git a/packages/networks/cardano-koios/tests/mocked/CardanoKoiosClient.mock.ts b/packages/networks/cardano-koios/tests/mocked/CardanoKoiosClient.mock.ts index 7c24e36..8729fe6 100644 --- a/packages/networks/cardano-koios/tests/mocked/CardanoKoiosClient.mock.ts +++ b/packages/networks/cardano-koios/tests/mocked/CardanoKoiosClient.mock.ts @@ -161,3 +161,12 @@ export const mockPostTxUtxos = (utxos: TxUtxos) => { postTxInfo: async () => [utxos], } as any); }; + +/** + * mock `getEpochParams` of cardano koios client + */ +export const mockGetEpochParams = () => { + jest.mocked(cardanoKoiosClientFactory).mockReturnValueOnce({ + getEpochParams: async () => [testData.epochParams], + } as any); +}; diff --git a/packages/networks/cardano-koios/tests/testData.ts b/packages/networks/cardano-koios/tests/testData.ts index 69bd00a..bff236c 100644 --- a/packages/networks/cardano-koios/tests/testData.ts +++ b/packages/networks/cardano-koios/tests/testData.ts @@ -580,3 +580,48 @@ export const unspentBoxId = '454426c78db02b32a02274d926850fad261bb08b3dbfac962ba38c5118856dc6.0'; export const boxId = '98884bf40d8ebbd89ad78c6deaa31f0cc47938d941bfc0452bbc9a13aeb37cd3.0'; + +export const epochParams = { + epoch_no: 447, + min_fee_a: 44, + min_fee_b: 155381, + max_block_size: 90112, + max_tx_size: 16384, + max_bh_size: 1100, + key_deposit: '2000000', + pool_deposit: '500000000', + max_epoch: 18, + optimal_pool_count: 500, + influence: 0.3, + monetary_expand_rate: 0.003, + treasury_growth_rate: 0.2, + decentralisation: 0, + extra_entropy: null, + protocol_major: 8, + protocol_minor: 0, + min_utxo_value: '0', + min_pool_cost: '170000000', + nonce: '3cf0a6c3179f521101ceef355b1b3e3d782846f0b9161dd7095e096bbb6536bf', + block_hash: + '376ca52b4759cb2a7aa255cbfc93b615c40366d7d043f168796eaa054f622dd9', + cost_models: {}, + price_mem: 0.0577, + price_step: 0.0000721, + max_tx_ex_mem: 14000000, + max_tx_ex_steps: 10000000000, + max_block_ex_mem: 62000000, + max_block_ex_steps: 20000000000, + max_val_size: 5000, + collateral_percent: 150, + max_collateral_inputs: 3, + coins_per_utxo_size: '4310', +}; +export const expectedRequiredParams = { + minFeeA: 44, + minFeeB: 155381, + poolDeposit: '500000000', + keyDeposit: '2000000', + maxValueSize: 5000, + maxTxSize: 16384, + coinsPerUtxoSize: '4310', +}; From 89526d3d9cf0d4d410f9201eb4a21f8f41dff4c8 Mon Sep 17 00:00:00 2001 From: HFazelinia Date: Tue, 7 Nov 2023 14:05:58 +0000 Subject: [PATCH 4/5] update rosen-clients --- package-lock.json | 20 ++++++++++---------- packages/networks/ergo-explorer/package.json | 4 ++-- packages/networks/ergo-node/package.json | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index dda8662..2c7715d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2483,9 +2483,9 @@ } }, "node_modules/@rosen-clients/ergo-explorer": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@rosen-clients/ergo-explorer/-/ergo-explorer-1.0.2.tgz", - "integrity": "sha512-I3pdZeo0kpUEqSHAA6EUyHGCETGE2bDjxPIKE3ZrE5/t3KURrJxLRJNQOgH9dyFpQz0uabCwF2LZmJjCGoXxdA==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rosen-clients/ergo-explorer/-/ergo-explorer-1.0.3.tgz", + "integrity": "sha512-Nf0ozLDxDpZSP5hhKEgtF9hA62Yhwjk/7J5EdNinoGASRDI/gTXjUlJfNTqTLx6A3/vPuwBH5/wzW6O22qXN8Q==", "dependencies": { "@types/json-bigint": "^1.0.1", "axios": "^1.3.4", @@ -2493,9 +2493,9 @@ } }, "node_modules/@rosen-clients/ergo-node": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rosen-clients/ergo-node/-/ergo-node-1.0.3.tgz", - "integrity": "sha512-MbaPllwStcoHckx3KNoXdvhf2r+Vks7OmRyWukB4qG06/rSlev93BBLOhLoOw9faNuRweGuP/FPXdT9A9f8XHQ==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@rosen-clients/ergo-node/-/ergo-node-1.0.4.tgz", + "integrity": "sha512-+kHFiWw1XK+yDFq34sLCEb7fJ1VTG9IUQq7umStZWo0JQQGXY5uz/s+4ifTtjynVjI+zow9VSW3rraegmiyU+A==", "dependencies": { "@types/json-bigint": "^1.0.1", "axios": "^1.3.4", @@ -8531,7 +8531,7 @@ }, "packages/networks/ergo-explorer": { "name": "@rosen-chains/ergo-explorer-network", - "version": "2.3.1", + "version": "2.3.2", "license": "GPL-3.0", "dependencies": { "@rosen-bridge/json-bigint": "^0.1.0", @@ -8540,7 +8540,7 @@ "@rosen-bridge/tokens": "^1.0.0", "@rosen-chains/abstract-chain": "^2.2.1", "@rosen-chains/ergo": "^2.3.1", - "@rosen-clients/ergo-explorer": "^1.0.2", + "@rosen-clients/ergo-explorer": "^1.0.3", "ergo-lib-wasm-nodejs": "^0.24.1", "it-all": "^3.0.1" }, @@ -8573,7 +8573,7 @@ }, "packages/networks/ergo-node": { "name": "@rosen-chains/ergo-node-network", - "version": "2.3.1", + "version": "2.3.2", "license": "GPL-3.0", "dependencies": { "@rosen-bridge/json-bigint": "^0.1.0", @@ -8582,7 +8582,7 @@ "@rosen-bridge/tokens": "^1.0.0", "@rosen-chains/abstract-chain": "^2.2.1", "@rosen-chains/ergo": "^2.3.1", - "@rosen-clients/ergo-node": "^1.0.3", + "@rosen-clients/ergo-node": "^1.0.4", "ergo-lib-wasm-nodejs": "^0.24.1", "it-all": "^3.0.1" }, diff --git a/packages/networks/ergo-explorer/package.json b/packages/networks/ergo-explorer/package.json index e2e712e..6cd10f4 100644 --- a/packages/networks/ergo-explorer/package.json +++ b/packages/networks/ergo-explorer/package.json @@ -1,6 +1,6 @@ { "name": "@rosen-chains/ergo-explorer-network", - "version": "2.3.1", + "version": "2.3.2", "description": "ergo explorer network package for rosen ergo chain", "main": "dist/lib/index.js", "types": "dist/lib/index.d.ts", @@ -26,7 +26,7 @@ "@rosen-bridge/tokens": "^1.0.0", "@rosen-chains/abstract-chain": "^2.2.1", "@rosen-chains/ergo": "^2.3.1", - "@rosen-clients/ergo-explorer": "^1.0.2", + "@rosen-clients/ergo-explorer": "^1.0.3", "ergo-lib-wasm-nodejs": "^0.24.1", "it-all": "^3.0.1" }, diff --git a/packages/networks/ergo-node/package.json b/packages/networks/ergo-node/package.json index c4163e0..0d82f43 100644 --- a/packages/networks/ergo-node/package.json +++ b/packages/networks/ergo-node/package.json @@ -1,6 +1,6 @@ { "name": "@rosen-chains/ergo-node-network", - "version": "2.3.1", + "version": "2.3.2", "description": "ergo node network package for rosen ergo chain", "main": "dist/lib/index.js", "types": "dist/lib/index.d.ts", @@ -26,7 +26,7 @@ "@rosen-bridge/tokens": "^1.0.0", "@rosen-chains/abstract-chain": "^2.2.1", "@rosen-chains/ergo": "^2.3.1", - "@rosen-clients/ergo-node": "^1.0.3", + "@rosen-clients/ergo-node": "^1.0.4", "ergo-lib-wasm-nodejs": "^0.24.1", "it-all": "^3.0.1" }, From 8a9f51145653622ea51fd62f41160dbcdf4002bb Mon Sep 17 00:00:00 2001 From: HFazelinia Date: Tue, 7 Nov 2023 19:00:04 +0000 Subject: [PATCH 5/5] minor improvement --- .../chains/cardano/lib/network/AbstractCardanoNetwork.ts | 4 ++-- packages/chains/cardano/lib/types.ts | 4 ++-- .../chains/cardano/tests/network/TestCardanoNetwork.ts | 8 ++++++-- .../networks/cardano-koios/lib/CardanoKoiosNetwork.ts | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/chains/cardano/lib/network/AbstractCardanoNetwork.ts b/packages/chains/cardano/lib/network/AbstractCardanoNetwork.ts index 7872012..fadd62a 100644 --- a/packages/chains/cardano/lib/network/AbstractCardanoNetwork.ts +++ b/packages/chains/cardano/lib/network/AbstractCardanoNetwork.ts @@ -1,5 +1,5 @@ import { AbstractUtxoChainNetwork } from '@rosen-chains/abstract-chain'; -import { CardanoProtocolParams, CardanoTx, CardanoUtxo } from '../types'; +import { CardanoProtocolParameters, CardanoTx, CardanoUtxo } from '../types'; import { CardanoRosenExtractor } from '@rosen-bridge/rosen-extractor'; import { Transaction } from '@emurgo/cardano-serialization-lib-nodejs'; @@ -32,7 +32,7 @@ abstract class AbstractCardanoNetwork extends AbstractUtxoChainNetwork< * gets required parameters of Cardano Protocol * @returns an object containing required protocol parameters */ - abstract getProtocolParameters: () => Promise; + abstract getProtocolParameters: () => Promise; } export default AbstractCardanoNetwork; diff --git a/packages/chains/cardano/lib/types.ts b/packages/chains/cardano/lib/types.ts index e6275be..2109e0b 100644 --- a/packages/chains/cardano/lib/types.ts +++ b/packages/chains/cardano/lib/types.ts @@ -52,7 +52,7 @@ interface CardanoTransactionJsonModel extends PaymentTransactionJsonModel { inputUtxos: Array; } -interface CardanoProtocolParams { +interface CardanoProtocolParameters { minFeeA: number; minFeeB: number; poolDeposit: string; @@ -71,5 +71,5 @@ export { CardanoTx, UtxoBoxesAssets, CardanoTransactionJsonModel, - CardanoProtocolParams, + CardanoProtocolParameters, }; diff --git a/packages/chains/cardano/tests/network/TestCardanoNetwork.ts b/packages/chains/cardano/tests/network/TestCardanoNetwork.ts index 7d76e9d..5b7fc50 100644 --- a/packages/chains/cardano/tests/network/TestCardanoNetwork.ts +++ b/packages/chains/cardano/tests/network/TestCardanoNetwork.ts @@ -1,6 +1,10 @@ import { AbstractCardanoNetwork } from '../../lib'; import { BlockInfo, ConfirmationStatus } from '@rosen-chains/abstract-chain'; -import { CardanoProtocolParams, CardanoTx, CardanoUtxo } from '../../lib/types'; +import { + CardanoProtocolParameters, + CardanoTx, + CardanoUtxo, +} from '../../lib/types'; import { CardanoRosenExtractor } from '@rosen-bridge/rosen-extractor'; import { protocolParameters } from '../testUtils'; @@ -63,7 +67,7 @@ class TestCardanoNetwork extends AbstractCardanoNetwork { throw Error('Not mocked'); }; - getProtocolParameters = (): Promise => + getProtocolParameters = (): Promise => Promise.resolve(protocolParameters); } diff --git a/packages/networks/cardano-koios/lib/CardanoKoiosNetwork.ts b/packages/networks/cardano-koios/lib/CardanoKoiosNetwork.ts index 51377a4..835b53c 100644 --- a/packages/networks/cardano-koios/lib/CardanoKoiosNetwork.ts +++ b/packages/networks/cardano-koios/lib/CardanoKoiosNetwork.ts @@ -10,7 +10,7 @@ import { CardanoUtxo, CardanoTx, CardanoAsset, - CardanoProtocolParams, + CardanoProtocolParameters, } from '@rosen-chains/cardano'; import { RosenTokens } from '@rosen-bridge/tokens'; import { @@ -537,7 +537,7 @@ class CardanoKoiosNetwork extends AbstractCardanoNetwork { * gets required parameters of Cardano Protocol * @returns an object containing required protocol parameters */ - getProtocolParameters = async (): Promise => { + getProtocolParameters = async (): Promise => { const allParams = await this.client.getEpochParams(); const epochParams = allParams[0]; this.logger.debug(