@ocap/message 1.15.7 → 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 +2 -163
- package/package.json +4 -4
package/index.d.ts
CHANGED
|
@@ -1,166 +1,5 @@
|
|
|
1
1
|
// Generate by [js2dts@0.3.3](https://github.com/whxaxes/js2dts#readme)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
* @static
|
|
8
|
-
* @param {string} type - input type
|
|
9
|
-
* @param {object} data - input data
|
|
10
|
-
* @returns {object} [almost same structure as input]
|
|
11
|
-
*/
|
|
12
|
-
declare function formatMessage(type: string, data: any): any;
|
|
13
|
-
/**
|
|
14
|
-
* Create an protobuf encoded Typed message with specified data, ready to send to rpc server
|
|
15
|
-
*
|
|
16
|
-
* @public
|
|
17
|
-
* @static
|
|
18
|
-
* @param {string} type - message type defined in forge-proto
|
|
19
|
-
* @param {object} params - message content
|
|
20
|
-
* @returns {object} Message instance
|
|
21
|
-
* @example
|
|
22
|
-
* const { createMessage } = require('@ocap/message');
|
|
23
|
-
* const message = createMessage ('CreateAssetTx', {
|
|
24
|
-
* moniker: 'asset',
|
|
25
|
-
* address: 'zaAKEJRKQWsdfjksdfjkASRD',
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* message.getMoniker(); // 'asset'
|
|
29
|
-
* message.getAddress(); // 'zaAKEJRKQWsdfjksdfjkASRD'
|
|
30
|
-
* message.getReadonly(); // false
|
|
31
|
-
* message.setReadonly(true);
|
|
32
|
-
*/
|
|
33
|
-
declare function createMessage(type: string, params: any): any;
|
|
34
|
-
/**
|
|
35
|
-
* Generated a fake message for a type, the message can be RPC request/response
|
|
36
|
-
*
|
|
37
|
-
* @public
|
|
38
|
-
* @static
|
|
39
|
-
* @param {string} type - Message type string, should be defined in forge-abi or forge-core-protocol
|
|
40
|
-
* @returns {object}
|
|
41
|
-
* @example
|
|
42
|
-
* const { fakeMessage} = require('@ocap/message');
|
|
43
|
-
* const message = fakeMessage('CreateAssetTx');
|
|
44
|
-
* // will output
|
|
45
|
-
* {
|
|
46
|
-
* moniker: 'arcblock',
|
|
47
|
-
* data: { type: 'string', value: 'ABCD 1234' },
|
|
48
|
-
* readonly: true,
|
|
49
|
-
* transferrable: true,
|
|
50
|
-
* ttl: 2,
|
|
51
|
-
* parent: 'arcblock',
|
|
52
|
-
* address: 'F2D072CBD4954A20F26280730795D91AC1039996CEB6E24A31E9CE548DCB5E55',
|
|
53
|
-
* }
|
|
54
|
-
*/
|
|
55
|
-
declare function fakeMessage(type: string): any;
|
|
56
|
-
/**
|
|
57
|
-
* Decode an google.protobuf.Any%{ typeUrl, value } => { type, value }
|
|
58
|
-
*
|
|
59
|
-
* @public
|
|
60
|
-
* @static
|
|
61
|
-
* @param {object} data encoded data object
|
|
62
|
-
* @returns {object} Object%{type, value}
|
|
63
|
-
*/
|
|
64
|
-
declare function decodeAny(data: any): any;
|
|
65
|
-
/**
|
|
66
|
-
* Encode { type, value } => google.protobuf.Any%{ typeUrl, value }
|
|
67
|
-
* Does nothing on already encoded message
|
|
68
|
-
*
|
|
69
|
-
* @public
|
|
70
|
-
* @static
|
|
71
|
-
* @param {object} data
|
|
72
|
-
* @returns {object} google.protobuf.Any
|
|
73
|
-
*/
|
|
74
|
-
declare function encodeAny(data: any): any;
|
|
75
|
-
/**
|
|
76
|
-
* Convert an { seconds, nanos } | date-string to google.protobuf.Timestamp object
|
|
77
|
-
*
|
|
78
|
-
* @public
|
|
79
|
-
* @static
|
|
80
|
-
* @param {string|object} value
|
|
81
|
-
* @returns {object} instanceof google.protobuf.Timestamp
|
|
82
|
-
*/
|
|
83
|
-
declare function encodeTimestamp(value: any): any;
|
|
84
|
-
/**
|
|
85
|
-
* Decode google.protobuf.Timestamp message to ISO Date String
|
|
86
|
-
*
|
|
87
|
-
* FIXME: node strictly equal because we rounded the `nanos` field
|
|
88
|
-
*
|
|
89
|
-
* @public
|
|
90
|
-
* @static
|
|
91
|
-
* @param {object} data
|
|
92
|
-
* @returns {strong} String timestamp
|
|
93
|
-
*/
|
|
94
|
-
declare function decodeTimestamp(data: any): any;
|
|
95
|
-
/**
|
|
96
|
-
* Encode BigUint and BigSint types defined in forge-sdk, double encoding is avoided
|
|
97
|
-
*
|
|
98
|
-
* @public
|
|
99
|
-
* @static
|
|
100
|
-
* @param {buffer|string|number} value - value to encode
|
|
101
|
-
* @param {string} type - type names defined in forge-proto
|
|
102
|
-
* @returns {object} Message
|
|
103
|
-
*/
|
|
104
|
-
declare function encodeBigInt(value: any, type: string): any;
|
|
105
|
-
/**
|
|
106
|
-
* Convert BigUint and BigSint to string representation of numbers
|
|
107
|
-
*
|
|
108
|
-
* @public
|
|
109
|
-
* @static
|
|
110
|
-
* @link https://stackoverflow.com/questions/23948278/how-to-convert-byte-array-into-a-signed-big-integer-in-javascript
|
|
111
|
-
* @param {object} data - usually from encodeBigInt
|
|
112
|
-
* @param {buffer} data.value
|
|
113
|
-
* @param {boolean} data.minus
|
|
114
|
-
* @returns {string} human readable number
|
|
115
|
-
*/
|
|
116
|
-
declare function decodeBigInt(data: _OcapMessage.T100): string;
|
|
117
|
-
/**
|
|
118
|
-
* Attach an $format method to rpc response
|
|
119
|
-
*
|
|
120
|
-
* @private
|
|
121
|
-
* @param {object} data
|
|
122
|
-
* @param {string} type
|
|
123
|
-
*/
|
|
124
|
-
declare function attachFormatFn(type: string, data: any, key?: string): void;
|
|
125
|
-
/**
|
|
126
|
-
* Attach an example method to
|
|
127
|
-
*
|
|
128
|
-
* @private
|
|
129
|
-
* @param {object} data
|
|
130
|
-
* @param {string} type
|
|
131
|
-
*/
|
|
132
|
-
declare function attachExampleFn(type: string, host: any, key: any): void;
|
|
133
|
-
/**
|
|
134
|
-
* Add type provider that can be used to format/create messages
|
|
135
|
-
*
|
|
136
|
-
* @param {object} provider - proto generated from {@see @ocap/proto}
|
|
137
|
-
*/
|
|
138
|
-
declare function addProvider(provider: any): void;
|
|
139
|
-
declare function getMessageType(type: any): any;
|
|
140
|
-
declare function toTypeUrl(type: any): any;
|
|
141
|
-
declare function fromTypeUrl(url: any): any;
|
|
142
|
-
declare const _OcapMessage: _OcapMessage.T101;
|
|
143
|
-
declare namespace _OcapMessage {
|
|
144
|
-
export interface T100 {
|
|
145
|
-
value: any;
|
|
146
|
-
minus: boolean;
|
|
147
|
-
}
|
|
148
|
-
export interface T101 {
|
|
149
|
-
formatMessage: typeof formatMessage;
|
|
150
|
-
createMessage: typeof createMessage;
|
|
151
|
-
fakeMessage: typeof fakeMessage;
|
|
152
|
-
decodeAny: typeof decodeAny;
|
|
153
|
-
encodeAny: typeof encodeAny;
|
|
154
|
-
encodeTimestamp: typeof encodeTimestamp;
|
|
155
|
-
decodeTimestamp: typeof decodeTimestamp;
|
|
156
|
-
encodeBigInt: typeof encodeBigInt;
|
|
157
|
-
decodeBigInt: typeof decodeBigInt;
|
|
158
|
-
attachFormatFn: typeof attachFormatFn;
|
|
159
|
-
attachExampleFn: typeof attachExampleFn;
|
|
160
|
-
addProvider: typeof addProvider;
|
|
161
|
-
getMessageType: typeof getMessageType;
|
|
162
|
-
toTypeUrl: typeof toTypeUrl;
|
|
163
|
-
fromTypeUrl: typeof fromTypeUrl;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
3
|
+
import * as LibMessage from './lib/message';
|
|
4
|
+
declare const _OcapMessage: typeof LibMessage;
|
|
166
5
|
export = _OcapMessage;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/message",
|
|
3
3
|
"description": "Utility functions to encode and decode message that can send to forge",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.16.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "wangshijun",
|
|
7
7
|
"email": "shijun@arcblock.io",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@ocap/proto": "1.
|
|
19
|
-
"@ocap/util": "1.
|
|
18
|
+
"@ocap/proto": "1.16.0",
|
|
19
|
+
"@ocap/util": "1.16.0",
|
|
20
20
|
"debug": "^4.3.3",
|
|
21
21
|
"google-protobuf": "3.18.0",
|
|
22
22
|
"lodash": "^4.17.21"
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"test": "jest --forceExit --detectOpenHandles",
|
|
69
69
|
"coverage": "yarn test -- --coverage"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "71742ee4fe24b9d2ac32b2a50bef5ce822b3a264"
|
|
72
72
|
}
|