koilib 5.4.0 → 5.5.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/lib/Contract.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Signer, SignerInterface } from "./Signer";
2
2
  import { Provider } from "./Provider";
3
3
  import { Serializer } from "./Serializer";
4
- import { TransactionJsonWait, Abi, CallContractOptions, DecodedOperationJson, OperationJson, DeployOptions, TransactionReceipt } from "./interface";
4
+ import { TransactionJsonWait, Abi, CallContractOptions, DecodedOperationJson, OperationJson, DeployOptions, TransactionReceipt, EventData, DecodedEventData } from "./interface";
5
5
  /**
6
6
  * The contract class contains the contract ID and contract entries
7
7
  * definition needed to encode/decode operations during the
@@ -147,6 +147,24 @@ export declare class Contract {
147
147
  * Get contract Id
148
148
  */
149
149
  getId(): string;
150
+ /**
151
+ * Fetch the ABI from the contract meta store and save it in the
152
+ * abi of the contract. The provider must have contract_meta_store
153
+ * microservice enabled.
154
+ * @param opts - options object with 2 boolean: 1) updateFunctions to
155
+ * specify if the contract functions should be regenerated based on
156
+ * the new ABI, and 2) updateSerializer to determine if the serializer
157
+ * should be updated with the types in the new ABI.
158
+ * @returns the new ABI saved in the contract
159
+ */
160
+ fetchAbi(opts?: {
161
+ updateFunctions: boolean;
162
+ updateSerializer: boolean;
163
+ }): Promise<Abi | undefined>;
164
+ /**
165
+ * Create the contract functions based on the ABI
166
+ */
167
+ updateFunctionsFromAbi(): boolean;
150
168
  /**
151
169
  * Function to deploy a new smart contract.
152
170
  * The Bytecode must be defined in the constructor of the class
@@ -246,5 +264,37 @@ export declare class Contract {
246
264
  * ```
247
265
  */
248
266
  decodeOperation(op: OperationJson): Promise<DecodedOperationJson>;
267
+ /**
268
+ * Decode an event received in a receipt
269
+ *
270
+ * @example
271
+ * ```ts
272
+ * const contract = new Contract({
273
+ * id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
274
+ * abi: utils.tokenAbi,
275
+ * });
276
+ * const event = {
277
+ * sequence: 1,
278
+ * source: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
279
+ * name: "koinos.contracts.token.mint_event",
280
+ * data: "ChkAxjdqxuwS-B50lPQ-lqhRBA3bf2b2ooAHENrw3Ek=",
281
+ * impacted: ["1K55BRw87nd64a7aiRarp6DLGRzYvoJo8J"],
282
+ * };
283
+ * const eventDecoded = await contract.decodeEvent(event);
284
+ * console.log(eventDecoded);
285
+ * // {
286
+ * // sequence: 1,
287
+ * // source: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
288
+ * // name: "koinos.contracts.token.mint_event",
289
+ * // data: "ChkAxjdqxuwS-B50lPQ-lqhRBA3bf2b2ooAHENrw3Ek=",
290
+ * // impacted: ["1K55BRw87nd64a7aiRarp6DLGRzYvoJo8J"],
291
+ * // args: {
292
+ * // to: "1K55BRw87nd64a7aiRarp6DLGRzYvoJo8J",
293
+ * // value: "154613850",
294
+ * // },
295
+ * // }
296
+ * ```
297
+ */
298
+ decodeEvent(event: EventData): Promise<DecodedEventData>;
249
299
  }
250
300
  export default Contract;
