{"_id":"@bunnyrobot-toolkit/profile-sdk","_rev":"2-ac6b697622557de78add3f9d5d83e20b","name":"@bunnyrobot-toolkit/profile-sdk","dist-tags":{"latest":"0.4.2"},"versions":{"0.5.6":{"name":"@bunnyrobot-toolkit/profile-sdk","version":"0.5.6","main":"dist/index.cjs.js","module":"dist/index.esm.js","types":"dist/index.d.ts","license":"MIT","private":false,"repository":{"type":"git","url":"git+https://github.com/bunnyrobot/bunnyrobot-toolkit.git#master"},"scripts":{"build":"rm -rf ./dist && rollup -c && tsc -d --emitDeclarationOnly --declarationDir dist","start":"yarn build && node ./dist","test":"jest","test:coverage":"jest --collectCoverage","lint":"eslint 'src/**/*.{js,jsx,ts,tsx}'","format:check":"prettier --check --loglevel error 'src/**/*.{js,jsx,ts,tsx}'","format:write":"prettier --write 'src/**/*.{js,jsx,ts,tsx}'"},"devDependencies":{"@babel/preset-env":"^7.13.15","@babel/preset-typescript":"^7.13.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-image":"^2.0.6","@rollup/plugin-node-resolve":"^11.2.1","@types/jest":"^26.0.22","@types/node":"^14.14.39","babel-jest":"^26.6.3","ethers":"^5.1.4","graphql":"^15.5.0","graphql-request":"^3.4.0","jest":"^26.6.3","msw":"^0.28.1","node-fetch":"^2.6.1","ts-jest":"^26.5.4"},"peerDependencies":{"ethers":"^5.1.4","graphql":"^15.5.0","graphql-request":"^3.4.0"},"dependencies":{"@types/js-cookie":"^2.2.6","js-cookie":"^2.2.1"},"publishConfig":{"access":"public"},"gitHead":"e11c1942b37064fa45d1908c99e2a1c4bdec6aad","description":"This package provides some handy functions to retrieve data for Pancakeswap Profile system.","bugs":{"url":"https://github.com/bunnyrobot/bunnyrobot-toolkit/issues"},"homepage":"https://github.com/bunnyrobot/bunnyrobot-toolkit/tree/master#readme","_id":"@bunnyrobot-toolkit/profile-sdk@0.5.6","_nodeVersion":"14.16.1","_npmVersion":"lerna/4.0.0/node@v14.16.1+x64 (win32)","dist":{"integrity":"sha512-cHM5iygRd5oSUCwSXo1WkMYWFpZrM49vsFqwcOlZ6L6kFZVRucLCKK5djhHx41ry/PiJtV7XpnpkSahQhQrNYg==","shasum":"abf622706f7c63b84dac2a5423c68a23ec8384bb","tarball":"https://registry.npmjs.org/@bunnyrobot-toolkit/profile-sdk/-/profile-sdk-0.5.6.tgz","fileCount":90,"unpackedSize":1500891,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg9rggCRA9TVsSAnZWagAAhIoP/jgX2/sXDXd9VX3uJJf0\nlkPb8hAZ3wbIAmfc5fKslopHlj0PXvddxG7QWwJ0H/Nv70BnPCx3TZSxvm5I\nNxKg4Bc7jJGoQGdOIijRNMDnsFj2rkfTu7nAACSZBX7xVorjRNDWxzoCUej2\n6hZ6xwjYHwyEDzhtj7UGNWAZWIdZ7DSZ1nvwOPr1YwxYVdvE3P/Mncs5om46\nM1P2yV8YOrX+678CH8Bh/17XwRSGK2xwOK07P9G6Rx2muC6gxG/jpXqemY1l\nVckApgE41oNZiTkGk8076SbxbPeWxcpmBU0dHgNs+TjZ8Z+Ate4LdC60C88n\nggCBNX4io4tKCdB1i+Vg1VtjuzF5iILh3WdG4dnxh1fSyKJFh+zp4dHKXOs4\nG4BNXYfZWJWFxWJoPo76uJgQJKIWpkWwhn/E+3K8WZ8ufmjbJ4EGKXXjWyoc\nWSCyysHHLWMOZefl7+SePxrAZZaA19ADmHfZlQKoqVtOsloIYEVt4HSUO9TP\nVHf/GlYgask2Uk2kRTezTJdNe6R0hxGOG6Aed6iM9tQsHmf85bDpmLY8mUbe\nyRlq0i4+3U4l8dP8Z74hXdfavkG3si0Q6Bs3J4+mGGcM2MjRvnMO4UVaGwbo\nspMzY2N1cVLKyRzxk8lH7P7qVtF+Xz2mQsxpRhyOr1vVSvHuc3HhRnRIwUpA\nP14l\r\n=uKjj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCsbYy7q/w4vUNVGQHUAqOHQBubp6aub++RY1E/9eZ7fQIhANRpCY08o1115xic1diaJ1cF+uVt9WGg0YJNHlHWHVqZ"}]},"_npmUser":{"name":"bunnyrobot","email":"bunnyrobot@gmail.com"},"directories":{},"maintainers":[{"name":"bunnyrobot","email":"bunnyrobot@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/profile-sdk_0.5.6_1626781728087_0.3470725560058274"},"_hasShrinkwrap":false},"0.4.2":{"name":"@bunnyrobot-toolkit/profile-sdk","version":"0.4.2","main":"dist/index.cjs.js","module":"dist/index.esm.js","types":"dist/index.d.ts","license":"MIT","private":false,"repository":{"type":"git","url":"git+https://github.com/bunnyrobot/bunnyrobot-toolkit.git#master"},"scripts":{"build":"rm -rf ./dist && rollup -c && tsc -d --emitDeclarationOnly --declarationDir dist","start":"yarn build && node ./dist","test":"jest","test:coverage":"jest --collectCoverage","lint":"eslint 'src/**/*.{js,jsx,ts,tsx}'","format:check":"prettier --check --loglevel error 'src/**/*.{js,jsx,ts,tsx}'","format:write":"prettier --write 'src/**/*.{js,jsx,ts,tsx}'"},"devDependencies":{"@babel/preset-env":"^7.13.15","@babel/preset-typescript":"^7.13.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-image":"^2.0.6","@rollup/plugin-node-resolve":"^11.2.1","@types/jest":"^26.0.22","@types/node":"^14.14.39","babel-jest":"^26.6.3","ethers":"^5.1.4","graphql":"^15.5.0","graphql-request":"^3.4.0","jest":"^26.6.3","msw":"^0.28.1","node-fetch":"^2.6.1","ts-jest":"^26.5.4"},"peerDependencies":{"ethers":"^5.1.4","graphql":"^15.5.0","graphql-request":"^3.4.0"},"dependencies":{"@types/js-cookie":"^2.2.6","js-cookie":"^2.2.1"},"publishConfig":{"access":"public"},"gitHead":"3a209e10246d12088485179be55d8b9383f4bb62","description":"This package provides some handy functions to retrieve data for Pancakeswap Profile system.","bugs":{"url":"https://github.com/bunnyrobot/bunnyrobot-toolkit/issues"},"homepage":"https://github.com/bunnyrobot/bunnyrobot-toolkit/tree/master#readme","_id":"@bunnyrobot-toolkit/profile-sdk@0.4.2","_nodeVersion":"14.16.1","_npmVersion":"lerna/4.0.0/node@v14.16.1+x64 (win32)","dist":{"integrity":"sha512-oTqC5nk3I2qjMbUVnyg1FzTwBoubYpOBLlGW4CTymMgVo2nai+DM7AhShlTqg6/Yo5uISy3ts0YCoZUslJHelg==","shasum":"26050fb3ca8a2f8122f378f8f908cd243eeef6ab","tarball":"https://registry.npmjs.org/@bunnyrobot-toolkit/profile-sdk/-/profile-sdk-0.4.2.tgz","fileCount":90,"unpackedSize":1499157,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg9r95CRA9TVsSAnZWagAArIIP/0aK2ZdCbpByEZUDUd+0\nDtfcUwsKlUUXvLheitjfNq+sxqtyzjAty7X7PyW0PsWeTkYy8ry7nbRg/yp4\ngdmWxHFK/IrA+XBw/b49Wa5JIpqsiKCNloadEv867QJkgFvVd9xjiej/HfrU\nASnFOZgDdAZ/21hmMUxuT8UHq7Xe06a8O97l8OT+MnIoMG3Y02UWCdU6lkRp\njMWcLfEKHD7m9dcGQADWAYhL+Sh+lElqsNXulm6RJrx4BdydH3GoR6WCmms8\nFJSHPDdBLqqPIIlVwkF3h0ZCcOfa3ZTsl7GqqX5qOMAjm1erQLfVgsYWLUmQ\nxN49KhND7TqQ6AhBbnnE76m/J6Y5xKx8CQEl2AN4yTU9gvIrp5MGQrEGsDwg\nmWPAQiQ1uR2+osoBgbezQKljchLUwlRycFl4KEqG54/lWepLAa8LImiOvcPi\nxqQ9n6tPk5Ua9Op8FhxZUQb49bNWPSla85iyLuvCtw52YMYb0UFmmMx1Vbsh\nUzQcmzThwhUbcVgi+k8+wGikKLSLsEdy86LEfATUlQWwteYDcxp5sqAHO2BG\nZ/jvm0VLt6WxxLshS/DhOXxzYWQ6xerftmJMgEZxiSMRBEa8moVa1w6EalqW\nD+PK3bhU3u1y7aRMle9FGMiaTAzeFvYVhN71hGUjkr5Krg7BHsSYf5VgtBAf\nnvcs\r\n=xUNc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD67ZRRwHy4HDLcpoq/4Szr6OZDNDWV8TrPbAVNMyWxtwIhAKb65l7sT/34A69cdpOtKirglYY6ORzp48L+LhlNiDwo"}]},"_npmUser":{"name":"bunnyrobot","email":"bunnyrobot@gmail.com"},"directories":{},"maintainers":[{"name":"bunnyrobot","email":"bunnyrobot@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/profile-sdk_0.4.2_1626783609416_0.25693535815167423"},"_hasShrinkwrap":false}},"time":{"created":"2021-07-20T11:48:48.017Z","0.5.6":"2021-07-20T11:48:48.239Z","modified":"2022-04-04T21:06:22.905Z","0.4.2":"2021-07-20T12:20:09.663Z"},"maintainers":[{"name":"bunnyrobot","email":"bunnyrobot@gmail.com"}],"description":"This package provides some handy functions to retrieve data for Pancakeswap Profile system.","homepage":"https://github.com/bunnyrobot/bunnyrobot-toolkit/tree/master#readme","repository":{"type":"git","url":"git+https://github.com/bunnyrobot/bunnyrobot-toolkit.git#master"},"bugs":{"url":"https://github.com/bunnyrobot/bunnyrobot-toolkit/issues"},"license":"MIT","readme":"# Pancakeswap Profile SDK\r\n\r\nThis package provides some handy functions to retrieve data for Pancakeswap Profile system.\r\n\r\n##### Table of Contents\r\n\r\n- [Installation](#installation)\r\n- [Usage](#usage)\r\n  - [Initialization](#initialization)\r\n  - [getUsername](#getUsername)\r\n  - [getTeam](#getTeam)\r\n  - [getProfile](#getProfile)\r\n  - [getAchievements](#getAchievements)\r\n- [Roadmap](#roadmap)\r\n\r\n## Installation\r\n\r\nInstall `@pancakeswap/profile-sdk` into your project with npm:\r\n\r\n```bash\r\nnpm install @pancakeswap/profile-sdk --save\r\n```\r\n\r\nor yarn:\r\n\r\n```bash\r\nyarn add @pancakeswap/profile-sdk\r\n```\r\n\r\nThis package requires `ethers`, `graphql` and `graphql-request` to be installed in your project.\r\n\r\n```bash\r\n# npm\r\nnpm install ethers graphql graphql-request --save\r\n# yarn\r\nyarn add ethers graphql graphql-request\r\n```\r\n\r\n## Usage\r\n\r\n### Initialization\r\n\r\nFirst set is to initialize the SDK with the following:\r\n\r\n```js\r\nimport PancakeProfileSdk from \"@pancakeswap/profile-sdk\";\r\n\r\nconst pancakeSdk = new PancakeProfileSdk();\r\n```\r\n\r\nYou can pass optional arguments to the constructor:\r\n\r\n- `provider` - custom RPC Provider instance if you want to use custom configuration, if not provided defaults to provider with random node from the [list of RPC nodes](src/utils/getRpcUrl.ts)\r\n- `chainId` - what chain ID to use, if not provided defaults to `56`\r\n\r\n```js\r\nimport PancakeProfileSdk from \"@pancakeswap/profile-sdk\";\r\nimport { ethers } from \"ethers\";\r\n\r\nconst customProvider = new ethers.providers.JsonRpcProvider(\"https://example.com\");\r\n\r\nconst pancakeSdk = new PancakeProfileSdk(customProvider, 97);\r\n```\r\n\r\n### getUsername\r\n\r\nReturns username for a given address. If the address does not have a profile or there is an error - returns empty string `\"\"`.\r\n\r\n```js\r\nimport PancakeProfileSdk from \"@pancakeswap/profile-sdk\";\r\n\r\nconst pancakeSdk = new PancakeProfileSdk();\r\nconst username = pancakeSdk.getUsername(\"0x123456789\");\r\nconsole.log(username); // \"Matatabi\"\r\n```\r\n\r\n### getTeam\r\n\r\nReturns team information for the team ID. In case of network error returns null. Note that at the moment `points` will return `0` for all teams (total team points will be calculated soon).\r\n\r\n```js\r\nimport PancakeProfileSdk from \"@pancakeswap/profile-sdk\";\r\n\r\nconst pancakeSdk = new PancakeProfileSdk();\r\nconst team = pancakeSdk.getTeam(1);\r\nconsole.log(team);\r\n// {\r\n//   id: 1,\r\n//   name: \"Syrup Storm\",\r\n//   description: \"The storm's a-comin! Watch out! These bulls are stampeding in a syrupy surge!\",\r\n//   isJoinable: true,\r\n//   users: 55123;\r\n//   points: 182500;\r\n//   images: images: {\r\n//     lg: \"syrup-storm-lg.png\",\r\n//     md: \"syrup-storm-md.png\",\r\n//     sm: \"syrup-storm-sm.png\",\r\n//     alt: \"syrup-storm-alt.png\",\r\n//     ipfs: \"https://gateway.pinata.cloud/ipfs/QmXKzSojwzYjtDCVgR6mVx7w7DbyYpS7zip4ovJB9fQdMG/syrup-storm.png\",\r\n//   },\r\n//   background: syrup-storm-bg.svg;\r\n//   textColor: \"#191326\";\r\n// }\r\n```\r\n\r\n### getProfile\r\n\r\nReturns full profile data for a given address. Under the hood retrieves username and team data using `getUsername` and `getTeam` and combines it with data from the profile contract. If address does not have a profile - returns `{ hasRegistered: false, profile: null }`. At the moment does not retrieve achievements (see [getAchievements](#getAchievements)).\r\n\r\nIt also sets `profile_${address}` cookie containing username and avatar (now only for pancakeswap.finance domain, maybe configurable in future versions)\r\n\r\n```js\r\nimport PancakeProfileSdk from \"@pancakeswap/profile-sdk\";\r\n\r\nconst pancakeSdk = new PancakeProfileSdk();\r\nconst profile = pancakeSdk.getProfile(\"0x123456789\");\r\nconsole.log(profile);\r\n// {\r\n//   hasRegistered: true\r\n//   profile: {\r\n//     userId: 6173,\r\n//     points: 2500,\r\n//     teamId: 1,\r\n//     nftAddress: \"0x11111111\",\r\n//     tokenId: 15,\r\n//     isActive: true,\r\n//     username: \"Matatabi\",\r\n//     nft: {\r\n//       name: \"Hiccup\",\r\n//       description: \"Oopsie daisy! Hiccup's had a bit of an accident. Poor little fella.\",\r\n//       images: {\r\n//         lg: \"hiccup-lg.png\",\r\n//         md: \"hiccup-md.png\",\r\n//         sm: \"hiccup-sm.png\",\r\n//         ipfs: \"https://gateway.pinata.cloud/ipfs/QmQ6EE6gkVzAQUdQLLM7CyrnME6LZHCoy92ZERW8HXmyjw/hiccup.png\",\r\n//       },\r\n//       sortOrder: 999,\r\n//       identifier: 'hiccup'\r\n//       type: 'pancake',\r\n//       variationId: 10\r\n//     },\r\n//     team: {\r\n//       id: 1,\r\n//       name: \"Syrup Storm\",\r\n//       description: \"The storm's a-comin! Watch out! These bulls are stampeding in a syrupy surge!\",\r\n//       isJoinable: true,\r\n//       users: 55123,\r\n//       points: 182500,\r\n//       images: images: {\r\n//         lg: \"syrup-storm-lg.png\",\r\n//         md: \"syrup-storm-md.png\",\r\n//         sm: \"syrup-storm-sm.png\",\r\n//         alt: \"syrup-storm-alt.png\",\r\n//         ipfs: \"https://gateway.pinata.cloud/ipfs/QmXKzSojwzYjtDCVgR6mVx7w7DbyYpS7zip4ovJB9fQdMG sy  rup-storm.png\",\r\n//       },\r\n//       background: syrup-storm-bg.svg,\r\n//       textColor: \"#191326\"\r\n//     },\r\n//     hasRegistered: true\r\n//   }\r\n// }\r\n```\r\n\r\n### getAchievements\r\n\r\nReturns array of achievements for a given address. If address has no achievements or no profile at all - returns empty array `[]`.\r\n\r\n```js\r\nimport PancakeProfileSdk from \"@pancakeswap/profile-sdk\";\r\n\r\nconst pancakeSdk = new PancakeProfileSdk();\r\n\r\nconst achievements = pancakeSdk.getAchievements(\"0x123456789\");\r\nconsole.log(achievements);\r\n// [\r\n//   {\r\n//     id: \"511080000\",\r\n//     type: \"ifo\",\r\n//     address: \"0x123456789\",\r\n//     title: {\r\n//       id: 999,\r\n//       fallback: `IFO Shopper: Belt`,\r\n//       data: {\r\n//         name: \"Belt\",\r\n//       },\r\n//     },\r\n//     description: {\r\n//       id: 999,\r\n//       fallback: `Committed more than $5 worth of LP in the Belt IFO`,\r\n//       data: {\r\n//         name: \"Belt\",\r\n//       },\r\n//     },\r\n//     badge: \"ifo-belt.svg\",\r\n//     points: 200,\r\n//   },\r\n//   {\r\n//     id: \"512010010\",\r\n//     type: \"teambattle\",\r\n//     address: \"0x123456789\",\r\n//     title: \"Easter Participant: Silver\",\r\n//     badge: \"easter-participant-silver.svg\",\r\n//     points: 500,\r\n//   },\r\n// ];\r\n```\r\n\r\n### Using images\r\n\r\nThis package bundles some images within itself, it exports `achievementBadges` and `teamImages` which are javascript objects with keys matching the image names returned by the API (e.g. `\"syrup-storm-md.png\"`) and values are Base64 encoded images:\r\n\r\n```JSX\r\nimport { Team, teamImages } from \"@pancakeswap/profile-sdk\";\r\n\r\nconst team = pancakeSdk.getTeam(1);\r\n// ...\r\nreturn <img src={teamImages[team.images.md]} alt={team.name} width=\"96px\" height=\"96px\" />\r\n```\r\n\r\nAlso `bunnyPlaceholder` image is exported to provide fallback for e.g. unregistered users.\r\n\r\n## Roadmap\r\n\r\nCurrent version of this SDK is 90% copy of existing from [pancake-frontend](https://github.com/pancakeswap/pancake-frontend) repo. There are several improvements to be made in the future versions of this SDK:\r\n\r\n- [ ] Better error handling (common bad status codes or broken internet connection)\r\n- [ ] Allow username & avatar cookie to be configurable or optional\r\n- [ ] Validate addresses and don't attempt to fetch data if address is not valid\r\n- [ ] NodeJS support. Currently it works out of the box only in browser. Need to research different options for cross-fetch and choose the one that provides less friction and increases bundle size the least.\r\n","readmeFilename":"README.md"}