@ember-finance/sdk 1.2.2 → 1.2.4

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.
@@ -0,0 +1,8 @@
1
+ import EmberVaultABI from "./EmberVault.json";
2
+ import EmberProtocolConfigABI from "./EmberProtocolConfig.json";
3
+ import ERC20TokenABI from "./ERC20Token.json";
4
+ import { Interface } from "ethers";
5
+ declare const EmberVault: Interface;
6
+ declare const EmberProtocolConfig: Interface;
7
+ declare const ERC20Token: Interface;
8
+ export { EmberVaultABI, EmberProtocolConfigABI, ERC20TokenABI, EmberVault, EmberProtocolConfig, ERC20Token };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ERC20Token = exports.EmberProtocolConfig = exports.EmberVault = exports.ERC20TokenABI = exports.EmberProtocolConfigABI = exports.EmberVaultABI = void 0;
7
+ const EmberVault_json_1 = __importDefault(require("./EmberVault.json"));
8
+ exports.EmberVaultABI = EmberVault_json_1.default;
9
+ const EmberProtocolConfig_json_1 = __importDefault(require("./EmberProtocolConfig.json"));
10
+ exports.EmberProtocolConfigABI = EmberProtocolConfig_json_1.default;
11
+ const ERC20Token_json_1 = __importDefault(require("./ERC20Token.json"));
12
+ exports.ERC20TokenABI = ERC20Token_json_1.default;
13
+ const ethers_1 = require("ethers");
14
+ const EmberVault = new ethers_1.Interface(EmberVault_json_1.default.abi);
15
+ exports.EmberVault = EmberVault;
16
+ const EmberProtocolConfig = new ethers_1.Interface(EmberProtocolConfig_json_1.default.abi);
17
+ exports.EmberProtocolConfig = EmberProtocolConfig;
18
+ const ERC20Token = new ethers_1.Interface(ERC20Token_json_1.default.abi);
19
+ exports.ERC20Token = ERC20Token;
@@ -1,4 +1,4 @@
1
- import { Signer } from "ethers";
1
+ import { Provider, Signer } from "ethers";
2
2
  import { IPermitSignature } from "../interfaces";
3
3
  import { NumStr } from "../../common/types";
4
4
  /**
@@ -79,6 +79,28 @@ export declare function getPermitVersion(tokenAddress: string, provider: import(
79
79
  * ```
80
80
  */
81
81
  export declare function supportsEIP5267(tokenAddress: string, provider: import("ethers").Provider): Promise<boolean>;
82
+ /**
83
+ * Helper function to check if a token supports EIP-2612
84
+ *
85
+ * EIP-2612 defines a standard way to retrieve EIP-712 domain information
86
+ * via the DOMAIN_SEPARATOR() method. This is useful for tokens that want to
87
+ * expose their domain separator parameters in a standardized way.
88
+ *
89
+ * @param tokenAddress The address of the ERC20 token
90
+ * @param provider An ethers.js provider
91
+ * @returns True if the token supports EIP-2612, false otherwise
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * import { supportsERC2612 } from "@ember-finance/sdk";
96
+ *
97
+ * const supports = await supportsERC2612(tokenAddress, provider);
98
+ * if (supports) {
99
+ * console.log("Token supports EIP-2612");
100
+ * }
101
+ * ```
102
+ */
103
+ export declare function supportsERC2612(tokenAddress: string, provider: Provider): Promise<boolean>;
82
104
  /**
83
105
  * Helper function to get the current nonce for a user from an EIP-2612 token
84
106
  *
@@ -36,8 +36,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.signPermit = signPermit;
37
37
  exports.getPermitVersion = getPermitVersion;
38
38
  exports.supportsEIP5267 = supportsEIP5267;
39
+ exports.supportsERC2612 = supportsERC2612;
39
40
  exports.getPermitNonce = getPermitNonce;
40
41
  exports.signPermitSimple = signPermitSimple;
42
+ const ethers_1 = require("ethers");
41
43
  /**
42
44
  * Signs an EIP-2612 permit message
43
45
  *
@@ -190,6 +192,42 @@ async function supportsEIP5267(tokenAddress, provider) {
190
192
  return false;
191
193
  }
192
194
  }
195
+ /**
196
+ * Helper function to check if a token supports EIP-2612
197
+ *
198
+ * EIP-2612 defines a standard way to retrieve EIP-712 domain information
199
+ * via the DOMAIN_SEPARATOR() method. This is useful for tokens that want to
200
+ * expose their domain separator parameters in a standardized way.
201
+ *
202
+ * @param tokenAddress The address of the ERC20 token
203
+ * @param provider An ethers.js provider
204
+ * @returns True if the token supports EIP-2612, false otherwise
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * import { supportsERC2612 } from "@ember-finance/sdk";
209
+ *
210
+ * const supports = await supportsERC2612(tokenAddress, provider);
211
+ * if (supports) {
212
+ * console.log("Token supports EIP-2612");
213
+ * }
214
+ * ```
215
+ */
216
+ async function supportsERC2612(tokenAddress, provider) {
217
+ const abi = [
218
+ "function nonces(address) view returns (uint256)",
219
+ "function DOMAIN_SEPARATOR() view returns (bytes32)"
220
+ ];
221
+ try {
222
+ const token = new ethers_1.Contract(tokenAddress, abi, provider);
223
+ await token.nonces(ethers_1.ZeroAddress);
224
+ await token.DOMAIN_SEPARATOR();
225
+ return true;
226
+ }
227
+ catch {
228
+ return false;
229
+ }
230
+ }
193
231
  /**
194
232
  * Helper function to get the current nonce for a user from an EIP-2612 token
195
233
  *
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.2",
4
+ "version": "1.2.4",
5
5
  "module": "./dist/index.js",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",