@augustdigital/sdk 8.22.1 → 8.24.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.
@@ -3,4 +3,4 @@
3
3
  * Generated during publish from package.json version
4
4
  * This file is gitignored and created at publish time
5
5
  */
6
- export declare const SDK_VERSION = "8.22.1";
6
+ export declare const SDK_VERSION = "8.24.0";
@@ -6,5 +6,5 @@ exports.SDK_VERSION = void 0;
6
6
  * Generated during publish from package.json version
7
7
  * This file is gitignored and created at publish time
8
8
  */
9
- exports.SDK_VERSION = '8.22.1';
9
+ exports.SDK_VERSION = '8.24.0';
10
10
  //# sourceMappingURL=version.js.map
@@ -42,10 +42,15 @@ export interface IAttributionConfig {
42
42
  /**
43
43
  * EVM chain IDs to attribute. Omit to attribute writes on every EVM chain
44
44
  * (the suffix is inert on chains without an ERC-8021 indexer and costs
45
- * ~16 gas per non-zero byte). When set, writes on other chains are sent
46
- * without the suffix; call sites that cannot determine their chain ID
47
- * append the suffix regardless, since over-attribution is harmless and
48
- * under-attribution loses data.
45
+ * ~16 gas per non-zero byte). When set, gating is fail-closed: writes on
46
+ * other chains and writes whose chain ID cannot be determined are sent
47
+ * without the suffix.
48
+ *
49
+ * Over-attribution is not harmless. The suffix makes calldata longer than
50
+ * the ABI encoding of the call, which breaks clear-signing on hardware
51
+ * wallets: a Ledger rejects an over-long ERC-20 `approve` with
52
+ * `EthAppCommandError: Invalid data 6a80`, so an unattributed chain that
53
+ * receives the suffix anyway cannot be transacted on from a Ledger at all.
49
54
  */
50
55
  chains?: number[];
51
56
  }
@@ -83,13 +88,23 @@ export declare function buildAttributionSuffix(codes: string[]): string;
83
88
  * init, not on the first write.
84
89
  */
85
90
  export declare function setAttribution(config: IAttributionConfig | null): void;
