Use Cosmos Kit with Keplr Extension support.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { Coin } from '@cosmjs/proto-signing'
|
||||
import type { logs } from '@cosmjs/stargate'
|
||||
import { useWallet } from 'contexts/wallet'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useWallet } from 'utils/wallet'
|
||||
|
||||
import type { BadgeHubContract, BadgeHubInstance, BadgeHubMessages, MigrateResponse } from './contract'
|
||||
import { badgeHub as initContract } from './contract'
|
||||
@@ -50,9 +50,19 @@ export function useBadgeHubContract(): UseBadgeHubContractProps {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const BadgeHubBaseContract = initContract(wallet.getClient(), wallet.address)
|
||||
setBadgeHub(BadgeHubBaseContract)
|
||||
}, [wallet])
|
||||
if (!wallet.isWalletConnected) {
|
||||
return
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
const client = await wallet.getSigningCosmWasmClient()
|
||||
const BadgeHubBaseContract = initContract(client, wallet.address || '')
|
||||
setBadgeHub(BadgeHubBaseContract)
|
||||
}
|
||||
|
||||
load().catch(console.error)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wallet.isWalletConnected, wallet.address])
|
||||
|
||||
const updateContractAddress = (contractAddress: string) => {
|
||||
setAddress(contractAddress)
|
||||
@@ -65,7 +75,10 @@ export function useBadgeHubContract(): UseBadgeHubContractProps {
|
||||
reject(new Error('Contract is not initialized.'))
|
||||
return
|
||||
}
|
||||
badgeHub.instantiate(wallet.address, codeId, initMsg, label, admin).then(resolve).catch(reject)
|
||||
badgeHub
|
||||
.instantiate(wallet.address || '', codeId, initMsg, label, admin)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
})
|
||||
},
|
||||
[badgeHub, wallet],
|
||||
@@ -79,7 +92,10 @@ export function useBadgeHubContract(): UseBadgeHubContractProps {
|
||||
return
|
||||
}
|
||||
console.log(wallet.address, contractAddress, codeId)
|
||||
badgeHub.migrate(wallet.address, contractAddress, codeId, migrateMsg).then(resolve).catch(reject)
|
||||
badgeHub
|
||||
.migrate(wallet.address || '', contractAddress, codeId, migrateMsg)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
})
|
||||
},
|
||||
[badgeHub, wallet],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useWallet } from 'contexts/wallet'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useWallet } from 'utils/wallet'
|
||||
|
||||
import type { BaseFactoryContract, BaseFactoryInstance, BaseFactoryMessages } from './contract'
|
||||
import { baseFactory as initContract } from './contract'
|
||||
@@ -22,9 +22,19 @@ export function useBaseFactoryContract(): UseBaseFactoryContractProps {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const BaseFactoryBaseContract = initContract(wallet.getClient(), wallet.address)
|
||||
setBaseFactory(BaseFactoryBaseContract)
|
||||
}, [wallet])
|
||||
if (!wallet.isWalletConnected) {
|
||||
return
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
const client = await wallet.getSigningCosmWasmClient()
|
||||
const BaseFactoryBaseContract = initContract(client, wallet.address || '')
|
||||
setBaseFactory(BaseFactoryBaseContract)
|
||||
}
|
||||
|
||||
load().catch(console.error)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wallet.isWalletConnected, wallet.address])
|
||||
|
||||
const updateContractAddress = (contractAddress: string) => {
|
||||
setAddress(contractAddress)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Coin } from '@cosmjs/proto-signing'
|
||||
import type { logs } from '@cosmjs/stargate'
|
||||
import { useWallet } from 'contexts/wallet'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useWallet } from 'utils/wallet'
|
||||
|
||||
import type { BaseMinterContract, BaseMinterInstance, BaseMinterMessages, MigrateResponse } from './contract'
|
||||
import { baseMinter as initContract } from './contract'
|
||||
@@ -38,9 +38,19 @@ export function useBaseMinterContract(): UseBaseMinterContractProps {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const BaseMinterBaseContract = initContract(wallet.getClient(), wallet.address)
|
||||
setBaseMinter(BaseMinterBaseContract)
|
||||
}, [wallet])
|
||||
if (!wallet.isWalletConnected) {
|
||||
return
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
const client = await wallet.getSigningCosmWasmClient()
|
||||
const BaseMinterBaseContract = initContract(client, wallet.address || '')
|
||||
setBaseMinter(BaseMinterBaseContract)
|
||||
}
|
||||
|
||||
load().catch(console.error)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wallet.isWalletConnected, wallet.address])
|
||||
|
||||
const updateContractAddress = (contractAddress: string) => {
|
||||
setAddress(contractAddress)
|
||||
@@ -53,7 +63,10 @@ export function useBaseMinterContract(): UseBaseMinterContractProps {
|
||||
reject(new Error('Contract is not initialized.'))
|
||||
return
|
||||
}
|
||||
baseMinter.instantiate(wallet.address, codeId, initMsg, label, admin).then(resolve).catch(reject)
|
||||
baseMinter
|
||||
.instantiate(wallet.address || '', codeId, initMsg, label, admin)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
})
|
||||
},
|
||||
[baseMinter, wallet],
|
||||
@@ -67,7 +80,10 @@ export function useBaseMinterContract(): UseBaseMinterContractProps {
|
||||
return
|
||||
}
|
||||
console.log(wallet.address, contractAddress, codeId)
|
||||
baseMinter.migrate(wallet.address, contractAddress, codeId, migrateMsg).then(resolve).catch(reject)
|
||||
baseMinter
|
||||
.migrate(wallet.address || '', contractAddress, codeId, migrateMsg)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
})
|
||||
},
|
||||
[baseMinter, wallet],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { logs } from '@cosmjs/stargate'
|
||||
import { useWallet } from 'contexts/wallet'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useWallet } from 'utils/wallet'
|
||||
|
||||
import type { OpenEditionFactoryContract, OpenEditionFactoryInstance, OpenEditionFactoryMessages } from './contract'
|
||||
import { openEditionFactory as initContract } from './contract'
|
||||
@@ -41,9 +41,19 @@ export function useOpenEditionFactoryContract(): UseOpenEditionFactoryContractPr
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const OpenEditionFactoryBaseContract = initContract(wallet.getClient(), wallet.address)
|
||||
setOpenEditionFactory(OpenEditionFactoryBaseContract)
|
||||
}, [wallet])
|
||||
if (!wallet.isWalletConnected) {
|
||||
return
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
const client = await wallet.getSigningCosmWasmClient()
|
||||
const OpenEditionFactoryBaseContract = initContract(client, wallet.address || '')
|
||||
setOpenEditionFactory(OpenEditionFactoryBaseContract)
|
||||
}
|
||||
|
||||
load().catch(console.error)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wallet.isWalletConnected, wallet.address])
|
||||
|
||||
const updateContractAddress = (contractAddress: string) => {
|
||||
setAddress(contractAddress)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Coin } from '@cosmjs/proto-signing'
|
||||
import type { logs } from '@cosmjs/stargate'
|
||||
import { useWallet } from 'contexts/wallet'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useWallet } from 'utils/wallet'
|
||||
|
||||
import type {
|
||||
MigrateResponse,
|
||||
@@ -55,9 +55,19 @@ export function useOpenEditionMinterContract(): UseOpenEditionMinterContractProp
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const OpenEditionMinterBaseContract = initContract(wallet.getClient(), wallet.address)
|
||||
setOpenEditionMinter(OpenEditionMinterBaseContract)
|
||||
}, [wallet])
|
||||
if (!wallet.isWalletConnected) {
|
||||
return
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
const client = await wallet.getSigningCosmWasmClient()
|
||||
const OpenEditionMinterBaseContract = initContract(client, wallet.address || '')
|
||||
setOpenEditionMinter(OpenEditionMinterBaseContract)
|
||||
}
|
||||
|
||||
load().catch(console.error)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wallet.isWalletConnected, wallet.address])
|
||||
|
||||
const updateContractAddress = (contractAddress: string) => {
|
||||
setAddress(contractAddress)
|
||||
@@ -70,7 +80,10 @@ export function useOpenEditionMinterContract(): UseOpenEditionMinterContractProp
|
||||
reject(new Error('Contract is not initialized.'))
|
||||
return
|
||||
}
|
||||
openEditionMinter.instantiate(wallet.address, codeId, initMsg, label, admin).then(resolve).catch(reject)
|
||||
openEditionMinter
|
||||
.instantiate(wallet.address || '', codeId, initMsg, label, admin)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
})
|
||||
},
|
||||
[openEditionMinter, wallet],
|
||||
@@ -84,7 +97,10 @@ export function useOpenEditionMinterContract(): UseOpenEditionMinterContractProp
|
||||
return
|
||||
}
|
||||
console.log(wallet.address, contractAddress, codeId)
|
||||
openEditionMinter.migrate(wallet.address, contractAddress, codeId, migrateMsg).then(resolve).catch(reject)
|
||||
openEditionMinter
|
||||
.migrate(wallet.address || '', contractAddress, codeId, migrateMsg)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
})
|
||||
},
|
||||
[openEditionMinter, wallet],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable eslint-comments/disable-enable-pair */
|
||||
|
||||
import { useWallet } from 'contexts/wallet'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useWallet } from 'utils/wallet'
|
||||
|
||||
import type {
|
||||
InstantiateResponse,
|
||||
@@ -40,9 +40,19 @@ export function useRoyaltyRegistryContract(): UseRoyaltyRegistryContractProps {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const royaltyRegistryContract = initContract(wallet.getClient(), wallet.address)
|
||||
setRoyaltyRegistry(royaltyRegistryContract)
|
||||
}, [wallet])
|
||||
if (!wallet.isWalletConnected) {
|
||||
return
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
const client = await wallet.getSigningCosmWasmClient()
|
||||
const royaltyRegistryContract = initContract(client, wallet.address || '')
|
||||
setRoyaltyRegistry(royaltyRegistryContract)
|
||||
}
|
||||
|
||||
load().catch(console.error)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wallet.isWalletConnected, wallet.address])
|
||||
|
||||
const updateContractAddress = (contractAddress: string) => {
|
||||
setAddress(contractAddress)
|
||||
@@ -69,7 +79,10 @@ export function useRoyaltyRegistryContract(): UseRoyaltyRegistryContractProps {
|
||||
return
|
||||
}
|
||||
console.log(wallet.address, contractAddress, codeId)
|
||||
royaltyRegistry.migrate(wallet.address, contractAddress, codeId, migrateMsg).then(resolve).catch(reject)
|
||||
royaltyRegistry
|
||||
.migrate(wallet.address || '', contractAddress, codeId, migrateMsg)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
})
|
||||
},
|
||||
[royaltyRegistry, wallet],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Coin } from '@cosmjs/proto-signing'
|
||||
import { useWallet } from 'contexts/wallet'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useWallet } from 'utils/wallet'
|
||||
|
||||
import type { MigrateResponse, SG721Contract, SG721Instance, Sg721Messages } from './contract'
|
||||
import { SG721 as initContract } from './contract'
|
||||
@@ -35,9 +35,19 @@ export function useSG721Contract(): UseSG721ContractProps {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const contract = initContract(wallet.getClient(), wallet.address)
|
||||
setSG721(contract)
|
||||
}, [wallet])
|
||||
if (!wallet.isWalletConnected) {
|
||||
return
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
const client = await wallet.getSigningCosmWasmClient()
|
||||
const contract = initContract(client, wallet.address || '')
|
||||
setSG721(contract)
|
||||
}
|
||||
|
||||
load().catch(console.error)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wallet.isWalletConnected, wallet.address])
|
||||
|
||||
const updateContractAddress = (contractAddress: string) => {
|
||||
setAddress(contractAddress)
|
||||
@@ -50,7 +60,9 @@ export function useSG721Contract(): UseSG721ContractProps {
|
||||
reject(new Error('Contract is not initialized.'))
|
||||
return
|
||||
}
|
||||
SG721.instantiate(wallet.address, codeId, initMsg, label, admin).then(resolve).catch(reject)
|
||||
SG721.instantiate(wallet.address || '', codeId, initMsg, label, admin)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
})
|
||||
},
|
||||
[SG721, wallet],
|
||||
@@ -64,7 +76,9 @@ export function useSG721Contract(): UseSG721ContractProps {
|
||||
return
|
||||
}
|
||||
console.log(wallet.address, contractAddress, codeId)
|
||||
SG721.migrate(wallet.address, contractAddress, codeId, migrateMsg).then(resolve).catch(reject)
|
||||
SG721.migrate(wallet.address || '', contractAddress, codeId, migrateMsg)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
})
|
||||
},
|
||||
[SG721, wallet],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable eslint-comments/disable-enable-pair */
|
||||
|
||||
import { useWallet } from 'contexts/wallet'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useWallet } from 'utils/wallet'
|
||||
|
||||
import type { InstantiateResponse, MigrateResponse, SplitsContract, SplitsInstance, SplitsMessages } from './contract'
|
||||
import { Splits as initContract } from './contract'
|
||||
@@ -34,9 +34,19 @@ export function useSplitsContract(): UseSplitsContractProps {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const splitsContract = initContract(wallet.getClient(), wallet.address)
|
||||
setSplits(splitsContract)
|
||||
}, [wallet])
|
||||
if (!wallet.isWalletConnected) {
|
||||
return
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
const client = await wallet.getSigningCosmWasmClient()
|
||||
const contract = initContract(client, wallet.address || '')
|
||||
setSplits(contract)
|
||||
}
|
||||
|
||||
load().catch(console.error)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wallet.isWalletConnected, wallet.address])
|
||||
|
||||
const updateContractAddress = (contractAddress: string) => {
|
||||
setAddress(contractAddress)
|
||||
@@ -63,7 +73,10 @@ export function useSplitsContract(): UseSplitsContractProps {
|
||||
return
|
||||
}
|
||||
console.log(wallet.address, contractAddress, codeId)
|
||||
splits.migrate(wallet.address, contractAddress, codeId, migrateMsg).then(resolve).catch(reject)
|
||||
splits
|
||||
.migrate(wallet.address || '', contractAddress, codeId, migrateMsg)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
})
|
||||
},
|
||||
[splits, wallet],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { logs } from '@cosmjs/stargate'
|
||||
import { useWallet } from 'contexts/wallet'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useWallet } from 'utils/wallet'
|
||||
|
||||
import type { VendingFactoryContract, VendingFactoryInstance, VendingFactoryMessages } from './contract'
|
||||
import { vendingFactory as initContract } from './contract'
|
||||
@@ -41,9 +41,19 @@ export function useVendingFactoryContract(): UseVendingFactoryContractProps {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const VendingFactoryBaseContract = initContract(wallet.getClient(), wallet.address)
|
||||
setVendingFactory(VendingFactoryBaseContract)
|
||||
}, [wallet])
|
||||
if (!wallet.isWalletConnected) {
|
||||
return
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
const client = await wallet.getSigningCosmWasmClient()
|
||||
const contract = initContract(client, wallet.address || '')
|
||||
setVendingFactory(contract)
|
||||
}
|
||||
|
||||
load().catch(console.error)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wallet.isWalletConnected, wallet.address])
|
||||
|
||||
const updateContractAddress = (contractAddress: string) => {
|
||||
setAddress(contractAddress)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Coin } from '@cosmjs/proto-signing'
|
||||
import type { logs } from '@cosmjs/stargate'
|
||||
import { useWallet } from 'contexts/wallet'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useWallet } from 'utils/wallet'
|
||||
|
||||
import type { MigrateResponse, VendingMinterContract, VendingMinterInstance, VendingMinterMessages } from './contract'
|
||||
import { vendingMinter as initContract } from './contract'
|
||||
@@ -50,9 +50,19 @@ export function useVendingMinterContract(): UseVendingMinterContractProps {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const VendingMinterBaseContract = initContract(wallet.getClient(), wallet.address)
|
||||
setVendingMinter(VendingMinterBaseContract)
|
||||
}, [wallet])
|
||||
if (!wallet.isWalletConnected) {
|
||||
return
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
const client = await wallet.getSigningCosmWasmClient()
|
||||
const contract = initContract(client, wallet.address || '')
|
||||
setVendingMinter(contract)
|
||||
}
|
||||
|
||||
load().catch(console.error)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wallet.isWalletConnected, wallet.address])
|
||||
|
||||
const updateContractAddress = (contractAddress: string) => {
|
||||
setAddress(contractAddress)
|
||||
@@ -65,7 +75,10 @@ export function useVendingMinterContract(): UseVendingMinterContractProps {
|
||||
reject(new Error('Contract is not initialized.'))
|
||||
return
|
||||
}
|
||||
vendingMinter.instantiate(wallet.address, codeId, initMsg, label, admin).then(resolve).catch(reject)
|
||||
vendingMinter
|
||||
.instantiate(wallet.address || '', codeId, initMsg, label, admin)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
})
|
||||
},
|
||||
[vendingMinter, wallet],
|
||||
@@ -79,7 +92,10 @@ export function useVendingMinterContract(): UseVendingMinterContractProps {
|
||||
return
|
||||
}
|
||||
console.log(wallet.address, contractAddress, codeId)
|
||||
vendingMinter.migrate(wallet.address, contractAddress, codeId, migrateMsg).then(resolve).catch(reject)
|
||||
vendingMinter
|
||||
.migrate(wallet.address || '', contractAddress, codeId, migrateMsg)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
})
|
||||
},
|
||||
[vendingMinter, wallet],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useWallet } from 'contexts/wallet'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useWallet } from 'utils/wallet'
|
||||
|
||||
import type { InstantiateResponse, WhiteListContract, WhiteListInstance, WhitelistMessages } from './contract'
|
||||
import { WhiteList as initContract } from './contract'
|
||||
@@ -30,9 +30,19 @@ export function useWhiteListContract(): UseWhiteListContractProps {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const whiteListContract = initContract(wallet.getClient(), wallet.address)
|
||||
setWhiteList(whiteListContract)
|
||||
}, [wallet])
|
||||
if (!wallet.isWalletConnected) {
|
||||
return
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
const client = await wallet.getSigningCosmWasmClient()
|
||||
const contract = initContract(client, wallet.address || '')
|
||||
setWhiteList(contract)
|
||||
}
|
||||
|
||||
load().catch(console.error)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wallet.isWalletConnected, wallet.address])
|
||||
|
||||
const updateContractAddress = (contractAddress: string) => {
|
||||
setAddress(contractAddress)
|
||||
|
||||
Reference in New Issue
Block a user