A Module written in javascript for managing various keyrings of Optimism accounts, encrypting them, and using them.
npm install --save @getsafle/vault-optimism-controller
const { KeyringController, getBalance } = require('@getsafle/vault-optimism-controller');
const optimismController = new KeyringController({
encryptor: {
// An optional object for defining encryption schemes:
// Defaults to Browser-native SubtleCrypto.
encrypt(password, object) {
return new Promise('encrypted!');
},
decrypt(password, encryptedString) {
return new Promise({ foo: 'bar' });
},
},
});
const keyringState = await optimismController.createNewVaultAndKeychain(password);
const keyringState = await optimismController.createNewVaultAndRestore(password, mnemonic);
const keyringState = await optimismController.addNewAccount(keyringObject);
const privateKey = await optimismController.exportAccount(address);
const signedTx = await optimismController.signTransaction(optimismTx, _fromAddress);
const signedMsg = await optimismController.signMessage(msgParams);
const signedObj = await optimismController.sign(msgParams, pvtKey, web3Obj);
const signedData = await optimismController.signTypedMessage(msgParams);
const balance = await getBalance(address, web3);