@clarigen/core 0.3.4 → 1.0.0-next.7

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/api.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { StacksNetwork } from 'micro-stacks/network';
2
+ import { StacksTransaction } from 'micro-stacks/transactions';
3
+ import { ClarityTypes } from './clarity-types';
4
+ import { ContractCall } from './pure';
5
+ interface ApiOptions {
6
+ network: StacksNetwork;
7
+ }
8
+ export declare function ro<T>(tx: ContractCall<T>, options: ApiOptions): Promise<T>;
9
+ export declare function roOk<Ok>(tx: ContractCall<ClarityTypes.Response<Ok, any>>, options: ApiOptions): Promise<Ok>;
10
+ export declare function roErr<Err>(tx: ContractCall<ClarityTypes.Response<any, Err>>, options: ApiOptions): Promise<Err>;
11
+ export declare function broadcast(transaction: StacksTransaction, options: ApiOptions): Promise<{
12
+ txId: string;
13
+ stacksTransaction: StacksTransaction;
14
+ }>;
15
+ export {};
@@ -1,4 +1,4 @@
1
- import { ClarityAbiFunction } from '@stacks/transactions';
1
+ import { ClarityAbiFunction } from 'micro-stacks/clarity';
2
2
  import { Transaction } from './transaction';
3
3
  export declare abstract class BaseProvider {
4
4
  callReadOnly(func: ClarityAbiFunction, args: any[]): Promise<void>;
@@ -1,46 +1,34 @@
1
- import type * as Clarity from '@stacks/transactions';
2
- import { ClarityAbi as _ClarityAbi, ClarityAbiType, ClarityAbiTypeTuple, ClarityValue } from '@stacks/transactions';
1
+ import { ClarityAbi as _ClarityAbi, ClarityAbiType, ClarityValue, ClarityAbiFunction } from 'micro-stacks/clarity';
3
2
  import { Result } from 'neverthrow';
3
+ export declare namespace ClarityTypes {
4
+ type Response<Ok, Err> = Result<Ok, Err>;
5
+ }
4
6
  export interface ClarityAbiMap {
5
7
  name: string;
6
- key: {
7
- name: string;
8
- type: ClarityAbiType;
9
- }[] | ClarityAbiTypeTuple | ClarityAbiType;
10
- value: {
11
- name: string;
12
- type: ClarityAbiType;
13
- }[] | ClarityAbiTypeTuple | ClarityAbiType;
8
+ key: ClarityAbiType;
9
+ value: ClarityAbiType;
14
10
  }
15
11
  export interface ClarityAbi extends Omit<_ClarityAbi, 'maps'> {
16
12
  maps: ClarityAbiMap[];
17
13
  clarity_version?: string;
18
14
  }
19
- export declare namespace ClarityTypes {
20
- type BooleanCV = Clarity.BooleanCV;
21
- type TrueCV = Clarity.TrueCV;
22
- type FalseCV = Clarity.FalseCV;
23
- type IntCV = Clarity.IntCV;
24
- type UIntCV = Clarity.UIntCV;
25
- type BufferCV = Clarity.BufferCV;
26
- type OptionalCV = Clarity.OptionalCV;
27
- type NoneCV = Clarity.NoneCV;
28
- type SomeCV = Clarity.SomeCV;
29
- type ResponseCV = Clarity.ResponseCV;
30
- type ResponseOkCV = Clarity.ResponseOkCV;
31
- type ResponseErrorCV = Clarity.ResponseErrorCV;
32
- type PrincipalCV = Clarity.PrincipalCV;
33
- type StandardPrincipalCV = Clarity.StandardPrincipalCV;
34
- type ContractPrincipalCV = Clarity.ContractPrincipalCV;
35
- type ListCV = Clarity.ListCV;
36
- type TupleCV = Clarity.TupleCV;
37
- type StringAsciiCV = Clarity.StringAsciiCV;
38
- type StringUtf8CV = Clarity.StringUtf8CV;
39
- type Response<Ok, Err> = Result<Ok, Err>;
40
- }
41
- export declare function cvToValue(val: ClarityValue): any;
15
+ /**
16
+ * @param val - ClarityValue
17
+ * @param returnResponse - if true, this will return a "response" object from the `neverthrow`
18
+ * library. Otherwise, it returns the inner value of the response (whether ok or err)
19
+ */
20
+ export declare function cvToValue<T = any>(val: ClarityValue, returnResponse?: boolean): T;
21
+ /**
22
+ * Converts a hex encoded string to the javascript clarity value object {type: string; value: any}
23
+ * @param hex - the hex encoded string with or without `0x` prefix
24
+ * @param jsonCompat - enable to serialize bigints to strings
25
+ */
26
+ export declare function hexToCvValue<T>(hex: string, jsonCompat?: boolean): any;
42
27
  declare type TupleInput = Record<string, any>;
43
28
  declare type CVInput = string | boolean | TupleInput | number | bigint;
44
29
  export declare function parseToCV(input: CVInput, type: ClarityAbiType): ClarityValue;
45
30
  export declare function cvToString(val: ClarityValue, encoding?: 'tryAscii' | 'hex'): string;
31
+ export declare function transformArgsToCV(func: ClarityAbiFunction, args: any[]): ClarityValue[];
32
+ export declare function expectOk<Ok>(response: ClarityTypes.Response<Ok, any>): Ok;
33
+ export declare function expectErr<Err>(response: ClarityTypes.Response<any, Err>): Err;
46
34
  export {};
@@ -0,0 +1,6 @@
1
+ import { Contracts, ContractInstances } from './types';
2
+ interface MakeContractsOptions {
3
+ deployerAddress?: string;
4
+ }
5
+ export declare function makeContracts<T extends Contracts<any>>(contracts: T, options?: MakeContractsOptions): ContractInstances<T>;
6
+ export {};
@@ -2,7 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var transactions = require('@stacks/transactions');
5
+ var clarity = require('micro-stacks/clarity');
6
+ var transactions = require('micro-stacks/transactions');
7
+ var common = require('micro-stacks/common');
8
+ var neverthrow = require('neverthrow');
9
+ var api = require('micro-stacks/api');
6
10
 
7
11
  var TESTNET_BURN_ADDRESS = 'ST000000000000000000002AMW42H';
8
12
  var MAINNET_BURN_ADDRESS = 'SP000000000000000000002Q6VF78';
@@ -35,7 +39,7 @@ var getContractIdentifier = function getContractIdentifier(contract) {
35
39
  };
36
40
  var getContractPrincipalCV = function getContractPrincipalCV(contract) {
37
41
  var contractName = getContractNameFromPath(contract.contractFile);
38
- return transactions.contractPrincipalCV(contract.address, contractName);
42
+ return clarity.contractPrincipalCV(contract.address, contractName);
39
43
  };
40
44
  function bootContractIdentifier(name, mainnet) {
41
45
  var addr = mainnet ? MAINNET_BURN_ADDRESS : TESTNET_BURN_ADDRESS;
@@ -56,69 +60,118 @@ function bootContractIdentifier(name, mainnet) {
56
60
  CoreNodeEventType["FtBurnEvent"] = "ft_burn_event";
57
61
  })(exports.CoreNodeEventType || (exports.CoreNodeEventType = {}));
58
62
 
63
+ function makeContracts(contracts, options) {
64
+ if (options === void 0) {
65
+ options = {};
66
+ }
67
+
68
+ var instances = {};
69
+
70
+ for (var k in contracts) {
71
+ var contract = contracts[k];
72
+ var address = options.deployerAddress || contract.address;
73
+ var identifier = address + "." + contract.name;
74
+ var instance = contract.contract(address, contract.name);
75
+ instances[k] = {
76
+ identifier: identifier,
77
+ contract: instance
78
+ };
79
+ }
80
+
81
+ return instances;
82
+ }
83
+
59
84
  function principalToString(principal) {
60
- if (principal.type === transactions.ClarityType.PrincipalStandard) {
61
- return transactions.addressToString(principal.address);
62
- } else if (principal.type === transactions.ClarityType.PrincipalContract) {
63
- var address = transactions.addressToString(principal.address);
85
+ if (principal.type === clarity.ClarityType.PrincipalStandard) {
86
+ return clarity.addressToString(principal.address);
87
+ } else if (principal.type === clarity.ClarityType.PrincipalContract) {
88
+ var address = clarity.addressToString(principal.address);
64
89
  return address + "." + principal.contractName.content;
65
90
  } else {
66
91
  throw new Error("Unexpected principal data: " + JSON.stringify(principal));
67
92
  }
68
93
  }
94
+ /**
95
+ * @param val - ClarityValue
96
+ * @param returnResponse - if true, this will return a "response" object from the `neverthrow`
97
+ * library. Otherwise, it returns the inner value of the response (whether ok or err)
98
+ */
99
+
100
+
101
+ function cvToValue(val, returnResponse) {
102
+ if (returnResponse === void 0) {
103
+ returnResponse = false;
104
+ }
69
105
 
70
- function cvToValue(val) {
71
106
  switch (val.type) {
72
- case transactions.ClarityType.BoolTrue:
107
+ case clarity.ClarityType.BoolTrue:
73
108
  return true;
74
109
 
75
- case transactions.ClarityType.BoolFalse:
110
+ case clarity.ClarityType.BoolFalse:
76
111
  return false;
77
112
 
78
- case transactions.ClarityType.Int:
113
+ case clarity.ClarityType.Int:
114
+ case clarity.ClarityType.UInt:
79
115
  return val.value;
80
116
 
81
- case transactions.ClarityType.UInt:
82
- return val.value;
83
-
84
- case transactions.ClarityType.Buffer:
117
+ case clarity.ClarityType.Buffer:
85
118
  return val.buffer;
86
119
 
87
- case transactions.ClarityType.OptionalNone:
120
+ case clarity.ClarityType.OptionalNone:
88
121
  return null;
89
122
 
90
- case transactions.ClarityType.OptionalSome:
123
+ case clarity.ClarityType.OptionalSome:
91
124
  return cvToValue(val.value);
92
125
 
93
- case transactions.ClarityType.ResponseErr:
126
+ case clarity.ClarityType.ResponseErr:
127
+ if (returnResponse) return neverthrow.err(cvToValue(val.value));
94
128
  return cvToValue(val.value);
95
129
 
96
- case transactions.ClarityType.ResponseOk:
130
+ case clarity.ClarityType.ResponseOk:
131
+ if (returnResponse) return neverthrow.ok(cvToValue(val.value));
97
132
  return cvToValue(val.value);
98
133
 
99
- case transactions.ClarityType.PrincipalStandard:
100
- case transactions.ClarityType.PrincipalContract:
134
+ case clarity.ClarityType.PrincipalStandard:
135
+ case clarity.ClarityType.PrincipalContract:
101
136
  return principalToString(val);
102
137
 
103
- case transactions.ClarityType.List:
138
+ case clarity.ClarityType.List:
104
139
  return val.list.map(function (v) {
105
140
  return cvToValue(v);
106
141
  });
107
142
 
108
- case transactions.ClarityType.Tuple:
143
+ case clarity.ClarityType.Tuple:
109
144
  var result = {};
110
- Object.keys(val.data).forEach(function (key) {
111
- result[key] = cvToValue(val.data[key]);
145
+ var arr = Object.keys(val.data).map(function (key) {
146
+ return [key, cvToValue(val.data[key])];
147
+ });
148
+ arr.forEach(function (_ref) {
149
+ var key = _ref[0],
150
+ value = _ref[1];
151
+ result[key] = value;
112
152
  });
113
153
  return result;
114
154
 
115
- case transactions.ClarityType.StringASCII:
155
+ case clarity.ClarityType.StringASCII:
116
156
  return val.data;
117
157
 
118
- case transactions.ClarityType.StringUTF8:
158
+ case clarity.ClarityType.StringUTF8:
119
159
  return val.data;
120
160
  }
121
161
  }
162
+ /**
163
+ * Converts a hex encoded string to the javascript clarity value object {type: string; value: any}
164
+ * @param hex - the hex encoded string with or without `0x` prefix
165
+ * @param jsonCompat - enable to serialize bigints to strings
166
+ */
167
+
168
+ function hexToCvValue(hex, jsonCompat) {
169
+ if (jsonCompat === void 0) {
170
+ jsonCompat = false;
171
+ }
172
+
173
+ return cvToValue(clarity.hexToCV(hex), jsonCompat);
174
+ }
122
175
 
123
176
  function inputToBigInt(input) {
124
177
  var isBigInt = typeof input === 'bigint';
@@ -144,38 +197,38 @@ function parseToCV(input, type) {
144
197
  var val = input[key.name];
145
198
  tuple[key.name] = parseToCV(val, key.type);
146
199
  });
147
- return transactions.tupleCV(tuple);
200
+ return clarity.tupleCV(tuple);
148
201
  } else if (transactions.isClarityAbiList(type)) {
149
202
  var inputs = input;
150
203
  var values = inputs.map(function (input) {
151
204
  return parseToCV(input, type.list.type);
152
205
  });
153
- return transactions.listCV(values);
206
+ return clarity.listCV(values);
154
207
  } else if (transactions.isClarityAbiOptional(type)) {
155
- if (!input) return transactions.noneCV();
156
- return transactions.someCV(parseToCV(input, type.optional));
208
+ if (!input) return clarity.noneCV();
209
+ return clarity.someCV(parseToCV(input, type.optional));
157
210
  } else if (transactions.isClarityAbiStringAscii(type)) {
158
211
  if (typeof input !== 'string') {
159
212
  throw new Error('Invalid string-ascii input');
160
213
  }
161
214
 
162
- return transactions.stringAsciiCV(input);
215
+ return clarity.stringAsciiCV(input);
163
216
  } else if (transactions.isClarityAbiStringUtf8(type)) {
164
217
  if (typeof input !== 'string') {
165
218
  throw new Error('Invalid string-ascii input');
166
219
  }
167
220
 
168
- return transactions.stringUtf8CV(input);
221
+ return clarity.stringUtf8CV(input);
169
222
  } else if (type === 'bool') {
170
223
  var inputString = typeof input === 'boolean' ? input.toString() : input;
171
224
  return transactions.parseToCV(inputString, type);
172
225
  } else if (type === 'uint128') {
173
226
  var bigi = inputToBigInt(input);
174
- return transactions.uintCV(bigi.toString());
227
+ return clarity.uintCV(bigi.toString());
175
228
  } else if (type === 'int128') {
176
229
  var _bigi = inputToBigInt(input);
177
230
 
178
- return transactions.intCV(_bigi.toString());
231
+ return clarity.intCV(_bigi.toString());
179
232
  } else if (type === 'trait_reference') {
180
233
  if (typeof input !== 'string') throw new Error('Invalid input for trait_reference');
181
234
 
@@ -183,7 +236,9 @@ function parseToCV(input, type) {
183
236
  addr = _input$split[0],
184
237
  name = _input$split[1];
185
238
 
186
- return transactions.contractPrincipalCV(addr, name);
239
+ return clarity.contractPrincipalCV(addr, name);
240
+ } else if (transactions.isClarityAbiBuffer(type)) {
241
+ return clarity.bufferCV(input);
187
242
  }
188
243
 
189
244
  return transactions.parseToCV(input, type);
@@ -194,62 +249,136 @@ function cvToString(val, encoding) {
194
249
  }
195
250
 
196
251
  switch (val.type) {
197
- case transactions.ClarityType.BoolTrue:
252
+ case clarity.ClarityType.BoolTrue:
198
253
  return 'true';
199
254
 
200
- case transactions.ClarityType.BoolFalse:
255
+ case clarity.ClarityType.BoolFalse:
201
256
  return 'false';
202
257
 
203
- case transactions.ClarityType.Int:
258
+ case clarity.ClarityType.Int:
204
259
  return val.value.toString();
205
260
 
206
- case transactions.ClarityType.UInt:
261
+ case clarity.ClarityType.UInt:
207
262
  return "u" + val.value.toString();
208
263
 
209
- case transactions.ClarityType.Buffer:
264
+ case clarity.ClarityType.Buffer:
210
265
  if (encoding === 'tryAscii') {
211
- var str = val.buffer.toString('ascii');
266
+ var str = common.bytesToAscii(val.buffer);
212
267
 
213
268
  if (/[ -~]/.test(str)) {
214
269
  return JSON.stringify(str);
215
270
  }
216
271
  }
217
272
 
218
- return "0x" + val.buffer.toString('hex');
273
+ return "0x" + common.bytesToHex(val.buffer);
219
274
 
220
- case transactions.ClarityType.OptionalNone:
275
+ case clarity.ClarityType.OptionalNone:
221
276
  return 'none';
222
277
 
223
- case transactions.ClarityType.OptionalSome:
278
+ case clarity.ClarityType.OptionalSome:
224
279
  return "(some " + cvToString(val.value, encoding) + ")";
225
280
 
226
- case transactions.ClarityType.ResponseErr:
281
+ case clarity.ClarityType.ResponseErr:
227
282
  return "(err " + cvToString(val.value, encoding) + ")";
228
283
 
229
- case transactions.ClarityType.ResponseOk:
284
+ case clarity.ClarityType.ResponseOk:
230
285
  return "(ok " + cvToString(val.value, encoding) + ")";
231
286
 
232
- case transactions.ClarityType.PrincipalStandard:
233
- case transactions.ClarityType.PrincipalContract:
287
+ case clarity.ClarityType.PrincipalStandard:
288
+ case clarity.ClarityType.PrincipalContract:
234
289
  return "'" + principalToString(val);
235
290
 
236
- case transactions.ClarityType.List:
291
+ case clarity.ClarityType.List:
237
292
  return "(list " + val.list.map(function (v) {
238
293
  return cvToString(v, encoding);
239
294
  }).join(' ') + ")";
240
295
 
241
- case transactions.ClarityType.Tuple:
296
+ case clarity.ClarityType.Tuple:
242
297
  return "(tuple " + Object.keys(val.data).map(function (key) {
243
298
  return "(" + key + " " + cvToString(val.data[key], encoding) + ")";
244
299
  }).join(' ') + ")";
245
300
 
246
- case transactions.ClarityType.StringASCII:
301
+ case clarity.ClarityType.StringASCII:
247
302
  return "\"" + val.data + "\"";
248
303
 
249
- case transactions.ClarityType.StringUTF8:
304
+ case clarity.ClarityType.StringUTF8:
250
305
  return "u\"" + val.data + "\"";
251
306
  }
252
307
  }
308
+ function transformArgsToCV(func, args) {
309
+ return args.map(function (arg, index) {
310
+ return parseToCV(arg, func.args[index].type);
311
+ });
312
+ }
313
+ function expectOk(response) {
314
+ return response.match(function (ok) {
315
+ return ok;
316
+ }, function (err) {
317
+ throw new Error("Expected OK, received error: " + err);
318
+ });
319
+ }
320
+ function expectErr(response) {
321
+ return response.match(function (ok) {
322
+ throw new Error("Expected Err, received Ok: " + ok);
323
+ }, function (err) {
324
+ return err;
325
+ });
326
+ }
327
+
328
+ function transformArguments(func, args) {
329
+ return transformArgsToCV(func, args);
330
+ }
331
+
332
+ function getter(contract, property) {
333
+ var foundFunction = contract.abi.functions.find(function (func) {
334
+ return toCamelCase(func.name) === property;
335
+ });
336
+
337
+ if (foundFunction) {
338
+ return function () {
339
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
340
+ args[_key] = arguments[_key];
341
+ }
342
+
343
+ var functionArgs = transformArguments(foundFunction, args);
344
+ return {
345
+ functionArgs: functionArgs,
346
+ contractAddress: contract.contractAddress,
347
+ contractName: contract.contractName,
348
+ "function": foundFunction,
349
+ nativeArgs: args
350
+ };
351
+ };
352
+ }
353
+
354
+ var foundMap = contract.abi.maps.find(function (map) {
355
+ return toCamelCase(map.name) === property;
356
+ });
357
+
358
+ if (foundMap) {
359
+ return function (key) {
360
+ var keyCV = parseToCV(key, foundMap.key);
361
+ var mapGet = {
362
+ contractAddress: contract.contractAddress,
363
+ contractName: contract.contractName,
364
+ map: foundMap,
365
+ nativeKey: key,
366
+ key: keyCV
367
+ };
368
+ return mapGet;
369
+ };
370
+ } // TODO: variables, tokens
371
+
372
+
373
+ throw new Error("Invalid function call: no function exists for " + String(property));
374
+ }
375
+
376
+ var proxyHandler = {
377
+ get: getter
378
+ };
379
+ var pureProxy = function pureProxy(target) {
380
+ return new Proxy(target, proxyHandler);
381
+ };
253
382
 
254
383
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
255
384
  try {
@@ -1053,6 +1182,175 @@ var BaseProvider = /*#__PURE__*/function () {
1053
1182
  return BaseProvider;
1054
1183
  }();
1055
1184
 
1185
+ function ro(_x, _x2) {
1186
+ return _ro.apply(this, arguments);
1187
+ }
1188
+
1189
+ function _ro() {
1190
+ _ro = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(tx, options) {
1191
+ var urlBase, url, body, response, msg, parsed;
1192
+ return runtime_1.wrap(function _callee$(_context) {
1193
+ while (1) {
1194
+ switch (_context.prev = _context.next) {
1195
+ case 0:
1196
+ urlBase = options.network.getReadOnlyFunctionCallApiUrl(tx.contractAddress, tx.contractName, tx["function"].name);
1197
+ url = urlBase + "?tip=latest";
1198
+ body = JSON.stringify({
1199
+ sender: tx.contractAddress,
1200
+ arguments: tx.functionArgs.map(function (arg) {
1201
+ return typeof arg === 'string' ? arg : clarity.cvToHex(arg);
1202
+ })
1203
+ });
1204
+ _context.next = 5;
1205
+ return common.fetchPrivate(url, {
1206
+ method: 'POST',
1207
+ body: body,
1208
+ headers: {
1209
+ 'Content-Type': 'application/json'
1210
+ }
1211
+ });
1212
+
1213
+ case 5:
1214
+ response = _context.sent;
1215
+
1216
+ if (response.ok) {
1217
+ _context.next = 17;
1218
+ break;
1219
+ }
1220
+
1221
+ msg = '';
1222
+ _context.prev = 8;
1223
+ _context.next = 11;
1224
+ return response.text();
1225
+
1226
+ case 11:
1227
+ msg = _context.sent;
1228
+ _context.next = 16;
1229
+ break;
1230
+
1231
+ case 14:
1232
+ _context.prev = 14;
1233
+ _context.t0 = _context["catch"](8);
1234
+
1235
+ case 16:
1236
+ throw new Error("Error calling read-only function. Response " + response.status + ": " + response.statusText + ". Attempted to fetch " + url + " and failed with the message: \"" + msg + "\"");
1237
+
1238
+ case 17:
1239
+ _context.t1 = api.parseReadOnlyResponse;
1240
+ _context.next = 20;
1241
+ return response.json();
1242
+
1243
+ case 20:
1244
+ _context.t2 = _context.sent;
1245
+ parsed = (0, _context.t1)(_context.t2);
1246
+ return _context.abrupt("return", cvToValue(parsed, true));
1247
+
1248
+ case 23:
1249
+ case "end":
1250
+ return _context.stop();
1251
+ }
1252
+ }
1253
+ }, _callee, null, [[8, 14]]);
1254
+ }));
1255
+ return _ro.apply(this, arguments);
1256
+ }
1257
+
1258
+ function roOk(_x3, _x4) {
1259
+ return _roOk.apply(this, arguments);
1260
+ }
1261
+
1262
+ function _roOk() {
1263
+ _roOk = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(tx, options) {
1264
+ var result;
1265
+ return runtime_1.wrap(function _callee2$(_context2) {
1266
+ while (1) {
1267
+ switch (_context2.prev = _context2.next) {
1268
+ case 0:
1269
+ _context2.next = 2;
1270
+ return ro(tx, options);
1271
+
1272
+ case 2:
1273
+ result = _context2.sent;
1274
+ return _context2.abrupt("return", expectOk(result));
1275
+
1276
+ case 4:
1277
+ case "end":
1278
+ return _context2.stop();
1279
+ }
1280
+ }
1281
+ }, _callee2);
1282
+ }));
1283
+ return _roOk.apply(this, arguments);
1284
+ }
1285
+
1286
+ function roErr(_x5, _x6) {
1287
+ return _roErr.apply(this, arguments);
1288
+ }
1289
+
1290
+ function _roErr() {
1291
+ _roErr = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(tx, options) {
1292
+ var result;
1293
+ return runtime_1.wrap(function _callee3$(_context3) {
1294
+ while (1) {
1295
+ switch (_context3.prev = _context3.next) {
1296
+ case 0:
1297
+ _context3.next = 2;
1298
+ return ro(tx, options);
1299
+
1300
+ case 2:
1301
+ result = _context3.sent;
1302
+ return _context3.abrupt("return", expectErr(result));
1303
+
1304
+ case 4:
1305
+ case "end":
1306
+ return _context3.stop();
1307
+ }
1308
+ }
1309
+ }, _callee3);
1310
+ }));
1311
+ return _roErr.apply(this, arguments);
1312
+ }
1313
+
1314
+ function broadcast(_x7, _x8) {
1315
+ return _broadcast.apply(this, arguments);
1316
+ }
1317
+
1318
+ function _broadcast() {
1319
+ _broadcast = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(transaction, options) {
1320
+ var result;
1321
+ return runtime_1.wrap(function _callee4$(_context4) {
1322
+ while (1) {
1323
+ switch (_context4.prev = _context4.next) {
1324
+ case 0:
1325
+ _context4.next = 2;
1326
+ return transactions.broadcastTransaction(transaction, options.network);
1327
+
1328
+ case 2:
1329
+ result = _context4.sent;
1330
+
1331
+ if (!('error' in result)) {
1332
+ _context4.next = 7;
1333
+ break;
1334
+ }
1335
+
1336
+ throw new Error("Error broadcasting tx: " + result.error + " - " + result.reason + " - " + result.reason_data);
1337
+
1338
+ case 7:
1339
+ return _context4.abrupt("return", {
1340
+ txId: result.txid,
1341
+ stacksTransaction: transaction
1342
+ });
1343
+
1344
+ case 8:
1345
+ case "end":
1346
+ return _context4.stop();
1347
+ }
1348
+ }
1349
+ }, _callee4);
1350
+ }));
1351
+ return _broadcast.apply(this, arguments);
1352
+ }
1353
+
1056
1354
  var makeHandler = function makeHandler(provider) {
1057
1355
  var handler = {
1058
1356
  get: function get(contract, property) {
@@ -1094,12 +1392,21 @@ exports.BaseProvider = BaseProvider;
1094
1392
  exports.MAINNET_BURN_ADDRESS = MAINNET_BURN_ADDRESS;
1095
1393
  exports.TESTNET_BURN_ADDRESS = TESTNET_BURN_ADDRESS;
1096
1394
  exports.bootContractIdentifier = bootContractIdentifier;
1395
+ exports.broadcast = broadcast;
1097
1396
  exports.cvToString = cvToString;
1098
1397
  exports.cvToValue = cvToValue;
1398
+ exports.expectErr = expectErr;
1399
+ exports.expectOk = expectOk;
1099
1400
  exports.getContractIdentifier = getContractIdentifier;
1100
1401
  exports.getContractNameFromPath = getContractNameFromPath;
1101
1402
  exports.getContractPrincipalCV = getContractPrincipalCV;
1403
+ exports.hexToCvValue = hexToCvValue;
1404
+ exports.makeContracts = makeContracts;
1102
1405
  exports.parseToCV = parseToCV;
1103
1406
  exports.proxy = proxy;
1407
+ exports.pureProxy = pureProxy;
1408
+ exports.ro = ro;
1409
+ exports.roErr = roErr;
1410
+ exports.roOk = roOk;
1104
1411
  exports.toCamelCase = toCamelCase;
1105
1412
  //# sourceMappingURL=core.cjs.development.js.map