andrecronje / rarity

d20srd reference implementation codified in solidity
Other
610 stars 121 forks source link

[rarity-react] React SDK Bounty Request #91

Open murderteeth opened 3 years ago

murderteeth commented 3 years ago

rarity-react

source @ github

An easy way to build Rarity games with React.

NPM JavaScript Style Guide

It started with a simple app... I wanted to see my summoners and the prizes they'd won while on a new adventure. There's lots of great example code out there, eg RarityExtended. But I didn't see much in the way of libraries or tools. And so it was...

I started with these goals

  • Make it easy to start building a new Rarity app with React
  • Apps can configure which expansions they use
  • Apps can write their own expansions or integrate 3rd party expansions
  • Typescript-first

Please give this 1st draft a try - 👹🙏

Features

What's Next

Install

yarn add rarity-react

Usage

export default function() { const customConfig = { id: 'custom-expansion-id', contract: '0x123... contract address ...456', abi: [... contract abi ...] } as RarityExpansionConfig

const customExpansion = { id: 'custom-expansion-id', getSummonerCalls: (contract: Contract, summonerId: string) => { return[ contract.customContractCall(summonerId) ] as Call[]; }, getSummonerExpansion: (callResults: any[]) => { const [ customProperty ] = callResults return { customProperty } } }

const sideExpansions = [] as RarityExpansion[] sideExpansions.push(...configureExpansions([customConfig], [customExpansion]))

const { summoners } = useSummoners()

return {summoners.map(s => { return

{s.expansions["custom-expansion-id"].customProperty}
})} }



- - -
####  Bounty
Please send bounties and donations here 
[0x8BB5d5A7706Dfd2D25ABE850388e23fe0c54f933](https://ftmscan.com/address/0x8BB5d5A7706Dfd2D25ABE850388e23fe0c54f933)
- - -