@mimicprotocol/test-ts 0.0.1-rc.9 → 0.0.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/CHANGELOG.md +134 -0
- package/README.md +21 -22
- package/dist/RunnerMock.d.ts +6 -1
- package/dist/RunnerMock.js +80 -26
- package/dist/RunnerMock.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/processors/evm-call.d.ts +3 -0
- package/dist/processors/evm-call.js +24 -0
- package/dist/processors/evm-call.js.map +1 -0
- package/dist/processors/index.d.ts +4 -0
- package/dist/processors/index.js +21 -0
- package/dist/processors/index.js.map +1 -0
- package/dist/processors/price.d.ts +3 -0
- package/dist/processors/price.js +16 -0
- package/dist/processors/price.js.map +1 -0
- package/dist/processors/relevant-tokens.d.ts +3 -0
- package/dist/processors/relevant-tokens.js +14 -0
- package/dist/processors/relevant-tokens.js.map +1 -0
- package/dist/processors/subgraph.d.ts +3 -0
- package/dist/processors/subgraph.js +16 -0
- package/dist/processors/subgraph.js.map +1 -0
- package/dist/run-function.d.ts +2 -0
- package/dist/run-function.js +83 -0
- package/dist/run-function.js.map +1 -0
- package/dist/types.d.ts +65 -41
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +93 -0
- package/dist/utils.js.map +1 -0
- package/dist/validators.d.ts +447 -20
- package/dist/validators.js +58 -10
- package/dist/validators.js.map +1 -1
- package/package.json +9 -3
- package/dist/run-task.d.ts +0 -2
- package/dist/run-task.js +0 -107
- package/dist/run-task.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# @mimicprotocol/test-ts
|
|
2
|
+
|
|
3
|
+
## 0.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 54f7344: Add Polygon, Avalanche, and BNB chain support
|
|
8
|
+
- 9a993b0: Add getNativeBalance
|
|
9
|
+
- 8aa883e: Bump sdk and runner versions
|
|
10
|
+
- 32adf4f: Fix ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING for new node versions
|
|
11
|
+
- 72bb607: Fix relevant tokens query price filter
|
|
12
|
+
- 8853afe: Fix clashing Result import
|
|
13
|
+
- 2bbe278: update eslint config
|
|
14
|
+
- 1e48dff: Bump runner-node to version 0.0.1-rc.8
|
|
15
|
+
- da39b85: Added Tokens class
|
|
16
|
+
- 9530e1c: Revert test command directory change
|
|
17
|
+
- 4a47218: Add function filter to codegen
|
|
18
|
+
- 426a4fe: Environment refactored
|
|
19
|
+
- 73e9713: Add getCode function to get the code of an address (Only EVM)
|
|
20
|
+
- 52b567d: Align oracle types naming convention
|
|
21
|
+
- 6a4fb70: rename to use functions
|
|
22
|
+
- 7657416: Add address and chain to event data
|
|
23
|
+
- e1277c7: Refactor Result to use unwrap instead of value
|
|
24
|
+
- 73a7900: Add login, logout and profiles commands
|
|
25
|
+
- 323663a: Change directory to positional argument in init and test command
|
|
26
|
+
- 213f37f: Fix class names overlapping
|
|
27
|
+
- 73a9cde: Fix npx init
|
|
28
|
+
- faac37c: Ensure early returns in favor of else blocks
|
|
29
|
+
- 0a6602a: Handle oracle query errors
|
|
30
|
+
- 48352fe: Add runner target on compilation
|
|
31
|
+
- ed2d252: Refactor credentials commands
|
|
32
|
+
- 21aba8d: Improve mocks error messages
|
|
33
|
+
- 94ef728: add custom storage
|
|
34
|
+
- 5c8c562: Fix MockConfig validator
|
|
35
|
+
- d455822: Bump SDK version
|
|
36
|
+
- 7d2279d: Refactor codegen, compile, build, deploy and test commands and their parameters
|
|
37
|
+
|
|
38
|
+
## 0.0.1-rc.41
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- 54f7344: Add Polygon, Avalanche, and BNB chain support
|
|
43
|
+
|
|
44
|
+
## 0.0.1-rc.40
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- 32adf4f: Fix ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING for new node versions
|
|
49
|
+
- 2bbe278: update eslint config
|
|
50
|
+
|
|
51
|
+
## 0.0.1-rc.39
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- 48352fe: Add runner target on compilation
|
|
56
|
+
|
|
57
|
+
## 0.0.1-rc.38
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- 73e9713: Add getCode function to get the code of an address (Only EVM)
|
|
62
|
+
|
|
63
|
+
## 0.0.1-rc.37
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- ed2d252: Refactor credentials commands
|
|
68
|
+
- 94ef728: add custom storage
|
|
69
|
+
- 7d2279d: Refactor codegen, compile, build, deploy and test commands and their parameters
|
|
70
|
+
|
|
71
|
+
## 0.0.1-rc.36
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- 6a4fb70: rename to use functions
|
|
76
|
+
|
|
77
|
+
## 0.0.1-rc.35
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- 9a993b0: Add getNativeBalance
|
|
82
|
+
- da39b85: Added Tokens class
|
|
83
|
+
- 426a4fe: Environment refactored
|
|
84
|
+
|
|
85
|
+
## 0.0.1-rc.34
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- 73a7900: Add login, logout and profiles commands
|
|
90
|
+
- d455822: Bump SDK version
|
|
91
|
+
|
|
92
|
+
## 0.0.1-rc.33
|
|
93
|
+
|
|
94
|
+
### Patch Changes
|
|
95
|
+
|
|
96
|
+
- 9530e1c: Revert test command directory change
|
|
97
|
+
- 21aba8d: Improve mocks error messages
|
|
98
|
+
- 5c8c562: Fix MockConfig validator
|
|
99
|
+
|
|
100
|
+
## 0.0.1-rc.32
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- 8853afe: Fix clashing Result import
|
|
105
|
+
- e1277c7: Refactor Result to use unwrap instead of value
|
|
106
|
+
- 323663a: Change directory to positional argument in init and test command
|
|
107
|
+
- faac37c: Ensure early returns in favor of else blocks
|
|
108
|
+
|
|
109
|
+
## 0.0.1-rc.31
|
|
110
|
+
|
|
111
|
+
### Patch Changes
|
|
112
|
+
|
|
113
|
+
- 1e48dff: Bump runner-node to version 0.0.1-rc.8
|
|
114
|
+
|
|
115
|
+
## 0.0.1-rc.30
|
|
116
|
+
|
|
117
|
+
### Patch Changes
|
|
118
|
+
|
|
119
|
+
- 213f37f: Fix class names overlapping
|
|
120
|
+
|
|
121
|
+
## 0.0.1-rc.29
|
|
122
|
+
|
|
123
|
+
### Patch Changes
|
|
124
|
+
|
|
125
|
+
- 72bb607: Fix relevant tokens query price filter
|
|
126
|
+
- 52b567d: Align oracle types naming convention
|
|
127
|
+
- 73a9cde: Fix npx init
|
|
128
|
+
- 0a6602a: Handle oracle query errors
|
|
129
|
+
|
|
130
|
+
## 0.0.1-rc.28
|
|
131
|
+
|
|
132
|
+
### Patch Changes
|
|
133
|
+
|
|
134
|
+
- 7657416: Add address and chain to event data
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<a href="https://mimic.fi"><img src="https://www.mimic.fi/logo.png" alt="Mimic Protocol" width="200"></a>
|
|
3
3
|
</h1>
|
|
4
4
|
|
|
5
|
-
<h4 align="center">Blockchain
|
|
5
|
+
<h4 align="center">Blockchain development platform</h4>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<a href="https://github.com/mimic-protocol/tooling/actions/workflows/ci.yml">
|
|
@@ -23,17 +23,17 @@
|
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
-
## Content
|
|
26
|
+
## Content
|
|
27
27
|
|
|
28
|
-
This package provides tooling and helpers to write and run tests for Mimic Protocol
|
|
28
|
+
This package provides tooling and helpers to write and run tests for Mimic Protocol functions using TypeScript. It includes:
|
|
29
29
|
|
|
30
30
|
- Mocking of inputs, balances, prices, contract calls responses, and context variables
|
|
31
|
-
- Simulated
|
|
32
|
-
- Structured
|
|
31
|
+
- Simulated function execution with mocked environment
|
|
32
|
+
- Structured function outputs to assert emitted intents using frameworks like Mocha and Chai
|
|
33
33
|
|
|
34
34
|
## Setup
|
|
35
35
|
|
|
36
|
-
To set up this project you'll need [git](https://git-scm.com) and [yarn](https://classic.yarnpkg.com) installed.
|
|
36
|
+
To set up this project you'll need [git](https://git-scm.com) and [yarn](https://classic.yarnpkg.com) installed.
|
|
37
37
|
|
|
38
38
|
Install the library from the root of the monorepo:
|
|
39
39
|
|
|
@@ -50,30 +50,30 @@ $ yarn
|
|
|
50
50
|
|
|
51
51
|
## Usage
|
|
52
52
|
|
|
53
|
-
Here’s an example of how to test a Mimic
|
|
53
|
+
Here’s an example of how to test a Mimic function:
|
|
54
54
|
|
|
55
55
|
```ts
|
|
56
|
-
import {
|
|
57
|
-
import { expect } from
|
|
56
|
+
import { runFunction } from "@mimicprotocol/test-ts";
|
|
57
|
+
import { expect } from "chai";
|
|
58
58
|
|
|
59
|
-
const
|
|
60
|
-
const context = { user:
|
|
61
|
-
const inputs = { token:
|
|
59
|
+
const funcDir = "./my-function";
|
|
60
|
+
const context = { user: "0x...", settler: "0x...", timestamp: Date.now() };
|
|
61
|
+
const inputs = { token: "0x...", amount: "10000000" };
|
|
62
62
|
|
|
63
|
-
const intents = await
|
|
63
|
+
const intents = await runFunction(funcDir, context, { inputs });
|
|
64
64
|
|
|
65
|
-
expect(intents).to.be.an(
|
|
66
|
-
expect(intents).to.have.lengthOf(1)
|
|
65
|
+
expect(intents).to.be.an("array").that.is.not.empty;
|
|
66
|
+
expect(intents).to.have.lengthOf(1);
|
|
67
67
|
|
|
68
|
-
expect(intents[0].type).to.be.equal(
|
|
69
|
-
expect(intents[0].settler).to.be.equal(context.settler)
|
|
68
|
+
expect(intents[0].type).to.be.equal("transfer");
|
|
69
|
+
expect(intents[0].settler).to.be.equal(context.settler);
|
|
70
70
|
|
|
71
|
-
expect(intents[0].transfers).to.have.lengthOf(1)
|
|
72
|
-
expect(intents[0].transfers[0].token).to.be.equal(inputs.token)
|
|
73
|
-
expect(intents[0].transfers[0].amount).to.be.equal(inputs.amount)
|
|
71
|
+
expect(intents[0].transfers).to.have.lengthOf(1);
|
|
72
|
+
expect(intents[0].transfers[0].token).to.be.equal(inputs.token);
|
|
73
|
+
expect(intents[0].transfers[0].amount).to.be.equal(inputs.amount);
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
For full
|
|
76
|
+
For full function testing guide and examples please visit [docs.mimic.fi](https://docs.mimic.fi/)
|
|
77
77
|
|
|
78
78
|
## Security
|
|
79
79
|
|
|
@@ -87,7 +87,6 @@ for the safety of the protocol, please contact us through <a href="mailto:securi
|
|
|
87
87
|
This project is licensed under the GNU General Public License v3.0.
|
|
88
88
|
See the [LICENSE](../../LICENSE) file for details.
|
|
89
89
|
|
|
90
|
-
|
|
91
90
|
---
|
|
92
91
|
|
|
93
92
|
> Website [mimic.fi](https://mimic.fi) ·
|
package/dist/RunnerMock.d.ts
CHANGED
|
@@ -2,13 +2,18 @@ export default class RunnerMock {
|
|
|
2
2
|
private instance;
|
|
3
3
|
private mockFolder;
|
|
4
4
|
private ENV_IMPORTS;
|
|
5
|
-
|
|
5
|
+
private LOG_IMPORTS;
|
|
6
|
+
constructor(functionFolder: string, mockFolder?: string);
|
|
6
7
|
private initializeWasmInstance;
|
|
7
8
|
private readJsonFile;
|
|
8
9
|
run(fnName?: string): void;
|
|
9
10
|
private createLogFn;
|
|
10
11
|
private logToFile;
|
|
11
12
|
private generateImports;
|
|
13
|
+
private getDefaultModuleImports;
|
|
14
|
+
private getDefaultEnvImports;
|
|
15
|
+
private getDefaultEvmImports;
|
|
16
|
+
private getDefaultSvmImports;
|
|
12
17
|
private patchStringInputs;
|
|
13
18
|
private createMockFunction;
|
|
14
19
|
private isParameterizedResponse;
|
package/dist/RunnerMock.js
CHANGED
|
@@ -28,35 +28,59 @@ const path_1 = require("path");
|
|
|
28
28
|
const validators_1 = require("./validators");
|
|
29
29
|
const LITTLE_ENDIAN = true;
|
|
30
30
|
class RunnerMock {
|
|
31
|
-
constructor(
|
|
31
|
+
constructor(functionFolder, mockFolder) {
|
|
32
32
|
this.ENV_IMPORTS = {
|
|
33
33
|
abort: (msgPtr, filePtr, line, col) => {
|
|
34
34
|
const msg = this.getStringFromMemory(msgPtr);
|
|
35
35
|
const file = this.getStringFromMemory(filePtr);
|
|
36
36
|
throw Error(`${msg} in ${file} (line ${line}, column ${col})`);
|
|
37
37
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
};
|
|
39
|
+
this.LOG_IMPORTS = {
|
|
40
|
+
_log: (level, msgPtr) => {
|
|
41
|
+
const msg = this.getStringFromMemory(msgPtr);
|
|
42
|
+
switch (level) {
|
|
43
|
+
case 0:
|
|
44
|
+
throw new Error(`[CRITICAL] ${msg}`);
|
|
45
|
+
case 1:
|
|
46
|
+
console.error(`[ERROR] ${msg}`);
|
|
47
|
+
break;
|
|
48
|
+
case 2:
|
|
49
|
+
console.warn(`[WARNING] ${msg}`);
|
|
50
|
+
break;
|
|
51
|
+
case 3:
|
|
52
|
+
console.info(`[INFO] ${msg}`);
|
|
53
|
+
break;
|
|
54
|
+
case 4:
|
|
55
|
+
console.debug(`[DEBUG] ${msg}`);
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
throw new Error(`Invalid log level: ${level}`);
|
|
59
|
+
}
|
|
41
60
|
},
|
|
42
61
|
};
|
|
43
|
-
this.mockFolder = mockFolder;
|
|
44
|
-
this.instance = this.initializeWasmInstance(
|
|
62
|
+
this.mockFolder = mockFolder || (0, path_1.join)(functionFolder, '..');
|
|
63
|
+
this.instance = this.initializeWasmInstance(functionFolder);
|
|
45
64
|
}
|
|
46
|
-
initializeWasmInstance(
|
|
65
|
+
initializeWasmInstance(functionFolder) {
|
|
47
66
|
try {
|
|
48
|
-
const
|
|
49
|
-
let { inputs, ...mock } = this.readJsonFile((0, path_1.join)(mockFolder, 'mock.json'), validators_1.MockConfigValidator);
|
|
67
|
+
const functionPath = (0, path_1.join)(functionFolder, 'function.wasm');
|
|
68
|
+
let { inputs, ...mock } = this.readJsonFile((0, path_1.join)(this.mockFolder, 'mock.json'), validators_1.MockConfigValidator);
|
|
50
69
|
inputs = inputs || {};
|
|
70
|
+
for (const [key, value] of Object.entries(inputs)) {
|
|
71
|
+
if (typeof value === 'object' && value !== null) {
|
|
72
|
+
inputs[key] = JSON.stringify(value);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
51
75
|
const imports = this.generateImports(mock, inputs);
|
|
52
|
-
const wasmBuffer = fs.readFileSync(
|
|
76
|
+
const wasmBuffer = fs.readFileSync(functionPath);
|
|
53
77
|
const wasmModule = new WebAssembly.Module(wasmBuffer);
|
|
54
78
|
const instance = new WebAssembly.Instance(wasmModule, imports);
|
|
55
79
|
this.patchStringInputs(inputs, imports, instance);
|
|
56
80
|
return instance;
|
|
57
81
|
}
|
|
58
82
|
catch (error) {
|
|
59
|
-
throw new Error(`Failed to initialize
|
|
83
|
+
throw new Error(`Failed to initialize WASM instance: ${error}`);
|
|
60
84
|
}
|
|
61
85
|
}
|
|
62
86
|
readJsonFile(filePath, validator) {
|
|
@@ -83,16 +107,14 @@ class RunnerMock {
|
|
|
83
107
|
run(fnName = 'main') {
|
|
84
108
|
try {
|
|
85
109
|
const fn = this.instance.exports[fnName];
|
|
86
|
-
if (typeof fn
|
|
87
|
-
fn();
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
110
|
+
if (typeof fn !== 'function') {
|
|
90
111
|
const availableExports = Object.keys(this.instance.exports).join(', ');
|
|
91
112
|
throw Error(`No "${fnName}" found in exports. Available exports: ${availableExports}`);
|
|
92
113
|
}
|
|
114
|
+
fn();
|
|
93
115
|
}
|
|
94
116
|
catch (error) {
|
|
95
|
-
throw Error(`
|
|
117
|
+
throw Error(`Function Execution Error - ${error}`);
|
|
96
118
|
}
|
|
97
119
|
}
|
|
98
120
|
createLogFn(call) {
|
|
@@ -108,9 +130,9 @@ class RunnerMock {
|
|
|
108
130
|
generateImports(mock, inputs) {
|
|
109
131
|
const importModules = {};
|
|
110
132
|
const variableImports = {};
|
|
111
|
-
for (const moduleName of ['environment', 'evm']) {
|
|
133
|
+
for (const moduleName of ['environment', 'evm', 'svm']) {
|
|
112
134
|
const moduleMocks = mock[moduleName] ?? {};
|
|
113
|
-
const moduleImports =
|
|
135
|
+
const moduleImports = this.getDefaultModuleImports(moduleName);
|
|
114
136
|
for (const [functionName, mockValue] of Object.entries(moduleMocks)) {
|
|
115
137
|
moduleImports[functionName] = this.createMockFunction(functionName, mockValue);
|
|
116
138
|
}
|
|
@@ -123,9 +145,45 @@ class RunnerMock {
|
|
|
123
145
|
return {
|
|
124
146
|
...importModules,
|
|
125
147
|
env: this.ENV_IMPORTS,
|
|
148
|
+
log: this.LOG_IMPORTS,
|
|
126
149
|
index: variableImports,
|
|
127
150
|
};
|
|
128
151
|
}
|
|
152
|
+
getDefaultModuleImports(moduleName) {
|
|
153
|
+
if (moduleName === 'evm')
|
|
154
|
+
return this.getDefaultEvmImports();
|
|
155
|
+
if (moduleName === 'svm')
|
|
156
|
+
return this.getDefaultSvmImports();
|
|
157
|
+
if (moduleName === 'environment')
|
|
158
|
+
return this.getDefaultEnvImports();
|
|
159
|
+
return {};
|
|
160
|
+
}
|
|
161
|
+
getDefaultEnvImports() {
|
|
162
|
+
const defaultResult = (data) => '{"success":"true","data":' + JSON.stringify(data) + ',"error":""}';
|
|
163
|
+
return {
|
|
164
|
+
_evmCall: this.createLogFn('_evmCall'),
|
|
165
|
+
_svmCall: this.createLogFn('_svmCall'),
|
|
166
|
+
_swap: this.createLogFn('_swap'),
|
|
167
|
+
_transfer: this.createLogFn('_transfer'),
|
|
168
|
+
_tokenPriceQuery: this.createMockFunction('_tokenPriceQuery', { default: defaultResult([]) }),
|
|
169
|
+
_relevantTokensQuery: this.createMockFunction('_relevantTokensQuery', { default: defaultResult([]) }),
|
|
170
|
+
_evmCallQuery: this.createMockFunction('_evmCallQuery', { default: defaultResult('0x') }),
|
|
171
|
+
_svmAccountsInfoQuery: this.createMockFunction('_svmAccountsInfoQuery', { default: defaultResult([]) }),
|
|
172
|
+
_getContext: this.createMockFunction('_getContext', { default: '' }),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
getDefaultEvmImports() {
|
|
176
|
+
return {
|
|
177
|
+
_encode: this.createMockFunction('_encode', { default: '0x' }),
|
|
178
|
+
_decode: this.createMockFunction('_decode', { default: '0x' }),
|
|
179
|
+
_keccak: this.createMockFunction('_keccak', { default: '0xabcd' }),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
getDefaultSvmImports() {
|
|
183
|
+
return {
|
|
184
|
+
_findProgramAddress: this.createMockFunction('_findProgramAddress', { default: '' }),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
129
187
|
patchStringInputs(inputs, imports, instance) {
|
|
130
188
|
for (const [key, value] of Object.entries(inputs)) {
|
|
131
189
|
if (typeof value === 'string') {
|
|
@@ -135,15 +193,11 @@ class RunnerMock {
|
|
|
135
193
|
}
|
|
136
194
|
}
|
|
137
195
|
createMockFunction(functionName, mockValue) {
|
|
138
|
-
if (mockValue === 'log')
|
|
196
|
+
if (mockValue === 'log')
|
|
139
197
|
return this.createLogFn(functionName);
|
|
140
|
-
|
|
141
|
-
else if (this.isParameterizedResponse(mockValue)) {
|
|
198
|
+
if (this.isParameterizedResponse(mockValue))
|
|
142
199
|
return this.createParameterizedFunction(functionName, mockValue);
|
|
143
|
-
|
|
144
|
-
else {
|
|
145
|
-
return this.createConstantFunction(String(mockValue));
|
|
146
|
-
}
|
|
200
|
+
return this.createConstantFunction(String(mockValue));
|
|
147
201
|
}
|
|
148
202
|
isParameterizedResponse(value) {
|
|
149
203
|
const result = validators_1.ParameterizedResponseValidator.safeParse(value);
|
|
@@ -163,7 +217,7 @@ class RunnerMock {
|
|
|
163
217
|
result = this.writeStringToMemory(config.default);
|
|
164
218
|
}
|
|
165
219
|
else {
|
|
166
|
-
throw new Error(`No response defined for parameter "${param}" in function "${functionName}"
|
|
220
|
+
throw new Error(`No response defined for parameter "${param}" in function "${functionName}".`);
|
|
167
221
|
}
|
|
168
222
|
if (config.log === true) {
|
|
169
223
|
this.logToFile(functionName, param);
|
package/dist/RunnerMock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RunnerMock.js","sourceRoot":"","sources":["../src/RunnerMock.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"RunnerMock.js","sourceRoot":"","sources":["../src/RunnerMock.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,uCAAwB;AACxB,+BAA2B;AAG3B,6CAAkF;AAElF,MAAM,aAAa,GAAG,IAAI,CAAA;AAE1B,MAAqB,UAAU;IAkC7B,YAAY,cAAsB,EAAE,UAAmB;QA/B/C,gBAAW,GAAG;YACpB,KAAK,EAAE,CAAC,MAAc,EAAE,OAAe,EAAE,IAAY,EAAE,GAAW,EAAE,EAAE;gBACpE,MAAM,GAAG,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAA;gBAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;gBAC9C,MAAM,KAAK,CAAC,GAAG,GAAG,OAAO,IAAI,UAAU,IAAI,YAAY,GAAG,GAAG,CAAC,CAAA;YAChE,CAAC;SACF,CAAA;QACO,gBAAW,GAAG;YACpB,IAAI,EAAE,CAAC,KAAa,EAAE,MAAc,EAAE,EAAE;gBACtC,MAAM,GAAG,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAA;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,MAAM,CAAC,MAAM,CAAC,CAAA;QACxC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,EAAE,aAAa,CAAC,CAAA;QACpD,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC,CAAA;QACtD,OAAO,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAClD,CAAC;IAEO,mBAAmB,CAAC,GAAW,EAAE,QAAQ,GAAG,IAAI,CAAC,QAAQ;QAC/D,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAA4B,CAAA;QAC5D,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAyB,CAAA;QAEzD,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;QAE/E,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAW,CAAA;QAC/C,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QAClE,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAE7D,OAAO,GAAG,CAAA;IACZ,CAAC;CACF;AAxPD,6BAwPC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.RunnerMock = void 0;
|
|
21
|
-
__exportStar(require("./run-
|
|
21
|
+
__exportStar(require("./run-function"), exports);
|
|
22
22
|
var RunnerMock_1 = require("./RunnerMock");
|
|
23
23
|
Object.defineProperty(exports, "RunnerMock", { enumerable: true, get: function () { return __importDefault(RunnerMock_1).default; } });
|
|
24
24
|
__exportStar(require("./types"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,2CAAoD;AAA3C,yHAAA,OAAO,OAAc;AAC9B,0CAAuB"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { OracleQueryParams, OracleQueryResult } from '@mimicprotocol/sdk';
|
|
2
|
+
import { EvmCallQueryRequest, EvmCallQueryResponse, QueryProcessor } from '../types';
|
|
3
|
+
export declare const evmCallQueryProcessor: QueryProcessor<EvmCallQueryRequest, EvmCallQueryResponse, OracleQueryParams<'EvmCallQuery'>, OracleQueryResult<'EvmCallQuery'>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.evmCallQueryProcessor = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const validators_1 = require("../validators");
|
|
6
|
+
exports.evmCallQueryProcessor = {
|
|
7
|
+
queryName: 'EvmCallQuery',
|
|
8
|
+
queryTypeLabel: 'contract call entry',
|
|
9
|
+
requestValidator: validators_1.EvmCallRequestValidator,
|
|
10
|
+
responseValidator: validators_1.EvmCallTypedValueValidator,
|
|
11
|
+
transformParams: (req, timestamp) => {
|
|
12
|
+
const data = req.params
|
|
13
|
+
? (0, ethers_1.concat)([req.fnSelector, ...req.params.map((p) => ethers_1.AbiCoder.defaultAbiCoder().encode([p.abiType], [p.value]))])
|
|
14
|
+
: req.fnSelector;
|
|
15
|
+
return {
|
|
16
|
+
to: req.to,
|
|
17
|
+
chainId: req.chainId,
|
|
18
|
+
data,
|
|
19
|
+
timestamp: req.timestamp ?? timestamp,
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
transformResponse: (res) => ethers_1.AbiCoder.defaultAbiCoder().encode([res.abiType], [res.value]),
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=evm-call.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm-call.js","sourceRoot":"","sources":["../../src/processors/evm-call.ts"],"names":[],"mappings":";;;AACA,mCAAyC;AAGzC,8CAAmF;AAEtE,QAAA,qBAAqB,GAK9B;IACF,SAAS,EAAE,cAAc;IACzB,cAAc,EAAE,qBAAqB;IACrC,gBAAgB,EAAE,oCAAuB;IACzC,iBAAiB,EAAE,uCAA0B;IAC7C,eAAe,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE;QAClC,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM;YACrB,CAAC,CAAC,IAAA,eAAM,EAAC,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAQ,CAAC,eAAe,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/G,CAAC,CAAC,GAAG,CAAC,UAAU,CAAA;QAClB,OAAO;YACL,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,IAAI;YACJ,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,SAAS;SACtC,CAAA;IACH,CAAC;IACD,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,iBAAQ,CAAC,eAAe,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CAC1F,CAAA"}
|
|
@@ -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("./evm-call"), exports);
|
|
18
|
+
__exportStar(require("./price"), exports);
|
|
19
|
+
__exportStar(require("./relevant-tokens"), exports);
|
|
20
|
+
__exportStar(require("./subgraph"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/processors/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,0CAAuB;AACvB,oDAAiC;AACjC,6CAA0B"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { OracleQueryParams, OracleQueryResult } from '@mimicprotocol/sdk';
|
|
2
|
+
import { QueryProcessor, TokenPriceQueryRequest, TokenPriceQueryResponse } from '../types';
|
|
3
|
+
export declare const priceQueryProcessor: QueryProcessor<TokenPriceQueryRequest, TokenPriceQueryResponse, OracleQueryParams<'TokenPriceQuery'>, OracleQueryResult<'TokenPriceQuery'>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.priceQueryProcessor = void 0;
|
|
4
|
+
const validators_1 = require("../validators");
|
|
5
|
+
exports.priceQueryProcessor = {
|
|
6
|
+
queryName: 'TokenPriceQuery',
|
|
7
|
+
queryTypeLabel: 'price entry',
|
|
8
|
+
requestValidator: validators_1.TokenPriceRequestValidator,
|
|
9
|
+
responseValidator: validators_1.TokenPriceResponseValidator,
|
|
10
|
+
transformParams: (req, timestamp) => ({
|
|
11
|
+
token: req.token,
|
|
12
|
+
timestamp: req.timestamp ?? timestamp,
|
|
13
|
+
}),
|
|
14
|
+
transformResponse: (res) => res[0],
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=price.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../src/processors/price.ts"],"names":[],"mappings":";;;AAGA,8CAAuF;AAE1E,QAAA,mBAAmB,GAK5B;IACF,SAAS,EAAE,iBAAiB;IAC5B,cAAc,EAAE,aAAa;IAC7B,gBAAgB,EAAE,uCAA0B;IAC5C,iBAAiB,EAAE,wCAA2B;IAC9C,eAAe,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;QACpC,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,SAAS;KACtC,CAAC;IACF,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACnC,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { OracleQueryParams, OracleQueryResult } from '@mimicprotocol/sdk';
|
|
2
|
+
import { QueryProcessor, RelevantTokensQueryRequest, RelevantTokensQueryResponse } from '../types';
|
|
3
|
+
export declare const relevantTokensQueryProcessor: QueryProcessor<RelevantTokensQueryRequest, RelevantTokensQueryResponse[], OracleQueryParams<'RelevantTokensQuery'>, OracleQueryResult<'RelevantTokensQuery'>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.relevantTokensQueryProcessor = void 0;
|
|
4
|
+
const sdk_1 = require("@mimicprotocol/sdk");
|
|
5
|
+
const validators_1 = require("../validators");
|
|
6
|
+
exports.relevantTokensQueryProcessor = {
|
|
7
|
+
queryName: 'RelevantTokensQuery',
|
|
8
|
+
queryTypeLabel: 'relevant tokens entry',
|
|
9
|
+
requestValidator: validators_1.RelevantTokensRequestValidator,
|
|
10
|
+
responseValidator: sdk_1.z.array(validators_1.RelevantTokensResponseValidator),
|
|
11
|
+
transformParams: (req) => req,
|
|
12
|
+
transformResponse: (res) => res[0],
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=relevant-tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relevant-tokens.js","sourceRoot":"","sources":["../../src/processors/relevant-tokens.ts"],"names":[],"mappings":";;;AAAA,4CAA4E;AAG5E,8CAA+F;AAElF,QAAA,4BAA4B,GAKrC;IACF,SAAS,EAAE,qBAAqB;IAChC,cAAc,EAAE,uBAAuB;IACvC,gBAAgB,EAAE,2CAA8B;IAChD,iBAAiB,EAAE,OAAC,CAAC,KAAK,CAAC,4CAA+B,CAAC;IAC3D,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG;IAC7B,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACnC,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { OracleQueryParams, OracleQueryResult } from '@mimicprotocol/sdk';
|
|
2
|
+
import { QueryProcessor, SubgraphQueryRequest, SubgraphQueryResponse } from '../types';
|
|
3
|
+
export declare const subgraphQueryProcessor: QueryProcessor<SubgraphQueryRequest, SubgraphQueryResponse, OracleQueryParams<'SubgraphQuery'>, OracleQueryResult<'SubgraphQuery'>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subgraphQueryProcessor = void 0;
|
|
4
|
+
const validators_1 = require("../validators");
|
|
5
|
+
exports.subgraphQueryProcessor = {
|
|
6
|
+
queryName: 'SubgraphQuery',
|
|
7
|
+
queryTypeLabel: 'subgraph query entry',
|
|
8
|
+
requestValidator: validators_1.SubgraphQueryRequestValidator,
|
|
9
|
+
responseValidator: validators_1.SubgraphQueryResponseValidator,
|
|
10
|
+
transformParams: (req, timestamp) => ({
|
|
11
|
+
...req,
|
|
12
|
+
timestamp: req.timestamp ?? timestamp,
|
|
13
|
+
}),
|
|
14
|
+
transformResponse: (res) => res,
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=subgraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph.js","sourceRoot":"","sources":["../../src/processors/subgraph.ts"],"names":[],"mappings":";;;AAGA,8CAA6F;AAEhF,QAAA,sBAAsB,GAK/B;IACF,SAAS,EAAE,eAAe;IAC1B,cAAc,EAAE,sBAAsB;IACtC,gBAAgB,EAAE,0CAA6B;IAC/C,iBAAiB,EAAE,2CAA8B;IACjD,eAAe,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;QACpC,GAAG,GAAG;QACN,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,SAAS;KACtC,CAAC;IACF,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG;CAChC,CAAA"}
|