-
Notifications
You must be signed in to change notification settings - Fork 10
Integration with mosaic.js npm - 0.10.0-beta.2 #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
03e54c2
309f5ef
264d616
18aa2f7
af4bc5e
19db18a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,7 @@ const fs = require('fs'), | |
| path = require('path'); | ||
| //__NOT_FOR_WEB__END__ | ||
|
|
||
| const Mosaic = require('@openstfoundation/mosaic-tbd'); | ||
| const AbiBinProvider = Mosaic.AbiBinProvider; | ||
| const { AbiBinProvider } = require('@openstfoundation/mosaic.js'); | ||
|
|
||
| let DEFAULT_ABI_FOLDER_PATH, DEFAULT_BIN_FOLDER_PATH; | ||
| //__NOT_FOR_WEB__BEGIN__ | ||
|
|
@@ -22,18 +21,32 @@ class OpenSTAbiBinProvider extends AbiBinProvider { | |
| /** | ||
| * Constructor for OpenSTAbiBinProvider. | ||
| * | ||
| * @param abiFolderPath Folder path where abi is present. | ||
| * @param binFolderPath Folder path where bin is present. | ||
| * @param mosaicAbiFolderPath Folder path where mosaic abi is present. | ||
| * @param mosaicBinFolderPath Folder path where mosaic bin is present. | ||
| * @param {string} [abiFolderPath] Folder path where abi is present. | ||
| * @param {string} [binFolderPath] Folder path where bin is present. | ||
| */ | ||
| constructor(abiFolderPath, binFolderPath, mosaicAbiFolderPath, mosaicBinFolderPath) { | ||
| abiFolderPath = abiFolderPath || DEFAULT_ABI_FOLDER_PATH; | ||
| binFolderPath = binFolderPath || DEFAULT_BIN_FOLDER_PATH; | ||
| super(abiFolderPath, binFolderPath); | ||
| constructor(abiFolderPath, binFolderPath) { | ||
| const abiDirectoryPath = abiFolderPath || DEFAULT_ABI_FOLDER_PATH; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DEFAULT_ABI_FOLDER_PATH and DEFAULT_BIN_FOLDER_PATH are guarded (NOT_FOR_WEB__BEGIN). Should we check that if they are undefined and abiFolderPath, binFolderPath are not passed and raise error?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. However I am still not sure how can DEFAULT_ABI_FOLDER_PATH, DEFAULT_BIN_FOLDER_PATH can be undefined. Having said that once openst-contracts npm package are integrated, we will not need path dependencies .
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abhayks1 can you please expand on that? I cannot follow. |
||
| const binDirectoryPath = binFolderPath || DEFAULT_BIN_FOLDER_PATH; | ||
| super(); | ||
|
|
||
| const oThis = this; | ||
| oThis.mosaicAbiBinProvider = new AbiBinProvider(mosaicAbiFolderPath, mosaicBinFolderPath); | ||
| oThis.mosaicAbiBinProvider = new AbiBinProvider(); | ||
|
|
||
| // add all ABIs from abiDirectoryPath | ||
| fs.readdirSync(abiDirectoryPath).forEach((abiFile) => { | ||
| const fPath = path.resolve(abiDirectoryPath, abiFile); | ||
| const contractName = path.basename(abiFile, path.extname(abiFile)); | ||
| const contractAbi = JSON.parse(fs.readFileSync(fPath)); | ||
| oThis.addABI(contractName, contractAbi); | ||
| }); | ||
|
|
||
| // add all bins from binDirectoryPath | ||
| fs.readdirSync(binDirectoryPath).forEach((binFile) => { | ||
| const fPath = path.resolve(binDirectoryPath, binFile); | ||
| const contractName = path.basename(binFile, path.extname(binFile)); | ||
| const contractBin = fs.readFileSync(fPath, 'utf8'); | ||
| oThis.addBIN(contractName, contractBin); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why OpenSTAbiBinProvider is inheriting from AbiBinProvider of mosaic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OpenST is on top of mosaic. Inheriting AbiBinProvider of mosaic helps end users to retrieve abi/bin of mosaic with a single OpenST AbiBinProvider object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But should they need to? Why?