Skip to content

Commit

Permalink
feat: add a function to generate a random ens, set the ens to the plu…
Browse files Browse the repository at this point in the history
…gin settings
  • Loading branch information
clauBv23 committed Mar 12, 2024
1 parent f7c5f31 commit 02a2242
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/contracts/plugin-settings.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import buildMetadata from './src/build-metadata.json';
import releaseMetadata from './src/release-metadata.json';
import {generateRandomEns} from './utils/helpers';
import {VersionTag} from '@aragon/osx-commons-sdk';

export const PLUGIN_CONTRACT_NAME = 'MyPlugin'; // This must match the filename `packages/contracts/src/MyPlugin.sol` and the contract name `MyPlugin` within.
export const PLUGIN_SETUP_CONTRACT_NAME = 'MyPluginSetup'; // This must match the filename `packages/contracts/src/MyPluginSetup.sol` and the contract name `MyPluginSetup` within.
export const PLUGIN_REPO_ENS_SUBDOMAIN_NAME = 'my'; // This will result in the ENS domain name 'my.plugin.dao.eth'
export const PLUGIN_REPO_ENS_SUBDOMAIN_NAME = generateRandomEns(8); // This will result in the ENS domain name 'my.plugin.dao.eth'

export const VERSION: VersionTag = {
release: 1, // Increment this number ONLY if breaking/incompatible changes were made. Updates between releases are NOT possible.
Expand Down
11 changes: 11 additions & 0 deletions packages/contracts/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,16 @@ export async function createVersion(
return tx;
}

export function generateRandomEns(length: number): string {
const allowedCharacters = 'abcdefghijklmnopqrstuvwxyz-0123456789';
let result = '';
for (let i = 0; i < length; i++) {
result += allowedCharacters.charAt(
Math.floor(Math.random() * allowedCharacters.length)
);
}
return result;
}

export const AragonOSxAsciiArt =
" ____ _____ \n /\\ / __ \\ / ____| \n / \\ _ __ __ _ __ _ ___ _ __ | | | | (_____ __ \n / /\\ \\ | '__/ _` |/ _` |/ _ \\| '_ \\ | | | |\\___ \\ \\/ / \n / ____ \\| | | (_| | (_| | (_) | | | | | |__| |____) > < \n /_/ \\_\\_| \\__,_|\\__, |\\___/|_| |_| \\____/|_____/_/\\_\\ \n __/ | \n |___/ \n";

0 comments on commit 02a2242

Please sign in to comment.