Skip to content

Commit

Permalink
Merge branch '81-remove-leading-zero-txid-check-in-cardanochain' into…
Browse files Browse the repository at this point in the history
… 'dev'

remove leading zero tx id check in CardanoChain

Closes #81

See merge request ergo/rosen-bridge/rosen-chains!87
  • Loading branch information
vorujack committed Jan 27, 2024
2 parents aa3125a + 76ca688 commit daf9e51
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 50 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

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

4 changes: 0 additions & 4 deletions packages/chains/cardano/lib/CardanoChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ class CardanoChain extends AbstractUtxoChain<CardanoUtxo> {
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,
Expand Down Expand Up @@ -451,9 +450,6 @@ class CardanoChain extends AbstractUtxoChain<CardanoUtxo> {
transaction: PaymentTransaction,
_signingStatus: SigningStatus = SigningStatus.Signed
): Promise<boolean> => {
// check if txId is valid
if (!CardanoUtils.isTxIdValid(transaction.txId)) return false;

const tx = Serializer.deserialize(transaction.txBytes);
const txBody = tx.body();

Expand Down
7 changes: 0 additions & 7 deletions packages/chains/cardano/lib/CardanoUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion packages/chains/cardano/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
25 changes: 0 additions & 25 deletions packages/chains/cardano/tests/CardanoChain.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/networks/cardano-blockfrost/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
}
}
4 changes: 2 additions & 2 deletions packages/networks/cardano-graphql/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
}
}
4 changes: 2 additions & 2 deletions 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": "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",
Expand All @@ -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": {
Expand Down

0 comments on commit daf9e51

Please sign in to comment.