Compare commits

..
Author SHA1 Message Date
github-actions[bot]andgithub-actions[bot] 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 Tank e78da6b36c [wallets] Wallet connect v2 corrections (#1265) 2023-06-28 13:34:42 +00:00
iketwandManan Tank 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
Joaquim VergesandJonas Daniels 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
github-actions[bot]andgithub-actions[bot] 11bb053246 Version Packages (#1261)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-27 22:16:09 -07:00
iketwandManan Tank efb3546ec8 [Wallets] Fix. Respect dev passed chains. (#1259)
Co-authored-by: Manan Tank <[email protected]>
2023-06-28 05:07:24 +00:00
17 changed files with 156 additions and 29 deletions
+14
View File
@@ -1,5 +1,19 @@
# @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
- Updated dependencies [[`efb3546e`](https://github.com/thirdweb-dev/js/commit/efb3546ec8268156be00301af28b9d83ecd5ab08)]:
- @thirdweb-dev/wallets@1.0.1
## 3.2.4
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "3.2.4",
"version": "3.2.6",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
+14
View File
@@ -1,5 +1,19 @@
# @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
- Updated dependencies [[`efb3546e`](https://github.com/thirdweb-dev/js/commit/efb3546ec8268156be00301af28b9d83ecd5ab08)]:
- @thirdweb-dev/wallets@1.0.1
## 3.14.4
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-core",
"version": "3.14.4",
"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,9 @@
# @thirdweb-dev/react-native-compat
## 0.2.25
## 0.2.24
## 0.2.23
## 0.2.22
+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.23",
"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",
+16
View File
@@ -1,5 +1,21 @@
# @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
- Updated dependencies [[`efb3546e`](https://github.com/thirdweb-dev/js/commit/efb3546ec8268156be00301af28b9d83ecd5ab08)]:
- @thirdweb-dev/wallets@1.0.1
- @thirdweb-dev/react-core@3.14.5
## 0.2.23
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-native",
"version": "0.2.23",
"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",
+16
View File
@@ -1,5 +1,21 @@
# @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
- Updated dependencies [[`efb3546e`](https://github.com/thirdweb-dev/js/commit/efb3546ec8268156be00301af28b9d83ecd5ab08)]:
- @thirdweb-dev/wallets@1.0.1
- @thirdweb-dev/react-core@3.14.5
## 3.14.4
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "3.14.4",
"version": "3.14.6",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+2 -2
View File
@@ -1,12 +1,12 @@
import { ThirdwebSDK } from "../../src/evm";
import { expectError, sdk } from "./before-setup";
import { expect } from "chai";
import { ethers } from "ethers";
import { Wallet } from "ethers";
describe("Error Handling", async () => {
it("should throw proper error on account with no balance", async () => {
const newSdk = ThirdwebSDK.fromSigner(
ethers.Wallet.createRandom().connect(sdk.getProvider()),
Wallet.createRandom().connect(sdk.getProvider()),
);
try {
+16
View File
@@ -1,5 +1,21 @@
# @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
- Updated dependencies [[`efb3546e`](https://github.com/thirdweb-dev/js/commit/efb3546ec8268156be00301af28b9d83ecd5ab08)]:
- @thirdweb-dev/wallets@1.0.1
- @thirdweb-dev/auth@3.2.5
## 0.2.41
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/unity-js-bridge",
"version": "0.2.41",
"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",
+16
View File
@@ -1,5 +1,21 @@
# @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
- [#1259](https://github.com/thirdweb-dev/js/pull/1259) [`efb3546e`](https://github.com/thirdweb-dev/js/commit/efb3546ec8268156be00301af28b9d83ecd5ab08) Thanks [@iketw](https://github.com/iketw)! - Fix. Respecting passed wallets if less then 50, otherwhise use defaults chains.
## 1.0.0
### Major Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/wallets",
"version": "1.0.0",
"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,11 +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
const optionalChains = [
1, 5, 84531, 137, 80001, 42161, 421613, 10, 420, 56, 97, 250, 4002,
43114, 43113, 1337,
].filter((chainId) => chainId !== targetChainId);
const optionalChains = this.filteredChains
.filter((chain) => chain.chainId !== targetChainId)
.map((optionalChain) => optionalChain.chainId);
this.emit("message", { type: "connecting" });
@@ -136,7 +144,7 @@ export class WalletConnectConnector extends WagmiConnector<
});
await this.#setRequestedChainsIds(
this.chains.map(({ chainId }) => chainId),
this.filteredChains.map(({ chainId }) => chainId),
);
}
@@ -305,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,
);
@@ -326,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,
@@ -366,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 (