From 460ac496fe29cd25247c1cee71e1bc3c7de75aef Mon Sep 17 00:00:00 2001 From: Bill Barman Date: Thu, 22 Nov 2018 16:39:05 +0800 Subject: [PATCH 1/2] move DID to utils/DIDTools --- src/{DID.ts => utils/DIDTools.ts} | 0 test/{DID.test.ts => utils/DIDTools.test.ts} | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/{DID.ts => utils/DIDTools.ts} (100%) rename test/{DID.test.ts => utils/DIDTools.test.ts} (97%) diff --git a/src/DID.ts b/src/utils/DIDTools.ts similarity index 100% rename from src/DID.ts rename to src/utils/DIDTools.ts diff --git a/test/DID.test.ts b/test/utils/DIDTools.test.ts similarity index 97% rename from test/DID.test.ts rename to test/utils/DIDTools.test.ts index db2a703..c021a03 100644 --- a/test/DID.test.ts +++ b/test/utils/DIDTools.test.ts @@ -1,9 +1,9 @@ import * as assert from "assert" -import * as didTools from "../src/DID" +import * as didTools from "../../src/utils/DIDTools" import * as Web3 from "web3" -describe("DID Tests", () => { +describe("DIDTools Tests", () => { describe("did generate", () => { From d79ad1e7b172135b80a9a4eee6c2a45306622bf7 Mon Sep 17 00:00:00 2001 From: Bill Barman Date: Thu, 22 Nov 2018 16:40:19 +0800 Subject: [PATCH 2/2] rename DIDTo .. didTo --- src/utils/DIDTools.ts | 4 ++-- test/utils/DIDTools.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/DIDTools.ts b/src/utils/DIDTools.ts index 2883ce4..d14638a 100644 --- a/src/utils/DIDTools.ts +++ b/src/utils/DIDTools.ts @@ -121,7 +121,7 @@ export function idToDID(id: string, method?: string): string { * :return a hex string, without the leading '0x' * :return null if the DID is invalid */ -export function DIDToId(did: string): string { +export function didToId(did: string): string { const result = didParse(did) if (result && result.idHex ) { return result.idHex @@ -129,7 +129,7 @@ export function DIDToId(did: string): string { return null } -export function DIDToIdBytes(did: string): Uint8Array { +export function didToIdBytes(did: string): Uint8Array { const result = didParse(did) if (result && result.idHex) { return Web3.utils.hexToBytes("0x" + result.idHex) diff --git a/test/utils/DIDTools.test.ts b/test/utils/DIDTools.test.ts index c021a03..3347928 100644 --- a/test/utils/DIDTools.test.ts +++ b/test/utils/DIDTools.test.ts @@ -68,7 +68,7 @@ describe("DIDTools Tests", () => { const testId = Web3.utils.randomHex(32).substring(2) const testMethod = "op" 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 () => { @@ -76,7 +76,7 @@ describe("DIDTools Tests", () => { const byteId = Web3.utils.hexToBytes("0x" + testId) const testMethod = "op" const validDID = "did:" + testMethod + ":" + testId - const bufferTest = Buffer.from(didTools.DIDToIdBytes(validDID)) + const bufferTest = Buffer.from(didTools.didToIdBytes(validDID)) const bufferValid = Buffer.from(byteId) assert(Buffer.compare(bufferTest, bufferValid) === 0 ) })