@keplr-wallet/common 0.12.76 → 0.12.77-alpha.1
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/build/coin/index.d.ts +5 -0
- package/build/coin/index.js +28 -0
- package/build/coin/index.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/package.json +4 -4
- package/src/coin/index.ts +32 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCoinStr = exports.isValidCoinStr = void 0;
|
|
4
|
+
function isValidCoinStr(str) {
|
|
5
|
+
const split = str.split(/^([0-9]+)(\s)*([a-zA-Z][a-zA-Z0-9/-]*)$/);
|
|
6
|
+
if (split.length === 5) {
|
|
7
|
+
if (split[1].length > 0 &&
|
|
8
|
+
split[3].length > 0 &&
|
|
9
|
+
!Number.isNaN(parseInt(split[1]))) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
exports.isValidCoinStr = isValidCoinStr;
|
|
16
|
+
function parseCoinStr(str) {
|
|
17
|
+
const split = str.split(/^([0-9]+)(\s)*([a-zA-Z][a-zA-Z0-9/-]*)$/);
|
|
18
|
+
if (split.length === 5) {
|
|
19
|
+
const denom = split[3];
|
|
20
|
+
return {
|
|
21
|
+
denom,
|
|
22
|
+
amount: split[1],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
throw new Error(`Invalid coin string: ${str}`);
|
|
26
|
+
}
|
|
27
|
+
exports.parseCoinStr = parseCoinStr;
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/coin/index.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,GAAW;IACxC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAEnE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,IACE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;YACnB,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;YACnB,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EACjC;YACA,OAAO,IAAI,CAAC;SACb;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAdD,wCAcC;AAED,SAAgB,YAAY,CAAC,GAAW;IAItC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAEnE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,OAAO;YACL,KAAK;YACL,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;SACjB,CAAC;KACH;IAED,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,EAAE,CAAC,CAAC;AACjD,CAAC;AAfD,oCAeC"}
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,0CAAwB;AACxB,yCAAuB;AACvB,0CAAwB;AACxB,2CAAyB;AACzB,yCAAuB;AACvB,yCAAuB;AACvB,0CAAwB;AACxB,0CAAwB;AACxB,6CAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,0CAAwB;AACxB,yCAAuB;AACvB,0CAAwB;AACxB,2CAAyB;AACzB,yCAAuB;AACvB,yCAAuB;AACvB,0CAAwB;AACxB,0CAAwB;AACxB,6CAA2B;AAC3B,yCAAuB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keplr-wallet/common",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.77-alpha.1",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"author": "chainapsis",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@keplr-wallet/crypto": "0.12.
|
|
20
|
-
"@keplr-wallet/types": "0.12.
|
|
19
|
+
"@keplr-wallet/crypto": "0.12.77-alpha.1",
|
|
20
|
+
"@keplr-wallet/types": "0.12.77-alpha.1",
|
|
21
21
|
"buffer": "^6.0.3",
|
|
22
22
|
"delay": "^4.4.0",
|
|
23
23
|
"mobx": "^6.1.7"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "e0615fa83bdd70706b2d000164c7a92a1392d937"
|
|
26
26
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function isValidCoinStr(str: string): boolean {
|
|
2
|
+
const split = str.split(/^([0-9]+)(\s)*([a-zA-Z][a-zA-Z0-9/-]*)$/);
|
|
3
|
+
|
|
4
|
+
if (split.length === 5) {
|
|
5
|
+
if (
|
|
6
|
+
split[1].length > 0 &&
|
|
7
|
+
split[3].length > 0 &&
|
|
8
|
+
!Number.isNaN(parseInt(split[1]))
|
|
9
|
+
) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function parseCoinStr(str: string): {
|
|
18
|
+
denom: string;
|
|
19
|
+
amount: string;
|
|
20
|
+
} {
|
|
21
|
+
const split = str.split(/^([0-9]+)(\s)*([a-zA-Z][a-zA-Z0-9/-]*)$/);
|
|
22
|
+
|
|
23
|
+
if (split.length === 5) {
|
|
24
|
+
const denom = split[3];
|
|
25
|
+
return {
|
|
26
|
+
denom,
|
|
27
|
+
amount: split[1],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
throw new Error(`Invalid coin string: ${str}`);
|
|
32
|
+
}
|
package/src/index.ts
CHANGED