package/lib/Contract.js CHANGED
@@ -80,6 +80,9 @@ class Contract {
80
80
  else if (c.abi && c.abi.koilib_types) {
81
81
  this.serializer = new Serializer_1.Serializer(c.abi.koilib_types);
82
82
  }
83
+ else if (c.abi && c.abi.types) {
84
+ this.serializer = new Serializer_1.Serializer(c.abi.types);
85
+ }
83
86
  this.options = {
84
87
  signTransaction: true,
85
88
  sendTransaction: true,
@@ -88,83 +91,7 @@ class Contract {
88
91
  ...c.options,
89
92
  };
90
93
  this.functions = {};
91
- if (this.abi && this.abi.methods) {
92
- Object.keys(this.abi.methods).forEach((name) => {
93
- this.functions[name] = async (argu = {}, options) => {
94
- if (!this.provider)
95
- throw new Error("provider not found");
96
- if (!this.abi || !this.abi.methods)
97
- throw new Error("Methods are not defined");
98
- if (!this.abi.methods[name])
99
- throw new Error(`Method ${name} not defined in the ABI`);
100
- const opts = {
101
- ...this.options,
102
- ...options,
103
- };
104
- const { read_only: readOnly, return: output, default_output: defaultOutput, preformat_argument: preformatArgument, preformat_return: preformatReturn, } = this.abi.methods[name];
105
- let args;
106
- if (typeof preformatArgument === "function") {
107
- args = preformatArgument(argu);
108
- }
109
- else {
110
- args = argu;
111
- }
112
- const operation = await this.encodeOperation({ name, args });
113
- if (opts.onlyOperation) {
114
- return { operation };
115
- }
116
- if (readOnly) {
117
- if (!output)
118
- throw new Error(`No output defined for ${name}`);
119
- // read contract
120
- const { result: resultEncoded } = await this.provider.readContract(operation.call_contract);
121
- let result = defaultOutput;
122
- if (resultEncoded) {
123
- result = await this.serializer.deserialize(resultEncoded, output);
124
- }
125
- if (typeof preformatReturn === "function") {
126
- result = preformatReturn(result);
127
- }
128
- return { operation, result };
129
- }
130
- // write contract (sign and send)
131
- if (!this.signer)
132
- throw new Error("signer not found");
133
- let tx = await this.signer.prepareTransaction({
134
- header: {
135
- ...(opts.chainId && { chain_id: opts.chainId }),
136
- ...(opts.rcLimit && { rc_limit: opts.rcLimit }),
137
- ...(opts.nonce && { nonce: opts.nonce }),
138
- ...(opts.payer && { payer: opts.payer }),
139
- ...(opts.payee && { payee: opts.payee }),
140
- },
141
- operations: [
142
- ...(opts.previousOperations ? opts.previousOperations : []),
143
- operation,
144
- ...(opts.nextOperations ? opts.nextOperations : []),
145
- ],
146
- });
147
- if (opts.sendAbis) {
148
- if (!opts.abis)
149
- opts.abis = {};
150
- const contractId = this.getId();
151
- if (!opts.abis[contractId])
152
- opts.abis[contractId] = this.abi;
153
- }
154
- // return result if the transaction will not be broadcasted
155
- if (!opts.sendTransaction) {
156
- const noWait = () => {
157
- throw new Error("This transaction was not broadcasted");
158
- };
159
- if (opts.signTransaction)
160
- tx = await this.signer.signTransaction(tx, opts.sendAbis ? opts.abis : undefined);
161
- return { operation, transaction: { ...tx, wait: noWait } };
162
- }
163
- const { transaction, receipt } = await this.signer.sendTransaction(tx, opts);
164
- return { operation, transaction, receipt };
165
- };
166
- });
167
- }
94
+ this.updateFunctionsFromAbi();
168
95
  }
169
96
  /**
170
97
  * Get contract Id
@@ -172,6 +99,121 @@ class Contract {
172
99
  getId() {
173
100
  return (0, utils_1.encodeBase58)(this.id);
174
101
  }
102
+ /**
103
+ * Fetch the ABI from the contract meta store and save it in the
104
+ * abi of the contract. The provider must have contract_meta_store
105
+ * microservice enabled.
106
+ * @param opts - options object with 2 boolean: 1) updateFunctions to
107
+ * specify if the contract functions should be regenerated based on
108
+ * the new ABI, and 2) updateSerializer to determine if the serializer
109
+ * should be updated with the types in the new ABI.
110
+ * @returns the new ABI saved in the contract
111
+ */
112
+ async fetchAbi(opts = {
113
+ updateFunctions: true,
114
+ updateSerializer: true,
115
+ }) {
116
+ if (!this.provider)
117
+ throw new Error("provider not found");
118
+ const response = await this.provider.call("contract_meta_store.get_contract_meta", {
119
+ contract_id: this.getId(),
120
+ });
121
+ if (!response.meta || !response.meta.abi)
122
+ return undefined;
123
+ this.abi = JSON.parse(response.meta.abi);
124
+ if (opts.updateFunctions)
125
+ this.updateFunctionsFromAbi();
126
+ if (opts.updateSerializer) {
127
+ if (this.abi.koilib_types)
128
+ this.serializer = new Serializer_1.Serializer(this.abi.koilib_types);
129
+ else if (this.abi.types)
130
+ this.serializer = new Serializer_1.Serializer(this.abi.types);
131
+ }
132
+ return this.abi;
133
+ }
134
+ /**
135
+ * Create the contract functions based on the ABI
136
+ */
137
+ updateFunctionsFromAbi() {
138
+ if (!this.abi || !this.abi.methods)
139
+ return false;
140
+ Object.keys(this.abi.methods).forEach((name) => {
141
+ this.functions[name] = async (argu = {}, options) => {
142
+ if (!this.provider)
143
+ throw new Error("provider not found");
144
+ if (!this.abi || !this.abi.methods)
145
+ throw new Error("Methods are not defined");
146
+ if (!this.abi.methods[name])
147
+ throw new Error(`Method ${name} not defined in the ABI`);
148
+ const opts = {
149
+ ...this.options,
150
+ ...options,
151
+ };
152
+ const { read_only: readOnly, return: output, default_output: defaultOutput, preformat_argument: preformatArgument, preformat_return: preformatReturn, } = this.abi.methods[name];
153
+ let args;
154
+ if (typeof preformatArgument === "function") {
155
+ args = preformatArgument(argu);
156
+ }
157
+ else {
158
+ args = argu;
159
+ }
160
+ const operation = await this.encodeOperation({ name, args });
161
+ if (opts.onlyOperation) {
162
+ return { operation };
163
+ }
164
+ if (readOnly) {
165
+ if (!output)
166
+ throw new Error(`No output defined for ${name}`);
167
+ // read contract
168
+ const { result: resultEncoded } = await this.provider.readContract(operation.call_contract);
169
+ let result = defaultOutput;
170
+ if (resultEncoded) {
171
+ result = await this.serializer.deserialize(resultEncoded, output);
172
+ }
173
+ if (typeof preformatReturn === "function") {
174
+ result = preformatReturn(result);
175
+ }
176
+ return { operation, result };
177
+ }
178
+ // write contract (sign and send)
179
+ if (!this.signer)
180
+ throw new Error("signer not found");
181
+ let tx = await this.signer.prepareTransaction({
182
+ header: {
183
+ ...(opts.chainId && { chain_id: opts.chainId }),
184
+ ...(opts.rcLimit && { rc_limit: opts.rcLimit }),
185
+ ...(opts.nonce && { nonce: opts.nonce }),
186
+ ...(opts.payer && { payer: opts.payer }),
187
+ ...(opts.payee && { payee: opts.payee }),
188
+ },
189
+ operations: [
190
+ ...(opts.previousOperations ? opts.previousOperations : []),
191
+ operation,
192
+ ...(opts.nextOperations ? opts.nextOperations : []),
193
+ ],
194
+ });
195
+ if (opts.sendAbis) {
196
+ if (!opts.abis)
197
+ opts.abis = {};
198
+ const contractId = this.getId();
199
+ if (!opts.abis[contractId])
200
+ opts.abis[contractId] = this.abi;
201
+ }
202
+ // return result if the transaction will not be broadcasted
203
+ if (!opts.sendTransaction) {
204
+ const noWait = () => {
205
+ throw new Error("This transaction was not broadcasted");
206
+ };
207
+ if (opts.signTransaction)
208
+ tx = await this.signer.signTransaction(tx, opts.sendAbis ? opts.abis : undefined);
209
+ return { operation, transaction: { ...tx, wait: noWait } };
210
+ }
211
+ const { transaction, receipt } = await this.signer.sendTransaction(tx, opts);
212
+ return { operation, transaction, receipt };
213
+ };
214
+ });
215
+ return true;
216
+ }
175
217
  /**
176
218
  * Function to deploy a new smart contract.
177
219
  * The Bytecode must be defined in the constructor of the class
@@ -362,6 +404,49 @@ class Contract {
362
404
  }
363
405
  throw new Error(`Unknown method id ${op.call_contract.entry_point}`);
364
406
  }
407
+ /**
408
+ * Decode an event received in a receipt
409
+ *
410
+ * @example
411
+ * ```ts
412
+ * const contract = new Contract({
413
+ * id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
414
+ * abi: utils.tokenAbi,
415
+ * });
416
+ * const event = {
417
+ * sequence: 1,
418
+ * source: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
419
+ * name: "koinos.contracts.token.mint_event",
420
+ * data: "ChkAxjdqxuwS-B50lPQ-lqhRBA3bf2b2ooAHENrw3Ek=",
421
+ * impacted: ["1K55BRw87nd64a7aiRarp6DLGRzYvoJo8J"],
422
+ * };
423
+ * const eventDecoded = await contract.decodeEvent(event);
424
+ * console.log(eventDecoded);
425
+ * // {
426
+ * // sequence: 1,
427
+ * // source: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
428
+ * // name: "koinos.contracts.token.mint_event",
429
+ * // data: "ChkAxjdqxuwS-B50lPQ-lqhRBA3bf2b2ooAHENrw3Ek=",
430
+ * // impacted: ["1K55BRw87nd64a7aiRarp6DLGRzYvoJo8J"],
431
+ * // args: {
432
+ * // to: "1K55BRw87nd64a7aiRarp6DLGRzYvoJo8J",
433
+ * // value: "154613850",
434
+ * // },
435
+ * // }
436
+ * ```
437
+ */
438
+ async decodeEvent(event) {
439
+ if (!this.serializer)
440
+ throw new Error("Serializer is not defined");
441
+ let typeName = event.name;
442
+ if (this.abi && this.abi.events && this.abi.events[event.name]) {
443
+ typeName = this.abi.events[event.name].argument;
444
+ }
445
+ const args = typeName
446
+ ? await this.serializer.deserialize(event.data, typeName)
447
+ : {};
448
+ return { ...event, args };
449
+ }
365
450
  }
