koilib 2.7.0 → 3.1.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/README.md +75 -12
- package/dist/koinos.js +8556 -269
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +66 -18
- package/lib/Contract.js +103 -40
- package/lib/Contract.js.map +1 -1
- package/lib/Provider.d.ts +22 -7
- package/lib/Provider.js +60 -21
- package/lib/Provider.js.map +1 -1
- package/lib/Serializer.d.ts +9 -3
- package/lib/Serializer.js +111 -85
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.d.ts +58 -38
- package/lib/Signer.js +318 -97
- package/lib/Signer.js.map +1 -1
- package/lib/browser/Contract.d.ts +66 -18
- package/lib/browser/Contract.js +103 -40
- package/lib/browser/Contract.js.map +1 -1
- package/lib/browser/Provider.d.ts +22 -7
- package/lib/browser/Provider.js +60 -21
- package/lib/browser/Provider.js.map +1 -1
- package/lib/browser/Serializer.d.ts +9 -3
- package/lib/browser/Serializer.js +111 -85
- package/lib/browser/Serializer.js.map +1 -1
- package/lib/browser/Signer.d.ts +58 -38
- package/lib/browser/Signer.js +318 -97
- package/lib/browser/Signer.js.map +1 -1
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/index.js +1 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/indexUtils.d.ts +2 -0
- package/lib/browser/indexUtils.js +15 -0
- package/lib/browser/indexUtils.js.map +1 -0
- package/lib/browser/interface.d.ts +242 -46
- package/lib/browser/jsonDescriptors/chain-proto.json +676 -0
- package/lib/browser/jsonDescriptors/{krc20-proto.json → token-proto.json} +47 -4
- package/lib/browser/protoModules/protocol-proto.d.ts +2 -0
- package/lib/browser/protoModules/protocol-proto.js +6336 -0
- package/lib/browser/protoModules/protocol-proto.js.map +1 -0
- package/lib/browser/utils.d.ts +19 -255
- package/lib/browser/utils.js +170 -15
- package/lib/browser/utils.js.map +1 -1
- package/lib/browser/utilsNode.d.ts +1021 -0
- package/lib/browser/utilsNode.js +346 -0
- package/lib/browser/utilsNode.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/indexUtils.d.ts +2 -0
- package/lib/indexUtils.js +15 -0
- package/lib/indexUtils.js.map +1 -0
- package/lib/interface.d.ts +242 -46
- package/lib/jsonDescriptors/chain-proto.json +676 -0
- package/lib/jsonDescriptors/{krc20-proto.json → token-proto.json} +47 -4
- package/lib/protoModules/protocol-proto.d.ts +2 -0
- package/lib/protoModules/protocol-proto.js +6336 -0
- package/lib/protoModules/protocol-proto.js.map +1 -0
- package/lib/utils.d.ts +19 -255
- package/lib/utils.js +170 -15
- package/lib/utils.js.map +1 -1
- package/lib/utilsNode.d.ts +1021 -0
- package/lib/utilsNode.js +346 -0
- package/lib/utilsNode.js.map +1 -0
- package/package.json +1 -1
- package/lib/browser/jsonDescriptors/protocol-proto.json +0 -246
- package/lib/jsonDescriptors/protocol-proto.json +0 -246
package/lib/browser/Provider.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Provider = void 0;
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
const protocol_proto_js_1 = require("./protoModules/protocol-proto.js");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
|
|
4
9
|
async function sleep(ms) {
|
|
5
10
|
return new Promise((r) => setTimeout(r, ms));
|
|
6
11
|
}
|
|
@@ -26,7 +31,7 @@ class Provider {
|
|
|
26
31
|
else
|
|
27
32
|
this.rpcNodes = [rpcNodes];
|
|
28
33
|
this.currentNodeId = 0;
|
|
29
|
-
this.onError = () =>
|
|
34
|
+
this.onError = () => true;
|
|
30
35
|
}
|
|
31
36
|
/**
|
|
32
37
|
* Function to make jsonrpc requests to the RPC node
|
|
@@ -39,7 +44,7 @@ class Provider {
|
|
|
39
44
|
// eslint-disable-next-line no-constant-condition
|
|
40
45
|
while (true) {
|
|
41
46
|
try {
|
|
42
|
-
const
|
|
47
|
+
const body = {
|
|
43
48
|
id: Math.round(Math.random() * 1000),
|
|
44
49
|
jsonrpc: "2.0",
|
|
45
50
|
method,
|
|
@@ -48,18 +53,27 @@ class Provider {
|
|
|
48
53
|
const url = this.rpcNodes[this.currentNodeId];
|
|
49
54
|
const response = await fetch(url, {
|
|
50
55
|
method: "POST",
|
|
51
|
-
body: JSON.stringify(
|
|
56
|
+
body: JSON.stringify(body),
|
|
52
57
|
});
|
|
53
58
|
const json = (await response.json());
|
|
54
|
-
if (json.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
throw
|
|
59
|
+
if (json.result !== undefined)
|
|
60
|
+
return json.result;
|
|
61
|
+
if (!json.error)
|
|
62
|
+
throw new Error("undefined error");
|
|
63
|
+
const { message, data } = json.error;
|
|
64
|
+
if (!data)
|
|
65
|
+
throw new Error(message);
|
|
66
|
+
let dataJson;
|
|
67
|
+
try {
|
|
68
|
+
dataJson = JSON.parse(data);
|
|
61
69
|
}
|
|
62
|
-
|
|
70
|
+
catch (e) {
|
|
71
|
+
dataJson = { data };
|
|
72
|
+
}
|
|
73
|
+
throw new Error(JSON.stringify({
|
|
74
|
+
...(message && { error: message }),
|
|
75
|
+
...dataJson,
|
|
76
|
+
}));
|
|
63
77
|
}
|
|
64
78
|
catch (e) {
|
|
65
79
|
const currentNode = this.rpcNodes[this.currentNodeId];
|
|
@@ -76,13 +90,24 @@ class Provider {
|
|
|
76
90
|
* transactions for a particular account. This call is used
|
|
77
91
|
* when creating new transactions.
|
|
78
92
|
* @param account - account address
|
|
93
|
+
* @param deserialize - If set true it will deserialize the nonce
|
|
94
|
+
* and return it as number (default). If set false it will return
|
|
95
|
+
* the nonce encoded as received from the RPC.
|
|
79
96
|
* @returns Nonce
|
|
80
97
|
*/
|
|
81
|
-
async getNonce(account) {
|
|
82
|
-
const { nonce } = await this.call("chain.get_account_nonce", { account });
|
|
83
|
-
if (!
|
|
84
|
-
return
|
|
85
|
-
|
|
98
|
+
async getNonce(account, deserialize = true) {
|
|
99
|
+
const { nonce: nonceBase64url } = await this.call("chain.get_account_nonce", { account });
|
|
100
|
+
if (!deserialize) {
|
|
101
|
+
return nonceBase64url;
|
|
102
|
+
}
|
|
103
|
+
const valueBuffer = (0, utils_1.decodeBase64url)(nonceBase64url);
|
|
104
|
+
const message = protocol_proto_js_1.koinos.chain.value_type.decode(valueBuffer);
|
|
105
|
+
const object = protocol_proto_js_1.koinos.chain.value_type.toObject(message, {
|
|
106
|
+
longs: String,
|
|
107
|
+
defaults: true,
|
|
108
|
+
});
|
|
109
|
+
// todo: consider the case where nonce is greater than max safe integer
|
|
110
|
+
return Number(object.uint64_value);
|
|
86
111
|
}
|
|
87
112
|
async getAccountRc(account) {
|
|
88
113
|
const { rc } = await this.call("chain.get_account_rc", {
|
|
@@ -102,7 +127,7 @@ class Provider {
|
|
|
102
127
|
}
|
|
103
128
|
async getBlocksById(blockIds) {
|
|
104
129
|
return this.call("block_store.get_blocks_by_id", {
|
|
105
|
-
|
|
130
|
+
block_ids: blockIds,
|
|
106
131
|
return_block: true,
|
|
107
132
|
return_receipt: false,
|
|
108
133
|
});
|
|
@@ -113,6 +138,13 @@ class Provider {
|
|
|
113
138
|
async getHeadInfo() {
|
|
114
139
|
return this.call("chain.get_head_info", {});
|
|
115
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Function to get the chain
|
|
143
|
+
*/
|
|
144
|
+
async getChainId() {
|
|
145
|
+
const { chain_id: chainId } = await this.call("chain.get_chain_id", {});
|
|
146
|
+
return chainId;
|
|
147
|
+
}
|
|
116
148
|
/**
|
|
117
149
|
* Function to get consecutive blocks in descending order
|
|
118
150
|
* @param height - Starting block height
|
|
@@ -155,16 +187,16 @@ class Provider {
|
|
|
155
187
|
*
|
|
156
188
|
* When _byTransactionId_ is used it returns the block id.
|
|
157
189
|
*
|
|
158
|
-
* @param timeout - Timeout in milliseconds. By default it is
|
|
190
|
+
* @param timeout - Timeout in milliseconds. By default it is 60000
|
|
159
191
|
* @example
|
|
160
192
|
* ```ts
|
|
161
193
|
* const blockNumber = await provider.wait(txId);
|
|
162
|
-
* // const blockNumber = await provider.wait(txId, "byBlock",
|
|
163
|
-
* // const blockId = await provider.wait(txId, "byTransactionId",
|
|
194
|
+
* // const blockNumber = await provider.wait(txId, "byBlock", 60000);
|
|
195
|
+
* // const blockId = await provider.wait(txId, "byTransactionId", 60000);
|
|
164
196
|
* console.log("Transaction mined")
|
|
165
197
|
* ```
|
|
166
198
|
*/
|
|
167
|
-
async wait(txId, type = "byBlock", timeout =
|
|
199
|
+
async wait(txId, type = "byBlock", timeout = 60000) {
|
|
168
200
|
const iniTime = Date.now();
|
|
169
201
|
if (type === "byTransactionId") {
|
|
170
202
|
while (Date.now() < iniTime + timeout) {
|
|
@@ -232,6 +264,13 @@ class Provider {
|
|
|
232
264
|
async sendTransaction(transaction) {
|
|
233
265
|
return this.call("chain.submit_transaction", { transaction });
|
|
234
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Function to call "chain.submit_block" to send a signed
|
|
269
|
+
* block to the blockchain.
|
|
270
|
+
*/
|
|
271
|
+
async submitBlock(block) {
|
|
272
|
+
return this.call("chain.submit_block", { block });
|
|
273
|
+
}
|
|
235
274
|
/**
|
|
236
275
|
* Function to call "chain.read_contract" to read a contract.
|
|
237
276
|
* This function is used by [[Contract]] class when read methods
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../src/Provider.ts"],"names":[],"mappings":";;;AAMA,KAAK,UAAU,KAAK,CAAC,EAAU;IAC7B,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAA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AAW,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC;gBAAE,SAAS;YACxD,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,MAAM,cAAc,CACzC,WAAW,EACX,CAAC,EACD,YAAY,CAAC,EAAE,CAChB,CAAC;YACF,IAAI,IAAI;gBAAE,OAAO,IAAI,CAAC;YACtB,IAAI,CAAC,UAAU;gBAAE,UAAU,GAAG,MAAM,CAAC;YACrC,WAAW,IAAI,CAAC,CAAC;SAClB;QACD,MAAM,IAAI,KAAK,CACb,+BAA+B,OAAO,4BAA4B,QAAQ,OAAO,WAAW,EAAE,CAC/F,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,eAAe,CAAC,WAA4B;QAGhD,OAAO,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAChE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW,CAAC,KAAgB;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY,CAAC,SAAoC;QAIrD,OAAO,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;CACF;AAvaD,4BAuaC;AAED,kBAAe,QAAQ,CAAC"}
|
|
@@ -49,7 +49,7 @@ export declare class Serializer {
|
|
|
49
49
|
*/
|
|
50
50
|
defaultType?: Type;
|
|
51
51
|
/**
|
|
52
|
-
* Preformat bytes for
|
|
52
|
+
* Preformat bytes for base64url, base58 or hex string
|
|
53
53
|
*/
|
|
54
54
|
bytesConversion: boolean;
|
|
55
55
|
constructor(types: INamespace, opts?: {
|
|
@@ -65,17 +65,23 @@ export declare class Serializer {
|
|
|
65
65
|
*/
|
|
66
66
|
bytesConversion?: boolean;
|
|
67
67
|
});
|
|
68
|
+
btypeDecode(valueBtypeEncoded: Record<string, unknown> | unknown[], protobufType: Type): Record<string, unknown>;
|
|
69
|
+
btypeEncode(valueBtypeDecoded: Record<string, unknown> | unknown[], protobufType: Type): Record<string, unknown>;
|
|
68
70
|
/**
|
|
69
71
|
* Function to encode a type using the protobuffer definitions
|
|
70
72
|
* It also prepares the bytes for special cases (base58, hex string)
|
|
71
73
|
* when bytesConversion param is true.
|
|
72
74
|
*/
|
|
73
|
-
serialize(valueDecoded: Record<string, unknown>, typeName?: string
|
|
75
|
+
serialize(valueDecoded: Record<string, unknown>, typeName?: string, opts?: {
|
|
76
|
+
bytesConversion?: boolean;
|
|
77
|
+
}): Promise<Uint8Array>;
|
|
74
78
|
/**
|
|
75
79
|
* Function to decode bytes using the protobuffer definitions
|
|
76
80
|
* It also encodes the bytes for special cases (base58, hex string)
|
|
77
81
|
* when bytesConversion param is true.
|
|
78
82
|
*/
|
|
79
|
-
deserialize<T = Record<string, unknown>>(valueEncoded: string | Uint8Array, typeName?: string
|
|
83
|
+
deserialize<T = Record<string, unknown>>(valueEncoded: string | Uint8Array, typeName?: string, opts?: {
|
|
84
|
+
bytesConversion?: boolean;
|
|
85
|
+
}): Promise<T>;
|
|
80
86
|
}
|
|
81
87
|
export default Serializer;
|
|
@@ -4,22 +4,25 @@ exports.Serializer = void 0;
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/require-await */
|
|
5
5
|
const light_1 = require("protobufjs/light");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
const OP_BYTES_1 = "(btype)";
|
|
8
|
+
const OP_BYTES_2 = "(koinos.btype)";
|
|
9
|
+
const nativeTypes = [
|
|
10
|
+
"double",
|
|
11
|
+
"float",
|
|
12
|
+
"int32",
|
|
13
|
+
"int64",
|
|
14
|
+
"uint32",
|
|
15
|
+
"uint64",
|
|
16
|
+
"sint32",
|
|
17
|
+
"sint64",
|
|
18
|
+
"fixed32",
|
|
19
|
+
"fixed64",
|
|
20
|
+
"sfixed32",
|
|
21
|
+
"sfixed64",
|
|
22
|
+
"bool",
|
|
23
|
+
"string",
|
|
24
|
+
"bytes",
|
|
25
|
+
];
|
|
23
26
|
/**
|
|
24
27
|
* The serializer class serialize and deserialize data using
|
|
25
28
|
* protocol buffers.
|
|
@@ -58,7 +61,7 @@ function copyValue(value) {
|
|
|
58
61
|
class Serializer {
|
|
59
62
|
constructor(types, opts) {
|
|
60
63
|
/**
|
|
61
|
-
* Preformat bytes for
|
|
64
|
+
* Preformat bytes for base64url, base58 or hex string
|
|
62
65
|
*/
|
|
63
66
|
this.bytesConversion = true;
|
|
64
67
|
this.types = types;
|
|
@@ -68,47 +71,93 @@ class Serializer {
|
|
|
68
71
|
if (opts && typeof opts.bytesConversion !== "undefined")
|
|
69
72
|
this.bytesConversion = opts.bytesConversion;
|
|
70
73
|
}
|
|
74
|
+
btypeDecode(valueBtypeEncoded, protobufType) {
|
|
75
|
+
const valueBtypeDecoded = {};
|
|
76
|
+
Object.keys(protobufType.fields).forEach((fieldName) => {
|
|
77
|
+
const { options, name, type, rule } = protobufType.fields[fieldName];
|
|
78
|
+
if (!valueBtypeEncoded[name])
|
|
79
|
+
return;
|
|
80
|
+
const typeField = { type };
|
|
81
|
+
if (options) {
|
|
82
|
+
if (options[OP_BYTES_1])
|
|
83
|
+
typeField.btype = options[OP_BYTES_1];
|
|
84
|
+
else if (options[OP_BYTES_2])
|
|
85
|
+
typeField.btype = options[OP_BYTES_2];
|
|
86
|
+
}
|
|
87
|
+
// arrays
|
|
88
|
+
if (rule === "repeated") {
|
|
89
|
+
valueBtypeDecoded[name] = valueBtypeEncoded[name].map((itemEncoded) => {
|
|
90
|
+
// custom objects
|
|
91
|
+
if (!nativeTypes.includes(type)) {
|
|
92
|
+
const protoBuf = this.root.lookupType(type);
|
|
93
|
+
return this.btypeDecode(itemEncoded, protoBuf);
|
|
94
|
+
}
|
|
95
|
+
// native types
|
|
96
|
+
return (0, utils_1.btypeDecodeValue)(itemEncoded, typeField);
|
|
97
|
+
});
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// custom objects
|
|
101
|
+
if (!nativeTypes.includes(type)) {
|
|
102
|
+
const protoBuf = this.root.lookupType(type);
|
|
103
|
+
valueBtypeDecoded[name] = this.btypeDecode(valueBtypeEncoded[name], protoBuf);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// native types
|
|
107
|
+
valueBtypeDecoded[name] = (0, utils_1.btypeDecodeValue)(valueBtypeEncoded[name], typeField);
|
|
108
|
+
});
|
|
109
|
+
return valueBtypeDecoded;
|
|
110
|
+
}
|
|
111
|
+
btypeEncode(valueBtypeDecoded, protobufType) {
|
|
112
|
+
const valueBtypeEncoded = {};
|
|
113
|
+
Object.keys(protobufType.fields).forEach((fieldName) => {
|
|
114
|
+
const { options, name, type, rule } = protobufType.fields[fieldName];
|
|
115
|
+
if (!valueBtypeDecoded[name])
|
|
116
|
+
return;
|
|
117
|
+
const typeField = { type };
|
|
118
|
+
if (options) {
|
|
119
|
+
if (options[OP_BYTES_1])
|
|
120
|
+
typeField.btype = options[OP_BYTES_1];
|
|
121
|
+
else if (options[OP_BYTES_2])
|
|
122
|
+
typeField.btype = options[OP_BYTES_2];
|
|
123
|
+
}
|
|
124
|
+
// arrays
|
|
125
|
+
if (rule === "repeated") {
|
|
126
|
+
valueBtypeEncoded[name] = valueBtypeDecoded[name].map((itemDecoded) => {
|
|
127
|
+
// custom objects
|
|
128
|
+
if (!nativeTypes.includes(type)) {
|
|
129
|
+
const protoBuf = this.root.lookupType(type);
|
|
130
|
+
return this.btypeEncode(itemDecoded, protoBuf);
|
|
131
|
+
}
|
|
132
|
+
// native types
|
|
133
|
+
return (0, utils_1.btypeEncodeValue)(itemDecoded, typeField);
|
|
134
|
+
});
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
// custom objects
|
|
138
|
+
if (!nativeTypes.includes(type)) {
|
|
139
|
+
const protoBuf = this.root.lookupType(type);
|
|
140
|
+
valueBtypeEncoded[name] = this.btypeEncode(valueBtypeDecoded[name], protoBuf);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
// native types
|
|
144
|
+
valueBtypeEncoded[name] = (0, utils_1.btypeEncodeValue)(valueBtypeDecoded[name], typeField);
|
|
145
|
+
});
|
|
146
|
+
return valueBtypeEncoded;
|
|
147
|
+
}
|
|
71
148
|
/**
|
|
72
149
|
* Function to encode a type using the protobuffer definitions
|
|
73
150
|
* It also prepares the bytes for special cases (base58, hex string)
|
|
74
151
|
* when bytesConversion param is true.
|
|
75
152
|
*/
|
|
76
|
-
async serialize(valueDecoded, typeName) {
|
|
153
|
+
async serialize(valueDecoded, typeName, opts) {
|
|
77
154
|
const protobufType = this.defaultType || this.root.lookupType(typeName);
|
|
78
155
|
let object = {};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (type !== "bytes") {
|
|
85
|
-
object[name] = copyValue(valueDecoded[name]);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
// Default byte conversion
|
|
89
|
-
if (!options || !options[OP_BYTES]) {
|
|
90
|
-
object[name] = (0, utils_1.decodeBase64)(valueDecoded[name]);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
// Specific byte conversion
|
|
94
|
-
switch (options[OP_BYTES]) {
|
|
95
|
-
case "BASE58":
|
|
96
|
-
case "CONTRACT_ID":
|
|
97
|
-
case "ADDRESS":
|
|
98
|
-
object[name] = (0, utils_1.decodeBase58)(valueDecoded[name]);
|
|
99
|
-
break;
|
|
100
|
-
case "BASE64":
|
|
101
|
-
object[name] = (0, utils_1.decodeBase64)(valueDecoded[name]);
|
|
102
|
-
break;
|
|
103
|
-
case "HEX":
|
|
104
|
-
case "BLOCK_ID":
|
|
105
|
-
case "TRANSACTION_ID":
|
|
106
|
-
object[name] = (0, utils_1.toUint8Array)(valueDecoded[name].replace("0x", ""));
|
|
107
|
-
break;
|
|
108
|
-
default:
|
|
109
|
-
throw new Error(`unknown koinos_byte_type ${options[OP_BYTES]}`);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
156
|
+
const bytesConversion = (opts === null || opts === void 0 ? void 0 : opts.bytesConversion) === undefined
|
|
157
|
+
? this.bytesConversion
|
|
158
|
+
: opts.bytesConversion;
|
|
159
|
+
if (bytesConversion) {
|
|
160
|
+
object = this.btypeDecode(valueDecoded, protobufType);
|
|
112
161
|
}
|
|
113
162
|
else {
|
|
114
163
|
object = valueDecoded;
|
|
@@ -122,45 +171,22 @@ class Serializer {
|
|
|
122
171
|
* It also encodes the bytes for special cases (base58, hex string)
|
|
123
172
|
* when bytesConversion param is true.
|
|
124
173
|
*/
|
|
125
|
-
async deserialize(valueEncoded, typeName) {
|
|
174
|
+
async deserialize(valueEncoded, typeName, opts) {
|
|
126
175
|
const valueBuffer = typeof valueEncoded === "string"
|
|
127
|
-
? (0, utils_1.
|
|
176
|
+
? (0, utils_1.decodeBase64url)(valueEncoded)
|
|
128
177
|
: valueEncoded;
|
|
129
178
|
const protobufType = this.defaultType || this.root.lookupType(typeName);
|
|
130
179
|
const message = protobufType.decode(valueBuffer);
|
|
131
|
-
const object = protobufType.toObject(message, {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
// TODO: format from Buffer to base58/base64 for nested fields
|
|
135
|
-
Object.keys(protobufType.fields).forEach((fieldName) => {
|
|
136
|
-
const { options, name, type } = protobufType.fields[fieldName];
|
|
137
|
-
// No byte conversion
|
|
138
|
-
if (type !== "bytes")
|
|
139
|
-
return;
|
|
140
|
-
// Default byte conversion
|
|
141
|
-
if (!options || !options[OP_BYTES]) {
|
|
142
|
-
object[name] = (0, utils_1.encodeBase64)(object[name]);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
// Specific byte conversion
|
|
146
|
-
switch (options[OP_BYTES]) {
|
|
147
|
-
case "BASE58":
|
|
148
|
-
case "CONTRACT_ID":
|
|
149
|
-
case "ADDRESS":
|
|
150
|
-
object[name] = (0, utils_1.encodeBase58)(object[name]);
|
|
151
|
-
break;
|
|
152
|
-
case "BASE64":
|
|
153
|
-
object[name] = (0, utils_1.encodeBase64)(object[name]);
|
|
154
|
-
break;
|
|
155
|
-
case "HEX":
|
|
156
|
-
case "BLOCK_ID":
|
|
157
|
-
case "TRANSACTION_ID":
|
|
158
|
-
object[name] = `0x${(0, utils_1.toHexString)(object[name])}`;
|
|
159
|
-
break;
|
|
160
|
-
default:
|
|
161
|
-
throw new Error(`unknown koinos_byte_type ${options[OP_BYTES]}`);
|
|
162
|
-
}
|
|
180
|
+
const object = protobufType.toObject(message, {
|
|
181
|
+
longs: String,
|
|
182
|
+
defaults: true,
|
|
163
183
|
});
|
|
184
|
+
const bytesConversion = (opts === null || opts === void 0 ? void 0 : opts.bytesConversion) === undefined
|
|
185
|
+
? this.bytesConversion
|
|
186
|
+
: opts.bytesConversion;
|
|
187
|
+
if (bytesConversion) {
|
|
188
|
+
return this.btypeEncode(object, protobufType);
|
|
189
|
+
}
|
|
164
190
|
return object;
|
|
165
191
|
}
|
|
166
192
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Serializer.js","sourceRoot":"","sources":["../../src/Serializer.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,4CAA0D;
|
|
1
|
+
{"version":3,"file":"Serializer.js","sourceRoot":"","sources":["../../src/Serializer.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,4CAA0D;AAE1D,mCAA8E;AAE9E,MAAM,UAAU,GAAG,SAAS,CAAC;AAC7B,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAEpC,MAAM,WAAW,GAAG;IAClB,QAAQ;IACR,OAAO;IACP,OA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