@blocklet/meta 1.8.15 → 1.8.18
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 +4 -0
- package/lib/parse-navigation.js +1 -1
- package/lib/payment/v2.js +34 -10
- package/lib/schema.js +2 -0
- package/package.json +12 -12
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
|
};
|
package/lib/parse-navigation.js
CHANGED
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
|
-
|
|
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,
|
|
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
|
|
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/lib/schema.js
CHANGED
|
@@ -73,6 +73,7 @@ const scriptsSchema = Joi.object({
|
|
|
73
73
|
postInstall: Joi.string().trim().min(1),
|
|
74
74
|
preDeploy: Joi.string().trim().min(1),
|
|
75
75
|
preStart: Joi.string().trim().min(1),
|
|
76
|
+
postStart: Joi.string().trim().min(1),
|
|
76
77
|
preStop: Joi.string().trim().min(1),
|
|
77
78
|
preUninstall: Joi.string().trim().min(1),
|
|
78
79
|
preConfig: Joi.string().trim().min(1),
|
|
@@ -81,6 +82,7 @@ const scriptsSchema = Joi.object({
|
|
|
81
82
|
.rename('post-install', 'postInstall')
|
|
82
83
|
.rename('pre-deploy', 'preDeploy')
|
|
83
84
|
.rename('pre-start', 'preStart')
|
|
85
|
+
.rename('post-start', 'postStart')
|
|
84
86
|
.rename('pre-stop', 'preStop')
|
|
85
87
|
.rename('pre-uninstall', 'preUninstall')
|
|
86
88
|
.rename('pre-config', 'preConfig')
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.18",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.8.
|
|
22
|
-
"@abtnode/util": "1.8.
|
|
23
|
-
"@arcblock/did": "1.17.
|
|
24
|
-
"@arcblock/did-ext": "1.17.
|
|
25
|
-
"@arcblock/did-util": "1.17.
|
|
26
|
-
"@arcblock/jwt": "1.17.
|
|
27
|
-
"@ocap/asset": "1.17.
|
|
28
|
-
"@ocap/mcrypto": "1.17.
|
|
29
|
-
"@ocap/util": "1.17.
|
|
30
|
-
"@ocap/wallet": "1.17.
|
|
21
|
+
"@abtnode/constant": "1.8.18",
|
|
22
|
+
"@abtnode/util": "1.8.18",
|
|
23
|
+
"@arcblock/did": "1.17.19",
|
|
24
|
+
"@arcblock/did-ext": "1.17.19",
|
|
25
|
+
"@arcblock/did-util": "1.17.19",
|
|
26
|
+
"@arcblock/jwt": "1.17.19",
|
|
27
|
+
"@ocap/asset": "1.17.19",
|
|
28
|
+
"@ocap/mcrypto": "1.17.19",
|
|
29
|
+
"@ocap/util": "1.17.19",
|
|
30
|
+
"@ocap/wallet": "1.17.19",
|
|
31
31
|
"ajv": "^8.11.0",
|
|
32
32
|
"axios": "^0.27.2",
|
|
33
33
|
"cjk-length": "^1.0.0",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"express": "^4.18.1",
|
|
54
54
|
"jest": "^27.5.1"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "7d82c570913bedf740afca15c27ef10d05aa85fc"
|
|
57
57
|
}
|