wallet: adding api_key configuration

Signed-off-by: Alexis Pentori <alexis@status.im>
This commit is contained in:
Alexis Pentori 2024-04-23 16:16:03 +02:00
parent 083fa2d6a7
commit 7315c8d734
No known key found for this signature in database
GPG Key ID: 65250D2801E47A10
4 changed files with 13 additions and 5 deletions

View File

@ -10,7 +10,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 1e55cfe0-f591-4281-9a20-18d89d45f685
dockerImageTag: 0.9.1
dockerImageTag: 1.0.1
dockerRepository: status-im/airbyte/wallet-fetcher
githubIssueLabel: source-wallet-fetcher
icon: icon.svg

View File

@ -24,7 +24,9 @@ class SourceWalletFetcher(AbstractSource):
bitcoin_wallets.append(wallet)
if 'ETH' in wallet['blockchain']:
ethereum_wallets.append(wallet)
api_key='freekey'
if "api_key" in config:
api_key=config["api_key"]
return [
BitcoinToken(wallets=bitcoin_wallets),
EthereumToken(wallets=ethereum_wallets)]
EthereumToken(wallets=ethereum_wallets, api_key=api_key)]

View File

@ -7,6 +7,11 @@ connectionSpecification:
- wallets
additionalProperties: true
properties:
api_key:
title: api_key
type: string
description: 'API key for ethplorer'
airbyte_secret: true
wallets:
title: Wallets
description: "List of wallet to scan"

View File

@ -13,9 +13,10 @@ class BlockchainStream(HttpStream):
primary_key = None
def __init__(self, wallets: List['str'], **kwargs):
def __init__(self, wallets: List['str'], api_key: str='freekey', **kwargs):
super().__init__(**kwargs)
self.wallets = wallets
self.api_key = api_key
def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, Any]]]:
for wallet in self.wallets:
@ -74,7 +75,7 @@ class EthereumToken(BlockchainStream):
url_base = "https://api.ethplorer.io/getAddressInfo/"
def path(self, stream_slice: Mapping[str, Any] = None, **kwargs) -> str:
return f"{stream_slice['address']}?apiKey=freekey"
return f"{stream_slice['address']}?apiKey={self.api_key}"
def parse_response(self,
response: requests.Response,