Skip to content

Commit

Permalink
fix: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
KannuSingh committed May 8, 2024
1 parent 0949aad commit 3932b80
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
26 changes: 15 additions & 11 deletions apps/laboratory/src/components/Ethers/EthersGetCallsStatusTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useState } from 'react'
import { sepolia } from '../../utils/ChainsUtil'
import { useWeb3ModalAccount, useWeb3ModalProvider } from '@web3modal/ethers/react'
import { useChakraToast } from '../Toast'
import { BrowserProvider} from 'ethers'
import { BrowserProvider } from 'ethers'

export type GetCallsStatusParams = `0x${string}`
export type GetCallsStatusParams = `0x${string}`

export function EthersGetCallsStatusTest() {
const toast = useChakraToast()
Expand All @@ -17,14 +17,16 @@ export function EthersGetCallsStatusTest() {
async function onGetCallsStatus() {
try {
setLoading(true)
if (!walletProvider || !address ) {
if (!walletProvider || !address) {
throw Error('user is disconnected')
}
if( !chainId) throw Error('chain not selected')
if( !batchCallId) throw Error('call tx hash not valid')
if (!chainId) throw Error('chain not selected')

Check failure on line 23 in apps/laboratory/src/components/Ethers/EthersGetCallsStatusTest.tsx

View workflow job for this annotation

GitHub Actions / code_style (lint)

Expected { after 'if' condition
if (!batchCallId) throw Error('call tx hash not valid')

Check failure on line 24 in apps/laboratory/src/components/Ethers/EthersGetCallsStatusTest.tsx

View workflow job for this annotation

GitHub Actions / code_style (lint)

Expected { after 'if' condition
const provider = new BrowserProvider(walletProvider, chainId)
const batchCallsStatus = await provider.send("wallet_getCallsStatus", [batchCallId as GetCallsStatusParams]);

const batchCallsStatus = await provider.send('wallet_getCallsStatus', [
batchCallId as GetCallsStatusParams
])

toast({
title: 'Success',
description: JSON.stringify(batchCallsStatus),
Expand All @@ -45,9 +47,11 @@ export function EthersGetCallsStatusTest() {

return allowedChains.includes(Number(chainId)) && address ? (
<Stack direction={['column', 'column', 'row']}>
<Input placeholder="0xf34ffa..."
onChange={e => setBatchCallId(e.target.value)}
value={batchCallId} />
<Input
placeholder="0xf34ffa..."
onChange={e => setBatchCallId(e.target.value)}
value={batchCallId}
/>
<Button
data-test-id="sign-transaction-button"
onClick={onGetCallsStatus}
Expand All @@ -61,4 +65,4 @@ export function EthersGetCallsStatusTest() {
Switch to Sepolia to test this feature
</Text>
)
}
}
58 changes: 27 additions & 31 deletions apps/laboratory/src/components/Ethers/EthersSendCallsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,61 @@ import { useWeb3ModalAccount, useWeb3ModalProvider } from '@web3modal/ethers/rea
import { useChakraToast } from '../Toast'
import { parseGwei, type Address } from 'viem'
import { vitalikEthAddress } from '../../utils/DataUtil'
import { BrowserProvider} from 'ethers'
import { BrowserProvider } from 'ethers'

export type SendCallsParams = {
version: string;
chainId: `0x${string}`; // Hex chain id
from: `0x${string}`;
version: string
chainId: `0x${string}` // Hex chain id

Check failure on line 12 in apps/laboratory/src/components/Ethers/EthersSendCallsTest.tsx

View workflow job for this annotation

GitHub Actions / code_style (lint)

Expected comment to be above code

Check failure on line 12 in apps/laboratory/src/components/Ethers/EthersSendCallsTest.tsx

View workflow job for this annotation

GitHub Actions / code_style (lint)

Unexpected comment inline with code
from: `0x${string}`
calls: {
to?: `0x${string}` | undefined;
data?: `0x${string}` | undefined;
value?: `0x${string}` | undefined; // Hex value
}[];
capabilities?: Record<string, any> | undefined;
};
to?: `0x${string}` | undefined
data?: `0x${string}` | undefined
value?: `0x${string}` | undefined // Hex value

Check failure on line 17 in apps/laboratory/src/components/Ethers/EthersSendCallsTest.tsx

View workflow job for this annotation

GitHub Actions / code_style (lint)

Expected comment to be above code

Check failure on line 17 in apps/laboratory/src/components/Ethers/EthersSendCallsTest.tsx

View workflow job for this annotation

GitHub Actions / code_style (lint)

Unexpected comment inline with code
}[]
capabilities?: Record<string, any> | undefined

Check failure on line 19 in apps/laboratory/src/components/Ethers/EthersSendCallsTest.tsx

View workflow job for this annotation

GitHub Actions / code_style (lint)

Unexpected any. Specify a different type
}

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

function formatTestBatchCall(accountAddress: string,chainId:number) {
function formatTestBatchCall(accountAddress: string, chainId: number) {

Check failure on line 28 in apps/laboratory/src/components/Ethers/EthersSendCallsTest.tsx

View workflow job for this annotation

GitHub Actions / code_style (lint)

'chainId' is already declared in the upper scope on line 24 column 20
// preparing calldata for batch send

Check failure on line 29 in apps/laboratory/src/components/Ethers/EthersSendCallsTest.tsx

View workflow job for this annotation

GitHub Actions / code_style (lint)

Comments should not begin with a lowercase character
const amountToSend = parseGwei('0.001').toString(16);
const amountToSend = parseGwei('0.001').toString(16)
const calls = [
{
to: vitalikEthAddress as `0x${string}`,
data: "0x" as `0x${string}`,
value: `0x${amountToSend}` as `0x${string}`,
data: '0x' as `0x${string}`,
value: `0x${amountToSend}` as `0x${string}`

Check failure on line 35 in apps/laboratory/src/components/Ethers/EthersSendCallsTest.tsx

View workflow job for this annotation

GitHub Actions / code_style (lint)

This assertion is unnecessary since it does not change the type of the expression
},
{
to: vitalikEthAddress as Address,
data: '0xdeadbeef' as `0x${string}`
},
];
}
]
const sendCallsRequestParams: SendCallsParams = {
version: "1.0",
version: '1.0',
chainId: `0x${BigInt(chainId).toString(16)}`,
from: accountAddress as `0x${string}`,
calls: calls,
};
return sendCallsRequestParams;
calls: calls
}

return sendCallsRequestParams
}

async function onSendCalls() {
try {
setLoading(true)
if (!walletProvider || !address ) {
if (!walletProvider || !address) {
throw Error('user is disconnected')
}
if( !chainId) throw Error('Select chain')
if (!chainId) throw Error('Select chain')
const provider = new BrowserProvider(walletProvider, chainId)
const sendCallsParams = formatTestBatchCall(address,chainId)
const sendCallsParams = formatTestBatchCall(address, chainId)
console.log(sendCallsParams)
const batchCallHash = await provider.send("wallet_sendCalls", [sendCallsParams]);
const batchCallHash = await provider.send('wallet_sendCalls', [sendCallsParams])

toast({
title: 'Success',
Expand All @@ -81,11 +81,7 @@ export function EthersSendCallsTest() {

return allowedChains.includes(Number(chainId)) && address ? (
<Stack direction={['column', 'column', 'row']}>
<Button
data-test-id="sign-transaction-button"
onClick={onSendCalls}
isDisabled={loading}
>
<Button data-test-id="sign-transaction-button" onClick={onSendCalls} isDisabled={loading}>
Send Batch Calls to Vitalik
</Button>

Expand All @@ -108,4 +104,4 @@ export function EthersSendCallsTest() {
Switch to Sepolia to test this feature
</Text>
)
}
}

0 comments on commit 3932b80

Please sign in to comment.