Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions migration/verification/get-staged-code-hash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { connect, keyStores } from "near-api-js";
import dotenv from "dotenv";
import chalk from "chalk";
import { Buffer } from "buffer";
import bs58 from "bs58";

dotenv.config();

interface NearConfig {
networkId: string;
nodeUrl: string;
}

async function get_staged_code_hash(config: NearConfig): Promise<void> {
const contractId = process.env.OMNI_BRIDGE_ACCOUNT_ID || ""

if (!contractId) {
console.log(chalk.yellow(`${contractId} ID not provided, skipping...`));
return;
}


const keyStore = new keyStores.InMemoryKeyStore();
const nearConnection = await connect({
networkId: config.networkId,
keyStore,
nodeUrl: config.nodeUrl,
headers: {},
});
const account = await nearConnection.account("dummy.near");

try {
const up_staged_code_hash = await account.viewFunction({
contractId,
methodName: "up_staged_code_hash",
args: {},
});
const buffer = Buffer.from(up_staged_code_hash);
const base64Encoded = buffer.toString("base64");

console.log("Base64:", base64Encoded);
Comment thread
karim-en marked this conversation as resolved.

const base58Encoded = bs58.encode(buffer);
console.log("Base58:", base58Encoded);
} catch (e) {
console.log(
chalk.yellow(
`up_staged_code_hash function not found or failed`,
),
);
}
}

const nearConfig: NearConfig = {
networkId: process.env.NETWORK_NEAR || "testnet",
nodeUrl: `https://rpc.${process.env.NETWORK_NEAR || "testnet"}.near.org`,
};
get_staged_code_hash(nearConfig)
1 change: 1 addition & 0 deletions migration/verification/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"typescript": "^5.8.2"
},
"dependencies": {
"bs58": "^6.0.0",
"chalk": "^5.4.1",
"dotenv": "^16.4.7",
"ethers": "^6.13.5",
Expand Down
15 changes: 15 additions & 0 deletions migration/verification/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified migration/verification/verify-contract-hash.sh
100644 → 100755
Empty file.
Loading