@pasosdejesus/m 0.15.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,50 +1,28 @@
1
- # Learn.tg - Smart Contracts
1
+ # Smart Contracts (Hardhat)
2
2
 
3
- This directory contains the Solidity smart contracts for the
4
- platform, managed with Hardhat. These contracts handle ...
5
-
6
- ## Overview
7
-
8
- - **`MockUSDT.sol`**: A mock USDT contract for testing purposes in a
9
- local or testnet environment.
3
+ Smart contracts managed with Hardhat.
10
4
 
11
5
  ## Prerequisites
12
6
 
13
7
  - [Node.js](https://nodejs.org/) (>= 18)
14
- - [Yarn](https://yarnpkg.com/)
15
- - A Celo-compatible wallet with test funds. You can get Sepolia Celo
16
- tokens from the [Celo Faucet](https://faucet.celo.org/celo-sepolia).
17
- To get test cCop use https://app.mento.org/
8
+ - [pnpm](https://pnpm.io/)
9
+ - A wallet with test funds for the target network.
18
10
 
19
11
  ## 1. Environment Configuration
20
12
 
21
- First, create your environment file by copying the template:
13
+ Create your environment file:
22
14
 
23
15
  ```sh
24
16
  cp .env.example .env
25
17
  ```
26
18
 
27
- Next, edit the `.env` file with the following information:
28
-
29
- - `NETWORK`: The network to deploy to. Use `celoSepolia` for the testnet
30
- or `celo` for mainnet.
31
- - `PRIVATE_KEY`: The private key of the wallet you will use for deployment.
32
- - `BLOCKSCOUT_API_KEY`: Your API key from Blockscout for contract
33
- verification. You can generate one in your account settings on the
34
- [Celo Blockscout explorer](https://explorer.celo.org/).
35
- - `DEPLOYED_AT`: This will hold the contract address after deployment.
36
- Leave it blank for now.
37
-
38
- **⚠️ Security Warning:** Never use a wallet containing real funds for
39
- development. Always generate and use a separate, dedicated wallet
40
- for testing.
19
+ Edit `.env` with your keys and network configuration.
41
20
 
42
21
  ## 2. Platform-Specific Setup (adJ / OpenBSD)
43
22
 
44
- Due to compatibility issues, Hardhat v3 does not work on adJ/OpenBSD
45
- as of 2025. This project is configured to use Hardhat v2. If you are on
46
- this platform, you must first run the following script to prepare the
47
- environment:
23
+ On OpenBSD/adJ, Hardhat's native binary (`@nomicfoundation/edr`) is not
24
+ available. This project uses `m contract:test` which falls back to
25
+ `@ethereumjs/vm` via `@pasosdejesus/edr`. Run the preparation script:
48
26
 
49
27
  ```sh
50
28
  bin/prepadJ.sh
@@ -52,78 +30,66 @@ bin/prepadJ.sh
52
30
 
53
31
  ## 3. Development Workflow
54
32
 
55
- Follow these steps to compile, deploy, and verify your contracts.
56
-
57
- ### Step 3.1: Install Dependencies
33
+ ### Install Dependencies
58
34
 
59
35
  ```sh
60
- yarn install
36
+ pnpm install
61
37
  ```
62
38
 
63
- ### Step 3.2: Compile Contracts
64
-
65
- This command compiles the Solidity contracts and automatically syncs the
66
- ABIs with the Next.js frontend.
39
+ ### Compile Contracts
67
40
 
68
41
  ```sh
69
- yarn build
42
+ pnpm build
70
43
  ```
71
44
 
72
- ### Step 3.3: Deploy the Contract
73
-
74
- Make sure your deployment wallet is funded. Then, run the deployment
75
- script:
45
+ ### Deploy
76
46
 
77
47
  ```sh
78
- bin/deploy*
48
+ # See scripts/ and bin/ for deployment helpers
49
+ pnpm deploy
79
50
  ```
80
51
 
81
- The script will output the contract address to the console. **Copy
82
- this address.**
52
+ ### Verify
83
53
 
84
- ### Step 3.4: Update Environment File
54
+ ```sh
55
+ pnpm verify
56
+ ```
85
57
 
86
- Paste the copied contract address into the `DEPLOYED_AT` variable in
87
- your `.env` file.
58
+ ## 4. Testing
88
59
 
89
- ### Step 3.5: Verify Contract on Blockscout
60
+ Two test runners are available:
90
61
 
91
- This step publishes and verifies the contract's source code on the
92
- blockchain explorer, which is a crucial trust and security signal.
62
+ ### Standard (Hardhat)
93
63
 
94
64
  ```sh
95
- bin/contractVerification
65
+ pnpm test
96
66
  ```
97
67
 
98
- ## 4. Testing
99
-
100
- The project uses Hardhat's built-in testing framework with Chai matchers.
101
- The tests are located in the `test/` directory.
68
+ Runs `hardhat test` with the built-in Hardhat Network (requires native EDR binary).
102
69
 
103
- To run the entire test suite, execute the following command:
70
+ ### OpenBSD / adJ
104
71
 
105
72
  ```sh
106
- yarn test
73
+ cd ../nextjs && pnpm contract:test
107
74
  ```
108
75
 
109
- This will compile your contracts, run the tests in an in-memory Hardhat
110
- Network, and report the results in the console.
76
+ Uses `@ethereumjs/vm` fallback via `@pasosdejesus/edr`. Run from the
77
+ nextjs app directory.
111
78
 
112
- ## ABI Synchronization
79
+ ### Experimental (hardhat3)
113
80
 
114
- The contract ABIs (Application Binary Interfaces) are essential for the
115
- frontend to interact with the smart contracts. This project is configured
116
- to sync them automatically.
81
+ ```
82
+ cd tests/test-project/apps/hardhat3 && pnpm test
83
+ ```
117
84
 
118
- - **Automatic Sync:** ABIs are synced to `../nextjs/abis/` every time you
119
- run `yarn build` (or `yarn compile`).
120
- - **Manual Sync:** To sync the ABIs without recompiling, run
121
- `yarn sync:abis`.
85
+ Zero-mocking runner using `node:test` + shim. No Hardhat installation needed.
86
+
87
+ ## ABI Synchronization
122
88
 
89
+ ABIs are synced to `../nextjs/abis/` automatically on `pnpm build`.
90
+ Manual sync: `pnpm sync:abis`.
123
91
 
124
- ## 5. Practices
92
+ ## Best Practices
125
93
 
126
- * Prefer a multisig
127
- * For a project with only one owner prefer a contract with transferOwner
128
- https://metaschool.so/articles/account-ownership-in-solidity
129
- and setBackendAddress
94
+ - Prefer a multisig for production deployments.
95
+ - Use dedicated test wallets — never use production keys for development.
@@ -3,6 +3,74 @@
3
3
  *
4
4
  * "Y todo lo que hagáis, hacedlo de corazón, como para el Señor y no para los hombres" (Colosenses 3:23)
5
5
  */
6
+ /**
7
+ * Mock Kysely class for use in vi.mock() factories and direct instantiation.
8
+ *
9
+ * ```typescript
10
+ * import { MockKysely } from '@pasosdejesus/m/test-utils/kysely-mocks'
11
+ * vi.mock('kysely', () => ({ Kysely: MockKysely }))
12
+ * ```
13
+ */
14
+ export declare class MockKysely {
15
+ private _executeTakeFirst;
16
+ private _execute;
17
+ private _sqlExecute;
18
+ constructor(options?: {
19
+ executeTakeFirst?: (...args: any[]) => any;
20
+ execute?: (...args: any[]) => any;
21
+ sqlExecute?: (query: any) => any;
22
+ });
23
+ selectFrom(): this;
24
+ where(): this;
25
+ selectAll(): this;
26
+ select(...args: any[]): this;
27
+ orderBy(): this;
28
+ limit(): this;
29
+ groupBy(): this;
30
+ having(): this;
31
+ leftJoin(): this;
32
+ innerJoin(): this;
33
+ insertInto(): this;
34
+ values(): this;
35
+ returningAll(): this;
36
+ updateTable(): this;
37
+ set(): this;
38
+ deleteFrom(): this;
39
+ with(): this;
40
+ transaction(): {
41
+ execute: (callback: any) => Promise<any>;
42
+ };
43
+ executeTakeFirst(): any;
44
+ executeTakeFirstOrThrow(): any;
45
+ execute(): any;
46
+ getExecutor(): {
47
+ executeQuery: (query: any) => any;
48
+ provideConnection: (callback: any) => Promise<any>;
49
+ releaseConnection: () => void;
50
+ transformQuery: (query: any, transformer: any) => any;
51
+ compileQuery: (query: any, ctx: any) => {
52
+ sql: string;
53
+ parameters: never[];
54
+ };
55
+ };
56
+ fn: {
57
+ countAll: import("vitest").Mock<() => {
58
+ as: import("vitest").Mock<() => {}>;
59
+ }>;
60
+ sum: import("vitest").Mock<() => {
61
+ as: import("vitest").Mock<() => {}>;
62
+ }>;
63
+ avg: import("vitest").Mock<() => {
64
+ as: import("vitest").Mock<() => {}>;
65
+ }>;
66
+ max: import("vitest").Mock<() => {
67
+ as: import("vitest").Mock<() => {}>;
68
+ }>;
69
+ min: import("vitest").Mock<() => {
70
+ as: import("vitest").Mock<() => {}>;
71
+ }>;
72
+ };
73
+ }
6
74
  /**
7
75
  * Creates a mock Kysely instance with configurable behavior
8
76
  *
@@ -21,60 +89,7 @@ export declare function createMockKysely(options?: {
21
89
  /** Whether to skip mocking the config module (default: false) */
22
90
  skipConfigMock?: boolean;
23
91
  }): {
24
- MockKysely: {
25
- new (): {
26
- selectFrom(): /*elided*/ any;
27
- where(): /*elided*/ any;
28
- selectAll(): /*elided*/ any;
29
- select(...args: any[]): /*elided*/ any;
30
- orderBy(): /*elided*/ any;
31
- limit(): /*elided*/ any;
32
- groupBy(): /*elided*/ any;
33
- having(): /*elided*/ any;
34
- leftJoin(): /*elided*/ any;
35
- innerJoin(): /*elided*/ any;
36
- insertInto(): /*elided*/ any;
37
- values(): /*elided*/ any;
38
- returningAll(): /*elided*/ any;
39
- updateTable(): /*elided*/ any;
40
- set(): /*elided*/ any;
41
- deleteFrom(): /*elided*/ any;
42
- with(): /*elided*/ any;
43
- transaction(): {
44
- execute: (callback: any) => Promise<any>;
45
- };
46
- executeTakeFirst(): any;
47
- executeTakeFirstOrThrow(): any;
48
- execute(): any;
49
- getExecutor(): {
50
- executeQuery: (query: any) => any;
51
- provideConnection: (callback: any) => Promise<any>;
52
- releaseConnection: () => void;
53
- transformQuery: (query: any, transformer: any) => any;
54
- compileQuery: (query: any, ctx: any) => {
55
- sql: string;
56
- parameters: never[];
57
- };
58
- };
59
- fn: {
60
- countAll: import("vitest").Mock<() => {
61
- as: import("vitest").Mock<() => {}>;
62
- }>;
63
- sum: import("vitest").Mock<() => {
64
- as: import("vitest").Mock<() => {}>;
65
- }>;
66
- avg: import("vitest").Mock<() => {
67
- as: import("vitest").Mock<() => {}>;
68
- }>;
69
- max: import("vitest").Mock<() => {
70
- as: import("vitest").Mock<() => {}>;
71
- }>;
72
- min: import("vitest").Mock<() => {
73
- as: import("vitest").Mock<() => {}>;
74
- }>;
75
- };
76
- };
77
- };
92
+ MockKysely: typeof MockKysely;
78
93
  mockExecuteTakeFirst: import("vitest").Mock<(...args: any[]) => any>;
79
94
  mockExecute: import("vitest").Mock<(...args: any[]) => any>;
80
95
  mockSqlExecute: import("vitest").Mock<(...args: any[]) => any>;
@@ -102,60 +117,7 @@ export declare function createMockKysely(options?: {
102
117
  * Pre-configured mock for database operations in API routes
103
118
  */
104
119
  export declare const apiDbMocks: {
105
- MockKysely: {
106
- new (): {
107
- selectFrom(): /*elided*/ any;
108
- where(): /*elided*/ any;
109
- selectAll(): /*elided*/ any;
110
- select(...args: any[]): /*elided*/ any;
111
- orderBy(): /*elided*/ any;
112
- limit(): /*elided*/ any;
113
- groupBy(): /*elided*/ any;
114
- having(): /*elided*/ any;
115
- leftJoin(): /*elided*/ any;
116
- innerJoin(): /*elided*/ any;
117
- insertInto(): /*elided*/ any;
118
- values(): /*elided*/ any;
119
- returningAll(): /*elided*/ any;
120
- updateTable(): /*elided*/ any;
121
- set(): /*elided*/ any;
122
- deleteFrom(): /*elided*/ any;
123
- with(): /*elided*/ any;
124
- transaction(): {
125
- execute: (callback: any) => Promise<any>;
126
- };
127
- executeTakeFirst(): any;
128
- executeTakeFirstOrThrow(): any;
129
- execute(): any;
130
- getExecutor(): {
131
- executeQuery: (query: any) => any;
132
- provideConnection: (callback: any) => Promise<any>;
133
- releaseConnection: () => void;
134
- transformQuery: (query: any, transformer: any) => any;
135
- compileQuery: (query: any, ctx: any) => {
136
- sql: string;
137
- parameters: never[];
138
- };
139
- };
140
- fn: {
141
- countAll: import("vitest").Mock<() => {
142
- as: import("vitest").Mock<() => {}>;
143
- }>;
144
- sum: import("vitest").Mock<() => {
145
- as: import("vitest").Mock<() => {}>;
146
- }>;
147
- avg: import("vitest").Mock<() => {
148
- as: import("vitest").Mock<() => {}>;
149
- }>;
150
- max: import("vitest").Mock<() => {
151
- as: import("vitest").Mock<() => {}>;
152
- }>;
153
- min: import("vitest").Mock<() => {
154
- as: import("vitest").Mock<() => {}>;
155
- }>;
156
- };
157
- };
158
- };
120
+ MockKysely: typeof MockKysely;
159
121
  mockExecuteTakeFirst: import("vitest").Mock<(...args: any[]) => any>;
160
122
  mockExecute: import("vitest").Mock<(...args: any[]) => any>;
161
123
  mockSqlExecute: import("vitest").Mock<(...args: any[]) => any>;
@@ -183,60 +145,7 @@ export declare const apiDbMocks: {
183
145
  * Pre-configured mock for database operations in lib functions
184
146
  */
185
147
  export declare const libDbMocks: {
186
- MockKysely: {
187
- new (): {
188
- selectFrom(): /*elided*/ any;
189
- where(): /*elided*/ any;
190
- selectAll(): /*elided*/ any;
191
- select(...args: any[]): /*elided*/ any;
192
- orderBy(): /*elided*/ any;
193
- limit(): /*elided*/ any;
194
- groupBy(): /*elided*/ any;
195
- having(): /*elided*/ any;
196
- leftJoin(): /*elided*/ any;
197
- innerJoin(): /*elided*/ any;
198
- insertInto(): /*elided*/ any;
199
- values(): /*elided*/ any;
200
- returningAll(): /*elided*/ any;
201
- updateTable(): /*elided*/ any;
202
- set(): /*elided*/ any;
203
- deleteFrom(): /*elided*/ any;
204
- with(): /*elided*/ any;
205
- transaction(): {
206
- execute: (callback: any) => Promise<any>;
207
- };
208
- executeTakeFirst(): any;
209
- executeTakeFirstOrThrow(): any;
210
- execute(): any;
211
- getExecutor(): {
212
- executeQuery: (query: any) => any;
213
- provideConnection: (callback: any) => Promise<any>;
214
- releaseConnection: () => void;
215
- transformQuery: (query: any, transformer: any) => any;
216
- compileQuery: (query: any, ctx: any) => {
217
- sql: string;
218
- parameters: never[];
219
- };
220
- };
221
- fn: {
222
- countAll: import("vitest").Mock<() => {
223
- as: import("vitest").Mock<() => {}>;
224
- }>;
225
- sum: import("vitest").Mock<() => {
226
- as: import("vitest").Mock<() => {}>;
227
- }>;
228
- avg: import("vitest").Mock<() => {
229
- as: import("vitest").Mock<() => {}>;
230
- }>;
231
- max: import("vitest").Mock<() => {
232
- as: import("vitest").Mock<() => {}>;
233
- }>;
234
- min: import("vitest").Mock<() => {
235
- as: import("vitest").Mock<() => {}>;
236
- }>;
237
- };
238
- };
239
- };
148
+ MockKysely: typeof MockKysely;
240
149
  mockExecuteTakeFirst: import("vitest").Mock<(...args: any[]) => any>;
241
150
  mockExecute: import("vitest").Mock<(...args: any[]) => any>;
242
151
  mockSqlExecute: import("vitest").Mock<(...args: any[]) => any>;
@@ -1 +1 @@
1
- {"version":3,"file":"kysely-mocks.d.ts","sourceRoot":"","sources":["../../src/test-utils/kysely-mocks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;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AM,UAAU;;;;;;;;yCA/DF,GAAG;;;IAapB;;;OAGG;;IAqBH;;OAEG;;IASH;;OAEG;;CAaqC,CAAA;AAE5C;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;yCApEF,GAAG;;;IAapB;;;OAGG;;IAqBH;;OAEG;;IASH;;OAEG;;CAkBqC,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY;;;;;;;;;;;;;;;;;;;;;;;EAyB3B"}
@@ -4,6 +4,72 @@
4
4
  * "Y todo lo que hagáis, hacedlo de corazón, como para el Señor y no para los hombres" (Colosenses 3:23)
5
5
  */
6
6
  import { vi } from 'vitest';
7
+ /**
8
+ * Mock Kysely class for use in vi.mock() factories and direct instantiation.
9
+ *
10
+ * ```typescript
11
+ * import { MockKysely } from '@pasosdejesus/m/test-utils/kysely-mocks'
12
+ * vi.mock('kysely', () => ({ Kysely: MockKysely }))
13
+ * ```
14
+ */
15
+ export class MockKysely {
16
+ _executeTakeFirst;
17
+ _execute;
18
+ _sqlExecute;
19
+ constructor(options) {
20
+ this._executeTakeFirst = options?.executeTakeFirst ?? (() => undefined);
21
+ this._execute = options?.execute ?? (() => undefined);
22
+ this._sqlExecute = options?.sqlExecute ?? (() => ({ rows: [] }));
23
+ }
24
+ selectFrom() { return this; }
25
+ where() { return this; }
26
+ selectAll() { return this; }
27
+ select(...args) { return this; }
28
+ orderBy() { return this; }
29
+ limit() { return this; }
30
+ groupBy() { return this; }
31
+ having() { return this; }
32
+ leftJoin() { return this; }
33
+ innerJoin() { return this; }
34
+ insertInto() { return this; }
35
+ values() { return this; }
36
+ returningAll() { return this; }
37
+ updateTable() { return this; }
38
+ set() { return this; }
39
+ deleteFrom() { return this; }
40
+ with() { return this; }
41
+ transaction() {
42
+ return {
43
+ execute: async (callback) => {
44
+ const mockTrx = new MockKysely({
45
+ executeTakeFirst: this._executeTakeFirst,
46
+ execute: this._execute,
47
+ sqlExecute: this._sqlExecute,
48
+ });
49
+ return callback(mockTrx);
50
+ }
51
+ };
52
+ }
53
+ executeTakeFirst() { return this._executeTakeFirst(); }
54
+ executeTakeFirstOrThrow() { return this._executeTakeFirst(); }
55
+ execute() { return this._execute(); }
56
+ getExecutor() {
57
+ return {
58
+ executeQuery: (query) => this._sqlExecute(query),
59
+ provideConnection: async (callback) => callback({}),
60
+ releaseConnection: () => { },
61
+ transformQuery: (query, transformer) => query,
62
+ compileQuery: (query, ctx) => ({ sql: '', parameters: [] }),
63
+ };
64
+ }
65
+ fn = {
66
+ countAll: vi.fn(() => ({ as: vi.fn(() => ({})) })),
67
+ sum: vi.fn(() => ({ as: vi.fn(() => ({})) })),
68
+ avg: vi.fn(() => ({ as: vi.fn(() => ({})) })),
69
+ max: vi.fn(() => ({ as: vi.fn(() => ({})) })),
70
+ min: vi.fn(() => ({ as: vi.fn(() => ({})) })),
71
+ };
72
+ }
7
73
  /**
8
74
  * Creates a mock Kysely instance with configurable behavior
9
75
  *
@@ -25,52 +91,6 @@ export function createMockKysely(options = {}) {
25
91
  if (opts.sqlExecute !== undefined) {
26
92
  mockSqlExecute.mockImplementation(options.sqlExecute);
27
93
  }
28
- class MockKysely {
29
- selectFrom() { return this; }
30
- where() { return this; }
31
- selectAll() { return this; }
32
- select(...args) { return this; }
33
- orderBy() { return this; }
34
- limit() { return this; }
35
- groupBy() { return this; }
36
- having() { return this; }
37
- leftJoin() { return this; }
38
- innerJoin() { return this; }
39
- insertInto() { return this; }
40
- values() { return this; }
41
- returningAll() { return this; }
42
- updateTable() { return this; }
43
- set() { return this; }
44
- deleteFrom() { return this; }
45
- with() { return this; }
46
- transaction() {
47
- return {
48
- execute: async (callback) => {
49
- const mockTrx = new MockKysely();
50
- return callback(mockTrx);
51
- }
52
- };
53
- }
54
- executeTakeFirst() { return mockExecuteTakeFirst(); }
55
- executeTakeFirstOrThrow() { return mockExecuteTakeFirst(); }
56
- execute() { return mockExecute(); }
57
- getExecutor() {
58
- return {
59
- executeQuery: (query) => mockSqlExecute(query),
60
- provideConnection: async (callback) => callback({}),
61
- releaseConnection: () => { },
62
- transformQuery: (query, transformer) => query,
63
- compileQuery: (query, ctx) => ({ sql: '', parameters: [] }),
64
- };
65
- }
66
- fn = {
67
- countAll: vi.fn(() => ({ as: vi.fn(() => ({})) })),
68
- sum: vi.fn(() => ({ as: vi.fn(() => ({})) })),
69
- avg: vi.fn(() => ({ as: vi.fn(() => ({})) })),
70
- max: vi.fn(() => ({ as: vi.fn(() => ({})) })),
71
- min: vi.fn(() => ({ as: vi.fn(() => ({})) })),
72
- };
73
- }
74
94
  const mockSql = vi.fn(() => ({
75
95
  as: vi.fn().mockReturnValue({}),
76
96
  execute: mockSqlExecute,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pasosdejesus/m",
3
- "version": "0.15.0",
3
+ "version": "0.16.1",
4
4
  "description": "Motor para crear y gestionar proyectos al estilo Pasos de Jesus.",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -125,8 +125,8 @@
125
125
  "picocolors": "^1.1.1"
126
126
  },
127
127
  "optionalDependencies": {
128
- "@pasosdejesus/edr": "0.1.0",
129
- "@pasosdejesus/contract-test": "0.1.0"
128
+ "@pasosdejesus/edr": "0.1.1",
129
+ "@pasosdejesus/contract-test": "0.1.1"
130
130
  },
131
131
  "devDependencies": {
132
132
  "@radix-ui/react-accordion": "^1.2.12",