diff --git a/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/ChainSafe.Gaming.Lootboxes.Chainlink.dll b/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/ChainSafe.Gaming.Lootboxes.Chainlink.dll
index 11abfb4e2..e4f725aec 100644
Binary files a/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/ChainSafe.Gaming.Lootboxes.Chainlink.dll and b/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/ChainSafe.Gaming.Lootboxes.Chainlink.dll differ
diff --git a/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/Chainsafe.Gaming.Chainlink.dll b/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/Chainsafe.Gaming.Chainlink.dll
index 1a5666d7e..4d76f4e7a 100644
Binary files a/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/Chainsafe.Gaming.Chainlink.dll and b/Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/Chainsafe.Gaming.Chainlink.dll differ
diff --git a/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/ChainlinkLootboxSampleLauncher.cs b/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/ChainlinkLootboxSampleLauncher.cs
index a1fe7ff64..1aa12a073 100644
--- a/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/ChainlinkLootboxSampleLauncher.cs
+++ b/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/ChainlinkLootboxSampleLauncher.cs
@@ -3,6 +3,7 @@
using ChainSafe.Gaming.Debugging;
using ChainSafe.Gaming.Evm.JsonRpc;
using ChainSafe.Gaming.Lootboxes.Chainlink;
+using ChainSafe.Gaming.UnityPackage;
using ChainSafe.Gaming.Wallets;
using ChainSafe.Gaming.Web3;
using ChainSafe.Gaming.Web3.Build;
@@ -36,8 +37,7 @@ private class Web3Config : ICompleteProjectConfig
private async void Awake()
{
- web3 = await new Web3Builder(new Web3Config())
- .Configure(services =>
+ web3 = Web3Accessor.TryWeb3 ?? await new Web3Builder(new Web3Config()).Configure(services =>
{
services.UseUnityEnvironment();
services.UseRpcProvider();
diff --git a/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs b/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs
new file mode 100644
index 000000000..3c21ce5aa
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs
@@ -0,0 +1,32 @@
+using ChainSafe.Gaming.Lootboxes.Chainlink;
+using ChainSafe.Gaming.UnityPackage.Common;
+using ChainSafe.Gaming.Web3.Build;
+using Microsoft.Extensions.DependencyInjection;
+using UnityEngine;
+
+namespace LootBoxes.Chainlink
+{
+ ///
+ /// Configures Lootboxes services to work with a .
+ ///
+ public class LootboxesServicesAdapter : MonoBehaviour, IWeb3BuilderServiceAdapter
+ {
+ // the default values are setup for sepolia.
+ [SerializeField] private string contractAddress = "0x1993e2dD323B5dcBd8b52dB7d370bC36D280424B";
+
+ [SerializeField] private string contractAbi = "[ { \"inputs\": [], \"name\": \"AcceptingOnlyLINK\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" } ], \"name\": \"AccessDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"AmountPerUnitOverflow\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" } ], \"name\": \"DepositStateCorruption\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"EndOfService\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InsufficientFee\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InsufficientGas\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InsufficientPayment\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"supply\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"requested\", \"type\": \"uint256\" } ], \"name\": \"InsufficientSupply\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InvalidLength\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"int256\", \"name\": \"value\", \"type\": \"int256\" } ], \"name\": \"InvalidLinkPrice\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InvalidLootboxType\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"InvalidRequestAllocation\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InvalidTokenAmount\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"InventoryStateCorruption\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"oldType\", \"type\": \"uint8\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"newType\", \"type\": \"uint8\" } ], \"name\": \"ModifiedRewardType\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NoTokens\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NothingToClaim\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NothingToRecover\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"OnlyThis\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"PendingOpenRequest\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"RewardWithdrawalDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" } ], \"name\": \"SupplyDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"supply\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"unitsToGet\", \"type\": \"uint256\" } ], \"name\": \"SupplyExceeded\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"TokenDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"currentPrice\", \"type\": \"uint256\" } ], \"name\": \"UnexpectedPrice\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"rewardType\", \"type\": \"uint8\" } ], \"name\": \"UnexpectedRewardType\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"UnitsOverflow\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"Unsupported\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"ViewCallFailed\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"ZeroAmount\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"ZeroSupply\", \"type\": \"error\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"Allocated\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"newSupply\", \"type\": \"uint256\" } ], \"name\": \"AmountPerUnitSet\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"bool\", \"name\": \"approved\", \"type\": \"bool\" } ], \"name\": \"ApprovalForAll\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"BoxesRecovered\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"caller\", \"type\": \"address\" } ], \"name\": \"EmergencyModeEnabled\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"tokenType\", \"type\": \"uint8\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"amounts\", \"type\": \"uint256[]\" } ], \"name\": \"EmergencyWithdrawal\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"bytes\", \"name\": \"reason\", \"type\": \"bytes\" } ], \"name\": \"OpenRequestFailed\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"randomness\", \"type\": \"uint256\" } ], \"name\": \"OpenRequestFulfilled\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"unitsToGet\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"OpenRequested\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"Paused\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"newPrice\", \"type\": \"uint256\" } ], \"name\": \"PriceUpdated\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"RewardsClaimed\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"previousAdminRole\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"newAdminRole\", \"type\": \"bytes32\" } ], \"name\": \"RoleAdminChanged\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"sender\", \"type\": \"address\" } ], \"name\": \"RoleGranted\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"sender\", \"type\": \"address\" } ], \"name\": \"RoleRevoked\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"buyer\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"payment\", \"type\": \"uint256\" } ], \"name\": \"Sold\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"supplier\", \"type\": \"address\" } ], \"name\": \"SupplierAdded\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"supplier\", \"type\": \"address\" } ], \"name\": \"SupplierRemoved\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"TokenAdded\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"values\", \"type\": \"uint256[]\" } ], \"name\": \"TransferBatch\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"TransferSingle\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"string\", \"name\": \"value\", \"type\": \"string\" }, { \"indexed\": true, \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"URI\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"Unpaused\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"Withdraw\", \"type\": \"event\" }, { \"inputs\": [], \"name\": \"DEFAULT_ADMIN_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"FACTORY\", \"outputs\": [ { \"internalType\": \"contract ILootboxFactory\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"LINK_ETH_FEED\", \"outputs\": [ { \"internalType\": \"contract AggregatorV3Interface\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"MINTER_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"PAUSER_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_requestId\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"_randomness\", \"type\": \"uint256\" } ], \"name\": \"_allocateRewards\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_suppliers\", \"type\": \"address[]\" } ], \"name\": \"addSuppliers\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_tokens\", \"type\": \"address[]\" } ], \"name\": \"addTokens\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"balanceOf\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"accounts\", \"type\": \"address[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" } ], \"name\": \"balanceOfBatch\", \"outputs\": [ { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"burn\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"values\", \"type\": \"uint256[]\" } ], \"name\": \"burnBatch\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_amount\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"_maxPrice\", \"type\": \"uint256\" } ], \"name\": \"buy\", \"outputs\": [], \"stateMutability\": \"payable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint32\", \"name\": \"_gas\", \"type\": \"uint32\" }, { \"internalType\": \"uint256\", \"name\": \"_gasPriceInWei\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"_units\", \"type\": \"uint256\" } ], \"name\": \"calculateOpenPrice\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"canClaimRewards\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"claimRewards\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_token\", \"type\": \"address\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"_type\", \"type\": \"uint8\" }, { \"internalType\": \"address\", \"name\": \"_to\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"_ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_amounts\", \"type\": \"uint256[]\" } ], \"name\": \"emergencyWithdraw\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getAllowedTokenTypes\", \"outputs\": [ { \"internalType\": \"enum LootboxInterface.RewardType[]\", \"name\": \"result\", \"type\": \"uint8[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getAllowedTokens\", \"outputs\": [ { \"internalType\": \"address[]\", \"name\": \"\", \"type\": \"address[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getAvailableSupply\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getInventory\", \"outputs\": [ { \"components\": [ { \"internalType\": \"address\", \"name\": \"rewardToken\", \"type\": \"address\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"rewardType\", \"type\": \"uint8\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" }, { \"components\": [ { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" } ], \"internalType\": \"struct LootboxInterface.ExtraRewardInfo[]\", \"name\": \"extra\", \"type\": \"tuple[]\" } ], \"internalType\": \"struct LootboxInterface.RewardView[]\", \"name\": \"result\", \"type\": \"tuple[]\" }, { \"components\": [ { \"internalType\": \"address\", \"name\": \"rewardToken\", \"type\": \"address\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"rewardType\", \"type\": \"uint8\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" }, { \"components\": [ { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" } ], \"internalType\": \"struct LootboxInterface.ExtraRewardInfo[]\", \"name\": \"extra\", \"type\": \"tuple[]\" } ], \"internalType\": \"struct LootboxInterface.RewardView[]\", \"name\": \"leftoversResult\", \"type\": \"tuple[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getLink\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getLinkPrice\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getLootboxTypes\", \"outputs\": [ { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"getOpenerRequestDetails\", \"outputs\": [ { \"components\": [ { \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"internalType\": \"uint96\", \"name\": \"unitsToGet\", \"type\": \"uint96\" }, { \"internalType\": \"uint256[]\", \"name\": \"lootIds\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"lootAmounts\", \"type\": \"uint256[]\" } ], \"internalType\": \"struct LootboxInterface.Request\", \"name\": \"request\", \"type\": \"tuple\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getPrice\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" } ], \"name\": \"getRoleAdmin\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"uint256\", \"name\": \"index\", \"type\": \"uint256\" } ], \"name\": \"getRoleMember\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" } ], \"name\": \"getRoleMemberCount\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getSuppliers\", \"outputs\": [ { \"internalType\": \"address[]\", \"name\": \"\", \"type\": \"address[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getVRFV2Wrapper\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"grantRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"hasRole\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" } ], \"name\": \"isApprovedForAll\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"isEmergencyMode\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"mint\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"amounts\", \"type\": \"uint256[]\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"mintBatch\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_tos\", \"type\": \"address[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_lootboxTypes\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_amounts\", \"type\": \"uint256[]\" } ], \"name\": \"mintToMany\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" }, { \"internalType\": \"bytes\", \"name\": \"\", \"type\": \"bytes\" } ], \"name\": \"onERC1155BatchReceived\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"\", \"type\": \"bytes\" } ], \"name\": \"onERC1155Received\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"\", \"type\": \"bytes\" } ], \"name\": \"onERC721Received\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint32\", \"name\": \"_gas\", \"type\": \"uint32\" }, { \"internalType\": \"uint256[]\", \"name\": \"_lootIds\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_lootAmounts\", \"type\": \"uint256[]\" } ], \"name\": \"open\", \"outputs\": [], \"stateMutability\": \"payable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"name\": \"openerRequests\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"pause\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"paused\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_requestId\", \"type\": \"uint256\" }, { \"internalType\": \"uint256[]\", \"name\": \"_randomWords\", \"type\": \"uint256[]\" } ], \"name\": \"rawFulfillRandomWords\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"recoverBoxes\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_suppliers\", \"type\": \"address[]\" } ], \"name\": \"removeSuppliers\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"renounceRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"revokeRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"amounts\", \"type\": \"uint256[]\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"safeBatchTransferFrom\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"safeTransferFrom\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_tokens\", \"type\": \"address[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_amountsPerUnit\", \"type\": \"uint256[]\" } ], \"name\": \"setAmountsPerUnit\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"internalType\": \"bool\", \"name\": \"approved\", \"type\": \"bool\" } ], \"name\": \"setApprovalForAll\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_newPrice\", \"type\": \"uint256\" } ], \"name\": \"setPrice\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"string\", \"name\": \"_baseURI\", \"type\": \"string\" } ], \"name\": \"setURI\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_from\", \"type\": \"address\" } ], \"name\": \"supplyAllowed\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes4\", \"name\": \"interfaceId\", \"type\": \"bytes4\" } ], \"name\": \"supportsInterface\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_token\", \"type\": \"address\" } ], \"name\": \"tokenAllowed\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unitsMinted\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unitsRequested\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unitsSupply\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unpause\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"name\": \"uri\", \"outputs\": [ { \"internalType\": \"string\", \"name\": \"\", \"type\": \"string\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"viewCall\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_token\", \"type\": \"address\" }, { \"internalType\": \"address payable\", \"name\": \"_to\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"_amount\", \"type\": \"uint256\" } ], \"name\": \"withdraw\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" } ]";
+
+ public Web3Builder ConfigureServices(Web3Builder web3Builder)
+ {
+ return web3Builder.Configure(services =>
+ {
+ services.UseChainlinkLootboxService(new LootboxServiceConfig
+ {
+ ContractAddress = contractAddress,
+ ContractAbi = contractAbi
+ });
+ services.AddSingleton();
+ });
+ }
+ }
+}
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs.meta b/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs.meta
similarity index 83%
rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs.meta
rename to Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs.meta
index 90c453b23..f5a49c735 100644
--- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs.meta
+++ b/Packages/io.chainsafe.web3-unity.lootboxes/Samples~/Chainlink Lootbox Samples/Scripts/LootboxesServicesAdapter.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 93ae86024927f3f499e488b918531db5
+guid: 1601a8846d451cf4fb87a7082da91a7f
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs b/Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs
new file mode 100644
index 000000000..1bb4ba2d3
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs
@@ -0,0 +1,24 @@
+using System.Collections;
+using System.Collections.Generic;
+using ChainSafe.Gaming.UnityPackage.Common;
+using ChainSafe.Gaming.Web3.Build;
+using UnityEngine;
+
+namespace ChainSafe.Gaming.Exchangers.Ramp
+{
+ ///
+ /// Add Ramp service when building a Web3 instance.
+ ///
+ public class RampServiceAdapter : MonoBehaviour, IWeb3BuilderServiceAdapter
+ {
+ [SerializeField] private RampExchangerConfigSO rampConfig;
+
+ public Web3Builder ConfigureServices(Web3Builder web3Builder)
+ {
+ return web3Builder.Configure(services =>
+ {
+ services.UseRampExchanger(rampConfig);
+ });
+ }
+ }
+}
diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta b/Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs.meta
similarity index 83%
rename from Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta
rename to Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs.meta
index 50f8761b4..f2a4207ba 100644
--- a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta
+++ b/Packages/io.chainsafe.web3-unity.ramp/Runtime/Scripts/RampServiceAdapter.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 74c0e58ffe715a448a1d221b425d7352
+guid: d4bbed5530529ea46a1f41b407499dc5
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scenes/SampleLogin - Web3Auth.unity b/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scenes/SampleLogin - Web3Auth.unity
index 23cde91b0..7c013242a 100644
--- a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scenes/SampleLogin - Web3Auth.unity
+++ b/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scenes/SampleLogin - Web3Auth.unity
@@ -476,7 +476,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- - m_Target: {fileID: 337558421}
+ - m_Target: {fileID: 0}
m_TargetAssemblyTypeName: Scenes.ErrorPopup, Assembly-CSharp
m_MethodName: Close
m_Mode: 1
@@ -574,7 +574,7 @@ MonoBehaviour:
m_GameObject: {fileID: 337558419}
m_Enabled: 1
m_EditorHideFlags: 0
- m_Script: {fileID: 11500000, guid: c001d0d5433b4215b8abba94194881bd, type: 3}
+ m_Script: {fileID: 11500000, guid: 9df78976caa7771429cfe2b9b96e1491, type: 3}
m_Name:
m_EditorClassIdentifier:
MessageLabel: {fileID: 804898217}
@@ -1184,7 +1184,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- - m_Target: {fileID: 337558421}
+ - m_Target: {fileID: 0}
m_TargetAssemblyTypeName: Scenes.ErrorPopup, Assembly-CSharp
m_MethodName: Close
m_Mode: 1
@@ -1362,6 +1362,7 @@ GameObject:
m_Component:
- component: {fileID: 1679801099}
- component: {fileID: 1679801100}
+ - component: {fileID: 1679801101}
m_Layer: 0
m_Name: Logic - Login - Web3Auth
m_TagString: Untagged
@@ -1396,10 +1397,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7b6902e441950fa4bb5cefdd2263164a, type: 3}
m_Name:
m_EditorClassIdentifier:
- k__BackingField: SampleRampIntegration
gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_
errorPopup: {fileID: 337558421}
- rampConfig: {fileID: 11400000, guid: d1f58846e4fc71d4e90f287a86f328f9, type: 2}
clientId: BCc0wTmuXureEzgawhUSZOWu4bgWo56sZPrxLiHQCpg5OHcNrfa44esdTS8Dm77VtmaIyjhbthdWfbLhSwf7jtU
redirectUri: torusapp://io.chainsafe.gamingsdk.sdkdemoscene/auth
network: 1
@@ -1416,6 +1415,19 @@ MonoBehaviour:
Provider: 3
- Button: {fileID: 7400892925769233044}
Provider: 4
+--- !u!114 &1679801101
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1679801098}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 3d2237df0314604419146b916b88d158, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ sceneToLoad: SampleMain
--- !u!1 &1799608969
GameObject:
m_ObjectHideFlags: 0
diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs b/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs
deleted file mode 100644
index 1b7d7489d..000000000
--- a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Utilities/Web3AuthSceneIndexer.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-#if UNITY_EDITOR
-using UnityEditor;
-
-///
-/// Add Web3.Unity Web3Auth package sample scenes to Build Settings Scenes
-///
-[InitializeOnLoad]
-public static class Web3AuthSceneIndexer
-{
- private const string ScenesIndexedKey = PackageName + "ScenesIndexed";
-
- private const string PackageName = "io.chainsafe.web3-unity.web3auth";
-
- static Web3AuthSceneIndexer()
- {
- SceneIndexer.TryAddEditorBuildSettingsScenes(PackageName, ScenesIndexedKey, new string[]
- {
- "SampleLogin - Web3Auth.Unity",
- });
- }
-}
-
-#endif
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLogin.cs b/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLoginProvider.cs
similarity index 84%
rename from Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLogin.cs
rename to Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLoginProvider.cs
index ed1a4a8c9..18d6e62a6 100644
--- a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLogin.cs
+++ b/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLoginProvider.cs
@@ -4,6 +4,7 @@
using System.Threading.Tasks;
using ChainSafe.Gaming.Exchangers.Ramp;
using ChainSafe.Gaming.UnityPackage;
+using ChainSafe.Gaming.UnityPackage.Common;
using ChainSafe.Gaming.Web3;
using ChainSafe.Gaming.Web3.Analytics;
using ChainSafe.Gaming.Web3.Build;
@@ -16,11 +17,11 @@
///
/// Login using Web3Auth.
///
-public class Web3AuthLogin : Login
+public class Web3AuthLoginProvider : LoginProvider, IWeb3BuilderServiceAdapter
{
///
/// Struct used for pairing login buttons to Web3 auth providers.
- /// Used when adding as listeners to the buttons.
+ /// Used when adding as listeners to the buttons.
///
[Serializable]
public struct ProviderAndButtonPair
@@ -35,7 +36,7 @@ public struct ProviderAndButtonPair
[SerializeField] private Network network;
[Header("UI")]
[SerializeField] private List providerAndButtonPairs;
-
+
private bool useProvider;
private Provider selectedProvider;
@@ -47,13 +48,13 @@ public void SetRememberMe(bool rememberMe)
this.rememberMe = rememberMe;
}
- protected override IEnumerator Initialize()
+ protected override async void Initialize()
{
+ base.Initialize();
+
//Always first add listeners.
providerAndButtonPairs.ForEach(p =>
p.Button.onClick.AddListener(delegate { LoginWithWeb3Auth(p.Provider); }));
-
- yield return null;
#if UNITY_WEBGL && !UNITY_EDITOR
Uri uri = new Uri(Application.absoluteURL);
@@ -63,9 +64,7 @@ protected override IEnumerator Initialize()
{
useProvider = false;
- Task loginTask = TryLogin();
-
- yield return new WaitUntil(() => loginTask.IsCompleted);
+ await TryLogin();
}
#else
@@ -73,15 +72,10 @@ protected override IEnumerator Initialize()
{
useProvider = false;
rememberMe = true;
- Task loginTask = TryLogin();
+ await TryLogin();
Debug.Log("Restoring existing Web3Auth session (Remember Me");
- yield return new WaitUntil(() => loginTask.IsCompleted);
}
#endif
-
- // add provider buttons listeners
-
-
}
private async void LoginWithWeb3Auth(Provider provider)
@@ -91,8 +85,7 @@ private async void LoginWithWeb3Auth(Provider provider)
useProvider = true;
}
selectedProvider = provider;
-
-
+
await TryLogin();
LogAnalytics(provider);
}
@@ -111,7 +104,7 @@ private void LogAnalytics(Provider provider)
});
}
- protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder)
+ public Web3Builder ConfigureServices(Web3Builder web3Builder)
{
return web3Builder.Configure(services =>
{
@@ -140,7 +133,7 @@ protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder)
};
}
- services.UseWeb3AuthWallet(web3AuthConfig);
+ services.UseWeb3AuthWallet(web3AuthConfig);
});
}
}
diff --git a/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLogin.cs.meta b/Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLoginProvider.cs.meta
similarity index 100%
rename from Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLogin.cs.meta
rename to Packages/io.chainsafe.web3-unity.web3auth/Samples~/Web3.Unity Web3Auth/Scripts/Web3AuthLoginProvider.cs.meta
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common.meta
new file mode 100644
index 000000000..737c04e1d
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 2ed1ce1c103b01b48a65b4631569502f
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts.meta
new file mode 100644
index 000000000..ae4d8755e
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: b3347b82b502e4f4fa3d94b8ae6c144a
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs
similarity index 56%
rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs
rename to Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs
index f8c26431a..2e7134c64 100644
--- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs
@@ -1,18 +1,25 @@
using UnityEngine;
using UnityEngine.UI;
-namespace Scenes
+namespace ChainSafe.Gaming.UnityPackage.Common
{
public class ErrorPopup : MonoBehaviour
{
public Text MessageLabel;
+ ///
+ /// Display error pop up when Login fails.
+ ///
+ /// Error message to be displayed.
public void ShowError(string message)
{
gameObject.SetActive(true);
MessageLabel.text = message;
}
+ ///
+ /// Close error popup.
+ ///
public void Close()
{
gameObject.SetActive(false);
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs.meta
similarity index 53%
rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs.meta
rename to Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs.meta
index b0a77395c..3c9c65f01 100644
--- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ErrorPopup.cs.meta
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ErrorPopup.cs.meta
@@ -1,3 +1,3 @@
fileFormatVersion: 2
-guid: c001d0d5433b4215b8abba94194881bd
+guid: 9df78976caa7771429cfe2b9b96e1491
timeCreated: 1691581208
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs
new file mode 100644
index 000000000..df265e476
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs
@@ -0,0 +1,101 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using ChainSafe.Gaming.Evm.Contracts;
+using ChainSafe.Gaming.Evm.JsonRpc;
+using ChainSafe.Gaming.MultiCall;
+using ChainSafe.Gaming.UnityPackage;
+using ChainSafe.Gaming.Web3;
+using ChainSafe.Gaming.Web3.Build;
+using ChainSafe.Gaming.Web3.Unity;
+using ChainSafe.GamingSdk.Gelato;
+using Scripts.EVM.Token;
+using UnityEngine;
+using UnityEngine.SceneManagement;
+
+namespace ChainSafe.Gaming.UnityPackage.Common
+{
+ ///
+ /// Builds Instance and Login using a Wallet or a provider.
+ ///
+ public interface ILoginProvider
+ {
+ ///
+ /// Gelato API key from Gelato's Web Dashboard.
+ ///
+ public string GelatoApiKey { get; }
+
+ ///
+ /// All service providers used for configuring instance services.
+ ///
+ public IWeb3BuilderServiceAdapter[] Web3BuilderServiceAdapters { get; }
+
+ ///
+ /// All Web3 initialized handlers called when Web3 instance is initialized.
+ ///
+ public IWeb3InitializedHandler[] Web3InitializedHandlers { get; }
+
+ ///
+ /// Login by Building a Instance.
+ ///
+ public async Task Login()
+ {
+ Web3.Web3 web3;
+
+ Web3Builder web3Builder = new Web3Builder(ProjectConfigUtilities.Load()).Configure(ConfigureCommonServices);
+
+ web3Builder = ConfigureWeb3Services(web3Builder);
+
+ web3 = await web3Builder.LaunchAsync();
+
+ Web3Accessor.Set(web3);
+
+ OnWeb3Initialized();
+ }
+
+ private void OnWeb3Initialized()
+ {
+ foreach (var web3InitializedHandler in Web3InitializedHandlers)
+ {
+ web3InitializedHandler.OnWeb3Initialized();
+ }
+ }
+
+ ///
+ /// Configure services to inject based on the type of Login/Provider you want to use.
+ ///
+ /// Builder for services to use.
+ /// Builder with new services added/injected.
+ private Web3Builder ConfigureWeb3Services(Web3Builder web3Builder)
+ {
+ foreach (var adapter in Web3BuilderServiceAdapters)
+ {
+ web3Builder = adapter.ConfigureServices(web3Builder);
+ }
+
+ return web3Builder;
+ }
+
+ private void ConfigureCommonServices(IWeb3ServiceCollection services)
+ {
+ services
+ .UseUnityEnvironment()
+ .UseGelato(GelatoApiKey)
+ .UseMultiCall()
+ .UseRpcProvider();
+
+ /* As many contracts as needed may be registered here.
+ * It is better to register all contracts the application
+ * will be interacting with at configuration time if they
+ * are known in advance. We're just registering shiba
+ * here to show how it's done. You can look at the
+ * `Scripts/Prefabs/Wallet/RegisteredContract` script
+ * to see how it's used later on.
+ */
+ services.ConfigureRegisteredContracts(contracts =>
+ contracts.RegisterContract("CsTestErc20", ABI.Erc20, Contracts.Erc20));
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs.meta
similarity index 83%
rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta
rename to Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs.meta
index 50f8761b4..f7c5148f3 100644
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs.meta
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/ILoginProvider.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 74c0e58ffe715a448a1d221b425d7352
+guid: 5428fb54c62be2747ad58358db433c80
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs
new file mode 100644
index 000000000..b6ec6a644
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs
@@ -0,0 +1,21 @@
+using ChainSafe.Gaming.Debugging;
+using ChainSafe.Gaming.Lootboxes.Chainlink;
+using ChainSafe.Gaming.Wallets;
+using ChainSafe.Gaming.Web3.Build;
+using UnityEngine;
+
+namespace ChainSafe.Gaming.UnityPackage.Common
+{
+ ///
+ /// Provides services for building a instance.
+ ///
+ public interface IWeb3BuilderServiceAdapter
+ {
+ ///
+ /// Configures services for building a instance.
+ ///
+ /// Builder object for a instance.
+ /// Builder with services configured to it.
+ public Web3Builder ConfigureServices(Web3Builder web3Builder);
+ }
+}
\ No newline at end of file
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs.meta
similarity index 83%
rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs.meta
rename to Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs.meta
index 90c453b23..5f166a5de 100644
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs.meta
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3BuilderServiceAdapter.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 93ae86024927f3f499e488b918531db5
+guid: 933b66c7fa977c542a9f852ed967efd0
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs
new file mode 100644
index 000000000..177493e43
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs
@@ -0,0 +1,13 @@
+namespace ChainSafe.Gaming.UnityPackage.Common
+{
+ ///
+ /// Initialized handler used for executing logic when a web3 instance is initialized.
+ ///
+ public interface IWeb3InitializedHandler
+ {
+ ///
+ /// Called when Web3 Instance in is initialized.
+ ///
+ public void OnWeb3Initialized();
+ }
+}
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs.meta
new file mode 100644
index 000000000..2dda32482
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/IWeb3InitializedHandler.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 415bfa3b2643497449b26a9dc2392df3
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs
new file mode 100644
index 000000000..9bb691590
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs
@@ -0,0 +1,26 @@
+using ChainSafe.Gaming.UnityPackage.Common;
+using UnityEngine;
+using UnityEngine.SceneManagement;
+
+namespace ChainSafe.Gaming.UnityPackage.Common
+{
+ ///
+ /// Loads scene when Web3 Instance is initialized.
+ ///
+ public class LoadSceneOnLogin : MonoBehaviour, IWeb3InitializedHandler
+ {
+ ///
+ /// Login scene cached/saved for Logout since we can have more than one Login scene.
+ ///
+ public static int LoginSceneBuildIndex { get; private set; }
+
+ [SerializeField] private string sceneToLoad;
+
+ public void OnWeb3Initialized()
+ {
+ LoginSceneBuildIndex = SceneManager.GetActiveScene().buildIndex;
+
+ SceneManager.LoadSceneAsync(sceneToLoad);
+ }
+ }
+}
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs.meta
new file mode 100644
index 000000000..36d62511c
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoadSceneOnLogin.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 3d2237df0314604419146b916b88d158
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs
new file mode 100644
index 000000000..baee80c28
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Threading.Tasks;
+using ChainSafe.Gaming.UnityPackage.Common;
+using UnityEngine;
+
+namespace Scenes
+{
+ ///
+ /// A concrete implementation of .
+ ///
+ public abstract class LoginProvider : MonoBehaviour, ILoginProvider
+ {
+ [SerializeField] private string gelatoApiKey = "";
+
+ [SerializeField] private ErrorPopup errorPopup;
+
+ public string GelatoApiKey => gelatoApiKey;
+ public IWeb3BuilderServiceAdapter[] Web3BuilderServiceAdapters { get; private set; }
+ public IWeb3InitializedHandler[] Web3InitializedHandlers { get; private set; }
+
+ private void Start()
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes Login providers.
+ ///
+ protected virtual void Initialize()
+ {
+ Web3BuilderServiceAdapters = GetComponents();
+
+ Web3InitializedHandlers = GetComponents();
+ }
+
+ ///
+ /// Try to Login and displays error and throws exception on a failed attempt.
+ ///
+ public async Task TryLogin()
+ {
+ try
+ {
+ await (this as ILoginProvider).Login();
+ }
+ catch (Exception e)
+ {
+ errorPopup.ShowError($"Login failed, please try again\n{e.Message} (see console for more details)");
+
+ throw;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs.meta
similarity index 53%
rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs.meta
rename to Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs.meta
index 61485ea02..b19bee141 100644
--- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs.meta
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Common/Scripts/LoginProvider.cs.meta
@@ -1,3 +1,3 @@
fileFormatVersion: 2
-guid: 9473851428864b439d6561c87053272a
+guid: b5a2f51f95094c949a28c71dc8658551
timeCreated: 1691581402
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Debugging.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Debugging.dll
index 3f33895c4..68e9fa68e 100644
Binary files a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Debugging.dll and b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Debugging.dll differ
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Gelato.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Gelato.dll
index 7557c6b8f..9a3b24086 100644
Binary files a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Gelato.dll and b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Gelato.dll differ
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessSigner.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessSigner.dll
index 38dc12395..63346efbe 100644
Binary files a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessSigner.dll and b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessSigner.dll differ
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessTransactionExecutor.Unity.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessTransactionExecutor.Unity.dll
index e8a369d40..0733f7cfb 100644
Binary files a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessTransactionExecutor.Unity.dll and b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessTransactionExecutor.Unity.dll differ
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessTransactionExecutor.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessTransactionExecutor.dll
index 32f55a2e7..6cb635525 100644
Binary files a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessTransactionExecutor.dll and b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessTransactionExecutor.dll differ
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.Unity.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.Unity.dll
index 031f1f62a..e3aa3db6f 100644
Binary files a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.Unity.dll and b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.Unity.dll differ
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.dll
index 4db43e04c..378e3c635 100644
Binary files a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.dll and b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.MetaMask.dll differ
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.ThirdParty.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.ThirdParty.dll
index 9b8e07590..d15c6767d 100644
Binary files a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.ThirdParty.dll and b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.ThirdParty.dll differ
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.dll
index 83ae70c1c..f61a407c0 100644
Binary files a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.dll and b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.dll differ
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.WalletConnect.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.WalletConnect.dll
index 4bd5e04d7..66f3f3299 100644
Binary files a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.WalletConnect.dll and b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.WalletConnect.dll differ
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.dll
index 862013e17..e1bcb73d0 100644
Binary files a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.dll and b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.dll differ
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - MetaMask.unity b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - MetaMask.unity
index fcd389c92..fd738cc43 100644
--- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - MetaMask.unity
+++ b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - MetaMask.unity
@@ -249,7 +249,7 @@ MonoBehaviour:
m_GameObject: {fileID: 314965759}
m_Enabled: 1
m_EditorHideFlags: 0
- m_Script: {fileID: 11500000, guid: c001d0d5433b4215b8abba94194881bd, type: 3}
+ m_Script: {fileID: 11500000, guid: 9df78976caa7771429cfe2b9b96e1491, type: 3}
m_Name:
m_EditorClassIdentifier:
MessageLabel: {fileID: 1028782728}
@@ -263,6 +263,7 @@ GameObject:
m_Component:
- component: {fileID: 433476714}
- component: {fileID: 433476715}
+ - component: {fileID: 433476716}
m_Layer: 0
m_Name: MetaMaskLogin
m_TagString: Untagged
@@ -297,11 +298,23 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b547b7e8ac8d2f442bfefe0c9f59ed1d, type: 3}
m_Name:
m_EditorClassIdentifier:
- k__BackingField: SampleMain
gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_
errorPopup: {fileID: 314965761}
rampConfig: {fileID: 11400000, guid: d1f58846e4fc71d4e90f287a86f328f9, type: 2}
loginButton: {fileID: 2048731599}
+--- !u!114 &433476716
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 433476712}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 3d2237df0314604419146b916b88d158, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ sceneToLoad: SampleMain
--- !u!1 &740974330
GameObject:
m_ObjectHideFlags: 0
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin.unity b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - WalletConnect.unity
similarity index 99%
rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin.unity
rename to Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - WalletConnect.unity
index 3f93cb2db..e7c5b063a 100644
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin.unity
+++ b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - WalletConnect.unity
@@ -2641,6 +2641,7 @@ GameObject:
m_Component:
- component: {fileID: 1334079841}
- component: {fileID: 1334079842}
+ - component: {fileID: 1334079843}
m_Layer: 0
m_Name: Logic - Login
m_TagString: Untagged
@@ -2675,7 +2676,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 96894e49d9863ec4db1d93a5e56f19cb, type: 3}
m_Name:
m_EditorClassIdentifier:
- k__BackingField: SampleMain
gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_
errorPopup: {fileID: 1701305868}
rampConfig: {fileID: 11400000, guid: d1f58846e4fc71d4e90f287a86f328f9, type: 2}
@@ -2702,6 +2702,19 @@ MonoBehaviour:
Universal:
VerifyUrl:
walletConnectModal: {fileID: 395689441}
+--- !u!114 &1334079843
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1334079840}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 3d2237df0314604419146b916b88d158, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ sceneToLoad: SampleMain
--- !u!1 &1491563361
GameObject:
m_ObjectHideFlags: 0
@@ -3193,7 +3206,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1701305866}
m_Enabled: 1
m_EditorHideFlags: 0
- m_Script: {fileID: 11500000, guid: c001d0d5433b4215b8abba94194881bd, type: 3}
+ m_Script: {fileID: 11500000, guid: 9df78976caa7771429cfe2b9b96e1491, type: 3}
m_Name:
m_EditorClassIdentifier:
MessageLabel: {fileID: 786896302}
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin.unity.meta b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - WalletConnect.unity.meta
similarity index 100%
rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin.unity.meta
rename to Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin - WalletConnect.unity.meta
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Prefabs/Logout.cs b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Prefabs/Logout.cs
index 88781c9bd..777b0f582 100644
--- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Prefabs/Logout.cs
+++ b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Prefabs/Logout.cs
@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using ChainSafe.Gaming.UnityPackage;
using ChainSafe.Gaming.Wallets;
+using ChainSafe.Gaming.UnityPackage.Common;
using Scenes;
using UnityEngine;
using UnityEngine.SceneManagement;
@@ -19,6 +20,6 @@ public async void OnLogout()
Web3Accessor.Clear();
// Go back to the first scene to log in again
- SceneManager.LoadScene(Login.LoginSceneIndex);
+ await SceneManager.LoadSceneAsync(LoadSceneOnLogin.LoginSceneBuildIndex);
}
}
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs
deleted file mode 100644
index 146dc217b..000000000
--- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/Login.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-using System;
-using System.Collections;
-using System.Threading.Tasks;
-using ChainSafe.Gaming.Evm.Contracts;
-using ChainSafe.Gaming.Evm.JsonRpc;
-using ChainSafe.Gaming.Exchangers.Ramp;
-using ChainSafe.Gaming.MultiCall;
-using ChainSafe.Gaming.UnityPackage;
-using ChainSafe.Gaming.Web3;
-using ChainSafe.Gaming.Web3.Build;
-using ChainSafe.Gaming.Web3.Unity;
-using ChainSafe.GamingSdk.Gelato;
-using Scripts.EVM.Token;
-using UnityEngine;
-using UnityEngine.SceneManagement;
-
-namespace Scenes
-{
- public abstract class Login : MonoBehaviour
- {
- [field:SerializeField] public string SceneToLoad { get; private set; }
-
- public static int LoginSceneIndex { get; private set; } = 0;
-
- [SerializeField] private string gelatoApiKey = "";
-
- [SerializeField] private ErrorPopup errorPopup;
-
- [SerializeField] private RampExchangerConfigSO rampConfig;
-
- private IEnumerator Start()
- {
- yield return Initialize();
- }
-
- protected abstract IEnumerator Initialize();
-
- protected abstract Web3Builder ConfigureWeb3Services(Web3Builder web3Builder);
-
- protected async Task TryLogin()
- {
- Web3 web3;
-
- try
- {
- Web3Builder web3Builder = new Web3Builder(ProjectConfigUtilities.Load())
- .Configure(ConfigureCommonServices);
-
- web3Builder = ConfigureWeb3Services(web3Builder);
-
- web3 = await web3Builder.LaunchAsync();
- }
-
- catch (Exception)
- {
-
- errorPopup.ShowError("Login failed, please try again\n(see console for more details)");
- throw;
- }
-
- Web3Accessor.Set(web3);
-
- //TODO: REMOVE THIS
- if (rampConfig != null)
- {
-
- Web3Accessor.Web3.RampExchanger().OnRampPurchaseCreated += data
- => Debug.Log($"On-Ramp purchase created {data.CryptoAmount} {data.Asset.Name}");
- Web3Accessor.Web3.RampExchanger().OffRampSaleCreated += data
- => Debug.Log($"Off-Ramp sale created {data.Fiat.Amount:C} {data.Fiat.CurrencySymbol}");
- }
-
- LoginSceneIndex = SceneManager.GetActiveScene().buildIndex;
-
- // Attempt scene transition based on the login object sceneToLoad value
- SceneManager.LoadScene(SceneToLoad);
- }
-
- private void ConfigureCommonServices(IWeb3ServiceCollection services)
- {
- services
- .UseUnityEnvironment()
- .UseGelato(gelatoApiKey)
- .UseMultiCall()
- .UseRpcProvider();
-
- if (rampConfig != null)
- services.UseRampExchanger(rampConfig);
- else
- Debug.LogWarning("Ramp config not provided");
-
- /* As many contracts as needed may be registered here.
- * It is better to register all contracts the application
- * will be interacting with at configuration time if they
- * are known in advance. We're just registering shiba
- * here to show how it's done. You can look at the
- * `Scripts/Prefabs/Wallet/RegisteredContract` script
- * to see how it's used later on.
- */
- services.ConfigureRegisteredContracts(contracts =>
- contracts.RegisterContract("CsTestErc20", ABI.Erc20, Contracts.Erc20));
-
- }
- }
-}
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLogin.cs b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLoginProvider.cs
similarity index 80%
rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLogin.cs
rename to Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLoginProvider.cs
index ed96d979f..2cd23b3e4 100644
--- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLogin.cs
+++ b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLoginProvider.cs
@@ -1,4 +1,5 @@
using System.Collections;
+using ChainSafe.Gaming.UnityPackage.Common;
#if UNITY_WEBGL && !UNITY_EDITOR
using ChainSafe.Gaming.MetaMask;
using ChainSafe.Gaming.MetaMask.Unity;
@@ -12,15 +13,15 @@
/// Login using MetaMask.
/// Only works for UnityWebGL build (not in editor).
///
-public class MetaMaskLogin : Login
+public class MetaMaskLoginProvider : LoginProvider, IWeb3BuilderServiceAdapter
{
[SerializeField] private Button loginButton;
- protected override IEnumerator Initialize()
+ protected override void Initialize()
{
- loginButton.onClick.AddListener(LoginClicked);
+ base.Initialize();
- yield return null;
+ loginButton.onClick.AddListener(LoginClicked);
}
private async void LoginClicked()
@@ -28,7 +29,7 @@ private async void LoginClicked()
await TryLogin();
}
- protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder)
+ public Web3Builder ConfigureServices(Web3Builder web3Builder)
{
return web3Builder.Configure(services =>
{
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLogin.cs.meta b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLoginProvider.cs.meta
similarity index 100%
rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLogin.cs.meta
rename to Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/MetaMaskLoginProvider.cs.meta
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/WalletConnectLoginProvider.cs
similarity index 96%
rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs
rename to Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/WalletConnectLoginProvider.cs
index 7dd991dc2..0938fd38c 100644
--- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs
+++ b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/WalletConnectLoginProvider.cs
@@ -5,6 +5,7 @@
using System.Threading.Tasks;
using ChainSafe.Gaming.Unity;
using ChainSafe.Gaming.UnityPackage;
+using ChainSafe.Gaming.UnityPackage.Common;
using ChainSafe.Gaming.WalletConnect;
using ChainSafe.Gaming.WalletConnect.Models;
using ChainSafe.Gaming.Web3.Build;
@@ -27,7 +28,7 @@
///
/// Login using an existing wallet using Wallet Connect.
///
-public class ExistingWalletLogin : Login
+public class WalletConnectLoginProvider : LoginProvider, IWeb3BuilderServiceAdapter
{
[Header("UI")][SerializeField] private TMP_Dropdown supportedWalletsDropdown;
@@ -76,8 +77,10 @@ private void OnDestroy()
}
}
- protected override IEnumerator Initialize()
+ protected override async void Initialize()
{
+ base.Initialize();
+
Assert.IsNotNull(loginButton);
Assert.IsNotNull(rememberMeToggle);
@@ -110,13 +113,11 @@ protected override IEnumerator Initialize()
if (!isRedirectionWalletAgnostic)
{
- yield return InitializeWalletSelection();
+ await InitializeWalletSelection();
}
// try auto login first
- var autoLoginTask = TryAutoLogin();
-
- yield return new WaitUntil(() => autoLoginTask.IsCompleted);
+ await TryAutoLogin();
loginButton.onClick.AddListener(LoginClicked);
}
@@ -126,7 +127,7 @@ private async void LoginClicked()
await TryLogin();
}
- protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder)
+ public Web3Builder ConfigureServices(Web3Builder web3Builder)
{
return web3Builder.Configure(services =>
{
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs.meta b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/WalletConnectLoginProvider.cs.meta
similarity index 100%
rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs.meta
rename to Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/WalletConnectLoginProvider.cs.meta
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs
deleted file mode 100644
index c5b9f9cd6..000000000
--- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/SceneIndexer.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-#if UNITY_EDITOR
-
-using System;
-using System.IO;
-using System.Linq;
-using Scenes;
-using UnityEditor;
-using UnityEditor.PackageManager;
-using UnityEditor.PackageManager.UI;
-using PackageInfo = UnityEditor.PackageManager.PackageInfo;
-
-[InitializeOnLoad]
-public static class SceneIndexer
-{
- private const string ScenesIndexedKey = PackageName + "ScenesIndexed";
-
- private const string PackageName = "io.chainsafe.web3-unity";
-
- static SceneIndexer()
- {
- TryAddEditorBuildSettingsScenes(PackageName, ScenesIndexedKey, new string[]
- {
- "SampleLogin.Unity",
- "SampleMain.Unity"
- });
- }
-
- public static void TryAddEditorBuildSettingsScenes(string packageName, string sessionKey, string[] scenes)
- {
- if (SessionState.GetBool(sessionKey, false))
- {
- return;
- }
-
- PackageInfo package = GetPackage(packageName);
-
- string importPath = GetImportPath(package);
-
- //Clear out scenes that do not exist
- EditorBuildSettings.scenes = EditorBuildSettings.scenes.Where(s => !string.IsNullOrEmpty(s.path)).ToArray();
-
- //scenes already added to build settings
- if (EditorBuildSettings.scenes.Any(s => Path.GetFullPath(s.path).Contains(importPath)))
- {
- SessionState.SetBool(sessionKey, true);
-
- return;
- }
-
- // convert and add importPath to scenes path
- EditorBuildSettingsScene[] editorBuildSettingsScenes = Array.ConvertAll(scenes, s => new EditorBuildSettingsScene(Path.Combine(importPath, s), true));
-
- EditorBuildSettings.scenes = editorBuildSettingsScenes.Concat(EditorBuildSettings.scenes).ToArray();
-
- SessionState.SetBool(sessionKey, true);
- }
-
- private static PackageInfo GetPackage(string name)
- {
- var listRequest = Client.List();
-
- while (!listRequest.IsCompleted)
- {
- //do nothing
- }
-
- PackageInfo[] packages = listRequest.Result.ToArray();
-
- PackageInfo package = packages.FirstOrDefault(p => p.name == name);
-
- if (package == null)
- {
- throw new Exception($"Installed Package {name} not found");
- }
-
- return package;
- }
-
- private static string GetImportPath(PackageInfo package)
- {
- Sample sample = Sample.FindByPackage(package.name, package.version).FirstOrDefault();
-
- string importPath = Path.GetRelativePath(Directory.GetCurrentDirectory(), sample.importPath);
-
- return Path.Combine(importPath, "Scenes");
- }
-}
-
-#endif
\ No newline at end of file
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/ChainlinkLootboxSampleLauncher.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/ChainlinkLootboxSampleLauncher.cs
index a1fe7ff64..1aa12a073 100644
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/ChainlinkLootboxSampleLauncher.cs
+++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/ChainlinkLootboxSampleLauncher.cs
@@ -3,6 +3,7 @@
using ChainSafe.Gaming.Debugging;
using ChainSafe.Gaming.Evm.JsonRpc;
using ChainSafe.Gaming.Lootboxes.Chainlink;
+using ChainSafe.Gaming.UnityPackage;
using ChainSafe.Gaming.Wallets;
using ChainSafe.Gaming.Web3;
using ChainSafe.Gaming.Web3.Build;
@@ -36,8 +37,7 @@ private class Web3Config : ICompleteProjectConfig
private async void Awake()
{
- web3 = await new Web3Builder(new Web3Config())
- .Configure(services =>
+ web3 = Web3Accessor.TryWeb3 ?? await new Web3Builder(new Web3Config()).Configure(services =>
{
services.UseUnityEnvironment();
services.UseRpcProvider();
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs
new file mode 100644
index 000000000..3c21ce5aa
--- /dev/null
+++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs
@@ -0,0 +1,32 @@
+using ChainSafe.Gaming.Lootboxes.Chainlink;
+using ChainSafe.Gaming.UnityPackage.Common;
+using ChainSafe.Gaming.Web3.Build;
+using Microsoft.Extensions.DependencyInjection;
+using UnityEngine;
+
+namespace LootBoxes.Chainlink
+{
+ ///
+ /// Configures Lootboxes services to work with a .
+ ///
+ public class LootboxesServicesAdapter : MonoBehaviour, IWeb3BuilderServiceAdapter
+ {
+ // the default values are setup for sepolia.
+ [SerializeField] private string contractAddress = "0x1993e2dD323B5dcBd8b52dB7d370bC36D280424B";
+
+ [SerializeField] private string contractAbi = "[ { \"inputs\": [], \"name\": \"AcceptingOnlyLINK\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" } ], \"name\": \"AccessDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"AmountPerUnitOverflow\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" } ], \"name\": \"DepositStateCorruption\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"EndOfService\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InsufficientFee\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InsufficientGas\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InsufficientPayment\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"supply\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"requested\", \"type\": \"uint256\" } ], \"name\": \"InsufficientSupply\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InvalidLength\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"int256\", \"name\": \"value\", \"type\": \"int256\" } ], \"name\": \"InvalidLinkPrice\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InvalidLootboxType\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"InvalidRequestAllocation\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"InvalidTokenAmount\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"InventoryStateCorruption\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"oldType\", \"type\": \"uint8\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"newType\", \"type\": \"uint8\" } ], \"name\": \"ModifiedRewardType\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NoTokens\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NothingToClaim\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NothingToRecover\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"OnlyThis\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"PendingOpenRequest\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"RewardWithdrawalDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" } ], \"name\": \"SupplyDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"supply\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"unitsToGet\", \"type\": \"uint256\" } ], \"name\": \"SupplyExceeded\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"TokenDenied\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"currentPrice\", \"type\": \"uint256\" } ], \"name\": \"UnexpectedPrice\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"rewardType\", \"type\": \"uint8\" } ], \"name\": \"UnexpectedRewardType\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"UnitsOverflow\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"Unsupported\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"ViewCallFailed\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"ZeroAmount\", \"type\": \"error\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"ZeroSupply\", \"type\": \"error\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"Allocated\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"newSupply\", \"type\": \"uint256\" } ], \"name\": \"AmountPerUnitSet\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"bool\", \"name\": \"approved\", \"type\": \"bool\" } ], \"name\": \"ApprovalForAll\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"BoxesRecovered\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"caller\", \"type\": \"address\" } ], \"name\": \"EmergencyModeEnabled\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"tokenType\", \"type\": \"uint8\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"amounts\", \"type\": \"uint256[]\" } ], \"name\": \"EmergencyWithdrawal\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"bytes\", \"name\": \"reason\", \"type\": \"bytes\" } ], \"name\": \"OpenRequestFailed\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"randomness\", \"type\": \"uint256\" } ], \"name\": \"OpenRequestFulfilled\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"unitsToGet\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"requestId\", \"type\": \"uint256\" } ], \"name\": \"OpenRequested\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"Paused\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"newPrice\", \"type\": \"uint256\" } ], \"name\": \"PriceUpdated\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"RewardsClaimed\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"previousAdminRole\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"newAdminRole\", \"type\": \"bytes32\" } ], \"name\": \"RoleAdminChanged\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"sender\", \"type\": \"address\" } ], \"name\": \"RoleGranted\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"sender\", \"type\": \"address\" } ], \"name\": \"RoleRevoked\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"buyer\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"payment\", \"type\": \"uint256\" } ], \"name\": \"Sold\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"supplier\", \"type\": \"address\" } ], \"name\": \"SupplierAdded\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"supplier\", \"type\": \"address\" } ], \"name\": \"SupplierRemoved\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"TokenAdded\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"indexed\": false, \"internalType\": \"uint256[]\", \"name\": \"values\", \"type\": \"uint256[]\" } ], \"name\": \"TransferBatch\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"TransferSingle\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"string\", \"name\": \"value\", \"type\": \"string\" }, { \"indexed\": true, \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"URI\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"Unpaused\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"Withdraw\", \"type\": \"event\" }, { \"inputs\": [], \"name\": \"DEFAULT_ADMIN_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"FACTORY\", \"outputs\": [ { \"internalType\": \"contract ILootboxFactory\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"LINK_ETH_FEED\", \"outputs\": [ { \"internalType\": \"contract AggregatorV3Interface\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"MINTER_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"PAUSER_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_requestId\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"_randomness\", \"type\": \"uint256\" } ], \"name\": \"_allocateRewards\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_suppliers\", \"type\": \"address[]\" } ], \"name\": \"addSuppliers\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_tokens\", \"type\": \"address[]\" } ], \"name\": \"addTokens\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"balanceOf\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"accounts\", \"type\": \"address[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" } ], \"name\": \"balanceOfBatch\", \"outputs\": [ { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" } ], \"name\": \"burn\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"values\", \"type\": \"uint256[]\" } ], \"name\": \"burnBatch\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_amount\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"_maxPrice\", \"type\": \"uint256\" } ], \"name\": \"buy\", \"outputs\": [], \"stateMutability\": \"payable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint32\", \"name\": \"_gas\", \"type\": \"uint32\" }, { \"internalType\": \"uint256\", \"name\": \"_gasPriceInWei\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"_units\", \"type\": \"uint256\" } ], \"name\": \"calculateOpenPrice\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"canClaimRewards\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"claimRewards\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_token\", \"type\": \"address\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"_type\", \"type\": \"uint8\" }, { \"internalType\": \"address\", \"name\": \"_to\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"_ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_amounts\", \"type\": \"uint256[]\" } ], \"name\": \"emergencyWithdraw\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getAllowedTokenTypes\", \"outputs\": [ { \"internalType\": \"enum LootboxInterface.RewardType[]\", \"name\": \"result\", \"type\": \"uint8[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getAllowedTokens\", \"outputs\": [ { \"internalType\": \"address[]\", \"name\": \"\", \"type\": \"address[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getAvailableSupply\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getInventory\", \"outputs\": [ { \"components\": [ { \"internalType\": \"address\", \"name\": \"rewardToken\", \"type\": \"address\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"rewardType\", \"type\": \"uint8\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" }, { \"components\": [ { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" } ], \"internalType\": \"struct LootboxInterface.ExtraRewardInfo[]\", \"name\": \"extra\", \"type\": \"tuple[]\" } ], \"internalType\": \"struct LootboxInterface.RewardView[]\", \"name\": \"result\", \"type\": \"tuple[]\" }, { \"components\": [ { \"internalType\": \"address\", \"name\": \"rewardToken\", \"type\": \"address\" }, { \"internalType\": \"enum LootboxInterface.RewardType\", \"name\": \"rewardType\", \"type\": \"uint8\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" }, { \"components\": [ { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"units\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amountPerUnit\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"balance\", \"type\": \"uint256\" } ], \"internalType\": \"struct LootboxInterface.ExtraRewardInfo[]\", \"name\": \"extra\", \"type\": \"tuple[]\" } ], \"internalType\": \"struct LootboxInterface.RewardView[]\", \"name\": \"leftoversResult\", \"type\": \"tuple[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getLink\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getLinkPrice\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getLootboxTypes\", \"outputs\": [ { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"getOpenerRequestDetails\", \"outputs\": [ { \"components\": [ { \"internalType\": \"address\", \"name\": \"opener\", \"type\": \"address\" }, { \"internalType\": \"uint96\", \"name\": \"unitsToGet\", \"type\": \"uint96\" }, { \"internalType\": \"uint256[]\", \"name\": \"lootIds\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"lootAmounts\", \"type\": \"uint256[]\" } ], \"internalType\": \"struct LootboxInterface.Request\", \"name\": \"request\", \"type\": \"tuple\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getPrice\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" } ], \"name\": \"getRoleAdmin\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"uint256\", \"name\": \"index\", \"type\": \"uint256\" } ], \"name\": \"getRoleMember\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" } ], \"name\": \"getRoleMemberCount\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getSuppliers\", \"outputs\": [ { \"internalType\": \"address[]\", \"name\": \"\", \"type\": \"address[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"getVRFV2Wrapper\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"grantRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"hasRole\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" } ], \"name\": \"isApprovedForAll\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"isEmergencyMode\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"mint\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"amounts\", \"type\": \"uint256[]\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"mintBatch\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_tos\", \"type\": \"address[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_lootboxTypes\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_amounts\", \"type\": \"uint256[]\" } ], \"name\": \"mintToMany\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" }, { \"internalType\": \"bytes\", \"name\": \"\", \"type\": \"bytes\" } ], \"name\": \"onERC1155BatchReceived\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"\", \"type\": \"bytes\" } ], \"name\": \"onERC1155Received\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"\", \"type\": \"bytes\" } ], \"name\": \"onERC721Received\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint32\", \"name\": \"_gas\", \"type\": \"uint32\" }, { \"internalType\": \"uint256[]\", \"name\": \"_lootIds\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_lootAmounts\", \"type\": \"uint256[]\" } ], \"name\": \"open\", \"outputs\": [], \"stateMutability\": \"payable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"name\": \"openerRequests\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"pause\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"paused\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_requestId\", \"type\": \"uint256\" }, { \"internalType\": \"uint256[]\", \"name\": \"_randomWords\", \"type\": \"uint256[]\" } ], \"name\": \"rawFulfillRandomWords\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_opener\", \"type\": \"address\" } ], \"name\": \"recoverBoxes\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_suppliers\", \"type\": \"address[]\" } ], \"name\": \"removeSuppliers\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"renounceRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"revokeRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"amounts\", \"type\": \"uint256[]\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"safeBatchTransferFrom\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"to\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"safeTransferFrom\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"_tokens\", \"type\": \"address[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"_amountsPerUnit\", \"type\": \"uint256[]\" } ], \"name\": \"setAmountsPerUnit\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"internalType\": \"bool\", \"name\": \"approved\", \"type\": \"bool\" } ], \"name\": \"setApprovalForAll\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"_newPrice\", \"type\": \"uint256\" } ], \"name\": \"setPrice\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"string\", \"name\": \"_baseURI\", \"type\": \"string\" } ], \"name\": \"setURI\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_from\", \"type\": \"address\" } ], \"name\": \"supplyAllowed\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes4\", \"name\": \"interfaceId\", \"type\": \"bytes4\" } ], \"name\": \"supportsInterface\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_token\", \"type\": \"address\" } ], \"name\": \"tokenAllowed\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unitsMinted\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unitsRequested\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unitsSupply\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"unpause\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"name\": \"uri\", \"outputs\": [ { \"internalType\": \"string\", \"name\": \"\", \"type\": \"string\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"viewCall\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"_token\", \"type\": \"address\" }, { \"internalType\": \"address payable\", \"name\": \"_to\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"_amount\", \"type\": \"uint256\" } ], \"name\": \"withdraw\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" } ]";
+
+ public Web3Builder ConfigureServices(Web3Builder web3Builder)
+ {
+ return web3Builder.Configure(services =>
+ {
+ services.UseChainlinkLootboxService(new LootboxServiceConfig
+ {
+ ContractAddress = contractAddress,
+ ContractAbi = contractAbi
+ });
+ services.AddSingleton();
+ });
+ }
+ }
+}
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs.meta
new file mode 100644
index 000000000..f5a49c735
--- /dev/null
+++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Lootboxes/1.0.0/Chainlink Lootbox Sample/Scripts/LootboxesServicesAdapter.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1601a8846d451cf4fb87a7082da91a7f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scenes/SampleLogin - Web3Auth.unity b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scenes/SampleLogin - Web3Auth.unity
index 23cde91b0..7c013242a 100644
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scenes/SampleLogin - Web3Auth.unity
+++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scenes/SampleLogin - Web3Auth.unity
@@ -476,7 +476,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- - m_Target: {fileID: 337558421}
+ - m_Target: {fileID: 0}
m_TargetAssemblyTypeName: Scenes.ErrorPopup, Assembly-CSharp
m_MethodName: Close
m_Mode: 1
@@ -574,7 +574,7 @@ MonoBehaviour:
m_GameObject: {fileID: 337558419}
m_Enabled: 1
m_EditorHideFlags: 0
- m_Script: {fileID: 11500000, guid: c001d0d5433b4215b8abba94194881bd, type: 3}
+ m_Script: {fileID: 11500000, guid: 9df78976caa7771429cfe2b9b96e1491, type: 3}
m_Name:
m_EditorClassIdentifier:
MessageLabel: {fileID: 804898217}
@@ -1184,7 +1184,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- - m_Target: {fileID: 337558421}
+ - m_Target: {fileID: 0}
m_TargetAssemblyTypeName: Scenes.ErrorPopup, Assembly-CSharp
m_MethodName: Close
m_Mode: 1
@@ -1362,6 +1362,7 @@ GameObject:
m_Component:
- component: {fileID: 1679801099}
- component: {fileID: 1679801100}
+ - component: {fileID: 1679801101}
m_Layer: 0
m_Name: Logic - Login - Web3Auth
m_TagString: Untagged
@@ -1396,10 +1397,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7b6902e441950fa4bb5cefdd2263164a, type: 3}
m_Name:
m_EditorClassIdentifier:
- k__BackingField: SampleRampIntegration
gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_
errorPopup: {fileID: 337558421}
- rampConfig: {fileID: 11400000, guid: d1f58846e4fc71d4e90f287a86f328f9, type: 2}
clientId: BCc0wTmuXureEzgawhUSZOWu4bgWo56sZPrxLiHQCpg5OHcNrfa44esdTS8Dm77VtmaIyjhbthdWfbLhSwf7jtU
redirectUri: torusapp://io.chainsafe.gamingsdk.sdkdemoscene/auth
network: 1
@@ -1416,6 +1415,19 @@ MonoBehaviour:
Provider: 3
- Button: {fileID: 7400892925769233044}
Provider: 4
+--- !u!114 &1679801101
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1679801098}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 3d2237df0314604419146b916b88d158, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ sceneToLoad: SampleMain
--- !u!1 &1799608969
GameObject:
m_ObjectHideFlags: 0
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs
deleted file mode 100644
index 1b7d7489d..000000000
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Utilities/Web3AuthSceneIndexer.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-#if UNITY_EDITOR
-using UnityEditor;
-
-///
-/// Add Web3.Unity Web3Auth package sample scenes to Build Settings Scenes
-///
-[InitializeOnLoad]
-public static class Web3AuthSceneIndexer
-{
- private const string ScenesIndexedKey = PackageName + "ScenesIndexed";
-
- private const string PackageName = "io.chainsafe.web3-unity.web3auth";
-
- static Web3AuthSceneIndexer()
- {
- SceneIndexer.TryAddEditorBuildSettingsScenes(PackageName, ScenesIndexedKey, new string[]
- {
- "SampleLogin - Web3Auth.Unity",
- });
- }
-}
-
-#endif
\ No newline at end of file
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLogin.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs
similarity index 84%
rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLogin.cs
rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs
index ed1a4a8c9..18d6e62a6 100644
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLogin.cs
+++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs
@@ -4,6 +4,7 @@
using System.Threading.Tasks;
using ChainSafe.Gaming.Exchangers.Ramp;
using ChainSafe.Gaming.UnityPackage;
+using ChainSafe.Gaming.UnityPackage.Common;
using ChainSafe.Gaming.Web3;
using ChainSafe.Gaming.Web3.Analytics;
using ChainSafe.Gaming.Web3.Build;
@@ -16,11 +17,11 @@
///
/// Login using Web3Auth.
///
-public class Web3AuthLogin : Login
+public class Web3AuthLoginProvider : LoginProvider, IWeb3BuilderServiceAdapter
{
///
/// Struct used for pairing login buttons to Web3 auth providers.
- /// Used when adding as listeners to the buttons.
+ /// Used when adding as listeners to the buttons.
///
[Serializable]
public struct ProviderAndButtonPair
@@ -35,7 +36,7 @@ public struct ProviderAndButtonPair
[SerializeField] private Network network;
[Header("UI")]
[SerializeField] private List providerAndButtonPairs;
-
+
private bool useProvider;
private Provider selectedProvider;
@@ -47,13 +48,13 @@ public void SetRememberMe(bool rememberMe)
this.rememberMe = rememberMe;
}
- protected override IEnumerator Initialize()
+ protected override async void Initialize()
{
+ base.Initialize();
+
//Always first add listeners.
providerAndButtonPairs.ForEach(p =>
p.Button.onClick.AddListener(delegate { LoginWithWeb3Auth(p.Provider); }));
-
- yield return null;
#if UNITY_WEBGL && !UNITY_EDITOR
Uri uri = new Uri(Application.absoluteURL);
@@ -63,9 +64,7 @@ protected override IEnumerator Initialize()
{
useProvider = false;
- Task loginTask = TryLogin();
-
- yield return new WaitUntil(() => loginTask.IsCompleted);
+ await TryLogin();
}
#else
@@ -73,15 +72,10 @@ protected override IEnumerator Initialize()
{
useProvider = false;
rememberMe = true;
- Task loginTask = TryLogin();
+ await TryLogin();
Debug.Log("Restoring existing Web3Auth session (Remember Me");
- yield return new WaitUntil(() => loginTask.IsCompleted);
}
#endif
-
- // add provider buttons listeners
-
-
}
private async void LoginWithWeb3Auth(Provider provider)
@@ -91,8 +85,7 @@ private async void LoginWithWeb3Auth(Provider provider)
useProvider = true;
}
selectedProvider = provider;
-
-
+
await TryLogin();
LogAnalytics(provider);
}
@@ -111,7 +104,7 @@ private void LogAnalytics(Provider provider)
});
}
- protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder)
+ public Web3Builder ConfigureServices(Web3Builder web3Builder)
{
return web3Builder.Configure(services =>
{
@@ -140,7 +133,7 @@ protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder)
};
}
- services.UseWeb3AuthWallet(web3AuthConfig);
+ services.UseWeb3AuthWallet(web3AuthConfig);
});
}
}
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLogin.cs.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs.meta
similarity index 100%
rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLogin.cs.meta
rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scripts/Web3AuthLoginProvider.cs.meta
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - MetaMask.unity b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - MetaMask.unity
index fcd389c92..fd738cc43 100644
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - MetaMask.unity
+++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - MetaMask.unity
@@ -249,7 +249,7 @@ MonoBehaviour:
m_GameObject: {fileID: 314965759}
m_Enabled: 1
m_EditorHideFlags: 0
- m_Script: {fileID: 11500000, guid: c001d0d5433b4215b8abba94194881bd, type: 3}
+ m_Script: {fileID: 11500000, guid: 9df78976caa7771429cfe2b9b96e1491, type: 3}
m_Name:
m_EditorClassIdentifier:
MessageLabel: {fileID: 1028782728}
@@ -263,6 +263,7 @@ GameObject:
m_Component:
- component: {fileID: 433476714}
- component: {fileID: 433476715}
+ - component: {fileID: 433476716}
m_Layer: 0
m_Name: MetaMaskLogin
m_TagString: Untagged
@@ -297,11 +298,23 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b547b7e8ac8d2f442bfefe0c9f59ed1d, type: 3}
m_Name:
m_EditorClassIdentifier:
- k__BackingField: SampleMain
gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_
errorPopup: {fileID: 314965761}
rampConfig: {fileID: 11400000, guid: d1f58846e4fc71d4e90f287a86f328f9, type: 2}
loginButton: {fileID: 2048731599}
+--- !u!114 &433476716
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 433476712}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 3d2237df0314604419146b916b88d158, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ sceneToLoad: SampleMain
--- !u!1 &740974330
GameObject:
m_ObjectHideFlags: 0
diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin.unity b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - WalletConnect.unity
similarity index 99%
rename from Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin.unity
rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - WalletConnect.unity
index 3f93cb2db..e7c5b063a 100644
--- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes/SampleLogin.unity
+++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - WalletConnect.unity
@@ -2641,6 +2641,7 @@ GameObject:
m_Component:
- component: {fileID: 1334079841}
- component: {fileID: 1334079842}
+ - component: {fileID: 1334079843}
m_Layer: 0
m_Name: Logic - Login
m_TagString: Untagged
@@ -2675,7 +2676,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 96894e49d9863ec4db1d93a5e56f19cb, type: 3}
m_Name:
m_EditorClassIdentifier:
- k__BackingField: SampleMain
gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_
errorPopup: {fileID: 1701305868}
rampConfig: {fileID: 11400000, guid: d1f58846e4fc71d4e90f287a86f328f9, type: 2}
@@ -2702,6 +2702,19 @@ MonoBehaviour:
Universal:
VerifyUrl:
walletConnectModal: {fileID: 395689441}
+--- !u!114 &1334079843
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1334079840}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 3d2237df0314604419146b916b88d158, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ sceneToLoad: SampleMain
--- !u!1 &1491563361
GameObject:
m_ObjectHideFlags: 0
@@ -3193,7 +3206,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1701305866}
m_Enabled: 1
m_EditorHideFlags: 0
- m_Script: {fileID: 11500000, guid: c001d0d5433b4215b8abba94194881bd, type: 3}
+ m_Script: {fileID: 11500000, guid: 9df78976caa7771429cfe2b9b96e1491, type: 3}
m_Name:
m_EditorClassIdentifier:
MessageLabel: {fileID: 786896302}
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin.unity.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - WalletConnect.unity.meta
similarity index 100%
rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin.unity.meta
rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin - WalletConnect.unity.meta
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Prefabs/Logout.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Prefabs/Logout.cs
index 88781c9bd..777b0f582 100644
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Prefabs/Logout.cs
+++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Prefabs/Logout.cs
@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using ChainSafe.Gaming.UnityPackage;
using ChainSafe.Gaming.Wallets;
+using ChainSafe.Gaming.UnityPackage.Common;
using Scenes;
using UnityEngine;
using UnityEngine.SceneManagement;
@@ -19,6 +20,6 @@ public async void OnLogout()
Web3Accessor.Clear();
// Go back to the first scene to log in again
- SceneManager.LoadScene(Login.LoginSceneIndex);
+ await SceneManager.LoadSceneAsync(LoadSceneOnLogin.LoginSceneBuildIndex);
}
}
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ErrorPopup.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ErrorPopup.cs
deleted file mode 100644
index f8c26431a..000000000
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ErrorPopup.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using UnityEngine;
-using UnityEngine.UI;
-
-namespace Scenes
-{
- public class ErrorPopup : MonoBehaviour
- {
- public Text MessageLabel;
-
- public void ShowError(string message)
- {
- gameObject.SetActive(true);
- MessageLabel.text = message;
- }
-
- public void Close()
- {
- gameObject.SetActive(false);
- }
- }
-}
\ No newline at end of file
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ErrorPopup.cs.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ErrorPopup.cs.meta
deleted file mode 100644
index b0a77395c..000000000
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ErrorPopup.cs.meta
+++ /dev/null
@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: c001d0d5433b4215b8abba94194881bd
-timeCreated: 1691581208
\ No newline at end of file
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/Login.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/Login.cs
deleted file mode 100644
index 146dc217b..000000000
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/Login.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-using System;
-using System.Collections;
-using System.Threading.Tasks;
-using ChainSafe.Gaming.Evm.Contracts;
-using ChainSafe.Gaming.Evm.JsonRpc;
-using ChainSafe.Gaming.Exchangers.Ramp;
-using ChainSafe.Gaming.MultiCall;
-using ChainSafe.Gaming.UnityPackage;
-using ChainSafe.Gaming.Web3;
-using ChainSafe.Gaming.Web3.Build;
-using ChainSafe.Gaming.Web3.Unity;
-using ChainSafe.GamingSdk.Gelato;
-using Scripts.EVM.Token;
-using UnityEngine;
-using UnityEngine.SceneManagement;
-
-namespace Scenes
-{
- public abstract class Login : MonoBehaviour
- {
- [field:SerializeField] public string SceneToLoad { get; private set; }
-
- public static int LoginSceneIndex { get; private set; } = 0;
-
- [SerializeField] private string gelatoApiKey = "";
-
- [SerializeField] private ErrorPopup errorPopup;
-
- [SerializeField] private RampExchangerConfigSO rampConfig;
-
- private IEnumerator Start()
- {
- yield return Initialize();
- }
-
- protected abstract IEnumerator Initialize();
-
- protected abstract Web3Builder ConfigureWeb3Services(Web3Builder web3Builder);
-
- protected async Task TryLogin()
- {
- Web3 web3;
-
- try
- {
- Web3Builder web3Builder = new Web3Builder(ProjectConfigUtilities.Load())
- .Configure(ConfigureCommonServices);
-
- web3Builder = ConfigureWeb3Services(web3Builder);
-
- web3 = await web3Builder.LaunchAsync();
- }
-
- catch (Exception)
- {
-
- errorPopup.ShowError("Login failed, please try again\n(see console for more details)");
- throw;
- }
-
- Web3Accessor.Set(web3);
-
- //TODO: REMOVE THIS
- if (rampConfig != null)
- {
-
- Web3Accessor.Web3.RampExchanger().OnRampPurchaseCreated += data
- => Debug.Log($"On-Ramp purchase created {data.CryptoAmount} {data.Asset.Name}");
- Web3Accessor.Web3.RampExchanger().OffRampSaleCreated += data
- => Debug.Log($"Off-Ramp sale created {data.Fiat.Amount:C} {data.Fiat.CurrencySymbol}");
- }
-
- LoginSceneIndex = SceneManager.GetActiveScene().buildIndex;
-
- // Attempt scene transition based on the login object sceneToLoad value
- SceneManager.LoadScene(SceneToLoad);
- }
-
- private void ConfigureCommonServices(IWeb3ServiceCollection services)
- {
- services
- .UseUnityEnvironment()
- .UseGelato(gelatoApiKey)
- .UseMultiCall()
- .UseRpcProvider();
-
- if (rampConfig != null)
- services.UseRampExchanger(rampConfig);
- else
- Debug.LogWarning("Ramp config not provided");
-
- /* As many contracts as needed may be registered here.
- * It is better to register all contracts the application
- * will be interacting with at configuration time if they
- * are known in advance. We're just registering shiba
- * here to show how it's done. You can look at the
- * `Scripts/Prefabs/Wallet/RegisteredContract` script
- * to see how it's used later on.
- */
- services.ConfigureRegisteredContracts(contracts =>
- contracts.RegisterContract("CsTestErc20", ABI.Erc20, Contracts.Erc20));
-
- }
- }
-}
\ No newline at end of file
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/Login.cs.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/Login.cs.meta
deleted file mode 100644
index 61485ea02..000000000
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/Login.cs.meta
+++ /dev/null
@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: 9473851428864b439d6561c87053272a
-timeCreated: 1691581402
\ No newline at end of file
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLogin.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs
similarity index 80%
rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLogin.cs
rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs
index ed96d979f..2cd23b3e4 100644
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLogin.cs
+++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs
@@ -1,4 +1,5 @@
using System.Collections;
+using ChainSafe.Gaming.UnityPackage.Common;
#if UNITY_WEBGL && !UNITY_EDITOR
using ChainSafe.Gaming.MetaMask;
using ChainSafe.Gaming.MetaMask.Unity;
@@ -12,15 +13,15 @@
/// Login using MetaMask.
/// Only works for UnityWebGL build (not in editor).
///
-public class MetaMaskLogin : Login
+public class MetaMaskLoginProvider : LoginProvider, IWeb3BuilderServiceAdapter
{
[SerializeField] private Button loginButton;
- protected override IEnumerator Initialize()
+ protected override void Initialize()
{
- loginButton.onClick.AddListener(LoginClicked);
+ base.Initialize();
- yield return null;
+ loginButton.onClick.AddListener(LoginClicked);
}
private async void LoginClicked()
@@ -28,7 +29,7 @@ private async void LoginClicked()
await TryLogin();
}
- protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder)
+ public Web3Builder ConfigureServices(Web3Builder web3Builder)
{
return web3Builder.Configure(services =>
{
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLogin.cs.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs.meta
similarity index 100%
rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLogin.cs.meta
rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/MetaMaskLoginProvider.cs.meta
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs
similarity index 96%
rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs
rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs
index 7dd991dc2..0938fd38c 100644
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs
+++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs
@@ -5,6 +5,7 @@
using System.Threading.Tasks;
using ChainSafe.Gaming.Unity;
using ChainSafe.Gaming.UnityPackage;
+using ChainSafe.Gaming.UnityPackage.Common;
using ChainSafe.Gaming.WalletConnect;
using ChainSafe.Gaming.WalletConnect.Models;
using ChainSafe.Gaming.Web3.Build;
@@ -27,7 +28,7 @@
///
/// Login using an existing wallet using Wallet Connect.
///
-public class ExistingWalletLogin : Login
+public class WalletConnectLoginProvider : LoginProvider, IWeb3BuilderServiceAdapter
{
[Header("UI")][SerializeField] private TMP_Dropdown supportedWalletsDropdown;
@@ -76,8 +77,10 @@ private void OnDestroy()
}
}
- protected override IEnumerator Initialize()
+ protected override async void Initialize()
{
+ base.Initialize();
+
Assert.IsNotNull(loginButton);
Assert.IsNotNull(rememberMeToggle);
@@ -110,13 +113,11 @@ protected override IEnumerator Initialize()
if (!isRedirectionWalletAgnostic)
{
- yield return InitializeWalletSelection();
+ await InitializeWalletSelection();
}
// try auto login first
- var autoLoginTask = TryAutoLogin();
-
- yield return new WaitUntil(() => autoLoginTask.IsCompleted);
+ await TryAutoLogin();
loginButton.onClick.AddListener(LoginClicked);
}
@@ -126,7 +127,7 @@ private async void LoginClicked()
await TryLogin();
}
- protected override Web3Builder ConfigureWeb3Services(Web3Builder web3Builder)
+ public Web3Builder ConfigureServices(Web3Builder web3Builder)
{
return web3Builder.Configure(services =>
{
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs.meta
similarity index 100%
rename from src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs.meta
rename to src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/WalletConnectLoginProvider.cs.meta
diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs
deleted file mode 100644
index c5b9f9cd6..000000000
--- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/SceneIndexer.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-#if UNITY_EDITOR
-
-using System;
-using System.IO;
-using System.Linq;
-using Scenes;
-using UnityEditor;
-using UnityEditor.PackageManager;
-using UnityEditor.PackageManager.UI;
-using PackageInfo = UnityEditor.PackageManager.PackageInfo;
-
-[InitializeOnLoad]
-public static class SceneIndexer
-{
- private const string ScenesIndexedKey = PackageName + "ScenesIndexed";
-
- private const string PackageName = "io.chainsafe.web3-unity";
-
- static SceneIndexer()
- {
- TryAddEditorBuildSettingsScenes(PackageName, ScenesIndexedKey, new string[]
- {
- "SampleLogin.Unity",
- "SampleMain.Unity"
- });
- }
-
- public static void TryAddEditorBuildSettingsScenes(string packageName, string sessionKey, string[] scenes)
- {
- if (SessionState.GetBool(sessionKey, false))
- {
- return;
- }
-
- PackageInfo package = GetPackage(packageName);
-
- string importPath = GetImportPath(package);
-
- //Clear out scenes that do not exist
- EditorBuildSettings.scenes = EditorBuildSettings.scenes.Where(s => !string.IsNullOrEmpty(s.path)).ToArray();
-
- //scenes already added to build settings
- if (EditorBuildSettings.scenes.Any(s => Path.GetFullPath(s.path).Contains(importPath)))
- {
- SessionState.SetBool(sessionKey, true);
-
- return;
- }
-
- // convert and add importPath to scenes path
- EditorBuildSettingsScene[] editorBuildSettingsScenes = Array.ConvertAll(scenes, s => new EditorBuildSettingsScene(Path.Combine(importPath, s), true));
-
- EditorBuildSettings.scenes = editorBuildSettingsScenes.Concat(EditorBuildSettings.scenes).ToArray();
-
- SessionState.SetBool(sessionKey, true);
- }
-
- private static PackageInfo GetPackage(string name)
- {
- var listRequest = Client.List();
-
- while (!listRequest.IsCompleted)
- {
- //do nothing
- }
-
- PackageInfo[] packages = listRequest.Result.ToArray();
-
- PackageInfo package = packages.FirstOrDefault(p => p.name == name);
-
- if (package == null)
- {
- throw new Exception($"Installed Package {name} not found");
- }
-
- return package;
- }
-
- private static string GetImportPath(PackageInfo package)
- {
- Sample sample = Sample.FindByPackage(package.name, package.version).FirstOrDefault();
-
- string importPath = Path.GetRelativePath(Directory.GetCurrentDirectory(), sample.importPath);
-
- return Path.Combine(importPath, "Scenes");
- }
-}
-
-#endif
\ No newline at end of file
diff --git a/src/UnitySampleProject/ProjectSettings/EditorBuildSettings.asset b/src/UnitySampleProject/ProjectSettings/EditorBuildSettings.asset
index f0f5080d0..2e8c5b781 100644
--- a/src/UnitySampleProject/ProjectSettings/EditorBuildSettings.asset
+++ b/src/UnitySampleProject/ProjectSettings/EditorBuildSettings.asset
@@ -13,7 +13,8 @@ EditorBuildSettings:
path: Assets/Samples/web3.unity SDK Ramp/1.0.0/Web3.Unity Ramp Samples/SampleRampIntegration.unity
guid: 9583b7671e7df46028765b84323c9bf7
- enabled: 1
- path: Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin.unity
+ path: Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scenes/SampleLogin
+ - WalletConnect.unity
guid: 1c1af5c5662d105498b2412267dde0df
- enabled: 1
path: Assets/Samples/web3.unity SDK Web3Auth/2.5.1/Web3.Unity Web3Auth Samples/Scenes/SampleLogin