Skip to content

Instantly share code, notes, and snippets.

View MCarlomagno's full-sized avatar
🚀

Marcos Carlomagno MCarlomagno

🚀
  • OpenZeppelin
  • Rosario - Argentina
View GitHub Profile
import 'package:flutter/material.dart';
class ParentWidget extends StatefulWidget {
const ParentWidget({Key? key}) : super(key: key);
@override
_ParentWidgetState createState() => _ParentWidgetState();
}
class _ParentWidgetState extends State<ParentWidget> {
void ask(account_name administrator, account_name contract, string task, uint32_t update_each, string memo, bytes args)
{
require_auth(administrator);
auto itt = requests.find(pack_hash(get_full_hash(task, memo, contract)));
eosio_assert(itt == requests.end() || itt->mode != REPEATABLE_REQUEST, "Already repeatable request");
set(request{task,
memo,
args,
administrator,
contract,
struct request
{
string task;
string memo;
bytes args;
account_name administrator;
account_name contract;
uint32_t timestamp;
uint32_t update_each;
request_type mode;
uint64_t pack_hash(checksum256 hash)
{
const uint64_t *p64 = reinterpret_cast<const uint64_t *>(&hash);
return p64[0] ^ p64[1] ^ p64[2] ^ p64[3];
}
checksum256 get_hash(const string &task, const account_name &contract)
{
checksum256 result;
size_t tasklen = strlen(task.c_str());
char *buffer = (char *)malloc(tasklen + 8);
memcpy(buffer, &contract, 8);
memcpy(buffer + 8, task.data(), tasklen);
sha256(buffer, tasklen + 8, &result);
return result;
}
void token::transfer( const name& from,
const name& to,
const asset& quantity,
const string& memo )
{
check( from != to, "cannot transfer to self" );
require_auth( from );
check( is_account( to ), "to account does not exist");
auto sym = quantity.symbol.code();
stats statstable( get_self(), sym.raw() );
void token::issue( const name& to, const asset& quantity, const string& memo )
{
auto sym = quantity.symbol;
check( sym.is_valid(), "invalid symbol name" );
check( memo.size() <= 256, "memo has more than 256 bytes" );
stats statstable( get_self(), sym.code().raw() );
auto existing = statstable.find( sym.code().raw() );
check( existing != statstable.end(), "token with symbol does not exist, create token before issue" );
const auto& st = *existing;
void token::create( const name& issuer,
const asset& maximum_supply )
{
require_auth( get_self() );
auto sym = maximum_supply.symbol;
check( sym.is_valid(), "invalid symbol name" );
check( maximum_supply.is_valid(), "invalid supply");
check( maximum_supply.amount > 0, "max-supply must be positive");
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract Ballot {
struct Voter {
uint weight; // weight is accumulated by delegation
bool voted; // if true, that person already voted
address delegate; // person delegated to
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract Owner {
address private owner;
event OwnerSet(address indexed oldOwner, address indexed newOwner);