Skip to content

Commit e4e99e0

Browse files
committed
feat: Magicdrop 1.0.2
- add mint-fee
1 parent 46c99d7 commit e4e99e0

File tree

11 files changed

+222
-57
lines changed

11 files changed

+222
-57
lines changed

cli-typescript/src/abis/index.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export const NEW_CONTRACT_INITIALIZED_EVENT_ABI = {
7575
{ name: 'standardId', type: 'uint8' },
7676
{ name: 'name', type: 'string' },
7777
{ name: 'symbol', type: 'string' },
78+
{ name: 'mintFee', type: 'uint256' },
7879
],
7980
} as const;
8081

@@ -142,6 +143,20 @@ export const TRANSFER_OWNERSHIP_ABI = {
142143
type: 'function',
143144
} as const;
144145

146+
export const SET_MINT_FEE_ABI = {
147+
inputs: [
148+
{
149+
internalType: 'uint256',
150+
name: 'mintFee',
151+
type: 'uint256',
152+
},
153+
],
154+
name: 'setMintFee',
155+
outputs: [],
156+
stateMutability: 'nonpayable',
157+
type: 'function',
158+
} as const;
159+
145160
export const ERC712M_ABIS = {
146161
setup: {
147162
type: 'function',
@@ -253,11 +268,6 @@ export const ERC712M_ABIS = {
253268
name: 'price',
254269
type: 'uint80',
255270
},
256-
{
257-
internalType: 'uint80',
258-
name: 'mintFee',
259-
type: 'uint80',
260-
},
261271
{
262272
internalType: 'uint32',
263273
name: 'walletLimit',
@@ -511,11 +521,6 @@ export const ERC1155M_ABIS = {
511521
name: 'price',
512522
type: 'uint80[]',
513523
},
514-
{
515-
internalType: 'uint80[]',
516-
name: 'mintFee',
517-
type: 'uint80[]',
518-
},
519524
{
520525
internalType: 'uint32[]',
521526
name: 'walletLimit',

cli-typescript/src/cmds/createCommand.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
setGlobalWalletLimitCmd,
2828
setMaxMintableSupplyCmd,
2929
setMintableCmd,
30+
setMintFeeCmd,
3031
setStagesCmd,
3132
setTimestampExpiryCmd,
3233
setTokenURISuffixCmd,
@@ -203,6 +204,7 @@ export const createEvmCommand = ({
203204
newCmd.addCommand(initContractCmd());
204205
newCmd.addCommand(setUriCmd());
205206
newCmd.addCommand(setStagesCmd());
207+
newCmd.addCommand(setMintFeeCmd());
206208
newCmd.addCommand(setGlobalWalletLimitCmd());
207209
newCmd.addCommand(setMaxMintableSupplyCmd());
208210
newCmd.addCommand(setCosginerCmd());

cli-typescript/src/cmds/general.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
getTokenIdOption,
1717
getTokenUriSuffixOption,
1818
getUriOption,
19+
mintFeeOption,
1920
} from '../utils/cmdOptions';
2021
import newWalletAction from '../utils/cmdActions/newWalletAction';
2122
import setUriAction from '../utils/cmdActions/setUriAction';
@@ -36,6 +37,7 @@ import { ownerMintAction } from '../utils/cmdActions/ownerMintAction';
3637
import { checkSignerBalanceAction } from '../utils/cmdActions/checkSignerBalanceAction';
3738
import getWalletInfoAction from '../utils/cmdActions/getWalletInfoAction';
3839
import getProjectConfigAction from '../utils/cmdActions/getProjectConfigAction';
40+
import setMintFeeAction from '../utils/cmdActions/setMintFeeAction';
3941

4042
export const createNewWalletCmd = () =>
4143
new Command('create-wallet')
@@ -196,3 +198,11 @@ export const checkSignerBalanceCmd = () =>
196198
.alias('csb')
197199
.description('Check the balance of the signer account for the collection.')
198200
.action(checkSignerBalanceAction);
201+
202+
export const setMintFeeCmd = () =>
203+
new Command('set-mint-fee')
204+
.command('set-mint-fee <symbol>')
205+
.alias('smf')
206+
.description('set the mint fee for the collection')
207+
.addOption(mintFeeOption().makeOptionMandatory())
208+
.action(setMintFeeAction);

cli-typescript/src/utils/ContractManager.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
MagicDropCloneFactoryAbis,
3131
MagicDropTokenImplRegistryAbis,
3232
NEW_CONTRACT_INITIALIZED_EVENT_ABI,
33+
SET_MINT_FEE_ABI,
3334
SET_TRANSFER_VALIDATOR_ABI,
3435
SUPPORTS_INTERFACE_ABI,
3536
} from '../abis';
@@ -99,6 +100,67 @@ export class ContractManager {
99100
}
100101
}
101102

103+
public async getMintFee(
104+
registryAddress: Hex,
105+
standardId: number,
106+
implId: number,
107+
): Promise<bigint> {
108+
try {
109+
const data = encodeFunctionData({
110+
abi: [MagicDropTokenImplRegistryAbis.getMintFee],
111+
functionName: MagicDropTokenImplRegistryAbis.getMintFee.name,
112+
args: [standardId, implId],
113+
});
114+
115+
const result = await this.client.call({
116+
to: registryAddress,
117+
data,
118+
});
119+
120+
showText('Fetching mint fee...', '', false, false);
121+
122+
if (!result.data) return BigInt(0);
123+
124+
const decodedResult = decodeFunctionResult({
125+
abi: [MagicDropTokenImplRegistryAbis.getMintFee],
126+
functionName: MagicDropTokenImplRegistryAbis.getMintFee.name,
127+
data: result.data,
128+
});
129+
130+
return decodedResult;
131+
} catch (error: any) {
132+
console.error('Error fetching deployment fee:', error.message);
133+
throw new Error('Failed to fetch deployment fee.');
134+
}
135+
}
136+
137+
public async setMintFee(
138+
contractAddress: Hex,
139+
mintFee: bigint,
140+
): Promise<TransactionReceipt> {
141+
try {
142+
const data = encodeFunctionData({
143+
abi: [SET_MINT_FEE_ABI],
144+
functionName: SET_MINT_FEE_ABI.name,
145+
args: [mintFee],
146+
});
147+
148+
showText('Setting mint fee... this will take a moment', '', false, false);
149+
150+
const txHash = await this.sendTransaction({
151+
to: contractAddress,
152+
data,
153+
});
154+
155+
const receipt = await this.waitForTransactionReceipt(txHash);
156+
157+
return receipt;
158+
} catch (error: any) {
159+
console.error('Error setting mint fee:', error.message);
160+
throw new Error('Failed to set mint fee.');
161+
}
162+
}
163+
102164
/**
103165
* Sends a transaction using METurnkeyServiceClient for signing.
104166
*/
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Hex } from 'viem';
2+
import { ContractManager } from '../ContractManager';
3+
import { parseMintFee, setMintFee } from '../deployContract';
4+
import { init } from '../evmUtils';
5+
import { getProjectSigner } from '../turnkey';
6+
import { showError } from '../display';
7+
import { verifyContractDeployment } from '../common';
8+
9+
const setMintFeeAction = async (
10+
symbol: string,
11+
params: { mintFee: number },
12+
) => {
13+
try {
14+
symbol = symbol.toLowerCase();
15+
16+
const { store } = init(symbol);
17+
const config = store.data!;
18+
19+
verifyContractDeployment(config.deployment?.contract_address);
20+
21+
const { signer } = await getProjectSigner(symbol);
22+
23+
const cm = new ContractManager(config.chainId, signer, symbol);
24+
25+
await setMintFee({
26+
cm,
27+
contractAddress: config.deployment!.contract_address as Hex,
28+
mintFee: parseMintFee(params.mintFee.toString()),
29+
});
30+
} catch (error: any) {
31+
showError({ text: `Error initializing contract: ${error.message}` });
32+
process.exit(1);
33+
}
34+
};
35+
36+
export default setMintFeeAction;

cli-typescript/src/utils/cmdActions/setStagesAction.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,13 @@ const sendERC721StagesTransaction = async (
6363
const args = stagesData.map((stage) => {
6464
return {
6565
price: stage[0],
66-
mintFee: stage[1],
67-
walletLimit: stage[2],
68-
merkleRoot: stage[3],
69-
maxStageSupply: stage[4],
70-
startTimeUnixSeconds: stage[5],
71-
endTimeUnixSeconds: stage[6],
66+
walletLimit: stage[1],
67+
merkleRoot: stage[2],
68+
maxStageSupply: stage[3],
69+
startTimeUnixSeconds: stage[4],
70+
endTimeUnixSeconds: stage[5],
7271
} as {
7372
price: bigint;
74-
mintFee: bigint;
7573
walletLimit: number;
7674
merkleRoot: Hex;
7775
maxStageSupply: number;
@@ -106,15 +104,13 @@ const sendERC1155SetupTransaction = async (
106104
const args = stagesData.map((stage) => {
107105
return {
108106
price: stage[0],
109-
mintFee: stage[1],
110-
walletLimit: stage[2],
111-
merkleRoot: stage[3],
112-
maxStageSupply: stage[4],
113-
startTimeUnixSeconds: stage[5],
114-
endTimeUnixSeconds: stage[6],
107+
walletLimit: stage[1],
108+
merkleRoot: stage[2],
109+
maxStageSupply: stage[3],
110+
startTimeUnixSeconds: stage[4],
111+
endTimeUnixSeconds: stage[5],
115112
} as {
116113
price: bigint[];
117-
mintFee: bigint[];
118114
walletLimit: number[];
119115
merkleRoot: `0x${string}`[];
120116
maxStageSupply: number[];

cli-typescript/src/utils/cmdOptions.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,11 @@ export const getConfigFileOption = () =>
159159
Path to the project configuration file. This file contains the config for the collection.
160160
`,
161161
);
162+
163+
export const mintFeeOption = () =>
164+
new Option(
165+
'--mintFee <mintFee>',
166+
`
167+
The mint fee for the collection in ether. This value is used to set the mint fee for the collection.
168+
`,
169+
);

cli-typescript/src/utils/constants.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ export const LIMITBREAK_TRANSFER_VALIDATOR_V3_BERACHAIN =
3434
'0x721c002b0059009a671d00ad1700c9748146cd1b';
3535

3636
export const ABSTRACT_FACTORY_ADDRESS =
37-
'0x4a08d3F6881c4843232EFdE05baCfb5eAaB35d19';
37+
'0x01c1C2f5271aDeA338dAfba77121Fc20B5176620';
3838
export const DEFAULT_FACTORY_ADDRESS =
39-
'0x000000009e44eBa131196847C685F20Cd4b68aC4';
39+
'0x00000000bEa935F8315156894Aa4a45D3c7a0075';
4040

4141
export const ABSTRACT_REGISTRY_ADDRESS =
42-
'0x9b60ad31F145ec7EE3c559153bB57928B65C0F87';
42+
'0x17c9921D99c1Fa6d3dC992719DA1123dCb2CaedA';
4343
export const DEFAULT_REGISTRY_ADDRESS =
44-
'0x00000000caF1E3978e291c5Fb53FeedB957eC146';
44+
'0x000000000e447e71b2EC36CD62048Dd2a1Cd0a57';
4545

4646
export const ICREATOR_TOKEN_INTERFACE_ID = '0xad0d7f6c'; // type(ICreatorToken).interfaceId
4747
export const TRUE_HEX =

0 commit comments

Comments
 (0)