[Feat] Check if valid API#2355
Conversation
| } | ||
|
|
||
| private isValidEthereumAddress(chain, network, add): boolean { | ||
| return !!Validation.validateAddress(chain, network, add); |
There was a problem hiding this comment.
We should be able to use Validation.validateAddress for all the chains, otherwise we need to update that method to where that is true.
| return !!bitcoreLib.Address.isValid(data, 'testnet'); | ||
| } | ||
|
|
||
| private isValidBitcoinCashLegacyMainnetAddress(data: string): boolean { |
There was a problem hiding this comment.
Chain specific api logic goes into packages/bitcore-node/src/providers/chain-state/${chain}/${chain}.ts
| this.isValidBitcoinCashLegacyMainnetAddress(addr) | ||
| ); | ||
| } else if(chain.toLowerCase() === 'eth') { | ||
| return this.isValidEthereumAddress('eth', network, addr); |
There was a problem hiding this comment.
The ethereum logic can go in packages/bitcore-node/src/modules/ethereum/api/csp.ts
Each chain's CSP should implement this isValidAddress method
767c526 to
b06fe9f
Compare
| getCoinsForTx(params: { chain: string; network: string; txid: string }): Promise<CoinListingJSON>; | ||
| getLocalTip(params): Promise<IBlock | null>; | ||
| getLocatorHashes(params): Promise<any>; | ||
| isValid(params): {isValid: boolean, type:string}; |
There was a problem hiding this comment.
params: {input: string}
| private isValidAddress(params): boolean { | ||
| const { chain, network, input } = params; | ||
| const addr = this.extractAddress(input); | ||
| return this.validateAddress(chain.toLowerCase(), network, addr); |
There was a problem hiding this comment.
Can we consolidate the logic of isValidAddress and validateAddress?
does Validation.validateAddress require the adddress to be extracted?
| } | ||
| } | ||
|
|
||
| private isValidBlockOrTx(inputValue): boolean { |
b06fe9f to
cba8191
Compare
| getCoinsForTx(params: { chain: string; network: string; txid: string }): Promise<CoinListingJSON>; | ||
| getLocalTip(params): Promise<IBlock | null>; | ||
| getLocatorHashes(params): Promise<any>; | ||
| isValid(params:{ input: string }): {isValid: boolean, type:string}; |
There was a problem hiding this comment.
Seems like chain and network should be in the typing for params, since
const { chain, network, input } = params;
on line 577
There was a problem hiding this comment.
Done ! Thanks !
cba8191 to
4978d25
Compare
4978d25 to
8947de5
Compare
[Feat] Check if valid API
[Feat] Check if valid API
[Feat] Check if valid API
No description provided.