Skip to content

Commit b9e8fdd

Browse files
committed
chore: update facet manifest to latest
1 parent 4660319 commit b9e8fdd

File tree

2 files changed

+51
-32
lines changed

2 files changed

+51
-32
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ jobs:
4545
npm i -g ts-node
4646
mkdir -p ./dist
4747
cp package*.json ./dist
48-
REF=$GITHUB_REF_NAME npm run release
48+
npm run release
4949
env:
50-
REPO: github.com/flair-sdk/contracts
5150
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5251
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5352
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

scripts/dist.ts

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,45 @@ const chainConfig = {
2626
},
2727
};
2828

29-
type EIP165InterfaceID = string;
29+
// Examples: flair-sdk:token/ERC1155/ERC1155 openzeppelin:token/ERC1155/ERC1155
30+
export type FacetFqn = string;
3031

31-
type FacetManifest = {
32-
category: string;
33-
title: string;
34-
notice: string;
35-
icon?: string;
36-
repo: string;
37-
ref: string;
38-
fqn: string;
39-
version: string;
32+
// Examples: 1.2.0 ... 1.2.5-alpha.1
33+
export type SemanticVersion = string;
34+
35+
// Examples: flair-sdk:token/ERC1155/ERC1155:^1.2.0
36+
export type FacetReference = string;
37+
38+
// Examples: 0x80ac58cd
39+
export type EIP165InterfaceID = string;
40+
41+
// Examples: git+ssh://github.com/flair-dao/contracts.git#my-branch ... npm:@flair-sdk/[email protected]
42+
export type SourceReference = string;
43+
44+
export type FacetManifest = {
45+
// Mandatory
4046
addresses: Record<string, string>;
41-
providesInterfaces: EIP165InterfaceID[];
4247
functionSelectors: string[];
43-
peerDependencies: EIP165InterfaceID[];
44-
requiredDependencies: EIP165InterfaceID[];
48+
49+
// Recommended
50+
fqn?: FacetFqn;
51+
version?: SemanticVersion;
52+
providesInterfaces?: EIP165InterfaceID[];
53+
peerDependencies?: (EIP165InterfaceID | FacetReference)[];
54+
requiredDependencies?: (EIP165InterfaceID | FacetReference)[];
55+
56+
// Informational
57+
category?: string;
58+
title?: string;
59+
author?: string;
60+
notice?: string;
61+
icon?: string;
62+
source?: string;
4563
};
4664

65+
const FQN_PREFIX = 'flair-sdk:';
66+
const SOURCE_PREFIX = 'npm:@flair-sdk/contracts@';
67+
4768
async function main() {
4869
const distPath = path.resolve(__dirname, '../dist');
4970

@@ -134,7 +155,7 @@ async function main() {
134155
throw new Error(`Could not find contract ${artifactName} in src/ directory: ${JSON.stringify(files)}`);
135156
}
136157

137-
const contractFqn = files[0].split('.', -1)[0];
158+
const contractFqn = `${FQN_PREFIX}${files[0].split('.', -1)[0]}`;
138159

139160
if (!contractFqn) {
140161
throw new Error(`Could not get artifact key for ${file}`);
@@ -176,9 +197,8 @@ async function main() {
176197
const facets = await scanForFacets(
177198
buildInfo,
178199
contractFqnToChainToAddress,
179-
process.env.REPO || pkgJson?.repository?.url || 'unknown',
180-
process.env.REF || 'main',
181-
process.env.VERSION || pkgJson?.version || 'unknown',
200+
pkgJson?.version || 'unknown',
201+
`${SOURCE_PREFIX}${pkgJson?.version}`,
182202
);
183203
fse.writeJSONSync(path.resolve(distPath, 'facets.json'), facets);
184204
}
@@ -197,19 +217,18 @@ main()
197217
async function scanForFacets(
198218
buildInfo: any,
199219
addressesRegistry: Record<string, Record<string, string>>,
200-
repo: string,
201-
ref: string,
202220
version: string,
221+
source: string,
203222
): Promise<Record<string, FacetManifest>> {
204223
const facets: Record<string, FacetManifest> = {};
205224

206225
for (const [fqn, addresses] of Object.entries(addressesRegistry)) {
207226
const artifact = fqn.split('/').pop();
208-
const source = `src/${fqn}.sol`;
227+
const file = `src/${fqn.split(':')[1]}.sol`;
209228

210229
const annotations = {
211-
...((artifact && buildInfo?.output?.contracts?.[source]?.[artifact]?.devdoc) || {}),
212-
...((artifact && buildInfo?.output?.contracts?.[source]?.[artifact]?.userdoc) || {}),
230+
...((artifact && buildInfo?.output?.contracts?.[file]?.[artifact]?.devdoc) || {}),
231+
...((artifact && buildInfo?.output?.contracts?.[file]?.[artifact]?.userdoc) || {}),
213232
};
214233

215234
const {
@@ -227,22 +246,23 @@ async function scanForFacets(
227246
}
228247

229248
const functionSelectors = Object.keys(
230-
buildInfo?.output?.contracts?.[source]?.[artifact]?.evm.methodIdentifiers || {},
249+
buildInfo?.output?.contracts?.[file]?.[artifact]?.evm.methodIdentifiers || {},
231250
);
232251

233252
facets[fqn] = {
234-
category,
235-
title,
236-
notice,
237-
repo,
238-
ref,
239-
fqn,
240-
version,
241253
addresses,
242254
functionSelectors,
255+
256+
fqn,
257+
version,
243258
providesInterfaces: stringListToArray(providesInterfaces),
244259
peerDependencies: stringListToArray(peerDependencies),
245260
requiredDependencies: stringListToArray(requiredDependencies),
261+
262+
category,
263+
title,
264+
notice,
265+
source,
246266
};
247267
}
248268

0 commit comments

Comments
 (0)