@@ -18,8 +18,6 @@ import {
1818 SignTransactionOptions ,
1919 TssVerifyAddressOptions ,
2020 VerifyTransactionOptions ,
21- InvalidAddressError ,
22- UnexpectedAddressError ,
2321} from '@bitgo/sdk-core' ;
2422import { coins , BaseCoin as StaticsBaseCoin } from '@bitgo/statics' ;
2523import { Principal } from '@dfinity/principal' ;
@@ -40,11 +38,9 @@ import {
4038 Signatures ,
4139 SigningPayload ,
4240 IcpTransactionExplanation ,
43- IcpCoinSpecific ,
4441} from './lib/iface' ;
4542import { TransactionBuilderFactory } from './lib/transactionBuilderFactory' ;
4643import utils from './lib/utils' ;
47- import { Transaction } from './lib' ;
4844
4945/**
5046 * Class representing the Internet Computer (ICP) coin.
@@ -90,13 +86,15 @@ export class Icp extends BaseCoin {
9086 }
9187
9288 async explainTransaction ( params : { txHex : string } ) : Promise < IcpTransactionExplanation > {
93- const transaction = ( await ( await this . getBuilderFactory ( ) . from ( params . txHex ) ) . build ( ) ) as Transaction ;
89+ const factory = this . getBuilderFactory ( ) ;
90+ const txBuilder = await factory . from ( params . txHex ) ;
91+ const transaction = await txBuilder . build ( ) ;
9492 return transaction . explainTransaction ( ) ;
9593 }
9694
9795 async verifyTransaction ( params : VerifyTransactionOptions ) : Promise < boolean > {
9896 const { txParams, txPrebuild } = params ;
99- const { txHex } = txPrebuild ;
97+ const txHex = txPrebuild ?. txHex ;
10098 if ( ! txHex ) {
10199 throw new Error ( 'txHex is required' ) ;
102100 }
@@ -113,22 +111,18 @@ export class Icp extends BaseCoin {
113111 const output = explainedTx . outputs [ 0 ] ;
114112 const recipient = txParams . recipients [ 0 ] ;
115113 assert (
116- output . address === recipient . address && BigNumber ( output . amount ) . eq ( BigNumber ( recipient . amount ) ) ,
114+ typeof recipient . address === 'string' &&
115+ typeof output . address === 'string' &&
116+ output . address === recipient . address &&
117+ BigNumber ( output . amount ) . eq ( BigNumber ( recipient . amount ) ) ,
117118 'Tx outputs does not match with expected txParams recipients'
118119 ) ;
119120 }
120121 return true ;
121122 }
122123
123124 async isWalletAddress ( params : TssVerifyAddressOptions ) : Promise < boolean > {
124- if ( ! this . isValidAddress ( params . address ) ) {
125- throw new InvalidAddressError ( `invalid address: ${ params . address } ` ) ;
126- }
127- const rootAddress = ( params . coinSpecific as IcpCoinSpecific ) . rootAddress ;
128- if ( params . address . includes ( rootAddress ) ) {
129- throw new UnexpectedAddressError ( `address validation failure: ${ params . address } vs ${ rootAddress } ` ) ;
130- }
131- return true ;
125+ return this . isValidAddress ( params . address ) ;
132126 }
133127
134128 async parseTransaction ( params : ParseTransactionOptions ) : Promise < ParsedTransaction > {
0 commit comments