Neo dAPI

Neo dAPI describes the Signer type below:

export interface Signer {
  account: string;
  scopes: UnionConcat<SignerScope, ",">;
  allowedContracts?: string[];
  allowedGroups?: string[];
  rules?: WitnessRule[];
}

Neoline (Chrome Extension)

Neoline uses the SignerLike like from neon-js

export interface SignerLike {
  /* account scripthash in big endian */
  account: string | HexString;
  scopes: number | string | WitnessScope;
  allowedContracts?: (string | HexString)[];
  allowedGroups?: (string | HexString)[];
  rules?: WitnessRuleJson[];
}

Neon Wallet

Note: Neon wallet version 2.18.1 and below uses an older version of neo3-invoker and does not support WitnessRules.

Neon wallet 2.19.0 and above uses neo3-invoker and accepts signers with the type below.

export type Signer = {
  /**
   * The level of permission the invocation needs
   */
  scopes: string | number;
  /**
   * An optional scriptHash to be used to sign, if no account is provided the user selected account will be used
   */
  account?: string;
  /**
   * When the scopes is `WitnessScope.CustomContracts`, you need to specify which contracts are allowed
   */
  allowedContracts?: string[];
  /**
   * When the scopes is `WitnessScope.CustomGroups`, you need to specify which groups are allowed
   */
  allowedGroups?: string[];

  rules?: WitnessRule[];
};

Tracing Neon wallet invocations (2.19.2)

Screen where user approves the transaction request.

119: const { result } = await approveRequest(request)

approveRequest method

311: public async approveRequest(request: TSessionRequest): Promise<TRequestResult> {

approveRequest method gets result from adapterMethod

328: const result = await adapterMethod.apply(this.adapter, [{ request, session }])

adapterMethod is a method from this.adapter 323: const adapterMethod = this.adapter[method] as (params: TAdapterMethodParam) => Promise<any>

this.adapter refers to AbstractWalletConnectNeonAdapter

44: public adapter: AbstractWalletConnectNeonAdapter | undefined

15: export abstract class AbstractWalletConnectNeonAdapter {

Assume we are calling invokeFunction method for our transaction

  async invokeFunction(args: TAdapterMethodParam): Promise<string> {
    const { invoker } = await this.getServices(args)
    const params = this.convertParams(args)
    return await invoker.invokeFunction(params)
  }

invoker refers to NeonInvoker

import { NeonInvoker } from '@cityofzion/neon-invoker'
...
    const invoker = await NeonInvoker.init({
      rpcAddress,
      account,
      signingCallback,
    })

NeonInvoker’s invokeFunction accepts ContractInvocationMulti

  async invokeFunction(cim: ContractInvocationMulti): Promise<string> {
    const accountArr = this.normalizeAccountArray(this.options.account)

    const script = NeonInvoker.buildScriptBuilder(cim)

    const rpcClient = new rpc.RPCClient(this.options.rpcAddress)
    const currentHeight = await rpcClient.getBlockCount()

    let trx = new tx.Transaction({
      script: u.HexString.fromHex(script),
      validUntilBlock: currentHeight + this.options.validBlocks,
      signers: NeonInvoker.buildMultipleSigner(accountArr, cim.signers),
    })

ContractInvocationMulti

export type ContractInvocationMulti = {
  /**
   * the signing options
   */
  signers?: Signer[]

And Signer clearly supports Witness Rules.

export type Signer = {
  /**
   * The level of permission the invocation needs
   */
  scopes: string | number;
  /**
   * An optional scriptHash to be used to sign, if no account is provided the user selected account will be used
   */
  account?: string;
  /**
   * When the scopes is `WitnessScope.CustomContracts`, you need to specify which contracts are allowed
   */
  allowedContracts?: string[];
  /**
   * When the scopes is `WitnessScope.CustomGroups`, you need to specify which groups are allowed
   */
  allowedGroups?: string[];

  rules?: WitnessRule[];
};