Skip to content

Commit 29bea91

Browse files
authored
Merge pull request #447 from AnthonyLaw/issue-beneficiaryPublicKey
fix #446
2 parents d60bb24 + b349454 commit 29bea91

File tree

4 files changed

+5
-49
lines changed

4 files changed

+5
-49
lines changed

e2e/infrastructure/BlockHttp.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe('BlockHttp', () => {
9595
expect(blockInfo.height.higher).to.be.equal(0);
9696
expect(blockInfo.timestamp.lower).to.be.equal(0);
9797
expect(blockInfo.timestamp.higher).to.be.equal(0);
98-
98+
expect(blockInfo.beneficiaryPublicKey).not.to.be.undefined;
9999
});
100100
});
101101

src/infrastructure/BlockHttp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { UInt64 } from '../model/UInt64';
2626
import { BlockRepository } from './BlockRepository';
2727
import { Http } from './Http';
2828
import { QueryParams } from './QueryParams';
29-
import { CreateTransactionFromDTO, extractBeneficiary } from './transaction/CreateTransactionFromDTO';
29+
import { CreateTransactionFromDTO } from './transaction/CreateTransactionFromDTO';
3030

3131
/**
3232
* Blockchain http repository.
@@ -122,7 +122,7 @@ export class BlockHttp extends Http implements BlockRepository {
122122
dto.block.transactionsHash,
123123
dto.block.receiptsHash,
124124
dto.block.stateHash,
125-
extractBeneficiary(dto, networkType),
125+
dto.block.beneficiaryPublicKey ? PublicAccount.createFromPublicKey(dto.block.beneficiaryPublicKey, networkType) : undefined,
126126
);
127127
}
128128

src/infrastructure/Listener.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ import { TransactionStatusError } from '../model/transaction/TransactionStatusEr
3232
import { TransferTransaction } from '../model/transaction/TransferTransaction';
3333
import { UInt64 } from '../model/UInt64';
3434
import { IListener } from './IListener';
35-
import {
36-
CreateTransactionFromDTO,
37-
extractBeneficiary,
38-
} from './transaction/CreateTransactionFromDTO';
35+
import { CreateTransactionFromDTO } from './transaction/CreateTransactionFromDTO';
3936

4037
enum ListenerChannelName {
4138
block = 'block',
@@ -157,7 +154,7 @@ export class Listener implements IListener {
157154
message.block.blockTransactionsHash,
158155
message.block.blockReceiptsHash,
159156
message.block.stateHash,
160-
extractBeneficiary(message, message.block.network), // passing `message` as `blockDTO`
157+
message.block.beneficiaryPublicKey,
161158
),
162159
});
163160
} else if (message.code) {

src/infrastructure/transaction/CreateTransactionFromDTO.ts

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -481,44 +481,3 @@ const extractMessage = (message: any): PlainMessage | EncryptedMessage => {
481481
}
482482
return msgObj;
483483
};
484-
485-
/**
486-
* Extract beneficiary public key from DTO.
487-
*
488-
* @todo Upgrade of catapult-rest WITH catapult-service-bootstrap versioning.
489-
*
490-
* With `cow` upgrade (nemtech/catapult-server@0.3.0.2), `catapult-rest` block DTO
491-
* was updated and latest catapult-service-bootstrap uses the wrong block DTO.
492-
* This will be fixed with next catapult-server upgrade to `dragon`.
493-
*
494-
* :warning It is currently not possible to read the block's beneficiary public key
495-
* except when working with a local instance of `catapult-rest`.
496-
*
497-
* @param beneficiary {string | undefined} The beneficiary public key if set
498-
* @return {Mosaic[]}
499-
*/
500-
export const extractBeneficiary = (
501-
blockDTO: any,
502-
networkType: NetworkType,
503-
): PublicAccount | undefined => {
504-
505-
let dtoPublicAccount: PublicAccount | undefined;
506-
let dtoFieldValue: string | undefined;
507-
if (blockDTO.beneficiaryPublicKey) {
508-
dtoFieldValue = blockDTO.beneficiaryPublicKey;
509-
} else if (blockDTO.beneficiary) {
510-
dtoFieldValue = blockDTO.beneficiary;
511-
}
512-
513-
if (! dtoFieldValue) {
514-
return undefined;
515-
}
516-
517-
try {
518-
// @FIX with latest catapult-service-bootstrap version, catapult-rest still returns
519-
// a `string` formatted copy of the public *when it is set at all*.
520-
dtoPublicAccount = PublicAccount.createFromPublicKey(dtoFieldValue, networkType);
521-
} catch (e) { dtoPublicAccount =  undefined; }
522-
523-
return dtoPublicAccount;
524-
};

0 commit comments

Comments
 (0)