Skip to content

Commit 7abc5ce

Browse files
committed
feat(express): migrated sendmany as type route
Ticket: WP-5427
1 parent d98cc3f commit 7abc5ce

File tree

4 files changed

+1327
-4
lines changed

4 files changed

+1327
-4
lines changed

modules/express/src/clientRoutes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -935,11 +935,11 @@ async function handleV2SendOne(req: express.Request) {
935935
* handle send many
936936
* @param req
937937
*/
938-
async function handleV2SendMany(req: express.Request) {
938+
async function handleV2SendMany(req: ExpressApiRouteRequest<'express.v2.wallet.sendmany', 'post'>) {
939939
const bitgo = req.bitgo;
940-
const coin = bitgo.coin(req.params.coin);
940+
const coin = bitgo.coin(req.decoded.coin);
941941
const reqId = new RequestTracer();
942-
const wallet = await coin.wallets().get({ id: req.params.id, reqId });
942+
const wallet = await coin.wallets().get({ id: req.decoded.id, reqId });
943943
req.body.reqId = reqId;
944944
let result;
945945
try {
@@ -1639,7 +1639,7 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
16391639

16401640
// send transaction
16411641
app.post('/api/v2/:coin/wallet/:id/sendcoins', parseBody, prepareBitGo(config), promiseWrapper(handleV2SendOne));
1642-
app.post('/api/v2/:coin/wallet/:id/sendmany', parseBody, prepareBitGo(config), promiseWrapper(handleV2SendMany));
1642+
router.post('express.v2.wallet.sendmany', [prepareBitGo(config), typedPromiseWrapper(handleV2SendMany)]);
16431643
app.post(
16441644
'/api/v2/:coin/wallet/:id/prebuildAndSignTransaction',
16451645
parseBody,

modules/express/src/typedRoutes/api/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { PostWalletTxSignTSS } from './v2/walletTxSignTSS';
3434
import { PostShareWallet } from './v2/shareWallet';
3535
import { PutExpressWalletUpdate } from './v2/expressWalletUpdate';
3636
import { PostFanoutUnspents } from './v2/fanoutUnspents';
37+
import { PostSendMany } from './v2/sendmany';
3738
import { PostConsolidateUnspents } from './v2/consolidateunspents';
3839
import { PostCoinSign } from './v2/coinSign';
3940

@@ -157,6 +158,12 @@ export const ExpressV2WalletCreateAddressApiSpec = apiSpec({
157158
},
158159
});
159160

161+
export const ExpressV2WalletSendManyApiSpec = apiSpec({
162+
'express.v2.wallet.sendmany': {
163+
post: PostSendMany,
164+
},
165+
});
166+
160167
export const ExpressKeychainLocalApiSpec = apiSpec({
161168
'express.keychain.local': {
162169
post: PostKeychainLocal,
@@ -252,6 +259,7 @@ export type ExpressApi = typeof ExpressPingApiSpec &
252259
typeof ExpressLightningGetStateApiSpec &
253260
typeof ExpressLightningInitWalletApiSpec &
254261
typeof ExpressLightningUnlockWalletApiSpec &
262+
typeof ExpressV2WalletSendManyApiSpec &
255263
typeof ExpressOfcSignPayloadApiSpec &
256264
typeof ExpressWalletRecoverTokenApiSpec &
257265
typeof ExpressCoinSigningApiSpec &
@@ -282,6 +290,7 @@ export const ExpressApi: ExpressApi = {
282290
...ExpressLightningGetStateApiSpec,
283291
...ExpressLightningInitWalletApiSpec,
284292
...ExpressLightningUnlockWalletApiSpec,
293+
...ExpressV2WalletSendManyApiSpec,
285294
...ExpressOfcSignPayloadApiSpec,
286295
...ExpressWalletRecoverTokenApiSpec,
287296
...ExpressCoinSigningApiSpec,

0 commit comments

Comments
 (0)