mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
rename DIDTo .. didTo
This commit is contained in:
parent
460ac496fe
commit
d79ad1e7b1
@ -121,7 +121,7 @@ export function idToDID(id: string, method?: string): string {
|
|||||||
* :return a hex string, without the leading '0x'
|
* :return a hex string, without the leading '0x'
|
||||||
* :return null if the DID is invalid
|
* :return null if the DID is invalid
|
||||||
*/
|
*/
|
||||||
export function DIDToId(did: string): string {
|
export function didToId(did: string): string {
|
||||||
const result = didParse(did)
|
const result = didParse(did)
|
||||||
if (result && result.idHex ) {
|
if (result && result.idHex ) {
|
||||||
return result.idHex
|
return result.idHex
|
||||||
@ -129,7 +129,7 @@ export function DIDToId(did: string): string {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DIDToIdBytes(did: string): Uint8Array {
|
export function didToIdBytes(did: string): Uint8Array {
|
||||||
const result = didParse(did)
|
const result = didParse(did)
|
||||||
if (result && result.idHex) {
|
if (result && result.idHex) {
|
||||||
return Web3.utils.hexToBytes("0x" + result.idHex)
|
return Web3.utils.hexToBytes("0x" + result.idHex)
|
||||||
|
@ -68,7 +68,7 @@ describe("DIDTools Tests", () => {
|
|||||||
const testId = Web3.utils.randomHex(32).substring(2)
|
const testId = Web3.utils.randomHex(32).substring(2)
|
||||||
const testMethod = "op"
|
const testMethod = "op"
|
||||||
const validDID = "did:" + testMethod + ":" + testId
|
const validDID = "did:" + testMethod + ":" + testId
|
||||||
assert(didTools.DIDToId(validDID) === testId)
|
assert(didTools.didToId(validDID) === testId)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should convert an Ocean DID to an array of bytes", async () => {
|
it("should convert an Ocean DID to an array of bytes", async () => {
|
||||||
@ -76,7 +76,7 @@ describe("DIDTools Tests", () => {
|
|||||||
const byteId = Web3.utils.hexToBytes("0x" + testId)
|
const byteId = Web3.utils.hexToBytes("0x" + testId)
|
||||||
const testMethod = "op"
|
const testMethod = "op"
|
||||||
const validDID = "did:" + testMethod + ":" + testId
|
const validDID = "did:" + testMethod + ":" + testId
|
||||||
const bufferTest = Buffer.from(didTools.DIDToIdBytes(validDID))
|
const bufferTest = Buffer.from(didTools.didToIdBytes(validDID))
|
||||||
const bufferValid = Buffer.from(byteId)
|
const bufferValid = Buffer.from(byteId)
|
||||||
assert(Buffer.compare(bufferTest, bufferValid) === 0 )
|
assert(Buffer.compare(bufferTest, bufferValid) === 0 )
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user