Skip to content

Commit

Permalink
Merge branch 'master' into releases
Browse files Browse the repository at this point in the history
  • Loading branch information
taoeffect committed Jun 21, 2024
2 parents 89f6d56 + 29e39ab commit 5484805
Show file tree
Hide file tree
Showing 13 changed files with 74,736 additions and 20 deletions.
7,825 changes: 7,825 additions & 0 deletions contracts/0.5.4/chatroom-slim.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions contracts/0.5.4/chatroom.0.5.4.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"head":"{\"manifestVersion\":\"1.0.0\"}","body":"{\"name\":\"gi.contracts/chatroom\",\"version\":\"0.5.4\",\"contract\":{\"hash\":\"z9brRu3VQskhDbpUpSmiDBMChcigG1m1iTd1dLEjsUnAKugxxXDM\",\"file\":\"chatroom.js\"},\"signingKeys\":[\"[\\\"edwards25519sha512batch\\\",\\\"IjAFp6gIzHW2HOIXXS9b4A3EKf8t9NNa5nndHcROiDk=\\\",null]\"],\"contractSlim\":{\"file\":\"chatroom-slim.js\",\"hash\":\"z9brRu3VGtzYPrmJAR8rrqPbvnxE8LoohKxVpjNrNtAMjwxxWnNe\"}}","signature":{"keyId":"z2DrjgbCDg34SaBhFjNEF45AVodCUu7QwcFBksz3BDgN4BekrdN","value":"dppjAw7EzhGdv7vQRKfzJ5XE+db8PKPBEdy17alb9kDVsx5TA7HaZ1bLR30ZEVHkD/SyE8Qf+ZD12hkCGTQ/AQ=="}}
16,643 changes: 16,643 additions & 0 deletions contracts/0.5.4/chatroom.js

Large diffs are not rendered by default.

9,025 changes: 9,025 additions & 0 deletions contracts/0.5.4/group-slim.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions contracts/0.5.4/group.0.5.4.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"head":"{\"manifestVersion\":\"1.0.0\"}","body":"{\"name\":\"gi.contracts/group\",\"version\":\"0.5.4\",\"contract\":{\"hash\":\"z9brRu3VNdaFTHNWqFsyvjVPMi7nA7ENyf2NF2QVrsxZevsS4RRK\",\"file\":\"group.js\"},\"signingKeys\":[\"[\\\"edwards25519sha512batch\\\",\\\"IjAFp6gIzHW2HOIXXS9b4A3EKf8t9NNa5nndHcROiDk=\\\",null]\"],\"contractSlim\":{\"file\":\"group-slim.js\",\"hash\":\"z9brRu3VTXnbXLZX72NxECZXMkKTequcKceBwXfqWiAwkZdszc58\"}}","signature":{"keyId":"z2DrjgbCDg34SaBhFjNEF45AVodCUu7QwcFBksz3BDgN4BekrdN","value":"hlSiceBP2V2pglnXQsJKZQRUi2f5M/8b1cAqkHMTUEFvoD8D03S2PeyIB8tEPmwpb+Oc/hkzZ6k0gN2bAVFaBg=="}}
17,854 changes: 17,854 additions & 0 deletions contracts/0.5.4/group.js

Large diffs are not rendered by default.

