@allbridge/bridge-core-sdk 3.27.0-beta.3 → 3.27.0-beta.5

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.
@@ -44,6 +44,7 @@ class AlgBridgeService extends models_2.ChainBridgeService {
44
44
  this.algorand = algorand;
45
45
  this.api = api;
46
46
  algorand.setDefaultSigner(algosdk_1.default.makeBasicAccountTransactionSigner(algosdk_1.default.mnemonicToSecretKey("tunnel gym elevator pulse motor evolve release orange culture make sister approve winter chair armor grocery distance festival tiger holiday dish wisdom region absorb secret")));
47
+ algorand.setDefaultValidityWindow(100);
47
48
  }
48
49
  send(_params) {
49
50
  throw new exceptions_1.MethodNotSupportedError();
@@ -132,6 +133,12 @@ class AlgBridgeService extends models_2.ChainBridgeService {
132
133
  note: "padding",
133
134
  });
134
135
  composer.addTransaction(paddingTx);
136
+ const paddingTx2 = await this.algorand.createTransaction.appCall({
137
+ appId: paddingUtil.appId,
138
+ sender,
139
+ note: "padding2",
140
+ });
141
+ composer.addTransaction(paddingTx2);
135
142
  const { transactions } = await composer.buildTransactions();
136
143
  return (0, alg_1.populateAndEncodeTxs)(transactions, sender, this.algorand.client.algod);
