Skip to content

Commit e696bf8

Browse files
chore: moved connector constants to common package
1 parent aae1248 commit e696bf8

File tree

32 files changed

+105
-71
lines changed

32 files changed

+105
-71
lines changed

packages/auth-ethers/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"access": "public"
3737
},
3838
"dependencies": {
39+
"@reown/appkit-common-react-native": "1.2.1",
3940
"@reown/appkit-wallet-react-native": "1.2.1"
4041
},
4142
"peerDependencies": {

packages/auth-ethers/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { AppKitFrameProvider, type AppKitFrameTypes } from '@reown/appkit-wallet-react-native';
2-
2+
import { ConstantsUtil, PresetsUtil } from '@reown/appkit-common-react-native';
33
interface AuthProviderProps {
44
projectId: string;
55
metadata: AppKitFrameTypes.Metadata;
66
}
77

88
export class AuthProvider extends AppKitFrameProvider {
9-
readonly id = 'appKitAuth';
10-
readonly name = 'AppKit Universal Wallet';
9+
readonly id = ConstantsUtil.AUTH_CONNECTOR_ID;
10+
readonly name = PresetsUtil.ConnectorNamesMap[ConstantsUtil.AUTH_CONNECTOR_ID]!;
1111

1212
constructor(props: AuthProviderProps) {
1313
super(props.projectId, props.metadata);

packages/auth-wagmi/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"access": "public"
3737
},
3838
"dependencies": {
39+
"@reown/appkit-common-react-native": "1.2.1",
3940
"@reown/appkit-core-react-native": "1.2.1",
4041
"@reown/appkit-wallet-react-native": "1.2.1"
4142
},

packages/auth-wagmi/src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { SwitchChainError, getAddress, type Address, type Hex } from 'viem';
33

44
import { AppKitFrameProvider } from '@reown/appkit-wallet-react-native';
55
import { StorageUtil } from '@reown/appkit-core-react-native';
6+
import { ConstantsUtil, PresetsUtil } from '@reown/appkit-common-react-native';
67

78
export type Metadata = {
89
name: string;
@@ -26,16 +27,16 @@ type StorageItemMap = {
2627
recentConnectorId?: string;
2728
};
2829

29-
authConnector.type = 'appKitAuth' as const;
30-
authConnector.id = 'appKitAuth' as const;
30+
authConnector.type = PresetsUtil.ConnectorTypesMap[ConstantsUtil.AUTH_CONNECTOR_ID]!;
31+
authConnector.id = ConstantsUtil.AUTH_CONNECTOR_ID;
3132
export function authConnector(parameters: AuthConnectorOptions) {
3233
let _provider: AppKitFrameProvider = {} as AppKitFrameProvider;
3334
let _currentAddress: Address | null = null;
3435
let _chainId: number | null = null;
3536

3637
return createConnector<Provider, {}, StorageItemMap>(config => ({
3738
id: authConnector.id,
38-
name: 'AppKit Universal Wallet',
39+
name: PresetsUtil.ConnectorNamesMap[ConstantsUtil.AUTH_CONNECTOR_ID]!,
3940
type: authConnector.type,
4041
async setup() {
4142
_provider = new AppKitFrameProvider(parameters.projectId, parameters.metadata);

packages/coinbase-ethers/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
"registry": "https://registry.npmjs.org/",
3737
"access": "public"
3838
},
39+
"dependencies": {
40+
"@reown/appkit-common-react-native": "1.2.1"
41+
},
3942
"peerDependencies": {
4043
"@coinbase/wallet-mobile-sdk": ">=1.0.10",
4144
"ethers": ">=5"

packages/coinbase-ethers/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { configure, WalletMobileSDKEVMProvider } from '@coinbase/wallet-mobile-sdk';
22
import type { WalletMobileSDKProviderOptions } from '@coinbase/wallet-mobile-sdk/build/WalletMobileSDKEVMProvider';
3+
import { ConstantsUtil, PresetsUtil } from '@reown/appkit-common-react-native';
34

45
interface RequestArguments {
56
readonly method: string;
@@ -12,8 +13,8 @@ type CoinbaseProviderOptions = WalletMobileSDKProviderOptions & {
1213
};
1314

1415
export class CoinbaseProvider {
15-
readonly id = 'coinbaseWallet';
16-
readonly name = 'Coinbase Wallet';
16+
readonly id = ConstantsUtil.COINBASE_CONNECTOR_ID;
17+
readonly name = PresetsUtil.ConnectorNamesMap[ConstantsUtil.COINBASE_CONNECTOR_ID]!;
1718

1819
private _provider?: WalletMobileSDKEVMProvider;
1920
private _initProviderPromise?: Promise<void>;

packages/coinbase-wagmi/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
"registry": "https://registry.npmjs.org/",
3737
"access": "public"
3838
},
39+
"dependencies": {
40+
"@reown/appkit-common-react-native": "1.2.1"
41+
},
3942
"peerDependencies": {
4043
"@coinbase/wallet-mobile-sdk": ">=1.0.10",
4144
"wagmi": ">=2"

packages/coinbase-wagmi/src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@ import {
88
} from 'viem';
99
import { WalletMobileSDKEVMProvider, configure } from '@coinbase/wallet-mobile-sdk';
1010
import type { WalletMobileSDKProviderOptions } from '@coinbase/wallet-mobile-sdk/build/WalletMobileSDKEVMProvider';
11+
import { ConstantsUtil, PresetsUtil } from '@reown/appkit-common-react-native';
1112

1213
type CoinbaseConnectorParameters = WalletMobileSDKProviderOptions & {
1314
redirect: string;
1415
};
1516

1617
type Provider = WalletMobileSDKEVMProvider;
1718

18-
coinbaseConnector.type = 'coinbaseWallet' as const;
19+
coinbaseConnector.type = PresetsUtil.ConnectorTypesMap[ConstantsUtil.COINBASE_CONNECTOR_ID]!;
1920
export function coinbaseConnector(parameters: CoinbaseConnectorParameters) {
2021
let _provider: Provider;
2122

2223
return createConnector<Provider>(config => ({
23-
id: 'coinbaseWallet',
24-
name: 'Coinbase Wallet',
24+
id: ConstantsUtil.COINBASE_CONNECTOR_ID,
25+
name: PresetsUtil.ConnectorNamesMap[ConstantsUtil.COINBASE_CONNECTOR_ID]!,
2526
type: coinbaseConnector.type,
2627
async connect({ chainId } = {}) {
2728
try {

packages/common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export { DateUtil } from './utils/DateUtil';
44
export { NamesUtil } from './utils/NamesUtil';
55
export { NetworkUtil } from './utils/NetworkUtil';
66
export { NumberUtil } from './utils/NumberUtil';
7+
export { PresetsUtil } from './utils/PresetsUtil';
78
export { StringUtil } from './utils/StringUtil';
89
export { ErrorUtil } from './utils/ErrorUtil';
910
export { erc20ABI } from './contracts/erc20';

packages/common/src/utils/ConstantsUtil.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
export const ConstantsUtil = {
2+
VERSION: '1.2.1',
3+
4+
EIP155: 'eip155',
5+
ADD_CHAIN_METHOD: 'wallet_addEthereumChain',
6+
27
WC_NAME_SUFFIX: '.reown.id',
38
WC_NAME_SUFFIX_LEGACY: '.wcn.id',
9+
410
BLOCKCHAIN_API_RPC_URL: 'https://rpc.walletconnect.org',
511
PULSE_API_URL: 'https://pulse.walletconnect.org',
612
API_URL: 'https://api.web3modal.org',
13+
14+
WALLET_CONNECT_CONNECTOR_ID: 'walletConnect',
715
COINBASE_CONNECTOR_ID: 'coinbaseWallet',
16+
AUTH_CONNECTOR_ID: 'appKitAuth',
17+
818
COINBASE_EXPLORER_ID: 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa',
19+
920
USDT_CONTRACT_ADDRESSES: [
1021
// Mainnet
1122
'0xdac17f958d2ee523a2206206994597c13d831ec7',

0 commit comments

Comments
 (0)