Skip to content

Commit

Permalink
chore: 1.4.2 (#180)
Browse files Browse the repository at this point in the history
* fix: updated the condition to send add chain request to only check for user rejection (#175)

* chore: removed fallback org logic (#176)

* chore: removed fallback org logic

* chore: code style

* chore: replaced missing urls (#177)

* chore: add clientId to BlockchainAPI requests (#178)
  • Loading branch information
ignaciosantise authored Jul 11, 2024
1 parent abe7976 commit 09695ee
Show file tree
Hide file tree
Showing 43 changed files with 285 additions and 134 deletions.
7 changes: 7 additions & 0 deletions apps/gallery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @apps/gallery

## 1.0.8

### Patch Changes

- Updated dependencies
- @web3modal/ui-react-native@1.4.2

## 1.0.7

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions apps/gallery/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apps/gallery",
"version": "1.0.7",
"version": "1.0.8",
"main": "index.js",
"private": true,
"devDependencies": {
Expand Down Expand Up @@ -33,6 +33,6 @@
},
"dependencies": {
"@storybook/theming": "^7.4.6",
"@web3modal/ui-react-native": "1.4.1"
"@web3modal/ui-react-native": "1.4.2"
}
}
7 changes: 7 additions & 0 deletions apps/native-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @apps/native-cli

## 1.0.8

### Patch Changes

- Updated dependencies
- @web3modal/wagmi-react-native@1.4.2

## 1.0.7

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions apps/native-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apps/native-cli",
"version": "1.0.7",
"version": "1.0.8",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand All @@ -15,7 +15,7 @@
"@react-native-clipboard/clipboard": "1.13.0",
"@react-native-community/netinfo": "9.3.10",
"@walletconnect/react-native-compat": "2.10.5",
"@web3modal/wagmi-react-native": "1.4.1",
"@web3modal/wagmi-react-native": "1.4.2",
"react": "18.2.0",
"react-native": "0.72.6",
"react-native-get-random-values": "~1.9.0",
Expand Down
8 changes: 8 additions & 0 deletions apps/native/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @apps/native

## 1.0.8

### Patch Changes

- Updated dependencies
- @web3modal/wagmi-react-native@1.4.2
- @web3modal/email-wagmi-react-native@1.4.2

## 1.0.7

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions apps/native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apps/native",
"version": "1.0.7",
"version": "1.0.8",
"main": "index.js",
"private": true,
"scripts": {
Expand All @@ -18,8 +18,8 @@
"@react-native-async-storage/async-storage": "1.21.0",
"@react-native-community/netinfo": "11.1.0",
"@walletconnect/react-native-compat": "2.10.5",
"@web3modal/email-wagmi-react-native": "1.4.1",
"@web3modal/wagmi-react-native": "1.4.1",
"@web3modal/email-wagmi-react-native": "1.4.2",
"@web3modal/wagmi-react-native": "1.4.2",
"expo": "^50.0.14",
"expo-application": "~5.8.3",
"expo-clipboard": "~5.0.1",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"test": "turbo run test --parallel",
"clean": "turbo clean && rm -rf node_modules && watchman watch-del-all",
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\" --ignore-path .gitignore",
"pre-publish": "turbo clean lint prettier test --parallel; yarn install; turbo run build;"
"pre-publish": "turbo clean lint prettier --parallel; yarn install; turbo run build; turbo run test;"
},
"devDependencies": {
"@changesets/changelog-github": "0.5.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/coinbase-ethers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @web3modal/coinbase-ethers-react-native

## 1.4.2

### Patch Changes

- 1.4.2

## 1.4.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/coinbase-ethers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3modal/coinbase-ethers-react-native",
"version": "1.4.1",
"version": "1.4.2",
"main": "lib/commonjs/index.js",
"types": "lib/typescript/index.d.ts",
"module": "lib/module/index.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/coinbase-wagmi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @web3modal/coinbase-wagmi-react-native

## 1.4.2

### Patch Changes

- 1.4.2

## 1.4.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/coinbase-wagmi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3modal/coinbase-wagmi-react-native",
"version": "1.4.1",
"version": "1.4.2",
"main": "lib/commonjs/index.js",
"types": "lib/typescript/index.d.ts",
"module": "lib/module/index.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @web3modal/core-react-native

## 1.4.2

### Patch Changes

- 1.4.2

## 1.4.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3modal/core-react-native",
"version": "1.4.1",
"version": "1.4.2",
"main": "lib/commonjs/index.js",
"types": "lib/typescript/index.d.ts",
"module": "lib/module/index.js",
Expand Down
13 changes: 6 additions & 7 deletions packages/core/src/__tests__/controllers/AssetController.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { AssetController } from '../../index';
import { AssetController, CoreHelperUtil } from '../../index';

const API_URL = CoreHelperUtil.getApiUrl();

// -- Tests --------------------------------------------------------------------
describe('AssetController', () => {
Expand All @@ -21,26 +23,23 @@ describe('AssetController', () => {

it('should save network images correctly', () => {
const MOCK_NETWORK_ID = '692ed6ba-e569-459a-556a-776476829e00';
const MOCK_NETWORK_IMAGE =
'https://api.web3modal.com/public/getAssetImage/692ed6ba-e569-459a-556a-776476829e00';
const MOCK_NETWORK_IMAGE = `${API_URL}/public/getAssetImage/692ed6ba-e569-459a-556a-776476829e00`;

AssetController.setNetworkImage(MOCK_NETWORK_ID, MOCK_NETWORK_IMAGE);
expect(AssetController.state.networkImages[MOCK_NETWORK_ID]).toEqual(MOCK_NETWORK_IMAGE);
});

it('should save wallet images correctly', () => {
const MOCK_WALLET_ID = '7c5ff577-a68d-49c5-02cd-3d83637b0b00';
const MOCK_WALLET_IMAGE =
'https://api.web3modal.com/getWalletImage/7c5ff577-a68d-49c5-02cd-3d83637b0b00';
const MOCK_WALLET_IMAGE = `${API_URL}/getWalletImage/7c5ff577-a68d-49c5-02cd-3d83637b0b00`;

AssetController.setWalletImage(MOCK_WALLET_ID, MOCK_WALLET_IMAGE);
expect(AssetController.state.walletImages[MOCK_WALLET_ID]).toEqual(MOCK_WALLET_IMAGE);
});

it('should save connector images correctly', () => {
const MOCK_CONNECTOR_ID = '7c5ff577-a68d-49c5-02cd-3d83637b0b00';
const MOCK_CONNECTOR_IMAGE =
'https://api.web3modal.com/getWalletImage/7c5ff577-a68d-49c5-02cd-3d83637b0b00';
const MOCK_CONNECTOR_IMAGE = `${API_URL}/getWalletImage/7c5ff577-a68d-49c5-02cd-3d83637b0b00`;

AssetController.setConnectorImage(MOCK_CONNECTOR_ID, MOCK_CONNECTOR_IMAGE);
expect(AssetController.state.connectorImages[MOCK_CONNECTOR_ID]).toEqual(MOCK_CONNECTOR_IMAGE);
Expand Down
26 changes: 24 additions & 2 deletions packages/core/src/controllers/BlockchainApiController.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { proxy } from 'valtio';

import { CoreHelperUtil } from '../utils/CoreHelperUtil';
import { FetchUtil } from '../utils/FetchUtil';
import type {
BlockchainApiIdentityRequest,
Expand All @@ -6,17 +9,36 @@ import type {
import { OptionsController } from './OptionsController';

// -- Helpers ------------------------------------------- //
const api = new FetchUtil({ baseUrl: 'https://rpc.walletconnect.com' });
const baseUrl = CoreHelperUtil.getBlockchainApiUrl();

// -- Types --------------------------------------------- //
export interface BlockchainApiControllerState {
clientId: string | null;
api: FetchUtil;
}

// -- State --------------------------------------------- //
const state = proxy<BlockchainApiControllerState>({
clientId: null,
api: new FetchUtil({ baseUrl })
});

// -- Controller ---------------------------------------- //
export const BlockchainApiController = {
state,

fetchIdentity({ caipChainId, address }: BlockchainApiIdentityRequest) {
return api.get<BlockchainApiIdentityResponse>({
return state.api.get<BlockchainApiIdentityResponse>({
path: `/v1/identity/${address}`,
params: {
chainId: caipChainId,
projectId: OptionsController.state.projectId
}
});
},

setClientId(clientId: string | null) {
state.clientId = clientId;
state.api = new FetchUtil({ baseUrl, clientId });
}
};
18 changes: 5 additions & 13 deletions packages/core/src/utils/ConstantsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@ export const ConstantsUtil = {

ONE_SEC_MS: 1000,

RESTRICTED_TIMEZONES: [
'ASIA/SHANGHAI',
'ASIA/URUMQI',
'ASIA/CHONGQING',
'ASIA/HARBIN',
'ASIA/KASHGAR',
'ASIA/MACAU',
'ASIA/HONG_KONG',
'ASIA/MACAO',
'ASIA/BEIJING',
'ASIA/HARBIN'
],
EMAIL_REGEX: /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/,
W3M_API_URL: 'https://api.web3modal.org',

EMAIL_REGEX: /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/
BLOCKCHAIN_API_RPC_URL: 'https://rpc.walletconnect.org',

PULSE_API_URL: 'https://pulse.walletconnect.org'
};
23 changes: 3 additions & 20 deletions packages/core/src/utils/CoreHelperUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,33 +125,16 @@ export const CoreHelperUtil = {
return formattedBalance ? `${formattedBalance} ${symbol}` : `0.000 ${symbol || ''}`;
},

isRestrictedRegion() {
try {
const { timeZone } = new Intl.DateTimeFormat().resolvedOptions();
const capTimeZone = timeZone.toUpperCase();

return ConstantsUtil.RESTRICTED_TIMEZONES.includes(capTimeZone);
} catch {
return false;
}
},

getApiUrl() {
return CoreHelperUtil.isRestrictedRegion()
? 'https://api.web3modal.org'
: 'https://api.web3modal.com';
return ConstantsUtil.W3M_API_URL;
},

getBlockchainApiUrl() {
return CoreHelperUtil.isRestrictedRegion()
? 'https://rpc.walletconnect.org'
: 'https://rpc.walletconnect.com';
return ConstantsUtil.BLOCKCHAIN_API_RPC_URL;
},

getAnalyticsUrl() {
return CoreHelperUtil.isRestrictedRegion()
? 'https://pulse.walletconnect.org'
: 'https://pulse.walletconnect.com';
return ConstantsUtil.PULSE_API_URL;
},

getUUID() {
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/utils/FetchUtil.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// -- Types ----------------------------------------------------------------------
interface Options {
baseUrl: string;
clientId?: string | null;
}

interface RequestArguments {
Expand All @@ -16,9 +17,11 @@ interface PostArguments extends RequestArguments {
// -- Utility --------------------------------------------------------------------
export class FetchUtil {
public baseUrl: Options['baseUrl'];
public clientId: Options['clientId'];

public constructor({ baseUrl }: Options) {
public constructor({ baseUrl, clientId }: Options) {
this.baseUrl = baseUrl;
this.clientId = clientId;
}

public async get<T>({ headers, ...args }: RequestArguments) {
Expand Down Expand Up @@ -87,6 +90,10 @@ export class FetchUtil {
});
}

if (this.clientId) {
url.searchParams.append('clientId', this.clientId);
}

return url.toString();
}

Expand Down
8 changes: 8 additions & 0 deletions packages/email-ethers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @web3modal/coinbase-wagmi-react-native

## 1.4.2

### Patch Changes

- 1.4.2
- Updated dependencies
- @web3modal/email-react-native@1.4.2

## 1.4.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/email-ethers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3modal/email-ethers-react-native",
"version": "1.4.1",
"version": "1.4.2",
"main": "lib/commonjs/index.js",
"types": "lib/typescript/index.d.ts",
"module": "lib/module/index.js",
Expand Down Expand Up @@ -37,7 +37,7 @@
"access": "public"
},
"dependencies": {
"@web3modal/email-react-native": "1.4.1"
"@web3modal/email-react-native": "1.4.2"
},
"peerDependencies": {
"ethers": ">=5"
Expand Down
8 changes: 8 additions & 0 deletions packages/email-wagmi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @web3modal/coinbase-wagmi-react-native

## 1.4.2

### Patch Changes

- 1.4.2
- Updated dependencies
- @web3modal/email-react-native@1.4.2

## 1.4.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/email-wagmi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3modal/email-wagmi-react-native",
"version": "1.4.1",
"version": "1.4.2",
"main": "lib/commonjs/index.js",
"types": "lib/typescript/index.d.ts",
"module": "lib/module/index.js",
Expand Down Expand Up @@ -37,7 +37,7 @@
"access": "public"
},
"dependencies": {
"@web3modal/email-react-native": "1.4.1"
"@web3modal/email-react-native": "1.4.2"
},
"peerDependencies": {
"wagmi": ">=1 <2"
Expand Down
Loading

0 comments on commit 09695ee

Please sign in to comment.