@@ -13,8 +13,9 @@ import {ecdsaRecover} from 'secp256k1';
1313
1414
1515const ec = new EC ( 'secp256k1' ) ;
16- const keyPair = ec . genKeyPair ( ) ;
17- console . log ( "private key" , keyPair . getPrivate ( 'hex' ) ) ;
16+ // const keyPair = ec.genKeyPair();
17+ // read private key from hex dump
18+ const keyPair = ec . keyFromPrivate ( '5b81cdf52ba0766983acf8dd0072904733d92afe4dd3499e83e879b43ccb73e8' ) ;
1819
1920describe ( "some tests" , ( ) => {
2021 // Configure the client to use the local cluster.
@@ -43,8 +44,10 @@ describe("some tests", () => {
4344 const addressBuffer = keccak256 ( publicKeyBuffer ) ; // Skip the first byte (format indicator)
4445 const address = addressBuffer . slice ( - 20 ) ;
4546 console . log ( "address" , bufferToHex ( address ) ) ;
47+ // console.log("address", address);
4648 // const tssAddress = [239, 36, 74, 232, 12, 58, 220, 53, 101, 185, 127, 45, 0, 144, 15, 163, 104, 163, 74, 178,];
4749 const tssAddress = Array . from ( address ) ;
50+ console . log ( "tss address" , tssAddress ) ;
4851
4952 it ( "Initializes the program" , async ( ) => {
5053 await gatewayProgram . methods . initialize ( tssAddress ) . rpc ( ) ;
@@ -134,8 +137,7 @@ describe("some tests", () => {
134137 ) ;
135138 tx . add ( memoInst ) ;
136139 const depositInst = await gatewayProgram . methods . depositSplToken (
137- new anchor . BN ( 1_000_000 ) ,
138- Buffer . from ( "hello" , "utf-8" ) ) . accounts (
140+ new anchor . BN ( 1_000_000 ) , address ) . accounts (
139141 {
140142 from : tokenAccount . address ,
141143 to : pda_ata . address ,
@@ -146,7 +148,7 @@ describe("some tests", () => {
146148
147149
148150 try {
149- await gatewayProgram . methods . depositSplToken ( new anchor . BN ( 1_000_000 ) , Buffer . from ( "world" , "utf-8" ) ) . accounts (
151+ await gatewayProgram . methods . depositSplToken ( new anchor . BN ( 1_000_000 ) , address ) . accounts (
150152 {
151153 from : tokenAccount . address ,
152154 to : wallet_ata ,
@@ -161,16 +163,6 @@ describe("some tests", () => {
161163 } ) ;
162164
163165 it ( "Withdraw 500_000 USDC from Gateway with ECDSA signature" , async ( ) => {
164-
165- // const tx_xfer = await spl.transfer(
166- // conn,
167- // wallet,
168- // tokenAccount.address,
169- // pda_ata.address,
170- // wallet,
171- // 1_000_000
172- // );
173- // console.log("xfer tx hash", tx_xfer);
174166 const account2 = await spl . getAccount ( conn , pda_ata . address ) ;
175167 expect ( account2 . amount ) . to . be . eq ( 1_000_000n ) ;
176168 // console.log("B4 withdraw: Account balance:", account2.amount.toString());
@@ -229,7 +221,7 @@ describe("some tests", () => {
229221 } ) ;
230222
231223 it ( "deposit and withdraw 0.5 SOL from Gateway with ECDSA signature" , async ( ) => {
232- await gatewayProgram . methods . deposit ( new anchor . BN ( 1_000_000_000 ) , Buffer . from ( "hello" ) ) . accounts ( { pda : pdaAccount } ) . rpc ( ) ;
224+ await gatewayProgram . methods . deposit ( new anchor . BN ( 1_000_000_000 ) , address ) . accounts ( { pda : pdaAccount } ) . rpc ( ) ;
233225 // const transaction = new anchor.web3.Transaction();
234226 // transaction.add(
235227 // web3.SystemProgram.transfer({
0 commit comments