gakonst / ethers-rs

Complete Ethereum & Celo library and wallet implementation in Rust. https://docs.rs/ethers
Apache License 2.0
2.5k stars 794 forks source link

Calling the contract method `unlock` always fail #2757

Closed eauxxs closed 7 months ago

eauxxs commented 8 months ago

Please post your question as a discussion in Telegram: https://t.me/ethers_rs

        let byte: [u8; 32] = [
            0xcb, 0xbe, 0x7d, 0xfe, 0x7b, 0xfb, 0x9f, 0x48, 0xc2, 0x66, 0x58, 0x7c, 0xde, 0x1d,
            0x74, 0x02, 0x52, 0xfc, 0xb2, 0x59, 0x46, 0xb3, 0xc7, 0xc5, 0x4b, 0x79, 0x96, 0x2b,
            0x05, 0x81, 0x37, 0x7d,
        ];

        let account = "0xec2682a140b45517c73aaccec53c8aa62b818cfe"
            .parse()
            .unwrap();
        let x = contract.has_role(byte, account).call().await.unwrap();
        println!("{:?}", x);

        let tx_hash = "0x6fec5f4725a0bb8f17f2a35f67c39ada5b96439e81c607fefa4b5df4c0cd3001"
            .parse()
            .unwrap();

        let r = contract.unlock(tx_hash);
        println!("{:?}", r);
        let rr = r.send().await.unwrap();
        println!("{:?}", rr);

return:

FunctionCall { tx: Eip1559(Eip1559TransactionRequest { from: None, to: Some(Address(0x16fc02e0ca26329a68cd4ddd3c8ae182fbd5931a)), gas: None, value: None, data: Some(Bytes(0x6198e3396fec5f4725a0bb8f17f2a35f67c39ada5b96439e81c607fefa4b5df4c0cd3001)), nonce: None, access_list: AccessList([]), max_priority_fee_per_gas: None, max_fee_per_gas: None, chain_id: None }), function: Function { name: "unlock", inputs: [Param { name: "txid", kind: Uint(256), internal_type: Some("uint256") }], outputs: [], constant: None, state_mutability: NonPayable }, block: None, client: SignerMiddleware { inner: Provider { inner: Provider { id: 5, client: Client { accepts: Accepts, proxies: [Proxy(System({}), None)], referer: true, default_headers: {"accept": "*/*"} }, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("data-seed-prebsc-1-s2.bnbchain.org")), port: Some(8545), path: "/", query: None, fragment: None } }, ens: None, interval: Some(1.5s), from: None, _node_client: Mutex { is_locked: false, has_waiters: false } }, signer: Wallet { address: 0xec2682a140b45517c73aaccec53c8aa62b818cfe, chain_Id: 97 }, address: 0xec2682a140b45517c73aaccec53c8aa62b818cfe }, datatype: PhantomData<()>, _m: PhantomData<ethers_middleware::signer::SignerMiddleware<alloc::sync::Arc<ethers_providers::rpc::provider::Provider<ethers_providers::rpc::transports::http::Provider>>, ethers_signers::wallet::Wallet<ecdsa::signing::SigningKey<k256::Secp256k1>>>> }
thread 'btb::tests::test_unlock' panicked at src/btb.rs:234:33:
called `Result::unwrap()` on an `Err` value: Revert(Bytes(0x4e487b710000000000000000000000000000000000000000000000000000000000000032))

when call unlock(tx_hash), assesslist is empty, is it ethers's reason?

eauxxs commented 8 months ago

param is not tx_hash, it is index of tx_hash, is the reason.