@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
package/src/types.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* Configuration for the Alchemy provider
|
|
8
|
+
* Uses ConnectionConfigSchema to ensure valid transport configuration
|
|
9
|
+
*/
|
|
10
|
+
export type AlchemyProviderConfig = z.infer<typeof ConnectionConfigSchema> & {
|
|
11
|
+
/** Policy ID(s) for gas sponsorship */
|
|
12
|
+
policyId?: string | string[];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Set to true to disable gas sponsorship by default
|
|
16
|
+
* Default: false (sponsorship enabled when policyId is provided)
|
|
17
|
+
*/
|
|
18
|
+
disableSponsorship?: boolean;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Unsigned transaction request
|
|
23
|
+
*/
|
|
24
|
+
export interface UnsignedTransactionRequest {
|
|
25
|
+
/** Recipient address */
|
|
26
|
+
to: Address;
|
|
27
|
+
|
|
28
|
+
/** Transaction data (calldata) */
|
|
29
|
+
data?: Hex;
|
|
30
|
+
|
|
31
|
+
/** Transaction value - accepts string | number | bigint */
|
|
32
|
+
value?: string | number | bigint;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Options for sending a transaction
|
|
37
|
+
*/
|
|
38
|
+
export interface SendTransactionOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Set to true to disable sponsorship for this specific transaction
|
|
41
|
+
* Default: false (follows provider's disableSponsorship setting)
|
|
42
|
+
*/
|
|
43
|
+
disableSponsorship?: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Result of a successful transaction
|
|
48
|
+
*/
|
|
49
|
+
export interface SendTransactionResult {
|
|
50
|
+
/** EVM transaction hash (first receipt hash) */
|
|
51
|
+
txnHash: Hash;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Hook result for sending transactions
|
|
56
|
+
*/
|
|
57
|
+
export interface UseSendTransactionResult {
|
|
58
|
+
/** Whether the transaction is currently being sent */
|
|
59
|
+
isLoading: boolean;
|
|
60
|
+
|
|
61
|
+
/** Error if transaction failed */
|
|
62
|
+
error: Error | null;
|
|
63
|
+
|
|
64
|
+
/** Transaction result if successful */
|
|
65
|
+
data: SendTransactionResult | null;
|
|
66
|
+
|
|
67
|
+
/** Reset the hook state */
|
|
68
|
+
reset(): void;
|
|
69
|
+
|
|
70
|
+
/** Send a transaction */
|
|
71
|
+
sendTransaction(
|
|
72
|
+
input: UnsignedTransactionRequest,
|
|
73
|
+
options?: SendTransactionOptions,
|
|
74
|
+
): Promise<SendTransactionResult>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Request parameters for preparing a swap
|
|
79
|
+
* Derived directly from the SDK to ensure type safety
|
|
80
|
+
*
|
|
81
|
+
* Note: Provide either `fromAmount` OR `minimumToAmount`, not both.
|
|
82
|
+
* - Use `fromAmount` to specify exact amount to swap FROM
|
|
83
|
+
* - Use `minimumToAmount` to specify minimum amount to receive TO
|
|
84
|
+
*/
|
|
85
|
+
export type PrepareSwapRequest = Parameters<
|
|
86
|
+
ReturnType<typeof swapActions>["requestQuoteV0"]
|
|
87
|
+
>[0];
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Response from requestQuoteV0
|
|
91
|
+
* Derived directly from the SDK to ensure type safety
|
|
92
|
+
*/
|
|
93
|
+
export type RequestQuoteV0Result = Awaited<
|
|
94
|
+
ReturnType<ReturnType<typeof swapActions>["requestQuoteV0"]>
|
|
95
|
+
>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Swap quote information extracted from prepared swap calls
|
|
99
|
+
* Derived directly from the SDK response
|
|
100
|
+
*/
|
|
101
|
+
export type SwapQuote = NonNullable<RequestQuoteV0Result["quote"]>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Result of preparing a swap (full response from requestQuoteV0)
|
|
105
|
+
* Contains quote and prepared calls ready for signing
|
|
106
|
+
*/
|
|
107
|
+
export type PrepareSwapResult = Extract<
|
|
108
|
+
RequestQuoteV0Result,
|
|
109
|
+
{ rawCalls?: false | undefined }
|
|
110
|
+
>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Hook result for preparing swaps
|
|
114
|
+
*/
|
|
115
|
+
export interface UsePrepareSwapResult {
|
|
116
|
+
/** Whether the swap is being prepared */
|
|
117
|
+
isLoading: boolean;
|
|
118
|
+
|
|
119
|
+
/** Error if preparation failed */
|
|
120
|
+
error: Error | null;
|
|
121
|
+
|
|
122
|
+
/** Prepared swap data if successful */
|
|
123
|
+
data: PrepareSwapResult | null;
|
|
124
|
+
|
|
125
|
+
/** Reset the hook state */
|
|
126
|
+
reset(): void;
|
|
127
|
+
|
|
128
|
+
/** Request a swap quote and prepare calls */
|
|
129
|
+
prepareSwap(request: PrepareSwapRequest): Promise<PrepareSwapResult>;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Result of submitting a swap
|
|
134
|
+
* Simplified wrapper that extracts the transaction hash
|
|
135
|
+
*/
|
|
136
|
+
export interface SubmitSwapResult {
|
|
137
|
+
/** Transaction hash of the swap */
|
|
138
|
+
txnHash: Hash;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Hook result for submitting swaps
|
|
143
|
+
*/
|
|
144
|
+
export interface UseSubmitSwapResult {
|
|
145
|
+
/** Whether the swap is being submitted */
|
|
146
|
+
isLoading: boolean;
|
|
147
|
+
|
|
148
|
+
/** Error if submission failed */
|
|
149
|
+
error: Error | null;
|
|
150
|
+
|
|
151
|
+
/** Swap submission result if successful */
|
|
152
|
+
data: SubmitSwapResult | null;
|
|
153
|
+
|
|
154
|
+
/** Reset the hook state */
|
|
155
|
+
reset(): void;
|
|
156
|
+
|
|
157
|
+
/** Sign and submit prepared swap calls */
|
|
158
|
+
submitSwap(preparedSwap: PrepareSwapResult): Promise<SubmitSwapResult>;
|
|
159
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
arbitrum,
|
|
3
|
+
arbitrumGoerli,
|
|
4
|
+
arbitrumNova,
|
|
5
|
+
arbitrumSepolia,
|
|
6
|
+
base,
|
|
7
|
+
baseGoerli,
|
|
8
|
+
baseSepolia,
|
|
9
|
+
fraxtal,
|
|
10
|
+
fraxtalSepolia,
|
|
11
|
+
goerli,
|
|
12
|
+
mainnet,
|
|
13
|
+
optimism,
|
|
14
|
+
optimismGoerli,
|
|
15
|
+
optimismSepolia,
|
|
16
|
+
polygon,
|
|
17
|
+
polygonAmoy,
|
|
18
|
+
polygonMumbai,
|
|
19
|
+
sepolia,
|
|
20
|
+
shape,
|
|
21
|
+
shapeSepolia,
|
|
22
|
+
worldChain,
|
|
23
|
+
worldChainSepolia,
|
|
24
|
+
zora,
|
|
25
|
+
zoraSepolia,
|
|
26
|
+
beraChainBartio,
|
|
27
|
+
opbnbMainnet,
|
|
28
|
+
opbnbTestnet,
|
|
29
|
+
soneiumMinato,
|
|
30
|
+
soneiumMainnet,
|
|
31
|
+
unichainMainnet,
|
|
32
|
+
unichainSepolia,
|
|
33
|
+
inkMainnet,
|
|
34
|
+
inkSepolia,
|
|
35
|
+
mekong,
|
|
36
|
+
monadTestnet,
|
|
37
|
+
openlootSepolia,
|
|
38
|
+
gensynTestnet,
|
|
39
|
+
riseTestnet,
|
|
40
|
+
storyMainnet,
|
|
41
|
+
storyAeneid,
|
|
42
|
+
celoAlfajores,
|
|
43
|
+
celoMainnet,
|
|
44
|
+
teaSepolia,
|
|
45
|
+
bobaSepolia,
|
|
46
|
+
bobaMainnet,
|
|
47
|
+
} from "@account-kit/infra";
|
|
48
|
+
|
|
49
|
+
export function getChain(chainId: number) {
|
|
50
|
+
switch (chainId) {
|
|
51
|
+
case sepolia.id:
|
|
52
|
+
return sepolia;
|
|
53
|
+
case mainnet.id:
|
|
54
|
+
return mainnet;
|
|
55
|
+
case arbitrum.id:
|
|
56
|
+
return arbitrum;
|
|
57
|
+
case arbitrumGoerli.id:
|
|
58
|
+
return arbitrumGoerli;
|
|
59
|
+
case arbitrumNova.id:
|
|
60
|
+
return arbitrumNova;
|
|
61
|
+
case arbitrumSepolia.id:
|
|
62
|
+
return arbitrumSepolia;
|
|
63
|
+
case base.id:
|
|
64
|
+
return base;
|
|
65
|
+
case baseGoerli.id:
|
|
66
|
+
return baseGoerli;
|
|
67
|
+
case baseSepolia.id:
|
|
68
|
+
return baseSepolia;
|
|
69
|
+
case fraxtal.id:
|
|
70
|
+
return fraxtal;
|
|
71
|
+
case fraxtalSepolia.id:
|
|
72
|
+
return fraxtalSepolia;
|
|
73
|
+
case goerli.id:
|
|
74
|
+
return goerli;
|
|
75
|
+
case optimism.id:
|
|
76
|
+
return optimism;
|
|
77
|
+
case optimismGoerli.id:
|
|
78
|
+
return optimismGoerli;
|
|
79
|
+
case optimismSepolia.id:
|
|
80
|
+
return optimismSepolia;
|
|
81
|
+
case polygon.id:
|
|
82
|
+
return polygon;
|
|
83
|
+
case polygonAmoy.id:
|
|
84
|
+
return polygonAmoy;
|
|
85
|
+
case polygonMumbai.id:
|
|
86
|
+
return polygonMumbai;
|
|
87
|
+
case shape.id:
|
|
88
|
+
return shape;
|
|
89
|
+
case shapeSepolia.id:
|
|
90
|
+
return shapeSepolia;
|
|
91
|
+
case worldChain.id:
|
|
92
|
+
return worldChain;
|
|
93
|
+
case worldChainSepolia.id:
|
|
94
|
+
return worldChainSepolia;
|
|
95
|
+
case zora.id:
|
|
96
|
+
return zora;
|
|
97
|
+
case zoraSepolia.id:
|
|
98
|
+
return zoraSepolia;
|
|
99
|
+
case beraChainBartio.id:
|
|
100
|
+
return beraChainBartio;
|
|
101
|
+
case opbnbMainnet.id:
|
|
102
|
+
return opbnbMainnet;
|
|
103
|
+
case opbnbTestnet.id:
|
|
104
|
+
return opbnbTestnet;
|
|
105
|
+
case soneiumMinato.id:
|
|
106
|
+
return soneiumMinato;
|
|
107
|
+
case soneiumMainnet.id:
|
|
108
|
+
return soneiumMainnet;
|
|
109
|
+
case unichainMainnet.id:
|
|
110
|
+
return unichainMainnet;
|
|
111
|
+
case unichainSepolia.id:
|
|
112
|
+
return unichainSepolia;
|
|
113
|
+
case inkMainnet.id:
|
|
114
|
+
return inkMainnet;
|
|
115
|
+
case inkSepolia.id:
|
|
116
|
+
return inkSepolia;
|
|
117
|
+
case mekong.id:
|
|
118
|
+
return mekong;
|
|
119
|
+
case monadTestnet.id:
|
|
120
|
+
return monadTestnet;
|
|
121
|
+
case openlootSepolia.id:
|
|
122
|
+
return openlootSepolia;
|
|
123
|
+
case gensynTestnet.id:
|
|
124
|
+
return gensynTestnet;
|
|
125
|
+
case riseTestnet.id:
|
|
126
|
+
return riseTestnet;
|
|
127
|
+
case storyMainnet.id:
|
|
128
|
+
return storyMainnet;
|
|
129
|
+
case storyAeneid.id:
|
|
130
|
+
return storyAeneid;
|
|
131
|
+
case celoAlfajores.id:
|
|
132
|
+
return celoAlfajores;
|
|
133
|
+
case celoMainnet.id:
|
|
134
|
+
return celoMainnet;
|
|
135
|
+
case teaSepolia.id:
|
|
136
|
+
return teaSepolia;
|
|
137
|
+
case bobaSepolia.id:
|
|
138
|
+
return bobaSepolia;
|
|
139
|
+
case bobaMainnet.id:
|
|
140
|
+
return bobaMainnet;
|
|
141
|
+
|
|
142
|
+
default:
|
|
143
|
+
throw new Error(`Unsupported chainId: ${chainId}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
package/src/version.ts
ADDED