@leofcoin/peernet 0.11.29 → 0.11.30

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.
@@ -1962,13 +1962,23 @@ class Peernet {
1962
1962
  try {
1963
1963
  const pub = await accountStore.get('public');
1964
1964
  this.id = JSON.parse(new TextDecoder().decode(pub)).walletId;
1965
- const accounts = await walletStore.get('accounts');
1965
+ let accounts = await walletStore.get('accounts');
1966
+ accounts = new TextDecoder().decode(accounts);
1967
+
1968
+ // fixing account issue (string while needs to be a JSON)
1969
+ // TODO: remove when on mainnet
1970
+ try {
1971
+ accounts = JSON.parse(new TextDecoder().decode(accounts));
1972
+ } catch (e) {
1973
+ accounts = [accounts.split(',')];
1974
+ }
1975
+
1966
1976
  this.accounts = JSON.parse(new TextDecoder().decode(accounts));
1967
1977
  } catch (e) {
1968
1978
  if (e.code === 'ERR_NOT_FOUND') {
1969
1979
  const {identity, accounts, config} = await generateAccount(this.network);
1970
1980
  walletStore.put('version', new TextEncoder().encode(1));
1971
- walletStore.put('accounts', new TextEncoder().encode(accounts));
1981
+ walletStore.put('accounts', new TextEncoder().encode(JSON.stringify(accounts)));
1972
1982
  walletStore.put('identity', new TextEncoder().encode(JSON.stringify(identity)));
1973
1983
  await accountStore.put('config', new TextEncoder().encode(JSON.stringify(config)));
1974
1984
  await accountStore.put('public', new TextEncoder().encode(JSON.stringify({walletId: identity.walletId})));
@@ -1854,13 +1854,23 @@ class Peernet {
1854
1854
  try {
1855
1855
  const pub = await accountStore.get('public');
1856
1856
  this.id = JSON.parse(new TextDecoder().decode(pub)).walletId;
1857
- const accounts = await walletStore.get('accounts');
1857
+ let accounts = await walletStore.get('accounts');
1858
+ accounts = new TextDecoder().decode(accounts);
1859
+
1860
+ // fixing account issue (string while needs to be a JSON)
1861
+ // TODO: remove when on mainnet
1862
+ try {
1863
+ accounts = JSON.parse(new TextDecoder().decode(accounts));
1864
+ } catch (e) {
1865
+ accounts = [accounts.split(',')];
1866
+ }
1867
+
1858
1868
  this.accounts = JSON.parse(new TextDecoder().decode(accounts));
1859
1869
  } catch (e) {
1860
1870
  if (e.code === 'ERR_NOT_FOUND') {
1861
1871
  const {identity, accounts, config} = await generateAccount(this.network);
1862
1872
  walletStore.put('version', new TextEncoder().encode(1));
1863
- walletStore.put('accounts', new TextEncoder().encode(accounts));
1873
+ walletStore.put('accounts', new TextEncoder().encode(JSON.stringify(accounts)));
1864
1874
  walletStore.put('identity', new TextEncoder().encode(JSON.stringify(identity)));
1865
1875
  await accountStore.put('config', new TextEncoder().encode(JSON.stringify(config)));
1866
1876
  await accountStore.put('public', new TextEncoder().encode(JSON.stringify({walletId: identity.walletId})));
@@ -1918,13 +1918,23 @@ class Peernet {
1918
1918
  try {
1919
1919
  const pub = await accountStore.get('public');
1920
1920
  this.id = JSON.parse(new TextDecoder().decode(pub)).walletId;
1921
- const accounts = await walletStore.get('accounts');
1921
+ let accounts = await walletStore.get('accounts');
1922
+ accounts = new TextDecoder().decode(accounts);
1923
+
1924
+ // fixing account issue (string while needs to be a JSON)
1925
+ // TODO: remove when on mainnet
1926
+ try {
1927
+ accounts = JSON.parse(new TextDecoder().decode(accounts));
1928
+ } catch (e) {
1929
+ accounts = [accounts.split(',')];
1930
+ }
1931
+
1922
1932
  this.accounts = JSON.parse(new TextDecoder().decode(accounts));
1923
1933
  } catch (e) {
1924
1934
  if (e.code === 'ERR_NOT_FOUND') {
1925
1935
  const {identity, accounts, config} = await generateAccount(this.network);
1926
1936
  walletStore.put('version', new TextEncoder().encode(1));
1927
- walletStore.put('accounts', new TextEncoder().encode(accounts));
1937
+ walletStore.put('accounts', new TextEncoder().encode(JSON.stringify(accounts)));
1928
1938
  walletStore.put('identity', new TextEncoder().encode(JSON.stringify(identity)));
1929
1939
  await accountStore.put('config', new TextEncoder().encode(JSON.stringify(config)));
1930
1940
  await accountStore.put('public', new TextEncoder().encode(JSON.stringify({walletId: identity.walletId})));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "0.11.29",
3
+ "version": "0.11.30",
4
4
  "description": "",
5
5
  "main": "dist/commonjs/peernet.js",
6
6
  "module": "dist/module/peernet.js",
package/src/peernet.js CHANGED
@@ -190,7 +190,17 @@ export default class Peernet {
190
190
  try {
191
191
  const pub = await accountStore.get('public')
192
192
  this.id = JSON.parse(new TextDecoder().decode(pub)).walletId
193
- const accounts = await walletStore.get('accounts')
193
+ let accounts = await walletStore.get('accounts')
194
+ accounts = new TextDecoder().decode(accounts)
195
+
196
+ // fixing account issue (string while needs to be a JSON)
197
+ // TODO: remove when on mainnet
198
+ try {
199
+ accounts = JSON.parse(new TextDecoder().decode(accounts))
200
+ } catch (e) {
201
+ accounts = [accounts.split(',')]
202
+ }
203
+
194
204
  this.accounts = JSON.parse(new TextDecoder().decode(accounts))
195
205
  } catch (e) {
196
206
  if (e.code === 'ERR_NOT_FOUND') {