Giter VIP home page Giter VIP logo

everscale-inpage-provider's Introduction

Logo

Everscale inpage provider โ€ƒ Latest Version Docs badge

About

Web3-like interface to the Everscale blockchain.

Usage

How to install

npm install --save everscale-inpage-provider

NOTE: this repo was originally used for ton-inpage-provider package which is DEPRECATED now.

Contents

Example

import {
  Address,
  ProviderRpcClient,
  TvmException
} from 'everscale-inpage-provider';

const ever = new ProviderRpcClient();

async function myApp() {
  if (!(await ever.hasProvider())) {
    throw new Error('Extension is not installed');
  }

  const { accountInteraction } = await ever.requestPermissions({
    permissions: ['basic', 'accountInteraction'],
  });
  if (accountInteraction == null) {
    throw new Error('Insufficient permissions');
  }

  const selectedAddress = accountInteraction.address;
  const dePoolAddress = new Address('0:bbcbf7eb4b6f1203ba2d4ff5375de30a5408a8130bf79f870efbcfd49ec164e9');

  const dePool = new ever.Contract(DePoolAbi, dePoolAddress);

  const transaction = await dePool
    .methods
    .addOrdinaryStake({
      stake: '10000000000',
    }).send({
      from: selectedAddress,
      amount: '10500000000',
      bounce: true,
    });
  console.log(transaction);

  try {
    const output = await dePool
      .methods
      .getParticipantInfo({
        addr: selectedAddress,
      })
      .call();
    console.log(output);
  } catch (e) {
    if (e instanceof TvmException) {
      console.error(e.code);
    }
  }
}

const DePoolAbi = {
  'ABI version': 2,
  'header': ['time', 'expire'],
  'functions': [{
    'name': 'addOrdinaryStake',
    'inputs': [
      { 'name': 'stake', 'type': 'uint64' },
    ],
    'outputs': [],
  }, {
    'name': 'getParticipantInfo',
    'inputs': [
      { 'name': 'addr', 'type': 'address' },
    ],
    'outputs': [
      { 'name': 'total', 'type': 'uint64' },
      { 'name': 'withdrawValue', 'type': 'uint64' },
      { 'name': 'reinvest', 'type': 'bool' },
      { 'name': 'reward', 'type': 'uint64' },
      { 'name': 'stakes', 'type': 'map(uint64,uint64)' },
      {
        'components': [
          { 'name': 'remainingAmount', 'type': 'uint64' },
          { 'name': 'lastWithdrawalTime', 'type': 'uint64' },
          { 'name': 'withdrawalPeriod', 'type': 'uint32' },
          { 'name': 'withdrawalValue', 'type': 'uint64' },
          { 'name': 'owner', 'type': 'address',
        }],
        'name': 'vestings', 'type': 'map(uint64,tuple)',
      },
      {
        'components': [
          { 'name': 'remainingAmount', 'type': 'uint64' },
          { 'name': 'lastWithdrawalTime', 'type': 'uint64' },
          { 'name': 'withdrawalPeriod', 'type': 'uint32' },
          { 'name': 'withdrawalValue', 'type': 'uint64' },
          { 'name': 'owner', 'type': 'address',
        }],
        'name': 'locks', 'type': 'map(uint64,tuple)',
      },
      { 'name': 'vestingDonor', 'type': 'address' },
      { 'name': 'lockDonor', 'type': 'address' },
    ],
  }],
  'data': [],
  'events': [],
} as const; // NOTE: `as const` is very important here

myApp().catch(console.error);

Build

npm install

# Build as ts library
# (output will be in the `dist` folder)
npm run build

# Build as js library to use directly in <script> tags
# (output will be in the `vanilla` folder)
npm run build:vanilla

Contributing

We welcome contributions to the project! If you notice any issues or errors, feel free to open an issue or submit a pull request.

License

