@movebridge/testing 0.1.0 → 0.2.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.
package/dist/index.d.mts CHANGED
@@ -280,8 +280,7 @@ declare const PREDEFINED_SCHEMAS: {
280
280
  payload: {
281
281
  function: string;
282
282
  typeArguments: string[];
283
- arguments: unknown[];
284
- type: "entry_function_payload";
283
+ functionArguments: unknown[];
285
284
  };
286
285
  hash: string;
287
286
  sender: string;
@@ -294,13 +293,11 @@ declare const PREDEFINED_SCHEMAS: {
294
293
  payload: Struct<{
295
294
  function: string;
296
295
  typeArguments: string[];
297
- arguments: unknown[];
298
- type: "entry_function_payload";
296
+ functionArguments: unknown[];
299
297
  }, {
300
- type: Struct<"entry_function_payload", "entry_function_payload">;
301
298
  function: Struct<string, null>;
302
299
  typeArguments: Struct<string[], Struct<string, null>>;
303
- arguments: Struct<unknown[], Struct<unknown, null>>;
300
+ functionArguments: Struct<unknown[], Struct<unknown, null>>;
304
301
  }>;
305
302
  timestamp: Struct<string, null>;
306
303
  }>;
package/dist/index.d.ts CHANGED
@@ -280,8 +280,7 @@ declare const PREDEFINED_SCHEMAS: {
280
280
  payload: {
281
281
  function: string;
282
282
  typeArguments: string[];
283
- arguments: unknown[];
284
- type: "entry_function_payload";
283
+ functionArguments: unknown[];
285
284
  };
286
285
  hash: string;
287
286
  sender: string;
@@ -294,13 +293,11 @@ declare const PREDEFINED_SCHEMAS: {
294
293
  payload: Struct<{
295
294
  function: string;
296
295
  typeArguments: string[];
297
- arguments: unknown[];
298
- type: "entry_function_payload";
296
+ functionArguments: unknown[];
299
297
  }, {
300
- type: Struct<"entry_function_payload", "entry_function_payload">;
301
298
  function: Struct<string, null>;
302
299
  typeArguments: Struct<string[], Struct<string, null>>;
303
- arguments: Struct<unknown[], Struct<unknown, null>>;
300
+ functionArguments: Struct<unknown[], Struct<unknown, null>>;
304
301
  }>;
305
302
  timestamp: Struct<string, null>;
306
303
  }>;
package/dist/index.js CHANGED
@@ -109,10 +109,9 @@ function createFaker(options) {
109
109
  sender: `0x${randomHex(64)}`,
110
110
  sequenceNumber: randomSequenceNumber(),
111
111
  payload: {
112
- type: "entry_function_payload",
113
112
  function: `0x${randomHex(64)}::module::function`,
114
113
  typeArguments: [],
115
- arguments: []
114
+ functionArguments: []
116
115
  },
117
116
  timestamp: randomTimestamp()
118
117
  };
@@ -673,18 +672,41 @@ function validatePayload(payload) {
673
672
  { argument: "payload", value: payload }
674
673
  );
675
674
  }
676
- if (payload.type !== "entry_function_payload") {
675
+ if (!FUNCTION_REGEX.test(payload.function)) {
676
+ throw new import_core3.MovementError(
677
+ `Invalid function identifier: ${payload.function}`,
678
+ "INVALID_ARGUMENT",
679
+ {
680
+ argument: "function",
681
+ value: payload.function,
682
+ expectedFormat: "0xADDRESS::module::function"
683
+ }
684
+ );
685
+ }
686
+ if (!Array.isArray(payload.typeArguments)) {
687
+ throw new import_core3.MovementError(
688
+ "typeArguments must be an array",
689
+ "INVALID_ARGUMENT",
690
+ { argument: "typeArguments", value: payload.typeArguments }
691
+ );
692
+ }
693
+ for (let i = 0; i < payload.typeArguments.length; i++) {
694
+ if (typeof payload.typeArguments[i] !== "string") {
695
+ throw new import_core3.MovementError(
696
+ `typeArguments[${i}] must be a string`,
697
+ "INVALID_ARGUMENT",
698
+ { argument: `typeArguments[${i}]`, value: payload.typeArguments[i] }
699
+ );
700
+ }
701
+ }
702
+ if (!Array.isArray(payload.functionArguments)) {
677
703
  throw new import_core3.MovementError(
678
- `Unsupported payload type: ${payload.type}`,
704
+ "functionArguments must be an array",
679
705
  "INVALID_ARGUMENT",
680
- { argument: "type", value: payload.type, supported: ["entry_function_payload"] }
706
+ { argument: "functionArguments", value: payload.functionArguments }
681
707
  );
682
708
  }
683
- return validateEntryFunctionPayload({
684
- function: payload.function,
685
- typeArguments: payload.typeArguments,
686
- arguments: payload.arguments
687
- });
709
+ return true;
688
710
  }
689
711
  function validateAmount(amount) {
690
712
  if (typeof amount !== "string") {
@@ -738,10 +760,9 @@ var PREDEFINED_SCHEMAS = {
738
760
  sender: (0, import_superstruct.string)(),
739
761
  sequenceNumber: (0, import_superstruct.string)(),
740
762
  payload: (0, import_superstruct.object)({
741
- type: (0, import_superstruct.literal)("entry_function_payload"),
742
763
  function: (0, import_superstruct.string)(),
743
764
  typeArguments: (0, import_superstruct.array)((0, import_superstruct.string)()),
744
- arguments: (0, import_superstruct.array)((0, import_superstruct.unknown)())
765
+ functionArguments: (0, import_superstruct.array)((0, import_superstruct.unknown)())
745
766
  }),
746
767
  timestamp: (0, import_superstruct.string)()
747
768
  }),
package/dist/index.mjs CHANGED
@@ -65,10 +65,9 @@ function createFaker(options) {
65
65
  sender: `0x${randomHex(64)}`,
66
66
  sequenceNumber: randomSequenceNumber(),
67
67
  payload: {
68
- type: "entry_function_payload",
69
68
  function: `0x${randomHex(64)}::module::function`,
70
69
  typeArguments: [],
71
- arguments: []
70
+ functionArguments: []
72
71
  },
73
72
  timestamp: randomTimestamp()
74
73
  };
@@ -629,18 +628,41 @@ function validatePayload(payload) {
629
628
  { argument: "payload", value: payload }
630
629
  );
631
630
  }
632
- if (payload.type !== "entry_function_payload") {
631
+ if (!FUNCTION_REGEX.test(payload.function)) {
632
+ throw new MovementError3(
633
+ `Invalid function identifier: ${payload.function}`,
634
+ "INVALID_ARGUMENT",
635
+ {
636
+ argument: "function",
637
+ value: payload.function,
638
+ expectedFormat: "0xADDRESS::module::function"
639
+ }
640
+ );
641
+ }
642
+ if (!Array.isArray(payload.typeArguments)) {
643
+ throw new MovementError3(
644
+ "typeArguments must be an array",
645
+ "INVALID_ARGUMENT",
646
+ { argument: "typeArguments", value: payload.typeArguments }
647
+ );
648
+ }
649
+ for (let i = 0; i < payload.typeArguments.length; i++) {
650
+ if (typeof payload.typeArguments[i] !== "string") {
651
+ throw new MovementError3(
652
+ `typeArguments[${i}] must be a string`,
653
+ "INVALID_ARGUMENT",
654
+ { argument: `typeArguments[${i}]`, value: payload.typeArguments[i] }
655
+ );
656
+ }
657
+ }
658
+ if (!Array.isArray(payload.functionArguments)) {
633
659
  throw new MovementError3(
634
- `Unsupported payload type: ${payload.type}`,
660
+ "functionArguments must be an array",
635
661
  "INVALID_ARGUMENT",
636
- { argument: "type", value: payload.type, supported: ["entry_function_payload"] }
662
+ { argument: "functionArguments", value: payload.functionArguments }
637
663
  );
638
664
  }
639
- return validateEntryFunctionPayload({
640
- function: payload.function,
641
- typeArguments: payload.typeArguments,
642
- arguments: payload.arguments
643
- });
665
+ return true;
644
666
  }
645
667
  function validateAmount(amount) {
646
668
  if (typeof amount !== "string") {
@@ -689,7 +711,6 @@ import {
689
711
  array,
690
712
  record,
691
713
  unknown,
692
- literal,
693
714
  nullable,
694
715
  validate
695
716
  } from "superstruct";
@@ -704,10 +725,9 @@ var PREDEFINED_SCHEMAS = {
704
725
  sender: string(),
705
726
  sequenceNumber: string(),
706
727
  payload: object({
707
- type: literal("entry_function_payload"),
708
728
  function: string(),
709
729
  typeArguments: array(string()),
710
- arguments: array(unknown())
730
+ functionArguments: array(unknown())
711
731
  }),
712
732
  timestamp: string()
713
733
  }),
package/package.json CHANGED
@@ -1,60 +1,60 @@
1
1
  {
2
- "name": "@movebridge/testing",
3
- "version": "0.1.0",
4
- "description": "Testing utilities for MoveBridge SDK - mocks, validators, fakers, and test harness",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
2
+ "name": "@movebridge/testing",
3
+ "version": "0.2.1",
4
+ "description": "Testing utilities for MoveBridge SDK - mocks, validators, fakers, and test harness",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
20
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
21
+ "clean": "rm -rf dist",
22
+ "typecheck": "tsc --noEmit",
23
+ "test": "vitest run",
24
+ "test:watch": "vitest",
25
+ "test:coverage": "vitest run --coverage",
26
+ "test:properties": "vitest run --testNamePattern='Property'"
27
+ },
28
+ "dependencies": {
29
+ "@movebridge/core": "workspace:*",
30
+ "superstruct": "^1.0.3"
31
+ },
32
+ "devDependencies": {
33
+ "fast-check": "^3.14.0",
34
+ "tsup": "^8.0.1",
35
+ "typescript": "^5.3.2"
36
+ },
37
+ "peerDependencies": {
38
+ "@movebridge/core": ">=0.1.0"
39
+ },
40
+ "keywords": [
41
+ "movement",
42
+ "aptos",
43
+ "blockchain",
44
+ "testing",
45
+ "mock",
46
+ "validator",
47
+ "sdk"
48
+ ],
49
+ "author": "Aqila Rifti",
50
+ "license": "MIT",
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "https://github.com/AqilaRifti/MoveBridge",
54
+ "directory": "packages/testing"
55
+ },
56
+ "homepage": "https://github.com/AqilaRifti/MoveBridge#readme",
57
+ "bugs": {
58
+ "url": "https://github.com/AqilaRifti/MoveBridge/issues"
13
59
  }
14
- },
15
- "files": [
16
- "dist"
17
- ],
18
- "dependencies": {
19
- "superstruct": "^1.0.3",
20
- "@movebridge/core": "0.1.0"
21
- },
22
- "devDependencies": {
23
- "fast-check": "^3.14.0",
24
- "tsup": "^8.0.1",
25
- "typescript": "^5.3.2"
26
- },
27
- "peerDependencies": {
28
- "@movebridge/core": ">=0.1.0"
29
- },
30
- "keywords": [
31
- "movement",
32
- "aptos",
33
- "blockchain",
34
- "testing",
35
- "mock",
36
- "validator",
37
- "sdk"
38
- ],
39
- "author": "Aqila Rifti",
40
- "license": "MIT",
41
- "repository": {
42
- "type": "git",
43
- "url": "https://github.com/AqilaRifti/MoveBridge",
44
- "directory": "packages/testing"
45
- },
46
- "homepage": "https://github.com/AqilaRifti/MoveBridge#readme",
47
- "bugs": {
48
- "url": "https://github.com/AqilaRifti/MoveBridge/issues"
49
- },
50
- "scripts": {
51
- "build": "tsup src/index.ts --format cjs,esm --dts --clean",
52
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
53
- "clean": "rm -rf dist",
54
- "typecheck": "tsc --noEmit",
55
- "test": "vitest run",
56
- "test:watch": "vitest",
57
- "test:coverage": "vitest run --coverage",
58
- "test:properties": "vitest run --testNamePattern='Property'"
59
- }
60
60
  }
package/LICENSE DELETED
File without changes