Skip to content

Commit

Permalink
feat: P-926 support other 4 bitcoin networks for brc20 contract
Browse files Browse the repository at this point in the history
  • Loading branch information
higherordertech committed Jul 18, 2024
1 parent 31bcf9b commit d54a065
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2020-2024 Trust Computing GmbH.
// This file is part of Litentry.
//
// Litentry is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Litentry is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Litentry. If not, see <https://www.gnu.org/licenses/>.

// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.8;

import "../Constants.sol";
import "../../libraries/Identities.sol";

library BRC20 {
function getDefaultTokenNetworks() internal pure returns (uint32[] memory) {
uint32[] memory networks = new uint32[](5);
networks[0] = Web3Networks.BitcoinP2tr;
networks[1] = Web3Networks.BitcoinP2pkh;
networks[2] = Web3Networks.BitcoinP2sh;
networks[3] = Web3Networks.BitcoinP2wpkh;
networks[4] = Web3Networks.BitcoinP2wsh;
return networks;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

pragma solidity ^0.8.8;

import "../Constants.sol";
import "../../libraries/Identities.sol";
import "../Constants.sol";
import "./BRC20.sol";

library Btcs {
function getTokenName() internal pure returns (string memory) {
Expand All @@ -39,9 +40,8 @@ library Btcs {
ranges[8] = 800 * Constants.decimals_factor;
return ranges;
}

function getTokenNetworks() internal pure returns (uint32[] memory) {
uint32[] memory networks = new uint32[](1);
networks[0] = Web3Networks.BitcoinP2tr;
return networks;
return BRC20.getDefaultTokenNetworks();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

pragma solidity ^0.8.8;

import "../Constants.sol";
import "../../libraries/Identities.sol";
import "../Constants.sol";
import "./BRC20.sol";

library Cats {
function getTokenName() internal pure returns (string memory) {
Expand All @@ -38,9 +39,8 @@ library Cats {
ranges[7] = 800000 * Constants.decimals_factor;
return ranges;
}

function getTokenNetworks() internal pure returns (uint32[] memory) {
uint32[] memory networks = new uint32[](1);
networks[0] = Web3Networks.BitcoinP2tr;
return networks;
return BRC20.getDefaultTokenNetworks();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

pragma solidity ^0.8.8;

import "../Constants.sol";
import "../../libraries/Identities.sol";
import "../Constants.sol";
import "./BRC20.sol";

library Long {
function getTokenName() internal pure returns (string memory) {
Expand All @@ -39,9 +40,8 @@ library Long {
ranges[8] = 3000 * Constants.decimals_factor;
return ranges;
}

function getTokenNetworks() internal pure returns (uint32[] memory) {
uint32[] memory networks = new uint32[](1);
networks[0] = Web3Networks.BitcoinP2tr;
return networks;
return BRC20.getDefaultTokenNetworks();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

pragma solidity ^0.8.8;

import "../Constants.sol";
import "../../libraries/Identities.sol";
import "../Constants.sol";
import "./BRC20.sol";

library Mmss {
function getTokenName() internal pure returns (string memory) {
Expand All @@ -39,9 +40,8 @@ library Mmss {
ranges[8] = 2000 * Constants.decimals_factor;
return ranges;
}

function getTokenNetworks() internal pure returns (uint32[] memory) {
uint32[] memory networks = new uint32[](1);
networks[0] = Web3Networks.BitcoinP2tr;
return networks;
return BRC20.getDefaultTokenNetworks();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

pragma solidity ^0.8.8;

import "../Constants.sol";
import "../../libraries/Identities.sol";
import "../Constants.sol";
import "./BRC20.sol";

library Ordi {
function getTokenName() internal pure returns (string memory) {
Expand All @@ -38,9 +39,8 @@ library Ordi {
ranges[7] = 500 * Constants.decimals_factor;
return ranges;
}

function getTokenNetworks() internal pure returns (uint32[] memory) {
uint32[] memory networks = new uint32[](1);
networks[0] = Web3Networks.BitcoinP2tr;
return networks;
return BRC20.getDefaultTokenNetworks();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

pragma solidity ^0.8.8;

import "../Constants.sol";
import "../../libraries/Identities.sol";
import "../Constants.sol";
import "./BRC20.sol";

library Rats {
function getTokenName() internal pure returns (string memory) {
Expand All @@ -39,9 +40,8 @@ library Rats {
ranges[8] = 2000000 * Constants.decimals_factor;
return ranges;
}

function getTokenNetworks() internal pure returns (uint32[] memory) {
uint32[] memory networks = new uint32[](1);
networks[0] = Web3Networks.BitcoinP2tr;
return networks;
return BRC20.getDefaultTokenNetworks();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

pragma solidity ^0.8.8;

import "../Constants.sol";
import "../../libraries/Identities.sol";
import "../Constants.sol";
import "./BRC20.sol";

library Sats {
function getTokenName() internal pure returns (string memory) {
Expand All @@ -39,9 +40,8 @@ library Sats {
ranges[8] = 6000000000 * Constants.decimals_factor;
return ranges;
}

function getTokenNetworks() internal pure returns (uint32[] memory) {
uint32[] memory networks = new uint32[](1);
networks[0] = Web3Networks.BitcoinP2tr;
return networks;
return BRC20.getDefaultTokenNetworks();
}
}

0 comments on commit d54a065

Please sign in to comment.