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

feat: read-only connected accounts integration (DAP-4807) #55

Merged
merged 28 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
017bd65
test: recover Switch Mutation test
Ni-2 Dec 11, 2024
64462b5
Merge branch 'develop' into recover-extension-test
Ni-2 Dec 11, 2024
5f8e494
fix: change Switch Mutation test for overlay flow
Ni-2 Dec 12, 2024
b944da5
feat: add routing to the Overlay; add Profile page
Ni-2 Dec 13, 2024
bf7370f
feat: adding CA page
Ni-2 Dec 16, 2024
19f3041
refactor: imports optimization
Ni-2 Dec 16, 2024
350f87c
Merge remote-tracking branch 'origin/develop' into dap-4807
alsakhaev Dec 16, 2024
ac403fb
Merge remote-tracking branch 'origin/develop' into dap-4807
alsakhaev Dec 16, 2024
e75bde4
Merge branch 'develop' into dap-4807
Ni-2 Dec 16, 2024
9a799cf
Merge branch 'dap-4807' into dap-4812
Ni-2 Dec 16, 2024
d47fcc2
feat: connect CA module to the Profile page
Ni-2 Dec 23, 2024
af62bae
Merge branch 'develop' into dap-4807
Ni-2 Dec 23, 2024
0fafb6a
Merge branch 'dap-4807' into dap-4812
Ni-2 Dec 23, 2024
fad3f99
feat: connect Connected Accounts module to smart contracts (DAP-4828)
Ni-2 Dec 25, 2024
e8e74ae
feat: add Profile button to the overlay header (DAP-4829)
Ni-2 Dec 26, 2024
d0823ea
fix: CA list element key
Ni-2 Dec 26, 2024
d6edfee
fix: Error `<null key={...} target={...}>` component in console (DAP-…
Ni-2 Dec 26, 2024
5828232
feat: new CA design (DAP-4830)
Ni-2 Dec 26, 2024
07be539
fix: improve CA item styles
Ni-2 Dec 26, 2024
103e0c7
feat: ca available in Widgets (DAP-4841)
Ni-2 Dec 26, 2024
4f582d3
refactor: small improvements
Ni-2 Dec 26, 2024
2293adf
test: add 1 active test for an empty CA module and 1 test for future …
Ni-2 Dec 27, 2024
ec3ad8e
Merge branch 'develop' into dap-4807
alsakhaev Dec 27, 2024
99c6fe7
build: fix lockfile
alsakhaev Dec 27, 2024
b403ab4
fix: getAllKeys is not implemented
alsakhaev Dec 27, 2024
0a474b6
refactor: reuse existing getNearConfig
alsakhaev Dec 27, 2024
63bc404
refactor: respect naming convention
alsakhaev Dec 27, 2024
f90f2e3
refactor: remove unused code
alsakhaev Dec 27, 2024
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
7 changes: 7 additions & 0 deletions apps/crawler-extension/src/contentscript/extension-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import browser from 'webextension-polyfill'
export class ExtensionStorage implements StorageService, IStorage {
constructor(private _keyPrefix: string) {}

async getAllKeys(): Promise<string[]> {
const storage = await browser.storage.local.get(null)
return Object.keys(storage)
.filter((key) => key.startsWith(this._keyPrefix + ':'))
.map((key) => key.substring(this._keyPrefix.length + 1))
}

async getItem(key: string): Promise<string> {
const globalKey = this._makeKey(key)
const result = await browser.storage.local.get(globalKey)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect, test } from '../fixtures/browser'

test('show empty Connected Accounts list on a Profile page when the no wallets connected', async ({
page,
}) => {
const url = 'https://github.com/dapplets/dapplet-extension/pull/217'
const noConnectedAccountsText = 'There are no connected accounts'
const recommendConnectWalletText = 'Connect your wallet to see connected accounts'

await page.goto(url)

// ToDo: move to POM
await expect(page.getByTestId('mweb-overlay')).toBeVisible({ timeout: 60_000 })

// actions
await page.getByTestId('profile-action-button').click()

// results
await expect(page.getByTestId('side-panel')).toBeVisible()
await expect(
page.getByTestId('profile-page').getByTestId('connected-accounts-module')
).toBeVisible()
await expect(
page.getByTestId('profile-page').getByTestId('connected-accounts-module')
).toContainText(noConnectedAccountsText)
await expect(
page.getByTestId('profile-page').getByTestId('connected-accounts-module')
).toContainText(recommendConnectWalletText)
})
20 changes: 20 additions & 0 deletions apps/extension/tests/scenarios/open-profile-using-header.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect, test } from '../fixtures/browser'

// ToDo: need to connect a wallet for this test case

// test('open Profile page through the button in the Overlay header', async ({ page }) => {
// const url = 'https://github.com/dapplets/dapplet-extension/pull/217'

// await page.goto(url)

// // ToDo: move to POM
// await expect(page.getByTestId('mweb-overlay')).toBeVisible({ timeout: 60_000 })
// await page.getByTestId('mutation-button').click()
// await expect(page.getByTestId('side-panel')).toBeVisible()

// // actions
// await page.getByTestId('profile-page-button').click()

// // results
// await expect(page.getByTestId('profile-page')).toBeVisible()
// })
1 change: 0 additions & 1 deletion apps/extension/tests/scenarios/open-profile.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect, test } from '../fixtures/browser'

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

