File tree Expand file tree Collapse file tree 2 files changed +53
-1
lines changed
Thirdweb.Wallets/InAppWallet/EcosystemWallet Expand file tree Collapse file tree 2 files changed +53
-1
lines changed Original file line number Diff line number Diff line change @@ -953,4 +953,54 @@ public static async Task<SocialProfiles> GetSocialProfiles(ThirdwebClient client
953953
954954 return new SocialProfiles ( deserializedResponse . Data ) ;
955955 }
956+
957+ /// <summary>
958+ /// Preprocesses the typed data JSON to stringify large numbers.
959+ /// </summary>
960+ /// <param name="json">The typed data JSON.</param>
961+ /// <returns>The preprocessed typed data JSON.</returns>
962+ public static string PreprocessTypedDataJson ( string json )
963+ {
964+ var jObject = JObject . Parse ( json ) ;
965+
966+ static void StringifyLargeNumbers ( JToken token )
967+ {
968+ if ( token is JObject obj )
969+ {
970+ foreach ( var property in obj . Properties ( ) )
971+ {
972+ StringifyLargeNumbers ( property . Value ) ;
973+ }
974+ }
975+ else if ( token is JArray array )
976+ {
977+ foreach ( var item in array )
978+ {
979+ StringifyLargeNumbers ( item ) ;
980+ }
981+ }
982+ else if ( token is JValue value )
983+ {
984+ if ( value . Type == JTokenType . Integer )
985+ {
986+ try
987+ {
988+ var bigInt = BigInteger . Parse ( value . ToString ( ) ) ;
989+ if ( bigInt > new BigInteger ( uint . MaxValue ) || bigInt < BigInteger . Zero )
990+ {
991+ value . Replace ( bigInt . ToString ( ) ) ;
992+ }
993+ }
994+ catch ( FormatException )
995+ {
996+ // Skip if the value isn't properly formatted as an integer
997+ }
998+ }
999+ }
1000+ }
1001+
1002+ StringifyLargeNumbers ( jObject ) ;
1003+
1004+ return jObject . ToString ( ) ;
1005+ }
9561006}
Original file line number Diff line number Diff line change @@ -776,9 +776,11 @@ public async Task<string> SignTypedDataV4(string json)
776776 throw new ArgumentNullException ( nameof ( json ) , "Json to sign cannot be null." ) ;
777777 }
778778
779+ var processedJson = Utils . PreprocessTypedDataJson ( json ) ;
780+
779781 var url = $ "{ ENCLAVE_PATH } /sign-typed-data";
780782
781- var requestContent = new StringContent ( json , Encoding . UTF8 , "application/json" ) ;
783+ var requestContent = new StringContent ( processedJson , Encoding . UTF8 , "application/json" ) ;
782784
783785 var response = await this . HttpClient . PostAsync ( url , requestContent ) . ConfigureAwait ( false ) ;
784786 _ = response . EnsureSuccessStatusCode ( ) ;
You can’t perform that action at this time.
0 commit comments