@metamask/keyring-snap-client
Version:
MetaMask Keyring Snap clients
80 lines • 3.79 kB
JavaScript
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;
import { KeyringRpcMethod } from "@metamask/keyring-api";
import { KeyringClient } from "./KeyringClient.mjs";
/**
* Public methods list.
*/
export const KeyringPublicRpcMethod = [
KeyringRpcMethod.CreateAccount,
KeyringRpcMethod.GetAccount,
KeyringRpcMethod.UpdateAccount,
KeyringRpcMethod.DeleteAccount,
KeyringRpcMethod.ExportAccount,
KeyringRpcMethod.ListAccounts,
KeyringRpcMethod.FilterAccountChains,
KeyringRpcMethod.GetRequest,
KeyringRpcMethod.ApproveRequest,
KeyringRpcMethod.RejectRequest,
KeyringRpcMethod.ListRequests,
];
/**
* A client that can be used by companion dapp. Only some keyring methods are
* available with this client.
*/
export 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(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);
}
}
_KeyringPublicClient_client = new WeakMap();
//# sourceMappingURL=KeyringPublicClient.mjs.map