Skip to content

Commit f944318

Browse files
authored
chore(deps): bump web3auth to v10 (#575)
* chore(deps): bump web3auth to v10 * ci: bump node
1 parent ee5976d commit f944318

File tree

10 files changed

+1197
-513
lines changed

10 files changed

+1197
-513
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: node
1919
uses: actions/setup-node@v4
2020
with:
21-
node-version: 20.9.0
21+
node-version: 20.18.0
2222

2323
- name: Deps
2424
run: |

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
"devDependencies": {
2525
"@types/jest": "29.0.3",
2626
"@types/node": "18.7.18",
27-
"@typescript-eslint/eslint-plugin": "5.38.0",
28-
"@typescript-eslint/parser": "5.38.0",
29-
"eslint": "8.23.1",
27+
"@typescript-eslint/eslint-plugin": "7.18.0",
28+
"@typescript-eslint/parser": "7.18.0",
29+
"eslint": "8.57.1",
3030
"eslint-config-prettier": "8.5.0",
3131
"eslint-plugin-prettier": "4.2.1",
3232
"eslint-plugin-simple-import-sort": "8.0.0",
@@ -37,8 +37,8 @@
3737
"prettier": "2.7.1",
3838
"publish-scripts": "0.1.0",
3939
"rimraf": "3.0.2",
40-
"ts-jest": "29.0.1",
41-
"typescript": "4.8.3"
40+
"ts-jest": "29.4.5",
41+
"typescript": "5.8.3"
4242
},
4343
"workspaces": [
4444
"packages/*",
@@ -48,4 +48,4 @@
4848
"type": "git",
4949
"url": "https://github.com/hyperweb-io/cosmos-kit#readme"
5050
}
51-
}
51+
}

