From bf8fea3bf8e2c78f9d293d417b21169be74c45d4 Mon Sep 17 00:00:00 2001 From: shareong <740310627@qq.com> Date: Thu, 14 May 2020 17:36:32 +0800 Subject: [PATCH] rename bcos ledger contract --- demo/.prepare.sh | 8 ++-- demo/bcos/clear.sh | 2 +- demo/htlc_config.sh | 22 +++++----- .../htlc/{BAC001.sol => LedgerSample.sol} | 44 +++++++++---------- .../{BACHTLC.sol => LedgerSampleHTLC.sol} | 16 +++---- 5 files changed, 46 insertions(+), 46 deletions(-) rename src/main/resources/chains-sample/bcos/htlc/{BAC001.sol => LedgerSample.sol} (84%) rename src/main/resources/chains-sample/bcos/htlc/{BACHTLC.sol => LedgerSampleHTLC.sol} (83%) diff --git a/demo/.prepare.sh b/demo/.prepare.sh index fffb3c1cb..95f622d51 100644 --- a/demo/.prepare.sh +++ b/demo/.prepare.sh @@ -38,10 +38,10 @@ prepare_bcos() LOG_INFO "Download HelloWeCross.sol ..." cp ${WECROSS_ROOT}/src/main/resources/chains-sample/bcos/HelloWeCross.sol ./ - LOG_INFO "Download bactool ..." - git clone --depth 1 https://github.com/Shareong/bactool.git - tar -zcf bactool.tar.gz bactool - rm -rf bactool + LOG_INFO "Download ledger-tool ..." + git clone --depth 1 https://github.com/Shareong/ledger-tool.git + tar -zcf ledger-tool.tar.gz ledger-tool + rm -rf ledger-tool cd - } diff --git a/demo/bcos/clear.sh b/demo/bcos/clear.sh index 353b69547..38a697239 100644 --- a/demo/bcos/clear.sh +++ b/demo/bcos/clear.sh @@ -2,4 +2,4 @@ if [ -e nodes/127.0.0.1/stop_all.sh ]; then bash nodes/127.0.0.1/stop_all.sh fi -rm -rf console ipconf nodes accounts bactool \ No newline at end of file +rm -rf console ipconf nodes accounts ledger-tool \ No newline at end of file diff --git a/demo/htlc_config.sh b/demo/htlc_config.sh index 7c6a12207..9f1ac0264 100644 --- a/demo/htlc_config.sh +++ b/demo/htlc_config.sh @@ -26,9 +26,9 @@ deploy_bcos_htlc() cd bcos/console rm -rf deploylog.txt bash start.sh < tmp.txt BCOS_LEDGER=$(grep 'assetAddress:' tmp.txt | awk '{print $2}') @@ -61,7 +61,7 @@ init_bcos_bcos_htlc() cd bcos/console bash start.sh < routers-payment/127.0.0.1-8250-25500/conf/accounts/bcos_sender/account.toml [account] type = 'BCOS2.0' diff --git a/src/main/resources/chains-sample/bcos/htlc/BAC001.sol b/src/main/resources/chains-sample/bcos/htlc/LedgerSample.sol similarity index 84% rename from src/main/resources/chains-sample/bcos/htlc/BAC001.sol rename to src/main/resources/chains-sample/bcos/htlc/LedgerSample.sol index eeb35547c..61b420b10 100755 --- a/src/main/resources/chains-sample/bcos/htlc/BAC001.sol +++ b/src/main/resources/chains-sample/bcos/htlc/LedgerSample.sol @@ -213,26 +213,26 @@ contract Suspendable is SuspenderRole { } } -contract IBAC001Receiver { +contract ILedgerSampleReceiver { /** * @notice Handle the receipt of an NFT - * @dev The BAC001 smart contract calls this function on the recipient + * @dev The LedgerSample smart contract calls this function on the recipient */ - function onBAC001Received(address operator, address from, uint256 value, bytes memory data) + function onLedgerSampleReceived(address operator, address from, uint256 value, bytes memory data) public returns (bytes4); } -contract BAC001Holder is IBAC001Receiver { - function onBAC001Received(address, address, uint256, bytes memory) public returns (bytes4) { - return this.onBAC001Received.selector; +contract LedgerSampleHolder is ILedgerSampleReceiver { + function onLedgerSampleReceived(address, address, uint256, bytes memory) public returns (bytes4) { + return this.onLedgerSampleReceived.selector; } } /** - * @title Standard BAC001 asset + * @title Standard LedgerSample asset */ -contract BAC001 is IssuerRole, Suspendable { +contract LedgerSample is IssuerRole, Suspendable { using SafeMath for uint256; using Address for address; @@ -243,8 +243,8 @@ contract BAC001 is IssuerRole, Suspendable { string private _shortName; uint8 private _minUnit; - // Equals to `bytes4(keccak256("onBAC001Received(address,address,uint256,bytes)"))` - bytes4 private constant _BAC001_RECEIVED = 0xc73d16ae; + // Equals to `bytes4(keccak256("onLedgerSampleReceived(address,address,uint256,bytes)"))` + bytes4 private constant _LedgerSample_RECEIVED = 0xc73d16ae; event Send( address indexed from, address indexed to, uint256 value, bytes data); @@ -276,13 +276,13 @@ contract BAC001 is IssuerRole, Suspendable { function send(address to, uint256 value, bytes data) public whenNotSuspended { _send(msg.sender, to, value, data); - require(_checkOnBAC001Received(msg.sender, to, value, data), "BAC001: send to non BAC001Receiver implementer"); + // require(_checkOnLedgerSampleReceived(msg.sender, to, value, data), "LedgerSample: send to non LedgerSampleReceiver implementer"); } // function safeSend(address to, uint256 value, bytes data) public whenNotSuspended { // send(to, value, data); -// require(_checkOnBAC001Received(msg.sender, to, value, data), "BAC001: send to non BAC001Receiver implementer"); +// require(_checkOnLedgerSampleReceived(msg.sender, to, value, data), "LedgerSample: send to non LedgerSampleReceiver implementer"); // } @@ -301,7 +301,7 @@ contract BAC001 is IssuerRole, Suspendable { _send(from, to, value, data); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); //add - require(_checkOnBAC001Received(from, to, value, data), "BAC001: send to non BAC001Receiver implementer"); + // require(_checkOnLedgerSampleReceived(from, to, value, data), "LedgerSample: send to non LedgerSampleReceiver implementer"); } @@ -309,7 +309,7 @@ contract BAC001 is IssuerRole, Suspendable { //// safe todo // function safeSendFrom(address from, address to, uint256 value, bytes data) public whenNotSuspended { // sendFrom(from, to, value, data); -// require(_checkOnBAC001Received(from, to, value, data), "BAC001: send to non BAC001Receiver implementer"); +// require(_checkOnLedgerSampleReceived(from, to, value, data), "LedgerSample: send to non LedgerSampleReceiver implementer"); // } @@ -327,15 +327,15 @@ contract BAC001 is IssuerRole, Suspendable { } - function _checkOnBAC001Received(address from, address to, uint256 value, bytes data) + function _checkOnLedgerSampleReceived(address from, address to, uint256 value, bytes data) internal returns (bool) { if (!to.isContract()) { return true; } - bytes4 retval = IBAC001Receiver(to).onBAC001Received(from, to, value, data); - return (retval == _BAC001_RECEIVED); + bytes4 retval = ILedgerSampleReceiver(to).onLedgerSampleReceived(from, to, value, data); + return (retval == _LedgerSample_RECEIVED); } /** @@ -394,7 +394,7 @@ contract BAC001 is IssuerRole, Suspendable { * @dev Send asset for a specified addresses. */ function _send(address from, address to, uint256 value, bytes data) internal { - require(to != address(0), "BAC001: send to the zero address"); + require(to != address(0), "LedgerSample: send to the zero address"); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); @@ -405,7 +405,7 @@ contract BAC001 is IssuerRole, Suspendable { * @dev Internal function that issues an amount of the asset and assigns it to */ function _issue(address account, uint256 value, bytes data) internal { - require(account != address(0), "BAC001: issue to the zero address"); + require(account != address(0), "LedgerSample: issue to the zero address"); _totalAmount = _totalAmount.add(value); _balances[account] = _balances[account].add(value); @@ -416,7 +416,7 @@ contract BAC001 is IssuerRole, Suspendable { * @dev Internal function that destroys an amount of the asset of a given */ function _destroy(address account, uint256 value, bytes data) internal { - require(account != address(0), "BAC001: destroy from the zero address"); + require(account != address(0), "LedgerSample: destroy from the zero address"); _totalAmount = _totalAmount.sub(value); _balances[account] = _balances[account].sub(value); @@ -427,8 +427,8 @@ contract BAC001 is IssuerRole, Suspendable { * @dev Approve an address to spend another addresses' assets. */ function _approve(address owner, address spender, uint256 value) internal { - require(owner != address(0), "BAC001: approve from the zero address"); - require(spender != address(0), "BAC001: approve to the zero address"); + require(owner != address(0), "LedgerSample: approve from the zero address"); + require(spender != address(0), "LedgerSample: approve to the zero address"); _allowed[owner][spender] = value; emit Approval( owner, spender, value); diff --git a/src/main/resources/chains-sample/bcos/htlc/BACHTLC.sol b/src/main/resources/chains-sample/bcos/htlc/LedgerSampleHTLC.sol similarity index 83% rename from src/main/resources/chains-sample/bcos/htlc/BACHTLC.sol rename to src/main/resources/chains-sample/bcos/htlc/LedgerSampleHTLC.sol index 8731a6d41..97d723836 100644 --- a/src/main/resources/chains-sample/bcos/htlc/BACHTLC.sol +++ b/src/main/resources/chains-sample/bcos/htlc/LedgerSampleHTLC.sol @@ -1,12 +1,12 @@ pragma solidity ^0.4.24; pragma experimental ABIEncoderV2; -import "./BAC001.sol"; +import "./LedgerSample.sol"; import "./HTLC.sol"; -contract BACHTLC is HTLC, BAC001Holder { +contract LedgerSampleHTLC is HTLC, LedgerSampleHolder { - // bac001 asset contract address + // asset contract address address assetContract; function init(string[] _ss) @@ -39,14 +39,14 @@ contract BACHTLC is HTLC, BAC001Holder { string memory _hash = _ss[0]; address sender = getSender(_hash); uint amount = getAmount(_hash); - if (BAC001(assetContract).allowance(sender, address(this)) < uint(amount)) + if (LedgerSample(assetContract).allowance(sender, address(this)) < uint(amount)) { result[0] = "insufficient authorized assets"; return; } // This htlc contract becomes the temporary owner of the assets - BAC001(assetContract).sendFrom(sender, address(this), uint(amount),""); + LedgerSample(assetContract).sendFrom(sender, address(this), uint(amount),""); setLockStatus(_hash); result[0] = "success"; @@ -70,7 +70,7 @@ contract BACHTLC is HTLC, BAC001Holder { // transfer from htlc contract to receiver address receiver = getReceiver(_hash); uint amount = getAmount(_hash); - BAC001(assetContract).send(receiver, uint(amount),""); + LedgerSample(assetContract).send(receiver, uint(amount),""); setUnlockStatus(_hash); setSecret(_ss); @@ -94,7 +94,7 @@ contract BACHTLC is HTLC, BAC001Holder { // transfer from htlc contract to sender address sender = getSender(_hash); uint amount = getAmount(_hash); - BAC001(assetContract).send(sender, uint(amount),""); + LedgerSample(assetContract).send(sender, uint(amount),""); setRollbackStatus(_hash); result[0] = "success"; @@ -106,7 +106,7 @@ contract BACHTLC is HTLC, BAC001Holder { returns(string[] result) { result = new string[](1); - uint b = BAC001(assetContract).balance(stringToAddress(_ss[0])); + uint b = LedgerSample(assetContract).balance(stringToAddress(_ss[0])); result[0] = uintToString(b); } }