137
144
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/alg/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2EAA4E;AAC5E,mDAA2C;AAC3C,6DAAwD;AAExD,oDAAwE;AACxE,4CAAmD;AACnD,gDAAmD;AAEnD,gEAA6D;AAC7D,0EAAuE;AACvE,yCAAqF;AACrF,sCAAuE;AACvE,oCAA8E;AAE9E,MAAa,gBAAiB,SAAQ,2BAAkB;IAI7C;IACA;IAJT,SAAS,GAAkB,uBAAS,CAAC,GAAG,CAAC;IAEzC,YACS,QAAwB,EACxB,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAHD,aAAQ,GAAR,QAAQ,CAAgB;QACxB,QAAG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7E,CAAC;IAEO,cAAc,CAAC,KAAa;QAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,qCAAiB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAClF,CAAC;CACF;AAnLD,4CAmLC","sourcesContent":["import { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { AlgoAmount } from \"@algorandfoundation/algokit-utils/types/amount\";\nimport algosdk, { Address } from \"algosdk\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { MethodNotSupportedError, SdkError } from \"../../../exceptions\";\nimport { FeePaymentMethod } from \"../../../models\";\nimport { assertNever } from \"../../../utils/utils\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { BridgeClient } from \"../../models/alg/BridgeClient\";\nimport { PaddingUtilClient } from \"../../models/alg/PaddingUtilClient\";\nimport { checkAssetOptIn, feeForInner, populateAndEncodeTxs } from \"../../utils/alg\";\nimport { ChainBridgeService, SendParams, SwapParams } from \"../models\";\nimport { getNonce, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\n\nexport class AlgBridgeService extends ChainBridgeService {\n chainType: ChainType.ALG = ChainType.ALG;\n\n constructor(\n public algorand: AlgorandClient,\n public api: AllbridgeCoreClient\n ) {\n super();\n algorand.setDefaultSigner(\n algosdk.makeBasicAccountTransactionSigner(\n algosdk.mnemonicToSecretKey(\n \"tunnel gym elevator pulse motor evolve release orange culture make sister approve winter chair armor grocery distance festival tiger holiday dish wisdom region absorb secret\"\n )\n )\n );\n }\n\n send(_params: SendParams): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n\n if (!params.sourceToken.bridgeId) {\n throw new SdkError(\"ALG sourceToken must contain 'bridgeId'\");\n }\n if (!params.sourceToken.paddingUtilId) {\n throw new SdkError(\"ALG sourceToken must contain 'paddingUtilId'\");\n }\n const bridgeId = BigInt(params.sourceToken.bridgeId);\n const bridge = this.getBridge(bridgeId);\n const paddingUtilId = BigInt(params.sourceToken.paddingUtilId);\n const paddingUtil = this.getPaddingUtil(paddingUtilId);\n const sender = Address.fromString(params.fromAccountAddress);\n const tokenId = BigInt(params.sourceToken.tokenAddress);\n const destinationChainId = txSendParams.toChainId;\n const recipient = txSendParams.toAccountAddress;\n const receiveToken = txSendParams.toTokenAddress;\n const nonce = getNonce();\n const amount = BigInt(txSendParams.amount);\n\n let totalFee = BigInt(txSendParams.fee);\n if (txSendParams.extraGas) {\n totalFee = totalFee + BigInt(txSendParams.extraGas);\n }\n\n const composer = this.algorand.newGroup();\n\n const assetTransferTx = await this.algorand.createTransaction.assetTransfer({\n amount,\n assetId: tokenId,\n receiver: bridge.appAddress,\n sender,\n });\n\n switch (txSendParams.gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n const paymentTx = await this.algorand.createTransaction.payment({\n amount: AlgoAmount.MicroAlgo(totalFee),\n receiver: bridge.appAddress,\n sender,\n });\n composer.addAppCallMethodCall(\n await bridge.params.swapAndBridge({\n args: {\n paymentRef: paymentTx,\n assetTransferRef: assetTransferTx,\n recipient,\n destinationChainId,\n receiveToken,\n nonce,\n },\n sender,\n extraFee: feeForInner(8),\n })\n );\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n composer.addAppCallMethodCall(\n await bridge.params.swapAndBridgeWithStable({\n args: {\n assetTransferRef: assetTransferTx,\n recipient,\n destinationChainId,\n receiveToken,\n nonce,\n feeTokenAmount: totalFee,\n },\n sender,\n extraFee: feeForInner(9),\n })\n );\n const paddingTx = await this.algorand.createTransaction.appCall({\n appId: paddingUtil.appId,\n sender,\n note: \"padding_1\",\n });\n composer.addTransaction(paddingTx);\n break;\n }\n case FeePaymentMethod.WITH_ARB:\n throw new SdkError(\"ALG bridge does not support ARB0 payment method\");\n default: {\n return assertNever(txSendParams.gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n\n const paddingTx = await this.algorand.createTransaction.appCall({\n appId: paddingUtil.appId,\n sender,\n note: \"padding\",\n });\n composer.addTransaction(paddingTx);\n\n const { transactions } = await composer.buildTransactions();\n return populateAndEncodeTxs(transactions, sender, this.algorand.client.algod);\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction> {\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n\n const sender = Address.fromString(params.fromAccountAddress);\n const recipient = params.toAccountAddress;\n const tokenId = BigInt(params.sourceToken.tokenAddress);\n const receiveTokenId = BigInt(params.destinationToken.tokenAddress);\n const receiveAmountMin = BigInt(txSwapParams.minimumReceiveAmount);\n const amount = BigInt(txSwapParams.amount);\n\n if (!params.sourceToken.bridgeId) {\n throw new SdkError(\"ALG sourceToken must contain 'bridgeId'\");\n }\n if (!params.sourceToken.paddingUtilId) {\n throw new SdkError(\"ALG sourceToken must contain 'paddingUtilId'\");\n }\n const bridgeId = BigInt(params.sourceToken.bridgeId);\n const bridge = this.getBridge(bridgeId);\n const paddingUtilId = BigInt(params.sourceToken.paddingUtilId);\n const paddingUtil = this.getPaddingUtil(paddingUtilId);\n\n const composer = this.algorand.newGroup();\n\n if (params.fromAccountAddress === recipient) {\n const optIn = await checkAssetOptIn(receiveTokenId, recipient, this.algorand);\n if (!optIn) {\n composer.addAssetOptIn({ sender: sender, assetId: receiveTokenId });\n }\n }\n\n const assetTransfer = this.algorand.createTransaction.assetTransfer({\n assetId: tokenId,\n amount: amount,\n sender,\n receiver: bridge.appAddress,\n });\n composer.addAppCallMethodCall(\n await bridge.params.swap({\n args: { assetTransferRef: assetTransfer, recipient, receiveAsset: receiveTokenId, receiveAmountMin },\n sender,\n extraFee: feeForInner(4),\n })\n );\n const paddingTx = await this.algorand.createTransaction.appCall({\n appId: paddingUtil.appId,\n sender,\n });\n composer.addTransaction(paddingTx);\n const { transactions } = await composer.buildTransactions();\n return populateAndEncodeTxs(transactions, sender, this.algorand.client.algod);\n }\n\n private getBridge(appId: bigint): BridgeClient {\n return this.algorand.client.getTypedAppClientById(BridgeClient, { appId });\n }\n\n private getPaddingUtil(appId: bigint): PaddingUtilClient {\n return this.algorand.client.getTypedAppClientById(PaddingUtilClient, { appId });\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/alg/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2EAA4E;AAC5E,mDAA2C;AAC3C,6DAAwD;AAExD,oDAAwE;AACxE,4CAAmD;AACnD,gDAAmD;AAEnD,gEAA6D;AAC7D,0EAAuE;AACvE,yCAAqF;AACrF,sCAAuE;AACvE,oCAA8E;AAE9E,MAAa,gBAAiB,SAAQ,2BAAkB;IAI7C;IACA;IAJT,SAAS,GAAkB,uBAAS,CAAC,GAAG,CAAC;IAEzC,YACS,QAAwB,EACxB,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAHD,aAAQ,GAAR,QAAQ,CAAgB;QACxB,QAAG,GAAH,GAAG,CAAqB;QAG/B,QAAQ,CAAC,gBAAgB,CACvB,iBAAO,CAAC,iCAAiC,CACvC,iBAAO,CAAC,mBAAmB,CACzB,+KAA+K,CAChL,CACF,CACF,CAAC;QACF,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,CAAC,OAAmB;QACtB,MAAM,IAAI,oCAAuB,EAAE,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,MAAkB;QAC9C,MAAM,YAAY,GAAG,MAAM,IAAA,2BAAmB,EAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAEjF,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;YACjC,MAAM,IAAI,qBAAQ,CAAC,yCAAyC,CAAC,CAAC;QAChE,CAAC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,CAAC,iBAAiB,CAAC,aAAa,CAAC;YAClE,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,MAAM;YACd,MAAM;YACN,QAAQ,EAAE,MAAM,CAAC,UAAU;SAC5B,CAAC,CAAC;QACH,QAAQ,CAAC,oBAAoB,CAC3B,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;YACvB,IAAI,EAAE,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE;YACpG,MAAM;YACN,QAAQ,EAAE,IAAA,iBAAW,EAAC,CAAC,CAAC;SACzB,CAAC,CACH,CAAC;QACF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,OAAO,CAAC;YAC9D,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,MAAM;SACP,CAAC,CAAC;QACH,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACnC,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QAC5D,OAAO,IAAA,0BAAoB,EAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChF,CAAC;IAEO,SAAS,CAAC,KAAa;QAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,2BAAY,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,CAAC;IAEO,cAAc,CAAC,KAAa;QAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,qCAAiB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAClF,CAAC;CACF;AA1LD,4CA0LC","sourcesContent":["import { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { AlgoAmount } from \"@algorandfoundation/algokit-utils/types/amount\";\nimport algosdk, { Address } from \"algosdk\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { MethodNotSupportedError, SdkError } from \"../../../exceptions\";\nimport { FeePaymentMethod } from \"../../../models\";\nimport { assertNever } from \"../../../utils/utils\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { BridgeClient } from \"../../models/alg/BridgeClient\";\nimport { PaddingUtilClient } from \"../../models/alg/PaddingUtilClient\";\nimport { checkAssetOptIn, feeForInner, populateAndEncodeTxs } from \"../../utils/alg\";\nimport { ChainBridgeService, SendParams, SwapParams } from \"../models\";\nimport { getNonce, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\n\nexport class AlgBridgeService extends ChainBridgeService {\n chainType: ChainType.ALG = ChainType.ALG;\n\n constructor(\n public algorand: AlgorandClient,\n public api: AllbridgeCoreClient\n ) {\n super();\n algorand.setDefaultSigner(\n algosdk.makeBasicAccountTransactionSigner(\n algosdk.mnemonicToSecretKey(\n \"tunnel gym elevator pulse motor evolve release orange culture make sister approve winter chair armor grocery distance festival tiger holiday dish wisdom region absorb secret\"\n )\n )\n );\n algorand.setDefaultValidityWindow(100);\n }\n\n send(_params: SendParams): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n\n if (!params.sourceToken.bridgeId) {\n throw new SdkError(\"ALG sourceToken must contain 'bridgeId'\");\n }\n if (!params.sourceToken.paddingUtilId) {\n throw new SdkError(\"ALG sourceToken must contain 'paddingUtilId'\");\n }\n const bridgeId = BigInt(params.sourceToken.bridgeId);\n const bridge = this.getBridge(bridgeId);\n const paddingUtilId = BigInt(params.sourceToken.paddingUtilId);\n const paddingUtil = this.getPaddingUtil(paddingUtilId);\n const sender = Address.fromString(params.fromAccountAddress);\n const tokenId = BigInt(params.sourceToken.tokenAddress);\n const destinationChainId = txSendParams.toChainId;\n const recipient = txSendParams.toAccountAddress;\n const receiveToken = txSendParams.toTokenAddress;\n const nonce = getNonce();\n const amount = BigInt(txSendParams.amount);\n\n let totalFee = BigInt(txSendParams.fee);\n if (txSendParams.extraGas) {\n totalFee = totalFee + BigInt(txSendParams.extraGas);\n }\n\n const composer = this.algorand.newGroup();\n\n const assetTransferTx = await this.algorand.createTransaction.assetTransfer({\n amount,\n assetId: tokenId,\n receiver: bridge.appAddress,\n sender,\n });\n\n switch (txSendParams.gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n const paymentTx = await this.algorand.createTransaction.payment({\n amount: AlgoAmount.MicroAlgo(totalFee),\n receiver: bridge.appAddress,\n sender,\n });\n composer.addAppCallMethodCall(\n await bridge.params.swapAndBridge({\n args: {\n paymentRef: paymentTx,\n assetTransferRef: assetTransferTx,\n recipient,\n destinationChainId,\n receiveToken,\n nonce,\n },\n sender,\n extraFee: feeForInner(8),\n })\n );\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n composer.addAppCallMethodCall(\n await bridge.params.swapAndBridgeWithStable({\n args: {\n assetTransferRef: assetTransferTx,\n recipient,\n destinationChainId,\n receiveToken,\n nonce,\n feeTokenAmount: totalFee,\n },\n sender,\n extraFee: feeForInner(9),\n })\n );\n const paddingTx = await this.algorand.createTransaction.appCall({\n appId: paddingUtil.appId,\n sender,\n note: \"padding_1\",\n });\n composer.addTransaction(paddingTx);\n break;\n }\n case FeePaymentMethod.WITH_ARB:\n throw new SdkError(\"ALG bridge does not support ARB0 payment method\");\n default: {\n return assertNever(txSendParams.gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n\n const paddingTx = await this.algorand.createTransaction.appCall({\n appId: paddingUtil.appId,\n sender,\n note: \"padding\",\n });\n composer.addTransaction(paddingTx);\n const paddingTx2 = await this.algorand.createTransaction.appCall({\n appId: paddingUtil.appId,\n sender,\n note: \"padding2\",\n });\n composer.addTransaction(paddingTx2);\n\n const { transactions } = await composer.buildTransactions();\n return populateAndEncodeTxs(transactions, sender, this.algorand.client.algod);\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction> {\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n\n const sender = Address.fromString(params.fromAccountAddress);\n const recipient = params.toAccountAddress;\n const tokenId = BigInt(params.sourceToken.tokenAddress);\n const receiveTokenId = BigInt(params.destinationToken.tokenAddress);\n const receiveAmountMin = BigInt(txSwapParams.minimumReceiveAmount);\n const amount = BigInt(txSwapParams.amount);\n\n if (!params.sourceToken.bridgeId) {\n throw new SdkError(\"ALG sourceToken must contain 'bridgeId'\");\n }\n if (!params.sourceToken.paddingUtilId) {\n throw new SdkError(\"ALG sourceToken must contain 'paddingUtilId'\");\n }\n const bridgeId = BigInt(params.sourceToken.bridgeId);\n const bridge = this.getBridge(bridgeId);\n const paddingUtilId = BigInt(params.sourceToken.paddingUtilId);\n const paddingUtil = this.getPaddingUtil(paddingUtilId);\n\n const composer = this.algorand.newGroup();\n\n if (params.fromAccountAddress === recipient) {\n const optIn = await checkAssetOptIn(receiveTokenId, recipient, this.algorand);\n if (!optIn) {\n composer.addAssetOptIn({ sender: sender, assetId: receiveTokenId });\n }\n }\n\n const assetTransfer = this.algorand.createTransaction.assetTransfer({\n assetId: tokenId,\n amount: amount,\n sender,\n receiver: bridge.appAddress,\n });\n composer.addAppCallMethodCall(\n await bridge.params.swap({\n args: { assetTransferRef: assetTransfer, recipient, receiveAsset: receiveTokenId, receiveAmountMin },\n sender,\n extraFee: feeForInner(4),\n })\n );\n const paddingTx = await this.algorand.createTransaction.appCall({\n appId: paddingUtil.appId,\n sender,\n });\n composer.addTransaction(paddingTx);\n const { transactions } = await composer.buildTransactions();\n return populateAndEncodeTxs(transactions, sender, this.algorand.client.algod);\n }\n\n private getBridge(appId: bigint): BridgeClient {\n return this.algorand.client.getTypedAppClientById(BridgeClient, { appId });\n }\n\n private getPaddingUtil(appId: bigint): PaddingUtilClient {\n return this.algorand.client.getTypedAppClientById(PaddingUtilClient, { appId });\n }\n}\n"]}
@@ -17,6 +17,7 @@ class AlgPoolService extends models_1.ChainPoolService {
17
17
  super();
18
18
  this.algorand = algorand;
19
19
  this.api = api;
20
+ algorand.setDefaultValidityWindow(100);
20
21
  }
