@ocap/asset 1.17.4 → 1.17.7

Sign up to get free protection for your applications and to get access to all the features.
package/lib/index.d.ts CHANGED
@@ -1,5 +1,34 @@
1
+ import type { LiteralUnion, PartialDeep } from 'type-fest';
2
+ import type { WalletObject } from '@ocap/wallet';
3
+ import type { TAssetFactoryState, TCreateAssetTx } from '@ocap/types';
1
4
  declare type $TSFixMe = any;
2
- export declare const isValidHook: (hook: $TSFixMe, quota?: $TSFixMe, throwOnError?: boolean) => boolean;
5
+ export declare type TPickedFactoryState = PartialDeep<TAssetFactoryState>;
6
+ export declare type TIssuer = {
7
+ name: string;
8
+ wallet: WalletObject;
9
+ };
10
+ export declare type TIssuerInput = {
11
+ id: string;
12
+ pk: string;
13
+ name: string;
14
+ };
15
+ export declare type THook = {
16
+ type: LiteralUnion<'contract' | 'url', string>;
17
+ name: LiteralUnion<'mint' | 'postMint', string>;
18
+ hook: string;
19
+ };
20
+ export declare type TInputMap = {
21
+ [key: string]: string;
22
+ };
23
+ export declare type TMintResult = {
24
+ address: string;
25
+ asset: TCreateAssetTx;
26
+ };
27
+ export declare type TPreMintResult = TMintResult & {
28
+ variables: TInputMap;
29
+ issuer: TIssuerInput;
30
+ };
31
+ export declare const isValidHook: (hook: THook, quota?: $TSFixMe, throwOnError?: boolean) => boolean;
3
32
  export declare const isValidFactory: (props: $TSFixMe) => boolean;
4
33
  /**
5
34
  * Find credentialSubject path in the object
@@ -20,14 +49,11 @@ export declare const findPrerenderKeys: (obj: $TSFixMe, keyword: string) => stri
20
49
  * @param {object} params.issuer issuer object
21
50
  */
22
51
  export declare const mintFromFactory: ({ factory, inputs, owner, issuer, }: {
23
- factory: $TSFixMe;
24
- inputs: $TSFixMe;
52
+ factory: TPickedFactoryState;
53
+ inputs: TInputMap;
25
54
  owner: string;
26
- issuer: $TSFixMe;
27
- }) => {
28
- asset: any;
29
- address: string;
30
- };
55
+ issuer: TIssuerInput;
56
+ }) => TMintResult;
31
57
  /**
32
58
  * Simulate minting from an asset factory, used for client side
33
59
  *
@@ -38,23 +64,10 @@ export declare const mintFromFactory: ({ factory, inputs, owner, issuer, }: {
38
64
  * @param {object} params.issuer factory issuer wallet and name
39
65
  */
40
66
  export declare const preMintFromFactory: ({ factory, inputs, owner, issuer, }: {
41
- factory?: $TSFixMe;
42
- inputs: $TSFixMe;
67
+ factory?: TPickedFactoryState;
68
+ inputs: TInputMap;
43
69
  owner?: string;
44
- issuer?: $TSFixMe;
45
- }) => {
46
- address: string;
47
- issuer: {
48
- id: any;
49
- pk: string;
50
- name: any;
51
- };
52
- variables: any;
53
- asset: any;
54
- };
55
- export declare const formatFactoryState: (state: $TSFixMe) => {
56
- address: any;
57
- output: any;
58
- data: any;
59
- };
70
+ issuer?: TIssuer;
71
+ }) => TPreMintResult;
72
+ export declare const formatFactoryState: (state: $TSFixMe) => TPickedFactoryState;
60
73
  export {};
package/lib/index.js CHANGED
@@ -53,6 +53,8 @@ const isValidHook = (hook, quota, throwOnError = false) => {
53
53
  return false;
54
54
  };
55
55
  exports.isValidHook = isValidHook;
56
+ // FIXME: we should use Joi to validate the schema
57
+ // @link https://github.com/improbable-eng/ts-protoc-gen
56
58
  const isValidFactory = (props) => {
57
59
  if (!props) {
58
60
  throw new Error('Factory props should not be empty');
@@ -255,7 +257,7 @@ const preMintFromFactory = ({ factory, inputs, owner, issuer, }) => {
255
257
  };
256
258
  exports.preMintFromFactory = preMintFromFactory;
257
259
  const formatFactoryState = (state) => {
258
- const { address, output, data } = state;
260
+ const { address, output, data, numMinted } = state;
259
261
  const outputX = (0, cloneDeep_1.default)(output);
260
262
  outputX.data.value = JSON.parse(outputX.data.value);
261
263
  outputX.data.type = outputX.data.typeUrl;
@@ -263,6 +265,7 @@ const formatFactoryState = (state) => {
263
265
  address,
264
266
  output: outputX,
265
267
  data: JSON.parse(data.value),
268
+ numMinted,
266
269
  };
267
270
  };
268
271
  exports.formatFactoryState = formatFactoryState;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ocap/asset",
3
3
  "description": "Utility to work with asset and factory on ArcBlock blockchain",
4
- "version": "1.17.4",
4
+ "version": "1.17.7",
5
5
  "author": {
6
6
  "name": "wangshijun",
7
7
  "email": "shijun@arcblock.io",
@@ -18,19 +18,21 @@
18
18
  "wangshijun <shijun@arcblock.io> (https://github.com/wangshijun)"
19
19
  ],
20
20
  "dependencies": {
21
- "@arcblock/did": "1.17.4",
22
- "@arcblock/did-util": "1.17.4",
23
- "@arcblock/vc": "1.17.4",
24
- "@ocap/contract": "1.17.4",
25
- "@ocap/mcrypto": "1.17.4",
26
- "@ocap/util": "1.17.4",
27
- "@ocap/wallet": "1.17.4",
21
+ "@arcblock/did": "1.17.7",
22
+ "@arcblock/did-util": "1.17.7",
23
+ "@arcblock/vc": "1.17.7",
24
+ "@ocap/contract": "1.17.7",
25
+ "@ocap/mcrypto": "1.17.7",
26
+ "@ocap/types": "1.17.7",
27
+ "@ocap/util": "1.17.7",
28
+ "@ocap/wallet": "1.17.7",
28
29
  "debug": "^4.3.3",
29
30
  "flat": "^5.0.2",
30
31
  "is-absolute-url": "^3.0.3",
31
32
  "json-stable-stringify": "^1.0.1",
32
33
  "lodash": "^4.17.21",
33
- "mustache": "^4.1.0"
34
+ "mustache": "^4.1.0",
35
+ "type-fest": "^2.16.0"
34
36
  },
35
37
  "devDependencies": {
36
38
  "@arcblock/eslint-config-ts": "0.2.2",
@@ -71,5 +73,5 @@
71
73
  "build": "tsc",
72
74
  "build:watch": "npm run build -- -w"
73
75
  },
74
- "gitHead": "296f3dccba7a691244212a51481fffcf142fc138"
76
+ "gitHead": "02d9fa7c14c70f0a5fc1dcc5dc5506e43cb71ba5"
75
77
  }