@metamask/multichain-account-service
Version:
Service to manage multichain accounts
27 lines • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SnapAccountProvider = void 0;
const keyring_controller_1 = require("@metamask/keyring-controller");
const BaseAccountProvider_1 = require("./BaseAccountProvider.cjs");
class SnapAccountProvider extends BaseAccountProvider_1.BaseAccountProvider {
constructor(snapId, messenger) {
super(messenger);
this.snapId = snapId;
}
async getRestrictedSnapAccountCreator() {
// NOTE: We're not supposed to make the keyring instance escape `withKeyring` but
// we have to use the `SnapKeyring` instance to be able to create Solana account
// without triggering UI confirmation.
// Also, creating account that way won't invalidate the Snap keyring state. The
// account will get created and persisted properly with the Snap account creation
// flow "asynchronously" (with `notify:accountCreated`).
const createAccount = await this.withKeyring({ type: keyring_controller_1.KeyringTypes.snap }, async ({ keyring }) => keyring.createAccount.bind(keyring));
return (options) => createAccount(this.snapId, options, {
displayAccountNameSuggestion: false,
displayConfirmation: false,
setSelectedAccount: false,
});
}
}
exports.SnapAccountProvider = SnapAccountProvider;
//# sourceMappingURL=SnapAccountProvider.cjs.map