Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stargate #2613

Merged
merged 69 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
048023a
Get balance
MissingNO57 Aug 10, 2021
e4031de
Removed unsafe functions
MissingNO57 Aug 10, 2021
8061e8c
lint fix
MissingNO57 Aug 10, 2021
d3ffd2f
Account query
MissingNO57 Aug 11, 2021
53247bf
Addresses fix
MissingNO57 Aug 11, 2021
51cff2a
Faucet fix
MissingNO57 Aug 11, 2021
fae8cd1
aea config
MissingNO57 Aug 11, 2021
f3977d6
account number and sequence fix
MissingNO57 Aug 11, 2021
6d6964a
tx generation
MissingNO57 Aug 11, 2021
a74f5b6
Txs
MissingNO57 Aug 11, 2021
34d9758
signing
MissingNO57 Aug 11, 2021
5028353
deploy init
MissingNO57 Aug 12, 2021
9d11753
Fix
MissingNO57 Aug 12, 2021
976b16c
fixes
MissingNO57 Aug 12, 2021
5f81a9d
execute
MissingNO57 Aug 12, 2021
2139320
removed unused functions
MissingNO57 Aug 12, 2021
46a2980
More fixed functions
MissingNO57 Aug 12, 2021
85e1ff2
fixes
MissingNO57 Aug 13, 2021
4aaa4b0
Some tests fixed
MissingNO57 Aug 13, 2021
d9c0fc0
FIxed tests
MissingNO57 Aug 13, 2021
529352c
Fixed tests
MissingNO57 Aug 13, 2021
e4fa462
fixed tests
MissingNO57 Aug 13, 2021
b1286b0
fixed tests
MissingNO57 Aug 13, 2021
df46224
Fixed tests
MissingNO57 Aug 13, 2021
96f00e2
Some fixes
MissingNO57 Aug 20, 2021
356b0f3
fixes
MissingNO57 Aug 20, 2021
fd5686f
tests aded
MissingNO57 Aug 20, 2021
8b54b48
arcturus
MissingNO57 Aug 20, 2021
bd4c383
Configs fixed
MissingNO57 Aug 23, 2021
77d3631
Fetchd image fix
MissingNO57 Aug 23, 2021
a4731c0
cosmpy
MissingNO57 Aug 23, 2021
cc4418e
resolved comments
MissingNO57 Aug 23, 2021
c11d0d9
Added dependencies
MissingNO57 Aug 23, 2021
9a51396
Fixes
MissingNO57 Aug 23, 2021
c8a61ae
Pipfile fix
MissingNO57 Aug 23, 2021
d311129
Checks fixes
MissingNO57 Aug 23, 2021
f560d30
Updated cosmpy to 0.1.3
MissingNO57 Aug 24, 2021
083d26d
Updated erc1155 contract to cw0.14
MissingNO57 Aug 24, 2021
6091391
Cosmpy version updated
MissingNO57 Aug 26, 2021
df2bd0a
Hashes update
MissingNO57 Aug 26, 2021
3390c8d
fixes
MissingNO57 Aug 27, 2021
6012504
more fixes
MissingNO57 Aug 27, 2021
17cc3ed
Funding fix
MissingNO57 Aug 27, 2021
0233b05
Test fixes
MissingNO57 Aug 27, 2021
36f2008
More tests fixed
MissingNO57 Aug 27, 2021
27df13e
Added get wealth timeout
MissingNO57 Aug 27, 2021
4c378e0
Improvements
MissingNO57 Aug 31, 2021
d2d49ee
get wealth moved
MissingNO57 Aug 31, 2021
3a67344
Removed rust
MissingNO57 Aug 31, 2021
d0087aa
Pipfile fix
MissingNO57 Aug 31, 2021
9d95d92
address ipfs cli command tests
5A11 Aug 31, 2021
0b508bb
Merge branch 'feature/queries' of https://github.com/fetchai/agents-a…
5A11 Aug 31, 2021
bbbf34f
fix: cleanup docs and fix docs related test
5A11 Aug 31, 2021
d062dab
cleanup: reuse get_wealth_if_needed
5A11 Aug 31, 2021
9988970
feat: update oracle contracts for cosmwasm 14
jrriehl Aug 31, 2021
89c6cbd
chore: update entrypoint lines
jrriehl Aug 31, 2021
e374c0a
chore: uncomment code
jrriehl Aug 31, 2021
6180fea
chore: generate ipfs hashes
jrriehl Aug 31, 2021
c7c46fb
pull latest develop
5A11 Sep 1, 2021
33815a4
hashes
5A11 Sep 1, 2021
c744a76
add ipfs installation to tox
5A11 Sep 1, 2021
fba58e2
Flaky test fix
MissingNO57 Sep 1, 2021
6befa3d
fix: change ports and private key
jrriehl Sep 2, 2021
411a8db
chore: update oracle contract binary
jrriehl Sep 2, 2021
fe921dd
fix: send 1 atestfet and update oracle client contract binary
jrriehl Sep 3, 2021
c8904db
chore: lint and hashes
jrriehl Sep 3, 2021
4fa28ea
Merge pull request #2609 from fetchai/fix/oracle-update
5A11 Sep 3, 2021
16d975d
fix: oracle handler test failure
5A11 Sep 3, 2021
3ded31f
Merge pull request #2593 from fetchai/feature/queries
5A11 Sep 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Faucet fix
  • Loading branch information
