create-stylus 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +7 -8
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/src/main.ts +2 -4
- package/src/tasks/copy-template-files.ts +7 -4
- package/src/utils/prompt-for-missing-options.ts +1 -1
- package/templates/base/package.json +1 -1
- package/templates/base/packages/nextjs/app/blockexplorer/_components/TransactionsTable.tsx +11 -9
- package/templates/base/packages/nextjs/app/debug/_components/contract/ContractUI.tsx +2 -2
- package/templates/base/packages/nextjs/app/debug/_components/contract/WriteOnlyFunctionForm.tsx +8 -4
- package/templates/base/packages/nextjs/components/scaffold-eth/Input/AddressInput.tsx +1 -9
- package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/AddressInfoDropdown.tsx +138 -24
- package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/RevealBurnerPKModal.tsx +59 -0
- package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/index.tsx +3 -2
- package/templates/base/packages/nextjs/eslint.config.mjs +6 -0
- package/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts +107 -28
- package/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts +5 -1
- package/templates/base/packages/nextjs/hooks/scaffold-eth/useTransactor.tsx +7 -5
- package/templates/base/packages/nextjs/icons/LightBugAntIcon.tsx +7 -7
- package/templates/base/packages/nextjs/next-env.d.ts +1 -0
- package/templates/base/packages/nextjs/package.json +4 -5
- package/templates/base/packages/nextjs/services/web3/wagmiConnectors.tsx +1 -0
- package/templates/base/packages/nextjs/styles/globals.css +28 -22
- package/templates/base/packages/nextjs/tailwind.config.js +1 -1
- package/templates/base/packages/nextjs/utils/scaffold-eth/contract.ts +74 -2
- package/templates/base/packages/stylus/scripts/deploy.ts +0 -8
- package/templates/base/packages/stylus/your-contract/Cargo.lock +4 -4
- package/templates/base/packages/stylus/your-contract/Cargo.toml +1 -1
- package/templates/base/packages/stylus/your-contract/src/lib.rs +3 -7
- package/templates/base/readme.md +56 -174
- package/templates/base/yarn.lock +239 -297
- package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/AngularWalletAddress.tsx +0 -223
- package/templates/base/packages/stylus/counter/.cargo/config.toml +0 -18
- package/templates/base/packages/stylus/counter/Cargo.lock +0 -5788
- package/templates/base/packages/stylus/counter/Cargo.toml +0 -46
- package/templates/base/packages/stylus/counter/rust-toolchain.toml +0 -2
- package/templates/base/packages/stylus/counter/src/lib.rs +0 -121
- package/templates/base/packages/stylus/counter/src/main.rs +0 -10
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
[package]
|
|
2
|
-
name = "counter"
|
|
3
|
-
version = "0.1.11"
|
|
4
|
-
edition = "2021"
|
|
5
|
-
license = "MIT OR Apache-2.0"
|
|
6
|
-
homepage = "https://github.com/OffchainLabs/stylus-hello-world"
|
|
7
|
-
repository = "https://github.com/OffchainLabs/stylus-hello-world"
|
|
8
|
-
keywords = ["arbitrum", "ethereum", "stylus", "alloy"]
|
|
9
|
-
description = "Stylus hello world example"
|
|
10
|
-
|
|
11
|
-
[dependencies]
|
|
12
|
-
alloy-primitives = "=0.8.20"
|
|
13
|
-
alloy-sol-types = "=0.8.20"
|
|
14
|
-
stylus-sdk = "0.9.0"
|
|
15
|
-
hex = { version = "0.4", default-features = false }
|
|
16
|
-
|
|
17
|
-
[dev-dependencies]
|
|
18
|
-
alloy-primitives = { version = "=0.8.20", features = ["sha3-keccak"] }
|
|
19
|
-
tokio = { version = "1.12.0", features = ["full"] }
|
|
20
|
-
ethers = "2.0"
|
|
21
|
-
eyre = "0.6.8"
|
|
22
|
-
stylus-sdk = { version = "0.9.0", features = ["stylus-test"] }
|
|
23
|
-
dotenv = "0.15.0"
|
|
24
|
-
|
|
25
|
-
[features]
|
|
26
|
-
default = ["mini-alloc"]
|
|
27
|
-
export-abi = ["stylus-sdk/export-abi"]
|
|
28
|
-
debug = ["stylus-sdk/debug"]
|
|
29
|
-
mini-alloc = ["stylus-sdk/mini-alloc"]
|
|
30
|
-
|
|
31
|
-
[[bin]]
|
|
32
|
-
name = "counter"
|
|
33
|
-
path = "src/main.rs"
|
|
34
|
-
|
|
35
|
-
[lib]
|
|
36
|
-
crate-type = ["lib", "cdylib"]
|
|
37
|
-
|
|
38
|
-
[profile.release]
|
|
39
|
-
codegen-units = 1
|
|
40
|
-
strip = true
|
|
41
|
-
lto = true
|
|
42
|
-
panic = "abort"
|
|
43
|
-
|
|
44
|
-
# If you need to reduce the binary size, it is advisable to try other
|
|
45
|
-
# optimization levels, such as "s" and "z"
|
|
46
|
-
opt-level = 3
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
//! Stylus Hello World
|
|
3
|
-
//!
|
|
4
|
-
//! The following contract implements the Counter example from Foundry.
|
|
5
|
-
//!
|
|
6
|
-
//! ```solidity
|
|
7
|
-
//! contract Counter {
|
|
8
|
-
//! uint256 public number;
|
|
9
|
-
//! function setNumber(uint256 newNumber) public {
|
|
10
|
-
//! number = newNumber;
|
|
11
|
-
//! }
|
|
12
|
-
//! function increment() public {
|
|
13
|
-
//! number++;
|
|
14
|
-
//! }
|
|
15
|
-
//! }
|
|
16
|
-
//! ```
|
|
17
|
-
//!
|
|
18
|
-
//! The program is ABI-equivalent with Solidity, which means you can call it from both Solidity and Rust.
|
|
19
|
-
//! To do this, run `cargo stylus export-abi`.
|
|
20
|
-
//!
|
|
21
|
-
//! Note: this code is a template-only and has not been audited.
|
|
22
|
-
//!
|
|
23
|
-
// Allow `cargo stylus export-abi` to generate a main function.
|
|
24
|
-
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]
|
|
25
|
-
#![cfg_attr(not(any(test, feature = "export-abi")), no_std)]
|
|
26
|
-
|
|
27
|
-
#[macro_use]
|
|
28
|
-
extern crate alloc;
|
|
29
|
-
|
|
30
|
-
use alloc::vec::Vec;
|
|
31
|
-
|
|
32
|
-
/// Import items from the SDK. The prelude contains common traits and macros.
|
|
33
|
-
use stylus_sdk::{alloy_primitives::U256, prelude::*};
|
|
34
|
-
|
|
35
|
-
// Define some persistent storage using the Solidity ABI.
|
|
36
|
-
// `Counter` will be the entrypoint.
|
|
37
|
-
sol_storage! {
|
|
38
|
-
#[entrypoint]
|
|
39
|
-
pub struct Counter {
|
|
40
|
-
uint256 number;
|
|
41
|
-
bool is_initialized;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/// Declare that `Counter` is a contract with the following external methods.
|
|
46
|
-
#[public]
|
|
47
|
-
impl Counter {
|
|
48
|
-
pub fn initialize(&mut self, initial_number: U256) {
|
|
49
|
-
if !self.is_initialized.get() {
|
|
50
|
-
self.number.set(initial_number);
|
|
51
|
-
self.is_initialized.set(true);
|
|
52
|
-
} else {
|
|
53
|
-
panic!("Counter already initialized");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/// Gets the number from storage.
|
|
58
|
-
pub fn number(&self) -> U256 {
|
|
59
|
-
self.number.get()
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/// Sets a number in storage to a user-specified value.
|
|
63
|
-
pub fn set_number(&mut self, new_number: U256) {
|
|
64
|
-
self.number.set(new_number);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/// Sets a number in storage to a user-specified value.
|
|
68
|
-
pub fn mul_number(&mut self, new_number: U256) {
|
|
69
|
-
self.number.set(new_number * self.number.get());
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/// Sets a number in storage to a user-specified value.
|
|
73
|
-
pub fn add_number(&mut self, new_number: U256) {
|
|
74
|
-
self.number.set(new_number + self.number.get());
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/// Increments `number` and updates its value in storage.
|
|
78
|
-
pub fn increment(&mut self) {
|
|
79
|
-
let number = self.number.get();
|
|
80
|
-
self.set_number(number + U256::from(1));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/// Adds the wei value from msg_value to the number in storage.
|
|
84
|
-
#[payable]
|
|
85
|
-
pub fn add_from_msg_value(&mut self) {
|
|
86
|
-
let number = self.number.get();
|
|
87
|
-
self.set_number(number + self.vm().msg_value());
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
#[cfg(test)]
|
|
92
|
-
mod test {
|
|
93
|
-
use super::*;
|
|
94
|
-
|
|
95
|
-
#[test]
|
|
96
|
-
fn test_counter() {
|
|
97
|
-
use stylus_sdk::testing::*;
|
|
98
|
-
let vm = TestVM::default();
|
|
99
|
-
let mut contract = Counter::from(&vm);
|
|
100
|
-
|
|
101
|
-
assert_eq!(U256::ZERO, contract.number());
|
|
102
|
-
|
|
103
|
-
contract.increment();
|
|
104
|
-
assert_eq!(U256::from(1), contract.number());
|
|
105
|
-
|
|
106
|
-
contract.add_number(U256::from(3));
|
|
107
|
-
assert_eq!(U256::from(4), contract.number());
|
|
108
|
-
|
|
109
|
-
contract.mul_number(U256::from(2));
|
|
110
|
-
assert_eq!(U256::from(8), contract.number());
|
|
111
|
-
|
|
112
|
-
contract.set_number(U256::from(100));
|
|
113
|
-
assert_eq!(U256::from(100), contract.number());
|
|
114
|
-
|
|
115
|
-
// Override the msg value for future contract method invocations.
|
|
116
|
-
vm.set_value(U256::from(2));
|
|
117
|
-
|
|
118
|
-
contract.add_from_msg_value();
|
|
119
|
-
assert_eq!(U256::from(102), contract.number());
|
|
120
|
-
}
|
|
121
|
-
}
|