Skip to content

Commit

Permalink
Add Bitcoin refund account property to stake msg
Browse files Browse the repository at this point in the history
Also leave a `TODO` not to revisit the message structure before the
launch.
  • Loading branch information
r-czajkowski committed Jan 16, 2024
1 parent 5701214 commit 2dfe62e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
10 changes: 9 additions & 1 deletion sdk/src/modules/staking/stake-initialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,20 @@ class StakeInitialization {
verifyingContract: this.#contracts.depositor.getChainIdentifier(),
}

// TODO: revisit the message structure before the launch.
const types: Types = {
Stake: [{ name: "receiver", type: "address" }],
Stake: [
{ name: "receiver", type: "address" },
{ name: "bitcoinRecoveryAddress", type: "string" },
],
}

const message: Message = {
receiver: this.#receiver.identifierHex,
// TODO: Make sure we can to pass the refund public key hash in this form.
bitcoinRecoveryAddress: this.#deposit
.getReceipt()
.refundPublicKeyHash.toPrefixedString(),
}

return { domain, types, message }
Expand Down
15 changes: 12 additions & 3 deletions sdk/test/modules/staking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ describe("Staking", () => {
})

describe("StakeInitialization", () => {
const { depositReceipt } = stakingInitializationData

beforeAll(() => {
mockedDeposit.getReceipt.mockReturnValue(depositReceipt)
})

describe("getDepositAddress", () => {
it("should return bitcoin deposit address", async () => {
expect(await result.getBitcoinAddress()).toBe(mockedDepositBTCAddress)
Expand Down Expand Up @@ -155,10 +161,15 @@ describe("Staking", () => {
verifyingContract: contracts.depositor.getChainIdentifier(),
},
{
Stake: [{ name: "receiver", type: "address" }],
Stake: [
{ name: "receiver", type: "address" },
{ name: "bitcoinRecoveryAddress", type: "string" },
],
},
{
receiver: receiver.identifierHex,
bitcoinRecoveryAddress:
depositReceipt.refundPublicKeyHash.toPrefixedString(),
},
)
})
Expand Down Expand Up @@ -220,7 +231,6 @@ describe("Staking", () => {
describe("when bitcoin deposit address has utxos", () => {
const {
fundingUtxos,
depositReceipt,
bitcoinRawTx,
bitcoinRawTxVectors,
mockedInitializeTxHash: mockedTxHash,
Expand All @@ -230,7 +240,6 @@ describe("Staking", () => {

beforeAll(async () => {
mockedDeposit.detectFunding.mockResolvedValue(fundingUtxos)
mockedDeposit.getReceipt.mockReturnValue(depositReceipt)
spyOnExtractBitcoinRawTxVectors = jest
.spyOn(TBTCModule, "extractBitcoinRawTxVectors")
.mockReturnValue(bitcoinRawTxVectors)
Expand Down

0 comments on commit 2dfe62e

Please sign in to comment.