Skip to content

Conversation

@midas-myth
Copy link
Contributor

@midas-myth midas-myth commented Dec 24, 2025

Note

Mass migration from ethers/typechain to viem across app, simplifying contract I/O, events, and infra.

  • Replace ethers contracts/utilities with viem: use publicClient.readContract, watchContractEvent, encodeFunctionData, viem constants/types, and decodeErrorResult; remove typechain-specific factories and adapt tests/utilities
  • Refactor RPC/WebSocket and multicall layers: use viem clients, new getWsUrl, streamlined endpoint selection, remove legacy RPC fallback switcher and delete old tracker (oldRpcTracker.ts); tidy RPC debug and AB flags
  • Update multichain/referrals flows: use viem clients and ISigner for signing; Stargate reads via readContract; encode tx payloads with viem; adjust OFT/LayerZero subscriptions
  • Synthetics/markets/orders: re-encode multicalls, simulate via viem/Tenderly, fix error parsing, and make reasonBytes a string; route/debug paths slightly reorganized
  • Minor: add ESLint rule, small gitignore tweaks, and miscellaneous util/test migrations (max/zero constants, parseUnits, address checks)

Written by Cursor Bugbot for commit f60a8aa. This will update automatically on new commits. Configure here.

…ts and updating contract interactions to use public client methods. Clean up .gitignore by removing unnecessary entries. Adjust types for QuoteOft to allow for more flexibility.
…factories, and interfaces, to streamline the codebase and eliminate redundancy.
… multiple components. Update ESLint configuration to disable optional catch binding rule. Clean up .gitignore by removing unnecessary entries. Adjust type definitions for trade history actions and improve contract interaction methods to utilize public client for better performance.
…osit functions to utilize encodeFunctionData for improved clarity and consistency. Remove redundant contract instantiation and streamline multicall payload creation across various transaction types.
…e and eliminate redundancy across various contract interfaces.
…rom the library, replacing instances of and for improved consistency and clarity in address validation and comparison.
…or improved signer management. Update random account generation to utilize private key accounts, enhancing security and consistency. Streamline wallet interactions and enhance type definitions across various components for better clarity and maintainability.
…ect. Update Vite configuration to reflect these changes.
@midas-myth midas-myth self-assigned this Dec 24, 2025
@midas-myth midas-myth changed the title Remove typechain Remove typechain FEDEV-3220 Dec 26, 2025
Comment on lines 172 to 184
args?: {
[key in ExtractAbiItem<
typeof abis.CustomErrors,
ContractErrorName<typeof abis.CustomErrors>
>["inputs"][number]["name"]]: AbiParameterToPrimitiveType<
Extract<
ExtractAbiItem<typeof abis.CustomErrors, ContractErrorName<typeof abis.CustomErrors>>["inputs"][number],
{ name: key }
>,
"inputs"
>;
};
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract to named type

