Skip to content

Commit 71b85c7

Browse files
authored
feat(express): migrated sendCoins to type route
2 parents 1321a91 + ed8125f commit 71b85c7

File tree

5 files changed

+1386
-7
lines changed

5 files changed

+1386
-7
lines changed

modules/express/src/clientRoutes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -911,11 +911,11 @@ function createTSSSendParams(req: express.Request, wallet: Wallet) {
911911
* handle send one
912912
* @param req
913913
*/
914-
async function handleV2SendOne(req: express.Request) {
914+
async function handleV2SendOne(req: ExpressApiRouteRequest<'express.v2.wallet.sendcoins', 'post'>) {
915915
const bitgo = req.bitgo;
916-
const coin = bitgo.coin(req.params.coin);
916+
const coin = bitgo.coin(req.decoded.coin);
917917
const reqId = new RequestTracer();
918-
const wallet = await coin.wallets().get({ id: req.params.id, reqId });
918+
const wallet = await coin.wallets().get({ id: req.decoded.id, reqId });
919919
req.body.reqId = reqId;
920920

921921
let result;
@@ -1640,7 +1640,7 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
16401640
router.post('express.v2.wallet.recovertoken', [prepareBitGo(config), typedPromiseWrapper(handleV2RecoverToken)]);
16411641

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

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { PostSendMany } from './v2/sendmany';
3838
import { PostConsolidateUnspents } from './v2/consolidateunspents';
3939
import { PostPrebuildAndSignTransaction } from './v2/prebuildAndSignTransaction';
4040
import { PostCoinSign } from './v2/coinSign';
41+
import { PostSendCoins } from './v2/sendCoins';
4142

4243
// Too large types can cause the following error
4344
//
@@ -168,6 +169,12 @@ export const ExpressV2WalletSendManyApiSpec = apiSpec({
168169
},
169170
});
170171

172+
export const ExpressV2WalletSendCoinsApiSpec = apiSpec({
173+
'express.v2.wallet.sendcoins': {
174+
post: PostSendCoins,
175+
},
176+
});
177+
171178
export const ExpressKeychainLocalApiSpec = apiSpec({
172179
'express.keychain.local': {
173180
post: PostKeychainLocal,
@@ -264,6 +271,7 @@ export type ExpressApi = typeof ExpressPingApiSpec &
264271
typeof ExpressLightningInitWalletApiSpec &
265272
typeof ExpressLightningUnlockWalletApiSpec &
266273
typeof ExpressV2WalletSendManyApiSpec &
274+
typeof ExpressV2WalletSendCoinsApiSpec &
267275
typeof ExpressOfcSignPayloadApiSpec &
268276
typeof ExpressWalletRecoverTokenApiSpec &
269277
typeof ExpressCoinSigningApiSpec &
@@ -295,6 +303,7 @@ export const ExpressApi: ExpressApi = {
295303
...ExpressLightningInitWalletApiSpec,
296304
...ExpressLightningUnlockWalletApiSpec,
297305
...ExpressV2WalletSendManyApiSpec,
306+
...ExpressV2WalletSendCoinsApiSpec,
298307
...ExpressOfcSignPayloadApiSpec,
299308
...ExpressWalletRecoverTokenApiSpec,
300309
...ExpressCoinSigningApiSpec,

0 commit comments

Comments
 (0)