@blocklet/launcher-util 1.9.36 → 1.9.38

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.
@@ -1,4 +1,6 @@
1
1
  const nodemailer = require('nodemailer');
2
+ const get = require('lodash.get');
3
+ const { getExplorerUrl } = require('../util');
2
4
 
3
5
  const send = (to, payload, { auth }) => {
4
6
  const transporter = nodemailer.createTransport({
@@ -11,7 +13,7 @@ const send = (to, payload, { auth }) => {
11
13
  return transporter.sendMail({ from: auth.from, to, subject: payload.subject, html: payload.html });
12
14
  };
13
15
 
14
- const getEmailMessage = ({ title, body, actions }) => {
16
+ const getEmailMessage = ({ title, body, actions, attachments }) => {
15
17
  let html = `<p>${body}</p>`;
16
18
  if (Array.isArray(actions) && actions.length > 0) {
17
19
  html += '<p>';
@@ -23,6 +25,15 @@ const getEmailMessage = ({ title, body, actions }) => {
23
25
  html += '</p>';
24
26
  }
25
27
 
28
+ const asset = (attachments || []).find((item) => item.type === 'asset');
29
+ if (asset) {
30
+ html += `<p>NFT: ${getExplorerUrl({
31
+ address: get(asset, 'data.did'),
32
+ type: 'assets',
33
+ chainHost: get(asset, 'data.chainHost'),
34
+ })}</p>`;
35
+ }
36
+
26
37
  return {
27
38
  subject: title,
28
39
  html,
package/lib/util.js CHANGED
@@ -91,6 +91,10 @@ const getSort = (sortby, sortdir) => {
91
91
  return { createdAt: -1 };
92
92
  };
93
93
 
94
+ const getExplorerUrl = ({ address, type = 'txs', chainHost }) => {
95
+ return `https://explorer.abtnetwork.io/explorer/${type}/${address}?host=${chainHost}`;
96
+ };
97
+
94
98
  module.exports = {
95
99
  calculatePrice,
96
100
  prettyDurationUnit,
@@ -98,4 +102,5 @@ module.exports = {
98
102
  formatExpirationTime,
99
103
  getSort,
100
104
  sortArrayByDate,
105
+ getExplorerUrl,
101
106
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/launcher-util",
3
- "version": "1.9.36",
3
+ "version": "1.9.38",
4
4
  "description": "Common constants",
5
5
  "keywords": [
6
6
  "constant"
@@ -38,8 +38,8 @@
38
38
  "lodash.pick": "^4.4.0",
39
39
  "moment": "^2.29.4",
40
40
  "moment-timezone": "^0.5.40",
41
- "nodemailer": "^6.8.0",
41
+ "nodemailer": "^6.9.0",
42
42
  "url-join": "^4.0.1"
43
43
  },
44
- "gitHead": "f57fe62381a27bb83e3ea95a8082d569c5e3c398"
44
+ "gitHead": "57c22db9630544ad76a5ed9b6486edcd5e798026"
45
45
  }