Beispiel #1
0
        // ReSharper disable once InconsistentNaming
        public Task ICallVASPIsRegisteredAsyncMethodOfVASPIndexClient(
            string vaspCodeOrContractAddress,
            int minimalConfirmationLevel)
        {
            var vaspIndex       = _scenarioContext.GetContractByType <VASPIndex>();
            var vaspIndexClient = new EtherGate.VASPIndexClient(vaspIndex.RealAddress, _web3);

            // ReSharper disable once ConvertSwitchStatementToSwitchExpression
            switch (vaspCodeOrContractAddress.Length)
            {
            case 8:
                return(ICallVASPIsRegisteredAsyncMethodOfVASPIndexClient
                       (
                           vaspIndexClient,
                           VASPCode.Parse(vaspCodeOrContractAddress),
                           minimalConfirmationLevel
                       ));

            case 42:
                return(ICallVASPIsRegisteredAsyncMethodOfVASPIndexClient
                       (
                           vaspIndexClient,
                           Address.Parse(vaspCodeOrContractAddress),
                           minimalConfirmationLevel
                       ));

            default:
                throw new ArgumentException
                      (
                          "Is definitely neither VASP code, nor VASP contract address",
                          nameof(vaspCodeOrContractAddress)
                      );
            }
        }
Beispiel #2
0
 public void GetVASPCodeAsyncCallResultShouldBe(
     string expectedVASPCode)
 {
     _scenarioContext
     .GetCallResult <VASPCode>()
     .ShouldBe(VASPCode.Parse(expectedVASPCode));
 }
Beispiel #3
0
        // ReSharper disable once InconsistentNaming
        private async Task ICallVASPIsRegisteredAsyncMethodOfVASPIndexClient(
            IVASPIndexClient vaspIndexClient,
            VASPCode vaspCode,
            int minimalConfirmationLevel)
        {
            var callResult = await vaspIndexClient.VASPIsRegisteredAsync
                             (
                vaspCode : vaspCode,
                minimalConfirmationLevel : new ConfirmationLevel(minimalConfirmationLevel)
                             );

            _scenarioContext.SetCallResult(callResult);
        }
Beispiel #4
0
        // ReSharper disable once InconsistentNaming
        public async Task ICallTryGetVASPContractAddressAsyncMethodOfVASPIndexClient(
            string vaspCode,
            int minimalConfirmationLevel)
        {
            var vaspIndex       = _scenarioContext.GetContractByType <VASPIndex>();
            var vaspIndexClient = new EtherGate.VASPIndexClient(vaspIndex.RealAddress, _web3);

            var callResult = await vaspIndexClient.TryGetVASPContractAddressAsync
                             (
                vaspCode : VASPCode.Parse(vaspCode),
                minimalConfirmationLevel : new ConfirmationLevel(minimalConfirmationLevel)
                             );

            _scenarioContext.SetCallResult(callResult);
        }
Beispiel #5
0
        public async Task VASPCreatedVaspContract(
            string vaspCode)
        {
            var vaspIndex = _scenarioContext.GetContractByType <VASPIndex>();

            var vaspContract = await vaspIndex.CreateVASPContractAsync
                               (
                vaspContractCreator : await _accounts.GetDeployerAsync(),
                vaspCode : VASPCode.Parse(vaspCode),
                vaspContractOwner : await _accounts.GetOwnerAsync(),
                channels : Channels.Parse("0x00000001"),
                transportKey : MockKeyGenerator.GenerateTransportKey(),
                messageKey : MockKeyGenerator.GenerateMessageKey(),
                signingKey : MockKeyGenerator.GenerateSigningKey()
                               );

            _scenarioContext.RegisterContract(vaspContract);
        }
        private async Task <Address> InnerCreateVASPContractAsync(
            Address vaspContractCreator,
            VASPCode vaspCode,
            Address vaspContractOwner,
            Channels channels,
            TransportKey transportKey,
            MessageKey messageKey,
            SigningKey signingKey)
        {
            var contract = Web3.Eth.GetContract(ABI, RealAddress);
            var function = contract.GetFunction("createVASPContract");

            var functionInput = new object[]
            {
                (byte[])vaspCode,
                (string)vaspContractOwner,
                (byte[])channels,
                (byte[])transportKey,
                (byte[])messageKey,
                (byte[])signingKey
            };

            var receipt = await function.SendTransactionAndWaitForReceiptAsync
                          (
                @from : vaspContractCreator,
                gas : await function.EstimateGasAsync(functionInput),
                value : new HexBigInteger(0),
                receiptRequestCancellationToken : null,
                functionInput : functionInput
                          );

            return(Address.Parse
                   (
                       receipt.Logs[5]["topics"][2]
                       .ToString()
                       .Replace
                       (
                           "0x000000000000000000000000",
                           "0x",
                           System.StringComparison.OrdinalIgnoreCase
                       )
                   ));
        }
        public async Task <VASPContract> CreateVASPContractAsync(
            Address vaspContractCreator,
            VASPCode vaspCode,
            Address vaspContractOwner,
            Channels channels,
            TransportKey transportKey,
            MessageKey messageKey,
            SigningKey signingKey)
        {
            var vaspContractAddress = await InnerCreateVASPContractAsync
                                      (
                vaspContractCreator,
                vaspCode,
                vaspContractOwner,
                channels,
                transportKey,
                messageKey,
                signingKey
                                      );

            return(new VASPContract(vaspContractAddress, Web3));
        }
