11import {
22 BaseCoin ,
33 BitGoBase ,
4+ InvalidAddressError ,
45 KeyPair ,
6+ MPCAlgorithm ,
57 ParsedTransaction ,
68 ParseTransactionOptions ,
79 SignedTransaction ,
@@ -10,6 +12,8 @@ import {
1012 VerifyTransactionOptions ,
1113} from '@bitgo/sdk-core' ;
1214import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics' ;
15+ import { KeyPair as AptKeyPair } from './lib' ;
16+ import utils from './lib/utils' ;
1317
1418export class Apt extends BaseCoin {
1519 protected readonly _staticsCoin : Readonly < StaticsBaseCoin > ;
@@ -46,28 +50,54 @@ export class Apt extends BaseCoin {
4650 return 'Aptos' ;
4751 }
4852
49- verifyTransaction ( params : VerifyTransactionOptions ) : Promise < boolean > {
50- throw new Error ( 'Method not implemented.' ) ;
53+ /** @inheritDoc */
54+ supportsTss ( ) : boolean {
55+ return true ;
56+ }
57+
58+ getMPCAlgorithm ( ) : MPCAlgorithm {
59+ return 'eddsa' ;
5160 }
5261
53- isWalletAddress ( params : VerifyAddressOptions ) : Promise < boolean > {
62+ allowsAccountConsolidations ( ) : boolean {
63+ return true ;
64+ }
65+
66+ async verifyTransaction ( params : VerifyTransactionOptions ) : Promise < boolean > {
5467 throw new Error ( 'Method not implemented.' ) ;
5568 }
5669
70+ async isWalletAddress ( params : VerifyAddressOptions ) : Promise < boolean > {
71+ const { address : newAddress } = params ;
72+
73+ if ( ! this . isValidAddress ( newAddress ) ) {
74+ throw new InvalidAddressError ( `invalid address: ${ newAddress } ` ) ;
75+ }
76+ return true ;
77+ }
78+
5779 parseTransaction ( params : ParseTransactionOptions ) : Promise < ParsedTransaction > {
5880 throw new Error ( 'Method not implemented.' ) ;
5981 }
6082
6183 generateKeyPair ( seed ?: Buffer ) : KeyPair {
62- throw new Error ( 'Method not implemented.' ) ;
84+ const keyPair = seed ? new AptKeyPair ( { seed } ) : new AptKeyPair ( ) ;
85+ const keys = keyPair . getKeys ( ) ;
86+ if ( ! keys . prv ) {
87+ throw new Error ( 'Missing prv in key generation.' ) ;
88+ }
89+ return {
90+ pub : keys . pub ,
91+ prv : keys . prv ,
92+ } ;
6393 }
6494
6595 isValidPub ( pub : string ) : boolean {
66- throw new Error ( 'Method not implemented.' ) ;
96+ return utils . isValidPublicKey ( pub ) ;
6797 }
6898
6999 isValidAddress ( address : string ) : boolean {
70- throw new Error ( 'Method not implemented.' ) ;
100+ return utils . isValidAddress ( address ) ;
71101 }
72102
73103 signTransaction ( params : SignTransactionOptions ) : Promise < SignedTransaction > {
0 commit comments