Expand Down
1 change: 0 additions & 1 deletion apps/extension/tests/scenarios/switch-mutation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect, test } from '../fixtures/browser'

// ToDo: qase mw-1
test('switch mutation', async ({ page }) => {
const url = 'https://github.com/dapplets/dapplet-extension/pull/217'
const sourceMutationId = 'bos.dapplets.near/mutation/Sandbox'
Expand Down
1 change: 1 addition & 0 deletions libs/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"big.js": "^6.2.1",
"bn.js": "^5.2.1",
"caching-decorator": "^1.0.3",
"ethereum-blockies-base64": "^1.0.2",
"js-sha256": "^0.11.0",
"json-stringify-deterministic": "^1.0.12",
"reflect-metadata": "^0.2.2"
Expand Down
3 changes: 3 additions & 0 deletions libs/backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type NearConfig = {
defaultMutationId: string
layoutManagers: BuiltInLayoutManagers
timeReference: TimeReference
connectedAccountsContractAddress: string
}

export const NearConfigs: { [networkId: string]: NearConfig } = {
Expand All @@ -37,6 +38,7 @@ export const NearConfigs: { [networkId: string]: NearConfig } = {
height: 134671239,
avgBlockTime: 1091, // https://nearblocks.io/
},
connectedAccountsContractAddress: 'connected-accounts.near',
},
testnet: {
networkId: 'testnet',
Expand All @@ -54,6 +56,7 @@ export const NearConfigs: { [networkId: string]: NearConfig } = {
height: 181770025,
avgBlockTime: 1000, // https://testnet.nearblocks.io/
},
connectedAccountsContractAddress: 'dev-1674551865700-67703371677231',
},
}

Expand Down
6 changes: 6 additions & 0 deletions libs/backend/src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { Notification } from './services/notification/notification.entity'
import { Resolution } from './services/notification/resolution.entity'
import { BaseLocalRepository } from './services/base/base-local.repository'
import { BaseAggRepository } from './services/base/base-agg.repository'
import { ConnectedAccountsService } from './services/connected-accounts/connected-accounts.service'

export type EngineConfig = {
networkId: string
Expand All @@ -45,6 +46,7 @@ export class Engine {
parserConfigService: ParserConfigService
notificationService: NotificationService
documentService: DocumentSerivce
connectedAccountsService: ConnectedAccountsService

constructor(public readonly config: EngineConfig) {
if (!this.config.storage) {
Expand Down Expand Up @@ -138,5 +140,9 @@ export class Engine {
unitOfWorkService,
nearSigner
)
this.connectedAccountsService = new ConnectedAccountsService(
nearSigner,
nearConfig.connectedAccountsContractAddress
)
}
}
11 changes: 11 additions & 0 deletions libs/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ export {
export { PullRequestAcceptedPayload } from './services/notification/types/pull-request-accepted'
export { PullRequestRejectedPayload } from './services/notification/types/pull-request-rejected'
export { RegularPayload } from './services/notification/types/regular'
export {
TConnectedAccount,
IConnectedAccountsPair,
ConnectedAccountsPairStatus,
IConnectedAccountUser,
WalletDescriptorWithCAMainStatus,
NearNetworks,
ChainTypes,
TConnectedAccountsVerificationRequestInfo,
} from './services/connected-accounts/types'
export { ConnectedAccountsService } from './services/connected-accounts/connected-accounts.service'

// ToDo: replace with DTO
export { ParserConfig } from './services/parser-config/parser-config.entity'
Expand Down
Loading