This repository has been archived by the owner on Aug 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ae3202
commit dd7e323
Showing
8 changed files
with
75 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { DDO, DID } from '@oceanprotocol/lib' | ||
|
||
export function readFileContent(file: File): Promise<string> { | ||
return new Promise((resolve, reject) => { | ||
const reader = new FileReader() | ||
reader.onerror = () => { | ||
reader.abort() | ||
reject(new DOMException('Problem parsing input file.')) | ||
} | ||
reader.onload = () => { | ||
resolve(reader.result as string) | ||
} | ||
reader.readAsText(file) | ||
}) | ||
} | ||
|
||
export function isDDO( | ||
toBeDetermined: DID | string | DDO | ||
): toBeDetermined is DDO { | ||
if ((toBeDetermined as DDO).id) { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
export function sleep(ms: number): Promise<void> { | ||
return new Promise((resolve) => { | ||
setTimeout(resolve, ms) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,4 @@ | ||
import { DDO, DID } from '@oceanprotocol/lib' | ||
|
||
export function readFileContent(file: File): Promise<string> { | ||
return new Promise((resolve, reject) => { | ||
const reader = new FileReader() | ||
reader.onerror = () => { | ||
reader.abort() | ||
reject(new DOMException('Problem parsing input file.')) | ||
} | ||
reader.onload = () => { | ||
resolve(reader.result as string) | ||
} | ||
reader.readAsText(file) | ||
}) | ||
} | ||
|
||
export function isDDO( | ||
toBeDetermined: DID | string | DDO | ||
): toBeDetermined is DDO { | ||
if ((toBeDetermined as DDO).id) { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
export const feedback: { [key in number]: string } = { | ||
99: 'Decrypting file URL...', | ||
0: '1/3 Looking for data token. Buying if none found...', | ||
1: '2/3 Transfering data token.', | ||
2: '3/3 Payment confirmed. Requesting access...' | ||
} | ||
|
||
export const publishFeedback: { [key in number]: string } = { | ||
0: '1/5 Creating datatoken ...', | ||
2: '2/5 Encrypting files ...', | ||
4: '3/5 Storing ddo ...', | ||
6: '4/5 Minting tokens ...', | ||
8: '5/5 Asset published succesfully' | ||
} | ||
|
||
export * from './dtUtils' | ||
export * from './web3' | ||
|
||
export function sleep(ms: number): Promise<void> { | ||
return new Promise((resolve) => { | ||
setTimeout(resolve, ms) | ||
}) | ||
} | ||
export * from './feedback' | ||
export * from './helpers' |