@ambitlabs/hyperliquid-sdk
Advanced tools
Comparing version
import { HyperliquidEnvironment } from './constants'; | ||
import { Signature, Signer } from './Signer'; | ||
import { Signer, Signature } from './Signer'; | ||
export type ActionResponse<TResponse extends any = { | ||
@@ -4,0 +4,0 @@ type: 'default'; |
@@ -1,5 +0,5 @@ | ||
import { Signer as EthersSigner } from 'ethers'; | ||
import { ExchangeEndpoint, HyperliquidAction, SpotDeployAction } from './ExchangeEndpoint'; | ||
import { AllMidsResponse, ClearingHouseStateResponse, InfoEndpoint, SpotMetaResponse, VaultDetailsResponse } from './InfoEndpoint'; | ||
import { Price } from './Price'; | ||
import { TypedDataSigner } from './Signer'; | ||
import { Size } from './Size'; | ||
@@ -46,6 +46,6 @@ import { HyperliquidEnvironment } from './constants'; | ||
readonly environment: HyperliquidEnvironment; | ||
readonly signer?: EthersSigner | undefined; | ||
readonly signer?: TypedDataSigner | undefined; | ||
readonly exchange: ExchangeEndpoint | undefined; | ||
readonly info: InfoEndpoint; | ||
constructor(environment: HyperliquidEnvironment, signer?: EthersSigner | undefined); | ||
constructor(environment: HyperliquidEnvironment, signer?: TypedDataSigner | undefined); | ||
fetchSpotMeta(): Promise<SpotMetaResponse>; | ||
@@ -52,0 +52,0 @@ fetchSpotTokens(): Promise<Record<string, { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HyperliquidSDK = void 0; | ||
const Signer_1 = require("./Signer"); | ||
const ExchangeEndpoint_1 = require("./ExchangeEndpoint"); | ||
const InfoEndpoint_1 = require("./InfoEndpoint"); | ||
const Signer_1 = require("./Signer"); | ||
const constants_1 = require("./constants"); | ||
@@ -8,0 +8,0 @@ class HyperliquidSDK { |
@@ -1,3 +0,7 @@ | ||
import { TypedDataDomain, TypedDataField, Signer as EthersSigner } from 'ethers'; | ||
import { TypedDataDomain, TypedDataField } from 'ethers'; | ||
import { HyperliquidEnvironment } from './constants'; | ||
type TypedDataSignerAction = (domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, values: Record<string, any>) => Promise<string>; | ||
export type TypedDataSigner = { | ||
signTypedData: TypedDataSignerAction; | ||
} | TypedDataSignerAction; | ||
export type Signature = { | ||
@@ -9,5 +13,5 @@ r: string; | ||
export declare class Signer { | ||
readonly signer: EthersSigner; | ||
readonly signer: TypedDataSigner; | ||
readonly environment: HyperliquidEnvironment; | ||
constructor(signer: EthersSigner, environment: HyperliquidEnvironment); | ||
constructor(signer: TypedDataSigner, environment: HyperliquidEnvironment); | ||
signL1Action(action: Record<string, any>, vaultAddress: string | null, nonce: number): Promise<Signature>; | ||
@@ -20,1 +24,2 @@ signUserAction(action: Record<string, any>, types: Record<string, Array<TypedDataField>>): Promise<Signature>; | ||
} | ||
export {}; |
@@ -37,3 +37,3 @@ "use strict"; | ||
version: '1', | ||
//chainId: 421614, | ||
chainId: 421614, | ||
verifyingContract: '0x0000000000000000000000000000000000000000', | ||
@@ -48,3 +48,4 @@ }; | ||
async signAction(domain, types, value) { | ||
const signature = await this.signer.signTypedData(domain, types, value); | ||
const signer = typeof this.signer === 'function' ? this.signer : this.signer.signTypedData.bind(this.signer); | ||
const signature = await signer(domain, types, value); | ||
return this.splitSig(signature); | ||
@@ -51,0 +52,0 @@ } |
import { HyperliquidEnvironment } from './constants'; | ||
import { Signature, Signer } from './Signer'; | ||
import { Signer, Signature } from './Signer'; | ||
export type ActionResponse<TResponse extends any = { | ||
@@ -4,0 +4,0 @@ type: 'default'; |
@@ -1,5 +0,5 @@ | ||
import { Signer as EthersSigner } from 'ethers'; | ||
import { ExchangeEndpoint, HyperliquidAction, SpotDeployAction } from './ExchangeEndpoint'; | ||
import { AllMidsResponse, ClearingHouseStateResponse, InfoEndpoint, SpotMetaResponse, VaultDetailsResponse } from './InfoEndpoint'; | ||
import { Price } from './Price'; | ||
import { TypedDataSigner } from './Signer'; | ||
import { Size } from './Size'; | ||
@@ -46,6 +46,6 @@ import { HyperliquidEnvironment } from './constants'; | ||
readonly environment: HyperliquidEnvironment; | ||
readonly signer?: EthersSigner | undefined; | ||
readonly signer?: TypedDataSigner | undefined; | ||
readonly exchange: ExchangeEndpoint | undefined; | ||
readonly info: InfoEndpoint; | ||
constructor(environment: HyperliquidEnvironment, signer?: EthersSigner | undefined); | ||
constructor(environment: HyperliquidEnvironment, signer?: TypedDataSigner | undefined); | ||
fetchSpotMeta(): Promise<SpotMetaResponse>; | ||
@@ -52,0 +52,0 @@ fetchSpotTokens(): Promise<Record<string, { |
@@ -1,4 +0,4 @@ | ||
import { Signer } from './Signer'; | ||
import { ExchangeEndpoint, } from './ExchangeEndpoint'; | ||
import { InfoEndpoint, } from './InfoEndpoint'; | ||
import { Signer } from './Signer'; | ||
import { HYPERLIQUID_API_URL } from './constants'; | ||
@@ -5,0 +5,0 @@ export class HyperliquidSDK { |
@@ -1,3 +0,7 @@ | ||
import { TypedDataDomain, TypedDataField, Signer as EthersSigner } from 'ethers'; | ||
import { TypedDataDomain, TypedDataField } from 'ethers'; | ||
import { HyperliquidEnvironment } from './constants'; | ||
type TypedDataSignerAction = (domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, values: Record<string, any>) => Promise<string>; | ||
export type TypedDataSigner = { | ||
signTypedData: TypedDataSignerAction; | ||
} | TypedDataSignerAction; | ||
export type Signature = { | ||
@@ -9,5 +13,5 @@ r: string; | ||
export declare class Signer { | ||
readonly signer: EthersSigner; | ||
readonly signer: TypedDataSigner; | ||
readonly environment: HyperliquidEnvironment; | ||
constructor(signer: EthersSigner, environment: HyperliquidEnvironment); | ||
constructor(signer: TypedDataSigner, environment: HyperliquidEnvironment); | ||
signL1Action(action: Record<string, any>, vaultAddress: string | null, nonce: number): Promise<Signature>; | ||
@@ -20,1 +24,2 @@ signUserAction(action: Record<string, any>, types: Record<string, Array<TypedDataField>>): Promise<Signature>; | ||
} | ||
export {}; |
@@ -34,3 +34,3 @@ // NOTE: this has been adapted from the following | ||
version: '1', | ||
//chainId: 421614, | ||
chainId: 421614, | ||
verifyingContract: '0x0000000000000000000000000000000000000000', | ||
@@ -45,3 +45,4 @@ }; | ||
async signAction(domain, types, value) { | ||
const signature = await this.signer.signTypedData(domain, types, value); | ||
const signer = typeof this.signer === 'function' ? this.signer : this.signer.signTypedData.bind(this.signer); | ||
const signature = await signer(domain, types, value); | ||
return this.splitSig(signature); | ||
@@ -48,0 +49,0 @@ } |
{ | ||
"name": "@ambitlabs/hyperliquid-sdk", | ||
"version": "0.0.1-beta10", | ||
"version": "0.0.1-beta11", | ||
"types": "./dist/esm/index.d.ts", | ||
@@ -5,0 +5,0 @@ "module": "./dist/esm/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
92718
1.08%1724
0.7%1
-50%