@veive-io/mod-validation-signature-as
Version:
Validation signature module for Veive
81 lines (72 loc) • 3.8 kB
text/typescript
import { System, Protobuf, StringBytes } from "@koinos/sdk-as";
import { modvalidation } from "@veive-io/mod-validation-as";
import { modvalidationsignature } from "./proto/modvalidationsignature";
import { IModValidation as ModValidation } from "@veive-io/mod-validation-as";
export class ModValidationSignature extends ModValidation {
/**
* Validate operation by checking allowance
* @external
*/
is_authorized(args: modvalidation.authorize_arguments): modvalidation.authorize_result {
const argsBuffer = Protobuf.encode(args, modvalidation.authorize_arguments.encode);
const callRes = System.call(this._contractId, 0x671f5bf7, argsBuffer);
if (callRes.code != 0) {
const errorMessage = `failed to call 'ModValidationSignature.is_authorized': ${callRes.res.error && callRes.res.error!.message ? callRes.res.error!.message : "unknown error"}`;
System.exit(callRes.code, StringBytes.stringToBytes(errorMessage));
}
if (!callRes.res.object) return new modvalidation.authorize_result();
return Protobuf.decode<modvalidation.authorize_result>(callRes.res.object, modvalidation.authorize_result.decode);
}
/**
* @external
*/
set_threshold(args: modvalidationsignature.set_threshold_args): void {
const argsBuffer = Protobuf.encode(args, modvalidationsignature.set_threshold_args.encode);
const callRes = System.call(this._contractId, 0x0a141a40, argsBuffer);
if (callRes.code != 0) {
const errorMessage = `failed to call 'ModValidationSignature.set_threshold': ${callRes.res.error && callRes.res.error!.message ? callRes.res.error!.message : "unknown error"}`;
System.exit(callRes.code, StringBytes.stringToBytes(errorMessage));
}
return;
}
/**
* @external
* @readonly
*/
get_threshold(args: modvalidationsignature.get_threshold_args): modvalidationsignature.get_threshold_result {
const argsBuffer = Protobuf.encode(args, modvalidationsignature.get_threshold_args.encode);
const callRes = System.call(this._contractId, 0x00ff64fa, argsBuffer);
if (callRes.code != 0) {
const errorMessage = `failed to call 'ModValidationSignature.get_threshold': ${callRes.res.error && callRes.res.error!.message ? callRes.res.error!.message : "unknown error"}`;
System.exit(callRes.code, StringBytes.stringToBytes(errorMessage));
}
if (!callRes.res.object) return new modvalidationsignature.get_threshold_result();
return Protobuf.decode<modvalidationsignature.get_threshold_result>(callRes.res.object, modvalidationsignature.get_threshold_result.decode);
}
/**
* @external
*/
on_install(args: modvalidation.on_install_args): void {
const argsBuffer = Protobuf.encode(args, modvalidation.on_install_args.encode);
const callRes = System.call(this._contractId, 0xd3813539, argsBuffer);
if (callRes.code != 0) {
const errorMessage = `failed to call 'ModValidationSignature.on_install': ${callRes.res.error && callRes.res.error!.message ? callRes.res.error!.message : "unknown error"}`;
System.exit(callRes.code, StringBytes.stringToBytes(errorMessage));
}
return;
}
/**
* @external
* @readonly
*/
manifest(): modvalidation.manifest {
const argsBuffer = new Uint8Array(0);
const callRes = System.call(this._contractId, 0x05b3abf2, argsBuffer);
if (callRes.code != 0) {
const errorMessage = `failed to call 'ModValidationSignature.manifest': ${callRes.res.error && callRes.res.error!.message ? callRes.res.error!.message : "unknown error"}`;
System.exit(callRes.code, StringBytes.stringToBytes(errorMessage));
}
if (!callRes.res.object) return new modvalidation.manifest();
return Protobuf.decode<modvalidation.manifest>(callRes.res.object, modvalidation.manifest.decode);
}
}