/// Creates a new transaction which tells the [recipient] that the document
        /// having the specified [documentId] and present inside the transaction with
        /// hash [txHash] has been properly seen.
        /// [proof] optional proof of reading.
        public static async Task <TransactionResult> sendDocumentReceipt(
            String recipient,
            String txHash,
            String documentId,
            Wallet wallet,
            String proof          = "",
            StdFee fee            = null,
            BroadcastingMode mode = BroadcastingMode.SYNC
            )
        {
            CommercioDocReceipt commercioDocReceipt = CommercioDocReceiptHelper.fromWallet(
                wallet: wallet,
                recipient: recipient,
                txHash: txHash,
                documentId: documentId,
                proof: proof
                );

            MsgSendDocumentReceipt msg = new MsgSendDocumentReceipt(receipt: commercioDocReceipt);

            // Careful here, Eugene: we are passing a list of BaseType containing the derived MsgSetDidDocument msg
            return(await TxHelper.createSignAndSendTx(new List <StdMsg> {
                msg
            }, wallet, fee : fee, mode : mode));
        }
Exemplo n.º 2
0
        /// 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));
        }
Exemplo n.º 3
0
        /// Closes the open CDPs having the given [closeCdps] list as being
        /// associated with the address present inside the specified [wallet].
        /// Optionally [fee] and broadcasting [mode] parameters can be specified.
        public static async Task <TransactionResult> closeCdpsList(List <CloseCdp> closeCdps, Wallet wallet, StdFee fee = null, BroadcastingMode mode = BroadcastingMode.SYNC)
        {
            List <MsgCloseCdp> msgs = closeCdps
                                      .Select(x => new MsgCloseCdp(x))
                                      .ToList();

            // Careful here, Eugene: we are passing a list of BaseType containing the derived MsgSetDidDocument msg
            return(await TxHelper.createSignAndSendTx(msgs.ToList <StdMsg>(), wallet, fee : fee, mode : mode));
        }
Exemplo n.º 4
0
        /// Performs a transaction opening a new CDP [openCdp] as being
        /// associated with the address present inside the specified [wallet].
        /// Optionally [fee] and broadcasting [mode] parameters can be specified.
        public static async Task <TransactionResult> openCdpSingle(OpenCdp openCdp, Wallet wallet, StdFee fee = null, BroadcastingMode mode = BroadcastingMode.SYNC)
        {
            MsgOpenCdp msg = new MsgOpenCdp(openCdp: openCdp);

            // Careful here, Eugene: we are passing a list of BaseType containing the derived MsgSetDidDocument msg
            return(await TxHelper.createSignAndSendTx(new List <StdMsg> {
                msg
            }, wallet, fee : fee, mode : mode));
        }
Exemplo n.º 5
0
        /// Performs a transaction setting the [didDocuments] list as being
        /// associated with the address present inside the specified [wallet].
        /// Optionally [fee] and broadcasting [mode] parameters can be specified.
        public static Task <TransactionResult> setDidDocumentsList(List <DidDocument> didDocuments, Wallet wallet, StdFee fee = null, BroadcastingMode mode = BroadcastingMode.SYNC)
        {
            List <MsgSetDidDocument> msgs = didDocuments
                                            .Select(x => new MsgSetDidDocument(x))
                                            .ToList();

            // Careful here, Eugene: we are passing a list of BaseType containing the derived MsgSetDidDocument msg
            // And I need to declare the thing explicitly in C#!
            return(TxHelper.createSignAndSendTx(msgs.ToList <StdMsg>(), wallet, fee: fee, mode: mode));
        }
Exemplo n.º 6
0
        /// Closes the CDP having the given [timestamp].
        /// Optionally [fee] and broadcasting [mode] parameters can be specified.
        public static async Task <TransactionResult> closeCdp(int timestamp, Wallet wallet, StdFee fee = null, BroadcastingMode mode = BroadcastingMode.SYNC)
        {
            CloseCdp closeCdp = CloseCdpHelper.fromWallet(wallet, timestamp);

            MsgCloseCdp msg = new MsgCloseCdp(closeCdp: closeCdp);

            // Careful here, Eugene: we are passing a list of BaseType containing the derived MsgSetDidDocument msg
            return(await TxHelper.createSignAndSendTx(new List <StdMsg> {
                msg
            }, wallet, fee : fee, mode : mode));
        }
Exemplo n.º 7
0
        /// Buys the membership with the given [membershipType].
        public static async Task <TransactionResult> buyMembership(MembershipType membershipType, Wallet wallet, StdFee fee = null, BroadcastingMode mode = BroadcastingMode.SYNC)
        {
            BuyMembership buyMembership = BuyMembershipHelper.fromWallet(wallet, membershipType);

            MsgBuyMembership msg = new MsgBuyMembership(buyMembership: buyMembership);

            // Careful here, Eugene: we are passing a list of BaseType containing the derived MsgSetDidDocument msg
            return(await TxHelper.createSignAndSendTx(new List <StdMsg> {
                msg
            }, wallet, fee : fee, mode : mode));
        }
