{"_id":"@andex/provider","name":"@andex/provider","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@andex/provider","version":"1.0.0","description":"Web3-like interface for the Venom blockchain","repository":{"type":"git","url":"git+https://github.com/andex-fi/andex-provider.git"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","build:vanilla":"rollup --config rollup.config.ts --configPlugin typescript","build:docs":"typedoc","lint":"npx eslint ."},"author":"","license":"GPL-3.0","devDependencies":{"@rollup/plugin-terser":"^0.2.1","@rollup/plugin-typescript":"^10.0.1","@typescript-eslint/eslint-plugin":"^5.31.0","@typescript-eslint/parser":"^5.31.0","eslint":"^8.21.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.2.1","path":"^0.12.7","rollup":"^3.9.0","typedoc":"^0.23.10","typedoc-plugin-missing-exports":"^0.23.0","typescript":"^4.2.4"},"gitHead":"90ef953d6dcc5f63227ab05f4c01a66d35bbbfdc","bugs":{"url":"https://github.com/andex-fi/andex-provider/issues"},"homepage":"https://github.com/andex-fi/andex-provider#readme","_id":"@andex/provider@1.0.0","_nodeVersion":"16.18.0","_npmVersion":"8.19.2","dist":{"integrity":"sha512-76zNaulGbHbZ/QOsq8+9WCzMMaju8i+j2avt6i16z7TgVac7b9Uc+cf9qkOx59fmnYRIaWzMtByqj4LViyfpWQ==","shasum":"bfd4d63fa21b64610fb9e617cf2f975090f8c17c","tarball":"https://registry.npmjs.org/@andex/provider/-/provider-1.0.0.tgz","fileCount":15,"unpackedSize":227343,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF0UhuwkN7yKxFVGdsoGlPEPcrkXoQ/xuI9be55DaNj0AiEA1pXep7ZkwK9F9luoPO9nvOIh2zwtve3OOlA36V4MQgQ="}]},"_npmUser":{"name":"natedotv2","email":"nathanirikefe@gmail.com"},"directories":{},"maintainers":[{"name":"natedotv2","email":"nathanirikefe@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/provider_1.0.0_1686169842837_0.6612915390109466"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-07T20:30:42.782Z","1.0.0":"2023-06-07T20:30:43.016Z","modified":"2023-06-07T20:30:43.181Z"},"maintainers":[{"name":"natedotv2","email":"nathanirikefe@gmail.com"}],"description":"Web3-like interface for the Venom blockchain","homepage":"https://github.com/andex-fi/andex-provider#readme","repository":{"type":"git","url":"git+https://github.com/andex-fi/andex-provider.git"},"bugs":{"url":"https://github.com/andex-fi/andex-provider/issues"},"license":"GPL-3.0","readme":"\n\n# Venom inpage provider &emsp;  [![Latest Version]][npmjs.com] [![Docs badge]][docs]\n\n## About\n\nWeb3-like interface to the Venom blockchain.\n\n## Usage\n\n### How to install\n\n```shell\nyarn add --save @andex/provider\n```\n\n> NOTE: this repo was inspired `everscale-inpage-provider` package which is not tailored for Venom specifically.\n\n### Contents\n\n- [`src/api.ts`](./src/api.ts) - RPC interface description\n- [`src/models.ts`](./src/models.ts) - general models, used in RPC interface\n- [`src/contract.ts`](./src/contract.ts) - typed contracts wrapper\n- [`src/stream.ts`](./src/stream.ts) - user-friendly api for streams\n- [`src/utils.ts`](./src/utils.ts) - some useful stuff\n\n### Example\n\n```typescript\nimport {\n  Address,\n  ProviderRpcClient,\n  TvmException\n} from '@andex/provider';\n\nconst venom = new ProviderRpcClient();\n\nasync function myApp() {\n  if (!(await venom.hasProvider())) {\n    throw new Error('Extension is not installed');\n  }\n\n  const { accountInteraction } = await venom.requestPermissions({\n    permissions: ['basic', 'accountInteraction'],\n  });\n  if (accountInteraction == null) {\n    throw new Error('Insufficient permissions');\n  }\n\n  const selectedAddress = accountInteraction.address;\n  const dePoolAddress = new Address('0:bbcbf7eb4b6f1203ba2d4ff5375de30a5408a8130bf79f870efbcfd49ec164e9');\n\n  const dePool = new venom.Contract(DePoolAbi, dePoolAddress);\n\n  const transaction = await dePool\n    .methods\n    .addOrdinaryStake({\n      stake: '10000000000',\n    }).send({\n      from: selectedAddress,\n      amount: '10500000000',\n      bounce: true,\n    });\n  console.log(transaction);\n\n  try {\n    const output = await dePool\n      .methods\n      .getParticipantInfo({\n        addr: selectedAddress,\n      })\n      .call();\n    console.log(output);\n  } catch (e) {\n    if (e instanceof TvmException) {\n      console.error(e.code);\n    }\n  }\n}\n\nconst DePoolAbi = {\n  'ABI version': 2,\n  'header': ['time', 'expire'],\n  'functions': [{\n    'name': 'addOrdinaryStake',\n    'inputs': [\n      { 'name': 'stake', 'type': 'uint64' },\n    ],\n    'outputs': [],\n  }, {\n    'name': 'getParticipantInfo',\n    'inputs': [\n      { 'name': 'addr', 'type': 'address' },\n    ],\n    'outputs': [\n      { 'name': 'total', 'type': 'uint64' },\n      { 'name': 'withdrawValue', 'type': 'uint64' },\n      { 'name': 'reinvest', 'type': 'bool' },\n      { 'name': 'reward', 'type': 'uint64' },\n      { 'name': 'stakes', 'type': 'map(uint64,uint64)' },\n      {\n        'components': [\n          { 'name': 'remainingAmount', 'type': 'uint64' },\n          { 'name': 'lastWithdrawalTime', 'type': 'uint64' },\n          { 'name': 'withdrawalPeriod', 'type': 'uint32' },\n          { 'name': 'withdrawalValue', 'type': 'uint64' },\n          { 'name': 'owner', 'type': 'address',\n        }],\n        'name': 'vestings', 'type': 'map(uint64,tuple)',\n      },\n      {\n        'components': [\n          { 'name': 'remainingAmount', 'type': 'uint64' },\n          { 'name': 'lastWithdrawalTime', 'type': 'uint64' },\n          { 'name': 'withdrawalPeriod', 'type': 'uint32' },\n          { 'name': 'withdrawalValue', 'type': 'uint64' },\n          { 'name': 'owner', 'type': 'address',\n        }],\n        'name': 'locks', 'type': 'map(uint64,tuple)',\n      },\n      { 'name': 'vestingDonor', 'type': 'address' },\n      { 'name': 'lockDonor', 'type': 'address' },\n    ],\n  }],\n  'data': [],\n  'events': [],\n} as const; // NOTE: `as const` is very important here\n\nmyApp().catch(console.error);\n```\n\n### Build\n\n```shell\nnpm install\n\n# Build as ts library\n# (output will be in the `dist` folder)\nnpm run build\n\n# Build as js library to use directly in <script> tags\n# (output will be in the `vanilla` folder)\nnpm run build:vanilla\n```\n\n## Contributing\n\nWe welcome contributions to the project! If you notice any issues or errors, feel free to open an issue or submit a pull request.\n\n## License\n\nLicensed under GPL-3.0 license ([LICENSE](/LICENSE) or https://opensource.org/license/gpl-3-0/).\n\n[latest version]: https://img.shields.io/npm/v/@andex/provider\n[npmjs.com]: https://www.npmjs.com/package/@andex/provider\n[docs badge]: https://img.shields.io/badge/docs-latest-brightgreen\n[docs]: https://andex-fi.github.io/andex-provider/index.html\n","readmeFilename":"README.md"}