Skip to content

Commit

Permalink
PR comments / cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
45930 committed Aug 14, 2024
1 parent 01cae16 commit f476b3a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
9 changes: 9 additions & 0 deletions src/examples/utils/network-configuration.ts
Original file line number Diff line number Diff line change
@@ -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',
}
Original file line number Diff line number Diff line change
@@ -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<K extends string>(
function randomAccounts<K extends string>(
...names: [K, ...K[]]
): { keys: Record<K, PrivateKey>; addresses: Record<K, PublicKey> } {
let base58Keys = Array(names.length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
SmartContract,
method,
assert,
} from '../../../../dist/node/index.js';
} from 'o1js';

export { ActionsContract, testLocal };

Expand Down
2 changes: 1 addition & 1 deletion src/examples/zkapps/reducer/actions-as-merkle-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
SmartContract,
method,
assert,
} from '../../../../dist/node/index.js';
} from 'o1js';

export { MerkleListReducing, testLocal };

Expand Down
29 changes: 6 additions & 23 deletions src/examples/zkapps/reducer/run-live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,26 @@ 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');

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');
Expand Down
2 changes: 1 addition & 1 deletion src/lib/mina/fetch.unit-test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export const mockFetchActionsResponse =
export {
mockFetchActionsResponse
}

const mockFetchActionsResponse =
{
"data": {
"actions": [
Expand Down

0 comments on commit f476b3a

Please sign in to comment.