Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERC-1155 Example #800

Merged
merged 78 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
a71ab50
Add basic contract skeleton
HCastano Jun 1, 2021
8c5ab59
Add dummy ERC-1155 trait implementations
HCastano Jun 1, 2021
38d6fde
Implement `balance_of` method
HCastano Jun 1, 2021
12b8c1c
First attempt at `balance_of_batch` implementation
HCastano Jun 1, 2021
82adb2f
Implement simple token transfer
HCastano Jun 2, 2021
344cef7
Flatten balances BTreeMap
HCastano Jun 2, 2021
c5d4ff8
Clean up account usage in tests
HCastano Jun 2, 2021
10b5072
Implement approval mechanism
HCastano Jun 2, 2021
f8b73e0
Fix bug when sending tokens to an account with zero balance
HCastano Jun 3, 2021
d2280f9
Check approvals before sending tokens
HCastano Jun 3, 2021
9d4d649
Suppress warnings
HCastano Jun 3, 2021
293b2cf
Appease Clippy
HCastano Jun 3, 2021
df723e5
Add crude support for token transfers to smart contracts
HCastano Jun 3, 2021
040bcde
Simplify check for smart contract-ness
HCastano Jun 3, 2021
9d073d4
Handle receiving tokens as a smart contract
HCastano Jun 3, 2021
68f99f9
Implement `safe_transfer_from` method
HCastano Jun 3, 2021
25e5b91
Only do approval and recipient checks during in batch transfers
HCastano Jun 3, 2021
8640f19
I was wrong about the compiler's cleverness...
HCastano Jun 3, 2021
ded172c
Add documentation about interface
HCastano Jun 4, 2021
404e218
Make better use of some imports
HCastano Jun 4, 2021
02e55b3
Disallow owners from approving themselves for token tranfers
HCastano Jun 4, 2021
bbe0369
Allow creating and minting tokens
HCastano Jun 4, 2021
adb3889
Derive default for storage struct
HCastano Jun 4, 2021
e31103b
Add note on on-chain panic
HCastano Jun 4, 2021
ae9df2d
Remove `with_balances` constructor
HCastano Jun 4, 2021
94f8ec8
RustFmt with Nightly
HCastano Jun 4, 2021
9611c0a
Tag on_received messages with selectors
HCastano Jun 7, 2021
ecf7c61
Add missing event
HCastano Jun 7, 2021
5e43bd6
Index topics in events
HCastano Jun 7, 2021
383ddaf
Remove note on BTreeSet usage
HCastano Jun 7, 2021
a025c74
Stop panicking on cross-contract call error
HCastano Jun 7, 2021
7a9da11
Nightly RustFmt
HCastano Jun 7, 2021
cbb66a8
Fix RustDoc links
HCastano Jun 7, 2021
51272c6
Merge branch 'master' into hc-erc-1155-example
HCastano Jun 9, 2021
0a4dbd7
Remove inline questions
HCastano Jun 9, 2021
d5d68ac
Remove unused `data` argument from `create/mint`
HCastano Jun 9, 2021
0280226
Rename magic value contants
HCastano Jun 9, 2021
673a494
Remove data argument from `mint/create` tests
HCastano Jun 9, 2021
db1c709
Use entry API when decreasing account balance
HCastano Jun 9, 2021
e95ddc0
Extract approvals pairs into struct
HCastano Jun 9, 2021
a6fd7ce
Improve some of the panic messages
HCastano Jun 9, 2021
58431b4
Cache calls to `self.env().caller()`
HCastano Jun 10, 2021
748825a
Allow `TransferSingle` events to contain Optional addresses
HCastano Jun 10, 2021
f07f2cf
Add logging around calls to `onERC1155Received`
HCastano Jun 11, 2021
57794c5
Improve debug message when receiving cross-contract results
HCastano Jun 11, 2021
03dffb5
Move warning lints to specific lines of code
HCastano Jun 14, 2021
3e79672
Format code
HCastano Jun 14, 2021
439cbf7
Remove backticks from URLs
HCastano Jun 17, 2021
871ec7c
Fix comment wording/typo
HCastano Jun 17, 2021
c7115d0
Add expected panic messages to tests
HCastano Jun 17, 2021
44dace6
Move imports related to x-contract calls closer to use site
HCastano Jun 17, 2021
097152e
Change selector bytes to hex for the humans
HCastano Jun 17, 2021
8085acd
Remove incorrect comment about off-chain environment testing
HCastano Jun 17, 2021
cfc53b9
Add documentation for `TokenId`
HCastano Jun 17, 2021
6b817a0
Nightly RustFmt
HCastano Jun 17, 2021
780f8be
Uppercase selector bytes
HCastano Jun 18, 2021
da9bce7
Don't repeat `erc_1155` in `Erc1155TokenReceiver` methods
HCastano Jun 18, 2021
a84df8d
Nightly RustFmt
HCastano Jun 18, 2021
5bdfbc9
Merge branch 'master' into hc-erc-1155-example
HCastano Jun 18, 2021
c66ec48
Appease the spellchecker
HCastano Jun 18, 2021
094a549
Use Environment typedef
HCastano Jun 22, 2021
412d20f
Allow tests to run in stable and experimental off-chain envs
HCastano Jun 22, 2021
312ec42
Add explanation as to why we don't accept tokens
HCastano Jun 22, 2021
b8a0b1b
Return `Result` when minting tokens
HCastano Jun 22, 2021
d6ca820
Allow (most) errors to be handled gracefully by caller
HCastano Jun 22, 2021
e0e3192
Nightly RustFmt
HCastano Jun 22, 2021
fe7e8ba
Add shorthand zero-address to allowed spelling list
HCastano Jun 22, 2021
1f9cdcf
Run tests with `--features ink-experimental-engine` in CI
HCastano Jun 23, 2021
0b4b1a2
Perform batch balance checks before trying to transfer tokens
HCastano Jun 23, 2021
c47a37b
Move smart contract transfer checks to their own helper function
HCastano Jun 23, 2021
8a20cfd
Appease Clippy
HCastano Jun 23, 2021
9cfa92f
Make `ensure` macro definition more explicit
HCastano Jun 24, 2021
f61184a
Iterate over values instead of references
HCastano Jun 24, 2021
1d72c26
Iterate over references again
HCastano Jun 24, 2021
9bfaa57
Return a value from `on_batch_received`
HCastano Jun 24, 2021
314c4c7
Merge branch 'master' into hc-erc-1155-example
HCastano Jun 25, 2021
32a6375
Don't collect into intermediate Vec
HCastano Jun 25, 2021
2bc2490
Wrap 0x00 in code blocks
HCastano Jul 5, 2021
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 .config/cargo_spellcheck.dic
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
80
0x00
HCastano marked this conversation as resolved.
Show resolved Hide resolved

