@evedex/exchange-crypto 1.0.19 → 1.0.23
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/README.md +1 -0
- package/dist/cjs/index.js +19 -19
- package/dist/cjs/utils/crypto.d.ts +1 -1
- package/dist/cjs/utils/crypto.js +3 -3
- package/dist/cjs/utils/exchange.d.ts +1 -0
- package/dist/mjs/index.js +20 -19
- package/dist/mjs/utils/crypto.d.ts +1 -1
- package/dist/mjs/utils/crypto.js +2 -2
- package/dist/mjs/utils/exchange.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -107,7 +107,7 @@ function signAuth(signer, payload) {
|
|
|
107
107
|
function signLimitOrder(signer, order) {
|
|
108
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
109
|
const chainId = yield signer.getChainId();
|
|
110
|
-
(0, validate_1.validatePayload)(Object.assign(Object.assign({}, order), { chainId }), crypto_1.
|
|
110
|
+
(0, validate_1.validatePayload)(Object.assign(Object.assign({}, order), { chainId }), crypto_1.EIP712Schemas.createLimitOrder);
|
|
111
111
|
const normalize = {
|
|
112
112
|
id: order.id,
|
|
113
113
|
instrument: order.instrument,
|
|
@@ -118,14 +118,14 @@ function signLimitOrder(signer, order) {
|
|
|
118
118
|
tpsl: order.tpsl,
|
|
119
119
|
chainId,
|
|
120
120
|
};
|
|
121
|
-
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(chainId), crypto_1.
|
|
122
|
-
return Object.assign(Object.assign(Object.assign({}, normalize), (order.postOnly && { postOnly: "yes" })), { signature: signer.serializeSignature(signature) });
|
|
121
|
+
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(chainId), crypto_1.EIP712Schemas.createLimitOrder, Object.assign(Object.assign({}, normalize), { quantity: (0, crypto_1.toEthNumber)(normalize.quantity), limitPrice: (0, crypto_1.toEthNumber)(normalize.limitPrice) }));
|
|
122
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, normalize), (order.postOnly && { postOnly: "yes" })), (order.timeInForce ? { timeInForce: order.timeInForce } : {})), { signature: signer.serializeSignature(signature) });
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
function signMarketOrder(signer, order) {
|
|
126
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
127
|
const chainId = yield signer.getChainId();
|
|
128
|
-
(0, validate_1.validatePayload)(Object.assign(Object.assign({}, order), { chainId }), crypto_1.
|
|
128
|
+
(0, validate_1.validatePayload)(Object.assign(Object.assign({}, order), { chainId }), crypto_1.EIP712Schemas.createMarketOrder);
|
|
129
129
|
const normalize = {
|
|
130
130
|
id: order.id,
|
|
131
131
|
instrument: order.instrument,
|
|
@@ -136,14 +136,14 @@ function signMarketOrder(signer, order) {
|
|
|
136
136
|
tpsl: order.tpsl,
|
|
137
137
|
chainId,
|
|
138
138
|
};
|
|
139
|
-
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(chainId), crypto_1.
|
|
139
|
+
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(chainId), crypto_1.EIP712Schemas.createMarketOrder, Object.assign(Object.assign({}, normalize), { cashQuantity: (0, crypto_1.toEthNumber)(normalize.cashQuantity) }));
|
|
140
140
|
return Object.assign(Object.assign({}, normalize), { signature: signer.serializeSignature(signature) });
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
143
|
function signStopLimitOrder(signer, order) {
|
|
144
144
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
145
|
const chainId = yield signer.getChainId();
|
|
146
|
-
(0, validate_1.validatePayload)(Object.assign(Object.assign({}, order), { chainId }), crypto_1.
|
|
146
|
+
(0, validate_1.validatePayload)(Object.assign(Object.assign({}, order), { chainId }), crypto_1.EIP712Schemas.createStopLimitOrder);
|
|
147
147
|
const normalize = {
|
|
148
148
|
id: order.id,
|
|
149
149
|
instrument: order.instrument,
|
|
@@ -155,14 +155,14 @@ function signStopLimitOrder(signer, order) {
|
|
|
155
155
|
tpsl: order.tpsl,
|
|
156
156
|
chainId,
|
|
157
157
|
};
|
|
158
|
-
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(chainId), crypto_1.
|
|
158
|
+
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(chainId), crypto_1.EIP712Schemas.createStopLimitOrder, Object.assign(Object.assign({}, normalize), { quantity: (0, crypto_1.toEthNumber)(normalize.quantity), limitPrice: (0, crypto_1.toEthNumber)(normalize.limitPrice), stopPrice: (0, crypto_1.toEthNumber)(normalize.stopPrice) }));
|
|
159
159
|
return Object.assign(Object.assign({}, normalize), { signature: signer.serializeSignature(signature) });
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
function signPositionCloseOrder(signer, order) {
|
|
163
163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
164
|
const chainId = yield signer.getChainId();
|
|
165
|
-
(0, validate_1.validatePayload)(Object.assign(Object.assign({}, order), { chainId }), crypto_1.
|
|
165
|
+
(0, validate_1.validatePayload)(Object.assign(Object.assign({}, order), { chainId }), crypto_1.EIP712Schemas.createPositionCloseOrder);
|
|
166
166
|
const normalize = {
|
|
167
167
|
id: order.id,
|
|
168
168
|
instrument: order.instrument,
|
|
@@ -170,43 +170,43 @@ function signPositionCloseOrder(signer, order) {
|
|
|
170
170
|
quantity: (0, numeric_1.toMatcherNumber)(order.quantity),
|
|
171
171
|
chainId,
|
|
172
172
|
};
|
|
173
|
-
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(chainId), crypto_1.
|
|
173
|
+
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(chainId), crypto_1.EIP712Schemas.createPositionCloseOrder, Object.assign(Object.assign({}, normalize), { quantity: (0, crypto_1.toEthNumber)(normalize.quantity) }));
|
|
174
174
|
return Object.assign(Object.assign({}, normalize), { signature: signer.serializeSignature(signature) });
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
function signReplaceLimitOrder(signer, order) {
|
|
178
178
|
return __awaiter(this, void 0, void 0, function* () {
|
|
179
|
-
(0, validate_1.validatePayload)(order, crypto_1.
|
|
179
|
+
(0, validate_1.validatePayload)(order, crypto_1.EIP712Schemas.replaceLimitOrder);
|
|
180
180
|
const normalize = {
|
|
181
181
|
orderId: order.orderId,
|
|
182
182
|
quantity: (0, numeric_1.toMatcherNumber)(order.quantity),
|
|
183
183
|
limitPrice: (0, numeric_1.toMatcherNumber)(order.limitPrice),
|
|
184
184
|
};
|
|
185
|
-
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(yield signer.getChainId()), crypto_1.
|
|
185
|
+
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(yield signer.getChainId()), crypto_1.EIP712Schemas.replaceLimitOrder, Object.assign(Object.assign({}, normalize), { quantity: (0, crypto_1.toEthNumber)(normalize.quantity), limitPrice: (0, crypto_1.toEthNumber)(normalize.limitPrice) }));
|
|
186
186
|
return Object.assign(Object.assign(Object.assign({}, normalize), (order.postOnly && { postOnly: "yes" })), { signature: signer.serializeSignature(signature) });
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
189
|
function signReplaceStopLimitOrder(signer, order) {
|
|
190
190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
-
(0, validate_1.validatePayload)(order, crypto_1.
|
|
191
|
+
(0, validate_1.validatePayload)(order, crypto_1.EIP712Schemas.replaceStopLimitOrder);
|
|
192
192
|
const normalize = {
|
|
193
193
|
orderId: order.orderId,
|
|
194
194
|
quantity: (0, numeric_1.toMatcherNumber)(order.quantity),
|
|
195
195
|
limitPrice: (0, numeric_1.toMatcherNumber)(order.limitPrice),
|
|
196
196
|
stopPrice: (0, numeric_1.toMatcherNumber)(order.stopPrice),
|
|
197
197
|
};
|
|
198
|
-
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(yield signer.getChainId()), crypto_1.
|
|
198
|
+
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(yield signer.getChainId()), crypto_1.EIP712Schemas.replaceStopLimitOrder, Object.assign(Object.assign({}, normalize), { quantity: (0, crypto_1.toEthNumber)(normalize.quantity), limitPrice: (0, crypto_1.toEthNumber)(normalize.limitPrice), stopPrice: (0, crypto_1.toEthNumber)(normalize.stopPrice) }));
|
|
199
199
|
return Object.assign(Object.assign({}, normalize), { signature: signer.serializeSignature(signature) });
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
function signTradingBalanceWithdraw(signer, withdraw) {
|
|
203
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
-
(0, validate_1.validatePayload)(withdraw, crypto_1.
|
|
204
|
+
(0, validate_1.validatePayload)(withdraw, crypto_1.EIP712Schemas.withdraw);
|
|
205
205
|
const normalize = {
|
|
206
206
|
recipient: withdraw.recipient,
|
|
207
207
|
amount: (0, big_js_1.default)(withdraw.amount).round(utils_1.MATCHER_PRECISION, big_js_1.default.roundDown).toString(),
|
|
208
208
|
};
|
|
209
|
-
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(yield signer.getChainId()), crypto_1.
|
|
209
|
+
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(yield signer.getChainId()), crypto_1.EIP712Schemas.withdraw, {
|
|
210
210
|
recipient: withdraw.recipient,
|
|
211
211
|
amount: (0, crypto_1.toEthNumber)(normalize.amount),
|
|
212
212
|
});
|
|
@@ -215,7 +215,7 @@ function signTradingBalanceWithdraw(signer, withdraw) {
|
|
|
215
215
|
}
|
|
216
216
|
function signTpSl(signer, tpsl) {
|
|
217
217
|
return __awaiter(this, void 0, void 0, function* () {
|
|
218
|
-
(0, validate_1.validatePayload)(tpsl, crypto_1.
|
|
218
|
+
(0, validate_1.validatePayload)(tpsl, crypto_1.EIP712Schemas.createTpSl);
|
|
219
219
|
const normalize = {
|
|
220
220
|
instrument: tpsl.instrument,
|
|
221
221
|
type: tpsl.type,
|
|
@@ -224,15 +224,15 @@ function signTpSl(signer, tpsl) {
|
|
|
224
224
|
price: (0, numeric_1.toMatcherNumber)(tpsl.price),
|
|
225
225
|
order: tpsl.order,
|
|
226
226
|
};
|
|
227
|
-
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(yield signer.getChainId()), crypto_1.
|
|
227
|
+
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(yield signer.getChainId()), crypto_1.EIP712Schemas.createTpSl, Object.assign(Object.assign({}, normalize), { quantity: (0, crypto_1.toEthNumber)(normalize.quantity), price: (0, crypto_1.toEthNumber)(normalize.price) }));
|
|
228
228
|
return Object.assign(Object.assign({}, normalize), { signature: signer.serializeSignature(signature) });
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
231
|
function signOauthConsentTequest(signer, payload) {
|
|
232
232
|
return __awaiter(this, void 0, void 0, function* () {
|
|
233
233
|
const { oauthRequestId } = payload;
|
|
234
|
-
(0, validate_1.validatePayload)({ oauthRequestId }, crypto_1.
|
|
235
|
-
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(yield signer.getChainId()), crypto_1.
|
|
234
|
+
(0, validate_1.validatePayload)({ oauthRequestId }, crypto_1.EIP712Schemas.oauthConsent);
|
|
235
|
+
const signature = yield signer.signTypedData((0, crypto_1.getDomainData)(yield signer.getChainId()), crypto_1.EIP712Schemas.oauthConsent, {
|
|
236
236
|
oauthRequestId,
|
|
237
237
|
});
|
|
238
238
|
return Object.assign(Object.assign({}, payload), { signature });
|
package/dist/cjs/utils/crypto.js
CHANGED
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.EIP712Schemas = void 0;
|
|
7
7
|
exports.getDomainData = getDomainData;
|
|
8
8
|
exports.toEthNumber = toEthNumber;
|
|
9
9
|
const big_js_1 = __importDefault(require("big.js"));
|
|
10
10
|
const constants_1 = require("./constants");
|
|
11
|
-
exports.
|
|
11
|
+
exports.EIP712Schemas = {
|
|
12
12
|
domain: {
|
|
13
13
|
name: "EVEDEX",
|
|
14
14
|
version: "2",
|
|
@@ -92,7 +92,7 @@ exports.EIP721Schemas = {
|
|
|
92
92
|
},
|
|
93
93
|
};
|
|
94
94
|
function getDomainData(chainId) {
|
|
95
|
-
return Object.assign(Object.assign({}, exports.
|
|
95
|
+
return Object.assign(Object.assign({}, exports.EIP712Schemas.domain), { chainId });
|
|
96
96
|
}
|
|
97
97
|
function toEthNumber(value) {
|
|
98
98
|
return (0, big_js_1.default)(value).mul(`1e${constants_1.MATCHER_PRECISION}`).toFixed(0);
|
package/dist/mjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Big from "big.js";
|
|
2
2
|
import { SiweMessage } from "siwe";
|
|
3
|
-
import {
|
|
3
|
+
import { EIP712Schemas, getDomainData, toEthNumber, } from "./utils/crypto";
|
|
4
4
|
import { toMatcherNumber } from "./utils/numeric";
|
|
5
5
|
import { validatePayload } from "./utils/validate";
|
|
6
6
|
import { MATCHER_PRECISION } from "./utils";
|
|
@@ -42,7 +42,7 @@ export async function signAuth(signer, payload) {
|
|
|
42
42
|
}
|
|
43
43
|
export async function signLimitOrder(signer, order) {
|
|
44
44
|
const chainId = await signer.getChainId();
|
|
45
|
-
validatePayload({ ...order, chainId },
|
|
45
|
+
validatePayload({ ...order, chainId }, EIP712Schemas.createLimitOrder);
|
|
46
46
|
const normalize = {
|
|
47
47
|
id: order.id,
|
|
48
48
|
instrument: order.instrument,
|
|
@@ -53,7 +53,7 @@ export async function signLimitOrder(signer, order) {
|
|
|
53
53
|
tpsl: order.tpsl,
|
|
54
54
|
chainId,
|
|
55
55
|
};
|
|
56
|
-
const signature = await signer.signTypedData(getDomainData(chainId),
|
|
56
|
+
const signature = await signer.signTypedData(getDomainData(chainId), EIP712Schemas.createLimitOrder, {
|
|
57
57
|
...normalize,
|
|
58
58
|
quantity: toEthNumber(normalize.quantity),
|
|
59
59
|
limitPrice: toEthNumber(normalize.limitPrice),
|
|
@@ -61,12 +61,13 @@ export async function signLimitOrder(signer, order) {
|
|
|
61
61
|
return {
|
|
62
62
|
...normalize,
|
|
63
63
|
...(order.postOnly && { postOnly: "yes" }),
|
|
64
|
+
...(order.timeInForce ? { timeInForce: order.timeInForce } : {}),
|
|
64
65
|
signature: signer.serializeSignature(signature),
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
export async function signMarketOrder(signer, order) {
|
|
68
69
|
const chainId = await signer.getChainId();
|
|
69
|
-
validatePayload({ ...order, chainId },
|
|
70
|
+
validatePayload({ ...order, chainId }, EIP712Schemas.createMarketOrder);
|
|
70
71
|
const normalize = {
|
|
71
72
|
id: order.id,
|
|
72
73
|
instrument: order.instrument,
|
|
@@ -77,7 +78,7 @@ export async function signMarketOrder(signer, order) {
|
|
|
77
78
|
tpsl: order.tpsl,
|
|
78
79
|
chainId,
|
|
79
80
|
};
|
|
80
|
-
const signature = await signer.signTypedData(getDomainData(chainId),
|
|
81
|
+
const signature = await signer.signTypedData(getDomainData(chainId), EIP712Schemas.createMarketOrder, {
|
|
81
82
|
...normalize,
|
|
82
83
|
cashQuantity: toEthNumber(normalize.cashQuantity),
|
|
83
84
|
});
|
|
@@ -88,7 +89,7 @@ export async function signMarketOrder(signer, order) {
|
|
|
88
89
|
}
|
|
89
90
|
export async function signStopLimitOrder(signer, order) {
|
|
90
91
|
const chainId = await signer.getChainId();
|
|
91
|
-
validatePayload({ ...order, chainId },
|
|
92
|
+
validatePayload({ ...order, chainId }, EIP712Schemas.createStopLimitOrder);
|
|
92
93
|
const normalize = {
|
|
93
94
|
id: order.id,
|
|
94
95
|
instrument: order.instrument,
|
|
@@ -100,7 +101,7 @@ export async function signStopLimitOrder(signer, order) {
|
|
|
100
101
|
tpsl: order.tpsl,
|
|
101
102
|
chainId,
|
|
102
103
|
};
|
|
103
|
-
const signature = await signer.signTypedData(getDomainData(chainId),
|
|
104
|
+
const signature = await signer.signTypedData(getDomainData(chainId), EIP712Schemas.createStopLimitOrder, {
|
|
104
105
|
...normalize,
|
|
105
106
|
quantity: toEthNumber(normalize.quantity),
|
|
106
107
|
limitPrice: toEthNumber(normalize.limitPrice),
|
|
@@ -113,7 +114,7 @@ export async function signStopLimitOrder(signer, order) {
|
|
|
113
114
|
}
|
|
114
115
|
export async function signPositionCloseOrder(signer, order) {
|
|
115
116
|
const chainId = await signer.getChainId();
|
|
116
|
-
validatePayload({ ...order, chainId },
|
|
117
|
+
validatePayload({ ...order, chainId }, EIP712Schemas.createPositionCloseOrder);
|
|
117
118
|
const normalize = {
|
|
118
119
|
id: order.id,
|
|
119
120
|
instrument: order.instrument,
|
|
@@ -121,7 +122,7 @@ export async function signPositionCloseOrder(signer, order) {
|
|
|
121
122
|
quantity: toMatcherNumber(order.quantity),
|
|
122
123
|
chainId,
|
|
123
124
|
};
|
|
124
|
-
const signature = await signer.signTypedData(getDomainData(chainId),
|
|
125
|
+
const signature = await signer.signTypedData(getDomainData(chainId), EIP712Schemas.createPositionCloseOrder, {
|
|
125
126
|
...normalize,
|
|
126
127
|
quantity: toEthNumber(normalize.quantity),
|
|
127
128
|
});
|
|
@@ -131,13 +132,13 @@ export async function signPositionCloseOrder(signer, order) {
|
|
|
131
132
|
};
|
|
132
133
|
}
|
|
133
134
|
export async function signReplaceLimitOrder(signer, order) {
|
|
134
|
-
validatePayload(order,
|
|
135
|
+
validatePayload(order, EIP712Schemas.replaceLimitOrder);
|
|
135
136
|
const normalize = {
|
|
136
137
|
orderId: order.orderId,
|
|
137
138
|
quantity: toMatcherNumber(order.quantity),
|
|
138
139
|
limitPrice: toMatcherNumber(order.limitPrice),
|
|
139
140
|
};
|
|
140
|
-
const signature = await signer.signTypedData(getDomainData(await signer.getChainId()),
|
|
141
|
+
const signature = await signer.signTypedData(getDomainData(await signer.getChainId()), EIP712Schemas.replaceLimitOrder, {
|
|
141
142
|
...normalize,
|
|
142
143
|
quantity: toEthNumber(normalize.quantity),
|
|
143
144
|
limitPrice: toEthNumber(normalize.limitPrice),
|
|
@@ -149,14 +150,14 @@ export async function signReplaceLimitOrder(signer, order) {
|
|
|
149
150
|
};
|
|
150
151
|
}
|
|
151
152
|
export async function signReplaceStopLimitOrder(signer, order) {
|
|
152
|
-
validatePayload(order,
|
|
153
|
+
validatePayload(order, EIP712Schemas.replaceStopLimitOrder);
|
|
153
154
|
const normalize = {
|
|
154
155
|
orderId: order.orderId,
|
|
155
156
|
quantity: toMatcherNumber(order.quantity),
|
|
156
157
|
limitPrice: toMatcherNumber(order.limitPrice),
|
|
157
158
|
stopPrice: toMatcherNumber(order.stopPrice),
|
|
158
159
|
};
|
|
159
|
-
const signature = await signer.signTypedData(getDomainData(await signer.getChainId()),
|
|
160
|
+
const signature = await signer.signTypedData(getDomainData(await signer.getChainId()), EIP712Schemas.replaceStopLimitOrder, {
|
|
160
161
|
...normalize,
|
|
161
162
|
quantity: toEthNumber(normalize.quantity),
|
|
162
163
|
limitPrice: toEthNumber(normalize.limitPrice),
|
|
@@ -168,12 +169,12 @@ export async function signReplaceStopLimitOrder(signer, order) {
|
|
|
168
169
|
};
|
|
169
170
|
}
|
|
170
171
|
export async function signTradingBalanceWithdraw(signer, withdraw) {
|
|
171
|
-
validatePayload(withdraw,
|
|
172
|
+
validatePayload(withdraw, EIP712Schemas.withdraw);
|
|
172
173
|
const normalize = {
|
|
173
174
|
recipient: withdraw.recipient,
|
|
174
175
|
amount: Big(withdraw.amount).round(MATCHER_PRECISION, Big.roundDown).toString(),
|
|
175
176
|
};
|
|
176
|
-
const signature = await signer.signTypedData(getDomainData(await signer.getChainId()),
|
|
177
|
+
const signature = await signer.signTypedData(getDomainData(await signer.getChainId()), EIP712Schemas.withdraw, {
|
|
177
178
|
recipient: withdraw.recipient,
|
|
178
179
|
amount: toEthNumber(normalize.amount),
|
|
179
180
|
});
|
|
@@ -183,7 +184,7 @@ export async function signTradingBalanceWithdraw(signer, withdraw) {
|
|
|
183
184
|
};
|
|
184
185
|
}
|
|
185
186
|
export async function signTpSl(signer, tpsl) {
|
|
186
|
-
validatePayload(tpsl,
|
|
187
|
+
validatePayload(tpsl, EIP712Schemas.createTpSl);
|
|
187
188
|
const normalize = {
|
|
188
189
|
instrument: tpsl.instrument,
|
|
189
190
|
type: tpsl.type,
|
|
@@ -192,7 +193,7 @@ export async function signTpSl(signer, tpsl) {
|
|
|
192
193
|
price: toMatcherNumber(tpsl.price),
|
|
193
194
|
order: tpsl.order,
|
|
194
195
|
};
|
|
195
|
-
const signature = await signer.signTypedData(getDomainData(await signer.getChainId()),
|
|
196
|
+
const signature = await signer.signTypedData(getDomainData(await signer.getChainId()), EIP712Schemas.createTpSl, {
|
|
196
197
|
...normalize,
|
|
197
198
|
quantity: toEthNumber(normalize.quantity),
|
|
198
199
|
price: toEthNumber(normalize.price),
|
|
@@ -204,8 +205,8 @@ export async function signTpSl(signer, tpsl) {
|
|
|
204
205
|
}
|
|
205
206
|
export async function signOauthConsentTequest(signer, payload) {
|
|
206
207
|
const { oauthRequestId } = payload;
|
|
207
|
-
validatePayload({ oauthRequestId },
|
|
208
|
-
const signature = await signer.signTypedData(getDomainData(await signer.getChainId()),
|
|
208
|
+
validatePayload({ oauthRequestId }, EIP712Schemas.oauthConsent);
|
|
209
|
+
const signature = await signer.signTypedData(getDomainData(await signer.getChainId()), EIP712Schemas.oauthConsent, {
|
|
209
210
|
oauthRequestId,
|
|
210
211
|
});
|
|
211
212
|
return {
|
package/dist/mjs/utils/crypto.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Big from "big.js";
|
|
2
2
|
import { MATCHER_PRECISION } from "./constants";
|
|
3
|
-
export const
|
|
3
|
+
export const EIP712Schemas = {
|
|
4
4
|
domain: {
|
|
5
5
|
name: "EVEDEX",
|
|
6
6
|
version: "2",
|
|
@@ -85,7 +85,7 @@ export const EIP721Schemas = {
|
|
|
85
85
|
};
|
|
86
86
|
export function getDomainData(chainId) {
|
|
87
87
|
return {
|
|
88
|
-
...
|
|
88
|
+
...EIP712Schemas.domain,
|
|
89
89
|
chainId,
|
|
90
90
|
};
|
|
91
91
|
}
|