@warptoad/skinny-fat-imt-js 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ import { type Account, type Address, type Hex, type PublicClient, type WalletClient } from "viem";
2
+ /** Presigned deployment of the deterministic-deployment-proxy. */
3
+ export declare const CREATE2_FACTORY_DEPLOYMENT: {
4
+ /** Recovered signer of the presigned transaction. Has no known private key. */
5
+ readonly deployer: Address;
6
+ /** 100000 gas at 100 gwei — the exact cost of the presigned transaction. */
7
+ readonly cost: 10000000000000000n;
8
+ readonly tx: Hex;
9
+ readonly address: Address;
10
+ };
11
+ export declare function deployCreate2Factory(publicClient: PublicClient, walletClient: WalletClient, account: Account): Promise<{
12
+ address: `0x${string}`;
13
+ deployed: boolean;
14
+ }>;
15
+ //# sourceMappingURL=deployFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployFactory.d.ts","sourceRoot":"","sources":["../../src/create2/deployFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAElG,kEAAkE;AAClE,eAAO,MAAM,0BAA0B;IACnC,+EAA+E;uBACrB,OAAO;IACjE,4EAA4E;;iBAE8Q,GAAG;sBACpS,OAAO;CAC1D,CAAC;AAEX,wBAAsB,oBAAoB,CACtC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAC,OAAO;;;GAuC1E"}
@@ -0,0 +1,42 @@
1
+ import {} from "viem";
2
+ /** Presigned deployment of the deterministic-deployment-proxy. */
3
+ export const CREATE2_FACTORY_DEPLOYMENT = {
4
+ /** Recovered signer of the presigned transaction. Has no known private key. */
5
+ deployer: "0x3fab184622dc19b6109349b94811493bf2a45362",
6
+ /** 100000 gas at 100 gwei — the exact cost of the presigned transaction. */
7
+ cost: 10000000000000000n,
8
+ tx: "0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222",
9
+ address: "0x4e59b44847b379578588920cA78FbF26c0B4956C",
10
+ };
11
+ export async function deployCreate2Factory(publicClient, walletClient, account) {
12
+ const { address, deployer, cost, tx } = CREATE2_FACTORY_DEPLOYMENT;
13
+ const existing = await publicClient.getCode({ address });
14
+ if (existing !== undefined && existing !== "0x") {
15
+ return { address, deployed: false };
16
+ }
17
+ // fund account
18
+ const balance = await publicClient.getBalance({ address: deployer });
19
+ if (balance < cost) {
20
+ const fundHash = await walletClient.sendTransaction({
21
+ to: deployer,
22
+ value: cost - balance,
23
+ account: account,
24
+ chain: walletClient.chain
25
+ });
26
+ await publicClient.waitForTransactionReceipt({ hash: fundHash });
27
+ }
28
+ // deploy
29
+ const hash = await publicClient.sendRawTransaction({ serializedTransaction: tx });
30
+ const receipt = await publicClient.waitForTransactionReceipt({ hash });
31
+ // check
32
+ if (receipt.status !== "success") {
33
+ throw new Error(`deterministic-deployment-proxy deployment reverted (tx ${hash})`);
34
+ }
35
+ const code = await publicClient.getCode({ address });
36
+ if (code === undefined || code === "0x") {
37
+ throw new Error(`deterministic-deployment-proxy deployment landed no code at ${address} — this chain ` +
38
+ "either rejects pre-EIP-155 transactions or derives contract addresses differently");
39
+ }
40
+ return { address, deployed: true };
41
+ }
42
+ //# sourceMappingURL=deployFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployFactory.js","sourceRoot":"","sources":["../../src/create2/deployFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8E,MAAM,MAAM,CAAC;AAElG,kEAAkE;AAClE,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACtC,+EAA+E;IAC/E,QAAQ,E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M,IAAI,KAAK,CAAC,0DAA0D,IAAI,GAAG,CAAC,CAAC;IACvF,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IACrD,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACX,+DAA+D,OAAO,gBAAgB;YACtF,mFAAmF,CACtF,CAAC;IACN,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACvC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from "./interfaces.js";
2
2
  export * from "./types.js";
3
3
  export * from "./create2.js";
4
+ export * from "./deployFactory.js";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/create2/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/create2/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from "./interfaces.js";
2
2
  export * from "./types.js";
3
3
  export * from "./create2.js";
4
+ export * from "./deployFactory.js";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/create2/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/create2/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warptoad/skinny-fat-imt-js",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "js library counter part of skinny-fat-imt contracts, used to sync the onchain tree client side",
5
5
  "license": "MIT",
6
6
  "author": "warptoad",
@@ -0,0 +1,53 @@
1
+ import { type Account, type Address, type Hex, type PublicClient, type WalletClient } from "viem";
2
+
3
+ /** Presigned deployment of the deterministic-deployment-proxy. */
4
+ export const CREATE2_FACTORY_DEPLOYMENT = {
5
+ /** Recovered signer of the presigned transaction. Has no known private key. */
6
+ deployer: "0x3fab184622dc19b6109349b94811493bf2a45362" as Address,
7
+ /** 100000 gas at 100 gwei — the exact cost of the presigned transaction. */
8
+ cost: 10000000000000000n,
9
+ tx: "0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222" as Hex,
10
+ address: "0x4e59b44847b379578588920cA78FbF26c0B4956C" as Address,
11
+ } as const;
12
+
13
+ export async function deployCreate2Factory(
14
+ publicClient: PublicClient, walletClient: WalletClient, account:Account
15
+ ) {
16
+ const { address, deployer, cost, tx } = CREATE2_FACTORY_DEPLOYMENT;
17
+
18
+ const existing = await publicClient.getCode({ address });
19
+ if (existing !== undefined && existing !== "0x") {
20
+ return { address, deployed: false };
21
+ }
22
+
23
+ // fund account
24
+ const balance = await publicClient.getBalance({ address: deployer });
25
+ if (balance < cost) {
26
+ const fundHash = await walletClient.sendTransaction({
27
+ to: deployer,
28
+ value: cost - balance,
29
+ account: account,
30
+ chain: walletClient.chain
31
+ });
32
+ await publicClient.waitForTransactionReceipt({ hash: fundHash });
33
+ }
34
+
35
+ // deploy
36
+ const hash = await publicClient.sendRawTransaction({ serializedTransaction: tx });
37
+ const receipt = await publicClient.waitForTransactionReceipt({ hash });
38
+
39
+ // check
40
+ if (receipt.status !== "success") {
41
+ throw new Error(`deterministic-deployment-proxy deployment reverted (tx ${hash})`);
42
+ }
43
+
44
+ const code = await publicClient.getCode({ address });
45
+ if (code === undefined || code === "0x") {
46
+ throw new Error(
47
+ `deterministic-deployment-proxy deployment landed no code at ${address} — this chain ` +
48
+ "either rejects pre-EIP-155 transactions or derives contract addresses differently",
49
+ );
50
+ }
51
+
52
+ return { address, deployed: true };
53
+ }
@@ -1,3 +1,4 @@
1
1
  export * from "./interfaces.js";
2
2
  export * from "./types.js";
3
3
  export * from "./create2.js";
4
+ export * from "./deployFactory.js";