trac-peer 0.1.9 → 0.1.11

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trac-peer",
3
3
  "main": "src/index.js",
4
- "version": "0.1.9",
4
+ "version": "0.1.11",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "trac-wallet": "^0.0.35",
package/src/functions.js CHANGED
@@ -308,8 +308,9 @@ export async function tx(input, peer){
308
308
  }
309
309
  res = await peer.protocol_instance.tx(splitted);
310
310
  } catch(e){ console.log(e) }
311
- if(null !== peer.protocol_instance.getError(res)){
312
- console.log(res.message);
311
+ const err = peer.protocol_instance.getError(res);
312
+ if(null !== err){
313
+ console.log(err.message);
313
314
  }
314
315
  peer.protocol_instance.sim = false;
315
316
  return res;
package/src/index.js CHANGED
@@ -100,7 +100,7 @@ export class Peer extends ReadyResource {
100
100
  post_tx.value.w, post_tx.value.i, post_tx.value.ipk,
101
101
  post_tx.value.ch, post_tx.value.in
102
102
  ) &&
103
- null !== _this.protocol_instance.getError(await _this.contract_instance.execute(op, batch))) {
103
+ null === _this.protocol_instance.getError(await _this.contract_instance.execute(op, batch))) {
104
104
  let len = await batch.get('txl');
105
105
  if(null === len) {
106
106
  len = 0;
@@ -143,7 +143,7 @@ export class Peer extends ReadyResource {
143
143
  null === await batch.get('sh/'+op.hash) &&
144
144
  b4a.byteLength(str_value) <= 10_2400 &&
145
145
  chat_status.value === 'on' &&
146
- null !== _this.protocol_instance.getError(await _this.contract_instance.execute(op, batch))){
146
+ null === _this.protocol_instance.getError(await _this.contract_instance.execute(op, batch))){
147
147
  let len = await batch.get('msgl');
148
148
  if(null === len) {
149
149
  len = 0;
package/src/protocol.js CHANGED
@@ -150,8 +150,8 @@ class Protocol{
150
150
  }
151
151
 
152
152
  getError(value){
153
- if (value === false || (value && value.stack && value.message)) {
154
- return value === false ? 'Generic Error' : value.message;
153
+ if (value === false || (value !== undefined && value.stack !== undefined && value.message != undefined)) {
154
+ return value === false ? new Error('Generic Error') : value;
155
155
  }
156
156
  return null;
157
157
  }