* 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>
24 KiB
@oceanprotocol/lib / Exports
@oceanprotocol/lib
Table of contents
Enumerations
Classes
- Aquarius
- Config
- ConfigHelper
- Datatoken
- DfRewards
- DfStrategyV1
- Dispenser
- FixedRateExchange
- Logger
- Nft
- NftFactory
- Provider
- Router
- SmartContract
- SmartContractWithAddress
- VeAllocate
- VeFeeDistributor
- VeFeeEstimate
- VeOcean
Interfaces
- AbiInput
- AbiItem
- AbiOutput
- Arweave
- Asset
- AssetDatatoken
- AssetLastEvent
- AssetNft
- AssetPrice
- ComputeAlgorithm
- ComputeAsset
- ComputeEnvironment
- ComputeJob
- ComputeOutput
- ComputeResult
- ConsumeMarketFee
- Credential
- Credentials
- DDO
- DatatokenCreateParams
- DatatokenRoles
- DispenserCreationParams
- DispenserParams
- DispenserToken
- DownloadResponse
- Event
- FeesInfo
- FileInfo
- Files
- FixedPriceExchange
- FreCreationParams
- FreOrderParams
- GraphqlQuery
- Ipfs
- Metadata
- MetadataAlgorithm
- MetadataAndTokenURI
- MetadataProof
- NftCreateData
- NftRoles
- Operation
- OrderParams
- PriceAndFees
- ProviderComputeInitialize
- ProviderComputeInitializeResults
- ProviderFees
- ProviderInitialize
- PublisherTrustedAlgorithm
- PublishingMarketFee
- Purgatory
- SearchQuery
- Service
- ServiceComputeOptions
- ServiceEndpoint
- Smartcontract
- Stats
- Template
- TokenOrder
- UrlFile
- UserCustomParameters
- ValidateMetadata
Type Aliases
Variables
- FEE_HISTORY_NOT_SUPPORTED
- GASLIMIT_DEFAULT
- LoggerInstance
- MAX_UINT_256
- ProviderInstance
- ZERO_ADDRESS
- configHelperNetworks
- minAbi
Functions
- allowance
- allowanceWei
- amountToUnits
- approve
- approveWei
- balance
- decimals
- downloadFile
- downloadFileBrowser
- generateDid
- generateDtName
- getErrorMessage
- getEventFromTx
- getFairGasPrice
- getHash
- getTokenDecimals
- sendTx
- setContractDefaults
- signHash
- sleep
- transfer
- unitsToAmount
Type Aliases
AbiType
Ƭ AbiType: "function"
| "constructor"
| "event"
| "fallback"
Defined in
ComputeResultType
Ƭ ComputeResultType: "algorithmLog"
| "output"
| "configrationLog"
| "publishLog"
Defined in
ReceiptOrDecimal
Ƭ ReceiptOrDecimal<G
>: G
extends false
? providers.TransactionResponse
: number
Type parameters
Name | Type |
---|---|
G |
extends boolean = false |
Defined in
ReceiptOrEstimate
Ƭ ReceiptOrEstimate<G
>: G
extends false
? providers.TransactionResponse
: BigNumber
Type parameters
Name | Type |
---|---|
G |
extends boolean = false |
Defined in
StateMutabilityType
Ƭ StateMutabilityType: "pure"
| "view"
| "nonpayable"
| "payable"
Defined in
Variables
FEE_HISTORY_NOT_SUPPORTED
• Const
FEE_HISTORY_NOT_SUPPORTED: "Returned error: Method eth_feeHistory not supported."
Defined in
GASLIMIT_DEFAULT
• Const
GASLIMIT_DEFAULT: 1000000
Defined in
LoggerInstance
• Const
LoggerInstance: Logger
Defined in
MAX_UINT_256
• Const
MAX_UINT_256: "115792089237316195423570985008687907853269984665640564039457584007913129639934"
Defined in
ProviderInstance
• Const
ProviderInstance: Provider
Defined in
ZERO_ADDRESS
• Const
ZERO_ADDRESS: "0x0000000000000000000000000000000000000000"
Defined in
configHelperNetworks
• Const
configHelperNetworks: Config
[]
Defined in
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
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
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
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
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
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
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
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
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
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
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
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
getErrorMessage
▸ getErrorMessage(error
): string
Parameters
Name | Type |
---|---|
error |
Object |
Returns
string
Defined in
getEventFromTx
▸ getEventFromTx(txReceipt
, eventName
): any
Parameters
Name | Type |
---|---|
txReceipt |
any |
eventName |
any |
Returns
any
Defined in
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
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
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
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
setContractDefaults
▸ setContractDefaults(contract
, config
): Contract
Parameters
Name | Type |
---|---|
contract |
Contract |
config |
Config |
Returns
Contract
Defined in
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
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
transfer
▸ transfer<G
>(signer
, config
, tokenAddress
, recipient
, amount
, estimateGas?
): Promise
<ReceiptOrEstimate
<G
>>
Moves amount tokens from the caller’s 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
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