Giter Club home page Giter Club logo

common's People

Contributors

adamdossa avatar amaury1093 avatar andreasgassmann avatar awesomepan avatar carlosala avatar gavofyork avatar github-actions[bot] avatar greenkeeper[bot] avatar hskang9 avatar jacogr avatar jak-pan avatar joelamouche avatar kwingram25 avatar lovesh avatar ltfschoen avatar mohsinriaz17 avatar nick-1979 avatar noodlesploder avatar ntduan avatar raoulmillais avatar raykyri avatar retotrinkler avatar roccomuso avatar roytimes avatar shamilkhan avatar stefie avatar tarikgul avatar tbaut avatar tomokazukozuma avatar tore19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

common's Issues

Add instance method to set prefix on keyring

  const keyring = new Keyring();
  
  keyring.setAddressPrefix(68);
  keyring.encodeAddress(...); // encodes with prefix
  keyring.encodeAddress(..., 42); // pass in optional prefix

Moving towards getting rid of the setAddressPrefix global (also has impacts on api/types for Address, AccountId & AccountIndex)

A question on util-crypto/nacl's deriveHard() usage

As far as I know,

in SLIP-0010, deriving child key on ed25519 curve means:

  1. create hmac of key and chaincode
  2. slice first 32 byte (IL) as key(the seed to generate new key), and the other 32 byte (IR) for chaincode to make entropy in next generation of keys.

but util-crypto/nacl's deriveHard() generates blake2 hash of concatenated(master_secret('ed25519 seed'), IL, IR).

Is there a missing component in the key derivation?

Sort out u8aFrom{String,Utf8}

Change fromString to use fromUtf8, remove the Utf8 version. Same with to, just get rid of toString completely in that case, use impl of toUtf8

An in-range update of @polkadot/ts is breaking the build ๐Ÿšจ

The devDependency @polkadot/ts was updated from 0.1.31 to 0.1.32.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@polkadot/ts is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of @polkadot/dev is breaking the build ๐Ÿšจ

The devDependency @polkadot/dev was updated from 0.20.24 to 0.20.25.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@polkadot/dev is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

schnorrkel polyfill breaks test

We are testing our application with jest.
After updating the polkadot api, we couldn't run our tests anymore, because of following error:

TypeError: Object.defineProperty called on non-object
        at Function.defineProperty (<anonymous>)

      at Object.<anonymous> (../node_modules/@polkadot/util-crypto/schnorrkel/schnorrkel-js/polyfill.js:9:10)
      at Object.<anonymous> (../node_modules/@polkadot/util-crypto/schnorrkel/schnorrkel-js/index.js:11:1)
      at Object.<anonymous> (../node_modules/@polkadot/util-crypto/schnorrkel/keypair/fromSeed.js:10:42)

The line failing is:

