koilib 2.6.1 → 3.0.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 +66 -12
- package/dist/koinos.js +8533 -274
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +53 -16
- package/lib/Contract.js +99 -31
- package/lib/Contract.js.map +1 -1
- package/lib/Provider.d.ts +39 -19
- package/lib/Provider.js +119 -87
- package/lib/Provider.js.map +1 -1
- package/lib/Serializer.d.ts +8 -3
- package/lib/Serializer.js +60 -41
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.d.ts +53 -39
- package/lib/Signer.js +320 -91
- package/lib/Signer.js.map +1 -1
- package/lib/browser/Contract.d.ts +53 -16
- package/lib/browser/Contract.js +99 -31
- package/lib/browser/Contract.js.map +1 -1
- package/lib/browser/Provider.d.ts +39 -19
- package/lib/browser/Provider.js +119 -87
- package/lib/browser/Provider.js.map +1 -1
- package/lib/browser/Serializer.d.ts +8 -3
- package/lib/browser/Serializer.js +60 -41
- package/lib/browser/Serializer.js.map +1 -1
- package/lib/browser/Signer.d.ts +53 -39
- package/lib/browser/Signer.js +320 -91
- 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 -65
- package/lib/browser/jsonDescriptors/chain-proto.json +676 -0
- package/lib/browser/jsonDescriptors/krc20-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 +18 -254
- package/lib/browser/utils.js +140 -12
- 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 -65
- package/lib/jsonDescriptors/chain-proto.json +676 -0
- package/lib/jsonDescriptors/krc20-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 +18 -254
- package/lib/utils.js +140 -12
- 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
|
}
|
|
@@ -76,13 +81,24 @@ class Provider {
|
|
|
76
81
|
* transactions for a particular account. This call is used
|
|
77
82
|
* when creating new transactions.
|
|
78
83
|
* @param account - account address
|
|
84
|
+
* @param deserialize - If set true it will deserialize the nonce
|
|
85
|
+
* and return it as number (default). If set false it will return
|
|
86
|
+
* the nonce encoded as received from the RPC.
|
|
79
87
|
* @returns Nonce
|
|
80
88
|
*/
|
|
81
|
-
async getNonce(account) {
|
|
82
|
-
const { nonce } = await this.call("chain.get_account_nonce", { account });
|
|
83
|
-
if (!
|
|
84
|
-
return
|
|
85
|
-
|
|
89
|
+
async getNonce(account, deserialize = true) {
|
|
90
|
+
const { nonce: nonceBase64url } = await this.call("chain.get_account_nonce", { account });
|
|
91
|
+
if (!deserialize) {
|
|
92
|
+
return nonceBase64url;
|
|
93
|
+
}
|
|
94
|
+
const valueBuffer = (0, utils_1.decodeBase64url)(nonceBase64url);
|
|
95
|
+
const message = protocol_proto_js_1.koinos.chain.value_type.decode(valueBuffer);
|
|
96
|
+
const object = protocol_proto_js_1.koinos.chain.value_type.toObject(message, {
|
|
97
|
+
longs: String,
|
|
98
|
+
defaults: true,
|
|
99
|
+
});
|
|
100
|
+
// todo: consider the case where nonce is greater than max safe integer
|
|
101
|
+
return Number(object.uint64_value);
|
|
86
102
|
}
|
|
87
103
|
async getAccountRc(account) {
|
|
88
104
|
const { rc } = await this.call("chain.get_account_rc", {
|
|
@@ -102,7 +118,7 @@ class Provider {
|
|
|
102
118
|
}
|
|
103
119
|
async getBlocksById(blockIds) {
|
|
104
120
|
return this.call("block_store.get_blocks_by_id", {
|
|
105
|
-
|
|
121
|
+
block_ids: blockIds,
|
|
106
122
|
return_block: true,
|
|
107
123
|
return_receipt: false,
|
|
108
124
|
});
|
|
@@ -113,6 +129,13 @@ class Provider {
|
|
|
113
129
|
async getHeadInfo() {
|
|
114
130
|
return this.call("chain.get_head_info", {});
|
|
115
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Function to get the chain
|
|
134
|
+
*/
|
|
135
|
+
async getChainId() {
|
|
136
|
+
const { chain_id: chainId } = await this.call("chain.get_chain_id", {});
|
|
137
|
+
return chainId;
|
|
138
|
+
}
|
|
116
139
|
/**
|
|
117
140
|
* Function to get consecutive blocks in descending order
|
|
118
141
|
* @param height - Starting block height
|
|
@@ -142,93 +165,102 @@ class Provider {
|
|
|
142
165
|
return (await this.getBlocks(height, 1))[0];
|
|
143
166
|
}
|
|
144
167
|
/**
|
|
145
|
-
* Function to
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
168
|
+
* Function to wait for a transaction to be mined.
|
|
169
|
+
* @param txId - transaction id
|
|
170
|
+
* @param type - Type must be "byBlock" (default) or "byTransactionId".
|
|
171
|
+
* _byBlock_ will query the blockchain to get blocks and search for the
|
|
172
|
+
* transaction there. _byTransactionId_ will query the "transaction store"
|
|
173
|
+
* microservice to search the transaction by its id. If non of them is
|
|
174
|
+
* specified the function will use "byBlock" (as "byTransactionId"
|
|
175
|
+
* requires the transaction store, which is an optional microservice).
|
|
176
|
+
*
|
|
177
|
+
* When _byBlock_ is used it returns the block number.
|
|
178
|
+
*
|
|
179
|
+
* When _byTransactionId_ is used it returns the block id.
|
|
180
|
+
*
|
|
181
|
+
* @param timeout - Timeout in milliseconds. By default it is 30000
|
|
150
182
|
* @example
|
|
151
183
|
* ```ts
|
|
152
|
-
* const
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
* signatureData: "...",
|
|
156
|
-
* });
|
|
157
|
-
* console.log("Transaction submitted to the mempool");
|
|
158
|
-
* // wait to be mined
|
|
159
|
-
* const blockNumber = await transactionResponse.wait();
|
|
160
|
-
* // const blockNumber = await transactionResponse.wait("byBlock", 30000);
|
|
161
|
-
* // const blockId = await transactionResponse.wait("byTransactionId", 30000);
|
|
184
|
+
* const blockNumber = await provider.wait(txId);
|
|
185
|
+
* // const blockNumber = await provider.wait(txId, "byBlock", 30000);
|
|
186
|
+
* // const blockId = await provider.wait(txId, "byTransactionId", 30000);
|
|
162
187
|
* console.log("Transaction mined")
|
|
163
188
|
* ```
|
|
164
189
|
*/
|
|
165
|
-
async
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (tx)
|
|
195
|
-
bNum = Number(block.block_height);
|
|
196
|
-
});
|
|
197
|
-
const lastId = blocks[blocks.length - 1].block_id;
|
|
198
|
-
return [bNum, lastId];
|
|
199
|
-
};
|
|
200
|
-
let blockNumber = 0;
|
|
201
|
-
let iniBlock = 0;
|
|
202
|
-
let previousId = "";
|
|
203
|
-
while (Date.now() < iniTime + timeout) {
|
|
204
|
-
await sleep(1000);
|
|
205
|
-
const { head_topology: headTopology } = await this.getHeadInfo();
|
|
206
|
-
if (blockNumber === 0) {
|
|
207
|
-
blockNumber = Number(headTopology.height);
|
|
208
|
-
iniBlock = blockNumber;
|
|
209
|
-
}
|
|
210
|
-
if (Number(headTopology.height) === blockNumber - 1 &&
|
|
211
|
-
previousId &&
|
|
212
|
-
previousId !== headTopology.id) {
|
|
213
|
-
const [bNum, lastId] = await findTxInBlocks(iniBlock, Number(headTopology.height) - iniBlock + 1, headTopology.id);
|
|
214
|
-
if (bNum)
|
|
215
|
-
return bNum;
|
|
216
|
-
previousId = lastId;
|
|
217
|
-
blockNumber = Number(headTopology.height) + 1;
|
|
218
|
-
}
|
|
219
|
-
// eslint-disable-next-line no-continue
|
|
220
|
-
if (blockNumber > Number(headTopology.height))
|
|
221
|
-
continue;
|
|
222
|
-
const [bNum, lastId] = await findTxInBlocks(blockNumber, 1, headTopology.id);
|
|
223
|
-
if (bNum)
|
|
224
|
-
return bNum;
|
|
225
|
-
if (!previousId)
|
|
226
|
-
previousId = lastId;
|
|
227
|
-
blockNumber += 1;
|
|
228
|
-
}
|
|
229
|
-
throw new Error(`Transaction not mined after ${timeout} ms. Blocks checked from ${iniBlock} to ${blockNumber}`);
|
|
230
|
-
},
|
|
190
|
+
async wait(txId, type = "byBlock", timeout = 30000) {
|
|
191
|
+
const iniTime = Date.now();
|
|
192
|
+
if (type === "byTransactionId") {
|
|
193
|
+
while (Date.now() < iniTime + timeout) {
|
|
194
|
+
await sleep(1000);
|
|
195
|
+
const { transactions } = await this.getTransactionsById([txId]);
|
|
196
|
+
if (transactions &&
|
|
197
|
+
transactions[0] &&
|
|
198
|
+
transactions[0].containing_blocks)
|
|
199
|
+
return transactions[0].containing_blocks[0];
|
|
200
|
+
}
|
|
201
|
+
throw new Error(`Transaction not mined after ${timeout} ms`);
|
|
202
|
+
}
|
|
203
|
+
// byBlock
|
|
204
|
+
const findTxInBlocks = async (ini, numBlocks, idRef) => {
|
|
205
|
+
const blocks = await this.getBlocks(ini, numBlocks, idRef);
|
|
206
|
+
let bNum = 0;
|
|
207
|
+
blocks.forEach((block) => {
|
|
208
|
+
if (!block ||
|
|
209
|
+
!block.block ||
|
|
210
|
+
!block.block_id ||
|
|
211
|
+
!block.block.transactions)
|
|
212
|
+
return;
|
|
213
|
+
const tx = block.block.transactions.find((t) => t.id === txId);
|
|
214
|
+
if (tx)
|
|
215
|
+
bNum = Number(block.block_height);
|
|
216
|
+
});
|
|
217
|
+
const lastId = blocks[blocks.length - 1].block_id;
|
|
218
|
+
return [bNum, lastId];
|
|
231
219
|
};
|
|
220
|
+
let blockNumber = 0;
|
|
221
|
+
let iniBlock = 0;
|
|
222
|
+
let previousId = "";
|
|
223
|
+
while (Date.now() < iniTime + timeout) {
|
|
224
|
+
await sleep(1000);
|
|
225
|
+
const { head_topology: headTopology } = await this.getHeadInfo();
|
|
226
|
+
if (blockNumber === 0) {
|
|
227
|
+
blockNumber = Number(headTopology.height);
|
|
228
|
+
iniBlock = blockNumber;
|
|
229
|
+
}
|
|
230
|
+
if (Number(headTopology.height) === blockNumber - 1 &&
|
|
231
|
+
previousId &&
|
|
232
|
+
previousId !== headTopology.id) {
|
|
233
|
+
const [bNum, lastId] = await findTxInBlocks(iniBlock, Number(headTopology.height) - iniBlock + 1, headTopology.id);
|
|
234
|
+
if (bNum)
|
|
235
|
+
return bNum;
|
|
236
|
+
previousId = lastId;
|
|
237
|
+
blockNumber = Number(headTopology.height) + 1;
|
|
238
|
+
}
|
|
239
|
+
// eslint-disable-next-line no-continue
|
|
240
|
+
if (blockNumber > Number(headTopology.height))
|
|
241
|
+
continue;
|
|
242
|
+
const [bNum, lastId] = await findTxInBlocks(blockNumber, 1, headTopology.id);
|
|
243
|
+
if (bNum)
|
|
244
|
+
return bNum;
|
|
245
|
+
if (!previousId)
|
|
246
|
+
previousId = lastId;
|
|
247
|
+
blockNumber += 1;
|
|
248
|
+
}
|
|
249
|
+
throw new Error(`Transaction not mined after ${timeout} ms. Blocks checked from ${iniBlock} to ${blockNumber}`);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Function to call "chain.submit_transaction" to send a signed
|
|
253
|
+
* transaction to the blockchain.
|
|
254
|
+
*/
|
|
255
|
+
async sendTransaction(transaction) {
|
|
256
|
+
return this.call("chain.submit_transaction", { transaction });
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Function to call "chain.submit_block" to send a signed
|
|
260
|
+
* block to the blockchain.
|
|
261
|
+
*/
|
|
262
|
+
async submitBlock(block) {
|
|
263
|
+
return this.call("chain.submit_block", { block });
|
|
232
264
|
}
|
|
233
265
|
/**
|
|
234
266
|
* Function to call "chain.read_contract" to read a contract.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../src/Provider.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../src/Provider.ts"],"names":[],"mappings":";;;AAKA,6DAA6D;AAC7D,aAAa;AACb,wEAA0D;AAC1D,mCAA0C;AAE1C,2IAA2I;AAE3I,KA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
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,22 @@ export declare class Serializer {
|
|
|
65
65
|
*/
|
|
66
66
|
bytesConversion?: boolean;
|
|
67
67
|
});
|
|
68
|
+
converter(valueDecoded: Record<string, unknown>, object: Record<string, unknown>, protobufType: Type, fieldName: string): void;
|
|
68
69
|
/**
|
|
69
70
|
* Function to encode a type using the protobuffer definitions
|
|
70
71
|
* It also prepares the bytes for special cases (base58, hex string)
|
|
71
72
|
* when bytesConversion param is true.
|
|
72
73
|
*/
|
|
73
|
-
serialize(valueDecoded: Record<string, unknown>, typeName?: string
|
|
74
|
+
serialize(valueDecoded: Record<string, unknown>, typeName?: string, opts?: {
|
|
75
|
+
bytesConversion?: boolean;
|
|
76
|
+
}): Promise<Uint8Array>;
|
|
74
77
|
/**
|
|
75
78
|
* Function to decode bytes using the protobuffer definitions
|
|
76
79
|
* It also encodes the bytes for special cases (base58, hex string)
|
|
77
80
|
* when bytesConversion param is true.
|
|
78
81
|
*/
|
|
79
|
-
deserialize<T = Record<string, unknown>>(valueEncoded: string | Uint8Array, typeName?: string
|
|
82
|
+
deserialize<T = Record<string, unknown>>(valueEncoded: string | Uint8Array, typeName?: string, opts?: {
|
|
83
|
+
bytesConversion?: boolean;
|
|
84
|
+
}): Promise<T>;
|
|
80
85
|
}
|
|
81
86
|
export default Serializer;
|
|
@@ -4,7 +4,7 @@ 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 OP_BYTES = "(
|
|
7
|
+
const OP_BYTES = "(btype)";
|
|
8
8
|
/**
|
|
9
9
|
* Makes a copy of a value. The returned value can be modified
|
|
10
10
|
* without altering the original one. Although this is not needed
|
|
@@ -58,7 +58,7 @@ function copyValue(value) {
|
|
|
58
58
|
class Serializer {
|
|
59
59
|
constructor(types, opts) {
|
|
60
60
|
/**
|
|
61
|
-
* Preformat bytes for
|
|
61
|
+
* Preformat bytes for base64url, base58 or hex string
|
|
62
62
|
*/
|
|
63
63
|
this.bytesConversion = true;
|
|
64
64
|
this.types = types;
|
|
@@ -68,47 +68,60 @@ class Serializer {
|
|
|
68
68
|
if (opts && typeof opts.bytesConversion !== "undefined")
|
|
69
69
|
this.bytesConversion = opts.bytesConversion;
|
|
70
70
|
}
|
|
71
|
+
converter(valueDecoded, object, protobufType, fieldName) {
|
|
72
|
+
const { options, name, type } = protobufType.fields[fieldName];
|
|
73
|
+
if (!valueDecoded[name])
|
|
74
|
+
return;
|
|
75
|
+
// if operation
|
|
76
|
+
if (type.endsWith("_operation")) {
|
|
77
|
+
const protoBuf = this.root.lookupType(type);
|
|
78
|
+
object[name] = {};
|
|
79
|
+
Object.keys(protoBuf.fields).forEach((fdName) => this.converter(valueDecoded[name], object[name], protoBuf, fdName));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// No byte conversion
|
|
83
|
+
if (type !== "bytes") {
|
|
84
|
+
object[name] = copyValue(valueDecoded[name]);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// Default byte conversion
|
|
88
|
+
if (!options || !options[OP_BYTES]) {
|
|
89
|
+
object[name] = (0, utils_1.decodeBase64url)(valueDecoded[name]);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// Specific byte conversion
|
|
93
|
+
switch (options[OP_BYTES]) {
|
|
94
|
+
case "BASE58":
|
|
95
|
+
case "CONTRACT_ID":
|
|
96
|
+
case "ADDRESS":
|
|
97
|
+
object[name] = (0, utils_1.decodeBase58)(valueDecoded[name]);
|
|
98
|
+
break;
|
|
99
|
+
case "BASE64":
|
|
100
|
+
object[name] = (0, utils_1.decodeBase64url)(valueDecoded[name]);
|
|
101
|
+
break;
|
|
102
|
+
case "HEX":
|
|
103
|
+
case "BLOCK_ID":
|
|
104
|
+
case "TRANSACTION_ID":
|
|
105
|
+
object[name] = (0, utils_1.toUint8Array)(valueDecoded[name].replace("0x", ""));
|
|
106
|
+
break;
|
|
107
|
+
default:
|
|
108
|
+
throw new Error(`unknown btype ${options[OP_BYTES]}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
71
111
|
/**
|
|
72
112
|
* Function to encode a type using the protobuffer definitions
|
|
73
113
|
* It also prepares the bytes for special cases (base58, hex string)
|
|
74
114
|
* when bytesConversion param is true.
|
|
75
115
|
*/
|
|
76
|
-
async serialize(valueDecoded, typeName) {
|
|
116
|
+
async serialize(valueDecoded, typeName, opts) {
|
|
77
117
|
const protobufType = this.defaultType || this.root.lookupType(typeName);
|
|
78
118
|
let object = {};
|
|
79
|
-
|
|
119
|
+
const bytesConversion = (opts === null || opts === void 0 ? void 0 : opts.bytesConversion) === undefined
|
|
120
|
+
? this.bytesConversion
|
|
121
|
+
: opts.bytesConversion;
|
|
122
|
+
if (bytesConversion) {
|
|
80
123
|
// TODO: format from Buffer to base58/base64 for nested fields
|
|
81
|
-
Object.keys(protobufType.fields).forEach((fieldName) =>
|
|
82
|
-
const { options, name, type } = protobufType.fields[fieldName];
|
|
83
|
-
// No byte conversion
|
|
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
|
-
});
|
|
124
|
+
Object.keys(protobufType.fields).forEach((fieldName) => this.converter(valueDecoded, object, protobufType, fieldName));
|
|
112
125
|
}
|
|
113
126
|
else {
|
|
114
127
|
object = valueDecoded;
|
|
@@ -122,14 +135,20 @@ class Serializer {
|
|
|
122
135
|
* It also encodes the bytes for special cases (base58, hex string)
|
|
123
136
|
* when bytesConversion param is true.
|
|
124
137
|
*/
|
|
125
|
-
async deserialize(valueEncoded, typeName) {
|
|
138
|
+
async deserialize(valueEncoded, typeName, opts) {
|
|
126
139
|
const valueBuffer = typeof valueEncoded === "string"
|
|
127
|
-
? (0, utils_1.
|
|
140
|
+
? (0, utils_1.decodeBase64url)(valueEncoded)
|
|
128
141
|
: valueEncoded;
|
|
129
142
|
const protobufType = this.defaultType || this.root.lookupType(typeName);
|
|
130
143
|
const message = protobufType.decode(valueBuffer);
|
|
131
|
-
const object = protobufType.toObject(message, {
|
|
132
|
-
|
|
144
|
+
const object = protobufType.toObject(message, {
|
|
145
|
+
longs: String,
|
|
146
|
+
defaults: true,
|
|
147
|
+
});
|
|
148
|
+
const bytesConversion = (opts === null || opts === void 0 ? void 0 : opts.bytesConversion) === undefined
|
|
149
|
+
? this.bytesConversion
|
|
150
|
+
: opts.bytesConversion;
|
|
151
|
+
if (!bytesConversion)
|
|
133
152
|
return object;
|
|
134
153
|
// TODO: format from Buffer to base58/base64 for nested fields
|
|
135
154
|
Object.keys(protobufType.fields).forEach((fieldName) => {
|
|
@@ -139,7 +158,7 @@ class Serializer {
|
|
|
139
158
|
return;
|
|
140
159
|
// Default byte conversion
|
|
141
160
|
if (!options || !options[OP_BYTES]) {
|
|
142
|
-
object[name] = (0, utils_1.
|
|
161
|
+
object[name] = (0, utils_1.encodeBase64url)(object[name]);
|
|
143
162
|
return;
|
|
144
163
|
}
|
|
145
164
|
// Specific byte conversion
|
|
@@ -150,7 +169,7 @@ class Serializer {
|
|
|
150
169
|
object[name] = (0, utils_1.encodeBase58)(object[name]);
|
|
151
170
|
break;
|
|
152
171
|
case "BASE64":
|
|
153
|
-
object[name] = (0, utils_1.
|
|
172
|
+
object[name] = (0, utils_1.encodeBase64url)(object[name]);
|
|
154
173
|
break;
|
|
155
174
|
case "HEX":
|
|
156
175
|
case "BLOCK_ID":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Serializer.js","sourceRoot":"","sources":["../../src/Serializer.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,4CAA0D;AAC1D,mCAOiB;AAEjB,MAAM,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"Serializer.js","sourceRoot":"","sources":["../../src/Serializer.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,4CAA0D;AAC1D,mCAOiB;AAEjB,MAAM,QAAQ,GAAG,SAAS,CAAC;AAE3B;;;;;;;;GAQG;AACH,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC1D,OAAO,KAAK,CAAC;KACd;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAY,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAa,UAAU;IAsBrB,YACE,KAAiB,EACjB,IAaC;QApBH;;W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