-
Notifications
You must be signed in to change notification settings - Fork 106
feat: add core Neo smart contract deployment framework #1351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
* SafeAttribute supports in properties * Update Nep11Token.cs * Safe setters are not allowed
- Add DeploymentToolkit class with basic deployment API - Implement network configuration support (mainnet, testnet, local, custom RPC) - Add WIF key support for transaction signing - Create comprehensive project structure with interfaces and models - Add configuration management with JSON and environment variable support - Include 16 unit tests covering all basic functionality - Update README.md with deployment documentation and usage examples This establishes the foundation for Neo smart contract deployment capabilities without implementation details, providing a clean base for future enhancements.
…rence - Fix whitespace formatting issues in deployment toolkit files - Add missing final newlines to all source files - Remove duplicate Microsoft.NET.Test.Sdk package reference in test project - All 16 unit tests continue to pass - Code formatting now passes GitHub Actions checks
2f05ca7
to
ce28e18
Compare
ce28e18
to
ef94799
Compare
/// <summary> | ||
/// Network magic number for transaction signing | ||
/// </summary> | ||
public uint NetworkMagic { get; set; } = 894710606; // Default to testnet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be retrieved from the rpc?
/// <summary> | ||
/// Network name (private, testnet, mainnet) | ||
/// </summary> | ||
public string Network { get; set; } = string.Empty; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depend to the RpcUrl, isn't it?
<ItemGroup> | ||
<Compile Update="**/*.cs"> | ||
<Pack>true</Pack> | ||
<PackagePath>src</PackagePath> | ||
</Compile> | ||
</ItemGroup> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's required?
- Remove Network property from NetworkConfiguration as it depends on RpcUrl - Change NetworkMagic to nullable and retrieve from RPC when not configured - Add logic to fetch NetworkMagic from RPC using GetVersionAsync() - Remove unnecessary Compile Update section from csproj file - Update unit tests to match new behavior
- Add tests to verify network magic can be retrieved from RPC - Add tests for network configuration priority (specific > global > RPC) - Add tests for SetNetwork with various inputs and edge cases - Add tests to ensure proper RPC URL configuration for known networks - Document expected network magic values for mainnet and testnet
- Change testnet RPC URL from testnet1.neo.coz.io to testnet.rpc.ngd.network - Update all test assertions to use the new NGD testnet URL - Add integration tests to verify RPC connectivity (skipped by default) - Ensure network magic retrieval works with NGD testnet endpoint
- Change from testnet.rpc.ngd.network to testnet.ngd.network - Update all test assertions to use the correct URL
- Change testnet RPC URL to http://seed2t5.neo.org:20332 - Update all test assertions to use the Neo seed node URL - Update integration test names to reflect Neo testnet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Jim8y
My suggestion is that if this is able to Deploy and test, so, the examples we have here should be deployed during tests and we could verify states.
That would be a good test that has a real flow behind.
On the other hand, I see some separation between this repo and the framework being pushed here.
its hard to balance, smaller prs for easier to review, but lacks complete functionality, complete tookit too large for reviewing. yet if you wish to review as a whole, you can check the full pr. bellow is the deployed example contracts on testnet. Latest Deployment (TestNet)
Deployment Details:
|
I see @Jim8y, but why this needed to be here in Devpack? What I see in this pr is like a framework for interacting with the blockchain. |
Maybe even the Core itself is better than here |
implementing, testing, deploying is a complete workflow, with this, developer can do everfything easily all together. they dont need to download and install and sync neo-cli, or searching for some unknown deployment methods. All of these is for a better development experience. |
@shargon all your concern and suggestion have being resolved. |
/// </summary> | ||
public class DeploymentToolkit : IDisposable | ||
{ | ||
private const string GAS_CONTRACT_HASH = "0xd2a4cff31913016155e38e474a2c06d08be276cf"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take the hash from the NativeContract Instance?
/// <summary> | ||
/// Wallet configuration settings | ||
/// </summary> | ||
public class WalletConfiguration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One class per file please
tests/Neo.SmartContract.Deploy.UnitTests/RpcIntegrationTests.cs
Outdated
Show resolved
Hide resolved
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); | ||
Directory.CreateDirectory(tempDir); | ||
var contractPath = Path.Combine(tempDir, "TestContract.cs"); | ||
File.WriteAllText(contractPath, contractCode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UT that create a file, should delete the file after the test
Co-authored-by: Shargon <[email protected]>
Co-authored-by: Shargon <[email protected]>
Co-authored-by: Shargon <[email protected]>
Co-authored-by: Shargon <[email protected]>
Co-authored-by: Shargon <[email protected]>
Co-authored-by: Shargon <[email protected]>
Co-authored-by: Shargon <[email protected]>
…ffolding; add DeploymentArtifactsDemo example; fix RpcStore OnNewSnapshot; docs update
{ | ||
if (!doCall) | ||
{ | ||
if (string.IsNullOrEmpty(wif) || string.IsNullOrEmpty(nef) || string.IsNullOrEmpty(manifest)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (string.IsNullOrWhiteSpace(wif) || string.IsNullOrWhiteSpace(nef) || string.IsNullOrWhiteSpace(manifest))
} | ||
else | ||
{ | ||
if (string.IsNullOrEmpty(contract) || string.IsNullOrEmpty(method)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (string.IsNullOrWhiteSpace(contract) || string.IsNullOrWhiteSpace(method))
} | ||
|
||
object[] callArgs = Array.Empty<object>(); | ||
if (!string.IsNullOrEmpty(argsJson)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!string.IsNullOrWhiteSpace(argsJson))
@Jim8y Could you solve the conflicts? |
…mples/Directory.Build.props and RpcStore; apply IsNullOrWhiteSpace in DeploymentArtifactsDemo
Summary
This PR establishes the foundational deployment infrastructure for Neo smart contracts, providing a clean, extensible API for deployment operations.
Key Features
Implementation Highlights
Files Added
src/Neo.SmartContract.Deploy/
- Complete project structuretests/Neo.SmartContract.Deploy.UnitTests/
- Comprehensive test suiteDependencies
This PR has no dependencies and establishes the foundation for future deployment features.
Testing
This PR creates a solid foundation that will be extended with full implementation in subsequent PRs.