-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from WalletConnect/fix/webgl-solidity-data-types
fix: interaction with some smart contract functions is broken in WebGL
- Loading branch information
Showing
9 changed files
with
103 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ mergeInto(LibraryManager.library, { | |
// Call the method using the provided function | ||
let result = await callFn(_web3ModalConfig, methodName, parameterObj); | ||
|
||
if (!result) { | ||
if (result === undefined || result === null) { | ||
{{{makeDynCall('viii', 'callbackPtr')}}} (id, undefined, undefined); | ||
return; | ||
} | ||
|
@@ -69,7 +69,7 @@ mergeInto(LibraryManager.library, { | |
const enableOnramp = parameters.enableOnramp; | ||
|
||
// Load the scripts and initialize the configuration | ||
import("https://cdn.jsdelivr.net/npm/@web3modal/[email protected].1/dist/wagmi.js").then(CDNW3M => { | ||
import("https://cdn.jsdelivr.net/npm/@web3modal/[email protected].11/dist/wagmi.js").then(CDNW3M => { | ||
const WagmiCore = CDNW3M['WagmiCore']; | ||
const Chains = CDNW3M['Chains']; | ||
const Web3modal = CDNW3M['Web3modal']; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
Packages/com.walletconnect.web3modal/Runtime/Utils/ByteArrayJsonConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using WalletConnectSharp.Common.Utils; | ||
|
||
namespace WalletConnect.Web3Modal.Utils | ||
{ | ||
/// <summary> | ||
/// Converts byte array to hex string and vice versa. | ||
/// </summary> | ||
/// <remarks> | ||
/// The default behavior of Newtonsoft.Json is to convert byte arrays to base64 strings. | ||
/// </remarks> | ||
public class ByteArrayJsonConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return objectType == typeof(byte[]); | ||
} | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
if (reader.TokenType == JsonToken.Null) | ||
return null; | ||
|
||
if (reader.TokenType == JsonToken.String) | ||
{ | ||
var hexString = (string)reader.Value; | ||
return hexString.HexToByteArray(); | ||
} | ||
|
||
throw new JsonSerializationException("Expected byte array object value"); | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
if (value == null) | ||
{ | ||
writer.WriteNull(); | ||
return; | ||
} | ||
|
||
var byteArray = (byte[])value; | ||
var hexString = byteArray.ToHex(true); | ||
|
||
writer.WriteValue(hexString); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Packages/com.walletconnect.web3modal/Runtime/Utils/ByteArrayJsonConverter.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters