Skip to content

Commit

Permalink
harmony-one#99 reduced OneBTC Contract size from 24KB to 21KB
Browse files Browse the repository at this point in the history
  • Loading branch information
hashmesan committed Apr 25, 2022
1 parent d5399cc commit 267a224
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion contract/bridge/contracts/TxValidate.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "@openzeppelin/contracts-upgradeable/math/MathUpgradeable.sol";
import {BTCUtils} from "@interlay/bitcoin-spv-sol/contracts/BTCUtils.sol";
import {BytesLib} from "@interlay/bitcoin-spv-sol/contracts/BytesLib.sol";
Expand All @@ -16,7 +17,7 @@ library TxValidate {
address recipientBtcAddress,
uint256 opReturnId,
uint256 outputIndex
) internal pure returns (uint256) {
) external pure returns (uint256) {
uint256 btcAmount;
address btcAddress;

Expand Down
2 changes: 1 addition & 1 deletion contract/bridge/contracts/crypto/Secp256k1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ library Secp256k1 {
uint256 scale,
uint256 Px,
uint256 Py
) internal pure returns (uint256, uint256) {
) external pure returns (uint256, uint256) {
require(scale % NN != 0, "invalid scale");
return EllipticCurve.ecMul(scale, Px, Py, AA, PP);
}
Expand Down
11 changes: 10 additions & 1 deletion contract/bridge/migrations/3_deploy_onebtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@ const { deployProxy } = require('@openzeppelin/truffle-upgrades');
const OneBtc = artifacts.require("OneBtc");
const RelayMock = artifacts.require("RelayMock");
const ExchangeRateOracleWrapper = artifacts.require("ExchangeRateOracleWrapper");
const Secp256k1 = artifacts.require("Secp256k1");
const TxValidate = artifacts.require("TxValidate");

module.exports = async function(deployer) {

const IRelay = await RelayMock.deployed();
const IExchangeRateOracleWrapper = await ExchangeRateOracleWrapper.deployed();
const Secp256k1Lib = await deployer.deploy(Secp256k1);
OneBtc.link("Secp256k1", Secp256k1Lib.address);

const c = await deployProxy(OneBtc, [IRelay.address, IExchangeRateOracleWrapper.address], { deployer } );
const TxValidateLib = await deployer.deploy(TxValidate);
OneBtc.link("TxValidate", TxValidateLib.address);

const c = await deployProxy(OneBtc, [IRelay.address, IExchangeRateOracleWrapper.address],
{ deployer, unsafeAllowLinkedLibraries: true } );
console.log(c.address)
};

0 comments on commit 267a224

Please sign in to comment.