@w3ux/utils 2.0.7-alpha.2 → 2.0.8

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/base.cjs CHANGED
@@ -37,7 +37,7 @@ __export(base_exports, {
37
37
  withTimeout: () => withTimeout
38
38
  });
39
39
  module.exports = __toCommonJS(base_exports);
40
- var import_substrate_bindings = require("@polkadot-api/substrate-bindings");
40
+ var import_utils = require("dedot/utils");
41
41
  var minDecimalPlaces = (val, minDecimals) => {
42
42
  try {
43
43
  const retainCommas = typeof val === "string" && val.includes(",");
@@ -140,8 +140,7 @@ var appendOrEmpty = (condition, value) => condition ? ` ${value}` : "";
140
140
  var appendOr = (condition, value, fallback) => condition ? ` ${value}` : ` ${fallback}`;
141
141
  var formatAccountSs58 = (address, ss58Prefix) => {
142
142
  try {
143
- const codec = (0, import_substrate_bindings.AccountId)(ss58Prefix);
144
- return codec.dec(codec.enc(address));
143
+ return (0, import_utils.encodeAddress)(address, ss58Prefix);
145
144
  } catch (e) {
146
145
  return null;
147
146
  }
package/base.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/base.ts
2
- import { AccountId } from "@polkadot-api/substrate-bindings";
2
+ import { encodeAddress } from "dedot/utils";
3
3
  var minDecimalPlaces = (val, minDecimals) => {
4
4
  try {
5
5
  const retainCommas = typeof val === "string" && val.includes(",");
@@ -102,8 +102,7 @@ var appendOrEmpty = (condition, value) => condition ? ` ${value}` : "";
102
102
  var appendOr = (condition, value, fallback) => condition ? ` ${value}` : ` ${fallback}`;
103
103
  var formatAccountSs58 = (address, ss58Prefix) => {
104
104
  try {
105
- const codec = AccountId(ss58Prefix);
106
- return codec.dec(codec.enc(address));
105
+ return encodeAddress(address, ss58Prefix);
107
106
  } catch (e) {
108
107
  return null;
109
108
  }
package/index.cjs CHANGED
@@ -62,7 +62,7 @@ __export(index_exports, {
62
62
  module.exports = __toCommonJS(index_exports);
63
63
 
64
64
  // src/base.ts
65
- var import_substrate_bindings = require("@polkadot-api/substrate-bindings");
65
+ var import_utils = require("dedot/utils");
66
66
  var minDecimalPlaces = (val, minDecimals) => {
67
67
  try {
68
68
  const retainCommas = typeof val === "string" && val.includes(",");
@@ -165,8 +165,7 @@ var appendOrEmpty = (condition, value) => condition ? ` ${value}` : "";
165
165
  var appendOr = (condition, value, fallback) => condition ? ` ${value}` : ` ${fallback}`;
166
166
  var formatAccountSs58 = (address, ss58Prefix) => {
167
167
  try {
168
- const codec = (0, import_substrate_bindings.AccountId)(ss58Prefix);
169
- return codec.dec(codec.enc(address));
168
+ return (0, import_utils.encodeAddress)(address, ss58Prefix);
170
169
  } catch (e) {
171
170
  return null;
172
171
  }
@@ -197,7 +196,7 @@ var u8aConcat = (...u8as) => {
197
196
  };
198
197
 
199
198
  // src/unit.ts
200
- var import_substrate_bindings2 = require("@polkadot-api/substrate-bindings");
199
+ var import_utils2 = require("dedot/utils");
201
200
  var planckToUnit = (val, units) => {
202
201
  try {
203
202
  units = Math.max(Math.round(units), 0);
@@ -255,8 +254,7 @@ var localStorageOrDefault = (key, _default, parse = false) => {
255
254
  };
256
255
  var isValidAddress = (address) => {
257
256
  try {
258
- const codec = (0, import_substrate_bindings2.AccountId)();
259
- codec.dec(codec.enc(address));
257
+ (0, import_utils2.decodeAddress)(address);
260
258
  return true;
261
259
  } catch (e) {
262
260
  return false;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/base.ts
2
- import { AccountId } from "@polkadot-api/substrate-bindings";
2
+ import { encodeAddress } from "dedot/utils";
3
3
  var minDecimalPlaces = (val, minDecimals) => {
4
4
  try {
5
5
  const retainCommas = typeof val === "string" && val.includes(",");
@@ -102,8 +102,7 @@ var appendOrEmpty = (condition, value) => condition ? ` ${value}` : "";
102
102
  var appendOr = (condition, value, fallback) => condition ? ` ${value}` : ` ${fallback}`;
103
103
  var formatAccountSs58 = (address, ss58Prefix) => {
104
104
  try {
105
- const codec = AccountId(ss58Prefix);
106
- return codec.dec(codec.enc(address));
105
+ return encodeAddress(address, ss58Prefix);
107
106
  } catch (e) {
108
107
  return null;
109
108
  }
@@ -134,7 +133,7 @@ var u8aConcat = (...u8as) => {
134
133
  };
135
134
 
136
135
  // src/unit.ts
137
- import { AccountId as AccountId2 } from "@polkadot-api/substrate-bindings";
136
+ import { decodeAddress } from "dedot/utils";
138
137
  var planckToUnit = (val, units) => {
139
138
  try {
140
139
  units = Math.max(Math.round(units), 0);
@@ -192,8 +191,7 @@ var localStorageOrDefault = (key, _default, parse = false) => {
192
191
  };
193
192
  var isValidAddress = (address) => {
194
193
  try {
195
- const codec = AccountId2();
196
- codec.dec(codec.enc(address));
194
+ decodeAddress(address);
197
195
  return true;
198
196
  } catch (e) {
199
197
  return false;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@w3ux/utils",
3
- "version": "2.0.7-alpha.2",
3
+ "version": "2.0.8",
4
4
  "license": "GPL-3.0-only",
5
5
  "dependencies": {
6
- "@polkadot-api/substrate-bindings": "^0.11.1"
6
+ "dedot": "^0.8.1"
7
7
  },
8
8
  "main": "index.cjs",
9
9
  "module": "index.js",
package/unit.cjs CHANGED
@@ -43,10 +43,10 @@ __export(unit_exports, {
43
43
  varToUrlHash: () => varToUrlHash
44
44
  });
45
45
  module.exports = __toCommonJS(unit_exports);
46
- var import_substrate_bindings2 = require("@polkadot-api/substrate-bindings");
46
+ var import_utils2 = require("dedot/utils");
47
47
 
48
48
  // src/base.ts
49
- var import_substrate_bindings = require("@polkadot-api/substrate-bindings");
49
+ var import_utils = require("dedot/utils");
50
50
  var rmCommas = (val) => val.replace(/,/g, "");
51
51
  var rmDecimals = (str) => str.split(".")[0];
52
52
 
@@ -108,8 +108,7 @@ var localStorageOrDefault = (key, _default, parse = false) => {
108
108
  };
109
109
  var isValidAddress = (address) => {
110
110
  try {
111
- const codec = (0, import_substrate_bindings2.AccountId)();
112
- codec.dec(codec.enc(address));
111
+ (0, import_utils2.decodeAddress)(address);
113
112
  return true;
114
113
  } catch (e) {
115
114
  return false;
package/unit.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // src/unit.ts
2
- import { AccountId as AccountId2 } from "@polkadot-api/substrate-bindings";
2
+ import { decodeAddress } from "dedot/utils";
3
3
 
4
4
  // src/base.ts
5
- import { AccountId } from "@polkadot-api/substrate-bindings";
5
+ import { encodeAddress } from "dedot/utils";
6
6
  var rmCommas = (val) => val.replace(/,/g, "");
7
7
  var rmDecimals = (str) => str.split(".")[0];
8
8
 
@@ -64,8 +64,7 @@ var localStorageOrDefault = (key, _default, parse = false) => {
64
64
  };
65
65
  var isValidAddress = (address) => {
66
66
  try {
67
- const codec = AccountId2();
68
- codec.dec(codec.enc(address));
67
+ decodeAddress(address);
69
68
  return true;
70
69
  } catch (e) {
71
70
  return false;