0

So, I have to approve a transaction on one contract and then I have a chained promise call to initiate a transfer onto another separate contract. Works just fine on Metamask Desktop, but on the Metamask Mobile app, after imitating and completing the first transaction, it basically says, "okay, we're done here" and refuses to move onto the next promised chain call. Here's the code.

initateStake = async () => {
      const web3 = new Web3(window.ethereum);
      const approveImperialContract = await new web3.eth.Contract(approveABI, ImperialAddress);
      const checkAllowed = await approveImperialContract.methods.allowed(this.state.accounts[0], stakeAddress).call({from: this.state.accounts[0]});
      console.log(checkAllowed);
      if (checkAllowed != 0) {
          try {
          this.setState({opacity: "fadeInMessage", actions: true, description: "Approved Balance already above 0, resetting approval to 0."});
          await approveImperialContract.methods.approve(stakeAddress, 0).send({from: this.state.accounts[0]});
          } catch (e) {
          console.log(e);
          this.setState({opacity: "fadeOutMessage", actions: false, description: e.message});
          return;
          }
      }
          try {
          //Create the approve request, send it and wait for approval
          this.setState({opacity: "fadeInMessage", actions: true, description: "Granting approval for sending Imperial Tokens (UNITS) to the stake contract."});
          await approveImperialContract.methods.approve(stakeAddress, this.state.triggerAction).send({from: this.state.accounts[0]});
          } catch (e) {
          console.log(e);
          this.setState({opacity: "fadeOutMessage", actions: false, description: e.message});
          return;
          }
          try {
          this.setState({actions: true, description: "Sending balance to the stake contract."});
          await this.state.stakeContract.methods.initateStake().send({from: this.state.accounts[0]}).then(() => {
              this.setState({description: "Success!"});
              this.displayStake();
              this.displayTimeWhenUserStaked();
              this.setState({actions: false});
              })
          } catch (e) {
          console.log(e);
          this.setState({opacity: "fadeOutMessage", actions: false, description: e.message});
          return;
          }
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.