Skip to content

Instantly share code, notes, and snippets.

View shawntabrizi's full-sized avatar

Shawn Tabrizi shawntabrizi

View GitHub Profile
@shawntabrizi
shawntabrizi / demo.rs
Last active February 11, 2019 12:12
Gav Demo Runtime from Web3 Summit
// initialise with:
// post({sender: runtime.indices.ss58Decode('F7Gh'), call: calls.demo.setPayment(1000)}).tie(console.log)
use parity_codec::Encode;
use srml_support::{StorageValue, dispatch::Result, decl_module, decl_storage};
use runtime_primitives::traits::Hash;
use {balances, system::{self, ensure_signed}};
pub trait Trait: balances::Trait {}
use support::{decl_module, decl_storage, decl_event, StorageValue, dispatch::Result};
use system::ensure_signed;
pub trait Trait: system::Trait {
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
}
type U8 = [u8; 1];
decl_storage! {
#![feature(prelude_import)]
#![no_std]
// Copyright 2017-2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
use support::{decl_module, dispatch::Result,
traits::{Currency, ExistenceRequirement, WithdrawReason}};
use system::ensure_signed;
// v1.0 branch
// use runtime_primitives::traits::As;
pub trait Trait: balances::Trait {}
decl_module! {
@shawntabrizi
shawntabrizi / adder_module.rs
Created June 21, 2019 10:19
Simple adder for Substrate
use support::{decl_module, decl_storage, decl_event, StorageValue, dispatch::Result, ensure, StorageMap};
use system::ensure_signed;
pub trait Trait: system::Trait {
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
}
decl_storage! {
trait Store for Module<T: Trait> as calculator {
FinalResult: u64;
@shawntabrizi
shawntabrizi / enum_module.rs
Created July 10, 2019 18:00
Substrate Enum
use support::{decl_module, decl_storage, StorageValue, dispatch::Result};
use system::ensure_signed;
use parity_codec::{ Encode, Decode };
#[derive(Encode, Decode, Clone, PartialEq)]
#[cfg_attr(feature = "std", derive(Debug))]
pub enum Choices {
None,
One,
Two,
use support::{decl_module, decl_storage, decl_event, StorageValue, dispatch::Result};
use system::ensure_signed;
use rstd::prelude::*;
use rstd::collections::btree_set::BTreeSet;
pub trait Trait: system::Trait {
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
}
decl_storage! {
@shawntabrizi
shawntabrizi / customSpecRaw.json
Last active September 13, 2019 08:37
Geneva Workshop
{
"name": "Local Testnet",
"id": "local_testnet",
"bootNodes": [
"/ip4/127.0.0.1/tcp/30333/p2p/QmSidBKvi8CcbqK5TZdAq1cxFBJAYwUWmg6VwwPtVK2eyT"
],
"telemetryEndpoints": null,
"protocolId": null,
"consensusEngine": null,
"properties": null,
/// A runtime module that interprets a sipmlified pi calculus
use support::{decl_module, decl_storage, decl_event, StorageMap, dispatch::Result, ensure};
use system::ensure_signed;
use rstd::boxed::Box;
use codec::{ Encode, Decode };
use sr_primitives::traits::Hash;
/// All the types of processes in our calculus
@shawntabrizi
shawntabrizi / 0_General_Instructions.md
Last active July 25, 2022 09:05
Sub 0.1 Workshop Setup Instructions

General Instructions

Most workshops at Sub0 will require that you have set up your computer to compile Substrate.

You can use this one-liner to do many of these steps for you automatically:

curl https://getsubstrate.io -sSf | bash -s -- --fast