-
Notifications
You must be signed in to change notification settings - Fork 130
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
[ISSUES#394]Update Snfoundry package to support starknet foundry script #426
base: starknet-foundry
Are you sure you want to change the base?
Changes from 114 commits
1be995f
a1b117e
9705812
cd6e31d
a84e277
e5dc4bf
0865d93
e37b20f
94327c7
6a8af0b
2c9d168
1a4abd0
8c90f64
bc26d24
5ae732f
d258d60
f343e25
ed0f216
d229d47
f95a0fa
7b0e55f
731903a
3253cc8
4e9a63f
e53fc15
260a00a
cac2446
59d4844
d72f170
935c0ca
0585e32
b96a778
50d3cc3
163d3a4
04eb6fb
5cd9299
1af0532
f87d552
0759535
43fc444
aa1a548
55e96bf
f2df1d3
b508265
1266242
d8f3ae0
bf111aa
17a1d55
61f08d7
07e8a56
5a3bf1a
bbc5525
ee8034d
d710a0b
9739ec4
abb9642
92ea3d5
74235b0
037793f
8e3c0f1
67ed378
aa08fc4
e6cb504
cfff51e
bea975c
977dbc8
27938d4
ae3803b
e47c5e3
f46ced0
7a65992
8ff9e3b
83493d7
d1fc936
44a8710
127d742
137be8d
611313b
24e49b0
7a0bf16
dce9bc2
6e9eb83
1f7e5fe
ffdb0b3
2e2f220
16825c8
edfd162
5083c24
07b2713
dfdf0fc
03fc22c
c4d5efd
995c122
8257222
5af2fb3
494fd3c
10de039
fbd7461
5ac2e5e
232fd7a
922f8ee
86aa1be
06cf48e
5670537
a850dca
3fd4002
e554410
cfa08df
aa1d3ff
6d18667
2f4d99c
7ab2a9b
6cbe572
f821bd7
1bfe300
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
## Devnet | ||
# PRIVATE_KEY_DEVNET=0x0000000000000000000000000000000071d7bb07b9a64f6f78ac4c816aff4da9 | ||
# ## Devnet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it necessary to change this flie? |
||
# PRIVATE_KEY_DEVNET=0x57b2f8431c772e647712ae93cc616638 | ||
# RPC_URL_DEVNET=http://127.0.0.1:5050 | ||
# ## last staknet devnet account address | ||
# ACCOUNT_ADDRESS_DEVNET=0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691 | ||
# ACCOUNT_ADDRESS_DEVNET=0x4b3f4ba8c00a02b66142a4b1dd41a4dfab4f92650922a3280977b0f03c75ee1 | ||
|
||
## Sepolia | ||
## Sepolia | ||
PRIVATE_KEY_SEPOLIA= | ||
RPC_URL_SEPOLIA=https://starknet-sepolia.public.blastapi.io/rpc/v0_7 | ||
ACCOUNT_ADDRESS_SEPOLIA= | ||
|
||
## Mainnet | ||
PRIVATE_KEY_MAINNET= | ||
RPC_URL_MAINNET= | ||
ACCOUNT_ADDRESS_MAINNET= | ||
ACCOUNT_ADDRESS_SEPOLIA= |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ snforge_std = "0.35.1" | |
|
||
[[target.starknet-contract]] | ||
casm = true | ||
sierra = true | ||
|
||
[tool.fmt] | ||
sort-module-level-items = true | ||
|
@@ -26,8 +27,7 @@ name = "SEPOLIA_LATEST" | |
url = "https://starknet-sepolia.public.blastapi.io/rpc/v0_7" | ||
block_id.tag = "latest" | ||
|
||
|
||
[lib] | ||
sierra = true | ||
casm = true | ||
|
||
[workspace] | ||
members = ["scripts"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should keep the sricpt to point to the new scarb. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod YourContract; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"version": "0.0.1", | ||
"scripts": { | ||
"chain": "starknet-devnet --seed 0 --account-class cairo1", | ||
"deploy": "ts-node scripts-ts/helpers/deploy-wrapper.ts", | ||
"deploy": "ts-node ./scripts-ts/helpers/command.ts deploy", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the main idea is to keep it in a branch snfoundry, wouldn't it be better to add it as a different deploy or adjust as you are doing What do you think @jrcarlos2000 ? |
||
"deploy:no-reset": "yarn workspace @ss-2/snfoundry deploy --no-reset", | ||
"test": "cd contracts && snforge test", | ||
"test-eslint": "node eslint-contract-name/eslint-plugin-contract-names.test.js", | ||
|
@@ -26,7 +26,6 @@ | |
}, | ||
"dependencies": { | ||
"dotenv": "^16.3.1", | ||
"dotenv-cli": "^7.4.2", | ||
"envfile": "^6.18.0", | ||
"prettier": "^2.8.8", | ||
"starknet": "6.12.1", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
# about script | ||
|
||
## how to run it | ||
|
||
- dev | ||
|
||
using `yarn deploy` to run. it will return this | ||
|
||
```bash | ||
|
||
No network specified. Running deployment on Devnet by default... | ||
command: account import | ||
error: Account with name = scaffold-devnet-account-1 already exists in network with chain_id = SN_SEPOLIA | ||
/Users/zhengpeng/Source/Code/Rust-Code/Github/scaffold-stark-2/packages/snfoundry | ||
warn: found duplicate packages named `addition v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` | ||
|
||
Found locations: | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
|
||
Because of this, referencing package `addition v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` will fail. | ||
|
||
warn: found duplicate packages named `fibonacci v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` | ||
|
||
Found locations: | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
|
||
Because of this, referencing package `fibonacci v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` will fail. | ||
|
||
warn: found duplicate packages named `hello_workspaces v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` | ||
|
||
Found locations: | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
|
||
Because of this, referencing package `hello_workspaces v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` will fail. | ||
|
||
Compiling lib(deploy_script) deploy_script v0.1.0 (/Users/zhengpeng/Source/Code/Rust-Code/Github/scaffold-stark-2/packages/snfoundry/scripts/Scarb.toml) | ||
Compiling starknet-contract(deploy_script) deploy_script v0.1.0 (/Users/zhengpeng/Source/Code/Rust-Code/Github/scaffold-stark-2/packages/snfoundry/scripts/Scarb.toml) | ||
Finished `dev` profile target(s) in 27 seconds | ||
warn: found duplicate packages named `addition v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` | ||
|
||
Found locations: | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
|
||
Because of this, referencing package `addition v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` will fail. | ||
|
||
warn: found duplicate packages named `fibonacci v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` | ||
|
||
Found locations: | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
|
||
Because of this, referencing package `fibonacci v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` will fail. | ||
|
||
warn: found duplicate packages named `hello_workspaces v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` | ||
|
||
Found locations: | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
|
||
Because of this, referencing package `hello_workspaces v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` will fail. | ||
|
||
Compiling lib(deploy_script) deploy_script v0.1.0 (/Users/zhengpeng/Source/Code/Rust-Code/Github/scaffold-stark-2/packages/snfoundry/scripts/Scarb.toml) | ||
Compiling starknet-contract(deploy_script) deploy_script v0.1.0 (/Users/zhengpeng/Source/Code/Rust-Code/Github/scaffold-stark-2/packages/snfoundry/scripts/Scarb.toml) | ||
Finished `dev` profile target(s) in 28 seconds | ||
Transaction hash: 0xedd4d2ff76d1de9a3110b9cf7aa020e50ff261613afd61ed62429e54c22424 | ||
declare result: class_hash: 2220056144819685874043888308841394761649577173077632235532171433250405236380, transaction_hash: 420211613070310794540196665175886258466526813601834003686575940845453845540 | ||
Transaction hash: 0x490873c5d820eac12c12e755f212fb895b12cd0fc0551a59c503218c764f191 | ||
Deployed the contract to address: contract_address: 152297156873262939265739539437283576539942821834396675633022867366606687161, transaction_hash: 2064610734862315252645720349992541243237703364262357271742237055097709588881 | ||
command: script run | ||
status: success | ||
|
||
|
||
``` | ||
|
||
|
||
- sepolia | ||
using `yarn deploy --network sepolia` to run. it will return this | ||
|
||
```bash | ||
sepolia network specified. Running... | ||
command: account import | ||
error: Account with name = scaffold-sepolia-account-1 already exists in network with chain_id = SN_SEPOLIA | ||
/Users/zhengpeng/Source/Code/Rust-Code/Github/scaffold-stark-2/packages/snfoundry | ||
warn: found duplicate packages named `addition v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` | ||
|
||
Found locations: | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
|
||
Because of this, referencing package `addition v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` will fail. | ||
|
||
warn: found duplicate packages named `fibonacci v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` | ||
|
||
Found locations: | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
|
||
Because of this, referencing package `fibonacci v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` will fail. | ||
|
||
warn: found duplicate packages named `hello_workspaces v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` | ||
|
||
Found locations: | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
|
||
Because of this, referencing package `hello_workspaces v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` will fail. | ||
|
||
Compiling lib(deploy_script) deploy_script v0.1.0 (/Users/zhengpeng/Source/Code/Rust-Code/Github/scaffold-stark-2/packages/snfoundry/scripts/Scarb.toml) | ||
Compiling starknet-contract(deploy_script) deploy_script v0.1.0 (/Users/zhengpeng/Source/Code/Rust-Code/Github/scaffold-stark-2/packages/snfoundry/scripts/Scarb.toml) | ||
Finished `dev` profile target(s) in 89 seconds | ||
warn: found duplicate packages named `addition v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` | ||
|
||
Found locations: | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
|
||
Because of this, referencing package `addition v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` will fail. | ||
|
||
warn: found duplicate packages named `fibonacci v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` | ||
|
||
Found locations: | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
|
||
Because of this, referencing package `fibonacci v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` will fail. | ||
|
||
warn: found duplicate packages named `hello_workspaces v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` | ||
|
||
Found locations: | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
- git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a | ||
|
||
Because of this, referencing package `hello_workspaces v0.1.0 (git+https://github.com/foundry-rs/starknet-foundry?tag=v0.35.1#089de2c7a391372a7aaa54ec2706b117f955d06a)` will fail. | ||
|
||
Compiling lib(deploy_script) deploy_script v0.1.0 (/Users/zhengpeng/Source/Code/Rust-Code/Github/scaffold-stark-2/packages/snfoundry/scripts/Scarb.toml) | ||
Compiling starknet-contract(deploy_script) deploy_script v0.1.0 (/Users/zhengpeng/Source/Code/Rust-Code/Github/scaffold-stark-2/packages/snfoundry/scripts/Scarb.toml) | ||
Finished `dev` profile target(s) in 26 seconds | ||
command: script run | ||
message: | ||
0x6465636c617265206661696c6564 ('declare failed') | ||
|
||
status: script panicked | ||
|
||
|
||
``` | ||
|
||
|
||
## current may Troubled problem | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is one of the main problems when integrating in the main, we must have it under control, once it is solved we could revaluate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes! It must be resolved, otherwise using cairo's dacare&&deploy in already declared scenarios will block it. but sncast_std seem not support return class_hash when declared exist. |
||
|
||
cairo script declare not support ,if declare exist then retrun class_hash. | ||
if the declare exist at the on-chain. the script will blocking. | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use core::byte_array::ByteArray; | ||
use sncast_std::{ | ||
declare, deploy, DeclareResultTrait, | ||
get_nonce, FeeSettings, EthFeeSettings | ||
}; | ||
|
||
|
||
// build the constructor calldata here | ||
fn build_constructor_calldata() -> Array::<felt252> { | ||
//constructor calldata goes here | ||
// dev-network owner address argument goes here as an argument | ||
//let owner = 0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec; | ||
// sepolia owner address argument goes here as an argument | ||
let owner = 0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691; | ||
array![owner.into()] | ||
} | ||
|
||
fn build_contract_name() -> ByteArray{ | ||
"YourContract" | ||
} | ||
|
||
|
||
fn main() { | ||
let max_fee = 99999999999999999; | ||
let salt = 0x3; | ||
let declare_nonce = get_nonce('latest'); | ||
let contract_name = build_contract_name(); | ||
let declare_result = declare( | ||
contract_name, | ||
FeeSettings::Eth(EthFeeSettings { max_fee: Option::Some(max_fee) }), | ||
Option::Some(declare_nonce) | ||
).expect('declare failed'); | ||
let class_hash = declare_result.class_hash(); | ||
println!("declare result: {}", declare_result); | ||
|
||
let constructor_calldata = build_constructor_calldata(); | ||
let deploy_nonce = get_nonce('pending'); | ||
let deploy_result = deploy( | ||
*class_hash, | ||
constructor_calldata, | ||
Option::Some(salt), | ||
true, | ||
FeeSettings::Eth(EthFeeSettings { max_fee: Option::Some(max_fee) }), | ||
Option::Some(deploy_nonce) | ||
).expect('contract deploy failed'); | ||
|
||
println!("Deployed the contract to address: {}", deploy_result); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
mod scripts; | ||
mod deploy_script; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should not change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update.