1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00
ocean.js/docs/modules.md
Alex Coseru 9bf71ba4f0
Features/ethers (#1696)
* add ethers

* global updates

* ve updates

* ve tests

* contract updates

* first test passing

* downgrade to ethers 5.7.2

* add log

* add tx wait

* full NftFactory.test

* add wait

* add Router tests

* fix dispenser

* Nft test

* add dispenser tests

* add fre tests part 1

* WIP datatoken unit tests

* add DFRewards test

* increase gas estimate

* increase gas estimate

* Work datatoken unit tests

* datatoken test more tests

* finished datatoken tests

* fix nft get data

* fix nft transfer tests

* Provider int tests

* Updating CodeExamples.md

* update provider & fix publish flow int test

* wip publish edit consume integration test

* more work on  publish edit consume integration test

* fix edit  publish edit consume integration test

* add 3 int tests

* Updating ComputeExamples.md

* fix signature and download

* fix compute flow integration test

* udapte handleComputeOrder helper

* update datatoken instance

* update datatoken global variable

* mint ocean tokens to consumer as well and added logs

* update compute exammples

* Updating ComputeExamples.md

* wip code examples readme

* update code examples readme

* Updating CodeExamples.md

* run all tests

* update dep in readme

* update readme

* code examples update metadata flags

* update dt instance in code examples md

* set metadata updates

* Updating CodeExamples.md

* update code examples readme structure

* Updating CodeExamples.md

* update readmes table links

* Updating CodeExamples.md

* Updating ComputeExamples.md

* clean-up

* Updating CodeExamples.md

* added missing unit tests for usdc fixed rate exchange tests

* more cleanup and jsdoc updates

* more  jsdoc updates

* donw with jsdoc updates

* handle provider errors

* add missing error handling file

* adds most of the provider errors

* update get compute env return type

* Release 3.0.0-next.0

* adding Typedoc to ethers branch

* update provider signature message

* fix lint

* Release 3.0.0-next.1

* fix lint

* adding Typedoc to ethers branch

* Updating CI to build and commit the documentation

* Updating documentation

* Updating script permissions

* fix todos add missing logic to send tx

* npm package cleanups

* Release 3.0.0-next.2

* update log messages for errors

* Release 3.0.0-next.3

* fix gasFee issue on sendTx

* Release 3.0.0-next.4

* add consume params typings (#1731)

* fix gas fee estimate

* remove comments

* add some delays before resolving datasets

* adds delay to Publish flow tests

* Release 3.0.0-next.5

---------

Co-authored-by: Bogdan Fazakas <bogdan.fazakas@gmail.com>
Co-authored-by: GitHub Actions Bot <>
Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
Co-authored-by: Jamie Hewitt <jamie@oceanprotocol.com>
2023-05-29 11:20:38 +03:00

24 KiB
Raw Blame History

@oceanprotocol/lib / Exports

@oceanprotocol/lib

Table of contents

Enumerations

Classes

Interfaces

Type Aliases

Variables

Functions

Type Aliases

AbiType

Ƭ AbiType: "function" | "constructor" | "event" | "fallback"

Defined in

@types/Contracts.ts:1


ComputeResultType

Ƭ ComputeResultType: "algorithmLog" | "output" | "configrationLog" | "publishLog"

Defined in

@types/Compute.ts:3


ReceiptOrDecimal

Ƭ ReceiptOrDecimal<G>: G extends false ? providers.TransactionResponse : number

Type parameters

Name Type
G extends boolean = false

Defined in

@types/ReturnTypes.ts:5


ReceiptOrEstimate

Ƭ ReceiptOrEstimate<G>: G extends false ? providers.TransactionResponse : BigNumber

Type parameters

Name Type
G extends boolean = false

Defined in

@types/ReturnTypes.ts:2


StateMutabilityType

Ƭ StateMutabilityType: "pure" | "view" | "nonpayable" | "payable"

Defined in

@types/Contracts.ts:2

Variables

FEE_HISTORY_NOT_SUPPORTED

Const FEE_HISTORY_NOT_SUPPORTED: "Returned error: Method eth_feeHistory not supported."

Defined in

utils/Constants.ts:5


GASLIMIT_DEFAULT

Const GASLIMIT_DEFAULT: 1000000

Defined in

utils/Constants.ts:2


LoggerInstance

Const LoggerInstance: Logger

Defined in

utils/Logger.ts:45


MAX_UINT_256

Const MAX_UINT_256: "115792089237316195423570985008687907853269984665640564039457584007913129639934"

Defined in

utils/Constants.ts:3


ProviderInstance

Const ProviderInstance: Provider

Defined in

services/Provider.ts:916


ZERO_ADDRESS

Const ZERO_ADDRESS: "0x0000000000000000000000000000000000000000"

Defined in

utils/Constants.ts:1


configHelperNetworks

Const configHelperNetworks: Config[]

Defined in

config/ConfigHelper.ts:25


minAbi

Const minAbi: ({ anonymous?: undefined = false; constant: boolean = false; inputs: { name: string = '_spender'; type: string = 'address' }[] ; name: string = 'approve'; outputs: { name: string = ''; type: string = 'bool' }[] ; payable: boolean = false; stateMutability: string = 'nonpayable'; type: string = 'function' } | { anonymous?: undefined = false; constant?: undefined = false; inputs?: undefined ; name?: undefined = 'Approval'; outputs?: undefined ; payable: boolean = true; stateMutability: string = 'payable'; type: string = 'fallback' } | { anonymous: boolean = false; constant?: undefined = false; inputs: { indexed: boolean = true; name: string = 'owner'; type: string = 'address' }[] ; name: string = 'Approval'; outputs?: undefined ; payable?: undefined = true; stateMutability?: undefined = 'payable'; type: string = 'event' })[]

Defined in

utils/minAbi.ts:1

Functions

allowance

allowance(signer, tokenAddress, account, spender, tokenDecimals?): Promise<string>

Get Allowance for any Datatoken

Parameters

Name Type Description
signer Signer The signer object
tokenAddress string The address of the token
account string The address of the caller
spender string The address of the spender
tokenDecimals? number optional number of decimals of the token

Returns

Promise<string>

Defined in

utils/TokenUtils.ts:143


allowanceWei

allowanceWei(signer, tokenAddress, account, spender): Promise<string>

Get Allowance in wei for any erc20

Parameters

Name Type Description
signer Signer The signer object
tokenAddress string The address of the token
account string The address of the caller
spender string The address of the spneder

Returns

Promise<string>

Defined in

utils/TokenUtils.ts:182


amountToUnits

amountToUnits(signer, token, amount, tokenDecimals?): Promise<string>

Converts an amount of tokens to units

Parameters

Name Type Description
signer Signer The signer object to use.
token string The token to convert
amount string The amount of tokens to convert
tokenDecimals? number The number of decimals of the token

Returns

Promise<string>

  • The converted amount in units

Defined in

utils/ContractUtils.ts:82


approve

approve<G>(signer, config, account, tokenAddress, spender, amount, force?, tokenDecimals?, estimateGas?): Promise<ReceiptOrDecimal<G> | number>

Approve spender to spent amount tokens

Type parameters

Name Type
G extends boolean = false

Parameters

Name Type Default value Description
signer Signer undefined The signer object
config Config undefined The config object
account string undefined The address of the caller
tokenAddress string undefined The address of the token
spender string undefined The address of the spender
amount string undefined amount of ERC20 Datatokens (always expressed as wei)
force boolean false if true, will overwrite any previous allowence. Else, will check if allowence is enough and will not send a transaction if it's not needed
tokenDecimals? number undefined optional number of decimals of the token
estimateGas? G undefined if true, returns the estimate gas cost for calling the method

Returns

Promise<ReceiptOrDecimal<G> | number>

Defined in

utils/TokenUtils.ts:19


approveWei

approveWei<G>(signer, config, account, tokenAddress, spender, amount, force?, estimateGas?): Promise<ReceiptOrEstimate<G>>

Approve spender to spent amount tokens

Type parameters

Name Type
G extends boolean = false

Parameters

Name Type Default value Description
signer Signer undefined The signer object
config Config undefined The config object
account string undefined The address of the caller
tokenAddress string undefined The address of the token
spender string undefined The address of the spender
amount string undefined amount of ERC20 tokens (always expressed as wei)
force boolean false if true, will overwrite any previous allowence. Else, will check if allowence is enough and will not send a transaction if it's not needed
estimateGas? G undefined if true, returns the estimate gas cost for calling the method

Returns

Promise<ReceiptOrEstimate<G>>

Defined in

utils/TokenUtils.ts:63


balance

balance(signer, tokenAddress, account, tokenDecimals?): Promise<string>

Get balance for any Datatoken

Parameters

Name Type Description
signer Signer The signer object
tokenAddress string The address of the token
account string The address of the caller
tokenDecimals? number optional number of decimals of the token

Returns

Promise<string>

Defined in

utils/TokenUtils.ts:163


decimals

decimals(signer, tokenAddress): Promise<number>

Get decimals for any Datatoken

Parameters

Name Type Description
signer Signer The signer object
tokenAddress string The address of the token

Returns

Promise<number>

Number of decimals of the token

Defined in

utils/TokenUtils.ts:198


downloadFile

downloadFile(url, index?): Promise<DownloadResponse>

Triggers a file download from the specified URL when called from a browser context.

Parameters

Name Type Description
url string The URL of the file to download
index? number The file index

Returns

Promise<DownloadResponse>

  • A Promise that resolves when the file has been downloaded

Defined in

utils/FetchHelper.ts:35


downloadFileBrowser

downloadFileBrowser(url): Promise<void>

Triggers a file download from the specified URL when called from a browser context.

Parameters

Name Type Description
url string The URL of the file to download

Returns

Promise<void>

  • A Promise that resolves when the file has been downloaded

Defined in

utils/FetchHelper.ts:9


generateDid

generateDid(nftAddress, chainId): string

Generates a valid DID

Parameters

Name Type Description
nftAddress string The NFT address
chainId number The chain ID

Returns

string

  • The DID

Defined in

utils/DdoHelpers.ts:10


generateDtName

generateDtName(wordList?): Object

This function generates a datatoken name and symbol from a given word list.

Parameters

Name Type Description
wordList? Object An object containing an array of nouns and adjectives.
wordList.adjectives string[] An array of adjectives.
wordList.nouns string[] An array of nouns.

Returns

Object

Returns an object containing the generated name and symbol. Produces e.g. "Endemic Jellyfish Token" & "ENDJEL-45"

Name Type
name string
symbol string

Defined in

utils/DatatokenName.ts:10


getErrorMessage

getErrorMessage(error): string

Parameters

Name Type
error Object

Returns

string

Defined in

utils/ProviderErrors.ts:77


getEventFromTx

getEventFromTx(txReceipt, eventName): any

Parameters

Name Type
txReceipt any
eventName any

Returns

any

Defined in

utils/ContractUtils.ts:96


getFairGasPrice

getFairGasPrice(signer, gasFeeMultiplier): Promise<string>

Asynchronous function that returns a fair gas price based on the current gas price and a multiplier.

Parameters

Name Type Description
signer Signer The signer object to use for fetching the current gas price.
gasFeeMultiplier number The multiplier to apply to the current gas price. If not provided, the current gas price is returned as a string.

Returns

Promise<string>

A Promise that resolves to a string representation of the fair gas price.

Defined in

utils/ContractUtils.ts:30


getHash

getHash(data): string

Returns the SHA256 hash of the input data

Parameters

Name Type Description
data any The input data

Returns

string

  • The SHA256 hash of the input data

Defined in

utils/DdoHelpers.ts:21


getTokenDecimals

getTokenDecimals(signer, token): Promise<any>

Asynchronous function that returns the number of decimal places for a given token.

Parameters

Name Type Description
signer Signer The signer object to use for fetching the token decimals.
token string The address of the token contract.

Returns

Promise<any>

A Promise that resolves to the number of decimal places for the token.

Defined in

utils/ContractUtils.ts:46


sendTx

sendTx(estGas, signer, gasFeeMultiplier, functionToSend, ...args): Promise<providers.TransactionResponse>

Send the transation on chain

Parameters

Name Type Description
estGas BigNumber estimated gas for the transaction
signer Signer signer object
gasFeeMultiplier number number represinting the multiplier we apply to gas fees
functionToSend ContractFunction<any> function that we need to send
...args any[] arguments of the function

Returns

Promise<providers.TransactionResponse>

transaction receipt

Defined in

utils/ContractUtils.ts:111


setContractDefaults

setContractDefaults(contract, config): Contract

Parameters

Name Type
contract Contract
config Config

Returns

Contract

Defined in

utils/ContractUtils.ts:10


signHash

signHash(signer, message): Promise<{ r: string ; s: string ; v: string }>

Signs the hash of a message using the provided signer.

Parameters

Name Type Description
signer Signer The signer to use for signing the hash.
message string The message to sign.

Returns

Promise<{ r: string ; s: string ; v: string }>

  • A Promise that resolves to the signature of the hash of the message.

Defined in

utils/SignatureUtils.ts:9


sleep

sleep(ms): Promise<unknown>

Simple blocking sleep function

Parameters

Name Type Description
ms number Number of miliseconds to wait

Returns

Promise<unknown>

Defined in

utils/General.ts:5


transfer

transfer<G>(signer, config, tokenAddress, recipient, amount, estimateGas?): Promise<ReceiptOrEstimate<G>>

Moves amount tokens from the callers account to recipient.

Type parameters

Name Type
G extends boolean = false

Parameters

Name Type Description
signer Signer The signer object
config Config The config object
tokenAddress string The address of the token
recipient string The address of the tokens receiver
amount string amount of ERC20 Datatokens (not as wei)
estimateGas? G if true returns the gas estimate

Returns

Promise<ReceiptOrEstimate<G>>

Defined in

utils/TokenUtils.ts:111


unitsToAmount

unitsToAmount(signer, token, amount, tokenDecimals?): Promise<string>

Converts an amount of units to tokens

Parameters

Name Type Description
signer Signer The signer object to use.
token string The token to convert
amount string The amount of units to convert
tokenDecimals? number The number of decimals in the token

Returns

Promise<string>

  • The converted amount in tokens

Defined in

utils/ContractUtils.ts:59