Skip to content

Commit 4a91875

Browse files
committed
fix: resolve type annotation error in TransactionBuilderFactory
Ticket: SC-3131
1 parent 133771b commit 4a91875

File tree

3 files changed

+37
-35
lines changed

3 files changed

+37
-35
lines changed

modules/sdk-coin-tao/src/lib/moveStakeBuilder.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Interface, Schema, Transaction, TransactionBuilder } from '@bitgo/abstract-substrate';
2-
import { InvalidTransactionError, TransactionType } from '@bitgo/sdk-core';
2+
import { InvalidTransactionError, TransactionType, BaseAddress } from '@bitgo/sdk-core';
33
import { BaseCoin as CoinConfig } from '@bitgo/statics';
44
import { DecodedSignedTx, DecodedSigningPayload, defineMethod, UnsignedTransaction } from '@substrate/txwrapper-core';
55
import BigNumber from 'bignumber.js';
@@ -58,7 +58,7 @@ export class MoveStakeBuilder extends TransactionBuilder {
5858
* @param {string} address of origin hotkey
5959
* @returns {MoveStakeBuilder} This builder.
6060
*/
61-
originHotkey(address: string): this {
61+
originHotkey({ address }: BaseAddress): this {
6262
this.validateAddress({ address });
6363
this._originHotkey = address;
6464
return this;
@@ -69,7 +69,7 @@ export class MoveStakeBuilder extends TransactionBuilder {
6969
* @param {string} address of destination hotkey
7070
* @returns {MoveStakeBuilder} This builder.
7171
*/
72-
destinationHotkey(address: string): this {
72+
destinationHotkey({ address }: BaseAddress): this {
7373
this.validateAddress({ address });
7474
this._destinationHotkey = address;
7575
return this;
@@ -107,8 +107,8 @@ export class MoveStakeBuilder extends TransactionBuilder {
107107
const tx = super.fromImplementation(rawTransaction);
108108
const txMethod = this._method.args as Interface.MoveStakeArgs;
109109
this.amount(txMethod.alphaAmount);
110-
this.originHotkey(txMethod.originHotkey);
111-
this.destinationHotkey(txMethod.destinationHotkey);
110+
this.originHotkey({ address: txMethod.originHotkey });
111+
this.destinationHotkey({ address: txMethod.destinationHotkey });
112112
this.originNetuid(txMethod.originNetuid);
113113
this.destinationNetuid(txMethod.destinationNetuid);
114114
return tx;

modules/sdk-coin-tao/src/lib/transactionBuilderFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class TransactionBuilderFactory extends BaseTransactionBuilderFactory {
3333
return new TokenTransferBuilder(this._coinConfig).material(this._material);
3434
}
3535

36-
getMoveStakeBuilder(): TransactionBuilder {
36+
getMoveStakeBuilder(): MoveStakeBuilder {
3737
return new MoveStakeBuilder(this._coinConfig).material(this._material);
3838
}
3939

modules/sdk-coin-tao/test/unit/transactionBuilder/moveStakeBuilder.ts

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,17 @@ describe('Tao Move Stake Builder', function () {
4343
it('should validate addresses', function () {
4444
const spyValidateAddress = spy(builder, 'validateAddress');
4545
assert.throws(
46-
() => builder.originHotkey('abc'),
46+
() => builder.originHotkey({ address: 'abc' }),
4747
(e: Error) => e.message === `The address 'abc' is not a well-formed dot address`
4848
);
4949
assert.throws(
50-
() => builder.destinationHotkey('abc'),
50+
() => builder.destinationHotkey({ address: 'abc' }),
5151
(e: Error) => e.message === `The address 'abc' is not a well-formed dot address`
5252
);
53-
should.doesNotThrow(() => builder.originHotkey('5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT'));
54-
should.doesNotThrow(() => builder.destinationHotkey('5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq'));
53+
should.doesNotThrow(() => builder.originHotkey({ address: '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' }));
54+
should.doesNotThrow(() =>
55+
builder.destinationHotkey({ address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' })
56+
);
5557

5658
SinonAssert.callCount(spyValidateAddress, 4);
5759
});
@@ -61,8 +63,8 @@ describe('Tao Move Stake Builder', function () {
6163
it('should build a move stake transaction', async function () {
6264
builder
6365
.amount('9007199254740995')
64-
.originHotkey('5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT')
65-
.destinationHotkey('5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq')
66+
.originHotkey({ address: '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' })
67+
.destinationHotkey({ address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' })
6668
.originNetuid('1')
6769
.destinationNetuid('1')
6870
.sender({ address: sender.address })
@@ -136,8 +138,8 @@ describe('Tao Move Stake Builder', function () {
136138
it('should build transaction with different netuids', async function () {
137139
builder
138140
.amount('1000000000000')
139-
.originHotkey('5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT')
140-
.destinationHotkey('5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq')
141+
.originHotkey({ address: '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' })
142+
.destinationHotkey({ address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' })
141143
.originNetuid('1')
142144
.destinationNetuid('2')
143145
.sender({ address: sender.address })
@@ -163,8 +165,8 @@ describe('Tao Move Stake Builder', function () {
163165
should.doesNotThrow(() => {
164166
builder
165167
.amount('1000000000000')
166-
.originHotkey('5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT')
167-
.destinationHotkey('5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq')
168+
.originHotkey({ address: '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' })
169+
.destinationHotkey({ address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' })
168170
.originNetuid('1')
169171
.destinationNetuid('1');
170172
});
@@ -231,8 +233,8 @@ describe('Tao Move Stake Builder', function () {
231233
it('should build a signed move stake transaction with TSS signature', async function () {
232234
builder
233235
.amount('9007199254740995')
234-
.originHotkey('5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT')
235-
.destinationHotkey('5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq')
236+
.originHotkey({ address: '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' })
237+
.destinationHotkey({ address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' })
236238
.originNetuid('1')
237239
.destinationNetuid('1')
238240
.sender({ address: sender.address })
@@ -265,8 +267,8 @@ describe('Tao Move Stake Builder', function () {
265267
it('should build an unsigned move stake transaction', async function () {
266268
builder
267269
.amount('50000000')
268-
.originHotkey('5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT')
269-
.destinationHotkey('5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq')
270+
.originHotkey({ address: '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' })
271+
.destinationHotkey({ address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' })
270272
.originNetuid('1')
271273
.destinationNetuid('2')
272274
.sender({ address: sender.address })
@@ -300,7 +302,7 @@ describe('Tao Move Stake Builder', function () {
300302
it('should throw error for missing origin hotkey', function () {
301303
builder
302304
.amount('1000000000000')
303-
.destinationHotkey('5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq')
305+
.destinationHotkey({ address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' })
304306
.originNetuid('1')
305307
.destinationNetuid('1');
306308

@@ -313,7 +315,7 @@ describe('Tao Move Stake Builder', function () {
313315
it('should throw error for missing destination hotkey', function () {
314316
builder
315317
.amount('1000000000000')
316-
.originHotkey('5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT')
318+
.originHotkey({ address: '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' })
317319
.originNetuid('1')
318320
.destinationNetuid('1');
319321

@@ -326,8 +328,8 @@ describe('Tao Move Stake Builder', function () {
326328
it('should throw error for missing origin netuid', function () {
327329
builder
328330
.amount('1000000000000')
329-
.originHotkey('5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT')
330-
.destinationHotkey('5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq')
331+
.originHotkey({ address: '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' })
332+
.destinationHotkey({ address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' })
331333
.destinationNetuid('1');
332334

333335
assert.throws(
@@ -339,8 +341,8 @@ describe('Tao Move Stake Builder', function () {
339341
it('should throw error for missing destination netuid', function () {
340342
builder
341343
.amount('1000000000000')
342-
.originHotkey('5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT')
343-
.destinationHotkey('5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq')
344+
.originHotkey({ address: '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' })
345+
.destinationHotkey({ address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' })
344346
.originNetuid('1');
345347

346348
assert.throws(
@@ -351,8 +353,8 @@ describe('Tao Move Stake Builder', function () {
351353

352354
it('should throw error for missing amount', function () {
353355
builder
354-
.originHotkey('5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT')
355-
.destinationHotkey('5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq')
356+
.originHotkey({ address: '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' })
357+
.destinationHotkey({ address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' })
356358
.originNetuid('1')
357359
.destinationNetuid('1');
358360

@@ -402,7 +404,7 @@ describe('Tao Move Stake Builder', function () {
402404
it('should handle same origin and destination hotkeys', function () {
403405
const sameAddress = '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT';
404406
should.doesNotThrow(() => {
405-
builder.originHotkey(sameAddress).destinationHotkey(sameAddress);
407+
builder.originHotkey({ address: sameAddress }).destinationHotkey({ address: sameAddress });
406408
});
407409
});
408410

@@ -422,11 +424,11 @@ describe('Tao Move Stake Builder', function () {
422424

423425
invalidAddresses.forEach((address) => {
424426
assert.throws(
425-
() => builder.originHotkey(address),
427+
() => builder.originHotkey({ address }),
426428
(e: Error) => e.message.includes('is not a well-formed dot address')
427429
);
428430
assert.throws(
429-
() => builder.destinationHotkey(address),
431+
() => builder.destinationHotkey({ address }),
430432
(e: Error) => e.message.includes('is not a well-formed dot address')
431433
);
432434
});
@@ -453,8 +455,8 @@ describe('Tao Move Stake Builder', function () {
453455
it('should provide correct explanation with different subnet tokens', async function () {
454456
builder
455457
.amount('1000000000000')
456-
.originHotkey('5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT')
457-
.destinationHotkey('5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq')
458+
.originHotkey({ address: '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' })
459+
.destinationHotkey({ address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' })
458460
.originNetuid('1')
459461
.destinationNetuid('2')
460462
.sender({ address: sender.address })
@@ -479,8 +481,8 @@ describe('Tao Move Stake Builder', function () {
479481
it('should handle explanation with zero tip', async function () {
480482
builder
481483
.amount('500000000')
482-
.originHotkey('5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT')
483-
.destinationHotkey('5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq')
484+
.originHotkey({ address: '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' })
485+
.destinationHotkey({ address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' })
484486
.originNetuid('1')
485487
.destinationNetuid('1')
486488
.sender({ address: sender.address })

0 commit comments

Comments
 (0)