-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script to automatically generate token bridge configs
- Loading branch information
1 parent
7312a51
commit c4f6891
Showing
13 changed files
with
8,135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
[*.{js,json,yml}] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/.yarn/** linguist-vendored | ||
/.yarn/releases/* binary | ||
/.yarn/plugins/**/* binary | ||
/.pnp.* binary linguist-generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
|
||
# Swap the comments on the following lines if you wish to use zero-installs | ||
# In that case, don't forget to run `yarn config set enableGlobalCache false`! | ||
# Documentation here: https://yarnpkg.com/features/caching#zero-installs | ||
|
||
#!.yarn/cache | ||
.pnp.* | ||
|
||
node_modules | ||
output.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# tbr-config-generator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env -S node --loader @swc-node/register/esm | ||
import { Chain } from "@wormhole-foundation/sdk"; | ||
import { writeFileSync } from "node:fs"; | ||
import { parseArgs } from "node:util"; | ||
|
||
const args = process.argv.slice(2); | ||
|
||
const { values, positionals } = parseArgs({ | ||
args, | ||
options: { | ||
help: { | ||
type: 'boolean', | ||
short: 'h' | ||
}, | ||
query: { | ||
type: 'string' | ||
}, | ||
address: { | ||
type: 'string' | ||
}, | ||
sourceChain: { | ||
type: 'string' | ||
}, | ||
targetChains: { | ||
type: 'string' | ||
} | ||
}, | ||
allowPositionals: true | ||
}); | ||
|
||
function printHelp() { | ||
console.log(` | ||
Usage: index.mts [options] | ||
Options: | ||
-h, --help Print this help message | ||
--queries The queries to run | ||
--address The address to use | ||
--source-chain The chain to use | ||
--target-chains The chains to use | ||
`); | ||
} | ||
|
||
if (values.help) { | ||
printHelp(); | ||
process.exit(0); | ||
} | ||
|
||
if (values.query && (values.sourceChain || values.address)) { | ||
console.error("Queries cannot be used with address or chain"); | ||
process.exit(1); | ||
} | ||
|
||
if (values.address && !values.sourceChain || values.sourceChain && !values.address) { | ||
console.error("Both address and chain are required"); | ||
process.exit(1); | ||
} | ||
|
||
async function executeCreateConfigFromAddressAndChain() { | ||
const { createConfigFromAddressAndChain } = await import("../src/createConfigFromAddressAndChain"); | ||
const wormholeSourceChain = values.sourceChain as Chain; | ||
const wormholeTargetChains = values.targetChains!.split(",") as Array<Chain>; | ||
const output = await createConfigFromAddressAndChain(values.address!, wormholeSourceChain, wormholeTargetChains); | ||
writeFileSync(positionals.pop() || "output.json", JSON.stringify(output, null, 2)); | ||
} | ||
|
||
if (values.address && values.sourceChain && values.targetChains) { | ||
console.log(`Running queries with address ${values.address} on chain ${values.sourceChain} and target chains ${values.targetChains}`); | ||
executeCreateConfigFromAddressAndChain(); | ||
} | ||
|
||
async function executeCreateConfigFromDuneQuery() { | ||
const { createConfigFromDuneQuery } = await import("../src/createConfigFromDuneQuery"); | ||
const output = await createConfigFromDuneQuery(parseInt(values.query!)); | ||
writeFileSync(positionals.pop() || "output.json", JSON.stringify(output, null, 2)); | ||
} | ||
|
||
if (values.query) { | ||
console.log(`Running queries ${values.query}`); | ||
executeCreateConfigFromDuneQuery(); | ||
} |
Oops, something went wrong.