@meshconnect/web-link-sdk 3.1.11 → 3.1.12
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/package.json
CHANGED
@@ -2,8 +2,8 @@ import { ethers } from 'ethers';
|
|
2
2
|
/**
|
3
3
|
* Sends a native EVM transaction
|
4
4
|
*/
|
5
|
-
export declare const sendEVMTransaction: (toAddress: string, amount: bigint, fromAddress: string) => Promise<string | Error>;
|
5
|
+
export declare const sendEVMTransaction: (toAddress: string, amount: bigint, fromAddress: string, gasLimit?: number | null, maxFeePerGas?: number | null, maxPriorityFeePerGas?: number | null) => Promise<string | Error>;
|
6
6
|
/**
|
7
7
|
* Sends an EVM token transaction
|
8
8
|
*/
|
9
|
-
export declare const sendEVMTokenTransaction: (contractAddress: string, abi: ethers.InterfaceAbi, functionName: string, args: unknown[], fromAddress: string
|
9
|
+
export declare const sendEVMTokenTransaction: (contractAddress: string, abi: ethers.InterfaceAbi, functionName: string, args: unknown[], fromAddress: string) => Promise<string | Error>;
|
@@ -34,15 +34,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
34
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
35
35
|
}
|
36
36
|
};
|
37
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
38
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
39
|
-
if (ar || !(i in from)) {
|
40
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
41
|
-
ar[i] = from[i];
|
42
|
-
}
|
43
|
-
}
|
44
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
45
|
-
};
|
46
37
|
import { ethers } from 'ethers';
|
47
38
|
import { getActiveRawProvider } from './provider';
|
48
39
|
var isUserRejection = function (error) {
|
@@ -60,7 +51,7 @@ var isUserRejection = function (error) {
|
|
60
51
|
/**
|
61
52
|
* Sends a native EVM transaction
|
62
53
|
*/
|
63
|
-
export var sendEVMTransaction = function (toAddress, amount, fromAddress) { return __awaiter(void 0, void 0, void 0, function () {
|
54
|
+
export var sendEVMTransaction = function (toAddress, amount, fromAddress, gasLimit, maxFeePerGas, maxPriorityFeePerGas) { return __awaiter(void 0, void 0, void 0, function () {
|
64
55
|
var activeRawProvider, chainIdHex, chainId, provider, signer, network, tx, receipt, txError_1, error_1;
|
65
56
|
return __generator(this, function (_a) {
|
66
57
|
switch (_a.label) {
|
@@ -93,7 +84,14 @@ export var sendEVMTransaction = function (toAddress, amount, fromAddress) { retu
|
|
93
84
|
_a.trys.push([4, 7, , 8]);
|
94
85
|
return [4 /*yield*/, signer.sendTransaction({
|
95
86
|
to: toAddress,
|
96
|
-
value: amount
|
87
|
+
value: amount,
|
88
|
+
gasLimit: gasLimit ? BigInt(Math.floor(gasLimit)) : undefined,
|
89
|
+
maxFeePerGas: maxFeePerGas
|
90
|
+
? BigInt(Math.floor(maxFeePerGas))
|
91
|
+
: undefined,
|
92
|
+
maxPriorityFeePerGas: maxPriorityFeePerGas
|
93
|
+
? BigInt(Math.floor(maxPriorityFeePerGas))
|
94
|
+
: undefined
|
97
95
|
})];
|
98
96
|
case 5:
|
99
97
|
tx = _a.sent();
|
@@ -127,12 +125,12 @@ export var sendEVMTransaction = function (toAddress, amount, fromAddress) { retu
|
|
127
125
|
/**
|
128
126
|
* Sends an EVM token transaction
|
129
127
|
*/
|
130
|
-
export var sendEVMTokenTransaction = function (contractAddress, abi, functionName, args, fromAddress
|
131
|
-
var activeRawProvider, chainIdHex, chainId, provider, signer, network, contract, txOptions,
|
128
|
+
export var sendEVMTokenTransaction = function (contractAddress, abi, functionName, args, fromAddress) { return __awaiter(void 0, void 0, void 0, function () {
|
129
|
+
var activeRawProvider, chainIdHex, chainId, provider, signer, network, contract, txOptions, gasLimit, maxFeePerGas, maxPriorityFeePerGas, tx, receipt, txError_2, error_2;
|
132
130
|
return __generator(this, function (_a) {
|
133
131
|
switch (_a.label) {
|
134
132
|
case 0:
|
135
|
-
_a.trys.push([0,
|
133
|
+
_a.trys.push([0, 9, , 10]);
|
136
134
|
activeRawProvider = getActiveRawProvider();
|
137
135
|
if (!activeRawProvider) {
|
138
136
|
throw new Error('No active EVM provider');
|
@@ -157,34 +155,40 @@ export var sendEVMTokenTransaction = function (contractAddress, abi, functionNam
|
|
157
155
|
}
|
158
156
|
contract = new ethers.Contract(contractAddress, abi, signer);
|
159
157
|
txOptions = {};
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
txOptions.gasPrice = feeData.gasPrice
|
164
|
-
? (feeData.gasPrice * BigInt(1000)) / BigInt(100)
|
158
|
+
gasLimit = (args === null || args === void 0 ? void 0 : args[2]) !== undefined ? toSafeNumber(args[2], 'gasLimit') : undefined;
|
159
|
+
maxFeePerGas = (args === null || args === void 0 ? void 0 : args[3]) !== undefined
|
160
|
+
? toSafeNumber(args[3], 'maxFeePerGas')
|
165
161
|
: undefined;
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
162
|
+
maxPriorityFeePerGas = (args === null || args === void 0 ? void 0 : args[4]) !== undefined
|
163
|
+
? toSafeNumber(args[4], 'maxPriorityFeePerGas')
|
164
|
+
: undefined;
|
165
|
+
txOptions.gasLimit = gasLimit ? BigInt(Math.floor(gasLimit)) : undefined;
|
166
|
+
txOptions.maxFeePerGas = maxFeePerGas
|
167
|
+
? BigInt(Math.floor(maxFeePerGas))
|
168
|
+
: undefined;
|
169
|
+
txOptions.maxPriorityFeePerGas = maxPriorityFeePerGas
|
170
|
+
? BigInt(Math.floor(maxPriorityFeePerGas))
|
171
|
+
: undefined;
|
172
|
+
_a.label = 4;
|
173
|
+
case 4:
|
174
|
+
_a.trys.push([4, 7, , 8]);
|
175
|
+
return [4 /*yield*/, contract[functionName](args[0], args[1], txOptions)
|
176
|
+
// Wait for transaction confirmation
|
177
|
+
];
|
171
178
|
case 5:
|
172
|
-
_a.trys.push([5, 8, , 9]);
|
173
|
-
return [4 /*yield*/, contract[functionName].apply(contract, __spreadArray(__spreadArray([], args, false), [txOptions], false))];
|
174
|
-
case 6:
|
175
179
|
tx = _a.sent();
|
176
180
|
return [4 /*yield*/, tx.wait()];
|
177
|
-
case
|
181
|
+
case 6:
|
178
182
|
receipt = _a.sent();
|
179
183
|
return [2 /*return*/, receipt ? receipt.hash : ''];
|
180
|
-
case
|
184
|
+
case 7:
|
181
185
|
txError_2 = _a.sent();
|
182
186
|
if (isUserRejection(txError_2)) {
|
183
187
|
return [2 /*return*/, new Error('Transaction was rejected by user')];
|
184
188
|
}
|
185
189
|
throw txError_2;
|
186
|
-
case
|
187
|
-
case
|
190
|
+
case 8: return [3 /*break*/, 10];
|
191
|
+
case 9:
|
188
192
|
error_2 = _a.sent();
|
189
193
|
console.error('Token transaction error:', error_2);
|
190
194
|
if (isUserRejection(error_2)) {
|
@@ -196,7 +200,13 @@ export var sendEVMTokenTransaction = function (contractAddress, abi, functionNam
|
|
196
200
|
return [2 /*return*/, error_2 instanceof Error
|
197
201
|
? error_2
|
198
202
|
: new Error('Failed to send token transaction')];
|
199
|
-
case
|
203
|
+
case 10: return [2 /*return*/];
|
200
204
|
}
|
201
205
|
});
|
202
206
|
}); };
|
207
|
+
function toSafeNumber(value, name) {
|
208
|
+
if (typeof value !== 'number' || Number.isNaN(value)) {
|
209
|
+
throw new TypeError("Invalid ".concat(name, ": expected a number, got ").concat(typeof value, " (").concat(value, ")"));
|
210
|
+
}
|
211
|
+
return value;
|
212
|
+
}
|
package/utils/types.d.ts
CHANGED
@@ -119,6 +119,9 @@ export interface TransferPayload {
|
|
119
119
|
network: string;
|
120
120
|
blockhash?: string;
|
121
121
|
walletName?: string;
|
122
|
+
gasLimit?: number | null;
|
123
|
+
maxFeePerGas?: number | null;
|
124
|
+
maxPriorityFeePerGas?: number | null;
|
122
125
|
}
|
123
126
|
export interface SmartContractPayload {
|
124
127
|
address: string;
|
@@ -129,7 +132,9 @@ export interface SmartContractPayload {
|
|
129
132
|
value?: string;
|
130
133
|
walletName?: string;
|
131
134
|
blockhash?: string;
|
132
|
-
gasLimit?:
|
135
|
+
gasLimit?: number | null;
|
136
|
+
maxFeePerGas?: number | null;
|
137
|
+
maxPriorityFeePerGas?: number | null;
|
133
138
|
}
|
134
139
|
export interface DisconnectPayload {
|
135
140
|
networkType?: string;
|
package/utils/version.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export declare const sdkVersion = "3.1.
|
1
|
+
export declare const sdkVersion = "3.1.12";
|
package/utils/version.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export var sdkVersion = '3.1.
|
1
|
+
export var sdkVersion = '3.1.12';
|
@@ -155,7 +155,7 @@ var EVMWalletStrategy = /** @class */ (function (_super) {
|
|
155
155
|
switch (_a.label) {
|
156
156
|
case 0:
|
157
157
|
_a.trys.push([0, 2, , 3]);
|
158
|
-
return [4 /*yield*/, sendEVMTransaction(payload.toAddress, BigInt(payload.amount * Math.pow(10, payload.decimalPlaces)), payload.account)];
|
158
|
+
return [4 /*yield*/, sendEVMTransaction(payload.toAddress, BigInt(payload.amount * Math.pow(10, payload.decimalPlaces)), payload.account, payload.gasLimit, payload.maxFeePerGas, payload.maxPriorityFeePerGas)];
|
159
159
|
case 1:
|
160
160
|
result = _a.sent();
|
161
161
|
if (result instanceof Error) {
|
@@ -177,7 +177,7 @@ var EVMWalletStrategy = /** @class */ (function (_super) {
|
|
177
177
|
switch (_a.label) {
|
178
178
|
case 0:
|
179
179
|
_a.trys.push([0, 2, , 3]);
|
180
|
-
return [4 /*yield*/, sendEVMTokenTransaction(payload.address, JSON.parse(payload.abi), payload.functionName, payload.args, payload.account
|
180
|
+
return [4 /*yield*/, sendEVMTokenTransaction(payload.address, JSON.parse(payload.abi), payload.functionName, payload.args, payload.account)];
|
181
181
|
case 1:
|
182
182
|
result = _a.sent();
|
183
183
|
if (result instanceof Error) {
|