-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2151 from OriginTrail/v6/prerelease/testnet
OriginTrail 6.0.0-beta.2.2.9 Testnet Release
- Loading branch information
Showing
22 changed files
with
340 additions
and
197 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
71 changes: 71 additions & 0 deletions
71
src/commands/protocols/publish/sender/local-store-command.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,71 @@ | ||
import { OPERATION_ID_STATUS, ERROR_TYPE, PUBLISH_TYPES } from '../../../../constants/constants.js'; | ||
import Command from '../../../command.js'; | ||
|
||
class LocalStoreCommand extends Command { | ||
constructor(ctx) { | ||
super(ctx); | ||
this.operationService = ctx.publishService; | ||
|
||
this.errorType = ERROR_TYPE.PUBLISH.PUBLISH_LOCAL_STORE_REMOTE_ERROR; | ||
} | ||
|
||
async execute(command) { | ||
const { publishType, operationId, assertionId } = command.data; | ||
|
||
await this.operationIdService.updateOperationIdStatus( | ||
operationId, | ||
OPERATION_ID_STATUS.PUBLISH.PUBLISH_LOCAL_STORE_START, | ||
); | ||
|
||
switch (publishType) { | ||
case PUBLISH_TYPES.ASSERTION: | ||
await this.operationService.localStoreAssertion(assertionId, operationId); | ||
break; | ||
case PUBLISH_TYPES.ASSET: | ||
await this.operationService.localStoreAsset( | ||
assertionId, | ||
command.data.blockchain, | ||
command.data.contract, | ||
command.data.tokenId, | ||
operationId, | ||
); | ||
break; | ||
case PUBLISH_TYPES.INDEX: | ||
await this.operationService.localStoreIndex( | ||
assertionId, | ||
command.data.blockchain, | ||
command.data.contract, | ||
command.data.tokenId, | ||
command.data.keyword, | ||
operationId, | ||
); | ||
break; | ||
default: | ||
throw Error(`Unknown publish type ${publishType}`); | ||
} | ||
|
||
await this.operationIdService.updateOperationIdStatus( | ||
operationId, | ||
OPERATION_ID_STATUS.PUBLISH.PUBLISH_LOCAL_STORE_END, | ||
); | ||
|
||
return this.continueSequence(command.data, command.sequence); | ||
} | ||
|
||
/** | ||
* Builds default localStoreCommand | ||
* @param map | ||
* @returns {{add, data: *, delay: *, deadline: *}} | ||
*/ | ||
default(map) { | ||
const command = { | ||
name: 'localStoreCommand', | ||
delay: 0, | ||
transactional: false, | ||
}; | ||
Object.assign(command, map); | ||
return command; | ||
} | ||
} | ||
|
||
export default LocalStoreCommand; |
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
Oops, something went wrong.