Unable to use warrant.aws_srp on ubuntu. Here is the code I use :
import boto3
from warrant.aws_srp import AWSSRP
import requests
import json
# Set up SRP authentication
client = boto3.client('cognito-idp', region_name='us-west-2')
aws = AWSSRP(username='YOUR_API_KEY', password='YOUR_API_SECRET', pool_id='YOUR_POOL_ID', client_id='YOUR_CLIENT_ID', client=client)
tokens = aws.authenticate_user()
# Get access token
access_token = tokens['AuthenticationResult']['AccessToken']
# Set up headers for the Defender API
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Api-Key': 'YOUR_API_KEY',
'Authorization': f'Bearer {access_token}',
}
# Set up the payload for the gasless transaction
payload = {
"from": "YOUR_RELAYER_ADDRESS",
"to": "YOUR_USER_PRIVATE_KEY",
"tokenAddress": "YOUR_TOKEN_ADDRESS",
"amount": "AMOUNT_TO_SEND",
"destination": "YOUR_DESTINATION_ADDRESS",
}
# Make the request to the Defender API
response = requests.post('http://api.defender.openzeppelin.com/relay', headers=headers, data=json.dumps(payload))
# Print the response
print(response.json())
Error code :
File "/home/ubuntu/transfer.py", line 2, in <module>
from warrant.aws_srp import AWSSRP
File "/home/ubuntu/.local/lib/python3.10/site-packages/warrant/__init__.py", line 8, in <module>
from jose import jwt, JWTError
File "/home/ubuntu/.local/lib/python3.10/site-packages/jose/jwt.py", line 11, in <module>
from jose import jws
File "/home/ubuntu/.local/lib/python3.10/site-packages/jose/jws.py", line 6, in <module>
from collections import Mapping, Iterable
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
I tried the following steps without success : https://stackoverflow.com/questions/69381312/in-vs-code-importerror-cannot-import-name-mapping-from-collections/69727802#69727802
Please help