-
Notifications
You must be signed in to change notification settings - Fork 124
Fix NullReferenceException in Web3.BlockHash() and AwaitWsRpcConnection() #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -312,11 +312,13 @@ public void Logout() | |||||||||||||
| /// <param name="maxSeconds">A given blockhash can only be used by transactions for about 60 to 90 seconds | ||||||||||||||
| /// https://docs.solana.com/developing/transaction_confirmation#how-does-transaction-expiration-work</param> | ||||||||||||||
| /// <returns></returns> | ||||||||||||||
| public static Task<string> BlockHash( | ||||||||||||||
| public static Task<string?> BlockHash( | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check for nullable enable in csproj and Directory.Build.props
rg -n "Nullable" --include="*.csproj" --include="*.props" --include="Directory.Build.*" -i
# Check for file-level nullable enable directives in C# files
rg -n "#nullable enable" --type=cs
# Also check the actual BlockHash method and its usages
echo "=== BlockHash method definition ==="
rg -n "BlockHash" --type=cs -A 2 -B 2
# Check if there are any callers of BlockHash
echo "=== BlockHash usages/callers ==="
rg -n "BlockHash\(" --type=csRepository: magicblock-labs/Solana.Unity-SDK Length of output: 21917 🏁 Script executed: #!/bin/bash
# Find and inspect .csproj files for Nullable settings
echo "=== Finding .csproj files ==="
find . -name "*.csproj" -type f | head -5
# Check the main csproj for Nullable setting
echo -e "\n=== Checking for Nullable in csproj files ==="
find . -name "*.csproj" -exec grep -l "Nullable" {} \;
# Check Web3.cs for file-level nullable directives and full method signature
echo -e "\n=== Web3.cs nullable directives and BlockHash method ==="
head -20 Runtime/codebase/Web3.cs
tail -n +310 Runtime/codebase/Web3.cs | head -20
# Check WalletBase.cs GetBlockHash implementation fully
echo -e "\n=== WalletBase GetBlockHash implementation ==="
sed -n '287,315p' Runtime/codebase/WalletBase.csRepository: magicblock-labs/Solana.Unity-SDK Length of output: 3002 API change is breaking for external SDK consumers, but semantically necessary. Changing 🤖 Prompt for AI Agents |
||||||||||||||
| Commitment commitment = Commitment.Confirmed, | ||||||||||||||
| bool useCache = true, | ||||||||||||||
| int maxSeconds = 0) => | ||||||||||||||
| Instance != null ? Instance.WalletBase.GetBlockHash(commitment, useCache, maxSeconds) : null; | ||||||||||||||
| Instance != null | ||||||||||||||
| ? Instance.WalletBase.GetBlockHash(commitment, useCache, maxSeconds) | ||||||||||||||
| : Task.FromResult<string?>(null); | ||||||||||||||
|
Comment on lines
+319
to
+321
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The guard on line 319 only checks 🐛 Proposed fix- Instance != null
- ? Instance.WalletBase.GetBlockHash(commitment, useCache, maxSeconds)
- : Task.FromResult<string?>(null);
+ Instance != null && Instance.WalletBase != null
+ ? Instance.WalletBase.GetBlockHash(commitment, useCache, maxSeconds)
+ : Task.FromResult<string?>(null);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.