Skip to content

Commit

Permalink
Add view and view batch endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
joon9823 committed Mar 25, 2024
1 parent 6078041 commit 33db472
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@initia/initia.js",
"version": "0.1.36",
"version": "0.1.37",
"description": "The JavaScript SDK for Initia",
"license": "MIT",
"author": "InitiaLabs",
Expand Down
43 changes: 43 additions & 0 deletions src/client/lcd/api/MoveAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ export interface TableInfo {
value_type: string;
}

export interface ViewRequest {
address: AccAddress;
module_name: string;
function_name: string;
type_args: string[];
args: string[];
}

export interface ViewResponse {
data: string;
events: VMEvent[];
gas_used: string;
}

export interface VMEvent {
type_tag: string;
data: string;
}

export class MoveAPI extends BaseAPI {
public async modules(
address: AccAddress,
Expand Down Expand Up @@ -133,6 +152,30 @@ export class MoveAPI extends BaseAPI {
);
}

public async view(
address: AccAddress,
moduleName: string,
functionName: string,
typeArgs: string[] = [],
args: string[] = []
): Promise<ViewResponse> {
return this.c.post<ViewResponse>(`/initia/move/v1/view`, {
address,
module_name: moduleName,
function_name: functionName,
type_args: typeArgs,
args,
});
}

public async viewBatch(requests: ViewRequest[]): Promise<ViewResponse[]> {
return this.c
.post<{ responses: ViewResponse[] }>(`/initia/move/v1/view/batch`, {
requests,
})
.then(d => d.responses);
}

public async resources(
address: AccAddress,
params: Partial<PaginationOptions & APIParams> = {}
Expand Down

0 comments on commit 33db472

Please sign in to comment.