-
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.
Adds wallet management to studio app
- Loading branch information
1 parent
39a9e3e
commit 622ffd7
Showing
42 changed files
with
581 additions
and
218 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
import { RewardCoin, Wallet } from '@thxnetwork/api/models'; | ||
import RewardCoinService from '@thxnetwork/api/services/RewardCoinService'; | ||
import { Wallet } from '@thxnetwork/api/models'; | ||
import SafeService from '@thxnetwork/api/services/SafeService'; | ||
import { PromiseParser } from '@thxnetwork/api/util'; | ||
import { WalletVariant } from '@thxnetwork/common/enums'; | ||
|
||
export default async function main() { | ||
// const reward = await RewardCoin.findById('669126e1110e00291909e0e3'); // Polygon Reward | ||
// const reward = await RewardCoin.findById('66952d939a90f7280b2d3164'); // Linea Reward | ||
const reward = await RewardCoin.findById('6698033a03bf2db6c9a940f1'); // Linea Reward | ||
const wallet = await Wallet.findById('669805738c683b6c4c506e97'); | ||
const service = new RewardCoinService(); | ||
const wallet = await Wallet.find({ variant: WalletVariant.Safe, poolId: { $exists: true } }); | ||
const chunkSize = 10; | ||
|
||
await service.createPayment({ | ||
reward, | ||
wallet, | ||
}); | ||
for (let i = 0; i < wallet.length; i += chunkSize) { | ||
await PromiseParser.parse( | ||
wallet.slice(i, i + chunkSize).map(async (w) => { | ||
const safe = await SafeService.getSafe(w); | ||
const owners = await safe.getOwners(); | ||
|
||
await w.updateOne({ owners }); | ||
}), | ||
); | ||
} | ||
} |
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
6 changes: 3 additions & 3 deletions
6
apps/api/src/app/controllers/pools/wallets/delete.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
13 changes: 4 additions & 9 deletions
13
apps/api/src/app/controllers/pools/wallets/list.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
17 changes: 11 additions & 6 deletions
17
apps/api/src/app/controllers/pools/wallets/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
10 changes: 5 additions & 5 deletions
10
apps/api/src/app/controllers/pools/wallets/wallets.router.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,13 +1,13 @@ | ||
import { assertRequestInput } from '@thxnetwork/api/middlewares'; | ||
import express from 'express'; | ||
import { assertRequestInput, assertPoolAccess } from '@thxnetwork/api/middlewares'; | ||
import * as RemoveWallets from './delete.controller'; | ||
import * as ListWallets from './list.controller'; | ||
import * as CreateWallets from './post.controller'; | ||
import * as RemoveWallets from './delete.controller'; | ||
|
||
const router: express.Router = express.Router({ mergeParams: true }); | ||
|
||
router.get('/', assertPoolAccess, assertRequestInput(ListWallets.validation), ListWallets.controller); | ||
router.post('/', assertPoolAccess, assertRequestInput(CreateWallets.validation), CreateWallets.controller); | ||
router.delete('/:walletId', assertPoolAccess, assertRequestInput(RemoveWallets.validation), RemoveWallets.controller); | ||
router.get('/', assertRequestInput(ListWallets.validation), ListWallets.controller); | ||
router.post('/', assertRequestInput(CreateWallets.validation), CreateWallets.controller); | ||
router.delete('/:walletId', assertRequestInput(RemoveWallets.validation), RemoveWallets.controller); | ||
|
||
export default router; |
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.