@harmony-js/core
Advanced tools
Comparing version 0.0.23 to 0.0.24
@@ -16,2 +16,3 @@ import { Messenger, NewPendingTransactions, NewHeaders, LogSub, Syncing } from '@harmony-js/network'; | ||
}): Promise<any>; | ||
getBlockNumber(): Promise<any>; | ||
/** | ||
@@ -18,0 +19,0 @@ * |
@@ -42,2 +42,15 @@ "use strict"; | ||
}; | ||
Blockchain.prototype.getBlockNumber = function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var result; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.messenger.send("hmy_blockNumber" /* BlockNumber */, [], this.chainPrefix)]; | ||
case 1: | ||
result = _a.sent(); | ||
return [2 /*return*/, this.getRpcResult(result)]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
@@ -44,0 +57,0 @@ * |
@@ -7,2 +7,3 @@ import * as utils from '@harmony-js/utils'; | ||
import { Blockchain } from './blockchain'; | ||
import { HarmonyConfig } from './util'; | ||
export declare class Harmony extends utils.HarmonyCore { | ||
@@ -28,8 +29,6 @@ Modules: { | ||
private provider; | ||
constructor(url: string | undefined, { chainType, chainId, }: { | ||
chainType: utils.ChainType; | ||
chainId: utils.ChainID; | ||
}); | ||
constructor(url?: string, config?: HarmonyConfig); | ||
setProvider(provider: string | HttpProvider | WSProvider): void; | ||
private onInitSetProvider; | ||
} | ||
//# sourceMappingURL=harmony.d.ts.map |
@@ -14,6 +14,10 @@ "use strict"; | ||
tslib_1.__extends(Harmony, _super); | ||
function Harmony(url, _a) { | ||
function Harmony(url, config) { | ||
if (url === void 0) { url = defaultUrl; } | ||
var _b = _a.chainType, chainType = _b === void 0 ? "hmy" /* Harmony */ : _b, _c = _a.chainId, chainId = _c === void 0 ? 0 /* Default */ : _c; | ||
var _this = _super.call(this, chainType, chainId) || this; | ||
if (config === void 0) { config = { | ||
chainUrl: defaultUrl, | ||
chainId: 0 /* Default */, | ||
chainType: "hmy" /* Harmony */, | ||
}; } | ||
var _this = _super.call(this, config.chainType, config.chainId) || this; | ||
_this.Modules = { | ||
@@ -30,8 +34,4 @@ HttpProvider: network_1.HttpProvider, | ||
}; | ||
var providerUrl = url; | ||
_this.provider = utils.isHttp(providerUrl) | ||
? new network_1.HttpProvider(providerUrl) | ||
: utils.isWs(providerUrl) | ||
? new network_1.WSProvider(providerUrl) | ||
: new network_1.HttpProvider(defaultUrl); | ||
var providerUrl = config.chainUrl || url; | ||
_this.provider = _this.onInitSetProvider(providerUrl); | ||
_this.messenger = new network_1.Messenger(_this.provider, _this.chainType, _this.chainId); | ||
@@ -64,2 +64,9 @@ _this.blockchain = new blockchain_1.Blockchain(_this.messenger); | ||
}; | ||
Harmony.prototype.onInitSetProvider = function (providerUrl) { | ||
return utils.isHttp(providerUrl) | ||
? new network_1.HttpProvider(providerUrl) | ||
: utils.isWs(providerUrl) | ||
? new network_1.WSProvider(providerUrl) | ||
: new network_1.HttpProvider(defaultUrl); | ||
}; | ||
return Harmony; | ||
@@ -66,0 +73,0 @@ }(utils.HarmonyCore)); |
@@ -559,6 +559,10 @@ /** | ||
__extends(Harmony, _super); | ||
function Harmony(url, _a) { | ||
function Harmony(url, config) { | ||
if (url === void 0) { url = defaultUrl; } | ||
var _b = _a.chainType, chainType = _b === void 0 ? "hmy" /* Harmony */ : _b, _c = _a.chainId, chainId = _c === void 0 ? 0 /* Default */ : _c; | ||
var _this = _super.call(this, chainType, chainId) || this; | ||
if (config === void 0) { config = { | ||
chainUrl: defaultUrl, | ||
chainId: 0 /* Default */, | ||
chainType: "hmy" /* Harmony */, | ||
}; } | ||
var _this = _super.call(this, config.chainType, config.chainId) || this; | ||
_this.Modules = { | ||
@@ -575,8 +579,4 @@ HttpProvider: network.HttpProvider, | ||
}; | ||
var providerUrl = url; | ||
_this.provider = utils.isHttp(providerUrl) | ||
? new network.HttpProvider(providerUrl) | ||
: utils.isWs(providerUrl) | ||
? new network.WSProvider(providerUrl) | ||
: new network.HttpProvider(defaultUrl); | ||
var providerUrl = !config ? url : config.chainUrl; | ||
_this.provider = _this.onInitSetProvider(providerUrl); | ||
_this.messenger = new network.Messenger(_this.provider, _this.chainType, _this.chainId); | ||
@@ -609,2 +609,9 @@ _this.blockchain = new Blockchain(_this.messenger); | ||
}; | ||
Harmony.prototype.onInitSetProvider = function (providerUrl) { | ||
return utils.isHttp(providerUrl) | ||
? new network.HttpProvider(providerUrl) | ||
: utils.isWs(providerUrl) | ||
? new network.WSProvider(providerUrl) | ||
: new network.HttpProvider(defaultUrl); | ||
}; | ||
return Harmony; | ||
@@ -611,0 +618,0 @@ }(utils.HarmonyCore)); |
@@ -0,0 +0,0 @@ export * from './harmony'; |
@@ -557,6 +557,10 @@ /** | ||
__extends(Harmony, _super); | ||
function Harmony(url, _a) { | ||
function Harmony(url, config) { | ||
if (url === void 0) { url = defaultUrl; } | ||
var _b = _a.chainType, chainType = _b === void 0 ? "hmy" /* Harmony */ : _b, _c = _a.chainId, chainId = _c === void 0 ? 0 /* Default */ : _c; | ||
var _this = _super.call(this, chainType, chainId) || this; | ||
if (config === void 0) { config = { | ||
chainUrl: defaultUrl, | ||
chainId: 0 /* Default */, | ||
chainType: "hmy" /* Harmony */, | ||
}; } | ||
var _this = _super.call(this, config.chainType, config.chainId) || this; | ||
_this.Modules = { | ||
@@ -573,8 +577,4 @@ HttpProvider: HttpProvider, | ||
}; | ||
var providerUrl = url; | ||
_this.provider = isHttp(providerUrl) | ||
? new HttpProvider(providerUrl) | ||
: isWs(providerUrl) | ||
? new WSProvider(providerUrl) | ||
: new HttpProvider(defaultUrl); | ||
var providerUrl = !config ? url : config.chainUrl; | ||
_this.provider = _this.onInitSetProvider(providerUrl); | ||
_this.messenger = new Messenger(_this.provider, _this.chainType, _this.chainId); | ||
@@ -607,2 +607,9 @@ _this.blockchain = new Blockchain(_this.messenger); | ||
}; | ||
Harmony.prototype.onInitSetProvider = function (providerUrl) { | ||
return isHttp(providerUrl) | ||
? new HttpProvider(providerUrl) | ||
: isWs(providerUrl) | ||
? new WSProvider(providerUrl) | ||
: new HttpProvider(defaultUrl); | ||
}; | ||
return Harmony; | ||
@@ -609,0 +616,0 @@ }(HarmonyCore)); |
@@ -554,6 +554,10 @@ /** | ||
__extends(Harmony, _super); | ||
function Harmony(url, _a) { | ||
function Harmony(url, config) { | ||
if (url === void 0) { url = defaultUrl; } | ||
var _b = _a.chainType, chainType = _b === void 0 ? "hmy" /* Harmony */ : _b, _c = _a.chainId, chainId = _c === void 0 ? 0 /* Default */ : _c; | ||
var _this = _super.call(this, chainType, chainId) || this; | ||
if (config === void 0) { config = { | ||
chainUrl: defaultUrl, | ||
chainId: 0 /* Default */, | ||
chainType: "hmy" /* Harmony */, | ||
}; } | ||
var _this = _super.call(this, config.chainType, config.chainId) || this; | ||
_this.Modules = { | ||
@@ -570,8 +574,4 @@ HttpProvider: network.HttpProvider, | ||
}; | ||
var providerUrl = url; | ||
_this.provider = utils.isHttp(providerUrl) | ||
? new network.HttpProvider(providerUrl) | ||
: utils.isWs(providerUrl) | ||
? new network.WSProvider(providerUrl) | ||
: new network.HttpProvider(defaultUrl); | ||
var providerUrl = !config ? url : config.chainUrl; | ||
_this.provider = _this.onInitSetProvider(providerUrl); | ||
_this.messenger = new network.Messenger(_this.provider, _this.chainType, _this.chainId); | ||
@@ -604,2 +604,9 @@ _this.blockchain = new Blockchain(_this.messenger); | ||
}; | ||
Harmony.prototype.onInitSetProvider = function (providerUrl) { | ||
return utils.isHttp(providerUrl) | ||
? new network.HttpProvider(providerUrl) | ||
: utils.isWs(providerUrl) | ||
? new network.WSProvider(providerUrl) | ||
: new network.HttpProvider(defaultUrl); | ||
}; | ||
return Harmony; | ||
@@ -606,0 +613,0 @@ }(utils.HarmonyCore)); |
@@ -0,0 +0,0 @@ import { HttpProvider, Messenger } from '@harmony-js/network'; |
{ | ||
"name": "@harmony-js/core", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "harmony core package", | ||
@@ -21,10 +21,10 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@harmony-js/account": "0.0.23", | ||
"@harmony-js/contract": "0.0.23", | ||
"@harmony-js/crypto": "0.0.23", | ||
"@harmony-js/network": "0.0.23", | ||
"@harmony-js/transaction": "0.0.23", | ||
"@harmony-js/utils": "0.0.23" | ||
"@harmony-js/account": "0.0.24", | ||
"@harmony-js/contract": "0.0.24", | ||
"@harmony-js/crypto": "0.0.24", | ||
"@harmony-js/network": "0.0.24", | ||
"@harmony-js/transaction": "0.0.24", | ||
"@harmony-js/utils": "0.0.24" | ||
}, | ||
"gitHead": "2b54d4deba2169372508da8f0a1816575e25a47c" | ||
"gitHead": "8e2ed1afe6538258197cc3a69c299020cfcfb679" | ||
} |
@@ -63,2 +63,10 @@ import { | ||
async getBlockNumber() { | ||
const result = await this.messenger.send( | ||
RPCMethod.BlockNumber, | ||
[], | ||
this.chainPrefix, | ||
); | ||
return this.getRpcResult(result); | ||
} | ||
/** | ||
@@ -65,0 +73,0 @@ * |
@@ -9,2 +9,3 @@ import * as crypto from '@harmony-js/crypto'; | ||
import { Blockchain } from './blockchain'; | ||
import { HarmonyConfig } from './util'; | ||
@@ -35,16 +36,13 @@ const defaultUrl = 'http://localhost:9500'; | ||
url: string = defaultUrl, | ||
{ | ||
chainType = utils.ChainType.Harmony, | ||
chainId = utils.ChainID.Default, | ||
}: { chainType: utils.ChainType; chainId: utils.ChainID }, | ||
config: HarmonyConfig = { | ||
chainUrl: defaultUrl, | ||
chainId: utils.ChainID.Default, | ||
chainType: utils.ChainType.Harmony, | ||
}, | ||
) { | ||
super(chainType, chainId); | ||
super(config.chainType, config.chainId); | ||
const providerUrl = url; | ||
const providerUrl = config.chainUrl || url; | ||
this.provider = utils.isHttp(providerUrl) | ||
? new HttpProvider(providerUrl) | ||
: utils.isWs(providerUrl) | ||
? new WSProvider(providerUrl) | ||
: new HttpProvider(defaultUrl); | ||
this.provider = this.onInitSetProvider(providerUrl); | ||
this.messenger = new Messenger(this.provider, this.chainType, this.chainId); | ||
@@ -73,2 +71,9 @@ this.blockchain = new Blockchain(this.messenger); | ||
} | ||
private onInitSetProvider(providerUrl: string): HttpProvider | WSProvider { | ||
return utils.isHttp(providerUrl) | ||
? new HttpProvider(providerUrl) | ||
: utils.isWs(providerUrl) | ||
? new WSProvider(providerUrl) | ||
: new HttpProvider(defaultUrl); | ||
} | ||
} |
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 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 not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
276767
38
3265
+ Added@harmony-js/account@0.0.24(transitive)
+ Added@harmony-js/crypto@0.0.24(transitive)
+ Added@harmony-js/network@0.0.24(transitive)
+ Added@harmony-js/transaction@0.0.24(transitive)
+ Added@harmony-js/utils@0.0.24(transitive)
- Removed@harmony-js/account@0.0.23(transitive)
- Removed@harmony-js/contract@0.0.23(transitive)
- Removed@harmony-js/crypto@0.0.23(transitive)
- Removed@harmony-js/network@0.0.23(transitive)
- Removed@harmony-js/transaction@0.0.23(transitive)
- Removed@harmony-js/utils@0.0.23(transitive)
Updated@harmony-js/account@0.0.24
Updated@harmony-js/contract@0.0.24
Updated@harmony-js/crypto@0.0.24
Updated@harmony-js/network@0.0.24
Updated@harmony-js/utils@0.0.24