# Id helper

Id helper allows to easily perform all the operations related to the commercio.network id module.

# Provided operations

  1. Returns the DidDocument associated with the given did, or null if no DidDocument was found
static Future<DidDocument> getDidDocument(String did, Wallet wallet) async
1
  1. Performs a transaction setting the specified DidDocument as being associated with the address present inside the specified wallet
static Future<TransactionResult> setDidDocument(
  DidDocument didDocument,
  Wallet wallet,
) 
1
2
3
4
  1. Creates a new Did deposit request for the given recipient and of the given amount.
    Signs everything that need to be signed (i.e. the signature JSON inside the payload) with the private key contained inside the given wallet
static Future<TransactionResult> requestDidDeposit(
  String recipient, 
  List<StdCoin> amount, 
  Wallet wallet
) async
1
2
3
4
5
  1. Create 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 wallet
Future<TransactionResult> requestDidPowerUp(
  String pairwiseDid, 
  List<StdCoin> amount, 
  Wallet wallet
) async
1
2
3
4
5

# Usage examples

You can reach the examples code here

import 'package:commerciosdk/export.dart';
import 'commons.dart';

void main() async {
  final info = NetworkInfo(
    bech32Hrp: "did:com:",
    lcdUrl: "http://localhost:1317",
  );

  final userMnemonic = [
    "will",
    "hard",
    "topic",
    "spray",
    "beyond",
    "ostrich",
    "moral",
    "morning",
    "gas",
    "loyal",
    "couch",
    "horn",
    "boss",
    "across",
    "age",
    "post",
    "october",
    "blur",
    "piece",
    "wheel",
    "film",
    "notable",
    "word",
    "man"
  ];

  final userWallet = Wallet.derive(userMnemonic, info);

  // --- Create Did Document
  final rsaKeyPair = await KeysHelper.generateRsaKeyPair();
  final ecKeyPair = await KeysHelper.generateEcKeyPair();
  final didDocument =  DidDocumentHelper.fromWallet(
    userWallet, 
    [rsaKeyPair.publicKey, ecKeyPair.publicKey]
  );
  
  // --- Set the Did Document
  await IdHelper.setDidDocument(didocument, userWallet);
  
  // --- Request the Did deposit
  final depositAmount = [StdCoin(denom: "ucommercio", amount: "100")];
  await IdHelper.requestDidDeposit(
    userWallet.bech32address, 
    depositAmount, 
    userWallet
  );

  // --- Request the Did power up
  final pairwiseMnemonic = [
    "push",
    "grace",
    "power",
    "desk",
    "arrive",
    "horror",
    "gallery",
    "physical",
    "kingdom",
    "ecology",
    "fat",
    "firm",
    "future",
    "service",
    "table",
    "little",
    "live",
    "reason",
    "maximum",
    "short",
    "motion",
    "planet",
    "stage",
    "second"
  ];

  final pairwiseWallet = Wallet.derive(pairwiseMnemonic, info);

  await IdHelper.requestDidPowerUp(
    pairwiseWallet.bech32Address,
    depositAmount,
    userWallet,
  );
}
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93