diff --git a/src/client/lcd/api/MoveAPI.ts b/src/client/lcd/api/MoveAPI.ts index ba57b5e..2590965 100644 --- a/src/client/lcd/api/MoveAPI.ts +++ b/src/client/lcd/api/MoveAPI.ts @@ -1,7 +1,6 @@ import { BaseAPI } from './BaseAPI'; -import { AccAddress, Denom, MoveParams, ModuleABI } from '../../../core'; +import { AccAddress, Denom, MoveParams } from '../../../core'; import { APIParams, Pagination, PaginationOptions } from '../APIRequester'; -import { argsEncodeWithABI } from '../../../util'; import { UpgradePolicy } from '@initia/initia.proto/initia/move/v1/types'; export interface Module { @@ -113,45 +112,6 @@ export class MoveAPI extends BaseAPI { .then(res => JSON.parse(res.data) as T); } - /** - * Query view function with not encoded arguments and abi. - * Arguments will be bcs encoded with type informations from abi. - * - * @param address - * @param moduleName - * @param functionName - * @param typeArgs - * @param args // not encoded arguments - * @param abi // base64 encoded module abi - * @returns - */ - public async viewFunctionWithABI( - abi: string, - address: AccAddress, - moduleName: string, - functionName: string, - typeArgs: string[] = [], - args: any[] = [] - ): Promise { - const module: ModuleABI = JSON.parse(Buffer.from(abi, 'base64').toString()); - - const functionAbi = module.exposed_functions.find( - exposedFunction => exposedFunction.name === functionName - ); - - if (!functionAbi) { - throw new Error('function not found'); - } - - return this.viewFunction( - address, - moduleName, - functionName, - typeArgs, - argsEncodeWithABI(args, functionAbi) - ); - } - public async view( address: AccAddress, moduleName: string, diff --git a/src/core/move/index.ts b/src/core/move/index.ts index 9ba301c..f6c1771 100644 --- a/src/core/move/index.ts +++ b/src/core/move/index.ts @@ -1,3 +1,2 @@ export * from './msgs'; export * from './MoveParams'; -export * from './types'; diff --git a/src/core/move/msgs/MsgExecute.ts b/src/core/move/msgs/MsgExecute.ts index 1dc5710..dd1daa7 100644 --- a/src/core/move/msgs/MsgExecute.ts +++ b/src/core/move/msgs/MsgExecute.ts @@ -2,8 +2,6 @@ import { JSONSerializable } from '../../../util/json'; import { AccAddress } from '../../bech32'; import { Any } from '@initia/initia.proto/google/protobuf/any'; import { MsgExecute as MsgExecute_pb } from '@initia/initia.proto/initia/move/v1/tx'; -import { argsEncodeWithABI } from '../../../util'; -import { ModuleABI } from '../types'; export class MsgExecute extends JSONSerializable< MsgExecute.Amino, @@ -157,77 +155,6 @@ export class MsgExecute extends JSONSerializable< args, }; } - - /** - * Generate `MsgExecute` from plain arguments(not bcs encoded). - * - * @example - * // In case of the types of arguments are ['u64', 'u64'] - * const abi = await lcd.move.module('init1def...', 'pair').then(res => res.abi) - * - * // msg that was generated with not encoded arguments - * consg msg1 = MsgExectueEntryFunction.fromPlainArgs( - * 'init1abc...', // sender - * 'init1def...', // module owner - * 'pair', // moudle name - * 'provide_liquidity', // function name - * [], - * [1000000000000, 2000000000000], - * abi - * ); - * - * // msg that was generated with the constructor - * const msg2 = new MsgExecute( - * 'init1abc...', // sender - * 'init1def...', // module owner - * 'pair', // moudle name - * 'provide_liquidity', // function name - * [], - * [ - * bcs.serialize('u64', 1000000000000), - * bcs.serialize('u64', 2000000000000), - * ] - * ); - * - * console.assert(msg1.toJSON(), msg2.toJSON() - * - * @param sender - * @param module_address - * @param module_name - * @param function_name - * @param type_args - * @param args - * @param abi // base64 encoded module abi - * @returns - */ - public static fromPlainArgs( - sender: AccAddress, - module_address: AccAddress, - module_name: string, - function_name: string, - type_args: string[] = [], - args: any[] = [], - abi: string - ): MsgExecute { - const module: ModuleABI = JSON.parse(abi); - - const functionAbi = module.exposed_functions.find( - exposedFunction => exposedFunction.name === function_name - ); - - if (!functionAbi) { - throw new Error('function not found'); - } - - return new MsgExecute( - sender, - module_address, - module_name, - function_name, - type_args, - argsEncodeWithABI(args, functionAbi) - ); - } } export namespace MsgExecute { diff --git a/src/core/move/msgs/MsgScript.ts b/src/core/move/msgs/MsgScript.ts index 5071350..3d4cf53 100644 --- a/src/core/move/msgs/MsgScript.ts +++ b/src/core/move/msgs/MsgScript.ts @@ -2,8 +2,6 @@ import { JSONSerializable } from '../../../util/json'; import { AccAddress } from '../../bech32'; import { Any } from '@initia/initia.proto/google/protobuf/any'; import { MsgScript as MsgScript_pb } from '@initia/initia.proto/initia/move/v1/tx'; -import { MoveFunctionABI } from '../types'; -import { argsEncodeWithABI } from '../../../util'; export class MsgScript extends JSONSerializable< MsgScript.Amino, @@ -96,59 +94,6 @@ export class MsgScript extends JSONSerializable< args, }; } - - /** - * Generate `MsgScript` from plain arguments(not bcs encoded) - * - * @example - * // In case of the types of arguments are ['u64', 'u64'] - * const abi = await lcd.move.scriptABI(script).then(res => res.abi) - * - * // msg that was generated with not encoded arguments - * consg msg1 = MsgScript.fromPlainArgs( - * 'init1abc...', // sender - * script, // code bytes - * [], - * [1000000000000, 2000000000000], - * abi - * ); - * - * // msg that was generated with the constructor - * const msg2 = new MsgScript( - * 'init1abc...', // sender - * script, // code bytes - * [], - * [ - * bcs.serialize('u64', 1000000000000), - * bcs.serialize('u64', 2000000000000), - * ] - * ); - * - * console.assert(msg1.toJSON(), msg2.toJSON() - * - * @param sender - * @param code_bytes - * @param type_args - * @param args - * @param abi // base64 encoded script abi - * @returns - */ - public static fromPlainArgs( - sender: AccAddress, - code_bytes: string, - type_args: string[], - args: any[], - abi: string - ): MsgScript { - const functionAbi: MoveFunctionABI = JSON.parse(abi); - - return new MsgScript( - sender, - code_bytes, - type_args, - argsEncodeWithABI(args, functionAbi) - ); - } } export namespace MsgScript { diff --git a/src/core/move/types.ts b/src/core/move/types.ts deleted file mode 100644 index dd6eaab..0000000 --- a/src/core/move/types.ts +++ /dev/null @@ -1,32 +0,0 @@ -export interface ModuleABI { - address: string; - name: string; - friends: string[]; - exposed_functions: MoveFunctionABI[]; - structs: MoveStructABI[]; -} - -export interface MoveFunctionABI { - name: string; - visibility: string; - is_entry: boolean; - generic_type_params: { - constraints: string[]; - }[]; - params: string[]; - return: string[]; -} - -export interface MoveStructABI { - name: string; - is_native: boolean; - abilities: string[]; - generic_type_params: { - constraints: string[]; - is_phantom: boolean; - }; - fields: { - name: string; - type: string; - }[]; -} diff --git a/src/util/index.ts b/src/util/index.ts index 55da6d9..b80c2da 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -1,4 +1,3 @@ -export * from './bcsLegacy'; export * from './bcs'; export * from './hash'; export * from './json';