Skip to content

Commit 7c6874a

Browse files
committed
fix: allow contract-principals in /extended/v1/address/:principal/mempool endpoint #1685
1 parent d9efad9 commit 7c6874a

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

src/api/routes/address.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,9 @@ export function createAddressRouter(db: PgStore, chainId: ChainID): express.Rout
543543
const limit = getPagingQueryLimit(ResourceType.Tx, req.query.limit);
544544
const offset = parsePagingQueryInput(req.query.offset ?? 0);
545545
const address = req.params['address'];
546-
if (!isValidC32Address(address)) {
546+
if (!isValidPrincipal(address)) {
547547
throw new InvalidRequestError(
548-
`Invalid query parameter for "${address}"`,
548+
`Invalid query parameter for "${address}", not a valid principal`,
549549
InvalidRequestErrorType.invalid_param
550550
);
551551
}

src/tests/mempool-tests.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,58 @@ describe('mempool tests', () => {
983983
};
984984
expect(JSON.parse(searchResult5.text)).toEqual(expectedResp5);
985985

986+
const searchResult5Address = await supertest(api.server).get(
987+
`/extended/v1/address/${contractCallId}/mempool`
988+
);
989+
expect(searchResult5Address.status).toBe(200);
990+
expect(searchResult5Address.type).toBe('application/json');
991+
const expectedResp5Address = {
992+
limit: getPagingQueryLimit(ResourceType.Tx),
993+
offset: 0,
994+
total: 2,
995+
results: [
996+
{
997+
fee_rate: '1234',
998+
nonce: 0,
999+
anchor_mode: 'any',
1000+
post_condition_mode: 'allow',
1001+
post_conditions: [],
1002+
receipt_time: 1594307650,
1003+
receipt_time_iso: '2020-07-09T15:14:10.000Z',
1004+
sender_address: 'testSend1',
1005+
sponsored: false,
1006+
token_transfer: {
1007+
amount: '1234',
1008+
memo: '0x',
1009+
recipient_address: 'SP32AEEF6WW5Y0NMJ1S8SBSZDAY8R5J32NBZFPKKZ.free-punks-v0',
1010+
},
1011+
tx_id: '0x8912000000000000000000000000000000000000000000000000000000000010',
1012+
tx_status: 'pending',
1013+
tx_type: 'token_transfer',
1014+
},
1015+
{
1016+
fee_rate: '1234',
1017+
nonce: 0,
1018+
anchor_mode: 'any',
1019+
post_condition_mode: 'allow',
1020+
post_conditions: [],
1021+
receipt_time: 1594307648,
1022+
receipt_time_iso: '2020-07-09T15:14:08.000Z',
1023+
sender_address: 'testSend1',
1024+
sponsored: false,
1025+
tx_id: '0x8912000000000000000000000000000000000000000000000000000000000008',
1026+
tx_status: 'pending',
1027+
tx_type: 'contract_call',
1028+
contract_call: {
1029+
contract_id: 'SP32AEEF6WW5Y0NMJ1S8SBSZDAY8R5J32NBZFPKKZ.free-punks-v0',
1030+
function_name: 'mint',
1031+
function_signature: '',
1032+
},
1033+
},
1034+
],
1035+
};
1036+
expect(JSON.parse(searchResult5Address.text)).toEqual(expectedResp5Address);
1037+
9861038
const searchResult6 = await supertest(api.server).get(
9871039
`/extended/v1/tx/mempool?address=${contractAddr}`
9881040
);

0 commit comments

Comments
 (0)