-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into remove/plugin-applicationlogs
- Loading branch information
Showing
4 changed files
with
100 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
FROM mcr.microsoft.com/devcontainers/dotnet:9.0-noble | ||
# https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md | ||
# https://mcr.microsoft.com/en-us/artifact/mar/dotnet/sdk/tags <-- this shows all images | ||
FROM mcr.microsoft.com/dotnet/sdk:9.0.101-noble | ||
|
||
# Install the libleveldb-dev package | ||
RUN apt-get update && apt-get install -y libleveldb-dev |
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,42 @@ | ||
// Copyright (C) 2015-2024 The Neo Project. | ||
// | ||
// GasTokenExtensions.cs file belongs to the neo project and is free | ||
// software distributed under the MIT software license, see the | ||
// accompanying file LICENSE in the main directory of the | ||
// repository or http://www.opensource.org/licenses/mit-license.php | ||
// for more details. | ||
// | ||
// Redistribution and use in source and binary forms with or without | ||
// modifications are permitted. | ||
|
||
using Neo.Persistence; | ||
using Neo.SmartContract; | ||
using Neo.SmartContract.Native; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Numerics; | ||
|
||
namespace Neo.Extensions | ||
{ | ||
public static class GasTokenExtensions | ||
{ | ||
public static IEnumerable<(UInt160 Address, BigInteger Balance)> GetAccounts(this GasToken gasToken, DataCache snapshot) | ||
{ | ||
if (gasToken is null) | ||
throw new ArgumentNullException(nameof(gasToken)); | ||
|
||
if (snapshot is null) | ||
throw new ArgumentNullException(nameof(snapshot)); | ||
|
||
var kb = new KeyBuilder(gasToken.Id, GasToken.Prefix_Account); | ||
var prefixKey = kb.ToArray(); | ||
|
||
foreach (var (key, value) in snapshot.Find(prefixKey, SeekDirection.Forward)) | ||
{ | ||
var keyBytes = key.ToArray(); | ||
var addressHash = new UInt160(keyBytes.AsSpan(prefixKey.Length)); | ||
yield return new(addressHash, value.GetInteroperable<AccountState>().Balance); | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (C) 2015-2024 The Neo Project. | ||
// | ||
// UT_GasTokenExtensions.cs file belongs to the neo project and is free | ||
// software distributed under the MIT software license, see the | ||
// accompanying file LICENSE in the main directory of the | ||
// repository or http://www.opensource.org/licenses/mit-license.php | ||
// for more details. | ||
// | ||
// Redistribution and use in source and binary forms with or without | ||
// modifications are permitted. | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Neo.Extensions; | ||
using Neo.SmartContract.Native; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Numerics; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Neo.UnitTests.Extensions | ||
{ | ||
[TestClass] | ||
public class UT_GasTokenExtensions | ||
{ | ||
private NeoSystem system; | ||
|
||
[TestInitialize] | ||
public void Initialize() | ||
{ | ||
system = TestBlockchain.TheNeoSystem; | ||
} | ||
|
||
[TestCleanup] | ||
public void Clean() | ||
{ | ||
TestBlockchain.ResetStore(); | ||
} | ||
|
||
[TestMethod] | ||
public void TestGetAccounts() | ||
{ | ||
UInt160 expected = "0x9f8f056a53e39585c7bb52886418c7bed83d126b"; | ||
|
||
var accounts = NativeContract.GAS.GetAccounts(system.StoreView); | ||
var actual = accounts.FirstOrDefault(); | ||
|
||
Assert.AreEqual(expected, actual.Address); | ||
Assert.AreEqual(5200000000000000, actual.Balance); | ||
} | ||
} | ||
} |