The 'wallet_invokeSnap' RPC request handlers

Should always return a promise as this is on the metamask side

interface FilSnapMethods {
    fil_configure: (
        ctx: SnapContext,
        params: Partial<
            {
                derivationPath: string;
                network: "mainnet"
                | "testnet";
                rpc: { token: string; url: string };
                unit?: { decimals: number; symbol: "FIL" | "tFIL" };
            },
        >,
    ) => Promise<ConfigureResponse>;
    fil_exportPrivateKey: (
        ctx: SnapContext,
    ) => Promise<ExportPrivateKeyResponse>;
    fil_getAccountInfo: (
        ctx: SnapContext,
    ) => Promise<Jsonify<GetAccountInfoResponse>>;
    fil_getAddress: (snap: SnapsProvider) => Promise<GetAddressResponse>;
    fil_getBalance: (ctx: SnapContext) => Promise<GetBalanceResponse>;
    fil_getGasForMessage: (
        ctx: SnapContext,
        params: {
            maxFee?: string;
            message: {
                gasFeeCap?: string;
                gasLimit?: number;
                gasPremium?: string;
                method?: number;
                nonce?: number;
                params?: string;
                to: string;
                value: string;
                version?: 0;
            };
        },
    ) => Promise<Jsonify<GasForMessageResponse>>;
    fil_getPublicKey: (snap: SnapsProvider) => Promise<GetPublicResponse>;
    fil_sendMessage: (
        ctx: SnapContext,
        params: {
            message: {
                from: string;
                gasFeeCap: string;
                gasLimit: number;
                gasPremium: string;
                method: number;
                nonce: number;
                params: string;
                to: string;
                value: string;
                version: 0;
            };
            signature: { data: string; type: "SECP256K1" };
        },
    ) => Promise<SendMessageResponse>;
    fil_signMessage: (
        ctx: SnapContext,
        params: {
            gasFeeCap?: string;
            gasLimit?: number;
            gasPremium?: string;
            method?: number;
            nonce?: number;
            params?: string;
            to: string;
            value: string;
            version?: 0;
        },
    ) => Promise<SignMessageResponse>;
    fil_signMessageRaw: (
        ctx: SnapContext,
        params: { message: string },
    ) => Promise<SignMessageRawResponse>;
}

Properties

fil_configure: (
    ctx: SnapContext,
    params: Partial<
        {
            derivationPath: string;
            network: "mainnet"
            | "testnet";
            rpc: { token: string; url: string };
            unit?: { decimals: number; symbol: "FIL" | "tFIL" };
        },
    >,
) => Promise<ConfigureResponse>

Type declaration

    • (
          ctx: SnapContext,
          params: Partial<
              {
                  derivationPath: string;
                  network: "mainnet"
                  | "testnet";
                  rpc: { token: string; url: string };
                  unit?: { decimals: number; symbol: "FIL" | "tFIL" };
              },
          >,
      ): Promise<ConfigureResponse>
    • Configures the snap with the provided configuration

      Parameters

      • ctx: SnapContext

        Snap context

      • params: Partial<
            {
                derivationPath: string;
                network: "mainnet"
                | "testnet";
                rpc: { token: string; url: string };
                unit?: { decimals: number; symbol: "FIL" | "tFIL" };
            },
        >

        overrides for the default configuration

      Returns Promise<ConfigureResponse>

fil_exportPrivateKey: (ctx: SnapContext) => Promise<ExportPrivateKeyResponse>

Type declaration

fil_getAccountInfo: (
    ctx: SnapContext,
) => Promise<Jsonify<GetAccountInfoResponse>>

Type declaration

fil_getAddress: (snap: SnapsProvider) => Promise<GetAddressResponse>
fil_getBalance: (ctx: SnapContext) => Promise<GetBalanceResponse>

Type declaration

fil_getGasForMessage: (
    ctx: SnapContext,
    params: {
        maxFee?: string;
        message: {
            gasFeeCap?: string;
            gasLimit?: number;
            gasPremium?: string;
            method?: number;
            nonce?: number;
            params?: string;
            to: string;
            value: string;
            version?: 0;
        };
    },
) => Promise<Jsonify<GasForMessageResponse>>

Type declaration

    • (
          ctx: SnapContext,
          params: {
              maxFee?: string;
              message: {
                  gasFeeCap?: string;
                  gasLimit?: number;
                  gasPremium?: string;
                  method?: number;
                  nonce?: number;
                  params?: string;
                  to: string;
                  value: string;
                  version?: 0;
              };
          },
      ): Promise<Jsonify<GasForMessageResponse>>
    • Get the gas estimate for a message

      Parameters

      • ctx: SnapContext

        Snap context

      • params: {
            maxFee?: string;
            message: {
                gasFeeCap?: string;
                gasLimit?: number;
                gasPremium?: string;
                method?: number;
                nonce?: number;
                params?: string;
                to: string;
                value: string;
                version?: 0;
            };
        }

        Estimate params

      Returns Promise<Jsonify<GasForMessageResponse>>

fil_getPublicKey: (snap: SnapsProvider) => Promise<GetPublicResponse>
fil_sendMessage: (
    ctx: SnapContext,
    params: {
        message: {
            from: string;
            gasFeeCap: string;
            gasLimit: number;
            gasPremium: string;
            method: number;
            nonce: number;
            params: string;
            to: string;
            value: string;
            version: 0;
        };
        signature: { data: string; type: "SECP256K1" };
    },
) => Promise<SendMessageResponse>

Type declaration

    • (
          ctx: SnapContext,
          params: {
              message: {
                  from: string;
                  gasFeeCap: string;
                  gasLimit: number;
                  gasPremium: string;
                  method: number;
                  nonce: number;
                  params: string;
                  to: string;
                  value: string;
                  version: 0;
              };
              signature: { data: string; type: "SECP256K1" };
          },
      ): Promise<SendMessageResponse>
    • Send a message to the network

      Parameters

      • ctx: SnapContext

        Snap context

      • params: {
            message: {
                from: string;
                gasFeeCap: string;
                gasLimit: number;
                gasPremium: string;
                method: number;
                nonce: number;
                params: string;
                to: string;
                value: string;
                version: 0;
            };
            signature: { data: string; type: "SECP256K1" };
        }

        The signed message

      Returns Promise<SendMessageResponse>

fil_signMessage: (
    ctx: SnapContext,
    params: {
        gasFeeCap?: string;
        gasLimit?: number;
        gasPremium?: string;
        method?: number;
        nonce?: number;
        params?: string;
        to: string;
        value: string;
        version?: 0;
    },
) => Promise<SignMessageResponse>

Type declaration

    • (
          ctx: SnapContext,
          params: {
              gasFeeCap?: string;
              gasLimit?: number;
              gasPremium?: string;
              method?: number;
              nonce?: number;
              params?: string;
              to: string;
              value: string;
              version?: 0;
          },
      ): Promise<SignMessageResponse>
    • Sign a message

      Parameters

      • ctx: SnapContext

        Snap context

      • params: {
            gasFeeCap?: string;
            gasLimit?: number;
            gasPremium?: string;
            method?: number;
            nonce?: number;
            params?: string;
            to: string;
            value: string;
            version?: 0;
        }

        The message request

      Returns Promise<SignMessageResponse>

fil_signMessageRaw: (
    ctx: SnapContext,
    params: { message: string },
) => Promise<SignMessageRawResponse>

Type declaration