@ocap/asset 1.17.3 → 1.17.6

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 { AssetFactoryState, CreateAssetTx } 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<AssetFactoryState.AsObject>;
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: CreateAssetTx.AsObject;
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.3",
4
+ "version": "1.17.6",
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.3",
22
- "@arcblock/did-util": "1.17.3",
23
- "@arcblock/vc": "1.17.3",
24
- "@ocap/contract": "1.17.3",
25
- "@ocap/mcrypto": "1.17.3",
26
- "@ocap/util": "1.17.3",
27
- "@ocap/wallet": "1.17.3",
21
+ "@arcblock/did": "1.17.6",
22
+ "@arcblock/did-util": "1.17.6",
23
+ "@arcblock/vc": "1.17.6",
24
+ "@ocap/contract": "1.17.6",
25
+ "@ocap/mcrypto": "1.17.6",
26
+ "@ocap/types": "1.17.6",
27
+ "@ocap/util": "1.17.6",
28
+ "@ocap/wallet": "1.17.6",
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": "7a74e4e2b362a6e6ea8d14617f0480966c3363d5"
76
+ "gitHead": "68e7711c1550c24505e4b8f5de1867a6ce360be8"
75
77
  }