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: change how addresses are derived #133

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion .nvmrc
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC it's the slip10 package that we use for deriving keys with ed25519 curve that needed this version of node (or newer).

Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.11.0
v20.18.0
173 changes: 173 additions & 0 deletions docs/diagrams/address-derivation.drawio

Large diffs are not rendered by default.

Binary file added docs/images/address-derivation.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"sentry": "node sentryscript.js"
},
"dependencies": {
"@avalabs/avalanche-module": "1.2.1",
"@avalabs/avalanche-module": "0.0.0-feat-solana-address-resolution-20250205161605",
"@avalabs/avalanchejs": "4.1.2-alpha.3",
"@avalabs/bitcoin-module": "1.2.1",
"@avalabs/bitcoin-module": "0.0.0-feat-solana-address-resolution-20250205161605",
"@avalabs/bridge-unified": "4.0.1",
"@avalabs/core-bridge-sdk": "3.1.0-alpha.32",
"@avalabs/core-chains-sdk": "3.1.0-alpha.32",
Expand All @@ -37,12 +37,12 @@
"@avalabs/core-token-prices-sdk": "3.1.0-alpha.32",
"@avalabs/core-utils-sdk": "3.1.0-alpha.32",
"@avalabs/core-wallets-sdk": "3.1.0-alpha.32",
"@avalabs/evm-module": "1.2.1",
"@avalabs/evm-module": "0.0.0-feat-solana-address-resolution-20250205161605",
"@avalabs/glacier-sdk": "3.1.0-alpha.32",
"@avalabs/hw-app-avalanche": "0.14.1",
"@avalabs/hvm-module": "1.2.1",
"@avalabs/hvm-module": "0.0.0-feat-solana-address-resolution-20250205161605",
"@avalabs/types": "3.1.0-alpha.32",
"@avalabs/vm-module-types": "1.2.1",
"@avalabs/vm-module-types": "0.0.0-feat-solana-address-resolution-20250205161605",
"@blockaid/client": "0.10.0",
"@coinbase/cbpay-js": "1.6.0",
"@cubist-labs/cubesigner-sdk": "0.3.28",
Expand All @@ -61,6 +61,7 @@
"@noble/curves": "1.6.0",
"@noble/hashes": "1.3.2",
"@openzeppelin/contracts": "4.9.6",
"@scure/base": "1.2.4",
"@sentry/browser": "7.66.0",
"@sentry/integrations": "7.66.0",
"@sentry/react": "7.66.0",
Expand All @@ -87,6 +88,7 @@
"ledger-bitcoin": "0.2.3",
"lodash": "4.17.21",
"lru-cache": "7.10.1",
"micro-key-producer": "0.7.5",
"micro-signals": "2.4.0",
"paraswap": "5.1.0",
"qrcode.react": "1.0.1",
Expand Down Expand Up @@ -223,7 +225,7 @@
"*.{ts,tsx}": "eslint --fix --max-warnings 0"
},
"volta": {
"node": "20.11.0",
"node": "20.18.0",
"yarn": "1.22.19"
},
"lavamoat": {
Expand Down Expand Up @@ -270,7 +272,9 @@
"@avalabs/core-bridge-sdk>@avalabs/core-wallets-sdk>@metamask/eth-sig-util>@metamask/utils>@ethereumjs/tx>@ethereumjs/common>ethereumjs-util>ethereum-cryptography>keccak": false,
"@avalabs/avalanche-module>@avalabs/vm-module-types>hypersdk-client>@metamask/sdk>@metamask/sdk-communication-layer>bufferutil": false,
"@avalabs/avalanche-module>@avalabs/vm-module-types>hypersdk-client>@metamask/sdk>@metamask/sdk-communication-layer>utf-8-validate": false,
"@avalabs/avalanche-module>@avalabs/vm-module-types>hypersdk-client>@metamask/sdk>eciesjs>secp256k1": false
"@avalabs/avalanche-module>@avalabs/vm-module-types>hypersdk-client>@metamask/sdk>eciesjs>secp256k1": false,
"@avalabs/avalanche-module>@avalabs/core-wallets-sdk>@metamask/eth-sig-util>ethereumjs-abi>ethereumjs-util>ethereum-cryptography>keccak": false,
"@avalabs/avalanche-module>@avalabs/core-wallets-sdk>@metamask/eth-sig-util>ethereumjs-abi>ethereumjs-util>ethereum-cryptography>secp256k1": false
}
}
}
7 changes: 2 additions & 5 deletions src/background/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ export type FirstParameter<T extends (...args: any) => any> = T extends (

export const ACTION_HANDLED_BY_MODULE = '__handled.via.vm.modules__';

export const hasDefined = <T extends object, K extends keyof T>(
obj: T,
key: K,
): obj is EnsureDefined<T, K> => {
return obj[key] !== undefined;
export type ExcludeUndefined<T extends Record<PropertyKey, unknown>> = {
[K in keyof T as T[K] extends undefined ? never : K]: T[K];
};
4 changes: 4 additions & 0 deletions src/background/runtime/BackgroundRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { LockService } from '@src/background/services/lock/LockService';
import { OnboardingService } from '@src/background/services/onboarding/OnboardingService';
import { ModuleManager } from '../vmModules/ModuleManager';
import { BridgeService } from '../services/bridge/BridgeService';
import { AddressResolver } from '../services/secrets/AddressResolver';

@singleton()
export class BackgroundRuntime {
Expand All @@ -16,6 +17,7 @@ export class BackgroundRuntime {
// we try to fetch the bridge configs as soon as possible
private bridgeService: BridgeService,
private moduleManager: ModuleManager,
private addressResolver: AddressResolver,
) {}

activate() {
Expand All @@ -28,6 +30,8 @@ export class BackgroundRuntime {
this.lockService.activate();
this.onboardingService.activate();
this.moduleManager.activate();

this.addressResolver.init(this.moduleManager);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to define the addressResolver here?
Can it just inject the moduleManager via DI like it does with it's other dependencies

}

private onInstalled() {
Expand Down
Loading
Loading