-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Depends on: #472 Closes: #353 This PR adds support for withdrawals in SDK and Acre dapp. To request a redemption we need to implement our custom redeemer proxy. Our redeemer proxy builds the redemption data and sends the redemption request transaction via Orangekit SDK. Here we also hardcode the `ethers` version to `6.10.0` (without `^`) in the `solidity` and `sdk` workspaces. The version of `ethers` in the `solidity` workspace has been resolved to `6.13.1` and the `sdk` workspace depends on it, so pnpm resolves `ethers` in `sdk` to `6.13.1` under the hood where there are some changes in the API and causes tests and builds to fail.
- Loading branch information
Showing
38 changed files
with
4,253 additions
and
3,507 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./useAcreContext" | ||
export * from "./useStakeFlow" | ||
export { default as useInitializeWithdraw } from "./useInitializeWithdraw" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useCallback } from "react" | ||
import { | ||
MessageSignedStepCallback, | ||
OnSignMessageStepCallback, | ||
} from "@acre-btc/sdk/dist/src/lib/redeemer-proxy" | ||
import { useAcreContext } from "./useAcreContext" | ||
|
||
export default function useInitializeWithdraw() { | ||
const { acre, isConnected } = useAcreContext() | ||
|
||
return useCallback( | ||
async ( | ||
amount: bigint, | ||
onSignMessageStep?: OnSignMessageStepCallback, | ||
messageSignedStep?: MessageSignedStepCallback, | ||
) => { | ||
if (!acre || !isConnected) return | ||
|
||
await acre.account.initializeWithdrawal( | ||
amount, | ||
onSignMessageStep, | ||
messageSignedStep, | ||
) | ||
}, | ||
[acre, isConnected], | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 79 additions & 15 deletions
94
dapp/src/components/TransactionModal/ActiveUnstakingStep/SignMessageModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeErrorModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from "react" | ||
import { | ||
Button, | ||
Icon, | ||
Link, | ||
ModalBody, | ||
ModalCloseButton, | ||
ModalFooter, | ||
ModalHeader, | ||
} from "@chakra-ui/react" | ||
import { TextMd } from "#/components/shared/Typography" | ||
import { EXTERNAL_HREF } from "#/constants" | ||
import { IconBrandDiscordFilled } from "@tabler/icons-react" | ||
|
||
export default function UnstakeErrorModal() { | ||
return ( | ||
<> | ||
<ModalCloseButton /> | ||
<ModalHeader color="red.400" textAlign="center"> | ||
Unexpected error... | ||
</ModalHeader> | ||
<ModalBody gap={10} pb={6}> | ||
<TextMd>Please try agin.</TextMd> | ||
</ModalBody> | ||
<ModalFooter py={6} px={8} flexDirection="row"> | ||
<Button | ||
as={Link} | ||
size="lg" | ||
width="100%" | ||
variant="outline" | ||
rightIcon={<Icon as={IconBrandDiscordFilled} boxSize={5} />} | ||
href={EXTERNAL_HREF.DISCORD} | ||
isExternal | ||
> | ||
Get help on Discord | ||
</Button> | ||
</ModalFooter> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import React from "react" | ||
import { ACTION_FLOW_TYPES, ActionFlowType } from "#/types" | ||
import StakingErrorModal from "./ActiveStakingStep/StakingErrorModal" | ||
import UnstakeErrorModal from "./ActiveUnstakingStep/UnstakeErrorModal" | ||
|
||
export default function ErrorModal({ type }: { type: ActionFlowType }) { | ||
if (type === ACTION_FLOW_TYPES.STAKE) return <StakingErrorModal /> | ||
// TODO: Handle the case of unstake action | ||
if (type === ACTION_FLOW_TYPES.UNSTAKE) return <UnstakeErrorModal /> | ||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export function useMinWithdrawAmount() { | ||
// TODO: Fetch this amount from SDK. | ||
return 1000000n // 0.01 BTC | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.