Skip to content

Commit 6001df3

Browse files
Merge pull request #379 from bsv-blockchain/fix/localkvstore-originator-passthrough
Fix/localkvstore originator passthrough
2 parents a77f3d0 + 2031a06 commit 6001df3

File tree

5 files changed

+41
-30
lines changed

5 files changed

+41
-30
lines changed

CHANGELOG.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file. The format
55
## Table of Contents
66

77
- [Unreleased](#unreleased)
8+
- [1.9.1 - 2025-11-10](#191---2025-11-10)
9+
- [1.9.0 - 2025-11-09](#190---2025-11-09)
810
- [1.8.13 - 2025-11-06](#1813---2025-11-06)
911
- [1.8.12 - 2025-11-06](#1812---2025-11-06)
1012
- [1.8.11 - 2025-10-30](#1811---2025-10-30)
@@ -173,11 +175,11 @@ All notable changes to this project will be documented in this file. The format
173175

174176
---
175177

176-
### [1.8.13] - 2025-11-06
178+
### [1.9.1] - 2025-11-10
177179

178-
### Added
180+
### Fixed
179181

180-
- LookupResolver: Support for custom overlay ranking to allow for expedited lookups and reputation tracking.
182+
- Added support for originator param in LocalKVStore wallet calls.
181183

182184
---
183185

@@ -193,6 +195,15 @@ All notable changes to this project will be documented in this file. The format
193195

194196
---
195197

198+
199+
### [1.8.13] - 2025-11-06
200+
201+
### Added
202+
203+
- LookupResolver: Support for custom overlay ranking to allow for expedited lookups and reputation tracking.
204+
205+
---
206+
196207
### [1.8.12] - 2025-11-06
197208

198209
### Fixed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bsv/sdk",
3-
"version": "1.9.0",
3+
"version": "1.9.1",
44
"type": "module",
55
"description": "BSV Blockchain Software Development Kit",
66
"main": "dist/cjs/mod.js",

src/kvstore/LocalKVStore.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export default class LocalKVStore {
115115
tagQueryMode: 'all',
116116
include: 'entire transactions',
117117
limit
118-
})
118+
}, this.originator)
119119
return results
120120
}
121121

@@ -175,7 +175,7 @@ export default class LocalKVStore {
175175
const { plaintext } = await this.wallet.decrypt({
176176
...this.getProtocol(key),
177177
ciphertext: field
178-
})
178+
}, this.originator)
179179
r.value = Utils.toUTF8(plaintext)
180180
}
181181
return r
@@ -241,7 +241,7 @@ export default class LocalKVStore {
241241
const { ciphertext } = await this.wallet.encrypt({
242242
...protocol,
243243
plaintext: valueAsArray
244-
})
244+
}, this.originator)
245245
valueAsArray = ciphertext
246246
}
247247

@@ -272,7 +272,7 @@ export default class LocalKVStore {
272272
acceptDelayedBroadcast: this.acceptDelayedBroadcast,
273273
randomizeOutputs: false
274274
}
275-
})
275+
}, this.originator)
276276

