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

better resolver logic

This commit is contained in:
Bill Barman 2018-11-22 19:01:36 +08:00
parent 41613e5131
commit 757e6884c3

View File

@ -38,22 +38,25 @@ export default class DIDResolver {
let data: DIDRecord = await this.getDID(didId)
while ( data && (maxHopCount === 0 || resolved.hopCount() < maxHopCount) ) {
resolved.addData(data)
didId = null
if (data.valueType === "URL" || data.valueType === "DDO" ) {
data = null
break
} else {
if ( data.value.match(/^[0-9a-fA-Fx]+/) ) {
if ( data.value.match(/^[0-9a-fA-FxX]+/) ) {
// get the hex value of the chain
didId = Web3.utils.toHex("0x" + data.value.replace(/^0x/, "")).substring(2)
} else if ( data.value.match(/^did:op/) ) {
// if the DID value is another Ocean DID then get the id
didId = DIDTools.didToId(data.value)
} else {
// check for unusall values in the 'DID' record, http, ftp, {xxx
data = null
// somethings wrong with this value, so stop
break
}
data = await this.getDID(didId)
// only look if we have another id to find
if ( didId ) {
data = await this.getDID(didId)
}
}
}
return resolved