Licensed under GPL-3.0 license (LICENSE or https://opensource.org/license/gpl-3-0/).

everscale-inpage-provider's People

Contributors

30mb1 avatar odrin avatar rexagon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

everscale-inpage-provider's Issues

Sender not found

I get this error (Error: sendMessage: Sender not found) when i attempt to send tokens to a recipient address:

`
const tokenWalletAddress = new Address(tokenWalletAddress);
const tokenWalletContract = new standalone.Contract(tokenWalletAbi, contractAddress);

await tokenWalletContract.methods.transfer({
amount: amountOfTokens,
recipient: new Address(recipientAddress),
deployWalletValue: "1000000000",
remainingGasTo: new Address(address),
notify: true,
payload: ""
}).send({
from: new Address(address),
amount: "1000000000",
bounce: true
});`

wallet signature issue

I am working on verifying wallet signatures in our backend. Signatures signed using Android Venom wallet are not getting verified with everscale-inpage-provider on backend. The same code base works when using Chrome extension for venom wallet. Any help. Is this a known issue with Venom wallet?

here's is my code for frontend:
const submitWallet = async () => {
console.log(new Address(address));
const providerState = await venomProvider?.getProviderState?.();
console.log(providerState?.permissions);
const publicKey = providerState?.permissions.accountInteraction?.publicKey;
console.log(publicKey);
try {
const base64 = btoa(
JSON.stringify({
walletAddress: address,
}),
);
const sign = await venomProvider.signDataRaw({ data: base64, publicKey });
dispatch(SubmitWallet({ publicKey, base64, signature: sign.signature }));
} catch (errr) {
console.log(errr);
}
};
and my backend code:
const { publicKey, base64, signature } = req.body;
const verificaiton = await ever.verifySignature({
publicKey,
dataHash: base64,
signature: signature,
});
if (!verificaiton.isValid) {
return res.status(403).json({
error: "Signature is not valid",
});
}

Proposal: Add support for uintX/intX in steps of 1 for AbiParamKindUint/AbiParamKindInt

type AbiParamKindUint = 'uint8' | 'uint16' | 'uint24' | 'uint32' | 'uint64' | 'uint128' | 'uint160' | 'uint256';

Sine 0.52.0 solidity "Supported uintX/intX in steps of 1: uint1, uint2, uint3 ... uint256"

https://github.com/tonlabs/TON-Solidity-Compiler/blob/6953ed5deec19ab6c41259879d10e73ab9643e42/Changelog_TON.md#0520-2021-11-15

Please consider adding support for these types.

Add `getNetworkTime` method

This method should return the maximum known block time.

Reference query:

query {
  blocks(
    orderBy: [{ path: "gen_utime", direction: DESC }],
    limit: 1
  ) {
    gen_utime
  }
}

sendMessage: Parameter count mismatch

Can somebody explain why i got this error ?

image

when I use this script

 public async getEverWalletTransaction(
    recipient: string,
    price: any,
    payload: any,
  ): Promise<string> {
    console.log(this.wallet.address);
    console.log(recipient);
    console.log(price.toString());
    console.log(payload);
    const { transaction } = await this.ton.rawApi.sendMessage({
      sender: this.wallet.address,
      recipient,
      amount: price.toString(),
      bounce: true,
      payload,
    });

    return transaction.id.hash;
  }

Uncaught NekotonRpcError Error: sendMessage: TypeError: account.prepareMessage is not a function

  const ever = new ProviderRpcClient({
    fallback: () =>
      EverscaleStandaloneClient.create({
        clock: new Clock(),
        connection: {
          id: 1000,
          group: 'venom_testnet',
          type: "jrpc",
          data: {
            endpoint: 'https://jrpc-testnet.venom.foundation/rpc'
          }
        },
        keystore: new SimpleKeystore({
          giverKey: Wallet,
          Wallet,
        }),
        accountsStorage: new SimpleAccountsStorage({
          entries: [giverAccount],
        }),
      }),
  });
  await ever.ensureInitialized();
  const VENOM_CONTRACT_MINT = new Address('0:b288234ed66c5d45250c01b5aa3a77f0b95050c4fb785bf62d05f580c9f7a341')
  const contract = new Contract(ever, VENOM_MINT_ABI ,VENOM_CONTRACT_MINT)
  const minter = await contract.methods.mintNftV2(info).send({
    from: new Address(address),
    amount : "1000000000",
  })
  console.log(minter)

account.prepareMessage i got this error when trying to call function, how can i fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.