Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@proto-kit/sequencer": "*",
"@proto-kit/stack": "*",
"@proto-kit/indexer": "*",
"@proto-kit/persistance": "*",
"o1js": "^2.10.0",
"tsyringe": "^4.10.0"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/commands/lightnet/faucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ interface FaucetArgs {

export const faucetCommand: CommandModule<{}, FaucetArgs> = {
command: "faucet <publicKey>",
describe: "Send MINA to an account from the lightnet faucet",
describe:
"Send MINA to an account from the lightnet faucet\n\nRequires: MINA_NODE_GRAPHQL_HOST, MINA_NODE_GRAPHQL_PORT, MINA_ARCHIVE_GRAPHQL_HOST, MINA_ARCHIVE_GRAPHQL_PORT, MINA_ACCOUNT_MANAGER_HOST, MINA_ACCOUNT_MANAGER_PORT",
builder: (yarg) =>
addEnvironmentOptions(
yarg.positional("publicKey", {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/lightnet/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface InitializeArgs {
export const initializeCommand: CommandModule<{}, InitializeArgs> = {
command: "initialize",
describe:
"Initialize lightnet: wait for network, fund accounts, and deploy settlement\n\nRequires: MINA_NODE_GRAPHQL_HOST, MINA_NODE_GRAPHQL_PORT, MINA_ARCHIVE_GRAPHQL_HOST, MINA_ARCHIVE_GRAPHQL_PORT, MINA_ACCOUNT_MANAGER_HOST, MINA_ACCOUNT_MANAGER_PORT, PROTOKIT_SETTLEMENT_CONTRACT_PRIVATE_KEY, PROTOKIT_DISPATCHER_CONTRACT_PRIVATE_KEY, PROTOKIT_MINA_BRIDGE_CONTRACT_PRIVATE_KEY",
"Initialize lightnet: wait for network, fund accounts, and deploy settlement\n\nRequires: MINA_NODE_GRAPHQL_HOST, MINA_NODE_GRAPHQL_PORT, MINA_ARCHIVE_GRAPHQL_HOST, MINA_ARCHIVE_GRAPHQL_PORT, MINA_ACCOUNT_MANAGER_HOST, MINA_ACCOUNT_MANAGER_PORT, PROTOKIT_SEQUENCER_PUBLIC_KEY, TEST_ACCOUNT_1_PUBLIC_KEY, PROTOKIT_SETTLEMENT_CONTRACT_PUBLIC_KEY, PROTOKIT_DISPATCHER_CONTRACT_PUBLIC_KEY",
builder: (yarg) => addEnvironmentOptions(yarg),
handler: async (args) => {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/settlement/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface DeployArgs {
export const deployCommand: CommandModule<{}, DeployArgs> = {
command: "deploy",
describe:
"Deploy settlement contracts\n\nRequires: PROTOKIT_SETTLEMENT_CONTRACT_PRIVATE_KEY, PROTOKIT_DISPATCHER_CONTRACT_PRIVATE_KEY, PROTOKIT_MINA_BRIDGE_CONTRACT_PRIVATE_KEY",
"Deploy settlement contracts\n\nRequires: PROTOKIT_SETTLEMENT_CONTRACT_PUBLIC_KEY, PROTOKIT_DISPATCHER_CONTRACT_PUBLIC_KEY",
builder: (yarg) => addEnvironmentOptions(yarg),
handler: async (args) => {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/settlement/tokenDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const tokenDeployCommand: CommandModule<{}, TokenDeployArgs> = {
command:
"token-deploy <tokenSymbol> <feepayerKey> <receiverPublicKey> [mintAmount]",
describe:
"Deploy custom fungible token for settlement\n\nRequires: PROTOKIT_SETTLEMENT_CONTRACT_PRIVATE_KEY, PROTOKIT_DISPATCHER_CONTRACT_PRIVATE_KEY, PROTOKIT_CUSTOM_TOKEN_PRIVATE_KEY, PROTOKIT_CUSTOM_TOKEN_ADMIN_PRIVATE_KEY, PROTOKIT_CUSTOM_TOKEN_BRIDGE_PRIVATE_KEY",
"Deploy custom fungible token for settlement\n\nRequires: REDIS_HOST, REDIS_PORT, REDIS_PASSWORD, DATABASE_URL, PROTOKIT_SETTLEMENT_CONTRACT_PRIVATE_KEY, PROTOKIT_DISPATCHER_CONTRACT_PRIVATE_KEY",
builder: (yarg) =>
addEnvironmentOptions(
yarg
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const wizardCommand: CommandModule<{}> = {
handler: async () => {
try {
const { default: createEnvironment } =
await import("../scripts/env/create-environment");
await import("../scripts/wizard/generate");
await createEnvironment();
process.exit(0);
} catch (error) {
Expand Down
15 changes: 8 additions & 7 deletions packages/cli/src/scripts/bridge/deposit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DispatchSmartContract } from "@proto-kit/protocol";
import { InMemoryDatabase } from "@proto-kit/sequencer";

import {
loadEnvironmentVariables,
Expand All @@ -25,6 +26,9 @@ export default async function (
);
}
loadEnvironmentVariables(options);
const { scriptModules, scriptModulesConfig } =
await import("../../utils/modules");

const {
BridgingModule,
MinaTransactionSender,
Expand All @@ -34,7 +38,6 @@ export default async function (
} = await import("@proto-kit/sequencer");
const { Runtime } = await import("@proto-kit/module");
const { Protocol } = await import("@proto-kit/protocol");
const { DefaultConfigs, DefaultModules } = await import("@proto-kit/stack");
const {
AccountUpdate,
fetchAccount,
Expand Down Expand Up @@ -87,8 +90,8 @@ export default async function (
...protocol.settlementModules,
}),
Sequencer: Sequencer.from({
...DefaultModules.inMemoryDatabase(),
...DefaultModules.settlementScript(),
Database: InMemoryDatabase,
...scriptModules,
}),
});

Expand All @@ -99,10 +102,8 @@ export default async function (
...protocol.settlementModulesConfig,
},
Sequencer: {
...DefaultConfigs.inMemoryDatabase(),
...DefaultConfigs.settlementScript({
preset: "development",
}),
Database: {},
...scriptModulesConfig,
},
});

Expand Down
15 changes: 8 additions & 7 deletions packages/cli/src/scripts/bridge/redeem.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { InMemoryDatabase } from "@proto-kit/sequencer";

import {
loadEnvironmentVariables,
getRequiredEnv,
Expand All @@ -22,6 +24,8 @@ export default async function (
);
}
loadEnvironmentVariables(options);
const { scriptModules, scriptModulesConfig } =
await import("../../utils/modules");

const {
BridgingModule,
Expand All @@ -42,7 +46,6 @@ export default async function (
UInt64,
} = await import("o1js");
const { FungibleToken } = await import("mina-fungible-token");
const { DefaultConfigs, DefaultModules } = await import("@proto-kit/stack");
const { runtime, protocol } = await loadUserModules();
const tokenId = Field(bridgeArgs.tokenId);
const toPrivateKey = PrivateKey.fromBase58(
Expand Down Expand Up @@ -72,8 +75,8 @@ export default async function (
...protocol.settlementModules,
}),
Sequencer: Sequencer.from({
...DefaultModules.inMemoryDatabase(),
...DefaultModules.settlementScript(),
Database: InMemoryDatabase,
...scriptModules,
}),
});

Expand All @@ -84,10 +87,8 @@ export default async function (
...protocol.settlementModulesConfig,
},
Sequencer: {
...DefaultConfigs.inMemoryDatabase(),
...DefaultConfigs.settlementScript({
preset: "development",
}),
Database: {},
...scriptModulesConfig,
},
});

Expand Down
37 changes: 23 additions & 14 deletions packages/cli/src/scripts/settlement/deploy-token.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/* eslint-disable no-inner-declarations */

import { DispatchSmartContract } from "@proto-kit/protocol";
import { PrismaRedisDatabase } from "@proto-kit/persistance";
import "reflect-metadata";
import { container } from "tsyringe";

import { loadEnvironmentVariables, LoadEnvOptions } from "../../utils/loadEnv";
import {
getRequiredEnv,
loadEnvironmentVariables,
LoadEnvOptions,
} from "../../utils/loadEnv";
import { loadUserModules } from "../../utils/loadUserModules";

export interface TokenDeployArgs {
Expand All @@ -25,6 +30,8 @@ export default async function (
);
}
loadEnvironmentVariables(options);
const { scriptModules, scriptModulesConfig } =
await import("../../utils/modules");

const { Runtime } = await import("@proto-kit/module");
const { Protocol } = await import("@proto-kit/protocol");
Expand All @@ -51,7 +58,6 @@ export default async function (
} = await import("o1js");
const { FungibleToken, FungibleTokenAdmin } =
await import("mina-fungible-token");
const { DefaultConfigs, DefaultModules } = await import("@proto-kit/stack");

const { runtime, protocol } = await loadUserModules();
const appChain = AppChain.from({
Expand All @@ -61,8 +67,8 @@ export default async function (
...protocol.settlementModules,
}),
Sequencer: Sequencer.from({
...DefaultModules.prismaRedisDatabase(),
...DefaultModules.settlementScript(),
Database: PrismaRedisDatabase,
...scriptModules,
}),
});

Expand All @@ -73,15 +79,18 @@ export default async function (
...protocol.settlementModulesConfig,
},
Sequencer: {
...DefaultConfigs.prismaRedisDatabase({
preset: "development",
overrides: {
pruneOnStartup: false,
Database: {
redis: {
host: getRequiredEnv("REDIS_HOST"),
port: Number(getRequiredEnv("REDIS_PORT")),
password: getRequiredEnv("REDIS_PASSWORD"),
},
}),
...DefaultConfigs.settlementScript({
preset: "development",
}),
prisma: {
connection: getRequiredEnv("DATABASE_URL"),
},
pruneOnStartup: false,
},
...scriptModulesConfig,
},
});

Expand Down Expand Up @@ -256,10 +265,10 @@ export default async function (

Provable.log("Deployed and initialized settlement contracts", {
settlement: PrivateKey.fromBase58(
process.env.PROTOKIT_SETTLEMENT_CONTRACT_PRIVATE_KEY!
getRequiredEnv("PROTOKIT_SETTLEMENT_CONTRACT_PRIVATE_KEY")
).toPublicKey(),
dispatcher: PrivateKey.fromBase58(
process.env.PROTOKIT_DISPATCHER_CONTRACT_PRIVATE_KEY!
getRequiredEnv("PROTOKIT_DISPATCHER_CONTRACT_PRIVATE_KEY")
).toPublicKey(),
});

Expand Down
14 changes: 6 additions & 8 deletions packages/cli/src/scripts/settlement/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import "reflect-metadata";
import { container } from "tsyringe";
import type { Environment } from "@proto-kit/stack";

import {
loadEnvironmentVariables,
Expand All @@ -17,8 +16,10 @@ export default async function (options: LoadEnvOptions) {
const { AppChain, Sequencer, SettlementModule, InMemoryDatabase } =
await import("@proto-kit/sequencer");

const { DefaultModules, DefaultConfigs } = await import("@proto-kit/stack");
loadEnvironmentVariables(options);
const { scriptModules, scriptModulesConfig } =
await import("../../utils/modules");

const { runtime, protocol } = await loadUserModules();
const appChain = AppChain.from({
Runtime: Runtime.from(runtime.modules),
Expand All @@ -28,7 +29,7 @@ export default async function (options: LoadEnvOptions) {
}),
Sequencer: Sequencer.from({
Database: InMemoryDatabase,
...DefaultModules.settlementScript(),
...scriptModules,
}),
});

Expand All @@ -39,11 +40,8 @@ export default async function (options: LoadEnvOptions) {
...protocol.settlementModulesConfig,
},
Sequencer: {
...DefaultConfigs.inMemoryDatabase(),
...DefaultConfigs.settlementScript({
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
preset: options.env as Environment,
}),
Database: {},
...scriptModulesConfig,
SettlementModule: {
addresses: undefined,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
generateWorkerConfig,
icons,
promptUser,
} from "../../utils/create-environment";
} from "../../utils/wizard";
import { resolveChainPath } from "../../utils/pathResolver";

export default async function () {
Expand Down Expand Up @@ -46,24 +46,22 @@ export default async function () {
fs.writeFileSync(chainConfigPath, chainConfig);

if (answers.includeIndexer) {
const indexerConfig = generateIndexerConfig(answers);
const indexerConfig = generateIndexerConfig();
if (indexerConfig) {
fs.writeFileSync(indexerConfigPath, indexerConfig);
}
}

if (answers.includeProcessor && answers.includeIndexer) {
const processorConfig = generateProcessorConfig(answers);
if (answers.includeProcessor) {
const processorConfig = generateProcessorConfig();
if (processorConfig) {
fs.writeFileSync(processorConfigPath, processorConfig);
}
}

if (answers.preset !== "inmemory") {
const workerConfig = generateWorkerConfig(answers);
if (workerConfig) {
fs.writeFileSync(workerConfigPath, workerConfig);
}
const workerConfig = generateWorkerConfig(answers);
if (workerConfig) {
fs.writeFileSync(workerConfigPath, workerConfig);
}

console.log(
Expand All @@ -89,7 +87,7 @@ export default async function () {
if (answers.includeProcessor && answers.includeIndexer) {
console.log(` ${green(icons.checkmark)} processor.config.ts`);
}
if (answers.preset !== "inmemory") {
if (workerConfig) {
console.log(` ${green(icons.checkmark)} worker.config.ts`);
}

Expand Down
Loading
Loading