Beispiel #1
0
        public override Hash ProposeNewContract(ContractDeploymentInput input)
        {
            // AssertDeploymentProposerAuthority(Context.Sender);
            var proposedContractInputHash = CalculateHashFromInput(input);

            Assert(State.ContractProposingInputMap[proposedContractInputHash] == null, "Already proposed.");
            State.ContractProposingInputMap[proposedContractInputHash] = new ContractProposingInput
            {
                Proposer = Context.Sender,
                Status   = ContractProposingInputStatus.Proposed
            };

            RequireParliamentContractAddressSet();

            // Create proposal for deployment
            var proposalCreationInput = new CreateProposalBySystemContractInput
            {
                ProposalInput = new CreateProposalInput
                {
                    ToAddress          = Context.Self,
                    ContractMethodName =
                        nameof(BasicContractZeroContainer.BasicContractZeroBase.ProposeContractCodeCheck),
                    Params = new ContractCodeCheckInput
                    {
                        ContractInput        = input.ToByteString(),
                        IsContractDeployment = true
                    }.ToByteString(),
                    OrganizationAddress = State.ContractDeploymentController.Value.OwnerAddress,
                    ExpiredTime         = Context.CurrentBlockTime.AddSeconds(ContractProposalExpirationTimePeriod)
                },
                OriginProposer = Context.Sender
            };

            Context.SendInline(State.ContractDeploymentController.Value.ContractAddress,
                               nameof(AuthorizationContractContainer.AuthorizationContractReferenceState
                                      .CreateProposalBySystemContract), proposalCreationInput.ToByteString());

            Context.Fire(new ContractProposed
            {
                ProposedContractInputHash = proposedContractInputHash
            });

            return(proposedContractInputHash);
        }
Beispiel #2
0
        public override Hash ProposeNewContract(ContractDeploymentInput input)
        {
            // AssertDeploymentProposerAuthority(Context.Sender);
            var proposedContractInputHash = CalculateHashFromInput(input);

            RegisterContractProposingData(proposedContractInputHash);

            // Create proposal for deployment
            var proposalCreationInput = new CreateProposalBySystemContractInput
            {
                ProposalInput = new CreateProposalInput
                {
                    ToAddress          = Context.Self,
                    ContractMethodName =
                        nameof(BasicContractZeroImplContainer.BasicContractZeroImplBase.ProposeContractCodeCheck),
                    Params = new ContractCodeCheckInput
                    {
                        ContractInput             = input.ToByteString(),
                        CodeCheckReleaseMethod    = nameof(DeploySmartContract),
                        ProposedContractInputHash = proposedContractInputHash,
                        Category         = input.Category,
                        IsSystemContract = false
                    }.ToByteString(),
                    OrganizationAddress = State.ContractDeploymentController.Value.OwnerAddress,
                    ExpiredTime         = Context.CurrentBlockTime.AddSeconds(ContractProposalExpirationTimePeriod)
                },
                OriginProposer = Context.Sender
            };

            Context.SendInline(State.ContractDeploymentController.Value.ContractAddress,
                               nameof(AuthorizationContractContainer.AuthorizationContractReferenceState
                                      .CreateProposalBySystemContract), proposalCreationInput.ToByteString());

            Context.Fire(new ContractProposed
            {
                ProposedContractInputHash = proposedContractInputHash
            });

            return(proposedContractInputHash);
        }