Skip to content

Commit

Permalink
Merge pull request #5606 from BitGo/add-common-types-for-tao
Browse files Browse the repository at this point in the history
feat(abstract-substrate): add common types/methods for TAO to abstract-substrate
  • Loading branch information
Vijay-Jagannathan authored Feb 21, 2025
2 parents 9829594 + 6298a42 commit 4785f16
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
17 changes: 16 additions & 1 deletion modules/abstract-substrate/src/lib/iface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
TransactionType,
} from '@bitgo/sdk-core';
import { BaseTxInfo, DecodedUnsignedTx, TypeRegistry } from '@substrate/txwrapper-core/lib/types';
import { Args } from '@substrate/txwrapper-core/lib/types/method';

export { HexString } from '@polkadot/util/types';

Expand All @@ -30,6 +31,8 @@ export enum MethodNames {
* @see https://polkadot.js.org/docs/substrate/extrinsics/#transferkeepalivedest-multiaddress-value-compactu128
*/
TransferKeepAlive = 'transferKeepAlive',
AddStake = 'addStake',
RemoveStake = 'removeStake',
}

/**
Expand Down Expand Up @@ -71,11 +74,23 @@ export interface TransferAllArgs {
keepAlive: boolean;
}

export interface AddStakeArgs extends Args {
amountStaked: number;
hotkey: string;
netuid: number;
}

export interface RemoveStakeArgs extends Args {
amountUnstaked: number;
hotkey: string;
netuid: number;
}

/**
* Decoded TxMethod from a transaction hex
*/
export interface TxMethod {
args: TransferArgs | TransferAllArgs;
args: TransferArgs | TransferAllArgs | AddStakeArgs | RemoveStakeArgs;
name: MethodNames;
pallet: string;
}
Expand Down
3 changes: 2 additions & 1 deletion modules/abstract-substrate/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as Constants from './constants';
import * as Errors from './errors';
import * as Interface from './iface';
import * as Schema from './txnSchema';
export { Utils, default as utils } from './utils';

export { KeyPair } from './keyPair';
export { SingletonRegistry } from './singletonRegistry';
export { Transaction } from './transaction';
export { TransactionBuilder } from './transactionBuilder';
export { TransferBuilder } from './transferBuilder';
export { Constants, Errors, Interface };
export { Constants, Errors, Interface, Schema };
12 changes: 12 additions & 0 deletions modules/abstract-substrate/src/lib/txnSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,15 @@ export const TransferTransactionSchema = joi.object({
export const TransferAllTransactionSchema = joi.object({
to: addressSchema.required(),
});

export const StakeTransactionSchema = joi.object({
amountStaked: joi.number().required(),
hotkey: joi.string().required(),
netuid: joi.number().required(),
});

export const UnstakeTransactionSchema = joi.object({
amountUnstaked: joi.number().required(),
hotkey: joi.string().required(),
netuid: joi.number().required(),
});

0 comments on commit 4785f16

Please sign in to comment.