@blocklet/meta 1.8.15 → 1.8.16

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/lib/info.js CHANGED
@@ -12,17 +12,20 @@ module.exports = (state, nodeSk, { returnWallet = true } = {}) => {
12
12
 
13
13
  const customDescription = envs.find((x) => x.key === 'BLOCKLET_APP_DESCRIPTION');
14
14
  const customPassportColor = envs.find((x) => x.key === 'BLOCKLET_PASSPORT_COLOR');
15
+ const customAppUrl = envs.find((x) => x.key === 'BLOCKLET_APP_URL');
15
16
 
16
17
  const { did } = state.meta;
17
18
  const name = getDisplayName(state);
18
19
  const description = get(customDescription, 'value', state.meta.description);
19
20
  const passportColor = get(customPassportColor, 'value', 'auto');
21
+ const appUrl = get(customAppUrl, 'value', '');
20
22
 
21
23
  if (!returnWallet) {
22
24
  return {
23
25
  did,
24
26
  name,
25
27
  description,
28
+ appUrl,
26
29
  };
27
30
  }
28
31
 
@@ -54,6 +57,7 @@ module.exports = (state, nodeSk, { returnWallet = true } = {}) => {
54
57
  name,
55
58
  description,
56
59
  passportColor,
60
+ appUrl,
57
61
  wallet,
58
62
  };
59
63
  };
@@ -140,7 +140,7 @@ const doParseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
140
140
  }
141
141
 
142
142
  if (childNav.role) {
143
- item.role = item.icon || childNav.role;
143
+ item.role = item.role || childNav.role;
144
144
  }
145
145
 
146
146
  if (childNav.section) {
package/lib/payment/v2.js CHANGED
@@ -265,9 +265,10 @@ const getTokenTransfers = ({ priceToken, shares = [], components = [] }) => {
265
265
  }
266
266
  }
267
267
 
268
- shares.forEach(({ address: accountAddress, value: ratio }) => {
268
+ shares.forEach(({ name, address: accountAddress, value: ratio }) => {
269
269
  contracts.push({
270
270
  tokenAddress: priceToken.address,
271
+ accountName: name,
271
272
  accountAddress,
272
273
  amount: parentShareBN.mul(new BN(ratio * defaultDecimals)).div(defaultDecimalsBN),
273
274
  });
@@ -296,9 +297,19 @@ const getContract = async ({ meta, priceTokens, components }) => {
296
297
 
297
298
  const contracts = getTokenTransfers({ priceToken, shares, components });
298
299
 
299
- return contracts
300
+ const code = contracts
300
301
  .map((x) => `transferToken('${x.tokenAddress}','${x.accountAddress}','${x.amount.toString()}')`)
301
302
  .join(';\n');
303
+
304
+ const shareList = contracts.map((x) => ({
305
+ ...x,
306
+ amount: fromUnitToToken(x.amount, priceToken.decimal),
307
+ }));
308
+
309
+ return {
310
+ code,
311
+ shares: shareList,
312
+ };
302
313
  };
303
314
 
304
315
  /**
@@ -395,7 +406,7 @@ const getPaymentIntegrity = async ({ contract, factoryInput, storeComponents, me
395
406
  const store = stores.find((x) => x.id === storeId);
396
407
 
397
408
  // eslint-disable-next-line no-param-reassign
398
- contract = await getContract({ meta, components, priceTokens });
409
+ contract = (await getContract({ meta, components, priceTokens })).code;
399
410
  // eslint-disable-next-line no-param-reassign
400
411
  factoryInput = await getFactoryInput(priceTokens);
401
412
  // eslint-disable-next-line no-param-reassign
@@ -413,10 +424,7 @@ const getPaymentIntegrity = async ({ contract, factoryInput, storeComponents, me
413
424
  return integrity;
414
425
  };
415
426
 
416
- const getStoreSignatures = async ({ meta, client, priceTokens, components, stores }) => {
417
- const factoryInput = getFactoryInput(priceTokens);
418
- const contract = await getContract({ meta, client, priceTokens, components });
419
-
427
+ const getStoreSignatures = async ({ meta, stores, factoryInput, contract }) => {
420
428
  const storeSignatures = [];
421
429
  for (const store of stores) {
422
430
  const { id, url, pk, components: storeComponents } = store;
@@ -467,13 +475,12 @@ const getStoreSignatures = async ({ meta, client, priceTokens, components, store
467
475
 
468
476
  return {
469
477
  storeSignatures,
470
- factoryInput,
471
- contract,
472
478
  };
473
479
  };
474
480
 
475
481
  /**
476
482
  * Used by CLI and Store to independent compute factory itx
483
+ *
477
484
  * @param {{
478
485
  * blockletMeta: BlockletMeta,
479
486
  * ocapClient: OcapClient,
@@ -483,18 +490,34 @@ const getStoreSignatures = async ({ meta, client, priceTokens, components, store
483
490
  * @returns {{
484
491
  * itx: Itx
485
492
  * store: Array<{id, url}>
493
+ * shares: Array<{
494
+ * accountName: string
495
+ * accountAddress: DID
496
+ * tokenAddress: DID
497
+ * amount: string|number,
498
+ * }>
486
499
  * }}
487
500
  */
488
501
  const createNftFactoryItx = async ({ blockletMeta, ocapClient, issuers, storeUrl }) => {
489
502
  const priceTokens = await getPriceTokens(blockletMeta, ocapClient);
490
503
  const { components, stores } = await getComponents(blockletMeta);
491
504
 
492
- const { factoryInput, contract, storeSignatures } = await getStoreSignatures({
505
+ const factoryInput = getFactoryInput(priceTokens);
506
+ const { code: contract, shares } = await getContract({
507
+ meta: blockletMeta,
508
+ client: ocapClient,
509
+ priceTokens,
510
+ components,
511
+ });
512
+
513
+ const { storeSignatures } = await getStoreSignatures({
493
514
  meta: blockletMeta,
494
515
  client: ocapClient,
495
516
  priceTokens,
496
517
  components,
497
518
  stores,
519
+ factoryInput,
520
+ contract,
498
521
  });
499
522
 
500
523
  return {
@@ -510,6 +533,7 @@ const createNftFactoryItx = async ({ blockletMeta, ocapClient, issuers, storeUrl
510
533
  contract,
511
534
  }),
512
535
  stores: storeSignatures.map((x) => ({ id: x.signer, url: x.storeUrl })),
536
+ shares,
513
537
  };
514
538
  };
515
539
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.15",
6
+ "version": "1.8.16",
7
7
  "description": "Library to parse/validate/fix blocklet meta",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -18,8 +18,8 @@
18
18
  "author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@abtnode/constant": "1.8.15",
22
- "@abtnode/util": "1.8.15",
21
+ "@abtnode/constant": "1.8.16",
22
+ "@abtnode/util": "1.8.16",
23
23
  "@arcblock/did": "1.17.17",
24
24
  "@arcblock/did-ext": "1.17.17",
25
25
  "@arcblock/did-util": "1.17.17",
@@ -53,5 +53,5 @@
53
53
  "express": "^4.18.1",
54
54
  "jest": "^27.5.1"
55
55
  },
56
- "gitHead": "57106db1b559b906734df5b8eac7ce87cae72980"
56
+ "gitHead": "2605cf6ebf2a0c3bb5524cb0f1385ad565fd85d6"
57
57
  }