@muritavo/testing-toolkit 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/emulator.d.ts +2 -2
- package/dist/client/emulator.js +16 -8
- package/dist/client/emulator.js.map +1 -1
- package/dist/client/utility.d.ts +7 -0
- package/dist/client/utility.js +39 -0
- package/dist/client/utility.js.map +1 -0
- package/dist/native/blockchain.d.ts +15 -0
- package/dist/native/blockchain.js +148 -0
- package/dist/native/blockchain.js.map +1 -0
- package/dist/native/consts.d.ts +5 -0
- package/dist/native/consts.js +9 -0
- package/dist/native/consts.js.map +1 -0
- package/dist/native/emulator.d.ts +16 -1
- package/dist/native/emulator.js +67 -8
- package/dist/native/emulator.js.map +1 -1
- package/dist/types/contract.d.ts +19 -18
- package/dist/types/contract.js +1 -2
- package/dist/types/contract.js.map +1 -1
- package/package.json +11 -3
|
@@ -10,7 +10,7 @@ export declare const deleteCollection: (projectId: string, collectionPath: strin
|
|
|
10
10
|
* @param projectId The current project id of the emulator instance
|
|
11
11
|
* @param cb The callback to be executed
|
|
12
12
|
*/
|
|
13
|
-
export declare const setupEmulator: (projectId: string, cb: (firestore: firebase.firestore.Firestore) => Promise<void
|
|
13
|
+
export declare const setupEmulator: (projectId: string, cb: (firestore: firebase.firestore.Firestore, storage: firebase.storage.Storage) => Promise<void>, storageBucket?: string) => Promise<void>;
|
|
14
14
|
/**
|
|
15
15
|
* Creates a user on the auth emulator allowing him to authenticate to the emulator
|
|
16
16
|
* @param projectId The current project id of the emulator instance
|
|
@@ -56,7 +56,7 @@ declare const FirebaseConfigEmulatorsShapeExample: {
|
|
|
56
56
|
readonly port: number;
|
|
57
57
|
};
|
|
58
58
|
readonly ui: {
|
|
59
|
-
readonly enabled:
|
|
59
|
+
readonly enabled: boolean;
|
|
60
60
|
readonly port: number;
|
|
61
61
|
};
|
|
62
62
|
};
|
package/dist/client/emulator.js
CHANGED
|
@@ -35,10 +35,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
38
41
|
exports.__esModule = true;
|
|
39
42
|
exports.clearFirestore = exports.setEmulatorConfig = exports.clearAuth = exports.addAuthUser = exports.setupEmulator = exports.deleteCollection = void 0;
|
|
40
|
-
var node_fetch_1 = require("node-fetch");
|
|
43
|
+
var node_fetch_1 = __importDefault(require("node-fetch"));
|
|
41
44
|
var rules_unit_testing_1 = require("@firebase/rules-unit-testing");
|
|
45
|
+
var consts_1 = require("../native/consts");
|
|
42
46
|
var emulatorConfig;
|
|
43
47
|
/**
|
|
44
48
|
* Deletes a collection from firebase
|
|
@@ -48,7 +52,7 @@ var emulatorConfig;
|
|
|
48
52
|
var deleteCollection = function (projectId, collectionPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
53
|
return __generator(this, function (_a) {
|
|
50
54
|
switch (_a.label) {
|
|
51
|
-
case 0: return [4 /*yield*/, (0, node_fetch_1["default"])("http://
|
|
55
|
+
case 0: return [4 /*yield*/, (0, node_fetch_1["default"])("http://".concat(consts_1.LOCALHOST_DOMAIN, ":").concat(_getPort("firestore"), "/emulator/v1/projects/").concat(projectId, "/databases/(default)/documents").concat(collectionPath), {
|
|
52
56
|
method: "delete"
|
|
53
57
|
})];
|
|
54
58
|
case 1:
|
|
@@ -63,15 +67,19 @@ exports.deleteCollection = deleteCollection;
|
|
|
63
67
|
* @param projectId The current project id of the emulator instance
|
|
64
68
|
* @param cb The callback to be executed
|
|
65
69
|
*/
|
|
66
|
-
var setupEmulator = function (projectId, cb) { return __awaiter(void 0, void 0, void 0, function () {
|
|
70
|
+
var setupEmulator = function (projectId, cb, storageBucket) { return __awaiter(void 0, void 0, void 0, function () {
|
|
67
71
|
var testEnv;
|
|
68
72
|
return __generator(this, function (_a) {
|
|
69
73
|
switch (_a.label) {
|
|
70
74
|
case 0: return [4 /*yield*/, (0, rules_unit_testing_1.initializeTestEnvironment)({
|
|
71
75
|
projectId: projectId,
|
|
72
76
|
firestore: {
|
|
73
|
-
host:
|
|
77
|
+
host: consts_1.LOCALHOST_DOMAIN,
|
|
74
78
|
port: _getPort("firestore")
|
|
79
|
+
},
|
|
80
|
+
storage: {
|
|
81
|
+
host: consts_1.LOCALHOST_DOMAIN,
|
|
82
|
+
port: _getPort("storage")
|
|
75
83
|
}
|
|
76
84
|
})];
|
|
77
85
|
case 1:
|
|
@@ -82,7 +90,7 @@ var setupEmulator = function (projectId, cb) { return __awaiter(void 0, void 0,
|
|
|
82
90
|
case 0: return [4 /*yield*/, cb(ctx.firestore({
|
|
83
91
|
experimentalForceLongPolling: true,
|
|
84
92
|
merge: true
|
|
85
|
-
}))];
|
|
93
|
+
}), ctx.storage(storageBucket))];
|
|
86
94
|
case 1:
|
|
87
95
|
_a.sent();
|
|
88
96
|
return [2 /*return*/];
|
|
@@ -109,7 +117,7 @@ var addAuthUser = function (projectId, email, password, localId) {
|
|
|
109
117
|
var result;
|
|
110
118
|
return __generator(this, function (_a) {
|
|
111
119
|
switch (_a.label) {
|
|
112
|
-
case 0: return [4 /*yield*/, (0, node_fetch_1["default"])("http://
|
|
120
|
+
case 0: return [4 /*yield*/, (0, node_fetch_1["default"])("http://".concat(consts_1.LOCALHOST_DOMAIN, ":").concat(_getPort("auth"), "/identitytoolkit.googleapis.com/v1/projects/").concat(projectId, "/accounts"), {
|
|
113
121
|
body: JSON.stringify({
|
|
114
122
|
email: email,
|
|
115
123
|
password: password,
|
|
@@ -140,7 +148,7 @@ var clearAuth = function (projectId) { return __awaiter(void 0, void 0, void 0,
|
|
|
140
148
|
var result;
|
|
141
149
|
return __generator(this, function (_a) {
|
|
142
150
|
switch (_a.label) {
|
|
143
|
-
case 0: return [4 /*yield*/, (0, node_fetch_1["default"])("http://
|
|
151
|
+
case 0: return [4 /*yield*/, (0, node_fetch_1["default"])("http://".concat(consts_1.LOCALHOST_DOMAIN, ":").concat(_getPort("auth"), "/emulator/v1/projects/").concat(projectId, "/accounts"), {
|
|
144
152
|
method: "delete"
|
|
145
153
|
})];
|
|
146
154
|
case 1:
|
|
@@ -171,7 +179,7 @@ var clearFirestore = function (projectId) { return __awaiter(void 0, void 0, voi
|
|
|
171
179
|
case 0: return [4 /*yield*/, (0, rules_unit_testing_1.initializeTestEnvironment)({
|
|
172
180
|
projectId: projectId,
|
|
173
181
|
firestore: {
|
|
174
|
-
host:
|
|
182
|
+
host: consts_1.LOCALHOST_DOMAIN,
|
|
175
183
|
port: _getPort("firestore")
|
|
176
184
|
}
|
|
177
185
|
})];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../../src/client/emulator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../../src/client/emulator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAmC;AACnC,mEAAyE;AAEzE,2CAAoD;AAEpD,IAAI,cAAmC,CAAC;AAExC;;;;GAIG;AACI,IAAM,gBAAgB,GAAG,UAC9B,SAAiB,EACjB,cAAsB;;;oBAEtB,qBAAM,IAAA,uBAAS,EACb,iBAAU,yBAAgB,cAAI,QAAQ,CACpC,WAAW,CACZ,mCAAyB,SAAS,2CAAiC,cAAc,CAAE,EACpF;oBACE,MAAM,EAAE,QAAQ;iBACjB,CACF,EAAA;;gBAPD,SAOC,CAAC;;;;KACH,CAAC;AAZW,QAAA,gBAAgB,oBAY3B;AAEF;;;;GAIG;AACI,IAAM,aAAa,GAAG,UAC3B,SAAiB,EACjB,EAGkB,EAClB,aAAsB;;;;oBAEN,qBAAM,IAAA,8CAAyB,EAAC;oBAC9C,SAAS,EAAE,SAA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F,OAAO,EAAE,IAAe;YACxB,IAAI,EAAE,IAAc;SACrB;KACF;CACO,CAAC;AAIX;;;;GAIG;AACH,SAAS,QAAQ,CAAC,QAAgD;IAChE,IAAI,CAAC,cAAc,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,gSASnB,CAAC,CAAC;KACA;IACD,IAAM,iBAAiB,GAAG,cAAc,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC7D,IAAI,CAAC,iBAAiB,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE;QACjD,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;KAC9C;IACD,OAAO,iBAAiB,CAAC,IAAI,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an random colored image with specified width, height and quality
|
|
3
|
+
* @param width width of the image
|
|
4
|
+
* @param height height of the image
|
|
5
|
+
* @param quality quality of the image
|
|
6
|
+
*/
|
|
7
|
+
export declare const generateImage: (cols: number, rows: number, strRandom: string, orientation?: "vertical" | "horizontal") => any;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.generateImage = void 0;
|
|
4
|
+
var text2png = require("text2png");
|
|
5
|
+
var firstEmoji = 0x1f604;
|
|
6
|
+
var emojisCount = 0x1f64f - firstEmoji;
|
|
7
|
+
/**
|
|
8
|
+
* Generates an random colored image with specified width, height and quality
|
|
9
|
+
* @param width width of the image
|
|
10
|
+
* @param height height of the image
|
|
11
|
+
* @param quality quality of the image
|
|
12
|
+
*/
|
|
13
|
+
var generateImage = function (cols, rows, strRandom, orientation) {
|
|
14
|
+
if (orientation === void 0) { orientation = "vertical"; }
|
|
15
|
+
strRandom =
|
|
16
|
+
orientation === "vertical" ? strRandom : "".concat(strRandom).concat(orientation);
|
|
17
|
+
var numFromStr = strRandom
|
|
18
|
+
.split("")
|
|
19
|
+
.reduce(function (r, char) { return r + char.charCodeAt(0); }, 0);
|
|
20
|
+
var rest = numFromStr % emojisCount;
|
|
21
|
+
var e = function (i) { return String.fromCodePoint(firstEmoji + rest + i); };
|
|
22
|
+
var template = "";
|
|
23
|
+
for (var i = 0; i < rows; i++) {
|
|
24
|
+
for (var c = 0; c < cols; c++) {
|
|
25
|
+
template += e(cols * i + c);
|
|
26
|
+
}
|
|
27
|
+
template += "\n";
|
|
28
|
+
}
|
|
29
|
+
var instance = text2png(template, {
|
|
30
|
+
output: "dataURL",
|
|
31
|
+
padding: 10,
|
|
32
|
+
font: "50px monospace",
|
|
33
|
+
color: "rgb(".concat(256 - (rest % 256), ", ").concat(256 - (numFromStr % 256), ", ").concat(256 - (Math.abs(numFromStr - rest) % 256), ")"),
|
|
34
|
+
backgroundColor: "rgb(".concat(rest % 256, ", ").concat(numFromStr % 256, ", ").concat(Math.abs(numFromStr - rest) % 256, ")")
|
|
35
|
+
});
|
|
36
|
+
return instance;
|
|
37
|
+
};
|
|
38
|
+
exports.generateImage = generateImage;
|
|
39
|
+
//# sourceMappingURL=utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../src/client/utility.ts"],"names":[],"mappings":";;;AAAA,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEnC,IAAM,UAAU,GAAG,OAAO,CAAC;AAC3B,IAAM,WAAW,GAAG,OAAO,GAAG,UAAU,CAAC;AAEzC;;;;;GAKG;AACI,IAAM,aAAa,GAAG,UAC3B,IAAY,EACZ,IAAY,EACZ,SAAiB,EACjB,WAAmD;IAAnD,4BAAA,EAAA,wBAAmD;IAEnD,SAAS;QACP,WAAW,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAG,SAAS,SAAG,WAAW,CAAE,CAAC;IACxE,IAAM,UAAU,GAAG,SAAS;SACzB,KAAK,CAAC,EAAE,CAAC;SACT,MAAM,CAAC,UAA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= {
|
|
2
|
+
[address: string]: {
|
|
3
|
+
balance: number;
|
|
4
|
+
unlocked: number;
|
|
5
|
+
secretKey: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare function startBlockchainNode(nftContractsProjectFolder: string): Promise<Addresses>;
|
|
9
|
+
export declare function deployContract(contractName: string, ...initializationArgs: any[]): Promise<{
|
|
10
|
+
address: string;
|
|
11
|
+
} | {
|
|
12
|
+
address: any;
|
|
13
|
+
owner: any;
|
|
14
|
+
}>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.__esModule = true;
|
|
50
|
+
exports.deployContract = exports.startBlockchainNode = void 0;
|
|
51
|
+
var ganache_1 = require("ganache");
|
|
52
|
+
var logger = require("debug")("cypress-toolkit/blockchain");
|
|
53
|
+
var instance;
|
|
54
|
+
function startBlockchainNode(nftContractsProjectFolder) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
+
var serverInstance, accounts;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
if (instance) {
|
|
61
|
+
return [2 /*return*/, instance.addresses];
|
|
62
|
+
}
|
|
63
|
+
logger("Starting blockchain server at \"".concat(nftContractsProjectFolder, "\""));
|
|
64
|
+
serverInstance = (0, ganache_1.server)({
|
|
65
|
+
miner: {
|
|
66
|
+
defaultTransactionGasLimit: 99000000000000,
|
|
67
|
+
callGasLimit: 99000000000000,
|
|
68
|
+
blockGasLimit: 99000000000000
|
|
69
|
+
},
|
|
70
|
+
wallet: {
|
|
71
|
+
deterministic: true
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return [4 /*yield*/, serverInstance.listen(15000).then(function () {
|
|
75
|
+
return Object.entries(serverInstance.provider.getInitialAccounts()).reduce(function (r, _a) {
|
|
76
|
+
var _b;
|
|
77
|
+
var k = _a[0], v = _a[1];
|
|
78
|
+
return (__assign(__assign({}, r), (_b = {}, _b[k] = __assign(__assign({}, v), { balance: Number(v.balance), unlocked: Number(v.unlocked) }), _b)));
|
|
79
|
+
}, {});
|
|
80
|
+
})];
|
|
81
|
+
case 1:
|
|
82
|
+
accounts = _a.sent();
|
|
83
|
+
instance = {
|
|
84
|
+
process: serverInstance,
|
|
85
|
+
rootFolder: nftContractsProjectFolder,
|
|
86
|
+
contracts: {},
|
|
87
|
+
addresses: accounts
|
|
88
|
+
};
|
|
89
|
+
return [2 /*return*/, accounts];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
exports.startBlockchainNode = startBlockchainNode;
|
|
95
|
+
function deployContract(contractName) {
|
|
96
|
+
var initializationArgs = [];
|
|
97
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
98
|
+
initializationArgs[_i - 1] = arguments[_i];
|
|
99
|
+
}
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
var startingDir, hardhat, ethers, owner, Factory, lock, connection, initializationKey;
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
switch (_a.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
if (!instance.contracts[contractName]) return [3 /*break*/, 1];
|
|
106
|
+
return [2 /*return*/, instance.contracts[contractName]];
|
|
107
|
+
case 1:
|
|
108
|
+
logger("Deploying contract ".concat(contractName, " with parameters ").concat(initializationArgs));
|
|
109
|
+
startingDir = process.cwd();
|
|
110
|
+
process.chdir(instance.rootFolder);
|
|
111
|
+
hardhat = require("hardhat");
|
|
112
|
+
hardhat.network.provider = instance.process.provider;
|
|
113
|
+
process.chdir(startingDir);
|
|
114
|
+
ethers = hardhat.ethers;
|
|
115
|
+
return [4 /*yield*/, ethers.getSigners()];
|
|
116
|
+
case 2:
|
|
117
|
+
owner = (_a.sent())[0];
|
|
118
|
+
return [4 /*yield*/, ethers.getContractFactory(contractName)];
|
|
119
|
+
case 3:
|
|
120
|
+
Factory = _a.sent();
|
|
121
|
+
return [4 /*yield*/, Factory.deploy()];
|
|
122
|
+
case 4:
|
|
123
|
+
lock = _a.sent();
|
|
124
|
+
return [4 /*yield*/, lock.deployed()];
|
|
125
|
+
case 5:
|
|
126
|
+
_a.sent();
|
|
127
|
+
if (!(initializationArgs.length > 0)) return [3 /*break*/, 7];
|
|
128
|
+
logger("Initializing contract with owner ".concat(owner, " and args ").concat(initializationArgs));
|
|
129
|
+
connection = lock.connect(owner);
|
|
130
|
+
initializationKey = Object.keys(connection.functions).find(function (a) {
|
|
131
|
+
return a.split(",", initializationArgs.length) &&
|
|
132
|
+
a.startsWith("initialize(");
|
|
133
|
+
}) || "initialize";
|
|
134
|
+
if (!connection[initializationKey]) return [3 /*break*/, 7];
|
|
135
|
+
return [4 /*yield*/, connection[initializationKey].apply(connection, initializationArgs)];
|
|
136
|
+
case 6:
|
|
137
|
+
_a.sent();
|
|
138
|
+
_a.label = 7;
|
|
139
|
+
case 7: return [2 /*return*/, {
|
|
140
|
+
address: lock.address,
|
|
141
|
+
owner: owner.address
|
|
142
|
+
}];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
exports.deployContract = deployContract;
|
|
148
|
+
//# sourceMappingURL=blockchain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockchain.js","sourceRoot":"","sources":["../../src/native/blockchain.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAiC;AACjC,IAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,4BAA4B,CAAC,CAAC;AAU9D,IAAI,QASI,CAAC;AAET,SAAsB,mBAAmB,CAAC,yBAAiC;;;;;;oBACzE,IAAI,QAAQ,EAAE;wBACZ,sBAAO,QAAQ,CAAC,SAAS,EAAC;qBAC3B;oBACD,MAAM,CAAC,0CAAkC,yBAAyB,OAAG,CAAC,CAAC;oBAIjE,cAAc,GAAG,IAAA,gBAAM,EAAC;wBAC5B,KAAK,EAAE;4BACL,0BAA0B,EAAE,cAAc;4BAC1C,YAAY,EAAE,cAAc;4BAC5B,aAAa,EAAE,cAAc;yBAC9B;wBACD,MAAM,EAAE;4BACN,aAAa,EAAE,IAAI;yBACpB;qBACF,CAAC,CAAC;oBACc,qBAAM,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;4BACvD,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC,MAAM,CACxE,UAAC,CAAC,EAAE,EAAM;;oCAAL,CAAC,QAAA,EAAE,CAAC,QAAA;gCAAM,OAAA,uBACV,CAAC,gBACH,CAAC,0BACG,CAAC,KACJ,OAAO,EAAE,MAAM,CAAC,C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AAI,GAAG,SAAsB;oBACnC,qBAAM,IAAI,CAAC,QAAQ,EAAE,EAAA;;oBAArB,SAAqB,CAAC;yBAElB,CAAA,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAA,EAA7B,wBAA6B;oBAC/B,MAAM,CACJ,2CAAoC,KAAK,uBAAa,kBAAkB,CAAE,CAC3E,CAAC;oBACI,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;oBACjC,iBAAiB,GACrB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,IAAI,CACpC,UAAC,CAAC;wBACA,OAAA,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC;4BACvC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC;oBAD3B,CAC2B,CAC9B,IAAI,YAAY,CAAC;yBAChB,UAAU,CAAC,iBAAiB,CAAC,EAA7B,wBAA6B;oBAC/B,qBAAM,UAAU,CAAC,iBAAiB,CAAC,OAA7B,UAAU,EAAuB,kBAAkB,GAAC;;oBAA1D,SAA0D,CAAC;;wBAE/D,sBAAO;wBACL,OAAO,EAAE,IAAI,CAAC,OAAO;wBACrB,KAAK,EAAE,KAAK,CAAC,OAAO;qBACrB,EAAC;;;;CAEL;AAxCD,wCAwCC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.LOCALHOST_DOMAIN = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* For some reason, on node 18 "node-fetch" fails when connecting to "localhost" domain
|
|
6
|
+
* So I needed to change to 127.0.0.1
|
|
7
|
+
*/
|
|
8
|
+
exports.LOCALHOST_DOMAIN = "127.0.0.1";
|
|
9
|
+
//# sourceMappingURL=consts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../src/native/consts.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,gBAAgB,GAAG,WAAW,CAAA"}
|
|
@@ -18,4 +18,19 @@ export declare function startEmulator(args: {
|
|
|
18
18
|
UIPort: number;
|
|
19
19
|
/** An optional flag to indicate when a new emulator instance should be created */
|
|
20
20
|
suiteId?: string;
|
|
21
|
-
|
|
21
|
+
ports: number[];
|
|
22
|
+
shouldSaveData: boolean;
|
|
23
|
+
only: ("functions" | "hosting" | "firestore" | "storage" | "auth")[] | string[];
|
|
24
|
+
}, isRetry?: boolean): Promise<null>;
|
|
25
|
+
declare type Admin = ReturnType<typeof _getAuthAdminInstance>;
|
|
26
|
+
declare type KeysWithValsOfType<T, V> = keyof {
|
|
27
|
+
[P in keyof T as T[P] extends V ? P : never]: P;
|
|
28
|
+
};
|
|
29
|
+
export declare function invokeAuthAdmin<F extends KeysWithValsOfType<Admin, (...params: any[]) => any>>({ projectId, port, functionName, params, }: {
|
|
30
|
+
projectId: string;
|
|
31
|
+
port: string;
|
|
32
|
+
functionName: F;
|
|
33
|
+
params: Parameters<Admin[F]>;
|
|
34
|
+
}): Promise<any>;
|
|
35
|
+
declare function _getAuthAdminInstance(projectId: string, authPort: string): Promise<any>;
|
|
36
|
+
export {};
|
package/dist/native/emulator.js
CHANGED
|
@@ -35,10 +35,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
38
41
|
exports.__esModule = true;
|
|
39
|
-
exports.startEmulator = exports.killEmulator = void 0;
|
|
40
|
-
var node_fetch_1 = require("node-fetch");
|
|
42
|
+
exports.invokeAuthAdmin = exports.startEmulator = exports.killEmulator = void 0;
|
|
43
|
+
var node_fetch_1 = __importDefault(require("node-fetch"));
|
|
41
44
|
var child_process_1 = require("child_process");
|
|
45
|
+
var kill_port_1 = __importDefault(require("kill-port"));
|
|
46
|
+
var consts_1 = require("./consts");
|
|
42
47
|
var log = require("debug")("@muritavo/testing-toolkit/emulator");
|
|
43
48
|
var spawnResult;
|
|
44
49
|
function WaitTimeout(ml) {
|
|
@@ -64,7 +69,7 @@ function killEmulator() {
|
|
|
64
69
|
var t_1 = setTimeout(function () {
|
|
65
70
|
spawnResult = undefined;
|
|
66
71
|
rej(new Error("Couldn't kill emulator"));
|
|
67
|
-
},
|
|
72
|
+
}, 20000);
|
|
68
73
|
spawnResult.process.on("close", function () {
|
|
69
74
|
clearTimeout(t_1);
|
|
70
75
|
r(null);
|
|
@@ -85,7 +90,8 @@ exports.killEmulator = killEmulator;
|
|
|
85
90
|
* @param args Check property typings for details
|
|
86
91
|
* @returns A promise that resolves when the emulator is ready or fails if the emulator couldn't start or be reached
|
|
87
92
|
*/
|
|
88
|
-
function startEmulator(args) {
|
|
93
|
+
function startEmulator(args, isRetry) {
|
|
94
|
+
if (isRetry === void 0) { isRetry = false; }
|
|
89
95
|
return __awaiter(this, void 0, void 0, function () {
|
|
90
96
|
var suiteId;
|
|
91
97
|
var _this = this;
|
|
@@ -106,7 +112,7 @@ function startEmulator(args) {
|
|
|
106
112
|
id: suiteId,
|
|
107
113
|
project: args.projectId,
|
|
108
114
|
database: args.databaseToImport,
|
|
109
|
-
process: (0, child_process_1.spawn)("firebase emulators:start -P ".concat(args.projectId, " ").concat(args.databaseToImport ? "--import ".concat(args.databaseToImport) : ""), {
|
|
115
|
+
process: (0, child_process_1.spawn)("firebase emulators:start -P ".concat(args.projectId, " ").concat(args.databaseToImport ? "--import ".concat(args.databaseToImport) : "", " ").concat(args.shouldSaveData ? "--export-on-exit" : "", " ").concat(args.only.length ? "--only=".concat(args.only.join(",")) : ""), {
|
|
110
116
|
cwd: undefined,
|
|
111
117
|
env: process.env,
|
|
112
118
|
shell: true
|
|
@@ -116,7 +122,7 @@ function startEmulator(args) {
|
|
|
116
122
|
* This script exists so we can start an emulator from inside cypress
|
|
117
123
|
*/
|
|
118
124
|
return [2 /*return*/, new Promise(function (r, rej) { return __awaiter(_this, void 0, void 0, function () {
|
|
119
|
-
var breakLoop, timeout, e_1;
|
|
125
|
+
var breakLoop, timeout, scriptOutput, e_1;
|
|
120
126
|
return __generator(this, function (_a) {
|
|
121
127
|
switch (_a.label) {
|
|
122
128
|
case 0:
|
|
@@ -139,10 +145,30 @@ function startEmulator(args) {
|
|
|
139
145
|
spawnResult.process.on("message", function (e) {
|
|
140
146
|
log("Emulator start sent message", e.toString());
|
|
141
147
|
});
|
|
148
|
+
scriptOutput = "";
|
|
149
|
+
spawnResult.process.stdout.on("data", function (data) {
|
|
150
|
+
data = data.toString();
|
|
151
|
+
scriptOutput += data;
|
|
152
|
+
});
|
|
142
153
|
spawnResult.process.on("close", function (e) {
|
|
143
154
|
clearTimeout(timeout);
|
|
144
155
|
log("Emulator closed with", e);
|
|
145
|
-
|
|
156
|
+
var unavailablePorts = args.ports.filter(function (p) {
|
|
157
|
+
return scriptOutput.includes(String(p));
|
|
158
|
+
});
|
|
159
|
+
var failedWithUnavailablePort = unavailablePorts.length;
|
|
160
|
+
if (failedWithUnavailablePort) {
|
|
161
|
+
log("Killing ports", unavailablePorts, "detected from text", scriptOutput);
|
|
162
|
+
Promise.all(unavailablePorts.map(function (p) { return (0, kill_port_1["default"])(p)["catch"](function () { }); })).then(function () {
|
|
163
|
+
if (isRetry === false)
|
|
164
|
+
return startEmulator(args, true);
|
|
165
|
+
else
|
|
166
|
+
rej(new Error("Some ports were unavailable (".concat(unavailablePorts.join(", "), "). They were killed, please try running the emulator again")));
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
rej(new Error("Emulator closed with code ".concat(e, ". Check the firebse-debug.log for more details")));
|
|
171
|
+
}
|
|
146
172
|
spawnResult = undefined;
|
|
147
173
|
});
|
|
148
174
|
_a.label = 1;
|
|
@@ -152,7 +178,7 @@ function startEmulator(args) {
|
|
|
152
178
|
case 2:
|
|
153
179
|
_a.trys.push([2, 4, , 5]);
|
|
154
180
|
log("Checking if emulator is up");
|
|
155
|
-
return [4 /*yield*/, (0, node_fetch_1["default"])("http://
|
|
181
|
+
return [4 /*yield*/, (0, node_fetch_1["default"])("http://".concat(consts_1.LOCALHOST_DOMAIN, ":").concat(args.UIPort))];
|
|
156
182
|
case 3:
|
|
157
183
|
_a.sent();
|
|
158
184
|
log("Emulator is up and ready");
|
|
@@ -162,6 +188,7 @@ function startEmulator(args) {
|
|
|
162
188
|
return [3 /*break*/, 5];
|
|
163
189
|
case 4:
|
|
164
190
|
e_1 = _a.sent();
|
|
191
|
+
log(e_1);
|
|
165
192
|
log("Process is killed: ", spawnResult === null || spawnResult === void 0 ? void 0 : spawnResult.process.killed);
|
|
166
193
|
log("Emulator is not ready yet, retrying in 1 sec");
|
|
167
194
|
return [3 /*break*/, 5];
|
|
@@ -178,4 +205,36 @@ function startEmulator(args) {
|
|
|
178
205
|
});
|
|
179
206
|
}
|
|
180
207
|
exports.startEmulator = startEmulator;
|
|
208
|
+
function invokeAuthAdmin(_a) {
|
|
209
|
+
var projectId = _a.projectId, port = _a.port, functionName = _a.functionName, params = _a.params;
|
|
210
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
211
|
+
var app, func;
|
|
212
|
+
return __generator(this, function (_b) {
|
|
213
|
+
switch (_b.label) {
|
|
214
|
+
case 0:
|
|
215
|
+
app = _getAuthAdminInstance(projectId, port);
|
|
216
|
+
func = app[functionName];
|
|
217
|
+
return [4 /*yield*/, func.bind(app).apply(void 0, params)];
|
|
218
|
+
case 1:
|
|
219
|
+
_b.sent();
|
|
220
|
+
return [2 /*return*/, null];
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
exports.invokeAuthAdmin = invokeAuthAdmin;
|
|
226
|
+
var adminApp = {};
|
|
227
|
+
function _getAuthAdminInstance(projectId, authPort) {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
229
|
+
var initializeApp, getAuth;
|
|
230
|
+
return __generator(this, function (_a) {
|
|
231
|
+
initializeApp = require("firebase-admin/app").initializeApp;
|
|
232
|
+
getAuth = require("firebase-admin/auth").getAuth;
|
|
233
|
+
process.env.FIREBASE_AUTH_EMULATOR_HOST = "".concat(consts_1.LOCALHOST_DOMAIN, ":").concat(authPort);
|
|
234
|
+
adminApp[projectId] =
|
|
235
|
+
adminApp[projectId] || initializeApp({ projectId: projectId }, projectId);
|
|
236
|
+
return [2 /*return*/, getAuth(adminApp[projectId])];
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
}
|
|
181
240
|
//# sourceMappingURL=emulator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../../src/native/emulator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../../src/native/emulator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAmC;AACnC,+CAAoD;AACpD,wDAAiC;AACjC,mCAA4C;AAE5C,IAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oCAAoC,CAAC,CAAC;AACnE,IAAI,WAKH,CAAC;AACF,SAAS,WAAW,CAAC,EAAQ;IAAR,mBAAA,EAAA,QAAQ;IAC3B,OAAO,IAAI,OAAO,CAAO,UAAC,CAAC;QACzB,UAAU,CAAC;YACT,CAAC,EAAE,CAAC;QACN,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,SAAsB,YAAY;;;YAChC,IAAI,CAAC,WAAW;gBAAE,sBAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAC;YAC/C,sBAAO,IAAI,OAAO,CAAC,UAAC,CAAC,EAAE,GAAG;oBACxB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b;AAjBD,0CAiBC;AAED,IAAI,QAAQ,GAIR,EAAE,CAAC;AAEP,SAAe,qBAAqB,CAAC,SAAiB,EAAE,QAAgB;;;;YAC9D,aAAa,GAAK,OAAO,CAAC,oBAAoB,CAAC,cAAlC,CAAmC;YAChD,OAAO,GAAK,OAAO,CAAC,qBAAqB,CAAC,QAAnC,CAAoC;YACnD,OAAO,CAAC,GAAG,CAAC,2BAA2B,GAAG,UAAG,yBAAgB,cAAI,QAAQ,CAAE,CAAC;YAC5E,QAAQ,CAAC,SAAS,CAAC;gBACjB,QAAQ,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,EAAE,SAAS,WAAA,EAAE,EAAE,SAAS,CAAC,CAAC;YACjE,sBAAO,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAC;;;CACrC"}
|
package/dist/types/contract.d.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { Contract, ContractOptions, EventData, PastEventOptions } from "web3-eth-contract";
|
|
2
|
-
declare type
|
|
2
|
+
export declare type AllABIs = readonly any[];
|
|
3
|
+
declare type ExtractMethods<A extends AllABIs[number]> = A extends {
|
|
3
4
|
type: "function";
|
|
4
5
|
} ? A["name"] : never;
|
|
5
|
-
declare type ExtractEvents<A extends
|
|
6
|
+
declare type ExtractEvents<A extends AllABIs[number]> = A extends {
|
|
6
7
|
type: "event";
|
|
7
8
|
} ? A["name"] : never;
|
|
8
|
-
declare type TypeOrInternalType<T> = T[
|
|
9
|
-
declare type MapTypeToJS<L, C> = L extends "address" | "uint256" | "uint128" | "uint8" | "string" | "bytes32" ? string : L extends "bool" ? boolean : L extends
|
|
10
|
-
declare type ExtractFromObj<R extends
|
|
9
|
+
declare type TypeOrInternalType<T> = T['internalType'] extends unknown ? T['type'] : T['internalType'];
|
|
10
|
+
declare type MapTypeToJS<L, C> = L extends "tuple[]" ? TuplifyUnion<C[number], C[number]['name']>[] : L extends "address" | "uint256" | "uint128" | "uint8" | "string" | "bytes32" ? string : L extends "uint256[]" | "string[]" ? string[] : L extends "bool" ? boolean : L extends 'tuple' ? TuplifyUnion<C[number], C[number]['name']> : unknown;
|
|
11
|
+
declare type ExtractFromObj<R extends (AllABIs[number] & {
|
|
11
12
|
type: "function";
|
|
12
|
-
}> = {
|
|
13
|
-
[K in R["outputs"][number]["name"]]: MapTypeToJS<TypeOrInternalType<R["outputs"][number] & {
|
|
13
|
+
})> = {
|
|
14
|
+
[K in R["outputs"][number]["name"]]: MapTypeToJS<TypeOrInternalType<(R["outputs"][number] & {
|
|
14
15
|
name: K;
|
|
15
|
-
}>, (R["outputs"][number] & {
|
|
16
|
+
})>, (R["outputs"][number] & {
|
|
16
17
|
name: K;
|
|
17
18
|
})["components"]>;
|
|
18
19
|
};
|
|
19
|
-
export declare type ExtractMethodDefinition<A extends
|
|
20
|
+
export declare type ExtractMethodDefinition<A extends AllABIs, N extends (AllABIs[number] & {
|
|
20
21
|
type: "function";
|
|
21
22
|
})["name"], R = A[number] & {
|
|
22
23
|
type: "function";
|
|
@@ -32,7 +33,7 @@ export declare type ExtractMethodDefinition<A extends any, N extends (any[number
|
|
|
32
33
|
outputs: {
|
|
33
34
|
length: 1;
|
|
34
35
|
};
|
|
35
|
-
} ? MapTypeToJS<TypeOrInternalType<R["outputs"][0]>, R["outputs"][0][
|
|
36
|
+
} ? MapTypeToJS<TypeOrInternalType<R["outputs"][0]>, R["outputs"][0]['components']> : R extends {
|
|
36
37
|
outputs: any;
|
|
37
38
|
} ? ExtractFromObj<R> : void>;
|
|
38
39
|
send: (prop: {
|
|
@@ -45,12 +46,12 @@ export declare type ExtractMethodDefinition<A extends any, N extends (any[number
|
|
|
45
46
|
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
46
47
|
declare type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
|
|
47
48
|
declare type Push<T extends any[], V> = [...T, V];
|
|
48
|
-
export declare type TuplifyUnion<FUNCS, T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<TuplifyUnion<FUNCS, Exclude<T, L>>, MapTypeToJS<TypeOrInternalType<FUNCS & {
|
|
49
|
+
export declare type TuplifyUnion<FUNCS, T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<TuplifyUnion<FUNCS, Exclude<T, L>>, MapTypeToJS<TypeOrInternalType<(FUNCS & {
|
|
49
50
|
name: L;
|
|
50
|
-
}>, (FUNCS & {
|
|
51
|
+
})>, (FUNCS & {
|
|
51
52
|
name: L;
|
|
52
|
-
})[
|
|
53
|
-
export
|
|
53
|
+
})['components']>>;
|
|
54
|
+
export default class GenericContract<A extends AllABIs = AllABIs, E extends string = ExtractEvents<A[number]> | "allEvents"> extends Contract {
|
|
54
55
|
events: Exclude<E, "allEvents">;
|
|
55
56
|
constructor(jsonInterface: A, address?: string, options?: ContractOptions);
|
|
56
57
|
methods: {
|
|
@@ -61,11 +62,11 @@ export declare class GenericContract<A extends any = any, E extends string = Ext
|
|
|
61
62
|
getPastEvents(event: E, options: PastEventOptions): Promise<GenericEventData<A>[]>;
|
|
62
63
|
getPastEvents(event: E, callback: (error: Error, event: EventData) => void): Promise<GenericEventData<A>[]>;
|
|
63
64
|
}
|
|
64
|
-
export declare type GenericEventData<E extends
|
|
65
|
-
declare type ABIEvent =
|
|
65
|
+
export declare type GenericEventData<E extends AllABIs> = EventData & GenericEvent<E>;
|
|
66
|
+
declare type ABIEvent = AllABIs[number] & {
|
|
66
67
|
type: "event";
|
|
67
68
|
};
|
|
68
|
-
declare type GenericEvent<ABI extends
|
|
69
|
+
declare type GenericEvent<ABI extends AllABIs, E extends string = ExtractEvents<ABI[number]>> = {
|
|
69
70
|
event: E;
|
|
70
71
|
returnValues: ExtractReturnValues<ABIEvent & {
|
|
71
72
|
name: E;
|
|
@@ -73,6 +74,6 @@ declare type GenericEvent<ABI extends any, E extends string = ExtractEvents<ABI[
|
|
|
73
74
|
};
|
|
74
75
|
declare type ExtractReturnValues<E extends ABIEvent> = ExtractInputType<E["inputs"][number]>;
|
|
75
76
|
declare type ExtractInputType<I extends ABIEvent["inputs"][number]> = {
|
|
76
|
-
[k in I["name"]]: MapTypeToJS<TypeOrInternalType<I>, I[
|
|
77
|
+
[k in I["name"]]: MapTypeToJS<TypeOrInternalType<I>, I['components']>;
|
|
77
78
|
};
|
|
78
79
|
export {};
|
package/dist/types/contract.js
CHANGED
|
@@ -15,7 +15,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
exports.__esModule = true;
|
|
18
|
-
exports.GenericContract = void 0;
|
|
19
18
|
// @ts-nocheck
|
|
20
19
|
var web3_eth_contract_1 = require("web3-eth-contract");
|
|
21
20
|
var GenericContract = /** @class */ (function (_super) {
|
|
@@ -28,5 +27,5 @@ var GenericContract = /** @class */ (function (_super) {
|
|
|
28
27
|
};
|
|
29
28
|
return GenericContract;
|
|
30
29
|
}(web3_eth_contract_1.Contract));
|
|
31
|
-
exports
|
|
30
|
+
exports["default"] = GenericContract;
|
|
32
31
|
//# sourceMappingURL=contract.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/types/contract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/types/contract.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,uDAK2B;AAyG3B;IAGY,mCAAQ;IAElB,yBAAY,aAAgB,EAAE,OAAgB,EAAE,OAAyB;eACvE,kBAAM,aAAqC,EAAE,OAAO,EAAE,OAAO,CAAC;IAChE,CAAC;IAkBQ,uCAAa,GAAtB,UACE,KAAU,EACV,OAAa,EACb,QAAc;QAEd,OAAO,iBAAM,aAAa,YAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAQ,CAAC;IAC9D,CAAC;IACH,sBAAC;AAAD,CAAC,AAhCD,CAGY,4BAAQ,GA6BnB"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muritavo/testing-toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A series of functions to help with testing",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"files": [
|
|
6
|
+
"files": [
|
|
7
|
+
"./dist"
|
|
8
|
+
],
|
|
7
9
|
"scripts": {
|
|
8
10
|
"dev": "tsc --watch",
|
|
9
11
|
"prepack": "tsc"
|
|
@@ -20,11 +22,17 @@
|
|
|
20
22
|
"homepage": "https://github.com/Muritavo/testing-toolkit#readme",
|
|
21
23
|
"devDependencies": {
|
|
22
24
|
"firebase": "^9.10.0",
|
|
23
|
-
"
|
|
25
|
+
"firebase-admin": "^11.5.0",
|
|
26
|
+
"text2png": "^2.3.0",
|
|
27
|
+
"web3": "^1.8.0",
|
|
28
|
+
"ganache": "^7.8.0",
|
|
29
|
+
"hardhat": "^2.14.1"
|
|
24
30
|
},
|
|
25
31
|
"dependencies": {
|
|
26
32
|
"@firebase/rules-unit-testing": "^2.0.4",
|
|
33
|
+
"@types/kill-port": "^2.0.3",
|
|
27
34
|
"@types/node-fetch": "^2.6.2",
|
|
35
|
+
"kill-port": "^2.0.1",
|
|
28
36
|
"node-fetch": "^1",
|
|
29
37
|
"typescript": "^4.8.4"
|
|
30
38
|
}
|