UNPKG

@dioxide-js/silas

Version:

RPC utility for Silas

35 lines (32 loc) 1.19 kB
import { NET } from '../constants/index.mjs'; import AddressService from '../api/address.mjs'; import { Transaction } from './transaction.mjs'; import Account from './account.mjs'; import provider from '../api/provider.mjs'; import BlockSvc from '../api/block.mjs'; import OverviewService from '../api/overview.mjs'; import Proof from './proof.mjs'; class Web3 { constructor(net, opts) { this.net = net || NET.TEST; if (!(opts === null || opts === void 0 ? void 0 : opts.apiKey)) { throw 'unfilled authorization'; } const options = Object.assign({ alg: 'sm2', showTxFlow: false }, opts); const { apiKey, n } = options; provider.set(this.net); provider.setApiKey(options.apiKey); this.address = new AddressService({ apiKey }); this.block = new BlockSvc({ apiKey }); this.overview = new OverviewService({ apiKey }); this.txn = new Transaction(options); this.proof = new Proof(options); this.account = new Account({ apiKey }); } setProvider(net) { this.net = net; provider.set(net); } } export { Web3 }; //# sourceMappingURL=index.mjs.map