init
This commit is contained in:
8
Assets/Editor/ChainSafe_RPC_Tests.meta
Normal file
8
Assets/Editor/ChainSafe_RPC_Tests.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2aa3465ef77bf3848becdc93ded51925
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "ChainSafe_RPC_Tests",
|
||||
"optionalUnityReferences": [
|
||||
"TestAssemblies"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5ccc76e67b401d4bbdc39cf233e2bf0
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Editor/ERC20_Tests.meta
Normal file
8
Assets/Editor/ERC20_Tests.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0300392acc6226e419fc924ce80fa782
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/Editor/ERC20_Tests/ERC20_Test.cs
Normal file
33
Assets/Editor/ERC20_Tests/ERC20_Test.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using NUnit.Framework;
|
||||
|
||||
public class ERC20_Test
|
||||
{
|
||||
public const string ERC_20 = "[ { \"inputs\": [ { \"internalType\": \"string\", \"name\": \"name_\", \"type\": \"string\" }, { \"internalType\": \"string\", \"name\": \"symbol_\", \"type\": \"string\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"constructor\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"owner\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"spender\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"Approval\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"Transfer\", \"type\": \"event\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"owner\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"spender\", \"type\": \"address\" } ], \"name\": \"allowance\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"spender\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"approve\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"balanceOf\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"decimals\", \"outputs\": [ { \"internalType\": \"uint8\", \"name\": \"\", \"type\": \"uint8\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"spender\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"subtractedValue\", \"type\": \"uint256\" } ], \"name\": \"decreaseAllowance\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"spender\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"addedValue\", \"type\": \"uint256\" } ], \"name\": \"increaseAllowance\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"name\", \"outputs\": [ { \"internalType\": \"string\", \"name\": \"\", \"type\": \"string\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"symbol\", \"outputs\": [ { \"internalType\": \"string\", \"name\": \"\", \"type\": \"string\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"totalSupply\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"recipient\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"transfer\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"sender\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"recipient\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"transferFrom\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" } ]";
|
||||
|
||||
// Start is called before the first frame update
|
||||
[Test]
|
||||
public void GetERC20_Balance_ABI_Test()
|
||||
{
|
||||
Assert.That(ERC_20, Is.AssignableTo<string>());
|
||||
}
|
||||
}
|
||||
/*
|
||||
[Test]
|
||||
public async void GetERC20_Balance_ABI()
|
||||
{
|
||||
// Arrange
|
||||
string _contract = "0x3E0C0447e47d49195fbE329265E330643eB42e6f";
|
||||
string _account = "0xd25b827D92b0fd656A1c829933e9b0b836d5C3e2";
|
||||
// ACT
|
||||
var provider = RPC.GetInstance.Provider();
|
||||
var contractData = new Contract(ERC_20, _contract, provider);
|
||||
string method = "balanceOf";
|
||||
var contractResponse = await contractData.Call(method, new object[]
|
||||
{
|
||||
_account
|
||||
});
|
||||
Debug.Log("Contract Response: " + contractResponse[0]);
|
||||
// Assert
|
||||
Assert.That(contractResponse[0], Is.AssignableTo<BigInteger>());
|
||||
}
|
||||
*/
|
||||
11
Assets/Editor/ERC20_Tests/ERC20_Test.cs.meta
Normal file
11
Assets/Editor/ERC20_Tests/ERC20_Test.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32fe5d672980b2546a7834ac0d0e34fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Editor/ServerSettings.meta
Normal file
8
Assets/Editor/ServerSettings.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08bd4833905f95047909687869268274
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
123
Assets/Editor/ServerSettings/ChainsafeServerSettings.cs
Normal file
123
Assets/Editor/ServerSettings/ChainsafeServerSettings.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using SDKConfiguration;
|
||||
using System;
|
||||
|
||||
public class ChainSafeServerSettings : EditorWindow
|
||||
{
|
||||
public string ProjectID = "Please Enter Your Project ID";
|
||||
public string ChainID = "Please Enter Your Chain ID";
|
||||
public string Chain = "Please Enter Your Chain i.e Ethereum, Binance, Cronos";
|
||||
public string Network = "Please Enter Your Network i.e Mainnet, Testnet";
|
||||
public string RPC = "Please Enter Your RPC";
|
||||
public User saveObject;
|
||||
Texture2D m_Logo = null;
|
||||
GameObject serverCheck = null;
|
||||
ProjectConfigScriptableObject projectConfigSO = null;
|
||||
|
||||
// checks if data is already entered
|
||||
void Awake()
|
||||
{
|
||||
if ((ProjectID == ("Please Enter Your Project ID")) && (PlayerPrefs.GetString("ProjectID") != ""))
|
||||
{
|
||||
ProjectID = PlayerPrefs.GetString("ProjectID");
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
if ((ChainID == ("Please Enter Your Chain ID")) && (PlayerPrefs.GetString("ChainID") != ""))
|
||||
{
|
||||
ChainID = PlayerPrefs.GetString("ChainID");
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
if (Chain == ("Please Enter Your Chain i.e Ethereum, Binance, Cronos") && (PlayerPrefs.GetString("Chain") != ""))
|
||||
{
|
||||
Chain = PlayerPrefs.GetString("Chain");
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
if (Network == ("Please Enter Your Network i.e Mainnet, Testnet") && (PlayerPrefs.GetString("Network") != ""))
|
||||
{
|
||||
Network = PlayerPrefs.GetString("Network");
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
if (RPC == ("Please Enter Your RPC") && (PlayerPrefs.GetString("RPC") != ""))
|
||||
{
|
||||
RPC = PlayerPrefs.GetString("RPC");
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
|
||||
// Initializes window
|
||||
[MenuItem("Window/ChainSafeServerSettings")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
// show existing window instance. If one doesn't exist, make one.
|
||||
EditorWindow.GetWindow(typeof(ChainSafeServerSettings));
|
||||
}
|
||||
|
||||
// called when menu is opened, loads Chainsafe Logo
|
||||
void OnEnable()
|
||||
{
|
||||
m_Logo = (Texture2D)Resources.Load("chainsafemenulogo", typeof(Texture2D));
|
||||
}
|
||||
|
||||
// displayed content
|
||||
void OnGUI()
|
||||
{
|
||||
// image
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
GUILayout.Label(m_Logo, GUILayout.MaxWidth(250f), GUILayout.MaxHeight(250f));
|
||||
EditorGUILayout.EndVertical();
|
||||
// text
|
||||
GUILayout.Label("Welcome To The ChainSafe SDK!", EditorStyles.boldLabel);
|
||||
GUILayout.Label("Here you can enter all the information needed to get your game started on the blockchain!", EditorStyles.label);
|
||||
// inputs
|
||||
ProjectID = EditorGUILayout.TextField("Project ID", ProjectID);
|
||||
ChainID = EditorGUILayout.TextField("Chain ID", ChainID);
|
||||
Chain = EditorGUILayout.TextField("Chain", Chain);
|
||||
Network = EditorGUILayout.TextField("Network", Network);
|
||||
RPC = EditorGUILayout.TextField("RPC", RPC);
|
||||
// buttons
|
||||
|
||||
// register
|
||||
if (GUILayout.Button("Need To Register?"))
|
||||
{
|
||||
Application.OpenURL("https://dashboard.gaming.chainsafe.io/");
|
||||
}
|
||||
// docs
|
||||
if (GUILayout.Button("Check Out Our Docs!"))
|
||||
{
|
||||
Application.OpenURL("https://docs.gaming.chainsafe.io/");
|
||||
}
|
||||
// save button
|
||||
if (GUILayout.Button("Save Settings"))
|
||||
{
|
||||
Debug.Log("Saving Settings!");
|
||||
// set player prefs for unity open close within the editor
|
||||
PlayerPrefs.SetString("ProjectID", ProjectID);
|
||||
PlayerPrefs.SetString("ChainID", ChainID);
|
||||
PlayerPrefs.SetString("Chain", Chain);
|
||||
PlayerPrefs.SetString("Network", Network);
|
||||
PlayerPrefs.SetString("RPC", RPC);
|
||||
PlayerPrefs.SetString("Registered", "true");
|
||||
// set the scriptable object for when the project is built out
|
||||
projectConfigSO = (ProjectConfigScriptableObject)Resources.Load("ProjectConfigData", typeof(ScriptableObject));
|
||||
projectConfigSO.ProjectID = ProjectID;
|
||||
projectConfigSO.ChainID = ChainID;
|
||||
projectConfigSO.Chain = Chain;
|
||||
projectConfigSO.Network = Network;
|
||||
projectConfigSO.RPC = RPC;
|
||||
EditorUtility.SetDirty(projectConfigSO);
|
||||
AssetDatabase.SaveAssets();
|
||||
// assign script to prefab and instantiate then destroy after
|
||||
serverCheck = (GameObject)Resources.Load("dll", typeof(GameObject));
|
||||
GameObject serverCheckScript = (GameObject)Instantiate(serverCheck, new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0));
|
||||
serverCheckScript.GetComponent<ServerCheck>().CheckProject();
|
||||
Debug.Log("Server Check Script: " + serverCheck);
|
||||
}
|
||||
GUILayout.Label("Reminder: Your ProjectID Must Be Valid To Save & Build With Our SDK. You Can Register For One On Our Website At Dashboard.Gaming.Chainsafe.io", EditorStyles.label);
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/ServerSettings/ChainsafeServerSettings.cs.meta
Normal file
11
Assets/Editor/ServerSettings/ChainsafeServerSettings.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 137e7c488f5f7df438703b4ad74e92b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user