@argonprotocol/mainchain 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -190
- package/browser/index.d.ts +483 -1978
- package/browser/index.js +110 -1984
- package/browser/index.js.map +1 -1
- package/lib/index.cjs +1006 -70
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +483 -1978
- package/lib/index.d.ts +483 -1978
- package/lib/index.js +1018 -82
- package/lib/index.js.map +1 -1
- package/package.json +6 -14
- package/lib/chunk-4ZBJ5W3P.cjs +0 -743
- package/lib/chunk-4ZBJ5W3P.cjs.map +0 -1
- package/lib/chunk-PE7HFDHD.js +0 -743
- package/lib/chunk-PE7HFDHD.js.map +0 -1
- package/lib/chunk-PXZPYJ4P.js +0 -2982
- package/lib/chunk-PXZPYJ4P.js.map +0 -1
- package/lib/chunk-VXYWJG66.cjs +0 -2982
- package/lib/chunk-VXYWJG66.cjs.map +0 -1
- package/lib/cli.cjs +0 -19
- package/lib/cli.cjs.map +0 -1
- package/lib/cli.d.cts +0 -1
- package/lib/cli.d.ts +0 -1
- package/lib/cli.js +0 -19
- package/lib/cli.js.map +0 -1
- package/lib/clis/index.cjs +0 -30
- package/lib/clis/index.cjs.map +0 -1
- package/lib/clis/index.d.cts +0 -129
- package/lib/clis/index.d.ts +0 -129
- package/lib/clis/index.js +0 -30
- package/lib/clis/index.js.map +0 -1
package/lib/index.cjs
CHANGED
|
@@ -1,6 +1,997 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;// src/interfaces/augment-api-consts.ts
|
|
2
|
+
require('@polkadot/api-base/types/consts');
|
|
3
|
+
|
|
4
|
+
// src/interfaces/augment-api-errors.ts
|
|
5
|
+
require('@polkadot/api-base/types/errors');
|
|
6
|
+
|
|
7
|
+
// src/interfaces/augment-api-events.ts
|
|
8
|
+
require('@polkadot/api-base/types/events');
|
|
9
|
+
|
|
10
|
+
// src/interfaces/augment-api-query.ts
|
|
11
|
+
require('@polkadot/api-base/types/storage');
|
|
12
|
+
|
|
13
|
+
// src/interfaces/augment-api-tx.ts
|
|
14
|
+
require('@polkadot/api-base/types/submittable');
|
|
15
|
+
|
|
16
|
+
// src/interfaces/augment-api-rpc.ts
|
|
17
|
+
require('@polkadot/rpc-core/types/jsonrpc');
|
|
18
|
+
|
|
19
|
+
// src/interfaces/augment-api-runtime.ts
|
|
20
|
+
require('@polkadot/api-base/types/calls');
|
|
21
|
+
|
|
22
|
+
// src/interfaces/augment-types.ts
|
|
23
|
+
require('@polkadot/types/types/registry');
|
|
24
|
+
|
|
25
|
+
// src/index.ts
|
|
26
|
+
var _api = require('@polkadot/api');
|
|
27
|
+
var _utilcrypto = require('@polkadot/util-crypto');
|
|
28
|
+
|
|
29
|
+
// src/WageProtector.ts
|
|
30
|
+
var WageProtector = class _WageProtector {
|
|
31
|
+
constructor(latestCpi) {
|
|
32
|
+
this.latestCpi = latestCpi;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Converts the base wage to the current wage using the latest CPI snapshot
|
|
36
|
+
*
|
|
37
|
+
* @param baseWage The base wage to convert
|
|
38
|
+
* @returns The protected wage
|
|
39
|
+
*/
|
|
40
|
+
getProtectedWage(baseWage) {
|
|
41
|
+
return baseWage * this.latestCpi.argonUsdTargetPrice / this.latestCpi.argonUsdPrice;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Subscribes to the current CPI and calls the callback function whenever the CPI changes
|
|
45
|
+
* @param client The ArgonClient to use
|
|
46
|
+
* @param callback The callback function to call when the CPI changes
|
|
47
|
+
* @returns An object with an unsubscribe function that can be called to stop the subscription
|
|
48
|
+
*/
|
|
49
|
+
static async subscribe(client, callback) {
|
|
50
|
+
const unsubscribe = await client.query.priceIndex.current(async (cpi) => {
|
|
51
|
+
if (cpi.isNone) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const finalizedBlock = await client.rpc.chain.getFinalizedHead();
|
|
55
|
+
callback(
|
|
56
|
+
new _WageProtector({
|
|
57
|
+
argonUsdTargetPrice: cpi.value.argonUsdTargetPrice.toBigInt(),
|
|
58
|
+
argonUsdPrice: cpi.value.argonUsdPrice.toBigInt(),
|
|
59
|
+
finalizedBlock: new Uint8Array(finalizedBlock),
|
|
60
|
+
tick: cpi.value.tick.toBigInt()
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
return { unsubscribe };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new WageProtector instance by subscribing to the current CPI and waiting for the first value
|
|
68
|
+
* @param client The ArgonClient to use
|
|
69
|
+
*/
|
|
70
|
+
static async create(client) {
|
|
71
|
+
return new Promise(async (resolve, reject) => {
|
|
72
|
+
try {
|
|
73
|
+
const { unsubscribe } = await _WageProtector.subscribe(client, (x) => {
|
|
74
|
+
resolve(x);
|
|
75
|
+
unsubscribe();
|
|
76
|
+
});
|
|
77
|
+
} catch (e) {
|
|
78
|
+
reject(e);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// src/TxSubmitter.ts
|
|
85
|
+
function logExtrinsicResult(result) {
|
|
86
|
+
const json = result.status.toJSON();
|
|
87
|
+
const status = Object.keys(json)[0];
|
|
88
|
+
console.debug('Transaction update: "%s"', status, json[status]);
|
|
89
|
+
}
|
|
90
|
+
var TxSubmitter = class {
|
|
91
|
+
constructor(client, tx, pair) {
|
|
92
|
+
this.client = client;
|
|
93
|
+
this.tx = tx;
|
|
94
|
+
this.pair = pair;
|
|
95
|
+
}
|
|
96
|
+
async feeEstimate(tip) {
|
|
97
|
+
const { partialFee } = await this.tx.paymentInfo(this.pair, { tip });
|
|
98
|
+
return partialFee.toBigInt();
|
|
99
|
+
}
|
|
100
|
+
async canAfford(options = {}) {
|
|
101
|
+
const { tip, unavailableBalance } = options;
|
|
102
|
+
const account = await this.client.query.system.account(this.pair.address);
|
|
103
|
+
let availableBalance = account.data.free.toBigInt();
|
|
104
|
+
const userBalance = availableBalance;
|
|
105
|
+
if (unavailableBalance) {
|
|
106
|
+
availableBalance -= unavailableBalance;
|
|
107
|
+
}
|
|
108
|
+
const existentialDeposit = options.includeExistentialDeposit ? this.client.consts.balances.existentialDeposit.toBigInt() : 0n;
|
|
109
|
+
const fees = await this.feeEstimate(tip);
|
|
110
|
+
const totalCharge = fees + (_nullishCoalesce(tip, () => ( 0n)));
|
|
111
|
+
const canAfford = availableBalance >= totalCharge + existentialDeposit;
|
|
112
|
+
return { canAfford, availableBalance: userBalance, txFee: fees };
|
|
113
|
+
}
|
|
114
|
+
async submit(options = {}) {
|
|
115
|
+
const { logResults, waitForBlock, useLatestNonce, ...apiOptions } = options;
|
|
116
|
+
await waitForLoad();
|
|
117
|
+
const result = new TxResult(this.client, logResults);
|
|
118
|
+
result.txProgressCallback = options.txProgressCallback;
|
|
119
|
+
let toHuman = this.tx.toHuman().method;
|
|
120
|
+
const txString = [];
|
|
121
|
+
let api = formatCall(toHuman);
|
|
122
|
+
const args = [];
|
|
123
|
+
if (api === "proxy.proxy") {
|
|
124
|
+
toHuman = toHuman.args.call;
|
|
125
|
+
txString.push("Proxy");
|
|
126
|
+
api = formatCall(toHuman);
|
|
127
|
+
}
|
|
128
|
+
if (api.startsWith("utility.batch")) {
|
|
129
|
+
const calls = toHuman.args.calls.map(formatCall).join(", ");
|
|
130
|
+
txString.push(`Batch[${calls}]`);
|
|
131
|
+
} else {
|
|
132
|
+
txString.push(api);
|
|
133
|
+
args.push(toHuman.args);
|
|
134
|
+
}
|
|
135
|
+
args.unshift(txString.join("->"));
|
|
136
|
+
if (useLatestNonce && !apiOptions.nonce) {
|
|
137
|
+
apiOptions.nonce = await this.client.rpc.system.accountNextIndex(this.pair.address);
|
|
138
|
+
}
|
|
139
|
+
console.log("Submitting transaction from %s:", this.pair.address, ...args);
|
|
140
|
+
await this.tx.signAndSend(this.pair, apiOptions, result.onResult.bind(result));
|
|
141
|
+
if (waitForBlock) {
|
|
142
|
+
await result.inBlockPromise;
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
function formatCall(call) {
|
|
148
|
+
return `${call.section}.${call.method}`;
|
|
149
|
+
}
|
|
150
|
+
var TxResult = (_class = class {
|
|
151
|
+
constructor(client, shouldLog = false) {;_class.prototype.__init.call(this);
|
|
152
|
+
this.client = client;
|
|
153
|
+
this.shouldLog = shouldLog;
|
|
154
|
+
this.inBlockPromise = new Promise((resolve, reject) => {
|
|
155
|
+
this.inBlockResolve = resolve;
|
|
156
|
+
this.inBlockReject = reject;
|
|
157
|
+
});
|
|
158
|
+
this.finalizedPromise = new Promise((resolve, reject) => {
|
|
159
|
+
this.finalizedResolve = resolve;
|
|
160
|
+
this.finalizedReject = reject;
|
|
161
|
+
});
|
|
162
|
+
this.inBlockPromise.catch(() => null);
|
|
163
|
+
this.finalizedPromise.catch(() => null);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
__init() {this.events = []}
|
|
169
|
+
/**
|
|
170
|
+
* The index of the batch that was interrupted, if any.
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The final fee paid for the transaction, including the fee tip.
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The fee tip paid for the transaction.
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
onResult(result) {
|
|
188
|
+
this.status = result.status;
|
|
189
|
+
if (this.shouldLog) {
|
|
190
|
+
logExtrinsicResult(result);
|
|
191
|
+
}
|
|
192
|
+
const { events, status, dispatchError, isFinalized } = result;
|
|
193
|
+
if (status.isInBlock) {
|
|
194
|
+
this.includedInBlock = new Uint8Array(status.asInBlock);
|
|
195
|
+
let encounteredError = dispatchError;
|
|
196
|
+
let batchErrorIndex;
|
|
197
|
+
for (const event of events) {
|
|
198
|
+
this.events.push(event.event);
|
|
199
|
+
if (this.client.events.utility.BatchInterrupted.is(event.event)) {
|
|
200
|
+
batchErrorIndex = event.event.data[0].toNumber();
|
|
201
|
+
this.batchInterruptedIndex = batchErrorIndex;
|
|
202
|
+
encounteredError = event.event.data[1];
|
|
203
|
+
}
|
|
204
|
+
if (this.client.events.transactionPayment.TransactionFeePaid.is(event.event)) {
|
|
205
|
+
const [_who, actualFee, tip] = event.event.data;
|
|
206
|
+
this.finalFee = actualFee.toBigInt();
|
|
207
|
+
this.finalFeeTip = tip.toBigInt();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (encounteredError) {
|
|
211
|
+
const error = dispatchErrorToExtrinsicError(this.client, encounteredError, batchErrorIndex);
|
|
212
|
+
this.reject(error);
|
|
213
|
+
} else {
|
|
214
|
+
this.inBlockResolve(new Uint8Array(status.asInBlock));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (isFinalized) {
|
|
218
|
+
this.finalizedResolve(status.asFinalized);
|
|
219
|
+
}
|
|
220
|
+
if (this.txProgressCallback) {
|
|
221
|
+
let percent = 0;
|
|
222
|
+
if (result.status.isBroadcast) {
|
|
223
|
+
percent = 50;
|
|
224
|
+
} else if (result.status.isInBlock) {
|
|
225
|
+
percent = 100;
|
|
226
|
+
}
|
|
227
|
+
this.txProgressCallback(percent, this);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
reject(error) {
|
|
231
|
+
this.inBlockReject(error);
|
|
232
|
+
this.finalizedReject(error);
|
|
233
|
+
}
|
|
234
|
+
}, _class);
|
|
235
|
+
|
|
236
|
+
// src/utils.ts
|
|
237
|
+
var _bignumberjs = require('bignumber.js'); var BN = _interopRequireWildcard(_bignumberjs); var BN2 = _interopRequireWildcard(_bignumberjs);
|
|
238
|
+
var { ROUND_FLOOR } = BN;
|
|
239
|
+
var MICROGONS_PER_ARGON = 1e6;
|
|
240
|
+
function formatArgons(microgons) {
|
|
241
|
+
if (microgons === void 0 || microgons === null) return "na";
|
|
242
|
+
const isNegative = microgons < 0;
|
|
243
|
+
let format = BN.default.call(void 0, microgons.toString()).abs().div(MICROGONS_PER_ARGON).toFormat(2, ROUND_FLOOR);
|
|
244
|
+
if (format.endsWith(".00")) {
|
|
245
|
+
format = format.slice(0, -3);
|
|
246
|
+
}
|
|
247
|
+
return `${isNegative ? "-" : ""}\u20B3${format}`;
|
|
248
|
+
}
|
|
249
|
+
async function gettersToObject(obj) {
|
|
250
|
+
if (obj === null || obj === void 0 || typeof obj !== "object") return obj;
|
|
251
|
+
const keys = [];
|
|
252
|
+
for (const key in obj) {
|
|
253
|
+
keys.push(key);
|
|
254
|
+
}
|
|
255
|
+
if (Symbol.iterator in obj) {
|
|
256
|
+
const iterableToArray = [];
|
|
257
|
+
for (const item of obj) {
|
|
258
|
+
iterableToArray.push(await gettersToObject(item));
|
|
259
|
+
}
|
|
260
|
+
return iterableToArray;
|
|
261
|
+
}
|
|
262
|
+
const result = {};
|
|
263
|
+
for (const key of keys) {
|
|
264
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, key);
|
|
265
|
+
if (descriptor && typeof descriptor.value === "function") {
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
const value = descriptor && descriptor.get ? descriptor.get.call(obj) : obj[key];
|
|
269
|
+
if (typeof value === "function") continue;
|
|
270
|
+
result[key] = await gettersToObject(value);
|
|
271
|
+
}
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
function dispatchErrorToString(client, error) {
|
|
275
|
+
let message = error.toString();
|
|
276
|
+
if (error.isModule) {
|
|
277
|
+
const decoded = client.registry.findMetaError(error.asModule);
|
|
278
|
+
const { docs, name, section } = decoded;
|
|
279
|
+
message = `${section}.${name}: ${docs.join(" ")}`;
|
|
280
|
+
}
|
|
281
|
+
return message;
|
|
282
|
+
}
|
|
283
|
+
var ExtrinsicError2 = class extends Error {
|
|
284
|
+
constructor(errorCode, details, batchInterruptedIndex) {
|
|
285
|
+
super(errorCode);
|
|
286
|
+
this.errorCode = errorCode;
|
|
287
|
+
this.details = details;
|
|
288
|
+
this.batchInterruptedIndex = batchInterruptedIndex;
|
|
289
|
+
}
|
|
290
|
+
toString() {
|
|
291
|
+
if (this.batchInterruptedIndex !== void 0) {
|
|
292
|
+
return `${this.errorCode} ${_nullishCoalesce(this.details, () => ( ""))} (Batch interrupted at index ${this.batchInterruptedIndex})`;
|
|
293
|
+
}
|
|
294
|
+
return `${this.errorCode} ${_nullishCoalesce(this.details, () => ( ""))}`;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
function dispatchErrorToExtrinsicError(client, error, batchInterruptedIndex) {
|
|
298
|
+
if (error.isModule) {
|
|
299
|
+
const decoded = client.registry.findMetaError(error.asModule);
|
|
300
|
+
const { docs, name, section } = decoded;
|
|
301
|
+
return new ExtrinsicError2(`${section}.${name}`, docs.join(" "), batchInterruptedIndex);
|
|
302
|
+
}
|
|
303
|
+
return new ExtrinsicError2(error.toString(), void 0, batchInterruptedIndex);
|
|
304
|
+
}
|
|
305
|
+
function checkForExtrinsicSuccess(events, client) {
|
|
306
|
+
return new Promise((resolve, reject) => {
|
|
307
|
+
for (const { event } of events) {
|
|
308
|
+
if (client.events.system.ExtrinsicSuccess.is(event)) {
|
|
309
|
+
resolve();
|
|
310
|
+
} else if (client.events.system.ExtrinsicFailed.is(event)) {
|
|
311
|
+
const [dispatchError] = event.data;
|
|
312
|
+
let errorInfo = dispatchError.toString();
|
|
313
|
+
if (dispatchError.isModule) {
|
|
314
|
+
const decoded = client.registry.findMetaError(dispatchError.asModule);
|
|
315
|
+
errorInfo = `${decoded.section}.${decoded.name}`;
|
|
316
|
+
}
|
|
317
|
+
reject(new Error(`${event.section}.${event.method}:: ExtrinsicFailed:: ${errorInfo}`));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// src/keyringUtils.ts
|
|
324
|
+
function keyringFromSuri(suri, cryptoType = "sr25519") {
|
|
325
|
+
return new (0, _api.Keyring)({ type: cryptoType }).createFromUri(suri);
|
|
326
|
+
}
|
|
327
|
+
function createKeyringPair(opts) {
|
|
328
|
+
const { cryptoType } = opts;
|
|
329
|
+
const seed = _utilcrypto.mnemonicGenerate.call(void 0, );
|
|
330
|
+
return keyringFromSuri(seed, cryptoType);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// src/header.ts
|
|
334
|
+
function getTickFromHeader(client, header) {
|
|
335
|
+
for (const x of header.digest.logs) {
|
|
336
|
+
if (x.isPreRuntime) {
|
|
337
|
+
const [engineId, data] = x.asPreRuntime;
|
|
338
|
+
if (engineId.toString() === "aura") {
|
|
339
|
+
return client.createType("u64", data).toNumber();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return void 0;
|
|
344
|
+
}
|
|
345
|
+
function getAuthorFromHeader(client, header) {
|
|
346
|
+
for (const x of header.digest.logs) {
|
|
347
|
+
if (x.isPreRuntime) {
|
|
348
|
+
const [engineId, data] = x.asPreRuntime;
|
|
349
|
+
if (engineId.toString() === "pow_") {
|
|
350
|
+
return client.createType("AccountId32", data).toHuman();
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return void 0;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// src/Vault.ts
|
|
358
|
+
|
|
359
|
+
var _bs58check = require('bs58check'); var _bs58check2 = _interopRequireDefault(_bs58check);
|
|
360
|
+
var _util = require('@polkadot/util');
|
|
361
|
+
var { ROUND_FLOOR: ROUND_FLOOR2 } = BN2;
|
|
362
|
+
var Vault = class _Vault {
|
|
363
|
+
constructor(id, vault, tickDuration) {
|
|
364
|
+
this.tickDuration = tickDuration;
|
|
365
|
+
this.vaultId = id;
|
|
366
|
+
this.openedTick = vault.openedTick.toNumber();
|
|
367
|
+
this.openedDate = new Date(this.openedTick * this.tickDuration);
|
|
368
|
+
this.argonsScheduledForRelease = /* @__PURE__ */ new Map();
|
|
369
|
+
this.load(vault);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
load(vault) {
|
|
385
|
+
this.securitization = vault.securitization.toBigInt();
|
|
386
|
+
this.securitizationRatio = fromFixedNumber(
|
|
387
|
+
vault.securitizationRatio.toBigInt(),
|
|
388
|
+
FIXED_U128_DECIMALS
|
|
389
|
+
).toNumber();
|
|
390
|
+
this.argonsLocked = vault.argonsLocked.toBigInt();
|
|
391
|
+
this.argonsPendingActivation = vault.argonsPendingActivation.toBigInt();
|
|
392
|
+
if (vault.argonsScheduledForRelease.size > 0) {
|
|
393
|
+
this.argonsScheduledForRelease.clear();
|
|
394
|
+
for (const [tick, amount] of vault.argonsScheduledForRelease.entries()) {
|
|
395
|
+
this.argonsScheduledForRelease.set(tick.toNumber(), amount.toBigInt());
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
this.terms = {
|
|
399
|
+
bitcoinAnnualPercentRate: fromFixedNumber(
|
|
400
|
+
vault.terms.bitcoinAnnualPercentRate.toBigInt(),
|
|
401
|
+
FIXED_U128_DECIMALS
|
|
402
|
+
),
|
|
403
|
+
bitcoinBaseFee: vault.terms.bitcoinBaseFee.toBigInt(),
|
|
404
|
+
liquidityPoolProfitSharing: fromFixedNumber(
|
|
405
|
+
vault.terms.liquidityPoolProfitSharing.toBigInt(),
|
|
406
|
+
PERMILL_DECIMALS
|
|
407
|
+
)
|
|
408
|
+
};
|
|
409
|
+
this.operatorAccountId = vault.operatorAccountId.toString();
|
|
410
|
+
this.isClosed = vault.isClosed.valueOf();
|
|
411
|
+
if (vault.pendingTerms.isSome) {
|
|
412
|
+
const [tickApply, terms] = vault.pendingTerms.value;
|
|
413
|
+
this.pendingTermsChangeTick = tickApply.toNumber();
|
|
414
|
+
this.pendingTerms = {
|
|
415
|
+
bitcoinAnnualPercentRate: fromFixedNumber(
|
|
416
|
+
terms.bitcoinAnnualPercentRate.toBigInt(),
|
|
417
|
+
FIXED_U128_DECIMALS
|
|
418
|
+
),
|
|
419
|
+
bitcoinBaseFee: terms.bitcoinBaseFee.toBigInt(),
|
|
420
|
+
liquidityPoolProfitSharing: fromFixedNumber(
|
|
421
|
+
vault.terms.liquidityPoolProfitSharing.toBigInt(),
|
|
422
|
+
PERMILL_DECIMALS
|
|
423
|
+
)
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
availableBitcoinSpace() {
|
|
428
|
+
const recoverySecuritization = this.recoverySecuritization();
|
|
429
|
+
const reLockable = this.getRelockCapacity();
|
|
430
|
+
return this.securitization - recoverySecuritization - this.argonsLocked + reLockable;
|
|
431
|
+
}
|
|
432
|
+
getRelockCapacity() {
|
|
433
|
+
return [...this.argonsScheduledForRelease.values()].reduce((acc, val) => acc + val, 0n);
|
|
434
|
+
}
|
|
435
|
+
securitizationRatioBN() {
|
|
436
|
+
return new (0, BN.default)(this.securitizationRatio);
|
|
437
|
+
}
|
|
438
|
+
recoverySecuritization() {
|
|
439
|
+
const reserved = new (0, BN.default)(1).div(this.securitizationRatioBN());
|
|
440
|
+
return this.securitization - BigInt(reserved.multipliedBy(this.securitization.toString()).toFixed(0, ROUND_FLOOR2));
|
|
441
|
+
}
|
|
442
|
+
minimumSecuritization() {
|
|
443
|
+
return BigInt(
|
|
444
|
+
this.securitizationRatioBN().multipliedBy(this.argonsLocked.toString()).decimalPlaces(0, BN.default.ROUND_CEIL).toString()
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
activatedSecuritization() {
|
|
448
|
+
const activated = this.argonsLocked - this.argonsPendingActivation;
|
|
449
|
+
const maxRatio = BN.default.call(void 0, Math.min(this.securitizationRatio, 2));
|
|
450
|
+
return BigInt(maxRatio.multipliedBy(activated.toString()).toFixed(0, ROUND_FLOOR2));
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Returns the amount of Argons available to match per liquidity pool
|
|
454
|
+
*/
|
|
455
|
+
activatedSecuritizationPerSlot() {
|
|
456
|
+
const activated = this.activatedSecuritization();
|
|
457
|
+
return activated / 10n;
|
|
458
|
+
}
|
|
459
|
+
calculateBitcoinFee(amount) {
|
|
460
|
+
const fee = this.terms.bitcoinAnnualPercentRate.multipliedBy(Number(amount)).integerValue(BN.default.ROUND_CEIL);
|
|
461
|
+
return BigInt(fee.toString()) + this.terms.bitcoinBaseFee;
|
|
462
|
+
}
|
|
463
|
+
static async get(client, vaultId, tickDurationMillis) {
|
|
464
|
+
const rawVault = await client.query.vaults.vaultsById(vaultId);
|
|
465
|
+
if (rawVault.isNone) {
|
|
466
|
+
throw new Error(`Vault with id ${vaultId} not found`);
|
|
467
|
+
}
|
|
468
|
+
const tickDuration = await _asyncNullishCoalesce(tickDurationMillis, async () => ( await client.query.ticks.genesisTicker().then((x) => x.tickDurationMillis.toNumber())));
|
|
469
|
+
return new _Vault(vaultId, rawVault.unwrap(), tickDuration);
|
|
470
|
+
}
|
|
471
|
+
static async create(client, keypair, args, config = {}) {
|
|
472
|
+
const {
|
|
473
|
+
securitization,
|
|
474
|
+
securitizationRatio,
|
|
475
|
+
annualPercentRate,
|
|
476
|
+
baseFee,
|
|
477
|
+
bitcoinXpub,
|
|
478
|
+
tip,
|
|
479
|
+
doNotExceedBalance,
|
|
480
|
+
txProgressCallback
|
|
481
|
+
} = args;
|
|
482
|
+
let xpubBytes = _util.hexToU8a.call(void 0, bitcoinXpub);
|
|
483
|
+
if (xpubBytes.length !== 78) {
|
|
484
|
+
if (bitcoinXpub.startsWith("xpub") || bitcoinXpub.startsWith("tpub") || bitcoinXpub.startsWith("zpub")) {
|
|
485
|
+
const bytes = _bs58check2.default.decode(bitcoinXpub);
|
|
486
|
+
if (bytes.length !== 78) {
|
|
487
|
+
throw new Error("Invalid Bitcoin xpub key length, must be 78 bytes");
|
|
488
|
+
}
|
|
489
|
+
xpubBytes = bytes;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
const vaultParams = {
|
|
493
|
+
terms: {
|
|
494
|
+
// convert to fixed u128
|
|
495
|
+
bitcoinAnnualPercentRate: toFixedNumber(annualPercentRate, FIXED_U128_DECIMALS),
|
|
496
|
+
bitcoinBaseFee: BigInt(baseFee),
|
|
497
|
+
liquidityPoolProfitSharing: toFixedNumber(
|
|
498
|
+
args.liquidityPoolProfitSharing,
|
|
499
|
+
PERMILL_DECIMALS
|
|
500
|
+
)
|
|
501
|
+
},
|
|
502
|
+
securitizationRatio: toFixedNumber(securitizationRatio, FIXED_U128_DECIMALS),
|
|
503
|
+
securitization: BigInt(securitization),
|
|
504
|
+
bitcoinXpubkey: xpubBytes
|
|
505
|
+
};
|
|
506
|
+
const tx = new TxSubmitter(client, client.tx.vaults.create(vaultParams), keypair);
|
|
507
|
+
if (doNotExceedBalance) {
|
|
508
|
+
const finalTip = _nullishCoalesce(tip, () => ( 0n));
|
|
509
|
+
let txFee = await tx.feeEstimate(finalTip);
|
|
510
|
+
while (txFee + finalTip + vaultParams.securitization > doNotExceedBalance) {
|
|
511
|
+
vaultParams.securitization = doNotExceedBalance - txFee - finalTip;
|
|
512
|
+
tx.tx = client.tx.vaults.create(vaultParams);
|
|
513
|
+
txFee = await tx.feeEstimate(finalTip);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
const canAfford = await tx.canAfford({ tip, unavailableBalance: BigInt(securitization) });
|
|
517
|
+
if (!canAfford.canAfford) {
|
|
518
|
+
throw new Error(
|
|
519
|
+
`Insufficient balance to create vault. Required: ${formatArgons(securitization)}, Available: ${formatArgons(canAfford.availableBalance)}`
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
const result = await tx.submit({
|
|
523
|
+
tip,
|
|
524
|
+
useLatestNonce: true,
|
|
525
|
+
waitForBlock: true,
|
|
526
|
+
txProgressCallback
|
|
527
|
+
});
|
|
528
|
+
await result.inBlockPromise;
|
|
529
|
+
let vaultId;
|
|
530
|
+
for (const event of result.events) {
|
|
531
|
+
if (client.events.vaults.VaultCreated.is(event)) {
|
|
532
|
+
vaultId = event.data.vaultId.toNumber();
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
if (vaultId === void 0) {
|
|
537
|
+
throw new Error("Vault creation failed, no VaultCreated event found");
|
|
538
|
+
}
|
|
539
|
+
const rawVault = await client.query.vaults.vaultsById(vaultId);
|
|
540
|
+
if (rawVault.isNone) {
|
|
541
|
+
throw new Error("Vault creation failed, vault not found");
|
|
542
|
+
}
|
|
543
|
+
const tickDuration = await _asyncNullishCoalesce(config.tickDurationMillis, async () => ( await client.query.ticks.genesisTicker().then((x) => x.tickDurationMillis.toNumber())));
|
|
544
|
+
const vault = new _Vault(vaultId, rawVault.unwrap(), tickDuration);
|
|
545
|
+
return { vault, txResult: result };
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
// src/convert.ts
|
|
550
|
+
|
|
551
|
+
function toFixedNumber(value, decimals) {
|
|
552
|
+
const factor = new (0, BN.default)(10).pow(decimals);
|
|
553
|
+
const bn = new (0, BN.default)(value);
|
|
554
|
+
const int = bn.times(factor).integerValue(BN.default.ROUND_DOWN);
|
|
555
|
+
return BigInt(int.toFixed(0));
|
|
556
|
+
}
|
|
557
|
+
function fromFixedNumber(value, decimals = FIXED_U128_DECIMALS) {
|
|
558
|
+
const factor = new (0, BN.default)(10).pow(decimals);
|
|
559
|
+
const bn = new (0, BN.default)(value.toString());
|
|
560
|
+
return bn.div(factor);
|
|
561
|
+
}
|
|
562
|
+
var FIXED_U128_DECIMALS = 18;
|
|
563
|
+
var PERMILL_DECIMALS = 6;
|
|
564
|
+
|
|
565
|
+
// src/BitcoinLocks.ts
|
|
566
|
+
|
|
567
|
+
var SATS_PER_BTC = 100000000n;
|
|
568
|
+
var BitcoinLocks = class {
|
|
569
|
+
constructor(client) {
|
|
570
|
+
this.client = client;
|
|
571
|
+
}
|
|
572
|
+
async getUtxoIdFromEvents(events) {
|
|
573
|
+
for (const event of events) {
|
|
574
|
+
if (this.client.events.bitcoinLocks.BitcoinLockCreated.is(event)) {
|
|
575
|
+
return event.data.utxoId.toNumber();
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
return void 0;
|
|
579
|
+
}
|
|
580
|
+
async getMarketRate(satoshis) {
|
|
581
|
+
const client = this.client;
|
|
582
|
+
const sats = client.createType("U64", satoshis.toString());
|
|
583
|
+
const marketRate = await client.rpc.state.call("BitcoinApis_market_rate", sats.toHex(true));
|
|
584
|
+
const rate = client.createType("Option<U128>", marketRate);
|
|
585
|
+
if (!rate.isSome) {
|
|
586
|
+
throw new Error("Market rate not available");
|
|
587
|
+
}
|
|
588
|
+
return rate.value.toBigInt();
|
|
589
|
+
}
|
|
590
|
+
async getRedemptionRate(satoshis) {
|
|
591
|
+
const client = this.client;
|
|
592
|
+
const sats = client.createType("U64", satoshis.toString());
|
|
593
|
+
const marketRate = await client.rpc.state.call("BitcoinApis_redemption_rate", sats.toHex(true));
|
|
594
|
+
const rate = client.createType("Option<U128>", marketRate);
|
|
595
|
+
if (!rate.isSome) {
|
|
596
|
+
throw new Error("Redemption rate not available");
|
|
597
|
+
}
|
|
598
|
+
return rate.value.toBigInt();
|
|
599
|
+
}
|
|
600
|
+
async getConfig() {
|
|
601
|
+
const client = this.client;
|
|
602
|
+
const bitcoinNetwork = await client.query.bitcoinUtxos.bitcoinNetwork();
|
|
603
|
+
return {
|
|
604
|
+
lockReleaseCosignDeadlineFrames: client.consts.bitcoinLocks.lockReleaseCosignDeadlineFrames.toNumber(),
|
|
605
|
+
pendingConfirmationExpirationBlocks: client.consts.bitcoinUtxos.maxPendingConfirmationBlocks.toNumber(),
|
|
606
|
+
tickDurationMillis: await client.query.ticks.genesisTicker().then((x) => x.tickDurationMillis.toNumber()),
|
|
607
|
+
bitcoinNetwork
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
async getBitcoinConfirmedBlockHeight() {
|
|
611
|
+
return await this.client.query.bitcoinUtxos.confirmedBitcoinBlockTip().then((x) => _nullishCoalesce(_optionalChain([x, 'access', _ => _.value, 'optionalAccess', _2 => _2.blockHeight, 'access', _3 => _3.toNumber, 'call', _4 => _4()]), () => ( 0)));
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Gets the UTXO reference by ID.
|
|
615
|
+
* @param utxoId - The UTXO ID to look up.
|
|
616
|
+
* @param clientAtHeight - Optional client at the block height to query the UTXO reference at a specific point in time.
|
|
617
|
+
* @return An object containing the transaction ID and output index, or undefined if not found.
|
|
618
|
+
* @return.txid - The Bitcoin transaction ID of the UTXO.
|
|
619
|
+
* @return.vout - The output index of the UTXO in the transaction.
|
|
620
|
+
* @return.bitcoinTxid - The Bitcoin transaction ID of the UTXO formatted in little endian
|
|
621
|
+
*/
|
|
622
|
+
async getUtxoRef(utxoId, clientAtHeight) {
|
|
623
|
+
const client = _nullishCoalesce(clientAtHeight, () => ( this.client));
|
|
624
|
+
const refRaw = await client.query.bitcoinUtxos.utxoIdToRef(utxoId);
|
|
625
|
+
if (!refRaw) {
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
const ref = refRaw.unwrap();
|
|
629
|
+
const txid = _util.u8aToHex.call(void 0, ref.txid);
|
|
630
|
+
const bitcoinTxid = _util.u8aToHex.call(void 0, ref.txid.reverse());
|
|
631
|
+
const vout = ref.outputIndex.toNumber();
|
|
632
|
+
return { txid, vout, bitcoinTxid };
|
|
633
|
+
}
|
|
634
|
+
async getReleaseRequest(utxoId, clientAtHeight) {
|
|
635
|
+
const client = _nullishCoalesce(clientAtHeight, () => ( this.client));
|
|
636
|
+
const requestMaybe = await client.query.bitcoinLocks.lockReleaseRequestsByUtxoId(utxoId);
|
|
637
|
+
if (!requestMaybe.isSome) {
|
|
638
|
+
return void 0;
|
|
639
|
+
}
|
|
640
|
+
const request = requestMaybe.unwrap();
|
|
641
|
+
return {
|
|
642
|
+
toScriptPubkey: request.toScriptPubkey.toHex(),
|
|
643
|
+
bitcoinNetworkFee: request.bitcoinNetworkFee.toBigInt(),
|
|
644
|
+
dueFrame: request.cosignDueFrame.toNumber(),
|
|
645
|
+
vaultId: request.vaultId.toNumber(),
|
|
646
|
+
redemptionPrice: request.redemptionPrice.toBigInt()
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
async submitVaultSignature(args) {
|
|
650
|
+
const { utxoId, vaultSignature, argonKeyring, txProgressCallback } = args;
|
|
651
|
+
const client = this.client;
|
|
652
|
+
if (!vaultSignature || vaultSignature.byteLength < 70 || vaultSignature.byteLength > 73) {
|
|
653
|
+
throw new Error(
|
|
654
|
+
`Invalid vault signature length: ${vaultSignature.byteLength}. Must be 70-73 bytes.`
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
const signature = _util.u8aToHex.call(void 0, vaultSignature);
|
|
658
|
+
const tx = client.tx.bitcoinLocks.cosignRelease(utxoId, signature);
|
|
659
|
+
const submitter = new TxSubmitter(client, tx, argonKeyring);
|
|
660
|
+
return await submitter.submit({ txProgressCallback });
|
|
661
|
+
}
|
|
662
|
+
async getBitcoinLock(utxoId) {
|
|
663
|
+
const utxoRaw = await this.client.query.bitcoinLocks.locksByUtxoId(utxoId);
|
|
664
|
+
if (!utxoRaw.isSome) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
const utxo = utxoRaw.unwrap();
|
|
668
|
+
const p2shBytesPrefix = "0020";
|
|
669
|
+
const wscriptHash = utxo.utxoScriptPubkey.asP2wsh.wscriptHash.toHex().replace("0x", "");
|
|
670
|
+
const p2wshScriptHashHex = `0x${p2shBytesPrefix}${wscriptHash}`;
|
|
671
|
+
const vaultId = utxo.vaultId.toNumber();
|
|
672
|
+
const peggedPrice = utxo.peggedPrice.toBigInt();
|
|
673
|
+
const liquidityPromised = utxo.liquidityPromised.toBigInt();
|
|
674
|
+
const ownerAccount = utxo.ownerAccount.toHuman();
|
|
675
|
+
const satoshis = utxo.satoshis.toBigInt();
|
|
676
|
+
const vaultPubkey = utxo.vaultPubkey.toHex();
|
|
677
|
+
const vaultClaimPubkey = utxo.vaultClaimPubkey.toHex();
|
|
678
|
+
const ownerPubkey = utxo.ownerPubkey.toHex();
|
|
679
|
+
const [fingerprint, cosign_hd_index, claim_hd_index] = utxo.vaultXpubSources;
|
|
680
|
+
const vaultXpubSources = {
|
|
681
|
+
parentFingerprint: new Uint8Array(fingerprint),
|
|
682
|
+
cosignHdIndex: cosign_hd_index.toNumber(),
|
|
683
|
+
claimHdIndex: claim_hd_index.toNumber()
|
|
684
|
+
};
|
|
685
|
+
const vaultClaimHeight = utxo.vaultClaimHeight.toNumber();
|
|
686
|
+
const openClaimHeight = utxo.openClaimHeight.toNumber();
|
|
687
|
+
const createdAtHeight = utxo.createdAtHeight.toNumber();
|
|
688
|
+
const isVerified = utxo.isVerified.toJSON();
|
|
689
|
+
const isRejectedNeedsRelease = utxo.isRejectedNeedsRelease.toJSON();
|
|
690
|
+
const fundHoldExtensionsByBitcoinExpirationHeight = Object.fromEntries(
|
|
691
|
+
[...utxo.fundHoldExtensions.entries()].map(([x, y]) => [x.toNumber(), y.toBigInt()])
|
|
692
|
+
);
|
|
693
|
+
return {
|
|
694
|
+
utxoId,
|
|
695
|
+
p2wshScriptHashHex,
|
|
696
|
+
vaultId,
|
|
697
|
+
peggedPrice,
|
|
698
|
+
liquidityPromised,
|
|
699
|
+
ownerAccount,
|
|
700
|
+
satoshis,
|
|
701
|
+
vaultPubkey,
|
|
702
|
+
vaultClaimPubkey,
|
|
703
|
+
ownerPubkey,
|
|
704
|
+
vaultXpubSources,
|
|
705
|
+
vaultClaimHeight,
|
|
706
|
+
openClaimHeight,
|
|
707
|
+
createdAtHeight,
|
|
708
|
+
isVerified,
|
|
709
|
+
isRejectedNeedsRelease,
|
|
710
|
+
fundHoldExtensionsByBitcoinExpirationHeight
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Finds the cosign signature for a vault lock by UTXO ID. Optionally waits for the signature
|
|
715
|
+
* @param utxoId - The UTXO ID of the bitcoin lock
|
|
716
|
+
* @param waitForSignatureMillis - Optional timeout in milliseconds to wait for the signature. If -1, waits indefinitely.
|
|
717
|
+
*/
|
|
718
|
+
async findVaultCosignSignature(utxoId, waitForSignatureMillis) {
|
|
719
|
+
const client = this.client;
|
|
720
|
+
const releaseHeight = await client.query.bitcoinLocks.lockReleaseCosignHeightById(utxoId);
|
|
721
|
+
if (releaseHeight.isSome) {
|
|
722
|
+
const releaseHeightValue = releaseHeight.unwrap().toNumber();
|
|
723
|
+
const signature = await this.getVaultCosignSignature(utxoId, releaseHeightValue);
|
|
724
|
+
if (signature) {
|
|
725
|
+
return { blockHeight: releaseHeightValue, signature };
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
if (!waitForSignatureMillis) {
|
|
729
|
+
return void 0;
|
|
730
|
+
}
|
|
731
|
+
return await new Promise(async (resolve, reject) => {
|
|
732
|
+
let timeout;
|
|
733
|
+
const unsub = await client.rpc.chain.subscribeNewHeads((header) => {
|
|
734
|
+
const atHeight = header.number.toNumber();
|
|
735
|
+
this.getVaultCosignSignature(utxoId, atHeight).then((signature) => {
|
|
736
|
+
if (signature) {
|
|
737
|
+
_optionalChain([unsub, 'optionalCall', _5 => _5()]);
|
|
738
|
+
clearTimeout(timeout);
|
|
739
|
+
resolve({ signature, blockHeight: atHeight });
|
|
740
|
+
}
|
|
741
|
+
}).catch((err) => {
|
|
742
|
+
console.error(`Error checking for cosign signature at height ${atHeight}:`, err);
|
|
743
|
+
});
|
|
744
|
+
});
|
|
745
|
+
if (waitForSignatureMillis !== -1) {
|
|
746
|
+
timeout = setTimeout(() => {
|
|
747
|
+
_optionalChain([unsub, 'optionalCall', _6 => _6()]);
|
|
748
|
+
reject(new Error(`Timeout waiting for cosign signature for UTXO ID ${utxoId}`));
|
|
749
|
+
}, waitForSignatureMillis);
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
async blockHashAtHeight(atHeight) {
|
|
754
|
+
const client = this.client;
|
|
755
|
+
for (let i = 0; i < 10; i++) {
|
|
756
|
+
const currentHeight = await client.query.system.number().then((x) => x.toNumber());
|
|
757
|
+
if (atHeight > currentHeight) {
|
|
758
|
+
console.warn(
|
|
759
|
+
`Requested block height ${atHeight} is greater than current height ${currentHeight}. Retrying...`
|
|
760
|
+
);
|
|
761
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
const hash = await client.rpc.chain.getBlockHash(atHeight).then((x) => x.toHex());
|
|
765
|
+
if (hash === "0x0000000000000000000000000000000000000000000000000000000000000000") {
|
|
766
|
+
console.warn(`Block hash not found for height ${atHeight}. Retrying...`);
|
|
767
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
768
|
+
continue;
|
|
769
|
+
}
|
|
770
|
+
return hash;
|
|
771
|
+
}
|
|
772
|
+
return void 0;
|
|
773
|
+
}
|
|
774
|
+
async getVaultCosignSignature(utxoId, atHeight) {
|
|
775
|
+
const client = this.client;
|
|
776
|
+
const blockHash = await this.blockHashAtHeight(atHeight);
|
|
777
|
+
if (!blockHash) {
|
|
778
|
+
console.warn(`Block hash not found for height ${atHeight}`);
|
|
779
|
+
return void 0;
|
|
780
|
+
}
|
|
781
|
+
const blockEvents = await client.at(blockHash).then((api) => api.query.system.events());
|
|
782
|
+
for (const event of blockEvents) {
|
|
783
|
+
if (client.events.bitcoinLocks.BitcoinUtxoCosigned.is(event.event)) {
|
|
784
|
+
const { utxoId: id, signature } = event.event.data;
|
|
785
|
+
if (id.toNumber() === utxoId) {
|
|
786
|
+
return new Uint8Array(signature);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return void 0;
|
|
791
|
+
}
|
|
792
|
+
async findPendingMints(utxoId) {
|
|
793
|
+
const pendingMint = await this.client.query.mint.pendingMintUtxos();
|
|
794
|
+
const mintsPending = [];
|
|
795
|
+
for (const [utxoIdRaw, _accountId, mintAmountRaw] of pendingMint) {
|
|
796
|
+
if (utxoIdRaw.toNumber() === utxoId) {
|
|
797
|
+
mintsPending.push(mintAmountRaw.toBigInt());
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
return mintsPending;
|
|
801
|
+
}
|
|
802
|
+
async createInitializeLockTx(args) {
|
|
803
|
+
const { vault, argonKeyring, satoshis, tip = 0n, ownerBitcoinPubkey } = args;
|
|
804
|
+
const client = this.client;
|
|
805
|
+
if (ownerBitcoinPubkey.length !== 33) {
|
|
806
|
+
throw new Error(
|
|
807
|
+
`Invalid Bitcoin key length: ${ownerBitcoinPubkey.length}. Must be a compressed pukey (33 bytes).`
|
|
808
|
+
);
|
|
809
|
+
}
|
|
810
|
+
const tx = client.tx.bitcoinLocks.initialize(vault.vaultId, satoshis, ownerBitcoinPubkey);
|
|
811
|
+
const submitter = new TxSubmitter(
|
|
812
|
+
client,
|
|
813
|
+
client.tx.bitcoinLocks.initialize(vault.vaultId, satoshis, ownerBitcoinPubkey),
|
|
814
|
+
argonKeyring
|
|
815
|
+
);
|
|
816
|
+
const marketPrice = await this.getMarketRate(BigInt(satoshis));
|
|
817
|
+
const isVaultOwner = argonKeyring.address === vault.operatorAccountId;
|
|
818
|
+
const securityFee = isVaultOwner ? 0n : vault.calculateBitcoinFee(marketPrice);
|
|
819
|
+
const { canAfford, availableBalance, txFee } = await submitter.canAfford({
|
|
820
|
+
tip,
|
|
821
|
+
unavailableBalance: securityFee + (_nullishCoalesce(args.reducedBalanceBy, () => ( 0n))),
|
|
822
|
+
includeExistentialDeposit: true
|
|
823
|
+
});
|
|
824
|
+
if (!canAfford) {
|
|
825
|
+
throw new Error(
|
|
826
|
+
`Insufficient funds to initialize lock. Available: ${formatArgons(availableBalance)}, Required: ${satoshis}`
|
|
827
|
+
);
|
|
828
|
+
}
|
|
829
|
+
return { tx, securityFee, txFee };
|
|
830
|
+
}
|
|
831
|
+
async getBitcoinLockFromTxResult(txResult) {
|
|
832
|
+
const client = this.client;
|
|
833
|
+
const blockHash = await txResult.inBlockPromise;
|
|
834
|
+
const blockHeight = await client.at(blockHash).then((x) => x.query.system.number()).then((x) => x.toNumber());
|
|
835
|
+
const utxoId = await _asyncNullishCoalesce(await this.getUtxoIdFromEvents(txResult.events), async () => ( 0));
|
|
836
|
+
if (utxoId === 0) {
|
|
837
|
+
throw new Error("Bitcoin lock creation failed, no UTXO ID found in transaction events");
|
|
838
|
+
}
|
|
839
|
+
const lock = await this.getBitcoinLock(utxoId);
|
|
840
|
+
if (!lock) {
|
|
841
|
+
throw new Error(`Lock with ID ${utxoId} not found after initialization`);
|
|
842
|
+
}
|
|
843
|
+
return { lock, createdAtHeight: blockHeight, txResult };
|
|
844
|
+
}
|
|
845
|
+
async initializeLock(args) {
|
|
846
|
+
const { argonKeyring, tip = 0n, txProgressCallback } = args;
|
|
847
|
+
const client = this.client;
|
|
848
|
+
const { tx, securityFee } = await this.createInitializeLockTx(args);
|
|
849
|
+
const submitter = new TxSubmitter(client, tx, argonKeyring);
|
|
850
|
+
const txResult = await submitter.submit({
|
|
851
|
+
waitForBlock: true,
|
|
852
|
+
logResults: true,
|
|
853
|
+
tip,
|
|
854
|
+
txProgressCallback
|
|
855
|
+
});
|
|
856
|
+
const { lock, createdAtHeight } = await this.getBitcoinLockFromTxResult(txResult);
|
|
857
|
+
return {
|
|
858
|
+
lock,
|
|
859
|
+
createdAtHeight,
|
|
860
|
+
txResult,
|
|
861
|
+
securityFee
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
async requiredSatoshisForArgonLiquidity(argonAmount) {
|
|
865
|
+
const marketRatePerBitcoin = await this.getMarketRate(SATS_PER_BTC);
|
|
866
|
+
return argonAmount * SATS_PER_BTC / marketRatePerBitcoin;
|
|
867
|
+
}
|
|
868
|
+
async requestRelease(args) {
|
|
869
|
+
const client = this.client;
|
|
870
|
+
const {
|
|
871
|
+
lock,
|
|
872
|
+
releaseRequest: { bitcoinNetworkFee, toScriptPubkey },
|
|
873
|
+
argonKeyring,
|
|
874
|
+
tip,
|
|
875
|
+
txProgressCallback
|
|
876
|
+
} = args;
|
|
877
|
+
if (!toScriptPubkey.startsWith("0x")) {
|
|
878
|
+
throw new Error("toScriptPubkey must be a hex string starting with 0x");
|
|
879
|
+
}
|
|
880
|
+
const submitter = new TxSubmitter(
|
|
881
|
+
client,
|
|
882
|
+
client.tx.bitcoinLocks.requestRelease(lock.utxoId, toScriptPubkey, bitcoinNetworkFee),
|
|
883
|
+
argonKeyring
|
|
884
|
+
);
|
|
885
|
+
let redemptionPrice = await this.getRedemptionRate(lock.satoshis);
|
|
886
|
+
if (redemptionPrice > lock.peggedPrice) {
|
|
887
|
+
redemptionPrice = lock.peggedPrice;
|
|
888
|
+
}
|
|
889
|
+
const canAfford = await submitter.canAfford({
|
|
890
|
+
tip,
|
|
891
|
+
unavailableBalance: BigInt(redemptionPrice)
|
|
892
|
+
});
|
|
893
|
+
if (!canAfford.canAfford) {
|
|
894
|
+
throw new Error(
|
|
895
|
+
`Insufficient funds to release lock. Available: ${formatArgons(canAfford.availableBalance)}, Required: ${formatArgons(redemptionPrice)}`
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
const txResult = await submitter.submit({
|
|
899
|
+
waitForBlock: true,
|
|
900
|
+
logResults: true,
|
|
901
|
+
tip,
|
|
902
|
+
txProgressCallback
|
|
903
|
+
});
|
|
904
|
+
const blockHash = await txResult.inBlockPromise;
|
|
905
|
+
const blockHeight = await client.at(blockHash).then((x) => x.query.system.number()).then((x) => x.toNumber());
|
|
906
|
+
return {
|
|
907
|
+
blockHash,
|
|
908
|
+
blockHeight
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
async releasePrice(satoshis, peggedPrice) {
|
|
912
|
+
const redemptionRate = await this.getRedemptionRate(satoshis);
|
|
913
|
+
if (redemptionRate > peggedPrice) {
|
|
914
|
+
return redemptionRate;
|
|
915
|
+
}
|
|
916
|
+
return peggedPrice;
|
|
917
|
+
}
|
|
918
|
+
async getRatchetPrice(lock, vault) {
|
|
919
|
+
const { createdAtHeight, vaultClaimHeight, peggedPrice, satoshis } = lock;
|
|
920
|
+
const client = this.client;
|
|
921
|
+
const marketRate = await this.getMarketRate(BigInt(satoshis));
|
|
922
|
+
let ratchetingFee = vault.terms.bitcoinBaseFee;
|
|
923
|
+
let burnAmount = 0n;
|
|
924
|
+
if (marketRate > peggedPrice) {
|
|
925
|
+
const lockFee = vault.calculateBitcoinFee(marketRate);
|
|
926
|
+
const currentBitcoinHeight = await client.query.bitcoinUtxos.confirmedBitcoinBlockTip().then((x) => x.unwrap().blockHeight.toNumber());
|
|
927
|
+
const blockLength = vaultClaimHeight - createdAtHeight;
|
|
928
|
+
const elapsed = (currentBitcoinHeight - createdAtHeight) / blockLength;
|
|
929
|
+
const remainingDuration = 1 - elapsed;
|
|
930
|
+
ratchetingFee = BigInt(remainingDuration * Number(lockFee));
|
|
931
|
+
} else {
|
|
932
|
+
burnAmount = await this.releasePrice(lock.satoshis, peggedPrice);
|
|
933
|
+
}
|
|
934
|
+
return {
|
|
935
|
+
ratchetingFee,
|
|
936
|
+
burnAmount,
|
|
937
|
+
marketRate
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
async ratchet(args) {
|
|
941
|
+
const { lock, argonKeyring, tip = 0n, vault, txProgressCallback } = args;
|
|
942
|
+
const client = this.client;
|
|
943
|
+
const ratchetPrice = await this.getRatchetPrice(lock, vault);
|
|
944
|
+
const txSubmitter = new TxSubmitter(
|
|
945
|
+
client,
|
|
946
|
+
client.tx.bitcoinLocks.ratchet(lock.utxoId),
|
|
947
|
+
argonKeyring
|
|
948
|
+
);
|
|
949
|
+
const canAfford = await txSubmitter.canAfford({
|
|
950
|
+
tip,
|
|
951
|
+
unavailableBalance: BigInt(ratchetPrice.burnAmount + ratchetPrice.ratchetingFee)
|
|
952
|
+
});
|
|
953
|
+
if (!canAfford.canAfford) {
|
|
954
|
+
throw new Error(
|
|
955
|
+
`Insufficient funds to ratchet lock. Available: ${formatArgons(canAfford.availableBalance)}, Required: ${formatArgons(
|
|
956
|
+
ratchetPrice.burnAmount + ratchetPrice.ratchetingFee
|
|
957
|
+
)}`
|
|
958
|
+
);
|
|
959
|
+
}
|
|
960
|
+
const submission = await txSubmitter.submit({
|
|
961
|
+
waitForBlock: true,
|
|
962
|
+
tip,
|
|
963
|
+
txProgressCallback
|
|
964
|
+
});
|
|
965
|
+
const ratchetEvent = submission.events.find(
|
|
966
|
+
(x) => client.events.bitcoinLocks.BitcoinLockRatcheted.is(x)
|
|
967
|
+
);
|
|
968
|
+
if (!ratchetEvent) {
|
|
969
|
+
throw new Error(`Ratchet event not found in transaction events`);
|
|
970
|
+
}
|
|
971
|
+
const blockHash = await submission.inBlockPromise;
|
|
972
|
+
const api = await client.at(blockHash);
|
|
973
|
+
const blockHeight = await api.query.system.number().then((x) => x.toNumber());
|
|
974
|
+
const bitcoinBlockHeight = await api.query.bitcoinUtxos.confirmedBitcoinBlockTip().then((x) => x.unwrap().blockHeight.toNumber());
|
|
975
|
+
const { amountBurned, newPeggedPrice, originalPeggedPrice } = ratchetEvent.data;
|
|
976
|
+
let mintAmount = newPeggedPrice.toBigInt();
|
|
977
|
+
if (newPeggedPrice > originalPeggedPrice) {
|
|
978
|
+
mintAmount -= originalPeggedPrice.toBigInt();
|
|
979
|
+
}
|
|
980
|
+
return {
|
|
981
|
+
txFee: _nullishCoalesce(submission.finalFee, () => ( 0n)),
|
|
982
|
+
securityFee: ratchetPrice.ratchetingFee,
|
|
983
|
+
pendingMint: mintAmount,
|
|
984
|
+
newPeggedPrice: newPeggedPrice.toBigInt(),
|
|
985
|
+
burned: amountBurned.toBigInt(),
|
|
986
|
+
blockHeight,
|
|
987
|
+
bitcoinBlockHeight
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
};
|
|
2
991
|
|
|
992
|
+
// src/index.ts
|
|
3
993
|
|
|
994
|
+
var _generic = require('@polkadot/types/generic');
|
|
4
995
|
|
|
5
996
|
|
|
6
997
|
|
|
@@ -24,6 +1015,19 @@
|
|
|
24
1015
|
|
|
25
1016
|
|
|
26
1017
|
|
|
1018
|
+
var _typescodec = require('@polkadot/types-codec');
|
|
1019
|
+
async function waitForLoad() {
|
|
1020
|
+
await _utilcrypto.cryptoWaitReady.call(void 0, );
|
|
1021
|
+
}
|
|
1022
|
+
async function getClient(host, options) {
|
|
1023
|
+
let provider;
|
|
1024
|
+
if (host.startsWith("http")) {
|
|
1025
|
+
provider = new (0, _api.HttpProvider)(host);
|
|
1026
|
+
} else {
|
|
1027
|
+
provider = new (0, _api.WsProvider)(host);
|
|
1028
|
+
}
|
|
1029
|
+
return await _api.ApiPromise.create({ provider, noInitWarn: true, ..._nullishCoalesce(options, () => ( {})) });
|
|
1030
|
+
}
|
|
27
1031
|
|
|
28
1032
|
|
|
29
1033
|
|
|
@@ -72,7 +1076,6 @@
|
|
|
72
1076
|
|
|
73
1077
|
|
|
74
1078
|
|
|
75
|
-
var _chunkVXYWJG66cjs = require('./chunk-VXYWJG66.cjs');
|
|
76
1079
|
|
|
77
1080
|
|
|
78
1081
|
|
|
@@ -80,72 +1083,5 @@ var _chunkVXYWJG66cjs = require('./chunk-VXYWJG66.cjs');
|
|
|
80
1083
|
|
|
81
1084
|
|
|
82
1085
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
exports.AccountMiners = _chunkVXYWJG66cjs.AccountMiners; exports.AccountRegistry = _chunkVXYWJG66cjs.AccountRegistry; exports.Accountset = _chunkVXYWJG66cjs.Accountset; exports.BTreeMap = _chunkVXYWJG66cjs.BTreeMap; exports.BidPool = _chunkVXYWJG66cjs.BidPool; exports.BitcoinLocks = _chunkVXYWJG66cjs.BitcoinLocks; exports.BlockWatch = _chunkVXYWJG66cjs.BlockWatch; exports.Bool = _chunkVXYWJG66cjs.Bool; exports.Bytes = _chunkVXYWJG66cjs.Bytes; exports.CohortBidder = _chunkVXYWJG66cjs.CohortBidder; exports.Compact = _chunkVXYWJG66cjs.Compact; exports.Enum = _chunkVXYWJG66cjs.Enum; exports.ExtrinsicError = _chunkVXYWJG66cjs.ExtrinsicError; exports.FrameCalculator = _chunkVXYWJG66cjs.FrameCalculator; exports.GenericAddress = _chunkVXYWJG66cjs.GenericAddress; exports.GenericBlock = _chunkVXYWJG66cjs.GenericBlock; exports.GenericEvent = _chunkVXYWJG66cjs.GenericEvent; exports.JsonExt = _chunkVXYWJG66cjs.JsonExt; exports.Keyring = _chunkVXYWJG66cjs.Keyring; exports.MICROGONS_PER_ARGON = _chunkVXYWJG66cjs.MICROGONS_PER_ARGON; exports.MiningBids = _chunkVXYWJG66cjs.MiningBids; exports.Null = _chunkVXYWJG66cjs.Null; exports.Option = _chunkVXYWJG66cjs.Option; exports.Range = _chunkVXYWJG66cjs.Range; exports.Result = _chunkVXYWJG66cjs.Result; exports.SATS_PER_BTC = _chunkVXYWJG66cjs.SATS_PER_BTC; exports.Struct = _chunkVXYWJG66cjs.Struct; exports.Text = _chunkVXYWJG66cjs.Text; exports.Tuple = _chunkVXYWJG66cjs.Tuple; exports.TxResult = _chunkVXYWJG66cjs.TxResult; exports.TxSubmitter = _chunkVXYWJG66cjs.TxSubmitter; exports.TypedEmitter = _chunkVXYWJG66cjs.TypedEmitter; exports.U256 = _chunkVXYWJG66cjs.U256; exports.U8aFixed = _chunkVXYWJG66cjs.U8aFixed; exports.Vault = _chunkVXYWJG66cjs.Vault; exports.VaultMonitor = _chunkVXYWJG66cjs.VaultMonitor; exports.Vec = _chunkVXYWJG66cjs.Vec; exports.WageProtector = _chunkVXYWJG66cjs.WageProtector; exports.bool = _chunkVXYWJG66cjs.bool; exports.checkForExtrinsicSuccess = _chunkVXYWJG66cjs.checkForExtrinsicSuccess; exports.convertFixedU128ToBigNumber = _chunkVXYWJG66cjs.convertFixedU128ToBigNumber; exports.convertNumberToFixedU128 = _chunkVXYWJG66cjs.convertNumberToFixedU128; exports.convertNumberToPermill = _chunkVXYWJG66cjs.convertNumberToPermill; exports.convertPermillToBigNumber = _chunkVXYWJG66cjs.convertPermillToBigNumber; exports.createKeyringPair = _chunkVXYWJG66cjs.createKeyringPair; exports.createNanoEvents = _chunkVXYWJG66cjs.createNanoEvents; exports.decodeAddress = _chunkVXYWJG66cjs.decodeAddress; exports.dispatchErrorToExtrinsicError = _chunkVXYWJG66cjs.dispatchErrorToExtrinsicError; exports.dispatchErrorToString = _chunkVXYWJG66cjs.dispatchErrorToString; exports.eventDataToJson = _chunkVXYWJG66cjs.eventDataToJson; exports.filterUndefined = _chunkVXYWJG66cjs.filterUndefined; exports.formatArgons = _chunkVXYWJG66cjs.formatArgons; exports.formatPercent = _chunkVXYWJG66cjs.formatPercent; exports.getAuthorFromHeader = _chunkVXYWJG66cjs.getAuthorFromHeader; exports.getClient = _chunkVXYWJG66cjs.getClient; exports.getConfig = _chunkVXYWJG66cjs.getConfig; exports.getTickFromHeader = _chunkVXYWJG66cjs.getTickFromHeader; exports.gettersToObject = _chunkVXYWJG66cjs.gettersToObject; exports.hexToU8a = _chunkVXYWJG66cjs.hexToU8a; exports.i128 = _chunkVXYWJG66cjs.i128; exports.keyringFromSuri = _chunkVXYWJG66cjs.keyringFromSuri; exports.miniSecretFromUri = _chunkVXYWJG66cjs.miniSecretFromUri; exports.mnemonicGenerate = _chunkVXYWJG66cjs.mnemonicGenerate; exports.setConfig = _chunkVXYWJG66cjs.setConfig; exports.toFixedNumber = _chunkVXYWJG66cjs.toFixedNumber; exports.u128 = _chunkVXYWJG66cjs.u128; exports.u16 = _chunkVXYWJG66cjs.u16; exports.u32 = _chunkVXYWJG66cjs.u32; exports.u64 = _chunkVXYWJG66cjs.u64; exports.u8 = _chunkVXYWJG66cjs.u8; exports.u8aEq = _chunkVXYWJG66cjs.u8aEq; exports.u8aToHex = _chunkVXYWJG66cjs.u8aToHex; exports.waitForLoad = _chunkVXYWJG66cjs.waitForLoad;
|
|
1086
|
+
exports.BTreeMap = _typescodec.BTreeMap; exports.BitcoinLocks = BitcoinLocks; exports.Bool = _typescodec.Bool; exports.Bytes = _typescodec.Bytes; exports.Compact = _typescodec.Compact; exports.Enum = _typescodec.Enum; exports.ExtrinsicError = ExtrinsicError2; exports.FIXED_U128_DECIMALS = FIXED_U128_DECIMALS; exports.GenericAddress = _generic.GenericAddress; exports.GenericBlock = _generic.GenericBlock; exports.GenericEvent = _generic.GenericEvent; exports.Keyring = _api.Keyring; exports.MICROGONS_PER_ARGON = MICROGONS_PER_ARGON; exports.Null = _typescodec.Null; exports.Option = _typescodec.Option; exports.PERMILL_DECIMALS = PERMILL_DECIMALS; exports.Range = _typescodec.Range; exports.Result = _typescodec.Result; exports.SATS_PER_BTC = SATS_PER_BTC; exports.Struct = _typescodec.Struct; exports.Text = _typescodec.Text; exports.Tuple = _typescodec.Tuple; exports.TxResult = TxResult; exports.TxSubmitter = TxSubmitter; exports.U256 = _typescodec.U256; exports.U8aFixed = _typescodec.U8aFixed; exports.Vault = Vault; exports.Vec = _typescodec.Vec; exports.WageProtector = WageProtector; exports.bool = _typescodec.bool; exports.checkForExtrinsicSuccess = checkForExtrinsicSuccess; exports.createKeyringPair = createKeyringPair; exports.decodeAddress = _utilcrypto.decodeAddress; exports.dispatchErrorToExtrinsicError = dispatchErrorToExtrinsicError; exports.dispatchErrorToString = dispatchErrorToString; exports.formatArgons = formatArgons; exports.fromFixedNumber = fromFixedNumber; exports.getAuthorFromHeader = getAuthorFromHeader; exports.getClient = getClient; exports.getTickFromHeader = getTickFromHeader; exports.gettersToObject = gettersToObject; exports.hexToU8a = _util.hexToU8a; exports.i128 = _typescodec.i128; exports.keyringFromSuri = keyringFromSuri; exports.mnemonicGenerate = _utilcrypto.mnemonicGenerate; exports.toFixedNumber = toFixedNumber; exports.u128 = _typescodec.u128; exports.u16 = _typescodec.u16; exports.u32 = _typescodec.u32; exports.u64 = _typescodec.u64; exports.u8 = _typescodec.u8; exports.u8aEq = _util.u8aEq; exports.u8aToHex = _util.u8aToHex; exports.waitForLoad = waitForLoad;
|
|
151
1087
|
//# sourceMappingURL=index.cjs.map
|