Skip to content

Commit d6e6ca8

Browse files
Add compatibility warning to confidential token wrapper (#134)
* Add minting wrap note * Update contracts/token/extensions/ConfidentialFungibleTokenERC20Wrapper.sol * remove gen-nav * add gen-nav as local file * move warning to the top --------- Co-authored-by: Arr00 <13561405+arr00@users.noreply.github.com>
1 parent bccc89b commit d6e6ca8

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

contracts/token/extensions/ConfidentialFungibleTokenERC20Wrapper.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import {ConfidentialFungibleToken} from "./../ConfidentialFungibleToken.sol";
1414
* @dev A wrapper contract built on top of {ConfidentialFungibleToken} that allows wrapping an `ERC20` token
1515
* into a confidential fungible token. The wrapper contract implements the `IERC1363Receiver` interface
1616
* which allows users to transfer `ERC1363` tokens directly to the wrapper with a callback to wrap the tokens.
17+
*
18+
* WARNING: Minting assumes the full amount of the underlying token transfer has been received, hence some non-standard
19+
* tokens such as fee-on-transfer or other deflationary-type tokens are not supported by this wrapper.
1720
*/
1821
abstract contract ConfidentialFungibleTokenERC20Wrapper is ConfidentialFungibleToken, IERC1363Receiver {
1922
IERC20 private immutable _underlying;

scripts/gen-nav.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/gen-nav.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env node
2+
3+
const path = require('path');
4+
const glob = require('glob');
5+
const startCase = require('lodash.startcase');
6+
7+
const baseDir = process.argv[2];
8+
9+
const files = glob.sync(baseDir + '/**/*.adoc').map(f => path.relative(baseDir, f));
10+
11+
console.log('.API');
12+
13+
function getPageTitle(directory) {
14+
switch (directory) {
15+
case 'metatx':
16+
return 'Meta Transactions';
17+
default:
18+
return startCase(directory);
19+
}
20+
}
21+
22+
const menuItems = files.reduce(
23+
(acc, file) => {
24+
let current = acc;
25+
const doc = file.replace(baseDir, '');
26+
27+
const keys = doc
28+
.split('/')
29+
.filter(Boolean)
30+
.map(k => k.replace('.adoc', ''));
31+
32+
for (let i = 0; i < keys.length; i++) {
33+
current = current.items[keys[i]] ??= {
34+
name: startCase(keys[i]),
35+
dir: keys[i],
36+
items: {},
37+
doc,
38+
};
39+
}
40+
41+
return acc;
42+
},
43+
{
44+
items: {},
45+
},
46+
);
47+
48+
const arrayifyItems = items =>
49+
Object.entries(items).map(([k, v]) => {
50+
if (Object.keys(v.items ?? {}).length > 0) return [v, arrayifyItems(v.items)];
51+
return [k, v];
52+
});
53+
54+
const isString = v => typeof v === 'string';
55+
56+
const sortItems = items =>
57+
items.sort(([a], [b]) =>
58+
(isString(a) ? a : a.name).toLowerCase().localeCompare(isString(b) ? b : b.name, undefined, { numeric: true }),
59+
);
60+
61+
const print = (items, level = 1) => {
62+
items.forEach(([k, v]) => {
63+
if (v.doc || k?.doc)
64+
console.log(`${'*'.repeat(level)} xref:${v.doc || k.doc}[${getPageTitle(isString(k) ? k : k.name)}]`);
65+
else console.log(`${'*'.repeat(level)} ${getPageTitle(isString(k) ? k : k.name)}`);
66+
if (Array.isArray(v)) print(v, level + 1);
67+
});
68+
};
69+
70+
print(
71+
sortItems(arrayifyItems(menuItems.items)).map(([k, v]) => {
72+
if (v?.length > 0) return [k, sortItems(v)];
73+
return [k, v];
74+
}),
75+
);

0 commit comments

Comments
 (0)