public WorkEventLogTest()
        {
            this.address           = this.addressFactory.Create();
            this.permissionManager = new ContractExecutor(this.addressFactory.Create());
            this.contractRegistry  = new ContractRegistry();
            this.workTracker       = new WorkTracker.WorkTracker(this.addressFactory.Create(), this.contractRegistry,
                                                                 this.permissionManager.Address);
            var perm    = new Permission(typeof(TrackWorkAction));
            var addPerm = new AddPermissionAction(string.Empty, this.workTracker.Address, perm,
                                                  this.permissionManager.Address);

            this.contractRegistry.RegisterContract(this.permissionManager);
            this.contractRegistry.RegisterContract(this.workTracker);

            this.permissionManager.ExecuteAction(addPerm);

            var eventSet = new HashSet <WorkEventArgs>()
            {
                new WorkEventArgs(5, new DateTime(2019, 5, 13), this.address),
                new WorkEventArgs(5, new DateTime(2019, 5, 14), this.address),
                new WorkEventArgs(5, new DateTime(2019, 5, 15), this.address),
                new WorkEventArgs(5, new DateTime(2019, 5, 16), this.address),
            };

            this.eventLog = new WorkEventLog(30, eventSet, this.workTracker);
        }
예제 #2
0
        public Task(Address address, ContractRegistry registry, Address permissionManager, Address receiver, Dictionary <Address, BigInteger> tokenManagers,
                    uint id, Address issuer, string header, string description, bool autoDump = false, Address assignee = null, HashSet <Address> tasks = null)
            : base(address, registry, permissionManager, receiver, tokenManagers)
        {
            this.Id          = id;
            this.Issuer      = issuer ?? throw new NullReferenceException();
            this.Header      = header;
            this.Description = description;
            this.SubTasks    = tasks ?? new HashSet <Address>();
            this.AutoDump    = autoDump;
            this.Assignee    = assignee;
            if (this.Assignee != null)
            {
                this.Stage = TaskStage.Unassigned;
            }
            else
            {
                this.Stage = TaskStage.Assigned;
            }

            if (this.AutoDump)
            {
                this.InitializePermissionForAutoDump();
            }

            this.ConfigurePermissionManager(permissionManager);
        }
예제 #3
0
        public SplitterPerTaskHoursTests()
        {
            this.contractRegistry = new ContractRegistry();
            var tokenTagger = new FungibleTokenTagger();
            var tokenPicker = new FungibleTokenPicker();

            this.permissionManager = new ContractExecutor(this.addressFactory.Create());
            this.workTracker       = new WorkTracker.WorkTracker(this.addressFactory.Create(), this.contractRegistry,
                                                                 this.permissionManager.Address);
            this.tokenManager = new TokenManager(
                this.addressFactory.Create(),
                this.permissionManager.Address,
                this.contractRegistry,
                tokenTagger,
                tokenPicker);
            this.splitterPerHours =
                new SplitterPerTaskHoursMock(this.addressFactory.Create(), this.tokenManager.Address, this.workTracker);
            this.taskRegistry = new TaskRegistry(this.addressFactory.Create(), this.contractRegistry,
                                                 this.permissionManager.Address, this.splitterPerHours.Address);
            this.contractRegistry.RegisterContract(this.taskRegistry);
            this.contractRegistry.RegisterContract(this.permissionManager);
            this.contractRegistry.RegisterContract(this.tokenManager);
            this.contractRegistry.RegisterContract(this.workTracker);
            this.contractRegistry.RegisterContract(this.splitterPerHours);
            this.InitializePermissions();
        }
예제 #4
0
            public void SaveContractRegistry(ContractRegistry registry)
            {
                var data     = StateSerialization.SerializeState(registry.GetState());
                var typeName = Encoding.ASCII.GetBytes(registry.GetType().Name);

                this.SaveData(this.integration.contractRegistryAddress, data, typeName);
                this.integration.logger.LogTrace("Saved registry data: " + data.Length + " bytes");
            }
 public MembersRegistry(
     Address address,
     ContractRegistry registry,
     Address permissionManager,
     HashSet <Address> addressesToMembers = null)
     : base(address, registry, permissionManager)
 {
     this.membersAddresses = addressesToMembers ?? new HashSet <Address>();
     this.ConfigurePermissionManager(permissionManager);
 }
예제 #6
0
 public AddressGroupRegistry(
     Address address,
     ContractRegistry registry,
     Address permissionManager,
     ISet <Address> groupAddresses)
     : base(address, registry, permissionManager)
 {
     this.groupAddresses = groupAddresses ?? new HashSet <Address>();
     this.ConfigurePermissionManager(permissionManager);
 }
 public AddressGroup(
     Address address,
     ContractRegistry registry,
     Address permissionManager,
     ISet <Address> members = null)
     : base(address, registry, permissionManager)
 {
     this.members = members ?? new HashSet <Address>();
     this.ConfigurePermissionManager(permissionManager);
 }
