diff --git a/examples/pre/nextjs/src/app/page.tsx b/examples/pre/nextjs/src/app/page.tsx index 65149bd36..5e612d6b6 100644 --- a/examples/pre/nextjs/src/app/page.tsx +++ b/examples/pre/nextjs/src/app/page.tsx @@ -2,10 +2,10 @@ import { Alice, Bob, + domains, EnactedPolicy, getPorterUri, initialize, - PRE_DOMAIN, SecretKey, toHexString, } from '@nucypher/pre'; @@ -107,7 +107,7 @@ function App() { const policy = await alice.grant( provider, provider.getSigner(), - getPorterUri(PRE_DOMAIN.TESTNET), + getPorterUri(domains.TESTNET), policyParams, ); diff --git a/examples/pre/nodejs/src/index.ts b/examples/pre/nodejs/src/index.ts index 5006fa65a..931567605 100644 --- a/examples/pre/nodejs/src/index.ts +++ b/examples/pre/nodejs/src/index.ts @@ -1,9 +1,9 @@ import { Alice, Bob, + domains, getPorterUri, initialize, - PRE_DOMAIN, SecretKey, toBytes, } from '@nucypher/pre'; @@ -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...'); diff --git a/examples/pre/react/src/App.tsx b/examples/pre/react/src/App.tsx index 3c3de670f..54d9ea5a3 100644 --- a/examples/pre/react/src/App.tsx +++ b/examples/pre/react/src/App.tsx @@ -1,10 +1,10 @@ import { Alice, Bob, + domains, EnactedPolicy, getPorterUri, initialize, - PRE_DOMAIN, SecretKey, toHexString } from '@nucypher/pre'; @@ -98,7 +98,7 @@ function App() { const policy = await alice.grant( provider, provider.getSigner(), - getPorterUri(PRE_DOMAIN.TESTNET), + getPorterUri(domains.TESTNET), policyParams, ); diff --git a/examples/pre/webpack-5/src/index.ts b/examples/pre/webpack-5/src/index.ts index f1dfa348f..fe05e1f4b 100644 --- a/examples/pre/webpack-5/src/index.ts +++ b/examples/pre/webpack-5/src/index.ts @@ -1,10 +1,10 @@ import { Alice, Bob, - PRE_DOMAIN, - SecretKey, + domains, getPorterUri, initialize, + SecretKey, } from '@nucypher/pre'; import { ethers } from 'ethers'; @@ -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( diff --git a/examples/taco/nextjs/src/app/page.tsx b/examples/taco/nextjs/src/app/page.tsx index a7e3da8fa..adc7e6393 100644 --- a/examples/taco/nextjs/src/app/page.tsx +++ b/examples/taco/nextjs/src/app/page.tsx @@ -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'; @@ -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)); diff --git a/examples/taco/nodejs/src/index.ts b/examples/taco/nodejs/src/index.ts index 1bbfa6550..339fc7cb9 100644 --- a/examples/taco/nodejs/src/index.ts +++ b/examples/taco/nodejs/src/index.ts @@ -5,7 +5,7 @@ import { fromBytes, getPorterUri, initialize, - TACO_DOMAIN, + domains, toBytes, } from '@nucypher/taco'; import * as dotenv from 'dotenv'; @@ -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); diff --git a/examples/taco/react/src/App.tsx b/examples/taco/react/src/App.tsx index 67691a937..4ff758a89 100644 --- a/examples/taco/react/src/App.tsx +++ b/examples/taco/react/src/App.tsx @@ -5,7 +5,7 @@ import { fromBytes, getPorterUri, initialize, - TACO_DOMAIN, + domains, } from '@nucypher/taco'; import {ethers} from 'ethers'; import {useEffect, useState} from 'react'; @@ -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)); diff --git a/examples/taco/webpack-5/src/index.ts b/examples/taco/webpack-5/src/index.ts index 3554c8e76..5b44889ab 100644 --- a/examples/taco/webpack-5/src/index.ts +++ b/examples/taco/webpack-5/src/index.ts @@ -5,7 +5,7 @@ import { fromBytes, getPorterUri, initialize, - TACO_DOMAIN, + domains, toBytes, } from '@nucypher/taco'; import { ethers } from 'ethers'; @@ -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); diff --git a/packages/pre/src/index.ts b/packages/pre/src/index.ts index 9b4a13d95..c5bf1e123 100644 --- a/packages/pre/src/index.ts +++ b/packages/pre/src/index.ts @@ -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'; diff --git a/packages/pre/src/porter.ts b/packages/pre/src/porter.ts deleted file mode 100644 index 8e244265a..000000000 --- a/packages/pre/src/porter.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { getPorterUri as doGetPorterUri } from '@nucypher/shared'; - -type PreDomain = 'oryx'; - -export const PRE_DOMAIN: Record = { - TESTNET: 'oryx', -}; - -export const getPorterUri = (domain: PreDomain): string => { - const preDomainKeys = Object.keys(PRE_DOMAIN); - if (!preDomainKeys.includes(domain)) { - throw new Error(`${domain} is not a valid PRE domain.`); - } - return doGetPorterUri(domain); -}; - -export { fromBytes, initialize, toBytes, toHexString } from '@nucypher/shared'; diff --git a/packages/shared/src/porter.ts b/packages/shared/src/porter.ts index c9a6e3f7b..2de148620 100644 --- a/packages/shared/src/porter.ts +++ b/packages/shared/src/porter.ts @@ -18,9 +18,16 @@ const porterUri: Record = { 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 = { + 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}`); diff --git a/packages/taco/src/index.ts b/packages/taco/src/index.ts index 617e917b2..f2d9646f4 100644 --- a/packages/taco/src/index.ts +++ b/packages/taco/src/index.ts @@ -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'; diff --git a/packages/taco/src/porter.ts b/packages/taco/src/porter.ts deleted file mode 100644 index 6572db214..000000000 --- a/packages/taco/src/porter.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { getPorterUri as doGetPorterUri } from '@nucypher/shared'; - -type TacoDomain = 'lynx' | 'tapir'; - -export const TACO_DOMAIN: Record = { - DEV: 'lynx', - TESTNET: 'tapir', -}; - -export const getPorterUri = (domain: TacoDomain): string => { - const tacoDomainKeys = Object.keys(TACO_DOMAIN); - if (!tacoDomainKeys.includes(domain)) { - throw new Error(`${domain} is not a valid TACo domain.`); - } - return doGetPorterUri(domain); -}; - -export { fromBytes, initialize, toBytes, toHexString } from '@nucypher/shared';