-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarity Setup Continued - Deposit Contract (#140)
* feat: initial registry contract and tests setup * feat: add github action for contract tests * deposit contract setup kickoff * calling into registry from deposit * pre-rebase updates * fix broken update * new complete-deposit checks * updated print & clarigen types * first test running * added getter test * addressed comments, minus removed tests * added back removed test * setup two of three remaining tests * added remaining tests * finished print test, ready for rereview * fixed type error * last items --------- Co-authored-by: Hank Stoever <[email protected]>
- Loading branch information
Showing
9 changed files
with
446 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tests/clarigen-types.ts |
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,59 @@ | ||
;; sBTC Deposit contract | ||
|
||
;; constants | ||
(define-constant txid-length u32) | ||
|
||
;; error codes | ||
(define-constant ERR_TXID_LEN (err u300)) | ||
(define-constant ERR_DEPOSIT_REPLAY (err u301)) | ||
|
||
;; data vars | ||
;; | ||
|
||
;; data maps | ||
;; | ||
|
||
;; public functions | ||
|
||
;; Accept a new deposit request | ||
;; Note that this function can only be called by the current | ||
;; bootstrap signer set address - it cannot be called by users directly. | ||
;; | ||
;; This function handles the validation & minting of sBTC, it then calls | ||
;; into the sbtc-registry contract to update the state of the protocol | ||
(define-public (complete-deposit-wrapper (txid (buff 32)) (vout-index uint) (amount uint) (recipient principal)) | ||
(let | ||
( | ||
(replay-fetch (contract-call? .sbtc-registry get-completed-deposit txid vout-index)) | ||
) | ||
|
||
;; TODO | ||
;; Check that tx-sender is the bootstrap signer | ||
|
||
;; Check that txid is the correct length | ||
(asserts! (is-eq (len txid) txid-length) ERR_TXID_LEN) | ||
|
||
;; Assert that the deposit has not already been completed (no replay) | ||
(asserts! (is-none replay-fetch) ERR_DEPOSIT_REPLAY) | ||
|
||
;; TODO | ||
;; Mint the sBTC to the recipient | ||
|
||
;; Complete the deposit | ||
(ok (contract-call? .sbtc-registry complete-deposit txid vout-index amount recipient)) | ||
) | ||
) | ||
|
||
;; Accept multiple new deposit requests | ||
;; Note that this function can only be called by the current | ||
;; bootstrap signer set address - it cannot be called by users directly. | ||
;; | ||
;; This function handles the validation & minting of sBTC by handling multiple (up to 1000) deposits at a time, | ||
;; it then calls into the sbtc-registry contract to update the state of the protocol | ||
|
||
;; read only functions | ||
;; | ||
|
||
;; private functions | ||
;; | ||
|
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
Oops, something went wrong.