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

Commit e57dbb1

Browse files
authored
import ethers purely as peerdependency instead of using individual sub-packages (#50)
* import ethers purely as peerdependency instead of using individual sub-packages * further cleanup of ethers deps
1 parent 8c0c27c commit e57dbb1

10 files changed

Lines changed: 30 additions & 34 deletions

File tree

docs/react.useeditions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export declare function useEditions(contract: RequiredParam<Erc1155>, queryParam
2121
external_url?: string | undefined;
2222
animation_url?: string | undefined;
2323
uri: string;
24-
id: import("@ethersproject/bignumber").BigNumber;
24+
id: import("ethers").BigNumber;
2525
};
26-
supply: import("@ethersproject/bignumber").BigNumber;
26+
supply: import("ethers").BigNumber;
2727
}[], unknown>;
2828
```
2929

@@ -36,7 +36,7 @@ export declare function useEditions(contract: RequiredParam<Erc1155>, queryParam
3636

3737
<b>Returns:</b>
3838

39-
import("react-query").UseQueryResult&lt;{ metadata: { \[x: string\]: import("@thirdweb-dev/sdk").Json; name?: string \| undefined; description?: string \| undefined; image?: string \| undefined; external\_url?: string \| undefined; animation\_url?: string \| undefined; uri: string; id: import("@ethersproject/bignumber").BigNumber; }; supply: import("@ethersproject/bignumber").BigNumber; }\[\], unknown&gt;
39+
import("react-query").UseQueryResult&lt;{ metadata: { \[x: string\]: import("@thirdweb-dev/sdk").Json; name?: string \| undefined; description?: string \| undefined; image?: string \| undefined; external\_url?: string \| undefined; animation\_url?: string \| undefined; uri: string; id: import("ethers").BigNumber; }; supply: import("ethers").BigNumber; }\[\], unknown&gt;
4040

4141
a response object that includes an array of NFTs
4242

docs/react.useeditiontotalcount.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Use this to get a the total (minted) supply of your ERC1155 contract.
1212
<b>Signature:</b>
1313

1414
```typescript
15-
export declare function useEditionTotalCount(contract: RequiredParam<Erc1155>, tokenId: BigNumberish): import("react-query").UseQueryResult<import("@ethersproject/bignumber").BigNumber, unknown>;
15+
export declare function useEditionTotalCount(contract: RequiredParam<Erc1155>, tokenId: BigNumberish): import("react-query").UseQueryResult<import("ethers").BigNumber, unknown>;
1616
```
1717

1818
## Parameters
@@ -24,7 +24,7 @@ export declare function useEditionTotalCount(contract: RequiredParam<Erc1155>, t
2424

2525
<b>Returns:</b>
2626

27-
import("react-query").UseQueryResult&lt;import("@ethersproject/bignumber").BigNumber, unknown&gt;
27+
import("react-query").UseQueryResult&lt;import("ethers").BigNumber, unknown&gt;
2828

2929
a response object that incudes the total minted supply
3030

docs/react.usemintedition.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export declare function useMintEdition(contract: RequiredParam<Erc1155>): import
2121
external_url?: string | undefined;
2222
animation_url?: string | undefined;
2323
uri: string;
24-
id: import("@ethersproject/bignumber").BigNumber;
24+
id: import("ethers").BigNumber;
2525
};
26-
supply: import("@ethersproject/bignumber").BigNumber;
26+
supply: import("ethers").BigNumber;
2727
}>, unknown, EditionMintParams, unknown>;
2828
```
2929

@@ -35,7 +35,7 @@ export declare function useMintEdition(contract: RequiredParam<Erc1155>): import
3535

3636
<b>Returns:</b>
3737

38-
import("react-query").UseMutationResult&lt;import("@thirdweb-dev/sdk").TransactionResultWithId&lt;{ metadata: { \[x: string\]: import("@thirdweb-dev/sdk").Json; name?: string \| undefined; description?: string \| undefined; image?: string \| undefined; external\_url?: string \| undefined; animation\_url?: string \| undefined; uri: string; id: import("@ethersproject/bignumber").BigNumber; }; supply: import("@ethersproject/bignumber").BigNumber; }&gt;, unknown, [EditionMintParams](./react.editionmintparams.md)<!-- -->, unknown&gt;
38+
import("react-query").UseMutationResult&lt;import("@thirdweb-dev/sdk").TransactionResultWithId&lt;{ metadata: { \[x: string\]: import("@thirdweb-dev/sdk").Json; name?: string \| undefined; description?: string \| undefined; image?: string \| undefined; external\_url?: string \| undefined; animation\_url?: string \| undefined; uri: string; id: import("ethers").BigNumber; }; supply: import("ethers").BigNumber; }&gt;, unknown, [EditionMintParams](./react.editionmintparams.md)<!-- -->, unknown&gt;
3939

4040
a mutation object that can be used to mint a new Edition token to the connected wallet
4141

