@tatumio/tezos-wallet-provider
Version:
Tezos provider with local wallet operations
229 lines • 9.01 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TatumProvider = void 0;
const utils_1 = require("@taquito/utils");
const bignumber_js_1 = __importDefault(require("bignumber.js"));
const utils_2 = require("./utils");
const defaultRPCOptions = { block: 'head' };
class TatumProvider {
constructor(rpc, chain) {
this.rpc = rpc;
this.chain = chain;
}
async getBalance(address, { block } = defaultRPCOptions) {
this.validateAddress(address);
const result = await this.rpc.getContractBalance({ contractId: address, block, chainId: this.chain });
return new bignumber_js_1.default(result);
}
getChainId() {
return this.rpc.getChainId({ chainId: this.chain });
}
async getConstants({ block } = defaultRPCOptions) {
const response = await this.rpc.getConstants({ block, chainId: this.chain });
const castedResponse = (0, utils_2.castToBigNumber)(response, [
'time_between_blocks',
'hard_gas_limit_per_operation',
'hard_gas_limit_per_block',
'proof_of_work_threshold',
'tokens_per_roll',
'seed_nonce_revelation_tip',
'block_security_deposit',
'endorsement_security_deposit',
'block_reward',
'endorsement_reward',
'cost_per_byte',
'hard_storage_limit_per_operation',
'test_chain_duration',
'baking_reward_per_endorsement',
'delay_per_missing_endorsement',
'minimal_block_delay',
'liquidity_baking_subsidy',
'cache_layout',
'baking_reward_fixed_portion',
'baking_reward_bonus_per_slot',
'endorsing_reward_per_slot',
'double_baking_punishment',
'delay_increment_per_round',
'tx_rollup_commitment_bond',
'vdf_difficulty',
'sc_rollup_stake_amount',
'minimal_stake',
]);
return {
...response,
...castedResponse,
};
}
async getContract(address, { block } = defaultRPCOptions) {
this.validateAddress(address);
const contractResponse = await this.rpc.getContract({ contractId: address, block, chainId: this.chain });
return {
...contractResponse,
balance: new bignumber_js_1.default(contractResponse.balance),
};
}
getBlockHeader({ block } = defaultRPCOptions) {
return this.rpc.getBlockHeader({ block: block, chainId: this.chain });
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
async getManagerKey(address, options) {
return 'dummy';
}
simulateOperation(op, { block } = defaultRPCOptions) {
const simulateOperation = {
...op,
block,
chainId: this.chain,
};
return this.rpc.simulateOperation(simulateOperation);
}
preapplyOperations(ops, { block } = defaultRPCOptions) {
const preapplyOperations = {
operations: ops,
block,
chainId: this.chain,
};
return this.rpc.preapplyOperations(preapplyOperations);
}
injectOperation(signedOpBytes) {
const injectOperation = {
operationBytes: signedOpBytes,
};
return this.rpc.injectOperation(injectOperation);
}
getProtocols({ block } = defaultRPCOptions) {
return this.rpc.getProtocols({ block, chainId: this.chain });
}
forgeOperations(data, options) {
throw new Error(`Method not implemented. Params: ${data}, ${options}`);
}
getAllTicketBalances(contract, options) {
throw new Error(`Method not implemented. Params: ${contract}, ${options}`);
}
getBakingRights(args, options) {
throw new Error(`Method not implemented. Params: ${args}, ${options}`);
}
getBallotList(options) {
throw new Error(`Method not implemented. Params: ${options}`);
}
getBallots(options) {
throw new Error(`Method not implemented. Params: ${options}`);
}
getBigMapExpr(id, expr, options) {
throw new Error(`Method not implemented. Params: ${id}, ${expr}, ${options}`);
}
getBigMapKey(address, key, options) {
throw new Error(`Method not implemented. Params: ${address}, ${key}, ${options}`);
}
getBlock(options) {
throw new Error(`Method not implemented. Params: ${options}`);
}
getBlockHash(options) {
throw new Error(`Method not implemented. Params: ${options}`);
}
getBlockMetadata(options) {
throw new Error(`Method not implemented. Params: ${options}`);
}
getCurrentPeriod(options) {
throw new Error(`Method not implemented. Params: ${options}`);
}
getCurrentProposal(options) {
throw new Error(`Method not implemented. Params: ${options}`);
}
getCurrentQuorum(options) {
throw new Error(`Method not implemented. Params: ${options}`);
}
getDelegate(address, options) {
throw new Error(`Method not implemented. Params: ${address}, ${options}`);
}
getDelegates(address, options) {
throw new Error(`Method not implemented. Params: ${address}, ${options}`);
}
getEndorsingRights(args, options) {
throw new Error(`Method not implemented. Params: ${args}, ${options}`);
}
getEntrypoints(contract, options) {
throw new Error(`Method not implemented. Params: ${contract}, ${options}`);
}
getLiveBlocks(options) {
throw new Error(`Method not implemented. Params: ${options}`);
}
getNormalizedScript(address, unparsingMode, options) {
throw new Error(`Method not implemented. Params: ${address}, ${unparsingMode}, ${options}`);
}
getOriginationProof(params, options) {
throw new Error(`Method not implemented. Params: ${params}, ${options}`);
}
getPendingOperations(args) {
throw new Error(`Method not implemented. Params: ${args}`);
}
getProposals(options) {
throw new Error(`Method not implemented. Params: ${options}`);
}
getRpcUrl() {
throw new Error(`Method not implemented. Params: `);
}
getSaplingDiffByContract(contract, options) {
throw new Error(`Method not implemented. Params: ${contract}, ${options}`);
}
getSaplingDiffById(id, options) {
throw new Error(`Method not implemented. Params: ${id}, ${options}`);
}
getScript(address, options) {
throw new Error(`Method not implemented. Params: ${address}, ${options}`);
}
getStorage(address, options) {
throw new Error(`Method not implemented. Params: ${address}, ${options}`);
}
getStoragePaidSpace(contract, options) {
throw new Error(`Method not implemented. Params: ${contract}, ${options}`);
}
getStorageUsedSpace(contract, options) {
throw new Error(`Method not implemented. Params: ${contract}, ${options}`);
}
getSuccessorPeriod(options) {
throw new Error(`Method not implemented. Params: ${options}`);
}
getTicketBalance(contract, ticket, options) {
throw new Error(`Method not implemented. Params: ${contract}, ${ticket}, ${options}`);
}
getTxRollupInbox(txRollupId, blockLevel, options) {
throw new Error(`Method not implemented. Params: ${txRollupId}, ${blockLevel}, ${options}`);
}
getTxRollupState(txRollupId, options) {
throw new Error(`Method not implemented. Params: ${txRollupId}, ${options}`);
}
getVotesListings(options) {
throw new Error(`Method not implemented. Params: ${options}`);
}
getVotingInfo(address, options) {
throw new Error(`Method not implemented. Params: ${address}, ${options}`);
}
packData(data, options) {
throw new Error(`Method not implemented. Params: ${data}, ${options}`);
}
runCode(code, options) {
throw new Error(`Method not implemented. Params: ${code}, ${options}`);
}
runOperation(op, options) {
throw new Error(`Method not implemented. Params: ${op}, ${options}`);
}
runScriptView(viewScriptParams, options) {
throw new Error(`Method not implemented. Params: ${viewScriptParams}, ${options}`);
}
runView(viewParams, options) {
throw new Error(`Method not implemented. Params: ${viewParams}, ${options}`);
}
validateAddress(address) {
const addressValidation = (0, utils_1.validateAddress)(address);
if (addressValidation !== utils_1.ValidationResult.VALID) {
throw new utils_1.InvalidAddressError(address, (0, utils_1.invalidDetail)(addressValidation));
}
}
}
exports.TatumProvider = TatumProvider;
//# sourceMappingURL=tatum.provider.js.map