@ercworldio/blockchain-shared 1.0.5-dev.7-PROJ-1469.1 → 1.0.5-dev.7-PROJ-1469.2

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.
@@ -3,6 +3,7 @@ import { Program } from "@coral-xyz/anchor";
3
3
  import { Commitment, Keypair, PublicKey, TransactionSignature } from "@solana/web3.js";
4
4
  import { Escrow } from "../types/escrow";
5
5
  import { BatchReceiver } from "../types/types";
6
+ import { ChainId } from "../../../../interfaces";
6
7
  export declare class EscrowAdminUtility {
7
8
  program: Program<Escrow>;
8
9
  provider: anchor.AnchorProvider;
@@ -84,12 +85,13 @@ export declare class EscrowAdminUtility {
84
85
  /**
85
86
  * Accepts an array of receivers and amounts and performs a batch withdrawal to the specified receivers
86
87
  * for the specified token (SOL or SPL)
88
+ * @param chain_id Network's chain id
87
89
  * @param token_address Address of the token to withdraw
88
90
  * @param recipients Array of receivers and their amounts
89
91
  * @param signer optional signer keypair
90
92
  * @returns string - signature
91
93
  */
92
- withdraw_batch(token_address: string, recipients: BatchReceiver[], signer?: Keypair): Promise<string>;
94
+ withdraw_batch(chain_id: ChainId, token_address: string, recipients: BatchReceiver[], signer?: Keypair): Promise<string>;
93
95
  /** @dev this might fail if the recipient does not have an ATA - take care of it in funding worker task */
94
96
  private batch_withdraw_spl;
95
97
  private batch_withdraw_sol;
@@ -1 +1 @@
1
- {"version":3,"file":"EscrowAdminUtility.d.ts","sourceRoot":"","sources":["../../../../../src/services/solana/escrow/services/EscrowAdminUtility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAoB,SAAS,EAA0E,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGjL,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKzC,OAAO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AAkB;YA6ClB,YAAY;YAyBZ,YAAY;YAgCZ,WAAW;YAwBX,WAAW;IAuCnB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAUlC,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;YAU9C,eAAe;IA0BhB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,GAAE,UAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1F,mBAAmB,CAC5B,SAAS,EAAE,oBAAoB,EAC/B,UAAU,GAAE,WAAW,GAAG,WAAyB,EACnD,SAAS,SAAS,GACnB,OAAO,CAAC,IAAI,CAAC;IAkChB;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,cAAc,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,kBAAkB;IAKnF;;;;;;OAMG;IACH,MAAM,CAAC,yBAAyB,CAAC,QAAQ,EAAE,MAAM,CAAC,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,kBAAkB;CAM/H;AAED,eAAe,kBAAkB,CAAC"}
@@ -358,29 +358,31 @@ class EscrowAdminUtility {
358
358
  /**
359
359
  * Accepts an array of receivers and amounts and performs a batch withdrawal to the specified receivers
360
360
  * for the specified token (SOL or SPL)
361
+ * @param chain_id Network's chain id
361
362
  * @param token_address Address of the token to withdraw
362
363
  * @param recipients Array of receivers and their amounts
363
364
  * @param signer optional signer keypair
364
365
  * @returns string - signature
365
366
  */
366
- withdraw_batch(token_address, recipients, signer) {
367
+ withdraw_batch(chain_id, token_address, recipients, signer) {
367
368
  return __awaiter(this, void 0, void 0, function* () {
368
369
  const token_pubkey = new web3_js_1.PublicKey(token_address);
369
370
  switch (token_pubkey.toBase58()) {
370
371
  case (web3_js_1.SystemProgram.programId.toBase58()):
371
- return this.batch_withdraw_sol(recipients, signer);
372
+ return this.batch_withdraw_sol(chain_id, recipients, signer);
372
373
  default:
373
- return this.batch_withdraw_spl(token_pubkey, recipients, signer);
374
+ return this.batch_withdraw_spl(chain_id, token_pubkey, recipients, signer);
374
375
  }
375
376
  });
376
377
  }
377
378
  /** @dev this might fail if the recipient does not have an ATA - take care of it in funding worker task */
378
- batch_withdraw_spl(mint, recipients, signer) {
379
+ batch_withdraw_spl(chainId, mint, recipients, signer) {
379
380
  return __awaiter(this, void 0, void 0, function* () {
380
381
  const escrowConfigPda = EscrowService.findEscrowConfigPda(this.program.programId);
381
382
  const vaultAuthority = EscrowService.findVaultAuthorityPda(this.program.programId);
382
383
  const vaultTokenAccount = EscrowService.findVaultAta(mint, this.program.programId);
383
384
  const amounts = recipients.map(r => new anchor.BN(r.amount_in_lamports));
385
+ const net_amounts = recipients.map(r => new anchor.BN(r.net_amount_in_lamports));
384
386
  const request_ids = recipients.map(r => new anchor.BN(r.request_id));
385
387
  const receivers = recipients.map(r => {
386
388
  const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(mint, new web3_js_1.PublicKey(r.receiver_pubkey));
@@ -391,7 +393,7 @@ class EscrowAdminUtility {
391
393
  };
392
394
  });
393
395
  const ix = yield this.program.methods
394
- .batchWithdrawTokens(request_ids, amounts)
396
+ .batchWithdrawTokens(new anchor.BN(chainId), request_ids, amounts, net_amounts)
395
397
  .accountsPartial({
396
398
  escrowConfig: escrowConfigPda,
397
399
  vaultAuthority: vaultAuthority,
@@ -407,11 +409,12 @@ class EscrowAdminUtility {
407
409
  return signature;
408
410
  });
409
411
  }
410
- batch_withdraw_sol(recipients, signer) {
412
+ batch_withdraw_sol(chainId, recipients, signer) {
411
413
  return __awaiter(this, void 0, void 0, function* () {
412
414
  const escrowConfigPda = EscrowService.findEscrowConfigPda(this.program.programId);
413
415
  const vaultAuthority = EscrowService.findVaultAuthorityPda(this.program.programId);
414
416
  const amounts = recipients.map(r => new anchor.BN(r.amount_in_lamports));
417
+ const net_amounts = recipients.map(r => new anchor.BN(r.net_amount_in_lamports));
415
418
  const receivers = recipients.map(r => {
416
419
  return {
417
420
  isSigner: false,
@@ -421,7 +424,7 @@ class EscrowAdminUtility {
421
424
  });
422
425
  const request_ids = recipients.map(r => new anchor.BN(r.request_id));
423
426
  const ix = yield this.program.methods
424
- .batchWithdrawSol(request_ids, amounts)
427
+ .batchWithdrawSol(new anchor.BN(chainId), request_ids, amounts, net_amounts)
425
428
  .accountsPartial({
426
429
  escrowConfig: escrowConfigPda,
427
430
  vaultAuthority: vaultAuthority,