91
+ /**
92
+ * Whether attribution is configured at all, independent of any chain gate.
93
+ *
94
+ * Call sites that need to know whether to resolve a chain ID before asking
95
+ * for the suffix use this; {@link getAttributionSuffix} applies the gate.
96
+ *
97
+ * @returns `true` when builder codes are configured.
98
+ */
99
+ export declare function isAttributionEnabled(): boolean;
86
100
  /**
87
101
  * Return the active ERC-8021 suffix for a write on the given chain, or
88
- * `undefined` when attribution is off or the chain is excluded.
102
+ * `undefined` when attribution is off or the chain is not attributed.
89
103
  *
90
104
  * @param chainId EVM chain ID of the transaction, when the call site knows
91
- * it. When omitted and a `chains` restriction is configured, the suffix is
92
- * returned anyway (over-attribution is harmless; see
105
+ * it. When a `chains` restriction is configured, gating is fail-closed: an
106
+ * omitted chain ID yields no suffix, since a suffix on an unattributed
107
+ * chain buys nothing and breaks hardware-wallet clear-signing (see
93
108
  * {@link IAttributionConfig.chains}).
94
109
  * @returns `0x`-prefixed hex suffix, or `undefined` when nothing should be
95
110
  * appended.
@@ -99,7 +114,8 @@ export declare function getAttributionSuffix(chainId?: number): string | undefin
99
114
  * Append the active attribution suffix to calldata.
100
115
  *
101
116
  * No-ops (returns `data` unchanged) when attribution is off, the chain is
102
- * excluded, `data` is empty/absent (plain value transfers are never
117
+ * not attributed (including an unknown chain under a `chains` restriction),
118
+ * `data` is empty/absent (plain value transfers are never
103
119
  * attributed), or `data` already ends with the ERC-8021 marker (guards
104
120
  * against double-appending when an upstream layer — e.g. a wagmi config
105
121
  * `dataSuffix` — already attributed the transaction).
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.ERC8021_MARKER = void 0;
19
19
  exports.buildAttributionSuffix = buildAttributionSuffix;
20
20
  exports.setAttribution = setAttribution;
21
+ exports.isAttributionEnabled = isAttributionEnabled;
21
22
  exports.getAttributionSuffix = getAttributionSuffix;
22
23
  exports.appendAttributionSuffix = appendAttributionSuffix;
23
24
  /**
@@ -96,13 +97,25 @@ function setAttribution(config) {
96
97
  ? config.chains
97
98
  : null;
98
99
  }
100
+ /**
101
+ * Whether attribution is configured at all, independent of any chain gate.
102
+ *
103
+ * Call sites that need to know whether to resolve a chain ID before asking
104
+ * for the suffix use this; {@link getAttributionSuffix} applies the gate.
105
+ *
106
+ * @returns `true` when builder codes are configured.
107
+ */
108
+ function isAttributionEnabled() {
109
+ return activeSuffix !== null;
110
+ }
99
111
  /**
100
112
  * Return the active ERC-8021 suffix for a write on the given chain, or
101
- * `undefined` when attribution is off or the chain is excluded.
113
+ * `undefined` when attribution is off or the chain is not attributed.
102
114
  *
103
115
  * @param chainId EVM chain ID of the transaction, when the call site knows
104
- * it. When omitted and a `chains` restriction is configured, the suffix is
105
- * returned anyway (over-attribution is harmless; see
116
+ * it. When a `chains` restriction is configured, gating is fail-closed: an
117
+ * omitted chain ID yields no suffix, since a suffix on an unattributed
118
+ * chain buys nothing and breaks hardware-wallet clear-signing (see
106
119
  * {@link IAttributionConfig.chains}).
107
120
  * @returns `0x`-prefixed hex suffix, or `undefined` when nothing should be
108
121
  * appended.
@@ -110,7 +123,9 @@ function setAttribution(config) {
110
123
  function getAttributionSuffix(chainId) {
111
124
  if (!activeSuffix)
112
125
  return undefined;
113
- if (activeChains && typeof chainId === 'number') {
126
+ if (activeChains) {
127
+ if (typeof chainId !== 'number')
128
+ return undefined;
114
129
  if (!activeChains.includes(chainId))
115
130
  return undefined;
116
131
  }
@@ -120,7 +135,8 @@ function getAttributionSuffix(chainId) {
120
135
  * Append the active attribution suffix to calldata.
121
136
  *
122
137
  * No-ops (returns `data` unchanged) when attribution is off, the chain is
123
- * excluded, `data` is empty/absent (plain value transfers are never
138
+ * not attributed (including an unknown chain under a `chains` restriction),
139
+ * `data` is empty/absent (plain value transfers are never
124
140
  * attributed), or `data` already ends with the ERC-8021 marker (guards
125
141
  * against double-appending when an upstream layer — e.g. a wagmi config
126
142
  * `dataSuffix` — already attributed the transaction).
@@ -44,7 +44,8 @@ export type CompatibleSigner = Signer | Wallet | any;
44
44
  * already ending in the ERC-8021 marker is left untouched. When the
45
45
  * configured `chains` list requires a chain check and the transaction does
46
46
  * not carry a `chainId`, the signer's provider network is consulted (one
47
- * cached RPC call).
47
+ * cached RPC call); if that lookup fails the transaction is sent
48
+ * unattributed.
48
49
  *
49
50
  * @param signer Normalized ethers Signer or Wallet.
50
51
  * @returns A proxied signer with an attribution-aware `sendTransaction`.
@@ -107,7 +107,8 @@ async function normalizeSigner(signer) {
107
107
  * already ending in the ERC-8021 marker is left untouched. When the
108
108
  * configured `chains` list requires a chain check and the transaction does
109
109
  * not carry a `chainId`, the signer's provider network is consulted (one
110
- * cached RPC call).
110
+ * cached RPC call); if that lookup fails the transaction is sent
111
+ * unattributed.
111
112
  *
112
113
  * @param signer Normalized ethers Signer or Wallet.
113
114
  * @returns A proxied signer with an attribution-aware `sendTransaction`.
@@ -117,7 +118,7 @@ function wrapSignerWithAttribution(signer) {
117
118
  get(target, prop) {
118
119
  if (prop === 'sendTransaction') {
119
120
  return async (tx) => {
120
- if (!(0, attribution_1.getAttributionSuffix)() || typeof tx?.data !== 'string') {
121
+ if (!(0, attribution_1.isAttributionEnabled)() || typeof tx?.data !== 'string') {
121
122
  return target.sendTransaction(tx);
122
123
  }
123
124
  let chainId = tx.chainId != null ? Number(tx.chainId) : undefined;
@@ -126,9 +127,10 @@ function wrapSignerWithAttribution(signer) {
126
127
  chainId = Number((await target.provider.getNetwork()).chainId);
127
128
  }
128
129
  catch {
129
- // Unknown chain: fall through with chainId undefined, which
130
- // appends regardless of a `chains` restriction —
131
- // over-attribution is harmless, under-attribution loses data.
130
+ // Unknown chain: fall through with chainId undefined. Under a
131
+ // `chains` restriction that means no suffix attributing a
132
+ // chain we cannot identify risks breaking hardware-wallet
133
+ // clear-signing for a gain we cannot confirm.
132
134
  }
133
135
  }
134
136
  const data = (0, attribution_1.appendAttributionSuffix)(tx.data, chainId);
@@ -43,6 +43,10 @@ export declare function needsCrossChainApproval(tokenAddress: IAddress, spenderA
43
43
  /**
44
44
  * Execute a token approval for a cross-chain operation.
45
45
  *
46
+ * @param chainId Chain the approval is sent on, used to gate ERC-8021
47
+ * attribution. Omitted means unattributed under a `chains` restriction —
48
+ * the suffix would lengthen `approve` calldata past its ABI encoding and
49
+ * break Ledger clear-signing.
46
50
  * @returns Transaction hash of the approval
47
51
  */
