Skip to content

Commit

Permalink
Merge branch 'main' into renovate/solana-web3.js-1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir authored Sep 10, 2024
2 parents abe8cc3 + 1b55e5d commit 882483d
Show file tree
Hide file tree
Showing 33 changed files with 528 additions and 364 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ui_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ on:
secrets:
NEXT_PUBLIC_PROJECT_ID:
required: true
RELEASE_TOKEN_V2:
required: true
TFC_INFRA_TOKEN:
required: true
TESTS_NEXTAUTH_SECRET:
required: false
TESTS_MAILSAC_API_KEY:
Expand All @@ -54,7 +58,7 @@ jobs:
labels: playwright
count: 5
secrets:
GITHUB_PAT: ${{ secrets.RELEASE_TOKEN }}
GITHUB_PAT: ${{ secrets.RELEASE_TOKEN_V2 }}
TF_API_TOKEN: ${{ secrets.TFC_INFRA_TOKEN }}

ui_tests:
Expand Down
4 changes: 2 additions & 2 deletions apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"sonner": "1.4.3",
"tailwind-merge": "2.2.1",
"vaul": "0.9.0",
"viem": "2.19.6",
"wagmi": "2.12.5",
"viem": "2.21.4",
"wagmi": "2.12.9",
"zustand": "4.5.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion apps/laboratory/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const cspHeader = `
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
img-src * 'self' data: blob: https://walletconnect.org https://walletconnect.com https://secure.walletconnect.com https://secure.walletconnect.org https://tokens-data.1inch.io https://tokens.1inch.io https://ipfs.io https://lab.web3modal.com;
font-src 'self' https://fonts.gstatic.com;
connect-src 'self' https://react-wallet.walletconnect.com https://rpc.walletconnect.com https://rpc.walletconnect.org https://relay.walletconnect.com https://relay.walletconnect.org wss://relay.walletconnect.com wss://relay.walletconnect.org https://pulse.walletconnect.com https://pulse.walletconnect.org https://api.web3modal.com https://api.web3modal.org wss://www.walletlink.org https://o1095249.ingest.sentry.io;
connect-src 'self' https://react-wallet.walletconnect.com https://rpc.walletconnect.com https://rpc.walletconnect.org https://relay.walletconnect.com https://relay.walletconnect.org wss://relay.walletconnect.com wss://relay.walletconnect.org https://pulse.walletconnect.com https://pulse.walletconnect.org https://api.web3modal.com https://api.web3modal.org wss://www.walletlink.org https://o1095249.ingest.sentry.io https://quote-api.jup.ag;
frame-src 'self' https://verify.walletconnect.com https://verify.walletconnect.org https://secure.walletconnect.com https://secure.walletconnect.org ${
process.env.NEXT_PUBLIC_SECURE_SITE_SDK_URL || ''
};
Expand Down
12 changes: 6 additions & 6 deletions apps/laboratory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
"@solana/wallet-adapter-wallets": "0.19.32",
"@solana/web3.js": "1.95.3",
"@tanstack/react-query": "5.24.8",
"@wagmi/connectors": "5.1.5",
"@wagmi/connectors": "5.1.9",
"@wagmi/core": "2.13.4",
"@walletconnect/ethereum-provider": "2.15.2",
"@walletconnect/utils": "2.15.2",
"@walletconnect/ethereum-provider": "2.16.1",
"@walletconnect/utils": "2.16.1",
"@web3modal/base": "workspace:*",
"@web3modal/ethers": "workspace:*",
"@web3modal/ethers5": "workspace:*",
Expand All @@ -63,7 +63,7 @@
"@web3modal/wallet": "workspace:*",
"axios": "1.7.2",
"bs58": "6.0.0",
"ethers": "6.13.0",
"ethers": "6.13.2",
"ethers5": "npm:[email protected]",
"framer-motion": "10.17.9",
"next": "14.2.3",
Expand All @@ -73,8 +73,8 @@
"react-icons": "4.12.0",
"rpc-websockets": "7.11.0",
"valtio": "1.11.2",
"viem": "2.19.6",
"wagmi": "2.12.5",
"viem": "2.21.4",
"wagmi": "2.12.9",
"webauthn-p256": "0.0.2"
},
"devDependencies": {
Expand Down
16 changes: 8 additions & 8 deletions apps/laboratory/public/.well-known/apple-app-site-association
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,27 @@
]
},
{
"appID": "W5R8AG9K22.com.walletconnect.web3modal.rnsample",
"appID": "W5R8AG9K22.com.walletconnect.web3modal.rnsample.internal",
"paths": [
"/rn_appkit*"
"/rn_appkit_internal"
]
},
{
"appID": "W5R8AG9K22.com.walletconnect.web3modal.rnsample.internal",
"appID": "W5R8AG9K22.com.walletconnect.web3modal.rnsample",
"paths": [
"/rn_appkit*"
"/rn_appkit"
]
},
{
"appID": "W5R8AG9K22.com.walletconnect.web3wallet.rnsample",
"appID": "W5R8AG9K22.com.walletconnect.web3wallet.rnsample.internal",
"paths": [
"/rn_walletkit*"
"/rn_walletkit_internal"
]
},
{
"appID": "W5R8AG9K22.com.walletconnect.web3wallet.rnsample.internal",
"appID": "W5R8AG9K22.com.walletconnect.web3wallet.rnsample",
"paths": [
"/rn_walletkit*"
"/rn_walletkit"
]
},
{
Expand Down
20 changes: 20 additions & 0 deletions apps/laboratory/public/.well-known/assetlinks.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@
]
}
},
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.walletconnect.web3wallet.rnsample.debug",
"sha256_cert_fingerprints": [
"3D:87:31:1C:66:8B:A0:CB:F9:F1:D5:28:3B:DF:2E:4F:CB:19:EA:AB:B4:B7:CE:C4:D9:E1:E0:6D:32:FB:C6:56"
]
}
},
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
Expand All @@ -129,6 +139,16 @@
]
}
},
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.walletconnect.web3modal.rnsample.debug",
"sha256_cert_fingerprints": [
"3D:87:31:1C:66:8B:A0:CB:F9:F1:D5:28:3B:DF:2E:4F:CB:19:EA:AB:B4:B7:CE:C4:D9:E1:E0:6D:32:FB:C6:56"
]
}
},
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
Expand Down
122 changes: 122 additions & 0 deletions apps/laboratory/src/components/Solana/SolanaSignJupiterSwapTest.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { useState } from 'react'
import { Button, Stack, Text, Spacer } from '@chakra-ui/react'
import { PublicKey, VersionedTransaction } from '@solana/web3.js'

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

