Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use uint256 #33

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions rsh/arc200/index.rsh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"reach 0.1";

const MAX_DECIMALS = 19; // same as AS
const MAX_DECIMALS = 256; // decimals fits in UInt8

const TokenMeta = Struct([
["name", Bytes(32)], // name
["symbol", Bytes(8)], // symbol
["decimals", UInt], // number of decimals
["totalSupply", UInt], // total supply
["totalSupply", UInt256], // total supply
]);

const State = Struct([
Expand All @@ -21,7 +21,7 @@ const MintParams = Object({
name: Bytes(32), // name
symbol: Bytes(8), // symbol
decimals: UInt, // number of decimals
totalSupply: UInt, // total supply
totalSupply: UInt256, // total supply
});

const Params = Object({
Expand All @@ -40,9 +40,9 @@ export const ARC200 = Reach.App(() => {
});

const A = API({
transfer: Fun([Address, UInt], Bool), // tranfer from this to address
transferFrom: Fun([Address, Address, UInt], Bool), // transfer from address to address
approve: Fun([Address, UInt], Bool), // approve address to spend this
transfer: Fun([Address, UInt256], Bool), // tranfer from this to address
transferFrom: Fun([Address, Address, UInt256], Bool), // transfer from address to address
approve: Fun([Address, UInt256], Bool), // approve address to spend this
deleteBalanceBox: Fun([Address], Bool), // delete balance box if zero
deleteAllowanceBox: Fun([Address, Address], Bool), // delete allowance box if zero
destroy: Fun([], Null), // destroy this contract
Expand All @@ -52,15 +52,15 @@ export const ARC200 = Reach.App(() => {
name: Fun([], Bytes(32)), // get name
symbol: Fun([], Bytes(8)), // get symbol
decimals: Fun([], UInt), // get decimals
totalSupply: Fun([], UInt), // get total supply
balanceOf: Fun([Address], UInt), // get balance of address
allowance: Fun([Address, Address], UInt), // get allowance of address to spend this
totalSupply: Fun([], UInt256), // get total supply
balanceOf: Fun([Address], UInt256), // get balance of address
allowance: Fun([Address, Address], UInt256), // get allowance of address to spend this
state: Fun([], State), // get state
});

const E = Events({
Transfer: [Address, Address, UInt, UInt],
Approval: [Address, Address, UInt, UInt],
Transfer: [Address, Address, UInt256, UInt],
Approval: [Address, Address, UInt256, UInt],
});

init();
Expand All @@ -76,7 +76,7 @@ export const ARC200 = Reach.App(() => {
"ARC200: Zero address must not equal manager address"
);
check(
meta.totalSupply > 0,
meta.totalSupply > UInt256(0),
"ARC200: Total supply must be greater than zero"
);
check(
Expand All @@ -85,11 +85,11 @@ export const ARC200 = Reach.App(() => {
);
});

const balances = new Map(UInt);
const allowances = new Map(Tuple(Address, Address), UInt);
const balances = new Map(UInt256);
const allowances = new Map(Tuple(Address, Address), UInt256);

balances[manager] = meta.totalSupply; // D creates manager and zero addres balance boxes
balances[zeroAddress] = 0;
balances[zeroAddress] = UInt256(0);

E.Transfer(zeroAddress, manager, meta.totalSupply, thisConsensusSecs());
D.interact.ready(getContract());
Expand All @@ -111,12 +111,12 @@ export const ARC200 = Reach.App(() => {
.define(() => {
const balanceOf = (owner) => {
const m_bal = balances[owner];
return fromSome(m_bal, 0);
return fromSome(m_bal, UInt256(0));
};
V.balanceOf.set(balanceOf);
const allowance = (owner, spender) => {
const m_bal = allowances[[owner, spender]];
return fromSome(m_bal, 0);
return fromSome(m_bal, UInt256(0));
};
V.allowance.set(allowance);
const state = () => State.fromObject(s);
Expand Down
Loading