Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor some parts of contract and accounts packages #7197

Merged
Show file tree
Hide file tree
Changes from 8 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
10 changes: 9 additions & 1 deletion packages/web3-eth-accounts/src/tx/transactionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@
} from './types.js';
import { BaseTransaction } from './baseTransaction.js';

const extraTxTypes: Map<Numbers, typeof BaseTransaction<unknown>> = new Map();
let extraTxTypes: Map<Numbers, typeof BaseTransaction<unknown>>;
// use the global object, to work fine even if web3-eth and web3-eth-accounts was on a different versions:
const typedGlobal = global as unknown as {extraTxTypes: Map<Numbers, typeof BaseTransaction<unknown>>}
if (!typedGlobal.extraTxTypes) {
extraTxTypes = new Map();
typedGlobal.extraTxTypes = extraTxTypes;
} else {
extraTxTypes = typedGlobal.extraTxTypes;

Check warning on line 41 in packages/web3-eth-accounts/src/tx/transactionFactory.ts

View check run for this annotation

Codecov / codecov/patch

packages/web3-eth-accounts/src/tx/transactionFactory.ts#L40-L41

Added lines #L40 - L41 were not covered by tests
}

// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class TransactionFactory {
Expand Down
Loading
Loading