Skip to content

Commit

Permalink
[#312] parse and upload dev and user doc to MultiBaas (#359)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeff Wentworth <[email protected]>
  • Loading branch information
n0thingness and shoenseiwaso authored Jun 7, 2024
1 parent 6f2a4b1 commit 860f2ac
Show file tree
Hide file tree
Showing 7 changed files with 272 additions and 43 deletions.
90 changes: 77 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hardhat-multibaas-plugin",
"version": "0.3.3",
"version": "0.3.4",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"keywords": [
Expand Down Expand Up @@ -35,6 +35,7 @@
"validator": "^13.12.0"
},
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.14.1",
"@types/validator": "^13.11.10",
"@typescript-eslint/eslint-plugin": "^7.11.0",
Expand All @@ -44,6 +45,7 @@
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"fs-extra": "^11.2.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.5",
"prettier": "^3.3.0",
Expand Down
74 changes: 56 additions & 18 deletions sample/contracts/MetaCoin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,66 @@ import "./ConvertLib.sol";
// coin/token contracts. If you want to create a standards-compliant
// token, see: https://github.com/ConsenSys/Tokens. Cheers!

/**
* @title MetaCoin
* @dev A simple coin-like contract example. This contract is not standards compliant and is meant for educational purposes. (devdoc)
* @notice A simple coin-like contract example. This contract is not standards compliant and is meant for educational purposes. (userdoc)
*/
contract MetaCoin {
mapping (address => uint) balances;
mapping(address => uint) balances;

event Transfer(address indexed _from, address indexed _to, uint256 _value);
/**
* @dev Event triggered when coins are transferred. (devdoc)
* @notice Event triggered when coins are transferred. (userdoc)
* @param _from The address from which the coins are sent.
* @param _to The address to which the coins are sent.
* @param _value The amount of coins transferred.
*/
event Transfer(address indexed _from, address indexed _to, uint256 _value);

constructor() {
balances[tx.origin] = 10000;
}
/**
* @dev Constructor that gives the contract creator an initial balance of 10000 MetaCoins. (devdoc)
* @notice Constructor that gives the contract creator an initial balance of 10000 MetaCoins. (userdoc)
*/
constructor() {
balances[tx.origin] = 10000;
}

function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Transfer(msg.sender, receiver, amount);
return true;
}
/**
* @dev Transfers coins from sender's account to receiver's account if the sender has sufficient balance. (devdoc)
* @notice Send `amount` of MetaCoins to `receiver`. (userdoc)
* @param receiver The address of the receiver.
* @param amount The amount of MetaCoins to send.
* @return sufficient Returns true if the sender has enough balance, false otherwise.
*/
function sendCoin(
address receiver,
uint amount
) public returns (bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Transfer(msg.sender, receiver, amount);
return true;
}

function getBalanceInEth(address addr) public view returns(uint){
return ConvertLib.convert(getBalance(addr),2);
}
/**
* @dev Converts the balance of `addr` from MetaCoins to Ether. (devdoc)
* @notice Get the balance of `addr` in Ether. (userdoc)
* @param addr The address whose balance is to be checked.
* @return The balance in Ether.
*/
function getBalanceInEth(address addr) public view returns (uint) {
return ConvertLib.convert(getBalance(addr), 2);
}

function getBalance(address addr) public view returns(uint) {
return balances[addr];
}
/**
* @dev Returns the balance of `addr`. (devdoc)
* @notice Get the balance of `addr` in MetaCoins. (userdoc)
* @param addr The address whose balance is to be checked.
* @return The balance in MetaCoins.
*/
function getBalance(address addr) public view returns (uint) {
return balances[addr];
}
}
14 changes: 8 additions & 6 deletions sample/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 860f2ac

Please sign in to comment.