@solana/react-hooks 0.0.0 → 0.1.0
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/README.md +114 -25
- package/dist/index.browser.cjs +1333 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.mjs +1294 -0
- package/dist/index.browser.mjs.map +1 -0
- package/dist/index.native.mjs +1294 -0
- package/dist/index.native.mjs.map +1 -0
- package/dist/index.node.cjs +1333 -0
- package/dist/index.node.cjs.map +1 -0
- package/dist/index.node.mjs +1294 -0
- package/dist/index.node.mjs.map +1 -0
- package/dist/types/QueryProvider.d.ts +11 -0
- package/dist/types/QueryProvider.d.ts.map +1 -0
- package/dist/types/SolanaProvider.d.ts +35 -0
- package/dist/types/SolanaProvider.d.ts.map +1 -0
- package/dist/types/context.d.ts +22 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/hooks.d.ts +208 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/query.d.ts +20 -0
- package/dist/types/query.d.ts.map +1 -0
- package/dist/types/queryHooks.d.ts +43 -0
- package/dist/types/queryHooks.d.ts.map +1 -0
- package/dist/types/querySuspenseContext.d.ts +4 -0
- package/dist/types/querySuspenseContext.d.ts.map +1 -0
- package/dist/types/ui.d.ts +52 -0
- package/dist/types/ui.d.ts.map +1 -0
- package/dist/types/useClientStore.d.ts +6 -0
- package/dist/types/useClientStore.d.ts.map +1 -0
- package/dist/types/walletStandardHooks.d.ts +78 -0
- package/dist/types/walletStandardHooks.d.ts.map +1 -0
- package/package.json +88 -84
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SolanaClient } from '@solana/client';
|
|
2
|
+
import { type BareFetcher, type SWRConfiguration, type SWRResponse } from 'swr';
|
|
3
|
+
export type QueryStatus = 'error' | 'idle' | 'loading' | 'success';
|
|
4
|
+
export type UseSolanaRpcQueryOptions<Data> = Omit<SWRConfiguration<Data, unknown, BareFetcher<Data>>, 'fallback' | 'suspense'> & Readonly<{
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
export type SolanaQueryResult<Data> = Readonly<{
|
|
8
|
+
data: Data | undefined;
|
|
9
|
+
dataUpdatedAt?: number;
|
|
10
|
+
error: unknown;
|
|
11
|
+
isError: boolean;
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
isSuccess: boolean;
|
|
14
|
+
isValidating: boolean;
|
|
15
|
+
mutate: SWRResponse<Data>['mutate'];
|
|
16
|
+
refresh(): Promise<Data | undefined>;
|
|
17
|
+
status: QueryStatus;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function useSolanaRpcQuery<Data>(scope: string, args: readonly unknown[], fetcher: (client: SolanaClient) => Promise<Data>, options?: UseSolanaRpcQueryOptions<Data>): SolanaQueryResult<Data>;
|
|
20
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAe,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAQxF,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnE,MAAM,MAAM,wBAAwB,CAAC,IAAI,IAAI,IAAI,CAChD,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,EAClD,UAAU,GAAG,UAAU,CACvB,GACA,QAAQ,CAAC;IACR,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC,CAAC;AAEJ,MAAM,MAAM,iBAAiB,CAAC,IAAI,IAAI,QAAQ,CAAC;IAC9C,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC;IACpC,OAAO,IAAI,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;IACrC,MAAM,EAAE,WAAW,CAAC;CACpB,CAAC,CAAC;AAEH,wBAAgB,iBAAiB,CAAC,IAAI,EACrC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,SAAS,OAAO,EAAE,EACxB,OAAO,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,EAChD,OAAO,GAAE,wBAAwB,CAAC,IAAI,CAAM,GAC1C,iBAAiB,CAAC,IAAI,CAAC,CAmDzB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type AddressLike, type SolanaClient } from '@solana/client';
|
|
2
|
+
import { type Base64EncodedWireTransaction, type Commitment, type SendableTransaction, type Transaction } from '@solana/kit';
|
|
3
|
+
import type { SolanaQueryResult, UseSolanaRpcQueryOptions } from './query';
|
|
4
|
+
type RpcInstance = SolanaClient['runtime']['rpc'];
|
|
5
|
+
type LatestBlockhashPlan = ReturnType<RpcInstance['getLatestBlockhash']>;
|
|
6
|
+
type LatestBlockhashResponse = Awaited<ReturnType<LatestBlockhashPlan['send']>>;
|
|
7
|
+
type ProgramAccountsPlan = ReturnType<RpcInstance['getProgramAccounts']>;
|
|
8
|
+
type ProgramAccountsConfig = Parameters<RpcInstance['getProgramAccounts']>[1];
|
|
9
|
+
type ProgramAccountsResponse = Awaited<ReturnType<ProgramAccountsPlan['send']>>;
|
|
10
|
+
type SimulateTransactionPlan = ReturnType<RpcInstance['simulateTransaction']>;
|
|
11
|
+
type SimulateTransactionConfig = Parameters<RpcInstance['simulateTransaction']>[1];
|
|
12
|
+
type SimulateTransactionResponse = Awaited<ReturnType<SimulateTransactionPlan['send']>>;
|
|
13
|
+
export type UseLatestBlockhashOptions = Omit<UseSolanaRpcQueryOptions<LatestBlockhashResponse>, 'refreshInterval'> & Readonly<{
|
|
14
|
+
commitment?: Commitment;
|
|
15
|
+
minContextSlot?: bigint | number;
|
|
16
|
+
refreshInterval?: number;
|
|
17
|
+
}>;
|
|
18
|
+
export type LatestBlockhashQueryResult = SolanaQueryResult<LatestBlockhashResponse> & Readonly<{
|
|
19
|
+
blockhash: string | null;
|
|
20
|
+
contextSlot: bigint | null | undefined;
|
|
21
|
+
lastValidBlockHeight: bigint | null;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function useLatestBlockhash(options?: UseLatestBlockhashOptions): LatestBlockhashQueryResult;
|
|
24
|
+
export type UseProgramAccountsOptions = UseSolanaRpcQueryOptions<ProgramAccountsResponse> & Readonly<{
|
|
25
|
+
commitment?: Commitment;
|
|
26
|
+
config?: ProgramAccountsConfig;
|
|
27
|
+
}>;
|
|
28
|
+
export type ProgramAccountsQueryResult = SolanaQueryResult<ProgramAccountsResponse> & Readonly<{
|
|
29
|
+
accounts: ProgramAccountsResponse;
|
|
30
|
+
}>;
|
|
31
|
+
export declare function useProgramAccounts(programAddress?: AddressLike, options?: UseProgramAccountsOptions): ProgramAccountsQueryResult;
|
|
32
|
+
export type UseSimulateTransactionOptions = Omit<UseSolanaRpcQueryOptions<SimulateTransactionResponse>, 'refreshInterval'> & Readonly<{
|
|
33
|
+
commitment?: Commitment;
|
|
34
|
+
config?: SimulateTransactionConfig;
|
|
35
|
+
refreshInterval?: number;
|
|
36
|
+
}>;
|
|
37
|
+
export type SimulateTransactionQueryResult = SolanaQueryResult<SimulateTransactionResponse> & Readonly<{
|
|
38
|
+
logs: readonly string[];
|
|
39
|
+
}>;
|
|
40
|
+
type SimulationInput = (SendableTransaction & Transaction) | Base64EncodedWireTransaction | string;
|
|
41
|
+
export declare function useSimulateTransaction(transaction?: SimulationInput | null, options?: UseSimulateTransactionOptions): SimulateTransactionQueryResult;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=queryHooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryHooks.d.ts","sourceRoot":"","sources":["../../src/queryHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAA+C,MAAM,gBAAgB,CAAC;AAClH,OAAO,EACN,KAAK,4BAA4B,EACjC,KAAK,UAAU,EAEf,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAG3E,KAAK,WAAW,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;AAElD,KAAK,mBAAmB,GAAG,UAAU,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAC;AACzE,KAAK,uBAAuB,GAAG,OAAO,CAAC,UAAU,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAEhF,KAAK,mBAAmB,GAAG,UAAU,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAC;AACzE,KAAK,qBAAqB,GAAG,UAAU,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9E,KAAK,uBAAuB,GAAG,OAAO,CAAC,UAAU,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAEhF,KAAK,uBAAuB,GAAG,UAAU,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,CAAC;AAC9E,KAAK,yBAAyB,GAAG,UAAU,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnF,KAAK,2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AAE,yBAAyB,CAAC;IACnC,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC,CAAC;AAEJ,MAAM,MAAM,8BAA8B,GAAG,iBAAiB,CAAC,2BAA2B,CAAC,GAC1F,QAAQ,CAAC;IACR,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CACxB,CAAC,CAAC;AAEJ,KAAK,eAAe,GAAG,CAAC,mBAAmB,GAAG,WAAW,CAAC,GAAG,4BAA4B,GAAG,MAAM,CAAC;AAEnG,wBAAgB,sBAAsB,CACrC,WAAW,CAAC,EAAE,eAAe,GAAG,IAAI,EACpC,OAAO,CAAC,EAAE,6BAA6B,GACrC,8BAA8B,CAuChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"querySuspenseContext.d.ts","sourceRoot":"","sources":["../../src/querySuspenseContext.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,oBAAoB,8CAAgD,CAAC;AAE3E,wBAAgB,0BAA0B,IAAI,OAAO,GAAG,SAAS,CAEhE;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { WalletConnector, WalletSession, WalletStatus } from '@solana/client';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import { type WalletStandardDiscoveryOptions } from './hooks';
|
|
4
|
+
type WalletConnectionState = Readonly<{
|
|
5
|
+
connect(connectorId: string, options?: Readonly<{
|
|
6
|
+
autoConnect?: boolean;
|
|
7
|
+
}>): Promise<void>;
|
|
8
|
+
connected: boolean;
|
|
9
|
+
connecting: boolean;
|
|
10
|
+
connectors: readonly WalletConnector[];
|
|
11
|
+
connectorId?: string;
|
|
12
|
+
disconnect(): Promise<void>;
|
|
13
|
+
error: unknown;
|
|
14
|
+
status: WalletStatus['status'];
|
|
15
|
+
wallet: WalletSession | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
type UseWalletConnectionOptions = Readonly<{
|
|
18
|
+
connectors?: readonly WalletConnector[];
|
|
19
|
+
discoveryOptions?: WalletStandardDiscoveryOptions;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Collects everything needed to build wallet connection UIs into a single hook.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useWalletConnection(options?: UseWalletConnectionOptions): WalletConnectionState;
|
|
25
|
+
type WalletConnectionManagerProps = Readonly<{
|
|
26
|
+
children: (state: WalletConnectionState) => ReactNode;
|
|
27
|
+
connectors?: readonly WalletConnector[];
|
|
28
|
+
discoveryOptions?: WalletStandardDiscoveryOptions;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Render-prop helper that lets you easily wire wallet status into custom UIs.
|
|
32
|
+
*/
|
|
33
|
+
export declare function WalletConnectionManager({ children, connectors, discoveryOptions }: WalletConnectionManagerProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
type UseWalletModalStateOptions = UseWalletConnectionOptions & Readonly<{
|
|
35
|
+
closeOnConnect?: boolean;
|
|
36
|
+
initialOpen?: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
export type WalletModalState = WalletConnectionState & Readonly<{
|
|
39
|
+
close(): void;
|
|
40
|
+
isOpen: boolean;
|
|
41
|
+
open(): void;
|
|
42
|
+
selectedConnector: string | null;
|
|
43
|
+
select(connectorId: string | null): void;
|
|
44
|
+
toggle(): void;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Small state machine for wallet selection modals – keeps track of modal visibility and the currently
|
|
48
|
+
* highlighted connector while reusing the connection state returned by {@link useWalletConnection}.
|
|
49
|
+
*/
|
|
50
|
+
export declare function useWalletModalState(options?: UseWalletModalStateOptions): WalletModalState;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE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G/G;AAED,KAAK,0BAA0B,GAAG,0BAA0B,GAC3D,QAAQ,CAAC;IACR,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC,CAAC;AAEJ,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,GACnD,QAAQ,CAAC;IACR,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,IAAI,IAAI,CAAC;IACb,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IACzC,MAAM,IAAI,IAAI,CAAC;CACf,CAAC,CAAC;AAEJ;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,0BAA+B,GAAG,gBAAgB,CAgC9F"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ClientState } from '@solana/client';
|
|
2
|
+
type Selector<T> = (state: ClientState) => T;
|
|
3
|
+
export declare function useClientStore(): ClientState;
|
|
4
|
+
export declare function useClientStore<T>(selector: Selector<T>): T;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=useClientStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClientStore.d.ts","sourceRoot":"","sources":["../../src/useClientStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAKlD,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,KAAK,CAAC,CAAC;AAG7C,wBAAgB,cAAc,IAAI,WAAW,CAAC;AAC9C,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { MessageModifyingSigner, TransactionModifyingSigner, TransactionSendingSigner } from '@solana/signers';
|
|
2
|
+
import { type SolanaSignAndSendTransactionInput, type SolanaSignAndSendTransactionOutput, type SolanaSignInInput, type SolanaSignInOutput, type SolanaSignMessageInput, type SolanaSignMessageOutput, type SolanaSignTransactionInput, type SolanaSignTransactionOutput } from '@solana/wallet-standard-features';
|
|
3
|
+
import type { IdentifierArray } from '@wallet-standard/base';
|
|
4
|
+
import type { UiWallet, UiWalletAccount } from '@wallet-standard/ui';
|
|
5
|
+
type AssertSolanaChain<T> = T extends `solana:${string}` ? T : never;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `@solana/react` for Wallet Standard hooks; this shim will be removed in a future release.
|
|
8
|
+
*/
|
|
9
|
+
export type OnlySolanaChains<T extends IdentifierArray> = T extends IdentifierArray ? AssertSolanaChain<T[number]> : never;
|
|
10
|
+
type SignAndSendInput = Readonly<Omit<SolanaSignAndSendTransactionInput, 'account' | 'chain' | 'options'> & {
|
|
11
|
+
options?: Readonly<{
|
|
12
|
+
minContextSlot?: bigint;
|
|
13
|
+
}>;
|
|
14
|
+
}>;
|
|
15
|
+
type SignAndSendOutput = SolanaSignAndSendTransactionOutput;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use `@solana/react` for Wallet Standard hooks; this shim will be removed in a future release.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useSignAndSendTransaction<TWalletAccount extends UiWalletAccount>(uiWalletAccount: TWalletAccount, chain: OnlySolanaChains<TWalletAccount['chains']>): (input: SignAndSendInput) => Promise<SignAndSendOutput>;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use `@solana/react` for Wallet Standard hooks; this shim will be removed in a future release.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useSignAndSendTransaction<TWalletAccount extends UiWalletAccount>(uiWalletAccount: TWalletAccount, chain: `solana:${string}`): (input: SignAndSendInput) => Promise<SignAndSendOutput>;
|
|
24
|
+
type SignInInput = SolanaSignInInput;
|
|
25
|
+
type SignInOutput = Omit<SolanaSignInOutput, 'account' | 'signatureType'> & Readonly<{
|
|
26
|
+
account: UiWalletAccount;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use `@solana/react` for Wallet Standard hooks; this shim will be removed in a future release.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useSignIn(uiWalletAccount: UiWalletAccount): (input?: Omit<SignInInput, 'address'>) => Promise<SignInOutput>;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use `@solana/react` for Wallet Standard hooks; this shim will be removed in a future release.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useSignIn(uiWallet: UiWallet): (input?: SignInInput) => Promise<SignInOutput>;
|
|
36
|
+
type SignMessageInput = Omit<SolanaSignMessageInput, 'account'>;
|
|
37
|
+
type SignMessageOutput = Omit<SolanaSignMessageOutput, 'signatureType'>;
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated Use `@solana/react` for Wallet Standard hooks; this shim will be removed in a future release.
|
|
40
|
+
*/
|
|
41
|
+
export declare function useSignMessage<TWalletAccount extends UiWalletAccount>(...config: Parameters<typeof useSignMessages<TWalletAccount>>): (input: SignMessageInput) => Promise<SignMessageOutput>;
|
|
42
|
+
declare function useSignMessages<TWalletAccount extends UiWalletAccount>(uiWalletAccount: TWalletAccount): (...inputs: readonly SignMessageInput[]) => Promise<readonly SignMessageOutput[]>;
|
|
43
|
+
type SignTransactionInput = Readonly<Omit<SolanaSignTransactionInput, 'account' | 'chain' | 'options'> & {
|
|
44
|
+
options?: Readonly<{
|
|
45
|
+
minContextSlot?: bigint;
|
|
46
|
+
}>;
|
|
47
|
+
}>;
|
|
48
|
+
type SignTransactionOutput = SolanaSignTransactionOutput;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Use `@solana/react` for Wallet Standard hooks; this shim will be removed in a future release.
|
|
51
|
+
*/
|
|
52
|
+
export declare function useSignTransaction<TWalletAccount extends UiWalletAccount>(uiWalletAccount: TWalletAccount, chain: OnlySolanaChains<TWalletAccount['chains']>): (input: SignTransactionInput) => Promise<SignTransactionOutput>;
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated Use `@solana/react` for Wallet Standard hooks; this shim will be removed in a future release.
|
|
55
|
+
*/
|
|
56
|
+
export declare function useSignTransaction<TWalletAccount extends UiWalletAccount>(uiWalletAccount: TWalletAccount, chain: `solana:${string}`): (input: SignTransactionInput) => Promise<SignTransactionOutput>;
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated Use `@solana/react` for Wallet Standard hooks; this shim will be removed in a future release.
|
|
59
|
+
*/
|
|
60
|
+
export declare function useWalletAccountMessageSigner<TWalletAccount extends UiWalletAccount>(uiWalletAccount: TWalletAccount): MessageModifyingSigner<TWalletAccount['address']>;
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Use `@solana/react` for Wallet Standard hooks; this shim will be removed in a future release.
|
|
63
|
+
*/
|
|
64
|
+
export declare function useWalletAccountTransactionSigner<TWalletAccount extends UiWalletAccount>(uiWalletAccount: TWalletAccount, chain: OnlySolanaChains<TWalletAccount['chains']>): TransactionModifyingSigner<TWalletAccount['address']>;
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated Use `@solana/react` for Wallet Standard hooks; this shim will be removed in a future release.
|
|
67
|
+
*/
|
|
68
|
+
export declare function useWalletAccountTransactionSigner<TWalletAccount extends UiWalletAccount>(uiWalletAccount: TWalletAccount, chain: `solana:${string}`): TransactionModifyingSigner<TWalletAccount['address']>;
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Use `@solana/react` for Wallet Standard hooks; this shim will be removed in a future release.
|
|
71
|
+
*/
|
|
72
|
+
export declare function useWalletAccountTransactionSendingSigner<TWalletAccount extends UiWalletAccount>(uiWalletAccount: TWalletAccount, chain: OnlySolanaChains<TWalletAccount['chains']>): TransactionSendingSigner<TWalletAccount['address']>;
|
|
73
|
+
/**
|
|
74
|
+
* @deprecated Use `@solana/react` for Wallet Standard hooks; this shim will be removed in a future release.
|
|
75
|
+
*/
|
|
76
|
+
export declare function useWalletAccountTransactionSendingSigner<TWalletAccount extends UiWalletAccount>(uiWalletAccount: TWalletAccount, chain: `solana:${string}`): TransactionSendingSigner<TWalletAccount['address']>;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=walletStandardHooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletStandardHooks.d.ts","sourceRoot":"","sources":["../../src/walletStandardHooks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACX,sBAAsB,EAEtB,0BAA0B,EAC1B,wBAAwB,EACxB,MAAM,iBAAiB,CAAC;AASzB,OAAO,EAGN,KAAK,iCAAiC,EACtC,KAAK,kCAAkC,EAGvC,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EAGvB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAG5B,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAkB,MAAM,qBAAqB,CAAC;AASrF,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,eAAe,IAAI,CAAC,SAAS,eAAe,GAChF,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAC5B,KAAK,CAAC;AAET,KAAK,gBAAgB,GAAG,QAAQ,CAC/B,IAAI,CAAC,iCAAiC,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC,GAAG;IAC1E,OAAO,CAAC,EAAE,QAAQ,CAAC;QAClB,cAAc,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC,CAAC;CACH,CACD,CAAC;AACF,KAAK,iBAAiB,GAAG,kCAAkC,CAAC;AAE5D;;GAEG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
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
2
|
+
"name": "@solana/react-hooks",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React hooks for the @solana/client Solana client",
|
|
5
|
+
"exports": {
|
|
6
|
+
"edge-light": {
|
|
7
|
+
"import": "./dist/index.node.mjs",
|
|
8
|
+
"require": "./dist/index.node.cjs"
|
|
9
|
+
},
|
|
10
|
+
"workerd": {
|
|
11
|
+
"import": "./dist/index.node.mjs",
|
|
12
|
+
"require": "./dist/index.node.cjs"
|
|
13
|
+
},
|
|
14
|
+
"browser": {
|
|
15
|
+
"import": "./dist/index.browser.mjs",
|
|
16
|
+
"require": "./dist/index.browser.cjs"
|
|
17
|
+
},
|
|
18
|
+
"node": {
|
|
19
|
+
"import": "./dist/index.node.mjs",
|
|
20
|
+
"require": "./dist/index.node.cjs"
|
|
21
|
+
},
|
|
22
|
+
"react-native": "./dist/index.native.mjs",
|
|
23
|
+
"types": "./dist/types/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"browser": {
|
|
26
|
+
"./dist/index.node.cjs": "./dist/index.browser.cjs",
|
|
27
|
+
"./dist/index.node.mjs": "./dist/index.browser.mjs"
|
|
28
|
+
},
|
|
29
|
+
"main": "./dist/index.node.cjs",
|
|
30
|
+
"module": "./dist/index.node.mjs",
|
|
31
|
+
"react-native": "./dist/index.native.mjs",
|
|
32
|
+
"types": "./dist/types/index.d.ts",
|
|
33
|
+
"type": "commonjs",
|
|
34
|
+
"files": [
|
|
35
|
+
"./dist/"
|
|
36
|
+
],
|
|
37
|
+
"sideEffects": false,
|
|
38
|
+
"keywords": [
|
|
39
|
+
"solana",
|
|
40
|
+
"web3",
|
|
41
|
+
"react",
|
|
42
|
+
"hooks"
|
|
43
|
+
],
|
|
44
|
+
"author": "Solana Maintainers <maintainers@solana.foundation>",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/solana-foundation/framework-kit"
|
|
48
|
+
},
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@solana/addresses": "^5.0.0",
|
|
52
|
+
"@solana/codecs-core": "^5.0.0",
|
|
53
|
+
"@solana/errors": "^5.0.0",
|
|
54
|
+
"@solana/keys": "^5.0.0",
|
|
55
|
+
"@solana/promises": "^5.0.0",
|
|
56
|
+
"@solana/signers": "^5.0.0",
|
|
57
|
+
"@solana/transaction-messages": "^5.0.0",
|
|
58
|
+
"@solana/transactions": "^5.0.0",
|
|
59
|
+
"@solana/wallet-standard-features": "^1.3.0",
|
|
60
|
+
"@solana/kit": "^5.0.0",
|
|
61
|
+
"swr": "^2.3.6",
|
|
62
|
+
"zustand": "^5.0.0",
|
|
63
|
+
"@wallet-standard/base": "^1.1.0",
|
|
64
|
+
"@wallet-standard/errors": "^0.1.1",
|
|
65
|
+
"@wallet-standard/ui": "^1.0.1",
|
|
66
|
+
"@wallet-standard/ui-registry": "^1.0.1",
|
|
67
|
+
"@solana/client": "0.1.0"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@types/react": "^19",
|
|
71
|
+
"react": "^19.0.0"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"react": ">=18"
|
|
75
|
+
},
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=20.18.0"
|
|
78
|
+
},
|
|
79
|
+
"scripts": {
|
|
80
|
+
"build": "pnpm compile:js && pnpm compile:typedefs",
|
|
81
|
+
"compile:js": "tsup --config ../build-scripts/tsup.config.package.ts",
|
|
82
|
+
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
|
|
83
|
+
"format": "biome check --write src",
|
|
84
|
+
"lint": "biome check src",
|
|
85
|
+
"test:typecheck": "tsc --noEmit",
|
|
86
|
+
"test": "vitest run --config ../../vitest.config.ts",
|
|
87
|
+
"typecheck": "pnpm test:typecheck"
|
|
88
|
+
}
|
|
89
|
+
}
|