Skip to content

Commit 92f6632

Browse files
committed
1.0.3
- can resolve CIP-68 (222) handles.
1 parent a4f39cd commit 92f6632

5 files changed

Lines changed: 33 additions & 39 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ We will check your input asap
4343

4444
Created by AndroDevs @2022
4545

46-
Follow us on Twitter [AndroDevs](https://twitter.com/AndroDevs)
46+
Follow us on X [AndroDevs](https://twitter.com/AndroDevs)
4747

4848
## Disclaimer
4949

lib/ada_handle.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ class AdaHandle {
33
static const String _handlePolicyId =
44
"f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a";
55

6+
/// Static CIP-68 (222) encoded prefix
7+
static const String cip68prefix = "000de140";
8+
69
/// Converts a handle string parameter to hex representation
710
///
811
/// e.g pass parameter "walmart"
@@ -27,6 +30,20 @@ class AdaHandle {
2730
throw Exception("Missing handle parameter");
2831
}
2932

33+
/// Creates a policyId, CIP-68 222 prefix and assetId hex combination for specific handle string value
34+
///
35+
/// e.g pass parameter "noodz"
36+
///
37+
/// result: f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a77616c6d617274
38+
static String getPolicyCip68PrefixAssetHexCombination(String handle) {
39+
if (handle.isNotEmpty) {
40+
return _handlePolicyId +
41+
cip68prefix +
42+
stringToHex(handle.trim().toLowerCase());
43+
}
44+
throw Exception("Missing handle parameter");
45+
}
46+
3047
static bool isHandlePolicy(String policyId) => policyId == _handlePolicyId;
3148

3249
/// Prepends policyId to asset hex value

pubspec.yaml

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: ada_handle
2-
description: Flutter ADA Handle package which is suporting conversion operations for $handle
3-
version: 1.0.2
2+
description: Flutter ADA Handle package which is supporting conversion operations for $handle
3+
version: 1.0.3
44
homepage: https://github.com/esodot/flutter_ada_handle
55

66
environment:
@@ -16,39 +16,4 @@ dev_dependencies:
1616
sdk: flutter
1717
flutter_lints: ^2.0.0
1818

19-
# For information on the generic Dart part of this file, see the
20-
# following page: https://dart.dev/tools/pub/pubspec
21-
22-
# The following section is specific to Flutter packages.
23-
flutter:
24-
25-
# To add assets to your package, add an assets section, like this:
26-
# assets:
27-
# - images/a_dot_burr.jpeg
28-
# - images/a_dot_ham.jpeg
29-
#
30-
# For details regarding assets in packages, see
31-
# https://flutter.dev/assets-and-images/#from-packages
32-
#
33-
# An image asset can refer to one or more resolution-specific "variants", see
34-
# https://flutter.dev/assets-and-images/#resolution-aware
35-
36-
# To add custom fonts to your package, add a fonts section here,
37-
# in this "flutter" section. Each entry in this list should have a
38-
# "family" key with the font family name, and a "fonts" key with a
39-
# list giving the asset and other descriptors for the font. For
40-
# example:
41-
# fonts:
42-
# - family: Schyler
43-
# fonts:
44-
# - asset: fonts/Schyler-Regular.ttf
45-
# - asset: fonts/Schyler-Italic.ttf
46-
# style: italic
47-
# - family: Trajan Pro
48-
# fonts:
49-
# - asset: fonts/TrajanPro.ttf
50-
# - asset: fonts/TrajanPro_Bold.ttf
51-
# weight: 700
52-
#
53-
# For details regarding fonts in packages, see
54-
# https://flutter.dev/custom-fonts/#from-packages
19+
flutter:

references/HandleResolution.pdf

37.1 KB
Binary file not shown.

test/ada_handle_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ Map<String, String> stringPolicyHexPair = {
1414
"ghostchain": AdaHandle.prependPolicyId("67686f7374636861696e"),
1515
};
1616

17+
Map<String, String> stringPolicyCip68HexPair = {
18+
"noodz": AdaHandle.prependPolicyId("000de1406e6f6f647a"),
19+
"ok": AdaHandle.prependPolicyId("000de1406f6b"),
20+
"ghostchain": AdaHandle.prependPolicyId("000de14067686f7374636861696e"),
21+
};
22+
1723
void main() {
1824
test("stringToHex", () {
1925
stringHexPair.forEach((handle, bytes) {
@@ -30,4 +36,10 @@ void main() {
3036
expect(AdaHandle.getPolicyAssetHexCombination(handle), bytes);
3137
});
3238
});
39+
40+
test("handleCip68", () {
41+
stringPolicyCip68HexPair.forEach((handle, bytes) {
42+
expect(AdaHandle.getPolicyCip68PrefixAssetHexCombination(handle), bytes);
43+
});
44+
});
3345
}

0 commit comments

Comments
 (0)