Skip to content

Commit

Permalink
Add getAccount method in GranteeSignerClient to handle AbstractAccoun…
Browse files Browse the repository at this point in the history
…t types (#53)

Imported Account from @cosmjs/stargate and added a new method 'getAccount' in GranteeSignerClient to fetch the account data. This method uses 'customAccountFromAny' from the @burnt-labs/signers package to convert the account data received. The 'customAccountFromAny' has also been exported in signers package index file to make it accessible for usage.

Closes #52
  • Loading branch information
justinbarry authored Jan 23, 2024
1 parent 047151f commit 2257a1f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/forty-rice-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@burnt-labs/abstraxion": minor
"@burnt-labs/signers": minor
---

Add getAccount method in GranteeSignerClient to parse abstractaccount.v1.AbstractAccount type accounts
12 changes: 11 additions & 1 deletion packages/abstraxion/src/GranteeSignerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import {
SigningCosmWasmClientOptions,
} from "@cosmjs/cosmwasm-stargate";
import { EncodeObject, OfflineSigner } from "@cosmjs/proto-signing";
import { SignerData, StdFee } from "@cosmjs/stargate";
import type { Account, SignerData, StdFee } from "@cosmjs/stargate";
import type { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import { MsgExec } from "cosmjs-types/cosmos/authz/v1beta1/tx";
import {
HttpEndpoint,
Tendermint37Client,
TendermintClient,
} from "@cosmjs/tendermint-rpc";
import { customAccountFromAny } from "@burnt-labs/signers";

interface GranteeSignerOptions {
readonly granterAddress: string;
Expand Down Expand Up @@ -60,6 +61,15 @@ export class GranteeSignerClient extends SigningCosmWasmClient {
this.granteeAddress = granteeAddress;
}

public async getAccount(searchAddress: string): Promise<Account | null> {
const account =
await this.forceGetQueryClient().auth.account(searchAddress);
if (!account) {
return null;
}
return customAccountFromAny(account);
}

public async signAndBroadcast(
signerAddress: string,
messages: readonly EncodeObject[],
Expand Down
1 change: 1 addition & 0 deletions packages/signers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export {
type AAccountData,
} from "./interfaces";
export { AbstractAccountJWTSigner } from "./signers/jwt-signer";
export { customAccountFromAny } from "./signers/utils";

0 comments on commit 2257a1f

Please sign in to comment.