Skip to content

refactor(contract_manager): restructure contract_manager #2711

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

Merged
merged 11 commits into from
May 27, 2025
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
30 changes: 25 additions & 5 deletions contract_manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,31 @@
"version": "1.0.0",
"description": "Set of tools to manage pyth contracts",
"private": true,
"main": "lib/index.js",
"types": "lib/index.d.ts",
"exports": {
"./node/*": {
"types": "./lib/node/utils/*.d.ts",
"default": "./lib/node/utils/*.js"
},
"./core/*": {
"types": "./lib/core/*.d.ts",
"default": "./lib/core/*.js"
},
"./data/chains/*.json": {
"default": "./store/chains/*.json"
},
"./data/contracts/*.json": {
"default": "./store/contracts/*.json"
},
"./data/tokens/*.json": {
"default": "./store/tokens/*.json"
},
"./data/vaults/*.json": {
"default": "./store/vaults/*.json"
}
},
"files": [
"lib/**/*"
"lib/**/*",
"store/**/*.json"
],
"scripts": {
"build": "tsc",
Expand Down Expand Up @@ -63,8 +84,7 @@
"typescript": "catalog:",
"viem": "^2.23.5",
"web3": "^1.8.2",
"web3-eth-contract": "^1.8.2",
"yaml": "^2.1.1"
"web3-eth-contract": "^1.8.2"
},
"devDependencies": {
"@types/web3": "^1.2.2",
Expand Down
6 changes: 3 additions & 3 deletions contract_manager/scripts/check_proposal.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { CosmWasmChain, EvmChain } from "../src/chains";
import { CosmWasmChain, EvmChain } from "../src/core/chains";
import { createHash } from "crypto";
import { DefaultStore } from "../src/store";
import { DefaultStore } from "../src/node/utils/store";
import {
CosmosUpgradeContract,
EvmExecute,
Expand All @@ -24,7 +24,7 @@ import {
EvmPriceFeedContract,
getCodeDigestWithoutAddress,
EvmWormholeContract,
} from "../src/contracts/evm";
} from "../src/core/contracts/evm";
import Web3 from "web3";

const parser = yargs(hideBin(process.argv))
Expand Down
12 changes: 4 additions & 8 deletions contract_manager/scripts/common.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import {
DefaultStore,
EvmChain,
EvmEntropyContract,
EvmWormholeContract,
getDefaultDeploymentConfig,
PrivateKey,
} from "../src";
import { DefaultStore } from "../src/node/utils/store";
import { existsSync, readFileSync, writeFileSync } from "fs";
import { join } from "path";
import Web3 from "web3";
import { Contract } from "web3-eth-contract";
import { InferredOptionType } from "yargs";
import { PrivateKey, getDefaultDeploymentConfig } from "../src/core/base";
import { EvmChain } from "../src/core/chains";
import { EvmEntropyContract, EvmWormholeContract } from "../src/core/contracts";

export interface BaseDeployConfig {
gasMultiplier: number;
Expand Down
6 changes: 3 additions & 3 deletions contract_manager/scripts/deploy_cosmwasm.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { CosmWasmChain } from "../src/chains";
import { CosmWasmPriceFeedContract } from "../src/contracts/cosmwasm";
import { DefaultStore } from "../src/store";
import { CosmWasmChain } from "../src/core/chains";
import { CosmWasmPriceFeedContract } from "../src/core/contracts/cosmwasm";
import { DefaultStore } from "../src/node/utils/store";

import { COMMON_DEPLOY_OPTIONS } from "./common";

Expand Down
6 changes: 3 additions & 3 deletions contract_manager/scripts/deploy_evm_contract.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { EvmChain } from "../src/chains";
import { DefaultStore } from "../src/store";
import { EvmChain } from "../src/core/chains";
import { DefaultStore } from "../src/node/utils/store";
import { readFileSync } from "fs";
import { toPrivateKey } from "../src";
import { toPrivateKey } from "../src/core/base";

import { COMMON_DEPLOY_OPTIONS } from "./common";

Expand Down
10 changes: 6 additions & 4 deletions contract_manager/scripts/deploy_evm_entropy_contracts.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { EvmChain } from "../src/chains";
import { DefaultStore } from "../src/store";
import { EvmChain } from "../src/core/chains";
import { DefaultStore } from "../src/node/utils/store";
import {
DeploymentType,
ENTROPY_DEFAULT_KEEPER,
ENTROPY_DEFAULT_PROVIDER,
EvmEntropyContract,
} from "../src/core/contracts/evm";
import {
DeploymentType,
getDefaultDeploymentConfig,
toDeploymentType,
toPrivateKey,
} from "../src";
} from "../src/core/base";
import {
COMMON_DEPLOY_OPTIONS,
deployIfNotCached,
Expand Down
18 changes: 9 additions & 9 deletions contract_manager/scripts/deploy_evm_pricefeed_contracts.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { EvmChain } from "../src/chains";
import { DefaultStore } from "../src/store";
import {
DeploymentType,
EvmPriceFeedContract,
getDefaultDeploymentConfig,
toDeploymentType,
toPrivateKey,
} from "../src";
import {
COMMON_DEPLOY_OPTIONS,
deployIfNotCached,
Expand All @@ -17,6 +8,15 @@ import {
BaseDeployConfig,
} from "./common";
import { HermesClient } from "@pythnetwork/hermes-client";
import {
DeploymentType,
getDefaultDeploymentConfig,
toDeploymentType,
toPrivateKey,
} from "../src/core/base";
import { EvmChain } from "../src/core/chains";
import { EvmPriceFeedContract } from "../src/core/contracts";
import { DefaultStore } from "../src/node/utils/store";

interface DeploymentConfig extends BaseDeployConfig {
type: DeploymentType;
Expand Down
22 changes: 12 additions & 10 deletions contract_manager/scripts/deploy_evm_pulse_contracts.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { EvmChain } from "../src/chains";
import { DefaultStore } from "../src/store";
import {
DeploymentType,
toDeploymentType,
toPrivateKey,
EvmPulseContract,
PULSE_DEFAULT_PROVIDER,
PULSE_DEFAULT_KEEPER,
} from "../src";
import {
COMMON_DEPLOY_OPTIONS,
deployIfNotCached,
Expand All @@ -21,6 +11,18 @@ import {
} from "./common";
import fs from "fs";
import path from "path";
import {
DeploymentType,
toDeploymentType,
toPrivateKey,
} from "../src/core/base";
import { EvmChain } from "../src/core/chains";
import {
PULSE_DEFAULT_PROVIDER,
PULSE_DEFAULT_KEEPER,
EvmPulseContract,
} from "../src/core/contracts";
import { DefaultStore } from "../src/node/utils/store";

interface DeploymentConfig extends BaseDeployConfig {
type: DeploymentType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { DefaultStore, EvmChain, loadHotWallet } from "../src";
import { EvmChain } from "../src/core/chains";
import { loadHotWallet } from "../src/node/utils/governance";
import { DefaultStore } from "../src/node/utils/store";

const parser = yargs(hideBin(process.argv))
.usage(
Expand Down
4 changes: 3 additions & 1 deletion contract_manager/scripts/entropy_debug_reveal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { DefaultStore, EvmChain, toPrivateKey } from "../src";
import { COMMON_DEPLOY_OPTIONS, findEntropyContract } from "./common";
import { toPrivateKey } from "../src/core/base";
import { EvmChain } from "../src/core/chains";
import { DefaultStore } from "../src/node/utils/store";

const parser = yargs(hideBin(process.argv))
.usage(
Expand Down
10 changes: 5 additions & 5 deletions contract_manager/scripts/execute_vaas.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { DefaultStore } from "../src/store";
import { SubmittedWormholeMessage, Vault } from "../src/governance";
import { parseVaa } from "@certusone/wormhole-sdk";
import { decodeGovernancePayload } from "@pythnetwork/xc-admin-common";
import { executeVaa } from "../src/executor";
import { toPrivateKey } from "../src";

import { COMMON_DEPLOY_OPTIONS } from "./common";
import { Vault } from "../src/node/utils/governance";
import { toPrivateKey } from "../src/core/base";
import { SubmittedWormholeMessage } from "../src/node/utils/governance";
import { executeVaa } from "../src/node/utils/executor";
import { DefaultStore } from "../src/node/utils/store";

const parser = yargs(hideBin(process.argv))
.usage(
Expand Down
3 changes: 2 additions & 1 deletion contract_manager/scripts/fetch_account_balance.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { DefaultStore, PrivateKey, toPrivateKey } from "../src";
import { PrivateKey, toPrivateKey } from "../src/core/base";
import { DefaultStore } from "../src/node/utils/store";

const parser = yargs(hideBin(process.argv))
.usage("Usage: $0 --private-key <private-key> [--chain <chain>]")
Expand Down
4 changes: 2 additions & 2 deletions contract_manager/scripts/fetch_fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { hideBin } from "yargs/helpers";
import {
AptosPriceFeedContract,
CosmWasmPriceFeedContract,
DefaultStore,
EvmPriceFeedContract,
TonPriceFeedContract,
} from "../src";
} from "../src/core/contracts";
import { DefaultStore } from "../src/node/utils/store";

const parser = yargs(hideBin(process.argv))
.usage("Usage: $0")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"chainName": "aurora",
"fee": 3,
"exponent": 12
},
{
"chainName": "avalanche",
"fee": 25,
"exponent": 13
},
{
"chainName": "conflux_espace",
"fee": 1,
"exponent": 17
},
{
"chainName": "cronos",
"fee": 6,
"exponent": 16
},
{
"chainName": "meter",
"fee": 2,
"exponent": 16
},
{
"chainName": "ronin",
"fee": 1,
"exponent": 15
},
{
"chainName": "sei_evm_mainnet",
"fee": 1,
"exponent": 16
},
{
"chainName": "shimmer",
"fee": 1,
"exponent": 18
}
]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { DefaultStore, loadHotWallet } from "../src";
import { readFileSync } from "fs";
import { parse } from "yaml";
import { DefaultStore } from "../src/node/utils/store";
import { loadHotWallet } from "../src/node/utils/governance";

const parser = yargs(hideBin(process.argv))
.usage("Usage: $0 --config <path/to/config.yaml>")
.usage("Usage: $0 --config <path/to/config.json>")
.options({
"config-path": {
type: "string",
Expand All @@ -31,7 +30,7 @@ async function main() {
vault: vaultId,
} = await parser.argv;

const config = parse(readFileSync(configPath, "utf8"));
const config = await import(configPath, { assert: { type: "json" } });

const updatePayloads: Buffer[] = [];
for (const setFeeEntry of config) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { DefaultStore, loadHotWallet } from "../src";
import { NearChain } from "../src/chains";
import { DefaultStore } from "../src/node/utils/store";
import { loadHotWallet } from "../src/node/utils/governance";
import { NearChain } from "../src/core/chains";

const parser = yargs(hideBin(process.argv))
.usage(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { DefaultStore, loadHotWallet } from "../src";
import { TonChain } from "../src/chains";
import { DefaultStore } from "../src/node/utils/store";
import { loadHotWallet } from "../src/node/utils/governance";
import { TonChain } from "../src/core/chains";
import { CHAINS, toChainName } from "@pythnetwork/xc-admin-common";
import fs from "fs";
import path from "path";
Expand Down
2 changes: 1 addition & 1 deletion contract_manager/scripts/get_entropy_registration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { DefaultStore } from "../src";
import { DefaultStore } from "../src/node/utils/store";

function deserializeCommitmentMetadata(data: Buffer) {
const seed = Uint8Array.from(data.subarray(0, 32));
Expand Down
4 changes: 3 additions & 1 deletion contract_manager/scripts/latency_entropy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { DefaultStore, EvmChain, toPrivateKey } from "../src";
import { DefaultStore } from "../src/node/utils/store";
import { EvmChain } from "../src/core/chains";
import { toPrivateKey } from "../src/core/base";
import { COMMON_DEPLOY_OPTIONS, findEntropyContract } from "./common";

const parser = yargs(hideBin(process.argv))
Expand Down
Loading
Loading