Skip to content

Commit

Permalink
add secret proof to transaction details
Browse files Browse the repository at this point in the history
  • Loading branch information
bassemmagdy committed Oct 21, 2021
1 parent aacbbb8 commit 51ad192
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/core/transactions/TransactionViewFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
AccountOperationRestrictionTransaction,
PersistentHarvestingDelegationMessage,
SecretLockTransaction,
SecretProofTransaction,
} from 'symbol-sdk';
import { ViewUnknownTransaction } from '@/core/transactions/ViewUnknownTransaction';
import { ViewHashLockTransaction } from '@/core/transactions/ViewHashLockTransaction';
Expand All @@ -59,6 +60,7 @@ import { ViewAccountMosaicRestrictionTransaction } from './ViewAccountMosaicRest
import { ViewAccountOperationRestrictionTransaction } from './ViewAccountOperationRestrictionTransaction';
import { ViewHarvestingTransaction } from './ViewHarvestingTransaction';
import { ViewSecretLockTransaction } from './ViewSecretLockTransaction';
import { ViewSecretProofTransaction } from './ViewSecretProofTransaction';

/**
* Transaction view factory.
Expand All @@ -77,7 +79,6 @@ export class TransactionViewFactory {
case TransactionType.AGGREGATE_COMPLETE:
case TransactionType.MOSAIC_ADDRESS_RESTRICTION:
case TransactionType.MOSAIC_GLOBAL_RESTRICTION:
case TransactionType.SECRET_PROOF:
return new ViewUnknownTransaction($store, transaction);
/// end-region XXX views for transaction types not yet implemented
case TransactionType.ACCOUNT_ADDRESS_RESTRICTION:
Expand Down Expand Up @@ -122,6 +123,8 @@ export class TransactionViewFactory {
return new ViewAccountKeyLinkTransaction($store, transaction as AccountKeyLinkTransaction);
case TransactionType.SECRET_LOCK:
return new ViewSecretLockTransaction($store, transaction as SecretLockTransaction);
case TransactionType.SECRET_PROOF:
return new ViewSecretProofTransaction($store, transaction as SecretProofTransaction);
default:
throw new Error(`View not implemented for transaction type '${transaction.type}'`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/transactions/ViewSecretLockTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
*/
// external dependencies
import { SecretLockTransaction, LockHashAlgorithm } from 'symbol-sdk';
import { SecretLockTransaction } from 'symbol-sdk';
// internal dependencies
import { TransactionView } from './TransactionView';
import { AttachedMosaic } from '@/services/MosaicService';
Expand Down Expand Up @@ -46,7 +46,7 @@ export class ViewSecretLockTransaction extends TransactionView<SecretLockTransac
},
{
key: 'lock_hash_algorithm',
value: this.transaction.hashAlgorithm === LockHashAlgorithm.Op_Hash_256 ? 'SHA3-256' : 'SHA-256',
value: this.transaction.hashAlgorithm,
},
];
}
Expand Down
44 changes: 44 additions & 0 deletions src/core/transactions/ViewSecretProofTransaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2020 NEM (https://nem.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*
*/
// external dependencies
import { SecretProofTransaction } from 'symbol-sdk';
// internal dependencies
import { TransactionView } from './TransactionView';
import { TransactionDetailItem } from '@/core/transactions/TransactionDetailItem';

export class ViewSecretProofTransaction extends TransactionView<SecretProofTransaction> {
/**
* Displayed items
*/
protected resolveDetailItems(): TransactionDetailItem[] {
return [
{ key: 'transfer_target', value: this.transaction.recipientAddress, isAddress: true },
{ key: 'deadline', value: this.transaction.deadline },
{
key: 'secret',
value: this.transaction.secret,
},
{
key: 'lock_hash_algorithm',
value: this.transaction.hashAlgorithm,
},
{
key: 'proof',
value: this.transaction.proof,
},
];
}
}

0 comments on commit 51ad192

Please sign in to comment.