Skip to content

Commit

Permalink
Merge branch 'V4' of github.com:WalletConnect/web3modal into feat/sig…
Browse files Browse the repository at this point in the history
…n-2.5
  • Loading branch information
tomiir committed May 3, 2024
2 parents b143fba + 9be77e2 commit 49ed8c5
Show file tree
Hide file tree
Showing 67 changed files with 1,083 additions and 811 deletions.
9 changes: 9 additions & 0 deletions apps/demo/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
- Updated dependencies []:
- @web3modal/wagmi@4.1.12-sign-2.5.2

## 4.1.12-910a844.0

### Patch Changes

- refactor: sync theme with secure site

- Updated dependencies []:
- @web3modal/wagmi@4.1.12-910a844.0

## 4.1.11

### Patch Changes
Expand Down
10 changes: 10 additions & 0 deletions apps/gallery/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
- @web3modal/common@4.1.12-sign-2.5.2
- @web3modal/ui@4.1.12-sign-2.5.2

## 4.1.12-910a844.0

### Patch Changes

- refactor: sync theme with secure site

- Updated dependencies []:
- @web3modal/common@4.1.12-910a844.0
- @web3modal/ui@4.1.12-910a844.0

## 4.1.11

### Patch Changes
Expand Down
12 changes: 12 additions & 0 deletions apps/laboratory/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
- @web3modal/siwe@4.1.12-sign-2.5.2
- @web3modal/solana@4.1.12-sign-2.5.2

## 4.1.12-910a844.0

### Patch Changes

- refactor: sync theme with secure site

- Updated dependencies []:
- @web3modal/ethers@4.1.12-910a844.0
- @web3modal/siwe@4.1.12-910a844.0
- @web3modal/solana@4.1.12-910a844.0
- @web3modal/wagmi@4.1.12-910a844.0

## 4.1.11

### Patch Changes
Expand Down
9 changes: 9 additions & 0 deletions examples/html-ethers5/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
- Updated dependencies []:
- @web3modal/ethers5@4.1.12-sign-2.5.2

## 4.1.12-910a844.0

### Patch Changes

- refactor: sync theme with secure site

- Updated dependencies []:
- @web3modal/ethers5@4.1.12-910a844.0

## 4.1.11

### Patch Changes
Expand Down
9 changes: 9 additions & 0 deletions examples/html-wagmi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
- Updated dependencies []:
- @web3modal/wagmi@4.1.12-sign-2.5.2

## 4.1.12-910a844.0

### Patch Changes

- refactor: sync theme with secure site

- Updated dependencies []:
- @web3modal/wagmi@4.1.12-910a844.0

## 4.1.11

### Patch Changes
Expand Down
9 changes: 9 additions & 0 deletions examples/next-wagmi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
- Updated dependencies []:
- @web3modal/wagmi@4.1.12-sign-2.5.2

## 4.1.12-910a844.0

### Patch Changes

- refactor: sync theme with secure site

- Updated dependencies []:
- @web3modal/wagmi@4.1.12-910a844.0

## 4.1.11

### Patch Changes
Expand Down
9 changes: 9 additions & 0 deletions examples/react-ethers5/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
- Updated dependencies []:
- @web3modal/ethers5@4.1.12-sign-2.5.2

## 4.1.12-910a844.0

### Patch Changes

- refactor: sync theme with secure site

- Updated dependencies []:
- @web3modal/ethers5@4.1.12-910a844.0

## 4.1.11

### Patch Changes
Expand Down
9 changes: 9 additions & 0 deletions examples/react-wagmi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
- Updated dependencies []:
- @web3modal/wagmi@4.1.12-sign-2.5.2

## 4.1.12-910a844.0

### Patch Changes

- refactor: sync theme with secure site

- Updated dependencies []:
- @web3modal/wagmi@4.1.12-910a844.0

## 4.1.11

### Patch Changes
Expand Down
9 changes: 9 additions & 0 deletions examples/vue-ethers5/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
- Updated dependencies []:
- @web3modal/ethers5@4.1.12-sign-2.5.2

## 4.1.12-910a844.0

### Patch Changes

- refactor: sync theme with secure site

- Updated dependencies []:
- @web3modal/ethers5@4.1.12-910a844.0

## 4.1.11

### Patch Changes
Expand Down
9 changes: 9 additions & 0 deletions examples/vue-wagmi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
- Updated dependencies []:
- @web3modal/wagmi@4.1.12-sign-2.5.2

