diff --git a/src/examples/utils/network-configuration.ts b/src/examples/utils/network-configuration.ts new file mode 100644 index 0000000000..1fb26628a9 --- /dev/null +++ b/src/examples/utils/network-configuration.ts @@ -0,0 +1,9 @@ +export { + DEFAULT_LIGHTNET_CONFIG +} + +const DEFAULT_LIGHTNET_CONFIG = { + mina: 'http://localhost:8080/graphql', + archive: 'http://localhost:8282', + lightnetAccountManager: 'http://localhost:8181', +} \ No newline at end of file diff --git a/src/examples/utils/randomAccounts.ts b/src/examples/utils/random-accounts.ts similarity index 83% rename from src/examples/utils/randomAccounts.ts rename to src/examples/utils/random-accounts.ts index 2b43a511d6..c1ca28265e 100644 --- a/src/examples/utils/randomAccounts.ts +++ b/src/examples/utils/random-accounts.ts @@ -1,9 +1,13 @@ -import { PrivateKey, PublicKey } from '../../../dist/node/index.js'; +import { PrivateKey, PublicKey } from 'o1js'; + +export { + randomAccounts +} /** * Predefined accounts keys, labeled by the input strings. Useful for testing/debugging with consistent keys. */ -export function randomAccounts( +function randomAccounts( ...names: [K, ...K[]] ): { keys: Record; addresses: Record } { let base58Keys = Array(names.length) diff --git a/src/examples/zkapps/reducer/actions-as-merkle-list-iterator.ts b/src/examples/zkapps/reducer/actions-as-merkle-list-iterator.ts index 643842a640..15b9c6e673 100644 --- a/src/examples/zkapps/reducer/actions-as-merkle-list-iterator.ts +++ b/src/examples/zkapps/reducer/actions-as-merkle-list-iterator.ts @@ -18,7 +18,7 @@ import { SmartContract, method, assert, -} from '../../../../dist/node/index.js'; +} from 'o1js'; export { ActionsContract, testLocal }; diff --git a/src/examples/zkapps/reducer/actions-as-merkle-list.ts b/src/examples/zkapps/reducer/actions-as-merkle-list.ts index 42e2160f88..4d66e92b48 100644 --- a/src/examples/zkapps/reducer/actions-as-merkle-list.ts +++ b/src/examples/zkapps/reducer/actions-as-merkle-list.ts @@ -17,7 +17,7 @@ import { SmartContract, method, assert, -} from '../../../../dist/node/index.js'; +} from 'o1js'; export { MerkleListReducing, testLocal }; diff --git a/src/examples/zkapps/reducer/run-live.ts b/src/examples/zkapps/reducer/run-live.ts index fac06d77ac..dc291dba01 100644 --- a/src/examples/zkapps/reducer/run-live.ts +++ b/src/examples/zkapps/reducer/run-live.ts @@ -3,28 +3,15 @@ import { Lightnet, Mina, PrivateKey, -} from '../../../../dist/node/index.js'; -import { randomAccounts } from '../../utils/randomAccounts.js'; +} from 'o1js'; +import { DEFAULT_LIGHTNET_CONFIG } from '../../utils/network-configuration.js'; +import { randomAccounts } from '../../utils/random-accounts.js'; import { tic, toc } from '../../utils/tic-toc.node.js'; import { MerkleListReducing } from './actions-as-merkle-list.js'; -const useCustomLocalNetwork = process.env.USE_CUSTOM_LOCAL_NETWORK === 'true'; - -if (!useCustomLocalNetwork) { - throw 'Only Lightnet is currently supported'; -} - tic('Run reducer examples against real network.'); console.log(); -const network = Mina.Network({ - mina: useCustomLocalNetwork - ? 'http://localhost:8080/graphql' - : 'https://berkeley.minascan.io/graphql', - archive: useCustomLocalNetwork - ? 'http://localhost:8282' - : 'https://api.minascan.io/archive/berkeley/v1/graphql', - lightnetAccountManager: 'http://localhost:8181', -}); +const network = Mina.Network(DEFAULT_LIGHTNET_CONFIG); Mina.setActiveInstance(network); let { keys, addresses } = randomAccounts('contract', 'user1', 'user2'); @@ -32,14 +19,10 @@ let { keys, addresses } = randomAccounts('contract', 'user1', 'user2'); let pendingTx: Mina.PendingTransaction; // compile contracts & wait for fee payer to be funded -const senderKey = useCustomLocalNetwork - ? (await Lightnet.acquireKeyPair()).privateKey - : PrivateKey.random(); +const senderKey = (await Lightnet.acquireKeyPair()).privateKey const sender = senderKey.toPublicKey(); -const sender2Key = useCustomLocalNetwork - ? (await Lightnet.acquireKeyPair()).privateKey - : PrivateKey.random(); +const sender2Key = (await Lightnet.acquireKeyPair()).privateKey const sender2 = sender2Key.toPublicKey(); tic('Compiling Merkle List Reducer Smart Contract'); diff --git a/src/lib/mina/fetch.unit-test.ts b/src/lib/mina/fetch.unit-test.ts index 5678eee9d6..3f0d662cec 100644 --- a/src/lib/mina/fetch.unit-test.ts +++ b/src/lib/mina/fetch.unit-test.ts @@ -1,6 +1,6 @@ import { PrivateKey, TokenId } from 'o1js'; import { createActionsList } from './fetch.js'; -import { mockFetchActionsResponse } from './fixtures/fetchActionsResponse.js'; +import { mockFetchActionsResponse } from './fixtures/fetch-actions-response.js'; import { test, describe } from 'node:test'; import { removeJsonQuotes } from './graphql.js'; import { expect } from 'expect'; diff --git a/src/lib/mina/fixtures/fetchActionsResponse.ts b/src/lib/mina/fixtures/fetch-actions-response.ts similarity index 98% rename from src/lib/mina/fixtures/fetchActionsResponse.ts rename to src/lib/mina/fixtures/fetch-actions-response.ts index 20e5648b87..3e280bbff2 100644 --- a/src/lib/mina/fixtures/fetchActionsResponse.ts +++ b/src/lib/mina/fixtures/fetch-actions-response.ts @@ -1,4 +1,8 @@ -export const mockFetchActionsResponse = +export { + mockFetchActionsResponse +} + +const mockFetchActionsResponse = { "data": { "actions": [