277277
if (outputs.length > 0 && typeof signableTransaction !== 'object') {
278278
throw new Error('Wallet did not return a signable transaction when expected.')
@@ -285,7 +285,7 @@ export default class LocalKVStore {
285285
const { txid } = await this.wallet.signAction({
286286
reference: signableTransaction.reference,
287287
spends
288-
})
288+
}, this.originator)
289289
outpoint = `${txid as string}.0`
290290
}
291291
} catch (error) {
@@ -326,15 +326,15 @@ export default class LocalKVStore {
326326
options: {
327327
acceptDelayedBroadcast: this.acceptDelayedBroadcast
328328
}
329-
})
329+
}, this.originator)
330330
if (typeof signableTransaction !== 'object') {
331331
throw new Error('Wallet did not return a signable transaction when expected.')
332332
}
333333
const spends = await this.getSpends(key, outputs, pushdrop, signableTransaction.tx)
334334
const { txid } = await this.wallet.signAction({
335335
reference: signableTransaction.reference,
336336
spends
337-
})
337+
}, this.originator)
338338
if (txid === undefined) { throw new Error('signAction must return a valid txid') }
339339
txids.push(txid)
340340
} catch (error) {

src/kvstore/__tests/LocalKVStore.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('localKVStore', () => {
104104
// const testUnlockingScriptHex = 'mockUnlockingScriptHex'; // Defined above
105105

106106
beforeEach(() => {
107-
// Reset mocks before each test (clears calls and resets implementations)
107+
// Reset mocks before each test (clears calls and resets implementations)
108108
jest.clearAllMocks()
109109

110110
// Create a fresh mock wallet for each test
@@ -122,7 +122,7 @@ describe('localKVStore', () => {
122122
// --- Constructor Tests ---
123123
describe('constructor', () => {
124124
it('should create an instance with default wallet and encrypt=true', () => {
125-
// We need to mock the default WalletClient if the SUT uses it
125+
// We need to mock the default WalletClient if the SUT uses it
126126
const MockedWalletClient = require('../../../mod.js').WalletClient
127127
const store = new LocalKVStore(undefined, 'default-context')
128128
expect(store).toBeInstanceOf(LocalKVStore)
@@ -200,7 +200,7 @@ describe('localKVStore', () => {
200200
let pushDropInstance: PushDrop // To access the instance methods
201201

202202
beforeEach(() => {
203-
// Get the mock instance that will be created by `new PushDrop()`
203+
// Get the mock instance that will be created by `new PushDrop()`
204204
pushDropInstance = new (PushDrop as any)()
205205
})
206206

@@ -223,7 +223,7 @@ describe('localKVStore', () => {
223223
plaintext: valueArray, // Should be Array<number>
224224
protocolID: [2, testContext],
225225
keyID: testKey
226-
})
226+
}, undefined)
227227
// Check the mock instance's lock method
228228
expect(mockPDInstance.lock).toHaveBeenCalledWith(
229229
// The lock function expects Array<number[] | Uint8Array>
@@ -250,7 +250,7 @@ describe('localKVStore', () => {
250250
acceptDelayedBroadcast: false,
251251
randomizeOutputs: false
252252
}
253-
})
253+
}, undefined)
254254
expect(mockWallet.signAction).not.toHaveBeenCalled()
255255
expect(mockWallet.relinquishOutput).not.toHaveBeenCalled()
256256
})
@@ -293,15 +293,15 @@ describe('localKVStore', () => {
293293
acceptDelayedBroadcast: false,
294294
randomizeOutputs: false
295295
}
296-
})
296+
}, undefined)
297297
expect(mockWallet.signAction).not.toHaveBeenCalled()
298298
expect(mockWallet.relinquishOutput).not.toHaveBeenCalled()
299299
})
300300

301301
it('should update an existing output (spend and create)', async () => {
302302
const existingOutpoint = 'oldTxId.0'
303303
const existingOutput = { outpoint: existingOutpoint, txid: 'oldTxId', vout: 0, lockingScript: 'oldScriptHex' } // Added script
304-
const mockBEEF = [1,2,3,4,5,6]
304+
const mockBEEF = [1, 2, 3, 4, 5, 6]
305305
const signableRef = 'signableTxRef123'
306306
const signableTx = []
307307
const updatedTxId = 'updatedTxId'
@@ -366,7 +366,7 @@ describe('localKVStore', () => {
366366
outputs: expect.arrayContaining([ // Check outputs array
367367
expect.objectContaining({ lockingScript: testLockingScriptHex }) // Check the new output script
368368
])
369-
}))
369+
}), undefined)
370370