366
451
  exports.Contract = Contract;
367
452
  exports.default =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} from "protobufjs/light";
1
+ import { 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/light](https://www.npmjs.com/package/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
- * awesomeField: {
25
+ * awesome_field: {
25
26
  * type: "string",
26
- * id: 1
27
- * }
28
- * }
29
- * }
30
- * }
31
- * }
32
- * }
33
- * }
34
- * const serializer = new Serializer(descriptorJson)
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
package/lib/Serializer.js CHANGED
@@ -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 light_1 = require("protobufjs/light");
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/light](https://www.npmjs.com/package/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
- * awesomeField: {
73
+ * awesome_field: {
49
74
  * type: "string",
50
- * id: 1
51
- * }
52
- * }
53
- * }
54
- * }
55
- * }
56
- * }
57
- * }
58
- * const serializer = new Serializer(descriptorJson)
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
- this.root = light_1.Root.fromJSON(this.types);
121
+ if (typeof types === "string") {
122
+ const protos = koinosPbToProto.convert((0, utils_1.decodeBase64)(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
- const protobufType = this.defaultType || this.root.lookupType(typeName);
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
- const protobufType = this.defaultType || this.root.lookupType(typeName);
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":";;;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;IA+BrB,YACE,KAAiB,EACjB,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,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,IAAI,CAAC,eAAe,KAAK,WAAW;YACrD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;IAChD,CAAC;IAED,WAAW,CACT,iBAAsD,EACtD,YAAkB,EAClB,cAAuB;QAEvB,MAAM,iBAAiB,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AW,CAAC;aACjD,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;;YACtD,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACnD,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC,OAAO,EAAE;YAC5C,KAAK,EAAE,MAAM;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QACH,MAAM,eAAe,GACnB,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,eAAe,MAAK,SAAS;YACjC,CAAC,CAAC,IAAI,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"}
@@ -119,7 +119,7 @@ class Transaction {
119
119
  };
120
120
  this.transaction.header = {
121
121
  ...this.transaction.header,
122
- header,
122
+ ...header,
123
123
  };
124
124
  }
125
125
  if (this.signer) {