|
92 | 92 | ;; are for the function by that name on this fork |
93 | 93 | (define-private (check-registration (signatures (list 9 (buff 65))) |
94 | 94 | (data {principal: principal, deposit-fn-name: (string-ascii 45), height: uint}) ) |
95 | | - (let ((registration-hash make-registration-hash data) |
96 | | - (signer-principals (try! (fold verify-sign-helper signatures (ok { hash: registration-hash, signers: (list) })))) ) |
| 95 | + (let ((registration-hash (make-registration-hash data)) |
| 96 | + (signer-principals (try! (fold verify-sign-helper signatures (ok { hash: registration-hash, signers: (list) }))))) |
97 | 97 | ;; TODO: perform checks on height? |
98 | 98 | ;; TODO: should we pass around the block-id as well to provide a meaningful error? |
99 | 99 | ;; check that the caller is a direct caller! |
100 | | - (asserts! (is-eq tx-sender contract-caller) (err ERR_UNAUTHORIZED_CONTRACT_CALLER))) |
| 100 | + (asserts! (is-eq tx-sender contract-caller) (err ERR_UNAUTHORIZED_CONTRACT_CALLER)) |
101 | 101 | ;; check that we have enough signatures |
102 | | - (check-miners (append (get signers signer-principals) tx-sender))) |
| 102 | + (check-miners (append (get signers signer-principals) tx-sender)))) |
103 | 103 |
|
104 | 104 | ;; TODO: this needs to be ensure that the miner can't call it directly with an earlier height |
105 | 105 | ;; so it either needs to be private or we could check that the height is recent |
106 | 106 | (define-private (make-registration-hash (data {principal: principal, deposit-fn-name: (string-ascii 45), height: uint})) |
107 | | - (let ((block-id (get-block-info? id-header-hash (get hash-height data))) |
108 | | - (data-buff (unwrap-panic (to-consensus-buff (merge data { block-id: block-id, multi-contract: CONTRACT_ADDRESS })))) |
| 107 | + (let ((block-id (get-block-info? id-header-hash (get height data))) |
| 108 | + (data-buff (unwrap-panic (to-consensus-buff? (merge data { block-id: block-id, multi-contract: CONTRACT_ADDRESS })))) |
109 | 109 | (data-hash (sha256 data-buff)) |
110 | 110 | (structured-hash (sha256 (concat sip18-data-prefix data-hash)))) |
111 | 111 | structured-hash)) |
112 | 112 |
|
113 | 113 | (define-read-only (make-ft-registration-hash (ft-contract <ft-trait>) (deposit-fn-name (string-ascii 45))) |
114 | 114 | (let ((contract_principal (contract-of ft-contract)) |
115 | | - (structured-hash make-registration-hash |
116 | | - {principal: contract_principal, deposit-fn-name: deposit-fn-name, height: block-height})) |
| 115 | + (structured-hash (make-registration-hash |
| 116 | + {principal: contract_principal, deposit-fn-name: deposit-fn-name, height: block-height}))) |
117 | 117 | {height: block-height, hash: structured-hash})) |
118 | 118 |
|
119 | 119 | (define-read-only (make-nft-registration-hash (nft-contract <nft-trait>) (deposit-fn-name (string-ascii 45))) |
120 | 120 | (let ((contract_principal (contract-of nft-contract)) |
121 | | - (structured-hash make-registration-hash |
122 | | - {principal: contract_principal, deposit-fn-name: deposit-fn-name, height: block-height})) |
| 121 | + (structured-hash (make-registration-hash |
| 122 | + {principal: contract_principal, deposit-fn-name: deposit-fn-name, height: block-height}))) |
123 | 123 | {height: block-height, hash: structured-hash})) |
124 | 124 |
|
125 | 125 | ;; height is the block-height when the hash was created that was signed |
|
128 | 128 | ;; deposit-fn-name is on the L2 |
129 | 129 | (define-public (register-new-ft-contract (ft-contract <ft-trait>) (deposit-fn-name (string-ascii 45) ) |
130 | 130 | (height uint) (signatures (list 9 (buff 65))) ) |
131 | | - (let (contract_principal (contract-of ft-contract)) |
| 131 | + (let ((contract_principal (contract-of ft-contract))) |
132 | 132 | (try! (check-registration signatures |
133 | | - {principal: contract_principal, deposit-fn-name: deposit-fn-name, height: height}))) |
| 133 | + {principal: contract_principal, deposit-fn-name: deposit-fn-name, height: height})) |
134 | 134 | ;; execute the registration |
135 | | - (as-contract (contract-call? .subnet register-new-ft-contract ft-contract deposit-fn-name)) ) |
| 135 | + (as-contract (contract-call? .subnet register-new-ft-contract ft-contract deposit-fn-name)) )) |
136 | 136 |
|
137 | 137 | ;; height is the block-height when the hash was created that was signed |
138 | 138 | ;; the purpose of this is to ensure that this is the same fork |
139 | 139 | ;; nft-contract is on the L1 |
140 | 140 | ;; deposit-fn-name is on the L2 |
141 | 141 | (define-public (register-new-nft-contract (nft-contract <nft-trait>) (deposit-fn-name (string-ascii 45) ) |
142 | 142 | (height uint) (signatures (list 9 (buff 65))) ) |
143 | | - (let (contract_principal (contract-of nft-contract)) |
| 143 | + (let ((contract_principal (contract-of nft-contract))) |
144 | 144 | (try! (check-registration signatures |
145 | | - {principal: contract_principal, deposit-fn-name: deposit-fn-name, height: height}))) |
| 145 | + {principal: contract_principal, deposit-fn-name: deposit-fn-name, height: height})) |
146 | 146 | ;; execute the registration |
147 | | - (as-contract (contract-call? .subnet register-new-nft-contract nft-contract deposit-fn-name)) ) |
| 147 | + (as-contract (contract-call? .subnet register-new-nft-contract nft-contract deposit-fn-name)) )) |
0 commit comments