UNPKG

@glitterprotocol/glitter-sdk

Version:

The JavaScript SDK for Glitter

108 lines 4.35 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.EthAccount = void 0; var json_1 = require("../../util/json"); var account_1 = require("@glitterprotocol/glitter.proto/ethermint/types/v1/account"); var any_1 = require("@glitterprotocol/glitter.proto/google/protobuf/any"); /** * Stores information about an account fetched from the blockchain. */ var EthAccount = /** @class */ (function (_super) { __extends(EthAccount, _super); /** * Creates a new Account object, holding information about a basic account. * * @param address account address * @param public_key account's public key information * @param account_number account number on the blockchain * @param sequence sequence number, or number of transactions that have been posted */ function EthAccount(base_account, code_hash) { var _this = _super.call(this) || this; _this.base_account = base_account; _this.code_hash = code_hash; return _this; } EthAccount.prototype.getAccountNumber = function () { return this.base_account.account_number; }; EthAccount.prototype.getSequenceNumber = function () { return this.base_account.sequence; }; EthAccount.prototype.getPublicKey = function () { return this.base_account.public_key; }; EthAccount.prototype.toAmino = function (_) { var _a = this, base_account = _a.base_account, code_hash = _a.code_hash; return { type: 'cosmos-sdk/BaseAccount', value: { base_account: base_account, code_hash: code_hash, }, }; }; EthAccount.fromAmino = function (data, _) { _; var _a = data.value, base_account = _a.base_account, code_hash = _a.code_hash; return new EthAccount(base_account, code_hash); }; EthAccount.fromData = function (data, _) { _; var base_account = data.base_account, code_hash = data.code_hash; return new EthAccount(base_account, code_hash); }; EthAccount.prototype.toData = function (_) { _; var _a = this, base_account = _a.base_account, code_hash = _a.code_hash; return { '@type': '/ethermint.types.v1.EthAccount', base_account: base_account, code_hash: code_hash, }; }; EthAccount.prototype.toProto = function (_) { _; var _a = this, base_account = _a.base_account, code_hash = _a.code_hash; return account_1.EthAccount.fromPartial({ baseAccount: { address: base_account.address, pubKey: base_account.public_key, accountNumber: base_account.account_number, sequence: base_account.sequence, }, codeHash: code_hash, }); }; EthAccount.fromProto = function (EthAccountProto, _) { _; return new EthAccount(EthAccountProto.baseAccount, EthAccountProto.codeHash); }; EthAccount.prototype.packAny = function (isClassic) { return any_1.Any.fromPartial({ typeUrl: '/ethermint.types.v1.EthAccount', value: account_1.EthAccount.encode(this.toProto(isClassic)).finish(), }); }; EthAccount.unpackAny = function (pubkeyAny, isClassic) { return EthAccount.fromProto(account_1.EthAccount.decode(pubkeyAny.value), isClassic); }; return EthAccount; }(json_1.JSONSerializable)); exports.EthAccount = EthAccount; //# sourceMappingURL=EthAccount.js.map