Skip to content

Commit

Permalink
badges
Browse files Browse the repository at this point in the history
  • Loading branch information
thedewpoint committed Jan 19, 2018
1 parent 1bc1c20 commit 52c0650
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@


[![Build Status](https://travis-ci.org/thedewpoint/iotauth.svg?branch=master)](https://travis-ci.org/thedewpoint/iota-basic.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/thedewpoint/iota-basic/badge.svg?branch=master)](https://coveralls.io/github/thedewpoint/iota-basic?branch=master)
[![dependencies Status](https://david-dm.org/thedewpoint/iota-basic/status.svg)](https://david-dm.org/thedewpoint/iota-basic) [![devDependencies Status](https://david-dm.org/thedewpoint/iota-basic/dev-status.svg)](https://david-dm.org/thedewpoint/iota-basic?type=dev)
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
[![NSP Status](https://nodesecurity.io/orgs/iota-basic/projects/3e32075b-34e3-4847-a495-e5d5e70a3022/badge)](https://nodesecurity.io/orgs/iota-basic/projects/3e32075b-34e3-4847-a495-e5d5e70a3022)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fthedewpoint%2Fiota-basic.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fthedewpoint%2Fiota-basic?ref=badge_shield)
[![TypeScript](https://badges.frapsoft.com/typescript/code/typescript.svg?v=101)](https://github.com/ellerbrock/typescript-badges/)

# Iota-basic
in progress
16 changes: 9 additions & 7 deletions __tests__/iota-basic-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as IOTA from 'iota.lib.js';
import { Iota, IIota } from '../src/index';
import { Iota, IIotaBasic } from '../src/index';
import { CurlHash } from '../src/impl/CurlHash';
import { CurlHashWebGl } from '../src/impl/CurlHashWebGl';
import { IAccountData } from '../src/api/AccountData';
Expand Down Expand Up @@ -41,17 +41,17 @@ afterEach(() => {
// jest.resetModules();
});
test('should return a receive address', async () => {
const iota: IIota = new Iota(testSeed, '', iotaClient);
const iota: IIotaBasic = new Iota(testSeed, '', iotaClient);
let receiveAddress: string = await iota.getReceiveAddress();
expect(iotaClient.valid.isAddress(receiveAddress)).toBe(true);
});
test('should return the account balance', async () => {
const iota: IIota = new Iota(testSeed, '', iotaClient);
const iota: IIotaBasic = new Iota(testSeed, '', iotaClient);
let balance: number = await iota.getBalance();
expect(balance).toBe(2);
});
test('should return account data correctly', async () => {
const iota: IIota = new Iota(testSeed, '', iotaClient);
const iota: IIotaBasic = new Iota(testSeed, '', iotaClient);
let accountData: IAccountData = await iota.getAccountData();
expect(accountData.balance).toBe(0);
expect(accountData.latestAddress).toBe(
Expand All @@ -69,10 +69,12 @@ test('use ccurl implementation when applicable', async () => {
expect(ccurlProvider instanceof CurlHash).toBe(true);
expect(ccurlProvider instanceof CurlHashWebGl).toBe(false);
});
test('should generate a valid checksum for a seed', async () => {
const iota = new Iota(testSeed, '', iotaClient);
let checksum = iota.getChecksum();
expect(checksum).toBe('ZUA');
});
test('use webgl2 ccurl implementation when applicable', async () => {
// Object.defineProperty(document, 'createElement', {
// value: (type) =>{{getContext: (type)=>{{}}}},
// });
global.document = {};
global.document.createElement = type => {
return {
Expand Down
5 changes: 5 additions & 0 deletions src/api/AccountData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ export interface IInput {
keyIndex: number;
security: number;
}
export interface ITransaction {
address: string;
value: number;
message: string;
}
3 changes: 2 additions & 1 deletion src/api/IotaBasic.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { IAccountData, ITransfer } from './AccountData';

export interface IIota {
export interface IIotaBasic {
getReceiveAddress(): Promise<string>;
sendTransaction(
receivingAddress: string,
value: number,
pow?: boolean
): Promise<any>;
getChecksum(): string;
getBalance(): Promise<number>;
getAccountData(): Promise<IAccountData>;
}
2 changes: 1 addition & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { IIota } from './IotaBasic';
export { IIotaBasic } from './IotaBasic';
7 changes: 5 additions & 2 deletions src/impl/IotaBasic.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as IOTA from 'iota.lib.js';
import { IAccountData, IInput, IInputs } from '../api/AccountData';
import { ICurlHash } from '../api/CurlHash';
import { IIota } from '../api/IotaBasic';
import { IIotaBasic } from '../api/IotaBasic';
import CurlFactory from './CurlFactory';

export class Iota implements IIota {
export class Iota implements IIotaBasic {
public readonly ccurlProvider: ICurlHash;
private seed: string;
private iota: any;
Expand Down Expand Up @@ -66,4 +66,7 @@ export class Iota implements IIota {
);
});
}
public getChecksum(): string {
return this.iota.utils.addChecksum(this.seed, 3, false).substr(-3);
}
}

0 comments on commit 52c0650

Please sign in to comment.