@atomiqlabs/chain-starknet 2.0.1 → 3.0.0-dev.0

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.
@@ -12,6 +12,32 @@ export declare const EscrowManagerAbi: readonly [{
12
12
  readonly name: "high";
13
13
  readonly type: "core::integer::u128";
14
14
  }];
15
+ }, {
16
+ readonly type: "struct";
17
+ readonly name: "escrow_manager::structs::escrow::EscrowExecution";
18
+ readonly members: readonly [{
19
+ readonly name: "contract";
20
+ readonly type: "core::starknet::contract_address::ContractAddress";
21
+ }, {
22
+ readonly name: "hash";
23
+ readonly type: "core::felt252";
24
+ }, {
25
+ readonly name: "expiry";
26
+ readonly type: "core::integer::u64";
27
+ }, {
28
+ readonly name: "fee";
29
+ readonly type: "core::integer::u256";
30
+ }];
31
+ }, {
32
+ readonly type: "enum";
33
+ readonly name: "core::option::Option::<escrow_manager::structs::escrow::EscrowExecution>";
34
+ readonly variants: readonly [{
35
+ readonly name: "Some";
36
+ readonly type: "escrow_manager::structs::escrow::EscrowExecution";
37
+ }, {
38
+ readonly name: "None";
39
+ readonly type: "()";
40
+ }];
15
41
  }, {
16
42
  readonly type: "struct";
17
43
  readonly name: "escrow_manager::structs::escrow::EscrowData";
@@ -51,6 +77,9 @@ export declare const EscrowManagerAbi: readonly [{
51
77
  }, {
52
78
  readonly name: "claimer_bounty";
53
79
  readonly type: "core::integer::u256";
80
+ }, {
81
+ readonly name: "success_action";
82
+ readonly type: "core::option::Option::<escrow_manager::structs::escrow::EscrowExecution>";
54
83
  }];
55
84
  }, {
56
85
  readonly type: "struct";
@@ -21,6 +21,42 @@ exports.EscrowManagerAbi = [
21
21
  }
22
22
  ]
23
23
  },
24
+ {
25
+ "type": "struct",
26
+ "name": "escrow_manager::structs::escrow::EscrowExecution",
27
+ "members": [
28
+ {
29
+ "name": "contract",
30
+ "type": "core::starknet::contract_address::ContractAddress"
31
+ },
32
+ {
33
+ "name": "hash",
34
+ "type": "core::felt252"
35
+ },
36
+ {
37
+ "name": "expiry",
38
+ "type": "core::integer::u64"
39
+ },
40
+ {
41
+ "name": "fee",
42
+ "type": "core::integer::u256"
43
+ }
44
+ ]
45
+ },
46
+ {
47
+ "type": "enum",
48
+ "name": "core::option::Option::<escrow_manager::structs::escrow::EscrowExecution>",
49
+ "variants": [
50
+ {
51
+ "name": "Some",
52
+ "type": "escrow_manager::structs::escrow::EscrowExecution"
53
+ },
54
+ {
55
+ "name": "None",
56
+ "type": "()"
57
+ }
58
+ ]
59
+ },
24
60
  {
25
61
  "type": "struct",
26
62
  "name": "escrow_manager::structs::escrow::EscrowData",
@@ -72,6 +108,10 @@ exports.EscrowManagerAbi = [
72
108
  {
73
109
  "name": "claimer_bounty",
74
110
  "type": "core::integer::u256"
111
+ },
112
+ {
113
+ "name": "success_action",
114
+ "type": "core::option::Option::<escrow_manager::structs::escrow::EscrowExecution>"
75
115
  }
76
116
  ]
77
117
  },
@@ -19,8 +19,8 @@ const ESCROW_STATE_COMMITTED = 1;
19
19
  const ESCROW_STATE_CLAIMED = 2;
20
20
  const ESCROW_STATE_REFUNDED = 3;
