UNPKG

@zlattice/lattice-js

Version:

Lattice blockchain TypeScript SDK with dual module support (CJS + ESM)

106 lines 2.79 kB
import { BuiltinContract } from "./types.js"; class ProposalContract { constructor() { this.iface = proposal.getLatticeInterface(); } async approve(proposalId) { return await this.iface.encodeFunctionData("vote", [proposalId, 1]); } async reject(proposalId) { return await this.iface.encodeFunctionData("vote", [proposalId, 0]); } async refresh(proposalId) { return await this.iface.encodeFunctionData("refresh", [proposalId]); } async refreshBatch(proposalIds) { return await this.iface.encodeFunctionData("batchRefresh", [proposalIds]); } async cancel(proposalId) { return await this.iface.encodeFunctionData("cancel", [proposalId]); } } const proposal = new BuiltinContract("提案合约", "zltc_amgWuhifLRUoZc3GSbv9wUUz6YUfTuWy5", `[ { "inputs": [ { "internalType": "string", "name": "ProposalId", "type": "string" }, { "internalType": "uint8", "name": "VoteSuggestion", "type": "uint8" } ], "name": "vote", "outputs": [ { "internalType": "bytes", "name": "", "type": "bytes" } ], "stateMutability": "pure", "type": "function" }, { "inputs": [ { "internalType": "string", "name": "ProposalId", "type": "string" } ], "name": "refresh", "outputs": [ { "internalType": "bytes", "name": "", "type": "bytes" } ], "stateMutability": "pure", "type": "function" }, { "inputs": [ { "internalType": "string[]", "name": "proposalIds", "type": "string[]" } ], "name": "batchRefresh", "outputs": [ { "internalType": "bytes", "name": "", "type": "bytes" } ], "stateMutability": "pure", "type": "function" }, { "inputs": [ { "internalType": "string", "name": "proposalId", "type": "string" } ], "name": "cancel", "outputs": [ { "internalType": "bytes", "name": "", "type": "bytes" } ], "stateMutability": "pure", "type": "function" } ]`); export { ProposalContract }; //# sourceMappingURL=proposal.js.map