Skip to content

Commit afb4dd3

Browse files
feat: add support for signing hypercore EIP 712 messages using fordefi or fireblocks (#1861)
Signed-off-by: shankar <shankar@layerzerolabs.org> Co-authored-by: shankar <shankar@layerzerolabs.org>
1 parent a2851bf commit afb4dd3

31 files changed

+1905
-163
lines changed

.changeset/thirty-trees-decide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@layerzerolabs/io-devtools": patch
3+
---
4+
5+
format splat for printf like logging

.changeset/unlucky-shirts-ring.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@layerzerolabs/hyperliquid-composer": patch
3+
"@layerzerolabs/oft-hyperliquid-example": patch
4+
---
5+
6+
feat: fireblocks and fordefi mpc signers for hyperliquid sdk

examples/oft-hyperliquid/deploy/MyHyperLiquidComposer_FeeAbstraction.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import assert from 'assert'
22

3-
import { Wallet } from 'ethers'
43
import { type DeployFunction } from 'hardhat-deploy/types'
54
import inquirer from 'inquirer'
65

7-
import { CHAIN_IDS, getCoreSpotDeployment, useBigBlock, useSmallBlock } from '@layerzerolabs/hyperliquid-composer'
6+
import {
7+
CHAIN_IDS,
8+
EthersSigner,
9+
getCoreSpotDeployment,
10+
useBigBlock,
11+
useSmallBlock,
12+
} from '@layerzerolabs/hyperliquid-composer'
813

914
const contractName_oft = 'MyOFT'
1015
const contractName_composer = 'MyHyperLiquidComposer_FeeAbstraction'
@@ -52,7 +57,7 @@ const deploy: DeployFunction = async (hre) => {
5257
// Get logger from hardhat flag --log-level
5358
const loglevel = hre.hardhatArguments.verbose ? 'debug' : 'error'
5459

55-
const wallet = new Wallet(privateKey.toString())
60+
const signer = new EthersSigner(privateKey.toString())
5661
const chainId = (await hre.ethers.provider.getNetwork()).chainId
5762
const isHyperliquid = chainId === CHAIN_IDS.MAINNET || chainId === CHAIN_IDS.TESTNET
5863
const isTestnet = chainId === CHAIN_IDS.TESTNET
@@ -101,7 +106,7 @@ const deploy: DeployFunction = async (hre) => {
101106

102107
if (!isDeployed_composer) {
103108
console.log(`Switching to hyperliquid big block for the address ${deployer} to deploy ${contractName_composer}`)
104-
const res = await useBigBlock(wallet, isTestnet, loglevel, true)
109+
const res = await useBigBlock(signer, isTestnet, loglevel, true)
105110
console.log(res)
106111
console.log(`Deplying a contract uses big block which is mined at a transaction per minute.`)
107112
}
@@ -133,7 +138,7 @@ const deploy: DeployFunction = async (hre) => {
133138
// Set small block eitherway as we do not have a method to check which hyperliquidblock we are on
134139
{
135140
console.log(`Using small block with address ${deployer} for faster transactions`)
136-
const res = await useSmallBlock(wallet, isTestnet, loglevel, true)
141+
const res = await useSmallBlock(signer, isTestnet, loglevel, true)
137142
console.log(JSON.stringify(res, null, 2))
138143
}
139144
}

examples/oft-hyperliquid/deploy/MyHyperLiquidComposer_FeeToken.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import assert from 'assert'
22

3-
import { Wallet } from 'ethers'
43
import { type DeployFunction } from 'hardhat-deploy/types'
54
import inquirer from 'inquirer'
65

7-
import { CHAIN_IDS, getCoreSpotDeployment, useBigBlock, useSmallBlock } from '@layerzerolabs/hyperliquid-composer'
6+
import {
7+
CHAIN_IDS,
8+
EthersSigner,
9+
getCoreSpotDeployment,
10+
useBigBlock,
11+
useSmallBlock,
12+
} from '@layerzerolabs/hyperliquid-composer'
813

914
const contractName_oft = 'MyOFT'
1015
const contractName_composer = 'MyHyperLiquidComposer_FeeToken'
@@ -34,7 +39,7 @@ const deploy: DeployFunction = async (hre) => {
3439
// Get logger from hardhat flag --log-level
3540
const loglevel = hre.hardhatArguments.verbose ? 'debug' : 'error'
3641

37-
const wallet = new Wallet(privateKey.toString())
42+
const signer = new EthersSigner(privateKey.toString())
3843
const chainId = (await hre.ethers.provider.getNetwork()).chainId
3944
const isHyperliquid = chainId === CHAIN_IDS.MAINNET || chainId === CHAIN_IDS.TESTNET
4045
const isTestnet = chainId === CHAIN_IDS.TESTNET
@@ -79,7 +84,7 @@ const deploy: DeployFunction = async (hre) => {
7984

8085
if (!isDeployed_composer) {
8186
console.log(`Switching to hyperliquid big block for the address ${deployer} to deploy ${contractName_composer}`)
82-
const res = await useBigBlock(wallet, isTestnet, loglevel, true)
87+
const res = await useBigBlock(signer, isTestnet, loglevel, true)
8388
console.log(res)
8489
console.log(`Deplying a contract uses big block which is mined at a transaction per minute.`)
8590
}
@@ -103,7 +108,7 @@ const deploy: DeployFunction = async (hre) => {
103108
// Set small block eitherway as we do not have a method to check which hyperliquidblock we are on
104109
{
105110
console.log(`Using small block with address ${deployer} for faster transactions`)
106-
const res = await useSmallBlock(wallet, isTestnet, loglevel, true)
111+
const res = await useSmallBlock(signer, isTestnet, loglevel, true)
107112
console.log(JSON.stringify(res, null, 2))
108113
}
109114
}

examples/oft-hyperliquid/deploy/MyHyperLiquidComposer_Recoverable.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import assert from 'assert'
22

3-
import { Wallet } from 'ethers'
43
import { type DeployFunction } from 'hardhat-deploy/types'
54
import inquirer from 'inquirer'
65

7-
import { CHAIN_IDS, getCoreSpotDeployment, useBigBlock, useSmallBlock } from '@layerzerolabs/hyperliquid-composer'
6+
import {
7+
CHAIN_IDS,
8+
EthersSigner,
9+
getCoreSpotDeployment,
10+
useBigBlock,
11+
useSmallBlock,
12+
} from '@layerzerolabs/hyperliquid-composer'
813

914
const contractName_oft = 'MyOFT'
1015
const contractName_composer = 'HyperLiquidComposer_Recoverable'
@@ -35,7 +40,7 @@ const deploy: DeployFunction = async (hre) => {
3540
// Get logger from hardhat flag --log-level
3641
const loglevel = hre.hardhatArguments.verbose ? 'debug' : 'error'
3742

38-
const wallet = new Wallet(privateKey.toString())
43+
const signer = new EthersSigner(privateKey.toString())
3944
const chainId = (await hre.ethers.provider.getNetwork()).chainId
4045
const isHyperliquid = chainId === CHAIN_IDS.MAINNET || chainId === CHAIN_IDS.TESTNET
4146
const isTestnet = chainId === CHAIN_IDS.TESTNET
@@ -81,7 +86,7 @@ const deploy: DeployFunction = async (hre) => {
8186

8287
if (!isDeployed_composer) {
8388
console.log(`Switching to hyperliquid big block for the address ${deployer} to deploy ${contractName_composer}`)
84-
const res = await useBigBlock(wallet, isTestnet, loglevel, true)
89+
const res = await useBigBlock(signer, isTestnet, loglevel, true)
8590
console.log(res)
8691
console.log(`Deplying a contract uses big block which is mined at a transaction per minute.`)
8792
}
@@ -106,7 +111,7 @@ const deploy: DeployFunction = async (hre) => {
106111
// Set small block eitherway as we do not have a method to check which hyperliquidblock we are on
107112
{
108113
console.log(`Using small block with address ${deployer} for faster transactions`)
109-
const res = await useSmallBlock(wallet, isTestnet, loglevel, true)
114+
const res = await useSmallBlock(signer, isTestnet, loglevel, true)
110115
console.log(JSON.stringify(res, null, 2))
111116
}
112117
}

examples/oft-hyperliquid/deploy/MyHyperliquidComposer.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import assert from 'assert'
22

3-
import { Wallet } from 'ethers'
43
import { type DeployFunction } from 'hardhat-deploy/types'
54
import inquirer from 'inquirer'
65

7-
import { CHAIN_IDS, getCoreSpotDeployment, useBigBlock, useSmallBlock } from '@layerzerolabs/hyperliquid-composer'
6+
import {
7+
CHAIN_IDS,
8+
EthersSigner,
9+
getCoreSpotDeployment,
10+
useBigBlock,
11+
useSmallBlock,
12+
} from '@layerzerolabs/hyperliquid-composer'
813

914
const contractName_oft = 'MyOFT'
1015
const contractName_composer = 'MyHyperLiquidComposer'
@@ -34,7 +39,7 @@ const deploy: DeployFunction = async (hre) => {
3439
// Get logger from hardhat flag --log-level
3540
const loglevel = hre.hardhatArguments.verbose ? 'debug' : 'error'
3641

37-
const wallet = new Wallet(privateKey.toString())
42+
const signer = new EthersSigner(privateKey.toString())
3843
const chainId = (await hre.ethers.provider.getNetwork()).chainId
3944
const isHyperliquid = chainId === CHAIN_IDS.MAINNET || chainId === CHAIN_IDS.TESTNET
4045
const isTestnet = chainId === CHAIN_IDS.TESTNET
@@ -79,7 +84,7 @@ const deploy: DeployFunction = async (hre) => {
7984

8085
if (!isDeployed_composer) {
8186
console.log(`Switching to hyperliquid big block for the address ${deployer} to deploy ${contractName_composer}`)
82-
const res = await useBigBlock(wallet, isTestnet, loglevel, true)
87+
const res = await useBigBlock(signer, isTestnet, loglevel, true)
8388
console.log(res)
8489
console.log(`Deplying a contract uses big block which is mined at a transaction per minute.`)
8590
}
@@ -103,7 +108,7 @@ const deploy: DeployFunction = async (hre) => {
103108
// Set small block eitherway as we do not have a method to check which hyperliquidblock we are on
104109
{
105110
console.log(`Using small block with address ${deployer} for faster transactions`)
106-
const res = await useSmallBlock(wallet, isTestnet, loglevel, true)
111+
const res = await useSmallBlock(signer, isTestnet, loglevel, true)
107112
console.log(JSON.stringify(res, null, 2))
108113
}
109114
}

examples/oft-hyperliquid/deploy/MyHyperliquidOFT.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import assert from 'assert'
22

3-
import { Wallet } from 'ethers'
43
import { type DeployFunction } from 'hardhat-deploy/types'
54

6-
import { CHAIN_IDS, useBigBlock, useSmallBlock } from '@layerzerolabs/hyperliquid-composer'
5+
import { CHAIN_IDS, EthersSigner, useBigBlock, useSmallBlock } from '@layerzerolabs/hyperliquid-composer'
76

87
const contractName_oft = 'MyOFT'
98
const tokenSymbol = 'MYOFT'
@@ -26,7 +25,7 @@ const deploy: DeployFunction = async (hre) => {
2625
// Get logger from hardhat flag --log-level
2726
const loglevel = hre.hardhatArguments.verbose ? 'debug' : 'info'
2827

29-
const wallet = new Wallet(privateKey.toString())
28+
const signer = new EthersSigner(privateKey.toString())
3029

3130
const chainId = (await hre.ethers.provider.getNetwork()).chainId
3231
const isHyperliquid = chainId === CHAIN_IDS.MAINNET || chainId === CHAIN_IDS.TESTNET
@@ -62,7 +61,7 @@ const deploy: DeployFunction = async (hre) => {
6261

6362
if (!isDeployed_oft && isHyperliquid) {
6463
console.log(`Switching to hyperliquid big block for the address ${deployer} to deploy ${contractName_oft}`)
65-
const res = await useBigBlock(wallet, isTestnet, loglevel, true)
64+
const res = await useBigBlock(signer, isTestnet, loglevel, true)
6665
console.log(JSON.stringify(res, null, 2))
6766
console.log(`Deplying a contract uses big block which is mined at a transaction per minute.`)
6867
}
@@ -85,7 +84,7 @@ const deploy: DeployFunction = async (hre) => {
8584
// Set small block eitherway as we do not have a method to check which hyperliquidblock we are on
8685
if (isHyperliquid) {
8786
console.log(`Using small block with address ${deployer} for faster transactions`)
88-
const res = await useSmallBlock(wallet, isTestnet, loglevel, true)
87+
const res = await useSmallBlock(signer, isTestnet, loglevel, true)
8988
console.log(JSON.stringify(res, null, 2))
9089
}
9190
}

0 commit comments

Comments
 (0)