-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed AccountInfo to return proper values.
- Loading branch information
Showing
4 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Solnet.Rpc.Models | ||
{ | ||
public class TokenAccountInfo | ||
{ | ||
public TokenBalance TokenAmount { get; set; } | ||
|
||
public string? Delegate { get; set; } | ||
|
||
public ulong DelegatedAmount { get; set; } | ||
|
||
public string State { get; set; } | ||
|
||
public bool IsNative { get; set; } | ||
|
||
public string Mint { get; set; } | ||
|
||
public string Owner { get; set; } | ||
} | ||
|
||
public class ParsedTokenAccountData | ||
{ | ||
public string Type { get; set; } | ||
|
||
public TokenAccountInfo Info { get; set; } | ||
} | ||
|
||
public class TokenAccountData | ||
{ | ||
public string Program { get; set; } | ||
|
||
public ParsedTokenAccountData Parsed { get; set; } | ||
} | ||
|
||
public class LargeAccount : TokenBalance | ||
{ | ||
public string Address { get; set; } | ||
} | ||
|
||
public class TokenBalance | ||
{ | ||
public string Amount { get; set; } | ||
|
||
public int Decimals { get; set; } | ||
|
||
public decimal? UiAmount { get; set; } | ||
|
||
public string UiAmountString { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Solnet.Rpc.Models | ||
{ | ||
public class AccountDataJsonConverter : JsonConverter<object> | ||
{ | ||
public override object Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
if(reader.TokenType == JsonTokenType.StartArray) | ||
{ | ||
return JsonSerializer.Deserialize<List<string>>(ref reader, options); | ||
} | ||
else if (reader.TokenType == JsonTokenType.StartObject) | ||
{ | ||
return JsonSerializer.Deserialize<TokenAccountData>(ref reader, options); | ||
} | ||
return null; | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, object value, JsonSerializerOptions options) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters