Skip to content

Commit

Permalink
Merge pull request #8 from ElrondNetwork/fixes-upon-extraction
Browse files Browse the repository at this point in the history
Fix DTOs.
  • Loading branch information
andreibancioiu authored Apr 11, 2022
2 parents b99a17f + 4c2212e commit cccfe8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
6 changes: 1 addition & 5 deletions src-network-providers/contractResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ export class ContractResults {
});
}

static empty(): ContractResults {
return new ContractResults([]);
}

static fromProxyHttpResponse(results: any[]): ContractResults {
let items = results.map(item => ContractResultItem.fromProxyHttpResponse(item));
return new ContractResults(items);
Expand All @@ -41,7 +37,7 @@ export class ContractResultItem {
gasPrice: IGasPrice = 0;
callType: number = 0;
returnMessage: string = "";
logs: TransactionLogs = TransactionLogs.empty();
logs: TransactionLogs = new TransactionLogs();

constructor(init?: Partial<ContractResultItem>) {
Object.assign(this, init);
Expand Down
21 changes: 9 additions & 12 deletions src-network-providers/transactionLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ import { Address } from "./primitives";
import { TransactionEvent } from "./transactionEvents";

export class TransactionLogs {
readonly address: IAddress;
readonly events: TransactionEvent[];
address: IAddress = new Address("");
events: TransactionEvent[] = [];

constructor(address: IAddress, events: TransactionEvent[]) {
this.address = address;
this.events = events;
}

static empty(): TransactionLogs {
return new TransactionLogs(new Address(""), []);
constructor(init?: Partial<TransactionLogs>) {
Object.assign(this, init);
}

static fromHttpResponse(logs: any): TransactionLogs {
let address = new Address(logs.address);
let events = (logs.events || []).map((event: any) => TransactionEvent.fromHttpResponse(event));
return new TransactionLogs(address, events);
let result = new TransactionLogs();
result.address = new Address(logs.address);
result.events = (logs.events || []).map((event: any) => TransactionEvent.fromHttpResponse(event));

return result;
}

findSingleOrNoneEvent(identifier: string, predicate?: (event: TransactionEvent) => boolean): TransactionEvent | undefined {
Expand Down
4 changes: 2 additions & 2 deletions src-network-providers/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class TransactionOnNetwork {
hyperblockHash: string = "";

receipt: TransactionReceipt = new TransactionReceipt();
contractResults: ContractResults = ContractResults.empty();
logs: TransactionLogs = TransactionLogs.empty();
contractResults: ContractResults = new ContractResults([]);
logs: TransactionLogs = new TransactionLogs();

constructor(init?: Partial<TransactionOnNetwork>) {
Object.assign(this, init);
Expand Down

0 comments on commit cccfe8e

Please sign in to comment.