From 7f3e8c545fa239529f86b864bc57ad8d76a6d3c4 Mon Sep 17 00:00:00 2001 From: byeongsu-hong Date: Fri, 1 Mar 2024 21:49:31 +0900 Subject: [PATCH] feat: add igp deployer --- script/deploy/igp.ts | 57 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 script/deploy/igp.ts diff --git a/script/deploy/igp.ts b/script/deploy/igp.ts new file mode 100644 index 00000000..47ee85d7 --- /dev/null +++ b/script/deploy/igp.ts @@ -0,0 +1,57 @@ +import { Client, IgpHookType, getNetwork } from "../shared/config"; +import { Context, ContextHook } from "../shared/context"; +import { deployContract, executeMultiMsg } from "../shared/contract"; + +export const deployIgp = async ( + networkId: string, + ctx: Context, + client: Client, + igpType: IgpHookType +): Promise => { + const { hrp, gas } = getNetwork(networkId); + + // init igp + const igp = await deployContract(ctx, client, "hpl_igp", { + hrp, + owner: igpType.owner === "" ? client.signer : igpType.owner, + gas_token: igpType.token || gas.denom, + beneficiary: client.signer, + default_gas_usage: igpType.default_gas_usage.toString(), + }); + + // init igp oracle + + const igpOracle = await deployContract(ctx, client, "hpl_igp_oracle", { + owner: client.signer, + }); + + await executeMultiMsg(client, [ + { + contract: igpOracle, + msg: { + set_remote_gas_data_configs: { + configs: Object.entries(igpType.configs).map(([domain, v]) => ({ + remote_domain: Number(domain), + token_exchange_rate: v.exchange_rate.toString(), + gas_price: v.gas_price.toString(), + })), + }, + }, + }, + { + contract: igp, + msg: { + router: { + set_routes: { + set: Object.keys(igpType.configs).map((domain) => ({ + domain: Number(domain), + route: igpOracle.address, + })), + }, + }, + }, + }, + ]); + + return { ...igp, oracle: igpOracle }; +};