Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encointer v0.8.0 #268

Merged
merged 17 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/js_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
name: executables
# in fact this action should download the latest artifact, but sometimes fails. Then we need to
# set the `run_id` to force a download of an updated binary.
run_id: 1607659373
run_id: 1671661551
path: node
repo: encointer/encointer-node

Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ and find the output in `build/app/outputs/bundle/release/app-release.aab`
#### Dev hints

Currently supports flutter: 2.02

Re-generate mobx g.dart files
flutter packages pub run build_runner build --delete-conflicting-outputs

Copy link
Member Author

@clangenb clangenb Jan 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant info: this is displayed10 lines below, too.

### Run tests

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
48 changes: 24 additions & 24 deletions lib/js_service_encointer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,52 @@
"tslib": "^2.3.1"
},
"dependencies": {
"@encointer/node-api": "^0.5.1",
"@encointer/types": "^0.5.1",
"@encointer/util": "^0.5.1",
"@encointer/worker-api": "^0.5.1",
"@polkadot/api": "^6.12.1",
"@polkadot/keyring": "^8.1.2",
"@polkadot/networks": "^8.1.2",
"@polkadot/rpc-provider": "^6.12.1",
"@polkadot/types": "^6.12.1",
"@polkadot/ui-shared": "^0.87.5",
"@polkadot/util": "^8.1.2",
"@polkadot/util-crypto": "^8.1.2",
"@encointer/node-api": "^0.6.0",
"@encointer/types": "^0.6.0",
"@encointer/util": "^0.6.0",
"@encointer/worker-api": "^0.6.0",
"@polkadot/api": "^7.2.1",
"@polkadot/keyring": "^8.2.2",
"@polkadot/networks": "^8.2.2",
"@polkadot/rpc-provider": "^7.2.1",
"@polkadot/types": "^7.2.1",
"@polkadot/ui-shared": "^0.88.1",
"@polkadot/util": "^8.2.2",
"@polkadot/util-crypto": "^8.2.2",
"Buffer": "^0.0.0",
"bn.js": "^4.12.0",
"buffer": "^6.0.3",
"core-js": "^3.19.3",
"core-js": "^3.20.2",
"node-rsa": "^1.1.1",
"oo7-substrate": "^0.8.0",
"process": "^0.11.10",
"regenerator-runtime": "^0.13.9",
"tslib": "^2.3.1"
},
"devDependencies": {
"@babel/core": "^7.16.0",
"@babel/preset-env": "^7.16.4",
"@babel/register": "^7.16.0",
"@babel/runtime": "^7.16.3",
"@jest/globals": "^27.4.4",
"@babel/core": "^7.16.7",
"@babel/preset-env": "^7.16.7",
"@babel/register": "^7.16.7",
"@babel/runtime": "^7.16.7",
"@jest/globals": "^27.4.6",
"@webpack-cli/info": "^1.4.0",
"@webpack-cli/init": "^1.1.3",
"babel-loader": "^8.2.3",
"browserslist": "^4.18.1",
"browserslist": "^4.19.1",
"constants-browserify": "^1.0.0",
"cross-env": "^7.0.3",
"crypto-browserify": "^3.12.0",
"eslint": "^8.4.1",
"eslint": "^8.6.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jest": "^25.3.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^25.3.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-only-warn": "^1.0.3",
"eslint-plugin-promise": "^5.2.0",
"eslint-plugin-standard": "^5.0.0",
"inquirer": "^8.2.0",
"jest": "^27.4.4",
"jest-config": "^27.4.4",
"jest": "^27.4.7",
"jest-config": "^27.4.7",
"prettier": "^2.5.1",
"stream-browserify": "^3.0.0",
"thread-loader": "^3.0.4",
Expand Down
58 changes: 9 additions & 49 deletions lib/js_service_encointer/src/service/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import {
getSubmittable
} from '../utils/QrSigner.js';
import { Keyring } from '@polkadot/keyring';
import { createType, i128 } from '@polkadot/types';
import { communityIdentifierFromString, parseI64F64 } from '@encointer/util';
import { createType } from '@polkadot/types';
import { communityIdentifierFromString } from '@encointer/util';
import { TrustedCallMap } from '../config/trustedCall.js';
import { base58Decode } from '@polkadot/util-crypto/base58/bs58';
import { callWorker, encointerBalances, substrateeRegistry, transfer } from '../config/consts.js';
import { unsubscribe } from '../utils/unsubscribe.js';
import settings from './settings.js';
import { stringToEncointerBalance } from '@encointer/types';
import { parseEncointerBalance, stringToEncointerBalance } from '@encointer/types';
import { extractEvents } from '@encointer/node-api';

export const keyring = new Keyring({ ss58Format: 0, type: 'sr25519' });

Expand Down Expand Up @@ -302,50 +303,6 @@ function isTcIsRegisterAttestations (txInfo) {
return TrustedCallMap[txInfo.module][txInfo.call] === 'ceremonies_register_attestations';
}

function _extractEvents (api, result) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outsourced to @encointer

if (!result || !result.events) {
return;
}

let success = false;
let error;
result.events
.filter((event) => !!event.event)
.map(({ event: { data, method, section } }) => {
if (section === 'system' && method === 'ExtrinsicFailed') {
const [dispatchError] = data;
let message = dispatchError.type;

if (dispatchError.isModule) {
try {
const mod = dispatchError.asModule;
const error = api.registry.findMetaError(
new Uint8Array([mod.index.toNumber(), mod.error.toNumber()])
);

message = `${error.section}.${error.name}`;
} catch (error) {
// swallow error
}
}
window.send('txUpdateEvent', {
title: `${section}.${method}`,
message
});
error = message;
} else {
window.send('txUpdateEvent', {
title: `${section}.${method}`,
message: 'ok'
});
if (section == 'system' && method == 'ExtrinsicSuccess') {
success = true;
}
}
});
return { success, error };
}

export function sendTx (txInfo, paramList) {
const keyPair = keyring.getPair(hexToU8a(txInfo.pubKey));
try {
Expand All @@ -369,19 +326,22 @@ export function sendTx (txInfo, paramList) {
function _sendTx (keyPair, txInfo, paramList) {
return new Promise((resolve) => {
let unsub = () => {};
let balanceHuman;

if (txInfo.module === encointerBalances && txInfo.call === transfer) {
balanceHuman = paramList[2];
paramList[1] = communityIdentifierFromString(api.registry, paramList[1]);
paramList[2] = bnToU8a(stringToEncointerBalance(paramList[2]), 128, true);
}

const tx = api.tx[txInfo.module][txInfo.call](...paramList);
const onStatusChange = (result) => {
if (result.status.isInBlock || result.status.isFinalized) {
const { success, error } = _extractEvents(api, result);
const { success, error } = extractEvents(api, result);
if (success) {
if (txInfo.module === encointerBalances && txInfo.call === transfer) {
paramList[2] = parseI64F64(paramList[2]);
// make transfer amount human-readable again
paramList[2] = balanceHuman;
}

resolve({
Expand Down
Loading