Skip to content

Commit

Permalink
Merge branch 'main' into fix/socials-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
enesozturk authored Sep 4, 2024
2 parents 916d2ed + 88ae1d8 commit f36d4a7
Show file tree
Hide file tree
Showing 34 changed files with 13,287 additions and 17,557 deletions.
41 changes: 27 additions & 14 deletions .github/workflows/ui_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,31 @@ on:
required: false

jobs:
setup_playwright_runners:
uses: WalletConnect/gh-actions-runners/.github/workflows/setup-runners.yml@main
with:
cpu: 16384
memory: 65536
labels: playwright
count: 5
secrets:
GITHUB_PAT: ${{ secrets.RELEASE_TOKEN }}
TF_API_TOKEN: ${{ secrets.TFC_INFRA_TOKEN }}

ui_tests:
name: 'Playwright Tests'
runs-on:
group: ubuntu-runners
runs-on: [self-hosted, playwright]
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5]
shardTotal: [5]
timeout-minutes: 20
steps:
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1
# Possibly this helps with GitHub-hosted runner network issues, but it's not confirmed
# It's not supported in self-hosted runners, however, so commenting it out for now
# - name: Tune GitHub-hosted runner network
# uses: smorimoto/tune-github-hosted-runner-network@v1

- name: checkout
uses: actions/checkout@v4
Expand All @@ -75,17 +87,18 @@ jobs:
node-version: 18.x
cache: 'pnpm'

- name: Get installed Playwright version
id: playwright-version
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').packages['apps/laboratory']['devDependencies']['@playwright/test'])")" >> $GITHUB_ENV
# - name: Get installed Playwright version
# id: playwright-version
# run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').packages['apps/laboratory']['devDependencies']['@playwright/test'])")" >> $GITHUB_ENV

- name: Cache playwright binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}-${{ hashFiles('apps/laboratory/tests/shared/constants/devices.ts') }}
# This cache causes weird errors on retry runs when using the self-hosted runners, disabling for now
# - name: Cache playwright binaries
# uses: actions/cache@v4
# id: playwright-cache
# with:
# path: |
# ~/.cache/ms-playwright
# key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}-${{ hashFiles('apps/laboratory/tests/shared/constants/devices.ts') }}

- name: Install dependencies
run: pnpm install
Expand Down
6 changes: 4 additions & 2 deletions apps/laboratory/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ 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://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;
frame-src 'self' https://verify.walletconnect.com https://verify.walletconnect.org https://secure.walletconnect.com https://secure.walletconnect.org;
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;
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 || ''
};
object-src 'none';
base-uri 'self';
form-action 'self';
Expand Down
1 change: 0 additions & 1 deletion apps/laboratory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"framer-motion": "10.17.9",
"next": "14.2.3",
"next-auth": "4.24.5",
"permissionless": "0.1.31",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "4.12.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { useEffect } from 'react'
import { Button, Stack } from '@chakra-ui/react'
import { privateKeyToAccount } from 'viem/accounts'
import { useChakraToast } from '../Toast'
import { LOCAL_SIGNER_KEY, getItem } from '../../utils/LocalStorage'
import { LOCAL_SIGNER_KEY, getLocalStorageItem } from '../../utils/LocalStorage'
import { createCredential } from 'webauthn-p256'
import { useWagmiPermissionsSync } from '../../context/WagmiPermissionsSyncContext'
import { usePasskey } from '../../context/PasskeyContext'

