thirdweb-dev / unity-sdk

Best in class Web3 Unity SDK, powered by thirdweb.
https://portal.thirdweb.com/unity
Apache License 2.0
126 stars 70 forks source link

Decouple singleton // Instance based classes #193

Closed 0xFirekeeper closed 4 months ago

0xFirekeeper commented 4 months ago

Moving towards removing ThirdwebManager dependency for SDKs that want to wrap thirdweb. Also will make it easier to port .NET SDK into Unity SDK later.

Removes old Authenticate and uses thirdweb auth backend based one only.

Removes Nethereum.SIWE, Nethereum.SIWE.Core, Nethereum.GnosisSafe

External and Common APIs affected:

Most internal APIs changed, ThirdwebManager Instances all removed except for WalletConnect ScriptableObject Load. Some utils take in an extra parameter now, some uncommon utils removed.

Adds a couple basic tests for raw sdk initialization, will need to move some of the defaults logic out of ThirdwebManager to make it more user-friendly.

This PR also improves passing down rpc headers when instantiating a ThirdwebClient for readonly purposes, will speed up reads when available. Adds Utils to get headers and get web3.


PR-Codex overview

The focus of this PR is restructuring classes and improving wallet functionalities.

Detailed summary

The following files were skipped due to too many changes: Assets/Tests/StorageTests.cs, Assets/Thirdweb/Examples/Scripts/Prefabs/Prefab_BuyWithCrypto.cs, Assets/Thirdweb/Core/Scripts/Pay/ThirdwebPay.BuyWithCrypto.cs, Assets/Thirdweb/Core/Scripts/Pay/ThirdwebPay.GetBuyWithFiatStatus.cs, Assets/Thirdweb/Core/Scripts/Pay/ThirdwebPay.GetBuyWithFiatCurrencies.cs, Assets/Thirdweb/Core/Scripts/Pay/ThirdwebPay.GetBuyWithFiatQuote.cs, Assets/Thirdweb/Core/Scripts/Pay/ThirdwebPay.GetBuyWithCryptoStatus.cs, Assets/Thirdweb/Core/Scripts/Pay/ThirdwebPay.GetBuyHistory.cs, Assets/Thirdweb/Core/Scripts/Pay/ThirdwebPay.GetBuyWithCryptoQuote.cs, Assets/Thirdweb/Core/Scripts/WalletsUI/WalletConnectUI.cs, Assets/Thirdweb/Examples/Scripts/Prefabs/Prefab_BuyWithFiat.cs, Assets/Thirdweb/Core/Scripts/EIP712.cs, Assets/Thirdweb/Examples/Scripts/Prefabs/Prefab_Miscellaneous.cs, Assets/Thirdweb/Core/Scripts/ThirdwebSession.cs, Assets/Tests/WalletTests.cs, Assets/Thirdweb/Core/Scripts/Blocks.cs, Assets/Thirdweb/Core/Scripts/ThirdwebSDK.cs, Assets/Thirdweb/Core/Scripts/TransactionManager.cs, Assets/Tests/ThirdwebSDKTests.cs, Assets/Thirdweb/Core/Scripts/Storage/Storage.cs, Assets/Thirdweb/Core/Scripts/Pack.cs, Assets/Thirdweb/Core/Scripts/AccountAbstraction/Core/BundlerClient.cs, Assets/Thirdweb/Core/Scripts/Utils.cs, Assets/Thirdweb/Core/Scripts/Contract.cs, Assets/Thirdweb/Core/Scripts/Transaction.cs, Assets/Thirdweb/Core/Scripts/ERC20.cs, Assets/Thirdweb/Core/Scripts/ERC721.cs, Assets/Thirdweb/Core/Scripts/AccountAbstraction/Core/SmartWallet.cs, Assets/Thirdweb/Core/Scripts/Marketplace.cs, Assets/Thirdweb/Core/Scripts/ERC1155.cs, Assets/Thirdweb/Core/Scripts/Wallet.cs

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

github-actions[bot] commented 4 months ago

Test Results for iOS

  1 files  ±0   16 suites  +1   8m 19s :stopwatch: +19s 102 tests +6  102 :white_check_mark: +6  0 :zzz: ±0  0 :x: ±0  106 runs  +6  106 :white_check_mark: +6  0 :zzz: ±0  0 :x: ±0 

Results for commit 3d3fd7ac. ± Comparison against base commit 7f62dbf7.

