UNPKG

@dioxide-js/silas

Version:

RPC utility for Silas

57 lines (54 loc) 1.82 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(privatekey, { sender, gasprice: 100, function: 'silas.ProofOfExistence.new', args: { key, content }, ttl, }); }); } 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(privatekey, { sender, gasprice: 100, function: 'silas.ProofOfExistence.newByProofKey', args: { proof_key, content, }, ttl, }); }); } 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