From bd921a08444079304373cc564991ca955fedc334 Mon Sep 17 00:00:00 2001 From: Kamil Pyszkowski Date: Fri, 8 Nov 2024 14:32:16 +0100 Subject: [PATCH 1/2] Calculate points when min amount met --- .../StakeFormModal/AcrePointsRewardEstimation.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/AcrePointsRewardEstimation.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/AcrePointsRewardEstimation.tsx index 2307b625d..a09463405 100644 --- a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/AcrePointsRewardEstimation.tsx +++ b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/AcrePointsRewardEstimation.tsx @@ -13,7 +13,7 @@ import { H4, TextMd } from "#/components/shared/Typography" import { numberToLocaleString } from "#/utils" import { IconChevronDown } from "@tabler/icons-react" import { TOKEN_AMOUNT_FIELD_NAME } from "#/components/shared/TokenAmountForm/TokenAmountFormBase" -import { useFormField } from "#/hooks" +import { useFormField, useMinDepositAmount } from "#/hooks" import { ONE_MONTH_IN_DAYS, ONE_WEEK_IN_DAYS } from "#/constants" const ACRE_POINTS_DATA = { @@ -48,7 +48,10 @@ function AcrePointsRewardEstimation(props: StackProps) { const { value = 0n } = useFormField( TOKEN_AMOUNT_FIELD_NAME, ) - const baseReward = Number(value) + const minDepositAmount = useMinDepositAmount() + const amount = value >= minDepositAmount ? value : 0n + + const baseReward = Number(amount) const pointsRate = 10000 const estimatedReward = useMemo( From 1771782084fb025c412d971280cd2228c4a86172 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 12 Nov 2024 13:15:08 +0100 Subject: [PATCH 2/2] Update Ledger Live bitcoin provider Switch deposit transaction to Wallet API Bitcoin module. Currently, we're using the Acre custom module to send Bitcoin transactions for the deposit. Since it doesn't work and the fix is on the way, we need to switch to the regular Bitcoin module as a workaround for E2E testing. --- .../ledger-live-manifest-development.json | 1 + .../ledger-live-manifest-mainnet.json | 1 + .../ledger-live-manifest-testnet.json | 1 + .../ledger-live/ledger-manifest-template.json | 1 + .../orangekit/ledger-live/bitcoin-provider.ts | 17 +++++++-------- .../tests/bitcoin-provider.test.ts | 21 +++++++++---------- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/dapp/manifests/ledger-live/ledger-live-manifest-development.json b/dapp/manifests/ledger-live/ledger-live-manifest-development.json index fbea240e6..649115b55 100644 --- a/dapp/manifests/ledger-live/ledger-live-manifest-development.json +++ b/dapp/manifests/ledger-live/ledger-live-manifest-development.json @@ -23,6 +23,7 @@ "account.list", "bitcoin.getAddress", "bitcoin.getPublicKey", + "transaction.signAndBroadcast", "custom.acre.messageSign", "custom.acre.transactionSignAndBroadcast" ], diff --git a/dapp/manifests/ledger-live/ledger-live-manifest-mainnet.json b/dapp/manifests/ledger-live/ledger-live-manifest-mainnet.json index eb892f6cc..a24319deb 100644 --- a/dapp/manifests/ledger-live/ledger-live-manifest-mainnet.json +++ b/dapp/manifests/ledger-live/ledger-live-manifest-mainnet.json @@ -23,6 +23,7 @@ "account.list", "bitcoin.getAddress", "bitcoin.getPublicKey", + "transaction.signAndBroadcast", "custom.acre.messageSign", "custom.acre.transactionSignAndBroadcast" ], diff --git a/dapp/manifests/ledger-live/ledger-live-manifest-testnet.json b/dapp/manifests/ledger-live/ledger-live-manifest-testnet.json index 9e5c4bf86..06dc73564 100644 --- a/dapp/manifests/ledger-live/ledger-live-manifest-testnet.json +++ b/dapp/manifests/ledger-live/ledger-live-manifest-testnet.json @@ -23,6 +23,7 @@ "account.list", "bitcoin.getAddress", "bitcoin.getPublicKey", + "transaction.signAndBroadcast", "custom.acre.messageSign", "custom.acre.transactionSignAndBroadcast" ], diff --git a/dapp/manifests/ledger-live/ledger-manifest-template.json b/dapp/manifests/ledger-live/ledger-manifest-template.json index 5dc0d624f..6a4bc80ee 100644 --- a/dapp/manifests/ledger-live/ledger-manifest-template.json +++ b/dapp/manifests/ledger-live/ledger-manifest-template.json @@ -23,6 +23,7 @@ "account.list", "bitcoin.getAddress", "bitcoin.getPublicKey", + "transaction.signAndBroadcast", "custom.acre.messageSign", "custom.acre.transactionSignAndBroadcast" ], diff --git a/dapp/src/utils/orangekit/ledger-live/bitcoin-provider.ts b/dapp/src/utils/orangekit/ledger-live/bitcoin-provider.ts index 742281234..5ed054a88 100644 --- a/dapp/src/utils/orangekit/ledger-live/bitcoin-provider.ts +++ b/dapp/src/utils/orangekit/ledger-live/bitcoin-provider.ts @@ -173,16 +173,15 @@ export default class AcreLedgerLiveBitcoinProvider throw new Error("Connect first") } + // TODO: In the current version of Acre module, sending Bitcoin transactions + // is not supported. Use the custom Acre module to send Bitcoin transaction + // once it works correctly. const txHash = await tryRequest()(() => - this.#walletApiClient.custom.acre.transactionSignAndBroadcast( - this.#account!.id, - { - family: "bitcoin", - amount: new BigNumber(satoshis), - recipient: to, - }, - { hwAppId: this.#hwAppId }, - ), + this.#walletApiClient.transaction.signAndBroadcast(this.#account!.id, { + family: "bitcoin", + amount: new BigNumber(satoshis), + recipient: to, + }), ) return txHash diff --git a/dapp/src/utils/orangekit/ledger-live/tests/bitcoin-provider.test.ts b/dapp/src/utils/orangekit/ledger-live/tests/bitcoin-provider.test.ts index d45294b28..80f782406 100644 --- a/dapp/src/utils/orangekit/ledger-live/tests/bitcoin-provider.test.ts +++ b/dapp/src/utils/orangekit/ledger-live/tests/bitcoin-provider.test.ts @@ -42,6 +42,9 @@ describe("AcreLedgerLiveBitcoinProvider", () => { messageSign: vi.fn(), }, }, + transaction: { + signAndBroadcast: vi.fn(), + }, account: { list: vi.fn(), request: vi.fn(), @@ -79,7 +82,7 @@ describe("AcreLedgerLiveBitcoinProvider", () => { let result: string beforeAll(async () => { - mockedWalletApiClient.custom.acre.transactionSignAndBroadcast.mockResolvedValue( + mockedWalletApiClient.transaction.signAndBroadcast.mockResolvedValue( mockedTxHash, ) @@ -88,16 +91,12 @@ describe("AcreLedgerLiveBitcoinProvider", () => { it("should send transaction via Acre custom module", () => { expect( - mockedWalletApiClient.custom.acre.transactionSignAndBroadcast, - ).toHaveBeenCalledWith( - mockedAccount.id, - { - family: "bitcoin", - amount: new BigNumber(satoshis), - recipient: bitcoinAddress, - }, - { hwAppId }, - ) + mockedWalletApiClient.transaction.signAndBroadcast, + ).toHaveBeenCalledWith(mockedAccount.id, { + family: "bitcoin", + amount: new BigNumber(satoshis), + recipient: bitcoinAddress, + }) }) it("should return transaction hash", () => {