Skip to content

Commit

Permalink
Merge branch 'main' of github.com:WalletConnect/web3modal into fix/so…
Browse files Browse the repository at this point in the history
…lana-wallet-rpc-old-params
  • Loading branch information
zoruka committed Aug 14, 2024
2 parents 00cf8b4 + 3e2b0aa commit 2d237e6
Show file tree
Hide file tree
Showing 44 changed files with 1,892 additions and 2,855 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/pr_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
- V5
- main

permissions:
pull-requests: write

concurrency:
# Support push/pr as event types with different behaviors each:
# 1. push: queue up builds
Expand Down Expand Up @@ -56,6 +59,33 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

bundle_size:
runs-on: ubuntu-latest
name: Bundle size check
steps:
- name: checkout
uses: actions/checkout@v3

- uses: pnpm/action-setup@v4
name: Install pnpm

- name: setup-node
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'pnpm'

- name: install
run: pnpm install

- name: build
run: pnpm build

- name: Running vite-size script
uses: glitch-txs/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

test:
runs-on: ubuntu-latest
continue-on-error: true
Expand Down
36 changes: 36 additions & 0 deletions apps/laboratory/public/.well-known/apple-app-site-association
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,42 @@
"paths": [
"/rn_walletkit*"
]
},
{
"appID": "W5R8AG9K22.com.walletconnect.flutterwallet",
"paths": [
"/walletkit_flutter"
]
},
{
"appID": "W5R8AG9K22.com.walletconnect.flutterwallet.internal",
"paths": [
"/walletkit_flutter_internal"
]
},
{
"appID": "W5R8AG9K22.com.walletconnect.flutterdapp",
"paths": [
"/appkit_flutter"
]
},
{
"appID": "W5R8AG9K22.com.walletconnect.flutterdapp.internal",
"paths": [
"/appkit_flutter_internal"
]
},
{
"appID": "W5R8AG9K22.com.web3modal.flutterExample",
"paths": [
"/appkit_flutter_modal"
]
},
{
"appID": "W5R8AG9K22.com.web3modal.flutterExample.internal",
"paths": [
"/appkit_flutter_modal_internal"
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function SolanaSendTransactionTest() {
async function onSendTransaction() {
try {
setLoading(true)
if (!walletProvider || !address) {
if (!walletProvider?.publicKey || !address) {
throw Error('user is disconnected')
}

Expand Down Expand Up @@ -73,7 +73,7 @@ export function SolanaSendTransactionTest() {
async function onSendVersionedTransaction() {
try {
setLoading(true)
if (!walletProvider || !address) {
if (!walletProvider?.publicKey || !address) {
throw Error('user is disconnected')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function SolanaSignAndSendTransaction() {
async function onSendTransaction(mode: 'legacy' | 'versioned') {
try {
setLoading(true)
if (!walletProvider || !address) {
if (!walletProvider?.publicKey || !address) {
throw Error('user is disconnected')
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Button } from '@chakra-ui/react'

import { useWeb3ModalAccount, useWeb3ModalProvider } from '@web3modal/solana/react'
import { useWeb3ModalProvider } from '@web3modal/solana/react'

import { ConstantsUtil } from '../../utils/ConstantsUtil'
import { useChakraToast } from '../Toast'

export function SolanaSignMessageTest() {
const toast = useChakraToast()
const { address } = useWeb3ModalAccount()
const { walletProvider } = useWeb3ModalProvider()

async function onSignMessage() {
try {
if (!walletProvider || !address) {
if (!walletProvider) {
throw Error('user is disconnected')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ const amountInLamports = 10_000_000

export function SolanaSignTransactionTest() {
const toast = useChakraToast()
const { address, chainId } = useWeb3ModalAccount()
const { chainId } = useWeb3ModalAccount()
const { walletProvider, connection } = useWeb3ModalProvider()
const [loading, setLoading] = useState(false)

async function onSignTransaction() {
try {
setLoading(true)
if (!walletProvider || !address) {
if (!walletProvider?.publicKey) {
throw Error('user is disconnected')
}

Expand Down Expand Up @@ -73,7 +73,7 @@ export function SolanaSignTransactionTest() {
async function onSignVersionedTransaction() {
try {
setLoading(true)
if (!walletProvider || !address) {
if (!walletProvider?.publicKey) {
throw Error('user is disconnected')
}

Expand Down Expand Up @@ -122,10 +122,6 @@ export function SolanaSignTransactionTest() {
}
}

if (!address) {
return null
}

if (chainId === solana.chainId) {
return (
<Text fontSize="md" color="yellow">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useChakraToast } from '../Toast'

export function SolanaWriteContractTest() {
const toast = useChakraToast()
const { address, currentChain } = useWeb3ModalAccount()
const { currentChain } = useWeb3ModalAccount()
const { walletProvider, connection } = useWeb3ModalProvider()
const [loading, setLoading] = useState(false)

Expand All @@ -26,7 +26,7 @@ export function SolanaWriteContractTest() {
const PROGRAM_ID = new PublicKey(detectProgramId(currentChain?.chainId ?? ''))

try {
if (!walletProvider || !address) {
if (!walletProvider?.publicKey) {
throw new Error('User is disconnected')
}

Expand Down
8 changes: 5 additions & 3 deletions examples/react-wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
"version": "5.0.10",
"scripts": {
"dev": "vite --port 3002",
"build": "vite build"
"build": "vite build",
"size": "pnpm run build && vite-size --react --externals wagmi viem @tanstack/react-query react react-dom"
},
"dependencies": {
"@tanstack/react-query": "5.24.8",
"@web3modal/wagmi": "workspace:*",
"react": "18.2.0",
"react-dom": "18.2.0",
"vite": "5.2.11",
"viem": "2.17.8",
"vite": "5.2.11",
"wagmi": "2.12.2"
},
"devDependencies": {
"@types/react": "18.2.62",
"@types/react-dom": "18.2.7",
"@vitejs/plugin-react": "4.2.1",
"vite": "5.2.11"
"vite": "5.2.11",
"vite-size": "0.0.4"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"publish:alpha": "pnpm install; pnpm build; changeset publish --tag alpha",
"publish:beta": "pnpm install; pnpm build; changeset publish --tag beta",
"publish:canary": "pnpm install; pnpm build; changeset publish --tag canary",
"prepare": "husky"
"prepare": "husky",
"size": "pnpm --filter=./examples/react-wagmi size"
},
"devDependencies": {
"@changesets/changelog-github": "0.5.0",
Expand Down
10 changes: 4 additions & 6 deletions packages/solana/exports/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import { getWeb3Modal } from '@web3modal/scaffold-react'

import { Web3Modal } from '../src/client.js'

import { SolStoreUtil } from '../src/utils/scaffold/index.js'
import { SolStoreUtil, type Connection, type Provider } from '../src/utils/scaffold/index.js'

import type { Web3ModalOptions } from '../src/client.js'
import type { Connection, Provider } from '../src/utils/scaffold/index.js'

// -- Setup -------------------------------------------------------------------
let modal: Web3Modal | undefined = undefined
Expand All @@ -31,12 +30,11 @@ export function createWeb3Modal(options: Web3ModalOptions) {

// -- Hooks -------------------------------------------------------------------
export function useWeb3ModalProvider() {
const { provider, providerType, connection } = useSnapshot(SolStoreUtil.state)
const { provider, connection } = useSnapshot(SolStoreUtil.state)

return {
walletProvider: provider as Provider,
walletProviderType: providerType,
connection: connection as Connection
walletProvider: provider as Provider | undefined,
connection: connection as Connection | undefined
}
}

Expand Down
14 changes: 5 additions & 9 deletions packages/solana/exports/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { ConstantsUtil } from '@web3modal/scaffold-utils'
import { getWeb3Modal } from '@web3modal/scaffold-vue'

import type { Web3ModalOptions } from '../src/client.js'
import type { CaipNetwork } from 'packages/core/dist/types/index.js'
import type { Provider } from '../src/utils/scaffold/index.js'
import type { CaipNetwork } from '@web3modal/scaffold'
import { SolStoreUtil } from '../src/utils/scaffold/SolanaStoreUtil.js'
import { Web3Modal } from '../src/client.js'

Expand Down Expand Up @@ -33,23 +32,20 @@ export function useWeb3ModalProvider() {
throw new Error('Please call "createWeb3Modal" before using "useWeb3ModalProvider" composition')
}

const walletProvider = ref(SolStoreUtil.state.provider as Provider)
const walletProviderType = ref(SolStoreUtil.state.providerType)
const walletProvider = ref(SolStoreUtil.state.provider)
const connection = ref(SolStoreUtil.state.connection)

const unsubscribe = modal.subscribeProvider(state => {
walletProvider.value = state.provider as Provider
walletProviderType.value = state.providerType
walletProvider.value = state.provider
})

onUnmounted(() => {
unsubscribe?.()
})

return {
walletProvider,
walletProviderType,
connection
walletProvider: walletProvider.value ?? undefined,
connection: connection.value ?? undefined
}
}

Expand Down
13 changes: 8 additions & 5 deletions packages/solana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@
},
"scripts": {
"build:clean": "rm -rf dist",
"build": "tsc --build",
"build": "tsc --build tsconfig.build.json",
"watch": "tsc --watch",
"typecheck": "tsc --noEmit",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"test": "vitest run --dir tests --coverage.enabled=true --coverage.reporter=json --coverage.reporter=json-summary --coverage.reportOnFailure=true"
},
"dependencies": {
"@ethersproject/sha2": "5.7.0",
Expand All @@ -61,23 +62,25 @@
"@wallet-standard/features": "1.0.3",
"@wallet-standard/wallet": "1.0.1",
"@walletconnect/universal-provider": "2.14.0",
"@web3modal/core": "workspace:*",
"@web3modal/common": "workspace:*",
"@web3modal/core": "workspace:*",
"@web3modal/polyfills": "workspace:*",
"@web3modal/scaffold": "workspace:*",
"@web3modal/scaffold-react": "workspace:*",
"@web3modal/scaffold-utils": "workspace:*",
"@web3modal/scaffold-vue": "workspace:*",
"@web3modal/wallet": "workspace:*",
"bn.js": "5.2.1",
"bs58": "5.0.0",
"borsh": "0.7.0",
"bs58": "5.0.0",
"buffer": "6.0.3",
"valtio": "1.11.2"
},
"devDependencies": {
"@types/bn.js": "5.1.5",
"@walletconnect/types": "2.14.0"
"@vitest/coverage-v8": "2.0.5",
"@walletconnect/types": "2.14.0",
"vitest": "2.0.3"
},
"peerDependencies": {
"react": ">=17",
Expand Down
Loading

0 comments on commit 2d237e6

Please sign in to comment.