Skip to content

Commit fbcb8a1

Browse files
author
Dev Kalra
authored
[cosmwasm] chain ids for pyth mainnet, pyth testnet stable, and pyth testnet edge feeds (#822)
* add chainids * chain ids * wormhole, instantiate, and test * update chain structure * update test script * update chain id guidelines * if brackets * correct test arguments
1 parent 4f67343 commit fbcb8a1

File tree

51 files changed

+1258
-595
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1258
-595
lines changed

governance/xc_governance_sdk_js/src/chains.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
import { CHAINS as WORMHOLE_CHAINS } from "@certusone/wormhole-sdk";
22

33
export { CHAINS as WORMHOLE_CHAINS } from "@certusone/wormhole-sdk";
4+
// GUIDELINES to add a chain
5+
// PYTH will have:
6+
// 1. Mainnet Deployment - which will have pyth mainnet governance and data sources
7+
// 2. Testnet Stable Deployment - which will also have pyth mainnet governance and data sources
8+
// 3. Testnet Edge Deployment - which will have pyth testnet governance and data sources.
9+
// Different chains will have different chain ids i.e., mainnet and testnet will have different chain ids.
10+
// Though stable and edge contracts on testnet will share the same chain id. They are governed by different
11+
// sources hence there is no chance of collision.
12+
13+
// If there is already a chain id in wormhole sdk. Use that for Mainnet
14+
// Else add a chain id for mainnet too.
15+
// Add an id for the testnet
16+
// Currently we are deploying this for cosmos chains only. But this will be for all the chains in future.
417
export const RECEIVER_CHAINS = {
518
cronos: 60001,
619
kcc: 60002,
@@ -14,10 +27,18 @@ export const RECEIVER_CHAINS = {
1427
meter: 60010,
1528
mantle: 60011,
1629
conflux_espace: 60012,
17-
sei: 60013,
30+
31+
// for cosmos
32+
injective_testnet: 60013,
1833
osmosis: 60014,
19-
neutron: 60015,
20-
juno: 60016,
34+
osmosis_testnet_4: 60015,
35+
osmosis_testnet_5: 60016,
36+
sei: 60017,
37+
sei_testnet_atlantic_2: 60018,
38+
neutron: 60019,
39+
neutron_testnet_pion_1: 60020,
40+
juno: 60020,
41+
juno_testnet: 60021,
2142
};
2243

2344
// If there is any overlapping value the receiver chain will replace the wormhole

target_chains/cosmwasm/tools/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"node-downloader-helper": "^2.1.7",
2929
"osmojs": "^13.0.0-rc.7-i-alpha",
3030
"rimraf": "^5.0.0",
31-
"yargs": "^17.0.1"
31+
"yargs": "^17.0.1",
32+
"@pythnetwork/price-service-client": "*"
3233
},
3334
"devDependencies": {
3435
"@types/adm-zip": "^0.5.0",

target_chains/cosmwasm/tools/src/chains-manager/chains.ts

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,26 @@ export enum ChainType {
1212
// CHAINNAME{_OPTIONAL-IDENTIFIER}
1313
// ENUM Value should be of the form:
1414
// chainname{_optional-identifier}
15-
export enum ChainIdTestnet {
15+
export enum ChainId {
16+
INJECTIVE_TESTNET = "injective_testnet",
17+
OSMOSIS_TESTNET_4 = "osmosis_testnet_4",
18+
OSMOSIS_TESTNET_5 = "osmosis_testnet_5",
19+
SEI_TESTNET_ATLANTIC_2 = "sei_testnet_atlantic_2",
20+
NEUTRON_TESTNET_PION_1 = "neutron_testnet_pion_1",
21+
JUNO_TESTNET = "juno_testnet",
22+
23+
// Below are mainnet chain ids
1624
INJECTIVE = "injective",
17-
OSMOSIS_4 = "osmosis_4",
18-
OSMOSIS_5 = "osmosis_5",
19-
SEI_ATLANTIC_2 = "sei_atlantic_2",
20-
NEUTRON_PION_1 = "neutron_pion_1",
21-
JUNO = "juno",
25+
OSMOSIS = "osmosis",
2226
}
2327

24-
export const ChainIdsTestnet = Object.values(ChainIdTestnet);
25-
26-
// TODO: ADD MAINNET IDs IN FUTURE
27-
// export enum ChainIdMainnet {
28-
// INJECTIVE = "injective",
29-
// }
28+
export const ChainIds = Object.values(ChainId);
3029

31-
export type ChainConfig =
30+
export type ChainNetworkConfig =
3231
| {
3332
// usually the chain name
3433
// osmosis, injective
35-
chainId: ChainIdTestnet;
34+
chainId: ChainId;
3635
chainType: ChainType.INJECTIVE;
3736

3837
// endpoints to create executor and querier for a particular chain
@@ -42,7 +41,7 @@ export type ChainConfig =
4241
| {
4342
// usually the chain name
4443
// osmosis, injective
45-
chainId: ChainIdTestnet;
44+
chainId: ChainId;
4645
chainType: ChainType.COSMWASM;
4746

4847
// endpoints to create executor and querier for a particular chain
@@ -58,60 +57,76 @@ export type ChainConfig =
5857
gasPrice: string;
5958
};
6059

61-
export const ChainsConfigTestnet: Record<ChainIdTestnet, ChainConfig> = {
62-
[ChainIdTestnet.INJECTIVE]: {
63-
chainId: ChainIdTestnet.INJECTIVE,
60+
export const CHAINS_NETWORK_CONFIG: Record<ChainId, ChainNetworkConfig> = {
61+
[ChainId.INJECTIVE_TESTNET]: {
62+
chainId: ChainId.INJECTIVE_TESTNET,
6463
chainType: ChainType.INJECTIVE,
6564
querierEndpoint: "https://k8s.testnet.tm.injective.network:443",
6665
executorEndpoint: "https://k8s.testnet.chain.grpc-web.injective.network",
6766
},
68-
[ChainIdTestnet.OSMOSIS_5]: {
69-
chainId: ChainIdTestnet.OSMOSIS_5,
67+
[ChainId.OSMOSIS_TESTNET_5]: {
68+
chainId: ChainId.OSMOSIS_TESTNET_5,
7069
chainType: ChainType.COSMWASM,
7170
executorEndpoint: "https://rpc.osmotest5.osmosis.zone/",
7271
querierEndpoint: "https://rpc.osmotest5.osmosis.zone/",
7372
prefix: "osmo",
7473
gasPrice: "0.025uosmo",
7574
},
76-
[ChainIdTestnet.OSMOSIS_4]: {
77-
chainId: ChainIdTestnet.OSMOSIS_4,
75+
[ChainId.OSMOSIS_TESTNET_4]: {
76+
chainId: ChainId.OSMOSIS_TESTNET_4,
7877
chainType: ChainType.COSMWASM,
7978
executorEndpoint: "https://rpc-test.osmosis.zone:443",
8079
querierEndpoint: "https://rpc-test.osmosis.zone:443",
8180
prefix: "osmo",
8281
gasPrice: "0.025uosmo",
8382
},
84-
[ChainIdTestnet.SEI_ATLANTIC_2]: {
85-
chainId: ChainIdTestnet.SEI_ATLANTIC_2,
83+
[ChainId.SEI_TESTNET_ATLANTIC_2]: {
84+
chainId: ChainId.SEI_TESTNET_ATLANTIC_2,
8685
chainType: ChainType.COSMWASM,
8786
executorEndpoint: "https://rpc.atlantic-2.seinetwork.io/",
8887
querierEndpoint: "https://rpc.atlantic-2.seinetwork.io/",
8988
prefix: "sei",
9089
gasPrice: "0.01usei",
9190
},
92-
[ChainIdTestnet.NEUTRON_PION_1]: {
93-
chainId: ChainIdTestnet.NEUTRON_PION_1,
91+
[ChainId.NEUTRON_TESTNET_PION_1]: {
92+
chainId: ChainId.NEUTRON_TESTNET_PION_1,
9493
chainType: ChainType.COSMWASM,
9594
executorEndpoint: "https://rpc.pion.rs-testnet.polypore.xyz/",
9695
querierEndpoint: "https://rpc.pion.rs-testnet.polypore.xyz/",
9796
prefix: "neutron",
9897
gasPrice: "0.025untrn",
9998
},
100-
[ChainIdTestnet.JUNO]: {
101-
chainId: ChainIdTestnet.JUNO,
99+
[ChainId.JUNO_TESTNET]: {
100+
chainId: ChainId.JUNO_TESTNET,
102101
chainType: ChainType.COSMWASM,
103102
executorEndpoint: "https://rpc.uni.junonetwork.io/",
104103
querierEndpoint: "https://rpc.uni.junonetwork.io/",
105104
prefix: "juno",
106105
gasPrice: "0.025ujunox",
107106
},
107+
108+
// Mainnet chains
109+
[ChainId.INJECTIVE]: {
110+
chainId: ChainId.INJECTIVE,
111+
chainType: ChainType.INJECTIVE,
112+
querierEndpoint: "https://k8s.testnet.tm.injective.network:443",
113+
executorEndpoint: "https://k8s.testnet.chain.grpc-web.injective.network",
114+
},
115+
[ChainId.OSMOSIS]: {
116+
chainId: ChainId.OSMOSIS,
117+
chainType: ChainType.COSMWASM,
118+
executorEndpoint: "https://rpc.osmotest5.osmosis.zone/",
119+
querierEndpoint: "https://rpc.osmotest5.osmosis.zone/",
120+
prefix: "osmo",
121+
gasPrice: "0.025uosmo",
122+
},
108123
};
109124

110125
/**
111126
* This method will return an executor for given chainConfig.
112127
*/
113128
export function createExecutorForChain(
114-
chainConfig: ChainConfig,
129+
chainConfig: ChainNetworkConfig,
115130
mnemonic: string
116131
): ChainExecutor {
117132
const chainType = chainConfig.chainType;
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
import { CHAINS } from "@pythnetwork/xc-governance-sdk";
2+
import { ChainId } from "./chains-manager/chains";
3+
import { DeploymentType } from "./helper";
4+
5+
type ChainContractConfig = {
6+
feeDenom: string;
7+
pythArtifactZipName: string;
8+
wormholeChainId: number;
9+
};
10+
11+
export const CHAINS_CONTRACT_CONFIG: Record<ChainId, ChainContractConfig> = {
12+
[ChainId.INJECTIVE_TESTNET]: {
13+
feeDenom: "inj",
14+
pythArtifactZipName: "injective",
15+
wormholeChainId: CHAINS.injective_testnet,
16+
},
17+
[ChainId.OSMOSIS_TESTNET_4]: {
18+
feeDenom: "uosmo",
19+
pythArtifactZipName: "osmosis",
20+
wormholeChainId: CHAINS.osmosis_testnet_4,
21+
},
22+
[ChainId.OSMOSIS_TESTNET_5]: {
23+
feeDenom: "uosmo",
24+
pythArtifactZipName: "osmosis",
25+
wormholeChainId: CHAINS.osmosis_testnet_5,
26+
},
27+
[ChainId.SEI_TESTNET_ATLANTIC_2]: {
28+
feeDenom: "usei",
29+
pythArtifactZipName: "cosmwasm",
30+
wormholeChainId: CHAINS.sei_testnet_atlantic_2,
31+
},
32+
[ChainId.NEUTRON_TESTNET_PION_1]: {
33+
feeDenom: "untrn",
34+
pythArtifactZipName: "cosmwasm",
35+
wormholeChainId: CHAINS.neutron_testnet_pion_1,
36+
},
37+
[ChainId.JUNO_TESTNET]: {
38+
feeDenom: "ujunox",
39+
pythArtifactZipName: "cosmwasm",
40+
wormholeChainId: CHAINS.juno_testnet,
41+
},
42+
43+
// mainnet
44+
[ChainId.INJECTIVE]: {
45+
feeDenom: "inj",
46+
pythArtifactZipName: "injective",
47+
wormholeChainId: CHAINS.injective,
48+
},
49+
[ChainId.OSMOSIS]: {
50+
feeDenom: "uosmo",
51+
pythArtifactZipName: "osmosis",
52+
wormholeChainId: CHAINS.osmosis,
53+
},
54+
};
55+
56+
function getPythSources(deploymentType: DeploymentType) {
57+
if (deploymentType === "stable") {
58+
return {
59+
data_sources: [
60+
{
61+
emitter: Buffer.from(
62+
"6bb14509a612f01fbbc4cffeebd4bbfb492a86df717ebe92eb6df432a3f00a25",
63+
"hex"
64+
).toString("base64"),
65+
chain_id: 1,
66+
},
67+
{
68+
emitter: Buffer.from(
69+
"f8cd23c2ab91237730770bbea08d61005cdda0984348f3f6eecb559638c0bba0",
70+
"hex"
71+
).toString("base64"),
72+
chain_id: 26,
73+
},
74+
],
75+
governance_source: {
76+
emitter: Buffer.from(
77+
"5635979a221c34931e32620b9293a463065555ea71fe97cd6237ade875b12e9e",
78+
"hex"
79+
).toString("base64"),
80+
chain_id: 1,
81+
},
82+
};
83+
}
84+
85+
return {
86+
data_sources: [
87+
{
88+
emitter: Buffer.from(
89+
"f346195ac02f37d60d4db8ffa6ef74cb1be3550047543a4a9ee9acf4d78697b0",
90+
"hex"
91+
).toString("base64"),
92+
chain_id: 1,
93+
},
94+
{
95+
emitter: Buffer.from(
96+
"a27839d641b07743c0cb5f68c51f8cd31d2c0762bec00dc6fcd25433ef1ab5b6",
97+
"hex"
98+
).toString("base64"),
99+
chain_id: 26,
100+
},
101+
],
102+
governance_source: {
103+
emitter: Buffer.from(
104+
"63278d271099bfd491951b3e648f08b1c71631e4a53674ad43e8f9f98068c385",
105+
"hex"
106+
).toString("base64"),
107+
chain_id: 1,
108+
},
109+
};
110+
}
111+
112+
export function getPythConfig({
113+
feeDenom,
114+
wormholeContract,
115+
wormholeChainId,
116+
deploymentType,
117+
}: {
118+
feeDenom: string;
119+
wormholeContract: string;
120+
wormholeChainId: number;
121+
deploymentType: DeploymentType;
122+
}) {
123+
return {
124+
wormhole_contract: wormholeContract,
125+
governance_source_index: 0,
126+
governance_sequence_number: 0,
127+
chain_id: wormholeChainId,
128+
valid_time_period_secs: 60,
129+
fee: {
130+
amount: "1",
131+
denom: feeDenom,
132+
},
133+
...getPythSources(deploymentType),
134+
};
135+
}
136+
137+
interface ReqWormholeConfig {
138+
feeDenom: string;
139+
wormholeChainId: number;
140+
deploymentType: DeploymentType;
141+
}
142+
143+
export function getWormholeConfig({
144+
feeDenom,
145+
wormholeChainId,
146+
deploymentType,
147+
}: ReqWormholeConfig) {
148+
if (deploymentType === "stable") {
149+
return {
150+
chain_id: wormholeChainId,
151+
fee_denom: feeDenom,
152+
gov_chain: 1,
153+
gov_address: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ=",
154+
guardian_set_expirity: 86400,
155+
initial_guardian_set: {
156+
addresses: [{ bytes: "WMw65cCXshPOPIGXnhuflXB0aqU=" }],
157+
expiration_time: 0,
158+
},
159+
};
160+
}
161+
162+
return {
163+
chain_id: wormholeChainId,
164+
fee_denom: feeDenom,
165+
gov_chain: 1,
166+
gov_address: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ=",
167+
guardian_set_expirity: 86400,
168+
initial_guardian_set: {
169+
addresses: [{ bytes: "E5R71IsY5T/a7ud/NHM5Gscnxjg=" }],
170+
expiration_time: 0,
171+
},
172+
};
173+
}

0 commit comments

Comments
 (0)