@secondlayer/stacks 6.5.3 → 6.6.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.
Files changed (39) hide show
  1. package/dist/shared/{stacks-esm-s3natb0x.js → stacks-esm-75qv0d9h.js} +4 -4
  2. package/dist/shared/{stacks-esm-s3natb0x.js.map → stacks-esm-75qv0d9h.js.map} +3 -3
  3. package/dist/shared/{stacks-esm-jm688fhe.js → stacks-esm-8chm2wtn.js} +13 -5
  4. package/dist/shared/{stacks-esm-jm688fhe.js.map → stacks-esm-8chm2wtn.js.map} +4 -4
  5. package/dist/shared/{stacks-esm-17adzt3x.js → stacks-esm-p3rrvmd8.js} +2 -2
  6. package/dist/src/actions/index.cjs +12 -4
  7. package/dist/src/actions/index.cjs.map +5 -5
  8. package/dist/src/actions/index.d.cts +2 -0
  9. package/dist/src/actions/index.d.ts +2 -0
  10. package/dist/src/actions/index.js +3 -3
  11. package/dist/src/bns/index.cjs +12 -4
  12. package/dist/src/bns/index.cjs.map +5 -5
  13. package/dist/src/bns/index.js +2 -2
  14. package/dist/src/index.cjs +32 -5
  15. package/dist/src/index.cjs.map +6 -6
  16. package/dist/src/index.d.cts +8 -0
  17. package/dist/src/index.d.ts +8 -0
  18. package/dist/src/index.js +32 -6
  19. package/dist/src/index.js.map +4 -4
  20. package/dist/src/pox/index.cjs +12 -4
  21. package/dist/src/pox/index.cjs.map +5 -5
  22. package/dist/src/pox/index.js +2 -2
  23. package/dist/src/pox5/index.cjs +12 -4
  24. package/dist/src/pox5/index.cjs.map +5 -5
  25. package/dist/src/pox5/index.js +2 -2
  26. package/dist/src/sbtc/index.cjs +12 -4
  27. package/dist/src/sbtc/index.cjs.map +5 -5
  28. package/dist/src/sbtc/index.js +2 -2
  29. package/dist/src/stackingdao/index.cjs +12 -4
  30. package/dist/src/stackingdao/index.cjs.map +5 -5
  31. package/dist/src/stackingdao/index.js +2 -2
  32. package/dist/src/utils/index.cjs +7 -2
  33. package/dist/src/utils/index.cjs.map +3 -3
  34. package/dist/src/utils/index.d.cts +8 -1
  35. package/dist/src/utils/index.d.ts +8 -1
  36. package/dist/src/utils/index.js +7 -2
  37. package/dist/src/utils/index.js.map +3 -3
  38. package/package.json +2 -2
  39. /package/dist/shared/{stacks-esm-17adzt3x.js.map → stacks-esm-p3rrvmd8.js.map} +0 -0
@@ -17,8 +17,8 @@ import {
17
17
  getContract2,
18
18
  resolveNetworkContract,
19
19
  ContractResponseError2
20
- } from "../../shared/stacks-esm-s3natb0x.js";
21
- import"../../shared/stacks-esm-jm688fhe.js";
20
+ } from "../../shared/stacks-esm-75qv0d9h.js";
21
+ import"../../shared/stacks-esm-8chm2wtn.js";
22
22
  import"../../shared/stacks-esm-hm7kb2cp.js";
23
23
 
24
24
  // src/bns/abi.ts
@@ -3322,6 +3322,13 @@ function assertNoFeeTierForProvider(fee) {
3322
3322
  throw new Error(`Fee tier '${fee}' requires local signing; provider (wallet) accounts set their own fee`);
3323
3323
  }
3324
3324
  }
3325
+ function resolveCallArgs(params) {
3326
+ const { args, functionArgs } = params;
3327
+ if (args !== undefined && functionArgs !== undefined) {
3328
+ throw new Error("Pass args or functionArgs, not both (functionArgs is deprecated)");
3329
+ }
3330
+ return args ?? functionArgs ?? [];
3331
+ }
3325
3332
 
3326
3333
  // src/actions/wallet/callContract.ts
3327
3334
  async function callContract(client, params) {
@@ -3329,12 +3336,13 @@ async function callContract(client, params) {
3329
3336
  if (!account)
3330
3337
  throw new Error("Account required");
3331
3338
  const [contractAddress, contractName] = parseContractId(params.contract);
3339
+ const args = resolveCallArgs(params);
3332
3340
  if (isProviderAccount(account)) {
3333
3341
  assertNoFeeTierForProvider(params.fee);
3334
3342
  const result = await account.provider.request("stx_callContract", {
3335
3343
  contract: params.contract,
3336
3344
  functionName: params.functionName,
3337
- functionArgs: params.functionArgs ?? []
3345
+ functionArgs: args
3338
3346
  });
3339
3347
  return result.txid;
3340
3348
  }
@@ -3346,7 +3354,7 @@ async function callContract(client, params) {
3346
3354
  contractAddress,
3347
3355
  contractName,
3348
3356
  functionName: params.functionName,
3349
- functionArgs: params.functionArgs ?? [],
3357
+ functionArgs: args,
3350
3358
  fee: needsFeeResolution ? 0n : params.fee,
3351
3359
  nonce,
3352
3360
  publicKey: account.publicKey,
@@ -3601,8 +3609,27 @@ function walletActions(client) {
3601
3609
  }
3602
3610
 
3603
3611
  // src/clients/createWalletClient.ts
3612
+ function alignAccountToChain(account, chain) {
3613
+ if (!chain || account.type === "provider")
3614
+ return account;
3615
+ try {
3616
+ const [version, hash] = c32addressDecode(account.address);
3617
+ const keyHash = bytesToHex(hash160(hexToBytes(account.publicKey)));
3618
+ if (hash !== keyHash)
3619
+ return account;
3620
+ const target = chain.addressVersion.singleSig;
3621
+ if (version === target)
3622
+ return account;
3623
+ return { ...account, address: c32address(target, hash) };
3624
+ } catch {
3625
+ return account;
3626
+ }
3627
+ }
3604
3628
  function createWalletClient(config) {
3605
- return createClient(config).extend(walletActions);
3629
+ return createClient({
3630
+ ...config,
3631
+ account: alignAccountToChain(config.account, config.chain)
3632
+ }).extend(walletActions);
3606
3633
  }
3607
3634
  // src/clients/decorators/multisig.ts
3608
3635
  function multisigActions(client) {
@@ -3650,7 +3677,7 @@ function multisigActions(client) {
3650
3677
  contractAddress,
3651
3678
  contractName,
3652
3679
  functionName: params.functionName,
3653
- functionArgs: params.functionArgs ?? [],
3680
+ functionArgs: resolveCallArgs(params),
3654
3681
  fee: params.fee ?? 0n,
3655
3682
  nonce,
3656
3683
  publicKeys: signers,
@@ -4603,5 +4630,5 @@ function parseStx(stx) {
4603
4630
  return parseUnits(stx, 6);
4604
4631
  }
4605
4632
 
4606
- //# debugId=371D4F170108B2A564756E2164756E21
4633
+ //# debugId=C6D5879CCBDF8CEC64756E2164756E21
4607
4634
  //# sourceMappingURL=index.cjs.map