Skip to content

Commit d7d606a

Browse files
committed
fix(sdk-coin-dot): update DOT sdk to latest
EA-1242
1 parent 80c504a commit d7d606a

File tree

8 files changed

+18184
-16495
lines changed

8 files changed

+18184
-16495
lines changed

modules/sdk-coin-dot/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
"dependencies": {
4343
"@bitgo/sdk-core": "^8.13.0",
4444
"@bitgo/statics": "^18.2.0",
45-
"@polkadot/api": "9.3.3",
46-
"@polkadot/keyring": "^10.1.8",
47-
"@polkadot/types": "9.3.3",
48-
"@polkadot/util": "^10.1.8",
49-
"@polkadot/util-crypto": "^10.1.8",
50-
"@substrate/txwrapper-core": "3.2.2",
51-
"@substrate/txwrapper-polkadot": "3.2.2",
45+
"@polkadot/api": "10.9.1",
46+
"@polkadot/keyring": "12.3.2",
47+
"@polkadot/types": "10.9.1",
48+
"@polkadot/util": "12.3.2",
49+
"@polkadot/util-crypto": "12.3.2",
50+
"@substrate/txwrapper-core": "7.0.1",
51+
"@substrate/txwrapper-polkadot": "7.0.1",
5252
"bignumber.js": "^9.0.0",
5353
"bs58": "^4.0.1",
5454
"hi-base32": "^0.5.1",

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,10 @@ export class BatchTransactionBuilder extends TransactionBuilder {
207207
return unsigned.method;
208208
}
209209

210-
private getBondCall(args: StakeBatchCallArgs): string {
210+
public getBondCall(args: StakeBatchCallArgs): string {
211211
const baseTxInfo = this.createBaseTxInfo();
212212
const unsigned = methods.staking.bond(
213213
{
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 || '',
216214
value: args.value,
217215
payee: this.getPayee(args.payee),
218216
},

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

Lines changed: 1 addition & 1 deletion
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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export abstract class NativeTransferBuilder extends TransactionBuilder {
3737
if (this._sweepFreeBalance) {
3838
transferTx = methods.balances.transferAll(
3939
{
40-
dest: this._to,
40+
dest: { id: this._to },
4141
keepAlive: this._keepAddressAlive,
4242
},
4343
baseTxInfo.baseTxInfo,
@@ -47,7 +47,7 @@ export abstract class NativeTransferBuilder extends TransactionBuilder {
4747
transferTx = methods.balances.transferKeepAlive(
4848
{
4949
value: this._amount,
50-
dest: this._to,
50+
dest: { id: this._to },
5151
},
5252
baseTxInfo.baseTxInfo,
5353
baseTxInfo.options

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export class StakingBuilder extends TransactionBuilder {
4141
return methods.staking.bond(
4242
{
4343
value: this._amount,
44-
controller: this._controller,
4544
payee: this._payee,
4645
},
4746
baseTxInfo.baseTxInfo,
@@ -117,7 +116,7 @@ export class StakingBuilder extends TransactionBuilder {
117116
if (decodedTxn.method?.name === MethodNames.Bond) {
118117
const txMethod = decodedTxn.method.args as unknown as StakeArgs;
119118
const value = txMethod.value;
120-
const controller = txMethod.controller?.id;
119+
const controller = txMethod.controller.id;
121120
const payee = txMethod.payee;
122121
const validationResult = StakeTransactionSchema.validate({ value, controller, payee });
123122
if (validationResult.error) {
@@ -141,7 +140,7 @@ export class StakingBuilder extends TransactionBuilder {
141140
this.amount(txMethod.value);
142141
this.owner({
143142
address: utils.decodeDotAddress(
144-
txMethod.controller?.id || '',
143+
txMethod.controller.id,
145144
utils.getAddressFormat(this._coinConfig.name as DotAssetTypes)
146145
),
147146
});

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,7 @@ 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(
220-
'hex'
221-
),
219+
pub: Buffer.from(decodeAddress(txMethod.controller.id, false, this._registry.chainSS58)).toString('hex'),
222220
});
223221

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

modules/sdk-coin-dot/test/unit/transactionBuilder/batchTransactionBuilder.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ describe('Dot Batch Transaction Builder', () => {
3939

4040
describe('signed', function () {
4141
it('should build a signed batch transaction', async () => {
42+
builder.getBondCall({
43+
value: '5',
44+
payee: { staked: null },
45+
});
4246
builder
4347
.calls(rawTx.pureProxy.batch)
4448
.sender({ address: sender.address })

yarn.lock

Lines changed: 18166 additions & 16476 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)