• createVincentAbilityPolicy() is used to bind a policy to a specific ability. You must provide a abilityParameterMappings argument which instructs the ability which of its abilityParams should be passed to the Vincent Policy during evaluation, and defines what the argument passed to the ability should be.

    For example, a Ability might receive an argument called tokenInAmount, but it may need to pass that as buyAmount to a policy that uses the tokenInAmount for its own purposes.

    import { bundledVincentPolicy } from '@lit-protocol/vincent-policy-spending-limit';

    const SpendingLimitPolicy = createVincentAbilityPolicy({
    abilityParamsSchema,
    bundledVincentPolicy,
    abilityParameterMappings: {
    rpcUrlForUniswap: 'rpcUrlForUniswap',
    chainIdForUniswap: 'chainIdForUniswap',
    ethRpcUrl: 'ethRpcUrl',
    tokenInAddress: 'tokenAddress',
    tokenInDecimals: 'tokenDecimals',
    tokenInAmount: 'buyAmount',
    },
    });

    Type Parameters

    • const VincentAbilityApiVersion extends string

    Parameters

    • config: {
          abilityParamsSchema: AbilityParamsSchema;
          bundledVincentPolicy: BundledVincentPolicy<
              {
                  packageName: PackageName;
                  abilityParamsSchema: PolicyAbilityParams;
                  userParamsSchema?: UserParams;
                  precheckAllowResultSchema?: PrecheckAllowResult;
                  precheckDenyResultSchema?: PrecheckDenyResult;
                  evalAllowResultSchema?: EvalAllowResult;
                  evalDenyResultSchema?: EvalDenyResult;
                  commitParamsSchema?: CommitParams;
                  commitAllowResultSchema?: CommitAllowResult;
                  commitDenyResultSchema?: CommitDenyResult;
                  evaluate: PolicyLifecycleFunction;
                  precheck?: PolicyLifecycleFunction<
                      PolicyAbilityParams,
                      UserParams,
                      PrecheckAllowResult,
                      PrecheckDenyResult,
                  >;
                  commit?: CommitLifecycleFunction<
                      CommitParams,
                      CommitAllowResult,
                      CommitDenyResult,
                  >;
              },
              IpfsCid,
              VincentAbilityApiVersion,
          >;
          abilityParameterMappings: Partial<
              { [K in string
              | number
              | symbol]: keyof TypeOf<PolicyAbilityParams> },
          >;
      }

    Returns {
        vincentPolicy: {
            packageName: PackageName;
            abilityParamsSchema: PolicyAbilityParams;
            userParamsSchema?: UserParams;
            precheckAllowResultSchema?: PrecheckAllowResult;
            precheckDenyResultSchema?: PrecheckDenyResult;
            evalAllowResultSchema?: EvalAllowResult;
            evalDenyResultSchema?: EvalDenyResult;
            commitParamsSchema?: CommitParams;
            commitAllowResultSchema?: CommitAllowResult;
            commitDenyResultSchema?: CommitDenyResult;
            evaluate: PolicyLifecycleFunction;
            precheck?: PolicyLifecycleFunction<
                PolicyAbilityParams,
                UserParams,
                PrecheckAllowResult,
                PrecheckDenyResult,
            >;
            commit?: CommitLifecycleFunction<
                CommitParams,
                CommitAllowResult,
                CommitDenyResult,
            >;
        };
        ipfsCid: IpfsCid;
        abilityParameterMappings: Partial<
            { [K in string
            | number
            | symbol]: keyof TypeOf<PolicyAbilityParams> },
        >;
    }

    A Vincent Policy that is configured to work with the provided ability {@displayType A Vincent Policy that is configured to work with the provided ability}