Exemplo n.º 1
0
        /// <summary>
        /// Disbursement Testament method(遺言状と相続権の払い出し)
        /// </summary>
        /// <param name="RequesterAddress"></param>
        /// <param name="Familyname"></param>
        public void Disbursementtestament(Address RequesterAddress, string Familyname)
        {
            var InheritanceManagement = GetInheritanceManagementTableName();

            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(InheritanceManagement, out var InheritancemanageTable))
            {
                return;
            }

            //親族チェック
            if (!InheritancemanageTable.TryGetValue(RequesterAddress.Encoded, out var familyname))
            {
                return;
            }

            if (Familyname != (familyname.ToString()))
            {
                return;
            }

            //遺言状トークン情報(トークンID)の取得
            var keyinfo = Familyname + "_Testament";

            if (!InheritancemanageTable.TryGetValue(ByteString.Encode(keyinfo), out var tokenId))
            {
                return;
            }
            var tokeninfo = tokenId.ToString();

            //遺言者の死亡確認
            var Diedinfokey = Familyname + "_DiedTestatorAddress";

            if (!TryGetInternalValue(ByteString.Encode(Diedinfokey), out var TestatorAddress))
            {
                return;
            }

            //相続要求者の鍵一致確認
            var Inheritanceinfokey = Familyname + "_InheritanceAddress";

            if (!TryGetInternalValue(ByteString.Encode(Inheritanceinfokey), out var inheritanceAddress))
            {
                return;
            }
            var InheritanceAddress = PublicKeyAddress.Decode(inheritanceAddress);

            if (InheritanceAddress != RequesterAddress)
            {
                return;
            }

            //NFTテーブルの呼び出し
            var TestamentNFTTableName = GetTestamentNFTTableName();

            if (!StateWriter.TryGetTableWriter <INFTTableWriter>(TestamentNFTTableName, out var nfttable))
            {
                return;
            }
            nfttable.TransferToken(tokeninfo, RequesterAddress);
        }
Exemplo n.º 2
0
        /// <summary>
        /// join (particepate Insurance)
        /// </summary>
        /// <param name="PaticipantAddress"></param>
        /// <param name="deposit"></param>
        public void join(Address PaticipantAddress, decimal deposit)
        {
            var participantTableName = GetParticipantListTableName();

            //TryGetTableWriter:(StateWriterに登録されたテーブルがあればtrue)
            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(participantTableName, out var participantTable))   //happen false
            {
                return;
            }

            if (participantTable.TryGetValue(PaticipantAddress.Encoded, out var value))
            {
                return;
            }
            //Binary values ​​are set in the participant table
            participantTable.SetValue(PaticipantAddress.Encoded, ByteString.Parse("00"));

            var insuranceTableName = GetInsuranceTableName();

            //TryGetTableWriter:(StateWriterに登録されたテーブルがあればtrue de srue)
            if (!StateWriter.TryGetTableWriter <IAssetTableWriter>(insuranceTableName, out var table))
            {
                return;
            }
            //Insurance payment
            table.MoveValue(PaticipantAddress, GetContractAddress(), deposit); //from(sender):PaticipantAddress, to(destination):GetContractAddress(), deposit(Monthly insurance money):deposit
        }
Exemplo n.º 3
0
        /// <summary>
        /// GenerateTestamentNFTTest method
        /// </summary>
        /// <param name="TestatorAddress"></param>
        /// <param name="tokenId"></param>
        public void GenerateTestamentNFTTest(Address TestatorAddress, string tokenId)
        {
            var TestamentNFTTableName = GetTestamentNFTTableName();

            if (!StateWriter.TryGetTableWriter <INFTTableWriter>(TestamentNFTTableName, out var table))
            {
                return;
            }

            table.GenerateToken(tokenId, TestatorAddress);
        }
Exemplo n.º 4
0
        /// <summary>
        /// GenerateAssetTest method
        /// </summary>
        /// <param name="TestatorAddress"></param>
        /// <param name="amount"></param>
        public void GenerateAssetTest(Address TestatorAddress, decimal amount)
        {
            var HeritageAssetTableName = GetHeritageAssetTableName();

            if (!StateWriter.TryGetTableWriter <IAssetTableWriter>(HeritageAssetTableName, out var table))
            {
                return;
            }

            table.MoveValue(table.VoidAddress, TestatorAddress, amount);
        }
