Skip to content

Conversation

@Le-Caignec
Copy link
Contributor

No description provided.

@Le-Caignec Le-Caignec changed the base branch from main to develop May 2, 2023 15:09
@Le-Caignec
Copy link
Contributor Author

Le-Caignec commented May 2, 2023

for testing RevokeAllAccess function :

 import { IExecDataProtector } from '@iexec/dataprotector';
import { getSignerFromPrivateKey } from 'iexec/utils';
import { Wallet } from 'ethers';

const main = async () => {
  const ethProvider = getSignerFromPrivateKey(
    'https://bellecour.iex.ec',
    Wallet.createRandom().privateKey
  );

  const dataProtector = new IExecDataProtector(ethProvider);

  const { address } = await dataProtector.protectData({
    data: {
      firstName: 'John',
      familyName: 'Doe',
      birthYear: 1971,
      usCitizen: true,
    },
    name: 'my personal data',
  });
  console.log('Protected Data Created : ', address);

  const orderHash_1 = await dataProtector.grantAccess({
    protectedData: address,
    authorizedUser: '0x5D350f9331F22E54Dc0854CaA80696f0b4fdCd7a',
    authorizedApp: '0x987def06c1e009cbc45d662b6a12195cbd77beb6',
  });
  console.log('Ganted Access given to the Protected Data : ', orderHash_1);

  const orderHash_2 = await dataProtector.grantAccess({
    protectedData: address,
    authorizedUser: '0x937e9C2028C413313A2C0EdA1aDf66E176F9Baf7',
    authorizedApp: '0x987def06c1e009cbc45d662b6a12195cbd77beb6',
  });
  console.log('Ganted Access given to the Protected Data : ', orderHash_2);

  await dataProtector
    .revokeAllAccessObservable({
      protectedData: address,
    })
    .subscribe(
      (data) => console.log(data),
      (e) => console.log(e),
      () => console.log('DONE')
    );
};

main();

@Le-Caignec Le-Caignec marked this pull request as ready for review May 2, 2023 15:14
Copy link
Member

@PierreJeanjacquot PierreJeanjacquot left a comment

Choose a reason for hiding this comment

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

see comments

Copy link
Member

@PierreJeanjacquot PierreJeanjacquot left a comment

Choose a reason for hiding this comment

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

LGTM

@Le-Caignec Le-Caignec merged commit 56eb240 into develop May 3, 2023
@Le-Caignec Le-Caignec deleted the feature/revokeAllAccess branch May 3, 2023 13:23
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.

2 participants