etc/react.api.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
import { AbiFunction } from '@thirdweb-dev/sdk/dist/src/schema/contracts/custom';
88
import { AuctionListing } from '@thirdweb-dev/sdk';
9-
import { BigNumber } from '@ethersproject/bignumber';
10-
import { BigNumber as BigNumber_2 } from 'ethers';
11-
import type { BigNumberish } from '@ethersproject/bignumber';
9+
import { BigNumber } from 'ethers';
10+
import type { BigNumberish } from 'ethers';
1211
import { Chain as Chain_2 } from './types';
1312
import { ChainId } from '@thirdweb-dev/sdk';
1413
import { CoinbaseWalletConnector } from 'wagmi/connectors/coinbaseWallet';
@@ -51,8 +50,7 @@ import { default as React_2 } from 'react';
5150
import { RefetchOptions } from 'react-query';
5251
import { RefetchQueryFilters } from 'react-query';
5352
import { SDKOptions } from '@thirdweb-dev/sdk';
54-
import { Signer } from '@ethersproject/abstract-signer';
55-
import { Signer as Signer_2 } from 'ethers';
53+
import { Signer } from 'ethers';
5654
import { SmartContract } from '@thirdweb-dev/sdk';
5755
import { Split } from '@thirdweb-dev/sdk';
5856
import { SUPPORTED_CHAIN_ID } from '@thirdweb-dev/sdk';
@@ -243,7 +241,7 @@ export function useClaimedNFTs(contract: RequiredParam<NFTDrop>, queryParams?: Q
243241
// Warning: (ae-incompatible-release-tags) The symbol "useClaimedNftSupply" is marked as @public, but its signature references "RequiredParam" which is marked as @beta
244242
//
245243
// @public (undocumented)
246-
export function useClaimedNftSupply(contract: RequiredParam<NFTDrop>): UseQueryResult<BigNumber_2, unknown>;
244+
export function useClaimedNftSupply(contract: RequiredParam<NFTDrop>): UseQueryResult<BigNumber, unknown>;
247245

248246
// @public
249247
export function useCoinbaseWallet(): () => Promise<{
@@ -550,7 +548,7 @@ export function useNFTDrop(contractAddress?: string): NFTDrop | undefined;
550548
export function useNFTs(contract: RequiredParam<Erc721>, queryParams?: QueryAllParams): UseQueryResult<NFTMetadataOwner[], unknown>;
551549

552550
// @beta
553-
export function useNFTSupply(contract: RequiredParam<Erc721>): UseQueryResult<BigNumber_2, unknown>;
551+
export function useNFTSupply(contract: RequiredParam<Erc721>): UseQueryResult<BigNumber, unknown>;
554552

555553
// @public
556554
export function usePack(contractAddress?: string): Pack | undefined;
@@ -574,7 +572,7 @@ export function useSDK(): ThirdwebSDK | undefined;
574572
// Warning: (ae-internal-missing-underscore) The name "useSigner" should be prefixed with an underscore because the declaration is marked as @internal
575573
//
576574
// @internal (undocumented)
577-
export function useSigner(): Signer_2 | undefined;
575+
export function useSigner(): Signer | undefined;
578576

579577
// @public
580578
export function useSplit(contractAddress?: string): Split | undefined;
@@ -586,7 +584,7 @@ export function useToken(contractAddress?: string): Token | undefined;
586584
export function useTokenBalance(contract: RequiredParam<Erc20>, address: RequiredParam<string>): UseQueryResult< {
587585
symbol: string;
588586
name: string;
589-
value: BigNumber_2;
587+
value: BigNumber;
590588
decimals: number;
591589
displayValue: string;
592590
}, unknown>;
@@ -600,7 +598,7 @@ export function useTokenDrop(contractAddress?: string): TokenDrop | undefined;
600598
export function useTokenSupply(contract: RequiredParam<Erc20>): UseQueryResult< {
601599
symbol: string;
602600
name: string;
603-
value: BigNumber_2;
601+
value: BigNumber;
604602
decimals: number;
605603
displayValue: string;
606604
}, unknown>;
@@ -614,13 +612,13 @@ image?: string | undefined;
614612
external_url?: string | undefined;
615613
animation_url?: string | undefined;
616614
uri: string;
617-
id: BigNumber_2;
615+
id: BigNumber;
618616
}[], unknown>;
619617

620618
// Warning: (ae-incompatible-release-tags) The symbol "useUnclaimedNftSupply" is marked as @public, but its signature references "RequiredParam" which is marked as @beta
621619
//
622620
// @public (undocumented)
623-
export function useUnclaimedNftSupply(contract: RequiredParam<NFTDrop>): UseQueryResult<BigNumber_2, unknown>;
621+
export function useUnclaimedNftSupply(contract: RequiredParam<NFTDrop>): UseQueryResult<BigNumber, unknown>;
624622

625623
// @public
626624
export function useVote(contractAddress?: string): Vote | undefined;

src/Provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import {
99
defaultSupportedChains,
1010
} from "./constants/chain";
1111
import { useSigner } from "./hooks/useSigner";
12-
import { Signer } from "@ethersproject/abstract-signer";
1312
import {
1413
IStorage,
1514
NetworkOrSignerOrProvider,
1615
SDKOptions,
1716
SUPPORTED_CHAIN_ID,
1817
ThirdwebSDK,
1918
} from "@thirdweb-dev/sdk";
19+
import { Signer } from "ethers";
2020
import React, { createContext, useEffect, useMemo } from "react";
2121
import { QueryClient, QueryClientProvider } from "react-query";
2222
import invariant from "tiny-invariant";

src/connectors/gnosis-safe.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// import { SafeEthersSigner, SafeService } from "@gnosis.pm/safe-ethers-adapters";
33
// import EthersAdapter from "@gnosis.pm/safe-ethers-lib";
44
import { ChainId } from "@thirdweb-dev/sdk";
5-
import { Signer, ethers } from "ethers";
6-
import { getAddress } from "ethers/lib/utils";
5+
import { Signer, ethers, utils } from "ethers";
76
import invariant from "tiny-invariant";
87
import { Chain, Connector, ConnectorData, normalizeChainId } from "wagmi";
98

@@ -139,7 +138,7 @@ export class GnosisSafeConnector extends Connector {
139138
if (accounts.length === 0) {
140139
this.emit("disconnect");
141140
} else {
142-
this.emit("change", { account: getAddress(accounts[0]) });
141+
this.emit("change", { account: utils.getAddress(accounts[0]) });
143142
}
144143
}
145144

src/connectors/magic.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { ExternalProvider, Web3Provider } from "@ethersproject/providers";
2-
import { getAddress } from "ethers/lib/utils";
1+
import { providers, utils } from "ethers";
32
import {
43
LoginWithMagicLinkConfiguration,
54
Magic as MagicInstance,
@@ -131,8 +130,8 @@ export class MagicConnector extends Connector {
131130
}
132131
getProvider() {
133132
invariant(this.magic, "connector is not initialized");
134-
return new Web3Provider(
135-
this.magic.rpcProvider as unknown as ExternalProvider,
133+
return new providers.Web3Provider(
134+
this.magic.rpcProvider as unknown as providers.ExternalProvider,
136135
);
137136
}
138137
async getSigner() {
@@ -154,7 +153,7 @@ export class MagicConnector extends Connector {
154153
if (accounts.length === 0) {
155154
this.emit("disconnect");
156155
} else {
157-
this.emit("change", { account: getAddress(accounts[0]) });
156+
this.emit("change", { account: utils.getAddress(accounts[0]) });
158157
}
159158
}
160159

src/hooks/async/edition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { useActiveChainId } from "../../Provider";
22
import { EditionMintParams, RequiredParam } from "../../types";
33
import { cacheKeys, createCacheKeyWithNetwork } from "../../utils/cache-keys";
44
import { useQueryWithNetwork } from "../query-utils/useQueryWithNetwork";
5-
import type { BigNumberish } from "@ethersproject/bignumber";
65
import type { Erc1155, QueryAllParams } from "@thirdweb-dev/sdk";
6+
import type { BigNumberish } from "ethers";
77
import { useMutation, useQueryClient } from "react-query";
88
import invariant from "tiny-invariant";
99

src/hooks/connectors/useGnosis.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
GnosisSafeConnector,
44
} from "../../connectors/gnosis-safe";
55
import { useConnect } from "../useConnect";
6-
import { isAddress } from "ethers/lib/utils";
6+
import { utils } from "ethers";
77
import invariant from "tiny-invariant";
88

99
/**
@@ -54,7 +54,7 @@ export function useGnosis() {
5454
"Gnosis safe chain id must match personal wallet chain id.",
5555
);
5656
invariant(
57-
isAddress(config.safeAddress),
57+
utils.isAddress(config.safeAddress),
5858
"Gnosis safe address must be a valid address.",
5959
);
6060
(connector as GnosisSafeConnector).setConfiguration(

src/utils/cache-keys.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { AddressZero } from "@ethersproject/constants";
21
import {
32
MarketplaceFilter,
43
QueryAllParams,
54
SUPPORTED_CHAIN_ID,
65
} from "@thirdweb-dev/sdk";
6+
import { constants } from "ethers";
77
import { QueryKey } from "react-query";
88

99
const TW_CACHE_KEY_PREFIX = "tw-cache";
@@ -16,7 +16,7 @@ function createCachekey(input: QueryKey): QueryKey {
1616
}
1717

1818
function createContractCacheKey(
19-
contractAddress: string = AddressZero,
19+
contractAddress: string = constants.AddressZero,
2020
input: QueryKey,
2121
): QueryKey {
2222
return createCachekey(["contract", contractAddress, ...input]);

0 commit comments

Comments
 (0)