Skip to content

Commit

Permalink
fix:Handle StakeRegistration on first proposal fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Sital999 committed Jan 6, 2025
1 parent 260cc08 commit 3d5138e
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 7 deletions.
4 changes: 2 additions & 2 deletions agent-manager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import environments from './config/environments'
const app = express()
const port = environments.serverPort

app.use('/health', healthCheck)
app.use('/blockfrost/health', blockfrostHealth)
app.use('/api/health', healthCheck)
app.use('/api/blockfrost/health', blockfrostHealth)

const server = app.listen(port, async () => {
console.log(`Server is running on http://localhost:${port}`)
Expand Down
16 changes: 15 additions & 1 deletion agent-node/src/functions/noConfidence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,19 @@ export default async function handler(context: FunctionContext, anchor: any) {
},
],
}
return await context.wallet.buildAndSubmit(req)
return await context.wallet.buildAndSubmit(req).catch(async (e) => {
if (e.includes('ProposalReturnAccountDoesNotExist')) {
await context.builtins.registerStake().catch((e) => {
throw e
})
return context.wallet
.buildAndSubmit(req)
.then((v) => v)
.catch((e) => {
throw e
})
} else {
throw e
}
})
}
16 changes: 14 additions & 2 deletions agent-node/src/functions/proposalNewConstitution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,19 @@ export default async function handler(
return await context.wallet
.buildAndSubmit(req, true)
.then((v) => v)
.catch((e) => {
throw e
.catch(async(e) => {
if (e.includes('ProposalReturnAccountDoesNotExist')) {
await context.builtins.registerStake().catch((e) => {
throw e
})
return context.wallet
.buildAndSubmit(req)
.then((v) => v)
.catch((e) => {
throw e
})
} else {
throw e
}
})
}
16 changes: 15 additions & 1 deletion agent-node/src/functions/treasuryWithdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,19 @@ export default async function handler(
},
],
}
return await context.wallet.buildAndSubmit(req, false)
return await context.wallet.buildAndSubmit(req, false).catch(async(e)=>{
if (e.includes('ProposalReturnAccountDoesNotExist')) {
await context.builtins.registerStake().catch((e) => {
throw e
})
return context.wallet
.buildAndSubmit(req)
.then((v) => v)
.catch((e) => {
throw e
})
} else {
throw e
}
})
}
16 changes: 15 additions & 1 deletion agent-node/src/functions/updateCommittee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,19 @@ export default async function handler(
},
],
}
return await context.wallet.buildAndSubmit(req, false)
return await context.wallet.buildAndSubmit(req, false).catch(async (e) => {
if (e.includes('ProposalReturnAccountDoesNotExist')) {
await context.builtins.registerStake().catch((e) => {
throw e
})
return context.wallet
.buildAndSubmit(req)
.then((v) => v)
.catch((e) => {
throw e
})
} else {
throw e
}
})
}
Empty file.

0 comments on commit 3d5138e

Please sign in to comment.