WebAssembly
Wasm
Expand Down Expand Up @@ -50,6 +51,7 @@ interoperate
cryptographic
Polkadot
bitwise
URI

hasher/S
hashmap/S
Expand Down
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ examples-test-experimental-engine:
# We test only the examples for which the tests have already been migrated to
# use the experimental engine.
- cargo test --no-default-features --features std, ink-experimental-engine --verbose --manifest-path examples/erc20/Cargo.toml
- cargo test --no-default-features --features std, ink-experimental-engine --verbose --manifest-path examples/erc1155/Cargo.toml
- cargo test --no-default-features --features std, ink-experimental-engine --verbose --manifest-path examples/contract-terminate/Cargo.toml
- cargo test --no-default-features --features std, ink-experimental-engine --verbose --manifest-path examples/contract-transfer/Cargo.toml

Expand Down
9 changes: 9 additions & 0 deletions examples/erc1155/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore build artifacts from the local tests sub-crate.
/target/

# Ignore backup files creates by cargo fmt.
**/*.rs.bk

# Remove Cargo.lock when creating an executable, leave it for libraries
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
Cargo.lock
38 changes: 38 additions & 0 deletions examples/erc1155/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "erc1155"
version = "3.0.0-rc3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

[dependencies]
ink_primitives = { version = "3.0.0-rc3", path = "../../crates/primitives", default-features = false }
ink_metadata = { version = "3.0.0-rc3", path = "../../crates/metadata", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "3.0.0-rc3", path = "../../crates/env", default-features = false, features = ["ink-debug"] }
ink_storage = { version = "3.0.0-rc3", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc3", path = "../../crates/lang", default-features = false }
ink_prelude = { version = "3.0.0-rc3", path = "../../crates/prelude", default-features = false }

scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

[lib]
name = "erc1155"
path = "lib.rs"
crate-type = ["cdylib"]

[features]
default = ["std"]
std = [
"ink_primitives/std",
"ink_metadata",
"ink_metadata/std",
"ink_env/std",
"ink_storage/std",
"ink_lang/std",
"ink_prelude/std",
"scale/std",
"scale-info",
"scale-info/std",
]
ink-as-dependency = []
HCastano marked this conversation as resolved.
Show resolved Hide resolved
ink-experimental-engine = ["ink_env/ink-experimental-engine"]
Loading