ethers/lib/utils#hashMessage TypeScript Examples

The following examples show how to use ethers/lib/utils#hashMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: fileSystemUtility.ts    From remix-project with MIT License 6 votes vote down vote up
migrate = async (fsFrom: fileSystem, fsTo: fileSystem) => {
        try {
            await fsFrom.checkWorkspaces()
            await fsTo.checkWorkspaces()

            if (fsTo.hasWorkSpaces) {
                console.log(`${fsTo.name} already has files`)
                return true
            }

            if (!fsFrom.hasWorkSpaces) {
                console.log('no files to migrate')
                return true
            }

            const fromFiles = await this.copyFolderToJson('/', null, null, fsFrom.fs)
            await this.populateWorkspace(fromFiles, fsTo.fs)
            const toFiles = await this.copyFolderToJson('/', null, null, fsTo.fs)

            if (hashMessage(JSON.stringify(toFiles)) === hashMessage(JSON.stringify(fromFiles))) {
                console.log('file migration successful')
                return true
            } else {
                _paq.push(['trackEvent', 'Migrate', 'error', 'hash mismatch'])
                console.log('file migration failed falling back to ' + fsFrom.name)
                fsTo.loaded = false
                return false
            }
        } catch (err) {
            console.log(err)
            _paq.push(['trackEvent', 'Migrate', 'error', err && err.message])
            console.log('file migration failed falling back to ' + fsFrom.name)
            fsTo.loaded = false
            return false
        }
    }