@ocap/sdk 1.27.16 → 1.28.1

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.
Files changed (2) hide show
  1. package/index.d.ts +127 -66
  2. package/package.json +7 -7
package/index.d.ts CHANGED
@@ -1,22 +1,23 @@
1
- import type { LiteralUnion } from 'type-fest';
1
+ import { BN } from './bn.js';
2
+ import { LiteralUnion } from 'type-fest';
2
3
  import rightPad from 'lodash/padEnd';
3
4
  import leftPad from 'lodash/padStart';
4
- import { BN } from './bn';
5
- export declare const isBase58btc: (data: any) => boolean;
6
- export type BytesType = string | Buffer | Uint8Array;
7
- export type EncodingType = LiteralUnion<'hex' | 'base16' | 'base58' | 'base64' | 'Uint8Array' | 'buffer', string>;
8
- export type KeyPairType = {
5
+
6
+ //#region src/index.d.ts
7
+ declare const isBase58btc: (data: any) => boolean;
8
+ type BytesType = string | Buffer | Uint8Array;
9
+ type EncodingType = LiteralUnion<'hex' | 'base16' | 'base58' | 'base64' | 'Uint8Array' | 'buffer', string>;
10
+ type KeyPairType = {
9
11
  publicKey: BytesType;
10
12
  secretKey: BytesType;
11
13
  };
12
- export { BN, leftPad, rightPad };
13
14
  /**
14
15
  * Returns a BN object, converts a number value to a BN
15
16
  * @param {string|number|BN} `arg` input a string number, hex string number, number, BigNumber or BN object
16
17
  * @return {BN} `output` BN object of the number
17
18
  * @throws if the argument is not an array, object that isn't a bignumber, not a string number or number
18
19
  */
19
- export declare const numberToBN: (arg: string | number | BN) => BN;
20
+ declare const numberToBN: (arg: string | number | BN) => BN;
20
21
  /**
21
22
  * Returns a `boolean` on whether or not the `string` starts with '0x'
22
23
  *
@@ -26,14 +27,14 @@ export declare const numberToBN: (arg: string | number | BN) => BN;
26
27
  * @return {Boolean} a boolean if it is or is not hex prefixed
27
28
  * @throws if the str input is not a string
28
29
  */
29
- export declare const isHexPrefixed: (str: string) => boolean;
30
+ declare const isHexPrefixed: (str: string) => boolean;
30
31
  /**
31
32
  * Removes '0x' from a given `String` if present
32
33
  *
33
34
  * @public
34
35
  * @static
35
36
  */
36
- export declare const stripHexPrefix: (str: string | any) => any;
37
+ declare const stripHexPrefix: (str: string | any) => any;
37
38
  /**
38
39
  * Returns true if object is BN, otherwise false
39
40
  *
@@ -43,7 +44,7 @@ export declare const stripHexPrefix: (str: string | any) => any;
43
44
  * @param {Object} object
44
45
  * @returns {Boolean}
45
46
  */
46
- export declare const isBN: (object: $TSFixMe) => boolean;
47
+ declare const isBN: (object: $TSFixMe) => boolean;
47
48
  /**
48
49
  * Returns true if object is BigNumber, otherwise false
49
50
  *
@@ -53,7 +54,7 @@ export declare const isBN: (object: $TSFixMe) => boolean;
53
54
  * @param {Object} object
54
55
  * @returns {Boolean}
55
56
  */
56
- export declare const isBigNumber: (object: $TSFixMe) => boolean;
57
+ declare const isBigNumber: (object: $TSFixMe) => boolean;
57
58
  /**
58
59
  * Check if string is HEX, requires a 0x in front
59
60
  *
@@ -63,7 +64,7 @@ export declare const isBigNumber: (object: $TSFixMe) => boolean;
63
64
  * @param {String} hex to be checked
64
65
  * @returns {Boolean}
65
66
  */
66
- export declare const isHexStrict: (hex: string) => boolean;
67
+ declare const isHexStrict: (hex: string) => boolean;
67
68
  /**
68
69
  * Check if string is HEX
69
70
  *
@@ -73,7 +74,7 @@ export declare const isHexStrict: (hex: string) => boolean;
73
74
  * @param {String} hex to be checked
74
75
  * @returns {Boolean}
75
76
  */
76
- export declare const isHex: (hex: string) => boolean;
77
+ declare const isHex: (hex: string) => boolean;
77
78
  /**
78
79
  * Takes an input and transforms it into an BN
79
80
  *
@@ -83,7 +84,7 @@ export declare const isHex: (hex: string) => boolean;
83
84
  * @param {Number|String|BN} num, string, HEX string or BN
84
85
  * @returns {BN} BN
85
86
  */
86
- export declare const toBN: (num: number | string | BN, base?: number | 'hex') => BN;
87
+ declare const toBN: (num: number | string | BN, base?: number | 'hex') => BN;
87
88
  /**
88
89
  * Should be called to get hex representation (prefixed by 0x) of utf8 string
89
90
  *
@@ -93,7 +94,7 @@ export declare const toBN: (num: number | string | BN, base?: number | 'hex') =>
93
94
  * @param {String} str
94
95
  * @returns {String} hex representation of input string
95
96
  */
96
- export declare const utf8ToHex: (str: string) => string;
97
+ declare const utf8ToHex: (str: string) => string;
97
98
  /**
98
99
  * Should be called to get utf8 from it's hex representation
99
100
  *
@@ -103,7 +104,7 @@ export declare const utf8ToHex: (str: string) => string;
103
104
  * @param {String} hex
104
105
  * @returns {String} ascii string representation of hex value
105
106
  */
106
- export declare const hexToUtf8: (hex: string) => string;
107
+ declare const hexToUtf8: (hex: string) => string;
107
108
  /**
108
109
  * Converts value to number representation
109
110
  *
@@ -113,7 +114,7 @@ export declare const hexToUtf8: (hex: string) => string;
113
114
  * @param {String|Number|BN} value
114
115
  * @returns {Number}
115
116
  */
116
- export declare const hexToNumber: (value: string | number | BN) => number;
117
+ declare const hexToNumber: (value: string | number | BN) => number;
117
118
  /**
118
119
  * Converts value to hex representation
119
120
  *
@@ -123,7 +124,7 @@ export declare const hexToNumber: (value: string | number | BN) => number;
123
124
  * @param {String|Number|BN} value
124
125
  * @returns {String}
125
126
  */
126
- export declare const numberToHex: (value: $TSFixMe) => string;
127
+ declare const numberToHex: (value: $TSFixMe) => string;
127
128
  /**
128
129
  * Convert a byte array to a hex string
129
130
  * Note: Implementation from crypto-js
@@ -134,7 +135,7 @@ export declare const numberToHex: (value: $TSFixMe) => string;
134
135
  * @param {Array} bytes
135
136
  * @returns {String} the hex string
136
137
  */
137
- export declare const bytesToHex: (bytes: $TSFixMe) => string;
138
+ declare const bytesToHex: (bytes: $TSFixMe) => string;
138
139
  /**
139
140
  * Convert a hex string to a byte array
140
141
  * Note: Implementation from crypto-js
@@ -145,7 +146,7 @@ export declare const bytesToHex: (bytes: $TSFixMe) => string;
145
146
  * @param {String} hex
146
147
  * @returns {Array} the byte array
147
148
  */
148
- export declare const hexToBytes: (hex: $TSFixMe) => Array<any>;
149
+ declare const hexToBytes: (hex: $TSFixMe) => Array<any>;
149
150
  /**
150
151
  * Auto converts any given value into it's hex representation.
151
152
  * And even stringify objects before.
@@ -157,7 +158,7 @@ export declare const hexToBytes: (hex: $TSFixMe) => Array<any>;
157
158
  * @param {Boolean} returnType
158
159
  * @returns {String}
159
160
  */
160
- export declare const toHex: (
161
+ declare const toHex: (
161
162
  value:
162
163
  | string
163
164
  | number
@@ -176,79 +177,118 @@ export declare const toHex: (
176
177
  },
177
178
  returnType?: boolean
178
179
  ) => string;
179
- export declare const numberToString: (arg: $TSFixMe) => any;
180
+ declare const numberToString: (arg: $TSFixMe) => any;
180
181
  /**
181
182
  * Format a big number to human readable number, such as 1_0000_0000_0000_000 => 1 Token
182
183
  */
183
- export declare const fromUnitToToken: (
184
- input: string | number | BN,
185
- decimal?: number,
186
- optionsInput?: $TSFixMe
187
- ) => string;
184
+ declare const fromUnitToToken: (input: string | number | BN, decimal?: number, optionsInput?: $TSFixMe) => string;
188
185
  /**
189
186
  * Convert human readable token number to big number instance
190
187
  */
191
- export declare const fromTokenToUnit: (input: string | number, decimal?: number) => BN;
188
+ declare const fromTokenToUnit: (input: string | number, decimal?: number) => BN;
192
189
  /**
193
190
  * Validates if a value is an Uint8Array.
194
191
  */
195
- export declare function isUint8Array(value: $TSFixMe): boolean;
192
+ declare function isUint8Array(value: $TSFixMe): boolean;
196
193
  /**
197
194
  * Generate a random UUID
198
195
  */
199
- export declare function UUID(): string;
196
+ declare function UUID(): string;
200
197
  /**
201
198
  * Check if a string is valid UUID
202
199
  */
203
- export declare function isUUID(str: string): boolean;
200
+ declare function isUUID(str: string): boolean;
204
201
  /**
205
202
  * Convert input to Uint8Array on best effort, base64 node supported
206
203
  */
207
- export declare function toUint8Array(v: any): Uint8Array;
204
+ declare function toUint8Array(v: any): Uint8Array;
208
205
  /**
209
206
  * Convert input to Buffer on best effort, base64 not supported
210
207
  */
211
- export declare function toBuffer(v: any): Buffer;
208
+ declare function toBuffer(v: any): Buffer;
212
209
  /**
213
210
  * Convert input to base58btc format on best effort
214
211
  */
215
- export declare function toBase58(v: any): string;
212
+ declare function toBase58(v: any): string;
216
213
  /**
217
214
  * Decode base58 string
218
215
  */
219
- export declare function fromBase58(v: string): Buffer;
216
+ declare function fromBase58(v: string): Buffer;
220
217
  /**
221
218
  * Convert input to base64 format
222
219
  */
223
- export declare function toBase64(v: any, escape?: boolean): string;
220
+ declare function toBase64(v: any, escape?: boolean): string;
224
221
  /**
225
222
  * Decode base64(base64_url) string to buffer
226
223
  */
227
- export declare function fromBase64(v: string): Buffer;
224
+ declare function fromBase64(v: string): Buffer;
228
225
  /**
229
226
  * Convert did to address: remove `did:abt:` prefix
230
227
  */
231
- export declare function toAddress(did: string): string;
228
+ declare function toAddress(did: string): string;
232
229
  /**
233
230
  * Convert address to did: prepend `did:abt:` prefix
234
231
  */
235
- export declare function toDid(address: string): string;
236
- export declare function isSameDid(a: string, b: string): boolean;
237
- export declare function formatTxType(type: string): any;
238
- import { EncodingType, BytesType } from '@ocap/util';
239
- import { DidType, DIDType, DIDTypeStr, DIDTypeArg } from '@arcblock/did';
232
+ declare function toDid(address: string): string;
233
+ declare function isSameDid(a: string, b: string): boolean;
234
+ declare function formatTxType(type: string): Capitalize<string>;
235
+ //#endregion
236
+ export {
237
+ BN,
238
+ BytesType,
239
+ EncodingType,
240
+ KeyPairType,
241
+ UUID,
242
+ bytesToHex,
243
+ formatTxType,
244
+ fromBase58,
245
+ fromBase64,
246
+ fromTokenToUnit,
247
+ fromUnitToToken,
248
+ hexToBytes,
249
+ hexToNumber,
250
+ hexToUtf8,
251
+ isBN,
252
+ isBase58btc,
253
+ isBigNumber,
254
+ isHex,
255
+ isHexPrefixed,
256
+ isHexStrict,
257
+ isSameDid,
258
+ isUUID,
259
+ isUint8Array,
260
+ leftPad,
261
+ numberToBN,
262
+ numberToHex,
263
+ numberToString,
264
+ rightPad,
265
+ stripHexPrefix,
266
+ toAddress,
267
+ toBN,
268
+ toBase58,
269
+ toBase64,
270
+ toBuffer,
271
+ toDid,
272
+ toHex,
273
+ toUint8Array,
274
+ utf8ToHex,
275
+ };
276
+ import { BytesType, EncodingType } from '@ocap/util';
277
+ import { DIDType, DIDTypeArg, DIDTypeStr, DidType } from '@arcblock/did';
278
+
279
+ //#region src/index.d.ts
240
280
  type KeyPairType<T extends BytesType = string> = {
241
281
  sk?: T;
242
282
  pk?: T;
243
283
  address?: string;
244
284
  };
245
- export type SerializedWallet = {
285
+ type SerializedWallet = {
246
286
  type: DIDTypeStr;
247
287
  pk: string;
248
288
  sk: string;
249
289
  address: string;
250
290
  };
251
- export interface WalletObject<T extends BytesType = string> {
291
+ interface WalletObject<T extends BytesType = string> {
252
292
  type: DIDType;
253
293
  secretKey: T;
254
294
  publicKey: T;
@@ -279,11 +319,11 @@ export interface WalletObject<T extends BytesType = string> {
279
319
  */
280
320
  toAddress(): string;
281
321
  }
282
- export declare const WalletType: typeof DidType;
322
+ declare const WalletType: typeof DidType;
283
323
  /**
284
324
  * Generate an wallet instance that can be used to sign a message or verify a signature
285
325
  */
286
- export declare function Wallet<T extends BytesType = string>(keyPair: KeyPairType<T>, t?: DIDTypeArg): WalletObject<T>;
326
+ declare function Wallet<T extends BytesType = string>(keyPair: KeyPairType<T>, t?: DIDTypeArg): WalletObject<T>;
287
327
  /**
288
328
  * Generate a wallet from secretKey
289
329
  *
@@ -302,67 +342,81 @@ export declare function Wallet<T extends BytesType = string>(keyPair: KeyPairTyp
302
342
  * assert.equal(signature, sig, "signature should match");
303
343
  * assert.ok(wallet.verify(message, signature), "signature should be verified");
304
344
  */
305
- export declare function fromSecretKey<T extends BytesType = string>(sk: T, _type?: DIDTypeArg): WalletObject<T>;
345
+ declare function fromSecretKey<T extends BytesType = string>(sk: T, _type?: DIDTypeArg): WalletObject<T>;
306
346
  /**
307
347
  * Generate a wallet from publicKey
308
348
  */
309
- export declare function fromPublicKey<T extends BytesType = string>(pk: T, _type?: DIDTypeArg): WalletObject<T>;
349
+ declare function fromPublicKey<T extends BytesType = string>(pk: T, _type?: DIDTypeArg): WalletObject<T>;
310
350
  /**
311
351
  * Generate a wallet from address (did)
312
352
  *
313
353
  * Since we do not know the publicKey and secretKey, this kind of wallet cannot be used for signing and verifying
314
354
  */
315
- export declare function fromAddress<T extends BytesType = string>(address: string): WalletObject<T>;
355
+ declare function fromAddress<T extends BytesType = string>(address: string): WalletObject<T>;
316
356
  /**
317
357
  * Generate a wallet by generating a random secretKey
318
358
  */
319
- export declare function fromRandom<T extends BytesType = string>(_type?: DIDTypeArg): WalletObject<T>;
359
+ declare function fromRandom<T extends BytesType = string>(_type?: DIDTypeArg): WalletObject<T>;
320
360
  /**
321
361
  * Generating a wallet from a serialized json presentation of another wallet
322
362
  */
323
- export declare function fromJSON<T extends BytesType = string>(json: SerializedWallet): WalletObject<T>;
363
+ declare function fromJSON<T extends BytesType = string>(json: SerializedWallet): WalletObject<T>;
324
364
  /**
325
365
  * Check if an object is valid wallet object
326
366
  */
327
- export declare function isValid(wallet: WalletObject, canSign?: boolean): boolean;
328
- export {};
367
+ declare function isValid(wallet: WalletObject, canSign?: boolean): boolean;
368
+ //#endregion
329
369
 
330
370
  import * as LibMessage from './lib/message';
331
371
  declare const _OcapMessage: typeof LibMessage;
332
372
  export = _OcapMessage;
333
- import { TCreateAssetTx, TCreateFactoryTx, TCreateRollupTx, TCreateTokenTx, CreateTokenFactoryTx } from '@ocap/types';
373
+ import { CreateTokenFactoryTx, TCreateAssetTx, TCreateFactoryTx, TCreateRollupTx, TCreateTokenTx } from '@ocap/types';
374
+
375
+ //#region src/index.d.ts
376
+
334
377
  /**
335
378
  * Create an itx address
336
379
  */
337
- export declare function toItxAddress(itx: object, type: string, role?: number): string;
380
+ declare function toItxAddress(itx: object, type: string, role?: number): string;
338
381
  /**
339
382
  * Create an asset address
340
383
  */
341
- export declare function toAssetAddress(itx: Partial<TCreateAssetTx>): string;
384
+ declare function toAssetAddress(itx: Partial<TCreateAssetTx>): string;
342
385
  /**
343
386
  * Create an asset factory address
344
387
  */
345
- export declare function toFactoryAddress(itx: Partial<TCreateFactoryTx>): string;
388
+ declare function toFactoryAddress(itx: Partial<TCreateFactoryTx>): string;
346
389
  /**
347
390
  * Create an token address
348
391
  */
349
- export declare function toTokenAddress(itx: Partial<TCreateTokenTx>): string;
392
+ declare function toTokenAddress(itx: Partial<TCreateTokenTx>): string;
350
393
  /**
351
394
  * Create a token factory address
352
395
  */
353
- export declare function toTokenFactoryAddress(itx: Partial<CreateTokenFactoryTx>): string;
396
+ declare function toTokenFactoryAddress(itx: Partial<CreateTokenFactoryTx>): string;
354
397
  /**
355
398
  * Create an rollup address
356
399
  */
357
- export declare function toRollupAddress(itx: Partial<TCreateRollupTx>): string;
400
+ declare function toRollupAddress(itx: Partial<TCreateRollupTx>): string;
358
401
  /**
359
402
  * Generate an stake address, eg: the did of the stake
360
403
  */
361
- export declare function toStakeAddress(sender: string, receiver: string, nonce?: string): string;
404
+ declare function toStakeAddress(sender: string, receiver: string, nonce?: string): string;
362
405
  /**
363
406
  * Generate an delegate address, eg: the did of the delegation
364
407
  */
365
- export declare function toDelegateAddress(delegator: string, delegatee: string): string;
408
+ declare function toDelegateAddress(delegator: string, delegatee: string): string;
409
+ //#endregion
410
+ export {
411
+ toAssetAddress,
412
+ toDelegateAddress,
413
+ toFactoryAddress,
414
+ toItxAddress,
415
+ toRollupAddress,
416
+ toStakeAddress,
417
+ toTokenAddress,
418
+ toTokenFactoryAddress,
419
+ };
366
420
  import { WalletObject } from '@ocap/wallet';
367
421
 
368
422
  type PartialDeep<T> = {
@@ -375,8 +429,6 @@ type PartialDeep<T> = {
375
429
 
376
430
  /*~ Write your module's methods and properties in this class */
377
431
  declare interface OcapSDK {
378
- constructor(endpoint: string, autoInit: boolean = true);
379
-
380
432
  getQueries(): string[];
381
433
  getSubscriptions(): string[];
382
434
  getMutations(): string[];
@@ -1686,6 +1738,7 @@ declare namespace GraphQLClient {
1686
1738
  initialSupply: string;
1687
1739
  maxTotalSupply: string;
1688
1740
  foreignToken: GraphQLClient.ForeignToken;
1741
+ spenders: string[];
1689
1742
  website: string;
1690
1743
  metadata: GraphQLClient.Any;
1691
1744
  data: GraphQLClient.Any;
@@ -2105,6 +2158,9 @@ declare namespace GraphQLClient {
2105
2158
  foreignToken: GraphQLClient.ForeignToken;
2106
2159
  tokenFactoryAddress: string;
2107
2160
  website: string;
2161
+ spenders: string[];
2162
+ minters: string[];
2163
+ type: string;
2108
2164
  metadata: GraphQLClient.Any;
2109
2165
  data: GraphQLClient.Any;
2110
2166
  }
@@ -2691,6 +2747,9 @@ declare namespace GraphQLClient {
2691
2747
  foreignToken: GraphQLClient.ForeignToken;
2692
2748
  tokenFactoryAddress: string;
2693
2749
  website: string;
2750
+ spenders: string[];
2751
+ minters: string[];
2752
+ type: string;
2694
2753
  metadata: GraphQLClient.Any;
2695
2754
  context: GraphQLClient.StateContext;
2696
2755
  data: GraphQLClient.Any;
@@ -2792,6 +2851,7 @@ declare namespace GraphQLClient {
2792
2851
 
2793
2852
  interface TxStakeConfig {
2794
2853
  createToken: string;
2854
+ createCreditToken: string;
2795
2855
  createTokenLockPeriod: number;
2796
2856
  }
2797
2857
 
@@ -3029,6 +3089,7 @@ declare namespace GraphQLClient {
3029
3089
  stakeFilter: GraphQLClient.StakeFilterInput;
3030
3090
  delegationFilter: GraphQLClient.DelegationFilterInput;
3031
3091
  tokenFactoryFilter: GraphQLClient.TokenFactoryFilterInput;
3092
+ includeData: boolean;
3032
3093
  }
3033
3094
 
3034
3095
  interface ListTokensParams {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ocap/sdk",
3
3
  "description": "Forge javascript SDK packages all-in-one",
4
- "version": "1.27.16",
4
+ "version": "1.28.1",
5
5
  "author": {
6
6
  "name": "wangshijun",
7
7
  "email": "shijun@arcblock.io",
@@ -22,11 +22,11 @@
22
22
  "debug": "^4.3.6",
23
23
  "react-app-polyfill": "^1.0.6",
24
24
  "readable-stream": "3.6.0",
25
- "@arcblock/did-util": "1.27.16",
26
- "@ocap/client": "1.27.16",
27
- "@ocap/message": "1.27.16",
28
- "@ocap/util": "1.27.16",
29
- "@ocap/wallet": "1.27.16"
25
+ "@arcblock/did-util": "1.28.1",
26
+ "@ocap/client": "1.28.1",
27
+ "@ocap/message": "1.28.1",
28
+ "@ocap/util": "1.28.1",
29
+ "@ocap/wallet": "1.28.1"
30
30
  },
31
31
  "devDependencies": {
32
32
  "inspectpack": "^4.7.1",
@@ -39,7 +39,7 @@
39
39
  "webpack": "^5.94.0",
40
40
  "webpack-bundle-analyzer": "^4.10.2",
41
41
  "webpack-cli": "^5.1.4",
42
- "@ocap/e2e-test": "1.27.16"
42
+ "@ocap/e2e-test": "1.28.1"
43
43
  },
44
44
  "remarkConfig": {
45
45
  "plugins": [