Skip to content

Commit ccc0a8a

Browse files
committed
chore: addressing pr feedback
1 parent dab2e95 commit ccc0a8a

File tree

7 files changed

+25
-35
lines changed

7 files changed

+25
-35
lines changed

packages/apps/ability-hyperliquid/src/generated/lit-action.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"ipfsCid": "QmQtGCkrvTJsLvvLvZWFhtrschv7N3SDC3nMzFQY95pkt1"
2+
"ipfsCid": "QmaGop5dGvYeGpLd19FPH2i8fDqnHAHSgzyuhmetUqmU3C"
33
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const getHyperliquidChainId = (useTestnet: boolean): string => {
2+
// Select chain ID and network based on testnet flag
3+
return useTestnet
4+
? '0x66eee' // Arbitrum Sepolia testnet chain ID: 421614
5+
: '0xa4b1'; // Arbitrum mainnet chain ID: 42161
6+
};
7+
8+
export const getHyperliquidChainName = (useTestnet: boolean): string => {
9+
return useTestnet ? 'Testnet' : 'Mainnet';
10+
};

packages/apps/ability-hyperliquid/src/lib/ability-helpers/send-perp-usdc.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { bigIntReplacer } from '@lit-protocol/vincent-ability-sdk';
1111

1212
import { LitActionPkpEthersWallet } from './lit-action-pkp-ethers-wallet';
1313
import { getHyperliquidNonce } from './get-hyperliquid-nonce';
14+
import { getHyperliquidChainId, getHyperliquidChainName } from './get-hyperliquid-chain-id';
1415

