-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add: ops script to initialize gateway program #20
Conversation
57c2299
to
3ddbccb
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #20 +/- ##
=====================================
Coverage 9.17% 9.17%
=====================================
Files 1 1
Lines 218 218
=====================================
Hits 20 20
Misses 198 198 ☔ View full report in Codecov by Sentry. |
da90859
to
3a7e0d5
Compare
@@ -16,3 +16,4 @@ wallet = "~/.config/solana/id.json" | |||
|
|||
[scripts] | |||
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" | |||
#test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/ops.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/ops.ts" |
// uncomment Anchor.toml [test] to run this script | ||
// #test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/ops.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unclear what does this mean. We should put instruction to run the script in the readme
console.log("====================================="); | ||
console.log("BEGIN OPS ON DEVNET........"); | ||
|
||
const provider = anchor.AnchorProvider.local("https://api.devnet.solana.com"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment above mention it c mainnet but here the URL is devnet. I think we should use an environment variable for it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, same as mentioned before: we could group all constants in const.ts, adding the ability to override them via env var.
// Uncomment the following to initialize the gateway program; | ||
// can only be initialized once | ||
// try { | ||
// const inst = await gatewayProgram.methods.initialize(tssAddressArray,chain_id_bn).transaction(); | ||
// console.log("initialize inst:", inst); | ||
// const tx = await anchor.web3.sendAndConfirmTransaction(conn, inst, [wallet]); | ||
// console.log("tx:", tx); | ||
// } catch (err) { | ||
// console.log("initialize err:", err); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should rather have argument or using environment variable to customize script logic
// const pdaAccountData = await gatewayProgram.account.pda.fetch(pdaAccount); | ||
try { | ||
console.log("fetching pda account data....", pdaAccount.toBase58()); | ||
// const data = await gatewayProgram.account.pda.fetch(pdaAccount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// const data = await gatewayProgram.account.pda.fetch(pdaAccount); |
|
||
const pdaAccountInfo = await conn.getAccountInfo(pdaAccount); | ||
console.log("pdaAccountInfoData:", pdaAccountInfo.data); | ||
// const pdaAccountData = await gatewayProgram.account.pda.fetch(pdaAccount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// const pdaAccountData = await gatewayProgram.account.pda.fetch(pdaAccount); |
console.log(`depositPaused: ${ainfo.depositPaused}`); | ||
console.log(`chain_id: ${ainfo.chainId}`); | ||
|
||
// console.log(`pda data:`, ainfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// console.log(`pda data:`, ainfo); |
// console.log(`pda account data: nonce ${pdaAccountData.nonce}`); | ||
// const hexAddr = bufferToHex(Buffer.from(pdaAccountData.tssAddress)); | ||
// console.log(`pda account data: tss address ${hexAddr}`); | ||
// console.log(`authority: ${pdaAccountData.authority.toBase58()}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// console.log(`pda account data: nonce ${pdaAccountData.nonce}`); | |
// const hexAddr = bufferToHex(Buffer.from(pdaAccountData.tssAddress)); | |
// console.log(`pda account data: tss address ${hexAddr}`); | |
// console.log(`authority: ${pdaAccountData.authority.toBase58()}`); |
@@ -0,0 +1,90 @@ | |||
// this is for ops on devnet/mainnet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unclear what ops means, if this is to deploy the gateway, it should be reflected in the name of the script?
import {bufferToHex} from "ethereumjs-util"; | ||
import {getAccount} from "@solana/spl-token"; | ||
|
||
const programId = new web3.PublicKey("ZETAjseVjuFsxdRxo6MmTCvqFwb3ZHUx56Co3vCmGis"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move all hardcoded values to constants in a separate file, and add the ability of overriding them via env vars?
console.log("====================================="); | ||
console.log("BEGIN OPS ON DEVNET........"); | ||
|
||
const provider = anchor.AnchorProvider.local("https://api.devnet.solana.com"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, same as mentioned before: we could group all constants in const.ts, adding the ability to override them via env var.
thanksf or the comments, but to clarify: the ops script serves two purposes:
This is one-off script (at most two-off). The commented code is there to prevent accidental re-deployment and can be uncommented for mainnet deployment. As long as it works I will not further improve it. |
Not sure to understand the point. If the script is not used in practice and just as a template, the we can have a playbook instead of it. |
closing this as it's not suitable for merging. |
No description provided.