Comment on lines 175 to 176
if (paramsAccount && ethers.isAddress(paramsAccount)) {
checkSummedAccount = ethers.getAddress(paramsAccount);
if (paramsAccount && isAddress(paramsAccount)) {
checkSummedAccount = getAddress(paramsAccount);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passs strict false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 16 to 76
import { signCreateWithdrawal } from "../signCreateWithdrawal";
import { signCreateGlvWithdrawal } from "../signCreateGlvWithdrawal";
import { CreateGlvWithdrawalParams } from "../types";
import { stargateTransferFees } from "./stargateTransferFees";

export async function estimateGlvWithdrawalPlatformTokenTransferInFees({
chainId,
srcChainId,
marketTokenAmount,
fullWntFee,
params,
secondaryOrPrimaryOutputTokenAddress: _secondaryOrPrimaryOutputTokenAddress,
globalExpressParams,
}: {
chainId: SettlementChainId;
srcChainId: SourceChainId;
marketTokenAmount: bigint;
fullWntFee: bigint;
params: CreateGlvWithdrawalParams;
secondaryOrPrimaryOutputTokenAddress: string;
globalExpressParams: GlobalExpressParams;
}): Promise<{
platformTokenTransferInGasLimit: bigint;
platformTokenTransferInNativeFee: bigint;
platformTokenTransferInComposeGas: bigint;
relayParamsPayload: RelayParamsPayload;
}> {
const settlementWrappedTokenData = globalExpressParams.tokensData[getWrappedToken(chainId).address];

const rawRelayParamsPayload = getRawRelayerParams({
chainId,
gasPaymentTokenAddress: settlementWrappedTokenData.address,
relayerFeeTokenAddress: settlementWrappedTokenData.address,
feeParams: {
feeToken: settlementWrappedTokenData.address,
feeAmount: fullWntFee,
feeSwapPath: [],
},
externalCalls: getEmptyExternalCallsPayload(),
tokenPermits: [],
});

const relayParamsPayload: RelayParamsPayload = {
...rawRelayParamsPayload,
deadline: BigInt(nowInSeconds() + DEFAULT_EXPRESS_ORDER_DEADLINE_DURATION),
};

const vaultAddress = getContract(chainId, "GlvVault");
const transferRequests = getTransferRequests([
{
to: vaultAddress,
token: params.addresses.glv,
amount: marketTokenAmount,
},
]);

if (!transferRequests) {
throw new Error("Transfer requests not found");
}

const signature = await signCreateWithdrawal({
const signature = await signCreateGlvWithdrawal({
chainId,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait till fix multichain is merged

Comment on lines 25 to 26
params: CreateWithdrawalParams;
params: CreateGlvWithdrawalParams;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait till fix multichain gets merged

let account;
if (queryAccount && ethers.isAddress(queryAccount)) {
account = ethers.getAddress(queryAccount);
if (queryAccount && isAddress(queryAccount)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use strict false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 30 to 37
if (!ethers.isAddress(receiver)) {
if (!isAddress(receiver)) {
return t`Invalid Receiver Address`;
}
if (!nftAddress || nftAddress.length === 0) {
return t`Enter NFT Address`;
}
if (!ethers.isAddress(nftAddress)) {
if (!isAddress(nftAddress)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strict false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const [, copyToClipboard] = useCopyToClipboard();
const { sender, receiver } = useParams<{ sender: string | undefined; receiver: string | undefined }>();
const isSenderAndReceiverValid = ethers.isAddress(sender) && ethers.isAddress(receiver);
const isSenderAndReceiverValid = sender && receiver && isAddress(sender) && isAddress(receiver);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strict false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return t`Enter Receiver Address`;
}
if (!ethers.isAddress(receiver)) {
if (!isAddress(receiver)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strict false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 97 to 99
const transport = fallback([
...getRpcProviders(chainId, purpose).map((provider) => http(provider.url, HTTP_TRANSPORT_OPTIONS)),
]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless spread

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

} else if (options.withExpress) {
transport = getRpcTransport(chainId as AnyChainId, "express");
} else {
transport = getRpcTransport(chainId as AnyChainId, "fallback");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why fallback, should be probably default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 45 to 54
throw new Error(`Unsupported websocket provider for chain id: ${chainId}`);
return new ethers.WebSocketProvider(getWsUrl(chainId)!, network, { staticNetwork: network });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protect from unsupported chain ids

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@midas-myth
Copy link
Contributor Author

@cursor review

…mponents and contexts for improved flexibility.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!

…ovider mapping and updating fallback transport type from fallback to default.
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 26, 2025

Deploying gmx-interface-home with  Cloudflare Pages  Cloudflare Pages

Latest commit: 580cbc7
Status: ✅  Deploy successful!
Preview URL: https://4156a026.gmx-interface-home.pages.dev
Branch Preview URL: https://remove-typechain.gmx-interface-home.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 26, 2025

Deploying gmx-interface with  Cloudflare Pages  Cloudflare Pages

Latest commit: 580cbc7
Status: ✅  Deploy successful!
Preview URL: https://b88fe7b4.gmx-interface.pages.dev
Branch Preview URL: https://remove-typechain.gmx-interface.pages.dev

View logs

@midas-myth midas-myth marked this pull request as ready for review December 26, 2025 14:54
@midas-myth
Copy link
Contributor Author

@cursor review

…event subscription logic by removing unused source chain provider references and adjusting account type to allow null. Enhanced clarity in debug logging for source chain approval events. Updated metrics to remove unnecessary data fields.
@midas-myth
Copy link
Contributor Author

@cursor review

i updates the web socket handling

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!

@midas-myth
Copy link
Contributor Author

src/lib/transactions/sendWalletTransaction.ts not changed

requiredListenerCount,
listenerCount,
},
data: {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why listenners params removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

viem is move of a black box when it comes to subscriptions, i tried but it was difficuly

});

blockTimestamp = blockTimestampResult.result!;
blockNumber = currentBlockNumberResult.result!;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need result**!** ? probably we should check if it's exist and throw an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, extracted to function, reused

],
});

blockTimestamp = blockTimestampResult.result!;
Copy link
Contributor

@divhead divhead Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here result**!**

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, extracted to function, reused


static fromPrivateKeyAccount(privateKeyAccount: PrivateKeyAccount): ISigner {
const gmxSigner = new ISigner({ privateKeyAccount });
gmxSigner._address = privateKeyAccount.address;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, seems _address should be settled in constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to constructor, added initialization lock promise

…handling in SyntheticsEventsProvider and useMultichainEvents to eliminate websocket dependencies. Introduce new metrics for Viem WebSocket client connections and disconnections. Refactor related code for improved clarity and performance.
…eTxn and simulateExecution functions. Introduce getBlockTimestampAndNumber utility for cleaner code and error handling. Update ISigner class to include initialization lock for address resolution.
@midas-myth midas-myth requested a review from divhead January 9, 2026 16:46
@midas-myth
Copy link
Contributor Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!

divhead
divhead previously approved these changes Jan 12, 2026
… for viem errors. Refactor error extraction and decoding logic for improved clarity and maintainability.
…al, enhancing error handling for missing tokens in multichain events.
@midas-myth
Copy link
Contributor Author

@cursor review
especially commits on the last 3 days

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants