|
1 | 1 | import React, { createContext, useEffect, useMemo, useState } from "react"; |
2 | | -import { ThirdwebSDK, SDKOptions } from "@thirdweb-dev/sdk"; |
| 2 | +import { ThirdwebSDK, SDKOptions, IStorage } from "@thirdweb-dev/sdk"; |
3 | 3 | import { |
4 | 4 | WagmiProvider, |
5 | 5 | ProviderProps as WagmiproviderProps, |
@@ -87,6 +87,11 @@ export interface ThirdwebProviderProps< |
87 | 87 | desiredChainId: TSupportedChain extends Chain |
88 | 88 | ? TSupportedChain["id"] |
89 | 89 | : TSupportedChain | undefined; |
| 90 | + |
| 91 | + /** |
| 92 | + * The storage interface to use with the sdk. |
| 93 | + */ |
| 94 | + storageInterface?: IStorage; |
90 | 95 | } |
91 | 96 |
|
92 | 97 | const defaultChainRpc: ThirdwebProviderProps["chainRpc"] = { |
@@ -246,15 +251,18 @@ interface SDKContext { |
246 | 251 | const ThirdwebSDKContext = createContext<SDKContext>({}); |
247 | 252 |
|
248 | 253 | const ThirdwebSDKProvider: React.FC< |
249 | | - Pick<ThirdwebProviderProps, "desiredChainId" | "sdkOptions"> |
250 | | -> = ({ sdkOptions, desiredChainId, children }) => { |
| 254 | + Pick< |
| 255 | + ThirdwebProviderProps, |
| 256 | + "desiredChainId" | "sdkOptions" | "storageInterface" |
| 257 | + > |
| 258 | +> = ({ sdkOptions, desiredChainId, storageInterface, children }) => { |
251 | 259 | const [sdk, setSDK] = useState<ThirdwebSDK | undefined>(undefined); |
252 | 260 | const provider = useProvider(); |
253 | 261 | const signer = useSigner(); |
254 | 262 |
|
255 | 263 | useEffect(() => { |
256 | 264 | if (desiredChainId) { |
257 | | - const _sdk = new ThirdwebSDK(provider, sdkOptions); |
| 265 | + const _sdk = new ThirdwebSDK(provider, sdkOptions, storageInterface); |
258 | 266 | (_sdk as any)._chainId = desiredChainId; |
259 | 267 | setSDK(_sdk); |
260 | 268 | } |
|
0 commit comments