Skip to content

Commit c0fbcd5

Browse files
chore: add format and lint pr check (#544)
* chore: add format and lint pr check * fix: matrix * fix: indent * fix: don't cache dependencies * fix: working directory * fix: working directory * fix: command * fix: working dir * fix: command * chore: refactor workflows * fix: on trigger * fix: install command * fix: add specific timeouts * fix: wallet format * fix: lint and format * fix: UI test env * fix: remove redundant naming
1 parent 4e487eb commit c0fbcd5

27 files changed

+340
-234
lines changed

.github/workflows/pr_checks.yml

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: UI Tests
1+
name: PR Checks
22

33
concurrency:
44
# Support push/pr as event types with different behaviors each:
@@ -18,34 +18,32 @@ on:
1818
- main
1919

2020
jobs:
21-
preview:
21+
code_style:
22+
name: "Code Style"
2223
runs-on: ubuntu-latest
23-
outputs:
24-
preview-url: ${{ steps.preview.outputs.PREVIEW_URL }}
24+
strategy:
25+
matrix:
26+
style-command:
27+
- lint
28+
- prettier
29+
project:
30+
- dapps/react-dapp-v2
31+
- wallets/react-wallet-v2
2532
steps:
26-
- uses: actions/checkout@v4
27-
- name: Install Vercel CLI
28-
run: npm install --global vercel@latest
29-
- name: Pull Vercel Environment Information
30-
run: vercel pull --yes --environment=preview --token=${{ secrets.UI_TEST_VERCEL_TOKEN }}
31-
- name: Build Project Artifacts
32-
run: vercel build --token=${{ secrets.UI_TEST_VERCEL_TOKEN }}
33-
- name: Deploy Project Artifacts to Vercel
34-
run: vercel deploy --prebuilt --token=${{ secrets.UI_TEST_VERCEL_TOKEN }} > preview.txt
35-
- name: preview
36-
id: preview
37-
run: echo "PREVIEW_URL=$(cat preview.txt | tail -n 1)" >> "$GITHUB_OUTPUT"
33+
- name: checkout
34+
uses: actions/checkout@v3
35+
- name: setup-node
36+
uses: actions/setup-node@v3
37+
with:
38+
node-version: 18.x
39+
- name: install
40+
working-directory: advanced/${{ matrix.project }}
41+
run: yarn install --immutable --immutable-cache --check-cache
42+
- name: check
43+
working-directory: advanced/${{ matrix.project }}
44+
run: yarn ${{ matrix.style-command }}
3845

3946
ui-test:
40-
needs: preview
41-
with:
42-
base-url: http://localhost:3000/
43-
wallet-url: ${{ needs.preview.outputs.preview-url }}/
44-
skip-playwright-webserver: false
45-
branch: V4
46-
command: playwright:test:wallet
47-
uses: WalletConnect/web3modal/.github/workflows/ui_tests.yml@V4
48-
secrets:
49-
NEXT_PUBLIC_PROJECT_ID: ${{ secrets.UI_TEST_PROJECT_ID }}
50-
TESTS_NEXTAUTH_SECRET: ${{ secrets.TESTS_NEXTAUTH_SECRET }}
51-
TESTS_MAILSEC_API_KEY: ${{ secrets.MAILSAC_API_KEY }}
47+
name: "UI Tests"
48+
uses: ./.github/workflows/ui_tests.yml
49+
secrets: inherit

.github/workflows/ui_tests.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: UI Tests
2+
3+
on: workflow_call
4+
5+
env:
6+
VERCEL_ORG_ID: ${{ secrets.VERCEL_TEAM_ID }}
7+
VERCEL_PROJECT_ID: ${{ secrets.UI_TEST_WALLET_V2_VERCEL_PROJECT_ID }}
8+
9+
jobs:
10+
preview:
11+
name: "Preview deployment"
12+
runs-on: ubuntu-latest
13+
outputs:
14+
preview-url: ${{ steps.preview.outputs.PREVIEW_URL }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Install Vercel CLI
18+
run: npm install --global vercel@latest
19+
- name: Pull Vercel Environment Information
20+
run: vercel pull --yes --environment=preview --token=${{ secrets.UI_TEST_VERCEL_TOKEN }}
21+
- name: Build Project Artifacts
22+
run: vercel build --token=${{ secrets.UI_TEST_VERCEL_TOKEN }}
23+
- name: Deploy Project Artifacts to Vercel
24+
run: vercel deploy --prebuilt --token=${{ secrets.UI_TEST_VERCEL_TOKEN }} > preview.txt
25+
- name: preview
26+
id: preview
27+
run: echo "PREVIEW_URL=$(cat preview.txt | tail -n 1)" >> "$GITHUB_OUTPUT"
28+
29+
ui-test:
30+
needs: preview
31+
with:
32+
base-url: http://localhost:3000/
33+
wallet-url: ${{ needs.preview.outputs.preview-url }}/
34+
skip-playwright-webserver: false
35+
branch: V4
36+
command: playwright:test:wallet
37+
uses: WalletConnect/web3modal/.github/workflows/ui_tests.yml@V4
38+
secrets:
39+
NEXT_PUBLIC_PROJECT_ID: ${{ secrets.UI_TEST_PROJECT_ID }}
40+
TESTS_NEXTAUTH_SECRET: ${{ secrets.TESTS_NEXTAUTH_SECRET }}
41+
TESTS_MAILSEC_API_KEY: ${{ secrets.MAILSAC_API_KEY }}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": "next/core-web-vitals",
33
"rules": {
4-
"no-trailing-spaces": 1
4+
"no-trailing-spaces": 1,
5+
"@next/next/no-img-element": "off"
56
}
67
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.changeset
2+
coverage
3+
.idea
4+
.next
5+
node_modules

advanced/dapps/react-dapp-v2/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"build": "next build",
88
"start": "next start",
99
"lint": "next lint",
10+
"prettier": "prettier --check '**/*.{js,ts,jsx,tsx}'",
1011
"prettier:write": "prettier --write '**/*.{js,ts,jsx,tsx}'"
1112
},
1213
"dependencies": {

advanced/dapps/react-dapp-v2/src/constants/default.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ export const DEFAULT_APP_METADATA = {
5959
* EIP5792
6060
*/
6161
export const DEFAULT_EIP5792_METHODS = {
62-
WALLET_GET_CAPABILITIES : "wallet_getCapabilities",
63-
WALLET_SEND_CALLS : "wallet_sendCalls",
64-
WALLET_GET_CALLS_STATUS : 'wallet_getCallsStatus'
65-
} as const
62+
WALLET_GET_CAPABILITIES: "wallet_getCapabilities",
63+
WALLET_SEND_CALLS: "wallet_sendCalls",
64+
WALLET_GET_CALLS_STATUS: "wallet_getCallsStatus",
65+
} as const;
6666

6767
export type SendCallsParams = {
6868
version: string;
@@ -77,7 +77,7 @@ export type SendCallsParams = {
7777
};
7878

7979
// capability names as string literals
80-
export type CapabilityName = 'atomicBatch' | 'paymasterService' | 'sessionKey';
80+
export type CapabilityName = "atomicBatch" | "paymasterService" | "sessionKey";
8181
// Capability type where each key is a capability name and value has `supported` field
8282
export type Capabilities = {
8383
[K in CapabilityName]: {
@@ -88,7 +88,7 @@ export type Capabilities = {
8888
export type GetCapabilitiesResult = Record<string, Capabilities>;
8989

9090
export type GetCallsResult = {
91-
status: 'PENDING' | 'CONFIRMED';
91+
status: "PENDING" | "CONFIRMED";
9292
receipts?: {
9393
logs: {
9494
address: `0x${string}`;
@@ -107,21 +107,21 @@ export type GetCallsResult = {
107107
* EIP155
108108
*/
109109
export const DEFAULT_EIP155_METHODS = {
110-
ETH_SEND_TRANSACTION : "eth_sendTransaction",
111-
PERSONAL_SIGN : "personal_sign",
112-
}
110+
ETH_SEND_TRANSACTION: "eth_sendTransaction",
111+
PERSONAL_SIGN: "personal_sign",
112+
};
113113

114114
export const DEFAULT_EIP155_OPTIONAL_METHODS = {
115-
ETH_SIGN_TRANSACTION : "eth_signTransaction",
116-
ETH_SIGN : "eth_sign",
117-
ETH_SIGN_TYPED_DATA : "eth_signTypedData",
118-
ETH_SIGN_TYPED_DATA_V4 : "eth_signTypedData_v4",
119-
} as const
115+
ETH_SIGN_TRANSACTION: "eth_signTransaction",
116+
ETH_SIGN: "eth_sign",
117+
ETH_SIGN_TYPED_DATA: "eth_signTypedData",
118+
ETH_SIGN_TYPED_DATA_V4: "eth_signTypedData_v4",
119+
} as const;
120120

121121
export const DEFAULT_OPTIONAL_METHODS = {
122-
...DEFAULT_EIP155_OPTIONAL_METHODS ,
123-
...DEFAULT_EIP5792_METHODS
124-
}
122+
...DEFAULT_EIP155_OPTIONAL_METHODS,
123+
...DEFAULT_EIP5792_METHODS,
124+
};
125125

126126
export enum DEFAULT_EIP_155_EVENTS {
127127
ETH_CHAIN_CHANGED = "chainChanged",

advanced/dapps/react-dapp-v2/src/contexts/JsonRpcContext.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export function JsonRpcContextProvider({
155155
const [pending, setPending] = useState(false);
156156
const [result, setResult] = useState<IFormattedRpcResponse | null>();
157157
const [isTestnet, setIsTestnet] = useState(getLocalStorageTestnetFlag());
158-
const [lastTxId, setLastTxId] = useState<`0x${string}`>()
158+
const [lastTxId, setLastTxId] = useState<`0x${string}`>();
159159
const [kadenaAccount, setKadenaAccount] = useState<KadenaAccount | null>(
160160
null
161161
);
@@ -519,11 +519,14 @@ export function JsonRpcContextProvider({
519519

520520
// The wallet_getCapabilities "caching" should ultimately move into the provider.
521521
// check the session.sessionProperties first for capabilities
522-
const capabilitiesJson = session?.sessionProperties?.['capabilities']
523-
const walletCapabilities = capabilitiesJson && JSON.parse(capabilitiesJson)
524-
let capabilities = walletCapabilities[address] as GetCapabilitiesResult|undefined
522+
const capabilitiesJson = session?.sessionProperties?.["capabilities"];
523+
const walletCapabilities =
524+
capabilitiesJson && JSON.parse(capabilitiesJson);
525+
let capabilities = walletCapabilities[address] as
526+
| GetCapabilitiesResult
527+
| undefined;
525528
// send request for wallet_getCapabilities
526-
if(!capabilities)
529+
if (!capabilities)
527530
capabilities = await client!.request<GetCapabilitiesResult>({
528531
topic: session!.topic,
529532
chainId,
@@ -553,8 +556,11 @@ export function JsonRpcContextProvider({
553556
`Missing rpcProvider definition for chainId: ${chainId}`
554557
);
555558
}
556-
if(lastTxId === undefined) throw new Error(`Last transaction ID is undefined, make sure previous call to sendCalls returns successfully. `);
557-
const params = [lastTxId]
559+
if (lastTxId === undefined)
560+
throw new Error(
561+
`Last transaction ID is undefined, make sure previous call to sendCalls returns successfully. `
562+
);
563+
const params = [lastTxId];
558564
// send request for wallet_getCallsStatus
559565
const getCallsStatusResult = await client!.request<GetCallsResult>({
560566
topic: session!.topic,
@@ -586,12 +592,13 @@ export function JsonRpcContextProvider({
586592
throw new Error(`Account for ${caipAccountAddress} not found`);
587593

588594
const balance = BigNumber.from(balances[account][0].balance || "0");
589-
if (balance.lt(parseEther('0.0002'))) {
595+
if (balance.lt(parseEther("0.0002"))) {
590596
return {
591597
method: DEFAULT_EIP5792_METHODS.WALLET_SEND_CALLS,
592598
address,
593599
valid: false,
594-
result: "Insufficient funds for batch call [minimum 0.0002ETH required excluding gas].",
600+
result:
601+
"Insufficient funds for batch call [minimum 0.0002ETH required excluding gas].",
595602
};
596603
}
597604
// split chainId
@@ -602,7 +609,8 @@ export function JsonRpcContextProvider({
602609
`Missing rpcProvider definition for chainId: ${chainId}`
603610
);
604611
}
605-
const sendCallsRequestParams:SendCallsParams = await formatTestBatchCall(account)
612+
const sendCallsRequestParams: SendCallsParams =
613+
await formatTestBatchCall(account);
606614
// send batch Tx
607615
const txId = await client!.request<string>({
608616
topic: session!.topic,
@@ -613,7 +621,9 @@ export function JsonRpcContextProvider({
613621
},
614622
});
615623
// store the last transactionId to use it for wallet_getCallsReceipt
616-
setLastTxId((txId && txId.startsWith('0x')) ? txId as `0x${string}` : undefined)
624+
setLastTxId(
625+
txId && txId.startsWith("0x") ? (txId as `0x${string}`) : undefined
626+
);
617627
// format displayed result
618628
return {
619629
method: DEFAULT_EIP5792_METHODS.WALLET_SEND_CALLS,

advanced/dapps/react-dapp-v2/src/helpers/tx.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,30 @@ export async function formatTestTransaction(account: string) {
4444
return tx;
4545
}
4646

47-
4847
export async function formatTestBatchCall(account: string) {
4948
const [namespace, reference, address] = account.split(":");
5049
// preparing calldata for batch send
5150
//sepolia pow faucet address
52-
const receiverAddress = '0x6Cc9397c3B38739daCbfaA68EaD5F5D77Ba5F455'
53-
const amountToSend = parseEther('0.0001').toHexString()
51+
const receiverAddress = "0x6Cc9397c3B38739daCbfaA68EaD5F5D77Ba5F455";
52+
const amountToSend = parseEther("0.0001").toHexString();
5453
const calls = [
5554
{
5655
to: receiverAddress as `0x${string}`,
57-
data:'0x' as `0x${string}`,
58-
value: amountToSend as `0x${string}`
56+
data: "0x" as `0x${string}`,
57+
value: amountToSend as `0x${string}`,
5958
},
6059
{
6160
to: receiverAddress as `0x${string}`,
62-
data:'0x' as `0x${string}`,
63-
value: amountToSend as `0x${string}`
61+
data: "0x" as `0x${string}`,
62+
value: amountToSend as `0x${string}`,
6463
},
65-
]
66-
const sendCallsRequestParams:SendCallsParams = {
67-
version:'1.0',
64+
];
65+
const sendCallsRequestParams: SendCallsParams = {
66+
version: "1.0",
6867
chainId: `0x${BigInt(reference).toString(16)}`,
6968
from: address as `0x${string}`,
7069
calls: calls,
71-
}
70+
};
7271

7372
return sendCallsRequestParams;
74-
}
73+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.changeset
2+
coverage
3+
.idea
4+
.next
5+
node_modules

advanced/wallets/react-wallet-v2/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"build": "next build",
77
"start": "next start",
88
"lint": "next lint",
9+
"prettier": "prettier --check '**/*.{js,ts,jsx,tsx}'",
910
"prettier:write": "prettier --write '**/*.{js,ts,jsx,tsx}'"
1011
},
1112
"dependencies": {

advanced/wallets/react-wallet-v2/src/data/EIP155Data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ export const EIP155_SIGNING_METHODS = {
132132
ETH_SIGN_TYPED_DATA_V4: 'eth_signTypedData_v4',
133133
ETH_SEND_RAW_TRANSACTION: 'eth_sendRawTransaction',
134134
ETH_SEND_TRANSACTION: 'eth_sendTransaction'
135-
}
135+
}

0 commit comments

Comments
 (0)