Пример #1
0
        protected override InteropTransaction PullPlatformTransaction(string platformName, Hash hash)
        {
            foreach (var swap in _swaps)
            {
                if (swap.platformName == platformName && swap.hash == hash)
                {
                    var info            = Nexus.GetPlatformInfo(platformName);
                    var platformAddress = info.Address;

                    string destAddress;
                    string temp;
                    WalletUtils.DecodePlatformAndAddress(info.Address, out temp, out destAddress);

                    var token  = Nexus.GetTokenInfo(swap.symbol);
                    var amount = UnitConversion.ToBigInteger(swap.amount, token.Decimals);

                    return(new InteropTransaction()
                    {
                        Platform = platformName,
                        Hash = hash,
                        Events = new Event[]
                        {
                            new Event(EventKind.TokenSend, WalletUtils.EncodeAddress(swap.sourceAddress, platformName), "swap", Serialization.Serialize(new TokenEventData()
                            {
                                chainAddress = platformAddress, symbol = swap.symbol, value = amount
                            })),
                            new Event(EventKind.TokenReceive, WalletUtils.EncodeAddress(destAddress, platformName), "swap", Serialization.Serialize(new TokenEventData()
                            {
                                chainAddress = platformAddress, symbol = swap.symbol, value = amount
                            }))
                        }
                    });
                }
            }

            throw new OracleException($"unknown transaction for {platformName} : {hash}");
        }