UNPKG

@hashgraph/sdk

Version:
74 lines (67 loc) 2.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var HieroProto = _interopRequireWildcard(require("@hashgraph/proto")); var _ContractId = _interopRequireDefault(require("./ContractId.cjs")); var _StorageChange = _interopRequireDefault(require("./StorageChange.cjs")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } // SPDX-License-Identifier: Apache-2.0 /** * @deprecated - Use mirror node for contract traceability instead */ class ContractStateChange { /** * @private * @param {object} props * @param {ContractId} props.contractId * @param {StorageChange[]} props.storageChanges */ constructor(props) { this.contractId = props.contractId; this.storageChanges = props.storageChanges; Object.freeze(this); } /** * @internal * @param {HieroProto.proto.IContractStateChange} change * @returns {ContractStateChange} */ static _fromProtobuf(change) { // eslint-disable-next-line deprecation/deprecation return new ContractStateChange({ contractId: _ContractId.default._fromProtobuf(/** @type {HieroProto.proto.IContractID} */change.contractId), storageChanges: (change.storageChanges != null ? change.storageChanges : [] // eslint-disable-next-line deprecation/deprecation ).map(change => _StorageChange.default._fromProtobuf(change)) }); } /** * @param {Uint8Array} bytes * @returns {ContractStateChange} */ static fromBytes(bytes) { // eslint-disable-next-line deprecation/deprecation return ContractStateChange._fromProtobuf(HieroProto.proto.ContractStateChange.decode(bytes)); } /** * @internal * @returns {HieroProto.proto.IContractStateChange} change */ _toProtobuf() { return { contractId: this.contractId._toProtobuf(), storageChanges: this.storageChanges.map(storageChange => storageChange._toProtobuf()) }; } /** * @returns {Uint8Array} */ toBytes() { // eslint-disable-next-line deprecation/deprecation return HieroProto.proto.ContractStateChange.encode(this._toProtobuf()).finish(); } } exports.default = ContractStateChange;