generated from proofoftom/buidler-waffle-typechain-quasar
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI changes to support different recipient registries
- Loading branch information
Showing
20 changed files
with
260 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { BigNumber, Contract } from 'ethers' | ||
import sdk from '@/graphql/sdk' | ||
import { BaseRecipientRegistry } from './abi' | ||
import { provider, ipfsGatewayUrl, recipientRegistryPolicy } from './core' | ||
import { chain } from '@/api/core' | ||
|
||
export interface RegistryInfo { | ||
deposit: BigNumber | ||
depositToken: string | ||
challengePeriodDuration: number | ||
listingPolicyUrl: string | ||
recipientCount: number | ||
owner: string | ||
} | ||
|
||
export async function getRegistryInfo( | ||
registryAddress: string | ||
): Promise<RegistryInfo> { | ||
const data = await sdk.GetRecipientRegistry({ | ||
registryAddress: registryAddress.toLowerCase(), | ||
}) | ||
|
||
const recipientRegistry = data.recipientRegistry | ||
const baseDeposit = recipientRegistry?.baseDeposit || BigNumber.from(0) | ||
const challengePeriodDuration = | ||
recipientRegistry?.challengePeriodDuration || BigNumber.from(0) | ||
const owner = recipientRegistry?.owner || '' | ||
|
||
/* TODO: get recipient count from the subgraph */ | ||
const registry = new Contract( | ||
registryAddress, | ||
BaseRecipientRegistry, | ||
provider | ||
) | ||
const recipientCount = await registry.getRecipientCount() | ||
|
||
return { | ||
deposit: baseDeposit, | ||
depositToken: chain.currency, | ||
challengePeriodDuration: challengePeriodDuration.toNumber(), | ||
listingPolicyUrl: `${ipfsGatewayUrl}/ipfs/${recipientRegistryPolicy}`, | ||
recipientCount: recipientCount.toNumber(), | ||
owner, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
query GetRecipientRegistry($registryAddress: ID!) { | ||
recipientRegistry(id: $registryAddress) { | ||
id | ||
baseDeposit | ||
challengePeriodDuration | ||
owner | ||
controller | ||
maxRecipients | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Vue from 'vue' | ||
import Component from 'vue-class-component' | ||
import { recipientRegistryType, RecipientRegistryType } from '@/api/core' | ||
|
||
// these registries support recipient registration | ||
const SUPPORT_REGISTRATION = [RecipientRegistryType.OPTIMISTIC] | ||
|
||
// these registries require registration deposits | ||
const REQUIRE_DEPOSIT = [RecipientRegistryType.OPTIMISTIC] | ||
|
||
@Component | ||
export class RecipientRegistryPlugin extends Vue { | ||
get supportRegistration(): boolean { | ||
return SUPPORT_REGISTRATION.includes( | ||
recipientRegistryType as RecipientRegistryType | ||
) | ||
} | ||
|
||
get requireDeposit(): boolean { | ||
return REQUIRE_DEPOSIT.includes( | ||
recipientRegistryType as RecipientRegistryType | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.