From ed7522948c7fed74bb850fa4f711ef8ae621199c Mon Sep 17 00:00:00 2001 From: BogBogdan Date: Mon, 30 Dec 2024 12:35:27 +0100 Subject: [PATCH 01/10] added paymaster functions --- .../blockchain-service-base.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/services/blockchain-service/blockchain-service-base.js b/services/blockchain-service/blockchain-service-base.js index 1c3a37a..1335d62 100644 --- a/services/blockchain-service/blockchain-service-base.js +++ b/services/blockchain-service/blockchain-service-base.js @@ -26,6 +26,7 @@ const KnowledgeCollectionAbi = require('dkg-evm-module/abi/KnowledgeCollection.j const KnowledgeCollectionStorageAbi = require('dkg-evm-module/abi/KnowledgeCollectionStorage.json'); const AskStorageAbi = require('dkg-evm-module/abi/AskStorage.json'); const ChronosAbi = require('dkg-evm-module/abi/Chronos.json'); +const PaymasterAbi = require('dkg-evm-module/abi/Paymaster.json'); export default class BlockchainServiceBase { constructor(config = {}) { @@ -50,6 +51,7 @@ export default class BlockchainServiceBase { this.abis.KnowledgeCollectionStorage = KnowledgeCollectionStorageAbi; this.abis.AskStorage = AskStorageAbi; this.abis.Chronos = ChronosAbi; + this.abis.Paymaster = PaymasterAbi; this.abis.KnowledgeCollectionStorage.filter((obj) => obj.type === 'event').forEach( (event) => { @@ -1204,4 +1206,36 @@ export default class BlockchainServiceBase { convertToWei(ether) { return Web3.utils.toWei(ether.toString(), 'ether'); } + + //Paymaster functions + async addAllowedAddressPeymaster(blockchain, public_adress) { + + //const public_adress = await this.getPublicKey(blockchain); + + return this.callContractFunction('Paymaster', 'addAllowedAddress', [public_adress], blockchain); + } + + async removeAllowedAddressPeymaster(blockchain, public_adress) { + + //const public_adress = await this.getPublicKey(blockchain); + + return this.callContractFunction('Paymaster', 'removeAllowedAddress', [public_adress], blockchain); + } + + async fundPaymasterPeymaster(blockchain, tokenAmount) { + + return this.callContractFunction('Paymaster', 'fundPaymaster', [tokenAmount], blockchain); + + } + + async withdrawPeymaster(blockchain, recipient, tokenAmount) { + + return this.callContractFunction('Paymaster', 'withdraw', [], blockchain, recipient, tokenAmount); + } + + async coverCostPeymaster(blockchain, tokenAmount) { + + return this.callContractFunction('Paymaster', 'coverCost', [], blockchain, tokenAmount); + } + } From ca34321edfbe67aed4c48b672f6afca90c69831b Mon Sep 17 00:00:00 2001 From: BogBogdan Date: Mon, 30 Dec 2024 14:21:57 +0100 Subject: [PATCH 02/10] paymaster-manager.js added --- managers/paymaster-operations-manager.js | 116 ++++++++++++++++++ .../blockchain-service-base.js | 17 +-- 2 files changed, 125 insertions(+), 8 deletions(-) create mode 100644 managers/paymaster-operations-manager.js diff --git a/managers/paymaster-operations-manager.js b/managers/paymaster-operations-manager.js new file mode 100644 index 0000000..5d214b1 --- /dev/null +++ b/managers/paymaster-operations-manager.js @@ -0,0 +1,116 @@ +import { ethers } from 'ethers'; +import { resolveUAL } from '../services/utilities.js'; +import { INCENTIVE_TYPE } from '../constants.js'; + +export default class PaymasterOperationsManager { + + constructor(services) { + this.blockchainService = services.blockchainService; + this.inputService = services.inputService; + this.nodeApiService = services.nodeApiService; + this.validationService = services.validationService; + } + + /** + * Sets allowance to a given quantity of tokens. + * @async + * @param {BigInt} tokenAmount - The amount of tokens (Wei) to set the allowance. + * @param {Object} [options={}] - Additional options for increasing allowance - currently only blockchain option expected. + * @param {string} recipient - The address of the recipient (used for operations like withdrawal or funding). + * @param {string} hubAddress - The address of the recipient (used for operations like withdrawal or funding). + * @returns {Object} Object containing hash of blockchain transaction and status. + */ + + async deployPaymasterContract(options, hubAddress) { + try { + + const blockchain = this.inputService.getBlockchain(options); + + if(this.validationService.validateBlockchain(blockchain) && this.validationService.validateAddress(hubAddress)) + { + await this.blockchainService.deployPaymasterContractFunction(blockchain, hubAddress); + } + + } catch (error) { + console.error("Error deploying Paymaster contract:", error); + } + } + + async addAllowedAddress(options) { + try { + + const blockchain = this.inputService.getBlockchain(options); + const public_address = await this.blockchainService.getPublicKey(blockchain); + + if(this.validationService.validateBlockchain(blockchain) && this.validationService.validateAddress(public_address)) + { + await this.blockchainService.addAllowedAddressFunction(blockchain, public_address); + } + + } catch (error) { + console.error("Error adding allowed address:", error); + } + } + + async removeAllowedAddress(options) { + try { + + const blockchain = this.inputService.getBlockchain(options); + const public_address = await this.blockchainService.getPublicKey(blockchain); + + if(this.validationService.validateBlockchain(blockchain) && this.validationService.validateAddress(public_address)) + { + await this.blockchainService.removeAllowedAddressFunction(blockchain, public_address); + } + + } catch (error) { + console.error("Error removing allowed address:", error); + } + } + + + async fundPaymaster(options, tokenAmount) { + try { + + const blockchain = this.inputService.getBlockchain(options); + + if(this.validationService.validateBlockchain(blockchain) && this.validationService.validateTokenAmount(tokenAmount)) + { + await this.blockchainService.fundFunction(blockchain, tokenAmount); + } + + } catch (error) { + console.error("Error funding paymaster:", error); + } + } + + async withdraw(options, recipient, tokenAmount) { + try { + + const blockchain = this.inputService.getBlockchain(options); + + if(this.validationService.validateBlockchain(blockchain) && this.validationService.validateTokenAmount(tokenAmount) && this.validationService.validateAddress(recipient)) + { + await this.blockchainService.withdrawFunction(blockchain, recipient, tokenAmount); + } + + } catch (error) { + console.error("Error withdrawing:", error); + } + } + + async coverCost(options, tokenAmount) { + try { + + const blockchain = this.inputService.getBlockchain(options); + + if(this.validationService.validateBlockchain(blockchain) && this.validationService.validateTokenAmount(tokenAmount)) + { + await this.blockchainService.coverCostFunction(blockchain, tokenAmount); + } + + } catch (error) { + console.error("Error covering cost:", error); + } + } +} \ No newline at end of file diff --git a/services/blockchain-service/blockchain-service-base.js b/services/blockchain-service/blockchain-service-base.js index 1335d62..e6af71d 100644 --- a/services/blockchain-service/blockchain-service-base.js +++ b/services/blockchain-service/blockchain-service-base.js @@ -1208,32 +1208,33 @@ export default class BlockchainServiceBase { } //Paymaster functions - async addAllowedAddressPeymaster(blockchain, public_adress) { + async deployPaymasterContractFunction(blockchain, hubAddress) { - //const public_adress = await this.getPublicKey(blockchain); + return this.callContractFunction('Paymaster', 'constructor', [hubAddress], blockchain); + } + + async addAllowedAddressFunction(blockchain, public_adress) { return this.callContractFunction('Paymaster', 'addAllowedAddress', [public_adress], blockchain); } - async removeAllowedAddressPeymaster(blockchain, public_adress) { - - //const public_adress = await this.getPublicKey(blockchain); + async removeAllowedAddressFunction(blockchain, public_adress) { return this.callContractFunction('Paymaster', 'removeAllowedAddress', [public_adress], blockchain); } - async fundPaymasterPeymaster(blockchain, tokenAmount) { + async fundFunction(blockchain, tokenAmount) { return this.callContractFunction('Paymaster', 'fundPaymaster', [tokenAmount], blockchain); } - async withdrawPeymaster(blockchain, recipient, tokenAmount) { + async withdrawFunction(blockchain, recipient, tokenAmount) { return this.callContractFunction('Paymaster', 'withdraw', [], blockchain, recipient, tokenAmount); } - async coverCostPeymaster(blockchain, tokenAmount) { + async coverCostFunction(blockchain, tokenAmount) { return this.callContractFunction('Paymaster', 'coverCost', [], blockchain, tokenAmount); } From cdf0a1efd78fa565e6f75817e86422d664f1ae0c Mon Sep 17 00:00:00 2001 From: BogBogdan Date: Mon, 30 Dec 2024 17:02:18 +0100 Subject: [PATCH 03/10] Fixed code ready for review --- managers/paymaster-operations-manager.js | 48 +++++++++---------- .../blockchain-service-base.js | 19 ++++++-- services/validation-service.js | 20 ++++++++ 3 files changed, 57 insertions(+), 30 deletions(-) diff --git a/managers/paymaster-operations-manager.js b/managers/paymaster-operations-manager.js index 5d214b1..82c1988 100644 --- a/managers/paymaster-operations-manager.js +++ b/managers/paymaster-operations-manager.js @@ -1,34 +1,31 @@ -import { ethers } from 'ethers'; -import { resolveUAL } from '../services/utilities.js'; -import { INCENTIVE_TYPE } from '../constants.js'; export default class PaymasterOperationsManager { constructor(services) { this.blockchainService = services.blockchainService; this.inputService = services.inputService; - this.nodeApiService = services.nodeApiService; this.validationService = services.validationService; } /** - * Sets allowance to a given quantity of tokens. * @async * @param {BigInt} tokenAmount - The amount of tokens (Wei) to set the allowance. * @param {Object} [options={}] - Additional options for increasing allowance - currently only blockchain option expected. * @param {string} recipient - The address of the recipient (used for operations like withdrawal or funding). - * @param {string} hubAddress - The address of the recipient (used for operations like withdrawal or funding). * @returns {Object} Object containing hash of blockchain transaction and status. */ - async deployPaymasterContract(options, hubAddress) { + async deployPaymasterContract(options) { try { const blockchain = this.inputService.getBlockchain(options); - if(this.validationService.validateBlockchain(blockchain) && this.validationService.validateAddress(hubAddress)) + + if(this.validationService.validateBlockchain(blockchain)) { - await this.blockchainService.deployPaymasterContractFunction(blockchain, hubAddress); + const paymasterAddress = await this.blockchainService.deployPaymasterContract(blockchain); + + return paymasterAddress; } } catch (error) { @@ -36,15 +33,14 @@ export default class PaymasterOperationsManager { } } - async addAllowedAddress(options) { + async addAllowedAddress(addresToBeWhitelested, options) { try { const blockchain = this.inputService.getBlockchain(options); - const public_address = await this.blockchainService.getPublicKey(blockchain); - if(this.validationService.validateBlockchain(blockchain) && this.validationService.validateAddress(public_address)) + if(this.validationService.validatePaymasterAdress(blockchain, addresToBeWhitelested)) { - await this.blockchainService.addAllowedAddressFunction(blockchain, public_address); + await this.blockchainService.addAllowedAddress(blockchain, addresToBeWhitelested); } } catch (error) { @@ -52,15 +48,15 @@ export default class PaymasterOperationsManager { } } - async removeAllowedAddress(options) { + async removeAllowedAddress(addresToBeWhitelested, options) { try { const blockchain = this.inputService.getBlockchain(options); - const public_address = await this.blockchainService.getPublicKey(blockchain); + - if(this.validationService.validateBlockchain(blockchain) && this.validationService.validateAddress(public_address)) + if(this.validationService.validatePaymasterAdress(blockchain, addresToBeWhitelested)) { - await this.blockchainService.removeAllowedAddressFunction(blockchain, public_address); + await this.blockchainService.removeAllowedAddress(blockchain, addresToBeWhitelested); } } catch (error) { @@ -69,14 +65,14 @@ export default class PaymasterOperationsManager { } - async fundPaymaster(options, tokenAmount) { + async fundPaymaster(tokenAmount, options) { try { const blockchain = this.inputService.getBlockchain(options); - if(this.validationService.validateBlockchain(blockchain) && this.validationService.validateTokenAmount(tokenAmount)) + if(this.validationService.validatePaymasterToken(blockchain,tokenAmount)) { - await this.blockchainService.fundFunction(blockchain, tokenAmount); + await this.blockchainService.fund(blockchain, tokenAmount); } } catch (error) { @@ -84,14 +80,14 @@ export default class PaymasterOperationsManager { } } - async withdraw(options, recipient, tokenAmount) { + async withdraw(recipient, tokenAmount, options) { try { const blockchain = this.inputService.getBlockchain(options); - if(this.validationService.validateBlockchain(blockchain) && this.validationService.validateTokenAmount(tokenAmount) && this.validationService.validateAddress(recipient)) + if(this.validationService.validatePaymasterTokenAdress(blockchain, tokenAmount, recipient)) { - await this.blockchainService.withdrawFunction(blockchain, recipient, tokenAmount); + await this.blockchainService.withdraw(blockchain, recipient, tokenAmount); } } catch (error) { @@ -99,14 +95,14 @@ export default class PaymasterOperationsManager { } } - async coverCost(options, tokenAmount) { + async coverCost(tokenAmount, options) { try { const blockchain = this.inputService.getBlockchain(options); - if(this.validationService.validateBlockchain(blockchain) && this.validationService.validateTokenAmount(tokenAmount)) + if(this.validationService.validatePaymasterToken(blockchain, tokenAmount)) { - await this.blockchainService.coverCostFunction(blockchain, tokenAmount); + await this.blockchainService.coverCost(blockchain, tokenAmount); } } catch (error) { diff --git a/services/blockchain-service/blockchain-service-base.js b/services/blockchain-service/blockchain-service-base.js index e6af71d..e0f59dc 100644 --- a/services/blockchain-service/blockchain-service-base.js +++ b/services/blockchain-service/blockchain-service-base.js @@ -27,6 +27,7 @@ const KnowledgeCollectionStorageAbi = require('dkg-evm-module/abi/KnowledgeColle const AskStorageAbi = require('dkg-evm-module/abi/AskStorage.json'); const ChronosAbi = require('dkg-evm-module/abi/Chronos.json'); const PaymasterAbi = require('dkg-evm-module/abi/Paymaster.json'); +const PaymasterManagerAbi = require('dkg-evm-module/abi/PaymasterManager.json'); export default class BlockchainServiceBase { constructor(config = {}) { @@ -52,6 +53,7 @@ export default class BlockchainServiceBase { this.abis.AskStorage = AskStorageAbi; this.abis.Chronos = ChronosAbi; this.abis.Paymaster = PaymasterAbi; + this.abis.PaymasterManager = PaymasterManagerAbi; this.abis.KnowledgeCollectionStorage.filter((obj) => obj.type === 'event').forEach( (event) => { @@ -1208,9 +1210,18 @@ export default class BlockchainServiceBase { } //Paymaster functions - async deployPaymasterContractFunction(blockchain, hubAddress) { + async deployPaymasterContract(blockchain) { + + const paymasterAddress = await this.callContractFunction('PaymasterManager', 'constructor', [], blockchain); + + let { id } = await this.decodeEventLogs( + paymasterAddress, + 'deployPaymaster', + blockchain, + ); + + return { deployPaymaster: id, paymasterAddress }; - return this.callContractFunction('Paymaster', 'constructor', [hubAddress], blockchain); } async addAllowedAddressFunction(blockchain, public_adress) { @@ -1231,12 +1242,12 @@ export default class BlockchainServiceBase { async withdrawFunction(blockchain, recipient, tokenAmount) { - return this.callContractFunction('Paymaster', 'withdraw', [], blockchain, recipient, tokenAmount); + return this.callContractFunction('Paymaster', 'withdraw', [recipient, tokenAmount], blockchain); } async coverCostFunction(blockchain, tokenAmount) { - return this.callContractFunction('Paymaster', 'coverCost', [], blockchain, tokenAmount); + return this.callContractFunction('Paymaster', 'coverCost', [tokenAmount], blockchain); } } diff --git a/services/validation-service.js b/services/validation-service.js index a8b79a9..f54f347 100644 --- a/services/validation-service.js +++ b/services/validation-service.js @@ -773,4 +773,24 @@ export default class ValidationService { minimumNumberOfFinalizationConfirmations, ); } + + //Paymaster validator + + validatePaymasterAdress(blockchain, hubAddress) { + this.validateBlockchain(blockchain); + this.validateAddress(hubAddress); + } + + validatePaymasterToken(blockchain, tokenAmount) { + this.validateBlockchain(blockchain); + this.validateTokenAmount(tokenAmount); + } + + validatePaymasterTokenAdress(blockchain, tokenAmount, recipient) { + this.validateBlockchain(blockchain); + this.validateTokenAmount(tokenAmount); + this.validateAddress(recipient); + } + + } From 8868bb3a0f81c9420ea17afc5ecf1a580bd2e359 Mon Sep 17 00:00:00 2001 From: BogBogdan Date: Mon, 30 Dec 2024 20:01:55 +0100 Subject: [PATCH 04/10] Ran prettier on changed files and fixes --- managers/paymaster-operations-manager.js | 83 ++++++++----------- .../blockchain-service-base.js | 61 ++++++++------ 2 files changed, 70 insertions(+), 74 deletions(-) diff --git a/managers/paymaster-operations-manager.js b/managers/paymaster-operations-manager.js index 82c1988..9df2a4b 100644 --- a/managers/paymaster-operations-manager.js +++ b/managers/paymaster-operations-manager.js @@ -1,6 +1,4 @@ - export default class PaymasterOperationsManager { - constructor(services) { this.blockchainService = services.blockchainService; this.inputService = services.inputService; @@ -8,105 +6,96 @@ export default class PaymasterOperationsManager { } /** - * @async - * @param {BigInt} tokenAmount - The amount of tokens (Wei) to set the allowance. - * @param {Object} [options={}] - Additional options for increasing allowance - currently only blockchain option expected. - * @param {string} recipient - The address of the recipient (used for operations like withdrawal or funding). - * @returns {Object} Object containing hash of blockchain transaction and status. - */ + * @async + * @param {BigInt} tokenAmount - The amount of tokens (Wei) to set the allowance. + * @param {Object} [options={}] - Additional options for increasing allowance - currently only blockchain option expected. + * @param {string} recipient - The address of the recipient (used for operations like withdrawal or funding). + * @returns {Object} Object containing hash of blockchain transaction and status. + */ async deployPaymasterContract(options) { try { - const blockchain = this.inputService.getBlockchain(options); + if (this.validationService.validateBlockchain(blockchain)) { + const paymasterAddress = + await this.blockchainService.deployPaymasterContract(blockchain); - if(this.validationService.validateBlockchain(blockchain)) - { - const paymasterAddress = await this.blockchainService.deployPaymasterContract(blockchain); - return paymasterAddress; } - } catch (error) { - console.error("Error deploying Paymaster contract:", error); + console.error('Error deploying Paymaster contract:', error); } } async addAllowedAddress(addresToBeWhitelested, options) { try { - const blockchain = this.inputService.getBlockchain(options); - if(this.validationService.validatePaymasterAdress(blockchain, addresToBeWhitelested)) - { + if ( + this.validationService.validatePaymasterAddress(blockchain, addresToBeWhitelested) + ) { await this.blockchainService.addAllowedAddress(blockchain, addresToBeWhitelested); } - } catch (error) { - console.error("Error adding allowed address:", error); + console.error('Error adding allowed address:', error); } } async removeAllowedAddress(addresToBeWhitelested, options) { try { - const blockchain = this.inputService.getBlockchain(options); - - if(this.validationService.validatePaymasterAdress(blockchain, addresToBeWhitelested)) - { - await this.blockchainService.removeAllowedAddress(blockchain, addresToBeWhitelested); + if (this.validationService.validatePaymasterAdress(blockchain, addresToBeWhitelested)) { + await this.blockchainService.removeAllowedAddress( + blockchain, + addresToBeWhitelested, + ); } - } catch (error) { - console.error("Error removing allowed address:", error); + console.error('Error removing allowed address:', error); } } - async fundPaymaster(tokenAmount, options) { try { - const blockchain = this.inputService.getBlockchain(options); - if(this.validationService.validatePaymasterToken(blockchain,tokenAmount)) - { - await this.blockchainService.fund(blockchain, tokenAmount); + if (this.validationService.validatePaymasterToken(blockchain, tokenAmount)) { + await this.blockchainService.fundPaymaster(blockchain, tokenAmount); } - } catch (error) { - console.error("Error funding paymaster:", error); + console.error('Error funding paymaster:', error); } } async withdraw(recipient, tokenAmount, options) { try { - const blockchain = this.inputService.getBlockchain(options); - if(this.validationService.validatePaymasterTokenAdress(blockchain, tokenAmount, recipient)) - { - await this.blockchainService.withdraw(blockchain, recipient, tokenAmount); + if ( + this.validationService.validatePaymasterTokenAdress( + blockchain, + tokenAmount, + recipient, + ) + ) { + await this.blockchainService.withdrawPaymaster(blockchain, recipient, tokenAmount); } - } catch (error) { - console.error("Error withdrawing:", error); + console.error('Error withdrawing:', error); } } async coverCost(tokenAmount, options) { try { - const blockchain = this.inputService.getBlockchain(options); - if(this.validationService.validatePaymasterToken(blockchain, tokenAmount)) - { - await this.blockchainService.coverCost(blockchain, tokenAmount); + if (this.validationService.validatePaymasterToken(blockchain, tokenAmount)) { + await this.blockchainService.coverCostPaymaster(blockchain, tokenAmount); } - } catch (error) { - console.error("Error covering cost:", error); + console.error('Error covering cost:', error); } } -} \ No newline at end of file +} diff --git a/services/blockchain-service/blockchain-service-base.js b/services/blockchain-service/blockchain-service-base.js index e0f59dc..4a67d5a 100644 --- a/services/blockchain-service/blockchain-service-base.js +++ b/services/blockchain-service/blockchain-service-base.js @@ -148,8 +148,8 @@ export default class BlockchainServiceBase { blockchain.name.startsWith('otp') ? DEFAULT_GAS_PRICE.OTP : blockchain.name.startsWith('base') - ? DEFAULT_GAS_PRICE.BASE - : DEFAULT_GAS_PRICE.GNOSIS, + ? DEFAULT_GAS_PRICE.BASE + : DEFAULT_GAS_PRICE.GNOSIS, 'Gwei', ); } @@ -1148,8 +1148,8 @@ export default class BlockchainServiceBase { blockchain.name.startsWith('otp') ? DEFAULT_GAS_PRICE.OTP : blockchain.name.startsWith('base') - ? DEFAULT_GAS_PRICE.BASE - : DEFAULT_GAS_PRICE.GNOSIS, + ? DEFAULT_GAS_PRICE.BASE + : DEFAULT_GAS_PRICE.GNOSIS, 'Gwei', ); } @@ -1211,43 +1211,50 @@ export default class BlockchainServiceBase { //Paymaster functions async deployPaymasterContract(blockchain) { - - const paymasterAddress = await this.callContractFunction('PaymasterManager', 'constructor', [], blockchain); - - let { id } = await this.decodeEventLogs( - paymasterAddress, - 'deployPaymaster', + const paymasterAddress = await this.callContractFunction( + 'PaymasterManager', + 'constructor', + [], blockchain, ); - return { deployPaymaster: id, paymasterAddress }; + let { id } = await this.decodeEventLogs(paymasterAddress, 'deployPaymaster', blockchain); + return { deployPaymaster: id, paymasterAddress }; } - async addAllowedAddressFunction(blockchain, public_adress) { - - return this.callContractFunction('Paymaster', 'addAllowedAddress', [public_adress], blockchain); + async addAllowedAddress(blockchain, public_adress) { + return this.callContractFunction( + 'Paymaster', + 'addAllowedAddress', + [public_adress], + blockchain, + ); } - async removeAllowedAddressFunction(blockchain, public_adress) { - - return this.callContractFunction('Paymaster', 'removeAllowedAddress', [public_adress], blockchain); + async removeAllowedAddress(blockchain, public_adress) { + return this.callContractFunction( + 'Paymaster', + 'removeAllowedAddress', + [public_adress], + blockchain, + ); } - async fundFunction(blockchain, tokenAmount) { - - return this.callContractFunction('Paymaster', 'fundPaymaster', [tokenAmount], blockchain); - + async fundPaymaster(blockchain, tokenAmount) { + return this.callContractFunction('Paymaster', 'fundPaymaster', [tokenAmount], blockchain); } - async withdrawFunction(blockchain, recipient, tokenAmount) { - - return this.callContractFunction('Paymaster', 'withdraw', [recipient, tokenAmount], blockchain); + async withdrawPaymaster(blockchain, recipient, tokenAmount) { + return this.callContractFunction( + 'Paymaster', + 'withdraw', + [recipient, tokenAmount], + blockchain, + ); } - async coverCostFunction(blockchain, tokenAmount) { - + async coverCostPaymaster(blockchain, tokenAmount) { return this.callContractFunction('Paymaster', 'coverCost', [tokenAmount], blockchain); } - } From c41efbdc649f227b7d1d03e0296862a5b601fc8f Mon Sep 17 00:00:00 2001 From: BogBogdan Date: Tue, 31 Dec 2024 10:09:10 +0100 Subject: [PATCH 05/10] changes in deployPaymasterContract --- services/blockchain-service/blockchain-service-base.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/blockchain-service/blockchain-service-base.js b/services/blockchain-service/blockchain-service-base.js index 4a67d5a..486e58f 100644 --- a/services/blockchain-service/blockchain-service-base.js +++ b/services/blockchain-service/blockchain-service-base.js @@ -1211,16 +1211,16 @@ export default class BlockchainServiceBase { //Paymaster functions async deployPaymasterContract(blockchain) { - const paymasterAddress = await this.callContractFunction( + const paymasterAddressContract = await this.callContractFunction( 'PaymasterManager', 'constructor', [], blockchain, ); - let { id } = await this.decodeEventLogs(paymasterAddress, 'deployPaymaster', blockchain); + let { paymasterAddress } = await this.decodeEventLogs(paymasterAddressContract, 'deployPaymaster', blockchain); - return { deployPaymaster: id, paymasterAddress }; + return paymasterAddress; } async addAllowedAddress(blockchain, public_adress) { From b392907a02d6e36765ebea7f9a200b1e27bf48a4 Mon Sep 17 00:00:00 2001 From: BogBogdan Date: Tue, 31 Dec 2024 11:24:47 +0100 Subject: [PATCH 06/10] added demo-paymaster --- examples/demo-paymaster.js | 49 ++++++++++++++++++++++++ managers/paymaster-operations-manager.js | 7 ++-- services/validation-service.js | 2 +- 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 examples/demo-paymaster.js diff --git a/examples/demo-paymaster.js b/examples/demo-paymaster.js new file mode 100644 index 0000000..feb533e --- /dev/null +++ b/examples/demo-paymaster.js @@ -0,0 +1,49 @@ +import PaymasterOperationsManager from '../managers/paymaster-operations-manager.js'; +import BaseServiceManager from '../services/base-service-manager.js'; + +const config = { + nodeApiUrl: 'https://example.com/api', + blockchain: { + network: 'Base', + name: 'Base', + hubContract: '0xYourDeployedContractAddressHere', + rpc: 'https://base.rpc.url.here', + publicKey: '0xYourBasePublicKeyHere', + privateKey: '0xYourBasePrivateKeyHere' + }, +}; + +(async () => { + try { + + const baseServiceManager = new BaseServiceManager(config); + const services = baseServiceManager.getServices(); + + const paymasterManager = new PaymasterOperationsManager({ + blockchainService: services.blockchainService, + inputService: services.inputService, + validationService: services.validationService + }); + + const deployedAddress = await paymasterManager.deployPaymasterContract({ blockchain: 'Ethereum' }); + console.log('Deployed Address:', deployedAddress); + + await paymasterManager.addAllowedAddress('0x1dD2C730a2BcD26d6aEf7DCCF171FC2AB1384d14', { blockchain: 'Ethereum' }); + console.log('Added allowed address.'); + + await paymasterManager.removeAllowedAddress('0x1dD2C730a2BcD26d6aEf7DCCF171FC2AB1384d14', { blockchain: 'Ethereum' }); + console.log('Removed allowed address.'); + + await paymasterManager.fundPaymaster(BigInt(1000000), { blockchain: 'Ethereum' }); + console.log('Funded Paymaster.'); + + await paymasterManager.withdraw('0x1dD2C730a2BcD26d6aEf7DCCF171FC2AB1384d14', BigInt(500000), { blockchain: 'Ethereum' }); + console.log('Withdrawal complete.'); + + await paymasterManager.coverCost(BigInt(200000), { blockchain: 'Ethereum' }); + console.log('Covered cost.'); + + } catch (error) { + console.error('Error during tests:', error); + } +})(); diff --git a/managers/paymaster-operations-manager.js b/managers/paymaster-operations-manager.js index 9df2a4b..deeb516 100644 --- a/managers/paymaster-operations-manager.js +++ b/managers/paymaster-operations-manager.js @@ -16,7 +16,7 @@ export default class PaymasterOperationsManager { async deployPaymasterContract(options) { try { const blockchain = this.inputService.getBlockchain(options); - + if (this.validationService.validateBlockchain(blockchain)) { const paymasterAddress = await this.blockchainService.deployPaymasterContract(blockchain); @@ -31,7 +31,8 @@ export default class PaymasterOperationsManager { async addAllowedAddress(addresToBeWhitelested, options) { try { const blockchain = this.inputService.getBlockchain(options); - + + if ( this.validationService.validatePaymasterAddress(blockchain, addresToBeWhitelested) ) { @@ -46,7 +47,7 @@ export default class PaymasterOperationsManager { try { const blockchain = this.inputService.getBlockchain(options); - if (this.validationService.validatePaymasterAdress(blockchain, addresToBeWhitelested)) { + if (this.validationService.validatePaymasterAddress(blockchain, addresToBeWhitelested)) { await this.blockchainService.removeAllowedAddress( blockchain, addresToBeWhitelested, diff --git a/services/validation-service.js b/services/validation-service.js index f54f347..cfa3fec 100644 --- a/services/validation-service.js +++ b/services/validation-service.js @@ -776,7 +776,7 @@ export default class ValidationService { //Paymaster validator - validatePaymasterAdress(blockchain, hubAddress) { + validatePaymasterAddress(blockchain, hubAddress) { this.validateBlockchain(blockchain); this.validateAddress(hubAddress); } From a0b84eaffc4fdde4ba08423ec9f418f208351d5a Mon Sep 17 00:00:00 2001 From: BogBogdan Date: Fri, 3 Jan 2025 14:43:10 +0100 Subject: [PATCH 07/10] new push --- examples/demo-paymaster.js | 21 ++-- examples/demo.js | 26 ++-- examples/paymaster-demo.js | 113 ++++++++++++++++++ index.cjs | 86 ++++++++++++- index.js | 2 + managers/paymaster-operations-manager.js | 67 ++++------- .../blockchain-service-base.js | 24 ++-- .../node-blockchain-service.js | 12 ++ services/validation-service.js | 1 - 9 files changed, 274 insertions(+), 78 deletions(-) create mode 100644 examples/paymaster-demo.js diff --git a/examples/demo-paymaster.js b/examples/demo-paymaster.js index feb533e..796ab8a 100644 --- a/examples/demo-paymaster.js +++ b/examples/demo-paymaster.js @@ -1,15 +1,16 @@ import PaymasterOperationsManager from '../managers/paymaster-operations-manager.js'; import BaseServiceManager from '../services/base-service-manager.js'; +const PUBLIC_KEY = ''; +const PRIVATE_KEY = ''; + + const config = { - nodeApiUrl: 'https://example.com/api', + //nodeApiUrl: 'https://example.com/api', blockchain: { - network: 'Base', - name: 'Base', - hubContract: '0xYourDeployedContractAddressHere', - rpc: 'https://base.rpc.url.here', - publicKey: '0xYourBasePublicKeyHere', - privateKey: '0xYourBasePrivateKeyHere' + name: 'otp:20430', + publicKey: PUBLIC_KEY, + privateKey: PRIVATE_KEY, }, }; @@ -28,16 +29,16 @@ const config = { const deployedAddress = await paymasterManager.deployPaymasterContract({ blockchain: 'Ethereum' }); console.log('Deployed Address:', deployedAddress); - await paymasterManager.addAllowedAddress('0x1dD2C730a2BcD26d6aEf7DCCF171FC2AB1384d14', { blockchain: 'Ethereum' }); + await paymasterManager.addAllowedAddress('0x404028D4Bda2B3f2558695A09a9a31dF138Dc5F6', { blockchain: 'Ethereum' }); console.log('Added allowed address.'); - await paymasterManager.removeAllowedAddress('0x1dD2C730a2BcD26d6aEf7DCCF171FC2AB1384d14', { blockchain: 'Ethereum' }); + await paymasterManager.removeAllowedAddress('0x404028D4Bda2B3f2558695A09a9a31dF138Dc5F6', { blockchain: 'Ethereum' }); console.log('Removed allowed address.'); await paymasterManager.fundPaymaster(BigInt(1000000), { blockchain: 'Ethereum' }); console.log('Funded Paymaster.'); - await paymasterManager.withdraw('0x1dD2C730a2BcD26d6aEf7DCCF171FC2AB1384d14', BigInt(500000), { blockchain: 'Ethereum' }); + await paymasterManager.withdraw('0x404028D4Bda2B3f2558695A09a9a31dF138Dc5F6', BigInt(500000), { blockchain: 'Ethereum' }); console.log('Withdrawal complete.'); await paymasterManager.coverCost(BigInt(200000), { blockchain: 'Ethereum' }); diff --git a/examples/demo.js b/examples/demo.js index 4b51973..46360ce 100644 --- a/examples/demo.js +++ b/examples/demo.js @@ -2,18 +2,18 @@ import jsonld from 'jsonld'; import DKG from '../index.js'; import { sleepForMilliseconds } from '../services/utilities.js'; -const ENVIRONMENT = 'development'; -const OT_NODE_HOSTNAME = 'http://localhost'; +const ENVIRONMENT = 'testnet'; +const OT_NODE_HOSTNAME = 'https://v6-pegasus-node-06.origin-trail.network'; const OT_NODE_PORT = '8900'; -const PUBLIC_KEY = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'; -const PRIVATE_KEY = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'; +const PUBLIC_KEY = ''; +const PRIVATE_KEY = ''; const DkgClient = new DKG({ environment: ENVIRONMENT, endpoint: OT_NODE_HOSTNAME, port: OT_NODE_PORT, blockchain: { - name: 'hardhat1', + name: 'otp:20430', publicKey: PUBLIC_KEY, privateKey: PRIVATE_KEY, }, @@ -117,15 +117,15 @@ function divider() { // divider(); - // console.time('Publish (5 replications, 5 finalizations)'); - // const result3 = await DkgClient.asset.create(content, { - // epochsNum: 2, - // minimumNumberOfFinalizationConfirmations: 3, - // minimumNumberOfNodeReplications: 3, - // }); - // console.timeEnd('Publish (5 replications, 5 finalizations)'); + console.time('Publish (5 replications, 5 finalizations)'); + const result3 = await DkgClient.asset.create(content, { + epochsNum: 2, + minimumNumberOfFinalizationConfirmations: 3, + minimumNumberOfNodeReplications: 3, + });//payer in options + console.timeEnd('Publish (5 replications, 5 finalizations)'); - // console.log(JSON.stringify(result3, null, 2)); + console.log(JSON.stringify(result3, null, 2)); // divider(); diff --git a/examples/paymaster-demo.js b/examples/paymaster-demo.js new file mode 100644 index 0000000..c273a71 --- /dev/null +++ b/examples/paymaster-demo.js @@ -0,0 +1,113 @@ +import jsonld from 'jsonld'; +import DKG from '../index.js'; +import { sleepForMilliseconds } from '../services/utilities.js'; + +const ENVIRONMENT = 'testnet'; +const OT_NODE_HOSTNAME = 'https://v6-pegasus-node-06.origin-trail.network'; +const OT_NODE_PORT = '8900'; +const PUBLIC_KEY = ''; +const PRIVATE_KEY = ''; + +const DkgClient = new DKG({ + environment: ENVIRONMENT, + endpoint: OT_NODE_HOSTNAME, + port: OT_NODE_PORT, + blockchain: { + name: 'otp:20430', + publicKey: PUBLIC_KEY, + privateKey: PRIVATE_KEY, + }, + maxNumberOfRetries: 300, + frequency: 2, + contentType: 'all', + nodeApiVersion: '/v1', +}); + +function divider() { + console.log('=================================================='); + console.log('=================================================='); + console.log('=================================================='); +} + + +(async () => { + + const content = { + private: { + '@context': 'https://www.schema.org', + '@id': 'urn:eu-pp:safety-test:3oRIwPtUOJapwNSAGZTzCOWR9bEo', + '@type': 'ProductSafetyTest', + testType: 'Functional Safety Test', + testResults: 'Fail', + relatedProduct: [ + { + '@id': 'urn:epc:id:sgtin:59G1yu8uivSRKLLu', + name: '59G1yu8uivSRKLLu', + }, + ], + }, + }; + + const nodeInfo = await DkgClient.node.info(); + console.log('======================== NODE INFO RECEIVED'); + console.log(nodeInfo); + + divider(); + + //Publish paymaster + + // const deployedAddress = await DkgClient.paymaster.deployPaymasterContract({ + // epochsNum: 2, + // minimumNumberOfFinalizationConfirmations: 3, + // minimumNumberOfNodeReplications: 3, + // }); + + // console.log('Deployed Address:', deployedAddress); + + await DkgClient.paymaster.addAllowedAddress('0x1d23852331eDA24d1b6F5E21fdc419A38B0de28c',); + console.log('Added allowed address.'); + + // await DkgClient.paymaster.removeAllowedAddress('0x404028D4Bda2B3f2558695A09a9a31dF138Dc5F6', { + // epochsNum: 2, + // minimumNumberOfFinalizationConfirmations: 3, + // minimumNumberOfNodeReplications: 3, + // }); + // console.log('Removed allowed address.'); + + await DkgClient.paymaster.fundPaymaster(BigInt(1000000), { + epochsNum: 2, + minimumNumberOfFinalizationConfirmations: 3, + minimumNumberOfNodeReplications: 3, + }); + console.log('Funded Paymaster.'); + + //Allowe adress + await DkgClient.paymaster.deployPaymasterContract({ + epochsNum: 2, + minimumNumberOfFinalizationConfirmations: 3, + minimumNumberOfNodeReplications: 3, + }); + + // + + + console.time('Publish (5 replications, 5 finalizations)'); + const result3 = await DkgClient.asset.create(content, { + epochsNum: 2, + minimumNumberOfFinalizationConfirmations: 3, + minimumNumberOfNodeReplications: 3, + });//payer in options + + console.timeEnd('Publish (5 replications, 5 finalizations)'); + + console.log(JSON.stringify(result3, null, 2)); + + console.time('get'); + const getOperationResult = await DkgClient.graph.get( + 'did:dkg:base:84532/0xd5550173b0f7b8766ab2770e4ba86caf714a5af5/2', + ); + console.log('======================== ASSET GET'); + console.log(getOperationResult); + console.timeEnd('get'); + +})(); diff --git a/index.cjs b/index.cjs index 1be15e8..87bfe65 100644 --- a/index.cjs +++ b/index.cjs @@ -3124,6 +3124,8 @@ const KnowledgeCollectionAbi = require$1('dkg-evm-module/abi/KnowledgeCollection const KnowledgeCollectionStorageAbi = require$1('dkg-evm-module/abi/KnowledgeCollectionStorage.json'); const AskStorageAbi = require$1('dkg-evm-module/abi/AskStorage.json'); const ChronosAbi = require$1('dkg-evm-module/abi/Chronos.json'); +const PaymasterAbi = require$1('dkg-evm-module/abi/Paymaster.json'); +const PaymasterManagerAbi = require$1('dkg-evm-module/abi/PaymasterManager.json'); class BlockchainServiceBase { constructor(config = {}) { @@ -3148,6 +3150,8 @@ class BlockchainServiceBase { this.abis.KnowledgeCollectionStorage = KnowledgeCollectionStorageAbi; this.abis.AskStorage = AskStorageAbi; this.abis.Chronos = ChronosAbi; + this.abis.Paymaster = PaymasterAbi; + this.abis.PaymasterManager = PaymasterManagerAbi; this.abis.KnowledgeCollectionStorage.filter((obj) => obj.type === 'event').forEach( (event) => { @@ -3242,8 +3246,8 @@ class BlockchainServiceBase { blockchain.name.startsWith('otp') ? DEFAULT_GAS_PRICE.OTP : blockchain.name.startsWith('base') - ? DEFAULT_GAS_PRICE.BASE - : DEFAULT_GAS_PRICE.GNOSIS, + ? DEFAULT_GAS_PRICE.BASE + : DEFAULT_GAS_PRICE.GNOSIS, 'Gwei', ); } @@ -3502,9 +3506,10 @@ class BlockchainServiceBase { paranetKaContract, paranetTokenId, blockchain, + paymaster = null, stepHooks = emptyHooks, ) { - const sender = await this.getPublicKey(blockchain); + const sender = paymaster || await this.getPublicKey(blockchain); try { let allowanceIncreased, allowanceGap; @@ -4231,8 +4236,8 @@ class BlockchainServiceBase { blockchain.name.startsWith('otp') ? DEFAULT_GAS_PRICE.OTP : blockchain.name.startsWith('base') - ? DEFAULT_GAS_PRICE.BASE - : DEFAULT_GAS_PRICE.GNOSIS, + ? DEFAULT_GAS_PRICE.BASE + : DEFAULT_GAS_PRICE.GNOSIS, 'Gwei', ); } @@ -4291,6 +4296,55 @@ class BlockchainServiceBase { convertToWei(ether) { return Web3.utils.toWei(ether.toString(), 'ether'); } + + //Paymaster functions + async deployPaymasterContract(blockchain) { + const paymasterAddressContract = await this.callContractFunction( + 'PaymasterManager', + 'constructor', + [], + blockchain, + ); + + let { paymasterAddress } = await this.decodeEventLogs(paymasterAddressContract, 'deployPaymaster', blockchain); + + return paymasterAddress; + } + + async addAllowedAddress(blockchain, public_adress) { + return this.callContractFunction( + 'Paymaster', + 'addAllowedAddress', + [public_adress], + blockchain, + ); + } + + async removeAllowedAddress(blockchain, public_adress) { + return this.callContractFunction( + 'Paymaster', + 'removeAllowedAddress', + [public_adress], + blockchain, + ); + } + + async fundPaymaster(blockchain, tokenAmount) { + return this.callContractFunction('Paymaster', 'fundPaymaster', [tokenAmount], blockchain); + } + + async withdrawPaymaster(blockchain, recipient, tokenAmount) { + return this.callContractFunction( + 'Paymaster', + 'withdraw', + [recipient, tokenAmount], + blockchain, + ); + } + + async coverCostPaymaster(blockchain, tokenAmount) { + return this.callContractFunction('Paymaster', 'coverCost', [tokenAmount], blockchain); + } } /* eslint-disable no-await-in-loop */ @@ -4433,7 +4487,7 @@ class NodeBlockchainService extends BlockchainServiceBase { this.abis.KnowledgeCollectionStorage.filter((obj) => obj.type === 'event').forEach( (event) => { const concatInputs = event.inputs.map((input) => input.internalType); - + this.events[event.name] = { hash: Web3.utils.keccak256(`${event.name}(${concatInputs})`), inputs: event.inputs, @@ -5326,6 +5380,26 @@ class ValidationService { minimumNumberOfFinalizationConfirmations, ); } + + //Paymaster validator + + validatePaymasterAddress(blockchain, hubAddress) { + this.validateBlockchain(blockchain); + this.validateAddress(hubAddress); + } + + validatePaymasterToken(blockchain, tokenAmount) { + this.validateBlockchain(blockchain); + this.validateTokenAmount(tokenAmount); + } + + validatePaymasterTokenAdress(blockchain, tokenAmount, recipient) { + this.validateBlockchain(blockchain); + this.validateTokenAmount(tokenAmount); + this.validateAddress(recipient); + } + + } class InputService { diff --git a/index.js b/index.js index b456fe9..9c2a3e0 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,7 @@ import GraphOperationsManager from './managers/graph-operations-manager.js'; import NetworkOperationsManager from './managers/network-operations-manager.js'; import NodeOperationsManager from './managers/node-operations-manager.js'; import ParanetOperationsManager from './managers/paranet-operations-manager.js'; +import PaymasterOperationsManager from './managers/paymaster-operations-manager.js'; import BaseServiceManager from './services/base-service-manager.js'; @@ -21,6 +22,7 @@ export default class DkgClient { this.graph = new GraphOperationsManager(services); this.network = new NetworkOperationsManager(services); this.paranet = new ParanetOperationsManager(services); + this.paymaster = new PaymasterOperationsManager(services); // Backwards compatibility this.graph.get = this.asset.get.bind(this.asset); diff --git a/managers/paymaster-operations-manager.js b/managers/paymaster-operations-manager.js index deeb516..18f99b4 100644 --- a/managers/paymaster-operations-manager.js +++ b/managers/paymaster-operations-manager.js @@ -16,13 +16,13 @@ export default class PaymasterOperationsManager { async deployPaymasterContract(options) { try { const blockchain = this.inputService.getBlockchain(options); - - if (this.validationService.validateBlockchain(blockchain)) { - const paymasterAddress = - await this.blockchainService.deployPaymasterContract(blockchain); + + this.validationService.validateBlockchain(blockchain); + + const paymasterAddress = await this.blockchainService.deployPaymasterContract(blockchain); - return paymasterAddress; - } + return paymasterAddress; + } catch (error) { console.error('Error deploying Paymaster contract:', error); } @@ -31,13 +31,11 @@ export default class PaymasterOperationsManager { async addAllowedAddress(addresToBeWhitelested, options) { try { const blockchain = this.inputService.getBlockchain(options); - + + this.validationService.validatePaymasterAddress(blockchain, addresToBeWhitelested); - if ( - this.validationService.validatePaymasterAddress(blockchain, addresToBeWhitelested) - ) { - await this.blockchainService.addAllowedAddress(blockchain, addresToBeWhitelested); - } + await this.blockchainService.addAllowedAddress(blockchain, addresToBeWhitelested); + } catch (error) { console.error('Error adding allowed address:', error); } @@ -47,12 +45,10 @@ export default class PaymasterOperationsManager { try { const blockchain = this.inputService.getBlockchain(options); - if (this.validationService.validatePaymasterAddress(blockchain, addresToBeWhitelested)) { - await this.blockchainService.removeAllowedAddress( - blockchain, - addresToBeWhitelested, - ); - } + this.validationService.validatePaymasterAddress(blockchain, addresToBeWhitelested); + + await this.blockchainService.removeAllowedAddress(blockchain, addresToBeWhitelested); + } catch (error) { console.error('Error removing allowed address:', error); } @@ -62,9 +58,10 @@ export default class PaymasterOperationsManager { try { const blockchain = this.inputService.getBlockchain(options); - if (this.validationService.validatePaymasterToken(blockchain, tokenAmount)) { - await this.blockchainService.fundPaymaster(blockchain, tokenAmount); - } + this.validationService.validatePaymasterToken(blockchain, tokenAmount); + + await this.blockchainService.fundPaymaster(blockchain, tokenAmount); + } catch (error) { console.error('Error funding paymaster:', error); } @@ -74,29 +71,17 @@ export default class PaymasterOperationsManager { try { const blockchain = this.inputService.getBlockchain(options); - if ( - this.validationService.validatePaymasterTokenAdress( - blockchain, - tokenAmount, - recipient, - ) - ) { - await this.blockchainService.withdrawPaymaster(blockchain, recipient, tokenAmount); - } + this.validationService.validatePaymasterTokenAdress( + blockchain, + tokenAmount, + recipient, + ) + + await this.blockchainService.withdrawPaymaster(blockchain, recipient, tokenAmount); + } catch (error) { console.error('Error withdrawing:', error); } } - async coverCost(tokenAmount, options) { - try { - const blockchain = this.inputService.getBlockchain(options); - - if (this.validationService.validatePaymasterToken(blockchain, tokenAmount)) { - await this.blockchainService.coverCostPaymaster(blockchain, tokenAmount); - } - } catch (error) { - console.error('Error covering cost:', error); - } - } } diff --git a/services/blockchain-service/blockchain-service-base.js b/services/blockchain-service/blockchain-service-base.js index 486e58f..cb0270e 100644 --- a/services/blockchain-service/blockchain-service-base.js +++ b/services/blockchain-service/blockchain-service-base.js @@ -65,6 +65,18 @@ export default class BlockchainServiceBase { }; }, ); + + this.abis.PaymasterManager.filter((obj) => obj.type === 'event').forEach( + (event) => { + const concatInputs = event.inputs.map((input) => input.internalType); + + this.events[event.name] = { + hash: Web3.utils.keccak256(`${event.name}(${concatInputs})`), + inputs: event.inputs, + }; + + }, + ); } initializeWeb3() { @@ -410,7 +422,7 @@ export default class BlockchainServiceBase { blockchain, stepHooks = emptyHooks, ) { - const sender = await this.getPublicKey(blockchain); + const sender = await this.getPublicKey(blockchain); let serviceAgreementV1Address; let allowanceIncreased = false; let allowanceGap = 0; @@ -1211,14 +1223,15 @@ export default class BlockchainServiceBase { //Paymaster functions async deployPaymasterContract(blockchain) { - const paymasterAddressContract = await this.callContractFunction( + const paymasterAddressContract = await this.executeContractFunction( 'PaymasterManager', - 'constructor', + 'deployPaymaster', [], blockchain, ); - let { paymasterAddress } = await this.decodeEventLogs(paymasterAddressContract, 'deployPaymaster', blockchain); + + let { paymasterAddress } = await this.decodeEventLogs(paymasterAddressContract, 'PaymasterDeployed', blockchain); return paymasterAddress; } @@ -1254,7 +1267,4 @@ export default class BlockchainServiceBase { ); } - async coverCostPaymaster(blockchain, tokenAmount) { - return this.callContractFunction('Paymaster', 'coverCost', [tokenAmount], blockchain); - } } diff --git a/services/blockchain-service/implementations/node-blockchain-service.js b/services/blockchain-service/implementations/node-blockchain-service.js index ada2350..e9158f6 100644 --- a/services/blockchain-service/implementations/node-blockchain-service.js +++ b/services/blockchain-service/implementations/node-blockchain-service.js @@ -20,6 +20,18 @@ export default class NodeBlockchainService extends BlockchainServiceBase { }; }, ); + + this.abis.PaymasterManager.filter((obj) => obj.type === 'event').forEach( + (event) => { + const concatInputs = event.inputs.map((input) => input.internalType); + + this.events[event.name] = { + hash: Web3.utils.keccak256(`${event.name}(${concatInputs})`), + inputs: event.inputs, + }; + + }, + ); } initializeWeb3(blockchainName, blockchainRpc, blockchainOptions) { diff --git a/services/validation-service.js b/services/validation-service.js index cfa3fec..f8acfaf 100644 --- a/services/validation-service.js +++ b/services/validation-service.js @@ -605,7 +605,6 @@ export default class ValidationService { this.validateTransactionPollingTimeout(blockchain.transactionPollingTimeout); if (nodeSupported()) { this.validateRequiredParam('blockchain rpc', blockchain.rpc); - if (operation !== OPERATIONS.GET) { this.validateRequiredParam('blockchain public key', blockchain.publicKey); this.validateRequiredParam('blockchain private key', blockchain.privateKey); From 935b6386ade1158cc3123af088781d0250c07f1c Mon Sep 17 00:00:00 2001 From: BogBogdan Date: Mon, 6 Jan 2025 11:29:01 +0100 Subject: [PATCH 08/10] new commit --- examples/paymaster-demo.js | 22 ++++--- managers/paymaster-operations-manager.js | 25 ++++---- .../blockchain-service-base.js | 62 ++++++++++++++++--- services/validation-service.js | 9 ++- 4 files changed, 85 insertions(+), 33 deletions(-) diff --git a/examples/paymaster-demo.js b/examples/paymaster-demo.js index c273a71..d86bf06 100644 --- a/examples/paymaster-demo.js +++ b/examples/paymaster-demo.js @@ -3,7 +3,7 @@ import DKG from '../index.js'; import { sleepForMilliseconds } from '../services/utilities.js'; const ENVIRONMENT = 'testnet'; -const OT_NODE_HOSTNAME = 'https://v6-pegasus-node-06.origin-trail.network'; +const OT_NODE_HOSTNAME = 'https://v6-pegasus-node-02.origin-trail.network'; const OT_NODE_PORT = '8900'; const PUBLIC_KEY = ''; const PRIVATE_KEY = ''; @@ -56,15 +56,19 @@ function divider() { //Publish paymaster - // const deployedAddress = await DkgClient.paymaster.deployPaymasterContract({ - // epochsNum: 2, - // minimumNumberOfFinalizationConfirmations: 3, - // minimumNumberOfNodeReplications: 3, - // }); + const paymasterAddress = await DkgClient.paymaster.deployPaymasterContract({ + epochsNum: 2, + minimumNumberOfFinalizationConfirmations: 3, + minimumNumberOfNodeReplications: 3, + }); - // console.log('Deployed Address:', deployedAddress); + console.log('Deployed Address:', paymasterAddress); - await DkgClient.paymaster.addAllowedAddress('0x1d23852331eDA24d1b6F5E21fdc419A38B0de28c',); + await DkgClient.paymaster.addAllowedAddress(paymasterAddress, '0x1d23852331eDA24d1b6F5E21fdc419A38B0de28c',{ + epochsNum: 2, + minimumNumberOfFinalizationConfirmations: 3, + minimumNumberOfNodeReplications: 3, + }); console.log('Added allowed address.'); // await DkgClient.paymaster.removeAllowedAddress('0x404028D4Bda2B3f2558695A09a9a31dF138Dc5F6', { @@ -87,8 +91,6 @@ function divider() { minimumNumberOfFinalizationConfirmations: 3, minimumNumberOfNodeReplications: 3, }); - - // console.time('Publish (5 replications, 5 finalizations)'); diff --git a/managers/paymaster-operations-manager.js b/managers/paymaster-operations-manager.js index 18f99b4..f9bc1d7 100644 --- a/managers/paymaster-operations-manager.js +++ b/managers/paymaster-operations-manager.js @@ -13,7 +13,7 @@ export default class PaymasterOperationsManager { * @returns {Object} Object containing hash of blockchain transaction and status. */ - async deployPaymasterContract(options) { + async deployPaymasterContract(options = {}) { try { const blockchain = this.inputService.getBlockchain(options); @@ -28,56 +28,57 @@ export default class PaymasterOperationsManager { } } - async addAllowedAddress(addresToBeWhitelested, options) { + async addAllowedAddress(paymasterAddress,addresToBeWhitelested, options = {}) { try { const blockchain = this.inputService.getBlockchain(options); - this.validationService.validatePaymasterAddress(blockchain, addresToBeWhitelested); + this.validationService.validatePaymasterAddress(blockchain, paymasterAddress, addresToBeWhitelested); - await this.blockchainService.addAllowedAddress(blockchain, addresToBeWhitelested); + await this.blockchainService.addAllowedAddress(blockchain, paymasterAddress, addresToBeWhitelested); } catch (error) { console.error('Error adding allowed address:', error); } } - async removeAllowedAddress(addresToBeWhitelested, options) { + async removeAllowedAddress(paymasterAddress, addresToBeWhitelested, options = {}) { try { const blockchain = this.inputService.getBlockchain(options); - this.validationService.validatePaymasterAddress(blockchain, addresToBeWhitelested); + this.validationService.validatePaymasterAddress(blockchain, paymasterAddress, addresToBeWhitelested); - await this.blockchainService.removeAllowedAddress(blockchain, addresToBeWhitelested); + await this.blockchainService.removeAllowedAddress(blockchain,paymasterAddress, addresToBeWhitelested); } catch (error) { console.error('Error removing allowed address:', error); } } - async fundPaymaster(tokenAmount, options) { + async fundPaymaster(paymasterAddress, tokenAmount, options = {}) { try { const blockchain = this.inputService.getBlockchain(options); - this.validationService.validatePaymasterToken(blockchain, tokenAmount); + this.validationService.validatePaymasterToken(blockchain, paymasterAddress, tokenAmount); - await this.blockchainService.fundPaymaster(blockchain, tokenAmount); + await this.blockchainService.fundPaymaster(blockchain, paymasterAddress, tokenAmount); } catch (error) { console.error('Error funding paymaster:', error); } } - async withdraw(recipient, tokenAmount, options) { + async withdraw(paymasterAddress, recipient, tokenAmount, options = {}) { try { const blockchain = this.inputService.getBlockchain(options); this.validationService.validatePaymasterTokenAdress( blockchain, + paymasterAddress, tokenAmount, recipient, ) - await this.blockchainService.withdrawPaymaster(blockchain, recipient, tokenAmount); + await this.blockchainService.withdrawPaymaster(blockchain, paymasterAddress, recipient, tokenAmount); } catch (error) { console.error('Error withdrawing:', error); diff --git a/services/blockchain-service/blockchain-service-base.js b/services/blockchain-service/blockchain-service-base.js index cb0270e..02637eb 100644 --- a/services/blockchain-service/blockchain-service-base.js +++ b/services/blockchain-service/blockchain-service-base.js @@ -194,6 +194,44 @@ export default class BlockchainServiceBase { } } + async callContractFunctionPaymaster(paymasterAddress, contractName, functionName, args, blockchain) { + await this.ensureBlockchainInfo(blockchain); + + const web3Instance = await this.getWeb3Instance(blockchain); + + let paymasterContractInstance = new web3Instance.eth.Contract( + this.abis[contractName], + paymasterAddress, + { from: blockchain.publicKey }, + ) + + try { + return await paymasterContractInstance.methods[functionName](...args).call(); + } catch (error) { + if (/revert|VM Exception/i.test(error.message)) { + let status; + try { + status = await paymasterContractInstance.methods.status().call(); + } catch (_) { + status = false; + } + + if (!status && contractName !== 'ParanetNeuroIncentivesPool') { + await this.updateContractInstance(contractName, blockchain, true); + let paymasterContractInstance = new web3Instance.eth.Contract( + this.abis[contractName], + this[blockchain.name].contractAddress[blockchain.hubContract][contractName], + { from: blockchain.publicKey }, + ) + + return paymasterContractInstance.methods[functionName](...args).call(); + } + } + + throw error; + } + } + async prepareTransaction(contractInstance, functionName, args, blockchain) { await this.ensureBlockchainInfo(blockchain); const web3Instance = await this.getWeb3Instance(blockchain); @@ -1236,8 +1274,9 @@ export default class BlockchainServiceBase { return paymasterAddress; } - async addAllowedAddress(blockchain, public_adress) { - return this.callContractFunction( + async addAllowedAddress(blockchain, paymasterAddress, public_adress) { + return this.callContractFunctionPaymaster( + paymasterAddress, 'Paymaster', 'addAllowedAddress', [public_adress], @@ -1245,8 +1284,9 @@ export default class BlockchainServiceBase { ); } - async removeAllowedAddress(blockchain, public_adress) { - return this.callContractFunction( + async removeAllowedAddress(blockchain, paymasterAddress, public_adress) { + return this.callContractFunctionPaymaster( + paymasterAddress, 'Paymaster', 'removeAllowedAddress', [public_adress], @@ -1254,12 +1294,18 @@ export default class BlockchainServiceBase { ); } - async fundPaymaster(blockchain, tokenAmount) { - return this.callContractFunction('Paymaster', 'fundPaymaster', [tokenAmount], blockchain); + async fundPaymaster(blockchain, paymasterAddress, tokenAmount) { + return this.callContractFunctionPaymaster( + paymasterAddress, + 'Paymaster', + 'fundPaymaster', + [tokenAmount], + blockchain); } - async withdrawPaymaster(blockchain, recipient, tokenAmount) { - return this.callContractFunction( + async withdrawPaymaster(blockchain, paymasterAddress, recipient, tokenAmount) { + return this.callContractFunctionPaymaster( + paymasterAddress, 'Paymaster', 'withdraw', [recipient, tokenAmount], diff --git a/services/validation-service.js b/services/validation-service.js index f8acfaf..59f217c 100644 --- a/services/validation-service.js +++ b/services/validation-service.js @@ -775,18 +775,21 @@ export default class ValidationService { //Paymaster validator - validatePaymasterAddress(blockchain, hubAddress) { + validatePaymasterAddress(blockchain, paymasterAddress, hubAddress) { this.validateBlockchain(blockchain); + this.validateAddress(paymasterAddress); this.validateAddress(hubAddress); } - validatePaymasterToken(blockchain, tokenAmount) { + validatePaymasterToken(blockchain, paymasterAddress, tokenAmount) { this.validateBlockchain(blockchain); + this.validateAddress(paymasterAddress); this.validateTokenAmount(tokenAmount); } - validatePaymasterTokenAdress(blockchain, tokenAmount, recipient) { + validatePaymasterTokenAdress(blockchain, paymasterAddress, tokenAmount, recipient) { this.validateBlockchain(blockchain); + this.validateAddress(paymasterAddress); this.validateTokenAmount(tokenAmount); this.validateAddress(recipient); } From 35f1327efbe4c2d7be4d2bec5c5415418dd9a400 Mon Sep 17 00:00:00 2001 From: BogBogdan Date: Mon, 6 Jan 2025 14:36:59 +0100 Subject: [PATCH 09/10] new changes --- examples/demo-paymaster.js | 50 ---------- examples/paymaster-demo.js | 96 +++++++++---------- .../blockchain-service-base.js | 81 ++++++++++++++-- 3 files changed, 123 insertions(+), 104 deletions(-) delete mode 100644 examples/demo-paymaster.js diff --git a/examples/demo-paymaster.js b/examples/demo-paymaster.js deleted file mode 100644 index 796ab8a..0000000 --- a/examples/demo-paymaster.js +++ /dev/null @@ -1,50 +0,0 @@ -import PaymasterOperationsManager from '../managers/paymaster-operations-manager.js'; -import BaseServiceManager from '../services/base-service-manager.js'; - -const PUBLIC_KEY = ''; -const PRIVATE_KEY = ''; - - -const config = { - //nodeApiUrl: 'https://example.com/api', - blockchain: { - name: 'otp:20430', - publicKey: PUBLIC_KEY, - privateKey: PRIVATE_KEY, - }, -}; - -(async () => { - try { - - const baseServiceManager = new BaseServiceManager(config); - const services = baseServiceManager.getServices(); - - const paymasterManager = new PaymasterOperationsManager({ - blockchainService: services.blockchainService, - inputService: services.inputService, - validationService: services.validationService - }); - - const deployedAddress = await paymasterManager.deployPaymasterContract({ blockchain: 'Ethereum' }); - console.log('Deployed Address:', deployedAddress); - - await paymasterManager.addAllowedAddress('0x404028D4Bda2B3f2558695A09a9a31dF138Dc5F6', { blockchain: 'Ethereum' }); - console.log('Added allowed address.'); - - await paymasterManager.removeAllowedAddress('0x404028D4Bda2B3f2558695A09a9a31dF138Dc5F6', { blockchain: 'Ethereum' }); - console.log('Removed allowed address.'); - - await paymasterManager.fundPaymaster(BigInt(1000000), { blockchain: 'Ethereum' }); - console.log('Funded Paymaster.'); - - await paymasterManager.withdraw('0x404028D4Bda2B3f2558695A09a9a31dF138Dc5F6', BigInt(500000), { blockchain: 'Ethereum' }); - console.log('Withdrawal complete.'); - - await paymasterManager.coverCost(BigInt(200000), { blockchain: 'Ethereum' }); - console.log('Covered cost.'); - - } catch (error) { - console.error('Error during tests:', error); - } -})(); diff --git a/examples/paymaster-demo.js b/examples/paymaster-demo.js index d86bf06..cb589db 100644 --- a/examples/paymaster-demo.js +++ b/examples/paymaster-demo.js @@ -5,8 +5,8 @@ import { sleepForMilliseconds } from '../services/utilities.js'; const ENVIRONMENT = 'testnet'; const OT_NODE_HOSTNAME = 'https://v6-pegasus-node-02.origin-trail.network'; const OT_NODE_PORT = '8900'; -const PUBLIC_KEY = ''; -const PRIVATE_KEY = ''; +const PUBLIC_KEY = '0x1dD2C730a2BcD26d6aEf7DCCF171FC2AB1384d14'; +const PRIVATE_KEY = '8ae4f7c247ad422913c1c60187856091ad2bcb4e53fb2936d7633d7d02bd180a'; const DkgClient = new DKG({ environment: ENVIRONMENT, @@ -48,68 +48,68 @@ function divider() { }, }; - const nodeInfo = await DkgClient.node.info(); - console.log('======================== NODE INFO RECEIVED'); - console.log(nodeInfo); + // const nodeInfo = await DkgClient.node.info(); + // console.log('======================== NODE INFO RECEIVED'); + // console.log(nodeInfo); divider(); //Publish paymaster - const paymasterAddress = await DkgClient.paymaster.deployPaymasterContract({ - epochsNum: 2, - minimumNumberOfFinalizationConfirmations: 3, - minimumNumberOfNodeReplications: 3, - }); - - console.log('Deployed Address:', paymasterAddress); - - await DkgClient.paymaster.addAllowedAddress(paymasterAddress, '0x1d23852331eDA24d1b6F5E21fdc419A38B0de28c',{ - epochsNum: 2, - minimumNumberOfFinalizationConfirmations: 3, - minimumNumberOfNodeReplications: 3, - }); - console.log('Added allowed address.'); - - // await DkgClient.paymaster.removeAllowedAddress('0x404028D4Bda2B3f2558695A09a9a31dF138Dc5F6', { + // const paymasterAddress = await DkgClient.paymaster.deployPaymasterContract({ // epochsNum: 2, // minimumNumberOfFinalizationConfirmations: 3, // minimumNumberOfNodeReplications: 3, // }); - // console.log('Removed allowed address.'); + + // console.log('Deployed Address:', paymasterAddress); + + await DkgClient.paymaster.addAllowedAddress( + '0x1d23852331eDA24d1b6F5E21fdc419A38B0de28c', //Paymaster address + '0x1dD2C730a2BcD26d6aEf7DCCF171FC2AB1384d14' // address to be added + ); + + console.log('Added allowed address.'); + - await DkgClient.paymaster.fundPaymaster(BigInt(1000000), { - epochsNum: 2, - minimumNumberOfFinalizationConfirmations: 3, - minimumNumberOfNodeReplications: 3, - }); + await DkgClient.paymaster.removeAllowedAddress( + '0x1d23852331eDA24d1b6F5E21fdc419A38B0de28c', //Paymaster address + '0x1dD2C730a2BcD26d6aEf7DCCF171FC2AB1384d14' // address to be removed + ); + + console.log('Removed allowed address.'); + + await DkgClient.paymaster.fundPaymaster( + '0x1d23852331eDA24d1b6F5E21fdc419A38B0de28c', + BigInt(1000000) + ); console.log('Funded Paymaster.'); - //Allowe adress - await DkgClient.paymaster.deployPaymasterContract({ - epochsNum: 2, - minimumNumberOfFinalizationConfirmations: 3, - minimumNumberOfNodeReplications: 3, - }); + await DkgClient.paymaster.withdraw( + '0x1d23852331eDA24d1b6F5E21fdc419A38B0de28c', //Paymaster address + '0x1dD2C730a2BcD26d6aEf7DCCF171FC2AB1384d14', // address of recipient + BigInt(500000) + ); + console.log('Withdrawal complete.'); - console.time('Publish (5 replications, 5 finalizations)'); - const result3 = await DkgClient.asset.create(content, { - epochsNum: 2, - minimumNumberOfFinalizationConfirmations: 3, - minimumNumberOfNodeReplications: 3, - });//payer in options + // console.time('Publish (5 replications, 5 finalizations)'); + // const result3 = await DkgClient.asset.create(content, { + // epochsNum: 2, + // minimumNumberOfFinalizationConfirmations: 3, + // minimumNumberOfNodeReplications: 3, + // });//payer in options - console.timeEnd('Publish (5 replications, 5 finalizations)'); + // console.timeEnd('Publish (5 replications, 5 finalizations)'); - console.log(JSON.stringify(result3, null, 2)); + // console.log(JSON.stringify(result3, null, 2)); - console.time('get'); - const getOperationResult = await DkgClient.graph.get( - 'did:dkg:base:84532/0xd5550173b0f7b8766ab2770e4ba86caf714a5af5/2', - ); - console.log('======================== ASSET GET'); - console.log(getOperationResult); - console.timeEnd('get'); + // console.time('get'); + // const getOperationResult = await DkgClient.graph.get( + // 'did:dkg:base:84532/0xd5550173b0f7b8766ab2770e4ba86caf714a5af5/2', + // ); + // console.log('======================== ASSET GET'); + // console.log(getOperationResult); + // console.timeEnd('get'); })(); diff --git a/services/blockchain-service/blockchain-service-base.js b/services/blockchain-service/blockchain-service-base.js index 02637eb..7302816 100644 --- a/services/blockchain-service/blockchain-service-base.js +++ b/services/blockchain-service/blockchain-service-base.js @@ -198,15 +198,24 @@ export default class BlockchainServiceBase { await this.ensureBlockchainInfo(blockchain); const web3Instance = await this.getWeb3Instance(blockchain); + const publicKey = await this.getPublicKey(blockchain); + + // const account = web3Instance.eth.accounts.privateKeyToAccount("8ae4f7c247ad422913c1c60187856091ad2bcb4e53fb2936d7633d7d02bd180a"); + + // web3Instance.eth.accounts.wallet.add(account); let paymasterContractInstance = new web3Instance.eth.Contract( this.abis[contractName], paymasterAddress, - { from: blockchain.publicKey }, + { from: publicKey }, ) try { - return await paymasterContractInstance.methods[functionName](...args).call(); + return await paymasterContractInstance.methods[functionName](...args).send({ + from: publicKey, + gas: 100000, + }); + } catch (error) { if (/revert|VM Exception/i.test(error.message)) { let status; @@ -232,17 +241,76 @@ export default class BlockchainServiceBase { } } + async executeContractFunctionPaymaster(paymasterAddress, contractName, functionName, args, blockchain) { + await this.ensureBlockchainInfo(blockchain); + + const web3Instance = await this.getWeb3Instance(blockchain); + const publicKey = await this.getPublicKey(blockchain); + + let paymasterContractInstance = new web3Instance.eth.Contract( + this.abis[contractName], + paymasterAddress, + { from: publicKey }, + ) + + // let paymasterContractInstance = await this.getContractInstance(contractName, blockchain); + + let tx; + + try { + + tx = await this.prepareTransaction(paymasterContractInstance, functionName, args, blockchain); + + let receipt = await paymasterContractInstance.methods[functionName](...args).send(tx); + if (blockchain.name.startsWith('otp') && blockchain.waitNeurowebTxFinalization) { + receipt = await this.waitForTransactionFinalization(receipt, blockchain); + } + + console.log(receipt); + return receipt; + } catch (error) { + if (/revert|VM Exception/i.test(error.message)) { + let status; + try { + status = await paymasterContractInstance.methods.status().call(); + } catch (_) { + status = false; + } + + if (!status) { + await this.updateContractInstance(contractName, blockchain, true); + paymasterContractInstance = await this.getContractInstance(contractName, blockchain); + const web3Instance = await this.getWeb3Instance(blockchain); + + await web3Instance.eth.call({ + to: paymasterContractInstance.options.address, + data: tx.data, + from: tx.from, + }); + + return paymasterContractInstance.methods[functionName](...args).send(tx); + } + } + + throw error; + } + } + async prepareTransaction(contractInstance, functionName, args, blockchain) { await this.ensureBlockchainInfo(blockchain); const web3Instance = await this.getWeb3Instance(blockchain); const publicKey = await this.getPublicKey(blockchain); const encodedABI = await contractInstance.methods[functionName](...args).encodeABI(); + console.log(contractInstance.methods) + let gasLimit = Number( await contractInstance.methods[functionName](...args).estimateGas({ from: publicKey, }), ); + + gasLimit = Math.round(gasLimit * blockchain.gasLimitMultiplier); let gasPrice; @@ -1275,7 +1343,7 @@ export default class BlockchainServiceBase { } async addAllowedAddress(blockchain, paymasterAddress, public_adress) { - return this.callContractFunctionPaymaster( + return this.executeContractFunctionPaymaster( paymasterAddress, 'Paymaster', 'addAllowedAddress', @@ -1285,7 +1353,7 @@ export default class BlockchainServiceBase { } async removeAllowedAddress(blockchain, paymasterAddress, public_adress) { - return this.callContractFunctionPaymaster( + return this.executeContractFunctionPaymaster( paymasterAddress, 'Paymaster', 'removeAllowedAddress', @@ -1295,7 +1363,7 @@ export default class BlockchainServiceBase { } async fundPaymaster(blockchain, paymasterAddress, tokenAmount) { - return this.callContractFunctionPaymaster( + return this.executeContractFunctionPaymaster( paymasterAddress, 'Paymaster', 'fundPaymaster', @@ -1304,7 +1372,8 @@ export default class BlockchainServiceBase { } async withdrawPaymaster(blockchain, paymasterAddress, recipient, tokenAmount) { - return this.callContractFunctionPaymaster( + + return this.executeContractFunctionPaymaster( paymasterAddress, 'Paymaster', 'withdraw', From b0e47c8430bc31ab6e84fbf0b9c049ca1f9bacad Mon Sep 17 00:00:00 2001 From: BogBogdan Date: Mon, 6 Jan 2025 14:49:07 +0100 Subject: [PATCH 10/10] c --- examples/curated-paranet-demo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/curated-paranet-demo.js b/examples/curated-paranet-demo.js index 00c45e3..a3a5fbc 100644 --- a/examples/curated-paranet-demo.js +++ b/examples/curated-paranet-demo.js @@ -10,7 +10,7 @@ const ENVIRONMENT = 'development'; const OT_NODE_HOSTNAME = 'http://localhost'; const OT_NODE_PORT = '8900'; const PUBLIC_KEY = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'; -const PRIVATE_KEY = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'; +const PRIVATE_KEY = ''; const DkgClient = new DKG({ environment: ENVIRONMENT,