Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
b8e6f1e
start account
andrew-fleming Sep 3, 2024
9119f73
save progress
andrew-fleming Sep 4, 2024
27dfbd2
hook up account ui options
andrew-fleming Sep 5, 2024
fc86510
integrate upgrades and account access control, fix constructor
andrew-fleming Sep 6, 2024
a29b15b
add name to ui, clean up imports
andrew-fleming Sep 6, 2024
fe2c47a
clean up buildAccount logic
andrew-fleming Sep 6, 2024
c778cb8
improve account build fns
andrew-fleming Sep 8, 2024
ff0e9c0
clean up api
andrew-fleming Sep 10, 2024
b8d498b
clean up account
andrew-fleming Sep 10, 2024
62fdcdd
tidy up code
andrew-fleming Sep 10, 2024
d47006b
tmp fix for default val
andrew-fleming Sep 10, 2024
0528f1d
fix fmt
andrew-fleming Sep 10, 2024
69a4992
fix account controls
andrew-fleming Sep 10, 2024
5a51fe1
start tests
andrew-fleming Sep 10, 2024
56a15b7
Merge branch 'master' into add-cairo-account
andrew-fleming Sep 10, 2024
5d3fea8
add HelpTooltips
andrew-fleming Sep 10, 2024
84708d2
update snapshots
andrew-fleming Sep 10, 2024
a5e688e
move account tab
andrew-fleming Sep 12, 2024
ce23b6f
fix access fn
andrew-fleming Sep 12, 2024
7132e95
add account attr option to print
andrew-fleming Sep 12, 2024
f6d03cd
update tests
andrew-fleming Sep 12, 2024
9193ff7
fix tool tip description
andrew-fleming Sep 13, 2024
8f4b535
add accounts to default vals
andrew-fleming Sep 13, 2024
3b54d98
remove account cases from setAccessControl
andrew-fleming Sep 13, 2024
63eca66
add helper for account pathgen
andrew-fleming Sep 13, 2024
09a96f0
fix order
andrew-fleming Sep 13, 2024
b87b72e
set access as false for account
andrew-fleming Sep 13, 2024
6f7d5a8
fix deployable impl
andrew-fleming Sep 13, 2024
24474eb
remove isrc5 flag when not mixin
andrew-fleming Sep 13, 2024
73dc732
fix order
andrew-fleming Sep 13, 2024
5c737fd
add camel for src6 and publicKey
andrew-fleming Sep 13, 2024
3a0f84f
update snapshots
andrew-fleming Sep 13, 2024
d4b607a
fix fmt
andrew-fleming Sep 13, 2024
09a3651
fix fmt
andrew-fleming Sep 13, 2024
8eb7139
fix fmt
andrew-fleming Sep 13, 2024
58b9ded
remove unused imports
andrew-fleming Sep 13, 2024
747a510
Merge branch 'master' into add-cairo-account
ericglau Sep 13, 2024
4957094
Add account mapping to hyperlink injection
ericglau Sep 13, 2024
5bac023
Apply suggestions from code review
andrew-fleming Sep 14, 2024
2ed31e0
fix test names
andrew-fleming Sep 14, 2024
3e1727a
fix declarer feature name
andrew-fleming Sep 14, 2024
40ad8e3
match case order in buildGeneric
andrew-fleming Sep 14, 2024
f6a55e9
fix import order
andrew-fleming Sep 14, 2024
b781354
abstract upgradeable base logic
andrew-fleming Sep 15, 2024
5ddebeb
add line
andrew-fleming Sep 15, 2024
a04f9f2
use switch statements for account type
andrew-fleming Sep 16, 2024
cd06bad
Apply suggestions from code review
andrew-fleming Sep 16, 2024
e57cca8
add space between k/v
andrew-fleming Sep 16, 2024
6e9ef17
add options param, require isAccount
andrew-fleming Sep 16, 2024
c3c249f
update isAccount arg
andrew-fleming Sep 16, 2024
bdf0a40
update tests and snapshots
andrew-fleming Sep 16, 2024
3d90a16
fix fmt
andrew-fleming Sep 16, 2024
c866dc0
generate account in sources
andrew-fleming Sep 16, 2024
0da5329
add/integrate CommonContractOptions interface
andrew-fleming Sep 16, 2024
8f2b59d
update access test
andrew-fleming Sep 16, 2024
b208319
add account API interface, remove isAccessControlRequired from account
andrew-fleming Sep 16, 2024
190e5dd
Apply suggestions from code review
andrew-fleming Sep 17, 2024
4a97d68
update accountTypes name
andrew-fleming Sep 17, 2024
1a1b5fa
add account bool to contract interface
andrew-fleming Sep 17, 2024
6bd8959
check contract for account attr, remove isAccount from non-accounts
andrew-fleming Sep 17, 2024
d126892
remove isAccount from tests
andrew-fleming Sep 17, 2024
24e63cd
add changelog entry to core-cairo
andrew-fleming Sep 17, 2024
371cf55
remove commas
andrew-fleming Sep 17, 2024
fb26b01
fix buildAccount
andrew-fleming Sep 17, 2024
41da042
update account tests and snapshots
andrew-fleming Sep 17, 2024
e555286
update core-cairo readme
andrew-fleming Sep 17, 2024
dcec04f
fix printContract
andrew-fleming Sep 17, 2024
6f0a69a
fix eth test
andrew-fleming Sep 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/core-cairo/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Add Account and EthAccount. ([#387](https://github.com/OpenZeppelin/contracts-wizard/pull/387))

- **Breaking changes**:
- Use OpenZeppelin Contracts for Cairo v0.15.0. ([#378](https://github.com/OpenZeppelin/contracts-wizard/pull/378))
- Use OpenZeppelin Contracts for Cairo v0.16.0. ([#384](https://github.com/OpenZeppelin/contracts-wizard/pull/384))
Expand Down
9 changes: 9 additions & 0 deletions packages/core-cairo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The following contract types are supported:
- `erc20`
- `erc721`
- `erc1155`
- `account`
- `custom`

Each contract type has functions/constants as defined below.
Expand All @@ -33,6 +34,9 @@ function print(opts?: ERC721Options): string
function print(opts?: ERC1155Options): string
```
```js
function print(opts?: AccountOptions): string
```
```js
function print(opts?: CustomOptions): string
```
Returns a string representation of a contract generated using the provided options. If `opts` is not provided, uses [`defaults`](#defaults).
Expand All @@ -48,6 +52,9 @@ const defaults: Required<ERC721Options>
const defaults: Required<ERC1155Options>
```
```js
const defaults: Required<AccountOptions>
```
```js
const defaults: Required<CustomOptions>
```
The default options that are used for [`print`](#print).
Expand All @@ -67,6 +74,8 @@ function isAccessControlRequired(opts: Partial<CustomOptions>): boolean
```
Whether any of the provided options require access control to be enabled. If this returns `true`, then calling `print` with the same options would cause the `access` option to default to `'ownable'` if it was `undefined` or `false`.

> Note that account contracts handle permissions differently from the other supported contracts.
Thus, the `account` contract type does not include `isAccessControlRequired`.

### Contract specific functions

Expand Down
196 changes: 196 additions & 0 deletions packages/core-cairo/src/account.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
import test from 'ava';

import { buildAccount, AccountOptions } from './account';
import { printContract } from './print';

import { account } from '.';

function testAccount(title: string, opts: Partial<AccountOptions>) {
test(title, t => {
const c = buildAccount({
name: 'MyAccount',
type: 'stark',
...opts,
});
t.snapshot(printContract(c));
});
}

function testEthAccount(title: string, opts: Partial<AccountOptions>) {
test(title, t => {
const c = buildAccount({
name: 'MyAccount',
type: 'eth',
...opts,
});
t.snapshot(printContract(c));
});
}

/**
* Tests external API for equivalence with internal API
*/
function testAPIEquivalence(title: string, opts?: AccountOptions) {
test(title, t => {
t.is(account.print(opts), printContract(buildAccount({
name: 'MyAccount',
type: 'stark',
declare: true,
deploy: true,
pubkey: true,
...opts,
})));
});
}

testAccount('default full account, mixin + upgradeable', {});

testAccount('default full account, mixin + non-upgradeable', {
upgradeable: false
});

testAccount('explicit full account, mixin + upgradeable', {
name: 'MyAccount',
type: 'stark',
declare: true,
deploy: true,
pubkey: true,
upgradeable: true
});

testAccount('explicit full account, mixin + non-upgradeable', {
name: 'MyAccount',
type: 'stark',
declare: true,
deploy: true,
pubkey: true,
upgradeable: false
});

testAccount('basic account, upgradeable', {
declare: false,
deploy: false,
pubkey: false
});

testAccount('basic account, non-upgradeable', {
declare: false,
deploy: false,
pubkey: false,
upgradeable: false
});

testAccount('account declarer', {
deploy: false,
pubkey: false
});

testAccount('account deployable', {
declare: false,
pubkey: false
});

testAccount('account public key', {
declare: false,
deploy: false,
});

testAccount('account declarer, deployable', {
pubkey: false
});

testAccount('account declarer, public key', {
deploy: false
});

testAccount('account deployable, public key', {
declare: false
});

testEthAccount('default full ethAccount, mixin + upgradeable', {});

testEthAccount('default full ethAccount, mixin + non-upgradeable', {
upgradeable: false
});

testEthAccount('explicit full ethAccount, mixin + upgradeable', {
name: 'MyAccount',
type: 'eth',
declare: true,
deploy: true,
pubkey: true,
upgradeable: true
});

testEthAccount('explicit full ethAccount, mixin + non-upgradeable', {
name: 'MyAccount',
type: 'eth',
declare: true,
deploy: true,
pubkey: true,
upgradeable: false
});

testEthAccount('basic ethAccount, upgradeable', {
declare: false,
deploy: false,
pubkey: false
});

testEthAccount('basic ethAccount, non-upgradeable', {
declare: false,
deploy: false,
pubkey: false,
upgradeable: false
});

testEthAccount('ethAccount declarer', {
deploy: false,
pubkey: false
});

testEthAccount('ethAccount deployable', {
declare: false,
pubkey: false
});

testEthAccount('ethAccount public key', {
declare: false,
deploy: false,
});

testEthAccount('ethAccount declarer, deployable', {
pubkey: false
});

testEthAccount('ethAccount declarer, public key', {
deploy: false
});

testEthAccount('ethAccount deployable, public key', {
declare: false
});

testAPIEquivalence('account API default');

testAPIEquivalence('account API basic', {
name: 'CustomAccount',
type: 'stark',
declare: false,
deploy: false,
pubkey: false,
upgradeable: false,
});

testAPIEquivalence('account API full upgradeable', {
name: 'CustomAccount',
type: 'stark',
declare: true,
deploy: true,
pubkey: true,
upgradeable: true,
});

test('account API assert defaults', async t => {
t.is(account.print(account.defaults), account.print());
});
Loading