Skip to content

Commit bc85b2e

Browse files
revert: revert stuff from rebase
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
1 parent c84ec47 commit bc85b2e

5 files changed

Lines changed: 27 additions & 174 deletions

File tree

core/token-standard-service/src/token-standard-service.test.ts

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -964,94 +964,6 @@ describe('Token standard service', () => {
964964
])
965965
})
966966

967-
it('toPretty transactions', async () => {
968-
const { service } = makeService()
969-
const result = await service.core.toPrettyTransactions([], senderParty)
970-
expect(result.transactions).toHaveLength(0)
971-
expect(result.nextOffset).toBe(0)
972-
973-
const updates = [
974-
{ update: { OffsetCheckpoint: { value: { offset: 50 } } } },
975-
{ update: { OffsetCheckpoint: { value: { offset: 80 } } } },
976-
]
977-
978-
const updatesResult = await service.core.toPrettyTransactions(
979-
updates as any,
980-
senderParty
981-
)
982-
expect(updatesResult.nextOffset).toBeGreaterThanOrEqual(80)
983-
})
984-
985-
it('toQualfiedMemberId()', async () => {
986-
const { service } = makeService()
987-
expect(service.core.toQualifiedMemberId('abc123')).toBe('PAR::abc123')
988-
expect(service.core.toQualifiedMemberId('PAR::abc123')).toBe(
989-
'PAR::abc123'
990-
)
991-
expect(service.core.toQualifiedMemberId('MED::abc123')).toBe(
992-
'MED::abc123'
993-
)
994-
995-
expect(() => service.core.toQualifiedMemberId('')).toThrow(
996-
'memberId is required'
997-
)
998-
})
999-
1000-
it('converts all instrument pages to assets', async () => {
1001-
const { service, tokenClient } = makeService()
1002-
1003-
tokenClient.get
1004-
.mockResolvedValueOnce({
1005-
instruments: [
1006-
{
1007-
id: 'first-token',
1008-
name: 'First Token',
1009-
symbol: 'FIRST',
1010-
},
1011-
],
1012-
nextPageToken: 'page-2',
1013-
})
1014-
.mockResolvedValueOnce({
1015-
instruments: [
1016-
{
1017-
id: 'second-token',
1018-
name: 'Second Token',
1019-
symbol: 'SECOND',
1020-
},
1021-
],
1022-
})
1023-
.mockResolvedValueOnce({ adminId: 'admin-id' })
1024-
1025-
const response = await service.instrumentsToAsset(registryUrl)
1026-
1027-
expect(tokenClient.get).toHaveBeenNthCalledWith(
1028-
2,
1029-
'/registry/metadata/v1/instruments',
1030-
{ query: { pageToken: 'page-2' } }
1031-
)
1032-
expect(
1033-
tokenClient.get.mock.calls.filter(
1034-
([path]) => path === '/registry/metadata/v1/instruments'
1035-
)
1036-
).toHaveLength(2)
1037-
expect(response).toStrictEqual([
1038-
{
1039-
admin: 'admin-id',
1040-
displayName: 'First Token',
1041-
id: 'first-token',
1042-
registryUrl,
1043-
symbol: 'FIRST',
1044-
},
1045-
{
1046-
admin: 'admin-id',
1047-
displayName: 'Second Token',
1048-
id: 'second-token',
1049-
registryUrl,
1050-
symbol: 'SECOND',
1051-
},
1052-
])
1053-
})
1054-
1055967
it('holding locked returns correctly', async () => {
1056968
const future = new Date(Date.now() + 100_000).toISOString()
1057969
const past = new Date(Date.now() - 100_000).toISOString()

core/token-standard-service/src/token-standard-service.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ import {
1414
AllocationFactory_Allocate,
1515
AllocationSpecification,
1616
Transfer,
17+
transferInstructionRegistryTypes,
18+
allocationInstructionRegistryTypes,
1719
ExtraArgs,
1820
Metadata,
1921
FEATURED_APP_DELEGATE_PROXY_INTERFACE_ID,
2022
Holding,
2123
Beneficiaries,
22-
OffLedger,
2324
} from '@canton-network/core-token-standard'
2425
import {
2526
EventFilterBySetup,
@@ -505,7 +506,7 @@ class AllocationService {
505506
choiceArgs: AllocationFactory_Allocate,
506507
excludeDebugFields: boolean = true
507508
): Promise<
508-
OffLedger.AllocationInstructionV1.components['schemas']['FactoryWithChoiceContext']
509+
allocationInstructionRegistryTypes['schemas']['FactoryWithChoiceContext']
509510
> {
510511
return this.core
511512
.getTokenStandardClient(registryUrl)
@@ -518,7 +519,7 @@ class AllocationService {
518519
async createAllocationInstructionFromContext(
519520
factoryId: string,
520521
choiceArgs: AllocationFactory_Allocate,
521-
choiceContext: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
522+
choiceContext: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
522523
): Promise<[ExerciseCommand, DisclosedContract[]]> {
523524
choiceArgs.extraArgs.context = {
524525
...choiceContext.choiceContextData,
@@ -541,7 +542,7 @@ class AllocationService {
541542
requestedAt?: string,
542543
prefetchedRegistryChoiceContext?: {
543544
factoryId: string
544-
choiceContext: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
545+
choiceContext: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
545546
}
546547
): Promise<[ExerciseCommand, DisclosedContract[]]> {
547548
const choiceArgs = await this.buildAllocationFactoryChoiceArgs(
@@ -578,7 +579,7 @@ class AllocationService {
578579
| 'Allocation_ExecuteTransfer'
579580
| 'Allocation_Withdraw'
580581
| 'Allocation_Cancel',
581-
choiceContext: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
582+
choiceContext: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
582583
): [ExerciseCommand, DisclosedContract[]] {
583584
const exercise: ExerciseCommand = {
584585
templateId,
@@ -613,7 +614,7 @@ class AllocationService {
613614

614615
createExecuteTransferAllocationFromContext(
615616
allocationCid: string,
616-
choiceContext: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
617+
choiceContext: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
617618
): [ExerciseCommand, DisclosedContract[]] {
618619
return this.buildAllocationExerciseWithContext(
619620
ALLOCATION_INTERFACE_ID,
@@ -626,7 +627,7 @@ class AllocationService {
626627
async createExecuteTransferAllocation(
627628
allocationCid: string,
628629
registryUrl: string,
629-
prefetchedRegistryChoiceContext?: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
630+
prefetchedRegistryChoiceContext?: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
630631
): Promise<[ExerciseCommand, DisclosedContract[]]> {
631632
if (prefetchedRegistryChoiceContext) {
632633
return this.createExecuteTransferAllocationFromContext(
@@ -647,9 +648,7 @@ class AllocationService {
647648
async fetchWithdrawAllocationChoiceContext(
648649
allocationCid: string,
649650
registryUrl: string
650-
): Promise<
651-
OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
652-
> {
651+
): Promise<allocationInstructionRegistryTypes['schemas']['ChoiceContext']> {
653652
return this.core.getTokenStandardClient(registryUrl).post(
654653
'/registry/allocations/v1/{allocationId}/choice-contexts/withdraw',
655654
{
@@ -661,7 +660,7 @@ class AllocationService {
661660

662661
createWithdrawAllocationFromContext(
663662
allocationCid: string,
664-
choiceContext: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
663+
choiceContext: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
665664
): [ExerciseCommand, DisclosedContract[]] {
666665
return this.buildAllocationExerciseWithContext(
667666
ALLOCATION_INTERFACE_ID,
@@ -674,7 +673,7 @@ class AllocationService {
674673
async createWithdrawAllocation(
675674
allocationCid: string,
676675
registryUrl: string,
677-
prefetchedRegistryChoiceContext?: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
676+
prefetchedRegistryChoiceContext?: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
678677
): Promise<[ExerciseCommand, DisclosedContract[]]> {
679678
if (prefetchedRegistryChoiceContext) {
680679
return this.createWithdrawAllocationFromContext(
@@ -695,9 +694,7 @@ class AllocationService {
695694
async fetchCancelAllocationChoiceContext(
696695
allocationCid: string,
697696
registryUrl: string
698-
): Promise<
699-
OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
700-
> {
697+
): Promise<allocationInstructionRegistryTypes['schemas']['ChoiceContext']> {
701698
return this.core.getTokenStandardClient(registryUrl).post(
702699
'/registry/allocations/v1/{allocationId}/choice-contexts/cancel',
703700
{
@@ -709,7 +706,7 @@ class AllocationService {
709706

710707
createCancelAllocationFromContext(
711708
allocationCid: string,
712-
choiceContext: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
709+
choiceContext: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
713710
): [ExerciseCommand, DisclosedContract[]] {
714711
return this.buildAllocationExerciseWithContext(
715712
ALLOCATION_INTERFACE_ID,
@@ -722,7 +719,7 @@ class AllocationService {
722719
async createCancelAllocation(
723720
allocationCid: string,
724721
registryUrl: string,
725-
prefetchedRegistryChoiceContext?: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
722+
prefetchedRegistryChoiceContext?: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
726723
): Promise<[ExerciseCommand, DisclosedContract[]]> {
727724
if (prefetchedRegistryChoiceContext) {
728725
return this.createCancelAllocationFromContext(
@@ -878,7 +875,7 @@ class TransferService {
878875
choiceArgs: CreateTransferChoiceArgs,
879876
excludeDebugFields: boolean = true
880877
): Promise<
881-
OffLedger.TransferInstructionV1.components['schemas']['TransferFactoryWithChoiceContext']
878+
transferInstructionRegistryTypes['schemas']['TransferFactoryWithChoiceContext']
882879
> {
883880
return await this.core
884881
.getTokenStandardClient(registryUrl)
@@ -891,7 +888,7 @@ class TransferService {
891888
async createTransferFromContext(
892889
factoryId: string,
893890
choiceArgs: CreateTransferChoiceArgs,
894-
choiceContext: OffLedger.TransferInstructionV1.components['schemas']['ChoiceContext']
891+
choiceContext: transferInstructionRegistryTypes['schemas']['ChoiceContext']
895892
): Promise<[ExerciseCommand, DisclosedContract[]]> {
896893
this.logger.debug('Creating transfer from pre-fetched context...')
897894
choiceArgs.extraArgs.context = {
@@ -921,7 +918,7 @@ class TransferService {
921918
meta?: Metadata,
922919
prefetchedRegistryChoiceContext?: {
923920
factoryId: string
924-
choiceContext: OffLedger.TransferInstructionV1.components['schemas']['ChoiceContext']
921+
choiceContext: transferInstructionRegistryTypes['schemas']['ChoiceContext']
925922
},
926923
continueUntilCompletion?: boolean
927924
): Promise<[ExerciseCommand, DisclosedContract[]]> {
@@ -1129,7 +1126,7 @@ class TransferService {
11291126
async createAcceptTransferInstruction(
11301127
transferInstructionCid: string,
11311128
registryUrl: string,
1132-
prefetchedRegistryChoiceContext?: OffLedger.TransferInstructionV1.components['schemas']['ChoiceContext']
1129+
prefetchedRegistryChoiceContext?: transferInstructionRegistryTypes['schemas']['ChoiceContext']
11331130
): Promise<[ExerciseCommand, DisclosedContract[]]> {
11341131
if (prefetchedRegistryChoiceContext) {
11351132
return this.createAcceptTransferInstructionFromContext(
@@ -1210,7 +1207,7 @@ class TransferService {
12101207
async createRejectTransferInstruction(
12111208
transferInstructionCid: string,
12121209
registryUrl: string,
1213-
prefetchedRegistryChoiceContext?: OffLedger.TransferInstructionV1.components['schemas']['ChoiceContext']
1210+
prefetchedRegistryChoiceContext?: transferInstructionRegistryTypes['schemas']['ChoiceContext']
12141211
): Promise<[ExerciseCommand, DisclosedContract[]]> {
12151212
if (prefetchedRegistryChoiceContext) {
12161213
return this.createRejectTransferInstructionFromContext(
@@ -1292,7 +1289,7 @@ class TransferService {
12921289
async createWithdrawTransferInstruction(
12931290
transferInstructionCid: string,
12941291
registryUrl: string,
1295-
prefetchedRegistryChoiceContext?: OffLedger.TransferInstructionV1.components['schemas']['ChoiceContext']
1292+
prefetchedRegistryChoiceContext?: transferInstructionRegistryTypes['schemas']['ChoiceContext']
12961293
): Promise<[ExerciseCommand, DisclosedContract[]]> {
12971294
if (prefetchedRegistryChoiceContext) {
12981295
return this.createWithdrawTransferInstructionFromContext(
@@ -1320,7 +1317,7 @@ class TransferService {
13201317
transferInstructionCid: string,
13211318
registryUrl: string,
13221319
instructionChoice: 'Accept' | 'Reject' | 'Withdraw',
1323-
prefetchedRegistryChoiceContext?: OffLedger.TransferInstructionV1.components['schemas']['ChoiceContext']
1320+
prefetchedRegistryChoiceContext?: transferInstructionRegistryTypes['schemas']['ChoiceContext']
13241321
): Promise<[ExerciseCommand, DisclosedContract[]]> {
13251322
switch (instructionChoice) {
13261323
case 'Accept':

core/wallet-store-sql/src/store-sql.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,9 @@ implementations.forEach(([name, StoreImpl]) => {
656656
await store.addNetwork(network)
657657
await store.setSession({
658658
id: 'session-tx-immutable',
659+
origin: 'dapp-1',
659660
network: 'network1',
660-
accessToken: 'token',
661+
accessToken: 'test-access-token',
661662
})
662663

663664
for (let i = 0; i < 10; i++) {
@@ -697,8 +698,9 @@ implementations.forEach(([name, StoreImpl]) => {
697698
await store.addNetwork(network)
698699
await store.setSession({
699700
id: 'session-tx-immutable',
701+
origin: 'dapp-1',
700702
network: 'network1',
701-
accessToken: 'token',
703+
accessToken: 'test-access-token',
702704
})
703705

704706
for (let i = 0; i < 10; i++) {
@@ -737,8 +739,9 @@ implementations.forEach(([name, StoreImpl]) => {
737739
await store.addNetwork(network)
738740
await store.setSession({
739741
id: 'session-tx-immutable',
742+
origin: 'dapp-1',
740743
network: 'network1',
741-
accessToken: 'token',
744+
accessToken: 'test-access-token',
742745
})
743746

744747
for (let i = 0; i < 10; i++) {

wallet-gateway/remote/src/user-api/controller.test.ts

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,60 +1134,6 @@ describe('userController', () => {
11341134
})
11351135
})
11361136

1137-
it('addSession keeps the session when the ledger is disconnected', async () => {
1138-
mockNetworkStatus.mockResolvedValueOnce({
1139-
isConnected: false,
1140-
reason: 'Ledger unreachable: fetch failed',
1141-
})
1142-
const authWithValidClaims = createAuthWithAddSessionClaims()
1143-
const store = await createStore(logger, authWithValidClaims, {
1144-
withWallet: false,
1145-
})
1146-
const controller = createController(
1147-
store,
1148-
notificationService,
1149-
logger,
1150-
authWithValidClaims
1151-
)
1152-
1153-
const result = await controller.addSession({
1154-
networkId: 'network1',
1155-
})
1156-
1157-
expect(result.status).toBe('disconnected')
1158-
expect(result.reason).toBe('Ledger unreachable: fetch failed')
1159-
expect(walletSyncMocks.syncWallets).not.toHaveBeenCalled()
1160-
await expect(store.getSession()).resolves.toMatchObject({
1161-
network: 'network1',
1162-
})
1163-
})
1164-
1165-
it('addSession keeps the session when initial wallet sync fails', async () => {
1166-
walletSyncMocks.syncWallets.mockRejectedValueOnce(
1167-
new Error('Wallet sync failed')
1168-
)
1169-
const authWithValidClaims = createAuthWithAddSessionClaims()
1170-
const store = await createStore(logger, authWithValidClaims, {
1171-
withWallet: false,
1172-
})
1173-
const controller = createController(
1174-
store,
1175-
notificationService,
1176-
logger,
1177-
authWithValidClaims
1178-
)
1179-
1180-
const result = await controller.addSession({
1181-
networkId: 'network1',
1182-
})
1183-
1184-
expect(result.status).toBe('connected')
1185-
expect(walletSyncMocks.syncWallets).toHaveBeenCalledOnce()
1186-
await expect(store.getSession()).resolves.toMatchObject({
1187-
network: 'network1',
1188-
})
1189-
})
1190-
11911137
it('addSession rejects token when both scope and scp are missing', async () => {
11921138
const authWithoutScopeClaims: AuthContext = {
11931139
...auth,

wallet-gateway/remote/src/web/frontend/state-manager.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,6 @@ export class StateManager {
156156
await this.accessToken.clear(origin)
157157
await destroyTokenKey()
158158
}
159-
160-
async revokeAccessToken(): Promise<void> {
161-
await this.accessToken.clear()
162-
await destroyTokenKey()
163-
}
164159
}
165160

166161
export const stateManager = new StateManager()

0 commit comments

Comments
 (0)