From 76ca6881e18b6151ebb28bb900a533a23494e91e Mon Sep 17 00:00:00 2001 From: HFazelinia Date: Tue, 23 Jan 2024 21:06:05 +0000 Subject: [PATCH] remove leading zero tx id check in CardanoChain --- package-lock.json | 14 +++++------ packages/chains/cardano/lib/CardanoChain.ts | 4 --- packages/chains/cardano/lib/CardanoUtils.ts | 7 ------ packages/chains/cardano/package.json | 2 +- .../chains/cardano/tests/CardanoChain.spec.ts | 25 ------------------- .../networks/cardano-blockfrost/package.json | 4 +-- .../networks/cardano-graphql/package.json | 4 +-- packages/networks/cardano-koios/package.json | 4 +-- 8 files changed, 14 insertions(+), 50 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3a76ad9..290dec0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12022,7 +12022,7 @@ }, "packages/chains/cardano": { "name": "@rosen-chains/cardano", - "version": "3.2.2", + "version": "3.2.3", "license": "GPL-3.0", "dependencies": { "@emurgo/cardano-serialization-lib-nodejs": "^11.3.1", @@ -12080,7 +12080,7 @@ }, "packages/networks/cardano-blockfrost": { "name": "@rosen-chains/cardano-blockfrost-network", - "version": "1.2.2", + "version": "1.2.3", "license": "GPL-3.0", "dependencies": { "@blockfrost/blockfrost-js": "^5.4.0", @@ -12088,7 +12088,7 @@ "@rosen-bridge/abstract-logger": "^1.0.0", "@rosen-bridge/rosen-extractor": "^3.0.0", "@rosen-chains/abstract-chain": "^3.2.2", - "@rosen-chains/cardano": "^3.2.2" + "@rosen-chains/cardano": "^3.2.3" }, "devDependencies": { "@types/node": "^18.11.18", @@ -12566,7 +12566,7 @@ }, "packages/networks/cardano-graphql": { "name": "@rosen-chains/cardano-graphql-network", - "version": "0.2.2", + "version": "0.2.3", "license": "GPL-3.0", "dependencies": { "@apollo/client": "^3.8.7", @@ -12574,7 +12574,7 @@ "@rosen-bridge/abstract-logger": "^1.0.0", "@rosen-bridge/rosen-extractor": "^3.0.0", "@rosen-chains/abstract-chain": "^3.2.2", - "@rosen-chains/cardano": "^3.2.2" + "@rosen-chains/cardano": "^3.2.3" }, "devDependencies": { "@graphql-codegen/cli": "^5.0.0", @@ -13055,7 +13055,7 @@ }, "packages/networks/cardano-koios": { "name": "@rosen-chains/cardano-koios-network", - "version": "4.2.3", + "version": "4.2.4", "license": "GPL-3.0", "dependencies": { "@emurgo/cardano-serialization-lib-nodejs": "^11.3.1", @@ -13064,7 +13064,7 @@ "@rosen-bridge/rosen-extractor": "^3.0.0", "@rosen-bridge/tokens": "^1.0.0", "@rosen-chains/abstract-chain": "^3.2.2", - "@rosen-chains/cardano": "^3.2.2", + "@rosen-chains/cardano": "^3.2.3", "@rosen-clients/cardano-koios": "^2.0.1" }, "devDependencies": { diff --git a/packages/chains/cardano/lib/CardanoChain.ts b/packages/chains/cardano/lib/CardanoChain.ts index 81c577b..5eaa59f 100644 --- a/packages/chains/cardano/lib/CardanoChain.ts +++ b/packages/chains/cardano/lib/CardanoChain.ts @@ -247,7 +247,6 @@ class CardanoChain extends AbstractUtxoChain { const txId = Buffer.from( CardanoWasm.hash_transaction(txBody).to_bytes() ).toString('hex'); - if (!CardanoUtils.isTxIdValid(txId)) throw Error(`Invalid txId: [${txId}]`); const cardanoTx = new CardanoTransaction( txId, @@ -451,9 +450,6 @@ class CardanoChain extends AbstractUtxoChain { transaction: PaymentTransaction, _signingStatus: SigningStatus = SigningStatus.Signed ): Promise => { - // check if txId is valid - if (!CardanoUtils.isTxIdValid(transaction.txId)) return false; - const tx = Serializer.deserialize(transaction.txBytes); const txBody = tx.body(); diff --git a/packages/chains/cardano/lib/CardanoUtils.ts b/packages/chains/cardano/lib/CardanoUtils.ts index 6131f67..86cd062 100644 --- a/packages/chains/cardano/lib/CardanoUtils.ts +++ b/packages/chains/cardano/lib/CardanoUtils.ts @@ -161,13 +161,6 @@ class CardanoUtils { changeAmount ); }; - - /** - * verifies that txId doesn't start with zero - * @param txId - * @returns - */ - static isTxIdValid = (txId: string): boolean => txId[0] !== '0'; } export default CardanoUtils; diff --git a/packages/chains/cardano/package.json b/packages/chains/cardano/package.json index f18d55a..7382fd6 100644 --- a/packages/chains/cardano/package.json +++ b/packages/chains/cardano/package.json @@ -1,6 +1,6 @@ { "name": "@rosen-chains/cardano", - "version": "3.2.2", + "version": "3.2.3", "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/CardanoChain.spec.ts b/packages/chains/cardano/tests/CardanoChain.spec.ts index b8c6f67..ca1eb87 100644 --- a/packages/chains/cardano/tests/CardanoChain.spec.ts +++ b/packages/chains/cardano/tests/CardanoChain.spec.ts @@ -939,31 +939,6 @@ describe('CardanoChain', () => { // check returned value expect(result).toEqual(false); }); - - /** - * @target CardanoChain.isTxValid should return false when - * txId is invalid - * @dependencies - * @scenario - * - mock PaymentTransaction - * - call the function - * - check returned value - * @expected - * - it should return false - */ - it('should return false when txId is invalid', async () => { - // mock PaymentTransaction - const payment1 = CardanoTransaction.fromJson( - TestData.transaction7PaymentTransaction - ); - - // call the function - const cardanoChain = generateChainObject(network); - const result = await cardanoChain.isTxValid(payment1); - - // check returned value - expect(result).toEqual(false); - }); }); describe('verifyTransactionFee', () => { diff --git a/packages/networks/cardano-blockfrost/package.json b/packages/networks/cardano-blockfrost/package.json index 55fe84f..0abe06b 100644 --- a/packages/networks/cardano-blockfrost/package.json +++ b/packages/networks/cardano-blockfrost/package.json @@ -1,6 +1,6 @@ { "name": "@rosen-chains/cardano-blockfrost-network", - "version": "1.2.2", + "version": "1.2.3", "description": "a package to be used as network api provider for @rosen-chains/cardano package", "repository": "@rosen-chains/cardano-blockfrost-network", "license": "GPL-3.0", @@ -37,6 +37,6 @@ "@rosen-bridge/abstract-logger": "^1.0.0", "@rosen-bridge/rosen-extractor": "^3.0.0", "@rosen-chains/abstract-chain": "^3.2.2", - "@rosen-chains/cardano": "^3.2.2" + "@rosen-chains/cardano": "^3.2.3" } } diff --git a/packages/networks/cardano-graphql/package.json b/packages/networks/cardano-graphql/package.json index fb57aa5..65b3daa 100644 --- a/packages/networks/cardano-graphql/package.json +++ b/packages/networks/cardano-graphql/package.json @@ -1,6 +1,6 @@ { "name": "@rosen-chains/cardano-graphql-network", - "version": "0.2.2", + "version": "0.2.3", "description": "a package to be used as network api provider for @rosen-chains/cardano package", "repository": "@rosen-chains/cardano-graphql-network", "license": "GPL-3.0", @@ -41,6 +41,6 @@ "@rosen-bridge/abstract-logger": "^1.0.0", "@rosen-bridge/rosen-extractor": "^3.0.0", "@rosen-chains/abstract-chain": "^3.2.2", - "@rosen-chains/cardano": "^3.2.2" + "@rosen-chains/cardano": "^3.2.3" } } diff --git a/packages/networks/cardano-koios/package.json b/packages/networks/cardano-koios/package.json index 614dd6c..a3d838c 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": "4.2.3", + "version": "4.2.4", "description": "cardano koios network package for rosen cardano chain", "main": "dist/lib/index.js", "types": "dist/lib/index.d.ts", @@ -26,7 +26,7 @@ "@rosen-bridge/rosen-extractor": "^3.0.0", "@rosen-bridge/tokens": "^1.0.0", "@rosen-chains/abstract-chain": "^3.2.2", - "@rosen-chains/cardano": "^3.2.2", + "@rosen-chains/cardano": "^3.2.3", "@rosen-clients/cardano-koios": "^2.0.1" }, "devDependencies": {