예제 #1
0
        /// Creates a transaction having the given [msgs] and [fee] inside,
        /// signs it with the given [Wallet] and sends it to the blockchain.
        /// Optional parameters can be [fee] and broadcasting [mode],
        /// that can be of type "sync", "async" or "block".
        public static async Task <TransactionResult> createSignAndSendTx(List <StdMsg> msgs, Wallet wallet, StdFee fee = null, BroadcastingMode mode = BroadcastingMode.SYNC)
        {
            if (fee == null)
            {
                // Set the default value for fee
                int msgsNumber = msgs.Count > 0 ? msgs.Count : 1;
                fee = GenericUtils.calculateDefaultFee(msgsNumber: msgsNumber, fee: defaultAmount, denom: defaultDenom, gas: defaultGas);
            }

            String modeStr  = MyEnumExtensions.ToEnumMemberAttrValue(mode);
            StdTx  stdTx    = TxBuilder.buildStdTx(stdMsgs: msgs, fee: fee);
            StdTx  signedTx = await TxSigner.signStdTx(wallet : wallet, stdTx : stdTx);

            // return await TxSender.broadcastStdTx(wallet: wallet, stdTx: signedTx, mode: modeStr);
            TransactionResult res = await TxSender.broadcastStdTx(wallet : wallet, stdTx : signedTx, mode : modeStr);

            return(res);
        }
예제 #2
0
 /// Creates a BuyMembership from the given [wallet] and [membershipType].
 public static BuyMembership fromWallet(Wallet wallet, MembershipType membershipType, string tsp)
 {
     return(new BuyMembership(buyerDid: wallet.bech32Address, membershipType: MyEnumExtensions.ToEnumMemberAttrValue(membershipType), tsp: tsp));
 }