Skip to content

Commit

Permalink
Handle failed requests from Faucet client and timeouts in TransferCoi…
Browse files Browse the repository at this point in the history
…nExample
  • Loading branch information
kPatch committed Feb 15, 2023
1 parent db2f31f commit d36df2d
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,20 @@ IEnumerator RunTransferCoinExample()
string faucetEndpoint = "https://faucet.devnet.aptoslabs.com";

#region Fund Alice Account Through Devnet Faucet
Coroutine fundAliceAccountCor = StartCoroutine(FaucetClient.Instance.FundAccount((success, returnResult) =>
bool success = false;
responseInfo = new ResponseInfo();
Coroutine fundAliceAccountCor = StartCoroutine(FaucetClient.Instance.FundAccount((_success, _responseInfo) =>
{
Debug.Log("Faucet Response: " + returnResult);
success = _success;
responseInfo = _responseInfo;
}, aliceAddress.ToString(), 100000000, faucetEndpoint));
yield return fundAliceAccountCor;

if (responseInfo.status != ResponseInfo.Status.Success)
{
Debug.LogError("Faucet funding for Alice failed: " + responseInfo.message);
yield break;
}
#endregion

#region Get Alice Account Balance After Funding
Expand All @@ -116,11 +125,20 @@ IEnumerator RunTransferCoinExample()
#endregion

#region Fund Bob Account Through Devnet Faucet
Coroutine fundBobAccountCor = StartCoroutine(FaucetClient.Instance.FundAccount((success, returnResult) =>
success = false;
responseInfo = new ResponseInfo();
Coroutine fundBobAccountCor = StartCoroutine(FaucetClient.Instance.FundAccount((_success, _responseInfo) =>
{
Debug.Log("Faucet Response: " + returnResult);
success = _success;
responseInfo = _responseInfo;
}, bobAddress.ToString(), 100000000, faucetEndpoint));
yield return fundBobAccountCor;

if (responseInfo.status != ResponseInfo.Status.Success)
{
Debug.LogError("Faucet funding for Bob failed: " + responseInfo.message);
yield break;
}
#endregion

#region Get Bob Account Balance After Funding
Expand Down

0 comments on commit d36df2d

Please sign in to comment.