@dioxide-js/silas
Version:
RPC utility for Silas
37 lines (34 loc) • 1.27 kB
JavaScript
import { NET } from '../constants/index.mjs';
import AddressService from '../api/address.mjs';
import { Transaction } from './transaction.mjs';
import Account from './account.mjs';
import Contract from './contract.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 } = 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 });
this.contract = new Contract({ apiKey });
}
setProvider(net) {
this.net = net;
provider.set(net);
}
}
export { Web3 };
//# sourceMappingURL=index.mjs.map