Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# いろはjs (irohajs)

[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

## What's いろは(iroha)?
いろは(iroha) is [this](https://github.com/soramitsu/iroha).

Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
}
},
"devDependencies": {
"@types/jest": "^18.1.1",
"@types/jest": "^19.2.2",
"@types/node": "^7.0.2",
"@types/webpack": "^2.2.7",
"awesome-typescript-loader": "^3.1.0",
Expand All @@ -89,13 +89,15 @@
"coveralls": "^2.11.15",
"cz-conventional-changelog": "^2.0.0",
"husky": "^0.13.1",
"jasmine": "^2.5.3",
"jest": "^19.0.2",
"lodash": "^4.17.4",
"prompt": "^1.0.0",
"replace-in-file": "^2.3.2",
"rimraf": "^2.5.4",
"semantic-release": "^6.3.2",
"ts-jest": "^19.0.0",
"standard-version": "^4.0.0",
"ts-jest": "^19.0.8",
"ts-node": "^2.0.0",
"tslint": "^4.3.1",
"tslint-config-standard": "^4.0.0",
Expand All @@ -106,7 +108,10 @@
"webpack": "^2.2.0"
},
"dependencies": {
"axios": "^0.15.3",
"grpc": "^1.2.0",
"js-sha3": "^0.5.7",
"moment": "^2.18.1",
"supercop.js": "^2.0.1"
}
}
180 changes: 180 additions & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/**
* ITransactionRepositoryService
*/
export interface ITransactionRepositoryService {
find: (query: Query, cb: (error: any, response: TransactionResponse) => any) => any;
fetch: (query: Query, cb: (error: any, response: TransactionResponse) => any) => any;
fetchStream: (transaction: Transaction, cb: (error: any, response: StatusResponse) => any) => any;
}

/**
* IAssetRepositoryService
*/
export interface IAssetRepositoryService {
find: (query: Query, cb: (error: any, response: AssetResponse) => any) => any;
}

/**
* SumeragiService
*/
export interface ISumeragiService {
torii: (transaction: Transaction, cb: (error: any, response: StatusResponse) => any) => any;
verify: (consensusEvent: ConsensusEvent, cb: (error: any, response: StatusResponse) => any) => any;
kagami: (query: Query, cb: (error: any, response: StatusResponse) => any) => any;
}

/**
* IzanamiService
*/
export interface IIzanamiService {
izanagi: (transactionRespose: TransactionResponse, cb: (error: any, response: StatusResponse) => any) => any;
}

/**
* TransactionResponse
*/
export class TransactionResponse {
message: string;
code: number;
transaction: Array<Transaction>;
}

/**
* RecieverConfirmation
*/
export class RecieverConfirmation {
hash: string;
signature: Signature;
}

/**
* AssetResponse
*/
export class AssetResponse {
message: string;
code: number;
timestamp: number;
asset: Asset;
simpleAsset: SimpleAsset;
domain: Domain;
account: Account;
peer: Peer;
}

/**
* StatusResponse
*/
export class StatusResponse {
value: string;
message: string;
timestamp: number;
confirm: RecieverConfirmation;
}

/**
* Query
*/
export class Query {
type: string;
value: Map<string, BaseObject>;
senderPubkey: string;
}

/**
* BaseObject
*/
export class BaseObject {
valueString?: string;
valueInt?: number;
valueDouble?: number;
valueBoolean?: boolean;
}

/**
* SimpleAsset
*/
export class SimpleAsset {
domain: string;
name: string;
value: BaseObject;
smartContractName: string;
}

/**
* Asset
*/
export class Asset {
domain: string;
name: string;
value: Map<string, BaseObject>;
smartContractName: string;
}

/**
* Domain
*/
export class Domain {
ownerPublicKey: string;
name: string;
}

/**
* Account
*/
export class Account {
publicKey: string;
name: string;
assets: Array<string>;
}

/**
* ITrust
*/
export class Trust {
value: number;
isOk: boolean;
}

/**
* Peer
*/
export class Peer {
publicKey: string;
address: string;
trust: Trust;
}

/**
* Signature
*/
export class Signature {
publicKey: string;
signature: string;
}

/**
* Transaction
*/
export class Transaction {
txSignatures: Array<Signature>;
type: string;
senderPubkey: string;
hash: string;
timestamp: number;
asset: Asset;
simpleAsset: SimpleAsset;
domain: Domain;
account: Account;
peer: Peer;
receivePubkey: string;
}

/**
* ConsensusEvent
*/
export class ConsensusEvent {
eventSignatures: Array<Signature>;
transaction: Transaction;
order: number;
status: string;
}
22 changes: 22 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export const grpc = require("grpc");

import { ITransactionRepositoryService, IAssetRepositoryService, IIzanamiService, ISumeragiService } from "./api";

export interface GrpcService<T> {
new(...args: any[]) : T;
}

export interface IIroha {
TransactionRepository: GrpcService<ITransactionRepositoryService>;
AssetRepository: GrpcService<IAssetRepositoryService>;
Izanami: GrpcService<IIzanamiService>;
Sumeragi: GrpcService<ISumeragiService>;
}

export interface IApi {
Api: IIroha;
}

// const proto: IApi = grpc.load("src/protos/api.proto");
// export const api = proto.Api;
// const stub = new client.Izanami("0.0.0.0:8888", grpc.credentials.createInsecure());
35 changes: 35 additions & 0 deletions src/flatbuff/account.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
include "key.fbs";
include "primitives.fbs";
include "asset.fbs";

namespace iroha;


table Account {
pubKey: PublicKey (required); // primary key for account
alias: string;

// for m-n multisignature scheme
// signatories.size() = n, useKeys = m
signatories: [PublicKey];
useKeys: ushort = 1;
}


// message represents custom user data, related to account. User is able to store blobs in his account and access it by key.
// e.g.,
//{
// accPubKey: "account1",
// data: {
// key: "email",
// value: "bogdan@soramitsu.co.jp"
// }
//}
table Message {
accPubKey: PublicKey (required);

// values can be accessed by key for O(log(n)). Look at "Storing maps" section in flatbuffers docs
data: [KeyValueObject];
}

root_type Account;
44 changes: 44 additions & 0 deletions src/flatbuff/asset.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
include "primitives.fbs";

namespace iroha;

table ComplexAsset {
// (ledger:domain:asset) = composite primary key for any asset
asset_name: string (key, required); // sorted; name should be unique inside a domain
domain_name: string (required); // domain should be unique inside a ledger
ledger_name: string (required); // unique worldwide

description: string;

// amount and precision should be encoded in properties
prop: [KeyValueObject]; // using this, you can create complex assets

logic: AssetLogic;
}

table AssetLogic {
add: Chaincode;
remove: Chaincode;
transfer: Chaincode;
}


// currency is a simple asset, like USD.
table Currency {
currency_name: string (required, key);
domain_name: string (required);
ledger_name: string (required);

description: string;

amount: ulong;
precision: ulong;
}

union AnyAsset { ComplexAsset, Currency }

table Asset {
asset: AnyAsset;
}

root_type Asset;
Loading