@atomiqlabs/chain-evm 2.0.7 → 2.0.9
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/evm/btcrelay/EVMBtcRelay.d.ts +15 -48
- package/dist/evm/btcrelay/EVMBtcRelay.js +15 -48
- package/dist/evm/chain/EVMChainInterface.d.ts +69 -0
- package/dist/evm/chain/EVMChainInterface.js +69 -0
- package/dist/evm/events/EVMChainEventsBrowser.d.ts +15 -0
- package/dist/evm/events/EVMChainEventsBrowser.js +15 -0
- package/dist/evm/spv_swap/EVMSpvVaultContract.d.ts +72 -0
- package/dist/evm/spv_swap/EVMSpvVaultContract.js +72 -0
- package/dist/evm/spv_swap/EVMSpvWithdrawalData.d.ts +12 -0
- package/dist/evm/spv_swap/EVMSpvWithdrawalData.js +12 -0
- package/dist/evm/swaps/EVMSwapContract.d.ts +117 -33
- package/dist/evm/swaps/EVMSwapContract.js +117 -33
- package/dist/evm/swaps/EVMSwapData.d.ts +90 -0
- package/dist/evm/swaps/EVMSwapData.js +90 -0
- package/dist/evm/wallet/EVMBrowserSigner.js +2 -2
- package/dist/evm/wallet/EVMSigner.d.ts +3 -0
- package/dist/evm/wallet/EVMSigner.js +3 -0
- package/package.json +1 -1
- package/src/evm/btcrelay/EVMBtcRelay.ts +15 -48
- package/src/evm/chain/EVMChainInterface.ts +69 -0
- package/src/evm/events/EVMChainEventsBrowser.ts +15 -0
- package/src/evm/spv_swap/EVMSpvVaultContract.ts +72 -0
- package/src/evm/spv_swap/EVMSpvWithdrawalData.ts +12 -0
- package/src/evm/swaps/EVMSwapContract.ts +117 -33
- package/src/evm/swaps/EVMSwapData.ts +90 -0
- package/src/evm/wallet/EVMBrowserSigner.ts +2 -2
- package/src/evm/wallet/EVMSigner.ts +3 -0
|
@@ -161,19 +161,31 @@ export class EVMSwapData extends SwapData {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
/**
|
|
165
|
+
* @inheritDoc
|
|
166
|
+
*/
|
|
164
167
|
getOfferer(): string {
|
|
165
168
|
return this.offerer;
|
|
166
169
|
}
|
|
167
170
|
|
|
171
|
+
/**
|
|
172
|
+
* @inheritDoc
|
|
173
|
+
*/
|
|
168
174
|
setOfferer(newOfferer: string) {
|
|
169
175
|
this.offerer = newOfferer;
|
|
170
176
|
this.payIn = true;
|
|
171
177
|
}
|
|
172
178
|
|
|
179
|
+
/**
|
|
180
|
+
* @inheritDoc
|
|
181
|
+
*/
|
|
173
182
|
getClaimer(): string {
|
|
174
183
|
return this.claimer;
|
|
175
184
|
}
|
|
176
185
|
|
|
186
|
+
/**
|
|
187
|
+
* @inheritDoc
|
|
188
|
+
*/
|
|
177
189
|
setClaimer(newClaimer: string) {
|
|
178
190
|
this.claimer = newClaimer;
|
|
179
191
|
this.payIn = false;
|
|
@@ -181,6 +193,9 @@ export class EVMSwapData extends SwapData {
|
|
|
181
193
|
this.reputation = false;
|
|
182
194
|
}
|
|
183
195
|
|
|
196
|
+
/**
|
|
197
|
+
* @inheritDoc
|
|
198
|
+
*/
|
|
184
199
|
serialize(): any {
|
|
185
200
|
return {
|
|
186
201
|
type: "evm",
|
|
@@ -205,38 +220,65 @@ export class EVMSwapData extends SwapData {
|
|
|
205
220
|
}
|
|
206
221
|
}
|
|
207
222
|
|
|
223
|
+
/**
|
|
224
|
+
* @inheritDoc
|
|
225
|
+
*/
|
|
208
226
|
getAmount(): bigint {
|
|
209
227
|
return this.amount;
|
|
210
228
|
}
|
|
211
229
|
|
|
230
|
+
/**
|
|
231
|
+
* @inheritDoc
|
|
232
|
+
*/
|
|
212
233
|
getToken(): string {
|
|
213
234
|
return this.token;
|
|
214
235
|
}
|
|
215
236
|
|
|
237
|
+
/**
|
|
238
|
+
* @inheritDoc
|
|
239
|
+
*/
|
|
216
240
|
isToken(token: string): boolean {
|
|
217
241
|
return this.token.toLowerCase()===token.toLowerCase();
|
|
218
242
|
}
|
|
219
243
|
|
|
244
|
+
/**
|
|
245
|
+
* @inheritDoc
|
|
246
|
+
*/
|
|
220
247
|
getType(): ChainSwapType {
|
|
221
248
|
return this.kind;
|
|
222
249
|
}
|
|
223
250
|
|
|
251
|
+
/**
|
|
252
|
+
* @inheritDoc
|
|
253
|
+
*/
|
|
224
254
|
getExpiry(): bigint {
|
|
225
255
|
return TimelockRefundHandler.getExpiry(this);
|
|
226
256
|
}
|
|
227
257
|
|
|
258
|
+
/**
|
|
259
|
+
* @inheritDoc
|
|
260
|
+
*/
|
|
228
261
|
isPayIn(): boolean {
|
|
229
262
|
return this.payIn;
|
|
230
263
|
}
|
|
231
264
|
|
|
265
|
+
/**
|
|
266
|
+
* @inheritDoc
|
|
267
|
+
*/
|
|
232
268
|
isPayOut(): boolean {
|
|
233
269
|
return this.payOut;
|
|
234
270
|
}
|
|
235
271
|
|
|
272
|
+
/**
|
|
273
|
+
* @inheritDoc
|
|
274
|
+
*/
|
|
236
275
|
isTrackingReputation(): boolean {
|
|
237
276
|
return this.reputation;
|
|
238
277
|
}
|
|
239
278
|
|
|
279
|
+
/**
|
|
280
|
+
* @inheritDoc
|
|
281
|
+
*/
|
|
240
282
|
getEscrowHash(): string {
|
|
241
283
|
const encoded = AbiCoder.defaultAbiCoder().encode(
|
|
242
284
|
["address", "address", "uint256", "address", "uint256", "address", "bytes32", "address", "bytes32", "uint256", "uint256", "address", "bytes32"],
|
|
@@ -250,68 +292,110 @@ export class EVMSwapData extends SwapData {
|
|
|
250
292
|
return escrowHash.slice(2); //Strip `0x`
|
|
251
293
|
}
|
|
252
294
|
|
|
295
|
+
/**
|
|
296
|
+
* @inheritDoc
|
|
297
|
+
*/
|
|
253
298
|
getClaimHash(): string {
|
|
254
299
|
let hash = this.claimData;
|
|
255
300
|
if(hash.startsWith("0x")) hash = hash.slice(2);
|
|
256
301
|
return hash;
|
|
257
302
|
}
|
|
258
303
|
|
|
304
|
+
/**
|
|
305
|
+
* @inheritDoc
|
|
306
|
+
*/
|
|
259
307
|
getSequence(): bigint {
|
|
260
308
|
return this.sequence;
|
|
261
309
|
}
|
|
262
310
|
|
|
311
|
+
/**
|
|
312
|
+
* @inheritDoc
|
|
313
|
+
*/
|
|
263
314
|
getConfirmationsHint(): number | null {
|
|
264
315
|
if(this.extraData==null) return null;
|
|
265
316
|
if(this.extraData.length!=84) return null;
|
|
266
317
|
return parseInt(this.extraData.slice(80), 16);
|
|
267
318
|
}
|
|
268
319
|
|
|
320
|
+
/**
|
|
321
|
+
* @inheritDoc
|
|
322
|
+
*/
|
|
269
323
|
getNonceHint(): bigint | null {
|
|
270
324
|
if(this.extraData==null) return null;
|
|
271
325
|
if(this.extraData.length!=84) return null;
|
|
272
326
|
return BigInt("0x"+this.extraData.slice(64, 80));
|
|
273
327
|
}
|
|
274
328
|
|
|
329
|
+
/**
|
|
330
|
+
* @inheritDoc
|
|
331
|
+
*/
|
|
275
332
|
getTxoHashHint(): string | null {
|
|
276
333
|
if(this.extraData==null) return null;
|
|
277
334
|
if(this.extraData.length!=84) return null;
|
|
278
335
|
return this.extraData.slice(0, 64);
|
|
279
336
|
}
|
|
280
337
|
|
|
338
|
+
/**
|
|
339
|
+
* @inheritDoc
|
|
340
|
+
*/
|
|
281
341
|
getExtraData(): string | null {
|
|
282
342
|
return this.extraData ?? null;
|
|
283
343
|
}
|
|
284
344
|
|
|
345
|
+
/**
|
|
346
|
+
* @inheritDoc
|
|
347
|
+
*/
|
|
285
348
|
setExtraData(extraData: string): void {
|
|
286
349
|
this.extraData = extraData;
|
|
287
350
|
}
|
|
288
351
|
|
|
352
|
+
/**
|
|
353
|
+
* @inheritDoc
|
|
354
|
+
*/
|
|
289
355
|
getSecurityDeposit() {
|
|
290
356
|
return this.securityDeposit;
|
|
291
357
|
}
|
|
292
358
|
|
|
359
|
+
/**
|
|
360
|
+
* @inheritDoc
|
|
361
|
+
*/
|
|
293
362
|
getClaimerBounty() {
|
|
294
363
|
return this.claimerBounty;
|
|
295
364
|
}
|
|
296
365
|
|
|
366
|
+
/**
|
|
367
|
+
* @inheritDoc
|
|
368
|
+
*/
|
|
297
369
|
getTotalDeposit() {
|
|
298
370
|
return this.claimerBounty < this.securityDeposit ? this.securityDeposit : this.claimerBounty;
|
|
299
371
|
}
|
|
300
372
|
|
|
373
|
+
/**
|
|
374
|
+
* @inheritDoc
|
|
375
|
+
*/
|
|
301
376
|
getDepositToken() {
|
|
302
377
|
return this.depositToken;
|
|
303
378
|
}
|
|
304
379
|
|
|
380
|
+
/**
|
|
381
|
+
* @inheritDoc
|
|
382
|
+
*/
|
|
305
383
|
isDepositToken(token: string): boolean {
|
|
306
384
|
if(!token.startsWith("0x")) token = "0x"+token;
|
|
307
385
|
return this.depositToken.toLowerCase() === token.toLowerCase();
|
|
308
386
|
}
|
|
309
387
|
|
|
388
|
+
/**
|
|
389
|
+
* @inheritDoc
|
|
390
|
+
*/
|
|
310
391
|
isClaimer(address: string) {
|
|
311
392
|
if(!address.startsWith("0x")) address = "0x"+address;
|
|
312
393
|
return this.claimer.toLowerCase() === address.toLowerCase();
|
|
313
394
|
}
|
|
314
395
|
|
|
396
|
+
/**
|
|
397
|
+
* @inheritDoc
|
|
398
|
+
*/
|
|
315
399
|
isOfferer(address: string) {
|
|
316
400
|
if(!address.startsWith("0x")) address = "0x"+address;
|
|
317
401
|
return this.offerer.toLowerCase() === address.toLowerCase();
|
|
@@ -332,6 +416,9 @@ export class EVMSwapData extends SwapData {
|
|
|
332
416
|
return (this.claimData.startsWith("0x") ? this.claimData : "0x"+this.claimData) === data;
|
|
333
417
|
}
|
|
334
418
|
|
|
419
|
+
/**
|
|
420
|
+
* @inheritDoc
|
|
421
|
+
*/
|
|
335
422
|
equals(other: EVMSwapData): boolean {
|
|
336
423
|
return other.offerer.toLowerCase()===this.offerer.toLowerCase() &&
|
|
337
424
|
other.claimer.toLowerCase()===this.claimer.toLowerCase() &&
|
|
@@ -368,6 +455,9 @@ export class EVMSwapData extends SwapData {
|
|
|
368
455
|
}
|
|
369
456
|
}
|
|
370
457
|
|
|
458
|
+
/**
|
|
459
|
+
* @inheritDoc
|
|
460
|
+
*/
|
|
371
461
|
hasSuccessAction(): boolean {
|
|
372
462
|
return this.successActionCommitment !== ZeroHash;
|
|
373
463
|
}
|
|
@@ -17,8 +17,8 @@ export class EVMBrowserSigner extends EVMSigner {
|
|
|
17
17
|
try {
|
|
18
18
|
return await super.sendTransaction(transaction, onBeforePublish);
|
|
19
19
|
} catch (e: any) {
|
|
20
|
-
if(e
|
|
21
|
-
|
|
20
|
+
if(e?.message?.includes("ACTION_REJECTED") || e?.message?.includes("User rejected"))
|
|
21
|
+
e.message = "User refused to sign the transaction";
|
|
22
22
|
throw e;
|
|
23
23
|
}
|
|
24
24
|
}
|