You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add comparison for dev call and execute-function in the console user guide part.
Describe the Suggestion
I noticed there has two console commands, [dev call] and [account execute-function] can call public functions, but no examples found. I wrote the below move test code, and has a summary, maybe we can add some guide in cookbook.
my starcoin version is 1.11.11.
Test move code:
address A1 {
module M1{
use StarcoinFramework::Debug;
//use StarcoinFramework::Account;
use StarcoinFramework::Signer;
// a resource
struct Counter has key {
value: u64,
}
// no operation on global storage
public fun init_counter(a: u64): Counter {
return Counter{value: a}
}
// no operation on global storage
public(script) fun init_script_counter(a: u64) {
let c = Counter{value: a};
Debug::print<u64>(&c.value);
let Counter{value: _} = c;
}
// read global storage
public fun read_counter(account: signer): u64 acquires Counter {
let counter = borrow_global<Counter>(Signer::address_of(&account));
let Counter{value: value} = counter;
return *value
}
// write global storage
public fun create_counter_from_u64(account: signer, a: u64) {
move_to(&account, init_counter(a));
}
// write global storage
public fun create_counter(account: signer, c: Counter) {
move_to(&account, c);
}
// read global storage
public(script) fun read_script_counter(account: signer) acquires Counter {
let c = read_counter(account);
Debug::print<u64>(&(c));
}
// write global storage
public(script) fun create_script_counter(account: signer, a: u64){
create_counter(account, init_counter(a));
}
}
}
Summary: public functions:
1 no operation on global storage, dev call init_counter ok
2 read on global storage, dev call read_counter ok
3 write on global storage, dev call set_counter failed with error "Server returned rpc error Invalid params: status REJECTED_WRITE_SET of type Validation"
4 execute-function init_counter failed with error below
public(script) functions:
1 no operation on global storage, dev call init_script_counter ok
2 execute-function always succeed with a tx, regardless of nop/read/write on global storage
compliled move script(.mv):
1 successed, called via execute-script.
The text was updated successfully, but these errors were encountered:
Document Suggestion
Add comparison for dev call and execute-function in the console user guide part.
Describe the Suggestion
I noticed there has two console commands, [dev call] and [account execute-function] can call public functions, but no examples found. I wrote the below move test code, and has a summary, maybe we can add some guide in cookbook.
my starcoin version is 1.11.11.
Test move code:
Summary:
public functions:
1 no operation on global storage, dev call init_counter ok
2 read on global storage, dev call read_counter ok
3 write on global storage, dev call set_counter failed with error "Server returned rpc error Invalid params: status REJECTED_WRITE_SET of type Validation"
4 execute-function init_counter failed with error below
public(script) functions:
1 no operation on global storage, dev call init_script_counter ok
2 execute-function always succeed with a tx, regardless of nop/read/write on global storage
compliled move script(.mv):
1 successed, called via execute-script.
The text was updated successfully, but these errors were encountered: