graz 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  /// <reference types="../types/global" />
2
2
  import { DirectSignResponse, OfflineDirectSigner, Coin } from '@cosmjs/proto-signing';
3
3
  import { Key as Key$1, Keplr, ChainInfo, KeplrSignOptions, KeplrIntereactionOptions, OfflineAminoSigner as OfflineAminoSigner$1, AppCurrency } from '@keplr-wallet/types';
4
- import { OfflineAminoSigner, StdSignDoc, AminoSignResponse, StdSignature } from '@cosmjs/amino';
4
+ import { OfflineAminoSigner } from '@cosmjs/amino';
5
5
  import { WalletConnectModalConfig } from '@walletconnect/modal';
6
6
  import { SignClientTypes } from '@walletconnect/types';
7
7
  import * as _tanstack_react_query from '@tanstack/react-query';
8
8
  import { UseQueryResult } from '@tanstack/react-query';
9
9
  import { ParaWeb } from '@getpara/web-sdk';
10
10
  export { ParaWeb } from '@getpara/web-sdk';
11
- import { ParaGrazConfig as ParaGrazConfig$1 } from '@getpara/graz-connector';
11
+ import { ParaGrazConfig as ParaGrazConfig$1, ParaGrazConnector } from '@getpara/graz-connector';
12
12
  import * as _cosmjs_cosmwasm_stargate from '@cosmjs/cosmwasm-stargate';
13
13
  import { SigningCosmWasmClient, InstantiateOptions, CosmWasmClient, InstantiateResult, ExecuteResult, SigningCosmWasmClientOptions } from '@cosmjs/cosmwasm-stargate';
14
14
  import { SigningStargateClient, StdFee, DeliverTxResponse, QueryClient, StakingExtension, StargateClient, SigningStargateClientOptions } from '@cosmjs/stargate';
@@ -127,6 +127,92 @@ interface SuggestChainAndConnectArgs {
127
127
  }
128
128
  declare const suggestChainAndConnect: (args: SuggestChainAndConnectArgs) => Promise<ConnectResult>;
129
129
 
130
+ /**
131
+ * Logger types and interfaces for Graz
132
+ */
133
+ declare enum LogLevel {
134
+ ERROR = 0,
135
+ WARN = 1,
136
+ INFO = 2,
137
+ DEBUG = 3,
138
+ TRACE = 4
139
+ }
140
+ declare enum LogCategory {
141
+ WALLET = "wallet",// Wallet connections, disconnections
142
+ TRANSACTION = "transaction",// Transaction signing and broadcasting
143
+ QUERY = "query",// Blockchain queries
144
+ STORE = "store",// State management
145
+ MULTICHAIN = "multichain",// Multi-chain operations
146
+ EVENT = "event",// Wallet events
147
+ PERFORMANCE = "performance"
148
+ }
149
+ /**
150
+ * Error reporter interface for integration with error tracking services
151
+ * (e.g., Sentry, custom error tracking)
152
+ */
153
+ interface ErrorReporter {
154
+ captureException: (error: Error, context?: {
155
+ category?: string;
156
+ context?: Record<string, unknown>;
157
+ }) => void;
158
+ }
159
+ /**
160
+ * Logger configuration options
161
+ */
162
+ interface LoggerOptions {
163
+ /**
164
+ * Enable/disable logging
165
+ * @default true in development, false in production
166
+ */
167
+ enabled?: boolean;
168
+ /**
169
+ * Log level configuration:
170
+ * - Single LogLevel: Minimum level (e.g., LogLevel.INFO logs INFO, WARN, ERROR)
171
+ * - Array of LogLevel: Only log these specific levels
172
+ * - undefined/not specified: Log all levels
173
+ * @default undefined (all levels)
174
+ */
175
+ level?: LogLevel | LogLevel[];
176
+ /**
177
+ * Categories to log:
178
+ * - Array of categories: Only log these specific categories
179
+ * - Empty array or undefined: Log all categories
180
+ * @default undefined (all categories)
181
+ */
182
+ categories?: (keyof typeof LogCategory)[];
183
+ /**
184
+ * Optional error reporter for error tracking integration
185
+ */
186
+ errorReporter?: ErrorReporter;
187
+ }
188
+ /**
189
+ * Logger interface
190
+ */
191
+ interface Logger {
192
+ error(category: LogCategory, message: string, context?: Record<string, unknown>): void;
193
+ warn(category: LogCategory, message: string, context?: Record<string, unknown>): void;
194
+ info(category: LogCategory, message: string, context?: Record<string, unknown>): void;
195
+ debug(category: LogCategory, message: string, context?: Record<string, unknown>): void;
196
+ trace(category: LogCategory, message: string, context?: Record<string, unknown>): void;
197
+ time(label: string): void;
198
+ timeEnd(label: string): void;
199
+ group(label: string): void;
200
+ groupEnd(): void;
201
+ setLevel(level: LogLevel | LogLevel[] | undefined): void;
202
+ setCategories(categories: (keyof typeof LogCategory)[] | undefined): void;
203
+ enable(): void;
204
+ disable(): void;
205
+ }
206
+ /**
207
+ * Global window extensions for Graz debugging
208
+ */
209
+ declare global {
210
+ interface Window {
211
+ __GRAZ_DEBUG__?: boolean;
212
+ grazErrorReporter?: ErrorReporter;
213
+ }
214
+ }
215
+
130
216
  /**
131
217
  * Para wallet entity (compatible with Wallet from @getpara/core-sdk)
132
218
  * Represents a wallet within the Para ecosystem (different from Graz Wallet)
@@ -196,10 +282,10 @@ interface ParaGrazConfig {
196
282
  */
