Skip to content

Commit

Permalink
apply pr suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Oct 16, 2023
1 parent 76911fa commit 9b6de63
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 59 deletions.
4 changes: 2 additions & 2 deletions examples/pre/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import {
Alice,
Bob,
domains,
EnactedPolicy,
getPorterUri,
initialize,
PRE_DOMAIN,
SecretKey,
toHexString,
} from '@nucypher/pre';
Expand Down Expand Up @@ -107,7 +107,7 @@ function App() {
const policy = await alice.grant(
provider,
provider.getSigner(),
getPorterUri(PRE_DOMAIN.TESTNET),
getPorterUri(domains.TESTNET),
policyParams,
);

Expand Down
4 changes: 2 additions & 2 deletions examples/pre/nodejs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
Alice,
Bob,
domains,
getPorterUri,
initialize,
PRE_DOMAIN,
SecretKey,
toBytes,
} from '@nucypher/pre';
Expand Down Expand Up @@ -59,7 +59,7 @@ const runExample = async () => {
startDate: new Date(),
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30), // In 30 days,
};
const porterUri = getPorterUri(PRE_DOMAIN.TESTNET);
const porterUri = getPorterUri(domains.TESTNET);
const alice = makeAlice();

console.log('Creating policy...');
Expand Down
4 changes: 2 additions & 2 deletions examples/pre/react/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
Alice,
Bob,
domains,
EnactedPolicy,
getPorterUri,
initialize,
PRE_DOMAIN,
SecretKey,
toHexString
} from '@nucypher/pre';
Expand Down Expand Up @@ -98,7 +98,7 @@ function App() {
const policy = await alice.grant(
provider,
provider.getSigner(),
getPorterUri(PRE_DOMAIN.TESTNET),
getPorterUri(domains.TESTNET),
policyParams,
);

Expand Down
6 changes: 3 additions & 3 deletions examples/pre/webpack-5/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
Alice,
Bob,
PRE_DOMAIN,
SecretKey,
domains,
getPorterUri,
initialize,
SecretKey,
} from '@nucypher/pre';
import { ethers } from 'ethers';

Expand Down Expand Up @@ -65,7 +65,7 @@ const runExample = async () => {
startDate,
endDate,
};
const porterUri = getPorterUri(PRE_DOMAIN.TESTNET);
const porterUri = getPorterUri(domains.TESTNET);

const alice = makeAlice();
const policy = await alice.grant(
Expand Down
9 changes: 5 additions & 4 deletions examples/taco/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import {
conditions,
decrypt,
encrypt, fromBytes,
domains,
encrypt,
fromBytes,
getPorterUri,
initialize,
TACO_DOMAIN
initialize
} from '@nucypher/taco';
import {ethers} from 'ethers';
import {useEffect, useState} from 'react';
Expand Down Expand Up @@ -90,7 +91,7 @@ function App() {
const messageKit = await encrypt(provider, message, hasPositiveBalance, ritualId, signer);

console.log('Decrypting message...');
const porterUri = getPorterUri(TACO_DOMAIN.DEV);
const porterUri = getPorterUri(domains.DEV);
const decryptedMessage = await decrypt(provider, messageKit,porterUri,signer);

setDecryptedMessage(fromBytes(decryptedMessage));
Expand Down
4 changes: 2 additions & 2 deletions examples/taco/nodejs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
fromBytes,
getPorterUri,
initialize,
TACO_DOMAIN,
domains,
toBytes,
} from '@nucypher/taco';
import * as dotenv from 'dotenv';
Expand Down Expand Up @@ -58,7 +58,7 @@ const runExample = async () => {
);

console.log('Decrypting message...');
const porterUri = getPorterUri(TACO_DOMAIN.DEV);
const porterUri = getPorterUri(domains.DEV);
const decryptedBytes = await decrypt(provider, messageKit, porterUri, signer);
const decryptedMessageString = fromBytes(decryptedBytes);
console.log('Decrypted message:', decryptedMessageString);
Expand Down
4 changes: 2 additions & 2 deletions examples/taco/react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
fromBytes,
getPorterUri,
initialize,
TACO_DOMAIN,
domains,
} from '@nucypher/taco';
import {ethers} from 'ethers';
import {useEffect, useState} from 'react';
Expand Down Expand Up @@ -90,7 +90,7 @@ function App() {
const messageKit = await encrypt(provider, message, hasPositiveBalance, ritualId, signer);

console.log('Decrypting message...');
const porterUri = getPorterUri(TACO_DOMAIN.DEV);
const porterUri = getPorterUri(domains.DEV);
const decryptedMessage = await decrypt(provider, messageKit, porterUri, signer);

setDecryptedMessage(fromBytes(decryptedMessage));
Expand Down
4 changes: 2 additions & 2 deletions examples/taco/webpack-5/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
fromBytes,
getPorterUri,
initialize,
TACO_DOMAIN,
domains,
toBytes,
} from '@nucypher/taco';
import { ethers } from 'ethers';
Expand Down Expand Up @@ -48,7 +48,7 @@ const runExample = async () => {
);

console.log('Decrypting message...');
const porterUri = getPorterUri(TACO_DOMAIN.DEV);
const porterUri = getPorterUri(domains.DEV);
const decryptedBytes = await decrypt(provider, messageKit, porterUri, signer);
const decryptedMessage = fromBytes(decryptedBytes);
console.log('Decrypted message:', decryptedMessage);
Expand Down
3 changes: 1 addition & 2 deletions packages/pre/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ export {
SecretKey,
Signer,
TreasureMap,
initialize,
} from '@nucypher/nucypher-core';
export { fromBytes, initialize, toBytes, toHexString, getPorterUri, domains } from '@nucypher/shared';

export { Alice, Bob, Enrico } from './characters';
export { Cohort } from './cohort';
export { EnactedPolicy } from './policy';
export * from './porter';
17 changes: 0 additions & 17 deletions packages/pre/src/porter.ts

This file was deleted.

11 changes: 9 additions & 2 deletions packages/shared/src/porter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ const porterUri: Record<string, string> = {
oryx: 'https://porter-oryx.nucypher.community',
lynx: 'https://porter-lynx.nucypher.community',
};
export type PorterDomain = keyof typeof porterUri;

export const getPorterUri = (domain: PorterDomain): string => {
export type Domain = keyof typeof porterUri;

export const domains: Record<string, Domain> = {
DEV: 'lynx',
TESTNET: 'tapir',
MAINNET: 'mainnet',
};

export const getPorterUri = (domain: Domain): string => {
const uri = porterUri[domain];
if (!uri) {
throw new Error(`No default Porter URI found for domain: ${domain}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/taco/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { DkgPublicKey, ThresholdMessageKit } from '@nucypher/nucypher-core';
export { fromBytes, initialize, toBytes, toHexString, getPorterUri, domains } from '@nucypher/shared';

export * as conditions from './conditions';
export * from './porter';
export * from './taco';
18 changes: 0 additions & 18 deletions packages/taco/src/porter.ts

This file was deleted.

0 comments on commit 9b6de63

Please sign in to comment.