1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

added hdwallet support to examples

This commit is contained in:
Sebastian Gerske 2018-12-10 10:11:36 +01:00
parent 4f05e3f455
commit 8c4813b908
15 changed files with 46 additions and 33 deletions

View File

@ -3,7 +3,7 @@ import MetaData from "../ddo/MetaData"
import MetaDataBase from "../ddo/MetaDataBase"
import Service from "../ddo/Service"
import {Account, Logger, Ocean, ServiceAgreement} from "../squid"
import * as config from "./config.json"
import config from "./config"
(async () => {
const ocean: Ocean = await Ocean.getInstance(config)

View File

@ -3,9 +3,10 @@ import MetaData from "../ddo/MetaData"
import MetaDataBase from "../ddo/MetaDataBase"
import Service from "../ddo/Service"
import {Account, Logger, Ocean, ServiceAgreement} from "../squid"
import * as config from "./config.json"
import config from "./config"
(async () => {
const ocean: Ocean = await Ocean.getInstance(config)
const publisher: Account = (await ocean.getAccounts())[0]

View File

@ -1,7 +1,8 @@
import {Logger, Ocean} from "../squid"
import * as config from "./config.json"
import config from "./config"
(async () => {
const ocean: Ocean = await Ocean.getInstance(config)
const accounts = await ocean.getAccounts()

View File

@ -1,5 +1,5 @@
import {Logger, Ocean} from "../squid"
import * as config from "./config.json"
import config from "./config"
(async () => {
const ocean: Ocean = await Ocean.getInstance(config)

View File

@ -1,16 +1,7 @@
import * as HDWalletProvider from "truffle-hdwallet-provider"
import {Logger, Ocean} from "../squid"
import * as config from "./config.json"
import config from "./config"
(async () => {
const seedphrase = "genuine oyster tonight funny fat chimney initial answer potato myself doll enable"
// @ts-ignore
config.web3Provider = new HDWalletProvider(
seedphrase,
config.nodeUri,
0, 100,
)
const ocean: Ocean = await Ocean.getInstance(config)
const accounts = await ocean.getAccounts()

View File

@ -3,7 +3,7 @@ import MetaData from "../ddo/MetaData"
import MetaDataBase from "../ddo/MetaDataBase"
import Service from "../ddo/Service"
import {Account, Logger, Ocean, ServiceAgreement} from "../squid"
import * as config from "./config.json"
import config from "./config"
(async () => {
const ocean: Ocean = await Ocean.getInstance(config)

View File

@ -3,7 +3,7 @@ import MetaData from "../ddo/MetaData"
import MetaDataBase from "../ddo/MetaDataBase"
import Service from "../ddo/Service"
import {Account, Logger, Ocean} from "../squid"
import * as config from "./config.json"
import config from "./config"
(async () => {
const ocean: Ocean = await Ocean.getInstance(config)
@ -45,6 +45,8 @@ import * as config from "./config.json"
const accessService = ddo.findServiceByType("Access")
await consumer.requestTokens(100)
const serviceAgreementSignatureResult: any = await ocean
.signServiceAgreement(
ddo.id,

View File

@ -1,7 +1,7 @@
import {Logger, Ocean} from "../squid"
// tslint:disable-next-line
import EventListener from "../keeper/EventListener"
import * as config from "./config.json"
import config from "./config"
(async () => {
Ocean.getInstance(config)

View File

@ -2,9 +2,10 @@ import DDO from "../ddo/DDO"
import MetaData from "../ddo/MetaData"
import MetaDataBase from "../ddo/MetaDataBase"
import {Account, Logger, Ocean} from "../squid"
import * as config from "./config.json"
import config from "./config"
(async () => {
const ocean: Ocean = await Ocean.getInstance(config)
const publisher: Account = (await ocean.getAccounts())[0]

View File

@ -1,14 +1,15 @@
import {Account, Logger, Ocean, ServiceAgreementTemplate, Templates} from "../squid"
import * as config from "./config.json"
import config from "./config"
(async () => {
const ocean: Ocean = await Ocean.getInstance(config)
const templateOwner: Account = (await ocean.getAccounts())[5]
const templateOwner: Account = (await ocean.getAccounts())[0]
const serviceAgreementTemplate: ServiceAgreementTemplate = new ServiceAgreementTemplate(new Templates.Access())
const serviceAgreementRegistered: boolean = await serviceAgreementTemplate.register(templateOwner.getId())
Logger.log("ServiceAgreement registered:", serviceAgreementRegistered,
Logger.log("ServiceAgreementTemplate registered:", serviceAgreementRegistered,
"templateId:", serviceAgreementTemplate.getId())
})()

View File

@ -1,6 +1,6 @@
import DDO from "../ddo/DDO"
import {Logger, Ocean} from "../squid"
import * as config from "./config.json"
import config from "./config"
(async () => {
const ocean: Ocean = await Ocean.getInstance(config)

View File

@ -5,7 +5,7 @@ import MetaData from "../ddo/MetaData"
import MetaDataBase from "../ddo/MetaDataBase"
import Service from "../ddo/Service"
import {Account, Logger, Ocean} from "../squid"
import * as config from "./config.json"
import config from "./config"
(async () => {
const ocean: Ocean = await Ocean.getInstance(config)

View File

@ -1,10 +0,0 @@
{
"nodeUri": "http://localhost:8545",
"aquariusUri": "http://172.15.0.15:5000",
"brizoUri": "http://172.15.0.17:8030",
"parityUri": "http://localhost:8545",
"secretStoreUri": "http://localhost:12001",
"threshold": 0,
"password": "node0",
"address": "0x00bd138abd70e2f00903268f3db08f2d25677c9e"
}

16
src/examples/config.ts Normal file
View File

@ -0,0 +1,16 @@
import * as HDWalletProvider from "truffle-hdwallet-provider"
import Config from "../models/Config"
import * as config from "./config/config.json"
if (false) {
const seedphrase = "xxx"
// @ts-ignore
config.web3Provider = new HDWalletProvider(
seedphrase,
config.nodeUri,
0, 10,
)
}
export default config as Config

View File

@ -0,0 +1,10 @@
{
"nodeUri": "http://localhost:8545",
"aquariusUri": "http://aquarius.dev-ocean.com:5000",
"brizoUri": "http://localhost:8030",
"parityUri": "http://localhost:9545",
"secretStoreUri": "http://localhost:12001",
"threshold": 0,
"password": "secret",
"address": "0xa99d43d86a0758d5632313b8fa3972b6088a21bb"
}