Skip to content

Commit

Permalink
fix(sdk-coin-dot): update DOT sdk to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
noel-bitgo committed Aug 17, 2023
1 parent 80c504a commit d7d606a
Show file tree
Hide file tree
Showing 8 changed files with 18,184 additions and 16,495 deletions.
14 changes: 7 additions & 7 deletions modules/sdk-coin-dot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
"dependencies": {
"@bitgo/sdk-core": "^8.13.0",
"@bitgo/statics": "^18.2.0",
"@polkadot/api": "9.3.3",
"@polkadot/keyring": "^10.1.8",
"@polkadot/types": "9.3.3",
"@polkadot/util": "^10.1.8",
"@polkadot/util-crypto": "^10.1.8",
"@substrate/txwrapper-core": "3.2.2",
"@substrate/txwrapper-polkadot": "3.2.2",
"@polkadot/api": "10.9.1",
"@polkadot/keyring": "12.3.2",
"@polkadot/types": "10.9.1",
"@polkadot/util": "12.3.2",
"@polkadot/util-crypto": "12.3.2",
"@substrate/txwrapper-core": "7.0.1",
"@substrate/txwrapper-polkadot": "7.0.1",
"bignumber.js": "^9.0.0",
"bs58": "^4.0.1",
"hi-base32": "^0.5.1",
Expand Down
4 changes: 1 addition & 3 deletions modules/sdk-coin-dot/src/lib/batchTransactionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,10 @@ export class BatchTransactionBuilder extends TransactionBuilder {
return unsigned.method;
}

private getBondCall(args: StakeBatchCallArgs): string {
public getBondCall(args: StakeBatchCallArgs): string {
const baseTxInfo = this.createBaseTxInfo();
const unsigned = methods.staking.bond(
{
// 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
controller: args.controller?.id || '',
value: args.value,
payee: this.getPayee(args.payee),
},
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-dot/src/lib/iface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export type StakeArgsPayeeRaw = { controller?: null; stash?: null; staked?: null
*/
export interface StakeArgs {
value: string;
controller?: { id: string };
controller: { id: string };
payee: StakeArgsPayee;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/sdk-coin-dot/src/lib/nativeTransferBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export abstract class NativeTransferBuilder extends TransactionBuilder {
if (this._sweepFreeBalance) {
transferTx = methods.balances.transferAll(
{
dest: this._to,
dest: { id: this._to },
keepAlive: this._keepAddressAlive,
},
baseTxInfo.baseTxInfo,
Expand All @@ -47,7 +47,7 @@ export abstract class NativeTransferBuilder extends TransactionBuilder {
transferTx = methods.balances.transferKeepAlive(
{
value: this._amount,
dest: this._to,
dest: { id: this._to },
},
baseTxInfo.baseTxInfo,
baseTxInfo.options
Expand Down
5 changes: 2 additions & 3 deletions modules/sdk-coin-dot/src/lib/stakingBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class StakingBuilder extends TransactionBuilder {
return methods.staking.bond(
{
value: this._amount,
controller: this._controller,
payee: this._payee,
},
baseTxInfo.baseTxInfo,
Expand Down Expand Up @@ -117,7 +116,7 @@ export class StakingBuilder extends TransactionBuilder {
if (decodedTxn.method?.name === MethodNames.Bond) {
const txMethod = decodedTxn.method.args as unknown as StakeArgs;
const value = txMethod.value;
const controller = txMethod.controller?.id;
const controller = txMethod.controller.id;
const payee = txMethod.payee;
const validationResult = StakeTransactionSchema.validate({ value, controller, payee });
if (validationResult.error) {
Expand All @@ -141,7 +140,7 @@ export class StakingBuilder extends TransactionBuilder {
this.amount(txMethod.value);
this.owner({
address: utils.decodeDotAddress(
txMethod.controller?.id || '',
txMethod.controller.id,
utils.getAddressFormat(this._coinConfig.name as DotAssetTypes)
),
});
Expand Down
4 changes: 1 addition & 3 deletions modules/sdk-coin-dot/src/lib/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,7 @@ export class Transaction extends BaseTransaction {
const txMethod = decodedTx.method.args;
if (utils.isBond(txMethod)) {
const keypair = new KeyPair({
pub: Buffer.from(decodeAddress(txMethod.controller?.id || '', false, this._registry.chainSS58)).toString(
'hex'
),
pub: Buffer.from(decodeAddress(txMethod.controller.id, false, this._registry.chainSS58)).toString('hex'),
});

result.controller = keypair.getAddress(utils.getAddressFormat(this._coinConfig.name as DotAssetTypes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ describe('Dot Batch Transaction Builder', () => {

describe('signed', function () {
it('should build a signed batch transaction', async () => {
builder.getBondCall({
value: '5',
payee: { staked: null },
});
builder
.calls(rawTx.pureProxy.batch)
.sender({ address: sender.address })
Expand Down
34,642 changes: 18,166 additions & 16,476 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit d7d606a

Please sign in to comment.