Skip to content

Commit 9e37422

Browse files
committed
revert format changes
1 parent df02bfb commit 9e37422

File tree

2 files changed

+64
-80
lines changed

2 files changed

+64
-80
lines changed

packages/core/solidity/src/erc721.ts

Lines changed: 59 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
import { BaseFunction, Contract, ContractBuilder } from "./contract";
2-
import {
3-
Access,
4-
setAccessControl,
5-
requireAccessControl,
6-
} from "./set-access-control";
7-
import { addPauseFunctions } from "./add-pausable";
8-
import { supportsInterface } from "./common-functions";
9-
import { defineFunctions } from "./utils/define-functions";
10-
import {
11-
CommonOptions,
12-
withCommonDefaults,
13-
defaults as commonDefaults,
14-
} from "./common-options";
15-
import { setUpgradeable } from "./set-upgradeable";
16-
import { setInfo } from "./set-info";
17-
import { printContract } from "./print";
18-
import { ClockMode, clockModeDefault, setClockMode } from "./set-clock-mode";
1+
import { BaseFunction, Contract, ContractBuilder } from './contract';
2+
import { Access, setAccessControl, requireAccessControl } from './set-access-control';
3+
import { addPauseFunctions } from './add-pausable';
4+
import { supportsInterface } from './common-functions';
5+
import { defineFunctions } from './utils/define-functions';
6+
import { CommonOptions, withCommonDefaults, defaults as commonDefaults } from './common-options';
7+
import { setUpgradeable } from './set-upgradeable';
8+
import { setInfo } from './set-info';
9+
import { printContract } from './print';
10+
import { ClockMode, clockModeDefault, setClockMode } from './set-clock-mode';
1911

