@gvnrdao/dh-sdk 0.0.316 → 0.0.317

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.
@@ -5,7 +5,7 @@
5
5
  * @license MIT
6
6
  */
7
7
 
8
- /*! Axios v1.18.1 Copyright (c) 2026 Matt Zabriskie and contributors */
8
+ /*! Axios v1.19.0 Copyright (c) 2026 Matt Zabriskie and contributors */
9
9
 
10
10
  /*! MIT License. Copyright 2015-2022 Richard Moore <me@ricmoo.com>. See LICENSE.txt. */
11
11
 
@@ -321,7 +321,7 @@ var SEPOLIA_DEPLOYMENT = {
321
321
  MOCK_USDC_TOKEN: "0x96409A98e0D322d6566b7F44a0fAbD1BD4ce2AEc",
322
322
  MOCK_USDT_TOKEN: "0xF8b7fB38b17a310960E47805Be9adba0b0e0394D",
323
323
  POSITION_DELEGATE_REGISTRY: "0x482369De283622E7b05731875ec137d4E3D208F9",
324
- POSITION_DELEGATE_REGISTRY_IMPL: "0x301fa9AA527016D033e151b982C64cD8670a39E3",
324
+ POSITION_DELEGATE_REGISTRY_IMPL: "0xc681c48688cdAA966119E265e4a378ef8Fe0eBcA",
325
325
  AGENT_MODULE: "0xefb8C29C1e7e92ed7d81a52dbedaed74e37fe380",
326
326
  FEE_RECIPIENT_REGISTRY: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
327
327
  FEE_RECIPIENT_REGISTRY_IMPL: "0xd08513a7cB2dd354B26cDDf549616F12054c34c9",
@@ -288,7 +288,7 @@ var SEPOLIA_DEPLOYMENT = {
288
288
  MOCK_USDC_TOKEN: "0x96409A98e0D322d6566b7F44a0fAbD1BD4ce2AEc",
289
289
  MOCK_USDT_TOKEN: "0xF8b7fB38b17a310960E47805Be9adba0b0e0394D",
290
290
  POSITION_DELEGATE_REGISTRY: "0x482369De283622E7b05731875ec137d4E3D208F9",
291
- POSITION_DELEGATE_REGISTRY_IMPL: "0x301fa9AA527016D033e151b982C64cD8670a39E3",
291
+ POSITION_DELEGATE_REGISTRY_IMPL: "0xc681c48688cdAA966119E265e4a378ef8Fe0eBcA",
292
292
  AGENT_MODULE: "0xefb8C29C1e7e92ed7d81a52dbedaed74e37fe380",
293
293
  FEE_RECIPIENT_REGISTRY: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
294
294
  FEE_RECIPIENT_REGISTRY_IMPL: "0xd08513a7cB2dd354B26cDDf549616F12054c34c9",
package/dist/index.d.ts CHANGED
@@ -51,7 +51,7 @@ export type { ProtocolEvent, ProtocolEventsFilter, ProtocolEventsResult, } from
51
51
  export { fetchProtocolPauseStatus, assertProtocolNotPaused, } from './protocol/protocol-pause';
52
52
  export type { ProtocolPauseStatus, ProtocolPauseKey, } from './protocol/protocol-pause';
53
53
  export { SDKError, ErrorCategory, ErrorSeverity } from './utils/error-handler';
54
- export { setPositionDelegate, getPositionDelegate } from './utils/position-delegate.utils';
54
+ export { setPositionDelegate, getPositionDelegate, isPositionDelegate, getDelegateStatus, DelegateDenyReason, } from './utils/position-delegate.utils';
55
55
  export { buildBtcExecuteEnvelope, } from './utils/btc-withdrawal-message';
56
56
  export type { BtcExecuteSignParams, BtcExecuteSignedEnvelope, } from './utils/btc-withdrawal-message';
57
57
  export { reconcileAuthorizedSpend, defaultHttpGetJson, } from './utils/withdrawal-reconciliation.utils';
package/dist/index.js CHANGED
@@ -346,7 +346,7 @@ var init_deployment_addresses = __esm({
346
346
  MOCK_USDC_TOKEN: "0x96409A98e0D322d6566b7F44a0fAbD1BD4ce2AEc",
347
347
  MOCK_USDT_TOKEN: "0xF8b7fB38b17a310960E47805Be9adba0b0e0394D",
348
348
  POSITION_DELEGATE_REGISTRY: "0x482369De283622E7b05731875ec137d4E3D208F9",
349
- POSITION_DELEGATE_REGISTRY_IMPL: "0x301fa9AA527016D033e151b982C64cD8670a39E3",
349
+ POSITION_DELEGATE_REGISTRY_IMPL: "0xc681c48688cdAA966119E265e4a378ef8Fe0eBcA",
350
350
  AGENT_MODULE: "0xefb8C29C1e7e92ed7d81a52dbedaed74e37fe380",
351
351
  FEE_RECIPIENT_REGISTRY: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
352
352
  FEE_RECIPIENT_REGISTRY_IMPL: "0xd08513a7cB2dd354B26cDDf549616F12054c34c9",
@@ -5583,6 +5583,7 @@ __export(src_exports, {
5583
5583
  CacheManager: () => CacheManager,
5584
5584
  ContractManager: () => ContractManager,
5585
5585
  DEFAULT_LIT_NETWORK: () => DEFAULT_LIT_NETWORK,
5586
+ DelegateDenyReason: () => DelegateDenyReason,
5586
5587
  DiamondHandsSDK: () => DiamondHandsSDK,
5587
5588
  ErrorCategory: () => ErrorCategory,
5588
5589
  ErrorSeverity: () => ErrorSeverity,
@@ -5631,6 +5632,7 @@ __export(src_exports, {
5631
5632
  firstSuccess: () => firstSuccess,
5632
5633
  fromPromise: () => fromPromise,
5633
5634
  getContractsByNetwork: () => getContractsByNetwork,
5635
+ getDelegateStatus: () => getDelegateStatus,
5634
5636
  getDeploymentByNetwork: () => getDeploymentByNetwork,
5635
5637
  getPositionDelegate: () => getPositionDelegate,
5636
5638
  isClosePositionAuth: () => isClosePositionAuth,
@@ -5638,6 +5640,7 @@ __export(src_exports, {
5638
5640
  isExtendTermAuth: () => isExtendTermAuth,
5639
5641
  isFailure: () => isFailure,
5640
5642
  isMintUCDAuth: () => isMintUCDAuth,
5643
+ isPositionDelegate: () => isPositionDelegate,
5641
5644
  isRepayDebtAuth: () => isRepayDebtAuth,
5642
5645
  isServiceModeConfig: () => isServiceModeConfig,
5643
5646
  isStandaloneModeConfig: () => isStandaloneModeConfig,
@@ -17922,9 +17925,20 @@ var AgentDelegationRegistry__factory = class extends import_ethers15.ContractFac
17922
17925
  var import_ethers16 = require("ethers");
17923
17926
  var POSITION_DELEGATE_REGISTRY_ABI = [
17924
17927
  "function positionDelegate(bytes32 positionId) view returns (address)",
17928
+ "function isDelegate(bytes32 positionId, address delegate) view returns (bool)",
17925
17929
  "function setPositionDelegate(bytes32 positionId, address newDelegate) external",
17926
17930
  "event PositionDelegateUpdated(bytes32 indexed positionId, address indexed oldDelegate, address indexed newDelegate)"
17927
17931
  ];
17932
+ var DelegateDenyReason = /* @__PURE__ */ ((DelegateDenyReason2) => {
17933
+ DelegateDenyReason2[DelegateDenyReason2["NONE"] = 0] = "NONE";
17934
+ DelegateDenyReason2[DelegateDenyReason2["PAUSED"] = 1] = "PAUSED";
17935
+ DelegateDenyReason2[DelegateDenyReason2["NO_DELEGATE"] = 2] = "NO_DELEGATE";
17936
+ DelegateDenyReason2[DelegateDenyReason2["NOT_DELEGATE"] = 3] = "NOT_DELEGATE";
17937
+ return DelegateDenyReason2;
17938
+ })(DelegateDenyReason || {});
17939
+ var DELEGATE_STATUS_ABI = [
17940
+ "function delegateStatus(bytes32 positionId, address delegate) view returns (bool ok, uint8 reason)"
17941
+ ];
17928
17942
  async function setPositionDelegate(positionId, delegate, signer, registryAddress) {
17929
17943
  const registry = new import_ethers16.Contract(
17930
17944
  registryAddress,
@@ -17941,6 +17955,28 @@ async function getPositionDelegate(positionId, provider, registryAddress) {
17941
17955
  );
17942
17956
  return registry["positionDelegate"](positionId);
17943
17957
  }
17958
+ async function isPositionDelegate(positionId, delegate, provider, registryAddress) {
17959
+ const registry = new import_ethers16.Contract(
17960
+ registryAddress,
17961
+ POSITION_DELEGATE_REGISTRY_ABI,
17962
+ provider
17963
+ );
17964
+ return registry["isDelegate"](positionId, delegate);
17965
+ }
17966
+ async function getDelegateStatus(positionId, delegate, provider, registryAddress) {
17967
+ const registry = new import_ethers16.Contract(
17968
+ registryAddress,
17969
+ DELEGATE_STATUS_ABI,
17970
+ provider
17971
+ );
17972
+ try {
17973
+ const [ok, reason] = await registry["delegateStatus"](positionId, delegate);
17974
+ return { ok: Boolean(ok), reason: Number(reason) };
17975
+ } catch {
17976
+ const ok = await isPositionDelegate(positionId, delegate, provider, registryAddress);
17977
+ return { ok, reason: ok ? 0 /* NONE */ : 3 /* NOT_DELEGATE */ };
17978
+ }
17979
+ }
17944
17980
 
17945
17981
  // src/utils/agent-delegation.utils.ts
17946
17982
  async function mintAgentPkp(params) {
@@ -25917,6 +25953,7 @@ var EventHelpers = {
25917
25953
  CacheManager,
25918
25954
  ContractManager,
25919
25955
  DEFAULT_LIT_NETWORK,
25956
+ DelegateDenyReason,
25920
25957
  DiamondHandsSDK,
25921
25958
  ErrorCategory,
25922
25959
  ErrorSeverity,
@@ -25964,6 +26001,7 @@ var EventHelpers = {
25964
26001
  firstSuccess,
25965
26002
  fromPromise,
25966
26003
  getContractsByNetwork,
26004
+ getDelegateStatus,
25967
26005
  getDeploymentByNetwork,
25968
26006
  getPositionDelegate,
25969
26007
  isClosePositionAuth,
@@ -25971,6 +26009,7 @@ var EventHelpers = {
25971
26009
  isExtendTermAuth,
25972
26010
  isFailure,
25973
26011
  isMintUCDAuth,
26012
+ isPositionDelegate,
25974
26013
  isRepayDebtAuth,
25975
26014
  isServiceModeConfig,
25976
26015
  isStandaloneModeConfig,
package/dist/index.mjs CHANGED
@@ -352,7 +352,7 @@ var init_deployment_addresses = __esm({
352
352
  MOCK_USDC_TOKEN: "0x96409A98e0D322d6566b7F44a0fAbD1BD4ce2AEc",
353
353
  MOCK_USDT_TOKEN: "0xF8b7fB38b17a310960E47805Be9adba0b0e0394D",
354
354
  POSITION_DELEGATE_REGISTRY: "0x482369De283622E7b05731875ec137d4E3D208F9",
355
- POSITION_DELEGATE_REGISTRY_IMPL: "0x301fa9AA527016D033e151b982C64cD8670a39E3",
355
+ POSITION_DELEGATE_REGISTRY_IMPL: "0xc681c48688cdAA966119E265e4a378ef8Fe0eBcA",
356
356
  AGENT_MODULE: "0xefb8C29C1e7e92ed7d81a52dbedaed74e37fe380",
357
357
  FEE_RECIPIENT_REGISTRY: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
358
358
  FEE_RECIPIENT_REGISTRY_IMPL: "0xd08513a7cB2dd354B26cDDf549616F12054c34c9",
@@ -17851,9 +17851,20 @@ var AgentDelegationRegistry__factory = class extends ContractFactory2 {
17851
17851
  import { Contract as Contract8 } from "ethers";
17852
17852
  var POSITION_DELEGATE_REGISTRY_ABI = [
17853
17853
  "function positionDelegate(bytes32 positionId) view returns (address)",
17854
+ "function isDelegate(bytes32 positionId, address delegate) view returns (bool)",
17854
17855
  "function setPositionDelegate(bytes32 positionId, address newDelegate) external",
17855
17856
  "event PositionDelegateUpdated(bytes32 indexed positionId, address indexed oldDelegate, address indexed newDelegate)"
17856
17857
  ];
17858
+ var DelegateDenyReason = /* @__PURE__ */ ((DelegateDenyReason2) => {
17859
+ DelegateDenyReason2[DelegateDenyReason2["NONE"] = 0] = "NONE";
17860
+ DelegateDenyReason2[DelegateDenyReason2["PAUSED"] = 1] = "PAUSED";
17861
+ DelegateDenyReason2[DelegateDenyReason2["NO_DELEGATE"] = 2] = "NO_DELEGATE";
17862
+ DelegateDenyReason2[DelegateDenyReason2["NOT_DELEGATE"] = 3] = "NOT_DELEGATE";
17863
+ return DelegateDenyReason2;
17864
+ })(DelegateDenyReason || {});
17865
+ var DELEGATE_STATUS_ABI = [
17866
+ "function delegateStatus(bytes32 positionId, address delegate) view returns (bool ok, uint8 reason)"
17867
+ ];
17857
17868
  async function setPositionDelegate(positionId, delegate, signer, registryAddress) {
17858
17869
  const registry = new Contract8(
17859
17870
  registryAddress,
@@ -17870,6 +17881,28 @@ async function getPositionDelegate(positionId, provider, registryAddress) {
17870
17881
  );
17871
17882
  return registry["positionDelegate"](positionId);
17872
17883
  }
17884
+ async function isPositionDelegate(positionId, delegate, provider, registryAddress) {
17885
+ const registry = new Contract8(
17886
+ registryAddress,
17887
+ POSITION_DELEGATE_REGISTRY_ABI,
17888
+ provider
17889
+ );
17890
+ return registry["isDelegate"](positionId, delegate);
17891
+ }
17892
+ async function getDelegateStatus(positionId, delegate, provider, registryAddress) {
17893
+ const registry = new Contract8(
17894
+ registryAddress,
17895
+ DELEGATE_STATUS_ABI,
17896
+ provider
17897
+ );
17898
+ try {
17899
+ const [ok, reason] = await registry["delegateStatus"](positionId, delegate);
17900
+ return { ok: Boolean(ok), reason: Number(reason) };
17901
+ } catch {
17902
+ const ok = await isPositionDelegate(positionId, delegate, provider, registryAddress);
17903
+ return { ok, reason: ok ? 0 /* NONE */ : 3 /* NOT_DELEGATE */ };
17904
+ }
17905
+ }
17873
17906
 
17874
17907
  // src/utils/agent-delegation.utils.ts
17875
17908
  async function mintAgentPkp(params) {
@@ -25845,6 +25878,7 @@ export {
25845
25878
  CacheManager,
25846
25879
  ContractManager,
25847
25880
  DEFAULT_LIT_NETWORK,
25881
+ DelegateDenyReason,
25848
25882
  DiamondHandsSDK,
25849
25883
  ErrorCategory,
25850
25884
  ErrorSeverity,
@@ -25893,6 +25927,7 @@ export {
25893
25927
  firstSuccess,
25894
25928
  fromPromise,
25895
25929
  getContractsByNetwork,
25930
+ getDelegateStatus,
25896
25931
  getDeploymentByNetwork,
25897
25932
  getPositionDelegate,
25898
25933
  isClosePositionAuth,
@@ -25900,6 +25935,7 @@ export {
25900
25935
  isExtendTermAuth,
25901
25936
  isFailure,
25902
25937
  isMintUCDAuth,
25938
+ isPositionDelegate,
25903
25939
  isRepayDebtAuth,
25904
25940
  isServiceModeConfig,
25905
25941
  isStandaloneModeConfig,
@@ -12,6 +12,13 @@
12
12
  * and cannot carry the additional storage + setter without going over.
13
13
  */
14
14
  import { type Signer, type Provider, type TransactionResponse } from "ethers";
15
+ /** Registry v2.0.0 `delegateStatus` deny reasons. */
16
+ export declare enum DelegateDenyReason {
17
+ NONE = 0,
18
+ PAUSED = 1,
19
+ NO_DELEGATE = 2,
20
+ NOT_DELEGATE = 3
21
+ }
15
22
  /**
16
23
  * Register (or revoke) the off-chain authorization delegate for a position.
17
24
  *
@@ -30,6 +37,15 @@ export declare function setPositionDelegate(positionId: string, delegate: string
30
37
  /**
31
38
  * Read the currently registered delegate for a position.
32
39
  *
40
+ * PROVENANCE ONLY — do NOT use this to make an authorization decision. This reads the raw
41
+ * `positionDelegate` mapping, which is a public getter and therefore CANNOT reflect the
42
+ * registry's pause kill-switch or its revoked-address burn set: it will happily return a
43
+ * delegate the registry itself denies. Use {@link isPositionDelegate} for any
44
+ * "may this address act?" question.
45
+ *
46
+ * Legitimate uses: displaying who is configured, and the idempotence check before
47
+ * `setPositionDelegate` (both care about what is stored, not whether it is currently usable).
48
+ *
33
49
  * Returns the zero address when no delegate has been registered. Pure view;
34
50
  * any provider works (signer not required).
35
51
  *
@@ -39,3 +55,33 @@ export declare function setPositionDelegate(positionId: string, delegate: string
39
55
  * @returns The delegate EOA, or zero address if none.
40
56
  */
41
57
  export declare function getPositionDelegate(positionId: string, provider: Provider | Signer, registryAddress: string): Promise<string>;
58
+ /**
59
+ * THE authorization read: may `delegate` act for `positionId` right now?
60
+ *
61
+ * Calls the registry's `isDelegate` gate, which folds in the pause kill-switch and the
62
+ * permanent burn set — unlike {@link getPositionDelegate}, which reads the ungated mapping.
63
+ *
64
+ * Version-agnostic by construction: `isDelegate` has existed since registry v1.1.0 with this
65
+ * exact `(bytes32,address) returns (bool)` signature, so the selector is identical across
66
+ * versions. v2.0.0 only makes it strictly MORE restrictive (additionally denying when paused
67
+ * or burned), never more permissive — so this is safe against an un-upgraded registry too.
68
+ *
69
+ * @param positionId Position identifier (bytes32).
70
+ * @param delegate Candidate delegate address.
71
+ * @param provider Ethers provider or signer.
72
+ * @param registryAddress Deployed `PositionDelegateRegistry` address.
73
+ */
74
+ export declare function isPositionDelegate(positionId: string, delegate: string, provider: Provider | Signer, registryAddress: string): Promise<boolean>;
75
+ /**
76
+ * Same gate as {@link isPositionDelegate} but returns WHY it was denied, so a UI can say
77
+ * "delegation is paused" instead of the misleading "no delegate configured".
78
+ *
79
+ * `delegateStatus` is a v2.0.0-only selector. On an older registry the call reverts, and this
80
+ * falls back to `isDelegate` — a clean feature-detect, which is exactly why the reason was added
81
+ * as a NEW function rather than by changing `isDelegate`'s return type (that would have been a
82
+ * silent decode hazard across versions, since the selector would not have changed).
83
+ */
84
+ export declare function getDelegateStatus(positionId: string, delegate: string, provider: Provider | Signer, registryAddress: string): Promise<{
85
+ ok: boolean;
86
+ reason: DelegateDenyReason;
87
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gvnrdao/dh-sdk",
3
- "version": "0.0.316",
3
+ "version": "0.0.317",
4
4
  "description": "TypeScript SDK for Diamond Hands Protocol - Bitcoin-backed lending with LIT Protocol PKPs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",