Skip to content

Conversation

@Le-Caignec
Copy link
Contributor

@Le-Caignec Le-Caignec commented Feb 26, 2024

  • remove preflight checks that were made with the subgraph
  • fix unit tests

@Le-Caignec Le-Caignec requested a review from cedric25 February 26, 2024 16:38
@Le-Caignec Le-Caignec self-assigned this Feb 26, 2024
@Le-Caignec Le-Caignec changed the base branch from v2 to feature/add-FetchProtectedDataByCollection-function February 26, 2024 16:38
@Le-Caignec Le-Caignec changed the title Feature/implement pre flight check [SDK] Implement pre flight check Feb 26, 2024
Copy link
Contributor

@cedric25 cedric25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite a lot of work 💪

First round of comments!

Base automatically changed from feature/add-FetchProtectedDataByCollection-function to v2 February 27, 2024 13:43
@cedric25 cedric25 changed the title [SDK] Implement pre flight check [SDK] Implement preflight checks with SC Feb 27, 2024
@Le-Caignec Le-Caignec requested a review from cedric25 February 28, 2024 07:30
"build:watch": "npm run build -- --watch",
"check-types": "tsc --noEmit",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --coverage",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why you'd like to remove the coverage report?

"kubo-rpc-client": "^3.0.0",
"magic-bytes.js": "^1.0.15",
"typescript": "^4.9.5",
"typechain": "^8.3.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be only a dev dependency I think?
Same for @typechain/ethers-v6

**/node_modules/
**/contracts/
**/contracts/
**/typechain/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we do with this new folder?
1️⃣ Commit these files?
2️⃣ gitignore them?
We need to choose :)

I'd choose 1️⃣

"format": "prettier --write \"(src|tests)/**/*.ts\"",
"check-format": "prettier --check \"(src|tests)/**/*.ts|tests/**/*.ts\""
"check-format": "prettier --check \"(src|tests)/**/*.ts|tests/**/*.ts\"",
"generate-types": "typechain --target=ethers-v6 --out-dir ./typechain '../sharing-smart-contract/artifacts/contracts/**/!(*.dbg).json' --node16-modules"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be safer to first remove entire folder, with rimraf for example.

npm i -D rimraf
Suggested change
"generate-types": "typechain --target=ethers-v6 --out-dir ./typechain '../sharing-smart-contract/artifacts/contracts/**/!(*.dbg).json' --node16-modules"
"generate-types": "rimraf typechain && typechain --target=ethers-v6 --out-dir ./typechain '../sharing-smart-contract/artifacts/contracts/**/!(*.dbg).json' --node16-modules"

Without that when re-running the script, I had both interface and interfaces in this generated folder.

}
};

export const onlyProtectedDataCurrentlyForSubscription = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A protected data is not for subscription, the collection is.

);

//---------- Smart Contract Call ----------
onlyBalanceNotEmpty({ sharingContract, userAddress });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing await?

Suggested change
onlyBalanceNotEmpty({ sharingContract, userAddress });
await onlyBalanceNotEmpty({ sharingContract, userAddress });

const sharingContract = await getSharingContract(
iexec,
sharingContractAddress
const subscriptionParams: ISubscription.SubscriptionParamsStruct = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type not necessary here. If something's wrong here, calling setSubscriptionParams will complain.

}
};

export const onlyCollectionCurrentlyForSubscription = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this "currently" term brings any value... Maybe we could remove it from all methods in this file.

};
};

export const getProtectedDataDetails = async ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I counted well, this function calls the smart-contract 5 times.
We'll see later if this is really necessary for all getProtectedDataDetails callers.

}

//TODO: implement multicall
const [collectionDetails, userRentalExpiration, userSubscriptionExpiration] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird that calling getProtectedDataRenter returns a result called userRentalExpiration.

Ok I get it, more explicitly this smart-contract method could be named getProtectedDataLatestRentalExpirationForUser.

@cedric25 cedric25 merged commit d24b02d into v2 Mar 4, 2024
@cedric25 cedric25 deleted the feature/implement-pre-flight-check branch March 4, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants