@atomiqlabs/chain-evm 1.0.0-dev.22

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.
Files changed (146) hide show
  1. package/LICENSE +201 -0
  2. package/dist/chains/citrea/CitreaChainType.d.ts +13 -0
  3. package/dist/chains/citrea/CitreaChainType.js +2 -0
  4. package/dist/chains/citrea/CitreaInitializer.d.ts +30 -0
  5. package/dist/chains/citrea/CitreaInitializer.js +120 -0
  6. package/dist/evm/btcrelay/BtcRelayAbi.d.ts +198 -0
  7. package/dist/evm/btcrelay/BtcRelayAbi.js +261 -0
  8. package/dist/evm/btcrelay/BtcRelayTypechain.d.ts +172 -0
  9. package/dist/evm/btcrelay/BtcRelayTypechain.js +2 -0
  10. package/dist/evm/btcrelay/EVMBtcRelay.d.ts +188 -0
  11. package/dist/evm/btcrelay/EVMBtcRelay.js +419 -0
  12. package/dist/evm/btcrelay/headers/EVMBtcHeader.d.ts +33 -0
  13. package/dist/evm/btcrelay/headers/EVMBtcHeader.js +84 -0
  14. package/dist/evm/btcrelay/headers/EVMBtcStoredHeader.d.ts +56 -0
  15. package/dist/evm/btcrelay/headers/EVMBtcStoredHeader.js +123 -0
  16. package/dist/evm/chain/EVMChainInterface.d.ts +51 -0
  17. package/dist/evm/chain/EVMChainInterface.js +90 -0
  18. package/dist/evm/chain/EVMModule.d.ts +9 -0
  19. package/dist/evm/chain/EVMModule.js +13 -0
  20. package/dist/evm/chain/modules/ERC20Abi.d.ts +168 -0
  21. package/dist/evm/chain/modules/ERC20Abi.js +225 -0
  22. package/dist/evm/chain/modules/EVMAddresses.d.ts +9 -0
  23. package/dist/evm/chain/modules/EVMAddresses.js +26 -0
  24. package/dist/evm/chain/modules/EVMBlocks.d.ts +20 -0
  25. package/dist/evm/chain/modules/EVMBlocks.js +64 -0
  26. package/dist/evm/chain/modules/EVMEvents.d.ts +36 -0
  27. package/dist/evm/chain/modules/EVMEvents.js +122 -0
  28. package/dist/evm/chain/modules/EVMFees.d.ts +35 -0
  29. package/dist/evm/chain/modules/EVMFees.js +73 -0
  30. package/dist/evm/chain/modules/EVMSignatures.d.ts +29 -0
  31. package/dist/evm/chain/modules/EVMSignatures.js +68 -0
  32. package/dist/evm/chain/modules/EVMTokens.d.ts +49 -0
  33. package/dist/evm/chain/modules/EVMTokens.js +105 -0
  34. package/dist/evm/chain/modules/EVMTransactions.d.ts +89 -0
  35. package/dist/evm/chain/modules/EVMTransactions.js +216 -0
  36. package/dist/evm/contract/EVMContractBase.d.ts +22 -0
  37. package/dist/evm/contract/EVMContractBase.js +34 -0
  38. package/dist/evm/contract/EVMContractModule.d.ts +8 -0
  39. package/dist/evm/contract/EVMContractModule.js +11 -0
  40. package/dist/evm/contract/modules/EVMContractEvents.d.ts +42 -0
  41. package/dist/evm/contract/modules/EVMContractEvents.js +75 -0
  42. package/dist/evm/events/EVMChainEvents.d.ts +22 -0
  43. package/dist/evm/events/EVMChainEvents.js +67 -0
  44. package/dist/evm/events/EVMChainEventsBrowser.d.ts +86 -0
  45. package/dist/evm/events/EVMChainEventsBrowser.js +294 -0
  46. package/dist/evm/spv_swap/EVMSpvVaultContract.d.ts +64 -0
  47. package/dist/evm/spv_swap/EVMSpvVaultContract.js +410 -0
  48. package/dist/evm/spv_swap/EVMSpvVaultData.d.ts +38 -0
  49. package/dist/evm/spv_swap/EVMSpvVaultData.js +159 -0
  50. package/dist/evm/spv_swap/EVMSpvWithdrawalData.d.ts +19 -0
  51. package/dist/evm/spv_swap/EVMSpvWithdrawalData.js +55 -0
  52. package/dist/evm/spv_swap/SpvVaultContractAbi.d.ts +91 -0
  53. package/dist/evm/spv_swap/SpvVaultContractAbi.js +849 -0
  54. package/dist/evm/spv_swap/SpvVaultContractTypechain.d.ts +450 -0
  55. package/dist/evm/spv_swap/SpvVaultContractTypechain.js +2 -0
  56. package/dist/evm/swaps/EVMSwapContract.d.ts +192 -0
  57. package/dist/evm/swaps/EVMSwapContract.js +373 -0
  58. package/dist/evm/swaps/EVMSwapData.d.ts +64 -0
  59. package/dist/evm/swaps/EVMSwapData.js +254 -0
  60. package/dist/evm/swaps/EVMSwapModule.d.ts +9 -0
  61. package/dist/evm/swaps/EVMSwapModule.js +11 -0
  62. package/dist/evm/swaps/EscrowManagerAbi.d.ts +120 -0
  63. package/dist/evm/swaps/EscrowManagerAbi.js +985 -0
  64. package/dist/evm/swaps/EscrowManagerTypechain.d.ts +475 -0
  65. package/dist/evm/swaps/EscrowManagerTypechain.js +2 -0
  66. package/dist/evm/swaps/handlers/IHandler.d.ts +13 -0
  67. package/dist/evm/swaps/handlers/IHandler.js +2 -0
  68. package/dist/evm/swaps/handlers/claim/ClaimHandlers.d.ts +10 -0
  69. package/dist/evm/swaps/handlers/claim/ClaimHandlers.js +13 -0
  70. package/dist/evm/swaps/handlers/claim/HashlockClaimHandler.d.ts +20 -0
  71. package/dist/evm/swaps/handlers/claim/HashlockClaimHandler.js +39 -0
  72. package/dist/evm/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.d.ts +24 -0
  73. package/dist/evm/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.js +59 -0
  74. package/dist/evm/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.d.ts +25 -0
  75. package/dist/evm/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.js +51 -0
  76. package/dist/evm/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.d.ts +21 -0
  77. package/dist/evm/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.js +28 -0
  78. package/dist/evm/swaps/handlers/claim/btc/IBitcoinClaimHandler.d.ts +48 -0
  79. package/dist/evm/swaps/handlers/claim/btc/IBitcoinClaimHandler.js +63 -0
  80. package/dist/evm/swaps/handlers/refund/TimelockRefundHandler.d.ts +17 -0
  81. package/dist/evm/swaps/handlers/refund/TimelockRefundHandler.js +28 -0
  82. package/dist/evm/swaps/modules/EVMLpVault.d.ts +69 -0
  83. package/dist/evm/swaps/modules/EVMLpVault.js +131 -0
  84. package/dist/evm/swaps/modules/EVMSwapClaim.d.ts +53 -0
  85. package/dist/evm/swaps/modules/EVMSwapClaim.js +101 -0
  86. package/dist/evm/swaps/modules/EVMSwapInit.d.ts +88 -0
  87. package/dist/evm/swaps/modules/EVMSwapInit.js +241 -0
  88. package/dist/evm/swaps/modules/EVMSwapRefund.d.ts +62 -0
  89. package/dist/evm/swaps/modules/EVMSwapRefund.js +132 -0
  90. package/dist/evm/typechain/common.d.ts +50 -0
  91. package/dist/evm/typechain/common.js +2 -0
  92. package/dist/evm/wallet/EVMSigner.d.ts +9 -0
  93. package/dist/evm/wallet/EVMSigner.js +16 -0
  94. package/dist/index.d.ts +37 -0
  95. package/dist/index.js +53 -0
  96. package/dist/utils/Utils.d.ts +15 -0
  97. package/dist/utils/Utils.js +71 -0
  98. package/package.json +37 -0
  99. package/src/chains/citrea/CitreaChainType.ts +28 -0
  100. package/src/chains/citrea/CitreaInitializer.ts +167 -0
  101. package/src/evm/btcrelay/BtcRelayAbi.ts +258 -0
  102. package/src/evm/btcrelay/BtcRelayTypechain.ts +371 -0
  103. package/src/evm/btcrelay/EVMBtcRelay.ts +517 -0
  104. package/src/evm/btcrelay/headers/EVMBtcHeader.ts +110 -0
  105. package/src/evm/btcrelay/headers/EVMBtcStoredHeader.ts +153 -0
  106. package/src/evm/chain/EVMChainInterface.ts +157 -0
  107. package/src/evm/chain/EVMModule.ts +21 -0
  108. package/src/evm/chain/modules/ERC20Abi.ts +222 -0
  109. package/src/evm/chain/modules/EVMAddresses.ts +24 -0
  110. package/src/evm/chain/modules/EVMBlocks.ts +75 -0
  111. package/src/evm/chain/modules/EVMEvents.ts +139 -0
  112. package/src/evm/chain/modules/EVMFees.ts +105 -0
  113. package/src/evm/chain/modules/EVMSignatures.ts +76 -0
  114. package/src/evm/chain/modules/EVMTokens.ts +115 -0
  115. package/src/evm/chain/modules/EVMTransactions.ts +246 -0
  116. package/src/evm/contract/EVMContractBase.ts +63 -0
  117. package/src/evm/contract/EVMContractModule.ts +16 -0
  118. package/src/evm/contract/modules/EVMContractEvents.ts +102 -0
  119. package/src/evm/events/EVMChainEvents.ts +81 -0
  120. package/src/evm/events/EVMChainEventsBrowser.ts +390 -0
  121. package/src/evm/spv_swap/EVMSpvVaultContract.ts +533 -0
  122. package/src/evm/spv_swap/EVMSpvVaultData.ts +201 -0
  123. package/src/evm/spv_swap/EVMSpvWithdrawalData.ts +70 -0
  124. package/src/evm/spv_swap/SpvVaultContractAbi.ts +846 -0
  125. package/src/evm/spv_swap/SpvVaultContractTypechain.ts +685 -0
  126. package/src/evm/swaps/EVMSwapContract.ts +590 -0
  127. package/src/evm/swaps/EVMSwapData.ts +367 -0
  128. package/src/evm/swaps/EVMSwapModule.ts +16 -0
  129. package/src/evm/swaps/EscrowManagerAbi.ts +982 -0
  130. package/src/evm/swaps/EscrowManagerTypechain.ts +723 -0
  131. package/src/evm/swaps/handlers/IHandler.ts +17 -0
  132. package/src/evm/swaps/handlers/claim/ClaimHandlers.ts +20 -0
  133. package/src/evm/swaps/handlers/claim/HashlockClaimHandler.ts +47 -0
  134. package/src/evm/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.ts +82 -0
  135. package/src/evm/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.ts +76 -0
  136. package/src/evm/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.ts +46 -0
  137. package/src/evm/swaps/handlers/claim/btc/IBitcoinClaimHandler.ts +115 -0
  138. package/src/evm/swaps/handlers/refund/TimelockRefundHandler.ts +38 -0
  139. package/src/evm/swaps/modules/EVMLpVault.ts +153 -0
  140. package/src/evm/swaps/modules/EVMSwapClaim.ts +141 -0
  141. package/src/evm/swaps/modules/EVMSwapInit.ts +292 -0
  142. package/src/evm/swaps/modules/EVMSwapRefund.ts +198 -0
  143. package/src/evm/typechain/common.ts +131 -0
  144. package/src/evm/wallet/EVMSigner.ts +23 -0
  145. package/src/index.ts +44 -0
  146. package/src/utils/Utils.ts +81 -0
