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
28 changes: 23 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist*
yarn-error.log
package-lock.json
.idea
build
dist
dist-ssr
*.local

examples/**/*.wasm
examples/**/*.abi

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
6 changes: 6 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extension": ["ts"],
"require": "ts-node/register",
"node-option": ["no-experimental-strip-types"],
"spec": "./src/**/*.spec.ts"
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pbatmetal Should we change copyright here?

Copyright (c) 2021 Jeeyong "conr2d" Um

The MIT License
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@ The focus of VeRT is on the better compatibility than the performance, so it can
npm install @proton/vert
```

## Test
## Development

- nodejs v16 or higher

```shell
npm run test
pnpm install
```

- nodejs v14
## Test

```shell
node --experimental-wasm-bigint node_modules/mocha/bin/_mocha src/**/*.spec.ts -r ts-node/register
pnpm run test
```

## License
Expand Down
27 changes: 0 additions & 27 deletions bundle.js

This file was deleted.

1 change: 1 addition & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'rustbn.js'
21 changes: 21 additions & 0 deletions esbuild.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import esbuild from 'esbuild';

// Create the esbuild build configuration
esbuild.build({
entryPoints: ['dist/index.js'], // Main entry point (change as needed)
bundle: true, // Enable bundling
format: 'esm',
outfile: 'dist/bundle.js', // Output file
sourcemap: true, // Generate sourcemaps
minify: true, // Minify the output for production
external: [], // Exclude specific modules from being bundled (e.g., node_modules)
platform: 'node', //node
sourcemap: true,
define: {
global: 'global',
process: 'process',
Buffer: 'Buffer'
},
// format: 'iife',
globalName: 'Vert'
}).catch(() => process.exit(1)); // Exit on error
29 changes: 29 additions & 0 deletions eslint.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";
import json from "@eslint/json";
import { defineConfig } from "eslint/config";

export default defineConfig([
{ files: ["**/*.{js,mjs,cjs,ts,mts,cts}"], plugins: { js }, extends: ["js/recommended"], languageOptions: { globals: globals.node } },
tseslint.configs.recommended,
{ files: ["**/*.json"], plugins: { json }, language: "json/json", extends: ["json/recommended"] },
{ files: ["**/*.jsonc"], plugins: { json }, language: "json/jsonc", extends: ["json/recommended"] },
{
rules: {
"@typescript-eslint/no-explicit-any": "warn",
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
}
}
]);
7 changes: 7 additions & 0 deletions examples/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extension": ["js", "ts"],
"require": ["./register-loader.js", "ts-node/register"],
"node-option": [
"experimental-specifier-resolution=node"
]
}
11 changes: 8 additions & 3 deletions examples/fixtures/fixtures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ import fs from "fs";
import path from "path";
import { expect } from "chai";
import { Name } from "@greymass/eosio"
import { Blockchain, nameToBigInt } from "../../dist";
import { Blockchain, nameToBigInt } from "@proton/vert";

import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const blockchain = new Blockchain()

const contractName = Name.from('test')
const fixtures = blockchain.createAccount({
name: contractName,
wasm: fs.readFileSync(path.join(__dirname, '/fixtures.wasm')),
abi: fs.readFileSync(path.join(__dirname, '/fixtures.abi'), 'utf8')
wasm: fs.readFileSync(path.join(__dirname, 'fixtures.wasm')),
abi: fs.readFileSync(path.join(__dirname, 'fixtures.abi'), 'utf8')
});

interface Row {
Expand Down
15 changes: 10 additions & 5 deletions examples/foo/foo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ import fs from "fs";
import path from "path";
import { expect } from "chai";
import { Name, Int64 } from "@greymass/eosio"
import { Blockchain, nameToBigInt, protonAssert } from "../../dist";
import { Blockchain, nameToBigInt, protonAssert } from "@proton/vert";

import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const blockchain = new Blockchain()

const testName = Name.from('test')
const foo = blockchain.createAccount({
name: testName,
wasm: fs.readFileSync(path.join(__dirname, '/foo.wasm')),
abi: fs.readFileSync(path.join(__dirname, '/foo.abi'), 'utf8')
wasm: fs.readFileSync(path.join(__dirname, 'foo.wasm')),
abi: fs.readFileSync(path.join(__dirname, 'foo.abi'), 'utf8')
});
blockchain.createAccount('alice')
blockchain.createAccount('bob')
Expand All @@ -25,7 +30,7 @@ describe('foo_test', () => {
// try storing value with the wrong permission
await foo.actions.store(['alice', 1]).send('bob@active');
} catch (e) {
expect(e.message).to.equal('missing required authority alice');
expect((e as Error).message).to.equal('missing required authority alice');
}
});

Expand All @@ -34,7 +39,7 @@ describe('foo_test', () => {
// try storing a negative value
await foo.actions.store(['alice', -1]).send('alice@active');
} catch (e) {
expect(e.message).to.equal(protonAssert('require non-negative value'));
expect((e as Error).message).to.equal(protonAssert('require non-negative value'));
}
});

Expand Down
11 changes: 8 additions & 3 deletions examples/inline/inline.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import fs from "fs";
import path from "path";
import { expect } from "chai";
import { Blockchain } from "../../dist";
import { Name, PermissionLevel, Serializer, Transaction, UInt64 } from "@greymass/eosio"
import { Account, Blockchain } from "@proton/vert";
import { Name, PermissionLevel, Serializer, Transaction } from "@greymass/eosio"

import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const blockchain = new Blockchain()

Expand All @@ -13,7 +18,7 @@ const strToAccount = (str: string) => blockchain.createAccount({
enableInline: true
})

const accounts = {}
const accounts: Record<string, Account> = {}
const accountz = ['r1', 'r2', 'i11', 'i14', 'i21', 'i112', 'i121', 'i131', 'i141', 'i1211', 'i1222', 'n12', 'n13', 'n22', 'n111', 'n122', 'n132', 'n142', 'n1212', 'n1221']

for (const account of accountz) {
Expand Down
18 changes: 10 additions & 8 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
{
"private": true,
"name": "test",
"name": "examples",
"version": "1.0.0",
"description": "",
"type": "module",
"scripts": {
"build:inline": "blanc++ ./inline/notified1.cpp -o ./inline/notified1.wasm && blanc++ ./inline/notified2.cpp -o ./inline/notified2.wasm && blanc++ ./inline/notified3.cpp -o ./inline/notified3.wasm && blanc++ ./inline/notified4.cpp -o ./inline/notified4.wasm && blanc++ ./inline/receiver.cpp -o ./inline/receiver.wasm && blanc++ ./inline/sender.cpp -o ./inline/sender.wasm",
"build:foo": "blanc++ ./foo/foo.cpp -o ./foo/foo.wasm",
"build:timer": "blanc++ ./timer/timer.cpp -o ./timer/timer.wasm",
"build:fixtures": "blanc++ ./fixtures/fixtures.cpp -o ./fixtures/fixtures.wasm",
"build": "run-p build:*",
"test:foo": "mocha ./foo/foo.spec.ts -r ts-node/register",
"test:foo": "mocha ./foo/foo.spec.ts",
"test:inline": "mocha ./inline/inline.spec.ts -r ts-node/register",
"test:timer": "mocha ./timer/timer.spec.ts -r ts-node/register",
"test:fixtures": "mocha ./fixtures/fixtures.spec.ts -r ts-node/register",
"test:fixtures": "mocha ./fixtures/fixtures.spec.ts",
"test": "run-p test:*"
},
"author": "Jeeyong Um <[email protected]>",
"license": "MIT",
"devDependencies": {
"@proton/vert": "workspace:^",
"@types/mocha": "^10.0.10",
"chai": "^6.2.2",
"mocha": "^11.7.6",
"npm-run-all": "^4.1.5",
"@haderech/vert": "*",
"chai": "*",
"mocha": "*",
"ts-node": "*",
"typescript": "*"
"ts-node": "^10.9.2",
"typescript": "~6.0.3"
}
}
Loading