예제 #8
0
 public TaskRegistry(
     Address address,
     ContractRegistry registry,
     Address permissionManager,
     Address defaultTokenSplitter,
     HashSet <Address> tasks = null)
     : base(address, registry, permissionManager)
 {
     this.DefaultTokenSplitter = defaultTokenSplitter ?? throw new ArgumentNullException();
     this.tasksAddresses       = tasks ?? new HashSet <Address>();
 }
        public MemberRegistryTest()
        {
            this.contractRegistry = new ContractRegistry();
            var tokenTagger = new FungibleTokenTagger();
            var tokenPicker = new FungibleTokenPicker();

            this.permissionManager = new ContractExecutor(this.addressFactory.Create());
            this.membersRegistry   = new MembersRegistry(this.addressFactory.Create(), contractRegistry,
                                                         this.permissionManager.Address);

            this.contractRegistry.RegisterContract(this.permissionManager);
            this.contractRegistry.RegisterContract(this.membersRegistry);
        }
예제 #10
0
        public AddressGroupTest()
        {
            this.contractRegistry = new ContractRegistry();
            var tokenTagger = new FungibleTokenTagger();
            var tokenPicker = new FungibleTokenPicker();

            this.permissionManager = new ContractExecutor(this.addressFactory.Create());
            this.addressGroup      = new AddressGroup(this.addressFactory.Create(), this.contractRegistry,
                                                      this.permissionManager.Address);

            this.contractRegistry.RegisterContract(this.permissionManager);
            this.contractRegistry.RegisterContract(this.addressGroup);
        }
예제 #11
0
 public TokenStakingGroup(
     Address address,
     ContractRegistry registry,
     Address permissionManager,
     uint requiredStake,
     Address tokenManager,
     ISet <Address> members = null)
     : base(address, registry, permissionManager, members)
 {
     this.requiredStake = requiredStake;
     this.tokenManager  = tokenManager;
     this.ConfigurePermissionManager(permissionManager);
 }
 public WorkTrackerController(
     Address address,
     ContractRegistry registry,
     Address permissionManager,
     WorkEventLog eventLog,
     List <TrackerGuardBase> trackGuards,
     WorkTracker workTracker)
     : base(address, registry, permissionManager)
 {
     this.workTracker =
         workTracker ?? new WorkTracker(null, null, this.Address);
     this.eventLog =
         eventLog ?? new WorkEventLog(30, new HashSet <WorkEventArgs>(), this.workTracker);
 }
예제 #13
0
 public Member(
     Address address,
     ContractRegistry registry,
     Address permissionManager,
     SortedDictionary <Address, ITokensReceivedStrategy> addressToTokensReceivedStrategy = null,
     SortedDictionary <Address, ITokensReceivedStrategy> addressToTokensMintedStrategy   = null)
     : base(address, registry, permissionManager)
 {
     this.addressToTokensReceivedStrategy = addressToTokensReceivedStrategy ??
                                            new SortedDictionary <Address, ITokensReceivedStrategy>();
     this.addressToTokensMintedStrategy = addressToTokensMintedStrategy ??
                                          new SortedDictionary <Address, ITokensReceivedStrategy>();
     this.ConfigurePermissionManager(permissionManager);
 }
        public WorkTrackerTest()
        {
            this.address           = this.addressFactory.Create();
            this.permissionManager = new ContractExecutor(this.addressFactory.Create());
            this.contractRegistry  = new ContractRegistry();
            this.workTracker       = new WorkTracker.WorkTracker(
                this.addressFactory.Create(),
                this.contractRegistry,
                this.permissionManager.Address);

            this.contractRegistry.RegisterContract(this.permissionManager);
            this.contractRegistry.RegisterContract(this.workTracker);

            this.ConfigurePermissions();
        }
        public TokenRelay(
            Address address,
            ContractRegistry registry,
            Address permissionManager,
            Address receiver,
            IDictionary <Address, BigInteger> tokenManagers = null)
            : base(address, registry, permissionManager)
        {
            if (receiver.Equals(this.Address))
            {
                throw new UnallowedRewardReceiverException(this, receiver);
            }

            this.TokenReceiver           = receiver;
            this.TokenManagersToBalances = tokenManagers ?? new SortedDictionary <Address, BigInteger>();
        }
        public MembersTest()
        {
            this.contractRegistry = new ContractRegistry();
            var tokenTagger = new FungibleTokenTagger();
            var tokenPicker = new FungibleTokenPicker();

            this.permissionManager = new ContractExecutor(this.addressFactory.Create());
            this.tokenManager      = new TokenManager(
                this.addressFactory.Create(),
                this.permissionManager.Address,
                this.contractRegistry,
                tokenTagger,
                tokenPicker);
            var addMintPermission = new AddPermissionAction(
                string.Empty,
                this.tokenManager.Address,
                new Permission(typeof(MintAction)),
                this.permissionManager.Address);

            this.contractRegistry.RegisterContract(this.permissionManager);
            this.contractRegistry.RegisterContract(this.tokenManager);
            this.permissionManager.ExecuteAction(addMintPermission);
        }
예제 #17
0
 public ContractContext(ContractRegistry registry, Address address)
 {
     this.Address  = address;
     this.registry = registry;
 }
 public WorkTracker(Address address, ContractRegistry registry, Address permissionManager)
     : base(address, registry, permissionManager)
 {
     this.TrackGuards = new HashSet <ITrackerGuard>();
 }