@@ -0,0 +1,367 @@
1
+ import {SwapData, ChainSwapType} from "@atomiqlabs/base";
2
+ import {AbiCoder, hexlify, keccak256, ZeroHash} from "ethers";
3
+ import {EscrowDataStruct, EscrowDataStructOutput} from "./EscrowManagerTypechain";
4
+ import {IClaimHandler} from "./handlers/claim/ClaimHandlers";
5
+ import {TimelockRefundHandler} from "./handlers/refund/TimelockRefundHandler";
6
+
7
+ const FLAG_PAY_OUT: bigint = 0x01n;
8
+ const FLAG_PAY_IN: bigint = 0x02n;
9
+ const FLAG_REPUTATION: bigint = 0x04n;
10
+
11
+ export class EVMSwapData extends SwapData {
12
+
13
+ static toFlags(val: bigint): {payOut: boolean, payIn: boolean, reputation: boolean, sequence: bigint} {
14
+ return {
15
+ sequence: val >> 64n,
16
+ payOut: (val & FLAG_PAY_OUT) === FLAG_PAY_OUT,
17
+ payIn: (val & FLAG_PAY_IN) === FLAG_PAY_IN,
18
+ reputation: (val & FLAG_REPUTATION) === FLAG_REPUTATION
19
+ }
20
+ }
21
+
22
+ private getFlags(): bigint {
23
+ return (this.sequence << 64n) +
24
+ (this.payOut ? FLAG_PAY_OUT : 0n) +
25
+ (this.payIn ? FLAG_PAY_IN : 0n) +
26
+ (this.reputation ? FLAG_REPUTATION : 0n);
27
+ }
28
+
29
+ offerer: string;
30
+ claimer: string;
31
+ token: string;
32
+
33
+ refundHandler: string;
34
+ claimHandler: string;
35
+
36
+ //Flags
37
+ payOut: boolean;
38
+ payIn: boolean;
39
+ reputation: boolean;
40
+ sequence: bigint;
41
+
42
+ claimData: string;
43
+ refundData: string;
44
+
45
+ amount: bigint;
46
+
47
+ depositToken: string;
48
+ securityDeposit: bigint;
49
+ claimerBounty: bigint;
50
+
51
+ extraData: string;
52
+
53
+ kind: ChainSwapType;
54
+
55
+ constructor(
56
+ offerer: string,
57
+ claimer: string,
58
+ token: string,
59
+ refundHandler: string,
60
+ claimHandler: string,
61
+ payOut: boolean,
62
+ payIn: boolean,
63
+ reputation: boolean,
64
+ sequence: bigint,
65
+ claimData: string,
66
+ refundData: string,
67
+ amount: bigint,
68
+ depositToken: string,
69
+ securityDeposit: bigint,
70
+ claimerBounty: bigint,
71
+ kind: ChainSwapType,
72
+ extraData: string
73
+ );
74
+
75
+ constructor(data: any);
76
+
77
+ constructor(
78
+ offererOrData: string | any,
79
+ claimer?: string,
80
+ token?: string,
81
+ refundHandler?: string,
82
+ claimHandler?: string,
83
+ payOut?: boolean,
84
+ payIn?: boolean,
85
+ reputation?: boolean,
86
+ sequence?: bigint,
87
+ claimData?: string,
88
+ refundData?: string,
89
+ amount?: bigint,
90
+ depositToken?: string,
91
+ securityDeposit?: bigint,
92
+ claimerBounty?: bigint,
93
+ kind?: ChainSwapType,
94
+ extraData?: string
95
+ ) {
96
+ super();
97
+ if(claimer!=null || token!=null || refundHandler!=null || claimHandler!=null ||
98
+ payOut!=null || payIn!=null || reputation!=null || sequence!=null || claimData!=null || refundData!=null ||
99
+ amount!=null || depositToken!=null || securityDeposit!=null || claimerBounty!=null) {
100
+ this.offerer = offererOrData;
101
+ this.claimer = claimer;
102
+ this.token = token;
103
+ this.refundHandler = refundHandler;
104
+ this.claimHandler = claimHandler;
105
+ this.payOut = payOut;
106
+ this.payIn = payIn;
107
+ this.reputation = reputation;
108
+ this.sequence = sequence;
109
+ this.claimData = claimData;
110
+ this.refundData = refundData;
111
+ this.amount = amount;
112
+ this.depositToken = depositToken;
113
+ this.securityDeposit = securityDeposit;
114
+ this.claimerBounty = claimerBounty;
115
+ this.kind = kind;
116
+ this.extraData = extraData;
117
+ } else {
118
+ this.offerer = offererOrData.offerer;
119
+ this.claimer = offererOrData.claimer;
120
+ this.token = offererOrData.token;
121
+ this.refundHandler = offererOrData.refundHandler;
122
+ this.claimHandler = offererOrData.claimHandler;
123
+ this.payOut = offererOrData.payOut;
124
+ this.payIn = offererOrData.payIn;
125
+ this.reputation = offererOrData.reputation;
126
+ this.sequence = offererOrData.sequence==null ? null : BigInt(offererOrData.sequence);
127
+ this.claimData = offererOrData.claimData;
128
+ this.refundData = offererOrData.refundData;
129
+ this.amount = offererOrData.amount==null ? null : BigInt(offererOrData.amount);
130
+ this.depositToken = offererOrData.depositToken;
131
+ this.securityDeposit = offererOrData.securityDeposit==null ? null : BigInt(offererOrData.securityDeposit);
132
+ this.claimerBounty = offererOrData.claimerBounty==null ? null : BigInt(offererOrData.claimerBounty);
133
+ this.kind = offererOrData.kind;
134
+ this.extraData = offererOrData.extraData;
135
+ }
136
+ }
137
+
138
+ getOfferer(): string {
139
+ return this.offerer;
140
+ }
141
+
142
+ setOfferer(newOfferer: string) {
143
+ this.offerer = newOfferer;
144
+ this.payIn = true;
145
+ }
146
+
147
+ getClaimer(): string {
148
+ return this.claimer;
149
+ }
150
+
151
+ setClaimer(newClaimer: string) {
152
+ this.claimer = newClaimer;
153
+ this.payIn = false;
154
+ this.payOut = true;
155
+ this.reputation = false;
156
+ }
157
+
158
+ serialize(): any {
159
+ return {
160
+ type: "evm",
161
+ offerer: this.offerer,
162
+ claimer: this.claimer,
163
+ token: this.token,
164
+ refundHandler: this.refundHandler,
165
+ claimHandler: this.claimHandler,
166
+ payOut: this.payOut,
167
+ payIn: this.payIn,
168
+ reputation: this.reputation,
169
+ sequence: this.sequence==null ? null : this.sequence.toString(10),
170
+ claimData: this.claimData,
171
+ refundData: this.refundData,
172
+ amount: this.amount==null ? null : this.amount.toString(10),
173
+ depositToken: this.depositToken,
174
+ securityDeposit: this.securityDeposit==null ? null : this.securityDeposit.toString(10),
175
+ claimerBounty: this.claimerBounty==null ? null : this.claimerBounty.toString(10),
176
+ kind: this.kind,
177
+ extraData: this.extraData
178
+ }
179
+ }
180
+
181
+ getAmount(): bigint {
182
+ return this.amount;
183
+ }
184
+
185
+ getToken(): string {
186
+ return this.token;
187
+ }
188
+
189
+ isToken(token: string): boolean {
190
+ return this.token.toLowerCase()===token.toLowerCase();
191
+ }
192
+
193
+ getType(): ChainSwapType {
194
+ return this.kind;
195
+ }
196
+
197
+ getExpiry(): bigint {
198
+ return TimelockRefundHandler.getExpiry(this);
199
+ }
200
+
201
+ isPayIn(): boolean {
202
+ return this.payIn;
203
+ }
204
+
205
+ isPayOut(): boolean {
206
+ return this.payOut;
207
+ }
208
+
209
+ getEscrowHash(): string {
210
+ const encoded = AbiCoder.defaultAbiCoder().encode(
211
+ ["address", "address", "uint256", "address", "uint256", "address", "bytes32", "address", "bytes32", "uint256", "uint256", "address", "bytes32"],
212
+ [
213
+ this.offerer, this.claimer, this.amount, this.token, this.getFlags(),
214
+ this.claimHandler, this.claimData, this.refundHandler, this.refundData,
215
+ this.securityDeposit, this.claimerBounty, this.depositToken, ZeroHash
216
+ ]
217
+ )
218
+ let escrowHash = keccak256(encoded);
219
+ return escrowHash.slice(2); //Strip `0x`
220
+ }
221
+
222
+ getClaimHash(): string {
223
+ let hash = this.claimData;
224
+ if(hash.startsWith("0x")) hash = hash.slice(2);
225
+ return hash;
226
+ }
227
+
228
+ getSequence(): bigint {
229
+ return this.sequence;
230
+ }
231
+
232
+ getConfirmationsHint(): number {
233
+ if(this.extraData==null) return null;
234
+ if(this.extraData.length!=84) return null;
235
+ return parseInt(this.extraData.slice(80), 16);
236
+ }
237
+
238
+ getNonceHint(): bigint {
239
+ if(this.extraData==null) return null;
240
+ if(this.extraData.length!=84) return null;
241
+ return BigInt("0x"+this.extraData.slice(64, 80));
242
+ }
243
+
244
+ getTxoHashHint(): string {
245
+ if(this.extraData==null) return null;
246
+ if(this.extraData.length!=84) return null;
247
+ return this.extraData.slice(0, 64);
248
+ }
249
+
250
+ getExtraData(): string {
251
+ return this.extraData;
252
+ }
253
+
254
+ setExtraData(extraData: string): void {
255
+ this.extraData = extraData;
256
+ }
257
+
258
+ getSecurityDeposit() {
259
+ return this.securityDeposit;
260
+ }
261
+
262
+ getClaimerBounty() {
263
+ return this.claimerBounty;
264
+ }
265
+
266
+ getTotalDeposit() {
267
+ return this.claimerBounty < this.securityDeposit ? this.securityDeposit : this.claimerBounty;
268
+ }
269
+
270
+ getDepositToken() {
271
+ return this.depositToken;
272
+ }
273
+
274
+ isDepositToken(token: string): boolean {
275
+ if(!token.startsWith("0x")) token = "0x"+token;
276
+ return this.depositToken.toLowerCase() === token.toLowerCase();
277
+ }
278
+
279
+ isClaimer(address: string) {
280
+ if(!address.startsWith("0x")) address = "0x"+address;
281
+ return this.claimer.toLowerCase() === address.toLowerCase();
282
+ }
283
+
284
+ isOfferer(address: string) {
285
+ if(!address.startsWith("0x")) address = "0x"+address;
286
+ return this.offerer.toLowerCase() === address.toLowerCase();
287
+ }
288
+
289
+ isRefundHandler(address: string): boolean {
290
+ if(!address.startsWith("0x")) address = "0x"+address;
291
+ return this.refundHandler.toLowerCase() === address.toLowerCase();
292
+ }
293
+
294
+ isClaimHandler(address: string): boolean {
295
+ if(!address.startsWith("0x")) address = "0x"+address;
296
+ return this.claimHandler.toLowerCase() === address.toLowerCase();
297
+ }
298
+
299
+ isClaimData(data: string): boolean {
300
+ if(!data.startsWith("0x")) data = "0x"+data;
301
+ return (this.claimData.startsWith("0x") ? this.claimData : "0x"+this.claimData) === data;
302
+ }
303
+
304
+ equals(other: EVMSwapData): boolean {
305
+ return other.offerer.toLowerCase()===this.offerer.toLowerCase() &&
306
+ other.claimer.toLowerCase()===this.claimer.toLowerCase() &&
307
+ other.token.toLowerCase()===this.token.toLowerCase() &&
308
+ other.refundHandler.toLowerCase()===this.refundHandler.toLowerCase() &&
309
+ other.claimHandler.toLowerCase()===this.claimHandler.toLowerCase() &&
310
+ other.payIn===this.payIn &&
311
+ other.payOut===this.payOut &&
312
+ other.reputation===this.reputation &&
313
+ this.sequence === other.sequence &&
314
+ other.claimData.toLowerCase()===this.claimData.toLowerCase() &&
315
+ other.refundData.toLowerCase()===this.refundData.toLowerCase() &&
316
+ other.amount === this.amount &&
317
+ other.securityDeposit === this.securityDeposit &&
318
+ other.claimerBounty === this.claimerBounty
319
+ }
320
+
321
+ toEscrowStruct(): EscrowDataStruct {
322
+ return {
323
+ offerer: this.offerer,
324
+ claimer: this.claimer,
325
+ token: this.token,
326
+ refundHandler: this.refundHandler,
327
+ claimHandler: this.claimHandler,
328
+ flags: this.getFlags(),
329
+ claimData: this.claimData,
330
+ refundData: this.refundData,
331
+ amount: this.amount,
332
+ depositToken: this.depositToken,
333
+ securityDeposit: this.securityDeposit,
334
+ claimerBounty: this.claimerBounty,
335
+ successActionCommitment: ZeroHash //For now enforce no success action
336
+ }
337
+ }
338
+
339
+ static deserializeFromStruct(struct: EscrowDataStruct, claimHandlerImpl: IClaimHandler<any, any>): EVMSwapData {
340
+ const {payOut, payIn, reputation, sequence} = EVMSwapData.toFlags(BigInt(struct.flags));
341
+
342
+ if(struct.successActionCommitment !== ZeroHash) // throw new Error("Success action not allowed!");
343
+
344
+ return new EVMSwapData(
345
+ struct.offerer as string,
346
+ struct.claimer as string,
347
+ struct.token as string,
348
+ struct.refundHandler as string,
349
+ struct.claimHandler as string,
350
+ payOut,
351
+ payIn,
352
+ reputation,
353
+ sequence,
354
+ hexlify(struct.claimData),
355
+ hexlify(struct.refundData),
356
+ BigInt(struct.amount),
357
+ struct.depositToken as string,
358
+ BigInt(struct.securityDeposit),
359
+ BigInt(struct.claimerBounty),
360
+ claimHandlerImpl.getType(),
361
+ null
362
+ );
363
+ }
364
+
365
+ }
366
+
367
+ SwapData.deserializers["evm"] = EVMSwapData;
@@ -0,0 +1,16 @@
1
+ import {EscrowManager} from "./EscrowManagerTypechain";
2
+ import {EVMContractModule} from "../contract/EVMContractModule";
3
+ import {EVMSwapContract} from "./EVMSwapContract";
4
+ import {EVMChainInterface} from "../chain/EVMChainInterface";
5
+
6
+ export class EVMSwapModule extends EVMContractModule<EscrowManager> {
7
+
8
+ readonly contract: EVMSwapContract;
9
+ readonly swapContract: EscrowManager;
10
+
11
+ constructor(chainInterface: EVMChainInterface, contract: EVMSwapContract) {
12
+ super(chainInterface, contract);
13
+ this.swapContract = contract.contract;
14
+ }
15
+
16
+ }