-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #921 from singnet/staging
Updated versions of packages, added handling big numbers
- Loading branch information
Showing
449 changed files
with
1,427 additions
and
74,996 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
REACT_APP_SANDBOX_SERVICE_ENDPOINT=http://localhost:8088 | ||
REACT_APP_SANDBOX_SERVICE_ENDPOINT=daemon_enpoint | ||
REACT_APP_SANDBOX_ORG_ID=org_id | ||
REACT_APP_SANDBOX_SERVICE_ID=service_id | ||
REACT_APP_WEB3_PROVIDER=wss://ropsten.infura.io/ws/v3/{infura_project_id} | ||
REACT_APP_SANDBOX=true |
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 |
---|---|---|
@@ -1,67 +1,94 @@ | ||
# snet-dapp | ||
|
||
This Dapp allows you to browse the list of services from the SingularityNET Registry and call them. | ||
The beta dapp is under active development and will see several changes in the upcoming weeks | ||
This Dapp allows you to browse the list of AI services from the SingularityNET Registry and call them. | ||
|
||
## How to call a Service | ||
|
||
1. Navigate to the SingularityNET beta [dapp](http://beta.singularitynet.io/) | ||
1. Navigate to the SingularityNET [beta dapp](http://beta.singularitynet.io/) | ||
2. Sign up / Login to the DApp account | ||
3. Every service has a free trial, so you can invoke the service without any payment | ||
3. Some artificial intelligence services have a free trial version, so you can use it without any payment | ||
4. If free trial has expired, you need to use your AGIX tokens to make the call using Metamask (this is on the mainnet) | ||
5. Authorize and Transfer tokens to the Multi party escrow in the Accounts page | ||
6. Follow the service execution steps on the service details page | ||
7. The result from the operation is displayed in the result tab | ||
|
||
## Development instructions | ||
|
||
* Install [Node.js and npm](https://nodejs.org/) | ||
* `npm install` to get dependencies | ||
* `npm run start` to serve the application locally and watch source files for modifications | ||
|
||
Install [Node.js and npm](https://nodejs.org/) and [yarn](https://classic.yarnpkg.com/lang/en/docs/install) | ||
|
||
- node version >=18 | ||
- yarn version >=1.22.21 | ||
|
||
For getting dependencies: | ||
``` | ||
yarn install | ||
``` | ||
To serve the application locally and watch source files for modifications: | ||
``` | ||
yarn start | ||
``` | ||
or | ||
``` | ||
npm run start | ||
``` | ||
## UI for Services | ||
|
||
Currently the UI needed by a service to capture inputs and render the output must be provided by the service developer as a PR. It must be provided in the form of a React component. | ||
This approach will change in the future as we support a generic mechanism to declaratively describe a service's API. See [this](https://github.com/singnet/custom-ui-research) for more details | ||
Currently the UI needed by a service to capture inputs and render the output must be provided by the service developer through [Publisher](https://publisher.singularitynet.io/). To create a Snet-dapp style user interface, a developer can use the [next repository](https://github.com/singnet/snet-dapp-components). | ||
|
||
## Sandbox mode for Services | ||
|
||
git clone [email protected]:singnet/snet-dapp.git | ||
cd snet-dapp | ||
npm install | ||
cp .env.sandbox .env | ||
This approach will change in the future. Work on it is in progress | ||
|
||
## Sandbox mode for Services | ||
|
||
Cloning this repo: | ||
``` | ||
git clone [email protected]:singnet/snet-dapp.git | ||
``` | ||
Go to project folder: | ||
``` | ||
cd snet-dapp | ||
``` | ||
Get dependencies: | ||
``` | ||
yarn install | ||
``` | ||
Create the env file: | ||
``` | ||
cp .env.sandbox .env | ||
``` | ||
1. Update `.env` file to reflect the actual values for each environment variable. | ||
|
||
1. `REACT_APP_SANDBOX_SERVICE_ENDPOINT` | ||
|
||
The endpoint of the service running locally. `snetd` defaults to `http://localhost:8088`. | ||
The daemon endpoint for call AI methods of your service. | ||
|
||
2. `REACT_APP_SANDBOX_ORG_ID` & `REACT_APP_SANDBOX_SERVICE_ID` | ||
|
||
The `org_id` to which the service belongs and the `service_id` of the service. The values set for these variables will be used for registering the custom ui. | ||
|
||
3. `REACT_APP_WEB3_PROVIDER` | ||
|
||
The infura endpoint to be used for the Web3 connection. | ||
|
||
2. Start the AI service locally along with the snet daemon. Make sure the blockchain is disabled in the daemon configuration. | ||
2. Start the AI service locally along with the snet daemon. Make sure the blockchain is disabled in the daemon configuration. | ||
3. Building the custom ui | ||
1. Generate `js` stubs from `.proto` files | ||
|
||
For the custom ui to talk to the services on SingularityNET platform via the DApp, we are using [gRPC-web](https://github.com/improbable-eng/grpc-web) by improbable-eng. Apart from the steps mentioned at the official [documentation](https://github.com/improbable-eng/grpc-web/blob/master/client/grpc-web/docs/code-generation.md) to generate `js stubs` from `.proto` definitions, you also need to provide the `namespace_prefix` flag to the generator. Here is an example which illustrates the usage | ||
|
||
``` | ||
For Linux | ||
``` | ||
protoc \ | ||
--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \ | ||
--js_out=import_style=commonjs,binary,namespace_prefix=<uniq_name_space>:. \ | ||
--ts_out=service=true:. \ | ||
example_service.proto | ||
``` | ||
<uniq_name_space> should be a combination of `package_name` + `org_id` + `service_id`. | ||
For the following [proto file](https://github.com/singnet/example-service/blob/master/service/service_spec/example_service.proto) with `org_id=snet` and `service_id=example-service` the namespace_prefix would be `example_service_snet_example_service`. <br /> | ||
PS: All the `-` should be replaced by `_`. | ||
--js_out=import_style=commonjs,binary,namespace_prefix=\ | ||
[package name]_[org id]_[service]:. --ts_out=service=grpc-web:. \ | ||
[proto file name].proto | ||
``` | ||
For Windows CMD | ||
``` | ||
protoc ^ | ||
--plugin=protoc-gen-ts=%cd%/node_modules/.bin/protoc-gen-ts.cmd ^ --js_out=import_style=commonjs,binary,namespace_prefix=^ | ||
[package name]_[org id]_[service]:. --ts_out=service=grpc-web:. ^ | ||
[proto file name].proto | ||
``` | ||
2. You need build the custom UI following the steps | ||
Create a new directory named after the `org-id` to which this service belongs inside `src/assets/thirdPartyServices`. It could be possible that the directory already exists, in which case you can use it instead of creating a new one. | ||
|
@@ -84,7 +111,12 @@ For the following [proto file](https://github.com/singnet/example-service/blob/m | |
thirdPartyCustomUIComponents.addCustomUIComponent(orgId, serviceId, CustomUIComponent); | ||
5. Assuming that the snet daemon is running on port `8088`, running the bellow commands should bring up the DApp in sandbox mode for local development. | ||
npm run sandbox | ||
5. Assuming that the snet daemon is running on the port that you specified in the REACT_APP_SANDBOX_SERVICE_ENDPOINT, running the bellow commands should bring up the DApp in sandbox mode for local development. | ||
``` | ||
yarn start | ||
``` | ||
or | ||
``` | ||
npm run start | ||
``` |
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,27 @@ | ||
const webpack = require("webpack"); | ||
|
||
module.exports = function override(config) { | ||
const fallback = config.resolve.fallback || {}; | ||
Object.assign(fallback, { | ||
os: require.resolve("os-browserify"), | ||
url: require.resolve("url"), | ||
path: require.resolve("path-browserify"), | ||
}); | ||
config.resolve.fallback = fallback; | ||
config.plugins = (config.plugins || []).concat([ | ||
new webpack.ProvidePlugin({ | ||
process: "process/browser", | ||
Buffer: ["buffer", "Buffer"], | ||
}), | ||
]); | ||
config.ignoreWarnings = [/Failed to parse source map/]; | ||
config.module.rules.push({ | ||
test: /\.(js|mjs|jsx)$/, | ||
enforce: "pre", | ||
loader: require.resolve("source-map-loader"), | ||
resolve: { | ||
fullySpecified: false, | ||
}, | ||
}); | ||
return config; | ||
}; |
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
Oops, something went wrong.