Skip to content

Commit 849e9b8

Browse files
MaximusHaximusAnsonhkg
authored andcommitted
fix(node-client-nodejs): LIT-2658 - Fix createCapacityDelegationAuthSig() creating auth sigs that are not usable by anyone when caller provides no delegateeAddresses
1 parent 90db139 commit 849e9b8

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ interface CapacityCreditsRes {
122122
capacityDelegationAuthSig: AuthSig;
123123
}
124124

125-
/** ---------- Main Export Class ---------- */
126-
127125
export class LitNodeClientNodeJs
128126
extends LitCore
129127
implements LitClientSessionManager
@@ -180,19 +178,13 @@ export class LitNodeClientNodeJs
180178
const {
181179
dAppOwnerWallet,
182180
capacityTokenId,
181+
delegateeAddresses,
183182
uses,
184183
domain,
185184
expiration,
186185
statement,
187186
} = params;
188187

189-
let { delegateeAddresses } = params;
190-
191-
// -- if delegateeAddresses is not provided, set it to an empty array
192-
if (!delegateeAddresses) {
193-
delegateeAddresses = [];
194-
}
195-
196188
// -- This is the owner address who holds the Capacity Credits NFT token and wants to delegate its
197189
// usage to a list of delegatee addresses
198190
const dAppOwnerWalletAddress = ethers.utils.getAddress(
@@ -223,13 +215,6 @@ export class LitNodeClientNodeJs
223215
// throw new Error('dAppOwnerWallet must be an ethers wallet');
224216
// }
225217

226-
// -- Strip the 0x prefix from each element in the addresses array if it exists
227-
if (delegateeAddresses && delegateeAddresses.length > 0) {
228-
delegateeAddresses = delegateeAddresses.map((address) =>
229-
address.startsWith('0x') ? address.slice(2) : address
230-
);
231-
}
232-
233218
// -- create LitRLIResource
234219
// Note: we have other resources such as LitAccessControlConditionResource, LitPKPResource and LitActionResource)
235220
// lit-ratelimitincrease://{tokenId}
@@ -241,7 +226,13 @@ export class LitNodeClientNodeJs
241226

242227
const capabilities = {
243228
...(capacityTokenId ? { nft_id: [capacityTokenId] } : {}), // Conditionally include nft_id
244-
delegate_to: delegateeAddresses,
229+
...(delegateeAddresses
230+
? {
231+
delegate_to: delegateeAddresses.map((address) =>
232+
address.startsWith('0x') ? address.slice(2) : address
233+
),
234+
}
235+
: {}),
245236
uses: _uses.toString(),
246237
};
247238

0 commit comments

Comments
 (0)