Skip to content

Commit

Permalink
fix: minor fixes
Browse files Browse the repository at this point in the history
TICKET: WIN-4296
  • Loading branch information
yash-bitgo committed Jan 28, 2025
1 parent 895d938 commit 90aa8aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 41 deletions.
42 changes: 2 additions & 40 deletions modules/abstract-substrate/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { DotAssetTypes, BaseUtils, DotAddressFormat, isBase58, isValidEd25519PublicKey, Seed } from '@bitgo/sdk-core';
import { decodeAddress, encodeAddress, Keyring } from '@polkadot/keyring';
import { decodePair } from '@polkadot/keyring/pair/decode';
import { decodeAddress, encodeAddress } from '@polkadot/keyring';
import { KeyringPair } from '@polkadot/keyring/types';
import { createTypeUnsafe, GenericCall, GenericExtrinsic, GenericExtrinsicPayload } from '@polkadot/types';
import { EXTRINSIC_VERSION } from '@polkadot/types/extrinsic/v4/Extrinsic';
import { hexToU8a, isHex, u8aToHex, u8aToU8a } from '@polkadot/util';
import { base64Decode, signatureVerify } from '@polkadot/util-crypto';
import { signatureVerify } from '@polkadot/util-crypto';
import { Args, BaseTxInfo, defineMethod, OptionsWithMeta, UnsignedTransaction } from '@substrate/txwrapper-core';
import { DecodedSignedTx, DecodedSigningPayload, TypeRegistry } from '@substrate/txwrapper-core/lib/types';
import { construct } from '@substrate/txwrapper-polkadot';
Expand All @@ -29,7 +28,6 @@ import {
TxMethod,
UnstakeBatchCallArgs,
} from './iface';
import { KeyPair } from '.';

const PROXY_METHOD_ARG = 2;
// map to retrieve the address encoding format when the key is the asset name
Expand Down Expand Up @@ -160,19 +158,6 @@ export class Utils implements BaseUtils {
return decodedArgs.args;
}

/**
* keyPairFromSeed generates an object with secretKey and publicKey using the substrate sdk
* @param seed 32 bytes long seed
* @returns KeyPair
*/
keyPairFromSeed(seed: Uint8Array): KeyPair {
const keyring = new Keyring({ type: 'ed25519' });
const keyringPair = keyring.addFromSeed(seed);
const pairJson = keyringPair.toJson();
const decodedKeyPair = decodePair('', base64Decode(pairJson.encoded), pairJson.encoding.type);
return new KeyPair({ prv: Buffer.from(decodedKeyPair.secretKey).toString('hex') });
}

/**
* Signing function. Implement this on the OFFLINE signing device.
*
Expand Down Expand Up @@ -216,18 +201,6 @@ export class Utils implements BaseUtils {
});
}

/**
* Decodes the substrate address from the given format
*
* @param {string} address
* @param {number} [ss58Format]
* @returns {string}
*/
decodeSubstrateAddress(address: string, ss58Format: number): string {
const keypair = new KeyPair({ pub: Buffer.from(decodeAddress(address, undefined, ss58Format)).toString('hex') });
return keypair.getAddress(ss58Format);
}

/**
* Decodes the substrate address from the given format
*
Expand Down Expand Up @@ -424,17 +397,6 @@ export class Utils implements BaseUtils {
return signature;
}

/**
* Decodes the dot address from the given format
*
* @param {string} address
* @param {number} [ss58Format]
* @returns {KeyPair}
*/
decodeSubstrateAddressToKeyPair(address: string, ss58Format?: number): KeyPair {
return new KeyPair({ pub: Buffer.from(decodeAddress(address, undefined, ss58Format)).toString('hex') });
}

/**
* Checks whether the given input is a hex string with with 0 value
* used to check whether a given transaction is immortal or mortal
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-tao/src/tao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
VerifyTransactionOptions,
} from '@bitgo/sdk-core';
import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics';
import { SubstrateCoin, Utils } from '@bitgo/abstract-substrate';
import { Interface, SubstrateCoin, Utils } from '@bitgo/abstract-substrate';
import { TaoKeyPair } from './lib';

const utils = Utils.default;
Expand Down

0 comments on commit 90aa8aa

Please sign in to comment.