PHP WebShell

Текущая директория: /opt/BitGoJS/node_modules/@hashgraph/sdk/lib/account

Просмотр файла: AccountInfoFlow.cjs

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _AccountInfoQuery = _interopRequireDefault(require("./AccountInfoQuery.cjs"));
var _KeyList = _interopRequireDefault(require("../KeyList.cjs"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*-
 * ‌
 * Hedera JavaScript SDK
 * ​
 * Copyright (C) 2020 - 2022 Hedera Hashgraph, LLC
 * ​
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ‍
 */

/**
 * @typedef {import("../client/Client.js").default<*, *>} Client
 * @typedef {import("../transaction/Transaction.js").default} Transaction
 * @typedef {import("../PublicKey.js").default} PublicKey
 * @typedef {import("./AccountId.js").default} AccountId
 * @typedef {import("../Signer.js").Signer} Signer
 */

class AccountInfoFlow {
  /**
   * @param {Client} client
   * @param {AccountId | string} accountId
   * @param {Uint8Array} message
   * @param {Uint8Array} signature
   * @returns {Promise<boolean>}
   */
  static async verifySignature(client, accountId, message, signature) {
    const info = await new _AccountInfoQuery.default().setAccountId(accountId).execute(client);
    if (info.key instanceof _KeyList.default) {
      return false;
    }
    return (/** @type {PublicKey} */info.key.verify(message, signature)
    );
  }

  /**
   * @param {Client} client
   * @param {AccountId | string} accountId
   * @param {Transaction} transaction
   * @returns {Promise<boolean>}
   */
  static async verifyTransaction(client, accountId, transaction) {
    const info = await new _AccountInfoQuery.default().setAccountId(accountId).execute(client);
    if (info.key instanceof _KeyList.default) {
      return false;
    }
    return (/** @type {PublicKey} */info.key.verifyTransaction(transaction)
    );
  }

  /**
   * @param {Signer} signer
   * @param {AccountId | string} accountId
   * @param {Uint8Array} message
   * @param {Uint8Array} signature
   * @returns {Promise<boolean>}
   */
  static async verifySignatureWithSigner(signer, accountId, message, signature) {
    const info = await new _AccountInfoQuery.default().setAccountId(accountId).executeWithSigner(signer);
    if (info.key instanceof _KeyList.default) {
      return false;
    }
    return (/** @type {PublicKey} */info.key.verify(message, signature)
    );
  }

  /**
   * @param {Signer} signer
   * @param {AccountId | string} accountId
   * @param {Transaction} transaction
   * @returns {Promise<boolean>}
   */
  static async verifyTransactionWithSigner(signer, accountId, transaction) {
    const info = await new _AccountInfoQuery.default().setAccountId(accountId).executeWithSigner(signer);
    if (info.key instanceof _KeyList.default) {
      return false;
    }
    return (/** @type {PublicKey} */info.key.verifyTransaction(transaction)
    );
  }
}
exports.default = AccountInfoFlow;

Выполнить команду


Для локальной разработки. Не используйте в интернете!