Skip to content

Instantly share code, notes, and snippets.

View mariano-aguero's full-sized avatar
:octocat:
Focusing

Mariano Aguero mariano-aguero

:octocat:
Focusing
View GitHub Profile
function tokenProxy (const action : tokenAction; const store : store): operation is
block {
const tokenContract: contract (tokenAction) =
case (Tezos.get_contract_opt (store.token.contractAddress) : option (contract (tokenAction))) of
Some (contractAction) -> contractAction
| None -> (failwith ("Contract not found.") : contract (tokenAction))
end;
const proxyOperation : operation = Tezos.transaction (action, 0mutez, tokenContract);
} with proxyOperation;
function depositImp(var store: store): return is
block {
if amount = 0mutez
then failwith("No tez transferred!");
else skip;
// Setting the deposit to the sender
store := updateDeposit(amount, store);
// TODO: try to get the decimals property from the token contract
@mariano-aguero
mariano-aguero / token.ligo
Created April 23, 2020 14:31
Change amount
// This is an implementation of the FA1.2 specification in PascaLIGO
type amountNat is nat;
type account is record
balance : amountNat;
allowances: map(address, amountNat);
end
type action is
@mariano-aguero
mariano-aguero / owner.ligo
Last active May 11, 2020 18:57
Ownership mechanism
type action is AddOwner of (address)
// An unordered collections of owner accounts
type store is record
owners: set(address);
end
type return is list(operation) * store
// Function that checks if an account is an owner
@mariano-aguero
mariano-aguero / roles.ligo
Last active May 14, 2020 12:34
Role mechanism
// Allowed roles, you can add a new annotation right here, for example 'Dev' or 'Moderator'
type role is Admin | User | NoRole
type action is
| MakeAdmin of (address)
| MakeUser of (address)
| RemoveRole of (address)
type store is record
users: big_map(address, role);
if amount =/= 0tz then failwith ("This contract do not accept token amount");
const emptyOps : list(operation) = list end;
function approve (const addressSpender : address; const value : nat; var store : store) : return is
block {
// If sender is the spender approving is not necessary
if sender = addressSpender then skip;
else block {
const senderAccount: account = getAccount(sender, store.accounts);
var allowance: nat := getAllowance(addressSpender, senderAccount.allowances);
@mariano-aguero
mariano-aguero / errors.ligo
Created May 15, 2020 12:47
Files with errors codes
// Error codes used with the `failwith` method , for contract execution termination.
const error_not_enough_balance : string = "0";
const error_transaction_of_funds_failed : string = "1";
const error_amount_must_be_zero : string = "3";
@mariano-aguero
mariano-aguero / owner.json
Last active June 26, 2020 17:33
Wallet that can mint tokens
{
"mnemonic": [
"pepper",
"elbow",
"pizza",
"best",
"speak",
"usual",
"mass",
"pepper",
@mariano-aguero
mariano-aguero / bob.json
Created May 19, 2020 21:00
Wallet with some tokens
{
"mnemonic": [
"essence",
"crucial",
"useful",
"blush",
"phone",
"private",
"found",
"apple",