@ember-finance/sdk 1.2.0 → 1.2.1

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.
@@ -57,6 +57,28 @@ export declare function signPermit(signer: Signer, tokenAddress: string, tokenNa
57
57
  * ```
58
58
  */
59
59
  export declare function getPermitVersion(tokenAddress: string, provider: import("ethers").Provider): Promise<string>;
60
+ /**
61
+ * Helper function to check if a token supports EIP-5267
62
+ *
63
+ * EIP-5267 defines a standard way to retrieve EIP-712 domain information
64
+ * via the eip712Domain() method. This is useful for tokens that want to
65
+ * expose their domain separator parameters in a standardized way.
66
+ *
67
+ * @param tokenAddress The address of the ERC20 token
68
+ * @param provider An ethers.js provider
69
+ * @returns True if the token supports EIP-5267, false otherwise
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * import { supportsEIP5267 } from "@ember-finance/sdk";
74
+ *
75
+ * const supports = await supportsEIP5267(tokenAddress, provider);
76
+ * if (supports) {
77
+ * console.log("Token supports EIP-5267");
78
+ * }
79
+ * ```
80
+ */
81
+ export declare function supportsEIP5267(tokenAddress: string, provider: import("ethers").Provider): Promise<boolean>;
60
82
  /**
61
83
  * Helper function to get the current nonce for a user from an EIP-2612 token
62
84
  *
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.signPermit = signPermit;
37
37
  exports.getPermitVersion = getPermitVersion;
38
+ exports.supportsEIP5267 = supportsEIP5267;
38
39
  exports.getPermitNonce = getPermitNonce;
39
40
  exports.signPermitSimple = signPermitSimple;
40
41
  /**
@@ -153,6 +154,42 @@ async function getPermitVersion(tokenAddress, provider) {
153
154
  return "2";
154
155
  }
155
156
  }
157
+ /**
158
+ * Helper function to check if a token supports EIP-5267
159
+ *
160
+ * EIP-5267 defines a standard way to retrieve EIP-712 domain information
161
+ * via the eip712Domain() method. This is useful for tokens that want to
162
+ * expose their domain separator parameters in a standardized way.
163
+ *
164
+ * @param tokenAddress The address of the ERC20 token
165
+ * @param provider An ethers.js provider
166
+ * @returns True if the token supports EIP-5267, false otherwise
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * import { supportsEIP5267 } from "@ember-finance/sdk";
171
+ *
172
+ * const supports = await supportsEIP5267(tokenAddress, provider);
173
+ * if (supports) {
174
+ * console.log("Token supports EIP-5267");
175
+ * }
176
+ * ```
177
+ */
178
+ async function supportsEIP5267(tokenAddress, provider) {
179
+ try {
180
+ const { Contract } = await Promise.resolve().then(() => __importStar(require("ethers")));
181
+ const tokenContract = new Contract(tokenAddress, [
182
+ "function eip712Domain() view returns (bytes1 fields, string name, string version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] extensions)"
183
+ ], provider);
184
+ // Try to call the method - if it succeeds, the token supports EIP-5267
185
+ await tokenContract.eip712Domain();
186
+ return true;
187
+ }
188
+ catch (error) {
189
+ // If the call fails, the token does not support EIP-5267
190
+ return false;
191
+ }
192
+ }
156
193
  /**
157
194
  * Helper function to get the current nonce for a user from an EIP-2612 token
158
195
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ember-finance/sdk",
3
3
  "description": "Ember Protocol SDK",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "module": "./dist/index.js",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",