Skip to content
Merged
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 apps/extension-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build": "vite build",
"test": "pnpm --dir ../.. --filter @ancore/ui-kit build && vitest run",
"test:watch": "vitest",
"lint": "eslint src/",
Expand Down
8 changes: 6 additions & 2 deletions apps/extension-wallet/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
"compilerOptions": {
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"jsx": "react-jsx",
"types": ["vitest/globals"],
"types": ["vitest/globals", "chrome", "webextension-polyfill"],
"noEmit": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"strict": false,
"noImplicitAny": false,
"noUnusedLocals": false,
"noUnusedParameters": false
},
"include": ["src", "vitest.config.ts"]
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
},
"devDependencies": {
"@turbo/gen": "^2.3.0",
"@types/chrome": "^0.1.38",
"@types/node": "^25.5.0",
"@types/webextension-polyfill": "^0.12.5",
"husky": "^9.0.0",
"lint-staged": "^15.0.0",
"prettier": "^3.2.5",
Expand Down Expand Up @@ -60,7 +62,8 @@
"overrides": {
"js-yaml": ">=4.1.1",
"tmp": ">=0.2.4",
"esbuild": "0.21.5"
"esbuild": "0.21.5",
"@stellar/stellar-sdk": "^13.3.0"
}
},
"packageManager": "pnpm@9.0.0",
Expand Down
9 changes: 7 additions & 2 deletions packages/account-abstraction/src/initialize.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
/* eslint-disable no-redeclare */
/**
* initialize — invoke AccountContract.initialize(owner) with typed error handling.
*
* Encodes the owner argument to XDR, invokes the contract, and maps
* contract panics to typed errors.
*/

import type { AccountContractReadOptions, AccountContractWriteResult, InvocationArgs } from './account-contract';
import type {
AccountContractReadOptions,
AccountContractWriteResult,
InvocationArgs,
} from './account-contract';
import { AccountContract } from './account-contract';
import { AlreadyInitializedError, ContractInvocationError, mapContractError } from './errors';

Expand Down Expand Up @@ -70,7 +75,7 @@ function buildInitialize(contract: AccountContract, params: InitializeParams): I
async function invokeInitialize(
contract: AccountContract,
params: InitializeParams,
options: AccountContractReadOptions
_options: AccountContractReadOptions
): Promise<AccountContractWriteResult> {
try {
const invocation = contract.initialize(params.owner);
Expand Down
17 changes: 13 additions & 4 deletions packages/account-abstraction/src/revoke-session-key.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
/* eslint-disable no-redeclare */
/**
* revokeSessionKey — invoke AccountContract.revoke_session_key(publicKey).
*
* Encodes the public key to XDR BytesN<32>, invokes the contract, and maps
* contract panics to typed errors.
*/

import type { AccountContractReadOptions, AccountContractWriteResult, InvocationArgs } from './account-contract';
import type {
AccountContractReadOptions,
AccountContractWriteResult,
InvocationArgs,
} from './account-contract';
import { AccountContract } from './account-contract';
import { ContractInvocationError, mapContractError, SessionKeyNotFoundError, UnauthorizedError } from './errors';
import { ContractInvocationError, mapContractError } from './errors';

// ---------------------------------------------------------------------------
// Public interfaces
Expand Down Expand Up @@ -89,13 +94,17 @@ function resolveContract(contract: AccountContract | string): AccountContract {

function validateRevokeSessionKeyParams(params: RevokeSessionKeyParams): void {
if (!params || typeof params !== 'object') {
throw new ContractInvocationError('revokeSessionKey requires a params object with a publicKey field.');
throw new ContractInvocationError(
'revokeSessionKey requires a params object with a publicKey field.'
);
}
if (
(typeof params.publicKey !== 'string' || params.publicKey.trim().length === 0) &&
!(params.publicKey instanceof Uint8Array)
) {
throw new ContractInvocationError('revokeSessionKey: "publicKey" must be a non-empty string or Uint8Array.');
throw new ContractInvocationError(
'revokeSessionKey: "publicKey" must be a non-empty string or Uint8Array.'
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@ancore/types": "workspace:*",
"@noble/ed25519": "^2.1.0",
"@noble/hashes": "^1.4.0",
"@stellar/stellar-sdk": "^12.0.0",
"@stellar/stellar-sdk": "^13.3.0",
"bip39": "^3.1.0",
"ed25519-hd-key": "^1.3.0"
},
Expand Down
10 changes: 4 additions & 6 deletions packages/crypto/src/key-derivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@ export function deriveKeypairFromMnemonic(mnemonic: string, index: number): Keyp
throw new Error('Index must be a non-negative integer');
}

// Convert mnemonic to seed
const seed = bip39.mnemonicToSeedSync(mnemonic);

// Derive the master key
const masterKey = ed25519HdKey.getMasterKeyFromSeed(seed);
// Convert mnemonic to seed (Bypassing outdated TypeScript definitions with 'any')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const seed = (bip39 as any).mnemonicToSeedSync(mnemonic);

// Derive the path using BIP44 for Stellar: m/44'/148'/0'/0/{index}
// 44' - BIP44 purpose
// 148' - Stellar coin type (https://github.com/satoshilabs/slips/blob/master/slip-0044.md)
// 0' - account level
// 0 - change level (0 for external addresses)
// {index} - address index
const path = `m/44'/148'/0'/0/${index}`;
const path = `m/44'/148'/${index}'`;
const derivedKey = ed25519HdKey.derivePath(path, seed.toString('hex'));

// Create Stellar keypair from the derived private key
Expand Down
1 change: 0 additions & 1 deletion packages/stellar/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
"moduleResolution": "node",
"composite": false,
"types": ["node", "jest"]
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
},
"dependencies": {
"zod": "^3.22.0",
"@stellar/stellar-sdk": "^12.0.0"
"@stellar/stellar-sdk": "^13.3.0"
}
}
78 changes: 39 additions & 39 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.