Ejemplo n.º 1
0
        /// <summary>
        /// Loads MyDid from ledger
        /// TODO: replace string metadata with IMetadata and use "injected" factory for IMetadata
        /// </summary>
        /// <returns>The did.</returns>
        /// <param name="pool">Pool.</param>
        /// <param name="wallet">Wallet.</param>
        /// <param name="did">Did.</param>
        public static IDid GetMyDid(IPool pool, IWallet wallet, string did)
        {
            string result = DidAsync.GetMyDidWithMetaAsync(wallet, did).Result;

            //   returned
            //   {
            //     "did": string - DID stored in the wallet,
            //     "verkey": string - The DIDs transport key (ver key, key id),
            //     "tempVerkey": string - Temporary DIDs transport key (ver key, key id), exist only during the rotation of the keys.
            //                            After rotation is done, it becomes a new verkey.
            //     "metadata": string - The meta information stored with the DID
            //   }

            var json = JObject.Parse(result);

            did = json["did"].Value <string>();
            string verkey     = json["verkey"].Value <string>();
            string tempVerkey = json["tempVerkey"].Value <string>();
            string metadata   = json["metadata"].Value <string>();

            return(new DidInstance(pool, wallet, did, verkey, metadata, tempVerkey));
        }