48
52
  export declare function approveCrossChain(tokenAddress: IAddress, spenderAddress: IAddress, amount: bigint, walletClient: {
@@ -56,7 +60,7 @@ export declare function approveCrossChain(tokenAddress: IAddress, spenderAddress
56
60
  }) => Promise<{
57
61
  status: string;
58
62
  }>;
59
- }): Promise<string>;
63
+ }, chainId?: number): Promise<string>;
60
64
  /**
61
65
  * Execute a cross-chain deposit via LayerZero OVault. Validates the source
62
66
  * chain, ensures approval, estimates gas with a buffer, and waits for the
@@ -526,9 +526,13 @@ async function needsCrossChainApproval(tokenAddress, spenderAddress, walletAddre
526
526
  /**
527
527
  * Execute a token approval for a cross-chain operation.
528
528
  *
529
+ * @param chainId Chain the approval is sent on, used to gate ERC-8021
530
+ * attribution. Omitted means unattributed under a `chains` restriction —
531
+ * the suffix would lengthen `approve` calldata past its ABI encoding and
532
+ * break Ledger clear-signing.
529
533
  * @returns Transaction hash of the approval
530
534
  */
531
- async function approveCrossChain(tokenAddress, spenderAddress, amount, walletClient, publicClient) {
535
+ async function approveCrossChain(tokenAddress, spenderAddress, amount, walletClient, publicClient, chainId) {
532
536
  if (!walletClient.account) {
533
537
  throw new Error('Wallet not ready — please reconnect your wallet');
534
538
  }
@@ -538,7 +542,7 @@ async function approveCrossChain(tokenAddress, spenderAddress, amount, walletCli
538
542
  abi: OFT_1.ABI_CROSS_CHAIN_ERC20,
539
543
  functionName: 'approve',
540
544
  args: [spenderAddress, amount],
541
- dataSuffix: (0, attribution_1.getAttributionSuffix)(),
545
+ dataSuffix: (0, attribution_1.getAttributionSuffix)(chainId),
542
546
  });
543
547
  const receipt = await publicClient.waitForTransactionReceipt({
544
548
  hash: hash,
@@ -595,7 +599,7 @@ async function crossChainVaultDeposit(props) {
595
599
  BigInt((0, core_1.toNormalizedBn)(props.amount, props.decimals).raw);
596
600
  const approvalNeeded = await needsCrossChainApproval(tokenAddr, spenderAddr, props.walletAddress, approvalAmount, publicClient);
597
601
  if (approvalNeeded) {
598
- await approveCrossChain(tokenAddr, spenderAddr, approvalAmount, walletClient, publicClient);
602
+ await approveCrossChain(tokenAddr, spenderAddr, approvalAmount, walletClient, publicClient, props.userChainId);
599
603
  }
600
604
  }
601
605
  // 3. Estimate gas with buffer
@@ -678,7 +682,7 @@ async function crossChainVaultRedeem(props) {
678
682
  if (!props.skipApprovalCheck && txInputs.approval) {
679
683
  const approvalNeeded = await needsCrossChainApproval(txInputs.approval.tokenAddress, txInputs.approval.spender, props.walletAddress, txInputs.approval.amount, publicClient);
680
684
  if (approvalNeeded) {
681
- await approveCrossChain(txInputs.approval.tokenAddress, txInputs.approval.spender, txInputs.approval.amount, walletClient, publicClient);
685
+ await approveCrossChain(txInputs.approval.tokenAddress, txInputs.approval.spender, txInputs.approval.amount, walletClient, publicClient, props.config.hubChainId);
682
686
  }
683
687
  }
684
688
  // 4. Estimate gas with buffer
package/lib/sdk.d.ts CHANGED
@@ -15020,7 +15020,8 @@ export declare function allowance(signer: IContractRunner, options: IAllowanceOp
15020
15020
  * Append the active attribution suffix to calldata.
15021
15021
  *
15022
15022
  * No-ops (returns `data` unchanged) when attribution is off, the chain is
15023
- * excluded, `data` is empty/absent (plain value transfers are never
15023
+ * not attributed (including an unknown chain under a `chains` restriction),
15024
+ * `data` is empty/absent (plain value transfers are never
15024
15025
  * attributed), or `data` already ends with the ERC-8021 marker (guards
15025
15026
  * against double-appending when an upstream layer — e.g. a wagmi config
15026
15027
  * `dataSuffix` — already attributed the transaction).
@@ -15065,6 +15066,10 @@ export declare function approve(signer: Signer | Wallet, options: IContractWrite
15065
15066
  /**
15066
15067
  * Execute a token approval for a cross-chain operation.
15067
15068
  *
15069
+ * @param chainId Chain the approval is sent on, used to gate ERC-8021
15070
+ * attribution. Omitted means unattributed under a `chains` restriction —
15071
+ * the suffix would lengthen `approve` calldata past its ABI encoding and
15072
+ * break Ledger clear-signing.
15068
15073
  * @returns Transaction hash of the approval
15069
15074
  */
15070
15075
  export declare function approveCrossChain(tokenAddress: IAddress, spenderAddress: IAddress, amount: bigint, walletClient: {
@@ -15078,7 +15083,7 @@ export declare function approveCrossChain(tokenAddress: IAddress, spenderAddress
15078
15083
  }) => Promise<{
15079
15084
  status: string;
15080
15085
  }>;
15081
- }): Promise<string>;
15086
+ }, chainId?: number): Promise<string>;
15082
15087
 
15083
15088
  /**
15084
15089
  * Discriminated union returned by {@link approve}. Lets callers tell apart
@@ -18277,11 +18282,12 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
18277
18282
 
18278
18283
  /**
18279
18284
  * Return the active ERC-8021 suffix for a write on the given chain, or
18280
- * `undefined` when attribution is off or the chain is excluded.
18285
+ * `undefined` when attribution is off or the chain is not attributed.
18281
18286
  *
18282
18287
  * @param chainId EVM chain ID of the transaction, when the call site knows
18283
- * it. When omitted and a `chains` restriction is configured, the suffix is
18284
- * returned anyway (over-attribution is harmless; see
18288
+ * it. When a `chains` restriction is configured, gating is fail-closed: an
18289
+ * omitted chain ID yields no suffix, since a suffix on an unattributed
18290
+ * chain buys nothing and breaks hardware-wallet clear-signing (see
18285
18291
  * {@link IAttributionConfig.chains}).
18286
18292
  * @returns `0x`-prefixed hex suffix, or `undefined` when nothing should be
18287
18293
  * appended.
@@ -19649,10 +19655,15 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
19649
19655
  /**
19650
19656
  * EVM chain IDs to attribute. Omit to attribute writes on every EVM chain
19651
19657
  * (the suffix is inert on chains without an ERC-8021 indexer and costs
19652
- * ~16 gas per non-zero byte). When set, writes on other chains are sent
19653
- * without the suffix; call sites that cannot determine their chain ID
19654
- * append the suffix regardless, since over-attribution is harmless and
19655
- * under-attribution loses data.
19658
+ * ~16 gas per non-zero byte). When set, gating is fail-closed: writes on
19659
+ * other chains and writes whose chain ID cannot be determined are sent
19660
+ * without the suffix.
19661
+ *
19662
+ * Over-attribution is not harmless. The suffix makes calldata longer than
19663
+ * the ABI encoding of the call, which breaks clear-signing on hardware
19664
+ * wallets: a Ledger rejects an over-long ERC-20 `approve` with
19665
+ * `EthAppCommandError: Invalid data 6a80`, so an unattributed chain that
19666
+ * receives the suffix anyway cannot be transacted on from a Ledger at all.
19656
19667
  */
19657
19668
  chains?: number[];
19658
19669
  }
@@ -21066,6 +21077,16 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
21066
21077
  */
21067
21078
  export declare function isAnalyticsForcedOnViaEnv(): boolean;
21068
21079
 
21080
+ /**
21081
+ * Whether attribution is configured at all, independent of any chain gate.
21082
+ *
21083
+ * Call sites that need to know whether to resolve a chain ID before asking
21084
+ * for the suffix use this; {@link getAttributionSuffix} applies the gate.
21085
+ *
21086
+ * @returns `true` when builder codes are configured.
21087
+ */
21088
+ export declare function isAttributionEnabled(): boolean;
21089
+
21069
21090
  /** Type guard. Works across realms (e.g. Web Worker / VM contexts). */
21070
21091
  export declare function isAugustSDKError(err: unknown): err is AugustSDKError;
21071
21092
 
@@ -26834,7 +26855,8 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
26834
26855
  * already ending in the ERC-8021 marker is left untouched. When the
26835
26856
  * configured `chains` list requires a chain check and the transaction does
26836
26857
  * not carry a `chainId`, the signer's provider network is consulted (one
26837
- * cached RPC call).
26858
+ * cached RPC call); if that lookup fails the transaction is sent
26859
+ * unattributed.
26838
26860
  *
26839
26861
  * @param signer Normalized ethers Signer or Wallet.
26840
26862
  * @returns A proxied signer with an attribution-aware `sendTransaction`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augustdigital/sdk",
3
- "version": "8.22.1",
3
+ "version": "8.24.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/sdk.d.ts",
6
6
  "keywords": [