@clarigen/test 0.3.3 → 1.0.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +26 -23
- package/dist/test.cjs.development.js +532 -355
- package/dist/test.cjs.development.js.map +1 -1
- package/dist/test.cjs.production.min.js +1 -1
- package/dist/test.cjs.production.min.js.map +1 -1
- package/dist/test.esm.js +533 -354
- package/dist/test.esm.js.map +1 -1
- package/dist/utils/clarity-cli-adapter.d.ts +31 -11
- package/dist/utils/index.d.ts +2 -4
- package/dist/utils/pure.d.ts +44 -0
- package/dist/utils/util-contract.d.ts +9 -4
- package/package.json +17 -15
- package/dist/utils/clarity.d.ts +0 -1
package/dist/test.esm.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { getDefaultBinaryFilePath, getTempFilePath, NativeClarityBinProvider, hasStdErr, createClarityBin as createClarityBin$1 } from '@clarigen/native-bin';
|
|
2
|
+
import { filterEvents, CoreNodeEventType, cvToValue, cvToString, getContractIdentifier } from '@clarigen/core';
|
|
3
|
+
import { publicKeyToStxAddress, StacksNetworkVersion } from 'micro-stacks/crypto';
|
|
4
|
+
import { makeRandomPrivKey, getPublicKeyFromStacksPrivateKey } from 'micro-stacks/transactions';
|
|
5
|
+
import { hexToCV, responseErrorCV, responseOkCV } from 'micro-stacks/clarity';
|
|
5
6
|
import { join } from 'path';
|
|
7
|
+
import { intToBigInt } from 'micro-stacks/common';
|
|
6
8
|
|
|
7
9
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
8
10
|
try {
|
|
@@ -40,6 +42,24 @@ function _asyncToGenerator(fn) {
|
|
|
40
42
|
};
|
|
41
43
|
}
|
|
42
44
|
|
|
45
|
+
function _extends() {
|
|
46
|
+
_extends = Object.assign || function (target) {
|
|
47
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
48
|
+
var source = arguments[i];
|
|
49
|
+
|
|
50
|
+
for (var key in source) {
|
|
51
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
52
|
+
target[key] = source[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return target;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return _extends.apply(this, arguments);
|
|
61
|
+
}
|
|
62
|
+
|
|
43
63
|
function createCommonjsModule(fn, module) {
|
|
44
64
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
45
65
|
}
|
|
@@ -805,7 +825,9 @@ var executeJson = /*#__PURE__*/function () {
|
|
|
805
825
|
throw new Error("Execution error: " + result.stderr);
|
|
806
826
|
|
|
807
827
|
case 10:
|
|
808
|
-
return _context.abrupt("return", response
|
|
828
|
+
return _context.abrupt("return", _extends({}, response, {
|
|
829
|
+
stderr: result.stderr
|
|
830
|
+
}));
|
|
809
831
|
|
|
810
832
|
case 11:
|
|
811
833
|
case "end":
|
|
@@ -819,22 +841,20 @@ var executeJson = /*#__PURE__*/function () {
|
|
|
819
841
|
return _ref2.apply(this, arguments);
|
|
820
842
|
};
|
|
821
843
|
}();
|
|
822
|
-
var
|
|
844
|
+
var evalRaw = /*#__PURE__*/function () {
|
|
823
845
|
var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref3) {
|
|
824
|
-
var contractAddress,
|
|
825
|
-
|
|
846
|
+
var contractAddress, code, provider, receipt, response;
|
|
826
847
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
827
848
|
while (1) {
|
|
828
849
|
switch (_context2.prev = _context2.next) {
|
|
829
850
|
case 0:
|
|
830
|
-
contractAddress = _ref3.contractAddress,
|
|
831
|
-
|
|
832
|
-
_context2.next = 4;
|
|
851
|
+
contractAddress = _ref3.contractAddress, code = _ref3.code, provider = _ref3.provider;
|
|
852
|
+
_context2.next = 3;
|
|
833
853
|
return provider.runCommand(['eval_at_chaintip', '--costs', contractAddress, provider.dbFilePath], {
|
|
834
|
-
stdin:
|
|
854
|
+
stdin: code
|
|
835
855
|
});
|
|
836
856
|
|
|
837
|
-
case
|
|
857
|
+
case 3:
|
|
838
858
|
receipt = _context2.sent;
|
|
839
859
|
|
|
840
860
|
if (process.env.PRINT_CLARIGEN_STDERR && receipt.stderr) {
|
|
@@ -844,16 +864,18 @@ var evalJson = /*#__PURE__*/function () {
|
|
|
844
864
|
response = JSON.parse(receipt.stdout);
|
|
845
865
|
|
|
846
866
|
if (response.success) {
|
|
847
|
-
_context2.next =
|
|
867
|
+
_context2.next = 8;
|
|
848
868
|
break;
|
|
849
869
|
}
|
|
850
870
|
|
|
851
871
|
throw new Error(JSON.stringify(response.error, null, 2));
|
|
852
872
|
|
|
853
|
-
case
|
|
854
|
-
return _context2.abrupt("return", response
|
|
873
|
+
case 8:
|
|
874
|
+
return _context2.abrupt("return", _extends({}, response, {
|
|
875
|
+
stderr: receipt.stderr
|
|
876
|
+
}));
|
|
855
877
|
|
|
856
|
-
case
|
|
878
|
+
case 9:
|
|
857
879
|
case "end":
|
|
858
880
|
return _context2.stop();
|
|
859
881
|
}
|
|
@@ -861,10 +883,23 @@ var evalJson = /*#__PURE__*/function () {
|
|
|
861
883
|
}, _callee2);
|
|
862
884
|
}));
|
|
863
885
|
|
|
864
|
-
return function
|
|
886
|
+
return function evalRaw(_x2) {
|
|
865
887
|
return _ref4.apply(this, arguments);
|
|
866
888
|
};
|
|
867
889
|
}();
|
|
890
|
+
var evalJson = function evalJson(_ref5) {
|
|
891
|
+
var contractAddress = _ref5.contractAddress,
|
|
892
|
+
functionName = _ref5.functionName,
|
|
893
|
+
provider = _ref5.provider,
|
|
894
|
+
_ref5$args = _ref5.args,
|
|
895
|
+
args = _ref5$args === void 0 ? [] : _ref5$args;
|
|
896
|
+
var code = "(" + functionName + " " + args.join(' ') + ")";
|
|
897
|
+
return evalRaw({
|
|
898
|
+
contractAddress: contractAddress,
|
|
899
|
+
provider: provider,
|
|
900
|
+
code: code
|
|
901
|
+
});
|
|
902
|
+
};
|
|
868
903
|
function getAllocations(allocations) {
|
|
869
904
|
if (!allocations) return [];
|
|
870
905
|
|
|
@@ -895,14 +930,14 @@ function stringifyAllocations(allocations) {
|
|
|
895
930
|
}
|
|
896
931
|
|
|
897
932
|
var createClarityBin = /*#__PURE__*/function () {
|
|
898
|
-
var
|
|
899
|
-
var
|
|
933
|
+
var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(_temp) {
|
|
934
|
+
var _ref7, allocations, _ref7$testnet, testnet, binFile, dbFileName, _allocations, provider, args;
|
|
900
935
|
|
|
901
936
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
902
937
|
while (1) {
|
|
903
938
|
switch (_context3.prev = _context3.next) {
|
|
904
939
|
case 0:
|
|
905
|
-
|
|
940
|
+
_ref7 = _temp === void 0 ? {} : _temp, allocations = _ref7.allocations, _ref7$testnet = _ref7.testnet, testnet = _ref7$testnet === void 0 ? true : _ref7$testnet;
|
|
906
941
|
binFile = getDefaultBinaryFilePath();
|
|
907
942
|
dbFileName = getTempFilePath();
|
|
908
943
|
_allocations = getAllocations(allocations);
|
|
@@ -926,88 +961,23 @@ var createClarityBin = /*#__PURE__*/function () {
|
|
|
926
961
|
}));
|
|
927
962
|
|
|
928
963
|
return function createClarityBin(_x3) {
|
|
929
|
-
return
|
|
964
|
+
return _ref6.apply(this, arguments);
|
|
930
965
|
};
|
|
931
966
|
}();
|
|
932
|
-
function getDefaultClarityBin(_x4) {
|
|
933
|
-
return _getDefaultClarityBin.apply(this, arguments);
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
function _getDefaultClarityBin() {
|
|
937
|
-
_getDefaultClarityBin = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(clarityBinOrAccounts) {
|
|
938
|
-
var clarityBin;
|
|
939
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
940
|
-
while (1) {
|
|
941
|
-
switch (_context4.prev = _context4.next) {
|
|
942
|
-
case 0:
|
|
943
|
-
if (clarityBinOrAccounts) {
|
|
944
|
-
_context4.next = 6;
|
|
945
|
-
break;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
_context4.next = 3;
|
|
949
|
-
return createClarityBin();
|
|
950
|
-
|
|
951
|
-
case 3:
|
|
952
|
-
clarityBin = _context4.sent;
|
|
953
|
-
_context4.next = 17;
|
|
954
|
-
break;
|
|
955
|
-
|
|
956
|
-
case 6:
|
|
957
|
-
if (!('deployer' in clarityBinOrAccounts)) {
|
|
958
|
-
_context4.next = 12;
|
|
959
|
-
break;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
_context4.next = 9;
|
|
963
|
-
return createClarityBin({
|
|
964
|
-
allocations: clarityBinOrAccounts
|
|
965
|
-
});
|
|
966
|
-
|
|
967
|
-
case 9:
|
|
968
|
-
clarityBin = _context4.sent;
|
|
969
|
-
_context4.next = 17;
|
|
970
|
-
break;
|
|
971
|
-
|
|
972
|
-
case 12:
|
|
973
|
-
if (!(clarityBinOrAccounts instanceof NativeClarityBinProvider)) {
|
|
974
|
-
_context4.next = 16;
|
|
975
|
-
break;
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
clarityBin = clarityBinOrAccounts;
|
|
979
|
-
_context4.next = 17;
|
|
980
|
-
break;
|
|
981
|
-
|
|
982
|
-
case 16:
|
|
983
|
-
throw new Error('Should never get here');
|
|
984
|
-
|
|
985
|
-
case 17:
|
|
986
|
-
return _context4.abrupt("return", clarityBin);
|
|
987
|
-
|
|
988
|
-
case 18:
|
|
989
|
-
case "end":
|
|
990
|
-
return _context4.stop();
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
}, _callee4);
|
|
994
|
-
}));
|
|
995
|
-
return _getDefaultClarityBin.apply(this, arguments);
|
|
996
|
-
}
|
|
997
967
|
|
|
998
968
|
function deployContract(_x5) {
|
|
999
969
|
return _deployContract.apply(this, arguments);
|
|
1000
970
|
}
|
|
1001
971
|
|
|
1002
972
|
function _deployContract() {
|
|
1003
|
-
_deployContract = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(
|
|
973
|
+
_deployContract = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(_ref8) {
|
|
1004
974
|
var contractIdentifier, contractFilePath, provider, receipt, output, initialization, _initialization$split, error, trace, startLine, matcher, matches;
|
|
1005
975
|
|
|
1006
976
|
return runtime_1.wrap(function _callee5$(_context5) {
|
|
1007
977
|
while (1) {
|
|
1008
978
|
switch (_context5.prev = _context5.next) {
|
|
1009
979
|
case 0:
|
|
1010
|
-
contractIdentifier =
|
|
980
|
+
contractIdentifier = _ref8.contractIdentifier, contractFilePath = _ref8.contractFilePath, provider = _ref8.provider;
|
|
1011
981
|
_context5.next = 3;
|
|
1012
982
|
return provider.runCommand(['launch', contractIdentifier, contractFilePath, provider.dbFilePath, '--costs', '--assets']);
|
|
1013
983
|
|
|
@@ -1056,6 +1026,14 @@ function _deployContract() {
|
|
|
1056
1026
|
return _deployContract.apply(this, arguments);
|
|
1057
1027
|
}
|
|
1058
1028
|
|
|
1029
|
+
function getPrints(events) {
|
|
1030
|
+
return filterEvents(events, CoreNodeEventType.ContractEvent).map(function (e) {
|
|
1031
|
+
var hex = e.contract_event.raw_value;
|
|
1032
|
+
var cv = hexToCV(hex);
|
|
1033
|
+
return cvToValue(cv);
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1059
1037
|
var UTIL_CONTRACT_ID = 'ST000000000000000000002AMW42H.clarigen-test-utils';
|
|
1060
1038
|
function deployUtilContract(_x) {
|
|
1061
1039
|
return _deployUtilContract.apply(this, arguments);
|
|
@@ -1091,34 +1069,39 @@ function _deployUtilContract() {
|
|
|
1091
1069
|
return _deployUtilContract.apply(this, arguments);
|
|
1092
1070
|
}
|
|
1093
1071
|
|
|
1072
|
+
function getBin(provider) {
|
|
1073
|
+
return 'clarityBin' in provider ? provider.clarityBin : provider;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1094
1076
|
function getBlockHeight(_x2) {
|
|
1095
1077
|
return _getBlockHeight.apply(this, arguments);
|
|
1096
1078
|
}
|
|
1097
1079
|
|
|
1098
1080
|
function _getBlockHeight() {
|
|
1099
1081
|
_getBlockHeight = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(provider) {
|
|
1100
|
-
var _yield$evalJson, output_serialized, outputCV, blockHeight;
|
|
1082
|
+
var bin, _yield$evalJson, output_serialized, outputCV, blockHeight;
|
|
1101
1083
|
|
|
1102
1084
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1103
1085
|
while (1) {
|
|
1104
1086
|
switch (_context2.prev = _context2.next) {
|
|
1105
1087
|
case 0:
|
|
1106
|
-
|
|
1088
|
+
bin = getBin(provider);
|
|
1089
|
+
_context2.next = 3;
|
|
1107
1090
|
return evalJson({
|
|
1108
1091
|
contractAddress: UTIL_CONTRACT_ID,
|
|
1109
1092
|
functionName: 'get-block-height',
|
|
1110
1093
|
args: [],
|
|
1111
|
-
provider:
|
|
1094
|
+
provider: bin
|
|
1112
1095
|
});
|
|
1113
1096
|
|
|
1114
|
-
case
|
|
1097
|
+
case 3:
|
|
1115
1098
|
_yield$evalJson = _context2.sent;
|
|
1116
1099
|
output_serialized = _yield$evalJson.output_serialized;
|
|
1117
|
-
outputCV =
|
|
1100
|
+
outputCV = hexToCV(output_serialized);
|
|
1118
1101
|
blockHeight = cvToValue(outputCV);
|
|
1119
1102
|
return _context2.abrupt("return", blockHeight);
|
|
1120
1103
|
|
|
1121
|
-
case
|
|
1104
|
+
case 8:
|
|
1122
1105
|
case "end":
|
|
1123
1106
|
return _context2.stop();
|
|
1124
1107
|
}
|
|
@@ -1134,20 +1117,22 @@ function mineBlock(_x3) {
|
|
|
1134
1117
|
|
|
1135
1118
|
function _mineBlock() {
|
|
1136
1119
|
_mineBlock = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(provider) {
|
|
1120
|
+
var bin;
|
|
1137
1121
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1138
1122
|
while (1) {
|
|
1139
1123
|
switch (_context3.prev = _context3.next) {
|
|
1140
1124
|
case 0:
|
|
1141
|
-
|
|
1125
|
+
bin = getBin(provider);
|
|
1126
|
+
_context3.next = 3;
|
|
1142
1127
|
return executeJson({
|
|
1143
1128
|
contractAddress: UTIL_CONTRACT_ID,
|
|
1144
1129
|
functionName: 'mine-block',
|
|
1145
1130
|
args: [],
|
|
1146
|
-
provider:
|
|
1131
|
+
provider: bin,
|
|
1147
1132
|
senderAddress: 'ST000000000000000000002AMW42H'
|
|
1148
1133
|
});
|
|
1149
1134
|
|
|
1150
|
-
case
|
|
1135
|
+
case 3:
|
|
1151
1136
|
case "end":
|
|
1152
1137
|
return _context3.stop();
|
|
1153
1138
|
}
|
|
@@ -1162,29 +1147,30 @@ function mineBlocks(_x4, _x5) {
|
|
|
1162
1147
|
}
|
|
1163
1148
|
|
|
1164
1149
|
function _mineBlocks() {
|
|
1165
|
-
_mineBlocks = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(
|
|
1166
|
-
var index;
|
|
1150
|
+
_mineBlocks = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(_blocks, provider) {
|
|
1151
|
+
var blocks, index;
|
|
1167
1152
|
return runtime_1.wrap(function _callee4$(_context4) {
|
|
1168
1153
|
while (1) {
|
|
1169
1154
|
switch (_context4.prev = _context4.next) {
|
|
1170
1155
|
case 0:
|
|
1156
|
+
blocks = intToBigInt(_blocks);
|
|
1171
1157
|
index = 0;
|
|
1172
1158
|
|
|
1173
|
-
case
|
|
1159
|
+
case 2:
|
|
1174
1160
|
if (!(index < blocks)) {
|
|
1175
|
-
_context4.next =
|
|
1161
|
+
_context4.next = 8;
|
|
1176
1162
|
break;
|
|
1177
1163
|
}
|
|
1178
1164
|
|
|
1179
|
-
_context4.next =
|
|
1165
|
+
_context4.next = 5;
|
|
1180
1166
|
return mineBlock(provider);
|
|
1181
1167
|
|
|
1182
|
-
case
|
|
1168
|
+
case 5:
|
|
1183
1169
|
index++;
|
|
1184
|
-
_context4.next =
|
|
1170
|
+
_context4.next = 2;
|
|
1185
1171
|
break;
|
|
1186
1172
|
|
|
1187
|
-
case
|
|
1173
|
+
case 8:
|
|
1188
1174
|
case "end":
|
|
1189
1175
|
return _context4.stop();
|
|
1190
1176
|
}
|
|
@@ -1200,28 +1186,29 @@ function getStxBalance(_x6, _x7) {
|
|
|
1200
1186
|
|
|
1201
1187
|
function _getStxBalance() {
|
|
1202
1188
|
_getStxBalance = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(provider, account) {
|
|
1203
|
-
var _yield$evalJson2, output_serialized, outputCV, balance;
|
|
1189
|
+
var bin, _yield$evalJson2, output_serialized, outputCV, balance;
|
|
1204
1190
|
|
|
1205
1191
|
return runtime_1.wrap(function _callee5$(_context5) {
|
|
1206
1192
|
while (1) {
|
|
1207
1193
|
switch (_context5.prev = _context5.next) {
|
|
1208
1194
|
case 0:
|
|
1209
|
-
|
|
1195
|
+
bin = getBin(provider);
|
|
1196
|
+
_context5.next = 3;
|
|
1210
1197
|
return evalJson({
|
|
1211
1198
|
contractAddress: UTIL_CONTRACT_ID,
|
|
1212
1199
|
functionName: 'get-stx-balance',
|
|
1213
1200
|
args: ["'" + account],
|
|
1214
|
-
provider:
|
|
1201
|
+
provider: bin
|
|
1215
1202
|
});
|
|
1216
1203
|
|
|
1217
|
-
case
|
|
1204
|
+
case 3:
|
|
1218
1205
|
_yield$evalJson2 = _context5.sent;
|
|
1219
1206
|
output_serialized = _yield$evalJson2.output_serialized;
|
|
1220
|
-
outputCV =
|
|
1207
|
+
outputCV = hexToCV(output_serialized);
|
|
1221
1208
|
balance = cvToValue(outputCV);
|
|
1222
1209
|
return _context5.abrupt("return", balance);
|
|
1223
1210
|
|
|
1224
|
-
case
|
|
1211
|
+
case 8:
|
|
1225
1212
|
case "end":
|
|
1226
1213
|
return _context5.stop();
|
|
1227
1214
|
}
|
|
@@ -1231,141 +1218,284 @@ function _getStxBalance() {
|
|
|
1231
1218
|
return _getStxBalance.apply(this, arguments);
|
|
1232
1219
|
}
|
|
1233
1220
|
|
|
1234
|
-
function
|
|
1235
|
-
|
|
1221
|
+
function makeRandomAddress(version) {
|
|
1222
|
+
if (version === void 0) {
|
|
1223
|
+
version = StacksNetworkVersion.testnetP2PKH;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
var privateKey = makeRandomPrivKey();
|
|
1227
|
+
var publicKey = getPublicKeyFromStacksPrivateKey(privateKey);
|
|
1228
|
+
var address = publicKeyToStxAddress(publicKey.data, version);
|
|
1229
|
+
return address;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
function formatArguments(args) {
|
|
1233
|
+
return args.map(function (arg) {
|
|
1234
|
+
return cvToString(arg);
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
function getIdentifier(tx) {
|
|
1239
|
+
return tx.contractAddress + "." + tx.contractName;
|
|
1236
1240
|
}
|
|
1237
1241
|
|
|
1238
|
-
function
|
|
1239
|
-
|
|
1240
|
-
|
|
1242
|
+
function getLogs(stderr) {
|
|
1243
|
+
if (stderr === '') return [];
|
|
1244
|
+
return stderr.split('\n').map(function (line) {
|
|
1245
|
+
return line.slice(62);
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
function makeEvalResult(result) {
|
|
1250
|
+
var resultCV = hexToCV(result.output_serialized);
|
|
1251
|
+
var value = cvToValue(resultCV, true);
|
|
1252
|
+
return {
|
|
1253
|
+
value: value,
|
|
1254
|
+
clarityValue: resultCV,
|
|
1255
|
+
logs: getLogs(result.stderr),
|
|
1256
|
+
costs: result.costs
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
function ro(_x, _x2) {
|
|
1261
|
+
return _ro.apply(this, arguments);
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
function _ro() {
|
|
1265
|
+
_ro = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(tx, bin) {
|
|
1266
|
+
var result;
|
|
1241
1267
|
return runtime_1.wrap(function _callee$(_context) {
|
|
1242
1268
|
while (1) {
|
|
1243
1269
|
switch (_context.prev = _context.next) {
|
|
1244
1270
|
case 0:
|
|
1245
1271
|
_context.next = 2;
|
|
1246
|
-
return
|
|
1247
|
-
|
|
1272
|
+
return evalJson({
|
|
1273
|
+
functionName: tx["function"].name,
|
|
1274
|
+
args: formatArguments(tx.functionArgs),
|
|
1275
|
+
contractAddress: getIdentifier(tx),
|
|
1276
|
+
provider: bin
|
|
1248
1277
|
});
|
|
1249
1278
|
|
|
1250
1279
|
case 2:
|
|
1251
|
-
receipt = _context.sent;
|
|
1252
|
-
_context.next = 5;
|
|
1253
|
-
return receipt.getResult();
|
|
1254
|
-
|
|
1255
|
-
case 5:
|
|
1256
1280
|
result = _context.sent;
|
|
1257
|
-
return _context.abrupt("return", result);
|
|
1281
|
+
return _context.abrupt("return", makeEvalResult(result));
|
|
1258
1282
|
|
|
1259
|
-
case
|
|
1283
|
+
case 4:
|
|
1260
1284
|
case "end":
|
|
1261
1285
|
return _context.stop();
|
|
1262
1286
|
}
|
|
1263
1287
|
}
|
|
1264
1288
|
}, _callee);
|
|
1265
1289
|
}));
|
|
1266
|
-
return
|
|
1290
|
+
return _ro.apply(this, arguments);
|
|
1267
1291
|
}
|
|
1268
1292
|
|
|
1269
|
-
function
|
|
1270
|
-
return
|
|
1293
|
+
function evalCode(_x3) {
|
|
1294
|
+
return _evalCode.apply(this, arguments);
|
|
1271
1295
|
}
|
|
1272
1296
|
|
|
1273
|
-
function
|
|
1274
|
-
|
|
1275
|
-
var result;
|
|
1297
|
+
function _evalCode() {
|
|
1298
|
+
_evalCode = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref) {
|
|
1299
|
+
var contractAddress, code, bin, result;
|
|
1276
1300
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1277
1301
|
while (1) {
|
|
1278
1302
|
switch (_context2.prev = _context2.next) {
|
|
1279
1303
|
case 0:
|
|
1280
|
-
|
|
1281
|
-
|
|
1304
|
+
contractAddress = _ref.contractAddress, code = _ref.code, bin = _ref.bin;
|
|
1305
|
+
_context2.next = 3;
|
|
1306
|
+
return evalRaw({
|
|
1307
|
+
contractAddress: contractAddress,
|
|
1308
|
+
code: code,
|
|
1309
|
+
provider: bin
|
|
1310
|
+
});
|
|
1282
1311
|
|
|
1283
|
-
case
|
|
1312
|
+
case 3:
|
|
1284
1313
|
result = _context2.sent;
|
|
1285
|
-
|
|
1286
|
-
if (result.isOk) {
|
|
1287
|
-
_context2.next = 5;
|
|
1288
|
-
break;
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
throw new Error("Expected transaction ok, got error: " + result.value);
|
|
1314
|
+
return _context2.abrupt("return", makeEvalResult(result));
|
|
1292
1315
|
|
|
1293
1316
|
case 5:
|
|
1294
|
-
return _context2.abrupt("return", result);
|
|
1295
|
-
|
|
1296
|
-
case 6:
|
|
1297
1317
|
case "end":
|
|
1298
1318
|
return _context2.stop();
|
|
1299
1319
|
}
|
|
1300
1320
|
}
|
|
1301
1321
|
}, _callee2);
|
|
1302
1322
|
}));
|
|
1303
|
-
return
|
|
1323
|
+
return _evalCode.apply(this, arguments);
|
|
1304
1324
|
}
|
|
1305
1325
|
|
|
1306
|
-
function
|
|
1307
|
-
return
|
|
1326
|
+
function tx(_x4) {
|
|
1327
|
+
return _tx.apply(this, arguments);
|
|
1308
1328
|
}
|
|
1309
1329
|
|
|
1310
|
-
function
|
|
1311
|
-
|
|
1312
|
-
var result;
|
|
1330
|
+
function _tx() {
|
|
1331
|
+
_tx = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(_ref2) {
|
|
1332
|
+
var tx, senderAddress, bin, result, resultCV, value, baseReturn;
|
|
1313
1333
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1314
1334
|
while (1) {
|
|
1315
1335
|
switch (_context3.prev = _context3.next) {
|
|
1316
1336
|
case 0:
|
|
1317
|
-
|
|
1318
|
-
|
|
1337
|
+
tx = _ref2.tx, senderAddress = _ref2.senderAddress, bin = _ref2.bin;
|
|
1338
|
+
_context3.next = 3;
|
|
1339
|
+
return executeJson({
|
|
1340
|
+
contractAddress: getIdentifier(tx),
|
|
1341
|
+
senderAddress: senderAddress,
|
|
1342
|
+
provider: bin,
|
|
1343
|
+
functionName: tx["function"].name,
|
|
1344
|
+
args: formatArguments(tx.functionArgs)
|
|
1345
|
+
});
|
|
1319
1346
|
|
|
1320
|
-
case
|
|
1347
|
+
case 3:
|
|
1321
1348
|
result = _context3.sent;
|
|
1349
|
+
resultCV = hexToCV(result.output_serialized);
|
|
1350
|
+
value = cvToValue(resultCV);
|
|
1351
|
+
baseReturn = {
|
|
1352
|
+
value: value,
|
|
1353
|
+
logs: getLogs(result.stderr),
|
|
1354
|
+
costs: result.costs
|
|
1355
|
+
};
|
|
1322
1356
|
|
|
1323
|
-
if (!result.
|
|
1324
|
-
_context3.next =
|
|
1357
|
+
if (!result.success) {
|
|
1358
|
+
_context3.next = 9;
|
|
1325
1359
|
break;
|
|
1326
1360
|
}
|
|
1327
1361
|
|
|
1328
|
-
|
|
1362
|
+
return _context3.abrupt("return", _extends({}, baseReturn, {
|
|
1363
|
+
isOk: true,
|
|
1364
|
+
response: responseOkCV(resultCV),
|
|
1365
|
+
assets: result.assets,
|
|
1366
|
+
events: result.events,
|
|
1367
|
+
prints: getPrints(result.events)
|
|
1368
|
+
}));
|
|
1329
1369
|
|
|
1330
|
-
case
|
|
1331
|
-
return _context3.abrupt("return",
|
|
1370
|
+
case 9:
|
|
1371
|
+
return _context3.abrupt("return", _extends({}, baseReturn, {
|
|
1372
|
+
isOk: false,
|
|
1373
|
+
response: responseErrorCV(resultCV)
|
|
1374
|
+
}));
|
|
1332
1375
|
|
|
1333
|
-
case
|
|
1376
|
+
case 10:
|
|
1334
1377
|
case "end":
|
|
1335
1378
|
return _context3.stop();
|
|
1336
1379
|
}
|
|
1337
1380
|
}
|
|
1338
1381
|
}, _callee3);
|
|
1339
1382
|
}));
|
|
1340
|
-
return
|
|
1383
|
+
return _tx.apply(this, arguments);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
function mapGet(_x5) {
|
|
1387
|
+
return _mapGet.apply(this, arguments);
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
function _mapGet() {
|
|
1391
|
+
_mapGet = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(_ref3) {
|
|
1392
|
+
var map, bin, code, result;
|
|
1393
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
1394
|
+
while (1) {
|
|
1395
|
+
switch (_context4.prev = _context4.next) {
|
|
1396
|
+
case 0:
|
|
1397
|
+
map = _ref3.map, bin = _ref3.bin;
|
|
1398
|
+
code = "(map-get? " + map.map.name + " " + cvToString(map.key) + ")";
|
|
1399
|
+
_context4.next = 4;
|
|
1400
|
+
return evalCode({
|
|
1401
|
+
contractAddress: getIdentifier(map),
|
|
1402
|
+
code: code,
|
|
1403
|
+
bin: bin
|
|
1404
|
+
});
|
|
1405
|
+
|
|
1406
|
+
case 4:
|
|
1407
|
+
result = _context4.sent;
|
|
1408
|
+
return _context4.abrupt("return", result.value);
|
|
1409
|
+
|
|
1410
|
+
case 6:
|
|
1411
|
+
case "end":
|
|
1412
|
+
return _context4.stop();
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
}, _callee4);
|
|
1416
|
+
}));
|
|
1417
|
+
return _mapGet.apply(this, arguments);
|
|
1341
1418
|
}
|
|
1342
1419
|
|
|
1343
1420
|
var TestProvider = /*#__PURE__*/function () {
|
|
1344
|
-
function TestProvider(clarityBin
|
|
1421
|
+
function TestProvider(clarityBin) {
|
|
1345
1422
|
this.clarityBin = clarityBin;
|
|
1346
|
-
this.contractIdentifier = contractIdentifier;
|
|
1347
|
-
this.contractFile = contractFile;
|
|
1348
1423
|
}
|
|
1349
1424
|
|
|
1350
|
-
TestProvider.
|
|
1351
|
-
var
|
|
1352
|
-
var clarityBin,
|
|
1425
|
+
TestProvider.fromContracts = /*#__PURE__*/function () {
|
|
1426
|
+
var _fromContracts = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(contracts, options) {
|
|
1427
|
+
var clarityBin, instances, k, contract, identifier, instance, provider;
|
|
1353
1428
|
return runtime_1.wrap(function _callee$(_context) {
|
|
1354
1429
|
while (1) {
|
|
1355
1430
|
switch (_context.prev = _context.next) {
|
|
1356
1431
|
case 0:
|
|
1357
|
-
|
|
1358
|
-
|
|
1432
|
+
if (options === void 0) {
|
|
1433
|
+
options = {};
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
_context.t0 = options.clarityBin;
|
|
1437
|
+
|
|
1438
|
+
if (_context.t0) {
|
|
1439
|
+
_context.next = 6;
|
|
1440
|
+
break;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
_context.next = 5;
|
|
1444
|
+
return createClarityBin$1();
|
|
1445
|
+
|
|
1446
|
+
case 5:
|
|
1447
|
+
_context.t0 = _context.sent;
|
|
1448
|
+
|
|
1449
|
+
case 6:
|
|
1450
|
+
clarityBin = _context.t0;
|
|
1451
|
+
instances = {};
|
|
1452
|
+
_context.next = 10;
|
|
1453
|
+
return deployUtilContract(clarityBin);
|
|
1454
|
+
|
|
1455
|
+
case 10:
|
|
1456
|
+
_context.t1 = runtime_1.keys(contracts);
|
|
1457
|
+
|
|
1458
|
+
case 11:
|
|
1459
|
+
if ((_context.t2 = _context.t1()).done) {
|
|
1460
|
+
_context.next = 22;
|
|
1461
|
+
break;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
k = _context.t2.value;
|
|
1465
|
+
|
|
1466
|
+
if (!Object.prototype.hasOwnProperty.call(contracts, k)) {
|
|
1467
|
+
_context.next = 20;
|
|
1468
|
+
break;
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
contract = contracts[k];
|
|
1472
|
+
identifier = getContractIdentifier(contract);
|
|
1473
|
+
_context.next = 18;
|
|
1359
1474
|
return deployContract({
|
|
1360
|
-
contractIdentifier:
|
|
1361
|
-
contractFilePath:
|
|
1475
|
+
contractIdentifier: identifier,
|
|
1476
|
+
contractFilePath: contract.contractFile,
|
|
1362
1477
|
provider: clarityBin
|
|
1363
1478
|
});
|
|
1364
1479
|
|
|
1365
|
-
case
|
|
1366
|
-
|
|
1480
|
+
case 18:
|
|
1481
|
+
instance = contract.contract(contract.address, contract.name);
|
|
1482
|
+
instances[k] = {
|
|
1483
|
+
identifier: getContractIdentifier(contract),
|
|
1484
|
+
contract: instance
|
|
1485
|
+
};
|
|
1367
1486
|
|
|
1368
|
-
case
|
|
1487
|
+
case 20:
|
|
1488
|
+
_context.next = 11;
|
|
1489
|
+
break;
|
|
1490
|
+
|
|
1491
|
+
case 22:
|
|
1492
|
+
provider = new this(clarityBin);
|
|
1493
|
+
return _context.abrupt("return", {
|
|
1494
|
+
deployed: instances,
|
|
1495
|
+
provider: provider
|
|
1496
|
+
});
|
|
1497
|
+
|
|
1498
|
+
case 24:
|
|
1369
1499
|
case "end":
|
|
1370
1500
|
return _context.stop();
|
|
1371
1501
|
}
|
|
@@ -1373,44 +1503,34 @@ var TestProvider = /*#__PURE__*/function () {
|
|
|
1373
1503
|
}, _callee, this);
|
|
1374
1504
|
}));
|
|
1375
1505
|
|
|
1376
|
-
function
|
|
1377
|
-
return
|
|
1506
|
+
function fromContracts(_x, _x2) {
|
|
1507
|
+
return _fromContracts.apply(this, arguments);
|
|
1378
1508
|
}
|
|
1379
1509
|
|
|
1380
|
-
return
|
|
1510
|
+
return fromContracts;
|
|
1381
1511
|
}();
|
|
1382
1512
|
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1513
|
+
var _proto = TestProvider.prototype;
|
|
1514
|
+
|
|
1515
|
+
_proto.ro = function ro$1(tx) {
|
|
1516
|
+
return ro(tx, this.clarityBin);
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1519
|
+
_proto.rov = /*#__PURE__*/function () {
|
|
1520
|
+
var _rov = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(tx) {
|
|
1521
|
+
var result;
|
|
1386
1522
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1387
1523
|
while (1) {
|
|
1388
1524
|
switch (_context2.prev = _context2.next) {
|
|
1389
1525
|
case 0:
|
|
1390
|
-
|
|
1391
|
-
|
|
1526
|
+
_context2.next = 2;
|
|
1527
|
+
return this.ro(tx);
|
|
1392
1528
|
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
throw new Error('TestProvider must have an address');
|
|
1529
|
+
case 2:
|
|
1530
|
+
result = _context2.sent;
|
|
1531
|
+
return _context2.abrupt("return", result.value);
|
|
1399
1532
|
|
|
1400
1533
|
case 4:
|
|
1401
|
-
contractName = contract.name || getContractNameFromPath(contract.contractFile);
|
|
1402
|
-
_context2.next = 7;
|
|
1403
|
-
return this.create({
|
|
1404
|
-
clarityBin: clarityBin,
|
|
1405
|
-
contractFilePath: contract.contractFile,
|
|
1406
|
-
contractIdentifier: address + "." + contractName
|
|
1407
|
-
});
|
|
1408
|
-
|
|
1409
|
-
case 7:
|
|
1410
|
-
provider = _context2.sent;
|
|
1411
|
-
return _context2.abrupt("return", contract.contract(provider));
|
|
1412
|
-
|
|
1413
|
-
case 9:
|
|
1414
1534
|
case "end":
|
|
1415
1535
|
return _context2.stop();
|
|
1416
1536
|
}
|
|
@@ -1418,216 +1538,275 @@ var TestProvider = /*#__PURE__*/function () {
|
|
|
1418
1538
|
}, _callee2, this);
|
|
1419
1539
|
}));
|
|
1420
1540
|
|
|
1421
|
-
function
|
|
1422
|
-
return
|
|
1541
|
+
function rov(_x3) {
|
|
1542
|
+
return _rov.apply(this, arguments);
|
|
1423
1543
|
}
|
|
1424
1544
|
|
|
1425
|
-
return
|
|
1545
|
+
return rov;
|
|
1426
1546
|
}();
|
|
1427
1547
|
|
|
1428
|
-
|
|
1429
|
-
var
|
|
1430
|
-
var
|
|
1548
|
+
_proto.roOk = /*#__PURE__*/function () {
|
|
1549
|
+
var _roOk = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(tx) {
|
|
1550
|
+
var result;
|
|
1431
1551
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1432
1552
|
while (1) {
|
|
1433
1553
|
switch (_context3.prev = _context3.next) {
|
|
1434
1554
|
case 0:
|
|
1435
1555
|
_context3.next = 2;
|
|
1436
|
-
return
|
|
1556
|
+
return this.ro(tx);
|
|
1437
1557
|
|
|
1438
1558
|
case 2:
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1559
|
+
result = _context3.sent;
|
|
1560
|
+
return _context3.abrupt("return", result.value.match(function (ok) {
|
|
1561
|
+
return _extends({}, result, {
|
|
1562
|
+
value: ok
|
|
1563
|
+
});
|
|
1564
|
+
}, function (err) {
|
|
1565
|
+
throw new Error("Expected OK, received error: " + err);
|
|
1566
|
+
}));
|
|
1443
1567
|
|
|
1444
|
-
case
|
|
1445
|
-
|
|
1568
|
+
case 4:
|
|
1569
|
+
case "end":
|
|
1570
|
+
return _context3.stop();
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
}, _callee3, this);
|
|
1574
|
+
}));
|
|
1446
1575
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
break;
|
|
1451
|
-
}
|
|
1576
|
+
function roOk(_x4) {
|
|
1577
|
+
return _roOk.apply(this, arguments);
|
|
1578
|
+
}
|
|
1452
1579
|
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
_context3.next = 12;
|
|
1456
|
-
return this.fromContract({
|
|
1457
|
-
contract: contract,
|
|
1458
|
-
clarityBin: clarityBin
|
|
1459
|
-
});
|
|
1580
|
+
return roOk;
|
|
1581
|
+
}();
|
|
1460
1582
|
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1583
|
+
_proto.roErr = /*#__PURE__*/function () {
|
|
1584
|
+
var _roErr = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(tx) {
|
|
1585
|
+
var result;
|
|
1586
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
1587
|
+
while (1) {
|
|
1588
|
+
switch (_context4.prev = _context4.next) {
|
|
1589
|
+
case 0:
|
|
1590
|
+
_context4.next = 2;
|
|
1591
|
+
return this.ro(tx);
|
|
1469
1592
|
|
|
1470
|
-
case
|
|
1471
|
-
|
|
1593
|
+
case 2:
|
|
1594
|
+
result = _context4.sent;
|
|
1595
|
+
return _context4.abrupt("return", result.value.match(function (ok) {
|
|
1596
|
+
throw new Error("Expected err, received ok: " + ok);
|
|
1597
|
+
}, function (err) {
|
|
1598
|
+
return _extends({}, result, {
|
|
1599
|
+
value: err
|
|
1600
|
+
});
|
|
1601
|
+
}));
|
|
1472
1602
|
|
|
1473
|
-
case
|
|
1603
|
+
case 4:
|
|
1474
1604
|
case "end":
|
|
1475
|
-
return
|
|
1605
|
+
return _context4.stop();
|
|
1476
1606
|
}
|
|
1477
1607
|
}
|
|
1478
|
-
},
|
|
1608
|
+
}, _callee4, this);
|
|
1479
1609
|
}));
|
|
1480
1610
|
|
|
1481
|
-
function
|
|
1482
|
-
return
|
|
1611
|
+
function roErr(_x5) {
|
|
1612
|
+
return _roErr.apply(this, arguments);
|
|
1483
1613
|
}
|
|
1484
1614
|
|
|
1485
|
-
return
|
|
1615
|
+
return roErr;
|
|
1486
1616
|
}();
|
|
1487
1617
|
|
|
1488
|
-
|
|
1618
|
+
_proto.rovOk = /*#__PURE__*/function () {
|
|
1619
|
+
var _rovOk = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(tx) {
|
|
1620
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
1621
|
+
while (1) {
|
|
1622
|
+
switch (_context5.prev = _context5.next) {
|
|
1623
|
+
case 0:
|
|
1624
|
+
_context5.next = 2;
|
|
1625
|
+
return this.roOk(tx);
|
|
1489
1626
|
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1627
|
+
case 2:
|
|
1628
|
+
return _context5.abrupt("return", _context5.sent.value);
|
|
1629
|
+
|
|
1630
|
+
case 3:
|
|
1631
|
+
case "end":
|
|
1632
|
+
return _context5.stop();
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
}, _callee5, this);
|
|
1636
|
+
}));
|
|
1637
|
+
|
|
1638
|
+
function rovOk(_x6) {
|
|
1639
|
+
return _rovOk.apply(this, arguments);
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
return rovOk;
|
|
1643
|
+
}();
|
|
1644
|
+
|
|
1645
|
+
_proto.rovErr = /*#__PURE__*/function () {
|
|
1646
|
+
var _rovErr = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(tx) {
|
|
1647
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
1494
1648
|
while (1) {
|
|
1495
|
-
switch (
|
|
1649
|
+
switch (_context6.prev = _context6.next) {
|
|
1496
1650
|
case 0:
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
args: argsFormatted,
|
|
1503
|
-
provider: this.clarityBin
|
|
1504
|
-
});
|
|
1651
|
+
_context6.next = 2;
|
|
1652
|
+
return this.roErr(tx);
|
|
1653
|
+
|
|
1654
|
+
case 2:
|
|
1655
|
+
return _context6.abrupt("return", _context6.sent.value);
|
|
1505
1656
|
|
|
1506
1657
|
case 3:
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1658
|
+
case "end":
|
|
1659
|
+
return _context6.stop();
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
}, _callee6, this);
|
|
1663
|
+
}));
|
|
1513
1664
|
|
|
1514
|
-
|
|
1515
|
-
|
|
1665
|
+
function rovErr(_x7) {
|
|
1666
|
+
return _rovErr.apply(this, arguments);
|
|
1667
|
+
}
|
|
1516
1668
|
|
|
1517
|
-
|
|
1518
|
-
|
|
1669
|
+
return rovErr;
|
|
1670
|
+
}();
|
|
1519
1671
|
|
|
1520
|
-
|
|
1521
|
-
|
|
1672
|
+
_proto.tx = function tx$1(_tx2, senderAddress) {
|
|
1673
|
+
return tx({
|
|
1674
|
+
tx: _tx2,
|
|
1675
|
+
senderAddress: senderAddress,
|
|
1676
|
+
bin: this.clarityBin
|
|
1677
|
+
});
|
|
1678
|
+
};
|
|
1522
1679
|
|
|
1523
|
-
|
|
1680
|
+
_proto.txOk = /*#__PURE__*/function () {
|
|
1681
|
+
var _txOk = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(tx, senderAddress) {
|
|
1682
|
+
var result;
|
|
1683
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
1684
|
+
while (1) {
|
|
1685
|
+
switch (_context7.prev = _context7.next) {
|
|
1686
|
+
case 0:
|
|
1687
|
+
_context7.next = 2;
|
|
1688
|
+
return this.tx(tx, senderAddress);
|
|
1689
|
+
|
|
1690
|
+
case 2:
|
|
1691
|
+
result = _context7.sent;
|
|
1692
|
+
|
|
1693
|
+
if (result.isOk) {
|
|
1694
|
+
_context7.next = 5;
|
|
1695
|
+
break;
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
throw new Error("Expected OK, received error: " + result.value);
|
|
1699
|
+
|
|
1700
|
+
case 5:
|
|
1701
|
+
return _context7.abrupt("return", result);
|
|
1702
|
+
|
|
1703
|
+
case 6:
|
|
1524
1704
|
case "end":
|
|
1525
|
-
return
|
|
1705
|
+
return _context7.stop();
|
|
1526
1706
|
}
|
|
1527
1707
|
}
|
|
1528
|
-
},
|
|
1708
|
+
}, _callee7, this);
|
|
1529
1709
|
}));
|
|
1530
1710
|
|
|
1531
|
-
function
|
|
1532
|
-
return
|
|
1711
|
+
function txOk(_x8, _x9) {
|
|
1712
|
+
return _txOk.apply(this, arguments);
|
|
1533
1713
|
}
|
|
1534
1714
|
|
|
1535
|
-
return
|
|
1715
|
+
return txOk;
|
|
1536
1716
|
}();
|
|
1537
1717
|
|
|
1538
|
-
_proto.
|
|
1539
|
-
var
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
while (1) {
|
|
1548
|
-
switch (_context5.prev = _context5.next) {
|
|
1549
|
-
case 0:
|
|
1550
|
-
if ('sender' in options) {
|
|
1551
|
-
_context5.next = 2;
|
|
1552
|
-
break;
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
throw new Error('Passing `sender` is required.');
|
|
1556
|
-
|
|
1557
|
-
case 2:
|
|
1558
|
-
_context5.next = 4;
|
|
1559
|
-
return executeJson({
|
|
1560
|
-
provider: _this.clarityBin,
|
|
1561
|
-
contractAddress: _this.contractIdentifier,
|
|
1562
|
-
senderAddress: options.sender,
|
|
1563
|
-
functionName: func.name,
|
|
1564
|
-
args: argsFormatted
|
|
1565
|
-
});
|
|
1718
|
+
_proto.txErr = /*#__PURE__*/function () {
|
|
1719
|
+
var _txErr = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(tx, senderAddress) {
|
|
1720
|
+
var result;
|
|
1721
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
1722
|
+
while (1) {
|
|
1723
|
+
switch (_context8.prev = _context8.next) {
|
|
1724
|
+
case 0:
|
|
1725
|
+
_context8.next = 2;
|
|
1726
|
+
return this.tx(tx, senderAddress);
|
|
1566
1727
|
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
getResult = function getResult() {
|
|
1571
|
-
var resultCV = deserializeCV(Buffer.from(receipt.output_serialized, 'hex'));
|
|
1572
|
-
var result = cvToValue(resultCV);
|
|
1573
|
-
|
|
1574
|
-
if (receipt.success) {
|
|
1575
|
-
return Promise.resolve({
|
|
1576
|
-
isOk: true,
|
|
1577
|
-
response: responseOkCV(resultCV),
|
|
1578
|
-
value: result,
|
|
1579
|
-
events: receipt.events,
|
|
1580
|
-
costs: receipt.costs,
|
|
1581
|
-
assets: receipt.assets
|
|
1582
|
-
});
|
|
1583
|
-
} else {
|
|
1584
|
-
return Promise.resolve({
|
|
1585
|
-
isOk: false,
|
|
1586
|
-
response: responseErrorCV(resultCV),
|
|
1587
|
-
value: result,
|
|
1588
|
-
costs: receipt.costs
|
|
1589
|
-
});
|
|
1590
|
-
}
|
|
1591
|
-
};
|
|
1592
|
-
|
|
1593
|
-
return _context5.abrupt("return", {
|
|
1594
|
-
getResult: getResult
|
|
1595
|
-
});
|
|
1728
|
+
case 2:
|
|
1729
|
+
result = _context8.sent;
|
|
1596
1730
|
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1731
|
+
if (!result.isOk) {
|
|
1732
|
+
_context8.next = 5;
|
|
1733
|
+
break;
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
throw new Error("Expected Err, received ok: " + result.value);
|
|
1737
|
+
|
|
1738
|
+
case 5:
|
|
1739
|
+
return _context8.abrupt("return", result);
|
|
1740
|
+
|
|
1741
|
+
case 6:
|
|
1742
|
+
case "end":
|
|
1743
|
+
return _context8.stop();
|
|
1601
1744
|
}
|
|
1602
|
-
}
|
|
1603
|
-
})
|
|
1745
|
+
}
|
|
1746
|
+
}, _callee8, this);
|
|
1747
|
+
}));
|
|
1604
1748
|
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
}();
|
|
1749
|
+
function txErr(_x10, _x11) {
|
|
1750
|
+
return _txErr.apply(this, arguments);
|
|
1751
|
+
}
|
|
1609
1752
|
|
|
1610
|
-
return
|
|
1611
|
-
|
|
1612
|
-
|
|
1753
|
+
return txErr;
|
|
1754
|
+
}();
|
|
1755
|
+
|
|
1756
|
+
_proto.evalCode = function evalCode$1(code, contractAddress) {
|
|
1757
|
+
if (contractAddress === void 0) {
|
|
1758
|
+
contractAddress = UTIL_CONTRACT_ID;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
return evalCode({
|
|
1762
|
+
contractAddress: contractAddress,
|
|
1763
|
+
code: code,
|
|
1764
|
+
bin: this.clarityBin
|
|
1765
|
+
});
|
|
1613
1766
|
};
|
|
1614
1767
|
|
|
1615
|
-
_proto.
|
|
1616
|
-
|
|
1617
|
-
var
|
|
1768
|
+
_proto.eval = /*#__PURE__*/function () {
|
|
1769
|
+
var _eval2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(code, contractAddress) {
|
|
1770
|
+
var result;
|
|
1771
|
+
return runtime_1.wrap(function _callee9$(_context9) {
|
|
1772
|
+
while (1) {
|
|
1773
|
+
switch (_context9.prev = _context9.next) {
|
|
1774
|
+
case 0:
|
|
1775
|
+
if (contractAddress === void 0) {
|
|
1776
|
+
contractAddress = UTIL_CONTRACT_ID;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
_context9.next = 3;
|
|
1780
|
+
return this.evalCode(code, contractAddress);
|
|
1618
1781
|
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1782
|
+
case 3:
|
|
1783
|
+
result = _context9.sent;
|
|
1784
|
+
return _context9.abrupt("return", result.value);
|
|
1785
|
+
|
|
1786
|
+
case 5:
|
|
1787
|
+
case "end":
|
|
1788
|
+
return _context9.stop();
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
}, _callee9, this);
|
|
1792
|
+
}));
|
|
1793
|
+
|
|
1794
|
+
function _eval(_x12, _x13) {
|
|
1795
|
+
return _eval2.apply(this, arguments);
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
return _eval;
|
|
1799
|
+
}();
|
|
1622
1800
|
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1801
|
+
_proto.mapGet = function mapGet$1(map) {
|
|
1802
|
+
return mapGet({
|
|
1803
|
+
map: map,
|
|
1804
|
+
bin: this.clarityBin
|
|
1626
1805
|
});
|
|
1627
1806
|
};
|
|
1628
1807
|
|
|
1629
1808
|
return TestProvider;
|
|
1630
1809
|
}();
|
|
1631
1810
|
|
|
1632
|
-
export { TestProvider, createClarityBin, evalJson, executeJson, getBlockHeight, getStxBalance,
|
|
1811
|
+
export { TestProvider, createClarityBin, evalJson, executeJson, getBlockHeight, getStxBalance, makeRandomAddress, mineBlocks };
|
|
1633
1812
|
//# sourceMappingURL=test.esm.js.map
|