Skip to content

Commit 5df254d

Browse files
asimm241zone117x
authored andcommitted
refactor: refactor the code, added comment, added docker-composer in package.json
1 parent b60cc8c commit 5df254d

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
"@typescript-eslint/parser": "^2.25.0",
154154
"compare-versions": "^3.6.0",
155155
"concurrently": "^5.2.0",
156+
"docker-compose": "^0.23.5",
156157
"eslint": "^6.8.0",
157158
"eslint-config-prettier": "^6.10.1",
158159
"eslint-plugin-prettier": "^3.1.2",

src/api/routes/rosetta/account.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
} from '@blockstack/stacks-blockchain-api-types';
1111
import { RosettaErrors, RosettaConstants } from '../../rosetta-constants';
1212
import { rosettaValidateRequest, ValidSchema, makeRosettaError } from '../../rosetta-validate';
13-
import { StacksCoreRpcClient } from '../../../core-rpc/client';
1413

1514
export function createRosettaAccountRouter(db: DataStore): RouterWithAsync {
1615
const router = addAsync(express.Router());
@@ -49,13 +48,6 @@ export function createRosettaAccountRouter(db: DataStore): RouterWithAsync {
4948

5049
const block = blockQuery.result;
5150
const result = await db.getStxBalanceAtBlock(accountIdentifier.address, block.block_height);
52-
let value = result.balance.toString();
53-
54-
if (value == '0') {
55-
const fake = await new StacksCoreRpcClient().getAccountBalance(accountIdentifier.address);
56-
console.log(`-------- fake for ${accountIdentifier.address} is ${fake}`);
57-
value = fake.toString();
58-
}
5951

6052
const response: RosettaAccountBalanceResponse = {
6153
block_identifier: {
@@ -64,7 +56,7 @@ export function createRosettaAccountRouter(db: DataStore): RouterWithAsync {
6456
},
6557
balances: [
6658
{
67-
value: value,
59+
value: result.balance.toString(),
6860
currency: {
6961
symbol: RosettaConstants.symbol,
7062
decimals: RosettaConstants.decimals,

src/api/routes/rosetta/construction.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,12 @@ export function createRosettaConstructionRouter(db: DataStore): RouterWithAsync
520520
let newSignature: MessageSignature;
521521

522522
try {
523+
/**
524+
* the elliptic library produces signatures that aren't in an "allowed" format
525+
* it preapend v (i.e 01) while it should append it at the end, to incorporate that rotate
526+
* the signature to match the elipcitc library
527+
* Discussion here: https://github.com/coinbase/rosetta-sdk-go/issues/201
528+
*/
523529
let hash = signatures[0].hex_bytes;
524530
if (!hash.startsWith('01') && hash.slice(128) == '01') {
525531
hash = signatures[0].hex_bytes.slice(128) + signatures[0].hex_bytes.slice(0, -2);

src/tests-rosetta/api.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,15 +1472,13 @@ describe('Rosetta API', () => {
14721472
],
14731473
};
14741474

1475-
const accountInfo = await new StacksCoreRpcClient().getAccount(sender);
1476-
14771475
const tokenTransferOptions: UnsignedTokenTransferOptions = {
14781476
recipient: recipient,
14791477
amount: new BN('500000'),
14801478
fee: new BN(fee),
14811479
publicKey: publicKey,
14821480
network: GetStacksTestnetNetwork(),
1483-
nonce: accountInfo.nonce ? new BN(accountInfo.nonce) : new BN(0),
1481+
nonce: new BN(0),
14841482
};
14851483

14861484
const transaction = await makeUnsignedSTXTokenTransfer(tokenTransferOptions);
@@ -1489,12 +1487,7 @@ describe('Rosetta API', () => {
14891487

14901488
const signer = new TransactionSigner(transaction);
14911489

1492-
const prehash = makeSigHashPreSign(
1493-
signer.sigHash,
1494-
AuthType.Standard,
1495-
new BN(fee),
1496-
accountInfo.nonce ? new BN(accountInfo.nonce) : new BN(0)
1497-
);
1490+
const prehash = makeSigHashPreSign(signer.sigHash, AuthType.Standard, new BN(fee), new BN(0));
14981491

14991492
const result = await supertest(api.server)
15001493
.post(`/rosetta/v1/construction/payloads`)

0 commit comments

Comments
 (0)