Beispiel #8
0
        public void SpecifiedPropertyOfTheGetVASPInfoAsyncCallResultShouldBe(
            string propertyName,
            string propertyValue)
        {
            var callResult = _scenarioContext.GetCallResult <VASPInfo>();

            switch (propertyName)
            {
            case "Channels":
                callResult.Channels
                .ShouldBe(Channels.Parse(propertyValue));
                break;

            case "MessageKey":
                callResult.MessageKey
                .ShouldBe(MessageKey.Parse(propertyValue));
                break;

            case "SigningKey":
                callResult.SigningKey
                .ShouldBe(SigningKey.Parse(propertyValue));
                break;

            case "TransportKey":
                callResult.TransportKey
                .ShouldBe(TransportKey.Parse(propertyValue));
                break;

            case "VASPCode":
                callResult.VASPCode
                .ShouldBe(VASPCode.Parse(propertyValue));
                break;

            default:
                throw new ArgumentException("Unexpected property name", nameof(propertyName));
            }
        }
Beispiel #9
0
        // ReSharper disable once InconsistentNaming
        public async Task ICallCreateVASPContractAsyncMethodOfVASPIndexClientWithGivenParameters()
        {
            var vaspIndex       = _scenarioContext.GetContractByType <VASPIndex>();
            var vaspIndexClient = new VASPIndexClient
                                  (
                vaspIndex.RealAddress,
                _estimateGasPriceStrategy,
                _web3
                                  );

            var callResult = await vaspIndexClient.CreateVASPContractAsync
                             (
                from : await _accounts.GetDeployerAsync(),
                vaspCode : VASPCode.Parse(_scenarioContext.GetParameter("vaspCode")),
                owner : Address.Parse(_scenarioContext.GetParameter("owner")),
                channels : Channels.Parse(_scenarioContext.GetParameter("channels")),
                transportKey : TransportKey.Parse(_scenarioContext.GetParameter("transportKey")),
                messageKey : MessageKey.Parse(_scenarioContext.GetParameter("messageKey")),
                signingKey : SigningKey.Parse(_scenarioContext.GetParameter("signingKey")),
                minimalConfirmationLevel : ConfirmationLevel.Parse(_scenarioContext.GetParameter("minimalConfirmationLevel"))
                             );

            _scenarioContext.SetCallResult(callResult);
        }
        public async Task <VASPContract> DeployVASPContractAsync(
            VASPCode vaspCode,
            Address owner,
            Channels channels,
            TransportKey transportKey,
            MessageKey messageKey,
            SigningKey signingKey)
        {
            var vaspContractAddress = Address.Parse(await DeployAsync(
                                                        abi: VASPContract.ABI,
                                                        byteCode: VASPContract.ByteCode,
                                                        constructorArguments: new object[]
            {
                (byte[])vaspCode,
                (string)owner,
                (byte[])channels,
                (byte[])transportKey,
                (byte[])messageKey,
                (byte[])signingKey
            }
                                                        ));

            return(new VASPContract(vaspContractAddress, _web3));
        }