-
Notifications
You must be signed in to change notification settings - Fork 10
[SDK] Implement preflight checks with SC #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cedric25
left a comment
There was a problem hiding this 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!
packages/sdk/src/lib/dataProtectorSharing/smartContract/getterForSharingContract.ts
Outdated
Show resolved
Hide resolved
packages/sdk/src/lib/dataProtectorSharing/DataProtectorSharing.ts
Outdated
Show resolved
Hide resolved
packages/sdk/src/lib/dataProtectorSharing/removeFromCollection.ts
Outdated
Show resolved
Hide resolved
packages/sdk/src/lib/dataProtectorSharing/removeFromCollection.ts
Outdated
Show resolved
Hide resolved
packages/sdk/src/lib/dataProtectorSharing/smartContract/preFlightCheck.ts
Outdated
Show resolved
Hide resolved
packages/sdk/tests/e2e/dataProtectorSharing/addToCollection.test.ts
Outdated
Show resolved
Hide resolved
packages/sdk/tests/e2e/dataProtectorSharing/addToCollection.test.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Cedric Nicoloso <[email protected]>
…st.ts Co-authored-by: Cedric Nicoloso <[email protected]>
…st.ts Co-authored-by: Cedric Nicoloso <[email protected]>
Co-authored-by: Cedric Nicoloso <[email protected]>
Co-authored-by: Cedric Nicoloso <[email protected]>
packages/sdk/src/lib/dataProtectorSharing/smartContract/sharingContract.reads.ts
Outdated
Show resolved
Hide resolved
packages/sdk/src/lib/dataProtectorSharing/smartContract/sharingContract.reads.ts
Outdated
Show resolved
Hide resolved
packages/sdk/tests/e2e/dataProtectorSharing/setProtectedDataToRenting.test.ts
Outdated
Show resolved
Hide resolved
packages/sdk/tests/e2e/dataProtectorSharing/setProtectedDataForSale.test.ts
Show resolved
Hide resolved
packages/sdk/tests/e2e/dataProtectorSharing/removeProtectedDataFromRenting.test.ts
Outdated
Show resolved
Hide resolved
packages/sdk/tests/e2e/dataProtectorSharing/removeProtectedDataForSale.test.ts
Show resolved
Hide resolved
packages/sdk/src/lib/dataProtectorSharing/removeFromCollection.ts
Outdated
Show resolved
Hide resolved
…gContract.reads.ts Co-authored-by: Cedric Nicoloso <[email protected]>
…gContract.reads.ts Co-authored-by: Cedric Nicoloso <[email protected]>
…om/iExecBlockchainComputing/dataprotector-sdk into feature/implement-pre-flight-check
| "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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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/ |
There was a problem hiding this comment.
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️⃣
packages/sdk/package.json
Outdated
| "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" |
There was a problem hiding this comment.
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
| "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 = ( |
There was a problem hiding this comment.
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 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing await?
| onlyBalanceNotEmpty({ sharingContract, userAddress }); | |
| await onlyBalanceNotEmpty({ sharingContract, userAddress }); |
| const sharingContract = await getSharingContract( | ||
| iexec, | ||
| sharingContractAddress | ||
| const subscriptionParams: ISubscription.SubscriptionParamsStruct = { |
There was a problem hiding this comment.
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 = ( |
There was a problem hiding this comment.
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 ({ |
There was a problem hiding this comment.
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] = |
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.