Exemplo n.º 5
0
        /// <summary>
        /// GenerateTest method
        /// </summary>
        /// <param name="participantAddress"></param>
        /// <param name="amount"></param>
        public void GenerateTest(Address participantAddress, decimal amount)
        {
            var insuranceTableName = GetInsuranceTableName();

            if (!StateWriter.TryGetTableWriter <IAssetTableWriter>(insuranceTableName, out var table))
            {
                return;
            }

            table.MoveValue(table.VoidAddress, participantAddress, amount);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Inheritance Execution(遺産相続実行)
        /// </summary>
        /// <param name="RequesterAddress"></param>
        /// <param name="Familyname"></param>
        public void InheritanceExecution(Address RequesterAddress, string Familyname)
        {
            var InheritanceManagement = GetInheritanceManagementTableName();

            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(InheritanceManagement, out var inheritancemanageTable))
            {
                return;
            }

            //相続要求者の鍵一致確認(NFTが盗まれたアカウント(鍵)からの要求の対策)
            var Inheritanceinfokey = Familyname + "_InheritanceAddress";

            if (!TryGetInternalValue(ByteString.Encode(Inheritanceinfokey), out var inheritanceAddress))
            {
                return;
            }
            var InheritanceAddress = PublicKeyAddress.Decode(inheritanceAddress);

            if (InheritanceAddress != RequesterAddress)
            {
                return;
            }

            var contractAddress = GetContractAddress();
            //金融資産相続情報の取得から相続まで
            var Assetinfokey = Familyname + "_HeritageAsset";

            if (inheritancemanageTable.TryGetValue(ByteString.Encode(Assetinfokey), out var deposit))
            {
                var amount = Convert.ToDecimal(deposit.ToString());
                var HeritageAssetTableName = GetHeritageAssetTableName();
                if (!StateWriter.TryGetTableWriter <IAssetTableWriter>(HeritageAssetTableName, out var heritageassettable))
                {
                    return;
                }
                heritageassettable.MoveValue(contractAddress, RequesterAddress, amount);
            }

            //有形資産相続情報の取得から相続まで
            var Tangibleinfokey = Familyname + "_TangibleAsset";

            if (inheritancemanageTable.TryGetValue(ByteString.Encode(Tangibleinfokey), out var tokenId))
            {
                var tokeninfo = tokenId.ToString();
                var TangibleAssetNFTTableName = GetTangibleAssetNFTTableName();
                if (!StateWriter.TryGetTableWriter <INFTTableWriter>(TangibleAssetNFTTableName, out var tangiblenftTable))
                {
                    return;
                }
                tangiblenftTable.TransferToken(tokeninfo, RequesterAddress);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 相続可能性のある親族に関する情報登録
        /// </summary>
        /// <param name="RelativesAddress">親族の公開鍵</param>
        public void registrelatives(Address RelativesAddress, string Familyname)
        {
            var inheritanceManagementTableName = GetInheritanceManagementTableName();

            //TryGetTableWriter:(StateWriterに登録されたテーブルがあればtrue)
            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(inheritanceManagementTableName, out var managementTable))   //happen false
            {
                return;
            }

            //すでに登録されているかチェック
            if (managementTable.TryGetValue(RelativesAddress.Encoded, out var value))
            {
                return;
            }

            //Binary values ​​are set in the participant table
            managementTable.SetValue(RelativesAddress.Encoded, ByteString.Parse(Familyname));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Deposit Testament NFT method(遺言状をスマートコントラクトにあづける)
        /// </summary>
        /// <param name="tokenId"></param>
        /// <param name="Familyname"></param>
        public void deposittestamentNFT(string tokenId, string Familyname)
        {
            var InheritanceManagement = GetInheritanceManagementTableName();

            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(InheritanceManagement, out var InheritancemanageTable))
            {
                return;
            }
            var keyinfo = Familyname + "_Testament";

            //スマートコントラクトに預けた〇〇家の遺言状情報の登録
            InheritancemanageTable.SetValue(ByteString.Encode(keyinfo), ByteString.Encode(tokenId));

            var TestamentNFTTable = GetTestamentNFTTableName();

            if (!StateWriter.TryGetTableWriter <INFTTableWriter>(TestamentNFTTable, out var Table))
            {
                return;
            }

            Table.TransferToken(tokenId, GetContractAddress());
        }
Exemplo n.º 9
0
        /// <summary>
        /// vote method
        /// </summary>
        /// <param name="ParticipantAddress"></param>
        public void vote(Address ParticipantAddress)
        {
            var participantTableName = GetParticipantListTableName();

            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(participantTableName, out var participantTable))   //happen false
            {
                return;
            }

            if (!participantTable.TryGetValue(ParticipantAddress.Encoded, out var value))
            {
                return;
            }

            participantTable.SetValue(ParticipantAddress.Encoded, ByteString.Parse("01"));

            //confirm number of participant votes

            var insuranceTableName = GetInsuranceTableName();

            if (!StateWriter.TryGetTableWriter <IAssetTableWriter>(insuranceTableName, out var table))
            {
                return;
            }
            // Can pay insurance amount?
            var contractAddress = GetContractAddress();

            if (!TryGetInternalValue(ByteString.Encode("beneficiaryAddress"), out var address))
            {
                return;
            }

            var beneficiaryAddress = PublicKeyAddress.Decode(address);

            decimal amount = 100m;

            table.MoveValue(contractAddress, beneficiaryAddress, amount);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Deposit HeritageAsset method (現金、預金の財産をスマートコントラクトに預ける)
        /// </summary>
        /// <param name="TestatorAddress"></param>
        /// <param name="deposit"></param>
        /// <param name="Familyname"></param>
        public void depositheritageasset(Address TestatorAddress, decimal deposit, string Familyname)
        {
            var InheritanceManagement = GetInheritanceManagementTableName();

            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(InheritanceManagement, out var InheritancemanageTable))
            {
                return;
            }
            var keyinfo = Familyname + "_HeritageAsset";
            var amount  = Convert.ToString(deposit);

            //スマートコントラクトに預けた〇〇家の資産枚数を登録
            InheritancemanageTable.SetValue(ByteString.Encode(keyinfo), ByteString.Encode(amount));

            var HeritageAssetTable = GetHeritageAssetTableName();

            if (!StateWriter.TryGetTableWriter <IAssetTableWriter>(HeritageAssetTable, out var Table))   //happen false
            {
                return;
            }

            Table.MoveValue(TestatorAddress, GetContractAddress(), deposit);
        }