This repository has been archived by the owner on Jan 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: fix tests, fetchAssetLockPublicKeyHashFactory
- Loading branch information
Showing
54 changed files
with
602 additions
and
614 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...n/IdentityTopUpTransition/validation/state/validateIdentityTopUpTransitionStateFactory.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
const ValidationResult = require('../../../../../validation/ValidationResult'); | ||
|
||
/** | ||
* @return {validateIdentityTopUpTransitionData} | ||
* @return {validateIdentityTopUpTransitionState} | ||
*/ | ||
function validateIdentityTopUpTransitionStateFactory() { | ||
/** | ||
* @typedef validateIdentityTopUpTransitionData | ||
* @typedef {validateIdentityTopUpTransitionState} | ||
* @param {IdentityTopUpTransition} stateTransition | ||
* @return {ValidationResult} | ||
* @return {Promise<ValidationResult>} | ||
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
async function validateIdentityTopUpTransitionData(stateTransition) { | ||
async function validateIdentityTopUpTransitionState(stateTransition) { | ||
return new ValidationResult(); | ||
} | ||
|
||
return validateIdentityTopUpTransitionData; | ||
return validateIdentityTopUpTransitionState; | ||
} | ||
|
||
module.exports = validateIdentityTopUpTransitionStateFactory; |
49 changes: 49 additions & 0 deletions
49
lib/identity/stateTransition/assetLockProof/fetchAssetLockPublicKeyHash.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const { Transaction } = require('@dashevo/dashcore-lib'); | ||
|
||
const InstantAssetLockProof = require('./instant/InstantAssetLockProof'); | ||
const ChainAssetLockProof = require('./chain/ChainAssetLockProof'); | ||
|
||
/** | ||
* @param {StateRepository} stateRepository | ||
* @return {fetchAssetLockPublicKeyHash} | ||
*/ | ||
function fetchAssetLockPublicKeyHashFactory(stateRepository) { | ||
/** | ||
* @typedef {fetchAssetLockPublicKeyHash} | ||
* @param {InstantAssetLockProof|ChainAssetLockProof} assetLockProof | ||
* @return {Promise<Buffer>} | ||
*/ | ||
async function fetchAssetLockPublicKeyHash(assetLockProof) { | ||
let transaction; | ||
let outputIndex; | ||
|
||
if (assetLockProof instanceof InstantAssetLockProof) { | ||
transaction = assetLockProof.getTransaction(); | ||
outputIndex = assetLockProof.getOutputIndex(); | ||
} else if (assetLockProof instanceof ChainAssetLockProof) { | ||
const outPoint = Transaction.parseOutPointBuffer(assetLockProof.getOutPoint()); | ||
|
||
outputIndex = outPoint.outputIndex; | ||
|
||
const rawTransaction = await stateRepository.fetchTransaction(outPoint.transactionHash); | ||
|
||
if (!rawTransaction) { | ||
throw new Error(); | ||
} | ||
|
||
transaction = new Transaction(rawTransaction); | ||
} | ||
|
||
const output = transaction.outputs[outputIndex]; | ||
|
||
if (!output) { | ||
throw new Error(); | ||
} | ||
|
||
return output.script.getData(); | ||
} | ||
|
||
return fetchAssetLockPublicKeyHash; | ||
} | ||
|
||
module.exports = fetchAssetLockPublicKeyHashFactory; |
Oops, something went wrong.