Skip to content
Draft
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
18 changes: 15 additions & 3 deletions .github/workflows/lint-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ jobs:
echo "Working tree dirty at end of job"
exit 1
fi
- name: Upload build artifacts
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: package-dist-${{ github.sha }}
# Glob discards the path before the first wildcard (`packages/`), so
# the artifact root is `<package>/dist/...`. Download into `packages/`
# to restore `packages/<package>/dist/...`.
path: packages/*/dist
retention-days: 1

test-scripts:
name: Test Scripts
Expand All @@ -181,7 +190,7 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
needs: prepare
needs: [prepare, build]
strategy:
matrix:
node-version: [20.x, 22.x]
Expand All @@ -192,8 +201,11 @@ jobs:
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
- name: Build for tests
run: yarn workspace ${{ matrix.package-name }} build
- name: Restore build artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
name: package-dist-${{ github.sha }}
path: packages
- run: yarn workspace ${{ matrix.package-name }} run test
- name: Require clean working directory
shell: bash
Expand Down
100 changes: 0 additions & 100 deletions eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1510,15 +1510,7 @@
"count": 20
}
},
"packages/tron-wallet-snap/src/caching/InMemoryCache.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/caching/StateCache.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
},
"no-restricted-syntax": {
"count": 1
}
Expand All @@ -1533,20 +1525,7 @@
"count": 2
}
},
"packages/tron-wallet-snap/src/clients/price-api/PriceApiClient.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/clients/price-api/types.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/clients/security-alerts-api/utils.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
},
"no-restricted-syntax": {
"count": 5
}
Expand All @@ -1559,11 +1538,6 @@
"count": 1
}
},
"packages/tron-wallet-snap/src/clients/token-api/TokenApiClient.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/clients/trongrid/TrongridApiClient.test.ts": {
"require-atomic-updates": {
"count": 1
Expand All @@ -1582,16 +1556,6 @@
"count": 42
}
},
"packages/tron-wallet-snap/src/handlers/clientRequest/clientRequest.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/handlers/clientRequest/validation.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/handlers/cronjob/cronjob.test.tsx": {
"@typescript-eslint/explicit-function-return-type": {
"count": 2
Expand All @@ -1610,11 +1574,6 @@
"count": 1
}
},
"packages/tron-wallet-snap/src/services/accounts/AccountsService.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/services/assets/AssetsRepository.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 2
Expand All @@ -1628,16 +1587,6 @@
"count": 1
}
},
"packages/tron-wallet-snap/src/services/assets/adapters/SnapAssetsAdapter.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/services/config/ConfigProvider.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/services/send/FeeCalculatorService.ts": {
"no-restricted-syntax": {
"count": 1
Expand All @@ -1651,11 +1600,6 @@
"count": 15
}
},
"packages/tron-wallet-snap/src/services/send/SendService.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/services/send/TransactionExpirationRefresherService.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 5
Expand All @@ -1666,11 +1610,6 @@
"count": 7
}
},
"packages/tron-wallet-snap/src/services/staking/StakingService.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/services/state/State.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 1
Expand All @@ -1679,11 +1618,6 @@
"count": 1
}
},
"packages/tron-wallet-snap/src/services/transaction-expiration-refresher/TransactionExpirationRefresherService.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/services/transaction-scan/TransactionScanService.ts": {
"no-restricted-syntax": {
"count": 5
Expand All @@ -1705,14 +1639,6 @@
},
"@typescript-eslint/no-explicit-any": {
"count": 7
},
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/services/wallet/WalletService.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/ui/confirmation/components/TransactionAlert/TransactionAlert.test.tsx": {
Expand All @@ -1731,9 +1657,6 @@
"packages/tron-wallet-snap/src/ui/confirmation/views/ConfirmSignMessage/render.test.tsx": {
"@typescript-eslint/no-explicit-any": {
"count": 3
},
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/ui/confirmation/views/ConfirmSignTransaction/ConfirmSignTransaction.test.tsx": {
Expand All @@ -1744,14 +1667,6 @@
"packages/tron-wallet-snap/src/ui/confirmation/views/ConfirmSignTransaction/render.test.tsx": {
"@typescript-eslint/no-explicit-any": {
"count": 14
},
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/ui/confirmation/views/ConfirmSignTransaction/render.tsx": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/ui/confirmation/views/ConfirmTransactionRequest/ConfirmTransactionRequest.test.tsx": {
Expand All @@ -1767,26 +1682,11 @@
"count": 2
}
},
"packages/tron-wallet-snap/src/utils/deriveTronFromCoinTypeNode.test.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/utils/deriveTronFromCoinTypeNode.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/utils/getExplorerUrl.test.ts": {
"n/no-process-env": {
"count": 3
}
},
"packages/tron-wallet-snap/src/validation/keyring-structs.test.ts": {
"import-x/no-extraneous-dependencies": {
"count": 1
}
},
"packages/tron-wallet-snap/src/validation/transaction.test.ts": {
"@typescript-eslint/no-explicit-any": {
"count": 1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"files": [],
"scripts": {
"build": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run build",
"build": "yarn workspaces foreach --all --no-private --topological-dev --parallel --interlaced --verbose run build",
"build:clean": "yarn build:only-clean && yarn build",
"build:docs": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run build:docs",
"build:only-clean": "rimraf -g 'packages/*/dist'",
Expand Down
9 changes: 9 additions & 0 deletions packages/tron-wallet-snap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add Core messenger plumbing (`getMessenger`, `RemoteFeatureFlagsProvider`, `AssetsProvider`) for upcoming AssetsController migration ([#95](https://github.com/MetaMask/internal-snaps/pull/95))
- Route fungible asset reads through Core AssetsController based on migration stage ([#127](https://github.com/MetaMask/internal-snaps/pull/127))

### Removed

- Assets migration feature-flag routing. Fungible reads (`getAccountAssetByID`, `getAccountAssetsByIDs`, `getAccountAssetsByScope`) now always use Core `AssetsController` via `AssetsProvider`; snap-owned protocol assets remain on the Snap adapter for sync, reads, and keyring events. Removed `RemoteFeatureFlagController:getState` messenger endowment ([#97](https://github.com/MetaMask/internal-snaps/pull/97))

## [3.0.0]

### Added
Expand Down
6 changes: 6 additions & 0 deletions packages/tron-wallet-snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@metamask/utils": "^11.9.0"
},
"devDependencies": {
"@metamask/assets-controller": "^13.0.0",
"@metamask/auto-changelog": "^6.1.1",
"@metamask/key-tree": "^10.1.1",
"@metamask/keyring-api": "^23.7.0",
"@metamask/keyring-snap-sdk": "^9.2.1",
"@metamask/messenger": "^2.0.0",
"@metamask/snap-networks-utils": "^1.0.0",
"@metamask/snaps-cli": "^8.4.1",
"@metamask/snaps-jest": "^10.2.0",
"@metamask/snaps-sdk": "^11.2.0",
Expand Down
9 changes: 8 additions & 1 deletion packages/tron-wallet-snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/internal-snaps.git"
},
"source": {
"shasum": "s5YqLxf2VlRkjAfbTnHJCZXjWGdcaOi3h0JCe+wHeXo=",
"shasum": "6dgldMOKKiG/d+FsXzdI0Smd3MfJn7MCqhykDVXeRf8=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down Expand Up @@ -63,6 +63,13 @@
},
"endowment:assets": {
"scopes": ["tron:728126428"]
},
"endowment:messenger": {
"actions": [
"AssetsController:getAccountAssetByID",
"AssetsController:getAccountAssetsByIDs",
"AssetsController:getAccountAssetsByScope"
]
}
},
"platformVersion": "11.2.0",
Expand Down
26 changes: 25 additions & 1 deletion packages/tron-wallet-snap/src/context.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { AssetsProvider } from '@metamask/snap-networks-utils';
import type { AssetsProviderMessenger } from '@metamask/snap-networks-utils';
import { getMessenger } from '@metamask/snaps-sdk';

import { InMemoryCache } from './caching/InMemoryCache';
import { StateCache } from './caching/StateCache';
import { PriceApiClient } from './clients/price-api/PriceApiClient';
Expand Down Expand Up @@ -29,6 +33,10 @@ import { TransactionScanService } from './services/transaction-scan/TransactionS
import { TransactionsRepository } from './services/transactions/TransactionsRepository';
import { TransactionsService } from './services/transactions/TransactionsService';
import { WalletService } from './services/wallet/WalletService';
import type {
CoreMessenger,
CoreMessengerMessenger,
} from './types/core-messenger';
import logger, { noOpLogger } from './utils/logger';

/**
Expand Down Expand Up @@ -82,13 +90,21 @@ const priceApiClient = new PriceApiClient(configProvider, priceCache);
// Token API client
const tokenApiClient = new TokenApiClient(configProvider);

/**
* Core controllers plumbing
*/
const coreMessenger = getMessenger<CoreMessengerMessenger>();
const assetsProvider = new AssetsProvider({
messenger: coreMessenger as AssetsProviderMessenger,
});

// Security Alerts API client
const securityAlertsApiClient = new SecurityAlertsApiClient(
configProvider,
logger,
);

// Business Services - depend on Repositories, State and other Services
// Business Services
const assetsService = new AssetsService({
logger,
state,
Expand All @@ -98,6 +114,7 @@ const assetsService = new AssetsService({
priceApiClient,
tokenApiClient,
snapClient,
assetsProvider,
});

const transactionsService = new TransactionsService({
Expand Down Expand Up @@ -235,6 +252,11 @@ export type SnapExecutionContext = {
confirmationHandler: ConfirmationHandler;
transactionScanService: TransactionScanService;
transactionExpirationRefresherService: TransactionExpirationRefresherService;
/**
* Core messenger plumbing for AssetsController reads.
*/
coreMessenger: CoreMessenger;
assetsProvider: AssetsProvider;
/**
* Handlers
*/
Expand Down Expand Up @@ -267,6 +289,8 @@ const snapContext: SnapExecutionContext = {
confirmationHandler,
transactionScanService,
transactionExpirationRefresherService,
coreMessenger,
assetsProvider,
/**
* Handlers
*/
Expand Down
Loading
Loading