Пример #1
0
        private async Task <string> TestRunMessage(Func <ResultOfEncodeMessage, Abi, string, Task <string> > run)
        {
            var subscribeParams = new
            {
                subscriptionId = "0x1111111111111111111111111111111111111111111111111111111111111111",
                pubkey         = SubscribeParamsPubkey,
                to             = "0:3333333333333333333333333333333333333333333333333333333333333333",
                value          = "0x123",
                period         = "0x456"
            };

            KeyPair keys = await _tonClient.Crypto.GenerateRandomSignKeys();

            const string walletAddress = "0:2222222222222222222222222222222222222222222222222222222222222222";

            ParamsOfEncodeMessage encodeMessageParams = GetParamsOfEncodeMessage(TestsEnv.Packages.Subscription, walletAddress, keys);
            var address = await _tonClient.DeployWithGiver(encodeMessageParams);

            var fetchAccount = await FetchAccount(address);

            var account = fetchAccount.Get <string>("boc");

            ResultOfEncodeMessage message = await GetSubscribeMessage(address, subscribeParams.ToJsonElement(), TestsEnv.Packages.Subscription, keys);

            // run
            var runResult = await run(message, TestsEnv.Packages.Subscription.Abi, account);

            var getSubscriptionMessage = await GetSubscriptionEncodedMessage(address, TestsEnv.Packages.Subscription, subscribeParams.subscriptionId, keys);

            ResultOfRunTvm result = await _tonClient.Tvm.RunTvm(new ParamsOfRunTvm
            {
                Abi     = TestsEnv.Packages.Subscription.Abi,
                Account = runResult,
                Message = getSubscriptionMessage
            });

            return(result.Decoded.Output.Get <JsonElement>("value0").Get <string>("pubkey"));
        }