Skip to content

Commit

Permalink
Firekeeper/stability (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper authored May 28, 2023
1 parent 150d53d commit 439b177
Show file tree
Hide file tree
Showing 34 changed files with 752 additions and 808 deletions.
4 changes: 2 additions & 2 deletions Assets/Thirdweb/Core/Prefabs/WalletProvider_MagicAuth.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 8849381089353801714}
- component: {fileID: 8849381089353801717}
- component: {fileID: 1354709178478519460}
m_Layer: 0
m_Name: WalletProvider_MagicAuth
m_TagString: Untagged
Expand All @@ -32,7 +32,7 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &8849381089353801717
--- !u!114 &1354709178478519460
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
Expand Down
94 changes: 25 additions & 69 deletions Assets/Thirdweb/Core/Prefabs/WalletProvider_Metamask.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -2989,7 +2989,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4036888909731852399}
m_RootOrder: 2
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!20 &3503421935344847224
Camera:
Expand Down Expand Up @@ -5102,6 +5102,7 @@ GameObject:
m_Component:
- component: {fileID: 3503421935870801902}
- component: {fileID: 2433011551695929986}
- component: {fileID: 4559418603046196302}
m_Layer: 0
m_Name: WalletProvider_Metamask
m_TagString: Untagged
Expand Down Expand Up @@ -5139,6 +5140,27 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
config: {fileID: 11400000, guid: 6cbb8289bcfbdba43817188b3b4f15e0, type: 2}
--- !u!114 &4559418603046196302
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3503421935870801903}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f9088d607e1d7b3478fcc73da2791fec, type: 3}
m_Name:
m_EditorClassIdentifier:
MetamaskCanvas: {fileID: 8744985464267693835}
ConnectButton: {fileID: 3503421936221029119}
welcomeScreen: {fileID: 3503421936027490483}
mainScreen: {fileID: 3503421936428190661}
DeeplinkButton: {fileID: 3503421936066145370}
HeaderText: {fileID: 3503421936426239605}
DescriptionText: {fileID: 3503421935881847325}
loadingSprite: {fileID: 21300000, guid: 717e217158e3e694eb447a4a5910fbbd, type: 3}
QRCodeImage: {fileID: 32878201333017964}
--- !u!1 &3503421935881847323
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -6522,7 +6544,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4036888909731852399}
m_RootOrder: 3
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &3503421936118848201
MonoBehaviour:
Expand Down Expand Up @@ -6737,19 +6759,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2433011551695929986}
m_TargetAssemblyTypeName: MetaMask.Unity.MetaMaskUnity, MetaMaskUnity.Runtime
m_MethodName: Connect
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 3503421936427613058}
- m_Target: {fileID: 4559418603046196302}
m_TargetAssemblyTypeName: MetaMask.Unity.Samples.VisualController, Assembly-CSharp
m_MethodName: OpenMainScreen
m_Mode: 1
Expand Down Expand Up @@ -7964,59 +7974,6 @@ MonoBehaviour:
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &3503421936427613057
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3503421936427613059}
- component: {fileID: 3503421936427613058}
m_Layer: 0
m_Name: Controller
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3503421936427613059
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3503421936427613057}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4036888909731852399}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &3503421936427613058
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3503421936427613057}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f9088d607e1d7b3478fcc73da2791fec, type: 3}
m_Name:
m_EditorClassIdentifier:
MetamaskCanvas: {fileID: 8744985464267693835}
ConnectButton: {fileID: 3503421936221029119}
welcomeScreen: {fileID: 3503421936027490483}
mainScreen: {fileID: 3503421936428190661}
DeeplinkButton: {fileID: 3503421936066145370}
HeaderText: {fileID: 3503421936426239605}
DescriptionText: {fileID: 3503421935881847325}
loadingSprite: {fileID: 21300000, guid: 717e217158e3e694eb447a4a5910fbbd, type: 3}
QRCodeImage: {fileID: 32878201333017964}
--- !u!1 &3503421936427620979
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -9547,7 +9504,6 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3503421936374056257}
- {fileID: 3503421936427613059}
- {fileID: 3503421935344847227}
- {fileID: 3503421936118848200}
m_Father: {fileID: 3503421935870801902}
Expand Down
9 changes: 5 additions & 4 deletions Assets/Thirdweb/Core/Scripts/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public class Contract : Routable
/// </summary>
public Events events;

