@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.
@@ -0,0 +1,5 @@
1
+ export declare function isValidCoinStr(str: string): boolean;
2
+ export declare function parseCoinStr(str: string): {
3
+ denom: string;
4
+ amount: string;
5
+ };
@@ -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
@@ -8,3 +8,4 @@ export * from "./icns";
8
8
  export * from "./retry";
9
9
  export * from "./sleep";
10
10
  export * from "./mnemonic";
11
+ export * from "./coin";
package/build/index.js CHANGED
@@ -24,4 +24,5 @@ __exportStar(require("./icns"), exports);
24
24
  __exportStar(require("./retry"), exports);
25
25
  __exportStar(require("./sleep"), exports);
26
26
  __exportStar(require("./mnemonic"), exports);
27
+ __exportStar(require("./coin"), exports);
27
28
  //# sourceMappingURL=index.js.map
@@ -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.76",
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.76",
20
- "@keplr-wallet/types": "0.12.76",
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": "0b1fd7794f86f654351eaba532cdc45af3ee34a4"
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
@@ -8,3 +8,4 @@ export * from "./icns";
8
8
  export * from "./retry";
9
9
  export * from "./sleep";
10
10
  export * from "./mnemonic";
11
+ export * from "./coin";