Skip to content

Commit

Permalink
feat: Wasm changes & comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja committed Dec 19, 2023
1 parent 9fa5f76 commit cfb2605
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 28 deletions.
10 changes: 10 additions & 0 deletions public/hyperswitch/wasm/euclid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ export function getAllKeys(): any;
*/
export function getKeyType(key: string): string;
/**
* @returns {any}
*/
export function getThreeDsKeys(): any;
/**
* @returns {any}
*/
export function getSurchargeKeys(): any;
/**
* @param {string} val
* @returns {string}
*/
Expand Down Expand Up @@ -100,6 +108,8 @@ export interface InitOutput {
readonly getAllConnectors: (a: number) => void;
readonly getAllKeys: (a: number) => void;
readonly getKeyType: (a: number, b: number, c: number) => void;
readonly getThreeDsKeys: (a: number) => void;
readonly getSurchargeKeys: (a: number) => void;
readonly getVariantValues: (a: number, b: number, c: number) => void;
readonly addTwo: (a: number, b: number) => number;
readonly getDescriptionCategory: (a: number) => void;
Expand Down
38 changes: 38 additions & 0 deletions public/hyperswitch/wasm/euclid.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,44 @@ export function getKeyType(key) {
}
}

/**
* @returns {any}
*/
export function getThreeDsKeys() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.getThreeDsKeys(retptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
if (r2) {
throw takeObject(r1);
}
return takeObject(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}

/**
* @returns {any}
*/
export function getSurchargeKeys() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.getSurchargeKeys(retptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
if (r2) {
throw takeObject(r1);
}
return takeObject(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}

/**
* @param {string} val
* @returns {string}
Expand Down
Binary file modified public/hyperswitch/wasm/euclid_bg.wasm
Binary file not shown.
2 changes: 2 additions & 0 deletions public/hyperswitch/wasm/euclid_bg.wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export function runProgram(a: number, b: number, c: number): void;
export function getAllConnectors(a: number): void;
export function getAllKeys(a: number): void;
export function getKeyType(a: number, b: number, c: number): void;
export function getThreeDsKeys(a: number): void;
export function getSurchargeKeys(a: number): void;
export function getVariantValues(a: number, b: number, c: number): void;
export function addTwo(a: number, b: number): number;
export function getDescriptionCategory(a: number): void;
Expand Down
65 changes: 37 additions & 28 deletions src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -287,34 +287,43 @@ module FieldInp = {
let field = ReactFinalForm.useField(`${prefix}.lhs`).input
let op = ReactFinalForm.useField(`${prefix}.comparison`).input
let val = ReactFinalForm.useField(`${prefix}.value.value`).input

let keyDescriptionMapper = Window.getDescriptionCategory()->MapTypes.changeType
let convertedValue = LogicUtils.convertMapObjectToDict(keyDescriptionMapper)
let options = convertedValue->Js.Dict.keys->Js.Array2.reduce((acc, ele) => {
open LogicUtils
convertedValue
->Js.Dict.get(ele)
->Belt.Option.getWithDefault([]->Js.Json.array)
->Js.Json.decodeArray
->Belt.Option.getWithDefault([])
->Js.Array2.forEach(value => {
let dictValue = value->LogicUtils.getDictFromJsonObject
let extractValueFromDict = key =>
dictValue
->Js.Dict.get(key)
->Option.getWithDefault(""->Js.Json.string)
->getStringFromJson("")

let generatedSelectBoxOptionType: SelectBox.dropdownOption = {
label: extractValueFromDict("kind"),
value: extractValueFromDict("kind"),
description: extractValueFromDict("description"),
optGroup: ele,
}
acc->Js.Array2.push(generatedSelectBoxOptionType)->ignore
})
acc
}, [])
let descriptionCategory = Window.getDescriptionCategory()

let convertedValue = React.useMemo1(() => {
let keyDescriptionMapper = descriptionCategory->MapTypes.changeType
keyDescriptionMapper->LogicUtils.convertMapObjectToDict
}, [descriptionCategory])

let options = React.useMemo1(
() => convertedValue->Js.Dict.keys->Js.Array2.reduce((acc, ele) => {
open LogicUtils
convertedValue
->Js.Dict.get(ele)
->Belt.Option.getWithDefault([]->Js.Json.array)
->Js.Json.decodeArray
->Belt.Option.getWithDefault([])
->Js.Array2.forEach(
value => {
let dictValue = value->LogicUtils.getDictFromJsonObject
let extractValueFromDict = key =>
dictValue
->Js.Dict.get(key)
->Option.getWithDefault(""->Js.Json.string)
->getStringFromJson("")

let generatedSelectBoxOptionType: SelectBox.dropdownOption = {
label: extractValueFromDict("kind"),
value: extractValueFromDict("kind"),
description: extractValueFromDict("description"),
optGroup: ele,
}
acc->Js.Array2.push(generatedSelectBoxOptionType)->ignore
},
)
acc
}, []),
[convertedValue],
)

let input: ReactFinalForm.fieldRenderPropsInput = {
name: "string",
Expand Down

0 comments on commit cfb2605

Please sign in to comment.