-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first push to leverage ts sdk for constants
- Loading branch information
1 parent
b7a0d00
commit e3d2c8c
Showing
10 changed files
with
616 additions
and
2 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 @@ | ||
node_modules |
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,14 @@ | ||
GENEREATORS = chains cctpDomains | ||
|
||
chains_PATH = ../src/constants/Chains.sol | ||
cctpDomains_PATH = ../src/constants/CCTPDomains.sol | ||
|
||
.PHONY: generate $(GENEREATORS) | ||
|
||
generate: $(GENEREATORS) | ||
|
||
$(GENEREATORS): node_modules | ||
npm run --silent $@ > $($@_PATH) | ||
|
||
node_modules: | ||
npm install |
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,30 @@ | ||
import { toCapsSnakeCase } from "./utils"; | ||
import * as base from "@wormhole-foundation/sdk-base"; | ||
|
||
const { circleChainId, circleNetworks, circleChainMap } = base.circle; | ||
|
||
console.log( | ||
`// SPDX-License-Identifier: Apache 2 | ||
pragma solidity ^0.8.0; | ||
// This file is auto-generated by gen/cctpDomains.ts. | ||
`); | ||
|
||
if (circleNetworks[0] !== "Mainnet" || circleNetworks[1] !== "Testnet") | ||
throw new Error("circleNetworks has unexpected content"); | ||
|
||
const mainnetChains = base.column(circleChainMap[0], 0); | ||
const testnetChains = base.column(circleChainMap[1], 0); | ||
|
||
for (const chain of mainnetChains) | ||
console.log( | ||
`uint32 constant CCTP_DOMAIN_${toCapsSnakeCase(chain)} = ${circleChainId("Mainnet", chain)};` | ||
); | ||
|
||
console.log(` | ||
// Additional Testnet mappings:`); | ||
for (const chain of testnetChains) | ||
if (!(mainnetChains as string[]).includes(chain)) | ||
console.log( | ||
`uint32 constant CCTP_DOMAIN_${toCapsSnakeCase(chain)} = ${circleChainId("Testnet", chain)};` | ||
); |
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 @@ | ||
import { toCapsSnakeCase } from "./utils"; | ||
import * as base from "@wormhole-foundation/sdk-base"; | ||
|
||
const { chains, chainToChainId } = base.chain; | ||
|
||
console.log( | ||
`// SPDX-License-Identifier: Apache 2 | ||
pragma solidity ^0.8.0; | ||
// This file is auto-generated by gen/chains.ts. | ||
// In the wormhole wire format, 0 indicates that a message is for any destination chain | ||
uint16 constant CHAIN_ID_UNSET = 0;`); | ||
|
||
for (const chain of chains) | ||
console.log(`uint16 constant CHAIN_ID_${toCapsSnakeCase(chain)} = ${chainToChainId(chain)};`); |
Oops, something went wrong.