diff --git a/sdk/wallet-sdk/src/wallet/__test__/mocks.ts b/sdk/wallet-sdk/src/wallet/__test__/mocks.ts index 80f07d847..d1d62f46e 100644 --- a/sdk/wallet-sdk/src/wallet/__test__/mocks.ts +++ b/sdk/wallet-sdk/src/wallet/__test__/mocks.ts @@ -2,15 +2,25 @@ // SPDX-License-Identifier: Apache-2.0 import { MockedObject, vi } from 'vitest' -import { SDKContext } from '../sdk.js' +import { + AmuletConfig, + AssetConfig, + BasicSDKOptions, + EventsConfig, + SDKContext, + TokenConfig, + TokenProviderConfig, +} from '../sdk.js' import { SDKLogger } from '../logger/logger.js' import { SDKErrorHandler } from '../error/handler.js' -const ledgerProvider = { +const exampleLink = 'http://example.com' + +export const ledgerProvider = { request: vi.fn().mockResolvedValue(undefined), } -const mockLogger = { +export const mockLogger = { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), @@ -26,7 +36,7 @@ const mockErrorHandler = new SDKErrorHandler(mockLogger) const throwSpy = vi.spyOn(mockErrorHandler, 'throw') throwSpy.mockImplementation(vi.fn() as never) -const ctx: SDKContext = { +export const ctx: SDKContext = { ledgerProvider, userId: 'userId', logger: mockLogger, @@ -34,8 +44,35 @@ const ctx: SDKContext = { defaultSynchronizerId: '', } -export const mock = { - ledgerProvider, - mockLogger, - ctx, +export const tokenProviderConfig: TokenProviderConfig = { + method: 'static', + token: 'token', +} + +export const basicSDKOptions: BasicSDKOptions = { + auth: tokenProviderConfig, + ledgerClientUrl: exampleLink, +} + +export const amuletConfig: AmuletConfig = { + validatorUrl: exampleLink, + scanApiUrl: exampleLink, + auth: tokenProviderConfig, + registryUrl: exampleLink, +} + +export const tokenConfig: TokenConfig = { + validatorUrl: exampleLink, + auth: tokenProviderConfig, + registries: [exampleLink, exampleLink], +} + +export const assetConfig: AssetConfig = { + auth: tokenProviderConfig, + registries: [exampleLink, exampleLink], +} + +export const eventsConfig: EventsConfig = { + websocketURL: exampleLink, + auth: tokenProviderConfig, } diff --git a/sdk/wallet-sdk/src/wallet/init/__test__/init.test.ts b/sdk/wallet-sdk/src/wallet/init/__test__/init.test.ts new file mode 100644 index 000000000..dedce1e69 --- /dev/null +++ b/sdk/wallet-sdk/src/wallet/init/__test__/init.test.ts @@ -0,0 +1,172 @@ +// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { beforeEach, describe, expect, it, vi } from 'vitest' +import * as mock from '../../__test__/mocks' +import { + InitializedSDK, + OfflineInitializedSDK, + ExtendedInitializedSDK, +} from '../..' +import { KeysNamespace } from '../../namespace/keys' +import { SDKUtilsNamespace } from '../../namespace/utils' +import { LedgerNamespace } from '../../namespace/ledger' +import { PartyNamespace } from '../../namespace/party' +import { UserNamespace } from '../../namespace/user' +import { AmuletNamespace } from '../../namespace/amulet' +import { AssetNamespace } from '../../namespace/asset' +import { EventsNamespace } from '../../namespace/events' +import { TokenNamespace } from '../../namespace/token' + +const { + ValidatorInternalClient, + get, + TokenStandardService, + AmuletService, + ScanProxyClient, + ScanClient, +} = vi.hoisted(() => { + const get = vi.fn().mockImplementation(() => + Promise.resolve({ + party_id: 'partyId', + }) + ) + + const registriesToAssets = vi.fn().mockResolvedValue([]) + + return { + ValidatorInternalClient: vi.fn( + class { + get = get + } + ), + get, + TokenStandardService: vi.fn( + class { + registriesToAssets = registriesToAssets + } + ), + AmuletService: vi.fn(class {}), + ScanProxyClient: vi.fn(class {}), + ScanClient: vi.fn(class {}), + } +}) + +vi.mock('@canton-network/core-splice-client', async (importOriginal) => { + const actual = + await importOriginal< + typeof import('@canton-network/core-splice-client') + >() + return { + ...actual, + ValidatorInternalClient, + ScanProxyClient, + ScanClient, + } +}) + +vi.mock('@canton-network/core-token-standard-service', () => ({ + TokenStandardService, +})) + +vi.mock('@canton-network/core-amulet-service', () => ({ + AmuletService, +})) + +describe('init SDK', () => { + describe('offline', () => { + let sdk: OfflineInitializedSDK + beforeEach(() => { + vi.clearAllMocks() + + sdk = new OfflineInitializedSDK(mock.ctx) + }) + + it('should expose offline interface', () => { + expect(sdk.keys).toBeInstanceOf(KeysNamespace) + expect(sdk.utils).toBeInstanceOf(SDKUtilsNamespace) + }) + }) + + describe('basic', () => { + let sdk: InitializedSDK + beforeEach(() => { + vi.clearAllMocks() + + sdk = new InitializedSDK(mock.ctx) + }) + + it('should expose basic interface', () => { + sdk = new InitializedSDK(mock.ctx) + + // OfflineSDKInterface + expect(sdk.keys).toBeInstanceOf(KeysNamespace) + expect(sdk.utils).toBeInstanceOf(SDKUtilsNamespace) + + // BasicSDKInterface + expect(sdk.ledger).toBeInstanceOf(LedgerNamespace) + expect(sdk.party).toBeInstanceOf(PartyNamespace) + expect(sdk.user).toBeInstanceOf(UserNamespace) + expect(sdk.registerPlugins).toBeDefined() + }) + }) + + describe('extended', () => { + beforeEach(async () => { + vi.clearAllMocks() + }) + + it('should expose extended interface', async () => { + const sdk = await ExtendedInitializedSDK.create(mock.ctx, { + amulet: mock.amuletConfig, + asset: mock.assetConfig, + events: mock.eventsConfig, + token: mock.tokenConfig, + }) + + // OfflineSDKInterface + expect(sdk.keys).toBeInstanceOf(KeysNamespace) + expect(sdk.utils).toBeInstanceOf(SDKUtilsNamespace) + + // BasicSDKInterface + expect(sdk.ledger).toBeInstanceOf(LedgerNamespace) + expect(sdk.party).toBeInstanceOf(PartyNamespace) + expect(sdk.user).toBeInstanceOf(UserNamespace) + expect(sdk.registerPlugins).toBeDefined() + + // ExtendedInitializedSDK + expect(sdk.amulet).toBeInstanceOf(AmuletNamespace) + expect(sdk.asset).toBeInstanceOf(AssetNamespace) + expect(sdk.events).toBeInstanceOf(EventsNamespace) + expect(sdk.token).toBeInstanceOf(TokenNamespace) + }) + + it('should create amulet namespace based on services', async () => { + await ExtendedInitializedSDK.create(mock.ctx, { + amulet: mock.amuletConfig, + }) + + expect(ScanClient).toHaveBeenCalledOnce() + expect(ScanProxyClient).toHaveBeenCalledOnce() + expect(TokenStandardService).toHaveBeenCalledOnce() + expect(AmuletService).toHaveBeenCalledOnce() + }) + + it('should create token namespace based on services', async () => { + await ExtendedInitializedSDK.create(mock.ctx, { + token: mock.tokenConfig, + }) + + expect(get).toHaveBeenCalledOnce() + expect(TokenStandardService).toHaveBeenCalledOnce() + }) + + it('should create asset namespace based on services', async () => { + await ExtendedInitializedSDK.create(mock.ctx, { + asset: mock.assetConfig, + }) + + expect(TokenStandardService).toHaveBeenCalledOnce() + }) + }) +}) diff --git a/sdk/wallet-sdk/src/wallet/init/__test__/plugin.test.ts b/sdk/wallet-sdk/src/wallet/init/__test__/plugin.test.ts new file mode 100644 index 000000000..7a83c0056 --- /dev/null +++ b/sdk/wallet-sdk/src/wallet/init/__test__/plugin.test.ts @@ -0,0 +1,90 @@ +// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { beforeEach, describe, expect, it, vi } from 'vitest' +import { EXTENDED_SDK_OPTION_KEYS, SDKPlugin } from '../' +import * as mock from '../../__test__/mocks' +import { SDK, SDKContext } from '../..' + +const testPluginFactory = (key: string) => { + return vi.fn( + class extends SDKPlugin { + constructor(ctx: SDKContext) { + super(key, ctx) + } + } + ) +} + +const pluginName = 'pluginName' + +class TestPlugin extends SDKPlugin { + constructor(ctx: SDKContext) { + super(pluginName, ctx) + } + + public testMethod() { + return true + } +} + +describe('plugin', () => { + beforeEach(() => { + vi.clearAllMocks() + }) + + EXTENDED_SDK_OPTION_KEYS.forEach((key) => { + it(`should throw error if ${key} is used as a name`, () => { + expect(() => new (testPluginFactory(key))(mock.ctx)).toThrow() + }) + }) + + it('should call a plugin constructor when registering', async () => { + // Mock the authenticated user response + mock.ledgerProvider.request + .mockResolvedValueOnce({ + user: { id: 'test-user-id' }, + }) + // Mock the connected synchronizers response + .mockResolvedValueOnce({ + connectedSynchronizers: [{ id: 'sync-1' }], + }) + + const sdk = await SDK.create({ + ledgerProvider: mock.ledgerProvider as never, + }) + + const PluginClass = testPluginFactory('plugin') + + const SDKWithPlugin = sdk.registerPlugins({ + plugin: PluginClass, + }) + + expect(SDKWithPlugin.plugin).toBeInstanceOf(PluginClass) + expect(PluginClass).toHaveBeenCalledOnce() + }) + + it('should successfully register a plugin under provided name', async () => { + // Mock the authenticated user response + mock.ledgerProvider.request + .mockResolvedValueOnce({ + user: { id: 'test-user-id' }, + }) + // Mock the connected synchronizers response + .mockResolvedValueOnce({ + connectedSynchronizers: [{ id: 'sync-1' }], + }) + + const sdk = await SDK.create({ + ledgerProvider: mock.ledgerProvider as never, + }) + const SDKWithPlugin = sdk.registerPlugins({ + [pluginName]: TestPlugin, + }) + + const registeredPlugin = SDKWithPlugin[pluginName] + + expect(registeredPlugin).toBeDefined() + expect(registeredPlugin.testMethod()).toBe(true) + }) +}) diff --git a/sdk/wallet-sdk/src/wallet/init/index.ts b/sdk/wallet-sdk/src/wallet/init/index.ts index 1d8ca6c87..42b15a69f 100644 --- a/sdk/wallet-sdk/src/wallet/init/index.ts +++ b/sdk/wallet-sdk/src/wallet/init/index.ts @@ -1,6 +1,7 @@ // Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. // SPDX-License-Identifier: Apache-2.0 +export * from './types/context.js' export * from './initializedSDK.js' export * from './types/index.js' export { SDKPlugin } from './plugin.js' diff --git a/sdk/wallet-sdk/src/wallet/init/plugin.ts b/sdk/wallet-sdk/src/wallet/init/plugin.ts index c3d508438..6c9412dac 100644 --- a/sdk/wallet-sdk/src/wallet/init/plugin.ts +++ b/sdk/wallet-sdk/src/wallet/init/plugin.ts @@ -2,26 +2,38 @@ // SPDX-License-Identifier: Apache-2.0 import { SDKLogger } from '../logger/index.js' -import { - EXTENDED_SDK_OPTION_KEYS, - ExtendedSDKOptions, - SDKContext, -} from '../sdk.js' +import { EXTENDED_SDK_OPTION_KEYS, ExtendedSDKOptions } from './types/sdk.js' +import type { SDKContext } from './types/context.js' export abstract class SDKPlugin { + /** + * + * @deprecated use this.ctx.logger instead + */ protected readonly logger: ReturnType + protected readonly ctx: SDKContext constructor( public readonly name: string, - protected readonly ctx: SDKContext + protected readonly _ctx: SDKContext ) { if (EXTENDED_SDK_OPTION_KEYS.includes(name as keyof ExtendedSDKOptions)) throw Error( - `Name ${name} is reserved and cannot be used to register the plugin. Reserved names: ${EXTENDED_SDK_OPTION_KEYS.join(', ')}.` + `Name "${name}" is reserved and cannot be used to register the plugin. Reserved names: ${EXTENDED_SDK_OPTION_KEYS.join(', ')}.` ) - this.logger = ctx.logger.child({ + const logger = _ctx.logger.child({ plugin: name, }) + + /** + * @deprecated + */ + this.logger = logger + + this.ctx = { + ..._ctx, + logger, + } } } diff --git a/sdk/wallet-sdk/src/wallet/init/types/context.ts b/sdk/wallet-sdk/src/wallet/init/types/context.ts new file mode 100644 index 000000000..44f64fad8 --- /dev/null +++ b/sdk/wallet-sdk/src/wallet/init/types/context.ts @@ -0,0 +1,19 @@ +// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { AbstractLedgerProvider } from '@canton-network/core-provider-ledger' +import { SDKLogger } from '../../logger/logger.js' +import { SDKErrorHandler } from '../../error/handler.js' + +export type SDKContext = { + ledgerProvider: AbstractLedgerProvider + userId: string + logger: SDKLogger + error: SDKErrorHandler + defaultSynchronizerId: string +} + +export type OfflineSDKContext = { + logger: SDKLogger + error: SDKErrorHandler +} diff --git a/sdk/wallet-sdk/src/wallet/init/types/sdk.ts b/sdk/wallet-sdk/src/wallet/init/types/sdk.ts index a3e4f0195..48044a95f 100644 --- a/sdk/wallet-sdk/src/wallet/init/types/sdk.ts +++ b/sdk/wallet-sdk/src/wallet/init/types/sdk.ts @@ -9,8 +9,9 @@ import { PartyNamespace } from '../../namespace/party/index.js' import { UserNamespace } from '../../namespace/user/index.js' import { SDKUtilsNamespace } from '../../namespace/utils/index.js' import { AmuletNamespace } from '../../namespace/amulet/namespace.js' -import { AssetNamespace, SDKContext, TokenNamespace } from '../../sdk.js' +import type { AssetNamespace, TokenNamespace } from '../../sdk.js' import { EventsNamespace } from '../../namespace/events/namespace.js' +import type { SDKContext } from './context.js' import { AmuletConfig, AssetConfig, diff --git a/sdk/wallet-sdk/src/wallet/namespace/amulet/namespace.ts b/sdk/wallet-sdk/src/wallet/namespace/amulet/namespace.ts index 88a3a8d4b..a16f1ba6d 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/amulet/namespace.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/amulet/namespace.ts @@ -2,7 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 import { PartyId } from '@canton-network/core-types' -import { AssetBody, SDKContext } from '../../sdk.js' +import type { AssetBody } from '../../sdk.js' +import type { SDKContext } from '../../init/types/context.js' import { PreparedCommand } from '../transactions/types.js' import { FeaturedAppRight, diff --git a/sdk/wallet-sdk/src/wallet/namespace/amulet/preapproval.ts b/sdk/wallet-sdk/src/wallet/namespace/amulet/preapproval.ts index fe31ed9a0..df386dbd6 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/amulet/preapproval.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/amulet/preapproval.ts @@ -2,7 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 import { PartyId } from '@canton-network/core-types' -import { AmuletNamespaceConfig, LedgerTypes } from '../../sdk.js' +import type { AmuletNamespaceConfig } from '../../sdk.js' +import type { LedgerCommonSchemas } from '@canton-network/core-ledger-client-types' import { PreapprovalParties } from './types.js' import { LedgerNamespace } from '../ledger/namespace.js' import { fetchAmulet } from './namespace.js' @@ -17,14 +18,14 @@ export class PreapprovalNamespace { */ public readonly command: { create: (args: { parties: PreapprovalParties }) => Promise<{ - CreateCommand: LedgerTypes['CreateCommand'] + CreateCommand: LedgerCommonSchemas['CreateCommand'] }> cancel: (args: { parties: PreapprovalParties }) => Promise< | [ - { ExerciseCommand: LedgerTypes['ExerciseCommand'] }, - LedgerTypes['DisclosedContract'][], + { ExerciseCommand: LedgerCommonSchemas['ExerciseCommand'] }, + LedgerCommonSchemas['DisclosedContract'][], ] | typeof EMPTY_COMMAND_RESULT > @@ -43,20 +44,20 @@ export class PreapprovalNamespace { const amulet = await fetchAmulet(this.ctx) - const command: { CreateCommand: LedgerTypes['CreateCommand'] } = - { - CreateCommand: { - templateId: - '#splice-wallet:Splice.Wallet.TransferPreapproval:TransferPreapprovalProposal', - createArguments: { - provider: - parties?.provider ?? - this.ctx.validatorParty, - receiver: parties.receiver, - expectedDso: amulet.admin, - }, + const command: { + CreateCommand: LedgerCommonSchemas['CreateCommand'] + } = { + CreateCommand: { + templateId: + '#splice-wallet:Splice.Wallet.TransferPreapproval:TransferPreapprovalProposal', + createArguments: { + provider: + parties?.provider ?? this.ctx.validatorParty, + receiver: parties.receiver, + expectedDso: amulet.admin, }, - } + }, + } return command }, diff --git a/sdk/wallet-sdk/src/wallet/namespace/events/types.ts b/sdk/wallet-sdk/src/wallet/namespace/events/types.ts index a32ce56c8..4f889f6c9 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/events/types.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/events/types.ts @@ -4,7 +4,7 @@ import { AuthTokenProvider } from '@canton-network/core-wallet-auth' import { PartyId } from '@canton-network/core-types' import { type LedgerCommonSchemas } from '@canton-network/core-ledger-client-types' -import { SDKContext } from '../../sdk.js' +import type { SDKContext } from '../../init/types/context.js' import { ParsedURL } from '../utils/url.js' export type UpdatesOptions = { diff --git a/sdk/wallet-sdk/src/wallet/namespace/ledger/namespace.ts b/sdk/wallet-sdk/src/wallet/namespace/ledger/namespace.ts index 43ae6c662..f8cb4531e 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/ledger/namespace.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/ledger/namespace.ts @@ -1,7 +1,8 @@ // Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -import { LedgerTypes, SDKContext } from '../../sdk.js' +import type { LedgerCommonSchemas } from '@canton-network/core-ledger-client-types' +import type { SDKContext } from '../../init/types/context.js' import { v4 } from 'uuid' import { PrepareOptions, ExecuteOptions, AcsRequestOptions } from './types.js' import { PreparedTransaction } from '../transactions/prepared.js' @@ -181,7 +182,9 @@ export class LedgerNamespace { */ readRaw: async ( options: AcsRequestOptions - ): Promise> => { + ): Promise< + Array + > => { const resolvedOptions = await this.resolveAcsOptions(options) this.sdkContext.logger.debug( @@ -207,7 +210,7 @@ export class LedgerNamespace { .map((acs) => { const jsActiveContract = ( acs.contractEntry as { - JsActiveContract: LedgerTypes['JsActiveContract'] + JsActiveContract: LedgerCommonSchemas['JsActiveContract'] } ).JsActiveContract diff --git a/sdk/wallet-sdk/src/wallet/namespace/ledger/types.ts b/sdk/wallet-sdk/src/wallet/namespace/ledger/types.ts index 9f4c9c3ff..f1e5eb3ff 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/ledger/types.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/ledger/types.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { PartyId } from '@canton-network/core-types' -import { LedgerTypes } from '../../sdk.js' +import type { LedgerCommonSchemas } from '@canton-network/core-ledger-client-types' import { AcsOptions } from '@canton-network/core-acs-reader' export type PrepareOptions = { @@ -10,7 +10,7 @@ export type PrepareOptions = { commands: WrappedCommand | WrappedCommand[] | unknown commandId?: string synchronizerId?: string - disclosedContracts?: LedgerTypes['DisclosedContract'][] + disclosedContracts?: LedgerCommonSchemas['DisclosedContract'][] } export type ExecuteOptions = { @@ -19,9 +19,9 @@ export type ExecuteOptions = { } export type RawCommandMap = { - ExerciseCommand: LedgerTypes['ExerciseCommand'] - CreateCommand: LedgerTypes['CreateCommand'] - CreateAndExerciseCommand: LedgerTypes['CreateAndExerciseCommand'] + ExerciseCommand: LedgerCommonSchemas['ExerciseCommand'] + CreateCommand: LedgerCommonSchemas['CreateCommand'] + CreateAndExerciseCommand: LedgerCommonSchemas['CreateAndExerciseCommand'] } export type WrappedCommand< K extends keyof RawCommandMap = keyof RawCommandMap, diff --git a/sdk/wallet-sdk/src/wallet/namespace/party/namespace.ts b/sdk/wallet-sdk/src/wallet/namespace/party/namespace.ts index f1b5008e7..3aa4972e0 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/party/namespace.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/party/namespace.ts @@ -4,7 +4,7 @@ import { PartyId } from '@canton-network/core-types' import { ExternalPartyNamespace } from './external/index.js' import { Ops } from '@canton-network/core-provider-ledger' -import { SDKContext } from '../../sdk.js' +import type { SDKContext } from '../../init/types/context.js' import { InternalPartyNamespace } from './index.js' import { SDKUtilsNamespace } from '../utils/index.js' diff --git a/sdk/wallet-sdk/src/wallet/namespace/party/party.test.ts b/sdk/wallet-sdk/src/wallet/namespace/party/party.test.ts index b1fb58912..4d51ab748 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/party/party.test.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/party/party.test.ts @@ -1,7 +1,7 @@ // Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -import { mock } from '../../__test__/mocks' +import * as mock from '../../__test__/mocks' import { it, describe, beforeEach, vi, expect } from 'vitest' import { PartyNamespace, diff --git a/sdk/wallet-sdk/src/wallet/namespace/token/namespace.ts b/sdk/wallet-sdk/src/wallet/namespace/token/namespace.ts index 87ed0d8c4..a746af701 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/token/namespace.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/token/namespace.ts @@ -7,7 +7,7 @@ import { TransferNamespace } from './transfer/index.js' import { TokenStandardService } from '@canton-network/core-token-standard-service' import { PartyId } from '@canton-network/core-types' import { PrettyTransactions } from '@canton-network/core-tx-parser' -import { SDKContext } from '../../sdk.js' +import type { SDKContext } from '../../init/types/context.js' import { ParsedURL } from '../utils/url.js' export type TokenNamespaceConfig = { diff --git a/sdk/wallet-sdk/src/wallet/namespace/transactions/prepared.ts b/sdk/wallet-sdk/src/wallet/namespace/transactions/prepared.ts index 970cfcaf3..744c5a4d2 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/transactions/prepared.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/transactions/prepared.ts @@ -6,7 +6,7 @@ import { signTransactionHash, } from '@canton-network/core-signing-lib' import { SignedTransaction } from './signed.js' -import { SDKContext } from '../../sdk.js' +import type { SDKContext } from '../../init/types/context.js' import { Ops } from '@canton-network/core-provider-ledger' import { decodePreparedTransaction } from '@canton-network/core-tx-visualizer' import { LedgerNamespace } from '../ledger/index.js' diff --git a/sdk/wallet-sdk/src/wallet/namespace/transactions/signed.ts b/sdk/wallet-sdk/src/wallet/namespace/transactions/signed.ts index 5c09a3407..474034fcf 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/transactions/signed.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/transactions/signed.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { Ops } from '@canton-network/core-provider-ledger' -import { SDKContext } from '../../sdk.js' +import type { SDKContext } from '../../init/types/context.js' import { ExecuteOptions } from '../ledger/types.js' import { LedgerNamespace } from '../ledger/index.js' diff --git a/sdk/wallet-sdk/src/wallet/namespace/transactions/types.ts b/sdk/wallet-sdk/src/wallet/namespace/transactions/types.ts index 2830db524..520baa256 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/transactions/types.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/transactions/types.ts @@ -1,7 +1,7 @@ // Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -import { LedgerTypes } from '../../sdk.js' +import type { LedgerCommonSchemas } from '@canton-network/core-ledger-client-types' import { RawCommandMap, WrappedCommand } from '../ledger/index.js' export type PreparedCommand< @@ -15,5 +15,5 @@ export type PreparedCommand< : K extends keyof RawCommandMap ? WrappedCommand : never, - LedgerTypes['DisclosedContract'][], + LedgerCommonSchemas['DisclosedContract'][], ] diff --git a/sdk/wallet-sdk/src/wallet/namespace/user/namespace.ts b/sdk/wallet-sdk/src/wallet/namespace/user/namespace.ts index 9ac6c4d40..b0e2dd439 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/user/namespace.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/user/namespace.ts @@ -1,7 +1,7 @@ // Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -import { SDKContext } from '../../sdk.js' +import type { SDKContext } from '../../init/types/context.js' import { SDKLogger } from '../../logger/logger.js' import { CreateUserParams, GrantOrRevokeRightsParams } from './types.js' diff --git a/sdk/wallet-sdk/src/wallet/namespace/utils/index.ts b/sdk/wallet-sdk/src/wallet/namespace/utils/index.ts index 24670eb48..59ff8a011 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/utils/index.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/utils/index.ts @@ -4,7 +4,7 @@ import { HashNamespace } from './hash/service.js' import { PingService } from './ping/index.js' -import { OfflineSDKContext } from '../../sdk.js' +import type { OfflineSDKContext } from '../../init/types/context.js' export class SDKUtilsNamespace { public readonly ping: PingService diff --git a/sdk/wallet-sdk/src/wallet/namespace/utils/url.ts b/sdk/wallet-sdk/src/wallet/namespace/utils/url.ts index 9ee1c50be..e1ee8a8b9 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/utils/url.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/utils/url.ts @@ -1,7 +1,7 @@ // Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -import { SDKContext } from '../../sdk.js' +import type { SDKContext } from '../../init/types/context.js' import { TokenStandardService } from '@canton-network/core-token-standard-service' export type URLInput = URL | string diff --git a/sdk/wallet-sdk/src/wallet/namespace/utils/utils.test.ts b/sdk/wallet-sdk/src/wallet/namespace/utils/utils.test.ts index c7ca0d303..a9efa3613 100644 --- a/sdk/wallet-sdk/src/wallet/namespace/utils/utils.test.ts +++ b/sdk/wallet-sdk/src/wallet/namespace/utils/utils.test.ts @@ -3,7 +3,7 @@ import { describe, it, vi, expect } from 'vitest' import { parseAssets, ParsedURL } from './url.js' -import { SDKContext } from '../../sdk.js' +import type { SDKContext } from '../../init/types/context.js' import { SDKLogger } from '../../logger/index.js' import { SDKError, SDKErrorHandler } from '../../error/index.js' import { SDKUtilsNamespace } from './index.js' diff --git a/sdk/wallet-sdk/src/wallet/sdk.ts b/sdk/wallet-sdk/src/wallet/sdk.ts index c7a63e07c..52d7d2460 100644 --- a/sdk/wallet-sdk/src/wallet/sdk.ts +++ b/sdk/wallet-sdk/src/wallet/sdk.ts @@ -27,7 +27,9 @@ import { } from '@canton-network/core-ledger-client-types' import { AllowedLogAdapters } from './logger/types.js' import { DappLedgerRpc } from '@canton-network/core-provider-dapp' -export * from './namespace/asset/index.js' +import { SDKContext } from './index.js' +export { findAsset } from './namespace/asset/index.js' +export type * from './namespace/asset/index.js' export type * from './namespace/token/index.js' export type * from './namespace/amulet/index.js' export { type TokenProviderConfig } from '@canton-network/core-wallet-auth' @@ -44,21 +46,7 @@ export { } from '@canton-network/core-signing-lib' export type LedgerTypes = LedgerCommonSchemas -export type SDKContext = { - ledgerProvider: AbstractLedgerProvider - userId: string - logger: SDKLogger - error: SDKErrorHandler - defaultSynchronizerId: string -} - -export type OfflineSDKContext = { - logger: SDKLogger - error: SDKErrorHandler -} - export * from './init/index.js' -export { PrepareOptions, ExecuteOptions } from './namespace/ledger/index.js' export * from './namespace/transactions/prepared.js' export * from './namespace/transactions/signed.js'