Skip to content

Commit

Permalink
Using ao proxy process for balance
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost committed Jun 29, 2024
1 parent 8e0e3c7 commit 1bd7ea6
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/aoWebWallet/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public static class Constants
{
public static string AoTokenId => "m3PaWzK4PTG9lAaqYQPaPdOcXdO8hYqi5Fe9NWqXd0w";
public static string AoProxyTokenId => "Pi-WmAQp2-mh-oWH9lWpz5EthlUDj_W0IusAv-RXhRk";
public static string CredTokenId => "Sa0iBLPNyJQrwpTTG-tWLQU-1QeUAJA73DdxGGiKoJc";
}
}
1 change: 1 addition & 0 deletions src/aoWebWallet/Models/Token.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace aoWebWallet.Models
public class Token
{
public required string TokenId { get; set; }
public string? ProxyTokenId { get; set; }
public bool IsSystemToken { get; set; }
public bool IsUserAdded { get; set; }
public bool IsVisible { get; set; } = true;
Expand Down
13 changes: 9 additions & 4 deletions src/aoWebWallet/Services/StorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public static void AddSystemTokens(List<Token> result)
Logo = "UkS-mdoiG8hcAClhKK8ch4ZhEzla0mCPDOix9hpdSFE",
Name = "AO",
Ticker = "AO"
}); //AO
},
proxyTokenId:Constants.AoProxyTokenId); //AO

AddSystemToken(result, Constants.CredTokenId,
new TokenData
Expand Down Expand Up @@ -160,13 +161,17 @@ public static void AddSystemTokens(List<Token> result)
});
}

private static void AddSystemToken(List<Token> list, string tokenId, TokenData tokenData)
private static void AddSystemToken(List<Token> list, string tokenId, TokenData tokenData, string? proxyTokenId = null)
{
var existing = list.Where(x => x.TokenId == tokenId).FirstOrDefault();
if (existing != null)
existing.IsSystemToken = true;
{
existing.IsSystemToken = true;
existing.TokenData = tokenData;
existing.ProxyTokenId = proxyTokenId;
}
else
list.Add(new Token { TokenId = tokenId, IsSystemToken = true, TokenData = tokenData });
list.Add(new Token { TokenId = tokenId, ProxyTokenId = proxyTokenId, IsSystemToken = true, TokenData = tokenData });
}

public async ValueTask<Token> AddToken(string tokenId, TokenData data, bool isUserAdded, bool? isVisible)
Expand Down
12 changes: 0 additions & 12 deletions src/aoWebWallet/ViewModels/BalanceDataViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,5 @@ public class BalanceDataViewModel

public required string Address { get; set; }

//public void Load()
//{
// BalanceDataLoader.DataLoader.LoadAsync(async () =>
// {
// var balanceData = await tokenClient.GetBalance(token.TokenId, address);
// return balanceData;
// }, (x) =>
// {
// balanceData.BalanceDataLoader.Data = x;
// TokenTransferList.ForcePropertyChanged();
// });
//}
}
}
6 changes: 5 additions & 1 deletion src/aoWebWallet/ViewModels/WalletDetailViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ private async Task LoadBalanceDataList(string address, bool onlyNew = false)

balanceData.BalanceDataLoader.DataLoader.LoadAsync(async () =>
{
var balanceData = await tokenClient.GetBalance(token.TokenId, address);
var tokenForBalance = token.ProxyTokenId;
if(string.IsNullOrEmpty(tokenForBalance))
tokenForBalance = token.TokenId;

var balanceData = await tokenClient.GetBalance(tokenForBalance, address);
return balanceData;
}, (x) =>
{
Expand Down
2 changes: 1 addition & 1 deletion src/aoWebWallet/aoWebWallet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ArweaveAO" Version="0.0.5" />
<PackageReference Include="ArweaveAO" Version="0.0.6" />
<PackageReference Include="ArweaveBlazor" Version="0.0.9" />
<PackageReference Include="ClipLazor" Version="2.1.1" />
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="6.9.2" />
Expand Down
2 changes: 1 addition & 1 deletion src/aoww.ProcesModels/aoww.ProcesModels.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ArweaveAO" Version="0.0.5" />
<PackageReference Include="ArweaveAO" Version="0.0.6" />
</ItemGroup>

</Project>

0 comments on commit 1bd7ea6

Please sign in to comment.