Skip to content

Iris compatibility, Aeproject update #4

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
38 changes: 22 additions & 16 deletions contracts/fungible-token-full.aes
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,24 @@
// THIS IS NOT SECURITY AUDITED
// DO NEVER USE THIS WITHOUT SECURITY AUDIT FIRST

@compiler >= 4
@compiler >= 5

include "Option.aes"
include "String.aes"

/// @title - Fungible token with all the extensions - burn, mint, allowances
contract FungibleTokenFull =

// This defines the state of type record encapsulating the conract's mutable state
// This defines the state of type record encapsulating the contract's mutable state
record state =
{ owner : address // the smart contract's owner address
, total_supply : int // total token supply
, balances : balances // balances for each account
, meta_info : meta_info // token meta info (name, symbol, decimals)
, allowances : allowances // owner of account approves the transfer of an amount to another account
, swapped : map(address, int)
, minter : address } // address which is allowed to issue new tokens
, swapped : map(address, int) }

// This is the meta information record type
// This is the meta-information record type
record meta_info =
{ name : string
, symbol : string
Expand Down Expand Up @@ -63,20 +65,24 @@ contract FungibleTokenFull =
// Create a fungible token with
// the following `name` `symbol` and `decimals`
// and set the inital smart contract state
entrypoint init(name: string, decimals : int, symbol : string, minter : address) =
entrypoint init(name: string, decimals : int, symbol : string, initial_owner_balance : option(int)) =
// If the `name` lenght is less than 1 symbol abort the execution
require(String.length(name) >= 1, "STRING_TOO_SHORT_NAME")
// If the `symbol` length is less than 1 symbol abort the execution
require(String.length(symbol) >= 1, "STRING_TOO_SHORT_SYMBOL")
// If the provided value for `decimals` is negative abort the execution
require_non_negative_value(decimals)
{ owner = Call.caller,
total_supply = 0,
balances = {},
// If negative initial owner balance is passed, abort the execution
let initial_supply = Option.default(0, initial_owner_balance)
require_non_negative_value(initial_supply)

let owner = Call.caller
{ owner = owner,
total_supply = initial_supply,
balances = Option.match({}, (balance) => { [owner] = balance }, initial_owner_balance),
meta_info = { name = name, symbol = symbol, decimals = decimals },
allowances = {},
swapped = {},
minter = minter }
swapped = {} }

// Get the token meta info
entrypoint meta_info() : meta_info =
Expand All @@ -99,8 +105,8 @@ contract FungibleTokenFull =
// If the `owner` address haven't had any token balance
// in this smart contract the return value is None
// Otherwise Some(int) is returned with the current balance
entrypoint balance(owner: address) : option(int) =
Map.lookup(owner, state.balances)
entrypoint balance(account: address) : option(int) =
Map.lookup(account, state.balances)

// Get all swapped tokens stored in state
entrypoint swapped() : map(address, int) =
Expand Down Expand Up @@ -135,15 +141,15 @@ contract FungibleTokenFull =
// The execution will abort and fail if there is no allowance set up previous this call
stateful entrypoint transfer_allowance(from_account: address, to_account: address, value: int) =
let allowance_accounts = { from_account = from_account, for_account = Call.caller }
internal_change_allowance(allowance_accounts, -value)
internal_transfer(from_account, to_account, value)
internal_change_allowance(allowance_accounts, -value)

// Create allowance for `for_account` to withdraw from your account `Call.caller`,
// multiple times, up to the `value` amount.
// This function will abort and fail if called again when there is allowance
// already set for these particular accounts pair.
stateful entrypoint create_allowance(for_account: address, value: int) =
// Chcek if the passed value is not negative
// Check if the passed value is not negative
require_non_negative_value(value)
// Set the allowance account pair in the memory variable
let allowance_accounts = { from_account = Call.caller, for_account = for_account }
Expand Down Expand Up @@ -180,7 +186,7 @@ contract FungibleTokenFull =
// Creates `value` tokens and assigns them to `account`, increasing the total supply.
// Emits a `Mint` event with `account` and `value`.
stateful entrypoint mint(account: address, value: int) =
require(Call.caller == state.minter, "NOT_ALLOWED_TO_MINT")
require_owner()
require_non_negative_value(value)
put(state{ total_supply = state.total_supply + value, balances[account = 0] @ b = b + value })
Chain.event(Mint(account, value))
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.compiler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ version: '3'
services:
compiler:
hostname: compiler
image: aeternity/aesophia_http:v4.0.0
image: 'aeternity/aesophia_http:${COMPILER_TAG}'
ports:
- "3080:3080"
- '3080:3080'
64 changes: 10 additions & 54 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,18 @@
# Small local network of three nodes using the fastest mean16
version: '3'
services:
node1:
image: aeternity/aeternity:v5.0.0-rc.5
hostname: node1
node:
image: 'aeternity/aeternity:${NODE_TAG}'
hostname: node
environment:
EPOCH_CONFIG: /home/epoch/epoch.yaml
command: >
bin/aeternity console -noinput -aehttp enable_debug_endpoints true
AETERNITY_CONFIG: /home/aeternity/aeternity.yaml
command: |
bin/aeternity console -noinput -aehttp enable_debug_endpoints true
volumes:
- ./docker/aeternity_node1_mean15.yaml:/home/epoch/epoch.yaml
- ./docker/keys/node1:/home/epoch/node/keys
- node1_db:/home/epoch/node/data/mnesia

node2:
image: aeternity/aeternity:v5.0.0-rc.5
hostname: node2
environment:
EPOCH_CONFIG: /home/epoch/epoch.yaml
command: >
bin/aeternity console -noinput -aehttp enable_debug_endpoints true
volumes:
- ./docker/aeternity_node2_mean15.yaml:/home/epoch/epoch.yaml
- ./docker/keys/node2:/home/epoch/node/keys
- node2_db:/home/epoch/node/data/mnesia

node3:
image: aeternity/aeternity:v5.0.0-rc.5
hostname: node3
environment:
EPOCH_CONFIG: /home/epoch/epoch.yaml
command: >
bin/aeternity console -noinput -aehttp enable_debug_endpoints true
volumes:
- ./docker/aeternity_node3_mean15.yaml:/home/epoch/epoch.yaml
- ./docker/keys/node3:/home/epoch/node/keys
- node3_db:/home/epoch/node/data/mnesia

- './docker/aeternity.yaml:/home/aeternity/aeternity.yaml'
proxy:
image: nginx:1.13.8
image: 'nginx:1.13.8'
hostname: proxy
ports:
- "3001:3001"
- "3002:3002"
- "3003:3003"

- '3001:3001'
volumes:
- ./docker/nginx-default.conf:/etc/nginx/conf.d/default.conf
- ./docker/nginx-cors.conf:/etc/nginx/cors.conf
- ./docker/nginx-ws.conf:/etc/nginx/ws.conf



volumes:
node1_db:
node1_keys:
node2_db:
node2_keys:
node3_db:
node3_keys:

- './docker/nginx.conf:/etc/nginx/conf.d/default.conf'
26 changes: 6 additions & 20 deletions docker/aeternity_node1_mean15.yaml → docker/aeternity.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
peers:
- aenode://pp_28uQUgsPcsy7TQwnRxhF8GMKU4ykFLKsgf4TwDwPMNaSCXwWV8@node2:3015
- aenode://pp_Dxq41rJN33j26MLqryvh7AnhuZywefWKEPBiiYu2Da2vDWLBq@node3:3015
peers: []

http:
external:
Expand All @@ -10,26 +7,17 @@ http:
debug_endpoints: true
port: 3113
listen_address: 0.0.0.0
endpoints:
dry-run: true

chain:
persist: true

websocket:
channel:
listen_address: 0.0.0.0
port: 3014

keys:
peer_password: "top secret"
dir: ./keys

chain:
persist: true
hard_forks:
"1": 0
"2": 1
"3": 2
"4": 3


mining:
autostart: true
beneficiary: "ak_2mwRmUeYmfuW93ti9HMSUJzCk1EYcQEfikVSzgo6k2VghsWhgU"
Expand All @@ -43,6 +31,4 @@ mining:
edge_bits: 15

fork_management:
network_id: "ae_devnet"


network_id: ae_devnet
45 changes: 0 additions & 45 deletions docker/aeternity_node2_mean15.yaml

This file was deleted.

45 changes: 0 additions & 45 deletions docker/aeternity_node3_mean15.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions docker/entrypoint.sh

This file was deleted.

17 changes: 0 additions & 17 deletions docker/healthcheck.sh

This file was deleted.

1 change: 0 additions & 1 deletion docker/keys/beneficiary/key

This file was deleted.

1 change: 0 additions & 1 deletion docker/keys/beneficiary/key.pub

This file was deleted.

1 change: 0 additions & 1 deletion docker/keys/node1/peer_key

This file was deleted.

1 change: 0 additions & 1 deletion docker/keys/node1/peer_key.pub

This file was deleted.

1 change: 0 additions & 1 deletion docker/keys/node1/sign_key

This file was deleted.

1 change: 0 additions & 1 deletion docker/keys/node1/sign_key.pub

This file was deleted.

1 change: 0 additions & 1 deletion docker/keys/node2/peer_key

This file was deleted.

1 change: 0 additions & 1 deletion docker/keys/node2/peer_key.pub

This file was deleted.

Binary file removed docker/keys/node2/sign_key
Binary file not shown.
Binary file removed docker/keys/node2/sign_key.pub
Binary file not shown.
2 changes: 0 additions & 2 deletions docker/keys/node3/peer_key

This file was deleted.

1 change: 0 additions & 1 deletion docker/keys/node3/peer_key.pub

This file was deleted.

1 change: 0 additions & 1 deletion docker/keys/node3/sign_key

This file was deleted.

1 change: 0 additions & 1 deletion docker/keys/node3/sign_key.pub

This file was deleted.

Empty file removed docker/nginx-cors.conf
Empty file.
Loading