From c81dfd7fb6818a5dc8ca4e493985ef45a4cfc464 Mon Sep 17 00:00:00 2001 From: Brice Dobry Date: Tue, 7 Mar 2023 17:16:33 -0500 Subject: [PATCH 1/2] feat: return `block-height` from `withdraw?` funcs `stx-wtihdraw?`, `ft-withdraw?` and `nft-withdraw?` do not return any meaningful value on success. When attempting to make a withdrawal, users will need the block height in which the withdrawal occured in order to perform the second stage of the withdraw (on the L1). This changeset makes these withdraw functions return the block height for convenience. --- src/chainstate/stacks/boot/subnet.clar | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/chainstate/stacks/boot/subnet.clar b/src/chainstate/stacks/boot/subnet.clar index 83cf9da27..f601683c4 100644 --- a/src/chainstate/stacks/boot/subnet.clar +++ b/src/chainstate/stacks/boot/subnet.clar @@ -72,7 +72,8 @@ amount: amount, asset-contract: (contract-of asset), }) - (contract-call? asset burn-for-withdrawal amount sender) + (try! (contract-call? asset burn-for-withdrawal amount sender)) + (ok block-height) ) ) @@ -84,7 +85,8 @@ id: id, asset-contract: (contract-of asset), }) - (contract-call? asset burn-for-withdrawal id sender) + (try! (contract-call? asset burn-for-withdrawal id sender)) + (ok block-height) ) ) @@ -95,6 +97,7 @@ sender: sender, amount: amount, }) - (stx-transfer? amount sender (as-contract tx-sender)) + (try! (stx-transfer? amount sender (as-contract tx-sender))) + (ok block-height) ) ) From bb2d8b63927b98ebddef54fb95c7573fd1c749e8 Mon Sep 17 00:00:00 2001 From: Brice Dobry Date: Wed, 8 Mar 2023 08:35:34 -0500 Subject: [PATCH 2/2] feat: add withdraw-height to print event In addition to returning the withdraw height from the `-withdraw?` functions, this commit adds this height to the print event as well. --- src/chainstate/stacks/boot/subnet.clar | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/chainstate/stacks/boot/subnet.clar b/src/chainstate/stacks/boot/subnet.clar index f601683c4..8fa79d9f8 100644 --- a/src/chainstate/stacks/boot/subnet.clar +++ b/src/chainstate/stacks/boot/subnet.clar @@ -71,6 +71,7 @@ sender: sender, amount: amount, asset-contract: (contract-of asset), + withdrawal-height: block-height, }) (try! (contract-call? asset burn-for-withdrawal amount sender)) (ok block-height) @@ -84,6 +85,7 @@ sender: sender, id: id, asset-contract: (contract-of asset), + withdrawal-height: block-height, }) (try! (contract-call? asset burn-for-withdrawal id sender)) (ok block-height) @@ -96,6 +98,7 @@ type: "stx", sender: sender, amount: amount, + withdrawal-height: block-height, }) (try! (stx-transfer? amount sender (as-contract tx-sender))) (ok block-height)