From 89c2cac977b4b4c506567bfdee4d8e689ef8efe4 Mon Sep 17 00:00:00 2001 From: tarikgul Date: Mon, 16 Oct 2023 13:00:45 -0400 Subject: [PATCH] Add setClaimPermission --- .../src/methods/nominationPools/index.ts | 2 + .../setClaimPermission.spec.ts | 22 +++++++++ .../nominationPools/setClaimPermission.ts | 46 +++++++++++++++++++ .../src/test-helpers/TEST_METHOD_ARGS.ts | 3 ++ 4 files changed, 73 insertions(+) create mode 100644 packages/txwrapper-substrate/src/methods/nominationPools/setClaimPermission.spec.ts create mode 100644 packages/txwrapper-substrate/src/methods/nominationPools/setClaimPermission.ts diff --git a/packages/txwrapper-substrate/src/methods/nominationPools/index.ts b/packages/txwrapper-substrate/src/methods/nominationPools/index.ts index e5a11246..c40db7ab 100644 --- a/packages/txwrapper-substrate/src/methods/nominationPools/index.ts +++ b/packages/txwrapper-substrate/src/methods/nominationPools/index.ts @@ -1,4 +1,5 @@ export * from './bondExtra'; +export * from './bondExtraOther'; export * from './chill'; export * from './claimPayout'; export * from './create'; @@ -6,6 +7,7 @@ export * from './createWithPoolId'; export * from './join'; export * from './nominate'; export * from './poolWithdrawUnbonded'; +export * from './setClaimPermission'; export * from './setConfigs'; export * from './setMetadata'; export * from './setState'; diff --git a/packages/txwrapper-substrate/src/methods/nominationPools/setClaimPermission.spec.ts b/packages/txwrapper-substrate/src/methods/nominationPools/setClaimPermission.spec.ts new file mode 100644 index 00000000..f9138474 --- /dev/null +++ b/packages/txwrapper-substrate/src/methods/nominationPools/setClaimPermission.spec.ts @@ -0,0 +1,22 @@ +import { + itHasCorrectBaseTxInfo, + KUSAMA_TEST_OPTIONS, + TEST_BASE_TX_INFO, +} from '@substrate/txwrapper-dev'; + +import { TEST_METHOD_ARGS } from '../../test-helpers'; +import { setClaimPermission } from './setClaimPermission'; + +describe('nominationPools::setClaimPermission', () => { + it('should work', () => { + const unsigned = setClaimPermission( + TEST_METHOD_ARGS.nominationPools.setClaimPermission, + TEST_BASE_TX_INFO, + KUSAMA_TEST_OPTIONS + ); + + itHasCorrectBaseTxInfo(unsigned); + + expect(unsigned.method).toBe('0x290f00'); + }); +}); diff --git a/packages/txwrapper-substrate/src/methods/nominationPools/setClaimPermission.ts b/packages/txwrapper-substrate/src/methods/nominationPools/setClaimPermission.ts new file mode 100644 index 00000000..971b0cde --- /dev/null +++ b/packages/txwrapper-substrate/src/methods/nominationPools/setClaimPermission.ts @@ -0,0 +1,46 @@ +import { + Args, + BaseTxInfo, + defineMethod, + OptionsWithMeta, + UnsignedTransaction, +} from '@substrate/txwrapper-core'; + +export interface NominationPoolsSetClaimPermission extends Args { + /** + * Account to claim reward. The value will either be: + * `Permissioned` | `PermissionlessCompound` | `PermissionlessWithdraw` | `PermissionlessAll` + */ + permission: string; +} + +/** + * Allows a pool member to set a claim permission to allow or disallow permissionless + * bonding and withdrawing. + * + * By default, this is `Permissioned`, which implies only the pool member themselves can + * claim their pending rewards. If a pool member wishes so, they can set this to + * `PermissionlessAll` to allow any account to claim their rewards and bond extra to the + * pool. + * + * @param args - Arguments specific to this method. + * @param info - Information required to construct the transaction. + * @param options - Registry and metadata used for constructing the method. + */ +export function setClaimPermission( + args: NominationPoolsSetClaimPermission, + info: BaseTxInfo, + options: OptionsWithMeta +): UnsignedTransaction { + return defineMethod( + { + method: { + args, + name: 'setClaimPermission', + pallet: 'nominationPools', + }, + ...info, + }, + options + ); +} diff --git a/packages/txwrapper-substrate/src/test-helpers/TEST_METHOD_ARGS.ts b/packages/txwrapper-substrate/src/test-helpers/TEST_METHOD_ARGS.ts index 04dd2b37..06dee95e 100644 --- a/packages/txwrapper-substrate/src/test-helpers/TEST_METHOD_ARGS.ts +++ b/packages/txwrapper-substrate/src/test-helpers/TEST_METHOD_ARGS.ts @@ -244,6 +244,9 @@ export const TEST_METHOD_ARGS = { poolId: 1, numSlashingSpans: 2, }, + setClaimPermission: { + permission: 'Permissioned', + }, setConfigs: { minJoinBond: { Set: '1000000' }, minCreateBond: { Set: '1000000' },