@account-kit/privy-integration 4.68.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/LICENSE +21 -0
- package/README.md +372 -0
- package/dist/esm/Provider.d.ts +61 -0
- package/dist/esm/Provider.js +100 -0
- package/dist/esm/Provider.js.map +1 -0
- package/dist/esm/hooks/internal/useEmbeddedWallet.d.ts +10 -0
- package/dist/esm/hooks/internal/useEmbeddedWallet.js +22 -0
- package/dist/esm/hooks/internal/useEmbeddedWallet.js.map +1 -0
- package/dist/esm/hooks/useAlchemyClient.d.ts +17 -0
- package/dist/esm/hooks/useAlchemyClient.js +119 -0
- package/dist/esm/hooks/useAlchemyClient.js.map +1 -0
- package/dist/esm/hooks/useAlchemyPrepareSwap.d.ts +42 -0
- package/dist/esm/hooks/useAlchemyPrepareSwap.js +95 -0
- package/dist/esm/hooks/useAlchemyPrepareSwap.js.map +1 -0
- package/dist/esm/hooks/useAlchemySendTransaction.d.ts +26 -0
- package/dist/esm/hooks/useAlchemySendTransaction.js +127 -0
- package/dist/esm/hooks/useAlchemySendTransaction.js.map +1 -0
- package/dist/esm/hooks/useAlchemySubmitSwap.d.ts +31 -0
- package/dist/esm/hooks/useAlchemySubmitSwap.js +93 -0
- package/dist/esm/hooks/useAlchemySubmitSwap.js.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.d.ts +124 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/util/getChain.d.ts +1 -0
- package/dist/esm/util/getChain.js +98 -0
- package/dist/esm/util/getChain.js.map +1 -0
- package/dist/esm/version.d.ts +1 -0
- package/dist/esm/version.js +4 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/types/Provider.d.ts +62 -0
- package/dist/types/Provider.d.ts.map +1 -0
- package/dist/types/hooks/internal/useEmbeddedWallet.d.ts +11 -0
- package/dist/types/hooks/internal/useEmbeddedWallet.d.ts.map +1 -0
- package/dist/types/hooks/useAlchemyClient.d.ts +18 -0
- package/dist/types/hooks/useAlchemyClient.d.ts.map +1 -0
- package/dist/types/hooks/useAlchemyPrepareSwap.d.ts +43 -0
- package/dist/types/hooks/useAlchemyPrepareSwap.d.ts.map +1 -0
- package/dist/types/hooks/useAlchemySendTransaction.d.ts +27 -0
- package/dist/types/hooks/useAlchemySendTransaction.d.ts.map +1 -0
- package/dist/types/hooks/useAlchemySubmitSwap.d.ts +32 -0
- package/dist/types/hooks/useAlchemySubmitSwap.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +125 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/util/getChain.d.ts +2 -0
- package/dist/types/util/getChain.d.ts.map +1 -0
- package/dist/types/version.d.ts +2 -0
- package/dist/types/version.d.ts.map +1 -0
- package/package.json +66 -0
- package/src/hooks/internal/useEmbeddedWallet.ts +29 -0
- package/src/hooks/useAlchemyClient.ts +160 -0
- package/src/hooks/useAlchemyPrepareSwap.ts +113 -0
- package/src/hooks/useAlchemySendTransaction.ts +160 -0
- package/src/hooks/useAlchemySubmitSwap.ts +120 -0
- package/src/index.ts +23 -0
- package/src/types.ts +159 -0
- package/src/util/getChain.ts +145 -0
- package/src/version.ts +3 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { Address, Hash, Hex } from "viem";
|
|
2
|
+
import type { swapActions } from "@account-kit/wallet-client/experimental";
|
|
3
|
+
import { ConnectionConfigSchema } from "@aa-sdk/core";
|
|
4
|
+
import type { z } from "zod";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for the Alchemy provider
|
|
7
|
+
* Uses ConnectionConfigSchema to ensure valid transport configuration
|
|
8
|
+
*/
|
|
9
|
+
export type AlchemyProviderConfig = z.infer<typeof ConnectionConfigSchema> & {
|
|
10
|
+
/** Policy ID(s) for gas sponsorship */
|
|
11
|
+
policyId?: string | string[];
|
|
12
|
+
/**
|
|
13
|
+
* Set to true to disable gas sponsorship by default
|
|
14
|
+
* Default: false (sponsorship enabled when policyId is provided)
|
|
15
|
+
*/
|
|
16
|
+
disableSponsorship?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Unsigned transaction request
|
|
20
|
+
*/
|
|
21
|
+
export interface UnsignedTransactionRequest {
|
|
22
|
+
/** Recipient address */
|
|
23
|
+
to: Address;
|
|
24
|
+
/** Transaction data (calldata) */
|
|
25
|
+
data?: Hex;
|
|
26
|
+
/** Transaction value - accepts string | number | bigint */
|
|
27
|
+
value?: string | number | bigint;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Options for sending a transaction
|
|
31
|
+
*/
|
|
32
|
+
export interface SendTransactionOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Set to true to disable sponsorship for this specific transaction
|
|
35
|
+
* Default: false (follows provider's disableSponsorship setting)
|
|
36
|
+
*/
|
|
37
|
+
disableSponsorship?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Result of a successful transaction
|
|
41
|
+
*/
|
|
42
|
+
export interface SendTransactionResult {
|
|
43
|
+
/** EVM transaction hash (first receipt hash) */
|
|
44
|
+
txnHash: Hash;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Hook result for sending transactions
|
|
48
|
+
*/
|
|
49
|
+
export interface UseSendTransactionResult {
|
|
50
|
+
/** Whether the transaction is currently being sent */
|
|
51
|
+
isLoading: boolean;
|
|
52
|
+
/** Error if transaction failed */
|
|
53
|
+
error: Error | null;
|
|
54
|
+
/** Transaction result if successful */
|
|
55
|
+
data: SendTransactionResult | null;
|
|
56
|
+
/** Reset the hook state */
|
|
57
|
+
reset(): void;
|
|
58
|
+
/** Send a transaction */
|
|
59
|
+
sendTransaction(input: UnsignedTransactionRequest, options?: SendTransactionOptions): Promise<SendTransactionResult>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Request parameters for preparing a swap
|
|
63
|
+
* Derived directly from the SDK to ensure type safety
|
|
64
|
+
*
|
|
65
|
+
* Note: Provide either `fromAmount` OR `minimumToAmount`, not both.
|
|
66
|
+
* - Use `fromAmount` to specify exact amount to swap FROM
|
|
67
|
+
* - Use `minimumToAmount` to specify minimum amount to receive TO
|
|
68
|
+
*/
|
|
69
|
+
export type PrepareSwapRequest = Parameters<ReturnType<typeof swapActions>["requestQuoteV0"]>[0];
|
|
70
|
+
/**
|
|
71
|
+
* Response from requestQuoteV0
|
|
72
|
+
* Derived directly from the SDK to ensure type safety
|
|
73
|
+
*/
|
|
74
|
+
export type RequestQuoteV0Result = Awaited<ReturnType<ReturnType<typeof swapActions>["requestQuoteV0"]>>;
|
|
75
|
+
/**
|
|
76
|
+
* Swap quote information extracted from prepared swap calls
|
|
77
|
+
* Derived directly from the SDK response
|
|
78
|
+
*/
|
|
79
|
+
export type SwapQuote = NonNullable<RequestQuoteV0Result["quote"]>;
|
|
80
|
+
/**
|
|
81
|
+
* Result of preparing a swap (full response from requestQuoteV0)
|
|
82
|
+
* Contains quote and prepared calls ready for signing
|
|
83
|
+
*/
|
|
84
|
+
export type PrepareSwapResult = Extract<RequestQuoteV0Result, {
|
|
85
|
+
rawCalls?: false | undefined;
|
|
86
|
+
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Hook result for preparing swaps
|
|
89
|
+
*/
|
|
90
|
+
export interface UsePrepareSwapResult {
|
|
91
|
+
/** Whether the swap is being prepared */
|
|
92
|
+
isLoading: boolean;
|
|
93
|
+
/** Error if preparation failed */
|
|
94
|
+
error: Error | null;
|
|
95
|
+
/** Prepared swap data if successful */
|
|
96
|
+
data: PrepareSwapResult | null;
|
|
97
|
+
/** Reset the hook state */
|
|
98
|
+
reset(): void;
|
|
99
|
+
/** Request a swap quote and prepare calls */
|
|
100
|
+
prepareSwap(request: PrepareSwapRequest): Promise<PrepareSwapResult>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Result of submitting a swap
|
|
104
|
+
* Simplified wrapper that extracts the transaction hash
|
|
105
|
+
*/
|
|
106
|
+
export interface SubmitSwapResult {
|
|
107
|
+
/** Transaction hash of the swap */
|
|
108
|
+
txnHash: Hash;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Hook result for submitting swaps
|
|
112
|
+
*/
|
|
113
|
+
export interface UseSubmitSwapResult {
|
|
114
|
+
/** Whether the swap is being submitted */
|
|
115
|
+
isLoading: boolean;
|
|
116
|
+
/** Error if submission failed */
|
|
117
|
+
error: Error | null;
|
|
118
|
+
/** Swap submission result if successful */
|
|
119
|
+
data: SubmitSwapResult | null;
|
|
120
|
+
/** Reset the hook state */
|
|
121
|
+
reset(): void;
|
|
122
|
+
/** Sign and submit prepared swap calls */
|
|
123
|
+
submitSwap(preparedSwap: PrepareSwapResult): Promise<SubmitSwapResult>;
|
|
124
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["import type { Address, Hash, Hex } from \"viem\";\nimport type { swapActions } from \"@account-kit/wallet-client/experimental\";\nimport { ConnectionConfigSchema } from \"@aa-sdk/core\";\nimport type { z } from \"zod\";\n\n/**\n * Configuration for the Alchemy provider\n * Uses ConnectionConfigSchema to ensure valid transport configuration\n */\nexport type AlchemyProviderConfig = z.infer<typeof ConnectionConfigSchema> & {\n /** Policy ID(s) for gas sponsorship */\n policyId?: string | string[];\n\n /**\n * Set to true to disable gas sponsorship by default\n * Default: false (sponsorship enabled when policyId is provided)\n */\n disableSponsorship?: boolean;\n};\n\n/**\n * Unsigned transaction request\n */\nexport interface UnsignedTransactionRequest {\n /** Recipient address */\n to: Address;\n\n /** Transaction data (calldata) */\n data?: Hex;\n\n /** Transaction value - accepts string | number | bigint */\n value?: string | number | bigint;\n}\n\n/**\n * Options for sending a transaction\n */\nexport interface SendTransactionOptions {\n /**\n * Set to true to disable sponsorship for this specific transaction\n * Default: false (follows provider's disableSponsorship setting)\n */\n disableSponsorship?: boolean;\n}\n\n/**\n * Result of a successful transaction\n */\nexport interface SendTransactionResult {\n /** EVM transaction hash (first receipt hash) */\n txnHash: Hash;\n}\n\n/**\n * Hook result for sending transactions\n */\nexport interface UseSendTransactionResult {\n /** Whether the transaction is currently being sent */\n isLoading: boolean;\n\n /** Error if transaction failed */\n error: Error | null;\n\n /** Transaction result if successful */\n data: SendTransactionResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Send a transaction */\n sendTransaction(\n input: UnsignedTransactionRequest,\n options?: SendTransactionOptions,\n ): Promise<SendTransactionResult>;\n}\n\n/**\n * Request parameters for preparing a swap\n * Derived directly from the SDK to ensure type safety\n *\n * Note: Provide either `fromAmount` OR `minimumToAmount`, not both.\n * - Use `fromAmount` to specify exact amount to swap FROM\n * - Use `minimumToAmount` to specify minimum amount to receive TO\n */\nexport type PrepareSwapRequest = Parameters<\n ReturnType<typeof swapActions>[\"requestQuoteV0\"]\n>[0];\n\n/**\n * Response from requestQuoteV0\n * Derived directly from the SDK to ensure type safety\n */\nexport type RequestQuoteV0Result = Awaited<\n ReturnType<ReturnType<typeof swapActions>[\"requestQuoteV0\"]>\n>;\n\n/**\n * Swap quote information extracted from prepared swap calls\n * Derived directly from the SDK response\n */\nexport type SwapQuote = NonNullable<RequestQuoteV0Result[\"quote\"]>;\n\n/**\n * Result of preparing a swap (full response from requestQuoteV0)\n * Contains quote and prepared calls ready for signing\n */\nexport type PrepareSwapResult = Extract<\n RequestQuoteV0Result,\n { rawCalls?: false | undefined }\n>;\n\n/**\n * Hook result for preparing swaps\n */\nexport interface UsePrepareSwapResult {\n /** Whether the swap is being prepared */\n isLoading: boolean;\n\n /** Error if preparation failed */\n error: Error | null;\n\n /** Prepared swap data if successful */\n data: PrepareSwapResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Request a swap quote and prepare calls */\n prepareSwap(request: PrepareSwapRequest): Promise<PrepareSwapResult>;\n}\n\n/**\n * Result of submitting a swap\n * Simplified wrapper that extracts the transaction hash\n */\nexport interface SubmitSwapResult {\n /** Transaction hash of the swap */\n txnHash: Hash;\n}\n\n/**\n * Hook result for submitting swaps\n */\nexport interface UseSubmitSwapResult {\n /** Whether the swap is being submitted */\n isLoading: boolean;\n\n /** Error if submission failed */\n error: Error | null;\n\n /** Swap submission result if successful */\n data: SubmitSwapResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Sign and submit prepared swap calls */\n submitSwap(preparedSwap: PrepareSwapResult): Promise<SubmitSwapResult>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getChain(chainId: number): import("viem").Chain;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { arbitrum, arbitrumGoerli, arbitrumNova, arbitrumSepolia, base, baseGoerli, baseSepolia, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, shape, shapeSepolia, worldChain, worldChainSepolia, zora, zoraSepolia, beraChainBartio, opbnbMainnet, opbnbTestnet, soneiumMinato, soneiumMainnet, unichainMainnet, unichainSepolia, inkMainnet, inkSepolia, mekong, monadTestnet, openlootSepolia, gensynTestnet, riseTestnet, storyMainnet, storyAeneid, celoAlfajores, celoMainnet, teaSepolia, bobaSepolia, bobaMainnet, } from "@account-kit/infra";
|
|
2
|
+
export function getChain(chainId) {
|
|
3
|
+
switch (chainId) {
|
|
4
|
+
case sepolia.id:
|
|
5
|
+
return sepolia;
|
|
6
|
+
case mainnet.id:
|
|
7
|
+
return mainnet;
|
|
8
|
+
case arbitrum.id:
|
|
9
|
+
return arbitrum;
|
|
10
|
+
case arbitrumGoerli.id:
|
|
11
|
+
return arbitrumGoerli;
|
|
12
|
+
case arbitrumNova.id:
|
|
13
|
+
return arbitrumNova;
|
|
14
|
+
case arbitrumSepolia.id:
|
|
15
|
+
return arbitrumSepolia;
|
|
16
|
+
case base.id:
|
|
17
|
+
return base;
|
|
18
|
+
case baseGoerli.id:
|
|
19
|
+
return baseGoerli;
|
|
20
|
+
case baseSepolia.id:
|
|
21
|
+
return baseSepolia;
|
|
22
|
+
case fraxtal.id:
|
|
23
|
+
return fraxtal;
|
|
24
|
+
case fraxtalSepolia.id:
|
|
25
|
+
return fraxtalSepolia;
|
|
26
|
+
case goerli.id:
|
|
27
|
+
return goerli;
|
|
28
|
+
case optimism.id:
|
|
29
|
+
return optimism;
|
|
30
|
+
case optimismGoerli.id:
|
|
31
|
+
return optimismGoerli;
|
|
32
|
+
case optimismSepolia.id:
|
|
33
|
+
return optimismSepolia;
|
|
34
|
+
case polygon.id:
|
|
35
|
+
return polygon;
|
|
36
|
+
case polygonAmoy.id:
|
|
37
|
+
return polygonAmoy;
|
|
38
|
+
case polygonMumbai.id:
|
|
39
|
+
return polygonMumbai;
|
|
40
|
+
case shape.id:
|
|
41
|
+
return shape;
|
|
42
|
+
case shapeSepolia.id:
|
|
43
|
+
return shapeSepolia;
|
|
44
|
+
case worldChain.id:
|
|
45
|
+
return worldChain;
|
|
46
|
+
case worldChainSepolia.id:
|
|
47
|
+
return worldChainSepolia;
|
|
48
|
+
case zora.id:
|
|
49
|
+
return zora;
|
|
50
|
+
case zoraSepolia.id:
|
|
51
|
+
return zoraSepolia;
|
|
52
|
+
case beraChainBartio.id:
|
|
53
|
+
return beraChainBartio;
|
|
54
|
+
case opbnbMainnet.id:
|
|
55
|
+
return opbnbMainnet;
|
|
56
|
+
case opbnbTestnet.id:
|
|
57
|
+
return opbnbTestnet;
|
|
58
|
+
case soneiumMinato.id:
|
|
59
|
+
return soneiumMinato;
|
|
60
|
+
case soneiumMainnet.id:
|
|
61
|
+
return soneiumMainnet;
|
|
62
|
+
case unichainMainnet.id:
|
|
63
|
+
return unichainMainnet;
|
|
64
|
+
case unichainSepolia.id:
|
|
65
|
+
return unichainSepolia;
|
|
66
|
+
case inkMainnet.id:
|
|
67
|
+
return inkMainnet;
|
|
68
|
+
case inkSepolia.id:
|
|
69
|
+
return inkSepolia;
|
|
70
|
+
case mekong.id:
|
|
71
|
+
return mekong;
|
|
72
|
+
case monadTestnet.id:
|
|
73
|
+
return monadTestnet;
|
|
74
|
+
case openlootSepolia.id:
|
|
75
|
+
return openlootSepolia;
|
|
76
|
+
case gensynTestnet.id:
|
|
77
|
+
return gensynTestnet;
|
|
78
|
+
case riseTestnet.id:
|
|
79
|
+
return riseTestnet;
|
|
80
|
+
case storyMainnet.id:
|
|
81
|
+
return storyMainnet;
|
|
82
|
+
case storyAeneid.id:
|
|
83
|
+
return storyAeneid;
|
|
84
|
+
case celoAlfajores.id:
|
|
85
|
+
return celoAlfajores;
|
|
86
|
+
case celoMainnet.id:
|
|
87
|
+
return celoMainnet;
|
|
88
|
+
case teaSepolia.id:
|
|
89
|
+
return teaSepolia;
|
|
90
|
+
case bobaSepolia.id:
|
|
91
|
+
return bobaSepolia;
|
|
92
|
+
case bobaMainnet.id:
|
|
93
|
+
return bobaMainnet;
|
|
94
|
+
default:
|
|
95
|
+
throw new Error(`Unsupported chainId: ${chainId}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=getChain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getChain.js","sourceRoot":"","sources":["../../../src/util/getChain.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,EACf,IAAI,EACJ,UAAU,EACV,WAAW,EACX,OAAO,EACP,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,EACR,cAAc,EACd,eAAe,EACf,OAAO,EACP,WAAW,EACX,aAAa,EACb,OAAO,EACP,KAAK,EACL,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACX,eAAe,EACf,YAAY,EACZ,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ACrB,KAAK,aAAa,CAAC,EAAE;YACnB,OAAO,aAAa,CAAC;QACvB,KAAK,WAAW,CAAC,EAAE;YACjB,OAAO,WAAW,CAAC;QACrB,KAAK,UAAU,CAAC,EAAE;YAChB,OAAO,UAAU,CAAC;QACpB,KAAK,WAAW,CAAC,EAAE;YACjB,OAAO,WAAW,CAAC;QACrB,KAAK,WAAW,CAAC,EAAE;YACjB,OAAO,WAAW,CAAC;QAErB;YACE,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC","sourcesContent":["import {\n arbitrum,\n arbitrumGoerli,\n arbitrumNova,\n arbitrumSepolia,\n base,\n baseGoerli,\n baseSepolia,\n fraxtal,\n fraxtalSepolia,\n goerli,\n mainnet,\n optimism,\n optimismGoerli,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n shape,\n shapeSepolia,\n worldChain,\n worldChainSepolia,\n zora,\n zoraSepolia,\n beraChainBartio,\n opbnbMainnet,\n opbnbTestnet,\n soneiumMinato,\n soneiumMainnet,\n unichainMainnet,\n unichainSepolia,\n inkMainnet,\n inkSepolia,\n mekong,\n monadTestnet,\n openlootSepolia,\n gensynTestnet,\n riseTestnet,\n storyMainnet,\n storyAeneid,\n celoAlfajores,\n celoMainnet,\n teaSepolia,\n bobaSepolia,\n bobaMainnet,\n} from \"@account-kit/infra\";\n\nexport function getChain(chainId: number) {\n switch (chainId) {\n case sepolia.id:\n return sepolia;\n case mainnet.id:\n return mainnet;\n case arbitrum.id:\n return arbitrum;\n case arbitrumGoerli.id:\n return arbitrumGoerli;\n case arbitrumNova.id:\n return arbitrumNova;\n case arbitrumSepolia.id:\n return arbitrumSepolia;\n case base.id:\n return base;\n case baseGoerli.id:\n return baseGoerli;\n case baseSepolia.id:\n return baseSepolia;\n case fraxtal.id:\n return fraxtal;\n case fraxtalSepolia.id:\n return fraxtalSepolia;\n case goerli.id:\n return goerli;\n case optimism.id:\n return optimism;\n case optimismGoerli.id:\n return optimismGoerli;\n case optimismSepolia.id:\n return optimismSepolia;\n case polygon.id:\n return polygon;\n case polygonAmoy.id:\n return polygonAmoy;\n case polygonMumbai.id:\n return polygonMumbai;\n case shape.id:\n return shape;\n case shapeSepolia.id:\n return shapeSepolia;\n case worldChain.id:\n return worldChain;\n case worldChainSepolia.id:\n return worldChainSepolia;\n case zora.id:\n return zora;\n case zoraSepolia.id:\n return zoraSepolia;\n case beraChainBartio.id:\n return beraChainBartio;\n case opbnbMainnet.id:\n return opbnbMainnet;\n case opbnbTestnet.id:\n return opbnbTestnet;\n case soneiumMinato.id:\n return soneiumMinato;\n case soneiumMainnet.id:\n return soneiumMainnet;\n case unichainMainnet.id:\n return unichainMainnet;\n case unichainSepolia.id:\n return unichainSepolia;\n case inkMainnet.id:\n return inkMainnet;\n case inkSepolia.id:\n return inkSepolia;\n case mekong.id:\n return mekong;\n case monadTestnet.id:\n return monadTestnet;\n case openlootSepolia.id:\n return openlootSepolia;\n case gensynTestnet.id:\n return gensynTestnet;\n case riseTestnet.id:\n return riseTestnet;\n case storyMainnet.id:\n return storyMainnet;\n case storyAeneid.id:\n return storyAeneid;\n case celoAlfajores.id:\n return celoAlfajores;\n case celoMainnet.id:\n return celoMainnet;\n case teaSepolia.id:\n return teaSepolia;\n case bobaSepolia.id:\n return bobaSepolia;\n case bobaMainnet.id:\n return bobaMainnet;\n\n default:\n throw new Error(`Unsupported chainId: ${chainId}`);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "4.68.0";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.68.0\";\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type PropsWithChildren } from "react";
|
|
2
|
+
import type { SmartWalletClient } from "@account-kit/wallet-client";
|
|
3
|
+
import type { AlchemyProviderConfig } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Client cache stored in React tree (similar to QueryClient in React Query)
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
interface ClientCache {
|
|
10
|
+
client: SmartWalletClient | null;
|
|
11
|
+
cacheKey: string | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Provider component that configures Alchemy infrastructure for transaction handling
|
|
15
|
+
* Must be nested INSIDE PrivyProvider to access authentication state
|
|
16
|
+
* Automatically manages client cache lifecycle and resets on logout
|
|
17
|
+
*
|
|
18
|
+
* @param {PropsWithChildren<AlchemyProviderConfig>} props - Component props
|
|
19
|
+
* @param {React.ReactNode} props.children - React children to wrap with Alchemy configuration
|
|
20
|
+
* @param {string} [props.apiKey] - Your Alchemy API key
|
|
21
|
+
* @param {string} [props.jwt] - JWT token for authentication
|
|
22
|
+
* @param {string} [props.rpcUrl] - Custom RPC URL
|
|
23
|
+
* @param {string | string[]} [props.policyId] - Gas Manager policy ID(s)
|
|
24
|
+
* @param {boolean} [props.disableSponsorship] - Set to true to disable sponsorship by default (default: false)
|
|
25
|
+
* @returns {JSX.Element} Provider component
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <PrivyProvider appId="...">
|
|
30
|
+
* <AlchemyProvider
|
|
31
|
+
* apiKey="your-alchemy-api-key"
|
|
32
|
+
* policyId="your-gas-policy-id"
|
|
33
|
+
* >
|
|
34
|
+
* <YourApp />
|
|
35
|
+
* </AlchemyProvider>
|
|
36
|
+
* </PrivyProvider>
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function AlchemyProvider({ children, ...config }: PropsWithChildren<AlchemyProviderConfig>): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
/**
|
|
41
|
+
* Hook to access Alchemy provider configuration
|
|
42
|
+
* Must be used within an <AlchemyProvider> component
|
|
43
|
+
*
|
|
44
|
+
* @returns {AlchemyProviderConfig} The current Alchemy configuration
|
|
45
|
+
* @throws {Error} If used outside of AlchemyProvider
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* const config = useAlchemyConfig();
|
|
50
|
+
* console.log('Policy ID:', config.policyId);
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function useAlchemyConfig(): AlchemyProviderConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Hook to access the client cache (internal use only)
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
* @returns {ClientCache} The client cache object
|
|
59
|
+
*/
|
|
60
|
+
export declare function useClientCache(): ClientCache;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=Provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../src/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EAKvB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAIxD;;;;GAIG;AACH,UAAU,WAAW;IACnB,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,2CAiD1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,IAAI,qBAAqB,CAMxD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAQ5C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ConnectedWallet as PrivyWallet } from "@privy-io/react-auth";
|
|
2
|
+
/**
|
|
3
|
+
* Internal hook to get the Privy embedded wallet
|
|
4
|
+
* Shared across multiple hooks to avoid duplication
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
* @returns {() => PrivyWallet} Function that returns the embedded wallet
|
|
8
|
+
* @throws {Error} If embedded wallet is not found
|
|
9
|
+
*/
|
|
10
|
+
export declare function useEmbeddedWallet(): () => PrivyWallet;
|
|
11
|
+
//# sourceMappingURL=useEmbeddedWallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEmbeddedWallet.d.ts","sourceRoot":"","sources":["../../../../src/hooks/internal/useEmbeddedWallet.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,eAAe,IAAI,WAAW,EACpC,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,UAGW,WAAW,CAWtD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type SmartWalletClient } from "@account-kit/wallet-client";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to get and memoize a SmartWalletClient instance
|
|
4
|
+
* The client is cached in the AlchemyProvider context (React tree scoped)
|
|
5
|
+
* Automatically clears cache on logout via the provider
|
|
6
|
+
*
|
|
7
|
+
* @returns {{ getClient: () => Promise<SmartWalletClient> }} Object containing the smart wallet client getter
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const { getClient } = useAlchemyClient();
|
|
12
|
+
* const smartWalletClient = await getClient();
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function useAlchemyClient(): {
|
|
16
|
+
getClient: () => Promise<SmartWalletClient>;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useAlchemyClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAlchemyClient.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAlchemyClient.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,4BAA4B,CAAC;AAMpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB;qBAgCU,OAAO,CAAC,iBAAiB,CAAC;EA4FnE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { UsePrepareSwapResult } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to request swap quotes and prepare swap calls
|
|
4
|
+
* Part of the two-step swap process: prepare → submit
|
|
5
|
+
* Use with `useAlchemySubmitSwap()` to execute the prepared swap
|
|
6
|
+
*
|
|
7
|
+
* Supports two modes:
|
|
8
|
+
* 1. Specify exact amount to swap FROM (`fromAmount`)
|
|
9
|
+
* 2. Specify minimum amount to receive TO (`minimumToAmount`)
|
|
10
|
+
*
|
|
11
|
+
* @returns {UsePrepareSwapResult} Hook result with prepareSwap function and state
|
|
12
|
+
*
|
|
13
|
+
* @example Complete swap flow
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const { prepareSwap } = useAlchemyPrepareSwap();
|
|
16
|
+
* const { submitSwap } = useAlchemySubmitSwap();
|
|
17
|
+
*
|
|
18
|
+
* // Step 1: Prepare the swap (get quote)
|
|
19
|
+
* const preparedSwap = await prepareSwap({
|
|
20
|
+
* fromToken: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
21
|
+
* toToken: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
22
|
+
* fromAmount: '0xde0b6b3a7640000', // 1 ETH in hex
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // Step 2: Execute the swap
|
|
26
|
+
* const result = await submitSwap(preparedSwap);
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example Swap for minimum amount TO
|
|
30
|
+
* ```tsx
|
|
31
|
+
* const { prepareSwap } = useAlchemyPrepareSwap();
|
|
32
|
+
*
|
|
33
|
+
* // Swap ETH to get at least 100 USDC
|
|
34
|
+
* const result = await prepareSwap({
|
|
35
|
+
* fromToken: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
36
|
+
* toToken: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
37
|
+
* minimumToAmount: '0x5f5e100', // 100 USDC (6 decimals) in hex
|
|
38
|
+
* });
|
|
39
|
+
* console.log('Quote expiry:', new Date(parseInt(result.quote.expiry, 16) * 1000));
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function useAlchemyPrepareSwap(): UsePrepareSwapResult;
|
|
43
|
+
//# sourceMappingURL=useAlchemyPrepareSwap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAlchemyPrepareSwap.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAlchemyPrepareSwap.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,qBAAqB,IAAI,oBAAoB,CA6D5D"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { UseSendTransactionResult } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to send transactions with optional gas sponsorship via Alchemy
|
|
4
|
+
* Drop-in alternative to Privy's useSendTransaction hook
|
|
5
|
+
*
|
|
6
|
+
* @returns {UseSendTransactionResult} Hook result with sendTransaction function and state
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const { sendTransaction, isLoading, error, data } = useAlchemySendTransaction();
|
|
11
|
+
*
|
|
12
|
+
* const handleSend = async () => {
|
|
13
|
+
* try {
|
|
14
|
+
* const result = await sendTransaction({
|
|
15
|
+
* to: '0x...',
|
|
16
|
+
* data: '0x...',
|
|
17
|
+
* value: '1000000000000000000', // 1 ETH
|
|
18
|
+
* });
|
|
19
|
+
* console.log('Transaction hash:', result.txnHash);
|
|
20
|
+
* } catch (err) {
|
|
21
|
+
* console.error('Transaction failed:', err);
|
|
22
|
+
* }
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function useAlchemySendTransaction(): UseSendTransactionResult;
|
|
27
|
+
//# sourceMappingURL=useAlchemySendTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAlchemySendTransaction.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAlchemySendTransaction.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAIV,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAuBlB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,yBAAyB,IAAI,wBAAwB,CAsGpE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { UseSubmitSwapResult } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to sign and submit prepared swap calls
|
|
4
|
+
* Part of the two-step swap process: prepare → submit
|
|
5
|
+
*
|
|
6
|
+
* @returns {UseSubmitSwapResult} Hook result with submitSwap function and state
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const { prepareSwap } = useAlchemyPrepareSwap();
|
|
11
|
+
* const { submitSwap, isLoading, error, data } = useAlchemySubmitSwap();
|
|
12
|
+
*
|
|
13
|
+
* const handleSwap = async () => {
|
|
14
|
+
* try {
|
|
15
|
+
* // Step 1: Prepare the swap
|
|
16
|
+
* const preparedSwap = await prepareSwap({
|
|
17
|
+
* fromToken: '0x...',
|
|
18
|
+
* toToken: '0x...',
|
|
19
|
+
* fromAmount: '0x...',
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Step 2: Submit the swap
|
|
23
|
+
* const result = await submitSwap(preparedSwap);
|
|
24
|
+
* console.log('Swap confirmed:', result.txnHash);
|
|
25
|
+
* } catch (err) {
|
|
26
|
+
* console.error('Swap failed:', err);
|
|
27
|
+
* }
|
|
28
|
+
* };
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function useAlchemySubmitSwap(): UseSubmitSwapResult;
|
|
32
|
+
//# sourceMappingURL=useAlchemySubmitSwap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAlchemySubmitSwap.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAlchemySubmitSwap.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,oBAAoB,IAAI,mBAAmB,CAiF1D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AlchemyProvider, useAlchemyConfig } from "./Provider.js";
|
|
2
|
+
export { useAlchemyClient } from "./hooks/useAlchemyClient.js";
|
|
3
|
+
export { useAlchemySendTransaction } from "./hooks/useAlchemySendTransaction.js";
|
|
4
|
+
export { useAlchemyPrepareSwap } from "./hooks/useAlchemyPrepareSwap.js";
|
|
5
|
+
export { useAlchemySubmitSwap } from "./hooks/useAlchemySubmitSwap.js";
|
|
6
|
+
export type { AlchemyProviderConfig, UnsignedTransactionRequest, SendTransactionOptions, SendTransactionResult, UseSendTransactionResult, PrepareSwapRequest, PrepareSwapResult, UsePrepareSwapResult, SubmitSwapResult, UseSubmitSwapResult, SwapQuote, } from "./types.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGlE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAGvE,YAAY,EACV,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,SAAS,GACV,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { Address, Hash, Hex } from "viem";
|
|
2
|
+
import type { swapActions } from "@account-kit/wallet-client/experimental";
|
|
3
|
+
import { ConnectionConfigSchema } from "@aa-sdk/core";
|
|
4
|
+
import type { z } from "zod";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for the Alchemy provider
|
|
7
|
+
* Uses ConnectionConfigSchema to ensure valid transport configuration
|
|
8
|
+
*/
|
|
9
|
+
export type AlchemyProviderConfig = z.infer<typeof ConnectionConfigSchema> & {
|
|
10
|
+
/** Policy ID(s) for gas sponsorship */
|
|
11
|
+
policyId?: string | string[];
|
|
12
|
+
/**
|
|
13
|
+
* Set to true to disable gas sponsorship by default
|
|
14
|
+
* Default: false (sponsorship enabled when policyId is provided)
|
|
15
|
+
*/
|
|
16
|
+
disableSponsorship?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Unsigned transaction request
|
|
20
|
+
*/
|
|
21
|
+
export interface UnsignedTransactionRequest {
|
|
22
|
+
/** Recipient address */
|
|
23
|
+
to: Address;
|
|
24
|
+
/** Transaction data (calldata) */
|
|
25
|
+
data?: Hex;
|
|
26
|
+
/** Transaction value - accepts string | number | bigint */
|
|
27
|
+
value?: string | number | bigint;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Options for sending a transaction
|
|
31
|
+
*/
|
|
32
|
+
export interface SendTransactionOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Set to true to disable sponsorship for this specific transaction
|
|
35
|
+
* Default: false (follows provider's disableSponsorship setting)
|
|
36
|
+
*/
|
|
37
|
+
disableSponsorship?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Result of a successful transaction
|
|
41
|
+
*/
|
|
42
|
+
export interface SendTransactionResult {
|
|
43
|
+
/** EVM transaction hash (first receipt hash) */
|
|
44
|
+
txnHash: Hash;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Hook result for sending transactions
|
|
48
|
+
*/
|
|
49
|
+
export interface UseSendTransactionResult {
|
|
50
|
+
/** Whether the transaction is currently being sent */
|
|
51
|
+
isLoading: boolean;
|
|
52
|
+
/** Error if transaction failed */
|
|
53
|
+
error: Error | null;
|
|
54
|
+
/** Transaction result if successful */
|
|
55
|
+
data: SendTransactionResult | null;
|
|
56
|
+
/** Reset the hook state */
|
|
57
|
+
reset(): void;
|
|
58
|
+
/** Send a transaction */
|
|
59
|
+
sendTransaction(input: UnsignedTransactionRequest, options?: SendTransactionOptions): Promise<SendTransactionResult>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Request parameters for preparing a swap
|
|
63
|
+
* Derived directly from the SDK to ensure type safety
|
|
64
|
+
*
|
|
65
|
+
* Note: Provide either `fromAmount` OR `minimumToAmount`, not both.
|
|
66
|
+
* - Use `fromAmount` to specify exact amount to swap FROM
|
|
67
|
+
* - Use `minimumToAmount` to specify minimum amount to receive TO
|
|
68
|
+
*/
|
|
69
|
+
export type PrepareSwapRequest = Parameters<ReturnType<typeof swapActions>["requestQuoteV0"]>[0];
|
|
70
|
+
/**
|
|
71
|
+
* Response from requestQuoteV0
|
|
72
|
+
* Derived directly from the SDK to ensure type safety
|
|
73
|
+
*/
|
|
74
|
+
export type RequestQuoteV0Result = Awaited<ReturnType<ReturnType<typeof swapActions>["requestQuoteV0"]>>;
|
|
75
|
+
/**
|
|
76
|
+
* Swap quote information extracted from prepared swap calls
|
|
77
|
+
* Derived directly from the SDK response
|
|
78
|
+
*/
|
|
79
|
+
export type SwapQuote = NonNullable<RequestQuoteV0Result["quote"]>;
|
|
80
|
+
/**
|
|
81
|
+
* Result of preparing a swap (full response from requestQuoteV0)
|
|
82
|
+
* Contains quote and prepared calls ready for signing
|
|
83
|
+
*/
|
|
84
|
+
export type PrepareSwapResult = Extract<RequestQuoteV0Result, {
|
|
85
|
+
rawCalls?: false | undefined;
|
|
86
|
+
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Hook result for preparing swaps
|
|
89
|
+
*/
|
|
90
|
+
export interface UsePrepareSwapResult {
|
|
91
|
+
/** Whether the swap is being prepared */
|
|
92
|
+
isLoading: boolean;
|
|
93
|
+
/** Error if preparation failed */
|
|
94
|
+
error: Error | null;
|
|
95
|
+
/** Prepared swap data if successful */
|
|
96
|
+
data: PrepareSwapResult | null;
|
|
97
|
+
/** Reset the hook state */
|
|
98
|
+
reset(): void;
|
|
99
|
+
/** Request a swap quote and prepare calls */
|
|
100
|
+
prepareSwap(request: PrepareSwapRequest): Promise<PrepareSwapResult>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Result of submitting a swap
|
|
104
|
+
* Simplified wrapper that extracts the transaction hash
|
|
105
|
+
*/
|
|
106
|
+
export interface SubmitSwapResult {
|
|
107
|
+
/** Transaction hash of the swap */
|
|
108
|
+
txnHash: Hash;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Hook result for submitting swaps
|
|
112
|
+
*/
|
|
113
|
+
export interface UseSubmitSwapResult {
|
|
114
|
+
/** Whether the swap is being submitted */
|
|
115
|
+
isLoading: boolean;
|
|
116
|
+
/** Error if submission failed */
|
|
117
|
+
error: Error | null;
|
|
118
|
+
/** Swap submission result if successful */
|
|
119
|
+
data: SubmitSwapResult | null;
|
|
120
|
+
/** Reset the hook state */
|
|
121
|
+
reset(): void;
|
|
122
|
+
/** Sign and submit prepared swap calls */
|
|
123
|
+
submitSwap(preparedSwap: PrepareSwapResult): Promise<SubmitSwapResult>;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,GAAG;IAC3E,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE7B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,wBAAwB;IACxB,EAAE,EAAE,OAAO,CAAC;IAEZ,kCAAkC;IAClC,IAAI,CAAC,EAAE,GAAG,CAAC;IAEX,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gDAAgD;IAChD,OAAO,EAAE,IAAI,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IAC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AAgB;IAC/B,mCAAmC;IACnC,OAAO,EAAE,IAAI,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IAEnB,iCAAiC;IACjC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAEpB,2CAA2C;IAC3C,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAE9B,2BAA2B;IAC3B,KAAK,IAAI,IAAI,CAAC;IAEd,0CAA0C;IAC1C,UAAU,CAAC,YAAY,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getChain.d.ts","sourceRoot":"","sources":["../../../src/util/getChain.ts"],"names":[],"mappings":"AAgDA,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,wBAgGvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,WAAW,CAAC"}
|