-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: A5 Pickle <[email protected]> Co-authored-by: Abhishek Rajput <[email protected]>
- Loading branch information
1 parent
b1593e0
commit 18d7a34
Showing
21 changed files
with
240 additions
and
75 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
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
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
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
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
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
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
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,103 @@ | ||
import { Connection, PublicKey } from "@solana/web3.js"; | ||
import { Chain, toChainId } from "@wormhole-foundation/sdk-base"; | ||
import { toUniversal } from "@wormhole-foundation/sdk-definitions"; | ||
import "@wormhole-foundation/sdk-evm/address"; | ||
import * as matchingEngineSdk from "../src/matchingEngine"; | ||
import * as tokenRouterSdk from "../src/tokenRouter"; | ||
|
||
const USDC_MINT = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); | ||
|
||
const CHAINS: Chain[] = ["Arbitrum", "Base"]; | ||
|
||
// Here we go. | ||
main(); | ||
|
||
// impl | ||
|
||
async function main() { | ||
const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed"); | ||
|
||
console.log("Collecting Solana Matching Engine and Token Router Info..."); | ||
console.log(); | ||
{ | ||
const matchingEngine = new matchingEngineSdk.MatchingEngineProgram( | ||
connection, | ||
matchingEngineSdk.mainnet(), | ||
USDC_MINT, | ||
); | ||
|
||
const custodian = matchingEngine.custodianAddress(); | ||
console.log("Matching Engine"); | ||
console.log(" Custodian (NOTE: The Custodian's address is the program's emitter):"); | ||
console.log(` Native: ${custodian.toString()}`); | ||
console.log(` Universal: ${custodian.toBuffer().toString("hex")}`); | ||
console.log(); | ||
|
||
const cctpMintRecipient = matchingEngine.cctpMintRecipientAddress(); | ||
console.log(" Mint Recipient:"); | ||
console.log(` Native: ${cctpMintRecipient.toString()}`); | ||
console.log(` Universal: ${cctpMintRecipient.toBuffer().toString("hex")}`); | ||
console.log(); | ||
|
||
const custodianData = await matchingEngine.fetchCustodian(); | ||
console.log("Custodian Data"); | ||
console.log(JSON.stringify(custodianData, null, 2)); | ||
console.log(); | ||
|
||
const auctionConfig = await matchingEngine.fetchAuctionConfig( | ||
custodianData.auctionConfigId, | ||
); | ||
console.log("Auction Config Data"); | ||
console.log(JSON.stringify(auctionConfig, null, 2)); | ||
console.log(); | ||
|
||
for (const chainName of CHAINS) { | ||
await matchingEngine | ||
.fetchRouterEndpointInfo(toChainId(chainName)) | ||
.then((endpointData) => { | ||
console.log( | ||
`Registered Endpoint (${chainName}): ${stringifyEndpoint( | ||
chainName, | ||
endpointData, | ||
)}`, | ||
); | ||
}) | ||
.catch((err) => { | ||
console.log(`Not Registered: ${chainName}`); | ||
}); | ||
console.log(); | ||
} | ||
} | ||
|
||
{ | ||
const tokenRouter = new tokenRouterSdk.TokenRouterProgram( | ||
connection, | ||
tokenRouterSdk.mainnet(), | ||
USDC_MINT, | ||
); | ||
|
||
const custodian = tokenRouter.custodianAddress(); | ||
console.log(`Token Router`); | ||
console.log(" Custodian (NOTE: The Custodian's address is the program's emitter):"); | ||
console.log(` Native: ${custodian.toString()}`); | ||
console.log(` Universal: ${custodian.toBuffer().toString("hex")}`); | ||
console.log(); | ||
|
||
const cctpMintRecipient = tokenRouter.cctpMintRecipientAddress(); | ||
console.log(" Mint Recipient:"); | ||
console.log(` Native: ${cctpMintRecipient.toString()}`); | ||
console.log(` Universal: ${cctpMintRecipient.toBuffer().toString("hex")}`); | ||
console.log(); | ||
} | ||
} | ||
|
||
function stringifyEndpoint(chain: Chain, endpoint: matchingEngineSdk.EndpointInfo) { | ||
const out = { | ||
address: toUniversal(chain, Uint8Array.from(endpoint.address)).toNative(chain).toString(), | ||
mintRecipient: toUniversal(chain, Uint8Array.from(endpoint.mintRecipient)) | ||
.toNative(chain) | ||
.toString(), | ||
protocol: endpoint.protocol, | ||
}; | ||
return JSON.stringify(out, null, 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
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
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
Oops, something went wrong.