5
5
cosmwasmBuildSignedMessage ,
6
6
evmBuildSignedMessage ,
7
7
aptosBuildSignedMessage ,
8
+ suiBuildSignedMessage ,
8
9
} from './ecosystems/signatures'
9
10
import { ethers } from 'ethers'
10
11
import fs from 'fs'
@@ -15,8 +16,9 @@ import { Keypair, PublicKey } from '@solana/web3.js'
15
16
import { EthSecp256k1Wallet } from '@injectivelabs/sdk-ts/dist/cjs/core/accounts/signers/EthSecp256k1Wallet'
16
17
import { OfflineAminoSigner } from '@injectivelabs/sdk-ts/dist/cjs/core/accounts/signers/types/amino-signer'
17
18
import { hardDriveSignMessage , signDiscordMessage } from './ecosystems/solana'
18
- import { AptosAccount , HexString } from 'aptos'
19
+ import { AptosAccount } from 'aptos'
19
20
import { aptosGetFullMessage } from './ecosystems/aptos'
21
+ import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519'
20
22
21
23
const KEY_DIR = './integration/keys/'
22
24
export const TEST_DISCORD_USERNAME =
@@ -39,42 +41,42 @@ export function loadAnchorWallet(): NodeWallet {
39
41
export async function loadTestWallets ( ) : Promise <
40
42
Record < Ecosystem , TestWallet [ ] >
41
43
> {
42
- const evmWallet = TestEvmWallet . fromKeyfile (
43
- path . resolve ( KEY_DIR , 'evm_private_key.json' )
44
- )
44
+ const evmPrivateKeyPath = path . resolve ( KEY_DIR , 'evm_private_key.json' )
45
45
const cosmosPrivateKeyPath = path . resolve ( KEY_DIR , 'cosmos_private_key.json' )
46
46
const aptosPrivateKeyPath = path . resolve ( KEY_DIR , 'aptos_private_key.json' )
47
+ const suiPrivateKeyPath = path . resolve ( KEY_DIR , 'sui_private_key.json' )
48
+
47
49
const dispenserGuardKeyPath = path . resolve (
48
50
KEY_DIR ,
49
51
'dispenser_guard_private_key.json'
50
52
)
51
53
const solanaPrivateKeyPath = path . resolve ( KEY_DIR , 'solana_private_key.json' )
52
54
53
55
const result : Record < Ecosystem , TestWallet [ ] > = {
54
- evm : [ ] ,
55
- cosmwasm : [ ] ,
56
+ discord : [ ] ,
56
57
solana : [ ] ,
57
- aptos : [ ] ,
58
+ evm : [ ] ,
58
59
sui : [ ] ,
59
- discord : [ ] ,
60
+ aptos : [ ] ,
61
+ cosmwasm : [ ] ,
60
62
injective : [ ] ,
61
63
}
62
- result [ 'evm' ] = [ evmWallet ]
63
-
64
+ result [ 'discord' ] = [
65
+ DiscordTestWallet . fromKeyfile ( TEST_DISCORD_USERNAME , dispenserGuardKeyPath ) ,
66
+ ]
67
+ result [ 'solana' ] = [ TestSolanaWallet . fromKeyfile ( solanaPrivateKeyPath ) ]
68
+ result [ 'evm' ] = [ TestEvmWallet . fromKeyfile ( evmPrivateKeyPath ) ]
69
+ result [ 'sui' ] = [ TestSuiWallet . fromKeyfile ( suiPrivateKeyPath ) ]
70
+ result [ 'aptos' ] = [ TestAptosWallet . fromKeyfile ( aptosPrivateKeyPath ) ]
64
71
result [ 'cosmwasm' ] = [
65
72
await TestCosmWasmWallet . fromKeyFile ( cosmosPrivateKeyPath ) ,
66
73
await TestCosmWasmWallet . fromKeyFile ( cosmosPrivateKeyPath , 'osmo' ) ,
67
74
await TestCosmWasmWallet . fromKeyFile ( cosmosPrivateKeyPath , 'neutron' ) ,
68
75
]
69
- result [ 'aptos' ] = [ TestAptosWallet . fromKeyfile ( aptosPrivateKeyPath ) ]
70
76
result [ 'injective' ] = [
71
77
await TestCosmWasmWallet . fromKeyFile ( cosmosPrivateKeyPath , 'inj' ) ,
72
78
]
73
79
74
- result [ 'discord' ] = [
75
- DiscordTestWallet . fromKeyfile ( TEST_DISCORD_USERNAME , dispenserGuardKeyPath ) ,
76
- ]
77
- result [ 'solana' ] = [ TestSolanaWallet . fromKeyfile ( solanaPrivateKeyPath ) ]
78
80
return result
79
81
}
80
82
@@ -212,18 +214,18 @@ export class TestSolanaWallet implements TestWallet {
212
214
}
213
215
214
216
export class TestAptosWallet implements TestWallet {
215
- constructor ( readonly wallet : AptosAccount , readonly addressStr : string ) { }
217
+ constructor ( readonly wallet : AptosAccount ) { }
216
218
static fromKeyfile ( keyFile : string ) : TestAptosWallet {
217
219
const jsonContent = fs . readFileSync ( keyFile , 'utf8' )
218
220
const mnemonic = JSON . parse ( jsonContent ) . mnemonic
219
221
const aptosAccount = AptosAccount . fromDerivePath (
220
222
"m/44'/637'/0'/0'/0'" ,
221
223
mnemonic
222
224
)
223
- return new TestAptosWallet ( aptosAccount , aptosAccount . authKey ( ) . hex ( ) )
225
+ return new TestAptosWallet ( aptosAccount )
224
226
}
225
227
address ( ) : string {
226
- return this . addressStr
228
+ return this . wallet . authKey ( ) . hex ( )
227
229
}
228
230
229
231
async signMessage ( payload : string ) : Promise < SignedMessage > {
@@ -236,3 +238,24 @@ export class TestAptosWallet implements TestWallet {
236
238
)
237
239
}
238
240
}
241
+
242
+ export class TestSuiWallet implements TestWallet {
243
+ constructor ( readonly wallet : Ed25519Keypair ) { }
244
+
245
+ static fromKeyfile ( keyFile : string ) : TestSuiWallet {
246
+ const jsonContent = fs . readFileSync ( keyFile , 'utf8' )
247
+ const mnemonic = JSON . parse ( jsonContent ) . mnemonic
248
+ return new TestSuiWallet ( Ed25519Keypair . deriveKeypair ( mnemonic ) )
249
+ }
250
+
251
+ address ( ) : string {
252
+ return this . wallet . toSuiAddress ( )
253
+ }
254
+ async signMessage ( payload : string ) : Promise < SignedMessage > {
255
+ const response = (
256
+ await this . wallet . signPersonalMessage ( Buffer . from ( payload ) )
257
+ ) . signature
258
+
259
+ return suiBuildSignedMessage ( response , payload )
260
+ }
261
+ }
0 commit comments