Exemplo n.º 8
0
        /// Sends a new transaction in order to invite the given [userDid].
        public static async Task <TransactionResult> inviteUser(String userDid, Wallet wallet, StdFee fee = null, BroadcastingMode mode = BroadcastingMode.SYNC)
        {
            InviteUser inviteUser = InviteUserHelper.fromWallet(wallet, userDid);

            MsgInviteUser msg = new MsgInviteUser(inviteUser: inviteUser);

            // Careful here, Eugene: we are passing a list of BaseType containing the derived MsgSetDidDocument msg
            return(await TxHelper.createSignAndSendTx(new List <StdMsg> {
                msg
            }, wallet, fee : fee, mode : mode));
        }
Exemplo n.º 9
0
        /// Opens a new CDP depositing the given Commercio Token [amount].
        /// Optionally [fee] and broadcasting [mode] parameters can be specified.
        public static async Task <TransactionResult> openCdp(int amount, Wallet wallet, StdFee fee = null, BroadcastingMode mode = BroadcastingMode.SYNC)
        {
            List <StdCoin> depositAmount = new List <StdCoin> {
                new StdCoin("ucommercio", amount.ToString())
            };

            OpenCdp openCdp = OpenCdpHelper.fromWallet(wallet, depositAmount);

            MsgOpenCdp msg = new MsgOpenCdp(openCdp: openCdp);

            // Careful here, Eugene: we are passing a list of BaseType containing the derived MsgSetDidDocument msg
            return(await TxHelper.createSignAndSendTx(new List <StdMsg> {
                msg
            }, wallet, fee : fee, mode : mode));
        }
Exemplo n.º 10
0
        /// Creates a new Did power up request for the given [pairwiseDid] and of the given [amount].
        /// Signs everything that needs to be signed (i.e. the signature JSON inside the payload) with the
        /// private key contained inside the given  [senderWallet] and the [privateKey].
        public static async Task <TransactionResult> requestDidPowerUp(
            Wallet senderWallet,
            String pairwiseDid,
            List <StdCoin> amount,
            RSAPrivateKey privateKey,
            StdFee fee            = null,
            BroadcastingMode mode = BroadcastingMode.SYNC
            )
        {
            RequestDidPowerUp requestDidPowerUp = await RequestDidPowerUpHelper.fromWallet(
                senderWallet,
                pairwiseDid,
                amount,
                privateKey
                );

            MsgRequestDidPowerUp msg = new MsgRequestDidPowerUp(requestDidPowerUp: requestDidPowerUp);

            // Careful here, Eugene: we are passing a list of BaseType containing the derived MsgSetDidDocument msg
            return(await TxHelper.createSignAndSendTx(new List <StdMsg> {
                msg
            }, senderWallet, fee : fee, mode : mode));
        }
Exemplo n.º 11
0
        // This doesn't seem to be used, although it is there in Dart code... I will keep it as a placeholder
        // Use static HttpClient to avoid exhausting system resources for network connections.
        // private static HttpClient client = new HttpClient();

        #endregion

        #region Properties
        #endregion

        #region Constructors
        #endregion

        #region Public Methods

        /// Creates a new transaction that allows to share the document associated
        /// with the given [contentUri] and having the given [metadata]
        /// and [checksum]. If [encryptedData] is specified, encrypts the proper
        /// data for the specified [recipients] and then sends the transaction
        /// to the blockchain.
        public static async Task <TransactionResult> shareDocument(
            String id,
            CommercioDocMetadata metadata,
            List <String> recipients,
            Wallet wallet,
            CommercioDoSign doSign             = null,
            CommercioDocChecksum checksum      = null,
            KeyParameter aesKey                = null,
            List <EncryptedData> encryptedData = null,
            StdFee fee            = null,
            String contentUri     = null,
            BroadcastingMode mode = BroadcastingMode.SYNC
            )
        {
            // Build a generic document
            CommercioDoc commercioDoc = await CommercioDocHelper.fromWallet(
                wallet : wallet,
                recipients : recipients,
                id : id,
                metadata : metadata,
                checksum : checksum,
                contentUri : contentUri,
                doSign : doSign,
                encryptedData : encryptedData,
                aesKey : aesKey
                );


            // Build the tx message
            MsgShareDocument msg = new MsgShareDocument(document: commercioDoc);

            // Careful here, Eugene: we are passing a list of BaseType containing the derived MsgSetDidDocument msg
            return(await TxHelper.createSignAndSendTx(new List <StdMsg> {
                msg
            }, wallet, fee : fee, mode : mode));
        }