Skip to content

Commit 6fbe570

Browse files
kumaryash90IDubuque
authored andcommitted
Spicy chain gas override (#1805)
1 parent 38e86c0 commit 6fbe570

File tree

7 files changed

+44
-19
lines changed

7 files changed

+44
-19
lines changed

.changeset/thick-buckets-deny.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@thirdweb-dev/chains": patch
3+
"@thirdweb-dev/sdk": patch
4+
---
5+
6+
Spicy Chain deployments

packages/chains/data/additional/88882.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default {
1919
explorers: [
2020
{
2121
name: "Spicy Explorer",
22-
url: "http://spicy-explorer.chiliz.com/",
22+
url: "https://spicy-explorer.chiliz.com/",
2323
standard: "none",
2424
},
2525
],

packages/sdk/src/evm/common/any-evm-constants.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ export const CUSTOM_GAS_FOR_CHAIN: Record<number, CustomChain> = {
5757
name: "BitTorrent Chain",
5858
gasPrice: 300_000 * 10 ** 9,
5959
},
60+
[88882]: {
61+
name: "Spicy Chain",
62+
gasPrice: 2500 * 10 ** 9,
63+
gasLimit: 200_000,
64+
},
65+
[88888]: {
66+
name: "Chiliz Chain",
67+
gasPrice: 2500 * 10 ** 9,
68+
gasLimit: 200_000,
69+
},
6070
};
6171
/* eslint-enable no-useless-computed-key */
6272

packages/sdk/src/evm/common/any-evm-utils/deployCreate2Factory.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { BigNumber, Signer } from "ethers";
22
import invariant from "tiny-invariant";
3-
import { toWei } from "../currency/toWei";
43
import type { DeployOptions } from "../../types/deploy";
54
import { CUSTOM_GAS_FOR_CHAIN } from "../any-evm-constants";
65
import { COMMON_FACTORY } from "./constants";
@@ -34,11 +33,11 @@ export async function deployCreate2Factory(
3433
const chainId = enforceEip155 ? networkId : 0;
3534
console.debug(`ChainId ${networkId} enforces EIP155: ${enforceEip155}`);
3635
const deploymentInfo = CUSTOM_GAS_FOR_CHAIN[networkId]
37-
? getCreate2FactoryDeploymentInfo(
38-
chainId,
39-
CUSTOM_GAS_FOR_CHAIN[networkId].gasPrice,
40-
)
41-
: getCreate2FactoryDeploymentInfo(chainId);
36+
? getCreate2FactoryDeploymentInfo(chainId, {
37+
gasPrice: CUSTOM_GAS_FOR_CHAIN[networkId].gasPrice,
38+
gasLimit: CUSTOM_GAS_FOR_CHAIN[networkId].gasLimit,
39+
})
40+
: getCreate2FactoryDeploymentInfo(chainId, {});
4241

4342
const factoryExists = await isContractDeployed(
4443
deploymentInfo.deployment,
@@ -47,10 +46,19 @@ export async function deployCreate2Factory(
4746

4847
// deploy community factory if not already deployed
4948
if (!factoryExists) {
49+
const gasPrice = CUSTOM_GAS_FOR_CHAIN[networkId]?.gasPrice
50+
? CUSTOM_GAS_FOR_CHAIN[networkId].gasPrice
51+
: 100 * 10 ** 9;
52+
const gasLimit = CUSTOM_GAS_FOR_CHAIN[networkId]?.gasLimit
53+
? CUSTOM_GAS_FOR_CHAIN[networkId].gasLimit
54+
: 100000;
55+
56+
invariant(gasLimit, "gasLimit undefined for create2 factory deploy");
57+
invariant(gasPrice, "gasPrice undefined for create2 factory deploy");
58+
5059
// send balance to the keyless signer
51-
const valueToSend = CUSTOM_GAS_FOR_CHAIN[networkId]
52-
? BigNumber.from(CUSTOM_GAS_FOR_CHAIN[networkId].gasPrice).mul(100000)
53-
: toWei("0.01");
60+
const valueToSend = BigNumber.from(gasPrice).mul(gasLimit);
61+
5462
if (
5563
(await signer.provider.getBalance(deploymentInfo.signer)).lt(valueToSend)
5664
) {

packages/sdk/src/evm/common/any-evm-utils/getCreate2FactoryAddress.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ export async function getCreate2FactoryAddress(
2828
const networkId = (await provider.getNetwork()).chainId;
2929
const chainId = enforceEip155 ? networkId : 0;
3030
const deploymentInfo = CUSTOM_GAS_FOR_CHAIN[networkId]
31-
? getCreate2FactoryDeploymentInfo(
32-
chainId,
33-
CUSTOM_GAS_FOR_CHAIN[networkId].gasPrice,
34-
)
35-
: getCreate2FactoryDeploymentInfo(chainId);
31+
? getCreate2FactoryDeploymentInfo(chainId, {
32+
gasPrice: CUSTOM_GAS_FOR_CHAIN[networkId].gasPrice,
33+
gasLimit: CUSTOM_GAS_FOR_CHAIN[networkId].gasLimit,
34+
})
35+
: getCreate2FactoryDeploymentInfo(chainId, {});
3636

3737
return deploymentInfo.deployment;
3838
}

packages/sdk/src/evm/common/any-evm-utils/getCreate2FactoryDeploymentInfo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import { getKeylessTxn } from "./getKeylessTxn";
1111
*/
1212
export function getCreate2FactoryDeploymentInfo(
1313
chainId: number,
14-
gasPrice?: number,
14+
gasOptions: { gasPrice?: number; gasLimit?: number },
1515
): KeylessDeploymentInfo {
1616
const signature = utils.joinSignature(SIGNATURE);
1717
const deploymentTransaction = getKeylessTxn(
1818
{
19-
gasPrice: gasPrice ? gasPrice : 100 * 10 ** 9,
20-
gasLimit: 100000,
19+
gasPrice: gasOptions.gasPrice ? gasOptions.gasPrice : 100 * 10 ** 9,
20+
gasLimit: gasOptions.gasLimit ? gasOptions.gasLimit : 100000,
2121
nonce: 0,
2222
data: CREATE2_FACTORY_BYTECODE,
2323
chainId: chainId,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export type CustomChain = {
22
name: string;
3-
gasPrice: number;
3+
gasPrice?: number;
4+
gasLimit?: number;
45
};

0 commit comments

Comments
 (0)