@0xmonaco/core 0.7.1 → 0.7.2

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.
@@ -48,6 +48,7 @@ export class ApplicationsAPIImpl extends BaseAPI {
48
48
  allowedOrigins: data.allowed_origins,
49
49
  webhookUrl: data.webhook_url,
50
50
  vaultContractAddress: data.vault_contract_address,
51
+ clientId: data.client_id,
51
52
  };
52
53
  }
53
54
  }
@@ -56,6 +56,15 @@ export declare class VaultAPIImpl extends BaseAPI implements VaultAPI {
56
56
  * @private
57
57
  */
58
58
  getVaultAddress(): Promise<Address>;
59
+ /**
60
+ * Fetches the application's client ID from the applications API.
61
+ * The client ID is embedded in on-chain deposit calls so the indexer can
62
+ * attribute the deposit to the correct application.
63
+ *
64
+ * @returns Promise resolving to the application client ID
65
+ * @private
66
+ */
67
+ private getClientId;
59
68
  /**
60
69
  * Resolves an asset ID to its token address and determines if it's a native token.
61
70
  *
@@ -225,20 +234,6 @@ export declare class VaultAPIImpl extends BaseAPI implements VaultAPI {
225
234
  * ```
226
235
  */
227
236
  needsApproval(assetId: string, amount: bigint): Promise<boolean>;
228
- /**
229
- * Retrieves a deposit signature from the API Gateway.
230
- *
231
- * Internal method that communicates with the Monaco API Gateway to obtain
232
- * the cryptographic signature required for deposit transactions. The signature
233
- * validates the deposit request and ensures proper authorization.
234
- *
235
- * @param assetId - The asset identifier (UUID) to deposit
236
- * @param amount - The amount to deposit (as bigint)
237
- * @returns Promise resolving to object containing seed and signature
238
- * @throws {APIError} When signature retrieval fails
239
- * @private
240
- */
241
- private getDepositSignature;
242
237
  /**
243
238
  * Retrieves a withdrawal signature from the API Gateway.
244
239
  *
@@ -70,6 +70,18 @@ export class VaultAPIImpl extends BaseAPI {
70
70
  const config = await this.applicationsAPI.getApplicationConfig();
71
71
  return config.vaultContractAddress;
72
72
  }
73
+ /**
74
+ * Fetches the application's client ID from the applications API.
75
+ * The client ID is embedded in on-chain deposit calls so the indexer can
76
+ * attribute the deposit to the correct application.
77
+ *
78
+ * @returns Promise resolving to the application client ID
79
+ * @private
80
+ */
81
+ async getClientId() {
82
+ const config = await this.applicationsAPI.getApplicationConfig();
83
+ return config.clientId;
84
+ }
73
85
  /**
74
86
  * Resolves an asset ID to its token address and determines if it's a native token.
75
87
  *
@@ -216,6 +228,7 @@ export class VaultAPIImpl extends BaseAPI {
216
228
  // Validate inputs
217
229
  validate(DepositSchema, { assetId, amount, autoWait });
218
230
  const vaultAddress = await this.getVaultAddress();
231
+ const clientId = await this.getClientId();
219
232
  const { tokenAddress, isNativeToken } = await this.resolveAsset(assetId);
220
233
  if (!isNativeToken) {
221
234
  // Check if approval is needed before proceeding
@@ -226,20 +239,18 @@ export class VaultAPIImpl extends BaseAPI {
226
239
  });
227
240
  }
228
241
  }
229
- // Get signature from backend API using asset_id
230
- const { seed, signature } = await this.getDepositSignature(assetId, amount);
231
242
  const walletAccount = this.walletClient.account;
232
243
  if (!walletAccount) {
233
244
  throw new InvalidConfigError("No account available in wallet client", "account");
234
245
  }
235
- // For native SEI (zero address), use depositNative (payable); for ERC20 tokens, use deposit
246
+ // For native SEI (zero address), use depositNative (payable); for ERC20 tokens, use depositERC20
236
247
  let hash;
237
248
  if (isNativeToken) {
238
249
  hash = await this.walletClient.writeContract({
239
250
  address: vaultAddress,
240
251
  abi: CONTRACT_ABIS.vault,
241
252
  functionName: "depositNative",
242
- args: [seed, signature],
253
+ args: [walletAccount.address, clientId],
243
254
  account: walletAccount,
244
255
  chain: this.chain,
245
256
  value: amount,
@@ -249,8 +260,8 @@ export class VaultAPIImpl extends BaseAPI {
249
260
  hash = await this.walletClient.writeContract({
250
261
  address: vaultAddress,
251
262
  abi: CONTRACT_ABIS.vault,
252
- functionName: "deposit",
253
- args: [tokenAddress, amount, seed, signature],
263
+ functionName: "depositERC20",
264
+ args: [walletAccount.address, clientId, tokenAddress, amount],
254
265
  account: walletAccount,
255
266
  chain: this.chain,
256
267
  });
@@ -415,32 +426,6 @@ export class VaultAPIImpl extends BaseAPI {
415
426
  const allowance = await this.getAllowance(assetId);
416
427
  return allowance < amount;
417
428
  }
418
- /**
419
- * Retrieves a deposit signature from the API Gateway.
420
- *
421
- * Internal method that communicates with the Monaco API Gateway to obtain
422
- * the cryptographic signature required for deposit transactions. The signature
423
- * validates the deposit request and ensures proper authorization.
424
- *
425
- * @param assetId - The asset identifier (UUID) to deposit
426
- * @param amount - The amount to deposit (as bigint)
427
- * @returns Promise resolving to object containing seed and signature
428
- * @throws {APIError} When signature retrieval fails
429
- * @private
430
- */
431
- async getDepositSignature(assetId, amount) {
432
- const data = await this.makeAuthenticatedRequest("/api/v1/deposit/signature", {
433
- method: "POST",
434
- body: JSON.stringify({
435
- asset_id: assetId,
436
- amount: amount.toString(),
437
- }),
438
- });
439
- return {
440
- seed: data.seed,
441
- signature: data.signature,
442
- };
443
- }
444
429
  /**
445
430
  * Retrieves a withdrawal signature from the API Gateway.
446
431
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/core",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",