# Mint helper
Mint helper allows to easily perform all the operations related to the commercio.network mint
module.
# Provided operations
Mints the CCCs having the given
mintCccs
list as being associated with the address present inside the specifiedwallet
. Optionallyfee
and broadcastingmode
parameters can be specified.suspend fun mintCccsList( mintCccs: List<MintCcc>, wallet: Wallet, fee: StdFee? = null, mode: BroadcastingMode? = null ): TxResponse
1
2
3
4
5
6Returns the list of all the
ExchangeTradePosition
that the specified wallet has minted.suspend fun getExchangeTradePositions( wallet: Wallet ): List<ExchangeTradePosition>
1
2
3Burns the CCCs having the given
burnCccs
list as being associated with the address present inside the specifiedwallet
. Optionallyfee
and broadcastingmode
parameters can be specified.suspend fun burnCccsList( burnCccs: List<BurnCcc>, wallet: Wallet, fee: StdFee? = null, mode: BroadcastingMode? = null ): TxResponse
1
2
3
4
5
6
# Usage examples
val info = NetworkInfo(bech32Hrp = "did:com:", lcdUrl = "http://localhost:1317")
val userMnemonic = listOf(
"will",
"hard",
"topic",
"spray",
"beyond",
"ostrich",
"moral",
"morning",
"gas",
"loyal",
"couch",
"horn",
"boss",
"across",
"age",
"post",
"october",
"blur",
"piece",
"wheel",
"film",
"notable",
"word",
"man"
)
val wallet = Wallet.derive(mnemonic = userMnemonic, networkInfo = info)
val stdCoin = StdCoin(denom = "uccc", amount = "20")
val fee = StdFee(gas = "200000", amount = listOf(StdCoin(denom = "ucommercio", amount = "10000")))// optional
val mode = TxHelper.BroadcastingMode.BLOCK // optional
try {
val mintCcc = MintCcc(
depositAmount = listOf(stdCoin),
depositorDid = wallet.bech32Address,
id = UUID.randomUUID().toString()
)
//Mint CCC
MintHelper.mintCccsList(
mintCccs = listOf(mintCcc),
wallet = wallet,
fee = fee, // optional
mode = mode // optional
)
// Get all Exchange Trade Positions
val etps = MintHelper.getExchangeTradePositions(wallet)
val burnCccs = mutableListOf<BurnCcc>()
etps.forEach {
val _burnCcc = BurnCccHelper.fromWallet(
wallet = wallet, id = it.id,
amount = StdCoin(denom = it.credits.dnom, amount = it.credits.amount)
)
burnCccs.add(_burnCcc)
}
//Burn CCC
MintHelper.burnCccsList(burnCccs, wallet)
} catch (e: Exception) {
throw e
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68