Skip to content

Instantly share code, notes, and snippets.

View pedrouid's full-sized avatar
🛠️
Building @WalletConnect

Pedro Gomes pedrouid

🛠️
Building @WalletConnect
View GitHub Profile
@pedrouid
pedrouid / eslint-typescript.md
Last active August 11, 2022 14:31
Eslint + Prettier configuration for Typescript 3.7+ (2020)

Eslint + Prettier configuration for Typescript 3.7+ (2020)

  1. Install required dependencies
npm install --save-dev @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-prettier eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-prettier eslint-plugin-promise eslint-plugin-react eslint-plugin-standard prettier

# OR

yarn add -D @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-prettier eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-prettier eslint-plugin-promise eslint-plugin-react eslint-plugin-standard prettier
@pedrouid
pedrouid / recursive-parse.ts
Created December 8, 2019 14:46
Recursive Parse (BigNumber example)
const BigNumber = require("bignumber.js");
let test = {
initialState: {
amount: {
_hex: "0x4563918244f40000",
},
assetId: "0xeec918d74c746167564401103096D45BbD494B74",
coinTransfers: [
{
@pedrouid
pedrouid / recursive-parse.ts
Created December 8, 2019 14:46
Recursive Parse (BigNumber example)
const BigNumber = require("bignumber.js");
let test = {
initialState: {
amount: {
_hex: "0x4563918244f40000",
},
assetId: "0xeec918d74c746167564401103096D45BbD494B74",
coinTransfers: [
{
@pedrouid
pedrouid / migration.md
Last active September 15, 2019 12:27
Migrating Web3Connect from v1.0.0-beta.20 to v1.0.0-beta.22

Web3Connect

Migrating from v1.0.0-beta.20 to v1.0.0-beta.22

Note: We had to skip v1.0.0-beta.21 on NPM because of a test version that was published.

In this latest release (v1.0.0-beta.22), we've had to (once again) introduce breaking changes to allow Web3Connect to work with optional dependencies. When integrating Web3Connect you can choose each providers to support but unfortunately on the v1.0.0-beta.20 you were still required to install all of them as dependencies in your app even if they were disabled. However with the new release (v1.0.0-beta.22) we require dependencies to be injected to enable the providers you choose to support hence there are breaking changes in the library options.

Below I will describe the before and after of each integration type avaiable with Web3Connect.

React Button

@pedrouid
pedrouid / migration.md
Last active September 10, 2019 09:34
Migrating Web3Connect from v1.0.0-beta.19 to v1.0.0-beta.20

Web3Connect

Migrating from v1.0.0-beta.19 to v1.0.0-beta.20

In this last release, we've refactored the library considerably which includes breaking changes from the previous release. But you will be please to know that we reduced the bundle size from 3.91 mb to 314 kb!! That's a 92% bundle size decrease!!!!

However this comes with its own caveats. Check the two sections bellow for the changes made for Install, Options and Single Provider

Install

@pedrouid
pedrouid / 3box-thread.js
Created August 23, 2019 19:54
3Box Threads
// Creating/joining thread in space
const thread = await space.joinThread('orders')
// Others can join by same space and thread name or by thread address
const thread = await space.joinThreadByAddress('/orbitdb/zdpuAp5QpBKR4BBVTvqe3KXVcNgo4z8Rkp9C5eK38iuEZj3jq/3box.thread.pos_bufficorn.orders')
// Post new order in thread
await thread.post({order_id: '123', item_id: '456', amount: '0.0015'})
// Listen live for new thread posts
@pedrouid
pedrouid / 3box-auth.js
Created August 23, 2019 19:54
Auth with 3box
// Authenticate store owner
const box = Box.openBox(ethAddress, window.ethereum)
// App specific space for store owner
const space = await box.openSpace('pos_bufficorn')
// Add data/items
await space.public.set('store_settings', JSON.stringify({ name:'Bufficorn Cafe', description: 'Locally Roasted Coffee in Denver'}))
@pedrouid
pedrouid / wallet.js
Created August 14, 2019 19:03
Example with ethers.js (Ethereum Wallet)
const ethers = require('ethers')
const standardPath = "m/44'/60'/0'/0";
const activeIndex: number = 0;
function generatePath() {
const path = `${standardPath}/${activeIndex}`;
return path;
}
@pedrouid
pedrouid / index.ts
Created July 18, 2019 13:18
Redux Thunk Async Example
export const accountLogin = (username: string, password: string) => async (
dispatch: any,
getState: any
) => {
dispatch({ type: ACCOUNT_LOGIN_REQUEST });
try {
const session = await apiLogin(username, password)
dispatch({ type: ACCOUNT_LOGIN_SUCCESS, payload: session });
@pedrouid
pedrouid / index.html
Created July 15, 2019 13:21
Test WalletConnect (HTML + JS)
<html>
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="/favicon.ico" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<title>WalletConnect Example</title>