Skip to content

Commit

Permalink
Merge branch 'main' into points-card-update
Browse files Browse the repository at this point in the history
  • Loading branch information
nkuba authored Nov 12, 2024
2 parents ac78d66 + d78803e commit b86ac70
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"account.list",
"bitcoin.getAddress",
"bitcoin.getPublicKey",
"transaction.signAndBroadcast",
"custom.acre.messageSign",
"custom.acre.transactionSignAndBroadcast"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"account.list",
"bitcoin.getAddress",
"bitcoin.getPublicKey",
"transaction.signAndBroadcast",
"custom.acre.messageSign",
"custom.acre.transactionSignAndBroadcast"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"account.list",
"bitcoin.getAddress",
"bitcoin.getPublicKey",
"transaction.signAndBroadcast",
"custom.acre.messageSign",
"custom.acre.transactionSignAndBroadcast"
],
Expand Down
1 change: 1 addition & 0 deletions dapp/manifests/ledger-live/ledger-manifest-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"account.list",
"bitcoin.getAddress",
"bitcoin.getPublicKey",
"transaction.signAndBroadcast",
"custom.acre.messageSign",
"custom.acre.transactionSignAndBroadcast"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -48,7 +48,10 @@ function AcrePointsRewardEstimation(props: StackProps) {
const { value = 0n } = useFormField<bigint | undefined>(
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(
Expand Down
17 changes: 8 additions & 9 deletions dapp/src/utils/orangekit/ledger-live/bitcoin-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>()(() =>
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
Expand Down
21 changes: 10 additions & 11 deletions dapp/src/utils/orangekit/ledger-live/tests/bitcoin-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ describe("AcreLedgerLiveBitcoinProvider", () => {
messageSign: vi.fn(),
},
},
transaction: {
signAndBroadcast: vi.fn(),
},
account: {
list: vi.fn(),
request: vi.fn(),
Expand Down Expand Up @@ -79,7 +82,7 @@ describe("AcreLedgerLiveBitcoinProvider", () => {
let result: string

beforeAll(async () => {
mockedWalletApiClient.custom.acre.transactionSignAndBroadcast.mockResolvedValue(
mockedWalletApiClient.transaction.signAndBroadcast.mockResolvedValue(
mockedTxHash,
)

Expand All @@ -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", () => {
Expand Down

0 comments on commit b86ac70

Please sign in to comment.