## 4.1.12-910a844.0

### Patch Changes

- refactor: sync theme with secure site

- Updated dependencies []:
- @web3modal/wagmi@4.1.12-910a844.0

## 4.1.11

### Patch Changes
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"prettier:format": "prettier --write .",
"clean": "rm -rf `find . -type d -name node_modules -o -name dist -o -name .next -o -name out`; rm package-lock.json",
"changeset:pre": "changeset pre enter",
"changeset:pre:exit": "changeset pre exit",
"changeset": "changeset; changeset version",
"publish:latest": "npm install; npm run build; changeset publish",
"publish:alpha": "npm install; npm run build; changeset publish --tag alpha",
Expand Down
6 changes: 6 additions & 0 deletions packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

- fix: Email transaction approval

## 4.1.12-910a844.0

### Patch Changes

- refactor: sync theme with secure site

## 4.1.11

### Patch Changes
Expand Down
1 change: 1 addition & 0 deletions packages/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
export { DateUtil } from './src/utils/DateUtil.js'
export { NetworkUtil } from './src/utils/NetworkUtil.js'
export { NumberUtil } from './src/utils/NumberUtil.js'
export * from './src/utils/ThemeUtil.js'

export type * from './src/utils/TypeUtil.js'
32 changes: 32 additions & 0 deletions packages/common/src/utils/ThemeUtil.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// -- Types ------------------------------------------------------------------
export type ThemeType = 'dark' | 'light'

export interface ThemeVariables {
'--w3m-font-family'?: string
'--w3m-accent'?: string
'--w3m-color-mix'?: string
'--w3m-color-mix-strength'?: number
'--w3m-font-size-master'?: string
'--w3m-border-radius-master'?: string
'--w3m-z-index'?: number
}

export interface W3mThemeVariables {
'--w3m-accent': string
'--w3m-background': string
}

// -- Utilities ---------------------------------------------------------------
export function getW3mThemeVariables(themeVariables?: ThemeVariables, themeType?: ThemeType) {
if (themeType === 'light') {
return {
'--w3m-accent': themeVariables?.['--w3m-accent'] || '#5773ff',
'--w3m-background': '#fff'
}
}

return {
'--w3m-accent': themeVariables?.['--w3m-accent'] || '#667dff',
'--w3m-background': '#121313'
}
}
10 changes: 10 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
- @web3modal/common@4.1.12-sign-2.5.2
- @web3modal/wallet@4.1.12-sign-2.5.2

## 4.1.12-910a844.0

### Patch Changes

- refactor: sync theme with secure site

- Updated dependencies []:
- @web3modal/common@4.1.12-910a844.0
- @web3modal/wallet@4.1.12-910a844.0

## 4.1.11

### Patch Changes
Expand Down
7 changes: 2 additions & 5 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,8 @@ export type { EventsControllerState } from './src/controllers/EventsController.j
export { TransactionsController } from './src/controllers/TransactionsController.js'
export type { TransactionsControllerState } from './src/controllers/TransactionsController.js'

export { ConvertController } from './src/controllers/ConvertController.js'
export type {
ConvertControllerState,
ConvertInputTarget
} from './src/controllers/ConvertController.js'
export { SwapController } from './src/controllers/SwapController.js'
export type { SwapControllerState, SwapInputTarget } from './src/controllers/SwapController.js'

export { SendController } from './src/controllers/SendController.js'
export type { SendControllerState } from './src/controllers/SendController.js'
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/controllers/AccountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { CaipAddress, ConnectedWalletInfo } from '../utils/TypeUtil.js'
import type { Balance } from '@web3modal/common'
import { BlockchainApiController } from './BlockchainApiController.js'
import { SnackController } from './SnackController.js'
import { ConvertController } from './ConvertController.js'
import { ConvertApiUtil } from '../utils/ConvertApiUtil.js'
import { SwapController } from './SwapController.js'
import { SwapApiUtil } from '../utils/SwapApiUtil.js'
import type { W3mFrameTypes } from '@web3modal/wallet'

