Skip to content

Commit

Permalink
✨ merge wip changes
Browse files Browse the repository at this point in the history
  • Loading branch information
salamaashoush committed Dec 18, 2024
1 parent 14586a5 commit 4511d85
Show file tree
Hide file tree
Showing 293 changed files with 11,399 additions and 12,399 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ coverage
dist
.turbo
build
types
.vscode
.DS_Store
.eslintcache
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22
23
2 changes: 1 addition & 1 deletion .pact-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.12
nightly
18 changes: 18 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
{
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always",
"source.organizeImports": "always"
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.experimental.useFlatConfig": true,
"[ignore]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[dotenv]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"coverage-gutters.showLineCoverage": false,
"coverage-gutters.showRulerCoverage": false,
"coverage-gutters.showGutterCoverage": false
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ npx pact-toolbox init
```typescript
// NOTE: don't ovveride the existing file, just update the necessary parts.
// import pact vite plugin
import pactVitePlugin from '@pact-toolbox/unplugin/vite';
import pactVitePlugin from "@pact-toolbox/unplugin/vite";

export default defineConfig({
plugins: [
// add pact vite plugin
pactVitePlugin({
onReady: async (client) => {
const isDeployed = await client.isContractDeployed('free.hello-world');
await client.deployContract('hello-world.pact', {
const isDeployed = await client.isContractDeployed("free.hello-world");
await client.deployContract("hello-world.pact", {
prepareTx: {
upgrade: isDeployed,
},
Expand All @@ -51,7 +51,7 @@ npx pact-toolbox doctor
- to install pact

```bash
npx pact-toolbox pact install 4.10
npx pactup install 4.10
```

### Step 5: Start vite dev server.
Expand Down
Empty file modified apps/cli/bin/pact-toolbox.mjs
100755 → 100644
Empty file.
24 changes: 12 additions & 12 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@
"verify": "tsc --noEmit --skipLibCheck"
},
"dependencies": {
"@kadena/client": "^1.11.2",
"@kadena/client": "^1.15.0",
"@kadena/pactjs": "^0.4.3",
"@kadena/pactjs-cli": "^1.11.2",
"@kadena/types": "^0.6.2",
"@pact-toolbox/client-utils": "workspace:*",
"@kadena/pactjs-cli": "^1.15.0",
"@kadena/types": "^0.7.0",
"@pact-toolbox/client": "workspace:*",
"@pact-toolbox/config": "workspace:*",
"@pact-toolbox/fabricator": "workspace:*",
"@pact-toolbox/init": "workspace:*",
Expand All @@ -76,14 +76,14 @@
"devDependencies": {
"@pact-toolbox/prettier-config": "workspace:*",
"@pact-toolbox/tsconfig": "workspace:*",
"@types/node": "^20.14.2",
"@vitest/coverage-v8": "^1.6.0",
"oxlint": "^0.4.3",
"prettier": "^3.3.1",
"tsup": "^8.1.0",
"tsx": "^4.14.1",
"typescript": "^5.4.5",
"vitest": "^1.6.0"
"@types/node": "^22.9.1",
"@vitest/coverage-v8": "^2.1.5",
"oxlint": "^0.13.0",
"prettier": "^3.3.3",
"tsup": "^8.3.5",
"tsx": "^4.19.2",
"typescript": "^5.7.2",
"vitest": "^2.1.5"
},
"peerDependencies": {
"vitest": "^1.2.2"
Expand Down
5 changes: 5 additions & 0 deletions apps/cli/pact/hello-world.pact.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// THIS FILE IS AUTOGENERATED

import { PactUnsignedTransactionBuilder, PactExecPayload } from '@pact-toolbox/client';

export declare function sayHello(name: string):PactUnsignedTransactionBuilder<PactExecPayload, unknown>;
5 changes: 5 additions & 0 deletions apps/cli/pact/hello2.pact.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// THIS FILE IS AUTOGENERATED

import { PactUnsignedTransactionBuilder, PactExecPayload } from '@pact-toolbox/client';

export declare function test(name: string):PactUnsignedTransactionBuilder<PactExecPayload, unknown>;
Empty file modified apps/cli/src/cli.ts
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions apps/cli/src/commands/prelude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineCommand } from "citty";
import { join } from "pathe";

import { resolveConfig } from "@pact-toolbox/config";
import { downloadPreludes } from "@pact-toolbox/prelude";
import { downloadAllPreludes } from "@pact-toolbox/prelude";
import { PactToolboxClient } from "@pact-toolbox/runtime";
import { logger } from "@pact-toolbox/utils";

Expand All @@ -15,7 +15,7 @@ export const preludeCommand = defineCommand({
const config = await resolveConfig();
const client = new PactToolboxClient(config);
const start = performance.now();
await downloadPreludes({
await downloadAllPreludes({
client,
contractsDir: config.contractsDir ?? "pact",
preludes: config.preludes ?? [],
Expand Down
24 changes: 15 additions & 9 deletions apps/cli/src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,24 @@ export const runCommand = defineCommand({
alias: "n",
description: "Network to use",
required: false,
default: "local",
},
},
run: async ({ args }) => {
const { script, network, start, ...rest } = args;
logger.start(`Running script ${script} on network ${network}`);
await runScript(script, {
network,
args: rest,
scriptOptions: {
autoStartNetwork: start,
},
});
logger.start(`Running script ${script} ${network ? `on network ${network}` : ""}`);
try {
await runScript(script, {
network,
args: rest,
scriptOptions: {
autoStartNetwork: start,
},
});
} catch (error) {
logger.error(`Error running script ${script}:`, error);
process.exit(1);
}
logger.success(`Script ${script} finished`);
process.exit(0);
},
});
34 changes: 16 additions & 18 deletions apps/cli/src/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ await bench("localPactServer", async () => {
});
await local.start();
await local.client.deployContract("hello-world.pact");
const signer = local.client.getValidateSigner();
const tx = local.client
const signer = local.client.getSignerKeys();
await local.client
.execution('(free.hello-world.say-hello "Salama")')
.addSigner(signer.publicKey)
.createTransaction();
const signedTx = await local.client.sign(tx);
console.log(await local.client.submitAndListen(signedTx));
.withSigner(signer.publicKey)
.sign()
.submitAndListen();
await local.stop();
});

Expand Down Expand Up @@ -55,13 +54,13 @@ await bench("devnetOnDemand", async () => {
});
await devnetOnDemand.start();
await devnetOnDemand.client.deployContract("hello-world.pact");
const signer = devnetOnDemand.client.getValidateSigner();
const tx = devnetOnDemand.client
const signer = devnetOnDemand.client.getSignerKeys();
await devnetOnDemand.client
.execution('(free.hello-world.say-hello "Salama")')
.addSigner(signer.publicKey)
.createTransaction();
const signedTx = await devnetOnDemand.client.sign(tx);
console.log(await devnetOnDemand.client.submitAndListen(signedTx));
.withSigner(signer.publicKey)
.sign()
.submitAndListen();

await devnetOnDemand.stop();
});

Expand All @@ -72,14 +71,13 @@ await bench("devnet", async () => {
});
await devnet.start();
await devnet.client.deployContract("hello-world.pact");
const signer = devnet.client.getValidateSigner();
const tx = devnet.client
const signer = devnet.client.getSignerKeys();
await devnet.client
.execution('(free.hello-world.say-hello "Salama")')
.addSigner(signer.publicKey)
.createTransaction();
.withSigner(signer.publicKey)
.sign()
.submitAndListen();

const signedTx = await devnet.client.sign(tx);
console.log(await devnet.client.submitAndListen(signedTx));
await devnet.stop();
});

Expand Down
30 changes: 30 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
"files": { "ignoreUnknown": false, "ignore": [] },
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 120,
"attributePosition": "auto",
"bracketSpacing": true
},
"organizeImports": { "enabled": true },
"linter": { "enabled": true },
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "all",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSameLine": false,
"quoteStyle": "double",
"attributePosition": "auto",
"bracketSpacing": true
}
}
}
28 changes: 13 additions & 15 deletions examples/todo-mvc-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,30 @@
"scripts": {
"lint": "oxlint --import-plugin --deny-warnings",
"format": "prettier --check . --ignore-path ../../.gitignore",
"test": "npx pact-toolbox pact install && npx pact-toolbox prelude && NODE_OPTIONS='--import tsx' vitest run",
"test": "NODE_OPTIONS='--import tsx' npx pact-toolbox test",
"verify": "tsc --noEmit"
},
"dependencies": {
"@kadena/client": "^1.11.2",
"@pact-toolbox/client-utils": "workspace:*",
"@pact-toolbox/wallet": "workspace:*",
"@tanstack/react-query": "^5.40.1",
"@kadena/client": "^1.15.0",
"@pact-toolbox/client": "workspace:*",
"@tanstack/react-query": "^5.61.0",
"react": "^18.3.1"
},
"devDependencies": {
"@pact-toolbox/prettier-config": "workspace:*",
"@pact-toolbox/test": "workspace:*",
"@pact-toolbox/unplugin": "workspace:*",
"@pact-toolbox/wallet": "workspace:*",
"@testing-library/react": "~16.0.0",
"@testing-library/react": "~16.0.1",
"@testing-library/user-event": "~14.5.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react-swc": "^3.7.0",
"happy-dom": "^14.12.0",
"oxlint": "^0.4.3",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react-swc": "^3.7.1",
"happy-dom": "^15.11.6",
"oxlint": "^0.13.0",
"pact-toolbox": "workspace:*",
"prettier": "^3.3.1",
"typescript": "^5.4.5",
"vitest": "^1.6.0",
"prettier": "^3.3.3",
"typescript": "^5.7.2",
"vitest": "^2.1.5",
"vitest-dom": "^0.1.1"
},
"prettier": "@pact-toolbox/prettier-config"
Expand Down
5 changes: 5 additions & 0 deletions examples/todo-mvc-common/pact/hello-world.pact.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// THIS FILE IS AUTOGENERATED

import { PactTransactionBuilder, PactExecPayload } from '@pact-toolbox/client';

export declare function sayHello(name: string): PactTransactionBuilder<PactExecPayload, unknown>;
27 changes: 15 additions & 12 deletions examples/todo-mvc-common/pact/todos.pact
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,54 @@

;; todo schema and table
(defschema todo
"Row type for todos."
title:string
completed:bool
deleted:bool
"Row type for todos table"
id:string
title:string
completed:bool
deleted:bool
)


(deftable todo-table:{todo})

;;
;; API functions
;;

(defun new-todo (id title)
(defun new-todo:string (id:string title:string)
@doc "Create new todo with ENTRY and DATE."
(insert todo-table id {
"id": id,
"title": title,
"completed": false,
"deleted": false
})
)

(defun toggle-todo-status (id)
(defun toggle-todo-status (id:string)
"Toggle completed status flag for todo at ID."
(with-read todo-table id { "completed":= state }
(update todo-table id { "completed": (not state) })
)
)

(defun edit-todo (id title)
(defun edit-todo (id:string title:string)
"Update todo ENTRY at ID."
(update todo-table id { "title": title }))

(defun delete-todo (id)
(defun delete-todo (id:string)
"Delete todo title at ID (by setting deleted flag)."
(update todo-table id { "deleted": true })
)

(defun read-todo (id)
(defun read-todo:object{todo} (id:string)
"Read a single todo"
(+ {'id: id} (read todo-table id))
(read todo-table id)
)

(defun read-todos()
(defun read-todos:[object{todo}] ()
"Read all todos."
(map (read-todo) (keys todo-table))
(filter (lambda (todo) (= (at "deleted" todo) false)) (map (read-todo) (keys todo-table)))
)
)

Expand Down
Loading

0 comments on commit 4511d85

Please sign in to comment.