Skip to content

Commit

Permalink
build fix
Browse files Browse the repository at this point in the history
  • Loading branch information
antisaa committed Feb 2, 2025
1 parent 51ed9c9 commit 7d32176
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 4 deletions.
5 changes: 5 additions & 0 deletions bin/run_icrc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /bin/sh
set -e

BLOCKCHAIN=icrc NODE_URL=https://icrc-rosetta-ckbtc.santiment.net CKBTC_NODE_URL=https://icrc-rosetta-ckbtc.santiment.net CKETH_NODE_URL=https://icrc-rosetta-cketh.santiment.net CKUSDC_NODE_URL=https://icrc-rosetta-ckusdc.santiment.net CKUSDT_NODE_URL=https://icrc-rosetta-ckusdt.santiment.net docker compose -f docker/docker-compose.yaml up --build
docker compose -f docker/docker-compose.yaml rm -f
2 changes: 1 addition & 1 deletion src/blockchains/icp/icp_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BaseWorker } from '../../lib/worker_base';
import { ICPBlock, Transaction, ExtendedTransaction } from './lib/icp_types';
import fetch from 'node-fetch';
import assert from 'assert';
import { transactionOrder, stableSort } from '../eth/lib/util';
import { transactionOrder, stableSort } from './lib/util';
import BigNumber from 'bignumber.js';

export class ICPWorker extends BaseWorker {
Expand Down
26 changes: 26 additions & 0 deletions src/blockchains/icp/lib/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function transactionOrder(a, b) {
return a.blockNumber - b.blockNumber || a.transactionPosition - b.transactionPosition;
}

function stableSort(array, sortFunc) {
array.forEach((x, i) => x._position = i);

array.sort(function (a, b) {
let sortResult = sortFunc(a, b);
if (sortResult !== 0) {
return sortResult;
}
else {
return a._position - b._position;
}
});

array.forEach(x => delete x._position);
}


module.exports = {
transactionOrder,
stableSort
};

4 changes: 2 additions & 2 deletions src/blockchains/icrc/icrc_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BaseWorker } from '../../lib/worker_base';
import { ICRCBlock, Transaction, ExtendedTransaction, TransferPart } from './lib/icrc_types';
import fetch from 'node-fetch';
import assert from 'assert';
import { transactionOrder, stableSort } from '../eth/lib/util';
import { transactionOrder, stableSort } from './lib/util';
import BigNumber from 'bignumber.js';

export class ICRCWorker extends BaseWorker {
Expand Down Expand Up @@ -224,7 +224,7 @@ export class ICRCWorker extends BaseWorker {
toTransferOperations.push(toOperation);
}

if (operation.type !== 'TRANSFER' && operation.type !== 'APPROVE' && operation.type !== 'MINT' && operation.type !== 'FEE' && operation.type !== 'BURN' && operation.type !== 'FEE_COLLECTOR'){
if (operation.type !== 'TRANSFER' && operation.type !== 'APPROVE' && operation.type !== 'MINT' && operation.type !== 'FEE' && operation.type !== 'BURN' && operation.type !== 'FEE_COLLECTOR' && operation.type !== 'SPENDER'){
console.log(operation.type);
console.log(operation);
console.log(block);
Expand Down
2 changes: 1 addition & 1 deletion src/blockchains/icrc/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export const LOOP_INTERVAL_CURRENT_MODE_SEC = getIntEnvVariable('LOOP_INTERVAL_C
exports.RPC_USERNAME = process.env.RPC_USERNAME;
exports.RPC_PASSWORD = process.env.RPC_PASSWORD;
export const MAX_CONCURRENT_REQUESTS = getIntEnvVariable('MAX_CONCURRENT_REQUESTS', 50);
exports.CANISTER=process.env.CANISTER
exports.CANISTER = process.env.CANISTER
26 changes: 26 additions & 0 deletions src/blockchains/icrc/lib/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function transactionOrder(a, b) {
return a.blockNumber - b.blockNumber || a.transactionPosition - b.transactionPosition;
}

function stableSort(array, sortFunc) {
array.forEach((x, i) => x._position = i);

array.sort(function (a, b) {
let sortResult = sortFunc(a, b);
if (sortResult !== 0) {
return sortResult;
}
else {
return a._position - b._position;
}
});

array.forEach(x => delete x._position);
}


module.exports = {
transactionOrder,
stableSort
};

0 comments on commit 7d32176

Please sign in to comment.