feat: added WalletConnect integration for improve tests speed#361
feat: added WalletConnect integration for improve tests speed#361
Conversation
…etConnect handling
…etConnect handling
…n void and enhance transaction validation
…n void and enhance transaction validation
…tion cancellation
…tion cancellation
…ity and maintainability
…esponse structure
| @@ -7,16 +17,20 @@ export interface CommonWalletConfig { | |||
| WALLET_TYPE: WalletConnectType; | |||
| LATEST_STABLE_DOWNLOAD_LINK?: string; // Link to stable wallet extension version for test (optional) | |||
| EXTENSION_START_PATH: string; // Start path for wallet setup | |||
There was a problem hiding this comment.
Is I'm correct that at this point of implementation WC direct connection EXTENSION_START_PATH also should be optional?
| import type { WCSessionRequest } from '../components'; | ||
| import type { WCWallet } from '../wc.service'; | ||
|
|
||
| const isAddr = (v: unknown) => /^0x[a-fA-F0-9]{40}$/.test(String(v)); |
There was a problem hiding this comment.
Better use
import { isAddress } from 'viem';
const isAddr = (v: unknown) => isAddress(String(v));
Also is it expected that address has unknown type?
| let proposal; | ||
| await test.step(`Pairing`, async () => { | ||
| [proposal] = await Promise.all([ | ||
| this.waitForProposalOnce(this.defaultTimeoutMs), | ||
| this.signClient.core.pairing.pair({ uri }), | ||
| ]); | ||
| }); | ||
| const { id, params } = proposal; |
There was a problem hiding this comment.
Better to use if no cons
const proposal = await test.step('Pairing', async () => {
const [proposal] = await Promise.all([
this.waitForProposalOnce(this.defaultTimeoutMs),
this.signClient.core.pairing.pair({ uri }),
]);
return proposal;
});
const { id, params } = proposal;
| async validateRequest( | ||
| req: WCSessionRequest, | ||
| ): Promise<WCSessionRequest | undefined> { | ||
| // @todo: think about it, i think its bullshit |
There was a problem hiding this comment.
Could you explain root of the comment pls?
As i see it's used by
const currentPendingRequest = this.pendings[0];
->
if (currentPendingRequest) {
return this.validateRequest(currentPendingRequest);
}
->
// @todo: think about it, i think its bullshit
if (req.processed) {
If request is pending he can be in processed state?
| async changeNetwork(networkName: string): Promise<void> { | ||
| await test.step(`Change network to ${networkName}`, async () => { | ||
| const chain = await this.networkSettings.changeNetwork(networkName); | ||
| this.rebuildViemClients(chain); |
| } | ||
|
|
||
| private async rebuildViemClients(chain: Chain) { | ||
| test.step(`Rebuild Viem clients for chain ${chain.id}`, async () => { |
| const net = | ||
| this.networkSettings.networksByChainId.get(chain.id) || | ||
| this.options.standConfig; | ||
| if (net?.rpcUrl) { |
There was a problem hiding this comment.
Minor: net might be a bit ambiguous. Maybe networkConfig (or similar) would make the intent clearer.
| this.walletClient = null; | ||
| this.publicClient = null; |
There was a problem hiding this comment.
Could you explain why do you need to set this.walletClient && this.publicClient to null? Where it should be inited? I see updateAllSessionsNamespaces after rebuildViemClients but for me it's confuised
No description provided.