11/* eslint-disable */
2- // trails-api v1-25.11.11+5874e69 33a6141c3a06d537a04fb28c7629368b534dfeba
2+ // trails-api v1-25.11.11+c8ddd1e ebd89d95e8dd3b22ad108ccc213058b6ac9813cb
33// --
4- // Code generated by Webrpc-gen@v0.31.1 with typescript generator. DO NOT EDIT.
4+ // Code generated by Webrpc-gen@v0.31.1 with typescript@v0.23.0 generator. DO NOT EDIT.
55//
6- // webrpc-gen -schema=trails-api.ridl -target=typescript -client -out=./clients/trails-api.gen.ts
6+ // webrpc-gen -schema=trails-api.ridl -target=typescript@v0.23.0 -client -out=./clients/trails-api.gen.ts
77
88// Webrpc description and code-gen version
99export const WebrpcVersion = 'v1'
1010
1111// Schema version of your RIDL schema
12- export const WebrpcSchemaVersion = 'v1-25.11.11+5874e69 '
12+ export const WebrpcSchemaVersion = 'v1-25.11.11+c8ddd1e '
1313
1414// Schema hash generated from your RIDL schema
15- export const WebrpcSchemaHash = '33a6141c3a06d537a04fb28c7629368b534dfeba '
15+ export const WebrpcSchemaHash = 'ebd89d95e8dd3b22ad108ccc213058b6ac9813cb '
1616
1717//
1818// Client interface
@@ -852,40 +852,6 @@ const BIG_INT_FIELDS: { [typ: string]: (string | [string, string])[] } = {
852852 WaitIntentReceiptResponse : [ [ 'intentReceipt' , 'IntentReceipt' ] ]
853853}
854854
855- // Encode in-place: mutate provided object graph to serialize bigints to strings.
856- function encodeType ( typ : string , obj : any ) : any {
857- if ( obj == null || typeof obj !== 'object' ) return obj
858- const descs = BIG_INT_FIELDS [ typ ] || [ ]
859- if ( ! descs . length ) return obj
860- for ( const d of descs ) {
861- if ( Array . isArray ( d ) ) {
862- const [ fieldName , nestedType ] = d
863- if ( fieldName . endsWith ( '[]' ) ) {
864- const base = fieldName . slice ( 0 , - 2 )
865- const arr = obj [ base ]
866- if ( Array . isArray ( arr ) ) {
867- for ( let i = 0 ; i < arr . length ; i ++ ) arr [ i ] = encodeType ( nestedType , arr [ i ] )
868- }
869- } else if ( obj [ fieldName ] ) {
870- obj [ fieldName ] = encodeType ( nestedType , obj [ fieldName ] )
871- }
872- continue
873- }
874- if ( d . endsWith ( '[]' ) ) {
875- const base = d . slice ( 0 , - 2 )
876- const arr = obj [ base ]
877- if ( Array . isArray ( arr ) ) {
878- for ( let i = 0 ; i < arr . length ; i ++ ) {
879- if ( typeof arr [ i ] === 'bigint' ) arr [ i ] = arr [ i ] . toString ( )
880- }
881- }
882- continue
883- }
884- if ( typeof obj [ d ] === 'bigint' ) obj [ d ] = obj [ d ] . toString ( )
885- }
886- return obj
887- }
888-
889855// Decode in-place: mutate object graph; throw if expected numeric string is invalid.
890856function decodeType ( typ : string , obj : any ) : any {
891857 if ( obj == null || typeof obj !== 'object' ) return obj
@@ -901,7 +867,16 @@ function decodeType(typ: string, obj: any): any {
901867 for ( let i = 0 ; i < arr . length ; i ++ ) arr [ i ] = decodeType ( nestedType , arr [ i ] )
902868 }
903869 } else if ( obj [ fieldName ] ) {
904- obj [ fieldName ] = decodeType ( nestedType , obj [ fieldName ] )
870+ // Handle nestedType that might be an array type like 'Message[]'
871+ if ( nestedType . endsWith ( '[]' ) ) {
872+ const baseType = nestedType . slice ( 0 , - 2 )
873+ const arr = obj [ fieldName ]
874+ if ( Array . isArray ( arr ) ) {
875+ for ( let i = 0 ; i < arr . length ; i ++ ) arr [ i ] = decodeType ( baseType , arr [ i ] )
876+ }
877+ } else {
878+ obj [ fieldName ] = decodeType ( nestedType , obj [ fieldName ] )
879+ }
905880 }
906881 continue
907882 }
@@ -934,9 +909,9 @@ function decodeType(typ: string, obj: any): any {
934909 return obj
935910}
936911
937- // Encode object of given root type to JSON with BigInts converted to decimal strings.
938- export const JsonEncode = < T = any > ( obj : T , typ : string = '' ) : string => {
939- return JSON . stringify ( encodeType ( typ , obj ) )
912+ // Encode object to JSON with BigInts converted to decimal strings.
913+ export const JsonEncode = < T = any > ( obj : T ) : string => {
914+ return JSON . stringify ( obj , ( key , value ) => ( typeof value === 'bigint' ? value . toString ( ) : value ) )
940915}
941916
942917// Decode data (JSON string or already-parsed object) and convert declared BigInt string fields back to BigInt.
@@ -1581,7 +1556,7 @@ export const webrpcErrorByCode: { [code: number]: any } = {
15811556
15821557export const WebrpcHeader = 'Webrpc'
15831558
1584- export const WebrpcHeaderValue = 'webrpc@v0.31.1;gen-typescript@v0.22.5 ;trails-api@v1-25.11.11+5874e69 '
1559+ export const WebrpcHeaderValue = 'webrpc@v0.31.1;gen-typescript@v0.23.0 ;trails-api@v1-25.11.11+c8ddd1e '
15851560
15861561type WebrpcGenVersions = {
15871562 WebrpcGenVersion : string
0 commit comments