@zilliqa-js/blockchain
Advanced tools
Comparing version 0.2.0 to 0.2.1-next.20181112
import { Transaction, Wallet } from '@zilliqa-js/account'; | ||
import { Provider, ZilliqaModule, RPCResponse } from '@zilliqa-js/core'; | ||
import { DsBlockObj, BlockList, TxBlockObj, TxList, ShardingStructure } from './types'; | ||
export default class Blockchain implements ZilliqaModule { | ||
export declare class Blockchain implements ZilliqaModule { | ||
signer: Wallet; | ||
@@ -91,3 +91,4 @@ provider: Provider; | ||
getTxBlockRate(): Promise<RPCResponse<number, string>>; | ||
/** getTxBlockListing | ||
/** | ||
* getTxBlockListing | ||
* | ||
@@ -94,0 +95,0 @@ * Get a paginated list of Transaction blocks. Takes a page number as |
@@ -73,3 +73,3 @@ "use strict"; | ||
Blockchain.prototype.getDSBlockListing = function (max) { | ||
return this.provider.send("DSBlockListing" /* DSBlockListing */); | ||
return this.provider.send("DSBlockListing" /* DSBlockListing */, max); | ||
}; | ||
@@ -117,3 +117,4 @@ /** | ||
}; | ||
/** getTxBlockListing | ||
/** | ||
* getTxBlockListing | ||
* | ||
@@ -278,3 +279,3 @@ * Get a paginated list of Transaction blocks. Takes a page number as | ||
}()); | ||
exports.default = Blockchain; | ||
exports.Blockchain = Blockchain; | ||
//# sourceMappingURL=chain.js.map |
@@ -1,3 +0,3 @@ | ||
export { default as Blockchain } from './chain'; | ||
export { default as Network } from './network'; | ||
export { Blockchain } from './chain'; | ||
export { Network } from './network'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var chain_1 = require("./chain"); | ||
exports.Blockchain = chain_1.default; | ||
exports.Blockchain = chain_1.Blockchain; | ||
var network_1 = require("./network"); | ||
exports.Network = network_1.default; | ||
exports.Network = network_1.Network; | ||
//# sourceMappingURL=index.js.map |
import { Provider, ZilliqaModule } from '@zilliqa-js/core'; | ||
import { Wallet } from '@zilliqa-js/account'; | ||
export default class Network implements ZilliqaModule { | ||
export declare class Network implements ZilliqaModule { | ||
provider: Provider; | ||
@@ -5,0 +5,0 @@ signer: Wallet; |
@@ -19,3 +19,3 @@ "use strict"; | ||
}()); | ||
exports.default = Network; | ||
exports.Network = Network; | ||
//# sourceMappingURL=network.js.map |
{ | ||
"name": "@zilliqa-js/blockchain", | ||
"version": "0.2.0", | ||
"version": "0.2.1-next.20181112", | ||
"description": "Class(es) for interacting with the Zilliqa blockchain.", | ||
"main": "dist/index.js", | ||
"node": "dist/index.js", | ||
"main": "dist/index.umd.js", | ||
"node": "dist/index.umd.js", | ||
"browser": "dist/index.umd.js", | ||
@@ -22,7 +22,7 @@ "module": "dist/index.esm.js", | ||
"dependencies": { | ||
"@zilliqa-js/account": "^0.2.0", | ||
"@zilliqa-js/core": "^0.2.0", | ||
"@zilliqa-js/account": "^0.2.1-next.20181112", | ||
"@zilliqa-js/core": "^0.2.1-next.20181112", | ||
"bn.js": "^4.11.8" | ||
}, | ||
"gitHead": "c1a04e0c11848b02233410c7f1e09e00db1efd26" | ||
"gitHead": "51b5325fbe7a8a986931ce089058fb4619cf85d1" | ||
} |
@@ -16,3 +16,2 @@ import { Transaction, Wallet, util } from '@zilliqa-js/account'; | ||
TransactionObj, | ||
TransactionReceiptObj, | ||
ShardingStructure, | ||
@@ -22,3 +21,3 @@ } from './types'; | ||
export default class Blockchain implements ZilliqaModule { | ||
export class Blockchain implements ZilliqaModule { | ||
signer: Wallet; | ||
@@ -101,3 +100,3 @@ provider: Provider; | ||
getDSBlockListing(max: number): Promise<RPCResponse<BlockList, string>> { | ||
return this.provider.send(RPCMethod.DSBlockListing); | ||
return this.provider.send(RPCMethod.DSBlockListing, max); | ||
} | ||
@@ -150,3 +149,4 @@ | ||
/** getTxBlockListing | ||
/** | ||
* getTxBlockListing | ||
* | ||
@@ -153,0 +153,0 @@ * Get a paginated list of Transaction blocks. Takes a page number as |
@@ -1,2 +0,2 @@ | ||
export { default as Blockchain } from './chain'; | ||
export { default as Network } from './network'; | ||
export { Blockchain } from './chain'; | ||
export { Network } from './network'; |
@@ -10,3 +10,3 @@ import { Provider, ZilliqaModule } from '@zilliqa-js/core'; | ||
export default class Network implements ZilliqaModule { | ||
export class Network implements ZilliqaModule { | ||
provider: Provider; | ||
@@ -13,0 +13,0 @@ signer: Wallet; |
@@ -5,4 +5,4 @@ import BN from 'bn.js'; | ||
import Blockchain from '../src/chain'; | ||
import { DsBlockObj, TxBlockObj, BlockList } from '../src/types'; | ||
import { Blockchain } from '../src/chain'; | ||
import { TxBlockObj, BlockList } from '../src/types'; | ||
import schemas from './schema.json'; | ||
@@ -38,7 +38,27 @@ | ||
it('should be able to get a list of DS blocks', async () => { | ||
const response = await bc.getLatestDSBlock(); | ||
const latestBlock = (<DsBlockObj>response.result).header.blockNum; | ||
const responseDsList = await bc.getDSBlockListing(1); | ||
const { result } = await bc.getNumDSBlocks(); | ||
const numDSBlocks = parseInt(<string>result, 10); | ||
expect(responseDsList.result).toMatchSchema(schemas.definitions.BlockList); | ||
if (numDSBlocks > 10) { | ||
const numPages = | ||
numDSBlocks % 10 === 0 | ||
? numDSBlocks / 10 | ||
: (numDSBlocks - (numDSBlocks % 10)) / 10 + 1; | ||
const pages: Array<Promise<RPCResponse<BlockList, string>>> = []; | ||
for (let i = 1; i <= numPages; i++) { | ||
pages.push(bc.getDSBlockListing(i)); | ||
} | ||
const resolved = await Promise.all(pages); | ||
const receivedNumTxBlocks = resolved.reduce((n, list) => { | ||
return n + (<BlockList>list.result).data.length; | ||
}, 0); | ||
expect(resolved.length).toEqual(numPages); | ||
expect(receivedNumTxBlocks).toEqual(numDSBlocks); | ||
} else { | ||
const response = await bc.getDSBlockListing(1); | ||
expect((<BlockList>response.result).data.length).toEqual(numDSBlocks); | ||
} | ||
}); | ||
@@ -45,0 +65,0 @@ |
import BN from 'bn.js'; | ||
import { Transaction, Wallet, TxCreated } from '@zilliqa-js/account'; | ||
import { HTTPProvider, RPCResponseSuccess } from '@zilliqa-js/core'; | ||
import { Transaction, Wallet } from '@zilliqa-js/account'; | ||
import { HTTPProvider } from '@zilliqa-js/core'; | ||
import Blockchain from '../src/chain'; | ||
import { Blockchain } from '../src/chain'; | ||
@@ -8,0 +8,0 @@ import fetch from 'jest-fetch-mock'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
791842
38
8353
1
278