Skip to content

Commit

Permalink
Merge pull request #54 from Brushfam/release/3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemka374 authored May 9, 2023
2 parents a255c21 + b2aa40a commit 13e82f3
Show file tree
Hide file tree
Showing 61 changed files with 85 additions and 85 deletions.
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ members = [
exclude = [
"examples",
"example_project_structure",
"mock"
]

[package]
name = "openbrush"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2018"

Expand All @@ -31,8 +30,8 @@ ink = { version = "4.1.0", default-features = false}
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }

openbrush_contracts = { version = "~3.0.0", path = "contracts", default-features = false }
openbrush_lang = { version = "~3.0.0", path = "lang", default-features = false }
openbrush_contracts = { version = "~3.1.1", path = "contracts", default-features = false }
openbrush_lang = { version = "~3.1.1", path = "lang", default-features = false }

[lib]
name = "openbrush"
Expand Down
4 changes: 2 additions & 2 deletions contracts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "openbrush_contracts"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand All @@ -19,7 +19,7 @@ ink = { version = "4.1.0", default-features = false}
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }

openbrush = { version = "~3.0.0", package = "openbrush_lang", path = "../lang", default-features = false }
openbrush = { version = "~3.1.1", package = "openbrush_lang", path = "../lang", default-features = false }

pallet-assets-chain-extension = { git = "https://github.com/727-ventures/pallet-assets-chain-extension", branch = "polkadot-v0.9.37", default-features = false, features = ["ink-lang"] }

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/smart-contracts/example/contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ implementation of `Lending` and `LendingPermissioned` traits defined in the `len
```toml
[package]
name = "lending_contract"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand All @@ -29,7 +29,7 @@ scale-info = { version = "2.3", default-features = false, features = ["derive"],
shares_contract = { path = "../shares", default-features = false, features = ["ink-as-dependency"] }
loan_contract = { path = "../loan", default-features = false, features = ["ink-as-dependency"] }
lending_project = { path = "../..", default-features = false }
openbrush = { version = "~3.0.0", default-features = false, features = ["pausable", "access_control"] }
openbrush = { version = "~3.1.1", default-features = false, features = ["pausable", "access_control"] }

[lib]
name = "lending_contract"
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/smart-contracts/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ scale = { package = "parity-scale-codec", version = "3", default-features = fals
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }

# Brush dependency
openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.0.0", default-features = false }
openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.1.1", default-features = false }

[features]
default = ["std"]
Expand Down Expand Up @@ -73,17 +73,17 @@ The name of the feature is the same as the name of the module. For example:

To enable `psp22`:
```toml
openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.0.0", default-features = false, features = ["psp22"] }
openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.1.1", default-features = false, features = ["psp22"] }
```

To enable `ownable`:
```toml
openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.0.0", default-features = false, features = ["ownable"] }
openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.1.1", default-features = false, features = ["ownable"] }
```

To enable both:
```toml
openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.0.0", default-features = false, features = ["psp22, ownable"] }
openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.1.1", default-features = false, features = ["psp22, ownable"] }
```

After enabling the feature and importing the corresponding module, you need to embed the module
Expand Down
1 change: 1 addition & 0 deletions docs/docs/smart-contracts/proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This example shows how you can use the implementation of [proxy](https://github.
## Disclaimer

Delegate calls [were marked](https://github.com/paritytech/ink/pull/1331#discussion_r953736863) as a possible attack vector in ink! Therefore the `Proxy` pattern will not work within OpenBrush until this is reimplemented in ink! 4.
You can use this tutorial for general understanding of `Proxy` pattern.

## Step 1: Import default implementation

Expand Down
34 changes: 18 additions & 16 deletions docs/docs/smart-contracts/upgradeable.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ Upgradeability allows experimenting and deploying the product at the early stage

Decentralization can be achieved by providing the right to upgrade only to decentralized authority like governance, multisig, or another analog.

There is also a possibility of smart contract upgradeability via `Proxy` and `Diamond` patterns, but these use `DelegateCall`. Delegate calls [were marked](https://github.com/paritytech/ink/pull/1331#discussion_r953736863) as a possible attack vector in ink! Therefore the `Proxy` and `Diamond` patterns will not work within OpenBrush until this is reimplemented in ink! 4.
There is also a possibility of smart contract upgradeability via `Proxy` and `Diamond` patterns, but these use `DelegateCall`.
Right now contracts that use `DelegateCall` are not supported by OpenBrush due to latest ink! changes, for more information, please check the following issues:

- https://github.com/paritytech/ink/pull/1331#discussion_r953736863
- https://github.com/Brushfam/openbrush-contracts/issues/36

Our team is currently working on the new approach of working with `DelegateCall`. For now, we recommend using `Lazy` struct
for the upgradeable contracts. `Lazy` is a wrapper for a storage field, that allows you to set it to its definite storage key.

## Storage layout

Expand Down Expand Up @@ -84,11 +91,12 @@ With this approach, you can order your units as you wish. You can add/remove/swa
logic units and don't worry about storage layout because each logic unit will have its space
in the blockchain's storage. If storage keys are unique, those spaces don't overlap.

OpenBrush provides [`openbrush::upgradeable_storage`](https://github.com/727-Ventures/openbrush-contracts/blob/main/lang/macro/src/lib.rs#L447)
attribute macro that implements all required traits with specified storage key(storage key is required input argument to macro).
Also, macro initializes the field with a default value if the field is not initialized before
(it can be actual during the upgrade because new fields are not initialized yet).
You can use that macro to define a logic unit.
OpenBrush provides [`openbrush::upgradeable_storage`](https://github.com/727-Ventures/openbrush-contracts/blob/main/lang/macro/src/lib.rs#L447)
attribute macro that implements some of the required traits with specified storage key(storage key is required input argument to macro).
This way, macro will define the storage key for this struct, but WILL NOT set this struct by it's storage key automatically.
So, you will need to perform such actions manually, or use `Lazy` wrapper. All of the `Lazy` and `Mapping` units that are defined inside of the type
will have their definite storage keys to prevent storage corruption, also it will implement traits to ease the work with storage,
like `Storage` to be accessible by using `.data()` method later.

> **Note**: Each logic unit should have a unique storage key.
The storage key should be used only once in the contract.
Expand Down Expand Up @@ -393,6 +401,9 @@ of your contract, permission system, etc.

### The `Diamond` Standard

### Disclaimer
Right now, you can't use diamond standard in OpenBrush because of the problems with delegate calls.

Using `Diamond` Standard you can add support for several facets(logic layers) that
can be upgraded. [This standard](https://eips.ethereum.org/EIPS/eip-2535) came
from the ethereum network. It works in the same way in ink! but instead of the
Expand All @@ -410,9 +421,6 @@ Each selector is unique and belongs only to one facet. So selectors of facets ca
call to the smart contract to the corresponding facet (logic layer).
`Diamond` contract has a function `diamond_cut` that allows registering each facet.

OpenBrush provides default implementation for `Diamond` standard on ink!.
For more details you can check [Diamond](diamond/diamond.md).

All suggestions above ideally describe how to develop an upgradeable contract
with multi-logic layers and many logic units.
So here we will describe how to write facets (logic layers) with OpenBrush.
Expand All @@ -425,13 +433,7 @@ with storage.
Each logic unit should have a unique storage key and be upgradeable (support initialization
on demand, use storage key as an offset for all inner fields). It can be a struct with
one or many fields (structs without fields are useless) or an enum with at least two
variants (an enum with one variant is a structure). You can define struct/enum with the
`openbrush::upgradeable_storage` macro and have an independent logic unit. You can
create several units and combine them into one contract.

> **Note**: If your contract has at least one field that is not defined with the
`openbrush::upgradeable_storage`, it will fail during execution. Each field should be
upgradeable in the facet.
variants (an enum with one variant is a structure).

As an example, we will define logic units for `PSP22` and `Ownable` facets.

Expand Down
2 changes: 1 addition & 1 deletion example_project_structure/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lending_project"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected], [email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion example_project_structure/contracts/lending/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lending_contract"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion example_project_structure/contracts/loan/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "loan_contract"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion example_project_structure/contracts/shares/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shares_contract"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion example_project_structure/contracts/stable_coin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "stable_coin_contract"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/access_control/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_access_control"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/access_control_extensions/enumerable/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_access_control_enumerable"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/alternatives/diamond/ink/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_diamond"
version = "3.0.0-beta.1"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/alternatives/diamond/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust_diamond"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/diamond/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_diamond"
version = "3.0.0-beta.1"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/diamond/diamond_caller/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "diamond_caller"
version = "3.0.0-beta.1"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/diamond/psp22_facet_v1/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_psp22_facet_v1"
version = "3.0.0-beta.1"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/diamond/psp22_facet_v2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_psp22_facet_v2"
version = "3.0.0-beta.1"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/diamond/psp22_metadata_facet/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_psp22_metadata_facet"
version = "3.0.0-beta.1"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flash_borrower"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/ownable/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_ownable"
version = "3.0.0-beta.1"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/pausable/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_pausable"
version = "3.0.0-beta.1"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/payment_splitter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_payment_splitter"
version = "3.0.0-beta.1"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/proxy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_proxy"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/proxy/psp22_metadata_upgradeable/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_psp22_metadata_upgradeable"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/proxy/psp22_upgradeable/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_psp22_upgradeable"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/psp22/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_psp22"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/psp22_extensions/burnable/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_psp22_burnable"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/psp22_extensions/capped/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_psp22_capped"
version = "3.0.0-beta.1"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/psp22_extensions/flashmint/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_psp22_flashmint"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/psp22_extensions/metadata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_psp22_metadata"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/psp22_extensions/mintable/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_psp22_mintable"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/psp22_extensions/pausable/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_psp22_pausable"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/psp22_extensions/wrapper/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_psp22_wrapper"
version = "3.0.0"
version = "3.1.1"
authors = ["Brushfam <[email protected]>"]
edition = "2021"

Expand Down
Loading

0 comments on commit 13e82f3

Please sign in to comment.