Skip to content

Commit 2476345

Browse files
committed
chore: fix exports
1 parent dfd8f52 commit 2476345

File tree

6 files changed

+34
-43
lines changed

6 files changed

+34
-43
lines changed

src/api/routes/rosetta/construction.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ import { bitcoinToStacksAddress } from 'stacks-encoding-native-js';
5252
import { getCoreNodeEndpoint, StacksCoreRpcClient } from '../../../core-rpc/client';
5353
import { DbBlock } from '../../../datastore/common';
5454
import { PgStore } from '../../../datastore/pg-store';
55-
import { FoundOrNot, has0xPrefix, hexToBuffer, isValidC32Address } from '../../../helpers';
55+
import {
56+
doesThrow,
57+
FoundOrNot,
58+
has0xPrefix,
59+
hexToBuffer,
60+
isValidC32Address,
61+
} from '../../../helpers';
5662
import { asyncHandler } from '../../async-handler';
5763
import {
5864
RosettaConstants,
@@ -838,16 +844,6 @@ export function createRosettaConstructionRouter(db: PgStore, chainId: ChainID):
838844
return router;
839845
}
840846

841-
// todo: where do you prefer your helper methods?
842-
function doesThrow(fn: () => void) {
843-
try {
844-
fn();
845-
return false;
846-
} catch {
847-
return true;
848-
}
849-
}
850-
851847
// Middleware ==================================================================
852848
function makeValidationMiddleware(chainId: ChainID) {
853849
return asyncHandler(async function validationMiddleware(req, res, next) {

src/helpers.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,3 +1090,12 @@ export function parseEventTypeStrings(values: string[]): DbEventTypeId[] {
10901090
}
10911091
});
10921092
}
1093+
1094+
export function doesThrow(fn: () => void) {
1095+
try {
1096+
fn();
1097+
return false;
1098+
} catch {
1099+
return true;
1100+
}
1101+
}

src/test-utils/test-helpers.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
tupleCV,
3434
} from '@stacks/transactions';
3535
import { RPCClient } from 'rpc-bitcoin';
36+
import { getRosettaNetworkName, RosettaConstants } from '../api/rosetta-constants';
3637

3738
import {
3839
ClarityTypeID,
@@ -41,7 +42,6 @@ import {
4142
} from 'stacks-encoding-native-js';
4243
import * as supertest from 'supertest';
4344
import { ApiServer } from '../api/init';
44-
import { getRosettaNetworkName, RosettaConstants } from '../api/rosetta-constants';
4545
import { testnetKeys } from '../api/routes/debug';
4646
import { CoreRpcPoxInfo, StacksCoreRpcClient } from '../core-rpc/client';
4747
import { DbBlock, DbTx, DbTxStatus } from '../datastore/common';
@@ -211,7 +211,8 @@ export async function standByUntilBurnBlock(burnBlockHeight: number): Promise<Db
211211
return dbBlock;
212212
}
213213