Object.defineProperty((global as any).self, 'crypto', {

We circumvent the problem right now, by setting the node_env to another value for our tests.

Refactor blake2b subdirectory into blake2 outer directory

In https://github.com/polkadot-js/common/tree/master/packages/util-crypto/src/blake2, we could get rid of blake2bAsHex and blake2bAsU8a, and instead just use blake2AsHex and blake2AsU8a (but making the bitLength argument optional). Meaning we'd get rid of the blake2 subdirectory (the second subdirectory). Based on discussion with @jacogr we are just using blake2b, not blake2s, so we can get rid of the subdirectory approach
Not since there is only 2b, can flatten the whole thing.
Assume that the only use of the subdirectory is inside that directory, so it shouldn't be necessary to update other repos, but double check anyway if anything points to blake2/blake2b/*.ts.

So the only thing that we should do that has been suggested i.e. top-level. Instead of this -

https://github.com/polkadot-js/common/blob/master/packages/util-crypto/src/blake2/asHex.ts#L19

export default function blake2AsHex (data: Uint8Array, bitLength: number = 256): string {
  return blake2bAsHex(data, bitLength);
}

We should just do the following, which is basically what's inside the 2b directory

export default function blake2AsHex (data: Uint8Array, bitLength: number = 256): string {
  return u8aToHex(
    blake2bAsU8a(data, bitLength)
  );
}

Note that in the blake2b subdirectory, the default value for bitLength is 512, whereas the calling functions in the outer directory have a default value of bitLength as 256. We should use the 256 default, since all our hashes are 32 bytes

Webpack error with schnorrkel

Uncaught TypeError: TextDecoder is not a constructor
    at eval (schnorrkel_js.js?2cbf:179)
    at Object.../../node_modules/@parity/schnorrkel-js/schnorrkel_js.js (main.d8a8675f.js:351)

Add debug logging

  1. Parse DEBUG=foor,bar polkadot.js ...
  2. Inside logging,
  • when debugKeys.includes(key), l.debug(...) -> l.log(...)
  • when !debugKeys.includes(key), l.debug(...) -> () => void

isHex(something) has unintended effects

isHex (value: any): value is string has the side-effects -

return isHex(value)
  ? (value.length - 2) / 2
  : value.length // here it is _not_ a string

Better would be to just return boolean

An in-range update of @polkadot/dev is breaking the build ๐Ÿšจ

The devDependency @polkadot/dev was updated from 0.24.4 to 0.24.5.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@polkadot/dev is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of @polkadot/dev is breaking the build ๐Ÿšจ

The devDependency @polkadot/dev was updated from 0.22.1 to 0.22.2.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@polkadot/dev is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of babel7 is breaking the build ๐Ÿšจ

There have been updates to the babel7 monorepo:

    • The devDependency @babel/core was updated from 7.4.5 to 7.5.0.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the babel7 group definition.

babel7 is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of @polkadot/ts is breaking the build ๐Ÿšจ

The devDependency @polkadot/ts was updated from 0.1.38 to 0.1.39.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@polkadot/ts is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of @polkadot/ts is breaking the build ๐Ÿšจ

The devDependency @polkadot/ts was updated from 0.1.49 to 0.1.50.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@polkadot/ts is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Convert primitives to object-with-baseclass

This one is a bit involved, so it probably makes sense starting with 1, seeing how it goes (implementing across the tree, i.e. here, api & apps) and then taking it further.

Basically, atm any value actually refers to the base type. For this example, let's take BlockNumber. In effect, it is type BlockNumber = BN, the idea is -

// probably may not be needed to pass generic, probably just Uint8Array (sliceables)
interface ParamEncoder <S> {
  encode (): S;
  toJSON (): any;
}

interface ParamDecoder <C, O> {
  decode (input: S): C;
  fromJSON (input: any): C;
}

interface BaseParam <T> { // or BasePrimitive, or BaseType, or...
  value: T;
}

class BlockNumber implements ParamEncoder<Uint8Array>, BaseParam<BN> {
  value: BN;

  encode (): Uint8Array {
    // ... convert to sliceable
  }

  toJSON (): any {
    // yes, we have utils for this, just a sample
    return '0x' + this.value.toString(16);
  }

  static decode (input: Uint8Array): BlockNumber {
    return new BlockNumber(...);
  } 

  static fromJSON (input: any): BlockNumber {
    return new BlockNumber(...);
  }
}  

The benefits we get -

  1. consistent interface for all values
  2. encoding/decoding is not done in different places across the codebase
  3. instead of import encoder from '@polkadot/primitives/bn/encoder'; enoder(bn) we just do bn.encode()

BlockNumber here is actually an interesting one -

  1. It may encode differently depending on chain (sizes, Nonce & Balance are currently good examples of this)
  2. It shares the same type with others, only differring in length, i.e. Balance & Nonce are also with the same logic.
  3. With the above in mind, it probably makes a bit more sense doing Nonce or Balance first (the latter has further-reaching UI impacts, so Nonce conevrs all the bases, but has a lesser footprint)

Add lmdb interface (PRE client use)

The DB interfaces needs to be adapted since lmdb uses transactions by default. (So BaseDb needs to expose part of the TransactionDb interfaces)

An in-range update of @polkadot/dev is breaking the build ๐Ÿšจ

The devDependency @polkadot/dev was updated from 0.21.3 to 0.21.4.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@polkadot/dev is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Expose mnemonicToSeed

Which is just mnemonicToSecret(seed).subarray(0, 32)

Just don't want to be doing the externally, i.e. in the UI

Add conversion aliasses

e.g. currently we have u8aFromBuffer, the equivalent bufferToU8a should be made available. An alias could look like the following:

const bufferToU8a = require('../u8a/fromBuffer');

module.exports = bufferToU8a;

(buffer, number, hex, u8a, ...)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.