Esempio n. 1
0
        public override void Issue(ContractParameters parameters)
        {
            var fromAddress = (Address)parameters[ContractParameterTypes.__addressFrom];

            if (fromAddress != (string)OwnerInitiationAddress)
            {
                throw new DirectiveCallFailed($"Not allowed to issue from here.");
            }

            // from directive input parameters
            var toAddress = (Address)parameters[ContractParameterTypes.__addressTo];
            var amount    = (long)parameters[ContractParameterTypes.__amount];

            // from contract input parameters
            var supplyLimit   = (long)@in.supplyLimit;
            var currentSupply = (long)@in.currentSupply;

            if (amount > (supplyLimit - currentSupply))
            {
                throw new DirectiveCallFailed("Amount exceeds supply.");
            }

            if (currentSupply < supplyLimit)
            {
                // On Success of transaction, update current supply
                var _ = new Action <bool>((success) =>
                {
                    if (success)
                    {
                        @out.currentSupply = (currentSupply + amount);
                    }
                });

                var fingerprint       = (string)@in.fingerPrint;
                var masterFingerprint = (string)parameters["FromFingerprint"];
                var userFingerprint   = (string)parameters["ToFingerprint"];

                bmx
                .Asset()
                .Transfer()
                .Params((coin) =>
                {
                    coin.Symbol          = Symbol;
                    coin.Amount          = amount;
                    coin.ContractAddress = ContractAddress;
                    coin.From            = fromAddress;
                    coin.To = toAddress;
                    coin.FromFingerprint = masterFingerprint;
                    coin.ToFingerprint   = userFingerprint;
                    coin.Fingerprint     = fingerprint;
                    coin.Name            = Name;
                })
                .From(fromAddress, masterFingerprint)
                .To(toAddress, userFingerprint)
                .Encrypt()
                .Execute()
                .Go(_);
            }
        }
Esempio n. 2
0
        public override void Mint(ContractParameters parameters)
        {
            var masterFingerprint = (string)@in.fingerPrint;
            var userFingerprint   = (string)parameters[ContractParameterTypes.__fingerPrint];

            if (masterFingerprint != userFingerprint)
            {
                throw new DirectiveCallFailed("Fingerprints do not match. Authentication failed.");
            }

            var fromAddress = (Address)parameters[ContractParameterTypes.__addressFrom];

            if (fromAddress != ContractAddress)
            {
                throw new DirectiveCallFailed("Caller address is not allowed.");
            }

            var supplyLimit   = (long)@in.supplyLimit;
            var initialSupply = (long)@in.initialSupply;
            var currentSupply = (long)@in.currentSupply;

            var amount = (long)@in.amount;

            if (initialSupply > (supplyLimit - currentSupply))
            {
                throw new DirectiveCallFailed($"The supply limit of {string.Format("{0:N0}", supplyLimit)} has been reached. No further minting is possible.");
            }

            // On Success of transaction, update current supply
            var _ = new Action <bool>((success) =>
            {
                if (success)
                {
                    @in.currentSupply = currentSupply + amount;
                }
            });

            bmx
            .Asset()
            .Issue()
            .Params((coin) =>
            {
                coin.Symbol          = Symbol;
                coin.ContractAddress = fromAddress;
                coin.To              = ContractAddress;
                coin.Fingerprint     = masterFingerprint;
                coin.FromFingerprint = masterFingerprint;
                coin.ToFingerprint   = masterFingerprint;
                coin.Amount          = initialSupply;
                coin.Name            = Name;
            })
            .From(fromAddress, masterFingerprint)
            .To(ContractAddress, masterFingerprint)
            .Encrypt()
            .Execute()
            .Go(_);
        }
Esempio n. 3
0
        /// <summary>
        /// Construtor
        /// </summary>
        public WorkspaceInfo()
        {
            AutoFitMode          = 0;
            ImageCacheCount      = 6;
            ImageCacheDuration   = 40;
            MagnifierScaleFactor = 200;
            MagnifierSize        = 1;
            MaxRecentFile        = 10;
            RecentCatalogList    = new List <RecentFileInfo>();
            RecentFileList       = new List <RecentFileInfo>();
            Dynamics             = new List <string>();
            ConvertParameters    = new ContractParameters();
            DeviceInfoList       = new List <DeviceInfo>();
            StartingLanguageCode = "en";

            Extended = new ExtendedInfo();
            Feed     = new FeedInfo();
        }
Esempio n. 4
0
        /// <summary>
        /// worker thread result method
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // First, handle the case where an exception was thrown.
            if (e.Error != null)
            {
                this.lbResults.Items.Add("Operation error !");
            }
            else if (e.Cancelled)
            {
                // Next, handle the case where the user canceled the operation.
                // Note that due to a race condition in the DoWork event handler, the Cancelled
                // flag may not have been set, even though CancelAsync was called.
                this.lbResults.Items.Add("Operation cancelled !");
            }
            else if (e.Result != null)
            {
                // Finally, handle the case where the operation succeeded.
                ContractParameters param = e.Result as ContractParameters;

                if (param.CheckResult)
                {
                    this.lbResults.Items.Add("Operation succeded !");
                }
                else
                {
                    this.lbResults.Items.Add("Errors occured !");
                }

                if (param.ResfreshLibrary)
                {
                    Messenger.Default.Send <List <string> >(param.ResultFiles, ViewModelMessages.CatalogUpdate);
                    this.lbResults.Items.Add("Refresing library !");
                }
            }

            //finally
            this.btnConvert.IsEnabled       = true;
            this.btnCancel.Visibility       = System.Windows.Visibility.Collapsed;
            this.progressResults.Visibility = System.Windows.Visibility.Collapsed;
            this.paramGrid.IsEnabled        = true;

            System.Media.SystemSounds.Exclamation.Play();
        }