214-
export async function standByForTx(expectedTxId: string): Promise<DbTx> {
214+
// todo: add `export` to this and remove other implementations of this
215+
async function standByForTx(expectedTxId: string): Promise<DbTx> {
215216
const tx = await new Promise<DbTx>(async resolve => {
216217
const listener: (txId: string) => void = async txId => {
217218
if (txId !== expectedTxId) {
@@ -262,7 +263,8 @@ export async function standByForTxSuccess(expectedTxId: string): Promise<DbTx> {
262263
return tx;
263264
}
264265

265-
export async function standByUntilBlock(blockHeight: number): Promise<DbBlock> {
266+
// todo: add `export` to this and remove other implementations of this
267+
async function standByUntilBlock(blockHeight: number): Promise<DbBlock> {
266268
const dbBlock = await new Promise<DbBlock>(async resolve => {
267269
const listener: (blockHash: string) => void = async blockHash => {
268270
const dbBlockQuery = await testEnv.api.datastore.getBlock({ hash: blockHash });
@@ -371,7 +373,8 @@ export async function readOnlyFnCall<T extends NativeClarityValue>(
371373
return decodedVal;
372374
}
373375

374-
export async function fetchRosetta<TPostBody, TRes>(endpoint: string, body: TPostBody) {
376+
// todo: add `export` to this and remove other implementations of this
377+
async function fetchRosetta<TPostBody, TRes>(endpoint: string, body: TPostBody) {
375378
const result = await supertest(testEnv.api.server)
376379
.post(endpoint)
377380
.send(body as any);

src/tests-2.1-transition/pox-transition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
getRosettaBlockByBurnBlockHeight,
3030
stackStxWithRosetta,
3131
standByForAccountUnlock,
32-
} from 'src/test-utils/test-helpers';
32+
} from '../test-utils/test-helpers';
3333
import { decodeClarityValue } from 'stacks-encoding-native-js';
3434
import { ApiServer } from '../api/init';
3535
import { testnetKeys } from '../api/routes/debug';

src/tests-2.1/pox-2-auto-unlock.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { StacksCoreRpcClient } from '../core-rpc/client';
2-
import { ApiServer } from '../api/init';
3-
import { PgWriteStore } from '../datastore/pg-write-store';
41
import { StacksNetwork } from '@stacks/network';
2+
import { AnchorMode, makeContractCall, uintCV } from '@stacks/transactions';
3+
import { AddressStxBalanceResponse } from 'docs/generated';
54
import { RPCClient } from 'rpc-bitcoin';
5+
import { ApiServer } from '../api/init';
66
import { testnetKeys } from '../api/routes/debug';
7+
import { StacksCoreRpcClient } from '../core-rpc/client';
8+
import { PgWriteStore } from '../datastore/pg-write-store';
79
import {
810
Account,
911
accountFromKey,
@@ -14,9 +16,6 @@ import {
1416
TestEnvContext,
1517
} from '../test-utils/test-helpers';
1618

17-
import { AnchorMode, makeContractCall, uintCV } from '@stacks/transactions';
18-
import { AddressStxBalanceResponse } from 'docs/generated';
19-
2019
describe('PoX-2 - Auto unlock', () => {
2120
let db: PgWriteStore;
2221
let api: ApiServer;

src/tests-2.1/pox-2-rosetta.ts

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,30 @@ import { StacksNetwork } from '@stacks/network';
44
import {
55
AddressStxBalanceResponse,
66
BurnchainRewardListResponse,
7-
NetworkIdentifier,
8-
RosettaAccountBalanceRequest,
9-
RosettaAccountBalanceResponse,
10-
RosettaBlockRequest,
11-
RosettaBlockResponse,
12-
RosettaConstructionMetadataRequest,
13-
RosettaConstructionMetadataResponse,
14-
RosettaConstructionPayloadResponse,
15-
RosettaConstructionPayloadsRequest,
16-
RosettaConstructionPreprocessRequest,
17-
RosettaConstructionPreprocessResponse,
18-
RosettaConstructionSubmitRequest,
19-
RosettaConstructionSubmitResponse,
20-
RosettaOperation,
7+
BurnchainRewardSlotHolderListResponse,
218
} from '@stacks/stacks-blockchain-api-types';
229
import {
2310
AnchorMode,
24-
ChainID,
25-
createStacksPrivateKey,
26-
deserializeTransaction,
2711
getAddressFromPrivateKey,
2812
makeSTXTokenTransfer,
29-
TransactionSigner,
3013
TransactionVersion,
3114
} from '@stacks/transactions';
3215
import bignumber from 'bignumber.js';
3316
import { RPCClient } from 'rpc-bitcoin';
34-
import * as supertest from 'supertest';
17+
import { DbTxStatus } from '../../src/datastore/common';
3518
import { ApiServer } from '../api/init';
36-
import { getRosettaNetworkName, RosettaConstants } from '../api/rosetta-constants';
3719
import { testnetKeys } from '../api/routes/debug';
3820
import { CoreRpcPoxInfo, StacksCoreRpcClient } from '../core-rpc/client';
3921
import { PgWriteStore } from '../datastore/pg-write-store';
4022
import { ECPair, getBitcoinAddressFromKey } from '../ec-helpers';
4123
import { hexToBuffer } from '../helpers';
4224
import {
4325
fetchGet,
26+
getRosettaAccountBalance,
27+
getRosettaBlockByBurnBlockHeight,
28+
stackStxWithRosetta,
4429
standByForAccountUnlock,
4530
standByForTxSuccess,
46-
standByUntilBlock,
4731
standByUntilBurnBlock,
4832
testEnv,
4933
TestEnvContext,

0 commit comments

Comments
 (0)