2012
export interface ERC721Options extends CommonOptions {
2113
name: string;
@@ -35,9 +27,9 @@ export interface ERC721Options extends CommonOptions {
3527
}
3628

3729
export const defaults: Required<ERC721Options> = {
38-
name: "MyToken",
39-
symbol: "MTK",
40-
baseUri: "",
30+
name: 'MyToken',
31+
symbol: 'MTK',
32+
baseUri: '',
4133
enumerable: false,
4234
uriStorage: false,
4335
burnable: false,
@@ -70,7 +62,7 @@ export function printERC721(opts: ERC721Options = defaults): string {
7062
}
7163

7264
export function isAccessControlRequired(opts: Partial<ERC721Options>): boolean {
73-
return opts.mintable || opts.pausable || opts.upgradeable === "uups";
65+
return opts.mintable || opts.pausable || opts.upgradeable === 'uups';
7466
}
7567

7668
export function buildERC721(opts: ERC721Options): Contract {
@@ -120,8 +112,8 @@ export function buildERC721(opts: ERC721Options): Contract {
120112

121113
function addPausableExtension(c: ContractBuilder, access: Access) {
122114
const ERC721Pausable = {
123-
name: "ERC721Pausable",
124-
path: "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol",
115+
name: 'ERC721Pausable',
116+
path: '@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol',
125117
};
126118
c.addParent(ERC721Pausable);
127119
c.addOverride(ERC721Pausable, functions._update);
@@ -130,8 +122,8 @@ function addPausableExtension(c: ContractBuilder, access: Access) {
130122
}
131123

132124
const ERC721 = {
133-
name: "ERC721",
134-
path: "@openzeppelin/contracts/token/ERC721/ERC721.sol",
125+
name: 'ERC721',
126+
path: '@openzeppelin/contracts/token/ERC721/ERC721.sol',
135127
};
136128

137129
function addBase(c: ContractBuilder, name: string, symbol: string) {
@@ -150,8 +142,8 @@ function addBaseURI(c: ContractBuilder, baseUri: string) {
150142

151143
function addEnumerable(c: ContractBuilder) {
152144
const ERC721Enumerable = {
153-
name: "ERC721Enumerable",
154-
path: "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol",
145+
name: 'ERC721Enumerable',
146+
path: '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol',
155147
};
156148
c.addParent(ERC721Enumerable);
157149

@@ -162,8 +154,8 @@ function addEnumerable(c: ContractBuilder) {
162154

163155
function addURIStorage(c: ContractBuilder) {
164156
const ERC721URIStorage = {
165-
name: "ERC721URIStorage",
166-
path: "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol",
157+
name: 'ERC721URIStorage',
158+
path: '@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol',
167159
};
168160
c.addParent(ERC721URIStorage);
169161

@@ -173,45 +165,40 @@ function addURIStorage(c: ContractBuilder) {
173165

174166
function addBurnable(c: ContractBuilder) {
175167
c.addParent({
176-
name: "ERC721Burnable",
177-
path: "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol",
168+
name: 'ERC721Burnable',
169+
path: '@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol',
178170
});
179171
}
180172

181-
function addMintable(
182-
c: ContractBuilder,
183-
access: Access,
184-
incremental = false,
185-
uriStorage = false
186-
) {
173+
function addMintable(c: ContractBuilder, access: Access, incremental = false, uriStorage = false) {
187174
const fn = getMintFunction(incremental, uriStorage);
188-
requireAccessControl(c, fn, access, "MINTER", "minter");
175+
requireAccessControl(c, fn, access, 'MINTER', 'minter');
189176

190177
if (incremental) {
191-
c.addVariable("uint256 private _nextTokenId;");
192-
c.addFunctionCode("uint256 tokenId = _nextTokenId++;", fn);
193-
c.addFunctionCode("_safeMint(to, tokenId);", fn);
178+
c.addVariable('uint256 private _nextTokenId;');
179+
c.addFunctionCode('uint256 tokenId = _nextTokenId++;', fn);
180+
c.addFunctionCode('_safeMint(to, tokenId);', fn);
194181
} else {
195-
c.addFunctionCode("_safeMint(to, tokenId);", fn);
182+
c.addFunctionCode('_safeMint(to, tokenId);', fn);
196183
}
197184

198185
if (uriStorage) {
199-
c.addFunctionCode("_setTokenURI(tokenId, uri);", fn);
186+
c.addFunctionCode('_setTokenURI(tokenId, uri);', fn);
200187
}
201188

202-
if (incremental) c.addFunctionCode("return tokenId;", fn);
189+
if (incremental) c.addFunctionCode('return tokenId;', fn);
203190
}
204191

205192
function addVotes(c: ContractBuilder, name: string, clockMode: ClockMode) {
206193
const EIP712 = {
207-
name: "EIP712",
208-
path: "@openzeppelin/contracts/utils/cryptography/EIP712.sol",
194+
name: 'EIP712',
195+
path: '@openzeppelin/contracts/utils/cryptography/EIP712.sol',
209196
};
210-
c.addParent(EIP712, [name, "1"]);
197+
c.addParent(EIP712, [name, '1']);
211198

212199
const ERC721Votes = {
213-
name: "ERC721Votes",
214-
path: "@openzeppelin/contracts/token/ERC721/extensions/ERC721Votes.sol",
200+
name: 'ERC721Votes',
201+
path: '@openzeppelin/contracts/token/ERC721/extensions/ERC721Votes.sol',
215202
};
216203
c.addParent(ERC721Votes);
217204

@@ -223,55 +210,52 @@ function addVotes(c: ContractBuilder, name: string, clockMode: ClockMode) {
223210

224211
const functions = defineFunctions({
225212
_update: {
226-
kind: "internal" as const,
213+
kind: 'internal' as const,
227214
args: [
228-
{ name: "to", type: "address" },
229-
{ name: "tokenId", type: "uint256" },
230-
{ name: "auth", type: "address" },
215+
{ name: 'to', type: 'address' },
216+
{ name: 'tokenId', type: 'uint256' },
217+
{ name: 'auth', type: 'address' },
231218
],
232-
returns: ["address"],
219+
returns: ['address'],
233220
},
234221

235222
tokenURI: {
236-
kind: "public" as const,
237-
args: [{ name: "tokenId", type: "uint256" }],
238-
returns: ["string memory"],
239-
mutability: "view" as const,
223+
kind: 'public' as const,
224+
args: [{ name: 'tokenId', type: 'uint256' }],
225+
returns: ['string memory'],
226+
mutability: 'view' as const,
240227
},
241228

242229
_baseURI: {
243-
kind: "internal" as const,
230+
kind: 'internal' as const,
244231
args: [],
245-
returns: ["string memory"],
246-
mutability: "pure" as const,
232+
returns: ['string memory'],
233+
mutability: 'pure' as const,
247234
},
248235

249236
_increaseBalance: {
250-
kind: "internal" as const,
237+
kind: 'internal' as const,
251238
args: [
252-
{ name: "account", type: "address" },
253-
{ name: "value", type: "uint128" },
239+
{ name: 'account', type: 'address' },
240+
{ name: 'value', type: 'uint128' },
254241
],
255242
},
256243
});
257244

258-
function getMintFunction(
259-
incremental: boolean,
260-
uriStorage: boolean
261-
): BaseFunction {
245+
function getMintFunction(incremental: boolean, uriStorage: boolean): BaseFunction {
262246
const fn: BaseFunction = {
263-
name: "safeMint",
264-
kind: "public" as const,
265-
args: [{ name: "to", type: "address" }],
266-
returns: incremental ? ["uint256"] : undefined,
247+
name: 'safeMint',
248+
kind: 'public' as const,
249+
args: [{ name: 'to', type: 'address' }],
250+
returns: incremental ? ['uint256'] : undefined,
267251
};
268252

269253
if (!incremental) {
270-
fn.args.push({ name: "tokenId", type: "uint256" });
254+
fn.args.push({ name: 'tokenId', type: 'uint256' });
271255
}
272256

273257
if (uriStorage) {
274-
fn.args.push({ name: "uri", type: "string memory" });
258+
fn.args.push({ name: 'uri', type: 'string memory' });
275259
}
276260

277261
return fn;
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import type { BaseFunction } from "../contract";
1+
import type { BaseFunction } from '../contract';
22

3-
type ImplicitNameFunction = Omit<BaseFunction, "name">;
3+
type ImplicitNameFunction = Omit<BaseFunction, 'name'>;
44

55
export function defineFunctions<F extends string>(
6-
fns: Record<F, ImplicitNameFunction>
6+
fns: Record<F, ImplicitNameFunction>,
77
): Record<F, BaseFunction>;
88

99
export function defineFunctions(
10-
fns: Record<string, ImplicitNameFunction>
10+
fns: Record<string, ImplicitNameFunction>,
1111
): Record<string, BaseFunction> {
1212
return Object.fromEntries(
13-
Object.entries(fns).map(([name, fn]) => [name, Object.assign({ name }, fn)])
13+
Object.entries(fns).map(([name, fn]) => [name, Object.assign({ name }, fn)]),
1414
);
1515
}

0 commit comments

Comments
 (0)