Skip to content
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

Rework governance/ update admin-module NTRN-70 sdk47 #196

Merged
merged 7 commits into from
Sep 7, 2023
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
8 changes: 4 additions & 4 deletions gen-proto-ibc-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ rm -r ./proto-thirdparty-tmp
rm -rf ./ibc-go

git clone [email protected]:cosmos/ibc-go.git
cd ibc-go && git checkout v4.3.0 && cd ../
cd ibc-go && git checkout v7.2.0 && cd proto && buf export . --output=../../proto-thirdparty-tmp && cd ../..

git clone [email protected]:Ethernal-Tech/admin-module.git
git clone [email protected]:neutron-org/admin-module.git
cd admin-module && git checkout feat/admin-module-sdk47 && cd proto && buf export . --output=../../proto-thirdparty-tmp && cd ../..

cp -r ibc-go/proto ./proto
cp -r ibc-go/third_party/proto ./proto-thirdparty-tmp
mv ./proto-thirdparty-tmp/tendermint ./proto/
cp -r ./admin-module/proto/adminmodule ./proto/
cp -r ./admin-module/proto/cosmos ./proto/

proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
proto_files=()
Expand Down
93,436 changes: 49,240 additions & 44,196 deletions src/generated/ibc/proto.cjs

Large diffs are not rendered by default.

27,992 changes: 15,001 additions & 12,991 deletions src/generated/ibc/proto.d.ts

Large diffs are not rendered by default.

93,436 changes: 49,240 additions & 44,196 deletions src/generated/ibc/proto.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/helpers/cosmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const IBC_USDC_DENOM = process.env.IBC_USDC_DENOM || 'uibcusdc';
export const COSMOS_DENOM = process.env.COSMOS_DENOM || 'uatom';
export const IBC_RELAYER_NEUTRON_ADDRESS =
'neutron1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u';
export const ADMIN_MODULE_ADDRESS =
'neutron1hxskfdxpp5hqgtjj6am6nkjefhfzj359x0ar3z';

