@@ -68,6 +68,10 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
6868 mapping (bytes16 graphId = > GraphData) public graphDataMap;
6969 mapping (bytes16 graphId = > WithdrawData) public withdrawDataMap;
7070
71+ constructor () {
72+ _disableInitializers ();
73+ }
74+
7175 // initializer
7276 function initialize (
7377 IPegBTC _pegBTC ,
@@ -191,7 +195,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
191195 );
192196 }
193197
194- function getCancelWithdrawDigest (
198+ function _getCancelWithdrawDigest (
195199 bytes16 graphId
196200 ) internal view returns (bytes32 ) {
197201 return
@@ -204,11 +208,11 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
204208 bytes16 graphId ,
205209 uint256 nonce
206210 ) public view returns (bytes32 ) {
207- bytes32 msgHash = getCancelWithdrawDigest (graphId);
211+ bytes32 msgHash = _getCancelWithdrawDigest (graphId);
208212 return committeeManagement.getNoncedDigest (msgHash, nonce);
209213 }
210214
211- function getUnlockStakeDigest (
215+ function _getUnlockStakeDigest (
212216 address operator ,
213217 uint256 amount
214218 ) internal view returns (bytes32 ) {
@@ -228,7 +232,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
228232 uint256 amount ,
229233 uint256 nonce
230234 ) public view returns (bytes32 ) {
231- bytes32 msgHash = getUnlockStakeDigest (operator, amount);
235+ bytes32 msgHash = _getUnlockStakeDigest (operator, amount);
232236 return committeeManagement.getNoncedDigest (msgHash, nonce);
233237 }
234238
@@ -277,7 +281,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
277281 if (withdrawData.status != WithdrawStatus.Processing)
278282 revert WithdrawStatusInvalid ();
279283
280- bytes32 takeTxid = BitvmTxParser.computeTxid (rawTakeTx);
284+ bytes32 takeTxid = BitvmTxParser._computeTxid (rawTakeTx);
281285 if (takeTxid != expectedTxid) revert TxidMismatch ();
282286 _verifyMerkleInclusion (takeProof, takeTxid, false );
283287
@@ -287,7 +291,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
287291 uint64 rewardAmountSats = _operatorReward (peginData.peginAmountSats);
288292 pegBTC.transfer (
289293 withdrawData.operatorAddress,
290- Converter.amountFromSats (rewardAmountSats)
294+ Converter._amountFromSats (rewardAmountSats)
291295 );
292296
293297 if (happyPath) {
@@ -331,6 +335,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
331335 string calldata userChangeAddress ,
332336 string calldata userRefundAddress
333337 ) external payable {
338+ // TODO: check if request already exists
334339 PeginDataInner storage peginData = peginDataMap[instanceId];
335340 if (peginData.status != PeginStatus.None) revert InstanceUsed ();
336341 // TODO: check peginAmount,feeRate,userInputs
@@ -449,7 +454,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
449454 uint64 peginAmountSats ,
450455 address depositorAddress ,
451456 bytes16 parsedInstanceId
452- ) = BitvmTxParser.parsePegin (rawPeginTx);
457+ ) = BitvmTxParser._parsePegin (rawPeginTx);
453458 if (parsedInstanceId != instanceId) revert InstanceMismatch ();
454459 if (peginAmountSats != peginData.peginAmountSats)
455460 revert PeginAmountMismatch ();
@@ -481,9 +486,9 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
481486 if (feeAmountSats >= peginAmountSats) revert FeeTooHigh ();
482487 pegBTC.mint (
483488 depositorAddress,
484- Converter.amountFromSats (peginAmountSats - feeAmountSats)
489+ Converter._amountFromSats (peginAmountSats - feeAmountSats)
485490 );
486- pegBTC.mint (address (this ), Converter.amountFromSats (feeAmountSats));
491+ pegBTC.mint (address (this ), Converter._amountFromSats (feeAmountSats));
487492
488493 emit BridgeIn (
489494 depositorAddress,
@@ -554,7 +559,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
554559 peginData.status = PeginStatus.Locked;
555560
556561 // lock operator's pegBTC
557- uint256 lockAmount = Converter.amountFromSats (
562+ uint256 lockAmount = Converter._amountFromSats (
558563 peginData.peginAmountSats
559564 );
560565 pegBTC.transferFrom (msg .sender , address (this ), lockAmount);
@@ -588,6 +593,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
588593 revert TimelockNotExpired ();
589594 }
590595 withdrawData.status = WithdrawStatus.Canceled;
596+ // FIXME: transfer to operator or gateway?
591597 pegBTC.transfer (msg .sender , withdrawData.lockAmount);
592598 peginData.status = PeginStatus.Withdrawbale;
593599
@@ -601,7 +607,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
601607 ) external {
602608 // validate committeeSigs
603609 WithdrawData storage withdrawData = withdrawDataMap[graphId];
604- bytes32 cancel_digest = getCancelWithdrawDigest (graphId);
610+ bytes32 cancel_digest = _getCancelWithdrawDigest (graphId);
605611 committeeManagement.executeNoncedSignatures (
606612 cancel_digest,
607613 nonce,
@@ -614,6 +620,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
614620 if (withdrawData.status != WithdrawStatus.Initialized)
615621 revert WithdrawStatusInvalid ();
616622 withdrawData.status = WithdrawStatus.Canceled;
623+ // FIXME: transfer to operator or gateway?
617624 pegBTC.transfer (msg .sender , withdrawData.lockAmount);
618625 peginData.status = PeginStatus.Withdrawbale;
619626 emit CancelWithdraw (withdrawData.instanceId, graphId, msg .sender );
@@ -633,7 +640,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
633640 revert KickoffHeightLow ();
634641
635642 GraphData storage graphData = graphDataMap[graphId];
636- bytes32 kickoffTxid = BitvmTxParser.computeTxid (rawKickoffTx);
643+ bytes32 kickoffTxid = BitvmTxParser._computeTxid (rawKickoffTx);
637644 if (kickoffTxid != graphData.kickoffTxid) revert TxidMismatch ();
638645 _verifyMerkleInclusion (kickoffProof, kickoffTxid, false );
639646
@@ -710,7 +717,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
710717 kickoffTxid,
711718 kickoffVout,
712719 challengerAddress
713- ) = BitvmTxParser.parseChallengeTx (rawChallengeStartTx);
720+ ) = BitvmTxParser._parseChallengeTx (rawChallengeStartTx);
714721 if (kickoffTxid != graphData.kickoffTxid) revert TxidMismatch ();
715722 if (kickoffVout != BitvmTxParser.CHALLENGE_CONNECTOR_VOUT)
716723 revert TxidMismatch ();
@@ -725,21 +732,21 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
725732 bytes32 challengeFinishTxid;
726733 address disproverAddress;
727734 if (disproveTxType == DisproveTxType.AssertTimeout) {
728- (challengeFinishTxid) = BitvmTxParser.computeTxid (
735+ (challengeFinishTxid) = BitvmTxParser._computeTxid (
729736 rawChallengeFinishTx
730737 );
731738 if (graphData.assertTimoutTxids.length <= txnIndex)
732739 revert IndexOutOfRange ();
733740 if (challengeFinishTxid != graphData.assertTimoutTxids[txnIndex])
734741 revert TxidMismatch ();
735742 } else if (disproveTxType == DisproveTxType.OperatorCommitTimeout) {
736- (challengeFinishTxid) = BitvmTxParser.computeTxid (
743+ (challengeFinishTxid) = BitvmTxParser._computeTxid (
737744 rawChallengeFinishTx
738745 );
739746 if (challengeFinishTxid != graphData.commitTimoutTxid)
740747 revert TxidMismatch ();
741748 } else if (disproveTxType == DisproveTxType.OperatorNack) {
742- (challengeFinishTxid) = BitvmTxParser.computeTxid (
749+ (challengeFinishTxid) = BitvmTxParser._computeTxid (
743750 rawChallengeFinishTx
744751 );
745752 if (graphData.NackTxids.length <= txnIndex)
@@ -752,7 +759,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
752759 kickoffTxid,
753760 kickoffVout,
754761 disproverAddress
755- ) = BitvmTxParser.parseDisproveTx (rawChallengeFinishTx);
762+ ) = BitvmTxParser._parseDisproveTx (rawChallengeFinishTx);
756763 if (kickoffTxid != graphData.kickoffTxid) revert TxidMismatch ();
757764 if (kickoffVout != BitvmTxParser.DISPROVE_CONNECTOR_VOUT)
758765 revert TxidMismatch ();
@@ -762,7 +769,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
762769 kickoffTxid,
763770 kickoffVout,
764771 disproverAddress
765- ) = BitvmTxParser.parseQuickChallengeTx (rawChallengeFinishTx);
772+ ) = BitvmTxParser._parseQuickChallengeTx (rawChallengeFinishTx);
766773 if (kickoffTxid != graphData.kickoffTxid) revert TxidMismatch ();
767774 if (kickoffVout != BitvmTxParser.GUARDIAN_CONNECTOR_VOUT)
768775 revert TxidMismatch ();
@@ -774,7 +781,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
774781 kickoffTxid,
775782 kickoffVout,
776783 disproverAddress
777- ) = BitvmTxParser.parseChallengeIncompleteKickoffTx (
784+ ) = BitvmTxParser._parseChallengeIncompleteKickoffTx (
778785 rawChallengeFinishTx
779786 );
780787 if (kickoffTxid != graphData.kickoffTxid) revert TxidMismatch ();
@@ -835,7 +842,7 @@ contract GatewayUpgradeable is BitvmPolicy, Initializable, IGateway {
835842 uint256 nonce ,
836843 bytes [] calldata committeeSigs
837844 ) external {
838- bytes32 msgHash = getUnlockStakeDigest (operator, amount);
845+ bytes32 msgHash = _getUnlockStakeDigest (operator, amount);
839846 committeeManagement.executeNoncedSignatures (
840847 msgHash,
841848 nonce,
0 commit comments