Skip to content

Instantly share code, notes, and snippets.

@tgrecojs
tgrecojs / index.js
Last active January 19, 2024 22:04 — forked from degrammer/index.js
lockdown example
#!/usr/bin/env node
import 'ses';
lockdown();
const isFrozen = x => Object.isFrozen(x);
const c1 = new Compartment({ console, Date });
@tgrecojs
tgrecojs / data.json
Last active January 19, 2024 19:12
airdrop-mock-data.json
[
{
"amount": 2000,
"address": "cosmos1p00xhl9ysacadcduxglhavstr8yvh9hfzk6z6w",
"pubkey": "033f1d99e8f90c8b46e7a2f14f3fa52ce484bd419744b3bac58db2b227b87a2e5a",
"PrivateKey": "047baf28b432df107dcfb71d21ecc93a655cfaf842b5e4268a9603369c39c47d"
},
{
"amount": 2000,
"address": "cosmos1yquxnvua4me07zxyq85fnxkdg9htqvn90x8m7h",
/**
* @file endo plugin for cosmos network protocol primitives: RPC, LCD (aka API).
*/
// @ts-check
/* global globalThis */
import { Far } from '@endo/far';
import { makeHttpClient, makeLCD } from './httpClient.js';
assert.typeof(globalThis.fetch, 'function');

Feedback for the IBC localDemo

Prepare Cosmos Chain Section

gm keys

I ran into an issue when trying to create the channel due to a mismatch of keys. The output below shows the error that I received. The issue was - the keys generated via gm keys were not in sync with the keys that hermes had known about.

hermes create channel --a-chain ibc-0 --b-chain agoriclocal --a-port transfer --b-port pegasus --new-client-connection
2023-05-31T22:18:46.926628Z  INFO ThreadId(01) using default configuration from '/Users/tgreco/.hermes/config.toml'
@tgrecojs
tgrecojs / makeMintExo.js
Created May 31, 2023 16:39
mintMaker exo with Interface guard for prepareIssuerKit
import { Nat } from '@endo/nat';
import { M } from '@agoric/store';
// reproducing purseShape found in ERTP
// https://github.com/Agoric/agoric-sdk/blob/master/packages/ERTP/src/typeGuards.js#L8
const purseShape = M.remotable('Purse');
const IssuerI = M.interface('Issuer', {
makeEmptyPurse: M.call().returns(purseShape),
});
@tgrecojs
tgrecojs / monads.js
Last active February 16, 2023 04:15
common group of ADTs
const Reducer = run => ({
run,
concat: other => Reducer((acc, x) => other.run(run(acc, x), x)),
contramap: f => Reducer((acc, x) => run(acc, f(x))),
map: f => Reducer((acc, x) => f(run(acc, x)))
});
const Id = x => ({
map: f => Id(f(x)),
chain: f => f(x),
import { assert } from './util'
const compose = (...fns) => x => fns.reduceRight((y, f) => f(y), x);
// const { proxy: accountProxy, revoke: revokeAccount } = Proxy.revocable(objProto, {});
// Reflect.get(accountProxy, 'balance')
// objProto.deposit(10000)
// Reflect.get(accountProxy,'balance')
@tgrecojs
tgrecojs / intro.md
Last active January 11, 2023 00:26
riteway testing with agoric

Riteway test wrapper

  • Utility lib for using the riteway testing library with agoric.

Explicit test failure messages

  • forces you to write tests cases the "rite" way:
    • Readable
    • Integrated
    • Thorough
    • Explicit,
@tgrecojs
tgrecojs / contract.js
Created December 2, 2022 01:35
zoe fungible faucet contract
// @ts-check
/* global harden */
import '@agoric/zoe/exported.js';
import { AmountMath } from '@agoric/ertp';
import { assert } from '@agoric/assert';
import { Far } from '@endo/marshal';
import { assertIssuerKeywords, swap } from '@agoric/zoe/src/contractSupport';
/**
* This is a very simple contract that creates a new issuer and mints payments
(function(){
const url = top._CVE_URL;
alert(`this message originated in a script that was successfully fetched from "${url}" [even though "${top.location.hostname}"'s Content Security Policy may not allow it!] (CVE-2020-6519)`);
}())