-
Notifications
You must be signed in to change notification settings - Fork 490
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
2,297 additions
and
4 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 |
---|---|---|
@@ -1,12 +1,20 @@ | ||
*.txt | ||
|
||
node_modules/ | ||
.build/ | ||
cache/ | ||
.idea/ | ||
artifacts/ | ||
starknet-artifacts/ | ||
.pytest_cache/ | ||
build/ | ||
tmp/ | ||
**/*_compiled.json | ||
**/*_abi.json | ||
package-lock.json | ||
**/*compiled.json | ||
**/*abi.json | ||
**/*.bin | ||
|
||
**/*.txt | ||
|
||
**/*.sum | ||
|
||
*/**/__pycache__ | ||
*/**/__pycache__ |
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,18 @@ | ||
module.exports = { | ||
env: { | ||
browser: false, | ||
es2021: true, | ||
mocha: true, | ||
node: true, | ||
}, | ||
plugins: ["@typescript-eslint"], | ||
extends: ["standard", "plugin:prettier/recommended", "plugin:node/recommended"], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
}, | ||
rules: { | ||
"node/no-unsupported-features/es-syntax": ["error", { ignores: ["modules"] }], | ||
}, | ||
}; | ||
|
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,21 @@ | ||
{ | ||
"arrowParens": "avoid", | ||
"bracketSpacing": true, | ||
"printWidth": 120, | ||
"singleQuote": false, | ||
"tabWidth": 2, | ||
"trailingComma": "all", | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"printWidth": 80, | ||
"tabWidth": 4, | ||
"useTabs": false, | ||
"singleQuote": false, | ||
"bracketSpacing": false, | ||
"explicitTypes": "always" | ||
} | ||
} | ||
] | ||
} |
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,165 @@ | ||
# SPDX-License-Identifier: MIT | ||
# OpenZeppelin Cairo Contracts v0.1.0 (token/erc20/ERC20.cairo) | ||
|
||
%lang starknet | ||
|
||
from starkware.cairo.common.cairo_builtins import HashBuiltin | ||
from starkware.cairo.common.uint256 import Uint256 | ||
|
||
from openzeppelin.token.erc20.library import ( | ||
ERC20_name, | ||
ERC20_symbol, | ||
ERC20_totalSupply, | ||
ERC20_decimals, | ||
ERC20_balanceOf, | ||
ERC20_allowance, | ||
|
||
ERC20_initializer, | ||
ERC20_approve, | ||
ERC20_increaseAllowance, | ||
ERC20_decreaseAllowance, | ||
ERC20_transfer, | ||
ERC20_transferFrom, | ||
ERC20_mint | ||
) | ||
|
||
from openzeppelin.utils.constants import TRUE | ||
|
||
@constructor | ||
func constructor{ | ||
syscall_ptr: felt*, | ||
pedersen_ptr: HashBuiltin*, | ||
range_check_ptr | ||
}( | ||
name: felt, | ||
symbol: felt, | ||
decimals: felt, | ||
initial_supply: Uint256, | ||
recipient: felt | ||
): | ||
ERC20_initializer(name, symbol, decimals) | ||
ERC20_mint(recipient, initial_supply) | ||
return () | ||
end | ||
|
||
# | ||
# Getters | ||
# | ||
|
||
@view | ||
func name{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}() -> (name: felt): | ||
let (name) = ERC20_name() | ||
return (name) | ||
end | ||
|
||
@view | ||
func symbol{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}() -> (symbol: felt): | ||
let (symbol) = ERC20_symbol() | ||
return (symbol) | ||
end | ||
|
||
@view | ||
func totalSupply{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}() -> (totalSupply: Uint256): | ||
let (totalSupply: Uint256) = ERC20_totalSupply() | ||
return (totalSupply) | ||
end | ||
|
||
@view | ||
func decimals{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}() -> (decimals: felt): | ||
let (decimals) = ERC20_decimals() | ||
return (decimals) | ||
end | ||
|
||
@view | ||
func balanceOf{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}(account: felt) -> (balance: Uint256): | ||
let (balance: Uint256) = ERC20_balanceOf(account) | ||
return (balance) | ||
end | ||
|
||
@view | ||
func allowance{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}(owner: felt, spender: felt) -> (remaining: Uint256): | ||
let (remaining: Uint256) = ERC20_allowance(owner, spender) | ||
return (remaining) | ||
end | ||
|
||
# | ||
# Externals | ||
# | ||
|
||
@external | ||
func transfer{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}(recipient: felt, amount: Uint256) -> (success: felt): | ||
ERC20_transfer(recipient, amount) | ||
return (TRUE) | ||
end | ||
|
||
@external | ||
func transferFrom{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}( | ||
sender: felt, | ||
recipient: felt, | ||
amount: Uint256 | ||
) -> (success: felt): | ||
ERC20_transferFrom(sender, recipient, amount) | ||
return (TRUE) | ||
end | ||
|
||
@external | ||
func approve{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}(spender: felt, amount: Uint256) -> (success: felt): | ||
ERC20_approve(spender, amount) | ||
return (TRUE) | ||
end | ||
|
||
@external | ||
func increaseAllowance{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}(spender: felt, added_value: Uint256) -> (success: felt): | ||
ERC20_increaseAllowance(spender, added_value) | ||
return (TRUE) | ||
end | ||
|
||
@external | ||
func decreaseAllowance{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}(spender: felt, subtracted_value: Uint256) -> (success: felt): | ||
ERC20_decreaseAllowance(spender, subtracted_value) | ||
return (TRUE) | ||
end |
Oops, something went wrong.