@pioneer-platform/uniswap-client 0.0.19 → 0.0.20
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/lib/index.js +25 -8
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -482,11 +482,11 @@ function toDeadline(expiration) {
|
|
|
482
482
|
var build_permit_tx = function (_a) {
|
|
483
483
|
var from = _a.from, token = _a.token, amount = _a.amount, chainId = _a.chainId;
|
|
484
484
|
return __awaiter(this, void 0, void 0, function () {
|
|
485
|
-
var PERMIT_EXPIRATION, PERMIT_SIG_EXPIRATION, providerUrl, provider, nonce, permit,
|
|
486
|
-
return __generator(this, function (
|
|
487
|
-
switch (
|
|
485
|
+
var PERMIT_EXPIRATION, PERMIT_SIG_EXPIRATION, providerUrl, provider, nonce, permit, fullResponse, domain, types, values, typedData, tx, e_6;
|
|
486
|
+
return __generator(this, function (_b) {
|
|
487
|
+
switch (_b.label) {
|
|
488
488
|
case 0:
|
|
489
|
-
|
|
489
|
+
_b.trys.push([0, 2, , 3]);
|
|
490
490
|
PERMIT_EXPIRATION = 2592000000;
|
|
491
491
|
PERMIT_SIG_EXPIRATION = 1800000;
|
|
492
492
|
providerUrl = EIP155_MAINNET_CHAINS['eip155:' + chainId].rpc;
|
|
@@ -496,7 +496,7 @@ var build_permit_tx = function (_a) {
|
|
|
496
496
|
provider = new ethers.providers.JsonRpcProvider(providerUrl);
|
|
497
497
|
return [4 /*yield*/, provider.getTransactionCount(from, "latest")];
|
|
498
498
|
case 1:
|
|
499
|
-
nonce =
|
|
499
|
+
nonce = _b.sent();
|
|
500
500
|
permit = {
|
|
501
501
|
details: {
|
|
502
502
|
token: token,
|
|
@@ -507,14 +507,31 @@ var build_permit_tx = function (_a) {
|
|
|
507
507
|
spender: from,
|
|
508
508
|
sigDeadline: toDeadline(PERMIT_SIG_EXPIRATION),
|
|
509
509
|
};
|
|
510
|
-
|
|
510
|
+
fullResponse = permit2_sdk_1.AllowanceTransfer.getPermitData(permit, permit2_sdk_1.PERMIT2_ADDRESS, chainId);
|
|
511
|
+
log.info("fullResponse: ", fullResponse);
|
|
512
|
+
domain = fullResponse.domain, types = fullResponse.types, values = fullResponse.values;
|
|
513
|
+
// Ensure 'EIP712Domain' is included in the types definitions
|
|
514
|
+
// If it's not already present or not recognized for some reason, define it explicitly
|
|
515
|
+
if (!types['EIP712Domain']) {
|
|
516
|
+
types['EIP712Domain'] = [
|
|
517
|
+
{ name: "name", type: "string" },
|
|
518
|
+
{ name: "chainId", type: "uint256" },
|
|
519
|
+
{ name: "verifyingContract", type: "address" },
|
|
520
|
+
];
|
|
521
|
+
}
|
|
522
|
+
typedData = {
|
|
523
|
+
domain: domain,
|
|
524
|
+
types: types,
|
|
525
|
+
message: values, // Use 'values' as the 'message' for EIP712 signing
|
|
526
|
+
primaryType: "PermitSingle" // Assuming 'PermitSingle' as the primaryType based on your types definition
|
|
527
|
+
};
|
|
511
528
|
tx = {
|
|
512
529
|
type: 'signTypedData',
|
|
513
|
-
txParams:
|
|
530
|
+
txParams: typedData // Ensuring txParams contains the correctly formatted EIP-712 data
|
|
514
531
|
};
|
|
515
532
|
return [2 /*return*/, tx];
|
|
516
533
|
case 2:
|
|
517
|
-
e_6 =
|
|
534
|
+
e_6 = _b.sent();
|
|
518
535
|
console.error(e_6);
|
|
519
536
|
return [3 /*break*/, 3];
|
|
520
537
|
case 3: return [2 /*return*/];
|