Skip to content

Commit f1ea962

Browse files
authored
Upgrade MetaMask SDK to 1.3.1 (#153)
1 parent 6befc1e commit f1ea962

File tree

394 files changed

+2312
-11891
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

394 files changed

+2312
-11891
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
using System.IO;
2+
using evm.net.Generator;
3+
using evm.net.Models.ABI;
4+
using Newtonsoft.Json;
5+
using UnityEditor;
6+
using UnityEngine;
7+
8+
public class ContractGeneratorEditor : EditorWindow
9+
{
10+
private static ContractGeneratorEditor instance;
11+
12+
private Vector2 AbiScrollPos;
13+
private string AbiJson = "[\n\t{ }\n]";
14+
private string rootNamespace = "Contracts";
15+
16+
[MenuItem("Tools/MetaMask/Contract ABI Converter")]
17+
public static void Initialize()
18+
{
19+
instance = GetWindow<ContractGeneratorEditor>();
20+
instance.titleContent = new GUIContent("Contract ABI -> Code Generator");
21+
instance.minSize = new Vector2(440, 292);
22+
instance.Show();
23+
}
24+
25+
private void OnEnable()
26+
{
27+
EditorApplication.update += EditorUpdate;
28+
}
29+
30+
private void OnDisable()
31+
{
32+
EditorApplication.update -= EditorUpdate;
33+
}
34+
35+
private void EditorUpdate()
36+
{
37+
38+
}
39+
40+
private void OnGUI()
41+
{
42+
if (instance == null)
43+
{
44+
Initialize();
45+
}
46+
47+
EditorGUILayout.LabelField("Contract ABI Json", EditorStyles.boldLabel);
48+
EditorGUILayout.HelpBox("Copy and paste your Contract ABI JSON to the text box below, then click Convert. You may optionally set options to customize the generated C# code.", MessageType.Info);
49+
50+
AbiScrollPos = EditorGUILayout.BeginScrollView(AbiScrollPos);
51+
AbiJson = EditorGUILayout.TextArea(AbiJson, GUILayout.ExpandHeight(true));
52+
EditorGUILayout.EndScrollView();
53+
54+
GUILayout.Space(15f);
55+
56+
EditorGUILayout.LabelField("Contract Code Settings", EditorStyles.boldLabel);
57+
58+
rootNamespace = EditorGUILayout.TextField("Root Namespace", rootNamespace);
59+
60+
GUILayout.Space(15f);
61+
62+
63+
if (GUILayout.Button("Convert"))
64+
{
65+
string contractName;
66+
string bytecode = null;
67+
ContractABI abi;
68+
try
69+
{
70+
var contractArtifact = JsonConvert.DeserializeObject<ContractArtifact>(AbiJson);
71+
contractName = contractArtifact.ContractName;
72+
bytecode = contractArtifact.Bytecode;
73+
abi = contractArtifact.ABI;
74+
}
75+
catch (JsonSerializationException)
76+
{
77+
// Try just ContractABI
78+
abi = JsonConvert.DeserializeObject<ContractABI>(AbiJson);
79+
contractName = rootNamespace.Split(".")[0];
80+
}
81+
82+
// Choose save directory
83+
string path = EditorUtility.SaveFolderPanel("Choose folder to save scripts", "Assets", contractName);
84+
85+
ContractInterfaceGenerator generator = new ContractInterfaceGenerator(rootNamespace, contractName, bytecode, abi);
86+
var items = generator.GenerateAll();
87+
88+
foreach (var item in items.Keys)
89+
{
90+
var filepath = path + "/" + item + ".cs";
91+
var text = items[item];
92+
93+
File.WriteAllText(filepath, text);
94+
}
95+
96+
AssetDatabase.Refresh();
97+
}
98+
}
99+
100+
101+
}
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Thirdweb/Core/Plugins/MetaMask/Editor/EditorGUI/MetaMaskWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private void Installer()
185185
StoreYPosition();
186186
}
187187

188-
private Dictionary<string, Vector2> scrollPositions = new();
188+
private Dictionary<string, Vector2> scrollPositions = new Dictionary<string, Vector2>();
189189
private string MakeTextField(string label, string value)
190190
{
191191
EditorGUILayout.LabelField(label, this._smallHeaderStyle);

Assets/Thirdweb/Core/Plugins/MetaMask/Plugins/Libraries/EventEmitter.NET.meta renamed to Assets/Thirdweb/Core/Plugins/MetaMask/Installer/Documentation.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

0 commit comments

Comments
 (0)