Skip to content

Commit c3b6331

Browse files
committed
feat(networks): update @lit-protocol/contracts to version 0.2.3 and add SIGN_SESSION_KEY to pricing constants
1 parent 52a529f commit c3b6331

File tree

22 files changed

+2265
-24
lines changed

22 files changed

+2265
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"private": true,
3535
"dependencies": {
3636
"@dotenvx/dotenvx": "^1.6.4",
37-
"@lit-protocol/contracts": "^0.2.0",
37+
"@lit-protocol/contracts": "^0.2.3",
3838
"@lit-protocol/nacl": "7.1.1",
3939
"@lit-protocol/uint8arrays": "7.1.1",
4040
"@metamask/eth-sig-util": "5.0.2",

packages/networks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"directory": "../../dist/packages/networks"
1919
},
2020
"dependencies": {
21-
"@lit-protocol/contracts": "^0.2.1",
21+
"@lit-protocol/contracts": "^0.2.3",
2222
"@lit-protocol/nacl": "7.1.1",
2323
"@noble/curves": "^1.8.1",
2424
"@wagmi/core": "^2.17.1",

packages/networks/src/networks/vNaga/envs/naga-dev/api-manager/e2ee-request-manager/E2EERequestManager.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const handleEncryptedError = (
126126
// Try to decrypt the error payload to get the actual error message
127127
try {
128128
_logger.info(
129-
`${operationName}: Attempting to decrypt error payload for detailed error information...`
129+
`"${operationName}": Attempting to decrypt error payload for detailed error information...`
130130
);
131131

132132
const errorAsEncryptedPayload = {
@@ -145,7 +145,7 @@ const handleEncryptedError = (
145145
);
146146

147147
_logger.error(
148-
`${operationName}: Decrypted error details from nodes:`,
148+
`"${operationName}": Decrypted error details from nodes:`,
149149
decryptedErrorValues
150150
);
151151

@@ -157,35 +157,35 @@ const handleEncryptedError = (
157157
? `. Details: ${firstError.errorObject}`
158158
: '';
159159
throw new Error(
160-
`${operationName} failed. ${errorMessage}${errorDetails}`
160+
`"${operationName}" failed. ${errorMessage}${errorDetails}`
161161
);
162162
}
163163

164164
// If no specific error field, show the full decrypted response
165165
throw new Error(
166-
`${operationName} failed. ${JSON.stringify(decryptedErrorValues)}`
166+
`"${operationName}" failed. ${JSON.stringify(decryptedErrorValues)}`
167167
);
168168
} catch (decryptError) {
169169
_logger.error(
170-
`${operationName}: Failed to decrypt error payload:`,
170+
`"${operationName}": Failed to decrypt error payload:`,
171171
decryptError
172172
);
173173

174174
// If the decryptError is actually our thrown error with the node's message, re-throw it
175175
if (
176176
decryptError instanceof Error &&
177-
decryptError.message.includes(`${operationName} failed.`)
177+
decryptError.message.includes(`"${operationName}" failed.`)
178178
) {
179179
throw decryptError;
180180
}
181181

182182
throw new Error(
183-
`${operationName} failed. The nodes returned an encrypted error response that could not be decrypted. ` +
184-
`This may indicate a configuration or network connectivity issue.`
183+
`"${operationName}" failed. The nodes returned an encrypted error response that could not be decrypted. ` +
184+
`This may indicate a configuration or network connectivity issue. ${JSON.stringify(errorResult)}`
185185
);
186186
}
187187
} else {
188-
throw new Error(`${operationName} failed with no error details provided`);
188+
throw new Error(`"${operationName}" failed. ${JSON.stringify(errorResult)}`);
189189
}
190190
};
191191

packages/networks/src/networks/vNaga/envs/naga-dev/naga-dev.module.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,15 @@ const networkModuleObject = {
599599
requestId: string,
600600
jitContext: NagaJitContext
601601
) => {
602+
603+
if (!result.success) {
604+
E2EERequestManager.handleEncryptedError(
605+
result,
606+
jitContext,
607+
'PKP Sign'
608+
);
609+
}
610+
602611
const decryptedValues = E2EERequestManager.decryptBatchResponse(
603612
result,
604613
jitContext,
@@ -828,6 +837,7 @@ const networkModuleObject = {
828837
curveType: 'BLS' as const,
829838
epoch: requestBody.epoch,
830839
nodeSet: requestBody.nodeSet,
840+
maxPrice: getUserMaxPrice({ product: 'SIGN_SESSION_KEY' }).toString(),
831841
};
832842

833843
// Encrypt the request data using the E2EE manager
@@ -876,6 +886,14 @@ const networkModuleObject = {
876886
'signSessionKey:handleResponse: Processing signSessionKey response'
877887
);
878888

889+
if (!result.success) {
890+
E2EERequestManager.handleEncryptedError(
891+
result,
892+
jitContext,
893+
'Session key signing'
894+
);
895+
}
896+
879897
// Decrypt the batch response using the E2EE manager
880898
const decryptedValues = E2EERequestManager.decryptBatchResponse(
881899
result,

packages/networks/src/networks/vNaga/envs/naga-dev/pricing-manager/getUserMaxPrice.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const getUserMaxPrice = (params: {
1616
DECRYPTION: BigInt(-1),
1717
SIGN: BigInt(-1),
1818
LIT_ACTION: BigInt(-1),
19+
SIGN_SESSION_KEY: BigInt(-1),
1920
};
2021

2122
if (defaultMaxPriceByProduct[params.product] === BigInt(-1)) {

packages/networks/src/networks/vNaga/envs/naga-dev/pricing-manager/pricing.constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ export const UNSIGNED_128_MAX =
1111
* - DECRYPTION (0): Used for decryption operations
1212
* - SIGN (1): Used for signing operations
1313
* - LIT_ACTION (2): Used for Lit Actions execution
14+
* - SIGN_SESSION_KEY (3): Used for sign session key operations
1415
*/
1516
export const PRODUCT_IDS = {
1617
DECRYPTION: 0n, // For decryption operations
1718
SIGN: 1n, // For signing operations
1819
LIT_ACTION: 2n, // For Lit Actions execution
20+
SIGN_SESSION_KEY: 3n, // For sign session key operations
1921
} as const;

packages/networks/src/networks/vNaga/envs/naga-local/api-manager/e2ee-request-manager/E2EERequestManager.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const handleEncryptedError = (
126126
// Try to decrypt the error payload to get the actual error message
127127
try {
128128
_logger.info(
129-
`${operationName}: Attempting to decrypt error payload for detailed error information...`
129+
`"${operationName}": Attempting to decrypt error payload for detailed error information...`
130130
);
131131

132132
const errorAsEncryptedPayload = {
@@ -145,7 +145,7 @@ const handleEncryptedError = (
145145
);
146146

147147
_logger.error(
148-
`${operationName}: Decrypted error details from nodes:`,
148+
`"${operationName}": Decrypted error details from nodes:`,
149149
decryptedErrorValues
150150
);
151151

@@ -157,35 +157,35 @@ const handleEncryptedError = (
157157
? `. Details: ${firstError.errorObject}`
158158
: '';
159159
throw new Error(
160-
`${operationName} failed. ${errorMessage}${errorDetails}`
160+
`"${operationName}" failed. ${errorMessage}${errorDetails}`
161161
);
162162
}
163163

164164
// If no specific error field, show the full decrypted response
165165
throw new Error(
166-
`${operationName} failed. ${JSON.stringify(decryptedErrorValues)}`
166+
`"${operationName}" failed. ${JSON.stringify(decryptedErrorValues)}`
167167
);
168168
} catch (decryptError) {
169169
_logger.error(
170-
`${operationName}: Failed to decrypt error payload:`,
170+
`"${operationName}": Failed to decrypt error payload:`,
171171
decryptError
172172
);
173173

174174
// If the decryptError is actually our thrown error with the node's message, re-throw it
175175
if (
176176
decryptError instanceof Error &&
177-
decryptError.message.includes(`${operationName} failed.`)
177+
decryptError.message.includes(`"${operationName}" failed.`)
178178
) {
179179
throw decryptError;
180180
}
181181

182182
throw new Error(
183-
`${operationName} failed. The nodes returned an encrypted error response that could not be decrypted. ` +
184-
`This may indicate a configuration or network connectivity issue.`
183+
`"${operationName}" failed. The nodes returned an encrypted error response that could not be decrypted. ` +
184+
`This may indicate a configuration or network connectivity issue. ${JSON.stringify(errorResult)}`
185185
);
186186
}
187187
} else {
188-
throw new Error(`${operationName} failed with no error details provided`);
188+
throw new Error(`"${operationName}" failed. ${JSON.stringify(errorResult)}`);
189189
}
190190
};
191191

packages/networks/src/networks/vNaga/envs/naga-local/chain-manager/createChainManager.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type CreateChainManagerReturn = {
2121
pkpPermissionsManager: (
2222
pkpIdentifier: PkpIdentifierRaw
2323
) => InstanceType<typeof api.PKPPermissionsManager>;
24+
paymentManager: () => InstanceType<typeof api.PaymentManager>;
2425
getPKPsByAuthData: (
2526
authData: {
2627
authMethodType: number | bigint;
@@ -81,6 +82,12 @@ export const createChainManager = (
8182
accountOrWalletClient
8283
);
8384
},
85+
paymentManager: () => {
86+
return new api.PaymentManager(
87+
_networkConfig,
88+
accountOrWalletClient
89+
);
90+
},
8491
getPKPsByAuthData: (
8592
authData: {
8693
authMethodType: number | bigint;

0 commit comments

Comments
 (0)