Giter VIP home page Giter VIP logo

aepp-sdk-js's Introduction

æternity's JavaScript SDK

main action codecov docs npm npm

JavaScript SDK for the revolutionary æternity blockchain, targeting the æternity node implementation. The aepp-sdk is hosted on GitHub.

Guides & Examples

Introduction

Usage guides:

There are also examples that you can directly use and play with.

CLI - Command Line Interface

To quickly test all of æternity's blockchain features from your terminal, you can install and use the CLI by running:

  1. npm i -g @aeternity/aepp-cli to globally install the CLI
  2. aecli --help to get a list of possible commands

Contributing

For advanced use, to get a deeper understanding of the SDK or to contribute to its development, it is advised to read the Contributing Guidelines section.

Changelog

We keep our Changelog up to date.

License

ISC License (ISC) Copyright © 2024 æternity developers

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

aepp-sdk-js's People

Contributors

and1 avatar andi-apeunit avatar andrenarchy avatar davidyuk avatar dependabot[bot] avatar eminogrande avatar gorbak25 avatar greenkeeper[bot] avatar janmichek avatar johnsnewby avatar jsnewby avatar kalovelo avatar maptuhec avatar marc0olo avatar martinkaintas avatar mpowaga avatar mradkov avatar muxe avatar nduchak avatar nikita-fuchs avatar noandrea avatar outergod avatar perseverance avatar ricricucit avatar shekhar-shubhendu avatar subhod-i avatar tarasherasymchuk avatar thepiwo avatar tillkolter avatar vsavovlime 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aepp-sdk-js's Issues

Export transaction creators by name instead of wrapping with stampit

es/tx/js.js is a useful module that contains pure functions for generation of transactions, but why they are exported only as a stampit instance instead of using es6 named exports? That will simplify usage of this functions and enable tree shaking (can be not so helpful in this case, but in general it is better to write tree shakable code). Also, this module already exporting some functions by name.

Expected Behavior

import { spendTxNative } from '@aeternity/aepp-sdk/es/tx/js.js';
const spendTx = spendTxNative({ ... });

Current Behavior

import JsTxStamp from '@aeternity/aepp-sdk/es/tx/js.js';
const JsTx = JsTxStamp();
const spendTx = JsTx.spendTxNative({ ... });

Example in the Base app.

Wallet flavor missing function

