@guardian-network/policy-intermediate-representation 0.3.2

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.
Files changed (137) hide show
  1. package/README.md +36 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +8 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/ir-notation/errors/ErrorFactory.d.ts +7 -0
  7. package/dist/ir-notation/errors/ErrorFactory.d.ts.map +1 -0
  8. package/dist/ir-notation/errors/ErrorFactory.js +17 -0
  9. package/dist/ir-notation/errors/ErrorFactory.js.map +1 -0
  10. package/dist/ir-notation/errors/index.d.ts +2 -0
  11. package/dist/ir-notation/errors/index.d.ts.map +1 -0
  12. package/dist/ir-notation/errors/index.js +18 -0
  13. package/dist/ir-notation/errors/index.js.map +1 -0
  14. package/dist/ir-notation/errors/validation-errors.d.ts +11 -0
  15. package/dist/ir-notation/errors/validation-errors.d.ts.map +1 -0
  16. package/dist/ir-notation/errors/validation-errors.js +26 -0
  17. package/dist/ir-notation/errors/validation-errors.js.map +1 -0
  18. package/dist/ir-notation/helpers/formatters.d.ts +18 -0
  19. package/dist/ir-notation/helpers/formatters.d.ts.map +1 -0
  20. package/dist/ir-notation/helpers/formatters.js +45 -0
  21. package/dist/ir-notation/helpers/formatters.js.map +1 -0
  22. package/dist/ir-notation/helpers/index.d.ts +5 -0
  23. package/dist/ir-notation/helpers/index.d.ts.map +1 -0
  24. package/dist/ir-notation/helpers/index.js +21 -0
  25. package/dist/ir-notation/helpers/index.js.map +1 -0
  26. package/dist/ir-notation/helpers/matchers.d.ts +4 -0
  27. package/dist/ir-notation/helpers/matchers.d.ts.map +1 -0
  28. package/dist/ir-notation/helpers/matchers.js +17 -0
  29. package/dist/ir-notation/helpers/matchers.js.map +1 -0
  30. package/dist/ir-notation/helpers/morphs.d.ts +4 -0
  31. package/dist/ir-notation/helpers/morphs.d.ts.map +1 -0
  32. package/dist/ir-notation/helpers/morphs.js +26 -0
  33. package/dist/ir-notation/helpers/morphs.js.map +1 -0
  34. package/dist/ir-notation/helpers/validation/index.d.ts +2 -0
  35. package/dist/ir-notation/helpers/validation/index.d.ts.map +1 -0
  36. package/dist/ir-notation/helpers/validation/index.js +18 -0
  37. package/dist/ir-notation/helpers/validation/index.js.map +1 -0
  38. package/dist/ir-notation/helpers/validation/typing.validation.d.ts +10 -0
  39. package/dist/ir-notation/helpers/validation/typing.validation.d.ts.map +1 -0
  40. package/dist/ir-notation/helpers/validation/typing.validation.js +41 -0
  41. package/dist/ir-notation/helpers/validation/typing.validation.js.map +1 -0
  42. package/dist/ir-notation/parser/index.d.ts +4 -0
  43. package/dist/ir-notation/parser/index.d.ts.map +1 -0
  44. package/dist/ir-notation/parser/index.js +14 -0
  45. package/dist/ir-notation/parser/index.js.map +1 -0
  46. package/dist/ir-notation/parser/parser-contracts/ParserWithValidation.d.ts +14 -0
  47. package/dist/ir-notation/parser/parser-contracts/ParserWithValidation.d.ts.map +1 -0
  48. package/dist/ir-notation/parser/parser-contracts/ParserWithValidation.js +44 -0
  49. package/dist/ir-notation/parser/parser-contracts/ParserWithValidation.js.map +1 -0
  50. package/dist/ir-notation/parser/parser-contracts/SimplifiedParser.d.ts +12 -0
  51. package/dist/ir-notation/parser/parser-contracts/SimplifiedParser.d.ts.map +1 -0
  52. package/dist/ir-notation/parser/parser-contracts/SimplifiedParser.js +27 -0
  53. package/dist/ir-notation/parser/parser-contracts/SimplifiedParser.js.map +1 -0
  54. package/dist/ir-notation/parser/parser-contracts/StaticParser.d.ts +7 -0
  55. package/dist/ir-notation/parser/parser-contracts/StaticParser.d.ts.map +1 -0
  56. package/dist/ir-notation/parser/parser-contracts/StaticParser.js +16 -0
  57. package/dist/ir-notation/parser/parser-contracts/StaticParser.js.map +1 -0
  58. package/dist/ir-notation/parser/parser-contracts/base/ParserBase.d.ts +7 -0
  59. package/dist/ir-notation/parser/parser-contracts/base/ParserBase.d.ts.map +1 -0
  60. package/dist/ir-notation/parser/parser-contracts/base/ParserBase.js +40 -0
  61. package/dist/ir-notation/parser/parser-contracts/base/ParserBase.js.map +1 -0
  62. package/dist/ir-notation/parser/parser-contracts/guards.d.ts +5 -0
  63. package/dist/ir-notation/parser/parser-contracts/guards.d.ts.map +1 -0
  64. package/dist/ir-notation/parser/parser-contracts/guards.js +14 -0
  65. package/dist/ir-notation/parser/parser-contracts/guards.js.map +1 -0
  66. package/dist/ir-notation/parser/parser-contracts/index.d.ts +5 -0
  67. package/dist/ir-notation/parser/parser-contracts/index.d.ts.map +1 -0
  68. package/dist/ir-notation/parser/parser-contracts/index.js +13 -0
  69. package/dist/ir-notation/parser/parser-contracts/index.js.map +1 -0
  70. package/dist/ir-notation/parser/parser-contracts/tools/ParamsExtractor.d.ts +19 -0
  71. package/dist/ir-notation/parser/parser-contracts/tools/ParamsExtractor.d.ts.map +1 -0
  72. package/dist/ir-notation/parser/parser-contracts/tools/ParamsExtractor.js +140 -0
  73. package/dist/ir-notation/parser/parser-contracts/tools/ParamsExtractor.js.map +1 -0
  74. package/dist/ir-notation/parser/parser-contracts/tools/TypesNormalizer.d.ts +7 -0
  75. package/dist/ir-notation/parser/parser-contracts/tools/TypesNormalizer.d.ts.map +1 -0
  76. package/dist/ir-notation/parser/parser-contracts/tools/TypesNormalizer.js +49 -0
  77. package/dist/ir-notation/parser/parser-contracts/tools/TypesNormalizer.js.map +1 -0
  78. package/dist/ir-notation/parser/parser-contracts/tools/index.d.ts +6 -0
  79. package/dist/ir-notation/parser/parser-contracts/tools/index.d.ts.map +1 -0
  80. package/dist/ir-notation/parser/parser-contracts/tools/index.js +25 -0
  81. package/dist/ir-notation/parser/parser-contracts/tools/index.js.map +1 -0
  82. package/dist/ir-notation/parser/parser-contracts/tools/tools.helper.d.ts +5 -0
  83. package/dist/ir-notation/parser/parser-contracts/tools/tools.helper.d.ts.map +1 -0
  84. package/dist/ir-notation/parser/parser-contracts/tools/tools.helper.js +26 -0
  85. package/dist/ir-notation/parser/parser-contracts/tools/tools.helper.js.map +1 -0
  86. package/dist/ir-notation/parser/parser-contracts/tools/types-source/DSLConfigArgsTypesSource.d.ts +10 -0
  87. package/dist/ir-notation/parser/parser-contracts/tools/types-source/DSLConfigArgsTypesSource.d.ts.map +1 -0
  88. package/dist/ir-notation/parser/parser-contracts/tools/types-source/DSLConfigArgsTypesSource.js +36 -0
  89. package/dist/ir-notation/parser/parser-contracts/tools/types-source/DSLConfigArgsTypesSource.js.map +1 -0
  90. package/dist/ir-notation/parser/parser-contracts/tools/types-source/OnchainDescriptorArgsTypesSource.d.ts +12 -0
  91. package/dist/ir-notation/parser/parser-contracts/tools/types-source/OnchainDescriptorArgsTypesSource.d.ts.map +1 -0
  92. package/dist/ir-notation/parser/parser-contracts/tools/types-source/OnchainDescriptorArgsTypesSource.js +39 -0
  93. package/dist/ir-notation/parser/parser-contracts/tools/types-source/OnchainDescriptorArgsTypesSource.js.map +1 -0
  94. package/dist/ir-notation/parser/parser-contracts/types.d.ts +59 -0
  95. package/dist/ir-notation/parser/parser-contracts/types.d.ts.map +1 -0
  96. package/dist/ir-notation/parser/parser-contracts/types.js +12 -0
  97. package/dist/ir-notation/parser/parser-contracts/types.js.map +1 -0
  98. package/dist/ir-notation/parser/parser.unvalidated.d.ts +6 -0
  99. package/dist/ir-notation/parser/parser.unvalidated.d.ts.map +1 -0
  100. package/dist/ir-notation/parser/parser.unvalidated.js +92 -0
  101. package/dist/ir-notation/parser/parser.unvalidated.js.map +1 -0
  102. package/dist/ir-notation/parser/parser.validated.d.ts +17 -0
  103. package/dist/ir-notation/parser/parser.validated.d.ts.map +1 -0
  104. package/dist/ir-notation/parser/parser.validated.js +37 -0
  105. package/dist/ir-notation/parser/parser.validated.js.map +1 -0
  106. package/dist/ir-notation/parser/types.d.ts +9 -0
  107. package/dist/ir-notation/parser/types.d.ts.map +1 -0
  108. package/dist/ir-notation/parser/types.js +11 -0
  109. package/dist/ir-notation/parser/types.js.map +1 -0
  110. package/package.json +71 -0
  111. package/src/index.ts +5 -0
  112. package/src/ir-notation/errors/ErrorFactory.ts +25 -0
  113. package/src/ir-notation/errors/index.ts +1 -0
  114. package/src/ir-notation/errors/validation-errors.ts +38 -0
  115. package/src/ir-notation/helpers/formatters.ts +63 -0
  116. package/src/ir-notation/helpers/index.ts +4 -0
  117. package/src/ir-notation/helpers/matchers.ts +12 -0
  118. package/src/ir-notation/helpers/morphs.ts +26 -0
  119. package/src/ir-notation/helpers/validation/index.ts +1 -0
  120. package/src/ir-notation/helpers/validation/typing.validation.ts +89 -0
  121. package/src/ir-notation/parser/index.ts +10 -0
  122. package/src/ir-notation/parser/parser-contracts/ParserWithValidation.ts +99 -0
  123. package/src/ir-notation/parser/parser-contracts/SimplifiedParser.ts +41 -0
  124. package/src/ir-notation/parser/parser-contracts/StaticParser.ts +25 -0
  125. package/src/ir-notation/parser/parser-contracts/base/ParserBase.ts +79 -0
  126. package/src/ir-notation/parser/parser-contracts/guards.ts +17 -0
  127. package/src/ir-notation/parser/parser-contracts/index.ts +7 -0
  128. package/src/ir-notation/parser/parser-contracts/tools/ParamsExtractor.ts +251 -0
  129. package/src/ir-notation/parser/parser-contracts/tools/TypesNormalizer.ts +78 -0
  130. package/src/ir-notation/parser/parser-contracts/tools/index.ts +5 -0
  131. package/src/ir-notation/parser/parser-contracts/tools/tools.helper.ts +33 -0
  132. package/src/ir-notation/parser/parser-contracts/tools/types-source/DSLConfigArgsTypesSource.ts +52 -0
  133. package/src/ir-notation/parser/parser-contracts/tools/types-source/OnchainDescriptorArgsTypesSource.ts +76 -0
  134. package/src/ir-notation/parser/parser-contracts/types.ts +78 -0
  135. package/src/ir-notation/parser/parser.unvalidated.ts +200 -0
  136. package/src/ir-notation/parser/parser.validated.ts +67 -0
  137. package/src/ir-notation/parser/types.ts +28 -0
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Policy definition IR translator
2
+ Intermediate representation (IR) is needed to create the layer of abstraction between high-level policy constructors and the code that represents the policy onchain.
3
+ IR can be perseived as an interface between human-readable code, GUI constructors - all sorts of tools convenient to humans, and object model of a policy that is used only by onchain code.
4
+ IR is not ment neither to be written by humans nor to be read or debugged by them. It's an unambigous notation for policy-constructing translator.
5
+
6
+ The notation consists of an instance definitions, each written in a new line.
7
+ The instance definition consists of three clauses, following each other, separated with spaces. Here they are:
8
+ 1. **Artifact clause** \
9
+ Defines an address of the target artifact of an instance. Denoted with curvy braces `{}` with a single value inside.
10
+ > `{0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48}`
11
+
12
+ 2. **Execution arguments clause** \
13
+ Declares all the needed data, passed to the artifact's `exec` method.
14
+ All arguments are enclosed into parenthesis `()` and divided with comma `,`. \
15
+ **Constants** are written as is - strings are doublequoted, bytes and addresses must have `0x` prefix. \
16
+ **Variables** are listed by names with mandatory prefix `var`. E.g. `var bool myValue` ↦ `varmyValue`. \
17
+ Also, postfix `$"<injection>"` is appended to all variables. If the variable is injected, injection attribute is pasted instead of `<injection>`. \
18
+ **Substitutions** are referenced by `nodeId` inside verical bars `||`.
19
+
20
+ > `(varMyNumber$"", varInjected$"my_attr", 1234, 0xe983fD1798689eee00c0Fb77e79B8f372DF41060, |0x0d68bc8fa0092f4020226d6cf49843553da6de839c908e4220723149ee39a11e|)`
21
+
22
+ 3. **Initialization arguments clause** \
23
+ Optional block. Declares all the needed data, passed to the artifact's `init` method. Can be empty or absent. \
24
+ All arguments are enclosed into parenthesis `<>` and divided with comma `,`. \
25
+ Arguments **must** be constants.
26
+ > `<1234, "init_me", true, 0x31621c02470F4e9e71428e209EfC97c07cdc64A3>`
27
+
28
+ Overall, valid IR looks like this:
29
+ ```
30
+ {0x6768008f6c2Ac94F9D65533D13A974b376495c7b} (1,"lang","here I am") <0,0xdeadbeef,true>
31
+ {0xB60B02062d1256A79C81A061a9277e84ffbB0Ff7} (|0x7ce384eae0aa9f573819ad8aaa6a4eec71d9079f031feee34d51343934131dfe|,0xD9e88d1d18d8Cf3a17e97af9F017Ef8760dee583,varboolVar$"is_dev",0xdeadbeef,|0x7ce384eae0aa9f573819ad8aaa6a4eec71d9079f031feee34d51343934131dfe|,true) <>
32
+ {0xB60B02062d1256A79C81A061a9277e84ffbB0Ff7} (|0x7ce384eae0aa9f573819ad8aaa6a4eec71d9079f031feee34d51343934131dfe|,|0x5487fd7ba958bc80cdcaf554b244cb54db0a2def3d506dbbaf0b9d6956f3e825|) <"initialize me",0xd00d,0xB60B02062d1256A79C81A061a9277e84ffbB0Ff7>
33
+ {0x4838B106FCe9647Bdf1E7877BF73cE8B0BAD5f97} (|0xcb329f0b2f36e169bcdfee34b756614933b5255d462873e07fe749690e77223a|)
34
+ ```
35
+
36
+ The root node is not passed via IR - it is ment to be set by other means as a separate meta-argument.
@@ -0,0 +1,2 @@
1
+ export { ParserWithValidation, SimplifiedParser, StaticParser, } from './ir-notation/parser';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,GACb,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StaticParser = exports.SimplifiedParser = exports.ParserWithValidation = void 0;
4
+ var parser_1 = require("./ir-notation/parser");
5
+ Object.defineProperty(exports, "ParserWithValidation", { enumerable: true, get: function () { return parser_1.ParserWithValidation; } });
6
+ Object.defineProperty(exports, "SimplifiedParser", { enumerable: true, get: function () { return parser_1.SimplifiedParser; } });
7
+ Object.defineProperty(exports, "StaticParser", { enumerable: true, get: function () { return parser_1.StaticParser; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+CAI8B;AAH5B,8GAAA,oBAAoB,OAAA;AACpB,0GAAA,gBAAgB,OAAA;AAChB,sGAAA,YAAY,OAAA"}
@@ -0,0 +1,7 @@
1
+ import { ExecTypesDoNotMatchError, InitTypesDoNotMatchError, SubstitutionTypesDoNotMatchError } from './validation-errors';
2
+ export declare class ErrorFactory {
3
+ static initTypesNotMacth: (value: string, onchainName: string, onchainType: string, offchainType: string) => InitTypesDoNotMatchError;
4
+ static execTypesNotMacth: (value: string, onchainName: string, onchainType: string, offchainType: string) => ExecTypesDoNotMatchError;
5
+ static substitutionTypesNotMatch: (selfInstanceId: string, refInstanceId: string, selfExecArgName: string, selfExecArgType: string, refInstanceReturnType: string) => SubstitutionTypesDoNotMatchError;
6
+ }
7
+ //# sourceMappingURL=ErrorFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorFactory.d.ts","sourceRoot":"","sources":["../../../src/ir-notation/errors/ErrorFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,gCAAgC,EACjC,MAAM,qBAAqB,CAAC;AAE7B,qBAAa,YAAY;IACvB,MAAM,CAAC,iBAAiB,8GAItB;IAEF,MAAM,CAAC,iBAAiB,8GAItB;IAEF,MAAM,CAAC,yBAAyB,uKAI9B;CACH"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorFactory = void 0;
4
+ const validation_errors_1 = require("./validation-errors");
5
+ class ErrorFactory {
6
+ static initTypesNotMacth = (...params) => {
7
+ return validation_errors_1.InitTypesDoNotMatchError.create(...params);
8
+ };
9
+ static execTypesNotMacth = (...params) => {
10
+ return validation_errors_1.ExecTypesDoNotMatchError.create(...params);
11
+ };
12
+ static substitutionTypesNotMatch = (...params) => {
13
+ return validation_errors_1.SubstitutionTypesDoNotMatchError.create(...params);
14
+ };
15
+ }
16
+ exports.ErrorFactory = ErrorFactory;
17
+ //# sourceMappingURL=ErrorFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorFactory.js","sourceRoot":"","sources":["../../../src/ir-notation/errors/ErrorFactory.ts"],"names":[],"mappings":";;;AAAA,2DAI6B;AAE7B,MAAa,YAAY;IACvB,MAAM,CAAC,iBAAiB,GAAG,CACzB,GAAG,MAA0D,EAC7D,EAAE;QACF,OAAO,4CAAwB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;IACpD,CAAC,CAAC;IAEF,MAAM,CAAC,iBAAiB,GAAG,CACzB,GAAG,MAA0D,EAC7D,EAAE;QACF,OAAO,4CAAwB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;IACpD,CAAC,CAAC;IAEF,MAAM,CAAC,yBAAyB,GAAG,CACjC,GAAG,MAAkE,EACrE,EAAE;QACF,OAAO,oDAAgC,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;IAC5D,CAAC,CAAC;;AAjBJ,oCAkBC"}
@@ -0,0 +1,2 @@
1
+ export * from './ErrorFactory';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ir-notation/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ErrorFactory"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ir-notation/errors/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}
@@ -0,0 +1,11 @@
1
+ import { BaseError } from '@guardian-network/shared';
2
+ export declare class InitTypesDoNotMatchError extends BaseError {
3
+ static create: (value: string, onchainName: string, onchainType: string, offchainType: string) => InitTypesDoNotMatchError;
4
+ }
5
+ export declare class ExecTypesDoNotMatchError extends BaseError {
6
+ static create: (value: string, onchainName: string, onchainType: string, offchainType: string) => ExecTypesDoNotMatchError;
7
+ }
8
+ export declare class SubstitutionTypesDoNotMatchError extends BaseError {
9
+ static create: (selfInstanceId: string, refInstanceId: string, selfExecArgName: string, selfExecArgType: string, refInstanceReturnType: string) => SubstitutionTypesDoNotMatchError;
10
+ }
11
+ //# sourceMappingURL=validation-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-errors.d.ts","sourceRoot":"","sources":["../../../src/ir-notation/errors/validation-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD,qBAAa,wBAAyB,SAAQ,SAAS;IACrD,MAAM,CAAC,MAAM,UACJ,MAAM,eACA,MAAM,eACN,MAAM,gBACL,MAAM,8BAIpB;CACH;AAED,qBAAa,wBAAyB,SAAQ,SAAS;IACrD,MAAM,CAAC,MAAM,UACJ,MAAM,eACA,MAAM,eACN,MAAM,gBACL,MAAM,8BAIpB;CACH;AAED,qBAAa,gCAAiC,SAAQ,SAAS;IAC7D,MAAM,CAAC,MAAM,mBACK,MAAM,iBACP,MAAM,mBACJ,MAAM,mBACN,MAAM,yBACA,MAAM,sCAI7B;CACH"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubstitutionTypesDoNotMatchError = exports.ExecTypesDoNotMatchError = exports.InitTypesDoNotMatchError = void 0;
4
+ const shared_1 = require("@guardian-network/shared");
5
+ class InitTypesDoNotMatchError extends shared_1.BaseError {
6
+ static create = (value, onchainName, onchainType, offchainType) => {
7
+ const errorMessage = `Initialization value ${value} (onchain name: ${onchainName}) is not matched by type: \r\n Expected onchain: ${onchainType} \r\n Got from DSL: ${offchainType}`;
8
+ return this.build(errorMessage);
9
+ };
10
+ }
11
+ exports.InitTypesDoNotMatchError = InitTypesDoNotMatchError;
12
+ class ExecTypesDoNotMatchError extends shared_1.BaseError {
13
+ static create = (value, onchainName, onchainType, offchainType) => {
14
+ const errorMessage = `Execution value ${value} (onchain name: ${onchainName}) is not matched by type: \r\n Expected onchain: ${onchainType} \r\n Got from DSL: ${offchainType}`;
15
+ return this.build(errorMessage);
16
+ };
17
+ }
18
+ exports.ExecTypesDoNotMatchError = ExecTypesDoNotMatchError;
19
+ class SubstitutionTypesDoNotMatchError extends shared_1.BaseError {
20
+ static create = (selfInstanceId, refInstanceId, selfExecArgName, selfExecArgType, refInstanceReturnType) => {
21
+ const errorMessage = `Instance ${selfInstanceId} has exec argument ${selfExecArgName} of type ${selfExecArgType} that is being substituted with instance ${refInstanceId} of type ${refInstanceReturnType}`;
22
+ return this.build(errorMessage);
23
+ };
24
+ }
25
+ exports.SubstitutionTypesDoNotMatchError = SubstitutionTypesDoNotMatchError;
26
+ //# sourceMappingURL=validation-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-errors.js","sourceRoot":"","sources":["../../../src/ir-notation/errors/validation-errors.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AAErD,MAAa,wBAAyB,SAAQ,kBAAS;IACrD,MAAM,CAAC,MAAM,GAAG,CACd,KAAa,EACb,WAAmB,EACnB,WAAmB,EACnB,YAAoB,EACpB,EAAE;QACF,MAAM,YAAY,GAAG,wBAAwB,KAAK,mBAAmB,WAAW,oDAAoD,WAAW,uBAAuB,YAAY,EAAE,CAAC;QACrL,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC,CAAC;;AATJ,4DAUC;AAED,MAAa,wBAAyB,SAAQ,kBAAS;IACrD,MAAM,CAAC,MAAM,GAAG,CACd,KAAa,EACb,WAAmB,EACnB,WAAmB,EACnB,YAAoB,EACpB,EAAE;QACF,MAAM,YAAY,GAAG,mBAAmB,KAAK,mBAAmB,WAAW,oDAAoD,WAAW,uBAAuB,YAAY,EAAE,CAAC;QAChL,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC,CAAC;;AATJ,4DAUC;AAED,MAAa,gCAAiC,SAAQ,kBAAS;IAC7D,MAAM,CAAC,MAAM,GAAG,CACd,cAAsB,EACtB,aAAqB,EACrB,eAAuB,EACvB,eAAuB,EACvB,qBAA6B,EAC7B,EAAE;QACF,MAAM,YAAY,GAAG,YAAY,cAAc,sBAAsB,eAAe,YAAY,eAAe,4CAA4C,aAAa,YAAY,qBAAqB,EAAE,CAAC;QAC5M,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC,CAAC;;AAVJ,4EAWC"}
@@ -0,0 +1,18 @@
1
+ import { SupportedSolidityType } from '@guardian-network/shared';
2
+ export declare const bytesEncodeArgs: (args: string[], types: SupportedSolidityType[]) => string;
3
+ export declare const indexConstants: (parameters: {
4
+ value: string;
5
+ index: number;
6
+ }[], argsTypes: SupportedSolidityType[]) => {
7
+ value: string;
8
+ index: number;
9
+ }[];
10
+ export declare function extractComponents(input: string): {
11
+ addressClause: string;
12
+ paramsClause: string;
13
+ initClause: string;
14
+ };
15
+ export declare function extractArguments(input: string): string[];
16
+ export declare function extractInjection(inputString: string): string;
17
+ export declare const DSLTypesToIRTypes: (el: string) => "string" | "bytes" | "bool" | "uint256" | "address";
18
+ //# sourceMappingURL=formatters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../../src/ir-notation/helpers/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAIlC,eAAO,MAAM,eAAe,SACpB,MAAM,EAAE,SACP,qBAAqB,EAAE,WAO/B,CAAC;AAEF,eAAO,MAAM,cAAc,eACb;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,aACnC,qBAAqB,EAAE;;;GAQ/B,CAAC;AAEN,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM;;;;EAU9C;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAMxD;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAK5D;AAED,eAAO,MAAM,iBAAiB,OAAQ,MAAM,wDAI3C,CAAC"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DSLTypesToIRTypes = exports.indexConstants = exports.bytesEncodeArgs = void 0;
4
+ exports.extractComponents = extractComponents;
5
+ exports.extractArguments = extractArguments;
6
+ exports.extractInjection = extractInjection;
7
+ const shared_1 = require("@guardian-network/shared");
8
+ const _1 = require(".");
9
+ const types_1 = require("../parser/types");
10
+ const bytesEncodeArgs = (args, types) => {
11
+ const typedArgs = args.map((arg, index) => (0, _1.toTypedWithKnownType)(arg, types[index]));
12
+ return shared_1.defaultAbiCoder.encode(types, typedArgs);
13
+ };
14
+ exports.bytesEncodeArgs = bytesEncodeArgs;
15
+ const indexConstants = (parameters, argsTypes) => parameters.map((arg, index) => ({
16
+ value: shared_1.defaultAbiCoder.encode([argsTypes[index]], [(0, _1.toTypedWithKnownType)(arg.value, argsTypes[index])]),
17
+ index: arg.index,
18
+ }));
19
+ exports.indexConstants = indexConstants;
20
+ function extractComponents(input) {
21
+ const regex = /\{([^}]+)\}\s*\(([^)]*)\)\s*<([^>]*)>/;
22
+ const match = input.match(regex);
23
+ if (match && match.length === 4) {
24
+ const [, addressClause, paramsClause, initClause] = match;
25
+ return { addressClause, paramsClause, initClause };
26
+ }
27
+ throw new Error('Input string does not match the expected format.');
28
+ }
29
+ function extractArguments(input) {
30
+ if (input.trim() === '') {
31
+ return [];
32
+ }
33
+ return input.split(',').map((value) => value.trim());
34
+ }
35
+ function extractInjection(inputString) {
36
+ const matcher = /\$"([^"]*)"$/;
37
+ const matched = inputString.match(matcher);
38
+ return matched ? matched[1] : '';
39
+ }
40
+ const DSLTypesToIRTypes = (el) => {
41
+ const typed = types_1.DSLTypesMapping[el];
42
+ return typed;
43
+ };
44
+ exports.DSLTypesToIRTypes = DSLTypesToIRTypes;
45
+ //# sourceMappingURL=formatters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../src/ir-notation/helpers/formatters.ts"],"names":[],"mappings":";;;AA+BA,8CAUC;AAED,4CAMC;AAED,4CAKC;AAxDD,qDAIkC;AAClC,wBAAyC;AACzC,2CAAkD;AAE3C,MAAM,eAAe,GAAG,CAC7B,IAAc,EACd,KAA8B,EAC9B,EAAE;IACF,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CACxC,IAAA,uBAAoB,EAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CACxC,CAAC;IAEF,OAAO,wBAAe,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC,CAAC;AATW,QAAA,eAAe,mBAS1B;AAEK,MAAM,cAAc,GAAG,CAC5B,UAA8C,EAC9C,SAAkC,EAClC,EAAE,CACF,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9B,KAAK,EAAE,wBAAe,CAAC,MAAM,CAC3B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAClB,CAAC,IAAA,uBAAoB,EAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CACpD;IACD,KAAK,EAAE,GAAG,CAAC,KAAK;CACjB,CAAC,CAAC,CAAC;AAVO,QAAA,cAAc,kBAUrB;AAEN,SAAgB,iBAAiB,CAAC,KAAa;IAC7C,MAAM,KAAK,GAAG,uCAAuC,CAAC;IACtD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAEjC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,MAAM,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC;QAC1D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;IACrD,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;AACtE,CAAC;AAED,SAAgB,gBAAgB,CAAC,KAAa;IAC5C,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;AACvD,CAAC;AAED,SAAgB,gBAAgB,CAAC,WAAmB;IAClD,MAAM,OAAO,GAAG,cAAc,CAAC;IAC/B,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAE3C,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnC,CAAC;AAEM,MAAM,iBAAiB,GAAG,CAAC,EAAU,EAAE,EAAE;IAE9C,MAAM,KAAK,GAAG,uBAAe,CAAC,EAAa,CAAC,CAAC;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAJW,QAAA,iBAAiB,qBAI5B"}
@@ -0,0 +1,5 @@
1
+ export * from './formatters';
2
+ export * from './matchers';
3
+ export * from './morphs';
4
+ export * from './validation';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ir-notation/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./formatters"), exports);
18
+ __exportStar(require("./matchers"), exports);
19
+ __exportStar(require("./morphs"), exports);
20
+ __exportStar(require("./validation"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ir-notation/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,6CAA2B;AAC3B,2CAAyB;AACzB,+CAA6B"}
@@ -0,0 +1,4 @@
1
+ export declare const strIsVar: (str: string) => boolean;
2
+ export declare const strIsSubst: (str: string) => boolean;
3
+ export declare const isConstant: (arg: string) => boolean;
4
+ //# sourceMappingURL=matchers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../../../src/ir-notation/helpers/matchers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,QAAS,MAAM,KAAG,OAEtC,CAAC;AACF,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,OAExC,CAAC;AAEF,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,OAIxC,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isConstant = exports.strIsSubst = exports.strIsVar = void 0;
4
+ const strIsVar = (str) => {
5
+ return /^var/.test(str);
6
+ };
7
+ exports.strIsVar = strIsVar;
8
+ const strIsSubst = (str) => {
9
+ return str[0] == '|' && str[str.length - 1] == '|';
10
+ };
11
+ exports.strIsSubst = strIsSubst;
12
+ const isConstant = (arg) => {
13
+ const regex = /^(?!var)(?!\|.*\|$).*/;
14
+ return regex.test(arg);
15
+ };
16
+ exports.isConstant = isConstant;
17
+ //# sourceMappingURL=matchers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matchers.js","sourceRoot":"","sources":["../../../src/ir-notation/helpers/matchers.ts"],"names":[],"mappings":";;;AAAO,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAW,EAAE;IAC/C,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC,CAAC;AAFW,QAAA,QAAQ,YAEnB;AACK,MAAM,UAAU,GAAG,CAAC,GAAW,EAAW,EAAE;IACjD,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC;AACrD,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;AAEK,MAAM,UAAU,GAAG,CAAC,GAAW,EAAW,EAAE;IACjD,MAAM,KAAK,GAAG,uBAAuB,CAAC;IAEtC,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC,CAAC;AAJW,QAAA,UAAU,cAIrB"}
@@ -0,0 +1,4 @@
1
+ import { SupportedSolidityType } from '@guardian-network/shared';
2
+ export declare const strToBool: (str: string) => boolean;
3
+ export declare const toTypedWithKnownType: (arg: string, type: SupportedSolidityType) => string | bigint | boolean | Uint8Array;
4
+ //# sourceMappingURL=morphs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"morphs.d.ts","sourceRoot":"","sources":["../../../src/ir-notation/helpers/morphs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,eAAO,MAAM,SAAS,QAAS,MAAM,KAAG,OAEvC,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAC1B,MAAM,QACL,qBAAqB,2CAgB5B,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toTypedWithKnownType = exports.strToBool = void 0;
4
+ const ethers_1 = require("ethers");
5
+ const strToBool = (str) => {
6
+ return str == 'true' ? true : false;
7
+ };
8
+ exports.strToBool = strToBool;
9
+ const toTypedWithKnownType = (arg, type) => {
10
+ switch (type) {
11
+ case 'address':
12
+ return (0, ethers_1.getAddress)(arg);
13
+ case 'bool':
14
+ return (0, exports.strToBool)(arg);
15
+ case 'string':
16
+ return arg.replace(/^"(.*)"$/, '$1');
17
+ case 'bytes':
18
+ return (0, ethers_1.getBytes)(arg);
19
+ case 'uint256':
20
+ return BigInt(arg);
21
+ default:
22
+ throw new Error(`Unsupported constant value type: ${arg}: ${type}`);
23
+ }
24
+ };
25
+ exports.toTypedWithKnownType = toTypedWithKnownType;
26
+ //# sourceMappingURL=morphs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"morphs.js","sourceRoot":"","sources":["../../../src/ir-notation/helpers/morphs.ts"],"names":[],"mappings":";;;AACA,mCAA8C;AAEvC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAW,EAAE;IAChD,OAAO,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AACtC,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB;AAEK,MAAM,oBAAoB,GAAG,CAClC,GAAW,EACX,IAA2B,EAC3B,EAAE;IACF,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,SAAS;YACZ,OAAO,IAAA,mBAAU,EAAC,GAAG,CAAC,CAAC;QACzB,KAAK,MAAM;YACT,OAAO,IAAA,iBAAS,EAAC,GAAG,CAAC,CAAC;QACxB,KAAK,QAAQ;YACX,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QACvC,KAAK,OAAO;YACV,OAAO,IAAA,iBAAQ,EAAC,GAAG,CAAC,CAAC;QACvB,KAAK,SAAS;YACZ,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;QACrB;YACE,MAAM,IAAI,KAAK,CAAC,oCAAoC,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC;IACxE,CAAC;AACH,CAAC,CAAC;AAlBW,QAAA,oBAAoB,wBAkB/B"}
@@ -0,0 +1,2 @@
1
+ export * from './typing.validation';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ir-notation/helpers/validation/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./typing.validation"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ir-notation/helpers/validation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC"}
@@ -0,0 +1,10 @@
1
+ import { MinTypedValue, NodeTreeInitData as ParsingResult } from '@guardian-network/shared';
2
+ import { ContractRunner } from 'ethers';
3
+ type InitExecArgumentsConfig = {
4
+ execArguments: Array<MinTypedValue>;
5
+ initArguments: Array<MinTypedValue>;
6
+ };
7
+ export declare const dslTypesToOnchainTypesParamsValidation: (provider: ContractRunner) => (artifactAddress: string, initExecArgumentsConfig: InitExecArgumentsConfig) => Promise<void>;
8
+ export declare const onchainSubstitutionToReturnTypesValidation: (provider: ContractRunner) => (output: ParsingResult[]) => Promise<void>;
9
+ export {};
10
+ //# sourceMappingURL=typing.validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typing.validation.d.ts","sourceRoot":"","sources":["../../../../src/ir-notation/helpers/validation/typing.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,gBAAgB,IAAI,aAAa,EAClC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAIxC,KAAK,uBAAuB,GAAG;IAC7B,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IACpC,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,sCAAsC,aACtC,cAAc,uBAEN,MAAM,2BACE,uBAAuB,kBAqCjD,CAAC;AAEJ,eAAO,MAAM,0CAA0C,aAC1C,cAAc,cAAoB,aAAa,EAAE,kBA8B3D,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onchainSubstitutionToReturnTypesValidation = exports.dslTypesToOnchainTypesParamsValidation = void 0;
4
+ const shared_1 = require("@guardian-network/shared");
5
+ const errors_1 = require("../../errors");
6
+ const formatters_1 = require("../formatters");
7
+ const dslTypesToOnchainTypesParamsValidation = (provider) => async (artifactAddress, initExecArgumentsConfig) => {
8
+ const instance = shared_1.MinArbitraryDataArtifactFactory.connect(artifactAddress, provider);
9
+ const { argsNames, argsTypes } = await instance.getExecDescriptor();
10
+ const { argsNames: initArgsNames, argsTypes: initArgsTypes } = await instance.getInitDescriptor();
11
+ for (let i = 0; i < initArgsNames.length; i++) {
12
+ const mirroredDslParameter = initExecArgumentsConfig.initArguments[i];
13
+ const parsedType = (0, formatters_1.DSLTypesToIRTypes)(mirroredDslParameter.type);
14
+ if (initArgsTypes[i] !== parsedType) {
15
+ throw errors_1.ErrorFactory.initTypesNotMacth(mirroredDslParameter.value, initArgsNames[i], initArgsTypes[i], parsedType);
16
+ }
17
+ }
18
+ for (let i = 0; i < argsNames.length; i++) {
19
+ const mirroredDslParameter = initExecArgumentsConfig.execArguments[i];
20
+ const parsedType = (0, formatters_1.DSLTypesToIRTypes)(mirroredDslParameter.type);
21
+ if (argsTypes[i] !== parsedType) {
22
+ throw errors_1.ErrorFactory.execTypesNotMacth(mirroredDslParameter.value, argsNames[i], argsTypes[i], parsedType);
23
+ }
24
+ }
25
+ };
26
+ exports.dslTypesToOnchainTypesParamsValidation = dslTypesToOnchainTypesParamsValidation;
27
+ const onchainSubstitutionToReturnTypesValidation = (provider) => async (output) => {
28
+ for (const instance of output) {
29
+ const currentInstance = shared_1.MinArbitraryDataArtifactFactory.connect(instance.artifactAddress, provider);
30
+ for (const refNode of instance.substitutedExecArgs) {
31
+ const refDeclaration = output.find((el) => el.id == refNode.supplierNodeId);
32
+ const refArtifactInstance = shared_1.MinArbitraryDataArtifactFactory.connect(refDeclaration?.artifactAddress, provider);
33
+ const { returnType } = await refArtifactInstance.getExecDescriptor();
34
+ const { argsTypes, argsNames } = await currentInstance.getExecDescriptor();
35
+ if (!(argsTypes[Number(refNode.index)] == returnType))
36
+ throw errors_1.ErrorFactory.substitutionTypesNotMatch(instance.id, argsNames[Number(refNode.index)], argsTypes[Number(refNode.index)], refNode.supplierNodeId, returnType);
37
+ }
38
+ }
39
+ };
40
+ exports.onchainSubstitutionToReturnTypesValidation = onchainSubstitutionToReturnTypesValidation;
41
+ //# sourceMappingURL=typing.validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typing.validation.js","sourceRoot":"","sources":["../../../../src/ir-notation/helpers/validation/typing.validation.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,4 @@
1
+ export { ParserWithValidation, SimplifiedParser, StaticParser, } from './parser-contracts';
2
+ export { parseIRByDSLTypesWithInterceptor, parseIRByOnchainTypesWithInterceptor, } from './parser.unvalidated';
3
+ export { getIRParser, getIRParserUnvalidate } from './parser.validated';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ir-notation/parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gCAAgC,EAChC,oCAAoC,GACrC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getIRParserUnvalidate = exports.getIRParser = exports.parseIRByOnchainTypesWithInterceptor = exports.parseIRByDSLTypesWithInterceptor = exports.StaticParser = exports.SimplifiedParser = exports.ParserWithValidation = void 0;
4
+ var parser_contracts_1 = require("./parser-contracts");
5
+ Object.defineProperty(exports, "ParserWithValidation", { enumerable: true, get: function () { return parser_contracts_1.ParserWithValidation; } });
6
+ Object.defineProperty(exports, "SimplifiedParser", { enumerable: true, get: function () { return parser_contracts_1.SimplifiedParser; } });
7
+ Object.defineProperty(exports, "StaticParser", { enumerable: true, get: function () { return parser_contracts_1.StaticParser; } });
8
+ var parser_unvalidated_1 = require("./parser.unvalidated");
9
+ Object.defineProperty(exports, "parseIRByDSLTypesWithInterceptor", { enumerable: true, get: function () { return parser_unvalidated_1.parseIRByDSLTypesWithInterceptor; } });
10
+ Object.defineProperty(exports, "parseIRByOnchainTypesWithInterceptor", { enumerable: true, get: function () { return parser_unvalidated_1.parseIRByOnchainTypesWithInterceptor; } });
11
+ var parser_validated_1 = require("./parser.validated");
12
+ Object.defineProperty(exports, "getIRParser", { enumerable: true, get: function () { return parser_validated_1.getIRParser; } });
13
+ Object.defineProperty(exports, "getIRParserUnvalidate", { enumerable: true, get: function () { return parser_validated_1.getIRParserUnvalidate; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ir-notation/parser/index.ts"],"names":[],"mappings":";;;AAAA,uDAI4B;AAH1B,wHAAA,oBAAoB,OAAA;AACpB,oHAAA,gBAAgB,OAAA;AAChB,gHAAA,YAAY,OAAA;AAEd,2DAG8B;AAF5B,sIAAA,gCAAgC,OAAA;AAChC,0IAAA,oCAAoC,OAAA;AAEtC,uDAAwE;AAA/D,+GAAA,WAAW,OAAA;AAAE,yHAAA,qBAAqB,OAAA"}
@@ -0,0 +1,14 @@
1
+ import { LacLangCompilerOptions as CompilerConfiguration, InstanceConfig, TranspilerOutput } from '@guardian-network/shared';
2
+ import { ContractRunner } from 'ethers';
3
+ import { ValidationMiddlware } from '../types';
4
+ import { SimplifiedParser } from './SimplifiedParser';
5
+ import { GetTypesValues } from './types';
6
+ export declare class ParserWithValidation extends SimplifiedParser {
7
+ private middleware?;
8
+ static fromOnchainSource: (intermediatePresentation: string, provider: ContractRunner) => ParserWithValidation;
9
+ static fromDSLBasedConfig: (intermediatePresentation: string, artifactConfigsList: Array<InstanceConfig>, provider?: ContractRunner) => ParserWithValidation;
10
+ static fromCompilerConfiguration: (config: CompilerConfiguration, { ir: intermediatePresentation, typings: artifactConfigsList, }: Pick<TranspilerOutput, "ir" | "typings">) => ParserWithValidation;
11
+ static create: (intermediatePresentation: string, getTypesSource: GetTypesValues, middleware?: ValidationMiddlware) => ParserWithValidation;
12
+ constructor(getTypesSource: GetTypesValues, intermediatePresentation: string, middleware?: ValidationMiddlware | undefined);
13
+ }
14
+ //# sourceMappingURL=ParserWithValidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParserWithValidation.d.ts","sourceRoot":"","sources":["../../../../src/ir-notation/parser/parser-contracts/ParserWithValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,IAAI,qBAAqB,EAC/C,cAAc,EACd,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,qBAAa,oBAAqB,SAAQ,gBAAgB;IAkFtD,OAAO,CAAC,UAAU,CAAC;IAjFrB,MAAM,CAAC,iBAAiB,6BACI,MAAM,YACtB,cAAc,KACvB,oBAAoB,CAMrB;IAEF,MAAM,CAAC,kBAAkB,6BACG,MAAM,uBACX,KAAK,CAAC,cAAc,CAAC,aAC/B,cAAc,0BAczB;IAEF,MAAM,CAAC,yBAAyB,WACtB,qBAAqB,mEAI1B,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,SAAS,CAAC,KAC1C,oBAAoB,CA0BrB;IAEF,MAAM,CAAC,MAAM,6BACe,MAAM,kBAChB,cAAc,eACjB,mBAAmB,KAC/B,oBAAoB,CAMrB;gBAKA,cAAc,EAAE,cAAc,EAC9B,wBAAwB,EAAE,MAAM,EACxB,UAAU,CAAC,EAAE,mBAAmB,YAAA;CAI3C"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParserWithValidation = void 0;
4
+ const parser_validated_1 = require("../parser.validated");
5
+ const SimplifiedParser_1 = require("./SimplifiedParser");
6
+ const tools_1 = require("./tools");
7
+ class ParserWithValidation extends SimplifiedParser_1.SimplifiedParser {
8
+ middleware;
9
+ static fromOnchainSource = (intermediatePresentation, provider) => {
10
+ const middleware = (0, parser_validated_1.TypingsValidator)(provider);
11
+ const getTypesSource = (0, tools_1.createOrInferTypesSource)(provider);
12
+ return this.create(intermediatePresentation, getTypesSource, middleware);
13
+ };
14
+ static fromDSLBasedConfig = (intermediatePresentation, artifactConfigsList, provider) => {
15
+ let middleware;
16
+ if (!!provider) {
17
+ middleware = (0, parser_validated_1.TypingsValidator)(provider);
18
+ }
19
+ const getTypesSource = tools_1.DSLConfigArgsTypesSource.build(artifactConfigsList);
20
+ return this.create(intermediatePresentation, getTypesSource.getTypes, middleware);
21
+ };
22
+ static fromCompilerConfiguration = (config, { ir: intermediatePresentation, typings: artifactConfigsList, }) => {
23
+ const { checkTypesAgainstDslDeclarations, checkTypesAgainstOnchainDescriptors, provider, } = config;
24
+ const isProvider = !!provider;
25
+ if (!!checkTypesAgainstDslDeclarations) {
26
+ return this.fromDSLBasedConfig(intermediatePresentation, artifactConfigsList, provider);
27
+ }
28
+ if (!!checkTypesAgainstOnchainDescriptors) {
29
+ if (!isProvider)
30
+ throw new Error(`Parser: provider not supplied`);
31
+ return this.fromOnchainSource(intermediatePresentation, provider);
32
+ }
33
+ return this.fromDSLBasedConfig(intermediatePresentation, artifactConfigsList);
34
+ };
35
+ static create = (intermediatePresentation, getTypesSource, middleware) => {
36
+ return new ParserWithValidation(getTypesSource, intermediatePresentation, middleware);
37
+ };
38
+ constructor(getTypesSource, intermediatePresentation, middleware) {
39
+ super(getTypesSource, intermediatePresentation);
40
+ this.middleware = middleware;
41
+ }
42
+ }
43
+ exports.ParserWithValidation = ParserWithValidation;
44
+ //# sourceMappingURL=ParserWithValidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParserWithValidation.js","sourceRoot":"","sources":["../../../../src/ir-notation/parser/parser-contracts/ParserWithValidation.ts"],"names":[],"mappings":";;;AAMA,0DAAuD;AAEvD,yDAAsD;AACtD,mCAA6E;AAG7E,MAAa,oBAAqB,SAAQ,mCAAgB;IAkF9C;IAjFV,MAAM,CAAC,iBAAiB,GAAG,CACzB,wBAAgC,EAChC,QAAwB,EACF,EAAE;QACxB,MAAM,UAAU,GAAG,IAAA,mCAAgB,EAAC,QAAQ,CAAC,CAAC;QAE9C,MAAM,cAAc,GAAG,IAAA,gCAAwB,EAAC,QAAQ,CAAC,CAAC;QAE1D,OAAO,IAAI,CAAC,MAAM,CAAC,wBAAwB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;IAC3E,CAAC,CAAC;IAEF,MAAM,CAAC,kBAAkB,GAAG,CAC1B,wBAAgC,EAChC,mBAA0C,EAC1C,QAAyB,EACzB,EAAE;QACF,IAAI,UAA2C,CAAC;QAChD,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;YACf,UAAU,GAAG,IAAA,mCAAgB,EAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC;QAED,MAAM,cAAc,GAAG,gCAAwB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE3E,OAAO,IAAI,CAAC,MAAM,CAChB,wBAAwB,EACxB,cAAc,CAAC,QAAQ,EACvB,UAAU,CACX,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,CAAC,yBAAyB,GAAG,CACjC,MAA6B,EAC7B,EACE,EAAE,EAAE,wBAAwB,EAC5B,OAAO,EAAE,mBAAmB,GACa,EACrB,EAAE;QACxB,MAAM,EACJ,gCAAgC,EAChC,mCAAmC,EACnC,QAAQ,GACT,GAAG,MAAM,CAAC;QACX,MAAM,UAAU,GAAG,CAAC,CAAC,QAAQ,CAAC;QAE9B,IAAI,CAAC,CAAC,gCAAgC,EAAE,CAAC;YACvC,OAAO,IAAI,CAAC,kBAAkB,CAC5B,wBAAwB,EACxB,mBAAmB,EACnB,QAAQ,CACT,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,CAAC,mCAAmC,EAAE,CAAC;YAC1C,IAAI,CAAC,UAAU;gBAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;YAElE,OAAO,IAAI,CAAC,iBAAiB,CAAC,wBAAwB,EAAE,QAAQ,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,IAAI,CAAC,kBAAkB,CAC5B,wBAAwB,EACxB,mBAAmB,CACpB,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,CAAC,MAAM,GAAG,CACd,wBAAgC,EAChC,cAA8B,EAC9B,UAAgC,EACV,EAAE;QACxB,OAAO,IAAI,oBAAoB,CAC7B,cAAc,EACd,wBAAwB,EACxB,UAAU,CACX,CAAC;IACJ,CAAC,CAAC;IAIF,YACE,cAA8B,EAC9B,wBAAgC,EACxB,UAAgC;QAExC,KAAK,CAAC,cAAc,EAAE,wBAAwB,CAAC,CAAC;QAFxC,eAAU,GAAV,UAAU,CAAsB;IAG1C,CAAC;;AArFH,oDAsFC"}
@@ -0,0 +1,12 @@
1
+ import { ContractRunner } from 'ethers';
2
+ import { ParsingResult } from '../types';
3
+ import { GetTypesValues, IArgsTypesSource } from './types';
4
+ export declare class SimplifiedParser {
5
+ protected getTypesSource: GetTypesValues;
6
+ protected intermediatePresentation: string;
7
+ static build: (intermediatePresentation: string, providerOrSource: ContractRunner | IArgsTypesSource) => SimplifiedParser;
8
+ constructor(getTypesSource: GetTypesValues, intermediatePresentation: string);
9
+ protected get unprocessedArtifacts(): Array<string>;
10
+ process: () => Promise<Array<ParsingResult>>;
11
+ }
12
+ //# sourceMappingURL=SimplifiedParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimplifiedParser.d.ts","sourceRoot":"","sources":["../../../../src/ir-notation/parser/parser-contracts/SimplifiedParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3D,qBAAa,gBAAgB;IAazB,SAAS,CAAC,cAAc,EAAE,cAAc;IACxC,SAAS,CAAC,wBAAwB,EAAE,MAAM;IAb5C,MAAM,CAAC,KAAK,6BACgB,MAAM,oBACd,cAAc,GAAG,gBAAgB,KAClD,gBAAgB,CAIjB;gBAKU,cAAc,EAAE,cAAc,EAC9B,wBAAwB,EAAE,MAAM;IAG5C,SAAS,KAAK,oBAAoB,IAAI,KAAK,CAAC,MAAM,CAAC,CAElD;IAOD,OAAO,QAAa,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAO/C;CACH"}