Skip to content

Support for differently-named identity contracts #160

Description

@corrideat

Problem

This is a known but undocumented issue surfaced by okTurtles/todomvc#1:

The contract must be named gi.contracts/identity. POST /event rejects an
unattributed first message for any other name, and registers a username only
for that type.

The relevant logic:

          // Only allow identity contracts to be created without attribution
          if (!credentials?.billableContractID && deserializedHEAD.isFirstMessage) {
            const manifest = await sbp('chelonia.db/get', deserializedHEAD.head.manifest)
            let name: string
            try {
              if (!manifest) throw new Error('empty manifest')
              const parsedManifest = JSON.parse(manifest)
              ;({ name } = JSON.parse(parsedManifest.body))
            } catch (e) {
              if (e instanceof HTTPException) throw e
              throw new HTTPException(422, { message: 'Invalid manifest' })
            }
            if (name !== 'gi.contracts/identity') {
              throw new HTTPException(401, { message: 'This contract type requires ownership information' })
            }
            // ...
          }

The rationale for this is / was that identity contracts are special from an accounting perspective, since they aren't owned by any other contract, and they're also 'free' to create. The check is there as sanity check to prevent creating other types of contracts for 'free'.

Solution

At a very minimum, the 'gi.contracts/identity' value needs to be configurable, so that different kinds of identity contracts can be used.

An even better solution is to find a way to remove the check entirely while still honouring the intent behind it (free identity contract registration, forced ownership information for other contracts).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions