Skip to content

Commit 6ef2483

Browse files
committed
feat(express): migrated sendmany as type route
Ticket: WP-5427
1 parent eb6bbc1 commit 6ef2483

File tree

4 files changed

+1942
-4
lines changed

4 files changed

+1942
-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 {
@@ -1641,7 +1641,7 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
16411641

16421642
// send transaction
16431643
app.post('/api/v2/:coin/wallet/:id/sendcoins', parseBody, prepareBitGo(config), promiseWrapper(handleV2SendOne));
1644-
app.post('/api/v2/:coin/wallet/:id/sendmany', parseBody, prepareBitGo(config), promiseWrapper(handleV2SendMany));
1644+
router.post('express.v2.wallet.sendmany', [prepareBitGo(config), typedPromiseWrapper(handleV2SendMany)]);
16451645
router.post('express.v2.wallet.prebuildandsigntransaction', [
16461646
prepareBitGo(config),
16471647
typedPromiseWrapper(handleV2PrebuildAndSignTransaction),

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 { PostPrebuildAndSignTransaction } from './v2/prebuildAndSignTransaction';
3940
import { PostCoinSign } from './v2/coinSign';
@@ -161,6 +162,12 @@ export const ExpressV2WalletCreateAddressApiSpec = apiSpec({
161162
},
162163
});
163164

165+
export const ExpressV2WalletSendManyApiSpec = apiSpec({
166+
'express.v2.wallet.sendmany': {
167+
post: PostSendMany,
168+
},
169+
});
170+
164171
export const ExpressKeychainLocalApiSpec = apiSpec({
165172
'express.keychain.local': {
166173
post: PostKeychainLocal,
@@ -256,6 +263,7 @@ export type ExpressApi = typeof ExpressPingApiSpec &
256263
typeof ExpressLightningGetStateApiSpec &
257264
typeof ExpressLightningInitWalletApiSpec &
258265
typeof ExpressLightningUnlockWalletApiSpec &
266+
typeof ExpressV2WalletSendManyApiSpec &
259267
typeof ExpressOfcSignPayloadApiSpec &
260268
typeof ExpressWalletRecoverTokenApiSpec &
261269
typeof ExpressCoinSigningApiSpec &
@@ -286,6 +294,7 @@ export const ExpressApi: ExpressApi = {
286294
...ExpressLightningGetStateApiSpec,
287295
...ExpressLightningInitWalletApiSpec,
288296
...ExpressLightningUnlockWalletApiSpec,
297+
...ExpressV2WalletSendManyApiSpec,
289298
...ExpressOfcSignPayloadApiSpec,
290299
...ExpressWalletRecoverTokenApiSpec,
291300
...ExpressCoinSigningApiSpec,

0 commit comments

Comments
 (0)