197
283
  noModal?: boolean;
198
284
  /**
199
- * Optional connector class constructor to use instead of default
200
- * Allows for custom Para connector implementations
285
+ * Required connector class constructor
286
+ * Must be provided to use Para wallet functionality
201
287
  */
202
- connectorClass?: new (config: ParaGrazConfig, chains?: ChainInfo[] | null) => ParaGrazConnector;
288
+ connectorClass: new (config: ParaGrazConfig, chains?: ChainInfo[] | null) => ParaGrazConnector;
203
289
  /**
204
290
  * Props for customizing the Para modal appearance and behavior
205
291
  * Only used when using @getpara/graz-integration with modal support
@@ -212,72 +298,6 @@ interface ParaGrazConfig {
212
298
  */
213
299
  queryClient?: _tanstack_react_query.QueryClient;
214
300
  }
215
- /**
216
- * Para wallet connector interface
217
- * Implements the Graz Wallet interface with Para-specific methods
218
- */
219
- interface ParaGrazConnector extends Omit<Wallet, "experimentalSuggestChain"> {
220
- /**
221
- * Enable connection to one or more chains
222
- * @param chainIds - Single chain ID or array of chain IDs
223
- */
224
- enable(chainIds: string | string[]): Promise<void>;
225
- /**
226
- * Disconnect from Para wallet
227
- */
228
- disconnect(): Promise<void>;
229
- /**
230
- * Get the Para Web SDK client instance
231
- */
232
- getParaWebClient(): ParaWeb;
233
- /**
234
- * Get the connector configuration
235
- */
236
- getConfig(): ParaGrazConfig;
237
- /**
238
- * Get account key for a specific chain
239
- * @param chainId - The chain identifier
240
- */
241
- getKey(chainId: string): Promise<Key>;
242
- /**
243
- * Get offline signer that only supports Amino signing
244
- * @param chainId - The chain identifier
245
- */
246
- getOfflineSignerOnlyAmino(chainId: string): OfflineAminoSigner;
247
- /**
248
- * Get hybrid offline signer supporting both Amino and Direct signing
249
- * @param chainId - The chain identifier
250
- */
251
- getOfflineSigner(chainId: string): OfflineAminoSigner & OfflineDirectSigner;
252
- /**
253
- * Get offline signer, automatically choosing between Amino and Direct
254
- * @param chainId - The chain identifier
255
- */
256
- getOfflineSignerAuto(chainId: string): Promise<OfflineAminoSigner | OfflineDirectSigner>;
257
- /**
258
- * Sign transaction using Amino format
259
- * @param chainId - The chain identifier
260
- * @param signer - The signer address
261
- * @param signDoc - The Amino sign document
262
- * @param signOptions - Optional signing options
263
- */
264
- signAmino(chainId: string, signer: string, signDoc: StdSignDoc, signOptions?: KeplrSignOptions): Promise<AminoSignResponse>;
265
- /**
266
- * Sign transaction using Direct/Protobuf format
267
- * @param chainId - The chain identifier
268
- * @param signer - The signer address
269
- * @param signDoc - The Direct sign document
270
- * @param signOptions - Optional signing options
271
- */
272
- signDirect(chainId: string, signer: string, signDoc: SignDoc, signOptions?: KeplrSignOptions): Promise<DirectSignResponse>;
273
- /**
274
- * Sign arbitrary data
275
- * @param chainId - The chain identifier
276
- * @param signer - The signer address
277
- * @param data - Data to sign (string or bytes)
278
- */
279
- signArbitrary(chainId: string, signer: string, data: string | Uint8Array): Promise<StdSignature>;
280
- }
281
301
 
