Skip to content

Commit

Permalink
Fix tryGetContract and TryEvaluateNamedSlot (#127)
Browse files Browse the repository at this point in the history
* update CI

* fix tryGetContract

* use TestApplicationEngine.CreateTestTransaction

* Bump css-what from 5.0.0 to 5.0.1 in /src/extension

Bumps [css-what](https://github.com/fb55/css-what) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/fb55/css-what/releases)
- [Commits](fb55/css-what@v5.0.0...v5.0.1)

---
updated-dependencies:
- dependency-name: css-what
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* return true correctly from TryEvaluateNamedSlot

* Update readme.md (#123)

* Neo.BlockchainToolkit3 Version 1.0.51

* azure ci build on ubuntu

Co-authored-by: Harry <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Guil. Sperb Machado <[email protected]>
  • Loading branch information
4 people committed Jun 16, 2021
1 parent e8ad61d commit 3f03913
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ jobs:
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install nbgv
run: dotnet tool install nbgv --tool-path ./tools --version 3.3.37
run: dotnet tool install nbgv --tool-path ./tools
- name: Run nbgv
run: echo "NUGET_PACKAGE_VERSION=$(./tools/nbgv get-version -v NuGetPackageVersion)" >> $GITHUB_ENV
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions eng/azure-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ variables:
configuration: release

pool:
vmImage: 'windows-2019'
vmImage: 'ubuntu-20.04'

trigger:
batch: false
Expand All @@ -23,7 +23,7 @@ steps:
displayName: 'use .NET Core SDK from global.json'
inputs:
packageType: 'sdk'
useGlobalJson: true
version: '5.0.x'

- script: dotnet --list-sdks
displayName: list sdks
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ The debug information format is [fully documented](https://github.com/ngdseattle
This format is supported by a variety of Neo smart contract compilers including

* [NEON (C#)](https://github.com/neo-project/neo-devpack-dotnet)
* [neo3wj (Java/Kotlin/Android)](https://neow3j.io/)
* [neow3j (Java/Kotlin/Android)](https://neow3j.io)
* [neo-boa (Python)](https://github.com/CityOfZion/neo-boa)
* [NeoGo (GoLang)](https://github.com/nspcc-dev/neo-go)
* [NEO•ONE (TypeScript)](https://neo-one.io/)
* [NEO•ONE (TypeScript)](https://neo-one.io)

As of version 2.0, the Neo Smart Contract Debugger supports both
[Neo N3 and Neo Legacy](https://medium.com/neo-smart-economy/introducing-neo-n3-the-next-evolution-of-the-neo-blockchain-b2960c4def6e).
Expand Down
1 change: 1 addition & 0 deletions src/adapter3/DebugSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ static bool TryEvaluateNamedSlot(IReadOnlyList<StackItem> slot, IReadOnlyList<De
? _type
: ContractParameterType.Any;
result = (slot[variableList[i].Index], type);
return true;
}
}

Expand Down
35 changes: 18 additions & 17 deletions src/adapter3/LaunchConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Neo.BlockchainToolkit;
using Neo.BlockchainToolkit.Models;
using Neo.BlockchainToolkit.Persistence;
using Neo.BlockchainToolkit.SmartContract;
using Neo.Cryptography.ECC;
using Neo.IO;
using Neo.Network.P2P.Payloads;
Expand Down Expand Up @@ -268,14 +269,21 @@ public void Dispose()

static ContractParameterParser CreateContractParameterParser(byte addressVersion, IStore store, ExpressChain? chain)
{
var deployedContracts = ImmutableDictionary<string, UInt160>.Empty;
using (var snapshot = new SnapshotCache(store))
{
deployedContracts = NativeContract.ContractManagement.ListContracts(snapshot)
.ToImmutableDictionary(
contract => contract.Manifest.Name,
contract => contract.Hash);
}
ContractParameterParser.TryGetUInt160 tryGetContract = (string name, out UInt160 scriptHash) =>
{
using var snapshot = new SnapshotCache(store);
foreach (var contract in NativeContract.ContractManagement.ListContracts(snapshot))
{
if (contract.Manifest.Name.Equals(name))
{
scriptHash = contract.Hash;
return true;
}
}
scriptHash = null!;
return false;
};

ContractParameterParser.TryGetUInt160? tryGetAccount = chain == null
? null
Expand All @@ -291,7 +299,7 @@ static ContractParameterParser CreateContractParameterParser(byte addressVersion
return false;
};

return new ContractParameterParser(addressVersion, tryGetAccount, deployedContracts.TryGetValue);
return new ContractParameterParser(addressVersion, tryGetAccount, tryGetContract);
}

static (int id, UInt160 scriptHash) EnsureContractDeployed(IStore store, NefFile nefFile, ContractManifest manifest, Signer deploySigner, ProtocolSettings settings)
Expand Down Expand Up @@ -378,14 +386,7 @@ static void OnDeploy(ContractState contract, Signer deploySigner, DataCache snap
var deployMethod = contract.Manifest.Abi.GetMethod("_deploy", 2);
if (deployMethod is not null)
{
var tx = new Transaction
{
Attributes = Array.Empty<TransactionAttribute>(),
Script = Array.Empty<byte>(),
Signers = new[] { deploySigner },
Witnesses = Array.Empty<Witness>()
};

var tx = TestApplicationEngine.CreateTestTransaction(deploySigner);
using (var engine = ApplicationEngine.Create(TriggerType.Application, tx, snapshot, null, settings))
{
var context = engine.LoadContract(contract, deployMethod, CallFlags.All);
Expand Down
2 changes: 1 addition & 1 deletion src/adapter3/neodebug-3-adapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="3.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Shared.VsCodeDebugProtocol" Version="16.9.50204.1" />
<PackageReference Include="Neo.BlockchainToolkit3" Version="1.0.47-preview" />
<PackageReference Include="Neo.BlockchainToolkit3" Version="1.0.51-preview" />
<PackageReference Include="Nito.Disposables" Version="2.2.0" />
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
<PackageReference Include="System.Linq.Async" Version="5.0.0" />
Expand Down
6 changes: 3 additions & 3 deletions src/extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3f03913

Please sign in to comment.