Skip to content

Instantly share code, notes, and snippets.

View mradkov's full-sized avatar

mradkov

View GitHub Profile
@mradkov
mradkov / map
Last active June 11, 2019 04:28
pass map to function
contract MapTest =
record state = { my_map: map(string, string)
, owner : address}
public function init() : state = { my_map = {}, owner = Call.caller }
public function set_map(new_map : map(string, string)) : bool =
only_owner()
filter_put(set_map_at_index, Map.to_list(new_map), [])
@mradkov
mradkov / ae-vote.aes
Last active January 25, 2019 11:40
ae-vote.aes sophia ml aeternity smart contract
contract Vote =
type candidate = address
type votes = list(address)
record state =
{ vote : map(candidate, votes) }
public function init() : state =
{ vote = { } }
/*
* ISC License (ISC)
* Copyright (c) 2018 aeternity developers
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
@mradkov
mradkov / deploy.js
Created January 10, 2019 07:34
Aeternity AddressBook deployment script - https://github.com/mradkov/addressbook-aepp-aeternity
/*
* ISC License (ISC)
* Copyright (c) 2018 aeternity developers
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
@compiler >= 4
contract AddressBook =
record state =
{ people : map(address, person) }
record person =
{ first_name : string
, last_name : string
, age : int }
@mradkov
mradkov / DDNSservice.test.js
Created January 5, 2019 12:28
DDNSservice.test.js
const DDNSService = artifacts.require('../contracts/DDNSService.sol')
const assertRevert = require('./utils/assertRevert');
const watchEvent = require('./utils/watchEvent');
const constants = require('./utils/constants');
const increaseTime = require('./utils/increaseTime');
contract('DDNSService', ([owner, wallet, anotherAccount]) => {
let contractInstance;
let events = [];
@mradkov
mradkov / DDNSService.sol
Created November 30, 2018 10:44
DDNSService.sol
pragma solidity >=0.4.22 <0.6.0;
import "./common/Ownable.sol";
import "./common/Destructible.sol";
import "./libs/SafeMath.sol";
contract DDNSService is Destructible {
/** USINGS */
@mradkov
mradkov / DDNS-function-getIp
Created November 30, 2018 10:44
DDNS-function-getIp
/*
* @dev - Get ip of domain
* @param domain
* @param topLevel
*/
function getIP(
bytes memory domain,
bytes12 topLevel
)
public
@mradkov
mradkov / DDNS-function-getReceptList
Created November 30, 2018 10:42
DDNS-function-getReceptList
/**
* @dev - Get receipt list for the msg.sender
*/
function getReceiptList() public view returns (bytes32[] memory) {
return paymentReceipts[msg.sender];
}
@mradkov
mradkov / DDNS-function-getReceipt
Created November 30, 2018 10:41
DDNS-function-getReceipt
/*
* @dev - Get single receipt
* @param receiptKey
*/
function getReceipt(bytes32 receiptKey) public view returns (uint, uint, uint) {
return (receiptDetails[receiptKey].amountPaidWei,
receiptDetails[receiptKey].timestamp,
receiptDetails[receiptKey].expires);
}