Skip to content

Commit f0c6d02

Browse files
authored
feat(magicdrop 2): freeze or thaw 721 contract (#227)
1 parent 46c99d7 commit f0c6d02

File tree

4 files changed

+22
-24
lines changed

4 files changed

+22
-24
lines changed

cli-typescript/src/abis/index.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,20 @@ export const TRANSFER_OWNERSHIP_ABI = {
142142
type: 'function',
143143
} as const;
144144

145+
export const SET_TRANSFERABLE_ABI = {
146+
inputs: [
147+
{
148+
internalType: 'bool',
149+
name: 'transferable',
150+
type: 'bool',
151+
},
152+
],
153+
name: 'setTransferable',
154+
outputs: [],
155+
stateMutability: 'nonpayable',
156+
type: 'function',
157+
} as const;
158+
145159
export const ERC712M_ABIS = {
146160
setup: {
147161
type: 'function',
@@ -380,19 +394,6 @@ export const ERC712M_ABIS = {
380394
};
381395

382396
export const ERC1155M_ABIS = {
383-
setTransferable: {
384-
inputs: [
385-
{
386-
internalType: 'bool',
387-
name: 'transferable',
388-
type: 'bool',
389-
},
390-
],
391-
name: 'setTransferable',
392-
outputs: [],
393-
stateMutability: 'nonpayable',
394-
type: 'function',
395-
},
396397
setup: {
397398
type: 'function',
398399
name: 'setup',

cli-typescript/src/cmds/general.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ export const freezeThawContractCmd = () =>
120120
.command('freeze-thaw-contract <symbol>')
121121
.alias('ftc')
122122
.alias('freeze-thaw')
123-
.description(
124-
`Freeze/Thaw contract. Support for ${TOKEN_STANDARD.ERC1155} only`,
125-
)
123+
.description('Freeze or Thaw contract.')
126124
.addOption(getFreezeThawOption().makeOptionMandatory())
127125
.action(freezeThawContractAction);
128126

cli-typescript/src/utils/ContractManager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
MagicDropTokenImplRegistryAbis,
3232
NEW_CONTRACT_INITIALIZED_EVENT_ABI,
3333
SET_TRANSFER_VALIDATOR_ABI,
34+
SET_TRANSFERABLE_ABI,
3435
SUPPORTS_INTERFACE_ABI,
3536
} from '../abis';
3637
import { printTransactionHash, showText } from './display';
@@ -358,8 +359,8 @@ export class ContractManager {
358359
);
359360

360361
const data = encodeFunctionData({
361-
abi: [ERC1155M_ABIS.setTransferable],
362-
functionName: ERC1155M_ABIS.setTransferable.name,
362+
abi: [SET_TRANSFERABLE_ABI],
363+
functionName: SET_TRANSFERABLE_ABI.name,
363364
args: [!freeze],
364365
});
365366

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ export const freezeThawContractAction = async (
1212
try {
1313
const { cm, config } = await actionPresets(symbol);
1414

15-
if (config.tokenStandard !== TOKEN_STANDARD.ERC1155)
16-
throw new Error(
17-
`this action is only supported for ${TOKEN_STANDARD.ERC1155} collections`,
18-
);
19-
2015
showText(
2116
`You're about to ${params.choice} the contract: ${config.deployment!.contract_address}`,
2217
'',
@@ -41,6 +36,9 @@ export const freezeThawContractAction = async (
4136
`Token transfers ${params.choice === 'freeze' ? 'frozen' : 'thawed'}.`,
4237
);
4338
} catch (error: any) {
44-
showError({ text: `Failed to ${params.choice}: ${error.message}` });
39+
showError({
40+
text: `Failed to ${params.choice}: ${error.message}`,
41+
subtext: `contract is probably already ${params.choice === 'freeze' ? 'frozen' : 'thawed'}. Try ${params.choice === 'freeze' ? 'thawing' : 'freezing'} it again.`,
42+
});
4543
}
4644
};

0 commit comments

Comments
 (0)