This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct request | |
{ | |
string task; | |
string memo; | |
bytes args; | |
account_name administrator; | |
account_name contract; | |
uint32_t timestamp; | |
uint32_t update_each; | |
request_type mode; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |