mirror of
https://github.com/oceanprotocol/react.git
synced 2024-12-23 01:29:49 +01:00
test fix
This commit is contained in:
parent
a36d72d6d7
commit
2aa4f7b140
@ -44,10 +44,10 @@ function useConsume(): UseConsume {
|
|||||||
setConsumeStepText(consumeFeedback[2])
|
setConsumeStepText(consumeFeedback[2])
|
||||||
const res = JSON.parse(order)
|
const res = JSON.parse(order)
|
||||||
const tokenTransfer = await ocean.datatokens.transfer(
|
const tokenTransfer = await ocean.datatokens.transfer(
|
||||||
res['dataToken'],
|
res.dataToken,
|
||||||
res['to'],
|
res.to,
|
||||||
res['numTokens'],
|
res.numTokens,
|
||||||
res['from']
|
res.from
|
||||||
)
|
)
|
||||||
setConsumeStep(3)
|
setConsumeStep(3)
|
||||||
setConsumeStepText(consumeFeedback[3])
|
setConsumeStepText(consumeFeedback[3])
|
||||||
|
@ -12,8 +12,6 @@ interface UsePublish {
|
|||||||
) => Promise<DDO>
|
) => Promise<DDO>
|
||||||
mint: (tokenAddress: string, tokensToMint: number) => void
|
mint: (tokenAddress: string, tokensToMint: number) => void
|
||||||
}
|
}
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/development/Factory.json')
|
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json')
|
|
||||||
|
|
||||||
function usePublish(): UsePublish {
|
function usePublish(): UsePublish {
|
||||||
const { web3, ocean, status, account, accountId, config } = useOcean()
|
const { web3, ocean, status, account, accountId, config } = useOcean()
|
||||||
@ -21,14 +19,14 @@ function usePublish(): UsePublish {
|
|||||||
async function publish(
|
async function publish(
|
||||||
asset: Metadata,
|
asset: Metadata,
|
||||||
tokensToMint: number,
|
tokensToMint: number,
|
||||||
price: number = 1
|
price = 1
|
||||||
): Promise<DDO> {
|
): Promise<DDO> {
|
||||||
if (status !== ProviderStatus.CONNECTED) return
|
if (status !== ProviderStatus.CONNECTED) return
|
||||||
|
|
||||||
const datatoken = new DataTokens(
|
const datatoken = new DataTokens(
|
||||||
ocean.datatokens.factoryAddress,
|
ocean.datatokens.factoryAddress,
|
||||||
factory.abi,
|
ocean.datatokens.factoryABI,
|
||||||
datatokensTemplate.abi,
|
ocean.datatokens.datatokensABI,
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -80,8 +78,8 @@ function usePublish(): UsePublish {
|
|||||||
if (datatoken === undefined)
|
if (datatoken === undefined)
|
||||||
datatoken = new DataTokens(
|
datatoken = new DataTokens(
|
||||||
ocean.datatokens.factoryAddress,
|
ocean.datatokens.factoryAddress,
|
||||||
factory.abi,
|
ocean.datatokens.factoryABI,
|
||||||
datatokensTemplate.abi,
|
ocean.datatokens.datatokensABI,
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -97,8 +95,8 @@ function usePublish(): UsePublish {
|
|||||||
if (datatoken === undefined)
|
if (datatoken === undefined)
|
||||||
datatoken = new DataTokens(
|
datatoken = new DataTokens(
|
||||||
ocean.datatokens.factoryAddress,
|
ocean.datatokens.factoryAddress,
|
||||||
factory.abi,
|
ocean.datatokens.factoryABI,
|
||||||
datatokensTemplate.abi,
|
ocean.datatokens.datatokensABI,
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -117,11 +115,6 @@ function usePublish(): UsePublish {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
async function init(): Promise<void> {}
|
|
||||||
init()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
publish,
|
publish,
|
||||||
mint
|
mint
|
||||||
|
@ -4,9 +4,6 @@ import ProviderStatus from './ProviderStatus'
|
|||||||
import { Ocean, Logger, Account, Config } from '@oceanprotocol/lib'
|
import { Ocean, Logger, Account, Config } from '@oceanprotocol/lib'
|
||||||
import Web3Modal, { ICoreOptions } from 'web3modal'
|
import Web3Modal, { ICoreOptions } from 'web3modal'
|
||||||
|
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/development/Factory.json')
|
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json')
|
|
||||||
|
|
||||||
interface OceanProviderValue {
|
interface OceanProviderValue {
|
||||||
web3: Web3 | undefined
|
web3: Web3 | undefined
|
||||||
web3Provider: any
|
web3Provider: any
|
||||||
@ -61,10 +58,6 @@ function OceanProvider({
|
|||||||
const web3 = new Web3(provider)
|
const web3 = new Web3(provider)
|
||||||
setWeb3(web3)
|
setWeb3(web3)
|
||||||
|
|
||||||
config.factoryABI = config.factoryABI ? config.factoryABI : factory.abi
|
|
||||||
config.datatokensABI = config.datatokensABI
|
|
||||||
? config.datatokensABI
|
|
||||||
: datatokensTemplate.abi
|
|
||||||
config.web3Provider = web3
|
config.web3Provider = web3
|
||||||
const ocean = await Ocean.getInstance(config)
|
const ocean = await Ocean.getInstance(config)
|
||||||
|
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
import { Ocean, Config, Account, Logger } from '@oceanprotocol/squid'
|
|
||||||
import Balance from '@oceanprotocol/squid/dist/node/models/Balance'
|
|
||||||
import Web3 from 'web3'
|
|
||||||
|
|
||||||
export async function connectOcean(
|
|
||||||
web3: Web3,
|
|
||||||
config: Config
|
|
||||||
): Promise<{
|
|
||||||
ocean: Ocean
|
|
||||||
account: Account
|
|
||||||
accountId: string
|
|
||||||
balance: Balance
|
|
||||||
}> {
|
|
||||||
Logger.debug('Connecting to Ocean...')
|
|
||||||
const ocean = await Ocean.getInstance({
|
|
||||||
web3Provider: web3.currentProvider,
|
|
||||||
...config
|
|
||||||
})
|
|
||||||
Logger.debug('Ocean instance ready.')
|
|
||||||
// TODO : ocean was not connected and yet i got here and account was undefined so getId() threw an unmanaged error
|
|
||||||
const oceanAccounts = await ocean.accounts.list()
|
|
||||||
const account = oceanAccounts[0]
|
|
||||||
const accountId = account.getId()
|
|
||||||
const balance = await account.getBalance()
|
|
||||||
|
|
||||||
return { ocean, account, accountId, balance }
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user