Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 15 additions & 10 deletions cli-typescript/src/abis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const NEW_CONTRACT_INITIALIZED_EVENT_ABI = {
{ name: 'standardId', type: 'uint8' },
{ name: 'name', type: 'string' },
{ name: 'symbol', type: 'string' },
{ name: 'mintFee', type: 'uint256' },
],
} as const;

Expand Down Expand Up @@ -142,6 +143,20 @@ export const TRANSFER_OWNERSHIP_ABI = {
type: 'function',
} as const;

export const SET_MINT_FEE_ABI = {
inputs: [
{
internalType: 'uint256',
name: 'mintFee',
type: 'uint256',
},
],
name: 'setMintFee',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
} as const;

export const ERC712M_ABIS = {
setup: {
type: 'function',
Expand Down Expand Up @@ -253,11 +268,6 @@ export const ERC712M_ABIS = {
name: 'price',
type: 'uint80',
},
{
internalType: 'uint80',
name: 'mintFee',
type: 'uint80',
},
{
internalType: 'uint32',
name: 'walletLimit',
Expand Down Expand Up @@ -511,11 +521,6 @@ export const ERC1155M_ABIS = {
name: 'price',
type: 'uint80[]',
},
{
internalType: 'uint80[]',
name: 'mintFee',
type: 'uint80[]',
},
{
internalType: 'uint32[]',
name: 'walletLimit',
Expand Down
2 changes: 2 additions & 0 deletions cli-typescript/src/cmds/createCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
setGlobalWalletLimitCmd,
setMaxMintableSupplyCmd,
setMintableCmd,
setMintFeeCmd,
setStagesCmd,
setTimestampExpiryCmd,
setTokenURISuffixCmd,
Expand Down Expand Up @@ -203,6 +204,7 @@ export const createEvmCommand = ({
newCmd.addCommand(initContractCmd());
newCmd.addCommand(setUriCmd());
newCmd.addCommand(setStagesCmd());
newCmd.addCommand(setMintFeeCmd());
newCmd.addCommand(setGlobalWalletLimitCmd());
newCmd.addCommand(setMaxMintableSupplyCmd());
newCmd.addCommand(setCosginerCmd());
Expand Down
10 changes: 10 additions & 0 deletions cli-typescript/src/cmds/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getTokenIdOption,
getTokenUriSuffixOption,
getUriOption,
mintFeeOption,
} from '../utils/cmdOptions';
import newWalletAction from '../utils/cmdActions/newWalletAction';
import setUriAction from '../utils/cmdActions/setUriAction';
Expand All @@ -36,6 +37,7 @@ import { ownerMintAction } from '../utils/cmdActions/ownerMintAction';
import { checkSignerBalanceAction } from '../utils/cmdActions/checkSignerBalanceAction';
import getWalletInfoAction from '../utils/cmdActions/getWalletInfoAction';
import getProjectConfigAction from '../utils/cmdActions/getProjectConfigAction';
import setMintFeeAction from '../utils/cmdActions/setMintFeeAction';

export const createNewWalletCmd = () =>
new Command('create-wallet')
Expand Down Expand Up @@ -196,3 +198,11 @@ export const checkSignerBalanceCmd = () =>
.alias('csb')
.description('Check the balance of the signer account for the collection.')
.action(checkSignerBalanceAction);

export const setMintFeeCmd = () =>
new Command('set-mint-fee')
.command('set-mint-fee <symbol>')
.alias('smf')
.description('set the mint fee for the collection')
.addOption(mintFeeOption().makeOptionMandatory())
.action(setMintFeeAction);
62 changes: 62 additions & 0 deletions cli-typescript/src/utils/ContractManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
MagicDropCloneFactoryAbis,
MagicDropTokenImplRegistryAbis,
NEW_CONTRACT_INITIALIZED_EVENT_ABI,
SET_MINT_FEE_ABI,
SET_TRANSFER_VALIDATOR_ABI,
SUPPORTS_INTERFACE_ABI,
} from '../abis';
Expand Down Expand Up @@ -99,6 +100,67 @@ export class ContractManager {
}
}

public async getMintFee(
registryAddress: Hex,
standardId: number,
implId: number,
): Promise<bigint> {
try {
const data = encodeFunctionData({
abi: [MagicDropTokenImplRegistryAbis.getMintFee],
functionName: MagicDropTokenImplRegistryAbis.getMintFee.name,
args: [standardId, implId],
});

const result = await this.client.call({
to: registryAddress,
data,
});

showText('Fetching mint fee...', '', false, false);

if (!result.data) return BigInt(0);

const decodedResult = decodeFunctionResult({
abi: [MagicDropTokenImplRegistryAbis.getMintFee],
functionName: MagicDropTokenImplRegistryAbis.getMintFee.name,
data: result.data,
});

return decodedResult;
} catch (error: any) {
console.error('Error fetching deployment fee:', error.message);
throw new Error('Failed to fetch deployment fee.');
}
}

public async setMintFee(
contractAddress: Hex,
mintFee: bigint,
): Promise<TransactionReceipt> {
try {
const data = encodeFunctionData({
abi: [SET_MINT_FEE_ABI],
functionName: SET_MINT_FEE_ABI.name,
args: [mintFee],
});

showText('Setting mint fee... this will take a moment', '', false, false);

const txHash = await this.sendTransaction({
to: contractAddress,
data,
});

const receipt = await this.waitForTransactionReceipt(txHash);

return receipt;
} catch (error: any) {
console.error('Error setting mint fee:', error.message);
throw new Error('Failed to set mint fee.');
}
}

/**
* Sends a transaction using METurnkeyServiceClient for signing.
*/
Expand Down
36 changes: 36 additions & 0 deletions cli-typescript/src/utils/cmdActions/setMintFeeAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Hex } from 'viem';
import { ContractManager } from '../ContractManager';
import { parseMintFee, setMintFee } from '../deployContract';
import { init } from '../evmUtils';
import { getProjectSigner } from '../turnkey';
import { showError } from '../display';
import { verifyContractDeployment } from '../common';

const setMintFeeAction = async (
symbol: string,
params: { mintFee: number },
) => {
try {
symbol = symbol.toLowerCase();

const { store } = init(symbol);
const config = store.data!;

verifyContractDeployment(config.deployment?.contract_address);

const { signer } = await getProjectSigner(symbol);

const cm = new ContractManager(config.chainId, signer, symbol);

await setMintFee({
cm,
contractAddress: config.deployment!.contract_address as Hex,
mintFee: parseMintFee(params.mintFee.toString()),
});
} catch (error: any) {
showError({ text: `Error initializing contract: ${error.message}` });
process.exit(1);
}
};

export default setMintFeeAction;
24 changes: 10 additions & 14 deletions cli-typescript/src/utils/cmdActions/setStagesAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ const sendERC721StagesTransaction = async (
const args = stagesData.map((stage) => {
return {
price: stage[0],
mintFee: stage[1],
walletLimit: stage[2],
merkleRoot: stage[3],
maxStageSupply: stage[4],
startTimeUnixSeconds: stage[5],
endTimeUnixSeconds: stage[6],
walletLimit: stage[1],
merkleRoot: stage[2],
maxStageSupply: stage[3],
startTimeUnixSeconds: stage[4],
endTimeUnixSeconds: stage[5],
} as {
price: bigint;
mintFee: bigint;
walletLimit: number;
merkleRoot: Hex;
maxStageSupply: number;
Expand Down Expand Up @@ -106,15 +104,13 @@ const sendERC1155SetupTransaction = async (
const args = stagesData.map((stage) => {
return {
price: stage[0],
mintFee: stage[1],
walletLimit: stage[2],
merkleRoot: stage[3],
maxStageSupply: stage[4],
startTimeUnixSeconds: stage[5],
endTimeUnixSeconds: stage[6],
walletLimit: stage[1],
merkleRoot: stage[2],
maxStageSupply: stage[3],
startTimeUnixSeconds: stage[4],
endTimeUnixSeconds: stage[5],
} as {
price: bigint[];
mintFee: bigint[];
walletLimit: number[];
merkleRoot: `0x${string}`[];
maxStageSupply: number[];
Expand Down
8 changes: 8 additions & 0 deletions cli-typescript/src/utils/cmdOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,11 @@ export const getConfigFileOption = () =>
Path to the project configuration file. This file contains the config for the collection.
`,
);

export const mintFeeOption = () =>
new Option(
'--mintFee <mintFee>',
`
The mint fee for the collection in ether. This value is used to set the mint fee for the collection.
`,
);
8 changes: 4 additions & 4 deletions cli-typescript/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ export const LIMITBREAK_TRANSFER_VALIDATOR_V3_BERACHAIN =
'0x721c002b0059009a671d00ad1700c9748146cd1b';

export const ABSTRACT_FACTORY_ADDRESS =
'0x4a08d3F6881c4843232EFdE05baCfb5eAaB35d19';
'0x01c1C2f5271aDeA338dAfba77121Fc20B5176620';
export const DEFAULT_FACTORY_ADDRESS =
'0x000000009e44eBa131196847C685F20Cd4b68aC4';
'0x00000000bEa935F8315156894Aa4a45D3c7a0075';

export const ABSTRACT_REGISTRY_ADDRESS =
'0x9b60ad31F145ec7EE3c559153bB57928B65C0F87';
'0x17c9921D99c1Fa6d3dC992719DA1123dCb2CaedA';
export const DEFAULT_REGISTRY_ADDRESS =
'0x00000000caF1E3978e291c5Fb53FeedB957eC146';
'0x000000000e447e71b2EC36CD62048Dd2a1Cd0a57';

export const ICREATOR_TOKEN_INTERFACE_ID = '0xad0d7f6c'; // type(ICreatorToken).interfaceId
export const TRUE_HEX =
Expand Down
Loading