diff --git a/packages/apps/wallet-sdk-example/src/components/Header.tsx b/packages/apps/wallet-sdk-example/src/components/Header.tsx index ccfd11d165..25c51ae6ae 100644 --- a/packages/apps/wallet-sdk-example/src/components/Header.tsx +++ b/packages/apps/wallet-sdk-example/src/components/Header.tsx @@ -69,6 +69,11 @@ export const Header: React.FC = () => { Kadena Names + + + Accounts by public key + + @@ -84,9 +89,6 @@ export const Header: React.FC = () => { Testnet - - Testnet (Pact 5) - diff --git a/packages/apps/wallet-sdk-example/src/hooks/accountsByPublickey.ts b/packages/apps/wallet-sdk-example/src/hooks/accountsByPublickey.ts new file mode 100644 index 0000000000..8f7c4cc562 --- /dev/null +++ b/packages/apps/wallet-sdk-example/src/hooks/accountsByPublickey.ts @@ -0,0 +1,72 @@ +import type { + IFungibleAccount, + IFungibleAccountsResponse, +} from '@kadena/wallet-sdk'; +import { walletSdk } from '@kadena/wallet-sdk'; +import { useQuery } from '@tanstack/react-query'; +import { useEffect, useState } from 'react'; +import { useWalletState } from '../state/wallet'; +import { useFunctionTracker } from './functionTracker'; + +/** + * Custom hook to fetch fungible accounts by public key. + * + * @param publicKey - The public key associated with the account. + * @param fungibleName - The name of the fungible token. + * @param graphType - The type of GraphQL endpoint to use (Kadena or Hackachain). + * @returns An object containing the fetched accounts, loading state, error, and refetch function. + */ +export const useAccountsByPublicKey = ( + publicKey: string, + fungibleName: string, +) => { + const wallet = useWalletState(); + const [accounts, setAccounts] = useState([]); + + const trackGetAccounts = useFunctionTracker( + 'walletSdk.getFungibleAccountsByPublicKey', + ); + + const { + data: accountsResponse, + error, + isLoading, + refetch, + } = useQuery({ + queryKey: [ + 'accountsByPublicKey', + publicKey, + fungibleName, + wallet.selectedNetwork, + ], + enabled: false, + queryFn: async () => { + if (!publicKey || !fungibleName || !wallet.selectedNetwork) { + return undefined; + } + + return trackGetAccounts.wrap(walletSdk.getFungibleAccountsByPublicKey)({ + publicKey, + fungibleName, + networkId: wallet.selectedNetwork, + }); + }, + }); + + useEffect(() => { + if (accountsResponse?.fungibleAccounts) { + setAccounts(accountsResponse.fungibleAccounts); + } else { + setAccounts([]); + } + }, [accountsResponse]); + + return { + accounts, + error, + isLoading, + refetch, + // Demo: Track function calls for debugging or logging purposes + functionCalls: [trackGetAccounts.data], + }; +}; diff --git a/packages/apps/wallet-sdk-example/src/host.ts b/packages/apps/wallet-sdk-example/src/host.ts index bfad18366c..1c710a0d6d 100644 --- a/packages/apps/wallet-sdk-example/src/host.ts +++ b/packages/apps/wallet-sdk-example/src/host.ts @@ -9,7 +9,6 @@ export type ChainwebHostGenerator = (options: { export const chainwebHostMap: Record = { mainnet01: 'https://api.chainweb.com', testnet04: 'https://api.testnet.chainweb.com', - testnet05: 'https://api.testnet.chainweb.com', }; export const getChainIdByNetwork = (networkId: string): ChainId => { diff --git a/packages/apps/wallet-sdk-example/src/pages/accountsByPublickey.tsx b/packages/apps/wallet-sdk-example/src/pages/accountsByPublickey.tsx new file mode 100644 index 0000000000..fa8c07413d --- /dev/null +++ b/packages/apps/wallet-sdk-example/src/pages/accountsByPublickey.tsx @@ -0,0 +1,138 @@ +import { MonoFormatListBulleted } from '@kadena/kode-icons/system'; +import { + Button, + Card, + Cell, + Column, + ContentHeader, + Divider, + Row, + Stack, + Table, + TableBody, + TableHeader, + Text, + TextField, +} from '@kadena/kode-ui'; + +import { useState } from 'react'; +import SdkFunctionDisplay from '../components/SdkFunctionDisplayer'; // Demo +import { TextEllipsis } from '../components/Text'; +import { useAccountsByPublicKey } from '../hooks/accountsByPublickey'; + +export const AccountsByPublicKey = () => { + const [publicKey, setPublicKey] = useState(''); + const [fungibleName, setFungibleName] = useState(''); + + const { accounts, functionCalls, error, isLoading, refetch } = + useAccountsByPublicKey(publicKey, fungibleName); + + const handleFetchAccounts = () => { + refetch(); + }; + + return ( +
+ + } + /> + + + + + + Fetch Accounts + + + + + + + + + + + {error && ( + + Error fetching accounts: {error.message} + + )} + + {isLoading && ( + + + Loading accounts... + + + )} + + {!isLoading && !error && ( + + + Associated accounts + + + {accounts?.length ? ( + + + Account Name + Chain + + + {accounts.map((accountItem, index) => ( + + + + {accountItem.accountName} + + + + {accountItem.chainAccounts.map((chain, chainIndex) => ( +
+ {chain.chainId} ({chain.accountName}) +
+ ))} +
+
+ ))} +
+
+ ) : ( + No associated accounts + )} +
+ )} +
+ + {/* + This is for Demo purposes, displaying what SDK function is executed for this action + */} + {functionCalls.map((data, index) => ( + + ))} +
+ ); +}; + +export default AccountsByPublicKey; diff --git a/packages/apps/wallet-sdk-example/src/routes.tsx b/packages/apps/wallet-sdk-example/src/routes.tsx index 8e0bd7cf0f..dd9ca6a7df 100644 --- a/packages/apps/wallet-sdk-example/src/routes.tsx +++ b/packages/apps/wallet-sdk-example/src/routes.tsx @@ -1,5 +1,6 @@ import { RouteObject } from 'react-router-dom'; +import { AccountsByPublicKey } from './pages/accountsByPublickey'; import MarkdownPage from './pages/Home'; import { KadenaNames } from './pages/kadenaNames/KadenaNamesResolver'; import { Transfer } from './pages/Transfer'; @@ -27,6 +28,10 @@ const routes: RouteObject[] = [ path: '/kadenanames', element: , }, + { + path: 'accountsbypublickey', + element: , + }, ]; export default routes; diff --git a/packages/libs/wallet-sdk/etc/wallet-sdk.api.json b/packages/libs/wallet-sdk/etc/wallet-sdk.api.json index ee3c9c7d14..75b3503c8a 100644 --- a/packages/libs/wallet-sdk/etc/wallet-sdk.api.json +++ b/packages/libs/wallet-sdk/etc/wallet-sdk.api.json @@ -447,6 +447,78 @@ ], "extendsTokenRanges": [] }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!IChainAccount:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface IChainAccount " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "IChainAccount", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IChainAccount#accountName:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "accountName: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "accountName", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IChainAccount#chainId:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "chainId: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "chainId", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + } + ], + "extendsTokenRanges": [] + }, { "kind": "TypeAlias", "canonicalReference": "@kadena/wallet-sdk!ICreateCrossChainTransfer:type", @@ -1450,6 +1522,232 @@ ], "extendsTokenRanges": [] }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!IFungibleAccount:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface IFungibleAccount " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "IFungibleAccount", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IFungibleAccount#accountName:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "accountName: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "accountName", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IFungibleAccount#chainAccounts:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "chainAccounts: " + }, + { + "kind": "Reference", + "text": "IChainAccount", + "canonicalReference": "@kadena/wallet-sdk!IChainAccount:interface" + }, + { + "kind": "Content", + "text": "[]" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "chainAccounts", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 3 + } + } + ], + "extendsTokenRanges": [] + }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!IFungibleAccountsOptions:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface IFungibleAccountsOptions " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "IFungibleAccountsOptions", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IFungibleAccountsOptions#fungibleName:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "fungibleName?: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "fungibleName", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IFungibleAccountsOptions#networkId:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "networkId: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "networkId", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IFungibleAccountsOptions#publicKey:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "publicKey: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "publicKey", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + } + ], + "extendsTokenRanges": [] + }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!IFungibleAccountsResponse:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface IFungibleAccountsResponse " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "IFungibleAccountsResponse", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IFungibleAccountsResponse#fungibleAccounts:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "fungibleAccounts: " + }, + { + "kind": "Reference", + "text": "IFungibleAccount", + "canonicalReference": "@kadena/wallet-sdk!IFungibleAccount:interface" + }, + { + "kind": "Content", + "text": "[]" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "fungibleAccounts", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 3 + } + } + ], + "extendsTokenRanges": [] + }, { "kind": "Interface", "canonicalReference": "@kadena/wallet-sdk!IGuard:interface", @@ -3283,6 +3581,69 @@ "isAbstract": false, "name": "getChainwebUrl" }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#getFungibleAccountsByPublicKey:member(1)", + "docComment": "/**\n * Fetch accounts by public key.\n *\n * @param options - Options containing publicKey, fungibleName, and networkId.\n *\n * @returns A promise resolving to IFungibleAccountsResponse.\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "getFungibleAccountsByPublicKey(options: " + }, + { + "kind": "Reference", + "text": "IFungibleAccountsOptions", + "canonicalReference": "@kadena/wallet-sdk!IFungibleAccountsOptions:interface" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "Promise", + "canonicalReference": "!Promise:interface" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "IFungibleAccountsResponse", + "canonicalReference": "@kadena/wallet-sdk!IFungibleAccountsResponse:interface" + }, + { + "kind": "Content", + "text": ">" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 3, + "endIndex": 7 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "options", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isOptional": false + } + ], + "isOptional": false, + "isAbstract": false, + "name": "getFungibleAccountsByPublicKey" + }, { "kind": "Method", "canonicalReference": "@kadena/wallet-sdk!WalletSDK#getGasLimitEstimate:member(1)", diff --git a/packages/libs/wallet-sdk/etc/wallet-sdk.api.md b/packages/libs/wallet-sdk/etc/wallet-sdk.api.md index 6c63353849..7d04f791a7 100644 --- a/packages/libs/wallet-sdk/etc/wallet-sdk.api.md +++ b/packages/libs/wallet-sdk/etc/wallet-sdk.api.md @@ -50,6 +50,14 @@ export interface IChain { id: ChainId; } +// @public (undocumented) +export interface IChainAccount { + // (undocumented) + accountName: string; + // (undocumented) + chainId: string; +} + // @public (undocumented) export type ICreateCrossChainTransfer = Parameters[0]; @@ -166,6 +174,30 @@ export interface IEthvmDevTokenInfo { totalSupply?: number; } +// @public (undocumented) +export interface IFungibleAccount { + // (undocumented) + accountName: string; + // (undocumented) + chainAccounts: IChainAccount[]; +} + +// @public (undocumented) +export interface IFungibleAccountsOptions { + // (undocumented) + fungibleName?: string; + // (undocumented) + networkId: string; + // (undocumented) + publicKey: string; +} + +// @public (undocumented) +export interface IFungibleAccountsResponse { + // (undocumented) + fungibleAccounts: IFungibleAccount[]; +} + // @public (undocumented) export interface IGuard { // (undocumented) @@ -305,6 +337,7 @@ export class WalletSDK { getChains(networkHost: string): Promise; // (undocumented) getChainwebUrl(...args: Parameters): ReturnType; + getFungibleAccountsByPublicKey(options: IFungibleAccountsOptions): Promise; // (undocumented) getGasLimitEstimate(transaction: ICommand, networkId: string, chainId: ChainId_2): Promise; // (undocumented) diff --git a/packages/libs/wallet-sdk/src/gql/gql.ts b/packages/libs/wallet-sdk/src/gql/gql.ts index f43a775191..4b130da6f5 100644 --- a/packages/libs/wallet-sdk/src/gql/gql.ts +++ b/packages/libs/wallet-sdk/src/gql/gql.ts @@ -14,6 +14,7 @@ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document- * Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size */ const documents = { + "\n query accountsByPublicKey($publicKey: String!, $fungibleName: String) {\n fungibleAccountsByPublicKey(\n publicKey: $publicKey\n fungibleName: $fungibleName\n ) {\n accountName\n chainAccounts {\n accountName\n chainId\n }\n }\n }\n": types.AccountsByPublicKeyDocument, "\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n minerAccount {\n accountName\n }\n }\n transaction {\n cmd {\n networkId\n meta {\n gasPrice\n sender\n }\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n gas\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n": types.TransferFieldsFragmentDoc, "\n query accountTransfers(\n $accountName: String!\n $fungibleName: String\n $first: Int\n $last: Int\n $before: String\n $after: String\n ) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: $first, last: $last, before: $before, after: $after) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n": types.AccountTransfersDocument, "\n query accountChainTransfers(\n $accountName: String!\n $chainId: String\n $fungibleName: String\n $first: Int\n $last: Int\n $before: String\n $after: String\n ) {\n lastBlockHeight\n transfers(\n accountName: $accountName\n chainId: $chainId\n fungibleName: $fungibleName\n first: $first\n last: $last\n before: $before\n after: $after\n ) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n": types.AccountChainTransfersDocument, @@ -34,6 +35,10 @@ const documents = { */ export function graphql(source: string): unknown; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "\n query accountsByPublicKey($publicKey: String!, $fungibleName: String) {\n fungibleAccountsByPublicKey(\n publicKey: $publicKey\n fungibleName: $fungibleName\n ) {\n accountName\n chainAccounts {\n accountName\n chainId\n }\n }\n }\n"): (typeof documents)["\n query accountsByPublicKey($publicKey: String!, $fungibleName: String) {\n fungibleAccountsByPublicKey(\n publicKey: $publicKey\n fungibleName: $fungibleName\n ) {\n accountName\n chainAccounts {\n accountName\n chainId\n }\n }\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/packages/libs/wallet-sdk/src/gql/graphql.ts b/packages/libs/wallet-sdk/src/gql/graphql.ts index 3732f0b0ee..5b01620e2f 100644 --- a/packages/libs/wallet-sdk/src/gql/graphql.ts +++ b/packages/libs/wallet-sdk/src/gql/graphql.ts @@ -959,6 +959,14 @@ export type Transfer = Node & { transaction?: Maybe; }; +export type AccountsByPublicKeyQueryVariables = Exact<{ + publicKey: Scalars['String']['input']; + fungibleName?: InputMaybe; +}>; + + +export type AccountsByPublicKeyQuery = { __typename?: 'Query', fungibleAccountsByPublicKey: Array<{ __typename?: 'FungibleAccount', accountName: string, chainAccounts: Array<{ __typename?: 'FungibleChainAccount', accountName: string, chainId: string }> }> }; + export type TransferFieldsFragment = { __typename?: 'Transfer', amount: any, chainId: number, orderIndex: number, receiverAccount: string, requestKey: string, senderAccount: string, moduleName: string, block: { __typename?: 'Block', hash: string, height: number, creationTime: string, minerAccount: { __typename?: 'FungibleChainAccount', accountName: string } }, transaction?: { __typename?: 'Transaction', cmd: { __typename?: 'TransactionCommand', networkId: string, meta: { __typename?: 'TransactionMeta', gasPrice: number, sender: string }, payload: { __typename: 'ContinuationPayload', step?: number | null, pactId?: string | null } | { __typename: 'ExecutionPayload', code?: string | null, data: string }, signers: Array<{ __typename?: 'Signer', clist: Array<{ __typename?: 'TransactionCapability', name: string, args: string }> }> }, result: { __typename: 'TransactionMempoolInfo' } | { __typename: 'TransactionResult', goodResult?: string | null, badResult?: string | null, gas: number, events: { __typename?: 'TransactionResultEventsConnection', edges: Array<{ __typename?: 'TransactionResultEventsConnectionEdge', node: { __typename?: 'Event', name: string, parameters?: string | null } } | null> } } } | null } & { ' $fragmentName'?: 'TransferFieldsFragment' }; export type AccountTransfersQueryVariables = Exact<{ @@ -1010,6 +1018,7 @@ export type AccountTransferRequestKeyQuery = { __typename?: 'Query', lastBlockHe ) }> } }; export const TransferFieldsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}},{"kind":"Field","name":{"kind":"Name","value":"minerAccount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountName"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"meta"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"gasPrice"}},{"kind":"Field","name":{"kind":"Name","value":"sender"}}]}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"gas"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; +export const AccountsByPublicKeyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountsByPublicKey"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"publicKey"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"fungibleAccountsByPublicKey"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"publicKey"},"value":{"kind":"Variable","name":{"kind":"Name","value":"publicKey"}}},{"kind":"Argument","name":{"kind":"Name","value":"fungibleName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountName"}},{"kind":"Field","name":{"kind":"Name","value":"chainAccounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountName"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}}]}}]}}]}}]} as unknown as DocumentNode; export const AccountTransfersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountTransfers"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"last"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"before"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"fungibleAccount"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}},{"kind":"Argument","name":{"kind":"Name","value":"fungibleName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"last"},"value":{"kind":"Variable","name":{"kind":"Name","value":"last"}}},{"kind":"Argument","name":{"kind":"Name","value":"before"},"value":{"kind":"Variable","name":{"kind":"Name","value":"before"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}},{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}}]}},{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}},{"kind":"Field","name":{"kind":"Name","value":"crossChainTransfer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}},{"kind":"Field","name":{"kind":"Name","value":"minerAccount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountName"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"meta"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"gasPrice"}},{"kind":"Field","name":{"kind":"Name","value":"sender"}}]}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"gas"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; export const AccountChainTransfersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountChainTransfers"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"chainId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"last"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"before"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}},{"kind":"Argument","name":{"kind":"Name","value":"chainId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"chainId"}}},{"kind":"Argument","name":{"kind":"Name","value":"fungibleName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}}},{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"last"},"value":{"kind":"Variable","name":{"kind":"Name","value":"last"}}},{"kind":"Argument","name":{"kind":"Name","value":"before"},"value":{"kind":"Variable","name":{"kind":"Name","value":"before"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}},{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}}]}},{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}},{"kind":"Field","name":{"kind":"Name","value":"crossChainTransfer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}},{"kind":"Field","name":{"kind":"Name","value":"minerAccount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountName"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"meta"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"gasPrice"}},{"kind":"Field","name":{"kind":"Name","value":"sender"}}]}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"gas"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; export const AccountTransferRequestKeyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountTransferRequestKey"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"requestKey"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"requestKey"},"value":{"kind":"Variable","name":{"kind":"Name","value":"requestKey"}}},{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}},{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}}]}},{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}},{"kind":"Field","name":{"kind":"Name","value":"minerAccount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountName"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"meta"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"gasPrice"}},{"kind":"Field","name":{"kind":"Name","value":"sender"}}]}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"gas"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/packages/libs/wallet-sdk/src/index.ts b/packages/libs/wallet-sdk/src/index.ts index d3077d8a38..8b96d7799e 100644 --- a/packages/libs/wallet-sdk/src/index.ts +++ b/packages/libs/wallet-sdk/src/index.ts @@ -1,4 +1,5 @@ export { ChainwebHostGenerator, GraphqlHostGenerator } from './sdk/host.js'; + export type * from './sdk/interface.js'; export { ILogTransport, LogLevel } from './sdk/logger.js'; export { WalletSDK, walletSdk } from './sdk/walletSdk.js'; diff --git a/packages/libs/wallet-sdk/src/sdk/host.ts b/packages/libs/wallet-sdk/src/sdk/host.ts index 36abb65e95..21acce87d5 100644 --- a/packages/libs/wallet-sdk/src/sdk/host.ts +++ b/packages/libs/wallet-sdk/src/sdk/host.ts @@ -14,7 +14,6 @@ export type GraphqlHostGenerator = (options: { networkId: string }) => string; const chainwebHostMap: Record = { mainnet01: 'https://api.chainweb.com', testnet04: 'https://api.testnet.chainweb.com', - testnet05: 'https://api.testnet.chainweb.com', }; export const defaultChainwebHostGenerator: ChainwebHostGenerator = ( @@ -24,9 +23,8 @@ export const defaultChainwebHostGenerator: ChainwebHostGenerator = ( }; const graphqlHostMap: Record = { - mainnet01: 'https://graph.kadena.network/graphql', - testnet04: 'https://graph.testnet.kadena.network/graphql', - testnet05: 'https://graph.testnet.kadena.network/graphql', + mainnet01: 'https://www.kadindexer.io/graphql', + testnet04: 'https://testnet.kadindexer.io/graphql', }; export const defaultGraphqlHostGenerator: GraphqlHostGenerator = (options) => { diff --git a/packages/libs/wallet-sdk/src/sdk/interface.ts b/packages/libs/wallet-sdk/src/sdk/interface.ts index b4eb84d004..8816fa50fd 100644 --- a/packages/libs/wallet-sdk/src/sdk/interface.ts +++ b/packages/libs/wallet-sdk/src/sdk/interface.ts @@ -231,3 +231,48 @@ export type INodeChainInfo = Pick; * @public */ export type INodeNetworkInfo = Omit; + +/** + * Options for fetching fungible accounts. + */ + +/** + * @public + */ +export interface IFungibleAccountsOptions { + publicKey: string; + fungibleName?: string; + networkId: string; +} + +/** + * Represents a chain account associated with a fungible account. + */ +/** + * @public + */ +export interface IChainAccount { + accountName: string; + chainId: string; +} + +/** + * Represents a fungible account. + */ +/** + * @public + */ +export interface IFungibleAccount { + accountName: string; + chainAccounts: IChainAccount[]; +} + +/** + * Response structure for fetching fungible accounts. + */ +/** + * @public + */ +export interface IFungibleAccountsResponse { + fungibleAccounts: IFungibleAccount[]; +} diff --git a/packages/libs/wallet-sdk/src/sdk/tests/getAccountsByPublickey.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/getAccountsByPublickey.test.ts new file mode 100644 index 0000000000..613baf2315 --- /dev/null +++ b/packages/libs/wallet-sdk/src/sdk/tests/getAccountsByPublickey.test.ts @@ -0,0 +1,98 @@ +import { describe, expect, it } from 'vitest'; +import { walletSdk } from '../walletSdk.js'; + +describe('getFungibleAccountsByPublicKey', () => { + /** + * Tests for fungable accounts by publickey + */ + describe('Graph', () => { + it('fetches fungible accounts correctly with valid inputs', async () => { + const publicKey = + '232d28fe92059876b5febb69e7e10a92e46e844697d9643dfdef7d61eec06359'; + const fungibleName = 'coin'; + const networkId = 'testnet04'; + + const result = await walletSdk.getFungibleAccountsByPublicKey({ + publicKey, + fungibleName, + networkId, + }); + + const expectedAccounts = [ + { + accountName: + 'k:232d28fe92059876b5febb69e7e10a92e46e844697d9643dfdef7d61eec06359', + chainAccounts: [ + { + accountName: + 'k:232d28fe92059876b5febb69e7e10a92e46e844697d9643dfdef7d61eec06359', + chainId: '2', + }, + ], + }, + ]; + expect(result.fungibleAccounts).toEqual(expectedAccounts); + }); + + it('fetches multiple fungible accounts correctly with valid inputs', async () => { + const publicKey = + '554754f48b16df24b552f6832dda090642ed9658559fef9f3ee1bb4637ea7c94'; + const fungibleName = 'coin'; + const networkId = 'testnet04'; + + const result = await walletSdk.getFungibleAccountsByPublicKey({ + publicKey, + fungibleName, + networkId, + }); + + const expectedAccounts = [ + { + accountName: + 'k:554754f48b16df24b552f6832dda090642ed9658559fef9f3ee1bb4637ea7c94', + chainAccounts: [ + { + accountName: + 'k:554754f48b16df24b552f6832dda090642ed9658559fef9f3ee1bb4637ea7c94', + chainId: '0', + }, + { + accountName: + 'k:554754f48b16df24b552f6832dda090642ed9658559fef9f3ee1bb4637ea7c94', + chainId: '1', + }, + { + accountName: + 'k:554754f48b16df24b552f6832dda090642ed9658559fef9f3ee1bb4637ea7c94', + chainId: '2', + }, + { + accountName: + 'k:554754f48b16df24b552f6832dda090642ed9658559fef9f3ee1bb4637ea7c94', + chainId: '5', + }, + { + accountName: + 'k:554754f48b16df24b552f6832dda090642ed9658559fef9f3ee1bb4637ea7c94', + chainId: '8', + }, + ], + }, + ]; + expect(result.fungibleAccounts).toEqual(expectedAccounts); + }); + + it('returns an empty array when no accounts are found', async () => { + const publicKey = 'nonexistentpublickey1234567890'; + const fungibleName = 'coin'; + const networkId = 'testnet04'; + + const result = await walletSdk.getFungibleAccountsByPublicKey({ + publicKey, + fungibleName, + networkId, + }); + expect(result.fungibleAccounts).toEqual([]); + }); + }); +}); diff --git a/packages/libs/wallet-sdk/src/sdk/tests/hosts.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/hosts.test.ts index ac4a9a2ebd..cb33adaaeb 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/hosts.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/hosts.test.ts @@ -29,17 +29,6 @@ describe('Host Generators', () => { expect(result).toBe(expectedUrl); }); - it('should generate the correct Chainweb URL for testnet05 and chainId 3', () => { - const networkId = 'testnet05'; - const chainId = '3'; - const expectedUrl = - 'https://api.testnet.chainweb.com/chainweb/0.0/testnet05/chain/3/pact'; - - const result = defaultChainwebHostGenerator({ networkId, chainId }); - - expect(result).toBe(expectedUrl); - }); - it('should generate a URL with "undefined" for unsupported networkId', () => { const networkId = 'unknownNetwork'; const chainId = '1'; @@ -78,17 +67,7 @@ describe('Host Generators', () => { it('should generate the correct GraphQL URL for testnet04', () => { const networkId = 'testnet04'; - const expectedUrl = 'https://graph.testnet.kadena.network/graphql'; - - const result = defaultGraphqlHostGenerator({ networkId }); - - expect(result).toBe(expectedUrl); - expect(consoleWarnSpy).not.toHaveBeenCalled(); - }); - - it('should generate the correct GraphQL URL for testnet05', () => { - const networkId = 'testnet05'; - const expectedUrl = 'https://graph.testnet.kadena.network/graphql'; + const expectedUrl = 'https://testnet.kadindexer.io/graphql'; const result = defaultGraphqlHostGenerator({ networkId }); diff --git a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts index 9478e269d7..a309765fac 100644 --- a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts +++ b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts @@ -15,6 +15,7 @@ import type { import * as accountService from '../services/accountService.js'; import { pollRequestKeys } from '../services/chainweb/chainweb.js'; +import { fetchAccountsByPublicKey } from '../services/graphql/accountByPublicKey.js'; import { getChainTransfers } from '../services/graphql/getChainTransfers.js'; import { getTransfers } from '../services/graphql/getTransfers.js'; import { pollGraphqlTransfers } from '../services/graphql/pollTransfers.js'; @@ -41,6 +42,8 @@ import type { ICreateTransferCreate, ICreateTransferCreateOptional, ICrossChainTransfer, + IFungibleAccountsOptions, + IFungibleAccountsResponse, INodeChainInfo, INodeNetworkInfo, ITransactionDescriptor, @@ -95,6 +98,8 @@ export class WalletSDK { this.createFinishCrossChainTransfer.bind(this); this.sendTransaction = this.sendTransaction.bind(this); this.getGasLimitEstimate = this.getGasLimitEstimate.bind(this); + this.getFungibleAccountsByPublicKey = + this.getFungibleAccountsByPublicKey.bind(this); } public getChainwebUrl( @@ -299,6 +304,20 @@ export class WalletSDK { return result; } + /** + * Fetch accounts by public key. + * + * @param options - Options containing publicKey, fungibleName, and networkId. + * @returns A promise resolving to IFungibleAccountsResponse. + */ + public async getFungibleAccountsByPublicKey( + options: IFungibleAccountsOptions, + ): Promise { + const { networkId, ...rest } = options; + const url = this.getGraphqlUrl({ networkId }); + return fetchAccountsByPublicKey(url, rest); + } + public async getTransfers( options: ITransferOptions, ): Promise { diff --git a/packages/libs/wallet-sdk/src/services/graphql/account.query.ts b/packages/libs/wallet-sdk/src/services/graphql/account.query.ts new file mode 100644 index 0000000000..398c232c40 --- /dev/null +++ b/packages/libs/wallet-sdk/src/services/graphql/account.query.ts @@ -0,0 +1,16 @@ +import { graphql } from '../../gql/gql.js'; + +export const ACCOUNTS_BY_PUBLIC_KEY_QUERY = graphql(` + query accountsByPublicKey($publicKey: String!, $fungibleName: String) { + fungibleAccountsByPublicKey( + publicKey: $publicKey + fungibleName: $fungibleName + ) { + accountName + chainAccounts { + accountName + chainId + } + } + } +`); diff --git a/packages/libs/wallet-sdk/src/services/graphql/accountByPublicKey.ts b/packages/libs/wallet-sdk/src/services/graphql/accountByPublicKey.ts new file mode 100644 index 0000000000..cf0cc62b65 --- /dev/null +++ b/packages/libs/wallet-sdk/src/services/graphql/accountByPublicKey.ts @@ -0,0 +1,55 @@ +import { createClient, fetchExchange } from '@urql/core'; +import type { + IFungibleAccount, + IFungibleAccountsOptions, + IFungibleAccountsResponse, +} from '../../sdk/interface.js'; + +import { ACCOUNTS_BY_PUBLIC_KEY_QUERY } from './account.query.js'; + +/** + * Service to fetch fungible accounts by public key. + * + * @param graphqlUrl - The GraphQL endpoint URL. + * @param options - Options containing publicKey and fungibleName. + * @returns A promise resolving to IFungibleAccountsResponse. + */ +export async function fetchAccountsByPublicKey( + graphqlUrl: string, + options: Omit, +): Promise { + const client = createClient({ url: graphqlUrl, exchanges: [fetchExchange] }); + const result = await client + .query(ACCOUNTS_BY_PUBLIC_KEY_QUERY, { + publicKey: options.publicKey, + fungibleName: options.fungibleName, + }) + .toPromise(); + + if (result.error) { + throw new Error(`GraphQL Error: ${result.error.message}`); + } + + if (!result.data) { + throw new Error('No data returned from GraphQL query.'); + } + + if (result.data.fungibleAccountsByPublicKey.length === 0) { + return { + fungibleAccounts: [], + }; + } + + const fungibleAccounts: IFungibleAccount[] = + result.data.fungibleAccountsByPublicKey.map((account) => ({ + accountName: account.accountName, + chainAccounts: account.chainAccounts.map((chain) => ({ + accountName: chain.accountName, + chainId: chain.chainId, + })), + })); + + return { + fungibleAccounts, + }; +}