From c905da7290bf718781836b9fbf1e3fd187d2c252 Mon Sep 17 00:00:00 2001 From: matteo-cristino Date: Thu, 18 Jan 2024 11:08:40 +0100 Subject: [PATCH] =?UTF-8?q?fix(bindings):=20=F0=9F=90=9B=20update=20js=20b?= =?UTF-8?q?inding=20to=20latest=20client=20contracts=20modification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bindings/javascript/src/index.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bindings/javascript/src/index.ts b/bindings/javascript/src/index.ts index 5e5666b..4ccabcf 100644 --- a/bindings/javascript/src/index.ts +++ b/bindings/javascript/src/index.ts @@ -68,13 +68,11 @@ const prepareZencodeKeyring = ( } const preparePks = async ( - requestKeyring: ControllerKeyring, - additionalData: string + requestKeyring: ControllerKeyring ) :Promise => { const contractPks = readFromFile('client/v1/create-identity-pubkeys.zen'); - const data = readFromFile(additionalData); const keys = prepareZencodeKeyring(requestKeyring); - let {result} = await zencode_exec(contractPks, {data, keys}); + let {result} = await zencode_exec(contractPks, {data: "{}", keys}); return result; } @@ -82,15 +80,17 @@ const prepareRequest= async ( requestDomain: string, requestType: string, data: string, + settings: string, contractPath: string ) :Promise => { + const keys = readFromFile(settings); data = JSON.parse(data); data["did_spec"] = requestDomain; data = JSON.stringify(data); let res: string = null; if (requestType == DidActions.CREATE || requestType == DidActions.UPDATE) { const contractRequest = readFromFile(contractPath); - const {result} = await zencode_exec(contractRequest, {data, keys : "{}"}); + const {result} = await zencode_exec(contractRequest, {data, keys}); res = result; } else if (requestType == DidActions.DEACTIVATE) { const id = `did:dyne:${requestDomain}:${JSON.parse(data)["eddsa_public_key"]}`; @@ -128,8 +128,8 @@ export const createRequest = async ( requestDomain: string, requestType: DidActions ) :Promise => { - const data = await preparePks(requestKeyring, "client/v1/did-settings.json"); - const result = await prepareRequest(requestDomain, requestType, data, "client/v1/pubkeys-request-unsigned.zen"); + const data = await preparePks(requestKeyring); + const result = await prepareRequest(requestDomain, requestType, data, "client/v1/did-settings.json", "client/v1/pubkeys-request-unsigned.zen"); return JSON.parse(result).request; } @@ -147,11 +147,11 @@ export const createIfacerRequest = async ( requestType: DidActions, requestIdentifier: string, ) :Promise => { - let data = await preparePks(requestKeyring, "client/v1/ifacer/did-settings.json"); + let data = await preparePks(requestKeyring); const dataDict = JSON.parse(data); dataDict.identifier = requestIdentifier; data = JSON.stringify(dataDict); - const result = await prepareRequest(requestDomain, requestType, data, "client/v1/ifacer/pubkeys-request-unsigned.zen"); + const result = await prepareRequest(requestDomain, requestType, data, "client/v1/ifacer/did-settings.json", "client/v1/ifacer/pubkeys-request-unsigned.zen"); return JSON.parse(result).request; } @@ -191,4 +191,4 @@ export const sendRequest = async ( { data: request, keys: "{}"} ) return res.data; -} \ No newline at end of file +}