atfi 1.1.0 → 1.1.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.
package/dist/index.d.mts CHANGED
@@ -197,6 +197,8 @@ interface EventSummary {
197
197
  maxParticipants: number;
198
198
  currentParticipants: number;
199
199
  status: EventStatus;
200
+ tokenSymbol: string;
201
+ tokenDecimals: number;
200
202
  }
201
203
  interface ATFiSDKConfig {
202
204
  /** Custom factory address (optional, defaults to mainnet) */
@@ -617,7 +619,8 @@ declare enum ATFiErrorCode {
617
619
  INSUFFICIENT_ALLOWANCE = "INSUFFICIENT_ALLOWANCE",
618
620
  TRANSACTION_FAILED = "TRANSACTION_FAILED",
619
621
  CONTRACT_ERROR = "CONTRACT_ERROR",
620
- VAULT_NOT_FOUND = "VAULT_NOT_FOUND"
622
+ VAULT_NOT_FOUND = "VAULT_NOT_FOUND",
623
+ NETWORK_ERROR = "NETWORK_ERROR"
621
624
  }
622
625
  declare class ATFiError extends Error {
623
626
  code: ATFiErrorCode;
package/dist/index.d.ts CHANGED
@@ -197,6 +197,8 @@ interface EventSummary {
197
197
  maxParticipants: number;
198
198
  currentParticipants: number;
199
199
  status: EventStatus;
200
+ tokenSymbol: string;
201
+ tokenDecimals: number;
200
202
  }
201
203
  interface ATFiSDKConfig {
202
204
  /** Custom factory address (optional, defaults to mainnet) */
@@ -617,7 +619,8 @@ declare enum ATFiErrorCode {
617
619
  INSUFFICIENT_ALLOWANCE = "INSUFFICIENT_ALLOWANCE",
618
620
  TRANSACTION_FAILED = "TRANSACTION_FAILED",
619
621
  CONTRACT_ERROR = "CONTRACT_ERROR",
620
- VAULT_NOT_FOUND = "VAULT_NOT_FOUND"
622
+ VAULT_NOT_FOUND = "VAULT_NOT_FOUND",
623
+ NETWORK_ERROR = "NETWORK_ERROR"
621
624
  }
622
625
  declare class ATFiError extends Error {
623
626
  code: ATFiErrorCode;
package/dist/index.js CHANGED
@@ -224,6 +224,7 @@ var ATFiErrorCode = /* @__PURE__ */ ((ATFiErrorCode2) => {
224
224
  ATFiErrorCode2["TRANSACTION_FAILED"] = "TRANSACTION_FAILED";
225
225
  ATFiErrorCode2["CONTRACT_ERROR"] = "CONTRACT_ERROR";
226
226
  ATFiErrorCode2["VAULT_NOT_FOUND"] = "VAULT_NOT_FOUND";
227
+ ATFiErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
227
228
  return ATFiErrorCode2;
228
229
  })(ATFiErrorCode || {});
229
230
  var ATFiError = class extends Error {
@@ -253,7 +254,8 @@ var CONTRACT_ERROR_MAP = {
253
254
  VaultAlreadySettled: "VAULT_ALREADY_SETTLED" /* VAULT_ALREADY_SETTLED */,
254
255
  VaultNotSettled: "VAULT_NOT_SETTLED" /* VAULT_NOT_SETTLED */,
255
256
  YieldOnlySupportsUSDC: "YIELD_ONLY_USDC" /* YIELD_ONLY_USDC */,
256
- OwnableUnauthorizedAccount: "NOT_OWNER" /* NOT_OWNER */
257
+ OwnableUnauthorizedAccount: "NOT_OWNER" /* NOT_OWNER */,
258
+ NetworkError: "NETWORK_ERROR" /* NETWORK_ERROR */
257
259
  };
258
260
  function parseContractError(error) {
259
261
  if (error instanceof ATFiError) {
@@ -632,6 +634,16 @@ var ATFiSDK = class _ATFiSDK {
632
634
  */
633
635
  async createEvent(params) {
634
636
  this.ensureWallet();
637
+ if (this.walletClient && this.publicClient.chain) {
638
+ const walletChainId = await this.walletClient.getChainId();
639
+ const publicChainId = this.publicClient.chain.id;
640
+ if (walletChainId !== publicChainId) {
641
+ throw new ATFiError(
642
+ `Wrong network. Please switch to ${this.publicClient.chain.name} (Chain ID: ${publicChainId})`,
643
+ "NETWORK_ERROR" /* NETWORK_ERROR */
644
+ );
645
+ }
646
+ }
635
647
  const simulation = await this._simulateCreateEvent(params);
636
648
  return {
637
649
  simulation,
@@ -887,7 +899,9 @@ var ATFiSDK = class _ATFiSDK {
887
899
  stakeAmount: info.stakeAmount,
888
900
  maxParticipants: info.maxParticipants,
889
901
  currentParticipants: info.currentParticipants,
890
- status
902
+ status,
903
+ tokenSymbol: info.tokenSymbol,
904
+ tokenDecimals: info.tokenDecimals
891
905
  };
892
906
  });
893
907
  }
package/dist/index.mjs CHANGED
@@ -173,6 +173,7 @@ var ATFiErrorCode = /* @__PURE__ */ ((ATFiErrorCode2) => {
173
173
  ATFiErrorCode2["TRANSACTION_FAILED"] = "TRANSACTION_FAILED";
174
174
  ATFiErrorCode2["CONTRACT_ERROR"] = "CONTRACT_ERROR";
175
175
  ATFiErrorCode2["VAULT_NOT_FOUND"] = "VAULT_NOT_FOUND";
176
+ ATFiErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
176
177
  return ATFiErrorCode2;
177
178
  })(ATFiErrorCode || {});
178
179
  var ATFiError = class extends Error {
@@ -202,7 +203,8 @@ var CONTRACT_ERROR_MAP = {
202
203
  VaultAlreadySettled: "VAULT_ALREADY_SETTLED" /* VAULT_ALREADY_SETTLED */,
203
204
  VaultNotSettled: "VAULT_NOT_SETTLED" /* VAULT_NOT_SETTLED */,
204
205
  YieldOnlySupportsUSDC: "YIELD_ONLY_USDC" /* YIELD_ONLY_USDC */,
205
- OwnableUnauthorizedAccount: "NOT_OWNER" /* NOT_OWNER */
206
+ OwnableUnauthorizedAccount: "NOT_OWNER" /* NOT_OWNER */,
207
+ NetworkError: "NETWORK_ERROR" /* NETWORK_ERROR */
206
208
  };
207
209
  function parseContractError(error) {
208
210
  if (error instanceof ATFiError) {
@@ -581,6 +583,16 @@ var ATFiSDK = class _ATFiSDK {
581
583
  */
582
584
  async createEvent(params) {
583
585
  this.ensureWallet();
586
+ if (this.walletClient && this.publicClient.chain) {
587
+ const walletChainId = await this.walletClient.getChainId();
588
+ const publicChainId = this.publicClient.chain.id;
589
+ if (walletChainId !== publicChainId) {
590
+ throw new ATFiError(
591
+ `Wrong network. Please switch to ${this.publicClient.chain.name} (Chain ID: ${publicChainId})`,
592
+ "NETWORK_ERROR" /* NETWORK_ERROR */
593
+ );
594
+ }
595
+ }
584
596
  const simulation = await this._simulateCreateEvent(params);
585
597
  return {
586
598
  simulation,
@@ -836,7 +848,9 @@ var ATFiSDK = class _ATFiSDK {
836
848
  stakeAmount: info.stakeAmount,
837
849
  maxParticipants: info.maxParticipants,
838
850
  currentParticipants: info.currentParticipants,
839
- status
851
+ status,
852
+ tokenSymbol: info.tokenSymbol,
853
+ tokenDecimals: info.tokenDecimals
840
854
  };
841
855
  });
842
856
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atfi",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "TypeScript SDK for ATFi commitment vaults on Base",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",