Skip to content

Commit

Permalink
fix: changed the target submodule repo to use the latest bot version
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Feb 14, 2024
1 parent b556272 commit d002b0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
url = https://github.com/Uniswap/permit2
[submodule "lib/ubiquibot"]
path = lib/ubiquibot
url = https://github.com/ubiquity/ubiquibot
url = https://github.com/pavlovcik/ubiquibot
branch = refactor/move-to-delegated-compute
shallow = true
21 changes: 9 additions & 12 deletions static/scripts/onboarding/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { ethers } from "ethers";
import { parseUnits } from "ethers/lib/utils";
import _sodium from "libsodium-wrappers";
import YAML from "yaml";
import { DefaultConfig } from "../../../lib/ubiquibot/src/configs/ubiquibot-config-default";
import { MergedConfig } from "../../../lib/ubiquibot/src/types";
import { BotConfig } from "../../../lib/ubiquibot/src/types/configuration-types";
import { erc20Abi } from "../rewards/abis/erc20Abi";
import { getNetworkName, NetworkIds, Tokens } from "../rewards/constants";

Expand All @@ -29,14 +28,12 @@ const REPO_NAME = "ubiquibot-config";
const DEFAULT_REPO = "ubiquibot";
const KEY_PATH = ".github/ubiquibot-config.yml";
const DEFAULT_PATH = "ubiquibot-config-default.json";
const PRIVATE_ENCRYPTED_KEY_NAME = "privateKeyEncrypted";
const EVM_NETWORK_KEY_NAME = "evmNetworkId";
const KEY_PREFIX = "HSK_";
const X25519_KEY = "5ghIlfGjz_ChcYlBDOG7dzmgAgBPuTahpvTMBipSH00";

let encryptedValue = "";

let defaultConf = DefaultConfig
let defaultConf: BotConfig;

export const parseYAML = async <T>(data: string | undefined) => {
if (!data) return undefined
Expand Down Expand Up @@ -148,8 +145,8 @@ const sodiumEncryptedSeal = async (publicKey: string, secret: string) => {
const binsec = sodium.from_string(secret);
const encBytes = sodium.crypto_box_seal(binsec, binkey);
const output = sodium.to_base64(encBytes, sodium.base64_variants.URLSAFE_NO_PADDING);
defaultConf[PRIVATE_ENCRYPTED_KEY_NAME] = output;
defaultConf[EVM_NETWORK_KEY_NAME] = Number(chainIdSelect.value);
defaultConf["keys"]["evmPrivateEncrypted"] = output;
defaultConf["payments"]["evmNetworkId"] = Number(chainIdSelect.value);
outKey.value = YAMLStringify(defaultConf);
outKey.style.height = getTextBox(outKey.value);
encryptedValue = output;
Expand Down Expand Up @@ -224,9 +221,9 @@ const setConfig = async () => {
const conf = await getConf();

const updatedConf = defaultConf;
const parsedConf = await parseYAML<MergedConfig>(conf);
updatedConf[PRIVATE_ENCRYPTED_KEY_NAME] = encryptedValue;
updatedConf[EVM_NETWORK_KEY_NAME] = Number(chainIdSelect.value);
const parsedConf = await parseYAML<BotConfig>(conf);
updatedConf["keys"]["evmPrivateEncrypted"] = encryptedValue;
updatedConf["payments"]["evmNetworkId"] = Number(chainIdSelect.value);

// combine configs (default + remote org wide)
const combinedConf = Object.assign(updatedConf, parsedConf);
Expand Down Expand Up @@ -474,12 +471,12 @@ const init = async () => {
let conf = await getConf(true);
if (conf !== undefined) {
try {
const parsedConf = JSON.parse(conf) as MergedConfig;
const parsedConf = JSON.parse(conf) as BotConfig;
if (!parsedConf) {
throw new Error("Configuration could not be parsed!")
}
defaultConf = parsedConf;
defaultConf[PRIVATE_ENCRYPTED_KEY_NAME] = "";
defaultConf["keys"]["evmPrivateEncrypted"] = "";
setInputListeners();

setBtn.addEventListener("click", async () => {
Expand Down

0 comments on commit d002b0a

Please sign in to comment.