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 dca9bee commit fc7ed1e
Show file tree
Hide file tree
Showing 15 changed files with 2,834 additions and 2,864 deletions.
2 changes: 1 addition & 1 deletion modules/account-lib/resources/dot/westend.ts

Large diffs are not rendered by default.

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.15.0",
"@bitgo/statics": "^18.4.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
2 changes: 0 additions & 2 deletions modules/sdk-coin-dot/src/lib/batchTransactionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ export class BatchTransactionBuilder extends TransactionBuilder {
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
6 changes: 1 addition & 5 deletions modules/sdk-coin-dot/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,7 @@ export class Utils implements BaseUtils {
* @return true if arg is of type StakeBatchCallArgs, false otherwise.
*/
isStakeBatchCallArgs(arg: BatchCallObject['args']): arg is StakeBatchCallArgs {
return (
(arg as StakeBatchCallArgs).value !== undefined &&
(arg as StakeBatchCallArgs).controller !== undefined &&
(arg as StakeBatchCallArgs).payee !== undefined
);
return (arg as StakeBatchCallArgs).value !== undefined && (arg as StakeBatchCallArgs).payee !== undefined;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-dot/src/resources/westend.ts

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions modules/sdk-coin-dot/test/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const rawTx = {
signed:
'0xf102840061b18c6dc02ddcabdeac56cb4f21a971cc41cc97640f6f85b073480008c53a0d00aadae7fa1f53e7a5c900b330ff71bee6782cf3c29a2c6f9599162381cd021ad581c74ded89f49ec79adefed64af8ff16649553523dda9cb4f017cbf15681e50e3502000010020806000061b18c6dc02ddcabdeac56cb4f21a971cc41cc97640f6f85b073480008c53a0d070088526a74001601009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f02540200000000',
unsigned:
'0x550110020806000061b18c6dc02ddcabdeac56cb4f21a971cc41cc97640f6f85b073480008c53a0d070088526a74001601009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f0254020000000035020000682400000e000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e462ab5246361febb9294ffa41dd099edddec30a205ea15fbd247abb0ddbabd51',
'0x550110020806000061b18c6dc02ddcabdeac56cb4f21a971cc41cc97640f6f85b073480008c53a0d070088526a74001601009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f0254020000000035020000d624000016000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e462ab5246361febb9294ffa41dd099edddec30a205ea15fbd247abb0ddbabd51',
batch: [
'0x06000061b18c6dc02ddcabdeac56cb4f21a971cc41cc97640f6f85b073480008c53a0d070088526a7400',
'0x1601009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f02540200000000',
Expand All @@ -85,7 +85,7 @@ export const rawTx = {
signed:
'0xc501840061b18c6dc02ddcabdeac56cb4f21a971cc41cc97640f6f85b073480008c53a0d00aadae7fa1f53e7a5c900b330ff71bee6782cf3c29a2c6f9599162381cd021ad581c74ded89f49ec79adefed64af8ff16649553523dda9cb4f017cbf15681e50ed50121030006010bfadb9bbae251',
unsigned:
'0x2406010bfadb9bbae251d501210300682400000e000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e149799bc9602cb5cf201f3425fb8d253b2d4e61fc119dcab3249f307f594754d',
'0x2406010bfadb9bbae251d501210300d624000016000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e149799bc9602cb5cf201f3425fb8d253b2d4e61fc119dcab3249f307f594754d',
},
addProxy: {
signed:
Expand All @@ -111,28 +111,28 @@ export const rawTx = {
signed:
'0x1502840061b18c6dc02ddcabdeac56cb4f21a971cc41cc97640f6f85b073480008c53a0d0040ddb0cb7d290d14cd17f4d96f4261233d7add26505cb35bbbb93692467b88d31ba5e7d16fc8b3fd7a6e496d3c4a101dbc2a97f4ee81b2a16f4be672fdf1fd043502000010000c160400000000000000160400000000000100160400000000000200',
unsigned:
'0x7810000c16040000000000000016040000000000010016040000000000020035020000682400000e000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e462ab5246361febb9294ffa41dd099edddec30a205ea15fbd247abb0ddbabd51',
'0x7810000c16040000000000000016040000000000010016040000000000020035020000d624000016000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e462ab5246361febb9294ffa41dd099edddec30a205ea15fbd247abb0ddbabd51',
},
twoAddPureProxies: {
signed:
'0xf101840061b18c6dc02ddcabdeac56cb4f21a971cc41cc97640f6f85b073480008c53a0d00aadae7fa1f53e7a5c900b330ff71bee6782cf3c29a2c6f9599162381cd021ad581c74ded89f49ec79adefed64af8ff16649553523dda9cb4f017cbf15681e50e15030000100008160400000000000000160400000000000100',
unsigned:
'0x541000081604000000000000001604000000000001003502210300682400000e000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e462ab5246361febb9294ffa41dd099edddec30a205ea15fbd247abb0ddbabd51',
'0x541000081604000000000000001604000000000001003502210300d624000016000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e462ab5246361febb9294ffa41dd099edddec30a205ea15fbd247abb0ddbabd51',
},
},
batchAll: {
twoAddPureProxies: {
signed:
'0xf101840061b18c6dc02ddcabdeac56cb4f21a971cc41cc97640f6f85b073480008c53a0d00aadae7fa1f53e7a5c900b330ff71bee6782cf3c29a2c6f9599162381cd021ad581c74ded89f49ec79adefed64af8ff16649553523dda9cb4f017cbf15681e50e15030000100208160400000000000000160400000000000100',
unsigned:
'0x541002081604000000000000001604000000000001003502210300682400000e000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e462ab5246361febb9294ffa41dd099edddec30a205ea15fbd247abb0ddbabd51',
'0x541002081604000000000000001604000000000001003502210300d624000016000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e462ab5246361febb9294ffa41dd099edddec30a205ea15fbd247abb0ddbabd51',
},
},
proxy: {
signed:
'0xdd028400d472bd6e0f1f92297631938e30edb682208c2cd2698d80cf678c53a69979eb9f00aadae7fa1f53e7a5c900b330ff71bee6782cf3c29a2c6f9599162381cd021ad581c74ded89f49ec79adefed64af8ff16649553523dda9cb4f017cbf15681e50ed50121030016000061b18c6dc02ddcabdeac56cb4f21a971cc41cc97640f6f85b073480008c53a0d01000403009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f02540bfadb9bbae251',
unsigned:
'0x3d0116000061b18c6dc02ddcabdeac56cb4f21a971cc41cc97640f6f85b073480008c53a0d01000403009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f02540bfadb9bbae251d501210300682400000e000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e149799bc9602cb5cf201f3425fb8d253b2d4e61fc119dcab3249f307f594754d',
'0x3d0116000061b18c6dc02ddcabdeac56cb4f21a971cc41cc97640f6f85b073480008c53a0d01000403009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f02540bfadb9bbae251d501210300d624000016000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e149799bc9602cb5cf201f3425fb8d253b2d4e61fc119dcab3249f307f594754d',
transferCall: '0x0503009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f02540bfadb9bbae251',
},
unstake: {
Expand All @@ -144,7 +144,7 @@ export const rawTx = {
signed:
'0x7102840061b18c6dc02ddcabdeac56cb4f21a971cc41cc97640f6f85b073480008c53a0d00aadae7fa1f53e7a5c900b330ff71bee6782cf3c29a2c6f9599162381cd021ad581c74ded89f49ec79adefed64af8ff16649553523dda9cb4f017cbf15681e50e3502000010020c1602009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f0254020000000006060602070088526a74',
unsigned:
'0xd410020c1602009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f0254020000000006060602070088526a7435020000682400000e000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e462ab5246361febb9294ffa41dd099edddec30a205ea15fbd247abb0ddbabd51',
'0xd410020c1602009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f0254020000000006060602070088526a7435020000d624000016000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e462ab5246361febb9294ffa41dd099edddec30a205ea15fbd247abb0ddbabd51',
batch: [
'0x1602009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f02540200000000',
'0x0606',
Expand Down
6 changes: 3 additions & 3 deletions modules/sdk-coin-dot/test/resources/materialData.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/sdk-coin-dot/test/resources/testnet.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/sdk-coin-dot/test/unit/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('utils', () => {
);
should.equal(
txHex,
'0xb9018400000000000000000000000000000000000000000000000000000000000000000000b6d868a11d202b56df1959f5d5f81f44ce1f95c8e70424b17080ea869d1c39d453f16c38fbef600a636c9a62a49ede5ee695a1822faf2f94fcfbb184a4254009d501210300000000000000'
'0xad018400000000000000000000000000000000000000000000000000000000000000000000b6d868a11d202b56df1959f5d5f81f44ce1f95c8e70424b17080ea869d1c39d453f16c38fbef600a636c9a62a49ede5ee695a1822faf2f94fcfbb184a4254009d501210300000000'
);
});
});
4 changes: 2 additions & 2 deletions modules/statics/src/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ class PolkadotTestnet extends Testnet implements DotNetwork {
explorerUrl = 'https://westend.subscan.io/extrinsic/';
specName = 'westend' as PolkadotSpecNameType;
genesisHash = '0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e';
specVersion = 9320;
specVersion = 9430;
chainName = 'Westend';
txVersion = 14;
txVersion = 22;
}

class Celo extends Mainnet implements EthereumNetwork {
Expand Down
Loading

0 comments on commit fc7ed1e

Please sign in to comment.