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

test: e2e gno organization deployer #1304

Merged
merged 35 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e56ac5b
test: e2e test to create dao creation flow
MikaelVallenet Oct 10, 2024
6860ec0
wip: e2e test to create dao creation flow
MikaelVallenet Oct 10, 2024
c04bea2
wip: e2e test handle filling all steps in dao creation form
MikaelVallenet Oct 10, 2024
59680d9
wip: e2e test handle filling all steps in dao creation form
MikaelVallenet Oct 11, 2024
d3f01e3
Merge branch 'main' into e2e-test-dao-creation-gno
MikaelVallenet Oct 11, 2024
83d31c8
wip: e2e test handle filling all steps in dao creation form
MikaelVallenet Oct 14, 2024
f5a55e2
wip: e2e test handle filling all steps in dao creation form
MikaelVallenet Oct 14, 2024
a020752
fix: remove unused std from gno dao realm generation
MikaelVallenet Oct 15, 2024
7c60018
feat: add adena mock deploy pkg function
MikaelVallenet Oct 15, 2024
e4f4b20
fix: finish e2e test organization creation flow on gno
MikaelVallenet Oct 15, 2024
21567e5
chore: refactor project structure by moving all e2e test files into g…
MikaelVallenet Oct 15, 2024
9b8a071
style: run eslint
MikaelVallenet Oct 15, 2024
03f1e7c
revert: useless modification on e2e test
MikaelVallenet Oct 15, 2024
cdc95c3
fix: delete useless pkg comment
MikaelVallenet Oct 15, 2024
c0eb78c
fix: run lint on networks files
MikaelVallenet Oct 15, 2024
2ec5b9e
Merge branch 'main' into e2e-test-dao-creation-gno
MikaelVallenet Oct 15, 2024
c3516ce
fix: delete useless console.log
MikaelVallenet Oct 16, 2024
dcd664e
feat: use enum to handle adena type message value
MikaelVallenet Oct 16, 2024
55176c8
fix: delete mint & burn tori token for common dao
MikaelVallenet Oct 22, 2024
ca2b6f1
Merge branch 'main' into e2e-test-dao-creation-gno
n0izn0iz Oct 29, 2024
b0cf985
fix(dao): remove modboard related code
MikaelVallenet Oct 31, 2024
5093189
Merge branch 'e2e-test-dao-creation-gno' of github.com:TERITORI/terit…
MikaelVallenet Oct 31, 2024
c3899dd
Merge branch 'main' into e2e-test-dao-creation-gno
MikaelVallenet Oct 31, 2024
ff5bca0
fix(gnovm): remove leftover of tori import
MikaelVallenet Oct 31, 2024
5caf06f
feat: add a call to members JSON
MikaelVallenet Oct 31, 2024
ed52b3f
feat: add a call to members JSON
MikaelVallenet Oct 31, 2024
0fa0a0a
fix: remove tori admin handler
MikaelVallenet Oct 31, 2024
4e08f27
chore: run eslint
MikaelVallenet Oct 31, 2024
fce1b40
fix: add a TODO to fix later the groupId
MikaelVallenet Oct 31, 2024
ca673e0
fix: remove groupId
MikaelVallenet Oct 31, 2024
8be6a98
fix: keep only e2e related code
MikaelVallenet Nov 1, 2024
010420e
fix: keep only e2e related code
MikaelVallenet Nov 1, 2024
d9cd564
Merge branch 'main' into e2e-test-dao-creation-gno
MikaelVallenet Nov 1, 2024
958ab53
Merge branch 'main' into e2e-test-dao-creation-gno
n0izn0iz Nov 2, 2024
ac7a8bc
Merge branch 'main' into e2e-test-dao-creation-gno
n0izn0iz Nov 2, 2024
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
File renamed without changes.
35 changes: 35 additions & 0 deletions cypress/e2e/gno/organization-creation.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { connectWallet, resetChain } from "./lib";

