Skip to content

Commit

Permalink
fix(bindings): šŸ› update js binding to latest client contracts modificā€¦
Browse files Browse the repository at this point in the history
ā€¦ation
  • Loading branch information
matteo-cristino committed Jan 18, 2024
1 parent 0b50d02 commit c905da7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions bindings/javascript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,29 @@ const prepareZencodeKeyring = (
}

const preparePks = async (
requestKeyring: ControllerKeyring,
additionalData: string
requestKeyring: ControllerKeyring
) :Promise<string> => {
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;
}

const prepareRequest= async (
requestDomain: string,
requestType: string,
data: string,
settings: string,
contractPath: string
) :Promise<string> => {
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"]}`;
Expand Down Expand Up @@ -128,8 +128,8 @@ export const createRequest = async (
requestDomain: string,
requestType: DidActions
) :Promise<DidRequest> => {
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;
}

Expand All @@ -147,11 +147,11 @@ export const createIfacerRequest = async (
requestType: DidActions,
requestIdentifier: string,
) :Promise<DidRequest> => {
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;
}

Expand Down Expand Up @@ -191,4 +191,4 @@ export const sendRequest = async (
{ data: request, keys: "{}"}
)
return res.data;
}
}

0 comments on commit c905da7

Please sign in to comment.