Ejemplo 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);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
        }