-
Notifications
You must be signed in to change notification settings - Fork 0
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
Token contract -- (tested) #12
Conversation
njeans
commented
Jun 18, 2023
•
edited by sbellem
Loading
edited by sbellem
- cargo test
- cargo build --target wasm32-unknown-unknown
- deployment to a local devnet
deposit tests get balance function unused variable warnings
We need to figure out why The main issue is with the Just for troubleshooting's sake, the patch shown below builds without error, but the check diff --git a/src/contract.rs b/src/contract.rs
index 1e6fc95..74596f1 100644
--- a/src/contract.rs
+++ b/src/contract.rs
@@ -309,7 +309,8 @@ fn try_write_checkpoint(
// ---------------------------------------- QUERIES --------------------------------------
#[entry_point]
-pub fn query(deps: Deps, env: Env, info: MessageInfo, msg: QueryMsg) -> StdResult<Binary> {
+//pub fn query(deps: Deps, env: Env, info: MessageInfo, msg: QueryMsg) -> StdResult<Binary> {
+pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::GetState {
} => qet_state(deps, env),
@@ -325,9 +326,11 @@ pub fn query(deps: Deps, env: Env, info: MessageInfo, msg: QueryMsg) -> StdResul
} => get_checkpoint(deps, env),
QueryMsg::ProcessNext {
cipher
- } => process_request(deps, env, info, cipher),
+ //} => process_request(deps, env, info, cipher),
+ } => process_request(deps, env, cipher),
QueryMsg::GetBalance {
- } => get_balance(deps, env, info)
+ //} => get_balance(deps, env, info)
+ } => get_balance(deps, env)
}
}
@@ -445,7 +448,7 @@ fn get_checkpoint(
fn get_balance(
deps: Deps,
_env: Env,
- info: MessageInfo
+ //info: MessageInfo
) -> StdResult<Binary> {
let checkpoint = CheckPoint::load(deps.storage)?;
@@ -453,7 +456,8 @@ fn get_balance(
let mut res = Uint128::zero();
for i in 0..checkpoint.checkpoint.len() {
let a = checkpoint.checkpoint.get(i).unwrap();
- let b: bool = a.address == info.sender;
+ //let b: bool = a.address == info.sender;
+ let b: bool = true;
let b_int = bool_to_uint128(b);
res = res.checked_add(a.balance.checked_mul(b_int).unwrap()).unwrap();
}
@@ -464,7 +468,7 @@ fn get_balance(
fn process_request(
deps: Deps,
env: Env,
- info: MessageInfo,
+ //info: MessageInfo,
cipher: Binary
)-> StdResult<Binary> {
let mut checkpoint: CheckPoint = CheckPoint::decrypt_checkpoint(deps.storage, cipher).unwrap(); |
Wonder if this could work ... diff --git a/src/contract.rs b/src/contract.rs
index 1e6fc95..30f5211 100644
--- a/src/contract.rs
+++ b/src/contract.rs
@@ -309,7 +309,7 @@ fn try_write_checkpoint(
// ---------------------------------------- QUERIES --------------------------------------
#[entry_point]
-pub fn query(deps: Deps, env: Env, info: MessageInfo, msg: QueryMsg) -> StdResult<Binary> {
+pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::GetState {
} => qet_state(deps, env),
@@ -325,9 +325,10 @@ pub fn query(deps: Deps, env: Env, info: MessageInfo, msg: QueryMsg) -> StdResul
} => get_checkpoint(deps, env),
QueryMsg::ProcessNext {
cipher
- } => process_request(deps, env, info, cipher),
+ } => process_request(deps, env, cipher),
QueryMsg::GetBalance {
- } => get_balance(deps, env, info)
+ address
+ } => get_balance(deps, env, address)
}
}
@@ -445,7 +446,8 @@ fn get_checkpoint(
fn get_balance(
deps: Deps,
_env: Env,
- info: MessageInfo
+ // FIXME ?
+ address: Addr
) -> StdResult<Binary> {
let checkpoint = CheckPoint::load(deps.storage)?;
@@ -453,7 +455,8 @@ fn get_balance(
let mut res = Uint128::zero();
for i in 0..checkpoint.checkpoint.len() {
let a = checkpoint.checkpoint.get(i).unwrap();
- let b: bool = a.address == info.sender;
+ // FIXME ?
+ let b: bool = a.address == address;
let b_int = bool_to_uint128(b);
res = res.checked_add(a.balance.checked_mul(b_int).unwrap()).unwrap();
}
@@ -464,7 +467,6 @@ fn get_balance(
fn process_request(
deps: Deps,
env: Env,
- info: MessageInfo,
cipher: Binary
)-> StdResult<Binary> {
let mut checkpoint: CheckPoint = CheckPoint::decrypt_checkpoint(deps.storage, cipher).unwrap();
diff --git a/src/msg.rs b/src/msg.rs
index f0872dc..5982cd7 100644
--- a/src/msg.rs
+++ b/src/msg.rs
@@ -48,7 +48,9 @@ pub enum QueryMsg {
old_mac: Binary,
},
- GetBalance{},
+ GetBalance{
+ address: Addr
+ },
GetRequest {
seqno: Uint128 |
This might work: 32dbeb9 Tests pass, and build in docker worked on my laptop. |
Deploying the contract does not work ... stuck on the storing step.
|
$ secretcli query tx 96C9FCC2CC4853A8A28111033F478ECC3044D430B98B00F9E8361726609394FF | jq .raw_log
"failed to execute message; message index: 0: Execution error: Error during static Wasm validation: Contract is not CosmWasm v0.10 or v1. To support v0.10 please fix the former two errors, to supports v1 please fix the latter two errors: $[Err(StaticValidationErr { msg: \"Wasm contract doesn't have required export: \\\"cosmwasm_vm_version_3\\\". Exports required by VM: [\\\"cosmwasm_vm_version_3\\\", \\\"query\\\", \\\"init\\\", \\\"handle\\\", \\\"allocate\\\", \\\"deallocate\\\"].\", backtrace: Backtrace( 0: cosmwasm_sgx_vm::errors::vm_error::VmError::static_validation_err\n 1: cosmwasm_sgx_vm::compatability::check_wasm_exports\n 2: cosmwasm_sgx_vm::compatability::check_wasm\n 3: cosmwasm_sgx_vm::cache::CosmCache<S,A,Q>::save_wasm\n 4: go_cosmwasm::do_create\n 5: create\n 6: _cgo_8890a1994f42_C2func_create\n 7: <unknown>\n) }), Err(StaticValidationErr { msg: \"Wasm contract requires unsupported import: \\\"env.GFp_memcmp\\\". Imports supported by VM: [\\\"env.db_read\\\", \\\"env.db_write\\\", \\\"env.db_remove\\\", \\\"env.canonicalize_address\\\", \\\"env.humanize_address\\\", \\\"env.query_chain\\\", \\\"env.secp256k1_verify\\\", \\\"env.secp256k1_recover_pubkey\\\", \\\"env.secp256k1_sign\\\", \\\"env.ed25519_verify\\\", \\\"env.ed25519_batch_verify\\\", \\\"env.ed25519_sign\\\", \\\"env.db_scan\\\", \\\"env.db_next\\\", \\\"env.debug_print\\\"].\", backtrace: Backtrace( 0: cosmwasm_sgx_vm::errors::vm_error::VmError::static_validation_err\n 1: cosmwasm_sgx_vm::compatability::check_wasm_imports\n 2: cosmwasm_sgx_vm::compatability::check_wasm\n 3: cosmwasm_sgx_vm::cache::CosmCache<S,A,Q>::save_wasm\n 4: go_cosmwasm::do_create\n 5: create\n 6: _cgo_8890a1994f42_C2func_create\n 7: <unknown>\n) }), Ok(()), Err(StaticValidationErr { msg: \"Wasm contract requires unsupported import: \\\"env.GFp_memcmp\\\". Imports supported by VM: [\\\"env.db_read\\\", \\\"env.db_write\\\", \\\"env.db_remove\\\", \\\"env.addr_validate\\\", \\\"env.addr_canonicalize\\\", \\\"env.addr_humanize\\\", \\\"env.secp256k1_verify\\\", \\\"env.secp256k1_recover_pubkey\\\", \\\"env.secp256k1_sign\\\", \\\"env.ed25519_verify\\\", \\\"env.ed25519_batch_verify\\\", \\\"env.ed25519_sign\\\", \\\"env.debug\\\", \\\"env.query_chain\\\", \\\"env.db_scan\\\", \\\"env.db_next\\\", \\\"env.gas_evaporate\\\", \\\"env.check_gas\\\"].\", backtrace: Backtrace( 0: cosmwasm_sgx_vm::errors::vm_error::VmError::static_validation_err\n 1: cosmwasm_sgx_vm::compatability::check_wasm_imports\n 2: cosmwasm_sgx_vm::compatability::check_wasm\n 3: cosmwasm_sgx_vm::cache::CosmCache<S,A,Q>::save_wasm\n 4: go_cosmwasm::do_create\n 5: create\n 6: _cgo_8890a1994f42_C2func_create\n 7: <unknown>\n) })]: create contract failed" |
closed in favor of #17 |