-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dependencies to single Safe pools and auto deployment upon cam…
…paign creation
- Loading branch information
1 parent
6c5876d
commit 416efad
Showing
22 changed files
with
99 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 1 addition & 9 deletions
10
apps/api/src/app/controllers/pools/duplicate/post.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,21 @@ | ||
import { param } from 'express-validator'; | ||
import { Request, Response } from 'express'; | ||
import { safeVersion } from '@thxnetwork/api/services/ContractService'; | ||
import { Pool } from '@thxnetwork/api/models'; | ||
import PoolService from '@thxnetwork/api/services/PoolService'; | ||
import SafeService from '@thxnetwork/api/services/SafeService'; | ||
|
||
const validation = [param('id').isMongoId()]; | ||
|
||
const controller = async (req: Request, res: Response) => { | ||
const pool = await Pool.findById(req.params.id); | ||
|
||
const duplicatePool = await PoolService.deploy(req.auth.sub, `${pool.settings.title} (clone)`); | ||
|
||
// Deploy a Safe for the campaign | ||
const safe = await SafeService.create({ sub: req.auth.sub, safeVersion, poolId: duplicatePool.id }); | ||
// Update predicted safe address for pool | ||
await pool.updateOne({ safeAddress: safe.address }); | ||
|
||
// Duplicate Quests | ||
// TODO | ||
|
||
// Duplicate Rewards | ||
// TODO | ||
|
||
res.status(201).json({ ...duplicatePool.toJSON(), safeAddress: safe.address, safe }); | ||
res.status(201).json(duplicatePool.toJSON()); | ||
}; | ||
|
||
export { controller, validation }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,14 @@ | ||
import { Request, Response } from 'express'; | ||
import { body } from 'express-validator'; | ||
import { safeVersion } from '@thxnetwork/api/services/ContractService'; | ||
import PoolService from '@thxnetwork/api/services/PoolService'; | ||
import SafeService from '@thxnetwork/api/services/SafeService'; | ||
|
||
const validation = [body('settings.title').optional().isString().trim().escape().isLength({ max: 50 })]; | ||
|
||
const controller = async (req: Request, res: Response) => { | ||
const { title } = req.body; | ||
const pool = await PoolService.deploy(req.auth.sub, title || 'My Quest Campaign'); | ||
|
||
// Deploy a Safe for the campaign | ||
const poolId = String(pool._id); | ||
const safe = await SafeService.create({ sub: req.auth.sub, safeVersion, poolId }); | ||
|
||
// Update predicted safe address for pool | ||
await pool.updateOne({ safeAddress: safe.address }); | ||
|
||
res.status(201).json({ ...pool.toJSON(), safeAddress: safe.address, safe }); | ||
res.status(201).json(pool.toJSON()); | ||
}; | ||
|
||
export { controller, validation }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.