-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
Removing NEO issue
- Loading branch information
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
|
||
namespace Poltergeist | ||
{ | ||
public struct Account | ||
{ | ||
public string name; | ||
public PlatformKind platforms; | ||
public string phaAddress; | ||
public string neoAddress; | ||
public string ethAddress; | ||
public string WIF; | ||
public bool passwordProtected; | ||
public int passwordIterations; | ||
public string salt; | ||
public string iv; | ||
public string password; // Not used after account upgrade to version 2. | ||
public string misc; | ||
|
||
public override string ToString() | ||
{ | ||
return $"{name.ToUpper()} [{platforms}]"; | ||
} | ||
|
||
public string GetWif(string passwordHash) | ||
{ | ||
return String.IsNullOrEmpty(passwordHash) ? WIF : AccountManager.DecryptString(WIF, passwordHash, iv); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Poltergeist | ||
{ | ||
public enum AccountFlags | ||
{ | ||
None = 0x0, | ||
Master = 0x1, | ||
Validator = 0x2 | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.Collections.Generic; | ||
using Phantasma.SDK; | ||
|
||
namespace Poltergeist | ||
{ | ||
public static class AccountFlagsExtensions | ||
{ | ||
public static List<PlatformKind> Split(this PlatformKind kind) | ||
{ | ||
var list = new List<PlatformKind>(); | ||
foreach (var platform in AccountManager.AvailablePlatforms) | ||
{ | ||
if (kind.HasFlag(platform)) | ||
{ | ||
list.Add(platform); | ||
} | ||
} | ||
return list; | ||
} | ||
|
||
public static PlatformKind GetTransferTargets(this PlatformKind kind, Token token) | ||
{ | ||
if (!token.IsSwappable()) | ||
{ | ||
return kind; | ||
} | ||
|
||
PlatformKind targets; | ||
|
||
switch (kind) | ||
{ | ||
case PlatformKind.Phantasma: | ||
targets = PlatformKind.Phantasma; | ||
targets |= Tokens.HasSwappableToken(token.symbol, PlatformKind.Neo) ? PlatformKind.Neo : PlatformKind.None; | ||
targets |= Tokens.HasSwappableToken(token.symbol, PlatformKind.Ethereum) ? PlatformKind.Ethereum : PlatformKind.None; | ||
targets |= Tokens.HasSwappableToken(token.symbol, PlatformKind.BSC) ? PlatformKind.BSC : PlatformKind.None; | ||
return targets; | ||
|
||
case PlatformKind.Neo: | ||
targets = PlatformKind.Neo; | ||
targets |= Tokens.HasSwappableToken(token.symbol, PlatformKind.Phantasma) ? PlatformKind.Phantasma : PlatformKind.None; | ||
return targets; | ||
|
||
case PlatformKind.Ethereum: | ||
targets = PlatformKind.Ethereum; | ||
targets |= Tokens.HasSwappableToken(token.symbol, PlatformKind.Phantasma) ? PlatformKind.Phantasma : PlatformKind.None; | ||
return targets; | ||
|
||
case PlatformKind.BSC: | ||
targets = PlatformKind.BSC; | ||
targets |= Tokens.HasSwappableToken(token.symbol, PlatformKind.Phantasma) ? PlatformKind.Phantasma : PlatformKind.None; | ||
return targets; | ||
|
||
default: | ||
return PlatformKind.None; | ||
} | ||
} | ||
public static bool ValidateTransferTarget(this PlatformKind kind, Token token, PlatformKind targetKind) | ||
{ | ||
var targets = kind.GetTransferTargets(token); | ||
return targets.HasFlag(targetKind); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Poltergeist | ||
{ | ||
public struct AccountLegacyV1 | ||
{ | ||
public static readonly int MinPasswordLength = 6; | ||
public static readonly int MaxPasswordLength = 32; | ||
|
||
public string name; | ||
public PlatformKind platforms; | ||
public string WIF; | ||
public string password; | ||
public string misc; | ||
|
||
public override string ToString() | ||
{ | ||
return $"{name.ToUpper()} [{platforms}]"; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Collections.Generic; | ||
using Phantasma.Core.Types; | ||
using Phantasma.SDK; | ||
|
||
namespace Poltergeist | ||
{ | ||
public class AccountState | ||
{ | ||
public PlatformKind platform; | ||
public string name; | ||
public string address; | ||
public Balance[] balances; | ||
public AccountFlags flags; | ||
public Timestamp stakeTime; | ||
|
||
public Archive[] archives; | ||
public string avatarData; | ||
public uint availableStorage; | ||
public uint usedStorage; | ||
public uint totalStorage => availableStorage + usedStorage; | ||
|
||
public Dictionary<string, string> dappTokens = new Dictionary<string, string>(); | ||
|
||
public decimal GetAvailableAmount(string symbol) | ||
{ | ||
for (int i = 0; i < balances.Length; i++) | ||
{ | ||
var entry = balances[i]; | ||
if (entry.Symbol == symbol) | ||
{ | ||
return entry.Available; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
public void RegisterDappToken(string dapp, string token) | ||
{ | ||
dappTokens[dapp] = token; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Poltergeist | ||
{ | ||
public struct AccountsExport | ||
{ | ||
public string walletIdentifier; | ||
public int accountsVersion; | ||
public string accounts; | ||
public bool passwordProtected; | ||
public int passwordIterations; | ||
public string salt; | ||
public string iv; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
namespace Poltergeist | ||
{ | ||
public class Balance | ||
{ | ||
public string Symbol; | ||
public decimal Available; | ||
public decimal Staked; | ||
public decimal Pending; | ||
public decimal Claimable; | ||
public string Chain; | ||
public int Decimals; | ||
public bool Burnable; | ||
public bool Fungible; | ||
public string PendingPlatform; | ||
public string PendingHash; | ||
public string[] Ids; | ||
|
||
public decimal Total => Available + Staked + Pending + Claimable; | ||
} | ||
} | ||
namespace Poltergeist | ||
{ | ||
public class Balance | ||
{ | ||
public string Symbol; | ||
public decimal Available; | ||
public decimal Staked; | ||
public decimal Pending; | ||
public decimal Claimable; | ||
public string Chain; | ||
public int Decimals; | ||
public bool Burnable; | ||
public bool Fungible; | ||
public string PendingPlatform; | ||
public string PendingHash; | ||
public string[] Ids; | ||
|
||
public decimal Total => Available + Staked + Pending + Claimable; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
using System; | ||
|
||
namespace Poltergeist | ||
{ | ||
public struct HistoryEntry | ||
{ | ||
public string hash; | ||
public DateTime date; | ||
public string url; | ||
} | ||
} | ||
using System; | ||
|
||
namespace Poltergeist | ||
{ | ||
public struct HistoryEntry | ||
{ | ||
public string hash; | ||
public DateTime date; | ||
public string url; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
|
||
namespace Poltergeist | ||
{ | ||
[Flags] | ||
public enum PlatformKind | ||
{ | ||
None = 0x0, | ||
Phantasma = 0x1, | ||
Neo = 0x2, | ||
Ethereum = 0x4, | ||
BSC = 0x8, | ||
} | ||
} |
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
using System; | ||
|
||
namespace Poltergeist | ||
{ | ||
public class RefreshStatus | ||
{ | ||
// Balance | ||
public bool BalanceRefreshing; | ||
public DateTime LastBalanceRefresh; | ||
public Action BalanceRefreshCallback; | ||
// History | ||
public bool HistoryRefreshing; | ||
public DateTime LastHistoryRefresh; | ||
|
||
public override string ToString() | ||
{ | ||
return $"BalanceRefreshing: {BalanceRefreshing}, LastBalanceRefresh: {LastBalanceRefresh}, HistoryRefreshing: {HistoryRefreshing}, LastHistoryRefresh: {LastHistoryRefresh}"; | ||
} | ||
} | ||
} | ||
using System; | ||
|
||
namespace Poltergeist | ||
{ | ||
public class RefreshStatus | ||
{ | ||
// Balance | ||
public bool BalanceRefreshing; | ||
public DateTime LastBalanceRefresh; | ||
public Action BalanceRefreshCallback; | ||
// History | ||
public bool HistoryRefreshing; | ||
public DateTime LastHistoryRefresh; | ||
|
||
public override string ToString() | ||
{ | ||
return $"BalanceRefreshing: {BalanceRefreshing}, LastBalanceRefresh: {LastBalanceRefresh}, HistoryRefreshing: {HistoryRefreshing}, LastHistoryRefresh: {LastHistoryRefresh}"; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.