21
21
  const swapContractAddreses = {
22
- [starknet_1.constants.StarknetChainId.SN_SEPOLIA]: "0x06874044dae5bbe712775cdb576d6aef45fc87a22ce629f2b101a7d591d4e7ca",
23
- [starknet_1.constants.StarknetChainId.SN_MAIN]: "0x04fb26d02d2cf612566cd86cab299716d926272e9f49514670233952ecaf8f0c"
22
+ [starknet_1.constants.StarknetChainId.SN_SEPOLIA]: "0x00408d62790b47eaf9cc93239d371e1b1a3140590aa1ba4527ee4801784a11a4",
23
+ [starknet_1.constants.StarknetChainId.SN_MAIN]: ""
24
24
  };
25
25
  const defaultClaimAddresses = {
26
26
  [starknet_1.constants.StarknetChainId.SN_SEPOLIA]: {
@@ -258,7 +258,8 @@ class StarknetSwapData extends base_1.SwapData {
258
258
  amount: starknet_1.cairo.uint256((0, Utils_1.toBigInt)(this.amount)),
259
259
  fee_token: this.feeToken,
260
260
  security_deposit: starknet_1.cairo.uint256((0, Utils_1.toBigInt)(this.securityDeposit)),
261
- claimer_bounty: starknet_1.cairo.uint256((0, Utils_1.toBigInt)(this.claimerBounty))
261
+ claimer_bounty: starknet_1.cairo.uint256((0, Utils_1.toBigInt)(this.claimerBounty)),
262
+ success_action: new starknet_1.CairoOption(starknet_1.CairoOptionVariant.None) //For now enforce no success action
262
263
  };
263
264
  }
264
265
  static fromSerializedFeltArray(span, claimHandlerImpl) {
@@ -274,6 +275,14 @@ class StarknetSwapData extends base_1.SwapData {
274
275
  const feeToken = (0, Utils_1.toHex)(span.shift());
275
276
  const securityDeposit = (0, Utils_1.toBigInt)({ low: span.shift(), high: span.shift() });
276
277
  const claimerBounty = (0, Utils_1.toBigInt)({ low: span.shift(), high: span.shift() });
278
+ const hasSuccessAction = (0, Utils_1.toBigInt)(span.shift());
279
+ if (hasSuccessAction) {
280
+ const executionContract = (0, Utils_1.toHex)(span.shift());
281
+ const executionHash = (0, Utils_1.toHex)(span.shift());
282
+ const executionExpiry = (0, Utils_1.toBigInt)(span.shift());
283
+ const executionFee = (0, Utils_1.toBigInt)({ low: span.shift(), high: span.shift() });
284
+ throw new Error("Success action not allowed!");
285
+ }
277
286
  return new StarknetSwapData(offerer, claimer, token, refundHandler, claimHandler, payOut, payIn, reputation, sequence, claimData, refundData, amount, feeToken, securityDeposit, claimerBounty, claimHandlerImpl.getType(), null);
278
287
  }
279
288
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/chain-starknet",
3
- "version": "2.0.1",
3
+ "version": "3.0.0-dev.0",
4
4
  "description": "Starknet specific base implementation",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -18,6 +18,42 @@ export const EscrowManagerAbi = [
18
18
  }
19
19
  ]
20
20
  },
