Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade dependencies across the codebase #454

Merged
merged 3 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/five-candles-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"thirdweb": patch
"@thirdweb-dev/react": patch
"@thirdweb-dev/sdk": patch
"@thirdweb-dev/unity-js-bridge": patch
"@thirdweb-dev/wallets": patch
---

upgraded dependencies
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@changesets/cli": "^2.24.3",
"@manypkg/cli": "^0.19.1",
"@manypkg/get-packages": "^1.1.3",
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
"eslint": "^8.21.0",
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.7.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"@types/prompts": "^2.0.14",
"@types/rimraf": "^3.0.0",
"@types/tar": "^6.1.2",
"@types/update-notifier": "^5.1.0",
"@types/update-notifier": "^6.0.1",
"@types/validate-npm-package-name": "^4.0.0",
"hardhat": "^2.9.3",
"jest": "^28",
"jest": "^29",
"prettier": "^2.7.1",
"ts-jest": "^28.0.8",
"ts-jest": "^29.0.3",
"ts-node": "^10.7.0",
"tsup": "^6.2.3",
"typescript": "^4.7.4"
Expand Down Expand Up @@ -74,4 +74,4 @@
"sourcemap": true,
"clean": true
}
}
}
12 changes: 6 additions & 6 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,19 @@
"dependencies": {
"@emotion/react": "^11.10.0",
"@emotion/styled": "^11.10.0",
"@gnosis.pm/safe-core-sdk": "^3.1.1",
"@gnosis.pm/safe-ethers-adapters": "0.1.0-alpha.11",
"@gnosis.pm/safe-ethers-lib": "^1.6.1",
"@react-icons/all-files": "^4.1.0",
"@safe-global/safe-core-sdk": "^3.2.0",
"@safe-global/safe-ethers-adapters": "0.1.0-alpha.13",
"@safe-global/safe-ethers-lib": "^1.7.0",
"@solana/wallet-adapter-phantom": "^0.9.17",
"@tanstack/react-query": "^4.0.10",
"@zag-js/menu": "^0.1.16",
"@zag-js/react": "^0.1.18",
"@zag-js/menu": "^0.3.0",
"@zag-js/react": "^0.3.1",
"buffer": "^6.0.3",
"color": "^4.2.3",
"copy-to-clipboard": "^3.3.2",
"detect-browser": "^5.3.0",
"magic-sdk": "^8.1.1",
"magic-sdk": "^10.0.0",
"mime": "^3.0.0",
"react-cool-dimensions": "^2.0.7",
"tiny-invariant": "^1.2.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/evm/connectors/gnosis-safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ export class GnosisSafeConnector extends Connector {
invariant(serverUrl, "Chain not supported");

const [safeEthersAdapters, safeCoreSdk, safeEthersLib] = await Promise.all([
import("@gnosis.pm/safe-ethers-adapters"),
import("@gnosis.pm/safe-core-sdk"),
import("@gnosis.pm/safe-ethers-lib"),
import("@safe-global/safe-ethers-adapters"),
import("@safe-global/safe-core-sdk"),
import("@safe-global/safe-ethers-lib"),
]);

const ethAdapter = new safeEthersLib.default({
Expand Down

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@types/deep-equal-in-any-order": "^1.0.1",
"@types/mocha": "^10.0.0",
"@types/node": "^18.0.0",
"@types/uuid": "^8.3.3",
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"chai": "^4.3.6",
Expand Down Expand Up @@ -146,4 +146,4 @@
"url": "https://github.com/thirdweb-dev/js/issues"
},
"author": "thirdweb eng <eng@thirdweb.com>"
}
}
4 changes: 2 additions & 2 deletions packages/unity-js-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"dist/"
],
"dependencies": {
"@thirdweb-dev/pay": "*",
"@thirdweb-dev/sdk": "*",
"@thirdweb-dev/storage": "*",
"@thirdweb-dev/wallets": "*",
"@thirdweb-dev/pay": "*",
"ethers": "^5.7.2"
},
"devDependencies": {
"esbuild": "^0.15.16",
"esbuild": "0.15.17",
"node-stdlib-browser": "^1.2.0",
"typescript": "^4.7.4"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/wallets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"sideEffects": false,
"dependencies": {
"@coinbase/wallet-sdk": "^3.6.0",
"@wagmi/core": "^0.7.6",
"@wagmi/chains": "^0.1.0",
"@wagmi/core": "^0.8.0",
"@walletconnect/ethereum-provider": "^1.7.8",
"abitype": "^0.2.5",
"ethers": "^5.7.2",
Expand Down
11 changes: 8 additions & 3 deletions packages/wallets/src/connectors/coinbase-wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ export class CoinbaseWalletConnector extends Connector<
: chain_.id === walletExtensionChainId,
) || this.chains[0];
const chainId = this.options.chainId || chain?.id;
const jsonRpcUrl = this.options.jsonRpcUrl || chain?.rpcUrls.default;
const jsonRpcUrl =
this.options.jsonRpcUrl || chain?.rpcUrls.default.http[0];

this.#provider = this.#client.makeWeb3Provider(jsonRpcUrl, chainId);
}
Expand Down Expand Up @@ -199,7 +200,8 @@ export class CoinbaseWalletConnector extends Connector<
id: chainId,
name: `Chain ${id}`,
network: `${id}`,
rpcUrls: { default: "" },
nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
rpcUrls: { default: { http: [""] } },
}
);
} catch (error) {
Expand All @@ -218,7 +220,10 @@ export class CoinbaseWalletConnector extends Connector<
chainId: id,
chainName: chain.name,
nativeCurrency: chain.nativeCurrency,
rpcUrls: [chain.rpcUrls.public ?? chain.rpcUrls.default],
rpcUrls: [
chain.rpcUrls.public?.http[0] ??
chain.rpcUrls.default.http[0],
],
blockExplorerUrls: this.getBlockExplorerUrls(chain),
},
],
Expand Down
86 changes: 52 additions & 34 deletions packages/wallets/src/connectors/injected/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ import type { Address } from "abitype";
import { providers } from "ethers";
import { getAddress, hexValue } from "ethers/lib/utils.js";