public Contract(string chain, string address, string abi = null) : base(abi != null ? $"{address}{Routable.subSeparator}{abi}" : address)
public Contract(string chain, string address, string abi = null)
: base(abi != null ? $"{address}{Routable.subSeparator}{abi}" : address)
{
this.chain = chain;
this.address = address;
Expand All @@ -65,7 +66,7 @@ public async Task<CurrencyValue> GetBalance()
}
else
{
BigInteger balance = await ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetBalance.SendRequestAsync(address);
BigInteger balance = await ThirdwebManager.Instance.SDK.session.Web3.Eth.GetBalance.SendRequestAsync(address);
CurrencyValue cv = new CurrencyValue();
cv.value = balance.ToString();
cv.displayValue = balance.ToString().ToEth();
Expand All @@ -90,7 +91,7 @@ public async Task<T> Read<T>(string functionName, params object[] args)
if (this.abi == null)
throw new UnityException("You must pass an ABI for native platform custom calls");

var contract = ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetContract(this.abi, this.address);
var contract = ThirdwebManager.Instance.SDK.session.Web3.Eth.GetContract(this.abi, this.address);
var function = contract.GetFunction(functionName);
return await function.CallAsync<T>(args);
}
Expand Down Expand Up @@ -126,7 +127,7 @@ public async Task<TransactionResult> Write(string functionName, TransactionReque
if (this.abi == null)
throw new UnityException("You must pass an ABI for native platform custom calls");

var contract = ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetContract(this.abi, this.address);
var contract = ThirdwebManager.Instance.SDK.session.Web3.Eth.GetContract(this.abi, this.address);

var function = contract.GetFunction(functionName);

Expand Down
4 changes: 2 additions & 2 deletions Assets/Thirdweb/Core/Scripts/Deployer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public async Task<string> DeployNFTDrop(NFTContractDeployMetadata metadata)
throw new UnityException("This functionality is not yet available on your current platform.");

var deploymentMessage = new DropERC721Deployment();
var deploymentHandler = ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetContractDeploymentHandler<DropERC721Deployment>();
var deploymentHandler = ThirdwebManager.Instance.SDK.session.Web3.Eth.GetContractDeploymentHandler<DropERC721Deployment>();
var deploymentReceipt = await deploymentHandler.SendRequestAndWaitForReceiptAsync(deploymentMessage);
DropERC721Service dropERC721Service = new DropERC721Service(ThirdwebManager.Instance.SDK.nativeSession.web3, deploymentReceipt.ContractAddress);
DropERC721Service dropERC721Service = new DropERC721Service(ThirdwebManager.Instance.SDK.session.Web3, deploymentReceipt.ContractAddress);
var initializeReceipt = await dropERC721Service.InitializeRequestAndWaitForReceiptAsync(
defaultAdmin: await ThirdwebManager.Instance.SDK.wallet.GetAddress(),
name: metadata.name,
Expand Down
4 changes: 3 additions & 1 deletion Assets/Thirdweb/Core/Scripts/ERC20.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,10 @@ public async Task<ERC20SignedPayload> Generate(ERC20MintPayload payloadToSign, s
Uid = payloadToSign.uid.HexStringToByteArray()
};

var name = await TransactionManager.ThirdwebRead<TokenERC20Contract.NameFunction, TokenERC20Contract.NameOutputDTO>(contractAddress, new TokenERC20Contract.NameFunction() { });

string signature = await Thirdweb.EIP712.GenerateSignature_TokenERC20(
"TokenERC20",
name.ReturnValue1,
"1",
await ThirdwebManager.Instance.SDK.wallet.GetChainId(),
contractAddress,
Expand Down
2 changes: 1 addition & 1 deletion Assets/Thirdweb/Core/Scripts/Marketplace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ public async Task<TransactionResult> MakeOffer(MakeOfferInput input)
AssetContract = input.assetContractAddress,
TokenId = BigInteger.Parse(input.tokenId),
Quantity = BigInteger.Parse(input.quantity ?? "1"),
Currency = input.currencyContractAddress ?? Utils.GetNativeTokenWrapper(ThirdwebManager.Instance.SDK.nativeSession.lastChainId),
Currency = input.currencyContractAddress ?? Utils.GetNativeTokenWrapper(ThirdwebManager.Instance.SDK.session.ChainId),
TotalPrice = BigInteger.Parse(input.totalPrice.ToWei()),
ExpirationTimestamp = (BigInteger)(input.endTimestamp ?? Utils.GetUnixTimeStampIn10Years())
}
Expand Down
10 changes: 5 additions & 5 deletions Assets/Thirdweb/Core/Scripts/Multicall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static async Task<List<TokenData721>> GetOwnedTokenData721(string contrac

public static async Task<List<TokenData721>> GetAllOwners721(string contractAddress, int startTokenId, int endTokenId)
{
MultiQueryHandler multiqueryHandler = ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetMultiQueryHandler();
MultiQueryHandler multiqueryHandler = ThirdwebManager.Instance.SDK.session.Web3.Eth.GetMultiQueryHandler();
var calls = new List<MulticallInputOutput<TokenERC721.OwnerOfFunction, TokenERC721.OwnerOfOutputDTO>>();
for (int i = startTokenId; i <= endTokenId; i++)
{
Expand All @@ -61,7 +61,7 @@ public static async Task<List<TokenData721>> GetAllOwners721(string contractAddr

public static async Task<List<TokenData721>> GetSpecificOwners721(string contractAddress, int[] tokenIds)
{
MultiQueryHandler multiqueryHandler = ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetMultiQueryHandler();
MultiQueryHandler multiqueryHandler = ThirdwebManager.Instance.SDK.session.Web3.Eth.GetMultiQueryHandler();
var calls = new List<MulticallInputOutput<TokenERC721.OwnerOfFunction, TokenERC721.OwnerOfOutputDTO>>();
for (int i = 0; i < tokenIds.Length; i++)
{
Expand All @@ -84,7 +84,7 @@ public static async Task<List<TokenData721>> GetSpecificOwners721(string contrac

public static async Task<List<TokenData721>> GetAllTokenUris721(string contractAddress, int startTokenId, int endTokenId)
{
MultiQueryHandler multiqueryHandler = ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetMultiQueryHandler();
MultiQueryHandler multiqueryHandler = ThirdwebManager.Instance.SDK.session.Web3.Eth.GetMultiQueryHandler();
var calls = new List<MulticallInputOutput<TokenERC721.TokenURIFunction, TokenERC721.TokenURIOutputDTO>>();
for (int i = startTokenId; i <= endTokenId; i++)
{
Expand All @@ -107,7 +107,7 @@ public static async Task<List<TokenData721>> GetAllTokenUris721(string contractA

public static async Task<List<TokenData721>> GetSpecificTokenUris721(string contractAddress, int[] tokenIds)
{
MultiQueryHandler multiqueryHandler = ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetMultiQueryHandler();
MultiQueryHandler multiqueryHandler = ThirdwebManager.Instance.SDK.session.Web3.Eth.GetMultiQueryHandler();
var calls = new List<MulticallInputOutput<TokenERC721.TokenURIFunction, TokenERC721.TokenURIOutputDTO>>();
for (int i = 0; i < tokenIds.Length; i++)
{
Expand All @@ -130,7 +130,7 @@ public static async Task<List<TokenData721>> GetSpecificTokenUris721(string cont

public static async Task<List<int>> GetOwnedTokenIds721(string contractAddress, string ownerAddress)
{
MultiQueryHandler multiqueryHandler = ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetMultiQueryHandler();
MultiQueryHandler multiqueryHandler = ThirdwebManager.Instance.SDK.session.Web3.Eth.GetMultiQueryHandler();
var contract = ThirdwebManager.Instance.SDK.GetContract(contractAddress);
var balance = BigInteger.Parse(await contract.ERC721.BalanceOf(ownerAddress));
var calls = new List<MulticallInputOutput<TokenERC721.TokenOfOwnerByIndexFunction, TokenERC721.TokenOfOwnerByIndexOutputDTO>>();
Expand Down
44 changes: 44 additions & 0 deletions Assets/Thirdweb/Core/Scripts/ThirdwebInterceptor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using MetaMask.Unity;
using Nethereum.JsonRpc.Client;
using Newtonsoft.Json;

namespace Thirdweb
{
public class ThirdwebInterceptor : RequestInterceptor
{
private readonly ThirdwebSession _thirdwebSession;

public ThirdwebInterceptor(ThirdwebSession thirdwebSession)
{
_thirdwebSession = thirdwebSession;
}

public override async Task<object> InterceptSendRequestAsync<T>(Func<RpcRequest, string, Task<T>> interceptedSendRequestAsync, RpcRequest request, string route = null)
{
if (request.Method == "eth_accounts" && _thirdwebSession.IsConnected)
{
return await _thirdwebSession.GetAddress().ConfigureAwait(false);
}

return await interceptedSendRequestAsync(request, route).ConfigureAwait(false);
}

public override async Task<object> InterceptSendRequestAsync<T>(
Func<string, string, object[], Task<T>> interceptedSendRequestAsync,
string method,
string route = null,
params object[] paramList
)
{
if (method == "eth_accounts")
{
return await _thirdwebSession.GetAddress().ConfigureAwait(false);
}

return await interceptedSendRequestAsync(method, route, paramList).ConfigureAwait(false);
}
}
}
11 changes: 11 additions & 0 deletions Assets/Thirdweb/Core/Scripts/ThirdwebInterceptor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 439b177

Please sign in to comment.