@certik/skynet 0.10.58 → 0.10.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/address.js +17 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/address.js
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
function parseAddress(address) {
|
|
2
|
-
|
|
2
|
+
// in case of address has multiple colons, we only split the first one
|
|
3
|
+
const separatorIndex = address.indexOf(":");
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
let protocolPart;
|
|
6
|
+
let addressPart;
|
|
7
|
+
|
|
8
|
+
if (separatorIndex === -1) {
|
|
9
|
+
// if there is no colon, we assume it is an ethereum address
|
|
10
|
+
protocolPart = "eth";
|
|
11
|
+
addressPart = address;
|
|
12
|
+
} else {
|
|
13
|
+
protocolPart = address.slice(0, separatorIndex);
|
|
14
|
+
addressPart = address.slice(separatorIndex + 1);
|
|
15
|
+
}
|
|
16
|
+
if (addressPart.startsWith("0x")) {
|
|
17
|
+
// We only lowercase the address part if it starts with 0x, otherwise it is a case-sensitive address (such as tron)
|
|
18
|
+
addressPart = addressPart.toLowerCase();
|
|
6
19
|
}
|
|
7
20
|
|
|
8
|
-
return [
|
|
21
|
+
return [protocolPart, addressPart];
|
|
9
22
|
}
|
|
10
23
|
|
|
11
24
|
function composeAddress(protocol, addr) {
|