/// <summary>
        ///     send 100000000 tons to account
        /// </summary>
        /// <param name="tonClient"></param>
        /// <param name="account">the giver sends money to himself by default</param>
        public static async Task SendGramsFromLocalGiver(this ITonClient tonClient, string account = null)
        {
            account ??= TestsEnv.LocalGiverAddress;

            var processMessageParams = new ParamsOfProcessMessage
            {
                MessageEncodeParams = new ParamsOfEncodeMessage
                {
                    Address = TestsEnv.LocalGiverAddress,
                    Abi     = TestsEnv.Packages.GiverAbiV1,
                    CallSet = new CallSet
                    {
                        FunctionName = "sendGrams",
                        Input        = new { dest = account, amount = 1000000000 }.ToJsonElement()
                    },
                    Signer = new Signer.None()
                },
                SendEvents = false
            };

            await WorkaroundOldGiverSemaphore.WaitAsync();

            ResultOfProcessMessage resultOfProcessMessage;

            try
            {
                resultOfProcessMessage = await tonClient.Processing.ProcessMessage(processMessageParams);
            }
            finally
            {
                WorkaroundOldGiverSemaphore.Release();
            }

            foreach (var outMessage in resultOfProcessMessage.OutMessages)
            {
                ResultOfParse parseResult = await tonClient.Boc.ParseMessage(new ParamsOfParse
                {
                    Boc = outMessage
                });

                var parsedPrototype = new { type = default(int), id = default(string) };
                var parsedMessage   = parseResult.Parsed !.Value.ToAnonymous(parsedPrototype);

                if (parsedMessage.type == 0)
                {
                    await tonClient.Net.WaitForCollection(new ParamsOfWaitForCollection
                    {
                        Collection = "transactions",
                        Filter     = new { in_msg = new { eq = parsedMessage.id } }.ToJsonElement(),
                        Result     = "id"
                    });
                }
            }
        }
예제 #2
0
 /// <summary>
 /// <para>Creates message, sends it to the network and monitors its processing.</para>
 /// <para>Creates ABI-compatible message,</para>
 /// <para>sends it to the network and monitors for the result transaction.</para>
 /// <para>Decodes the output messages' bodies.</para>
 /// <para>If contract's ABI includes "expire" header, then</para>
 /// <para>SDK implements retries in case of unsuccessful message delivery within the expiration</para>
 /// <para>timeout: SDK recreates the message, sends it and processes it again.</para>
 /// <para>The intermediate events, such as `WillFetchFirstBlock`, `WillSend`, `DidSend`,</para>
 /// <para>`WillFetchNextBlock`, etc - are switched on/off by `send_events` flag</para>
 /// <para>and logged into the supplied callback function.</para>
 /// <para>The retry configuration parameters are defined in the client's `NetworkConfig` and `AbiConfig`.</para>
 /// <para>If contract's ABI does not include "expire" header</para>
 /// <para>then, if no transaction is found within the network timeout (see config parameter ), exits with error.</para>
 /// </summary>
 public async Task <ResultOfProcessMessage> ProcessMessage(ParamsOfProcessMessage @params, Action <ProcessingEvent, uint> request = null, CancellationToken cancellationToken = default)
 {
     return(await _tonClientAdapter.Request <ParamsOfProcessMessage, ResultOfProcessMessage, ProcessingEvent>("processing.process_message", @params, request, cancellationToken));
 }