Skip to content

Commit

Permalink
Merge pull request #524 from fmorency/bump-web3auth-9
Browse files Browse the repository at this point in the history
chore: bump web3auth to 9.5.0
  • Loading branch information
pyramation authored Jan 15, 2025
2 parents 4f79057 + 6ce7587 commit bf08c48
Show file tree
Hide file tree
Showing 6 changed files with 565 additions and 610 deletions.
12 changes: 6 additions & 6 deletions wallets/web3auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@
"@cosmos-kit/core": "^2.15.1",
"@solana/web3.js": "^1.77.3",
"@toruslabs/eccrypto": "^2.1.1",
"@web3auth/base": "^8.12.4",
"@web3auth/base-provider": "^8.12.4",
"@web3auth/ethereum-provider": "^8.12.4",
"@web3auth/no-modal": "^8.12.4",
"@web3auth/openlogin-adapter": "^8.12.4",
"@web3auth/solana-provider": "^8.12.4",
"@web3auth/base": "^9.5.0",
"@web3auth/base-provider": "^9.5.0",
"@web3auth/ethereum-provider": "^9.5.0",
"@web3auth/no-modal": "^9.5.0",
"@web3auth/auth-adapter": "^9.5.0",
"@web3auth/solana-provider": "^9.5.0",
"ethereum-cryptography": "^2.1.2",
"url": "^0.11.1"
},
Expand Down
2 changes: 1 addition & 1 deletion wallets/web3auth/src/extension/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { OfflineDirectSigner } from '@cosmjs/proto-signing';
import { DappEnv, WalletClient } from '@cosmos-kit/core';
import { makeADR36AminoSignDoc } from '@keplr-wallet/cosmos';
import eccrypto from '@toruslabs/eccrypto';
import { LOGIN_PROVIDER } from '@web3auth/auth-adapter';
import { UserInfo } from '@web3auth/base';
import { LOGIN_PROVIDER } from '@web3auth/openlogin-adapter';

import { Web3AuthSigner } from './signer';
import { Web3AuthClientOptions } from './types';
Expand Down
10 changes: 4 additions & 6 deletions wallets/web3auth/src/extension/main-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MainWalletBase } from '@cosmos-kit/core';
import { getHashQueryParams } from '@toruslabs/openlogin';
import { OPENLOGIN_NETWORK } from '@web3auth/openlogin-adapter';
import { getHashQueryParams } from '@web3auth/auth-adapter';
import { WEB3AUTH_NETWORK } from '@web3auth/base';

import { Web3AuthChainWallet } from './chain-wallet';
import { Web3AuthClient } from './client';
Expand Down Expand Up @@ -29,7 +29,7 @@ export class Web3AuthWallet extends MainWalletBase {

if (
typeof options.client?.web3AuthNetwork !== 'string' ||
!Object.values(OPENLOGIN_NETWORK).includes(
!Object.values(WEB3AUTH_NETWORK).includes(
options.client.web3AuthNetwork
)
) {
Expand Down Expand Up @@ -69,9 +69,7 @@ export class Web3AuthWallet extends MainWalletBase {
return;
}

// Same logic used in `@web3auth/openlogin-adapter` >
// `@toruslabs/openlogin` init function to determine if the adapter should
// attempt to connect from the redirect.
// Same logic used in `@web3auth/auth-adapter` >
const redirectResult = getHashQueryParams();
const shouldAutoConnect =
Object.keys(redirectResult).length > 0 &&
Expand Down
8 changes: 4 additions & 4 deletions wallets/web3auth/src/extension/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { AminoSignResponse, StdSignDoc } from '@cosmjs/amino';
import { AccountData, DirectSignResponse } from '@cosmjs/proto-signing';
import { Wallet } from '@cosmos-kit/core';
import { Ecies } from '@toruslabs/eccrypto';
import { Web3AuthNoModalOptions } from '@web3auth/base';
import {
LOGIN_PROVIDER_TYPE,
OPENLOGIN_NETWORK_TYPE,
} from '@web3auth/openlogin-adapter';
WEB3AUTH_NETWORK_TYPE,
} from '@web3auth/auth-adapter';
import { Web3AuthNoModalOptions } from '@web3auth/base';
import { SignDoc } from 'cosmjs-types/cosmos/tx/v1beta1/tx';

export type Web3AuthWalletInfo = Wallet & { options: Web3AuthClientOptions };
Expand All @@ -24,7 +24,7 @@ export type Web3AuthClientOptions = {
// Web3Auth client options.
client: {
clientId: string;
web3AuthNetwork: OPENLOGIN_NETWORK_TYPE;
web3AuthNetwork: WEB3AUTH_NETWORK_TYPE;
} & Omit<Web3AuthNoModalOptions, 'chainConfig'> & {
chainConfig?: Omit<
Web3AuthNoModalOptions['chainConfig'],
Expand Down
29 changes: 13 additions & 16 deletions wallets/web3auth/src/extension/utils.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { sha256 } from '@cosmjs/crypto';
import { toUtf8 } from '@cosmjs/encoding';
import eccrypto, { Ecies } from '@toruslabs/eccrypto';
import { AuthAdapter, AuthLoginParams } from '@web3auth/auth-adapter';
import {
ADAPTER_STATUS,
CHAIN_NAMESPACES,
CustomChainConfig,
SafeEventEmitterProvider,
UX_MODE,
WALLET_ADAPTERS,
} from '@web3auth/base';
import { CommonPrivateKeyProvider } from '@web3auth/base-provider';
import { Web3AuthNoModal } from '@web3auth/no-modal';
import {
OpenloginAdapter,
OpenloginLoginParams,
UX_MODE,
} from '@web3auth/openlogin-adapter';

import {
FromWorkerMessage,
Expand Down Expand Up @@ -126,15 +123,21 @@ export const connectClientAndProvider = async (
chainId: 'other',
rpcTarget: 'other',
displayName: 'other',
blockExplorer: 'other',
blockExplorerUrl: 'other',
ticker: 'other',
tickerName: 'other',
...options.client.chainConfig,
chainNamespace: CHAIN_NAMESPACES.OTHER,
};
const privateKeyProvider = new CommonPrivateKeyProvider({
config: {
chainConfig,
},
});
const client = new Web3AuthNoModal({
...options.client,
chainConfig,
privateKeyProvider,
});

// Popups are blocked by default on mobile browsers, so use redirect. Popup is
Expand All @@ -154,29 +157,23 @@ export const connectClientAndProvider = async (
);
}

const privateKeyProvider = new CommonPrivateKeyProvider({
config: {
chainConfig,
},
});
const openloginAdapter = new OpenloginAdapter({
privateKeyProvider,
const authAdapter = new AuthAdapter({
adapterSettings: {
uxMode,
},
});
client.configureAdapter(openloginAdapter);
client.configureAdapter(authAdapter);

await client.init();

let provider = client.connected ? client.provider : null;
if (!client.connected && !dontAttemptLogin) {
try {
const loginHint = options.getLoginHint?.();
provider = await client.connectTo(WALLET_ADAPTERS.OPENLOGIN, {
provider = await client.connectTo(WALLET_ADAPTERS.AUTH, {
loginProvider: options.loginProvider,
login_hint: loginHint,
} as OpenloginLoginParams);
} as AuthLoginParams);
} catch (err) {
// Unnecessary error thrown during redirect, so log and ignore it.
if (
Expand Down
Loading

0 comments on commit bf08c48

Please sign in to comment.