Compare commits

...
Author SHA1 Message Date
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
7b1d62b323 Version Packages (#1262)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-28 08:07:57 -07:00
Manan TankandGitHub e78da6b36c [wallets] Wallet connect v2 corrections (#1265) 2023-06-28 13:34:42 +00:00
ed711c8cb2 [Wallets] Use min number of chains if user passes more than 50 chains (#1263)
Co-authored-by: Manan Tank <[email protected]>
2023-06-28 12:04:28 +00:00
05a7495a13 [Wallets] handle passing RPC urls to SmartWallet config (#1255)
Co-authored-by: Jonas Daniels <[email protected]>
2023-06-28 07:20:04 +00:00
18 changed files with 110 additions and 34 deletions
+7
View File
@@ -1,5 +1,12 @@
# @thirdweb-dev/auth
## 3.2.6
### Patch Changes
- Updated dependencies [[`ed711c8c`](https://github.com/thirdweb-dev/js/commit/ed711c8cb2ed6a0deb1b2a5eeec06df1d4edc5e8), [`05a7495a`](https://github.com/thirdweb-dev/js/commit/05a7495a132aabab5f48abbdb80a468ff6f65df8), [`e78da6b3`](https://github.com/thirdweb-dev/js/commit/e78da6b36cfa6d954234820563201bf760186ed1)]:
- @thirdweb-dev/wallets@1.0.2
## 3.2.5
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "3.2.5",
"version": "3.2.6",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
+7
View File
@@ -1,5 +1,12 @@
# @thirdweb-dev/react-core
## 3.14.6
### Patch Changes
- Updated dependencies [[`ed711c8c`](https://github.com/thirdweb-dev/js/commit/ed711c8cb2ed6a0deb1b2a5eeec06df1d4edc5e8), [`05a7495a`](https://github.com/thirdweb-dev/js/commit/05a7495a132aabab5f48abbdb80a468ff6f65df8), [`e78da6b3`](https://github.com/thirdweb-dev/js/commit/e78da6b36cfa6d954234820563201bf760186ed1)]:
- @thirdweb-dev/wallets@1.0.2
## 3.14.5
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-core",
"version": "3.14.5",
"version": "3.14.6",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -1,5 +1,7 @@
# @thirdweb-dev/react-native-compat
## 0.2.25
## 0.2.24
## 0.2.23
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects",
"version": "0.2.24",
"version": "0.2.25",
"author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
"license": "Apache-2.0",
+8
View File
@@ -1,5 +1,13 @@
# @thirdweb-dev/react-native
## 0.2.25
### Patch Changes
- Updated dependencies [[`ed711c8c`](https://github.com/thirdweb-dev/js/commit/ed711c8cb2ed6a0deb1b2a5eeec06df1d4edc5e8), [`05a7495a`](https://github.com/thirdweb-dev/js/commit/05a7495a132aabab5f48abbdb80a468ff6f65df8), [`e78da6b3`](https://github.com/thirdweb-dev/js/commit/e78da6b36cfa6d954234820563201bf760186ed1)]:
- @thirdweb-dev/wallets@1.0.2
- @thirdweb-dev/react-core@3.14.6
## 0.2.24
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-native",
"version": "0.2.24",
"version": "0.2.25",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+8
View File
@@ -1,5 +1,13 @@
# @thirdweb-dev/react
## 3.14.6
### Patch Changes
- Updated dependencies [[`ed711c8c`](https://github.com/thirdweb-dev/js/commit/ed711c8cb2ed6a0deb1b2a5eeec06df1d4edc5e8), [`05a7495a`](https://github.com/thirdweb-dev/js/commit/05a7495a132aabab5f48abbdb80a468ff6f65df8), [`e78da6b3`](https://github.com/thirdweb-dev/js/commit/e78da6b36cfa6d954234820563201bf760186ed1)]:
- @thirdweb-dev/wallets@1.0.2
- @thirdweb-dev/react-core@3.14.6
## 3.14.5
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "3.14.5",
"version": "3.14.6",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+1 -1
View File
@@ -4,7 +4,7 @@ import { expect } from "chai";
import { Wallet } from "ethers";
describe("Error Handling", async () => {
test.skip("should throw proper error on account with no balance", async () => {
it("should throw proper error on account with no balance", async () => {
const newSdk = ThirdwebSDK.fromSigner(
Wallet.createRandom().connect(sdk.getProvider()),
);
+1 -1
View File
@@ -177,7 +177,7 @@ describe("Tiered Drop Contract", async () => {
expect(nfts[0].metadata.name).to.equal("NFT #5");
});
test.skip("metadata should reveal correctly", async () => {
it("metadata should reveal correctly", async () => {
contract = await deployTieredDrop();
const placeholder = {
+8
View File
@@ -1,5 +1,13 @@
# @thirdweb-dev/unity-js-bridge
## 0.2.43
### Patch Changes
- Updated dependencies [[`ed711c8c`](https://github.com/thirdweb-dev/js/commit/ed711c8cb2ed6a0deb1b2a5eeec06df1d4edc5e8), [`05a7495a`](https://github.com/thirdweb-dev/js/commit/05a7495a132aabab5f48abbdb80a468ff6f65df8), [`e78da6b3`](https://github.com/thirdweb-dev/js/commit/e78da6b36cfa6d954234820563201bf760186ed1)]:
- @thirdweb-dev/wallets@1.0.2
- @thirdweb-dev/auth@3.2.6
## 0.2.42
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/unity-js-bridge",
"version": "0.2.42",
"version": "0.2.43",
"main": "dist/thirdweb-unity-bridge.js",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
"license": "Apache-2.0",
+10
View File
@@ -1,5 +1,15 @@
# @thirdweb-dev/wallets
## 1.0.2
### Patch Changes
- [#1263](https://github.com/thirdweb-dev/js/pull/1263) [`ed711c8c`](https://github.com/thirdweb-dev/js/commit/ed711c8cb2ed6a0deb1b2a5eeec06df1d4edc5e8) Thanks [@iketw](https://github.com/iketw)! - Pass a min set of chains if user passes more than 50 chains. We'll rely on "adding chains" for new chains
- [#1255](https://github.com/thirdweb-dev/js/pull/1255) [`05a7495a`](https://github.com/thirdweb-dev/js/commit/05a7495a132aabab5f48abbdb80a468ff6f65df8) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Handle passing RPC urls as chain in SmartWallet config
- [#1265](https://github.com/thirdweb-dev/js/pull/1265) [`e78da6b3`](https://github.com/thirdweb-dev/js/commit/e78da6b36cfa6d954234820563201bf760186ed1) Thanks [@MananTank](https://github.com/MananTank)! - Wallet Connect v2 Corrections
## 1.0.1
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/wallets",
"version": "1.0.1",
"version": "1.0.2",
"main": "dist/thirdweb-dev-wallets.cjs.js",
"module": "dist/thirdweb-dev-wallets.esm.js",
"types": "dist/thirdweb-dev-wallets.cjs.d.ts",
@@ -1,4 +1,4 @@
import { Chain } from "@thirdweb-dev/chains";
import { Chain, getChainByChainId } from "@thirdweb-dev/chains";
import { ConnectParams, Connector } from "../../interfaces/connector";
import { ERC4337EthersProvider } from "./lib/erc4337-provider";
import { getVerifyingPaymaster } from "./lib/paymaster";
@@ -15,6 +15,7 @@ import { EVMWallet } from "../../interfaces";
import { ERC4337EthersSigner } from "./lib/erc4337-signer";
import { BigNumber, ethers, providers } from "ethers";
import {
ChainOrRpcUrl,
getChainProvider,
SmartContract,
Transaction,
@@ -36,14 +37,14 @@ export class SmartWalletConnector extends Connector<SmartWalletConnectionArgs> {
async initialize(personalWallet: EVMWallet) {
const config = this.config;
const chain =
typeof config.chain === "string"
? config.chain
: (config.chain as Chain).slug;
const originalProvider = getChainProvider(config.chain, {
thirdwebApiKey: config.thirdwebApiKey || DEFAULT_WALLET_API_KEY,
}) as providers.BaseProvider;
const chainSlug = await this.getChainSlug(config.chain, originalProvider);
const bundlerUrl =
this.config.bundlerUrl || `https://${chain}.bundler.thirdweb.com`;
this.config.bundlerUrl || `https://${chainSlug}.bundler.thirdweb.com`;
const paymasterUrl =
this.config.paymasterUrl || `https://${chain}.bundler.thirdweb.com`;
this.config.paymasterUrl || `https://${chainSlug}.bundler.thirdweb.com`;
const entryPointAddress = config.entryPointAddress || ENTRYPOINT_ADDRESS;
const localSigner = await personalWallet.getSigner();
const providerConfig: ProviderConfig = {
@@ -65,9 +66,6 @@ export class SmartWalletConnector extends Connector<SmartWalletConnectionArgs> {
accountInfo: config.accountInfo || this.defaultAccountInfo(),
thirdwebApiKey: config.thirdwebApiKey,
};
const originalProvider = getChainProvider(config.chain, {
thirdwebApiKey: config.thirdwebApiKey || DEFAULT_WALLET_API_KEY,
}) as providers.BaseProvider;
this.personalWallet = personalWallet;
const accountApi = new AccountAPI(providerConfig, originalProvider);
this.aaProvider = await create4337Provider(
@@ -251,4 +249,29 @@ export class SmartWalletConnector extends Connector<SmartWalletConnectionArgs> {
},
};
}
private async getChainSlug(
chainOrRpc: ChainOrRpcUrl,
provider: ethers.providers.Provider,
): Promise<string> {
if (typeof chainOrRpc === "object") {
return chainOrRpc.slug;
}
if (typeof chainOrRpc === "number") {
const chain = getChainByChainId(chainOrRpc);
return chain.slug;
}
if (typeof chainOrRpc === "string") {
if (chainOrRpc.startsWith("http") || chainOrRpc.startsWith("ws")) {
// if it's a url, try to get the chain id from the provider
const chainId = (await provider.getNetwork()).chainId;
const chain = getChainByChainId(chainId);
return chain.slug;
}
// otherwise its the network name
return chainOrRpc;
} else {
throw new Error(`Invalid network: ${chainOrRpc}`);
}
}
}
@@ -12,6 +12,8 @@ import { providers, utils } from "ethers";
import { walletIds } from "../../constants/walletIds";
import { QRModalOptions } from "./qrModalOptions";
const chainsToRequest = new Set([1, 137, 10, 42161, 56]);
type WalletConnectOptions = {
qrModalOptions?: QRModalOptions;
projectId: string;
@@ -78,6 +80,7 @@ export class WalletConnectConnector extends WagmiConnector<
#provider?: WalletConnectProvider;
#initProviderPromise?: Promise<void>;
#storage: AsyncStorage;
filteredChains: Chain[];
constructor(config: { chains?: Chain[]; options: WalletConnectOptions }) {
super({
@@ -86,6 +89,13 @@ export class WalletConnectConnector extends WagmiConnector<
});
this.#storage = config.options.storage;
this.#createProvider();
this.filteredChains =
this.chains.length > 50
? this.chains.filter((c) => {
return chainsToRequest.has(c.chainId);
})
: this.chains;
}
async connect({ chainId: chainIdP, pairingTopic }: ConnectConfig = {}) {
@@ -101,7 +111,7 @@ export class WalletConnectConnector extends WagmiConnector<
if (lastUsedChainId && !this.isChainUnsupported(lastUsedChainId)) {
targetChainId = lastUsedChainId;
} else {
targetChainId = this.chains[0]?.chainId;
targetChainId = this.filteredChains[0]?.chainId;
}
}
if (!targetChainId) {
@@ -120,16 +130,9 @@ export class WalletConnectConnector extends WagmiConnector<
// If there no active session, or the chains are stale, connect.
if (!provider.session || isChainsStale) {
// defaultChains, passing ALL CHAINS hangs the connector
// respect user's chains if less than 50
const optionalChains = (
this.chains.length > 50
? [
1, 5, 84531, 137, 80001, 42161, 421613, 10, 420, 56, 97, 250,
4002, 43114, 43113, 1337,
]
: this.chains.map(({ chainId }) => chainId)
).filter((chainId) => chainId !== targetChainId);
const optionalChains = this.filteredChains
.filter((chain) => chain.chainId !== targetChainId)
.map((optionalChain) => optionalChain.chainId);
this.emit("message", { type: "connecting" });
@@ -141,7 +144,7 @@ export class WalletConnectConnector extends WagmiConnector<
});
await this.#setRequestedChainsIds(
this.chains.map(({ chainId }) => chainId),
this.filteredChains.map(({ chainId }) => chainId),
);
}
@@ -310,7 +313,7 @@ export class WalletConnectConnector extends WagmiConnector<
OPTIONAL_EVENTS,
OPTIONAL_METHODS,
} = await import("@walletconnect/ethereum-provider");
const [defaultChain, ...optionalChains] = this.chains.map(
const [defaultChain, ...optionalChains] = this.filteredChains.map(
({ chainId }) => chainId,
);
@@ -331,7 +334,7 @@ export class WalletConnectConnector extends WagmiConnector<
icons: [this.options.dappMetadata.logoUrl || ""],
},
rpcMap: Object.fromEntries(
this.chains.map((chain) => [chain.chainId, chain.rpc[0]]),
this.filteredChains.map((chain) => [chain.chainId, chain.rpc[0]]),
),
qrModalOptions: this.options.qrModalOptions,
@@ -371,7 +374,7 @@ export class WalletConnectConnector extends WagmiConnector<
}
const requestedChains = await this.#getRequestedChainsIds();
const connectorChains = this.chains.map(({ chainId }) => chainId);
const connectorChains = this.filteredChains.map(({ chainId }) => chainId);
const namespaceChains = this.#getNamespaceChainsIds();
if (