MissingNO57 committed Aug 11, 2021
commit 51cff2af5d3d26df3a7a3b0521e157ad70f463dd
62 changes: 30 additions & 32 deletions plugins/aea-ledger-cosmos/aea_ledger_cosmos/cosmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
from cosm.bank.rest_client import BankRestClient, QueryBalanceRequest
from cosm.common.rest_client import RestClient
from cosm.wasm.rest_client import WasmRestClient
from cosmos.auth.v1beta1.auth_pb2 import BaseAccount
from cosmos.auth.v1beta1.query_pb2 import QueryAccountRequest
from cosmwasm.wasm.v1beta1.query_pb2 import QuerySmartContractStateRequest
from ecdsa import ( # type: ignore # pylint: disable=wrong-import-order
Expand Down Expand Up @@ -222,7 +221,11 @@ def get_code_id(tx_receipt: JSONLike) -> Optional[int]:
"""
code_id: Optional[int] = None
try:
res = [dic_["value"] for dic_ in tx_receipt["logs"][0]["events"][0]["attributes"] if dic_["key"] == "code_id"] # type: ignore
res = [
dic_["value"]
for dic_ in tx_receipt["logs"][0]["events"][0]["attributes"]
if dic_["key"] == "code_id"
] # type: ignore
code_id = int(res[0])
except (KeyError, IndexError): # pragma: nocover
code_id = None
Expand All @@ -238,7 +241,11 @@ def get_contract_address(tx_receipt: JSONLike) -> Optional[str]:
"""
contract_address: Optional[str] = None
try:
res = [dic_["value"] for dic_ in tx_receipt["logs"][0]["events"][0]["attributes"] if dic_["key"] == "contract_address"] # type: ignore
res = [
dic_["value"]
for dic_ in tx_receipt["logs"][0]["events"][0]["attributes"]
if dic_["key"] == "contract_address"
] # type: ignore
contract_address = res[0]
except (KeyError, IndexError): # pragma: nocover
contract_address = None
Expand Down Expand Up @@ -1087,14 +1094,8 @@ def _try_get_account_number_and_sequence(
:return: a tuple of account number and sequence
"""
auth = AuthRestClient(self.rest_client)
account_response = auth.Account(QueryAccountRequest(address=address))
account = BaseAccount()
if account_response.account.Is(BaseAccount.DESCRIPTOR):
account_response.account.Unpack(account)
else:
raise TypeError("Unexpected account type")

return account.account_number, account.sequence
res = auth.Account(QueryAccountRequest(address=address))
return res

def send_signed_transaction(self, tx_signed: JSONLike) -> Optional[str]:
"""
Expand Down Expand Up @@ -1255,23 +1256,17 @@ class CosmosApi(_CosmosApi, CosmosHelper):
class CosmosFaucetStatus:
tx_digest: Optional[str]
status: str
status_code: int
"""
CosmosFaucetStatus = namedtuple(
"CosmosFaucetStatus", ["tx_digest", "status", "status_code"]
)
CosmosFaucetStatus = namedtuple("CosmosFaucetStatus", ["tx_digest", "status"])


class CosmosFaucetApi(FaucetApi):
"""Cosmos testnet faucet API."""

FAUCET_STATUS_PENDING = 1 # noqa: F841
FAUCET_STATUS_PROCESSING = 2 # noqa: F841
FAUCET_STATUS_COMPLETED = 20 # noqa: F841
FAUCET_STATUS_FAILED = 21 # noqa: F841
FAUCET_STATUS_TIMED_OUT = 22 # noqa: F841
FAUCET_STATUS_RATE_LIMITED = 23 # noqa: F841
FAUCET_STATUS_RATE_UNAVAILABLE = 99 # noqa: F841
FAUCET_STATUS_PENDING = "pending" # noqa: F841
FAUCET_STATUS_PROCESSING = "processing" # noqa: F841
FAUCET_STATUS_COMPLETED = "complete" # noqa: F841
FAUCET_STATUS_FAILED = "failed" # noqa: F841

identifier = _COSMOS
testnet_faucet_url = DEFAULT_FAUCET_URL
Expand Down Expand Up @@ -1304,11 +1299,14 @@ def get_wealth(self, address: Address, url: Optional[str] = None) -> None:
raise RuntimeError("Failed to check faucet claim status")

# if the status is complete
if status.status_code == self.FAUCET_STATUS_COMPLETED:
if status.status == self.FAUCET_STATUS_COMPLETED:
break

# if the status is failure
if status.status_code > self.FAUCET_STATUS_COMPLETED: # pragma: nocover
if (
status.status != self.FAUCET_STATUS_PENDING
and status.status != self.FAUCET_STATUS_PROCESSING
): # pragma: nocover
raise RuntimeError(f"Failed to get wealth for {address}")

# if the status is incomplete
Expand All @@ -1332,12 +1330,12 @@ def _try_create_faucet_claim(
:return: None on failure, otherwise the request uid
"""
uri = cls._faucet_request_uri(url)
response = requests.post(url=uri, data={"Address": address})
response = requests.post(url=uri, json={"address": address})

uid = None
if response.status_code == 200:
try:
uid = response.json()["uid"]
uid = response.json()["uuid"]
except KeyError: # pragma: nocover
ValueError(f"key `uid` not found in response_json={response.json()}")
_default_logger.info("Wealth claim generated, uid: {}".format(uid))
Expand Down Expand Up @@ -1372,11 +1370,11 @@ def _try_check_faucet_claim(

# parse the response
data = response.json()
return CosmosFaucetStatus(
tx_digest=data.get("txDigest"),
status=data["status"],
status_code=data["statusCode"],
)
tx_digest = None
if "txStatus" in data["claim"]:
tx_digest = data["claim"]["txStatus"]["hash"]

return CosmosFaucetStatus(tx_digest=tx_digest, status=data["claim"]["status"],)

@classmethod
def _faucet_request_uri(cls, url: Optional[str] = None) -> str:
Expand All @@ -1389,7 +1387,7 @@ def _faucet_request_uri(cls, url: Optional[str] = None) -> str:
if cls.testnet_faucet_url is None: # pragma: nocover
raise ValueError("Testnet faucet url not set.")
url = cls.testnet_faucet_url if url is None else url
return f"{url}/claim/requests"
return f"{url}/api/v3/claims"

@classmethod
def _faucet_status_uri(cls, uid: str, url: Optional[str] = None) -> str:
Expand Down
49 changes: 27 additions & 22 deletions plugins/aea-ledger-fetchai/aea_ledger_fetchai/_cosmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ def get_code_id(tx_receipt: JSONLike) -> Optional[int]:
"""
code_id: Optional[int] = None
try:
res = [dic_["value"] for dic_ in tx_receipt["logs"][0]["events"][0]["attributes"] if dic_["key"] == "code_id"] # type: ignore
res = [
dic_["value"]
for dic_ in tx_receipt["logs"][0]["events"][0]["attributes"]
if dic_["key"] == "code_id"
] # type: ignore
code_id = int(res[0])
except (KeyError, IndexError): # pragma: nocover
code_id = None
Expand All @@ -237,7 +241,11 @@ def get_contract_address(tx_receipt: JSONLike) -> Optional[str]:
"""
contract_address: Optional[str] = None
try:
res = [dic_["value"] for dic_ in tx_receipt["logs"][0]["events"][0]["attributes"] if dic_["key"] == "contract_address"] # type: ignore
res = [
dic_["value"]
for dic_ in tx_receipt["logs"][0]["events"][0]["attributes"]
if dic_["key"] == "contract_address"
] # type: ignore
contract_address = res[0]
except (KeyError, IndexError): # pragma: nocover
contract_address = None
Expand Down Expand Up @@ -1248,23 +1256,17 @@ class CosmosApi(_CosmosApi, CosmosHelper):
class CosmosFaucetStatus:
tx_digest: Optional[str]
status: str
status_code: int
"""
CosmosFaucetStatus = namedtuple(
"CosmosFaucetStatus", ["tx_digest", "status", "status_code"]
)
CosmosFaucetStatus = namedtuple("CosmosFaucetStatus", ["tx_digest", "status"])


class CosmosFaucetApi(FaucetApi):
"""Cosmos testnet faucet API."""

FAUCET_STATUS_PENDING = 1 # noqa: F841
FAUCET_STATUS_PROCESSING = 2 # noqa: F841
FAUCET_STATUS_COMPLETED = 20 # noqa: F841
FAUCET_STATUS_FAILED = 21 # noqa: F841
FAUCET_STATUS_TIMED_OUT = 22 # noqa: F841
FAUCET_STATUS_RATE_LIMITED = 23 # noqa: F841
FAUCET_STATUS_RATE_UNAVAILABLE = 99 # noqa: F841
FAUCET_STATUS_PENDING = "pending" # noqa: F841
FAUCET_STATUS_PROCESSING = "processing" # noqa: F841
FAUCET_STATUS_COMPLETED = "complete" # noqa: F841
FAUCET_STATUS_FAILED = "failed" # noqa: F841

identifier = _COSMOS
testnet_faucet_url = DEFAULT_FAUCET_URL
Expand Down Expand Up @@ -1297,11 +1299,14 @@ def get_wealth(self, address: Address, url: Optional[str] = None) -> None:
raise RuntimeError("Failed to check faucet claim status")

# if the status is complete
if status.status_code == self.FAUCET_STATUS_COMPLETED:
if status.status == self.FAUCET_STATUS_COMPLETED:
break

# if the status is failure
if status.status_code > self.FAUCET_STATUS_COMPLETED: # pragma: nocover
if (
status.status != self.FAUCET_STATUS_PENDING
and status.status != self.FAUCET_STATUS_PROCESSING
): # pragma: nocover
raise RuntimeError(f"Failed to get wealth for {address}")

# if the status is incomplete
Expand All @@ -1325,12 +1330,12 @@ def _try_create_faucet_claim(
:return: None on failure, otherwise the request uid
"""
uri = cls._faucet_request_uri(url)
response = requests.post(url=uri, data={"Address": address})
response = requests.post(url=uri, json={"address": address})

uid = None
if response.status_code == 200:
try:
uid = response.json()["uid"]
uid = response.json()["uuid"]
except KeyError: # pragma: nocover
ValueError(f"key `uid` not found in response_json={response.json()}")
_default_logger.info("Wealth claim generated, uid: {}".format(uid))
Expand Down Expand Up @@ -1365,11 +1370,11 @@ def _try_check_faucet_claim(

# parse the response
data = response.json()
return CosmosFaucetStatus(
tx_digest=data.get("txDigest"),
status=data["status"],
status_code=data["statusCode"],
)
tx_digest = None
if "txStatus" in data["claim"]:
tx_digest = data["claim"]["txStatus"]["hash"]

return CosmosFaucetStatus(tx_digest=tx_digest, status=data["claim"]["status"],)

@classmethod
def _faucet_request_uri(cls, url: Optional[str] = None) -> str:
Expand Down