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:
parent
4f05e3f455
commit
8c4813b908
@ -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)
|
||||
|
@ -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]
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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]
|
||||
|
@ -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())
|
||||
})()
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
16
src/examples/config.ts
Normal 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
|
10
src/examples/config/config.json
Normal file
10
src/examples/config/config.json
Normal 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"
|
||||
}
|
Loading…
Reference in New Issue
Block a user