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