Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25,732 changes: 9,559 additions & 16,173 deletions package-lock.json

Large diffs are not rendered by default.

89 changes: 41 additions & 48 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@
"type-check": "npm run build:metadata && tsc --noEmit",
"doc:json": "node ./scripts/typedoc.js",
"docs": "typedoc --options typedoc.json --plugin typedoc-plugin-markdown",
"run": "ts-node",
"release": "release-it --non-interactive",
"changelog": "auto-changelog -p",
"prepublishOnly": "npm run build",
"mocha": "TS_NODE_PROJECT='./test/tsconfig.json' mocha --config=test/.mocharc.json --node-env=test --exit",
"test": "npm run lint && npm run test:unit:cover && npm run test:integration:cover",
"test:unit": "npx tsx ./node_modules/mocha/bin/mocha.js --config ./test/.mocharc.json 'test/unit/**/*.test.ts' --verbose",
"test:sapphire": "npm run mocha -- 'test/integration/Sapphire.test.ts'",
"test:sapphire": "npx tsx ./node_modules/mocha/bin/mocha.js --config ./test/.mocharc.json 'test/integration/Sapphire.test.ts'",
"test:integration": "npx tsx ./node_modules/mocha/bin/mocha.js --config ./test/.mocharc.json 'test/integration/**/*.test.ts' --exclude 'test/integration/Sapphire.test.ts' --verbose",
"test:unit:cover": "nyc --report-dir coverage/unit npm run test:unit",
"test:integration:cover": "nyc --report-dir coverage/integration --no-clean npm run test:integration",
Expand All @@ -67,65 +65,60 @@
"engines": {
"node": ">=18"
},
"peerDependencies": {
"web3": "^1.8.0"
},
"dependencies": {
"@oasisprotocol/sapphire-paratime": "^1.3.2",
"@oceanprotocol/ddo-js": "^0.3.0",
"bignumber.js": "^9.3.1",
"crypto-js": "^4.1.1",
"decimal.js": "^10.4.1",
"eciesjs": "^0.4.5",
"ethers": "^6.15.0",
"jsonwebtoken": "^9.0.2"
"@oasisprotocol/sapphire-ethers-v6": "^6.0.1",
"@oceanprotocol/ddo-js": "^0.4.1",
"bignumber.js": "^11.1.5",
"crypto-js": "^4.2.0",
"decimal.js": "^10.6.0",
"eciesjs": "^0.5.0",
"ethers": "^6.17.0",
"jsonwebtoken": "^9.0.3"
},
"devDependencies": {
"@chainsafe/libp2p-noise": "^17.0.0",
"@chainsafe/libp2p-yamux": "^8.0.1",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@libp2p/bootstrap": "^12.0.14",
"@libp2p/circuit-relay-v2": "^4.1.7",
"@libp2p/identify": "^4.0.13",
"@libp2p/kad-dht": "^16.1.6",
"@libp2p/tcp": "^11.0.13",
"@libp2p/websockets": "^10.1.6",
"@multiformats/multiaddr": "^13.0.1",
"@libp2p/bootstrap": "^12.0.29",
"@libp2p/circuit-relay-v2": "^4.2.11",
"@libp2p/identify": "^4.1.12",
"@libp2p/interface": "^3.2.5",
"@libp2p/kad-dht": "^16.4.2",
"@libp2p/peer-id": "^6.0.14",
"@libp2p/ping": "^3.1.11",
"@libp2p/tcp": "^11.0.26",
"@libp2p/utils": "^7.3.2",
"@libp2p/websockets": "^10.1.19",
"@multiformats/multiaddr": "^13.0.3",
"@oceanprotocol/contracts": "^2.9.0",
"@truffle/hdwallet-provider": "^2.0.14",
"@types/chai": "^5.2.2",
"@types/chai-spies": "^1.0.3",
"@types/crypto-js": "^4.1.1",
"@types/chai": "^5.2.3",
"@types/crypto-js": "^4.2.2",
"@types/jsonwebtoken": "^9.0.10",
"@types/mocha": "^10.0.10",
"@types/node": "^24.3.0",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^6.4.1",
"auto-changelog": "^2.4.0",
"c8": "^10.1.3",
"@types/node": "^26.2.0",
"@typescript-eslint/eslint-plugin": "^8.67.0",
"@typescript-eslint/parser": "^8.67.0",
"auto-changelog": "^2.6.0",
"chai": "^6.2.2",
"chai-spies": "^1.0.0",
"cross-env": "^10.1.0",
"eslint": "^8.23.1",
"eslint-config-oceanprotocol": "^2.0.3",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-prettier": "^4.2.1",
"fs": "0.0.1-security",
"libp2p": "^3.1.6",
"cross-fetch": "^4.1.0",
"eslint": "^8.57.1",
"eslint-config-oceanprotocol": "^2.0.4",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.6",
"libp2p": "^3.3.8",
"microbundle": "^0.15.1",
"mocha": "^11.7.1",
"mocha": "^11.8.0",
"mock-local-storage": "^1.1.24",
"multiformats": "^14.0.5",
"nyc": "^18.0.0",
"ora": "9.4.0",
"prettier": "^2.7.1",
"release-it": "^19.2.4",
"prettier": "^3.9.6",
"release-it": "^21.0.2",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.2",
"ts-node-register": "^1.0.0",
"tsx": "^4.21.0",
"typedoc": "^0.25.1",
"typedoc-plugin-markdown": "^4.0.3",
"typescript": "^5.1.6"
"tsx": "^4.23.12",
"typedoc": "^0.28.20",
"typedoc-plugin-markdown": "^4.12.0",
"typescript": "^6.0.3",
"uint8arrays": "^6.1.1"
},
"nyc": {
"extends": "@istanbuljs/nyc-config-typescript",
Expand Down
18 changes: 9 additions & 9 deletions scripts/get-metadata.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env node
'use strict';
'use strict'

import { execSync } from 'child_process';
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const packageInfo = require('../package.json');
let commitHash = 'unknown';
import { execSync } from 'child_process'
import { createRequire } from 'module'
const require = createRequire(import.meta.url)
const packageInfo = require('../package.json')
let commitHash = 'unknown'
try {
commitHash = execSync('git rev-parse HEAD').toString().trim();
commitHash = execSync('git rev-parse HEAD').toString().trim()
} catch (e) {
console.warn('Not a git repository, skipping commit hash metadata.');
console.warn('Not a git repository, skipping commit hash metadata.')
}
process.stdout.write(
JSON.stringify(
Expand All @@ -20,4 +20,4 @@ process.stdout.write(
null,
2
)
);
)
4 changes: 2 additions & 2 deletions scripts/typedoc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env node

/* eslint-disable security/detect-non-literal-fs-filename */
import { createRequire } from 'module';
import { createRequire } from 'module'

const require = createRequire(import.meta.url);
const require = createRequire(import.meta.url)

const fs = require('fs')
const TypeDoc = require('typedoc')
Expand Down
5 changes: 1 addition & 4 deletions src/@types/Compute.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { MetadataAlgorithm, ConsumerParameter } from '@oceanprotocol/ddo-js'
import { StorageObject, EncryptMethod } from './File'
export type ComputeResultType =
| 'algorithmLog'
| 'output'
| 'configrationLog'
| 'publishLog'
'algorithmLog' | 'output' | 'configrationLog' | 'publishLog'

// new V2 C2D Compute Environment specs
export interface RunningPlatform {
Expand Down
5 changes: 2 additions & 3 deletions src/contracts/NFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,8 @@ export class Nft extends SmartContract {
) {
throw new Error(`Caller is not Manager nor DatatokenDeployer`)
}
const estGas = await nftContract.removeFromCreateERC20List.estimateGas(
datatokenDeployer
)
const estGas =
await nftContract.removeFromCreateERC20List.estimateGas(datatokenDeployer)
const overrides = await buildTxOverrides(
estGas,
this.getSignerAccordingSdk(),
Expand Down
5 changes: 2 additions & 3 deletions src/contracts/NFTFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,8 @@ export class NftFactory extends SmartContractWithAddress {
if (templateIndex > (await this.getCurrentNFTTemplateCount()))
throw new Error(`Template index doesnt exist`)
if (templateIndex === 0) throw new Error(`Template index cannot be ZERO`)
const estGas = await this.contract.reactivate721TokenTemplate.estimateGas(
templateIndex
)
const estGas =
await this.contract.reactivate721TokenTemplate.estimateGas(templateIndex)
const overrides = await buildTxOverrides(
estGas,
this.getSignerAccordingSdk(),
Expand Down
4 changes: 2 additions & 2 deletions src/contracts/SmartContract.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ethers, Signer, Contract } from 'ethers'
import { AbiItem } from '../@types/index.js'
import { Config, ConfigHelper } from '../config/index.js'
import * as sapphire from '@oasisprotocol/sapphire-paratime'
import { wrapEthersSigner } from '@oasisprotocol/sapphire-ethers-v6'
import {
amountToUnits,
getFairGasPrice,
Expand Down Expand Up @@ -36,7 +36,7 @@ export abstract class SmartContract {

protected getSignerAccordingSdk() {
return this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
? sapphire.wrap(this.signer)
? wrapEthersSigner(this.signer)
: this.signer
}

Expand Down
8 changes: 2 additions & 6 deletions src/services/providers/HttpProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,6 @@ export class HttpProvider {
signal?: AbortSignal,
includeMetrics?: boolean
): Promise<NodeComputeJob | NodeComputeJob[]> {
const consumerAddress = await getConsumerAddress(signerOrAuthToken)
const computeStatusUrl = this.baseUrl(nodeUri) + '/api/services/compute'
let consumerAddress: string
let nonce: string
Expand All @@ -934,9 +933,7 @@ export class HttpProvider {
nodeUri,
signerOrAuthToken,
PROTOCOL_COMMANDS.COMPUTE_GET_STATUS,
signal,
providerEndpoints,
serviceEndpoints
signal
))
} else {
consumerAddress = await getConsumerAddress(signerOrAuthToken)
Expand Down Expand Up @@ -1573,8 +1570,7 @@ export class HttpProvider {
// browser. undici accepts a streamed body only with `duplex: 'half'` (not in the DOM
// RequestInit type, so the init object is cast below).
const RS = (globalThis as any).ReadableStream as
| (new (opts: any) => ReadableStream)
| undefined
(new (opts: any) => ReadableStream) | undefined
if (typeof RS !== 'function') {
throw new Error('ReadableStream is not available in this environment')
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/providers/P2pProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ export class P2pProvider {
)
// ocean-node may return a plain number or { nonce: number }
const nonceValue =
typeof result === 'number' ? result : result?.nonce ?? result ?? 0
typeof result === 'number' ? result : (result?.nonce ?? result ?? 0)
return !nonceValue || nonceValue === null ? 0 : Number(nonceValue)
} catch (e) {
LoggerInstance.error('P2P getNonce failed:', e)
Expand Down
24 changes: 12 additions & 12 deletions src/utils/ContractUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,25 +209,25 @@ export async function buildTxOverrides(
Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_POLYGON
? MIN_GAS_FEE_POLYGON
: Number(chainId) === SEPOLIA_NETWORK_ID &&
Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_SEPOLIA
? MIN_GAS_FEE_SEPOLIA
: KNOWN_CONFIDENTIAL_EVMS.includes(Number(chainId)) &&
Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_SAPPHIRE
? MIN_GAS_FEE_SAPPHIRE
: Number(aggressiveFeePriorityFeePerGas),
Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_SEPOLIA
? MIN_GAS_FEE_SEPOLIA
: KNOWN_CONFIDENTIAL_EVMS.includes(Number(chainId)) &&
Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_SAPPHIRE
? MIN_GAS_FEE_SAPPHIRE
: Number(aggressiveFeePriorityFeePerGas),

maxFeePerGas:
(Number(chainId) === MUMBAI_NETWORK_ID ||
Number(chainId) === POLYGON_NETWORK_ID) &&
Number(aggressiveFeePerGas) < MIN_GAS_FEE_POLYGON
? MIN_GAS_FEE_POLYGON
: Number(chainId) === SEPOLIA_NETWORK_ID &&
Number(aggressiveFeePerGas) < MIN_GAS_FEE_SEPOLIA
? MIN_GAS_FEE_SEPOLIA
: KNOWN_CONFIDENTIAL_EVMS.includes(Number(chainId)) &&
Number(aggressiveFeePerGas) < MIN_GAS_FEE_SAPPHIRE
? MIN_GAS_FEE_SAPPHIRE
: Number(aggressiveFeePerGas)
Number(aggressiveFeePerGas) < MIN_GAS_FEE_SEPOLIA
? MIN_GAS_FEE_SEPOLIA
: KNOWN_CONFIDENTIAL_EVMS.includes(Number(chainId)) &&
Number(aggressiveFeePerGas) < MIN_GAS_FEE_SAPPHIRE
? MIN_GAS_FEE_SAPPHIRE
: Number(aggressiveFeePerGas)
}
} else {
overrides = {
Expand Down
12 changes: 6 additions & 6 deletions src/utils/eciesencrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ function normalizePublicKey(publicKey: PublicKeyInput): string {
publicKey instanceof Uint8Array
? publicKey
: Array.isArray(publicKey)
? Uint8Array.from(publicKey)
: Uint8Array.from(
Object.keys(publicKey)
.sort((a, b) => Number(a) - Number(b))
.map((key) => publicKey[Number(key)])
)
? Uint8Array.from(publicKey)
: Uint8Array.from(
Object.keys(publicKey)
.sort((a, b) => Number(a) - Number(b))
.map((key) => publicKey[Number(key)])
)

return `0x${bytesToHex(bytes)}`
}
Expand Down
12 changes: 8 additions & 4 deletions test/integration/Sapphire.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import * as sapphire from '@oasisprotocol/sapphire-paratime'
import {
NETWORKS,
wrapEthersProvider,
wrapEthersSigner
} from '@oasisprotocol/sapphire-ethers-v6'
import addresses from '@oceanprotocol/contracts/addresses/address.json'
import { ethers, toUtf8Bytes } from 'ethers'
import { AccesslistFactory } from '../../src/contracts/AccessListFactory.js'
Expand All @@ -12,8 +16,8 @@ import ERC20Template4 from '@oceanprotocol/contracts/artifacts/contracts/templat
import { getEventFromTx } from '../../src/utils/index.js'

describe('Sapphire tests', async () => {
const provider = sapphire.wrap(
ethers.getDefaultProvider(sapphire.NETWORKS.testnet.defaultGateway)
const provider = wrapEthersProvider(
ethers.getDefaultProvider(NETWORKS.testnet.defaultGateway)
)
const privateKey = process.env.PRIVATE_KEY
const privateKeyConsumer = process.env.PRIVATE_KEY_CONSUMER
Expand All @@ -22,7 +26,7 @@ describe('Sapphire tests', async () => {
}
const wallet = privateKey ? new ethers.Wallet(privateKey, provider) : null
const walletWrapped = privateKey
? sapphire.wrap(new ethers.Wallet(privateKey, provider))
? wrapEthersSigner(new ethers.Wallet(privateKey, provider))
: null
const consumer = privateKeyConsumer
? new ethers.Wallet(privateKeyConsumer, provider)
Expand Down
6 changes: 6 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"moduleResolution": "node",
// the root config pins rootDir to ./src for the published .d.ts layout; the test program
// also spans test/, so widen it back to the repo root here
"rootDir": "..",
// TS 6 no longer auto-includes @types/mocha here, so the mocha globals
// (describe/it/before) have to be requested explicitly
"types": ["mocha", "node"],
"module": "ESNext",
"target": "ESNext",
"noUnusedLocals": false,
Expand Down
Loading
Loading