-
Notifications
You must be signed in to change notification settings - Fork 42
Sandbox mode
git clone git@github.com:singnet/refactored-dapp.git
cd refactored-dapp
npm install
cp .env.sandbox .env
-
Update
.envfile to reflect the actual values for each environment variable.-
REACT_APP_SANDBOX_SERVICE_ENDPOINTThe endpoint of the service running locally.
snetddefaults tohttp://localhost:8088. -
REACT_APP_SANDBOX_ORG_ID&REACT_APP_SANDBOX_SERVICE_IDThe
org_idto which the service belongs and theservice_idof the service. The values set for these variables will be used for registering the custom ui.
-
-
Start the AI service locally along with the snet daemon. Make sure the blockchain is disabled in the daemon configuration.
-
Building the custom ui
-
Generate
jsstubs from.protofilesFor the custom ui to talk to the services on SingularityNET platform via the DApp, we are using gRPC-web by improbable-eng. Apart from the steps mentioned at the official documentation to generate
js stubsfrom.protodefinitions, you also need to provide thenamespace_prefixflag to the generator. Here is an example which illustrates the usageprotoc \ --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 withorg_id=snetandservice_id=example-servicethe namespace_prefix would beexample_service_snet_example_service.
PS: All the-should be replaced by_. -
You need build the custom UI following the steps
Create a new directory named after the
org-idto which this service belongs insidesrc/assets/thirdPartyServices. It could be possible that the directory already exists, in which case you can use it instead of creating a new one.Create a new directory named after the
service-idunder the newly created directory in the above stepe.g. for a service with org-id: snet and service-id: example-service you will have to do the following assuming you are at the root of the
refactored-dappcd src/assets/thirdPartyServices mkdir snet cd snet mkdir example_service cd example_servicePut the all the resources used by the custom ui under this directory including the
js stubs.
-
-
Register the custom ui
Add an entry for the new service in
src/assets/thirdPartyServices/index.jsif it does not already exist. Add the following line towards the end of the file. Make sure to replaceorgId,serviceIdandCustomUIComponentaccordingly.thirdPartyCustomUIComponents.addCustomUIComponent(orgId, serviceId, CustomUIComponent); -
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