-
Notifications
You must be signed in to change notification settings - Fork 124
feat: add GetCapabilities MWA 2.0 method #277
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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| using System.Collections.Generic; | ||
| using Newtonsoft.Json; | ||
| using UnityEngine.Scripting; | ||
|
|
||
| // ReSharper disable once CheckNamespace | ||
|
|
||
| [Preserve] | ||
| public class CapabilitiesResult | ||
| { | ||
| [JsonProperty("max_transactions_per_request", NullValueHandling = NullValueHandling.Ignore)] | ||
| [RequiredMember] | ||
| public int? MaxTransactionsPerRequest { get; set; } | ||
|
|
||
| [JsonProperty("max_messages_per_request", NullValueHandling = NullValueHandling.Ignore)] | ||
| [RequiredMember] | ||
| public int? MaxMessagesPerRequest { get; set; } | ||
|
|
||
| [JsonProperty("supported_transaction_versions")] | ||
| [RequiredMember] | ||
| public List<string> SupportedTransactionVersions { get; set; } | ||
|
|
||
| [JsonProperty("features", NullValueHandling = NullValueHandling.Ignore)] | ||
| [RequiredMember] | ||
| public List<string> Features { get; set; } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -186,6 +186,27 @@ public override async Task<byte[]> SignMessage(byte[] message) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return signedMessages.SignedPayloadsBytes[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public async Task<CapabilitiesResult> GetCapabilities() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CapabilitiesResult capabilities = null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var localAssociationScenario = new LocalAssociationScenario(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var result = await localAssociationScenario.StartAndExecute( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| new List<Action<IAdapterOperations>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async client => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| capabilities = await client.GetCapabilities(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!result.WasSuccessful) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Debug.LogError(result.Error.Message); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new Exception(result.Error.Message); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return capabilities; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+191
to
+208
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. Guard against null capabilities payload before returning. On Line 207, 🛡️ Proposed fix if (!result.WasSuccessful)
{
Debug.LogError(result.Error.Message);
throw new Exception(result.Error.Message);
}
+ if (capabilities == null)
+ {
+ throw new Exception("get_capabilities returned an empty result.");
+ }
return capabilities;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| protected override Task<Account> _CreateAccount(string mnemonic = null, string password = null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new NotImplementedException("Can't create a new account in phantom wallet"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize collection properties to avoid null-driven crashes.
On Line 20 and Line 24, both lists can deserialize as
null, which makes downstream iteration fragile. Prefer non-null defaults.💡 Proposed fix
[JsonProperty("supported_transaction_versions")] [RequiredMember] - public List<string> SupportedTransactionVersions { get; set; } + public List<string> SupportedTransactionVersions { get; set; } = new(); [JsonProperty("features", NullValueHandling = NullValueHandling.Ignore)] [RequiredMember] - public List<string> Features { get; set; } + public List<string> Features { get; set; } = new();📝 Committable suggestion
🤖 Prompt for AI Agents