Skip to content

Commit

Permalink
createContract -> getContract everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Oct 3, 2023
1 parent 069809b commit 2013116
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions e2e/packages/client-vanilla/src/mud/setupNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
import { getNetworkConfig } from "./getNetworkConfig";
import { world } from "./world";
import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
import { createBurnerAccount, createContract, transportObserver } from "@latticexyz/common";
import { createBurnerAccount, getContract, transportObserver } from "@latticexyz/common";
import mudConfig from "contracts/mud.config";

export type SetupNetworkResult = Awaited<ReturnType<typeof setupNetwork>>;
Expand All @@ -26,7 +26,7 @@ export async function setupNetwork() {
account: burnerAccount,
});

const worldContract = createContract({
const worldContract = getContract({
address: networkConfig.worldAddress as Hex,
abi: IWorldAbi,
publicClient,
Expand Down
4 changes: 2 additions & 2 deletions e2e/packages/test-data/generate-test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
numberToHex,
} from "viem";
import { mudFoundry } from "@latticexyz/common/chains";
import { createContract } from "@latticexyz/common";
import { getContract } from "@latticexyz/common";
import { storeEventsAbi } from "@latticexyz/store";
import { privateKeyToAccount } from "viem/accounts";
import IWorldAbi from "../contracts/out/IWorld.sol/IWorld.abi.json";
Expand Down Expand Up @@ -63,7 +63,7 @@ const walletClient = createWalletClient({
account,
});

const worldContract = createContract({
const worldContract = getContract({
address: worldAddress,
abi: IWorldAbi,
publicClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
import { getNetworkConfig } from "./getNetworkConfig";
import { world } from "./world";
import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
import { createBurnerAccount, createContract, transportObserver, ContractWrite } from "@latticexyz/common";
import { createBurnerAccount, getContract, transportObserver, ContractWrite } from "@latticexyz/common";
import { Subject, share } from "rxjs";
import mudConfig from "contracts/mud.config";

Expand All @@ -28,7 +28,7 @@ export async function setupNetwork() {
});

const write$ = new Subject<ContractWrite>();
const worldContract = createContract({
const worldContract = getContract({
address: networkConfig.worldAddress as Hex,
abi: IWorldAbi,
publicClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
import { getNetworkConfig } from "./getNetworkConfig";
import { world } from "./world";
import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
import { ContractWrite, createBurnerAccount, createContract, transportObserver } from "@latticexyz/common";
import { ContractWrite, createBurnerAccount, getContract, transportObserver } from "@latticexyz/common";
import { Subject, share } from "rxjs";
import mudConfig from "contracts/mud.config";
import { createClient as createFaucetClient } from "@latticexyz/faucet";
Expand All @@ -29,7 +29,7 @@ export async function setupNetwork() {
});

const write$ = new Subject<ContractWrite>();
const worldContract = createContract({
const worldContract = getContract({
address: networkConfig.worldAddress as Hex,
abi: IWorldAbi,
publicClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
import { getNetworkConfig } from "./getNetworkConfig";
import { world } from "./world";
import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
import { createBurnerAccount, createContract, transportObserver, ContractWrite } from "@latticexyz/common";
import { createBurnerAccount, getContract, transportObserver, ContractWrite } from "@latticexyz/common";
import { Subject, share } from "rxjs";
import mudConfig from "contracts/mud.config";

Expand All @@ -28,7 +28,7 @@ export async function setupNetwork() {
});

const write$ = new Subject<ContractWrite>();
const worldContract = createContract({
const worldContract = getContract({
address: networkConfig.worldAddress as Hex,
abi: IWorldAbi,
publicClient,
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/utils/utils/deployContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export async function deployContract(input: TxConfig & { nonce: number; contract
throw new MUDError(
`Error deploying ${contract.name}: invalid bytecode. Note that linking of public libraries is not supported yet, make sure none of your libraries use "external" functions.`
);
} else if (error?.message.includes("CreateContractLimit")) {
throw new MUDError(`Error deploying ${contract.name}: CreateContractLimit exceeded.`);
} else if (error?.message.includes("getContractLimit")) {
throw new MUDError(`Error deploying ${contract.name}: getContractLimit exceeded.`);
} else throw error;
}
}
2 changes: 1 addition & 1 deletion packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export * from "./transportObserver";
export * from "./writeContract";

/** @deprecated use `getContract` instead */
export { createContract } from "./createContract";
export { getContract } from "./getContract";
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function createSystemCalls(
* SetupNetworkResult, as defined in setupNetwork.ts
*
* - Out of this parameter, we only care about two fields:
* - worldContract (which comes from createContract, see
* - worldContract (which comes from getContract, see
* https://github.com/latticexyz/mud/blob/26dabb34321eedff7a43f3fcb46da4f3f5ba3708/templates/phaser/packages/client/src/mud/setupNetwork.ts#L31).
* - waitForTransaction (which comes from syncToRecs, see
* https://github.com/latticexyz/mud/blob/26dabb34321eedff7a43f3fcb46da4f3f5ba3708/templates/phaser/packages/client/src/mud/setupNetwork.ts#L39).
Expand Down
4 changes: 2 additions & 2 deletions templates/phaser/packages/client/src/mud/setupNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
import { getNetworkConfig } from "./getNetworkConfig";
import { world } from "./world";
import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
import { createBurnerAccount, createContract, transportObserver, ContractWrite } from "@latticexyz/common";
import { createBurnerAccount, getContract, transportObserver, ContractWrite } from "@latticexyz/common";
import { Subject, share } from "rxjs";

/*
Expand Down Expand Up @@ -58,7 +58,7 @@ export async function setupNetwork() {
/*
* Create an object for communicating with the deployed World.
*/
const worldContract = createContract({
const worldContract = getContract({
address: networkConfig.worldAddress as Hex,
abi: IWorldAbi,
publicClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function createSystemCalls(
* SetupNetworkResult, as defined in setupNetwork.ts
*
* - Out of this parameter, we only care about two fields:
* - worldContract (which comes from createContract, see
* - worldContract (which comes from getContract, see
* https://github.com/latticexyz/mud/blob/26dabb34321eedff7a43f3fcb46da4f3f5ba3708/templates/react/packages/client/src/mud/setupNetwork.ts#L31).
* - waitForTransaction (which comes from syncToRecs, see
* https://github.com/latticexyz/mud/blob/26dabb34321eedff7a43f3fcb46da4f3f5ba3708/templates/react/packages/client/src/mud/setupNetwork.ts#L39).
Expand Down
4 changes: 2 additions & 2 deletions templates/react/packages/client/src/mud/setupNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
import { getNetworkConfig } from "./getNetworkConfig";
import { world } from "./world";
import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
import { createBurnerAccount, createContract, transportObserver, ContractWrite } from "@latticexyz/common";
import { createBurnerAccount, getContract, transportObserver, ContractWrite } from "@latticexyz/common";

import { Subject, share } from "rxjs";

Expand Down Expand Up @@ -60,7 +60,7 @@ export async function setupNetwork() {
/*
* Create an object for communicating with the deployed World.
*/
const worldContract = createContract({
const worldContract = getContract({
address: networkConfig.worldAddress as Hex,
abi: IWorldAbi,
publicClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function createSystemCalls(
* SetupNetworkResult, as defined in setupNetwork.ts
*
* - Out of this parameter, we only care about two fields:
* - worldContract (which comes from createContract, see
* - worldContract (which comes from getContract, see
* https://github.com/latticexyz/mud/blob/26dabb34321eedff7a43f3fcb46da4f3f5ba3708/templates/threejs/packages/client/src/mud/setupNetwork.ts#L31).
* - waitForTransaction (which comes from syncToRecs, see
* https://github.com/latticexyz/mud/blob/26dabb34321eedff7a43f3fcb46da4f3f5ba3708/templates/threejs/packages/client/src/mud/setupNetwork.ts#L39).
Expand Down
4 changes: 2 additions & 2 deletions templates/threejs/packages/client/src/mud/setupNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
import { getNetworkConfig } from "./getNetworkConfig";
import { world } from "./world";
import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
import { createBurnerAccount, createContract, transportObserver, ContractWrite } from "@latticexyz/common";
import { createBurnerAccount, getContract, transportObserver, ContractWrite } from "@latticexyz/common";
import { Subject, share } from "rxjs";

/*
Expand Down Expand Up @@ -58,7 +58,7 @@ export async function setupNetwork() {
/*
* Create an object for communicating with the deployed World.
*/
const worldContract = createContract({
const worldContract = getContract({
address: networkConfig.worldAddress as Hex,
abi: IWorldAbi,
publicClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function createSystemCalls(
* SetupNetworkResult, as defined in setupNetwork.ts
*
* - Out of this parameter, we only care about two fields:
* - worldContract (which comes from createContract, see
* - worldContract (which comes from getContract, see
* https://github.com/latticexyz/mud/blob/26dabb34321eedff7a43f3fcb46da4f3f5ba3708/templates/vanilla/packages/client/src/mud/setupNetwork.ts#L31).
* - waitForTransaction (which comes from syncToRecs, see
* https://github.com/latticexyz/mud/blob/26dabb34321eedff7a43f3fcb46da4f3f5ba3708/templates/vanilla/packages/client/src/mud/setupNetwork.ts#L39).
Expand Down
4 changes: 2 additions & 2 deletions templates/vanilla/packages/client/src/mud/setupNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
import { getNetworkConfig } from "./getNetworkConfig";
import { world } from "./world";
import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
import { createBurnerAccount, createContract, transportObserver, ContractWrite } from "@latticexyz/common";
import { createBurnerAccount, getContract, transportObserver, ContractWrite } from "@latticexyz/common";

import { Subject, share } from "rxjs";

Expand Down Expand Up @@ -60,7 +60,7 @@ export async function setupNetwork() {
/*
* Create an object for communicating with the deployed World.
*/
const worldContract = createContract({
const worldContract = getContract({
address: networkConfig.worldAddress as Hex,
abi: IWorldAbi,
publicClient,
Expand Down

0 comments on commit 2013116

Please sign in to comment.