import { solana } from '../../utils/ChainsUtil'
import { useChakraToast } from '../Toast'
import bs58 from 'bs58'

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

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

if (!connection) {
throw Error('no connection set')
}

const transaction = await createJupiterSwapTransaction({
publicKey: walletProvider.publicKey
})
const signedTransaction = await walletProvider.signTransaction(transaction)
const signature = signedTransaction.signatures[0]

if (!signature) {
throw Error('Empty signature')
}

toast({
title: 'Success',
description: bs58.encode(signature),
type: 'success'
})
} catch (err) {
toast({
title: 'Error',
description: (err as Error).message,
type: 'error'
})
} finally {
setLoading(false)
}
}

if (chainId === solana.chainId) {
return (
<Text fontSize="md" color="yellow">
Switch to Solana Devnet or Testnet to test this feature
</Text>
)
}

return (
<Stack direction={['column', 'column', 'row']}>
<Button
data-test-id="sign-transaction-button"
onClick={onSignVersionedTransaction}
isDisabled={loading}
>
Sign Jupiter Swap Transaction
</Button>
<Spacer />
</Stack>
)
}

type CreateJupiterSwapTransactionParams = {
publicKey: PublicKey
}

async function createJupiterSwapTransaction({ publicKey }: CreateJupiterSwapTransactionParams) {
const qs = new URLSearchParams({
inputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
outputMint: 'So11111111111111111111111111111111111111112',
amount: '100000',
slippageBps: '300',
swapMode: 'ExactIn',
onlyDirectRoutes: 'false',
asLegacyTransaction: 'false',
maxAccounts: '64',
minimizeSlippage: 'false'
})

const quoteResponse = await (
await fetch(`https://quote-api.jup.ag/v6/quote?${qs.toString()}`)
).json()
const swapResponse = await (
await fetch('https://quote-api.jup.ag/v6/swap', {
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
userPublicKey: publicKey.toString(),
wrapAndUnwrapSol: true,
prioritizationFeeLamports: {
priorityLevelWithMaxLamports: {
maxLamports: 4000000,
global: false,
priorityLevel: 'high'
}
},
asLegacyTransaction: false,
dynamicComputeUnitLimit: true,
allowOptimizedWrappedSolTokenAccount: false,
quoteResponse,
dynamicSlippage: { maxBps: 300 }
}),
method: 'POST'
})
).json()

