Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions modules/express/src/clientRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -968,11 +968,13 @@ async function handleV2SendMany(req: express.Request) {
* - send/broadcast transaction
* @param req where req.body is {@link PrebuildAndSignTransactionOptions}
*/
export async function handleV2PrebuildAndSignTransaction(req: express.Request): Promise<SignedTransactionRequest> {
export async function handleV2PrebuildAndSignTransaction(
req: ExpressApiRouteRequest<'express.v2.wallet.prebuildandsigntransaction', 'post'>
): Promise<SignedTransactionRequest> {
const bitgo = req.bitgo;
const coin = bitgo.coin(req.params.coin);
const coin = bitgo.coin(req.decoded.coin);
const reqId = new RequestTracer();
const wallet = await coin.wallets().get({ id: req.params.id, reqId });
const wallet = await coin.wallets().get({ id: req.decoded.id, reqId });
req.body.reqId = reqId;
let result;
try {
Expand Down Expand Up @@ -1640,12 +1642,10 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
// send transaction
app.post('/api/v2/:coin/wallet/:id/sendcoins', parseBody, prepareBitGo(config), promiseWrapper(handleV2SendOne));
app.post('/api/v2/:coin/wallet/:id/sendmany', parseBody, prepareBitGo(config), promiseWrapper(handleV2SendMany));
app.post(
'/api/v2/:coin/wallet/:id/prebuildAndSignTransaction',
parseBody,
router.post('express.v2.wallet.prebuildandsigntransaction', [
prepareBitGo(config),
promiseWrapper(handleV2PrebuildAndSignTransaction)
);
typedPromiseWrapper(handleV2PrebuildAndSignTransaction),
]);

// token enablement
app.post(
Expand Down
10 changes: 7 additions & 3 deletions modules/express/src/typedRoutes/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { PostShareWallet } from './v2/shareWallet';
import { PutExpressWalletUpdate } from './v2/expressWalletUpdate';
import { PostFanoutUnspents } from './v2/fanoutUnspents';
import { PostConsolidateUnspents } from './v2/consolidateunspents';
import { PostPrebuildAndSignTransaction } from './v2/prebuildAndSignTransaction';
import { PostCoinSign } from './v2/coinSign';

// Too large types can cause the following error
Expand Down Expand Up @@ -109,10 +110,13 @@ export const ExpressV1PendingApprovalsApiSpec = apiSpec({
},
});

export const ExpressV1WalletSignTransactionApiSpec = apiSpec({
export const ExpressWalletSignTransactionApiSpec = apiSpec({
'express.v1.wallet.signTransaction': {
post: PostSignTransaction,
},
'express.v2.wallet.prebuildandsigntransaction': {
post: PostPrebuildAndSignTransaction,
},
});

export const ExpressV1KeychainDeriveApiSpec = apiSpec({
Expand Down Expand Up @@ -240,7 +244,7 @@ export type ExpressApi = typeof ExpressPingApiSpec &
typeof ExpressV1WalletAcceptShareApiSpec &
typeof ExpressV1WalletSimpleCreateApiSpec &
typeof ExpressV1PendingApprovalsApiSpec &
typeof ExpressV1WalletSignTransactionApiSpec &
typeof ExpressWalletSignTransactionApiSpec &
typeof ExpressV1KeychainDeriveApiSpec &
typeof ExpressV1KeychainLocalApiSpec &
typeof ExpressV1PendingApprovalConstructTxApiSpec &
Expand Down Expand Up @@ -270,7 +274,7 @@ export const ExpressApi: ExpressApi = {
...ExpressV1WalletAcceptShareApiSpec,
...ExpressV1WalletSimpleCreateApiSpec,
...ExpressV1PendingApprovalsApiSpec,
...ExpressV1WalletSignTransactionApiSpec,
...ExpressWalletSignTransactionApiSpec,
...ExpressV1KeychainDeriveApiSpec,
...ExpressV1KeychainLocalApiSpec,
...ExpressV1PendingApprovalConstructTxApiSpec,
Expand Down
Loading