21
+ {
22
+ "type": "struct",
23
+ "name": "escrow_manager::structs::escrow::EscrowExecution",
24
+ "members": [
25
+ {
26
+ "name": "contract",
27
+ "type": "core::starknet::contract_address::ContractAddress"
28
+ },
29
+ {
30
+ "name": "hash",
31
+ "type": "core::felt252"
32
+ },
33
+ {
34
+ "name": "expiry",
35
+ "type": "core::integer::u64"
36
+ },
37
+ {
38
+ "name": "fee",
39
+ "type": "core::integer::u256"
40
+ }
41
+ ]
42
+ },
43
+ {
44
+ "type": "enum",
45
+ "name": "core::option::Option::<escrow_manager::structs::escrow::EscrowExecution>",
46
+ "variants": [
47
+ {
48
+ "name": "Some",
49
+ "type": "escrow_manager::structs::escrow::EscrowExecution"
50
+ },
51
+ {
52
+ "name": "None",
53
+ "type": "()"
54
+ }
55
+ ]
56
+ },
21
57
  {
22
58
  "type": "struct",
23
59
  "name": "escrow_manager::structs::escrow::EscrowData",
@@ -69,6 +105,10 @@ export const EscrowManagerAbi = [
69
105
  {
70
106
  "name": "claimer_bounty",
71
107
  "type": "core::integer::u256"
108
+ },
109
+ {
110
+ "name": "success_action",
111
+ "type": "core::option::Option::<escrow_manager::structs::escrow::EscrowExecution>"
72
112
  }
73
113
  ]
74
114
  },
@@ -33,8 +33,8 @@ const ESCROW_STATE_CLAIMED = 2;
33
33
  const ESCROW_STATE_REFUNDED = 3;
34
34
 
35
35
  const swapContractAddreses = {
36
- [constants.StarknetChainId.SN_SEPOLIA]: "0x06874044dae5bbe712775cdb576d6aef45fc87a22ce629f2b101a7d591d4e7ca",
37
- [constants.StarknetChainId.SN_MAIN]: "0x04fb26d02d2cf612566cd86cab299716d926272e9f49514670233952ecaf8f0c"
36
+ [constants.StarknetChainId.SN_SEPOLIA]: "0x00408d62790b47eaf9cc93239d371e1b1a3140590aa1ba4527ee4801784a11a4",
37
+ [constants.StarknetChainId.SN_MAIN]: ""
38
38
  };
39
39
 
40
40
  const defaultClaimAddresses = {
@@ -1,6 +1,6 @@
1
1
  import {SwapData, ChainSwapType} from "@atomiqlabs/base";
2
2
  import {TimelockRefundHandler} from "./handlers/refund/TimelockRefundHandler";
3
- import {BigNumberish, cairo, hash} from "starknet";
3
+ import {BigNumberish, cairo, CairoOption, CairoOptionVariant, hash} from "starknet";
4
4
  import {toBigInt, toHex} from "../../utils/Utils";
5
5
  import {
6
6
  StringToPrimitiveType
@@ -350,7 +350,8 @@ export class StarknetSwapData extends SwapData {
350
350
  amount: cairo.uint256(toBigInt(this.amount)),
351
351
  fee_token: this.feeToken,
352
352
  security_deposit: cairo.uint256(toBigInt(this.securityDeposit)),
353
- claimer_bounty: cairo.uint256(toBigInt(this.claimerBounty))
353
+ claimer_bounty: cairo.uint256(toBigInt(this.claimerBounty)),
354
+ success_action: new CairoOption(CairoOptionVariant.None) //For now enforce no success action
354
355
  }
355
356
  }
356
357
 
@@ -367,6 +368,14 @@ export class StarknetSwapData extends SwapData {
367
368
  const feeToken = toHex(span.shift());
368
369
  const securityDeposit = toBigInt({low: span.shift(), high: span.shift()});
369
370
  const claimerBounty = toBigInt({low: span.shift(), high: span.shift()});
371
+ const hasSuccessAction = toBigInt(span.shift());
372
+ if(hasSuccessAction) {
373
+ const executionContract = toHex(span.shift());
374
+ const executionHash = toHex(span.shift());
375
+ const executionExpiry = toBigInt(span.shift());
376
+ const executionFee = toBigInt({low: span.shift(), high: span.shift()});
377
+ throw new Error("Success action not allowed!");
378
+ }
370
379
 
371
380
  return new StarknetSwapData(
372
381
  offerer,