This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ethUtil = require('ethereumjs-util'); | |
const abi = require('ethereumjs-abi'); | |
const chai = require('chai'); | |
const typedData = { | |
types: { | |
EIP712Domain: [ | |
{ name: 'name', type: 'string' }, | |
{ name: 'version', type: 'string' }, | |
{ name: 'chainId', type: 'uint256' }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm init -y | |
echo "node_modules\n.env" > .gitignore | |
echo "# Node.js Boilerplate Sample" > README.md | |
touch .env | |
mkdir -p src/test && touch src/index.js | |
mkdir -p src/lib | |
mkdir -p .github/workflows && touch .github/workflows/actions.yaml | |
mkdir .vscode && touch .vscode/settings.json | |
touch .prettierrc | |
git init |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.5.12; | |
// FIXME: This contract was altered compared to the production version. | |
// It doesn't use LibNote anymore. | |
// New deployments of this contract will need to include custom events (TO DO). | |
contract Dai { | |
// --- Auth --- | |
mapping (address => uint) public wards; | |
function rely(address guy) external auth { wards[guy] = 1; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"main": "index.js", | |
"scripts": { | |
"clean": "rimraf dist", | |
"start": "NODE_ENV=production node -r ts-node/register/transpile-only -r tsconfig-paths/register ./dist/index.js", | |
"build": "npm run clean && tsc", | |
"dev": "NODE_ENV=development ts-node-dev -r tsconfig-paths/register ./src/index.ts", | |
"test": "mocha -r ts-node/register \"src/test/**/*.spec.ts\"", | |
"pm2:dev": "npm run build && pm2 start pm2_dev.config.js", | |
"pm2:prod": "npm run build && pm2 start pm2_prod.config.js", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */ | |
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ | |
"outDir": "./dist", /* Redirect output structure to the directory. */ | |
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ | |
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ | |
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ | |
"skipLibC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"test": "mocha \"test/**/*.spec.js\"" | |
# TypeScript development | |
"test": "mocha -r ts-node/register \"src/test/**/*.spec.ts\"" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BasicStrategy as Strategy } from 'passport-http'; | |
import { Injectable, InternalServerErrorException, UnauthorizedException } from '@nestjs/common'; | |
import { PassportStrategy } from '@nestjs/passport'; | |
import { ConfigService } from '@nestjs/config'; | |
import { timingSafeEqual } from 'crypto'; | |
@Injectable() | |
export class AdminBasicStrategy extends PassportStrategy(Strategy) { | |
constructor(private readonly configService: ConfigService) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const HDWallet = require('ethereum-hdwallet') | |
const bip39 = require('bip39'); | |
const fs = require('fs') | |
const seedStart = 'program deny train foot scrap marble anxiety oblige hybrid clean' | |
const words = fs.readFileSync('./words.txt').toString('utf-8').split('\r\n') | |
for(let x = 0; x < words.length; x++){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Fn = (...args: any[]) => any; | |
function makeAsync<T extends Fn>(fn: Fn): (...args: Parameters<T>) => Promise<ReturnType<T>> { | |
return function (this: any, ...args: Parameters<T>): Promise<ReturnType<T>> { | |
return new Promise<ReturnType<T>>((res, rej) => { | |
try { | |
res(fn.call(this, ...args)); | |
} catch (e) { | |
rej(e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Person = { | |
firstName: "Lawrence", | |
lastName: "Eagles", | |
sayName: function () { | |
setTimeout(function() { | |
console.log("my fullname is " + this.firstName + " " + this.lastName) | |
}.bind(this), 100) // binds this here. | |
} | |
} |