Skip to content

Instantly share code, notes, and snippets.

View MCarlomagno's full-sized avatar
🚀

Marcos Carlomagno MCarlomagno

🚀
  • OpenZeppelin
  • Rosario - Argentina
View GitHub Profile
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");
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::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() );
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;
}
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];
}
struct request
{
string task;
string memo;
bytes args;
account_name administrator;
account_name contract;
uint32_t timestamp;
uint32_t update_each;
request_type mode;
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,
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> {
import 'package:flutter/material.dart';
// Global reactive value
final counter = ValueNotifier<int>(0);
class MyWidget extends StatefulWidget {
@override
_MyWidgetState createState() => _MyWidgetState();
}
class Info extends InheritedWidget {
// this udget uses the of(context)
//method to call the build method
// when updateShouldNotify function returns true
const Info({
Key key,
@required this.score,
@required Widget child,
}) : assert(score != null),
assert(child != null),