@chipi-stack/backend 12.1.0 → 12.3.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.
- package/dist/index.js +24 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -21
- package/dist/index.mjs.map +1 -1
- package/dist/skuTransactions.js +9 -11
- package/dist/skuTransactions.js.map +1 -1
- package/dist/skuTransactions.mjs +9 -11
- package/dist/skuTransactions.mjs.map +1 -1
- package/dist/transactions.js +9 -11
- package/dist/transactions.js.map +1 -1
- package/dist/transactions.mjs +9 -11
- package/dist/transactions.mjs.map +1 -1
- package/dist/wallets.js +15 -10
- package/dist/wallets.js.map +1 -1
- package/dist/wallets.mjs +15 -10
- package/dist/wallets.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -203,9 +203,18 @@ var ChipiWallets = class {
|
|
|
203
203
|
externalUserId,
|
|
204
204
|
bearerToken,
|
|
205
205
|
userId,
|
|
206
|
-
walletType = "CHIPI"
|
|
206
|
+
walletType = "CHIPI",
|
|
207
207
|
// Default to CHIPI wallet
|
|
208
|
+
usePasskey
|
|
208
209
|
} = params;
|
|
210
|
+
if (!encryptKey) {
|
|
211
|
+
if (usePasskey) {
|
|
212
|
+
throw new Error(
|
|
213
|
+
"encryptKey is required when using passkey. The passkey authentication should have provided the encryptKey."
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
throw new Error("encryptKey is required for wallet creation");
|
|
217
|
+
}
|
|
209
218
|
const rpcUrl = walletType === "READY" ? shared.WALLET_RPC_ENDPOINTS.READY : shared.WALLET_RPC_ENDPOINTS.CHIPI;
|
|
210
219
|
const provider = new starknet.RpcProvider({ nodeUrl: rpcUrl });
|
|
211
220
|
const privateKeyAX = this.getPrivateKeyAX();
|
|
@@ -222,7 +231,7 @@ var ChipiWallets = class {
|
|
|
222
231
|
0
|
|
223
232
|
);
|
|
224
233
|
const account = new starknet.Account(provider, publicKey, privateKeyAX);
|
|
225
|
-
const
|
|
234
|
+
const typedDataResponse = await this.client.post({
|
|
226
235
|
endpoint: `${shared.API_ENDPOINTS.CHIPI_WALLETS}/prepare-creation`,
|
|
227
236
|
bearerToken,
|
|
228
237
|
body: {
|
|
@@ -232,8 +241,8 @@ var ChipiWallets = class {
|
|
|
232
241
|
// Needed for backend to build deployment data
|
|
233
242
|
}
|
|
234
243
|
});
|
|
235
|
-
const {
|
|
236
|
-
const userSignature = await account.signMessage(
|
|
244
|
+
const { typedData: typedData2, accountClassHash: accountClassHashResponse } = typedDataResponse;
|
|
245
|
+
const userSignature = await account.signMessage(typedData2);
|
|
237
246
|
const deploymentData = {
|
|
238
247
|
class_hash: accountClassHashResponse,
|
|
239
248
|
salt: starkKeyPubAX,
|
|
@@ -254,7 +263,7 @@ var ChipiWallets = class {
|
|
|
254
263
|
s: userSignature.s.toString(),
|
|
255
264
|
recovery: userSignature.recovery
|
|
256
265
|
},
|
|
257
|
-
|
|
266
|
+
typedData: typedData2,
|
|
258
267
|
encryptedPrivateKey,
|
|
259
268
|
deploymentData: {
|
|
260
269
|
...deploymentData,
|
|
@@ -263,11 +272,7 @@ var ChipiWallets = class {
|
|
|
263
272
|
}
|
|
264
273
|
}
|
|
265
274
|
});
|
|
266
|
-
return
|
|
267
|
-
txHash: executeTransactionResponse.txHash,
|
|
268
|
-
walletPublicKey: executeTransactionResponse.walletPublicKey,
|
|
269
|
-
wallet: executeTransactionResponse.wallet
|
|
270
|
-
};
|
|
275
|
+
return executeTransactionResponse;
|
|
271
276
|
} catch (error) {
|
|
272
277
|
console.error("Detailed error:", error);
|
|
273
278
|
if (error instanceof Error && error.message.includes("SSL")) {
|
|
@@ -349,15 +354,14 @@ var executePaymasterTransaction = async ({
|
|
|
349
354
|
client
|
|
350
355
|
}) => {
|
|
351
356
|
try {
|
|
352
|
-
const { encryptKey, wallet, calls, saveToDatabase } = params;
|
|
353
|
-
if (!
|
|
354
|
-
|
|
355
|
-
|
|
357
|
+
const { encryptKey, wallet, calls, saveToDatabase, usePasskey } = params;
|
|
358
|
+
if (!encryptKey) {
|
|
359
|
+
throw new Error(
|
|
360
|
+
usePasskey ? "encryptKey is required when using passkey. The passkey authentication should have provided the encryptKey." : "encryptKey is required for transaction execution"
|
|
356
361
|
);
|
|
357
362
|
}
|
|
358
|
-
const
|
|
359
|
-
const
|
|
360
|
-
const accountClassHash = walletType === "READY" ? shared.WALLET_CLASS_HASHES.READY : shared.WALLET_CLASS_HASHES.CHIPI;
|
|
363
|
+
const rpcUrl = shared.WALLET_RPC_ENDPOINTS.READY;
|
|
364
|
+
const accountClassHash = shared.WALLET_CLASS_HASHES.READY;
|
|
361
365
|
const privateKeyDecrypted = decryptPrivateKey(
|
|
362
366
|
wallet.encryptedPrivateKey,
|
|
363
367
|
encryptKey
|
|
@@ -371,23 +375,22 @@ var executePaymasterTransaction = async ({
|
|
|
371
375
|
wallet.publicKey,
|
|
372
376
|
privateKeyDecrypted
|
|
373
377
|
);
|
|
374
|
-
const
|
|
378
|
+
const { typedData: typedData2, walletType } = await client.post({
|
|
375
379
|
endpoint: "/transactions/prepare-typed-data",
|
|
376
380
|
bearerToken,
|
|
377
381
|
body: {
|
|
378
382
|
publicKey: wallet.publicKey,
|
|
379
|
-
walletType,
|
|
380
383
|
calls,
|
|
381
384
|
accountClassHash
|
|
382
385
|
}
|
|
383
386
|
});
|
|
384
|
-
const userSignature = await account.signMessage(
|
|
387
|
+
const userSignature = await account.signMessage(typedData2);
|
|
385
388
|
const result = await client.post({
|
|
386
389
|
endpoint: "/transactions/execute-sponsored-transaction",
|
|
387
390
|
bearerToken,
|
|
388
391
|
body: {
|
|
389
392
|
publicKey: wallet.publicKey,
|
|
390
|
-
|
|
393
|
+
typedData: typedData2,
|
|
391
394
|
userSignature: {
|
|
392
395
|
r: userSignature.r.toString(),
|
|
393
396
|
s: userSignature.s.toString(),
|