// BalancesResponse is the response model for the bank balances query.
type BalancesResponse = {
Expand Down Expand Up @@ -90,6 +92,10 @@ cosmosclient.codec.register(
'/cosmos.adminmodule.adminmodule.MsgSubmitProposal',
adminmodule.MsgSubmitProposal,
);
cosmosclient.codec.register(
'/cosmos.adminmodule.adminmodule.MsgSubmitProposalLegacy',
adminmodule.MsgSubmitProposalLegacy,
);
cosmosclient.codec.register(
'/ibc.lightclients.tendermint.v1.ClientState',
ibcProto.lightclients.tendermint.v1.ClientState,
Expand Down Expand Up @@ -700,7 +706,7 @@ export class WalletWrapper {
mode: cosmosclient.rest.tx.BroadcastTxMode = cosmosclient.rest.tx
.BroadcastTxMode.Sync,
): Promise<BroadcastTx200ResponseTxResponse> {
const msg = new adminmodule.MsgSubmitProposal({
const msg = new adminmodule.MsgSubmitProposalLegacy({
content: cosmosclient.codec.instanceToProtoAny(
new cosmosclient.proto.cosmos.params.v1beta1.ParameterChangeProposal({
title: 'mock',
Expand Down
91 changes: 77 additions & 14 deletions src/helpers/dao.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from 'axios';
import {
ADMIN_MODULE_ADDRESS,
CosmosWrapper,
createBankMessage,
getEventAttribute,
Expand All @@ -22,6 +23,7 @@ import {
clientUpdateProposal,
paramChangeProposal,
ParamChangeProposalInfo,
pinCodesCustomAutrhorityProposal,
pinCodesProposal,
removeSchedule,
SendProposalInfo,
Expand Down Expand Up @@ -828,14 +830,16 @@ export class DaoMember {
custom: {
submit_admin_proposal: {
admin_proposal: {
software_upgrade_proposal: {
title,
description,
plan: {
name,
height,
info,
},
proposal_execute_message: {
message: JSON.stringify({
'@type': '/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade',
authority: ADMIN_MODULE_ADDRESS,
plan: {
name,
height,
info,
},
}),
},
},
},
Expand All @@ -861,9 +865,41 @@ export class DaoMember {
custom: {
submit_admin_proposal: {
admin_proposal: {
cancel_software_upgrade_proposal: {
title,
description,
proposal_execute_message: {
message: JSON.stringify({
'@type': '/cosmos.upgrade.v1beta1.MsgCancelUpgrade',
authority: 'neutron1hxskfdxpp5hqgtjj6am6nkjefhfzj359x0ar3z',
}),
},
},
},
},
};
return await this.submitSingleChoiceProposal(
title,
description,
[message],
deposit,
);
}
/**
* submitCancelSoftwareUpgradeProposal creates proposal.
*/
async submitBankUpdateParamsProposal(
title: string,
description: string,
deposit: string,
): Promise<number> {
const message = {
custom: {
submit_admin_proposal: {
admin_proposal: {
proposal_execute_message: {
message: JSON.stringify({
'@type': '/cosmos.bank.v1beta1.MsgUpdateParams',
authority: ADMIN_MODULE_ADDRESS,
params: { default_send_enabled: false },
}),
},
},
},
Expand Down Expand Up @@ -1123,6 +1159,32 @@ export class DaoMember {
);
}

/**
* submitPinCodesCustomAuthorityProposal creates proposal which pins given code ids to wasmvm.
*/
async submitPinCodesCustomAuthorityProposal(
title: string,
description: string,
codesIds: number[],
amount: string,
authority: string,
): Promise<number> {
const message = pinCodesCustomAutrhorityProposal(
{
title,
description,
codes_ids: codesIds,
},
authority,
);
return await this.submitSingleChoiceProposal(
title,
description,
[message],
amount,
);
}

/**
* submitUnpinCodesProposal creates proposal which unpins given code ids to wasmvm.
*/
Expand Down Expand Up @@ -1205,13 +1267,13 @@ export class DaoMember {
async submitUpdateAdminProposal(
title: string,
description: string,
sender: string,
contract: string,
newAdmin: string,
amount: string,
): Promise<number> {
const message = updateAdminProposal({
title,
description,
sender,
contract,
new_admin: newAdmin,
});
Expand All @@ -1229,10 +1291,11 @@ export class DaoMember {
async submitClearAdminProposal(
title: string,
description: string,
sender: string,
contract: string,
amount: string,
): Promise<number> {
const message = clearAdminProposal({ title, description, contract });
const message = clearAdminProposal({ sender, contract });
return await this.submitSingleChoiceProposal(
title,
description,
Expand Down
68 changes: 47 additions & 21 deletions src/helpers/proposal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { google } from '../generated/proto';
import Any = google.protobuf.Any;
import { ADMIN_MODULE_ADDRESS } from './cosmos';

export type ParamChangeProposalInfo = {
title: string;
Expand All @@ -16,15 +17,13 @@ export type PinCodesInfo = {
};

export type UpdateAdmin = {
title: string;
description: string;
sender: string;
contract: string;
new_admin: string;
};

export type ClearAdmin = {
title: string;
description: string;
sender: string;
contract: string;
};

Expand Down Expand Up @@ -146,10 +145,31 @@ export const pinCodesProposal = (info: PinCodesInfo): any => ({
custom: {
submit_admin_proposal: {
admin_proposal: {
pin_codes_proposal: {
title: info.title,
description: info.description,
code_ids: info.codes_ids,
proposal_execute_message: {
message: JSON.stringify({
'@type': '/cosmwasm.wasm.v1.MsgPinCodes',
authority: ADMIN_MODULE_ADDRESS,
code_ids: info.codes_ids,
}),
},
},
},
},
});

export const pinCodesCustomAutrhorityProposal = (
info: PinCodesInfo,
authority: string,
): any => ({
custom: {
submit_admin_proposal: {
admin_proposal: {
proposal_execute_message: {
message: JSON.stringify({
'@type': '/cosmwasm.wasm.v1.MsgPinCodes',
authority: authority,
code_ids: info.codes_ids,
}),
},
},
},
Expand All @@ -160,10 +180,12 @@ export const unpinCodesProposal = (info: PinCodesInfo): any => ({
custom: {
submit_admin_proposal: {
admin_proposal: {
unpin_codes_proposal: {
title: info.title,
description: info.description,
code_ids: info.codes_ids,
proposal_execute_message: {
message: JSON.stringify({
'@type': '/cosmwasm.wasm.v1.MsgUnpinCodes',
authority: ADMIN_MODULE_ADDRESS,
code_ids: info.codes_ids,
}),
},
},
},
Expand All @@ -174,11 +196,13 @@ export const updateAdminProposal = (info: UpdateAdmin): any => ({
custom: {
submit_admin_proposal: {
admin_proposal: {
update_admin_proposal: {
title: info.title,
description: info.description,
contract: info.contract,
new_admin: info.new_admin,
proposal_execute_message: {
message: JSON.stringify({
'@type': '/cosmwasm.wasm.v1.MsgUpdateAdmin',
sender: info.sender,
contract: info.contract,
new_admin: info.new_admin,
}),
},
},
},
Expand All @@ -189,10 +213,12 @@ export const clearAdminProposal = (info: ClearAdmin): any => ({
custom: {
submit_admin_proposal: {
admin_proposal: {
clear_admin_proposal: {
title: info.title,
description: info.description,
contract: info.contract,
proposal_execute_message: {
message: JSON.stringify({
'@type': '/cosmwasm.wasm.v1.MsgClearAdmin',
sender: info.sender,
contract: info.contract,
}),
},
},
},
Expand Down
Loading