Fix handleApiReturn
This commit is contained in:
parent
33dbf552a6
commit
64775af683
@ -981,6 +981,23 @@ export class Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async handleApiReturn(apiReturn: ApiReturn) {
|
public async handleApiReturn(apiReturn: ApiReturn) {
|
||||||
|
// Check for errors in the returned objects
|
||||||
|
if (apiReturn.new_tx_to_send && apiReturn.new_tx_to_send.error) {
|
||||||
|
const error = apiReturn.new_tx_to_send.error;
|
||||||
|
const errorMessage = typeof error === 'object' && error !== null ?
|
||||||
|
(error as any).GenericError || JSON.stringify(error) :
|
||||||
|
String(error);
|
||||||
|
throw new Error(`Transaction error: ${errorMessage}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (apiReturn.commit_to_send && apiReturn.commit_to_send.error) {
|
||||||
|
const error = apiReturn.commit_to_send.error;
|
||||||
|
const errorMessage = typeof error === 'object' && error !== null ?
|
||||||
|
(error as any).GenericError || JSON.stringify(error) :
|
||||||
|
String(error);
|
||||||
|
throw new Error(`Commit error: ${errorMessage}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (apiReturn.partial_tx) {
|
if (apiReturn.partial_tx) {
|
||||||
try {
|
try {
|
||||||
const res = wasm.sign_transaction(apiReturn.partial_tx);
|
const res = wasm.sign_transaction(apiReturn.partial_tx);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user