55 cosmwasmBuildSignedMessage ,
66 evmBuildSignedMessage ,
77 aptosBuildSignedMessage ,
8+ suiBuildSignedMessage ,
89} from './ecosystems/signatures'
910import { ethers } from 'ethers'
1011import fs from 'fs'
@@ -15,8 +16,9 @@ import { Keypair, PublicKey } from '@solana/web3.js'
1516import { EthSecp256k1Wallet } from '@injectivelabs/sdk-ts/dist/cjs/core/accounts/signers/EthSecp256k1Wallet'
1617import { OfflineAminoSigner } from '@injectivelabs/sdk-ts/dist/cjs/core/accounts/signers/types/amino-signer'
1718import { hardDriveSignMessage , signDiscordMessage } from './ecosystems/solana'
18- import { AptosAccount , HexString } from 'aptos'
19+ import { AptosAccount } from 'aptos'
1920import { aptosGetFullMessage } from './ecosystems/aptos'
21+ import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519'
2022
2123const KEY_DIR = './integration/keys/'
2224export const TEST_DISCORD_USERNAME =
@@ -39,42 +41,42 @@ export function loadAnchorWallet(): NodeWallet {
3941export async function loadTestWallets ( ) : Promise <
4042 Record < Ecosystem , TestWallet [ ] >
4143> {
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' )
4545 const cosmosPrivateKeyPath = path . resolve ( KEY_DIR , 'cosmos_private_key.json' )
4646 const aptosPrivateKeyPath = path . resolve ( KEY_DIR , 'aptos_private_key.json' )
47+ const suiPrivateKeyPath = path . resolve ( KEY_DIR , 'sui_private_key.json' )
48+
4749 const dispenserGuardKeyPath = path . resolve (
4850 KEY_DIR ,
4951 'dispenser_guard_private_key.json'
5052 )
5153 const solanaPrivateKeyPath = path . resolve ( KEY_DIR , 'solana_private_key.json' )
5254
5355 const result : Record < Ecosystem , TestWallet [ ] > = {
54- evm : [ ] ,
55- cosmwasm : [ ] ,
56+ discord : [ ] ,
5657 solana : [ ] ,
57- aptos : [ ] ,
58+ evm : [ ] ,
5859 sui : [ ] ,
59- discord : [ ] ,
60+ aptos : [ ] ,
61+ cosmwasm : [ ] ,
6062 injective : [ ] ,
6163 }
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 ) ]
6471 result [ 'cosmwasm' ] = [
6572 await TestCosmWasmWallet . fromKeyFile ( cosmosPrivateKeyPath ) ,
6673 await TestCosmWasmWallet . fromKeyFile ( cosmosPrivateKeyPath , 'osmo' ) ,
6774 await TestCosmWasmWallet . fromKeyFile ( cosmosPrivateKeyPath , 'neutron' ) ,
6875 ]
69- result [ 'aptos' ] = [ TestAptosWallet . fromKeyfile ( aptosPrivateKeyPath ) ]
7076 result [ 'injective' ] = [
7177 await TestCosmWasmWallet . fromKeyFile ( cosmosPrivateKeyPath , 'inj' ) ,
7278 ]
7379
74- result [ 'discord' ] = [
75- DiscordTestWallet . fromKeyfile ( TEST_DISCORD_USERNAME , dispenserGuardKeyPath ) ,
76- ]
77- result [ 'solana' ] = [ TestSolanaWallet . fromKeyfile ( solanaPrivateKeyPath ) ]
7880 return result
7981}
8082
@@ -212,18 +214,18 @@ export class TestSolanaWallet implements TestWallet {
212214}
213215
214216export class TestAptosWallet implements TestWallet {
215- constructor ( readonly wallet : AptosAccount , readonly addressStr : string ) { }
217+ constructor ( readonly wallet : AptosAccount ) { }
216218 static fromKeyfile ( keyFile : string ) : TestAptosWallet {
217219 const jsonContent = fs . readFileSync ( keyFile , 'utf8' )
218220 const mnemonic = JSON . parse ( jsonContent ) . mnemonic
219221 const aptosAccount = AptosAccount . fromDerivePath (
220222 "m/44'/637'/0'/0'/0'" ,
221223 mnemonic
222224 )
223- return new TestAptosWallet ( aptosAccount , aptosAccount . authKey ( ) . hex ( ) )
225+ return new TestAptosWallet ( aptosAccount )
224226 }
225227 address ( ) : string {
226- return this . addressStr
228+ return this . wallet . authKey ( ) . hex ( )
227229 }
228230
229231 async signMessage ( payload : string ) : Promise < SignedMessage > {
@@ -236,3 +238,24 @@ export class TestAptosWallet implements TestWallet {
236238 )
237239 }
238240}
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