1516
export type SendPerpUsdcResult = {
1617
sendResult: SuccessResponse;
@@ -35,18 +36,12 @@ export async function sendPerpUsdc({
3536
const pkpWallet = new LitActionPkpEthersWallet(pkpPublicKey);
3637
const nonce = await getHyperliquidNonce();
3738

38-
// Select chain ID and network based on testnet flag
39-
const signatureChainId = useTestnet
40-
? '0x66eee' // Arbitrum Sepolia testnet chain ID: 421614
41-
: '0xa4b1'; // Arbitrum mainnet chain ID: 42161
42-
const hyperliquidChain = useTestnet ? 'Testnet' : 'Mainnet';
43-
4439
// Construct send action
4540
// UsdSend uses standard 6 decimals for USDC (not Hyperliquid's 8 decimal precision)
4641
const sendAction = parser(UsdSendRequest.entries.action)({
4742
type: 'usdSend',
48-
signatureChainId,
49-
hyperliquidChain,
43+
signatureChainId: getHyperliquidChainId(useTestnet),
44+
hyperliquidChain: getHyperliquidChainName(useTestnet),
5045
destination,
5146
// Convert amount from micro-units (6 decimals) to human-readable format
5247
// e.g., "1000000" -> "1.0"

packages/apps/ability-hyperliquid/src/lib/ability-helpers/send-spot-asset.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { bigIntReplacer } from '@lit-protocol/vincent-ability-sdk';
1111

1212
import { LitActionPkpEthersWallet } from './lit-action-pkp-ethers-wallet';
1313
import { getHyperliquidNonce } from './get-hyperliquid-nonce';
14+
import { getHyperliquidChainId, getHyperliquidChainName } from './get-hyperliquid-chain-id';
1415

1516
export type SendSpotAssetResult = {
1617
sendResult: SuccessResponse;
@@ -48,17 +49,11 @@ export async function sendSpotAsset({
4849
}
4950
console.log('[sendAsset] Token info:', tokenInfo);
5051

51-
// Select chain ID and network based on testnet flag
52-
const signatureChainId = useTestnet
53-
? '0x66eee' // Arbitrum Sepolia testnet chain ID: 421614
54-
: '0xa4b1'; // Arbitrum mainnet chain ID: 42161
55-
const hyperliquidChain = useTestnet ? 'Testnet' : 'Mainnet';
56-
5752
// Construct send action
5853
const sendAction = parser(SpotSendRequest.entries.action)({
5954
type: 'spotSend',
60-
signatureChainId,
61-
hyperliquidChain,
55+
signatureChainId: getHyperliquidChainId(useTestnet),
56+
hyperliquidChain: getHyperliquidChainName(useTestnet),
6257
destination,
6358
// Construct token identifier in the format expected by SpotSend: "name:0xaddress"
6459
token: `${tokenInfo.name}:${tokenInfo.tokenId}`,

packages/apps/ability-hyperliquid/src/lib/ability-helpers/transfer-usdc-to.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { bigIntReplacer } from '@lit-protocol/vincent-ability-sdk';
1111

1212
import { LitActionPkpEthersWallet } from './lit-action-pkp-ethers-wallet';
1313
import { getHyperliquidNonce } from './get-hyperliquid-nonce';
14+
import { getHyperliquidChainId, getHyperliquidChainName } from './get-hyperliquid-chain-id';
1415

1516
export type TransferUsdcResult = {
1617
transferResult: SuccessResponse;
@@ -40,19 +41,13 @@ export async function transferUsdcTo({
4041

4142
const nonce = await getHyperliquidNonce();
4243

43-
// Select chain ID and network based on testnet flag
44-
const signatureChainId = useTestnet
45-
? '0x66eee' // Arbitrum Sepolia testnet chain ID: 421614
46-
: '0xa4b1'; // Arbitrum mainnet chain ID: 42161
47-
const hyperliquidChain = useTestnet ? 'Testnet' : 'Mainnet';
48-
4944
const transferAction = parser(UsdClassTransferRequest.entries.action)({
5045
type: 'usdClassTransfer',
5146
// Convert amount from raw units (e.g., "1000000" for 1.0 USDC) to formatted string (e.g., "1.0")
5247
// Hyperliquid expects the amount as a string in human-readable format
5348
amount: ethers.utils.formatUnits(amount, 6),
54-
signatureChainId,
55-
hyperliquidChain,
49+
signatureChainId: getHyperliquidChainId(useTestnet),
50+
hyperliquidChain: getHyperliquidChainName(useTestnet),
5651
toPerp: to === 'perp',
5752
nonce,
5853
});

packages/apps/ability-hyperliquid/src/lib/ability-helpers/withdraw-usdc.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { bigIntReplacer } from '@lit-protocol/vincent-ability-sdk';
1111

1212
import { LitActionPkpEthersWallet } from './lit-action-pkp-ethers-wallet';
1313
import { getHyperliquidNonce } from './get-hyperliquid-nonce';
14+
import { getHyperliquidChainId, getHyperliquidChainName } from './get-hyperliquid-chain-id';
1415

1516
export type WithdrawUsdcResult = {
1617
withdrawResult: SuccessResponse;
@@ -36,17 +37,11 @@ export async function withdrawUsdc({
3637
const pkpWallet = new LitActionPkpEthersWallet(pkpPublicKey);
3738
const nonce = await getHyperliquidNonce();
3839

39-
// Select chain ID and network based on testnet flag
40-
const signatureChainId = useTestnet
41-
? '0x66eee' // Arbitrum Sepolia testnet chain ID: 421614
42-
: '0xa4b1'; // Arbitrum mainnet chain ID: 42161
43-
const hyperliquidChain = useTestnet ? 'Testnet' : 'Mainnet';
44-
4540
// Construct withdraw action
4641
const withdrawAction = parser(Withdraw3Request.entries.action)({
4742
type: 'withdraw3',
48-
signatureChainId,
49-
hyperliquidChain,
43+
signatureChainId: getHyperliquidChainId(useTestnet),
44+
hyperliquidChain: getHyperliquidChainName(useTestnet),
5045
destination,
5146
// Convert amount from raw units (e.g., "1000000" for 1.0 USDC) to formatted string (e.g., "1.0")
5247
// Hyperliquid expects the amount as a string in human-readable format

0 commit comments

Comments
 (0)