deleteAccount method
Deletes account recovery registration.
Permanently removes the account's recovery configuration. This operation is irrecoverable and should be used with caution.
Parameters:
addressStellar account address to deletejwtAuthentication token from SEP-10
Returns final account response before deletion.
Throws:
- SEP30BadRequestResponseException on invalid request (HTTP 400)
- SEP30UnauthorizedResponseException on authentication failure (HTTP 401)
- SEP30NotFoundResponseException if account not found (HTTP 404)
- SEP30ConflictResponseException on deletion conflict (HTTP 409)
- SEP30UnknownResponseException on other HTTP errors
See: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0030.md#delete-accountsaddress
Implementation
Future<SEP30AccountResponse> deleteAccount(String address, String jwt) async {
Uri requestURI =
Util.appendEndpointToUrl(_serviceAddress, 'accounts/$address');
Map<String, String> headers = {...(this.httpRequestHeaders ?? {})};
headers["Authorization"] = "Bearer " + jwt;
headers.putIfAbsent("Content-Type", () => "application/json");
SEP30AccountResponse result =
await httpClient.delete(requestURI, headers: headers).then((response) {
switch (response.statusCode) {
case 200:
return SEP30AccountResponse.fromJson(json.decode(response.body));
case 400:
throw SEP30BadRequestResponseException(
errorFromResponseBody(response.body));
case 401:
throw SEP30UnauthorizedResponseException(
errorFromResponseBody(response.body));
case 404:
throw SEP30NotFoundResponseException(
errorFromResponseBody(response.body));
case 409:
throw SEP30ConflictResponseException(
errorFromResponseBody(response.body));
default:
throw new SEP30UnknownResponseException(
response.statusCode, response.body);
}
}).catchError((onError) {
throw onError;
});
return result;
}