diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..dd84ea7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md new file mode 100644 index 0000000..48d5f81 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/custom.md @@ -0,0 +1,10 @@ +--- +name: Custom issue template +about: Describe this issue template's purpose here. +title: '' +labels: '' +assignees: '' + +--- + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..093a954 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Node.js CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present + - run: npm test diff --git a/contract address b/contract address new file mode 100644 index 0000000..e868c20 --- /dev/null +++ b/contract address @@ -0,0 +1,103 @@ +pragma solidity ^0.5.8; + +interface ITRC20 { + function transfer(address to, uint256 value) external returns (bool); + function approve(address spender, uint256 value) external returns (bool); + function transferFrom(address from, address to, uint256 value) external returns (bool); + function totalSupply() external view returns (uint256); + function balanceOf(address who) external view returns (uint256); + function allowance(address owner, address spender) external view returns (uint256); + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval(address indexed owner, address indexed spender, uint256 value); +} + +library SafeMath { + + function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + uint256 c = a + b; + require(c >= a, errorMessage); + + return c; + } + + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b <= a, errorMessage); + uint256 c = a - b; + + return c; + } + +} + +contract BTT is ITRC20 { + using SafeMath for uint256; + string constant public name = "BitTorrent"; + string constant public symbol = "BTT"; + uint8 constant public decimals = 18; + + uint256 private totalSupply_; + mapping(address => uint256) private balanceOf_; + mapping(address => mapping(address => uint256)) private allowance_; + + constructor(address fund) public { + totalSupply_ = 9900 * 1e8 * 1e18 * 1e3; + balanceOf_[fund] = totalSupply_; + emit Transfer(address(0x00), fund, totalSupply_); + } + + function totalSupply() public view returns (uint256) { + return totalSupply_; + } + + function balanceOf(address guy) public view returns (uint256){ + return balanceOf_[guy]; + } + + function allowance(address src, address guy) public view returns (uint256){ + return allowance_[src][guy]; + } + + function approve(address guy, uint256 sad) public returns (bool) { + allowance_[msg.sender][guy] = sad; + emit Approval(msg.sender, guy, sad); + return true; + } + + function transfer(address dst, uint256 sad) public returns (bool) { + return transferFrom(msg.sender, dst, sad); + } + + function transferFrom(address src, address dst, uint256 sad) + public returns (bool) + { + require(balanceOf_[src] >= sad, "src balance not enough"); + + if (src != msg.sender && allowance_[src][msg.sender] != uint256(-1)) { + require(allowance_[src][msg.sender] >= sad, "src allowance is not enough"); + allowance_[src][msg.sender] = allowance_[src][msg.sender].sub(sad, "allowance subtraction overflow") ; + } + balanceOf_[src] = balanceOf_[src].sub(sad, "from balance subtraction overflow"); + balanceOf_[dst] = balanceOf_[dst].add(sad, "to balance addition overflow") ; + + emit Transfer(src, dst, sad); + return true; + } + + function increaseAllowance(address guy, uint256 addedValue) public returns (bool) { + require(guy != address(0)); + + allowance_[msg.sender][guy] = allowance_[msg.sender][guy].add(addedValue, "allowance addition overflow") ; + emit Approval(msg.sender, guy, allowance_[msg.sender][guy]); + return true; + } + + function decreaseAllowance(address guy, uint256 subtractedValue) public returns (bool) { + require(guy != address(0)); + + allowance_[msg.sender][guy] = allowance_[msg.sender][guy].sub(subtractedValue, "allowance subtraction overflow") ; + emit Approval(msg.sender, guy, allowance_[msg.sender][guy]); + return true; + } +} + +