return VersionedTransaction.deserialize(Buffer.from(swapResponse.swapTransaction, 'base64'))
}
14 changes: 14 additions & 0 deletions apps/laboratory/src/components/Solana/SolanaTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { SolanaWriteContractTest } from './SolanaWriteContractTest'
import { solana, solanaDevnet, solanaTestnet } from '../../utils/ChainsUtil'
import { SolanaSignAndSendTransaction } from './SolanaSignAndSendTransactionTest'
import { SolanaSignAllTransactionsTest } from './SolanaSignAllTransactionsTest'
import { SolanaSignJupiterSwapTest } from './SolanaSignJupiterSwapTest'

export function SolanaTests() {
const { isConnected, currentChain } = useWeb3ModalAccount()
Expand Down Expand Up @@ -83,6 +84,19 @@ export function SolanaTests() {
</Heading>
<SolanaSignAndSendTransaction />
</Box>

<Box>
<Heading size="xs" textTransform="uppercase" pb="2">
Sign Jupiter Swap Transaction
<Tooltip label="Use Jupiter Swap API to create a transaction that has Address Lookup Tables and requests for the wallet to sign it">
<Text as="span" fontSize="sm" ml="2">
ℹ️
</Text>
</Tooltip>
</Heading>
<SolanaSignJupiterSwapTest />
</Box>

{(currentChain?.chainId === solanaTestnet.chainId ||
currentChain?.chainId === solanaDevnet.chainId) && (
<Stack divider={<StackDivider />} spacing="4">
Expand Down
8 changes: 4 additions & 4 deletions apps/laboratory/tests/no-socials.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ noSocialsTest.afterAll(async () => {
})

// -- Tests --------------------------------------------------------------------
noSocialsTest('should not display any socials', () => {
modalValidator.expectNoSocials()
noSocialsTest('should not display any socials', async () => {
await modalValidator.expectNoSocials()
})

noSocialsTest('should show email login', () => {
modalValidator.expectEmailLogin()
noSocialsTest('should show email login', async () => {
await modalValidator.expectEmailLogin()
})
2 changes: 1 addition & 1 deletion examples/html-ethers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"@web3modal/ethers": "workspace:*",
"ethers": "6.13.0"
"ethers": "6.13.2"
},
"devDependencies": {
"vite": "5.2.11"
Expand Down
2 changes: 1 addition & 1 deletion examples/html-wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "vite build"
},
"dependencies": {
"@wagmi/connectors": "5.1.5",
"@wagmi/connectors": "5.1.9",
"@wagmi/core": "2.13.4",
"@web3modal/wagmi": "workspace:*",
"react": "18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/next-wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"next": "14.2.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"viem": "2.19.6",
"wagmi": "2.12.5"
"viem": "2.21.4",
"wagmi": "2.12.9"
},
"devDependencies": {
"@types/react": "18.2.62",
Expand Down
2 changes: 1 addition & 1 deletion examples/react-ethers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"@web3modal/ethers": "workspace:*",
"ethers": "6.9.0",
"ethers": "6.13.2",
"react": "18.2.0",
"react-dom": "18.2.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react-wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"@web3modal/wagmi": "workspace:*",
"react": "18.2.0",
"react-dom": "18.2.0",
"viem": "2.19.6",
"viem": "2.21.4",
"vite": "5.2.11",
"wagmi": "2.12.5"
"wagmi": "2.12.9"
},
"devDependencies": {
"@types/react": "18.2.62",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue-wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "vite build"
},
"dependencies": {
"@wagmi/connectors": "5.1.5",
"@wagmi/connectors": "5.1.9",
"@wagmi/core": "2.13.4",
"@web3modal/wagmi": "workspace:*",
"vue": "3.4.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Connection,
PublicKey,
Transaction,
TransactionMessage,
VersionedTransaction,
type SendOptions
} from '@solana/web3.js'
Expand Down Expand Up @@ -284,18 +283,9 @@ export class WalletConnectProvider extends ProviderEventEmitter implements Provi
* This is a deprecated method that is used to support older versions of the
* WalletConnect RPC API. It should be removed in the future
*/
private getRawRPCParams(_transaction: AnyTransaction) {
let transaction = _transaction

private getRawRPCParams(transaction: AnyTransaction) {
if (isVersionedTransaction(transaction)) {
const instructions = TransactionMessage.decompile(transaction.message).instructions
const legacyMessage = new TransactionMessage({
payerKey: new PublicKey(this.getAccount(true).publicKey),
recentBlockhash: transaction.message.recentBlockhash,
instructions: [...instructions]
}).compileToLegacyMessage()

transaction = Transaction.populate(legacyMessage)
return {}
}

return {
Expand Down
Loading

0 comments on commit 882483d

Please sign in to comment.