├── DOCKER
├── testnet
│ ├── node1
│ │ ├── tendermint.log
│ │ ├── data
│ │ │ └── priv_validator_state.json
│ │ └── config
│ │ │ ├── node_key.json
│ │ │ ├── priv_validator_key.json
│ │ │ └── genesis.json
│ ├── node2
│ │ ├── tendermint.log
│ │ ├── data
│ │ │ └── priv_validator_state.json
│ │ └── config
│ │ │ ├── node_key.json
│ │ │ ├── priv_validator_key.json
│ │ │ └── genesis.json
│ ├── node3
│ │ ├── tendermint.log
│ │ ├── data
│ │ │ └── priv_validator_state.json
│ │ └── config
│ │ │ ├── node_key.json
│ │ │ ├── priv_validator_key.json
│ │ │ └── genesis.json
│ └── node0
│ │ ├── data
│ │ └── priv_validator_state.json
│ │ └── config
│ │ ├── node_key.json
│ │ ├── priv_validator_key.json
│ │ └── genesis.json
├── Dockerfile
└── wrapper.sh
├── .idea
└── .idea.PhantasmaChain
│ └── .idea
│ ├── .name
│ ├── encodings.xml
│ ├── vcs.xml
│ ├── indexLayout.xml
│ └── .gitignore
├── logo.png
├── fix-eol.sh
├── Phantasma.Core
├── src
│ ├── Domain
│ │ ├── IChainSwap.cs
│ │ ├── IOracleObserver.cs
│ │ ├── ITask.cs
│ │ ├── ICustomContract.cs
│ │ ├── IFeed.cs
│ │ ├── Leaderboard.cs
│ │ ├── ITransaction.cs
│ │ ├── IExecutionContext.cs
│ │ ├── IArchiveEncryption.cs
│ │ ├── IChainTask.cs
│ │ ├── IExecutionFrame.cs
│ │ ├── IAPIResult.cs
│ │ ├── INativeContract.cs
│ │ ├── IOrganization.cs
│ │ ├── IOracleReader.cs
│ │ ├── ExecutionContext.cs
│ │ ├── IArchive.cs
│ │ ├── TransactionResult.cs
│ │ ├── ExecutionFrame.cs
│ │ ├── OracleEntry.cs
│ │ ├── Opcodes.cs
│ │ ├── IVirtualMachine.cs
│ │ ├── OracleFeed.cs
│ │ ├── Exceptions.cs
│ │ └── PlatformInfo.cs
│ ├── Cryptography
│ │ ├── SignatureKind.cs
│ │ ├── Hashing
│ │ │ ├── RIPEMD160.cs
│ │ │ ├── SHA3Keccak.cs
│ │ │ └── SHA256.cs
│ │ ├── Entropy.cs
│ │ ├── PoW.cs
│ │ ├── Signature.cs
│ │ └── EdDSA
│ │ │ └── Ed25519Signature.cs
│ ├── Numerics
│ │ └── Phantasma.Numerics.csproj.user
│ ├── Storage
│ │ └── Context
│ │ │ ├── IStorageCollection.cs
│ │ │ ├── KeyStoreStorage.cs
│ │ │ └── StorageValue.cs
│ ├── Utils
│ │ └── StreamUtils.cs
│ └── Phantasma.Core.csproj
└── tests
│ ├── AddressTests.cs
│ └── Phantasma.Core.Tests.csproj
├── Phantasma.Node
├── testnet
│ ├── node0
│ │ ├── data
│ │ │ └── priv_validator_state.json
│ │ └── config
│ │ │ ├── node_key.json
│ │ │ ├── priv_validator_key.json
│ │ │ └── genesis.json
│ ├── node1
│ │ ├── data
│ │ │ └── priv_validator_state.json
│ │ └── config
│ │ │ ├── node_key.json
│ │ │ ├── priv_validator_key.json
│ │ │ └── genesis.json
│ ├── node2
│ │ ├── data
│ │ │ └── priv_validator_state.json
│ │ └── config
│ │ │ ├── node_key.json
│ │ │ ├── priv_validator_key.json
│ │ │ └── genesis.json
│ └── node3
│ │ ├── data
│ │ └── priv_validator_state.json
│ │ └── config
│ │ ├── node_key.json
│ │ ├── priv_validator_key.json
│ │ └── genesis.json
├── Events
│ ├── InvalidateEndpointCacheEvent.cs
│ ├── IEventBus.cs
│ └── EventBus.cs
├── Authentication
│ ├── BasicAuthenticationDefaults.cs
│ ├── BasicAuthenticationSchemeOptions.cs
│ └── BasicAuthenticationExtensions.cs
├── Caching
│ ├── EndpointCacheResult.cs
│ └── IEndpointCacheManager.cs
├── Metrics
│ ├── IEndpointMetrics.cs
│ └── EndpointMetrics.cs
├── Shell
│ └── SpookShell.cs
├── Chains
│ ├── Neo2
│ │ └── Asset.cs
│ └── Ethereum
│ │ ├── EthEvents.cs
│ │ ├── EthTxExtensions.cs
│ │ └── EthFunctions.cs
├── Hosting
│ └── EventBusBackgroundService.cs
├── Converters
│ └── EnumerableJsonConverterFactory.cs
├── DeliverTxResult.cs
├── Oracles
│ ├── Pricer.cs
│ ├── CryptoCompare.cs
│ └── CoinGecko.cs
├── Swagger
│ ├── SwaggerAuthorizationMiddleware.cs
│ └── SwaggerExtensions.cs
└── Middleware
│ ├── ErrorLoggingMiddleware.cs
│ └── PerformanceMiddleware.cs
├── global.json
├── Phantasma.Business
├── tests
│ ├── Blockchain
│ │ ├── SwapsTest.cs
│ │ ├── GasMachineTest.cs
│ │ ├── TransactionTest.cs
│ │ └── BlockTest.cs
│ ├── VM
│ │ ├── DisassemblerTest.cs
│ │ ├── ScriptContextTest.cs
│ │ ├── ExecutionContextTest.cs
│ │ ├── ExecutionFrameTest.cs
│ │ └── DebugInfoTest.cs
│ └── Phantasma.Business.Tests.csproj
└── src
│ ├── CodeGen
│ ├── CompilerException.cs
│ ├── Core
│ │ ├── Nodes
│ │ │ ├── ExpressionNode.cs
│ │ │ ├── ImportNode.cs
│ │ │ ├── ExitNode.cs
│ │ │ ├── TypeNode.cs
│ │ │ ├── CallNode.cs
│ │ │ ├── WhileNode.cs
│ │ │ ├── ParameterNode.cs
│ │ │ ├── StatementNode.cs
│ │ │ ├── ClassNode.cs
│ │ │ ├── DeclarationNode.cs
│ │ │ ├── AssignmentNode.cs
│ │ │ ├── ModuleNode.cs
│ │ │ ├── StackAssignmentNode.cs
│ │ │ ├── BlockNode.cs
│ │ │ ├── ReturnNode.cs
│ │ │ ├── VariableExpressionNode.cs
│ │ │ ├── LiteralExpressionNode.cs
│ │ │ └── UnaryExpressionNode.cs
│ │ ├── LanguageProcessor.cs
│ │ └── Compiler.cs
│ └── Assembler
│ │ └── Label.cs
│ ├── Blockchain
│ ├── TransactionExtensions.cs
│ ├── Interop.cs
│ ├── CustomContract.cs
│ ├── Contracts
│ │ ├── CrownContract.tomb
│ │ ├── ContractNames.cs
│ │ └── FriendContract.cs
│ └── Storage
│ │ └── SharedArchiveEncryption.cs
│ └── Phantasma.Business.csproj
├── Tendermint.RPC
├── src
│ ├── Endpoint
│ │ ├── IEndpointResponse.cs
│ │ ├── Subscribe.cs
│ │ ├── Unsubscribe.cs
│ │ ├── UnsubscribeAll.cs
│ │ ├── Health.cs
│ │ ├── EEndpointRequest.cs
│ │ ├── UnconfirmedTxs.cs
│ │ ├── Blockchain.cs
│ │ ├── ConsensusParams.cs
│ │ ├── BroadcastTxAsync.cs
│ │ ├── NumUnconfirmedTxs.cs
│ │ ├── TxSearch.cs
│ │ ├── BroadcastTxSync.cs
│ │ ├── AbciInfo.cs
│ │ └── Block.cs
│ ├── NodeRpcException.cs
│ ├── RpcRequest.cs
│ ├── JsonNetSerializer.cs
│ ├── RpcResponse.cs
│ └── INodeRpc.cs
└── Tendermint.RPC.csproj
├── .gitignore
├── .editorconfig
├── Tendermint
├── CodeType.cs
├── proto
│ └── tendermint
│ │ ├── libs
│ │ └── bits
│ │ │ └── types.proto
│ │ ├── types
│ │ ├── events.proto
│ │ ├── block.proto
│ │ ├── validator.proto
│ │ ├── evidence.proto
│ │ └── canonical.proto
│ │ ├── mempool
│ │ ├── types.proto
│ │ └── message.go
│ │ ├── crypto
│ │ ├── keys.proto
│ │ └── proof.proto
│ │ ├── privval
│ │ └── service.proto
│ │ ├── version
│ │ └── types.proto
│ │ ├── p2p
│ │ ├── conn.proto
│ │ ├── pex.proto
│ │ ├── pex.go
│ │ └── types.proto
│ │ ├── rpc
│ │ └── grpc
│ │ │ └── types.proto
│ │ ├── consensus
│ │ ├── message_test.go
│ │ ├── wal.proto
│ │ └── message.go
│ │ ├── blocksync
│ │ └── types.proto
│ │ └── statesync
│ │ └── types.proto
├── Extensions
│ ├── ByteArrayExtensions.cs
│ ├── IntExtensions.cs
│ ├── StringExtensions.cs
│ └── ByteStringExtensions.cs
└── Tendermint.csproj
├── Phantasma.Shared
└── src
│ ├── Types
│ ├── Surprise.cs
│ └── Map.cs
│ ├── Phantasma.Shared.csproj
│ └── Utils
│ └── ByteArrayComparer.cs
├── .github
├── pull_request_template.md
└── workflows
│ ├── dotnet-core.yml
│ └── dotnet-server.yml
├── Phantasma.Tests
├── Phantasma.Tests.csproj.user
├── .idea
│ └── .idea.Phantasma.Tests.dir
│ │ └── .idea
│ │ └── .gitignore
├── Phantasma.Neo
│ └── Utils
│ │ └── LuxUtils.cs
├── WalletTests.cs
├── NachoTests.cs
├── Phantasma.Simulator
│ └── Phantasma.Simulator.csproj
└── Phantasma.Tests.csproj
├── Phantasma.Infrastructure
└── src
│ ├── API
│ ├── Controllers
│ │ ├── BaseControllerV1.cs
│ │ ├── BaseRpcControllerV1.cs
│ │ ├── ValidatorController.cs
│ │ ├── ChainController.cs
│ │ ├── OrganizationController.cs
│ │ ├── ContractController.cs
│ │ ├── LeaderboardController.cs
│ │ └── PlatformController.cs
│ └── DefaultAvatar.cs
│ ├── RocksDB
│ └── Phantasma.RocksDB.csproj
│ ├── Pay
│ ├── Phantasma.Pay.csproj
│ └── WalletUtils.cs
│ └── Phantasma.Infrastructure.csproj
├── cl.sh
├── .travis.yml
├── clean.sh
└── LICENSE
/DOCKER/testnet/node1/tendermint.log:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/DOCKER/testnet/node2/tendermint.log:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/DOCKER/testnet/node3/tendermint.log:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/.idea.PhantasmaChain/.idea/.name:
--------------------------------------------------------------------------------
1 | PhantasmaChain
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Relfos/phantasma-ng/master/logo.png
--------------------------------------------------------------------------------
/fix-eol.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | find ./ -name "*.cs" -exec dos2unix --keepdate --keep-bom {} +
--------------------------------------------------------------------------------
/DOCKER/testnet/node0/data/priv_validator_state.json:
--------------------------------------------------------------------------------
1 | {
2 | "height": "0",
3 | "round": 0,
4 | "step": 0
5 | }
--------------------------------------------------------------------------------
/DOCKER/testnet/node1/data/priv_validator_state.json:
--------------------------------------------------------------------------------
1 | {
2 | "height": "0",
3 | "round": 0,
4 | "step": 0
5 | }
--------------------------------------------------------------------------------
/DOCKER/testnet/node2/data/priv_validator_state.json:
--------------------------------------------------------------------------------
1 | {
2 | "height": "0",
3 | "round": 0,
4 | "step": 0
5 | }
--------------------------------------------------------------------------------
/DOCKER/testnet/node3/data/priv_validator_state.json:
--------------------------------------------------------------------------------
1 | {
2 | "height": "0",
3 | "round": 0,
4 | "step": 0
5 | }
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/IChainSwap.cs:
--------------------------------------------------------------------------------
1 | namespace Phantasma.Core;
2 |
3 | public interface IChainSwap
4 | {
5 | }
6 |
--------------------------------------------------------------------------------
/Phantasma.Node/testnet/node0/data/priv_validator_state.json:
--------------------------------------------------------------------------------
1 | {
2 | "height": "0",
3 | "round": 0,
4 | "step": 0
5 | }
--------------------------------------------------------------------------------
/Phantasma.Node/testnet/node1/data/priv_validator_state.json:
--------------------------------------------------------------------------------
1 | {
2 | "height": "0",
3 | "round": 0,
4 | "step": 0
5 | }
--------------------------------------------------------------------------------
/Phantasma.Node/testnet/node2/data/priv_validator_state.json:
--------------------------------------------------------------------------------
1 | {
2 | "height": "0",
3 | "round": 0,
4 | "step": 0
5 | }
--------------------------------------------------------------------------------
/Phantasma.Node/testnet/node3/data/priv_validator_state.json:
--------------------------------------------------------------------------------
1 | {
2 | "height": "0",
3 | "round": 0,
4 | "step": 0
5 | }
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "6.0",
4 | "rollForward": "latestMajor",
5 | "allowPrerelease": true
6 | }
7 | }
--------------------------------------------------------------------------------
/Phantasma.Business/tests/Blockchain/SwapsTest.cs:
--------------------------------------------------------------------------------
1 | namespace Phantasma.Business.Tests;
2 |
3 | public class SwapsTest
4 | {
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/Phantasma.Business/tests/Blockchain/GasMachineTest.cs:
--------------------------------------------------------------------------------
1 | namespace Phantasma.Business.Tests;
2 |
3 | public class GasMachineTest
4 | {
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/Phantasma.Business/tests/VM/DisassemblerTest.cs:
--------------------------------------------------------------------------------
1 | namespace Phantasma.Business.Tests.VM;
2 |
3 | public class DisassemblerTest
4 | {
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/Phantasma.Business/tests/VM/ScriptContextTest.cs:
--------------------------------------------------------------------------------
1 | namespace Phantasma.Business.Tests.VM;
2 |
3 | public class ScriptContextTest
4 | {
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/Tendermint.RPC/src/Endpoint/IEndpointResponse.cs:
--------------------------------------------------------------------------------
1 | namespace Tendermint.RPC.Endpoint
2 | {
3 | public interface IEndpointResponse
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.tmp
2 | .vs/
3 | TestResults/
4 | Published/
5 | */obj/
6 | */bin/
7 | packages/
8 | .github/*
9 |
10 | **/obj/**
11 | **/bin/**
12 | **/Dumps/**
13 |
--------------------------------------------------------------------------------
/Phantasma.Node/Events/InvalidateEndpointCacheEvent.cs:
--------------------------------------------------------------------------------
1 | namespace Phantasma.Node.Events;
2 |
3 | public class InvalidateEndpointCacheEvent
4 | {
5 | public string Tag { get; set; }
6 | }
7 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Don't use tabs for indentation.
2 | [*]
3 | indent_style = space
4 | end_of_line = lf
5 |
6 | # Code files
7 | [*.{cs}]
8 | indent_size = 4
9 | insert_final_newline = true
10 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Cryptography/SignatureKind.cs:
--------------------------------------------------------------------------------
1 | namespace Phantasma.Core
2 | {
3 | public enum SignatureKind
4 | {
5 | None,
6 | Ed25519,
7 | ECDSA
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/.idea/.idea.PhantasmaChain/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Phantasma.Node/Authentication/BasicAuthenticationDefaults.cs:
--------------------------------------------------------------------------------
1 | namespace Phantasma.Node.Authentication;
2 |
3 | public class BasicAuthenticationDefaults
4 | {
5 | public const string AuthenticationScheme = "Basic";
6 | }
7 |
--------------------------------------------------------------------------------
/DOCKER/testnet/node0/config/node_key.json:
--------------------------------------------------------------------------------
1 | {"id":"0c8203a0e63d7c025a4be9e4391b42fb65d344ab","priv_key":{"type":"tendermint/PrivKeyEd25519","value":"fYOKXzF1PA/dGFBu0KS/0ldzXjv0Gqv+/hP9s1d7J28H8bu7BcWOIlEqOROTr5ifhDk+NCQdJB+LBqlTgaVahA=="}}
--------------------------------------------------------------------------------
/DOCKER/testnet/node1/config/node_key.json:
--------------------------------------------------------------------------------
1 | {"id":"e602bda8f1bc8b916af4d312ce2b5c610074f423","priv_key":{"type":"tendermint/PrivKeyEd25519","value":"AhVZnuWq8cmgnd8c63IuGDnYjYN+MiflhHNGPZOi3EKhWo/EABxxszjAb2bzEzJTPF287GMicERJoGTtI6ss3Q=="}}
--------------------------------------------------------------------------------
/DOCKER/testnet/node2/config/node_key.json:
--------------------------------------------------------------------------------
1 | {"id":"ea9eb814c23bc75d53324f9b650ff2b71720a0c3","priv_key":{"type":"tendermint/PrivKeyEd25519","value":"EZOV8eeJiu0k/dR12nW+K4AZ3DUpmtypHQesg0larNB47zZ5YGxHRTwDRgdkLaE6wsU+lgev81qh0heXck5rQw=="}}
--------------------------------------------------------------------------------
/DOCKER/testnet/node3/config/node_key.json:
--------------------------------------------------------------------------------
1 | {"id":"5aa2fce0959bc52e743b5653f5010b9f7eafcdb1","priv_key":{"type":"tendermint/PrivKeyEd25519","value":"MS5+pO4SJ2tRu98tl7tMUzBwN/1llU9Hgk77l4o2ASrzUefZM44woD13da48P2BGWB6703tPSaDBM353kIMaWQ=="}}
--------------------------------------------------------------------------------
/.idea/.idea.PhantasmaChain/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Phantasma.Node/testnet/node0/config/node_key.json:
--------------------------------------------------------------------------------
1 | {"id":"0c8203a0e63d7c025a4be9e4391b42fb65d344ab","priv_key":{"type":"tendermint/PrivKeyEd25519","value":"fYOKXzF1PA/dGFBu0KS/0ldzXjv0Gqv+/hP9s1d7J28H8bu7BcWOIlEqOROTr5ifhDk+NCQdJB+LBqlTgaVahA=="}}
--------------------------------------------------------------------------------
/Phantasma.Node/testnet/node1/config/node_key.json:
--------------------------------------------------------------------------------
1 | {"id":"e602bda8f1bc8b916af4d312ce2b5c610074f423","priv_key":{"type":"tendermint/PrivKeyEd25519","value":"AhVZnuWq8cmgnd8c63IuGDnYjYN+MiflhHNGPZOi3EKhWo/EABxxszjAb2bzEzJTPF287GMicERJoGTtI6ss3Q=="}}
--------------------------------------------------------------------------------
/Phantasma.Node/testnet/node2/config/node_key.json:
--------------------------------------------------------------------------------
1 | {"id":"ea9eb814c23bc75d53324f9b650ff2b71720a0c3","priv_key":{"type":"tendermint/PrivKeyEd25519","value":"EZOV8eeJiu0k/dR12nW+K4AZ3DUpmtypHQesg0larNB47zZ5YGxHRTwDRgdkLaE6wsU+lgev81qh0heXck5rQw=="}}
--------------------------------------------------------------------------------
/Phantasma.Node/testnet/node3/config/node_key.json:
--------------------------------------------------------------------------------
1 | {"id":"5aa2fce0959bc52e743b5653f5010b9f7eafcdb1","priv_key":{"type":"tendermint/PrivKeyEd25519","value":"MS5+pO4SJ2tRu98tl7tMUzBwN/1llU9Hgk77l4o2ASrzUefZM44woD13da48P2BGWB6703tPSaDBM353kIMaWQ=="}}
--------------------------------------------------------------------------------
/Tendermint/CodeType.cs:
--------------------------------------------------------------------------------
1 | namespace Types
2 | {
3 | public enum CodeType : uint
4 | {
5 | Ok = 0,
6 | Error = 1,
7 | Expired = 2,
8 | InvalidChain = 3,
9 | UnsignedTx = 4,
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Phantasma.Node/Events/IEventBus.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 |
4 | namespace Phantasma.Node.Events;
5 |
6 | public interface IEventBus
7 | {
8 | Task Run(CancellationToken cancellationToken);
9 | }
10 |
--------------------------------------------------------------------------------
/Phantasma.Shared/src/Types/Surprise.cs:
--------------------------------------------------------------------------------
1 | namespace Phantasma.Shared.Types
2 | {
3 | public interface IPromise
4 | {
5 | T Value { get; }
6 | Timestamp Timestamp { get; }
7 | bool Hidden { get; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Phantasma.Node/Caching/EndpointCacheResult.cs:
--------------------------------------------------------------------------------
1 | namespace Phantasma.Node.Caching;
2 |
3 | public class EndpointCacheResult
4 | {
5 | public string Key { get; set; }
6 | public string Content { get; set; }
7 | public bool Cached { get; set; }
8 | }
9 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ## Please do not open any `Pull Requests` to the `master` branch.
2 | ## If you do so expect them to be closed without further notice.
3 |
4 | ## `Pull Requests` are very weclome on the `development` branch.
5 |
6 | Thank you.
7 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/IOracleObserver.cs:
--------------------------------------------------------------------------------
1 | using Phantasma.Core.Context;
2 |
3 | namespace Phantasma.Core
4 | {
5 | public interface IOracleObserver
6 | {
7 | void Update(INexus nexus, StorageContext storage);
8 | }
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/Phantasma.Business/tests/VM/ExecutionContextTest.cs:
--------------------------------------------------------------------------------
1 | using Xunit;
2 |
3 | namespace Phantasma.Business.Tests.VM;
4 |
5 | public class ExecutionContextTest
6 | {
7 | [Fact]
8 | public void test_something()
9 | {
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Phantasma.Tests/Phantasma.Tests.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | false
5 |
6 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Numerics/Phantasma.Numerics.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | false
5 |
6 |
--------------------------------------------------------------------------------
/Phantasma.Node/Authentication/BasicAuthenticationSchemeOptions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Authentication;
2 |
3 | namespace Phantasma.Node.Authentication;
4 |
5 | public class BasicAuthenticationSchemeOptions : AuthenticationSchemeOptions
6 | {
7 | public string Realm { get; set; }
8 | }
9 |
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/libs/bits/types.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.libs.bits;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/libs/bits";
5 |
6 | message BitArray {
7 | int64 bits = 1;
8 | repeated uint64 elems = 2;
9 | }
10 |
--------------------------------------------------------------------------------
/Tendermint.RPC/src/Endpoint/Subscribe.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Tendermint.RPC.Endpoint
6 | {
7 | ///
8 | /// Websocket API
9 | ///
10 | public class Subscribe
11 | {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Tendermint.RPC/src/Endpoint/Unsubscribe.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Tendermint.RPC.Endpoint
6 | {
7 | ///
8 | /// Websocket API
9 | ///
10 | public class Unsubscribe
11 | {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/types/events.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.types;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/types";
5 |
6 | message EventDataRoundState {
7 | int64 height = 1;
8 | int32 round = 2;
9 | string step = 3;
10 | }
11 |
--------------------------------------------------------------------------------
/Phantasma.Infrastructure/src/API/Controllers/BaseControllerV1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace Phantasma.Infrastructure.Controllers;
4 |
5 | [ApiController]
6 | [Produces("application/json")]
7 | [Route("api/v1")]
8 | public abstract class BaseControllerV1 : ControllerBase
9 | {
10 | }
11 |
--------------------------------------------------------------------------------
/Phantasma.Infrastructure/src/API/Controllers/BaseRpcControllerV1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace Phantasma.Infrastructure.Controllers;
4 |
5 | [ApiController]
6 | [Produces("application/json")]
7 | [Route("")]
8 | public abstract class BaseRpcControllerV1 : ControllerBase
9 | {
10 | }
11 |
--------------------------------------------------------------------------------
/Tendermint.RPC/src/Endpoint/UnsubscribeAll.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Tendermint.RPC.Endpoint
6 | {
7 | ///
8 | /// Websocket API
9 | ///
10 | public class UnsubscribeAll
11 | {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Phantasma.Shared/src/Phantasma.Shared.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/.idea.PhantasmaChain/.idea/indexLayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ../../new
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/mempool/types.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.mempool;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/mempool";
5 |
6 | message Txs {
7 | repeated bytes txs = 1;
8 | }
9 |
10 | message Message {
11 | oneof sum {
12 | Txs txs = 1;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/CodeGen/CompilerException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Phantasma.Business
4 | {
5 | public class CompilerException : Exception
6 | {
7 | public CompilerException(uint lineNumber, string message)
8 | : base($"ERROR: {message} in line {lineNumber}.")
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/ITask.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 |
3 | namespace Phantasma.Core
4 | {
5 | public enum TaskFrequencyMode
6 | {
7 | Always,
8 | Time,
9 | Blocks,
10 | }
11 |
12 | public enum TaskResult
13 | {
14 | Running,
15 | Halted,
16 | Crashed,
17 | Skipped,
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/.idea/.idea.PhantasmaChain/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Rider ignored files
5 | /contentModel.xml
6 | /projectSettingsUpdater.xml
7 | /.idea.PhantasmaChain.iml
8 | /modules.xml
9 | # Editor-based HTTP Client requests
10 | /httpRequests/
11 | # Datasource local storage ignored files
12 | /dataSources/
13 | /dataSources.local.xml
14 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/ICustomContract.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 |
3 | namespace Phantasma.Core;
4 |
5 | public interface ICustomContract
6 | {
7 | string Name { get; }
8 | byte[] Script { get; }
9 | ContractInterface ABI { get; }
10 | BigInteger Order { get; } // TODO remove this?
11 | IRuntime Runtime { get; }
12 | Address Address { get; }
13 | }
14 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/Blockchain/TransactionExtensions.cs:
--------------------------------------------------------------------------------
1 | using Phantasma.Core;
2 |
3 | namespace Phantasma.Business
4 | {
5 | public static class TransactionExtensions
6 | {
7 | public static bool IsValid(this Transaction tx, IChain chain)
8 | {
9 | return (chain.Name == tx.ChainName && chain.Nexus.Name == tx.NexusName);
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/IFeed.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Phantasma.Core
3 | {
4 | public enum FeedMode
5 | {
6 | First,
7 | Last,
8 | Max,
9 | Min,
10 | Average
11 | }
12 |
13 | public interface IFeed
14 | {
15 | public string Name { get; }
16 | public Address Address { get; }
17 | public FeedMode Mode { get; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Phantasma.Tests/.idea/.idea.Phantasma.Tests.dir/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Rider ignored files
5 | /modules.xml
6 | /contentModel.xml
7 | /projectSettingsUpdater.xml
8 | /.idea.Phantasma.Tests.iml
9 | # Editor-based HTTP Client requests
10 | /httpRequests/
11 | # Datasource local storage ignored files
12 | /dataSources/
13 | /dataSources.local.xml
14 |
--------------------------------------------------------------------------------
/DOCKER/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM debian:stable-slim
2 | WORKDIR /app
3 |
4 | # Copy everything
5 | COPY DOCKER/wrapper.sh ./
6 | COPY DOCKER/testnet ./testnet
7 | COPY DOCKER/bin ./testnet
8 |
9 | RUN apt-get update; apt-get install -y libc6-dev \
10 | libsnappy-dev libicu-dev screen bash vim net-tools ca-certificates openssl libssl-dev
11 |
12 | EXPOSE 5101 5102 5103 5104
13 |
14 | ENTRYPOINT ["/app/wrapper.sh"]
15 |
16 |
--------------------------------------------------------------------------------
/DOCKER/testnet/node0/config/priv_validator_key.json:
--------------------------------------------------------------------------------
1 | {
2 | "address": "11BB132EC77BC788B65CEAE309A21EC9AD30686C",
3 | "pub_key": {
4 | "type": "tendermint/PubKeyEd25519",
5 | "value": "XGZrm1htSmuI3+fhsu8+VxOuPGbqubdE13gVbhIHe1Q="
6 | },
7 | "priv_key": {
8 | "type": "tendermint/PrivKeyEd25519",
9 | "value": "IfyqKw3PG2PA2bwDL8Z4WB6ecddnX7cMY4jb/TXEOKRcZmubWG1Ka4jf5+Gy7z5XE648Zuq5t0TXeBVuEgd7VA=="
10 | }
11 | }
--------------------------------------------------------------------------------
/DOCKER/testnet/node1/config/priv_validator_key.json:
--------------------------------------------------------------------------------
1 | {
2 | "address": "7CCF8D79D6B7ED4B0FACFD4C3C1FA547DEA0E5CD",
3 | "pub_key": {
4 | "type": "tendermint/PubKeyEd25519",
5 | "value": "IiiA7W0pkTGnIFi/zqIHjfgMt/1gLZUwo/Bt6L8F6Ms="
6 | },
7 | "priv_key": {
8 | "type": "tendermint/PrivKeyEd25519",
9 | "value": "qJvlX0IFlM1jq5NdOzeTBdd2nwOajnNMhYHQDcpoPvoiKIDtbSmRMacgWL/OogeN+Ay3/WAtlTCj8G3ovwXoyw=="
10 | }
11 | }
--------------------------------------------------------------------------------
/DOCKER/testnet/node2/config/priv_validator_key.json:
--------------------------------------------------------------------------------
1 | {
2 | "address": "C06DF36A9325CAA700406E1404E777D3DE7533B2",
3 | "pub_key": {
4 | "type": "tendermint/PubKeyEd25519",
5 | "value": "ZXuG6/FObVz4mhCpKwPHi6R/ZnehI/t+Xww74DX56II="
6 | },
7 | "priv_key": {
8 | "type": "tendermint/PrivKeyEd25519",
9 | "value": "0vO2mjoK9/eioHHpLtHs3E7Z4GY7lIySiFJIxa5Te6lle4br8U5tXPiaEKkrA8eLpH9md6Ej+35fDDvgNfnogg=="
10 | }
11 | }
--------------------------------------------------------------------------------
/DOCKER/testnet/node3/config/priv_validator_key.json:
--------------------------------------------------------------------------------
1 | {
2 | "address": "92544D338AB5935A8F6D4CE3953546FB6B0368C5",
3 | "pub_key": {
4 | "type": "tendermint/PubKeyEd25519",
5 | "value": "/tirj7G+lHmiZ/L94DVoXDwBhC7bqPv4zoVS7Rlau8E="
6 | },
7 | "priv_key": {
8 | "type": "tendermint/PrivKeyEd25519",
9 | "value": "MJOu+vhS1Z3wttneYCSb64ijevipO7qI4Y2BrkVmTx7+2KuPsb6UeaJn8v3gNWhcPAGELtuo+/jOhVLtGVq7wQ=="
10 | }
11 | }
--------------------------------------------------------------------------------
/Phantasma.Shared/src/Types/Map.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Phantasma.Shared.Types
4 | {
5 | public interface IMap
6 | {
7 | void Put(Key key, Value val);
8 | Value Get(Key key);
9 | bool Remove(Key key);
10 | bool Contains(Key key);
11 | void Clear();
12 | void Iterate(Action visitor);
13 |
14 | uint Count { get; }
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Storage/Context/IStorageCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Phantasma.Core.Context
4 | {
5 | public interface IStorageCollection
6 | {
7 | byte[] BaseKey { get; }
8 | StorageContext Context { get; }
9 | }
10 |
11 | public class StorageException: Exception
12 | {
13 | public StorageException(string msg): base(msg)
14 | {
15 |
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Phantasma.Node/testnet/node0/config/priv_validator_key.json:
--------------------------------------------------------------------------------
1 | {
2 | "address": "11BB132EC77BC788B65CEAE309A21EC9AD30686C",
3 | "pub_key": {
4 | "type": "tendermint/PubKeyEd25519",
5 | "value": "XGZrm1htSmuI3+fhsu8+VxOuPGbqubdE13gVbhIHe1Q="
6 | },
7 | "priv_key": {
8 | "type": "tendermint/PrivKeyEd25519",
9 | "value": "IfyqKw3PG2PA2bwDL8Z4WB6ecddnX7cMY4jb/TXEOKRcZmubWG1Ka4jf5+Gy7z5XE648Zuq5t0TXeBVuEgd7VA=="
10 | }
11 | }
--------------------------------------------------------------------------------
/Phantasma.Node/testnet/node1/config/priv_validator_key.json:
--------------------------------------------------------------------------------
1 | {
2 | "address": "7CCF8D79D6B7ED4B0FACFD4C3C1FA547DEA0E5CD",
3 | "pub_key": {
4 | "type": "tendermint/PubKeyEd25519",
5 | "value": "IiiA7W0pkTGnIFi/zqIHjfgMt/1gLZUwo/Bt6L8F6Ms="
6 | },
7 | "priv_key": {
8 | "type": "tendermint/PrivKeyEd25519",
9 | "value": "qJvlX0IFlM1jq5NdOzeTBdd2nwOajnNMhYHQDcpoPvoiKIDtbSmRMacgWL/OogeN+Ay3/WAtlTCj8G3ovwXoyw=="
10 | }
11 | }
--------------------------------------------------------------------------------
/Phantasma.Node/testnet/node2/config/priv_validator_key.json:
--------------------------------------------------------------------------------
1 | {
2 | "address": "C06DF36A9325CAA700406E1404E777D3DE7533B2",
3 | "pub_key": {
4 | "type": "tendermint/PubKeyEd25519",
5 | "value": "ZXuG6/FObVz4mhCpKwPHi6R/ZnehI/t+Xww74DX56II="
6 | },
7 | "priv_key": {
8 | "type": "tendermint/PrivKeyEd25519",
9 | "value": "0vO2mjoK9/eioHHpLtHs3E7Z4GY7lIySiFJIxa5Te6lle4br8U5tXPiaEKkrA8eLpH9md6Ej+35fDDvgNfnogg=="
10 | }
11 | }
--------------------------------------------------------------------------------
/Phantasma.Node/testnet/node3/config/priv_validator_key.json:
--------------------------------------------------------------------------------
1 | {
2 | "address": "92544D338AB5935A8F6D4CE3953546FB6B0368C5",
3 | "pub_key": {
4 | "type": "tendermint/PubKeyEd25519",
5 | "value": "/tirj7G+lHmiZ/L94DVoXDwBhC7bqPv4zoVS7Rlau8E="
6 | },
7 | "priv_key": {
8 | "type": "tendermint/PrivKeyEd25519",
9 | "value": "MJOu+vhS1Z3wttneYCSb64ijevipO7qI4Y2BrkVmTx7+2KuPsb6UeaJn8v3gNWhcPAGELtuo+/jOhVLtGVq7wQ=="
10 | }
11 | }
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/Leaderboard.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 |
3 | namespace Phantasma.Core
4 | {
5 | public struct LeaderboardRow
6 | {
7 | public Address address;
8 | public BigInteger score;
9 | }
10 |
11 | public struct Leaderboard
12 | {
13 | public string name;
14 | public Address owner;
15 | public BigInteger size;
16 | public BigInteger round;
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/CodeGen/Core/Nodes/ExpressionNode.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Phantasma.Business.Core.Nodes
4 | {
5 | public abstract class ExpressionNode : CompilerNode
6 | {
7 | public ExpressionNode(CompilerNode owner) : base(owner)
8 | {
9 | }
10 |
11 | public abstract List Emit(Compiler compiler);
12 |
13 | public abstract TypeKind GetKind();
14 | }
15 | }
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/ITransaction.cs:
--------------------------------------------------------------------------------
1 | using Phantasma.Shared.Types;
2 |
3 | namespace Phantasma.Core
4 | {
5 | public interface ITransaction
6 | {
7 | byte[] Script { get; }
8 |
9 | string NexusName { get; }
10 | string ChainName { get; }
11 |
12 | Timestamp Expiration { get; }
13 |
14 | byte[] Payload { get; }
15 |
16 | Signature[] Signatures { get; }
17 | Hash Hash { get; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Phantasma.Node/Metrics/IEndpointMetrics.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 |
4 | namespace Phantasma.Node.Metrics;
5 |
6 | public interface IEndpointMetrics
7 | {
8 | Task Count(
9 | string path
10 | );
11 |
12 | Task[]> GetCounts();
13 |
14 | Task Average(
15 | string path,
16 | long duration
17 | );
18 |
19 | Task[]> GetAverages();
20 | }
21 |
--------------------------------------------------------------------------------
/Phantasma.Node/Shell/SpookShell.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Collections.Generic;
6 | using Phantasma.Core;
7 | using Phantasma.Node.Utils;
8 |
9 | namespace Phantasma.Node.Shell
10 | {
11 | class SpookShell
12 | {
13 | private Node _node;
14 |
15 | public SpookShell(string[] args, Node node)
16 | {
17 | _node = node;
18 | }
19 |
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Phantasma.Business/tests/VM/ExecutionFrameTest.cs:
--------------------------------------------------------------------------------
1 | using Phantasma.Core;
2 | using Xunit;
3 |
4 | namespace Phantasma.Business.Tests.VM;
5 |
6 | public class ExecutionFrameTest
7 | {
8 |
9 | private ExecutionFrame ExecutionFrame;
10 |
11 | private void Init()
12 | {
13 | //ExecutionFrame = new ExecutionFrame();
14 | }
15 |
16 | [Fact]
17 | public void get_test_register()
18 | {
19 | //ExecutionFrame.GetRegister();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Tendermint.RPC/src/Endpoint/Health.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Tendermint.RPC.Endpoint
6 | {
7 | /*
8 | The above command returns JSON structured like this:
9 | {
10 | "error": "",
11 | "result": {},
12 | "id": "",
13 | "jsonrpc": "2.0"
14 | }
15 | */
16 |
17 | public class ResultHealth : IEndpointResponse
18 | {
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Cryptography/Hashing/RIPEMD160.cs:
--------------------------------------------------------------------------------
1 | using Org.BouncyCastle.Crypto.Digests;
2 |
3 | namespace Phantasma.Core
4 | {
5 | public class RIPEMD160
6 | {
7 | public byte[] ComputeHash(byte[] rgb)
8 | {
9 | var digest = new RipeMD160Digest();
10 | var result = new byte[digest.GetDigestSize()];
11 | digest.BlockUpdate(rgb, 0, rgb.Length);
12 | digest.DoFinal(result, 0);
13 |
14 | return result;
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/cl.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | previous_tag=0
3 | for current_tag in $(git tag --sort=-creatordate)
4 | do
5 |
6 | if [ "$previous_tag" != 0 ];then
7 | tag_date=$(git log -1 --pretty=format:'%ad' --date=short ${previous_tag})
8 | printf "## ${previous_tag} (${tag_date})\n\n"
9 | git log ${current_tag}...${previous_tag} --pretty=format:'* %s [View](https://github.com/phantasma-io/PhantasmaChain/commits/%H)' --reverse | grep -v Merge
10 | printf "\n\n"
11 | fi
12 | previous_tag=${current_tag}
13 | done
14 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/IExecutionContext.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Phantasma.Core
4 | {
5 | public enum ExecutionState
6 | {
7 | Running,
8 | Break,
9 | Fault,
10 | Halt
11 | }
12 |
13 | public interface IExecutionContext
14 | {
15 | public string Name { get; }
16 |
17 | public Address Address { get; }
18 |
19 | public abstract ExecutionState Execute(IExecutionFrame frame, Stack stack);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Tendermint/Extensions/ByteArrayExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace Types.Extensions
4 | {
5 | public static class ByteArrayExtensions
6 | {
7 | // https://stackoverflow.com/a/311179/959687
8 | public static string ByteArrayToString(this byte[] ba)
9 | {
10 | var hex = new StringBuilder(ba.Length * 2);
11 | foreach (var b in ba)
12 | hex.AppendFormat("{0:x2}", b);
13 | return hex.ToString();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/IArchiveEncryption.cs:
--------------------------------------------------------------------------------
1 | namespace Phantasma.Core;
2 |
3 | public enum ArchiveEncryptionMode
4 | {
5 | None,
6 | Private,
7 | Shared
8 | }
9 |
10 | public interface IArchiveEncryption : ISerializable
11 | {
12 | ArchiveEncryptionMode Mode { get; }
13 |
14 | string EncryptName(string name, PhantasmaKeys keys);
15 | string DecryptName(string name, PhantasmaKeys keys);
16 | byte[] Encrypt(byte[] chunk, PhantasmaKeys keys);
17 | byte[] Decrypt(byte[] chunk, PhantasmaKeys keys);
18 | }
19 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/IChainTask.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using Phantasma.Core;
3 |
4 | namespace Phantasma.Core;
5 |
6 | public interface IChainTask
7 | {
8 | BigInteger ID { get; }
9 | bool State { get; }
10 | Address Owner { get; }
11 | string ContextName { get; }
12 | string Method { get; }
13 | uint Frequency { get; }
14 | uint Delay { get; }
15 | TaskFrequencyMode Mode { get; }
16 | BigInteger GasLimit { get; }
17 | BigInteger Height { get; }
18 | byte[] ToByteArray();
19 | }
20 |
--------------------------------------------------------------------------------
/Tendermint.RPC/src/Endpoint/EEndpointRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Tendermint.RPC.Endpoint
6 | {
7 | public enum EEndpointRequest
8 | {
9 | AbciInfo, ConsensusState, DumpConsesusState, NetInfo, Genesis, Health, NumUnconfirmedTxs, Status,
10 | AbciQuery, Block, BlockByHash, BlockResults, Blockchain, Commit, ConsensusParams, Tx, TxSearch, UnconfirmedTxs, Validators,
11 | BroadcastTxAsync, BroadcastTxCommit, BroadcastTxSync
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/crypto/keys.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.crypto;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto";
5 |
6 | import "gogoproto/gogo.proto";
7 |
8 | // PublicKey defines the keys available for use with Tendermint Validators
9 | message PublicKey {
10 | option (gogoproto.compare) = true;
11 | option (gogoproto.equal) = true;
12 |
13 | oneof sum {
14 | bytes ed25519 = 1;
15 | bytes secp256k1 = 2;
16 | bytes sr25519 = 3;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Cryptography/Hashing/SHA3Keccak.cs:
--------------------------------------------------------------------------------
1 | using Org.BouncyCastle.Crypto.Digests;
2 |
3 | namespace Phantasma.Core.Hashing
4 | {
5 | public static class SHA3Keccak
6 | {
7 | public static byte[] CalculateHash(byte[] value)
8 | {
9 | var digest = new KeccakDigest(256);
10 | var output = new byte[digest.GetDigestSize()];
11 | digest.BlockUpdate(value, 0, value.Length);
12 | digest.DoFinal(output, 0);
13 | return output;
14 | }
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/Phantasma.Infrastructure/src/API/DefaultAvatar.cs:
--------------------------------------------------------------------------------
1 | namespace Phantasma.Infrastructure
2 | {
3 | public static class DefaultAvatar
4 | {
5 | public readonly static string Data = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAJFBMVEWcnJz////39/etra3e3t6lpaW1tbXn5+fW1tbv7+/Ozs69vb2ss4cPAAAAk0lEQVQoz2OgJWA2QOWnKAqVIfM5BIGgAUlgIUhAAsFnEwSDBLgAC0SgAC7ABBEQhQsYQgSEMQRwa2GHGopu7QaEQxpBfBF0pzsg+3WioKAkkn9ZHcFaAuACRhBDleEaFCECQjBNQYJQoAoVcIQJiCA5Cx4iCIcjHB+IEBCFBigcSMHMRDV1IkJAEiygiBAQYmAAABD5F4JgcTScAAAAAElFTkSuQmCC";
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Phantasma.Infrastructure/src/RocksDB/Phantasma.RocksDB.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.1
4 | 40
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Phantasma.Node/Authentication/BasicAuthenticationExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Authentication;
2 |
3 | namespace Phantasma.Node.Authentication;
4 |
5 | public static class BasicAuthenticationExtensions
6 | {
7 | public static AuthenticationBuilder AddBasicAuthentication(this AuthenticationBuilder builder)
8 | {
9 | return builder.AddScheme(
10 | BasicAuthenticationDefaults.AuthenticationScheme, options => options.Realm = "Phantasma");
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Phantasma.Node/Caching/IEndpointCacheManager.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using Microsoft.Extensions.Primitives;
4 |
5 | namespace Phantasma.Node.Caching;
6 |
7 | public interface IEndpointCacheManager
8 | {
9 | Task Add(string key, string content, int duration, string tag = null);
10 |
11 | Task Get(string route, IEnumerable> queryParams,
12 | string tag = null);
13 |
14 | Task Invalidate(string tag = null);
15 | }
16 |
--------------------------------------------------------------------------------
/Tendermint/Extensions/IntExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Google.Protobuf;
3 |
4 | namespace Types.Extensions
5 | {
6 | public static class IntExtensions
7 | {
8 | public static ByteString ToByteString(this int value)
9 | {
10 | var buffer = BitConverter.GetBytes(value);
11 | if (BitConverter.IsLittleEndian)
12 | {
13 | Array.Reverse(buffer);
14 | }
15 |
16 | return ByteString.CopyFrom(buffer, 0, buffer.Length);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Phantasma.Node/Chains/Neo2/Asset.cs:
--------------------------------------------------------------------------------
1 | using Neo;
2 |
3 | namespace Phantasma.Node.Chains
4 | {
5 | public class Asset
6 | {
7 | public UInt256 hash;
8 | public string name;
9 | }
10 |
11 | public enum AssetType : byte
12 | {
13 | CreditFlag = 0x40,
14 | DutyFlag = 0x80,
15 |
16 | GoverningToken = 0x00,
17 | UtilityToken = 0x01,
18 | Currency = 0x08,
19 | Share = DutyFlag | 0x10,
20 | Invoice = DutyFlag | 0x18,
21 | Token = CreditFlag | 0x20,
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/privval/service.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.privval;
3 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/privval";
4 |
5 | import "tendermint/privval/types.proto";
6 |
7 | //----------------------------------------
8 | // Service Definition
9 |
10 | service PrivValidatorAPI {
11 | rpc GetPubKey(PubKeyRequest) returns (PubKeyResponse);
12 | rpc SignVote(SignVoteRequest) returns (SignedVoteResponse);
13 | rpc SignProposal(SignProposalRequest) returns (SignedProposalResponse);
14 | }
15 |
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/version/types.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.version;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/version";
5 |
6 | import "gogoproto/gogo.proto";
7 |
8 | // Consensus captures the consensus rules for processing a block in the blockchain,
9 | // including all blockchain data structures and the rules of the application's
10 | // state transition machine.
11 | message Consensus {
12 | option (gogoproto.equal) = true;
13 |
14 | uint64 block = 1;
15 | uint64 app = 2;
16 | }
17 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/IExecutionFrame.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Numerics;
4 | using System.Collections.Generic;
5 | using System.Security.Policy;
6 |
7 | namespace Phantasma.Core
8 | {
9 | public interface IExecutionFrame
10 | {
11 | public VMObject[] Registers { get; }
12 |
13 | uint Offset { get; } // current instruction pointer **before** the frame was entered
14 | IExecutionContext Context { get; }
15 | IVirtualMachine VM { get; }
16 |
17 | VMObject GetRegister(int index);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/CodeGen/Assembler/Label.cs:
--------------------------------------------------------------------------------
1 | namespace Phantasma.Business.Assembler
2 | {
3 | internal class Label : Semanteme
4 | {
5 | public readonly string Name;
6 |
7 | public Label(uint lineNumber, string name) : base(lineNumber)
8 | {
9 | this.Name = name;
10 | }
11 |
12 | public override void Process(ScriptBuilder sb)
13 | {
14 | sb.EmitLabel(Name);
15 | }
16 |
17 | public override string ToString()
18 | {
19 | return Name;
20 | }
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/Blockchain/Interop.cs:
--------------------------------------------------------------------------------
1 | using Phantasma.Core;
2 |
3 | namespace Phantasma.Business
4 | {
5 | public static class InteropUtils
6 | {
7 | public static PhantasmaKeys GenerateInteropKeys(PhantasmaKeys genesisKeys, Hash genesisHash, string platformName)
8 | {
9 | var temp = $"{genesisKeys.ToWIF()}{genesisHash.ToString()}{platformName}";
10 | temp = temp.ToUpper();
11 |
12 | var privateKey = CryptoExtensions.Sha256(temp);
13 | var key = new PhantasmaKeys(privateKey);
14 | return key;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Phantasma.Core/tests/AddressTests.cs:
--------------------------------------------------------------------------------
1 | using Phantasma.Core;
2 | using Shouldly;
3 | using System.Text.Json.Nodes;
4 | using System.Collections.Generic;
5 | using Xunit;
6 | using static Phantasma.Core.WalletLink;
7 |
8 | namespace Phantasma.Core.Tests
9 | {
10 | public class AddressTests
11 | {
12 | [Fact]
13 | public void null_address_test()
14 | {
15 | var address = Address.Null;
16 | address.ToByteArray().Length.ShouldBe(Address.LengthInBytes);
17 | address.ToByteArray().ShouldBe(new byte[Address.LengthInBytes]);
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Phantasma.Node/Chains/Ethereum/EthEvents.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using Nethereum.Contracts;
3 | using Nethereum.ABI.FunctionEncoding.Attributes;
4 |
5 | namespace Phantasma.Node.Chains
6 | {
7 | [Event("Swap")]
8 | public class SwapEventDTO : IEventDTO
9 | {
10 | [Parameter("address", "_from", 1, true)]
11 | public virtual string From { get; set; }
12 | [Parameter("address", "_to", 2, true)]
13 | public virtual string To { get; set; }
14 | [Parameter("uint256", "_value", 3, false)]
15 | public virtual BigInteger Value { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/IAPIResult.cs:
--------------------------------------------------------------------------------
1 | using System.Text.Json;
2 | using System.Text.Json.Nodes;
3 |
4 | namespace Phantasma.Core
5 | {
6 | public struct ErrorResult
7 | {
8 | public string error;
9 | }
10 |
11 | public static class APIUtils
12 | {
13 | public static JsonNode FromAPIResult(object input)
14 | {
15 | return FromObject(input);
16 | }
17 |
18 | private static JsonNode FromObject(object input)
19 | {
20 | return JsonNode.Parse(JsonSerializer.Serialize(input, input.GetType()));
21 | }
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: csharp
2 |
3 | os:
4 | - linux
5 |
6 | dist: trusty
7 | sudo: required
8 |
9 | mono: none
10 | dotnet: 3.1.0
11 |
12 | before_install:
13 | - cd Phantasma.Tests
14 |
15 | script:
16 | - dotnet restore
17 | - dotnet test
18 |
19 | after_success:
20 | - wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
21 | - chmod +x send.sh
22 | - ./send.sh success $WEBHOOK_URL
23 | after_failure:
24 | - wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
25 | - chmod +x send.sh
26 | - ./send.sh failure $WEBHOOK_URL
27 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Cryptography/Entropy.cs:
--------------------------------------------------------------------------------
1 | using Phantasma.Shared.Utils;
2 | using System;
3 |
4 | namespace Phantasma.Core
5 | {
6 | public static class Entropy
7 | {
8 | private static System.Security.Cryptography.RandomNumberGenerator rnd = System.Security.Cryptography.RandomNumberGenerator.Create();
9 |
10 | public static byte[] GetRandomBytes(int targetLength)
11 | {
12 | var bytes = new byte[targetLength];
13 | lock (rnd)
14 | {
15 | rnd.GetBytes(bytes);
16 | }
17 |
18 | return bytes;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Phantasma.Infrastructure/src/Pay/Phantasma.Pay.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 | 40
5 | C:\code\PhantasmaSpook\Backup\Phantasma.Pay\
6 | Current
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/types/block.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.types;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/types";
5 |
6 | import "gogoproto/gogo.proto";
7 | import "tendermint/types/types.proto";
8 | import "tendermint/types/evidence.proto";
9 |
10 | message Block {
11 | Header header = 1 [(gogoproto.nullable) = false];
12 | Data data = 2 [(gogoproto.nullable) = false];
13 | tendermint.types.EvidenceList evidence = 3 [(gogoproto.nullable) = false];
14 | Commit last_commit = 4;
15 | }
16 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/CodeGen/Core/Nodes/ImportNode.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace Phantasma.Business.Core.Nodes
5 | {
6 | public class ImportNode : CompilerNode
7 | {
8 | public string reference;
9 |
10 | public ImportNode(ModuleNode owner) : base(owner)
11 | {
12 | owner.imports.Add(this);
13 | }
14 |
15 | public override IEnumerable Nodes => Enumerable.Empty();
16 |
17 | public override string ToString()
18 | {
19 | return base.ToString() + "=>" + this.reference;
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/.github/workflows/dotnet-core.yml:
--------------------------------------------------------------------------------
1 | name: .NET Core
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | build:
7 |
8 | runs-on: ubuntu-latest
9 |
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Setup .NET Core
13 | uses: actions/setup-dotnet@v1
14 | with:
15 | dotnet-version: 6.0.x
16 | - name: Install dependencies
17 | run: |
18 | sudo apt-get install libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev libzstd-dev librocksdb-dev
19 | dotnet restore
20 | - name: Build
21 | run: dotnet build --configuration Release --no-restore
22 | - name: Test
23 | run: dotnet test --no-restore --verbosity normal
24 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/INativeContract.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using Phantasma.Core.Context;
3 |
4 | namespace Phantasma.Core;
5 |
6 | public interface INativeContract
7 | {
8 | string Name { get; }
9 | NativeContractKind Kind { get; }
10 | ContractInterface ABI { get; }
11 | BigInteger Order { get; } // TODO remove this?
12 | IRuntime Runtime { get; }
13 | Address Address { get; }
14 | void SetRuntime(IRuntime runtime);
15 | void LoadFromStorage(StorageContext storage);
16 | void SaveChangesToStorage();
17 | bool HasInternalMethod(string methodName);
18 | object CallInternalMethod(IRuntime runtime, string name, object[] args);
19 | }
20 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Cryptography/Hashing/SHA256.cs:
--------------------------------------------------------------------------------
1 | using Org.BouncyCastle.Crypto.Digests;
2 |
3 | namespace Phantasma.Core.Hashing
4 | {
5 | public class SHA256
6 | {
7 | public byte[] ComputeHash(byte[] data)
8 | {
9 | return ComputeHash(data, 0, (uint)data.Length);
10 | }
11 |
12 | public byte[] ComputeHash(byte[] data, uint offset, uint length)
13 | {
14 | var digest = new Sha256Digest();
15 | var output = new byte[digest.GetDigestSize()];
16 | digest.BlockUpdate(data, (int)offset, (int)length);
17 | digest.DoFinal(output, 0);
18 | return output;
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/Tendermint.RPC/src/NodeRpcException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Tendermint.RPC
6 | {
7 | public class NodeRpcException : Exception
8 | {
9 | public Error Error { get; }
10 |
11 | public NodeRpcException(String message) : base(message)
12 | {
13 | }
14 |
15 | public NodeRpcException(String message, Error error) : base(message)
16 | {
17 | Error = error;
18 | }
19 |
20 | public NodeRpcException(String message, Exception innerException, Error error) : base(message, innerException)
21 | {
22 | Error = error;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/Blockchain/CustomContract.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using Phantasma.Core;
3 | using Phantasma.Shared;
4 |
5 | namespace Phantasma.Business
6 | {
7 | public sealed class CustomContract : SmartContract, ICustomContract
8 | {
9 | private string _name;
10 | public override string Name => _name;
11 |
12 | public byte[] Script { get; private set; }
13 |
14 | public CustomContract(string name, byte[] script, ContractInterface abi) : base()
15 | {
16 | Throw.IfNull(script, nameof(script));
17 | this.Script = script;
18 |
19 | _name = name;
20 |
21 | this.ABI = abi;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/CodeGen/Core/Nodes/ExitNode.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace Phantasma.Business.Core.Nodes
5 | {
6 | public class ExitNode : StatementNode
7 | {
8 | public ExitNode(CompilerNode owner) : base(owner)
9 | {
10 | }
11 |
12 | public override List Emit(Compiler compiler)
13 | {
14 | var temp = new List();
15 | temp.Add(new Instruction() { source = this, target = null, a = null, op = Instruction.Opcode.Return });
16 | return temp;
17 | }
18 |
19 | public override IEnumerable Nodes => Enumerable.Empty();
20 | }
21 | }
--------------------------------------------------------------------------------
/Tendermint.RPC/src/Endpoint/UnconfirmedTxs.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using Newtonsoft.Json.Linq;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 |
7 | namespace Tendermint.RPC.Endpoint
8 | {
9 | /*
10 | {
11 | "jsonrpc": "2.0",
12 | "id": "",
13 | "result": {
14 | "n_txs": "0",
15 | "txs": []
16 | }
17 | }
18 | */
19 |
20 | public class ResultUnconfirmedTxs : IEndpointResponse
21 | {
22 | [JsonProperty("n_txs")]
23 | public string NTxs { get; set; }
24 |
25 | [JsonExtensionData, JsonProperty("txs")]
26 | public IDictionary Txs { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/IOrganization.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 |
3 | namespace Phantasma.Core
4 | {
5 | public interface IOrganization
6 | {
7 | string ID { get; }
8 | string Name { get; }
9 | Address Address { get; }
10 | byte[] Script { get; }
11 | BigInteger Size { get; } // number of members
12 |
13 | bool IsMember(Address address);
14 | bool IsWitness(Transaction tx);
15 | bool MigrateMember(IRuntime Runtime, Address admin, Address from, Address to);
16 | bool AddMember(IRuntime Runtime, Address from, Address target);
17 | bool RemoveMember(IRuntime Runtime, Address from, Address target);
18 | Address[] GetMembers();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/CodeGen/Core/Nodes/TypeNode.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace Phantasma.Business.Core.Nodes
5 | {
6 |
7 | public enum TypeKind
8 | {
9 | Unknown,
10 | Void,
11 | String,
12 | Integer,
13 | Float,
14 | Boolean,
15 | ByteArray,
16 | Struct,
17 | }
18 |
19 | public class TypeNode: CompilerNode
20 | {
21 | public TypeKind Kind;
22 |
23 | public TypeNode(CompilerNode owner, TypeKind kind) : base(owner)
24 | {
25 | this.Kind = kind;
26 | }
27 |
28 | public override IEnumerable Nodes => Enumerable.Empty();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/IOracleReader.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using System.Collections.Generic;
3 | using Phantasma.Shared.Types;
4 |
5 | namespace Phantasma.Core;
6 |
7 | public interface IOracleReader
8 | {
9 | BigInteger ProtocolVersion { get; }
10 | IEnumerable Entries { get; }
11 | string GetCurrentHeight(string platformName, string chainName);
12 | void SetCurrentHeight(string platformName, string chainName, string height);
13 | List ReadAllBlocks(string platformName, string chainName);
14 | T Read(Timestamp time, string url) where T : class;
15 | InteropTransaction ReadTransaction(string platform, string chain, Hash hash);
16 | void Clear();
17 | void MergeTxData();
18 | }
19 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/CodeGen/Core/Nodes/CallNode.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace Phantasma.Business.Core.Nodes
5 | {
6 | public class CallNode: StatementNode
7 | {
8 | public MethodNode method;
9 |
10 | public CallNode(CompilerNode owner) : base(owner)
11 | {
12 | }
13 |
14 | public override IEnumerable Nodes => Enumerable.Empty();
15 |
16 | public override List Emit(Compiler compiler)
17 | {
18 | var temp = new List();
19 | temp.Add(new Instruction() { source = this, target = method.name, op = Instruction.Opcode.Call });
20 | return temp;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/CodeGen/Core/Nodes/WhileNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Phantasma.Business.Core.Nodes
5 | {
6 | public class WhileNode : StatementNode
7 | {
8 | public ExpressionNode expr;
9 | public StatementNode body;
10 |
11 | public WhileNode(BlockNode owner) : base(owner)
12 | {
13 | }
14 |
15 | public override IEnumerable Nodes
16 | {
17 | get
18 | {
19 | yield return expr;
20 | yield return body;
21 | }
22 | }
23 |
24 | public override List Emit(Compiler compiler)
25 | {
26 | throw new NotImplementedException();
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/Phantasma.Business/src/CodeGen/Core/Nodes/ParameterNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Phantasma.Business.Core.Nodes
5 | {
6 | public class ParameterNode : CompilerNode
7 | {
8 | public DeclarationNode decl;
9 |
10 | public ParameterNode(MethodNode owner) : base(owner)
11 | {
12 | owner.parameters.Add(this);
13 | }
14 |
15 | public override string ToString()
16 | {
17 | return base.ToString() + "=>" + this.decl.ToString();
18 | }
19 |
20 | public override IEnumerable Nodes
21 | {
22 | get
23 | {
24 | yield return decl;
25 | yield break;
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/ExecutionContext.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Phantasma.Core
4 | {
5 | public abstract class ExecutionContext
6 | {
7 | public abstract string Name { get; }
8 |
9 | private Address _address;
10 | public Address Address {
11 | get
12 | {
13 | if (_address.IsNull)
14 | {
15 | _address = Address.FromHash(Name);
16 | }
17 |
18 | return _address;
19 | }
20 | }
21 |
22 | public abstract ExecutionState Execute(ExecutionFrame frame, Stack stack);
23 |
24 | public override string ToString()
25 | {
26 | return Name;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/CodeGen/Core/Nodes/StatementNode.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Phantasma.Business.Core.Nodes
4 | {
5 | public abstract class StatementNode : CompilerNode
6 | {
7 | public StatementNode(CompilerNode owner) : base(owner)
8 | {
9 | }
10 |
11 | public abstract List Emit(Compiler compiler);
12 |
13 | public MethodNode FindParentMethod()
14 | {
15 | var node = Owner;
16 | while (node != null)
17 | {
18 | if (node is MethodNode)
19 | {
20 | return (MethodNode)node;
21 | }
22 |
23 | node = node.Owner;
24 | }
25 |
26 | return null;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/Phantasma.Core/src/Utils/StreamUtils.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace Phantasma.Core
4 | {
5 | public static class StreamExtensions
6 | {
7 | public static uint ReadUInt24(this BinaryReader reader)
8 | {
9 | var b1 = reader.ReadByte();
10 | var b2 = reader.ReadByte();
11 | var b3 = reader.ReadByte();
12 | return
13 | (((uint)b1) << 16) |
14 | (((uint)b2) << 8) |
15 | ((uint)b3);
16 | }
17 |
18 | public static void WriteUInt24(this BinaryWriter writer, uint val)
19 | {
20 | writer.Write((byte)((val >> 16) & 0xFF));
21 | writer.Write((byte)((val >> 8) & 0xFF));
22 | writer.Write((byte)(val & 0xFF));
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/mempool/message.go:
--------------------------------------------------------------------------------
1 | package mempool
2 |
3 | import (
4 | "fmt"
5 |
6 | "github.com/gogo/protobuf/proto"
7 | )
8 |
9 | // Wrap implements the p2p Wrapper interface and wraps a mempool message.
10 | func (m *Message) Wrap(pb proto.Message) error {
11 | switch msg := pb.(type) {
12 | case *Txs:
13 | m.Sum = &Message_Txs{Txs: msg}
14 |
15 | default:
16 | return fmt.Errorf("unknown message: %T", msg)
17 | }
18 |
19 | return nil
20 | }
21 |
22 | // Unwrap implements the p2p Wrapper interface and unwraps a wrapped mempool
23 | // message.
24 | func (m *Message) Unwrap() (proto.Message, error) {
25 | switch msg := m.Sum.(type) {
26 | case *Message_Txs:
27 | return m.GetTxs(), nil
28 |
29 | default:
30 | return nil, fmt.Errorf("unknown message: %T", msg)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/Phantasma.Business.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | disable
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Phantasma.Core/tests/Phantasma.Core.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 |
8 |
9 |
10 |
11 | all
12 | runtime; build; native; contentfiles; analyzers; buildtransitive
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/CodeGen/Core/Nodes/ClassNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Phantasma.Business.Core.Nodes
5 | {
6 | public class ClassNode : CompilerNode
7 | {
8 | public string name;
9 | public string parent;
10 | public bool isAbstract;
11 | public bool isStatic;
12 | public Visibility visibility;
13 |
14 | public List methods = new List();
15 |
16 | public ClassNode(ModuleNode owner) : base(owner)
17 | {
18 | owner.classes.Add(this);
19 | }
20 |
21 | public override IEnumerable Nodes => methods;
22 |
23 | public override string ToString()
24 | {
25 | return base.ToString() + "=>" + this.name;
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/Phantasma.Infrastructure/src/API/Controllers/ValidatorController.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Microsoft.AspNetCore.Mvc;
3 | using Phantasma.Core;
4 |
5 | namespace Phantasma.Infrastructure.Controllers
6 | {
7 | public class ValidatorController : BaseControllerV1
8 | {
9 | [APIInfo(typeof(ValidatorResult[]), "Returns an array of available validators.", false, 300)]
10 | [HttpGet("GetValidators")]
11 | public ValidatorResult[] GetValidators()
12 | {
13 | var nexus = NexusAPI.GetNexus();
14 |
15 | var validators = nexus.GetValidators().
16 | Where(x => !x.address.IsNull).
17 | Select(x => new ValidatorResult() { address = x.address.ToString(), type = x.type.ToString() });
18 |
19 | return validators.ToArray();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/p2p/conn.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.p2p;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p";
5 |
6 | import "gogoproto/gogo.proto";
7 | import "tendermint/crypto/keys.proto";
8 |
9 | message PacketPing {}
10 |
11 | message PacketPong {}
12 |
13 | message PacketMsg {
14 | int32 channel_id = 1 [(gogoproto.customname) = "ChannelID"];
15 | bool eof = 2 [(gogoproto.customname) = "EOF"];
16 | bytes data = 3;
17 | }
18 |
19 | message Packet {
20 | oneof sum {
21 | PacketPing packet_ping = 1;
22 | PacketPong packet_pong = 2;
23 | PacketMsg packet_msg = 3;
24 | }
25 | }
26 |
27 | message AuthSigMessage {
28 | tendermint.crypto.PublicKey pub_key = 1 [(gogoproto.nullable) = false];
29 | bytes sig = 2;
30 | }
31 |
--------------------------------------------------------------------------------
/Tendermint.RPC/src/RpcRequest.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Tendermint.RPC
7 | {
8 | public class RpcRequest
9 | {
10 | /*
11 | {
12 | "method": "broadcast_tx_sync",
13 | "jsonrpc": "2.0",
14 | "params": [
15 | "abc"
16 | ],
17 | "id": "dontcare"
18 | }
19 | */
20 |
21 | [JsonProperty("method")]
22 | public string Method { get; set; }
23 |
24 | [JsonProperty("jsonrpc")]
25 | public string JsonRpc { get; set; }
26 |
27 | [JsonProperty("params")]
28 | public List Params { get; set; }
29 |
30 | [JsonProperty("id")]
31 | public string Id { get; set; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Tendermint/Extensions/StringExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using Google.Protobuf;
4 |
5 | namespace Types.Extensions
6 | {
7 | public static class StringExtensions
8 | {
9 | public static ByteString ToByteString(this string input)
10 | {
11 | var base64String = Convert.ToBase64String(Encoding.UTF8.GetBytes(input));
12 | return ByteString.FromBase64(base64String);
13 | }
14 |
15 | // https://stackoverflow.com/a/311179/959687
16 | public static byte[] StringToByteArray(this string hex)
17 | {
18 | var numberChars = hex.Length;
19 | var bytes = new byte[numberChars / 2];
20 | for (var i = 0; i < numberChars; i += 2)
21 | bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
22 | return bytes;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/types/validator.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.types;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/types";
5 |
6 | import "gogoproto/gogo.proto";
7 | import "tendermint/crypto/keys.proto";
8 |
9 | message ValidatorSet {
10 | repeated Validator validators = 1;
11 | Validator proposer = 2;
12 | int64 total_voting_power = 3;
13 | }
14 |
15 | message Validator {
16 | bytes address = 1;
17 | tendermint.crypto.PublicKey pub_key = 2 [(gogoproto.nullable) = false];
18 | int64 voting_power = 3;
19 | int64 proposer_priority = 4;
20 | }
21 |
22 | message SimpleValidator {
23 | tendermint.crypto.PublicKey pub_key = 1;
24 | int64 voting_power = 2;
25 | }
26 |
--------------------------------------------------------------------------------
/Tendermint.RPC/src/JsonNetSerializer.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using RestSharp;
3 | using RestSharp.Serialization;
4 |
5 | namespace Tendermint.RPC
6 | {
7 | public class JsonNetSerializer : IRestSerializer
8 | {
9 | public string Serialize(object obj) => JsonConvert.SerializeObject(obj);
10 |
11 | public string Serialize(Parameter parameter) => JsonConvert.SerializeObject(parameter.Value);
12 |
13 | public T Deserialize(IRestResponse response) => JsonConvert.DeserializeObject(response.Content);
14 |
15 | public string[] SupportedContentTypes { get; } =
16 | {
17 | "application/json", "text/json", "text/x-json", "text/javascript", "*+json"
18 | };
19 |
20 | public string ContentType { get; set; } = "application/json";
21 |
22 | public DataFormat DataFormat { get; } = DataFormat.Json;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/clean.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | rm --force -r .vs
4 | rm --force -r Phantasma.Business/src/bin
5 | rm --force -r Phantasma.Business/src/obj
6 | rm --force -r Phantasma.Core/src/bin
7 | rm --force -r Phantasma.Core/src/obj
8 | rm --force -r Phantasma.Core.Tests/bin
9 | rm --force -r Phantasma.Core.Tests/obj
10 | rm --force -r Phantasma.Infrastructure/src/bin
11 | rm --force -r Phantasma.Infrastructure/src/obj
12 | rm --force -r Phantasma.Shared/src/bin
13 | rm --force -r Phantasma.Shared/src/obj
14 | rm --force -r Phantasma.Node/bin
15 | rm --force -r Phantasma.Node/obj
16 | rm --force -r Phantasma.Tests/bin
17 | rm --force -r Phantasma.Tests/obj
18 | rm --force -r Phantasma.Tests/Phantasma.Simulator/bin
19 | rm --force -r Phantasma.Tests/Phantasma.Simulator/obj
20 | rm --force -r Tendermint/bin
21 | rm --force -r Tendermint/obj
22 | rm --force -r Tendermint.RPC/bin
23 | rm --force -r Tendermint.RPC/obj
24 |
25 |
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/rpc/grpc/types.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.rpc.grpc;
3 | option go_package = "github.com/tendermint/tendermint/rpc/grpc;coregrpc";
4 |
5 | import "tendermint/abci/types.proto";
6 |
7 | //----------------------------------------
8 | // Request types
9 |
10 | message RequestPing {}
11 |
12 | message RequestBroadcastTx {
13 | bytes tx = 1;
14 | }
15 |
16 | //----------------------------------------
17 | // Response types
18 |
19 | message ResponsePing {}
20 |
21 | message ResponseBroadcastTx {
22 | tendermint.abci.ResponseCheckTx check_tx = 1;
23 | tendermint.abci.ResponseDeliverTx deliver_tx = 2;
24 | }
25 |
26 | //----------------------------------------
27 | // Service Definition
28 |
29 | service BroadcastAPI {
30 | rpc Ping(RequestPing) returns (ResponsePing);
31 | rpc BroadcastTx(RequestBroadcastTx) returns (ResponseBroadcastTx);
32 | }
33 |
--------------------------------------------------------------------------------
/Phantasma.Business/tests/Phantasma.Business.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 |
8 |
9 |
10 |
11 | all
12 | runtime; build; native; contentfiles; analyzers; buildtransitive
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Phantasma.Shared/src/Utils/ByteArrayComparer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace Phantasma.Shared.Utils
6 | {
7 | public class ByteArrayComparer : IEqualityComparer
8 | {
9 | public bool Equals(byte[] left, byte[] right)
10 | {
11 | return left.CompareBytes(right);
12 | }
13 |
14 | public int GetHashCode(byte[] key)
15 | {
16 | Throw.IfNull(key, nameof(key));
17 | unchecked // disable overflow, for the unlikely possibility that you
18 | { // are compiling with overflow-checking enabled
19 | int hash = 27;
20 | for (int i=0; i();
13 |
14 | var nexus = NexusAPI.GetNexus();
15 |
16 | var chains = nexus.GetChains(nexus.RootStorage);
17 | foreach (var chainName in chains)
18 | {
19 | var chain = nexus.GetChainByName(chainName);
20 | var single = NexusAPI.FillChain(chain);
21 | objs.Add(single);
22 | }
23 |
24 | return objs.ToArray();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Phantasma.Business/tests/Blockchain/TransactionTest.cs:
--------------------------------------------------------------------------------
1 | using Phantasma.Core;
2 | using Shouldly;
3 | using System.Text.Json.Nodes;
4 | using System.Collections.Generic;
5 | using Xunit;
6 | using static Phantasma.Core.WalletLink;
7 |
8 | namespace Phantasma.Business.Tests
9 | {
10 | public class TransactionTest
11 | {
12 | [Fact]
13 | public void null_transaction_test()
14 | {
15 | var transaction = new Phantasma.Core.Transaction();
16 | transaction.NexusName.ShouldBe(null);
17 | transaction.ChainName.ShouldBe(null);
18 | transaction.Hash.ShouldBeOfType();
19 | transaction.HasSignatures.ShouldBe(false);
20 | transaction.Signatures.ShouldBe(null);
21 | transaction.Script.ShouldBe(null);
22 | transaction.Payload.ShouldBe(null);
23 | }
24 |
25 | [Fact]
26 | public void is_signed_by()
27 | {
28 |
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/IArchive.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 | using System.Numerics;
4 | using Phantasma.Shared.Types;
5 |
6 | namespace Phantasma.Core;
7 |
8 | public interface IArchive
9 | {
10 | string Name { get; }
11 | Hash Hash { get; }
12 | MerkleTree MerkleTree { get; }
13 | BigInteger Size { get; }
14 | Timestamp Time { get; }
15 | IArchiveEncryption Encryption { get; }
16 | BigInteger BlockCount { get; }
17 | IEnumerable Owners { get; }
18 | int OwnerCount { get; }
19 | IEnumerable MissingBlockIndices { get; }
20 | int MissingBlockCount { get; }
21 | IEnumerable BlockHashes { get; }
22 | void SerializeData(BinaryWriter writer);
23 | byte[] ToByteArray();
24 | void UnserializeData(BinaryReader reader);
25 | void AddOwner(Address address);
26 | void RemoveOwner(Address address);
27 | bool IsOwner(Address address);
28 | void AddMissingBlock(int blockIndex);
29 | }
30 |
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/p2p/pex.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.p2p;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p";
5 |
6 | import "gogoproto/gogo.proto";
7 |
8 | message PexAddress {
9 | string id = 1 [(gogoproto.customname) = "ID"];
10 | string ip = 2 [(gogoproto.customname) = "IP"];
11 | uint32 port = 3;
12 | }
13 |
14 | message PexRequest {}
15 |
16 | message PexResponse {
17 | repeated PexAddress addresses = 1 [(gogoproto.nullable) = false];
18 | }
19 |
20 | message PexAddressV2 {
21 | string url = 1 [(gogoproto.customname) = "URL"];
22 | }
23 |
24 | message PexRequestV2 {}
25 |
26 | message PexResponseV2 {
27 | repeated PexAddressV2 addresses = 1 [(gogoproto.nullable) = false];
28 | }
29 |
30 | message PexMessage {
31 | oneof sum {
32 | PexRequest pex_request = 1;
33 | PexResponse pex_response = 2;
34 | PexRequestV2 pex_request_v2 = 3;
35 | PexResponseV2 pex_response_v2 = 4;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Phantasma.Node/Hosting/EventBusBackgroundService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 | using Foundatio.Extensions.Hosting.Startup;
4 | using Phantasma.Node.Events;
5 | using Microsoft.Extensions.Hosting;
6 |
7 | namespace Phantasma.Node.Hosting;
8 |
9 | public class EventBusBackgroundService : BackgroundService
10 | {
11 | private readonly IEventBus _bus;
12 | private readonly StartupActionsContext _startupContext;
13 |
14 | public EventBusBackgroundService(
15 | IEventBus bus,
16 | StartupActionsContext startupContext
17 | )
18 | {
19 | _bus = bus;
20 | _startupContext = startupContext;
21 | }
22 |
23 | protected override async Task ExecuteAsync(
24 | CancellationToken stoppingToken
25 | )
26 | {
27 | if (_startupContext != null)
28 | {
29 | await _startupContext.WaitForStartupAsync(stoppingToken);
30 | }
31 |
32 | await _bus.Run(stoppingToken);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Phantasma.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | disable
5 |
6 |
7 | true
8 |
9 |
10 | true
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Tendermint.RPC/src/Endpoint/Blockchain.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Tendermint.RPC.Endpoint
7 | {
8 | /*
9 | Get block headers for minHeight <= height <= maxHeight. Block headers are returned in descending order (highest first). Query Parameters
10 | Parameter Type Default Required Description
11 | minHeight int64 false true height of blockchain
12 | maxHeight int64 false true height of blockchain
13 |
14 | Return Type: List of blocks
15 |
16 | type ResultBlockchainInfo struct {
17 | LastHeight int64
18 | BlockMetas []*types.BlockMeta
19 | }
20 | */
21 |
22 | public class ResultBlockchainInfo : IEndpointResponse
23 | {
24 | [JsonProperty("last_height")]
25 | public string LastHeight { get; set; }
26 |
27 | [JsonProperty("block_metas")]
28 | public List BlockMetas { get; set; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Tendermint/Tendermint.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 |
5 |
6 |
7 |
8 |
9 |
10 |
22 |
23 |
--------------------------------------------------------------------------------
/Tendermint.RPC/Tendermint.RPC.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 |
5 |
6 |
7 |
8 |
9 |
10 |
22 |
23 |
--------------------------------------------------------------------------------
/Phantasma.Infrastructure/src/API/Controllers/OrganizationController.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Microsoft.AspNetCore.Mvc;
3 |
4 | namespace Phantasma.Infrastructure.Controllers
5 | {
6 | public class OrganizationController : BaseControllerV1
7 | {
8 | [APIInfo(typeof(OrganizationResult), "Returns info about an organization.", false, 60)]
9 | [HttpGet("GetOrganization")]
10 | public OrganizationResult GetOrganization(string ID)
11 | {
12 | var nexus = NexusAPI.GetNexus();
13 |
14 | if (!nexus.OrganizationExists(nexus.RootStorage, ID))
15 | {
16 | throw new APIException("invalid organization");
17 | }
18 |
19 | var org = nexus.GetOrganizationByName(nexus.RootStorage, ID);
20 | var members = org.GetMembers();
21 |
22 | return new OrganizationResult()
23 | {
24 | id = ID,
25 | name = org.Name,
26 | members = members.Select(x => x.Text).ToArray(),
27 | };
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Phantasma.Node/Converters/EnumerableJsonConverterFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using System.Text.Json;
5 | using System.Text.Json.Serialization;
6 |
7 | namespace Phantasma.Node.Converters;
8 |
9 | public class EnumerableJsonConverterFactory : JsonConverterFactory
10 | {
11 | public override bool CanConvert(Type typeToConvert)
12 | {
13 | if (!typeToConvert.IsGenericType) return false;
14 |
15 | var realType = typeToConvert.GetGenericTypeDefinition();
16 |
17 | return realType.IsAssignableTo(typeof(IEnumerable<>));
18 | }
19 |
20 | public override JsonConverter CreateConverter(Type type, JsonSerializerOptions options)
21 | {
22 | var valueType = type.GetGenericArguments()[0];
23 |
24 | var converter = (JsonConverter)Activator.CreateInstance(
25 | typeof(EnumerableJsonConverter<>).MakeGenericType(valueType), BindingFlags.Instance | BindingFlags.Public,
26 | null, new object[] { options }, null);
27 |
28 | return converter;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Phantasma.Tests/Phantasma.Neo/Utils/LuxUtils.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Phantasma.Neo.Utils;
3 |
4 | // Testing methods:
5 | // bool IsValidAddress(this string address)
6 |
7 | namespace Phantasma.Tests
8 | {
9 | [TestClass]
10 | public class PhantasmaNeoUtilsTests
11 | {
12 | [TestMethod]
13 | public void IsValidAddressTest()
14 | {
15 | // Checking valid address
16 | Assert.IsTrue("AP6ZkjweW4NGskMca2KH2cchNJbFWW2vZe".IsValidAddress());
17 |
18 | // Checking invalid address
19 | Assert.IsFalse("AP6ZkjweW4NGskMca2KH2cchNJbFWW2vZee".IsValidAddress());
20 |
21 | // Checking invalid address
22 | Assert.IsFalse("AP6ZkjweW4NGskMca2KH2cchNJbFWW2vZ".IsValidAddress());
23 |
24 | // Checking invalid address
25 | Assert.IsFalse("AP6ZkjweW4NGskMca2KH2cchNJbFWW2vZE".IsValidAddress());
26 |
27 | // Checking invalid address
28 | Assert.IsFalse("AP6ZkjweW4NGskMca2KH2cchNJbFWW2lOI".IsValidAddress());
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/crypto/proof.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.crypto;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto";
5 |
6 | import "gogoproto/gogo.proto";
7 |
8 | message Proof {
9 | int64 total = 1;
10 | int64 index = 2;
11 | bytes leaf_hash = 3;
12 | repeated bytes aunts = 4;
13 | }
14 |
15 | message ValueOp {
16 | // Encoded in ProofOp.Key.
17 | bytes key = 1;
18 |
19 | // To encode in ProofOp.Data
20 | Proof proof = 2;
21 | }
22 |
23 | message DominoOp {
24 | string key = 1;
25 | string input = 2;
26 | string output = 3;
27 | }
28 |
29 | // ProofOp defines an operation used for calculating Merkle root
30 | // The data could be arbitrary format, providing nessecary data
31 | // for example neighbouring node hash
32 | message ProofOp {
33 | string type = 1;
34 | bytes key = 2;
35 | bytes data = 3;
36 | }
37 |
38 | // ProofOps is Merkle proof defined by the list of ProofOps
39 | message ProofOps {
40 | repeated ProofOp ops = 1 [(gogoproto.nullable) = false];
41 | }
42 |
--------------------------------------------------------------------------------
/Tendermint/proto/tendermint/consensus/message_test.go:
--------------------------------------------------------------------------------
1 | package consensus_test
2 |
3 | import (
4 | "encoding/hex"
5 | "math"
6 | "testing"
7 |
8 | "github.com/gogo/protobuf/proto"
9 | "github.com/stretchr/testify/require"
10 |
11 | tmcons "github.com/tendermint/tendermint/proto/tendermint/consensus"
12 | tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
13 | )
14 |
15 | func TestHasVoteVector(t *testing.T) {
16 | testCases := []struct {
17 | msg tmcons.HasVote
18 | expBytes string
19 | }{
20 | {tmcons.HasVote{1, 3, tmproto.PrevoteType, 1}, "3a080801100318012001"},
21 | {tmcons.HasVote{2, 2, tmproto.PrecommitType, 2}, "3a080802100218022002"},
22 | {tmcons.HasVote{math.MaxInt64, math.MaxInt32, tmproto.ProposalType, math.MaxInt32},
23 | "3a1808ffffffffffffffff7f10ffffffff07182020ffffffff07"},
24 | }
25 |
26 | for i, tc := range testCases {
27 | msg := tmcons.Message{&tmcons.Message_HasVote{HasVote: &tc.msg}}
28 | bz, err := proto.Marshal(&msg)
29 | require.NoError(t, err)
30 | require.Equal(t, tc.expBytes, hex.EncodeToString(bz), "test vector failed", i)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Phantasma.Business/tests/Blockchain/BlockTest.cs:
--------------------------------------------------------------------------------
1 | using Phantasma.Core;
2 | using Shouldly;
3 | using System.Text.Json.Nodes;
4 | using System.Collections.Generic;
5 | using Phantasma.Shared.Types;
6 | using Xunit;
7 | using static Phantasma.Core.WalletLink;
8 |
9 | namespace Phantasma.Business.Tests
10 | {
11 | public class BlockTest
12 | {
13 | [Fact]
14 | public void null_block_test()
15 | {
16 | var block = new Block();
17 | block.Timestamp.ShouldBe(Timestamp.Null);
18 | block.Payload.ShouldBe(null);
19 | block.Events.ShouldBe(new List());
20 | block.OracleData.ShouldBe(new OracleEntry[0]);
21 | block.TransactionCount.ShouldBe(0);
22 | // TODO: Need to check transactions to be null
23 | //block.PreviousHash.ShouldBeNull(Hash.Null);
24 | block.TransactionHashes.ShouldBe(new Hash[0]);
25 | block.Height.ShouldBe(0);
26 | block.ChainAddress.ShouldBe(Address.Null);
27 | block.Validator.ShouldBe(Address.Null);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Phantasma.Business/src/CodeGen/Core/Nodes/DeclarationNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Collections.Generic;
4 |
5 | namespace Phantasma.Business.Core.Nodes
6 | {
7 | public class DeclarationNode : CompilerNode
8 | {
9 | public string identifier;
10 | public TypeNode type;
11 |
12 | public DeclarationNode(CompilerNode owner) : base(owner)
13 | {
14 | if (owner is BlockNode)
15 | {
16 | ((BlockNode)owner).declarations.Add(this);
17 | }
18 | else
19 | if (owner is ParameterNode)
20 | {
21 | ((ParameterNode)owner).decl = this;
22 | }
23 | else
24 | {
25 | throw new Exception("Invalid owner");
26 | }
27 | }
28 |
29 | public override IEnumerable Nodes => Enumerable.Empty();
30 |
31 | public override string ToString()
32 | {
33 | return base.ToString() + "=>" + this.identifier+"/"+this.type.Kind;
34 | }
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/Phantasma.Business/src/CodeGen/Core/Nodes/AssignmentNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace Phantasma.Business.Core.Nodes
6 | {
7 | public class AssignmentNode : StatementNode
8 | {
9 | public string identifier;
10 | public ExpressionNode expr;
11 |
12 | public AssignmentNode(CompilerNode owner) : base(owner)
13 | {
14 | }
15 |
16 | public override IEnumerable Nodes
17 | {
18 | get
19 | {
20 | yield return expr;
21 | yield break;
22 | }
23 | }
24 |
25 | public override string ToString()
26 | {
27 | return base.ToString() + "=>" + this.identifier;
28 | }
29 |
30 | public override List Emit(Compiler compiler)
31 | {
32 | var temp = expr.Emit(compiler);
33 | temp.Add(new Instruction() { source = this, target = this.identifier, a = temp.Last(), op = Instruction.Opcode.Assign});
34 | return temp;
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/Tendermint.RPC/src/Endpoint/ConsensusParams.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Tendermint.RPC.Endpoint
7 | {
8 | /*
9 | {
10 | "jsonrpc": "2.0",
11 | "id": "",
12 | "result": {
13 | "block_height": "10779111",
14 | "consensus_params": {
15 | "block_size": {
16 | "max_bytes": "1048576",
17 | "max_gas": "-1"
18 | },
19 | "evidence": {
20 | "max_age": "100000"
21 | },
22 | "validator": {
23 | "pub_key_types": [
24 | "ed25519"
25 | ]
26 | }
27 | }
28 | }
29 | }
30 | */
31 |
32 | public class ResultConsensusParams : IEndpointResponse
33 | {
34 | [JsonProperty("block_height")]
35 | public string BlockHeight { get; set; }
36 |
37 | [JsonProperty("consensus_params")]
38 | public ConsensusParams ConsensusParams { get; set; }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Tendermint.RPC/src/Endpoint/BroadcastTxAsync.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Tendermint.RPC.Endpoint
6 | {
7 | /*
8 | BroadcastTxAsync
9 |
10 | This method just return transaction hash right away and there is no return from CheckTx or DeliverTx. Transaction Parameters
11 | Parameter Type Default Required Description
12 | tx Tx nil true The transaction info bytes in hex
13 |
14 | Return Parameters Checktx Result
15 |
16 | type ResultBroadcastTx struct {
17 | Code uint32
18 | Data cmn.HexBytes
19 | Log string
20 | Hash cmn.HexBytes
21 | }
22 | */
23 |
24 | /*
25 | {
26 | "error": "",
27 | "result": {
28 | "hash": "721B67C1772EA5FC7E80D70DEAA3C52034204FC60C057FF1117EE45468C1A980",
29 | "log": "",
30 | "data": "",
31 | "code": "0"
32 | },
33 | "id": "",
34 | "jsonrpc": "2.0"
35 |
36 | }
37 | */
38 | }
39 |
--------------------------------------------------------------------------------
/.github/workflows/dotnet-server.yml:
--------------------------------------------------------------------------------
1 | name: Deploy Testnet
2 |
3 | on:
4 | workflow_dispatch:
5 |
6 | jobs:
7 | build:
8 |
9 | runs-on: ubuntu-latest
10 |
11 | steps:
12 | - uses: actions/checkout@v3
13 |
14 | - name: Copy Files via scp
15 | uses: appleboy/scp-action@master
16 | with:
17 | host: ${{ secrets.HOST }}
18 | port: ${{ secrets.PORT }}
19 | username: ${{ secrets.USERNAME }}
20 | key: ${{ secrets.SSHKEY }}
21 | passphrase: ${{ secrets.PASSPHRASE }}
22 | source: "./"
23 | target: ${{ secrets.FOLDER }}
24 |
25 | - name: Building Docker in the server
26 | uses: appleboy/ssh-action@master
27 | with:
28 | host: ${{ secrets.HOST }}
29 | port: ${{ secrets.PORT }}
30 | username: ${{ secrets.USERNAME }}
31 | key: ${{ secrets.SSHKEY }}
32 | passphrase: ${{ secrets.PASSPHRASE }}
33 | script: |
34 | cd ${{ secrets.FOLDER }}
35 | echo ${{ secrets.PASS }} | sudo -S chmod u+x ./testnet_startup.sh;
36 | echo ${{ secrets.PASS }} | sudo -S ./testnet_startup.sh;
37 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/TransactionResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using Phantasma.Core;
4 |
5 | namespace Phantasma.Core;
6 |
7 | public class TransactionResult
8 | {
9 | public Hash Hash{ get; set; }
10 |
11 | public uint Code { get; set; }
12 |
13 | public VMObject Result { get; set; }
14 |
15 | public string Log { get; set; }
16 |
17 | public string Info { get; set; }
18 |
19 | public long Gas { get; set; }
20 |
21 | public long GasUsed { get; set; }
22 |
23 | public Event[] Events { get; set; }
24 |
25 | public string Codespace { get; set; }
26 |
27 |
28 | public TransactionResult() {}
29 | public TransactionResult(uint code, VMObject result, string log, string info, long gas, long gasUsed, IEnumerable events,
30 | string codespace)
31 | {
32 | this.Code = code;
33 | this.Result = result;
34 | this.Log = log;
35 | this.Info = info;
36 | this.Gas = gas;
37 | this.GasUsed = gasUsed;
38 | this.Events = events.ToArray();
39 | this.Codespace = codespace;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Phantasma.Node/DeliverTxResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using Phantasma.Core;
4 |
5 | namespace Phantasma.Business;
6 | public class DeliverTxResult
7 | {
8 | public Hash Hash { get; set; }
9 | public uint Code { get; set; }
10 |
11 | public byte[] Result { get; set; }
12 |
13 | public string Log { get; set; }
14 |
15 | public string Info { get; set; }
16 |
17 | public long Gas { get; set; }
18 |
19 | public long GasUsed { get; set; }
20 |
21 | public Event[] Events { get; set; }
22 |
23 | public string Codespace { get; set; }
24 |
25 |
26 | public DeliverTxResult() {}
27 | public DeliverTxResult(uint code, byte[] result, string log, string info, long gas, long gasUsed, IEnumerable events,
28 | string codespace)
29 | {
30 | this.Code = code;
31 | this.Result = result;
32 | this.Log = log;
33 | this.Info = info;
34 | this.Gas = gas;
35 | this.GasUsed = gasUsed;
36 | this.Events = events.ToArray();
37 | this.Codespace = codespace;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Phantasma.Tests/WalletTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Phantasma.Blockchain;
3 | using Phantasma.Cryptography;
4 | using Phantasma.Domain;
5 | using Phantasma.Numerics;
6 | using Phantasma.VM.Utils;
7 | using System.Linq;
8 |
9 | namespace Phantasma.Tests
10 | {
11 | [TestClass]
12 | public class WalletTests
13 | {
14 | [TestMethod]
15 | public void TransferScriptMethodExtraction()
16 | {
17 | var source = PhantasmaKeys.Generate();
18 | var dest = PhantasmaKeys.Generate();
19 | var amount = UnitConversion.GetUnitValue(DomainSettings.StakingTokenDecimals);
20 | var script = ScriptUtils.BeginScript().AllowGas(source.Address, Address.Null, 1, 999).TransferTokens(DomainSettings.StakingTokenSymbol, source.Address, dest.Address, amount).SpendGas(source.Address).EndScript();
21 |
22 | var table = DisasmUtils.GetDefaultDisasmTable();
23 | var methods = DisasmUtils.ExtractMethodCalls(script, table);
24 |
25 | Assert.IsTrue(methods != null && methods.Count() == 3);
26 | }
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/Tendermint/Extensions/ByteStringExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Text;
4 | using Google.Protobuf;
5 |
6 | namespace Types.Extensions
7 | {
8 | public static class ByteStringExtensions
9 | {
10 | public static int ToInt(this ByteString value)
11 | {
12 | var originalByteArray = value.ToByteArray();
13 | var byteArray = Enumerable
14 | .Repeat(0, 4 - originalByteArray.Length)
15 | .Concat(originalByteArray)
16 | .ToArray();
17 |
18 | if (BitConverter.IsLittleEndian)
19 | {
20 | Array.Reverse(byteArray);
21 | }
22 |
23 | return BitConverter.ToInt32(byteArray, 0);
24 | }
25 |
26 | public static string ToStringSafe(this ByteString value)
27 | {
28 | var byteArray = value.ToByteArray();
29 | var utf8String = Encoding.UTF8.GetString(byteArray);
30 | var decodedByteArray = Convert.FromBase64String(utf8String);
31 | return Encoding.UTF8.GetString(decodedByteArray);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/ExecutionFrame.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Phantasma.Core
4 | {
5 | public class ExecutionFrame
6 | {
7 | public VMObject[] Registers { get; }
8 |
9 | public uint Offset { get; } // current instruction pointer **before** the frame was entered
10 | public ExecutionContext Context { get; }
11 | public IVirtualMachine VM { get; }
12 |
13 | public ExecutionFrame(IVirtualMachine VM, uint offset, ExecutionContext context, int registerCount)
14 | {
15 | this.VM = VM;
16 | this.Offset = offset;
17 | this.Context = context;
18 |
19 | Registers = new VMObject[registerCount];
20 |
21 | for (int i = 0; i < registerCount; i++)
22 | {
23 | Registers[i] = new VMObject();
24 | }
25 | }
26 |
27 | public VMObject GetRegister(int index)
28 | {
29 | if (index < 0 || index >= Registers.Length)
30 | {
31 | throw new ArgumentException("Invalid index");
32 | }
33 |
34 | return Registers[index];
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Phantasma.Core/src/Domain/OracleEntry.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Phantasma.Core
4 | {
5 | public struct OracleEntry
6 | {
7 | public string URL { get; private set; }
8 | public byte[] Content { get; private set; }
9 |
10 | public OracleEntry(string url, byte[] content)
11 | {
12 | URL = url;
13 | Content = content;
14 | }
15 |
16 | public override bool Equals(object obj)
17 | {
18 | if (!(obj is OracleEntry))
19 | {
20 | return false;
21 | }
22 |
23 | var entry = (OracleEntry)obj;
24 | return URL == entry.URL &&
25 | EqualityComparer