@dzapio/sdk 2.0.40 → 2.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +24 -5
- package/dist/index.d.ts +24 -5
- package/dist/index.js +66 -52
- package/dist/index.mjs +66 -52
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
|
-
import { WalletCallReceipt as WalletCallReceipt$1,
|
|
2
|
+
import { WalletCallReceipt as WalletCallReceipt$1, TypedDataDomain, Prettify, WalletClient, TransactionReceipt, ChainFormatters, Chain as Chain$1, Assign } from 'viem';
|
|
3
3
|
import { Signer } from 'ethers';
|
|
4
4
|
import * as viemChains from 'viem/chains';
|
|
5
5
|
import { Chain as Chain$2 } from 'viem/chains';
|
|
@@ -753,7 +753,19 @@ type BtclnTxData = {
|
|
|
753
753
|
paymentRequest: string;
|
|
754
754
|
paymentExpiry: number;
|
|
755
755
|
};
|
|
756
|
-
type
|
|
756
|
+
type HyperLiquidSignTypedData<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
757
|
+
domain: TypedDataDomain;
|
|
758
|
+
types: Record<string, {
|
|
759
|
+
name: string;
|
|
760
|
+
type: string;
|
|
761
|
+
}[]>;
|
|
762
|
+
primaryType: string;
|
|
763
|
+
message: M;
|
|
764
|
+
};
|
|
765
|
+
type HyperLiquidTxData = {
|
|
766
|
+
signTypedData: HyperLiquidSignTypedData[];
|
|
767
|
+
};
|
|
768
|
+
type TxData = EvmTxData | SvmTxData | BtcTxData | BtclnTxData | HyperLiquidTxData;
|
|
757
769
|
type TxRequestData<T> = {
|
|
758
770
|
status: typeof STATUS.success;
|
|
759
771
|
txId: string;
|
|
@@ -921,7 +933,14 @@ type PermitErrorResponse = {
|
|
|
921
933
|
permitType: PermitMode;
|
|
922
934
|
};
|
|
923
935
|
type SignPermitResponse<T extends PermitMode = PermitMode> = T extends typeof PermitTypes.AutoPermit ? PermitSingleResponse | PermitBatchResponse | PermitErrorResponse : T extends typeof PermitTypes.PermitBatchWitnessTransferFrom ? PermitBatchResponse | PermitErrorResponse : PermitSingleResponse | PermitErrorResponse;
|
|
924
|
-
type
|
|
936
|
+
type HyperLiquidBroadcastTxData = {
|
|
937
|
+
message: Record<string, unknown>;
|
|
938
|
+
primaryType: string;
|
|
939
|
+
signatureChainId: number;
|
|
940
|
+
signature: HexString;
|
|
941
|
+
account: HexString;
|
|
942
|
+
};
|
|
943
|
+
type BroadcastTxData = string | HyperLiquidBroadcastTxData[];
|
|
925
944
|
type BroadcastTxParams = {
|
|
926
945
|
txId: string;
|
|
927
946
|
chainId: number;
|
|
@@ -2251,7 +2270,7 @@ declare const hyperliquid: {
|
|
|
2251
2270
|
};
|
|
2252
2271
|
};
|
|
2253
2272
|
ensTlds?: readonly string[] | undefined;
|
|
2254
|
-
id:
|
|
2273
|
+
id: 1337;
|
|
2255
2274
|
name: "Hyperliquid";
|
|
2256
2275
|
nativeCurrency: {
|
|
2257
2276
|
readonly name: "HYPE";
|
|
@@ -2423,4 +2442,4 @@ declare const citrea: {
|
|
|
2423
2442
|
declare const customViemChains: viemChains.Chain[];
|
|
2424
2443
|
declare const viemChainsById: Record<number, viemChains.Chain>;
|
|
2425
2444
|
|
|
2426
|
-
export { type AllowanceType, AllowanceTypes, type ApiRpcResponse, type ApprovalMode, ApprovalModes, type BatchPermitCallbackParams, type BtcTxData, type BtclnTxData, type Chain, type ChainData, type ContractErrorResponse, DZapClient, DZapPermitMode, type DZapTransactionResponse, type EvmTxData, type Fee, type FeeDetails, type GaslessTradeBuildTxnResponse, type HexString, OtherAbis, type ParamQuotes, type PermitMode, PermitTypes, type ProviderDetails, type PsbtInput, type PsbtOutput, type QuoteFilter, QuoteFilters, STATUS, type SVMTxnDetails, Services, type SignPermitResponse, type SignatureCallbackParams, SignatureExpiryInSecs, type SinglePermitCallbackParams, StatusCodes, type StepAction, type SvmTxData, type SwapInfo, SwapInputDataDecoder, type Token, type TokenInfo, type TokenPermitData, type TokenResponse, type TradeBuildTxnRequest, type TradeBuildTxnRequestData, type TradeBuildTxnResponse, type TradeGasBuildTxnResponse, type TradePath, type TradeQuotesRequest, type TradeQuotesRequestData, type TradeQuotesResponse, type TradeStatusResponse, type TradeStep, TxnStatus, type ZapBuildTxnRequest, type ZapBuildTxnResponse, type ZapBundleAction, type ZapBundleRequest, type ZapBundleSrcToken, type ZapBvmTxnDetails, type ZapChains, type ZapEvmTxnDetails, type ZapFee, type ZapIntegratorConfig, type ZapPath, type ZapPathAction, type ZapPathAsset, type ZapPool, type ZapPoolDetails, type ZapPoolDetailsRequest, type ZapPoolsRequest, type ZapPoolsResponse, type ZapPosition, type ZapPositionsRequest, type ZapPositionsResponse, type ZapProviders, type ZapQuoteRequest, type ZapQuoteResponse, type ZapRouteRequestPoolDetails, type ZapRouteRequestPositionDetails, type ZapStatus, type ZapStatusAsset, type ZapStatusRequest, type ZapStatusResponse, type ZapStatusStep, type ZapStep, type ZapTransactionStep, type ZapTxnDetails, type ZapUnderlyingToken, type ZapUnderlyingTokenWithAmount, arthera, astralisTestnet, checkEIP2612PermitSupport, citrea, classifyAddress, contractErrorActions, customViemChains, erc20Functions, extendViemChain, fiveIre, formatToken, getTokensPairKey, hemi, hyperEvm, hyperliquid, pushTestnet, stableChain, tempo, viemChainsById, zapPathAction, zapStepAction };
|
|
2445
|
+
export { type AllowanceType, AllowanceTypes, type ApiRpcResponse, type ApprovalMode, ApprovalModes, type BatchPermitCallbackParams, type BtcTxData, type BtclnTxData, type Chain, type ChainData, type ContractErrorResponse, DZapClient, DZapPermitMode, type DZapTransactionResponse, type EvmTxData, type Fee, type FeeDetails, type GaslessTradeBuildTxnResponse, type HexString, type HyperLiquidTxData, OtherAbis, type ParamQuotes, type PermitMode, PermitTypes, type ProviderDetails, type PsbtInput, type PsbtOutput, type QuoteFilter, QuoteFilters, STATUS, type SVMTxnDetails, Services, type SignPermitResponse, type SignatureCallbackParams, SignatureExpiryInSecs, type SinglePermitCallbackParams, StatusCodes, type StepAction, type SvmTxData, type SwapInfo, SwapInputDataDecoder, type Token, type TokenInfo, type TokenPermitData, type TokenResponse, type TradeBuildTxnRequest, type TradeBuildTxnRequestData, type TradeBuildTxnResponse, type TradeGasBuildTxnResponse, type TradePath, type TradeQuotesRequest, type TradeQuotesRequestData, type TradeQuotesResponse, type TradeStatusResponse, type TradeStep, TxnStatus, type ZapBuildTxnRequest, type ZapBuildTxnResponse, type ZapBundleAction, type ZapBundleRequest, type ZapBundleSrcToken, type ZapBvmTxnDetails, type ZapChains, type ZapEvmTxnDetails, type ZapFee, type ZapIntegratorConfig, type ZapPath, type ZapPathAction, type ZapPathAsset, type ZapPool, type ZapPoolDetails, type ZapPoolDetailsRequest, type ZapPoolsRequest, type ZapPoolsResponse, type ZapPosition, type ZapPositionsRequest, type ZapPositionsResponse, type ZapProviders, type ZapQuoteRequest, type ZapQuoteResponse, type ZapRouteRequestPoolDetails, type ZapRouteRequestPositionDetails, type ZapStatus, type ZapStatusAsset, type ZapStatusRequest, type ZapStatusResponse, type ZapStatusStep, type ZapStep, type ZapTransactionStep, type ZapTxnDetails, type ZapUnderlyingToken, type ZapUnderlyingTokenWithAmount, arthera, astralisTestnet, checkEIP2612PermitSupport, citrea, classifyAddress, contractErrorActions, customViemChains, erc20Functions, extendViemChain, fiveIre, formatToken, getTokensPairKey, hemi, hyperEvm, hyperliquid, pushTestnet, stableChain, tempo, viemChainsById, zapPathAction, zapStepAction };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
|
-
import { WalletCallReceipt as WalletCallReceipt$1,
|
|
2
|
+
import { WalletCallReceipt as WalletCallReceipt$1, TypedDataDomain, Prettify, WalletClient, TransactionReceipt, ChainFormatters, Chain as Chain$1, Assign } from 'viem';
|
|
3
3
|
import { Signer } from 'ethers';
|
|
4
4
|
import * as viemChains from 'viem/chains';
|
|
5
5
|
import { Chain as Chain$2 } from 'viem/chains';
|
|
@@ -753,7 +753,19 @@ type BtclnTxData = {
|
|
|
753
753
|
paymentRequest: string;
|
|
754
754
|
paymentExpiry: number;
|
|
755
755
|
};
|
|
756
|
-
type
|
|
756
|
+
type HyperLiquidSignTypedData<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
757
|
+
domain: TypedDataDomain;
|
|
758
|
+
types: Record<string, {
|
|
759
|
+
name: string;
|
|
760
|
+
type: string;
|
|
761
|
+
}[]>;
|
|
762
|
+
primaryType: string;
|
|
763
|
+
message: M;
|
|
764
|
+
};
|
|
765
|
+
type HyperLiquidTxData = {
|
|
766
|
+
signTypedData: HyperLiquidSignTypedData[];
|
|
767
|
+
};
|
|
768
|
+
type TxData = EvmTxData | SvmTxData | BtcTxData | BtclnTxData | HyperLiquidTxData;
|
|
757
769
|
type TxRequestData<T> = {
|
|
758
770
|
status: typeof STATUS.success;
|
|
759
771
|
txId: string;
|
|
@@ -921,7 +933,14 @@ type PermitErrorResponse = {
|
|
|
921
933
|
permitType: PermitMode;
|
|
922
934
|
};
|
|
923
935
|
type SignPermitResponse<T extends PermitMode = PermitMode> = T extends typeof PermitTypes.AutoPermit ? PermitSingleResponse | PermitBatchResponse | PermitErrorResponse : T extends typeof PermitTypes.PermitBatchWitnessTransferFrom ? PermitBatchResponse | PermitErrorResponse : PermitSingleResponse | PermitErrorResponse;
|
|
924
|
-
type
|
|
936
|
+
type HyperLiquidBroadcastTxData = {
|
|
937
|
+
message: Record<string, unknown>;
|
|
938
|
+
primaryType: string;
|
|
939
|
+
signatureChainId: number;
|
|
940
|
+
signature: HexString;
|
|
941
|
+
account: HexString;
|
|
942
|
+
};
|
|
943
|
+
type BroadcastTxData = string | HyperLiquidBroadcastTxData[];
|
|
925
944
|
type BroadcastTxParams = {
|
|
926
945
|
txId: string;
|
|
927
946
|
chainId: number;
|
|
@@ -2251,7 +2270,7 @@ declare const hyperliquid: {
|
|
|
2251
2270
|
};
|
|
2252
2271
|
};
|
|
2253
2272
|
ensTlds?: readonly string[] | undefined;
|
|
2254
|
-
id:
|
|
2273
|
+
id: 1337;
|
|
2255
2274
|
name: "Hyperliquid";
|
|
2256
2275
|
nativeCurrency: {
|
|
2257
2276
|
readonly name: "HYPE";
|
|
@@ -2423,4 +2442,4 @@ declare const citrea: {
|
|
|
2423
2442
|
declare const customViemChains: viemChains.Chain[];
|
|
2424
2443
|
declare const viemChainsById: Record<number, viemChains.Chain>;
|
|
2425
2444
|
|
|
2426
|
-
export { type AllowanceType, AllowanceTypes, type ApiRpcResponse, type ApprovalMode, ApprovalModes, type BatchPermitCallbackParams, type BtcTxData, type BtclnTxData, type Chain, type ChainData, type ContractErrorResponse, DZapClient, DZapPermitMode, type DZapTransactionResponse, type EvmTxData, type Fee, type FeeDetails, type GaslessTradeBuildTxnResponse, type HexString, OtherAbis, type ParamQuotes, type PermitMode, PermitTypes, type ProviderDetails, type PsbtInput, type PsbtOutput, type QuoteFilter, QuoteFilters, STATUS, type SVMTxnDetails, Services, type SignPermitResponse, type SignatureCallbackParams, SignatureExpiryInSecs, type SinglePermitCallbackParams, StatusCodes, type StepAction, type SvmTxData, type SwapInfo, SwapInputDataDecoder, type Token, type TokenInfo, type TokenPermitData, type TokenResponse, type TradeBuildTxnRequest, type TradeBuildTxnRequestData, type TradeBuildTxnResponse, type TradeGasBuildTxnResponse, type TradePath, type TradeQuotesRequest, type TradeQuotesRequestData, type TradeQuotesResponse, type TradeStatusResponse, type TradeStep, TxnStatus, type ZapBuildTxnRequest, type ZapBuildTxnResponse, type ZapBundleAction, type ZapBundleRequest, type ZapBundleSrcToken, type ZapBvmTxnDetails, type ZapChains, type ZapEvmTxnDetails, type ZapFee, type ZapIntegratorConfig, type ZapPath, type ZapPathAction, type ZapPathAsset, type ZapPool, type ZapPoolDetails, type ZapPoolDetailsRequest, type ZapPoolsRequest, type ZapPoolsResponse, type ZapPosition, type ZapPositionsRequest, type ZapPositionsResponse, type ZapProviders, type ZapQuoteRequest, type ZapQuoteResponse, type ZapRouteRequestPoolDetails, type ZapRouteRequestPositionDetails, type ZapStatus, type ZapStatusAsset, type ZapStatusRequest, type ZapStatusResponse, type ZapStatusStep, type ZapStep, type ZapTransactionStep, type ZapTxnDetails, type ZapUnderlyingToken, type ZapUnderlyingTokenWithAmount, arthera, astralisTestnet, checkEIP2612PermitSupport, citrea, classifyAddress, contractErrorActions, customViemChains, erc20Functions, extendViemChain, fiveIre, formatToken, getTokensPairKey, hemi, hyperEvm, hyperliquid, pushTestnet, stableChain, tempo, viemChainsById, zapPathAction, zapStepAction };
|
|
2445
|
+
export { type AllowanceType, AllowanceTypes, type ApiRpcResponse, type ApprovalMode, ApprovalModes, type BatchPermitCallbackParams, type BtcTxData, type BtclnTxData, type Chain, type ChainData, type ContractErrorResponse, DZapClient, DZapPermitMode, type DZapTransactionResponse, type EvmTxData, type Fee, type FeeDetails, type GaslessTradeBuildTxnResponse, type HexString, type HyperLiquidTxData, OtherAbis, type ParamQuotes, type PermitMode, PermitTypes, type ProviderDetails, type PsbtInput, type PsbtOutput, type QuoteFilter, QuoteFilters, STATUS, type SVMTxnDetails, Services, type SignPermitResponse, type SignatureCallbackParams, SignatureExpiryInSecs, type SinglePermitCallbackParams, StatusCodes, type StepAction, type SvmTxData, type SwapInfo, SwapInputDataDecoder, type Token, type TokenInfo, type TokenPermitData, type TokenResponse, type TradeBuildTxnRequest, type TradeBuildTxnRequestData, type TradeBuildTxnResponse, type TradeGasBuildTxnResponse, type TradePath, type TradeQuotesRequest, type TradeQuotesRequestData, type TradeQuotesResponse, type TradeStatusResponse, type TradeStep, TxnStatus, type ZapBuildTxnRequest, type ZapBuildTxnResponse, type ZapBundleAction, type ZapBundleRequest, type ZapBundleSrcToken, type ZapBvmTxnDetails, type ZapChains, type ZapEvmTxnDetails, type ZapFee, type ZapIntegratorConfig, type ZapPath, type ZapPathAction, type ZapPathAsset, type ZapPool, type ZapPoolDetails, type ZapPoolDetailsRequest, type ZapPoolsRequest, type ZapPoolsResponse, type ZapPosition, type ZapPositionsRequest, type ZapPositionsResponse, type ZapProviders, type ZapQuoteRequest, type ZapQuoteResponse, type ZapRouteRequestPoolDetails, type ZapRouteRequestPositionDetails, type ZapStatus, type ZapStatusAsset, type ZapStatusRequest, type ZapStatusResponse, type ZapStatusStep, type ZapStep, type ZapTransactionStep, type ZapTxnDetails, type ZapUnderlyingToken, type ZapUnderlyingTokenWithAmount, arthera, astralisTestnet, checkEIP2612PermitSupport, citrea, classifyAddress, contractErrorActions, customViemChains, erc20Functions, extendViemChain, fiveIre, formatToken, getTokensPairKey, hemi, hyperEvm, hyperliquid, pushTestnet, stableChain, tempo, viemChainsById, zapPathAction, zapStepAction };
|
package/dist/index.js
CHANGED
|
@@ -10725,7 +10725,7 @@ var hyperEvm = /* @__PURE__ */ viem.defineChain({
|
|
|
10725
10725
|
}
|
|
10726
10726
|
});
|
|
10727
10727
|
var hyperliquid = /* @__PURE__ */ viem.defineChain({
|
|
10728
|
-
id:
|
|
10728
|
+
id: 1337,
|
|
10729
10729
|
name: "Hyperliquid",
|
|
10730
10730
|
nativeCurrency: { name: "HYPE", symbol: "HYPE", decimals: 18 },
|
|
10731
10731
|
contracts: {
|
|
@@ -12886,7 +12886,7 @@ var exclusiveChainIds = {
|
|
|
12886
12886
|
abstract: 2741,
|
|
12887
12887
|
lens: 232,
|
|
12888
12888
|
citreaTestnet: 5115,
|
|
12889
|
-
hyperLiquid:
|
|
12889
|
+
hyperLiquid: 1337,
|
|
12890
12890
|
citrea: 4114,
|
|
12891
12891
|
pushTestnet: 42101,
|
|
12892
12892
|
astralisTestnet: 71261,
|
|
@@ -14769,6 +14769,61 @@ var signCustomTypedData = async (params) => {
|
|
|
14769
14769
|
}
|
|
14770
14770
|
};
|
|
14771
14771
|
|
|
14772
|
+
// src/transactionHandlers/hyperliquid.ts
|
|
14773
|
+
var HyperLiquidTxHandler = class {
|
|
14774
|
+
};
|
|
14775
|
+
HyperLiquidTxHandler.sendTransaction = async (signer, account, txnData, chainId, additionalInfo, updatedQuotes) => {
|
|
14776
|
+
var _a;
|
|
14777
|
+
const signTypedData2 = "signTypedData" in txnData.transaction ? txnData.transaction.signTypedData : null;
|
|
14778
|
+
if (!signTypedData2) {
|
|
14779
|
+
return {
|
|
14780
|
+
status: "error" /* error */,
|
|
14781
|
+
errorMsg: "Missing typed data for HyperLiquid transaction",
|
|
14782
|
+
code: 500 /* Error */
|
|
14783
|
+
};
|
|
14784
|
+
}
|
|
14785
|
+
const txData = [];
|
|
14786
|
+
for (let i = 0; i < signTypedData2.length; i++) {
|
|
14787
|
+
const typedData = signTypedData2[i];
|
|
14788
|
+
const [resp, signatureChainId] = await Promise.all([
|
|
14789
|
+
signCustomTypedData({
|
|
14790
|
+
signer,
|
|
14791
|
+
account,
|
|
14792
|
+
domain: typedData.domain,
|
|
14793
|
+
types: typedData.types,
|
|
14794
|
+
message: typedData.message,
|
|
14795
|
+
primaryType: typedData.primaryType
|
|
14796
|
+
}),
|
|
14797
|
+
signer.getChainId()
|
|
14798
|
+
]);
|
|
14799
|
+
if (resp.status !== "success" /* success */ || !((_a = resp.data) == null ? void 0 : _a.signature)) {
|
|
14800
|
+
throw new Error("Failed to sign transaction");
|
|
14801
|
+
}
|
|
14802
|
+
txData.push({
|
|
14803
|
+
primaryType: typedData.primaryType,
|
|
14804
|
+
message: typedData.message,
|
|
14805
|
+
signature: resp.data.signature,
|
|
14806
|
+
account,
|
|
14807
|
+
signatureChainId
|
|
14808
|
+
});
|
|
14809
|
+
}
|
|
14810
|
+
const txResp = await broadcastTradeTx({
|
|
14811
|
+
chainId,
|
|
14812
|
+
txData,
|
|
14813
|
+
txId: txnData.txId
|
|
14814
|
+
});
|
|
14815
|
+
if (txResp.status !== "success" /* success */) {
|
|
14816
|
+
throw new Error("Failed to broadcast or save transaction");
|
|
14817
|
+
}
|
|
14818
|
+
return {
|
|
14819
|
+
status: "success" /* success */,
|
|
14820
|
+
code: 200 /* Success */,
|
|
14821
|
+
txnHash: txResp.txnHash,
|
|
14822
|
+
additionalInfo,
|
|
14823
|
+
updatedQuotes
|
|
14824
|
+
};
|
|
14825
|
+
};
|
|
14826
|
+
|
|
14772
14827
|
// src/transactionHandlers/trade.ts
|
|
14773
14828
|
var _TradeTxnHandler = class _TradeTxnHandler {
|
|
14774
14829
|
};
|
|
@@ -14842,54 +14897,6 @@ _TradeTxnHandler.sendTxnWithBatch = async (request, signer, txnParams, chainId,
|
|
|
14842
14897
|
updatedQuotes
|
|
14843
14898
|
};
|
|
14844
14899
|
};
|
|
14845
|
-
_TradeTxnHandler.sendHyperLiquidTransaction = async (signer, txnParams, txnData, chainId, additionalInfo, updatedQuotes) => {
|
|
14846
|
-
var _a;
|
|
14847
|
-
let txnDetails;
|
|
14848
|
-
if (chainId === exclusiveChainIds.hyperLiquid) {
|
|
14849
|
-
const providerData = additionalInfo ? Object.values(additionalInfo)[0] : null;
|
|
14850
|
-
const typedData = providerData && "typedData" in providerData ? providerData.typedData : null;
|
|
14851
|
-
if (!additionalInfo || !typedData) {
|
|
14852
|
-
return {
|
|
14853
|
-
status: "error" /* error */,
|
|
14854
|
-
errorMsg: "Missing additional info for HyperLiquid transaction",
|
|
14855
|
-
code: 500 /* Error */
|
|
14856
|
-
};
|
|
14857
|
-
}
|
|
14858
|
-
const resp = await signCustomTypedData({
|
|
14859
|
-
signer,
|
|
14860
|
-
account: txnParams.from,
|
|
14861
|
-
domain: typedData.domain,
|
|
14862
|
-
types: typedData.types,
|
|
14863
|
-
message: typedData.message,
|
|
14864
|
-
primaryType: typedData.primaryType
|
|
14865
|
-
});
|
|
14866
|
-
if (resp.status !== "success" /* success */) {
|
|
14867
|
-
throw new Error("Failed to sign transaction");
|
|
14868
|
-
}
|
|
14869
|
-
txnDetails = (_a = resp.data) == null ? void 0 : _a.signature;
|
|
14870
|
-
} else {
|
|
14871
|
-
const resp = await _TradeTxnHandler.sendTransaction(signer, txnParams, chainId, additionalInfo, updatedQuotes);
|
|
14872
|
-
if (resp.status !== "success" /* success */) {
|
|
14873
|
-
throw new Error("Failed to sign transaction");
|
|
14874
|
-
}
|
|
14875
|
-
txnDetails = resp.txnHash;
|
|
14876
|
-
}
|
|
14877
|
-
const txResp = await broadcastTradeTx({
|
|
14878
|
-
chainId,
|
|
14879
|
-
txData: txnDetails,
|
|
14880
|
-
txId: txnData.txId
|
|
14881
|
-
});
|
|
14882
|
-
if (txResp.status !== "success" /* success */) {
|
|
14883
|
-
throw new Error("Failed to broadcast or save transaction");
|
|
14884
|
-
}
|
|
14885
|
-
return {
|
|
14886
|
-
status: "success" /* success */,
|
|
14887
|
-
code: 200 /* Success */,
|
|
14888
|
-
txnHash: txResp.txnHash,
|
|
14889
|
-
additionalInfo,
|
|
14890
|
-
updatedQuotes
|
|
14891
|
-
};
|
|
14892
|
-
};
|
|
14893
14900
|
_TradeTxnHandler.buildAndSendTransaction = async ({
|
|
14894
14901
|
request,
|
|
14895
14902
|
signer,
|
|
@@ -14909,8 +14916,15 @@ _TradeTxnHandler.buildAndSendTransaction = async ({
|
|
|
14909
14916
|
}
|
|
14910
14917
|
const { data, from, to, value, gasLimit, additionalInfo, updatedQuotes } = buildTxnResponseData;
|
|
14911
14918
|
const txnParams = { from, to, data, value, gasLimit };
|
|
14912
|
-
if (
|
|
14913
|
-
return
|
|
14919
|
+
if (chainId === exclusiveChainIds.hyperLiquid) {
|
|
14920
|
+
return HyperLiquidTxHandler.sendTransaction(
|
|
14921
|
+
signer,
|
|
14922
|
+
txnParams.from,
|
|
14923
|
+
buildTxnResponseData,
|
|
14924
|
+
chainId,
|
|
14925
|
+
additionalInfo,
|
|
14926
|
+
updatedQuotes
|
|
14927
|
+
);
|
|
14914
14928
|
}
|
|
14915
14929
|
if (batchTransaction && !isTypeSigner(signer)) {
|
|
14916
14930
|
return _TradeTxnHandler.sendTxnWithBatch(request, signer, txnParams, chainId, additionalInfo, updatedQuotes, multicallAddress, rpcUrls);
|
package/dist/index.mjs
CHANGED
|
@@ -10699,7 +10699,7 @@ var hyperEvm = /* @__PURE__ */ defineChain({
|
|
|
10699
10699
|
}
|
|
10700
10700
|
});
|
|
10701
10701
|
var hyperliquid = /* @__PURE__ */ defineChain({
|
|
10702
|
-
id:
|
|
10702
|
+
id: 1337,
|
|
10703
10703
|
name: "Hyperliquid",
|
|
10704
10704
|
nativeCurrency: { name: "HYPE", symbol: "HYPE", decimals: 18 },
|
|
10705
10705
|
contracts: {
|
|
@@ -12860,7 +12860,7 @@ var exclusiveChainIds = {
|
|
|
12860
12860
|
abstract: 2741,
|
|
12861
12861
|
lens: 232,
|
|
12862
12862
|
citreaTestnet: 5115,
|
|
12863
|
-
hyperLiquid:
|
|
12863
|
+
hyperLiquid: 1337,
|
|
12864
12864
|
citrea: 4114,
|
|
12865
12865
|
pushTestnet: 42101,
|
|
12866
12866
|
astralisTestnet: 71261,
|
|
@@ -14743,6 +14743,61 @@ var signCustomTypedData = async (params) => {
|
|
|
14743
14743
|
}
|
|
14744
14744
|
};
|
|
14745
14745
|
|
|
14746
|
+
// src/transactionHandlers/hyperliquid.ts
|
|
14747
|
+
var HyperLiquidTxHandler = class {
|
|
14748
|
+
};
|
|
14749
|
+
HyperLiquidTxHandler.sendTransaction = async (signer, account, txnData, chainId, additionalInfo, updatedQuotes) => {
|
|
14750
|
+
var _a;
|
|
14751
|
+
const signTypedData2 = "signTypedData" in txnData.transaction ? txnData.transaction.signTypedData : null;
|
|
14752
|
+
if (!signTypedData2) {
|
|
14753
|
+
return {
|
|
14754
|
+
status: "error" /* error */,
|
|
14755
|
+
errorMsg: "Missing typed data for HyperLiquid transaction",
|
|
14756
|
+
code: 500 /* Error */
|
|
14757
|
+
};
|
|
14758
|
+
}
|
|
14759
|
+
const txData = [];
|
|
14760
|
+
for (let i = 0; i < signTypedData2.length; i++) {
|
|
14761
|
+
const typedData = signTypedData2[i];
|
|
14762
|
+
const [resp, signatureChainId] = await Promise.all([
|
|
14763
|
+
signCustomTypedData({
|
|
14764
|
+
signer,
|
|
14765
|
+
account,
|
|
14766
|
+
domain: typedData.domain,
|
|
14767
|
+
types: typedData.types,
|
|
14768
|
+
message: typedData.message,
|
|
14769
|
+
primaryType: typedData.primaryType
|
|
14770
|
+
}),
|
|
14771
|
+
signer.getChainId()
|
|
14772
|
+
]);
|
|
14773
|
+
if (resp.status !== "success" /* success */ || !((_a = resp.data) == null ? void 0 : _a.signature)) {
|
|
14774
|
+
throw new Error("Failed to sign transaction");
|
|
14775
|
+
}
|
|
14776
|
+
txData.push({
|
|
14777
|
+
primaryType: typedData.primaryType,
|
|
14778
|
+
message: typedData.message,
|
|
14779
|
+
signature: resp.data.signature,
|
|
14780
|
+
account,
|
|
14781
|
+
signatureChainId
|
|
14782
|
+
});
|
|
14783
|
+
}
|
|
14784
|
+
const txResp = await broadcastTradeTx({
|
|
14785
|
+
chainId,
|
|
14786
|
+
txData,
|
|
14787
|
+
txId: txnData.txId
|
|
14788
|
+
});
|
|
14789
|
+
if (txResp.status !== "success" /* success */) {
|
|
14790
|
+
throw new Error("Failed to broadcast or save transaction");
|
|
14791
|
+
}
|
|
14792
|
+
return {
|
|
14793
|
+
status: "success" /* success */,
|
|
14794
|
+
code: 200 /* Success */,
|
|
14795
|
+
txnHash: txResp.txnHash,
|
|
14796
|
+
additionalInfo,
|
|
14797
|
+
updatedQuotes
|
|
14798
|
+
};
|
|
14799
|
+
};
|
|
14800
|
+
|
|
14746
14801
|
// src/transactionHandlers/trade.ts
|
|
14747
14802
|
var _TradeTxnHandler = class _TradeTxnHandler {
|
|
14748
14803
|
};
|
|
@@ -14816,54 +14871,6 @@ _TradeTxnHandler.sendTxnWithBatch = async (request, signer, txnParams, chainId,
|
|
|
14816
14871
|
updatedQuotes
|
|
14817
14872
|
};
|
|
14818
14873
|
};
|
|
14819
|
-
_TradeTxnHandler.sendHyperLiquidTransaction = async (signer, txnParams, txnData, chainId, additionalInfo, updatedQuotes) => {
|
|
14820
|
-
var _a;
|
|
14821
|
-
let txnDetails;
|
|
14822
|
-
if (chainId === exclusiveChainIds.hyperLiquid) {
|
|
14823
|
-
const providerData = additionalInfo ? Object.values(additionalInfo)[0] : null;
|
|
14824
|
-
const typedData = providerData && "typedData" in providerData ? providerData.typedData : null;
|
|
14825
|
-
if (!additionalInfo || !typedData) {
|
|
14826
|
-
return {
|
|
14827
|
-
status: "error" /* error */,
|
|
14828
|
-
errorMsg: "Missing additional info for HyperLiquid transaction",
|
|
14829
|
-
code: 500 /* Error */
|
|
14830
|
-
};
|
|
14831
|
-
}
|
|
14832
|
-
const resp = await signCustomTypedData({
|
|
14833
|
-
signer,
|
|
14834
|
-
account: txnParams.from,
|
|
14835
|
-
domain: typedData.domain,
|
|
14836
|
-
types: typedData.types,
|
|
14837
|
-
message: typedData.message,
|
|
14838
|
-
primaryType: typedData.primaryType
|
|
14839
|
-
});
|
|
14840
|
-
if (resp.status !== "success" /* success */) {
|
|
14841
|
-
throw new Error("Failed to sign transaction");
|
|
14842
|
-
}
|
|
14843
|
-
txnDetails = (_a = resp.data) == null ? void 0 : _a.signature;
|
|
14844
|
-
} else {
|
|
14845
|
-
const resp = await _TradeTxnHandler.sendTransaction(signer, txnParams, chainId, additionalInfo, updatedQuotes);
|
|
14846
|
-
if (resp.status !== "success" /* success */) {
|
|
14847
|
-
throw new Error("Failed to sign transaction");
|
|
14848
|
-
}
|
|
14849
|
-
txnDetails = resp.txnHash;
|
|
14850
|
-
}
|
|
14851
|
-
const txResp = await broadcastTradeTx({
|
|
14852
|
-
chainId,
|
|
14853
|
-
txData: txnDetails,
|
|
14854
|
-
txId: txnData.txId
|
|
14855
|
-
});
|
|
14856
|
-
if (txResp.status !== "success" /* success */) {
|
|
14857
|
-
throw new Error("Failed to broadcast or save transaction");
|
|
14858
|
-
}
|
|
14859
|
-
return {
|
|
14860
|
-
status: "success" /* success */,
|
|
14861
|
-
code: 200 /* Success */,
|
|
14862
|
-
txnHash: txResp.txnHash,
|
|
14863
|
-
additionalInfo,
|
|
14864
|
-
updatedQuotes
|
|
14865
|
-
};
|
|
14866
|
-
};
|
|
14867
14874
|
_TradeTxnHandler.buildAndSendTransaction = async ({
|
|
14868
14875
|
request,
|
|
14869
14876
|
signer,
|
|
@@ -14883,8 +14890,15 @@ _TradeTxnHandler.buildAndSendTransaction = async ({
|
|
|
14883
14890
|
}
|
|
14884
14891
|
const { data, from, to, value, gasLimit, additionalInfo, updatedQuotes } = buildTxnResponseData;
|
|
14885
14892
|
const txnParams = { from, to, data, value, gasLimit };
|
|
14886
|
-
if (
|
|
14887
|
-
return
|
|
14893
|
+
if (chainId === exclusiveChainIds.hyperLiquid) {
|
|
14894
|
+
return HyperLiquidTxHandler.sendTransaction(
|
|
14895
|
+
signer,
|
|
14896
|
+
txnParams.from,
|
|
14897
|
+
buildTxnResponseData,
|
|
14898
|
+
chainId,
|
|
14899
|
+
additionalInfo,
|
|
14900
|
+
updatedQuotes
|
|
14901
|
+
);
|
|
14888
14902
|
}
|
|
14889
14903
|
if (batchTransaction && !isTypeSigner(signer)) {
|
|
14890
14904
|
return _TradeTxnHandler.sendTxnWithBatch(request, signer, txnParams, chainId, additionalInfo, updatedQuotes, multicallAddress, rpcUrls);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dzapio/sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.41",
|
|
4
4
|
"description": "A TypeScript/JavaScript SDK for interacting with the DZap protocol, providing utilities for DeFi operations including Swaps, Bridges, and Zaps.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"source": "src/index.ts",
|