Skip to content

Commit

Permalink
Merge pull request #56 from terra-money/feat/auth/api
Browse files Browse the repository at this point in the history
feat: auth api get module account
  • Loading branch information
emidev98 authored Nov 1, 2023
2 parents 7711a24 + 1812a1b commit 137088c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 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": "@terra-money/feather.js",
"version": "2.0.0-beta.5",
"version": "2.0.0-beta.7",
"description": "The JavaScript SDK for Terra and Feather chains",
"license": "MIT",
"author": "Terraform Labs, PTE.",
Expand Down
22 changes: 19 additions & 3 deletions src/client/lcd/api/AuthAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,31 @@ export class AuthAPI extends BaseAPI {
*
* @param address address of account to look up
*/
public async moduleAccountInfo(
public async moduleAccountsInfo(
chainID: string,
params: APIParams = {}
): Promise<Array<Account>> {
): Promise<Array<ModuleAccount>> {
const { accounts } = await this.getReqFromChainID(chainID).get<{
accounts: Array<ModuleAccount.Data>;
}>(`/cosmos/auth/v1beta1/module_accounts`, params);

return accounts.map((account: any) => Account.fromData(account));
return accounts.map((account: any) => ModuleAccount.fromData(account));
}
/**
* Query a specific module acccount information
*
* @param address address of account to look up
*/
public async moduleAccountInfo(
chainID: string,
moduleName: string,
params: APIParams = {}
): Promise<ModuleAccount> {
const { account } = await this.getReqFromChainID(chainID).get<{
account: ModuleAccount.Data;
}>(`/cosmos/auth/v1beta1/module_accounts/${moduleName}`, params);

return ModuleAccount.fromData(account);
}
/**
* Looks up the account information using its Terra account address. If the account has
Expand Down
6 changes: 0 additions & 6 deletions src/core/ica/controller/v1/CosmosTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ export class CosmosTx extends JSONSerializable<

public static fromData(data: CosmosTx.Data, _?: boolean): CosmosTx {
_;
console.log('CosmosTx#fromData', data);
const parsedData = Buffer.from(data, 'base64');
const { messages } = CosmosTx_pb.decode(parsedData);
return new CosmosTx(messages.map(msg => Msg.fromProto(msg)));
}

public toData(_?: boolean): CosmosTx.Data {
_;
console.log('CosmosTx#toData', this.messages);
const { messages } = this;

const ct = CosmosTx_pb.encode({
Expand All @@ -51,13 +49,11 @@ export class CosmosTx extends JSONSerializable<

public static fromProto(proto: CosmosTx.Proto, _?: boolean): CosmosTx {
_;
console.log('CosmosTx#fromProto', proto);
return new CosmosTx(proto.messages.map(msg => Msg.fromProto(msg)));
}

public toProto(_?: boolean): CosmosTx.Proto {
_;
console.log('CosmosTx#toProto', this.messages);
const { messages } = this;

const ct = CosmosTx_pb.encode({
Expand All @@ -68,14 +64,12 @@ export class CosmosTx extends JSONSerializable<
}

public packAny(isClassic?: boolean): Any {
console.log('CosmosTx#packAny', this.messages);
return Any.fromPartial({
value: this.toProto(isClassic) as any,
});
}

public static unpackAny(msgAny: Any, isClassic?: boolean): CosmosTx {
console.log('CosmosTx#unpackAny', msgAny);
return CosmosTx.fromProto(CosmosTx_pb.decode(msgAny.value), isClassic);
}
}
Expand Down

0 comments on commit 137088c

Please sign in to comment.