koilib 2.8.0 → 3.1.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.
- package/README.md +75 -12
- package/dist/koinos.js +8535 -284
- 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 +3 -1
- package/lib/Serializer.js +103 -83
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.d.ts +54 -42
- package/lib/Signer.js +305 -114
- 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 +3 -1
- package/lib/browser/Serializer.js +103 -83
- package/lib/browser/Serializer.js.map +1 -1
- package/lib/browser/Signer.d.ts +54 -42
- package/lib/browser/Signer.js +305 -114
- 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/Provider.js
CHANGED
|
@@ -5,6 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Provider = void 0;
|
|
7
7
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
const protocol_proto_js_1 = require("./protoModules/protocol-proto.js");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
|
|
8
13
|
async function sleep(ms) {
|
|
9
14
|
return new Promise((r) => setTimeout(r, ms));
|
|
10
15
|
}
|
|
@@ -30,7 +35,7 @@ class Provider {
|
|
|
30
35
|
else
|
|
31
36
|
this.rpcNodes = [rpcNodes];
|
|
32
37
|
this.currentNodeId = 0;
|
|
33
|
-
this.onError = () =>
|
|
38
|
+
this.onError = () => true;
|
|
34
39
|
}
|
|
35
40
|
/**
|
|
36
41
|
* Function to make jsonrpc requests to the RPC node
|
|
@@ -43,7 +48,7 @@ class Provider {
|
|
|
43
48
|
// eslint-disable-next-line no-constant-condition
|
|
44
49
|
while (true) {
|
|
45
50
|
try {
|
|
46
|
-
const
|
|
51
|
+
const body = {
|
|
47
52
|
id: Math.round(Math.random() * 1000),
|
|
48
53
|
jsonrpc: "2.0",
|
|
49
54
|
method,
|
|
@@ -52,18 +57,27 @@ class Provider {
|
|
|
52
57
|
const url = this.rpcNodes[this.currentNodeId];
|
|
53
58
|
const response = await (0, cross_fetch_1.default)(url, {
|
|
54
59
|
method: "POST",
|
|
55
|
-
body: JSON.stringify(
|
|
60
|
+
body: JSON.stringify(body),
|
|
56
61
|
});
|
|
57
62
|
const json = (await response.json());
|
|
58
|
-
if (json.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
throw
|
|
63
|
+
if (json.result !== undefined)
|
|
64
|
+
return json.result;
|
|
65
|
+
if (!json.error)
|
|
66
|
+
throw new Error("undefined error");
|
|
67
|
+
const { message, data } = json.error;
|
|
68
|
+
if (!data)
|
|
69
|
+
throw new Error(message);
|
|
70
|
+
let dataJson;
|
|
71
|
+
try {
|
|
72
|
+
dataJson = JSON.parse(data);
|
|
65
73
|
}
|
|
66
|
-
|
|
74
|
+
catch (e) {
|
|
75
|
+
dataJson = { data };
|
|
76
|
+
}
|
|
77
|
+
throw new Error(JSON.stringify({
|
|
78
|
+
...(message && { error: message }),
|
|
79
|
+
...dataJson,
|
|
80
|
+
}));
|
|
67
81
|
}
|
|
68
82
|
catch (e) {
|
|
69
83
|
const currentNode = this.rpcNodes[this.currentNodeId];
|
|
@@ -80,13 +94,24 @@ class Provider {
|
|
|
80
94
|
* transactions for a particular account. This call is used
|
|
81
95
|
* when creating new transactions.
|
|
82
96
|
* @param account - account address
|
|
97
|
+
* @param deserialize - If set true it will deserialize the nonce
|
|
98
|
+
* and return it as number (default). If set false it will return
|
|
99
|
+
* the nonce encoded as received from the RPC.
|
|
83
100
|
* @returns Nonce
|
|
84
101
|
*/
|
|
85
|
-
async getNonce(account) {
|
|
86
|
-
const { nonce } = await this.call("chain.get_account_nonce", { account });
|
|
87
|
-
if (!
|
|
88
|
-
return
|
|
89
|
-
|
|
102
|
+
async getNonce(account, deserialize = true) {
|
|
103
|
+
const { nonce: nonceBase64url } = await this.call("chain.get_account_nonce", { account });
|
|
104
|
+
if (!deserialize) {
|
|
105
|
+
return nonceBase64url;
|
|
106
|
+
}
|
|
107
|
+
const valueBuffer = (0, utils_1.decodeBase64url)(nonceBase64url);
|
|
108
|
+
const message = protocol_proto_js_1.koinos.chain.value_type.decode(valueBuffer);
|
|
109
|
+
const object = protocol_proto_js_1.koinos.chain.value_type.toObject(message, {
|
|
110
|
+
longs: String,
|
|
111
|
+
defaults: true,
|
|
112
|
+
});
|
|
113
|
+
// todo: consider the case where nonce is greater than max safe integer
|
|
114
|
+
return Number(object.uint64_value);
|
|
90
115
|
}
|
|
91
116
|
async getAccountRc(account) {
|
|
92
117
|
const { rc } = await this.call("chain.get_account_rc", {
|
|
@@ -106,7 +131,7 @@ class Provider {
|
|
|
106
131
|
}
|
|
107
132
|
async getBlocksById(blockIds) {
|
|
108
133
|
return this.call("block_store.get_blocks_by_id", {
|
|
109
|
-
|
|
134
|
+
block_ids: blockIds,
|
|
110
135
|
return_block: true,
|
|
111
136
|
return_receipt: false,
|
|
112
137
|
});
|
|
@@ -117,6 +142,13 @@ class Provider {
|
|
|
117
142
|
async getHeadInfo() {
|
|
118
143
|
return this.call("chain.get_head_info", {});
|
|
119
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Function to get the chain
|
|
147
|
+
*/
|
|
148
|
+
async getChainId() {
|
|
149
|
+
const { chain_id: chainId } = await this.call("chain.get_chain_id", {});
|
|
150
|
+
return chainId;
|
|
151
|
+
}
|
|
120
152
|
/**
|
|
121
153
|
* Function to get consecutive blocks in descending order
|
|
122
154
|
* @param height - Starting block height
|
|
@@ -159,16 +191,16 @@ class Provider {
|
|
|
159
191
|
*
|
|
160
192
|
* When _byTransactionId_ is used it returns the block id.
|
|
161
193
|
*
|
|
162
|
-
* @param timeout - Timeout in milliseconds. By default it is
|
|
194
|
+
* @param timeout - Timeout in milliseconds. By default it is 60000
|
|
163
195
|
* @example
|
|
164
196
|
* ```ts
|
|
165
197
|
* const blockNumber = await provider.wait(txId);
|
|
166
|
-
* // const blockNumber = await provider.wait(txId, "byBlock",
|
|
167
|
-
* // const blockId = await provider.wait(txId, "byTransactionId",
|
|
198
|
+
* // const blockNumber = await provider.wait(txId, "byBlock", 60000);
|
|
199
|
+
* // const blockId = await provider.wait(txId, "byTransactionId", 60000);
|
|
168
200
|
* console.log("Transaction mined")
|
|
169
201
|
* ```
|
|
170
202
|
*/
|
|
171
|
-
async wait(txId, type = "byBlock", timeout =
|
|
203
|
+
async wait(txId, type = "byBlock", timeout = 60000) {
|
|
172
204
|
const iniTime = Date.now();
|
|
173
205
|
if (type === "byTransactionId") {
|
|
174
206
|
while (Date.now() < iniTime + timeout) {
|
|
@@ -236,6 +268,13 @@ class Provider {
|
|
|
236
268
|
async sendTransaction(transaction) {
|
|
237
269
|
return this.call("chain.submit_transaction", { transaction });
|
|
238
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Function to call "chain.submit_block" to send a signed
|
|
273
|
+
* block to the blockchain.
|
|
274
|
+
*/
|
|
275
|
+
async submitBlock(block) {
|
|
276
|
+
return this.call("chain.submit_block", { block });
|
|
277
|
+
}
|
|
239
278
|
/**
|
|
240
279
|
* Function to call "chain.read_contract" to read a contract.
|
|
241
280
|
* This function is used by [[Contract]] class when read methods
|
package/lib/Provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../src/Provider.ts"],"names":[],"mapp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B,UAAU,GAAG,MAAM,CAAC;gBACpB,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;aAC/C;YACD,uCAAuC;YACvC,IAAI,WAAW,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"}
|
package/lib/Serializer.d.ts
CHANGED
|
@@ -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,6 +65,8 @@ 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)
|
package/lib/Serializer.js
CHANGED
|
@@ -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,6 +71,80 @@ 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)
|
|
@@ -80,38 +157,7 @@ class Serializer {
|
|
|
80
157
|
? this.bytesConversion
|
|
81
158
|
: opts.bytesConversion;
|
|
82
159
|
if (bytesConversion) {
|
|
83
|
-
|
|
84
|
-
Object.keys(protobufType.fields).forEach((fieldName) => {
|
|
85
|
-
const { options, name, type } = protobufType.fields[fieldName];
|
|
86
|
-
// No byte conversion
|
|
87
|
-
if (type !== "bytes") {
|
|
88
|
-
object[name] = copyValue(valueDecoded[name]);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
// Default byte conversion
|
|
92
|
-
if (!options || !options[OP_BYTES]) {
|
|
93
|
-
object[name] = (0, utils_1.decodeBase64)(valueDecoded[name]);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
// Specific byte conversion
|
|
97
|
-
switch (options[OP_BYTES]) {
|
|
98
|
-
case "BASE58":
|
|
99
|
-
case "CONTRACT_ID":
|
|
100
|
-
case "ADDRESS":
|
|
101
|
-
object[name] = (0, utils_1.decodeBase58)(valueDecoded[name]);
|
|
102
|
-
break;
|
|
103
|
-
case "BASE64":
|
|
104
|
-
object[name] = (0, utils_1.decodeBase64)(valueDecoded[name]);
|
|
105
|
-
break;
|
|
106
|
-
case "HEX":
|
|
107
|
-
case "BLOCK_ID":
|
|
108
|
-
case "TRANSACTION_ID":
|
|
109
|
-
object[name] = (0, utils_1.toUint8Array)(valueDecoded[name].replace("0x", ""));
|
|
110
|
-
break;
|
|
111
|
-
default:
|
|
112
|
-
throw new Error(`unknown koinos_byte_type ${options[OP_BYTES]}`);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
160
|
+
object = this.btypeDecode(valueDecoded, protobufType);
|
|
115
161
|
}
|
|
116
162
|
else {
|
|
117
163
|
object = valueDecoded;
|
|
@@ -127,46 +173,20 @@ class Serializer {
|
|
|
127
173
|
*/
|
|
128
174
|
async deserialize(valueEncoded, typeName, opts) {
|
|
129
175
|
const valueBuffer = typeof valueEncoded === "string"
|
|
130
|
-
? (0, utils_1.
|
|
176
|
+
? (0, utils_1.decodeBase64url)(valueEncoded)
|
|
131
177
|
: valueEncoded;
|
|
132
178
|
const protobufType = this.defaultType || this.root.lookupType(typeName);
|
|
133
179
|
const message = protobufType.decode(valueBuffer);
|
|
134
|
-
const object = protobufType.toObject(message, {
|
|
180
|
+
const object = protobufType.toObject(message, {
|
|
181
|
+
longs: String,
|
|
182
|
+
defaults: true,
|
|
183
|
+
});
|
|
135
184
|
const bytesConversion = (opts === null || opts === void 0 ? void 0 : opts.bytesConversion) === undefined
|
|
136
185
|
? this.bytesConversion
|
|
137
186
|
: opts.bytesConversion;
|
|
138
|
-
if (
|
|
139
|
-
return object;
|
|
140
|
-
|
|
141
|
-
Object.keys(protobufType.fields).forEach((fieldName) => {
|
|
142
|
-
const { options, name, type } = protobufType.fields[fieldName];
|
|
143
|
-
// No byte conversion
|
|
144
|
-
if (type !== "bytes")
|
|
145
|
-
return;
|
|
146
|
-
// Default byte conversion
|
|
147
|
-
if (!options || !options[OP_BYTES]) {
|
|
148
|
-
object[name] = (0, utils_1.encodeBase64)(object[name]);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
// Specific byte conversion
|
|
152
|
-
switch (options[OP_BYTES]) {
|
|
153
|
-
case "BASE58":
|
|
154
|
-
case "CONTRACT_ID":
|
|
155
|
-
case "ADDRESS":
|
|
156
|
-
object[name] = (0, utils_1.encodeBase58)(object[name]);
|
|
157
|
-
break;
|
|
158
|
-
case "BASE64":
|
|
159
|
-
object[name] = (0, utils_1.encodeBase64)(object[name]);
|
|
160
|
-
break;
|
|
161
|
-
case "HEX":
|
|
162
|
-
case "BLOCK_ID":
|
|
163
|
-
case "TRANSACTION_ID":
|
|
164
|
-
object[name] = `0x${(0, utils_1.toHexString)(object[name])}`;
|
|
165
|
-
break;
|
|
166
|
-
default:
|
|
167
|
-
throw new Error(`unknown koinos_byte_type ${options[OP_BYTES]}`);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
187
|
+
if (bytesConversion) {
|
|
188
|
+
return this.btypeEncode(object, protobufType);
|
|
189
|
+
}
|
|
170
190
|
return object;
|
|
171
191
|
}
|
|
172
192
|
}
|
package/lib/Serializer.js.map
CHANGED
|
@@ -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,OAAO;IACP,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,SAAS;IACT,UAAU;IACV,UAAU;IACV,MAAM;IACN,QAAQ;IACR,OAAO;CACR,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAa,UAAU;IAsBrB,YACE,KAAiB,EACjB,IAaC;QApBH;;WAEG;QACH,oBAAe,GAAG,IAAI,CAAC;QAmBrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,YAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,eAAe;YACvB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAChE,IAAI,IAAI,IAAI,OAAO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