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 11import mustache from "mustache" ;
22import { DisputeDetails } from "./disputeDetailsTypes" ;
33import DisputeDetailsSchema , { RefuseToArbitrateAnswer } from "./disputeDetailsSchema" ;
4+ import { lambdas } from "./lambdas" ;
45
56export const populateTemplate = ( mustacheTemplate : string , data : any ) : DisputeDetails => {
6- const render = mustache . render ( mustacheTemplate , data ) ;
7+ const render = mustache . render ( mustacheTemplate , { ... data , ... lambdas } ) ;
78 const dispute = JSON . parse ( render ) ;
89
910 const validation = DisputeDetailsSchema . safeParse ( dispute ) ;
You can’t perform that action at this time.
0 commit comments