UNPKG

vendee-example

Version:

Vendee contract example

71 lines (70 loc) 1.96 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Example = void 0; const vendee_1 = require("vendee"); const ExampleContent_1 = __importDefault(require("./ExampleContent")); class Example extends vendee_1.Contract { _call; _run; _payload; constructor(config = {}, options = {}) { if (config.address === undefined) super({ abi: ExampleContent_1.default.abi, initial: config.initial ?? {}, keys: config.keys, tvc: ExampleContent_1.default.tvc }, options); else super({ address: config.address, abi: ExampleContent_1.default.abi }, options); this._call = new ExampleCalls(this); this._run = new ExampleRuns(this); this._payload = new ExamplePayload(this); } async deploy(value, input, useGiver = true, timeout = 60000) { return await this._deploy(value, input, useGiver, timeout); } get call() { return this._call; } get run() { return this._run; } get payload() { return this._payload; } } exports.Example = Example; class ExampleCalls { contract; constructor(contract) { this.contract = contract; } async getCount(keys) { return await this.contract.callMethod('getCount', {}, keys); } } class ExampleRuns { contract; constructor(contract) { this.contract = contract; } async getCount() { return (await this.contract.runMethod('getCount')).value; } } class ExamplePayload { contract; constructor(contract) { this.contract = contract; } async getCount() { return await this.contract.createPayload('getCount'); } }