mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Merge pull request #1500 from oceanprotocol/issue-1474-refactoring-move-types-to-types-folder
Issue-#1474: Refactoring(3). Move types to src\@types folder
This commit is contained in:
commit
d613f33213
@ -5,3 +5,13 @@ export interface DispenserCreationParams {
|
||||
withMint?: boolean // true if we want to allow the dispenser to be a minter
|
||||
allowedSwapper?: string // only account that can ask tokens. set address(0) if not required
|
||||
}
|
||||
|
||||
export interface DispenserToken {
|
||||
active: boolean
|
||||
owner: string
|
||||
maxTokens: string
|
||||
maxBalance: string
|
||||
balance: string
|
||||
isMinter: boolean
|
||||
allowedSwapper: string
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { ProviderFees } from '.'
|
||||
|
||||
export interface Erc20CreateParams {
|
||||
templateIndex: number
|
||||
minter: string
|
||||
@ -21,3 +23,22 @@ export interface PublishingMarketFee {
|
||||
publishMarketFeeToken: string
|
||||
publishMarketFeeAmount: string
|
||||
}
|
||||
|
||||
export interface DatatokenRoles {
|
||||
minter: boolean
|
||||
paymentManager: boolean
|
||||
}
|
||||
|
||||
export interface OrderParams {
|
||||
consumer: string
|
||||
serviceIndex: number
|
||||
_providerFee: ProviderFees
|
||||
_consumeMarketFee: ConsumeMarketFee
|
||||
}
|
||||
|
||||
export interface DispenserParams {
|
||||
maxTokens: string
|
||||
maxBalance: string
|
||||
withMint?: boolean // true if we want to allow the dispenser to be a minter
|
||||
allowedSwapper?: string // only account that can ask tokens. set address(0) if not required
|
||||
}
|
||||
|
@ -11,3 +11,10 @@ export interface MetadataAndTokenURI {
|
||||
tokenURI: string
|
||||
metadataProofs?: MetadataProof[]
|
||||
}
|
||||
|
||||
export interface NftRoles {
|
||||
manager: boolean
|
||||
deployERC20: boolean
|
||||
updateMetadata: boolean
|
||||
store: boolean
|
||||
}
|
||||
|
@ -25,3 +25,29 @@ export interface PriceAndFees {
|
||||
marketFeeAmount: string
|
||||
consumeMarketFeeAmount: string
|
||||
}
|
||||
|
||||
export interface FixedPriceExchange {
|
||||
active: boolean
|
||||
exchangeOwner: string
|
||||
datatoken: string
|
||||
baseToken: string
|
||||
fixedRate: string
|
||||
dtDecimals: string
|
||||
btDecimals: string
|
||||
dtBalance: string
|
||||
btBalance: string
|
||||
dtSupply: string
|
||||
btSupply: string
|
||||
withMint: boolean
|
||||
allowedSwapper: string
|
||||
exchangeId?: string
|
||||
}
|
||||
|
||||
export interface FeesInfo {
|
||||
opcFee: string
|
||||
marketFee: string
|
||||
marketFeeCollector: string
|
||||
marketFeeAvailable: string
|
||||
oceanFeeAvailable: string
|
||||
exchangeId: string
|
||||
}
|
||||
|
23
src/@types/NFTFactory.ts
Normal file
23
src/@types/NFTFactory.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { ConsumeMarketFee, ProviderFees } from '.'
|
||||
|
||||
export interface Template {
|
||||
templateAddress: string
|
||||
isActive: boolean
|
||||
}
|
||||
|
||||
export interface TokenOrder {
|
||||
tokenAddress: string
|
||||
consumer: string
|
||||
serviceIndex: number
|
||||
_providerFee: ProviderFees
|
||||
_consumeMarketFee: ConsumeMarketFee
|
||||
}
|
||||
|
||||
export interface NftCreateData {
|
||||
name: string
|
||||
symbol: string
|
||||
templateIndex: number
|
||||
tokenURI: string
|
||||
transferable: boolean
|
||||
owner: string
|
||||
}
|
@ -26,3 +26,12 @@ export interface ProviderComputeInitializeResults {
|
||||
algorithm?: ProviderComputeInitialize
|
||||
datasets?: ProviderComputeInitialize[]
|
||||
}
|
||||
|
||||
export interface ServiceEndpoint {
|
||||
serviceName: string
|
||||
method: string
|
||||
urlPath: string
|
||||
}
|
||||
export interface UserCustomParameters {
|
||||
[key: string]: any
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ export * from './Erc20'
|
||||
export * from './Erc721'
|
||||
export * from './FileMetadata'
|
||||
export * from './FixedPrice'
|
||||
export * from './NFTFactory'
|
||||
export * from './Pool'
|
||||
export * from './Provider'
|
||||
export * from './Router'
|
||||
|
@ -16,36 +16,15 @@ import {
|
||||
} from '../../utils'
|
||||
import { Config, ConfigHelper } from '../../config'
|
||||
import {
|
||||
ProviderFees,
|
||||
FreCreationParams,
|
||||
Erc20CreateParams,
|
||||
PoolCreationParams,
|
||||
DispenserCreationParams,
|
||||
ConsumeMarketFee
|
||||
NftCreateData,
|
||||
Template,
|
||||
TokenOrder
|
||||
} from '../../@types'
|
||||
|
||||
interface Template {
|
||||
templateAddress: string
|
||||
isActive: boolean
|
||||
}
|
||||
|
||||
export interface TokenOrder {
|
||||
tokenAddress: string
|
||||
consumer: string
|
||||
serviceIndex: number
|
||||
_providerFee: ProviderFees
|
||||
_consumeMarketFee: ConsumeMarketFee
|
||||
}
|
||||
|
||||
export interface NftCreateData {
|
||||
name: string
|
||||
symbol: string
|
||||
templateIndex: number
|
||||
tokenURI: string
|
||||
transferable: boolean
|
||||
owner: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides an interface for NFT Factory contract
|
||||
*/
|
||||
|
@ -12,16 +12,7 @@ import {
|
||||
} from '../../utils/'
|
||||
import { Datatoken } from '..'
|
||||
import { Config, ConfigHelper } from '../../config'
|
||||
|
||||
export interface DispenserToken {
|
||||
active: boolean
|
||||
owner: string
|
||||
maxTokens: string
|
||||
maxBalance: string
|
||||
balance: string
|
||||
isMinter: boolean
|
||||
allowedSwapper: string
|
||||
}
|
||||
import { DispenserToken } from '../../@types'
|
||||
|
||||
export class Dispenser {
|
||||
public web3: Web3 = null
|
||||
|
@ -13,50 +13,10 @@ import {
|
||||
ZERO_ADDRESS
|
||||
} from '../../utils'
|
||||
import { Config, ConfigHelper } from '../../config'
|
||||
import { PriceAndFees } from '../../@types'
|
||||
|
||||
export interface FixedPriceExchange {
|
||||
active: boolean
|
||||
exchangeOwner: string
|
||||
datatoken: string
|
||||
baseToken: string
|
||||
fixedRate: string
|
||||
dtDecimals: string
|
||||
btDecimals: string
|
||||
dtBalance: string
|
||||
btBalance: string
|
||||
dtSupply: string
|
||||
btSupply: string
|
||||
withMint: boolean
|
||||
allowedSwapper: string
|
||||
exchangeId?: string
|
||||
}
|
||||
|
||||
export interface FeesInfo {
|
||||
opcFee: string
|
||||
marketFee: string
|
||||
marketFeeCollector: string
|
||||
marketFeeAvailable: string
|
||||
oceanFeeAvailable: string
|
||||
exchangeId: string
|
||||
}
|
||||
export interface FixedPriceSwap {
|
||||
exchangeId: string
|
||||
caller: string
|
||||
baseTokenAmount: string
|
||||
datatokenAmount: string
|
||||
}
|
||||
|
||||
/* eslint-disable no-unused-vars */
|
||||
export enum FixedRateCreateProgressStep {
|
||||
CreatingExchange,
|
||||
ApprovingDatatoken
|
||||
}
|
||||
/* eslint-enable no-unused-vars */
|
||||
import { PriceAndFees, FeesInfo, FixedPriceExchange } from '../../@types'
|
||||
|
||||
export class FixedRateExchange {
|
||||
/** Ocean related functions */
|
||||
public oceanAddress: string = null
|
||||
public fixedRateAddress: string
|
||||
public fixedRateExchangeAbi: AbiItem | AbiItem[]
|
||||
public web3: Web3
|
||||
@ -75,14 +35,12 @@ export class FixedRateExchange {
|
||||
fixedRateAddress: string,
|
||||
network?: string | number,
|
||||
fixedRateExchangeAbi: AbiItem | AbiItem[] = null,
|
||||
oceanAddress: string = null,
|
||||
config?: Config
|
||||
) {
|
||||
this.web3 = web3
|
||||
this.config = config || new ConfigHelper().getConfig(network || 'unknown')
|
||||
this.fixedRateExchangeAbi =
|
||||
fixedRateExchangeAbi || (defaultFixedRateExchangeAbi.abi as AbiItem[])
|
||||
this.oceanAddress = oceanAddress
|
||||
this.fixedRateAddress = fixedRateAddress
|
||||
this.fixedRateContract = setContractDefaults(
|
||||
new this.web3.eth.Contract(this.fixedRateExchangeAbi, this.fixedRateAddress),
|
||||
|
@ -16,7 +16,8 @@ import {
|
||||
getMaxAddLiquidity,
|
||||
getMaxRemoveLiquidity,
|
||||
getMaxSwapExactIn,
|
||||
getMaxSwapExactOut
|
||||
getMaxSwapExactOut,
|
||||
MAX_UINT_256
|
||||
} from '../../utils'
|
||||
import {
|
||||
CurrentFees,
|
||||
@ -27,9 +28,6 @@ import {
|
||||
} from '../../@types'
|
||||
import { Config, ConfigHelper } from '../../config'
|
||||
|
||||
const MaxUint256 =
|
||||
'115792089237316195423570985008687907853269984665640564039457584007913129639934'
|
||||
|
||||
/**
|
||||
* Provides an interface to Ocean friendly fork from Balancer BPool
|
||||
*/
|
||||
@ -803,7 +801,7 @@ export class Pool {
|
||||
await this.getBaseToken(poolAddress),
|
||||
amountsInOutMaxFee.maxPrice
|
||||
)
|
||||
: MaxUint256
|
||||
: MAX_UINT_256
|
||||
|
||||
return estimateGas(
|
||||
address,
|
||||
@ -868,7 +866,7 @@ export class Pool {
|
||||
await this.getBaseToken(poolAddress),
|
||||
amountsInOutMaxFee.maxPrice
|
||||
)
|
||||
: MaxUint256
|
||||
: MAX_UINT_256
|
||||
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
@ -954,7 +952,7 @@ export class Pool {
|
||||
await this.getBaseToken(poolAddress),
|
||||
amountsInOutMaxFee.maxPrice
|
||||
)
|
||||
: MaxUint256
|
||||
: MAX_UINT_256
|
||||
|
||||
return estimateGas(
|
||||
address,
|
||||
@ -1015,7 +1013,7 @@ export class Pool {
|
||||
await this.getBaseToken(poolAddress),
|
||||
amountsInOutMaxFee.maxPrice
|
||||
)
|
||||
: MaxUint256
|
||||
: MAX_UINT_256
|
||||
|
||||
const estGas = await estimateGas(
|
||||
account,
|
||||
|
@ -18,36 +18,16 @@ import {
|
||||
FreOrderParams,
|
||||
FreCreationParams,
|
||||
ProviderFees,
|
||||
PublishingMarketFee
|
||||
PublishingMarketFee,
|
||||
DispenserParams,
|
||||
OrderParams,
|
||||
DatatokenRoles
|
||||
} from '../../@types'
|
||||
import { Nft } from './NFT'
|
||||
import { Config, ConfigHelper } from '../../config'
|
||||
|
||||
/**
|
||||
* ERC20 ROLES
|
||||
*/
|
||||
interface Roles {
|
||||
minter: boolean
|
||||
paymentManager: boolean
|
||||
}
|
||||
|
||||
export interface OrderParams {
|
||||
consumer: string
|
||||
serviceIndex: number
|
||||
_providerFee: ProviderFees
|
||||
_consumeMarketFee: ConsumeMarketFee
|
||||
}
|
||||
|
||||
export interface DispenserParams {
|
||||
maxTokens: string
|
||||
maxBalance: string
|
||||
withMint?: boolean // true if we want to allow the dispenser to be a minter
|
||||
allowedSwapper?: string // only account that can ask tokens. set address(0) if not required
|
||||
}
|
||||
|
||||
export class Datatoken {
|
||||
public factoryAddress: string
|
||||
public factoryABI: AbiItem | AbiItem[]
|
||||
public datatokensAbi: AbiItem | AbiItem[]
|
||||
public datatokensEnterpriseAbi: AbiItem | AbiItem[]
|
||||
public web3: Web3
|
||||
@ -1234,9 +1214,12 @@ export class Datatoken {
|
||||
/** Returns ERC20 user's permissions for a datatoken
|
||||
* @param {String} dtAddress Datatoken adress
|
||||
* @param {String} address user adress
|
||||
* @return {Promise<Roles>}
|
||||
* @return {Promise<DatatokenRoles>}
|
||||
*/
|
||||
public async getDTPermissions(dtAddress: string, address: string): Promise<Roles> {
|
||||
public async getDTPermissions(
|
||||
dtAddress: string,
|
||||
address: string
|
||||
): Promise<DatatokenRoles> {
|
||||
const dtContract = setContractDefaults(
|
||||
new this.web3.eth.Contract(this.datatokensAbi, dtAddress),
|
||||
this.config
|
||||
|
@ -10,22 +10,11 @@ import {
|
||||
estimateGas
|
||||
} from '../../utils'
|
||||
import { Contract } from 'web3-eth-contract'
|
||||
import { MetadataProof, MetadataAndTokenURI } from '../../@types'
|
||||
import { MetadataProof, MetadataAndTokenURI, NftRoles } from '../../@types'
|
||||
import { Config, ConfigHelper } from '../../config'
|
||||
|
||||
/**
|
||||
* ERC721 ROLES
|
||||
*/
|
||||
interface Roles {
|
||||
manager: boolean
|
||||
deployERC20: boolean
|
||||
updateMetadata: boolean
|
||||
store: boolean
|
||||
}
|
||||
|
||||
export class Nft {
|
||||
public factory721Address: string
|
||||
public factory721Abi: AbiItem | AbiItem[]
|
||||
public nftAbi: AbiItem | AbiItem[]
|
||||
public web3: Web3
|
||||
public startBlock: number
|
||||
@ -1173,9 +1162,9 @@ export class Nft {
|
||||
/** Get users NFT Permissions
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} address user adress
|
||||
* @return {Promise<Roles>}
|
||||
* @return {Promise<NftRoles>}
|
||||
*/
|
||||
public async getNftPermissions(nftAddress: string, address: string): Promise<Roles> {
|
||||
public async getNftPermissions(nftAddress: string, address: string): Promise<NftRoles> {
|
||||
const nftContract = setContractDefaults(
|
||||
new this.web3.eth.Contract(this.nftAbi, nftAddress),
|
||||
this.config
|
||||
@ -1199,7 +1188,7 @@ export class Nft {
|
||||
/** Get users ERC20Deployer role
|
||||
* @param {String} nftAddress erc721 contract adress
|
||||
* @param {String} address user adress
|
||||
* @return {Promise<Roles>}
|
||||
* @return {Promise<boolean>}
|
||||
*/
|
||||
public async isErc20Deployer(nftAddress: string, address: string): Promise<boolean> {
|
||||
const nftContract = setContractDefaults(
|
||||
|
@ -9,22 +9,11 @@ import {
|
||||
ComputeAsset,
|
||||
ComputeEnvironment,
|
||||
ProviderInitialize,
|
||||
ProviderComputeInitializeResults
|
||||
ProviderComputeInitializeResults,
|
||||
ServiceEndpoint,
|
||||
UserCustomParameters
|
||||
} from '../@types'
|
||||
|
||||
export interface HttpCallback {
|
||||
(httpMethod: string, url: string, body: string, header: any): Promise<any>
|
||||
}
|
||||
|
||||
export interface ServiceEndpoint {
|
||||
serviceName: string
|
||||
method: string
|
||||
urlPath: string
|
||||
}
|
||||
export interface UserCustomParameters {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export class Provider {
|
||||
/**
|
||||
* Returns the provider endpoints
|
||||
|
@ -1,2 +1,4 @@
|
||||
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
|
||||
export const GASLIMIT_DEFAULT = 1000000
|
||||
export const MAX_UINT_256 =
|
||||
'115792089237316195423570985008687907853269984665640564039457584007913129639934'
|
||||
|
@ -100,13 +100,7 @@ describe('Fixed Rate unit test', () => {
|
||||
// user1 has no dt1
|
||||
expect(await balance(web3, dtAddress, user1)).to.equal('0')
|
||||
|
||||
fixedRate = new FixedRateExchange(
|
||||
web3,
|
||||
contracts.fixedRateAddress,
|
||||
8996,
|
||||
null,
|
||||
contracts.oceanAddress
|
||||
)
|
||||
fixedRate = new FixedRateExchange(web3, contracts.fixedRateAddress, 8996)
|
||||
assert(fixedRate != null)
|
||||
})
|
||||
|
||||
@ -415,13 +409,7 @@ describe('Fixed Rate unit test', () => {
|
||||
// user1 has no dt1
|
||||
expect(await balance(web3, dtAddress, user1)).to.equal('0')
|
||||
|
||||
fixedRate = new FixedRateExchange(
|
||||
web3,
|
||||
contracts.fixedRateAddress,
|
||||
8996,
|
||||
null,
|
||||
contracts.oceanAddress
|
||||
)
|
||||
fixedRate = new FixedRateExchange(web3, contracts.fixedRateAddress, 8996)
|
||||
assert(fixedRate != null)
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user