Skip to content

Commit 4ba87b5

Browse files
Ni-2alsakhaev
andauthored
feat: read-only connected accounts integration (DAP-4807) (#55)
* test: recover Switch Mutation test * fix: change Switch Mutation test for overlay flow * feat: add routing to the Overlay; add Profile page * feat: adding CA page * refactor: imports optimization * feat: connect CA module to the Profile page * feat: connect Connected Accounts module to smart contracts (DAP-4828) * feat: add Profile button to the overlay header (DAP-4829) * fix: CA list element key * fix: Error `<null key={...} target={...}>` component in console (DAP-4840) * feat: new CA design (DAP-4830) * fix: improve CA item styles * feat: ca available in Widgets (DAP-4841) * refactor: small improvements * test: add 1 active test for an empty CA module and 1 test for future for a Profile button in the Overlay header * build: fix lockfile * fix: getAllKeys is not implemented * refactor: reuse existing getNearConfig * refactor: respect naming convention * refactor: remove unused code --------- Co-authored-by: Alexander Sakhaev <alsakhaev@gmail.com>
1 parent 181d1cc commit 4ba87b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4517
-241
lines changed

apps/crawler-extension/src/contentscript/extension-storage.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import browser from 'webextension-polyfill'
55
export class ExtensionStorage implements StorageService, IStorage {
66
constructor(private _keyPrefix: string) {}
77

8+
async getAllKeys(): Promise<string[]> {
9+
const storage = await browser.storage.local.get(null)
10+
return Object.keys(storage)
11+
.filter((key) => key.startsWith(this._keyPrefix + ':'))
12+
.map((key) => key.substring(this._keyPrefix.length + 1))
13+
}
14+
815
async getItem(key: string): Promise<string> {
916
const globalKey = this._makeKey(key)
1017
const result = await browser.storage.local.get(globalKey)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { expect, test } from '../fixtures/browser'
2+
3+
test('show empty Connected Accounts list on a Profile page when the no wallets connected', async ({
4+
page,
5+
}) => {
6+
const url = 'https://github.com/dapplets/dapplet-extension/pull/217'
7+
const noConnectedAccountsText = 'There are no connected accounts'
8+
const recommendConnectWalletText = 'Connect your wallet to see connected accounts'
9+
10+
await page.goto(url)
11+
12+
// ToDo: move to POM
13+
await expect(page.getByTestId('mweb-overlay')).toBeVisible({ timeout: 60_000 })
14+
15+
// actions
16+
await page.getByTestId('profile-action-button').click()
17+
18+
// results
19+
await expect(page.getByTestId('side-panel')).toBeVisible()
20+
await expect(
21+
page.getByTestId('profile-page').getByTestId('connected-accounts-module')
22+
).toBeVisible()
23+
await expect(
24+
page.getByTestId('profile-page').getByTestId('connected-accounts-module')
25+
).toContainText(noConnectedAccountsText)
26+
await expect(
27+
page.getByTestId('profile-page').getByTestId('connected-accounts-module')
28+
).toContainText(recommendConnectWalletText)
29+
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { expect, test } from '../fixtures/browser'
2+
3+
// ToDo: need to connect a wallet for this test case
4+
5+
// test('open Profile page through the button in the Overlay header', async ({ page }) => {
6+
// const url = 'https://github.com/dapplets/dapplet-extension/pull/217'
7+
8+
// await page.goto(url)
9+
10+
// // ToDo: move to POM
11+
// await expect(page.getByTestId('mweb-overlay')).toBeVisible({ timeout: 60_000 })
12+
// await page.getByTestId('mutation-button').click()
13+
// await expect(page.getByTestId('side-panel')).toBeVisible()
14+
15+
// // actions
16+
// await page.getByTestId('profile-page-button').click()
17+
18+
// // results
19+
// await expect(page.getByTestId('profile-page')).toBeVisible()
20+
// })

apps/extension/tests/scenarios/open-profile.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { expect, test } from '../fixtures/browser'
22

3-
// ToDo: qase mw-1
43
test('open Profile page through the button in Mini Overlay', async ({ page }) => {
54
const url = 'https://github.com/dapplets/dapplet-extension/pull/217'
65

apps/extension/tests/scenarios/switch-mutation.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { expect, test } from '../fixtures/browser'
22

3-
// ToDo: qase mw-1
43
test('switch mutation', async ({ page }) => {
54
const url = 'https://github.com/dapplets/dapplet-extension/pull/217'
65
const sourceMutationId = 'bos.dapplets.near/mutation/Sandbox'

libs/backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"big.js": "^6.2.1",
2929
"bn.js": "^5.2.1",
3030
"caching-decorator": "^1.0.3",
31+
"ethereum-blockies-base64": "^1.0.2",
3132
"js-sha256": "^0.11.0",
3233
"json-stringify-deterministic": "^1.0.12",
3334
"reflect-metadata": "^0.2.2"

libs/backend/src/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export type NearConfig = {
1818
defaultMutationId: string
1919
layoutManagers: BuiltInLayoutManagers
2020
timeReference: TimeReference
21+
connectedAccountsContractAddress: string
2122
}
2223

2324
export const NearConfigs: { [networkId: string]: NearConfig } = {
@@ -37,6 +38,7 @@ export const NearConfigs: { [networkId: string]: NearConfig } = {
3738
height: 134671239,
3839
avgBlockTime: 1091, // https://nearblocks.io/
3940
},
41+
connectedAccountsContractAddress: 'connected-accounts.near',
4042
},
4143
testnet: {
4244
networkId: 'testnet',
@@ -54,6 +56,7 @@ export const NearConfigs: { [networkId: string]: NearConfig } = {
5456
height: 181770025,
5557
avgBlockTime: 1000, // https://testnet.nearblocks.io/
5658
},
59+
connectedAccountsContractAddress: 'dev-1674551865700-67703371677231',
5760
},
5861
}
5962

libs/backend/src/engine.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { Notification } from './services/notification/notification.entity'
2525
import { Resolution } from './services/notification/resolution.entity'
2626
import { BaseLocalRepository } from './services/base/base-local.repository'
2727
import { BaseAggRepository } from './services/base/base-agg.repository'
28+
import { ConnectedAccountsService } from './services/connected-accounts/connected-accounts.service'
2829

2930
export type EngineConfig = {
3031
networkId: string
@@ -45,6 +46,7 @@ export class Engine {
4546
parserConfigService: ParserConfigService
4647
notificationService: NotificationService
4748
documentService: DocumentSerivce
49+
connectedAccountsService: ConnectedAccountsService
4850

4951
constructor(public readonly config: EngineConfig) {
5052
if (!this.config.storage) {
@@ -138,5 +140,9 @@ export class Engine {
138140
unitOfWorkService,
139141
nearSigner
140142
)
143+
this.connectedAccountsService = new ConnectedAccountsService(
144+
nearSigner,
145+
nearConfig.connectedAccountsContractAddress
146+
)
141147
}
142148
}

libs/backend/src/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ export {
3838
export { PullRequestAcceptedPayload } from './services/notification/types/pull-request-accepted'
3939
export { PullRequestRejectedPayload } from './services/notification/types/pull-request-rejected'
4040
export { RegularPayload } from './services/notification/types/regular'
41+
export {
42+
TConnectedAccount,
43+
IConnectedAccountsPair,
44+
ConnectedAccountsPairStatus,
45+
IConnectedAccountUser,
46+
WalletDescriptorWithCAMainStatus,
47+
NearNetworks,
48+
ChainTypes,
49+
TConnectedAccountsVerificationRequestInfo,
50+
} from './services/connected-accounts/types'
51+
export { ConnectedAccountsService } from './services/connected-accounts/connected-accounts.service'
4152

4253
// ToDo: replace with DTO
4354
export { ParserConfig } from './services/parser-config/parser-config.entity'

0 commit comments

Comments
 (0)