Explorer

definy.read-account-created

description
Read whether the server has accepted create_account of the account, reading the create_account events 500 at a time from offset (read_events_page), then continue with then
type
Fn(account_id: String, offset: Number, then: Fn(created: Boolean) -> @definy.service-io) -> @definy.service-io
expression
fn(account_id$0, offset$1, then$2) =>
  @definy.store-read-events-page(
    event_type: #some("create_account"),
    limit: 500,
    offset: $1,
    then: fn(events$3) =>
      match @core.list-fold(
          T: @definy.stored-event,
          A: Boolean,
          reducer: fn(acc$4, item$5) =>
            @core.or(left: $4, right: @core.equal(left: $5.account_id, right: $0)),
          init: false,
          xs: $3
        ) {
        true =>
          $2(created: true),
        false =>
          match @core.less-than(left: @core.list-length(value: $3), right: 500) {
            true =>
              $2(created: false),
            false =>
              @definy.read-account-created(
                account_id: $0,
                offset: @core.plus(left: $1, right: 500),
                then: fn(created$6) =>
                  $2(created: $6)
              )
          }
      }
  )
visibility
public
definy.read-account-created (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: K9y7Tlozaj_udrlyCUQiROdU9dC0ygrGnT_vTZQLEvs
content hash: Ikgyq94iLksxqsvywawlDZ-zjX9nhcOwk7aiSq6NMN4