@harmony-js/core
Version:
harmony core package
162 lines • 4.47 kB
TypeScript
/**
* @packageDocumentation
* @module harmony-core
*/
import * as utils from '@harmony-js/utils';
import { HttpProvider, Messenger, WSProvider, ShardingItem } from '@harmony-js/network';
import { TransactionFactory, Transaction } from '@harmony-js/transaction';
import { StakingTransaction, StakingFactory } from '@harmony-js/staking';
import { ContractFactory, Contract } from '@harmony-js/contract';
import { Wallet, Account } from '@harmony-js/account';
import { Blockchain } from './blockchain';
import { HarmonyConfig } from './util';
export declare class Harmony extends utils.HarmonyCore {
/**@ignore*/
Modules: {
HttpProvider: typeof HttpProvider;
WSProvider: typeof WSProvider;
Messenger: typeof Messenger;
Blockchain: typeof Blockchain;
TransactionFactory: typeof TransactionFactory;
StakingFactory: typeof StakingFactory;
Wallet: typeof Wallet;
Transaction: typeof Transaction;
StakingTransaction: typeof StakingTransaction;
Account: typeof Account;
Contract: typeof Contract;
};
/**@ignore*/
messenger: Messenger;
/**@ignore*/
transactions: TransactionFactory;
/**@ignore*/
stakings: StakingFactory;
/**@ignore*/
wallet: Wallet;
/**@ignore*/
blockchain: Blockchain;
/**@ignore*/
contracts: ContractFactory;
/**@ignore*/
crypto: any;
/**@ignore*/
utils: any;
/**@ignore*/
defaultShardID?: number;
/**@ignore*/
private provider;
/**
* Create a harmony instance
*
* @param url The end-points of the hmy blockchain
* @param config set up `ChainID` and `ChainType`, typically we can use the default values
*
* @example
* ```
* // import or require Harmony class
* const { Harmony } = require('@harmony-js/core');
*
* // import or require settings
* const { ChainID, ChainType } = require('@harmony-js/utils');
*
* // Initialize the Harmony instance
* const hmy = new Harmony(
* // rpc url:
* // local: http://localhost:9500
* // testnet: https://api.s0.b.hmny.io/
* // mainnet: https://api.s0.t.hmny.io/
* 'http://localhost:9500',
* {
* // chainType set to Harmony
* chainType: ChainType.Harmony,
* // chainType set to HmyLocal
* chainId: ChainID.HmyLocal,
* },
* );
* ```
*/
constructor(url: string, config?: HarmonyConfig);
/**
* Will change the provider for its module.
*
* @param provider a valid provider, you can replace it with your own working node
*
* @example
* ```javascript
* const tmp = hmy.setProvider('http://localhost:9500');
* ```
*/
setProvider(provider: string | HttpProvider | WSProvider): void;
/**
* set the chainID
*
* @hint
* ```
* Default = 0,
* EthMainnet = 1,
Morden = 2,
Ropsten = 3,
Rinkeby = 4,
RootstockMainnet = 30,
RootstockTestnet = 31,
Kovan = 42,
EtcMainnet = 61,
EtcTestnet = 62,
Geth = 1337,
Ganache = 0,
HmyMainnet = 1,
HmyTestnet = 2,
HmyLocal = 2,
HmyPangaea = 3
* ```
* @param chainId
*
* @example
* ```
* hmy.setChainId(2);
* ```
*/
setChainId(chainId: utils.ChainID): void;
/**
* Change the Shard ID
*
* @example
* ```
* hmy.setShardID(2);
* ```
*/
setShardID(shardID: number): void;
/**
* set the chainType
*
* @param chainType `hmy` or `eth`
*
* @example
* ```
* // set chainType to hmy
* hmy.setChainType('hmy');
* // set chainType to eth
* hmy.setChainType('eth');
* ```
*/
setChainType(chainType: utils.ChainType): void;
/**
* Set the sharding Structure
*
* @param shardingStructures The array of information of sharding structures
*
* @example
* ```javascript
* hmy.shardingStructures([
* {"current":true,"http":"http://127.0.0.1:9500",
* "shardID":0,"ws":"ws://127.0.0.1:9800"},
* {"current":false,"http":"http://127.0.0.1:9501",
* "shardID":1,"ws":"ws://127.0.0.1:9801"}
* ]);
* ```
*/
shardingStructures(shardingStructures: ShardingItem[]): void;
/**@ignore*/
private setMessenger;
}
//# sourceMappingURL=harmony.d.ts.map