Integrate new keyring (#693)

* Integrate new keyring

* Bump

* Bump version

* ed25519 dusl-support
This commit is contained in:
Jaco Greeff
2019-02-14 23:17:02 +01:00
committed by GitHub
parent e75040daac
commit ead67ec9d6
22 changed files with 150 additions and 66 deletions
+4
View File
@@ -1,3 +1,7 @@
# 0.43.1
- Intrduces support for the new keyring with sr25519 support in addition to ed25519. While this does not change the exposed API, it is considerred breaking since @polkadot/keuyring has interface changes. (Unless needed, don't rush the upgrade)
# 0.42.1
- Support for substrate hash signing with implVersion >= 18
+1 -1
View File
@@ -9,5 +9,5 @@
"packages": [
"packages/*"
],
"version": "0.42.19"
"version": "0.43.0"
}
+1 -1
View File
@@ -24,7 +24,7 @@
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@polkadot/dev": "^0.23.14",
"@polkadot/dev": "^0.23.15",
"@polkadot/ts": "^0.1.52"
}
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "0.42.19",
"version": "0.43.0",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
"keywords": [
@@ -31,8 +31,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/api": "^0.42.19",
"@polkadot/types": "^0.42.19",
"@polkadot/api": "^0.43.0",
"@polkadot/types": "^0.43.0",
"@types/memoizee": "^0.4.2",
"@types/rx": "^4.1.1",
"memoizee": "^0.4.14",
+8 -8
View File
@@ -1,7 +1,7 @@
{
"name": "@polkadot/api",
"version": "0.42.19",
"description": "An RxJS wrapper around the Polkadot JS RPC",
"version": "0.43.0",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
"keywords": [
"Polkadot",
@@ -30,12 +30,12 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/api-derive": "^0.42.19",
"@polkadot/extrinsics": "^0.42.19",
"@polkadot/rpc-provider": "^0.42.19",
"@polkadot/rpc-rx": "^0.42.19",
"@polkadot/storage": "^0.42.19",
"@polkadot/types": "^0.42.19",
"@polkadot/api-derive": "^0.43.0",
"@polkadot/extrinsics": "^0.43.0",
"@polkadot/rpc-provider": "^0.43.0",
"@polkadot/rpc-rx": "^0.43.0",
"@polkadot/storage": "^0.43.0",
"@polkadot/types": "^0.43.0",
"@types/rx": "^4.1.1",
"rxjs": "^6.3.3"
}
@@ -7,7 +7,7 @@ import testingPairs from '@polkadot/keyring/testingPairs';
import Api from '../../src/promise';
const keyring = testingPairs();
const keyring = testingPairs({ type: 'ed25519' });
describe.skip('e2e queries', () => {
let api;
+54 -2
View File
@@ -3,19 +3,24 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import testingPairs from '@polkadot/keyring/testingPairs';
import createPair from '@polkadot/keyring/pair';
import { randomAsHex } from '@polkadot/util-crypto';
import { stringToU8a } from '@polkadot/util';
import Api from '../../src/promise';
import WsProvider from '../../../rpc-provider/src/ws';
import SingleAccountSigner from "../util/SingleAccountSigner";
const keyring = testingPairs();
const keyring = testingPairs({ type: 'ed25519' });
describe.skip('e2e transactions', () => {
let api;
beforeEach(async (done) => {
if (!api) {
api = await Api.create();
api = await Api.create({
provider: new WsProvider('ws://127.0.0.1:9944')
});
}
jest.setTimeout(30000);
@@ -154,4 +159,51 @@ describe.skip('e2e transactions', () => {
expect(hash.toHex()).toHaveLength(66);
});
it('makes a transfer, swaps types and then another one', async (done) => {
const pair = createPair('sr25519', { seed: stringToU8a('testing123'.padEnd(32)) });
function doOne (cb) {
return api.tx.balances
.transfer(pair.address(), 123456)
.signAndSend(keyring.dave, ({ events, status, type }) => {
console.log('One: Transaction status:', type);
if (type === 'Finalised') {
console.log('Completed at block hash', status.value.toHex());
console.log('Events:');
events.forEach(({ phase, event: { data, method, section } }) => {
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
});
cb()
}
});
};
function doTwo (cb) {
return api.tx.balances
.transfer(keyring.alice.address(), 12345)
.signAndSend(pair, ({ events, status, type }) => {
console.log('One: Transaction status:', type);
if (type === 'Finalised') {
console.log('Completed at block hash', status.value.toHex());
console.log('Events:');
events.forEach(({ phase, event: { data, method, section } }) => {
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
});
cb()
}
});
}
// return doTwo(done);
return doOne(() => {
doTwo(done)
});
});
});
+1 -1
View File
@@ -7,7 +7,7 @@ import testingPairs from '@polkadot/keyring/testingPairs';
import Api from '../../src/rx';
const keyring = testingPairs();
const keyring = testingPairs({ type: 'ed25519' });
describe.skip('e2e queries', () => {
let api;
+1 -1
View File
@@ -7,7 +7,7 @@ import testingPairs from '@polkadot/keyring/testingPairs';
import Api from '../../src/rx';
const keyring = testingPairs();
const keyring = testingPairs({ type: 'ed25519' });
describe.skip('e2e transactions', () => {
let api;
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "0.42.19",
"version": "0.43.0",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"keywords": [
@@ -30,9 +30,9 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/jsonrpc": "^0.42.19",
"@polkadot/rpc-provider": "^0.42.19",
"@polkadot/types": "^0.42.19",
"@polkadot/util": "^0.33.36"
"@polkadot/jsonrpc": "^0.43.0",
"@polkadot/rpc-provider": "^0.43.0",
"@polkadot/types": "^0.43.0",
"@polkadot/util": "^0.34.6"
}
}
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "0.42.19",
"version": "0.43.0",
"description": "Transport providers for the API",
"main": "index.js",
"keywords": [
@@ -30,10 +30,10 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/keyring": "^0.33.36",
"@polkadot/storage": "^0.42.19",
"@polkadot/util": "^0.33.36",
"@polkadot/util-crypto": "^0.33.36",
"@polkadot/keyring": "^0.34.6",
"@polkadot/storage": "^0.43.0",
"@polkadot/util": "^0.34.6",
"@polkadot/util-crypto": "^0.34.6",
"@types/nock": "^9.3.0",
"eventemitter3": "^3.1.0",
"isomorphic-fetch": "^2.2.1",
+1 -1
View File
@@ -30,7 +30,7 @@ const SUBSCRIPTIONS: string[] = Array.prototype.concat.apply(
)
);
const keyring = testKeyring();
const keyring = testKeyring({ type: 'sr25519' });
const l = logger('api-mock');
/**
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-rx",
"version": "0.42.19",
"version": "0.43.0",
"description": "An RxJs wrapper around the Polkadot JS API",
"main": "index.js",
"keywords": [
@@ -30,8 +30,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-rx#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/rpc-core": "^0.42.19",
"@polkadot/rpc-provider": "^0.42.19",
"@polkadot/rpc-core": "^0.43.0",
"@polkadot/rpc-provider": "^0.43.0",
"@types/memoizee": "^0.4.2",
"@types/rx": "^4.1.1",
"memoizee": "^0.4.14",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/extrinsics",
"version": "0.42.19",
"version": "0.43.0",
"main": "index.js",
"repository": "https://github.com/polkadot-js/api.git",
"author": "Jaco Greeff <jacogr@gmail.com>",
@@ -11,7 +11,7 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/types": "^0.42.19",
"@polkadot/util": "^0.33.36"
"@polkadot/types": "^0.43.0",
"@polkadot/util": "^0.34.6"
}
}
+1 -1
View File
@@ -7,7 +7,7 @@ import { Extrinsic } from '@polkadot/types/index';
import extrinsics from './static';
const keyring = testingPairs();
const keyring = testingPairs({ type: 'ed25519' });
describe('extrinsics', () => {
it('encodes extrinsic correctly (nobody)', () => {
@@ -8,7 +8,7 @@ import testingPairs from '@polkadot/keyring/testingPairs';
import extrinsics from '../../src/static';
const keyring = testingPairs();
const keyring = testingPairs({ type: 'ed25519' });
describe.skip('e2e transfer', () => {
let api;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/jsonrpc",
"version": "0.42.19",
"version": "0.43.0",
"description": "Method definitions for the Polkadot RPC layer",
"main": "index.js",
"engines": {
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/storage",
"version": "0.42.19",
"version": "0.43.0",
"description": "Generic wrapper wrapper around state storage",
"main": "index.js",
"engines": {
@@ -30,9 +30,9 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-storage#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/keyring": "^0.33.36",
"@polkadot/types": "^0.42.19",
"@polkadot/util": "^0.33.36",
"@polkadot/util-crypto": "^0.33.36"
"@polkadot/keyring": "^0.34.6",
"@polkadot/types": "^0.43.0",
"@polkadot/util": "^0.34.6",
"@polkadot/util-crypto": "^0.34.6"
}
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "0.42.19",
"version": "0.43.0",
"description": "Implementation of the Parity codec",
"main": "index.js",
"keywords": [
@@ -30,8 +30,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/keyring": "^0.33.36",
"@polkadot/util": "^0.33.36",
"@polkadot/keyring": "^0.34.6",
"@polkadot/util": "^0.34.6",
"core-js": "^2.6.2"
}
}
+16
View File
@@ -12,3 +12,19 @@ import H512 from './H512';
*/
export default class Signature extends H512 {
}
/**
* @name Ed25519Signature
* @description
* The default Ed25519 that is used accross the system. It is currectly defined
* as a 512-bit value, represented by a [[H512]].
*/
export class Ed25519Signature extends Signature {}
/**
* @name Sr25519Signature
* @description
* The default Sr25519 signature that is used accross the system. It is currectly defined
* as a 512-bit value, represented by a [[H512]].
*/
export class Sr25519Signature extends Signature {}
+1 -1
View File
@@ -73,7 +73,7 @@ export { default as RuntimeVersion } from './RuntimeVersion';
export { default as Schedule } from './Schedule';
export { default as SeedOf } from './SeedOf';
export { default as SessionKey } from './SessionKey';
export { default as Signature } from './Signature';
export { default as Signature, Ed25519Signature, Sr25519Signature } from './Signature';
export { default as SignedBlock } from './SignedBlock';
export { default as StorageChangeSet } from './StorageChangeSet';
export { default as StorageData } from './StorageData';
+31 -19
View File
@@ -1293,10 +1293,15 @@
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==
"@polkadot/dev@^0.23.14":
version "0.23.14"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.23.14.tgz#e649dfaaab4fb1c8e8f2c1695a8b5367dd3ce2ce"
integrity sha512-vmgS7THEvEp1v7iKw/QxanedAozSIRzUJWVHLUkIRyDSRfH3/iOFxEwNso0CNMULO1OHfIfhgDP+3lHj/IMB1A==
"@parity/schnorrkel-js@^0.1.2":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@parity/schnorrkel-js/-/schnorrkel-js-0.1.2.tgz#08c9663299cbe43d292599a1312a761b2426900f"
integrity sha512-eQSCY6kb16Lhnlgdz1FbADo1PEI3Xgp0ApGpNydf0yBEQ6AMVo1YN/4zMA3lFjqnurv9NsAy11OJApailUNneQ==
"@polkadot/dev@^0.23.15":
version "0.23.15"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.23.15.tgz#f1428a706e5ff2138eaf38900070579dee84b57d"
integrity sha512-SVkB3s1KsFQm9Pka8zKx4S06LX5S70r7xCV2lTmbj/5Wj/diamuZgbAHU313cH89q59qU9Bns2gJhynvGXkXfg==
dependencies:
"@babel/cli" "^7.2.3"
"@babel/core" "^7.2.2"
@@ -1333,14 +1338,14 @@
typedoc-plugin-no-inherit "^1.1.2"
typescript "^3.2.2"
"@polkadot/keyring@^0.33.36":
version "0.33.36"
resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.33.36.tgz#def02631369b1a2288ae95d32cadd63299f877f7"
integrity sha512-UUyb0ua+b10FAt+dH5Vuua0mu+FH9WY+as+IoVNXyDY8PpHY+kg8MDXXrCGBueCF5CaiiAJP7gD5vp7U10nrEg==
"@polkadot/keyring@^0.34.6":
version "0.34.6"
resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.34.6.tgz#fbe7a9a4cc4d96c8c692c5269aa953aee5d3e7ef"
integrity sha512-137VRVVYhLQseB8qHVqmMhcn0PjXjRxJxGLIwxqfPPquPd6z00xcprNwLKm35fi9bH8Akj6isKD7e/DRKbAfSA==
dependencies:
"@babel/runtime" "^7.2.0"
"@polkadot/util" "^0.33.36"
"@polkadot/util-crypto" "^0.33.36"
"@polkadot/util" "^0.34.6"
"@polkadot/util-crypto" "^0.34.6"
"@types/bs58" "^4.0.0"
bs58 "^4.0.1"
@@ -1349,24 +1354,26 @@
resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.52.tgz#6fb09e494d244dad4b3a9ca581bfe13beec66565"
integrity sha512-sij1O0x4CY51A394RYD4/aQwDPwIxIeTOpYI4AZgdF/vq5nvF14b4XFq9vAcSnblaIosf0sYKoz1f3dkN3QqLw==
"@polkadot/util-crypto@^0.33.36":
version "0.33.36"
resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.33.36.tgz#3b1fc84be7126fd92ee4de960baafb901e50b1a4"
integrity sha512-kjzdOrBL8NKfZZdWIhQFim3yDWo6sHjWOuxJQt8k22pHa/ATF8zVZ6Xqi4r+wsfBa9S+G6AE5yyVOirVPQYeCQ==
"@polkadot/util-crypto@^0.34.6":
version "0.34.6"
resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.34.6.tgz#4cbe8afb1630fd6bf5e602612ea18026c300c4a5"
integrity sha512-F/fAAOFMgzQwxheE2RAIf5G/oPVlJhKUTJLClrgyac5dmpnueWd4wfaHJC+071yFzP5GMR/0cTGe1LOShb9jOw==
dependencies:
"@babel/runtime" "^7.2.0"
"@polkadot/util" "^0.33.36"
"@parity/schnorrkel-js" "^0.1.2"
"@polkadot/util" "^0.34.6"
"@types/bip39" "^2.4.1"
"@types/webassembly-js-api" "^0.0.2"
bip39 "^2.5.0"
blakejs "^1.1.0"
js-sha3 "^0.8.0"
tweetnacl "^1.0.0"
xxhashjs "^0.2.2"
"@polkadot/util@^0.33.36":
version "0.33.36"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.33.36.tgz#975590dd059f78209c9d398f72651ac393dd8245"
integrity sha512-N5b46NYTNJODILXNGRxvW/8yeKiHjQv4k3YmJhYnslMsEbaXPvkePFUA2N8Ji1LQrAD8sQbaoG8aYoNaqHSJMA==
"@polkadot/util@^0.34.6":
version "0.34.6"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.34.6.tgz#00f66a231c3764719081fdcf2694ad53fbd7dcf3"
integrity sha512-8Ag/ISA7t0onx7f+PbREIJX69hWZe+prUDhRjVMT64VkiSE2ErfM74Lu+A3N4Yy9a/APQUTUhDrI6cnBT8SGbg==
dependencies:
"@babel/runtime" "^7.2.0"
"@types/bn.js" "^4.11.3"
@@ -1602,6 +1609,11 @@
"@types/glob" "*"
"@types/node" "*"
"@types/webassembly-js-api@^0.0.2":
version "0.0.2"
resolved "https://registry.yarnpkg.com/@types/webassembly-js-api/-/webassembly-js-api-0.0.2.tgz#43a04bd75fa20332133c6c3986156bfeb4a3ced7"
integrity sha512-htlxJRag6RUiMYUkS8Fjup+TMHO0VarpiF9MrqYaGJ0wXtIraQFz40rfA8VIeCiWy8sgpv3RLmigpgicG8fqGA==
"@types/xxhashjs@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@types/xxhashjs/-/xxhashjs-0.1.1.tgz#980709096c7138713b7777f49dccd4b8f93908e5"