Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nft #428

Merged
merged 13 commits into from
Aug 31, 2021
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@emotion/core": "^10.0.27",
"@emotion/styled": "^10.0.27",
"@ensdomains/ens-contracts": "^0.0.3",
"@wearekickback/contracts": "1.4.6",
"@wearekickback/contracts": "1.5.0",
"@wearekickback/shared": "^1.14.1",
"apollo-cache-inmemory": "^1.2.8",
"apollo-client": "^2.4.0",
Expand Down
41 changes: 28 additions & 13 deletions src/GlobalState.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ const TOKEN_SECRET = 'kickback'
const TOKEN_ALGORITHM = 'HS256'

const walletChecks = [{ checkName: 'connect' }, { checkName: 'network' }]

const getNetworkId = networkId => {
if (networkId === '35') {
// Default chainId for ganache
// return 1337
return 1337
} else {
return parseInt(networkId)
}
}

const wallets = [
{ walletName: 'coinbase', preferred: true },
{
Expand Down Expand Up @@ -78,15 +89,18 @@ const wallets = [
},
preferred: true
}
// Disabled as it throws an error message
// {
// walletName: 'squarelink',
// apiKey: SQUARELINK_KEY
// }
// Disabled as it throws an error message
// { walletName: 'dapper' }
]

const getWallets = networkId => {
console.log({ networkId })
if ([1, 100, 137].includes(networkId)) {
return wallets
} else {
// only return metamask for localhost
return [{ walletName: 'metamask', preferred: true }]
}
}

