wallet-fetcher: fix issues
Signed-off-by: Alexis Pentori <alexis@status.im>
This commit is contained in:
parent
3bbc5be5f0
commit
7b9e880839
|
@ -1,6 +1,12 @@
|
||||||
{
|
{
|
||||||
"wallets": [
|
"wallets": [
|
||||||
"0x23f4569002a5A07f0Ecf688142eEB6bcD883eeF8",
|
{
|
||||||
"0xdAC17F958D2ee523a2206206994597C13D831ec7"
|
"address": "0x23f4569002a5A07f0Ecf688142eEB6bcD883eeF8",
|
||||||
|
"name": "wallet-test-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
||||||
|
"name": "wallet-test-2"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,26 +24,39 @@ class Token(HttpStream):
|
||||||
# Set this as a noop.
|
# Set this as a noop.
|
||||||
primary_key = None
|
primary_key = None
|
||||||
|
|
||||||
def __init__(self, wallet_address: str, **kwargs):
|
def __init__(self, wallets: List[str], **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.wallet_address = wallet_address
|
self.wallets = wallets
|
||||||
|
|
||||||
|
def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, Any]]]:
|
||||||
|
for wallet in self.wallets:
|
||||||
|
yield {
|
||||||
|
"address": wallet['address'],
|
||||||
|
"name": wallet['name']
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]:
|
def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def path(self, **kwargs) -> str:
|
def path(self, stream_slice: Mapping[str, Any] = None, **kwargs) -> str:
|
||||||
address = self.wallet_address
|
return f"{stream_slice['address']}?apiKey=freekey"
|
||||||
return f"{address}?apiKey=freekey"
|
|
||||||
|
|
||||||
def request_params(
|
# def request_params(
|
||||||
self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_page_token: Mapping[str, Any] = None
|
# self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_page_token: Mapping[str, Any] = None
|
||||||
) -> MutableMapping[str, Any]:
|
# ) -> MutableMapping[str, Any]:
|
||||||
return {"wallet_address": self.wallet_address}
|
# return {"wallet_address": self.wallet_address}
|
||||||
|
|
||||||
def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]:
|
def parse_response(self,
|
||||||
|
response: requests.Response,
|
||||||
|
stream_slice: Mapping[str, Any] = None,
|
||||||
|
**kwargs
|
||||||
|
) -> Iterable[Mapping]:
|
||||||
logger.info("Getting ETH balance information")
|
logger.info("Getting ETH balance information")
|
||||||
eth_data=response.json()['ETH']
|
eth_data=response.json()['ETH']
|
||||||
yield {
|
yield {
|
||||||
|
"wallet_name": stream_slice['name'],
|
||||||
"name":"ETH",
|
"name":"ETH",
|
||||||
"symbol":"ETH",
|
"symbol":"ETH",
|
||||||
"description": "Native Ethereum token",
|
"description": "Native Ethereum token",
|
||||||
|
@ -56,7 +69,7 @@ class Token(HttpStream):
|
||||||
tokens_data=response.json()['tokens']
|
tokens_data=response.json()['tokens']
|
||||||
for t in tokens_data:
|
for t in tokens_data:
|
||||||
try:
|
try:
|
||||||
yield extract_token(self.wallet_address, t)
|
yield extract_token(stream_slice['name'], t)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error('Dropping token not valid %s' % t )
|
logger.error('Dropping token not valid %s' % t )
|
||||||
# Source
|
# Source
|
||||||
|
@ -74,10 +87,10 @@ class SourceWalletFetcher(AbstractSource):
|
||||||
# TODO remove the authenticator if not required.
|
# TODO remove the authenticator if not required.
|
||||||
tokens: List[Token] = []
|
tokens: List[Token] = []
|
||||||
|
|
||||||
for wallet in config["wallets"]:
|
# for wallet in config["wallets"]:
|
||||||
tokens.append(
|
# tokens.append(
|
||||||
Token(
|
# Token(
|
||||||
wallet_address=wallet['address'],
|
# wallet_address=wallet['address'],
|
||||||
)
|
# )
|
||||||
)
|
# )
|
||||||
return tokens
|
return [Token(wallets=config['wallets'])]
|
||||||
|
|
Loading…
Reference in New Issue