Skip to content

Instantly share code, notes, and snippets.

View LucasIsasmendi's full-sized avatar
♻️
Building Specific Knowledge

Lucas Isasmendi LucasIsasmendi

♻️
Building Specific Knowledge
View GitHub Profile
@LucasIsasmendi
LucasIsasmendi / folder-structure.ts
Created April 13, 2019 01:03
Folder structure iov-core new package
// your blockchain constants
constants.ts
// main logic files with BCP flavor
myblockchaincodec.ts
myblockchainconnection.ts
// this one joins the codec and the connection
myblockchainconnector.ts
// this exports all
index.ts
// some test files, don't forget about them
@LucasIsasmendi
LucasIsasmendi / add-package-tasks.md
Created April 13, 2019 01:00
Tasks to add a new package to iov-core
  • Add folder structure
  • Add codec
  • Add connection
  • Add connector
  • Add unit tests
@LucasIsasmendi
LucasIsasmendi / crypto.ts
Created April 13, 2019 00:53
Faucet crypto changes
// On walletFromCodec function add your crypto flawor,
// only ed25519 and secp256k1 are supported currently.
@LucasIsasmendi
LucasIsasmendi / codec.ts
Created April 13, 2019 00:51
Faucet codec changes
// On imports add myblockchain
import { myblockchainCodec, myblockchainConnector } from "@iov/myblockchain";
// On enum Codec add MyBlockchain
export const enum Codec {
MyBlockchain
}
// On codecFromString function add MyBlockchain codec
export function codecFromString(input: string): Codec {
switch (input) {
@LucasIsasmendi
LucasIsasmendi / myblockchainconnector.ts
Created April 13, 2019 00:47
New iov-core package connector
// TODO: add some imports
import { myblockchainCodec } from "./myblockchaincodec";
import { MyBlockchainConnection } from "./myblockchainconnection";
export function myBlockchainConnector(url, someParameters): ChainConnector {
// TODO: add some logic based on your blockchain connection
return {
client: async () => MyBlockchainConnection.establish(url, someParameters),
codec: myblockchainCodec, /** we exported a const here, remember */
}
@LucasIsasmendi
LucasIsasmendi / myblockchainconnection.ts
Created April 13, 2019 00:36
New iov-core package connection
// TODO: imports and functions goes here
/** A high-level interface to a blockchain node */
export class MyBlockchainConnection implements BlockchainConnection {
public static async establish(myBlockchainParameters):
Promise<MyBlockchainConnection> {
// TODO: logic to load blockchain parameters (nethash, chainId, etc)
return new MyBlockchainConnection(myBlockchainParameters);
}
@LucasIsasmendi
LucasIsasmendi / myblockchaincodec.ts
Last active April 13, 2019 00:31
New iov-core package codec
// TODO: imports and functions goes here
export const myblockchainCodec: TxCodec = {
/** these are the bytes we create to add a signature;
* they often include nonce and chainID */
bytesToSign: (unsigned: UnsignedTransaction, nonce: Nonce): SigningJob => {
// TODO: write your unsigned transaction serialization recipe
return {
bytes, /** the serialized transaction */
prehashType /** your crypto flawor from PrehashType: Sha256, Sha512, Keccak256 */

Keybase proof

I hereby claim:

  • I am lucasisasmendi on github.
  • I am lucasisasmendi (https://keybase.io/lucasisasmendi) on keybase.
  • I have a public key ASCcpuv7J3LwcPZU2UEvXCgeuIDKuyInt-aegjGflMMi5go

To claim this, I am signing this object: