From cfde7a89e8d7f5c43964fe9dfddad1b23eb294ac Mon Sep 17 00:00:00 2001 From: TheMonkeyCoder Date: Wed, 18 Dec 2024 17:55:00 +0300 Subject: [PATCH] feat: include all account object properties in GraphQL response for getAccount API query --- apps/klesia/src/index.spec.ts | 2 +- apps/klesia/src/methods/mina.spec.ts | 2 +- apps/klesia/src/methods/mina.ts | 48 +++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/apps/klesia/src/index.spec.ts b/apps/klesia/src/index.spec.ts index 53a6a5a..95ccfc8 100644 --- a/apps/klesia/src/index.spec.ts +++ b/apps/klesia/src/index.spec.ts @@ -53,6 +53,6 @@ describe("Mina Devnet RPC", () => { // biome-ignore lint/suspicious/noExplicitAny: TODO const { result } = (await response.json()) as any; expect(BigInt(result.nonce)).toBeGreaterThanOrEqual(0); - expect(BigInt(result.balance)).toBeGreaterThanOrEqual(0); + expect(BigInt(result.balance.total)).toBeGreaterThanOrEqual(0); }); }); diff --git a/apps/klesia/src/methods/mina.spec.ts b/apps/klesia/src/methods/mina.spec.ts index a3cd1aa..db59be0 100644 --- a/apps/klesia/src/methods/mina.spec.ts +++ b/apps/klesia/src/methods/mina.spec.ts @@ -26,5 +26,5 @@ it("should return network id", async () => { it("should get account info", async () => { const result = await mina.getAccount({ publicKey: TEST_PKEY }); expect(BigInt(result.nonce)).toBeGreaterThanOrEqual(0); - expect(BigInt(result.balance)).toBeGreaterThanOrEqual(0); + expect(BigInt(result.balance.total)).toBeGreaterThanOrEqual(0); }); diff --git a/apps/klesia/src/methods/mina.ts b/apps/klesia/src/methods/mina.ts index 4effa54..43b2bc4 100644 --- a/apps/klesia/src/methods/mina.ts +++ b/apps/klesia/src/methods/mina.ts @@ -150,23 +150,61 @@ const getAccount = async ({ publicKey }: { publicKey: string }) => { gql` query { account(publicKey: $publicKey) { + publicKey + token nonce balance { total } + tokenSymbol + receiptChainHash + timing { + initialMinimumBalance + cliffTime + cliffAmount + vestingPeriod + vestingIncrement + } + permissions { + editState + access + send + receive + setDelegate + setPermissions + setVerificationKey { + auth + txnVersion + } + setZkappUri + editActionState + setTokenSymbol + incrementNonce + setVotingFor + setTiming + } + delegateAccount { publicKey } + votingFor + zkappState + verificationKey { + verificationKey + hash + } + actionState + provedState + zkappUri } } `, { publicKey }, ); - return { - nonce: data.account.nonce, - balance: data.account.balance.total, - }; + return data.account; } catch { return { nonce: "0", - balance: "0", + balance: { + total: "0", + }, }; } };