@@ -131,22 +131,16 @@ export async function sendTransactionWithLedger(
131
131
confirm : boolean ,
132
132
logger ?: Logger ,
133
133
) : Promise < void > {
134
- const ledger = new LedgerSingleSigner ( logger )
135
-
136
- try {
137
- await ledger . connect ( )
138
- } catch ( e ) {
139
- if ( e instanceof Error ) {
140
- Errors . error ( e . message )
141
- } else {
142
- throw e
143
- }
144
- }
134
+ const ledgerApp = new LedgerSingleSigner ( logger )
145
135
146
136
const publicKey = ( await client . wallet . getAccountPublicKey ( { account : from } ) ) . content
147
137
. publicKey
148
138
149
- const ledgerPublicKey = await ledger . getPublicAddress ( )
139
+ const ledgerPublicKey = await ledger ( {
140
+ ledger : ledgerApp ,
141
+ message : 'Get Public Address' ,
142
+ action : ( ) => ledgerApp . getPublicAddress ( ) ,
143
+ } )
150
144
151
145
if ( publicKey !== ledgerPublicKey ) {
152
146
Errors . error (
@@ -163,13 +157,18 @@ export async function sendTransactionWithLedger(
163
157
164
158
ux . stdout ( 'Please confirm the transaction on your Ledger device' )
165
159
166
- const signature = ( await ledger . sign ( unsignedTransaction ) ) . toString ( 'hex' )
160
+ const signature = await ledger ( {
161
+ ledger : ledgerApp ,
162
+ message : 'Sign Transaction' ,
163
+ approval : true ,
164
+ action : ( ) => ledgerApp . sign ( unsignedTransaction ) ,
165
+ } )
167
166
168
- ux . stdout ( `\nSignature: ${ signature } ` )
167
+ ux . stdout ( `\nSignature: ${ signature . toString ( 'hex' ) } ` )
169
168
170
169
const addSignatureResponse = await client . wallet . addSignature ( {
171
170
unsignedTransaction,
172
- signature,
171
+ signature : signature . toString ( 'hex' ) ,
173
172
} )
174
173
175
174
const signedTransaction = addSignatureResponse . content . transaction
0 commit comments