Here is the code. I get error message "Error: {“message”:“PartialVMError with status INVALID_MAIN_FUNCTION_SIGNATURE”,“error_code”:“invalid_input”,“vm_error_code”:null} "
module two_sum::addition {
use std::signer;
use std::error;
struct NumbersHolder has key {
num1: u64,
num2: u64,
}
const ENO_NUMBERS: u64 = 0;
#[view]
public fun get_sum(account: signer): u64 acquires NumbersHolder {
let account_addr = signer::address_of(&account);
assert!(exists<NumbersHolder>(account_addr), error::not_found(ENO_NUMBERS));
let holder = borrow_global<NumbersHolder>(account_addr);
holder.num1 + holder.num2
}
public entry fun set_numbers(account: signer, a: u64, b: u64) acquires NumbersHolder {
let account_addr = signer::address_of(&account);
if (!exists<NumbersHolder>(account_addr)) {
move_to(&account, NumbersHolder { num1: a, num2: b })
} else {
let holder = borrow_global_mut<NumbersHolder>(account_addr);
holder.num1 = a;
holder.num2 = b;
}
}
#[test(account = @0x1)]
public entry fun test_set_numbers_and_get_sum(account: signer) acquires NumbersHolder {
let addr = signer::address_of(&account);
set_numbers(account, 5, 10);
assert!(get_sum(account) == 15, ENO_NUMBERS);
}
}
For any help with Move, feel free to check out the dev discussion channel of the Aptos official server.
You just need to get a dev role first in the choose role channel to see it. The Aptos Assistant is a very useful tool. Just make sure to double check its answers by asking it if it is sure about the answer. Some of these chatbots can hallucinate at times so also check in with the dev discussion chat to make sure the code answer is a solid one.
Ok, update - with no change to the code, but just fixing that indentation error (based on what was shared in this thread)… still getting the same error message.