export function WagmiCreatePasskeySignerTest() {
const { isPasskeyAvailable, setPasskey, passkeyId } = useWagmiPermissionsSync()
const { isPasskeyAvailable, setPasskey, passkeyId } = usePasskey()
const toast = useChakraToast()

async function handleCreatePasskey() {
Expand All @@ -31,7 +31,7 @@ export function WagmiCreatePasskeySignerTest() {
}

useEffect(() => {
const storedLocalSignerPrivateKey = getItem(LOCAL_SIGNER_KEY)
const storedLocalSignerPrivateKey = getLocalStorageItem(LOCAL_SIGNER_KEY)
if (storedLocalSignerPrivateKey) {
privateKeyToAccount(storedLocalSignerPrivateKey as `0x${string}`)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ import { useChakraToast } from '../Toast'
import { encodeFunctionData, parseEther } from 'viem'
import { abi as donutContractAbi, address as donutContractaddress } from '../../utils/DonutContract'
import { sepolia } from 'viem/chains'
import { useWagmiPermissionsAsync } from '../../context/WagmiPermissionsAsyncContext'
import { useERC7715PermissionsAsync } from '../../hooks/useERC7715PermissionsAsync'
import { useLocalEcdsaKey } from '../../context/LocalEcdsaKeyContext'
import { useERC7715Permissions } from '../../hooks/useERC7715Permissions'
import { executeActionsWithECDSAAndCosignerPermissions } from '../../utils/ERC7715Utils'

export function WagmiPurchaseDonutAsyncPermissionsTest() {
const { grantedPermissions, wcCosignerData, privateKey, projectId } = useWagmiPermissionsAsync()
const { privateKey } = useLocalEcdsaKey()

const { executeActionsWithECDSAAndCosignerPermissions } = useERC7715PermissionsAsync({
chain: sepolia,
permissions: grantedPermissions,
projectId
})
const { grantedPermissions, pci } = useERC7715Permissions()

const {
data: donutsOwned,
Expand All @@ -35,40 +32,43 @@ export function WagmiPurchaseDonutAsyncPermissionsTest() {
async function onPurchaseDonutWithPermissions() {
setTransactionPending(true)
try {
if (!wcCosignerData) {
throw Error('No wc-cosigner data available')
}

if (!privateKey) {
throw new Error(`Unable to get dApp private key`)
}
if (!grantedPermissions) {
throw Error('No permissions available')
}
if (!pci) {
throw Error('No WC cosigner data(PCI) available')
}
const purchaseDonutCallData = encodeFunctionData({
abi: donutContractAbi,
functionName: 'purchase',
args: [1]
})
const purchaseDonutCallDataExecution = [
{
target: donutContractaddress as `0x${string}`,
to: donutContractaddress as `0x${string}`,
value: parseEther('0.0001'),
callData: purchaseDonutCallData
data: purchaseDonutCallData
}
]
const txHash = await executeActionsWithECDSAAndCosignerPermissions({
actions: purchaseDonutCallDataExecution,
chain: sepolia,
ecdsaPrivateKey: privateKey as `0x${string}`
ecdsaPrivateKey: privateKey as `0x${string}`,
permissions: grantedPermissions,
pci
})
if (txHash) {
toast({
title: 'Transaction success',
description: txHash,
title: 'UserOp submitted successfully',
description: `UserOp Hash: ${txHash}`,
type: 'success'
})
await fetchDonutsOwned()
}
} catch (error) {
// Console.log(error)
toast({
title: 'Transaction Failed',
description: `${error}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ import { useState } from 'react'
import { useChakraToast } from '../Toast'
import { encodeFunctionData, parseEther } from 'viem'
import { abi as donutContractAbi, address as donutContractaddress } from '../../utils/DonutContract'
import { useERC7715PermissionsSync } from '../../hooks/useERC7715PermissionsSync'
import { useWagmiPermissionsSync } from '../../context/WagmiPermissionsSyncContext'
import { useERC7715Permissions } from '../../hooks/useERC7715Permissions'
import { usePasskey } from '../../context/PasskeyContext'
import { sepolia } from 'viem/chains'
import { executeActionsWithPasskeyAndCosignerPermissions } from '../../utils/ERC7715Utils'

export function WagmiPurchaseDonutSyncPermissionsTest() {
const { grantedPermissions, wcCosignerData, passkeyId, projectId } = useWagmiPermissionsSync()
const { executeActionsWithPasskeyAndCosignerPermissions } = useERC7715PermissionsSync({
chain: sepolia,
permissions: grantedPermissions,
projectId
})
const { passkeyId } = usePasskey()
const { grantedPermissions, pci } = useERC7715Permissions()

const {
data: donutsOwned,
Expand All @@ -37,8 +34,8 @@ export function WagmiPurchaseDonutSyncPermissionsTest() {
if (!grantedPermissions) {
throw Error('No permissions available')
}
if (!wcCosignerData) {
throw Error('No wc-cosigner data available')
if (!pci) {
throw Error('No WC cosigner data(PCI) available')
}

const purchaseDonutCallData = encodeFunctionData({
Expand All @@ -48,20 +45,22 @@ export function WagmiPurchaseDonutSyncPermissionsTest() {
})
const purchaseDonutCallDataExecution = [
{
target: donutContractaddress as `0x${string}`,
to: donutContractaddress as `0x${string}`,
value: parseEther('0.0001'),
callData: purchaseDonutCallData
data: purchaseDonutCallData
}
]
const txHash = await executeActionsWithPasskeyAndCosignerPermissions({
actions: purchaseDonutCallDataExecution,
chain: sepolia,
passkeyId,
wcCosignerData
permissions: grantedPermissions,
pci
})
if (txHash) {
toast({
title: 'Transaction success',
description: txHash,
title: 'UserOp submitted successfully',
description: `UserOp Hash: ${txHash}`,
type: 'success'
})
await fetchDonutsOwned()
Expand Down
Loading

0 comments on commit f36d4a7

Please sign in to comment.