Skip to content

Commit d0ce75e

Browse files
committed
remove any
1 parent cfda4fc commit d0ce75e

3 files changed

Lines changed: 44 additions & 35 deletions

File tree

src/commands.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export class Commands {
155155

156156
const updateAssetTx = await updateAssetMetadata(
157157
this.signer,
158-
asset as any,
158+
asset,
159159
this.oceanNodeUrl,
160160
this.aquarius,
161161
encryptDDO
@@ -354,7 +354,7 @@ export class Commands {
354354
ddos[dataDdo],
355355
ddos[dataDdo].services[0].id,
356356
algo,
357-
algoDdo as any
357+
algoDdo
358358
);
359359
if (!canStartCompute) {
360360
console.error(
@@ -396,7 +396,7 @@ export class Commands {
396396
console.log("Ordering algorithm: ", args[2]);
397397
algo.transferTxId = await handleComputeOrder(
398398
providerInitializeComputeJob.algorithm,
399-
algoDdo as any,
399+
algoDdo,
400400
this.signer,
401401
computeEnv.consumerAddress,
402402
0,
@@ -601,7 +601,7 @@ export class Commands {
601601
ddos[dataDdo],
602602
ddos[dataDdo].services[0].id,
603603
algo,
604-
algoDdo as any
604+
algoDdo
605605
);
606606
if (!canStartCompute) {
607607
console.error(
@@ -751,8 +751,7 @@ export class Commands {
751751
return;
752752
}
753753

754-
// @ts-ignore
755-
if (asset.nft.owner !== (await this.signer.getAddress())) {
754+
if (asset.indexedMetadata.nft.owner !== (await this.signer.getAddress())) {
756755
console.error(
757756
"You are not the owner of this asset, and there for you cannot update it."
758757
);
@@ -806,7 +805,7 @@ export class Commands {
806805
try {
807806
const txid = await updateAssetMetadata(
808807
this.signer,
809-
asset as any,
808+
asset,
810809
this.oceanNodeUrl,
811810
this.aquarius,
812811
encryptDDO
@@ -832,8 +831,7 @@ export class Commands {
832831
);
833832
return;
834833
}
835-
// @ts-ignore
836-
if (asset.nft.owner !== (await this.signer.getAddress())) {
834+
if (asset.indexedMetadata.nft.owner !== (await this.signer.getAddress())) {
837835
console.error(
838836
"You are not the owner of this asset, and there for you cannot update it."
839837
);
@@ -876,7 +874,7 @@ export class Commands {
876874

877875
const txid = await updateAssetMetadata(
878876
this.signer,
879-
asset as any,
877+
asset,
880878
this.oceanNodeUrl,
881879
this.aquarius,
882880
encryptDDO

src/helpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export async function createAssetUtil(
109109
symbol: string,
110110
owner: Signer,
111111
assetUrl: any,
112-
ddo: any,
112+
ddo: DDO,
113113
oceanNodeUrl: string,
114114
config: Config,
115115
aquariusInstance: Aquarius,
@@ -159,10 +159,10 @@ export async function updateAssetMetadata(
159159
const nft = new Nft(owner, (await owner.provider.getNetwork()).chainId);
160160
let flags;
161161
let metadata;
162-
const validateResult = await aquariusInstance.validate(updatedDdo as any, owner, oceanNodeUrl);
162+
const validateResult = await aquariusInstance.validate(updatedDdo, owner, oceanNodeUrl);
163163
if (encryptDDO) {
164164
const providerResponse = await ProviderInstance.encrypt(
165-
updatedDdo as any,
165+
updatedDdo,
166166
updatedDdo.chainId,
167167
oceanNodeUrl
168168
);
@@ -233,7 +233,7 @@ export async function handleComputeOrder(
233233
}
234234
console.log("Ordering asset with DID: ", asset.id);
235235
const txStartOrder = await orderAsset(
236-
asset as any,
236+
asset,
237237
payerAccount,
238238
config,
239239
datatoken,

src/publishAsset.ts

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Aquarius,
66
} from '@oceanprotocol/lib';
77
import { createAssetUtil, updateAssetMetadata } from './helpers.js';
8+
import { Asset } from '@oceanprotocol/ddo-js';
89

910
export interface PublishAssetParams {
1011
title: string;
@@ -26,7 +27,7 @@ export async function publishAsset(aquarius: Aquarius, params: PublishAssetParam
2627
try {
2728

2829
// Prepare initial metadata for the asset
29-
const metadata = {
30+
const metadata: Asset = {
3031
'@context': ['https://w3id.org/did/v1'],
3132
id: '', // Will be updated after creating asset
3233
version: '4.1.0',
@@ -42,12 +43,33 @@ export async function publishAsset(aquarius: Aquarius, params: PublishAssetParam
4243
license: 'MIT',
4344
tags: params.tags
4445
},
45-
stats: {
46-
allocated: 0,
47-
orders: 0,
48-
price: {
49-
value: params.isCharged ? Number(params.price) : 0
50-
}
46+
indexedMetadata: {
47+
nft: {
48+
address: "",
49+
name: "Ocean Data NFT",
50+
symbol: "OCEAN-NFT",
51+
state: 5,
52+
tokenURI: "",
53+
owner: "",
54+
created: ""
55+
},
56+
event: undefined,
57+
purgatory: undefined,
58+
stats: [
59+
{
60+
orders: 0,
61+
prices: [{
62+
price: params.price,
63+
contract: '0x282d8efCe846A88B159800bd4130ad77443Fa1A1',
64+
token: params.token,
65+
type: params.isCharged === false ? 'dispenser' : 'fixedrate'
66+
}],
67+
datatokenAddress: '',
68+
name: 'access',
69+
serviceId: 'access',
70+
symbol: ''
71+
}
72+
]
5173
},
5274
services: [
5375
{
@@ -59,20 +81,9 @@ export async function publishAsset(aquarius: Aquarius, params: PublishAssetParam
5981
serviceEndpoint: params.providerUrl,
6082
timeout: Number(params.timeout),
6183
},
62-
],
63-
nft: {
64-
address: "",
65-
name: "Ocean Data NFT",
66-
symbol: "OCEAN-NFT",
67-
state: 5,
68-
tokenURI: "",
69-
owner: "",
70-
created: ""
71-
},
72-
datatokens: [],
73-
event: undefined,
74-
purgatory: undefined
75-
} as any;
84+
]
85+
};
86+
7687

7788
// Asset URL setup based on storage type
7889
const assetUrl = {

0 commit comments

Comments
 (0)