alkanesjs 1.2.5 → 1.2.6

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.
@@ -77638,10 +77638,17 @@ var TokenABI = abi.contract({
77638
77638
  initialize: abi.opcode(0n).custom(async function(opcode, params) {
77639
77639
  const parsed = paramSchema.safeParse(params.tokenParams);
77640
77640
  if (!parsed.success) {
77641
- return new BoxedError("InvalidParams" /* InvalidParams */, `Invalid parameters: ${parsed.error.message}`);
77641
+ return new BoxedError(
77642
+ "InvalidParams" /* InvalidParams */,
77643
+ `Invalid parameters: ${parsed.error.message}`
77644
+ );
77642
77645
  }
77643
- const nameEncoded = consumeOrThrow(new Encodable(parsed.data.name).encodeFrom("name"));
77644
- const symbolEncoded = consumeOrThrow(new Encodable(parsed.data.symbol).encodeFrom("char"));
77646
+ const nameEncoded = consumeOrThrow(
77647
+ new Encodable(parsed.data.name).encodeFrom("name")
77648
+ );
77649
+ const symbolEncoded = consumeOrThrow(
77650
+ new Encodable(parsed.data.symbol).encodeFrom("char")
77651
+ );
77645
77652
  const premine = (parsed.data.premine ?? 0n) * 10n ** DECIMALS;
77646
77653
  const valuePerMint = (parsed.data.valuePerMint ?? 0n) * 10n ** DECIMALS;
77647
77654
  const callData = [
@@ -77653,7 +77660,13 @@ var TokenABI = abi.contract({
77653
77660
  ...nameEncoded,
77654
77661
  ...symbolEncoded
77655
77662
  ];
77656
- const res = consumeOrThrow(await this.pushExecute({ signPsbt: this.signPsbt, address: params.address, callData }));
77663
+ const res = consumeOrThrow(
77664
+ await this.pushExecute({
77665
+ signPsbt: this.signPsbt,
77666
+ address: params.address,
77667
+ callData
77668
+ })
77669
+ );
77657
77670
  return new BoxedSuccess(res);
77658
77671
  }),
77659
77672
  mintTokens: abi.opcode(77n).execute().returns("uint8Array"),
@@ -77666,19 +77679,20 @@ var TokenABI = abi.contract({
77666
77679
  getData: abi.opcode(1000n).view().returns("uint8Array"),
77667
77680
  getBalance: abi.opcode(1002n).custom(async function(opcode, address3) {
77668
77681
  try {
77669
- const outpoints = consumeOrThrow(
77670
- await this.provider.rpc.alkanes.alkanes_getAlkanesByAddress(address3)
77671
- ).outpoints;
77682
+ const balances = consumeOrThrow(
77683
+ await this.provider.rpc.espo.getAddressBalances(address3)
77684
+ ).balances;
77672
77685
  const target2 = `${this.alkaneId.block.toString()}:${this.alkaneId.tx.toString()}`;
77673
- const balance = outpoints.reduce((acc, op) => {
77674
- const val = BigInt(
77675
- op.runes.find((e) => `${BigInt(e.rune.id.block)}:${BigInt(e.rune.id.tx)}` === target2)?.balance ?? "0"
77676
- );
77677
- return acc + val;
77678
- }, 0n);
77679
- return new BoxedSuccess(new DecodableAlkanesResponse(balance).decodeTo("tokenValue"));
77686
+ return new BoxedSuccess(
77687
+ new DecodableAlkanesResponse(BigInt(balances[target2]) ?? 0n).decodeTo(
77688
+ "tokenValue"
77689
+ )
77690
+ );
77680
77691
  } catch (err) {
77681
- return new BoxedError("UnknownError" /* UnknownError */, `Failed to fetch balance: ${err.message}`);
77692
+ return new BoxedError(
77693
+ "UnknownError" /* UnknownError */,
77694
+ `Failed to fetch balance: ${err.message}`
77695
+ );
77682
77696
  }
77683
77697
  })
77684
77698
  });