From e2024f5f7e64db5e3ee2909988d617f4490a7dde Mon Sep 17 00:00:00 2001 From: pavanvora Date: Fri, 27 Dec 2024 14:13:00 +0530 Subject: [PATCH 1/2] disable rewards withdraw --- .../coin-cardano/src/buildTransaction.ts | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/libs/coin-modules/coin-cardano/src/buildTransaction.ts b/libs/coin-modules/coin-cardano/src/buildTransaction.ts index 185a03c70946..1b1cbea4e34c 100644 --- a/libs/coin-modules/coin-cardano/src/buildTransaction.ts +++ b/libs/coin-modules/coin-cardano/src/buildTransaction.ts @@ -5,13 +5,11 @@ import { } from "@stricahq/typhonjs"; import BigNumber from "bignumber.js"; import type { TokenAccount } from "@ledgerhq/types-live"; -import { RewardAddress } from "@stricahq/typhonjs/dist/address"; import { getAccountStakeCredential, getBaseAddress, getTTL, mergeTokens, - isTestnet, isProtocolParamsValid, } from "./logic"; import { decodeTokenAssetId, decodeTokenCurrencyId, getTokenAssetId } from "./buildSubAccounts"; @@ -44,28 +42,34 @@ function getTyphonInputFromUtxo(utxo: CardanoOutput): TyphonTypes.Input { }; } -function getRewardWithdrawalCertificate(account: CardanoAccount): TyphonTypes.Withdrawal | null { - if (!account.cardanoResources.delegation?.rewards.gt(0)) { - return null; - } - - const stakeCredential = getAccountStakeCredential(account.xpub as string, account.index); - const stakeKeyHashCredential: TyphonTypes.HashCredential = { - hash: Buffer.from(stakeCredential.key, "hex"), - type: TyphonTypes.HashType.ADDRESS, - bipPath: stakeCredential.path, - }; - - const networkId = isTestnet(account.currency) - ? TyphonTypes.NetworkId.TESTNET - : TyphonTypes.NetworkId.MAINNET; - const rewardAddress = new RewardAddress(networkId, stakeKeyHashCredential); - const rewardsWithdrawalCertificate: TyphonTypes.Withdrawal = { - rewardAccount: rewardAddress, - amount: account.cardanoResources.delegation.rewards, - }; - - return rewardsWithdrawalCertificate; +function getRewardWithdrawalCertificate(_account: CardanoAccount): TyphonTypes.Withdrawal | null { + return null; + + /** + * Disable rewards withdraw certificate, as a work around for Chang 2 hard fork + */ + + // if (!account.cardanoResources.delegation?.rewards.gt(0)) { + // return null; + // } + + // const stakeCredential = getAccountStakeCredential(account.xpub as string, account.index); + // const stakeKeyHashCredential: TyphonTypes.HashCredential = { + // hash: Buffer.from(stakeCredential.key, "hex"), + // type: TyphonTypes.HashType.ADDRESS, + // bipPath: stakeCredential.path, + // }; + + // const networkId = isTestnet(account.currency) + // ? TyphonTypes.NetworkId.TESTNET + // : TyphonTypes.NetworkId.MAINNET; + // const rewardAddress = new RewardAddress(networkId, stakeKeyHashCredential); + // const rewardsWithdrawalCertificate: TyphonTypes.Withdrawal = { + // rewardAccount: rewardAddress, + // amount: account.cardanoResources.delegation.rewards, + // }; + + // return rewardsWithdrawalCertificate; } const buildSendTokenTransaction = async ({ From a06e08bbef14aa151c3aa008cbf7ead2c3846f03 Mon Sep 17 00:00:00 2001 From: pavanvora Date: Fri, 27 Dec 2024 22:47:25 +0530 Subject: [PATCH 2/2] add changeset --- .changeset/perfect-schools-pretend.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/perfect-schools-pretend.md diff --git a/.changeset/perfect-schools-pretend.md b/.changeset/perfect-schools-pretend.md new file mode 100644 index 000000000000..2d52ab960100 --- /dev/null +++ b/.changeset/perfect-schools-pretend.md @@ -0,0 +1,5 @@ +--- +"@ledgerhq/coin-cardano": minor +--- + +Disable auto withdrawal of rewards as a workaround for the upcoming Cardano hard fork