Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit 6e1d595

Browse files
committed
initial v2
1 parent 0203c2e commit 6e1d595

29 files changed

+290
-404
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules/
2-
dist/
2+
dist/
3+
.yalc
4+
yalc.lock

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@thirdweb-dev/react",
3-
"version": "1.0.0-alpha.3",
3+
"version": "2.0.0-alpha.1",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com:thirdweb-dev/react.git"
@@ -44,7 +44,7 @@
4444
"typescript": "^4.5.5"
4545
},
4646
"dependencies": {
47-
"@3rdweb/sdk": "^1.41.0",
47+
"@thirdweb-dev/sdk": "^2.0.0-nightly.8",
4848
"react-query": "^3.34.15",
4949
"tiny-invariant": "^1.2.0",
5050
"wagmi": "^0.2.12"

src/Provider.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { createContext, useEffect, useMemo, useState } from "react";
2-
import { ISDKOptions, ThirdwebSDK } from "@3rdweb/sdk";
2+
import { ThirdwebSDK, SDKOptions } from "@thirdweb-dev/sdk";
33
import {
44
WagmiProvider,
55
ProviderProps as WagmiproviderProps,
@@ -52,7 +52,7 @@ export interface ThirdwebPoviderProps {
5252
* The Thirdweb SDK options.
5353
* @see {@link https://thirdweb-dev.github.io/typescript-sdk/sdk.isdkoptions.html | ISDKOptions}
5454
*/
55-
sdkOptions?: Partial<ISDKOptions>;
55+
sdkOptions?: Partial<SDKOptions>;
5656
/**
5757
*
5858
* Advanced options.
@@ -182,7 +182,7 @@ const ThirdwebSDKProvider: React.FC<
182182
useEffect(() => {
183183
if (desiredChainId) {
184184
const _sdk = new ThirdwebSDK(
185-
sdkOptions?.readOnlyRpcUrl || provider,
185+
sdkOptions?.readonlySettings?.rpcUrl || provider,
186186
sdkOptions,
187187
);
188188
(_sdk as any)._chainId = desiredChainId;
@@ -192,7 +192,7 @@ const ThirdwebSDKProvider: React.FC<
192192

193193
useEffect(() => {
194194
if (signer.data && sdk && (sdk as any)._chainId === desiredChainId) {
195-
sdk.setProviderOrSigner(signer.data);
195+
sdk.updateSignerOrProvider(signer.data);
196196
}
197197
}, [signer.data, sdk, desiredChainId]);
198198

src/hooks/modules/index.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
export * from "./useBundleDropModule";
2-
export * from "./useBundleModule";
3-
export * from "./useBundleSignatureModule";
4-
export * from "./useDropModule";
5-
export * from "./useMarketModule";
6-
export * from "./useMarketplaceModule";
7-
export * from "./useModule";
8-
export * from "./useNFTModule";
9-
export * from "./usePackModule";
1+
export * from "./useEditionDrop";
2+
export * from "./useEdition";
3+
export * from "./useNFTDrop";
4+
export * from "./useMarketplace";
5+
export * from "./useContract";
6+
export * from "./useNFTCollection";
7+
export * from "./usePack";
108
export * from "./useTokenModule";
119
export * from "./useVoteModule";

src/hooks/modules/useBundleDropModule.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/hooks/modules/useBundleModule.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/hooks/modules/useBundleSignatureModule.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/hooks/modules/useContract.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { ContractForContractType, ContractType } from "@thirdweb-dev/sdk";
2+
import { useSDK } from "../../Provider";
3+
4+
/**
5+
* @internal
6+
* @param contractType - the module type
7+
* @param contractAddress - the module address
8+
* @returns the instance of the module for the given type and address
9+
*/
10+
export function useContract<TContractType extends ContractType>(
11+
contractType: TContractType,
12+
contractAddress: string,
13+
): ContractForContractType<TContractType> {
14+
const sdk = useSDK();
15+
if (!sdk) {
16+
return undefined;
17+
}
18+
return sdk.getContract(contractAddress, contractType);
19+
}

src/hooks/modules/useDropModule.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/hooks/modules/useEdition.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Edition } from "@thirdweb-dev/sdk";
2+
import { useContract } from "./useContract";
3+
4+
export function useEdition(moduleAddress: string) {
5+
return useContract("edition", moduleAddress) as Edition;
6+
}

0 commit comments

Comments
 (0)