How to use the arc.enableWalletProvider function in arc

To help you get started, we’ve selected a few arc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github daostack / alchemy / src / components / Proposal / Create / SchemeForms / CreateContributionRewardProposal.tsx View on Github external
public async handleSubmit(values: IFormValues, { setSubmitting }: any ): Promise {
    if (!await enableWalletProvider({ showNotification: this.props.showNotification })) { return; }

    if (!values.beneficiary.startsWith("0x")) { values.beneficiary = "0x" + values.beneficiary; }

    const externalTokenDetails = tokenDetails(values.externalTokenAddress);
    let externalTokenReward;

    // If we know the decimals for the token then multiply by that
    if (externalTokenDetails) {
      externalTokenReward = toBaseUnit(values.externalTokenReward.toString(), externalTokenDetails.decimals);
    // Otherwise just convert to Wei and hope for the best
    } else {
      externalTokenReward = toWei(Number(values.externalTokenReward));
    }

    const proposalValues = {...values,
      scheme: this.props.scheme.address,
github daostack / alchemy / src / components / Scheme / ReputationFromToken.tsx View on Github external
public async handleSubmit(values: IFormValues, { _props, setSubmitting, _setErrors }: any): Promise {
    // only connect to wallet if we do not have a private key to sign with
    if (!this.state.privateKey &&
      !await enableWalletProvider({ showNotification: this.props.showNotification })) {
      setSubmitting(false);
      return;
    }

    const schemeState = this.props.schemeState;
    const schemeAddress = schemeState.address;
    const arc = getArc();
    const schemeContract = await arc.getContract(schemeAddress);
    const alreadyRedeemed = await schemeContract.methods.redeems(this.state.redeemerAddress).call();
    if (alreadyRedeemed) {
      this.props.showNotification(NotificationStatus.Failure, `Reputation for the account ${this.state.redeemerAddress} was already redeemed`);
    } else if (values.useTxSenderService === true) {
      // construct the message to sign
      // const signatureType = 1
      const messageToSign = "0x"+ ethABI.soliditySHA3(
        ["address","address"],
github daostack / alchemy / src / components / Proposal / Create / SchemeForms / CreateSchemeRegistrarProposal.tsx View on Github external
public async handleSubmit(values: IFormValues, { setSubmitting }: any ):  Promise {
    if (!await enableWalletProvider({ showNotification: this.props.showNotification })) { return; }

    let permissions = 1;
    if (values.permissions.registerSchemes) {
      permissions += 2;
    }
    if (values.permissions.changeConstraints) {
      permissions += 4;
    }
    if (values.permissions.upgradeController) {
      permissions += 8;
    }
    if (values.permissions.genericCall) {
      permissions += 16;
    }

    const currentTab = this.state.currentTab;
github daostack / alchemy / src / components / Scheme / SchemeProposalsPage.tsx View on Github external
private async handleNewProposal(daoAvatarAddress: Address, schemeId: any): Promise {
    if (!await enableWalletProvider({ showNotification: this.props.showNotification })) { return; }

    this.props.history.push(`/dao/${daoAvatarAddress}/scheme/${schemeId}/proposals/create/`);
  }
github daostack / alchemy / src / components / Proposal / Voting / VoteBreakdown.tsx View on Github external
public async handleClickVote(vote: number, _event: any): Promise {
    if (!await enableWalletProvider({ showNotification: this.props.showNotification })) { return; }

    if (this.props.currentAccountState.reputation.gt(new BN(0))) {
      this.setState({ showPreVoteModal: true, currentVote: vote });
    }
  }