Skip to content

Commit 53cac41

Browse files
committed
refactor: convert yaml to json
1 parent 604e64a commit 53cac41

File tree

66 files changed

+4124
-2693
lines changed

Some content is hidden

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

66 files changed

+4124
-2693
lines changed

contract_manager/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@
7171
"typescript": "catalog:",
7272
"viem": "^2.23.5",
7373
"web3": "^1.8.2",
74-
"web3-eth-contract": "^1.8.2",
75-
"yaml": "^2.1.1"
74+
"web3-eth-contract": "^1.8.2"
7675
},
7776
"devDependencies": {
7877
"@types/web3": "^1.2.2",

contract_manager/scripts/generate_governance_set_fee_payload.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import { hideBin } from "yargs/helpers";
33
import { DefaultStore } from "../src/node/utils/store";
44
import { loadHotWallet } from "../src/node/utils/governance";
55
import { readFileSync } from "fs";
6-
import { parse } from "yaml";
76

87
const parser = yargs(hideBin(process.argv))
9-
.usage("Usage: $0 --config <path/to/config.yaml>")
8+
.usage("Usage: $0 --config <path/to/config.json>")
109
.options({
1110
"config-path": {
1211
type: "string",
@@ -32,7 +31,7 @@ async function main() {
3231
vault: vaultId,
3332
} = await parser.argv;
3433

35-
const config = parse(readFileSync(configPath, "utf8"));
34+
const config = JSON.parse(readFileSync(configPath, "utf8"));
3635

3736
const updatePayloads: Buffer[] = [];
3837
for (const setFeeEntry of config) {

contract_manager/src/node/utils/store.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import {
3333
} from "../../core/contracts";
3434
import { Token } from "../../core/token";
3535
import { PriceFeedContract, Storable } from "../../core/base";
36-
import { parse, stringify } from "yaml";
3736
import { readdirSync, readFileSync, statSync, writeFileSync } from "fs";
3837
import { Vault } from "./governance";
3938
import {
@@ -63,10 +62,10 @@ export class Store {
6362
}
6463

6564
static serialize(obj: Storable) {
66-
return stringify([obj.toJson()]);
65+
return JSON.stringify([obj.toJson()], null, 2);
6766
}
6867

69-
getYamlFiles(path: string) {
68+
getJsonFiles(path: string) {
7069
const walk = function (dir: string) {
7170
let results: string[] = [];
7271
const list = readdirSync(dir);
@@ -83,7 +82,7 @@ export class Store {
8382
});
8483
return results;
8584
};
86-
return walk(path).filter((file) => file.endsWith(".yaml"));
85+
return walk(path).filter((file) => file.endsWith(".json"));
8786
}
8887

8988
loadAllChains() {
@@ -100,8 +99,8 @@ export class Store {
10099
[IotaChain.type]: IotaChain,
101100
};
102101

103-
this.getYamlFiles(`${this.path}/chains/`).forEach((yamlFile) => {
104-
const parsedArray = parse(readFileSync(yamlFile, "utf-8"));
102+
this.getJsonFiles(`${this.path}/chains/`).forEach((jsonFile) => {
103+
const parsedArray = JSON.parse(readFileSync(jsonFile, "utf-8"));
105104
for (const parsed of parsedArray) {
106105
if (allChainClasses[parsed.type] === undefined) {
107106
throw new Error(
@@ -129,8 +128,12 @@ export class Store {
129128
}
130129
for (const [type, contracts] of Object.entries(contractsByType)) {
131130
writeFileSync(
132-
`${this.path}/contracts/${type}s.yaml`,
133-
stringify(contracts.map((c) => c.toJson())),
131+
`${this.path}/contracts/${type}s.json`,
132+
JSON.stringify(
133+
contracts.map((c) => c.toJson()),
134+
null,
135+
2,
136+
),
134137
);
135138
}
136139
}
@@ -145,8 +148,12 @@ export class Store {
145148
}
146149
for (const [type, chains] of Object.entries(chainsByType)) {
147150
writeFileSync(
148-
`${this.path}/chains/${type}s.yaml`,
149-
stringify(chains.map((c) => c.toJson())),
151+
`${this.path}/chains/${type}s.json`,
152+
JSON.stringify(
153+
chains.map((c) => c.toJson()),
154+
null,
155+
2,
156+
),
150157
);
151158
}
152159
}
@@ -174,8 +181,8 @@ export class Store {
174181
[IotaPriceFeedContract.type]: IotaPriceFeedContract,
175182
[IotaWormholeContract.type]: IotaWormholeContract,
176183
};
177-
this.getYamlFiles(`${this.path}/contracts/`).forEach((yamlFile) => {
178-
const parsedArray = parse(readFileSync(yamlFile, "utf-8"));
184+
this.getJsonFiles(`${this.path}/contracts/`).forEach((jsonFile) => {
185+
const parsedArray = JSON.parse(readFileSync(jsonFile, "utf-8"));
179186
for (const parsed of parsedArray) {
180187
if (allContractClasses[parsed.type] === undefined) return;
181188
if (!this.chains[parsed.chain])
@@ -207,8 +214,8 @@ export class Store {
207214
}
208215

209216
loadAllTokens() {
210-
this.getYamlFiles(`${this.path}/tokens/`).forEach((yamlFile) => {
211-
const parsedArray = parse(readFileSync(yamlFile, "utf-8"));
217+
this.getJsonFiles(`${this.path}/tokens/`).forEach((jsonFile) => {
218+
const parsedArray = JSON.parse(readFileSync(jsonFile, "utf-8"));
212219
for (const parsed of parsedArray) {
213220
if (parsed.type !== Token.type) return;
214221

@@ -221,8 +228,8 @@ export class Store {
221228
}
222229

223230
loadAllVaults() {
224-
this.getYamlFiles(`${this.path}/vaults/`).forEach((yamlFile) => {
225-
const parsedArray = parse(readFileSync(yamlFile, "utf-8"));
231+
this.getJsonFiles(`${this.path}/vaults/`).forEach((jsonFile) => {
232+
const parsedArray = JSON.parse(readFileSync(jsonFile, "utf-8"));
226233
for (const parsed of parsedArray) {
227234
if (parsed.type !== Vault.type) return;
228235

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[
2+
{
3+
"id": "aptos_testnet",
4+
"wormholeChainName": "aptos",
5+
"mainnet": false,
6+
"rpcUrl": "https://fullnode.testnet.aptoslabs.com/v1",
7+
"type": "AptosChain"
8+
},
9+
{
10+
"id": "aptos_mainnet",
11+
"wormholeChainName": "aptos",
12+
"mainnet": true,
13+
"rpcUrl": "https://fullnode.mainnet.aptoslabs.com/v1",
14+
"type": "AptosChain",
15+
"nativeToken": "APT"
16+
},
17+
{
18+
"id": "movement_m1_devnet",
19+
"wormholeChainName": "movement_m1_devnet",
20+
"mainnet": false,
21+
"rpcUrl": "https://devnet.m1.movementlabs.xyz/v1",
22+
"type": "AptosChain"
23+
},
24+
{
25+
"id": "movement_suzuka_testnet",
26+
"wormholeChainName": "movement_suzuka_testnet",
27+
"mainnet": false,
28+
"rpcUrl": "https://aptos.testnet.suzuka.movementlabs.xyz/v1",
29+
"type": "AptosChain"
30+
},
31+
{
32+
"id": "movement_porto_testnet",
33+
"wormholeChainName": "movement_porto_testnet",
34+
"mainnet": false,
35+
"rpcUrl": "https://aptos.testnet.porto.movementlabs.xyz/v1",
36+
"type": "AptosChain"
37+
},
38+
{
39+
"id": "movement_bardock_testnet",
40+
"wormholeChainName": "movement_bardock_testnet",
41+
"mainnet": false,
42+
"rpcUrl": "https://aptos.testnet.bardock.movementlabs.xyz/v1",
43+
"type": "AptosChain"
44+
},
45+
{
46+
"id": "movement_mainnet",
47+
"wormholeChainName": "movement_mainnet",
48+
"mainnet": true,
49+
"rpcUrl": "https://mainnet.movementnetwork.xyz/v1",
50+
"type": "AptosChain"
51+
}
52+
]

contract_manager/store/chains/AptosChains.yaml

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
[
2+
{
3+
"endpoint": "https://sentry.tm.injective.network:443",
4+
"id": "injective",
5+
"wormholeChainName": "injective",
6+
"mainnet": true,
7+
"type": "CosmWasmChain",
8+
"feeDenom": "inj"
9+
},
10+
{
11+
"endpoint": "https://rpc.atlantic-2.seinetwork.io/",
12+
"id": "sei_testnet_atlantic_2",
13+
"wormholeChainName": "sei_testnet_atlantic_2",
14+
"mainnet": false,
15+
"gasPrice": "0.10",
16+
"prefix": "sei",
17+
"feeDenom": "usei",
18+
"type": "CosmWasmChain"
19+
},
20+
{
21+
"endpoint": "https://rpc.osmosis.zone:443",
22+
"id": "osmosis",
23+
"wormholeChainName": "osmosis",
24+
"mainnet": true,
25+
"gasPrice": "0.025",
26+
"prefix": "osmo",
27+
"feeDenom": "uosmo",
28+
"type": "CosmWasmChain"
29+
},
30+
{
31+
"endpoint": "https://testnet.sentry.tm.injective.network:443",
32+
"id": "injective_testnet",
33+
"wormholeChainName": "injective_testnet",
34+
"mainnet": false,
35+
"feeDenom": "inj",
36+
"type": "CosmWasmChain"
37+
},
38+
{
39+
"endpoint": "https://rpc-palvus.pion-1.ntrn.tech/",
40+
"id": "neutron_testnet_pion_1",
41+
"wormholeChainName": "neutron_testnet_pion_1",
42+
"mainnet": false,
43+
"gasPrice": "0.05",
44+
"prefix": "neutron",
45+
"feeDenom": "untrn",
46+
"type": "CosmWasmChain"
47+
},
48+
{
49+
"endpoint": "https://rpc.osmotest5.osmosis.zone/",
50+
"id": "osmosis_testnet_5",
51+
"wormholeChainName": "osmosis_testnet_5",
52+
"mainnet": false,
53+
"gasPrice": "0.025",
54+
"prefix": "osmo",
55+
"feeDenom": "uosmo",
56+
"type": "CosmWasmChain"
57+
},
58+
{
59+
"endpoint": "https://sei-rpc.polkachu.com",
60+
"id": "sei_pacific_1",
61+
"wormholeChainName": "sei_pacific_1",
62+
"mainnet": true,
63+
"gasPrice": "0.025",
64+
"prefix": "sei",
65+
"feeDenom": "usei",
66+
"type": "CosmWasmChain"
67+
},
68+
{
69+
"endpoint": "https://rpc-kralum.neutron-1.neutron.org",
70+
"id": "neutron",
71+
"wormholeChainName": "neutron",
72+
"mainnet": true,
73+
"gasPrice": "0.025",
74+
"prefix": "neutron",
75+
"feeDenom": "untrn",
76+
"type": "CosmWasmChain"
77+
},
78+
{
79+
"endpoint": "https://juno-testnet-rpc.polkachu.com/",
80+
"id": "juno_testnet",
81+
"wormholeChainName": "juno_testnet",
82+
"mainnet": false,
83+
"gasPrice": "0.025",
84+
"prefix": "juno",
85+
"feeDenom": "ujunox",
86+
"type": "CosmWasmChain"
87+
},
88+
{
89+
"endpoint": "http://18.199.53.161:26657",
90+
"id": "rol_testnet",
91+
"wormholeChainName": "rol_testnet",
92+
"mainnet": false,
93+
"gasPrice": "0.025",
94+
"prefix": "rol",
95+
"feeDenom": "urax",
96+
"type": "CosmWasmChain"
97+
},
98+
{
99+
"endpoint": "https://rpc.xion-testnet-2.burnt.com:443",
100+
"id": "xion_testnet_2",
101+
"wormholeChainName": "xion_testnet",
102+
"mainnet": false,
103+
"gasPrice": "0.025",
104+
"prefix": "xion",
105+
"feeDenom": "uxion",
106+
"type": "CosmWasmChain"
107+
},
108+
{
109+
"endpoint": "https://rpc.xion-mainnet-1.burnt.com:443",
110+
"id": "xion",
111+
"wormholeChainName": "xion",
112+
"mainnet": true,
113+
"gasPrice": "0.025",
114+
"prefix": "xion",
115+
"feeDenom": "uxion",
116+
"type": "CosmWasmChain"
117+
}
118+
]

0 commit comments

Comments
 (0)