Skip to content

Commit

Permalink
Merge pull request #348 from docknetwork/offchain-signatures
Browse files Browse the repository at this point in the history
Offchain signatures + updated `@docknetwork/crypto-wasm`, `@docknetwork/crypto-wasm-ts`.
  • Loading branch information
lovesh authored May 26, 2023
2 parents 1cbbdf2 + e4f34b4 commit 69fef42
Show file tree
Hide file tree
Showing 77 changed files with 5,397 additions and 2,533 deletions.
8 changes: 7 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ node_modules
dist
build
tests
tutorial
tutorials
.github
.env
docker
.editorconfig
.eslintrc.json
.git
.npmrc
env_example
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"sourceType": "module"
},
"rules": {
"no-unused-vars": ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_", "caughtErrorsIgnorePattern": "^_" }],
"no-use-before-define": [
"error",
{
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/integrations-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
runs-on: ubuntu-latest
env:
CONFIG_DOCK_NODE_IMAGE_TAG: 'mainnet'
TestSchemes: 'BBSPlus'
steps:
- uses: actions/checkout@v2
- uses: ibnesayeed/[email protected]
Expand All @@ -41,6 +42,7 @@ jobs:
env:
CONFIG_DOCK_NODE_IMAGE_TAG: 'testnet'
DISABLE_DEMOCRACY_PREIMAGE_TESTS: true
TestSchemes: 'BBSPlus'
steps:
- uses: actions/checkout@v2
- uses: ibnesayeed/[email protected]
Expand Down
9 changes: 3 additions & 6 deletions docker/staking_payouts/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
FROM node:14-stretch AS builder
FROM node:16.6.0-buster AS builder
WORKDIR /usr/app

COPY . .

RUN yarn
RUN yarn build-scripts

FROM public.ecr.aws/lambda/nodejs:14
FROM public.ecr.aws/lambda/nodejs:16

COPY --from=builder [ "/usr/app/build/scripts/staking_payouts.js", "/usr/app/yarn.lock", "/usr/app/package.json", "./" ]

RUN npm i -g yarn
RUN yarn
COPY --from=builder [ "/usr/app/build/*", "./" ]

CMD [ "staking_payouts.handler" ]
43 changes: 34 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/sdk",
"version": "4.0.1",
"version": "5.0.0",
"main": "index.js",
"license": "MIT",
"repository": {
Expand All @@ -17,9 +17,14 @@
"@babel/preset-env": "^7.15.6",
"@comunica/actor-init-sparql-rdfjs": "^1.22.3",
"@comunica/types": "^1.0.0",
"@rollup/plugin-commonjs": "^20.0.0",
"@docknetwork/crypto-wasm": "^0.18.0",
"@polkadot/x-bigint": "10.1.11",
"@polkadot/x-bundle": "10.1.11",
"@polkadot/x-global": "10.1.11",
"@rollup/plugin-alias": "^4.0.2",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-wasm": "^5.1.0",
"@types/jest": "^26.0.24",
"aws-sdk": "^2.1057.0",
Expand All @@ -39,12 +44,13 @@
"parity-scale-codec": "^0.5.3",
"r1csfile": "0.0.41",
"ramda": "^0.27.2",
"rollup": "2.56.3",
"rollup-plugin-multi-input": "^1.3.1",
"rollup": "2.78.0",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-multi-input": "^1.3.2",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-terser": "^7.0.2",
"rxjs": "^7.4.0",
"typescript": "^4.2.3",
"typescript": "5.0.4",
"web3": "^1.7.5"
},
"scripts": {
Expand All @@ -70,7 +76,7 @@
"lint-examples": "eslint \"{src,example}/**/*.js\"",
"lint-tests": "eslint \"{tests/unit,tests/integration}/**/*.js\"",
"build": "rollup -c",
"build-scripts": "rollup -c rollup.scripts.config.js",
"build-scripts": "rollup -c rollup.scripts.config.mjs",
"watch": "rollup -c -w",
"test": "yarn jest --verbose ./tests/unit",
"test-integration": "NODE_ENV=production jest --verbose --runInBand --forceExit ./tests/integration",
Expand All @@ -86,9 +92,23 @@
"mdbook": "mdbook build tutorials --dest-dir ../out/tutorials",
"type-check": "tsc --allowJs --checkJs --noEmit --moduleResolution node --resolveJsonModule --target ES6 --skipLibCheck true --allowSyntheticDefaultImports true"
},
"resolutions": {
"@polkadot/api": "9.7.1",
"@polkadot/keyring": "10.1.11",
"@polkadot/rpc-provider": "9.7.1",
"@polkadot/types": "9.7.1",
"@polkadot/types-known": "9.7.1",
"@polkadot/util": "10.1.11",
"@polkadot/util-crypto": "10.1.11",
"@polkadot/x-textencoder": "10.1.11",
"@polkadot/x-textdecoder": "10.1.11",
"@polkadot/x-ws": "10.1.11",
"@polkadot/x-fetch": "10.1.11",
"@polkadot/x-randomvalues": "10.1.11"
},
"dependencies": {
"@docknetwork/crypto-wasm-ts": "0.31.2",
"@docknetwork/node-types": "^0.15.0",
"@docknetwork/crypto-wasm-ts": "^0.33.3",
"@docknetwork/node-types": "^0.16.0",
"@juanelas/base64": "^1.0.5",
"@polkadot/api": "9.7.1",
"@polkadot/keyring": "10.1.11",
Expand All @@ -97,6 +117,11 @@
"@polkadot/types-known": "9.7.1",
"@polkadot/util": "10.1.11",
"@polkadot/util-crypto": "10.1.11",
"@polkadot/x-fetch": "10.1.11",
"@polkadot/x-randomvalues": "10.1.11",
"@polkadot/x-textdecoder": "10.1.11",
"@polkadot/x-textencoder": "10.1.11",
"@polkadot/x-ws": "10.1.11",
"@transmute/json-web-signature": "^0.7.0-unstable.80",
"axios": "0.27.2",
"base64url": "3.0.1",
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.js → rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import multiInput from 'rollup-plugin-multi-input';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
// import { wasm } from '@rollup/plugin-wasm';
import pkg from './package.json';
// import pkg from './package.json';

export default async function() {
return [{
plugins: [
multiInput(),
multiInput.default(),
json(),
terser(),
commonjs(),
Expand Down
20 changes: 0 additions & 20 deletions rollup.scripts.config.js

This file was deleted.

152 changes: 152 additions & 0 deletions rollup.scripts.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import json from "@rollup/plugin-json";
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import multiInput from "rollup-plugin-multi-input";
import { wasm } from "@rollup/plugin-wasm";
import path from "path";
import pluginAlias from "@rollup/plugin-alias";

function expand(prefix, all) {
return all.map((p) => (p ? `${prefix}-${p}` : prefix));
}

const baseEntries = [
...expand("api", ["augment", "base", "derive"]),
...expand("rpc", ["augment", "core", "provider"]),
...expand("types", [
...expand("augment", ["", "lookup", "registry"]),
"codec",
"create",
"helpers",
"known",
]),
].reduce(
(all, p) => ({
...all,
[`@polkadot/${p}`]: path.resolve(
process.cwd(),
`node_modules/@polkadot/${p}`
),
}),
{
// we point to a specific file for these (default augmentations)
"@polkadot/rpc-core/types/jsonrpc": path.resolve(
process.cwd(),
"node_modules/@polkadot/rpc-core/types/jsonrpc.js"
),
"@polkadot/types-codec/types/registry": path.resolve(
process.cwd(),
"node_modules/@polkadot/types-codec/types/registry.js"
),
}
);

const entries = [
"hw-ledger-transports",
"networks",
"x-bigint",
"x-fetch",
"x-global",
"x-randomvalues",
"x-textdecoder",
"x-textencoder",
"x-ws",
"wasm-crypto-init",
].reduce(
(all, p) => ({
...all,
[`@polkadot/${p}`]: path.resolve(
process.cwd(),
`node_modules/@polkadot/${p}`
),
}),
baseEntries
);

const overrides = {
"@polkadot/hw-ledger": {
// these are all in the un-shakable and unused hdDerivation stuff from the Zondax libs, ignore
entries: {
"bip32-ed25519": path.resolve(
process.cwd(),
"node_modules/@polkadot/x-bundle/build/empty.js"
),
bip39: path.resolve(
process.cwd(),
"node_modules/@polkadot/x-bundle/build/empty.js"
),
blakejs: path.resolve(
process.cwd(),
"node_modules/@polkadot/x-bundle/build/empty.js"
),
bs58: path.resolve(
process.cwd(),
"node_modules/@polkadot/x-bundle/build/empty.js"
),
events: path.resolve(
process.cwd(),
"node_modules/@polkadot/x-bundle/build/empty.js"
),
"hash.js": path.resolve(
process.cwd(),
"node_modules/@polkadot/x-bundle/build/empty.js"
),
},
},
"@polkadot/util-crypto": {
entries: {
"@polkadot/wasm-crypto": path.resolve(
process.cwd(),
"node_modules/@polkadot/wasm-crypto/bundle.js"
),
"bn.js": path.resolve(
process.cwd(),
"node_modules/@polkadot/x-bundle/build/bn.cjs"
),
buffer: path.resolve(
process.cwd(),
"node_modules/@polkadot/x-bundle/build/buffer.js"
),
crypto: path.resolve(
process.cwd(),
"node_modules/@polkadot/x-bundle/build/crypto.js"
),
},
inject: {
Buffer: path.resolve(
process.cwd(),
"node_modules/@polkadot/x-bundle/build/buffer.js"
),
crypto: path.resolve(
process.cwd(),
"node_modules/@polkadot/x-bundle/build/crypto.js"
),
inherits: path.resolve(
process.cwd(),
"node_modules/@polkadot/x-bundle/build/inherits.js"
),
},
polyfill: false,
},
};

export default {
external: [],
plugins: [
multiInput,
pluginAlias({ entries }),
json(),
commonjs(),
resolve({ preferBuiltins: false }),
wasm({
sync: ["*.wasm"],
}),
],
input: ["scripts/staking_payouts.js"],
output: {
manualChunks: {},
dir: "build",
format: "cjs",
entryFileNames: "[name].js",
},
};
12 changes: 11 additions & 1 deletion scripts/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Helpers for scripts

import { ApiPromise, WsProvider, Keyring } from "@polkadot/api";
import { Keyring } from "@polkadot/api";
import { cryptoWaitReady } from "@polkadot/util-crypto";
import { formatBalance } from "@polkadot/util";
import { bufferCount, map as mapRx } from "rxjs/operators";
Expand All @@ -11,6 +11,8 @@ import {
prop,
when,
isNil,
either,
equals,
o,
mapObjIndexed,
curry,
Expand Down Expand Up @@ -304,3 +306,11 @@ export const withDockAPI = curry((params, fn) => async (...args) => {
}
}
});

/**
* Converts "true" and non-zero to `true`, other values to `false`.
*
* @param {*} value
* @returns {bool}
*/
export const parseBool = either(equals("true"), o(Boolean, Number));
Loading

0 comments on commit 69fef42

Please sign in to comment.