@dashevo/dapi-grpc 0.24.0-dev.6 → 0.25.0-dev.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.
- package/README.md +3 -3
- package/browser.js +13 -5
- package/clients/core/v0/nodejs/CorePromiseClient.js +2 -1
- package/clients/core/v0/nodejs/core_protoc.js +33 -33
- package/clients/core/v0/web/CorePromiseClient.js +159 -0
- package/clients/core/v0/web/core_pb.d.ts +783 -0
- package/clients/core/v0/web/core_pb.js +33 -33
- package/clients/core/v0/web/core_pb_service.d.ts +161 -0
- package/clients/core/v0/web/core_pb_service.js +317 -0
- package/clients/platform/v0/nodejs/PlatformPromiseClient.js +2 -1
- package/clients/platform/v0/nodejs/platform_pbjs.js +348 -20
- package/clients/platform/v0/nodejs/platform_protoc.js +131 -39
- package/clients/platform/v0/web/PlatformPromiseClient.js +130 -0
- package/clients/platform/v0/web/platform_pb.d.ts +608 -0
- package/clients/platform/v0/web/platform_pb.js +131 -39
- package/clients/platform/v0/web/platform_pb_service.d.ts +177 -0
- package/clients/platform/v0/web/platform_pb_service.js +301 -0
- package/lib/utils/parseMetadata.js +27 -0
- package/node.js +4 -0
- package/package.json +4 -4
- package/protos/platform/v0/platform.proto +6 -1
- package/scripts/build.sh +3 -3
- package/scripts/patch-protobuf-js.sh +30 -0
- package/clients/core/v0/web/core_grpc_web_pb.js +0 -499
- package/clients/platform/v0/web/platform_grpc_web_pb.js +0 -509
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
// package: org.dash.platform.dapi.v0
|
|
2
|
+
// file: platform.proto
|
|
3
|
+
|
|
4
|
+
var platform_pb = require("./platform_pb");
|
|
5
|
+
var grpc = require("@improbable-eng/grpc-web").grpc;
|
|
6
|
+
|
|
7
|
+
var Platform = (function () {
|
|
8
|
+
function Platform() {}
|
|
9
|
+
Platform.serviceName = "org.dash.platform.dapi.v0.Platform";
|
|
10
|
+
return Platform;
|
|
11
|
+
}());
|
|
12
|
+
|
|
13
|
+
Platform.broadcastStateTransition = {
|
|
14
|
+
methodName: "broadcastStateTransition",
|
|
15
|
+
service: Platform,
|
|
16
|
+
requestStream: false,
|
|
17
|
+
responseStream: false,
|
|
18
|
+
requestType: platform_pb.BroadcastStateTransitionRequest,
|
|
19
|
+
responseType: platform_pb.BroadcastStateTransitionResponse
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
Platform.getIdentity = {
|
|
23
|
+
methodName: "getIdentity",
|
|
24
|
+
service: Platform,
|
|
25
|
+
requestStream: false,
|
|
26
|
+
responseStream: false,
|
|
27
|
+
requestType: platform_pb.GetIdentityRequest,
|
|
28
|
+
responseType: platform_pb.GetIdentityResponse
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
Platform.getDataContract = {
|
|
32
|
+
methodName: "getDataContract",
|
|
33
|
+
service: Platform,
|
|
34
|
+
requestStream: false,
|
|
35
|
+
responseStream: false,
|
|
36
|
+
requestType: platform_pb.GetDataContractRequest,
|
|
37
|
+
responseType: platform_pb.GetDataContractResponse
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
Platform.getDocuments = {
|
|
41
|
+
methodName: "getDocuments",
|
|
42
|
+
service: Platform,
|
|
43
|
+
requestStream: false,
|
|
44
|
+
responseStream: false,
|
|
45
|
+
requestType: platform_pb.GetDocumentsRequest,
|
|
46
|
+
responseType: platform_pb.GetDocumentsResponse
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
Platform.getIdentitiesByPublicKeyHashes = {
|
|
50
|
+
methodName: "getIdentitiesByPublicKeyHashes",
|
|
51
|
+
service: Platform,
|
|
52
|
+
requestStream: false,
|
|
53
|
+
responseStream: false,
|
|
54
|
+
requestType: platform_pb.GetIdentitiesByPublicKeyHashesRequest,
|
|
55
|
+
responseType: platform_pb.GetIdentitiesByPublicKeyHashesResponse
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
Platform.waitForStateTransitionResult = {
|
|
59
|
+
methodName: "waitForStateTransitionResult",
|
|
60
|
+
service: Platform,
|
|
61
|
+
requestStream: false,
|
|
62
|
+
responseStream: false,
|
|
63
|
+
requestType: platform_pb.WaitForStateTransitionResultRequest,
|
|
64
|
+
responseType: platform_pb.WaitForStateTransitionResultResponse
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
Platform.getConsensusParams = {
|
|
68
|
+
methodName: "getConsensusParams",
|
|
69
|
+
service: Platform,
|
|
70
|
+
requestStream: false,
|
|
71
|
+
responseStream: false,
|
|
72
|
+
requestType: platform_pb.GetConsensusParamsRequest,
|
|
73
|
+
responseType: platform_pb.GetConsensusParamsResponse
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
exports.Platform = Platform;
|
|
77
|
+
|
|
78
|
+
function PlatformClient(serviceHost, options) {
|
|
79
|
+
this.serviceHost = serviceHost;
|
|
80
|
+
this.options = options || {};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
PlatformClient.prototype.broadcastStateTransition = function broadcastStateTransition(requestMessage, metadata, callback) {
|
|
84
|
+
if (arguments.length === 2) {
|
|
85
|
+
callback = arguments[1];
|
|
86
|
+
}
|
|
87
|
+
var client = grpc.unary(Platform.broadcastStateTransition, {
|
|
88
|
+
request: requestMessage,
|
|
89
|
+
host: this.serviceHost,
|
|
90
|
+
metadata: metadata,
|
|
91
|
+
transport: this.options.transport,
|
|
92
|
+
debug: this.options.debug,
|
|
93
|
+
onEnd: function (response) {
|
|
94
|
+
if (callback) {
|
|
95
|
+
if (response.status !== grpc.Code.OK) {
|
|
96
|
+
var err = new Error(response.statusMessage);
|
|
97
|
+
err.code = response.status;
|
|
98
|
+
err.metadata = response.trailers;
|
|
99
|
+
callback(err, null);
|
|
100
|
+
} else {
|
|
101
|
+
callback(null, response.message);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
cancel: function () {
|
|
108
|
+
callback = null;
|
|
109
|
+
client.close();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
PlatformClient.prototype.getIdentity = function getIdentity(requestMessage, metadata, callback) {
|
|
115
|
+
if (arguments.length === 2) {
|
|
116
|
+
callback = arguments[1];
|
|
117
|
+
}
|
|
118
|
+
var client = grpc.unary(Platform.getIdentity, {
|
|
119
|
+
request: requestMessage,
|
|
120
|
+
host: this.serviceHost,
|
|
121
|
+
metadata: metadata,
|
|
122
|
+
transport: this.options.transport,
|
|
123
|
+
debug: this.options.debug,
|
|
124
|
+
onEnd: function (response) {
|
|
125
|
+
if (callback) {
|
|
126
|
+
if (response.status !== grpc.Code.OK) {
|
|
127
|
+
var err = new Error(response.statusMessage);
|
|
128
|
+
err.code = response.status;
|
|
129
|
+
err.metadata = response.trailers;
|
|
130
|
+
callback(err, null);
|
|
131
|
+
} else {
|
|
132
|
+
callback(null, response.message);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
cancel: function () {
|
|
139
|
+
callback = null;
|
|
140
|
+
client.close();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
PlatformClient.prototype.getDataContract = function getDataContract(requestMessage, metadata, callback) {
|
|
146
|
+
if (arguments.length === 2) {
|
|
147
|
+
callback = arguments[1];
|
|
148
|
+
}
|
|
149
|
+
var client = grpc.unary(Platform.getDataContract, {
|
|
150
|
+
request: requestMessage,
|
|
151
|
+
host: this.serviceHost,
|
|
152
|
+
metadata: metadata,
|
|
153
|
+
transport: this.options.transport,
|
|
154
|
+
debug: this.options.debug,
|
|
155
|
+
onEnd: function (response) {
|
|
156
|
+
if (callback) {
|
|
157
|
+
if (response.status !== grpc.Code.OK) {
|
|
158
|
+
var err = new Error(response.statusMessage);
|
|
159
|
+
err.code = response.status;
|
|
160
|
+
err.metadata = response.trailers;
|
|
161
|
+
callback(err, null);
|
|
162
|
+
} else {
|
|
163
|
+
callback(null, response.message);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
cancel: function () {
|
|
170
|
+
callback = null;
|
|
171
|
+
client.close();
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
PlatformClient.prototype.getDocuments = function getDocuments(requestMessage, metadata, callback) {
|
|
177
|
+
if (arguments.length === 2) {
|
|
178
|
+
callback = arguments[1];
|
|
179
|
+
}
|
|
180
|
+
var client = grpc.unary(Platform.getDocuments, {
|
|
181
|
+
request: requestMessage,
|
|
182
|
+
host: this.serviceHost,
|
|
183
|
+
metadata: metadata,
|
|
184
|
+
transport: this.options.transport,
|
|
185
|
+
debug: this.options.debug,
|
|
186
|
+
onEnd: function (response) {
|
|
187
|
+
if (callback) {
|
|
188
|
+
if (response.status !== grpc.Code.OK) {
|
|
189
|
+
var err = new Error(response.statusMessage);
|
|
190
|
+
err.code = response.status;
|
|
191
|
+
err.metadata = response.trailers;
|
|
192
|
+
callback(err, null);
|
|
193
|
+
} else {
|
|
194
|
+
callback(null, response.message);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
return {
|
|
200
|
+
cancel: function () {
|
|
201
|
+
callback = null;
|
|
202
|
+
client.close();
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
PlatformClient.prototype.getIdentitiesByPublicKeyHashes = function getIdentitiesByPublicKeyHashes(requestMessage, metadata, callback) {
|
|
208
|
+
if (arguments.length === 2) {
|
|
209
|
+
callback = arguments[1];
|
|
210
|
+
}
|
|
211
|
+
var client = grpc.unary(Platform.getIdentitiesByPublicKeyHashes, {
|
|
212
|
+
request: requestMessage,
|
|
213
|
+
host: this.serviceHost,
|
|
214
|
+
metadata: metadata,
|
|
215
|
+
transport: this.options.transport,
|
|
216
|
+
debug: this.options.debug,
|
|
217
|
+
onEnd: function (response) {
|
|
218
|
+
if (callback) {
|
|
219
|
+
if (response.status !== grpc.Code.OK) {
|
|
220
|
+
var err = new Error(response.statusMessage);
|
|
221
|
+
err.code = response.status;
|
|
222
|
+
err.metadata = response.trailers;
|
|
223
|
+
callback(err, null);
|
|
224
|
+
} else {
|
|
225
|
+
callback(null, response.message);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
return {
|
|
231
|
+
cancel: function () {
|
|
232
|
+
callback = null;
|
|
233
|
+
client.close();
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
PlatformClient.prototype.waitForStateTransitionResult = function waitForStateTransitionResult(requestMessage, metadata, callback) {
|
|
239
|
+
if (arguments.length === 2) {
|
|
240
|
+
callback = arguments[1];
|
|
241
|
+
}
|
|
242
|
+
var client = grpc.unary(Platform.waitForStateTransitionResult, {
|
|
243
|
+
request: requestMessage,
|
|
244
|
+
host: this.serviceHost,
|
|
245
|
+
metadata: metadata,
|
|
246
|
+
transport: this.options.transport,
|
|
247
|
+
debug: this.options.debug,
|
|
248
|
+
onEnd: function (response) {
|
|
249
|
+
if (callback) {
|
|
250
|
+
if (response.status !== grpc.Code.OK) {
|
|
251
|
+
var err = new Error(response.statusMessage);
|
|
252
|
+
err.code = response.status;
|
|
253
|
+
err.metadata = response.trailers;
|
|
254
|
+
callback(err, null);
|
|
255
|
+
} else {
|
|
256
|
+
callback(null, response.message);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
return {
|
|
262
|
+
cancel: function () {
|
|
263
|
+
callback = null;
|
|
264
|
+
client.close();
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
PlatformClient.prototype.getConsensusParams = function getConsensusParams(requestMessage, metadata, callback) {
|
|
270
|
+
if (arguments.length === 2) {
|
|
271
|
+
callback = arguments[1];
|
|
272
|
+
}
|
|
273
|
+
var client = grpc.unary(Platform.getConsensusParams, {
|
|
274
|
+
request: requestMessage,
|
|
275
|
+
host: this.serviceHost,
|
|
276
|
+
metadata: metadata,
|
|
277
|
+
transport: this.options.transport,
|
|
278
|
+
debug: this.options.debug,
|
|
279
|
+
onEnd: function (response) {
|
|
280
|
+
if (callback) {
|
|
281
|
+
if (response.status !== grpc.Code.OK) {
|
|
282
|
+
var err = new Error(response.statusMessage);
|
|
283
|
+
err.code = response.status;
|
|
284
|
+
err.metadata = response.trailers;
|
|
285
|
+
callback(err, null);
|
|
286
|
+
} else {
|
|
287
|
+
callback(null, response.message);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
return {
|
|
293
|
+
cancel: function () {
|
|
294
|
+
callback = null;
|
|
295
|
+
client.close();
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
exports.PlatformClient = PlatformClient;
|
|
301
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { Metadata: MetadataGrpcJS } = require('@grpc/grpc-js/build/src/metadata');
|
|
2
|
+
const { grpc: { Metadata: MetadataGrpcWeb } } = require('@improbable-eng/grpc-web');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {MetadataGrpcJS|MetadataGrpcWeb} metadata
|
|
7
|
+
* @return {{}|{[p: string]: string}}
|
|
8
|
+
*/
|
|
9
|
+
const parseMetadata = (metadata) => {
|
|
10
|
+
if (metadata instanceof MetadataGrpcJS) {
|
|
11
|
+
return metadata.getMap();
|
|
12
|
+
} if (metadata instanceof MetadataGrpcWeb) {
|
|
13
|
+
const parsedMetadata = {};
|
|
14
|
+
metadata.forEach((key, values) => {
|
|
15
|
+
// Mapping each key to the first value associated with it.
|
|
16
|
+
// This corresponds to the getMap() behaviour of the grpc-js Metadata class.
|
|
17
|
+
const [value] = values;
|
|
18
|
+
parsedMetadata[key] = value;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return parsedMetadata;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return metadata;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = parseMetadata;
|
package/node.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { Metadata } = require('@grpc/grpc-js/build/src/metadata');
|
|
1
2
|
const CorePromiseClient = require('./clients/core/v0/nodejs/CorePromiseClient');
|
|
2
3
|
const PlatformPromiseClient = require('./clients/platform/v0/nodejs/PlatformPromiseClient');
|
|
3
4
|
|
|
@@ -6,6 +7,7 @@ const protocPlatformMessages = require('./clients/platform/v0/nodejs/platform_pr
|
|
|
6
7
|
|
|
7
8
|
const getCoreDefinition = require('./lib/getCoreDefinition');
|
|
8
9
|
const getPlatformDefinition = require('./lib/getPlatformDefinition');
|
|
10
|
+
const parseMetadata = require('./lib/utils/parseMetadata');
|
|
9
11
|
|
|
10
12
|
const {
|
|
11
13
|
org: {
|
|
@@ -45,4 +47,6 @@ module.exports = {
|
|
|
45
47
|
...protocCoreMessages,
|
|
46
48
|
...protocPlatformMessages,
|
|
47
49
|
},
|
|
50
|
+
parseMetadata,
|
|
51
|
+
Metadata,
|
|
48
52
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-grpc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0-dev.2",
|
|
4
4
|
"description": "DAPI GRPC definition file and generated clients",
|
|
5
5
|
"browser": "browser.js",
|
|
6
6
|
"main": "node.js",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "yarn exec scripts/build.sh",
|
|
8
|
+
"build": "yarn exec scripts/build.sh && yarn exec scripts/patch-protobuf-js.sh",
|
|
9
9
|
"lint": "eslint .",
|
|
10
10
|
"prepublishOnly": "yarn run build",
|
|
11
11
|
"test": "yarn run test:unit",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/dashevo/dapi-grpc#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@dashevo/grpc-common": "0.
|
|
36
|
+
"@dashevo/grpc-common": "0.25.0-dev.2",
|
|
37
37
|
"@dashevo/protobufjs": "6.10.5",
|
|
38
38
|
"@grpc/grpc-js": "^1.3.7",
|
|
39
|
+
"@improbable-eng/grpc-web": "^0.15.0",
|
|
39
40
|
"google-protobuf": "^3.12.2",
|
|
40
|
-
"grpc-web": "1.2.1",
|
|
41
41
|
"long": "^5.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
@@ -2,6 +2,8 @@ syntax = "proto3";
|
|
|
2
2
|
|
|
3
3
|
package org.dash.platform.dapi.v0;
|
|
4
4
|
|
|
5
|
+
import "google/protobuf/timestamp.proto";
|
|
6
|
+
|
|
5
7
|
service Platform {
|
|
6
8
|
rpc broadcastStateTransition (BroadcastStateTransitionRequest) returns (BroadcastStateTransitionResponse);
|
|
7
9
|
rpc getIdentity (GetIdentityRequest) returns (GetIdentityResponse);
|
|
@@ -14,13 +16,16 @@ service Platform {
|
|
|
14
16
|
|
|
15
17
|
message Proof {
|
|
16
18
|
bytes merkle_proof = 1;
|
|
17
|
-
bytes
|
|
19
|
+
bytes quorum_hash = 2;
|
|
18
20
|
bytes signature = 3;
|
|
21
|
+
uint32 round = 4;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
message ResponseMetadata {
|
|
22
25
|
int64 height = 1;
|
|
23
26
|
uint32 core_chain_locked_height = 2;
|
|
27
|
+
uint64 time_ms = 3;
|
|
28
|
+
uint32 protocol_version = 4;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
message StateTransitionBroadcastError {
|
package/scripts/build.sh
CHANGED
|
@@ -18,7 +18,7 @@ PLATFORM_OBJ_C_OUT_PATH="$PLATFORM_CLIENTS_PATH/objective-c"
|
|
|
18
18
|
CORE_PYTHON_OUT_PATH="$CORE_CLIENTS_PATH/python"
|
|
19
19
|
PLATFORM_PYTHON_OUT_PATH="$PLATFORM_CLIENTS_PATH/python"
|
|
20
20
|
|
|
21
|
-
PROTOC_IMAGE="
|
|
21
|
+
PROTOC_IMAGE="rvolosatovs/protoc:4.0.0"
|
|
22
22
|
|
|
23
23
|
#################################################
|
|
24
24
|
# Generate JavaScript client for `Core` service #
|
|
@@ -31,7 +31,7 @@ docker run -v "$CORE_PROTO_PATH:$CORE_PROTO_PATH" \
|
|
|
31
31
|
--rm \
|
|
32
32
|
"$PROTOC_IMAGE" \
|
|
33
33
|
--js_out="import_style=commonjs:$CORE_WEB_OUT_PATH" \
|
|
34
|
-
--
|
|
34
|
+
--ts_out="service=grpc-web:$CORE_WEB_OUT_PATH" \
|
|
35
35
|
-I="$CORE_PROTO_PATH" \
|
|
36
36
|
"core.proto"
|
|
37
37
|
|
|
@@ -63,7 +63,7 @@ docker run -v "$PLATFORM_PROTO_PATH:$PLATFORM_PROTO_PATH" \
|
|
|
63
63
|
--rm \
|
|
64
64
|
"$PROTOC_IMAGE" \
|
|
65
65
|
--js_out="import_style=commonjs:$PLATFORM_WEB_OUT_PATH" \
|
|
66
|
-
--
|
|
66
|
+
--ts_out="service=grpc-web:$PLATFORM_WEB_OUT_PATH" \
|
|
67
67
|
-I="$PLATFORM_PROTO_PATH" \
|
|
68
68
|
"platform.proto"
|
|
69
69
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
files=$(find "$PWD/clients/core/v0/web" "$PWD/clients/core/v0/nodejs" "$PWD/clients/platform/v0/web" "$PWD/clients/platform/v0/nodejs" -name "*_pb.js" -o -name "*_protoc.js")
|
|
4
|
+
OS=$(uname)
|
|
5
|
+
|
|
6
|
+
function replace_in_file() {
|
|
7
|
+
if [ "$OS" = 'Darwin' ]; then
|
|
8
|
+
# for MacOS
|
|
9
|
+
sed -i '' -e "$1" "$2"
|
|
10
|
+
else
|
|
11
|
+
# for Linux and Windows
|
|
12
|
+
sed -i'' -e "$1" "$2"
|
|
13
|
+
fi
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
# Loop over the files
|
|
17
|
+
for file in $files
|
|
18
|
+
do
|
|
19
|
+
|
|
20
|
+
replace_in_file 's/var global = Function('\''return this'\'')();/const proto = {};/g' "$file"
|
|
21
|
+
if grep -qrE "[^a-zA-Z]Function\(" "$file"; then
|
|
22
|
+
echo "Error: Function( still present"
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
replace_in_file 's/, global);/, { proto });/g' "$file"
|
|
26
|
+
if grep -qrE '(^|[^a-zA-Z."])global([^a-zA-Z]|$)' "$file"; then
|
|
27
|
+
echo "Error: global still present"
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
done
|