mirror of
https://github.com/oceanprotocol/market.git
synced 2024-09-28 03:58:59 +02:00
more cleanup and typos
This commit is contained in:
parent
fe065aea58
commit
1a54dda59c
@ -1,11 +1,12 @@
|
|||||||
import { Logger, Ocean } from '@oceanprotocol/lib'
|
import { Logger, Ocean } from '@oceanprotocol/lib'
|
||||||
|
import { TransactionReceipt } from 'web3-core'
|
||||||
|
|
||||||
export async function setMinterToPublisher(
|
export async function setMinterToPublisher(
|
||||||
ocean: Ocean,
|
ocean: Ocean,
|
||||||
dataTokenAddress: string,
|
dataTokenAddress: string,
|
||||||
accountId: string,
|
accountId: string,
|
||||||
setError: (msg: string) => void
|
setError: (msg: string) => void
|
||||||
): Promise<any> {
|
): Promise<TransactionReceipt> {
|
||||||
// free pricing v3 workaround part1
|
// free pricing v3 workaround part1
|
||||||
const response = await ocean.OceanDispenser.cancelMinter(
|
const response = await ocean.OceanDispenser.cancelMinter(
|
||||||
dataTokenAddress,
|
dataTokenAddress,
|
||||||
@ -23,7 +24,7 @@ export async function setMinterToDispenser(
|
|||||||
dataTokenAddress: string,
|
dataTokenAddress: string,
|
||||||
accountId: string,
|
accountId: string,
|
||||||
setError: (msg: string) => void
|
setError: (msg: string) => void
|
||||||
): Promise<any> {
|
): Promise<TransactionReceipt> {
|
||||||
// free pricing v3 workaround part2
|
// free pricing v3 workaround part2
|
||||||
const response = await ocean.OceanDispenser.makeMinter(
|
const response = await ocean.OceanDispenser.makeMinter(
|
||||||
dataTokenAddress,
|
dataTokenAddress,
|
||||||
|
@ -76,7 +76,7 @@ export function checkIfTimeoutInPredefinedValues(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAlgoithComponent(
|
function getAlgorithmComponent(
|
||||||
image: string,
|
image: string,
|
||||||
containerTag: string,
|
containerTag: string,
|
||||||
entrypoint: string,
|
entrypoint: string,
|
||||||
@ -94,7 +94,7 @@ function getAlgoithComponent(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAlgoithFileExtension(fileUrl: string): string {
|
function getAlgorithmFileExtension(fileUrl: string): string {
|
||||||
const splitedFileUrl = fileUrl.split('.')
|
const splitedFileUrl = fileUrl.split('.')
|
||||||
return splitedFileUrl[splitedFileUrl.length - 1]
|
return splitedFileUrl[splitedFileUrl.length - 1]
|
||||||
}
|
}
|
||||||
@ -203,7 +203,6 @@ export function transformPublishAlgorithmFormToMetadata(
|
|||||||
author,
|
author,
|
||||||
description,
|
description,
|
||||||
tags,
|
tags,
|
||||||
dockerImage,
|
|
||||||
image,
|
image,
|
||||||
containerTag,
|
containerTag,
|
||||||
entrypoint,
|
entrypoint,
|
||||||
@ -214,12 +213,12 @@ export function transformPublishAlgorithmFormToMetadata(
|
|||||||
): MetadataMarket {
|
): MetadataMarket {
|
||||||
const currentTime = toStringNoMS(new Date())
|
const currentTime = toStringNoMS(new Date())
|
||||||
const fileUrl = typeof files !== 'string' && files[0].url
|
const fileUrl = typeof files !== 'string' && files[0].url
|
||||||
const algorithmLanguace = getAlgoithFileExtension(fileUrl)
|
const algorithmLanguage = getAlgorithmFileExtension(fileUrl)
|
||||||
const algorithm = getAlgoithComponent(
|
const algorithm = getAlgorithmComponent(
|
||||||
image,
|
image,
|
||||||
containerTag,
|
containerTag,
|
||||||
entrypoint,
|
entrypoint,
|
||||||
algorithmLanguace
|
algorithmLanguage
|
||||||
)
|
)
|
||||||
const metadata: MetadataMarket = {
|
const metadata: MetadataMarket = {
|
||||||
main: {
|
main: {
|
||||||
@ -230,7 +229,7 @@ export function transformPublishAlgorithmFormToMetadata(
|
|||||||
dateCreated: ddo ? ddo.created : currentTime,
|
dateCreated: ddo ? ddo.created : currentTime,
|
||||||
files: typeof files !== 'string' && files,
|
files: typeof files !== 'string' && files,
|
||||||
license: 'https://market.oceanprotocol.com/terms',
|
license: 'https://market.oceanprotocol.com/terms',
|
||||||
algorithm: algorithm
|
algorithm
|
||||||
},
|
},
|
||||||
additionalInformation: {
|
additionalInformation: {
|
||||||
...AssetModel.additionalInformation,
|
...AssetModel.additionalInformation,
|
||||||
@ -242,29 +241,3 @@ export function transformPublishAlgorithmFormToMetadata(
|
|||||||
|
|
||||||
return metadata
|
return metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
function idToName(id: number): string {
|
|
||||||
switch (id) {
|
|
||||||
case 1:
|
|
||||||
return 'eth'
|
|
||||||
case 137:
|
|
||||||
return 'polygon'
|
|
||||||
case 3:
|
|
||||||
return 'ropsten'
|
|
||||||
case 4:
|
|
||||||
return 'rinkeby'
|
|
||||||
case 1287:
|
|
||||||
return 'moonbase'
|
|
||||||
default:
|
|
||||||
return 'eth'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function mapChainIdsToNetworkNames(chainIds: number[]): string[] {
|
|
||||||
const networkNames: string[] = []
|
|
||||||
for (let i = 0; i < chainIds.length; i++) {
|
|
||||||
const networkName = idToName(chainIds[i])
|
|
||||||
networkNames.push(networkName)
|
|
||||||
}
|
|
||||||
return networkNames
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user