21
22
  async buildRawTransactionClaimRewards(params) {
22
23
  const userAccount = params.accountAddress;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/liquidity-pool/alg/index.ts"],"names":[],"mappings":";;;AACA,qCAA8E;AAC9E,6DAAwD;AAExD,oDAA+C;AAE/C,4DAAwE;AAExE,4DAAyD;AACzD,yCAAwE;AACxE,sCAMmB;AAEnB,MAAa,cAAe,SAAQ,yBAAgB;IAKzC;IACA;IALT,SAAS,GAAkB,uBAAS,CAAC,GAAG,CAAC;IACjC,CAAC,GAAG,EAAE,CAAC;IAEf,YACS,QAAwB,EACxB,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAHD,aAAQ,GAAR,QAAQ,CAAgB;QACxB,QAAG,GAAH,GAAG,CAAqB;IAGjC,CAAC;IAED,KAAK,CAAC,+BAA+B,CAAC,MAA4B;QAChE,MAAM,WAAW,GAAG,MAAM,CAAC,cAAc,CAAC;QAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAC1C,QAAQ,CAAC,oBAAoB,CAC3B,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;YAC7B,IAAI,EAAE,EAAE;YACR,MAAM,EAAE,WAAW;YACnB,QAAQ,EAAE,IAAA,iBAAW,EAAC,CAAC,CAAC;YACx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gorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { assignGroupID, bytesToBigInt, OnApplicationComplete } from \"algosdk\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { SdkError } from \"../../../exceptions\";\nimport { PoolInfo, TokenWithChainDetails } from \"../../../tokens-info\";\nimport { calculatePoolInfoImbalance } from \"../../../utils/calculation\";\nimport { RawTransaction } from \"../../models\";\nimport { PoolClient } from \"../../models/alg/PoolClient\";\nimport { checkAppOptIn, encodeTxs, feeForInner } from \"../../utils/alg\";\nimport {\n ChainPoolService,\n LiquidityPoolsParams,\n LiquidityPoolsParamsWithAmount,\n UserBalance,\n UserBalanceInfo,\n} from \"../models\";\n\nexport class AlgPoolService extends ChainPoolService {\n chainType: ChainType.ALG = ChainType.ALG;\n private P = 48;\n\n constructor(\n public algorand: AlgorandClient,\n public api: AllbridgeCoreClient\n ) {\n super();\n }\n\n async buildRawTransactionClaimRewards(params: LiquidityPoolsParams): Promise<RawTransaction> {\n const userAccount = params.accountAddress;\n const assetId = BigInt(params.token.tokenAddress);\n const poolId = BigInt(params.token.poolAddress);\n const pool = this.getPool(poolId);\n\n const composer = this.algorand.newGroup();\n composer.addAppCallMethodCall(\n await pool.params.claimRewards({\n args: [],\n sender: userAccount,\n extraFee: feeForInner(1),\n assetReferences: [assetId],\n })\n );\n let { transactions } = await composer.buildTransactions();\n transactions = assignGroupID(transactions);\n return encodeTxs(...transactions);\n }\n\n async buildRawTransactionDeposit(params: LiquidityPoolsParamsWithAmount): Promise<RawTransaction> {\n const userAccount = params.accountAddress;\n const amount = BigInt(params.amount);\n const assetId = BigInt(params.token.tokenAddress);\n const poolId = BigInt(params.token.poolAddress);\n const pool = this.getPool(poolId);\n\n const isOptedIn = await checkAppOptIn(poolId, userAccount, this.algorand);\n\n const onComplete: OnApplicationComplete.OptInOC | OnApplicationComplete.NoOpOC = isOptedIn\n ? OnApplicationComplete.NoOpOC\n : OnApplicationComplete.OptInOC;\n\n const composer = this.algorand.newGroup();\n\n const assetTransfer = await this.algorand.createTransaction.assetTransfer({\n assetId: assetId,\n amount: amount,\n sender: userAccount,\n receiver: pool.appAddress,\n });\n composer.addAppCallMethodCall(\n await pool.params.deposit({\n args: { assetTransferRef: assetTransfer },\n sender: userAccount,\n onComplete: onComplete,\n extraFee: feeForInner(5),\n })\n );\n\n let { transactions } = await composer.buildTransactions();\n transactions = assignGroupID(transactions);\n return encodeTxs(...transactions);\n }\n\n async buildRawTransactionWithdraw(params: LiquidityPoolsParamsWithAmount): Promise<RawTransaction> {\n const userAccount = params.accountAddress;\n const amount = BigInt(params.amount);\n const assetId = BigInt(params.token.tokenAddress);\n const poolId = BigInt(params.token.poolAddress);\n const pool = this.getPool(poolId);\n\n const composer = this.algorand.newGroup();\n composer.addAppCallMethodCall(\n await pool.params.withdraw({\n args: { amountLp: amount },\n sender: userAccount,\n assetReferences: [assetId],\n extraFee: feeForInner(7),\n })\n );\n\n let { transactions } = await composer.buildTransactions();\n transactions = assignGroupID(transactions);\n return encodeTxs(...transactions);\n }\n\n async getPoolInfoFromChain(token: TokenWithChainDetails): Promise<PoolInfo> {\n const pool = this.getPool(BigInt(token.poolAddress));\n const all = await pool.state.global.getAll();\n const aValue = all.a?.toString();\n const dValue = all.d?.toString();\n const tokenBalance = all.tokenBalance?.toString();\n const vUsdBalance = all.vUsdBalance?.toString();\n const totalLpAmount = all.totalSupply?.toString();\n const accRewardPerShareP = bytesToBigInt(all.accRewardPerShareP?.asByteArray() ?? Uint8Array.from([])).toString();\n if (aValue && dValue && tokenBalance && vUsdBalance && totalLpAmount && accRewardPerShareP) {\n const imbalance = calculatePoolInfoImbalance({ tokenBalance, vUsdBalance });\n return {\n aValue,\n dValue,\n tokenBalance,\n vUsdBalance,\n totalLpAmount,\n accRewardPerShareP,\n p: this.P,\n imbalance,\n };\n }\n throw new SdkError(\"Unable to pool info from chain\");\n }\n\n async getUserBalanceInfo(accountAddress: string, token: TokenWithChainDetails): Promise<UserBalanceInfo> {\n const appId = BigInt(token.poolAddress);\n const pool = this.getPool(appId);\n try {\n const { balance, userRewardDebt } = await pool.state.local(accountAddress).getAll();\n if (balance !== undefined && userRewardDebt !== undefined) {\n return new UserBalance({\n lpAmount: balance.toString(),\n rewardDebt: userRewardDebt.toString(),\n });\n }\n } catch (ignoreError) {\n const info = await this.algorand.account.getInformation(accountAddress);\n const localStates = info.appsLocalState;\n if (localStates) {\n const isOptedIn = localStates.find(({ id: id }) => id === appId);\n if (!isOptedIn) {\n return new UserBalance({ lpAmount: \"0\", rewardDebt: \"0\" });\n }\n }\n }\n throw new SdkError(\"Unable to get user balance\");\n }\n\n private getPool(appId: bigint): PoolClient {\n return this.algorand.client.getTypedAppClientById(PoolClient, { appId });\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/liquidity-pool/alg/index.ts"],"names":[],"mappings":";;;AACA,qCAA8E;AAC9E,6DAAwD;AAExD,oDAA+C;AAE/C,4DAAwE;AAExE,4DAAyD;AACzD,yCAAwE;AACxE,sCAMmB;AAEnB,MAAa,cAAe,SAAQ,yBAAgB;IAKzC;IACA;IALT,SAAS,GAAkB,uBAAS,CAAC,GAAG,CAAC;IACjC,CAAC,GAAG,EAAE,CAAC;IAEf,YACS,QAAwB,EACxB,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAHD,aAAQ,GAAR,QAAQ,CAAgB;QACxB,QAAG,GAAH,GAAG,CAAqB;QAG/B,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,+BAA+B,CAAC,MAA4B;QAChE,MAAM,WAAW,GAAG,MAAM,CAAC,cAAc,CAAC;QAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC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,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;gBAC7D,CAAC;YACH,CAAC;QACH,CAAC;QACD,MAAM,IAAI,qBAAQ,CAAC,4BAA4B,CAAC,CAAC;IACnD,CAAC;IAEO,OAAO,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,uBAAU,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF;AA7ID,wCA6IC","sourcesContent":["import { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { assignGroupID, bytesToBigInt, OnApplicationComplete } from \"algosdk\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { SdkError } from \"../../../exceptions\";\nimport { PoolInfo, TokenWithChainDetails } from \"../../../tokens-info\";\nimport { calculatePoolInfoImbalance } from \"../../../utils/calculation\";\nimport { RawTransaction } from \"../../models\";\nimport { PoolClient } from \"../../models/alg/PoolClient\";\nimport { checkAppOptIn, encodeTxs, feeForInner } from \"../../utils/alg\";\nimport {\n ChainPoolService,\n LiquidityPoolsParams,\n LiquidityPoolsParamsWithAmount,\n UserBalance,\n UserBalanceInfo,\n} from \"../models\";\n\nexport class AlgPoolService extends ChainPoolService {\n chainType: ChainType.ALG = ChainType.ALG;\n private P = 48;\n\n constructor(\n public algorand: AlgorandClient,\n public api: AllbridgeCoreClient\n ) {\n super();\n algorand.setDefaultValidityWindow(100);\n }\n\n async buildRawTransactionClaimRewards(params: LiquidityPoolsParams): Promise<RawTransaction> {\n const userAccount = params.accountAddress;\n const assetId = BigInt(params.token.tokenAddress);\n const poolId = BigInt(params.token.poolAddress);\n const pool = this.getPool(poolId);\n\n const composer = this.algorand.newGroup();\n composer.addAppCallMethodCall(\n await pool.params.claimRewards({\n args: [],\n sender: userAccount,\n extraFee: feeForInner(1),\n assetReferences: [assetId],\n })\n );\n let { transactions } = await composer.buildTransactions();\n transactions = assignGroupID(transactions);\n return encodeTxs(...transactions);\n }\n\n async buildRawTransactionDeposit(params: LiquidityPoolsParamsWithAmount): Promise<RawTransaction> {\n const userAccount = params.accountAddress;\n const amount = BigInt(params.amount);\n const assetId = BigInt(params.token.tokenAddress);\n const poolId = BigInt(params.token.poolAddress);\n const pool = this.getPool(poolId);\n\n const isOptedIn = await checkAppOptIn(poolId, userAccount, this.algorand);\n\n const onComplete: OnApplicationComplete.OptInOC | OnApplicationComplete.NoOpOC = isOptedIn\n ? OnApplicationComplete.NoOpOC\n : OnApplicationComplete.OptInOC;\n\n const composer = this.algorand.newGroup();\n\n const assetTransfer = await this.algorand.createTransaction.assetTransfer({\n assetId: assetId,\n amount: amount,\n sender: userAccount,\n receiver: pool.appAddress,\n });\n composer.addAppCallMethodCall(\n await pool.params.deposit({\n args: { assetTransferRef: assetTransfer },\n sender: userAccount,\n onComplete: onComplete,\n extraFee: feeForInner(5),\n })\n );\n\n let { transactions } = await composer.buildTransactions();\n transactions = assignGroupID(transactions);\n return encodeTxs(...transactions);\n }\n\n async buildRawTransactionWithdraw(params: LiquidityPoolsParamsWithAmount): Promise<RawTransaction> {\n const userAccount = params.accountAddress;\n const amount = BigInt(params.amount);\n const assetId = BigInt(params.token.tokenAddress);\n const poolId = BigInt(params.token.poolAddress);\n const pool = this.getPool(poolId);\n\n const composer = this.algorand.newGroup();\n composer.addAppCallMethodCall(\n await pool.params.withdraw({\n args: { amountLp: amount },\n sender: userAccount,\n assetReferences: [assetId],\n extraFee: feeForInner(7),\n })\n );\n\n let { transactions } = await composer.buildTransactions();\n transactions = assignGroupID(transactions);\n return encodeTxs(...transactions);\n }\n\n async getPoolInfoFromChain(token: TokenWithChainDetails): Promise<PoolInfo> {\n const pool = this.getPool(BigInt(token.poolAddress));\n const all = await pool.state.global.getAll();\n const aValue = all.a?.toString();\n const dValue = all.d?.toString();\n const tokenBalance = all.tokenBalance?.toString();\n const vUsdBalance = all.vUsdBalance?.toString();\n const totalLpAmount = all.totalSupply?.toString();\n const accRewardPerShareP = bytesToBigInt(all.accRewardPerShareP?.asByteArray() ?? Uint8Array.from([])).toString();\n if (aValue && dValue && tokenBalance && vUsdBalance && totalLpAmount && accRewardPerShareP) {\n const imbalance = calculatePoolInfoImbalance({ tokenBalance, vUsdBalance });\n return {\n aValue,\n dValue,\n tokenBalance,\n vUsdBalance,\n totalLpAmount,\n accRewardPerShareP,\n p: this.P,\n imbalance,\n };\n }\n throw new SdkError(\"Unable to pool info from chain\");\n }\n\n async getUserBalanceInfo(accountAddress: string, token: TokenWithChainDetails): Promise<UserBalanceInfo> {\n const appId = BigInt(token.poolAddress);\n const pool = this.getPool(appId);\n try {\n const { balance, userRewardDebt } = await pool.state.local(accountAddress).getAll();\n if (balance !== undefined && userRewardDebt !== undefined) {\n return new UserBalance({\n lpAmount: balance.toString(),\n rewardDebt: userRewardDebt.toString(),\n });\n }\n } catch (ignoreError) {\n const info = await this.algorand.account.getInformation(accountAddress);\n const localStates = info.appsLocalState;\n if (localStates) {\n const isOptedIn = localStates.find(({ id: id }) => id === appId);\n if (!isOptedIn) {\n return new UserBalance({ lpAmount: \"0\", rewardDebt: \"0\" });\n }\n }\n }\n throw new SdkError(\"Unable to get user balance\");\n }\n\n private getPool(appId: bigint): PoolClient {\n return this.algorand.client.getTypedAppClientById(PoolClient, { appId });\n }\n}\n"]}
