@cfxlabsinc/b2b-services
    Preparing search index...

    Class BackofficeWalletConfigAdminService

    Authoritative writer for b2b.backoffice_wallet, the config behind /wallets. Once a write commits it busts both snapshots in the shared backoffice-wallet namespace: the whole-table one (BackofficeWalletQueryService) and the Utila-only one (UtilaBackofficeWalletService).

    Index
    instance: (...args: []) => BackofficeWalletConfigAdminService = ...

    The process default: built from each dependency's own instance().

    • Backs a UTILA row with a wallet holding addresses, as a mintfx ledger account is backed: a CFX_ONLY wallet whose one UTILA secret holds no key. Another row on the same Utila wallet shares that wallet. Each chain's addresses take account indexes in the order given. On a wallet that exists already, addresses it lacks take the next free indexes, and added counts them. dryRun runs the checks and writes nothing.

      Parameters

      Returns Promise<
          | {
              ok: true;
              value: { added: number; backed: boolean; wallet: BackofficeWalletConfig };
          }
          | {
              error: | ServiceError<
                  "WALLET_NOT_FOUND"
                  | "WALLET_NOT_UTILA"
                  | "NO_ADDRESSES",
              >
              | ServiceError<"ADDRESS_ALREADY_HELD", { held: UtilaWalletAddress[] }>;
              ok: false;
          },
      >

    • Backs a Utila wallet, as back does a row's: the one wallet and UTILA secret for that Utila wallet, holding addresses. vaultId is Utila's id of a live vault. When no backoffice wallet names the Utila wallet, a UTILA row UTILA_<walletId> is made on the backed wallet; one that does is left alone. row is the row made, or the first one naming it.

      Parameters

      • input: {
            addresses: UtilaWalletAddress[];
            dryRun?: boolean;
            vaultEnv: "dev" | "prod";
            vaultId: string;
            walletId: string;
        }

      Returns Promise<
          | {
              ok: true;
              value: {
                  added: number;
                  backed: boolean;
                  row: string
                  | null;
                  rowAdded: boolean;
                  wallet: { id: string; secretId: string } | null;
              };
          }
          | {
              error: ServiceError<"WALLET_DUPLICATE">
              | RecordUtilaAddressesError;
              ok: false;
          },
      >

    • utilaVaultId is the uvault_… id of a live vault: required for a UTILA wallet, refused for any other provider.

      Parameters

      • input: { data: BackofficeWalletWriteData; utilaVaultId?: string }

      Returns Promise<
          | { ok: true; value: BackofficeWalletConfig }
          | {
              error:
                  | ServiceError<"WALLET_DUPLICATE">
                  | UtilaVaultError
                  | WalletApiOwnedError
                  | NotMintfxError;
              ok: false;
          },
      >

    • Hard-deletes the wallet; b2b.backoffice_wallet has no deleted_at. Refused while a ledger account sits on its wallet and no other row holds it: the account would then read as mintfx, with no PDA behind it.

      Parameters

      • input: { id: string }

      Returns Promise<
          | { ok: true; value: void }
          | {
              error:
                  | WalletApiOwnedError
                  | ServiceError<
                      "WALLET_NOT_FOUND"
                      | "BACKOFFICE_WALLET_HAS_LEDGER_ACCOUNT",
                  >;
              ok: false;
          },
      >

    • Parameters

      • Optionalinput: {
            backed?: boolean;
            ids?: string[];
            orderBy?: DbOrderByCriterion<
                Omit<
                    PgTableWithColumns<
                        {
                            columns: {
                                createdAt: PgBuildColumn<
                                    "backoffice_wallet",
                                    SetHasDefault<(...)>,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                data: PgBuildColumn<
                                    "backoffice_wallet",
                                    Set$Type<(...), (...)>,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                description: PgBuildColumn<
                                    "backoffice_wallet",
                                    PgTextBuilder<(...)>,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                externalId: PgBuildColumn<
                                    "backoffice_wallet",
                                    SetHasRuntimeDefault<(...)>,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                id: PgBuildColumn<
                                    "backoffice_wallet",
                                    HasIdentity<(...), (...)>,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                ledgerAccountExternalId: PgBuildColumn<
                                    "backoffice_wallet",
                                    PgTextBuilder<(...)>,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                ledgerAccountId: PgBuildColumn<
                                    "backoffice_wallet",
                                    PgIntegerBuilder,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                name: PgBuildColumn<
                                    "backoffice_wallet",
                                    SetNotNull<(...)>,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                provider: PgBuildColumn<
                                    "backoffice_wallet",
                                    Set$Type<(...), (...)>,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                status: PgBuildColumn<
                                    "backoffice_wallet",
                                    SetHasDefault<(...)>,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                updatedAt: PgBuildColumn<
                                    "backoffice_wallet",
                                    SetHasDefault<(...)>,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                utilaVaultExternalId: PgBuildColumn<
                                    "backoffice_wallet",
                                    PgTextBuilder<(...)>,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                utilaVaultId: PgBuildColumn<
                                    "backoffice_wallet",
                                    PgIntegerBuilder,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                utilaWalletId: PgBuildColumn<
                                    "backoffice_wallet",
                                    PgTextBuilder<(...)>,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                walletExternalId: PgBuildColumn<
                                    "backoffice_wallet",
                                    PgTextBuilder<(...)>,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                walletId: PgBuildColumn<
                                    "backoffice_wallet",
                                    PgIntegerBuilder,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                                walletSecretId: PgBuildColumn<
                                    "backoffice_wallet",
                                    PgIntegerBuilder,
                                    {
                                        data: ...;
                                        dataType: ...;
                                        driverParam: ...;
                                        enumValues: ...;
                                        generated: ...;
                                        hasDefault: ...;
                                        hasRuntimeDefault: ...;
                                        identity: ...;
                                        isAutoincrement: ...;
                                        isPrimaryKey: ...;
                                        name: ...;
                                        notNull: ...;
                                        tableName: ...;
                                    },
                                >;
                            };
                            dialect: "pg";
                            isAlias: false;
                            name: "backoffice_wallet";
                            schema: "b2b";
                        },
                    >,
                    "enableRLS",
                >,
                "name"
                | "createdAt",
            >[];
            page?: number;
            pageSize?: number;
            providers?: ("SOLANA" | "LEDGER_ACCOUNT" | "UTILA" | "WALLET")[];
            statuses?: ("ACTIVE" | "DISABLED")[];
        }
        • Optionalbacked?: boolean

          Whether a wallet backs the row.

        • Optionalids?: string[]
        • OptionalorderBy?: DbOrderByCriterion<
              Omit<
                  PgTableWithColumns<
                      {
                          columns: {
                              createdAt: PgBuildColumn<
                                  "backoffice_wallet",
                                  SetHasDefault<(...)>,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              data: PgBuildColumn<
                                  "backoffice_wallet",
                                  Set$Type<(...), (...)>,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              description: PgBuildColumn<
                                  "backoffice_wallet",
                                  PgTextBuilder<(...)>,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              externalId: PgBuildColumn<
                                  "backoffice_wallet",
                                  SetHasRuntimeDefault<(...)>,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              id: PgBuildColumn<
                                  "backoffice_wallet",
                                  HasIdentity<(...), (...)>,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              ledgerAccountExternalId: PgBuildColumn<
                                  "backoffice_wallet",
                                  PgTextBuilder<(...)>,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              ledgerAccountId: PgBuildColumn<
                                  "backoffice_wallet",
                                  PgIntegerBuilder,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              name: PgBuildColumn<
                                  "backoffice_wallet",
                                  SetNotNull<(...)>,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              provider: PgBuildColumn<
                                  "backoffice_wallet",
                                  Set$Type<(...), (...)>,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              status: PgBuildColumn<
                                  "backoffice_wallet",
                                  SetHasDefault<(...)>,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              updatedAt: PgBuildColumn<
                                  "backoffice_wallet",
                                  SetHasDefault<(...)>,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              utilaVaultExternalId: PgBuildColumn<
                                  "backoffice_wallet",
                                  PgTextBuilder<(...)>,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              utilaVaultId: PgBuildColumn<
                                  "backoffice_wallet",
                                  PgIntegerBuilder,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              utilaWalletId: PgBuildColumn<
                                  "backoffice_wallet",
                                  PgTextBuilder<(...)>,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              walletExternalId: PgBuildColumn<
                                  "backoffice_wallet",
                                  PgTextBuilder<(...)>,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              walletId: PgBuildColumn<
                                  "backoffice_wallet",
                                  PgIntegerBuilder,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                              walletSecretId: PgBuildColumn<
                                  "backoffice_wallet",
                                  PgIntegerBuilder,
                                  {
                                      data: ...;
                                      dataType: ...;
                                      driverParam: ...;
                                      enumValues: ...;
                                      generated: ...;
                                      hasDefault: ...;
                                      hasRuntimeDefault: ...;
                                      identity: ...;
                                      isAutoincrement: ...;
                                      isPrimaryKey: ...;
                                      name: ...;
                                      notNull: ...;
                                      tableName: ...;
                                  },
                              >;
                          };
                          dialect: "pg";
                          isAlias: false;
                          name: "backoffice_wallet";
                          schema: "b2b";
                      },
                  >,
                  "enableRLS",
              >,
              "name"
              | "createdAt",
          >[]

          Defaults to name ascending.

        • Optionalpage?: number
        • OptionalpageSize?: number
        • Optionalproviders?: ("SOLANA" | "LEDGER_ACCOUNT" | "UTILA" | "WALLET")[]
        • Optionalstatuses?: ("ACTIVE" | "DISABLED")[]

      Returns Promise<
          {
              ok: true;
              value: {
                  hasNext: boolean;
                  items: BackofficeWalletConfig[];
                  total: number;
              };
          },
      >

    • A write that changes nothing returns the unchanged row without busting.

      utilaVaultId moves a UTILA wallet to another live vault. Omitted, the wallet keeps its vault; a wallet becoming UTILA must name one.

      Parameters

      • input: { data: Partial<BackofficeWalletWriteData>; id: string; utilaVaultId?: string }

      Returns Promise<
          | { ok: true; value: BackofficeWalletConfig }
          | {
              error:
                  | UtilaVaultError
                  | WalletApiOwnedError
                  | NotMintfxError
                  | ServiceError<"WALLET_DUPLICATE" | "WALLET_NOT_FOUND">
                  | BackedWalletError;
              ok: false;
          },
      >