Skip to content

Commit

Permalink
AutoRelayer: remove anchor file that was prettified
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeHowarth committed Aug 17, 2023
1 parent 7b7b44a commit 2f50b3e
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions sdk/js/scripts/compileAnchorIdls.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@ const DST_IDL = __dirname + "/../src/anchor-idl";
const TS = __dirname + "/../src/solana/types";

const programs = {
"wormhole.json": "Wormhole",
"token_bridge.json": "TokenBridge",
"nft_bridge.json": "NftBridge",
"wormhole.json": "Wormhole",
"token_bridge.json": "TokenBridge",
"nft_bridge.json": "NftBridge",
};

function main() {
if (!fs.existsSync(DST_IDL)) {
fs.mkdirSync(DST_IDL);
}
if (!fs.existsSync(DST_IDL)) {
fs.mkdirSync(DST_IDL);
}

if (!fs.existsSync(TS)) {
fs.mkdirSync(TS);
}
if (!fs.existsSync(TS)) {
fs.mkdirSync(TS);
}

for (const basename of fs.readdirSync(SRC_IDL)) {
const idl = DST_IDL + "/" + basename;
fs.copyFileSync(SRC_IDL + "/" + basename, idl);
for (const basename of fs.readdirSync(SRC_IDL)) {
const idl = DST_IDL + "/" + basename;
fs.copyFileSync(SRC_IDL + "/" + basename, idl);

const targetTypescript =
TS + "/" + snakeToCamel(basename).replace("json", "ts");
const targetTypescript = TS + "/" + snakeToCamel(basename).replace("json", "ts");

const programType = programs[basename];
fs.writeFileSync(targetTypescript, `export type ${programType} = `);
fs.appendFileSync(targetTypescript, fs.readFileSync(idl));
}
const programType = programs[basename];
fs.writeFileSync(targetTypescript, `export type ${programType} = `);
fs.appendFileSync(targetTypescript, fs.readFileSync(idl));
}
}

const snakeToCamel = (str) =>
str
.toLowerCase()
.replace(/([-_][a-z])/g, (group) =>
group.toUpperCase().replace("-", "").replace("_", "")
);
const snakeToCamel = str =>
str.toLowerCase().replace(/([-_][a-z])/g, group =>
group
.toUpperCase()
.replace('-', '')
.replace('_', '')
);

main();
main();

0 comments on commit 2f50b3e

Please sign in to comment.