Skip to content

Commit 971ffed

Browse files
frolicalvrs
andauthored
feat(entrykit): initial release (#3419)
Co-authored-by: alvarius <alvarius@lattice.xyz>
1 parent 1b477d4 commit 971ffed

File tree

129 files changed

+9154
-1407
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+9154
-1407
lines changed

.changeset/dirty-buttons-tickle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@latticexyz/entrykit": patch
3+
---
4+
5+
Initial, experimental release of EntryKit.

packages/common/src/deploy/ensureContract.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type Contract = {
88
bytecode: Hex;
99
deployedBytecodeSize?: number;
1010
debugLabel?: string;
11+
salt?: Hex;
1112
};
1213

1314
export async function ensureContract({
@@ -16,6 +17,7 @@ export async function ensureContract({
1617
bytecode,
1718
deployedBytecodeSize,
1819
debugLabel = "contract",
20+
salt = singletonSalt,
1921
}: {
2022
readonly client: Client<Transport, Chain | undefined, Account>;
2123
readonly deployerAddress: Hex;
@@ -24,7 +26,7 @@ export async function ensureContract({
2426
throw new Error(`Found unlinked public library in ${debugLabel} bytecode`);
2527
}
2628

27-
const address = getCreate2Address({ from: deployerAddress, salt: singletonSalt, bytecode });
29+
const address = getCreate2Address({ from: deployerAddress, salt, bytecode });
2830

2931
const contractCode = await getCode(client, { address, blockTag: "pending" });
3032
if (contractCode) {
@@ -50,7 +52,7 @@ export async function ensureContract({
5052
await sendTransaction(client, {
5153
chain: client.chain ?? null,
5254
to: deployerAddress,
53-
data: concatHex([singletonSalt, bytecode]),
55+
data: concatHex([salt, bytecode]),
5456
}),
5557
];
5658
}

packages/common/src/deploy/getContractAddress.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import { singletonSalt } from "./common";
44
export function getContractAddress({
55
deployerAddress,
66
bytecode,
7+
salt = singletonSalt,
78
}: {
89
readonly deployerAddress: Hex;
910
readonly bytecode: Hex;
11+
readonly salt?: Hex;
1012
}): Hex {
11-
return getCreate2Address({ from: deployerAddress, bytecode, salt: singletonSalt });
13+
return getCreate2Address({ from: deployerAddress, bytecode, salt });
1214
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
export function uniqueBy<value, key>(values: readonly value[], getKey: (value: value) => key): readonly value[] {
22
const map = new Map<key, value>();
33
for (const value of values) {
4-
map.set(getKey(value), value);
4+
const key = getKey(value);
5+
if (!map.has(key)) {
6+
map.set(key, value);
7+
}
58
}
69
return Array.from(map.values());
710
}

packages/common/src/waitForTransactions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export async function waitForTransactions({
99
}: {
1010
readonly client: Client<Transport, Chain | undefined, Account>;
1111
readonly hashes: readonly Hex[];
12-
readonly debugLabel: string;
12+
readonly debugLabel?: string;
1313
}): Promise<void> {
1414
if (!hashes.length) return;
1515

packages/entrykit/.eslintrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": ["../../.eslintrc", "plugin:react/recommended", "plugin:react-hooks/recommended"],
3+
"plugins": ["react", "react-hooks"],
4+
"rules": {
5+
"react/react-in-jsx-scope": "off"
6+
}
7+
}

packages/entrykit/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# EntryKit
2+
3+
UI kit to streamline signing in to MUD apps.
4+
5+
## Installation
6+
7+
```
8+
npm install @latticexyz/entrykit
9+
```
10+
11+
## Usage
12+
13+
TODO
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
// workaround for https://github.com/pnpm/pnpm/issues/1801
3+
import "../dist/tsup/bin/deploy-local-prereqs.js";
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module "*?inline" {
2+
const content: string;
3+
export default content;
4+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
scrollback: 10000
2+
procs:
3+
anvil:
4+
shell: anvil --dump-state playground/anvil-state.json
5+
6+
deploy-prereqs:
7+
shell: ./bin/deploy-local-prereqs.js
8+
env:
9+
DEBUG: "mud:*"
10+
# Anvil default account (0x70997970C51812dc3A010C7d01b50e0d17dc79C8)
11+
PRIVATE_KEY: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
12+
13+
# deploy-quarry-paymaster:
14+
# cwd: ../../../quarry-paymaster/packages/contracts
15+
# shell: pnpm mud deploy --salt 0x && pnpm fund:paymaster:local && pnpm fund:issuer:local
16+
# env:
17+
# DEBUG: "mud:*"
18+
19+
deploy-game:
20+
cwd: ../../test/mock-game-contracts
21+
shell: pnpm deploy:local --salt 0x
22+
env:
23+
DEBUG: "mud:*"
24+
# Anvil default account (0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc)
25+
PRIVATE_KEY: "0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba"
26+
27+
# deploy-bundler:
28+
# cwd: ../../../alto
29+
# shell: pnpm ts-node scripts/localDeployer/index.ts

0 commit comments

Comments
 (0)