diff --git a/src/api/contracts.ts b/src/api/contracts.ts index bc3594a..26ed438 100644 --- a/src/api/contracts.ts +++ b/src/api/contracts.ts @@ -3,8 +3,11 @@ import { Contract, Signer } from "ethers" import { BACKEND_URL } from "@/constants" import { http } from "./common" +export enum Contracts { + Adapter = "IAdapter", +} + async function getContractAbi(contractName: string): Promise { - // TODO: take artifact URL from instance config const url = `${BACKEND_URL}/contracts/${contractName}.json` const response = await http(url, { method: "GET", diff --git a/src/api/instance.ts b/src/api/instance.ts index 4178ce5..2181192 100644 --- a/src/api/instance.ts +++ b/src/api/instance.ts @@ -9,7 +9,6 @@ export interface InstanceInfo { registrations: boolean; login_message: string; blockchain_explorer_url: string | null; - blockchain_contract_name: string | null; blockchain_contract_address: string | null; ipfs_gateway_url: string | null; } diff --git a/src/api/nft.ts b/src/api/nft.ts index fa8eb9a..e283c44 100644 --- a/src/api/nft.ts +++ b/src/api/nft.ts @@ -4,7 +4,7 @@ import { TransactionResponse } from "@ethersproject/abstract-provider" import { BACKEND_URL } from "@/constants" import { Signature } from "@/utils/ethereum" import { http } from "./common" -import { getContract } from "./contracts" +import { Contracts, getContract } from "./contracts" import { Post } from "./posts" export async function makePermanent( @@ -49,14 +49,13 @@ export interface TokenMetadata { } export async function mintToken( - contractName: string, contractAddress: string, signer: Signer, ownerAddress: string, tokenUri: string, serverSignature: Signature, ): Promise { - const adapter = await getContract(contractName, contractAddress, signer) + const adapter = await getContract(Contracts.Adapter, contractAddress, signer) const transaction = await adapter.mint( ownerAddress, tokenUri, diff --git a/src/api/subscriptions.ts b/src/api/subscriptions.ts index 6d0e271..355c359 100644 --- a/src/api/subscriptions.ts +++ b/src/api/subscriptions.ts @@ -4,7 +4,7 @@ import { TransactionResponse } from "@ethersproject/abstract-provider" import { BACKEND_URL } from "@/constants" import { Signature } from "@/utils/ethereum" import { http } from "./common" -import { getContract } from "./contracts" +import { Contracts, getContract } from "./contracts" export async function getSubscriptionAuthorization( authToken: string, @@ -23,13 +23,12 @@ export async function getSubscriptionAuthorization( } export async function configureSubscription( - contractName: string, contractAddress: string, signer: Signer, recipientAddress: string, serverSignature: Signature, ): Promise { - const adapter = await getContract(contractName, contractAddress, signer) + const adapter = await getContract(Contracts.Adapter, contractAddress, signer) const transaction = await adapter.configureSubscription( recipientAddress, serverSignature.v, @@ -40,12 +39,11 @@ export async function configureSubscription( } export async function isSubscriptionConfigured( - contractName: string, contractAddress: string, signer: Signer, recipientAddress: string, ): Promise { - const adapter = await getContract(contractName, contractAddress, signer) + const adapter = await getContract(Contracts.Adapter, contractAddress, signer) const result = await adapter.isSubscriptionConfigured(recipientAddress) return result } diff --git a/src/components/Post.vue b/src/components/Post.vue index 23ac29f..2a0c5c6 100644 --- a/src/components/Post.vue +++ b/src/components/Post.vue @@ -457,7 +457,6 @@ export default class PostComponent extends Vue { if ( !currentUser || !instance || - !instance.blockchain_contract_name || !instance.blockchain_contract_address ) { return @@ -488,7 +487,6 @@ export default class PostComponent extends Vue { } try { const transaction = await mintToken( - instance.blockchain_contract_name, instance.blockchain_contract_address, signer, currentUser.wallet_address, diff --git a/src/views/Profile.vue b/src/views/Profile.vue index 634aa9b..08f673c 100644 --- a/src/views/Profile.vue +++ b/src/views/Profile.vue @@ -316,7 +316,6 @@ export default class ProfileView extends Vue { !this.profile || !this.profile.wallet_address || !instance || - !instance.blockchain_contract_name || !instance.blockchain_contract_address ) { return @@ -326,7 +325,6 @@ export default class ProfileView extends Vue { return } this.subscriptionConfigured = await isSubscriptionConfigured( - instance.blockchain_contract_name, instance.blockchain_contract_address, signer, this.profile.wallet_address, @@ -338,7 +336,6 @@ export default class ProfileView extends Vue { if ( !currentUser || !instance || - !instance.blockchain_contract_name || !instance.blockchain_contract_address ) { return @@ -351,7 +348,6 @@ export default class ProfileView extends Vue { const authToken = this.store.ensureAuthToken() const signature = await getSubscriptionAuthorization(authToken) await configureSubscription( - instance.blockchain_contract_name, instance.blockchain_contract_address, signer, currentUser.wallet_address,