Skip to content

Commit

Permalink
Rename nknWalletSDK to nknWallet
Browse files Browse the repository at this point in the history
Signed-off-by: Yilun <zyl.skysniper@gmail.com>
  • Loading branch information
yilunzhang committed Aug 16, 2018
1 parent a309c1e commit 3df04c6
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Gruntfile.js
Expand Up @@ -8,7 +8,7 @@ module.exports = function(grunt) {
},
options: {
browserifyOptions: {
standalone: 'nkn-wallet-SDK'
standalone: 'nkn-wallet'
}
}
}
Expand All @@ -31,4 +31,4 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify-es');

grunt.registerTask('dist', ['browserify', 'uglify']);
};
};
24 changes: 12 additions & 12 deletions README.md
Expand Up @@ -16,7 +16,7 @@ npm install nkn-wallet
And then in your code:

```javascript
const nknWalletSDK = require('nkn-wallet');
const nknWallet = require('nkn-wallet');
```

For browser, use `dist/nkn-wallet.js` or `dist/nkn-wallet.min.js`.
Expand All @@ -25,12 +25,12 @@ For browser, use `dist/nkn-wallet.js` or `dist/nkn-wallet.min.js`.

+ import
```javascript
const nknWalletSDK = require('nkn-wallet');
const nknWallet = require('nkn-wallet');
```

+ create a new wallet
```javascript
const wallet = nknWalletSDK.newWallet('pwd')
const wallet = nknWallet.newWallet('pwd')
```

+ get wallet's json string
Expand All @@ -40,12 +40,12 @@ const walletJson = wallet.toJSON()

+ load wallet from a wallet json string
```javascript
const walletFromJson = nknWalletSDK.loadJsonWallet(walletJson, 'pwd')
const walletFromJson = nknWallet.loadJsonWallet(walletJson, 'pwd')
```

+ restore wallet from a private key
```javascript
const walletFromPrivateKey = nknWalletSDK.restoreWalletByPrivateKey('the private key', 'new-wallet-password')
const walletFromPrivateKey = nknWallet.restoreWalletByPrivateKey('the private key', 'new-wallet-password')
```

+ transfer asset to some address
Expand All @@ -72,11 +72,11 @@ Check [examples](examples) for full examples.

NKN wallet only stores some static information such as encrypted private keys,
addresses and so on. All dynamic information needs to be queried from a NKN
node. By default the SDK will try to use RPC server provided by us, but you can
node. By default it will try to use RPC server provided by us, but you can
change it (together with NKN token ID) by calling the global configure function:

```javascript
nknWalletSDK.configure({
nknWallet.configure({
rpcAddr: 'http://127.0.0.1:30003',
})
```
Expand All @@ -86,7 +86,7 @@ configurations will be used.

## API

+ nknWalletSDK
+ nknWallet

```javascript

Expand All @@ -99,7 +99,7 @@ configurations will be used.
*
* @param config | Object
*/
nknWalletSDK.configure(config)
nknWallet.configure(config)
```

```javascript
Expand All @@ -108,7 +108,7 @@ nknWalletSDK.configure(config)
* @param password : string : the password to encrypt wallet
* @returns {NknWallet} : a NknWallet instance
*/
nknWalletSDK.newWallet(password)
nknWallet.newWallet(password)
```

```javascript
Expand All @@ -120,7 +120,7 @@ nknWalletSDK.newWallet(password)
*
* !this method will thow an error if the password is wrong!
*/
nknWalletSDK.loadJsonWallet(walletJson, password)
nknWallet.loadJsonWallet(walletJson, password)
```

```javascript
Expand All @@ -130,7 +130,7 @@ nknWalletSDK.loadJsonWallet(walletJson, password)
* @param password : string : password for new wallet
* @returns {NknWallet} : a NknWallet instance
*/
nknWalletSDK.restoreWalletByPrivateKey(privateKey, password)
nknWallet.restoreWalletByPrivateKey(privateKey, password)
```

+ NknWallet
Expand Down
4 changes: 2 additions & 2 deletions dist/nkn-wallet.js
@@ -1,4 +1,4 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.nknWalletSDK = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.nknWallet = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
'use strict'

let WalletError = function (code, msg) {
Expand Down Expand Up @@ -1061,7 +1061,7 @@ module.exports = {
'use strict'

let baseInfo = function () {
return {"jsonrpc":"2.0", "id":"nkn-wallet-sdk"}
return {"jsonrpc":"2.0", "id":"nkn-wallet"}
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion dist/nkn-wallet.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/nkn-wallet.min.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions examples/node_example.js
@@ -1,21 +1,21 @@
const nknWalletSDK = require('../lib/wallet');
const nknWallet = require('../lib/wallet');

// Uncomment this if you want to use customized rpc node
// nknWalletSDK.configure({
// nknWallet.configure({
// rpcAddr: 'http://127.0.0.1:30003'
// })

// Create a new wallet
const wallet = nknWalletSDK.newWallet('pwd')
const wallet = nknWallet.newWallet('pwd')

// Get wallet's json string
const walletJson = wallet.toJSON()

// Load wallet from a wallet json string
const walletFromJson = nknWalletSDK.loadJsonWallet(walletJson, 'pwd')
const walletFromJson = nknWallet.loadJsonWallet(walletJson, 'pwd')

// Restore wallet from a private key
const walletFromPrivateKey = nknWalletSDK.restoreWalletByPrivateKey('the private key', 'new-wallet-password')
const walletFromPrivateKey = nknWallet.restoreWalletByPrivateKey('the private key', 'new-wallet-password')

// Query asset balance for this wallet
wallet.queryAssetBalance().then(function(value) {
Expand Down
2 changes: 1 addition & 1 deletion lib/network/serverApi.js
@@ -1,7 +1,7 @@
'use strict'

let baseInfo = function () {
return {"jsonrpc":"2.0", "id":"nkn-wallet-sdk"}
return {"jsonrpc":"2.0", "id":"nkn-wallet"}
}

module.exports = {
Expand Down

0 comments on commit 3df04c6

Please sign in to comment.