class Provider extends Component {
state = {
apolloClient: this.props.client,
Expand All @@ -108,7 +122,9 @@ class Provider extends Component {
return this.state.auth.loggedIn
}

setUpWallet = async ({ action, networkId, dontForceSetUp }) => {
setUpWallet = async args => {
const { action, networkId, dontForceSetUp } = args
console.log({ action, networkId, dontForceSetUp })
// Check if user has chosen a wallet before, if so just use that.
// If not, the user will have to select a wallet so only proceed if required.
const lastUsedWallet = LocalStorage.getItem(WALLET)
Expand All @@ -117,21 +133,20 @@ class Provider extends Component {
}

let { onboard } = this.state
console.log({ networkId, NETWORK_NAME })

if (!onboard) {
// dappid is mandatory so will have throw away id for local usage.
let testid = 'c212885d-e81d-416f-ac37-06d9ad2cf5af'
onboard = Onboard({
dappId: BLOCKNATIVE_DAPPID || testid,
networkId: parseInt(networkId),
networkName: NETWORK_NAME,
networkId: getNetworkId(networkId),
networkName: NETWORK_NAME || 'local',
walletCheck: walletChecks,
walletSelect: {
heading: 'Select a wallet to connect to Kickback',
description:
'To use Kickback you need an Ethereum wallet. Please select one from below:',
wallets
wallets: getWallets(getNetworkId(networkId))
}
})
this.setState({ onboard })
Expand Down Expand Up @@ -360,7 +375,7 @@ class Provider extends Component {
// Try and open wallet
await this.setUpWallet({
action: 'Sign In',
networkId: networkState.expectedNetworkId,
networkId: parseInt(networkState.expectedNetworkId),
dontForceSetUp: true
})

Expand Down
2 changes: 1 addition & 1 deletion src/api/resolvers/singleEventResolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const resolvers = {
let tokenAddress = args.tokenAddress

const web3 = await getWeb3()
const option = await getOption({ gas: 3000000 })
const option = await getOption()
if (tokenAddress === '') {
tokenAddress = EMPTY_ADDRESS
}
Expand Down
25 changes: 23 additions & 2 deletions src/components/UserProfile/UserProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ const TinyAvatarImg = styled('img')`
width: 15px;
`

const OpenSeaLink = styled('a')`
margin 1em;
`

export default function UserProfile({ profile: p }) {
let twitter,
walletLink,
Expand All @@ -137,8 +141,8 @@ export default function UserProfile({ profile: p }) {
p && p.eventsAttended.map(p => (p.isAttended = true))
p && p.eventsHosted.map(p => (p.isHosted = true))
const merged = _.merge(
_.keyBy(p.eventsAttended, 'name'),
_.keyBy(p.eventsHosted, 'name')
_.keyBy(p.eventsHosted, 'name'),
_.keyBy(p.eventsAttended, 'name')
)
sorted = _.sortBy(Object.values(merged), [
function(o) {
Expand Down Expand Up @@ -198,12 +202,29 @@ export default function UserProfile({ profile: p }) {
let contributionReceived = p.eventsContributionReceived.filter(
p => p.name === event.name
)
let tokenUrl

if (
event.isNft &&
event.participants &&
event.participants.length > 0
) {
tokenUrl = `https://opensea.io/assets/matic/${event.address}/${event.participants[0].index}`
}
return (
<EventAttendedContainer key={event.address}>
<EventLink to={`/event/${event.address}`}>
{event.name}
</EventLink>
{event.isHosted && '(Host)'}
{tokenUrl && (
<OpenSeaLink href={tokenUrl}>
<img
target="_blank"
src="https://opensea.io/favicon.ico"
/>
</OpenSeaLink>
)}
{(contributed.length > 0 ||
contributionReceived.length > 0) && (
<ContributionList>
Expand Down
35 changes: 34 additions & 1 deletion src/graphql/fragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const PartyFields = gql`
withdrawn
ownerAddress
optional
isNft
roles {
role
user {
Expand All @@ -87,7 +88,39 @@ export const ProfileFieldsDetailed = gql`
...PartyFields
}
eventsHosted {
...PartyFields
id
address
name
description
timezone
start
end
arriveBy
createdAt
location
headerImg
balance
deposit
tokenAddress
symbol
decimals
coolingPeriod
participantLimit
ended
finalizedAt
cancelled
status
clearFee
withdrawn
ownerAddress
optional
isNft
roles {
role
user {
...ProfileFields
}
}
}
eventsContributed {
amount
Expand Down
52 changes: 5 additions & 47 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4453,10 +4453,10 @@
dependencies:
"@walletconnect/window-getters" "^1.0.0"

"@wearekickback/contracts@1.4.6":
version "1.4.6"
resolved "https://registry.yarnpkg.com/@wearekickback/contracts/-/contracts-1.4.6.tgz#6f38fb5841893667d32951988efbf0365dfaa32f"
integrity sha512-mvRTT4ka4u0yRDPIw+1C2Q+gpa/qvXQU4RhyV4ExUVBWM+d7WwjVuT5DBuAownibzxtfsSnTbekiGIb1yuoyYg==
"@wearekickback/contracts@1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@wearekickback/contracts/-/contracts-1.5.0.tgz#c69016e29c833b263c18bf0b9e27f70a3d9fc964"
integrity sha512-nrTt7WJ9Z9qKMT6j0+nxHJwDR+FmA+L8NE/ZXyMqd7VFiRBWXlGTzlZyClnIjzwRVPwJ9pftRROxDDSkY2Vb0Q==

"@wearekickback/shared@^1.14.1":
version "1.14.1"
Expand Down Expand Up @@ -12372,28 +12372,7 @@ fs.realpath@^1.0.0:
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=

[email protected]:
version "1.2.4"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.4.tgz#f41dcb1af2582af3692da36fc55cbd8e1041c426"
integrity sha512-z8H8/diyk76B7q5wg+Ud0+CqzcAF3mBBI/bA5ne5zrRUUIvNkJY//D3BqyH571KuAC4Nr7Rw7CjWX4r0y9DvNg==
dependencies:
nan "^2.9.2"
node-pre-gyp "^0.10.0"

fsevents@^1.2.3, fsevents@^1.2.7:
version "1.2.13"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.13.tgz#f325cb0455592428bcf11b383370ef70e3bfcc38"
integrity sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==
dependencies:
bindings "^1.5.0"
nan "^2.12.1"

fsevents@~2.1.2:
version "2.1.3"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e"
integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==

fsevents@~2.3.1:
[email protected], [email protected], fsevents@^1.2.3, fsevents@^1.2.7, fsevents@~2.1.2, fsevents@~2.3.1:
version "2.3.2"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
Expand Down Expand Up @@ -17355,11 +17334,6 @@ nan@^2.12.1, nan@^2.13.2, nan@^2.14.0, nan@^2.14.2, nan@^2.2.1:
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19"
integrity sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==

nan@^2.9.2:
version "2.15.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee"
integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==

nano-base32@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/nano-base32/-/nano-base32-1.0.1.tgz#ba548c879efcfb90da1c4d9e097db4a46c9255ef"
Expand Down Expand Up @@ -17612,22 +17586,6 @@ node-notifier@^5.2.1:
shellwords "^0.1.1"
which "^1.3.0"

node-pre-gyp@^0.10.0:
version "0.10.3"
resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz#3070040716afdc778747b61b6887bf78880b80fc"
integrity sha512-d1xFs+C/IPS8Id0qPTZ4bUT8wWryfR/OzzAFxweG+uLN85oPzyo2Iw6bVlLQ/JOdgNonXLCoRyqDzDWq4iw72A==
dependencies:
detect-libc "^1.0.2"
mkdirp "^0.5.1"
needle "^2.2.1"
nopt "^4.0.1"
npm-packlist "^1.1.6"
npmlog "^4.0.2"
rc "^1.2.7"
rimraf "^2.6.1"
semver "^5.3.0"
tar "^4"

node-pre-gyp@^0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz#db1f33215272f692cd38f03238e3e9b47c5dd054"
Expand Down