@@ -10,11 +10,13 @@ import {
1010 ParseTransactionOptions ,
1111 SignedTransaction ,
1212 SignTransactionOptions ,
13- VerifyAddressOptions ,
13+ TransactionType ,
14+ TssVerifyAddressOptions ,
1415 VerifyTransactionOptions ,
1516} from '@bitgo/sdk-core' ;
1617import { auditEddsaPrivateKey } from '@bitgo/sdk-lib-mpc' ;
17- import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics' ;
18+ import { BaseCoin as StaticsBaseCoin , coins } from '@bitgo/statics' ;
19+ import { TransactionBuilderFactory } from './lib' ;
1820import { KeyPair as CantonKeyPair } from './lib/keyPair' ;
1921import utils from './lib/utils' ;
2022
@@ -70,12 +72,29 @@ export class Canton extends BaseCoin {
7072 }
7173
7274 /** @inheritDoc */
73- verifyTransaction ( params : VerifyTransactionOptions ) : Promise < boolean > {
74- throw new Error ( 'Method not implemented.' ) ;
75+ async verifyTransaction ( params : VerifyTransactionOptions ) : Promise < boolean > {
76+ const coinConfig = coins . get ( this . getChain ( ) ) ;
77+ // extract `txParams` when verifying other transaction types
78+ const { txPrebuild : txPrebuild } = params ;
79+ const rawTx = txPrebuild . txHex ;
80+ if ( ! rawTx ) {
81+ throw new Error ( 'missing required tx prebuild property txHex' ) ;
82+ }
83+ const txBuilder = new TransactionBuilderFactory ( coinConfig ) . from ( rawTx ) ;
84+ const transaction = txBuilder . transaction ;
85+ switch ( transaction . type ) {
86+ case TransactionType . WalletInitialization : {
87+ // there is no input for this type of transaction, so always return true
88+ return true ;
89+ }
90+ default : {
91+ throw new Error ( `unknown transaction type, ${ transaction . type } ` ) ;
92+ }
93+ }
7594 }
7695
7796 /** @inheritDoc */
78- isWalletAddress ( params : VerifyAddressOptions ) : Promise < boolean > {
97+ isWalletAddress ( params : TssVerifyAddressOptions ) : Promise < boolean > {
7998 throw new Error ( 'Method not implemented.' ) ;
8099 }
81100
@@ -104,7 +123,9 @@ export class Canton extends BaseCoin {
104123
105124 /** @inheritDoc */
106125 isValidAddress ( address : string ) : boolean {
107- throw new Error ( 'Method not implemented.' ) ;
126+ // canton addresses are of the form, partyHint::fingerprint
127+ // where partyHint is of length 5 and fingerprint is 68 characters long
128+ return utils . isValidAddress ( address ) ;
108129 }
109130
110131 /** @inheritDoc */
0 commit comments