This pull request removes 2 and adds 8 tests. Note that renamed tests count towards both. ``` Authenticate_WithLocalWallet_Success Verify_WithLocalWallet_Success ``` ``` ContractRead_Success ContractWrite_Success CustomContractRead_Success CustomContractWrite_Success IPFSDownload_Success IPFSUpload_Success Initialization_Success WalletSignMessage_Success ```

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 4 months ago

Test Results for Android

  1 files  ±0   16 suites  +1   8m 9s :stopwatch: +7s 102 tests +6  102 :white_check_mark: +6  0 :zzz: ±0  0 :x: ±0  106 runs  +6  106 :white_check_mark: +6  0 :zzz: ±0  0 :x: ±0 

Results for commit 3d3fd7ac. ± Comparison against base commit 7f62dbf7.

This pull request removes 2 and adds 8 tests. Note that renamed tests count towards both. ``` Authenticate_WithLocalWallet_Success Verify_WithLocalWallet_Success ``` ``` ContractRead_Success ContractWrite_Success CustomContractRead_Success CustomContractWrite_Success IPFSDownload_Success IPFSUpload_Success Initialization_Success WalletSignMessage_Success ```

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 4 months ago

Test Results for WebGL

  1 files  ±0   16 suites  +1   8m 15s :stopwatch: +18s 102 tests +6  102 :white_check_mark: +6  0 :zzz: ±0  0 :x: ±0  106 runs  +6  106 :white_check_mark: +6  0 :zzz: ±0  0 :x: ±0 

Results for commit 3d3fd7ac. ± Comparison against base commit 7f62dbf7.

This pull request removes 2 and adds 8 tests. Note that renamed tests count towards both. ``` Authenticate_WithLocalWallet_Success Verify_WithLocalWallet_Success ``` ``` ContractRead_Success ContractWrite_Success CustomContractRead_Success CustomContractWrite_Success IPFSDownload_Success IPFSUpload_Success Initialization_Success WalletSignMessage_Success ```

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 4 months ago

Test Results for StandaloneLinux64

  1 files  ±0   16 suites  +1   7m 57s :stopwatch: -12s 102 tests +6  102 :white_check_mark: +6  0 :zzz: ±0  0 :x: ±0  106 runs  +6  106 :white_check_mark: +6  0 :zzz: ±0  0 :x: ±0 

Results for commit 3d3fd7ac. ± Comparison against base commit 7f62dbf7.

This pull request removes 2 and adds 8 tests. Note that renamed tests count towards both. ``` Authenticate_WithLocalWallet_Success Verify_WithLocalWallet_Success ``` ``` ContractRead_Success ContractWrite_Success CustomContractRead_Success CustomContractWrite_Success IPFSDownload_Success IPFSUpload_Success Initialization_Success WalletSignMessage_Success ```

:recycle: This comment has been updated with latest results.

0xFirekeeper commented 4 months ago

/codex do you even know what this pr is about

pr-codex[bot] commented 4 months ago

do you even know what this pr is about

@0xFirekeeper This PR involves several changes related to the Thirdweb project. Here are some highlights:

  1. Namespace and Class Changes:

    • Moved ThirdwebPay class to the Thirdweb.Pay namespace.
    • Added a constructor to ThirdwebPay that takes a ThirdwebSDK instance.
  2. Code Refactoring:

    • Updated the rpc value based on conditions in ThirdwebManager.cs.
    • Made changes to the Prefab_SmartWallet.cs file, adding a reference to ThirdwebManager.
    • Updated UserOpUtils.cs.meta and ThirdwebPay.cs.meta files with new guid values.
  3. Functionality Updates:

    • Updated the ThirdwebManagerTests.cs file to check certain conditions.
    • Made changes to the Events class constructor to accept a ThirdwebSDK instance.
    • Updated TransactionReadTests.cs to include the chain ID from the ThirdwebManager SDK instance.
    • Updated ThirdwebInAppWallet.cs and ThirdwebMetamask.cs to include an additional field (_clientId and _appName respectively) in their constructors.
    • Modified the ThirdwebPay.BuyWithFiat method to use ThirdwebManager instance by default.
  4. Wallet and Connection Updates:

    • Updated the ThirdwebSmartWallet.cs file to use the ThirdwebSDK instance instead of SmartWalletConfig.
    • Updated ThirdwebWalletConnect.cs to include supported chains and wallet IDs.
    • Updated the InAppWalletUI.cs file to include a clientId parameter in the Connect method.
  5. Miscellaneous Changes:

    • Made changes to the Prefab_Miscellaneous.prefab file, updating button names.
    • Updated the StorageTests.cs file to include IPFS gateway-related changes.

These changes aim to improve functionality, structure, and maintainability within the Thirdweb project.