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
@mariano-aguero
mariano-aguero / fa12.ligo
Created April 20, 2020 17:24
FA12 token actions
type tokenAction is
| GetAllowance of (address * address * contract(nat))
| Transfer of (address * address * nat)
| Approve of (address * nat)
| GetBalance of (address * contract(nat))
| GetTotalSupply of (unit * contract(nat))
| Mint of (nat)
| Burn of (nat)
| Symbol of (unit * contract(string))
| Name of (unit * contract(string))
@mariano-aguero
mariano-aguero / fa12.ligo
Created April 20, 2020 17:04
FA 1.2 entry points
function main (const action : tokenAction ; const store : store) : return is
block {
if amount =/= 0tz then failwith ("This contract do not accept token amount");
else skip;
} with case action of
GetAllowance(n) -> allowance(n.0, n.1, n.2, store)
| Transfer(n) -> transfer(n.0, n.1, n.2, store)
| Approve(n) -> approve(n.0, n.1, store)
| GetBalance(n) -> balanceOf(n.0, n.1, store)
| GetTotalSupply(n) -> totalSupply(n.1, store)
@mariano-aguero
mariano-aguero / conversions.ligo
Last active April 14, 2020 16:52
Liquidity pool for tezos
function natToTz(const val: nat): tez is val * 1tz
function natToMutez(const val: nat): tez is val * 1mutez
function tezToNatWithMutez(const val: tez): nat is val / 1mutez
function tezToNatWithTz(const val: tez): nat is val / 1tz
function natToInt(const val: nat): int is val + 0
(address :from, (address :to, nat :value)) %transfer
view (address :owner) nat %getBalance
view unit nat %getTotalSupply
@mariano-aguero
mariano-aguero / asset.ligo
Created February 27, 2020 19:48
Implementation of the FA1.2 specification, AKA ERC20
// This is an implementation of the FA1.2 specification in PascaLIGO
type amount is nat;
type account is record
balance : amount;
allowances: map(address, amount);
end
type action is
const Big = require('big.js')
const BN = require('bn.js')
const MathBN = {
sub: (a, b) => {
const aBN = new Big(a || '0')
const bBN = new Big(b || '0')
return aBN.sub(bBN).toString(10)
},
add: (a, b) => {
@mariano-aguero
mariano-aguero / protoletter-3.md
Last active November 3, 2023 10:22
IPFS/ENS/IPNS

IPFS

Trabajando en un proyecto de Gnosis, nos surgio a partir de un requerimiento la necesidad de alojar y servir nuestra aplicacion de una forma totalmente descentralizada.

Usando IPFS(interplanetary file system) y ENS(ethereum name service) pudimos resolver este problema.

Para recordar un poco la definicion de IPFS es un sistema de archivos distribuidos punto a punto que busca conectar todos los dispositivos informáticos con el mismo sistema de archivos , por lo cual los archivos de la aplicacion van a estar descentralizados, alojados en diferentes nodos que pueden estar siendo ejecutados en cualquier lugar del mundo.

Asi como HTTP busca los recursos basandose en la URL, IPFS usa hashes para buscar recursos en su red, por ejemplo un hash es QmbgxQP34EtizTFQ7hEZKCvysQjgpei1hM5w4d2QnrVRQj, y podemos acceder al mismo a traves de un gateway como Pinata https://gateway.pinata.cloud/ipfs/QmbgxQP34EtizTFQ7hEZKCvysQjgpei1hM5w4d2QnrVRQj , u otro gateway como [IPFS.io](https:/

const useAsyncDerivedValue = (value, f) => {
const [derivedValue, setDerivedValue] = useState(null)
const [debouncedValue] = useDebounce(value, 500)
useEffect(() => {
let cancelled = false
f(debouncedValue).then(result => {
if (!cancelled) setDerivedValue (result)
})
@mariano-aguero
mariano-aguero / truncateStringInTheMiddle.js
Created January 10, 2019 17:39
Truncate address in the middle, 3 dots
const truncateStringInTheMiddle = (
str,
strLength = 50,
strPositionStart = 24,
strPositionEnd = 25
) => {
if (typeof str === 'string' && str.length > strLength) {
return `${str.substr(0, strPositionStart)}...${str.substr(
str.length - strPositionEnd,
str.length
@mariano-aguero
mariano-aguero / budda
Last active January 5, 2019 19:33
Buddha Bless
/*! =========================================================
*
* _oo0oo_
* o8888888o
* 88" . "88
* (| -_- |)
* 0\ = /0
* ___/`---'\___
* .' \| |// '.