UNPKG

@dioxide-js/silas

Version:

RPC utility for Silas

60 lines (57 loc) 1.88 kB
import { __awaiter } from '../node_modules/tslib/tslib.es6.mjs'; import { Transaction } from './transaction.mjs'; import ProofSvc from '../api/proof.mjs'; class Proof { constructor(opts) { this.tx = new Transaction(opts); this.proofSvc = new ProofSvc(opts); } newProof(privatekey, params) { return __awaiter(this, void 0, void 0, function* () { const { sender, ttl, key, content } = params; if (!privatekey || !sender) { throw `both privatekey and sender are required`; } return this.tx.send({ sender, gasprice: 100, function: 'silas.ProofOfExistence.new', args: { key, content, }, ttl, }, privatekey); }); } newProofByProofKey(privatekey, params) { return __awaiter(this, void 0, void 0, function* () { const { sender, ttl, proof_key, content = '' } = params; if (!privatekey || !sender) { throw `both privatekey and sender are required`; } return this.tx.send({ sender, gasprice: 100, function: 'silas.ProofOfExistence.newByProofKey', args: { proof_key, content, }, ttl, }, privatekey); }); } getProofs(params) { return __awaiter(this, void 0, void 0, function* () { return this.proofSvc.getProofs(params); }); } checkProof(proof_hash) { return __awaiter(this, void 0, void 0, function* () { return this.proofSvc.checkProof(proof_hash); }); } } export { Proof as default }; //# sourceMappingURL=proof.mjs.map