Skip to content

Commit 839a409

Browse files
Faizan Dastgirzone117x
authored andcommitted
fix: typos and add check signer in parse test
1 parent e617e31 commit 839a409

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/api/routes/rosetta/construction.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
bitcoinAddressToSTXAddress,
2727
getOperations,
2828
getOptionsFromOperations,
29-
getSingers,
29+
getSigners,
3030
isDecimalsSupported,
3131
isSignedTransaction,
3232
isSymbolSupported,
@@ -249,18 +249,18 @@ export function createRosettaConstructionRouter(db: DataStore): RouterWithAsync
249249
return;
250250
}
251251
const inputTx = req.body.transaction;
252-
const singed = req.body.signed;
252+
const signed = req.body.signed;
253253
const transaction = rawTxToStacksTransaction(inputTx);
254254
const checkSigned = isSignedTransaction(transaction);
255-
if (singed != checkSigned) {
255+
if (signed != checkSigned) {
256256
res.status(400).json(RosettaErrors.invalidParams);
257257
return;
258258
}
259259
const operations = getOperations(rawTxToBaseTx(inputTx));
260-
if (singed) {
260+
if (signed) {
261261
res.json({
262262
operations: operations,
263-
account_identifier_signers: getSingers(transaction),
263+
account_identifier_signers: getSigners(transaction),
264264
});
265265
} else {
266266
res.json({

src/rosetta-helpers.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ export function rawTxToBaseTx(raw_tx: string): BaseTx {
359359
return dbtx;
360360
}
361361

362-
export function getSingers(transaction: StacksTransaction): RosettaAccountIdentifier[] | undefined {
362+
export function getSigners(transaction: StacksTransaction): RosettaAccountIdentifier[] | undefined {
363363
let address;
364364
if (transaction.payload.payloadType == PayloadType.TokenTransfer) {
365365
address = transaction.payload.recipient.address;
@@ -373,25 +373,25 @@ export function getSingers(transaction: StacksTransaction): RosettaAccountIdenti
373373
const account_identifier_signers: RosettaAccountIdentifier[] = [];
374374
if (transaction.auth.authType == AuthType.Standard) {
375375
if (transaction.auth.spendingCondition) {
376-
const singer = {
376+
const signer = {
377377
address: addressToString({
378378
version: version,
379379
hash160: transaction.auth.spendingCondition.signer,
380380
type: type,
381381
}),
382382
};
383-
account_identifier_signers.push(singer);
383+
account_identifier_signers.push(signer);
384384
}
385385
} else if (transaction.auth.authType == AuthType.Sponsored) {
386386
if (transaction.auth.spendingCondition) {
387-
const singer = {
387+
const signer = {
388388
address: addressToString({
389389
version: version,
390390
hash160: transaction.auth.spendingCondition.signer,
391391
type: type,
392392
}),
393393
};
394-
account_identifier_signers.push(singer);
394+
account_identifier_signers.push(signer);
395395
}
396396
if (transaction.auth.sponsorSpendingCondition) {
397397
const sponsored = {

src/tests-rosetta/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,8 @@ describe('Rosetta API', () => {
967967
// test recipient
968968
expect(actual.operations[2].account?.address).toEqual(recipientAddr);
969969
expect(actual.operations[2].amount?.value).toEqual(amount.toString());
970+
// test signer
971+
expect(actual.account_identifier_signers?.[0].address).toEqual(senderAddr);
970972
});
971973

972974
test('construction/parse - unsigned', async () => {

0 commit comments

Comments
 (0)