Skip to content

Commit

Permalink
Add more auto imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Warta committed Jul 19, 2018
1 parent 5328d67 commit ccd7c5d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
11 changes: 1 addition & 10 deletions packages/iov-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ How to use the web4 cli
3. Play around like in the following example code:

```
> const { Ed25519SimpleAddressKeyringEntry, Keyring, UserProfile } = require("@iov/keycontrol")
> const profile = new UserProfile();
> profile.addEntry(Ed25519SimpleAddressKeyringEntry.fromMnemonic("melt wisdom mesh wash item catalog talk enjoy gaze hat brush wash"))
Expand Down Expand Up @@ -36,12 +35,7 @@ How to use the web4 cli
[ { pubkey: { algo: 'ed25519', data: [Object] },
label: 'the first one' } ]
> import { Nonce } from "@iov/types";
> import Long = require("long")
> const nonce = new Long(0x11223344, 0x55667788) as Nonce;
> .editor
import { AddressBytes, ChainId, SendTx, TokenTicker, TransactionKind } from "@iov/types";
const sendTx: SendTx = {
kind: TransactionKind.SEND,
chainId: "aabb" as ChainId,
Expand All @@ -55,8 +49,7 @@ const sendTx: SendTx = {
},
};
^D
> import { bnsCodec } from "@iov/bns";
> const nonce = new Long(0x11223344, 0x55667788) as Nonce;
> profile.signTransaction(0, mainIdentity, sendTx, bnsCodec, nonce).then(signed => console.log(signed))
```

Expand Down Expand Up @@ -92,8 +85,6 @@ const sendTx: SendTx = {
6. Now store to disk

```
> const leveldown = require('leveldown')
> const levelup = require('levelup')
> const db = levelup(leveldown('./my_userprofile_db'))
> profile.storeIn(db, "secret passwd")
```
Expand Down
28 changes: 23 additions & 5 deletions packages/iov-cli/init
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
import colors = require('colors/safe');
const leveldown = require('leveldown')
const levelup = require('levelup')
import Long from "long";
import { bnsCodec } from "@iov/bns";
import { Encoding } from '@iov/encoding';
import { Ed25519SimpleAddressKeyringEntry, UserProfile } from '@iov/keycontrol';
import { AddressBytes, ChainId, Nonce, SendTx, TokenTicker, TransactionKind } from "@iov/types";
console.log(colors.green('Done initializing session for you. Have fun!'));
console.log(colors.yellow('Available imports:'));
console.log(colors.yellow(' from @iov/encoding'));
console.log(colors.yellow(' - Encoding'));
console.log(colors.yellow(' from @iov/keycontrol'));
console.log(colors.yellow(' - Ed25519SimpleAddressKeyringEntry'));
console.log(colors.yellow(' - UserProfile'));
console.log(colors.yellow(' * leveldown'));
console.log(colors.yellow(' * levelup'));
console.log(colors.yellow(' * from long'));
console.log(colors.yellow(' - Long'));
console.log(colors.yellow(' * from @iov/bns'));
console.log(colors.yellow(' - bnsCodec'));
console.log(colors.yellow(' * from @iov/encoding'));
console.log(colors.yellow(' - Encoding'));
console.log(colors.yellow(' * from @iov/keycontrol'));
console.log(colors.yellow(' - Ed25519SimpleAddressKeyringEntry'));
console.log(colors.yellow(' - UserProfile'));
console.log(colors.yellow(' * from @iov/types'));
console.log(colors.yellow(' - AddressBytes'));
console.log(colors.yellow(' - ChainId'));
console.log(colors.yellow(' - Nonce'));
console.log(colors.yellow(' - SendTx'));
console.log(colors.yellow(' - TokenTicker'));
console.log(colors.yellow(' - TransactionKind'));

0 comments on commit ccd7c5d

Please sign in to comment.