371371
// Verify signing steps
372372
expect(MockedTransaction.fromAtomicBEEF).toHaveBeenCalledWith(signableTx)
@@ -383,7 +383,7 @@ describe('localKVStore', () => {
383383
spends: {
384384
0: { unlockingScript: testUnlockingScriptHex } // Check unlocking script from mock sign result
385385
}
386-
})
386+
}, undefined)
387387
expect(mockWallet.relinquishOutput).not.toHaveBeenCalled()
388388
})
389389

@@ -395,7 +395,7 @@ describe('localKVStore', () => {
395395
const existingOutpoint2 = 'oldTxId2.1'
396396
const existingOutput1 = { outpoint: existingOutpoint1, txid: 'oldTxId1', vout: 0, lockingScript: 's1' }
397397
const existingOutput2 = { outpoint: existingOutpoint2, txid: 'oldTxId2', vout: 1, lockingScript: 's2' }
398-
const mockBEEF = [1,2,3,4,5,6]
398+
const mockBEEF = [1, 2, 3, 4, 5, 6]
399399
const signableRef = 'signableTxRefMulti'
400400
const signableTx = []
401401
const updatedTxId = 'updatedTxIdMulti'
@@ -457,7 +457,7 @@ describe('localKVStore', () => {
457457
outputs: expect.arrayContaining([
458458
expect.objectContaining({ lockingScript: testLockingScriptHex })
459459
])
460-
}))
460+
}), undefined)
461461

462462
// Verify signing loop
463463
expect(MockedTransaction.fromAtomicBEEF).toHaveBeenCalledWith(signableTx)
@@ -478,14 +478,14 @@ describe('localKVStore', () => {
478478
0: { unlockingScript: testUnlockingScriptHex }, // Same mock script for both
479479
1: { unlockingScript: testUnlockingScriptHex }
480480
}
481-
})
481+
}, undefined)
482482
expect(mockWallet.relinquishOutput).not.toHaveBeenCalled()
483483
})
484484

485485
it('should preserve original error message when createAction fails', async () => {
486486
const originalErrorMessage = 'Network connection timeout while creating transaction'
487487
const originalError = new Error(originalErrorMessage)
488-
488+
489489
// Mock the lookupValue to return a value that differs from what we're setting
490490
// to ensure set() will attempt to create a transaction
491491
const mockedLor: ListOutputsResult = {
@@ -533,7 +533,7 @@ describe('localKVStore', () => {
533533
let pushDropInstance: PushDrop // To access the instance methods
534534

535535
beforeEach(() => {
536-
// Get the mock instance that will be created by `new PushDrop()`
536+
// Get the mock instance that will be created by `new PushDrop()`
537537
pushDropInstance = new (PushDrop as any)()
538538
})
539539

@@ -598,7 +598,7 @@ describe('localKVStore', () => {
598598
options: {
599599
acceptDelayedBroadcast: false
600600
}
601-
})
601+
}, undefined)
602602
// Check that outputs key is absent
603603
expect(mockWallet.createAction.mock.calls[0][0]).not.toHaveProperty('outputs')
604604

@@ -619,7 +619,7 @@ describe('localKVStore', () => {
619619
0: { unlockingScript: testUnlockingScriptHex },
620620
1: { unlockingScript: testUnlockingScriptHex }
621621
}
622-
})
622+
}, undefined)
623623
expect(mockWallet.relinquishOutput).not.toHaveBeenCalled()
624624
})
625625

@@ -659,7 +659,7 @@ describe('localKVStore', () => {
659659
it('should preserve original error message when wallet operations fail during removal', async () => {
660660
const originalErrorMessage = 'Insufficient funds to cover transaction fees'
661661
const originalError = new Error(originalErrorMessage)
662-
662+
663663
const existingOutpoint = 'failTxId.0'
664664
const existingOutput = { outpoint: existingOutpoint, txid: 'failTxId', vout: 0, lockingScript: 's1' }
665665
const mockBEEF = Buffer.from('mockBEEFFail')

0 commit comments

Comments
 (0)