wowok
Version:
Wowok Blockchain TypeScript API
1 lines • 661 B
JavaScript
import{bcs}from'../_deps/bcs/index.js';import{Address}from'./bcs.js';export function pureBcsSchemaFromTypeName(a){switch(a){case'u8':return bcs['u8']();case'u16':return bcs['u16']();case'u32':return bcs['u32']();case'u64':return bcs['u64']();case'u128':return bcs['u128']();case'u256':return bcs['u256']();case'bool':return bcs['bool']();case'string':return bcs['string']();case'id':case'address':return Address;}const b=a['match'](/^(vector|option)<(.+)>$/);if(b){const [c,d]=b['slice'](0x1);return c==='vector'?bcs['vector'](pureBcsSchemaFromTypeName(d)):bcs['option'](pureBcsSchemaFromTypeName(d));}throw new Error('Invalid\x20Pure\x20type\x20name:\x20'+a);}