koilib 5.3.1 → 5.5.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 +85 -4
- package/dist/koinos.js +15717 -2629
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +49 -5
- package/lib/Contract.js +168 -98
- package/lib/Contract.js.map +1 -1
- package/lib/Serializer.d.ts +36 -15
- package/lib/Serializer.js +82 -16
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.js +1 -1
- package/lib/Signer.js.map +1 -1
- package/lib/Transaction.d.ts +109 -0
- package/lib/Transaction.js +184 -0
- package/lib/Transaction.js.map +1 -0
- package/lib/browser/Contract.d.ts +49 -5
- package/lib/browser/Contract.js +168 -98
- package/lib/browser/Contract.js.map +1 -1
- package/lib/browser/Serializer.d.ts +36 -15
- package/lib/browser/Serializer.js +82 -16
- package/lib/browser/Serializer.js.map +1 -1
- package/lib/browser/Signer.js +1 -1
- package/lib/browser/Signer.js.map +1 -1
- package/lib/browser/Transaction.d.ts +109 -0
- package/lib/browser/Transaction.js +184 -0
- package/lib/browser/Transaction.js.map +1 -0
- package/lib/browser/index.d.ts +1 -0
- package/lib/browser/index.js +1 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index2.js +2 -0
- package/lib/browser/index2.js.map +1 -1
- package/lib/browser/interface.d.ts +188 -86
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/index2.js +2 -0
- package/lib/index2.js.map +1 -1
- package/lib/interface.d.ts +188 -86
- package/package.json +3 -1
package/lib/browser/Contract.js
CHANGED
|
@@ -63,9 +63,14 @@ const utils_1 = require("./utils");
|
|
|
63
63
|
class Contract {
|
|
64
64
|
constructor(c) {
|
|
65
65
|
var _a;
|
|
66
|
+
this.signer = c.signer;
|
|
66
67
|
if (c.id)
|
|
67
68
|
this.id = (0, utils_1.decodeBase58)(c.id);
|
|
68
|
-
|
|
69
|
+
else {
|
|
70
|
+
if (!this.signer)
|
|
71
|
+
throw new Error("at least signer or contract id must be defined");
|
|
72
|
+
this.id = (0, utils_1.decodeBase58)(this.signer.getAddress());
|
|
73
|
+
}
|
|
69
74
|
this.provider = c.provider || ((_a = c.signer) === null || _a === void 0 ? void 0 : _a.provider);
|
|
70
75
|
this.abi = c.abi;
|
|
71
76
|
this.bytecode = c.bytecode;
|
|
@@ -75,6 +80,9 @@ class Contract {
|
|
|
75
80
|
else if (c.abi && c.abi.koilib_types) {
|
|
76
81
|
this.serializer = new Serializer_1.Serializer(c.abi.koilib_types);
|
|
77
82
|
}
|
|
83
|
+
else if (c.abi && c.abi.types) {
|
|
84
|
+
this.serializer = new Serializer_1.Serializer(c.abi.types);
|
|
85
|
+
}
|
|
78
86
|
this.options = {
|
|
79
87
|
signTransaction: true,
|
|
80
88
|
sendTransaction: true,
|
|
@@ -83,94 +91,123 @@ class Contract {
|
|
|
83
91
|
...c.options,
|
|
84
92
|
};
|
|
85
93
|
this.functions = {};
|
|
86
|
-
|
|
87
|
-
Object.keys(this.abi.methods).forEach((name) => {
|
|
88
|
-
this.functions[name] = async (argu = {}, options) => {
|
|
89
|
-
if (!this.provider)
|
|
90
|
-
throw new Error("provider not found");
|
|
91
|
-
if (!this.abi || !this.abi.methods)
|
|
92
|
-
throw new Error("Methods are not defined");
|
|
93
|
-
if (!this.abi.methods[name])
|
|
94
|
-
throw new Error(`Method ${name} not defined in the ABI`);
|
|
95
|
-
const opts = {
|
|
96
|
-
...this.options,
|
|
97
|
-
...options,
|
|
98
|
-
};
|
|
99
|
-
const { read_only: readOnly, return: output, default_output: defaultOutput, preformat_argument: preformatArgument, preformat_return: preformatReturn, } = this.abi.methods[name];
|
|
100
|
-
let args;
|
|
101
|
-
if (typeof preformatArgument === "function") {
|
|
102
|
-
args = preformatArgument(argu);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
args = argu;
|
|
106
|
-
}
|
|
107
|
-
const operation = await this.encodeOperation({ name, args });
|
|
108
|
-
if (opts.onlyOperation) {
|
|
109
|
-
return { operation };
|
|
110
|
-
}
|
|
111
|
-
if (readOnly) {
|
|
112
|
-
if (!output)
|
|
113
|
-
throw new Error(`No output defined for ${name}`);
|
|
114
|
-
// read contract
|
|
115
|
-
const { result: resultEncoded } = await this.provider.readContract(operation.call_contract);
|
|
116
|
-
let result = defaultOutput;
|
|
117
|
-
if (resultEncoded) {
|
|
118
|
-
result = await this.serializer.deserialize(resultEncoded, output);
|
|
119
|
-
}
|
|
120
|
-
if (typeof preformatReturn === "function") {
|
|
121
|
-
result = preformatReturn(result);
|
|
122
|
-
}
|
|
123
|
-
return { operation, result };
|
|
124
|
-
}
|
|
125
|
-
// write contract (sign and send)
|
|
126
|
-
if (!this.signer)
|
|
127
|
-
throw new Error("signer not found");
|
|
128
|
-
let tx = await this.signer.prepareTransaction({
|
|
129
|
-
header: {
|
|
130
|
-
...(opts.chainId && { chain_id: opts.chainId }),
|
|
131
|
-
...(opts.rcLimit && { rc_limit: opts.rcLimit }),
|
|
132
|
-
...(opts.nonce && { nonce: opts.nonce }),
|
|
133
|
-
...(opts.payer && { payer: opts.payer }),
|
|
134
|
-
...(opts.payee && { payee: opts.payee }),
|
|
135
|
-
},
|
|
136
|
-
operations: [
|
|
137
|
-
...(opts.previousOperations ? opts.previousOperations : []),
|
|
138
|
-
operation,
|
|
139
|
-
...(opts.nextOperations ? opts.nextOperations : []),
|
|
140
|
-
],
|
|
141
|
-
});
|
|
142
|
-
const optsSend = {
|
|
143
|
-
broadcast: opts.broadcast,
|
|
144
|
-
beforeSend: opts.beforeSend,
|
|
145
|
-
};
|
|
146
|
-
if (opts.sendAbis) {
|
|
147
|
-
optsSend.abis = {};
|
|
148
|
-
const contractId = (0, utils_1.encodeBase58)(this.id);
|
|
149
|
-
optsSend.abis[contractId] = this.abi;
|
|
150
|
-
}
|
|
151
|
-
// return result if the transaction will not be broadcasted
|
|
152
|
-
if (!opts.sendTransaction) {
|
|
153
|
-
const noWait = () => {
|
|
154
|
-
throw new Error("This transaction was not broadcasted");
|
|
155
|
-
};
|
|
156
|
-
if (opts.signTransaction)
|
|
157
|
-
tx = await this.signer.signTransaction(tx, optsSend.abis);
|
|
158
|
-
return { operation, transaction: { ...tx, wait: noWait } };
|
|
159
|
-
}
|
|
160
|
-
const { transaction, receipt } = await this.signer.sendTransaction(tx, optsSend);
|
|
161
|
-
return { operation, transaction, receipt };
|
|
162
|
-
};
|
|
163
|
-
});
|
|
164
|
-
}
|
|
94
|
+
this.updateFunctionsFromAbi();
|
|
165
95
|
}
|
|
166
96
|
/**
|
|
167
97
|
* Get contract Id
|
|
168
98
|
*/
|
|
169
99
|
getId() {
|
|
170
|
-
if (!this.id)
|
|
171
|
-
throw new Error("id is not defined");
|
|
172
100
|
return (0, utils_1.encodeBase58)(this.id);
|
|
173
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Fetch the ABI from the contract meta store. The provider must
|
|
104
|
+
* have contract_meta_store microservice enabled.
|
|
105
|
+
*/
|
|
106
|
+
async fetcthAbi(opts = {
|
|
107
|
+
updateFunctions: true,
|
|
108
|
+
updateSerializer: true,
|
|
109
|
+
}) {
|
|
110
|
+
if (!this.provider)
|
|
111
|
+
throw new Error("provider not found");
|
|
112
|
+
const response = await this.provider.call("contract_meta_store.get_contract_meta", {
|
|
113
|
+
contract_id: this.getId(),
|
|
114
|
+
});
|
|
115
|
+
if (!response.meta || !response.meta.abi)
|
|
116
|
+
return undefined;
|
|
117
|
+
this.abi = JSON.parse(response.meta.abi);
|
|
118
|
+
if (opts.updateFunctions)
|
|
119
|
+
this.updateFunctionsFromAbi();
|
|
120
|
+
if (opts.updateSerializer) {
|
|
121
|
+
if (this.abi.koilib_types)
|
|
122
|
+
this.serializer = new Serializer_1.Serializer(this.abi.koilib_types);
|
|
123
|
+
else if (this.abi.types)
|
|
124
|
+
this.serializer = new Serializer_1.Serializer(this.abi.types);
|
|
125
|
+
}
|
|
126
|
+
return this.abi;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Create the contract functions based on the ABI
|
|
130
|
+
*/
|
|
131
|
+
updateFunctionsFromAbi() {
|
|
132
|
+
if (!this.abi || !this.abi.methods)
|
|
133
|
+
return false;
|
|
134
|
+
Object.keys(this.abi.methods).forEach((name) => {
|
|
135
|
+
this.functions[name] = async (argu = {}, options) => {
|
|
136
|
+
if (!this.provider)
|
|
137
|
+
throw new Error("provider not found");
|
|
138
|
+
if (!this.abi || !this.abi.methods)
|
|
139
|
+
throw new Error("Methods are not defined");
|
|
140
|
+
if (!this.abi.methods[name])
|
|
141
|
+
throw new Error(`Method ${name} not defined in the ABI`);
|
|
142
|
+
const opts = {
|
|
143
|
+
...this.options,
|
|
144
|
+
...options,
|
|
145
|
+
};
|
|
146
|
+
const { read_only: readOnly, return: output, default_output: defaultOutput, preformat_argument: preformatArgument, preformat_return: preformatReturn, } = this.abi.methods[name];
|
|
147
|
+
let args;
|
|
148
|
+
if (typeof preformatArgument === "function") {
|
|
149
|
+
args = preformatArgument(argu);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
args = argu;
|
|
153
|
+
}
|
|
154
|
+
const operation = await this.encodeOperation({ name, args });
|
|
155
|
+
if (opts.onlyOperation) {
|
|
156
|
+
return { operation };
|
|
157
|
+
}
|
|
158
|
+
if (readOnly) {
|
|
159
|
+
if (!output)
|
|
160
|
+
throw new Error(`No output defined for ${name}`);
|
|
161
|
+
// read contract
|
|
162
|
+
const { result: resultEncoded } = await this.provider.readContract(operation.call_contract);
|
|
163
|
+
let result = defaultOutput;
|
|
164
|
+
if (resultEncoded) {
|
|
165
|
+
result = await this.serializer.deserialize(resultEncoded, output);
|
|
166
|
+
}
|
|
167
|
+
if (typeof preformatReturn === "function") {
|
|
168
|
+
result = preformatReturn(result);
|
|
169
|
+
}
|
|
170
|
+
return { operation, result };
|
|
171
|
+
}
|
|
172
|
+
// write contract (sign and send)
|
|
173
|
+
if (!this.signer)
|
|
174
|
+
throw new Error("signer not found");
|
|
175
|
+
let tx = await this.signer.prepareTransaction({
|
|
176
|
+
header: {
|
|
177
|
+
...(opts.chainId && { chain_id: opts.chainId }),
|
|
178
|
+
...(opts.rcLimit && { rc_limit: opts.rcLimit }),
|
|
179
|
+
...(opts.nonce && { nonce: opts.nonce }),
|
|
180
|
+
...(opts.payer && { payer: opts.payer }),
|
|
181
|
+
...(opts.payee && { payee: opts.payee }),
|
|
182
|
+
},
|
|
183
|
+
operations: [
|
|
184
|
+
...(opts.previousOperations ? opts.previousOperations : []),
|
|
185
|
+
operation,
|
|
186
|
+
...(opts.nextOperations ? opts.nextOperations : []),
|
|
187
|
+
],
|
|
188
|
+
});
|
|
189
|
+
if (opts.sendAbis) {
|
|
190
|
+
if (!opts.abis)
|
|
191
|
+
opts.abis = {};
|
|
192
|
+
const contractId = this.getId();
|
|
193
|
+
if (!opts.abis[contractId])
|
|
194
|
+
opts.abis[contractId] = this.abi;
|
|
195
|
+
}
|
|
196
|
+
// return result if the transaction will not be broadcasted
|
|
197
|
+
if (!opts.sendTransaction) {
|
|
198
|
+
const noWait = () => {
|
|
199
|
+
throw new Error("This transaction was not broadcasted");
|
|
200
|
+
};
|
|
201
|
+
if (opts.signTransaction)
|
|
202
|
+
tx = await this.signer.signTransaction(tx, opts.sendAbis ? opts.abis : undefined);
|
|
203
|
+
return { operation, transaction: { ...tx, wait: noWait } };
|
|
204
|
+
}
|
|
205
|
+
const { transaction, receipt } = await this.signer.sendTransaction(tx, opts);
|
|
206
|
+
return { operation, transaction, receipt };
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
174
211
|
/**
|
|
175
212
|
* Function to deploy a new smart contract.
|
|
176
213
|
* The Bytecode must be defined in the constructor of the class
|
|
@@ -224,9 +261,7 @@ class Contract {
|
|
|
224
261
|
...this.options,
|
|
225
262
|
...options,
|
|
226
263
|
};
|
|
227
|
-
const contractId = this.
|
|
228
|
-
? (0, utils_1.encodeBase58)(this.id)
|
|
229
|
-
: this.signer.getAddress();
|
|
264
|
+
const contractId = this.getId();
|
|
230
265
|
const operation = {
|
|
231
266
|
upload_contract: {
|
|
232
267
|
contract_id: contractId,
|
|
@@ -260,20 +295,16 @@ class Contract {
|
|
|
260
295
|
...(opts.nextOperations ? opts.nextOperations : []),
|
|
261
296
|
],
|
|
262
297
|
});
|
|
263
|
-
const optsSend = {
|
|
264
|
-
broadcast: opts.broadcast,
|
|
265
|
-
beforeSend: opts.beforeSend,
|
|
266
|
-
};
|
|
267
298
|
// return result if the transaction will not be broadcasted
|
|
268
299
|
if (!opts.sendTransaction) {
|
|
269
300
|
const noWait = () => {
|
|
270
301
|
throw new Error("This transaction was not broadcasted");
|
|
271
302
|
};
|
|
272
303
|
if (opts.signTransaction)
|
|
273
|
-
tx = await this.signer.signTransaction(tx);
|
|
304
|
+
tx = await this.signer.signTransaction(tx, opts.sendAbis ? opts.abis : undefined);
|
|
274
305
|
return { operation, transaction: { ...tx, wait: noWait } };
|
|
275
306
|
}
|
|
276
|
-
const { transaction, receipt } = await this.signer.sendTransaction(tx,
|
|
307
|
+
const { transaction, receipt } = await this.signer.sendTransaction(tx, opts);
|
|
277
308
|
return { operation, transaction, receipt };
|
|
278
309
|
}
|
|
279
310
|
/**
|
|
@@ -307,8 +338,6 @@ class Contract {
|
|
|
307
338
|
throw new Error(`Operation ${op.name} unknown`);
|
|
308
339
|
if (!this.serializer)
|
|
309
340
|
throw new Error("Serializer is not defined");
|
|
310
|
-
if (!this.id)
|
|
311
|
-
throw new Error("Contract id is not defined");
|
|
312
341
|
const method = this.abi.methods[op.name];
|
|
313
342
|
let bufferArguments = new Uint8Array(0);
|
|
314
343
|
if (method.argument) {
|
|
@@ -318,7 +347,7 @@ class Contract {
|
|
|
318
347
|
}
|
|
319
348
|
return {
|
|
320
349
|
call_contract: {
|
|
321
|
-
contract_id:
|
|
350
|
+
contract_id: this.getId(),
|
|
322
351
|
entry_point: method.entry_point,
|
|
323
352
|
args: (0, utils_1.encodeBase64url)(bufferArguments),
|
|
324
353
|
},
|
|
@@ -347,16 +376,14 @@ class Contract {
|
|
|
347
376
|
* ```
|
|
348
377
|
*/
|
|
349
378
|
async decodeOperation(op) {
|
|
350
|
-
if (!this.id)
|
|
351
|
-
throw new Error("Contract id is not defined");
|
|
352
379
|
if (!this.abi || !this.abi.methods)
|
|
353
380
|
throw new Error("Methods are not defined");
|
|
354
381
|
if (!this.serializer)
|
|
355
382
|
throw new Error("Serializer is not defined");
|
|
356
383
|
if (!op.call_contract)
|
|
357
384
|
throw new Error("Operation is not CallContractOperation");
|
|
358
|
-
if (op.call_contract.contract_id !==
|
|
359
|
-
throw new Error(`Invalid contract id. Expected: ${
|
|
385
|
+
if (op.call_contract.contract_id !== this.getId())
|
|
386
|
+
throw new Error(`Invalid contract id. Expected: ${this.getId()}. Received: ${op.call_contract.contract_id}`);
|
|
360
387
|
for (let i = 0; i < Object.keys(this.abi.methods).length; i += 1) {
|
|
361
388
|
const opName = Object.keys(this.abi.methods)[i];
|
|
362
389
|
const method = this.abi.methods[opName];
|
|
@@ -371,6 +398,49 @@ class Contract {
|
|
|
371
398
|
}
|
|
372
399
|
throw new Error(`Unknown method id ${op.call_contract.entry_point}`);
|
|
373
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* Decode an event received in a receipt
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```ts
|
|
406
|
+
* const contract = new Contract({
|
|
407
|
+
* id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
408
|
+
* abi: utils.tokenAbi,
|
|
409
|
+
* });
|
|
410
|
+
* const event = {
|
|
411
|
+
* sequence: 1,
|
|
412
|
+
* source: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
413
|
+
* name: "koinos.contracts.token.mint_event",
|
|
414
|
+
* data: "ChkAxjdqxuwS-B50lPQ-lqhRBA3bf2b2ooAHENrw3Ek=",
|
|
415
|
+
* impacted: ["1K55BRw87nd64a7aiRarp6DLGRzYvoJo8J"],
|
|
416
|
+
* };
|
|
417
|
+
* const eventDecoded = await contract.decodeEvent(event);
|
|
418
|
+
* console.log(eventDecoded);
|
|
419
|
+
* // {
|
|
420
|
+
* // sequence: 1,
|
|
421
|
+
* // source: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
422
|
+
* // name: "koinos.contracts.token.mint_event",
|
|
423
|
+
* // data: "ChkAxjdqxuwS-B50lPQ-lqhRBA3bf2b2ooAHENrw3Ek=",
|
|
424
|
+
* // impacted: ["1K55BRw87nd64a7aiRarp6DLGRzYvoJo8J"],
|
|
425
|
+
* // args: {
|
|
426
|
+
* // to: "1K55BRw87nd64a7aiRarp6DLGRzYvoJo8J",
|
|
427
|
+
* // value: "154613850",
|
|
428
|
+
* // },
|
|
429
|
+
* // }
|
|
430
|
+
* ```
|
|
431
|
+
*/
|
|
432
|
+
async decodeEvent(event) {
|
|
433
|
+
if (!this.serializer)
|
|
434
|
+
throw new Error("Serializer is not defined");
|
|
435
|
+
let typeName = event.name;
|
|
436
|
+
if (this.abi && this.abi.events && this.abi.events[event.name]) {
|
|
437
|
+
typeName = this.abi.events[event.name].argument;
|
|
438
|
+
}
|
|
439
|
+
const args = typeName
|
|
440
|
+
? await this.serializer.deserialize(event.data, typeName)
|
|
441
|
+
: {};
|
|
442
|
+
return { ...event, args };
|
|
443
|
+
}
|
|
374
444
|
}
|
|
375
445
|
exports.Contract = Contract;
|
|
376
446
|
exports.default = Contract;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contract.js","sourceRoot":"","sources":["../../src/Contract.ts"],"names":[],"mappings":";;;AAGA,6CAA0C;AAW1C,mCAAsE;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAa,QAAQ;IAgFnB,YAAY,CAcX;;QACC,IAAI,CAAC,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,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{ Root, Type, INamespace } from "protobufjs";
|
|
2
2
|
/**
|
|
3
3
|
* The serializer class serialize and deserialize data using
|
|
4
|
-
* protocol buffers.
|
|
4
|
+
* protocol buffers. It accepts the descriptor in JSON or binary format
|
|
5
5
|
*
|
|
6
|
-
* NOTE: This class uses the [protobufjs
|
|
6
|
+
* NOTE: This class uses the [protobufjs](https://www.npmjs.com/package/protobufjs)
|
|
7
7
|
* library internally, which uses reflection (use of _eval_
|
|
8
8
|
* and _new Function_) for the construction of the types.
|
|
9
9
|
* This could cause issues in environments where _eval_ is not
|
|
@@ -15,23 +15,44 @@ import { Root, Type, INamespace } from "protobufjs/light";
|
|
|
15
15
|
* @example
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
|
+
* // using descriptor JSON
|
|
18
19
|
* const descriptorJson = {
|
|
19
20
|
* nested: {
|
|
20
21
|
* awesomepackage: {
|
|
21
22
|
* nested: {
|
|
22
23
|
* AwesomeMessage: {
|
|
23
24
|
* fields: {
|
|
24
|
-
*
|
|
25
|
+
* awesome_field: {
|
|
25
26
|
* type: "string",
|
|
26
|
-
* id: 1
|
|
27
|
-
* }
|
|
28
|
-
* }
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
* const
|
|
27
|
+
* id: 1,
|
|
28
|
+
* },
|
|
29
|
+
* },
|
|
30
|
+
* },
|
|
31
|
+
* },
|
|
32
|
+
* },
|
|
33
|
+
* },
|
|
34
|
+
* };
|
|
35
|
+
* const serializer1 = new Serializer(descriptorJson);
|
|
36
|
+
* const message1 = await serializer1.deserialize(
|
|
37
|
+
* "CgZrb2lub3M=",
|
|
38
|
+
* "AwesomeMessage"
|
|
39
|
+
* );
|
|
40
|
+
* console.log(message1);
|
|
41
|
+
* // { awesome_field: 'koinos' }
|
|
42
|
+
*
|
|
43
|
+
* // using descriptor binary
|
|
44
|
+
* const descriptorBinary =
|
|
45
|
+
* "Cl4KDWF3ZXNvbWUucHJvdG8SDmF3ZXNvbWVwYWN" +
|
|
46
|
+
* "rYWdlIjUKDkF3ZXNvbWVNZXNzYWdlEiMKDWF3ZX" +
|
|
47
|
+
* "NvbWVfZmllbGQYASABKAlSDGF3ZXNvbWVGaWVsZ" +
|
|
48
|
+
* "GIGcHJvdG8z";
|
|
49
|
+
* const serializer2 = new Serializer(descriptorBinary);
|
|
50
|
+
* const message2 = await serializer2.deserialize(
|
|
51
|
+
* "CgZrb2lub3M=",
|
|
52
|
+
* "AwesomeMessage"
|
|
53
|
+
* );
|
|
54
|
+
* console.log(message2);
|
|
55
|
+
* // { awesome_field: 'koinos' }
|
|
35
56
|
* ```
|
|
36
57
|
*/
|
|
37
58
|
export declare class Serializer {
|
|
@@ -39,7 +60,7 @@ export declare class Serializer {
|
|
|
39
60
|
* Protobuffers descriptor in JSON format.
|
|
40
61
|
* See https://www.npmjs.com/package/protobufjs#using-json-descriptors
|
|
41
62
|
*/
|
|
42
|
-
types: INamespace;
|
|
63
|
+
types: INamespace | string;
|
|
43
64
|
/**
|
|
44
65
|
* Protobuffer definitions
|
|
45
66
|
*/
|
|
@@ -60,7 +81,7 @@ export declare class Serializer {
|
|
|
60
81
|
serialize: boolean;
|
|
61
82
|
deserialize: boolean;
|
|
62
83
|
};
|
|
63
|
-
constructor(types: INamespace, opts?: {
|
|
84
|
+
constructor(types: INamespace | string, opts?: {
|
|
64
85
|
/**
|
|
65
86
|
* Default type name. Use this option when you
|
|
66
87
|
* always want to serialize/deserialize the same type
|
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.Serializer = void 0;
|
|
4
27
|
/* eslint-disable @typescript-eslint/require-await */
|
|
5
|
-
const
|
|
28
|
+
const protobufjs_1 = require("protobufjs");
|
|
29
|
+
const koinosPbToProto = __importStar(require("@roamin/koinos-pb-to-proto"));
|
|
6
30
|
const utils_1 = require("./utils");
|
|
7
31
|
const OP_BYTES_1 = "(btype)";
|
|
8
32
|
const OP_BYTES_2 = "(koinos.btype)";
|
|
@@ -25,9 +49,9 @@ const nativeTypes = [
|
|
|
25
49
|
];
|
|
26
50
|
/**
|
|
27
51
|
* The serializer class serialize and deserialize data using
|
|
28
|
-
* protocol buffers.
|
|
52
|
+
* protocol buffers. It accepts the descriptor in JSON or binary format
|
|
29
53
|
*
|
|
30
|
-
* NOTE: This class uses the [protobufjs
|
|
54
|
+
* NOTE: This class uses the [protobufjs](https://www.npmjs.com/package/protobufjs)
|
|
31
55
|
* library internally, which uses reflection (use of _eval_
|
|
32
56
|
* and _new Function_) for the construction of the types.
|
|
33
57
|
* This could cause issues in environments where _eval_ is not
|
|
@@ -39,23 +63,44 @@ const nativeTypes = [
|
|
|
39
63
|
* @example
|
|
40
64
|
*
|
|
41
65
|
* ```ts
|
|
66
|
+
* // using descriptor JSON
|
|
42
67
|
* const descriptorJson = {
|
|
43
68
|
* nested: {
|
|
44
69
|
* awesomepackage: {
|
|
45
70
|
* nested: {
|
|
46
71
|
* AwesomeMessage: {
|
|
47
72
|
* fields: {
|
|
48
|
-
*
|
|
73
|
+
* awesome_field: {
|
|
49
74
|
* type: "string",
|
|
50
|
-
* id: 1
|
|
51
|
-
* }
|
|
52
|
-
* }
|
|
53
|
-
* }
|
|
54
|
-
* }
|
|
55
|
-
* }
|
|
56
|
-
* }
|
|
57
|
-
* }
|
|
58
|
-
* const
|
|
75
|
+
* id: 1,
|
|
76
|
+
* },
|
|
77
|
+
* },
|
|
78
|
+
* },
|
|
79
|
+
* },
|
|
80
|
+
* },
|
|
81
|
+
* },
|
|
82
|
+
* };
|
|
83
|
+
* const serializer1 = new Serializer(descriptorJson);
|
|
84
|
+
* const message1 = await serializer1.deserialize(
|
|
85
|
+
* "CgZrb2lub3M=",
|
|
86
|
+
* "AwesomeMessage"
|
|
87
|
+
* );
|
|
88
|
+
* console.log(message1);
|
|
89
|
+
* // { awesome_field: 'koinos' }
|
|
90
|
+
*
|
|
91
|
+
* // using descriptor binary
|
|
92
|
+
* const descriptorBinary =
|
|
93
|
+
* "Cl4KDWF3ZXNvbWUucHJvdG8SDmF3ZXNvbWVwYWN" +
|
|
94
|
+
* "rYWdlIjUKDkF3ZXNvbWVNZXNzYWdlEiMKDWF3ZX" +
|
|
95
|
+
* "NvbWVfZmllbGQYASABKAlSDGF3ZXNvbWVGaWVsZ" +
|
|
96
|
+
* "GIGcHJvdG8z";
|
|
97
|
+
* const serializer2 = new Serializer(descriptorBinary);
|
|
98
|
+
* const message2 = await serializer2.deserialize(
|
|
99
|
+
* "CgZrb2lub3M=",
|
|
100
|
+
* "AwesomeMessage"
|
|
101
|
+
* );
|
|
102
|
+
* console.log(message2);
|
|
103
|
+
* // { awesome_field: 'koinos' }
|
|
59
104
|
* ```
|
|
60
105
|
*/
|
|
61
106
|
class Serializer {
|
|
@@ -73,7 +118,16 @@ class Serializer {
|
|
|
73
118
|
deserialize: false,
|
|
74
119
|
};
|
|
75
120
|
this.types = types;
|
|
76
|
-
|
|
121
|
+
if (typeof types === "string") {
|
|
122
|
+
const protos = koinosPbToProto.convert(types);
|
|
123
|
+
this.root = new protobufjs_1.Root();
|
|
124
|
+
for (const proto of protos) {
|
|
125
|
+
(0, protobufjs_1.parse)(proto.definition, this.root, { keepCase: true });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this.root = protobufjs_1.Root.fromJSON(types);
|
|
130
|
+
}
|
|
77
131
|
if (opts === null || opts === void 0 ? void 0 : opts.defaultTypeName)
|
|
78
132
|
this.defaultType = this.root.lookupType(opts.defaultTypeName);
|
|
79
133
|
if (opts && typeof opts.bytesConversion !== "undefined")
|
|
@@ -179,7 +233,13 @@ class Serializer {
|
|
|
179
233
|
* when bytesConversion param is true.
|
|
180
234
|
*/
|
|
181
235
|
async serialize(valueDecoded, typeName, opts) {
|
|
182
|
-
|
|
236
|
+
let protobufType;
|
|
237
|
+
if (this.defaultType)
|
|
238
|
+
protobufType = this.defaultType;
|
|
239
|
+
else if (!typeName)
|
|
240
|
+
throw new Error("no typeName defined");
|
|
241
|
+
else
|
|
242
|
+
protobufType = this.root.lookupType(typeName);
|
|
183
243
|
let object = {};
|
|
184
244
|
const bytesConversion = (opts === null || opts === void 0 ? void 0 : opts.bytesConversion) === undefined
|
|
185
245
|
? this.bytesConversion
|
|
@@ -206,7 +266,13 @@ class Serializer {
|
|
|
206
266
|
const valueBuffer = typeof valueEncoded === "string"
|
|
207
267
|
? (0, utils_1.decodeBase64url)(valueEncoded)
|
|
208
268
|
: valueEncoded;
|
|
209
|
-
|
|
269
|
+
let protobufType;
|
|
270
|
+
if (this.defaultType)
|
|
271
|
+
protobufType = this.defaultType;
|
|
272
|
+
else if (!typeName)
|
|
273
|
+
throw new Error("no typeName defined");
|
|
274
|
+
else
|
|
275
|
+
protobufType = this.root.lookupType(typeName);
|
|
210
276
|
const message = protobufType.decode(valueBuffer);
|
|
211
277
|
const object = protobufType.toObject(message, {
|
|
212
278
|
longs: String,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Serializer.js","sourceRoot":"","sources":["../../src/Serializer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Serializer.js","sourceRoot":"","sources":["../../src/Serializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAqD;AACrD,2CAA2D;AAC3D,4EAA8D;AAE9D,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAa,UAAU;IA+BrB,YACE,KAA0B,EAC1B,IAaC;QA7BH;;WAEG;QACH,oBAAe,GAAG,IAAI,CAAC;QAEvB;;;WAGG;QACH,mBAAc,GAAG;YACf,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,KAAK;SACnB,CAAC;QAmBA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC9C,IAAI,CAAC,IAAI,GAAG,IAAI,iBAAI,EAAE,C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,CAAC,eAAe;YACtB,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC;QAC3B,MAAM,cAAc,GAClB,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,cAAc,MAAK,SAAS;YAChC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW;YACjC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;QAC1B,IAAI,eAAe,EAAE;YACnB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,cAAc,CAAM,CAAC;SACpE;QACD,OAAO,MAAW,CAAC;IACrB,CAAC;CACF;AAnRD,gCAmRC;AAED,kBAAe,UAAU,CAAC"}
|
package/lib/browser/Signer.js
CHANGED
|
@@ -342,7 +342,7 @@ class Signer {
|
|
|
342
342
|
async sendTransaction(transaction, options) {
|
|
343
343
|
var _a;
|
|
344
344
|
if (!transaction.signatures || !((_a = transaction.signatures) === null || _a === void 0 ? void 0 : _a.length))
|
|
345
|
-
transaction = await this.signTransaction(transaction, options === null || options === void 0 ? void 0 : options.abis);
|
|
345
|
+
transaction = await this.signTransaction(transaction, (options === null || options === void 0 ? void 0 : options.sendAbis) ? options.abis : undefined);
|
|
346
346
|
if (!this.provider)
|
|
347
347
|
throw new Error("provider is undefined");
|
|
348
348
|
const opts = {
|