Contracts app, and any other app initialised with Wallet flavor import Wallet from '@aeternity/aepp-sdk/es/ae/wallet.js' and/or Wallet.compose(Contract)({ should have the balance function

Expected Behavior

this.client.balance(accountPub).then(balance to work

Current Behavior

this.client.balance(accountPub).then(balance returns balance is not a function

Possible Solution

move balance back to Wallet...why was that moved in the first place?

Steps to Reproduce

  1. clone app-contracts vue app
  2. checkout branch feature/1.0.0-next
  3. launch yarn start:dev
  4. set "edgenet" as network (from the GUI)

Review of current master state (5f0e8ce)

This is a review of the Code in 5f0e8ce (since it's to late to create a PR now).

General Nitpicks:

  • Currently you're using axios to implement your HTTP interface. On the browser side there is a new standard API for HTTP requests called fetch. I think it would be nice to use that module instead, then you had one dependency less on the browser side. (Node would still need to install fetch-node)

Specific Nitpicks:

  • As long as the HTTP interface is still unstable I think we should not make any presumptions about it. AFAIK it does not yet support SSL. I propose to remove the "secure" option from the EpochHttpClient for now.

  • EpochHttpClient.post has options.config which are actually the headers of the reqeust. It would be nice if it was named options.headers instead.

  • I think it would be better to allow to let the getCommitmentHash parameter salt to be filled automatically. Developers might use it incorrectly and we can prevent that by calculating a hash for them. Also in the readme you state that you would use a 256bit int as salt, but such a number does not exist in plain JS. Everything is a 64bit float (and you have integer precision up to 32 bits). So maybe you can ask the core team if having a 32bit salt is secure enough.

  • in waitForBlock the timeout is actually the polling Interval. But maybe a timeout would be a good idea as well.

  • it would be nice if made the example.js into the actual test-suite of the thing.

Final Note:

Your code is nice and tidy and easy to understand. I like it. What's especially interesting is that it shows some inconsistencies in the API that we should collect on Thursday.

E.g. the naming of the parameters changes from salt to name_salt. There are multiple inconsistencies like this and your code shows them as you stay consistent.

Also, what I too had to work-around, was the double JSON-encoded pointers which is a bit ugly on the API side.

Separate into smaller projects, Mnemonic / Derivation / Vault / SDK

PR #41 would introduce Add HD wallet functionality to the aepp-sdk-js.
The problem mentioned by @muxe in the comments, is that the dependencies for that are quite heavy and will bloat the sdk.
Most applications will probably not deal wich mnemonic generation and PK derivation. After consultation with @e-user and @muxe we figured it would be best to separate the mnemonic code into a new project.

Maybe it even makes sense to separate it into even smaller projects to ensure applications can maintain a reasonable size by shipping only the required parts.

aepp-skd-js

  • smart wrapper for the epoch api
  • forward signing requests when used in an aepp
  • receive signing request when used in a wallet
  • convenience functions (hashing, decoding, validation, ect. ..)
  • state channel related protocols

aepp-mnemonic-js

  • a la BIP39
  • generate mnemonics
  • derive private master key
  • includes wordlists in several languages (size!)

aepp-hdderivation-js

  • a la BIP44

aepp-vault-js

  • secure on device storage of encrypted private keys
  • secure on device storage of personal data?

Howto: Reading state at height - a brief summary

This is a brief summary on how to implement reading state at height in the SDK. This allows to "read data from past blocks", more precisely: Execute static functions based on the states at previous block heights. Of course, this applies only to non-state-changing functions, e.g. no transactions involved here.

  1. Look at the dry-run API, it takes a block hash.
  2. Let people provide a block number as an optional parameter of the function call.
  3. Use that block number to look up the corresponding block hash
  4. With all that information, perform dry-run.

If that fails, because the required data didn't exist at that blockheight, return a meaningful error response that can be evaluated by a script and is human-readable

This is a wonderful thing to e.g. audit smart contracts: Who was the admin at time foo, who was the auction leader at point bar ?

Use native fetch instead of high level Axios

@devsnd recommended to use the native fetch in place of the more high level axios.

The server side would then have to depend on the node-fetch package, but its expected that the packaged version is much smaller without axios, so I think it's a good idea to follow

Add wallet functionality

As an SDK user (developer or end-user) I want to be able to import a wallet to be able to sign a transaction and set myself as the sender of certain transactions (accounts.getPublicKey would be deprecated then)

npm install issue

gyp ERR! build error
gyp ERR! stack Error: not found: make
gyp ERR! stack at getNotFoundError (/usr/lib/node_modules/npm/node_modules/which/which.js:13:12)
gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:68:19)
gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/isexe/index.js:42:5
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:154:21)
gyp ERR! System Linux 4.18.0-15-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/user/Documents/aeTest/node_modules/argon2
gyp ERR! node -v v10.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN The package nodemon is included as both a dev and production dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2019-03-01T15_34_52_058Z-debug.log

Transpiled SDK is broken in @vue/cli

Similar to #197

Expected Behavior

To don't throw the exception as if transpilation disabled.

Current Behavior

Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

Possible Solution

#196

Steps to Reproduce

  • create new @vue/cli project
  • add to main.js:
import * as SDK from '@aeternity/aepp-sdk/es'
console.log(SDK)
  • fill vue.config.js with
module.exports = {
  transpileDependencies: ['@aeternity/aepp-sdk'],
};
  • run development server by npm run serve

Versions

Nodejs version: v10.15.1
NPM version: 6.8.0
aepp-sdk-js version: 2.1.1-0.1.0-next

Detailed Description

Build log:

$ npm run serve

> [email protected] serve /home/denis/temp/app-flat-map
> vue-cli-service serve

 INFO  Starting development server...
 98% after emitting CopyPlugin                                                    

 WARNING  Compiled with 8 warnings                                                                                    1:16:21 PM

 warning  in ./node_modules/@aeternity/aepp-sdk/es/utils/crypto.js

"export 'default' (imported as 'nacl') was not found in 'tweetnacl'

 warning  in ./node_modules/@aeternity/aepp-sdk/es/utils/crypto.js

"export 'default' (imported as 'nacl') was not found in 'tweetnacl'

 warning  in ./node_modules/@aeternity/aepp-sdk/es/utils/crypto.js

"export 'default' (imported as 'nacl') was not found in 'tweetnacl'

 warning  in ./node_modules/@aeternity/aepp-sdk/es/utils/crypto.js

"export 'default' (imported as 'nacl') was not found in 'tweetnacl'

 warning  in ./node_modules/@aeternity/aepp-sdk/es/utils/hd-wallet.js

"export 'default' (imported as 'nacl') was not found in 'tweetnacl'

 warning  in ./node_modules/@aeternity/aepp-sdk/es/utils/hd-wallet.js

"export 'generateMnemonic' (imported as 'genMnemonic') was not found in '@aeternity/bip39'

 warning  in ./node_modules/@aeternity/aepp-sdk/es/utils/hd-wallet.js

"export 'mnemonicToSeed' was not found in '@aeternity/bip39'

 warning  in ./node_modules/@aeternity/aepp-sdk/es/utils/hd-wallet.js

"export 'validateMnemonic' was not found in '@aeternity/bip39'
                                                                                                                                
  App running at:
  - Local:   http://localhost:8081/ 
  - Network: http://192.168.1.41:8081/

  Note that the development build is not optimized.
  To create a production build, run npm run build.

Runtime log:

Navigated to http://localhost:8081/
log.js:24 [HMR] Waiting for update signal from WDS...
index.js:137 Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
    at Module.eval (index.js:137)
    at eval (index.js:149)
    at Module../node_modules/@aeternity/aepp-sdk/node_modules/@aeternity/bip39/index.js (app.js:1248)
    at __webpack_require__ (app.js:724)
    at fn (app.js:101)
    at Module.eval (hd-wallet.js:25)
    at eval (hd-wallet.js:135)
    at Module../node_modules/@aeternity/aepp-sdk/es/utils/hd-wallet.js (app.js:1212)
    at __webpack_require__ (app.js:724)
    at fn (app.js:101)
vue.runtime.esm.js:8363 You are running Vue in development mode.
Make sure to turn on production mode when deploying for production.
See more tips at https://vuejs.org/guide/deployment.html

Keypair generation

The SDK needs two features for private/public key pair generation:

Input:

- 12 word mnemonic + derivation path (we have one) (optional, default should be first one)
A standard thing among various protocols which should be supported

- arbitrary entropy (+derivation path)
This is important for use cases, where e.g. some device / oracle / data source returns data which you want to use to (deterministically re)create accounts and sign transactions or data. Sometimes you also want to be able to recreate a set of accounts among various development environments easily, e.g. by providing "asdf" as entropy. There has to be a way to use derivation paths here, too, probably by agreeing on how to go from random entropy + path => mnemonic + path = accounts

Output: Raw, unencrypted private key / address combination or contents of a keyfile (probably both as JSON? Don't remember the keyfile layout right now)
Fee free to assign further people. Thanks guys !

urlparser.resolve breaks path when it comes to test-api

@e-user

The problem that i'm having is that when i'm defining an absolute path, the library gets only the hostname of the API endpoint and the relative parameters.

Example: https://test-net-api.aepps.com/api/v2/ -> https://test-net-api.aepps.com/

And is using custom strings within the library to check for version and swager, and the entire library becomes unusable.

screen shot 2018-06-09 at 17 10 38

How I can configure Axios instance that swagger uses?

For example, I want to make HTTP requests more durable by enabling reconnection on failure and by changing the requests timeout:

import * as rax from 'retry-axios'

axios.defaults.timeout = 10000
axios.defaults.raxConfig = {
  retry: 5,
  noResponseRetries: 5
}
rax.attach()

I can't find a way to make such adjustments on the aepp side, it works only in utils/swagger.js file of SDK.

remove BN.js

This is not mandatory, but would improve bundle size:

Expected Behavior

have only 1 bignumber library

Current Behavior

BN.js is used and bignumber.js is a dependency of JSONbig

Possible Solution

Look at this PR.

It would be great if we could get rid of BN.js in favor of bignumber.js, since it's only used in es/utils/bytes.js, for the toBytes, but this adds about ~30Kb to the bundle.

example seems deprecated

Seems like this is not valid anymore in the current version of the aepp-sdk

const {AeternityClient, Crypto} = require('../dist/aepp-sdk.js')
const {HttpProvider} = AeternityClient.providers
const wallet = {
priv: process.env['WALLET_PRIV'],
pub: process.env['WALLET_PUB']
}
function spend (receiver, amount, {host}) {
const node = url.parse(host)
const client = new AeternityClient(new HttpProvider(node.hostname, node.port, {secured: node.protocol === 'https:'}))
client.base.spend(receiver, parseInt(amount), wallet).then(({tx_hash}) => {
console.log(`Waiting for ${tx_hash} to be mined...`)
return client.tx.waitForTransaction(tx_hash)
})
}

Import keys from aepp-python-sdk

Description

Importing a key from aepp-python-sdk which is version 3 does not work with aepp-sdk-js

Expected Behavior

Keys should be interchangeable to some degree, or cross exportable.

Current Behavior

Currently keys in python are 32bytes and in javascript are 64bytes, also the wallet file is incompatible between versions

Possible Solution

add support for 32 byte private keys or for v3 wallet files?

Steps to Reproduce

Get a string of 32bytes and use it as a key in the aecli.js
Copy a wallet from a python-sdk and try using it in the aecli.js

Environment / Context

Client side

NOTE: this may need to be moved, but since the aecli.js is still part of this package in the version available i wrote it here.

Version 0.24.0-0.2.0 Breaks aepp-blockchain-explorer

aepp-blockchain-explorer works with 0.24.0-0.1.0 if you edit epoch to return version 0.25.0 instead of 0.24.0

but using version 0.24.0-0.2.0 returns this:
Uncaught (in promise) Error: Method PostKeyBlock is unsupported. No interface for ["internal", "chain"]

Maybe that thrown error needs to be trapped by the aepp-blockchain-explorer? I am creating this here because I don't know if it should be here or on aepp-blockchain-explorer

aeternity/aepp-blockchain-explorer#84

Remove docker image after CI tests

Issue tracker is ONLY used for reporting bugs. NO NEW FEATURE ACCEPTED! Use stackoverflow for supporting issues.

Expected Behavior

Remove docker image used for testing

Current Behavior

Docker image used for testing doesn't get removed

Solution

screenshot 2018-12-11 at 12 44 29

enrich api for `ContractCreateTx`, include contract address

Issue tracker is ONLY used for reporting bugs. NO NEW FEATURE ACCEPTED! Use stackoverflow for supporting issues.

^ ok, and where are feature requests suppose to go?

When requesting ContractCreateTx data from chain there is no contract address.

Expected Behavior

get contract address in ContractCreateTx

Current Behavior

contract address is not available

Possible Solution

SDK computes contract address and enriches return data

Steps to Reproduce

  1. const transaction = await epoch.api.getTransactionByHash(hash)

Environment / Context

aepp sdk 1.0.1

Epoch Version

"version" : "1.0.1",

Remove unnecessary step when passing addresses during deployment

As seen in the example here, aeternity addresses need to be manually converted to hex when using them as a deployment parameter.

It would take away confusion, reduce errors and be much more intuitive to the user if we could use our own address format. This should be easily doable by including aecli's decode func in the SDK (if it's not there yet anyway).

Thank you for your consideration :)

SyntaxError of Unexpected identifier

I'm getting SyntaxError of Unexpected identifier while trying to import Ae. Could you kindly assist me with this.

My app.js file contains the line of code below
-- import Ae from '@aeternity/aepp-sdk/es/ae/universal'

Error is as follows (unexpected identifier is "Ae")

import Ae from '@aeternity/aepp-sdk/es/ae/universal' // or any other flavor
SyntaxError: Unexpected identifier
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)

Uncaught (in promise) TypeError: Assignment to constant variable. in swagger.js:241

This error occurs int the current version of the aepp-blockchain-explorer (https://sdk-testnet-explorer.aepps.com/#/) "@aeternity/aepp-sdk": "0.18.0-0.1.1" current sdk-testnet node is version 0.19

swagger.js:241 Uncaught (in promise) TypeError: Assignment to constant variable.
    at s.v (swagger.js:241)
    at memoizeWith.js:39
    at _arity.js:22
    at s.K.s.u (swagger.js:450)
    at t.f (mapObjIndexed.js:28)
    at t.@@transducer/step (_xwrap.js:12)
    at _reduce.js:9
    at I (_reduce.js:43)
    at mapObjIndexed.js:27
    at Object.e (_curry2.js:26)

Simplify package installation and usage

Wait, it just means import and export – not other future JavaScript features?
Yes. If you're using things like arrow functions and classes (or more exotic features like decorators and object spread), you should transpile them if you want your library to work in environments that don't support those features. Otherwise, whoever uses your library will have to transpile it themselves, including configuring their transpiler to handle your code, which might involve esoteric transforms and conflicting versions of Babel.
It's a frequent source of frustration. Be a responsible library author and ship code that actually runs in the environments you support!

https://github.com/rollup/rollup/wiki/pkg.module#wait-it-just-means-import-and-export--not-other-future-javascript-features

This article says that tree-shakable code can be delivered in a way that doesn't ask a user to make any additional setup on his side. As I see it is true because all packages that I'm using doesn't require additional setup except JS SDK.

Expected Behavior

import <...> from '@aeternity/aepp-sdk';
// tree-shakable, without changes in Webpack configs

Current Behavior

import <...> from '@aeternity/aepp-sdk/es';

, required changes in Webpack configs

Possible Solution

Transpile all es6 features except import/export

Possible Implementation

#117

Vue can't import the keystore file in use Javascript SDK

When I load the keystore file from javascript SDK, it got error:

bindings.js?dfc1:17 Uncaught TypeError: Cannot read property 'node' of undefined
at Object.eval (bindings.js?dfc1:17)
at eval (bindings.js:176)
at Object../node_modules/bindings/bindings.js (app.js:2793)
at webpack_require (app.js:725)
at fn (app.js:102)
at Object.eval (argon2.js?a5a5:3)
at eval (argon2.js:125)
at Object../node_modules/argon2/argon2.js (app.js:1916)
at webpack_require (app.js:725)
at fn (app.js:102)

Expected Behavior

I view the code in bindings.js, it has slice of code :

  , arch: process.arch
  , version: process.versions.node   // error occur here
  , bindings: 'bindings.node'

keystore needs argon2 , argon2 needs bindings , Is bindings can't work in Vue ?

Current Behavior

import { dump, getAddressFromPriv, recover } from '@aeternity/aepp-sdk/es/utils/keystore'

This work well in aepp-cli-js . Can't work in vue .

Possible Solution

Steps to Reproduce

Environment / Context

Epoch Version

Detailed Description

Possible Implementation

get tx hash after contract deploy

There are cases where I want to have the tx hash of the deploy transaction. especially with waitMined: false

currently only the contract address is returned

tx spend says 'Transaction Hash' but it actually prints out a transaction

Expected Behavior

The name label should indicate that this is actually an unsigned transaction, not a transaction hash.

Current Behavior

shinichi@ilya:~/source/aeternity aecli-js -u http://localhost:3003 tx spend $SENDER $RECP 10
Transaction Hash________________________ tx_+E0MAaEBzqet5HDJ+Z2dTkAIgKhvHUm7REti8Rqeu2S7z+tz/vOhAR8To7CL8AFABmKmi2nYdfeAPOxMCGR/btXYTHiXvVCjCoJBKAABgMzYKAE=

Possible Solution

Should follow the section in the CLI interface standard HackMD

Steps to Reproduce

shinichi@ilya:~/source/aeternity aecli-js -u http://localhost:3003 tx spend $SENDER $RECP 10
Transaction Hash________________________ tx_+E0MAaEBzqet5HDJ+Z2dTkAIgKhvHUm7REti8Rqeu2S7z+tz/vOhAR8To7CL8AFABmKmi2nYdfeAPOxMCGR/btXYTHiXvVCjCoJBKAABgMzYKAE=

Environment / Context

Epoch Version

Detailed Description

Possible Implementation

Bignumber and `client.balance`

Expected Behavior

calling client.balance should return a string (not a bignumber)

Current Behavior

calling client.balance returns 0

Possible Solution

This change to the SDK parseBigNumber function, solves the issue:

export function parseBigNumber (number) {
  return new BN(number).toString(10)
}
export function parseBigNumber (number) {
  return number.toString(10)
}

...but I'm not sure if we are always, receiving a number as bignumber. (like in this case)

Steps to Reproduce

  1. give to ak_6A2vcm1Sz6aqJezkLCssUXcyZTX7X8D5UwbuS2fRJr9KkYpRU A LOT of AE tokens
  2. run the aepp-contract (release 0.25.0-0.1.1) and check the balance number read from the client.balance SDK function (in epoch/index.js)

Environment / Context

aepp-contract

Epoch Version

SDK 0.25.0-0.1.1

docs: Use the proper name of the encoding algorithm

In aepp sdk documentation in several places mentioned that transactions/addresses are encoded using base58 that is a bit confusing because actually there using base58chech which is different from base58 in that at the end of payload added 4 bytes of checksum.

For a long time, I was thinking that there are used plain base58 and I understood the difference only when we tried to implement address generation for Ledger wallet.

Ability to check if Epoch address is valid

Hi there!

I have several places where it is necessary to check that entered Epoch address is valid. Seems that SDK API doesn't contain something similar and I had to write:

isRecipientValid: (recipient) => {
  let isValid
  try {
    isValid = recipient.slice(0, 3) === 'ak_' &&
      Crypto.decodeBase58Check(recipient.slice(3)).length === 32
  } catch (e) {
    isValid = false
  }
  return isValid
},

Will be better to move this utility function into SDK.

Transpiled SDK is broken in @vue/cli

As I understand from this PR, the only adding of SDK package to list of sources for transpilation by babel-loader are necessary to use it, but actually, transpiled code throws the exception in default setup of @vue/cli project.

Expected Behavior

To don't throw the exception as if transpilation disabled.

Current Behavior

traverseKeys function of swagger.js throws expection:

VM2850 swagger.js:369 Uncaught (in promise) TypeError: While calling getStatus (), Object(...) is not a function
    at eval (VM2850 swagger.js:369)
    at Array.map (<anonymous>)
    at Object (VM2850 swagger.js:368)
    at eval (VM2850 swagger.js:380)
    at eval (VM2489 _curryN.js:38)
    at eval (VM2488 _arity.js:16)
    at snakizeKeys (VM2850 swagger.js:392)
    at Object._callee$ (VM2850 swagger.js:532)
    at tryCatch (VM2277 runtime.js:62)
    at Generator.invoke [as _invoke] (VM2277 runtime.js:288)

Possible Solution

Transpile SDK before publishing to npm (#196), or write a guide how to use SDK with @vue/cli.

Steps to Reproduce

$ npm i @vue/cli -g
$ vue create test-app
# chose default settings
$ cd test-app
$ npm i @aeternity/[email protected]

create vue.config.js containing:

module.exports = {
  transpileDependencies: ['@aeternity/aepp-sdk'],
};

add to src/main.js:

import { EpochChain } from '@aeternity/aepp-sdk/es'
const url = 'https://sdk-testnet.aepps.com'
EpochChain({ url, internalUrl: url })
$ npm run serve

then open developer console, exception should be raised

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.