@toruslabs/ethereum-controllers 5.5.2 → 5.5.3
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/dist/ethereumControllers.cjs.js +19 -9
- package/dist/ethereumControllers.cjs.js.map +1 -1
- package/dist/ethereumControllers.esm.js +20 -9
- package/dist/ethereumControllers.esm.js.map +1 -1
- package/dist/ethereumControllers.umd.min.js +1 -1
- package/dist/ethereumControllers.umd.min.js.map +1 -1
- package/dist/types/utils/interfaces.d.ts +3 -0
- package/package.json +3 -3
- package/src/Preferences/PreferencesController.ts +2 -2
- package/src/utils/helpers.ts +18 -7
- package/src/utils/interfaces.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toruslabs/ethereum-controllers",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.3",
|
|
4
4
|
"homepage": "https://github.com/torusresearch/controllers#readme",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"main": "dist/ethereumControllers.cjs.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@ethereumjs/util": "^9.0.2",
|
|
25
25
|
"@metamask/eth-sig-util": "^7.0.1",
|
|
26
26
|
"@metamask/rpc-errors": "^6.1.0",
|
|
27
|
-
"@toruslabs/base-controllers": "^5.5.
|
|
27
|
+
"@toruslabs/base-controllers": "^5.5.3",
|
|
28
28
|
"@toruslabs/http-helpers": "^6.0.0",
|
|
29
29
|
"@toruslabs/openlogin-jrpc": "^7.0.0",
|
|
30
30
|
"async-mutex": "^0.4.1",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "f7e579647725a5daef02b33153dadfbdd94c86a6",
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
|
|
70
70
|
"hardhat": "^2.19.5"
|
|
@@ -96,7 +96,7 @@ export default class PreferencesController
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
public async initPreferences(params: InitPreferencesParams): Promise<void> {
|
|
99
|
-
const { address, jwtToken, calledFromEmbed, userInfo, rehydrate, locale = "en
|
|
99
|
+
const { address, jwtToken, calledFromEmbed, userInfo, rehydrate, locale = "en", type, signatures, web3AuthClientId, web3AuthNetwork } = params;
|
|
100
100
|
await super.init({ address, userInfo, idToken: jwtToken, type, metadata: { email: userInfo.email, signatures, network: web3AuthNetwork } });
|
|
101
101
|
const { aggregateVerifier, verifier, verifierId } = userInfo || {};
|
|
102
102
|
const userExists = await this.sync(address);
|
|
@@ -185,7 +185,7 @@ export default class PreferencesController
|
|
|
185
185
|
|
|
186
186
|
public async patchNewTx(tx: TransactionPayload, address: string): Promise<void> {
|
|
187
187
|
const formattedTx = formatPastTx(tx);
|
|
188
|
-
const storePastTx = this.getAddressState(address)?.formattedPastTransactions;
|
|
188
|
+
const storePastTx = this.getAddressState(address)?.formattedPastTransactions || [];
|
|
189
189
|
const duplicateIndex = storePastTx.findIndex((x) => x.transaction_hash === tx.transaction_hash && x.chainId === tx.chain_id);
|
|
190
190
|
if (tx.status === TransactionStatus.submitted || tx.status === TransactionStatus.confirmed) {
|
|
191
191
|
if (duplicateIndex === -1) {
|
package/src/utils/helpers.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
} from "@toruslabs/base-controllers";
|
|
10
10
|
import { SafeEventEmitterProvider } from "@toruslabs/openlogin-jrpc";
|
|
11
11
|
import BigNumber from "bignumber.js";
|
|
12
|
-
import { formatEther } from "ethers";
|
|
13
12
|
import log from "loglevel";
|
|
14
13
|
|
|
15
14
|
import { determineTransactionType } from "../Transaction/TransactionUtils";
|
|
@@ -198,14 +197,26 @@ export const addEtherscanTransactions = async (
|
|
|
198
197
|
);
|
|
199
198
|
|
|
200
199
|
const finalTxs = transactionPromises.reduce((accumulator, x) => {
|
|
201
|
-
|
|
200
|
+
let totalAmountString = x.value ? new BigNumber(x.value).div(new BigNumber(10).pow(new BigNumber(x.tokenDecimal || 18))).toString() : "";
|
|
201
|
+
let type = CONTRACT_TYPE_ETH;
|
|
202
|
+
if (x.contractAddress !== "") {
|
|
203
|
+
if (x.tokenID) {
|
|
204
|
+
type = x.tokenValue ? CONTRACT_TYPE_ERC1155 : CONTRACT_TYPE_ERC721;
|
|
205
|
+
} else {
|
|
206
|
+
type = CONTRACT_TYPE_ERC20;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (type === CONTRACT_TYPE_ERC1155) {
|
|
211
|
+
totalAmountString = x.tokenValue;
|
|
212
|
+
}
|
|
202
213
|
|
|
203
214
|
const etherscanTransaction: TransactionPayload = {
|
|
204
215
|
etherscanLink: getEtherScanHashLink(x.hash, chainId),
|
|
205
|
-
type
|
|
216
|
+
type,
|
|
206
217
|
type_image_link: x.type_image_link || "n/a",
|
|
207
|
-
type_name: x.
|
|
208
|
-
symbol: SUPPORTED_NETWORKS[chainId]?.ticker,
|
|
218
|
+
type_name: x.tokenName || SUPPORTED_NETWORKS[chainId]?.ticker || "n/a",
|
|
219
|
+
symbol: x.tokenSymbol || SUPPORTED_NETWORKS[chainId]?.ticker,
|
|
209
220
|
token_id: x.tokenID || "",
|
|
210
221
|
total_amount: totalAmountString,
|
|
211
222
|
created_at: new Date(Number(x.timeStamp) * 1000),
|
|
@@ -217,8 +228,8 @@ export const addEtherscanTransactions = async (
|
|
|
217
228
|
input: x.input,
|
|
218
229
|
contract_address: x.contractAddress,
|
|
219
230
|
transaction_category: x.transaction_category,
|
|
220
|
-
gas: x.
|
|
221
|
-
gasPrice: x.gasPrice,
|
|
231
|
+
gas: `0x${new BigNumber(x.gasUsed || 0, 10).toString(16)}`,
|
|
232
|
+
gasPrice: `0x${new BigNumber(x.gasPrice || 0, 10).toString(16)}`,
|
|
222
233
|
chain_id: chainId,
|
|
223
234
|
currency_amount: "",
|
|
224
235
|
nonce: x.nonce,
|
package/src/utils/interfaces.ts
CHANGED