@atomiqlabs/chain-starknet 4.0.0-dev.7 → 4.0.0-dev.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.
@@ -10,6 +10,7 @@ export declare class StarknetSwapInit extends StarknetSwapModule {
10
10
  /**
11
11
  * bare Init action based on the data passed in swapData
12
12
  *
13
+ * @param signer
13
14
  * @param swapData
14
15
  * @param timeout
15
16
  * @param signature
@@ -29,13 +29,14 @@ class StarknetSwapInit extends StarknetSwapModule_1.StarknetSwapModule {
29
29
  /**
30
30
  * bare Init action based on the data passed in swapData
31
31
  *
32
+ * @param signer
32
33
  * @param swapData
33
34
  * @param timeout
34
35
  * @param signature
35
36
  * @private
36
37
  */
37
- Init(swapData, timeout, signature) {
38
- return new StarknetAction_1.StarknetAction(swapData.payIn ? swapData.offerer : swapData.claimer, this.root, this.swapContract.populateTransaction.initialize(swapData.toEscrowStruct(), signature, timeout, swapData.extraData == null || swapData.extraData === "" ? [] : (0, Utils_1.bufferToBytes31Span)(buffer_1.Buffer.from(swapData.extraData, "hex")).map(Utils_1.toHex)), swapData.payIn ? StarknetSwapInit.GasCosts.INIT_PAY_IN : StarknetSwapInit.GasCosts.INIT);
38
+ Init(signer, swapData, timeout, signature) {
39
+ return new StarknetAction_1.StarknetAction(signer, this.root, this.swapContract.populateTransaction.initialize(swapData.toEscrowStruct(), signature ?? [], timeout, swapData.extraData == null || swapData.extraData === "" ? [] : (0, Utils_1.bufferToBytes31Span)(buffer_1.Buffer.from(swapData.extraData, "hex")).map(Utils_1.toHex)), swapData.payIn ? StarknetSwapInit.GasCosts.INIT_PAY_IN : StarknetSwapInit.GasCosts.INIT);
39
40
  }
40
41
  /**
41
42
  * Returns auth prefix to be used with a specific swap, payIn=true & payIn=false use different prefixes (these
@@ -199,7 +200,7 @@ class StarknetSwapInit extends StarknetSwapModule_1.StarknetSwapModule {
199
200
  throw new base_1.SwapDataVerificationError("Invoice already being paid for or paid");
200
201
  }
201
202
  feeRate ?? (feeRate = await this.root.Fees.getFeeRate());
202
- const initAction = this.Init(swapData, BigInt(timeout), JSON.parse(signature));
203
+ const initAction = this.Init(sender, swapData, BigInt(timeout), JSON.parse(signature));
203
204
  if (swapData.payIn && swapData.isOfferer(sender))
204
205
  initAction.addAction(this.root.Tokens.Approve(sender, this.swapContract.address, swapData.token, swapData.amount), 0); //Add erc20 approve
205
206
  if (swapData.getTotalDeposit() !== 0n)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/chain-starknet",
3
- "version": "4.0.0-dev.7",
3
+ "version": "4.0.0-dev.9",
4
4
  "description": "Starknet specific base implementation",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -41,18 +41,19 @@ export class StarknetSwapInit extends StarknetSwapModule {
41
41
  /**
42
42
  * bare Init action based on the data passed in swapData
43
43
  *
44
+ * @param signer
44
45
  * @param swapData
45
46
  * @param timeout
46
47
  * @param signature
47
48
  * @private
48
49
  */
49
- private Init(swapData: StarknetSwapData, timeout: bigint, signature: BigNumberish[]): StarknetAction {
50
+ private Init(signer: string, swapData: StarknetSwapData, timeout: bigint, signature: BigNumberish[]): StarknetAction {
50
51
  return new StarknetAction(
51
- swapData.payIn ? swapData.offerer : swapData.claimer,
52
+ signer,
52
53
  this.root,
53
54
  this.swapContract.populateTransaction.initialize(
54
55
  swapData.toEscrowStruct(),
55
- signature,
56
+ signature ?? [],
56
57
  timeout,
57
58
  swapData.extraData==null || swapData.extraData==="" ? [] : bufferToBytes31Span(Buffer.from(swapData.extraData, "hex")).map(toHex)
58
59
  ),
@@ -262,7 +263,7 @@ export class StarknetSwapInit extends StarknetSwapModule {
262
263
 
263
264
  feeRate ??= await this.root.Fees.getFeeRate();
264
265
 
265
- const initAction = this.Init(swapData, BigInt(timeout), JSON.parse(signature));
266
+ const initAction = this.Init(sender, swapData, BigInt(timeout), JSON.parse(signature));
266
267
  if(swapData.payIn && swapData.isOfferer(sender)) initAction.addAction(
267
268
  this.root.Tokens.Approve(sender, this.swapContract.address, swapData.token, swapData.amount), 0
268
269
  ); //Add erc20 approve