diff --git a/src/lib/flows/claim-project-flow/steps/add-ethereum-address/drips-json-template.ts b/src/lib/flows/claim-project-flow/steps/add-ethereum-address/drips-json-template.ts index 7e320a814..9e5ad59b5 100644 --- a/src/lib/flows/claim-project-flow/steps/add-ethereum-address/drips-json-template.ts +++ b/src/lib/flows/claim-project-flow/steps/add-ethereum-address/drips-json-template.ts @@ -1,12 +1,4 @@ -// Map(Object.entries(JSON.parse(jsonText))) - -// JSON.stringify(Object.fromEntries(foo.entries())) - -// Object.keys(existingJson.drips).map((key) => { -// return ` -// "${key}" -// ` -// }) +const NUM_SPACES = 2; export const getChangedTemplate = ( existingJson: object, @@ -15,7 +7,7 @@ export const getChangedTemplate = ( ): [string, [number | null, number | null]] => { // no change, so don't highlight anything if (Object.keys(existingJson).length === 0) { - return [JSON.stringify(objectTemplate(address, network), null, 2), [null, null]]; + return [JSON.stringify(objectTemplate(address, network), null, NUM_SPACES), [null, null]]; } // object are now iterated in order, so when we add the new network here, it will @@ -25,23 +17,15 @@ export const getChangedTemplate = ( ownedBy: address, }; - const asJSON = JSON.stringify(existingJsonCopy, null, 2); + const asJSON = JSON.stringify(existingJsonCopy, null, NUM_SPACES); const end = asJSON.lastIndexOf('}'); // TODO: can we make this magic string based of the actual content? const start = end - ' "": {\n "ownedBy": ""\n }\n }\n'.length - network.length - address.length; return [asJSON, [start, end]]; - // or whatever this should do - // something like take the full config as an object - // take the user's current configuration as an object - // take the network we want to add - // take the users fill configuration and add the network - // return it as a string? }; -// the code box should also take indices, which specificy highlight position(s) - export const objectTemplate = (address: string, network = 'ethereum') => { return { drips: { @@ -51,12 +35,3 @@ export const objectTemplate = (address: string, network = 'ethereum') => { }, }; }; - -export default (address: string, network = 'ethereum') => `{ - "drips": { - "${network}": { - "ownedBy": "${address}" - } - } -} -`;