Skip to content

Commit b603d09

Browse files
MKVEERENDRACoveMBericglau
authored
Fix: Automatically use unicode syntax for token names with non-ASCII characters (#476)
Co-authored-by: CoveMB <[email protected]> Co-authored-by: Eric Lau <[email protected]>
1 parent ecc4826 commit b603d09

19 files changed

+152
-1
lines changed

.changeset/light-regions-design.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@openzeppelin/wizard': patch
3+
---
4+
5+
Use unicode syntax for strings with non-ASCII characters

packages/core/solidity/src/contract.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ test('contract basics', t => {
2222
t.snapshot(printContract(Foo));
2323
});
2424

25+
test('contract name is unicodeSafe', t => {
26+
const Foo = new ContractBuilder('Footeć');
27+
t.snapshot(printContract(Foo));
28+
});
29+
2530
test('contract with a parent', t => {
2631
const Foo = new ContractBuilder('Foo');
2732
const Bar = toParentContract('Bar', './Bar.sol');

packages/core/solidity/src/contract.test.ts.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ Generated by [AVA](https://avajs.dev).
1616
}␊
1717
`
1818

19+
## contract name is unicodeSafe
20+
21+
> Snapshot 1
22+
23+
`// SPDX-License-Identifier: MIT␊
24+
// Compatible with OpenZeppelin Contracts ^5.0.0␊
25+
pragma solidity ^0.8.27;␊
26+
27+
contract Footec {␊
28+
}␊
29+
`
30+
1931
## contract with a parent
2032

2133
> Snapshot 1
29 Bytes
Binary file not shown.

packages/core/solidity/src/custom.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ function testAPIEquivalence(title: string, opts?: CustomOptions) {
3434

3535
testCustom('custom', {});
3636

37+
testCustom('custom name is unicode safe', {
38+
name: 'ćontract',
39+
});
40+
3741
testCustom('pausable', {
3842
pausable: true,
3943
});

packages/core/solidity/src/custom.test.ts.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ Generated by [AVA](https://avajs.dev).
1616
}␊
1717
`
1818

19+
## custom name is unicode safe
20+
21+
> Snapshot 1
22+
23+
`// SPDX-License-Identifier: MIT␊
24+
// Compatible with OpenZeppelin Contracts ^5.0.0␊
25+
pragma solidity ^0.8.27;␊
26+
27+
contract Contract {␊
28+
}␊
29+
`
30+
1931
## pausable
2032

2133
> Snapshot 1
30 Bytes
Binary file not shown.

packages/core/solidity/src/erc1155.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ function testAPIEquivalence(title: string, opts?: ERC1155Options) {
3636

3737
testERC1155('basic', {});
3838

39+
testERC1155('name is unicodeSafe', { name: 'MyTokeć' });
40+
3941
testERC1155('basic + roles', {
4042
access: 'roles',
4143
});

packages/core/solidity/src/erc1155.test.ts.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,29 @@ Generated by [AVA](https://avajs.dev).
2727
}␊
2828
`
2929

30+
## name is unicodeSafe
31+
32+
> Snapshot 1
33+
34+
`// SPDX-License-Identifier: MIT␊
35+
// Compatible with OpenZeppelin Contracts ^5.0.0␊
36+
pragma solidity ^0.8.27;␊
37+
38+
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
39+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";␊
40+
41+
contract MyTokec is ERC1155, Ownable {␊
42+
constructor(address initialOwner)␊
43+
ERC1155("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/")␊
44+
Ownable(initialOwner)␊
45+
{}␊
46+
47+
function setURI(string memory newuri) public onlyOwner {␊
48+
_setURI(newuri);␊
49+
}␊
50+
}␊
51+
`
52+
3053
## basic + roles
3154

3255
> Snapshot 1
26 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)