Skip to content

Commit

Permalink
Merge pull request #56 from deltaDAO/feat/update-oceanjs
Browse files Browse the repository at this point in the history
Feat/update oceanjs
  • Loading branch information
moritzkirstein authored Sep 5, 2023
2 parents df9ad79 + 6001129 commit 2e8f2ff
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 50 deletions.
53 changes: 49 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v0.3.0-alpha10](https://github.com/deltaDAO/nautilus/compare/v0.3.0-alpha9...v0.3.0-alpha10)
#### [v0.3.0-alpha15](https://github.com/deltaDAO/nautilus/compare/v0.3.0-alpha9...v0.3.0-alpha15)

- Feat/ethers [`#53`](https://github.com/deltaDAO/nautilus/pull/53)
- test: remove unused files [`bc30177`](https://github.com/deltaDAO/nautilus/commit/bc30177919e500c4ae165656a30f4242a687ef5c)
- fix: wait for chain during publish [`203964c`](https://github.com/deltaDAO/nautilus/commit/203964c4112b04d55f7af066fc5c8549cb11f391)
- refactor: move ProviderInstance call to provider.ts utils file [`6e31ff5`](https://github.com/deltaDAO/nautilus/commit/6e31ff5a4a538594de85caa2a85048f1c555ab56)
- docs: combine ethers setup section in README [`9c98261`](https://github.com/deltaDAO/nautilus/commit/9c98261aed9e9efa745e80f54360c29429ecb330)

#### [v0.3.0-alpha9](https://github.com/deltaDAO/nautilus/compare/v0.3.0-alpha8...v0.3.0-alpha9)

Expand Down Expand Up @@ -65,10 +66,46 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- refactor: use object as argument for getDDO [`50128d4`](https://github.com/deltaDAO/nautilus/commit/50128d407e710f21919db4ab577fbf21e551c42b)
- refactor: use early return [`e866001`](https://github.com/deltaDAO/nautilus/commit/e8660017a65fc49f6439edcbfadb335e602e00d2)

#### [v0.3.0-alpha2](https://github.com/deltaDAO/nautilus/compare/v0.3.0-alpha1...v0.3.0-alpha2)
#### [v0.3.0-alpha2](https://github.com/deltaDAO/nautilus/compare/v0.3.0-alpha14...v0.3.0-alpha2)

> 14 August 2023
#### [v0.3.0-alpha14](https://github.com/deltaDAO/nautilus/compare/v0.3.0-alpha13...v0.3.0-alpha14)

> 4 September 2023
- fix: wait for order txs to be included in chain [`a56cec8`](https://github.com/deltaDAO/nautilus/commit/a56cec8b41b4d5f8f879b7807c56d6c95dbe3cf4)
- Release 0.3.0-alpha14 [`7add1a1`](https://github.com/deltaDAO/nautilus/commit/7add1a12644ce8948231e31fc91e22ee86158803)

#### [v0.3.0-alpha13](https://github.com/deltaDAO/nautilus/compare/v0.3.0-alpha12...v0.3.0-alpha13)

> 4 September 2023
- Release 0.3.0-alpha13 [`617a298`](https://github.com/deltaDAO/nautilus/commit/617a298b736ce0dec6e2c0093f645fa4c795f546)
- fix: cast templateId to Number [`8a62cfb`](https://github.com/deltaDAO/nautilus/commit/8a62cfb70d458b37c4ef060e429ec305ec82b7f0)

#### [v0.3.0-alpha12](https://github.com/deltaDAO/nautilus/compare/v0.3.0-alpha11...v0.3.0-alpha12)

> 4 September 2023
- Release 0.3.0-alpha12 [`b4df016`](https://github.com/deltaDAO/nautilus/commit/b4df016a3c5d64ea22c67d85f2d2e8b1ba41709a)
- deps: update @oceanprotocol/lib to 3.1.1 (ocean.js) [`d6e0235`](https://github.com/deltaDAO/nautilus/commit/d6e02352ddcb6f59247155cf91a8d99c34a6de31)

#### [v0.3.0-alpha11](https://github.com/deltaDAO/nautilus/compare/v0.3.0-alpha10...v0.3.0-alpha11)

> 4 September 2023
- Feat/ethers [`#53`](https://github.com/deltaDAO/nautilus/pull/53)
- Release 0.3.0-alpha11 [`e056191`](https://github.com/deltaDAO/nautilus/commit/e056191dbba3b277360bcfb4dab494592b47e6ef)
- deps: update @oceanprotocol/lib (ocean.js) [`70d8f4e`](https://github.com/deltaDAO/nautilus/commit/70d8f4e340fd390ceb342975604642a03377d31f)
- fix: remove misleading comment [`df9ad79`](https://github.com/deltaDAO/nautilus/commit/df9ad79d76737f66900545fc2e56b166ad78b706)

#### [v0.3.0-alpha10](https://github.com/deltaDAO/nautilus/compare/v0.3.0-alpha1...v0.3.0-alpha10)

> 24 August 2023
- fix: consumer parameter handling in service [`#51`](https://github.com/deltaDAO/nautilus/pull/51)
- Feat/publish rework [`#46`](https://github.com/deltaDAO/nautilus/pull/46)
- docs: update web3 version hint [`#45`](https://github.com/deltaDAO/nautilus/pull/45)
- Fix/exports and deps [`#42`](https://github.com/deltaDAO/nautilus/pull/42)
- Update README.md [`#38`](https://github.com/deltaDAO/nautilus/pull/38)
Expand All @@ -80,14 +117,22 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- docs: create typedoc api documentation for version 0.2.2 [`74cf76e`](https://github.com/deltaDAO/nautilus/commit/74cf76ef7344029c0fb78ae4e384c8af944fa2fc)
- docs: create typedoc api documentation for version 0.1.2 [`a59e034`](https://github.com/deltaDAO/nautilus/commit/a59e034cac1adb327eca315c49c105d5e237b039)

#### [v0.3.0-alpha1](https://github.com/deltaDAO/nautilus/compare/v0.2.2...v0.3.0-alpha1)
#### [v0.3.0-alpha1](https://github.com/deltaDAO/nautilus/compare/v0.2.3...v0.3.0-alpha1)

> 11 August 2023
- docs: create typedoc api documentation for version 0.3.0-alpha [`5cf6ee2`](https://github.com/deltaDAO/nautilus/commit/5cf6ee20e6f5b335ae82de2b657d27432657beb9)
- feat!: major publishing rework. move datatoken to services, use multi tx setup (WIP) [`fb055f3`](https://github.com/deltaDAO/nautilus/commit/fb055f31f2a3030a5831171c60ffbeeef6977f24)
- deps: add chai and sinon [`91355db`](https://github.com/deltaDAO/nautilus/commit/91355db6ce65bab0172229ab07c2fe6f2afa559c)

#### [v0.2.3](https://github.com/deltaDAO/nautilus/compare/v0.2.2...v0.2.3)

> 29 August 2023
- docs: create typedoc api documentation for version 0.2.3 [`ab2270b`](https://github.com/deltaDAO/nautilus/commit/ab2270b05ac1a56ca14efaeb00c7e7de3826203a)
- Release 0.2.3 [`ae02f08`](https://github.com/deltaDAO/nautilus/commit/ae02f082940a0f423fd38443eb91cd067885a5ac)
- fix: consumerParameter type [`3e3a03e`](https://github.com/deltaDAO/nautilus/commit/3e3a03e9e9047116f61a176d6d3285465dc9ac4f)

#### [v0.2.2](https://github.com/deltaDAO/nautilus/compare/v0.2.1...v0.2.2)

> 25 July 2023
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@deltadao/nautilus",
"source": "./src/index.ts",
"version": "0.3.0-alpha10",
"version": "0.3.0-alpha15",
"description": "A typescript library enabling automated publish & consume in Ocean Protocol ecosystems",
"main": "./dist/lib.js",
"umd:main": "./dist/lib.umd.js",
Expand Down Expand Up @@ -40,7 +40,7 @@
},
"homepage": "https://github.com/deltaDAO/nautilus#readme",
"dependencies": {
"@oceanprotocol/lib": "^3.0.4",
"@oceanprotocol/lib": "^3.1.1",
"@urql/exchange-refocus": "^1.0.0",
"axios": "^1.3.4",
"decimal.js": "^10.4.3",
Expand Down
4 changes: 2 additions & 2 deletions src/@types/Publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ export interface PublishResponse {
services: {
service: NautilusService<ServiceTypes, FileTypes>
datatokenAddress: string
pricingTransactionReceipt: providers.TransactionResponse
tx: providers.TransactionReceipt
}[]
ddo: DDO
setMetadataTxReceipt: providers.TransactionResponse
setMetadataTxReceipt: providers.TransactionReceipt
}
35 changes: 17 additions & 18 deletions src/Nautilus/Nautilus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,28 +139,27 @@ export class Nautilus {
const services = await getAllPromisesOnArray(
asset.ddo.services,
async (service) => {
const { datatokenAddress, pricingTransactionReceipt } =
await createDatatokenAndPricing({
signer,
chainConfig,
nftAddress,
pricing: {
...service.pricing,
freCreationParams: {
...service.pricing.freCreationParams,
owner: asset.owner
}
},
datatokenParams: {
...service.datatokenCreateParams,
minter: asset.owner,
paymentCollector: asset.owner
const { datatokenAddress, tx } = await createDatatokenAndPricing({
signer,
chainConfig,
nftAddress,
pricing: {
...service.pricing,
freCreationParams: {
...service.pricing.freCreationParams,
owner: asset.owner
}
})
},
datatokenParams: {
...service.datatokenCreateParams,
minter: asset.owner,
paymentCollector: asset.owner
}
})

service.datatokenAddress = datatokenAddress

return { service, datatokenAddress, pricingTransactionReceipt }
return { service, datatokenAddress, tx }
}
)

Expand Down
4 changes: 3 additions & 1 deletion src/access/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ export async function access(accessConfig: AccessConfig) {
providerFees: initializeData?.providerFee
})

assetWithAccessDetails.accessDetails.validOrderTx = orderTx.hash
const tx = await orderTx.wait()

assetWithAccessDetails.accessDetails.validOrderTx = tx?.transactionHash
return await getAssetDownloadUrl(
assetWithPrice,
signer,
Expand Down
10 changes: 6 additions & 4 deletions src/compute/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,9 @@ export async function handleComputeOrder(
providerFees: initializeData.providerFee
})
if (!txReuseOrder) throw new Error('Failed to reuse order!')
LoggerInstance.debug('[compute] Reused order:', txReuseOrder)
return txReuseOrder?.hash
const tx = await txReuseOrder.wait()
LoggerInstance.debug('[compute] Reused order:', tx)
return tx?.transactionHash
}

LoggerInstance.debug('[compute] Calling order ...', initializeData)
Expand All @@ -395,8 +396,9 @@ export async function handleComputeOrder(
providerFees: initializeData?.providerFee,
computeConsumerAddress
})
LoggerInstance.debug('[compute] Order succeeded', txStartOrder)
return txStartOrder?.hash
const tx = await txStartOrder.wait()
LoggerInstance.debug('[compute] Order succeeded', tx)
return tx?.transactionHash
} catch (error) {
LoggerInstance.error(`[compute] ${error.message}`)
}
Expand Down
10 changes: 7 additions & 3 deletions src/publish/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ export async function createDatatokenAndPricing(config: CreateDatatokenConfig) {
pricingTransactionReceipt
)

return { datatokenAddress, pricingTransactionReceipt }
const tx = await pricingTransactionReceipt.wait()

return { datatokenAddress, tx }
}

export async function publishDDO(config: PublishDDOConfig) {
Expand Down Expand Up @@ -167,12 +169,14 @@ export async function publishDDO(config: PublishDDOConfig) {
validateResult.hash
)

const tx = await transactionReceipt.wait()

LoggerInstance.debug(`[publish] Published metadata on NFT.`, {
ddo,
transactionReceipt
tx: tx.transactionHash
})

return transactionReceipt
return tx
}

// TODO evaluate if we need these (1 transaction for multiple actions)
Expand Down
29 changes: 22 additions & 7 deletions src/utils/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ export async function order({

LoggerInstance.debug('[order] order type', asset.accessDetails?.type)

const templateId = Number(asset.accessDetails?.templateId)
LoggerInstance.debug('[order] order templateId', templateId)

switch (asset.accessDetails?.type) {
case 'fixed': {
const freParams = {
Expand All @@ -120,9 +123,9 @@ export async function order({
marketFeeAddress: ZERO_ADDRESS
} as FreOrderParams

if (asset.accessDetails.templateId === 1) {
if (templateId === 1) {
// buy datatoken
const txApprove = await approve(
const tx = await approve(
signer,
config,
accountId,
Expand All @@ -136,7 +139,11 @@ export async function order({
),
false
)

const txApprove = typeof tx !== 'number' ? await tx.wait() : tx

if (!txApprove) {
LoggerInstance.error('Unable to approve datatoken tx')
return
}
const fre = new FixedRateExchange(
Expand All @@ -150,6 +157,7 @@ export async function order({
ZERO_ADDRESS,
'0'
)
await freTx.wait()

return await datatoken.startOrder(
asset.accessDetails.datatoken.address,
Expand All @@ -160,8 +168,8 @@ export async function order({
)
}

if (asset.accessDetails.templateId === 2) {
const txApprove = await approve(
if (templateId === 2) {
const tx = await approve(
signer,
config,
accountId,
Expand All @@ -175,9 +183,14 @@ export async function order({
),
false
)

const txApprove = typeof tx !== 'number' ? await tx.wait() : tx

if (!txApprove) {
LoggerInstance.error('Unable to approve datatoken tx')
return
}

return await datatoken.buyFromFreAndOrder(
asset.accessDetails.datatoken.address,
orderParams,
Expand All @@ -189,17 +202,19 @@ export async function order({
case 'free': {
LoggerInstance.debug(
'[order] order with type "free" for templateId:',
asset.accessDetails.templateId
templateId
)

if (asset.accessDetails.templateId === 1) {
if (templateId === 1) {
const dispenser = new Dispenser(config.dispenserAddress, signer)
LoggerInstance.debug('[order] free order: dispenser', dispenser.address)
const dispenserTx = await dispenser.dispense(
asset.accessDetails?.datatoken.address,
'1',
accountId
)
await dispenserTx.wait()

LoggerInstance.debug(
'[order] free order: dispenser tx',
dispenserTx.hash
Expand All @@ -213,7 +228,7 @@ export async function order({
orderParams._consumeMarketFee
)
}
if (asset.accessDetails.templateId === 2) {
if (templateId === 2) {
LoggerInstance.debug('[order] buying from datatoken', {
datatoken: asset.services[0].datatokenAddress,
accountId,
Expand Down

0 comments on commit 2e8f2ff

Please sign in to comment.