connectSuccess method

Map<String, Object?> connectSuccess({
  1. int id = 1,
  2. String? address,
  3. String appName = 'tonkeeper',
  4. List<Map<String, Object?>>? features,
  5. bool withProof = false,
})

A connect event.

features defaults to a plain SendTransaction wallet; pass an explicit list to model one that advertises more, or less.

Implementation

Map<String, Object?> connectSuccess({
  int id = 1,
  String? address,
  String appName = 'tonkeeper',
  List<Map<String, Object?>>? features,
  bool withProof = false,
}) => {
  'event': 'connect',
  'id': id,
  'payload': {
    'items': [
      {
        'name': 'ton_addr',
        'address': address ?? '0:abc',
        'network': '-239',
        'publicKey': 'ff',
        'walletStateInit': 'te6',
      },
      if (withProof)
        {
          'name': 'ton_proof',
          'proof': {
            'timestamp': '1770000000',
            'domain': {'lengthBytes': 11, 'value': 'example.org'},
            'signature': 'c2ln',
            'payload': 'nonce-1',
          },
        },
    ],
    'device': {
      'platform': 'iphone',
      'appName': appName,
      'appVersion': '5.0.0',
      'maxProtocolVersion': 2,
      'features':
          features ??
          [
            {'name': 'SendTransaction', 'maxMessages': 4},
          ],
    },
  },
};