Merge pull request #11731 from MetaMask/Version-v10.0.0
Version v10.0.0 RCfeature/default_network_editable
@ -0,0 +1,47 @@ |
||||
# things that *are* used, that depcheck is wrong about |
||||
ignores: |
||||
# |
||||
# webapp deps |
||||
# |
||||
|
||||
- "@babel/runtime" |
||||
- "@fortawesome/fontawesome-free" |
||||
- "punycode" |
||||
|
||||
# |
||||
# dev deps |
||||
# |
||||
|
||||
# safety fallback for npm lifecycle scripts, not used normally |
||||
- "@lavamoat/preinstall-always-fail" |
||||
# used in testing + ci |
||||
- "@metamask/auto-changelog" # invoked as `auto-changelog` |
||||
- "@metamask/forwarder" |
||||
- "@metamask/test-dapp" |
||||
- "chromedriver" |
||||
- "geckodriver" |
||||
- "ganache-cli" |
||||
- "lavamoat-viz" |
||||
- "@sentry/cli" # invoked as `sentry-cli` |
||||
- "prettier-plugin-sort-json" # automatically imported by prettier |
||||
- "source-map-explorer" |
||||
- "depcheck" # ooo meta |
||||
# development tool |
||||
- "yarn-deduplicate" |
||||
# storybook |
||||
- "@storybook/core" |
||||
- "@storybook/addon-backgrounds" |
||||
- "@storybook/addon-toolbars" |
||||
- "style-loader" |
||||
- "css-loader" |
||||
- "sass-loader" |
||||
- "resolve-url-loader" |
||||
|
||||
# files depcheck should not parse |
||||
ignorePatterns: |
||||
# seems to incorrectly parse scss @include pragmas? |
||||
- "**/*.scss" |
||||
# self-contained bundle used for testing |
||||
- "**/send-eth-with-private-key-test/web3js.js" |
||||
- "**/send-eth-with-private-key-test/ethereumjs-tx.js" |
||||
|
Before Width: | Height: | Size: 920 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 783 B |
Before Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 833 B |
Before Width: | Height: | Size: 787 B |
Before Width: | Height: | Size: 842 B |
Before Width: | Height: | Size: 250 B |
Before Width: | Height: | Size: 847 B |
Before Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 654 B |
Before Width: | Height: | Size: 284 B |
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 337 B |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 118 KiB |
Before Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 8.4 KiB |
@ -0,0 +1 @@ |
||||
export const TRANSAK_API_KEY = '25ac1309-a49b-4411-b20e-5e56c61a5b1c'; // It's a public key, which will be included in a URL for Transak.
|
@ -1,24 +1,49 @@ |
||||
import { NETWORK_TO_NAME_MAP } from '../../../../shared/constants/network'; |
||||
import { TRANSACTION_ENVELOPE_TYPES } from '../../../../shared/constants/transaction'; |
||||
|
||||
export const getNetworkDisplayName = (key) => NETWORK_TO_NAME_MAP[key]; |
||||
|
||||
export function formatTxMetaForRpcResult(txMeta) { |
||||
return { |
||||
blockHash: txMeta.txReceipt ? txMeta.txReceipt.blockHash : null, |
||||
blockNumber: txMeta.txReceipt ? txMeta.txReceipt.blockNumber : null, |
||||
from: txMeta.txParams.from, |
||||
gas: txMeta.txParams.gas, |
||||
gasPrice: txMeta.txParams.gasPrice, |
||||
hash: txMeta.hash, |
||||
input: txMeta.txParams.data || '0x', |
||||
nonce: txMeta.txParams.nonce, |
||||
to: txMeta.txParams.to, |
||||
transactionIndex: txMeta.txReceipt |
||||
? txMeta.txReceipt.transactionIndex |
||||
: null, |
||||
value: txMeta.txParams.value || '0x0', |
||||
v: txMeta.v, |
||||
r: txMeta.r, |
||||
s: txMeta.s, |
||||
const { r, s, v, hash, txReceipt, txParams } = txMeta; |
||||
const { |
||||
to, |
||||
data, |
||||
nonce, |
||||
gas, |
||||
from, |
||||
value, |
||||
gasPrice, |
||||
accessList, |
||||
maxFeePerGas, |
||||
maxPriorityFeePerGas, |
||||
} = txParams; |
||||
|
||||
const formattedTxMeta = { |
||||
v, |
||||
r, |
||||
s, |
||||
to, |
||||
gas, |
||||
from, |
||||
hash, |
||||
nonce, |
||||
input: data || '0x', |
||||
value: value || '0x0', |
||||
accessList: accessList || null, |
||||
blockHash: txReceipt?.blockHash || null, |
||||
blockNumber: txReceipt?.blockNumber || null, |
||||
transactionIndex: txReceipt?.transactionIndex || null, |
||||
}; |
||||
|
||||
if (maxFeePerGas && maxPriorityFeePerGas) { |
||||
formattedTxMeta.gasPrice = maxFeePerGas; |
||||
formattedTxMeta.maxFeePerGas = maxFeePerGas; |
||||
formattedTxMeta.maxPriorityFeePerGas = maxPriorityFeePerGas; |
||||
formattedTxMeta.type = TRANSACTION_ENVELOPE_TYPES.FEE_MARKET; |
||||
} else { |
||||
formattedTxMeta.gasPrice = gasPrice; |
||||
formattedTxMeta.type = TRANSACTION_ENVELOPE_TYPES.LEGACY; |
||||
} |
||||
|
||||
return formattedTxMeta; |
||||
} |
||||
|
@ -0,0 +1,100 @@ |
||||
import { strict as assert } from 'assert'; |
||||
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'; |
||||
import { formatTxMetaForRpcResult } from './util'; |
||||
|
||||
describe('network utils', function () { |
||||
describe('formatTxMetaForRpcResult', function () { |
||||
it('should correctly format the tx meta object (EIP-1559)', function () { |
||||
const txMeta = { |
||||
id: 1, |
||||
status: TRANSACTION_STATUSES.UNAPPROVED, |
||||
txParams: { |
||||
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d', |
||||
to: '0x1678a085c290ebd122dc42cba69373b5953b831d', |
||||
maxFeePerGas: '0x77359400', |
||||
maxPriorityFeePerGas: '0x77359400', |
||||
gas: '0x7b0d', |
||||
nonce: '0x4b', |
||||
}, |
||||
type: 'sentEther', |
||||
origin: 'other', |
||||
chainId: '0x3', |
||||
time: 1624408066355, |
||||
metamaskNetworkId: '3', |
||||
hash: |
||||
'0x4bcb6cd6b182209585f8ad140260ddb35c81a575dd40f508d9767e652a9f60e7', |
||||
r: '0x4c3111e42ed5eec3dcecba1e234700f387e8693c373c61c3e54a762a26f1570e', |
||||
s: '0x18bfc4eeb7ebcfacc3bd59ea100a6834ea3265e65945dbec69aa2a06564fafff', |
||||
v: '0x29', |
||||
}; |
||||
const expectedResult = { |
||||
accessList: null, |
||||
blockHash: null, |
||||
blockNumber: null, |
||||
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d', |
||||
gas: '0x7b0d', |
||||
gasPrice: '0x77359400', |
||||
hash: |
||||
'0x4bcb6cd6b182209585f8ad140260ddb35c81a575dd40f508d9767e652a9f60e7', |
||||
input: '0x', |
||||
maxFeePerGas: '0x77359400', |
||||
maxPriorityFeePerGas: '0x77359400', |
||||
nonce: '0x4b', |
||||
r: '0x4c3111e42ed5eec3dcecba1e234700f387e8693c373c61c3e54a762a26f1570e', |
||||
s: '0x18bfc4eeb7ebcfacc3bd59ea100a6834ea3265e65945dbec69aa2a06564fafff', |
||||
to: '0x1678a085c290ebd122dc42cba69373b5953b831d', |
||||
transactionIndex: null, |
||||
type: '0x2', |
||||
v: '0x29', |
||||
value: '0x0', |
||||
}; |
||||
const result = formatTxMetaForRpcResult(txMeta); |
||||
assert.deepEqual(result, expectedResult); |
||||
}); |
||||
|
||||
it('should correctly format the tx meta object (non EIP-1559)', function () { |
||||
const txMeta = { |
||||
id: 1, |
||||
status: TRANSACTION_STATUSES.UNAPPROVED, |
||||
txParams: { |
||||
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d', |
||||
to: '0x1678a085c290ebd122dc42cba69373b5953b831d', |
||||
gasPrice: '0x77359400', |
||||
gas: '0x7b0d', |
||||
nonce: '0x4b', |
||||
}, |
||||
type: 'sentEther', |
||||
origin: 'other', |
||||
chainId: '0x3', |
||||
time: 1624408066355, |
||||
metamaskNetworkId: '3', |
||||
hash: |
||||
'0x4bcb6cd6b182209585f8ad140260ddb35c81a575dd40f508d9767e652a9f60e7', |
||||
r: '0x4c3111e42ed5eec3dcecba1e234700f387e8693c373c61c3e54a762a26f1570e', |
||||
s: '0x18bfc4eeb7ebcfacc3bd59ea100a6834ea3265e65945dbec69aa2a06564fafff', |
||||
v: '0x29', |
||||
}; |
||||
const expectedResult = { |
||||
accessList: null, |
||||
blockHash: null, |
||||
blockNumber: null, |
||||
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d', |
||||
gas: '0x7b0d', |
||||
hash: |
||||
'0x4bcb6cd6b182209585f8ad140260ddb35c81a575dd40f508d9767e652a9f60e7', |
||||
input: '0x', |
||||
gasPrice: '0x77359400', |
||||
nonce: '0x4b', |
||||
r: '0x4c3111e42ed5eec3dcecba1e234700f387e8693c373c61c3e54a762a26f1570e', |
||||
s: '0x18bfc4eeb7ebcfacc3bd59ea100a6834ea3265e65945dbec69aa2a06564fafff', |
||||
to: '0x1678a085c290ebd122dc42cba69373b5953b831d', |
||||
transactionIndex: null, |
||||
type: '0x0', |
||||
v: '0x29', |
||||
value: '0x0', |
||||
}; |
||||
const result = formatTxMetaForRpcResult(txMeta); |
||||
assert.deepEqual(result, expectedResult); |
||||
}); |
||||
}); |
||||
}); |