@ocap/sdk 1.15.5 → 1.16.0
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/index.d.ts +16 -164
- package/package.json +7 -7
package/index.d.ts
CHANGED
|
@@ -132,6 +132,9 @@ declare namespace ForgeSdkUtil {
|
|
|
132
132
|
isUUID: typeof isUUID;
|
|
133
133
|
toDid: typeof toDid;
|
|
134
134
|
toAddress: typeof toAddress;
|
|
135
|
+
formatTxType: (type: any) => any;
|
|
136
|
+
leftPad: any;
|
|
137
|
+
rightPad: any;
|
|
135
138
|
}
|
|
136
139
|
}
|
|
137
140
|
|
|
@@ -165,7 +168,7 @@ declare namespace ForgeSdkUtil {
|
|
|
165
168
|
* hash: types.HashType.SHA3,
|
|
166
169
|
* });
|
|
167
170
|
*/
|
|
168
|
-
declare function DidType(type?:
|
|
171
|
+
declare function DidType(type?: DidType | string): object;
|
|
169
172
|
/**
|
|
170
173
|
* Generate a wallet from secretKey
|
|
171
174
|
*
|
|
@@ -309,169 +312,8 @@ declare namespace ForgeSdkWallet {
|
|
|
309
312
|
}
|
|
310
313
|
}
|
|
311
314
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
*
|
|
315
|
-
* @public
|
|
316
|
-
* @static
|
|
317
|
-
* @param {string} type - input type
|
|
318
|
-
* @param {object} data - input data
|
|
319
|
-
* @returns {object} [almost same structure as input]
|
|
320
|
-
*/
|
|
321
|
-
declare function formatMessage(type: string, data: any): any;
|
|
322
|
-
/**
|
|
323
|
-
* Create an protobuf encoded Typed message with specified data, ready to send to rpc server
|
|
324
|
-
*
|
|
325
|
-
* @public
|
|
326
|
-
* @static
|
|
327
|
-
* @param {string} type - message type defined in forge-proto
|
|
328
|
-
* @param {object} params - message content
|
|
329
|
-
* @returns {object} Message instance
|
|
330
|
-
* @example
|
|
331
|
-
* const { createMessage } = require('@ocap/message');
|
|
332
|
-
* const message = createMessage ('CreateAssetTx', {
|
|
333
|
-
* moniker: 'asset',
|
|
334
|
-
* address: 'zaAKEJRKQWsdfjksdfjkASRD',
|
|
335
|
-
* });
|
|
336
|
-
*
|
|
337
|
-
* message.getMoniker(); // 'asset'
|
|
338
|
-
* message.getAddress(); // 'zaAKEJRKQWsdfjksdfjkASRD'
|
|
339
|
-
* message.getReadonly(); // false
|
|
340
|
-
* message.setReadonly(true);
|
|
341
|
-
*/
|
|
342
|
-
declare function createMessage(type: string, params: any): any;
|
|
343
|
-
/**
|
|
344
|
-
* Generated a fake message for a type, the message can be RPC request/response
|
|
345
|
-
*
|
|
346
|
-
* @public
|
|
347
|
-
* @static
|
|
348
|
-
* @param {string} type - Message type string, should be defined in forge-abi or forge-core-protocol
|
|
349
|
-
* @returns {object}
|
|
350
|
-
* @example
|
|
351
|
-
* const { fakeMessage} = require('@ocap/message');
|
|
352
|
-
* const message = fakeMessage('CreateAssetTx');
|
|
353
|
-
* // will output
|
|
354
|
-
* {
|
|
355
|
-
* moniker: 'arcblock',
|
|
356
|
-
* data: { type: 'string', value: 'ABCD 1234' },
|
|
357
|
-
* readonly: true,
|
|
358
|
-
* transferrable: true,
|
|
359
|
-
* ttl: 2,
|
|
360
|
-
* parent: 'arcblock',
|
|
361
|
-
* address: 'F2D072CBD4954A20F26280730795D91AC1039996CEB6E24A31E9CE548DCB5E55',
|
|
362
|
-
* }
|
|
363
|
-
*/
|
|
364
|
-
declare function fakeMessage(type: string): any;
|
|
365
|
-
/**
|
|
366
|
-
* Decode an google.protobuf.Any%{ typeUrl, value } => { type, value }
|
|
367
|
-
*
|
|
368
|
-
* @public
|
|
369
|
-
* @static
|
|
370
|
-
* @param {object} data encoded data object
|
|
371
|
-
* @returns {object} Object%{type, value}
|
|
372
|
-
*/
|
|
373
|
-
declare function decodeAny(data: any): any;
|
|
374
|
-
/**
|
|
375
|
-
* Encode { type, value } => google.protobuf.Any%{ typeUrl, value }
|
|
376
|
-
* Does nothing on already encoded message
|
|
377
|
-
*
|
|
378
|
-
* @public
|
|
379
|
-
* @static
|
|
380
|
-
* @param {object} data
|
|
381
|
-
* @returns {object} google.protobuf.Any
|
|
382
|
-
*/
|
|
383
|
-
declare function encodeAny(data: any): any;
|
|
384
|
-
/**
|
|
385
|
-
* Convert an { seconds, nanos } | date-string to google.protobuf.Timestamp object
|
|
386
|
-
*
|
|
387
|
-
* @public
|
|
388
|
-
* @static
|
|
389
|
-
* @param {string|object} value
|
|
390
|
-
* @returns {object} instanceof google.protobuf.Timestamp
|
|
391
|
-
*/
|
|
392
|
-
declare function encodeTimestamp(value: any): any;
|
|
393
|
-
/**
|
|
394
|
-
* Decode google.protobuf.Timestamp message to ISO Date String
|
|
395
|
-
*
|
|
396
|
-
* FIXME: node strictly equal because we rounded the `nanos` field
|
|
397
|
-
*
|
|
398
|
-
* @public
|
|
399
|
-
* @static
|
|
400
|
-
* @param {object} data
|
|
401
|
-
* @returns {strong} String timestamp
|
|
402
|
-
*/
|
|
403
|
-
declare function decodeTimestamp(data: any): any;
|
|
404
|
-
/**
|
|
405
|
-
* Encode BigUint and BigSint types defined in forge-sdk, double encoding is avoided
|
|
406
|
-
*
|
|
407
|
-
* @public
|
|
408
|
-
* @static
|
|
409
|
-
* @param {buffer|string|number} value - value to encode
|
|
410
|
-
* @param {string} type - type names defined in forge-proto
|
|
411
|
-
* @returns {object} Message
|
|
412
|
-
*/
|
|
413
|
-
declare function encodeBigInt(value: any, type: string): any;
|
|
414
|
-
/**
|
|
415
|
-
* Convert BigUint and BigSint to string representation of numbers
|
|
416
|
-
*
|
|
417
|
-
* @public
|
|
418
|
-
* @static
|
|
419
|
-
* @link https://stackoverflow.com/questions/23948278/how-to-convert-byte-array-into-a-signed-big-integer-in-javascript
|
|
420
|
-
* @param {object} data - usually from encodeBigInt
|
|
421
|
-
* @param {buffer} data.value
|
|
422
|
-
* @param {boolean} data.minus
|
|
423
|
-
* @returns {string} human readable number
|
|
424
|
-
*/
|
|
425
|
-
declare function decodeBigInt(data: _OcapMessage.T100): string;
|
|
426
|
-
/**
|
|
427
|
-
* Attach an $format method to rpc response
|
|
428
|
-
*
|
|
429
|
-
* @private
|
|
430
|
-
* @param {object} data
|
|
431
|
-
* @param {string} type
|
|
432
|
-
*/
|
|
433
|
-
declare function attachFormatFn(type: string, data: any, key?: string): void;
|
|
434
|
-
/**
|
|
435
|
-
* Attach an example method to
|
|
436
|
-
*
|
|
437
|
-
* @private
|
|
438
|
-
* @param {object} data
|
|
439
|
-
* @param {string} type
|
|
440
|
-
*/
|
|
441
|
-
declare function attachExampleFn(type: string, host: any, key: any): void;
|
|
442
|
-
/**
|
|
443
|
-
* Add type provider that can be used to format/create messages
|
|
444
|
-
*
|
|
445
|
-
* @param {object} provider - proto generated from {@see @ocap/proto}
|
|
446
|
-
*/
|
|
447
|
-
declare function addProvider(provider: any): void;
|
|
448
|
-
declare function getMessageType(type: any): any;
|
|
449
|
-
declare function toTypeUrl(type: any): any;
|
|
450
|
-
declare function fromTypeUrl(url: any): any;
|
|
451
|
-
declare const _OcapMessage: _OcapMessage.T101;
|
|
452
|
-
declare namespace _OcapMessage {
|
|
453
|
-
export interface T100 {
|
|
454
|
-
value: any;
|
|
455
|
-
minus: boolean;
|
|
456
|
-
}
|
|
457
|
-
export interface T101 {
|
|
458
|
-
formatMessage: typeof formatMessage;
|
|
459
|
-
createMessage: typeof createMessage;
|
|
460
|
-
fakeMessage: typeof fakeMessage;
|
|
461
|
-
decodeAny: typeof decodeAny;
|
|
462
|
-
encodeAny: typeof encodeAny;
|
|
463
|
-
encodeTimestamp: typeof encodeTimestamp;
|
|
464
|
-
decodeTimestamp: typeof decodeTimestamp;
|
|
465
|
-
encodeBigInt: typeof encodeBigInt;
|
|
466
|
-
decodeBigInt: typeof decodeBigInt;
|
|
467
|
-
attachFormatFn: typeof attachFormatFn;
|
|
468
|
-
attachExampleFn: typeof attachExampleFn;
|
|
469
|
-
addProvider: typeof addProvider;
|
|
470
|
-
getMessageType: typeof getMessageType;
|
|
471
|
-
toTypeUrl: typeof toTypeUrl;
|
|
472
|
-
fromTypeUrl: typeof fromTypeUrl;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
315
|
+
import * as LibMessage from './lib/message';
|
|
316
|
+
declare const _OcapMessage: typeof LibMessage;
|
|
475
317
|
export = _OcapMessage;
|
|
476
318
|
|
|
477
319
|
/**
|
|
@@ -578,6 +420,15 @@ declare function toTokenAddress(itx: any): string;
|
|
|
578
420
|
* @returns {string} factory address without `did:abt:` prefix
|
|
579
421
|
*/
|
|
580
422
|
declare function toFactoryAddress(itx: any): string;
|
|
423
|
+
/**
|
|
424
|
+
* Create an rollup address
|
|
425
|
+
*
|
|
426
|
+
* @public
|
|
427
|
+
* @static
|
|
428
|
+
* @param {object} itx - an object of `CreateRollupTx`
|
|
429
|
+
* @returns {string} rollup address without `did:abt:` prefix
|
|
430
|
+
*/
|
|
431
|
+
declare function toRollupAddress(itx: any): string;
|
|
581
432
|
declare namespace ForgeSdkUtil {
|
|
582
433
|
export interface T100 {
|
|
583
434
|
toAssetAddress: typeof toAssetAddress;
|
|
@@ -591,6 +442,7 @@ declare namespace ForgeSdkUtil {
|
|
|
591
442
|
toSwapAddress: typeof toSwapAddress;
|
|
592
443
|
toTokenAddress: typeof toTokenAddress;
|
|
593
444
|
toFactoryAddress: typeof toFactoryAddress;
|
|
445
|
+
toRollupAddress: typeof toRollupAddress;
|
|
594
446
|
}
|
|
595
447
|
}
|
|
596
448
|
|
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.
|
|
4
|
+
"version": "1.16.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "wangshijun",
|
|
7
7
|
"email": "shijun@arcblock.io",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@arcblock/did-util": "1.
|
|
19
|
-
"@ocap/client": "1.
|
|
20
|
-
"@ocap/message": "1.
|
|
21
|
-
"@ocap/util": "1.
|
|
22
|
-
"@ocap/wallet": "1.
|
|
18
|
+
"@arcblock/did-util": "1.16.0",
|
|
19
|
+
"@ocap/client": "1.16.0",
|
|
20
|
+
"@ocap/message": "1.16.0",
|
|
21
|
+
"@ocap/util": "1.16.0",
|
|
22
|
+
"@ocap/wallet": "1.16.0",
|
|
23
23
|
"debug": "^4.3.3",
|
|
24
24
|
"react-app-polyfill": "^1.0.1"
|
|
25
25
|
},
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"test": "jest --forceExit --detectOpenHandles",
|
|
79
79
|
"coverage": "yarn test -- --coverage"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "71742ee4fe24b9d2ac32b2a50bef5ce822b3a264"
|
|
82
82
|
}
|