Skip to content

Commit

Permalink
Merge pull request #147 from valory-xyz/tanya/handle-create-service-f…
Browse files Browse the repository at this point in the history
…ails

Handle createService failing correctly
  • Loading branch information
Tanya-atatakai authored May 28, 2024
2 parents 8a05ad1 + 10c2eca commit 48d7e81
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
15 changes: 9 additions & 6 deletions frontend/components/Main/MainHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ export const MainHeader = () => {
return ServicesService.createService({
serviceTemplate,
deploy: true,
}).then(() => {
setServiceStatus(DeploymentStatus.DEPLOYED);
setIsBalancePollingPaused(false);
setServiceButtonState(ServiceButtonLoadingState.NotLoading);
showNotification?.('Your agent is now running!');
});
})
.then(() => {
setServiceStatus(DeploymentStatus.DEPLOYED);
showNotification?.('Your agent is now running!');
})
.finally(() => {
setIsBalancePollingPaused(false);
setServiceButtonState(ServiceButtonLoadingState.NotLoading);
});
} catch (error) {
setIsBalancePollingPaused(false);
setServiceButtonState(ServiceButtonLoadingState.NotLoading);
Expand Down
31 changes: 19 additions & 12 deletions frontend/service/Services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,27 @@ const createService = async ({
serviceTemplate: ServiceTemplate;
deploy: boolean;
}): Promise<Service> =>
fetch(`${BACKEND_URL}/services`, {
method: 'POST',
body: JSON.stringify({
...serviceTemplate,
deploy,
configuration: {
...serviceTemplate.configuration,
rpc: `${process.env.GNOSIS_RPC}`,
new Promise((resolve, reject) =>
fetch(`${BACKEND_URL}/services`, {
method: 'POST',
body: JSON.stringify({
...serviceTemplate,
deploy,
configuration: {
...serviceTemplate.configuration,
rpc: `${process.env.GNOSIS_RPC}`,
},
}),
headers: {
'Content-Type': 'application/json',
},
}).then((response) => {
if (response.ok) {
resolve(response.json());
}
reject('Failed to create service');
}),
headers: {
'Content-Type': 'application/json',
},
}).then((response) => response.json());
);

const deployOnChain = async (serviceHash: ServiceHash): Promise<Deployment> =>
fetch(`${BACKEND_URL}/services/${serviceHash}/onchain/deploy`, {
Expand Down

0 comments on commit 48d7e81

Please sign in to comment.