282
302
  interface ChainConfig {
283
303
  path?: string;
@@ -324,6 +344,14 @@ interface GrazInternalStore {
324
344
  * Interval in milliseconds to ping the wallet.
325
345
  */
326
346
  pingInterval: number;
347
+ /**
348
+ * Logger configuration
349
+ */
350
+ loggerConfig: {
351
+ enabled: boolean;
352
+ level?: LogLevel | LogLevel[];
353
+ categories?: (keyof typeof LogCategory)[];
354
+ } | null;
327
355
  _notFoundFn: () => void;
328
356
  _reconnect: boolean;
329
357
  _reconnectConnector: WalletType | null;
@@ -354,6 +382,14 @@ interface ConfigureGrazArgs {
354
382
  */
355
383
  iframeOptions?: IframeOptions;
356
384
  pingInteval?: number;
385
+ /**
386
+ * Logger configuration
387
+ */
388
+ logger?: {
389
+ enabled?: boolean;
390
+ level?: LogLevel | LogLevel[] | undefined;
391
+ categories?: (keyof typeof LogCategory)[] | undefined;
392
+ };
357
393
  }
358
394
  declare const configureGraz: (args: ConfigureGrazArgs) => ConfigureGrazArgs;
359
395
 
@@ -440,6 +476,88 @@ declare const isLeapDappBrowser: () => boolean;
440
476
  declare const isWalletConnect: (type: WalletType) => boolean;
441
477
  declare const isPara: (type: WalletType) => type is WalletType.PARA;
442
478
 
479
+ /**
480
+ * Logger Categories
481
+ * Used for categorizing logs throughout the Graz library
482
+ */
483
+ declare const LOG_CATEGORIES: {
484
+ /** Wallet connections, disconnections, and adapter operations */
485
+ readonly WALLET: "wallet";
486
+ /** Transaction signing and broadcasting */
487
+ readonly TRANSACTION: "transaction";
488
+ /** Blockchain queries (balance, contract queries, etc.) */
489
+ readonly QUERY: "query";
490
+ /** State management operations (store updates) */
491
+ readonly STORE: "store";
492
+ /** Multi-chain parallel operations */
493
+ readonly MULTICHAIN: "multichain";
494
+ /** Wallet events and listeners */
495
+ readonly EVENT: "event";
496
+ /** Performance metrics and timing */
497
+ readonly PERFORMANCE: "performance";
498
+ };
499
+ /**
500
+ * Logger Function Names
501
+ * Action/method function names used in logging context
502
+ */
503
+ declare const LOG_FUNCTIONS: {
504
+ readonly CONNECT: "connect";
505
+ readonly DISCONNECT: "disconnect";
506
+ readonly RECONNECT: "reconnect";
507
+ readonly GET_WALLET: "getWallet";
508
+ readonly CLEAR_RECENT_CHAIN: "clearRecentChain";
509
+ readonly GET_RECENT_CHAIN_IDS: "getRecentChainIds";
510
+ readonly GET_RECENT_CHAINS: "getRecentChains";
511
+ readonly GET_CHAIN_INFO: "getChainInfo";
512
+ readonly GET_CHAIN_INFOS: "getChainInfos";
513
+ readonly ADD_CHAIN: "addChain";
514
+ readonly SUGGEST_CHAIN: "suggestChain";
515
+ readonly SUGGEST_CHAIN_AND_CONNECT: "suggestChainAndConnect";
516
+ readonly SEND_TOKENS: "sendTokens";
517
+ readonly SEND_IBC_TOKENS: "sendIbcTokens";
518
+ readonly INSTANTIATE_CONTRACT: "instantiateContract";
519
+ readonly EXECUTE_CONTRACT: "executeContract";
520
+ readonly GET_QUERY_SMART: "getQuerySmart";
521
+ readonly GET_QUERY_RAW: "getQueryRaw";
522
+ readonly CREATE_MULTI_CHAIN_ASYNC_FUNCTION: "createMultiChainAsyncFunction";
523
+ readonly HANDLE_FOCUS: "handleFocus";
524
+ readonly AUTO_CONNECT_IFRAME: "autoConnectIframe";
525
+ readonly RECONNECT_EFFECT: "reconnectEffect";
526
+ readonly SUBSCRIPTION: "subscription";
527
+ };
528
+ /**
529
+ * Logger Hook Names
530
+ * React hook names used in logging context
531
+ */
532
+ declare const LOG_HOOKS: {
533
+ readonly USE_CONNECT: "useConnect";
534
+ readonly USE_DISCONNECT: "useDisconnect";
535
+ readonly USE_CHECK_WALLET: "useCheckWallet";
536
+ readonly USE_ADD_CHAIN: "useAddChain";
537
+ readonly USE_SUGGEST_CHAIN: "useSuggestChain";
538
+ readonly USE_SUGGEST_CHAIN_AND_CONNECT: "useSuggestChainAndConnect";
539
+ readonly USE_STARGATE_CLIENT: "useStargateClient";
540
+ readonly USE_COSMWASM_CLIENT: "useCosmWasmClient";
541
+ readonly USE_STARGATE_SIGNING_CLIENT: "useStargateSigningClient";
542
+ readonly USE_COSMWASM_SIGNING_CLIENT: "useCosmWasmSigningClient";
543
+ readonly USE_SEND_TOKENS: "useSendTokens";
544
+ readonly USE_SEND_IBC_TOKENS: "useSendIbcTokens";
545
+ readonly USE_INSTANTIATE_CONTRACT: "useInstantiateContract";
546
+ readonly USE_EXECUTE_CONTRACT: "useExecuteContract";
547
+ };
548
+
549
+ /**
550
+ * Get the singleton logger instance
551
+ * @returns Logger instance
552
+ */
553
+ declare const getLogger: () => Logger;
554
+ /**
555
+ * Configure the logger with custom options
556
+ * This will recreate the logger instance with new options
557
+ * @param options Logger configuration options
558
+ */
559
+ declare const configureLogger: (options: LoggerOptions) => void;
560
+
443
561
  type CactusCosmosWallet = Pick<Keplr, "enable" | "getOfflineSigner" | "signDirect" | "signAmino" | "signArbitrary" | "getKey">;
444
562
  declare const getCactusCosmos: () => Wallet;
445
563
 
@@ -867,7 +985,7 @@ declare const useDisconnect: ({ onError, onLoading, onSuccess }?: MutationEventA
867
985
  declare function useOfflineSigners<const TChainIds extends readonly string[]>(args: {
868
986
  chainId: TChainIds;
869
987
  }): UseMultiChainQueryResult<TChainIds, OfflineSigners>;
870
- declare function useOfflineSigners(args?: {}): UseMultiChainQueryResult<undefined, OfflineSigners>;
988
+ declare function useOfflineSigners(args?: Record<string, never>): UseMultiChainQueryResult<undefined, OfflineSigners>;
871
989
  /**
872
990
  * graz query hook to retrieve staked balance for a specific chain and address.
873
991
  *
@@ -1752,11 +1870,20 @@ interface GrazProviderProps {
1752
1870
  * Graz uses `@tanstack/react-query`'s features under the hood, hence you need to wrap `GrazProvider` with `QueryClientProvider`.
1753
1871
  * @example
1754
1872
  * ```tsx
1873
+ * import { GrazProvider, LogLevel } from "graz";
1874
+ *
1755
1875
  * // example next.js application in _app.tsx
1756
1876
  * export default function CustomApp({ Component, pageProps }: AppProps) {
1757
1877
  * return (
1758
1878
  * <QueryClientProvider queryClient={queryClient}>
1759
- * <GrazProvider grazOptions={grazOptions}>
1879
+ * <GrazProvider grazOptions={{
1880
+ * chains: [cosmoshubChainInfo, osmosisChainInfo],
1881
+ * logger: {
1882
+ * enabled: true,
1883
+ * level: LogLevel.DEBUG,
1884
+ * categories: ['wallet', 'transaction'],
1885
+ * }
1886
+ * }}>
1760
1887
  * <Component {...pageProps} />
1761
1888
  * </GrazProvider>
1762
1889
  * </QueryClientProvider>
@@ -1781,4 +1908,4 @@ declare const useGrazEvents: () => null;
1781
1908
  */
1782
1909
  declare const GrazEvents: FC;
1783
1910
 
1784
- export { type ActionChainId, type AddChainArgs, type CactusCosmosWallet, type ConfigureGrazArgs, type ConnectArgs, type ConnectResult, type Dictionary, type ExecuteContractArgs, type ExecuteContractMutationArgs, GrazEvents, GrazProvider, type GrazProviderProps, type InstantiateContractArgs, type InstantiateContractMutationArgs, type Key, type KnownKeys, type Maybe, type OfflineSigners, type ParaGrazConfig, type ParaGrazConnector, type ParaGrazConnectorEvents, type ParaModalProps, type ParaWallet, type ReconnectArgs, type SendIbcTokensArgs, type SendTokensArgs, type SignAminoParams, type SignDirectParams, type SignDoc, type SuggestChainAndConnectArgs, type SuggestChainArgs, type UseAccountArgs, type UseAccountResult, type UseAddChainArgs, type UseConnectChainArgs, type UseExecuteContractArgs, type UseInstantiateContractArgs, type UseSuggestChainAndConnectArgs, type UseSuggestChainArgs, WALLET_TYPES, type Wallet, WalletType, addChain, checkWallet, clearRecentChain, clearSession, configureGraz, connect, defineChainInfo, defineChains, disconnect, executeContract, getAvailableWallets, getCactusCosmos, getChainInfo, getChainInfos, getCosmostation, getKeplr, getLeap, getMetamaskSnapLeap, getOfflineSigners, getOkx, getPara, getQueryRaw, getQuerySmart, getRecentChainIds, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, isLeapDappBrowser, isLeapSnaps, isPara, isWalletConnect, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, useAccount, useActiveChainCurrency, useActiveChainIds, useActiveChains, useActiveWalletType, useAddChain, useBalance, useBalanceStaked, useBalances, useChainInfo, useChainInfos, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClientValidators, useQueryRaw, useQuerySmart, useRecentChainIds, useRecentChains, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useSuggestChain, useSuggestChainAndConnect };
1911
+ export { type ActionChainId, type AddChainArgs, type CactusCosmosWallet, type ConfigureGrazArgs, type ConnectArgs, type ConnectResult, type Dictionary, type ErrorReporter, type ExecuteContractArgs, type ExecuteContractMutationArgs, GrazEvents, GrazProvider, type GrazProviderProps, type InstantiateContractArgs, type InstantiateContractMutationArgs, type Key, type KnownKeys, LOG_CATEGORIES, LOG_FUNCTIONS, LOG_HOOKS, LogCategory, LogLevel, type Logger, type LoggerOptions, type Maybe, type OfflineSigners, type ParaGrazConfig, type ParaGrazConnectorEvents, type ParaModalProps, type ParaWallet, type ReconnectArgs, type SendIbcTokensArgs, type SendTokensArgs, type SignAminoParams, type SignDirectParams, type SignDoc, type SuggestChainAndConnectArgs, type SuggestChainArgs, type UseAccountArgs, type UseAccountResult, type UseAddChainArgs, type UseConnectChainArgs, type UseExecuteContractArgs, type UseInstantiateContractArgs, type UseSuggestChainAndConnectArgs, type UseSuggestChainArgs, WALLET_TYPES, type Wallet, WalletType, addChain, checkWallet, clearRecentChain, clearSession, configureGraz, configureLogger, connect, defineChainInfo, defineChains, disconnect, executeContract, getAvailableWallets, getCactusCosmos, getChainInfo, getChainInfos, getCosmostation, getKeplr, getLeap, getLogger, getMetamaskSnapLeap, getOfflineSigners, getOkx, getPara, getQueryRaw, getQuerySmart, getRecentChainIds, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, isLeapDappBrowser, isLeapSnaps, isPara, isWalletConnect, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, useAccount, useActiveChainCurrency, useActiveChainIds, useActiveChains, useActiveWalletType, useAddChain, useBalance, useBalanceStaked, useBalances, useChainInfo, useChainInfos, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClientValidators, useQueryRaw, useQuerySmart, useRecentChainIds, useRecentChains, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useSuggestChain, useSuggestChainAndConnect };