Skip to content

Commit

Permalink
feat(deployment): sign same wallet transactions in a batch
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrishajev committed Dec 12, 2024
1 parent 30f5f30 commit d5917c8
Showing 1 changed file with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,27 @@ export class StaleManagedDeploymentsCleanerService {
createdHeight: currentHeight - this.MAX_LIVE_BLOCKS
});

const closeAllWalletStaleDeployments = deployments.map(async deployment => {
const message = this.rpcMessageService.getCloseDeploymentMsg(wallet.address, deployment.dseq);
this.logger.info({ event: "DEPLOYMENT_CLEAN_UP", params: { owner: wallet.address, dseq: deployment.dseq } });
const messages = deployments.map(deployment => this.rpcMessageService.getCloseDeploymentMsg(wallet.address, deployment.dseq));

try {
await client.signAndBroadcast([message]);
this.logger.info({ event: "DEPLOYMENT_CLEAN_UP_SUCCESS" });
} catch (error) {
if (error.message.includes("not allowed to pay fees")) {
await this.managedUserWalletService.authorizeSpending({
address: wallet.address,
limits: {
fees: this.config.FEE_ALLOWANCE_REFILL_AMOUNT
}
});
this.logger.info({ event: "DEPLOYMENT_CLEAN_UP", owner: wallet.address });

await client.signAndBroadcast([message]);
this.logger.info({ event: "DEPLOYMENT_CLEAN_UP_SUCCESS" });
} else {
throw error;
}
}
});
try {
await client.signAndBroadcast(messages);
this.logger.info({ event: "DEPLOYMENT_CLEAN_UP_SUCCESS", owner: wallet.address });
} catch (error) {
if (error.message.includes("not allowed to pay fees")) {
await this.managedUserWalletService.authorizeSpending({
address: wallet.address,
limits: {
fees: this.config.FEE_ALLOWANCE_REFILL_AMOUNT
}
});

await Promise.all(closeAllWalletStaleDeployments);
await client.signAndBroadcast(messages);
this.logger.info({ event: "DEPLOYMENT_CLEAN_UP_SUCCESS", owner: wallet.address });
} else {
throw error;
}
}
}
}

0 comments on commit d5917c8

Please sign in to comment.