Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/transaction-controller/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,12 @@ export interface TransactionParams {
* Value associated with this transaction.
*/
value?: string;

/**
* Type of transaction.
* 0x0 indicates a legacy transaction.
*/
type?: string;
}

/**
Expand Down
51 changes: 38 additions & 13 deletions packages/transaction-controller/src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ describe('utils', () => {
jest.clearAllMocks();
});

it('normalizeTxParams', () => {
const normalized = util.normalizeTxParams({
describe('normalizeTxParams', () => {
const commonInput = {
data: 'data',
from: 'FROM',
gas: 'gas',
Expand All @@ -31,18 +31,43 @@ describe('utils', () => {
maxFeePerGas: 'maxFeePerGas',
maxPriorityFeePerGas: 'maxPriorityFeePerGas',
estimatedBaseFee: 'estimatedBaseFee',
};

it('normalizeTransaction', () => {
const normalized = util.normalizeTxParams({
...commonInput,
});
expect(normalized).toStrictEqual({
data: '0xdata',
from: '0xfrom',
gas: '0xgas',
gasPrice: '0xgasPrice',
nonce: '0xnonce',
to: '0xto',
value: '0xvalue',
maxFeePerGas: '0xmaxFeePerGas',
maxPriorityFeePerGas: '0xmaxPriorityFeePerGas',
estimatedBaseFee: '0xestimatedBaseFee',
});
});
expect(normalized).toStrictEqual({
data: '0xdata',
from: '0xfrom',
gas: '0xgas',
gasPrice: '0xgasPrice',
nonce: '0xnonce',
to: '0xto',
value: '0xvalue',
maxFeePerGas: '0xmaxFeePerGas',
maxPriorityFeePerGas: '0xmaxPriorityFeePerGas',
estimatedBaseFee: '0xestimatedBaseFee',
it('normalizeTransaction if type is zero', () => {
const normalized = util.normalizeTxParams({
...commonInput,
type: '0x0',
});
expect(normalized).toStrictEqual({
data: '0xdata',
from: '0xfrom',
gas: '0xgas',
gasPrice: '0xgasPrice',
nonce: '0xnonce',
to: '0xto',
value: '0xvalue',
maxFeePerGas: '0xmaxFeePerGas',
maxPriorityFeePerGas: '0xmaxPriorityFeePerGas',
estimatedBaseFee: '0xestimatedBaseFee',
type: '0x0',
});
});
});

Expand Down
1 change: 1 addition & 0 deletions packages/transaction-controller/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const NORMALIZERS: { [param in keyof TransactionParams]: any } = {
addHexPrefix(maxPriorityFeePerGas),
estimatedBaseFee: (maxPriorityFeePerGas: string) =>
addHexPrefix(maxPriorityFeePerGas),
type: (type: string) => (type === '0x0' ? '0x0' : undefined),
};

/**
Expand Down