7,269 changes: 7,269 additions & 0 deletions contracts/0.5.4/identity-slim.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions contracts/0.5.4/identity.0.5.4.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"head":"{\"manifestVersion\":\"1.0.0\"}","body":"{\"name\":\"gi.contracts/identity\",\"version\":\"0.5.4\",\"contract\":{\"hash\":\"z9brRu3VSnU2hBVkgsZtrYGSH82v4b6aYrJ1FscYsDFSNwBWnUHJ\",\"file\":\"identity.js\"},\"signingKeys\":[\"[\\\"edwards25519sha512batch\\\",\\\"IjAFp6gIzHW2HOIXXS9b4A3EKf8t9NNa5nndHcROiDk=\\\",null]\"],\"contractSlim\":{\"file\":\"identity-slim.js\",\"hash\":\"z9brRu3VPYGaiYhWjCDKEn4at4SJyUCLNqBfZAHJY5QmJSJ42gJv\"}}","signature":{"keyId":"z2DrjgbCDg34SaBhFjNEF45AVodCUu7QwcFBksz3BDgN4BekrdN","value":"lMOL5BZ3BOf5btxd3ZYy3RmRsABema9060w/8dh0AK1DaaNcU0/azj83eG6Fd0La/NPtpVvo76dUG8YX/g+6Dw=="}}
16,089 changes: 16,089 additions & 0 deletions contracts/0.5.4/identity.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions frontend/controller/actions/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export const encryptedAction = (

try {
// Writing to a contract requires being subscribed to it
// Since we're only interested in writing and we don't know whether
// we're subscribed or should be, we use an ephemeral retain here that
// is undone at the end in a finally block.
await sbp('chelonia/contract/retain', contractID, { ephemeral: true })
const state = {
[contractID]: await sbp('chelonia/latestContractState', contractID)
Expand Down
39 changes: 22 additions & 17 deletions frontend/model/contracts/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,23 @@ sbp('chelonia/defineContract', {
}

try {
await sbp('chelonia/contract/retain', chatRoomID, { ephemeral: true })
// We need to be subscribed to the chatroom before writing to it, and
// also because of the following check (hasKeysToPerformOperation),
// which requires state.
// If we're joining the chatroom ourselves (actorID === memberID),
// ensure we _remain_ subscribed to the chatroom by not using an
// ephemeral call to retain.
// If we're _not_ joining the chatroom ourselves (but instead we've
// added someone else), we use 'ephemeral: true' because we don't want
// to remain subscribed to the chatroom if we're not a member(*).
// This used to be done in four steps: unconditional ephemeral retain
// here, ended with an ephemeral release in the finally block, and two
// conditional persistent retains on postpublish (for the current
// device) and the error handler (for other devices). This was too
// complex.
// (*) Yes, usually we'd be a member of the chatroom in this case, but
// we could have left afterwards.
await sbp('chelonia/contract/retain', chatRoomID, actorID !== memberID ? { ephemeral: true } : {})

if (!sbp('chelonia/contract/hasKeysToPerformOperation', chatRoomID, 'gi.contracts/chatroom/join')) {
throw new Error(`Missing keys to join chatroom ${chatRoomID}`)
Expand All @@ -1768,29 +1784,18 @@ sbp('chelonia/defineContract', {
await sbp('gi.actions/chatroom/join', {
contractID: chatRoomID,
data: actorID === memberID ? {} : { memberID },
encryptionKeyId,
...actorID === memberID && {
hooks: {
postpublish: () => {
sbp('chelonia/contract/retain', chatRoomID)
}
}
}
encryptionKeyId
}).catch(e => {
if (e.name === 'GIErrorUIRuntimeError' && e.cause?.name === 'GIChatroomAlreadyMemberError') {
if (actorID === memberID) {
// Increase reference count if we've already joined
// Note: this addresses syncing the contract from a new device,
// where `retain` in postpublish hasn't been called and the
// reference count is zero due to the state being fresh.
sbp('chelonia/contract/retain', chatRoomID)
}
return
}

console.warn(`Unable to join ${memberID} to chatroom ${chatRoomID} for group ${contractID}`, e)
})
} finally {
await sbp('chelonia/contract/release', chatRoomID, { ephemeral: true })
if (actorID !== memberID) {
await sbp('chelonia/contract/release', chatRoomID, { ephemeral: true })
}
}
},
// eslint-disable-next-line require-await
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "group-income",
"version": "0.5.3",
"contractsVersion": "0.5.3",
"version": "0.5.4",
"contractsVersion": "0.5.4",
"private": true,
"description": "",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion shared/domains/chelonia/internals.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ export default (sbp('sbp/selectors/register', {
}
}

const previousVolatileState = targetState._volatile
const previousVolatileState = targetState?._volatile
sbp('chelonia/private/queueEvent', v.contractID, ['chelonia/private/postKeyShare', v.contractID, mustResync ? previousVolatileState : null, signingKey])
.then(() => {
// The CONTRACT_HAS_RECEIVED_KEYS event is placed on the queue for
Expand Down

0 comments on commit 5484805

Please sign in to comment.