Skip to content

Commit b9f1279

Browse files
dkijaniaclaude
andcommitted
Fix get_account: split query for with/without token parameter
The daemon now requires $token as non-nullable when declared. Use GET_ACCOUNT (no token variable) by default and GET_ACCOUNT_WITH_TOKEN only when token_id is provided. Same pattern as pooled_user_commands fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 55fff61 commit b9f1279

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

src/mina_sdk/daemon/client.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,16 @@ def get_account(
221221
Raises:
222222
ValueError: If the account does not exist on the ledger.
223223
"""
224-
variables: dict[str, Any] = {"publicKey": public_key}
225224
if token_id is not None:
226-
variables["token"] = token_id
227-
228-
data = self._request(queries.GET_ACCOUNT, variables=variables, query_name="get_account")
225+
variables: dict[str, Any] = {"publicKey": public_key, "token": token_id}
226+
data = self._request(
227+
queries.GET_ACCOUNT_WITH_TOKEN, variables=variables, query_name="get_account"
228+
)
229+
else:
230+
variables = {"publicKey": public_key}
231+
data = self._request(
232+
queries.GET_ACCOUNT, variables=variables, query_name="get_account"
233+
)
229234
acc = data.get("account")
230235
if acc is None:
231236
raise ValueError(f"account not found: {public_key}")

src/mina_sdk/daemon/queries.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,23 @@
3131
"""
3232

3333
GET_ACCOUNT = """
34-
query ($publicKey: PublicKey!, $token: UInt64) {
34+
query ($publicKey: PublicKey!) {
35+
account(publicKey: $publicKey) {
36+
publicKey
37+
nonce
38+
delegate
39+
tokenId
40+
balance {
41+
total
42+
liquid
43+
locked
44+
}
45+
}
46+
}
47+
"""
48+
49+
GET_ACCOUNT_WITH_TOKEN = """
50+
query ($publicKey: PublicKey!, $token: UInt64!) {
3551
account(publicKey: $publicKey, token: $token) {
3652
publicKey
3753
nonce

0 commit comments

Comments
 (0)