Skip to content

Commit 69dcc40

Browse files
committed
added originator
1 parent 566d67f commit 69dcc40

File tree

6 files changed

+40
-30
lines changed

6 files changed

+40
-30
lines changed

src/identity/ContactsManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export class ContactsManager {
214214
}, this.originator)
215215

216216
// Create locking script for the new contact token
217-
const lockingScript = await new PushDrop(this.wallet).lock(
217+
const lockingScript = await new PushDrop(this.wallet, this.originator).lock(
218218
[ciphertext],
219219
CONTACT_PROTOCOL_ID,
220220
keyID,
@@ -226,7 +226,7 @@ export class ContactsManager {
226226
const [txid, outputIndex] = String(existingOutput.outpoint).split('.')
227227
const prevOutpoint = `${txid}.${outputIndex}` as const
228228

229-
const pushdrop = new PushDrop(this.wallet)
229+
const pushdrop = new PushDrop(this.wallet, this.originator)
230230
const { signableTransaction } = await this.wallet.createAction({
231231
description: 'Update Contact',
232232
inputBEEF: outputs.BEEF as number[],
@@ -339,7 +339,7 @@ export class ContactsManager {
339339
// Found the contact's output, spend it without creating a new one
340340
const prevOutpoint = `${txid}.${outputIndex}` as const
341341

342-
const pushdrop = new PushDrop(this.wallet)
342+
const pushdrop = new PushDrop(this.wallet, this.originator)
343343
const { signableTransaction } = await this.wallet.createAction({
344344
description: 'Delete Contact',
345345
inputBEEF: outputs.BEEF as number[],

src/identity/IdentityClient.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export class IdentityClient {
4848
certificate: WalletCertificate,
4949
fieldsToReveal: CertificateFieldNameUnder50Bytes[]
5050
): Promise<BroadcastResponse | BroadcastFailure> {
51-
debugger
5251
if (Object.keys(certificate.fields).length === 0) {
5352
throw new Error('Public reveal failed: Certificate has no fields to reveal!')
5453
}
@@ -123,7 +122,6 @@ export class IdentityClient {
123122
args: DiscoverByIdentityKeyArgs,
124123
overrideWithContacts = true
125124
): Promise<DisplayableIdentity[]> {
126-
debugger
127125
if (overrideWithContacts) {
128126
// Override results with personal contacts if available
129127
const contacts = await this.contactsManager.getContacts(args.identityKey)

src/identity/__tests/IdentityClient.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ describe('IdentityClient', () => {
193193
certificate,
194194
fieldsToReveal,
195195
verifier: expect.any(String)
196-
})
196+
}, undefined)
197197

198198
// Validate that createAction was called.
199199
expect(walletMock.createAction).toHaveBeenCalled()

src/overlay-tools/OverlayAdminTokenTemplate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import PushDrop from '../script/templates/PushDrop.js'
2-
import { WalletInterface } from '../wallet/Wallet.interfaces.js'
2+
import { OriginatorDomainNameStringUnder250Bytes, WalletInterface } from '../wallet/Wallet.interfaces.js'
33
import {
44
LockingScript,
55
ScriptTemplate,
@@ -48,8 +48,8 @@ export default class OverlayAdminTokenTemplate implements ScriptTemplate {
4848
* Constructs a new Overlay Admin template instance
4949
* @param wallet Wallet to use for locking and unlocking
5050
*/
51-
constructor (wallet: WalletInterface) {
52-
this.pushDrop = new PushDrop(wallet)
51+
constructor (wallet: WalletInterface, originator?: OriginatorDomainNameStringUnder250Bytes) {
52+
this.pushDrop = new PushDrop(wallet, originator)
5353
}
5454

5555
/**

src/registry/RegistryClient.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import {
33
WalletProtocol,
44
WalletClient,
55
PubKeyHex,
6-
SecurityLevel
6+
SecurityLevel,
7+
OriginatorDomainNameStringUnder250Bytes
78
} from '../wallet/index.js'
89
import { Utils } from '../primitives/index.js'
910
import {
@@ -51,7 +52,8 @@ export class RegistryClient {
5152

5253
constructor (
5354
private readonly wallet: WalletInterface = new WalletClient(),
54-
options: { acceptDelayedBroadcast?: boolean, resolver?: LookupResolver } = {}
55+
options: { acceptDelayedBroadcast?: boolean, resolver?: LookupResolver } = {},
56+
private readonly originator?: OriginatorDomainNameStringUnder250Bytes
5557
) {
5658
this.acceptDelayedBroadcast = options.acceptDelayedBroadcast ?? false
5759
this.resolver = options.resolver ?? new LookupResolver()
@@ -91,7 +93,7 @@ export class RegistryClient {
9193
*/
9294
async registerDefinition (data: DefinitionData): Promise<BroadcastResponse | BroadcastFailure> {
9395
const registryOperator = await this.getIdentityKey()
94-
const pushdrop = new PushDrop(this.wallet)
96+
const pushdrop = new PushDrop(this.wallet, this.originator)
9597

9698
// Convert definition data into PushDrop fields
9799
const fields = this.buildPushDropFields(data, registryOperator)
@@ -117,7 +119,7 @@ export class RegistryClient {
117119
acceptDelayedBroadcast: this.acceptDelayedBroadcast,
118120
randomizeOutputs: false
119121
}
120-
})
122+
}, this.originator)
121123
if (tx === undefined) {
122124
throw new Error(`Failed to create ${data.definitionType} registration transaction!`)
123125
}
@@ -262,15 +264,15 @@ export class RegistryClient {
262264
acceptDelayedBroadcast: this.acceptDelayedBroadcast,
263265
randomizeOutputs: false
264266
}
265-
})
267+
}, this.originator)
266268

267269
if (signableTransaction === undefined) {
268270
throw new Error('Failed to create signable transaction.')
269271
}
270272
const partialTx = Transaction.fromAtomicBEEF(signableTransaction.tx)
271273

272274
// Prepare the unlocker
273-
const pushdrop = new PushDrop(this.wallet)
275+
const pushdrop = new PushDrop(this.wallet, this.originator)
274276
const unlocker = pushdrop.unlock(
275277
this.mapDefinitionTypeToWalletProtocol(registryRecord.definitionType),
276278
REGISTRANT_KEY_ID,
@@ -291,7 +293,7 @@ export class RegistryClient {
291293
options: {
292294
acceptDelayedBroadcast: this.acceptDelayedBroadcast
293295
}
294-
})
296+
}, this.originator)
295297

296298
if (signedTx === undefined) {
297299
throw new Error('Failed to finalize the transaction signature.')
@@ -344,7 +346,7 @@ export class RegistryClient {
344346
? (registryRecord.name !== undefined ? registryRecord.name : registryRecord.type)
345347
: 'unknown'
346348

347-
const pushdrop = new PushDrop(this.wallet)
349+
const pushdrop = new PushDrop(this.wallet, this.originator)
348350

349351
// Build the new locking script with updated data
350352
const fields = this.buildPushDropFields(updatedData, currentIdentityKey)
@@ -374,7 +376,7 @@ export class RegistryClient {
374376
acceptDelayedBroadcast: this.acceptDelayedBroadcast,
375377
randomizeOutputs: false
376378
}
377-
})
379+
}, this.originator)
378380

379381
if (signableTransaction === undefined) {
380382
throw new Error('Failed to create signable transaction.')
@@ -403,7 +405,7 @@ export class RegistryClient {
403405
options: {
404406
acceptDelayedBroadcast: this.acceptDelayedBroadcast
405407
}
406-
})
408+
}, this.originator)
407409

