Skip to content

Commit

Permalink
feat(MMI-5803): Support transactions from account snaps that should n…
Browse files Browse the repository at this point in the history
…ot be published
  • Loading branch information
shane-t committed Dec 6, 2024
1 parent c2d3c1d commit d2d771d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5226,7 +5226,6 @@ describe('TransactionController', () => {
};
transactionMeta = {
...baseTransaction,
custodyId: '123',
history: [{ ...baseTransaction }],
};
});
Expand Down
11 changes: 5 additions & 6 deletions packages/transaction-controller/src/TransactionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,10 @@ export class TransactionController extends BaseController<
transactionMeta: TransactionMeta,
) => boolean;

private readonly beforePublish: (transactionMeta: TransactionMeta) => boolean;
private readonly beforePublish: (
transactionMeta: TransactionMeta,
rawTx: string,
) => boolean;

private readonly publish: (
transactionMeta: TransactionMeta,
Expand Down Expand Up @@ -1958,10 +1961,6 @@ export class TransactionController extends BaseController<
);
}

if (!transactionMeta.custodyId) {
throw new Error('Transaction must be a custodian transaction');
}

if (
status &&
![
Expand Down Expand Up @@ -2535,7 +2534,7 @@ export class TransactionController extends BaseController<
() => this.signTransaction(transactionMeta, transactionMeta.txParams),
);

if (!this.beforePublish(transactionMeta)) {
if (!this.beforePublish(transactionMeta, rawTx as string)) {
log('Skipping publishing transaction based on hook');
this.messagingSystem.publish(
`${controllerName}:transactionPublishingSkipped`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class PendingTransactionTracker {

#beforeCheckPendingTransaction: (transactionMeta: TransactionMeta) => boolean;

#beforePublish: (transactionMeta: TransactionMeta) => boolean;
#beforePublish: (transactionMeta: TransactionMeta, rawTx: string) => boolean;

constructor({
blockTracker,
Expand All @@ -121,7 +121,10 @@ export class PendingTransactionTracker {
beforeCheckPendingTransaction?: (
transactionMeta: TransactionMeta,
) => boolean;
beforePublish?: (transactionMeta: TransactionMeta) => boolean;
beforePublish?: (
transactionMeta: TransactionMeta,
rawTx: string,
) => boolean;
};
}) {
this.hub = new EventEmitter() as PendingTransactionTrackerEventEmitter;
Expand Down
10 changes: 0 additions & 10 deletions packages/transaction-controller/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,6 @@ type TransactionMetaBase = {
*/
currentTokenBalance?: string;

/**
* Unique ID for custodian transaction.
*/
custodyId?: string;

/**
* Custodian transaction status.
*/
custodyStatus?: string;

/** The optional custom nonce override as a decimal string. */
customNonceValue?: string;

Expand Down

0 comments on commit d2d771d

Please sign in to comment.