@dynamic-labs/ethereum-core 3.0.0-alpha.49
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/CHANGELOG.md +3894 -0
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/_virtual/_tslib.cjs +49 -0
- package/_virtual/_tslib.js +44 -0
- package/package.json +37 -0
- package/src/index.cjs +34 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +13 -0
- package/src/lib/utils/index.d.ts +2 -0
- package/src/lib/utils/logger.cjs +10 -0
- package/src/lib/utils/logger.d.ts +2 -0
- package/src/lib/utils/logger.js +6 -0
- package/src/lib/utils/validateAddressFormat.cjs +8 -0
- package/src/lib/utils/validateAddressFormat.d.ts +1 -0
- package/src/lib/utils/validateAddressFormat.js +4 -0
- package/src/lib/utils/viem/Eip1559FeeFeed.cjs +51 -0
- package/src/lib/utils/viem/Eip1559FeeFeed.d.ts +20 -0
- package/src/lib/utils/viem/Eip1559FeeFeed.js +47 -0
- package/src/lib/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.cjs +98 -0
- package/src/lib/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.d.ts +37 -0
- package/src/lib/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.js +94 -0
- package/src/lib/utils/viem/ViemRpcUiTransaction/index.d.ts +1 -0
- package/src/lib/utils/viem/ViemUiTransaction/ViemUiTransaction.cjs +121 -0
- package/src/lib/utils/viem/ViemUiTransaction/ViemUiTransaction.d.ts +56 -0
- package/src/lib/utils/viem/ViemUiTransaction/ViemUiTransaction.js +117 -0
- package/src/lib/utils/viem/ViemUiTransaction/index.d.ts +2 -0
- package/src/lib/utils/viem/chainsMap/chainsMap.cjs +31 -0
- package/src/lib/utils/viem/chainsMap/chainsMap.d.ts +2 -0
- package/src/lib/utils/viem/chainsMap/chainsMap.js +7 -0
- package/src/lib/utils/viem/chainsMap/index.d.ts +1 -0
- package/src/lib/utils/viem/confirmationTransport/confirmationTransport.cjs +39 -0
- package/src/lib/utils/viem/confirmationTransport/confirmationTransport.d.ts +11 -0
- package/src/lib/utils/viem/confirmationTransport/confirmationTransport.js +35 -0
- package/src/lib/utils/viem/confirmationTransport/index.d.ts +1 -0
- package/src/lib/utils/viem/createAccountWithUiConfirmation/createAccountWithUiConfirmation.cjs +41 -0
- package/src/lib/utils/viem/createAccountWithUiConfirmation/createAccountWithUiConfirmation.d.ts +12 -0
- package/src/lib/utils/viem/createAccountWithUiConfirmation/createAccountWithUiConfirmation.js +37 -0
- package/src/lib/utils/viem/createAccountWithUiConfirmation/index.d.ts +1 -0
- package/src/lib/utils/viem/createTransportWithUiConfirmation/createTransportWithUiConfirmation.cjs +33 -0
- package/src/lib/utils/viem/createTransportWithUiConfirmation/createTransportWithUiConfirmation.d.ts +25 -0
- package/src/lib/utils/viem/createTransportWithUiConfirmation/createTransportWithUiConfirmation.js +29 -0
- package/src/lib/utils/viem/createTransportWithUiConfirmation/index.d.ts +1 -0
- package/src/lib/utils/viem/createViemUiTransaction/createViemUiTransaction.cjs +40 -0
- package/src/lib/utils/viem/createViemUiTransaction/createViemUiTransaction.d.ts +9 -0
- package/src/lib/utils/viem/createViemUiTransaction/createViemUiTransaction.js +36 -0
- package/src/lib/utils/viem/createViemUiTransaction/index.d.ts +1 -0
- package/src/lib/utils/viem/createWalletClientFromWallet/createWalletClientFromWallet.cjs +70 -0
- package/src/lib/utils/viem/createWalletClientFromWallet/createWalletClientFromWallet.d.ts +19 -0
- package/src/lib/utils/viem/createWalletClientFromWallet/createWalletClientFromWallet.js +46 -0
- package/src/lib/utils/viem/createWalletClientFromWallet/index.d.ts +1 -0
- package/src/lib/utils/viem/createWalletClientWithUiConfirmation/createWalletClientWithUiConfirmation.cjs +73 -0
- package/src/lib/utils/viem/createWalletClientWithUiConfirmation/createWalletClientWithUiConfirmation.d.ts +29 -0
- package/src/lib/utils/viem/createWalletClientWithUiConfirmation/createWalletClientWithUiConfirmation.js +69 -0
- package/src/lib/utils/viem/createWalletClientWithUiConfirmation/index.d.ts +1 -0
- package/src/lib/utils/viem/erc20/abi.cjs +230 -0
- package/src/lib/utils/viem/erc20/abi.d.ts +38 -0
- package/src/lib/utils/viem/erc20/abi.js +226 -0
- package/src/lib/utils/viem/erc20/index.d.ts +1 -0
- package/src/lib/utils/viem/estimateL1Fee/estimateL1Fee.cjs +31 -0
- package/src/lib/utils/viem/estimateL1Fee/estimateL1Fee.d.ts +10 -0
- package/src/lib/utils/viem/estimateL1Fee/estimateL1Fee.js +26 -0
- package/src/lib/utils/viem/estimateL1Fee/index.d.ts +1 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/abi.cjs +23 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/abi.d.ts +20 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/abi.js +18 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/estimateL1Fee.cjs +30 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/estimateL1Fee.d.ts +3 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/estimateL1Fee.js +25 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/index.d.ts +1 -0
- package/src/lib/utils/viem/formatEther/formatEther.cjs +11 -0
- package/src/lib/utils/viem/formatEther/formatEther.d.ts +2 -0
- package/src/lib/utils/viem/formatEther/formatEther.js +7 -0
- package/src/lib/utils/viem/formatEther/index.d.ts +1 -0
- package/src/lib/utils/viem/getOrMapViemChain/getOrMapViemChain.cjs +77 -0
- package/src/lib/utils/viem/getOrMapViemChain/getOrMapViemChain.d.ts +11 -0
- package/src/lib/utils/viem/getOrMapViemChain/getOrMapViemChain.js +51 -0
- package/src/lib/utils/viem/getOrMapViemChain/index.d.ts +1 -0
- package/src/lib/utils/viem/index.d.ts +11 -0
- package/src/lib/utils/viem/interceptTransport/index.d.ts +1 -0
- package/src/lib/utils/viem/interceptTransport/interceptTransport.cjs +35 -0
- package/src/lib/utils/viem/interceptTransport/interceptTransport.d.ts +29 -0
- package/src/lib/utils/viem/interceptTransport/interceptTransport.js +31 -0
- package/src/lib/utils/viem/parseEther/index.d.ts +1 -0
- package/src/lib/utils/viem/parseEther/parseEther.cjs +10 -0
- package/src/lib/utils/viem/parseEther/parseEther.d.ts +1 -0
- package/src/lib/utils/viem/parseEther/parseEther.js +6 -0
- package/src/lib/utils/viem/unFormatTransaction/index.d.ts +1 -0
- package/src/lib/utils/viem/unFormatTransaction/unFormatTransaction.cjs +30 -0
- package/src/lib/utils/viem/unFormatTransaction/unFormatTransaction.d.ts +8 -0
- package/src/lib/utils/viem/unFormatTransaction/unFormatTransaction.js +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Dynamic Labs, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# ethereum core
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build ethereum-core` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test ethereum-core` to execute the unit tests via [Jest](https://jestjs.io).
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/******************************************************************************
|
|
7
|
+
Copyright (c) Microsoft Corporation.
|
|
8
|
+
|
|
9
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
+
purpose with or without fee is hereby granted.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
+
***************************************************************************** */
|
|
20
|
+
|
|
21
|
+
function __rest(s, e) {
|
|
22
|
+
var t = {};
|
|
23
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24
|
+
t[p] = s[p];
|
|
25
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
26
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
27
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
28
|
+
t[p[i]] = s[p[i]];
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
34
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
35
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
36
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
37
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
38
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
39
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
44
|
+
var e = new Error(message);
|
|
45
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.__awaiter = __awaiter;
|
|
49
|
+
exports.__rest = __rest;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/******************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
***************************************************************************** */
|
|
16
|
+
|
|
17
|
+
function __rest(s, e) {
|
|
18
|
+
var t = {};
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
22
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
23
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24
|
+
t[p[i]] = s[p[i]];
|
|
25
|
+
}
|
|
26
|
+
return t;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
30
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
31
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
32
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
33
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
34
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
35
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
40
|
+
var e = new Error(message);
|
|
41
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { __awaiter, __rest };
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dynamic-labs/ethereum-core",
|
|
3
|
+
"version": "3.0.0-alpha.49",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
7
|
+
"directory": "packages/ethereum-core"
|
|
8
|
+
},
|
|
9
|
+
"description": "Core package for utilities and types for viem",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/dynamic-labs/DynamicAuth/issues"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/dynamic-labs/DynamicAuth/main/packages/ethereum-core#readme",
|
|
14
|
+
"author": "Dynamic Labs, Inc.",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"main": "./src/index.cjs",
|
|
17
|
+
"module": "./src/index.js",
|
|
18
|
+
"types": "./src/index.d.ts",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./src/index.d.ts",
|
|
23
|
+
"import": "./src/index.js",
|
|
24
|
+
"require": "./src/index.cjs"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"viem": "^2.7.6",
|
|
30
|
+
"@dynamic-labs/logger": "3.0.0-alpha.49",
|
|
31
|
+
"@dynamic-labs/types": "3.0.0-alpha.49",
|
|
32
|
+
"@dynamic-labs/utils": "3.0.0-alpha.49",
|
|
33
|
+
"@dynamic-labs/wallet-book": "3.0.0-alpha.49",
|
|
34
|
+
"@dynamic-labs/wallet-connector-core": "3.0.0-alpha.49",
|
|
35
|
+
"eventemitter3": "5.0.1"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/index.cjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var ViemRpcUiTransaction = require('./lib/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.cjs');
|
|
7
|
+
var ViemUiTransaction = require('./lib/utils/viem/ViemUiTransaction/ViemUiTransaction.cjs');
|
|
8
|
+
var chainsMap = require('./lib/utils/viem/chainsMap/chainsMap.cjs');
|
|
9
|
+
var confirmationTransport = require('./lib/utils/viem/confirmationTransport/confirmationTransport.cjs');
|
|
10
|
+
var createTransportWithUiConfirmation = require('./lib/utils/viem/createTransportWithUiConfirmation/createTransportWithUiConfirmation.cjs');
|
|
11
|
+
var createViemUiTransaction = require('./lib/utils/viem/createViemUiTransaction/createViemUiTransaction.cjs');
|
|
12
|
+
var createWalletClientFromWallet = require('./lib/utils/viem/createWalletClientFromWallet/createWalletClientFromWallet.cjs');
|
|
13
|
+
var createWalletClientWithUiConfirmation = require('./lib/utils/viem/createWalletClientWithUiConfirmation/createWalletClientWithUiConfirmation.cjs');
|
|
14
|
+
var getOrMapViemChain = require('./lib/utils/viem/getOrMapViemChain/getOrMapViemChain.cjs');
|
|
15
|
+
var unFormatTransaction = require('./lib/utils/viem/unFormatTransaction/unFormatTransaction.cjs');
|
|
16
|
+
var abi = require('./lib/utils/viem/erc20/abi.cjs');
|
|
17
|
+
var validateAddressFormat = require('./lib/utils/validateAddressFormat.cjs');
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
exports.ViemRpcUiTransaction = ViemRpcUiTransaction.ViemRpcUiTransaction;
|
|
22
|
+
exports.ViemUiTransaction = ViemUiTransaction.ViemUiTransaction;
|
|
23
|
+
exports.chainsMap = chainsMap.chainsMap;
|
|
24
|
+
exports.confirmationTransport = confirmationTransport.confirmationTransport;
|
|
25
|
+
exports.createTransportWithUiConfirmation = createTransportWithUiConfirmation.createTransportWithUiConfirmation;
|
|
26
|
+
exports.createViemUiTransaction = createViemUiTransaction.createViemUiTransaction;
|
|
27
|
+
exports.createWalletClientFromWallet = createWalletClientFromWallet.createWalletClientFromWallet;
|
|
28
|
+
exports.createWalletClientWithUiConfirmation = createWalletClientWithUiConfirmation.createWalletClientWithUiConfirmation;
|
|
29
|
+
exports.getChain = getOrMapViemChain.getChain;
|
|
30
|
+
exports.getOrMapViemChain = getOrMapViemChain.getOrMapViemChain;
|
|
31
|
+
exports.mapChain = getOrMapViemChain.mapChain;
|
|
32
|
+
exports.unFormatTransaction = unFormatTransaction.unFormatTransaction;
|
|
33
|
+
exports.erc20Abi = abi.erc20Abi;
|
|
34
|
+
exports.validateAddressFormat = validateAddressFormat.validateAddressFormat;
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/utils';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
export { ViemRpcUiTransaction } from './lib/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.js';
|
|
3
|
+
export { ViemUiTransaction } from './lib/utils/viem/ViemUiTransaction/ViemUiTransaction.js';
|
|
4
|
+
export { chainsMap } from './lib/utils/viem/chainsMap/chainsMap.js';
|
|
5
|
+
export { confirmationTransport } from './lib/utils/viem/confirmationTransport/confirmationTransport.js';
|
|
6
|
+
export { createTransportWithUiConfirmation } from './lib/utils/viem/createTransportWithUiConfirmation/createTransportWithUiConfirmation.js';
|
|
7
|
+
export { createViemUiTransaction } from './lib/utils/viem/createViemUiTransaction/createViemUiTransaction.js';
|
|
8
|
+
export { createWalletClientFromWallet } from './lib/utils/viem/createWalletClientFromWallet/createWalletClientFromWallet.js';
|
|
9
|
+
export { createWalletClientWithUiConfirmation } from './lib/utils/viem/createWalletClientWithUiConfirmation/createWalletClientWithUiConfirmation.js';
|
|
10
|
+
export { getChain, getOrMapViemChain, mapChain } from './lib/utils/viem/getOrMapViemChain/getOrMapViemChain.js';
|
|
11
|
+
export { unFormatTransaction } from './lib/utils/viem/unFormatTransaction/unFormatTransaction.js';
|
|
12
|
+
export { erc20Abi } from './lib/utils/viem/erc20/abi.js';
|
|
13
|
+
export { validateAddressFormat } from './lib/utils/validateAddressFormat.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const validateAddressFormat: (address: string) => boolean;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var logger = require('../logger.cjs');
|
|
8
|
+
|
|
9
|
+
class Eip1559FeeFeed {
|
|
10
|
+
constructor({ publicClient, initialGasLimit, initialMaxFeePerGas, }) {
|
|
11
|
+
this.fee = {
|
|
12
|
+
gas: BigInt(0),
|
|
13
|
+
};
|
|
14
|
+
this.publicClient = publicClient;
|
|
15
|
+
this.initialGasLimit = initialGasLimit;
|
|
16
|
+
this.initialMaxFeePerGas = initialMaxFeePerGas;
|
|
17
|
+
}
|
|
18
|
+
fetchFee() {
|
|
19
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
try {
|
|
21
|
+
const l1Fee = yield this.estimateL1Fee();
|
|
22
|
+
// Original transaction already defined the gas limit and max fee per gas
|
|
23
|
+
if (this.initialGasLimit && this.initialMaxFeePerGas) {
|
|
24
|
+
this.fee.gas = this.initialGasLimit * this.initialMaxFeePerGas + l1Fee;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Estimate the gas limit
|
|
28
|
+
const gasLimit = yield this.estimateGas();
|
|
29
|
+
// Original transaction defined the max fee per gas
|
|
30
|
+
if (this.initialMaxFeePerGas) {
|
|
31
|
+
this.fee.gas = gasLimit * this.initialMaxFeePerGas + l1Fee;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
// Estimate max fee per gas
|
|
35
|
+
const estimatedFeesPerGas = yield this.publicClient.estimateFeesPerGas();
|
|
36
|
+
if (!estimatedFeesPerGas || !estimatedFeesPerGas.maxFeePerGas) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
this.fee.gas = gasLimit * estimatedFeesPerGas.maxFeePerGas + l1Fee;
|
|
40
|
+
this.maxFeePerGas = estimatedFeesPerGas.maxFeePerGas;
|
|
41
|
+
this.maxPriorityFeePerGas = estimatedFeesPerGas.maxPriorityFeePerGas;
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
logger.logger.debug(error);
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
exports.Eip1559FeeFeed = Eip1559FeeFeed;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Chain, PublicClient, Transport } from 'viem';
|
|
2
|
+
import { IUITransaction } from '@dynamic-labs/types';
|
|
3
|
+
type Eip1559FeeFeedProps = {
|
|
4
|
+
initialMaxFeePerGas?: bigint;
|
|
5
|
+
initialGasLimit?: bigint;
|
|
6
|
+
publicClient: PublicClient<Transport, Chain>;
|
|
7
|
+
};
|
|
8
|
+
export declare abstract class Eip1559FeeFeed {
|
|
9
|
+
fee: IUITransaction['fee'];
|
|
10
|
+
private initialMaxFeePerGas;
|
|
11
|
+
private initialGasLimit;
|
|
12
|
+
protected publicClient: PublicClient<Transport, Chain>;
|
|
13
|
+
constructor({ publicClient, initialGasLimit, initialMaxFeePerGas, }: Eip1559FeeFeedProps);
|
|
14
|
+
abstract estimateGas(): Promise<bigint>;
|
|
15
|
+
abstract estimateL1Fee(): Promise<bigint>;
|
|
16
|
+
abstract set maxFeePerGas(value: bigint);
|
|
17
|
+
abstract set maxPriorityFeePerGas(value: bigint);
|
|
18
|
+
fetchFee(): Promise<undefined>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
3
|
+
import { logger } from '../logger.js';
|
|
4
|
+
|
|
5
|
+
class Eip1559FeeFeed {
|
|
6
|
+
constructor({ publicClient, initialGasLimit, initialMaxFeePerGas, }) {
|
|
7
|
+
this.fee = {
|
|
8
|
+
gas: BigInt(0),
|
|
9
|
+
};
|
|
10
|
+
this.publicClient = publicClient;
|
|
11
|
+
this.initialGasLimit = initialGasLimit;
|
|
12
|
+
this.initialMaxFeePerGas = initialMaxFeePerGas;
|
|
13
|
+
}
|
|
14
|
+
fetchFee() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
try {
|
|
17
|
+
const l1Fee = yield this.estimateL1Fee();
|
|
18
|
+
// Original transaction already defined the gas limit and max fee per gas
|
|
19
|
+
if (this.initialGasLimit && this.initialMaxFeePerGas) {
|
|
20
|
+
this.fee.gas = this.initialGasLimit * this.initialMaxFeePerGas + l1Fee;
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// Estimate the gas limit
|
|
24
|
+
const gasLimit = yield this.estimateGas();
|
|
25
|
+
// Original transaction defined the max fee per gas
|
|
26
|
+
if (this.initialMaxFeePerGas) {
|
|
27
|
+
this.fee.gas = gasLimit * this.initialMaxFeePerGas + l1Fee;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// Estimate max fee per gas
|
|
31
|
+
const estimatedFeesPerGas = yield this.publicClient.estimateFeesPerGas();
|
|
32
|
+
if (!estimatedFeesPerGas || !estimatedFeesPerGas.maxFeePerGas) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
this.fee.gas = gasLimit * estimatedFeesPerGas.maxFeePerGas + l1Fee;
|
|
36
|
+
this.maxFeePerGas = estimatedFeesPerGas.maxFeePerGas;
|
|
37
|
+
this.maxPriorityFeePerGas = estimatedFeesPerGas.maxPriorityFeePerGas;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
logger.debug(error);
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { Eip1559FeeFeed };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var viem = require('viem');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
9
|
+
var validateAddressFormat = require('../../validateAddressFormat.cjs');
|
|
10
|
+
var Eip1559FeeFeed = require('../Eip1559FeeFeed.cjs');
|
|
11
|
+
var estimateL1Fee = require('../estimateL1Fee/estimateL1Fee.cjs');
|
|
12
|
+
var parseEther = require('../parseEther/parseEther.cjs');
|
|
13
|
+
var formatEther = require('../formatEther/formatEther.cjs');
|
|
14
|
+
|
|
15
|
+
class ViemRpcUiTransaction extends Eip1559FeeFeed.Eip1559FeeFeed {
|
|
16
|
+
constructor({ transaction, onSubmit, publicClient, }) {
|
|
17
|
+
super({
|
|
18
|
+
initialGasLimit: transaction.gas
|
|
19
|
+
? viem.hexToBigInt(transaction.gas)
|
|
20
|
+
: undefined,
|
|
21
|
+
initialMaxFeePerGas: transaction.maxFeePerGas
|
|
22
|
+
? viem.hexToBigInt(transaction.maxFeePerGas)
|
|
23
|
+
: undefined,
|
|
24
|
+
publicClient,
|
|
25
|
+
});
|
|
26
|
+
this.chain = 'EVM';
|
|
27
|
+
this.validateAddressFormat = validateAddressFormat.validateAddressFormat;
|
|
28
|
+
this.parse = parseEther.parseEther;
|
|
29
|
+
this.format = formatEther.formatEther;
|
|
30
|
+
this.transaction = transaction;
|
|
31
|
+
this.onSubmit = onSubmit;
|
|
32
|
+
this.publicClient = publicClient;
|
|
33
|
+
}
|
|
34
|
+
get to() {
|
|
35
|
+
return this.transaction.to || undefined;
|
|
36
|
+
}
|
|
37
|
+
get from() {
|
|
38
|
+
return this.transaction.from;
|
|
39
|
+
}
|
|
40
|
+
get value() {
|
|
41
|
+
const { value } = this.transaction;
|
|
42
|
+
return value ? viem.hexToBigInt(value) : undefined;
|
|
43
|
+
}
|
|
44
|
+
get data() {
|
|
45
|
+
return this.transaction.data;
|
|
46
|
+
}
|
|
47
|
+
submit() {
|
|
48
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
return this.onSubmit(this.transaction).catch((error) => {
|
|
50
|
+
if (error instanceof utils.UserRejectedTransactionError) {
|
|
51
|
+
throw new viem.TransactionExecutionError(new viem.BaseError(error.message), this.transaction);
|
|
52
|
+
}
|
|
53
|
+
throw error;
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
getBalance() {
|
|
58
|
+
return this.publicClient.getBalance({
|
|
59
|
+
address: this.transaction.from,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
estimateGas() {
|
|
63
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
65
|
+
const _a = this.transaction, transaction = _tslib.__rest(_a, ["from"]);
|
|
66
|
+
const hexResult = (yield this.publicClient.transport.request({
|
|
67
|
+
method: 'eth_estimateGas',
|
|
68
|
+
params: [transaction],
|
|
69
|
+
}));
|
|
70
|
+
return viem.hexToBigInt(hexResult);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
estimateL1Fee() {
|
|
74
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
var _a;
|
|
76
|
+
if (!estimateL1Fee.isL1FeeSupportedByChain(((_a = this.publicClient.chain) === null || _a === void 0 ? void 0 : _a.id) || 0)) {
|
|
77
|
+
return BigInt(0);
|
|
78
|
+
}
|
|
79
|
+
const result = yield estimateL1Fee.estimateL1Fee(this.publicClient, {
|
|
80
|
+
data: this.transaction.data,
|
|
81
|
+
to: this.transaction.to,
|
|
82
|
+
value: this.convertHexToBigInt(this.transaction.value),
|
|
83
|
+
});
|
|
84
|
+
return result;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
set maxFeePerGas(value) {
|
|
88
|
+
this.transaction.maxFeePerGas = viem.toHex(value);
|
|
89
|
+
}
|
|
90
|
+
set maxPriorityFeePerGas(value) {
|
|
91
|
+
this.transaction.maxPriorityFeePerGas = viem.toHex(value);
|
|
92
|
+
}
|
|
93
|
+
convertHexToBigInt(value) {
|
|
94
|
+
return value ? viem.hexToBigInt(value) : undefined;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
exports.ViemRpcUiTransaction = ViemRpcUiTransaction;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Chain, PublicClient, RpcTransactionRequest, Transport } from 'viem';
|
|
2
|
+
import { IUITransaction } from '@dynamic-labs/types';
|
|
3
|
+
import { Eip1559FeeFeed } from '../Eip1559FeeFeed';
|
|
4
|
+
type ViemRpcUiTransactionProps = {
|
|
5
|
+
transaction: RpcTransactionRequest;
|
|
6
|
+
onSubmit: (transaction: RpcTransactionRequest) => Promise<string>;
|
|
7
|
+
publicClient: PublicClient<Transport, Chain>;
|
|
8
|
+
};
|
|
9
|
+
export declare class ViemRpcUiTransaction extends Eip1559FeeFeed implements IUITransaction {
|
|
10
|
+
chain: string;
|
|
11
|
+
receipt: string | undefined;
|
|
12
|
+
private transaction;
|
|
13
|
+
protected publicClient: PublicClient<Transport, Chain>;
|
|
14
|
+
private onSubmit;
|
|
15
|
+
constructor({ transaction, onSubmit, publicClient, }: ViemRpcUiTransactionProps);
|
|
16
|
+
nonNativeValue?: bigint | undefined;
|
|
17
|
+
nonNativeAddress?: string | undefined;
|
|
18
|
+
nonNativeDecimal?: number | undefined;
|
|
19
|
+
nativePrice?: number | undefined;
|
|
20
|
+
parseNonNativeToken?: ((input: string, decimals: number) => bigint) | undefined;
|
|
21
|
+
formatNonNativeToken?: ((value: bigint, decimals: number) => string) | undefined;
|
|
22
|
+
validateAddressFormat: (address: string) => boolean;
|
|
23
|
+
parse: (input: string) => bigint;
|
|
24
|
+
format: (value: bigint, { precision }?: import("@dynamic-labs/types").IUITransactionFormatOptions) => string;
|
|
25
|
+
get to(): `0x${string}` | undefined;
|
|
26
|
+
get from(): `0x${string}`;
|
|
27
|
+
get value(): bigint | undefined;
|
|
28
|
+
get data(): `0x${string}` | undefined;
|
|
29
|
+
submit(): Promise<string>;
|
|
30
|
+
getBalance(): Promise<bigint>;
|
|
31
|
+
estimateGas(): Promise<bigint>;
|
|
32
|
+
estimateL1Fee(): Promise<bigint>;
|
|
33
|
+
set maxFeePerGas(value: bigint);
|
|
34
|
+
set maxPriorityFeePerGas(value: bigint);
|
|
35
|
+
private convertHexToBigInt;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter, __rest } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { hexToBigInt, toHex, TransactionExecutionError, BaseError } from 'viem';
|
|
4
|
+
import { UserRejectedTransactionError } from '@dynamic-labs/utils';
|
|
5
|
+
import { validateAddressFormat } from '../../validateAddressFormat.js';
|
|
6
|
+
import { Eip1559FeeFeed } from '../Eip1559FeeFeed.js';
|
|
7
|
+
import { isL1FeeSupportedByChain, estimateL1Fee } from '../estimateL1Fee/estimateL1Fee.js';
|
|
8
|
+
import { parseEther } from '../parseEther/parseEther.js';
|
|
9
|
+
import { formatEther } from '../formatEther/formatEther.js';
|
|
10
|
+
|
|
11
|
+
class ViemRpcUiTransaction extends Eip1559FeeFeed {
|
|
12
|
+
constructor({ transaction, onSubmit, publicClient, }) {
|
|
13
|
+
super({
|
|
14
|
+
initialGasLimit: transaction.gas
|
|
15
|
+
? hexToBigInt(transaction.gas)
|
|
16
|
+
: undefined,
|
|
17
|
+
initialMaxFeePerGas: transaction.maxFeePerGas
|
|
18
|
+
? hexToBigInt(transaction.maxFeePerGas)
|
|
19
|
+
: undefined,
|
|
20
|
+
publicClient,
|
|
21
|
+
});
|
|
22
|
+
this.chain = 'EVM';
|
|
23
|
+
this.validateAddressFormat = validateAddressFormat;
|
|
24
|
+
this.parse = parseEther;
|
|
25
|
+
this.format = formatEther;
|
|
26
|
+
this.transaction = transaction;
|
|
27
|
+
this.onSubmit = onSubmit;
|
|
28
|
+
this.publicClient = publicClient;
|
|
29
|
+
}
|
|
30
|
+
get to() {
|
|
31
|
+
return this.transaction.to || undefined;
|
|
32
|
+
}
|
|
33
|
+
get from() {
|
|
34
|
+
return this.transaction.from;
|
|
35
|
+
}
|
|
36
|
+
get value() {
|
|
37
|
+
const { value } = this.transaction;
|
|
38
|
+
return value ? hexToBigInt(value) : undefined;
|
|
39
|
+
}
|
|
40
|
+
get data() {
|
|
41
|
+
return this.transaction.data;
|
|
42
|
+
}
|
|
43
|
+
submit() {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
return this.onSubmit(this.transaction).catch((error) => {
|
|
46
|
+
if (error instanceof UserRejectedTransactionError) {
|
|
47
|
+
throw new TransactionExecutionError(new BaseError(error.message), this.transaction);
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
getBalance() {
|
|
54
|
+
return this.publicClient.getBalance({
|
|
55
|
+
address: this.transaction.from,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
estimateGas() {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
61
|
+
const _a = this.transaction, transaction = __rest(_a, ["from"]);
|
|
62
|
+
const hexResult = (yield this.publicClient.transport.request({
|
|
63
|
+
method: 'eth_estimateGas',
|
|
64
|
+
params: [transaction],
|
|
65
|
+
}));
|
|
66
|
+
return hexToBigInt(hexResult);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
estimateL1Fee() {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
var _a;
|
|
72
|
+
if (!isL1FeeSupportedByChain(((_a = this.publicClient.chain) === null || _a === void 0 ? void 0 : _a.id) || 0)) {
|
|
73
|
+
return BigInt(0);
|
|
74
|
+
}
|
|
75
|
+
const result = yield estimateL1Fee(this.publicClient, {
|
|
76
|
+
data: this.transaction.data,
|
|
77
|
+
to: this.transaction.to,
|
|
78
|
+
value: this.convertHexToBigInt(this.transaction.value),
|
|
79
|
+
});
|
|
80
|
+
return result;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
set maxFeePerGas(value) {
|
|
84
|
+
this.transaction.maxFeePerGas = toHex(value);
|
|
85
|
+
}
|
|
86
|
+
set maxPriorityFeePerGas(value) {
|
|
87
|
+
this.transaction.maxPriorityFeePerGas = toHex(value);
|
|
88
|
+
}
|
|
89
|
+
convertHexToBigInt(value) {
|
|
90
|
+
return value ? hexToBigInt(value) : undefined;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { ViemRpcUiTransaction };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ViemRpcUiTransaction } from './ViemRpcUiTransaction';
|