UNPKG

@metamask/keyring-snap-client

Version:
84 lines 4.14 kB
"use strict"; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _KeyringPublicClient_client; Object.defineProperty(exports, "__esModule", { value: true }); exports.KeyringPublicClient = exports.KeyringPublicRpcMethod = void 0; const keyring_api_1 = require("@metamask/keyring-api"); const KeyringClient_1 = require("./KeyringClient.cjs"); /** * Public methods list. */ exports.KeyringPublicRpcMethod = [ keyring_api_1.KeyringRpcMethod.CreateAccount, keyring_api_1.KeyringRpcMethod.GetAccount, keyring_api_1.KeyringRpcMethod.UpdateAccount, keyring_api_1.KeyringRpcMethod.DeleteAccount, keyring_api_1.KeyringRpcMethod.ExportAccount, keyring_api_1.KeyringRpcMethod.ListAccounts, keyring_api_1.KeyringRpcMethod.FilterAccountChains, keyring_api_1.KeyringRpcMethod.GetRequest, keyring_api_1.KeyringRpcMethod.ApproveRequest, keyring_api_1.KeyringRpcMethod.RejectRequest, keyring_api_1.KeyringRpcMethod.ListRequests, ]; /** * A client that can be used by companion dapp. Only some keyring methods are * available with this client. */ class KeyringPublicClient { /** * Create a new instance of `KeyringPublicClient`. * * @param sender - The `Sender` instance to use to send requests to the snap. */ constructor(sender) { _KeyringPublicClient_client.set(this, void 0); __classPrivateFieldSet(this, _KeyringPublicClient_client, new KeyringClient_1.KeyringClient(sender), "f"); } async createAccount(options) { return __classPrivateFieldGet(this, _KeyringPublicClient_client, "f").createAccount(options); } async deleteAccount(id) { return __classPrivateFieldGet(this, _KeyringPublicClient_client, "f").deleteAccount(id); } async listAccounts() { return __classPrivateFieldGet(this, _KeyringPublicClient_client, "f").listAccounts(); } async getAccount(id) { return __classPrivateFieldGet(this, _KeyringPublicClient_client, "f").getAccount(id); } async getRequest(id) { return __classPrivateFieldGet(this, _KeyringPublicClient_client, "f").getRequest(id); } async listRequests() { return __classPrivateFieldGet(this, _KeyringPublicClient_client, "f").listRequests(); } async updateAccount(account) { return __classPrivateFieldGet(this, _KeyringPublicClient_client, "f").updateAccount(account); } async approveRequest(id, data) { return __classPrivateFieldGet(this, _KeyringPublicClient_client, "f").approveRequest(id, data); } async rejectRequest(id) { return __classPrivateFieldGet(this, _KeyringPublicClient_client, "f").rejectRequest(id); } async filterAccountChains(id, chains) { return __classPrivateFieldGet(this, _KeyringPublicClient_client, "f").filterAccountChains(id, chains); } async exportAccount(id) { return __classPrivateFieldGet(this, _KeyringPublicClient_client, "f").exportAccount(id); } } exports.KeyringPublicClient = KeyringPublicClient; _KeyringPublicClient_client = new WeakMap(); //# sourceMappingURL=KeyringPublicClient.cjs.map