@atomiqlabs/chain-evm 1.0.0-dev.33 → 1.0.0-dev.35
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.
|
@@ -25,8 +25,9 @@ export declare class EVMSwapData extends SwapData {
|
|
|
25
25
|
securityDeposit: bigint;
|
|
26
26
|
claimerBounty: bigint;
|
|
27
27
|
extraData: string;
|
|
28
|
+
successActionCommitment: string;
|
|
28
29
|
kind: ChainSwapType;
|
|
29
|
-
constructor(offerer: string, claimer: string, token: string, refundHandler: string, claimHandler: string, payOut: boolean, payIn: boolean, reputation: boolean, sequence: bigint, claimData: string, refundData: string, amount: bigint, depositToken: string, securityDeposit: bigint, claimerBounty: bigint, kind: ChainSwapType, extraData: string);
|
|
30
|
+
constructor(offerer: string, claimer: string, token: string, refundHandler: string, claimHandler: string, payOut: boolean, payIn: boolean, reputation: boolean, sequence: bigint, claimData: string, refundData: string, amount: bigint, depositToken: string, securityDeposit: bigint, claimerBounty: bigint, kind: ChainSwapType, extraData: string, successActionCommitment?: string);
|
|
30
31
|
constructor(data: any);
|
|
31
32
|
getOfferer(): string;
|
|
32
33
|
setOfferer(newOfferer: string): void;
|
|
@@ -60,5 +61,6 @@ export declare class EVMSwapData extends SwapData {
|
|
|
60
61
|
isClaimData(data: string): boolean;
|
|
61
62
|
equals(other: EVMSwapData): boolean;
|
|
62
63
|
toEscrowStruct(): EscrowDataStruct;
|
|
64
|
+
hasSuccessAction(): boolean;
|
|
63
65
|
static deserializeFromStruct(struct: EscrowDataStruct, claimHandlerImpl: IClaimHandler<any, any>): EVMSwapData;
|
|
64
66
|
}
|
|
@@ -22,7 +22,7 @@ class EVMSwapData extends base_1.SwapData {
|
|
|
22
22
|
(this.payIn ? FLAG_PAY_IN : 0n) +
|
|
23
23
|
(this.reputation ? FLAG_REPUTATION : 0n);
|
|
24
24
|
}
|
|
25
|
-
constructor(offererOrData, claimer, token, refundHandler, claimHandler, payOut, payIn, reputation, sequence, claimData, refundData, amount, depositToken, securityDeposit, claimerBounty, kind, extraData) {
|
|
25
|
+
constructor(offererOrData, claimer, token, refundHandler, claimHandler, payOut, payIn, reputation, sequence, claimData, refundData, amount, depositToken, securityDeposit, claimerBounty, kind, extraData, successActionCommitment) {
|
|
26
26
|
super();
|
|
27
27
|
if (claimer != null || token != null || refundHandler != null || claimHandler != null ||
|
|
28
28
|
payOut != null || payIn != null || reputation != null || sequence != null || claimData != null || refundData != null ||
|
|
@@ -44,6 +44,7 @@ class EVMSwapData extends base_1.SwapData {
|
|
|
44
44
|
this.claimerBounty = claimerBounty;
|
|
45
45
|
this.kind = kind;
|
|
46
46
|
this.extraData = extraData;
|
|
47
|
+
this.successActionCommitment = successActionCommitment ?? ethers_1.ZeroHash;
|
|
47
48
|
}
|
|
48
49
|
else {
|
|
49
50
|
this.offerer = offererOrData.offerer;
|
|
@@ -63,6 +64,7 @@ class EVMSwapData extends base_1.SwapData {
|
|
|
63
64
|
this.claimerBounty = offererOrData.claimerBounty == null ? null : BigInt(offererOrData.claimerBounty);
|
|
64
65
|
this.kind = offererOrData.kind;
|
|
65
66
|
this.extraData = offererOrData.extraData;
|
|
67
|
+
this.successActionCommitment = offererOrData.successActionCommitment ?? ethers_1.ZeroHash;
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
getOfferer() {
|
|
@@ -100,7 +102,8 @@ class EVMSwapData extends base_1.SwapData {
|
|
|
100
102
|
securityDeposit: this.securityDeposit == null ? null : this.securityDeposit.toString(10),
|
|
101
103
|
claimerBounty: this.claimerBounty == null ? null : this.claimerBounty.toString(10),
|
|
102
104
|
kind: this.kind,
|
|
103
|
-
extraData: this.extraData
|
|
105
|
+
extraData: this.extraData,
|
|
106
|
+
successActionCommitment: this.successActionCommitment
|
|
104
107
|
};
|
|
105
108
|
}
|
|
106
109
|
getAmount() {
|
|
@@ -128,7 +131,7 @@ class EVMSwapData extends base_1.SwapData {
|
|
|
128
131
|
const encoded = ethers_1.AbiCoder.defaultAbiCoder().encode(["address", "address", "uint256", "address", "uint256", "address", "bytes32", "address", "bytes32", "uint256", "uint256", "address", "bytes32"], [
|
|
129
132
|
this.offerer, this.claimer, this.amount, this.token, this.getFlags(),
|
|
130
133
|
this.claimHandler, this.claimData, this.refundHandler, this.refundData,
|
|
131
|
-
this.securityDeposit, this.claimerBounty, this.depositToken,
|
|
134
|
+
this.securityDeposit, this.claimerBounty, this.depositToken, this.successActionCommitment
|
|
132
135
|
]);
|
|
133
136
|
let escrowHash = (0, ethers_1.keccak256)(encoded);
|
|
134
137
|
return escrowHash.slice(2); //Strip `0x`
|
|
@@ -220,12 +223,13 @@ class EVMSwapData extends base_1.SwapData {
|
|
|
220
223
|
other.payIn === this.payIn &&
|
|
221
224
|
other.payOut === this.payOut &&
|
|
222
225
|
other.reputation === this.reputation &&
|
|
223
|
-
|
|
226
|
+
other.sequence === this.sequence &&
|
|
224
227
|
other.claimData.toLowerCase() === this.claimData.toLowerCase() &&
|
|
225
228
|
other.refundData.toLowerCase() === this.refundData.toLowerCase() &&
|
|
226
229
|
other.amount === this.amount &&
|
|
227
230
|
other.securityDeposit === this.securityDeposit &&
|
|
228
|
-
other.claimerBounty === this.claimerBounty
|
|
231
|
+
other.claimerBounty === this.claimerBounty &&
|
|
232
|
+
other.successActionCommitment.toLowerCase() === this.successActionCommitment.toLowerCase();
|
|
229
233
|
}
|
|
230
234
|
toEscrowStruct() {
|
|
231
235
|
return {
|
|
@@ -241,13 +245,15 @@ class EVMSwapData extends base_1.SwapData {
|
|
|
241
245
|
depositToken: this.depositToken,
|
|
242
246
|
securityDeposit: this.securityDeposit,
|
|
243
247
|
claimerBounty: this.claimerBounty,
|
|
244
|
-
successActionCommitment:
|
|
248
|
+
successActionCommitment: this.successActionCommitment
|
|
245
249
|
};
|
|
246
250
|
}
|
|
251
|
+
hasSuccessAction() {
|
|
252
|
+
return this.successActionCommitment !== ethers_1.ZeroHash;
|
|
253
|
+
}
|
|
247
254
|
static deserializeFromStruct(struct, claimHandlerImpl) {
|
|
248
255
|
const { payOut, payIn, reputation, sequence } = EVMSwapData.toFlags(BigInt(struct.flags));
|
|
249
|
-
|
|
250
|
-
return new EVMSwapData(struct.offerer, struct.claimer, struct.token, struct.refundHandler, struct.claimHandler, payOut, payIn, reputation, sequence, (0, ethers_1.hexlify)(struct.claimData), (0, ethers_1.hexlify)(struct.refundData), BigInt(struct.amount), struct.depositToken, BigInt(struct.securityDeposit), BigInt(struct.claimerBounty), claimHandlerImpl.getType(), null);
|
|
256
|
+
return new EVMSwapData(struct.offerer, struct.claimer, struct.token, struct.refundHandler, struct.claimHandler, payOut, payIn, reputation, sequence, (0, ethers_1.hexlify)(struct.claimData), (0, ethers_1.hexlify)(struct.refundData), BigInt(struct.amount), struct.depositToken, BigInt(struct.securityDeposit), BigInt(struct.claimerBounty), claimHandlerImpl.getType(), null, struct.successActionCommitment);
|
|
251
257
|
}
|
|
252
258
|
}
|
|
253
259
|
exports.EVMSwapData = EVMSwapData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomiqlabs/chain-evm",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.35",
|
|
4
4
|
"description": "EVM specific base implementation",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types:": "./dist/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"author": "adambor",
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@atomiqlabs/base": "^10.0.0-dev.
|
|
26
|
+
"@atomiqlabs/base": "^10.0.0-dev.8",
|
|
27
27
|
"@noble/hashes": "^1.8.0",
|
|
28
28
|
"@scure/btc-signer": "1.6.0",
|
|
29
29
|
"buffer": "6.0.3"
|
|
@@ -50,6 +50,8 @@ export class EVMSwapData extends SwapData {
|
|
|
50
50
|
|
|
51
51
|
extraData: string;
|
|
52
52
|
|
|
53
|
+
successActionCommitment: string;
|
|
54
|
+
|
|
53
55
|
kind: ChainSwapType;
|
|
54
56
|
|
|
55
57
|
constructor(
|
|
@@ -69,7 +71,8 @@ export class EVMSwapData extends SwapData {
|
|
|
69
71
|
securityDeposit: bigint,
|
|
70
72
|
claimerBounty: bigint,
|
|
71
73
|
kind: ChainSwapType,
|
|
72
|
-
extraData: string
|
|
74
|
+
extraData: string,
|
|
75
|
+
successActionCommitment?: string
|
|
73
76
|
);
|
|
74
77
|
|
|
75
78
|
constructor(data: any);
|
|
@@ -91,7 +94,8 @@ export class EVMSwapData extends SwapData {
|
|
|
91
94
|
securityDeposit?: bigint,
|
|
92
95
|
claimerBounty?: bigint,
|
|
93
96
|
kind?: ChainSwapType,
|
|
94
|
-
extraData?: string
|
|
97
|
+
extraData?: string,
|
|
98
|
+
successActionCommitment?: string
|
|
95
99
|
) {
|
|
96
100
|
super();
|
|
97
101
|
if(claimer!=null || token!=null || refundHandler!=null || claimHandler!=null ||
|
|
@@ -114,6 +118,7 @@ export class EVMSwapData extends SwapData {
|
|
|
114
118
|
this.claimerBounty = claimerBounty;
|
|
115
119
|
this.kind = kind;
|
|
116
120
|
this.extraData = extraData;
|
|
121
|
+
this.successActionCommitment = successActionCommitment ?? ZeroHash;
|
|
117
122
|
} else {
|
|
118
123
|
this.offerer = offererOrData.offerer;
|
|
119
124
|
this.claimer = offererOrData.claimer;
|
|
@@ -132,6 +137,7 @@ export class EVMSwapData extends SwapData {
|
|
|
132
137
|
this.claimerBounty = offererOrData.claimerBounty==null ? null : BigInt(offererOrData.claimerBounty);
|
|
133
138
|
this.kind = offererOrData.kind;
|
|
134
139
|
this.extraData = offererOrData.extraData;
|
|
140
|
+
this.successActionCommitment = offererOrData.successActionCommitment ?? ZeroHash;
|
|
135
141
|
}
|
|
136
142
|
}
|
|
137
143
|
|
|
@@ -174,7 +180,8 @@ export class EVMSwapData extends SwapData {
|
|
|
174
180
|
securityDeposit: this.securityDeposit==null ? null : this.securityDeposit.toString(10),
|
|
175
181
|
claimerBounty: this.claimerBounty==null ? null : this.claimerBounty.toString(10),
|
|
176
182
|
kind: this.kind,
|
|
177
|
-
extraData: this.extraData
|
|
183
|
+
extraData: this.extraData,
|
|
184
|
+
successActionCommitment: this.successActionCommitment
|
|
178
185
|
}
|
|
179
186
|
}
|
|
180
187
|
|
|
@@ -212,7 +219,7 @@ export class EVMSwapData extends SwapData {
|
|
|
212
219
|
[
|
|
213
220
|
this.offerer, this.claimer, this.amount, this.token, this.getFlags(),
|
|
214
221
|
this.claimHandler, this.claimData, this.refundHandler, this.refundData,
|
|
215
|
-
this.securityDeposit, this.claimerBounty, this.depositToken,
|
|
222
|
+
this.securityDeposit, this.claimerBounty, this.depositToken, this.successActionCommitment
|
|
216
223
|
]
|
|
217
224
|
)
|
|
218
225
|
let escrowHash = keccak256(encoded);
|
|
@@ -310,12 +317,13 @@ export class EVMSwapData extends SwapData {
|
|
|
310
317
|
other.payIn===this.payIn &&
|
|
311
318
|
other.payOut===this.payOut &&
|
|
312
319
|
other.reputation===this.reputation &&
|
|
313
|
-
|
|
320
|
+
other.sequence === this.sequence &&
|
|
314
321
|
other.claimData.toLowerCase()===this.claimData.toLowerCase() &&
|
|
315
322
|
other.refundData.toLowerCase()===this.refundData.toLowerCase() &&
|
|
316
323
|
other.amount === this.amount &&
|
|
317
324
|
other.securityDeposit === this.securityDeposit &&
|
|
318
|
-
other.claimerBounty === this.claimerBounty
|
|
325
|
+
other.claimerBounty === this.claimerBounty &&
|
|
326
|
+
other.successActionCommitment.toLowerCase() === this.successActionCommitment.toLowerCase()
|
|
319
327
|
}
|
|
320
328
|
|
|
321
329
|
toEscrowStruct(): EscrowDataStruct {
|
|
@@ -332,15 +340,17 @@ export class EVMSwapData extends SwapData {
|
|
|
332
340
|
depositToken: this.depositToken,
|
|
333
341
|
securityDeposit: this.securityDeposit,
|
|
334
342
|
claimerBounty: this.claimerBounty,
|
|
335
|
-
successActionCommitment:
|
|
343
|
+
successActionCommitment: this.successActionCommitment
|
|
336
344
|
}
|
|
337
345
|
}
|
|
338
346
|
|
|
347
|
+
hasSuccessAction(): boolean {
|
|
348
|
+
return this.successActionCommitment !== ZeroHash;
|
|
349
|
+
}
|
|
350
|
+
|
|
339
351
|
static deserializeFromStruct(struct: EscrowDataStruct, claimHandlerImpl: IClaimHandler<any, any>): EVMSwapData {
|
|
340
352
|
const {payOut, payIn, reputation, sequence} = EVMSwapData.toFlags(BigInt(struct.flags));
|
|
341
353
|
|
|
342
|
-
// if(struct.successActionCommitment !== ZeroHash) throw new Error("Success action not allowed!");
|
|
343
|
-
|
|
344
354
|
return new EVMSwapData(
|
|
345
355
|
struct.offerer as string,
|
|
346
356
|
struct.claimer as string,
|
|
@@ -358,7 +368,8 @@ export class EVMSwapData extends SwapData {
|
|
|
358
368
|
BigInt(struct.securityDeposit),
|
|
359
369
|
BigInt(struct.claimerBounty),
|
|
360
370
|
claimHandlerImpl.getType(),
|
|
361
|
-
null
|
|
371
|
+
null,
|
|
372
|
+
struct.successActionCommitment as string
|
|
362
373
|
);
|
|
363
374
|
}
|
|
364
375
|
|