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