Skip to content

Commit b34dd1e

Browse files
Merge pull request #135 from torusresearch/feat/server-offset
feat: default server time offset
2 parents de06da0 + 1ae438d commit b34dd1e

14 files changed

+406
-47
lines changed

package-lock.json

+140
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"@types/json-stable-stringify": "^1.0.36",
4646
"@types/jsonwebtoken": "^9.0.5",
4747
"@types/mocha": "^10.0.6",
48+
"@types/sinon": "^17.0.3",
4849
"chai": "^4.3.10",
4950
"cross-env": "^7.0.3",
5051
"dotenv": "^16.3.1",
@@ -56,6 +57,7 @@
5657
"mocha": "^10.2.0",
5758
"prettier": "^3.1.0",
5859
"rimraf": "^5.0.5",
60+
"sinon": "^17.0.1",
5961
"ts-node": "^10.9.1",
6062
"typescript": "^5.3.2"
6163
},

src/helpers/common.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Ecies } from "@toruslabs/eccrypto";
22
import JsonStringify from "json-stable-stringify";
33

4-
import { EciesHex, VerifierLookupResponse } from "../interfaces";
4+
import { EciesHex, LegacyVerifierLookupResponse, VerifierLookupResponse } from "../interfaces";
55

66
// this function normalizes the result from nodes before passing the result to threshold check function
77
// For ex: some fields returns by nodes might be different from each other
@@ -25,6 +25,26 @@ export const normalizeKeysResult = (result: VerifierLookupResponse) => {
2525
return finalResult;
2626
};
2727

28+
// this function normalizes the result from nodes before passing the result to threshold check function
29+
// For ex: some fields returns by nodes might be different from each other
30+
// like key_index which may differ on sapphire_network for each queried node
31+
export const normalizeLegacyKeysResult = (result: LegacyVerifierLookupResponse) => {
32+
const finalResult: Pick<LegacyVerifierLookupResponse, "keys"> = {
33+
keys: [],
34+
};
35+
if (result && result.keys && result.keys.length > 0) {
36+
const finalKey = result.keys[0];
37+
finalResult.keys = [
38+
{
39+
pub_key_X: finalKey.pub_key_X,
40+
pub_key_Y: finalKey.pub_key_Y,
41+
address: finalKey.address,
42+
},
43+
];
44+
}
45+
return finalResult;
46+
};
47+
2848
export const kCombinations = (s: number | number[], k: number): number[][] => {
2949
let set = s;
3050
if (typeof set === "number") {

0 commit comments

Comments
 (0)