@@ -510,6 +510,8 @@ export declare abstract class BridgeParamsFactory {
510
510
  appReferences?: bigint[] | undefined;
511
511
  assetReferences?: bigint[] | undefined;
512
512
  boxReferences?: (import("@algorandfoundation/algokit-utils/types/app-manager").BoxReference | import("@algorandfoundation/algokit-utils/types/app-manager").BoxIdentifier)[] | undefined;
513
+ accessReferences?: import("@algorandfoundation/algokit-utils/types/app-manager").ResourceReference[] | undefined;
514
+ rejectVersion?: number | undefined;
513
515
  sender?: (Address | string) | undefined;
514
516
  method: string;
515
517
  args?: (import("algosdk").ABIValue | import("@algorandfoundation/algokit-utils/types/app-arc56").ABIStruct | AppMethodCallTransactionArgument | undefined)[] | undefined;
@@ -883,6 +885,7 @@ export declare class BridgeFactory {
883
885
  note?: string | Uint8Array | undefined;
884
886
  signer?: TransactionSigner | import("@algorandfoundation/algokit-utils/types/account").TransactionSignerAccount | undefined;
885
887
  onComplete?: OnApplicationComplete.NoOpOC | OnApplicationComplete.OptInOC | OnApplicationComplete.CloseOutOC | OnApplicationComplete.UpdateApplicationOC | OnApplicationComplete.DeleteApplicationOC | undefined;
888
+ rejectVersion?: number | undefined;
886
889
  lease?: string | Uint8Array | undefined;
887
890
  rekeyTo?: string | Address | undefined;
888
891
  staticFee?: import("@algorandfoundation/algokit-utils/types/amount").AlgoAmount | undefined;
@@ -894,6 +897,7 @@ export declare class BridgeFactory {
894
897
  appReferences?: bigint[] | undefined;
895
898
  assetReferences?: bigint[] | undefined;
896
899
  boxReferences?: (import("@algorandfoundation/algokit-utils/types/app-manager").BoxIdentifier | import("@algorandfoundation/algokit-utils/types/app-manager").BoxReference)[] | undefined;
900
+ accessReferences?: import("@algorandfoundation/algokit-utils/types/app-manager").ResourceReference[] | undefined;
897
901
  sender?: string | Address | undefined;
898
902
  method: string;
899
903
  args?: (import("algosdk").ABIValue | AppMethodCallTransactionArgument | import("@algorandfoundation/algokit-utils/types/app-arc56").ABIStruct | undefined)[] | undefined;
@@ -911,6 +915,7 @@ export declare class BridgeFactory {
911
915
  args?: Uint8Array[] | undefined;
912
916
  signer?: TransactionSigner | import("@algorandfoundation/algokit-utils/types/account").TransactionSignerAccount | undefined;
913
917
  onComplete?: OnApplicationComplete.NoOpOC | OnApplicationComplete.OptInOC | OnApplicationComplete.CloseOutOC | OnApplicationComplete.UpdateApplicationOC | OnApplicationComplete.DeleteApplicationOC | undefined;
918
+ rejectVersion?: number | undefined;
914
919
  lease?: string | Uint8Array | undefined;
915
920
  rekeyTo?: string | Address | undefined;
916
921
  staticFee?: import("@algorandfoundation/algokit-utils/types/amount").AlgoAmount | undefined;
@@ -922,6 +927,7 @@ export declare class BridgeFactory {
922
927
  appReferences?: bigint[] | undefined;
923
928
  assetReferences?: bigint[] | undefined;
924
929
  boxReferences?: (import("@algorandfoundation/algokit-utils/types/app-manager").BoxIdentifier | import("@algorandfoundation/algokit-utils/types/app-manager").BoxReference)[] | undefined;
930
+ accessReferences?: import("@algorandfoundation/algokit-utils/types/app-manager").ResourceReference[] | undefined;
925
931
  approvalProgram: string | Uint8Array;
926
932
  clearStateProgram: string | Uint8Array;
927
933
  schema?: {
@@ -950,6 +956,8 @@ export declare class BridgeFactory {
950
956
  appReferences?: bigint[] | undefined;
951
957
  assetReferences?: bigint[] | undefined;
952
958
  boxReferences?: (import("@algorandfoundation/algokit-utils/types/app-manager").BoxIdentifier | import("@algorandfoundation/algokit-utils/types/app-manager").BoxReference)[] | undefined;
959
+ accessReferences?: import("@algorandfoundation/algokit-utils/types/app-manager").ResourceReference[] | undefined;
960
+ rejectVersion?: number | undefined;
953
961
  approvalProgram: string | Uint8Array;
954
962
  clearStateProgram: string | Uint8Array;
955
963
  }> | import("@algorandfoundation/algokit-utils/types/composer").AppMethodCall<import("@algorandfoundation/algokit-utils/types/composer").AppMethodCallParams> | undefined)[] | undefined;
@@ -138,6 +138,8 @@ export declare abstract class PaddingUtilParamsFactory {
138
138
  appReferences?: bigint[] | undefined;
139
139
  assetReferences?: bigint[] | undefined;
140
140
  boxReferences?: (import("@algorandfoundation/algokit-utils/types/app-manager").BoxReference | import("@algorandfoundation/algokit-utils/types/app-manager").BoxIdentifier)[] | undefined;
141
+ accessReferences?: import("@algorandfoundation/algokit-utils/types/app-manager").ResourceReference[] | undefined;
142
+ rejectVersion?: number | undefined;
141
143
  sender?: (Address | string) | undefined;
142
144
  method: string;
143
145
  args?: (import("algosdk").ABIValue | import("@algorandfoundation/algokit-utils/types/app-arc56").ABIStruct | AppMethodCallTransactionArgument | undefined)[] | undefined;
@@ -322,6 +324,7 @@ export declare class PaddingUtilFactory {
322
324
  note?: string | Uint8Array | undefined;
323
325
  signer?: TransactionSigner | import("@algorandfoundation/algokit-utils/types/account").TransactionSignerAccount | undefined;
324
326
  onComplete?: OnApplicationComplete.NoOpOC | OnApplicationComplete.OptInOC | OnApplicationComplete.CloseOutOC | OnApplicationComplete.UpdateApplicationOC | OnApplicationComplete.DeleteApplicationOC | undefined;
327
+ rejectVersion?: number | undefined;
325
328
  lease?: string | Uint8Array | undefined;
326
329
  rekeyTo?: string | Address | undefined;
327
330
  staticFee?: import("@algorandfoundation/algokit-utils/types/amount").AlgoAmount | undefined;
@@ -333,6 +336,7 @@ export declare class PaddingUtilFactory {
333
336
  appReferences?: bigint[] | undefined;
334
337
  assetReferences?: bigint[] | undefined;
335
338
  boxReferences?: (import("@algorandfoundation/algokit-utils/types/app-manager").BoxIdentifier | import("@algorandfoundation/algokit-utils/types/app-manager").BoxReference)[] | undefined;
339
+ accessReferences?: import("@algorandfoundation/algokit-utils/types/app-manager").ResourceReference[] | undefined;
336
340
  sender?: string | Address | undefined;
337
341
  method: string;
338
342
  args?: (import("algosdk").ABIValue | AppMethodCallTransactionArgument | import("@algorandfoundation/algokit-utils/types/app-arc56").ABIStruct | undefined)[] | undefined;
@@ -345,15 +349,23 @@ export declare class PaddingUtilFactory {
345
349
  method: import("@algorandfoundation/algokit-utils/types/app-arc56").Arc56Method;
346
350
  args: (Transaction | import("algosdk").ABIValue | import("algosdk").TransactionWithSigner | Promise<Transaction> | import("@algorandfoundation/algokit-utils/types/composer").AppMethodCall<{
347
351
  sender: string | Address;
348
- maxFee?: import("@algorandfoundation/algokit-utils/types/amount").AlgoAmount | undefined;
352
+ maxFee?: import("@algorandfoundation/algokit-utils/types/amount" /**
353
+ * Creates a new instance of the PaddingUtil smart contract using the createApplication()void ABI method.
354
+ *
355
+ * @param params The params for the smart contract call
356
+ * @returns The create params
357
+ */).AlgoAmount | undefined;
349
358
  note?: string | Uint8Array | undefined;
350
359
  args?: Uint8Array[] | undefined;
351
360
  signer?: TransactionSigner | import("@algorandfoundation/algokit-utils/types/account").TransactionSignerAccount | undefined;
352
361
  onComplete?: OnApplicationComplete.NoOpOC | OnApplicationComplete.OptInOC | OnApplicationComplete.CloseOutOC | OnApplicationComplete.UpdateApplicationOC | OnApplicationComplete.DeleteApplicationOC | undefined;
362
+ rejectVersion?: number | undefined;
353
363
  lease?: string | Uint8Array | undefined;
354
364
  rekeyTo?: string | Address | undefined;
355
365
  staticFee?: import("@algorandfoundation/algokit-utils/types/amount").AlgoAmount | undefined;
356
- extraFee?: import("@algorandfoundation/algokit-utils/types/amount").AlgoAmount | undefined;
366
+ extraFee?: import("@algorandfoundation/algokit-utils/types/amount" /**
367
+ * Gets available create methods
368
+ */).AlgoAmount | undefined;
357
369
  validityWindow?: number | bigint | undefined;
358
370
  firstValidRound?: bigint | undefined;
359
371
  lastValidRound?: bigint | undefined;
@@ -361,6 +373,7 @@ export declare class PaddingUtilFactory {
361
373
  appReferences?: bigint[] | undefined;
362
374
  assetReferences?: bigint[] | undefined;
363
375
  boxReferences?: (import("@algorandfoundation/algokit-utils/types/app-manager").BoxIdentifier | import("@algorandfoundation/algokit-utils/types/app-manager").BoxReference)[] | undefined;
376
+ accessReferences?: import("@algorandfoundation/algokit-utils/types/app-manager").ResourceReference[] | undefined;
364
377
  approvalProgram: string | Uint8Array;
365
378
  clearStateProgram: string | Uint8Array;
366
379
  schema?: {
@@ -389,6 +402,8 @@ export declare class PaddingUtilFactory {
389
402
  appReferences?: bigint[] | undefined;
390
403
  assetReferences?: bigint[] | undefined;
391
404
  boxReferences?: (import("@algorandfoundation/algokit-utils/types/app-manager").BoxIdentifier | import("@algorandfoundation/algokit-utils/types/app-manager").BoxReference)[] | undefined;
405
+ accessReferences?: import("@algorandfoundation/algokit-utils/types/app-manager").ResourceReference[] | undefined;
406
+ rejectVersion?: number | undefined;
392
407
  approvalProgram: string | Uint8Array;
393
408
  clearStateProgram: string | Uint8Array;
394
409
  }> | import("@algorandfoundation/algokit-utils/types/composer").AppMethodCall<import("@algorandfoundation/algokit-utils/types/composer").AppMethodCallParams> | undefined)[] | undefined;
@@ -418,6 +418,8 @@ export declare abstract class PoolParamsFactory {
418
418
  appReferences?: bigint[] | undefined;
419
419
  assetReferences?: bigint[] | undefined;
420
420
  boxReferences?: (import("@algorandfoundation/algokit-utils/types/app-manager").BoxReference | import("@algorandfoundation/algokit-utils/types/app-manager").BoxIdentifier)[] | undefined;
421
+ accessReferences?: import("@algorandfoundation/algokit-utils/types/app-manager").ResourceReference[] | undefined;
422
+ rejectVersion?: number | undefined;
421
423
  sender?: (Address | string) | undefined;
422
424
  method: string;
423
425
  args?: (import("algosdk").ABIValue | import("@algorandfoundation/algokit-utils/types/app-arc56").ABIStruct | AppMethodCallTransactionArgument | undefined)[] | undefined;
@@ -771,6 +773,7 @@ export declare class PoolFactory {
771
773
  note?: string | Uint8Array | undefined;
772
774
  signer?: TransactionSigner | import("@algorandfoundation/algokit-utils/types/account").TransactionSignerAccount | undefined;
773
775
  onComplete?: OnApplicationComplete.NoOpOC | OnApplicationComplete.OptInOC | OnApplicationComplete.CloseOutOC | OnApplicationComplete.UpdateApplicationOC | OnApplicationComplete.DeleteApplicationOC | undefined;
776
+ rejectVersion?: number | undefined;
774
777
  lease?: string | Uint8Array | undefined;
775
778
  rekeyTo?: string | Address | undefined;
776
779
  staticFee?: import("@algorandfoundation/algokit-utils/types/amount").AlgoAmount | undefined;
@@ -782,6 +785,7 @@ export declare class PoolFactory {
782
785
  appReferences?: bigint[] | undefined;
783
786
  assetReferences?: bigint[] | undefined;
784
787
  boxReferences?: (import("@algorandfoundation/algokit-utils/types/app-manager").BoxIdentifier | import("@algorandfoundation/algokit-utils/types/app-manager").BoxReference)[] | undefined;
788
+ accessReferences?: import("@algorandfoundation/algokit-utils/types/app-manager").ResourceReference[] | undefined;
785
789
  sender?: string | Address | undefined;
786
790
  method: string;
787
791
  args?: (import("algosdk").ABIValue | AppMethodCallTransactionArgument | import("@algorandfoundation/algokit-utils/types/app-arc56").ABIStruct | undefined)[] | undefined;
@@ -799,6 +803,7 @@ export declare class PoolFactory {
799
803
  args?: Uint8Array[] | undefined;
800
804
  signer?: TransactionSigner | import("@algorandfoundation/algokit-utils/types/account").TransactionSignerAccount | undefined;
801
805
  onComplete?: OnApplicationComplete.NoOpOC | OnApplicationComplete.OptInOC | OnApplicationComplete.CloseOutOC | OnApplicationComplete.UpdateApplicationOC | OnApplicationComplete.DeleteApplicationOC | undefined;
806
+ rejectVersion?: number | undefined;
802
807
  lease?: string | Uint8Array | undefined;
803
808
  rekeyTo?: string | Address | undefined;
804
809
  staticFee?: import("@algorandfoundation/algokit-utils/types/amount").AlgoAmount | undefined;
@@ -810,6 +815,7 @@ export declare class PoolFactory {
810
815
  appReferences?: bigint[] | undefined;
811
816
  assetReferences?: bigint[] | undefined;
812
817
  boxReferences?: (import("@algorandfoundation/algokit-utils/types/app-manager").BoxIdentifier | import("@algorandfoundation/algokit-utils/types/app-manager").BoxReference)[] | undefined;
818
+ accessReferences?: import("@algorandfoundation/algokit-utils/types/app-manager").ResourceReference[] | undefined;
813
819
  approvalProgram: string | Uint8Array;
814
820
  clearStateProgram: string | Uint8Array;
815
821
  schema?: {
@@ -838,6 +844,8 @@ export declare class PoolFactory {
838
844
  appReferences?: bigint[] | undefined;
839
845
  assetReferences?: bigint[] | undefined;
840
846
  boxReferences?: (import("@algorandfoundation/algokit-utils/types/app-manager").BoxIdentifier | import("@algorandfoundation/algokit-utils/types/app-manager").BoxReference)[] | undefined;
847
+ accessReferences?: import("@algorandfoundation/algokit-utils/types/app-manager").ResourceReference[] | undefined;
848
+ rejectVersion?: number | undefined;
841
849
  approvalProgram: string | Uint8Array;
842
850
  clearStateProgram: string | Uint8Array;
843
851
  }> | import("@algorandfoundation/algokit-utils/types/composer").AppMethodCall<import("@algorandfoundation/algokit-utils/types/composer").AppMethodCallParams> | undefined)[] | undefined;
@@ -7,7 +7,7 @@ import { ApproveParamsDto, ChainTokenService, GetAllowanceParamsDto, GetTokenBal
7
7
  export declare class AlgTokenService extends ChainTokenService {
8
8
  algorand: AlgorandClient;
9
9
  api: AllbridgeCoreClient;
10
- chainType: ChainType.SUI;
10
+ chainType: ChainType.ALG;
11
11
  constructor(algorand: AlgorandClient, api: AllbridgeCoreClient);
12
12
  approve(_params: ApproveParamsDto): Promise<TransactionResponse>;
13
13
  buildRawTransactionApprove(_params: ApproveParamsDto): Promise<RawTransaction>;
@@ -7,11 +7,12 @@ const models_1 = require("../models");
7
7
  class AlgTokenService extends models_1.ChainTokenService {
8
8
  algorand;
9
9
  api;
10
- chainType = chain_enums_1.ChainType.SUI;
10
+ chainType = chain_enums_1.ChainType.ALG;
11
11
  constructor(algorand, api) {
12
12
  super();
13
13
  this.algorand = algorand;
14
14
  this.api = api;
15
+ algorand.setDefaultValidityWindow(100);
15
16
  }
16
17
  approve(_params) {
17
18
  throw new exceptions_1.MethodNotSupportedError();
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/token/alg/index.ts"],"names":[],"mappings":";;;AACA,6DAAwD;AAExD,oDAA8D;AAG9D,sCAA8G;AAE9G,MAAa,eAAgB,SAAQ,0BAAiB;IAI3C;IACA;IAJT,SAAS,GAAkB,uBAAS,CAAC,GAAG,CAAC;IAEzC,YACS,QAAwB,EACxB,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAHD,aAAQ,GAAR,QAAQ,CAAgB;QACxB,QAAG,GAAH,GAAG,CAAqB;IAGjC,CAAC;IAED,OAAO,CAAC,OAAyB;QAC/B,MAAM,IAAI,oCAAuB,EAAE,CAAC;IACtC,CAAC;IAED,0BAA0B,CAAC,OAAyB;QAClD,MAAM,IAAI,oCAAuB,EAAE,CAAC;IACtC,CAAC;IAED,YAAY,CAAC,OAA8B;QACzC,MAAM,IAAI,oCAAuB,EAAE,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,MAAmC;QAC7D,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAC3B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,MAA6B;QACjD,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAClC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;YAClG,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACjC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;gBACvB,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAC,CAAC;gBACnD,OAAO,GAAG,CAAC;YACb,CAAC;YACD,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;CACF;AAzCD,0CAyCC","sourcesContent":["import { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { MethodNotSupportedError } from \"../../../exceptions\";\nimport { GetNativeTokenBalanceParams } from \"../../bridge/models\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { ApproveParamsDto, ChainTokenService, GetAllowanceParamsDto, GetTokenBalanceParams } from \"../models\";\n\nexport class AlgTokenService extends ChainTokenService {\n chainType: ChainType.SUI = ChainType.SUI;\n\n constructor(\n public algorand: AlgorandClient,\n public api: AllbridgeCoreClient\n ) {\n super();\n }\n\n approve(_params: ApproveParamsDto): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n\n buildRawTransactionApprove(_params: ApproveParamsDto): Promise<RawTransaction> {\n throw new MethodNotSupportedError();\n }\n\n getAllowance(_params: GetAllowanceParamsDto): Promise<string> {\n throw new MethodNotSupportedError();\n }\n\n async getNativeTokenBalance(params: GetNativeTokenBalanceParams): Promise<string> {\n const { account } = params;\n const info = await this.algorand.account.getInformation(account);\n return info.balance.microAlgo.toString();\n }\n\n async getTokenBalance(params: GetTokenBalanceParams): Promise<string> {\n const { account, token } = params;\n try {\n const info = await this.algorand.asset.getAccountInformation(account, BigInt(token.tokenAddress));\n return info.balance.toString();\n } catch (e) {\n if (e instanceof Error) {\n e.message.includes(\"account asset info not found\");\n return \"0\";\n }\n throw e;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/token/alg/index.ts"],"names":[],"mappings":";;;AACA,6DAAwD;AAExD,oDAA8D;AAG9D,sCAA8G;AAE9G,MAAa,eAAgB,SAAQ,0BAAiB;IAI3C;IACA;IAJT,SAAS,GAAkB,uBAAS,CAAC,GAAG,CAAC;IAEzC,YACS,QAAwB,EACxB,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAHD,aAAQ,GAAR,QAAQ,CAAgB;QACxB,QAAG,GAAH,GAAG,CAAqB;QAG/B,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,OAAyB;QAC/B,MAAM,IAAI,oCAAuB,EAAE,CAAC;IACtC,CAAC;IAED,0BAA0B,CAAC,OAAyB;QAClD,MAAM,IAAI,oCAAuB,EAAE,CAAC;IACtC,CAAC;IAED,YAAY,CAAC,OAA8B;QACzC,MAAM,IAAI,oCAAuB,EAAE,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,MAAmC;QAC7D,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAC3B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,MAA6B;QACjD,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAClC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;YAClG,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACjC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;gBACvB,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAC,CAAC;gBACnD,OAAO,GAAG,CAAC;YACb,CAAC;YACD,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;CACF;AA1CD,0CA0CC","sourcesContent":["import { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { MethodNotSupportedError } from \"../../../exceptions\";\nimport { GetNativeTokenBalanceParams } from \"../../bridge/models\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { ApproveParamsDto, ChainTokenService, GetAllowanceParamsDto, GetTokenBalanceParams } from \"../models\";\n\nexport class AlgTokenService extends ChainTokenService {\n chainType: ChainType.ALG = ChainType.ALG;\n\n constructor(\n public algorand: AlgorandClient,\n public api: AllbridgeCoreClient\n ) {\n super();\n algorand.setDefaultValidityWindow(100);\n }\n\n approve(_params: ApproveParamsDto): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n\n buildRawTransactionApprove(_params: ApproveParamsDto): Promise<RawTransaction> {\n throw new MethodNotSupportedError();\n }\n\n getAllowance(_params: GetAllowanceParamsDto): Promise<string> {\n throw new MethodNotSupportedError();\n }\n\n async getNativeTokenBalance(params: GetNativeTokenBalanceParams): Promise<string> {\n const { account } = params;\n const info = await this.algorand.account.getInformation(account);\n return info.balance.microAlgo.toString();\n }\n\n async getTokenBalance(params: GetTokenBalanceParams): Promise<string> {\n const { account, token } = params;\n try {\n const info = await this.algorand.asset.getAccountInformation(account, BigInt(token.tokenAddress));\n return info.balance.toString();\n } catch (e) {\n if (e instanceof Error) {\n e.message.includes(\"account asset info not found\");\n return \"0\";\n }\n throw e;\n }\n }\n}\n"]}
@@ -53,13 +53,17 @@ class DefaultAlgUtils {
53
53
  }
54
54
  getAlgorand(client) {
55
55
  if (client) {
56
- return algokit_utils_1.AlgorandClient.fromClients({ algod: client });
56
+ const algorandClient = algokit_utils_1.AlgorandClient.fromClients({ algod: client });
57
+ algorandClient.setDefaultValidityWindow(100);
58
+ return algorandClient;
57
59
  }
58
60
  else {
59
61
  const nodeRpcUrl = this.nodeRpcUrlsConfig.getNodeRpcUrl(index_1.ChainSymbol.ALG);
60
- return algokit_utils_1.AlgorandClient.fromConfig({
62
+ const algorandClient = algokit_utils_1.AlgorandClient.fromConfig({
61
63
  algodConfig: { server: nodeRpcUrl },
62
64
  });
65
+ algorandClient.setDefaultValidityWindow(100);
66
+ return algorandClient;
63
67
  }
64
68
  }
65
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/alg/index.ts"],"names":[],"mappings":";;;AAAA,qEAAmE;AACnE,qCAAoE;AACpE,uCAA6D;AAE7D,kDAAqF;AAYrF,MAAa,eAAe;IACL;IAArB,YAAqB,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAE7D,KAAK,CAAC,eAAe,CAAC,OAAwB,EAAE,MAAc,EAAE,MAAgB;QAC9E,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC1C,OAAO,IAAA,qBAAe,EAAC,OAAO,EAAE,MAAM,EAA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EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;gBAC1C,MAAM,EAAE,EAAE;gBACV,QAAQ,EAAE,KAAK;aAChB,CAAC;YACF,IAAI,EAAE,EAAE;YACR,MAAM;YACN,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,+BAAqB,CAAC,OAAO;SAC1C,CAAC,CAAC;QACH,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QAC5D,OAAO,IAAA,eAAS,EAAC,GAAG,YAAY,CAAC,CAAC;IACpC,CAAC;IAEO,WAAW,CAAC,MAAgB;QAClC,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,8BAAc,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QACvD,CAAC;aAAM,CAAC;YACN,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,mBAAW,CAAC,GAAG,CAAC,CAAC;YACzE,OAAO,8BAAc,CAAC,UAAU,CAAC;gBAC/B,WAAW,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;aACpC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AAnED,0CAmEC","sourcesContent":["import { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { ABIMethod, Algodv2, OnApplicationComplete } from \"algosdk\";\nimport { ChainSymbol, RawAlgTransaction } from \"../../index\";\nimport { NodeRpcUrlsConfig } from \"../../services\";\nimport { checkAppOptIn, checkAssetOptIn, encodeTxs } from \"../../services/utils/alg\";\n\n/**\n * Contains usefully Alg methods\n */\nexport interface AlgUtils {\n checkAssetOptIn(assetId: string | bigint, sender: string, client?: Algodv2): Promise<boolean>;\n checkAppOptIn(appId: string | bigint, sender: string, client?: Algodv2): Promise<boolean>;\n buildRawTransactionAssetOptIn(assetId: string | bigint, sender: string, client?: Algodv2): Promise<RawAlgTransaction>;\n buildRawTransactionAppOptIn(appId: string | bigint, sender: string, client?: Algodv2): Promise<RawAlgTransaction>;\n}\n\nexport class DefaultAlgUtils implements AlgUtils {\n constructor(readonly nodeRpcUrlsConfig: NodeRpcUrlsConfig) {}\n\n async checkAssetOptIn(assetId: string | bigint, sender: string, client?: Algodv2): Promise<boolean> {\n const algorand = this.getAlgorand(client);\n return checkAssetOptIn(assetId, sender, algorand);\n }\n\n async buildRawTransactionAssetOptIn(\n assetId: string | bigint,\n sender: string,\n client?: Algodv2\n ): Promise<RawAlgTransaction> {\n const algorand = this.getAlgorand(client);\n if (typeof assetId === \"string\") {\n assetId = BigInt(assetId);\n }\n const tx = await algorand.createTransaction.assetOptIn({ assetId: assetId, sender: sender });\n return encodeTxs(tx);\n }\n\n async checkAppOptIn(appId: string | bigint, sender: string, client?: Algodv2): Promise<boolean> {\n const algorand = this.getAlgorand(client);\n return checkAppOptIn(appId, sender, algorand);\n }\n\n async buildRawTransactionAppOptIn(\n appId: string | bigint,\n sender: string,\n client?: Algodv2\n ): Promise<RawAlgTransaction> {\n const algorand = this.getAlgorand(client);\n if (typeof appId === \"string\") {\n appId = BigInt(appId);\n }\n\n const composer = algorand.newGroup();\n const signer = algorand.account.random();\n composer.addAppCallMethodCall({\n appId,\n method: new ABIMethod({\n name: \"optInToApplication\",\n desc: undefined,\n args: [],\n returns: { type: \"void\", desc: undefined },\n events: [],\n readonly: false,\n }),\n args: [],\n sender,\n signer: signer,\n onComplete: OnApplicationComplete.OptInOC,\n });\n const { transactions } = await composer.buildTransactions();\n return encodeTxs(...transactions);\n }\n\n private getAlgorand(client?: Algodv2): AlgorandClient {\n if (client) {\n return AlgorandClient.fromClients({ algod: client });\n } else {\n const nodeRpcUrl = this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.ALG);\n return AlgorandClient.fromConfig({\n algodConfig: { server: nodeRpcUrl },\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/alg/index.ts"],"names":[],"mappings":";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C,OAAO,cAAc,CAAC;QACxB,CAAC;IACH,CAAC;CACF;AAvED,0CAuEC","sourcesContent":["import { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { ABIMethod, Algodv2, OnApplicationComplete } from \"algosdk\";\nimport { ChainSymbol, RawAlgTransaction } from \"../../index\";\nimport { NodeRpcUrlsConfig } from \"../../services\";\nimport { checkAppOptIn, checkAssetOptIn, encodeTxs } from \"../../services/utils/alg\";\n\n/**\n * Contains usefully Alg methods\n */\nexport interface AlgUtils {\n checkAssetOptIn(assetId: string | bigint, sender: string, client?: Algodv2): Promise<boolean>;\n checkAppOptIn(appId: string | bigint, sender: string, client?: Algodv2): Promise<boolean>;\n buildRawTransactionAssetOptIn(assetId: string | bigint, sender: string, client?: Algodv2): Promise<RawAlgTransaction>;\n buildRawTransactionAppOptIn(appId: string | bigint, sender: string, client?: Algodv2): Promise<RawAlgTransaction>;\n}\n\nexport class DefaultAlgUtils implements AlgUtils {\n constructor(readonly nodeRpcUrlsConfig: NodeRpcUrlsConfig) {}\n\n async checkAssetOptIn(assetId: string | bigint, sender: string, client?: Algodv2): Promise<boolean> {\n const algorand = this.getAlgorand(client);\n return checkAssetOptIn(assetId, sender, algorand);\n }\n\n async buildRawTransactionAssetOptIn(\n assetId: string | bigint,\n sender: string,\n client?: Algodv2\n ): Promise<RawAlgTransaction> {\n const algorand = this.getAlgorand(client);\n if (typeof assetId === \"string\") {\n assetId = BigInt(assetId);\n }\n const tx = await algorand.createTransaction.assetOptIn({ assetId: assetId, sender: sender });\n return encodeTxs(tx);\n }\n\n async checkAppOptIn(appId: string | bigint, sender: string, client?: Algodv2): Promise<boolean> {\n const algorand = this.getAlgorand(client);\n return checkAppOptIn(appId, sender, algorand);\n }\n\n async buildRawTransactionAppOptIn(\n appId: string | bigint,\n sender: string,\n client?: Algodv2\n ): Promise<RawAlgTransaction> {\n const algorand = this.getAlgorand(client);\n if (typeof appId === \"string\") {\n appId = BigInt(appId);\n }\n\n const composer = algorand.newGroup();\n const signer = algorand.account.random();\n composer.addAppCallMethodCall({\n appId,\n method: new ABIMethod({\n name: \"optInToApplication\",\n desc: undefined,\n args: [],\n returns: { type: \"void\", desc: undefined },\n events: [],\n readonly: false,\n }),\n args: [],\n sender,\n signer: signer,\n onComplete: OnApplicationComplete.OptInOC,\n });\n const { transactions } = await composer.buildTransactions();\n return encodeTxs(...transactions);\n }\n\n private getAlgorand(client?: Algodv2): AlgorandClient {\n if (client) {\n const algorandClient = AlgorandClient.fromClients({ algod: client });\n algorandClient.setDefaultValidityWindow(100);\n return algorandClient;\n } else {\n const nodeRpcUrl = this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.ALG);\n const algorandClient = AlgorandClient.fromConfig({\n algodConfig: { server: nodeRpcUrl },\n });\n algorandClient.setDefaultValidityWindow(100);\n return algorandClient;\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "3.27.0-beta.3";
1
+ export declare const VERSION = "3.27.0-beta.5";
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "3.27.0-beta.3";
4
+ exports.VERSION = "3.27.0-beta.5";
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,eAAe,CAAC","sourcesContent":["export const VERSION = \"3.27.0-beta.3\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,eAAe,CAAC","sourcesContent":["export const VERSION = \"3.27.0-beta.5\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allbridge/bridge-core-sdk",
3
- "version": "3.27.0-beta.3",
3
+ "version": "3.27.0-beta.5",
4
4
  "main": "./dist/cjs/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -101,7 +101,7 @@
101
101
  "semver-regex": "3.1.4"
102
102
  },
103
103
  "dependencies": {
104
- "@algorandfoundation/algokit-utils": "^9.1.2",
104
+ "@algorandfoundation/algokit-utils": "^9.2.0",
105
105
  "@clarigen/core": "^3.1.0",
106
106
  "@mysten/sui": "1.18.0",
107
107
  "@project-serum/anchor": "^0.25.0",