Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/helpers/nodeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ export const GetPubKeyOrKeyAssign = async (params: {
if ((keyResult && (nonceResult || extendedVerifierId || LEGACY_NETWORKS_ROUTE_MAP[network])) || errorResult) {
if (keyResult) {
lookupResults.forEach((x1) => {
if (x1 && x1.result?.node_index) {
nodeIndexes.push(x1.result.node_index);
if (x1 && x1.result) {
const nodeIndex = parseInt(x1.result.node_index);
if (nodeIndex) nodeIndexes.push(nodeIndex);
}
});
}
Expand Down Expand Up @@ -208,7 +209,7 @@ export async function retrieveOrImportShare(params: {
return Promise.resolve(resultArr);
} else if (importedShares.length === 0 && completedRequests.length >= ~~((endpoints.length * 3) / 4) + 1) {
const requiredNodeResult = completedRequests.find((resp: JRPCResponse<CommitmentRequestResult>) => {
if (resp && resp.result?.nodeindex === 1) {
if (resp && resp.result?.nodeindex === "1") {
return true;
}
return false;
Expand Down
10 changes: 5 additions & 5 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ export interface VerifierLookupResponse {
created_at?: number;
}[];
is_new_key: boolean;
node_index: number;
node_index: string;
}

export interface CommitmentRequestResult {
signature: string;
data: string;
nodepubx: string;
nodepuby: string;
nodeindex: number;
nodeindex: string;
}

export interface JRPCResponse<T> {
Expand Down Expand Up @@ -111,7 +111,7 @@ export interface LegacyKeyAssignment {
X: string;
Y: string;
};
Threshold: number;
Threshold: string;
Verifiers: Record<string, string>;
Share: string;
Metadata: {
Expand All @@ -124,8 +124,8 @@ export interface KeyAssignment {
X: string;
Y: string;
};
threshold: number;
node_index: number;
threshold: string;
node_index: string;
// this is encrypted ciphertext
share: string;
share_metadata: EciesHex;
Expand Down
19 changes: 9 additions & 10 deletions test/onekey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,24 @@ describe("torus onekey", function () {

it("should still fetch v1 public address correctly", async function () {
const verifier = "google-lrc"; // any verifier
const verifierDetails = { verifier, verifierId: TORUS_TEST_EMAIL };
const verifierDetails = { verifier, verifierId: "himanshu@tor.us" };
const { torusNodeEndpoints, torusNodePub } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const publicAddress = (await torus.getPublicAddress(torusNodeEndpoints, torusNodePub, verifierDetails)) as TorusPublicKey;
expect(publicAddress.metadata.typeOfUser).to.equal("v1");
expect(publicAddress.finalKeyData.evmAddress).to.equal("0x5b56E06009528Bffb1d6336575731ee3B63f6150");
expect(publicAddress.finalKeyData.evmAddress).to.be.equal("0x930abEDDCa6F9807EaE77A3aCc5c78f20B168Fd1");
expect(publicAddress).eql({
oAuthKeyData: {
evmAddress: "0x5b56E06009528Bffb1d6336575731ee3B63f6150",
X: "38a259ba42875243bba7254dd75eb3b448d83f03726ca1359fd0262faa8cede7",
Y: "3ad7aece972e471eed7002149e830c0f5b60be93ad91bb7313437bd0702b3d79",
evmAddress: "0xf1e76fcDD28b5AA06De01de508fF21589aB9017E",
X: "b3f2b4d8b746353fe670e0c39ac9adb58056d4d7b718d06b623612d4ec49268b",
Y: "ac9f79dff78add39cdba380dbbf517c20cf2c1e06b32842a90a84a31f6eb9a9a",
},
finalKeyData: {
evmAddress: "0x5b56E06009528Bffb1d6336575731ee3B63f6150",
X: "38a259ba42875243bba7254dd75eb3b448d83f03726ca1359fd0262faa8cede7",
Y: "3ad7aece972e471eed7002149e830c0f5b60be93ad91bb7313437bd0702b3d79",
evmAddress: "0x930abEDDCa6F9807EaE77A3aCc5c78f20B168Fd1",
X: "12f6b90d66bda29807cf9ff14b2e537c25080154fc4fafed446306e8356ff425",
Y: "e7c92e164b83e1b53e41e5d87d478bb07d7b19d105143e426e1ef08f7b37f224",
},
metadata: {
pubNonce: undefined,
nonce: new BN(0),
nonce: new BN("186a20d9b00315855ff5622a083aca6b2d34ef66ef6e0a4de670f5b2fde37e0d", "hex"),
upgraded: false,
typeOfUser: "v1",
},
Expand Down
2 changes: 1 addition & 1 deletion test/sapphire_mainnet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const HashEnabledVerifier = "torus-test-verifierid-hash";
const TORUS_EXTENDED_VERIFIER_EMAIL = "testextenderverifierid@example.com";
const TORUS_IMPORT_EMAIL = "importeduser5@tor.us";

describe("torus utils sapphire mainnet", function () {
describe.skip("torus utils sapphire mainnet", function () {
let torus: TorusUtils;
let TORUS_NODE_MANAGER: NodeManager;

Expand Down