Skip to content

Commit

Permalink
Merge branch 'october'
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkbee1 committed Apr 25, 2024
2 parents 72527d5 + 94a482c commit bb62e19
Show file tree
Hide file tree
Showing 74 changed files with 1,007 additions and 453 deletions.
2 changes: 1 addition & 1 deletion lib/app/shared/constants/parameters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Parameters {
static const web3RpcMainnetUrl = 'https://mainnet.infura.io/v3/';

static const POLYGON_MAIN_NETWORK = 'main';
static const INFURA_URL = 'https://polygon-mainnet.infura.io/v3/';
static const POLYGON_INFURA_URL = 'https://polygon-mainnet.infura.io/v3/';
static const INFURA_RDP_URL = 'wss://polygon-mainnet.infura.io/v3/';
static const ID_STATE_CONTRACT_ADDR =
'0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D';
Expand Down
2 changes: 2 additions & 0 deletions lib/app/shared/constants/secure_storage_keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class SecureStorageKeys {
static const String ssiKey = 'ssi/key';

static const String p256PrivateKeyForWallet = 'p256PrivateKeyForWallet';
static const String p256PrivateKeyToGetAndPresentVC =
'p256PrivateKeyToGetAndPresentVC';

static const String cryptoAccount = 'cryptoAccount';
static const String cryptoAccounTrackingIndex = 'cryptoAccounTrackingIndex';
Expand Down
14 changes: 12 additions & 2 deletions lib/app/shared/enum/type/blockchain_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ extension BlockchainTypeX on BlockchainType {
String name = '';
switch (this) {
case BlockchainType.tezos:
throw Exception();
throw ResponseMessage(
data: {
'error': 'invalid_request',
'error_description': 'Chain is not supported for tezos.',
},
);

case BlockchainType.ethereum:
name = '1';
Expand All @@ -87,7 +92,12 @@ extension BlockchainTypeX on BlockchainType {
int get chainId {
switch (this) {
case BlockchainType.tezos:
throw Exception();
throw ResponseMessage(
data: {
'error': 'invalid_request',
'error_description': 'Chain is not supported for tezos.',
},
);

case BlockchainType.ethereum:
return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,12 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
} else if (this == CredentialSubjectType.ageRange) {
return Urls.ageRangeAIValidationUrl;
} else {
throw Exception();
throw ResponseMessage(
data: {
'error': 'invalid_request',
'error_description': 'Url is not specified for $name.',
},
);
}
}

Expand Down Expand Up @@ -672,6 +677,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
VCFormatType.ldpVc,
VCFormatType.jwtVcJson,
VCFormatType.vcSdJWT,
VCFormatType.jwtVc,
];

case CredentialSubjectType.identityCredential:
Expand Down Expand Up @@ -894,6 +900,8 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {

if (vcFormatType == VCFormatType.vcSdJWT) {
type = 'identitycredential';
} else if (vcFormatType == VCFormatType.jwtVc) {
type = 'individualverifiableattestation';
}

link = '${Urls.id360Url}'
Expand Down
14 changes: 14 additions & 0 deletions lib/app/shared/extension/double_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
extension DoubleExtension on double {
String decimalNumber(int n) {
int number = 1;
for (int i = 0; i < n; i++) {
if (i > toString().split('.').toList().last.length) {
break;
}
number *= 10;
}

final twoDecimalNumber = (this * number).floor() / number;
return twoDecimalNumber.toString();
}
}
1 change: 1 addition & 0 deletions lib/app/shared/extension/extension.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export 'bigint_extension.dart';
export 'credential_status.dart';
export 'double_extension.dart';
export 'iterable_extension.dart';
export 'string_extension.dart';
export 'unit8List_extension.dart';
25 changes: 24 additions & 1 deletion lib/app/shared/extension/string_extension.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'dart:convert';

import 'package:convert/convert.dart';
import 'package:decimal/decimal.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

extension StringExtension on String {
String formatNumber() {
String get formatNumber {
if (isEmpty || length < 3) return this;
final formatter = NumberFormat('#,###');
final value = this;
Expand Down Expand Up @@ -43,4 +44,26 @@ extension StringExtension on String {
final String bytes = hex.encode(encode);
return bytes;
}

bool get isEVM {
if (this == 'ETH' || this == 'MATIC' || this == 'FTM' || this == 'BNB') {
return true;
}
return false;
}

String decimalNumber(int n) {
int number = 1;
for (int i = 0; i < n; i++) {
if (i > toString().split('.').toList().last.length) {
break;
}
number *= 10;
}

final twoDecimalNumber =
(Decimal.parse(this) * Decimal.parse(number.toString())).floor() /
Decimal.parse(number.toString());
return twoDecimalNumber.toDecimal().toString();
}
}
Loading

0 comments on commit bb62e19

Please sign in to comment.