// -- Types --------------------------------------------- //
Expand Down Expand Up @@ -105,7 +105,7 @@ export const AccountController = {
const response = await BlockchainApiController.getBalance(state.address)

this.setTokenBalance(response.balances)
ConvertController.setBalances(ConvertApiUtil.mapBalancesToConvertTokens(response.balances))
SwapController.setBalances(SwapApiUtil.mapBalancesToSwapTokens(response.balances))
}
} catch (error) {
SnackController.showError('Failed to fetch token balance')
Expand Down
30 changes: 13 additions & 17 deletions packages/core/src/controllers/BlockchainApiController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { FetchUtil } from '../utils/FetchUtil.js'
import type {
BlockchainApiTransactionsRequest,
BlockchainApiTransactionsResponse,
BlockchainApiConvertTokensRequest,
BlockchainApiConvertTokensResponse,
BlockchainApiGenerateConvertCalldataRequest,
BlockchainApiGenerateConvertCalldataResponse,
BlockchainApiSwapTokensRequest,
BlockchainApiSwapTokensResponse,
BlockchainApiGenerateSwapCalldataRequest,
BlockchainApiGenerateSwapCalldataResponse,
BlockchainApiGenerateApproveCalldataRequest,
BlockchainApiGenerateApproveCalldataResponse,
BlockchainApiConvertAllowanceRequest,
BlockchainApiConvertAllowanceResponse,
BlockchainApiSwapAllowanceRequest,
BlockchainApiSwapAllowanceResponse,
BlockchainApiGasPriceRequest,
BlockchainApiGasPriceResponse,
BlockchainApiTokenPriceRequest,
Expand Down Expand Up @@ -136,8 +136,8 @@ export const BlockchainApiController = {
})
},

fetchConvertTokens({ projectId, chainId }: BlockchainApiConvertTokensRequest) {
return api.get<BlockchainApiConvertTokensResponse>({
fetchSwapTokens({ projectId, chainId }: BlockchainApiSwapTokensRequest) {
return api.get<BlockchainApiSwapTokensResponse>({
path: `/v1/convert/tokens?projectId=${projectId}&chainId=${chainId}`
})
},
Expand All @@ -156,14 +156,10 @@ export const BlockchainApiController = {
})
},

fetchConvertAllowance({
projectId,
tokenAddress,
userAddress
}: BlockchainApiConvertAllowanceRequest) {
fetchSwapAllowance({ projectId, tokenAddress, userAddress }: BlockchainApiSwapAllowanceRequest) {
const { sdkType, sdkVersion } = OptionsController.state

return api.get<BlockchainApiConvertAllowanceResponse>({
return api.get<BlockchainApiSwapAllowanceResponse>({
path: `/v1/convert/allowance?projectId=${projectId}&tokenAddress=${tokenAddress}&userAddress=${userAddress}`,
headers: {
'Content-Type': 'application/json',
Expand All @@ -186,14 +182,14 @@ export const BlockchainApiController = {
})
},

generateConvertCalldata({
generateSwapCalldata({
amount,
from,
projectId,
to,
userAddress
}: BlockchainApiGenerateConvertCalldataRequest) {
return api.post<BlockchainApiGenerateConvertCalldataResponse>({
}: BlockchainApiGenerateSwapCalldataRequest) {
return api.post<BlockchainApiGenerateSwapCalldataResponse>({
path: '/v1/convert/build-transaction',
headers: {
'Content-Type': 'application/json'
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/controllers/ConnectorController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { subscribeKey as subKey } from 'valtio/vanilla/utils'
import { proxy, ref, snapshot } from 'valtio/vanilla'
import type { Connector, EmailConnector } from '../utils/TypeUtil.js'
import { getW3mThemeVariables } from '@web3modal/common'
import { OptionsController } from './OptionsController.js'
import { ThemeController } from './ThemeController.js'

Expand Down Expand Up @@ -34,14 +35,18 @@ export const ConnectorController = {
if (connector.id === 'w3mEmail') {
const emailConnector = connector as EmailConnector
const optionsState = snapshot(OptionsController.state) as typeof OptionsController.state
const themeMode = ThemeController.getSnapshot().themeMode
const themeVariables = ThemeController.getSnapshot().themeVariables

emailConnector?.provider?.syncDappData?.({
metadata: optionsState.metadata,
sdkVersion: optionsState.sdkVersion,
projectId: optionsState.projectId
})
emailConnector.provider.syncTheme({
themeMode: ThemeController.getSnapshot().themeMode,
themeVariables: ThemeController.getSnapshot().themeVariables
themeMode,
themeVariables,
w3mThemeVariables: getW3mThemeVariables(themeVariables, themeMode)
})
}
},
Expand Down
Loading

0 comments on commit 49ed8c5

Please sign in to comment.