declare interface Window {
ethereum: Ethereum;
}

export type InjectedConnectorOptions = {
/** Name of connector */
name?: string | ((detectedName: string | string[]) => string);
/**
* [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) Ethereum Provider to target
*
* @default
* () => typeof window !== 'undefined' ? window.ethereum : undefined
*/
getProvider?: () => Ethereum | undefined;
/**
* MetaMask 10.9.3 emits disconnect event when chain is changed.
* This flag prevents the `"disconnect"` event from being emitted upon switching chains. See [GitHub issue](https://github.com/MetaMask/metamask-extension/issues/13375#issuecomment-1027663334) for more info.
Expand All @@ -38,16 +41,19 @@ export type InjectedConnectorOptions = {
shimDisconnect?: boolean;
};

type ConnectorOptions = InjectedConnectorOptions &
Required<Pick<InjectedConnectorOptions, "getProvider">>;

export class InjectedConnector extends Connector<
Window["ethereum"],
InjectedConnectorOptions | undefined,
Ethereum,
ConnectorOptions,
providers.JsonRpcSigner
> {
readonly id: string;
readonly name: string;
readonly ready = typeof window !== "undefined" && !!window.ethereum;
readonly ready: boolean;

#provider?: Window["ethereum"];
#provider?: Ethereum;
#switchingChains?: boolean;

protected shimDisconnectKey = "injected.shimDisconnect";
Expand All @@ -62,28 +68,34 @@ export class InjectedConnector extends Connector<
const options = {
shimDisconnect: true,
shimChainChangedDisconnect: true,
getProvider: () =>
typeof window !== "undefined"
? (window.ethereum as Ethereum)
: undefined,
...options_,
};
super({ chains, options });

let name = "Injected";
const overrideName = options.name;
if (typeof overrideName === "string") {
name = overrideName;
} else if (typeof window !== "undefined") {
const detectedName = getInjectedName(window.ethereum as Ethereum);
if (overrideName) {
name = overrideName(detectedName);
const provider = options.getProvider();
if (typeof options.name === "string") {
this.name = options.name;
} else if (provider) {
const detectedName = getInjectedName(provider as Ethereum);
if (options.name) {
this.name = options.name(detectedName);
} else {
name =
typeof detectedName === "string"
? detectedName
: (detectedName[0] as string);
if (typeof detectedName === "string") {
this.name = detectedName;
} else {
this.name = detectedName[0] as string;
}
}
} else {
this.name = "Injected";
}

this.id = "injected";
this.name = name;
this.ready = !!provider;
}

async connect({ chainId }: { chainId?: number } = {}) {
Expand Down Expand Up @@ -115,8 +127,8 @@ export class InjectedConnector extends Connector<
}

// Add shim to storage signalling wallet is connected
if (this.options?.shimDisconnect) {
await getConnectorStorage().setItem(this.shimDisconnectKey, true);
if (this.options.shimDisconnect) {
await getConnectorStorage()?.setItem(this.shimDisconnectKey, true);
}

return { account, chain: { id, unsupported }, provider };
Expand All @@ -142,8 +154,8 @@ export class InjectedConnector extends Connector<
provider.removeListener("disconnect", this.onDisconnect);

// Remove shim signalling wallet is disconnected
if (this.options?.shimDisconnect) {
await getConnectorStorage().removeItem(this.shimDisconnectKey);
if (this.options.shimDisconnect) {
await getConnectorStorage()?.removeItem(this.shimDisconnectKey);
}
}

Expand All @@ -168,8 +180,9 @@ export class InjectedConnector extends Connector<
}

async getProvider() {
if (typeof window !== "undefined" && !!window.ethereum) {
this.#provider = window.ethereum as Ethereum;
const provider = this.options.getProvider();
if (provider) {
this.#provider = provider;
}
return this.#provider as Ethereum;
}
Expand All @@ -188,9 +201,9 @@ export class InjectedConnector extends Connector<
async isAuthorized() {
try {
if (
this.options?.shimDisconnect &&
this.options.shimDisconnect &&
// If shim does not exist in storage, wallet is disconnected
!(await getConnectorStorage().getItem(this.shimDisconnectKey))
!(await getConnectorStorage()?.getItem(this.shimDisconnectKey))
) {
return false;
}
Expand All @@ -207,7 +220,7 @@ export class InjectedConnector extends Connector<
}

async switchChain(chainId: number) {
if (this.options?.shimChainChangedDisconnect) {
if (this.options.shimChainChangedDisconnect) {
this.#switchingChains = true;
}

Expand All @@ -227,7 +240,8 @@ export class InjectedConnector extends Connector<
id: chainId,
name: `Chain ${id}`,
network: `${id}`,
rpcUrls: { default: "" },
nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
rpcUrls: { default: { http: [""] } },
}
);
} catch (error) {
Expand All @@ -252,7 +266,11 @@ export class InjectedConnector extends Connector<
chainId: id,
chainName: chain.name,
nativeCurrency: chain.nativeCurrency,
rpcUrls: [chain.rpcUrls.public ?? chain.rpcUrls.default],
rpcUrls: [
chain.rpcUrls.public?.http[0] ??
chain.rpcUrls.default.http[0] ??
"",
],
blockExplorerUrls: this.getBlockExplorerUrls(chain),
},
],
Expand Down Expand Up @@ -322,14 +340,14 @@ export class InjectedConnector extends Connector<
// We need this as MetaMask can emit the "disconnect" event
// upon switching chains. This workaround ensures that the
// user currently isn't in the process of switching chains.
if (this.options?.shimChainChangedDisconnect && this.#switchingChains) {
if (this.options.shimChainChangedDisconnect && this.#switchingChains) {
this.#switchingChains = false;
return;
}

this.emit("disconnect");
// Remove shim signalling wallet is disconnected
if (this.options?.shimDisconnect) {
if (this.options.shimDisconnect) {
await getConnectorStorage().removeItem(this.shimDisconnectKey);
}
};
Expand Down