408410
if (signedTx === undefined) {
409411
throw new Error('Failed to finalize the transaction signature.')

src/registry/__tests/RegistryClient.test.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ jest.mock('../../primitives/index.js', () => {
9595
})
9696

9797
let walletMock: Partial<WalletInterface>
98+
const TEST_ORIGINATOR = 'test.originator.example'
9899

99100
/**
100101
* Build minimal valid DefinitionData for each type
@@ -163,7 +164,7 @@ describe('RegistryClient', () => {
163164
getNetwork: jest.fn().mockResolvedValue({ network: 'main' })
164165
}
165166

166-
registryClient = new RegistryClient(walletMock as WalletInterface)
167+
registryClient = new RegistryClient(walletMock as WalletInterface, {}, TEST_ORIGINATOR)
167168

168169
// Mock the resolver instance since it's now initialized in constructor
169170
; (registryClient as any).resolver = {
@@ -195,7 +196,8 @@ describe('RegistryClient', () => {
195196
lockingScript: 'mockLockingScriptHex'
196197
})
197198
])
198-
})
199+
}),
200+
TEST_ORIGINATOR
199201
)
200202
expect(TopicBroadcaster).toHaveBeenCalledWith(['tm_basketmap'], expect.objectContaining({
201203
networkPreset: 'main'
@@ -219,7 +221,8 @@ describe('RegistryClient', () => {
219221
lockingScript: 'mockLockingScriptHex'
220222
})
221223
])
222-
})
224+
}),
225+
TEST_ORIGINATOR
223226
)
224227

225228
expect(TopicBroadcaster).toHaveBeenCalledWith(['tm_protomap'], expect.objectContaining({
@@ -244,7 +247,8 @@ describe('RegistryClient', () => {
244247
lockingScript: 'mockLockingScriptHex'
245248
})
246249
])
247-
})
250+
}),
251+
TEST_ORIGINATOR
248252
)
249253

250254
expect(TopicBroadcaster).toHaveBeenCalledWith(['tm_certmap'], expect.objectContaining({
@@ -445,7 +449,8 @@ describe('RegistryClient', () => {
445449
inputDescription: 'Removing basket token'
446450
}
447451
]
448-
})
452+
}),
453+
TEST_ORIGINATOR
449454
)
450455

451456
expect(TopicBroadcaster).toHaveBeenCalledWith(['tm_basketmap'], expect.objectContaining({
@@ -535,7 +540,8 @@ describe('RegistryClient', () => {
535540
inputDescription: 'Removing protocol token'
536541
}
537542
]
538-
})
543+
}),
544+
TEST_ORIGINATOR
539545
)
540546

541547
expect(TopicBroadcaster).toHaveBeenCalledWith(['tm_protomap'], expect.objectContaining({
@@ -573,7 +579,8 @@ describe('RegistryClient', () => {
573579
inputDescription: 'Removing certificate token'
574580
}
575581
]
576-
})
582+
}),
583+
TEST_ORIGINATOR
577584
)
578585

579586
expect(TopicBroadcaster).toHaveBeenCalledWith(['tm_certmap'], expect.objectContaining({
@@ -604,13 +611,14 @@ describe('RegistryClient', () => {
604611
expect(walletMock.createAction).toHaveBeenCalledWith(
605612
expect.objectContaining({
606613
description: 'Remove certificate item: testCertType'
607-
})
614+
}),
615+
TEST_ORIGINATOR
608616
)
609617
})
610618

611619
it('should use acceptDelayedBroadcast setting from constructor', async () => {
612620
// Create a new client with acceptDelayedBroadcast: true
613-
const clientWithDelayedBroadcast = new RegistryClient(walletMock as WalletInterface, { acceptDelayedBroadcast: true })
621+
const clientWithDelayedBroadcast = new RegistryClient(walletMock as WalletInterface, { acceptDelayedBroadcast: true }, TEST_ORIGINATOR)
614622
; (clientWithDelayedBroadcast as any).resolver = {
615623
query: jest.fn().mockResolvedValue({ type: 'output-list', outputs: [] })
616624
}
@@ -622,15 +630,17 @@ describe('RegistryClient', () => {
622630
options: expect.objectContaining({
623631
acceptDelayedBroadcast: true
624632
})
625-
})
633+
}),
634+
TEST_ORIGINATOR
626635
)
627636

628637
expect(walletMock.signAction).toHaveBeenCalledWith(
629638
expect.objectContaining({
630639
options: expect.objectContaining({
631640
acceptDelayedBroadcast: true
632641
})
633-
})
642+
}),
643+
TEST_ORIGINATOR
634644
)
635645
})
636646
})

0 commit comments

Comments
 (0)