describe("Create an organization flow", () => {
it("works", () => {
resetChain();

cy.visit("http://localhost:8081/orgs?network=gno-dev", {
timeout: 300000,
});

connectWallet();

const daoName = "Test Dao";
const handle = "testdao";
const url =
"https://images.unsplash.com/photo-1492571350019-22de08371fd3?fm=jpg&q=60&w=3000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D";
const description = "Test Dao description";

cy.contains("Create Dao").click();

cy.get("input[placeholder='Type organization\\'s name here']").type(
daoName,
);
cy.get("input[placeholder='your_organization']").type(handle);
cy.get("input[placeholder='https://example.com/preview.png']").type(url);
cy.get('[data-testid="organization-description"]').type(description);

cy.contains("Next: Configure voting").click();
cy.contains("Next: Set tokens or members").click();
cy.get('[data-testid="member-settings-next"]').click();
cy.contains("Confirm & Launch the Organization").click();

cy.contains("Get Started", { timeout: 10000 }).should("exist");
});
});
File renamed without changes.
6 changes: 6 additions & 0 deletions networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4526,6 +4526,8 @@
"profilePkgPath": "gno.land/r/demo/profile",
"daoInterfacesPkgPath": "gno.land/p/teritori/dao_interfaces",
"daoCorePkgPath": "gno.land/p/teritori/dao_core",
"daoUtilsPkgPath": "gno.land/p/teritori/dao_utils",
"toriPkgPath": "gno.land/r/teritori/tori",
"nameServiceDefaultImage": "ipfs://bafkreignptjimiu7wuux6mk6uh4hb4odb6ff62ny4bvdokrhes7g67huse",
"gnowebURL": "http://127.0.0.1:8888",
"txIndexerURL": "http://127.0.0.1:8546"
Expand Down Expand Up @@ -4574,6 +4576,8 @@
"daoProposalSinglePkgPath": "gno.land/p/teritori/dao_proposal_single",
"daoInterfacesPkgPath": "gno.land/p/teritori/dao_interfaces",
"daoCorePkgPath": "gno.land/p/teritori/dao_core",
"daoUtilsPkgPath": "gno.land/r/teritori/dao_utils",
"toriPkgPath": "gno.land/r/teritori/tori",
"profilePkgPath": "gno.land/r/demo/profile",
"txIndexerURL": "https://indexer.portal-loop.gno.testnet.teritori.com"
},
Expand Down Expand Up @@ -4628,7 +4632,9 @@
"votingGroupPkgPath": "gno.land/p/teritori/dao_voting_group_v2",
"daoProposalSinglePkgPath": "gno.land/p/teritori/dao_proposal_single_v4",
"daoInterfacesPkgPath": "gno.land/p/teritori/dao_interfaces_v5",
"daoUtilsPkgPath": "",
"daoCorePkgPath": "gno.land/p/teritori/dao_core_v4",
"toriPkgPath": "",
"gnowebURL": "https://testnet.gno.teritori.com",
"faucetURL": "https://testnet.gno.teritori.com:5050/?toaddr=$addr"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/components/dao/GnoDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { NetworkKind, parseUserId } from "../../networks";
import { adenaVMCall, extractGnoNumber } from "../../utils/gno";
import {
GnoDAOUpdateSettings,
GnoSingleChoiceProposal,
GnoModboardsDeletePostMessage,
GnoModboardsCreateMessage,
GnoMintToriMessage,
GnoModboardsCreateMessage,
GnoModboardsDeletePostMessage,
GnoSingleChoiceProposal,
} from "../../utils/gnodao/messages";
import { fontSemibold20 } from "../../utils/style/fonts";
import { modalMarginPadding } from "../../utils/style/modals";
Expand Down Expand Up @@ -376,7 +376,7 @@ const GnoCreateProposal: React.FC<{ daoId: string | undefined }> = ({
{
caller: selectedWallet.address,
send: "",
pkg_path: daoAddress,
pkg_path: "gno.land/r/" + selectedWallet,
func: "ProposeJSON",
args: ["0", JSON.stringify(propReq)],
},
Expand Down
9 changes: 6 additions & 3 deletions packages/components/socialFeed/SocialActions/FlagModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import { useSelectedNetworkInfo } from "../../../hooks/useSelectedNetwork";
import useSelectedWallet from "../../../hooks/useSelectedWallet";
import { mustGetGnoNetwork } from "../../../networks";
import { TERITORI_FEED_ID } from "../../../utils/feed/constants";
import { adenaDoContract } from "../../../utils/gno";
import { neutral77, neutral33 } from "../../../utils/style/colors";
import {
adenaDoContract,
AdenaDoContractMessageType,
} from "../../../utils/gno";
import { neutral33, neutral77 } from "../../../utils/style/colors";
import { fontSemibold14, fontSemibold16 } from "../../../utils/style/fonts";
import { BrandText } from "../../BrandText";
import FlexRow from "../../FlexRow";
Expand Down Expand Up @@ -53,7 +56,7 @@ export const FlagModal: React.FC<FlagModalProps> = ({
try {
await adenaDoContract(
selectedNetworkId || "",
[{ type: "/vm.m_call", value: vmCall }],
[{ type: AdenaDoContractMessageType.CALL, value: vmCall }],
{
gasWanted: 2_000_000,
},
Expand Down
9 changes: 6 additions & 3 deletions packages/components/socialFeed/SocialActions/TipModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ import { useBalances } from "../../../hooks/useBalances";
import { useSelectedNetworkInfo } from "../../../hooks/useSelectedNetwork";
import useSelectedWallet from "../../../hooks/useSelectedWallet";
import {
NetworkKind,
getStakingCurrency,
keplrCurrencyFromNativeCurrencyInfo,
NetworkKind,
} from "../../../networks";
import { prettyPrice } from "../../../utils/coins";
import { defaultSocialFeedFee } from "../../../utils/fee";
import { TERITORI_FEED_ID } from "../../../utils/feed/constants";
import { adenaDoContract } from "../../../utils/gno";
import {
adenaDoContract,
AdenaDoContractMessageType,
} from "../../../utils/gno";
import { neutral77, primaryColor } from "../../../utils/style/colors";
import { fontSemibold13, fontSemibold14 } from "../../../utils/style/fonts";
import { BrandText } from "../../BrandText";
Expand Down Expand Up @@ -95,7 +98,7 @@ export const TipModal: React.FC<{
try {
await adenaDoContract(
selectedNetworkId || "",
[{ type: "/vm.m_call", value: vmCall }],
[{ type: AdenaDoContractMessageType.CALL, value: vmCall }],
{
gasWanted: 1_000_000,
},
Expand Down
7 changes: 5 additions & 2 deletions packages/components/socialFeed/modals/FlagConfirmModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { useFeedbacks } from "../../../context/FeedbacksProvider";
import { useSelectedNetworkId } from "../../../hooks/useSelectedNetwork";
import useSelectedWallet from "../../../hooks/useSelectedWallet";
import { mustGetGnoNetwork } from "../../../networks";
import { adenaDoContract } from "../../../utils/gno";
import {
adenaDoContract,
AdenaDoContractMessageType,
} from "../../../utils/gno";
import { GnoDAOVoteRequest } from "../../../utils/gnodao/messages";
import { neutral77 } from "../../../utils/style/colors";
import {
Expand Down Expand Up @@ -74,7 +77,7 @@ export const FlagConfirmModal: React.FC<FlagConfirmModalProps> = ({

const txHash = await adenaDoContract(
selectedNetworkId,
[{ type: "/vm.m_call", value: vmCall }],
[{ type: AdenaDoContractMessageType.CALL, value: vmCall }],
{
gasWanted: 2_000_000,
},
Expand Down
13 changes: 9 additions & 4 deletions packages/components/user/modals/EditProfileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import React, { useMemo } from "react";
import { View } from "react-native";

import {
ExecuteMsg as TNSExecuteMsg,
Metadata,
ExecuteMsg as TNSExecuteMsg,
} from "../../../contracts-clients/teritori-name-service/TeritoriNameService.types";
import { EditProfileForm } from "../forms/EditProfileForm";
import { TNSModalCommonProps } from "../types";
Expand All @@ -22,7 +22,12 @@ import { useNSUserInfo } from "@/hooks/useNSUserInfo";
import { useRunOrProposeTransaction } from "@/hooks/useRunOrProposeTransaction";
import useSelectedWallet from "@/hooks/useSelectedWallet";
import { getNetwork, NetworkKind, UserKind } from "@/networks";
import { adenaDoContract, AdenaDoContractMessage, VmCall } from "@/utils/gno";
import {
adenaDoContract,
AdenaDoContractMessage,
AdenaDoContractMessageType,
VmCall,
} from "@/utils/gno";
import { neutral17, neutral77 } from "@/utils/style/colors";
import { fontMedium16 } from "@/utils/style/fonts";
import { EMPTY_PROFILE, ProfileData } from "@/utils/upp";
Expand Down Expand Up @@ -183,7 +188,7 @@ export const EditProfileModal: React.FC<EditProfileModalProps> = ({
func: "Register",
args: ["", usernameValue, ""],
};
msgs.push({ type: "/vm.m_call", value: vmCall });
msgs.push({ type: AdenaDoContractMessageType.CALL, value: vmCall });
}

// FIXME: the contract supports only update data one by one
Expand Down Expand Up @@ -242,7 +247,7 @@ export const EditProfileModal: React.FC<EditProfileModalProps> = ({
args: [field, val],
};

msgs.push({ type: "/vm.m_call", value: vmCall });
msgs.push({ type: AdenaDoContractMessageType.CALL, value: vmCall });
}

if (msgs.length === 0) {
Expand Down
59 changes: 48 additions & 11 deletions packages/context/WalletsProvider/gnotest/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {
GnoJSONRPCProvider,
GnoWallet,
MemFile,
MemPackage,
MsgSend,
decodeTxMessages,
} from "@gnolang/gno-js-client";
import { TxFee, TransactionEndpoint, Tx } from "@gnolang/tm2-js-client";
import { TransactionEndpoint, Tx, TxFee } from "@gnolang/tm2-js-client";
import Long from "long";
import React from "react";
import { Pressable } from "react-native";
Expand All @@ -16,7 +18,11 @@ import { getUserId } from "@/networks";
import { gnoDevNetwork } from "@/networks/gno-dev";
import { setSelectedWalletId } from "@/store/slices/settings";
import { useAppDispatch } from "@/store/store";
import { RequestDocontractMessage } from "@/utils/gno";
import {
AdenaDoContractMessage,
AdenaDoContractMessageType,
RequestDocontractMessage,
} from "@/utils/gno";
import { WalletProvider } from "@/utils/walletProvider";

type UseGnotestResult = [true, boolean, Wallet[]] | [false, boolean, undefined];
Expand Down Expand Up @@ -268,7 +274,10 @@ const setupAdenaMock = () => {
throw new Error("Wallet not connected");
}
const msg = req.messages[0];
if (msg.type !== "/vm.m_call") {
if (
msg.type !== AdenaDoContractMessageType.CALL &&
msg.type !== AdenaDoContractMessageType.ADD_PKG
) {
throw new Error("Unsupported message type: " + msg.type);
n0izn0iz marked this conversation as resolved.
Show resolved Hide resolved
}
const txFee: TxFee = {
Expand All @@ -283,14 +292,19 @@ const setupAdenaMock = () => {
console.log("docontract sendAmount", sendAmount);
sendMap.set("ugnot", +sendAmount);
}
const res = await state.wallet.callMethod(
msg.value.pkg_path,
msg.value.func,
msg.value.args,
TransactionEndpoint.BROADCAST_TX_COMMIT,
sendMap,
txFee,
);
let res;
if (msg.type === AdenaDoContractMessageType.CALL) {
res = await state.wallet.callMethod(
msg.value.pkg_path,
msg.value.func,
msg.value.args,
TransactionEndpoint.BROADCAST_TX_COMMIT,
sendMap,
txFee,
);
} else {
res = await deployPackage(state.wallet, msg, sendMap, txFee);
}
return {
status: "success",
data: {
Expand All @@ -313,6 +327,29 @@ const setupAdenaMock = () => {
};
};

const deployPackage = async (
wallet: GnoWallet,
msg: AdenaDoContractMessage,
funds: Map<string, number> | undefined,
txFee: TxFee,
) => {
const files: MemFile[] = msg.value.package.files;

const pkg: MemPackage = {
name: msg.value.package.name,
path: msg.value.package.path,
files,
};

const tx = await wallet.deployPackage(
pkg,
TransactionEndpoint.BROADCAST_TX_COMMIT,
funds,
txFee,
);
return tx;
};

export const useGnotest: () => UseGnotestResult = () => {
const { wallet, address } = useGnotestStore();
const wallets: Wallet[] = [];
Expand Down
8 changes: 4 additions & 4 deletions packages/hooks/feed/useFeedPosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import { useBalances } from "../useBalances";

import { signingSocialFeedClient } from "@/client-creators/socialFeedClient";
import {
parseUserId,
getStakingCurrency,
mustGetCosmosNetwork,
NetworkKind,
parseUserId,
} from "@/networks";
import { prettyPrice } from "@/utils/coins";
import { defaultSocialFeedFee } from "@/utils/fee";
import { TERITORI_FEED_ID } from "@/utils/feed/constants";
import { FeedPostingStepId, feedPostingStep } from "@/utils/feed/posting";
import { adenaDoContract } from "@/utils/gno";
import { feedPostingStep, FeedPostingStepId } from "@/utils/feed/posting";
import { adenaDoContract, AdenaDoContractMessageType } from "@/utils/gno";
import { PostCategory } from "@/utils/types/feed";

export const useFeedPosting = (
Expand Down Expand Up @@ -124,7 +124,7 @@ export const useFeedPosting = (

const txHash = await adenaDoContract(
network.id,
[{ type: "/vm.m_call", value: vmCall }],
[{ type: AdenaDoContractMessageType.CALL, value: vmCall }],
{ gasWanted: 2_000_000 },
);

Expand Down
4 changes: 2 additions & 2 deletions packages/hooks/feed/useSocialReactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
NetworkKind,
} from "@/networks";
import { TERITORI_FEED_ID } from "@/utils/feed/constants";
import { adenaDoContract } from "@/utils/gno";
import { adenaDoContract, AdenaDoContractMessageType } from "@/utils/gno";
import {
DISLIKE_EMOJI,
getUpdatedReactions,
Expand Down Expand Up @@ -77,7 +77,7 @@ export const useSocialReactions = ({
};
const txHash = await adenaDoContract(
post.networkId,
[{ type: "/vm.m_call", value: vmCall }],
[{ type: AdenaDoContractMessageType.CALL, value: vmCall }],
{
gasWanted: 2_000_000,
},
Expand Down
3 changes: 2 additions & 1 deletion packages/networks/gno-dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ export const gnoDevNetwork: GnoNetworkInfo = {
votingGroupPkgPath: "gno.land/p/teritori/dao_voting_group",
daoProposalSinglePkgPath: "gno.land/p/teritori/dao_proposal_single",
profilePkgPath: "gno.land/r/demo/profile",

daoInterfacesPkgPath: "gno.land/p/teritori/dao_interfaces",
daoCorePkgPath: "gno.land/p/teritori/dao_core",
daoUtilsPkgPath: "gno.land/p/teritori/dao_utils",
toriPkgPath: "gno.land/r/teritori/tori",
nameServiceDefaultImage:
"ipfs://bafkreignptjimiu7wuux6mk6uh4hb4odb6ff62ny4bvdokrhes7g67huse",
gnowebURL: "http://127.0.0.1:8888",
Expand Down
2 changes: 2 additions & 0 deletions packages/networks/gno-portal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const gnoPortalNetwork: GnoNetworkInfo = {
daoProposalSinglePkgPath: "gno.land/p/teritori/dao_proposal_single",
daoInterfacesPkgPath: "gno.land/p/teritori/dao_interfaces",
daoCorePkgPath: "gno.land/p/teritori/dao_core",
daoUtilsPkgPath: "gno.land/r/teritori/dao_utils",
toriPkgPath: "gno.land/r/teritori/tori",
profilePkgPath: "gno.land/r/demo/profile",
txIndexerURL: "https://indexer.portal-loop.gno.testnet.teritori.com",
};
2 changes: 2 additions & 0 deletions packages/networks/gno-teritori/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export const gnoTeritoriNetwork: GnoNetworkInfo = {
votingGroupPkgPath: "gno.land/p/teritori/dao_voting_group_v2",
daoProposalSinglePkgPath: "gno.land/p/teritori/dao_proposal_single_v4",
daoInterfacesPkgPath: "gno.land/p/teritori/dao_interfaces_v5",
daoUtilsPkgPath: "", //TODO: fill with the correct path
daoCorePkgPath: "gno.land/p/teritori/dao_core_v4",
toriPkgPath: "", //TODO: fill with the correct path
gnowebURL: "https://testnet.gno.teritori.com",
faucetURL: "https://testnet.gno.teritori.com:5050/?toaddr=$addr",
};
2 changes: 2 additions & 0 deletions packages/networks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ export type GnoNetworkInfo = NetworkInfoBase & {
daoInterfacesPkgPath?: string;
daoCorePkgPath?: string;
groupsPkgPath?: string;
daoUtilsPkgPath?: string;
toriPkgPath?: string;
profilePkgPath?: string;
faucetURL?: string;
txIndexerURL?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export const CreateDAOSection: React.FC<CreateDAOSectionProps> = ({
// isAsterickSign
multiline
numberOfLines={3}
testID="organization-description"
/>
</View>
</View>
Expand Down
Loading
Loading