Skip to content

Instantly share code, notes, and snippets.

@Beasta
Last active September 29, 2021 07:37
Show Gist options
  • Save Beasta/3eaec00449086128eef36339bff47f68 to your computer and use it in GitHub Desktop.
Save Beasta/3eaec00449086128eef36339bff47f68 to your computer and use it in GitHub Desktop.
node.js script for retrieving, modifying, and updating Frame wallets. Meant to be run it its own folder. Kill Frame first.
// probably a smart idea to make sure that Frame isn't running when this is executed
const fs = require('fs');
// this location assumes Mac installation
let frameConfigLocation = `${process.env.HOME}/Library/Application Support/frame/config.json`;
// testMode will create a copy of the frame Config in the local folder and modify that instead of the original
const testMode = true;
let frameConfig;
let frameConfigAccounts;
const exampleAddressObj = {
id: '0x223c067F8CF28ae173EE5CafEa60cA44C335fecB',
name: 'Urbit Awesomeness',
lastSignerType: 'trezor',
address: '0x223c067F8CF28ae173EE5CafEa60cA44C335fecB',
status: 'ok',
signer: '',
requests: {},
ensName: 'URBIT.ETH',
tokens: {},
created: '13283371:1632340314349'
}
const enableTestMode = async () => {
try {
await fs.copyFileSync(frameConfigLocation, "./frameConfigBackup.json");
console.log(`file at ${frameConfigLocation} has been backed up`);
frameConfigLocation = './frameConfigBackup.json';
} catch (err) {
console.log('error copying file:',err);
}
}
const readFromDisk = async () => {
try {
// read file from disk
frameConfig = await JSON.parse(fs.readFileSync(frameConfigLocation, 'utf8'));
// extract the accounts. I'm assuming 14 could be the version? could be something that changes
frameConfigAccounts = frameConfig.main.__[14].main.accounts
} catch (err) {
console.log(err);
}
}
const writeToDisk = async () => {
try {
await fs.writeFileSync(frameConfigLocation, JSON.stringify(frameConfig, null, 2));
} catch (err) {
console.log('error writing file:', err);
}
}
const readModifyWrite = async () => {
if (testMode) {
await enableTestMode();
};
await readFromDisk();
// insert exampleAddressObj into the accounts
frameConfigAccounts[exampleAddressObj.address] = exampleAddressObj;
await writeToDisk();
}
readModifyWrite();
@Beasta
Copy link
Author

Beasta commented Sep 29, 2021

Similar script but for zapper.fi wallets - https://gist.github.com/Beasta/6b0649125cd138ab7c7c11764689111e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment