Skip to content

Commit

Permalink
rebase with milestone-2
Browse files Browse the repository at this point in the history
  • Loading branch information
guplersaxanoid committed Aug 23, 2023
2 parents 1f2b72d + af0abff commit 8c45efa
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 28 deletions.
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,5 @@
"prettier --write"
]
},
"packageManager": "[email protected]",
"dependencies": {
"stellar-sdk": "^10.4.1"
}
"packageManager": "[email protected]"
}
3 changes: 2 additions & 1 deletion packages/common-stellar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"@subql/types-stellar": "workspace:*",
"js-yaml": "^4.1.0",
"pino": "^6.13.3",
"reflect-metadata": "^0.1.13"
"reflect-metadata": "^0.1.13",
"stellar-sdk": "^10.4.1"
},
"peerDependencies": {
"class-transformer": "*",
Expand Down
2 changes: 1 addition & 1 deletion packages/common-stellar/src/project/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from '@subql/types-stellar';
import {plainToClass, Transform, Type} from 'class-transformer';
import {IsArray, IsEnum, IsInt, IsOptional, IsString, IsObject, ValidateNested} from 'class-validator';
import {Horizon, ServerApi} from 'stellar-sdk';
import {Horizon} from 'stellar-sdk';
import {SubqlStellarProcessorOptions} from './types';

export class BlockFilter implements StellarBlockFilter {
Expand Down
1 change: 1 addition & 0 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"rimraf": "^3.0.2",
"rxjs": "^7.5.2",
"soroban-client": "^0.9.1",
"stellar-sdk": "^10.4.1",
"yargs": "^16.2.0"
},
"peerDependencies": {
Expand Down
33 changes: 13 additions & 20 deletions packages/node/src/stellar/api.stellar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
StellarOperation,
StellarTransaction,
} from '@subql/types-stellar';
import { cloneDeep } from 'lodash';
import { Server, ServerApi } from 'stellar-sdk';
import { StellarBlockWrapped } from '../stellar/block.stellar';
import SafeStellarProvider from './safe-api';
Expand Down Expand Up @@ -125,20 +126,12 @@ export class StellarApi implements ApiWrapper<StellarBlockWrapper> {
): Promise<StellarEffect[]> {
const effects = (await this.api.effects().forOperation(operationId).call())
.records;
const wrappedEffects: StellarEffect[] = [];

effects.forEach((effect) => {
const wrappedEffect: StellarEffect = {
...effect,
ledger: null,
transaction: null,
operation: null,
};

wrappedEffects.push(wrappedEffect);
});

return wrappedEffects;
return effects.map((effect) => ({
...effect,
ledger: null,
transaction: null,
operation: null,
}));
}

private async fetchOperationsForTransaction(
Expand Down Expand Up @@ -185,7 +178,7 @@ export class StellarApi implements ApiWrapper<StellarBlockWrapper> {

const effects = (await this.fetchEffectsForOperation(op.id)).map(
(effect) => {
effect.operation = JSON.parse(JSON.stringify(wrappedOp));
effect.operation = cloneDeep(wrappedOp);
return effect;
},
);
Expand Down Expand Up @@ -229,9 +222,9 @@ export class StellarApi implements ApiWrapper<StellarBlockWrapper> {
const operations = (
await this.fetchOperationsForTransaction(tx.id, index + 1, sequence)
).map((op) => {
op.transaction = JSON.parse(JSON.stringify(wrappedTx));
op.transaction = cloneDeep(wrappedTx);
op.effects = op.effects.map((effect) => {
effect.transaction = JSON.parse(JSON.stringify(wrappedTx));
effect.transaction = cloneDeep(wrappedTx);
return effect;
});
op.events = op.events.map((event) => {
Expand Down Expand Up @@ -268,11 +261,11 @@ export class StellarApi implements ApiWrapper<StellarBlockWrapper> {

const transactions = (await this.fetchTransactionsForLedger(sequence)).map(
(tx) => {
tx.ledger = JSON.parse(JSON.stringify(wrappedLedger));
tx.ledger = cloneDeep(wrappedLedger);
tx.operations = tx.operations.map((op) => {
op.ledger = JSON.parse(JSON.stringify(wrappedLedger));
op.ledger = cloneDeep(wrappedLedger);
op.effects = op.effects.map((effect) => {
effect.ledger = JSON.parse(JSON.stringify(wrappedLedger));
effect.ledger = cloneDeep(wrappedLedger);
return effect;
});
op.events = op.events.map((event) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"/dist"
],
"dependencies": {
"soroban-client": "0.9.2"
"soroban-client": "0.9.2",
"stellar-sdk": "^10.4.1"
},
"stableVersion": "2.2.3-2"
}
2 changes: 1 addition & 1 deletion packages/types/src/stellar/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type StellarOperation<T extends Horizon.BaseOperationResponse = ServerApi
events: SorobanEvent[];
};

export type StellarEffect<T extends BaseEffectRecord = ServerApi.EffectRecord> = T & {
export type StellarEffect<T extends BaseEffectRecord = ServerApi.EffectRecord> = Omit<T, 'operation'> & {
operation: StellarOperation;
transaction: StellarTransaction;
ledger: StellarBlock;
Expand Down

0 comments on commit 8c45efa

Please sign in to comment.