1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const client_common_1 = require("@neo-one/client-common");
|
4 | const utils_1 = require("../utils");
|
5 | class Output extends client_common_1.OutputModel {
|
6 | constructor() {
|
7 | super(...arguments);
|
8 | this.equals = utils_1.utils.equals(Output, this, (other) => client_common_1.common.uInt256Equal(this.asset, other.asset) &&
|
9 | this.value.eq(other.value) &&
|
10 | client_common_1.common.uInt160Equal(this.address, other.address));
|
11 | this.toKeyString = utils_1.utils.toKeyString(Output, () => `${client_common_1.common.uInt256ToString(this.asset)}:${this.value.toString(10)}:${client_common_1.common.uInt160ToString(this.address)}`);
|
12 | }
|
13 | static deserializeWireBase({ reader }) {
|
14 | const asset = reader.readUInt256();
|
15 | const value = reader.readFixed8();
|
16 | const address = reader.readUInt160();
|
17 | return new this({ asset, value, address });
|
18 | }
|
19 | static deserializeWire(options) {
|
20 | return this.deserializeWireBase({
|
21 | context: options.context,
|
22 | reader: new utils_1.BinaryReader(options.buffer),
|
23 | });
|
24 | }
|
25 | clone({ value = this.value }) {
|
26 | return new Output({
|
27 | asset: this.asset,
|
28 | value,
|
29 | address: this.address,
|
30 | });
|
31 | }
|
32 | serializeJSON(context, index) {
|
33 | return {
|
34 | n: index,
|
35 | asset: client_common_1.JSONHelper.writeUInt256(this.asset),
|
36 | value: client_common_1.JSONHelper.writeFixed8(this.value),
|
37 | address: client_common_1.crypto.scriptHashToAddress({
|
38 | addressVersion: context.addressVersion,
|
39 | scriptHash: this.address,
|
40 | }),
|
41 | };
|
42 | }
|
43 | }
|
44 | exports.Output = Output;
|
45 |
|
46 |
|