Skip to content

Commit 439b177

Browse files
authored
Firekeeper/stability (#68)
1 parent 150d53d commit 439b177

File tree

34 files changed

+752
-808
lines changed

34 files changed

+752
-808
lines changed

Assets/Thirdweb/Core/Prefabs/WalletProvider_MagicAuth.prefab

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ GameObject:
99
serializedVersion: 6
1010
m_Component:
1111
- component: {fileID: 8849381089353801714}
12-
- component: {fileID: 8849381089353801717}
12+
- component: {fileID: 1354709178478519460}
1313
m_Layer: 0
1414
m_Name: WalletProvider_MagicAuth
1515
m_TagString: Untagged
@@ -32,7 +32,7 @@ Transform:
3232
m_Father: {fileID: 0}
3333
m_RootOrder: 0
3434
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35-
--- !u!114 &8849381089353801717
35+
--- !u!114 &1354709178478519460
3636
MonoBehaviour:
3737
m_ObjectHideFlags: 0
3838
m_CorrespondingSourceObject: {fileID: 0}

Assets/Thirdweb/Core/Prefabs/WalletProvider_Metamask.prefab

+25-69
Original file line numberDiff line numberDiff line change
@@ -2989,7 +2989,7 @@ Transform:
29892989
m_ConstrainProportionsScale: 0
29902990
m_Children: []
29912991
m_Father: {fileID: 4036888909731852399}
2992-
m_RootOrder: 2
2992+
m_RootOrder: 1
29932993
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
29942994
--- !u!20 &3503421935344847224
29952995
Camera:
@@ -5102,6 +5102,7 @@ GameObject:
51025102
m_Component:
51035103
- component: {fileID: 3503421935870801902}
51045104
- component: {fileID: 2433011551695929986}
5105+
- component: {fileID: 4559418603046196302}
51055106
m_Layer: 0
51065107
m_Name: WalletProvider_Metamask
51075108
m_TagString: Untagged
@@ -5139,6 +5140,27 @@ MonoBehaviour:
51395140
m_Name:
51405141
m_EditorClassIdentifier:
51415142
config: {fileID: 11400000, guid: 6cbb8289bcfbdba43817188b3b4f15e0, type: 2}
5143+
--- !u!114 &4559418603046196302
5144+
MonoBehaviour:
5145+
m_ObjectHideFlags: 0
5146+
m_CorrespondingSourceObject: {fileID: 0}
5147+
m_PrefabInstance: {fileID: 0}
5148+
m_PrefabAsset: {fileID: 0}
5149+
m_GameObject: {fileID: 3503421935870801903}
5150+
m_Enabled: 1
5151+
m_EditorHideFlags: 0
5152+
m_Script: {fileID: 11500000, guid: f9088d607e1d7b3478fcc73da2791fec, type: 3}
5153+
m_Name:
5154+
m_EditorClassIdentifier:
5155+
MetamaskCanvas: {fileID: 8744985464267693835}
5156+
ConnectButton: {fileID: 3503421936221029119}
5157+
welcomeScreen: {fileID: 3503421936027490483}
5158+
mainScreen: {fileID: 3503421936428190661}
5159+
DeeplinkButton: {fileID: 3503421936066145370}
5160+
HeaderText: {fileID: 3503421936426239605}
5161+
DescriptionText: {fileID: 3503421935881847325}
5162+
loadingSprite: {fileID: 21300000, guid: 717e217158e3e694eb447a4a5910fbbd, type: 3}
5163+
QRCodeImage: {fileID: 32878201333017964}
51425164
--- !u!1 &3503421935881847323
51435165
GameObject:
51445166
m_ObjectHideFlags: 0
@@ -6522,7 +6544,7 @@ Transform:
65226544
m_ConstrainProportionsScale: 0
65236545
m_Children: []
65246546
m_Father: {fileID: 4036888909731852399}
6525-
m_RootOrder: 3
6547+
m_RootOrder: 2
65266548
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
65276549
--- !u!114 &3503421936118848201
65286550
MonoBehaviour:
@@ -6737,19 +6759,7 @@ MonoBehaviour:
67376759
m_OnClick:
67386760
m_PersistentCalls:
67396761
m_Calls:
6740-
- m_Target: {fileID: 2433011551695929986}
6741-
m_TargetAssemblyTypeName: MetaMask.Unity.MetaMaskUnity, MetaMaskUnity.Runtime
6742-
m_MethodName: Connect
6743-
m_Mode: 1
6744-
m_Arguments:
6745-
m_ObjectArgument: {fileID: 0}
6746-
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
6747-
m_IntArgument: 0
6748-
m_FloatArgument: 0
6749-
m_StringArgument:
6750-
m_BoolArgument: 0
6751-
m_CallState: 2
6752-
- m_Target: {fileID: 3503421936427613058}
6762+
- m_Target: {fileID: 4559418603046196302}
67536763
m_TargetAssemblyTypeName: MetaMask.Unity.Samples.VisualController, Assembly-CSharp
67546764
m_MethodName: OpenMainScreen
67556765
m_Mode: 1
@@ -7964,59 +7974,6 @@ MonoBehaviour:
79647974
m_hasFontAssetChanged: 0
79657975
m_baseMaterial: {fileID: 0}
79667976
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
7967-
--- !u!1 &3503421936427613057
7968-
GameObject:
7969-
m_ObjectHideFlags: 0
7970-
m_CorrespondingSourceObject: {fileID: 0}
7971-
m_PrefabInstance: {fileID: 0}
7972-
m_PrefabAsset: {fileID: 0}
7973-
serializedVersion: 6
7974-
m_Component:
7975-
- component: {fileID: 3503421936427613059}
7976-
- component: {fileID: 3503421936427613058}
7977-
m_Layer: 0
7978-
m_Name: Controller
7979-
m_TagString: Untagged
7980-
m_Icon: {fileID: 0}
7981-
m_NavMeshLayer: 0
7982-
m_StaticEditorFlags: 0
7983-
m_IsActive: 1
7984-
--- !u!4 &3503421936427613059
7985-
Transform:
7986-
m_ObjectHideFlags: 0
7987-
m_CorrespondingSourceObject: {fileID: 0}
7988-
m_PrefabInstance: {fileID: 0}
7989-
m_PrefabAsset: {fileID: 0}
7990-
m_GameObject: {fileID: 3503421936427613057}
7991-
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
7992-
m_LocalPosition: {x: 0, y: 0, z: 0}
7993-
m_LocalScale: {x: 1, y: 1, z: 1}
7994-
m_ConstrainProportionsScale: 0
7995-
m_Children: []
7996-
m_Father: {fileID: 4036888909731852399}
7997-
m_RootOrder: 1
7998-
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
7999-
--- !u!114 &3503421936427613058
8000-
MonoBehaviour:
8001-
m_ObjectHideFlags: 0
8002-
m_CorrespondingSourceObject: {fileID: 0}
8003-
m_PrefabInstance: {fileID: 0}
8004-
m_PrefabAsset: {fileID: 0}
8005-
m_GameObject: {fileID: 3503421936427613057}
8006-
m_Enabled: 1
8007-
m_EditorHideFlags: 0
8008-
m_Script: {fileID: 11500000, guid: f9088d607e1d7b3478fcc73da2791fec, type: 3}
8009-
m_Name:
8010-
m_EditorClassIdentifier:
8011-
MetamaskCanvas: {fileID: 8744985464267693835}
8012-
ConnectButton: {fileID: 3503421936221029119}
8013-
welcomeScreen: {fileID: 3503421936027490483}
8014-
mainScreen: {fileID: 3503421936428190661}
8015-
DeeplinkButton: {fileID: 3503421936066145370}
8016-
HeaderText: {fileID: 3503421936426239605}
8017-
DescriptionText: {fileID: 3503421935881847325}
8018-
loadingSprite: {fileID: 21300000, guid: 717e217158e3e694eb447a4a5910fbbd, type: 3}
8019-
QRCodeImage: {fileID: 32878201333017964}
80207977
--- !u!1 &3503421936427620979
80217978
GameObject:
80227979
m_ObjectHideFlags: 0
@@ -9547,7 +9504,6 @@ Transform:
95479504
m_ConstrainProportionsScale: 0
95489505
m_Children:
95499506
- {fileID: 3503421936374056257}
9550-
- {fileID: 3503421936427613059}
95519507
- {fileID: 3503421935344847227}
95529508
- {fileID: 3503421936118848200}
95539509
m_Father: {fileID: 3503421935870801902}

Assets/Thirdweb/Core/Scripts/Contract.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public class Contract : Routable
4444
/// </summary>
4545
public Events events;
4646

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

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

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

131132
var function = contract.GetFunction(functionName);
132133

Assets/Thirdweb/Core/Scripts/Deployer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public async Task<string> DeployNFTDrop(NFTContractDeployMetadata metadata)
3737
throw new UnityException("This functionality is not yet available on your current platform.");
3838

3939
var deploymentMessage = new DropERC721Deployment();
40-
var deploymentHandler = ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetContractDeploymentHandler<DropERC721Deployment>();
40+
var deploymentHandler = ThirdwebManager.Instance.SDK.session.Web3.Eth.GetContractDeploymentHandler<DropERC721Deployment>();
4141
var deploymentReceipt = await deploymentHandler.SendRequestAndWaitForReceiptAsync(deploymentMessage);
42-
DropERC721Service dropERC721Service = new DropERC721Service(ThirdwebManager.Instance.SDK.nativeSession.web3, deploymentReceipt.ContractAddress);
42+
DropERC721Service dropERC721Service = new DropERC721Service(ThirdwebManager.Instance.SDK.session.Web3, deploymentReceipt.ContractAddress);
4343
var initializeReceipt = await dropERC721Service.InitializeRequestAndWaitForReceiptAsync(
4444
defaultAdmin: await ThirdwebManager.Instance.SDK.wallet.GetAddress(),
4545
name: metadata.name,

Assets/Thirdweb/Core/Scripts/ERC20.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,10 @@ public async Task<ERC20SignedPayload> Generate(ERC20MintPayload payloadToSign, s
488488
Uid = payloadToSign.uid.HexStringToByteArray()
489489
};
490490

491+
var name = await TransactionManager.ThirdwebRead<TokenERC20Contract.NameFunction, TokenERC20Contract.NameOutputDTO>(contractAddress, new TokenERC20Contract.NameFunction() { });
492+
491493
string signature = await Thirdweb.EIP712.GenerateSignature_TokenERC20(
492-
"TokenERC20",
494+
name.ReturnValue1,
493495
"1",
494496
await ThirdwebManager.Instance.SDK.wallet.GetChainId(),
495497
contractAddress,

Assets/Thirdweb/Core/Scripts/Marketplace.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ public async Task<TransactionResult> MakeOffer(MakeOfferInput input)
905905
AssetContract = input.assetContractAddress,
906906
TokenId = BigInteger.Parse(input.tokenId),
907907
Quantity = BigInteger.Parse(input.quantity ?? "1"),
908-
Currency = input.currencyContractAddress ?? Utils.GetNativeTokenWrapper(ThirdwebManager.Instance.SDK.nativeSession.lastChainId),
908+
Currency = input.currencyContractAddress ?? Utils.GetNativeTokenWrapper(ThirdwebManager.Instance.SDK.session.ChainId),
909909
TotalPrice = BigInteger.Parse(input.totalPrice.ToWei()),
910910
ExpirationTimestamp = (BigInteger)(input.endTimestamp ?? Utils.GetUnixTimeStampIn10Years())
911911
}

Assets/Thirdweb/Core/Scripts/Multicall.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static async Task<List<TokenData721>> GetOwnedTokenData721(string contrac
3838

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

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

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

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

131131
public static async Task<List<int>> GetOwnedTokenIds721(string contractAddress, string ownerAddress)
132132
{
133-
MultiQueryHandler multiqueryHandler = ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetMultiQueryHandler();
133+
MultiQueryHandler multiqueryHandler = ThirdwebManager.Instance.SDK.session.Web3.Eth.GetMultiQueryHandler();
134134
var contract = ThirdwebManager.Instance.SDK.GetContract(contractAddress);
135135
var balance = BigInteger.Parse(await contract.ERC721.BalanceOf(ownerAddress));
136136
var calls = new List<MulticallInputOutput<TokenERC721.TokenOfOwnerByIndexFunction, TokenERC721.TokenOfOwnerByIndexOutputDTO>>();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
using MetaMask.Unity;
5+
using Nethereum.JsonRpc.Client;
6+
using Newtonsoft.Json;
7+
8+
namespace Thirdweb
9+
{
10+
public class ThirdwebInterceptor : RequestInterceptor
11+
{
12+
private readonly ThirdwebSession _thirdwebSession;
13+
14+
public ThirdwebInterceptor(ThirdwebSession thirdwebSession)
15+
{
16+
_thirdwebSession = thirdwebSession;
17+
}
18+
19+
public override async Task<object> InterceptSendRequestAsync<T>(Func<RpcRequest, string, Task<T>> interceptedSendRequestAsync, RpcRequest request, string route = null)
20+
{
21+
if (request.Method == "eth_accounts" && _thirdwebSession.IsConnected)
22+
{
23+
return await _thirdwebSession.GetAddress().ConfigureAwait(false);
24+
}
25+
26+
return await interceptedSendRequestAsync(request, route).ConfigureAwait(false);
27+
}
28+
29+
public override async Task<object> InterceptSendRequestAsync<T>(
30+
Func<string, string, object[], Task<T>> interceptedSendRequestAsync,
31+
string method,
32+
string route = null,
33+
params object[] paramList
34+
)
35+
{
36+
if (method == "eth_accounts")
37+
{
38+
return await _thirdwebSession.GetAddress().ConfigureAwait(false);
39+
}
40+
41+
return await interceptedSendRequestAsync(method, route, paramList).ConfigureAwait(false);
42+
}
43+
}
44+
}

Assets/Thirdweb/Core/Scripts/ThirdwebInterceptor.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)