mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
use dtAddress as did
This commit is contained in:
parent
e06f96af0f
commit
6b2c7ea4ce
@ -20,10 +20,8 @@ before_script:
|
|||||||
- git clone https://github.com/oceanprotocol/barge
|
- git clone https://github.com/oceanprotocol/barge
|
||||||
- cd barge
|
- cd barge
|
||||||
- git checkout v3
|
- git checkout v3
|
||||||
- export PROVIDER_VERSION=latest
|
|
||||||
- export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
|
- export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
|
||||||
- export AQUARIUS_URI="http://172.15.0.5:5000"
|
- export AQUARIUS_URI="http://172.15.0.5:5000"
|
||||||
- export DEPLOY_CONTRACTS=true
|
|
||||||
- bash -x start_ocean.sh --no-dashboard 2>&1 > start_ocean.log &
|
- bash -x start_ocean.sh --no-dashboard 2>&1 > start_ocean.log &
|
||||||
- cd ..
|
- cd ..
|
||||||
- ./scripts/waitforcontracts.sh
|
- ./scripts/waitforcontracts.sh
|
||||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -939,9 +939,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@oceanprotocol/contracts": {
|
"@oceanprotocol/contracts": {
|
||||||
"version": "0.4.2",
|
"version": "0.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-0.4.2.tgz",
|
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-0.4.3.tgz",
|
||||||
"integrity": "sha512-IKRUe60pcBcEmQhkpusSc+w2CIEHxmyNzth+VRU5Je6lrP6/XnDaFRHjeYbSy306I/WxLjma88S1xOn86BMCOA=="
|
"integrity": "sha512-nn083eB7oW8Dvn+3R2WOjfuX7QzUvq2+yWTQrUAH5XcwGlcVP5CAXTvlkq7iJYbaAsPVDtefv2fd5aatJL6skw=="
|
||||||
},
|
},
|
||||||
"@octokit/auth-token": {
|
"@octokit/auth-token": {
|
||||||
"version": "2.4.2",
|
"version": "2.4.2",
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ethereum-navigator/navigator": "^0.5.0",
|
"@ethereum-navigator/navigator": "^0.5.0",
|
||||||
"@oceanprotocol/contracts": "^0.4.2",
|
"@oceanprotocol/contracts": "^0.4.3",
|
||||||
"decimal.js": "^10.2.0",
|
"decimal.js": "^10.2.0",
|
||||||
"fs": "0.0.1-security",
|
"fs": "0.0.1-security",
|
||||||
"lzma": "^2.3.2",
|
"lzma": "^2.3.2",
|
||||||
|
@ -356,7 +356,6 @@ export class DataTokens {
|
|||||||
/** Start Order
|
/** Start Order
|
||||||
* @param {String} dataTokenAddress
|
* @param {String} dataTokenAddress
|
||||||
* @param {String} amount
|
* @param {String} amount
|
||||||
* @param {String} did
|
|
||||||
* @param {Number} serviceId
|
* @param {Number} serviceId
|
||||||
* @param {String} mpFeeAddress
|
* @param {String} mpFeeAddress
|
||||||
* @param {String} address consumer Address
|
* @param {String} address consumer Address
|
||||||
@ -365,7 +364,6 @@ export class DataTokens {
|
|||||||
public async startOrder(
|
public async startOrder(
|
||||||
dataTokenAddress: string,
|
dataTokenAddress: string,
|
||||||
amount: string,
|
amount: string,
|
||||||
did: string,
|
|
||||||
serviceId: number,
|
serviceId: number,
|
||||||
mpFeeAddress: string,
|
mpFeeAddress: string,
|
||||||
address: string
|
address: string
|
||||||
@ -376,7 +374,7 @@ export class DataTokens {
|
|||||||
if (!mpFeeAddress) mpFeeAddress = '0x0000000000000000000000000000000000000000'
|
if (!mpFeeAddress) mpFeeAddress = '0x0000000000000000000000000000000000000000'
|
||||||
try {
|
try {
|
||||||
const trxReceipt = await datatoken.methods
|
const trxReceipt = await datatoken.methods
|
||||||
.startOrder(this.web3.utils.toWei(amount), did, String(serviceId), mpFeeAddress)
|
.startOrder(this.web3.utils.toWei(amount), String(serviceId), mpFeeAddress)
|
||||||
.send({ from: address, gas: 600000 })
|
.send({ from: address, gas: 600000 })
|
||||||
return trxReceipt
|
return trxReceipt
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -397,7 +395,6 @@ export class DataTokens {
|
|||||||
public async getPreviousValidOrders(
|
public async getPreviousValidOrders(
|
||||||
dataTokenAddress: string,
|
dataTokenAddress: string,
|
||||||
amount: string,
|
amount: string,
|
||||||
did: string,
|
|
||||||
serviceId: number,
|
serviceId: number,
|
||||||
timeout: number,
|
timeout: number,
|
||||||
address: string
|
address: string
|
||||||
@ -411,7 +408,6 @@ export class DataTokens {
|
|||||||
})
|
})
|
||||||
for (let i = 0; i < events.length; i++) {
|
for (let i = 0; i < events.length; i++) {
|
||||||
if (
|
if (
|
||||||
events[i].returnValues.did === did &&
|
|
||||||
String(events[i].returnValues.amount) === String(amount) &&
|
String(events[i].returnValues.amount) === String(amount) &&
|
||||||
String(events[i].returnValues.serviceId) === String(serviceId)
|
String(events[i].returnValues.serviceId) === String(serviceId)
|
||||||
) {
|
) {
|
||||||
|
@ -3,7 +3,7 @@ import { TransactionReceipt } from 'web3-core'
|
|||||||
import { Contract } from 'web3-eth-contract'
|
import { Contract } from 'web3-eth-contract'
|
||||||
import { AbiItem } from 'web3-utils/types'
|
import { AbiItem } from 'web3-utils/types'
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import defaultDDOContractABI from '@oceanprotocol/contracts/artifacts/DDO.json'
|
import defaultDDOContractABI from '@oceanprotocol/contracts/artifacts/Metadata.json'
|
||||||
import { didZeroX } from '../utils'
|
import { didZeroX } from '../utils'
|
||||||
import { LZMA } from 'lzma'
|
import { LZMA } from 'lzma'
|
||||||
|
|
||||||
@ -102,15 +102,16 @@ export class OnChainMetadataStore {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const estGas = await this.DDOContract.methods
|
/* const estGas = await this.DDOContract.methods
|
||||||
.create(did, flags, data)
|
.create(didZeroX(did), flags, data)
|
||||||
.estimateGas(function (err, estGas) {
|
.estimateGas(function (err, estGas) {
|
||||||
if (err) console.log('OnChainMetadataStore: ' + err)
|
if (err) console.log('OnChainMetadataStoreEstimateGas: ' + err)
|
||||||
return estGas
|
return estGas
|
||||||
})
|
})
|
||||||
|
*/
|
||||||
const trxReceipt = await this.DDOContract.methods
|
const trxReceipt = await this.DDOContract.methods
|
||||||
.create(did, flags, data)
|
.create(didZeroX(did), flags, data)
|
||||||
.send({ from: consumerAccount, gas: estGas + 1 })
|
.send({ from: consumerAccount })
|
||||||
return trxReceipt
|
return trxReceipt
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
@ -138,7 +139,7 @@ export class OnChainMetadataStore {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const trxReceipt = await this.DDOContract.methods
|
const trxReceipt = await this.DDOContract.methods
|
||||||
.update(did, flags, data)
|
.update(didZeroX(did), flags, data)
|
||||||
.send({ from: consumerAccount })
|
.send({ from: consumerAccount })
|
||||||
return trxReceipt
|
return trxReceipt
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -89,13 +89,13 @@ export class Config {
|
|||||||
* DDOContractAddress
|
* DDOContractAddress
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
public DDOContractAddress?: string
|
public MetadataContractAddress?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DDOContractABI
|
* DDOContractABI
|
||||||
* @type {any}
|
* @type {any}
|
||||||
*/
|
*/
|
||||||
public DDOContractABI?: AbiItem | AbiItem[]
|
public MetadataContractABI?: AbiItem | AbiItem[]
|
||||||
/**
|
/**
|
||||||
* Log level.
|
* Log level.
|
||||||
* @type {boolean | LogLevel}
|
* @type {boolean | LogLevel}
|
||||||
|
@ -108,7 +108,7 @@ export class Assets extends Instantiable {
|
|||||||
observer.next(CreateProgressStep.DataTokenCreated)
|
observer.next(CreateProgressStep.DataTokenCreated)
|
||||||
}
|
}
|
||||||
|
|
||||||
const did: DID = DID.generate()
|
const did: DID = DID.generate(dtAddress)
|
||||||
|
|
||||||
this.logger.log('Encrypting files')
|
this.logger.log('Encrypting files')
|
||||||
observer.next(CreateProgressStep.EncryptingFiles)
|
observer.next(CreateProgressStep.EncryptingFiles)
|
||||||
@ -486,7 +486,6 @@ export class Assets extends Instantiable {
|
|||||||
const previousOrder = await datatokens.getPreviousValidOrders(
|
const previousOrder = await datatokens.getPreviousValidOrders(
|
||||||
providerData.dataToken,
|
providerData.dataToken,
|
||||||
providerData.numTokens,
|
providerData.numTokens,
|
||||||
didZeroX(did),
|
|
||||||
serviceIndex,
|
serviceIndex,
|
||||||
service.attributes.main.timeout,
|
service.attributes.main.timeout,
|
||||||
consumerAddress
|
consumerAddress
|
||||||
@ -510,7 +509,6 @@ export class Assets extends Instantiable {
|
|||||||
const txid = await datatokens.startOrder(
|
const txid = await datatokens.startOrder(
|
||||||
providerData.dataToken,
|
providerData.dataToken,
|
||||||
this.web3.utils.fromWei(String(providerData.numTokens)),
|
this.web3.utils.fromWei(String(providerData.numTokens)),
|
||||||
didZeroX(did),
|
|
||||||
serviceIndex,
|
serviceIndex,
|
||||||
mpAddress,
|
mpAddress,
|
||||||
consumerAddress
|
consumerAddress
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { generateId } from '../utils/GeneratorHelpers'
|
import { generateId } from '../utils/GeneratorHelpers'
|
||||||
|
import { noZeroX, didZeroX } from '../utils'
|
||||||
const prefix = 'did:op:'
|
const prefix = 'did:op:'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,8 +16,7 @@ export default class DID {
|
|||||||
didString = didString.getDid()
|
didString = didString.getDid()
|
||||||
}
|
}
|
||||||
let did: DID
|
let did: DID
|
||||||
const didMatch = didString.match(/^did:op:([a-f0-9]{64})$/i)
|
const didMatch = didString.match(/^did:op:([a-f0-9]{40})$/i)
|
||||||
|
|
||||||
if (didMatch) {
|
if (didMatch) {
|
||||||
did = new DID(didMatch[1])
|
did = new DID(didMatch[1])
|
||||||
}
|
}
|
||||||
@ -30,11 +29,12 @@ export default class DID {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new DID.
|
* Generate a new DID.
|
||||||
|
* @param {string} dataTokenAddress Address of data token to use for DID.
|
||||||
* @return {DID}
|
* @return {DID}
|
||||||
*/
|
*/
|
||||||
public static generate(): DID {
|
public static generate(dataTokenAddress: string): DID {
|
||||||
return new DID(generateId())
|
return new DID(noZeroX(dataTokenAddress))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,8 +67,8 @@ export class Ocean extends Instantiable {
|
|||||||
)
|
)
|
||||||
instance.OnChainMetadataStore = new OnChainMetadataStore(
|
instance.OnChainMetadataStore = new OnChainMetadataStore(
|
||||||
instanceConfig.config.web3Provider,
|
instanceConfig.config.web3Provider,
|
||||||
instanceConfig.config.DDOContractAddress,
|
instanceConfig.config.MetadataContractAddress,
|
||||||
instanceConfig.config.DDOContractABI
|
instanceConfig.config.MetadataContractABI
|
||||||
)
|
)
|
||||||
instance.versions = await Versions.getInstance(instanceConfig)
|
instance.versions = await Versions.getInstance(instanceConfig)
|
||||||
instance.network = new Network()
|
instance.network = new Network()
|
||||||
|
@ -25,7 +25,7 @@ const configs: ConfigHelperConfig[] = [
|
|||||||
providerUri: 'http://127.0.0.1:8030',
|
providerUri: 'http://127.0.0.1:8030',
|
||||||
poolFactoryAddress: null,
|
poolFactoryAddress: null,
|
||||||
fixedRateExchangeAddress: null,
|
fixedRateExchangeAddress: null,
|
||||||
DDOContractAddress: null
|
MetadataContractAddress: null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
chainId: 4,
|
chainId: 4,
|
||||||
@ -37,7 +37,7 @@ const configs: ConfigHelperConfig[] = [
|
|||||||
providerUri: 'https://provider.rinkeby.v3.dev-ocean.com',
|
providerUri: 'https://provider.rinkeby.v3.dev-ocean.com',
|
||||||
poolFactoryAddress: '0x9B90A1358fbeEC1C4bB1DA7D4E85C708f87556Ec',
|
poolFactoryAddress: '0x9B90A1358fbeEC1C4bB1DA7D4E85C708f87556Ec',
|
||||||
fixedRateExchangeAddress: '0x991c08bD00761A299d3126a81a985329096896D4',
|
fixedRateExchangeAddress: '0x991c08bD00761A299d3126a81a985329096896D4',
|
||||||
DDOContractAddress: '0xEfA25E39192b3175d451D79C1c0a41Fa3C32c87d'
|
MetadataContractAddress: '0xEfA25E39192b3175d451D79C1c0a41Fa3C32c87d'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
chainId: 1,
|
chainId: 1,
|
||||||
@ -49,7 +49,7 @@ const configs: ConfigHelperConfig[] = [
|
|||||||
providerUri: null,
|
providerUri: null,
|
||||||
poolFactoryAddress: null,
|
poolFactoryAddress: null,
|
||||||
fixedRateExchangeAddress: null,
|
fixedRateExchangeAddress: null,
|
||||||
DDOContractAddress: null
|
MetadataContractAddress: null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ export class ConfigHelper {
|
|||||||
if (data.ganache.BFactory) configs[0].poolFactoryAddress = data.ganache.BFactory
|
if (data.ganache.BFactory) configs[0].poolFactoryAddress = data.ganache.BFactory
|
||||||
if (data.ganache.FixedRateExchange)
|
if (data.ganache.FixedRateExchange)
|
||||||
configs[0].fixedRateExchangeAddress = data.ganache.FixedRateExchange
|
configs[0].fixedRateExchangeAddress = data.ganache.FixedRateExchange
|
||||||
if (data.ganache.DDO) configs[0].DDOContractAddress = data.ganache.DDO
|
if (data.ganache.Metadata) configs[0].MetadataContractAddress = data.ganache.Metadata
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (process.env.AQUARIUS_URI) configs[0].metadataStoreUri = process.env.AQUARIUS_URI
|
if (process.env.AQUARIUS_URI) configs[0].metadataStoreUri = process.env.AQUARIUS_URI
|
||||||
|
@ -14,7 +14,7 @@ export const noDidPrefixed = (input: string): string => didTransformer(input, fa
|
|||||||
export function didTransformer(input = '', prefixOutput: boolean): string {
|
export function didTransformer(input = '', prefixOutput: boolean): string {
|
||||||
const { valid, output } = inputMatch(
|
const { valid, output } = inputMatch(
|
||||||
input,
|
input,
|
||||||
/^(?:0x|did:op:)*([a-f0-9]{64})$/i,
|
/^(?:0x|did:op:)*([a-f0-9]{40})$/i,
|
||||||
'didTransformer'
|
'didTransformer'
|
||||||
)
|
)
|
||||||
return (prefixOutput && valid ? 'did:op:' : '') + output
|
return (prefixOutput && valid ? 'did:op:' : '') + output
|
||||||
|
Loading…
x
Reference in New Issue
Block a user