Beispiel #1
0
        // Static contructor from raw json
        // was: Constructor from encoded json
        //      factory Result.fromRawJson(String str) => Result.fromJson(json.decode(str));
        //static public ResultId fromRawJson(String rawJson)
        //{
        //    Dictionary<String, Object> ObjClassDeJsoned = JsonConvert.DeserializeObject<Dictionary<String, Object>>(rawJson);
        //    return new ResultId(ObjClassDeJsoned);
        //}

        #region Constructors

        public ResultId(String owner, DidDocument didDocument)
        {
            Trace.Assert(owner != null);
            Trace.Assert(didDocument != null);
            this.owner       = owner;
            this.didDocument = didDocument;
        }
        /// Returns the Did Document associated with the given [did],
        /// or `null` if no Did Document was found.
        public static async Task <DidDocument> getDidDocument(String did, Wallet wallet)
        {
            DidDocument DidDoc;

            String url = $"{wallet.networkInfo.lcdUrl}/identities/{did}";
            // This needs to be checked...
            // List<Dictionary<String, Object>> response = (List<Dictionary<String, Object>>)(await Network.queryChain(url));
            JArray response = await Network.queryChain(url) as JArray;

            if (response == null)
            {
                return(null);
            }
            // Use Linq to query the JArray for value searched
            JObject DidFound = (JObject)response.Where(v => v["did_document"] != null);

            if (DidFound != null)
            {
                DidDoc = new DidDocument(DidFound);
            }
            else
            {
                DidDoc = null;
            }
            return(DidDoc);
        }
            /// creates a _Pair from a didDocument. *** Refactor first and second to better names
            public _Pair(DidDocument didDocument)
            {
                RSAPublicKey key = didDocument.encryptionKey();

                this.document = didDocument;
                this.pubKey   = key;
            }
 /// Public constructor.
 public MsgSetDidDocument(DidDocument didDocument)
 {
     Trace.Assert(didDocument != null);
     // Assigns the properties
     this.didDocument = didDocument;
     base.setProperties("commercio/MsgSetIdentity", _toJson());
 }
        /// Performs a transaction setting the specified [didDocument] as being
        /// associated with the address present inside the specified [wallet].
        public static Task <TransactionResult> setDidDocument(DidDocument didDocument, Wallet wallet, StdFee fee = null, BroadcastingMode mode = BroadcastingMode.SYNC)
        {
            MsgSetDidDocument msg = new MsgSetDidDocument(didDocument: didDocument);

            // Careful here, Eugene: we are passing a list of BaseType containing the derived MsgSetDidDocument msg
            return(TxHelper.createSignAndSendTx(new List <StdMsg> {
                msg
            }, wallet, fee: fee, mode: mode));
        }
Beispiel #6
0
 // Alternate constructor from Json JObject
 public ResultId(JObject json)
 {
     this.owner       = (String)json["owner"];
     this.didDocument = new DidDocument((JObject)json["did_document"]);
 }
 public _Pair(DidDocument first, RSAPublicKey second)
 {
     this.document = first;
     this.pubKey   = second;
 }