@clarigen/core 0.3.4 → 1.0.0-next.3
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 +15 -0
- package/dist/base-provider.d.ts +1 -1
- package/dist/clarity-types.d.ts +21 -33
- package/dist/contracts.d.ts +6 -0
- package/dist/core.cjs.development.js +298 -52
- package/dist/core.cjs.development.js.map +1 -1
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/core.cjs.production.min.js.map +1 -1
- package/dist/core.esm.js +247 -9
- package/dist/core.esm.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/pure/index.d.ts +36 -0
- package/dist/transaction.d.ts +1 -1
- package/dist/types.d.ts +5 -4
- package/dist/utils.d.ts +1 -1
- package/package.json +5 -8
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 {};
|
package/dist/base-provider.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClarityAbiFunction } from '
|
|
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>;
|
package/dist/clarity-types.d.ts
CHANGED
|
@@ -1,46 +1,34 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
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
|
|
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;
|
|
@@ -57,68 +61,96 @@ function bootContractIdentifier(name, mainnet) {
|
|
|
57
61
|
})(exports.CoreNodeEventType || (exports.CoreNodeEventType = {}));
|
|
58
62
|
|
|
59
63
|
function principalToString(principal) {
|
|
60
|
-
if (principal.type ===
|
|
61
|
-
return
|
|
62
|
-
} else if (principal.type ===
|
|
63
|
-
var address =
|
|
64
|
+
if (principal.type === clarity.ClarityType.PrincipalStandard) {
|
|
65
|
+
return clarity.addressToString(principal.address);
|
|
66
|
+
} else if (principal.type === clarity.ClarityType.PrincipalContract) {
|
|
67
|
+
var address = clarity.addressToString(principal.address);
|
|
64
68
|
return address + "." + principal.contractName.content;
|
|
65
69
|
} else {
|
|
66
70
|
throw new Error("Unexpected principal data: " + JSON.stringify(principal));
|
|
67
71
|
}
|
|
68
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* @param val - ClarityValue
|
|
75
|
+
* @param returnResponse - if true, this will return a "response" object from the `neverthrow`
|
|
76
|
+
* library. Otherwise, it returns the inner value of the response (whether ok or err)
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
function cvToValue(val, returnResponse) {
|
|
81
|
+
if (returnResponse === void 0) {
|
|
82
|
+
returnResponse = false;
|
|
83
|
+
}
|
|
69
84
|
|
|
70
|
-
function cvToValue(val) {
|
|
71
85
|
switch (val.type) {
|
|
72
|
-
case
|
|
86
|
+
case clarity.ClarityType.BoolTrue:
|
|
73
87
|
return true;
|
|
74
88
|
|
|
75
|
-
case
|
|
89
|
+
case clarity.ClarityType.BoolFalse:
|
|
76
90
|
return false;
|
|
77
91
|
|
|
78
|
-
case
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
case transactions.ClarityType.UInt:
|
|
92
|
+
case clarity.ClarityType.Int:
|
|
93
|
+
case clarity.ClarityType.UInt:
|
|
82
94
|
return val.value;
|
|
83
95
|
|
|
84
|
-
case
|
|
96
|
+
case clarity.ClarityType.Buffer:
|
|
85
97
|
return val.buffer;
|
|
86
98
|
|
|
87
|
-
case
|
|
99
|
+
case clarity.ClarityType.OptionalNone:
|
|
88
100
|
return null;
|
|
89
101
|
|
|
90
|
-
case
|
|
102
|
+
case clarity.ClarityType.OptionalSome:
|
|
91
103
|
return cvToValue(val.value);
|
|
92
104
|
|
|
93
|
-
case
|
|
105
|
+
case clarity.ClarityType.ResponseErr:
|
|
106
|
+
if (returnResponse) return neverthrow.err(cvToValue(val.value));
|
|
94
107
|
return cvToValue(val.value);
|
|
95
108
|
|
|
96
|
-
case
|
|
109
|
+
case clarity.ClarityType.ResponseOk:
|
|
110
|
+
if (returnResponse) return neverthrow.ok(cvToValue(val.value));
|
|
97
111
|
return cvToValue(val.value);
|
|
98
112
|
|
|
99
|
-
case
|
|
100
|
-
case
|
|
113
|
+
case clarity.ClarityType.PrincipalStandard:
|
|
114
|
+
case clarity.ClarityType.PrincipalContract:
|
|
101
115
|
return principalToString(val);
|
|
102
116
|
|
|
103
|
-
case
|
|
117
|
+
case clarity.ClarityType.List:
|
|
104
118
|
return val.list.map(function (v) {
|
|
105
119
|
return cvToValue(v);
|
|
106
120
|
});
|
|
107
121
|
|
|
108
|
-
case
|
|
122
|
+
case clarity.ClarityType.Tuple:
|
|
109
123
|
var result = {};
|
|
110
|
-
Object.keys(val.data).
|
|
111
|
-
|
|
124
|
+
var arr = Object.keys(val.data).map(function (key) {
|
|
125
|
+
return [key, cvToValue(val.data[key])];
|
|
126
|
+
});
|
|
127
|
+
arr.forEach(function (_ref) {
|
|
128
|
+
var key = _ref[0],
|
|
129
|
+
value = _ref[1];
|
|
130
|
+
result[key] = value;
|
|
112
131
|
});
|
|
113
132
|
return result;
|
|
114
133
|
|
|
115
|
-
case
|
|
134
|
+
case clarity.ClarityType.StringASCII:
|
|
116
135
|
return val.data;
|
|
117
136
|
|
|
118
|
-
case
|
|
137
|
+
case clarity.ClarityType.StringUTF8:
|
|
119
138
|
return val.data;
|
|
120
139
|
}
|
|
121
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Converts a hex encoded string to the javascript clarity value object {type: string; value: any}
|
|
143
|
+
* @param hex - the hex encoded string with or without `0x` prefix
|
|
144
|
+
* @param jsonCompat - enable to serialize bigints to strings
|
|
145
|
+
*/
|
|
146
|
+
|
|
147
|
+
function hexToCvValue(hex, jsonCompat) {
|
|
148
|
+
if (jsonCompat === void 0) {
|
|
149
|
+
jsonCompat = false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return cvToValue(clarity.hexToCV(hex), jsonCompat);
|
|
153
|
+
}
|
|
122
154
|
|
|
123
155
|
function inputToBigInt(input) {
|
|
124
156
|
var isBigInt = typeof input === 'bigint';
|
|
@@ -144,38 +176,38 @@ function parseToCV(input, type) {
|
|
|
144
176
|
var val = input[key.name];
|
|
145
177
|
tuple[key.name] = parseToCV(val, key.type);
|
|
146
178
|
});
|
|
147
|
-
return
|
|
179
|
+
return clarity.tupleCV(tuple);
|
|
148
180
|
} else if (transactions.isClarityAbiList(type)) {
|
|
149
181
|
var inputs = input;
|
|
150
182
|
var values = inputs.map(function (input) {
|
|
151
183
|
return parseToCV(input, type.list.type);
|
|
152
184
|
});
|
|
153
|
-
return
|
|
185
|
+
return clarity.listCV(values);
|
|
154
186
|
} else if (transactions.isClarityAbiOptional(type)) {
|
|
155
|
-
if (!input) return
|
|
156
|
-
return
|
|
187
|
+
if (!input) return clarity.noneCV();
|
|
188
|
+
return clarity.someCV(parseToCV(input, type.optional));
|
|
157
189
|
} else if (transactions.isClarityAbiStringAscii(type)) {
|
|
158
190
|
if (typeof input !== 'string') {
|
|
159
191
|
throw new Error('Invalid string-ascii input');
|
|
160
192
|
}
|
|
161
193
|
|
|
162
|
-
return
|
|
194
|
+
return clarity.stringAsciiCV(input);
|
|
163
195
|
} else if (transactions.isClarityAbiStringUtf8(type)) {
|
|
164
196
|
if (typeof input !== 'string') {
|
|
165
197
|
throw new Error('Invalid string-ascii input');
|
|
166
198
|
}
|
|
167
199
|
|
|
168
|
-
return
|
|
200
|
+
return clarity.stringUtf8CV(input);
|
|
169
201
|
} else if (type === 'bool') {
|
|
170
202
|
var inputString = typeof input === 'boolean' ? input.toString() : input;
|
|
171
203
|
return transactions.parseToCV(inputString, type);
|
|
172
204
|
} else if (type === 'uint128') {
|
|
173
205
|
var bigi = inputToBigInt(input);
|
|
174
|
-
return
|
|
206
|
+
return clarity.uintCV(bigi.toString());
|
|
175
207
|
} else if (type === 'int128') {
|
|
176
208
|
var _bigi = inputToBigInt(input);
|
|
177
209
|
|
|
178
|
-
return
|
|
210
|
+
return clarity.intCV(_bigi.toString());
|
|
179
211
|
} else if (type === 'trait_reference') {
|
|
180
212
|
if (typeof input !== 'string') throw new Error('Invalid input for trait_reference');
|
|
181
213
|
|
|
@@ -183,7 +215,9 @@ function parseToCV(input, type) {
|
|
|
183
215
|
addr = _input$split[0],
|
|
184
216
|
name = _input$split[1];
|
|
185
217
|
|
|
186
|
-
return
|
|
218
|
+
return clarity.contractPrincipalCV(addr, name);
|
|
219
|
+
} else if (transactions.isClarityAbiBuffer(type)) {
|
|
220
|
+
return clarity.bufferCV(input);
|
|
187
221
|
}
|
|
188
222
|
|
|
189
223
|
return transactions.parseToCV(input, type);
|
|
@@ -194,62 +228,136 @@ function cvToString(val, encoding) {
|
|
|
194
228
|
}
|
|
195
229
|
|
|
196
230
|
switch (val.type) {
|
|
197
|
-
case
|
|
231
|
+
case clarity.ClarityType.BoolTrue:
|
|
198
232
|
return 'true';
|
|
199
233
|
|
|
200
|
-
case
|
|
234
|
+
case clarity.ClarityType.BoolFalse:
|
|
201
235
|
return 'false';
|
|
202
236
|
|
|
203
|
-
case
|
|
237
|
+
case clarity.ClarityType.Int:
|
|
204
238
|
return val.value.toString();
|
|
205
239
|
|
|
206
|
-
case
|
|
240
|
+
case clarity.ClarityType.UInt:
|
|
207
241
|
return "u" + val.value.toString();
|
|
208
242
|
|
|
209
|
-
case
|
|
243
|
+
case clarity.ClarityType.Buffer:
|
|
210
244
|
if (encoding === 'tryAscii') {
|
|
211
|
-
var str = val.buffer
|
|
245
|
+
var str = common.bytesToAscii(val.buffer);
|
|
212
246
|
|
|
213
247
|
if (/[ -~]/.test(str)) {
|
|
214
248
|
return JSON.stringify(str);
|
|
215
249
|
}
|
|
216
250
|
}
|
|
217
251
|
|
|
218
|
-
return "0x" + val.buffer
|
|
252
|
+
return "0x" + common.bytesToHex(val.buffer);
|
|
219
253
|
|
|
220
|
-
case
|
|
254
|
+
case clarity.ClarityType.OptionalNone:
|
|
221
255
|
return 'none';
|
|
222
256
|
|
|
223
|
-
case
|
|
257
|
+
case clarity.ClarityType.OptionalSome:
|
|
224
258
|
return "(some " + cvToString(val.value, encoding) + ")";
|
|
225
259
|
|
|
226
|
-
case
|
|
260
|
+
case clarity.ClarityType.ResponseErr:
|
|
227
261
|
return "(err " + cvToString(val.value, encoding) + ")";
|
|
228
262
|
|
|
229
|
-
case
|
|
263
|
+
case clarity.ClarityType.ResponseOk:
|
|
230
264
|
return "(ok " + cvToString(val.value, encoding) + ")";
|
|
231
265
|
|
|
232
|
-
case
|
|
233
|
-
case
|
|
266
|
+
case clarity.ClarityType.PrincipalStandard:
|
|
267
|
+
case clarity.ClarityType.PrincipalContract:
|
|
234
268
|
return "'" + principalToString(val);
|
|
235
269
|
|
|
236
|
-
case
|
|
270
|
+
case clarity.ClarityType.List:
|
|
237
271
|
return "(list " + val.list.map(function (v) {
|
|
238
272
|
return cvToString(v, encoding);
|
|
239
273
|
}).join(' ') + ")";
|
|
240
274
|
|
|
241
|
-
case
|
|
275
|
+
case clarity.ClarityType.Tuple:
|
|
242
276
|
return "(tuple " + Object.keys(val.data).map(function (key) {
|
|
243
277
|
return "(" + key + " " + cvToString(val.data[key], encoding) + ")";
|
|
244
278
|
}).join(' ') + ")";
|
|
245
279
|
|
|
246
|
-
case
|
|
280
|
+
case clarity.ClarityType.StringASCII:
|
|
247
281
|
return "\"" + val.data + "\"";
|
|
248
282
|
|
|
249
|
-
case
|
|
283
|
+
case clarity.ClarityType.StringUTF8:
|
|
250
284
|
return "u\"" + val.data + "\"";
|
|
251
285
|
}
|
|
252
286
|
}
|
|
287
|
+
function transformArgsToCV(func, args) {
|
|
288
|
+
return args.map(function (arg, index) {
|
|
289
|
+
return parseToCV(arg, func.args[index].type);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
function expectOk(response) {
|
|
293
|
+
return response.match(function (ok) {
|
|
294
|
+
return ok;
|
|
295
|
+
}, function (err) {
|
|
296
|
+
throw new Error("Expected OK, received error: " + err);
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
function expectErr(response) {
|
|
300
|
+
return response.match(function (ok) {
|
|
301
|
+
throw new Error("Expected Err, received Ok: " + ok);
|
|
302
|
+
}, function (err) {
|
|
303
|
+
return err;
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function transformArguments(func, args) {
|
|
308
|
+
return transformArgsToCV(func, args);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function getter(contract, property) {
|
|
312
|
+
var foundFunction = contract.abi.functions.find(function (func) {
|
|
313
|
+
return toCamelCase(func.name) === property;
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
if (foundFunction) {
|
|
317
|
+
return function () {
|
|
318
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
319
|
+
args[_key] = arguments[_key];
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
var functionArgs = transformArguments(foundFunction, args);
|
|
323
|
+
return {
|
|
324
|
+
functionArgs: functionArgs,
|
|
325
|
+
contractAddress: contract.contractAddress,
|
|
326
|
+
contractName: contract.contractName,
|
|
327
|
+
"function": foundFunction,
|
|
328
|
+
nativeArgs: args
|
|
329
|
+
};
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
var foundMap = contract.abi.maps.find(function (map) {
|
|
334
|
+
return toCamelCase(map.name) === property;
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
if (foundMap) {
|
|
338
|
+
return function (key) {
|
|
339
|
+
var keyCV = parseToCV(key, foundMap.key);
|
|
340
|
+
var mapGet = {
|
|
341
|
+
contractAddress: contract.contractAddress,
|
|
342
|
+
contractName: contract.contractName,
|
|
343
|
+
map: foundMap,
|
|
344
|
+
nativeKey: key,
|
|
345
|
+
key: keyCV
|
|
346
|
+
};
|
|
347
|
+
return mapGet;
|
|
348
|
+
};
|
|
349
|
+
} // TODO: variables, tokens
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
throw new Error("Invalid function call: no function exists for " + String(property));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
var proxyHandler = {
|
|
356
|
+
get: getter
|
|
357
|
+
};
|
|
358
|
+
var pureProxy = function pureProxy(target) {
|
|
359
|
+
return new Proxy(target, proxyHandler);
|
|
360
|
+
};
|
|
253
361
|
|
|
254
362
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
255
363
|
try {
|
|
@@ -1053,6 +1161,136 @@ var BaseProvider = /*#__PURE__*/function () {
|
|
|
1053
1161
|
return BaseProvider;
|
|
1054
1162
|
}();
|
|
1055
1163
|
|
|
1164
|
+
function ro(_x, _x2) {
|
|
1165
|
+
return _ro.apply(this, arguments);
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
function _ro() {
|
|
1169
|
+
_ro = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(tx, options) {
|
|
1170
|
+
var result;
|
|
1171
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1172
|
+
while (1) {
|
|
1173
|
+
switch (_context.prev = _context.next) {
|
|
1174
|
+
case 0:
|
|
1175
|
+
_context.next = 2;
|
|
1176
|
+
return api.callReadOnlyFunction({
|
|
1177
|
+
contractAddress: tx.contractAddress,
|
|
1178
|
+
contractName: tx.contractName,
|
|
1179
|
+
functionArgs: tx.functionArgs,
|
|
1180
|
+
functionName: tx["function"].name,
|
|
1181
|
+
network: options.network
|
|
1182
|
+
});
|
|
1183
|
+
|
|
1184
|
+
case 2:
|
|
1185
|
+
result = _context.sent;
|
|
1186
|
+
return _context.abrupt("return", cvToValue(result, true));
|
|
1187
|
+
|
|
1188
|
+
case 4:
|
|
1189
|
+
case "end":
|
|
1190
|
+
return _context.stop();
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
}, _callee);
|
|
1194
|
+
}));
|
|
1195
|
+
return _ro.apply(this, arguments);
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
function roOk(_x3, _x4) {
|
|
1199
|
+
return _roOk.apply(this, arguments);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
function _roOk() {
|
|
1203
|
+
_roOk = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(tx, options) {
|
|
1204
|
+
var result;
|
|
1205
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1206
|
+
while (1) {
|
|
1207
|
+
switch (_context2.prev = _context2.next) {
|
|
1208
|
+
case 0:
|
|
1209
|
+
_context2.next = 2;
|
|
1210
|
+
return ro(tx, options);
|
|
1211
|
+
|
|
1212
|
+
case 2:
|
|
1213
|
+
result = _context2.sent;
|
|
1214
|
+
return _context2.abrupt("return", expectOk(result));
|
|
1215
|
+
|
|
1216
|
+
case 4:
|
|
1217
|
+
case "end":
|
|
1218
|
+
return _context2.stop();
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
}, _callee2);
|
|
1222
|
+
}));
|
|
1223
|
+
return _roOk.apply(this, arguments);
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
function roErr(_x5, _x6) {
|
|
1227
|
+
return _roErr.apply(this, arguments);
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
function _roErr() {
|
|
1231
|
+
_roErr = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(tx, options) {
|
|
1232
|
+
var result;
|
|
1233
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1234
|
+
while (1) {
|
|
1235
|
+
switch (_context3.prev = _context3.next) {
|
|
1236
|
+
case 0:
|
|
1237
|
+
_context3.next = 2;
|
|
1238
|
+
return ro(tx, options);
|
|
1239
|
+
|
|
1240
|
+
case 2:
|
|
1241
|
+
result = _context3.sent;
|
|
1242
|
+
return _context3.abrupt("return", expectErr(result));
|
|
1243
|
+
|
|
1244
|
+
case 4:
|
|
1245
|
+
case "end":
|
|
1246
|
+
return _context3.stop();
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
}, _callee3);
|
|
1250
|
+
}));
|
|
1251
|
+
return _roErr.apply(this, arguments);
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
function broadcast(_x7, _x8) {
|
|
1255
|
+
return _broadcast.apply(this, arguments);
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
function _broadcast() {
|
|
1259
|
+
_broadcast = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(transaction, options) {
|
|
1260
|
+
var result;
|
|
1261
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
1262
|
+
while (1) {
|
|
1263
|
+
switch (_context4.prev = _context4.next) {
|
|
1264
|
+
case 0:
|
|
1265
|
+
_context4.next = 2;
|
|
1266
|
+
return transactions.broadcastTransaction(transaction, options.network);
|
|
1267
|
+
|
|
1268
|
+
case 2:
|
|
1269
|
+
result = _context4.sent;
|
|
1270
|
+
|
|
1271
|
+
if (!('error' in result)) {
|
|
1272
|
+
_context4.next = 7;
|
|
1273
|
+
break;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
throw new Error("Error broadcasting tx: " + result.error + " - " + result.reason + " - " + result.reason_data);
|
|
1277
|
+
|
|
1278
|
+
case 7:
|
|
1279
|
+
return _context4.abrupt("return", {
|
|
1280
|
+
txId: result.txid,
|
|
1281
|
+
stacksTransaction: transaction
|
|
1282
|
+
});
|
|
1283
|
+
|
|
1284
|
+
case 8:
|
|
1285
|
+
case "end":
|
|
1286
|
+
return _context4.stop();
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}, _callee4);
|
|
1290
|
+
}));
|
|
1291
|
+
return _broadcast.apply(this, arguments);
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1056
1294
|
var makeHandler = function makeHandler(provider) {
|
|
1057
1295
|
var handler = {
|
|
1058
1296
|
get: function get(contract, property) {
|
|
@@ -1094,12 +1332,20 @@ exports.BaseProvider = BaseProvider;
|
|
|
1094
1332
|
exports.MAINNET_BURN_ADDRESS = MAINNET_BURN_ADDRESS;
|
|
1095
1333
|
exports.TESTNET_BURN_ADDRESS = TESTNET_BURN_ADDRESS;
|
|
1096
1334
|
exports.bootContractIdentifier = bootContractIdentifier;
|
|
1335
|
+
exports.broadcast = broadcast;
|
|
1097
1336
|
exports.cvToString = cvToString;
|
|
1098
1337
|
exports.cvToValue = cvToValue;
|
|
1338
|
+
exports.expectErr = expectErr;
|
|
1339
|
+
exports.expectOk = expectOk;
|
|
1099
1340
|
exports.getContractIdentifier = getContractIdentifier;
|
|
1100
1341
|
exports.getContractNameFromPath = getContractNameFromPath;
|
|
1101
1342
|
exports.getContractPrincipalCV = getContractPrincipalCV;
|
|
1343
|
+
exports.hexToCvValue = hexToCvValue;
|
|
1102
1344
|
exports.parseToCV = parseToCV;
|
|
1103
1345
|
exports.proxy = proxy;
|
|
1346
|
+
exports.pureProxy = pureProxy;
|
|
1347
|
+
exports.ro = ro;
|
|
1348
|
+
exports.roErr = roErr;
|
|
1349
|
+
exports.roOk = roOk;
|
|
1104
1350
|
exports.toCamelCase = toCamelCase;
|
|
1105
1351
|
//# sourceMappingURL=core.cjs.development.js.map
|