-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add ERC20/721 support
- Loading branch information
Showing
15 changed files
with
231 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ English | [日本語](README_JA.md) | |
- `exchange`: Implementations of the various exchanges. | ||
- `ledger`: A data storage system that manages the data required as additional information in the ledger. | ||
- `payment`: A set of functions required to build an off-chain payment system. | ||
- `token`: Implementation of the various token formats: Bonds, Shares, etc. | ||
- `token`: Implementation of the various token formats: ERC20, ERC721, Bonds, Shares, etc. | ||
- `utils`: A set of other utility functions. | ||
|
||
## Install | ||
|
@@ -57,7 +57,7 @@ $ pip install -r requirements.txt | |
Install openzeppelin-contracts. | ||
|
||
```bash | ||
$ brownie pm install OpenZeppelin/[email protected].1 | ||
$ brownie pm install OpenZeppelin/[email protected].2 | ||
``` | ||
|
||
## Compile Contracts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ | |
- `exchange`: 様々な取引機能(Exchange)の実装です。 | ||
- `ledger`: 法定原簿に必要な付加情報を管理するためのデータストレージ機能を提供します。 | ||
- `payment`: オフチェーン決済を実現するため機能群です。 | ||
- `token`: 各種トークンフォーマットの実装です(Bond型、Share型など)。 | ||
- `token`: 各種トークンフォーマットの実装です(ERC20、ERC721、Bond型、Share型など)。 | ||
- `utils`: その他のユーティリティ機能です。 | ||
|
||
## インストール | ||
|
@@ -55,7 +55,7 @@ $ pip install -r requirements.txt | |
|
||
openzeppelin-contractsをインストールします。 | ||
```bash | ||
$ brownie pm install OpenZeppelin/[email protected].1 | ||
$ brownie pm install OpenZeppelin/[email protected].2 | ||
``` | ||
|
||
## コントラクトのコンパイル | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ compiler: | |
solc: | ||
version: 0.8.19 | ||
dependencies: | ||
OpenZeppelin/[email protected].1 | ||
OpenZeppelin/[email protected].2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
pragma solidity ^0.8.0; | ||
|
||
import "OpenZeppelin/[email protected].1/contracts/utils/math/SafeMath.sol"; | ||
import "OpenZeppelin/[email protected].2/contracts/utils/math/SafeMath.sol"; | ||
import "./EscrowStorage.sol"; | ||
import "../access/Ownable.sol"; | ||
import "../utils/Errors.sol"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
|
||
pragma solidity ^0.8.0; | ||
|
||
import "OpenZeppelin/[email protected].1/contracts/utils/math/SafeMath.sol"; | ||
import "OpenZeppelin/[email protected].2/contracts/utils/math/SafeMath.sol"; | ||
import "./ExchangeStorage.sol"; | ||
import "../access/Ownable.sol"; | ||
import "../utils/Errors.sol"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
pragma solidity ^0.8.0; | ||
|
||
import "OpenZeppelin/[email protected].1/contracts/utils/math/SafeMath.sol"; | ||
import "OpenZeppelin/[email protected].2/contracts/utils/math/SafeMath.sol"; | ||
import "./EscrowStorage.sol"; | ||
import "../access/Ownable.sol"; | ||
import "../utils/Errors.sol"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
|
||
pragma solidity ^0.8.0; | ||
|
||
import "OpenZeppelin/[email protected].1/contracts/utils/math/SafeMath.sol"; | ||
import "OpenZeppelin/[email protected].2/contracts/utils/math/SafeMath.sol"; | ||
import "../access/Ownable.sol"; | ||
import "../utils/Errors.sol"; | ||
import "../../interfaces/ContractReceiver.sol"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright BOOSTRY Co., Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
pragma solidity ^0.8.0; | ||
|
||
import "OpenZeppelin/[email protected]/contracts/token/ERC20/ERC20.sol"; | ||
import "OpenZeppelin/[email protected]/contracts/token/ERC20/extensions/ERC20Burnable.sol"; | ||
import "OpenZeppelin/[email protected]/contracts/access/Ownable.sol"; | ||
|
||
contract IbetERC20 is ERC20, ERC20Burnable, Ownable { | ||
constructor() ERC20("IbetERC20", "") {} | ||
|
||
function mint(address to, uint256 amount) public onlyOwner { | ||
_mint(to, amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright BOOSTRY Co., Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
pragma solidity ^0.8.0; | ||
|
||
import "OpenZeppelin/[email protected]/contracts/token/ERC721/ERC721.sol"; | ||
import "OpenZeppelin/[email protected]/contracts/token/ERC721/extensions/ERC721Burnable.sol"; | ||
import "OpenZeppelin/[email protected]/contracts/access/Ownable.sol"; | ||
|
||
contract IbetERC721 is ERC721, ERC721Burnable, Ownable { | ||
constructor() ERC721("IbetERC721", "") {} | ||
|
||
function safeMint(address to, uint256 tokenId) public onlyOwner { | ||
_safeMint(to, tokenId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
|
||
pragma solidity ^0.8.0; | ||
|
||
import "OpenZeppelin/[email protected].1/contracts/utils/math/SafeMath.sol"; | ||
import "OpenZeppelin/[email protected].2/contracts/utils/math/SafeMath.sol"; | ||
import "../access/Ownable.sol"; | ||
import "../utils/Errors.sol"; | ||
import "../../interfaces/ContractReceiver.sol"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
pragma solidity ^0.8.0; | ||
|
||
import "OpenZeppelin/[email protected].1/contracts/utils/math/SafeMath.sol"; | ||
import "OpenZeppelin/[email protected].2/contracts/utils/math/SafeMath.sol"; | ||
import "../access/Ownable.sol"; | ||
import "../ledger/PersonalInfo.sol"; | ||
import "../utils/Errors.sol"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
|
||
pragma solidity ^0.8.0; | ||
|
||
import "OpenZeppelin/[email protected].1/contracts/utils/math/SafeMath.sol"; | ||
import "OpenZeppelin/[email protected].2/contracts/utils/math/SafeMath.sol"; | ||
import "../access/Ownable.sol"; | ||
import "../utils/Errors.sol"; | ||
import "../../interfaces/ContractReceiver.sol"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
pragma solidity ^0.8.0; | ||
|
||
import "OpenZeppelin/[email protected].1/contracts/utils/math/SafeMath.sol"; | ||
import "OpenZeppelin/[email protected].2/contracts/utils/math/SafeMath.sol"; | ||
import "../access/Ownable.sol"; | ||
import "../ledger/PersonalInfo.sol"; | ||
import "../utils/Errors.sol"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
""" | ||
Copyright BOOSTRY Co., Ltd. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
SPDX-License-Identifier: Apache-2.0 | ||
""" | ||
import brownie | ||
|
||
|
||
class TestDeploy: | ||
|
||
########################################################## | ||
# Normal | ||
########################################################## | ||
|
||
# Normal_1 | ||
def test_normal_1(self, IbetERC20, users): | ||
issuer = users["issuer"] | ||
|
||
# deploy | ||
token = issuer.deploy(IbetERC20) | ||
|
||
# assertion | ||
assert token.name() == "IbetERC20" | ||
assert token.symbol() == "" | ||
assert token.decimals() == 18 | ||
assert token.totalSupply() == 0 | ||
assert token.balanceOf(issuer.address) == 0 | ||
|
||
|
||
class TestMint: | ||
|
||
########################################################## | ||
# Normal | ||
########################################################## | ||
|
||
# Normal_1 | ||
def test_normal_1(self, IbetERC20, users): | ||
issuer = users["issuer"] | ||
|
||
# deploy | ||
token = issuer.deploy(IbetERC20) | ||
|
||
# mint | ||
token.mint(issuer.address, 10, {"from": issuer}) | ||
|
||
# assertion | ||
assert token.name() == "IbetERC20" | ||
assert token.symbol() == "" | ||
assert token.decimals() == 18 | ||
assert token.totalSupply() == 10 | ||
assert token.balanceOf(issuer.address) == 10 | ||
|
||
########################################################## | ||
# Error | ||
########################################################## | ||
|
||
# Error_1 | ||
def test_error_1(self, IbetERC20, users): | ||
issuer = users["issuer"] | ||
other = users["user1"] | ||
|
||
# deploy | ||
token = issuer.deploy(IbetERC20) | ||
|
||
# mint | ||
with brownie.reverts(revert_msg="Ownable: caller is not the owner"): | ||
token.mint(issuer.address, 10, {"from": other}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
""" | ||
Copyright BOOSTRY Co., Ltd. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
SPDX-License-Identifier: Apache-2.0 | ||
""" | ||
import brownie | ||
|
||
|
||
class TestDeploy: | ||
|
||
########################################################## | ||
# Normal | ||
########################################################## | ||
|
||
# Normal_1 | ||
def test_normal_1(self, IbetERC721, users): | ||
issuer = users["issuer"] | ||
|
||
# deploy | ||
token = issuer.deploy(IbetERC721) | ||
|
||
# assertion | ||
assert token.name() == "IbetERC721" | ||
assert token.balanceOf(issuer.address) == 0 | ||
|
||
|
||
class TestSafeMint: | ||
|
||
########################################################## | ||
# Normal | ||
########################################################## | ||
|
||
# Normal_1 | ||
def test_normal_1(self, IbetERC721, users): | ||
issuer = users["issuer"] | ||
|
||
# deploy | ||
token = issuer.deploy(IbetERC721) | ||
|
||
# mint | ||
token.safeMint(issuer.address, 123, {"from": issuer}) | ||
|
||
# assertion | ||
assert token.name() == "IbetERC721" | ||
assert token.balanceOf(issuer.address) == 1 | ||
assert token.ownerOf(123) == issuer.address | ||
|
||
|
||
########################################################## | ||
# Error | ||
########################################################## | ||
|
||
# Error_1 | ||
def test_error_1(self, IbetERC721, users): | ||
issuer = users["issuer"] | ||
other = users["user1"] | ||
|
||
# deploy | ||
token = issuer.deploy(IbetERC721) | ||
|
||
# mint | ||
with brownie.reverts(revert_msg="Ownable: caller is not the owner"): | ||
token.safeMint(issuer.address, 123, {"from": other}) |