diff --git a/examples/demo.js b/examples/demo.js index 7c35b31..b5755cf 100644 --- a/examples/demo.js +++ b/examples/demo.js @@ -252,6 +252,18 @@ function divider() { divider(); + const extendStoringResult = await DkgClient.asset.extendStoringPeriod(createAssetResult.UAL, 2); + console.log(`======================== ASSET STORING PERIOD EXTENDED`); + console.log(extendStoringResult); + + divider(); + + const addTokensResult = await DkgClient.asset.addTokens(createAssetResult.UAL, {tokenAmount: 1000}); + console.log(`======================== ADD TOKENS FOR AN ASSET`); + console.log(addTokensResult); + + divider(); + const newOwner = '0x2ACa90078563133db78085F66e6B8Cf5531623Ad'; const transferResult = await DkgClient.asset.transfer(createAssetResult.UAL, newOwner); console.log(`======================== ASSET TRANSFERRED TO ${newOwner}`); diff --git a/examples/paranet-demo.js b/examples/paranet-demo.js index 28ddc31..1c9ce9a 100644 --- a/examples/paranet-demo.js +++ b/examples/paranet-demo.js @@ -103,8 +103,9 @@ function divider() { console.log(paranetServiceUAL); divider(); - await DkgClient.paranet.addServices(paranetAssetResult.UAL, [ createServiceKAResult.UAL]); + const addServiceToParanet = await DkgClient.paranet.addServices(paranetAssetResult.UAL, [createServiceKAResult.UAL,]); console.log('======================== SERVICE ADDED TO PARANET'); + console.log(addServiceToParanet); divider(); content = { @@ -154,7 +155,7 @@ function divider() { divider(); let claimable = await DkgClient.paranet.getClaimableMinerReward(paranetAssetResult.UAL); - console.log('======================== KA MINER REWARD TO CLAIM') + console.log('======================== KA MINER REWARD TO CLAIM'); console.log(claimable); divider(); diff --git a/managers/asset-operations-manager.js b/managers/asset-operations-manager.js index 7e3ccd2..17c9849 100644 --- a/managers/asset-operations-manager.js +++ b/managers/asset-operations-manager.js @@ -152,6 +152,7 @@ class AssetOperationsManager { if (receipt) { return { + operation: receipt, transactionHash: receipt.transactionHash, status: receipt.status, }; @@ -185,6 +186,7 @@ class AssetOperationsManager { ); return { + operation: receipt, transactionHash: receipt.transactionHash, status: receipt.status, }; @@ -225,6 +227,7 @@ class AssetOperationsManager { ); return { + operation: receipt, transactionHash: receipt.transactionHash, status: receipt.status, }; @@ -301,7 +304,7 @@ class AssetOperationsManager { immutable, tokenAmount, authToken, - paranetUAL + paranetUAL, ); const { public: publicAssertion, private: privateAssertion } = await formatGraph( @@ -338,8 +341,9 @@ class AssetOperationsManager { )); let tokenId; - if(paranetUAL == null) { - tokenId = await this.blockchainService.createAsset( + let receipt; + if (paranetUAL == null) { + ({tokenId, receipt} = await this.blockchainService.createAsset( { publicAssertionId, assertionSize: publicAssertionSizeInBytes, @@ -354,10 +358,10 @@ class AssetOperationsManager { null, blockchain, stepHooks, - ); + )); } else { const { contract: paranetKaContract, tokenId: paranetTokenId } = resolveUAL(paranetUAL); - tokenId = await this.blockchainService.createAsset( + ({tokenId, receipt} = await this.blockchainService.createAsset( { publicAssertionId, assertionSize: publicAssertionSizeInBytes, @@ -372,7 +376,7 @@ class AssetOperationsManager { paranetTokenId, blockchain, stepHooks, - ); + )); } const resolvedUAL = { @@ -399,7 +403,7 @@ class AssetOperationsManager { const UAL = deriveUAL(blockchain.name, contentAssetStorageAddress, tokenId); - let operationId = await this.nodeApiService.publish( + let publishOperationId = await this.nodeApiService.publish( endpoint, port, authToken, @@ -411,53 +415,60 @@ class AssetOperationsManager { hashFunctionId, ); - let operationResult = await this.nodeApiService.getOperationResult( + let publishOperationResult = await this.nodeApiService.getOperationResult( endpoint, port, authToken, OPERATIONS.PUBLISH, maxNumberOfRetries, frequency, - operationId, + publishOperationId, ); - if (operationResult.status === OPERATION_STATUSES.FAILED) { + if (publishOperationResult.status === OPERATION_STATUSES.FAILED) { return { UAL, assertionId: publicAssertionId, - operation: getOperationStatusObject(operationResult, operationId), + operation: getOperationStatusObject(publishOperationResult, publishOperationId), }; } - operationId = await this.nodeApiService.localStore( + let localStoreOperationId = await this.nodeApiService.localStore( endpoint, port, authToken, assertions, ); - operationResult = await this.nodeApiService.getOperationResult( + let localStoreOperationResult = await this.nodeApiService.getOperationResult( endpoint, port, authToken, OPERATIONS.LOCAL_STORE, maxNumberOfRetries, DEFAULT_GET_LOCAL_STORE_RESULT_FREQUENCY, - operationId, + localStoreOperationId, ); stepHooks.afterHook({ status: OPERATIONS_STEP_STATUS.CREATE_ASSET_COMPLETED, data: { - operationId, - operationResult, + localStoreOperationId, + localStoreOperationResult, }, }); return { UAL, publicAssertionId, - operation: getOperationStatusObject(operationResult, operationId), + operation: { + mintKnowledgeAsset: receipt, + publish: getOperationStatusObject(publishOperationResult, publishOperationId), + localStore: getOperationStatusObject( + localStoreOperationResult, + localStoreOperationId, + ), + }, }; } @@ -819,7 +830,7 @@ class AssetOperationsManager { ); } - await this.blockchainService.updateAsset( + let receipt = await this.blockchainService.updateAsset( tokenId, publicAssertionId, publicAssertionSizeInBytes, @@ -853,32 +864,35 @@ class AssetOperationsManager { }); } - let operationId = await this.nodeApiService.localStore( + let localStoreOperationId = await this.nodeApiService.localStore( endpoint, port, authToken, assertions, ); - let operationResult = await this.nodeApiService.getOperationResult( + let localStoreOperationResult = await this.nodeApiService.getOperationResult( endpoint, port, authToken, OPERATIONS.LOCAL_STORE, maxNumberOfRetries, DEFAULT_GET_LOCAL_STORE_RESULT_FREQUENCY, - operationId, + localStoreOperationId, ); - if (operationResult.status === OPERATION_STATUSES.FAILED) { + if (localStoreOperationResult.status === OPERATION_STATUSES.FAILED) { return { UAL, assertionId: publicAssertionId, - operation: getOperationStatusObject(operationResult, operationId), + operation: getOperationStatusObject( + localStoreOperationResult, + localStoreOperationId, + ), }; } - operationId = await this.nodeApiService.update( + let updateOperationId = await this.nodeApiService.update( endpoint, port, authToken, @@ -889,19 +903,23 @@ class AssetOperationsManager { tokenId, hashFunctionId, ); - operationResult = await this.nodeApiService.getOperationResult( + let updateOperationResult = await this.nodeApiService.getOperationResult( endpoint, port, authToken, OPERATIONS.UPDATE, maxNumberOfRetries, frequency, - operationId, + updateOperationId, ); return { UAL, publicAssertionId, - operation: getOperationStatusObject(operationResult, operationId), + operation: { + updateKnowledgeAsset: receipt, + localStore: getOperationStatusObject(localStoreOperationResult, updateOperationId), + update: getOperationStatusObject(updateOperationResult, localStoreOperationId), + }, }; } @@ -978,11 +996,11 @@ class AssetOperationsManager { this.validationService.validateAssetUpdateCancel(UAL, blockchain); const { tokenId } = resolveUAL(UAL); - await this.blockchainService.cancelAssetUpdate(tokenId, blockchain); + let receipt = await this.blockchainService.cancelAssetUpdate(tokenId, blockchain); return { UAL, - operation: getOperationStatusObject({ status: 'COMPLETED' }, null), + operation: receipt, }; } @@ -1000,12 +1018,12 @@ class AssetOperationsManager { this.validationService.validateAssetTransfer(UAL, newOwner, blockchain); const { tokenId } = resolveUAL(UAL); - await this.blockchainService.transferAsset(tokenId, newOwner, blockchain); + let receipt = await this.blockchainService.transferAsset(tokenId, newOwner, blockchain); const owner = await this.blockchainService.getAssetOwner(tokenId, blockchain); return { UAL, owner, - operation: getOperationStatusObject({ status: 'COMPLETED' }, null), + operation: receipt, }; } @@ -1132,11 +1150,10 @@ class AssetOperationsManager { this.validationService.validateAssetBurn(UAL, blockchain); const { tokenId } = resolveUAL(UAL); - await this.blockchainService.burnAsset(tokenId, blockchain); - + let receipt = await this.blockchainService.burnAsset(tokenId, blockchain); return { UAL, - operation: getOperationStatusObject({ status: 'COMPLETED' }, null), + operation: receipt, }; } @@ -1194,7 +1211,7 @@ class AssetOperationsManager { ); } - await this.blockchainService.extendAssetStoringPeriod( + let receipt = await this.blockchainService.extendAssetStoringPeriod( tokenId, epochsNumber, tokenAmountInWei, @@ -1203,7 +1220,7 @@ class AssetOperationsManager { return { UAL, - operation: getOperationStatusObject({ status: 'COMPLETED' }, null), + operation: receipt, }; } @@ -1260,11 +1277,11 @@ class AssetOperationsManager { } } - await this.blockchainService.addTokens(tokenId, tokenAmountInWei, blockchain); + let receipt = await this.blockchainService.addTokens(tokenId, tokenAmountInWei, blockchain); return { UAL, - operation: getOperationStatusObject({ status: 'COMPLETED' }, null), + operation: receipt, }; } @@ -1320,11 +1337,15 @@ class AssetOperationsManager { } } - await this.blockchainService.addUpdateTokens(tokenId, tokenAmountInWei, blockchain); + let receipt = await this.blockchainService.addUpdateTokens( + tokenId, + tokenAmountInWei, + blockchain, + ); return { UAL, - operation: getOperationStatusObject({ status: 'COMPLETED' }, null), + operation: receipt }; } @@ -1392,27 +1413,24 @@ class AssetOperationsManager { async submitToParanet(UAL, paranetUAL, options = {}) { const blockchain = this.inputService.getBlockchain(options); - this.validationService.validateSubmitToParanet( - UAL, - paranetUAL, - blockchain, - ); + this.validationService.validateSubmitToParanet(UAL, paranetUAL, blockchain); const { contract, tokenId } = resolveUAL(UAL); const { contract: paranetContract, tokenId: paranetTokenId } = resolveUAL(paranetUAL); - await this.blockchainService.submitToParanet({ + let receipt = await this.blockchainService.submitToParanet( + { paranetContract, paranetTokenId, contract, tokenId, }, - blockchain + blockchain, ); return { UAL, - operation: getOperationStatusObject({ status: 'COMPLETED' }, null), + operation: receipt }; } } diff --git a/managers/paranet-operations-manager.js b/managers/paranet-operations-manager.js index 89ce36b..8e5ffc5 100644 --- a/managers/paranet-operations-manager.js +++ b/managers/paranet-operations-manager.js @@ -42,7 +42,7 @@ class ParanetOperationsManager { const { contract, tokenId } = resolveUAL(UAL); - await this.blockchainService.registerParanet({ + let receipt = await this.blockchainService.registerParanet({ contract, tokenId, paranetName, @@ -53,6 +53,7 @@ class ParanetOperationsManager { return { paranetUAL: UAL, + operation: receipt }; } @@ -91,7 +92,7 @@ class ParanetOperationsManager { if(incentiveType === INCENTIVE_TYPE.NEUROWEB) { const {contract, tokenId} = resolveUAL(paranetUAL); - await this.blockchainService.deployNeuroIncentivesPool({ + let receipt = await this.blockchainService.deployNeuroIncentivesPool({ contract, tokenId, tracToNeuroEmissionMultiplier, @@ -109,7 +110,8 @@ class ParanetOperationsManager { return { paranetUAL, - incentivesPoolContractAddress: neuroIncentivesPoolAddress + incentivesPoolContractAddress: neuroIncentivesPoolAddress, + operation: receipt }; } @@ -146,7 +148,7 @@ class ParanetOperationsManager { const { contract, tokenId } = resolveUAL(UAL); - await this.blockchainService.registerParanetService({ + let receipt = await this.blockchainService.registerParanetService({ contract, tokenId, paranetServiceName, @@ -157,7 +159,8 @@ class ParanetOperationsManager { ); return { - serviceUAL: UAL + serviceUAL: UAL, + operation: receipt }; } @@ -186,7 +189,7 @@ class ParanetOperationsManager { processedServicesArray.push([ serviceContract, serviceTokenId ]); } - await this.blockchainService.addParanetServices({ + let receipt = await this.blockchainService.addParanetServices({ contract, tokenId, processedServicesArray @@ -196,7 +199,8 @@ class ParanetOperationsManager { return { paranetUAL, - paranetServiceUALs + paranetServiceUALs, + operation: receipt }; } @@ -224,6 +228,7 @@ class ParanetOperationsManager { const receipt = await this.blockchainService.claimKnowledgeMinerReward(paranetId, blockchain); return { + operation: receipt, transactionHash: receipt.transactionHash, status: receipt.status, }; @@ -253,6 +258,7 @@ class ParanetOperationsManager { const receipt = await this.blockchainService.claimVoterReward(paranetId, blockchain); return { + operation: receipt, transactionHash: receipt.transactionHash, status: receipt.status, }; @@ -282,6 +288,7 @@ class ParanetOperationsManager { const receipt = await this.blockchainService.claimOperatorReward(paranetId, blockchain); return { + operation: receipt, transactionHash: receipt.transactionHash, status: receipt.status, }; @@ -447,6 +454,7 @@ class ParanetOperationsManager { }, blockchain); return { + operation: receipt, transactionHash: receipt.transactionHash, status: receipt.status, }; diff --git a/services/blockchain-service/blockchain-service-base.js b/services/blockchain-service/blockchain-service-base.js index 2854578..ae889b5 100644 --- a/services/blockchain-service/blockchain-service-base.js +++ b/services/blockchain-service/blockchain-service-base.js @@ -341,7 +341,7 @@ class BlockchainServiceBase { data: { tokenId }, }); - return tokenId; + return { tokenId, receipt }; } catch (error) { if (allowanceIncreased) { await this.executeContractFunction(