11import {
2- AddressCoinSpecific ,
32 AuditDecryptedKeyParams ,
43 BaseCoin ,
54 BitGoBase ,
@@ -21,8 +20,8 @@ import {
2120 RecoveryTxRequest ,
2221 SignedTransaction ,
2322 TssVerifyAddressOptions ,
23+ UnexpectedAddressError ,
2424 verifyEddsaTssWalletAddress ,
25- VerifyAddressOptions ,
2625 VerifyTransactionOptions ,
2726} from '@bitgo/sdk-core' ;
2827import { CoinFamily , BaseCoin as StaticsBaseCoin } from '@bitgo/statics' ;
@@ -36,13 +35,6 @@ import { ApiPromise } from '@polkadot/api';
3635
3736export const DEFAULT_SCAN_FACTOR = 20 ;
3837
39- export interface SubstrateVerifyAddressOptions extends VerifyAddressOptions {
40- index ?: number | string ;
41- coinSpecific ?: AddressCoinSpecific & {
42- index ?: number | string ;
43- } ;
44- }
45-
4638export class SubstrateCoin extends BaseCoin {
4739 protected readonly _staticsCoin : Readonly < StaticsBaseCoin > ;
4840 readonly MAX_VALIDITY_DURATION = 2400 ;
@@ -119,28 +111,15 @@ export class SubstrateCoin extends BaseCoin {
119111 }
120112
121113 /** @inheritDoc **/
122- async isWalletAddress ( params : SubstrateVerifyAddressOptions ) : Promise < boolean > {
123- const { address, keychains } = params ;
124-
125- const index = Number ( params . index ?? params . coinSpecific ?. index ) ;
126- if ( isNaN ( index ) || index < 0 ) {
127- throw new Error ( 'Invalid or missing index. index must be a non-negative number.' ) ;
128- }
129-
130- const tssParams : TssVerifyAddressOptions = {
131- address,
132- keychains : keychains as TssVerifyAddressOptions [ 'keychains' ] ,
133- index,
134- } ;
135-
114+ async isWalletAddress ( params : TssVerifyAddressOptions ) : Promise < boolean > {
136115 const isValid = await verifyEddsaTssWalletAddress (
137- tssParams ,
116+ params ,
138117 ( addr ) => this . isValidAddress ( addr ) ,
139118 ( pubKey ) => this . getAddressFromPublicKey ( pubKey )
140119 ) ;
141120
142121 if ( ! isValid ) {
143- throw new Error ( `Address verification failed: address ${ address } is not a wallet address at index ${ index } ` ) ;
122+ throw new UnexpectedAddressError ( ) ;
144123 }
145124
146125 return true ;
0 commit comments