@atomiqlabs/chain-evm 1.0.0-dev.32 → 1.0.0-dev.34
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`
|
|
@@ -241,13 +244,15 @@ class EVMSwapData extends base_1.SwapData {
|
|
|
241
244
|
depositToken: this.depositToken,
|
|
242
245
|
securityDeposit: this.securityDeposit,
|
|
243
246
|
claimerBounty: this.claimerBounty,
|
|
244
|
-
successActionCommitment:
|
|
247
|
+
successActionCommitment: this.successActionCommitment
|
|
245
248
|
};
|
|
246
249
|
}
|
|
250
|
+
hasSuccessAction() {
|
|
251
|
+
return this.successActionCommitment !== ethers_1.ZeroHash;
|
|
252
|
+
}
|
|
247
253
|
static deserializeFromStruct(struct, claimHandlerImpl) {
|
|
248
254
|
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);
|
|
255
|
+
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
256
|
}
|
|
252
257
|
}
|
|
253
258
|
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.34",
|
|
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);
|
|
@@ -332,15 +339,17 @@ export class EVMSwapData extends SwapData {
|
|
|
332
339
|
depositToken: this.depositToken,
|
|
333
340
|
securityDeposit: this.securityDeposit,
|
|
334
341
|
claimerBounty: this.claimerBounty,
|
|
335
|
-
successActionCommitment:
|
|
342
|
+
successActionCommitment: this.successActionCommitment
|
|
336
343
|
}
|
|
337
344
|
}
|
|
338
345
|
|
|
346
|
+
hasSuccessAction(): boolean {
|
|
347
|
+
return this.successActionCommitment !== ZeroHash;
|
|
348
|
+
}
|
|
349
|
+
|
|
339
350
|
static deserializeFromStruct(struct: EscrowDataStruct, claimHandlerImpl: IClaimHandler<any, any>): EVMSwapData {
|
|
340
351
|
const {payOut, payIn, reputation, sequence} = EVMSwapData.toFlags(BigInt(struct.flags));
|
|
341
352
|
|
|
342
|
-
if(struct.successActionCommitment !== ZeroHash) // throw new Error("Success action not allowed!");
|
|
343
|
-
|
|
344
353
|
return new EVMSwapData(
|
|
345
354
|
struct.offerer as string,
|
|
346
355
|
struct.claimer as string,
|
|
@@ -358,7 +367,8 @@ export class EVMSwapData extends SwapData {
|
|
|
358
367
|
BigInt(struct.securityDeposit),
|
|
359
368
|
BigInt(struct.claimerBounty),
|
|
360
369
|
claimHandlerImpl.getType(),
|
|
361
|
-
null
|
|
370
|
+
null,
|
|
371
|
+
struct.successActionCommitment as string
|
|
362
372
|
);
|
|
363
373
|
}
|
|
364
374
|
|