Skip to content

Commit 27782d0

Browse files
committed
fix(sdk-coin-dot): make controller optional for bond call
EA-1060 EA-1176
1 parent 902558a commit 27782d0

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

modules/sdk-coin-dot/src/lib/batchTransactionBuilder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ export class BatchTransactionBuilder extends TransactionBuilder {
211211
const baseTxInfo = this.createBaseTxInfo();
212212
const unsigned = methods.staking.bond(
213213
{
214-
controller: args.controller.id,
214+
// TODO(EA-1242): update DOT library to remove controller optional field -> https://github.com/paritytech/txwrapper-core/pull/309 and https://github.com/paritytech/substrate/pull/14039
215+
controller: args.controller?.id || '',
215216
value: args.value,
216217
payee: this.getPayee(args.payee),
217218
},

modules/sdk-coin-dot/src/lib/iface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export type StakeArgsPayeeRaw = { controller?: null; stash?: null; staked?: null
179179
*/
180180
export interface StakeArgs {
181181
value: string;
182-
controller: { id: string };
182+
controller?: { id: string };
183183
payee: StakeArgsPayee;
184184
}
185185

@@ -275,7 +275,7 @@ export type StakeBatchCallPayee =
275275

276276
export interface StakeBatchCallArgs {
277277
value: string;
278-
controller: { id: string };
278+
controller?: { id: string };
279279
payee: StakeBatchCallPayee;
280280
}
281281

modules/sdk-coin-dot/src/lib/stakingBuilder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export class StakingBuilder extends TransactionBuilder {
125125
if (decodedTxn.method?.name === MethodNames.Bond) {
126126
const txMethod = decodedTxn.method.args as unknown as StakeArgs;
127127
const value = txMethod.value;
128-
const controller = txMethod.controller.id;
128+
const controller = txMethod.controller?.id;
129129
const payee = txMethod.payee;
130130
const validationResult = StakeTransactionSchema.validate({ value, controller, payee });
131131
if (validationResult.error) {
@@ -150,7 +150,7 @@ export class StakingBuilder extends TransactionBuilder {
150150
console.log('[Dot staking debug] calling owner: ', JSON.stringify(txMethod));
151151
this.owner({
152152
address: utils.decodeDotAddress(
153-
txMethod.controller.id,
153+
txMethod.controller?.id || '',
154154
utils.getAddressFormat(this._coinConfig.name as DotAssetTypes)
155155
),
156156
});

modules/sdk-coin-dot/src/lib/transaction.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ export class Transaction extends BaseTransaction {
216216
const txMethod = decodedTx.method.args;
217217
if (utils.isBond(txMethod)) {
218218
const keypair = new KeyPair({
219-
pub: Buffer.from(decodeAddress(txMethod.controller.id, false, this._registry.chainSS58)).toString('hex'),
219+
pub: Buffer.from(decodeAddress(txMethod.controller?.id || '', false, this._registry.chainSS58)).toString(
220+
'hex'
221+
),
220222
});
221223

222224
result.controller = keypair.getAddress(utils.getAddressFormat(this._coinConfig.name as DotAssetTypes));

modules/sdk-coin-dot/src/lib/txnSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const TransferAllTransactionSchema = joi.object({
5252

5353
const CreateStakeTransactionSchema = joi.object({
5454
value: joi.string().required(),
55-
controller: addressSchema.required(),
55+
controller: joi.string().optional(),
5656
payee: [
5757
joi.string(),
5858
joi.object({

0 commit comments

Comments
 (0)