File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
kleros-sdk/src/dataMappings/utils Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change
1
+ export const lambdas = {
2
+ // Converts a value to hex representation
3
+ hex : function ( ) {
4
+ return function ( text : string , render : Function ) {
5
+ const originalValueStr = render ( text ) ;
6
+ const num = parseInt ( originalValueStr , 10 ) ;
7
+ if ( ! isNaN ( num ) ) {
8
+ return "0x" + num . toString ( 16 ) . toLowerCase ( ) ;
9
+ }
10
+ return originalValueStr ;
11
+ } ;
12
+ } ,
13
+ } ;
Original file line number Diff line number Diff line change 1
1
import mustache from "mustache" ;
2
2
import { DisputeDetails } from "./disputeDetailsTypes" ;
3
3
import DisputeDetailsSchema , { RefuseToArbitrateAnswer } from "./disputeDetailsSchema" ;
4
+ import { lambdas } from "./lambdas" ;
4
5
5
6
export const populateTemplate = ( mustacheTemplate : string , data : any ) : DisputeDetails => {
6
- const render = mustache . render ( mustacheTemplate , data ) ;
7
+ const render = mustache . render ( mustacheTemplate , { ... data , ... lambdas } ) ;
7
8
const dispute = JSON . parse ( render ) ;
8
9
9
10
const validation = DisputeDetailsSchema . safeParse ( dispute ) ;
You can’t perform that action at this time.
0 commit comments