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/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
|
}
|
|
@@ -80,13 +85,24 @@ class Provider {
|
|
|
80
85
|
* transactions for a particular account. This call is used
|
|
81
86
|
* when creating new transactions.
|
|
82
87
|
* @param account - account address
|
|
88
|
+
* @param deserialize - If set true it will deserialize the nonce
|
|
89
|
+
* and return it as number (default). If set false it will return
|
|
90
|
+
* the nonce encoded as received from the RPC.
|
|
83
91
|
* @returns Nonce
|
|
84
92
|
*/
|
|
85
|
-
async getNonce(account) {
|
|
86
|
-
const { nonce } = await this.call("chain.get_account_nonce", { account });
|
|
87
|
-
if (!
|
|
88
|
-
return
|
|
89
|
-
|
|
93
|
+
async getNonce(account, deserialize = true) {
|
|
94
|
+
const { nonce: nonceBase64url } = await this.call("chain.get_account_nonce", { account });
|
|
95
|
+
if (!deserialize) {
|
|
96
|
+
return nonceBase64url;
|
|
97
|
+
}
|
|
98
|
+
const valueBuffer = (0, utils_1.decodeBase64url)(nonceBase64url);
|
|
99
|
+
const message = protocol_proto_js_1.koinos.chain.value_type.decode(valueBuffer);
|
|
100
|
+
const object = protocol_proto_js_1.koinos.chain.value_type.toObject(message, {
|
|
101
|
+
longs: String,
|
|
102
|
+
defaults: true,
|
|
103
|
+
});
|
|
104
|
+
// todo: consider the case where nonce is greater than max safe integer
|
|
105
|
+
return Number(object.uint64_value);
|
|
90
106
|
}
|
|
91
107
|
async getAccountRc(account) {
|
|
92
108
|
const { rc } = await this.call("chain.get_account_rc", {
|
|
@@ -106,7 +122,7 @@ class Provider {
|
|
|
106
122
|
}
|
|
107
123
|
async getBlocksById(blockIds) {
|
|
108
124
|
return this.call("block_store.get_blocks_by_id", {
|
|
109
|
-
|
|
125
|
+
block_ids: blockIds,
|
|
110
126
|
return_block: true,
|
|
111
127
|
return_receipt: false,
|
|
112
128
|
});
|
|
@@ -117,6 +133,13 @@ class Provider {
|
|
|
117
133
|
async getHeadInfo() {
|
|
118
134
|
return this.call("chain.get_head_info", {});
|
|
119
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Function to get the chain
|
|
138
|
+
*/
|
|
139
|
+
async getChainId() {
|
|
140
|
+
const { chain_id: chainId } = await this.call("chain.get_chain_id", {});
|
|
141
|
+
return chainId;
|
|
142
|
+
}
|
|
120
143
|
/**
|
|
121
144
|
* Function to get consecutive blocks in descending order
|
|
122
145
|
* @param height - Starting block height
|
|
@@ -146,93 +169,102 @@ class Provider {
|
|
|
146
169
|
return (await this.getBlocks(height, 1))[0];
|
|
147
170
|
}
|
|
148
171
|
/**
|
|
149
|
-
* Function to
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
172
|
+
* Function to wait for a transaction to be mined.
|
|
173
|
+
* @param txId - transaction id
|
|
174
|
+
* @param type - Type must be "byBlock" (default) or "byTransactionId".
|
|
175
|
+
* _byBlock_ will query the blockchain to get blocks and search for the
|
|
176
|
+
* transaction there. _byTransactionId_ will query the "transaction store"
|
|
177
|
+
* microservice to search the transaction by its id. If non of them is
|
|
178
|
+
* specified the function will use "byBlock" (as "byTransactionId"
|
|
179
|
+
* requires the transaction store, which is an optional microservice).
|
|
180
|
+
*
|
|
181
|
+
* When _byBlock_ is used it returns the block number.
|
|
182
|
+
*
|
|
183
|
+
* When _byTransactionId_ is used it returns the block id.
|
|
184
|
+
*
|
|
185
|
+
* @param timeout - Timeout in milliseconds. By default it is 30000
|
|
154
186
|
* @example
|
|
155
187
|
* ```ts
|
|
156
|
-
* const
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* signatureData: "...",
|
|
160
|
-
* });
|
|
161
|
-
* console.log("Transaction submitted to the mempool");
|
|
162
|
-
* // wait to be mined
|
|
163
|
-
* const blockNumber = await transactionResponse.wait();
|
|
164
|
-
* // const blockNumber = await transactionResponse.wait("byBlock", 30000);
|
|
165
|
-
* // const blockId = await transactionResponse.wait("byTransactionId", 30000);
|
|
188
|
+
* const blockNumber = await provider.wait(txId);
|
|
189
|
+
* // const blockNumber = await provider.wait(txId, "byBlock", 30000);
|
|
190
|
+
* // const blockId = await provider.wait(txId, "byTransactionId", 30000);
|
|
166
191
|
* console.log("Transaction mined")
|
|
167
192
|
* ```
|
|
168
193
|
*/
|
|
169
|
-
async
|
|
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
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (tx)
|
|
199
|
-
bNum = Number(block.block_height);
|
|
200
|
-
});
|
|
201
|
-
const lastId = blocks[blocks.length - 1].block_id;
|
|
202
|
-
return [bNum, lastId];
|
|
203
|
-
};
|
|
204
|
-
let blockNumber = 0;
|
|
205
|
-
let iniBlock = 0;
|
|
206
|
-
let previousId = "";
|
|
207
|
-
while (Date.now() < iniTime + timeout) {
|
|
208
|
-
await sleep(1000);
|
|
209
|
-
const { head_topology: headTopology } = await this.getHeadInfo();
|
|
210
|
-
if (blockNumber === 0) {
|
|
211
|
-
blockNumber = Number(headTopology.height);
|
|
212
|
-
iniBlock = blockNumber;
|
|
213
|
-
}
|
|
214
|
-
if (Number(headTopology.height) === blockNumber - 1 &&
|
|
215
|
-
previousId &&
|
|
216
|
-
previousId !== headTopology.id) {
|
|
217
|
-
const [bNum, lastId] = await findTxInBlocks(iniBlock, Number(headTopology.height) - iniBlock + 1, headTopology.id);
|
|
218
|
-
if (bNum)
|
|
219
|
-
return bNum;
|
|
220
|
-
previousId = lastId;
|
|
221
|
-
blockNumber = Number(headTopology.height) + 1;
|
|
222
|
-
}
|
|
223
|
-
// eslint-disable-next-line no-continue
|
|
224
|
-
if (blockNumber > Number(headTopology.height))
|
|
225
|
-
continue;
|
|
226
|
-
const [bNum, lastId] = await findTxInBlocks(blockNumber, 1, headTopology.id);
|
|
227
|
-
if (bNum)
|
|
228
|
-
return bNum;
|
|
229
|
-
if (!previousId)
|
|
230
|
-
previousId = lastId;
|
|
231
|
-
blockNumber += 1;
|
|
232
|
-
}
|
|
233
|
-
throw new Error(`Transaction not mined after ${timeout} ms. Blocks checked from ${iniBlock} to ${blockNumber}`);
|
|
234
|
-
},
|
|
194
|
+
async wait(txId, type = "byBlock", timeout = 30000) {
|
|
195
|
+
const iniTime = Date.now();
|
|
196
|
+
if (type === "byTransactionId") {
|
|
197
|
+
while (Date.now() < iniTime + timeout) {
|
|
198
|
+
await sleep(1000);
|
|
199
|
+
const { transactions } = await this.getTransactionsById([txId]);
|
|
200
|
+
if (transactions &&
|
|
201
|
+
transactions[0] &&
|
|
202
|
+
transactions[0].containing_blocks)
|
|
203
|
+
return transactions[0].containing_blocks[0];
|
|
204
|
+
}
|
|
205
|
+
throw new Error(`Transaction not mined after ${timeout} ms`);
|
|
206
|
+
}
|
|
207
|
+
// byBlock
|
|
208
|
+
const findTxInBlocks = async (ini, numBlocks, idRef) => {
|
|
209
|
+
const blocks = await this.getBlocks(ini, numBlocks, idRef);
|
|
210
|
+
let bNum = 0;
|
|
211
|
+
blocks.forEach((block) => {
|
|
212
|
+
if (!block ||
|
|
213
|
+
!block.block ||
|
|
214
|
+
!block.block_id ||
|
|
215
|
+
!block.block.transactions)
|
|
216
|
+
return;
|
|
217
|
+
const tx = block.block.transactions.find((t) => t.id === txId);
|
|
218
|
+
if (tx)
|
|
219
|
+
bNum = Number(block.block_height);
|
|
220
|
+
});
|
|
221
|
+
const lastId = blocks[blocks.length - 1].block_id;
|
|
222
|
+
return [bNum, lastId];
|
|
235
223
|
};
|
|
224
|
+
let blockNumber = 0;
|
|
225
|
+
let iniBlock = 0;
|
|
226
|
+
let previousId = "";
|
|
227
|
+
while (Date.now() < iniTime + timeout) {
|
|
228
|
+
await sleep(1000);
|
|
229
|
+
const { head_topology: headTopology } = await this.getHeadInfo();
|
|
230
|
+
if (blockNumber === 0) {
|
|
231
|
+
blockNumber = Number(headTopology.height);
|
|
232
|
+
iniBlock = blockNumber;
|
|
233
|
+
}
|
|
234
|
+
if (Number(headTopology.height) === blockNumber - 1 &&
|
|
235
|
+
previousId &&
|
|
236
|
+
previousId !== headTopology.id) {
|
|
237
|
+
const [bNum, lastId] = await findTxInBlocks(iniBlock, Number(headTopology.height) - iniBlock + 1, headTopology.id);
|
|
238
|
+
if (bNum)
|
|
239
|
+
return bNum;
|
|
240
|
+
previousId = lastId;
|
|
241
|
+
blockNumber = Number(headTopology.height) + 1;
|
|
242
|
+
}
|
|
243
|
+
// eslint-disable-next-line no-continue
|
|
244
|
+
if (blockNumber > Number(headTopology.height))
|
|
245
|
+
continue;
|
|
246
|
+
const [bNum, lastId] = await findTxInBlocks(blockNumber, 1, headTopology.id);
|
|
247
|
+
if (bNum)
|
|
248
|
+
return bNum;
|
|
249
|
+
if (!previousId)
|
|
250
|
+
previousId = lastId;
|
|
251
|
+
blockNumber += 1;
|
|
252
|
+
}
|
|
253
|
+
throw new Error(`Transaction not mined after ${timeout} ms. Blocks checked from ${iniBlock} to ${blockNumber}`);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Function to call "chain.submit_transaction" to send a signed
|
|
257
|
+
* transaction to the blockchain.
|
|
258
|
+
*/
|
|
259
|
+
async sendTransaction(transaction) {
|
|
260
|
+
return this.call("chain.submit_transaction", { transaction });
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Function to call "chain.submit_block" to send a signed
|
|
264
|
+
* block to the blockchain.
|
|
265
|
+
*/
|
|
266
|
+
async submitBlock(block) {
|
|
267
|
+
return this.call("chain.submit_block", { block });
|
|
236
268
|
}
|
|
237
269
|
/**
|
|
238
270
|
* Function to call "chain.read_contract" to read a contract.
|
package/lib/Provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../src/Provider.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;
|
|
1
|
+
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../src/Provider.ts"],"names":[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S,CAAC,CAAC;IACrD,CAAC;CACF;AA7ZD,4BA6ZC;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,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;
|
package/lib/Serializer.js
CHANGED
|
@@ -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":
|
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;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,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