diff --git a/CLAUDE.md b/CLAUDE.md
index de0cd4b0..cbac2c8e 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -81,7 +81,7 @@ say — marks itself once at the top:
```
**Budget: 0 title-case strings.** Literals in composables are reported without a budget —
-39 remain, all of them terms of a `+` concatenation.
+19 remain, all of them terms of a `+` concatenation.
## Every target is 48dp, and every icon has a decided description
diff --git a/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/27.json b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/27.json
index ab7e8977..21f24e7b 100644
--- a/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/27.json
+++ b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/27.json
@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 27,
- "identityHash": "daabaf0818bccb5c97f884214e88674b",
+ "identityHash": "b3d7bf2b5f251ad1f39aeb01c7ab316d",
"entities": [
{
"tableName": "BroadcastNostrEventReceipt",
@@ -1986,221 +1986,6 @@
}
]
},
- {
- "tableName": "IcebergKeySession",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT NOT NULL, `onchainDkgSessionId` TEXT NOT NULL, `stage` TEXT NOT NULL, `root` TEXT, `share` TEXT, `groupPublicKey` TEXT, `publicShares` TEXT, `joinApprovedAt` INTEGER, `revealApprovedAt` INTEGER, `confirmApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `failureReason` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "coordinatorPublicKey",
- "columnName": "coordinatorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "userPublicKey",
- "columnName": "userPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "threshold",
- "columnName": "threshold",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "participantCount",
- "columnName": "participantCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "participantPublicKeys",
- "columnName": "participantPublicKeys",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "onchainDkgSessionId",
- "columnName": "onchainDkgSessionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "stage",
- "columnName": "stage",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "root",
- "columnName": "root",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "share",
- "columnName": "share",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupPublicKey",
- "columnName": "groupPublicKey",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "publicShares",
- "columnName": "publicShares",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "joinApprovedAt",
- "columnName": "joinApprovedAt",
- "affinity": "INTEGER"
- },
- {
- "fieldPath": "revealApprovedAt",
- "columnName": "revealApprovedAt",
- "affinity": "INTEGER"
- },
- {
- "fieldPath": "confirmApprovedAt",
- "columnName": "confirmApprovedAt",
- "affinity": "INTEGER"
- },
- {
- "fieldPath": "approvalRequestedThrough",
- "columnName": "approvalRequestedThrough",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "failureReason",
- "columnName": "failureReason",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "indices": [
- {
- "name": "index_IcebergKeySession_chatRoomId",
- "unique": false,
- "columnNames": [
- "chatRoomId"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergKeySession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
- }
- ],
- "foreignKeys": [
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "IcebergParticipantMessage",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `participantPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `participantPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `IcebergKeySession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "sessionId",
- "columnName": "sessionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "participantPublicKey",
- "columnName": "participantPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "kind",
- "columnName": "kind",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "payload",
- "columnName": "payload",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "sessionId",
- "participantPublicKey",
- "kind"
- ]
- },
- "indices": [
- {
- "name": "index_IcebergParticipantMessage_sessionId",
- "unique": false,
- "columnNames": [
- "sessionId"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergParticipantMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
- }
- ],
- "foreignKeys": [
- {
- "table": "IcebergKeySession",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "sessionId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
{
"tableName": "InReplyToRelation",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`replyingNostrEventId` TEXT NOT NULL, `inReplyToNostrEventId` TEXT NOT NULL, `inReplyToProfilePublicKey` TEXT, `inReplyToRootNostrEventId` TEXT, `inReplyToRootProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`replyingNostrEventId`, `inReplyToNostrEventId`), FOREIGN KEY(`inReplyToProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
@@ -2326,1407 +2111,6 @@
}
]
},
- {
- "tableName": "MantraArtifact",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `visibility` TEXT NOT NULL, `dialectId` TEXT NOT NULL, `license` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `signature` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`dialectId`) REFERENCES `MantraDialect`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "url",
- "columnName": "url",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "visibility",
- "columnName": "visibility",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "dialectId",
- "columnName": "dialectId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "license",
- "columnName": "license",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraDialect",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "dialectId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraArtifactVersion",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `artifactId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `versionLabel` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactId`) REFERENCES `MantraArtifact`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "artifactId",
- "columnName": "artifactId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "versionLabel",
- "columnName": "versionLabel",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraArtifact",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "artifactId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraChapter",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `artifactVersionId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `originalText` TEXT NOT NULL, `index` INTEGER NOT NULL, `wordCount` INTEGER NOT NULL, `characterCount` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactVersionId`) REFERENCES `MantraArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "artifactVersionId",
- "columnName": "artifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "originalText",
- "columnName": "originalText",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "wordCount",
- "columnName": "wordCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "characterCount",
- "columnName": "characterCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "artifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraChunk",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chapterId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `text` TEXT NOT NULL, `index` INTEGER NOT NULL, `wordCount` INTEGER NOT NULL, `characterCount` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chapterId`) REFERENCES `MantraChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chapterId",
- "columnName": "chapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "text",
- "columnName": "text",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "wordCount",
- "columnName": "wordCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "characterCount",
- "columnName": "characterCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraDialect",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `country` TEXT NOT NULL, `language` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "country",
- "columnName": "country",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "language",
- "columnName": "language",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslation",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationChunkId` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `text` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationChunkId`) REFERENCES `MantraTranslationChunk`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationChunkId",
- "columnName": "translationChunkId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationArtifactVersionId",
- "columnName": "translationArtifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "text",
- "columnName": "text",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationChunk",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationChunkId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraTranslationArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationArtifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationArtifactVersion",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `artifactVersionId` TEXT NOT NULL, `dialectId` TEXT NOT NULL, `name` TEXT NOT NULL, `visibility` TEXT NOT NULL, `license` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactVersionId`) REFERENCES `MantraArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`dialectId`) REFERENCES `MantraDialect`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "artifactVersionId",
- "columnName": "artifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "dialectId",
- "columnName": "dialectId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "visibility",
- "columnName": "visibility",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "license",
- "columnName": "license",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "artifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraDialect",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "dialectId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationArtifactVersionContributor",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `editorPublicKey` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersionContributor`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationArtifactVersionId",
- "columnName": "translationArtifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "editorPublicKey",
- "columnName": "editorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationArtifactVersionContributor",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationArtifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationChapter",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chapterId` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `index` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chapterId`) REFERENCES `MantraChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chapterId",
- "columnName": "chapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationArtifactVersionId",
- "columnName": "translationArtifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationArtifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationChapterContributor",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationChapterId` TEXT NOT NULL, `translatorPublicKey` TEXT NOT NULL, `role` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationChapterId`) REFERENCES `MantraTranslationChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationChapterId",
- "columnName": "translationChapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translatorPublicKey",
- "columnName": "translatorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "role",
- "columnName": "role",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationChapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationChunk",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chunkId` TEXT NOT NULL, `translationChapterId` TEXT NOT NULL, `text` TEXT NOT NULL, `index` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chunkId`) REFERENCES `MantraChunk`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`translationChapterId`) REFERENCES `MantraTranslationChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chunkId",
- "columnName": "chunkId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationChapterId",
- "columnName": "translationChapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "text",
- "columnName": "text",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraChunk",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chunkId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraTranslationChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationChapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationContributor",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `dTag` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationId` TEXT NOT NULL, `translatorPublicKey` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationId`) REFERENCES `MantraTranslation`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "dTag",
- "columnName": "dTag",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationId",
- "columnName": "translationId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translatorPublicKey",
- "columnName": "translatorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslation",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
{
"tableName": "MarmotCommitResult",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `peerKeyPackageEventId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `isOneMemberInitialGroupCreation` INTEGER NOT NULL, `commitBytes` BLOB NOT NULL, `welcomeBytes` BLOB, `groupInfoBytes` BLOB, `framedCommitBytes` BLOB NOT NULL, `preCommitExporterSecret` BLOB NOT NULL, `obligationId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`))",
@@ -3926,7 +2310,7 @@
},
{
"tableName": "MarmotInnerEvent",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `payloadEventId` TEXT, `marmotGroupEventId` TEXT, `directMessageRecipientPublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `marmotGroupEventId` TEXT, `directMessageRecipientPublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@@ -3969,11 +2353,6 @@
"columnName": "quotedEventId",
"affinity": "TEXT"
},
- {
- "fieldPath": "payloadEventId",
- "columnName": "payloadEventId",
- "affinity": "TEXT"
- },
{
"fieldPath": "marmotGroupEventId",
"columnName": "marmotGroupEventId",
@@ -6179,7 +4558,7 @@
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
- "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'daabaf0818bccb5c97f884214e88674b')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'b3d7bf2b5f251ad1f39aeb01c7ab316d')"
]
}
}
\ No newline at end of file
diff --git a/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/28.json b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/28.json
index 821326a4..cd7b208f 100644
--- a/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/28.json
+++ b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/28.json
@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 28,
- "identityHash": "d654728642ae147f8a1128ac3dfeb50b",
+ "identityHash": "b81b7b97c63fabcda1c21865b7b8c0e7",
"entities": [
{
"tableName": "BroadcastNostrEventReceipt",
@@ -1739,85 +1739,6 @@
}
]
},
- {
- "tableName": "GroupLightningSeed",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `nodeId` TEXT NOT NULL, `chain` TEXT NOT NULL, `wallet` INTEGER NOT NULL, `seed` TEXT NOT NULL, `sentBy` TEXT NOT NULL, `receivedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`, `nodeId`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "nodeId",
- "columnName": "nodeId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chain",
- "columnName": "chain",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "seed",
- "columnName": "seed",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "sentBy",
- "columnName": "sentBy",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "receivedAt",
- "columnName": "receivedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "chatRoomId",
- "nodeId"
- ]
- },
- "indices": [
- {
- "name": "index_GroupLightningSeed_chatRoomId",
- "unique": false,
- "columnNames": [
- "chatRoomId"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupLightningSeed_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
- }
- ],
- "foreignKeys": [
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
{
"tableName": "GroupSignedEvent",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `derivationPath` TEXT, `frostSigningSessionId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
@@ -1944,7 +1865,7 @@
},
{
"tableName": "GroupTransaction",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`frostSigningSessionId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `chain` TEXT NOT NULL, `account` INTEGER NOT NULL, `psbt` TEXT NOT NULL, `txid` TEXT NOT NULL, `signedTransaction` TEXT, `broadcastAt` INTEGER, `seenAt` INTEGER, `confirmedAt` INTEGER, `replacedByTxid` TEXT, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`frostSigningSessionId`), FOREIGN KEY(`frostSigningSessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`frostSigningSessionId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `chain` TEXT NOT NULL, `account` INTEGER NOT NULL, `guardedChatRoomId` TEXT, `psbt` TEXT NOT NULL, `txid` TEXT NOT NULL, `signedTransaction` TEXT, `broadcastAt` INTEGER, `seenAt` INTEGER, `confirmedAt` INTEGER, `replacedByTxid` TEXT, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`frostSigningSessionId`), FOREIGN KEY(`frostSigningSessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "frostSigningSessionId",
@@ -1970,6 +1891,11 @@
"affinity": "INTEGER",
"notNull": true
},
+ {
+ "fieldPath": "guardedChatRoomId",
+ "columnName": "guardedChatRoomId",
+ "affinity": "TEXT"
+ },
{
"fieldPath": "psbt",
"columnName": "psbt",
@@ -2065,221 +1991,6 @@
}
]
},
- {
- "tableName": "IcebergKeySession",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT NOT NULL, `onchainDkgSessionId` TEXT NOT NULL, `stage` TEXT NOT NULL, `root` TEXT, `share` TEXT, `groupPublicKey` TEXT, `publicShares` TEXT, `joinApprovedAt` INTEGER, `revealApprovedAt` INTEGER, `confirmApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `failureReason` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "coordinatorPublicKey",
- "columnName": "coordinatorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "userPublicKey",
- "columnName": "userPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "threshold",
- "columnName": "threshold",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "participantCount",
- "columnName": "participantCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "participantPublicKeys",
- "columnName": "participantPublicKeys",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "onchainDkgSessionId",
- "columnName": "onchainDkgSessionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "stage",
- "columnName": "stage",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "root",
- "columnName": "root",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "share",
- "columnName": "share",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupPublicKey",
- "columnName": "groupPublicKey",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "publicShares",
- "columnName": "publicShares",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "joinApprovedAt",
- "columnName": "joinApprovedAt",
- "affinity": "INTEGER"
- },
- {
- "fieldPath": "revealApprovedAt",
- "columnName": "revealApprovedAt",
- "affinity": "INTEGER"
- },
- {
- "fieldPath": "confirmApprovedAt",
- "columnName": "confirmApprovedAt",
- "affinity": "INTEGER"
- },
- {
- "fieldPath": "approvalRequestedThrough",
- "columnName": "approvalRequestedThrough",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "failureReason",
- "columnName": "failureReason",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "indices": [
- {
- "name": "index_IcebergKeySession_chatRoomId",
- "unique": false,
- "columnNames": [
- "chatRoomId"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergKeySession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
- }
- ],
- "foreignKeys": [
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "IcebergParticipantMessage",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `participantPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `participantPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `IcebergKeySession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "sessionId",
- "columnName": "sessionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "participantPublicKey",
- "columnName": "participantPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "kind",
- "columnName": "kind",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "payload",
- "columnName": "payload",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "sessionId",
- "participantPublicKey",
- "kind"
- ]
- },
- "indices": [
- {
- "name": "index_IcebergParticipantMessage_sessionId",
- "unique": false,
- "columnNames": [
- "sessionId"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergParticipantMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
- }
- ],
- "foreignKeys": [
- {
- "table": "IcebergKeySession",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "sessionId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
{
"tableName": "InReplyToRelation",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`replyingNostrEventId` TEXT NOT NULL, `inReplyToNostrEventId` TEXT NOT NULL, `inReplyToProfilePublicKey` TEXT, `inReplyToRootNostrEventId` TEXT, `inReplyToRootProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`replyingNostrEventId`, `inReplyToNostrEventId`), FOREIGN KEY(`inReplyToProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
@@ -2405,1407 +2116,6 @@
}
]
},
- {
- "tableName": "MantraArtifact",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `visibility` TEXT NOT NULL, `dialectId` TEXT NOT NULL, `license` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `signature` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`dialectId`) REFERENCES `MantraDialect`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "url",
- "columnName": "url",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "visibility",
- "columnName": "visibility",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "dialectId",
- "columnName": "dialectId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "license",
- "columnName": "license",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraDialect",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "dialectId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraArtifactVersion",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `artifactId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `versionLabel` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactId`) REFERENCES `MantraArtifact`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "artifactId",
- "columnName": "artifactId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "versionLabel",
- "columnName": "versionLabel",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraArtifact",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "artifactId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraChapter",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `artifactVersionId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `originalText` TEXT NOT NULL, `index` INTEGER NOT NULL, `wordCount` INTEGER NOT NULL, `characterCount` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactVersionId`) REFERENCES `MantraArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "artifactVersionId",
- "columnName": "artifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "originalText",
- "columnName": "originalText",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "wordCount",
- "columnName": "wordCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "characterCount",
- "columnName": "characterCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "artifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraChunk",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chapterId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `text` TEXT NOT NULL, `index` INTEGER NOT NULL, `wordCount` INTEGER NOT NULL, `characterCount` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chapterId`) REFERENCES `MantraChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chapterId",
- "columnName": "chapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "text",
- "columnName": "text",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "wordCount",
- "columnName": "wordCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "characterCount",
- "columnName": "characterCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraDialect",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `country` TEXT NOT NULL, `language` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "country",
- "columnName": "country",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "language",
- "columnName": "language",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslation",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationChunkId` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `text` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationChunkId`) REFERENCES `MantraTranslationChunk`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationChunkId",
- "columnName": "translationChunkId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationArtifactVersionId",
- "columnName": "translationArtifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "text",
- "columnName": "text",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationChunk",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationChunkId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraTranslationArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationArtifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationArtifactVersion",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `artifactVersionId` TEXT NOT NULL, `dialectId` TEXT NOT NULL, `name` TEXT NOT NULL, `visibility` TEXT NOT NULL, `license` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactVersionId`) REFERENCES `MantraArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`dialectId`) REFERENCES `MantraDialect`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "artifactVersionId",
- "columnName": "artifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "dialectId",
- "columnName": "dialectId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "visibility",
- "columnName": "visibility",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "license",
- "columnName": "license",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "artifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraDialect",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "dialectId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationArtifactVersionContributor",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `editorPublicKey` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersionContributor`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationArtifactVersionId",
- "columnName": "translationArtifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "editorPublicKey",
- "columnName": "editorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationArtifactVersionContributor",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationArtifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationChapter",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chapterId` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `index` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chapterId`) REFERENCES `MantraChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chapterId",
- "columnName": "chapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationArtifactVersionId",
- "columnName": "translationArtifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationArtifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationChapterContributor",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationChapterId` TEXT NOT NULL, `translatorPublicKey` TEXT NOT NULL, `role` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationChapterId`) REFERENCES `MantraTranslationChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationChapterId",
- "columnName": "translationChapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translatorPublicKey",
- "columnName": "translatorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "role",
- "columnName": "role",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationChapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationChunk",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chunkId` TEXT NOT NULL, `translationChapterId` TEXT NOT NULL, `text` TEXT NOT NULL, `index` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chunkId`) REFERENCES `MantraChunk`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`translationChapterId`) REFERENCES `MantraTranslationChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chunkId",
- "columnName": "chunkId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationChapterId",
- "columnName": "translationChapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "text",
- "columnName": "text",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraChunk",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chunkId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraTranslationChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationChapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationContributor",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `dTag` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationId` TEXT NOT NULL, `translatorPublicKey` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationId`) REFERENCES `MantraTranslation`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "dTag",
- "columnName": "dTag",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationId",
- "columnName": "translationId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translatorPublicKey",
- "columnName": "translatorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslation",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
{
"tableName": "MarmotCommitResult",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `peerKeyPackageEventId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `isOneMemberInitialGroupCreation` INTEGER NOT NULL, `commitBytes` BLOB NOT NULL, `welcomeBytes` BLOB, `groupInfoBytes` BLOB, `framedCommitBytes` BLOB NOT NULL, `preCommitExporterSecret` BLOB NOT NULL, `obligationId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`))",
@@ -4005,7 +2315,7 @@
},
{
"tableName": "MarmotInnerEvent",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `payloadEventId` TEXT, `marmotGroupEventId` TEXT, `directMessageRecipientPublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `marmotGroupEventId` TEXT, `directMessageRecipientPublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@@ -4048,11 +2358,6 @@
"columnName": "quotedEventId",
"affinity": "TEXT"
},
- {
- "fieldPath": "payloadEventId",
- "columnName": "payloadEventId",
- "affinity": "TEXT"
- },
{
"fieldPath": "marmotGroupEventId",
"columnName": "marmotGroupEventId",
@@ -6258,7 +4563,7 @@
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
- "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'd654728642ae147f8a1128ac3dfeb50b')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'b81b7b97c63fabcda1c21865b7b8c0e7')"
]
}
}
\ No newline at end of file
diff --git a/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/29.json b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/29.json
index 709631c2..eedb09be 100644
--- a/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/29.json
+++ b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/29.json
@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 29,
- "identityHash": "3d7cecc660080662defcb7612d40e230",
+ "identityHash": "9fb0ffd54bd2d67d1790f97b8bd644b0",
"entities": [
{
"tableName": "BroadcastNostrEventReceipt",
@@ -855,7 +855,7 @@
},
{
"tableName": "DkgSession",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT, `subject` TEXT, `stage` TEXT NOT NULL, `hostPublicKey` TEXT NOT NULL, `round1Random` TEXT NOT NULL, `round2AuxRandom` TEXT NOT NULL, `coordinatorRound1` TEXT, `certificate` TEXT, `thresholdPublicKey` TEXT, `secretShare` TEXT, `publicShares` TEXT, `recoveryData` TEXT, `failureReason` TEXT, `hostKeyApprovedAt` INTEGER, `round1ApprovedAt` INTEGER, `round2ApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `parentChatRoomId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT, `subject` TEXT, `walletPolicy` TEXT, `stage` TEXT NOT NULL, `hostPublicKey` TEXT NOT NULL, `round1Random` TEXT NOT NULL, `round2AuxRandom` TEXT NOT NULL, `coordinatorRound1` TEXT, `certificate` TEXT, `thresholdPublicKey` TEXT, `secretShare` TEXT, `publicShares` TEXT, `recoveryData` TEXT, `failureReason` TEXT, `hostKeyApprovedAt` INTEGER, `round1ApprovedAt` INTEGER, `round2ApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `parentChatRoomId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@@ -903,6 +903,11 @@
"columnName": "subject",
"affinity": "TEXT"
},
+ {
+ "fieldPath": "walletPolicy",
+ "columnName": "walletPolicy",
+ "affinity": "TEXT"
+ },
{
"fieldPath": "stage",
"columnName": "stage",
@@ -1739,85 +1744,6 @@
}
]
},
- {
- "tableName": "GroupLightningSeed",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `nodeId` TEXT NOT NULL, `chain` TEXT NOT NULL, `wallet` INTEGER NOT NULL, `seed` TEXT NOT NULL, `sentBy` TEXT NOT NULL, `receivedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`, `nodeId`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "nodeId",
- "columnName": "nodeId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chain",
- "columnName": "chain",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "seed",
- "columnName": "seed",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "sentBy",
- "columnName": "sentBy",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "receivedAt",
- "columnName": "receivedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "chatRoomId",
- "nodeId"
- ]
- },
- "indices": [
- {
- "name": "index_GroupLightningSeed_chatRoomId",
- "unique": false,
- "columnNames": [
- "chatRoomId"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupLightningSeed_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
- }
- ],
- "foreignKeys": [
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
{
"tableName": "GroupSignedEvent",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `derivationPath` TEXT, `frostSigningSessionId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
@@ -1944,7 +1870,7 @@
},
{
"tableName": "GroupTransaction",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`frostSigningSessionId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `chain` TEXT NOT NULL, `account` INTEGER NOT NULL, `psbt` TEXT NOT NULL, `txid` TEXT NOT NULL, `signedTransaction` TEXT, `broadcastAt` INTEGER, `seenAt` INTEGER, `confirmedAt` INTEGER, `replacedByTxid` TEXT, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`frostSigningSessionId`), FOREIGN KEY(`frostSigningSessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`frostSigningSessionId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `chain` TEXT NOT NULL, `account` INTEGER NOT NULL, `guardedChatRoomId` TEXT, `psbt` TEXT NOT NULL, `txid` TEXT NOT NULL, `signedTransaction` TEXT, `broadcastAt` INTEGER, `seenAt` INTEGER, `confirmedAt` INTEGER, `replacedByTxid` TEXT, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`frostSigningSessionId`), FOREIGN KEY(`frostSigningSessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "frostSigningSessionId",
@@ -1970,6 +1896,11 @@
"affinity": "INTEGER",
"notNull": true
},
+ {
+ "fieldPath": "guardedChatRoomId",
+ "columnName": "guardedChatRoomId",
+ "affinity": "TEXT"
+ },
{
"fieldPath": "psbt",
"columnName": "psbt",
@@ -2065,518 +1996,6 @@
}
]
},
- {
- "tableName": "IcebergBudgetSpend",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `paymentHash` TEXT NOT NULL, `consumedMsat` INTEGER NOT NULL, PRIMARY KEY(`wallet`, `paymentHash`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "paymentHash",
- "columnName": "paymentHash",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "consumedMsat",
- "columnName": "consumedMsat",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "paymentHash"
- ]
- }
- },
- {
- "tableName": "IcebergChannelLedger",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `channelId` TEXT NOT NULL, `fundingOutPoint` TEXT NOT NULL, `remoteFundingPubKey` TEXT NOT NULL, `ledger` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`wallet`, `channelId`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "channelId",
- "columnName": "channelId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "fundingOutPoint",
- "columnName": "fundingOutPoint",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "remoteFundingPubKey",
- "columnName": "remoteFundingPubKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "ledger",
- "columnName": "ledger",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "channelId"
- ]
- }
- },
- {
- "tableName": "IcebergEchoRow",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `label` TEXT NOT NULL, `participant` TEXT NOT NULL, `messageHash` TEXT NOT NULL, PRIMARY KEY(`wallet`, `label`, `participant`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "label",
- "columnName": "label",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "participant",
- "columnName": "participant",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "messageHash",
- "columnName": "messageHash",
- "affinity": "TEXT",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "label",
- "participant"
- ]
- }
- },
- {
- "tableName": "IcebergKeySession",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT NOT NULL, `onchainDkgSessionId` TEXT NOT NULL, `stage` TEXT NOT NULL, `root` TEXT, `share` TEXT, `groupPublicKey` TEXT, `publicShares` TEXT, `joinApprovedAt` INTEGER, `revealApprovedAt` INTEGER, `confirmApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `failureReason` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "coordinatorPublicKey",
- "columnName": "coordinatorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "userPublicKey",
- "columnName": "userPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "threshold",
- "columnName": "threshold",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "participantCount",
- "columnName": "participantCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "participantPublicKeys",
- "columnName": "participantPublicKeys",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "onchainDkgSessionId",
- "columnName": "onchainDkgSessionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "stage",
- "columnName": "stage",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "root",
- "columnName": "root",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "share",
- "columnName": "share",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupPublicKey",
- "columnName": "groupPublicKey",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "publicShares",
- "columnName": "publicShares",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "joinApprovedAt",
- "columnName": "joinApprovedAt",
- "affinity": "INTEGER"
- },
- {
- "fieldPath": "revealApprovedAt",
- "columnName": "revealApprovedAt",
- "affinity": "INTEGER"
- },
- {
- "fieldPath": "confirmApprovedAt",
- "columnName": "confirmApprovedAt",
- "affinity": "INTEGER"
- },
- {
- "fieldPath": "approvalRequestedThrough",
- "columnName": "approvalRequestedThrough",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "failureReason",
- "columnName": "failureReason",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "indices": [
- {
- "name": "index_IcebergKeySession_chatRoomId",
- "unique": false,
- "columnNames": [
- "chatRoomId"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergKeySession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
- }
- ],
- "foreignKeys": [
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "IcebergLabelAssignment",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `counter` INTEGER NOT NULL, `label` TEXT NOT NULL, `purpose` TEXT NOT NULL, `assignedAt` INTEGER NOT NULL, PRIMARY KEY(`wallet`, `counter`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "counter",
- "columnName": "counter",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "label",
- "columnName": "label",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "purpose",
- "columnName": "purpose",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "assignedAt",
- "columnName": "assignedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "counter"
- ]
- },
- "indices": [
- {
- "name": "index_IcebergLabelAssignment_wallet_purpose",
- "unique": false,
- "columnNames": [
- "wallet",
- "purpose"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergLabelAssignment_wallet_purpose` ON `${TABLE_NAME}` (`wallet`, `purpose`)"
- }
- ]
- },
- {
- "tableName": "IcebergLabelLedger",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `label` TEXT NOT NULL, `requestId` TEXT NOT NULL, `messageHash` TEXT NOT NULL, `echoedAt` INTEGER NOT NULL, `signedAt` INTEGER, PRIMARY KEY(`wallet`, `label`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "label",
- "columnName": "label",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "requestId",
- "columnName": "requestId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "messageHash",
- "columnName": "messageHash",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "echoedAt",
- "columnName": "echoedAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signedAt",
- "columnName": "signedAt",
- "affinity": "INTEGER"
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "label"
- ]
- }
- },
- {
- "tableName": "IcebergNonceRow",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `counter` INTEGER NOT NULL, `participant` TEXT NOT NULL, `contribution` TEXT NOT NULL, PRIMARY KEY(`wallet`, `counter`, `participant`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "counter",
- "columnName": "counter",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "participant",
- "columnName": "participant",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "contribution",
- "columnName": "contribution",
- "affinity": "TEXT",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "counter",
- "participant"
- ]
- }
- },
- {
- "tableName": "IcebergParticipantMessage",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `participantPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `participantPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `IcebergKeySession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "sessionId",
- "columnName": "sessionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "participantPublicKey",
- "columnName": "participantPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "kind",
- "columnName": "kind",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "payload",
- "columnName": "payload",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "sessionId",
- "participantPublicKey",
- "kind"
- ]
- },
- "indices": [
- {
- "name": "index_IcebergParticipantMessage_sessionId",
- "unique": false,
- "columnNames": [
- "sessionId"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergParticipantMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
- }
- ],
- "foreignKeys": [
- {
- "table": "IcebergKeySession",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "sessionId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "IcebergShareRow",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `requestId` TEXT NOT NULL, `participant` TEXT NOT NULL, `share` TEXT NOT NULL, PRIMARY KEY(`wallet`, `requestId`, `participant`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "requestId",
- "columnName": "requestId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "participant",
- "columnName": "participant",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "share",
- "columnName": "share",
- "affinity": "TEXT",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "requestId",
- "participant"
- ]
- }
- },
{
"tableName": "InReplyToRelation",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`replyingNostrEventId` TEXT NOT NULL, `inReplyToNostrEventId` TEXT NOT NULL, `inReplyToProfilePublicKey` TEXT, `inReplyToRootNostrEventId` TEXT, `inReplyToRootProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`replyingNostrEventId`, `inReplyToNostrEventId`), FOREIGN KEY(`inReplyToProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
@@ -2702,1407 +2121,6 @@
}
]
},
- {
- "tableName": "MantraArtifact",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `visibility` TEXT NOT NULL, `dialectId` TEXT NOT NULL, `license` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `signature` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`dialectId`) REFERENCES `MantraDialect`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "url",
- "columnName": "url",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "visibility",
- "columnName": "visibility",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "dialectId",
- "columnName": "dialectId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "license",
- "columnName": "license",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraDialect",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "dialectId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraArtifactVersion",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `artifactId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `versionLabel` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactId`) REFERENCES `MantraArtifact`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "artifactId",
- "columnName": "artifactId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "versionLabel",
- "columnName": "versionLabel",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraArtifact",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "artifactId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraChapter",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `artifactVersionId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `originalText` TEXT NOT NULL, `index` INTEGER NOT NULL, `wordCount` INTEGER NOT NULL, `characterCount` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactVersionId`) REFERENCES `MantraArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "artifactVersionId",
- "columnName": "artifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "originalText",
- "columnName": "originalText",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "wordCount",
- "columnName": "wordCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "characterCount",
- "columnName": "characterCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "artifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraChunk",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chapterId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `text` TEXT NOT NULL, `index` INTEGER NOT NULL, `wordCount` INTEGER NOT NULL, `characterCount` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chapterId`) REFERENCES `MantraChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chapterId",
- "columnName": "chapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "text",
- "columnName": "text",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "wordCount",
- "columnName": "wordCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "characterCount",
- "columnName": "characterCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraDialect",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `country` TEXT NOT NULL, `language` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "country",
- "columnName": "country",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "language",
- "columnName": "language",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslation",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationChunkId` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `text` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationChunkId`) REFERENCES `MantraTranslationChunk`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationChunkId",
- "columnName": "translationChunkId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationArtifactVersionId",
- "columnName": "translationArtifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "text",
- "columnName": "text",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationChunk",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationChunkId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraTranslationArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationArtifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationArtifactVersion",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `artifactVersionId` TEXT NOT NULL, `dialectId` TEXT NOT NULL, `name` TEXT NOT NULL, `visibility` TEXT NOT NULL, `license` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactVersionId`) REFERENCES `MantraArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`dialectId`) REFERENCES `MantraDialect`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "artifactVersionId",
- "columnName": "artifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "dialectId",
- "columnName": "dialectId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "visibility",
- "columnName": "visibility",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "license",
- "columnName": "license",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "artifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraDialect",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "dialectId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationArtifactVersionContributor",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `editorPublicKey` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersionContributor`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationArtifactVersionId",
- "columnName": "translationArtifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "editorPublicKey",
- "columnName": "editorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationArtifactVersionContributor",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationArtifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationChapter",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chapterId` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `index` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chapterId`) REFERENCES `MantraChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chapterId",
- "columnName": "chapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationArtifactVersionId",
- "columnName": "translationArtifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationArtifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationChapterContributor",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationChapterId` TEXT NOT NULL, `translatorPublicKey` TEXT NOT NULL, `role` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationChapterId`) REFERENCES `MantraTranslationChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationChapterId",
- "columnName": "translationChapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translatorPublicKey",
- "columnName": "translatorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "role",
- "columnName": "role",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationChapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationChunk",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chunkId` TEXT NOT NULL, `translationChapterId` TEXT NOT NULL, `text` TEXT NOT NULL, `index` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chunkId`) REFERENCES `MantraChunk`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`translationChapterId`) REFERENCES `MantraTranslationChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chunkId",
- "columnName": "chunkId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationChapterId",
- "columnName": "translationChapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "text",
- "columnName": "text",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraChunk",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chunkId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraTranslationChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationChapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationContributor",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `dTag` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationId` TEXT NOT NULL, `translatorPublicKey` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationId`) REFERENCES `MantraTranslation`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "dTag",
- "columnName": "dTag",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationId",
- "columnName": "translationId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translatorPublicKey",
- "columnName": "translatorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslation",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
{
"tableName": "MarmotCommitResult",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `peerKeyPackageEventId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `isOneMemberInitialGroupCreation` INTEGER NOT NULL, `commitBytes` BLOB NOT NULL, `welcomeBytes` BLOB, `groupInfoBytes` BLOB, `framedCommitBytes` BLOB NOT NULL, `preCommitExporterSecret` BLOB NOT NULL, `obligationId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`))",
@@ -4302,7 +2320,7 @@
},
{
"tableName": "MarmotInnerEvent",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `payloadEventId` TEXT, `marmotGroupEventId` TEXT, `directMessageRecipientPublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `marmotGroupEventId` TEXT, `directMessageRecipientPublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@@ -4345,11 +2363,6 @@
"columnName": "quotedEventId",
"affinity": "TEXT"
},
- {
- "fieldPath": "payloadEventId",
- "columnName": "payloadEventId",
- "affinity": "TEXT"
- },
{
"fieldPath": "marmotGroupEventId",
"columnName": "marmotGroupEventId",
@@ -6555,7 +4568,7 @@
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
- "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '3d7cecc660080662defcb7612d40e230')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '9fb0ffd54bd2d67d1790f97b8bd644b0')"
]
}
}
\ No newline at end of file
diff --git a/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/30.json b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/30.json
index b56b58d5..de9606ce 100644
--- a/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/30.json
+++ b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/30.json
@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 30,
- "identityHash": "1c1d38fb933b34767085c3d595c09815",
+ "identityHash": "47aa631ec4032d9b2c00bf0b38689864",
"entities": [
{
"tableName": "BroadcastNostrEventReceipt",
@@ -855,7 +855,7 @@
},
{
"tableName": "DkgSession",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT, `subject` TEXT, `stage` TEXT NOT NULL, `hostPublicKey` TEXT NOT NULL, `round1Random` TEXT NOT NULL, `round2AuxRandom` TEXT NOT NULL, `coordinatorRound1` TEXT, `certificate` TEXT, `thresholdPublicKey` TEXT, `secretShare` TEXT, `publicShares` TEXT, `recoveryData` TEXT, `failureReason` TEXT, `hostKeyApprovedAt` INTEGER, `round1ApprovedAt` INTEGER, `round2ApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `parentChatRoomId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT, `subject` TEXT, `walletPolicy` TEXT, `stage` TEXT NOT NULL, `hostPublicKey` TEXT NOT NULL, `round1Random` TEXT NOT NULL, `round2AuxRandom` TEXT NOT NULL, `coordinatorRound1` TEXT, `certificate` TEXT, `thresholdPublicKey` TEXT, `secretShare` TEXT, `publicShares` TEXT, `recoveryData` TEXT, `failureReason` TEXT, `hostKeyApprovedAt` INTEGER, `round1ApprovedAt` INTEGER, `round2ApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `parentChatRoomId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@@ -903,6 +903,11 @@
"columnName": "subject",
"affinity": "TEXT"
},
+ {
+ "fieldPath": "walletPolicy",
+ "columnName": "walletPolicy",
+ "affinity": "TEXT"
+ },
{
"fieldPath": "stage",
"columnName": "stage",
@@ -1739,234 +1744,6 @@
}
]
},
- {
- "tableName": "GroupLightningInvoiceRow",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `requestId` TEXT NOT NULL, `bolt11` TEXT NOT NULL, `receivedAt` INTEGER NOT NULL, PRIMARY KEY(`wallet`, `requestId`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "requestId",
- "columnName": "requestId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "bolt11",
- "columnName": "bolt11",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "receivedAt",
- "columnName": "receivedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "requestId"
- ]
- }
- },
- {
- "tableName": "GroupLightningPaymentRow",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `id` TEXT NOT NULL, `incoming` INTEGER NOT NULL, `amountMsat` INTEGER NOT NULL, `feesMsat` INTEGER NOT NULL, `paymentHash` TEXT, `description` TEXT, `completedAt` INTEGER, `succeeded` INTEGER NOT NULL, PRIMARY KEY(`wallet`, `id`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "incoming",
- "columnName": "incoming",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "amountMsat",
- "columnName": "amountMsat",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "feesMsat",
- "columnName": "feesMsat",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "paymentHash",
- "columnName": "paymentHash",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "description",
- "columnName": "description",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "completedAt",
- "columnName": "completedAt",
- "affinity": "INTEGER"
- },
- {
- "fieldPath": "succeeded",
- "columnName": "succeeded",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "id"
- ]
- }
- },
- {
- "tableName": "GroupLightningSeed",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `nodeId` TEXT NOT NULL, `chain` TEXT NOT NULL, `wallet` INTEGER NOT NULL, `seed` TEXT NOT NULL, `sentBy` TEXT NOT NULL, `receivedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`, `nodeId`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "nodeId",
- "columnName": "nodeId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chain",
- "columnName": "chain",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "seed",
- "columnName": "seed",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "sentBy",
- "columnName": "sentBy",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "receivedAt",
- "columnName": "receivedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "chatRoomId",
- "nodeId"
- ]
- },
- "indices": [
- {
- "name": "index_GroupLightningSeed_chatRoomId",
- "unique": false,
- "columnNames": [
- "chatRoomId"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupLightningSeed_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
- }
- ],
- "foreignKeys": [
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "GroupLightningSnapshotRow",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `sentBy` TEXT NOT NULL, `term` INTEGER NOT NULL, `content` TEXT NOT NULL, `sentAt` INTEGER NOT NULL, `receivedAt` INTEGER NOT NULL, PRIMARY KEY(`wallet`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "sentBy",
- "columnName": "sentBy",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "term",
- "columnName": "term",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "content",
- "columnName": "content",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "sentAt",
- "columnName": "sentAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "receivedAt",
- "columnName": "receivedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet"
- ]
- }
- },
{
"tableName": "GroupSignedEvent",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `derivationPath` TEXT, `frostSigningSessionId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
@@ -2093,7 +1870,7 @@
},
{
"tableName": "GroupTransaction",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`frostSigningSessionId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `chain` TEXT NOT NULL, `account` INTEGER NOT NULL, `psbt` TEXT NOT NULL, `txid` TEXT NOT NULL, `signedTransaction` TEXT, `broadcastAt` INTEGER, `seenAt` INTEGER, `confirmedAt` INTEGER, `replacedByTxid` TEXT, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`frostSigningSessionId`), FOREIGN KEY(`frostSigningSessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`frostSigningSessionId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `chain` TEXT NOT NULL, `account` INTEGER NOT NULL, `guardedChatRoomId` TEXT, `psbt` TEXT NOT NULL, `txid` TEXT NOT NULL, `signedTransaction` TEXT, `broadcastAt` INTEGER, `seenAt` INTEGER, `confirmedAt` INTEGER, `replacedByTxid` TEXT, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`frostSigningSessionId`), FOREIGN KEY(`frostSigningSessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "frostSigningSessionId",
@@ -2119,6 +1896,11 @@
"affinity": "INTEGER",
"notNull": true
},
+ {
+ "fieldPath": "guardedChatRoomId",
+ "columnName": "guardedChatRoomId",
+ "affinity": "TEXT"
+ },
{
"fieldPath": "psbt",
"columnName": "psbt",
@@ -2214,518 +1996,6 @@
}
]
},
- {
- "tableName": "IcebergBudgetSpend",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `paymentHash` TEXT NOT NULL, `consumedMsat` INTEGER NOT NULL, PRIMARY KEY(`wallet`, `paymentHash`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "paymentHash",
- "columnName": "paymentHash",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "consumedMsat",
- "columnName": "consumedMsat",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "paymentHash"
- ]
- }
- },
- {
- "tableName": "IcebergChannelLedger",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `channelId` TEXT NOT NULL, `fundingOutPoint` TEXT NOT NULL, `remoteFundingPubKey` TEXT NOT NULL, `ledger` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`wallet`, `channelId`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "channelId",
- "columnName": "channelId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "fundingOutPoint",
- "columnName": "fundingOutPoint",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "remoteFundingPubKey",
- "columnName": "remoteFundingPubKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "ledger",
- "columnName": "ledger",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "channelId"
- ]
- }
- },
- {
- "tableName": "IcebergEchoRow",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `label` TEXT NOT NULL, `participant` TEXT NOT NULL, `messageHash` TEXT NOT NULL, PRIMARY KEY(`wallet`, `label`, `participant`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "label",
- "columnName": "label",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "participant",
- "columnName": "participant",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "messageHash",
- "columnName": "messageHash",
- "affinity": "TEXT",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "label",
- "participant"
- ]
- }
- },
- {
- "tableName": "IcebergKeySession",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT NOT NULL, `onchainDkgSessionId` TEXT NOT NULL, `stage` TEXT NOT NULL, `root` TEXT, `share` TEXT, `groupPublicKey` TEXT, `publicShares` TEXT, `joinApprovedAt` INTEGER, `revealApprovedAt` INTEGER, `confirmApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `failureReason` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "coordinatorPublicKey",
- "columnName": "coordinatorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "userPublicKey",
- "columnName": "userPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "threshold",
- "columnName": "threshold",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "participantCount",
- "columnName": "participantCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "participantPublicKeys",
- "columnName": "participantPublicKeys",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "onchainDkgSessionId",
- "columnName": "onchainDkgSessionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "stage",
- "columnName": "stage",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "root",
- "columnName": "root",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "share",
- "columnName": "share",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupPublicKey",
- "columnName": "groupPublicKey",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "publicShares",
- "columnName": "publicShares",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "joinApprovedAt",
- "columnName": "joinApprovedAt",
- "affinity": "INTEGER"
- },
- {
- "fieldPath": "revealApprovedAt",
- "columnName": "revealApprovedAt",
- "affinity": "INTEGER"
- },
- {
- "fieldPath": "confirmApprovedAt",
- "columnName": "confirmApprovedAt",
- "affinity": "INTEGER"
- },
- {
- "fieldPath": "approvalRequestedThrough",
- "columnName": "approvalRequestedThrough",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "failureReason",
- "columnName": "failureReason",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "indices": [
- {
- "name": "index_IcebergKeySession_chatRoomId",
- "unique": false,
- "columnNames": [
- "chatRoomId"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergKeySession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
- }
- ],
- "foreignKeys": [
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "IcebergLabelAssignment",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `counter` INTEGER NOT NULL, `label` TEXT NOT NULL, `purpose` TEXT NOT NULL, `assignedAt` INTEGER NOT NULL, PRIMARY KEY(`wallet`, `counter`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "counter",
- "columnName": "counter",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "label",
- "columnName": "label",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "purpose",
- "columnName": "purpose",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "assignedAt",
- "columnName": "assignedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "counter"
- ]
- },
- "indices": [
- {
- "name": "index_IcebergLabelAssignment_wallet_purpose",
- "unique": false,
- "columnNames": [
- "wallet",
- "purpose"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergLabelAssignment_wallet_purpose` ON `${TABLE_NAME}` (`wallet`, `purpose`)"
- }
- ]
- },
- {
- "tableName": "IcebergLabelLedger",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `label` TEXT NOT NULL, `requestId` TEXT NOT NULL, `messageHash` TEXT NOT NULL, `echoedAt` INTEGER NOT NULL, `signedAt` INTEGER, PRIMARY KEY(`wallet`, `label`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "label",
- "columnName": "label",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "requestId",
- "columnName": "requestId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "messageHash",
- "columnName": "messageHash",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "echoedAt",
- "columnName": "echoedAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signedAt",
- "columnName": "signedAt",
- "affinity": "INTEGER"
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "label"
- ]
- }
- },
- {
- "tableName": "IcebergNonceRow",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `counter` INTEGER NOT NULL, `participant` TEXT NOT NULL, `contribution` TEXT NOT NULL, PRIMARY KEY(`wallet`, `counter`, `participant`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "counter",
- "columnName": "counter",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "participant",
- "columnName": "participant",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "contribution",
- "columnName": "contribution",
- "affinity": "TEXT",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "counter",
- "participant"
- ]
- }
- },
- {
- "tableName": "IcebergParticipantMessage",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `participantPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `participantPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `IcebergKeySession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "sessionId",
- "columnName": "sessionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "participantPublicKey",
- "columnName": "participantPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "kind",
- "columnName": "kind",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "payload",
- "columnName": "payload",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "sessionId",
- "participantPublicKey",
- "kind"
- ]
- },
- "indices": [
- {
- "name": "index_IcebergParticipantMessage_sessionId",
- "unique": false,
- "columnNames": [
- "sessionId"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergParticipantMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
- }
- ],
- "foreignKeys": [
- {
- "table": "IcebergKeySession",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "sessionId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "IcebergShareRow",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `requestId` TEXT NOT NULL, `participant` TEXT NOT NULL, `share` TEXT NOT NULL, PRIMARY KEY(`wallet`, `requestId`, `participant`))",
- "fields": [
- {
- "fieldPath": "wallet",
- "columnName": "wallet",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "requestId",
- "columnName": "requestId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "participant",
- "columnName": "participant",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "share",
- "columnName": "share",
- "affinity": "TEXT",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "wallet",
- "requestId",
- "participant"
- ]
- }
- },
{
"tableName": "InReplyToRelation",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`replyingNostrEventId` TEXT NOT NULL, `inReplyToNostrEventId` TEXT NOT NULL, `inReplyToProfilePublicKey` TEXT, `inReplyToRootNostrEventId` TEXT, `inReplyToRootProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`replyingNostrEventId`, `inReplyToNostrEventId`), FOREIGN KEY(`inReplyToProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
@@ -2851,1407 +2121,6 @@
}
]
},
- {
- "tableName": "MantraArtifact",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `visibility` TEXT NOT NULL, `dialectId` TEXT NOT NULL, `license` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `signature` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`dialectId`) REFERENCES `MantraDialect`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "url",
- "columnName": "url",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "visibility",
- "columnName": "visibility",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "dialectId",
- "columnName": "dialectId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "license",
- "columnName": "license",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraDialect",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "dialectId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraArtifactVersion",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `artifactId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `versionLabel` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactId`) REFERENCES `MantraArtifact`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "artifactId",
- "columnName": "artifactId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "versionLabel",
- "columnName": "versionLabel",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraArtifact",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "artifactId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraChapter",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `artifactVersionId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `originalText` TEXT NOT NULL, `index` INTEGER NOT NULL, `wordCount` INTEGER NOT NULL, `characterCount` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactVersionId`) REFERENCES `MantraArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "artifactVersionId",
- "columnName": "artifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "originalText",
- "columnName": "originalText",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "wordCount",
- "columnName": "wordCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "characterCount",
- "columnName": "characterCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "artifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraChunk",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chapterId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `text` TEXT NOT NULL, `index` INTEGER NOT NULL, `wordCount` INTEGER NOT NULL, `characterCount` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chapterId`) REFERENCES `MantraChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chapterId",
- "columnName": "chapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "text",
- "columnName": "text",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "wordCount",
- "columnName": "wordCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "characterCount",
- "columnName": "characterCount",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraDialect",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `country` TEXT NOT NULL, `language` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "country",
- "columnName": "country",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "language",
- "columnName": "language",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslation",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationChunkId` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `text` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationChunkId`) REFERENCES `MantraTranslationChunk`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationChunkId",
- "columnName": "translationChunkId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationArtifactVersionId",
- "columnName": "translationArtifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "text",
- "columnName": "text",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationChunk",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationChunkId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraTranslationArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationArtifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationArtifactVersion",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `artifactVersionId` TEXT NOT NULL, `dialectId` TEXT NOT NULL, `name` TEXT NOT NULL, `visibility` TEXT NOT NULL, `license` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactVersionId`) REFERENCES `MantraArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`dialectId`) REFERENCES `MantraDialect`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "artifactVersionId",
- "columnName": "artifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "dialectId",
- "columnName": "dialectId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "visibility",
- "columnName": "visibility",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "license",
- "columnName": "license",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "artifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraDialect",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "dialectId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationArtifactVersionContributor",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `editorPublicKey` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersionContributor`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationArtifactVersionId",
- "columnName": "translationArtifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "editorPublicKey",
- "columnName": "editorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationArtifactVersionContributor",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationArtifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationChapter",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chapterId` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `index` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chapterId`) REFERENCES `MantraChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chapterId",
- "columnName": "chapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationArtifactVersionId",
- "columnName": "translationArtifactVersionId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationArtifactVersion",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationArtifactVersionId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationChapterContributor",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationChapterId` TEXT NOT NULL, `translatorPublicKey` TEXT NOT NULL, `role` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationChapterId`) REFERENCES `MantraTranslationChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationChapterId",
- "columnName": "translationChapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translatorPublicKey",
- "columnName": "translatorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "role",
- "columnName": "role",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslationChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationChapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationChunk",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chunkId` TEXT NOT NULL, `translationChapterId` TEXT NOT NULL, `text` TEXT NOT NULL, `index` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chunkId`) REFERENCES `MantraChunk`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`translationChapterId`) REFERENCES `MantraTranslationChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chunkId",
- "columnName": "chunkId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationChapterId",
- "columnName": "translationChapterId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "text",
- "columnName": "text",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "index",
- "columnName": "index",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraChunk",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chunkId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "MantraTranslationChapter",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationChapterId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
- {
- "tableName": "MantraTranslationContributor",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `dTag` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationId` TEXT NOT NULL, `translatorPublicKey` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationId`) REFERENCES `MantraTranslation`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "id",
- "columnName": "id",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "dTag",
- "columnName": "dTag",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "publicKey",
- "columnName": "publicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translationId",
- "columnName": "translationId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "translatorPublicKey",
- "columnName": "translatorPublicKey",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "signature",
- "columnName": "signature",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "relayHint",
- "columnName": "relayHint",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "marmotGroupEventId",
- "columnName": "marmotGroupEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "groupSignedEventId",
- "columnName": "groupSignedEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "nostrEventId",
- "columnName": "nostrEventId",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "createdAt",
- "columnName": "createdAt",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "updatedAt",
- "columnName": "updatedAt",
- "affinity": "INTEGER",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "id"
- ]
- },
- "foreignKeys": [
- {
- "table": "MantraTranslation",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "translationId"
- ],
- "referencedColumns": [
- "id"
- ]
- },
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
{
"tableName": "MarmotCommitResult",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `peerKeyPackageEventId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `isOneMemberInitialGroupCreation` INTEGER NOT NULL, `commitBytes` BLOB NOT NULL, `welcomeBytes` BLOB, `groupInfoBytes` BLOB, `framedCommitBytes` BLOB NOT NULL, `preCommitExporterSecret` BLOB NOT NULL, `obligationId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`))",
@@ -4451,7 +2320,7 @@
},
{
"tableName": "MarmotInnerEvent",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `payloadEventId` TEXT, `marmotGroupEventId` TEXT, `directMessageRecipientPublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `marmotGroupEventId` TEXT, `directMessageRecipientPublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@@ -4494,11 +2363,6 @@
"columnName": "quotedEventId",
"affinity": "TEXT"
},
- {
- "fieldPath": "payloadEventId",
- "columnName": "payloadEventId",
- "affinity": "TEXT"
- },
{
"fieldPath": "marmotGroupEventId",
"columnName": "marmotGroupEventId",
@@ -4930,6 +2794,158 @@
}
]
},
+ {
+ "tableName": "MemberWallet",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`walletId` TEXT NOT NULL, `ownerPublicKey` TEXT NOT NULL, `guardingChatRoomId` TEXT NOT NULL, `chain` TEXT NOT NULL, `walletPrivateKey` TEXT NOT NULL, `label` TEXT, `requestJson` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`walletId`))",
+ "fields": [
+ {
+ "fieldPath": "walletId",
+ "columnName": "walletId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ownerPublicKey",
+ "columnName": "ownerPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "guardingChatRoomId",
+ "columnName": "guardingChatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chain",
+ "columnName": "chain",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "walletPrivateKey",
+ "columnName": "walletPrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "label",
+ "columnName": "label",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "requestJson",
+ "columnName": "requestJson",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "walletId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MemberWallet_ownerPublicKey",
+ "unique": false,
+ "columnNames": [
+ "ownerPublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MemberWallet_ownerPublicKey` ON `${TABLE_NAME}` (`ownerPublicKey`)"
+ },
+ {
+ "name": "index_MemberWallet_guardingChatRoomId",
+ "unique": false,
+ "columnNames": [
+ "guardingChatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MemberWallet_guardingChatRoomId` ON `${TABLE_NAME}` (`guardingChatRoomId`)"
+ }
+ ]
+ },
+ {
+ "tableName": "MemberWalletSpend",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`txid` TEXT NOT NULL, `walletId` TEXT NOT NULL, `psbt` TEXT NOT NULL, `signedTransaction` TEXT NOT NULL, `broadcastAt` INTEGER, `seenAt` INTEGER, `confirmedAt` INTEGER, `replacedByTxid` TEXT, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`txid`))",
+ "fields": [
+ {
+ "fieldPath": "txid",
+ "columnName": "txid",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "walletId",
+ "columnName": "walletId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "psbt",
+ "columnName": "psbt",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signedTransaction",
+ "columnName": "signedTransaction",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "broadcastAt",
+ "columnName": "broadcastAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seenAt",
+ "columnName": "seenAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "confirmedAt",
+ "columnName": "confirmedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "replacedByTxid",
+ "columnName": "replacedByTxid",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "txid"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MemberWalletSpend_walletId",
+ "unique": false,
+ "columnNames": [
+ "walletId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MemberWalletSpend_walletId` ON `${TABLE_NAME}` (`walletId`)"
+ }
+ ]
+ },
{
"tableName": "Mention",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `mentionedPublicKey` TEXT NOT NULL, `mentioningNostrEventId` TEXT, `relayUrl` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, FOREIGN KEY(`mentionedPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`mentioningNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
@@ -6704,7 +4720,7 @@
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
- "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '1c1d38fb933b34767085c3d595c09815')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '47aa631ec4032d9b2c00bf0b38689864')"
]
}
}
\ No newline at end of file
diff --git a/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/31.json b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/31.json
new file mode 100644
index 00000000..0d3f097d
--- /dev/null
+++ b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/31.json
@@ -0,0 +1,4731 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 31,
+ "identityHash": "63d1cbf5fb6fb297117d1e7a0d45766d",
+ "entities": [
+ {
+ "tableName": "BroadcastNostrEventReceipt",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `nostrEventId` TEXT NOT NULL, `unsignedNostrEventId` INTEGER, `isAccepted` INTEGER NOT NULL, `isSync` INTEGER NOT NULL, `relayURL` TEXT NOT NULL, `messages` TEXT, FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`unsignedNostrEventId`) REFERENCES `UnsignedNostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "isAccepted",
+ "columnName": "isAccepted",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isSync",
+ "columnName": "isSync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "messages",
+ "columnName": "messages",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_BroadcastNostrEventReceipt_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventReceipt_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_BroadcastNostrEventReceipt_isAccepted",
+ "unique": false,
+ "columnNames": [
+ "isAccepted"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventReceipt_isAccepted` ON `${TABLE_NAME}` (`isAccepted`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "UnsignedNostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "unsignedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "BroadcastNostrEventRequest",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `nostrEventId` TEXT NOT NULL, `unsignedNostrEventId` INTEGER, `status` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`unsignedNostrEventId`) REFERENCES `UnsignedNostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_BroadcastNostrEventRequest_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventRequest_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_BroadcastNostrEventRequest_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventRequest_status` ON `${TABLE_NAME}` (`status`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "UnsignedNostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "unsignedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Connection",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sourcePublicKey` TEXT NOT NULL, `destinationPublicKey` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`sourcePublicKey`, `destinationPublicKey`), FOREIGN KEY(`sourcePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`destinationPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sourcePublicKey",
+ "columnName": "sourcePublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "destinationPublicKey",
+ "columnName": "destinationPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sourcePublicKey",
+ "destinationPublicKey"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sourcePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "destinationPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `senderPublicKey` TEXT NOT NULL, `isUserMessage` INTEGER NOT NULL, `giftWrapPayloadId` TEXT, `marmotGroupEventId` TEXT, `marmotInnerEventId` TEXT, `chatRoomId` TEXT NOT NULL, `replyToMessageId` INTEGER, `quotedMessageId` INTEGER, `content` TEXT NOT NULL, `messageType` TEXT NOT NULL, `directMessageRecipientPublicKey` TEXT, `frostSigningSessionId` TEXT, `dkgSessionId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`giftWrapPayloadId`) REFERENCES `GiftWrapPayload`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`marmotInnerEventId`) REFERENCES `MarmotInnerEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "senderPublicKey",
+ "columnName": "senderPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserMessage",
+ "columnName": "isUserMessage",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "giftWrapPayloadId",
+ "columnName": "giftWrapPayloadId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotInnerEventId",
+ "columnName": "marmotInnerEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "replyToMessageId",
+ "columnName": "replyToMessageId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "quotedMessageId",
+ "columnName": "quotedMessageId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "messageType",
+ "columnName": "messageType",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "directMessageRecipientPublicKey",
+ "columnName": "directMessageRecipientPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "frostSigningSessionId",
+ "columnName": "frostSigningSessionId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "dkgSessionId",
+ "columnName": "dkgSessionId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_ChatMessage_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_ChatMessage_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "GiftWrapPayload",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "giftWrapPayloadId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MarmotGroupEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "marmotGroupEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MarmotInnerEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "marmotInnerEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessageBroadcastNostrEventRequestRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `chatMessageId` INTEGER NOT NULL, `broadcastNostrEventRequestId` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, FOREIGN KEY(`chatMessageId`) REFERENCES `ChatMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`broadcastNostrEventRequestId`) REFERENCES `BroadcastNostrEventRequest`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatMessageId",
+ "columnName": "chatMessageId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "broadcastNostrEventRequestId",
+ "columnName": "broadcastNostrEventRequestId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "BroadcastNostrEventRequest",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "broadcastNostrEventRequestId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessageBroadcastNostrEventReceiptRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `chatMessageId` INTEGER NOT NULL, `broadcastNostrEventReceiptId` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, FOREIGN KEY(`chatMessageId`) REFERENCES `ChatMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`broadcastNostrEventReceiptId`) REFERENCES `BroadcastNostrEventReceipt`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatMessageId",
+ "columnName": "chatMessageId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "broadcastNostrEventReceiptId",
+ "columnName": "broadcastNostrEventReceiptId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "BroadcastNostrEventReceipt",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "broadcastNostrEventReceiptId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessageNostrEventRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `chatMessageId` INTEGER NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, FOREIGN KEY(`chatMessageId`) REFERENCES `ChatMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatMessageId",
+ "columnName": "chatMessageId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatRoom",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `subject` TEXT, `description` TEXT, `mlsGroupState` TEXT, `initialGiftWrapPayloadId` TEXT, `leftGroupAt` INTEGER, `joinedGroupAt` INTEGER, `chronicleRequestedAt` INTEGER, `parentChatRoomId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`userPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`initialGiftWrapPayloadId`) REFERENCES `GiftWrapPayload`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "subject",
+ "columnName": "subject",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "mlsGroupState",
+ "columnName": "mlsGroupState",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "initialGiftWrapPayloadId",
+ "columnName": "initialGiftWrapPayloadId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "leftGroupAt",
+ "columnName": "leftGroupAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "joinedGroupAt",
+ "columnName": "joinedGroupAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "chronicleRequestedAt",
+ "columnName": "chronicleRequestedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "parentChatRoomId",
+ "columnName": "parentChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "userPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "GiftWrapPayload",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "initialGiftWrapPayloadId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "DkgParticipantMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `participantPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `participantPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `DkgSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKey",
+ "columnName": "participantPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "payload",
+ "columnName": "payload",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "participantPublicKey",
+ "kind"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_DkgParticipantMessage_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_DkgParticipantMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "DkgSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "DkgSession",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT, `subject` TEXT, `walletPolicy` TEXT, `guardianDelay` INTEGER, `stage` TEXT NOT NULL, `hostPublicKey` TEXT NOT NULL, `round1Random` TEXT NOT NULL, `round2AuxRandom` TEXT NOT NULL, `coordinatorRound1` TEXT, `certificate` TEXT, `thresholdPublicKey` TEXT, `secretShare` TEXT, `publicShares` TEXT, `recoveryData` TEXT, `failureReason` TEXT, `hostKeyApprovedAt` INTEGER, `round1ApprovedAt` INTEGER, `round2ApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `parentChatRoomId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorPublicKey",
+ "columnName": "coordinatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "threshold",
+ "columnName": "threshold",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantCount",
+ "columnName": "participantCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKeys",
+ "columnName": "participantPublicKeys",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "subject",
+ "columnName": "subject",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "walletPolicy",
+ "columnName": "walletPolicy",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "guardianDelay",
+ "columnName": "guardianDelay",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "stage",
+ "columnName": "stage",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "hostPublicKey",
+ "columnName": "hostPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "round1Random",
+ "columnName": "round1Random",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "round2AuxRandom",
+ "columnName": "round2AuxRandom",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorRound1",
+ "columnName": "coordinatorRound1",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "certificate",
+ "columnName": "certificate",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "thresholdPublicKey",
+ "columnName": "thresholdPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "secretShare",
+ "columnName": "secretShare",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "publicShares",
+ "columnName": "publicShares",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "recoveryData",
+ "columnName": "recoveryData",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failureReason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "hostKeyApprovedAt",
+ "columnName": "hostKeyApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "round1ApprovedAt",
+ "columnName": "round1ApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "round2ApprovedAt",
+ "columnName": "round2ApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "approvalRequestedThrough",
+ "columnName": "approvalRequestedThrough",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "parentChatRoomId",
+ "columnName": "parentChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_DkgSession_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_DkgSession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "FrostSignerMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `signerPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `signerPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signerPublicKey",
+ "columnName": "signerPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "payload",
+ "columnName": "payload",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "signerPublicKey",
+ "kind"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_FrostSignerMessage_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSignerMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "FrostSigningSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "FrostSigningItem",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `itemIndex` INTEGER NOT NULL, `unsignedEventJson` TEXT NOT NULL, `eventId` TEXT NOT NULL, `nonceRandom` TEXT NOT NULL, `aggregatedNonce` TEXT, `signature` TEXT, `inputIndex` INTEGER, PRIMARY KEY(`sessionId`, `itemIndex`), FOREIGN KEY(`sessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemIndex",
+ "columnName": "itemIndex",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "unsignedEventJson",
+ "columnName": "unsignedEventJson",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "eventId",
+ "columnName": "eventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nonceRandom",
+ "columnName": "nonceRandom",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "aggregatedNonce",
+ "columnName": "aggregatedNonce",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inputIndex",
+ "columnName": "inputIndex",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "itemIndex"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_FrostSigningItem_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSigningItem_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "FrostSigningSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "FrostSigningSession",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `signerId` INTEGER NOT NULL, `derivationPath` TEXT, `stage` TEXT NOT NULL, `signerIds` TEXT, `failureReason` TEXT, `signApprovedAt` INTEGER, `signDeclinedAt` INTEGER, `approvalRequestedAt` INTEGER, `resentAt` INTEGER, `subject` TEXT NOT NULL DEFAULT 'EVENTS', `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorPublicKey",
+ "columnName": "coordinatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dkgSessionId",
+ "columnName": "dkgSessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "threshold",
+ "columnName": "threshold",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantCount",
+ "columnName": "participantCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signerId",
+ "columnName": "signerId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "derivationPath",
+ "columnName": "derivationPath",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "stage",
+ "columnName": "stage",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signerIds",
+ "columnName": "signerIds",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failureReason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "signApprovedAt",
+ "columnName": "signApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "signDeclinedAt",
+ "columnName": "signDeclinedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "approvalRequestedAt",
+ "columnName": "approvalRequestedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "resentAt",
+ "columnName": "resentAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "subject",
+ "columnName": "subject",
+ "affinity": "TEXT",
+ "notNull": true,
+ "defaultValue": "'EVENTS'"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_FrostSigningSession_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSigningSession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ },
+ {
+ "name": "index_FrostSigningSession_dkgSessionId",
+ "unique": false,
+ "columnNames": [
+ "dkgSessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSigningSession_dkgSessionId` ON `${TABLE_NAME}` (`dkgSessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GiftWrapMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `receiverPublicKey` TEXT NOT NULL, `receiverRelayHit` TEXT, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receiverPublicKey",
+ "columnName": "receiverPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receiverRelayHit",
+ "columnName": "receiverRelayHit",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GiftWrapSeal",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `giftWrapMessageId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`giftWrapMessageId`) REFERENCES `GiftWrapMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "giftWrapMessageId",
+ "columnName": "giftWrapMessageId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "GiftWrapMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "giftWrapMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GiftWrapPayload",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `giftWrapSealId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`giftWrapSealId`) REFERENCES `GiftWrapSeal`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedEventId",
+ "columnName": "quotedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "giftWrapSealId",
+ "columnName": "giftWrapSealId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "GiftWrapSeal",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "giftWrapSealId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GroupKeyState",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `thresholdPublicKey` TEXT NOT NULL, `derivationPath` TEXT NOT NULL, `announcedBy` TEXT NOT NULL, `announcedAt` INTEGER NOT NULL, `parentChatRoomId` TEXT, `birthCertificateJson` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dkgSessionId",
+ "columnName": "dkgSessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "thresholdPublicKey",
+ "columnName": "thresholdPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "derivationPath",
+ "columnName": "derivationPath",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "announcedBy",
+ "columnName": "announcedBy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "announcedAt",
+ "columnName": "announcedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentChatRoomId",
+ "columnName": "parentChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "birthCertificateJson",
+ "columnName": "birthCertificateJson",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "chatRoomId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_GroupKeyState_dkgSessionId",
+ "unique": false,
+ "columnNames": [
+ "dkgSessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupKeyState_dkgSessionId` ON `${TABLE_NAME}` (`dkgSessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GroupSignedEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `derivationPath` TEXT, `frostSigningSessionId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "derivationPath",
+ "columnName": "derivationPath",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "frostSigningSessionId",
+ "columnName": "frostSigningSessionId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_GroupSignedEvent_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupSignedEvent_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ },
+ {
+ "name": "index_GroupSignedEvent_kind",
+ "unique": false,
+ "columnNames": [
+ "kind"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupSignedEvent_kind` ON `${TABLE_NAME}` (`kind`)"
+ },
+ {
+ "name": "index_GroupSignedEvent_frostSigningSessionId",
+ "unique": false,
+ "columnNames": [
+ "frostSigningSessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupSignedEvent_frostSigningSessionId` ON `${TABLE_NAME}` (`frostSigningSessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GroupTransaction",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`frostSigningSessionId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `chain` TEXT NOT NULL, `account` INTEGER NOT NULL, `guardedChatRoomId` TEXT, `psbt` TEXT NOT NULL, `txid` TEXT NOT NULL, `signedTransaction` TEXT, `broadcastAt` INTEGER, `seenAt` INTEGER, `confirmedAt` INTEGER, `replacedByTxid` TEXT, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`frostSigningSessionId`), FOREIGN KEY(`frostSigningSessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "frostSigningSessionId",
+ "columnName": "frostSigningSessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chain",
+ "columnName": "chain",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "account",
+ "columnName": "account",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "guardedChatRoomId",
+ "columnName": "guardedChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "psbt",
+ "columnName": "psbt",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "txid",
+ "columnName": "txid",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signedTransaction",
+ "columnName": "signedTransaction",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "broadcastAt",
+ "columnName": "broadcastAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seenAt",
+ "columnName": "seenAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "confirmedAt",
+ "columnName": "confirmedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "replacedByTxid",
+ "columnName": "replacedByTxid",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "frostSigningSessionId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_GroupTransaction_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupTransaction_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ },
+ {
+ "name": "index_GroupTransaction_txid",
+ "unique": false,
+ "columnNames": [
+ "txid"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupTransaction_txid` ON `${TABLE_NAME}` (`txid`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "FrostSigningSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "frostSigningSessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "InReplyToRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`replyingNostrEventId` TEXT NOT NULL, `inReplyToNostrEventId` TEXT NOT NULL, `inReplyToProfilePublicKey` TEXT, `inReplyToRootNostrEventId` TEXT, `inReplyToRootProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`replyingNostrEventId`, `inReplyToNostrEventId`), FOREIGN KEY(`inReplyToProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "replyingNostrEventId",
+ "columnName": "replyingNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "inReplyToNostrEventId",
+ "columnName": "inReplyToNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "inReplyToProfilePublicKey",
+ "columnName": "inReplyToProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootNostrEventId",
+ "columnName": "inReplyToRootNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootProfilePublicKey",
+ "columnName": "inReplyToRootProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "replyingNostrEventId",
+ "inReplyToNostrEventId"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToRootProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "replyingNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToRootNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotCommitResult",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `peerKeyPackageEventId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `isOneMemberInitialGroupCreation` INTEGER NOT NULL, `commitBytes` BLOB NOT NULL, `welcomeBytes` BLOB, `groupInfoBytes` BLOB, `framedCommitBytes` BLOB NOT NULL, `preCommitExporterSecret` BLOB NOT NULL, `obligationId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "peerKeyPackageEventId",
+ "columnName": "peerKeyPackageEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isOneMemberInitialGroupCreation",
+ "columnName": "isOneMemberInitialGroupCreation",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "commitBytes",
+ "columnName": "commitBytes",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "welcomeBytes",
+ "columnName": "welcomeBytes",
+ "affinity": "BLOB"
+ },
+ {
+ "fieldPath": "groupInfoBytes",
+ "columnName": "groupInfoBytes",
+ "affinity": "BLOB"
+ },
+ {
+ "fieldPath": "framedCommitBytes",
+ "columnName": "framedCommitBytes",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "preCommitExporterSecret",
+ "columnName": "preCommitExporterSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "obligationId",
+ "columnName": "obligationId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "MarmotGroupEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `signature` TEXT NOT NULL, `encryptedContent` TEXT NOT NULL, `expiresAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`id`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "encryptedContent",
+ "columnName": "encryptedContent",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "expiresAt",
+ "columnName": "expiresAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotInnerEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `marmotGroupEventId` TEXT, `directMessageRecipientPublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedEventId",
+ "columnName": "quotedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "directMessageRecipientPublicKey",
+ "columnName": "directMessageRecipientPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MarmotGroupEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "marmotGroupEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotKeyPackage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` BLOB NOT NULL, `profile` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`publicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tlsEncodedMarmotKeyPackage",
+ "columnName": "tlsEncodedMarmotKeyPackage",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profile",
+ "columnName": "profile",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "publicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotKeyPackageBundle",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` BLOB NOT NULL, `ncryptsecInitPrivateKey` TEXT NOT NULL, `ncryptsecEncryptionPrivateKey` TEXT NOT NULL, `ncryptsecSignaturePrivateKey` TEXT NOT NULL, `consumed` INTEGER NOT NULL, `rotated` INTEGER NOT NULL, `profile` TEXT, `dTag` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tlsEncodedMarmotKeyPackage",
+ "columnName": "tlsEncodedMarmotKeyPackage",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ncryptsecInitPrivateKey",
+ "columnName": "ncryptsecInitPrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ncryptsecEncryptionPrivateKey",
+ "columnName": "ncryptsecEncryptionPrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ncryptsecSignaturePrivateKey",
+ "columnName": "ncryptsecSignaturePrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "consumed",
+ "columnName": "consumed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rotated",
+ "columnName": "rotated",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profile",
+ "columnName": "profile",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "dTag",
+ "columnName": "dTag",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MarmotKeyPackageBundle_publicKey",
+ "unique": false,
+ "columnNames": [
+ "publicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MarmotKeyPackageBundle_publicKey` ON `${TABLE_NAME}` (`publicKey`)"
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotRouting",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`routingId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `activeFromEpoch` INTEGER NOT NULL, `retiredAtEpoch` INTEGER, PRIMARY KEY(`routingId`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "routingId",
+ "columnName": "routingId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "activeFromEpoch",
+ "columnName": "activeFromEpoch",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retiredAtEpoch",
+ "columnName": "retiredAtEpoch",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "routingId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MarmotRouting_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MarmotRouting_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotPublishObligation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`obligationId` TEXT NOT NULL, `bytes` BLOB NOT NULL, PRIMARY KEY(`obligationId`))",
+ "fields": [
+ {
+ "fieldPath": "obligationId",
+ "columnName": "obligationId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "bytes",
+ "columnName": "bytes",
+ "affinity": "BLOB",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "obligationId"
+ ]
+ }
+ },
+ {
+ "tableName": "MarmotOutboundGate",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`groupId` TEXT NOT NULL, `gate` TEXT NOT NULL, PRIMARY KEY(`groupId`))",
+ "fields": [
+ {
+ "fieldPath": "groupId",
+ "columnName": "groupId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "gate",
+ "columnName": "gate",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "groupId"
+ ]
+ }
+ },
+ {
+ "tableName": "MarmotRetainedEpochSecret",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `epoch` INTEGER NOT NULL, `senderDataSecret` BLOB NOT NULL, `encryptionSecret` BLOB NOT NULL, `leafCount` INTEGER NOT NULL, `exporterSecret` BLOB NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`, `epoch`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epoch",
+ "columnName": "epoch",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "senderDataSecret",
+ "columnName": "senderDataSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "encryptionSecret",
+ "columnName": "encryptionSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "leafCount",
+ "columnName": "leafCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "exporterSecret",
+ "columnName": "exporterSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "chatRoomId",
+ "epoch"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MemberWallet",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`walletId` TEXT NOT NULL, `ownerPublicKey` TEXT NOT NULL, `guardingChatRoomId` TEXT NOT NULL, `chain` TEXT NOT NULL, `walletPrivateKey` TEXT NOT NULL, `label` TEXT, `requestJson` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`walletId`))",
+ "fields": [
+ {
+ "fieldPath": "walletId",
+ "columnName": "walletId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ownerPublicKey",
+ "columnName": "ownerPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "guardingChatRoomId",
+ "columnName": "guardingChatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chain",
+ "columnName": "chain",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "walletPrivateKey",
+ "columnName": "walletPrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "label",
+ "columnName": "label",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "requestJson",
+ "columnName": "requestJson",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "walletId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MemberWallet_ownerPublicKey",
+ "unique": false,
+ "columnNames": [
+ "ownerPublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MemberWallet_ownerPublicKey` ON `${TABLE_NAME}` (`ownerPublicKey`)"
+ },
+ {
+ "name": "index_MemberWallet_guardingChatRoomId",
+ "unique": false,
+ "columnNames": [
+ "guardingChatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MemberWallet_guardingChatRoomId` ON `${TABLE_NAME}` (`guardingChatRoomId`)"
+ }
+ ]
+ },
+ {
+ "tableName": "MemberWalletSpend",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`txid` TEXT NOT NULL, `walletId` TEXT NOT NULL, `psbt` TEXT NOT NULL, `signedTransaction` TEXT NOT NULL, `broadcastAt` INTEGER, `seenAt` INTEGER, `confirmedAt` INTEGER, `replacedByTxid` TEXT, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`txid`))",
+ "fields": [
+ {
+ "fieldPath": "txid",
+ "columnName": "txid",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "walletId",
+ "columnName": "walletId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "psbt",
+ "columnName": "psbt",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signedTransaction",
+ "columnName": "signedTransaction",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "broadcastAt",
+ "columnName": "broadcastAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seenAt",
+ "columnName": "seenAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "confirmedAt",
+ "columnName": "confirmedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "replacedByTxid",
+ "columnName": "replacedByTxid",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "txid"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MemberWalletSpend_walletId",
+ "unique": false,
+ "columnNames": [
+ "walletId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MemberWalletSpend_walletId` ON `${TABLE_NAME}` (`walletId`)"
+ }
+ ]
+ },
+ {
+ "tableName": "Mention",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `mentionedPublicKey` TEXT NOT NULL, `mentioningNostrEventId` TEXT, `relayUrl` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, FOREIGN KEY(`mentionedPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`mentioningNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "mentionedPublicKey",
+ "columnName": "mentionedPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "mentioningNostrEventId",
+ "columnName": "mentioningNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "relayUrl",
+ "columnName": "relayUrl",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "mentionedPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "mentioningNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "NegentropySynchronizeRequest",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `uuid` TEXT NOT NULL, `purpose` TEXT NOT NULL, `status` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `isRecommendedRelay` INTEGER NOT NULL, `level` INTEGER NOT NULL, `synchronizationFilter` TEXT NOT NULL, `ownerPublicKey` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "uuid",
+ "columnName": "uuid",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "purpose",
+ "columnName": "purpose",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isRecommendedRelay",
+ "columnName": "isRecommendedRelay",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "level",
+ "columnName": "level",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "synchronizationFilter",
+ "columnName": "synchronizationFilter",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ownerPublicKey",
+ "columnName": "ownerPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_NegentropySynchronizeRequest_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NegentropySynchronizeRequest_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_NegentropySynchronizeRequest_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NegentropySynchronizeRequest_status` ON `${TABLE_NAME}` (`status`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "NegentropySynchronizeResult",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `status` TEXT NOT NULL, `negentropySynchronizeRequestId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`negentropySynchronizeRequestId`) REFERENCES `SynchronizeNostrEventResult`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "negentropySynchronizeRequestId",
+ "columnName": "negentropySynchronizeRequestId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "SynchronizeNostrEventResult",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "negentropySynchronizeRequestId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "NostrEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `pubKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `sig` TEXT NOT NULL, `relayUrl` TEXT, `quotedNostrEventId` TEXT, `quotedAuthorPublicKey` TEXT, `inReplyToNostrEventId` TEXT, `inReplyToAuthorPublicKey` TEXT, `inReplyToRootNostrEventId` TEXT, `inReplyToRootAuthorPublicKey` TEXT, `repostedNostrEventId` TEXT, `repostedAuthorPublicKey` TEXT, `unsignedNostrEventId` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pubKey",
+ "columnName": "pubKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sig",
+ "columnName": "sig",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayUrl",
+ "columnName": "relayUrl",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "quotedNostrEventId",
+ "columnName": "quotedNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "quotedAuthorPublicKey",
+ "columnName": "quotedAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToNostrEventId",
+ "columnName": "inReplyToNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToAuthorPublicKey",
+ "columnName": "inReplyToAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootNostrEventId",
+ "columnName": "inReplyToRootNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootAuthorPublicKey",
+ "columnName": "inReplyToRootAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "repostedNostrEventId",
+ "columnName": "repostedNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "repostedAuthorPublicKey",
+ "columnName": "repostedAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_NostrEvent_kind",
+ "unique": false,
+ "columnNames": [
+ "kind"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_kind` ON `${TABLE_NAME}` (`kind`)"
+ },
+ {
+ "name": "index_NostrEvent_pubKey",
+ "unique": false,
+ "columnNames": [
+ "pubKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_pubKey` ON `${TABLE_NAME}` (`pubKey`)"
+ },
+ {
+ "name": "index_NostrEvent_quotedNostrEventId",
+ "unique": false,
+ "columnNames": [
+ "quotedNostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_quotedNostrEventId` ON `${TABLE_NAME}` (`quotedNostrEventId`)"
+ },
+ {
+ "name": "index_NostrEvent_inReplyToNostrEventId",
+ "unique": false,
+ "columnNames": [
+ "inReplyToNostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_inReplyToNostrEventId` ON `${TABLE_NAME}` (`inReplyToNostrEventId`)"
+ },
+ {
+ "name": "index_NostrEvent_inReplyToRootNostrEventId",
+ "unique": false,
+ "columnNames": [
+ "inReplyToRootNostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_inReplyToRootNostrEventId` ON `${TABLE_NAME}` (`inReplyToRootNostrEventId`)"
+ }
+ ]
+ },
+ {
+ "tableName": "NostrEventRelay",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`relayURL` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`nostrEventId`, `relayURL`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "nostrEventId",
+ "relayURL"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_NostrEventRelay_relayURL",
+ "unique": false,
+ "columnNames": [
+ "relayURL"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEventRelay_relayURL` ON `${TABLE_NAME}` (`relayURL`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Participant",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `participantPublicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `adminAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, FOREIGN KEY(`participantPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKey",
+ "columnName": "participantPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "adminAt",
+ "columnName": "adminAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "participantPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Post",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `repostId` TEXT, `quote` TEXT, `content` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `replyToId` TEXT, `profilePublicKey` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`profilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyToId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`repostId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "repostId",
+ "columnName": "repostId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "quote",
+ "columnName": "quote",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "replyToId",
+ "columnName": "replyToId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "profilePublicKey",
+ "columnName": "profilePublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Post_profilePublicKey",
+ "unique": false,
+ "columnNames": [
+ "profilePublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_profilePublicKey` ON `${TABLE_NAME}` (`profilePublicKey`)"
+ },
+ {
+ "name": "index_Post_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_Post_replyToId",
+ "unique": false,
+ "columnNames": [
+ "replyToId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_replyToId` ON `${TABLE_NAME}` (`replyToId`)"
+ },
+ {
+ "name": "index_Post_repostId",
+ "unique": false,
+ "columnNames": [
+ "repostId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_repostId` ON `${TABLE_NAME}` (`repostId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "replyToId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Profile",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`publicKey` TEXT NOT NULL, `userName` TEXT, `displayName` TEXT, `picture` TEXT, `banner` TEXT, `website` TEXT, `about` TEXT, `bot` INTEGER, `pronouns` TEXT, `nip05` TEXT, `domain` TEXT, `lud06` TEXT, `lud16` TEXT, `twitter` TEXT, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`publicKey`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userName",
+ "columnName": "userName",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "displayName",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "picture",
+ "columnName": "picture",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "banner",
+ "columnName": "banner",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "website",
+ "columnName": "website",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "about",
+ "columnName": "about",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "bot",
+ "columnName": "bot",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "pronouns",
+ "columnName": "pronouns",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nip05",
+ "columnName": "nip05",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "domain",
+ "columnName": "domain",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lud06",
+ "columnName": "lud06",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lud16",
+ "columnName": "lud16",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "twitter",
+ "columnName": "twitter",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "publicKey"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Profile_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Profile_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "QuotedRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`quotingNostrEventId` TEXT NOT NULL, `quotedNostrEventId` TEXT NOT NULL, `quotedProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`quotingNostrEventId`, `quotedNostrEventId`), FOREIGN KEY(`quotedProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`quotingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`quotedNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "quotingNostrEventId",
+ "columnName": "quotingNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedNostrEventId",
+ "columnName": "quotedNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedProfilePublicKey",
+ "columnName": "quotedProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "quotingNostrEventId",
+ "quotedNostrEventId"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "quotedProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "quotingNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "quotedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Reaction",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `content` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `replyToId` TEXT NOT NULL, `profilePublicKey` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`profilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyToId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "replyToId",
+ "columnName": "replyToId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profilePublicKey",
+ "columnName": "profilePublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Reaction_profilePublicKey",
+ "unique": false,
+ "columnNames": [
+ "profilePublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Reaction_profilePublicKey` ON `${TABLE_NAME}` (`profilePublicKey`)"
+ },
+ {
+ "name": "index_Reaction_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Reaction_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_Reaction_replyToId",
+ "unique": false,
+ "columnNames": [
+ "replyToId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Reaction_replyToId` ON `${TABLE_NAME}` (`replyToId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "replyToId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "RecentSearch",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`query` TEXT NOT NULL, `synchronizationFilters` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`query`))",
+ "fields": [
+ {
+ "fieldPath": "query",
+ "columnName": "query",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "synchronizationFilters",
+ "columnName": "synchronizationFilters",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "query"
+ ]
+ }
+ },
+ {
+ "tableName": "Relay",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`publicKey` TEXT NOT NULL, `type` TEXT NOT NULL, `url` TEXT NOT NULL, `read` INTEGER NOT NULL, `write` INTEGER NOT NULL, PRIMARY KEY(`publicKey`, `type`, `url`))",
+ "fields": [
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "url",
+ "columnName": "url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "read",
+ "columnName": "read",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "write",
+ "columnName": "write",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "publicKey",
+ "type",
+ "url"
+ ]
+ }
+ },
+ {
+ "tableName": "RepostedRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`repostingNostrEventId` TEXT NOT NULL, `repostedNostrEventId` TEXT NOT NULL, `repostedProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`repostingNostrEventId`, `repostedNostrEventId`), FOREIGN KEY(`repostedProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`repostedNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`repostingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "repostingNostrEventId",
+ "columnName": "repostingNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "repostedNostrEventId",
+ "columnName": "repostedNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "repostedProfilePublicKey",
+ "columnName": "repostedProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "repostingNostrEventId",
+ "repostedNostrEventId"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostedProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostingNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "SynchronizeNostrEventRequest",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `purpose` TEXT NOT NULL, `status` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `isRecommendedRelay` INTEGER NOT NULL, `level` INTEGER NOT NULL, `synchronizationFilters` TEXT NOT NULL, `ownerPublicKey` TEXT, `nostrEventId` TEXT, `unsignedNostrEventId` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`unsignedNostrEventId`) REFERENCES `UnsignedNostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "purpose",
+ "columnName": "purpose",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isRecommendedRelay",
+ "columnName": "isRecommendedRelay",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "level",
+ "columnName": "level",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "synchronizationFilters",
+ "columnName": "synchronizationFilters",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ownerPublicKey",
+ "columnName": "ownerPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_SynchronizeNostrEventRequest_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_SynchronizeNostrEventRequest_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_SynchronizeNostrEventRequest_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_SynchronizeNostrEventRequest_status` ON `${TABLE_NAME}` (`status`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "UnsignedNostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "unsignedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "SynchronizeNostrEventResult",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_SynchronizeNostrEventResult_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_SynchronizeNostrEventResult_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "UnsignedNostrEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `pubKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `privateTags` TEXT, `content` TEXT NOT NULL, `signedAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pubKey",
+ "columnName": "pubKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "privateTags",
+ "columnName": "privateTags",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signedAt",
+ "columnName": "signedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_UnsignedNostrEvent_pubKey",
+ "unique": false,
+ "columnNames": [
+ "pubKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_UnsignedNostrEvent_pubKey` ON `${TABLE_NAME}` (`pubKey`)"
+ },
+ {
+ "name": "index_UnsignedNostrEvent_kind",
+ "unique": false,
+ "columnNames": [
+ "kind"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_UnsignedNostrEvent_kind` ON `${TABLE_NAME}` (`kind`)"
+ }
+ ]
+ },
+ {
+ "tableName": "Zap",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `postId` TEXT NOT NULL, `senderPublicKey` TEXT NOT NULL, `receiverPublicKey` TEXT NOT NULL, `message` TEXT, `invoice` TEXT, `amountInMillisatoshis` INTEGER, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`senderPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`receiverPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`postId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "postId",
+ "columnName": "postId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "senderPublicKey",
+ "columnName": "senderPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receiverPublicKey",
+ "columnName": "receiverPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "message",
+ "columnName": "message",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "invoice",
+ "columnName": "invoice",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "amountInMillisatoshis",
+ "columnName": "amountInMillisatoshis",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Zap_senderPublicKey",
+ "unique": false,
+ "columnNames": [
+ "senderPublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Zap_senderPublicKey` ON `${TABLE_NAME}` (`senderPublicKey`)"
+ },
+ {
+ "name": "index_Zap_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Zap_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_Zap_postId",
+ "unique": false,
+ "columnNames": [
+ "postId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Zap_postId` ON `${TABLE_NAME}` (`postId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "senderPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "receiverPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "postId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ }
+ ],
+ "setupQueries": [
+ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '63d1cbf5fb6fb297117d1e7a0d45766d')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/32.json b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/32.json
new file mode 100644
index 00000000..df42641a
--- /dev/null
+++ b/composeApp/schemas/com.machankura.bennu.compose.database.BennuDatabase/32.json
@@ -0,0 +1,5471 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 32,
+ "identityHash": "6272f3e8e60bff8f0692fe9061ed56dc",
+ "entities": [
+ {
+ "tableName": "BroadcastNostrEventReceipt",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `nostrEventId` TEXT NOT NULL, `unsignedNostrEventId` INTEGER, `isAccepted` INTEGER NOT NULL, `isSync` INTEGER NOT NULL, `relayURL` TEXT NOT NULL, `messages` TEXT, FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`unsignedNostrEventId`) REFERENCES `UnsignedNostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "isAccepted",
+ "columnName": "isAccepted",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isSync",
+ "columnName": "isSync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "messages",
+ "columnName": "messages",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_BroadcastNostrEventReceipt_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventReceipt_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_BroadcastNostrEventReceipt_isAccepted",
+ "unique": false,
+ "columnNames": [
+ "isAccepted"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventReceipt_isAccepted` ON `${TABLE_NAME}` (`isAccepted`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "UnsignedNostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "unsignedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "BroadcastNostrEventRequest",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `nostrEventId` TEXT NOT NULL, `unsignedNostrEventId` INTEGER, `status` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`unsignedNostrEventId`) REFERENCES `UnsignedNostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_BroadcastNostrEventRequest_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventRequest_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_BroadcastNostrEventRequest_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventRequest_status` ON `${TABLE_NAME}` (`status`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "UnsignedNostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "unsignedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Connection",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sourcePublicKey` TEXT NOT NULL, `destinationPublicKey` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`sourcePublicKey`, `destinationPublicKey`), FOREIGN KEY(`sourcePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`destinationPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sourcePublicKey",
+ "columnName": "sourcePublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "destinationPublicKey",
+ "columnName": "destinationPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sourcePublicKey",
+ "destinationPublicKey"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sourcePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "destinationPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `senderPublicKey` TEXT NOT NULL, `isUserMessage` INTEGER NOT NULL, `giftWrapPayloadId` TEXT, `marmotGroupEventId` TEXT, `marmotInnerEventId` TEXT, `chatRoomId` TEXT NOT NULL, `replyToMessageId` INTEGER, `quotedMessageId` INTEGER, `content` TEXT NOT NULL, `messageType` TEXT NOT NULL, `directMessageRecipientPublicKey` TEXT, `frostSigningSessionId` TEXT, `dkgSessionId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`giftWrapPayloadId`) REFERENCES `GiftWrapPayload`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`marmotInnerEventId`) REFERENCES `MarmotInnerEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "senderPublicKey",
+ "columnName": "senderPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserMessage",
+ "columnName": "isUserMessage",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "giftWrapPayloadId",
+ "columnName": "giftWrapPayloadId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotInnerEventId",
+ "columnName": "marmotInnerEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "replyToMessageId",
+ "columnName": "replyToMessageId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "quotedMessageId",
+ "columnName": "quotedMessageId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "messageType",
+ "columnName": "messageType",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "directMessageRecipientPublicKey",
+ "columnName": "directMessageRecipientPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "frostSigningSessionId",
+ "columnName": "frostSigningSessionId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "dkgSessionId",
+ "columnName": "dkgSessionId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_ChatMessage_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_ChatMessage_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "GiftWrapPayload",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "giftWrapPayloadId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MarmotGroupEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "marmotGroupEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MarmotInnerEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "marmotInnerEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessageBroadcastNostrEventRequestRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `chatMessageId` INTEGER NOT NULL, `broadcastNostrEventRequestId` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, FOREIGN KEY(`chatMessageId`) REFERENCES `ChatMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`broadcastNostrEventRequestId`) REFERENCES `BroadcastNostrEventRequest`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatMessageId",
+ "columnName": "chatMessageId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "broadcastNostrEventRequestId",
+ "columnName": "broadcastNostrEventRequestId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "BroadcastNostrEventRequest",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "broadcastNostrEventRequestId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessageBroadcastNostrEventReceiptRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `chatMessageId` INTEGER NOT NULL, `broadcastNostrEventReceiptId` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, FOREIGN KEY(`chatMessageId`) REFERENCES `ChatMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`broadcastNostrEventReceiptId`) REFERENCES `BroadcastNostrEventReceipt`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatMessageId",
+ "columnName": "chatMessageId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "broadcastNostrEventReceiptId",
+ "columnName": "broadcastNostrEventReceiptId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "BroadcastNostrEventReceipt",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "broadcastNostrEventReceiptId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessageNostrEventRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `chatMessageId` INTEGER NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, FOREIGN KEY(`chatMessageId`) REFERENCES `ChatMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatMessageId",
+ "columnName": "chatMessageId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatRoom",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `subject` TEXT, `description` TEXT, `mlsGroupState` TEXT, `initialGiftWrapPayloadId` TEXT, `leftGroupAt` INTEGER, `joinedGroupAt` INTEGER, `chronicleRequestedAt` INTEGER, `parentChatRoomId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`userPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`initialGiftWrapPayloadId`) REFERENCES `GiftWrapPayload`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "subject",
+ "columnName": "subject",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "mlsGroupState",
+ "columnName": "mlsGroupState",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "initialGiftWrapPayloadId",
+ "columnName": "initialGiftWrapPayloadId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "leftGroupAt",
+ "columnName": "leftGroupAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "joinedGroupAt",
+ "columnName": "joinedGroupAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "chronicleRequestedAt",
+ "columnName": "chronicleRequestedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "parentChatRoomId",
+ "columnName": "parentChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "userPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "GiftWrapPayload",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "initialGiftWrapPayloadId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "DkgParticipantMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `participantPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `participantPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `DkgSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKey",
+ "columnName": "participantPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "payload",
+ "columnName": "payload",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "participantPublicKey",
+ "kind"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_DkgParticipantMessage_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_DkgParticipantMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "DkgSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "DkgSession",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT, `subject` TEXT, `walletPolicy` TEXT, `guardianDelay` INTEGER, `stage` TEXT NOT NULL, `hostPublicKey` TEXT NOT NULL, `round1Random` TEXT NOT NULL, `round2AuxRandom` TEXT NOT NULL, `coordinatorRound1` TEXT, `certificate` TEXT, `thresholdPublicKey` TEXT, `secretShare` TEXT, `publicShares` TEXT, `recoveryData` TEXT, `failureReason` TEXT, `hostKeyApprovedAt` INTEGER, `round1ApprovedAt` INTEGER, `round2ApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `parentChatRoomId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorPublicKey",
+ "columnName": "coordinatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "threshold",
+ "columnName": "threshold",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantCount",
+ "columnName": "participantCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKeys",
+ "columnName": "participantPublicKeys",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "subject",
+ "columnName": "subject",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "walletPolicy",
+ "columnName": "walletPolicy",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "guardianDelay",
+ "columnName": "guardianDelay",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "stage",
+ "columnName": "stage",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "hostPublicKey",
+ "columnName": "hostPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "round1Random",
+ "columnName": "round1Random",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "round2AuxRandom",
+ "columnName": "round2AuxRandom",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorRound1",
+ "columnName": "coordinatorRound1",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "certificate",
+ "columnName": "certificate",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "thresholdPublicKey",
+ "columnName": "thresholdPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "secretShare",
+ "columnName": "secretShare",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "publicShares",
+ "columnName": "publicShares",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "recoveryData",
+ "columnName": "recoveryData",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failureReason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "hostKeyApprovedAt",
+ "columnName": "hostKeyApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "round1ApprovedAt",
+ "columnName": "round1ApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "round2ApprovedAt",
+ "columnName": "round2ApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "approvalRequestedThrough",
+ "columnName": "approvalRequestedThrough",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "parentChatRoomId",
+ "columnName": "parentChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_DkgSession_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_DkgSession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "FrostSignerMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `signerPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `signerPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signerPublicKey",
+ "columnName": "signerPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "payload",
+ "columnName": "payload",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "signerPublicKey",
+ "kind"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_FrostSignerMessage_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSignerMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "FrostSigningSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "FrostSigningItem",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `itemIndex` INTEGER NOT NULL, `unsignedEventJson` TEXT NOT NULL, `eventId` TEXT NOT NULL, `nonceRandom` TEXT NOT NULL, `aggregatedNonce` TEXT, `signature` TEXT, `inputIndex` INTEGER, PRIMARY KEY(`sessionId`, `itemIndex`), FOREIGN KEY(`sessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemIndex",
+ "columnName": "itemIndex",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "unsignedEventJson",
+ "columnName": "unsignedEventJson",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "eventId",
+ "columnName": "eventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nonceRandom",
+ "columnName": "nonceRandom",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "aggregatedNonce",
+ "columnName": "aggregatedNonce",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inputIndex",
+ "columnName": "inputIndex",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "itemIndex"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_FrostSigningItem_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSigningItem_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "FrostSigningSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "FrostSigningSession",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `signerId` INTEGER NOT NULL, `derivationPath` TEXT, `stage` TEXT NOT NULL, `signerIds` TEXT, `failureReason` TEXT, `signApprovedAt` INTEGER, `signDeclinedAt` INTEGER, `approvalRequestedAt` INTEGER, `resentAt` INTEGER, `subject` TEXT NOT NULL DEFAULT 'EVENTS', `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorPublicKey",
+ "columnName": "coordinatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dkgSessionId",
+ "columnName": "dkgSessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "threshold",
+ "columnName": "threshold",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantCount",
+ "columnName": "participantCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signerId",
+ "columnName": "signerId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "derivationPath",
+ "columnName": "derivationPath",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "stage",
+ "columnName": "stage",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signerIds",
+ "columnName": "signerIds",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failureReason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "signApprovedAt",
+ "columnName": "signApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "signDeclinedAt",
+ "columnName": "signDeclinedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "approvalRequestedAt",
+ "columnName": "approvalRequestedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "resentAt",
+ "columnName": "resentAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "subject",
+ "columnName": "subject",
+ "affinity": "TEXT",
+ "notNull": true,
+ "defaultValue": "'EVENTS'"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_FrostSigningSession_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSigningSession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ },
+ {
+ "name": "index_FrostSigningSession_dkgSessionId",
+ "unique": false,
+ "columnNames": [
+ "dkgSessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSigningSession_dkgSessionId` ON `${TABLE_NAME}` (`dkgSessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GiftWrapMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `receiverPublicKey` TEXT NOT NULL, `receiverRelayHit` TEXT, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receiverPublicKey",
+ "columnName": "receiverPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receiverRelayHit",
+ "columnName": "receiverRelayHit",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GiftWrapSeal",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `giftWrapMessageId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`giftWrapMessageId`) REFERENCES `GiftWrapMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "giftWrapMessageId",
+ "columnName": "giftWrapMessageId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "GiftWrapMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "giftWrapMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GiftWrapPayload",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `giftWrapSealId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`giftWrapSealId`) REFERENCES `GiftWrapSeal`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedEventId",
+ "columnName": "quotedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "giftWrapSealId",
+ "columnName": "giftWrapSealId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "GiftWrapSeal",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "giftWrapSealId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GroupKeyState",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `thresholdPublicKey` TEXT NOT NULL, `derivationPath` TEXT NOT NULL, `announcedBy` TEXT NOT NULL, `announcedAt` INTEGER NOT NULL, `parentChatRoomId` TEXT, `birthCertificateJson` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dkgSessionId",
+ "columnName": "dkgSessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "thresholdPublicKey",
+ "columnName": "thresholdPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "derivationPath",
+ "columnName": "derivationPath",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "announcedBy",
+ "columnName": "announcedBy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "announcedAt",
+ "columnName": "announcedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentChatRoomId",
+ "columnName": "parentChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "birthCertificateJson",
+ "columnName": "birthCertificateJson",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "chatRoomId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_GroupKeyState_dkgSessionId",
+ "unique": false,
+ "columnNames": [
+ "dkgSessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupKeyState_dkgSessionId` ON `${TABLE_NAME}` (`dkgSessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GroupLightningInvoiceRow",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `requestId` TEXT NOT NULL, `bolt11` TEXT NOT NULL, `receivedAt` INTEGER NOT NULL, PRIMARY KEY(`wallet`, `requestId`))",
+ "fields": [
+ {
+ "fieldPath": "wallet",
+ "columnName": "wallet",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "requestId",
+ "columnName": "requestId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "bolt11",
+ "columnName": "bolt11",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receivedAt",
+ "columnName": "receivedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "wallet",
+ "requestId"
+ ]
+ }
+ },
+ {
+ "tableName": "GroupLightningPaymentRow",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `id` TEXT NOT NULL, `incoming` INTEGER NOT NULL, `amountMsat` INTEGER NOT NULL, `feesMsat` INTEGER NOT NULL, `paymentHash` TEXT, `description` TEXT, `completedAt` INTEGER, `succeeded` INTEGER NOT NULL, PRIMARY KEY(`wallet`, `id`))",
+ "fields": [
+ {
+ "fieldPath": "wallet",
+ "columnName": "wallet",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "incoming",
+ "columnName": "incoming",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "amountMsat",
+ "columnName": "amountMsat",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "feesMsat",
+ "columnName": "feesMsat",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "paymentHash",
+ "columnName": "paymentHash",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "completedAt",
+ "columnName": "completedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "succeeded",
+ "columnName": "succeeded",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "wallet",
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "GroupLightningSeed",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `nodeId` TEXT NOT NULL, `chain` TEXT NOT NULL, `wallet` INTEGER NOT NULL, `seed` TEXT NOT NULL, `sentBy` TEXT NOT NULL, `receivedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`, `nodeId`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nodeId",
+ "columnName": "nodeId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chain",
+ "columnName": "chain",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "wallet",
+ "columnName": "wallet",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seed",
+ "columnName": "seed",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sentBy",
+ "columnName": "sentBy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receivedAt",
+ "columnName": "receivedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "chatRoomId",
+ "nodeId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_GroupLightningSeed_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupLightningSeed_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GroupLightningSnapshotRow",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `sentBy` TEXT NOT NULL, `term` INTEGER NOT NULL, `content` TEXT NOT NULL, `sentAt` INTEGER NOT NULL, `receivedAt` INTEGER NOT NULL, PRIMARY KEY(`wallet`))",
+ "fields": [
+ {
+ "fieldPath": "wallet",
+ "columnName": "wallet",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sentBy",
+ "columnName": "sentBy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "term",
+ "columnName": "term",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sentAt",
+ "columnName": "sentAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receivedAt",
+ "columnName": "receivedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "wallet"
+ ]
+ }
+ },
+ {
+ "tableName": "GroupSignedEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `derivationPath` TEXT, `frostSigningSessionId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "derivationPath",
+ "columnName": "derivationPath",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "frostSigningSessionId",
+ "columnName": "frostSigningSessionId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_GroupSignedEvent_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupSignedEvent_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ },
+ {
+ "name": "index_GroupSignedEvent_kind",
+ "unique": false,
+ "columnNames": [
+ "kind"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupSignedEvent_kind` ON `${TABLE_NAME}` (`kind`)"
+ },
+ {
+ "name": "index_GroupSignedEvent_frostSigningSessionId",
+ "unique": false,
+ "columnNames": [
+ "frostSigningSessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupSignedEvent_frostSigningSessionId` ON `${TABLE_NAME}` (`frostSigningSessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GroupTransaction",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`frostSigningSessionId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `chain` TEXT NOT NULL, `account` INTEGER NOT NULL, `guardedChatRoomId` TEXT, `psbt` TEXT NOT NULL, `txid` TEXT NOT NULL, `signedTransaction` TEXT, `broadcastAt` INTEGER, `seenAt` INTEGER, `confirmedAt` INTEGER, `replacedByTxid` TEXT, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`frostSigningSessionId`), FOREIGN KEY(`frostSigningSessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "frostSigningSessionId",
+ "columnName": "frostSigningSessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chain",
+ "columnName": "chain",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "account",
+ "columnName": "account",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "guardedChatRoomId",
+ "columnName": "guardedChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "psbt",
+ "columnName": "psbt",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "txid",
+ "columnName": "txid",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signedTransaction",
+ "columnName": "signedTransaction",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "broadcastAt",
+ "columnName": "broadcastAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seenAt",
+ "columnName": "seenAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "confirmedAt",
+ "columnName": "confirmedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "replacedByTxid",
+ "columnName": "replacedByTxid",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "frostSigningSessionId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_GroupTransaction_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupTransaction_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ },
+ {
+ "name": "index_GroupTransaction_txid",
+ "unique": false,
+ "columnNames": [
+ "txid"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupTransaction_txid` ON `${TABLE_NAME}` (`txid`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "FrostSigningSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "frostSigningSessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "IcebergBudgetSpend",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `paymentHash` TEXT NOT NULL, `consumedMsat` INTEGER NOT NULL, PRIMARY KEY(`wallet`, `paymentHash`))",
+ "fields": [
+ {
+ "fieldPath": "wallet",
+ "columnName": "wallet",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "paymentHash",
+ "columnName": "paymentHash",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "consumedMsat",
+ "columnName": "consumedMsat",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "wallet",
+ "paymentHash"
+ ]
+ }
+ },
+ {
+ "tableName": "IcebergChannelLedger",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `channelId` TEXT NOT NULL, `fundingOutPoint` TEXT NOT NULL, `remoteFundingPubKey` TEXT NOT NULL, `ledger` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`wallet`, `channelId`))",
+ "fields": [
+ {
+ "fieldPath": "wallet",
+ "columnName": "wallet",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channelId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "fundingOutPoint",
+ "columnName": "fundingOutPoint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remoteFundingPubKey",
+ "columnName": "remoteFundingPubKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ledger",
+ "columnName": "ledger",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "wallet",
+ "channelId"
+ ]
+ }
+ },
+ {
+ "tableName": "IcebergEchoRow",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `label` TEXT NOT NULL, `participant` TEXT NOT NULL, `messageHash` TEXT NOT NULL, PRIMARY KEY(`wallet`, `label`, `participant`))",
+ "fields": [
+ {
+ "fieldPath": "wallet",
+ "columnName": "wallet",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "label",
+ "columnName": "label",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participant",
+ "columnName": "participant",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "messageHash",
+ "columnName": "messageHash",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "wallet",
+ "label",
+ "participant"
+ ]
+ }
+ },
+ {
+ "tableName": "IcebergKeySession",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT NOT NULL, `onchainDkgSessionId` TEXT NOT NULL, `stage` TEXT NOT NULL, `root` TEXT, `share` TEXT, `groupPublicKey` TEXT, `publicShares` TEXT, `joinApprovedAt` INTEGER, `revealApprovedAt` INTEGER, `confirmApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `failureReason` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorPublicKey",
+ "columnName": "coordinatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "threshold",
+ "columnName": "threshold",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantCount",
+ "columnName": "participantCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKeys",
+ "columnName": "participantPublicKeys",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "onchainDkgSessionId",
+ "columnName": "onchainDkgSessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stage",
+ "columnName": "stage",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "root",
+ "columnName": "root",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "share",
+ "columnName": "share",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupPublicKey",
+ "columnName": "groupPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "publicShares",
+ "columnName": "publicShares",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "joinApprovedAt",
+ "columnName": "joinApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "revealApprovedAt",
+ "columnName": "revealApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "confirmApprovedAt",
+ "columnName": "confirmApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "approvalRequestedThrough",
+ "columnName": "approvalRequestedThrough",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failureReason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_IcebergKeySession_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergKeySession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "IcebergLabelAssignment",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `counter` INTEGER NOT NULL, `label` TEXT NOT NULL, `purpose` TEXT NOT NULL, `assignedAt` INTEGER NOT NULL, PRIMARY KEY(`wallet`, `counter`))",
+ "fields": [
+ {
+ "fieldPath": "wallet",
+ "columnName": "wallet",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "counter",
+ "columnName": "counter",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "label",
+ "columnName": "label",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "purpose",
+ "columnName": "purpose",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "assignedAt",
+ "columnName": "assignedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "wallet",
+ "counter"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_IcebergLabelAssignment_wallet_purpose",
+ "unique": false,
+ "columnNames": [
+ "wallet",
+ "purpose"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergLabelAssignment_wallet_purpose` ON `${TABLE_NAME}` (`wallet`, `purpose`)"
+ }
+ ]
+ },
+ {
+ "tableName": "IcebergLabelLedger",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `label` TEXT NOT NULL, `requestId` TEXT NOT NULL, `messageHash` TEXT NOT NULL, `echoedAt` INTEGER NOT NULL, `signedAt` INTEGER, PRIMARY KEY(`wallet`, `label`))",
+ "fields": [
+ {
+ "fieldPath": "wallet",
+ "columnName": "wallet",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "label",
+ "columnName": "label",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "requestId",
+ "columnName": "requestId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "messageHash",
+ "columnName": "messageHash",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "echoedAt",
+ "columnName": "echoedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signedAt",
+ "columnName": "signedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "wallet",
+ "label"
+ ]
+ }
+ },
+ {
+ "tableName": "IcebergNonceRow",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `counter` INTEGER NOT NULL, `participant` TEXT NOT NULL, `contribution` TEXT NOT NULL, PRIMARY KEY(`wallet`, `counter`, `participant`))",
+ "fields": [
+ {
+ "fieldPath": "wallet",
+ "columnName": "wallet",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "counter",
+ "columnName": "counter",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participant",
+ "columnName": "participant",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contribution",
+ "columnName": "contribution",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "wallet",
+ "counter",
+ "participant"
+ ]
+ }
+ },
+ {
+ "tableName": "IcebergParticipantMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `participantPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `participantPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `IcebergKeySession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKey",
+ "columnName": "participantPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "payload",
+ "columnName": "payload",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "participantPublicKey",
+ "kind"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_IcebergParticipantMessage_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_IcebergParticipantMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "IcebergKeySession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "IcebergShareRow",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wallet` TEXT NOT NULL, `requestId` TEXT NOT NULL, `participant` TEXT NOT NULL, `share` TEXT NOT NULL, PRIMARY KEY(`wallet`, `requestId`, `participant`))",
+ "fields": [
+ {
+ "fieldPath": "wallet",
+ "columnName": "wallet",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "requestId",
+ "columnName": "requestId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participant",
+ "columnName": "participant",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "share",
+ "columnName": "share",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "wallet",
+ "requestId",
+ "participant"
+ ]
+ }
+ },
+ {
+ "tableName": "InReplyToRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`replyingNostrEventId` TEXT NOT NULL, `inReplyToNostrEventId` TEXT NOT NULL, `inReplyToProfilePublicKey` TEXT, `inReplyToRootNostrEventId` TEXT, `inReplyToRootProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`replyingNostrEventId`, `inReplyToNostrEventId`), FOREIGN KEY(`inReplyToProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "replyingNostrEventId",
+ "columnName": "replyingNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "inReplyToNostrEventId",
+ "columnName": "inReplyToNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "inReplyToProfilePublicKey",
+ "columnName": "inReplyToProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootNostrEventId",
+ "columnName": "inReplyToRootNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootProfilePublicKey",
+ "columnName": "inReplyToRootProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "replyingNostrEventId",
+ "inReplyToNostrEventId"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToRootProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "replyingNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToRootNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotCommitResult",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `peerKeyPackageEventId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `isOneMemberInitialGroupCreation` INTEGER NOT NULL, `commitBytes` BLOB NOT NULL, `welcomeBytes` BLOB, `groupInfoBytes` BLOB, `framedCommitBytes` BLOB NOT NULL, `preCommitExporterSecret` BLOB NOT NULL, `obligationId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "peerKeyPackageEventId",
+ "columnName": "peerKeyPackageEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isOneMemberInitialGroupCreation",
+ "columnName": "isOneMemberInitialGroupCreation",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "commitBytes",
+ "columnName": "commitBytes",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "welcomeBytes",
+ "columnName": "welcomeBytes",
+ "affinity": "BLOB"
+ },
+ {
+ "fieldPath": "groupInfoBytes",
+ "columnName": "groupInfoBytes",
+ "affinity": "BLOB"
+ },
+ {
+ "fieldPath": "framedCommitBytes",
+ "columnName": "framedCommitBytes",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "preCommitExporterSecret",
+ "columnName": "preCommitExporterSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "obligationId",
+ "columnName": "obligationId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "MarmotGroupEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `signature` TEXT NOT NULL, `encryptedContent` TEXT NOT NULL, `expiresAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`id`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "encryptedContent",
+ "columnName": "encryptedContent",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "expiresAt",
+ "columnName": "expiresAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotInnerEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `marmotGroupEventId` TEXT, `directMessageRecipientPublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedEventId",
+ "columnName": "quotedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "directMessageRecipientPublicKey",
+ "columnName": "directMessageRecipientPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MarmotGroupEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "marmotGroupEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotKeyPackage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` BLOB NOT NULL, `profile` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`publicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tlsEncodedMarmotKeyPackage",
+ "columnName": "tlsEncodedMarmotKeyPackage",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profile",
+ "columnName": "profile",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "publicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotKeyPackageBundle",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` BLOB NOT NULL, `ncryptsecInitPrivateKey` TEXT NOT NULL, `ncryptsecEncryptionPrivateKey` TEXT NOT NULL, `ncryptsecSignaturePrivateKey` TEXT NOT NULL, `consumed` INTEGER NOT NULL, `rotated` INTEGER NOT NULL, `profile` TEXT, `dTag` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tlsEncodedMarmotKeyPackage",
+ "columnName": "tlsEncodedMarmotKeyPackage",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ncryptsecInitPrivateKey",
+ "columnName": "ncryptsecInitPrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ncryptsecEncryptionPrivateKey",
+ "columnName": "ncryptsecEncryptionPrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ncryptsecSignaturePrivateKey",
+ "columnName": "ncryptsecSignaturePrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "consumed",
+ "columnName": "consumed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rotated",
+ "columnName": "rotated",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profile",
+ "columnName": "profile",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "dTag",
+ "columnName": "dTag",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MarmotKeyPackageBundle_publicKey",
+ "unique": false,
+ "columnNames": [
+ "publicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MarmotKeyPackageBundle_publicKey` ON `${TABLE_NAME}` (`publicKey`)"
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotRouting",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`routingId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `activeFromEpoch` INTEGER NOT NULL, `retiredAtEpoch` INTEGER, PRIMARY KEY(`routingId`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "routingId",
+ "columnName": "routingId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "activeFromEpoch",
+ "columnName": "activeFromEpoch",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retiredAtEpoch",
+ "columnName": "retiredAtEpoch",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "routingId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MarmotRouting_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MarmotRouting_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotPublishObligation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`obligationId` TEXT NOT NULL, `bytes` BLOB NOT NULL, PRIMARY KEY(`obligationId`))",
+ "fields": [
+ {
+ "fieldPath": "obligationId",
+ "columnName": "obligationId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "bytes",
+ "columnName": "bytes",
+ "affinity": "BLOB",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "obligationId"
+ ]
+ }
+ },
+ {
+ "tableName": "MarmotOutboundGate",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`groupId` TEXT NOT NULL, `gate` TEXT NOT NULL, PRIMARY KEY(`groupId`))",
+ "fields": [
+ {
+ "fieldPath": "groupId",
+ "columnName": "groupId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "gate",
+ "columnName": "gate",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "groupId"
+ ]
+ }
+ },
+ {
+ "tableName": "MarmotRetainedEpochSecret",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `epoch` INTEGER NOT NULL, `senderDataSecret` BLOB NOT NULL, `encryptionSecret` BLOB NOT NULL, `leafCount` INTEGER NOT NULL, `exporterSecret` BLOB NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`, `epoch`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epoch",
+ "columnName": "epoch",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "senderDataSecret",
+ "columnName": "senderDataSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "encryptionSecret",
+ "columnName": "encryptionSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "leafCount",
+ "columnName": "leafCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "exporterSecret",
+ "columnName": "exporterSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "chatRoomId",
+ "epoch"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MemberWallet",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`walletId` TEXT NOT NULL, `ownerPublicKey` TEXT NOT NULL, `guardingChatRoomId` TEXT NOT NULL, `chain` TEXT NOT NULL, `walletPrivateKey` TEXT NOT NULL, `label` TEXT, `requestJson` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`walletId`))",
+ "fields": [
+ {
+ "fieldPath": "walletId",
+ "columnName": "walletId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ownerPublicKey",
+ "columnName": "ownerPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "guardingChatRoomId",
+ "columnName": "guardingChatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chain",
+ "columnName": "chain",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "walletPrivateKey",
+ "columnName": "walletPrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "label",
+ "columnName": "label",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "requestJson",
+ "columnName": "requestJson",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "walletId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MemberWallet_ownerPublicKey",
+ "unique": false,
+ "columnNames": [
+ "ownerPublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MemberWallet_ownerPublicKey` ON `${TABLE_NAME}` (`ownerPublicKey`)"
+ },
+ {
+ "name": "index_MemberWallet_guardingChatRoomId",
+ "unique": false,
+ "columnNames": [
+ "guardingChatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MemberWallet_guardingChatRoomId` ON `${TABLE_NAME}` (`guardingChatRoomId`)"
+ }
+ ]
+ },
+ {
+ "tableName": "MemberWalletSpend",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`txid` TEXT NOT NULL, `walletId` TEXT NOT NULL, `psbt` TEXT NOT NULL, `signedTransaction` TEXT NOT NULL, `broadcastAt` INTEGER, `seenAt` INTEGER, `confirmedAt` INTEGER, `replacedByTxid` TEXT, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`txid`))",
+ "fields": [
+ {
+ "fieldPath": "txid",
+ "columnName": "txid",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "walletId",
+ "columnName": "walletId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "psbt",
+ "columnName": "psbt",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signedTransaction",
+ "columnName": "signedTransaction",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "broadcastAt",
+ "columnName": "broadcastAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seenAt",
+ "columnName": "seenAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "confirmedAt",
+ "columnName": "confirmedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "replacedByTxid",
+ "columnName": "replacedByTxid",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "txid"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MemberWalletSpend_walletId",
+ "unique": false,
+ "columnNames": [
+ "walletId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MemberWalletSpend_walletId` ON `${TABLE_NAME}` (`walletId`)"
+ }
+ ]
+ },
+ {
+ "tableName": "Mention",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `mentionedPublicKey` TEXT NOT NULL, `mentioningNostrEventId` TEXT, `relayUrl` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, FOREIGN KEY(`mentionedPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`mentioningNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "mentionedPublicKey",
+ "columnName": "mentionedPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "mentioningNostrEventId",
+ "columnName": "mentioningNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "relayUrl",
+ "columnName": "relayUrl",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "mentionedPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "mentioningNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "NegentropySynchronizeRequest",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `uuid` TEXT NOT NULL, `purpose` TEXT NOT NULL, `status` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `isRecommendedRelay` INTEGER NOT NULL, `level` INTEGER NOT NULL, `synchronizationFilter` TEXT NOT NULL, `ownerPublicKey` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "uuid",
+ "columnName": "uuid",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "purpose",
+ "columnName": "purpose",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isRecommendedRelay",
+ "columnName": "isRecommendedRelay",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "level",
+ "columnName": "level",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "synchronizationFilter",
+ "columnName": "synchronizationFilter",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ownerPublicKey",
+ "columnName": "ownerPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_NegentropySynchronizeRequest_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NegentropySynchronizeRequest_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_NegentropySynchronizeRequest_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NegentropySynchronizeRequest_status` ON `${TABLE_NAME}` (`status`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "NegentropySynchronizeResult",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `status` TEXT NOT NULL, `negentropySynchronizeRequestId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`negentropySynchronizeRequestId`) REFERENCES `SynchronizeNostrEventResult`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "negentropySynchronizeRequestId",
+ "columnName": "negentropySynchronizeRequestId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "SynchronizeNostrEventResult",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "negentropySynchronizeRequestId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "NostrEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `pubKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `sig` TEXT NOT NULL, `relayUrl` TEXT, `quotedNostrEventId` TEXT, `quotedAuthorPublicKey` TEXT, `inReplyToNostrEventId` TEXT, `inReplyToAuthorPublicKey` TEXT, `inReplyToRootNostrEventId` TEXT, `inReplyToRootAuthorPublicKey` TEXT, `repostedNostrEventId` TEXT, `repostedAuthorPublicKey` TEXT, `unsignedNostrEventId` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pubKey",
+ "columnName": "pubKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sig",
+ "columnName": "sig",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayUrl",
+ "columnName": "relayUrl",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "quotedNostrEventId",
+ "columnName": "quotedNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "quotedAuthorPublicKey",
+ "columnName": "quotedAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToNostrEventId",
+ "columnName": "inReplyToNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToAuthorPublicKey",
+ "columnName": "inReplyToAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootNostrEventId",
+ "columnName": "inReplyToRootNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootAuthorPublicKey",
+ "columnName": "inReplyToRootAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "repostedNostrEventId",
+ "columnName": "repostedNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "repostedAuthorPublicKey",
+ "columnName": "repostedAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_NostrEvent_kind",
+ "unique": false,
+ "columnNames": [
+ "kind"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_kind` ON `${TABLE_NAME}` (`kind`)"
+ },
+ {
+ "name": "index_NostrEvent_pubKey",
+ "unique": false,
+ "columnNames": [
+ "pubKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_pubKey` ON `${TABLE_NAME}` (`pubKey`)"
+ },
+ {
+ "name": "index_NostrEvent_quotedNostrEventId",
+ "unique": false,
+ "columnNames": [
+ "quotedNostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_quotedNostrEventId` ON `${TABLE_NAME}` (`quotedNostrEventId`)"
+ },
+ {
+ "name": "index_NostrEvent_inReplyToNostrEventId",
+ "unique": false,
+ "columnNames": [
+ "inReplyToNostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_inReplyToNostrEventId` ON `${TABLE_NAME}` (`inReplyToNostrEventId`)"
+ },
+ {
+ "name": "index_NostrEvent_inReplyToRootNostrEventId",
+ "unique": false,
+ "columnNames": [
+ "inReplyToRootNostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_inReplyToRootNostrEventId` ON `${TABLE_NAME}` (`inReplyToRootNostrEventId`)"
+ }
+ ]
+ },
+ {
+ "tableName": "NostrEventRelay",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`relayURL` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`nostrEventId`, `relayURL`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "nostrEventId",
+ "relayURL"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_NostrEventRelay_relayURL",
+ "unique": false,
+ "columnNames": [
+ "relayURL"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEventRelay_relayURL` ON `${TABLE_NAME}` (`relayURL`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Participant",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `participantPublicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `adminAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, FOREIGN KEY(`participantPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKey",
+ "columnName": "participantPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "adminAt",
+ "columnName": "adminAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "participantPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Post",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `repostId` TEXT, `quote` TEXT, `content` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `replyToId` TEXT, `profilePublicKey` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`profilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyToId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`repostId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "repostId",
+ "columnName": "repostId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "quote",
+ "columnName": "quote",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "replyToId",
+ "columnName": "replyToId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "profilePublicKey",
+ "columnName": "profilePublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Post_profilePublicKey",
+ "unique": false,
+ "columnNames": [
+ "profilePublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_profilePublicKey` ON `${TABLE_NAME}` (`profilePublicKey`)"
+ },
+ {
+ "name": "index_Post_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_Post_replyToId",
+ "unique": false,
+ "columnNames": [
+ "replyToId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_replyToId` ON `${TABLE_NAME}` (`replyToId`)"
+ },
+ {
+ "name": "index_Post_repostId",
+ "unique": false,
+ "columnNames": [
+ "repostId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_repostId` ON `${TABLE_NAME}` (`repostId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "replyToId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Profile",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`publicKey` TEXT NOT NULL, `userName` TEXT, `displayName` TEXT, `picture` TEXT, `banner` TEXT, `website` TEXT, `about` TEXT, `bot` INTEGER, `pronouns` TEXT, `nip05` TEXT, `domain` TEXT, `lud06` TEXT, `lud16` TEXT, `twitter` TEXT, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`publicKey`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userName",
+ "columnName": "userName",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "displayName",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "picture",
+ "columnName": "picture",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "banner",
+ "columnName": "banner",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "website",
+ "columnName": "website",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "about",
+ "columnName": "about",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "bot",
+ "columnName": "bot",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "pronouns",
+ "columnName": "pronouns",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nip05",
+ "columnName": "nip05",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "domain",
+ "columnName": "domain",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lud06",
+ "columnName": "lud06",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lud16",
+ "columnName": "lud16",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "twitter",
+ "columnName": "twitter",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "publicKey"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Profile_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Profile_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "QuotedRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`quotingNostrEventId` TEXT NOT NULL, `quotedNostrEventId` TEXT NOT NULL, `quotedProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`quotingNostrEventId`, `quotedNostrEventId`), FOREIGN KEY(`quotedProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`quotingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`quotedNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "quotingNostrEventId",
+ "columnName": "quotingNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedNostrEventId",
+ "columnName": "quotedNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedProfilePublicKey",
+ "columnName": "quotedProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "quotingNostrEventId",
+ "quotedNostrEventId"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "quotedProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "quotingNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "quotedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Reaction",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `content` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `replyToId` TEXT NOT NULL, `profilePublicKey` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`profilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyToId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "replyToId",
+ "columnName": "replyToId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profilePublicKey",
+ "columnName": "profilePublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Reaction_profilePublicKey",
+ "unique": false,
+ "columnNames": [
+ "profilePublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Reaction_profilePublicKey` ON `${TABLE_NAME}` (`profilePublicKey`)"
+ },
+ {
+ "name": "index_Reaction_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Reaction_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_Reaction_replyToId",
+ "unique": false,
+ "columnNames": [
+ "replyToId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Reaction_replyToId` ON `${TABLE_NAME}` (`replyToId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "replyToId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "RecentSearch",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`query` TEXT NOT NULL, `synchronizationFilters` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`query`))",
+ "fields": [
+ {
+ "fieldPath": "query",
+ "columnName": "query",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "synchronizationFilters",
+ "columnName": "synchronizationFilters",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "query"
+ ]
+ }
+ },
+ {
+ "tableName": "Relay",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`publicKey` TEXT NOT NULL, `type` TEXT NOT NULL, `url` TEXT NOT NULL, `read` INTEGER NOT NULL, `write` INTEGER NOT NULL, PRIMARY KEY(`publicKey`, `type`, `url`))",
+ "fields": [
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "url",
+ "columnName": "url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "read",
+ "columnName": "read",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "write",
+ "columnName": "write",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "publicKey",
+ "type",
+ "url"
+ ]
+ }
+ },
+ {
+ "tableName": "RepostedRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`repostingNostrEventId` TEXT NOT NULL, `repostedNostrEventId` TEXT NOT NULL, `repostedProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`repostingNostrEventId`, `repostedNostrEventId`), FOREIGN KEY(`repostedProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`repostedNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`repostingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "repostingNostrEventId",
+ "columnName": "repostingNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "repostedNostrEventId",
+ "columnName": "repostedNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "repostedProfilePublicKey",
+ "columnName": "repostedProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "repostingNostrEventId",
+ "repostedNostrEventId"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostedProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostingNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "SynchronizeNostrEventRequest",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `purpose` TEXT NOT NULL, `status` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `isRecommendedRelay` INTEGER NOT NULL, `level` INTEGER NOT NULL, `synchronizationFilters` TEXT NOT NULL, `ownerPublicKey` TEXT, `nostrEventId` TEXT, `unsignedNostrEventId` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`unsignedNostrEventId`) REFERENCES `UnsignedNostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "purpose",
+ "columnName": "purpose",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isRecommendedRelay",
+ "columnName": "isRecommendedRelay",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "level",
+ "columnName": "level",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "synchronizationFilters",
+ "columnName": "synchronizationFilters",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ownerPublicKey",
+ "columnName": "ownerPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_SynchronizeNostrEventRequest_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_SynchronizeNostrEventRequest_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_SynchronizeNostrEventRequest_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_SynchronizeNostrEventRequest_status` ON `${TABLE_NAME}` (`status`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "UnsignedNostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "unsignedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "SynchronizeNostrEventResult",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_SynchronizeNostrEventResult_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_SynchronizeNostrEventResult_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "UnsignedNostrEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `pubKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `privateTags` TEXT, `content` TEXT NOT NULL, `signedAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pubKey",
+ "columnName": "pubKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "privateTags",
+ "columnName": "privateTags",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signedAt",
+ "columnName": "signedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_UnsignedNostrEvent_pubKey",
+ "unique": false,
+ "columnNames": [
+ "pubKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_UnsignedNostrEvent_pubKey` ON `${TABLE_NAME}` (`pubKey`)"
+ },
+ {
+ "name": "index_UnsignedNostrEvent_kind",
+ "unique": false,
+ "columnNames": [
+ "kind"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_UnsignedNostrEvent_kind` ON `${TABLE_NAME}` (`kind`)"
+ }
+ ]
+ },
+ {
+ "tableName": "Zap",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `postId` TEXT NOT NULL, `senderPublicKey` TEXT NOT NULL, `receiverPublicKey` TEXT NOT NULL, `message` TEXT, `invoice` TEXT, `amountInMillisatoshis` INTEGER, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`senderPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`receiverPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`postId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "postId",
+ "columnName": "postId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "senderPublicKey",
+ "columnName": "senderPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receiverPublicKey",
+ "columnName": "receiverPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "message",
+ "columnName": "message",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "invoice",
+ "columnName": "invoice",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "amountInMillisatoshis",
+ "columnName": "amountInMillisatoshis",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Zap_senderPublicKey",
+ "unique": false,
+ "columnNames": [
+ "senderPublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Zap_senderPublicKey` ON `${TABLE_NAME}` (`senderPublicKey`)"
+ },
+ {
+ "name": "index_Zap_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Zap_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_Zap_postId",
+ "unique": false,
+ "columnNames": [
+ "postId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Zap_postId` ON `${TABLE_NAME}` (`postId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "senderPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "receiverPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "postId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ }
+ ],
+ "setupQueries": [
+ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '6272f3e8e60bff8f0692fe9061ed56dc')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/composeResources/drawable/compose-multiplatform.xml b/composeApp/src/commonMain/composeResources/drawable/compose-multiplatform.xml
index 1ffc948c..601df181 100644
--- a/composeApp/src/commonMain/composeResources/drawable/compose-multiplatform.xml
+++ b/composeApp/src/commonMain/composeResources/drawable/compose-multiplatform.xml
@@ -1,44 +1,13 @@
-
+
+
+ android:fillColor="#FF3A1A"
+ android:pathData="M0,0 L512,0 L512,512 L0,512 Z"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+ android:fillColor="#000000"
+ android:pathData="M246.31,26.00 C244.88,25.74 243.39,26.79 241.55,28.54 C239.71,30.29 236.15,33.14 235.20,36.48 C234.24,39.82 237.67,41.82 235.83,48.55 C233.99,55.29 227.25,68.63 224.08,76.83 C220.90,85.02 218.77,91.18 216.77,97.79 C214.77,104.40 213.21,110.56 212.00,116.54 C210.80,122.51 209.94,131.37 209.46,133.69 C208.99,136.01 209.62,131.47 209.15,130.51 C208.67,129.56 207.02,130.04 206.60,127.97 C206.19,125.91 206.38,121.30 206.60,118.12 C206.83,114.95 206.99,113.20 207.87,108.91 C208.76,104.62 209.37,99.95 212.00,92.39 C214.64,84.83 221.63,69.74 223.76,63.48 C225.89,57.22 224.97,57.29 224.71,54.91 C224.46,52.52 223.06,50.52 222.17,49.19 C221.28,47.85 220.36,47.50 219.31,46.96 C218.26,46.42 217.31,45.95 215.82,46.01 C214.32,46.07 211.91,46.33 210.42,47.28 C208.92,48.23 207.49,50.24 206.92,51.73 C206.35,53.22 206.70,55.16 206.92,56.18 C207.14,57.19 207.49,57.76 208.19,57.76 C208.89,57.76 210.42,55.86 211.05,56.18 C211.69,56.49 213.59,55.92 212.00,59.67 C210.42,63.42 204.63,72.54 201.52,78.73 C198.41,84.93 195.23,92.07 193.26,96.84 C191.29,101.60 191.04,102.33 189.77,107.32 C188.50,112.31 186.18,123.30 185.64,126.70 C185.10,130.10 184.11,127.43 186.59,127.65 C189.07,127.88 197.71,127.65 200.57,127.97 C203.43,128.29 202.57,128.67 203.74,129.56 C204.92,130.45 206.60,132.10 207.56,133.37 C208.51,134.64 209.78,136.14 209.46,137.18 C209.15,138.23 207.08,138.30 205.65,139.73 C204.22,141.16 213.12,143.70 200.89,145.76 C188.66,147.83 147.13,150.46 132.27,152.12 C117.40,153.77 99.16,154.43 111.62,155.61 C124.07,156.79 190.50,158.21 206.92,159.10 C223.35,159.99 208.29,160.37 210.10,161.01 C211.91,161.65 212.39,162.54 217.72,162.92 C223.06,163.30 237.26,162.82 242.18,163.23 C247.11,163.65 245.84,164.25 247.27,165.46 C248.70,166.67 250.28,168.89 250.76,170.54 C251.24,172.19 251.17,173.72 250.13,175.31 C249.08,176.89 246.16,179.05 244.41,180.07 C242.66,181.09 244.63,181.09 239.64,181.34 C234.66,181.60 219.79,181.28 214.55,181.66 C209.30,182.04 210.42,182.61 208.19,183.57 C205.97,184.52 203.49,185.69 201.20,187.38 C198.92,189.06 196.34,191.44 194.53,193.73 C192.72,196.02 191.36,198.88 190.40,201.04 C189.45,203.20 189.13,204.53 188.81,206.76 C188.50,208.98 188.27,211.84 188.50,214.38 C188.72,216.92 189.07,219.30 190.08,222.00 C191.10,224.71 190.50,225.56 194.53,230.58 C198.57,235.60 208.29,244.56 214.23,252.18 C220.17,259.81 224.97,269.50 230.11,276.33 C235.26,283.16 240.98,287.70 245.04,293.17 C249.11,298.63 249.87,302.38 254.57,309.05 C259.28,315.72 270.14,328.59 273.32,333.19 C276.49,337.80 273.86,334.40 273.63,336.69 C273.41,338.97 275.64,334.08 272.05,346.85 C268.46,359.62 257.05,397.14 252.03,413.25 C247.01,429.35 244.63,436.06 241.87,443.43 C239.10,450.80 237.20,454.45 235.51,457.41 C233.83,460.36 233.51,460.11 231.70,461.22 C229.89,462.33 227.09,463.54 224.71,464.08 C222.33,464.62 219.47,464.55 217.41,464.39 C215.34,464.24 214.13,463.35 212.32,463.12 C210.51,462.90 208.03,462.87 206.60,463.12 C205.17,463.38 204.48,464.08 203.74,464.71 C203.01,465.35 203.81,466.36 202.16,466.94 C200.50,467.51 196.03,467.19 193.90,468.21 C191.77,469.22 189.35,472.59 189.45,472.97 C189.54,473.35 193.10,470.84 194.53,470.43 C195.96,470.02 197.55,470.05 198.03,470.43 C198.50,470.81 197.33,472.11 197.39,472.65 C197.45,473.19 197.71,473.45 198.34,473.61 C198.98,473.77 200.41,473.83 201.20,473.61 C202.00,473.39 200.73,472.65 203.11,472.34 C205.49,472.02 213.97,471.07 215.50,471.70 C217.02,472.34 212.96,474.66 212.32,476.15 C211.69,477.64 210.99,480.69 211.69,480.60 C212.39,480.50 214.93,476.21 216.45,475.51 C217.98,474.81 219.79,476.63 220.90,476.47 C222.01,476.31 220.17,475.58 223.12,474.56 C226.08,473.54 233.45,470.91 238.69,470.43 C243.93,469.95 251.56,471.29 254.57,471.70 C257.59,472.11 256.00,472.75 256.80,472.97 C257.59,473.19 258.64,473.19 259.34,472.97 C260.04,472.75 260.67,472.18 260.93,471.70 C261.18,471.22 260.45,470.37 260.93,470.11 C261.40,469.86 262.67,469.64 263.79,470.11 C264.90,470.59 267.22,473.23 267.60,472.97 C267.98,472.72 266.71,469.64 266.01,468.52 C265.31,467.41 264.64,466.71 263.47,466.30 C262.29,465.89 259.97,466.24 259.02,465.98 C258.07,465.73 258.39,464.78 257.75,464.71 C257.12,464.65 256.54,465.67 255.21,465.67 C253.87,465.67 251.30,465.19 249.81,464.71 C248.32,464.24 247.20,463.60 246.31,462.81 C245.42,462.01 244.57,461.76 244.41,459.95 C244.25,458.14 243.84,457.88 245.36,452.01 C246.89,446.13 248.12,441.59 253.62,424.68 C259.12,407.78 273.54,364.71 278.40,350.67 C283.26,336.62 282.15,343.20 282.85,340.50 C283.55,337.80 283.07,336.31 282.53,334.46 C281.99,332.62 280.94,332.88 279.67,329.38 C278.40,325.89 276.72,317.56 274.91,313.50 C273.09,309.43 270.24,307.24 268.87,304.92 C267.50,302.60 264.10,297.04 266.65,299.52 C269.19,302.00 278.34,313.66 284.12,319.85 C289.90,326.05 298.35,332.81 301.27,336.69 C304.20,340.56 301.18,341.07 301.59,343.04 C302.00,345.01 302.64,342.79 303.81,348.44 C304.99,354.10 306.13,359.81 308.58,377.03 C311.03,394.25 317.06,437.77 318.43,451.69 C319.79,465.60 317.70,458.52 316.84,460.58 C315.98,462.65 315.00,463.22 313.34,464.08 C311.69,464.93 309.53,465.57 306.99,465.67 C304.45,465.76 300.26,464.65 298.10,464.71 C295.94,464.78 295.01,465.41 293.97,465.98 C292.92,466.55 293.39,467.79 291.74,468.21 C290.09,468.62 286.12,467.95 284.12,468.52 C282.12,469.10 280.72,470.49 279.67,471.70 C278.62,472.91 277.54,475.67 277.76,475.83 C277.99,475.99 279.61,473.39 280.94,472.65 C282.28,471.92 284.85,471.29 285.71,471.38 C286.56,471.48 285.61,472.88 286.02,473.29 C286.44,473.70 288.41,473.13 288.25,473.93 C288.09,474.72 285.64,476.69 285.07,478.05 C284.50,479.42 284.50,482.12 284.75,482.18 C285.01,482.25 285.77,479.39 286.66,478.37 C287.55,477.36 289.20,476.24 290.15,476.15 C291.11,476.05 291.65,477.48 292.38,477.74 C293.11,477.99 292.38,478.44 294.60,477.74 C296.83,477.04 302.23,474.56 305.72,473.61 C309.21,472.65 313.92,472.11 315.57,472.02 C317.22,471.92 315.95,472.65 315.57,472.97 C315.19,473.29 314.08,473.04 313.34,473.93 C312.61,474.81 311.53,476.40 311.12,478.37 C310.71,480.34 310.42,485.30 310.80,485.68 C311.18,486.06 312.45,481.39 313.34,480.60 C314.23,479.80 314.62,481.61 316.20,480.91 C317.79,480.22 321.13,477.17 322.87,476.47 C324.62,475.77 325.51,476.15 326.69,476.78 C327.86,477.42 328.97,479.64 329.86,480.28 C330.75,480.91 331.45,479.80 332.09,480.60 C332.72,481.39 333.29,485.04 333.68,485.04 C334.06,485.04 334.37,482.41 334.31,480.60 C334.25,478.79 334.06,475.77 333.36,474.24 C332.66,472.72 329.48,471.70 330.18,471.38 C330.88,471.07 335.96,472.27 337.49,472.34 C339.01,472.40 338.85,472.24 339.39,471.70 C339.93,471.16 340.03,469.41 340.66,469.16 C341.30,468.91 342.41,469.54 343.21,470.11 C344.00,470.68 345.21,472.91 345.43,472.65 C345.65,472.40 345.27,469.73 344.48,468.52 C343.68,467.32 341.68,465.89 340.66,465.35 C339.65,464.81 339.01,465.57 338.44,465.35 C337.87,465.13 337.96,464.14 337.17,464.08 C336.38,464.01 334.79,465.09 333.68,465.03 C332.56,464.97 331.52,464.55 330.50,463.76 C329.48,462.97 328.50,462.01 327.64,460.26 C326.78,458.52 327.58,467.03 325.42,453.28 C323.26,439.52 316.93,394.98 314.62,377.67 C312.30,360.35 312.01,355.97 311.44,349.39 C310.87,342.82 311.37,340.82 311.12,338.28 C310.87,335.73 310.58,335.48 309.85,334.15 C309.12,332.81 308.01,332.46 306.67,330.33 C305.34,328.21 298.32,321.50 301.91,321.44 C305.50,321.38 319.22,327.95 328.28,330.02 C337.33,332.08 351.21,333.03 356.23,333.83 C361.25,334.62 356.80,333.35 358.45,334.78 C360.11,336.21 363.95,340.56 366.08,342.41 C368.21,344.25 370.37,345.74 371.16,345.90 C371.96,346.06 370.05,343.10 370.84,343.36 C371.64,343.61 375.13,347.11 375.93,347.49 C376.72,347.87 375.04,345.42 375.61,345.58 C376.18,345.74 378.88,348.35 379.42,348.44 C379.96,348.54 378.25,346.15 378.79,346.22 C379.33,346.28 382.12,348.51 382.60,348.76 C383.08,349.01 381.71,348.03 381.65,347.81 C381.58,347.58 381.11,347.08 382.28,347.49 C383.46,347.90 388.00,350.35 388.63,350.35 C389.27,350.35 385.78,347.65 386.09,347.49 C386.41,347.33 389.81,349.33 390.54,349.39 C391.27,349.46 389.81,347.49 390.54,347.81 C391.27,348.12 394.45,351.21 394.99,351.30 C395.53,351.40 393.50,348.70 393.72,348.44 C393.94,348.19 395.78,349.62 396.26,349.71 C396.74,349.81 396.26,348.92 396.58,349.08 C396.89,349.24 398.23,351.84 398.16,350.67 C398.10,349.49 395.94,342.88 396.26,342.09 C396.58,341.29 399.91,346.00 400.07,345.90 C400.23,345.80 397.59,342.31 397.21,341.45 C396.83,340.59 397.43,340.56 397.85,340.82 C398.26,341.07 400.01,344.15 399.75,343.04 C399.50,341.93 396.80,335.73 396.26,334.15 C395.72,332.56 396.10,333.26 396.58,333.51 C397.05,333.76 399.50,336.69 399.12,335.73 C398.74,334.78 395.08,329.22 394.35,327.79 C393.62,326.36 394.42,327.09 394.67,327.16 C394.92,327.22 397.78,331.06 395.94,328.11 C394.10,325.16 391.40,319.91 383.55,309.37 C375.70,298.82 359.09,276.96 348.92,264.89 C338.76,252.82 330.88,244.78 322.56,236.94 C314.23,229.09 306.61,223.18 299.05,217.88 C291.49,212.57 282.75,208.03 277.13,205.17 C271.51,202.31 268.87,201.77 265.37,200.72 C261.88,199.67 259.08,199.20 256.16,198.81 C253.24,198.43 250.86,198.18 247.90,198.50 C244.95,198.81 240.85,199.86 238.37,200.72 C235.89,201.58 235.29,201.93 232.97,203.58 C230.65,205.23 226.68,209.04 224.39,210.57 C222.11,212.09 220.74,212.41 219.31,212.79 C217.88,213.17 216.93,213.01 215.82,212.79 C214.70,212.57 213.66,212.38 212.64,211.52 C211.62,210.66 210.26,209.04 209.78,207.71 C209.30,206.38 209.53,204.85 209.78,203.58 C210.03,202.31 210.57,201.20 211.37,200.08 C212.16,198.97 213.34,197.80 214.55,196.91 C215.75,196.02 216.93,195.32 218.68,194.68 C220.42,194.05 221.28,193.41 225.03,193.10 C228.78,192.78 237.10,193.10 241.23,192.78 C245.36,192.46 246.89,192.14 249.81,191.19 C252.73,190.24 256.23,188.81 258.70,187.06 C261.18,185.31 263.31,183.09 264.74,180.71 C266.17,178.32 267.06,175.56 267.28,172.76 C267.50,169.97 267.03,166.82 266.01,163.87 C264.99,160.92 263.72,158.31 261.24,154.97 C258.77,151.64 249.08,145.51 251.08,143.86 C253.08,142.20 265.44,144.33 273.32,145.13 C281.20,145.92 290.85,147.25 298.41,148.62 C305.97,149.99 311.60,151.32 318.74,153.39 C325.89,155.45 341.36,161.11 341.30,161.01 C341.24,160.92 325.48,154.97 318.43,152.75 C311.37,150.53 307.09,149.26 299.05,147.67 C291.01,146.08 278.40,144.24 270.14,143.22 C261.88,142.20 253.30,142.04 249.49,141.63 C245.68,141.22 244.73,140.90 247.27,140.68 C249.81,140.46 254.41,139.82 264.74,140.36 C275.06,140.90 297.78,142.68 309.21,143.86 C320.65,145.03 326.85,146.17 333.36,147.35 C339.87,148.53 348.99,151.07 348.29,150.84 C347.59,150.62 335.36,147.41 329.23,146.08 C323.10,144.75 319.79,144.01 311.44,142.90 C303.08,141.79 290.63,140.30 279.03,139.41 C267.44,138.52 248.54,138.07 241.87,137.50 C235.20,136.93 238.59,136.87 239.01,135.91 C239.42,134.96 242.41,132.96 244.41,131.78 C246.41,130.61 247.33,129.78 251.08,128.92 C254.83,128.07 264.52,135.34 266.96,126.70 C269.41,118.06 265.79,87.69 265.69,77.14 C265.60,66.60 265.79,66.28 266.33,63.48 C266.87,60.69 268.23,60.85 268.87,60.31 C269.50,59.77 269.76,59.99 270.14,60.31 C270.52,60.62 270.52,62.05 271.09,62.21 C271.66,62.37 272.78,62.28 273.63,61.26 C274.49,60.24 275.86,57.67 276.18,56.18 C276.49,54.68 276.02,53.48 275.54,52.36 C275.06,51.25 274.27,50.24 273.32,49.50 C272.36,48.77 271.16,48.17 269.82,47.92 C268.49,47.66 267.28,47.28 265.37,47.92 C263.47,48.55 260.36,49.89 258.39,51.73 C256.42,53.57 254.80,56.33 253.62,59.04 C252.45,61.74 252.10,61.58 251.40,67.93 C250.70,74.28 250.22,88.83 249.49,97.16 C248.76,105.48 247.81,112.66 246.95,117.81 C246.09,122.95 245.46,126.00 244.41,127.97 C243.36,129.94 240.60,133.75 240.60,129.56 C240.60,125.37 243.23,115.96 244.41,102.87 C245.58,89.79 246.85,60.46 247.58,51.09 C248.32,41.72 248.06,48.33 248.86,46.65 C249.65,44.96 252.13,43.69 252.35,40.93 C252.57,38.16 251.14,32.60 250.13,30.13 C249.11,27.65 247.74,26.25 246.31,26.00 Z"/>
+
diff --git a/composeApp/src/commonMain/composeResources/values/strings.xml b/composeApp/src/commonMain/composeResources/values/strings.xml
index c1fbb96b..83c4127f 100644
--- a/composeApp/src/commonMain/composeResources/values/strings.xml
+++ b/composeApp/src/commonMain/composeResources/values/strings.xml
@@ -21,21 +21,18 @@
"XML file ... is not valid. Check the file content."
-->
Abandoned
+ Abandon
+ Abandon ceremony
+ Abandon this key ceremony?
+ It ends for everyone in it. No key is created, and the ceremony can be started again.
Abandoned. Nothing was signed.
All
Bennu
- Add a dialect the group can translate into
- Add artifact to library
- Add artifact to the group library
- Add chapter
- Add dialect
Add to group
- Add translation
After this there is no turning back.
All broadcasts are queued so that we can manage data usage on metered connections.
Any amount
ARTICLE
- Artifact detail
As long as you control your keys there can be no dispute about who YOU actually is.
Back
Backup confirmation
@@ -46,16 +43,11 @@
BIP39 seed with the standard BIP84 derivation path. The profile\'s nostr key comes off the same seed, so these 12 words restore both.
Block user
Cancel
- Chapter detail
- Chapter name
- Chapter translation
- Chapters
Choose who to chat with
Close
Cloud backup
Copy URL
Could not unlock your phrase. Please try again.
- Country
Create chat
Create new chat
Create profile
@@ -71,9 +63,6 @@
Currently no messages have been shared.\nBreak the ice.
Declined to sign
Delete group
- Details
- Dialect name
- Dialects
Direct message detail
Direct message functionality will be here.
Direct message via npub
@@ -82,20 +71,12 @@
Download
Download and securely store everything needed to recover this profile and the coins it holds.
Edit profile
- eg. Chapter 1 — The Beginning
- eg. First Edition
- eg. https://harper.com/2-kill-Bird
- eg. Lesotho
- eg. Sesotho
- eg. st
- eg. To Kill a Mocking Bird
Emergency kit
ENDED
Encrypt and back your recovery information up to your Google Drive or iCloud.
Enough members took part without you.
Enter the name you want to use for your group
Enter the name you want to use for your profile
- Enter the translation for this chunk
Events are indexed so that we can deliver a premium local first experience.
Everything else
Everything is cryptographical sound. Just announcing your profile to the world.
@@ -113,7 +94,6 @@
I have saved my recovery phrase somewhere safe.
I understand that if I lose this phone and my recovery phrase, I lose this profile and the funds in its wallet.
If you are new to Bennu or just want to create a fresh profile
- Initial version label
Input npub... or nip05
Introduce yourself
Invite
@@ -126,7 +106,6 @@
Key
Key package management
Key recovery
- Language
Learn more
Leave group
Remove from group
@@ -156,7 +135,6 @@
Name
Name (eg. Alan Turing)
Name (eg. Group Discussions)
- Name of artifact
Needs you
Needs your review.
Network relays
@@ -166,29 +144,17 @@
Not backed up yet
New chat
Next
- No artifacts exists in this groups library.
- No chapters.
- No chapters yet.
No chat message relays were found for this user.
- No chunks.
- No dialects have been defined in this group yet. Add one from the group's detail screen first.
- No dialects have been defined in this group.
No messages. Go to a profile and send them a message.
No one selected yet
No one to add yet.
No projects exists in this group.
No proposal has been abandoned.
- No translations yet.
- No versions.
Not now
Nothing is waiting for your signature.
Nothing was created and no key exists. It is safe to run it again.
Open chat
- Original
- Original text
- Original text (markdown)
✓ Paid
- Paste the chapter's markdown. Blank lines separate paragraphs into chunks.
Pay
Pay now
Post
@@ -201,11 +167,6 @@
Profiles
Projects
Proposals
- Propose
- Propose artifact
- Propose chapter
- Propose dialect
- Propose translation
Publish new key package
Re-broadcast
Asked the members who have not answered to take another look
@@ -261,11 +222,15 @@
Something went wrong and we were unable to sign in to your provided profile. Please try again later.
Something went wrong and we were unable to sign you up. Please try again later.
Something went wrong and we were unable to write a new note. Please try again later.
- Source dialect
Start
Start a group chat
Start chat via npub or nip05
Start key ceremony
+ This room was made from a key the group already holds, so it can't run a key ceremony of its own. A subgroup's ceremony is started from the group's details.
+ A shared key needs at least %1$s members to split it between.
+ Couldn't load this group.
+ Couldn't read your keys.
+ Couldn't start the key ceremony.
Startup error
Taking part with these members
Tap to load
@@ -277,12 +242,8 @@
The group has a shared key.
The recovery phrase (sometimes called a seed) is a list of 12 English words. It is the only way back to this profile: the key that signs as you, and the wallet that holds your coins, are both derived from it.\n\nOnly you have this phrase. Keep it private — nobody from Bennu will ever ask you for it.\n\nDo not lose it. Write it down and keep it somewhere safe that is not this phone. If you lose both the phone and the phrase, this profile and its funds are gone for good.
These are your keys. Keep them safe so they can keep unlocking this profile and its coins, even when you lose or change your phone.
- This artifact has no version for a translation to be of.
- This artifact has no version for a chapter to attach to.
- This chapter has no chunks.
This device holds no phrase for the profile that is signed in.
This decides who can change the group later. You can't switch afterwards.
- This group has no shared key, so it cannot sign them in.
This group has not been asked to sign anything yet.
This group has not signed anything yet.
This is fixed once the ceremony runs. Changing it later means generating a new key.
@@ -300,12 +261,6 @@
Could not sign out. Please try again.
This will give you write access to the profile.
Bennu broadcasts what you publish to a distributed set of relays, so it stays decentralised.
- Translate chunk
- Translate into which dialect?
- Translated text
- Translation
- Translation detail
- Translations
Transmit note
Trending notes functionality coming soon. In the meantime search for what you are looking for.
Try again
@@ -314,9 +269,6 @@
Unlocking your phrase…
Unsupported event kind
Untitled article
- Url
- Version
- Versions
View and accept invites you may have received to stay connected with others.
View invites
Waiting for you
@@ -348,15 +300,9 @@
Your profile is almost ready... just getting it's first cryptographic signature together.
Your share of it is on this device only. Your wallet backup restores it — nobody else's share can.
- Add chapter to %1$s
Add people to %1$s
Ask all %1$s again
Asked again about all %1$s proposals
- Chapter %1$s
- Chapter %1$s · %2$s words · %3$s characters
- Chunk %1$s
- Chunks (%1$s)
- %1$s/%2$s chunks translated
%1$s event(s) still unreadable%2$s
%1$s events, signed together
Everyone has to be online at the same time — the ceremony can only finish once all %1$s of you have taken part.
@@ -385,11 +331,9 @@
%1$s sent a private message to %2$s
Shared key for %1$s
to join the %1$s chat room.
- Translate %1$s
Unsupported event kind: %1$s
%1$s was created, but %2$s couldn't be added yet. Invite them again from the chat once they're on Bennu.
%1$s was created, but its shared key ceremony couldn't be started. Open the chat and start it from the group's details — until then the group has no key of its own.
- %1$s words · %2$s characters
#%1$s
You and %1$s others
You aren't following anyone yet.
@@ -434,104 +378,7 @@
Check the combined result and confirm it
The group has its key — finish setting it up
Open
- Nostr profile
- This group hasn't said anything about itself on Nostr yet.
-
- Not described yet
- Edit Nostr profile
- Propose Nostr profile
- What the group says about itself on Nostr
- The group signs this, so it takes a quorum. An empty field unsays what the group had said.
- This group has no shared key, so it cannot sign a profile. Run a shared key ceremony first.
- Signed by the group on %1$s
- No name on this profile
- About
- Picture url
- Website
- Nostr address
- Lightning address
- eg. Translation collective
- eg. A group translating hard books into Sesotho
- eg. https://example.com/group.png
- eg. https://example.com
- eg. group@example.com
- eg. group@getalby.com
- Couldn't ask the group to sign this profile.
- Relays
- Edit relays
- Not set yet
- No relays in this list
-
- %1$s of %2$s lists agreed
- Where the group lives on Nostr
- The group signs each list, so it takes a quorum. Only the lists you change are proposed.
- This group has no shared key, so it cannot sign a relay list. Run a shared key ceremony first.
- Relay url
- eg. wss://relay.example.com
- Add relay
- That isn't a relay address. Relays start with wss:// and cannot be on this device.
- That relay is already in this list.
- Propose relays
- Nothing has changed, so there is nothing to propose.
- Couldn't ask the group to sign these relays.
- Read
- Write
- General
- Messages
- Search
- Blocked
- Where the group publishes, and where a reader should look for it.
- Where a message addressed to the group should be sent.
- The relays a search of the group's work runs against.
- Relays the group will not talk to.
- A group signs and cannot decrypt, so every list here is public — including the blocked one, which most clients keep private.
- Signed %1$s
- Posts
- Add post
- Propose post
- This group hasn't posted anything yet.
-
- No posts yet
- 1 post
- %1$s posts
- What should the group say?
- The group signs a post, so it takes a quorum. It goes out in the group's name, not yours.
- This group has no shared key, so it cannot sign a post. Run a shared key ceremony first.
- A post needs something to say.
- Couldn't ask the group to sign this post.
- Posted %1$s
- A reply
- Propose event
- Paste an unsigned Nostr event for the group to sign. It is filed by kind: a profile (kind 0), a post (kind 1) or a relay list.
- The group signs it, so it takes a quorum. The author is the group and the time is now, whatever the paste says about either.
- This group has no shared key, so it cannot sign an event. Run a shared key ceremony first.
- Couldn't ask the group to sign this event.
- Unsigned event
- {"kind": 1, "tags": [], "content": "…"}
- What the group would sign
- Kind %1$s
- That isn't JSON.
- An event is a JSON object with a kind, tags and content.
- An event needs a kind.
- Kind %1$s has nowhere to go on the group's screen. It can file kinds %2$s.
- Tags must be a list of lists of strings.
- Content must be text.
- The content isn't a profile. A kind 0 carries a JSON object of profile fields.
Ask again
-
- Broadcast
- Sends the event to each relay below, exactly as the group signed it. Any member holding it can send it: the signature is the group's, not yours.
- Where the group has said it lives is filled in. Add or remove relays before sending.
- No relays to broadcast to. Add one above.
- Add a relay to broadcast to.
- Sending…
- Accepted
- Rejected: %1$s
- Couldn't send: %1$s
- No answer
- Accepted by %1$s of %2$s relays.
- Copy raw JSON
- Copied the raw JSON
A password-protected key (ncryptsec) is not supported yet. Decrypt it in the app it came from and paste the nsec.
Enter a recovery phrase or an nsec to sign in.
@@ -611,6 +458,8 @@
Group onchain wallet
Group onchain wallet on %1$s
+
+ %1$s onchain wallet
Open a group onchain wallet
Not opened yet
Open on %1$s
@@ -618,6 +467,28 @@
Opening a wallet asks the group to agree that it keeps coins here. Any quorum of members can then spend them together, and nobody can spend them alone.
Each member's share of the group's key is stored unencrypted on their device. Anyone with an unlocked device, or a copy of its data, holds that member's share.
Couldn't ask the group to open a wallet.
+ The groups above this one have agreed to guard its wallet. In a guarded wallet each of them can spend any coin that has waited as long as its own delay, without this group agreeing:
+ Open a guarded wallet
+ Open without guardians
+ Guarded wallets
+ Spend
+ Spend from %1$s's guarded wallet
+ Wallets of groups below this one. This group can spend a coin in each once the coin has waited as long as the delay that wallet gives this group.
+ %1$s sats within this group's reach
+ Fund
+ Fund %1$s's guarded wallet
+ %1$s sats arriving
+ To
+ %1$s's guarded wallet
+ This group can spend these coins again once they have waited %1$s.
+ Finding an address in %1$s's wallet…
+ Wait for this group's open payments to %1$s to confirm.
+ Tell the groups above
+ Not yet shared with the groups above that you're in
+ Share
+ Shared with the groups above
+ Couldn't share the wallet
+ Guarded: the groups above this one can spend any coin here that has waited as long as their own delay:
Balance
%1$s sats
%1$s sats on the way
@@ -664,6 +535,7 @@
Fee rate in sats per byte
Ask the group to send
Sends %1$s sats, with a fee of %2$s sats.
+ Sends %1$s sats to %2$s's guarded wallet, with a fee of %3$s sats.
%1$s sats come back to the group as change.
That isn't an address on %1$s.
The group has nothing confirmed to spend yet.
@@ -682,7 +554,7 @@
Signed, sending it to the network
Sent, waiting for a confirmation
Confirmed
- Replaced by a later spend
+ Replaced by another spend of the same coins
Send again
Bump the fee
Sent again
@@ -707,7 +579,6 @@
Each contribution is encrypted to the members who will hold it. Your randomness starts shaping the key here.
Confirming publishes your public share and a hash of every commitment you saw, so the group can check it agrees.
%1$s of 3 steps
- Couldn't start the key ceremony.
Couldn't approve this step.
Your share of this key is stored unencrypted on this device, as the onchain wallet's is.
Lightning wallet
@@ -779,4 +650,171 @@
Anyone can pay this offer, as often as they like, without asking for an invoice first. It pays the group's node, the one the group signed for.
Copy offer
Offer copied
+
+
+ The subgroup's wallet
+ Guarded wallet
+ Unguarded wallet
+ This group can spend any coin in it once it has waited as long as the delay below.
+ This group, after the delay below, and the %1$d above it, after the delays they chose, can spend any coin in it.
+ Only the subgroup can spend from its wallet. Groups above it can't reach it or anything beneath it.
+ This group is guarded, so its subgroups are too.
+ This group's own guardian keys can't be read, so it can't guard a subgroup.
+ The subgroup's wallet will be guarded: this group can spend any coin in it once it has waited %1$s, and each group above it after the delay it chose.
+ The subgroup's wallet will not be guarded: only the subgroup can spend from it.
+ The group above this one decided this group's wallet is guarded. Each group above it can spend any coin in it that has waited as long as its own delay, without this group agreeing:
+ The group above this one decided this group's wallet is not guarded. Only this group can spend from it.
+
+
+ %1$s, %2$s
+ %1$s: after %2$s
+ How long before this group can spend a coin
+ 1 hour
+ 2 hours
+ 1 day
+ 1 week
+ 1 month
+ 6 months
+ Longest
+ Custom
+ Delay in blocks
+ A coin the subgroup moves starts waiting again, so a long delay lets it keep its coins out of reach by moving them.
+ A group above this one
+ This group can spend a coin here after %1$s
+ Guarded wallet, after %1$s
+ Only coins that have waited %1$s can be spent from this guarded wallet.
+
+ - %1$s block
+ - %1$s blocks
+
+
+ - about %1$d minute
+ - about %1$d minutes
+
+
+ - about %1$d hour
+ - about %1$d hours
+
+
+ - about %1$d day
+ - about %1$d days
+
+
+ - about %1$d month
+ - about %1$d months
+
+
+ - about %1$d year
+ - about %1$d years
+
+
+
+ New guarded wallet
+ A group
+ Choose a group to guard it
+ None of your groups guards members' wallets yet. A group's signers can turn it on from the group's page.
+ A wallet only you can spend from, guarded by %1$s
+ %1$s can take any coin in it that has waited %2$s, without asking you.
+ %1$s can take any coin in it that has waited %2$s, and the group above it any coin that has waited %3$s, without asking you.
+ %1$s can take any coin in it that has waited %2$s, and each of the %3$d groups above it after the delay it chose, the shortest %4$s, without asking you.
+ Members of the groups that guard it will see its balance, and that it's yours.
+ If you lose this device, those groups can still move your coins for you.
+ Label (optional)
+ Ask %1$s
+ Asked %1$s to guard a wallet.
+ Couldn't ask the group to guard a wallet.
+ This profile can only look, so it can't sign a request.
+ Only a group with a shared key can guard a wallet.
+ This device doesn't know what this group signs with yet, so it can't work out the group's leaves.
+ Ask the group for its key
+ Asked. A member who holds the group's key will answer when their device next reads the room.
+ This group's guardian keys can't be read by this version of the app.
+ Guarded wallets for members aren't offered on this network yet.
+ This profile has no wallet of its own to watch the chain with, so it couldn't see its own coins.
+ %1$s would refuse this request: it was asked before the group said it guards members' wallets. Asking again makes a new one.
+ %1$s has changed its delay since you asked. Asking again makes a new request at the new delay.
+ %1$s has stopped guarding members' wallets, so this request won't be signed. You can discard it.
+ %1$s would refuse this request. Asking again makes a new one.
+ Guards members' wallets
+ Doesn't guard members' wallets
+ Stopped guarding new members' wallets
+ After %1$s
+ Guard members' wallets
+ How long before this group can take a coin from a member's wallet
+ A coin the member moves starts waiting again, so a long delay lets them keep their coins out of reach by moving them.
+ Wallets already guarded keep the delay they were guarded at.
+ Members whose app is older than this one can only be guarded at 12 blocks, and don't know this group can close.
+ Ask the group
+ Stop guarding new wallets
+ Stop guarding new members' wallets?
+ Wallets already guarded stay guarded, and this group can still take their coins after their delay.
+ Stop
+ Couldn't ask the group.
+ This group doesn't guard members' wallets.
+ This group has stopped guarding members' wallets.
+ You have no guarded wallets.
+ Waiting for someone in %1$s to put it to the group
+ %1$s is signing
+ %1$s didn't sign. Ask again, or discard it.
+ Key on another device
+ You're no longer in %1$s. It still guards this wallet.
+ Guarded by %1$s
+ Guarded by %1$s, below %2$s
+ this group
+ a group below %1$s
+ a group below this one
+ another group
+ the wallet guarded by %1$s
+ Spend from %1$s as %2$s
+ Members' wallets
+ %1$s, %2$s
+
+ - %1$d wallet
+ - %1$d wallets
+
+
+ - guarded by %1$d group
+ - guarded by %1$d groups
+
+ Fund %1$s's guarded wallet “%2$s”
+ Spend from %1$s's guarded wallet “%2$s”
+ Fund %1$s's wallet guarded by %2$s
+ Spend from %1$s's wallet guarded by %2$s
+ Discard
+ Discard this wallet?
+ Its key is forgotten. No address of it was ever offered, so nothing can have been paid to it.
+ Export key
+ Export this wallet's key?
+ Whoever holds these descriptors can spend every coin in this wallet. Keep them where only you can reach them.
+ Show key
+ Receive descriptor
+ Change descriptor
+ Copied.
+ Copy
+ Finding your coins…
+ %1$s took %2$s sats through its guardian leaf, in %3$s.
+ Taken by guardians
+ This wallet's key is on another of your devices, so it can be watched here but not spent from.
+ Couldn't ask again.
+ Couldn't discard the wallet.
+ %1$s sats come back to this wallet as change.
+ This wallet has nothing confirmed to spend.
+ This wallet doesn't have that much confirmed.
+ Send from your guarded wallet
+ You sign this alone, and it is sent as soon as you press the button.
+ Sending needs this wallet's key on this device, a group's certificate for it, and a wallet of this profile's own to watch the chain with.
+ Sign and send
+ Sent.
+ Couldn't send.
+ Your spends
+ Sent, waiting for the network to report it
+ In the mempool
+ @%1$s
+ Members' guarded wallets
+ Ask this group to guard a wallet for you
+ Asked by %1$s, not yet signed
+ Put to the group
+ Couldn't put it to the group.
+ Wallets your groups guard
+ This device tells the groups above about these on its own when it can. Share now if a group above hasn't heard.
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/BennuDatabase.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/BennuDatabase.kt
index 540db2c3..0be9bae1 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/BennuDatabase.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/BennuDatabase.kt
@@ -19,6 +19,7 @@ import com.machankura.bennu.compose.database.model.IcebergParticipantMessage
import com.machankura.bennu.compose.database.model.IcebergKeySession
import com.machankura.bennu.compose.database.model.GroupTransaction
import com.machankura.bennu.compose.database.dao.GroupTransactionDao
+import com.machankura.bennu.compose.database.dao.MemberWalletDao
import androidx.room3.ColumnTypeConverters
import androidx.room3.AutoMigration
import androidx.room3.ConstructedBy
@@ -43,19 +44,6 @@ import com.machankura.bennu.compose.database.dao.GiftWrapSealDao
import com.machankura.bennu.compose.database.dao.GroupKeyStateDao
import com.machankura.bennu.compose.database.dao.GroupSignedEventDao
import com.machankura.bennu.compose.database.dao.InReplyToRelationDao
-import com.machankura.bennu.compose.database.dao.MantraArtifactDao
-import com.machankura.bennu.compose.database.dao.MantraArtifactVersionDao
-import com.machankura.bennu.compose.database.dao.MantraChapterDao
-import com.machankura.bennu.compose.database.dao.MantraChunkDao
-import com.machankura.bennu.compose.database.dao.MantraDao
-import com.machankura.bennu.compose.database.dao.MantraDialectDao
-import com.machankura.bennu.compose.database.dao.MantraTranslationArtifactVersionDao
-import com.machankura.bennu.compose.database.dao.MantraTranslationArtifactVersionContributorDao
-import com.machankura.bennu.compose.database.dao.MantraTranslationChapterDao
-import com.machankura.bennu.compose.database.dao.MantraTranslationChapterContributorDao
-import com.machankura.bennu.compose.database.dao.MantraTranslationChunkDao
-import com.machankura.bennu.compose.database.dao.MantraTranslationDao
-import com.machankura.bennu.compose.database.dao.MantraTranslationContributorDao
import com.machankura.bennu.compose.database.dao.MarmotCommitResultDao
import com.machankura.bennu.compose.database.dao.MarmotOutboundDao
import com.machankura.bennu.compose.database.dao.MarmotGroupEventDao
@@ -98,18 +86,6 @@ import com.machankura.bennu.compose.database.model.GiftWrapSeal
import com.machankura.bennu.compose.database.model.GroupKeyState
import com.machankura.bennu.compose.database.model.GroupSignedEvent
import com.machankura.bennu.compose.database.model.InReplyToRelation
-import com.machankura.bennu.compose.database.model.MantraArtifact
-import com.machankura.bennu.compose.database.model.MantraArtifactVersion
-import com.machankura.bennu.compose.database.model.MantraChapter
-import com.machankura.bennu.compose.database.model.MantraChunk
-import com.machankura.bennu.compose.database.model.MantraDialect
-import com.machankura.bennu.compose.database.model.MantraTranslation
-import com.machankura.bennu.compose.database.model.MantraTranslationArtifactVersion
-import com.machankura.bennu.compose.database.model.MantraTranslationArtifactVersionContributor
-import com.machankura.bennu.compose.database.model.MantraTranslationChapter
-import com.machankura.bennu.compose.database.model.MantraTranslationChapterContributor
-import com.machankura.bennu.compose.database.model.MantraTranslationChunk
-import com.machankura.bennu.compose.database.model.MantraTranslationContributor
import com.machankura.bennu.compose.database.model.MarmotCommitResult
import com.machankura.bennu.compose.database.model.MarmotGroupEvent
import com.machankura.bennu.compose.database.model.MarmotInnerEvent
@@ -120,6 +96,8 @@ import com.machankura.bennu.compose.database.model.MarmotPublishObligation
import com.machankura.bennu.compose.database.model.MarmotOutboundGate
import com.machankura.bennu.compose.managers.MarmotEngine
import com.machankura.bennu.compose.database.model.MarmotRetainedEpochSecret
+import com.machankura.bennu.compose.database.model.MemberWallet
+import com.machankura.bennu.compose.database.model.MemberWalletSpend
import com.machankura.bennu.compose.database.model.Mention
import com.machankura.bennu.compose.database.model.NegentropySynchronizeRequest
import com.machankura.bennu.compose.database.model.NegentropySynchronizeResult
@@ -181,18 +159,6 @@ val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L)
IcebergParticipantMessage::class,
IcebergShareRow::class,
InReplyToRelation::class,
- MantraArtifact::class,
- MantraArtifactVersion::class,
- MantraChapter::class,
- MantraChunk::class,
- MantraDialect::class,
- MantraTranslation::class,
- MantraTranslationArtifactVersion::class,
- MantraTranslationArtifactVersionContributor::class,
- MantraTranslationChapter::class,
- MantraTranslationChapterContributor::class,
- MantraTranslationChunk::class,
- MantraTranslationContributor::class,
MarmotCommitResult::class,
MarmotGroupEvent::class,
MarmotInnerEvent::class,
@@ -202,6 +168,8 @@ val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L)
MarmotPublishObligation::class,
MarmotOutboundGate::class,
MarmotRetainedEpochSecret::class,
+ MemberWallet::class,
+ MemberWalletSpend::class,
Mention::class,
NegentropySynchronizeRequest::class,
NegentropySynchronizeResult::class,
@@ -220,7 +188,7 @@ val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L)
UnsignedNostrEvent::class,
Zap::class
],
- version = 30,
+ version = 32,
autoMigrations = [
// v2 only adds the DkgSession/DkgParticipantMessage tables, so Room can
// generate the migration itself — nothing existing changes shape.
@@ -408,19 +376,38 @@ val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L)
// nothing is rebuilt; a rebuild of either signing table would fire the
// cascades from FrostSigningSession, see docs/frost-batch-signing.md.
AutoMigration(from = 25, to = 26),
- // v27 is the group Lightning wallet's key ceremony (docs/group-lightning-wallet.md,
- // Phase 5): the IcebergKeySession and IcebergParticipantMessage tables. Two new
- // tables and nothing else, which Room migrates itself.
- AutoMigration(from = 26, to = 27),
- // v28 is the Lightning wallet's node seed (docs/group-lightning-wallet.md, Phase 6):
- // the GroupLightningSeed table, keyed by the node id each seed produces.
+ // v27 drops the nip30303 document tables and MarmotInnerEvent's
+ // payloadEventId, and deletes the chat lines nothing renders any more
+ // (docs/ceremony-creation.md, Phase 8). Manual -- it deletes rows --
+ // so it is MIGRATION_26_27 in `getRoomDatabase`, not an entry here.
+ //
+ // v28 adds the nullable GroupTransaction.guardedChatRoomId: the descendant
+ // whose guarded wallet a guardian's spend draws from
+ // (docs/group-wallet-guardians.md, Phase 7). Every spend before it was the
+ // room's own, which is what null means.
AutoMigration(from = 27, to = 28),
- // v29 is the co-signing protocol (docs/group-lightning-wallet.md, Phase 9): seven new
- // tables, from the round-one pool to the per-channel ledger. Nothing existing changes.
+ // v29 adds the nullable DkgSession.walletPolicy: the wallet policy a
+ // subgroup's ceremony was proposed under (docs/subgroup-wallet-policy.md,
+ // Phase 2). Every ceremony before it chose none, which is what null means.
AutoMigration(from = 28, to = 29),
- // v30 is what members keep of the operator's reports (docs/group-lightning-wallet.md,
- // Phases 10 and 11): the newest snapshot, the payments, the invoices. Three new tables.
+ // v30 adds MemberWallet and MemberWalletSpend: the random key of a
+ // guarded wallet one member holds and a group guards, and the spends the
+ // member signed alone from it (docs/member-guarded-wallets.md, Phase 5).
+ // New tables, and no foreign keys -- deleting a group's room must never
+ // delete a key coins may sit behind.
AutoMigration(from = 29, to = 30),
+ // v31 adds the nullable DkgSession.guardianDelay: the delay a guarded
+ // subgroup's ceremony was proposed under for the parent's own leaf
+ // (docs/guardian-delay.md, Phase 4). Null for every ceremony before it.
+ AutoMigration(from = 30, to = 31),
+ // v32 is the group Lightning wallet (docs/group-lightning-wallet.md): the Iceberg key
+ // ceremony (IcebergKeySession, IcebergParticipantMessage), the node seed
+ // (GroupLightningSeed), the co-signing protocol (seven Iceberg tables, from the round-one
+ // pool to the per-channel ledger), and what members keep of the operator's reports
+ // (GroupLightningSnapshotRow, GroupLightningPaymentRow, GroupLightningInvoiceRow). New
+ // tables and nothing else. They were four versions on the branch that built them, before
+ // it merged after v31; no installed database ever had those, so they are one step here.
+ AutoMigration(from = 31, to = 32),
]
)
@ConstructedBy(BennuDatabaseConstructor::class)
@@ -457,6 +444,8 @@ abstract class BennuDatabase: RoomDatabase() {
abstract fun groupTransactionDao(): GroupTransactionDao
+ abstract fun memberWalletDao(): MemberWalletDao
+
abstract fun connectionDao(): ConnectionDao
abstract fun giftWrapMessageDao(): GiftWrapMessageDao
@@ -467,31 +456,6 @@ abstract class BennuDatabase: RoomDatabase() {
abstract fun inReplyToRelationDao(): InReplyToRelationDao
- abstract fun mantraDao(): MantraDao
-
- abstract fun mantraArtifactDao(): MantraArtifactDao
-
- abstract fun mantraArtifactVersionDao(): MantraArtifactVersionDao
-
- abstract fun mantraChapterDao(): MantraChapterDao
-
- abstract fun mantraChunkDao(): MantraChunkDao
-
- abstract fun mantraDialectDao(): MantraDialectDao
-
- abstract fun mantraTranslationArtifactVersionDao(): MantraTranslationArtifactVersionDao
-
- abstract fun mantraTranslationArtifactVersionContributorDao(): MantraTranslationArtifactVersionContributorDao
-
- abstract fun mantraTranslationChapterDao(): MantraTranslationChapterDao
-
- abstract fun mantraTranslationChapterContributorDao(): MantraTranslationChapterContributorDao
-
- abstract fun mantraTranslationChunkDao(): MantraTranslationChunkDao
-
- abstract fun mantraTranslationDao(): MantraTranslationDao
-
- abstract fun mantraTranslationContributorDao(): MantraTranslationContributorDao
abstract fun icebergKeySessionDao(): IcebergKeySessionDao
@@ -558,6 +522,11 @@ abstract class BennuDatabase: RoomDatabase() {
useWriterConnection { transactor ->
transactor.immediateTransaction {
// TODO: Actually delete the data...
+ //
+ // When this does: MemberWallet holds the only copy of keys that
+ // coins may sit behind (docs/member-guarded-wallets.md, D6). A
+ // caller wiping a profile that holds an open member wallet has to
+ // say so first and offer the key's export, before anything goes.
}
}
}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/builder/PlatformDatabaseBuilder.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/builder/PlatformDatabaseBuilder.kt
index 13e5f002..6c4ae40e 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/builder/PlatformDatabaseBuilder.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/builder/PlatformDatabaseBuilder.kt
@@ -6,6 +6,7 @@ import com.machankura.bennu.compose.database.migrations.MIGRATION_3_4
import com.machankura.bennu.compose.database.migrations.MIGRATION_9_10
import com.machankura.bennu.compose.database.migrations.MIGRATION_13_14
import com.machankura.bennu.compose.database.migrations.MIGRATION_14_15
+import com.machankura.bennu.compose.database.migrations.MIGRATION_26_27
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
@@ -19,13 +20,15 @@ fun getRoomDatabase(
builder: RoomDatabase.Builder
): com.machankura.bennu.compose.database.BennuDatabase {
return builder
- // Everything else Room generates itself. These four move data rather than
+ // Everything else Room generates itself. These five move data rather than
// only changing shape, which an AutoMigration cannot express: 3->4 rewrites
// chat rows, 9->10 copies a session's per-event columns onto the items
// table before dropping them, 13->14 renames a column and rewrites the
- // chat rows that named it the old way, and 14->15 adds a column and deletes
- // the chat rows written for messages from before this device joined.
- .addMigrations(MIGRATION_3_4, MIGRATION_9_10, MIGRATION_13_14, MIGRATION_14_15)
+ // chat rows that named it the old way, 14->15 adds a column and deletes
+ // the chat rows written for messages from before this device joined, and
+ // 26->27 drops the document tables and deletes the chat rows nothing
+ // renders any more.
+ .addMigrations(MIGRATION_3_4, MIGRATION_9_10, MIGRATION_13_14, MIGRATION_14_15, MIGRATION_26_27)
.setDriver(BundledSQLiteDriver())
.setQueryCoroutineContext(Dispatchers.IO)
.build()
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraArtifactDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraArtifactDao.kt
deleted file mode 100644
index 9fb30e42..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraArtifactDao.kt
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.machankura.bennu.compose.database.dao
-
-import androidx.room3.Dao
-import androidx.room3.Query
-import androidx.room3.Upsert
-import com.machankura.bennu.compose.database.model.MantraArtifact
-
-@Dao
-interface MantraArtifactDao {
- @Upsert
- suspend fun upsert(mantraArtifact: MantraArtifact)
-
- @Query("SELECT * FROM MantraArtifact WHERE chatRoomId = :chatRoomId ORDER BY createdAt DESC")
- suspend fun getArtifactsByChatRoomId(chatRoomId: String): List
-
- @Query("SELECT * FROM MantraArtifact WHERE id = :id")
- suspend fun getArtifactById(id: String): MantraArtifact?
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraArtifactVersionDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraArtifactVersionDao.kt
deleted file mode 100644
index 845c191d..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraArtifactVersionDao.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.machankura.bennu.compose.database.dao
-
-import androidx.room3.Dao
-import androidx.room3.Insert
-import androidx.room3.OnConflictStrategy.Companion.IGNORE
-import androidx.room3.Query
-import androidx.room3.Upsert
-import com.machankura.bennu.compose.database.model.MantraArtifactVersion
-
-@Dao
-interface MantraArtifactVersionDao {
- @Upsert
- suspend fun upsert(mantraArtifactVersion: MantraArtifactVersion)
-
- @Query("SELECT * FROM MantraArtifactVersion WHERE artifactId = :artifactId ORDER BY createdAt DESC")
- suspend fun getArtifactVersionsByArtifactId(artifactId: String): List
-
- @Query("SELECT * FROM MantraArtifactVersion WHERE id = :id")
- suspend fun getArtifactVersionById(id: String): MantraArtifactVersion?
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraChapterDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraChapterDao.kt
deleted file mode 100644
index c25108e6..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraChapterDao.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.machankura.bennu.compose.database.dao
-
-import androidx.room3.Dao
-import androidx.room3.Insert
-import androidx.room3.OnConflictStrategy.Companion.IGNORE
-import androidx.room3.Query
-import androidx.room3.Upsert
-import com.machankura.bennu.compose.database.model.MantraChapter
-
-@Dao
-interface MantraChapterDao {
- @Upsert
- suspend fun upsert(mantraChapter: MantraChapter)
-
- /** Chapters across all versions of an artifact, ordered by their in-book index. */
- @Query(
- """
- SELECT MantraChapter.* FROM MantraChapter
- INNER JOIN MantraArtifactVersion
- ON MantraChapter.artifactVersionId = MantraArtifactVersion.id
- WHERE MantraArtifactVersion.artifactId = :artifactId
- ORDER BY MantraChapter.`index` ASC
- """
- )
- suspend fun getChaptersByArtifactId(artifactId: String): List
-
- @Query("SELECT * FROM MantraChapter WHERE artifactVersionId = :artifactVersionId ORDER BY `index` ASC")
- suspend fun getChaptersByArtifactVersionId(artifactVersionId: String): List
-
- @Query("SELECT * FROM MantraChapter WHERE id = :id")
- suspend fun getChapterById(id: String): MantraChapter?
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraChunkDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraChunkDao.kt
deleted file mode 100644
index e0913038..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraChunkDao.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.machankura.bennu.compose.database.dao
-
-import androidx.room3.Dao
-import androidx.room3.Insert
-import androidx.room3.OnConflictStrategy.Companion.IGNORE
-import androidx.room3.Query
-import androidx.room3.Upsert
-import com.machankura.bennu.compose.database.model.MantraChunk
-
-@Dao
-interface MantraChunkDao {
- @Upsert
- suspend fun upsert(mantraChunk: MantraChunk)
-
- @Query("SELECT * FROM MantraChunk WHERE chapterId = :chapterId ORDER BY `index` ASC")
- suspend fun getChunksByChapterId(chapterId: String): List
-
- @Query("SELECT * FROM MantraChunk WHERE id = :id")
- suspend fun getChunkById(id: String): MantraChunk?
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraDao.kt
deleted file mode 100644
index 5cf51b92..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraDao.kt
+++ /dev/null
@@ -1,216 +0,0 @@
-package com.machankura.bennu.compose.database.dao
-
-import androidx.room3.Dao
-import androidx.room3.Transaction
-import co.touchlab.kermit.Logger
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.machankura.bennu.compose.database.BennuDatabase
-import com.machankura.bennu.compose.database.model.ChatMessage
-import com.machankura.bennu.compose.database.model.MantraArtifactVersion
-import com.machankura.bennu.compose.database.model.MantraDialect
-import com.machankura.bennu.compose.database.model.MarmotInnerEvent
-import com.machankura.bennu.compose.database.model.intermdiate.LocalChatRoom
-import com.machankura.bennu.compose.nostr.nip30303.ArtifactVersionEvent
-import com.machankura.bennu.compose.nostr.nip30303.DialectEvent
-import com.machankura.bennu.compose.nostr.nip30303.SubmissionEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.ArtifactIdTag
-import com.machankura.bennu.compose.repository.MantraRepository.Companion.DEFAULT_LICENSE
-import com.machankura.bennu.compose.repository.MantraRepository.Companion.DEFAULT_VISIBILITY
-import kotlin.time.Instant
-
-@Dao
-abstract class MantraDao(
- private val database: BennuDatabase,
-) {
- val logger = Logger.withTag("NostrDao")
-
- /**
- * The unsigned nip30303 event [template] describes, authored by [publicKey].
- *
- * Its id is computed the same way the matching Mantra* entity computes
- * its own, so the row on disk and the payload on the wire are the same
- * event rather than two copies of one.
- */
- private fun rumorOf(
- template: EventTemplate,
- publicKey: HexKey,
- ): Event = Event(
- id = EventHasher.hashId(
- pubKey = publicKey,
- createdAt = template.createdAt,
- kind = template.kind,
- tags = template.tags,
- content = template.content,
- ),
- pubKey = publicKey,
- createdAt = template.createdAt,
- kind = template.kind,
- tags = template.tags,
- content = template.content,
- // A rumor. What signs for this reaching the group is the kind:445 the
- // outbound pipeline wraps it in, not the payload itself.
- sig = "",
- )
-
- /**
- * Queue [payload] for the group inside a [SubmissionEvent] that
- * [submitterPublicKey] authors.
- *
- * nip30303 events are never sent on their own. Wrapping them means the
- * payload keeps whoever wrote it as its author while the group still knows
- * which member put it there -- see [SubmissionEvent] for why the two are
- * worth telling apart.
- *
- * The submission is stored as an unprocessed rumor (null marmotGroupEventId),
- * which is what the outbound pipeline picks up and encrypts into a kind:445
- * group event for the chat room.
- */
- private suspend fun submitToGroup(
- chatRoomId: String,
- submitterPublicKey: HexKey,
- payload: Event,
- text: String,
- ): MarmotInnerEvent {
- val submissionTemplate = SubmissionEvent.build(payload = payload)
-
- val submissionInnerEvent = MarmotInnerEvent(
- id = EventHasher.hashId(
- pubKey = submitterPublicKey,
- createdAt = submissionTemplate.createdAt,
- kind = submissionTemplate.kind,
- tags = submissionTemplate.tags,
- content = submissionTemplate.content,
- ),
- publicKey = submitterPublicKey,
- kind = SubmissionEvent.KIND,
- createdAt = Instant.fromEpochSeconds(submissionTemplate.createdAt),
- tags = submissionTemplate.tags,
- content = submissionTemplate.content,
- payloadEventId = payload.id,
- chatRoomId = chatRoomId,
- )
-
- sendMarmotInnerEvent(
- chatRoomId = chatRoomId,
- userPublicKey = submitterPublicKey,
- text = text,
- marmotInnerEvent = submissionInnerEvent,
- )
-
- return submissionInnerEvent
- }
-
- @Transaction
- open suspend fun addDialect(
- localChatRoom: LocalChatRoom,
- name: String,
- country: String,
- language: String,
- userPublicKey: HexKey,
- ): MantraDialect? {
- logger.d("addDialect: $name")
-
- val dialectEventTemplate = DialectEvent.build(
- name = name,
- country = country,
- language = language,
- )
-
- val mantraDialect = MantraDialect.fromDialectEventTemplate(
- dialectEventTemplate = dialectEventTemplate,
- chatRoomId = localChatRoom.chatRoom.id,
- userPublicKey = userPublicKey,
- ) ?: return null
-
- return try {
- database.mantraDialectDao().upsert(mantraDialect)
-
- submitToGroup(
- chatRoomId = mantraDialect.chatRoomId,
- submitterPublicKey = userPublicKey,
- payload = rumorOf(dialectEventTemplate, userPublicKey),
- text = "Added $name as a dialect",
- )
-
- mantraDialect
- } catch (error: Throwable) {
- logger.e("Failed to add dialect \"$name\" to chat room ${localChatRoom.chatRoom.id}", error)
- null
- }
-
- }
-
- @Transaction
- open suspend fun addArtifactVersion(
- localChatRoom: LocalChatRoom,
- artifactId: HexKey,
- versionLabel: String,
- userPublicKey: HexKey,
- ): MantraArtifactVersion? {
- return addArtifactVersionInternal(
- localChatRoom = localChatRoom,
- artifactId = artifactId,
- versionLabel = versionLabel,
- userPublicKey = userPublicKey
- )
- }
-
- private suspend fun addArtifactVersionInternal(
- localChatRoom: LocalChatRoom,
- artifactId: HexKey,
- versionLabel: String,
- userPublicKey: HexKey,
- ): MantraArtifactVersion? {
- // The version label is carried in the event content (see
- // MantraArtifactVersion.fromArtifactVersionEvent).
- val artifactVersionEventTemplate = ArtifactVersionEvent.build(
- content = versionLabel,
- ) {
- addUnique(ArtifactIdTag.assemble(artifactId))
- }
-
- val mantraArtifactVersion = MantraArtifactVersion.fromArtifactVersionEventTemplate(
- artifactVersionEventTemplate = artifactVersionEventTemplate,
- chatRoomId = localChatRoom.chatRoom.id,
- userPublicKey = userPublicKey,
- ) ?: return null
-
- database.mantraArtifactVersionDao().upsert(mantraArtifactVersion)
-
- submitToGroup(
- chatRoomId = mantraArtifactVersion.chatRoomId,
- submitterPublicKey = userPublicKey,
- payload = rumorOf(artifactVersionEventTemplate, userPublicKey),
- text = "Add the ${artifactVersionEventTemplate.content} version",
- )
-
- return mantraArtifactVersion
- }
-
- private suspend fun sendMarmotInnerEvent(
- chatRoomId: String,
- userPublicKey: HexKey,
- text: String,
- marmotInnerEvent: MarmotInnerEvent
- ) {
- database.marmotInnerEventDao().upsert(
- marmotInnerEvent
- )
-
- database.chatMessageDao().upsert(
- ChatMessage(
- content = text,
- chatRoomId = chatRoomId,
- senderPublicKey = userPublicKey,
- isUserMessage = true,
- giftWrapPayloadId = null,
- marmotGroupEventId = null,
- marmotInnerEventId = marmotInnerEvent.id,
- )
- )
- // TODO: Depending on visibility (if signature is non-empty) might want to queue this event for broadcasting...
- }
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraDialectDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraDialectDao.kt
deleted file mode 100644
index 1d4b7f40..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraDialectDao.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.machankura.bennu.compose.database.dao
-
-import androidx.room3.Dao
-import androidx.room3.Insert
-import androidx.room3.OnConflictStrategy.Companion.IGNORE
-import androidx.room3.Query
-import androidx.room3.Upsert
-import com.machankura.bennu.compose.database.model.MantraDialect
-
-@Dao
-interface MantraDialectDao {
- @Upsert
- suspend fun upsert(mantraDialect: MantraDialect)
-
- @Query("SELECT * FROM MantraDialect WHERE chatRoomId = :chatRoomId ORDER BY name")
- suspend fun getDialectsByChatRoomId(chatRoomId: String): List
-
- @Query("SELECT * FROM MantraDialect WHERE id = :id")
- suspend fun getDialectById(id: String): MantraDialect?
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationArtifactVersionContributorDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationArtifactVersionContributorDao.kt
deleted file mode 100644
index b15910d7..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationArtifactVersionContributorDao.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.machankura.bennu.compose.database.dao
-
-import androidx.room3.Dao
-import androidx.room3.Upsert
-import com.machankura.bennu.compose.database.model.MantraTranslationArtifactVersionContributor
-
-@Dao
-interface MantraTranslationArtifactVersionContributorDao {
- @Upsert
- suspend fun upsert(mantraTranslationArtifactVersionContributor: MantraTranslationArtifactVersionContributor)
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationArtifactVersionDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationArtifactVersionDao.kt
deleted file mode 100644
index ca26aca6..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationArtifactVersionDao.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.machankura.bennu.compose.database.dao
-
-import androidx.room3.Dao
-import androidx.room3.Insert
-import androidx.room3.OnConflictStrategy.Companion.IGNORE
-import androidx.room3.Query
-import androidx.room3.Upsert
-import com.machankura.bennu.compose.database.model.MantraTranslationArtifactVersion
-
-@Dao
-interface MantraTranslationArtifactVersionDao {
- @Upsert
- suspend fun upsert(mantraTranslationArtifactVersion: MantraTranslationArtifactVersion)
-
- /** Translations targeting any version of an artifact. */
- @Query(
- """
- SELECT MantraTranslationArtifactVersion.* FROM MantraTranslationArtifactVersion
- INNER JOIN MantraArtifactVersion
- ON MantraTranslationArtifactVersion.artifactVersionId = MantraArtifactVersion.id
- WHERE MantraArtifactVersion.artifactId = :artifactId
- ORDER BY MantraTranslationArtifactVersion.createdAt DESC
- """
- )
- suspend fun getTranslationsByArtifactId(artifactId: String): List
-
- /**
- * Translations of one version, which is what a chapter of that version has
- * to be scaffolded into. Narrower than [getTranslationsByArtifactId]: a
- * chapter belongs to a version, and a translation of an older version is
- * not a translation the chapter is in.
- */
- @Query(
- """
- SELECT * FROM MantraTranslationArtifactVersion
- WHERE artifactVersionId = :artifactVersionId
- ORDER BY createdAt DESC
- """
- )
- suspend fun getTranslationsByArtifactVersionId(artifactVersionId: String): List
-
- @Query("SELECT * FROM MantraTranslationArtifactVersion WHERE id = :id")
- suspend fun getTranslationById(id: String): MantraTranslationArtifactVersion?
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationChapterContributorDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationChapterContributorDao.kt
deleted file mode 100644
index f5826cb7..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationChapterContributorDao.kt
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.machankura.bennu.compose.database.dao
-
-import androidx.room3.Dao
-import androidx.room3.Upsert
-import com.machankura.bennu.compose.database.model.MantraTranslationChapter
-import com.machankura.bennu.compose.database.model.MantraTranslationChapterContributor
-
-@Dao
-interface MantraTranslationChapterContributorDao {
- @Upsert
- suspend fun upsert(mantraTranslationChapterContributor: MantraTranslationChapterContributor)
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationChapterDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationChapterDao.kt
deleted file mode 100644
index 9cb71940..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationChapterDao.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.machankura.bennu.compose.database.dao
-
-import androidx.room3.Dao
-import androidx.room3.Insert
-import androidx.room3.OnConflictStrategy.Companion.IGNORE
-import androidx.room3.Query
-import androidx.room3.Upsert
-import com.machankura.bennu.compose.database.model.MantraTranslationChapter
-
-@Dao
-interface MantraTranslationChapterDao {
- @Upsert
- suspend fun upsert(mantraTranslationChapter: MantraTranslationChapter)
-
- @Query("SELECT * FROM MantraTranslationChapter WHERE translationArtifactVersionId = :translationArtifactVersionId ORDER BY `index` ASC")
- suspend fun getTranslationChaptersByTranslationArtifactVersionId(translationArtifactVersionId: String): List
-
- @Query("SELECT * FROM MantraTranslationChapter WHERE id = :id")
- suspend fun getTranslationChapterById(id: String): MantraTranslationChapter?
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationChunkDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationChunkDao.kt
deleted file mode 100644
index a80eca2d..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationChunkDao.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.machankura.bennu.compose.database.dao
-
-import androidx.room3.Dao
-import androidx.room3.Insert
-import androidx.room3.OnConflictStrategy.Companion.IGNORE
-import androidx.room3.Query
-import androidx.room3.Upsert
-import com.machankura.bennu.compose.database.model.MantraTranslationChunk
-
-@Dao
-interface MantraTranslationChunkDao {
- @Upsert
- suspend fun upsert(mantraTranslationChunk: MantraTranslationChunk)
-
- @Query("SELECT * FROM MantraTranslationChunk WHERE translationChapterId = :translationChapterId ORDER BY `index` ASC")
- suspend fun getTranslationChunksByTranslationChapterId(translationChapterId: String): List
-
- /**
- * Every translation this chapter holds of one source chunk.
- *
- * There should only ever be one, and this is how that is kept true: a
- * retranslation is a new event with a new id rather than an edit, so the
- * row it replaces has to be found and dropped.
- */
- @Query("SELECT * FROM MantraTranslationChunk WHERE translationChapterId = :translationChapterId AND chunkId = :chunkId")
- suspend fun getTranslationChunksByChunkId(
- translationChapterId: String,
- chunkId: String
- ): List
-
- @Query("DELETE FROM MantraTranslationChunk WHERE id = :id")
- suspend fun deleteById(id: String)
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationContributorDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationContributorDao.kt
deleted file mode 100644
index da5ce79e..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationContributorDao.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.machankura.bennu.compose.database.dao
-
-import androidx.room3.Dao
-import androidx.room3.Upsert
-import com.machankura.bennu.compose.database.model.MantraTranslationContributor
-
-@Dao
-interface MantraTranslationContributorDao {
- @Upsert
- suspend fun upsert(mantraTranslationContributor: MantraTranslationContributor)
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationDao.kt
deleted file mode 100644
index 0c13bb3f..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MantraTranslationDao.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.machankura.bennu.compose.database.dao
-
-import androidx.room3.Dao
-import androidx.room3.Insert
-import androidx.room3.OnConflictStrategy.Companion.IGNORE
-import androidx.room3.Upsert
-import com.machankura.bennu.compose.database.model.MantraTranslation
-
-@Dao
-interface MantraTranslationDao {
- @Upsert
- suspend fun upsert(mantraTranslation: MantraTranslation)
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MarmotInnerEventDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MarmotInnerEventDao.kt
index 8867b41c..55e790a6 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MarmotInnerEventDao.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MarmotInnerEventDao.kt
@@ -65,12 +65,4 @@ interface MarmotInnerEventDao {
@Query("DELETE FROM MarmotInnerEvent WHERE id = :id")
suspend fun deleteById(id: String)
- /**
- * Drop the submissions carrying [payloadEventId].
- *
- * A submission's id is the envelope's, not the payload's, so a superseded
- * nip30303 event cannot be un-queued by its own id.
- */
- @Query("DELETE FROM MarmotInnerEvent WHERE payloadEventId = :payloadEventId")
- suspend fun deleteByPayloadEventId(payloadEventId: String)
}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MemberWalletDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MemberWalletDao.kt
new file mode 100644
index 00000000..fc279727
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/MemberWalletDao.kt
@@ -0,0 +1,46 @@
+package com.machankura.bennu.compose.database.dao
+
+import androidx.room3.Dao
+import androidx.room3.Query
+import androidx.room3.Upsert
+import com.machankura.bennu.compose.database.model.MemberWallet
+import com.machankura.bennu.compose.database.model.MemberWalletSpend
+import kotlinx.coroutines.flow.Flow
+
+@Dao
+abstract class MemberWalletDao {
+ @Query("SELECT * FROM MemberWallet WHERE ownerPublicKey = :ownerPublicKey ORDER BY createdAt DESC")
+ abstract suspend fun getByOwner(ownerPublicKey: String): List
+
+ @Query("SELECT * FROM MemberWallet WHERE ownerPublicKey = :ownerPublicKey ORDER BY createdAt DESC")
+ abstract fun observeByOwner(ownerPublicKey: String): Flow>
+
+ @Query("SELECT * FROM MemberWallet WHERE walletId = :walletId")
+ abstract suspend fun getById(walletId: String): MemberWallet?
+
+ @Query("SELECT * FROM MemberWallet WHERE guardingChatRoomId = :chatRoomId ORDER BY createdAt DESC")
+ abstract suspend fun getByGuardingChatRoomId(chatRoomId: String): List
+
+ @Upsert
+ abstract suspend fun upsert(wallet: MemberWallet)
+
+ /**
+ * Deletes a wallet's key. `MemberWalletManager.discard` is the only caller,
+ * and only for a wallet no group has certified: before then no address was
+ * ever offered, so no coin can be behind the key.
+ */
+ @Query("DELETE FROM MemberWallet WHERE walletId = :walletId")
+ abstract suspend fun delete(walletId: String)
+
+ @Query("SELECT * FROM MemberWalletSpend WHERE walletId = :walletId ORDER BY createdAt DESC")
+ abstract suspend fun getSpends(walletId: String): List
+
+ @Query("SELECT * FROM MemberWalletSpend WHERE walletId = :walletId ORDER BY createdAt DESC")
+ abstract fun observeSpends(walletId: String): Flow>
+
+ @Query("SELECT * FROM MemberWalletSpend WHERE txid = :txid")
+ abstract suspend fun getSpend(txid: String): MemberWalletSpend?
+
+ @Upsert
+ abstract suspend fun upsertSpend(spend: MemberWalletSpend)
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/NostrDao.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/NostrDao.kt
index 8d792e4f..c538144a 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/NostrDao.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/dao/NostrDao.kt
@@ -1536,8 +1536,12 @@ abstract class NostrDao(
is GroupEventResult.ProposalStaged -> {
database.marmotOutboundDao().commitStagedProposals(localChatRoom)
}
+ // Every application message lands here -- chat, documents, and the
+ // ceremony and signing messages handled just below. Debug, because at
+ // info it read like a failure on each of them and sent at least one
+ // investigation the wrong way.
else -> {
- logger.i("No app logic to handle: $groupEventResult")
+ logger.d("No membership change to file for: $groupEventResult")
}
}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/migrations/RemoveDocumentsMigration.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/migrations/RemoveDocumentsMigration.kt
new file mode 100644
index 00000000..c936df0b
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/migrations/RemoveDocumentsMigration.kt
@@ -0,0 +1,80 @@
+package com.machankura.bennu.compose.database.migrations
+
+import androidx.room3.migration.Migration
+import androidx.sqlite.SQLiteConnection
+import androidx.sqlite.execSQL
+
+/**
+ * Drops the nip30303 document tables, and the chat lines nothing can show any more.
+ *
+ * The artifact, chapter, dialect and translation screens were unreachable, and
+ * their kinds shared numbers with the key ceremony's: a subgroup's round 1 (30312)
+ * was read as a document submission and landed in the parent's chat as raw hex.
+ * See docs/ceremony-creation.md, Phases 7 and 8.
+ *
+ * Manual rather than an `AutoMigration`, because it deletes chat rows as well as
+ * changing shape:
+ *
+ * - the lines the removed document arms wrote (`artifact`, `chapter`, `dialect`,
+ * `translationArtifactVersion`, `translation`), which nothing renders now;
+ * - the `unsupported` lines written for a ceremony's own messages. They are the
+ * raw-hex bubbles above, found by the kind of the inner event behind them, and
+ * only those: an `unsupported` line over any other kind is still the only trace
+ * an unrecognised payload leaves, and stays.
+ *
+ * Then the twelve tables, children before parents. No kept table has a foreign key
+ * into any of them, so nothing outside them cascades; the order is so the drops
+ * hold if foreign keys are ever enforced during a migration. And
+ * `MarmotInnerEvent.payloadEventId`, which only a submission ever set.
+ *
+ * `DROP COLUMN` is safe for the reason `ChronicleRenameMigration` gives for
+ * `RENAME COLUMN`: `getRoomDatabase` pins `BundledSQLiteDriver` on every platform,
+ * so the SQLite underneath is one this app chose. The column has no index and is
+ * in no foreign key, either of which SQLite would refuse to drop it from.
+ *
+ * `GroupSignedEvent` keeps any rows of the document kinds. The table is generic
+ * and keyed by kind, nothing reads those kinds any more, and deleting what a group
+ * signed is not this migration's call. The chronicle's column and its lines stay
+ * too: the chronicle is kept, carrying nothing.
+ */
+val MIGRATION_26_27 = object : Migration(26, 27) {
+ override suspend fun migrate(connection: SQLiteConnection) {
+ connection.execSQL(
+ "DELETE FROM `ChatMessage` WHERE `messageType` IN " +
+ "('artifact', 'chapter', 'dialect', 'translationArtifactVersion', 'translation')"
+ )
+ connection.execSQL(
+ "DELETE FROM `ChatMessage` WHERE `messageType` = 'unsupported' " +
+ "AND `marmotInnerEventId` IN (" +
+ "SELECT `id` FROM `MarmotInnerEvent` WHERE `kind` BETWEEN $FIRST_CEREMONY_KIND AND $LAST_CEREMONY_KIND)"
+ )
+
+ DOCUMENT_TABLES.forEach { table -> connection.execSQL("DROP TABLE IF EXISTS `$table`") }
+
+ connection.execSQL("ALTER TABLE `MarmotInnerEvent` DROP COLUMN `payloadEventId`")
+ }
+}
+
+/**
+ * The ceremony's kinds, written out rather than read from `DkgRitualEvents`: a
+ * migration has to keep meaning what it meant when it shipped, whatever the
+ * constants later say.
+ */
+private const val FIRST_CEREMONY_KIND = 30310
+private const val LAST_CEREMONY_KIND = 30316
+
+/** Children before parents. */
+internal val DOCUMENT_TABLES = listOf(
+ "MantraTranslationContributor",
+ "MantraTranslation",
+ "MantraTranslationArtifactVersionContributor",
+ "MantraTranslationChapterContributor",
+ "MantraTranslationChunk",
+ "MantraTranslationChapter",
+ "MantraTranslationArtifactVersion",
+ "MantraChunk",
+ "MantraChapter",
+ "MantraArtifactVersion",
+ "MantraArtifact",
+ "MantraDialect",
+)
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/ChatMessage.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/ChatMessage.kt
index 561bb0a8..b37c1cbc 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/ChatMessage.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/ChatMessage.kt
@@ -6,6 +6,9 @@ import com.machankura.bennu.compose.text.grouped
import fr.acinq.bitcoin.Satoshi
import com.machankura.bennu.compose.nostr.lightning.GroupLightningAuthorisationEvent
import com.machankura.bennu.compose.nostr.lightning.GroupLightningWalletStatementEvent
+import com.machankura.bennu.compose.text.describe
+import com.machankura.bennu.compose.text.BlockDuration
+import com.machankura.bennu.compose.nostr.wallet.MemberWalletPolicyEvent
import androidx.room3.Entity
import androidx.room3.ForeignKey
import androidx.room3.Index
@@ -18,8 +21,13 @@ import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
import com.machankura.bennu.compose.database.model.traits.UserViewableEntity
import com.machankura.bennu.compose.exceptions.MarmotUnprocessableInnerEventException
import com.machankura.bennu.compose.managers.ChronicleManager
+import com.machankura.bennu.compose.managers.MemberWalletManager
+import com.machankura.bennu.compose.nostr.wallet.GroupKeyNoticeEvent
+import com.machankura.bennu.compose.nostr.wallet.MemberWalletCertificateEvent
+import com.machankura.bennu.compose.nostr.wallet.MemberWalletRequestEvent
import com.machankura.bennu.compose.managers.GroupKeyStateManager
import com.machankura.bennu.compose.managers.GroupWalletManager
+import com.machankura.bennu.compose.managers.GuardianManager
import com.machankura.bennu.compose.managers.SubgroupManager
import com.machankura.bennu.compose.extensions.toHex
import com.vitorpamplona.quartz.marmot.GroupEventResult
@@ -29,9 +37,10 @@ import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair
import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent
-import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent
-import com.machankura.bennu.compose.nostr.GroupNostrProfile
-import com.machankura.bennu.compose.nostr.GroupRelaySet
+import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent
+import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent
+import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
+import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
import com.vitorpamplona.quartz.nipC7Chats.ChatEvent
import com.machankura.bennu.compose.nostr.dkg.DkgRitualEvents
import com.machankura.bennu.compose.nostr.frost.FrostSigningEvents
@@ -39,20 +48,9 @@ import com.machankura.bennu.compose.nostr.frost.GroupKeyStateEvent
import com.machankura.bennu.compose.nostr.subgroup.SubgroupBirthCertificateEvent
import com.machankura.bennu.compose.nostr.wallet.GroupWallet
import com.machankura.bennu.compose.nostr.wallet.GroupWalletStatementEvent
-import com.machankura.bennu.compose.nostr.nip30303.ArtifactEvent
-import com.machankura.bennu.compose.nostr.nip30303.ArtifactVersionEvent
-import com.machankura.bennu.compose.nostr.nip30303.ChapterEvent
-import com.machankura.bennu.compose.nostr.nip30303.ChunkEvent
-import com.machankura.bennu.compose.nostr.nip30303.DialectEvent
+import com.machankura.bennu.compose.nostr.wallet.GuardedWalletNoticeEvent
import com.machankura.bennu.compose.nostr.chronicle.ChronicleEvent
import com.machankura.bennu.compose.nostr.chronicle.ChronicleRequestEvent
-import com.machankura.bennu.compose.nostr.nip30303.SubmissionEvent
-import com.machankura.bennu.compose.nostr.nip30303.TranslationArtifactVersionContributorListEvent
-import com.machankura.bennu.compose.nostr.nip30303.TranslationArtifactVersionEvent
-import com.machankura.bennu.compose.nostr.nip30303.TranslationChapterEvent
-import com.machankura.bennu.compose.nostr.nip30303.TranslationChunkEvent
-import com.machankura.bennu.compose.nostr.nip30303.TranslationContributorListEvent
-import com.machankura.bennu.compose.nostr.nip30303.TranslationEvent
import co.touchlab.kermit.Logger
import com.vitorpamplona.quartz.nip01Core.core.firstTagValue
import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent
@@ -471,53 +469,6 @@ data class ChatMessage(
*/
const val TYPE_SUBGROUP_CERTIFIED = "subgroupCertified"
- /**
- * The group signed what it says about itself on nostr.
- *
- * A system line rather than a bubble, for the reason every group-signed
- * line is one: nobody said it, the group signed it. Whoever filled the
- * form in proposed it and a quorum agreed, and the transcript of that
- * happening is the signing session's own -- this is the line saying what
- * the group now is, which is worth having in the room because a rename is
- * the kind of thing members should not have to go looking for.
- *
- * Written only for a profile the *room* signed. A kind:0 authored by
- * anybody else that reaches this room is a member's own profile
- * travelling as a rumor, which is not the group saying anything.
- */
- const val TYPE_GROUP_PROFILE_SIGNED = "groupProfileSigned"
-
- /**
- * The group signed where it lives on nostr.
- *
- * One line per list, so a session that changed three of them writes three.
- * They are not three accounts of one thing -- each names which list was
- * agreed, which is the part a reader needs -- and `applyInnerEvent` is
- * handed one event at a time with no way to know it was in a batch anyway.
- */
- const val TYPE_GROUP_RELAYS_SIGNED = "groupRelaysSigned"
-
- /**
- * Every line about the group's own nostr identity, for the one check the
- * transcript dispatches on.
- *
- * The profile and the relay lists together, because they are the same kind
- * of statement -- the group's account of itself, signed by the group -- and
- * the transcript does the same thing with both. A type missing from here
- * renders as a chat bubble, silently, looking exactly like somebody having
- * said "The group is now called Translation collective".
- */
- /**
- * The group signed something to say publicly, in its own name.
- *
- * A system line rather than a bubble, like the other two -- nobody said it,
- * the group signed it -- and the line names the post rather than repeating
- * it, because the post itself is on the group's screen where it can be read
- * whole. A quote here would be the same words twice with the second copy
- * unable to say who agreed to them.
- */
- const val TYPE_GROUP_POST_SIGNED = "groupPostSigned"
-
/**
* Lines the curated-lists feature wrote: the group signing a list's schema,
* and an entry into one. The feature is gone and nothing writes either any
@@ -528,6 +479,15 @@ data class ChatMessage(
private const val TYPE_LEGACY_GROUP_SCHEMA_SIGNED = "groupSchemaSigned"
private const val TYPE_LEGACY_GROUP_ENTRY_CURATED = "groupEntryCurated"
+ /**
+ * Lines the group's nostr profile, relay lists and posts wrote. Those
+ * features are gone too, and these stay for the same reason: rows already
+ * in a transcript carry them and have to stay system lines.
+ */
+ private const val TYPE_LEGACY_GROUP_PROFILE_SIGNED = "groupProfileSigned"
+ private const val TYPE_LEGACY_GROUP_RELAYS_SIGNED = "groupRelaysSigned"
+ private const val TYPE_LEGACY_GROUP_POST_SIGNED = "groupPostSigned"
+
/**
* The group opened a wallet.
*
@@ -548,10 +508,47 @@ data class ChatMessage(
*/
const val TYPE_GROUP_TRANSACTION_CONFIRMED = "groupTransactionConfirmed"
+ /**
+ * A member told this group about a descendant's guarded wallet -- a
+ * `GuardedWalletNoticeEvent` this device checked and believes. Written
+ * from the notice, attributed to the member who forwarded it. See
+ * `docs/group-wallet-guardians.md`.
+ */
+ const val TYPE_GUARDED_WALLET_SHARED = "guardedWalletShared"
+
+ /**
+ * One of this group's guardians spent from its guarded wallet through its
+ * leaf. Read off the chain by `GuardianManager.takenIn`, and the child's
+ * only notice of it: nobody in this room signed it.
+ */
+ const val TYPE_GUARDIAN_SPEND = "guardianSpend"
+
+ /**
+ * A member asked this group to guard a wallet only they can spend from --
+ * a `MemberWalletRequestEvent` this device checked. A request, not a
+ * decision: the group decides when a signer puts it to the quorum. See
+ * `docs/member-guarded-wallets.md`.
+ */
+ const val TYPE_MEMBER_WALLET_REQUESTED = "memberWalletRequested"
+
+ /** The group signed a member wallet certificate: it now guards that member's wallet. */
+ const val TYPE_MEMBER_WALLET_GUARDED = "memberWalletGuarded"
+
+ /**
+ * The group signed a policy on its members' wallets: it guards them, at a
+ * delay, or it has stopped. See `docs/member-wallet-delay.md`.
+ */
+ const val TYPE_MEMBER_WALLET_POLICY = "memberWalletPolicy"
+
+ /**
+ * Every line the group signed, for the one check the transcript
+ * dispatches on. A type missing from here renders as a chat bubble,
+ * silently, looking exactly like somebody having said it.
+ */
val GROUP_IDENTITY_TYPES = setOf(
- TYPE_GROUP_PROFILE_SIGNED,
- TYPE_GROUP_RELAYS_SIGNED,
- TYPE_GROUP_POST_SIGNED,
+ TYPE_LEGACY_GROUP_PROFILE_SIGNED,
+ TYPE_LEGACY_GROUP_RELAYS_SIGNED,
+ TYPE_LEGACY_GROUP_POST_SIGNED,
TYPE_LEGACY_GROUP_SCHEMA_SIGNED,
TYPE_LEGACY_GROUP_ENTRY_CURATED,
TYPE_GROUP_WALLET_OPENED,
@@ -559,6 +556,11 @@ data class ChatMessage(
TYPE_GROUP_LIGHTNING_WALLET_OPENED,
TYPE_GROUP_LIGHTNING_OPERATOR_ELECTED,
TYPE_GROUP_LIGHTNING_PAYMENT_AUTHORISED,
+ TYPE_GUARDED_WALLET_SHARED,
+ TYPE_GUARDIAN_SPEND,
+ TYPE_MEMBER_WALLET_REQUESTED,
+ TYPE_MEMBER_WALLET_GUARDED,
+ TYPE_MEMBER_WALLET_POLICY,
)
/**
@@ -926,24 +928,25 @@ data class ChatMessage(
val event = Event.fromJsonOrNull(groupEventResult.innerEventJson)
?: throw MarmotUnprocessableInnerEventException("Can't process ${groupEventResult.innerEventJson}")
- // A submission is an envelope: the nip30303 event it delivers
- // is in its content, written by whoever wrote it. Everything
- // else on the wire is the nip30303 event itself. Either way the
- // row on disk is the outer event -- that is what the group sent
- // and what the chat line is attributed to.
- val submission = if (event.kind == SubmissionEvent.KIND) {
- SubmissionEvent(
- id = event.id,
- pubKey = event.pubKey,
- createdAt = event.createdAt,
- tags = event.tags,
- content = event.content,
- sig = event.sig,
- )
- } else {
- null
- }
- val payload = submission?.payload()
+ // A key ceremony's or a signing session's own message. Decided
+ // first: 30310-30312 were nip30303 document kinds too, and round
+ // 1 of a subgroup's ceremony (30312) was read as a document
+ // submission, failed to parse, and landed in the parent's chat
+ // as raw hex -- see docs/ceremony-creation.md, finding F11. Stored like
+ // every inner event, so a ceremony can replay what arrived
+ // before its proposal; acted on by the managers
+ // `NostrDao.fileGroupEventResult` dispatches to, which write
+ // their own transcript lines.
+ //
+ // Except a direct message's envelope. It shares 30330 with a
+ // signing session's decline, and is told apart by what it
+ // carries: an envelope holds a gift wrap, a decline does not.
+ // Treating every 30330 as a decline dropped every direct
+ // message in a current-profile room.
+ val isDirectMessageEnvelope = MarmotDirectMessage.wrapInside(event) != null
+ val isProtocolMessage = !isDirectMessageEnvelope && (
+ event.kind in DkgRitualEvents.ALL || event.kind in FrostSigningEvents.ALL
+ )
database.marmotInnerEventDao().upsert(
MarmotInnerEvent(
@@ -954,12 +957,13 @@ data class ChatMessage(
content = event.content,
chatRoomId = groupEventResult.groupId,
kind = event.kind,
- payloadEventId = payload?.id,
createdAt = Instant.fromEpochSeconds(event.createdAt)
)
)
- // A direct message is not a nip30303 payload to apply. It is
+ if (isProtocolMessage) return null
+
+ // A direct message is not a payload to apply. It is
// gift wrapped for one member, and what this device does with it
// depends only on whether its key opens it. A legacy room carries
// the wrap itself; a current-profile room carries it inside an
@@ -1017,6 +1021,33 @@ data class ChatMessage(
return null
}
+ // A descendant's guarded wallet, carried up by a member who is in
+ // both rooms. The row above is the whole record of it -- there is
+ // no table -- so all that is left is the line, and only for a
+ // notice this room can actually believe.
+ if (event.kind == GuardedWalletNoticeEvent.KIND) {
+ // And on, a generation further: the statement inside, to
+ // the groups above this one that this device is in. Any
+ // device that believes it can, whether or not it holds this
+ // room's key. docs/guarded-wallet-forwarding.md.
+ GuardedWalletNoticeEvent.statementOf(event)?.let {
+ GuardianManager.forwardOnArrival(database, it, groupEventResult.groupId)
+ }
+ val content = GuardianManager.describeNotice(database, groupEventResult.groupId, event)
+ ?: return null
+ return ChatMessage(
+ giftWrapPayloadId = null,
+ messageType = TYPE_GUARDED_WALLET_SHARED,
+ marmotGroupEventId = groupEvent.id,
+ marmotInnerEventId = event.id,
+ senderPublicKey = senderIdentity ?: event.pubKey,
+ isUserMessage = senderIdentity == activeKeyPair.pubKey.toHex(),
+ chatRoomId = groupEventResult.groupId,
+ createdAt = Instant.fromEpochSeconds(event.createdAt),
+ content = content,
+ )
+ }
+
// Somebody in the room holds none of its signed work and is
// asking. Any member may answer and none is elected to: a
// duplicate answer costs bandwidth and nothing else, since
@@ -1037,33 +1068,34 @@ data class ChatMessage(
return null
}
- // A submission whose payload will not parse, or which carries
- // another submission, is kept but not applied: there is nothing
- // here we can turn into a row.
- if (submission != null && (payload == null || payload.kind == SubmissionEvent.KIND)) {
- ChatMessage(
- giftWrapPayloadId = null,
- messageType = "unsupported",
- marmotGroupEventId = groupEvent.id,
- marmotInnerEventId = event.id,
- senderPublicKey = event.pubKey,
- isUserMessage = senderIdentity == activeKeyPair.pubKey.toHex(),
- chatRoomId = groupEventResult.groupId,
- createdAt = Instant.fromEpochSeconds(event.createdAt),
- content = event.content,
- )
- } else {
- applyInnerEvent(
+ // A member asking what the group signs with, so their device
+ // can work out a guarded wallet's leaves, or a member
+ // answering. Plumbing, so no line either way: the row above
+ // is the record, and an answer is checked each time it is
+ // read. Answered like the chronicle's request -- by any
+ // member holding the key state, none elected.
+ // docs/member-guarded-wallets.md, Phase 2.
+ if (event.kind == GroupKeyNoticeEvent.KIND) {
+ MemberWalletManager.answerKeyRequest(
database = database,
- groupId = groupEventResult.groupId,
- event = payload ?: event,
- marmotGroupEventId = groupEvent.id,
- marmotInnerEventId = event.id,
- senderPublicKey = event.pubKey,
- isUserMessage = senderIdentity == activeKeyPair.pubKey.toHex(),
- createdAt = Instant.fromEpochSeconds(event.createdAt),
+ chatRoomId = groupEventResult.groupId,
+ request = event,
+ userPublicKey = activeKeyPair.pubKey.toHex(),
)
+
+ return null
}
+
+ applyInnerEvent(
+ database = database,
+ groupId = groupEventResult.groupId,
+ event = event,
+ marmotGroupEventId = groupEvent.id,
+ marmotInnerEventId = event.id,
+ senderPublicKey = event.pubKey,
+ isUserMessage = senderIdentity == activeKeyPair.pubKey.toHex(),
+ createdAt = Instant.fromEpochSeconds(event.createdAt),
+ )
}
is GroupEventResult.CommitPending -> {
ChatMessage(
@@ -1157,16 +1189,12 @@ data class ChatMessage(
}
/**
- * Apply one nip30303 [event] the group delivered, and describe it for
- * the transcript.
+ * Apply one [event] the group delivered, and describe it for the
+ * transcript.
*
* [event] is what is being applied; the other parameters are how it
- * arrived. They come apart for submissions: the payload is written by
- * whoever wrote it -- possibly nobody in this group -- while
- * [marmotInnerEventId], [senderPublicKey] and [createdAt] all belong to
- * the envelope a member actually sent. Entity rows take their author
- * from [event], so the chat line says who added it and the row says who
- * wrote it.
+ * arrived -- [marmotInnerEventId], [senderPublicKey] and [createdAt]
+ * belong to the message a member actually sent.
*
* [groupSignedEventId] is the third way in, and the one with no
* envelope at all: a `GroupSignedEvent` the group put its own signature
@@ -1176,6 +1204,10 @@ data class ChatMessage(
* which is why they need an id of their own, and why every row this
* writes carries it.
*/
+ /** A member as a transcript line names them: their profile's name, or the start of their key. */
+ private suspend fun memberName(database: BennuDatabase, publicKey: HexKey): String =
+ database.profileDao().getProfileByPublicKey(publicKey)?.humanReadableNameOrPubkey() ?: publicKey.take(8)
+
internal suspend fun applyInnerEvent(
database: BennuDatabase,
groupId: String,
@@ -1187,10 +1219,8 @@ data class ChatMessage(
createdAt: Instant,
groupSignedEventId: HexKey? = null,
): ChatMessage? {
- // The last resort, named because one arm reaches it deliberately rather
- // than by falling off the end: a kind:1 the room did not sign is a
- // member's own note travelling through the room, and it has always
- // rendered as this. See the `TextNoteEvent` arm.
+ // The last resort: raw JSON in a bubble, the only trace an
+ // unrecognised payload leaves.
fun unsupported() = ChatMessage(
giftWrapPayloadId = null,
messageType = "unsupported",
@@ -1204,327 +1234,11 @@ data class ChatMessage(
)
return when (event.kind) {
- ChatEvent.KIND -> {
- ChatMessage(
- giftWrapPayloadId = null,
- messageType = "message",
- marmotGroupEventId = marmotGroupEventId,
- marmotInnerEventId = marmotInnerEventId,
- senderPublicKey = senderPublicKey,
- isUserMessage = isUserMessage,
- chatRoomId = groupId,
- createdAt = createdAt,
- content = event.content, // TODO: Figure out what to do here...
- )
- }
- ArtifactEvent.KIND -> {
- val artifactEvent = ArtifactEvent(
- id = event.id,
- pubKey = event.pubKey,
- createdAt = event.createdAt,
- tags = event.tags,
- content = event.content,
- sig = event.sig,
- )
-
- MantraArtifact.fromArtifactEvent(
- artifactEvent = artifactEvent,
- chatRoomId = groupId,
- )?.let { mantraArtifact ->
- database.mantraArtifactDao().upsert(
- mantraArtifact.copy(
- marmotGroupEventId = marmotGroupEventId,
- groupSignedEventId = groupSignedEventId,
- )
- )
-
- // The version the artifact starts life with is its own
- // event, signed in the same batch and applied after this
- // one -- see AddArtifactViewModel.addArtifact. It used to
- // be derived here instead; deriving it now as well would
- // stand a second, unsigned version row against the same
- // artifact, since the two hash differently.
-
- ChatMessage(
- giftWrapPayloadId = null,
- messageType = "artifact",
- marmotGroupEventId = marmotGroupEventId,
- marmotInnerEventId = marmotInnerEventId,
- senderPublicKey = senderPublicKey,
- isUserMessage = isUserMessage,
- chatRoomId = groupId,
- createdAt = createdAt,
- content = "Added ${mantraArtifact.name} to artifacts"
- )
- }
- }
- ArtifactVersionEvent.KIND -> {
- MantraArtifactVersion.fromArtifactVersionEvent(
- artifactVersionEvent = ArtifactVersionEvent(
- id = event.id,
- pubKey = event.pubKey,
- createdAt = event.createdAt,
- tags = event.tags,
- content = event.content,
- sig = event.sig
- ),
- chatRoomId = groupId,
- )?.let { mantraArtifactVersion ->
- database.mantraArtifactVersionDao().upsert(
- mantraArtifactVersion.copy(
- marmotGroupEventId = marmotGroupEventId,
- groupSignedEventId = groupSignedEventId,
- )
- )
-
- // No line of its own. A version arrives as the second
- // item of the batch that carries its artifact, and the
- // artifact has already said so -- the same reason a
- // chunk writes no line beside its chapter. While the
- // version was derived here rather than signed it wrote
- // none either, so this is the transcript standing still
- // rather than losing something.
- }
- null
- }
- ChapterEvent.KIND -> {
- // The chunks the chapter splits into are their own events,
- // signed in the same session and applied after it -- see
- // AddChapterViewModel.addChapter. Nothing to do here but the
- // chapter itself.
- MantraChapter.fromChapterEvent(
- chapterEvent = ChapterEvent(
- id = event.id,
- pubKey = event.pubKey,
- createdAt = event.createdAt,
- tags = event.tags,
- content = event.content,
- sig = event.sig
- ),
- chatRoomId = groupId,
- )?.let { mantraChapter ->
- database.mantraChapterDao().upsert(
- mantraChapter.copy(
- marmotGroupEventId = marmotGroupEventId,
- groupSignedEventId = groupSignedEventId,
- )
- )
-
- ChatMessage(
- giftWrapPayloadId = null,
- messageType = "chapter",
- marmotGroupEventId = marmotGroupEventId,
- marmotInnerEventId = marmotInnerEventId,
- senderPublicKey = senderPublicKey,
- isUserMessage = isUserMessage,
- chatRoomId = groupId,
- createdAt = createdAt,
- content = "Added ${mantraChapter.name} to chapters" // TODO: Use artifact name...
- )
- }
- }
-
- ChunkEvent.KIND -> {
- MantraChunk.fromChunkEvent(
- chunkEvent = ChunkEvent(
- id = event.id,
- pubKey = event.pubKey,
- createdAt = event.createdAt,
- tags = event.tags,
- content = event.content,
- sig = event.sig
- ),
- chatRoomId = groupId,
- )?.let { mantraChunk ->
- database.mantraChunkDao().upsert(
- mantraChunk.copy(
- marmotGroupEventId = marmotGroupEventId,
- groupSignedEventId = groupSignedEventId,
- )
- )
-
- // TODO: Chunks might be too noisy to show in chat...
- }
- null
- }
- DialectEvent.KIND -> {
- MantraDialect.fromDialectEvent(
- dialectEvent = DialectEvent(
- id = event.id,
- pubKey = event.pubKey,
- createdAt = event.createdAt,
- tags = event.tags,
- content = event.content,
- sig = event.sig
- ),
- chatRoomId = groupId,
- )?.let { mantraDialect ->
- database.mantraDialectDao().upsert(
- mantraDialect.copy(
- marmotGroupEventId = marmotGroupEventId,
- groupSignedEventId = groupSignedEventId,
- )
- )
-
-
- ChatMessage(
- giftWrapPayloadId = null,
- messageType = "dialect",
- marmotGroupEventId = marmotGroupEventId,
- marmotInnerEventId = marmotInnerEventId,
- senderPublicKey = senderPublicKey,
- isUserMessage = isUserMessage,
- chatRoomId = groupId,
- createdAt = createdAt,
- content = "Added ${mantraDialect.name} to dialects" // TODO: Use artifact name...
- )
- }
- }
- TranslationArtifactVersionEvent.KIND -> {
- MantraTranslationArtifactVersion.fromTranslationArtifactVersionEvent(
- translationArtifactVersionEvent = TranslationArtifactVersionEvent(
- id = event.id,
- pubKey = event.pubKey,
- createdAt = event.createdAt,
- tags = event.tags,
- content = event.content,
- sig = event.sig
- ),
- chatRoomId = groupId,
- )?.let { mantraTranslationArtifactVersion ->
- database.mantraTranslationArtifactVersionDao().upsert(
- mantraTranslationArtifactVersion.copy(
- marmotGroupEventId = marmotGroupEventId,
- groupSignedEventId = groupSignedEventId,
- )
- )
-
- ChatMessage(
- giftWrapPayloadId = null,
- messageType = "translationArtifactVersion",
- marmotGroupEventId = marmotGroupEventId,
- marmotInnerEventId = marmotInnerEventId,
- senderPublicKey = senderPublicKey,
- isUserMessage = isUserMessage,
- chatRoomId = groupId,
- createdAt = createdAt,
- content = "Added ${mantraTranslationArtifactVersion.name} to translation artifact versions" // TODO: Use artifact name...
- )
- }
- }
- TranslationArtifactVersionContributorListEvent.KIND -> {
- // TODO: Consume contributors...
- null
- }
- TranslationChapterEvent.KIND -> {
- MantraTranslationChapter.fromTranslationChapterEvent(
- translationChapterEvent = TranslationChapterEvent(
- id = event.id,
- pubKey = event.pubKey,
- createdAt = event.createdAt,
- tags = event.tags,
- content = event.content,
- sig = event.sig
- ),
- chatRoomId = groupId,
- )?.let { mantraTranslationChapter ->
- database.mantraTranslationChapterDao().upsert(
- mantraTranslationChapter.copy(
- marmotGroupEventId = marmotGroupEventId,
- groupSignedEventId = groupSignedEventId,
- )
- )
- // TODO: translation chapter might be too noisy for chat updates
- }
- null
- }
- TranslationChunkEvent.KIND -> {
- MantraTranslationChunk.fromTranslationChunkEvent(
- translationChunkEvent = TranslationChunkEvent(
- id = event.id,
- pubKey = event.pubKey,
- createdAt = event.createdAt,
- tags = event.tags,
- content = event.content,
- sig = event.sig
- ),
- chatRoomId = groupId,
- )?.let { mantraTranslationChunk ->
- // One translation per source chunk. Retranslating changes
- // the text and so the event's id, which makes it a new
- // event rather than an edit of the old one -- so the one
- // it supersedes is dropped here, or a passage would have
- // two answers to what it says and the reader would be
- // shown whichever the query happened to reach first.
- //
- // Newest wins by the timestamp the group signed at, not by
- // when it arrived, with the id breaking a tie. Two devices
- // catching up read the same events in whatever order the
- // relay hands them over, and they have to end up holding
- // the same translation either way.
- val existing = database.mantraTranslationChunkDao()
- .getTranslationChunksByChunkId(
- translationChapterId = mantraTranslationChunk.translationChapterId,
- chunkId = mantraTranslationChunk.chunkId,
- )
- .filterNot { it.id == mantraTranslationChunk.id }
-
- val isNewest = existing.none {
- it.createdAt > mantraTranslationChunk.createdAt ||
- (it.createdAt == mantraTranslationChunk.createdAt &&
- it.id > mantraTranslationChunk.id)
- }
-
- if (isNewest) {
- existing.forEach {
- database.mantraTranslationChunkDao().deleteById(it.id)
- }
-
- database.mantraTranslationChunkDao().upsert(
- mantraTranslationChunk.copy(
- marmotGroupEventId = marmotGroupEventId,
- groupSignedEventId = groupSignedEventId,
- )
- )
- }
- }
- null
- }
- TranslationContributorListEvent.KIND -> {
- // TODO: Consume contributors...
- null
- }
- TranslationEvent.KIND -> {
- MantraTranslation.fromTranslationEvent(
- translationEvent = TranslationEvent(
- id = event.id,
- pubKey = event.pubKey,
- createdAt = event.createdAt,
- tags = event.tags,
- content = event.content,
- sig = event.sig
- ),
- chatRoomId = groupId,
- )?.let { mantraTranslation ->
- database.mantraTranslationDao().upsert(
- mantraTranslation.copy(
- marmotGroupEventId = marmotGroupEventId,
- groupSignedEventId = groupSignedEventId,
- )
- )
- ChatMessage(
- giftWrapPayloadId = null,
- messageType = "translation",
- marmotGroupEventId = marmotGroupEventId,
- marmotInnerEventId = marmotInnerEventId,
- senderPublicKey = senderPublicKey,
- isUserMessage = isUserMessage,
- chatRoomId = groupId,
- createdAt = createdAt,
- content = "Added ${mantraTranslation.text} to translations" // TODO: Reference original text
- )
- }
- }
+ // First, above every content kind: protocol kinds are never
+ // content, whatever else might share their number, and a `when`
+ // takes the first arm that matches. The ceremony's 30310 and 30311
+ // once reached document arms that sat above this one.
+ //
// A signing session's own protocol messages. FrostSigningManager
// applies them and writes its own transcript lines naming who did
// what, so an "unsupported" row here would be a second, worse
@@ -1546,6 +1260,19 @@ data class ChatMessage(
// none of their business.
in DkgRitualEvents.ALL -> null
+ ChatEvent.KIND -> {
+ ChatMessage(
+ giftWrapPayloadId = null,
+ messageType = "message",
+ marmotGroupEventId = marmotGroupEventId,
+ marmotInnerEventId = marmotInnerEventId,
+ senderPublicKey = senderPublicKey,
+ isUserMessage = isUserMessage,
+ chatRoomId = groupId,
+ createdAt = createdAt,
+ content = event.content, // TODO: Figure out what to do here...
+ )
+ }
// The group saying what key one of its rooms signs with, arriving
// here the way every group-signed event does: applied by
// `FrostSigningManager` once a quorum has signed the proposal it
@@ -1615,103 +1342,78 @@ data class ChatMessage(
)
}
- // The group saying who it is on nostr. A room's id is the pubkey
- // it signs as, so a group has an identity from the moment it has a
- // key; this is the kind:0 describing it, signed by the group's own
- // quorum like everything else it says.
- //
- // **Only when the room itself signed it.** This arm is reached both
- // from a completed signing session, where the author is the room by
- // construction, and from an arriving inner event, where any member
- // could have sent a rumor of this kind -- and it cannot tell which.
- // A member's own kind:0 travelling through a room is their profile,
- // not the group's, and gets no line here.
- //
- // No row is written. The event is already on file as a
- // `GroupSignedEvent` -- `FrostSigningManager.complete` records the
- // batch before it applies it -- and `GroupNostrProfile` reads the
- // group's profile straight off those. A `Profile` row is not an
- // option anyway: it hangs off `NostrEvent` by foreign key, and a
- // group-signed event is not one.
- MetadataEvent.KIND -> {
- if (!event.pubKey.equals(groupId, ignoreCase = true)) return null
-
- val profile = GroupNostrProfile.of(
- signedEvent = GroupSignedEvent.fromEvent(event, chatRoomId = groupId),
- chatRoomId = groupId,
- ) ?: return null
+ // A member asking the group to guard a wallet of theirs. The
+ // inner event carries the signed request whole; only a request
+ // that checks out and asks this room gets a line, and it is a
+ // line and nothing more -- the group decides when a signer puts
+ // it to the quorum. docs/member-guarded-wallets.md.
+ MemberWalletRequestEvent.KIND -> {
+ val request = MemberWalletRequestEvent.carried(event) ?: return null
+ val reading = MemberWalletRequestEvent.verified(request)?.reading ?: return null
+ if (!reading.groupChatRoomId.equals(groupId, ignoreCase = true)) return null
ChatMessage(
giftWrapPayloadId = null,
- messageType = TYPE_GROUP_PROFILE_SIGNED,
+ messageType = TYPE_MEMBER_WALLET_REQUESTED,
marmotGroupEventId = marmotGroupEventId,
marmotInnerEventId = marmotInnerEventId,
senderPublicKey = senderPublicKey,
isUserMessage = isUserMessage,
chatRoomId = groupId,
createdAt = createdAt,
- content = profile.name()?.let { "The group is now called $it" }
- ?: "The group signed a new profile for itself"
+ content = "@${memberName(database, reading.memberPublicKey)} asked this group to guard a wallet",
)
}
- // The group saying something publicly, in its own name -- which
- // is a different thing from a member saying something in the room.
- // A room's messages are `ChatEvent`s; this is a kind:1 authored by
- // the room's own key, so any reader can check the group said it and
- // that no single member could have.
- //
- // Verified like the arms below and for the same reason: a rumor
- // carries an empty signature and any pubkey its sender likes, so an
- // author check alone would let one member put words in the group's
- // mouth in its own transcript.
- //
- // **Unlike those arms, a kind:1 that fails falls through to
- // `unsupported` rather than vanishing.** A member's kind:0 or relay
- // list passing through a room is identity plumbing nobody sent on
- // purpose and silence is the right treatment; a kind:1 is content,
- // somebody meant it, and it has rendered as an unsupported event
- // since before any of this existed. Dropping it here would be this
- // change quietly deleting messages it has no business touching.
- TextNoteEvent.KIND -> {
- val signed = GroupSignedEvent.fromEvent(event, chatRoomId = groupId)
- if (!signed.verifies()) return unsupported()
+ // The group agreeing to guard a member's wallet. Checked whole --
+ // the room's signature and the request inside -- because the line
+ // says the group made a promise about somebody's money. It is
+ // filed as a `GroupSignedEvent` either way, and every reader
+ // checks it there again.
+ MemberWalletCertificateEvent.KIND -> {
+ val verified = MemberWalletCertificateEvent.verify(event, groupId) ?: return null
+ // The groups above this one guard the wallet too, and learn
+ // of it only by being told. docs/guarded-wallet-forwarding.md.
+ GuardianManager.forwardOnArrival(database, event, groupId)
ChatMessage(
giftWrapPayloadId = null,
- messageType = TYPE_GROUP_POST_SIGNED,
+ messageType = TYPE_MEMBER_WALLET_GUARDED,
marmotGroupEventId = marmotGroupEventId,
marmotInnerEventId = marmotInnerEventId,
senderPublicKey = senderPublicKey,
isUserMessage = isUserMessage,
chatRoomId = groupId,
createdAt = createdAt,
- content = "The group posted in its own name"
+ content = "This group now guards a wallet for @${memberName(database, verified.memberPublicKey)}",
+ )
+ }
+
+ // The group saying whether it guards its members' wallets, and at
+ // what delay. Checked as the room's own signature, which is all a
+ // policy needs; one that does not verify gets no line, and is
+ // ignored where it is filed too. docs/member-wallet-delay.md.
+ MemberWalletPolicyEvent.KIND -> {
+ val policy = MemberWalletPolicyEvent.verify(event, groupId) ?: return null
+
+ ChatMessage(
+ giftWrapPayloadId = null,
+ messageType = TYPE_MEMBER_WALLET_POLICY,
+ marmotGroupEventId = marmotGroupEventId,
+ marmotInnerEventId = marmotInnerEventId,
+ senderPublicKey = senderPublicKey,
+ isUserMessage = isUserMessage,
+ chatRoomId = groupId,
+ createdAt = createdAt,
+ content = when (policy) {
+ is MemberWalletPolicyEvent.Policy.Open ->
+ "The group guards members' wallets, after ${BlockDuration.describe(policy.delay)}"
+ is MemberWalletPolicyEvent.Policy.Closed ->
+ "The group has stopped guarding new members' wallets"
+ },
)
}
- // The group saying where it lives on nostr: which relays carry
- // its work, take its messages, answer a search of it, and which it
- // will not talk to.
- //
- // **Verified, not just attributed.** This arm is reached from a
- // completed signing session, where the author is the room by
- // construction, and from an arriving inner event, where it is
- // whatever the sender wrote -- and it cannot tell which. A rumor
- // carries an empty signature and any pubkey its sender likes, so an
- // author check alone would let one member put "the group signed its
- // general relay list" in the transcript. `verifies` is what makes
- // the line mean what it says: the room's key over these tags.
- //
- // A member's own relay list travelling through the room fails the
- // author half and gets no line, which is right -- it is their list,
- // not the group's.
- //
- // No row is written, and nothing is parsed beyond the check. The
- // events are already on file as `GroupSignedEvent` and
- // `GroupRelayList` reads the lists straight off those; this arm
- // exists so a signed relay list is a line in the transcript rather
- // than raw JSON in a bubble.
// The group opening a wallet. Checked the whole way -- the room's
// signature, and the statement rederiving from the room's own key --
// because a line saying "the group opened a wallet" is a line people
@@ -1723,6 +1425,9 @@ data class ChatMessage(
val thresholdPublicKey = GroupWalletManager.thresholdKeyFor(database, groupId)
?: return null
val wallet = GroupWallet.of(signed, thresholdPublicKey) ?: return null
+ // A guarded wallet is one the groups above can find only by
+ // being told of it. docs/guarded-wallet-forwarding.md.
+ if (wallet.account.isGuarded) GuardianManager.forwardOnArrival(database, event, groupId)
ChatMessage(
giftWrapPayloadId = null,
@@ -1801,25 +1506,17 @@ data class ChatMessage(
)
}
- in GroupRelaySet.KINDS -> {
- val signed = GroupSignedEvent.fromEvent(event, chatRoomId = groupId)
- if (!signed.verifies()) return null
-
- val set = GroupRelaySet.entries.firstOrNull { it.kind == event.kind }
- ?: return null
-
- ChatMessage(
- giftWrapPayloadId = null,
- messageType = TYPE_GROUP_RELAYS_SIGNED,
- marmotGroupEventId = marmotGroupEventId,
- marmotInnerEventId = marmotInnerEventId,
- senderPublicKey = senderPublicKey,
- isUserMessage = isUserMessage,
- chatRoomId = groupId,
- createdAt = createdAt,
- content = "The group signed its ${set.name.lowercase()} relay list"
- )
- }
+ // A profile or a relay list -- the group's or a member's own --
+ // travelling through the room. The app no longer reads either as
+ // the group's, and both are identity plumbing nobody sends into a
+ // room on purpose, so neither is a line nor a raw-JSON bubble: a
+ // signing session an older build opened for one ends in silence.
+ // A kind:1 is content, and keeps the bubble it always had.
+ MetadataEvent.KIND,
+ AdvertisedRelayListEvent.KIND,
+ ChatMessageRelayListEvent.KIND,
+ SearchRelayListEvent.KIND,
+ BlockedRelayListEvent.KIND -> null
// v2's two non-chat kinds. A kind:1210 that arrives is one member's
// assertion about what the group's state became, and this device
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/DkgSession.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/DkgSession.kt
index 8f71c1fe..46477ccd 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/DkgSession.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/DkgSession.kt
@@ -8,6 +8,7 @@ import com.machankura.bennu.compose.database.model.traits.LocalStoreEntity
import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
import com.machankura.bennu.compose.database.model.types.DkgApprovalStep
import com.machankura.bennu.compose.database.model.types.DkgRitualStage
+import com.machankura.bennu.compose.nostr.subgroup.SubgroupWalletPolicy
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray
import fr.acinq.bitcoin.ByteVector
@@ -99,6 +100,33 @@ data class DkgSession(
*/
val subject: String? = null,
+ /**
+ * The wallet policy the coordinator chose for the subgroup this ceremony
+ * makes, as `SubgroupWalletPolicy.tagValue` -- or null for a ceremony that
+ * makes no subgroup, or one proposed by a build from before policies.
+ * `docs/subgroup-wallet-policy.md`.
+ *
+ * A claim on a proposal, like [subject], and read for two things only: the
+ * join screen, which tells an admin what they are agreeing to, and the
+ * certificate rung, which proposes the certificate under it. What makes it
+ * binding is the parent's quorum signing it into the certificate, and every
+ * child signer then refusing a key state whose certificate says otherwise.
+ */
+ val walletPolicy: String? = null,
+
+ /**
+ * The delay, in blocks, the coordinator chose for the parent's own leaf in
+ * the guarded subgroup this ceremony makes -- or null for an unguarded one,
+ * one that makes no subgroup, or one from a build before parents chose.
+ * `docs/guardian-delay.md`.
+ *
+ * A claim on a proposal like [walletPolicy], read for the join screen and for
+ * the certificate rung. A guarded ceremony with none is certified at
+ * `GuardianDerivation.DEFAULT_DELAY`, which is what its build would have
+ * written.
+ */
+ val guardianDelay: Long? = null,
+
val stage: DkgRitualStage = DkgRitualStage.COLLECTING_HOST_KEYS,
/** This device's ChillDKG host public key (33-byte compressed, hex). */
@@ -232,3 +260,7 @@ data class DkgSession(
publicKeys.takeIf { it.isNotEmpty() }?.sorted()?.joinToString(",")
}
}
+
+/** [DkgSession.walletPolicy], read; null for none or one this build does not know. */
+val DkgSession.subgroupWalletPolicy: SubgroupWalletPolicy?
+ get() = walletPolicy?.let(SubgroupWalletPolicy::fromTagValue)
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/GroupSignedEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/GroupSignedEvent.kt
index e53667de..6a229ee4 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/GroupSignedEvent.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/GroupSignedEvent.kt
@@ -36,12 +36,6 @@ import com.machankura.bennu.compose.nostr.frost.GroupKeyStateEvent
* columns are `NostrEvent`'s so that what is stored is an event rather than a
* summary of one, which is what makes [verifies] answerable from the row alone.
*
- * The one way one reaches a relay is a member sending it there by hand -- from
- * `BroadcastGroupSignedEventScreen`, or every accepted entry at once from the
- * entries screen -- and that path serialises the row straight to the pool
- * without ever making a `NostrEvent` of it -- see
- * `BroadcastGroupSignedEventViewModel` for why a row would be the wrong shape.
- *
* ### The derivation path
*
* [publicKey] is the group's threshold key walked to [derivationPath], and for a
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/GroupTransaction.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/GroupTransaction.kt
index b0960854..0e3c7ba3 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/GroupTransaction.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/GroupTransaction.kt
@@ -48,6 +48,18 @@ data class GroupTransaction(
/** The wallet account the inputs are under. From the room's statement, never from the proposal. */
val account: Long,
+ /**
+ * The descendant whose guarded wallet this spend draws from, through this
+ * room's guardian leaf -- or null for a spend from the room's own wallet.
+ * [account] is then the descendant's, from the statement this room was told.
+ *
+ * A descendant is a subgroup's room id or, since
+ * `docs/member-guarded-wallets.md`, a member wallet's `W`: either is what the
+ * line of descent ends in. The column keeps its name, because a rename is a
+ * migration for a word.
+ */
+ val guardedChatRoomId: String? = null,
+
/**
* The PSBT as proposed, base64. Write-once: it is what every item's sighash
* was computed from, and a second proposal under the same session id that
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraArtifact.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraArtifact.kt
deleted file mode 100644
index db1cdfb4..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraArtifact.kt
+++ /dev/null
@@ -1,163 +0,0 @@
-package com.machankura.bennu.compose.database.model
-
-import androidx.room3.Entity
-import androidx.room3.ForeignKey
-import androidx.room3.PrimaryKey
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.vitorpamplona.quartz.nip31Alts.AltTag
-import com.machankura.bennu.compose.database.model.traits.OptionalNostrEventEntity
-import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
-import com.machankura.bennu.compose.nostr.nip30303.ArtifactEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.ArtifactVersionMetadataTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.DialectIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.LicenseTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.UrlTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.VisibilityTag
-import kotlin.time.Clock
-import kotlin.time.Instant
-
-/**
- * 30300
- */
-@Entity(
- foreignKeys = [
- ForeignKey(
- entity = MantraDialect::class,
- parentColumns = ["id"],
- childColumns = ["dialectId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = ChatRoom::class,
- parentColumns = ["id"],
- childColumns = ["chatRoomId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ]
-)
-data class MantraArtifact(
- @PrimaryKey
- val id: HexKey,
- val publicKey: String,
- val name: String,
- val url: String, // Hash this to get the dTag...
- val visibility: String, // public, private, permissioned (public, but only members can contribute)
- val dialectId: String,
- val license: String,
-// val artifactApprovalId: String,
-
- val chatRoomId: String,
-
- /**
- * Signature will be an empty string if this is a rumor
- */
- val signature: String,
-
- val relayHint: String? = null,
-
- val marmotGroupEventId: HexKey? = null,
-
- /** The [GroupSignedEvent] this row was made from, when the group signed it. */
- val groupSignedEventId: HexKey? = null,
- /**
- * Related nostrEventId if this is not a rumor...
- */
- override val nostrEventId: HexKey? = null,
- override val createdAt: Instant = Clock.System.now(),
- override val updatedAt: Instant = createdAt
-): OptionalNostrEventEntity, TimestampedEntity {
- /**
- * The event the group signed, rebuilt from this row.
- *
- * [versionLabel] is a parameter because it is not on this row and cannot be.
- * `fromArtifactEvent` reads the artifact's own fields and drops the version
- * metadata, which `ChatMessage.applyInnerEvent` has by then turned into the
- * artifact's first `MantraArtifactVersion`. It was still part of what the
- * group put its signature to, so a rebuild without it hashes to a different
- * id and produces an event the signature does not cover -- which a receiver
- * reads as a forgery, silently. Recover it from the initial version: the one
- * whose `createdAt` is this artifact's, since `initialVersionOf` derives it
- * from the same event.
- *
- * Tag order matches [ArtifactEvent.build] exactly -- alt first -- for the
- * same reason, and `ChronicleRoundTripTest` is what says so. Both of those were
- * wrong here until a chronicle needed to rebuild an artifact and nothing had
- * ever called this.
- */
- @Deprecated(
- "Chronicle fallback for work signed before the GroupSignedEvent table. Read the " +
- "event off that table instead; this rebuild goes when the last pre-v13 install " +
- "does -- see the removal checklist in docs/member-chronicle.md."
- )
- fun toArtifactEvent(versionLabel: String): ArtifactEvent {
- return ArtifactEvent(
- id = id,
- pubKey = publicKey,
- createdAt = createdAt.epochSeconds,
- // Tag order matches ArtifactEvent.build so the event id round-trips.
- tags = TagArrayBuilder()
- .addUnique(
- AltTag.assemble(ArtifactEvent.ALT_DESCRIPTION)
- )
- .addUnique(UrlTag.assemble(url))
- .addUnique(VisibilityTag.assemble(visibility))
- .addUnique(LicenseTag.assemble(license))
- .addUnique(
- DialectIdTag.assemble(dialectId)
- )
- .addUnique(
- ArtifactVersionMetadataTag.assemble(versionLabel)
- )
- .build(),
- content = name,
- sig = signature
- )
- }
-
- companion object {
- fun fromArtifactEventTemplate(artifactEventTemplate: EventTemplate, chatRoomId: HexKey, userPublicKey: HexKey): MantraArtifact? {
- return fromArtifactEvent(
- ArtifactEvent(
- id = EventHasher.hashId(
- pubKey = userPublicKey, // TODO: get pub key...
- tags = artifactEventTemplate.tags,
- content = artifactEventTemplate.content,
- createdAt = artifactEventTemplate.createdAt,
- kind = artifactEventTemplate.kind
- ),
- content = artifactEventTemplate.content,
- tags = artifactEventTemplate.tags,
- createdAt = artifactEventTemplate.createdAt,
- pubKey = userPublicKey,
- sig = "" // Unsigned....
- ),
- chatRoomId = chatRoomId
- )
- }
- fun fromArtifactEvent(artifactEvent: ArtifactEvent, chatRoomId: HexKey, ): MantraArtifact? {
- return artifactEvent.url()?.let { url ->
- artifactEvent.visibility()?.let { visibility ->
- artifactEvent.license()?.let { license ->
- artifactEvent.dialectId()?.let { dialectId ->
- MantraArtifact(
- id = artifactEvent.id,
- publicKey = artifactEvent.pubKey,
- dialectId = dialectId,
- createdAt = Instant.fromEpochSeconds(artifactEvent.createdAt),
- url = url,
- license = license,
- visibility = visibility,
- name = artifactEvent.content,
- signature = artifactEvent.sig,
- chatRoomId = chatRoomId
- )
- }
- }
- }
- }
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraArtifactVersion.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraArtifactVersion.kt
deleted file mode 100644
index b73ccb1e..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraArtifactVersion.kt
+++ /dev/null
@@ -1,135 +0,0 @@
-package com.machankura.bennu.compose.database.model
-
-import androidx.room3.Entity
-import androidx.room3.ForeignKey
-import androidx.room3.PrimaryKey
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.vitorpamplona.quartz.nip31Alts.AltTag
-import com.machankura.bennu.compose.database.model.traits.OptionalNostrEventEntity
-import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
-import com.machankura.bennu.compose.nostr.nip30303.ArtifactVersionEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.ArtifactIdTag
-import kotlin.time.Clock
-import kotlin.time.Instant
-
-/**
- * 30301
- */
-@Entity(
- foreignKeys = [
- ForeignKey(
- entity = MantraArtifact::class,
- parentColumns = ["id"],
- childColumns = ["artifactId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = ChatRoom::class,
- parentColumns = ["id"],
- childColumns = ["chatRoomId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ],
-)
-data class MantraArtifactVersion(
- @PrimaryKey
- val id: HexKey,
- val artifactId: HexKey,
- val publicKey: HexKey,
-
- /**
- * Version Tag...
- */
- val versionLabel: String,
-
- /**
- * Signature will be an empty string if this is a rumor
- */
- val signature: String,
-
- val chatRoomId: String,
-
- val relayHint: String? = null,
- val marmotGroupEventId: HexKey? = null,
-
- /** The [GroupSignedEvent] this row was made from, when the group signed it. */
- val groupSignedEventId: HexKey? = null,
-
- /**
- * Related nostrEventId if this is not a rumor...
- */
- override val nostrEventId: HexKey? = null,
-
- override val createdAt: Instant = Clock.System.now(),
- override val updatedAt: Instant = createdAt
-): OptionalNostrEventEntity, TimestampedEntity {
- @Deprecated(
- "Chronicle fallback for work signed before the GroupSignedEvent table. Read the " +
- "event off that table instead; this rebuild goes when the last pre-v13 install " +
- "does -- see the removal checklist in docs/member-chronicle.md."
- )
- fun toArtifactVersionEvent(): ArtifactVersionEvent {
- return ArtifactVersionEvent(
- id = id,
- pubKey = publicKey,
- createdAt = createdAt.epochSeconds,
- // Tag order matches ArtifactVersionEvent.initialVersionOf, which puts
- // the alt first because `build` does, or the event id does not
- // round-trip. It was the other way round here for as long as nothing
- // called this -- see ChronicleRoundTripTest, which is what calls it now.
- tags = TagArrayBuilder()
- .addUnique(
- AltTag.assemble(ArtifactVersionEvent.ALT_DESCRIPTION)
- )
- .addUnique(
- ArtifactIdTag.assemble(artifactId)
- )
- .build(),
- content = versionLabel,
- sig = signature
- )
- }
-
- companion object {
- fun fromArtifactVersionEventTemplate(
- artifactVersionEventTemplate: EventTemplate,
- chatRoomId: HexKey,
- userPublicKey: HexKey,
- ): MantraArtifactVersion? {
- return fromArtifactVersionEvent(
- ArtifactVersionEvent(
- id = EventHasher.hashId(
- pubKey = userPublicKey,
- tags = artifactVersionEventTemplate.tags,
- content = artifactVersionEventTemplate.content,
- createdAt = artifactVersionEventTemplate.createdAt,
- kind = artifactVersionEventTemplate.kind,
- ),
- content = artifactVersionEventTemplate.content,
- tags = artifactVersionEventTemplate.tags,
- createdAt = artifactVersionEventTemplate.createdAt,
- pubKey = userPublicKey,
- sig = "", // Unsigned rumor
- ),
- chatRoomId = chatRoomId,
- )
- }
-
- fun fromArtifactVersionEvent(artifactVersionEvent: ArtifactVersionEvent, chatRoomId: HexKey, ): MantraArtifactVersion? {
- return artifactVersionEvent.artifactId()?.let { artifactId ->
- MantraArtifactVersion(
- id = artifactVersionEvent.id,
- publicKey = artifactVersionEvent.pubKey,
- createdAt = Instant.fromEpochSeconds(artifactVersionEvent.createdAt),
- artifactId = artifactId,
- versionLabel = artifactVersionEvent.content,
- signature = artifactVersionEvent.sig,
- chatRoomId = chatRoomId
- )
- }
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraChapter.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraChapter.kt
deleted file mode 100644
index 4d86b31c..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraChapter.kt
+++ /dev/null
@@ -1,157 +0,0 @@
-package com.machankura.bennu.compose.database.model
-
-import androidx.room3.Entity
-import androidx.room3.ForeignKey
-import androidx.room3.PrimaryKey
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.vitorpamplona.quartz.nip31Alts.AltTag
-import com.machankura.bennu.compose.database.model.traits.OptionalNostrEventEntity
-import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
-import com.machankura.bennu.compose.nostr.nip30303.ChapterEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.ArtifactVersionIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.IndexTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.NameTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.OriginalTextTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.WordStatisticsTag
-import kotlin.time.Clock
-import kotlin.time.Instant
-
-/**
- * 30302
- */
-@Entity(
- foreignKeys = [
- ForeignKey(
- entity = MantraArtifactVersion::class,
- parentColumns = ["id"],
- childColumns = ["artifactVersionId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = ChatRoom::class,
- parentColumns = ["id"],
- childColumns = ["chatRoomId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ],
-)
-data class MantraChapter(
- @PrimaryKey
- val id: HexKey,
- val artifactVersionId: HexKey,
- val publicKey: HexKey,
- val name: String,
- val originalText: String,
- val index: Int,
- val wordCount: Int,
- val characterCount: Int,
-
- /**
- * Signature will be an empty string if this is a rumor
- */
- val signature: String,
-
- val chatRoomId: String,
-
- val relayHint: String? = null,
- val marmotGroupEventId: HexKey? = null,
-
- /** The [GroupSignedEvent] this row was made from, when the group signed it. */
- val groupSignedEventId: HexKey? = null,
-
- /**
- * Related nostrEventId if this is not a rumor...
- */
- override val nostrEventId: HexKey? = null,
-
- override val createdAt: Instant = Clock.System.now(),
- override val updatedAt: Instant = createdAt
-): OptionalNostrEventEntity, TimestampedEntity {
-
- @Deprecated(
- "Chronicle fallback for work signed before the GroupSignedEvent table. Read the " +
- "event off that table instead; this rebuild goes when the last pre-v13 install " +
- "does -- see the removal checklist in docs/member-chronicle.md."
- )
- fun toChapterEvent(): ChapterEvent {
- return ChapterEvent(
- id = id,
- pubKey = publicKey,
- createdAt = createdAt.epochSeconds,
- // Tag order matches ChapterEvent.build so the event id round-trips.
- tags = TagArrayBuilder()
- .addUnique(AltTag.assemble(ChapterEvent.ALT_DESCRIPTION))
- .addUnique(
- ArtifactVersionIdTag.assemble(artifactVersionId)
- )
- .addUnique(NameTag.assemble(name))
- .addUnique(OriginalTextTag.assemble(originalText))
- .addUnique(
- IndexTag.assemble(
- index
- )
- )
- .addUnique(
- WordStatisticsTag.assemble(wordCount, characterCount)
- )
- .build(),
- content = "",
- sig = signature
- )
- }
-
- companion object {
- fun fromChapterEventTemplate(
- chapterEventTemplate: EventTemplate,
- chatRoomId: HexKey,
- userPublicKey: HexKey,
- ): MantraChapter? {
- return fromChapterEvent(
- ChapterEvent(
- id = EventHasher.hashId(
- pubKey = userPublicKey,
- tags = chapterEventTemplate.tags,
- content = chapterEventTemplate.content,
- createdAt = chapterEventTemplate.createdAt,
- kind = chapterEventTemplate.kind,
- ),
- content = chapterEventTemplate.content,
- tags = chapterEventTemplate.tags,
- createdAt = chapterEventTemplate.createdAt,
- pubKey = userPublicKey,
- sig = "", // Unsigned rumor
- ),
- chatRoomId = chatRoomId,
- )
- }
-
- fun fromChapterEvent(chapterEvent: ChapterEvent, chatRoomId: HexKey): MantraChapter? {
- return chapterEvent.name()?.let { name ->
- chapterEvent.originalText()?.let { originalText ->
- chapterEvent.wordStatisticsTag?.let { wordStatisticsTag ->
- chapterEvent.artifactVersionId()?.let { artifactId ->
- chapterEvent.index()?.let { index ->
- MantraChapter(
- id = chapterEvent.id,
- publicKey = chapterEvent.pubKey,
- createdAt = Instant.fromEpochSeconds(chapterEvent.createdAt),
- artifactVersionId = artifactId,
- name = name,
- originalText = originalText,
- index = index,
- wordCount = wordStatisticsTag.wordCount,
- characterCount = wordStatisticsTag.characterCount,
- signature = chapterEvent.sig,
- chatRoomId = chatRoomId
- )
- }
- }
- }
- }
- }
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraChunk.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraChunk.kt
deleted file mode 100644
index f71f451d..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraChunk.kt
+++ /dev/null
@@ -1,147 +0,0 @@
-package com.machankura.bennu.compose.database.model
-
-import androidx.room3.Entity
-import androidx.room3.ForeignKey
-import androidx.room3.PrimaryKey
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.vitorpamplona.quartz.nip31Alts.AltTag
-import com.machankura.bennu.compose.database.model.traits.OptionalNostrEventEntity
-import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
-import com.machankura.bennu.compose.nostr.nip30303.ChunkEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.ChapterIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.IndexTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.WordStatisticsTag
-import kotlin.time.Clock
-import kotlin.time.Instant
-
-/**
- * 30303
- */
-@Entity(
- foreignKeys = [
- ForeignKey(
- entity = MantraChapter::class,
- parentColumns = ["id"],
- childColumns = ["chapterId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = ChatRoom::class,
- parentColumns = ["id"],
- childColumns = ["chatRoomId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ],
-)
-data class MantraChunk(
- @PrimaryKey
- val id: HexKey,
- val chapterId: HexKey,
- val publicKey: HexKey,
- val text: String,
- val index: Int,
- val wordCount: Int,
- val characterCount: Int,
-
- /**
- * Signature will be an empty string if this is a rumor
- */
- val signature: String,
-
- val chatRoomId: String,
-
- val relayHint: String? = null,
- val marmotGroupEventId: HexKey? = null,
-
- /** The [GroupSignedEvent] this row was made from, when the group signed it. */
- val groupSignedEventId: HexKey? = null,
-
- /**
- * Related nostrEventId if this is not a rumor...
- */
- override val nostrEventId: HexKey? = null,
- override val createdAt: Instant = Clock.System.now(),
- override val updatedAt: Instant = createdAt
-): OptionalNostrEventEntity, TimestampedEntity {
-
- @Deprecated(
- "Chronicle fallback for work signed before the GroupSignedEvent table. Read the " +
- "event off that table instead; this rebuild goes when the last pre-v13 install " +
- "does -- see the removal checklist in docs/member-chronicle.md."
- )
- fun toChunkEvent(): ChunkEvent {
- return ChunkEvent(
- id = id,
- pubKey = publicKey,
- createdAt = createdAt.epochSeconds,
- // Tag order matches ChunkEvent.build so the event id round-trips.
- tags = TagArrayBuilder()
- .addUnique(AltTag.assemble(ChunkEvent.ALT_DESCRIPTION))
- .addUnique(
- ChapterIdTag.assemble(chapterId)
- )
- .addUnique(
- IndexTag.assemble(
- index
- )
- )
- .addUnique(
- WordStatisticsTag.assemble(wordCount, characterCount)
- )
- .build(),
- content = text,
- sig = signature
- )
- }
-
- companion object {
- fun fromChunkEventTemplate(
- chunkEventTemplate: EventTemplate,
- chatRoomId: HexKey,
- userPublicKey: HexKey,
- ): MantraChunk? {
- return fromChunkEvent(
- ChunkEvent(
- id = EventHasher.hashId(
- pubKey = userPublicKey,
- tags = chunkEventTemplate.tags,
- content = chunkEventTemplate.content,
- createdAt = chunkEventTemplate.createdAt,
- kind = chunkEventTemplate.kind,
- ),
- content = chunkEventTemplate.content,
- tags = chunkEventTemplate.tags,
- createdAt = chunkEventTemplate.createdAt,
- pubKey = userPublicKey,
- sig = "", // Unsigned rumor
- ),
- chatRoomId = chatRoomId,
- )
- }
-
- fun fromChunkEvent(chunkEvent: ChunkEvent, chatRoomId: HexKey): MantraChunk? {
- return chunkEvent.wordStatisticsTag?.let { wordStatisticsTag ->
- chunkEvent.index()?.let { index ->
- chunkEvent.chapterId()?.let { chapterId ->
- MantraChunk(
- id = chunkEvent.id,
- publicKey = chunkEvent.pubKey,
- createdAt = Instant.fromEpochSeconds(chunkEvent.createdAt),
- index = index,
- wordCount = wordStatisticsTag.wordCount,
- characterCount = wordStatisticsTag.characterCount,
- chapterId = chapterId,
- text = chunkEvent.content,
- signature = chunkEvent.sig,
- chatRoomId = chatRoomId
- )
- }
-
- }
- }
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraDialect.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraDialect.kt
deleted file mode 100644
index 113b4b99..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraDialect.kt
+++ /dev/null
@@ -1,126 +0,0 @@
-package com.machankura.bennu.compose.database.model
-
-import androidx.room3.Entity
-import androidx.room3.ForeignKey
-import androidx.room3.PrimaryKey
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.vitorpamplona.quartz.nip31Alts.AltTag
-import com.machankura.bennu.compose.database.model.traits.OptionalNostrEventEntity
-import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
-import com.machankura.bennu.compose.nostr.nip30303.DialectEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.CountryTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.LanguageTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.NameTag
-import kotlin.time.Clock
-import kotlin.time.Instant
-
-/**
- * 30304
- */
-@Entity(
- foreignKeys = [
- ForeignKey(
- entity = ChatRoom::class,
- parentColumns = ["id"],
- childColumns = ["chatRoomId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ]
-)
-data class MantraDialect(
- @PrimaryKey
- val id: HexKey,
- val publicKey: HexKey,
- val name: String,
- val country: String,
- val language: String,
-
- val signature: String,
-
- val chatRoomId: String,
-
- val relayHint: String? = null,
- val marmotGroupEventId: HexKey? = null,
-
- /** The [GroupSignedEvent] this row was made from, when the group signed it. */
- val groupSignedEventId: HexKey? = null,
-
- /**
- * Related nostrEventId if this is not a rumor...
- */
- override val nostrEventId: HexKey? = null,
- override val createdAt: Instant = Clock.System.now(),
- override val updatedAt: Instant = createdAt
-): OptionalNostrEventEntity, TimestampedEntity {
-
- @Deprecated(
- "Chronicle fallback for work signed before the GroupSignedEvent table. Read the " +
- "event off that table instead; this rebuild goes when the last pre-v13 install " +
- "does -- see the removal checklist in docs/member-chronicle.md."
- )
- fun toDialectEvent(): DialectEvent {
- return DialectEvent(
- id = id,
- pubKey = publicKey,
- createdAt = createdAt.epochSeconds,
- // Tag order matches DialectEvent.build so the event id round-trips.
- tags = TagArrayBuilder()
- .addUnique(AltTag.assemble(DialectEvent.ALT_DESCRIPTION))
- .addUnique(NameTag.assemble(name))
- .addUnique(CountryTag.assemble(country))
- .addUnique(LanguageTag.assemble(language))
- .build(),
- content = language, // TODO: Consider using the isoCode... as content?
- sig = signature
- )
- }
-
- companion object {
- fun fromDialectEventTemplate(
- dialectEventTemplate: EventTemplate,
- chatRoomId: HexKey,
- userPublicKey: HexKey,
- ): MantraDialect? {
- return fromDialectEvent(
- DialectEvent(
- id = EventHasher.hashId(
- pubKey = userPublicKey,
- tags = dialectEventTemplate.tags,
- content = dialectEventTemplate.content,
- createdAt = dialectEventTemplate.createdAt,
- kind = dialectEventTemplate.kind,
- ),
- content = dialectEventTemplate.content,
- tags = dialectEventTemplate.tags,
- createdAt = dialectEventTemplate.createdAt,
- pubKey = userPublicKey,
- sig = "", // Unsigned rumor
- ),
- chatRoomId = chatRoomId,
- )
- }
-
- fun fromDialectEvent(dialectEvent: DialectEvent, chatRoomId: HexKey): MantraDialect? {
- return dialectEvent.name()?.let { name ->
- dialectEvent.language()?.let { language ->
- dialectEvent.country()?.let { country ->
-
- MantraDialect(
- id = dialectEvent.id,
- publicKey = dialectEvent.pubKey,
- createdAt = Instant.fromEpochSeconds(dialectEvent.createdAt),
- name = name,
- language = language,
- country = country,
- signature = dialectEvent.sig,
- chatRoomId = chatRoomId
- )
- }
- }
- }
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslation.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslation.kt
deleted file mode 100644
index 31983b4f..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslation.kt
+++ /dev/null
@@ -1,107 +0,0 @@
-package com.machankura.bennu.compose.database.model
-
-import androidx.room3.Entity
-import androidx.room3.ForeignKey
-import androidx.room3.PrimaryKey
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.utils.ensure
-import com.machankura.bennu.compose.database.model.traits.OptionalNostrEventEntity
-import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
-import com.machankura.bennu.compose.nostr.nip30303.TranslationEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationArtifactVersionIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationChunkIdTag
-import kotlin.time.Clock
-import kotlin.time.Instant
-
-/**
- * 30305
- */
-@Entity(
- foreignKeys = [
- ForeignKey(
- entity = MantraTranslationChunk::class,
- parentColumns = ["id"],
- childColumns = ["translationChunkId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = MantraTranslationArtifactVersion::class,
- parentColumns = ["id"],
- childColumns = ["translationArtifactVersionId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = ChatRoom::class,
- parentColumns = ["id"],
- childColumns = ["chatRoomId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ],
-)
-data class MantraTranslation(
- @PrimaryKey
- val id: HexKey,
- val publicKey: HexKey,
- val translationChunkId: HexKey,
- val translationArtifactVersionId: HexKey,
- val text: String,
-
- val signature: String,
-
- val chatRoomId: String,
-
- val relayHint: String? = null,
- val marmotGroupEventId: HexKey? = null,
-
- /** The [GroupSignedEvent] this row was made from, when the group signed it. */
- val groupSignedEventId: HexKey? = null,
-
- /**
- * Related nostrEventId if this is not a rumor...
- */
- override val nostrEventId: HexKey? = null,
- override val createdAt: Instant = Clock.System.now(),
- override val updatedAt: Instant = createdAt
-): OptionalNostrEventEntity, TimestampedEntity {
-
- fun toTranslationEvent(): TranslationEvent {
- return TranslationEvent(
- id = id,
- pubKey = publicKey,
- createdAt = createdAt.epochSeconds,
- tags = TagArrayBuilder()
- .addUnique(
- TranslationArtifactVersionIdTag.assemble(translationArtifactVersionId)
- )
- .addUnique(
- TranslationChunkIdTag.assemble(translationChunkId)
- )
- .build(),
- content = text,
- sig = signature
- )
- }
-
- companion object {
- fun fromTranslationEvent(translationEvent: TranslationEvent, chatRoomId: HexKey): MantraTranslation? {
- ensure(translationEvent.translationChunkId() != null) { return null}
- ensure(translationEvent.translationArtifactVersionId() != null) { return null}
-
- return translationEvent.translationChunkId()?.let { translationChunkId ->
- translationEvent.translationArtifactVersionId()?.let { translationArtifactVersionId ->
- MantraTranslation(
- id = translationEvent.id,
- publicKey = translationEvent.pubKey,
- createdAt = Instant.fromEpochSeconds(translationEvent.createdAt),
- text = translationEvent.content,
- translationChunkId = translationChunkId,
- translationArtifactVersionId = translationArtifactVersionId,
- signature = translationEvent.sig,
- chatRoomId = chatRoomId
- )
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationArtifactVersion.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationArtifactVersion.kt
deleted file mode 100644
index 8f7c45e5..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationArtifactVersion.kt
+++ /dev/null
@@ -1,158 +0,0 @@
-package com.machankura.bennu.compose.database.model
-
-import androidx.room3.Entity
-import androidx.room3.ForeignKey
-import androidx.room3.PrimaryKey
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.vitorpamplona.quartz.nip31Alts.AltTag
-import com.machankura.bennu.compose.database.model.traits.OptionalNostrEventEntity
-import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
-import com.machankura.bennu.compose.nostr.nip30303.TranslationArtifactVersionEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.ArtifactVersionIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.DialectIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.LicenseTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.NameTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.VisibilityTag
-import kotlin.time.Clock
-import kotlin.time.Instant
-
-/**
- * 30306
- */
-@Entity(
- foreignKeys = [
- ForeignKey(
- entity = MantraArtifactVersion::class,
- parentColumns = ["id"],
- childColumns = ["artifactVersionId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = MantraDialect::class,
- parentColumns = ["id"],
- childColumns = ["dialectId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = ChatRoom::class,
- parentColumns = ["id"],
- childColumns = ["chatRoomId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ],
-)
-data class MantraTranslationArtifactVersion(
- @PrimaryKey
- val id: HexKey,
- val publicKey: HexKey,
- val artifactVersionId: HexKey,
- val dialectId: HexKey,
- val name: String,
- val visibility: String,
- val license: String,
-
- /**
- * Signature will be an empty string if this is a rumor
- */
- val signature: String,
-
- val chatRoomId: String,
-
- val relayHint: String? = null,
- val marmotGroupEventId: HexKey? = null,
-
- /** The [GroupSignedEvent] this row was made from, when the group signed it. */
- val groupSignedEventId: HexKey? = null,
-
- /**
- * Related nostrEventId if this is not a rumor...
- */
- override val nostrEventId: HexKey? = null,
- override val createdAt: Instant = Clock.System.now(),
- override val updatedAt: Instant = createdAt
-): OptionalNostrEventEntity, TimestampedEntity {
-
- @Deprecated(
- "Chronicle fallback for work signed before the GroupSignedEvent table. Read the " +
- "event off that table instead; this rebuild goes when the last pre-v13 install " +
- "does -- see the removal checklist in docs/member-chronicle.md."
- )
- fun toTranslationArtifactVersionEvent(): TranslationArtifactVersionEvent {
- return TranslationArtifactVersionEvent(
- id = id,
- pubKey = publicKey,
- createdAt = createdAt.epochSeconds,
- // Tag order matches TranslationArtifactVersionEvent.build so the id round-trips.
- tags = TagArrayBuilder()
- .addUnique(AltTag.assemble(TranslationArtifactVersionEvent.ALT_DESCRIPTION))
- .addUnique(
- ArtifactVersionIdTag.assemble(artifactVersionId)
- )
- .addUnique(
- DialectIdTag.assemble(dialectId)
- )
- .addUnique(NameTag.assemble(name))
- .addUnique(VisibilityTag.assemble(visibility))
- .addUnique(LicenseTag.assemble(license))
- .build(),
- content = "",
- sig = signature
- )
- }
-
- companion object {
- fun fromTranslationArtifactVersionEventTemplate(
- translationArtifactVersionEventTemplate: EventTemplate,
- chatRoomId: HexKey,
- userPublicKey: HexKey,
- ): MantraTranslationArtifactVersion? {
- return fromTranslationArtifactVersionEvent(
- TranslationArtifactVersionEvent(
- id = EventHasher.hashId(
- pubKey = userPublicKey,
- tags = translationArtifactVersionEventTemplate.tags,
- content = translationArtifactVersionEventTemplate.content,
- createdAt = translationArtifactVersionEventTemplate.createdAt,
- kind = translationArtifactVersionEventTemplate.kind,
- ),
- content = translationArtifactVersionEventTemplate.content,
- tags = translationArtifactVersionEventTemplate.tags,
- createdAt = translationArtifactVersionEventTemplate.createdAt,
- pubKey = userPublicKey,
- sig = "", // Unsigned rumor
- ),
- chatRoomId = chatRoomId,
- )
- }
-
- fun fromTranslationArtifactVersionEvent(translationArtifactVersionEvent: TranslationArtifactVersionEvent, chatRoomId: HexKey): MantraTranslationArtifactVersion? {
-
- return translationArtifactVersionEvent.artifactVersionId()?.let { artifactVersionId ->
- translationArtifactVersionEvent.dialectId()?.let { dialectId ->
- translationArtifactVersionEvent.name()?.let { name ->
- translationArtifactVersionEvent.visibility()?.let { visibility ->
- translationArtifactVersionEvent.license()?.let { license ->
- MantraTranslationArtifactVersion(
- id = translationArtifactVersionEvent.id,
- publicKey = translationArtifactVersionEvent.pubKey,
- createdAt = Instant.fromEpochSeconds(translationArtifactVersionEvent.createdAt),
- artifactVersionId = artifactVersionId,
- dialectId = dialectId,
- name = name,
- visibility = visibility,
- license = license,
- signature = translationArtifactVersionEvent.sig,
- chatRoomId = chatRoomId
- )
- }
- }
- }
- }
- }
- }
- }
-}
-
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationArtifactVersionContributor.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationArtifactVersionContributor.kt
deleted file mode 100644
index ae958bed..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationArtifactVersionContributor.kt
+++ /dev/null
@@ -1,90 +0,0 @@
-package com.machankura.bennu.compose.database.model
-
-import androidx.room3.Entity
-import androidx.room3.ForeignKey
-import androidx.room3.PrimaryKey
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.utils.TimeUtils
-import com.machankura.bennu.compose.database.model.traits.OptionalNostrEventEntity
-import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
-import com.machankura.bennu.compose.nostr.nip30303.TranslationArtifactVersionContributorListEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.ContributorTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationArtifactVersionIdTag
-import kotlin.time.Clock
-import kotlin.time.Instant
-
-/**
- * 30307
- */
-@Entity(
- foreignKeys = [
- ForeignKey(
- entity = MantraTranslationArtifactVersionContributor::class,
- parentColumns = ["id"],
- childColumns = ["translationArtifactVersionId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = ChatRoom::class,
- parentColumns = ["id"],
- childColumns = ["chatRoomId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ],
-)
-data class MantraTranslationArtifactVersionContributor(
- @PrimaryKey
- val id: HexKey,
- val publicKey: HexKey,
- val translationArtifactVersionId: HexKey,
- val editorPublicKey: HexKey,
-
- /**
- * Signature will be an empty string if this is a rumor
- */
- val signature: String,
-
- val chatRoomId: String,
-
- val relayHint: String? = null,
- val marmotGroupEventId: HexKey? = null,
-
- /** The [GroupSignedEvent] this row was made from, when the group signed it. */
- val groupSignedEventId: HexKey? = null,
-
- /**
- * Related nostrEventId if this is not a rumor...
- */
- override val nostrEventId: HexKey? = null,
- override val createdAt: Instant = Clock.System.now(),
- override val updatedAt: Instant = createdAt
-): OptionalNostrEventEntity, TimestampedEntity {
-
- companion object {
- fun toTranslationChapterProofReaderListEvent(chatRoomId: HexKey, mantraTranslationChapterProofReaders: List): TranslationArtifactVersionContributorListEvent {
- // TODO: create TranslationChapterProofReaderListEvent from mantraTranslationChapterProofReaders
- return TranslationArtifactVersionContributorListEvent(
- id = "",
- pubKey = "",
- createdAt = TimeUtils.now(),
- tags = TagArrayBuilder()
-
- .addUnique(
- TranslationArtifactVersionIdTag.assemble("") // TODO: use actual value..
- )
- // TODO: Add tag for editorPublicKey
- .addUnique(
- ContributorTag.assemble(
- "",
- ContributorTag.ROLE_EDITOR
- )
- )
- .build(),
- content = "",
- sig = ""
- )
- }
- }
-}
-
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationChapter.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationChapter.kt
deleted file mode 100644
index 5aa9475e..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationChapter.kt
+++ /dev/null
@@ -1,146 +0,0 @@
-package com.machankura.bennu.compose.database.model
-
-import androidx.room3.Entity
-import androidx.room3.ForeignKey
-import androidx.room3.PrimaryKey
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.vitorpamplona.quartz.nip31Alts.AltTag
-import com.machankura.bennu.compose.database.model.traits.OptionalNostrEventEntity
-import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
-import com.machankura.bennu.compose.nostr.nip30303.TranslationChapterEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.ChapterIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.IndexTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationArtifactVersionIdTag
-import kotlin.time.Clock
-import kotlin.time.Instant
-
-/**
- * 30308
- */
-@Entity(
- foreignKeys = [
- ForeignKey(
- entity = MantraTranslationArtifactVersion::class,
- parentColumns = ["id"],
- childColumns = ["translationArtifactVersionId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = MantraChapter::class,
- parentColumns = ["id"],
- childColumns = ["chapterId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = ChatRoom::class,
- parentColumns = ["id"],
- childColumns = ["chatRoomId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ],
-)
-data class MantraTranslationChapter(
- @PrimaryKey
- val id: HexKey,
- val publicKey: HexKey,
- val chapterId: HexKey,
- val translationArtifactVersionId: HexKey,
- val index: Int,
-
- /**
- * Signature will be an empty string if this is a rumor
- */
- val signature: String,
-
- val chatRoomId: String,
-
- val relayHint: String? = null,
- val marmotGroupEventId: HexKey? = null,
-
- /** The [GroupSignedEvent] this row was made from, when the group signed it. */
- val groupSignedEventId: HexKey? = null,
-
- /**
- * Related nostrEventId if this is not a rumor...
- */
- override val nostrEventId: HexKey? = null,
- override val createdAt: Instant = Clock.System.now(),
- override val updatedAt: Instant = createdAt
-): OptionalNostrEventEntity, TimestampedEntity {
- @Deprecated(
- "Chronicle fallback for work signed before the GroupSignedEvent table. Read the " +
- "event off that table instead; this rebuild goes when the last pre-v13 install " +
- "does -- see the removal checklist in docs/member-chronicle.md."
- )
- fun toTranslationChapterEvent(): TranslationChapterEvent {
- return TranslationChapterEvent(
- id = id,
- pubKey = publicKey,
- createdAt = createdAt.epochSeconds,
- // Tag order matches TranslationChapterEvent.build so the id round-trips.
- tags = TagArrayBuilder()
- .addUnique(AltTag.assemble(TranslationChapterEvent.ALT_DESCRIPTION))
- .addUnique(
- TranslationArtifactVersionIdTag.assemble(translationArtifactVersionId)
- )
- .addUnique(
- ChapterIdTag.assemble(chapterId)
- )
- .addUnique(
- IndexTag.assemble(index)
- )
- .build(),
- content = "",
- sig = signature
- )
- }
-
- companion object {
- fun fromTranslationChapterEventTemplate(
- translationChapterEventTemplate: EventTemplate,
- chatRoomId: HexKey,
- userPublicKey: HexKey,
- ): MantraTranslationChapter? {
- return fromTranslationChapterEvent(
- TranslationChapterEvent(
- id = EventHasher.hashId(
- pubKey = userPublicKey,
- tags = translationChapterEventTemplate.tags,
- content = translationChapterEventTemplate.content,
- createdAt = translationChapterEventTemplate.createdAt,
- kind = translationChapterEventTemplate.kind,
- ),
- content = translationChapterEventTemplate.content,
- tags = translationChapterEventTemplate.tags,
- createdAt = translationChapterEventTemplate.createdAt,
- pubKey = userPublicKey,
- sig = "", // Unsigned rumor
- ),
- chatRoomId = chatRoomId,
- )
- }
-
- fun fromTranslationChapterEvent(translationChapterEvent: TranslationChapterEvent, chatRoomId: HexKey): MantraTranslationChapter? {
- return translationChapterEvent.chapterId()?.let { chapterId ->
- translationChapterEvent.translationArtifactVersionId()?.let { translationArtifactVersionId ->
- translationChapterEvent.index()?.let { index ->
- MantraTranslationChapter(
- id = translationChapterEvent.id,
- publicKey = translationChapterEvent.pubKey,
- createdAt = Instant.fromEpochSeconds(translationChapterEvent.createdAt),
- chapterId = chapterId,
- translationArtifactVersionId = translationArtifactVersionId,
- index = index,
- signature = translationChapterEvent.sig,
- chatRoomId = chatRoomId
- )
- }
- }
- }
- }
- }
-}
-
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationChapterContributor.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationChapterContributor.kt
deleted file mode 100644
index 8a776a53..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationChapterContributor.kt
+++ /dev/null
@@ -1,87 +0,0 @@
-package com.machankura.bennu.compose.database.model
-
-import androidx.room3.Entity
-import androidx.room3.ForeignKey
-import androidx.room3.PrimaryKey
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nipF4Podcasts.metadata.tags.AuthorTag
-import com.vitorpamplona.quartz.utils.TimeUtils
-import com.machankura.bennu.compose.database.model.traits.OptionalNostrEventEntity
-import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
-import com.machankura.bennu.compose.nostr.nip30303.TranslationChapterContributorListEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.ContributorTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationChapterIdTag
-import kotlin.time.Clock
-import kotlin.time.Instant
-
-/**
- * 30310
- */
-@Entity(
- foreignKeys = [
- ForeignKey(
- entity = MantraTranslationChapter::class,
- parentColumns = ["id"],
- childColumns = ["translationChapterId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = ChatRoom::class,
- parentColumns = ["id"],
- childColumns = ["chatRoomId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ],
-)
-data class MantraTranslationChapterContributor(
- @PrimaryKey
- val id: HexKey,
- val publicKey: HexKey,
- val translationChapterId: HexKey,
- val translatorPublicKey: HexKey,
-
- val role: String,
- /**
- * Signature will be an empty string if this is a rumor
- */
- val signature: String,
-
- val chatRoomId: String,
-
- val relayHint: String? = null,
- val marmotGroupEventId: HexKey? = null,
-
- /** The [GroupSignedEvent] this row was made from, when the group signed it. */
- val groupSignedEventId: HexKey? = null,
-
- /**
- * Related nostrEventId if this is not a rumor...
- */
- override val nostrEventId: HexKey? = null,
- override val createdAt: Instant = Clock.System.now(),
- override val updatedAt: Instant = createdAt
-): OptionalNostrEventEntity, TimestampedEntity {
-
- companion object {
- fun toTranslationChapterTranslatorListEvent(mantraTranslationChapterTranslators: List): TranslationChapterContributorListEvent {
- // TODO: create TranslationChapterProofReaderListEvent from mantraTranslationChapterProofReaders
- return TranslationChapterContributorListEvent(
- id = "",
- pubKey = "",
- createdAt = TimeUtils.now(),
- tags = TagArrayBuilder()
- .addUnique(
- TranslationChapterIdTag.assemble("")
- )
- .addUnique(
- ContributorTag.assemble("", ContributorTag.ROLE_TRANSLATOR)
- )
- .build(),
- content = "",
- sig = ""
- )
- }
- }
-}
-
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationChunk.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationChunk.kt
deleted file mode 100644
index ac090b51..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationChunk.kt
+++ /dev/null
@@ -1,148 +0,0 @@
-package com.machankura.bennu.compose.database.model
-
-import androidx.room3.Entity
-import androidx.room3.ForeignKey
-import androidx.room3.PrimaryKey
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.vitorpamplona.quartz.nip31Alts.AltTag
-import com.machankura.bennu.compose.database.model.traits.OptionalNostrEventEntity
-import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
-import com.machankura.bennu.compose.nostr.nip30303.TranslationChunkEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.ChunkIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.IndexTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationChapterIdTag
-import kotlin.time.Clock
-import kotlin.time.Instant
-
-/**
- * 30311
- */
-@Entity(
- foreignKeys = [
- ForeignKey(
- entity = MantraChunk::class,
- parentColumns = ["id"],
- childColumns = ["chunkId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = MantraTranslationChapter::class,
- parentColumns = ["id"],
- childColumns = ["translationChapterId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = ChatRoom::class,
- parentColumns = ["id"],
- childColumns = ["chatRoomId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ],
-)
-data class MantraTranslationChunk(
- @PrimaryKey
- val id: HexKey,
- val publicKey: HexKey,
- val chunkId: HexKey,
- val translationChapterId: HexKey,
- val text: String,
- val index: Int,
-
- /**
- * Signature will be an empty string if this is a rumor
- */
- val signature: String,
-
- val chatRoomId: String,
-
- val relayHint: String? = null,
- val marmotGroupEventId: HexKey? = null,
-
- /** The [GroupSignedEvent] this row was made from, when the group signed it. */
- val groupSignedEventId: HexKey? = null,
-
- /**
- * Related nostrEventId if this is not a rumor...
- */
- override val nostrEventId: HexKey? = null,
- override val createdAt: Instant = Clock.System.now(),
- override val updatedAt: Instant = createdAt
-): OptionalNostrEventEntity, TimestampedEntity {
-
- @Deprecated(
- "Chronicle fallback for work signed before the GroupSignedEvent table. Read the " +
- "event off that table instead; this rebuild goes when the last pre-v13 install " +
- "does -- see the removal checklist in docs/member-chronicle.md."
- )
- fun toTranslationChunkEvent(): TranslationChunkEvent {
- return TranslationChunkEvent(
- id = id,
- pubKey = publicKey,
- createdAt = createdAt.epochSeconds,
- // Tag order matches TranslationChunkEvent.build so the id round-trips.
- tags = TagArrayBuilder()
- .addUnique(AltTag.assemble(TranslationChunkEvent.ALT_DESCRIPTION))
- .addUnique(
- TranslationChapterIdTag.assemble(translationChapterId)
- )
- .addUnique(
- ChunkIdTag.assemble(chunkId)
- )
- .addUnique(
- IndexTag.assemble(index)
- )
- .build(),
- content = text,
- sig = signature
- )
- }
-
- companion object {
- fun fromTranslationChunkEventTemplate(
- translationChunkEventTemplate: EventTemplate,
- chatRoomId: HexKey,
- userPublicKey: HexKey,
- ): MantraTranslationChunk? {
- return fromTranslationChunkEvent(
- TranslationChunkEvent(
- id = EventHasher.hashId(
- pubKey = userPublicKey,
- tags = translationChunkEventTemplate.tags,
- content = translationChunkEventTemplate.content,
- createdAt = translationChunkEventTemplate.createdAt,
- kind = translationChunkEventTemplate.kind,
- ),
- content = translationChunkEventTemplate.content,
- tags = translationChunkEventTemplate.tags,
- createdAt = translationChunkEventTemplate.createdAt,
- pubKey = userPublicKey,
- sig = "", // Unsigned rumor
- ),
- chatRoomId = chatRoomId,
- )
- }
-
- fun fromTranslationChunkEvent(translationChunkEvent: TranslationChunkEvent, chatRoomId: HexKey): MantraTranslationChunk? {
- return translationChunkEvent.translationChapterId()?.let { translationChapterId ->
- translationChunkEvent.chunkId()?.let { chunkId ->
- translationChunkEvent.index()?.let { index ->
- MantraTranslationChunk(
- id = translationChunkEvent.id,
- publicKey = translationChunkEvent.pubKey,
- createdAt = Instant.fromEpochSeconds(translationChunkEvent.createdAt),
- translationChapterId = translationChapterId,
- chunkId = chunkId,
- index = index,
- text = translationChunkEvent.content,
- signature = translationChunkEvent.sig,
- chatRoomId = chatRoomId
- )
- }
- }
- }
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationChunkProposal.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationChunkProposal.kt
deleted file mode 100644
index 68c63b74..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationChunkProposal.kt
+++ /dev/null
@@ -1,140 +0,0 @@
-package com.machankura.bennu.compose.database.model
-
-import androidx.room3.Entity
-import androidx.room3.ForeignKey
-import androidx.room3.PrimaryKey
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.vitorpamplona.quartz.nip31Alts.AltTag
-import com.machankura.bennu.compose.database.model.traits.OptionalNostrEventEntity
-import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
-import com.machankura.bennu.compose.nostr.nip30303.TranslationChunkEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.ChunkIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.IndexTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationChapterIdTag
-import kotlin.time.Clock
-import kotlin.time.Instant
-
-/**
- * 30311
- */
-@Entity(
- foreignKeys = [
- ForeignKey(
- entity = MantraChunk::class,
- parentColumns = ["id"],
- childColumns = ["chunkId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = MantraTranslationChapter::class,
- parentColumns = ["id"],
- childColumns = ["translationChapterId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = ChatRoom::class,
- parentColumns = ["id"],
- childColumns = ["chatRoomId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ],
-)
-data class MantraTranslationChunkProposal(
- @PrimaryKey
- val id: HexKey,
- val publicKey: HexKey,
- val chunkId: HexKey,
- val translationChapterId: HexKey,
- val text: String,
- val index: Int,
-
- /**
- * Signature will be an empty string if this is a rumor
- */
- val signature: String,
-
- val chatRoomId: String,
-
- val relayHint: String? = null,
- val marmotGroupEventId: HexKey? = null,
-
- /**
- * Related nostrEventId if this is not a rumor...
- */
- override val nostrEventId: HexKey? = null,
- override val createdAt: Instant = Clock.System.now(),
- override val updatedAt: Instant = createdAt
-): OptionalNostrEventEntity, TimestampedEntity {
-
- fun toTranslationChunkEvent(): TranslationChunkEvent {
- return TranslationChunkEvent(
- id = id,
- pubKey = publicKey,
- createdAt = createdAt.epochSeconds,
- // Tag order matches TranslationChunkEvent.build so the id round-trips.
- tags = TagArrayBuilder()
- .addUnique(AltTag.assemble(TranslationChunkEvent.ALT_DESCRIPTION))
- .addUnique(
- TranslationChapterIdTag.assemble(translationChapterId)
- )
- .addUnique(
- ChunkIdTag.assemble(chunkId)
- )
- .addUnique(
- IndexTag.assemble(index)
- )
- .build(),
- content = text,
- sig = signature
- )
- }
-
- companion object {
- fun fromTranslationChunkEventTemplate(
- translationChunkEventTemplate: EventTemplate,
- chatRoomId: HexKey,
- userPublicKey: HexKey,
- ): MantraTranslationChunkProposal? {
- return fromTranslationChunkEvent(
- TranslationChunkEvent(
- id = EventHasher.hashId(
- pubKey = userPublicKey,
- tags = translationChunkEventTemplate.tags,
- content = translationChunkEventTemplate.content,
- createdAt = translationChunkEventTemplate.createdAt,
- kind = translationChunkEventTemplate.kind,
- ),
- content = translationChunkEventTemplate.content,
- tags = translationChunkEventTemplate.tags,
- createdAt = translationChunkEventTemplate.createdAt,
- pubKey = userPublicKey,
- sig = "", // Unsigned rumor
- ),
- chatRoomId = chatRoomId,
- )
- }
-
- fun fromTranslationChunkEvent(translationChunkEvent: TranslationChunkEvent, chatRoomId: HexKey): MantraTranslationChunkProposal? {
- return translationChunkEvent.translationChapterId()?.let { translationChapterId ->
- translationChunkEvent.chunkId()?.let { chunkId ->
- translationChunkEvent.index()?.let { index ->
- MantraTranslationChunkProposal(
- id = translationChunkEvent.id,
- publicKey = translationChunkEvent.pubKey,
- createdAt = Instant.fromEpochSeconds(translationChunkEvent.createdAt),
- translationChapterId = translationChapterId,
- chunkId = chunkId,
- index = index,
- text = translationChunkEvent.content,
- signature = translationChunkEvent.sig,
- chatRoomId = chatRoomId
- )
- }
- }
- }
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationContributor.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationContributor.kt
deleted file mode 100644
index 56ef346f..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MantraTranslationContributor.kt
+++ /dev/null
@@ -1,116 +0,0 @@
-package com.machankura.bennu.compose.database.model
-
-import androidx.room3.Entity
-import androidx.room3.ForeignKey
-import androidx.room3.PrimaryKey
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip01Core.tags.dTag.DTag
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.machankura.bennu.compose.database.model.traits.OptionalNostrEventEntity
-import com.machankura.bennu.compose.database.model.traits.TimestampedEntity
-import com.machankura.bennu.compose.nostr.nip30303.TranslationContributorListEvent
-import com.machankura.bennu.compose.nostr.nip30303.tags.ContributorTag
-import kotlin.time.Clock
-import kotlin.time.Instant
-
-/**
- * 30312
- */
-@Entity(
- foreignKeys = [
- ForeignKey(
- entity = MantraTranslation::class,
- parentColumns = ["id"],
- childColumns = ["translationId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ForeignKey(
- entity = ChatRoom::class,
- parentColumns = ["id"],
- childColumns = ["chatRoomId"],
- onDelete = ForeignKey.CASCADE,
- ),
- ],
-)
-data class MantraTranslationContributor(
- @PrimaryKey
- val id: HexKey,
- val dTag: String,
- val publicKey: HexKey,
- val translationId: HexKey,
- val translatorPublicKey: HexKey,
-
- /**
- * Signature will be an empty string if this is a rumor
- */
- val signature: String,
-
- val chatRoomId: String,
-
- val relayHint: String? = null,
- val marmotGroupEventId: HexKey? = null,
-
- /** The [GroupSignedEvent] this row was made from, when the group signed it. */
- val groupSignedEventId: HexKey? = null,
- /**
- * Related nostrEventId if this is not a rumor...
- */
- override val nostrEventId: HexKey? = null,
- override val createdAt: Instant = Clock.System.now(),
- override val updatedAt: Instant = createdAt
-): OptionalNostrEventEntity, TimestampedEntity {
-
- companion object {
- fun toTranslationChapterProofReaderListEvent(mantraTranslationContributors: List): TranslationContributorListEvent? {
- mantraTranslationContributors.firstOrNull()?.let { firstMantraTranslationTranslator ->
- val allFromSameEvent = mantraTranslationContributors.all {
- it.publicKey == firstMantraTranslationTranslator.publicKey
- && it.createdAt == firstMantraTranslationTranslator.createdAt
- && it.dTag == firstMantraTranslationTranslator.dTag
- }
-
- if (allFromSameEvent) {
- val translatorPublicKeys = mantraTranslationContributors.map {
- ContributorTag.assemble(
- pubKey = it.publicKey,
- role = ContributorTag.ROLE_TRANSLATOR
- )
- }
- val template = eventTemplate(
- kind = TranslationContributorListEvent.KIND,
- description = "",
- createdAt = firstMantraTranslationTranslator.createdAt.epochSeconds
- ) {
- addUnique(
- DTag.assemble(
- firstMantraTranslationTranslator.dTag
- )
- )
- alt(TranslationContributorListEvent.ALT_DESCRIPTION)
-
- }
-
-
- return TranslationContributorListEvent(
- id = EventHasher.hashId(
- pubKey = firstMantraTranslationTranslator.publicKey,
- tags = template.tags,
- createdAt = template.createdAt,
- content = template.content,
- kind = template.kind
- ),
- pubKey = firstMantraTranslationTranslator.publicKey,
- createdAt = firstMantraTranslationTranslator.createdAt.epochSeconds,
- tags = translatorPublicKeys.toTypedArray(),
- content = template.content,
- sig = firstMantraTranslationTranslator.signature
- )
- }
- }
- return null
- }
- }
-}
-
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MarmotInnerEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MarmotInnerEvent.kt
index 00ead353..568724a9 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MarmotInnerEvent.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MarmotInnerEvent.kt
@@ -64,14 +64,6 @@ data class MarmotInnerEvent( // TODO: Rename this to GiftWrapPayload...
val content: String,
val quotedEventId: String? = null,
- /**
- * For a SubmissionEvent rumor, the id of the nip30303 event it carries.
- *
- * The submission's own id is derived from the envelope, so it is the only
- * handle the queue has on what is actually being submitted. Null for every
- * other kind, where the row *is* the event.
- */
- val payloadEventId: HexKey? = null,
/**
* Associated MarmotGroupEvent
@@ -140,7 +132,6 @@ data class MarmotInnerEvent( // TODO: Rename this to GiftWrapPayload...
if (!tags.contentDeepEquals(other.tags)) return false
if (content != other.content) return false
if (quotedEventId != other.quotedEventId) return false
- if (payloadEventId != other.payloadEventId) return false
if (marmotGroupEventId != other.marmotGroupEventId) return false
if (directMessageRecipientPublicKey != other.directMessageRecipientPublicKey) return false
if (createdAt != other.createdAt) return false
@@ -161,7 +152,6 @@ data class MarmotInnerEvent( // TODO: Rename this to GiftWrapPayload...
result = 31 * result + tags.contentDeepHashCode()
result = 31 * result + content.hashCode()
result = 31 * result + (quotedEventId?.hashCode() ?: 0)
- result = 31 * result + (payloadEventId?.hashCode() ?: 0)
result = 31 * result + (marmotGroupEventId?.hashCode() ?: 0)
result = 31 * result + (directMessageRecipientPublicKey?.hashCode() ?: 0)
result = 31 * result + createdAt.hashCode()
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MemberWallet.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MemberWallet.kt
new file mode 100644
index 00000000..68850128
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MemberWallet.kt
@@ -0,0 +1,68 @@
+package com.machankura.bennu.compose.database.model
+
+import androidx.room3.Entity
+import androidx.room3.Index
+import androidx.room3.PrimaryKey
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import kotlin.time.Clock
+import kotlin.time.Instant
+
+/**
+ * A guarded wallet this device holds the key of: one member's random key, and
+ * the request that asked a group to guard it. `docs/member-guarded-wallets.md`.
+ *
+ * The key is why there is a table at all. Everything else about a member's
+ * wallet is read off signed events -- whether it is certified is whether the
+ * group's room holds a 30334 for [walletId] that verifies, read again each time
+ * the way `GroupWallet` reads statements -- so there is no *certified* column to
+ * disagree with the signature.
+ *
+ * ### `guardingChatRoomId` is a plain column, never a foreign key
+ *
+ * The argument `docs/subgroups.md` makes against cascading `parentChatRoomId`,
+ * with money at the end of it. Deleting the group's room on this device must
+ * never delete a private key that coins may sit behind; and a member who leaves
+ * the group keeps a wallet the group still guards.
+ *
+ * ### One database holds every profile
+ *
+ * So every read is scoped by [ownerPublicKey], the profile the key belongs to.
+ */
+@Entity(
+ indices = [
+ Index("ownerPublicKey"),
+ Index("guardingChatRoomId"),
+ ],
+)
+data class MemberWallet(
+ /** `W`: `MemberWalletDerivation.walletId` of the wallet key. */
+ @PrimaryKey
+ val walletId: String,
+
+ /** The profile the wallet belongs to: the npub that signed the request. */
+ val ownerPublicKey: HexKey,
+
+ /** The group asked to guard it. */
+ val guardingChatRoomId: String,
+
+ /** The network, as `GroupWalletStatementEvent.chainName` writes it. */
+ val chain: String,
+
+ /**
+ * `k`, hex. Stored as `DkgSession.secretShare` is, in the profile's database;
+ * never logged, never sent. Lost with the device unless exported -- and then
+ * the guardians can still move the coins after 12 blocks.
+ */
+ val walletPrivateKey: HexKey,
+
+ /** The member's name for it, as the request carries it. */
+ val label: String? = null,
+
+ /** The signed 30335, whole: kept so a request the group did not sign can be asked again, unchanged. */
+ val requestJson: String,
+
+ val createdAt: Instant = Clock.System.now(),
+) {
+ override fun toString(): String =
+ "MemberWallet(walletId=$walletId, owner=$ownerPublicKey, guardedBy=$guardingChatRoomId, chain=$chain, key=)"
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MemberWalletSpend.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MemberWalletSpend.kt
new file mode 100644
index 00000000..18307bb9
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/model/MemberWalletSpend.kt
@@ -0,0 +1,53 @@
+package com.machankura.bennu.compose.database.model
+
+import androidx.room3.Entity
+import androidx.room3.Index
+import androidx.room3.PrimaryKey
+import kotlin.time.Clock
+import kotlin.time.Instant
+
+/**
+ * One transaction a member signed alone from their guarded wallet.
+ *
+ * The subset of [GroupTransaction] a spend with no signing session needs.
+ * `GroupTransaction` cannot hold it: its foreign keys are to a session and a
+ * room, and a member's own spend has neither. Written whole when it is signed,
+ * then filled in as the chain answers.
+ *
+ * No foreign key to [MemberWallet] either. A spend is a fact about the chain,
+ * and a row that cascaded away with its wallet would take the record of where
+ * the coins went with it.
+ */
+@Entity(
+ indices = [
+ Index("walletId"),
+ ],
+)
+data class MemberWalletSpend(
+ /** The transaction's id, which a segwit spend fixes before it is signed. */
+ @PrimaryKey
+ val txid: String,
+
+ /** `W`, the wallet the inputs are under. */
+ val walletId: String,
+
+ /** The PSBT as built, base64: what every input's sighash was computed from. */
+ val psbt: String,
+
+ /** The finished transaction, hex, once it has passed `correctlySpends`. */
+ val signedTransaction: String,
+
+ /** When this device last handed it to Electrum -- which reports success whatever the server said. */
+ val broadcastAt: Instant? = null,
+
+ /** When this device's wallet first saw the transaction, in the mempool or in a block. */
+ val seenAt: Instant? = null,
+
+ /** When its first confirmation was seen. */
+ val confirmedAt: Instant? = null,
+
+ /** The txid of a later spend of the same coins that confirmed instead, if one did. */
+ val replacedByTxid: String? = null,
+
+ val createdAt: Instant = Clock.System.now(),
+)
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseChatRepository.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseChatRepository.kt
index ed14be7d..a1ca6635 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseChatRepository.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseChatRepository.kt
@@ -1,8 +1,11 @@
package com.machankura.bennu.compose.database.repository
+import com.machankura.bennu.compose.managers.GuardianDerivation
+import com.machankura.bennu.compose.nostr.subgroup.WalletPolicyReading
import fr.acinq.bitcoin.Chain
import com.machankura.bennu.compose.managers.GroupLightningWalletManager
import com.machankura.bennu.compose.managers.GroupWalletManager
+import com.machankura.bennu.compose.managers.GuardianManager
import com.machankura.bennu.compose.managers.GroupWalletDerivation
import com.machankura.bennu.compose.nostr.wallet.GroupWallet
import com.machankura.bennu.compose.database.GENESIS_AT
@@ -20,10 +23,6 @@ import com.machankura.bennu.compose.managers.FrostSigningManager
import com.machankura.bennu.compose.managers.GroupKeyStateManager
import com.machankura.bennu.compose.managers.MarmotGroupCreation
import com.machankura.bennu.compose.managers.SubgroupManager
-import com.machankura.bennu.compose.nostr.GroupNostrProfile
-import com.machankura.bennu.compose.nostr.GroupPost
-import com.machankura.bennu.compose.nostr.GroupRelayList
-import com.machankura.bennu.compose.nostr.GroupRelaySet
import com.machankura.bennu.compose.database.model.ChatMessage
import com.machankura.bennu.compose.database.model.ChatRoom
import com.machankura.bennu.compose.database.model.GiftWrapPayload
@@ -40,8 +39,6 @@ import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray
import com.vitorpamplona.quartz.nip01Core.core.Kind
import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair
-import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent
-import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync
@@ -144,48 +141,21 @@ class DatabaseChatRepository(
null
}
- override suspend fun groupNostrProfile(chatRoomId: String): GroupNostrProfile? = try {
- GroupNostrProfile.newestAmong(
- signedEvents = database.groupSignedEventDao()
- .getByChatRoomIdAndKind(chatRoomId, MetadataEvent.KIND),
- chatRoomId = chatRoomId,
- )
+ override suspend fun walletPolicyOf(chatRoomId: String): WalletPolicyReading? = try {
+ SubgroupManager.walletPolicyOf(database, chatRoomId)
} catch (e: Throwable) {
- // Reading one parses content off the wire and checks a signature, and a
- // room that shows no profile is wrong and survivable where one that will
- // not open is neither -- the same trade the readings above make.
- logger.e("Error reading the nostr profile of $chatRoomId", e)
+ logger.e("Error reading the wallet policy of $chatRoomId", e)
null
}
- override suspend fun groupRelayLists(chatRoomId: String): List = try {
- // One query per set rather than one for the room: the four kinds are
- // indexed and a room's whole signed history is every artifact, chunk and
- // translation it has ever agreed.
- GroupRelaySet.entries.map { set ->
- GroupRelayList.newestAmong(
- signedEvents = database.groupSignedEventDao()
- .getByChatRoomIdAndKind(chatRoomId, set.kind),
- chatRoomId = chatRoomId,
- set = set,
- )
- }
+ // Null on a failure, which reads as keys this build cannot read: the picker
+ // then refuses a guarded subgroup rather than promising a grant it could not
+ // check.
+ override suspend fun guardiansOf(chatRoomId: String): List? = try {
+ SubgroupManager.guardiansOf(database, chatRoomId)
} catch (e: Throwable) {
- logger.e("Error reading the relay lists of $chatRoomId", e)
- // Four unsigned, empty sets: the screen draws "not set yet" rather than
- // failing to draw, which is the trade every reading above makes.
- GroupRelayList.allAmong(emptyList(), chatRoomId)
- }
-
- override suspend fun groupPosts(chatRoomId: String): List = try {
- GroupPost.newestFirstAmong(
- signedEvents = database.groupSignedEventDao()
- .getByChatRoomIdAndKind(chatRoomId, TextNoteEvent.KIND),
- chatRoomId = chatRoomId,
- )
- } catch (e: Throwable) {
- logger.e("Error reading the posts of $chatRoomId", e)
- emptyList()
+ logger.e("Error reading the guardians of $chatRoomId", e)
+ null
}
override suspend fun lightningParticipants(chatRoomId: String, chain: Chain): Set =
@@ -205,13 +175,50 @@ class DatabaseChatRepository(
null
}
- override suspend fun groupSignedEvent(chatRoomId: String, id: HexKey): GroupSignedEvent? = try {
- database.groupSignedEventDao().getById(id)?.takeIf { it.chatRoomId == chatRoomId }
+ override suspend fun groupWalletGuardedOpening(chatRoomId: String, chain: Chain): GroupWalletManager.GuardedOpening? = try {
+ GroupWalletManager.guardedAccountFor(database, chatRoomId, chain)
} catch (e: Throwable) {
- logger.e("Error reading the signed event $id of $chatRoomId", e)
+ logger.e("Error deriving the guarded wallet account of $chatRoomId", e)
null
}
+ override suspend fun guardedWallets(chatRoomId: String): List = try {
+ GuardianManager.guardedWalletsOf(database, chatRoomId)
+ } catch (e: Throwable) {
+ logger.e("Error reading the guarded wallets $chatRoomId was told about", e)
+ emptyList()
+ }
+
+ override suspend fun shareableGuardedWallets(chatRoomId: String, chain: Chain): List = try {
+ GuardianManager.shareableFrom(database, chatRoomId, chain)
+ } catch (e: Throwable) {
+ logger.e("Error reading what $chatRoomId can tell the groups above it", e)
+ emptyList()
+ }
+
+ override suspend fun forwardGuardedWallets(chatRoomId: String): Int = try {
+ GuardianManager.forwardAll(database, chatRoomId)
+ } catch (e: Throwable) {
+ // A room that opens without telling the groups above is wrong and
+ // survivable, and the button is still there.
+ logger.e("Error forwarding $chatRoomId's guarded wallets upward", e)
+ 0
+ }
+
+ override suspend fun shareGuardedWallet(shareable: GuardianManager.Shareable, userPublicKey: HexKey): Int = try {
+ GuardianManager.share(database, shareable.statement, shareable.rooms, userPublicKey, certificate = shareable.certificate)
+ } catch (e: Throwable) {
+ logger.e("Error telling the groups above about ${shareable.statement.pubKey}'s guarded wallet", e)
+ 0
+ }
+
+ override suspend fun recordGuardianSpends(chatRoomId: String, taken: List): Int = try {
+ GuardianManager.recordTaken(database, chatRoomId, taken)
+ } catch (e: Throwable) {
+ logger.e("Error recording guardian spends from $chatRoomId's wallet", e)
+ 0
+ }
+
override suspend fun canSign(chatRoomId: String): Boolean = try {
FrostSigningManager.canSign(database, chatRoomId)
} catch (e: Throwable) {
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseDkgRepository.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseDkgRepository.kt
index 16015f4b..77dbb6c4 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseDkgRepository.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseDkgRepository.kt
@@ -1,5 +1,6 @@
package com.machankura.bennu.compose.database.repository
+import com.machankura.bennu.compose.nostr.subgroup.SubgroupWalletPolicy
import com.machankura.bennu.compose.database.BennuDatabase
import com.machankura.bennu.compose.database.model.DkgParticipantMessage
import com.machankura.bennu.compose.database.model.DkgSession
@@ -64,7 +65,9 @@ class DatabaseDkgRepository(
threshold: Int,
parentChatRoomId: HexKey?,
participantPublicKeys: Set?,
- subject: String?
+ subject: String?,
+ walletPolicy: SubgroupWalletPolicy?,
+ guardianDelay: Long?
): DkgSession? = try {
ChillDkgRitualManager.proposeRitual(
database = database,
@@ -74,7 +77,9 @@ class DatabaseDkgRepository(
threshold = threshold,
parentChatRoomId = parentChatRoomId,
participantPublicKeys = participantPublicKeys,
- subject = subject
+ subject = subject,
+ walletPolicy = walletPolicy,
+ guardianDelay = guardianDelay
)
} catch (e: Throwable) {
logger.e("Error proposing DKG ritual for ${localChatRoom.chatRoom.id}", e)
@@ -214,6 +219,17 @@ class DatabaseDkgRepository(
null
}
+ override suspend fun abandon(localChatRoom: LocalChatRoom, sessionId: String): Boolean = try {
+ ChillDkgRitualManager.abandon(
+ database = database,
+ localChatRoom = localChatRoom,
+ sessionId = sessionId,
+ )
+ } catch (e: Throwable) {
+ logger.e("Error abandoning DKG ritual $sessionId", e)
+ false
+ }
+
override suspend fun approve(
localChatRoom: LocalChatRoom,
sessionId: String,
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseFrostSigningRepository.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseFrostSigningRepository.kt
index b90a59f8..a7badb0c 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseFrostSigningRepository.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseFrostSigningRepository.kt
@@ -149,6 +149,23 @@ class DatabaseFrostSigningRepository(
)
}
+ override suspend fun proposeGuardianSpend(
+ localChatRoom: LocalChatRoom,
+ userPublicKey: HexKey,
+ psbt: Psbt,
+ descendantChatRoomId: String,
+ chain: Chain,
+ ): FrostSigningSession? = proposing(localChatRoom) {
+ FrostSigningManager.proposeGuardianSpend(
+ database = database,
+ localChatRoom = localChatRoom,
+ userPublicKey = userPublicKey,
+ psbt = psbt,
+ descendantChatRoomId = descendantChatRoomId,
+ chain = chain,
+ )
+ }
+
override suspend fun checkedSpend(sessionId: String): GroupSpend.Checked? = try {
FrostSigningManager.checkedSpend(database, sessionId)
} catch (e: Throwable) {
@@ -177,6 +194,13 @@ class DatabaseFrostSigningRepository(
emptySet()
}
+ override suspend fun reservedFundingIndices(chatRoomId: String, account: GroupWalletDerivation.Account): Set = try {
+ FrostSigningManager.reservedFundingIndices(database, chatRoomId, account)
+ } catch (e: Throwable) {
+ logger.e("Error reading the funding addresses reserved in $chatRoomId", e)
+ emptySet()
+ }
+
override fun observeGroupTransactions(chatRoomId: String): Flow> =
database.groupTransactionDao().observeByChatRoomId(chatRoomId)
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseMantraRepository.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseMantraRepository.kt
deleted file mode 100644
index 28bd0e10..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseMantraRepository.kt
+++ /dev/null
@@ -1,94 +0,0 @@
-package com.machankura.bennu.compose.database.repository
-
-import co.touchlab.kermit.Logger
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import kotlinx.coroutines.CoroutineScope
-import com.machankura.bennu.compose.database.BennuDatabase
-import com.machankura.bennu.compose.database.model.MantraArtifact
-import com.machankura.bennu.compose.database.model.MantraArtifactVersion
-import com.machankura.bennu.compose.database.model.MantraChapter
-import com.machankura.bennu.compose.database.model.MantraChunk
-import com.machankura.bennu.compose.database.model.MantraDialect
-import com.machankura.bennu.compose.database.model.MantraTranslationArtifactVersion
-import com.machankura.bennu.compose.database.model.MantraTranslationChapter
-import com.machankura.bennu.compose.database.model.MantraTranslationChunk
-import com.machankura.bennu.compose.database.model.MarmotInnerEvent
-import com.machankura.bennu.compose.database.model.intermdiate.LocalChatRoom
-import com.machankura.bennu.compose.repository.MantraRepository
-
-class DatabaseMantraRepository(
- val database: BennuDatabase,
- val scope: CoroutineScope
-): MantraRepository {
-
- private val logger = Logger.withTag(TAG)
-
- override suspend fun getArtifacts(chatRoomId: String): List =
- database.mantraArtifactDao().getArtifactsByChatRoomId(chatRoomId)
-
- override suspend fun getArtifact(id: String): MantraArtifact? =
- database.mantraArtifactDao().getArtifactById(id)
-
- override suspend fun getArtifactVersions(artifactId: String): List =
- database.mantraArtifactVersionDao().getArtifactVersionsByArtifactId(artifactId)
-
- override suspend fun getArtifactVersion(id: String): MantraArtifactVersion? =
- database.mantraArtifactVersionDao().getArtifactVersionById(id)
-
- override suspend fun getChaptersForArtifact(artifactId: String): List =
- database.mantraChapterDao().getChaptersByArtifactId(artifactId)
-
- override suspend fun getChaptersForArtifactVersion(artifactVersionId: String): List =
- database.mantraChapterDao().getChaptersByArtifactVersionId(artifactVersionId)
-
- override suspend fun getChapter(id: String): MantraChapter? =
- database.mantraChapterDao().getChapterById(id)
-
- override suspend fun getChunksForChapter(chapterId: String): List =
- database.mantraChunkDao().getChunksByChapterId(chapterId)
-
- override suspend fun getChunk(id: String): MantraChunk? =
- database.mantraChunkDao().getChunkById(id)
-
- override suspend fun getTranslationsForArtifact(artifactId: String): List =
- database.mantraTranslationArtifactVersionDao().getTranslationsByArtifactId(artifactId)
-
- override suspend fun getTranslation(id: String): MantraTranslationArtifactVersion? =
- database.mantraTranslationArtifactVersionDao().getTranslationById(id)
-
- override suspend fun getTranslationsForArtifactVersion(artifactVersionId: String): List =
- database.mantraTranslationArtifactVersionDao().getTranslationsByArtifactVersionId(artifactVersionId)
-
- override suspend fun getTranslationChapter(id: String): MantraTranslationChapter? =
- database.mantraTranslationChapterDao().getTranslationChapterById(id)
-
- override suspend fun getTranslationChapters(translationArtifactVersionId: String): List =
- database.mantraTranslationChapterDao().getTranslationChaptersByTranslationArtifactVersionId(translationArtifactVersionId)
-
- override suspend fun getTranslationChunks(translationChapterId: String): List =
- database.mantraTranslationChunkDao().getTranslationChunksByTranslationChapterId(translationChapterId)
-
- override suspend fun getDialects(chatRoomId: String): List =
- database.mantraDialectDao().getDialectsByChatRoomId(chatRoomId)
-
- override suspend fun getDialect(id: String): MantraDialect? =
- database.mantraDialectDao().getDialectById(id)
-
- override suspend fun addArtifactVersion(
- localChatRoom: LocalChatRoom,
- artifactId: HexKey,
- versionLabel: String,
- userPublicKey: HexKey,
- ): MantraArtifactVersion? {
- return database.mantraDao().addArtifactVersion(
- localChatRoom = localChatRoom,
- artifactId = artifactId,
- versionLabel = versionLabel,
- userPublicKey = userPublicKey
- )
- }
-
- companion object {
- private const val TAG = "DatabaseMantraRepository"
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseMemberWalletRepository.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseMemberWalletRepository.kt
new file mode 100644
index 00000000..cd2f7701
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/database/repository/DatabaseMemberWalletRepository.kt
@@ -0,0 +1,153 @@
+package com.machankura.bennu.compose.database.repository
+
+import com.machankura.bennu.compose.nostr.wallet.MemberWalletPolicyEvent
+import co.touchlab.kermit.Logger
+import com.machankura.bennu.compose.database.BennuDatabase
+import com.machankura.bennu.compose.database.model.FrostSigningSession
+import com.machankura.bennu.compose.database.model.MemberWallet
+import com.machankura.bennu.compose.managers.GuardianManager
+import com.vitorpamplona.quartz.nip01Core.core.Event
+import com.machankura.bennu.compose.database.model.MemberWalletSpend
+import fr.acinq.bitcoin.Transaction
+import fr.acinq.bitcoin.psbt.Psbt
+import kotlinx.coroutines.flow.Flow
+import kotlin.time.Instant
+import com.machankura.bennu.compose.database.model.intermdiate.LocalChatRoom
+import com.machankura.bennu.compose.identity.Identity
+import com.machankura.bennu.compose.managers.MemberWalletManager
+import com.machankura.bennu.compose.repository.MemberWalletRepository
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import fr.acinq.bitcoin.Chain
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+
+class DatabaseMemberWalletRepository(
+ private val database: BennuDatabase,
+ private val activeIdentity: StateFlow = MutableStateFlow(null),
+) : MemberWalletRepository {
+ private val logger = Logger.withTag(TAG)
+
+ override suspend fun groupsOf(ownerPublicKey: HexKey): List = try {
+ MemberWalletManager.groupsOf(database, ownerPublicKey)
+ } catch (e: Throwable) {
+ logger.e("Error reading the groups that could guard a wallet", e)
+ emptyList()
+ }
+
+ override suspend fun refusal(chatRoomId: String, chain: Chain): MemberWalletManager.Refusal? = try {
+ MemberWalletManager.refusal(database, chatRoomId, canSign = activeIdentity.value?.canSign == true, chain = chain)
+ } catch (e: Throwable) {
+ logger.e("Error reading whether $chatRoomId can guard a wallet", e)
+ MemberWalletManager.Refusal.KEY_UNKNOWN
+ }
+
+ override suspend fun reachOf(chatRoomId: String): Int? = try {
+ MemberWalletManager.reachOf(database, chatRoomId)
+ } catch (e: Throwable) {
+ logger.e("Error reading how far $chatRoomId's guard reaches", e)
+ null
+ }
+
+ override suspend fun delaysOf(chatRoomId: String): List? = try {
+ MemberWalletManager.delaysOf(database, chatRoomId)
+ } catch (e: Throwable) {
+ logger.e("Error reading how far $chatRoomId's guard reaches", e)
+ null
+ }
+
+ override suspend fun askForGroupKey(chatRoomId: String): Boolean {
+ val identity = activeIdentity.value ?: return false
+ return MemberWalletManager.askForGroupKey(database, chatRoomId, identity.nostrPublicKey)
+ }
+
+ override suspend fun request(chatRoomId: String, chain: Chain, label: String?): MemberWallet {
+ val key = activeIdentity.value?.nostrPrivateKey ?: throw IllegalStateException("This profile cannot sign")
+ return MemberWalletManager.request(database, chatRoomId, key, chain, label)
+ }
+
+ override suspend fun walletsOf(ownerPublicKey: HexKey): List = try {
+ MemberWalletManager.walletsOf(database, ownerPublicKey)
+ } catch (e: Throwable) {
+ // A profile that lists no wallets is wrong and survivable; one that will
+ // not open because reading them threw is neither.
+ logger.e("Error reading $ownerPublicKey's guarded wallets", e)
+ emptyList()
+ }
+
+ override suspend fun walletOf(ownerPublicKey: HexKey, walletId: String): MemberWalletManager.MemberWalletRow? = try {
+ MemberWalletManager.walletOf(database, ownerPublicKey, walletId)
+ } catch (e: Throwable) {
+ logger.e("Error reading guarded wallet $walletId", e)
+ null
+ }
+
+ override suspend fun askAgain(walletId: String): String {
+ val wallet = database.memberWalletDao().getById(walletId) ?: throw IllegalStateException("No key for $walletId here")
+ check(wallet.ownerPublicKey == activeIdentity.value?.nostrPublicKey) { "Not this profile's wallet" }
+ val key = activeIdentity.value?.nostrPrivateKey ?: throw IllegalStateException("This profile cannot sign")
+ return MemberWalletManager.askAgain(database, wallet, key).walletId
+ }
+
+ override suspend fun discard(walletId: String) {
+ val wallet = database.memberWalletDao().getById(walletId) ?: return
+ check(wallet.ownerPublicKey == activeIdentity.value?.nostrPublicKey) { "Not this profile's wallet" }
+ MemberWalletManager.discard(database, walletId)
+ }
+
+ override suspend fun exportKey(walletId: String): Pair? {
+ val owner = activeIdentity.value?.nostrPublicKey ?: return null
+ return MemberWalletManager.exportKey(database, owner, walletId)
+ }
+
+ override suspend fun roomName(chatRoomId: String): String? =
+ database.chatRoomDao().findChatRoomById(chatRoomId)?.chatRoom?.subject?.takeIf { it.isNotBlank() }
+
+ override suspend fun signSpend(walletId: String, psbt: Psbt): Transaction {
+ val owner = activeIdentity.value?.nostrPublicKey ?: throw IllegalStateException("No profile is active")
+ return MemberWalletManager.signSpend(database, owner, walletId, psbt)
+ }
+
+ override suspend fun recordChain(txid: String, confirmations: Int?, broadcastAt: Instant?) =
+ MemberWalletManager.recordChain(database, txid, confirmations, broadcastAt)
+
+ override fun observeSpends(walletId: String): Flow> = database.memberWalletDao().observeSpends(walletId)
+
+ override suspend fun couldGuard(chatRoomId: String): Boolean = try {
+ database.chatRoomDao().findChatRoomById(chatRoomId)?.let { MemberWalletManager.couldGuard(database, it) } == true
+ } catch (e: Throwable) {
+ logger.e("Error reading whether $chatRoomId could guard a wallet", e)
+ false
+ }
+
+ override suspend fun policyOf(chatRoomId: String): MemberWalletPolicyEvent.Policy? = try {
+ MemberWalletManager.policyFor(database, chatRoomId)
+ } catch (e: Throwable) {
+ logger.e("Error reading $chatRoomId's member-wallet policy", e)
+ null
+ }
+
+ override suspend fun memberWalletsOf(chatRoomId: String): List = try {
+ MemberWalletManager.memberWalletsOf(database, chatRoomId)
+ } catch (e: Throwable) {
+ logger.e("Error reading the member wallets $chatRoomId guards", e)
+ emptyList()
+ }
+
+ override suspend fun putToGroup(chatRoomId: String, request: Event): FrostSigningSession {
+ val identity = activeIdentity.value ?: throw IllegalStateException("No profile is active")
+ val room = database.chatRoomDao().findChatRoomById(chatRoomId) ?: throw IllegalStateException("No such group here")
+ return MemberWalletManager.putToGroup(database, room, identity.nostrPublicKey, request)
+ }
+
+ override suspend fun guardedByGroupsHere(ownerPublicKey: HexKey): List = try {
+ val viewer = activeIdentity.value?.nostrPublicKey ?: return emptyList()
+ MemberWalletManager.guardedByGroupsHere(database, viewer, ownerPublicKey)
+ } catch (e: Throwable) {
+ logger.e("Error reading the wallets of $ownerPublicKey this profile's groups guard", e)
+ emptyList()
+ }
+
+ companion object {
+ private const val TAG = "DatabaseMemberWalletRepository"
+ }
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/ChillDkgRitualManager.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/ChillDkgRitualManager.kt
index 28cd7985..3c79f61d 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/ChillDkgRitualManager.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/ChillDkgRitualManager.kt
@@ -1,5 +1,9 @@
package com.machankura.bennu.compose.managers
+import com.machankura.bennu.compose.nostr.subgroup.tags.GuardianDelayTag
+import com.machankura.bennu.compose.database.model.subgroupWalletPolicy
+import com.machankura.bennu.compose.nostr.subgroup.tags.WalletPolicyTag
+import com.machankura.bennu.compose.nostr.subgroup.SubgroupWalletPolicy
import com.machankura.bennu.compose.database.BennuDatabase
import com.machankura.bennu.compose.database.model.ChatMessage
import com.machankura.bennu.compose.database.model.DkgParticipantMessage
@@ -106,6 +110,9 @@ object ChillDkgRitualManager {
*/
const val MINIMUM_PARTICIPANTS = 2
+ /** Why a ceremony a participant walked away from ended, as every device records it. */
+ private const val ABANDONED = "Abandoned by a participant"
+
/**
* This device's long-term ChillDKG host secret key.
*
@@ -138,6 +145,14 @@ object ChillDkgRitualManager {
fun canRunRitual(localChatRoom: LocalChatRoom): Boolean =
memberPublicKeys(localChatRoom).size >= MINIMUM_PARTICIPANTS
+ /**
+ * Whether [localChatRoom] is a Marmot room, and so can host a subgroup's
+ * ceremony but never one of its own. The same reading [broadcast] makes to
+ * pick a transport.
+ */
+ fun isMarmotRoom(localChatRoom: LocalChatRoom): Boolean =
+ localChatRoom.chatRoom.mlsGroupState != null
+
/**
* Everyone a ceremony is being run with — which is not the same question as
* who is in the room it runs in.
@@ -171,6 +186,17 @@ object ChillDkgRitualManager {
* and is carried to the other admins on the proposal because there is no
* longer a room of its own for them to read it off.
*
+ * [walletPolicy] is what the subgroup's wallet is to be, as the coordinator
+ * chose it on the picker -- carried on the proposal so every admin is told
+ * before joining, and on the session so whoever proposes the birth
+ * certificate proposes it under the same one. Only a subgroup's ceremony has
+ * one. See `docs/subgroup-wallet-policy.md`.
+ *
+ * [guardianDelay] is the delay, in blocks, the coordinator chose for the
+ * parent's own leaf in a guarded subgroup's wallet, carried the same way and
+ * for the same reasons. Only a guarded ceremony has one, and it is in
+ * `GuardianDerivation.DELAY_RANGE`. See `docs/guardian-delay.md`.
+ *
* Throws when the group or the threshold cannot support one; the UI checks
* both before offering the button, so reaching either is a bug rather than a
* user error.
@@ -183,8 +209,25 @@ object ChillDkgRitualManager {
threshold: Int,
parentChatRoomId: HexKey? = null,
participantPublicKeys: Set? = null,
- subject: String? = null
+ subject: String? = null,
+ walletPolicy: SubgroupWalletPolicy? = null,
+ guardianDelay: Long? = null
): DkgSession {
+ // A policy is for a subgroup's wallet, and a ceremony with no parent makes
+ // no subgroup. `acceptProposal` drops the same thing on the way in.
+ // Before the running check, which would otherwise hand back a ceremony
+ // for a question this one should never have asked.
+ require(walletPolicy == null || parentChatRoomId != null) {
+ "Only a subgroup's ceremony carries a wallet policy"
+ }
+ // A delay is a guarded wallet's, and within what a leaf can carry.
+ require(guardianDelay == null || walletPolicy == SubgroupWalletPolicy.GUARDED) {
+ "Only a guarded subgroup's ceremony carries a guardian delay"
+ }
+ require(guardianDelay == null || guardianDelay in GuardianDerivation.DELAY_RANGE) {
+ "A guardian's delay is ${GuardianDerivation.MIN_DELAY} to ${GuardianDerivation.MAX_DELAY} blocks, not $guardianDelay"
+ }
+
// Built the way a receiver rebuilds it from the proposal — the p-tags
// `broadcast` writes, plus this device — so both sides count the same `n`
// even if the room's own rows have drifted.
@@ -245,6 +288,15 @@ object ChillDkgRitualManager {
"${(members - room).joinToString { it.take(8) }}, who are not in it"
}
+ // A Marmot room's id is derived from the key it already has, so a ceremony
+ // of its own would make a key the room could never answer to. It hosts its
+ // subgroups' ceremonies and nothing else. The screens stopped offering one
+ // here, and this is what makes that a rule rather than a screen not drawing
+ // a button -- see docs/ceremony-creation.md.
+ require(parentChatRoomId != null || !isMarmotRoom(localChatRoom)) {
+ "${localChatRoom.chatRoom.id} is a Marmot room; it can only host a subgroup's ceremony"
+ }
+
require(members.size >= MINIMUM_PARTICIPANTS) {
"A shared key needs at least $MINIMUM_PARTICIPANTS members, this ceremony has ${members.size}"
}
@@ -273,6 +325,8 @@ object ChillDkgRitualManager {
// subgroup's ceremony runs in the parent's room over a subset of it.
participantPublicKeys = DkgSession.formatParticipants(members),
subject = ceremonySubject,
+ walletPolicy = walletPolicy?.tagValue,
+ guardianDelay = guardianDelay,
hostPublicKey = deriveHostPublicKey(nostrPrivateKey).value.toHex(),
// Fresh per session. Persisted because participantStep1/2 are pure in
// it, which is what makes the whole ritual restart-safe.
@@ -375,7 +429,7 @@ object ChillDkgRitualManager {
return
}
- if (!record(database, session, innerEvent)) return
+ if (!record(database, localChatRoom, session, innerEvent)) return
advance(
database = database,
@@ -399,6 +453,20 @@ object ChillDkgRitualManager {
): DkgSession? {
database.dkgSessionDao().getSessionById(sessionId)?.let { return it }
+ // The receiving half of `proposeRitual`'s refusal. A build from before it
+ // can still put a group's own ceremony on the wire in a Marmot room, and
+ // recording it would show every member a ceremony whose key the room can
+ // never use -- which is how a second ceremony ended up beside a subgroup's.
+ if (isMarmotRoom(localChatRoom) &&
+ DkgRitualEvents.parseParentChatRoomId(innerEvent.tags) == null
+ ) {
+ logger.w(
+ "DKG proposal $sessionId names no parent in Marmot room " +
+ "${localChatRoom.chatRoom.id}; dropping"
+ )
+ return null
+ }
+
// The participant set is the proposal's own p-tags plus its sender, NOT
// this device's view of the room. `n` is hashed into the session identity,
// so two devices that disagree on it cannot complete a ritual together —
@@ -437,6 +505,37 @@ object ChillDkgRitualManager {
return null
}
+ // A policy is only for a subgroup's wallet, and one that does not read is
+ // not one to join on the assumption it says nothing: an admin would be
+ // shown no policy and then asked to sign a key state under one.
+ val walletPolicy = when (val tag = DkgRitualEvents.parseWalletPolicy(innerEvent.tags)) {
+ WalletPolicyTag.Result.Absent -> null
+ WalletPolicyTag.Result.Unreadable -> {
+ logger.w("DKG proposal $sessionId carries a wallet policy that does not read; dropping")
+ return null
+ }
+ is WalletPolicyTag.Result.Present -> tag.policy
+ }
+ if (walletPolicy != null && DkgRitualEvents.parseParentChatRoomId(innerEvent.tags) == null) {
+ logger.w("DKG proposal $sessionId carries a wallet policy and names no parent; dropping")
+ return null
+ }
+
+ // The same for the delay: a guarded subgroup's only, and in range. An
+ // admin shown no delay must not be asked to sign a certificate under one.
+ val guardianDelay = when (val tag = DkgRitualEvents.parseGuardianDelay(innerEvent.tags)) {
+ GuardianDelayTag.Result.Absent -> null
+ GuardianDelayTag.Result.Unreadable -> {
+ logger.w("DKG proposal $sessionId carries a guardian delay that does not read; dropping")
+ return null
+ }
+ is GuardianDelayTag.Result.Present -> tag.delay
+ }
+ if (guardianDelay != null && walletPolicy != SubgroupWalletPolicy.GUARDED) {
+ logger.w("DKG proposal $sessionId carries a guardian delay for a subgroup that is not guarded; dropping")
+ return null
+ }
+
val session = DkgSession(
id = sessionId,
chatRoomId = localChatRoom.chatRoom.id,
@@ -461,6 +560,10 @@ object ChillDkgRitualManager {
// on it, and the certificate the parent's quorum signs is over this
// name, so an admin who dislikes it declines that.
subject = DkgRitualEvents.parseSubject(innerEvent.tags),
+ // What the subgroup's wallet is to be, as claimed -- shown at the join
+ // gate, so joining is agreeing to it. See the checks above.
+ walletPolicy = walletPolicy?.tagValue,
+ guardianDelay = guardianDelay,
hostPublicKey = deriveHostPublicKey(nostrPrivateKey).value.toHex(),
round1Random = RandomInstance.bytes(32).toHex(),
round2AuxRandom = RandomInstance.bytes(32).toHex(),
@@ -550,7 +653,7 @@ object ChillDkgRitualManager {
logger.i("Replaying ${stored.size} stored message(s) for ritual ${session.id}")
stored.forEach { payload ->
- if (!record(database, session, payload)) return
+ if (!record(database, localChatRoom, session, payload)) return
}
}
@@ -564,6 +667,7 @@ object ChillDkgRitualManager {
*/
private suspend fun record(
database: BennuDatabase,
+ localChatRoom: LocalChatRoom,
session: DkgSession,
innerEvent: Event
): Boolean {
@@ -634,6 +738,18 @@ object ChillDkgRitualManager {
}
DkgRitualEvents.FAILURE -> {
+ // Only somebody in the ceremony can end it. In a parent's room every
+ // member can read a subgroup's proposal, and so could name its
+ // session -- but a member who was never in it walking away is not
+ // the ceremony failing.
+ if (innerEvent.pubKey !in participantsOf(session, localChatRoom)) {
+ logger.w(
+ "Ritual ${session.id}: FAILURE from ${innerEvent.pubKey.take(8)}, " +
+ "who is not in it; ignoring"
+ )
+ return true
+ }
+
fail(
database = database,
session = session,
@@ -1088,6 +1204,49 @@ object ChillDkgRitualManager {
return null
}
+ /**
+ * Ends a ceremony this device is in, for everyone in it.
+ *
+ * ChillDKG has no "no" short of this: a participant who never approves stalls
+ * the ceremony for good, and the others are left waiting on a key that will
+ * not come. Saying so lets them stop. It is the same FAILURE message a fault
+ * sends, and every device files it the same way -- no key is created, and the
+ * group can start again.
+ *
+ * Returns whether it was ended. Refuses, rather than throws, a ceremony this
+ * device is not in or one that is already over: a stale screen may ask.
+ */
+ suspend fun abandon(
+ database: BennuDatabase,
+ localChatRoom: LocalChatRoom,
+ sessionId: String,
+ ): Boolean {
+ val session = database.dkgSessionDao().getSessionById(sessionId) ?: return false
+
+ if (session.stage == DkgRitualStage.COMPLETE || session.stage == DkgRitualStage.FAILED) {
+ logger.i("Ritual $sessionId is already over; nothing to abandon")
+ return false
+ }
+
+ if (session.userPublicKey !in participantsOf(session, localChatRoom)) {
+ logger.w("Ritual $sessionId does not include this device; not abandoning it")
+ return false
+ }
+
+ logger.i("Abandoning ritual $sessionId")
+
+ fail(database, session, ABANDONED)
+ broadcast(
+ database = database,
+ localChatRoom = localChatRoom,
+ session = session,
+ kind = DkgRitualEvents.FAILURE,
+ content = ABANDONED
+ )
+
+ return true
+ }
+
/**
* Records that this device's owner agreed to [step], then lets the ritual run as
* far as the next thing it is waiting on.
@@ -1374,7 +1533,10 @@ object ChillDkgRitualManager {
sessionId = session.id,
threshold = if (includeThreshold) session.threshold else null,
parentChatRoomId = if (includeParent) session.parentChatRoomId else null,
- subject = subject
+ subject = subject,
+ // With the parent, and for the same reason: only on the proposal.
+ walletPolicy = if (includeParent) session.subgroupWalletPolicy else null,
+ guardianDelay = if (includeParent) session.guardianDelay else null
)
val createdAt = Clock.System.now().epochSeconds
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/ChronicleManager.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/ChronicleManager.kt
index 3fe5838d..39cf6bfb 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/ChronicleManager.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/ChronicleManager.kt
@@ -18,7 +18,7 @@ import kotlin.time.Instant
import com.machankura.bennu.compose.nostr.chronicle.ChronicleEvent
import com.machankura.bennu.compose.nostr.chronicle.ChronicleRequestEvent
import com.machankura.bennu.compose.nostr.frost.GroupKeyStateEvent
-import com.machankura.bennu.compose.nostr.nip30303.TranslationChunkEvent
+import com.machankura.bennu.compose.nostr.chronicle.ChronicleKinds
/**
* Building the group's signed record into pages a member who lacks it can apply.
@@ -28,49 +28,39 @@ import com.machankura.bennu.compose.nostr.nip30303.TranslationChunkEvent
* locally by each device that took part and never goes on the wire. This is how
* it gets to them.
*
- * ### The events are the chronicle, and the rows are the fallback
+ * ### Carrying nothing, for now
+ *
+ * What a chronicle may carry is [ChronicleEvent.KINDS], and that is empty since
+ * the document kinds it was built for were removed (docs/ceremony-creation.md,
+ * Phase 7). Every entry point here takes the kinds as a parameter defaulting to
+ * that list, and with it empty the chronicle is quiet: [requestIfEmpty] asks for
+ * nothing, [sendTo] sends nothing, and a page from an older build applies
+ * nothing. The machinery is kept, and tested with a list of the tests' own, for
+ * the next kind that should join.
+ *
+ * ### The events are the chronicle
*
* `GroupSignedEvent` holds what the group signed, as it signed it, so
- * [signedEventsOf] reads it first: no rebuild, no round-trip risk, and nothing
- * that depends on a row having kept every field of the event it came from. The
- * artifact's version label is the standing example -- it is not on the artifact
- * row at all, and [rebuiltEventsOf] has to go and find it on the initial version
- * or leave the artifact out.
+ * [signedEventsOf] reads it: no rebuild, no round-trip risk, and nothing that
+ * depends on a row having kept every field of the event it came from.
*
- * A room whose work predates that table has no events on file, so the rebuild
- * stays as the fallback for exactly what the table is missing, keyed by id.
- * Every payload it produces stands or falls on being byte-identical to what was
- * signed; `ChronicleRoundTripTest` is what says it is, per kind, against a real
- * quorum, and it found two faults in the artifact's rebuild the first time it
- * ran -- both of which would have shipped payloads that every receiver drops as
- * forgeries without a word. Both it and everything that exists only to hold it
- * up are marked `@Deprecated`; the fallback can go once no install still holds
- * pre-v13 work, and docs/member-chronicle.md's "Retiring the rebuild" is the list
- * of what goes with it.
- *
- * **The allowlist does real work on the way out now.** The rebuild could only
- * ever produce document kinds; the table holds everything the group has ever
- * signed, `GroupKeyStateEvent` included. So [signedEventsOf] filters on
- * [ChronicleEvent.isChroniclable] before anything else, which is the same rule
- * [applyPage] applies on the way in. Without it `ChronicleEvent.build` would
- * refuse the page and take the whole chronicle down with it.
- *
- * A room's own key state no longer sits in that table under the room -- it is
- * signed in the NIP-17 room the ceremony ran in, before the room exists, and
- * filed under that room; see `GroupKeyStateManager`. That makes the filter a
- * narrower guard than it was and not a redundant one: what it is really stopping
+ * **The allowlist does real work on the way out.** The table holds everything
+ * the group has ever signed, `GroupKeyStateEvent` included. So [signedEventsOf]
+ * filters on the kinds before anything else, which is the same rule [applyPage]
+ * applies on the way in. Without it `ChronicleEvent.build` would refuse the page
+ * and take the whole chronicle down with it. What the filter is really stopping
* is a member replaying any group-signed statement about the record as though it
- * were work, and [applyPage] refuses the same kinds coming the other way. The
- * two are a pair and neither is safe to drop on the strength of the other.
+ * were work, and [applyPage] refuses the same kinds coming the other way. The two
+ * are a pair and neither is safe to drop on the strength of the other.
*
* ### Nothing unverifiable leaves
*
- * Every rebuilt event is checked with [GroupKeyStateEvent.isSignedByRoom] before
- * it is packed, against the same room id the recipient will check it with. That
- * is not politeness towards the receiver, who checks anyway. It is what keeps an
- * chronicle honest about its own size: a row that came from a member's rumor
- * cannot be chronicled, and dropping it here rather than letting the recipient
- * drop it means the page count says what will actually arrive.
+ * Every event is checked with [GroupKeyStateEvent.isSignedByRoom] before it is
+ * packed, against the same room id the recipient will check it with. That is not
+ * politeness towards the receiver, who checks anyway. It is what keeps a
+ * chronicle honest about its own size: dropping a payload here rather than
+ * letting the recipient drop it means the page count says what will actually
+ * arrive.
*/
object ChronicleManager {
private const val TAG = "ChronicleManager"
@@ -93,16 +83,13 @@ object ChronicleManager {
recipient: HexKey,
chronicleId: String = RandomInstance.bytes(32).toHex(),
createdAt: Long = TimeUtils.now(),
+ kinds: ChronicleKinds = ChronicleEvent.KINDS,
): List> {
- val held = signedEventsOf(database, chatRoomId)
+ val held = signedEventsOf(database, chatRoomId, kinds)
- // One rule over both sources: nothing leaves that the recipient could
- // not check for themselves. What a drop means depends on where it came
- // from, and the two are worth telling apart when reading this log --
- // from the rebuild it is the ordinary case of a member's own rumor
- // sitting in the same table as the group's work, and from the record it
- // is a row that has drifted from the event it recorded, which nothing
- // in this app does on purpose.
+ // Nothing leaves that the recipient could not check for themselves. A
+ // drop here is a row that has drifted from the event it recorded, which
+ // nothing in this app does on purpose.
val verified = held.filter { GroupKeyStateEvent.isSignedByRoom(it, chatRoomId) }
if (verified.size != held.size) {
logger.d(
@@ -111,7 +98,7 @@ object ChronicleManager {
)
}
- val pages = paginate(ChronicleEvent.inApplyOrder(verified))
+ val pages = paginate(kinds.inApplyOrder(verified))
if (pages.isEmpty()) {
logger.i("Nothing signed to chronicle for room $chatRoomId")
return emptyList()
@@ -130,6 +117,7 @@ object ChronicleManager {
count = pages.size,
recipient = recipient,
createdAt = createdAt,
+ kinds = kinds,
)
}
}
@@ -139,9 +127,12 @@ object ChronicleManager {
/**
* Ask the group for its signed history, if this device holds none of it.
*
- * Called on entering a room. The condition is deliberately crude -- no
- * dialects and no artifacts -- because the three cases it has to catch look
- * identical from inside the database and should not be told apart:
+ * Called on entering a room. Does nothing while [kinds] is empty, which it
+ * is in this app at the moment -- see the class comment.
+ *
+ * The condition is deliberately crude -- nothing of a chroniclable kind on
+ * file -- because the three cases it has to catch look identical from inside
+ * the database and should not be told apart:
*
* - a member added after the work was done, whose invite may be recent;
* - a reinstall, whose invite is long past;
@@ -162,12 +153,17 @@ object ChronicleManager {
database: BennuDatabase,
chatRoomId: String,
userPublicKey: HexKey,
+ kinds: ChronicleKinds = ChronicleEvent.KINDS,
): Boolean {
+ // Quiet while a chronicle may carry nothing: there is no answer worth
+ // asking for, and asking would put a request on the wire and a line in
+ // the transcript on every room the member opens.
+ if (kinds.isEmpty()) return false
+
val chatRoom = database.chatRoomDao().findChatRoomById(chatRoomId)?.chatRoom ?: return false
if (chatRoom.chronicleRequestedAt != null) return false
- val holdsWork = database.mantraDialectDao().getDialectsByChatRoomId(chatRoomId).isNotEmpty() ||
- database.mantraArtifactDao().getArtifactsByChatRoomId(chatRoomId).isNotEmpty()
+ val holdsWork = signedEventsOf(database, chatRoomId, kinds).isNotEmpty()
if (holdsWork) return false
@@ -217,10 +213,11 @@ object ChronicleManager {
chatRoomId: String,
userPublicKey: HexKey,
recipient: HexKey,
+ kinds: ChronicleKinds = ChronicleEvent.KINDS,
): Int {
if (recipient.equals(userPublicKey, ignoreCase = true)) return 0
- val pages = assemble(database, chatRoomId, recipient)
+ val pages = assemble(database, chatRoomId, recipient, kinds = kinds)
if (pages.isEmpty()) {
logger.i("Nothing signed here to send ${recipient.take(8)} for $chatRoomId")
return 0
@@ -373,6 +370,7 @@ object ChronicleManager {
chatRoomId: String,
userPublicKey: HexKey,
page: Event,
+ kinds: ChronicleKinds = ChronicleEvent.KINDS,
): Outcome {
val recipient = ChronicleEvent(
id = page.id,
@@ -388,7 +386,7 @@ object ChronicleManager {
return Outcome()
}
- return sweep(database, chatRoomId, userPublicKey)
+ return sweep(database, chatRoomId, userPublicKey, kinds)
}
/**
@@ -421,6 +419,7 @@ object ChronicleManager {
database: BennuDatabase,
chatRoomId: String,
userPublicKey: HexKey,
+ kinds: ChronicleKinds = ChronicleEvent.KINDS,
): Outcome {
val pages = database.marmotInnerEventDao()
.getByChatRoomAndKinds(chatRoomId, listOf(ChronicleEvent.KIND))
@@ -433,7 +432,7 @@ object ChronicleManager {
while (true) {
pass = Outcome()
- pages.forEach { pass += applyPage(database, chatRoomId, it) }
+ pages.forEach { pass += applyPage(database, chatRoomId, it, kinds) }
if (pass.failed == 0 || pass.failed >= previousFailures) {
if (pass.failed > 0) {
@@ -513,6 +512,7 @@ object ChronicleManager {
database: BennuDatabase,
chatRoomId: String,
stored: MarmotInnerEvent,
+ kinds: ChronicleKinds,
): Outcome {
val payloads = ChronicleEvent.decodePage(stored.content)
if (payloads == null) {
@@ -530,13 +530,13 @@ object ChronicleManager {
var outcome = Outcome()
- ChronicleEvent.inApplyOrder(payloads).forEach { payload ->
+ kinds.inApplyOrder(payloads).forEach { payload ->
// The allowlist first, and it is not a formality. Verification admits
// an event to the apply path on the strength of the group's
// signature, which makes every kind the group has ever signed
// replayable by any member at any time -- a GroupKeyStateEvent from
// an earlier epoch passes the signature check perfectly.
- if (!ChronicleEvent.isChroniclable(payload.kind)) {
+ if (!kinds.isChroniclable(payload.kind)) {
logger.w(
"Chronicle page ${stored.id.take(8)} carries kind ${payload.kind}, " +
"which a chronicle may not deliver; dropping ${payload.id.take(8)}"
@@ -605,224 +605,31 @@ object ChronicleManager {
}
/**
- * Every chroniclable event this device holds for the room: the ones the group
- * signed here or sent here, plus anything only the rows still remember.
+ * Every chroniclable event this device holds for the room, as the group
+ * signed it.
*
- * The record comes first because it is the event rather than a reconstruction
- * of one, and the rebuild fills the gap behind it -- keyed by id, so an event
- * held both ways travels once. A room that upgraded mid-life has both, and
- * neither half is complete on its own.
- *
- * The two disagree only in one direction worth naming. An id the rebuild
- * produces that the record does not hold is either work from before the
- * table existed, which is the point of the fallback, or a rebuild that has
- * gone wrong -- and a wrong rebuild hashes to an id whose signature does not
- * verify, so the filter in [assemble] drops it either way rather than
- * shipping a payload every receiver reads as a forgery.
- *
- * Order does not matter at this point; [ChronicleEvent.inApplyOrder] settles it
- * afterwards. It is stable within a rank, so a room holding some of its work
- * both ways can order two chapters differently from a member holding one way
- * only. That costs nothing: pages are idempotent and applied payload by
- * payload, and two members already differed by the order their rows were
- * written in.
+ * Order does not matter at this point; [ChronicleKinds.inApplyOrder] settles
+ * it afterwards.
*/
private suspend fun signedEventsOf(
database: BennuDatabase,
chatRoomId: String,
- ): List {
- val recorded = database.groupSignedEventDao()
- .getByChatRoomId(chatRoomId)
- // The allowlist, applied to the source that can actually trip it --
- // see the class comment. A key state on file is the room's own, and
- // sending it would be handing every member a validly signed
- // statement about what the room signs with, replayable forever.
- .filter { ChronicleEvent.isChroniclable(it.kind) }
- .map { it.toEvent() }
-
- val onFile = recorded.mapTo(mutableSetOf()) { it.id }
- val rebuilt = rebuiltEventsOf(database, chatRoomId).filterNot { it.id in onFile }
-
- if (rebuilt.isNotEmpty()) {
- logger.d(
- "Chronicling $chatRoomId: ${recorded.size} event(s) as the group signed them, " +
- "${rebuilt.size} rebuilt from rows that predate the record"
- )
- }
-
- return currentTranslationsOnly(recorded + rebuilt)
- }
-
- /**
- * Drops every translation of a passage but the one that stands.
- *
- * The record keeps every event the group ever signed, deliberately -- a
- * signature is the group's statement and discarding one is not this table's
- * business. The rows do not: `ChatMessage.applyInnerEvent` supersedes a
- * translation chunk, deleting the one it replaces, so a passage translated
- * three times leaves one row and three events.
- *
- * That difference reaches the chronicle the moment it is read from the record
- * rather than rebuilt from rows, and it compounds: every draft a group ever
- * signed would travel in every chronicle it ever sends, for as long as the room
- * exists. A chronicle exists to catch a member up on where the group has got
- * to, not to hand them its drafting history.
- *
- * **The rule is the applying arm's, restated rather than approximated**:
- * newest by the timestamp the group signed at, id breaking a tie. It has to
- * be, or the chronicle would ship one translation as current and the recipient
- * would settle on another -- and since both are validly signed, nothing
- * downstream would notice the disagreement.
- *
- * Dropping the drafts is safe precisely because the recipient applies the
- * same rule: it is not what keeps them correct, only what stops them being
- * sent work they would immediately discard.
- *
- * A translation naming no passage is left alone rather than grouped with
- * others: it is unappliable either way, and letting one stand in for a whole
- * passage would let a malformed event suppress a good one.
- */
- private fun currentTranslationsOnly(events: List): List {
- val translations = events.filter { it.kind == TranslationChunkEvent.KIND }
- if (translations.size < 2) return events
-
- val current = translations
- .groupBy { event ->
- val translation = TranslationChunkEvent(
- id = event.id,
- pubKey = event.pubKey,
- createdAt = event.createdAt,
- tags = event.tags,
- content = event.content,
- sig = event.sig,
- )
-
- val chapterId = translation.translationChapterId()
- val chunkId = translation.chunkId()
-
- if (chapterId == null || chunkId == null) event.id else "$chapterId/$chunkId"
- }
- .values
- .mapNotNull { candidates ->
- candidates.maxWithOrNull(compareBy({ it.createdAt }, { it.id }))
- }
- .mapTo(mutableSetOf()) { it.id }
-
- if (current.size != translations.size) {
- logger.d(
- "Leaving ${translations.size - current.size} superseded translation(s) " +
- "out of the chronicle"
- )
- }
-
- return events.filter { it.kind != TranslationChunkEvent.KIND || it.id in current }
- }
-
- /**
- * The room's rows, rebuilt into the events they came from.
- *
- * Walked down the tree rather than queried per kind, because only dialects
- * and artifacts have a by-room query and the rest hang off a parent. The walk
- * is also what makes an artifact's version label reachable: it is not on the
- * artifact row -- see `MantraArtifact.toArtifactEvent` -- and the version it
- * went into is one step away here.
- *
- * Still walked on every chronicle, and by now it contributes nothing in most
- * rooms: everything signed or applied since `GroupSignedEvent` existed is on
- * file as an event, and [signedEventsOf] discards whatever this rebuilds of
- * it. The walk is a handful of indexed queries against a room's own rows,
- * and it is what makes a half-upgraded room whole, so it runs rather than
- * being skipped when the record looks complete -- there is no way to tell a
- * complete record from a partial one without doing it.
- *
- * It returns everything it can rebuild and lets [signedEventsOf] and the
- * verify filter decide what can travel.
- *
- * Deprecated rather than merely legacy: it is a whole mechanism kept alive
- * for a shrinking set of rows, and it takes eight `toXEvent()` methods and a
- * ten-case round-trip suite with it. **docs/member-chronicle.md, "Retiring the
- * rebuild", is the checklist** -- what goes, what only looks like it goes,
- * and the one thing that has to be true before any of it can.
- */
- @Deprecated(
- "Chronicle fallback for work signed before the GroupSignedEvent table. " +
- "Goes when the last pre-v13 install does -- see the removal checklist " +
- "in docs/member-chronicle.md."
- )
- private suspend fun rebuiltEventsOf(
- database: BennuDatabase,
- chatRoomId: String,
- ): List = buildList {
- database.mantraDialectDao().getDialectsByChatRoomId(chatRoomId).forEach {
- add(it.toDialectEvent())
- }
-
- database.mantraArtifactDao().getArtifactsByChatRoomId(chatRoomId).forEach { artifact ->
- val versions = database.mantraArtifactVersionDao()
- .getArtifactVersionsByArtifactId(artifact.id)
-
- // The version an artifact starts life with carries the label the
- // artifact was signed with, and `ArtifactVersionEvent.initialVersionOf`
- // gives it the artifact's own timestamp. The label is still not on the
- // artifact row -- `fromArtifactEvent` drops it -- so this is where it
- // comes back from. An artifact with no such version is one this device
- // cannot rebuild, which is a gap in the chronicle rather than a reason to
- // abandon it.
- val versionLabel = versions
- .firstOrNull { it.createdAt == artifact.createdAt }
- ?.versionLabel
-
- if (versionLabel == null) {
- logger.w("Artifact ${artifact.id} has no initial version; leaving it out")
- } else {
- add(artifact.toArtifactEvent(versionLabel = versionLabel))
- }
-
- versions.forEach { version ->
- add(version.toArtifactVersionEvent())
-
- database.mantraChapterDao()
- .getChaptersByArtifactVersionId(version.id)
- .forEach { chapter ->
- add(chapter.toChapterEvent())
-
- database.mantraChunkDao()
- .getChunksByChapterId(chapter.id)
- .forEach { add(it.toChunkEvent()) }
- }
-
- database.mantraTranslationArtifactVersionDao()
- .getTranslationsByArtifactVersionId(version.id)
- .forEach { translationVersion ->
- add(translationVersion.toTranslationArtifactVersionEvent())
-
- database.mantraTranslationChapterDao()
- .getTranslationChaptersByTranslationArtifactVersionId(translationVersion.id)
- .forEach { translationChapter ->
- add(translationChapter.toTranslationChapterEvent())
-
- // Only the translation that survived supersession
- // is here to be found: retranslating a passage
- // changes the text and so the event id, and the
- // arm that applies one drops what it replaces. So
- // a chronicle carries a group's current answer to
- // each passage rather than its drafts, which is
- // the same thing every other member holds.
- database.mantraTranslationChunkDao()
- .getTranslationChunksByTranslationChapterId(translationChapter.id)
- .forEach { add(it.toTranslationChunkEvent()) }
- }
- }
- }
- }
- }
+ kinds: ChronicleKinds,
+ ): List = database.groupSignedEventDao()
+ .getByChatRoomId(chatRoomId)
+ // The allowlist, applied to the source that can actually trip it --
+ // see the class comment. A key state on file is the room's own, and
+ // sending it would be handing every member a validly signed
+ // statement about what the room signs with, replayable forever.
+ .filter { kinds.isChroniclable(it.kind) }
+ .map { it.toEvent() }
/**
* [events] cut into pages that fit, keeping the order they arrive in.
*
* Greedy: fill a page until the next event would cross either cap. Both are
- * checked because they bind different chronicles -- a room of one-line dialects
- * hits the count first and a room of chapters hits the bytes.
+ * checked because they bind different chronicles -- a room of one-line events
+ * hits the count first and a room of long ones hits the bytes.
*
* The bytes are the page's *escaped* bytes -- what it will occupy as the
* `content` of the Marmot app event that carries it, which is what a
@@ -832,7 +639,7 @@ object ChronicleManager {
*
* An event too large to share a page with anything is given one of its own.
* One too large for even that is dropped with a log rather than failing the
- * chronicle: a chapter nobody can chronicle is a hole, and a member who gets
+ * chronicle: an event nobody can chronicle is a hole, and a member who gets
* nothing at all is a bigger one.
*/
private fun paginate(events: List): List> {
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/FrostSigningManager.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/FrostSigningManager.kt
index 0f9b9e63..2da8a5bc 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/FrostSigningManager.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/FrostSigningManager.kt
@@ -1,9 +1,12 @@
package com.machankura.bennu.compose.managers
+import com.machankura.bennu.compose.nostr.subgroup.allows
+import com.machankura.bennu.compose.nostr.frost.GroupKeyStateEvent
import fr.acinq.bitcoin.OutPoint
import com.machankura.bennu.compose.database.model.GroupTransaction
import com.machankura.bennu.compose.database.model.types.FrostSigningSubject
import com.machankura.bennu.compose.nostr.wallet.GroupWalletStatementEvent
+import com.machankura.bennu.compose.nostr.wallet.MemberWalletCertificateEvent
import com.machankura.bennu.compose.wallet.GroupSpend
import fr.acinq.bitcoin.ByteVector64
import fr.acinq.bitcoin.Chain
@@ -57,6 +60,7 @@ import com.machankura.bennu.compose.database.model.types.FrostSigningStage
import com.machankura.bennu.compose.extensions.toHex
import com.machankura.bennu.compose.nostr.dkg.DkgRitualEvents
import com.machankura.bennu.compose.nostr.frost.FrostSigningEvents
+import com.machankura.bennu.compose.nostr.subgroup.SubgroupBirthCertificateEvent
/**
* Signs a nostr event with a group's FROST threshold key, in one of its rooms.
@@ -565,6 +569,73 @@ object FrostSigningManager {
}
}
+ // A birth certificate's guardian keys are a promise by the group signing
+ // it, so they have to be the keys it grants: recomputed here from the key
+ // this session signs with and the group's own certificate, never taken
+ // from the proposer. Its wallet policy has to be one the group may make:
+ // a guarded group only makes guarded subgroups. Refused before anything is shown, for the reason a
+ // mismatched id is.
+ val thresholdPublicKey = key.thresholdPublicKey
+ unsignedEvents.forEach { rebuilt ->
+ if (rebuilt.kind != SubgroupBirthCertificateEvent.KIND || thresholdPublicKey == null) return@forEach
+ SubgroupManager.refuseCertificate(database, rebuilt.pubKey, thresholdPublicKey, rebuilt)?.let { reason ->
+ logger.w("Signing proposal $sessionId carries a birth certificate that $reason; dropping")
+ return null
+ }
+ }
+
+ // A member wallet's certificate is this group agreeing to guard one
+ // member's key, so it has to be exactly what that member asked for, asked
+ // by a member, with exactly the guardian keys this group grants -- the
+ // list a guarded subgroup of it would get. Recomputed from this device's
+ // own key state, never taken from the sponsor who proposed it.
+ // docs/member-guarded-wallets.md, Phase 7.
+ unsignedEvents.forEach { rebuilt ->
+ if (rebuilt.kind != MemberWalletCertificateEvent.KIND) return@forEach
+ val reason = thresholdPublicKey
+ ?.let { MemberWalletManager.refuseCertificate(database, rebuilt.pubKey, it, rebuilt) }
+ ?: if (thresholdPublicKey == null) "cannot be checked without the group's key" else null
+ reason?.let {
+ logger.w("Signing proposal $sessionId carries a member wallet certificate that $it; dropping")
+ return null
+ }
+ }
+
+ // A subgroup's key state carries its birth certificate, and the
+ // certificate's wallet policy has to be the one this group was made
+ // under: every admin was shown it at the join gate, so joining was
+ // agreeing to it. A certificate proposed later, by a parent admin
+ // resuming the flow, under another one would be the child signing a
+ // decision none of its members agreed to. [key] is the child's own
+ // ceremony here, which is where the policy was filed.
+ // `docs/subgroup-wallet-policy.md`, Phase 5.
+ // A wallet statement has to be one the room's parent allows: a subgroup
+ // decided guarded opens a guarded wallet and nothing else, and one decided
+ // unguarded a plain one. Read off this device's own certificate for the
+ // room, never the proposal's, and refused before it is shown -- a member
+ // should not be asked to approve what their device already knows the
+ // room has ruled out. docs/subgroup-wallet-policy.md, Phase 7.
+ unsignedEvents.forEach { rebuilt ->
+ if (rebuilt.kind != GroupWalletStatementEvent.KIND) return@forEach
+ val guarded = GroupWalletStatementEvent.read(rebuilt.tags, rebuilt.content)?.guardians?.isNotEmpty() ?: return@forEach
+ val policy = SubgroupManager.walletPolicyOf(database, rebuilt.pubKey)
+ if (!policy.allows(guarded)) {
+ logger.w(
+ "Signing proposal $sessionId opens ${if (guarded) "a guarded" else "an unguarded"} wallet, " +
+ "and this group's parent decided otherwise; dropping"
+ )
+ return null
+ }
+ }
+
+ unsignedEvents.forEach { rebuilt ->
+ if (rebuilt.kind != GroupKeyStateEvent.KIND) return@forEach
+ SubgroupManager.refuseKeyState(key, rebuilt)?.let { reason ->
+ logger.w("Signing proposal $sessionId carries a key state that $reason; dropping")
+ return null
+ }
+ }
+
val session = FrostSigningSession(
id = sessionId,
chatRoomId = localChatRoom.chatRoom.id,
@@ -631,7 +702,7 @@ object FrostSigningManager {
val wallet = GroupWalletManager.walletFor(database, chatRoomId, thresholdPublicKey, chain, account)
?: throw IllegalStateException("This group has not opened a wallet on ${GroupWalletStatementEvent.chainName(chain)}")
- val checked = when (val result = GroupSpend.check(psbt, wallet.account)) {
+ val checked = when (val result = GroupSpend.check(psbt, wallet.account).withFundings(database, chatRoomId)) {
is GroupSpend.Result.Ok -> result.checked
is GroupSpend.Result.Refused -> throw IllegalArgumentException("This spend ${result.reason}")
}
@@ -675,6 +746,82 @@ object FrostSigningManager {
return session
}
+ /**
+ * Opens a session over one transaction from a *descendant's* guarded wallet,
+ * signed through this room's guardian leaf -- `docs/group-wallet-guardians.md`.
+ *
+ * The same session as [proposeSpend] in every way but three: the wallet is
+ * the one this room was told about rather than its own, every input is
+ * signed over BIP342's script-path sighash as the key this group's walk
+ * reaches, and the proposal names the descendant so every signer reads the
+ * same wallet from its own copy of the statement.
+ *
+ * @throws IllegalArgumentException when the spend fails a check, with the reason
+ * @throws IllegalStateException when the room has no key, this device holds no
+ * share of it, or the room holds no guarded wallet of [descendantChatRoomId] on
+ * [chain] at [account]
+ */
+ suspend fun proposeGuardianSpend(
+ database: BennuDatabase,
+ localChatRoom: LocalChatRoom,
+ userPublicKey: HexKey,
+ psbt: Psbt,
+ descendantChatRoomId: String,
+ chain: Chain,
+ account: Long = 0L,
+ ): FrostSigningSession {
+ val chatRoomId = localChatRoom.chatRoom.id
+ val ceremony = completedKey(database, chatRoomId)
+ ?: throw IllegalStateException("This group has no shared key to sign with")
+ val thresholdPublicKey = ceremony.thresholdPublicKey
+ ?: throw IllegalStateException("Ceremony ${ceremony.id} holds no threshold key")
+ val signerId = signerIdOf(database, ceremony, userPublicKey)
+ ?: throw IllegalStateException("This device is not a participant in ceremony ${ceremony.id}")
+ val guarded = GuardianManager.guardedWalletFor(database, chatRoomId, descendantChatRoomId, chain, account)
+ ?: throw IllegalStateException("This group guards no wallet of $descendantChatRoomId on ${GroupWalletStatementEvent.chainName(chain)}")
+
+ val checked = when (val result = GroupSpend.check(psbt, guarded.account, guarded.spender(thresholdPublicKey)).withFundings(database, chatRoomId)) {
+ is GroupSpend.Result.Ok -> result.checked
+ is GroupSpend.Result.Refused -> throw IllegalArgumentException("This spend ${result.reason}")
+ }
+
+ val session = FrostSigningSession(
+ id = RandomInstance.bytes(32).toHex(),
+ chatRoomId = chatRoomId,
+ coordinatorPublicKey = userPublicKey,
+ userPublicKey = userPublicKey,
+ dkgSessionId = ceremony.id,
+ threshold = ceremony.threshold,
+ participantCount = ceremony.participantCount,
+ signerId = signerId,
+ derivationPath = null,
+ subject = FrostSigningSubject.TRANSACTION,
+ signApprovedAt = Clock.System.now()
+ )
+ writeSpend(database, session, checked, chain, account, guardedChatRoomId = descendantChatRoomId)
+ announceStarted(database, session)
+
+ logger.i(
+ "Proposing guardian spend ${session.id} from $descendantChatRoomId: ${checked.inputs.size} input(s), " +
+ "${checked.amountSent.sat} sats out, ${checked.fee.sat} sats fee, txid ${checked.tx.txid}"
+ )
+
+ broadcast(
+ database = database,
+ localChatRoom = localChatRoom,
+ session = session,
+ kind = FrostSigningEvents.TRANSACTION_PROPOSAL,
+ content = GroupSpend.encode(psbt),
+ includeKey = true,
+ extraTags = FrostSigningEvents.walletTags(GroupWalletStatementEvent.chainName(chain), account) +
+ FrostSigningEvents.guardedTags(descendantChatRoomId)
+ )
+
+ advance(database, localChatRoom, session.id)
+
+ return session
+ }
+
/**
* Records a proposed spend, after every check [GroupSpend.check] makes.
* Returns the session, whether it was just created or already known.
@@ -737,14 +884,33 @@ object FrostSigningManager {
return null
}
- // 1. There is a wallet, and it is the room's.
- val wallet = GroupWalletManager.walletFor(database, localChatRoom.chatRoom.id, thresholdPublicKey, chain, account)
- if (wallet == null) {
- logger.w("Spend proposal $sessionId spends from a wallet the group has not opened on $chainName; dropping")
- return null
+ // 1. There is a wallet, and it is the room's -- or, for a guardian's
+ // spend, a descendant's this room was told about and holds a leaf in.
+ // Either way read from this device's own copy of the statement.
+ val guardedChatRoomId = FrostSigningEvents.parseGuarded(innerEvent.tags)
+ val (walletAccount, spender) = if (guardedChatRoomId == null) {
+ val wallet = GroupWalletManager.walletFor(database, localChatRoom.chatRoom.id, thresholdPublicKey, chain, account)
+ if (wallet == null) {
+ logger.w("Spend proposal $sessionId spends from a wallet the group has not opened on $chainName; dropping")
+ return null
+ }
+ wallet.account to GroupSpend.Spender.Owner
+ } else {
+ // The leaf is the room's, so the key signing it has to be the room's
+ // own -- not a subgroup ceremony held in this room.
+ if (GroupWalletManager.thresholdKeyFor(database, localChatRoom.chatRoom.id) != thresholdPublicKey) {
+ logger.w("Guardian spend proposal $sessionId names a key that is not this room's; dropping")
+ return null
+ }
+ val guarded = GuardianManager.guardedWalletFor(database, localChatRoom.chatRoom.id, guardedChatRoomId, chain, account)
+ if (guarded == null) {
+ logger.w("Guardian spend proposal $sessionId spends from a wallet this room guards none of; dropping")
+ return null
+ }
+ guarded.account to guarded.spender(thresholdPublicKey)
}
- val checked = when (val result = GroupSpend.check(psbt, wallet.account)) {
+ val checked = when (val result = GroupSpend.check(psbt, walletAccount, spender).withFundings(database, localChatRoom.chatRoom.id)) {
is GroupSpend.Result.Ok -> result.checked
is GroupSpend.Result.Refused -> {
logger.w("Spend proposal $sessionId ${result.reason}; dropping")
@@ -764,7 +930,7 @@ object FrostSigningManager {
derivationPath = null,
subject = FrostSigningSubject.TRANSACTION,
)
- writeSpend(database, session, checked, chain, account)
+ writeSpend(database, session, checked, chain, account, guardedChatRoomId)
announceStarted(database, session)
logger.i(
@@ -788,6 +954,7 @@ object FrostSigningManager {
checked: GroupSpend.Checked,
chain: Chain,
account: Long,
+ guardedChatRoomId: String? = null,
) {
database.frostSigningSessionDao().upsert(session)
database.frostSigningSessionDao().upsertItems(
@@ -809,6 +976,7 @@ object FrostSigningManager {
chatRoomId = session.chatRoomId,
chain = GroupWalletStatementEvent.chainName(chain),
account = account,
+ guardedChatRoomId = guardedChatRoomId,
psbt = GroupSpend.encode(checked.psbt),
txid = checked.tx.txid.toString(),
)
@@ -826,6 +994,26 @@ object FrostSigningManager {
* rebuilt on every pass from the ceremony's key and the transaction row --
* the same rule as a room's path: stored inputs, rederived, never cached.
*/
+ /**
+ * One cache per input: the address's key path for the room's own spend, read
+ * off the items as always; the guardian's leaf for a spend through it, read
+ * off the spend checked again -- the leaf, the walk and the sighash are one
+ * computation, and a cache taken apart from it could sign for another leaf.
+ */
+ private suspend fun spendCaches(
+ database: BennuDatabase,
+ session: FrostSigningSession,
+ thresholdPublicKey: HexKey,
+ items: List,
+ ): List? {
+ val transaction = database.groupTransactionDao().getBySessionId(session.id) ?: return null
+ if (transaction.guardedChatRoomId == null) {
+ return spendDerivations(database, session, thresholdPublicKey, items)?.map { it.cache }
+ }
+ val checked = checkedSpend(database, session.id) ?: return null
+ return checked.inputs.map { it.cache }.takeIf { it.size == items.size }
+ }
+
private suspend fun spendDerivations(
database: BennuDatabase,
session: FrostSigningSession,
@@ -840,6 +1028,30 @@ object FrostSigningManager {
}
}
+ /** What a spend session signs under: its transaction row, the account its coins are in, and who signs them. */
+ private data class SpendContext(
+ val transaction: GroupTransaction,
+ val account: GroupWalletDerivation.Account,
+ val spender: GroupSpend.Spender,
+ )
+
+ /**
+ * [spendAccount], and for a guardian's spend the descendant's guarded wallet
+ * as this room holds it, with this group as the spender.
+ */
+ private suspend fun spendContext(
+ database: BennuDatabase,
+ session: FrostSigningSession,
+ thresholdPublicKey: HexKey,
+ ): SpendContext? {
+ val transaction = database.groupTransactionDao().getBySessionId(session.id) ?: return null
+ val guardedChatRoomId = transaction.guardedChatRoomId
+ ?: return spendAccount(database, session, thresholdPublicKey)?.let { (row, account) -> SpendContext(row, account, GroupSpend.Spender.Owner) }
+ val chain = GroupWalletStatementEvent.chainNamed(transaction.chain) ?: return null
+ val guarded = GuardianManager.guardedWalletFor(database, transaction.chatRoomId, guardedChatRoomId, chain, transaction.account) ?: return null
+ return SpendContext(transaction, guarded.account, guarded.spender(thresholdPublicKey))
+ }
+
private suspend fun spendAccount(
database: BennuDatabase,
session: FrostSigningSession,
@@ -847,7 +1059,11 @@ object FrostSigningManager {
): Pair? {
val transaction = database.groupTransactionDao().getBySessionId(session.id) ?: return null
val chain = GroupWalletStatementEvent.chainNamed(transaction.chain) ?: return null
- return transaction to GroupWalletDerivation.account(thresholdPublicKey, chain, transaction.account)
+ // The account as the room's statement opened it: a guarded one's
+ // addresses carry its guardians' leaves, and the bare derivation would be
+ // a plain account at the same key, whose addresses none of these coins are at.
+ val opened = GroupWalletManager.walletFor(database, transaction.chatRoomId, thresholdPublicKey, chain, transaction.account)
+ return transaction to (opened?.account ?: GroupWalletDerivation.account(thresholdPublicKey, chain, transaction.account))
}
/**
@@ -1084,9 +1300,28 @@ object FrostSigningManager {
if (session.subject != FrostSigningSubject.TRANSACTION) return null
val thresholdPublicKey = database.dkgSessionDao().getSessionById(session.dkgSessionId)?.thresholdPublicKey
?: return null
- val (transaction, account) = spendAccount(database, session, thresholdPublicKey) ?: return null
- val psbt = GroupSpend.decode(transaction.psbt) ?: return null
- return (GroupSpend.check(psbt, account) as? GroupSpend.Result.Ok)?.checked
+ val context = spendContext(database, session, thresholdPublicKey) ?: return null
+ val psbt = GroupSpend.decode(context.transaction.psbt) ?: return null
+ return (GroupSpend.check(psbt, context.account, context.spender).withFundings(database, context.transaction.chatRoomId) as? GroupSpend.Result.Ok)?.checked
+ }
+
+ /**
+ * A checked spend with its payments into descendants' guarded wallets read
+ * against the ones [chatRoomId] holds -- `GroupSpend.fundingsOf` -- or
+ * refused for a claim that does not derive. Every place a spend is checked
+ * for a member to read or sign reads its fundings here, so the label a
+ * signer sees is the one every other signer's device derived too.
+ *
+ * A spend none of whose payments claims anything -- every spend to a typed
+ * address -- reads no guarded wallets at all.
+ */
+ private suspend fun GroupSpend.Result.withFundings(database: BennuDatabase, chatRoomId: String): GroupSpend.Result {
+ val checked = (this as? GroupSpend.Result.Ok)?.checked ?: return this
+ if (checked.payments.all { checked.psbt.outputs[it.index].taprootDerivationPaths.isEmpty() }) return this
+ return when (val reading = GroupSpend.fundingsOf(checked, GuardianManager.guardedWalletsOf(database, chatRoomId))) {
+ is GroupSpend.FundingReading.Ok -> GroupSpend.Result.Ok(checked.copy(fundings = reading.fundings))
+ is GroupSpend.FundingReading.Refused -> GroupSpend.Result.Refused(reading.reason)
+ }
}
/**
@@ -1115,6 +1350,21 @@ object FrostSigningManager {
.flatMap { GroupSpend.claimedChangeIndices(it, account) }
.toSet()
+ /**
+ * The receive addresses of [account] -- a descendant's guarded wallet -- that
+ * a room's open spends fund, which a new funding should not pay as well.
+ * Held by the same sessions as [reservedOutPoints], for the reason
+ * [reservedChangeIndices] gives.
+ */
+ suspend fun reservedFundingIndices(
+ database: BennuDatabase,
+ chatRoomId: String,
+ account: GroupWalletDerivation.Account,
+ ): Set =
+ openSpends(database, chatRoomId)
+ .flatMap { GroupSpend.claimedFundingIndices(it, account) }
+ .toSet()
+
/** The PSBT of every spend in the room whose session has not failed. */
private suspend fun openSpends(database: BennuDatabase, chatRoomId: String): List =
database.groupTransactionDao().getByChatRoomId(chatRoomId)
@@ -1142,28 +1392,7 @@ object FrostSigningManager {
database.groupTransactionDao().upsert(confirmed.copy(confirmedAt = at, seenAt = confirmed.seenAt ?: at))
- val coins = coinsOf(confirmed)
- database.groupTransactionDao().getByChatRoomId(confirmed.chatRoomId)
- .filter { it.frostSigningSessionId != sessionId && (coinsOf(it) intersect coins).isNotEmpty() }
- .forEach { other ->
- val otherSession = database.frostSigningSessionDao().getSessionById(other.frostSigningSessionId)
- ?: return@forEach
- when (otherSession.stage) {
- FrostSigningStage.COMPLETE -> if (other.confirmedAt == null && other.replacedByTxid == null) {
- database.groupTransactionDao().upsert(other.copy(replacedByTxid = confirmed.txid))
- }
-
- FrostSigningStage.FAILED -> Unit
-
- else -> fail(
- database = database,
- session = otherSession,
- reason = "Spent by another transaction",
- content = "abandoned a spend: another of the group's transactions spent its coins first. " +
- "Nothing was signed."
- )
- }
- }
+ settleSpendsOf(database, confirmed.chatRoomId, coinsOf(confirmed), byTxid = confirmed.txid, except = sessionId)
val sent = checkedSpend(database, sessionId)?.amountSent
announce(
@@ -1176,6 +1405,67 @@ object FrostSigningManager {
)
}
+ /**
+ * A spend whose coins a transaction the room never proposed has taken, as
+ * [conflictTxid] confirmed: marked replaced, and every other spend of the same
+ * coins settled with it.
+ *
+ * A guarded wallet's coins have two kinds of spender. The child's own spend
+ * can lose a coin to a guardian's, and a guardian's to the child's, and the
+ * winner is never a row in the loser's room -- so [recordConfirmed] cannot be
+ * what settles the loser. The watcher is: it asks the chain whether a signed
+ * spend's coins are still there, and calls this when one was taken by a
+ * confirmed transaction. Once per spend, by the read of `replacedByTxid`.
+ */
+ suspend fun recordReplaced(database: BennuDatabase, sessionId: String, conflictTxid: String) {
+ val lost = database.groupTransactionDao().getBySessionId(sessionId) ?: return
+ if (lost.confirmedAt != null || lost.replacedByTxid != null) return
+
+ database.groupTransactionDao().upsert(lost.copy(replacedByTxid = conflictTxid))
+ settleSpendsOf(database, lost.chatRoomId, coinsOf(lost), byTxid = conflictTxid, except = sessionId)
+ logger.i("Spend $sessionId lost its coins to $conflictTxid")
+ }
+
+ /**
+ * Every spend in [chatRoomId] other than [except] that wants any of [coins],
+ * settled by [byTxid] having taken them: only one spend of a coin can ever
+ * confirm, so the rest are over whatever stage they are in. One still
+ * collecting is abandoned -- its signatures, if it ever got them, would be
+ * over a transaction nobody can mine. One already signed is a transaction
+ * [byTxid] replaced, a fee bump or a race, and is marked so rather than
+ * failed: it was signed, and saying otherwise would misreport what the group
+ * did.
+ */
+ private suspend fun settleSpendsOf(
+ database: BennuDatabase,
+ chatRoomId: String,
+ coins: Set,
+ byTxid: String,
+ except: String,
+ ) {
+ database.groupTransactionDao().getByChatRoomId(chatRoomId)
+ .filter { it.frostSigningSessionId != except && (coinsOf(it) intersect coins).isNotEmpty() }
+ .forEach { other ->
+ val otherSession = database.frostSigningSessionDao().getSessionById(other.frostSigningSessionId)
+ ?: return@forEach
+ when (otherSession.stage) {
+ FrostSigningStage.COMPLETE -> if (other.confirmedAt == null && other.replacedByTxid == null) {
+ database.groupTransactionDao().upsert(other.copy(replacedByTxid = byTxid))
+ }
+
+ FrostSigningStage.FAILED -> Unit
+
+ else -> fail(
+ database = database,
+ session = otherSession,
+ reason = "Spent by another transaction",
+ content = "abandoned a spend: another transaction spent its coins first. " +
+ "Nothing was signed."
+ )
+ }
+ }
+ }
+
private fun coinsOf(transaction: GroupTransaction): Set =
GroupSpend.decode(transaction.psbt)?.global?.tx?.txIn?.map { it.outPoint }?.toSet().orEmpty()
@@ -1189,7 +1479,7 @@ object FrostSigningManager {
* transaction nobody can mine, and `correctlySpends` is the only check that
* asks the question the network will. Nothing is applied and nothing is
* filed as a `GroupSignedEvent` -- this is not an event, and the chronicle
- * and the broadcast screen read that table.
+ * reads that table.
*/
private suspend fun completeSpend(
database: BennuDatabase,
@@ -1199,11 +1489,11 @@ object FrostSigningManager {
val key = database.dkgSessionDao().getSessionById(session.dkgSessionId)
val thresholdPublicKey = key?.thresholdPublicKey
?: throw IllegalStateException("The ceremony this spend signs under is gone")
- val (transaction, account) = spendAccount(database, session, thresholdPublicKey)
+ val (transaction, account, spender) = spendContext(database, session, thresholdPublicKey)
?: throw IllegalStateException("This spend has no transaction on file")
val psbt = GroupSpend.decode(transaction.psbt)
?: throw IllegalStateException("This spend's PSBT can no longer be read")
- val checked = when (val result = GroupSpend.check(psbt, account)) {
+ val checked = when (val result = GroupSpend.check(psbt, account, spender)) {
is GroupSpend.Result.Ok -> result.checked
is GroupSpend.Result.Refused -> throw IllegalStateException("This spend ${result.reason}")
}
@@ -1211,13 +1501,13 @@ object FrostSigningManager {
val signatures = items.mapIndexed { index, item ->
val input = checked.inputs[index]
val signature = ByteVector64(item.signature!!)
- if (!Crypto.verifySignatureSchnorr(input.sighash, signature, input.derivation.outputKey)) {
+ if (!Crypto.verifySignatureSchnorr(input.sighash, signature, input.signingKey)) {
throw IllegalStateException("The aggregated signature for input $index does not verify against its coin")
}
signature
}
- val signed = GroupSpend.witnessed(checked.tx, signatures)
+ val signed = checked.witnessed(signatures)
signed.correctlySpends(
checked.inputs.associate { it.outPoint to it.txOut },
ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS
@@ -1240,8 +1530,11 @@ object FrostSigningManager {
database = database,
session = session,
messageType = ChatMessage.TYPE_FROST_COMPLETE,
- content = "The group signed a transaction sending ${checked.amountSent.sat} sats, " +
- "with ${checked.fee.sat} sats in fees. It took ${session.threshold} of " +
+ content = when (val guardian = checked.spender as? GroupSpend.Spender.Guardian) {
+ null -> "The group signed a transaction sending ${checked.amountSent.sat} sats, "
+ else -> "The group signed a transaction sending ${checked.amountSent.sat} sats from " +
+ "${com.machankura.bennu.compose.text.ProposedSpend.guardedWallet(guardian.name, guardian.label)}, "
+ } + "with ${checked.fee.sat} sats in fees. It took ${session.threshold} of " +
"${session.participantCount} members.",
actor = session.coordinatorPublicKey
)
@@ -1595,8 +1888,7 @@ object FrostSigningManager {
.cache
.let { cache -> List(items.size) { cache } }
- FrostSigningSubject.TRANSACTION -> spendDerivations(database, session, thresholdPublicKey, items)
- ?.map { it.cache }
+ FrostSigningSubject.TRANSACTION -> spendCaches(database, session, thresholdPublicKey, items)
?: throw IllegalStateException("The coins this transaction spends no longer derive under the group's wallet")
FrostSigningSubject.SWEEP -> sweepOf(database, session, thresholdPublicKey)
@@ -1831,8 +2123,7 @@ object FrostSigningManager {
// wire from here: a signed event authored by the threshold key cannot
// travel as an inner event anyway, because the outbound pipeline
// re-authors rumors as their sender and would strip the group's
- // signature off. Sending one to relays is a member's separate act,
- // from `BroadcastGroupSignedEventScreen`, off the recorded row.
+ // signature off.
signedEvents.forEach { applySignedEvent(database, session, it, recorded) }
announce(
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupKeyStateManager.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupKeyStateManager.kt
index 181b8fe8..de4bc698 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupKeyStateManager.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupKeyStateManager.kt
@@ -423,6 +423,19 @@ object GroupKeyStateManager {
return null
}
+ // A wallet policy present and unreadable must never look absent: an
+ // undecided child is offered both wallets, so a corrupt `guarded` would
+ // hand it the plain one its parent took away -- the lesson of
+ // [GroupKeyStateEvent.claimsParentage], one tag further on.
+ // `docs/subgroup-wallet-policy.md`.
+ if (SubgroupBirthCertificateEvent.parseWalletPolicy(certificate.tags) == null) {
+ logger.w(
+ "Key state for $announced carries a certificate whose wallet policy does not " +
+ "read, or contradicts its guardian keys; dropping"
+ )
+ return null
+ }
+
return Parentage(
SubgroupParentage(parentChatRoomId = parentChatRoomId, certificate = certificate)
)
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningAuthorisations.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningAuthorisations.kt
index 2b3d59c2..a12fe844 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningAuthorisations.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningAuthorisations.kt
@@ -18,7 +18,7 @@ import kotlin.time.Instant
* What the group has authorised its Lightning wallet to spend, as a co-signer reads it and the operator's
* node acts on it (`docs/group-lightning-wallet.md`, Phases 12 and 13).
*
- * An authorisation is a group-signed event (kind 30346, [GroupLightningAuthorisationEvent]). The group
+ * An authorisation is a group-signed event (kind 30363, [GroupLightningAuthorisationEvent]). The group
* may sign two for one invoice -- once more after the first expired, say. They are one payment: the
* budget is the larger, and it is open while either is. A close or force close names one channel, and
* lasts [CHANNEL_ACTION_LIFETIME].
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningNode.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningNode.kt
index 4f302dd4..f8b2b9ee 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningNode.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningNode.kt
@@ -66,7 +66,7 @@ import kotlinx.coroutines.launch
* transport ([GroupIcebergTransport]) reaches the members through the room. It runs only while this
* device is the elected operator and has heard from the room recently ([GroupLightningOperatorManager.mayRunNode]),
* and it stops itself the moment a newer term names somebody else -- telling the room where its
- * channels were as it goes (kind 30349).
+ * channels were as it goes (kind 30366).
*
* The node itself is behind [PeerHandle], so the life cycle can be tested without an LSP to connect to.
*/
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningOperatorManager.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningOperatorManager.kt
index 5ac8991b..3387bde8 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningOperatorManager.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningOperatorManager.kt
@@ -87,7 +87,7 @@ object GroupLightningOperatorManager {
return current(database, chatRoomId, chain, wallet)?.publicKey == userPublicKey
}
- /** Tells the room this device's node stopped, and where its channels were (kind 30349). */
+ /** Tells the room this device's node stopped, and where its channels were (kind 30366). */
suspend fun announceStopped(database: BennuDatabase, localChatRoom: LocalChatRoom, userPublicKey: HexKey, chain: Chain, wallet: Long, term: Long, commitmentNumbers: Map) {
GroupLightningWalletManager.queue(
database, localChatRoom, userPublicKey, GroupLightningEvents.STOPPED,
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningWalletManager.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningWalletManager.kt
index d1d6337b..a74821ff 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningWalletManager.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupLightningWalletManager.kt
@@ -144,7 +144,7 @@ object GroupLightningWalletManager {
/**
* Proposes the wallet: makes its node seed, sends it to every other participant encrypted to them
- * (kind 30340), and opens a signing session over the statement. The wallet exists once a quorum signs.
+ * (kind 30357), and opens a signing session over the statement. The wallet exists once a quorum signs.
*/
suspend fun proposeWallet(
database: BennuDatabase,
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupWalletDerivation.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupWalletDerivation.kt
index fa49f211..cea9dd47 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupWalletDerivation.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupWalletDerivation.kt
@@ -13,6 +13,7 @@ import fr.acinq.bitcoin.KeyPath
import fr.acinq.bitcoin.PrivateKey
import fr.acinq.bitcoin.PublicKey
import fr.acinq.bitcoin.Script
+import fr.acinq.bitcoin.ScriptTree
import fr.acinq.bitcoin.XonlyPublicKey
import fr.acinq.bitcoin.crypto.Pack
import fr.acinq.bitcoin.crypto.frost.TweakCache
@@ -54,6 +55,15 @@ import fr.acinq.bitcoin.utils.Either
* key for any address recovers the group's threshold key -- the room, every
* address of every account, and every event the group can sign. Nothing here or
* anywhere else reconstructs one. The only export is the account xpub.
+ *
+ * ### A guarded account
+ *
+ * An account opened with guardians -- the keys a subgroup's birth certificate
+ * grants it, see `GuardianDerivation` -- is the same account with one change at
+ * the very end: each address commits to a tree of one leaf per guardian, so the
+ * last tweak is BIP341's script-path tweak over that tree rather than BIP86's
+ * empty one. The internal key, and so the group's own key-path spend, is
+ * untouched. `docs/group-wallet-guardians.md` says why.
*/
object GroupWalletDerivation {
/** BIP44's external chain: addresses handed out to be paid. */
@@ -71,7 +81,7 @@ object GroupWalletDerivation {
private const val ACCOUNT_TAG = "bennu/group-wallet/account/v1"
/** The largest unhardened BIP32 index. Hardened ones cannot be walked here. */
- private const val MAX_INDEX: Long = 0x7FFFFFFFL
+ internal const val MAX_INDEX: Long = 0x7FFFFFFFL
/**
* One account of one group on one network: the extended public key every
@@ -86,7 +96,16 @@ object GroupWalletDerivation {
val extendedPublicKey: DeterministicWallet.ExtendedPublicKey,
/** The threshold key tweaked to [extendedPublicKey]'s key: what the account's sessions start from. */
internal val cache: TweakCache,
+ /**
+ * The ancestors that can spend from every address of this account, nearest
+ * first -- empty for an account nobody guards, which is every account a
+ * group that is nobody's subgroup opens.
+ */
+ val guardians: List = emptyList(),
) {
+ /** Whether its addresses carry guardian leaves. */
+ val isGuarded: Boolean get() = guardians.isNotEmpty()
+
/** The account key's own fingerprint, as a descriptor's key origin and a PSBT's derivation name it. */
val fingerprint: Long get() = extendedPublicKey.fingerprint()
@@ -109,14 +128,20 @@ object GroupWalletDerivation {
val changeDescriptor: String get() = descriptor(CHANGE)
private fun descriptor(change: Long): String {
- val body = "tr([$fingerprintHex]$xpub/$change/*)"
+ val tree = if (isGuarded) "," + GuardianDerivation.descriptorTree(guardians, chain, account, change) else ""
+ val body = "tr([$fingerprintHex]$xpub/$change/*$tree)"
return "$body#${Descriptor.checksum(body)}"
}
- override fun equals(other: Any?): Boolean =
- other is Account && chain == other.chain && account == other.account && extendedPublicKey == other.extendedPublicKey
+ /** The same account with [guardians] in every address. */
+ fun guardedBy(guardians: List): Account =
+ Account(chain, account, extendedPublicKey, cache, guardians)
- override fun hashCode(): Int = extendedPublicKey.hashCode()
+ override fun equals(other: Any?): Boolean =
+ other is Account && chain == other.chain && account == other.account &&
+ extendedPublicKey == other.extendedPublicKey && guardians == other.guardians
+
+ override fun hashCode(): Int = extendedPublicKey.hashCode() * 31 + guardians.hashCode()
}
/**
@@ -134,12 +159,22 @@ object GroupWalletDerivation {
/** BIP86's output key `Q`: the key in the output script, and the key a spend's signature verifies against. */
val outputKey: XonlyPublicKey,
val cache: TweakCache,
+ /** The guardian leaves this address commits to, or null for BIP86's empty tree. */
+ val tree: ScriptTree? = null,
) {
+ /** The tweak from [internalKey] to [outputKey]: over [tree] when there is one, BIP86's otherwise. */
+ val taprootTweak: Crypto.TaprootTweak
+ get() = tree?.let { Crypto.TaprootTweak.ScriptPathTweak(it.hash()) } ?: Crypto.TaprootTweak.KeyPathTweak
+
/** `OP_1 `. */
val pubkeyScript: ByteVector
- get() = ByteVector(Script.write(Script.pay2tr(internalKey, Crypto.TaprootTweak.KeyPathTweak)))
+ get() = ByteVector(Script.write(Script.pay2tr(internalKey, taprootTweak)))
- fun address(chain: Chain): String = Bitcoin.computeBIP86Address(internalKey, chain.chainHash)
+ fun address(chain: Chain): String = when (tree) {
+ null -> Bitcoin.computeBIP86Address(internalKey, chain.chainHash)
+ else -> Bitcoin.addressFromPublicKeyScript(chain.chainHash, pubkeyScript.toByteArray()).right
+ ?: throw IllegalStateException("a taproot output always has an address")
+ }
/** The path below the account, as a PSBT's `tap_bip32_derivation` carries it. */
val keyPath: KeyPath get() = KeyPath(listOf(change, index))
@@ -153,22 +188,21 @@ object GroupWalletDerivation {
* or the HMAC lands on an invalid scalar -- around 2^-127, and BIP32 throws at
* the same place.
*/
- fun account(thresholdPublicKey: HexKey, chain: Chain, account: Long = 0L): Account {
+ fun account(
+ thresholdPublicKey: HexKey,
+ chain: Chain,
+ account: Long = 0L,
+ guardians: List = emptyList(),
+ ): Account {
require(account in 0L..MAX_INDEX) { "account $account is not an unhardened index" }
val root = PublicKey(ByteVector(thresholdPublicKey.hexToByteArray()))
require(root.isValid()) { "the threshold key is not a valid point" }
- val i = Crypto.hmac512(
- ACCOUNT_TAG.encodeToByteArray(),
- root.value.toByteArray() + chain.chainHash.value.toByteArray() + Pack.writeInt32BE(account.toInt())
- )
- val tweak = i.copyOfRange(0, 32)
- val chainCode = i.copyOfRange(32, 64)
- require(Crypto.isPrivKeyValid(tweak)) { "the account step for account $account landed on an invalid scalar" }
+ val (tweak, chainCode) = accountStep(root, chain, account)
val accountKey = root + PrivateKey(tweak).publicKey()
- val cache = plainTweak(TweakCache.create(root), ByteVector32(tweak), "the account step")
+ val cache = plainTweak(TweakCache.create(root), tweak, "the account step")
// The cache tracks the full point; the point arithmetic above is the
// reference it has to agree with, or every session for this account signs
// for a key nobody's coins are at.
@@ -179,15 +213,34 @@ object GroupWalletDerivation {
account = account,
extendedPublicKey = DeterministicWallet.ExtendedPublicKey(
publickeybytes = accountKey.value,
- chaincode = ByteVector32(chainCode),
+ chaincode = chainCode,
depth = 0,
path = KeyPath.empty,
parent = 0L,
),
cache = cache,
+ guardians = guardians,
)
}
+ /**
+ * The account step's tweak and chain code for [root]: `I[0:32]` and
+ * `I[32:64]` of the tagged HMAC over the key, the network and the account.
+ *
+ * Split out for the one holder of a key path who has its private key -- a
+ * member wallet, `MemberWalletDerivation` -- which adds the same tweak to
+ * the scalar that [account] adds to the point.
+ */
+ internal fun accountStep(root: PublicKey, chain: Chain, account: Long): Pair {
+ val i = Crypto.hmac512(
+ ACCOUNT_TAG.encodeToByteArray(),
+ root.value.toByteArray() + chain.chainHash.value.toByteArray() + Pack.writeInt32BE(account.toInt())
+ )
+ val tweak = i.copyOfRange(0, 32)
+ require(Crypto.isPrivKeyValid(tweak)) { "the account step for account $account landed on an invalid scalar" }
+ return ByteVector32(tweak) to ByteVector32(i.copyOfRange(32, 64))
+ }
+
/**
* The address at `//` under [account].
*
@@ -197,19 +250,27 @@ object GroupWalletDerivation {
* a parity mistake in the cache and a wallet whose signatures do not verify.
*/
fun derive(account: Account, change: Long, index: Long): Derived =
- deriveBelow(account.extendedPublicKey, account.cache, change, index)
+ deriveBelow(
+ account.extendedPublicKey,
+ account.cache,
+ change,
+ index,
+ tree = GuardianDerivation.treeAt(account.guardians, account.chain, account.account, change, index),
+ )
/**
- * The tail on its own: BIP32 public derivation and the BIP341 key-path tweak,
- * from any account-level key and the cache that signs as it. Split out so the
- * tail can be tested against BIP86's published vectors, which start from a
- * seed's account key rather than from a threshold key.
+ * The tail on its own: BIP32 public derivation and the BIP341 tweak -- over
+ * [tree] when there is one, BIP86's key-path tweak otherwise -- from any
+ * account-level key and the cache that signs as it. Split out so the tail can
+ * be tested against BIP86's published vectors, which start from a seed's
+ * account key rather than from a threshold key.
*/
internal fun deriveBelow(
accountKey: DeterministicWallet.ExtendedPublicKey,
accountCache: TweakCache,
change: Long,
index: Long,
+ tree: ScriptTree? = null,
): Derived {
require(change == RECEIVE || change == CHANGE) { "change must be $RECEIVE or $CHANGE, not $change" }
require(index in 0L..MAX_INDEX) { "index $index is not an unhardened index" }
@@ -224,19 +285,20 @@ object GroupWalletDerivation {
val internalKey = childKey.publicKey.xOnly()
require(cache.tweakedPublicKey == internalKey) { "the cache does not reach the internal key at $change/$index" }
- cache = when (val tweaked = cache.tweak(internalKey.tweak(Crypto.TaprootTweak.KeyPathTweak), isXonly = true)) {
- is Either.Left -> throw IllegalArgumentException("Could not apply the key-path tweak at $change/$index", tweaked.value)
+ val taprootTweak = tree?.let { Crypto.TaprootTweak.ScriptPathTweak(it.hash()) } ?: Crypto.TaprootTweak.KeyPathTweak
+ cache = when (val tweaked = cache.tweak(internalKey.tweak(taprootTweak), isXonly = true)) {
+ is Either.Left -> throw IllegalArgumentException("Could not apply the taproot tweak at $change/$index", tweaked.value)
is Either.Right -> tweaked.value.first
}
- val outputKey = internalKey.outputKey(Crypto.TaprootTweak.KeyPathTweak).first
+ val outputKey = internalKey.outputKey(taprootTweak).first
require(cache.tweakedPublicKey == outputKey) { "the cache does not reach the output key at $change/$index" }
- return Derived(change = change, index = index, internalKey = internalKey, outputKey = outputKey, cache = cache)
+ return Derived(change = change, index = index, internalKey = internalKey, outputKey = outputKey, cache = cache, tree = tree)
}
/** BIP32's `I_L` for one unhardened step: the scalar CKDpub adds, which a FROST cache takes as a plain tweak. */
- private fun childTweak(parent: DeterministicWallet.ExtendedPublicKey, index: Long): ByteVector32 =
+ internal fun childTweak(parent: DeterministicWallet.ExtendedPublicKey, index: Long): ByteVector32 =
ByteVector32(
Crypto.hmac512(
parent.chaincode.toByteArray(),
@@ -244,7 +306,7 @@ object GroupWalletDerivation {
).copyOfRange(0, 32)
)
- private fun plainTweak(cache: TweakCache, tweak: ByteVector32, step: String): TweakCache =
+ internal fun plainTweak(cache: TweakCache, tweak: ByteVector32, step: String): TweakCache =
when (val tweaked = cache.tweak(tweak, isXonly = false)) {
is Either.Left -> throw IllegalArgumentException("Could not apply $step to the group's key", tweaked.value)
is Either.Right -> tweaked.value.first
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupWalletManager.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupWalletManager.kt
index 37c35462..c9a51fc5 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupWalletManager.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GroupWalletManager.kt
@@ -1,8 +1,11 @@
package com.machankura.bennu.compose.managers
+import com.machankura.bennu.compose.nostr.subgroup.WalletPolicyReading
import com.machankura.bennu.compose.database.BennuDatabase
import com.machankura.bennu.compose.nostr.wallet.GroupWallet
import com.machankura.bennu.compose.nostr.wallet.GroupWalletStatementEvent
+import com.machankura.bennu.compose.nostr.subgroup.SubgroupBirthCertificateEvent
+import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import fr.acinq.bitcoin.Chain
@@ -35,6 +38,40 @@ object GroupWalletManager {
): GroupWalletDerivation.Account? =
thresholdKeyFor(database, chatRoomId)?.let { GroupWalletDerivation.account(it, chain, account) }
+ /** A guarded account a room could open, and the certificate that granted its guardians, which the statement carries. */
+ data class GuardedOpening(
+ val account: GroupWalletDerivation.Account,
+ val certificate: Event,
+ )
+
+ /**
+ * The guarded account [chatRoomId] would open on [chain], or null for a room
+ * whose certificate grants it no guardian keys -- a room nobody's subgroup,
+ * or one certified before certificates carried them.
+ *
+ * Off the verified key state, the one place a certificate this device
+ * believes is kept. A member who holds no key state cannot open one; that
+ * member cannot sign, either.
+ */
+ suspend fun guardedAccountFor(
+ database: BennuDatabase,
+ chatRoomId: String,
+ chain: Chain,
+ account: Long = 0L,
+ ): GuardedOpening? {
+ val thresholdPublicKey = thresholdKeyFor(database, chatRoomId) ?: return null
+ val certificate = GroupKeyStateManager.keyStateFor(database, chatRoomId)
+ ?.takeIf { it.verifies() }
+ ?.birthCertificateJson
+ ?.let { Event.fromJsonOrNull(it) }
+ ?: return null
+ val guardians = SubgroupBirthCertificateEvent.parseGuardians(certificate.tags)
+ ?.takeIf { it.isNotEmpty() }
+ ?: return null
+
+ return GuardedOpening(GroupWalletDerivation.account(thresholdPublicKey, chain, account, guardians), certificate)
+ }
+
/**
* The wallet [chatRoomId] has opened on [chain] under [thresholdPublicKey], or
* null when the room signed no statement that key rederives.
@@ -54,6 +91,7 @@ object GroupWalletManager {
thresholdPublicKey = thresholdPublicKey,
chain = chain,
account = account,
+ policy = walletPolicyFor(database, chatRoomId),
)
/** The wallet [chatRoomId] has opened on [chain], or null when the group has not opened one. */
@@ -71,6 +109,17 @@ object GroupWalletManager {
thresholdPublicKey = thresholdPublicKey,
chain = chain,
account = account,
+ policy = walletPolicyFor(database, chatRoomId),
)
}
+
+ /**
+ * What [chatRoomId]'s parent decided about its wallet at its birth, or null
+ * for a room with no certificate -- `docs/subgroup-wallet-policy.md`. The
+ * same reading the picker and every parent signer make, through
+ * `SubgroupManager.walletPolicyOf`, so the wallet a device opens, offers and
+ * signs for cannot disagree with what the group was made as.
+ */
+ suspend fun walletPolicyFor(database: BennuDatabase, chatRoomId: String): WalletPolicyReading? =
+ SubgroupManager.walletPolicyOf(database, chatRoomId)
}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GuardianDerivation.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GuardianDerivation.kt
new file mode 100644
index 00000000..ab5f7ab7
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GuardianDerivation.kt
@@ -0,0 +1,314 @@
+package com.machankura.bennu.compose.managers
+
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray
+import fr.acinq.bitcoin.ByteVector
+import fr.acinq.bitcoin.ByteVector32
+import fr.acinq.bitcoin.Chain
+import fr.acinq.bitcoin.Crypto
+import fr.acinq.bitcoin.DeterministicWallet
+import fr.acinq.bitcoin.KeyPath
+import fr.acinq.bitcoin.OP_CHECKSEQUENCEVERIFY
+import fr.acinq.bitcoin.OP_CHECKSIGVERIFY
+import fr.acinq.bitcoin.OP_PUSHDATA
+import fr.acinq.bitcoin.PrivateKey
+import fr.acinq.bitcoin.PublicKey
+import fr.acinq.bitcoin.Script
+import fr.acinq.bitcoin.ScriptElt
+import fr.acinq.bitcoin.ScriptEltMapping
+import fr.acinq.bitcoin.ScriptTree
+import fr.acinq.bitcoin.XonlyPublicKey
+import fr.acinq.bitcoin.crypto.Pack
+import fr.acinq.bitcoin.crypto.frost.TweakCache
+
+/**
+ * The keys an ancestor group holds in a subgroup's wallet, and the leaves they
+ * sit in.
+ *
+ * Every group has one guardian root, a tagged HMAC away from its threshold key,
+ * which it never hands out. What a parent writes into a child's birth
+ * certificate is that root one public BIP32 step further, at an index taken
+ * from the child's room id -- and, behind it, every key the parent's own
+ * ancestors gave the parent, each one step further at the same index:
+ *
+ * ```
+ * I = HMAC-SHA512("bennu/group-wallet/guardian/v1", serP(K_A))
+ * R_A = K_A + I[0:32]·G, chain code I[32:64] A's guardian root
+ * i(C) = taggedHash("bennu/group-wallet/guardian/child/v1", C)[0:4] & 0x7fffffff
+ * grant(C) = [R_A/i(C)] ++ [g/i(C) for g in grant(A)] nearest first
+ * L = xonly(g / network / account / change / index) a leaf key in one address
+ * ```
+ *
+ * See `docs/group-wallet-guardians.md` for why each step is what it is. In
+ * short: a fresh key per child is what lets the parent *agree* to guard it, a
+ * root nobody publishes is what keeps a guardian spend unlinkable to a Marmot
+ * room, and re-deriving every inherited key per child is what keeps a parent's
+ * wallet and its child's from sharing a leaf.
+ *
+ * ### The same rule as the wallet's
+ *
+ * Every step is a public tweak of the threshold key, so a leaked leaf private
+ * key recovers the group's threshold key. Nothing reconstructs one: a leaf is
+ * signed for by a FROST session over [signingCache].
+ */
+object GuardianDerivation {
+ /**
+ * The fewest blocks a coin can sit confirmed before an ancestor can take it:
+ * about an hour, so the child's own spends always go first -- a guardian
+ * cannot race the child for a payment that has only just arrived.
+ * `docs/guardian-delay.md`.
+ */
+ const val MIN_DELAY: Long = 6L
+
+ /**
+ * The most: BIP68's block-based relative lock is the low 16 bits of
+ * `nSequence`, so 65,535 blocks, about 15 months. Staying within it also
+ * keeps bit 22 clear, so the lock always counts blocks, and keeps every
+ * guardian input far below `GroupSpend.MAX_SEQUENCE`, so a guardian spend
+ * can still be bumped.
+ */
+ const val MAX_DELAY: Long = 0xFFFFL
+
+ /** Every delay a leaf may carry. A guardian tag outside it does not read. */
+ val DELAY_RANGE: LongRange = MIN_DELAY..MAX_DELAY
+
+ /**
+ * The delay a parent is offered first for its own leaf, and the one every
+ * certificate carried before parents chose: two hours. Each guardian's own
+ * delay is written into its tag, and each ancestor's travels down the tree
+ * unchanged -- [Guardian.grantedTo] copies it -- so this is a default, not
+ * the delay. `docs/guardian-delay.md`.
+ */
+ const val DEFAULT_DELAY: Long = 12L
+
+ /**
+ * The key of the guardian root's HMAC. An input to every guardian key, so it
+ * is frozen the moment a certificate carries one: a rename moves every leaf.
+ */
+ private const val ROOT_TAG = "bennu/group-wallet/guardian/v1"
+
+ /** The tag of the hash a child's index is taken from. Frozen for the same reason. */
+ private const val CHILD_TAG = "bennu/group-wallet/guardian/child/v1"
+
+ /**
+ * One ancestor's guardian key as granted to one group: whose it is, and the
+ * extended public key that group's addresses derive that ancestor's leaves
+ * from.
+ *
+ * Held as the key and the chain code rather than as an
+ * [DeterministicWallet.ExtendedPublicKey], whose depth, parent fingerprint and
+ * path would make two grants of the same key compare unequal depending on how
+ * each was reached. Only the 65 bytes take part in a derivation.
+ */
+ data class Guardian(
+ /** The ancestor's room id, which its leaf is named by. */
+ val chatRoomId: String,
+ val publicKey: PublicKey,
+ val chainCode: ByteVector32,
+ val delay: Long = DEFAULT_DELAY,
+ ) {
+ /** As a depth-0 extended key, the form every derivation below starts from. */
+ val extendedPublicKey: DeterministicWallet.ExtendedPublicKey
+ get() = DeterministicWallet.ExtendedPublicKey(
+ publickeybytes = publicKey.value,
+ chaincode = chainCode,
+ depth = 0,
+ path = KeyPath.empty,
+ parent = 0L,
+ )
+
+ /** `xpub` on mainnet and `tpub` on every test network, as the wallet's own xpub is. */
+ fun encoded(chain: Chain): String =
+ extendedPublicKey.encode(if (chain.isMainnet()) DeterministicWallet.xpub else DeterministicWallet.tpub)
+
+ /** The same ancestor, one public step further, for [childChatRoomId] -- and at the same delay. */
+ fun grantedTo(childChatRoomId: String): Guardian {
+ val child = extendedPublicKey.derivePublicKey(childIndex(childChatRoomId))
+ return copy(publicKey = child.publicKey, chainCode = child.chaincode)
+ }
+ }
+
+ /** A group's guardian root, and the cache that signs as it. */
+ class Root internal constructor(
+ val publicKey: PublicKey,
+ val chainCode: ByteVector32,
+ internal val cache: TweakCache,
+ ) {
+ val extendedPublicKey: DeterministicWallet.ExtendedPublicKey
+ get() = DeterministicWallet.ExtendedPublicKey(publicKey.value, chainCode, 0, KeyPath.empty, 0L)
+ }
+
+ /** One guardian's leaf in one address, and -- on the guardian's side -- the cache that signs as it. */
+ data class Signing(
+ val leafKey: XonlyPublicKey,
+ val cache: TweakCache,
+ )
+
+ /**
+ * The guardian root of the group holding [thresholdPublicKey].
+ *
+ * @throws IllegalArgumentException if the key is not a point, or the HMAC
+ * lands on an invalid scalar -- around 2^-127, and BIP32 throws at the same place.
+ */
+ fun root(thresholdPublicKey: HexKey): Root {
+ val threshold = PublicKey(ByteVector(thresholdPublicKey.hexToByteArray()))
+ require(threshold.isValid()) { "the threshold key is not a valid point" }
+
+ val i = Crypto.hmac512(ROOT_TAG.encodeToByteArray(), threshold.value.toByteArray())
+ val tweak = i.copyOfRange(0, 32)
+ require(Crypto.isPrivKeyValid(tweak)) { "the guardian root landed on an invalid scalar" }
+
+ val rootKey = threshold + PrivateKey(tweak).publicKey()
+ val cache = GroupWalletDerivation.plainTweak(TweakCache.create(threshold), ByteVector32(tweak), "the guardian root")
+ require(cache.tweakedPublicKey == rootKey.xOnly()) { "the guardian root's cache does not reach its key" }
+
+ return Root(publicKey = rootKey, chainCode = ByteVector32(i.copyOfRange(32, 64)), cache = cache)
+ }
+
+ /**
+ * The unhardened index a child's keys are derived at: the first four bytes
+ * of a tagged hash of its room id, top bit cleared.
+ */
+ fun childIndex(childChatRoomId: String): Long {
+ val roomId = childChatRoomId.lowercase().hexToByteArray()
+ require(roomId.size == 32) { "a room id is 32 bytes, not ${roomId.size}" }
+ return Pack.int32BE(Crypto.taggedHash(roomId, CHILD_TAG).toByteArray(), 0).toLong() and GroupWalletDerivation.MAX_INDEX
+ }
+
+ /**
+ * The network's index under a guardian key. Not BIP44's coin type: the
+ * networks this app knows, numbered once, so a guardian key granted for no
+ * network in particular gives each one unrelated leaves.
+ */
+ fun networkIndex(chain: Chain): Long = when (chain) {
+ Chain.Mainnet -> 0L
+ Chain.Testnet3 -> 1L
+ Chain.Testnet4 -> 2L
+ Chain.Signet -> 3L
+ Chain.Regtest -> 4L
+ }
+
+ /**
+ * What the group holding [thresholdPublicKey], whose room is [ownChatRoomId],
+ * writes into [childChatRoomId]'s certificate: its own root one step further,
+ * then each of [inherited] -- the keys its own certificate carries, nearest
+ * first -- one step further, in the same order.
+ *
+ * The same function a signer's device runs to check a proposed certificate:
+ * a certificate whose guardians are not exactly this list is not one the
+ * group agreed to.
+ *
+ * [delay] is the parent's own leaf's, which it chooses for this child. An
+ * inherited key keeps the delay its own ancestor chose: a group cannot
+ * shorten or lengthen another group's terms in its child's wallet.
+ */
+ fun grant(
+ thresholdPublicKey: HexKey,
+ ownChatRoomId: String,
+ inherited: List,
+ childChatRoomId: String,
+ delay: Long = DEFAULT_DELAY,
+ ): List {
+ require(delay in DELAY_RANGE) { "a guardian's delay is $MIN_DELAY to $MAX_DELAY blocks, not $delay" }
+ val own = root(thresholdPublicKey).extendedPublicKey.derivePublicKey(childIndex(childChatRoomId))
+ return listOf(Guardian(ownChatRoomId, own.publicKey, own.chaincode, delay)) +
+ inherited.map { it.grantedTo(childChatRoomId) }
+ }
+
+ /** [guardian]'s key one level above the leaves of [account]'s `change` branch. */
+ private fun branchKey(guardian: Guardian, chain: Chain, account: Long, change: Long): DeterministicWallet.ExtendedPublicKey =
+ guardian.extendedPublicKey.derivePublicKey(listOf(networkIndex(chain), account, change))
+
+ /** [guardian]'s leaf key in the address at `change/index` of [account] on [chain]. */
+ fun leafKey(guardian: Guardian, chain: Chain, account: Long, change: Long, index: Long): XonlyPublicKey =
+ branchKey(guardian, chain, account, change).derivePublicKey(index).publicKey.xOnly()
+
+ /**
+ * ` OP_CHECKSIGVERIFY OP_CHECKSEQUENCEVERIFY` -- miniscript's
+ * `and_v(v:pk(key),older(delay))`. A delay of 1-16 is the single opcode for
+ * it, as miniscript writes it; anything else is a minimal number push.
+ */
+ fun leafScript(key: XonlyPublicKey, delay: Long): List {
+ require(delay in DELAY_RANGE) { "a guardian's delay is $MIN_DELAY to $MAX_DELAY blocks, not $delay" }
+ val lock = if (delay <= 16) ScriptEltMapping.code2elt.getValue(0x50 + delay.toInt())
+ else OP_PUSHDATA(Script.encodeNumber(delay))
+ return listOf(OP_PUSHDATA(key), OP_CHECKSIGVERIFY, lock, OP_CHECKSEQUENCEVERIFY)
+ }
+
+ /** One leaf per guardian in the address at `change/index`, nearest first. */
+ fun leaves(guardians: List, chain: Chain, account: Long, change: Long, index: Long): List =
+ guardians.map { ScriptTree.Leaf(leafScript(leafKey(it, chain, account, change, index), it.delay)) }
+
+ /**
+ * The leaves as a caterpillar, nearest first: the first leaf at depth one,
+ * the rest one level further down each. Every guardian can act at the same
+ * moment, so the order decides only whose control block is shortest -- and
+ * the parent, who knows the child best, gets the cheapest spend.
+ */
+ fun tree(leaves: List): ScriptTree {
+ require(leaves.isNotEmpty()) { "a tree needs a leaf" }
+ return leaves.dropLast(1).foldRight(leaves.last() as ScriptTree) { leaf, rest -> ScriptTree.Branch(leaf, rest) }
+ }
+
+ /** The tree in the address at `change/index`, or null for an unguarded one. */
+ fun treeAt(guardians: List, chain: Chain, account: Long, change: Long, index: Long): ScriptTree? =
+ guardians.takeIf { it.isNotEmpty() }?.let { tree(leaves(it, chain, account, change, index)) }
+
+ /**
+ * The tree half of a `tr()` descriptor over a whole branch: `{a,{b,c}}`, the
+ * same caterpillar [tree] builds, each leaf ranged over the branch's indices.
+ */
+ fun descriptorTree(guardians: List, chain: Chain, account: Long, change: Long): String {
+ require(guardians.isNotEmpty()) { "a tree needs a leaf" }
+ val leaves = guardians.map { guardian ->
+ val path = "${networkIndex(chain)}/$account/$change/*"
+ "and_v(v:pk(${guardian.encoded(chain)}/$path),older(${guardian.delay}))"
+ }
+ return leaves.dropLast(1).foldRight(leaves.last()) { leaf, rest -> "{$leaf,$rest}" }
+ }
+
+ /**
+ * The room ids an ancestor walks from its own root down to [childChatRoomId],
+ * through the line of descent [guardians] -- a certificate's guardian list,
+ * nearest first -- names. Null when [ancestorChatRoomId] is not among them.
+ *
+ * For `guardians = [A1, A2, A3]` and `ancestor = A3`, that is `[A2, A1, C]`:
+ * the generations below A3, its own child first.
+ */
+ fun lineage(guardians: List, childChatRoomId: String, ancestorChatRoomId: String): List? {
+ val position = guardians.indexOfFirst { it.chatRoomId.equals(ancestorChatRoomId, ignoreCase = true) }
+ if (position < 0) return null
+ return guardians.take(position).map { it.chatRoomId }.reversed() + childChatRoomId
+ }
+
+ /**
+ * The cache the group holding [thresholdPublicKey] signs a leaf with: its
+ * guardian root, then one plain step per generation down [lineage], then
+ * the network, the account and the address. Every step is a plain tweak, so
+ * the cache tracks exactly the point the descendant derives from its grant.
+ *
+ * No TapTweak follows: a script-path signature is by the leaf key itself.
+ */
+ fun signingCache(
+ thresholdPublicKey: HexKey,
+ lineage: List,
+ chain: Chain,
+ account: Long,
+ change: Long,
+ index: Long,
+ ): Signing {
+ val root = root(thresholdPublicKey)
+ val path = lineage.map(::childIndex) + listOf(networkIndex(chain), account, change, index)
+
+ var key = root.extendedPublicKey
+ var cache = root.cache
+ path.forEach { step ->
+ cache = GroupWalletDerivation.plainTweak(cache, GroupWalletDerivation.childTweak(key, step), "guardian step $step")
+ key = key.derivePublicKey(step)
+ }
+
+ val leafKey = key.publicKey.xOnly()
+ require(cache.tweakedPublicKey == leafKey) { "the guardian cache does not reach its leaf key" }
+ return Signing(leafKey = leafKey, cache = cache)
+ }
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GuardianManager.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GuardianManager.kt
new file mode 100644
index 00000000..812b10b3
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/GuardianManager.kt
@@ -0,0 +1,746 @@
+package com.machankura.bennu.compose.managers
+
+import com.machankura.bennu.compose.nostr.subgroup.allows
+import co.touchlab.kermit.Logger
+import com.machankura.bennu.compose.database.BennuDatabase
+import com.machankura.bennu.compose.database.model.ChatMessage
+import com.machankura.bennu.compose.database.model.MarmotInnerEvent
+import com.machankura.bennu.compose.database.model.intermdiate.LocalChatRoom
+import com.machankura.bennu.compose.nostr.frost.GroupKeyStateEvent
+import com.machankura.bennu.compose.nostr.subgroup.SubgroupBirthCertificateEvent
+import com.machankura.bennu.compose.nostr.wallet.GroupWalletStatementEvent
+import com.machankura.bennu.compose.nostr.wallet.GuardedWalletNoticeEvent
+import com.machankura.bennu.compose.nostr.wallet.MemberWalletCertificateEvent
+import com.machankura.bennu.compose.wallet.GroupSpend
+import com.machankura.bennu.compose.wallet.GroupWalletRollout
+import com.vitorpamplona.quartz.nip01Core.core.Event
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
+import fr.acinq.bitcoin.Chain
+import fr.acinq.bitcoin.OutPoint
+import fr.acinq.bitcoin.Satoshi
+import fr.acinq.bitcoin.Transaction
+import fr.acinq.bitcoin.TxId
+import fr.acinq.bitcoin.TxOut
+import fr.acinq.lightning.utils.sum
+import kotlin.time.Clock
+import kotlin.time.Instant
+
+/**
+ * What an ancestor group knows of the guarded wallets beneath it, and how it
+ * comes to know.
+ *
+ * A descendant opens a guarded wallet in its own room. Its ancestors are not in
+ * that room, so a member who sits in both carries the signed statement across
+ * as a [GuardedWalletNoticeEvent]; every device in the ancestor's room checks it
+ * for itself, and from then on watches the wallet and can propose spending from
+ * it through its own leaf. See `docs/group-wallet-guardians.md`, "How an
+ * ancestor finds the coins".
+ *
+ * A notice forwarded into a middle group can be forwarded again from there, so
+ * a root needs a member in common with each generation, not with the grandchild.
+ */
+object GuardianManager {
+ private const val TAG = "GuardianManager"
+
+ private val logger = Logger.withTag(TAG)
+
+ /**
+ * Whose guarded wallet it is: a subgroup's, under its quorum's key, or one
+ * member's, under a key only they hold -- `docs/member-guarded-wallets.md`.
+ * Either way [id] is what the line of descent ends in, so every guardian
+ * signs for its leaf the same way.
+ */
+ sealed interface GuardedSubject {
+ /** A room id, or a member wallet's `W`. */
+ val id: String
+
+ data class Subgroup(override val id: String, val name: String?) : GuardedSubject
+
+ data class Member(
+ override val id: String,
+ val ownerPublicKey: HexKey,
+ val label: String?,
+ /** The member's profile name on this device, where one is known; filled where a database is to hand. */
+ val ownerName: String? = null,
+ /**
+ * The group that directly guards it, by its founding name where this
+ * device can check a birth certificate for it, else its room name here;
+ * null when neither is known. Filled where a database is to hand.
+ * `docs/member-wallet-guarding-group.md`, D2.
+ */
+ val guardianName: String? = null,
+ /** The holding group's own child it sits under, named the same way; null when the holder guards it directly. */
+ val branchName: String? = null,
+ ) : GuardedSubject
+ }
+
+ /** A descendant's guarded wallet, as one of its ancestors holds it. */
+ data class GuardedWallet(
+ /** The ancestor holding it: the room it was told to. */
+ val ancestorChatRoomId: String,
+ /** [subject]'s id: the descendant's room, or a member wallet's `W`. */
+ val descendantChatRoomId: String,
+ /**
+ * What the ancestor believes it on, whole: a subgroup's signed statement,
+ * or the member wallet certificate the guarding group signed.
+ */
+ val statement: Event,
+ /** The account the statement opens, rederived from the descendant's key. */
+ val account: GroupWalletDerivation.Account,
+ /** A subgroup's birth certificate, carried in the statement -- or, for a member, the certificate itself. */
+ val certificate: Event,
+ /** The rooms the ancestor walks from its own child down to the descendant -- `GuardianDerivation.lineage`. */
+ val lineage: List,
+ val subject: GuardedSubject = GuardedSubject.Subgroup(descendantChatRoomId, SubgroupBirthCertificateEvent.parseName(certificate.tags)),
+ /**
+ * For a member's wallet: the birth certificate of the group that directly
+ * guards it, checked, where this device holds one -- what a notice
+ * carries upward so the groups above can name that group.
+ * `docs/member-wallet-guarding-group.md`, D4.
+ */
+ val guardianCertificate: Event? = null,
+ ) {
+ /** What the descendant's parent certified it as, for a subgroup. The founding name: a rename does not reach it. */
+ val name: String? get() = (subject as? GuardedSubject.Subgroup)?.name
+
+ val chain: Chain get() = account.chain
+
+ val openedAt: Instant get() = Instant.fromEpochSeconds(statement.createdAt)
+
+ /** Where the ancestor sits among the guardians: whose leaf, in every address, is its. */
+ val position: Int get() = account.guardians.indexOfFirst { it.chatRoomId.equals(ancestorChatRoomId, ignoreCase = true) }
+
+ /**
+ * How long a coin here waits before this ancestor can take it: the delay
+ * on its own leaf, which the group that granted it chose and which two of
+ * an ancestor's descendants can have set differently.
+ * `docs/guardian-delay.md`.
+ */
+ val delay: Long get() = account.guardians[position].delay
+
+ /**
+ * The group that directly guards it: the nearest guardian, which for a
+ * member's wallet is the group that signed its certificate --
+ * `MemberWalletRequestEvent.verified` refuses a request whose nearest
+ * guardian is not the group it asks. `docs/member-wallet-guarding-group.md`, D1.
+ */
+ val directGuardianChatRoomId: String get() = account.guardians.first().chatRoomId
+
+ /** True when the ancestor holding it is the group that directly guards it. */
+ val isGuardedHere: Boolean get() = position == 0
+
+ /**
+ * The ancestor's own child the wallet sits under -- the branch of its tree
+ * -- or null when the ancestor guards it directly. The ancestor signed
+ * that child's birth certificate, so it can always name it.
+ */
+ val branchChatRoomId: String? get() = lineage.takeIf { position > 0 }?.first()
+
+ /** The ancestor as the spender of a spend from this wallet, signing as [thresholdPublicKey] -- null to only build one. */
+ fun spender(thresholdPublicKey: HexKey? = null): GroupSpend.Spender.Guardian =
+ GroupSpend.Spender.Guardian(position = position, lineage = lineage, thresholdPublicKey = thresholdPublicKey, name = displayName, label = label)
+
+ /** A member's label for it, where they gave one; null for a subgroup's. */
+ val label: String? get() = (subject as? GuardedSubject.Member)?.label
+
+ /** How a spend from it names it: a subgroup's founding name, or `@` and a member's. */
+ val displayName: String?
+ get() = when (val subject = subject) {
+ is GuardedSubject.Subgroup -> subject.name
+ is GuardedSubject.Member -> "@" + (subject.ownerName ?: subject.ownerPublicKey.take(8))
+ }
+ }
+
+ /**
+ * A guarded wallet statement believed on its own merits -- everything
+ * [verify] checks except the walk down from an ancestor's own guardian root,
+ * which only a device holding that ancestor's key can make. What a forwarder
+ * checks before passing a statement on (`docs/guarded-wallet-forwarding.md`,
+ * D2): a notice it would copy into every group above should be one it
+ * believes itself.
+ */
+ data class Believable(
+ val statement: Event,
+ /** The descendant's room id, or a member wallet's `W`: what the line of descent ends in. */
+ val descendantId: String,
+ /** The account the statement opens, rederived from the descendant's key. */
+ val account: GroupWalletDerivation.Account,
+ /** A subgroup's birth certificate, carried in the statement -- or, for a member, the certificate itself. */
+ val certificate: Event,
+ val subject: GuardedSubject,
+ ) {
+ /** Every guardian, nearest first: the groups that can be told. */
+ val guardians: List get() = account.guardians
+
+ val chain: Chain get() = account.chain
+ }
+
+ /**
+ * [statement] believed, or null:
+ *
+ * 1. it is a wallet statement, and the room it is authored by signed it;
+ * 2. it is guarded, and carries the certificate its guardians came from;
+ * 3. the certificate's key makes that room, and the statement's xpub, tree
+ * and descriptors all rederive from it -- `Reading.verifiedAgainst`, which
+ * also checks the certificate certifies the room and grants exactly those
+ * guardians.
+ *
+ * Or a member wallet certificate the guarding group signed over the member's
+ * own request -- `MemberWalletCertificateEvent.verify`.
+ */
+ fun believable(statement: Event): Believable? = runCatching {
+ if (statement.kind == MemberWalletCertificateEvent.KIND) {
+ val verified = MemberWalletCertificateEvent.verify(statement, statement.pubKey) ?: return null
+ return Believable(
+ statement = statement,
+ descendantId = verified.walletId,
+ account = verified.account,
+ certificate = statement,
+ subject = GuardedSubject.Member(verified.walletId, verified.memberPublicKey, verified.label),
+ )
+ }
+ if (statement.kind != GroupWalletStatementEvent.KIND) return null
+ val descendantChatRoomId = statement.pubKey
+ if (!GroupKeyStateEvent.isSignedByRoom(statement, descendantChatRoomId)) return null
+
+ val reading = GroupWalletStatementEvent.read(statement.tags, statement.content) ?: return null
+ if (reading.guardians.isEmpty()) return null
+ val certificate = reading.certificate ?: return null
+ // A guarded wallet the certificate's own policy does not allow -- one it
+ // contradicts, or decided unguarded -- is not one an honest descendant
+ // opens, so it is not one to list. docs/subgroup-wallet-policy.md.
+ if (!SubgroupBirthCertificateEvent.parseWalletPolicy(certificate.tags).let { it != null && it.allows(guarded = true) }) return null
+
+ val descendantKey = SubgroupBirthCertificateEvent.parseThresholdPublicKey(certificate.tags) ?: return null
+ if (!SharedKeyDerivation.marmotGroupId(descendantKey).equals(descendantChatRoomId, ignoreCase = true)) return null
+ val account = reading.verifiedAgainst(descendantKey) ?: return null
+
+ Believable(
+ statement = statement,
+ descendantId = descendantChatRoomId,
+ account = account,
+ certificate = certificate,
+ subject = GuardedSubject.Subgroup(descendantChatRoomId, SubgroupBirthCertificateEvent.parseName(certificate.tags)),
+ )
+ }.getOrNull()
+
+ /**
+ * [statement] as a guarded wallet [ancestorChatRoomId] guards, or null when
+ * it is not one -- believed on its own merits, never on the word of whoever
+ * forwarded it: [believable], and
+ *
+ * 4. the ancestor is among the guardians, and the key the statement names
+ * for it is the key [ancestorThresholdPublicKey]'s guardian root reaches
+ * down the line of descent the guardians name. A key it does not reach is
+ * a leaf this group cannot sign, whatever the statement calls it. The
+ * line ends in the descendant's room, or in a member wallet's id.
+ */
+ fun verify(statement: Event, ancestorChatRoomId: String, ancestorThresholdPublicKey: HexKey): GuardedWallet? = runCatching {
+ val believed = believable(statement) ?: return null
+ val account = believed.account
+
+ val lineage = GuardianDerivation.lineage(account.guardians, believed.descendantId, ancestorChatRoomId) ?: return null
+ val named = account.guardians.first { it.chatRoomId.equals(ancestorChatRoomId, ignoreCase = true) }
+ val walked = GuardianDerivation.root(ancestorThresholdPublicKey).extendedPublicKey
+ .derivePublicKey(lineage.map(GuardianDerivation::childIndex))
+ if (walked.publicKey != named.publicKey || walked.chaincode != named.chainCode) return null
+
+ GuardedWallet(
+ ancestorChatRoomId = ancestorChatRoomId,
+ descendantChatRoomId = believed.descendantId,
+ statement = statement,
+ account = account,
+ certificate = believed.certificate,
+ lineage = lineage,
+ subject = believed.subject,
+ )
+ }.getOrNull()
+
+ /**
+ * [wallet] with its member's profile name, and the names of the group that
+ * directly guards it and of the branch it sits under, where this device knows
+ * them. [known] are birth certificates that came to hand some other way --
+ * those the statements told to the holding room carry.
+ */
+ private suspend fun named(database: BennuDatabase, wallet: GuardedWallet, known: List = emptyList()): GuardedWallet {
+ val member = wallet.subject as? GuardedSubject.Member ?: return wallet
+ val name = database.profileDao().getProfileByPublicKey(member.ownerPublicKey)?.humanReadableNameOrPubkey()
+ val guardians = wallet.account.guardians
+
+ suspend fun certificateOf(position: Int): Event? =
+ guardians.getOrNull(position + 1)?.let { parent -> foundingCertificateOf(database, guardians[position].chatRoomId, parent.chatRoomId, known) }
+
+ // Founding name first, then the room's name here: the order D2 of
+ // docs/member-wallet-guarding-group.md gives, so the card agrees with a
+ // subgroup row in the same list naming the same room.
+ suspend fun nameOf(position: Int, certificate: Event?): String? =
+ certificate?.let { SubgroupBirthCertificateEvent.parseName(it.tags) }
+ ?: database.chatRoomDao().findChatRoomById(guardians[position].chatRoomId)?.chatRoom?.subject?.takeIf { it.isNotBlank() }
+
+ val guardianCertificate = certificateOf(0)
+ return wallet.copy(
+ subject = member.copy(
+ ownerName = name,
+ guardianName = nameOf(0, guardianCertificate),
+ branchName = wallet.position.takeIf { it > 0 }?.let { nameOf(it - 1, certificateOf(it - 1)) },
+ ),
+ guardianCertificate = guardianCertificate,
+ )
+ }
+
+ /**
+ * What [roomId] was called at its founding, read off a birth certificate
+ * [parentRoomId] signed for it -- or null when this device holds none it can
+ * check. Each candidate is checked with `SubgroupBirthCertificateEvent.certifies`,
+ * whoever handed it over: [carried] first, then the certificates the parent
+ * signed (every device in the parent holds them), then the one in [roomId]'s
+ * own key state (every device in the room). `docs/member-wallet-guarding-group.md`, D3.
+ */
+ suspend fun foundingNameOf(
+ database: BennuDatabase,
+ roomId: String,
+ parentRoomId: String,
+ carried: List = emptyList(),
+ ): String? = foundingCertificateOf(database, roomId, parentRoomId, carried)?.let { SubgroupBirthCertificateEvent.parseName(it.tags) }
+
+ /** The birth certificate [foundingNameOf] reads the name off, checked, or null. */
+ suspend fun foundingCertificateOf(
+ database: BennuDatabase,
+ roomId: String,
+ parentRoomId: String,
+ carried: List = emptyList(),
+ ): Event? {
+ fun List.certifying(): Event? = firstOrNull { SubgroupBirthCertificateEvent.certifies(it, roomId, parentRoomId) }
+
+ carried.certifying()?.let { return it }
+ database.groupSignedEventDao()
+ .getByChatRoomIdAndKind(parentRoomId, SubgroupBirthCertificateEvent.KIND)
+ .map { it.toEvent() }
+ .certifying()?.let { return it }
+ return listOfNotNull(
+ database.groupKeyStateDao().getByChatRoomId(roomId)?.birthCertificateJson?.let { Event.fromJsonOrNull(it) }
+ ).certifying()
+ }
+
+ /**
+ * The guardian rooms a statement is told to from [chatRoomId]: those after it
+ * in [guardians], nearest first -- upward only
+ * (`docs/guarded-wallet-forwarding.md`, D3). A room the list does not name is
+ * the wallet's own, a subgroup's, and is told to every guardian.
+ *
+ * Every guardian *except* the room, which is what the button used to take,
+ * reaches down as well as up: from a root holding a grandchild's statement it
+ * would tell the middle group, which told the root.
+ */
+ fun upwardOf(guardians: List, chatRoomId: String): List {
+ val position = guardians.indexOfFirst { it.chatRoomId.equals(chatRoomId, ignoreCase = true) }
+ return guardians.drop(position + 1).map { it.chatRoomId }
+ }
+
+ /**
+ * Of [candidates] -- the members of both a room and a group above it, as this
+ * device's participant lists have them -- the one who sends a notice the
+ * moment a wallet arrives: the lowest key. Everybody else waits for the
+ * catch-up, by when the elected device's notice has usually arrived
+ * (`docs/guarded-wallet-forwarding.md`, D4). Null when there are none.
+ */
+ fun electedSender(candidates: Set): HexKey? = candidates.map { it.lowercase() }.minOrNull()
+
+ /**
+ * Every guarded wallet [ancestorChatRoomId] has been told about and can sign
+ * for, one per descendant account on each network.
+ *
+ * Read off the notices the room's inbound path filed, checked again each
+ * time. Where two statements describe one account, the rules
+ * `GroupWallet.newestAmong` applies to the descendant's own copy apply here:
+ * the earliest decides the guardians and a later one naming others is
+ * ignored, so a forwarder cannot move the addresses an ancestor watches.
+ */
+ suspend fun guardedWalletsOf(database: BennuDatabase, ancestorChatRoomId: String): List {
+ val thresholdPublicKey = GroupWalletManager.thresholdKeyFor(database, ancestorChatRoomId) ?: return emptyList()
+ val order = compareBy({ it.openedAt }, { it.statement.id })
+
+ // What it was told, and -- for its own members' wallets -- what it signed:
+ // the group holds a member wallet certificate it signed, and needs no
+ // notice to learn of it.
+ val notices = database.marmotInnerEventDao()
+ .getByChatRoomAndKinds(ancestorChatRoomId, listOf(GuardedWalletNoticeEvent.KIND))
+ val told = notices.mapNotNull { row -> Event.fromJsonOrNull(row.content) }
+ val signed = database.groupSignedEventDao()
+ .getByChatRoomIdAndKind(ancestorChatRoomId, MemberWalletCertificateEvent.KIND)
+ .map { it.toEvent() }
+
+ // Birth certificates the room was handed: the one a subgroup's statement
+ // carries, and the guardian's a member wallet's notice carries. Pooled,
+ // since each is checked against the room and parent it is used for, and
+ // one that certifies neither is never used.
+ val known = told.filter { it.kind == GroupWalletStatementEvent.KIND }
+ .mapNotNull { GroupWalletStatementEvent.read(it.tags, it.content)?.certificate } +
+ notices.mapNotNull { GuardedWalletNoticeEvent.certificateIn(it.tags) }
+
+ return (told + signed)
+ .mapNotNull { verify(it, ancestorChatRoomId, thresholdPublicKey) }
+ .map { named(database, it, known) }
+ .groupBy { Triple(it.descendantChatRoomId, it.chain, it.account.account) }
+ .mapNotNull { (_, statements) ->
+ val first = statements.minWithOrNull(order) ?: return@mapNotNull null
+ statements.filter { it.account.guardians == first.account.guardians }.maxWithOrNull(order)
+ }
+ .sortedBy { it.name ?: it.descendantChatRoomId }
+ }
+
+ /** The guarded wallet [ancestorChatRoomId] holds for [descendantChatRoomId] on [chain] at [account], or null. */
+ suspend fun guardedWalletFor(
+ database: BennuDatabase,
+ ancestorChatRoomId: String,
+ descendantChatRoomId: String,
+ chain: Chain,
+ account: Long,
+ ): GuardedWallet? = guardedWalletsOf(database, ancestorChatRoomId).firstOrNull {
+ it.descendantChatRoomId.equals(descendantChatRoomId, ignoreCase = true) && it.chain == chain && it.account.account == account
+ }
+
+ /** A guarded statement this device can carry upward, and the rooms it can carry it into. */
+ data class Shareable(
+ val statement: Event,
+ /** What the statement's room was certified as, for the screen. Null for a member's wallet. */
+ val name: String?,
+ val rooms: List,
+ /** For a member's wallet: the member, and their profile name where this device knows one. */
+ val ownerPublicKey: HexKey? = null,
+ val ownerName: String? = null,
+ /** For a member's wallet: its guardian's birth certificate, carried on the notice -- `GuardedWalletNoticeEvent`. */
+ val certificate: Event? = null,
+ )
+
+ /**
+ * The guarded statements this device can tell to groups above [chatRoomId]:
+ * the room's own guarded wallet, and every one the room was itself told
+ * about -- passed on a generation further. Each with the guardian rooms this
+ * device is a member of and has not told yet.
+ */
+ suspend fun shareableFrom(database: BennuDatabase, chatRoomId: String, chain: Chain): List {
+ val own = GroupWalletManager.walletFor(database, chatRoomId, chain)
+ ?.takeIf { it.account.isGuarded }
+ ?.let { wallet ->
+ val statement = wallet.signedEvent.toEvent()
+ val certificate = GroupWalletStatementEvent.read(statement.tags, statement.content)?.certificate
+ statement to (certificate?.let { SubgroupBirthCertificateEvent.parseName(it.tags) })
+ }
+ // Everything it guards or was told of -- its own members' wallets among
+ // them, since it holds those certificates itself -- passed on a
+ // generation further.
+ val passedOn = guardedWalletsOf(database, chatRoomId)
+ .filter { it.chain == chain }
+
+ val candidates = listOfNotNull(own?.let { (statement, name) -> Shareable(statement, name, emptyList()) }) +
+ passedOn.map { wallet ->
+ val member = wallet.subject as? GuardedSubject.Member
+ Shareable(wallet.statement, wallet.name, emptyList(), member?.ownerPublicKey, member?.ownerName, wallet.guardianCertificate)
+ }
+
+ return candidates.mapNotNull { candidate ->
+ val rooms = targetsFor(database, candidate.statement, fromChatRoomId = chatRoomId, withCertificate = candidate.certificate != null)
+ rooms.takeIf { it.isNotEmpty() }?.let { candidate.copy(rooms = it) }
+ }
+ }
+
+ /**
+ * The groups above [fromChatRoomId] that [statement] should be told to and
+ * this device can tell: [upwardOf] the room, Marmot rooms this device holds,
+ * belonging to the same profile as the room it is told from -- one database
+ * holds every profile, and a device must never post into a room as a
+ * profile that is not the one in it -- and not told yet. Nothing for a
+ * statement this device does not believe ([believable]).
+ */
+ private suspend fun targetsFor(database: BennuDatabase, statement: Event, fromChatRoomId: String, withCertificate: Boolean = false): List {
+ val believed = believable(statement) ?: return emptyList()
+ val profile = database.chatRoomDao().findChatRoomById(fromChatRoomId)?.chatRoom?.userPublicKey
+
+ return upwardOf(believed.guardians, fromChatRoomId)
+ .mapNotNull { database.chatRoomDao().findChatRoomById(it) }
+ .filter { it.chatRoom.mlsGroupState != null }
+ .filter { profile == null || it.chatRoom.userPublicKey.equals(profile, ignoreCase = true) }
+ .filterNot { room -> told(database, room.chatRoom.id, statement.id, withCertificate) }
+ }
+
+ /**
+ * Whether [chatRoomId] holds the statement [statementId] in any form: a
+ * notice carrying it, or the signed event itself -- which is how a group
+ * holds a member wallet certificate it signed, and never as a notice.
+ *
+ * With [withCertificate] -- this device has the guardian's birth certificate
+ * to add -- a notice counts only if it carries one: a room told before
+ * notices carried it is told again, once, so the name reaches it.
+ * `docs/member-wallet-guarding-group.md`, D5.
+ */
+ internal suspend fun told(database: BennuDatabase, chatRoomId: String, statementId: HexKey, withCertificate: Boolean = false): Boolean =
+ database.groupSignedEventDao().getById(statementId)?.chatRoomId.equals(chatRoomId, ignoreCase = true) ||
+ database.marmotInnerEventDao()
+ .getByChatRoomAndKinds(chatRoomId, listOf(GuardedWalletNoticeEvent.KIND))
+ .any { Event.fromJsonOrNull(it.content)?.id == statementId && (!withCertificate || GuardedWalletNoticeEvent.certificateIn(it.tags) != null) }
+
+ /**
+ * For a member wallet's certificate, the birth certificate of the group that
+ * signed it, checked, where this device holds one -- what a notice from
+ * [chatRoomId] carries upward so the groups above can name that group.
+ * Null for a subgroup's statement, which carries its own.
+ * `docs/member-wallet-guarding-group.md`, D4.
+ */
+ private suspend fun guardianCertificateFor(database: BennuDatabase, statement: Event, chatRoomId: String): Event? {
+ if (statement.kind != MemberWalletCertificateEvent.KIND) return null
+ val guardians = believable(statement)?.guardians ?: return null
+ val parent = guardians.getOrNull(1) ?: return null
+ val carried = database.marmotInnerEventDao()
+ .getByChatRoomAndKinds(chatRoomId, listOf(GuardedWalletNoticeEvent.KIND))
+ .mapNotNull { GuardedWalletNoticeEvent.certificateIn(it.tags) }
+ return foundingCertificateOf(database, guardians.first().chatRoomId, parent.chatRoomId, carried)
+ }
+
+ /**
+ * Tells every group above [chatRoomId] that this device can tell, and that
+ * has not been told, about [statement] -- as the profile that is in
+ * [chatRoomId]. `docs/guarded-wallet-forwarding.md`, Phase 2.
+ *
+ * With [whenElected], only the groups this device is the elected sender for
+ * ([electedSender] over the members of both rooms, as this device's
+ * participant lists have them, itself always among them): the moment a wallet
+ * arrives every device in both rooms has it, and only one of them should
+ * post at once. The catch-up passes false, and tells whatever is still left.
+ *
+ * Returns the rooms told.
+ */
+ suspend fun forward(database: BennuDatabase, statement: Event, chatRoomId: String, whenElected: Boolean): List {
+ val sender = database.chatRoomDao().findChatRoomById(chatRoomId)?.chatRoom?.userPublicKey ?: return emptyList()
+ val members = database.participantDao().findParticipantsByChatRoomId(chatRoomId).map { it.participantPublicKey.lowercase() }.toSet()
+
+ val certificate = guardianCertificateFor(database, statement, chatRoomId)
+ val targets = targetsFor(database, statement, fromChatRoomId = chatRoomId, withCertificate = certificate != null).filter { target ->
+ if (!whenElected) return@filter true
+ val both = database.participantDao().findParticipantsByChatRoomId(target.chatRoom.id)
+ .map { it.participantPublicKey.lowercase() }
+ .filter { it in members }
+ .toSet() + sender.lowercase()
+ electedSender(both).equals(sender, ignoreCase = true)
+ }
+ if (targets.isNotEmpty()) share(database, statement, targets, sender, certificate = certificate)
+ return targets
+ }
+
+ /** Every network a guarded wallet can be on: the catch-up forwards them all. */
+ private val CHAINS: List = listOf(Chain.Mainnet, Chain.Testnet3, Chain.Testnet4, Chain.Signet, Chain.Regtest)
+
+ /**
+ * The catch-up: everything [shareableFrom] would list from [chatRoomId], on
+ * every network, through [forward] without the election -- whatever the
+ * elected device never sent, whatever arrived while this one was offline,
+ * and everything filed before forwarding existed.
+ * `docs/guarded-wallet-forwarding.md`, Phase 4. Run as the group's chat and
+ * its wallet screen open. Returns how many groups were told.
+ */
+ suspend fun forwardAll(database: BennuDatabase, chatRoomId: String): Int {
+ if (!GroupWalletRollout.FORWARDS_GUARDED_WALLETS) return 0
+ val own = CHAINS.mapNotNull { chain ->
+ GroupWalletManager.walletFor(database, chatRoomId, chain)?.takeIf { it.account.isGuarded }?.signedEvent?.toEvent()
+ }
+ val held = guardedWalletsOf(database, chatRoomId).map { it.statement }
+
+ return (own + held).distinctBy { it.id }.sumOf { statement ->
+ runCatching { forward(database, statement, chatRoomId, whenElected = false).size }
+ .onFailure { logger.e("Could not forward ${statement.id.take(8)} from $chatRoomId", it) }
+ .getOrDefault(0)
+ }
+ }
+
+ /**
+ * [forward] on arrival, from the inbound path: elected, behind
+ * `GroupWalletRollout.FORWARDS_GUARDED_WALLETS`, and never failing the
+ * arrival it rides on -- forwarding is an extra, and the arrival is the thing.
+ */
+ suspend fun forwardOnArrival(database: BennuDatabase, statement: Event, chatRoomId: String) {
+ if (!GroupWalletRollout.FORWARDS_GUARDED_WALLETS) return
+ runCatching { forward(database, statement, chatRoomId, whenElected = true) }
+ .onSuccess { told -> if (told.isNotEmpty()) logger.i("Forwarded ${statement.id.take(8)} from $chatRoomId to ${told.size} group(s) above") }
+ .onFailure { logger.e("Could not forward ${statement.id.take(8)} from $chatRoomId", it) }
+ }
+
+ /**
+ * Tells every room in [rooms] about [statement], as [userPublicKey]: one
+ * notice each, queued for the outbound pipeline the way every inner event
+ * is. Returns how many were queued.
+ *
+ * Each notice names its room in an `h` tag. Without it, one statement told
+ * to a grandchild's parent and grandparent in the same second is one id --
+ * and one row, the last room's -- so the parent was never told.
+ *
+ * [certificate], for a member's wallet, is its guardian's birth certificate,
+ * carried as a tag -- `GuardedWalletNoticeEvent`.
+ */
+ suspend fun share(
+ database: BennuDatabase,
+ statement: Event,
+ rooms: List,
+ userPublicKey: HexKey,
+ createdAt: Long = Clock.System.now().epochSeconds,
+ certificate: Event? = null,
+ ): Int {
+ val content = statement.toJson()
+
+ // The sender is never handed its own MLS message back, so the line the
+ // other members' devices write when it arrives is written here for the
+ // sender's own -- before the notice, which then finds a line already
+ // there. docs/guarded-wallet-forwarding.md, D6.
+ val line = believable(statement)?.let { describe(named(database, it.subject)) }
+
+ rooms.forEach { room ->
+ val tags = listOfNotNull(arrayOf("h", room.chatRoom.id), certificate?.let(GuardedWalletNoticeEvent::certificateTag)).toTypedArray()
+ val id = EventHasher.hashId(userPublicKey, createdAt, GuardedWalletNoticeEvent.KIND, tags, content)
+ line?.takeIf { firstNoticeOf(database, room.chatRoom.id, statement.id, excludingNotice = id) }?.let {
+ database.chatMessageDao().upsert(
+ ChatMessage(
+ giftWrapPayloadId = null,
+ messageType = ChatMessage.TYPE_GUARDED_WALLET_SHARED,
+ marmotGroupEventId = null,
+ marmotInnerEventId = null,
+ senderPublicKey = userPublicKey,
+ isUserMessage = true,
+ chatRoomId = room.chatRoom.id,
+ createdAt = Instant.fromEpochSeconds(createdAt),
+ content = it,
+ )
+ )
+ }
+ database.marmotInnerEventDao().upsert(
+ MarmotInnerEvent(
+ id = id,
+ publicKey = userPublicKey,
+ kind = GuardedWalletNoticeEvent.KIND,
+ createdAt = Instant.fromEpochSeconds(createdAt),
+ tags = tags,
+ content = content,
+ chatRoomId = room.chatRoom.id,
+ )
+ )
+ logger.i("Told ${room.chatRoom.id} about ${statement.pubKey}'s guarded wallet")
+ }
+
+ return rooms.size
+ }
+
+ /** Coins of a guarded wallet one of its guardians took, in one transaction. */
+ data class Taken(
+ val txid: TxId,
+ val guardian: GuardianDerivation.Guardian,
+ val amount: Satoshi,
+ )
+
+ /**
+ * Which guardians of [account] took which of [coins] in [spending] -- one
+ * entry per guardian -- read off the witnesses alone.
+ *
+ * A guardian's input carries three things: a signature, a leaf, and the
+ * control block proving the leaf is in the address. The leaf is matched
+ * against the guardian leaves of the address the coin was at, so a leaf is
+ * named only by a guardian whose key it is; anything else -- the wallet's own
+ * key-path spend, a witness of another shape -- names nobody.
+ */
+ fun takenIn(
+ spending: Transaction,
+ account: GroupWalletDerivation.Account,
+ coins: Map>,
+ ): List {
+ if (!account.isGuarded) return emptyList()
+
+ return spending.txIn.mapNotNull { input ->
+ val (txOut, derivation) = coins[input.outPoint] ?: return@mapNotNull null
+ val stack = input.witness.stack.takeIf { it.size == 3 } ?: return@mapNotNull null
+ val leaves = GuardianDerivation.leaves(account.guardians, account.chain, account.account, derivation.change, derivation.index)
+ val position = leaves.indexOfFirst { it.script == stack[1] }.takeIf { it >= 0 } ?: return@mapNotNull null
+ account.guardians[position] to txOut.amount
+ }
+ .groupBy({ it.first }, { it.second })
+ .map { (guardian, amounts) -> Taken(spending.txid, guardian, amounts.sum()) }
+ }
+
+ /**
+ * Writes a transcript line in [chatRoomId] for each of [taken] it has no line
+ * for yet. Returns how many it wrote.
+ *
+ * The whole of the child's notice that an ancestor spent from its wallet --
+ * there is no channel from the ancestor's room into this one -- so it is
+ * written by whichever device reads the chain first, and every device that
+ * reads it afterwards finds it already there.
+ */
+ suspend fun recordTaken(database: BennuDatabase, chatRoomId: String, taken: List): Int {
+ val written = database.chatMessageDao().getChatMessagesByChatRoomId(chatRoomId)
+ .map { it.chatMessage }
+ .filter { it.messageType == ChatMessage.TYPE_GUARDIAN_SPEND }
+ .map { it.content }
+
+ val fresh = taken.filter { spend -> written.none { it.contains(spend.txid.toString()) } }
+ fresh.forEach { spend ->
+ val name = database.chatRoomDao().findChatRoomById(spend.guardian.chatRoomId)?.chatRoom?.subject
+ ?.takeIf { it.isNotBlank() }
+ ?: "A group above this one"
+ database.chatMessageDao().upsert(
+ ChatMessage(
+ senderPublicKey = spend.guardian.chatRoomId,
+ isUserMessage = false,
+ giftWrapPayloadId = null,
+ marmotGroupEventId = null,
+ marmotInnerEventId = null,
+ chatRoomId = chatRoomId,
+ content = "$name took ${spend.amount.sat} sats from this wallet through its guardian leaf, " +
+ "in transaction ${spend.txid}.",
+ messageType = ChatMessage.TYPE_GUARDIAN_SPEND,
+ )
+ )
+ logger.i("${spend.guardian.chatRoomId} took ${spend.amount.sat} sats from $chatRoomId's guarded wallet in ${spend.txid}")
+ }
+ return fresh.size
+ }
+
+ /**
+ * What a notice that arrived in [chatRoomId] says, for its transcript line --
+ * or null when it is not one this room can believe, which gets no line: a
+ * line saying a wallet was shared would read as the group being told
+ * something it was not.
+ */
+ suspend fun describeNotice(database: BennuDatabase, chatRoomId: String, notice: Event): String? {
+ val statement = GuardedWalletNoticeEvent.statementOf(notice) ?: return null
+ val thresholdPublicKey = GroupWalletManager.thresholdKeyFor(database, chatRoomId) ?: return null
+ val wallet = verify(statement, chatRoomId, thresholdPublicKey) ?: return null
+ // One line per wallet per group: a second notice of a statement this room
+ // already holds -- told before, by another forwarder, or signed here --
+ // is filed and silent. docs/guarded-wallet-forwarding.md, D6.
+ if (!firstNoticeOf(database, chatRoomId, statement.id, excludingNotice = notice.id)) return null
+
+ return describe(named(database, wallet).subject)
+ }
+
+ private fun describe(subject: GuardedSubject): String = when (subject) {
+ is GuardedSubject.Member -> "Shared @${subject.ownerName ?: subject.ownerPublicKey.take(8)}'s guarded wallet with this group."
+ is GuardedSubject.Subgroup -> subject.name?.let { "Shared the guarded wallet of $it with this group." }
+ ?: "Shared a subgroup's guarded wallet with this group."
+ }
+
+ /** [subject] with its member's profile name, where this device knows one. */
+ private suspend fun named(database: BennuDatabase, subject: GuardedSubject): GuardedSubject {
+ val member = subject as? GuardedSubject.Member ?: return subject
+ val name = database.profileDao().getProfileByPublicKey(member.ownerPublicKey)?.humanReadableNameOrPubkey()
+ return member.copy(ownerName = name)
+ }
+
+ /**
+ * Whether a notice of [statementId] -- [excludingNotice], the one being
+ * filed or sent -- is the first [chatRoomId] holds: no other notice in the
+ * room carries the statement, and the room did not sign it itself.
+ */
+ private suspend fun firstNoticeOf(database: BennuDatabase, chatRoomId: String, statementId: HexKey, excludingNotice: HexKey): Boolean {
+ if (database.groupSignedEventDao().getById(statementId)?.chatRoomId.equals(chatRoomId, ignoreCase = true)) return false
+ return database.marmotInnerEventDao()
+ .getByChatRoomAndKinds(chatRoomId, listOf(GuardedWalletNoticeEvent.KIND))
+ .none { it.id != excludingNotice && Event.fromJsonOrNull(it.content)?.id == statementId }
+ }
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/MemberWalletDerivation.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/MemberWalletDerivation.kt
new file mode 100644
index 00000000..6fa8ec41
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/MemberWalletDerivation.kt
@@ -0,0 +1,145 @@
+package com.machankura.bennu.compose.managers
+
+import com.machankura.bennu.compose.wallet.GroupSpend
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray
+import com.vitorpamplona.quartz.nip01Core.core.toHexKey
+import com.vitorpamplona.quartz.utils.RandomInstance
+import fr.acinq.bitcoin.ByteVector32
+import fr.acinq.bitcoin.ByteVector64
+import fr.acinq.bitcoin.Chain
+import fr.acinq.bitcoin.Crypto
+import fr.acinq.bitcoin.Descriptor
+import fr.acinq.bitcoin.DeterministicWallet
+import fr.acinq.bitcoin.KeyPath
+import fr.acinq.bitcoin.PrivateKey
+import fr.acinq.bitcoin.PublicKey
+
+/**
+ * The keys of a wallet one member holds and a group guards: a guarded wallet
+ * whose key path is the member's own key rather than a group's threshold key.
+ *
+ * Everything public is the group wallet's derivation with the member's key in
+ * the threshold key's place, and the guardian derivation with the wallet's id in
+ * a child room's place:
+ *
+ * ```
+ * k random, generated on the member's device and never sent
+ * P_W = k·G the wallet key
+ * W = taggedHash("bennu/member-wallet/id/v1", serP(P_W)) the wallet's id
+ * account = GroupWalletDerivation.account(P_W, chain, 0, grant)
+ * grant = GuardianDerivation.grant(K_G, G, guardians(G), W)
+ * ```
+ *
+ * So a member's wallet under G is guarded exactly as a guarded subgroup of G
+ * would be. What is new is only the private side: the member holds `k`, so
+ * every tweak the account and the address add to the point is added to the
+ * scalar too, and a spend is one Schnorr signature. See
+ * `docs/member-guarded-wallets.md`.
+ *
+ * ### Why `W` is a hash and not the key
+ *
+ * A room id here is a public key, and `GroupKeyStateEvent.isSignedByRoom` asks
+ * whether that key signed something. A `W` nobody holds a key for cannot be
+ * mistaken for a room by anything that checks signatures.
+ *
+ * ### The rule this inherits
+ *
+ * Every step below `P_W` is an unhardened public tweak, and every guardian holds
+ * the account xpub. A guardian who learns the private key of one address can
+ * therefore recover `k`. That is why `k` is random and good for one wallet only:
+ * never the nostr key, never a key from the profile's seed.
+ */
+object MemberWalletDerivation {
+ /** The tag of a wallet id's hash. Frozen the moment a certificate carries one: a rename moves every leaf. */
+ private const val ID_TAG = "bennu/member-wallet/id/v1"
+
+ /**
+ * The account a member wallet always opens at. One wallet is one key, so a
+ * second account would be a second wallet under a key that already has one.
+ */
+ const val ACCOUNT: Long = 0L
+
+ /** A fresh wallet key, from the platform's secure random. */
+ fun generate(): PrivateKey {
+ while (true) {
+ val candidate = PrivateKey(ByteVector32(RandomInstance.bytes(32)))
+ if (candidate.isValid()) return candidate
+ }
+ }
+
+ /** `W`: the tagged hash of the wallet key's compressed form, hex. */
+ fun walletId(walletKey: PublicKey): String =
+ Crypto.taggedHash(walletKey.value.toByteArray(), ID_TAG).toByteArray().toHexKey()
+
+ fun walletId(walletKey: HexKey): String = walletId(PublicKey(walletKey.hexToByteArray()))
+
+ /**
+ * The account [walletKey] opens on [chain] under [guardians]:
+ * `GroupWalletDerivation.account` over the member's key.
+ */
+ fun account(walletKey: PublicKey, chain: Chain, guardians: List): GroupWalletDerivation.Account =
+ GroupWalletDerivation.account(walletKey.toString(), chain, ACCOUNT, guardians)
+
+ /**
+ * The account key as a private extended key: [walletPrivateKey] plus the
+ * scalar `GroupWalletDerivation.account` adds to the point, with the same
+ * chain code. Plain addition, so there is no parity to get wrong until the
+ * taproot tweak at the very end.
+ */
+ fun accountPrivateKey(walletPrivateKey: PrivateKey, chain: Chain): DeterministicWallet.ExtendedPrivateKey {
+ val (tweak, chainCode) = GroupWalletDerivation.accountStep(walletPrivateKey.publicKey(), chain, ACCOUNT)
+ return DeterministicWallet.ExtendedPrivateKey(
+ secretkeybytes = (walletPrivateKey + PrivateKey(tweak)).value,
+ chaincode = chainCode,
+ depth = 0,
+ path = KeyPath.empty,
+ parent = 0L,
+ )
+ }
+
+ /** The private key of the internal key at `change/index`: CKDpriv twice below [accountPrivateKey]. */
+ fun privateKeyAt(walletPrivateKey: PrivateKey, chain: Chain, change: Long, index: Long): PrivateKey {
+ require(change == GroupWalletDerivation.RECEIVE || change == GroupWalletDerivation.CHANGE) { "change must be 0 or 1, not $change" }
+ require(index in 0L..GroupWalletDerivation.MAX_INDEX) { "index $index is not an unhardened index" }
+ return accountPrivateKey(walletPrivateKey, chain).derivePrivateKey(listOf(change, index)).privateKey
+ }
+
+ /**
+ * The receive and change descriptors of [account] with the account's private
+ * key in place of its xpub -- what any wallet that imports taproot
+ * descriptors can sweep the coins with. The member's backup of last resort,
+ * shown only behind a confirmation: whoever holds these holds the coins.
+ */
+ fun privateDescriptors(walletPrivateKey: PrivateKey, account: GroupWalletDerivation.Account): Pair {
+ val extended = accountPrivateKey(walletPrivateKey, account.chain)
+ require(extended.extendedPublicKey == account.extendedPublicKey) { "this key does not open this account" }
+ val xprv = extended.encode(if (account.chain.isMainnet()) DeterministicWallet.xprv else DeterministicWallet.tprv)
+
+ fun swap(descriptor: String): String {
+ val body = descriptor.substringBefore('#').replaceFirst(account.xpub, xprv)
+ return "$body#${Descriptor.checksum(body)}"
+ }
+ return swap(account.receiveDescriptor) to swap(account.changeDescriptor)
+ }
+
+ /**
+ * The signature [input] of a checked spend needs from the wallet's own key:
+ * the address's private key under the address's taproot tweak, over the
+ * input's key-path sighash.
+ *
+ * Refuses a guardian's input -- the member never signs through a leaf -- and
+ * an input whose address is not one this key reaches, so a signature made
+ * here always verifies against the key the coin is at.
+ */
+ fun sign(walletPrivateKey: PrivateKey, chain: Chain, input: GroupSpend.SpentInput): ByteVector64 {
+ require(input.leaf == null) { "a member signs on the key path, never through a guardian's leaf" }
+ val derivation = input.derivation
+ val privateKey = privateKeyAt(walletPrivateKey, chain, derivation.change, derivation.index)
+ require(privateKey.xOnlyPublicKey() == derivation.internalKey) { "this key does not reach the address at ${derivation.change}/${derivation.index}" }
+
+ val signature = Crypto.signSchnorr(input.sighash, privateKey, derivation.taprootTweak)
+ require(Crypto.verifySignatureSchnorr(input.sighash, signature, input.signingKey)) { "the signature does not verify against the coin's key" }
+ return signature
+ }
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/MemberWalletManager.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/MemberWalletManager.kt
new file mode 100644
index 00000000..bbb4de52
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/MemberWalletManager.kt
@@ -0,0 +1,866 @@
+package com.machankura.bennu.compose.managers
+
+import com.machankura.bennu.compose.database.model.types.ChatRoomType
+import com.machankura.bennu.compose.nostr.wallet.MemberWalletPolicyEvent
+import co.touchlab.kermit.Logger
+import com.machankura.bennu.compose.database.BennuDatabase
+import com.machankura.bennu.compose.database.model.FrostSigningSession
+import com.machankura.bennu.compose.database.model.MemberWallet
+import com.machankura.bennu.compose.database.model.MemberWalletSpend
+import com.machankura.bennu.compose.wallet.GroupSpend
+import fr.acinq.bitcoin.ScriptFlags
+import fr.acinq.bitcoin.Transaction
+import fr.acinq.bitcoin.psbt.Psbt
+import fr.acinq.secp256k1.Hex
+import com.machankura.bennu.compose.database.model.MarmotInnerEvent
+import com.machankura.bennu.compose.database.model.intermdiate.LocalChatRoom
+import com.machankura.bennu.compose.database.model.types.FrostSigningStage
+import com.machankura.bennu.compose.nostr.subgroup.SubgroupBirthCertificateEvent
+import com.machankura.bennu.compose.nostr.wallet.GroupKeyNoticeEvent
+import com.machankura.bennu.compose.nostr.wallet.GroupWalletStatementEvent
+import com.machankura.bennu.compose.nostr.wallet.MemberWalletCertificateEvent
+import com.machankura.bennu.compose.nostr.wallet.MemberWalletRequestEvent
+import com.vitorpamplona.quartz.nip01Core.core.Event
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
+import com.machankura.bennu.compose.wallet.GroupWalletRollout
+import fr.acinq.bitcoin.Chain
+import fr.acinq.bitcoin.PrivateKey
+import kotlin.time.Clock
+import kotlin.time.Instant
+
+/**
+ * A member's guarded wallet, from the asking to the guarding:
+ * `docs/member-guarded-wallets.md`.
+ *
+ * The member's device makes a random key, works out every ancestor leaf, stores
+ * the key and only then asks the group. A signer puts the request to the group,
+ * the group's quorum signs a certificate saying it guards that key for that
+ * person, and the certificate is what every device opens the wallet on.
+ */
+object MemberWalletManager {
+ private const val TAG = "MemberWalletManager"
+
+ private val logger = Logger.withTag(TAG)
+
+ /**
+ * The key [chatRoomId] signs with and the certificate it was born with --
+ * what a member's grant is worked out from -- or null when this device knows
+ * neither.
+ *
+ * This device's own verified key state first. Behind it, the newest answer to
+ * a key notice in the room that checks out: a member welcomed after the
+ * founding holds no key state, and asks (`askForGroupKey`). Never filed as
+ * key state -- see [GroupKeyNoticeEvent].
+ */
+ suspend fun groupKeyFor(database: BennuDatabase, chatRoomId: String): GroupKeyNoticeEvent.GroupKey? {
+ GroupKeyStateManager.keyStateFor(database, chatRoomId)?.takeIf { it.verifies() }?.let { state ->
+ return GroupKeyNoticeEvent.GroupKey(
+ chatRoomId = state.chatRoomId,
+ thresholdPublicKey = state.thresholdPublicKey,
+ certificate = state.birthCertificateJson?.let { Event.fromJsonOrNull(it) },
+ )
+ }
+
+ return noticesIn(database, chatRoomId)
+ .sortedByDescending { it.createdAt }
+ .firstNotNullOfOrNull { GroupKeyNoticeEvent.read(it, chatRoomId) }
+ }
+
+ /**
+ * Whether [chatRoomId] guards its members' wallets, and at what delay: the
+ * newest policy its own room signed, open or closed, among the ones this
+ * device holds -- `docs/member-wallet-delay.md`. Null when it holds none,
+ * which means the group has not opened (D8), or that this device has not
+ * yet been told.
+ *
+ * The one reader, used by the member's device when it builds a request and
+ * by every signer when it judges one.
+ */
+ suspend fun policyFor(database: BennuDatabase, chatRoomId: String): MemberWalletPolicyEvent.Policy? =
+ MemberWalletPolicyEvent.newestAmong(
+ database.groupSignedEventDao()
+ .getByChatRoomIdAndKind(chatRoomId, MemberWalletPolicyEvent.KIND)
+ .map { it.toEvent() } +
+ // A late member's only way to it: carried in a key answer, and
+ // checked again here as the room's own signature.
+ noticesIn(database, chatRoomId).mapNotNull { GroupKeyNoticeEvent.read(it, chatRoomId)?.policy?.event },
+ chatRoomId,
+ )
+
+ /**
+ * Asks [chatRoomId] for its key, as [userPublicKey]. Returns false, asking
+ * nothing, when this device already knows it or has asked and not been
+ * answered: a second question would get the same answer.
+ */
+ suspend fun askForGroupKey(database: BennuDatabase, chatRoomId: String, userPublicKey: HexKey): Boolean {
+ if (groupKeyFor(database, chatRoomId) != null) return false
+
+ val notices = noticesIn(database, chatRoomId)
+ val answered = notices.mapNotNull { GroupKeyNoticeEvent.answers(it) }.toSet()
+ if (notices.any { GroupKeyNoticeEvent.isAsking(it) && it.pubKey == userPublicKey && it.id !in answered }) return false
+
+ queue(database, chatRoomId, userPublicKey, GroupKeyNoticeEvent.askingTags(chatRoomId), content = "")
+ logger.i("Asked $chatRoomId for its key")
+ return true
+ }
+
+ /**
+ * Answers [request], an asking notice that arrived in [chatRoomId], as
+ * [userPublicKey] -- when this device holds the room's verified key state and
+ * nobody has answered it yet. Returns whether it answered.
+ *
+ * Any member holding the state may answer, and none is elected to: a
+ * duplicate answer costs bandwidth and nothing else, since every answer is
+ * checked on its own and they all say the same thing. The chronicle's
+ * request is answered the same way.
+ */
+ suspend fun answerKeyRequest(database: BennuDatabase, chatRoomId: String, request: Event, userPublicKey: HexKey): Boolean {
+ if (!GroupKeyNoticeEvent.isAsking(request) || request.pubKey == userPublicKey) return false
+ val state = GroupKeyStateManager.keyStateFor(database, chatRoomId)?.takeIf { it.verifies() } ?: return false
+ val path = state.pathIndices() ?: return false
+ if (noticesIn(database, chatRoomId).any { GroupKeyNoticeEvent.answers(it) == request.id }) return false
+
+ val groupKey = GroupKeyNoticeEvent.GroupKey(
+ chatRoomId = state.chatRoomId,
+ thresholdPublicKey = state.thresholdPublicKey,
+ certificate = state.birthCertificateJson?.let { Event.fromJsonOrNull(it) },
+ // The other thing a late member cannot read for themselves.
+ // docs/member-wallet-delay.md, Phase 3.
+ policy = policyFor(database, chatRoomId),
+ )
+ queue(database, chatRoomId, userPublicKey, GroupKeyNoticeEvent.answeringTags(request.id, groupKey, path), content = state.thresholdPublicKey)
+ logger.i("Answered ${request.pubKey.take(8)}'s request for $chatRoomId's key")
+ return true
+ }
+
+ // ---- The member's side -----------------------------------------------
+
+ /** Why a member cannot ask a group to guard a wallet for them here, said as a reason the screen can name. */
+ enum class Refusal {
+ /** A read-only profile: it cannot sign the request. */
+ CANNOT_SIGN,
+
+ /** The room is not a Marmot group, so there is no quorum to sign and no room to carry it. */
+ NOT_A_GROUP,
+
+ /** This device does not know what the group signs with -- [askForGroupKey] is the way on. */
+ KEY_UNKNOWN,
+
+ /** The group's certificate carries guardian keys this build cannot read. */
+ GUARDIANS_UNREADABLE,
+
+ /** Member wallets are not offered on this network yet: `GroupWalletRollout.offersMemberWalletsOn`. */
+ NOT_ON_THIS_NETWORK,
+
+ /** The profile has no Electrum client, so it could not see its own coins. Read by the screen, not here. */
+ CANNOT_WATCH,
+
+ /**
+ * The group has not said it guards members' wallets: no policy, as far as
+ * this device knows. `docs/member-wallet-delay.md`, D8.
+ */
+ NOT_OFFERED,
+
+ /** The group's newest policy closed it to new members' wallets. D9. */
+ CLOSED,
+ }
+
+ /**
+ * The groups [ownerPublicKey] is in that could guard a wallet for them: Marmot
+ * rooms, whether or not their key is known yet -- but not a direct chat.
+ *
+ * A direct chat is a Marmot room too, of exactly two people, and it never has
+ * a key: a key ceremony needs at least `ChatRoomType.MINIMUM_ROBUST_GROUP_SIZE`
+ * participants. Listed, it would ask for a key nobody can ever answer with.
+ * So a room of fewer than three members is left out unless this device knows
+ * its key -- a real group can shrink to two after its ceremony, and still sign
+ * if the two make its quorum. The same "the two of us" the direct-message
+ * lookup uses (`ChatRepository.findDirectMessageRoom`).
+ */
+ suspend fun groupsOf(database: BennuDatabase, ownerPublicKey: HexKey): List =
+ database.chatRoomDao().getChatRoomListByUserPublicKey(ownerPublicKey).filter { couldGuard(database, it) }
+
+ /** Whether [room] is a group that could guard a member's wallet: [groupsOf]'s one rule, for a room on its own page too. */
+ suspend fun couldGuard(database: BennuDatabase, room: LocalChatRoom): Boolean {
+ if (room.chatRoom.mlsGroupState == null) return false
+ val members = room.localParticipants.map { it.participant.participantPublicKey.lowercase() }.toSet()
+ return members.size >= ChatRoomType.MINIMUM_ROBUST_GROUP_SIZE || groupKeyFor(database, room.chatRoom.id) != null
+ }
+
+ /** Why [chatRoomId] cannot guard a wallet for this profile on [chain], or null when it can. */
+ suspend fun refusal(database: BennuDatabase, chatRoomId: String, canSign: Boolean, chain: Chain): Refusal? {
+ if (!canSign) return Refusal.CANNOT_SIGN
+ if (!GroupWalletRollout.offersMemberWalletsOn(chain)) return Refusal.NOT_ON_THIS_NETWORK
+ val room = database.chatRoomDao().findChatRoomById(chatRoomId)
+ if (room?.chatRoom?.mlsGroupState == null) return Refusal.NOT_A_GROUP
+ val groupKey = groupKeyFor(database, chatRoomId) ?: return Refusal.KEY_UNKNOWN
+ if (groupKey.certificate != null && SubgroupBirthCertificateEvent.parseGuardians(groupKey.certificate.tags) == null) {
+ return Refusal.GUARDIANS_UNREADABLE
+ }
+ // Only a group that has opened guards members' wallets, at the delay it
+ // chose -- and a late member learns it with the key, so no key and no
+ // policy is KEY_UNKNOWN above, with its button to ask.
+ return when (policyFor(database, chatRoomId)) {
+ null -> Refusal.NOT_OFFERED
+ is MemberWalletPolicyEvent.Policy.Closed -> Refusal.CLOSED
+ is MemberWalletPolicyEvent.Policy.Open -> null
+ }
+ }
+
+ /**
+ * How many groups a wallet guarded by [chatRoomId] would be guarded by: the
+ * group, and every group above it whose key it passes down. Null when this
+ * device does not know the group's key.
+ */
+ suspend fun reachOf(database: BennuDatabase, chatRoomId: String): Int? =
+ groupKeyFor(database, chatRoomId)?.let { it.guardians.size + 1 }
+
+ /**
+ * How long a coin in a wallet [chatRoomId] guards would wait for each of its
+ * guardians, nearest first: the group's own leaf at the delay its open policy
+ * sets, and every group above it at the delay it chose -- the same list the
+ * grant in [request] carries. Null when this device does not know the
+ * group's key, or the group is not open. `docs/member-wallet-delay.md`.
+ */
+ suspend fun delaysOf(database: BennuDatabase, chatRoomId: String): List? {
+ val key = groupKeyFor(database, chatRoomId) ?: return null
+ val policy = policyFor(database, chatRoomId) as? MemberWalletPolicyEvent.Policy.Open ?: return null
+ return listOf(policy.delay) + key.guardians.map { it.delay }
+ }
+
+ /**
+ * Steps 1 and 2: makes a random key, works out every ancestor's leaf and
+ * both descriptors, stores the key, and only then asks [chatRoomId] to
+ * guard the wallet, as the member [memberPrivateKey] holds.
+ *
+ * The row is written before the request is queued, so a crash between the
+ * two leaves a key and no request rather than a request and no key. The
+ * request is checked the way every signer will check it before it goes, so
+ * a quorum is never shown one this device would refuse. A member who holds a
+ * share of the group's key puts it to the group in the same breath; anybody
+ * else waits for a signer to.
+ *
+ * @throws IllegalStateException with the [Refusal] when it cannot be asked
+ */
+ suspend fun request(
+ database: BennuDatabase,
+ chatRoomId: String,
+ memberPrivateKey: PrivateKey,
+ chain: Chain,
+ label: String?,
+ createdAt: Instant = Clock.System.now(),
+ ): MemberWallet {
+ refusal(database, chatRoomId, canSign = true, chain)?.let { throw IllegalStateException("Cannot ask: $it") }
+ val groupKey = groupKeyFor(database, chatRoomId) ?: throw IllegalStateException("Cannot ask: ${Refusal.KEY_UNKNOWN}")
+ val memberPublicKey = memberPrivateKey.xOnlyPublicKey().value.toHex()
+
+ // The group's own leaf at the delay its newest policy sets, which the
+ // request carries so every signer judges it by what the group signed.
+ // refusal() has already refused a group that is not open.
+ val policy = policyFor(database, chatRoomId) as? MemberWalletPolicyEvent.Policy.Open
+ ?: throw IllegalStateException("Cannot ask: ${Refusal.NOT_OFFERED}")
+
+ val walletPrivateKey = MemberWalletDerivation.generate()
+ val walletId = MemberWalletDerivation.walletId(walletPrivateKey.publicKey())
+ val grant = GuardianDerivation.grant(groupKey.thresholdPublicKey, chatRoomId.lowercase(), groupKey.guardians, walletId, policy.delay)
+ val account = MemberWalletDerivation.account(walletPrivateKey.publicKey(), chain, grant)
+
+ val request = MemberWalletRequestEvent.build(
+ memberPrivateKey = memberPrivateKey,
+ groupChatRoomId = chatRoomId,
+ walletPrivateKey = walletPrivateKey,
+ account = account,
+ label = label,
+ createdAt = createdAt.epochSeconds,
+ policy = policy.event,
+ )
+ checkNotNull(MemberWalletRequestEvent.verified(request)) { "The request this device built does not check out" }
+
+ val wallet = MemberWallet(
+ walletId = walletId,
+ ownerPublicKey = memberPublicKey,
+ guardingChatRoomId = chatRoomId,
+ chain = GroupWalletStatementEvent.chainName(chain),
+ walletPrivateKey = walletPrivateKey.value.toHex(),
+ label = MemberWalletRequestEvent.read(request)?.label,
+ requestJson = request.toJson(),
+ // The request's own second: the row and the event it carries agree on when.
+ createdAt = Instant.fromEpochSeconds(request.createdAt),
+ )
+ database.memberWalletDao().upsert(wallet)
+ send(database, chatRoomId, request)
+ logger.i("Asked $chatRoomId to guard wallet ${walletId.take(8)}")
+
+ sponsorIfSigner(database, chatRoomId, memberPublicKey, request)
+ return wallet
+ }
+
+ /**
+ * Asks again -- for a request no signer put to the group, or one the group
+ * did not sign. With the request [wallet] was asked with, unchanged, when
+ * the group would still accept it; otherwise with a new one under the
+ * group's newest policy and a new key, as the member [memberPrivateKey]
+ * holds, and the old key discarded: no address of it was ever offered.
+ * `docs/member-wallet-delay.md`, Phase 5.
+ *
+ * Returns the wallet now asked for -- [wallet] itself, or its replacement.
+ *
+ * @throws IllegalStateException when a new request is needed and this group
+ * cannot be asked now, with the [Refusal]
+ */
+ suspend fun askAgain(database: BennuDatabase, wallet: MemberWallet, memberPrivateKey: PrivateKey): MemberWallet {
+ val request = Event.fromJsonOrNull(wallet.requestJson) ?: throw IllegalStateException("The stored request does not read")
+ if (judgePolicy(database, wallet.guardingChatRoomId, request) is PolicyJudgement.At) {
+ send(database, wallet.guardingChatRoomId, request)
+ sponsorIfSigner(database, wallet.guardingChatRoomId, wallet.ownerPublicKey, request)
+ return wallet
+ }
+
+ val chain = MemberWalletRequestEvent.read(request)?.chain ?: throw IllegalStateException("The stored request does not read")
+ val replacement = request(database, wallet.guardingChatRoomId, memberPrivateKey, chain, wallet.label)
+ discard(database, wallet.walletId)
+ logger.i("Asked ${wallet.guardingChatRoomId} again for a new wallet in place of ${wallet.walletId.take(8)}")
+ return replacement
+ }
+
+ /**
+ * Forgets [walletId]'s key. Refused once a group has certified the wallet:
+ * from then on its addresses may have been paid. Before, none was ever
+ * offered, so no coin can be behind the key.
+ */
+ suspend fun discard(database: BennuDatabase, walletId: String) {
+ val wallet = database.memberWalletDao().getById(walletId) ?: return
+ check(certificatesOf(database, wallet.guardingChatRoomId).none { it.walletId == walletId }) {
+ "A group guards this wallet: its key is not discarded"
+ }
+ database.memberWalletDao().delete(walletId)
+ }
+
+ /** The request into [chatRoomId], whole, as an inner event's content: see `MemberWalletRequestEvent`. */
+ private suspend fun send(database: BennuDatabase, chatRoomId: String, request: Event) {
+ queue(
+ database = database,
+ chatRoomId = chatRoomId,
+ userPublicKey = request.pubKey,
+ tags = arrayOf(arrayOf("h", chatRoomId.lowercase())),
+ content = request.toJson(),
+ kind = MemberWalletRequestEvent.KIND,
+ )
+ }
+
+ private suspend fun sponsorIfSigner(database: BennuDatabase, chatRoomId: String, memberPublicKey: HexKey, request: Event) {
+ if (!FrostSigningManager.canSign(database, chatRoomId)) return
+ val room = database.chatRoomDao().findChatRoomById(chatRoomId) ?: return
+ runCatching { putToGroup(database, room, memberPublicKey, request) }
+ .onFailure { logger.w("Asked $chatRoomId, and could not put it to the group: ${it.message}") }
+ }
+
+ /** Where a member's wallet has got to, as one fact the profile shows. */
+ enum class WalletState {
+ /** A key and a request here; nobody has put it to the group yet. */
+ ASKED,
+
+ /** A session is running over its certificate. */
+ SIGNING,
+
+ /** The session failed or was declined, and the group has not certified it. */
+ NOT_SIGNED,
+
+ /** Certified, and the key is on this device. */
+ OPEN,
+
+ /** Certified, and the key is on another device of this profile's. */
+ WATCH_ONLY,
+ }
+
+ /** One of a member's guarded wallets, as their profile lists it. */
+ data class MemberWalletRow(
+ val walletId: String,
+ val groupChatRoomId: String,
+ /** The guarding group's room on this device, or null when this device is not in it. */
+ val groupRoom: LocalChatRoom?,
+ val label: String?,
+ val chain: Chain,
+ /** The account the wallet opens: rederived from the request, guardians and all. */
+ val account: GroupWalletDerivation.Account,
+ val state: WalletState,
+ /** Whether the member is still a member of the guarding group, as far as this device can see. */
+ val isMember: Boolean,
+ /** The stored key's row, for a wallet whose key is here. Never handed to a screen. */
+ internal val stored: MemberWallet?,
+ /**
+ * Why the group would refuse this wallet's request as it stands, for one
+ * not yet guarded -- [judgePolicy] -- or null when it would not. Asking
+ * again then makes a new request. `docs/member-wallet-delay.md`.
+ */
+ val refusedBecause: Why? = null,
+ ) {
+ val isCertified: Boolean get() = state == WalletState.OPEN || state == WalletState.WATCH_ONLY
+ }
+
+ /**
+ * Every guarded wallet of [ownerPublicKey]'s this device knows about, newest
+ * first: the ones whose key is here, and the ones a group this device is in
+ * has certified for this profile -- which includes wallets made on another
+ * of its devices.
+ */
+ suspend fun walletsOf(database: BennuDatabase, ownerPublicKey: HexKey): List {
+ val stored = database.memberWalletDao().getByOwner(ownerPublicKey)
+ val certified = database.groupSignedEventDao().getByKind(MemberWalletCertificateEvent.KIND)
+ .filter { MemberWalletCertificateEvent.memberOf(it.toEvent()).equals(ownerPublicKey, ignoreCase = true) }
+ .mapNotNull { MemberWalletCertificateEvent.verify(it.toEvent(), it.chatRoomId) }
+ .distinctBy { it.walletId }
+ .associateBy { it.walletId }
+
+ val fromKeys = stored.mapNotNull { wallet ->
+ val request = Event.fromJsonOrNull(wallet.requestJson) ?: return@mapNotNull null
+ val verified = MemberWalletRequestEvent.verified(request) ?: return@mapNotNull null
+ val state = when {
+ certified.containsKey(wallet.walletId) -> WalletState.OPEN
+ openSessionFor(database, wallet.guardingChatRoomId, request) != null -> WalletState.SIGNING
+ wasNotSigned(database, wallet.guardingChatRoomId, request) -> WalletState.NOT_SIGNED
+ else -> WalletState.ASKED
+ }
+ row(database, wallet.walletId, wallet.guardingChatRoomId, wallet.label, verified.account, state, ownerPublicKey, wallet)
+ .let { row ->
+ if (row.isCertified) row
+ else row.copy(refusedBecause = (judgePolicy(database, wallet.guardingChatRoomId, request) as? PolicyJudgement.Refused)?.why)
+ }
+ }
+ val elsewhere = certified.values
+ .filter { cert -> stored.none { it.walletId == cert.walletId } }
+ .map { row(database, it.walletId, it.groupChatRoomId, it.label, it.account, WalletState.WATCH_ONLY, ownerPublicKey, null) }
+
+ return (fromKeys + elsewhere).sortedByDescending { it.stored?.createdAt?.epochSeconds ?: 0L }
+ }
+
+ private suspend fun row(
+ database: BennuDatabase,
+ walletId: String,
+ groupChatRoomId: String,
+ label: String?,
+ account: GroupWalletDerivation.Account,
+ state: WalletState,
+ ownerPublicKey: HexKey,
+ stored: MemberWallet?,
+ ): MemberWalletRow {
+ val room = database.chatRoomDao().findChatRoomById(groupChatRoomId)
+ val isMember = room == null || database.participantDao().findParticipantsByChatRoomId(groupChatRoomId)
+ .any { it.participantPublicKey.equals(ownerPublicKey, ignoreCase = true) }
+ return MemberWalletRow(walletId, groupChatRoomId, room, label, account.chain, account, state, isMember, stored)
+ }
+
+ /** [ownerPublicKey]'s wallet [walletId], or null when this device knows of none. */
+ suspend fun walletOf(database: BennuDatabase, ownerPublicKey: HexKey, walletId: String): MemberWalletRow? =
+ walletsOf(database, ownerPublicKey).firstOrNull { it.walletId == walletId }
+
+ /**
+ * [walletId]'s descriptors with its private key in them, or null when the key
+ * is not on this device. See `MemberWalletDerivation.privateDescriptors`.
+ */
+ suspend fun exportKey(database: BennuDatabase, ownerPublicKey: HexKey, walletId: String): Pair? {
+ val row = walletOf(database, ownerPublicKey, walletId) ?: return null
+ val key = row.stored?.walletPrivateKey?.let { PrivateKey.fromHex(it) } ?: return null
+ return MemberWalletDerivation.privateDescriptors(key, row.account)
+ }
+
+ /**
+ * Signs [psbt] as [walletId]'s own key and files the spend, returning the
+ * finished transaction for the caller to broadcast.
+ *
+ * Checked the way a group member checks a group spend -- `GroupSpend.check`
+ * against the account the wallet rederives to, never against the PSBT's own
+ * claims -- because the builder is shared and so are its mistakes; and then
+ * `correctlySpends`, the last word on whether the network will take it.
+ *
+ * @throws IllegalStateException when the key is not here, the wallet is not
+ * certified, the spend fails a check or is over the cap
+ */
+ suspend fun signSpend(database: BennuDatabase, ownerPublicKey: HexKey, walletId: String, psbt: Psbt, at: Instant = Clock.System.now()): Transaction {
+ val row = walletOf(database, ownerPublicKey, walletId) ?: throw IllegalStateException("No such wallet")
+ check(row.state == WalletState.OPEN) { "Only a certified wallet whose key is here can spend" }
+ val key = PrivateKey.fromHex(checkNotNull(row.stored).walletPrivateKey)
+
+ val checked = when (val result = GroupSpend.check(psbt, row.account, GroupSpend.Spender.Owner)) {
+ is GroupSpend.Result.Ok -> result.checked
+ is GroupSpend.Result.Refused -> throw IllegalStateException("This spend ${result.reason}")
+ }
+ GroupWalletRollout.memberCapFor(row.chain)?.let { cap ->
+ check(checked.amountSent <= cap) { "This spend sends more than the ${cap.sat} sats one spend may send on mainnet" }
+ }
+
+ val signed = checked.witnessed(checked.inputs.map { MemberWalletDerivation.sign(key, row.chain, it) })
+ signed.correctlySpends(checked.inputs.associate { it.outPoint to it.txOut }, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS)
+
+ database.memberWalletDao().upsertSpend(
+ MemberWalletSpend(
+ txid = signed.txid.toString(),
+ walletId = walletId,
+ psbt = GroupSpend.encode(psbt),
+ signedTransaction = Hex.encode(Transaction.write(signed)),
+ createdAt = at,
+ )
+ )
+ logger.i("Signed ${signed.txid} from wallet ${walletId.take(8)}")
+ return signed
+ }
+
+ /**
+ * Files what the chain said of [txid]: handed to Electrum at [broadcastAt],
+ * and -- with [confirmations] non-null -- seen, and confirmed once it is at
+ * least one deep.
+ */
+ suspend fun recordChain(database: BennuDatabase, txid: String, confirmations: Int?, broadcastAt: Instant? = null, at: Instant = Clock.System.now()) {
+ val spend = database.memberWalletDao().getSpend(txid) ?: return
+ val updated = spend.copy(
+ broadcastAt = broadcastAt ?: spend.broadcastAt,
+ seenAt = spend.seenAt ?: at.takeIf { confirmations != null },
+ confirmedAt = spend.confirmedAt ?: at.takeIf { (confirmations ?: 0) >= 1 },
+ )
+ if (updated != spend) database.memberWalletDao().upsertSpend(updated)
+ }
+
+ // ---- The group's side ------------------------------------------------
+
+ /**
+ * Every certificate [chatRoomId] holds that verifies as its own: the member
+ * wallets this group guards, newest first. One per wallet -- the `d` tag makes
+ * two certificates for one wallet replacements, and they say the same thing.
+ */
+ suspend fun certificatesOf(database: BennuDatabase, chatRoomId: String): List =
+ database.groupSignedEventDao()
+ .getByChatRoomIdAndKind(chatRoomId, MemberWalletCertificateEvent.KIND)
+ .mapNotNull { MemberWalletCertificateEvent.verify(it.toEvent(), chatRoomId) }
+ .sortedByDescending { it.certificate.createdAt }
+ .distinctBy { it.walletId }
+
+ /**
+ * Every request a member has put into [chatRoomId] that checks out and asks
+ * this room, newest first, one per wallet.
+ */
+ suspend fun requestsIn(database: BennuDatabase, chatRoomId: String): List =
+ database.marmotInnerEventDao()
+ .getByChatRoomAndKinds(chatRoomId, listOf(MemberWalletRequestEvent.KIND))
+ .mapNotNull { MemberWalletRequestEvent.carried(it.asEvent()) }
+ .mapNotNull { MemberWalletRequestEvent.verified(it) }
+ .filter { it.reading.groupChatRoomId.equals(chatRoomId, ignoreCase = true) }
+ .sortedByDescending { it.request.createdAt }
+ .distinctBy { it.reading.walletId }
+
+ /**
+ * The event id a certificate for [request] signed in [chatRoomId] will have.
+ * The room's id is the author, and the request fixes everything else -- which
+ * is what lets two sponsors find each other's session.
+ */
+ fun certificateIdFor(chatRoomId: String, request: Event): HexKey {
+ val template = MemberWalletCertificateEvent.template(request)
+ return EventHasher.hashId(chatRoomId.lowercase(), template.createdAt, template.kind, template.tags, template.content)
+ }
+
+ /** The session open in [chatRoomId] over [request]'s certificate, if one is still running. */
+ suspend fun openSessionFor(database: BennuDatabase, chatRoomId: String, request: Event): FrostSigningSession? {
+ val certificateId = certificateIdFor(chatRoomId, request)
+ return database.frostSigningSessionDao().getSessionsForChatRoom(chatRoomId)
+ .filter { it.stage != FrostSigningStage.FAILED && it.stage != FrostSigningStage.COMPLETE }
+ .firstOrNull { session -> database.frostSigningSessionDao().getItems(session.id).any { it.eventId == certificateId } }
+ }
+
+ /** Whether the latest session over [request]'s certificate in [chatRoomId] failed -- declined, or abandoned. */
+ suspend fun wasNotSigned(database: BennuDatabase, chatRoomId: String, request: Event): Boolean {
+ val certificateId = certificateIdFor(chatRoomId, request)
+ val sessions = database.frostSigningSessionDao().getSessionsForChatRoom(chatRoomId)
+ .filter { session -> database.frostSigningSessionDao().getItems(session.id).any { it.eventId == certificateId } }
+ return sessions.isNotEmpty() && sessions.all { it.stage == FrostSigningStage.FAILED }
+ }
+
+ /**
+ * The requests in [chatRoomId] still waiting for somebody to put them to the
+ * group: no certificate for the wallet, and no session running over one.
+ */
+ suspend fun awaitingSponsor(database: BennuDatabase, chatRoomId: String): List {
+ val certified = certificatesOf(database, chatRoomId).map { it.walletId }.toSet()
+ return requestsIn(database, chatRoomId)
+ .filter { it.reading.walletId !in certified }
+ .filter { openSessionFor(database, chatRoomId, it.request) == null }
+ }
+
+ /**
+ * Why [chatRoomId], signing as [thresholdPublicKey], should not sign a
+ * proposed member wallet [certificate] -- or null when it may.
+ *
+ * The check every signer makes before agreeing to guard a member's wallet,
+ * refused before anything is shown, for the reason a mismatched id is:
+ *
+ * - it is not exactly the certificate the request it carries asks for, or
+ * the request does not check out, or it asked another group;
+ * - the person asking is not a member of this room;
+ * - its guardians are not the ones this group grants: `SubgroupManager.grantFor`
+ * with the wallet's id in a child room's place -- the same list a guarded
+ * subgroup of this group would get. A coordinator who slipped a key in,
+ * dropped an ancestor or reordered the leaves is refused here.
+ *
+ * The group's own wallet policy decides only which keys the grant carries.
+ * It never refuses a member's wallet: an unguarded group guards its members
+ * with its own key alone. `docs/member-guarded-wallets.md`, Phase 7.
+ *
+ * The group's *member-wallet* policy decides whether it guards one at all,
+ * and the delay on its own leaf: [judgePolicy], `docs/member-wallet-delay.md`.
+ */
+ suspend fun refuseCertificate(
+ database: BennuDatabase,
+ chatRoomId: String,
+ thresholdPublicKey: HexKey,
+ certificate: Event,
+ ): String? {
+ val verified = MemberWalletCertificateEvent.verify(certificate, chatRoomId, signed = false)
+ ?: return "is not a certificate this group could have been asked for"
+
+ val member = database.participantDao().findParticipantsByChatRoomId(chatRoomId)
+ .any { it.participantPublicKey.equals(verified.memberPublicKey, ignoreCase = true) }
+ if (!member) return "was asked by somebody who is not a member"
+
+ val delay = when (val judged = judgePolicy(database, chatRoomId, verified.request)) {
+ is PolicyJudgement.Refused -> return judged.reason
+ is PolicyJudgement.At -> judged.delay
+ }
+
+ val expected = runCatching { SubgroupManager.grantFor(database, chatRoomId, thresholdPublicKey, verified.walletId, delay) }.getOrNull()
+ ?: return "grants keys this device cannot check"
+ return if (verified.account.guardians == expected) null else "grants guardian keys this group does not"
+ }
+
+ /** What a signer makes of the policy a request was built under: the delay to judge it at, or why not. */
+ sealed interface PolicyJudgement {
+ data class At(val delay: Long) : PolicyJudgement
+ data class Refused(val reason: String, val why: Why) : PolicyJudgement
+ }
+
+ /** Why a request's policy will not do, said as a reason the member's screen can name. */
+ enum class Why {
+ /** Built before policies, or under none: the group never said it guards members' wallets. */
+ NO_POLICY,
+
+ /** It carries a policy, but not an open one the group signed. */
+ NOT_THE_GROUPS,
+
+ /** The group has a newer delay; the request was built under an older one. */
+ DELAY_CHANGED,
+
+ /** The group has since stopped guarding members' wallets. */
+ CLOSED,
+ }
+
+ /**
+ * The delay [chatRoomId]'s own leaf must have in the wallet [request] asks
+ * for, or why the request cannot be signed -- `docs/member-wallet-delay.md`,
+ * D6. `held` is this device's newest policy, `carried` the one the request
+ * was built under:
+ *
+ * - carried, an open policy the group signed, and nothing held newer: at
+ * its delay. Newer than what this device holds is fine -- the group
+ * signed it, and this device missed it;
+ * - carried, but a newer open one held: stale, *asked under a delay the
+ * group has since changed*;
+ * - carried, but a newer closed one held: stale, *the group has stopped*;
+ * - carried and not an open policy the group signed: refused;
+ * - none carried: refused. A request from before policies never asked for
+ * the delay the group chose, or of a group that chose to guard members.
+ *
+ * Read from the request, not the certificate, so the member's screen and a
+ * sponsor's device can ask it before there is a certificate to check.
+ */
+ suspend fun judgePolicy(database: BennuDatabase, chatRoomId: String, request: Event): PolicyJudgement {
+ val reading = MemberWalletRequestEvent.read(request)
+ ?: return PolicyJudgement.Refused("is not a request this group could have been asked", Why.NOT_THE_GROUPS)
+ val carried = reading.policy
+ ?: return PolicyJudgement.Refused("does not say the group guards members' wallets", Why.NO_POLICY)
+ val open = MemberWalletPolicyEvent.verify(carried, chatRoomId) as? MemberWalletPolicyEvent.Policy.Open
+ ?: return PolicyJudgement.Refused("carries a policy this group did not sign open", Why.NOT_THE_GROUPS)
+
+ val held = policyFor(database, chatRoomId)
+ if (held != null && MemberWalletPolicyEvent.ORDER.compare(held, open) > 0) {
+ return when (held) {
+ is MemberWalletPolicyEvent.Policy.Open ->
+ PolicyJudgement.Refused("was asked under a delay the group has since changed", Why.DELAY_CHANGED)
+ is MemberWalletPolicyEvent.Policy.Closed ->
+ PolicyJudgement.Refused("was asked of a group that has since stopped guarding members' wallets", Why.CLOSED)
+ }
+ }
+ return PolicyJudgement.At(open.delay)
+ }
+
+ /**
+ * Puts [request] to [groupRoom]'s quorum, as [userPublicKey]: a signing
+ * session over the certificate the request determines, which this device's
+ * proposing counts as approving. Returns the session already running over it
+ * instead, when another signer got there first.
+ *
+ * @throws IllegalStateException when the wallet is already certified, or this
+ * device would refuse the certificate itself -- a quorum should never be asked
+ * for what the proposer's own device knows is wrong.
+ */
+ suspend fun putToGroup(database: BennuDatabase, groupRoom: LocalChatRoom, userPublicKey: HexKey, request: Event): FrostSigningSession {
+ val chatRoomId = groupRoom.chatRoom.id
+ val reading = MemberWalletRequestEvent.verified(request)?.reading
+ ?: throw IllegalStateException("This request does not check out")
+ check(certificatesOf(database, chatRoomId).none { it.walletId == reading.walletId }) { "This group already guards that wallet" }
+ openSessionFor(database, chatRoomId, request)?.let { return it }
+
+ val thresholdPublicKey = GroupWalletManager.thresholdKeyFor(database, chatRoomId)
+ ?: throw IllegalStateException("This group has no shared key to sign with")
+ val template = MemberWalletCertificateEvent.template(request)
+ val unsigned = Event(certificateIdFor(chatRoomId, request), chatRoomId.lowercase(), template.createdAt, template.kind, template.tags, template.content, "")
+ refuseCertificate(database, chatRoomId, thresholdPublicKey, unsigned)?.let { reason ->
+ throw IllegalStateException("This group would refuse it: it $reason")
+ }
+
+ logger.i("Putting ${reading.memberPublicKey.take(8)}'s wallet ${reading.walletId.take(8)} to $chatRoomId")
+ return FrostSigningManager.proposeSigning(
+ database = database,
+ localChatRoom = groupRoom,
+ userPublicKey = userPublicKey,
+ kind = template.kind,
+ tags = template.tags,
+ content = template.content,
+ createdAt = template.createdAt,
+ )
+ }
+
+ // ---- Shown from the group, and from the person -----------------------
+
+ /** A member's wallet as the guarding group's page lists it: certified, or asked for and not yet put to the group. */
+ data class GroupMemberWallet(
+ val walletId: String,
+ val ownerPublicKey: HexKey,
+ /** The member's profile name on this device, or null. */
+ val ownerName: String?,
+ val label: String?,
+ val request: Event,
+ val isCertified: Boolean,
+ )
+
+ /**
+ * The member wallets [chatRoomId] guards, and the requests still waiting for
+ * a signer to put them to it -- the group's page's *Members' guarded
+ * wallets*, which is never mixed into its subgroups: a row there is a
+ * person, not a room.
+ */
+ suspend fun memberWalletsOf(database: BennuDatabase, chatRoomId: String): List {
+ suspend fun nameOf(publicKey: HexKey) = database.profileDao().getProfileByPublicKey(publicKey)?.humanReadableNameOrPubkey()
+ val certified = certificatesOf(database, chatRoomId).map {
+ GroupMemberWallet(it.walletId, it.memberPublicKey, nameOf(it.memberPublicKey), it.label, it.request, isCertified = true)
+ }
+ val waiting = awaitingSponsor(database, chatRoomId).map {
+ GroupMemberWallet(it.reading.walletId, it.reading.memberPublicKey, nameOf(it.reading.memberPublicKey), it.reading.label, it.request, isCertified = false)
+ }
+ return certified + waiting
+ }
+
+ /**
+ * Every guarded wallet of [ownerPublicKey]'s that a group [viewerPublicKey]
+ * is in on this device guards, as that group holds it -- the person's page's *Wallets your
+ * groups guard*. One entry per guarding group: a wallet guarded by a group
+ * and its parent, both here, is two ways in, each spending through its own
+ * leaf.
+ */
+ suspend fun guardedByGroupsHere(database: BennuDatabase, viewerPublicKey: HexKey, ownerPublicKey: HexKey): List =
+ database.chatRoomDao().getChatRoomListByUserPublicKey(viewerPublicKey)
+ .filter { it.chatRoom.mlsGroupState != null }
+ .flatMap { room ->
+ val wallets = runCatching { GuardianManager.guardedWalletsOf(database, room.chatRoom.id) }.getOrDefault(emptyList())
+ .filter { (it.subject as? GuardianManager.GuardedSubject.Member)?.ownerPublicKey.equals(ownerPublicKey, ignoreCase = true) }
+ if (wallets.isEmpty()) return@flatMap emptyList()
+ val canSpend = FrostSigningManager.canSign(database, room.chatRoom.id)
+ wallets.map { GuardedHere(it, room.chatRoom.subject?.takeIf { name -> name.isNotBlank() }, canSpend) }
+ }
+
+ /** A member's wallet as one of the guarding groups on this device holds it. */
+ data class GuardedHere(
+ val wallet: GuardianManager.GuardedWallet,
+ /**
+ * The holding group's room name here -- the group with a leaf in it, which
+ * is not always the one that directly guards it: that is
+ * `GuardedSubject.Member.guardianName`.
+ */
+ val holderName: String?,
+ /** Whether this device holds a share of that group's key, and so can propose a spend through its leaf. */
+ val canSpend: Boolean,
+ )
+
+ /**
+ * One of a member's wallets on their page, with every group here that holds
+ * a leaf in it -- `docs/member-wallet-guarding-group.md`, D7. The page used to
+ * draw a row per holder, so a wallet held by a group and its parent appeared
+ * twice, each row calling its holder the guardian.
+ */
+ data class GuardedHereWallet(
+ val walletId: String,
+ val label: String?,
+ /** The group that directly guards it, as any holder here can name it, or null. */
+ val guardianName: String?,
+ /** Where no holder can name it: a group it is known to sit below, or null. */
+ val below: String?,
+ /** The groups here holding a leaf in it, nearest first. */
+ val holders: List,
+ )
+
+ /** [rows] -- one per holding group, as [guardedByGroupsHere] gives them -- as one entry per wallet. */
+ fun byWallet(rows: List): List =
+ rows.groupBy { it.wallet.descendantChatRoomId.lowercase() }.map { (_, held) ->
+ val holders = held.sortedBy { it.wallet.position }
+ val members = holders.mapNotNull { it.wallet.subject as? GuardianManager.GuardedSubject.Member }
+ GuardedHereWallet(
+ walletId = holders.first().wallet.descendantChatRoomId,
+ label = members.firstNotNullOfOrNull { it.label },
+ guardianName = members.firstNotNullOfOrNull { it.guardianName },
+ // The nearest holder's own child it sits under, or the holder
+ // itself: either is a group it is truly below.
+ below = holders.firstNotNullOfOrNull { holder ->
+ (holder.wallet.subject as? GuardianManager.GuardedSubject.Member)?.branchName ?: holder.holderName?.takeUnless { holder.wallet.isGuardedHere }
+ },
+ holders = holders,
+ )
+ }
+
+ private suspend fun noticesIn(database: BennuDatabase, chatRoomId: String): List =
+ database.marmotInnerEventDao()
+ .getByChatRoomAndKinds(chatRoomId, listOf(GroupKeyNoticeEvent.KIND))
+ .map { it.asEvent() }
+
+ /**
+ * A stored inner event as the event it was, unsigned: an inner event's
+ * authority is the MLS frame it arrived in, not a signature, so `sig` is
+ * empty here as it is everywhere inner events are read back.
+ */
+ internal fun MarmotInnerEvent.asEvent(): Event =
+ Event(id = id, pubKey = publicKey, createdAt = createdAt.epochSeconds, kind = kind, tags = tags, content = content, sig = "")
+
+ /**
+ * Queues one inner event in [chatRoomId] for the outbound pipeline, the way
+ * every inner event is: a row, which `encryptAndSendMarmotInnerEvent` sends.
+ */
+ internal suspend fun queue(
+ database: BennuDatabase,
+ chatRoomId: String,
+ userPublicKey: HexKey,
+ tags: Array>,
+ content: String,
+ kind: Int = GroupKeyNoticeEvent.KIND,
+ createdAt: Instant = Clock.System.now(),
+ ): HexKey {
+ val id = EventHasher.hashId(userPublicKey, createdAt.epochSeconds, kind, tags, content)
+ database.marmotInnerEventDao().upsert(
+ MarmotInnerEvent(
+ id = id,
+ publicKey = userPublicKey,
+ kind = kind,
+ createdAt = createdAt,
+ tags = tags,
+ content = content,
+ chatRoomId = chatRoomId,
+ )
+ )
+ return id
+ }
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/SubgroupManager.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/SubgroupManager.kt
index c6bee971..21f14eb4 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/SubgroupManager.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/SubgroupManager.kt
@@ -1,5 +1,10 @@
package com.machankura.bennu.compose.managers
+import com.machankura.bennu.compose.nostr.frost.GroupKeyStateEvent
+import com.machankura.bennu.compose.database.model.subgroupWalletPolicy
+import com.machankura.bennu.compose.nostr.subgroup.isDecided
+import com.machankura.bennu.compose.nostr.subgroup.SubgroupWalletPolicy
+import com.machankura.bennu.compose.nostr.subgroup.WalletPolicyReading
import co.touchlab.kermit.Logger
import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip01Core.core.HexKey
@@ -193,6 +198,21 @@ object SubgroupManager {
* A session of one, never batched, for the reason `GroupKeyStateManager.propose`
* gives: a batch is only as available as its worst item, and everything after
* this depends on it.
+ *
+ * The wallet policy comes off [key], the child's ceremony, where the picker
+ * put it and every admin was shown it -- never from a caller, for the reason
+ * the key does not. `docs/subgroup-wallet-policy.md`:
+ *
+ * | ceremony's policy | parent's own | certificate |
+ * |-------------------|---------------------|-------------------------------|
+ * | guarded | any | the grant, `guarded` |
+ * | unguarded | not guarded | no keys, `unguarded` |
+ * | unguarded | guarded | refused: D4 |
+ * | none (older) | not guarded | the grant, no policy -- today |
+ * | none (older) | guarded | the grant, `guarded` |
+ *
+ * @throws IllegalStateException for an unguarded ceremony under a guarded
+ * parent, with the reason and the remedy
*/
suspend fun proposeBirthCertificate(
database: BennuDatabase,
@@ -229,6 +249,45 @@ object SubgroupManager {
"$parentChatRoomId has already certified $subgroupChatRoomId"
}
+ // What the child's wallet is to be. A guarded parent can only make guarded
+ // subgroups, and every one of its signers refuses anything else -- so an
+ // unguarded ceremony under one is stranded, and proposing it would only
+ // spend a quorum's attention. It is not quietly certified as guarded
+ // instead: its admins joined on the understanding it would not be, and
+ // every child signer refuses a certificate that says otherwise. An older
+ // build's ceremony carried no policy and showed its admins none, so under
+ // a guarded parent the certificate says the only thing its signers accept.
+ val parentGuarded = walletPolicyOf(database, parentChatRoomId).isDecided(SubgroupWalletPolicy.GUARDED)
+ val walletPolicy = when (key.subgroupWalletPolicy) {
+ SubgroupWalletPolicy.UNGUARDED -> {
+ check(!parentGuarded) {
+ "This group is guarded, so its subgroups are too. Start the subgroup again: " +
+ "its admins joined it as unguarded."
+ }
+ SubgroupWalletPolicy.UNGUARDED
+ }
+ SubgroupWalletPolicy.GUARDED -> SubgroupWalletPolicy.GUARDED
+ null -> SubgroupWalletPolicy.GUARDED.takeIf { parentGuarded }
+ }
+
+ // The parent's guardian keys for the child: its own, and the ones its
+ // ancestors granted it -- or none, for an unguarded child, whose
+ // certificate then grants nothing to it or to anything beneath it. Every
+ // signer recomputes this list and refuses a certificate carrying any
+ // other -- see [refuseCertificate].
+ val guardians = if (walletPolicy == SubgroupWalletPolicy.UNGUARDED) {
+ emptyList()
+ } else {
+ val parentKey = FrostSigningManager.completedKey(database, parentChatRoomId)?.thresholdPublicKey
+ ?: throw IllegalStateException("$parentChatRoomId has no key to grant a guardian key under")
+ // The parent's own leaf's delay as its coordinator chose it, or the
+ // default an older build's ceremony would have written. Every
+ // inherited key keeps the delay its own ancestor chose.
+ // docs/guardian-delay.md.
+ grantFor(database, parentChatRoomId, parentKey, subgroupChatRoomId, key.guardianDelay ?: GuardianDerivation.DEFAULT_DELAY)
+ ?: throw IllegalStateException("$parentChatRoomId's own certificate carries guardian keys this build cannot read")
+ }
+
logger.i("Asking $parentChatRoomId to certify $subgroupChatRoomId as its subgroup")
return FrostSigningManager.proposeSigning(
@@ -242,12 +301,129 @@ object SubgroupManager {
thresholdPublicKey = thresholdPublicKey,
adminPublicKeys = adminPublicKeys,
name = subgroupName,
- path = path
+ path = path,
+ guardians = guardians,
+ walletPolicy = walletPolicy
),
content = subgroupChatRoomId
)
}
+ /**
+ * The guardian keys [chatRoomId]'s own certificate grants it, nearest first:
+ * empty for a group with no parent, or whose certificate predates guardian
+ * keys -- either way it grants only its own key onward -- and null when the
+ * certificate carries keys this build cannot read.
+ *
+ * Off the verified key state, which only holds a certificate
+ * `GroupKeyStateManager.stateFrom` checked.
+ */
+ suspend fun guardiansOf(database: BennuDatabase, chatRoomId: String): List? {
+ val certificate = database.groupKeyStateDao().getByChatRoomId(chatRoomId)
+ ?.birthCertificateJson
+ ?.let { Event.fromJsonOrNull(it) }
+ ?: return emptyList()
+ return SubgroupBirthCertificateEvent.parseGuardians(certificate.tags)
+ }
+
+ /**
+ * What [chatRoomId]'s own certificate says of its wallet --
+ * `docs/subgroup-wallet-policy.md` -- or null for a room with no certificate:
+ * a root group, or a member who holds no key state for it.
+ *
+ * Off the verified key state, like [guardiansOf]. A state whose certificate
+ * carries a policy that does not read is dropped before it is stored, so a
+ * certificate held here always reads; if one somehow does not, it is logged
+ * and read as none rather than guessed at.
+ *
+ * The one reader the picker, every parent signer and the wallet screen share,
+ * so the three cannot disagree about what a group is.
+ */
+ suspend fun walletPolicyOf(database: BennuDatabase, chatRoomId: String): WalletPolicyReading? {
+ val certificate = database.groupKeyStateDao().getByChatRoomId(chatRoomId)
+ ?.birthCertificateJson
+ ?.let { Event.fromJsonOrNull(it) }
+ ?: return null
+ return SubgroupBirthCertificateEvent.parseWalletPolicy(certificate.tags)
+ ?: run {
+ logger.w("$chatRoomId's certificate carries a wallet policy that does not read")
+ null
+ }
+ }
+
+ /**
+ * What [parentChatRoomId], signing as [thresholdPublicKey], grants
+ * [subgroupChatRoomId]: `GuardianDerivation.grant` over the keys its own
+ * certificate carries. Null when those cannot be read.
+ */
+ suspend fun grantFor(
+ database: BennuDatabase,
+ parentChatRoomId: String,
+ thresholdPublicKey: HexKey,
+ subgroupChatRoomId: String,
+ delay: Long = GuardianDerivation.DEFAULT_DELAY
+ ): List? {
+ val inherited = guardiansOf(database, parentChatRoomId) ?: return null
+ return GuardianDerivation.grant(thresholdPublicKey, parentChatRoomId, inherited, subgroupChatRoomId, delay)
+ }
+
+ /**
+ * Why [chatRoomId] should not sign a proposed certificate, or null when it
+ * may: its guardian keys are not the ones the group grants, or its wallet
+ * policy is not one the group may make.
+ *
+ * The check every parent signer makes before agreeing to guard a child, or
+ * to certify one unguarded. A coordinator who slipped a key of their own into
+ * the list, dropped an ancestor, or reordered the leaves would be asking the
+ * group to vouch for a wallet tree it did not make; one who certified an
+ * unguarded child of a guarded group would be taking a branch out of the
+ * reach of every group above it. Either way the proposal is refused rather
+ * than shown.
+ *
+ * The group's own policy is read off this device's verified key state, never
+ * off the proposal. Under a guarded group anything but a guarded certificate
+ * is refused -- an undecided one included, since an undecided child is
+ * offered the plain wallet D4 exists to take away. A certificate with no keys
+ * and no policy from an older proposer grants nothing, and is still signable
+ * under any other group. See `docs/subgroup-wallet-policy.md`.
+ */
+ suspend fun refuseCertificate(
+ database: BennuDatabase,
+ chatRoomId: String,
+ thresholdPublicKey: HexKey,
+ certificate: Event
+ ): String? {
+ val proposed = SubgroupBirthCertificateEvent.parseGuardians(certificate.tags)
+ ?: return "carries a guardian key that does not read"
+ val policy = SubgroupBirthCertificateEvent.parseWalletPolicy(certificate.tags)
+ ?: return "carries a wallet policy that does not read, or that its keys contradict"
+
+ if (walletPolicyOf(database, chatRoomId).isDecided(SubgroupWalletPolicy.GUARDED) &&
+ !policy.isDecided(SubgroupWalletPolicy.GUARDED)
+ ) {
+ return "would make an unguarded subgroup of a guarded group"
+ }
+
+ // Unguarded, or an older proposer's certificate with no keys: grants
+ // nothing. Phase 1's read has already refused an unguarded one with keys.
+ if (proposed.isEmpty()) return null
+
+ val subgroupChatRoomId = SubgroupBirthCertificateEvent.parseSubgroupChatRoomId(certificate.tags)
+ ?: return "names no subgroup"
+ // The parent's own leaf's delay is the proposal's -- the coordinator chose
+ // it, in range, or the tag would not have read -- and everything else is
+ // recomputed: the keys, their order, and every inherited key's delay,
+ // which has to be the one this group's own certificate carries. A
+ // proposer cannot shorten or lengthen an ancestor's wait in the child's
+ // wallet. docs/guardian-delay.md.
+ val expected = runCatching {
+ grantFor(database, chatRoomId, thresholdPublicKey, subgroupChatRoomId, proposed.first().delay)
+ }.getOrNull()
+ ?: return "grants keys this device cannot check"
+
+ return if (proposed == expected) null else "grants guardian keys this group does not"
+ }
+
/**
* The newest certificate by [parentChatRoomId] that actually certifies
* [subgroupChatRoomId], or null if this device holds none.
@@ -315,6 +491,12 @@ object SubgroupManager {
"cannot name a parent yet"
)
+ // Every other child signer refuses a certificate under another policy, so
+ // proposing it would only stall a quorum -- see [refuseKeyState].
+ refusePolicy(key, certificate.toEvent())?.let { reason ->
+ throw IllegalStateException("$parentChatRoomId's certificate for $subgroupChatRoomId $reason")
+ }
+
return GroupKeyStateManager.propose(
database = database,
localChatRoom = ceremonyRoom,
@@ -328,6 +510,41 @@ object SubgroupManager {
)
}
+ /**
+ * Why a child signer should not sign [keyState] under [key], its own
+ * ceremony, or null when it may: the birth certificate it carries decides a
+ * wallet policy other than the one the ceremony announced.
+ *
+ * Every admin was shown that policy at the join gate, so joining was agreeing
+ * to it. A certificate proposed later under another -- by a parent admin
+ * resuming the flow, or one whose device read the parent differently -- would
+ * be the child signing a decision none of its members agreed to. A ceremony
+ * that announced none, from an older build, has nothing to hold the
+ * certificate to. `docs/subgroup-wallet-policy.md`, Phase 5.
+ */
+ fun refuseKeyState(key: DkgSession, keyState: Event): String? {
+ val certificate = GroupKeyStateEvent.parseBirthCertificate(keyState.tags) ?: return null
+ return refusePolicy(key, certificate)
+ }
+
+ private fun refusePolicy(key: DkgSession, certificate: Event): String? {
+ val agreed = key.subgroupWalletPolicy ?: return null
+ val certified = SubgroupBirthCertificateEvent.parseWalletPolicy(certificate.tags)
+ if (!certified.isDecided(agreed)) {
+ return "carries a certificate whose wallet policy is not the one this group was made under ($agreed)"
+ }
+
+ // And the delay on the parent's own leaf, which the admins were shown
+ // at the same gate. docs/guardian-delay.md.
+ val agreedDelay = key.guardianDelay ?: return null
+ val certifiedDelay = SubgroupBirthCertificateEvent.parseGuardians(certificate.tags)?.firstOrNull()?.delay
+ return if (certifiedDelay == agreedDelay) {
+ null
+ } else {
+ "carries a certificate whose guardian delay is not the one this group was made under ($agreedDelay blocks)"
+ }
+ }
+
/**
* A subgroup as the parent's own record has it, plus whatever this device
* happens to hold about it.
@@ -351,6 +568,21 @@ object SubgroupManager {
val keyState: GroupKeyState?,
) {
/** Whether this device can open the subgroup, rather than only know of it. */
+ /**
+ * What the parent decided about the subgroup's wallet when it certified
+ * it -- `docs/subgroup-wallet-policy.md`. Founding history like [name]:
+ * decided once, and never changed by anything after.
+ */
+ val walletPolicy: WalletPolicyReading?
+ get() = SubgroupBirthCertificateEvent.parseWalletPolicy(certificate.tags)
+
+ /**
+ * The delay the parent gave its own leaf in the subgroup's wallet, or
+ * null for a certificate that grants no keys -- `docs/guardian-delay.md`.
+ */
+ val guardianDelay: Long?
+ get() = SubgroupBirthCertificateEvent.parseGuardians(certificate.tags)?.firstOrNull()?.delay
+
val isJoined: Boolean get() = room != null
}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/TranslationScaffold.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/TranslationScaffold.kt
deleted file mode 100644
index 83081bf8..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/managers/TranslationScaffold.kt
+++ /dev/null
@@ -1,92 +0,0 @@
-package com.machankura.bennu.compose.managers
-
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.machankura.bennu.compose.database.model.MantraChapter
-import com.machankura.bennu.compose.database.model.MantraTranslationChapter
-import com.machankura.bennu.compose.nostr.nip30303.TranslationChapterEvent
-
-/**
- * The rows that join a translation to the chapters it is a translation of.
- *
- * A translation chapter carries no words. It is `(translation, chapter,
- * position)` and nothing else, and it exists so that a translated chunk has
- * somewhere to hang: a translation without one for a chapter is a translation
- * that chapter cannot be worked on in.
- *
- * Both ends of that join arrive on their own schedule -- a chapter is signed
- * into an artifact that already has translations, a translation is started on
- * an artifact that already has chapters -- so the same scaffolding is built
- * from either side and, when the two miss each other, afterwards. One function
- * for all three, because three copies of a cross product is three chances to
- * disagree about what a translation covers.
- */
-object TranslationScaffold {
-
- /**
- * A source chapter, reduced to what a translation chapter needs of it:
- * which chapter, and where it sits.
- *
- * Taken as this rather than as a [MantraChapter] because the chapter is not
- * always a row yet. When a chapter is signed into an artifact, the
- * scaffolding goes out in the same breath as the chapter itself, against an
- * id that exists only as the unsigned event a session is about to sign.
- */
- data class SourceChapter(
- val id: HexKey,
- val index: Int,
- ) {
- companion object {
- fun of(chapter: MantraChapter) = SourceChapter(id = chapter.id, index = chapter.index)
- }
- }
-
- /**
- * A translation chapter for every pair of [translationArtifactVersionIds]
- * and [chapters], in that nesting: a translation's chapters stay together
- * and in reading order.
- *
- * The order is the order a session will sign them in and the order they
- * will be applied in, so it is fixed here rather than left to a caller.
- *
- * [createdAt] is stamped on all of them rather than read per event, so that
- * a scaffolding proposed as one act reads as one -- the timestamp of the
- * chapter or the translation that occasioned it, not of whichever moment
- * each template happened to be built in.
- */
- fun chaptersOf(
- translationArtifactVersionIds: List,
- chapters: List,
- createdAt: Long,
- ): List> =
- translationArtifactVersionIds.flatMap { translationArtifactVersionId ->
- chapters.map { chapter ->
- TranslationChapterEvent.build(
- translationArtifactVersionId = translationArtifactVersionId,
- chapterId = chapter.id,
- // The source chapter's own position, never this list's: a
- // catch-up proposes a subset, so counting the list would
- // renumber the chapters it happens to be filling in.
- index = chapter.index,
- createdAt = createdAt,
- )
- }
- }
-
- /**
- * The source chapters a translation has nothing for yet.
- *
- * Matched on the source chapter each translation chapter names rather than
- * on how many there are of each. A translation that is missing its second
- * chapter and has picked up its third is not a translation that is missing
- * its last one, and a count would say it was.
- */
- fun chaptersMissingFrom(
- translationChapters: List,
- sourceChapters: List,
- ): List {
- val covered = translationChapters.mapTo(mutableSetOf()) { it.chapterId }
-
- return sourceChapters.filterNot { it.id in covered }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/network/relays/EventPublishTransport.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/network/relays/EventPublishTransport.kt
deleted file mode 100644
index a6a8fd2b..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/network/relays/EventPublishTransport.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.machankura.bennu.compose.network.relays
-
-import kotlinx.coroutines.flow.Flow
-import com.machankura.bennu.compose.database.model.NostrEvent
-import com.machankura.bennu.compose.network.dto.RelayDTO
-
-/**
- * The slice of the relay layer a one-off publish needs.
- *
- * The same cut [LiveSubscriptionTransport] makes and for the same reason:
- * [RelaysSocketManager] starts collecting relay lists in its `init` and cannot be
- * stood up in a test, so a screen that hands it an event would otherwise have no
- * way to check what it does with the answers.
- *
- * Everything the app publishes as *itself* goes through the
- * `BroadcastNostrEventRequest` queue instead, which is durable and retried. This
- * exists for the one thing that must not: an event the group signed. The queue
- * hangs off a `NostrEvent` row, and a row for the group's event would put its post
- * into the home feed and offer it to every relay the sync loop reconciles with --
- * see `BroadcastGroupSignedEventViewModel` for the whole of that argument.
- */
-interface EventPublishTransport {
-
- /**
- * Sends [nostrEvent] to each of [relays], opening a socket to any it does not
- * already hold, and answers once per relay: the relay's OK, its rejection, or
- * the error that stopped it being asked.
- *
- * @see RelayPool.publishEvent
- */
- @Throws(com.machankura.bennu.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
- suspend fun publishEvent(nostrEvent: NostrEvent, relays: Set): Flow
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/network/relays/RelaysSocketManager.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/network/relays/RelaysSocketManager.kt
index 1c85c200..1b45855e 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/network/relays/RelaysSocketManager.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/network/relays/RelaysSocketManager.kt
@@ -32,7 +32,7 @@ class RelaysSocketManager(
private val relayRepository: com.machankura.bennu.compose.repository.RelayRepository,
/** Injectable so that a test can drive the identity observer on a dispatcher it controls. */
private val scope: CoroutineScope = CoroutineScope(Dispatchers.IO),
-) : LiveSubscriptionTransport, EventPublishTransport {
+) : LiveSubscriptionTransport {
val logger = Logger.withTag("RelaysSocketManager")
private val relayPoolsMutex = Mutex()
@@ -116,7 +116,7 @@ class RelaysSocketManager(
}
@Throws(com.machankura.bennu.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
- override suspend fun publishEvent(nostrEvent: com.machankura.bennu.compose.database.model.NostrEvent, relays: Set): Flow {
+ suspend fun publishEvent(nostrEvent: com.machankura.bennu.compose.database.model.NostrEvent, relays: Set): Flow {
logger.d("publishEvent: $nostrEvent")
return relayPool.publishEvent(
nostrEvent = nostrEvent,
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/GroupEventProposal.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/GroupEventProposal.kt
deleted file mode 100644
index 8d65a414..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/GroupEventProposal.kt
+++ /dev/null
@@ -1,177 +0,0 @@
-package com.machankura.bennu.compose.nostr
-
-import com.machankura.bennu.compose.network.serialization.CommonJson
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.Kind
-import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent
-import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent
-import kotlinx.serialization.json.JsonArray
-import kotlinx.serialization.json.JsonElement
-import kotlinx.serialization.json.JsonObject
-import kotlinx.serialization.json.JsonPrimitive
-import kotlinx.serialization.json.contentOrNull
-import kotlinx.serialization.json.intOrNull
-
-/**
- * An unsigned event a member pasted for the group to sign, read and checked
- * before a quorum is asked for it.
- *
- * The typed editors -- the profile form, the post composer, the relay
- * editor -- each build one kind of event and know what it needs. This is the
- * untyped way in: the event as JSON, the way another tool prints it, pasted
- * whole. What comes out is the same thing the editors
- * produce, a kind, tags and content for `FrostSigningRepository.proposeSigning`,
- * and it is filed the same way when the quorum signs: `FrostSigningManager.complete`
- * records it as a `GroupSignedEvent` and the group's screen reads its profile,
- * posts and relay lists straight off those by kind.
- *
- * ### What is ignored
- *
- * `id`, `pubkey`, `sig` and `created_at`. The group is the author -- the
- * session resolves the room's key and hashes the id over it -- and the time is
- * when the session opens, which is what every typed editor does too. A pasted
- * `created_at` in particular has to go: the kinds here are replaceable or
- * addressable, so a stale one would make the new event *older* than the last and
- * the proposal would look as though it did nothing. The screen says so.
- *
- * ### What is refused, and why before rather than after
- *
- * Only kinds the group's screen has a place for, and only events that place
- * would accept. A signature is the most expensive thing this app does, and the
- * readers refuse rather than repair: a kind 0 whose content is not a profile
- * or a blank post would each be signed, filed and shown nowhere, with nothing
- * to tell the member their quorum was spent on nothing. So every check a reader makes is made here first, on the paste.
- */
-object GroupEventProposal {
- /**
- * The kinds a pasted event may be: exactly the ones the group's screen reads.
- *
- * Not the kinds `ChatMessage.applyInnerEvent` has an arm for. A subgroup
- * certificate or a key state event has invariants a paste cannot be trusted
- * to meet and a place in the room's life that a form is not, and the
- * nip30303 kinds have editors of their own. The line is "has a section on the
- * group's screen", because that is where a member goes to see it landed.
- */
- val ACCEPTED_KINDS: Set =
- setOf(MetadataEvent.KIND, TextNoteEvent.KIND) + GroupRelaySet.KINDS
-
- sealed interface Reading
-
- /** An event the group could sign and the screen could show. */
- class Ready(
- val kind: Kind,
- val tags: Array>,
- val content: String,
- ) : Reading {
- /**
- * The event as the signing screen will describe it, for a preview before
- * the button is pressed. The id, author and signature are placeholders:
- * `ProposedEvent.summarize` reads none of them.
- */
- fun preview(): Event = Event(
- id = "",
- pubKey = "",
- createdAt = 0,
- kind = kind,
- tags = tags,
- content = content,
- sig = "",
- )
- }
-
- /** Why the paste cannot be proposed as it is. */
- sealed interface Refused : Reading {
- data object NotJson : Refused
-
- /** JSON, but an array, a string, a number -- anything but an object. */
- data object NotAnObject : Refused
-
- data object NoKind : Refused
-
- data class KindNotAccepted(val kind: Kind) : Refused
-
- /** `tags` present but not a list of lists of strings. */
- data object TagsMalformed : Refused
-
- /** `content` present but not a string. */
- data object ContentNotText : Refused
-
- /** A kind 0 whose content will not parse as a profile. */
- data object ProfileUnreadable : Refused
-
- /** A kind 1 with nothing to say, which the posts reader would drop. */
- data object PostBlank : Refused
- }
-
- private const val KEY_KIND = "kind"
- private const val KEY_TAGS = "tags"
- private const val KEY_CONTENT = "content"
-
- /** The paste as something the group could sign, or the reason it is not. */
- fun read(json: String): Reading {
- val element = runCatching { CommonJson.parseToJsonElement(json) }.getOrNull()
- ?: return Refused.NotJson
-
- val obj = element as? JsonObject ?: return Refused.NotAnObject
-
- // A number or a numeric string: relays write the former and a hand
- // types either, and there is nothing to be gained by refusing "1".
- val kind = (obj[KEY_KIND] as? JsonPrimitive)?.intOrNull ?: return Refused.NoKind
- if (kind !in ACCEPTED_KINDS) return Refused.KindNotAccepted(kind)
-
- val tags = when (val raw = obj[KEY_TAGS]) {
- null -> emptyArray()
- else -> readTags(raw) ?: return Refused.TagsMalformed
- }
-
- val content = when (val raw = obj[KEY_CONTENT]) {
- null -> ""
- else -> (raw as? JsonPrimitive)?.takeIf { it.isString }?.content
- ?: return Refused.ContentNotText
- }
-
- return when (kind) {
- // An empty kind 0 is a profile the group has wiped, which it is
- // entitled to do; content that is not JSON is not a profile at all.
- // The same line `GroupNostrProfile.of` draws.
- MetadataEvent.KIND -> if (metadataOf(tags, content) == null) {
- Refused.ProfileUnreadable
- } else {
- Ready(kind, tags, content)
- }
-
- // The line `AddGroupPostViewModel.proposePost` draws, for the reason
- // it gives: a blank post cannot be told from a broken one and, kind:1
- // not being replaceable, cannot be un-said.
- TextNoteEvent.KIND -> if (content.isBlank()) {
- Refused.PostBlank
- } else {
- Ready(kind, tags, content)
- }
-
- // A relay list with no relay in it is a list the group has withdrawn,
- // which the relays card shows as "no relays" rather than as nothing.
- else -> Ready(kind, tags, content)
- }
- }
-
- private fun readTags(raw: JsonElement): Array>? {
- val outer = raw as? JsonArray ?: return null
-
- return outer.map { tag ->
- val inner = tag as? JsonArray ?: return null
- inner.map { value ->
- (value as? JsonPrimitive)?.takeIf { it.isString }?.contentOrNull ?: return null
- }.toTypedArray()
- }.toTypedArray()
- }
-
- private fun metadataOf(tags: Array>, content: String) = MetadataEvent(
- id = "",
- pubKey = "",
- createdAt = 0,
- tags = tags,
- content = content,
- sig = "",
- ).contactMetaData()
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/GroupNostrProfile.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/GroupNostrProfile.kt
deleted file mode 100644
index 011964df..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/GroupNostrProfile.kt
+++ /dev/null
@@ -1,196 +0,0 @@
-package com.machankura.bennu.compose.nostr
-
-import com.machankura.bennu.compose.database.model.GroupSignedEvent
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent
-import com.vitorpamplona.quartz.nip01Core.metadata.UserMetadata
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import kotlin.time.Instant
-
-/**
- * The kind:0 a group signed about itself, as the group signed it.
- *
- * A Marmot room's id *is* the nostr pubkey it signs as -- see
- * `docs/shared-key-derivation.md`, where those are one value -- so the group has
- * an identity on nostr whether or not it has ever said anything about it. This is
- * what it says: a name, a picture, a line about what the group is for, authored by
- * the group rather than by whichever member typed it.
- *
- * ### Why this reads off [GroupSignedEvent] and not off `Profile`
- *
- * A `Profile` row hangs off a `NostrEvent` by foreign key, and a group-signed
- * event is not a `NostrEvent`: no member sent it, it never travelled on the wire
- * as itself, and the outbound pipeline would re-author it as its sender and strip
- * the group's signature off. See `GroupSignedEvent`, which exists for exactly the
- * events in that position. So the group's profile lives where the group's other
- * signed statements live, and this is the reading of it.
- *
- * The consequence worth stating: **nothing here reaches a relay by being signed.**
- * A member's kind:0 is published and is how the rest of nostr learns their name; a
- * group's is signed and kept, and every device that followed the signing session
- * -- or was handed the event afterwards -- holds it. It reaches a relay when a
- * member sends it there from `BroadcastGroupSignedEventScreen`, which serialises
- * the signed row directly rather than making a `NostrEvent` row for an event no
- * member authored -- a decision this still does not make.
- *
- * ### What a reading has to earn
- *
- * [GroupSignedEvent.verifies] and nothing less: the author has to be the room, the
- * id has to be the hash of the fields beside it, and the signature has to verify.
- * That is what makes this the *group's* profile rather than a kind:0 that happened
- * to be filed against the room -- and it is checkable from the row alone, with no
- * ceremony or key state to consult first.
- *
- * A room never derived from its group's key signs as the bare threshold key rather
- * than as its own id, so it has no profile *for its own pubkey* and gets none
- * here. That is the derivation's limit rather than this reader's, and it is the
- * same limit `GroupSignedEvent.verifies` documents.
- */
-data class GroupNostrProfile(
- /** The group's statement, whole, with the signature that makes it one. */
- val signedEvent: GroupSignedEvent,
- /** Its content parsed: the fields nostr clients read a profile out of. */
- val metadata: UserMetadata,
-) {
- /** The group's nostr identity, which for a derived room is also its id. */
- val publicKey: HexKey get() = signedEvent.publicKey
-
- /** When the group signed it, which is what decides the newest of two. */
- val signedAt: Instant get() = signedEvent.createdAt
-
- /**
- * What to call the group, or null when it has published no name.
- *
- * `display_name` before `name`, which is what `UserMetadata.anyName` does and
- * what every other nostr client does. Null rather than the pubkey: a caller
- * showing this beside the pubkey would otherwise show it twice.
- */
- fun name(): String? = metadata.anyName()?.takeIf { it.isNotBlank() }
-
- fun about(): String? = metadata.about?.takeIf { it.isNotBlank() }
-
- fun picture(): String? = metadata.picture?.takeIf { it.isNotBlank() }
-
- fun banner(): String? = metadata.banner?.takeIf { it.isNotBlank() }
-
- fun website(): String? = metadata.website?.takeIf { it.isNotBlank() }
-
- fun nip05(): String? = metadata.nip05?.takeIf { it.isNotBlank() }
-
- fun lud16(): String? = metadata.lud16?.takeIf { it.isNotBlank() }
-
- /** The event as the group signed it, for [MetadataEvent.updateFromPast]. */
- fun asMetadataEvent(): MetadataEvent = signedEvent.toEvent().let { event ->
- MetadataEvent(
- id = event.id,
- pubKey = event.pubKey,
- createdAt = event.createdAt,
- tags = event.tags,
- content = event.content,
- sig = event.sig,
- )
- }
-
- companion object {
- /**
- * The reading of one signed event, or null when it is not one of these.
- *
- * Three ways to be null and they are all the same refusal: the wrong kind,
- * a signature that does not check out as [chatRoomId]'s, or content that
- * will not parse as a profile. A caller gets a profile the group really
- * signed or gets nothing.
- */
- fun of(signedEvent: GroupSignedEvent, chatRoomId: String): GroupNostrProfile? {
- if (signedEvent.kind != MetadataEvent.KIND) return null
- if (!signedEvent.verifies()) return null
-
- // An empty kind:0 parses to an empty profile rather than to null --
- // wiping a profile is a thing groups are entitled to do, and quartz
- // reads it as the blank one it is. Null here is a parse failure.
- val metadata = MetadataEvent(
- id = signedEvent.id,
- pubKey = signedEvent.publicKey,
- createdAt = signedEvent.createdAt.epochSeconds,
- tags = signedEvent.tags,
- content = signedEvent.content,
- sig = signedEvent.signature,
- ).contactMetaData() ?: return null
-
- return GroupNostrProfile(signedEvent = signedEvent, metadata = metadata)
- }
-
- /**
- * The newest profile [chatRoomId] signed among [signedEvents], or null if
- * it signed none.
- *
- * Newest by the timestamp the group signed at, with the id breaking a tie,
- * because kind:0 is replaceable: a group that edits its profile signs a
- * second one and the second is the answer. Two devices reading the same
- * events in whatever order the queries hand them over have to agree on
- * which, and a tie on the second is not rare enough to leave to luck.
- *
- * Takes the events rather than fetching them so the same question can be
- * asked of a query's result or of a flow's emission.
- */
- fun newestAmong(
- signedEvents: List,
- chatRoomId: String,
- ): GroupNostrProfile? =
- signedEvents
- .asSequence()
- .mapNotNull { of(it, chatRoomId) }
- .maxWithOrNull(
- compareBy({ it.signedAt }, { it.signedEvent.id })
- )
-
- /**
- * The event to ask the group to sign for a profile with these fields.
- *
- * Built from [latest] where the group has one, so a field this app does not
- * offer -- a birthday, a CLINK offer, whatever a future NIP adds -- survives
- * an edit instead of being dropped by it. That is `updateFromPast`'s whole
- * job, and reaching for `createNew` on a group that already has a profile
- * would quietly wipe every such field.
- *
- * Blank means delete, which is `MetadataEvent`'s own rule for these
- * arguments: an empty string removes the key and null leaves it alone. The
- * screen sends what its fields hold, so clearing one clears it in the
- * profile -- which is the only way to *un*-say something a group has said.
- *
- * [name] is written to both `name` and `display_name`, which are the two
- * fields readers pick a name out of and which disagree at their peril. A
- * group whose `display_name` was set by some other tool and whose `name` was
- * edited here would keep answering to the old one in every client that
- * prefers `display_name` -- an edit that visibly does not take. One field on
- * the form, both keys in the event.
- */
- fun template(
- latest: GroupNostrProfile?,
- name: String,
- about: String,
- picture: String,
- website: String,
- nip05: String,
- lud16: String,
- ): EventTemplate = latest?.let {
- MetadataEvent.updateFromPast(
- latest = it.asMetadataEvent(),
- name = name,
- displayName = name,
- about = about,
- picture = picture,
- website = website,
- nip05 = nip05,
- lnAddress = lud16,
- )
- } ?: MetadataEvent.createNew(
- name = name,
- displayName = name,
- about = about,
- picture = picture,
- website = website,
- nip05 = nip05,
- lnAddress = lud16,
- )
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/GroupPost.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/GroupPost.kt
deleted file mode 100644
index a21ad3c8..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/GroupPost.kt
+++ /dev/null
@@ -1,121 +0,0 @@
-package com.machankura.bennu.compose.nostr
-
-import com.machankura.bennu.compose.database.model.GroupSignedEvent
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent
-import kotlin.time.Instant
-
-/**
- * A kind:1 the group signed: something it said publicly, as itself.
- *
- * The room's id is the pubkey it signs as, so a note authored by that key is the
- * *group* posting rather than a member posting in the group. Those are different
- * things and the room already has the second one -- the transcript. This is the
- * first: a statement the group put a quorum's signature to, which any reader can
- * check came from the group and not from whoever typed it.
- *
- * ### Why this is not a `Post` row
- *
- * `Post` hangs off both `NostrEvent` and `Profile` by foreign key, and a group has
- * neither: a group-signed event is not a `NostrEvent` -- see `GroupNostrProfile`,
- * which gives the reasoning at length -- and the group has no `Profile` row for the
- * same reason. So a group's posts live where the group's other signed statements
- * live, and this is the reading of them.
- *
- * ### Nothing here has reached a relay
- *
- * The same caveat `GroupNostrProfile` and `GroupRelayList` carry, and it bites
- * hardest here: a post is the one kind of statement whose entire purpose is to be
- * read by people outside the group. `FrostSigningManager.complete` applies signed
- * events locally and puts nothing on the wire, so for now a group's posts are
- * visible to its members and to nobody else. The relay lists beside them say where
- * they should go; sending them is a job that does not exist yet.
- */
-data class GroupPost(
- /** The group's statement, whole, with the signature that makes it one. */
- val signedEvent: GroupSignedEvent,
-) {
- /** The group's nostr identity, which for a derived room is also its id. */
- val publicKey: HexKey get() = signedEvent.publicKey
-
- /** When the group signed it, which is the order posts are read in. */
- val postedAt: Instant get() = signedEvent.createdAt
-
- /** What the group said. */
- val content: String get() = signedEvent.content
-
- /**
- * Whether this is the group speaking rather than answering.
- *
- * A kind:1 with no `e` tag starts a thread; one with them is a reply. Nothing
- * here writes a reply yet -- the composer builds a bare note -- so this exists
- * to keep an imported or chronicled reply from being drawn as an announcement.
- */
- fun isNewThread(): Boolean = asTextNoteEvent().isNewThread()
-
- /** The event as the group signed it. */
- fun asTextNoteEvent(): TextNoteEvent = signedEvent.toEvent().let { event ->
- TextNoteEvent(
- id = event.id,
- pubKey = event.pubKey,
- createdAt = event.createdAt,
- tags = event.tags,
- content = event.content,
- sig = event.sig,
- )
- }
-
- companion object {
- /**
- * The reading of one signed event, or null when it is not one of these.
- *
- * The same gate the profile and the relay lists use: the wrong kind, or a
- * signature that does not check out as [chatRoomId]'s, and a caller gets
- * nothing. A kind:1 a member sent into the room is that member's note, not
- * the group's, and fails on the author.
- */
- fun of(signedEvent: GroupSignedEvent, chatRoomId: String): GroupPost? {
- if (signedEvent.kind != TextNoteEvent.KIND) return null
- if (!signedEvent.verifies()) return null
-
- return GroupPost(signedEvent)
- }
-
- /**
- * Every post [chatRoomId] signed among [signedEvents], newest first.
- *
- * Newest first because that is how a feed is read, and the id breaks a tie
- * so two devices holding the same posts show them in the same order. Unlike
- * a profile or a relay list these accumulate rather than replace: kind:1 is
- * not replaceable, so a second post stands beside the first.
- *
- * Blank posts are dropped. A signed note with nothing in it renders as an
- * empty card that cannot be told from a broken one, and the composer will
- * not produce one -- so anything that reaches here empty came from
- * somewhere this app does not control.
- */
- fun newestFirstAmong(
- signedEvents: List,
- chatRoomId: String,
- ): List =
- signedEvents
- .mapNotNull { of(it, chatRoomId) }
- .filter { it.content.isNotBlank() }
- .sortedWith(compareByDescending { it.postedAt }.thenByDescending {
- it.signedEvent.id
- })
-
- /**
- * The event to ask the group to sign for a post saying [note].
- *
- * A bare kind:1: no reply tags, no mentions, no subject. What the group is
- * doing here is speaking, and every tag `TextNoteEvent.build` can add
- * describes a relationship to something else -- a thread to reply into, a
- * pubkey to notify -- which a group's first way of posting does not have
- * and should not guess at.
- */
- fun template(note: String): EventTemplate =
- TextNoteEvent.build(note = note.trim())
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/GroupRelayList.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/GroupRelayList.kt
deleted file mode 100644
index ec817e28..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/GroupRelayList.kt
+++ /dev/null
@@ -1,279 +0,0 @@
-package com.machankura.bennu.compose.nostr
-
-import com.machankura.bennu.compose.database.model.GroupSignedEvent
-import com.vitorpamplona.quartz.nip01Core.core.Kind
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.displayUrl
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.isLocalHost
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent
-import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent
-import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
-import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
-import com.vitorpamplona.quartz.nip65RelayList.tags.AdvertisedRelayInfo
-import com.vitorpamplona.quartz.nip65RelayList.tags.AdvertisedRelayType
-import kotlin.time.Instant
-import com.vitorpamplona.quartz.nip51Lists.relayLists.tags.RelayTag as Nip51RelayTag
-import com.vitorpamplona.quartz.nip17Dm.settings.tags.RelayTag as Nip17RelayTag
-
-/**
- * Where a group lives on nostr, as the group itself has said.
- *
- * A Marmot room's id is the pubkey it signs as, so the group is an author like any
- * other and the same four relay lists apply to it: where it publishes and is read
- * from, where its messages arrive, where it can be searched for, and what it will
- * not talk to. Each is a replaceable event of its own kind, so each is agreed --
- * and can be missing -- separately.
- *
- * Read off [GroupSignedEvent] and gated on [GroupSignedEvent.verifies], for the
- * reasons `GroupNostrProfile` gives at length: a group-signed event is not a
- * `NostrEvent`, and only an event the room itself authored is the group speaking.
- *
- * ### Nothing here reaches a relay by being signed
- *
- * The lists say where the group's work *should* go; sending it there is a separate
- * act, taken by a member one event at a time from `BroadcastGroupSignedEventScreen`,
- * and the General list is what that screen fills its relay picker from. See
- * `GroupNostrProfile`, which carries the same caveat for the same reason.
- *
- * ### Public tags only, and not by preference
- *
- * NIP-51 puts a relay list's entries in the encrypted half by default -- a blocked
- * list especially, since who you refuse to talk to is nobody's business. A group
- * cannot use it. The encryption is NIP-44 to the author's own key, and there is no
- * ECDH for a FROST threshold key here: the group can sign and cannot decrypt. So
- * every list is written in public tags, which is a real difference from what a
- * person's client would write and is worth knowing before blocking anything.
- */
-data class GroupRelayList(
- val set: GroupRelaySet,
- /**
- * The group's statement, or null for a set it has never agreed.
- *
- * Null and an empty [relays] are different states: never said, versus said and
- * said nothing. A group that signs an empty list has withdrawn the one it had.
- */
- val signedEvent: GroupSignedEvent?,
- val relays: List,
-) {
- /** When the group signed it, or null for a set it has never agreed. */
- val signedAt: Instant? get() = signedEvent?.createdAt
-
- /** Whether the group has ever put its key to this set. */
- val isAgreed: Boolean get() = signedEvent != null
-
- companion object {
- /**
- * The reading of one signed event as [set], or null when it is not one.
- *
- * The same three refusals as `GroupNostrProfile.of`: the wrong kind, a
- * signature that is not [chatRoomId]'s, or tags that carry no relay.
- */
- fun of(
- signedEvent: GroupSignedEvent,
- chatRoomId: String,
- set: GroupRelaySet,
- ): GroupRelayList? {
- if (signedEvent.kind != set.kind) return null
- if (!signedEvent.verifies()) return null
-
- return GroupRelayList(
- set = set,
- signedEvent = signedEvent,
- relays = set.parse(signedEvent.tags),
- )
- }
-
- /**
- * The newest list [chatRoomId] signed for [set] among [signedEvents].
- *
- * Never null: a set the group has never agreed reads back as an unsigned,
- * empty list rather than as an absence, so a caller always has a row per
- * set to show and [isAgreed] is what separates the two.
- *
- * Newest by the group's own timestamp with the id breaking a tie, for the
- * reason `GroupNostrProfile.newestAmong` gives: these are replaceable, and
- * two devices reading the same events in different orders have to agree.
- */
- fun newestAmong(
- signedEvents: List,
- chatRoomId: String,
- set: GroupRelaySet,
- ): GroupRelayList =
- signedEvents
- .asSequence()
- .mapNotNull { of(it, chatRoomId, set) }
- .maxWithOrNull(compareBy({ it.signedAt }, { it.signedEvent?.id }))
- ?: GroupRelayList(set = set, signedEvent = null, relays = emptyList())
-
- /** Every set, in the order the editor shows them. */
- fun allAmong(
- signedEvents: List,
- chatRoomId: String,
- ): List =
- GroupRelaySet.entries.map { newestAmong(signedEvents, chatRoomId, it) }
- }
-}
-
-/**
- * One relay in one of a group's lists.
- *
- * [read] and [write] mean something only in [GroupRelaySet.General], which is the
- * one list NIP-65 gives markers to; everywhere else a relay is simply in the list
- * and both are true. They are kept on the shared type rather than split into two
- * so that the editor has one row shape and one add path.
- *
- * **Neither is not a state.** NIP-65 writes a bare `r` tag for both, `read` for
- * read-only and `write` for write-only, and has nothing at all for a relay that is
- * neither -- a relay you will not read from and will not write to is one you have
- * removed. The editor enforces that rather than this dropping it silently.
- */
-data class GroupRelay(
- val url: NormalizedRelayUrl,
- val read: Boolean = true,
- val write: Boolean = true,
-) {
- /** The host, for a list that is read rather than copied. */
- fun displayUrl(): String = url.displayUrl()
-}
-
-/**
- * The relay lists a group keeps, and what each one is for.
- *
- * The four a person's client keeps, because a group is an author like any other and
- * these are the four questions the network asks about one.
- *
- * **Key packages (MIP-00, kind 10051) are deliberately not here**, though this app
- * writes one for every person. A key package is a device's offer to be added to an
- * MLS group, and a group has no device and joins nothing -- so a group advertising
- * where its key packages live would be pointing at a place that will always be
- * empty, which is worse than saying nothing. See `MarmotKeyPackage`, which is keyed
- * by member.
- *
- * **Relay feeds (kind 10012) are not here either**, for the harder reason: the list
- * lives in the encrypted half and a threshold key cannot decrypt. See
- * [GroupRelayList]'s note on public tags.
- */
-enum class GroupRelaySet(
- val kind: Kind,
- /** Whether NIP-65's read and write markers apply, which is General alone. */
- val hasReadWriteMarkers: Boolean = false,
-) {
- /**
- * NIP-65: where the group publishes and where a reader should look for it.
- *
- * The one that matters most and the only one with markers. Everything the group
- * signs is addressed to whoever wants to read it, and this is the answer to
- * where.
- */
- General(AdvertisedRelayListEvent.KIND, hasReadWriteMarkers = true),
-
- /** NIP-17: where a message addressed to the group's key should be sent. */
- Messages(ChatMessageRelayListEvent.KIND),
-
- /** NIP-50: the relays the group would have a search of its work run against. */
- Search(SearchRelayListEvent.KIND),
-
- /** NIP-51: relays the group will not talk to, whatever else says otherwise. */
- Blocked(BlockedRelayListEvent.KIND),
- ;
-
- /**
- * What a group with nothing agreed starts the editor at.
- *
- * The app's own relay, which is where everything else this build publishes and
- * reads already goes -- see `Relays.ephemeral`. A group seeded with nothing
- * would be a group whose first proposal is an empty list, which says less than
- * having never said anything at all.
- *
- * Blocked is the exception and starts empty on purpose: a default there is a
- * refusal to talk to somebody that nobody in the group chose.
- */
- fun defaults(): List = when (this) {
- Blocked -> emptyList()
- else -> listOf(GroupRelay(Relays.ephemeral))
- }
-
- /** The relays out of a signed event's tags, in the order the group wrote them. */
- fun parse(tags: Array>): List = when (this) {
- General -> tags.mapNotNull(AdvertisedRelayInfo::parse).map {
- GroupRelay(
- url = it.relayUrl,
- read = it.type.isRead(),
- write = it.type.isWrite(),
- )
- }
- // Both nip51 lists and NIP-17's use a "relay" tag, and the two RelayTag
- // classes that parse it are different classes in different packages. Named
- // apart at the import so a reader can see which NIP each line is following.
- Messages -> tags.mapNotNull(Nip17RelayTag::parse).map { GroupRelay(it) }
- Search, Blocked -> tags.mapNotNull(Nip51RelayTag::parse).map { GroupRelay(it) }
- }.distinctBy { it.url }
-
- /**
- * The event to ask the group to sign for this set.
- *
- * Built from scratch rather than from the group's last one, which is the
- * opposite of what `GroupNostrProfile.template` does and for a reason: a
- * profile is a bag of independent fields where an unknown one is worth keeping,
- * and a relay list is one list where the whole point of signing a new one is to
- * replace it. Carrying a tag forward here would make a removal impossible.
- *
- * A relay that is neither read nor write is dropped rather than written, since
- * NIP-65 cannot express one -- the editor does not allow the state, and this is
- * the second line of that defence rather than the first.
- */
- fun template(relays: List): EventTemplate<*> {
- val tags = when (this) {
- General -> relays.mapNotNull { relay ->
- val type = when {
- relay.read && relay.write -> AdvertisedRelayType.BOTH
- relay.read -> AdvertisedRelayType.READ
- relay.write -> AdvertisedRelayType.WRITE
- else -> return@mapNotNull null
- }
- AdvertisedRelayInfo.assemble(relay.url, type)
- }
- Messages -> relays.map { Nip17RelayTag.assemble(it.url) }
- Search, Blocked -> relays.map { Nip51RelayTag.assemble(it.url) }
- }
-
- // Empty content throughout. For General and Messages that is all the kind
- // has; for the two nip51 lists it is where the encrypted half would go, and
- // a group has no encrypted half. See [GroupRelayList].
- return EventTemplate(
- createdAt = kotlin.time.Clock.System.now().epochSeconds,
- kind = kind,
- tags = tags.toTypedArray(),
- content = "",
- )
- }
-
- companion object {
- /**
- * The kinds a group's relay lists are written as.
- *
- * A set rather than a walk of [entries], for `ChatMessage.applyInnerEvent`,
- * whose dispatch is one `when` over an event's kind -- and a `when` branch
- * has to be a constant expression rather than a predicate over an enum.
- */
- val KINDS: Set = entries.map { it.kind }.toSet()
-
- /**
- * [url] as a relay a group could actually be told to use, or null.
- *
- * Structural only, and deliberately narrow: `wss://` because a group's
- * signed list is read by strangers over the open network and `ws://` would
- * ask them to fetch it in the clear, and no loopback because a relay only
- * this device can reach is not something to put a quorum's signature on.
- * Wisp's `RelayConfig.isValidUrl` refuses the same three things.
- */
- fun relayUrlOrNull(url: String): NormalizedRelayUrl? {
- val trimmed = url.trim()
- if (!trimmed.startsWith("wss://", ignoreCase = true)) return null
-
- return RelayUrlNormalizer.normalizeOrNull(trimmed)?.takeUnless { it.isLocalHost() }
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/chronicle/ChronicleEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/chronicle/ChronicleEvent.kt
index c6e7c1ce..171fcc73 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/chronicle/ChronicleEvent.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/chronicle/ChronicleEvent.kt
@@ -14,14 +14,6 @@ import com.machankura.bennu.compose.network.serialization.CommonJson
import com.machankura.bennu.compose.nostr.chronicle.tags.ChronicleIdTag
import com.machankura.bennu.compose.nostr.chronicle.tags.ChroniclePageTag
import com.machankura.bennu.compose.nostr.chronicle.tags.ChronicleRecipientTag
-import com.machankura.bennu.compose.nostr.nip30303.ArtifactEvent
-import com.machankura.bennu.compose.nostr.nip30303.ArtifactVersionEvent
-import com.machankura.bennu.compose.nostr.nip30303.ChapterEvent
-import com.machankura.bennu.compose.nostr.nip30303.ChunkEvent
-import com.machankura.bennu.compose.nostr.nip30303.DialectEvent
-import com.machankura.bennu.compose.nostr.nip30303.TranslationArtifactVersionEvent
-import com.machankura.bennu.compose.nostr.nip30303.TranslationChapterEvent
-import com.machankura.bennu.compose.nostr.nip30303.TranslationChunkEvent
/**
* 30327
@@ -45,16 +37,7 @@ import com.machankura.bennu.compose.nostr.nip30303.TranslationChunkEvent
* deliberately does not do: it never carries the chat, and it cannot make its
* recipient able to *sign* anything.
*
- * ### Why not a [com.machankura.bennu.compose.nostr.nip30303.SubmissionEvent] each
- *
- * The envelope fits and the meaning does not. A submission is an *act* -- this
- * member is putting this event in front of this group -- and a chronicle asserts
- * nothing; it re-delivers what the group already agreed. On one kind a
- * four-hundred-event backfill is indistinguishable from four hundred new
- * submissions and every device has to guess which it is looking at. It would
- * also be one inner event and one kind:445 per payload, where a page is one, and
- * the submission arm of `ChatMessage.applyInnerEvent` files a chat line per
- * payload, which a chronicle must not.
+ * It carries nothing in this app at the moment -- see [KINDS].
*/
@Immutable
class ChronicleEvent(
@@ -88,18 +71,12 @@ class ChronicleEvent(
companion object {
/**
* Sits past `GroupKeyStateEvent` at 30326, in the Marmot inner-event
- * space it shares with the nip30303 document kinds and the FROST signing
- * family.
+ * space it shares with the FROST signing family.
*
- * 30313 was free next to the document kinds and is not used, on
- * `FrostSigningEvents`' own advice: the DKG's 30310-30316 already overlap
- * that range and are told apart only by living in NIP-17 gift wraps
- * instead, which is "an accident of routing rather than a decision, and
- * the next family added should not rely on it." This is that next family.
- *
- * It is also the right neighbourhood on the merits. A chronicle is not a
- * document kind; it is a statement about the record, which is what a key
- * state is too.
+ * 30313 is not used, on `FrostSigningEvents`' own advice: the DKG's
+ * 30310-30316 sit there, and once collided with document kinds that
+ * shared their numbers. This family took numbers nobody else uses
+ * instead.
*/
const val KIND: Kind = 30327
@@ -109,7 +86,7 @@ class ChronicleEvent(
* The most JSON one page may carry.
*
* A byte cap rather than a count alone, because the payloads vary by two
- * orders of magnitude -- a chunk is a paragraph, an artifact is a URL.
+ * orders of magnitude -- a paragraph of text against a single URL.
* Sized so the finished kind:445 clears the tightest relay limits with
* room for the MLS framing and the NIP-44 expansion that sit outside it;
* measure it against a real one rather than trusting the arithmetic.
@@ -130,8 +107,8 @@ class ChronicleEvent(
* The most payloads one page may carry.
*
* The byte cap bounds the transport; this bounds the receiver's *work*,
- * and they are not the same limit -- 64 KB of one-line dialects is a lot
- * more signature verifies than 64 KB of chapters.
+ * and they are not the same limit -- 64 KB of one-line events is a lot
+ * more signature verifies than 64 KB of long ones.
*
* **Sized under what the byte cap allows, or it would never fire.** An
* event carries a 64-character id, a 64-character pubkey and a
@@ -154,82 +131,29 @@ class ChronicleEvent(
const val MAX_PAGE_EVENTS = 96
/**
- * The kinds a chronicle may carry, in the order they have to be applied.
+ * The kinds a chronicle may carry in this app: **none, at the moment.**
*
- * One list doing both jobs, because a separate allowlist is one more
- * thing that can disagree with the order it is applied in.
+ * It was built to hand a late member the group's signed documents --
+ * dialects, artifacts, chapters and their translations -- and those kinds
+ * were removed with the screens that made them (docs/ceremony-creation.md,
+ * Phase 7). Everything else the group signs is left out on purpose:
*
- * **The order is Room's, not nostr's.** Every one of these has a foreign
- * key on the one before it, so a chronicle applied out of order is a
- * constraint violation rather than a wrong answer. Kind order is not
- * dependency order and never was -- a translation chapter (30308) hangs
- * off a translation artifact version (30306) which hangs off an artifact
- * version (30301) -- so this is a list rather than a `sortedBy { kind }`.
+ * - a `GroupKeyStateEvent` or a subgroup's birth certificate is a validly
+ * signed statement about the group that anyone holding a copy could
+ * replay -- see [ChronicleKinds];
+ * - wallet statements have their own way to a member who joins late.
*
- * **It is an allowlist first.** Verification admits an event to the apply
- * path on the strength of the group's signature, which makes every kind
- * the group has ever signed replayable by any member at any time. A
- * `GroupKeyStateEvent` is group-signed and passes verification perfectly,
- * so a chronicle carrying an old one is a validly signed statement about
- * what the room signs with, replayed by whoever kept a copy. Nothing but
- * this list stops it.
- *
- * ### What is missing from it, and why
- *
- * **Only kinds the group actually signs can be here**, because a chronicle
- * that cannot be verified is one that has to be believed. Six of the
- * thirteen nip30303 kinds reach a signing session; the rest travel as
- * rumors -- empty signature, member author, vouched for by the MLS frame
- * they arrived in and by nothing that survives leaving it.
- *
- * Left out for that reason:
- *
- * - `TranslationEvent` (30311). Nothing builds one; the inbound arm
- * exists and no producer does.
- * - The contributor lists (30305, 30307, 30310). `applyInnerEvent` has
- * no arm that writes a row for any of them, so chronicling them would
- * cost bytes and restore nothing.
- *
- * Two kinds were on that list and are not any more, because the app
- * stopped leaving them unsigned. `ArtifactVersionEvent` (30301) used to be
- * derived from the signed artifact on arrival, and is now the second item
- * of the batch that carries it. `TranslationChunkEvent` (30309) -- the
- * translated text itself -- used to be submitted as its author's rumor,
- * and is now proposed to the group like everything else. Both are
- * therefore checkable, and a chronicle that left them out would hand a new
- * member the whole structure and none of the prose.
+ * So the machinery stays and carries nothing: with an empty list a device
+ * asks for no chronicle, sends none, and applies nothing from one that an
+ * older build sends -- see `ChronicleManager`. Adding a kind back is a
+ * decision that belongs here, with the reason it is safe to replay.
*/
- private val APPLY_ORDER: List = listOf(
- DialectEvent.KIND,
- ArtifactEvent.KIND,
- ArtifactVersionEvent.KIND,
- ChapterEvent.KIND,
- ChunkEvent.KIND,
- TranslationArtifactVersionEvent.KIND,
- TranslationChapterEvent.KIND,
- TranslationChunkEvent.KIND,
- )
+ val KINDS: ChronicleKinds = ChronicleKinds.NONE
- /** Every kind a chronicle may carry. */
- val CHRONICLABLE_KINDS: Set = APPLY_ORDER.toSet()
+ /** Every kind a chronicle may carry in this app. */
+ val CHRONICLABLE_KINDS: Set = KINDS.all
- /**
- * Where [kind] sits in dependency order, or null if a chronicle may not
- * carry it at all.
- */
- fun applyRank(kind: Kind): Int? = APPLY_ORDER.indexOf(kind).takeIf { it >= 0 }
-
- fun isChroniclable(kind: Kind): Boolean = kind in CHRONICLABLE_KINDS
-
- /**
- * [payloads] in dependency order, so a page applies front to back.
- *
- * Stable within a rank: two chapters of one version have no order between
- * them and keeping the caller's is one less thing that varies between two
- * members assembling the same chronicle.
- */
- fun inApplyOrder(payloads: List): List =
- payloads.sortedBy { applyRank(it.kind) ?: Int.MAX_VALUE }
+ fun isChroniclable(kind: Kind): Boolean = KINDS.isChroniclable(kind)
/**
* The bytes [json] occupies once it is the `content` of a Marmot app event --
@@ -315,6 +239,7 @@ class ChronicleEvent(
count: Int,
recipient: HexKey,
createdAt: Long = TimeUtils.now(),
+ kinds: ChronicleKinds = KINDS,
initializer: TagArrayBuilder.() -> Unit = {},
): EventTemplate {
require(payloads.isNotEmpty()) { "A chronicle page carries at least one event" }
@@ -322,7 +247,7 @@ class ChronicleEvent(
"A chronicle page carries at most $MAX_PAGE_EVENTS events, not ${payloads.size}"
}
payloads.forEach {
- require(isChroniclable(it.kind)) { "A chronicle may not carry kind ${it.kind}" }
+ require(kinds.isChroniclable(it.kind)) { "A chronicle may not carry kind ${it.kind}" }
}
val content = encodePage(payloads)
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/chronicle/ChronicleKinds.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/chronicle/ChronicleKinds.kt
new file mode 100644
index 00000000..2de65eb4
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/chronicle/ChronicleKinds.kt
@@ -0,0 +1,51 @@
+package com.machankura.bennu.compose.nostr.chronicle
+
+import com.vitorpamplona.quartz.nip01Core.core.Event
+import com.vitorpamplona.quartz.nip01Core.core.Kind
+
+/**
+ * The kinds a chronicle may carry, in the order they have to be applied.
+ *
+ * One list doing both jobs, because a separate allowlist is one more thing that
+ * can disagree with the order it is applied in. The order is the database's, not
+ * nostr's: where one kind's rows hang off another's, the one they hang off comes
+ * first, so a page applies front to back.
+ *
+ * **It is an allowlist first.** Verification admits an event to the apply path on
+ * the strength of the group's signature, which makes every kind the group has
+ * ever signed replayable by any member at any time. A `GroupKeyStateEvent` is
+ * group-signed and passes verification perfectly, so a chronicle carrying an old
+ * one is a validly signed statement about what the room signs with, replayed by
+ * whoever kept a copy. Nothing but this list stops it.
+ *
+ * A value rather than a constant so the machinery can be exercised without
+ * making anything chroniclable in the app: the app's own list is
+ * [ChronicleEvent.KINDS], and the tests hand in theirs.
+ */
+class ChronicleKinds(private val applyOrder: List) {
+
+ /** Every kind a chronicle may carry. */
+ val all: Set = applyOrder.toSet()
+
+ /** A chronicle that may carry nothing asks for nothing and sends nothing. */
+ fun isEmpty(): Boolean = applyOrder.isEmpty()
+
+ /** Where [kind] sits in apply order, or null if a chronicle may not carry it at all. */
+ fun applyRank(kind: Kind): Int? = applyOrder.indexOf(kind).takeIf { it >= 0 }
+
+ fun isChroniclable(kind: Kind): Boolean = kind in all
+
+ /**
+ * [payloads] in apply order, so a page applies front to back.
+ *
+ * Stable within a rank: two events of one kind have no order between them,
+ * and keeping the caller's is one less thing that varies between two members
+ * assembling the same chronicle.
+ */
+ fun inApplyOrder(payloads: List): List =
+ payloads.sortedBy { applyRank(it.kind) ?: Int.MAX_VALUE }
+
+ companion object {
+ val NONE = ChronicleKinds(emptyList())
+ }
+}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/dkg/DkgRitualEvents.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/dkg/DkgRitualEvents.kt
index 7df3a943..2cff072b 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/dkg/DkgRitualEvents.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/dkg/DkgRitualEvents.kt
@@ -1,19 +1,27 @@
package com.machankura.bennu.compose.nostr.dkg
+import com.machankura.bennu.compose.nostr.subgroup.tags.GuardianDelayTag
import com.machankura.bennu.compose.nostr.dkg.tags.DkgSessionIdTag
import com.machankura.bennu.compose.nostr.dkg.tags.DkgThresholdTag
import com.vitorpamplona.quartz.nip01Core.core.Kind
import com.vitorpamplona.quartz.nip14Subject.SubjectTag
+import com.machankura.bennu.compose.nostr.subgroup.SubgroupWalletPolicy
import com.machankura.bennu.compose.nostr.subgroup.tags.SubgroupParentTag
+import com.machankura.bennu.compose.nostr.subgroup.tags.WalletPolicyTag
/**
* The nostr kinds a ChillDKG ritual is carried on.
*
- * These are **rumor** kinds: they only ever exist inside a NIP-17 gift wrap
- * addressed to the group, so no relay sees them unencrypted and the replaceable
- * semantics normally implied by the 3xxxx range never apply. They sit next to
- * the app's other private kinds (30300-30309) deliberately — the transport,
- * sealing and broadcast pipeline is the same one chat messages ride.
+ * These are **rumor** kinds: they only ever travel encrypted -- inside a NIP-17
+ * gift wrap for a group's own ceremony, and as a Marmot inner event in the
+ * parent's room for a subgroup's -- so no relay sees them in the clear and the
+ * replaceable semantics normally implied by the 3xxxx range never apply. The
+ * transport, sealing and broadcast pipeline is the one chat messages ride.
+ *
+ * 30310-30312 used to be nip30303 document kinds too, and a round 1 read as a
+ * document submission once reached a parent's chat as raw hex. `ChatMessage`
+ * recognises these before any content kind for that reason, and the document
+ * kinds are gone. See docs/ceremony-creation.md.
*
* Who talks to whom, in order:
*
@@ -76,12 +84,16 @@ object DkgRitualEvents {
sessionId: String,
threshold: Int? = null,
parentChatRoomId: String? = null,
- subject: String? = null
+ subject: String? = null,
+ walletPolicy: SubgroupWalletPolicy? = null,
+ guardianDelay: Long? = null
): Array> = buildList {
add(DkgSessionIdTag.assemble(sessionId))
threshold?.let { add(DkgThresholdTag.assemble(it)) }
parentChatRoomId?.let { add(SubgroupParentTag.assemble(it)) }
subject?.ifBlank { null }?.let { add(SubjectTag.assemble(it)) }
+ walletPolicy?.let { add(WalletPolicyTag.assemble(it)) }
+ guardianDelay?.let { add(GuardianDelayTag.assemble(it)) }
}.toTypedArray()
fun parseSessionId(tags: Array>): String? =
@@ -124,4 +136,26 @@ object DkgRitualEvents {
*/
fun parseSubject(tags: Array>): String? =
tags.firstNotNullOfOrNull(SubjectTag::parse)
+
+ /**
+ * The wallet policy the coordinator chose for the subgroup this ceremony
+ * makes -- `docs/subgroup-wallet-policy.md`.
+ *
+ * Authenticates nothing, as [parseParentChatRoomId] does not: it is what the
+ * admins are shown before they join, and what the certificate is later
+ * proposed under. Absent for an ordinary ceremony and for one from an older
+ * build; unreadable is told apart from absent, because a proposal whose
+ * policy cannot be read is not one to join on the assumption it has none.
+ */
+ fun parseWalletPolicy(tags: Array>): WalletPolicyTag.Result =
+ WalletPolicyTag.parseOne(tags)
+
+ /**
+ * The delay the coordinator chose for the parent's own leaf, beside a
+ * guarded policy -- `docs/guardian-delay.md`. Authenticates nothing, as the
+ * policy does not: it is what the admins are shown, and what the certificate
+ * is proposed under.
+ */
+ fun parseGuardianDelay(tags: Array>): GuardianDelayTag.Result =
+ GuardianDelayTag.parseOne(tags)
}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/frost/FrostSigningEvents.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/frost/FrostSigningEvents.kt
index c879f8ef..f30411fa 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/frost/FrostSigningEvents.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/frost/FrostSigningEvents.kt
@@ -51,23 +51,17 @@ import com.machankura.bennu.compose.nostr.frost.tags.FrostSilentMembersTag
*
* ### Why 3032x
*
- * These share the inner-event space with the nip30303 document kinds, which run
- * 30300 up to [com.machankura.bennu.compose.nostr.nip30303.SubmissionEvent] at 30312 --
- * the same space, because both are Marmot inner events and both are dispatched
- * on kind by the same inbound path. Starting at 30320 leaves that family room to
- * grow into.
+ * These started past the nip30303 document kinds, which ran 30300 up to 30312
+ * in the same Marmot inner-event space and were dispatched on kind by the same
+ * inbound path. Those kinds are gone (docs/ceremony-creation.md), and 30300-30309
+ * are free.
*
- * The DKG's 30310-30316 look like a clash and are not, but the reason is
- * narrower than it used to be. The nip30303 kinds exist only inside Marmot inner
- * events and the DKG's only inside NIP-17 gift wraps, so the numbers overlap
- * where nothing reads across -- the DKG's proposal and host-key kinds sit on
- * 30310 and 30311 alongside two nip30303 kinds, and its round-1 kind is 30312,
- * alongside SubmissionEvent.
- *
- * These kinds are now the ones that *do* travel on both transports, which is
- * exactly why they must not overlap with either family. They do not. But that
- * separation was an accident of routing rather than a decision, and the next
- * family added should not rely on it.
+ * The DKG's 30310-30316 *did* clash with that family once a subgroup's ceremony
+ * moved into its parent's Marmot room: its round 1 reached the parent's chat as
+ * an unreadable document submission. `ChatMessage` recognises this family's
+ * kinds and the DKG's before any content kind, so a protocol kind is never read
+ * as content whatever shares its number. A new family should still take numbers
+ * nobody else uses.
*/
object FrostSigningEvents {
/**
@@ -188,6 +182,21 @@ object FrostSigningEvents {
return chain to account
}
+ private const val GUARDED_TAG = "guarded"
+
+ /**
+ * On a [TRANSACTION_PROPOSAL] from an ancestor's room: the descendant whose
+ * guarded wallet it spends from, through the room's guardian leaf. Absent
+ * for a spend from the room's own wallet. Which wallet it is is all this
+ * says; every signer then reads that wallet from the statement its own room
+ * was told, never from the proposal.
+ */
+ fun guardedTags(descendantChatRoomId: String): Array> = arrayOf(arrayOf(GUARDED_TAG, descendantChatRoomId))
+
+ /** The descendant a guardian's [TRANSACTION_PROPOSAL] names, or null for the room's own wallet. */
+ fun parseGuarded(tags: Array>): String? =
+ tags.firstOrNull { it.size >= 2 && it[0] == GUARDED_TAG }?.get(1)?.takeIf { it.isNotBlank() }
+
fun parseSessionId(tags: Array>): String? =
tags.firstNotNullOfOrNull(FrostSessionIdTag::parse)?.sessionId
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningAuthorisationEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningAuthorisationEvent.kt
index 6bc23d79..15377cd5 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningAuthorisationEvent.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningAuthorisationEvent.kt
@@ -8,7 +8,7 @@ import fr.acinq.lightning.payment.Bolt11Invoice
import kotlin.time.Clock
/**
- * Something the group lets its Lightning wallet do: kind 30346, FROST-signed, never broadcast
+ * Something the group lets its Lightning wallet do: kind 30363, FROST-signed, never broadcast
* (`docs/group-lightning-wallet.md`, Phase 12).
*
* The operator's node acts on an authorisation, and every co-signer reads it as a budget: an HTLC the
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningEvents.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningEvents.kt
index 06dcad1b..7ae71d2a 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningEvents.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningEvents.kt
@@ -14,54 +14,58 @@ import com.vitorpamplona.quartz.nip01Core.core.Kind
* apply.
*
* ```
- * proposer --[ 30333 ceremony proposal ]-> everyone "let's make a t-of-n Iceberg key"
- * participant --[ 30334 DKG round 1 ]-> everyone commitments to seed contributions
- * participant --[ 30335 DKG round 2 ]-> everyone contributions, each encrypted to its holder
- * participant --[ 30336 DKG round 3 ]-> everyone public share + transcript signature
- * anyone --[ 30337 ceremony failure ]-> everyone abort + blame
- * group --[ 30338 wallet statement ] FROST-signed, never broadcast
- * group --[ 30339 operator statement] FROST-signed, never broadcast
- * opener --[ 30340 node seed ]-> each participant, encrypted to them
- * operator --[ 30341 signing request ]-> everyone
- * participant --[ 30342 echo ]-> everyone (label, message hash)
- * participant --[ 30343 nonce batch ]-> everyone round-one contributions
- * participant --[ 30344 signature share ]-> everyone round two
- * operator --[ 30345 snapshot ]-> everyone balance, channels, payments
- * group --[ 30346 authorisation ] FROST-signed: pay, close, force-close, splice-out
- * member --[ 30347 invoice request ]-> everyone
- * operator --[ 30348 invoice ]-> everyone
- * old operator--[ 30349 stopped ]-> everyone its last commitment numbers
+ * proposer --[ 30350 ceremony proposal ]-> everyone "let's make a t-of-n Iceberg key"
+ * participant --[ 30351 DKG round 1 ]-> everyone commitments to seed contributions
+ * participant --[ 30352 DKG round 2 ]-> everyone contributions, each encrypted to its holder
+ * participant --[ 30353 DKG round 3 ]-> everyone public share + transcript signature
+ * anyone --[ 30354 ceremony failure ]-> everyone abort + blame
+ * group --[ 30355 wallet statement ] FROST-signed, never broadcast
+ * group --[ 30356 operator statement] FROST-signed, never broadcast
+ * opener --[ 30357 node seed ]-> each participant, encrypted to them
+ * operator --[ 30358 signing request ]-> everyone
+ * participant --[ 30359 echo ]-> everyone (label, message hash)
+ * participant --[ 30360 nonce batch ]-> everyone round-one contributions
+ * participant --[ 30361 signature share ]-> everyone round two
+ * operator --[ 30362 snapshot ]-> everyone balance, channels, payments
+ * group --[ 30363 authorisation ] FROST-signed: pay, close, force-close, splice-out
+ * member --[ 30364 invoice request ]-> everyone
+ * operator --[ 30365 invoice ]-> everyone
+ * old operator--[ 30366 stopped ]-> everyone its last commitment numbers
* ```
*
- * ### Why 30333
+ * ### Why 30350
*
- * 30330-30332 were the highest kinds in use when this family was reserved, and
- * the note on `FrostSigningEvents` asks the next family not to rely on routing
- * to keep it apart from the others. So this one is a fresh run with nothing
- * else in it, and `GroupLightningEventsTest` asserts that none of it overlaps any
- * kind the app already dispatches on.
+ * This family was first reserved at 30333-30349, the run after the highest
+ * kinds then in use. The guarded-wallet family took 30333-30337 on the main
+ * branch while this one was being built, and the two met at the merge, where
+ * nothing would have failed: each reads the other's events by kind. Rumor kinds
+ * are never published and nothing had shipped, so this family moved to a fresh
+ * run past the guarded wallets' with room before it. The note on
+ * `FrostSigningEvents` asks the next family not to rely on routing to keep it
+ * apart from the others; `GroupLightningEventsTest` asserts both that none of it
+ * overlaps a kind the app uses and that it starts past all of them.
*/
object GroupLightningEvents {
- val CEREMONY_PROPOSAL: Kind = 30333
- val DKG_ROUND_1: Kind = 30334
- val DKG_ROUND_2: Kind = 30335
- val DKG_ROUND_3: Kind = 30336
- val CEREMONY_FAILURE: Kind = 30337
+ val CEREMONY_PROPOSAL: Kind = 30350
+ val DKG_ROUND_1: Kind = 30351
+ val DKG_ROUND_2: Kind = 30352
+ val DKG_ROUND_3: Kind = 30353
+ val CEREMONY_FAILURE: Kind = 30354
- val WALLET_STATEMENT: Kind = 30338
- val OPERATOR_STATEMENT: Kind = 30339
- val NODE_SEED: Kind = 30340
+ val WALLET_STATEMENT: Kind = 30355
+ val OPERATOR_STATEMENT: Kind = 30356
+ val NODE_SEED: Kind = 30357
- val SIGNING_REQUEST: Kind = 30341
- val ECHO: Kind = 30342
- val NONCE_BATCH: Kind = 30343
- val SIGNATURE_SHARE: Kind = 30344
+ val SIGNING_REQUEST: Kind = 30358
+ val ECHO: Kind = 30359
+ val NONCE_BATCH: Kind = 30360
+ val SIGNATURE_SHARE: Kind = 30361
- val SNAPSHOT: Kind = 30345
- val AUTHORISATION: Kind = 30346
- val INVOICE_REQUEST: Kind = 30347
- val INVOICE: Kind = 30348
- val STOPPED: Kind = 30349
+ val SNAPSHOT: Kind = 30362
+ val AUTHORISATION: Kind = 30363
+ val INVOICE_REQUEST: Kind = 30364
+ val INVOICE: Kind = 30365
+ val STOPPED: Kind = 30366
/** The Iceberg ceremony's kinds, for routing to its ritual manager. */
val CEREMONY: Set = setOf(CEREMONY_PROPOSAL, DKG_ROUND_1, DKG_ROUND_2, DKG_ROUND_3, CEREMONY_FAILURE)
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningOperatorStatementEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningOperatorStatementEvent.kt
index aac3190d..3e149964 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningOperatorStatementEvent.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningOperatorStatementEvent.kt
@@ -7,7 +7,7 @@ import fr.acinq.bitcoin.Chain
import kotlin.time.Clock
/**
- * Who runs the group's Lightning node: kind 30339, FROST-signed, never broadcast
+ * Who runs the group's Lightning node: kind 30356, FROST-signed, never broadcast
* (`docs/group-lightning-wallet.md`, Phase 7).
*
* The term is what every co-signer fences on. It only goes up, and a request from anyone but the
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningWalletStatementEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningWalletStatementEvent.kt
index df552419..dc62369a 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningWalletStatementEvent.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/lightning/GroupLightningWalletStatementEvent.kt
@@ -8,7 +8,7 @@ import fr.acinq.bitcoin.Chain
import kotlin.time.Clock
/**
- * The group's statement that it keeps a Lightning wallet: kind 30338, FROST-signed by the room through
+ * The group's statement that it keeps a Lightning wallet: kind 30355, FROST-signed by the room through
* the ordinary proposal flow, never broadcast (`docs/group-lightning-wallet.md`, Phase 6).
*
* It binds together everything a co-signer checks before it answers for a channel: which onchain wallet
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/ArtifactEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/ArtifactEvent.kt
deleted file mode 100644
index 77d21318..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/ArtifactEvent.kt
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip22Comments.RootScope
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.nip50Search.SearchableEvent
-import com.vitorpamplona.quartz.utils.TimeUtils
-import com.machankura.bennu.compose.nostr.nip30303.tags.ArtifactVersionMetadataTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.DialectIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.LicenseTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.UrlTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.VisibilityTag
-
-
-@Immutable
-class ArtifactEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
- fun url() = tags.firstNotNullOfOrNull(UrlTag::parse)?.url
- fun visibility() = tags.firstNotNullOfOrNull(VisibilityTag::parse)?.visibility
- fun license() = tags.firstNotNullOfOrNull(LicenseTag::parse)?.license
-
- fun dialectIdReference() = tags.firstNotNullOfOrNull(DialectIdTag::parse)?.ref
- fun dialectId() = dialectIdReference()?.eventId
-
- /**
- * The label of the version this artifact starts life with.
- *
- * Carried on the artifact rather than in an event of its own because the
- * group signs the artifact and nothing else. A first version proposed
- * separately would need either a second quorum for one form or an id each
- * device invents for itself, and invented ids differ on every device holding
- * the same artifact. Null on artifacts written before this was declared.
- */
- fun versionLabel() = tags.firstNotNullOfOrNull(ArtifactVersionMetadataTag::parse)?.versionLabel
-
- companion object {
- const val KIND = 30300
- const val ALT_DESCRIPTION = "Artifact"
-
- fun build(
- name: String,
- url: String,
- visibility: String,
- license: String,
- dialectId: String,
- versionLabel: String,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, name, createdAt) {
- alt(ALT_DESCRIPTION)
- addUnique(UrlTag.assemble(url))
- addUnique(VisibilityTag.assemble(visibility))
- addUnique(LicenseTag.assemble(license))
- addUnique(
- DialectIdTag.assemble(dialectId)
- )
- addUnique(ArtifactVersionMetadataTag.assemble(versionLabel))
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/ArtifactVersionEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/ArtifactVersionEvent.kt
deleted file mode 100644
index 541a1616..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/ArtifactVersionEvent.kt
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip22Comments.RootScope
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.nip50Search.SearchableEvent
-import com.vitorpamplona.quartz.utils.TimeUtils
-import com.machankura.bennu.compose.nostr.nip30303.tags.ArtifactIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.ArtifactVersionMetadataTag
-
-
-@Immutable
-class ArtifactVersionEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
-
- fun versionLabel() = tags.firstNotNullOfOrNull(ArtifactVersionMetadataTag::parse)?.versionLabel
-
- fun artifactIdReference() = tags.firstNotNullOfOrNull(ArtifactIdTag::parse)?.ref
- fun artifactId() = artifactIdReference()?.eventId
-
- companion object {
- const val KIND = 30301
- const val ALT_DESCRIPTION = "ArtifactVersion"
-
- /**
- * The first version [artifact] declares, ready to be signed with it.
- *
- * An artifact and the version it starts life with go to the group as one
- * batch, so this is built from the artifact *after* it has been authored
- * under the group's key -- [artifact] is the unsigned event the session
- * will sign, which is where the id this carries comes from. Building it
- * anywhere else would mean naming an artifact id before one exists.
- *
- * It takes the artifact's own timestamp, so the batch reads as one act
- * rather than two events that happen to share a session.
- *
- * This used to be derived on arrival instead, from the label the
- * artifact carries -- the same shape a chapter's chunks were in, and
- * abandoned for the same reason. Deriving cost nothing while the
- * alternative was a second quorum, and nothing is what it bought: a row
- * naming the group as its author with no signature to show for it, which
- * a chapter then hangs off. A batch is one quorum, so the version can
- * carry the group's signature over its own label.
- *
- * Empty when the artifact declares no version -- every artifact written
- * before it did -- which leaves a batch of one and an artifact with no
- * version, exactly as before.
- */
- fun initialVersionOf(artifact: Event): List> {
- val versionLabel = ArtifactEvent(
- id = artifact.id,
- pubKey = artifact.pubKey,
- createdAt = artifact.createdAt,
- tags = artifact.tags,
- content = artifact.content,
- sig = artifact.sig
- ).versionLabel() ?: return emptyList()
-
- return listOf(
- build(content = versionLabel, createdAt = artifact.createdAt) {
- addUnique(ArtifactIdTag.assemble(artifact.id))
- }
- )
- }
-
- fun build(
- content: String,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, content, createdAt) {
- alt(ALT_DESCRIPTION)
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/ChapterEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/ChapterEvent.kt
deleted file mode 100644
index 933e1c38..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/ChapterEvent.kt
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.utils.TimeUtils
-import com.machankura.bennu.compose.nostr.nip30303.tags.ArtifactVersionIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.IndexTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.NameTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.OriginalTextTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.WordStatisticsTag
-
-
-@Immutable
-class ChapterEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
- val wordStatisticsTag = tags.firstNotNullOfOrNull(WordStatisticsTag::parse)
-
- fun artifactVersionIdReference() = tags.firstNotNullOfOrNull(ArtifactVersionIdTag::parse)?.ref
- fun artifactVersionId() = artifactVersionIdReference()?.eventId
-
- fun name() = tags.firstNotNullOfOrNull(NameTag::parse)?.name
-
- /**
- * The markdown the chapter is, whole.
- *
- * The chapter carries its text even though the chunks cut from it are
- * signed alongside it and carry the same words between them. It is the
- * chapter as the group signed it: chunk boundaries are a decision about how
- * to divide the work, and a chapter that kept only the pieces could never be
- * divided again differently without losing what was agreed to.
- */
- fun originalText() = tags.firstNotNullOfOrNull(OriginalTextTag::parse)?.originalText
-
- fun index() = tags.firstNotNullOfOrNull(IndexTag::parse)?.index
- fun wordCount() = wordStatisticsTag?.wordCount
- fun characterCount() = wordStatisticsTag?.characterCount
-
- companion object {
- const val KIND = 30302
- const val ALT_DESCRIPTION = "Chapter"
-
- fun build(
- artifactVersionId: String,
- name: String,
- originalText: String,
- index: Int,
- wordCount: Int,
- characterCount: Int,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, "", createdAt) {
- alt(ALT_DESCRIPTION)
- addUnique(ArtifactVersionIdTag.assemble(artifactVersionId))
- addUnique(NameTag.assemble(name))
- addUnique(OriginalTextTag.assemble(originalText))
- addUnique(IndexTag.assemble(index))
- addUnique(WordStatisticsTag.assemble(wordCount, characterCount))
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/ChunkEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/ChunkEvent.kt
deleted file mode 100644
index 8a9004be..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/ChunkEvent.kt
+++ /dev/null
@@ -1,94 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip22Comments.RootScope
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.nip50Search.SearchableEvent
-import com.vitorpamplona.quartz.utils.TimeUtils
-import com.machankura.bennu.compose.nostr.nip30303.tags.ChapterIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.IndexTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.WordStatisticsTag
-import com.machankura.bennu.compose.text.Markdown
-
-
-@Immutable
-class ChunkEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
- val wordStatisticsTag = tags.firstNotNullOfOrNull(WordStatisticsTag::parse)
-
- fun index() = tags.firstNotNullOfOrNull(IndexTag::parse)?.index
- fun wordCount() = wordStatisticsTag?.wordCount
- fun characterCount() = wordStatisticsTag?.characterCount
-
- fun chapterIdReference() = tags.firstNotNullOfOrNull(ChapterIdTag::parse)?.ref
- fun chapterId() = chapterIdReference()?.eventId
-
- companion object {
- const val KIND = 30303
- const val ALT_DESCRIPTION = "Chunk"
-
- /**
- * The chunks [chapter]'s text splits into, ready to be signed with it.
- *
- * A chapter and its chunks go to the group as one batch, so these are
- * built from the chapter *after* it has been authored under the group's
- * key -- [chapter] is the unsigned event the session will sign, which is
- * where the id each chunk carries comes from. Splitting anywhere else
- * would mean naming a chapter id before one exists.
- *
- * They take the chapter's own timestamp, so the batch reads as one act
- * rather than as events that happen to share a session.
- *
- * Empty when the chapter has no text to split, which is a chapter with
- * nothing in it to translate.
- */
- fun splitOf(chapter: Event): List> {
- val originalText = ChapterEvent(
- id = chapter.id,
- pubKey = chapter.pubKey,
- createdAt = chapter.createdAt,
- tags = chapter.tags,
- content = chapter.content,
- sig = chapter.sig
- ).originalText() ?: return emptyList()
-
- return Markdown.splitParagraphs(originalText).mapIndexed { index, paragraph ->
- build(
- chapterId = chapter.id,
- text = paragraph,
- index = index,
- wordCount = Markdown.wordCount(paragraph),
- characterCount = Markdown.characterCount(paragraph),
- createdAt = chapter.createdAt,
- )
- }
- }
-
- fun build(
- chapterId: String,
- text: String,
- index: Int,
- wordCount: Int,
- characterCount: Int,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, text, createdAt) {
- alt(ALT_DESCRIPTION)
- addUnique(ChapterIdTag.assemble(chapterId))
- addUnique(IndexTag.assemble(index))
- addUnique(WordStatisticsTag.assemble(wordCount, characterCount))
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/DialectEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/DialectEvent.kt
deleted file mode 100644
index e8fcae4c..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/DialectEvent.kt
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip22Comments.RootScope
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.nip50Search.SearchableEvent
-import com.vitorpamplona.quartz.utils.TimeUtils
-import com.machankura.bennu.compose.nostr.nip30303.tags.CountryTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.LanguageTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.NameTag
-
-
-@Immutable
-class DialectEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
- fun name() = tags.firstNotNullOfOrNull(NameTag::parse)?.name
- fun country() = tags.firstNotNullOfOrNull(CountryTag::parse)?.country
- fun language() = tags.firstNotNullOfOrNull(LanguageTag::parse)?.language
-
- companion object {
- const val KIND = 30304
- const val ALT_DESCRIPTION = "Dialect"
-
- fun build(
- name: String,
- country: String,
- language: String,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, language, createdAt) {
- alt(ALT_DESCRIPTION)
- addUnique(NameTag.assemble(name))
- addUnique(CountryTag.assemble(country))
- addUnique(LanguageTag.assemble(language))
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/SubmissionEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/SubmissionEvent.kt
deleted file mode 100644
index 4d458ac4..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/SubmissionEvent.kt
+++ /dev/null
@@ -1,81 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.utils.TimeUtils
-import com.machankura.bennu.compose.nostr.nip30303.tags.PayloadIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.PayloadKindTag
-
-/**
- * 30312
- *
- * An envelope that carries one nip30303 event into a group.
- *
- * Every other nip30303 kind describes a thing -- an artifact, a dialect, a
- * chapter, a translated chunk. A submission describes an act: *this member is
- * putting this event in front of this group*. The two are separate on purpose,
- * because they answer different questions and often have different answers.
- *
- * The payload travels whole, in [content], keeping its own id, author and
- * signature. Nothing is rewritten to make it look like the submitter's work.
- * That buys two things:
- *
- * - A group can take in work written by somebody who is not in it. A
- * translation lifted from a public chronicle, a chapter transcribed by an
- * outside contributor, an artifact somebody published years ago -- an admin
- * submits it and the group applies it, with the original author still named
- * on the row.
- * - Authorship stops being a claim the transport makes. Before this, being
- * the sender of a group message *was* being the author of the event inside
- * it, so the only events a group could hold were ones its own members had
- * written under their own keys.
- *
- * A submission is not an endorsement and grants nothing: a payload's author is
- * whoever signed it, and who may submit is the group's business.
- */
-@Immutable
-class SubmissionEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
-
- /**
- * The submitted event, parsed out of [content].
- *
- * Null when the content is not an event at all -- treat that as a
- * submission that cannot be applied, not as an empty one.
- */
- fun payload(): Event? = Event.fromJsonOrNull(content)
-
- fun payloadKind() = tags.firstNotNullOfOrNull(PayloadKindTag::parse)?.kind
-
- fun payloadIdReference() = tags.firstNotNullOfOrNull(PayloadIdTag::parse)?.ref
- fun payloadId() = payloadIdReference()?.eventId
-
- /** Who wrote the payload, which is not who sent this submission. */
- fun payloadAuthor() = payloadIdReference()?.author
-
- companion object {
- const val KIND = 30312
- const val ALT_DESCRIPTION = "Submission"
-
- fun build(
- payload: Event,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, payload.toJson(), createdAt) {
- alt(ALT_DESCRIPTION)
- addUnique(PayloadKindTag.assemble(payload.kind))
- addUnique(PayloadIdTag.assemble(eventId = payload.id, pubkey = payload.pubKey))
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationArtifactVersionContributorListEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationArtifactVersionContributorListEvent.kt
deleted file mode 100644
index 4c6c049b..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationArtifactVersionContributorListEvent.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip22Comments.RootScope
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.nip50Search.SearchableEvent
-import com.vitorpamplona.quartz.utils.TimeUtils
-
-
-@Immutable
-class TranslationArtifactVersionContributorListEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
-
- companion object {
- const val KIND = 30305
- const val ALT_DESCRIPTION = "TranslationArtifactVersionContributorListEvent"
-
- fun build(
- content: String,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, content, createdAt) {
- alt(ALT_DESCRIPTION)
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationArtifactVersionEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationArtifactVersionEvent.kt
deleted file mode 100644
index ac851170..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationArtifactVersionEvent.kt
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.utils.TimeUtils
-import com.machankura.bennu.compose.nostr.nip30303.tags.ArtifactVersionIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.DialectIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.LicenseTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.NameTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.VisibilityTag
-
-
-@Immutable
-class TranslationArtifactVersionEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
-
- fun name() = tags.firstNotNullOfOrNull(NameTag::parse)?.name
- fun visibility() = tags.firstNotNullOfOrNull(VisibilityTag::parse)?.visibility
- fun license() = tags.firstNotNullOfOrNull(LicenseTag::parse)?.license
-
- fun artifactVersionIdReference() = tags.firstNotNullOfOrNull(ArtifactVersionIdTag::parse)?.ref
- fun artifactVersionId() = artifactVersionIdReference()?.eventId
-
- fun dialectIdReference() = tags.firstNotNullOfOrNull(DialectIdTag::parse)?.ref
- fun dialectId() = dialectIdReference()?.eventId
-
- companion object {
- const val KIND = 30306
- const val ALT_DESCRIPTION = "TranslationArtifactVersion"
-
- fun build(
- artifactVersionId: String,
- dialectId: String,
- name: String,
- visibility: String,
- license: String,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, "", createdAt) {
- alt(ALT_DESCRIPTION)
- addUnique(ArtifactVersionIdTag.assemble(artifactVersionId))
- addUnique(DialectIdTag.assemble(dialectId))
- addUnique(NameTag.assemble(name))
- addUnique(VisibilityTag.assemble(visibility))
- addUnique(LicenseTag.assemble(license))
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationChapterContributorListEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationChapterContributorListEvent.kt
deleted file mode 100644
index 62ce9b9a..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationChapterContributorListEvent.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip22Comments.RootScope
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.nip50Search.SearchableEvent
-import com.vitorpamplona.quartz.utils.TimeUtils
-
-
-@Immutable
-class TranslationChapterContributorListEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
-
- companion object {
- const val KIND = 30307
- const val ALT_DESCRIPTION = "TranslationChapterContributorListEvent"
-
- fun build(
- content: String,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, content, createdAt) {
- alt(ALT_DESCRIPTION)
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationChapterEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationChapterEvent.kt
deleted file mode 100644
index d37c9bfc..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationChapterEvent.kt
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip22Comments.RootScope
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.nip50Search.SearchableEvent
-import com.vitorpamplona.quartz.utils.TimeUtils
-import com.machankura.bennu.compose.nostr.nip30303.tags.ChapterIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.IndexTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationArtifactVersionIdTag
-
-
-@Immutable
-class TranslationChapterEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
-
- fun translationArtifactVersionIdReference() = tags.firstNotNullOfOrNull(TranslationArtifactVersionIdTag::parse)?.ref
- fun translationArtifactVersionId() = translationArtifactVersionIdReference()?.eventId
-
- fun chapterIdReference() = tags.firstNotNullOfOrNull(ChapterIdTag::parse)?.ref
- fun chapterId() = chapterIdReference()?.eventId
-
- fun index() = tags.firstNotNullOfOrNull(IndexTag::parse)?.index
-
- companion object {
- const val KIND = 30308
- const val ALT_DESCRIPTION = "TranslationChapter"
-
- fun build(
- translationArtifactVersionId: String,
- chapterId: String,
- index: Int,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, "", createdAt) {
- alt(ALT_DESCRIPTION)
- addUnique(TranslationArtifactVersionIdTag.assemble(translationArtifactVersionId))
- addUnique(ChapterIdTag.assemble(chapterId))
- addUnique(IndexTag.assemble(index))
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationChunkEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationChunkEvent.kt
deleted file mode 100644
index 725d5421..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationChunkEvent.kt
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip22Comments.RootScope
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.nip50Search.SearchableEvent
-import com.vitorpamplona.quartz.utils.TimeUtils
-import com.machankura.bennu.compose.nostr.nip30303.tags.ChunkIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.IndexTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationArtifactVersionIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationChapterIdTag
-
-
-@Immutable
-class TranslationChunkEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
-
- fun translationChapterIdReference() = tags.firstNotNullOfOrNull(TranslationChapterIdTag::parse)?.ref
- fun translationChapterId() = translationChapterIdReference()?.eventId
-
- fun index() = tags.firstNotNullOfOrNull(IndexTag::parse)?.index
-
- fun chunkIdReference() = tags.firstNotNullOfOrNull(ChunkIdTag::parse)?.ref
- fun chunkId() = chunkIdReference()?.eventId
-
- companion object {
- const val KIND = 30309
- const val ALT_DESCRIPTION = "TranslationChunk"
-
- fun build(
- translationChapterId: String,
- chunkId: String,
- index: Int,
- text: String,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, text, createdAt) {
- alt(ALT_DESCRIPTION)
- addUnique(TranslationChapterIdTag.assemble(translationChapterId))
- addUnique(ChunkIdTag.assemble(chunkId))
- addUnique(IndexTag.assemble(index))
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationChunkProposalEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationChunkProposalEvent.kt
deleted file mode 100644
index 2032dbe6..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationChunkProposalEvent.kt
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip22Comments.RootScope
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.nip50Search.SearchableEvent
-import com.vitorpamplona.quartz.utils.TimeUtils
-import com.machankura.bennu.compose.nostr.nip30303.tags.ChunkIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.IndexTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationArtifactVersionIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationChapterIdTag
-
-
-@Immutable
-class TranslationChunkProposalEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
-
- fun translationChapterIdReference() = tags.firstNotNullOfOrNull(TranslationChapterIdTag::parse)?.ref
- fun translationChapterId() = translationChapterIdReference()?.eventId
-
- fun index() = tags.firstNotNullOfOrNull(IndexTag::parse)?.index
-
- fun chunkIdReference() = tags.firstNotNullOfOrNull(ChunkIdTag::parse)?.ref
- fun chunkId() = chunkIdReference()?.eventId
-
- companion object {
- const val KIND = 30309
- const val ALT_DESCRIPTION = "TranslationChunk"
-
- fun build(
- translationChapterId: String,
- chunkId: String,
- index: Int,
- text: String,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, text, createdAt) {
- alt(ALT_DESCRIPTION)
- addUnique(TranslationChapterIdTag.assemble(translationChapterId))
- addUnique(ChunkIdTag.assemble(chunkId))
- addUnique(IndexTag.assemble(index))
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationContributorListEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationContributorListEvent.kt
deleted file mode 100644
index ac186cef..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationContributorListEvent.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip22Comments.RootScope
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.nip50Search.SearchableEvent
-import com.vitorpamplona.quartz.utils.TimeUtils
-
-
-@Immutable
-class TranslationContributorListEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
-
- companion object {
- const val KIND = 30310
- const val ALT_DESCRIPTION = "TranslationContributorListEvent"
-
- fun build(
- content: String,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, content, createdAt) {
- alt(ALT_DESCRIPTION)
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationEvent.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationEvent.kt
deleted file mode 100644
index 978f0eea..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/TranslationEvent.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303
-
-import androidx.compose.runtime.Immutable
-import com.vitorpamplona.quartz.nip01Core.core.Event
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
-import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate
-import com.vitorpamplona.quartz.nip22Comments.RootScope
-import com.vitorpamplona.quartz.nip31Alts.alt
-import com.vitorpamplona.quartz.nip50Search.SearchableEvent
-import com.vitorpamplona.quartz.utils.TimeUtils
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationArtifactVersionIdTag
-import com.machankura.bennu.compose.nostr.nip30303.tags.TranslationChunkIdTag
-
-
-@Immutable
-class TranslationEvent(
- id: HexKey,
- pubKey: HexKey,
- createdAt: Long,
- tags: Array>,
- content: String,
- sig: HexKey,
-) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
-
- fun translationChunkIdReference() = tags.firstNotNullOfOrNull(TranslationChunkIdTag::parse)?.ref
- fun translationChunkId() = translationChunkIdReference()?.eventId
-
- fun translationArtifactVersionIdReference() = tags.firstNotNullOfOrNull(TranslationArtifactVersionIdTag::parse)?.ref
- fun translationArtifactVersionId() = translationArtifactVersionIdReference()?.eventId
-
- companion object {
- const val KIND = 30311
- const val ALT_DESCRIPTION = "Translation"
-
- fun build(
- content: String,
- createdAt: Long = TimeUtils.now(),
- initializer: TagArrayBuilder.() -> Unit = {},
- ) = eventTemplate(KIND, content, createdAt) {
- alt(ALT_DESCRIPTION)
- initializer()
- }
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ArtifactIdTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ArtifactIdTag.kt
deleted file mode 100644
index 05679d22..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ArtifactIdTag.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
-import com.vitorpamplona.quartz.nip01Core.tags.events.EventReference
-import com.vitorpamplona.quartz.utils.arrayOfNotNull
-import com.vitorpamplona.quartz.utils.ensure
-
-data class ArtifactIdTag(
- val ref: EventReference,
-) {
- constructor(eventId: String, relayHint: NormalizedRelayUrl?, pubkey: String?) : this(
- EventReference(eventId, pubkey, relayHint)
- )
-
- companion object {
- const val TAG_NAME = "artifactId"
-
- fun parse(tag: Array): ArtifactIdTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
- ensure(tag[1].length == 64) { return null }
-
- val relayHint = tag.getOrNull(2)?.let { RelayUrlNormalizer.normalizeOrNull(it) }
-
- return ArtifactIdTag(tag[1], relayHint, tag.getOrNull(3))
- }
-
- fun assemble(
- eventId: HexKey,
- relay: NormalizedRelayUrl? = null,
- pubkey: String? = null,
- ) = arrayOfNotNull(TAG_NAME, eventId, relay?.url, pubkey)
-
- fun assemble(ref: EventReference) = assemble(ref.eventId, ref.relayHint, ref.author)
- }
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ArtifactVersionIdTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ArtifactVersionIdTag.kt
deleted file mode 100644
index ceed58a3..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ArtifactVersionIdTag.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
-import com.vitorpamplona.quartz.nip01Core.tags.events.EventReference
-import com.vitorpamplona.quartz.utils.arrayOfNotNull
-import com.vitorpamplona.quartz.utils.ensure
-
-class ArtifactVersionIdTag(
- val ref: EventReference,
-) {
- constructor(eventId: String, relayHint: NormalizedRelayUrl?, pubkey: String?) : this(
- EventReference(eventId, pubkey, relayHint)
- )
-
- companion object {
- const val TAG_NAME = "artifactVersionId"
-
- fun parse(tag: Array): ArtifactVersionIdTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
- ensure(tag[1].length == 64) { return null }
-
- val relayHint = tag.getOrNull(2)?.let { RelayUrlNormalizer.normalizeOrNull(it) }
-
- return ArtifactVersionIdTag(tag[1], relayHint, tag.getOrNull(3))
- }
-
- fun assemble(
- eventId: HexKey,
- relay: NormalizedRelayUrl? = null,
- pubkey: String? = null,
- ) = arrayOfNotNull(TAG_NAME, eventId, relay?.url, pubkey)
-
- fun assemble(ref: EventReference) = assemble(ref.eventId, ref.relayHint, ref.author)
- }
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ArtifactVersionMetadataTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ArtifactVersionMetadataTag.kt
deleted file mode 100644
index ebb206d9..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ArtifactVersionMetadataTag.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.utils.ensure
-
-class ArtifactVersionMetadataTag(
- val versionLabel: String,
-) {
- fun toTagArray() = assemble(
- versionLabel = versionLabel,
- )
-
- companion object {
- const val TAG_NAME = "artifactVersion"
-
- fun parse(tag: Array): ArtifactVersionMetadataTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
-
- return ArtifactVersionMetadataTag(
- versionLabel = tag[1],
- )
- }
-
- fun assemble(
- versionLabel: String,
- ): Array = arrayOf(
- TAG_NAME,
- versionLabel
- )
-
- fun assemble(artifactVersionMetadataTag: ArtifactVersionMetadataTag) = assemble(
- versionLabel = artifactVersionMetadataTag.versionLabel,
- )
- }
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ChapterIdTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ChapterIdTag.kt
deleted file mode 100644
index 898388c2..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ChapterIdTag.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
-import com.vitorpamplona.quartz.nip01Core.tags.events.EventReference
-import com.vitorpamplona.quartz.utils.arrayOfNotNull
-import com.vitorpamplona.quartz.utils.ensure
-
-class ChapterIdTag(
- val ref: EventReference,
-) {
- constructor(eventId: String, relayHint: NormalizedRelayUrl?, pubkey: String?) : this(
- EventReference(eventId, pubkey, relayHint)
- )
-
- companion object {
- const val TAG_NAME = "chapterIdTag"
-
- fun parse(tag: Array): ChapterIdTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
- ensure(tag[1].length == 64) { return null }
-
- val relayHint = tag.getOrNull(2)?.let { RelayUrlNormalizer.normalizeOrNull(it) }
-
- return ChapterIdTag(tag[1], relayHint, tag.getOrNull(3))
- }
-
- fun assemble(
- eventId: HexKey,
- relay: NormalizedRelayUrl? = null,
- pubkey: String? = null,
- ) = arrayOfNotNull(TAG_NAME, eventId, relay?.url, pubkey)
-
- fun assemble(ref: EventReference) = assemble(ref.eventId, ref.relayHint, ref.author)
- }
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ChunkIdTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ChunkIdTag.kt
deleted file mode 100644
index 0ef01f08..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ChunkIdTag.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
-import com.vitorpamplona.quartz.nip01Core.tags.events.EventReference
-import com.vitorpamplona.quartz.utils.arrayOfNotNull
-import com.vitorpamplona.quartz.utils.ensure
-
-class ChunkIdTag(
- val ref: EventReference,
-) {
- constructor(eventId: String, relayHint: NormalizedRelayUrl?, pubkey: String?) : this(
- EventReference(eventId, pubkey, relayHint)
- )
-
- companion object {
- const val TAG_NAME = "chunkIdTag"
-
- fun parse(tag: Array): ChunkIdTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
- ensure(tag[1].length == 64) { return null }
-
- val relayHint = tag.getOrNull(2)?.let { RelayUrlNormalizer.normalizeOrNull(it) }
-
- return ChunkIdTag(tag[1], relayHint, tag.getOrNull(3))
- }
-
- fun assemble(
- eventId: HexKey,
- relay: NormalizedRelayUrl? = null,
- pubkey: String? = null,
- ) = arrayOfNotNull(TAG_NAME, eventId, relay?.url, pubkey)
-
- fun assemble(ref: EventReference) = assemble(ref.eventId, ref.relayHint, ref.author)
- }
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ContributorTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ContributorTag.kt
deleted file mode 100644
index 71ebe987..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/ContributorTag.kt
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.utils.ensure
-
-/**
- * Based on NIP-F4
- */
-class ContributorTag(
- val pubKey: HexKey,
- val role: String? = null,
-) {
- fun toTagArray() = assemble(pubKey, role)
-
- companion object {
- const val TAG_NAME = "p"
-
- const val ROLE_TRANSLATOR = "translator"
- const val ROLE_PROOF_READER = "proofreader"
- const val ROLE_EDITOR = "editor"
-
- private val KNOWN_ROLES = setOf(ROLE_TRANSLATOR, ROLE_PROOF_READER, ROLE_EDITOR)
-
- fun isTagged(tag: Array) = tag.has(1) && tag[0] == TAG_NAME && tag[1].length == 64
-
- fun parse(tag: Array): ContributorTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
- ensure(tag[1].length == 64) { return null }
- // NIP-F4 overloads slot 2 as role — but only host/cohost/editor are spec-defined.
- // Anything else (notably a stale relay-hint URL copied from a kind:3 p-tag) gets
- // dropped so it doesn't render as 'Role: wss://relay…' under the author chip.
- val role = tag.getOrNull(2)?.takeIf { it in KNOWN_ROLES }
- return ContributorTag(tag[1], role)
- }
-
- fun assemble(
- pubKey: HexKey,
- role: String? = null,
- ): Array =
- if (role.isNullOrEmpty()) {
- arrayOf(TAG_NAME, pubKey)
- } else {
- arrayOf(TAG_NAME, pubKey, role)
- }
-
- fun assemble(author: ContributorTag) = assemble(author.pubKey, author.role)
-
- fun assemble(authors: List) = authors.map { assemble(it) }
- }
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/CountryTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/CountryTag.kt
deleted file mode 100644
index 07b578fd..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/CountryTag.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.utils.ensure
-
-class CountryTag(
- val country: String,
-) {
- fun toTagArray() = assemble(country = country)
-
- companion object {
- const val TAG_NAME = "country"
-
- fun parse(tag: Array): CountryTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
-
- return CountryTag(country = tag[1])
- }
-
- fun assemble(country: String): Array = arrayOf(TAG_NAME, country)
-
- fun assemble(countryTag: CountryTag) = assemble(country = countryTag.country)
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/DialectIdTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/DialectIdTag.kt
deleted file mode 100644
index 7b544d8e..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/DialectIdTag.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
-import com.vitorpamplona.quartz.nip01Core.tags.events.EventReference
-import com.vitorpamplona.quartz.utils.arrayOfNotNull
-import com.vitorpamplona.quartz.utils.ensure
-
-class DialectIdTag(
- val ref: EventReference,
-) {
- constructor(eventId: String, relayHint: NormalizedRelayUrl?, pubkey: String?) : this(
- EventReference(eventId, pubkey, relayHint)
- )
-
- companion object {
- const val TAG_NAME = "dialectIdTag"
-
- fun parse(tag: Array): DialectIdTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
- ensure(tag[1].length == 64) { return null }
-
- val relayHint = tag.getOrNull(2)?.let { RelayUrlNormalizer.normalizeOrNull(it) }
-
- return DialectIdTag(tag[1], relayHint, tag.getOrNull(3))
- }
-
- fun assemble(
- eventId: HexKey,
- relay: NormalizedRelayUrl? = null,
- pubkey: String? = null,
- ) = arrayOfNotNull(TAG_NAME, eventId, relay?.url, pubkey)
-
- fun assemble(ref: EventReference) = assemble(ref.eventId, ref.relayHint, ref.author)
- }
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/IndexTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/IndexTag.kt
deleted file mode 100644
index 10833c25..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/IndexTag.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.utils.ensure
-
-class IndexTag(
- val index: Int,
-) {
- fun toTagArray() = assemble(
- index = index,
- )
-
- companion object {
- const val TAG_NAME = "index"
-
- fun parse(tag: Array): IndexTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
-
- val index = tag[1].toIntOrNull() ?: return null
- return IndexTag(
- index = index,
- )
- }
-
- fun assemble(
- index: Int,
- ): Array = arrayOf(
- TAG_NAME,
- index.toString()
- )
-
- fun assemble(indexTag: IndexTag) = assemble(
- index = indexTag.index,
- )
- }
-}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/LanguageTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/LanguageTag.kt
deleted file mode 100644
index 3060d6c6..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/LanguageTag.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.utils.ensure
-
-class LanguageTag(
- val language: String,
-) {
- fun toTagArray() = assemble(language = language)
-
- companion object {
- const val TAG_NAME = "language"
-
- fun parse(tag: Array): LanguageTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
-
- return LanguageTag(language = tag[1])
- }
-
- fun assemble(language: String): Array = arrayOf(TAG_NAME, language)
-
- fun assemble(languageTag: LanguageTag) = assemble(language = languageTag.language)
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/LicenseTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/LicenseTag.kt
deleted file mode 100644
index 3bf5a07b..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/LicenseTag.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.utils.ensure
-
-class LicenseTag(
- val license: String,
-) {
- fun toTagArray() = assemble(license = license)
-
- companion object {
- const val TAG_NAME = "license"
-
- fun parse(tag: Array): LicenseTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
-
- return LicenseTag(license = tag[1])
- }
-
- fun assemble(license: String): Array = arrayOf(TAG_NAME, license)
-
- fun assemble(licenseTag: LicenseTag) = assemble(license = licenseTag.license)
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/NameTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/NameTag.kt
deleted file mode 100644
index d467590c..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/NameTag.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.utils.ensure
-
-class NameTag(
- val name: String,
-) {
- fun toTagArray() = assemble(name = name)
-
- companion object {
- const val TAG_NAME = "name"
-
- fun parse(tag: Array): NameTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
-
- return NameTag(name = tag[1])
- }
-
- fun assemble(name: String): Array = arrayOf(TAG_NAME, name)
-
- fun assemble(nameTag: NameTag) = assemble(name = nameTag.name)
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/OriginalTextTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/OriginalTextTag.kt
deleted file mode 100644
index 29c06d83..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/OriginalTextTag.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.utils.ensure
-
-class OriginalTextTag(
- val originalText: String,
-) {
- fun toTagArray() = assemble(originalText = originalText)
-
- companion object {
- const val TAG_NAME = "original_text"
-
- fun parse(tag: Array): OriginalTextTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
-
- return OriginalTextTag(originalText = tag[1])
- }
-
- fun assemble(originalText: String): Array = arrayOf(TAG_NAME, originalText)
-
- fun assemble(originalTextTag: OriginalTextTag) = assemble(originalText = originalTextTag.originalText)
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/PayloadIdTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/PayloadIdTag.kt
deleted file mode 100644
index b8f9a4a0..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/PayloadIdTag.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.HexKey
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
-import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
-import com.vitorpamplona.quartz.nip01Core.tags.events.EventReference
-import com.vitorpamplona.quartz.utils.arrayOfNotNull
-import com.vitorpamplona.quartz.utils.ensure
-
-/**
- * The event a submission carries, named on the submission itself.
- *
- * The payload is already in the submission's content, so this tag is not how a
- * reader gets at it -- it is how they filter for it. The author slot matters
- * more than usual here: on a submission it names whoever wrote the payload,
- * who is not necessarily the member who submitted it.
- */
-data class PayloadIdTag(
- val ref: EventReference,
-) {
- constructor(eventId: String, relayHint: NormalizedRelayUrl?, pubkey: String?) : this(
- EventReference(eventId, pubkey, relayHint)
- )
-
- companion object {
- const val TAG_NAME = "payloadId"
-
- fun parse(tag: Array): PayloadIdTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
- ensure(tag[1].length == 64) { return null }
-
- val relayHint = tag.getOrNull(2)?.let { RelayUrlNormalizer.normalizeOrNull(it) }
-
- return PayloadIdTag(tag[1], relayHint, tag.getOrNull(3))
- }
-
- fun assemble(
- eventId: HexKey,
- relay: NormalizedRelayUrl? = null,
- pubkey: String? = null,
- ) = arrayOfNotNull(TAG_NAME, eventId, relay?.url, pubkey)
-
- fun assemble(ref: EventReference) = assemble(ref.eventId, ref.relayHint, ref.author)
- }
-}
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/PayloadKindTag.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/PayloadKindTag.kt
deleted file mode 100644
index 4ab55914..00000000
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/nostr/nip30303/tags/PayloadKindTag.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.machankura.bennu.compose.nostr.nip30303.tags
-
-import com.vitorpamplona.quartz.nip01Core.core.has
-import com.vitorpamplona.quartz.utils.ensure
-
-/**
- * The kind of the event a submission carries.
- *
- * Lets a client decide whether it can apply a submission without parsing the
- * payload JSON out of the content first.
- */
-class PayloadKindTag(
- val kind: Int,
-) {
- fun toTagArray() = assemble(
- kind = kind,
- )
-
- companion object {
- const val TAG_NAME = "payloadKind"
-
- fun parse(tag: Array): PayloadKindTag? {
- ensure(tag.has(1)) { return null }
- ensure(tag[0] == TAG_NAME) { return null }
-
- val kind = tag[1].toIntOrNull() ?: return null
- return PayloadKindTag(
- kind = kind,
- )
- }
-
- fun assemble(
- kind: Int,
- ): Array