UNPKG

wowok

Version:

Wowok Blockchain TypeScript API

1 lines 2.04 kB
import{isValidDescription,MAX_DESCRIPTION_LENGTH,ObjectType,PackageAddress}from'../common.js';import{W_ERROR,WErrors}from'../exception.js';import{isValidAddress}from'../local/local.js';import{CallBase}from'./base.js';export class CallProof extends CallBase{['data'];constructor(a){super(),this['data']=a;}async['call'](a){return await this['prepare'](a),await this['exec'](a);}async['operate'](a,b,c,d){await this['new_with_mark'](a,b,ObjectType['Proof'],create(b,this['data']?.['description'],this['data']?.['proof'],this['data']?.['server_pubkey'],this['data']?.['server_signature'],this['data']?.['proof_type'],this['data']?.['item_count'],this['data']?.['about_address']),this['data']?.['namedNew']);}}export function proofFn(a){return PackageAddress+'::proof::'+a;}export const MAX_PROOF_SIZE=0x9e20;export const MAX_SERVER_PUBKEY_SIZE=0x1000;export const MAX_SERVER_SIGNATURE_SIZE=0x1000;export const gen_proof=async(a,b,c,d,e,f,g,h)=>{const i=new CallProof({'proof':b,'server_pubkey':c,'server_signature':d,'proof_type':e,'description':f,'item_count':g,'about_address':h});return await i['call'](a);};export function create(a,b,c,d,e,f,g,h){return!isValidDescription(b)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20length\x20exceeds\x20'+MAX_DESCRIPTION_LENGTH),c['length']>MAX_PROOF_SIZE&&W_ERROR(WErrors['InvalidParam'],'Proof\x20length\x20exceeds\x20'+MAX_PROOF_SIZE),d['length']>MAX_SERVER_PUBKEY_SIZE&&W_ERROR(WErrors['InvalidParam'],'Server\x20pubkey\x20length\x20exceeds\x20'+MAX_SERVER_PUBKEY_SIZE),e['length']>MAX_SERVER_SIGNATURE_SIZE&&W_ERROR(WErrors['InvalidParam'],'Server\x20signature\x20length\x20exceeds\x20'+MAX_SERVER_SIGNATURE_SIZE),!isValidAddress(h)&&W_ERROR(WErrors['IsValidAddress'],'About\x20address\x20'+h+'\x20is\x20not\x20valid'),a['moveCall']({'target':proofFn('create_wowok_proof'),'arguments':[a['pure']['string'](c),a['pure']['option']('u64',g),a['pure']['string'](b),a['pure']['string'](d),a['pure']['string'](e),a['pure']['option']('address',h),a['pure']['u64'](f),a['object']['clock']()]});}