Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/infrastructure/BlockHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('BlockHttp', () => {
expect(blockInfo.height.higher).to.be.equal(0);
expect(blockInfo.timestamp.lower).to.be.equal(0);
expect(blockInfo.timestamp.higher).to.be.equal(0);

expect(blockInfo.beneficiaryPublicKey).not.to.be.undefined;
});
});

Expand Down
4 changes: 2 additions & 2 deletions src/infrastructure/BlockHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { UInt64 } from '../model/UInt64';
import { BlockRepository } from './BlockRepository';
import { Http } from './Http';
import { QueryParams } from './QueryParams';
import { CreateTransactionFromDTO, extractBeneficiary } from './transaction/CreateTransactionFromDTO';
import { CreateTransactionFromDTO } from './transaction/CreateTransactionFromDTO';

/**
* Blockchain http repository.
Expand Down Expand Up @@ -122,7 +122,7 @@ export class BlockHttp extends Http implements BlockRepository {
dto.block.transactionsHash,
dto.block.receiptsHash,
dto.block.stateHash,
extractBeneficiary(dto, networkType),
dto.block.beneficiaryPublicKey ? PublicAccount.createFromPublicKey(dto.block.beneficiaryPublicKey, networkType) : undefined,
);
}

Expand Down
7 changes: 2 additions & 5 deletions src/infrastructure/Listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ import { TransactionStatusError } from '../model/transaction/TransactionStatusEr
import { TransferTransaction } from '../model/transaction/TransferTransaction';
import { UInt64 } from '../model/UInt64';
import { IListener } from './IListener';
import {
CreateTransactionFromDTO,
extractBeneficiary,
} from './transaction/CreateTransactionFromDTO';
import { CreateTransactionFromDTO } from './transaction/CreateTransactionFromDTO';

enum ListenerChannelName {
block = 'block',
Expand Down Expand Up @@ -157,7 +154,7 @@ export class Listener implements IListener {
message.block.blockTransactionsHash,
message.block.blockReceiptsHash,
message.block.stateHash,
extractBeneficiary(message, message.block.network), // passing `message` as `blockDTO`
message.block.beneficiaryPublicKey,
),
});
} else if (message.code) {
Expand Down
41 changes: 0 additions & 41 deletions src/infrastructure/transaction/CreateTransactionFromDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,44 +481,3 @@ const extractMessage = (message: any): PlainMessage | EncryptedMessage => {
}
return msgObj;
};

/**
* Extract beneficiary public key from DTO.
*
* @todo Upgrade of catapult-rest WITH catapult-service-bootstrap versioning.
*
* With `cow` upgrade (nemtech/catapult-server@0.3.0.2), `catapult-rest` block DTO
* was updated and latest catapult-service-bootstrap uses the wrong block DTO.
* This will be fixed with next catapult-server upgrade to `dragon`.
*
* :warning It is currently not possible to read the block's beneficiary public key
* except when working with a local instance of `catapult-rest`.
*
* @param beneficiary {string | undefined} The beneficiary public key if set
* @return {Mosaic[]}
*/
export const extractBeneficiary = (
blockDTO: any,
networkType: NetworkType,
): PublicAccount | undefined => {

let dtoPublicAccount: PublicAccount | undefined;
let dtoFieldValue: string | undefined;
if (blockDTO.beneficiaryPublicKey) {
dtoFieldValue = blockDTO.beneficiaryPublicKey;
} else if (blockDTO.beneficiary) {
dtoFieldValue = blockDTO.beneficiary;
}

if (! dtoFieldValue) {
return undefined;
}

try {
// @FIX with latest catapult-service-bootstrap version, catapult-rest still returns
// a `string` formatted copy of the public *when it is set at all*.
dtoPublicAccount = PublicAccount.createFromPublicKey(dtoFieldValue, networkType);
} catch (e) { dtoPublicAccount =  undefined; }

return dtoPublicAccount;
};