wallets/web3auth/package.json

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,17 @@
5757
]
5858
},
5959
"dependencies": {
60+
"@toruslabs/eccrypto": "6.2.0",
6061
"@cosmos-kit/core": "^2.16.7",
61-
"@solana/web3.js": "^1.77.3",
62-
"@toruslabs/eccrypto": "^2.1.1",
63-
"@web3auth/auth-adapter": "^9.5.0",
64-
"@web3auth/base": "^9.5.0",
65-
"@web3auth/base-provider": "^9.5.0",
66-
"@web3auth/ethereum-provider": "^9.5.0",
67-
"@web3auth/no-modal": "^9.5.0",
68-
"@web3auth/solana-provider": "^9.5.0",
69-
"ethereum-cryptography": "^2.1.2",
70-
"url": "^0.11.1"
62+
"@web3auth/auth": "^10.5.0",
63+
"@web3auth/modal": "^10.4.0",
64+
"url": "^0.11.1",
65+
"viem": "^2.23.0",
66+
"@react-native-async-storage/async-storage": "^2.2.0"
7167
},
7268
"devDependencies": {
73-
"@chain-registry/types": "^0.46.11"
69+
"@chain-registry/types": "^0.46.11",
70+
"typescript": "5.8.3"
7471
},
7572
"peerDependencies": {
7673
"@chain-registry/types": ">= 0.17",

wallets/web3auth/src/extension/client.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { OfflineAminoSigner, StdSignature } from '@cosmjs/amino';
33
import { OfflineDirectSigner } from '@cosmjs/proto-signing';
44
import { DappEnv, WalletClient } from '@cosmos-kit/core';
55
import { makeADR36AminoSignDoc } from '@keplr-wallet/cosmos';
6-
import eccrypto from '@toruslabs/eccrypto';
7-
import { LOGIN_PROVIDER } from '@web3auth/auth-adapter';
8-
import { UserInfo } from '@web3auth/base';
6+
import * as eccrypto from '@toruslabs/eccrypto';
7+
import { AUTH_CONNECTION, UserInfo } from '@web3auth/modal';
98

109
import { Web3AuthSigner } from './signer';
1110
import { Web3AuthClientOptions } from './types';
@@ -61,8 +60,8 @@ export class Web3AuthClient implements WalletClient {
6160
}
6261

6362
if (
64-
(this.#options?.loginProvider === LOGIN_PROVIDER.EMAIL_PASSWORDLESS ||
65-
this.#options?.loginProvider === LOGIN_PROVIDER.SMS_PASSWORDLESS) &&
63+
(this.#options?.loginProvider === AUTH_CONNECTION.EMAIL_PASSWORDLESS ||
64+
this.#options?.loginProvider === AUTH_CONNECTION.SMS_PASSWORDLESS) &&
6665
this.#loginHint === undefined
6766
) {
6867
throw new Error(

wallets/web3auth/src/extension/main-wallet.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { MainWalletBase } from '@cosmos-kit/core';
2-
import { getHashQueryParams } from '@web3auth/auth-adapter';
3-
import { WEB3AUTH_NETWORK } from '@web3auth/base';
2+
import { getHashQueryParams } from '@web3auth/auth';
3+
import { WEB3AUTH_NETWORK } from '@web3auth/modal';
44

55
import { Web3AuthChainWallet } from './chain-wallet';
66
import { Web3AuthClient } from './client';
@@ -30,7 +30,8 @@ export class Web3AuthWallet extends MainWalletBase {
3030
if (
3131
typeof options.client?.web3AuthNetwork !== 'string' ||
3232
!Object.values(WEB3AUTH_NETWORK).includes(
33-
options.client.web3AuthNetwork
33+
options.client
34+
.web3AuthNetwork as typeof WEB3AUTH_NETWORK[keyof typeof WEB3AUTH_NETWORK]
3435
)
3536
) {
3637
throw new Error('Invalid web3auth network');

wallets/web3auth/src/extension/signer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
DirectSignResponse,
1010
OfflineDirectSigner,
1111
} from '@cosmjs/proto-signing';
12-
import eccrypto from '@toruslabs/eccrypto';
12+
import * as eccrypto from '@toruslabs/eccrypto';
1313
import { SignDoc } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
1414

1515
import { PromptSign, SignData, ToWorkerMessage } from './types';

wallets/web3auth/src/extension/types.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,23 @@ import { AminoSignResponse, StdSignDoc } from '@cosmjs/amino';
22
import { AccountData, DirectSignResponse } from '@cosmjs/proto-signing';
33
import { Wallet } from '@cosmos-kit/core';
44
import { Ecies } from '@toruslabs/eccrypto';
5-
import {
6-
LOGIN_PROVIDER_TYPE,
7-
MfaLevelType,
8-
WEB3AUTH_NETWORK_TYPE,
9-
} from '@web3auth/auth-adapter';
10-
import { Web3AuthNoModalOptions } from '@web3auth/base';
5+
import { AUTH_CONNECTION_TYPE, Web3AuthNoModalOptions } from '@web3auth/modal';
116
import { SignDoc } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
127

138
export type Web3AuthWalletInfo = Wallet & { options: Web3AuthClientOptions };
149

1510
export type Web3AuthLoginMethod = {
16-
provider: LOGIN_PROVIDER_TYPE;
11+
provider: AUTH_CONNECTION_TYPE;
1712
name: string;
1813
logo: string;
1914
};
2015

2116
export type Web3AuthClientOptions = {
22-
loginProvider: LOGIN_PROVIDER_TYPE;
23-
mfaLevel?: MfaLevelType;
17+
loginProvider: AUTH_CONNECTION_TYPE;
2418
getLoginHint?: () => string | undefined;
2519

2620
// Web3Auth client options.
27-
client: {
28-
clientId: string;
29-
web3AuthNetwork: WEB3AUTH_NETWORK_TYPE;
30-
} & Omit<Web3AuthNoModalOptions, 'chainConfig'> & {
31-
chainConfig?: Omit<
32-
Web3AuthNoModalOptions['chainConfig'],
33-
'chainNamespace'
34-
>;
35-
};
21+
client: Web3AuthNoModalOptions;
3622

3723
// Mobile devices block popups by default, so the default behavior is to use
3824
// the redirect method to sign-in on mobile, and the popup method on desktop.

wallets/web3auth/src/extension/utils.ts

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import { sha256 } from '@cosmjs/crypto';
22
import { toUtf8 } from '@cosmjs/encoding';
3-
import eccrypto, { Ecies } from '@toruslabs/eccrypto';
4-
import { AuthAdapter, AuthLoginParams } from '@web3auth/auth-adapter';
3+
import * as eccrypto from '@toruslabs/eccrypto';
4+
import { Ecies } from '@toruslabs/eccrypto';
55
import {
6-
ADAPTER_STATUS,
7-
CHAIN_NAMESPACES,
8-
CustomChainConfig,
6+
CONNECTOR_STATUS,
97
SafeEventEmitterProvider,
108
UX_MODE,
11-
WALLET_ADAPTERS,
12-
} from '@web3auth/base';
13-
import { CommonPrivateKeyProvider } from '@web3auth/base-provider';
14-
import { Web3AuthNoModal } from '@web3auth/no-modal';
9+
WALLET_CONNECTORS,
10+
Web3Auth,
11+
} from '@web3auth/modal';
1512

1613
import {
1714
FromWorkerMessage,
@@ -116,28 +113,11 @@ export const connectClientAndProvider = async (
116113
options: Web3AuthClientOptions,
117114
{ dontAttemptLogin = false } = {}
118115
): Promise<{
119-
client: Web3AuthNoModal;
116+
client: Web3Auth;
120117
provider: SafeEventEmitterProvider | null;
121118
}> => {
122-
const chainConfig: CustomChainConfig = {
123-
chainId: 'other',
124-
rpcTarget: 'other',
125-
displayName: 'other',
126-
blockExplorerUrl: 'other',
127-
ticker: 'other',
128-
tickerName: 'other',
129-
...options.client.chainConfig,
130-
chainNamespace: CHAIN_NAMESPACES.OTHER,
131-
};
132-
const privateKeyProvider = new CommonPrivateKeyProvider({
133-
config: {
134-
chainConfig,
135-
},
136-
});
137-
const client = new Web3AuthNoModal({
119+
const client = new Web3Auth({
138120
...options.client,
139-
chainConfig,
140-
privateKeyProvider,
141121
});
142122

143123
// Popups are blocked by default on mobile browsers, so use redirect. Popup is
@@ -157,27 +137,29 @@ export const connectClientAndProvider = async (
157137
);
158138
}
159139

160-
const mfaLevel = options.mfaLevel ?? 'default';
161-
const authAdapter = new AuthAdapter({
162-
adapterSettings: {
163-
uxMode,
164-
},
165-
loginSettings: {
166-
mfaLevel,
167-
},
168-
});
169-
client.configureAdapter(authAdapter);
170-
171140
await client.init();
172141

142+
// Wait up to 10 seconds for the client to be ready or connected.
143+
// This is necessary on v10 because init() does not wait for the session to
144+
// be restored.
145+
const timeout = 10000;
146+
const startTime = Date.now();
147+
while (
148+
client.status !== CONNECTOR_STATUS.READY &&
149+
client.status !== CONNECTOR_STATUS.CONNECTED &&
150+
Date.now() - startTime < timeout
151+
) {
152+
await new Promise((resolve) => setTimeout(resolve, 100));
153+
}
154+
173155
let provider = client.connected ? client.provider : null;
174156
if (!client.connected && !dontAttemptLogin) {
175157
try {
176158
const loginHint = options.getLoginHint?.();
177-
provider = await client.connectTo(WALLET_ADAPTERS.AUTH, {
178-
loginProvider: options.loginProvider,
179-
login_hint: loginHint,
180-
} as AuthLoginParams);
159+
provider = await client.connectTo(WALLET_CONNECTORS.AUTH, {
160+
authConnection: options.loginProvider,
161+
loginHint: loginHint,
162+
});
181163
} catch (err) {
182164
// Unnecessary error thrown during redirect, so log and ignore it.
183165
if (
@@ -194,7 +176,7 @@ export const connectClientAndProvider = async (
194176
}
195177

196178
if (usingRedirect) {
197-
if (client.status === ADAPTER_STATUS.CONNECTED) {
179+
if (client.status === CONNECTOR_STATUS.CONNECTED) {
198180
// On successful connection from a redirect, remove the localStorage key
199181
// so we do not attempt to auto connect on the next page load.
200182
localStorage.removeItem(WEB3AUTH_REDIRECT_AUTO_CONNECT_KEY);

wallets/web3auth/src/extension/web3auth.worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Secp256k1Wallet } from '@cosmjs/amino';
22
import { DirectSecp256k1Wallet } from '@cosmjs/proto-signing';
3-
import eccrypto from '@toruslabs/eccrypto';
3+
import * as eccrypto from '@toruslabs/eccrypto';
44

55
import { ToWorkerMessage } from './types';
66
import { decrypt, hashObject } from './utils';

0 commit comments

Comments
 (0)