diff --git a/ui/core/src/baseApp.js b/ui/core/src/baseApp.js index 4db360309..024cbaf2b 100644 --- a/ui/core/src/baseApp.js +++ b/ui/core/src/baseApp.js @@ -383,7 +383,7 @@ export default { this.handleError(err) }) }, - setConfig (d) { + async setConfig (d) { if (d.blockchainNet) { this.blockchainNet = d.blockchainNet } @@ -395,6 +395,8 @@ export default { } if (this.blockchainNet && this.blockchainProxeusFSAddress) { this.wallet = new WalletInterface(this.blockchainNet, this.blockchainProxeusFSAddress) + + await this.wallet.validateUserNetwork(() => this.$root.$emit('service-off'), () => this.$root.$emit('service-on')) } }, acknowledgeFirstLogin () { diff --git a/ui/core/src/components/document/Verification.vue b/ui/core/src/components/document/Verification.vue index 1431398b6..3afb50343 100644 --- a/ui/core/src/components/document/Verification.vue +++ b/ui/core/src/components/document/Verification.vue @@ -6,7 +6,7 @@
{{ $t('Connecting with the blockchain ...') }}
-

@@ -15,11 +15,16 @@

-
+
+
+ +
@@ -65,6 +70,9 @@ export default { created () { }, computed: { + hasPreinitError () { + return this.wallet().isIncorrectNetwork === true + } }, methods: { drop (file) { diff --git a/ui/core/src/components/document/VerificationFileEntry.vue b/ui/core/src/components/document/VerificationFileEntry.vue index 7d065cc79..2b5d8c181 100644 --- a/ui/core/src/components/document/VerificationFileEntry.vue +++ b/ui/core/src/components/document/VerificationFileEntry.vue @@ -5,16 +5,16 @@ - +

{{ $t('Verified file is valid', 'The file {filename} is valid.', {filename: file.name}) }}

+ class="text-success">{{ $t('Verified file is valid', 'The file {filename} is valid.', {filename: file?.name}) }}

{{ $t('Verified file revoked', 'The file {filename} has been revoked.', {filename: file.name}) }}

+ class="text-danger">{{ $t('Verified file revoked', 'The file {filename} has been revoked.', {filename: file?.name}) }}

{{ $t('Verified file is invalid', 'The file {filename} is invalid.', {filename: file.name}) }}

+ class="text-danger">{{ $t('Verified file is invalid', 'The file {filename} is invalid.', {filename: file?.name}) }}
@@ -26,7 +26,7 @@
-
+
{{ $t('Verified file invalid explanation', 'This file has been recognised as authentic but has since been declared invalid. It may have expired or been recalled by the issuer.') }}

{{ $t('Error while verifying file', 'File hash could not been verified due to technical problems. Please try again.') }}

+

{{ $t('Error while using public RPC', 'Please install Metamask extension to verify file.') }}


@@ -101,6 +103,24 @@
+
+
+ +
+
+
+

{{ $t('Unable to verify a document', 'Unable to verify a document') }}

+
+
+
+
+

{{ $t('Error incorrect network', 'Document can not be verified within incorrect network.') }}

+
+
+
+
+
@@ -108,22 +128,22 @@ - +
-

{{ file.name }}

+

{{ file?.name }}

{{ $t('Verified file is valid', 'The file {filename} is valid.', {filename: file.name}) }} + class="text-success">{{ $t('Verified file is valid', 'The file {filename} is valid.', {filename: file?.name}) }} {{ $t('Verified file revoked', 'The file {filename} has been revoked.', {filename: file.name}) }} + class="text-danger">{{ $t('Verified file revoked', 'The file {filename} has been revoked.', {filename: file?.name}) }} {{ $t('Verified file is invalid', 'The file {filename} is invalid.', {filename: file.name}) }} + class="text-danger">{{ $t('Verified file is invalid', 'The file {filename} is invalid.', {filename: file?.name}) }}
@@ -145,6 +165,9 @@ {{ $t('Error while verifying file', 'File could not been verified due to technical problems. Please try again.') }} + + {{ $t('Error while using public RPC', 'Please install Metamask extension to verify file.') }} + @@ -203,7 +226,7 @@ import Spinner from '../Spinner' export default { name: 'verification-file-entry', - props: ['file', 'wallet', 'singleFile'], + props: ['file', 'wallet', 'singleFile', 'hasPreinitError'], components: { Spinner }, @@ -220,23 +243,30 @@ export default { signatures: [], contract: undefined, errorValidating: false, + errorPublicRPC: false, + validationException: false, showDetails: false } }, mounted () { - this.verify() + if (!this.hasPreinitError) { + this.verify() + } }, computed: { valid () { - return this.errorValidating === false && this.loading === false && this.loading === false && this.status === true + return this.validationException === false && this.loading === false && this.loading === false && this.status === true }, invalid () { - return this.errorValidating === false && this.loading === false && this.status === false && + return this.validationException === false && this.loading === false && this.status === false && this.isFileInvalidated === true }, notFound () { - return this.errorValidating === false && this.loading === false && this.status === false && - this.isFileInvalidated !== true + return this.validationException === false && this.loading === false && this.status === false && + this.isFileInvalidated !== true && !this.hasPreinitError + }, + isIncorrectNetwork () { + return this.wallet().isIncorrectNetwork === true } }, filters: { @@ -252,6 +282,7 @@ export default { methods: { async verify () { this.loading = true + try { // use hash if it already comes with the file object if (this.file.hash) { @@ -264,48 +295,44 @@ export default { this.isFileInvalidated = false - let result - try { - result = await this.wallet().verifyHash(this.hash) - } catch (e) { - result = false - } - if (result) { - const transaction = await this.wallet().web3.eth.getTransaction(result) - this.creator = transaction.from - this.contract = transaction.to - const block = await this.wallet().web3.eth.getBlock(transaction.blockNumber) - // *1000 is conversion to seconds - this.timestamp = (new Date(block.timestamp * 1000)).toUTCString() + const result = await this.wallet().verifyHash(this.hash) - const signersArr = await this.wallet().proxeusFS.contract.methods.getFileSigners(this.hash).call() - Promise.all(signersArr.map(async signerAddr => { - const registrationTxBlock = await this.wallet().getRegistrationTxBlock(signerAddr) - return { - address: signerAddr, - txHash: registrationTxBlock.txHash, - block: block, - time: (new Date(registrationTxBlock.block.timestamp * 1000)).toUTCString() - } - })).then((sn) => { - this.signatures = sn - }) + const transaction = await this.wallet().web3.eth.getTransaction(result) + this.creator = transaction.from + this.contract = transaction.to + const block = await this.wallet().web3.eth.getBlock(transaction.blockNumber) + // *1000 is conversion to seconds + this.timestamp = (new Date(block.timestamp * 1000)).toUTCString() - this.loading = false - this.tx = result - this.status = true - // emit event to alert parent component of status - this.$emit('updateFileState', true) - } else { - this.status = false - this.tx = null - this.loading = false - } + const signersArr = await this.wallet().proxeusFS.contract.methods.getFileSigners(this.hash).call() + Promise.all(signersArr.map(async signerAddr => { + const registrationTxBlock = await this.wallet().getRegistrationTxBlock(signerAddr) + return { + address: signerAddr, + txHash: registrationTxBlock.txHash, + block: block, + time: (new Date(registrationTxBlock.block.timestamp * 1000)).toUTCString() + } + })).then((sn) => { + this.signatures = sn + }) + + this.loading = false + this.tx = result + this.status = true + // emit event to alert parent component of status + this.$emit('updateFileState', true) } catch (e) { this.status = false this.loading = false this.tx = null - this.errorValidating = true + this.validationException = true + + if (this.wallet().isPublicRPCUsing) { + this.errorPublicRPC = true + } else { + this.errorValidating = true + } } }, async hashFile (file) { diff --git a/ui/wallet/src/ProxeusEthereum/WalletInterface.js b/ui/wallet/src/ProxeusEthereum/WalletInterface.js index abdd63a85..f44348bd6 100644 --- a/ui/wallet/src/ProxeusEthereum/WalletInterface.js +++ b/ui/wallet/src/ProxeusEthereum/WalletInterface.js @@ -1,10 +1,15 @@ import serviceConfig from './config/service-config' -import { PROXEUS_FS_ABI, XES_TOKEN_ABI } from './config/ABI' +import { + PROXEUS_FS_ABI, + XES_TOKEN_ABI +} from './config/ABI' import ProxeusWallet from './ProxeusWallet' import ProxeusFS from './services/ProxeusFS' import MetamaskWallet from './MetamaskWallet' -import { keccak256 } from 'js-sha3' +import { + keccak256 +} from 'js-sha3' import MetamaskUtil from './MetamaskUtil' import Web3 from 'web3' @@ -14,11 +19,12 @@ import getTransactionReceiptMined from './helpers/getTransactionReceiptMined' class WalletInterface { // TODO improve checking that current network matches what is expected // TODO: network param only for compatibility reasons with blockchain/dapp - constructor (network = 'sepolia', proxeusFSAddress, forceProxeusWallet = false) { - this.useProxeusWallet = forceProxeusWallet || typeof window.ethereum === 'undefined' - + constructor(network = 'sepolia', proxeusFSAddress, forceProxeusWallet = false) { // make sure we are using the web3 we want and not the one provided by metamask this.web3 = new Web3(Web3.givenProvider || 'ws://localhost:8545') + this.systemNetworkId = this.getNetworkIdByName(network) + + this.useProxeusWallet = forceProxeusWallet || typeof window.ethereum === 'undefined' this.web3.eth.getTransactionReceiptMined = getTransactionReceiptMined this.serviceConfig = serviceConfig[network] @@ -31,7 +37,8 @@ class WalletInterface { // connect to the network using what was given in the constructor this.web3.setProvider( new this.web3.providers.HttpProvider( - 'https://' + network + '.infura.io/')) + this.getPublicRPC(network))) + this.isPublicRPCUsing = true } else { if (window.ethereum) { this.web3.setProvider(window.ethereum) @@ -43,8 +50,9 @@ class WalletInterface { // add the XES smart contract to the config this.xesTokenContract = new this.web3.eth.Contract( XES_TOKEN_ABI, - this.serviceConfig.XES_TOKEN_ADDRESS, - { gas: this.serviceConfig.DEFAULT_GAS_REGULAR } + this.serviceConfig.XES_TOKEN_ADDRESS, { + gas: this.serviceConfig.DEFAULT_GAS_REGULAR + } ) this.setProxeusFsContract(this.serviceConfig.PROXEUS_FS_ADDRESS) @@ -55,24 +63,51 @@ class WalletInterface { // set the default from address to use on the proxeusFS smart contract this.wallet.setupDefaultAccount().then(() => { - if (this.wallet.getCurrentAddress() !== null) { this.proxeusFSContract.options.from = this.wallet.getCurrentAddress() } + if (this.wallet.getCurrentAddress() !== null) { + this.proxeusFSContract.options.from = this.wallet.getCurrentAddress() + } }) } } - signMessage (message) { + async validateUserNetwork(blockCb, unblockCb) { + if (window.ethereum && this.systemNetworkId.toString() !== window.ethereum.networkVersion) { + try { + if (blockCb) { + blockCb() + } + + await window.ethereum.request({ + method: 'wallet_switchEthereumChain', + params: [{ + chainId: this.web3.utils.toHex(this.systemNetworkId) + }] + }) + + this.isIncorrectNetwork = false + } catch { + this.isIncorrectNetwork = true + } finally { + if (unblockCb) { + unblockCb() + } + } + } + } + + signMessage(message) { return this.wallet.signMessage(message) } - getCurrentAddress () { + getCurrentAddress() { return this.wallet.getCurrentAddress() } - hasAccount () { + hasAccount() { return this.wallet.getCurrentAddress() !== undefined } - importKeystore (keystore, password) { + importKeystore(keystore, password) { // optional function on wallet if (!this.wallet.importKeystore) { return null @@ -81,7 +116,7 @@ class WalletInterface { return this.wallet.importKeystore(keystore, password) } - exportKeystore (password) { + exportKeystore(password) { // optional function on wallet if (!this.wallet.exportKeystore) { return null @@ -90,7 +125,7 @@ class WalletInterface { return this.wallet.exportKeystore(password) } - importPrivateKey (privateKey) { + importPrivateKey(privateKey) { // optional function on wallet if (!this.wallet.importPrivateKey) { return null @@ -99,7 +134,7 @@ class WalletInterface { return this.wallet.importPrivateKey(privateKey) } - exportPrivateKey () { + exportPrivateKey() { // optional function on wallet if (!this.wallet.exportPrivateKey) { return null @@ -108,17 +143,17 @@ class WalletInterface { return this.wallet.exportPrivateKey() } - storePGPPublicKey (pgpPublicKey) { + storePGPPublicKey(pgpPublicKey) { pgpPublicKey = btoa(pgpPublicKey) // TODO: Store keys in constants localStorage.setItem('pgpPk', pgpPublicKey) } - loadPGPPublicKey () { + loadPGPPublicKey() { return atob(localStorage.getItem('pgpPk')) } - exportWalletToBlob (password = '') { + exportWalletToBlob(password = '') { if (password === '') { try { const authObj = localStorage.getItem('mnidmao') @@ -137,10 +172,13 @@ class WalletInterface { btoa(JSON.stringify({ keystore: encryptedKeystore, pgpKeys: this.web3.eth.accounts.wallet.PGPKeys - }))], { type: 'text/plain' }) + })) + ], { + type: 'text/plain' + }) } - importWalletFromBlob (blob, password) { + importWalletFromBlob(blob, password) { const reader = new FileReader() // first set the reader event listener and wrap it in a promise const promise = new Promise((resolve, reject) => { @@ -157,7 +195,9 @@ class WalletInterface { this.proxeusFSContract.options.from = this.getCurrentAddress() // save the pgp keys, encrypted keystore, and password on local storage - localStorage.setItem('mnidmao', btoa(JSON.stringify({ password }))) + localStorage.setItem('mnidmao', btoa(JSON.stringify({ + password + }))) localStorage.setItem('mnidmpgp', btoa(JSON.stringify(parsed.pgpKeys[this.getCurrentAddress()]))) localStorage.setItem('mnidmks', @@ -187,7 +227,7 @@ class WalletInterface { * * @param password - the password that protects the keystore */ - saveWallet (password) { + saveWallet(password) { let encryptedKeystore = this.exportKeystore(password) if (encryptedKeystore.length === 0) { return false @@ -216,7 +256,7 @@ class WalletInterface { * * @param password - the password that protects the keystore */ - loadWallet (password = '') { + loadWallet(password = '') { const authObj = localStorage.getItem('mnidmao') let pgp = localStorage.getItem('mnidmpgp') let encryptedKeystore = this.getKeystoreFromLocalStorage() @@ -250,11 +290,11 @@ class WalletInterface { return true } - lockAccount () { + lockAccount() { localStorage.removeItem('mnidmao') } - logout () { + logout() { localStorage.removeItem('mnidmao') localStorage.removeItem('mnidmks') localStorage.removeItem('mnidmpgp') @@ -264,11 +304,11 @@ class WalletInterface { this.web3.eth.accounts.wallet.clear() } - getKeystoreFromLocalStorage () { + getKeystoreFromLocalStorage() { return localStorage.getItem('mnidmks') } - getPasswordFromLocalStorage () { + getPasswordFromLocalStorage() { try { const authObj = localStorage.getItem('mnidmao') return JSON.parse(atob(authObj)).password @@ -284,9 +324,12 @@ class WalletInterface { * @param publicKey * @param privateKey */ - importPGPKeyPair (address, publicKey, privateKey) { + importPGPKeyPair(address, publicKey, privateKey) { if (!this.web3.eth.accounts.wallet.PGPKeys) this.web3.eth.accounts.wallet.PGPKeys = {} - this.web3.eth.accounts.wallet.PGPKeys[address] = { publicKey, privateKey } + this.web3.eth.accounts.wallet.PGPKeys[address] = { + publicKey, + privateKey + } } /* @@ -295,11 +338,11 @@ class WalletInterface { * @param address - the ethereum wallet address to which the PGP key pair relates to * @return Object with two fields: "privateKey" and "publicKey" */ - exportPGPKeyPair (address) { + exportPGPKeyPair(address) { return this.web3.eth.accounts.wallet.PGPKeys[address] } - createNewAccount () { + createNewAccount() { return this.web3.eth.accounts.wallet.create(1) } @@ -307,16 +350,18 @@ class WalletInterface { * Everything below this comment needs to be moved outside of the wallet libray */ - hashFile (arrBuffer) { + hashFile(arrBuffer) { return keccak256(arrBuffer) } - getDocumentRegistrationTx (hash, proxeusFSContract) { + getDocumentRegistrationTx(hash, proxeusFSContract) { const contract = (proxeusFSContract === undefined) ? this.proxeusFSContract : proxeusFSContract.contract // this one is based on events and not promises, so can't use async return new Promise((resolve, reject) => { contract.getPastEvents('UpdatedEvent', { - filter: { hash: hash }, + filter: { + hash: hash + }, fromBlock: 0 }, (error, result) => { if (error) { @@ -331,12 +376,13 @@ class WalletInterface { }) } - setProxeusFsContract (address) { + setProxeusFsContract(address) { // add the document registry smart contract to the config this.proxeusFSContract = new this.web3.eth.Contract( PROXEUS_FS_ABI, - address, - { gas: this.serviceConfig.DEFAULT_GAS_REGULAR } + address, { + gas: this.serviceConfig.DEFAULT_GAS_REGULAR + } ) // Attach proxeus FS Service @@ -348,13 +394,14 @@ class WalletInterface { * * @return array of past contract instances */ - getAllProxeusFsServices () { + getAllProxeusFsServices() { const proxeusFSPastContracts = [] for (const address of this.serviceConfig.PROXEUS_FS_PAST_ADDRESSES) { const proxeusFSContract = new this.web3.eth.Contract( PROXEUS_FS_ABI, - address, - { gas: this.serviceConfig.DEFAULT_GAS_REGULAR } + address, { + gas: this.serviceConfig.DEFAULT_GAS_REGULAR + } ) proxeusFSPastContracts.push(new ProxeusFS(this.web3, proxeusFSContract)) } @@ -366,8 +413,12 @@ class WalletInterface { * * @return string */ - async getClientProvidedNetwork () { + async getClientProvidedNetwork() { const netId = await this.web3.eth.getChainId() + return this.getNetworkNameById(netId) + } + + getNetworkNameById(netId) { switch (netId) { case 5: return 'goerli' @@ -382,12 +433,37 @@ class WalletInterface { } } - async XESAmountPerFile ({ providers }) { - const tokensRaw = await this.proxeusFS.XESAmountPerFile({ providers }) - return this.metamaskUtil.formatBalance(this.web3.utils.toHex(tokensRaw)) + getNetworkIdByName(name) { + switch (name) { + case 'goerli': + return 5 + case 'sepolia': + return 11155111 + case 'polygon': + return 137 + case 'polygon-mumbai': + return 80001 + default: + return 1 + } + } + + getPublicRPC(network) { + switch (network) { + case 'goerli': + return 'https://goerli.rpc.thirdweb.com/' + case 'sepolia': + return 'https://sepolia.rpc.thirdweb.com/' + case 'polygon': + return 'https://polygon.rpc.thirdweb.com/' + case 'polygon-mumbai': + return 'https://mumbai.rpc.thirdweb.com/' + default: + return 'https://ethereum.rpc.thirdweb.com/' + } } - async verifyHash (hash) { + async verifyHash(hash) { const result = await this.proxeusFS.fileVerify(hash) if (result && result[0] === true) { @@ -403,7 +479,7 @@ class WalletInterface { throw new Error('Could not verify hash.') } - async fileVerify (hash) { + async fileVerify(hash) { const result = await this.proxeusFS.fileVerify(hash) if (result && result[0] === true) { @@ -419,7 +495,7 @@ class WalletInterface { throw new Error('Could not verify hash.') } - formatBalance (decimalsToKeep, tokensRaw) { + formatBalance(decimalsToKeep, tokensRaw) { if (decimalsToKeep !== undefined) { return this.metamaskUtil.formatBalance(this.web3.utils.toHex(tokensRaw), decimalsToKeep) @@ -428,7 +504,7 @@ class WalletInterface { } } - transferETH (to, amount) { + transferETH(to, amount) { return this.web3.eth.sendTransaction({ to: to, value: amount, @@ -436,16 +512,16 @@ class WalletInterface { }) } - async getETHBalance (decimalsToKeep) { + async getETHBalance(decimalsToKeep) { return this.formatBalance(decimalsToKeep, await this.web3.eth.getBalance(this.getCurrentAddress())) } // optional callback parameter - transferXES (to, amount, callback) { + transferXES(to, amount, callback) { return this.wallet.transferXES(to, amount, callback) } - async getXESBalance (decimalsToKeep, address) { + async getXESBalance(decimalsToKeep, address) { if (address === undefined) { address = this.getCurrentAddress() } @@ -455,13 +531,18 @@ class WalletInterface { return this.formatBalance(decimalsToKeep, tokensRaw) } - approveXES (spender, value) { + approveXES(spender, value) { return this.xesTokenContract.methods.approve(spender, - this.web3.utils.toWei(value.toString())) - .send({ from: this.getCurrentAddress() }) + this.web3.utils.toWei(value.toString())) + .send({ + from: this.getCurrentAddress() + }) } - async getAllowance ({ spender, decimalsToKeep }) { + async getAllowance({ + spender, + decimalsToKeep + }) { const owner = this.getCurrentAddress() const tokensRaw = await this.xesTokenContract.methods.allowance(owner, spender).call() @@ -474,20 +555,22 @@ class WalletInterface { } } - txMined (tx) { + txMined(tx) { return this.web3.eth.getTransactionReceiptMined(tx) } - async getFileSignedEvent (signerAddress) { + async getFileSignedEvent(signerAddress) { const arrEvents = await this.proxeusFSContract.getPastEvents( 'FileSignedEvent', { - filter: { signer: signerAddress }, + filter: { + signer: signerAddress + }, fromBlock: 0 }) return arrEvents[0] || null } - async getRegistrationTxBlock (signerAddress) { + async getRegistrationTxBlock(signerAddress) { const event = await this.getFileSignedEvent(signerAddress) if (event === null) { return null @@ -499,7 +582,7 @@ class WalletInterface { } } - async getBlock (blockHash) { + async getBlock(blockHash) { return await this.web3.eth.getBlock(blockHash) } } diff --git a/ui/wallet/src/ProxeusEthereum/services/ProxeusFS.js b/ui/wallet/src/ProxeusEthereum/services/ProxeusFS.js index 67bbbaf8e..8869ad059 100644 --- a/ui/wallet/src/ProxeusEthereum/services/ProxeusFS.js +++ b/ui/wallet/src/ProxeusEthereum/services/ProxeusFS.js @@ -4,46 +4,10 @@ export default class { this.contract = proxeusFSContract } - async XESAmountPerFile ({ providers }) { - return this.contract.methods.getXESPrice().call() - } - - /** - ** Free calls - **/ - - /* - * Returns expiry information of a file - */ - fileExpiry (hash) { - } - - fileGetPerm (hash, address, write) { - return this.contract.methods.fileGetPerm(hash, address, write).call() - } - - fileHasSP (hash, spAddress) { - return this.contract.methods.fileHasSP(hash, spAddress).call() - } - - /* - * Returns file metadata - */ - fileInfo (hash) { - return this.contract.methods.fileInfo(hash).call() - } - - /* - * Returns a list of files - */ - async fileList () { - return this.contract.methods.fileList().call() - } - /* * Returns a list of signers for a specific file */ - getFileSigners (hash) { + async getFileSigners (hash) { return this.contract.methods.getFileSigners(hash).call() } @@ -54,87 +18,40 @@ export default class { return this.contract.methods.verifyFile(hash).call() } - /* - * Returns metadata about a Service Provider - */ - spInfo (hash) { - return this.contract.methods.spInfo(hash).call() - } - - /* - * Returns a list of storage providers - */ - spList () { - return this.contract.methods.spList().call() - } - - /* - * Paid calls + /** + * Sign file */ - - fileRemove (hash) { - return this.contract.methods.fileRemove(hash).send() - } - - signFile ({ hash }) { + async signFile ({ + hash + }) { return this.contract.methods.signFile(hash).send() } - fileSetPerm (hash, address) { - return this.contract.methods.fileSetPerm(hash, address).send() - } - - createFileDefinedSigners ({ hash, definedSigners, expiry, replaces, providers }) { - return this.contract.methods.createFileDefinedSigners( - hash, - definedSigners, - expiry / 1000 || 0, - this.web3.utils.fromAscii('0x0'), - providers - ).send() - } - - createFileUndefinedSigners ({ hash, data, mandatorySigners, expiry, replaces, providers, xes }) { + /** + * Create a file with undefined signers + */ + async createFileUndefinedSigners ({ + hash, + data + }) { return this.contract.methods.registerFile( hash, data ).send() } - createFileUndefinedSignersEstimateGas ( - { from, hash, data, mandatorySigners, expiry, replaces, providers }, cb, xes) { - const opt = from ? { from } : {} + /** + * Estimate gas for freate a file with undefined signers + */ + async createFileUndefinedSignersEstimateGas ({ + from, + hash + }, cb, xes) { + const opt = from ? { + from + } : {} return this.contract.methods.registerFile( hash ).estimateGas(opt, cb) } - - createFileThumbnail (hash, pParent, pPublic) { - return this.contract.methods.createFileThumbnail( - hash, - pParent, - pPublic - ).send() - } - - fileRequestSign (hash, address) { - return this.contract.methods.fileRequestSign(hash, address).send() - } - - fileRequestAccess () { - } - - getRequestSignEvents (address, fromBlock) { - return this.contract.getPastEvents('RequestSign', { - filter: { to: address }, - fromBlock: fromBlock || 0 - }) - } - - getNotifySignEvents (hash, address, fromBlock) { - return this.contract.getPastEvents('NotifySign', { - filter: { hash: hash, who: address }, - fromBlock: fromBlock || 0 - }) - } }