Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update contracts #3

Open
wants to merge 90 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
cf92b94
fix invite flow
vibern0 Oct 14, 2024
096578f
update addresses to 0.3.7
vibern0 Oct 14, 2024
1382145
feat: update addresses
vibern0 Oct 16, 2024
b5997ac
fix: create avatar when invited if does not exists
vibern0 Oct 16, 2024
3c16d0e
feat: trustee and truster as avatars
vibern0 Oct 16, 2024
3cd3f55
feat: cidV0 + fix number of trusts
vibern0 Oct 16, 2024
19264da
feat: add caching of user Profiles from IPFS metadata fetch
johannafransn Oct 22, 2024
0da78ba
feat: do not register self trust
vibern0 Oct 28, 2024
f3b002b
try/catch on external call
vibern0 Oct 28, 2024
6afadb6
feat: mint end period
vibern0 Oct 28, 2024
b36a372
feat: last mint and mint end period optional
vibern0 Oct 28, 2024
1b0ea24
feat: remove unused
vibern0 Oct 28, 2024
92d8d1c
feat: split handler files
vibern0 Oct 28, 2024
b4ea320
fix: config
vibern0 Oct 29, 2024
9cc3c8f
feat: add support to pathfinder
vibern0 Oct 29, 2024
2ca2fe3
Merge pull request #1 from gnosis/bernardovieira/gw-974-add-pathfinde…
johannafransn Oct 29, 2024
7614a84
fix: mintEndPeriod as Int
vibern0 Oct 29, 2024
e9f07b0
feat: save last demurrage timestamp
vibern0 Oct 29, 2024
d3c8857
Merge pull request #2 from gnosis/vibern/save-last-demurrage-timestamp
teawaterwire Oct 30, 2024
f2a227d
chore: deploy to envio
Oct 30, 2024
99193fb
fix: add demurrage property in v1 hub handler
teawaterwire Oct 30, 2024
4d61d7a
feat: cache by metadigest (#3)
vibern0 Oct 31, 2024
d6aa0d3
feat: add back v1 addresses
vibern0 Oct 31, 2024
f8b39c8
feat: bump envio dep
vibern0 Oct 31, 2024
f4e01b5
fresh install
johannafransn Nov 1, 2024
c894fec
comment out v1 contracts for now to speed up syncing
johannafransn Nov 1, 2024
a8209cc
add back invitedBy
johannafransn Nov 1, 2024
f8b6cc8
feat: refactor token wrapping to erc20 (#4)
vibern0 Nov 4, 2024
cdfc081
feat: isVerified prop in Avatar entity
vibern0 Nov 4, 2024
c682bcc
feat: tokenOwner as Avatar entity
vibern0 Nov 4, 2024
39daec7
feat: circles v1
vibern0 Nov 5, 2024
027b6a0
fix: crc breakdown displayed wrong (#5)
vibern0 Nov 7, 2024
8ac3063
add debug for pending invites
johannafransn Nov 11, 2024
5e6d4d9
feat: improve token owner id
vibern0 Nov 13, 2024
384b014
feat: add enum docs
vibern0 Nov 13, 2024
604e8df
fix: trust relations v1 and v2
vibern0 Nov 13, 2024
19dcf0b
feat: add entities to docs
vibern0 Nov 13, 2024
8083e2c
docs: add group membership example
vibern0 Nov 13, 2024
ac7f120
docs : new trust example
vibern0 Nov 14, 2024
0d0b24d
fix: profile undefined values
vibern0 Nov 14, 2024
66a62f4
feat: do not handle HubTransfer v1
vibern0 Nov 14, 2024
33629d4
feat: hub transfer handler
vibern0 Nov 18, 2024
4182de7
feat: update avatar balance with computedValue prop + fix balance
vibern0 Nov 18, 2024
9b58242
feat: is migrated prop
vibern0 Nov 18, 2024
e9f796e
docs: get invited
vibern0 Nov 19, 2024
8c37584
feat: remove deprecated test file
vibern0 Nov 19, 2024
181cef0
feat: update cache.db
vibern0 Nov 19, 2024
88d381b
feat: bump deps
vibern0 Nov 19, 2024
c04bb3b
feat: bumo envio dep
vibern0 Nov 19, 2024
1608a86
feat: enable v1
vibern0 Nov 19, 2024
a9cfdda
feat: add trusts given and trusts received with docs
vibern0 Nov 20, 2024
dc2a864
feat: remove contractRegister handle
vibern0 Nov 20, 2024
cadfc58
feat: use preRegisterDynamicContracts
vibern0 Nov 21, 2024
7e7aa66
fix: untrust
vibern0 Nov 21, 2024
717886f
feat: trusts given and received count + fix invited by + loaders
vibern0 Nov 21, 2024
010006a
feat: new transfer type + demurrage linked to transfer
vibern0 Nov 21, 2024
e229eac
fix: remove profile cache usage
vibern0 Nov 21, 2024
74e0d38
docs: transfer with demurrage
vibern0 Nov 22, 2024
072b103
feat: measure public gateways 29 seconds, add more validation to prof…
johannafransn Nov 22, 2024
ffad769
feat: add centralized endpoint as well which uses private IPFS gateway
johannafransn Nov 22, 2024
cc359e0
feat: small cleanup
johannafransn Nov 22, 2024
b4bebf4
feat: small cleanup
johannafransn Nov 22, 2024
d4cc804
Merge pull request #6 from gnosis/johanna/gw-1040-fix-ipfs-timeouts
johannafransn Nov 22, 2024
6ad97cf
feat: fix conflicts, deploy for test recent start block head ipfs tim…
johannafransn Nov 22, 2024
094c812
feat: delete cache
johannafransn Nov 22, 2024
db0661d
feat: comment out anything that has to do with ProfileCache as it fai…
johannafransn Nov 22, 2024
9f2d3df
feat: new deploy with no IPFS timeouts
johannafransn Nov 22, 2024
ed0eb20
Merge remote-tracking branch 'origin/envio'
johannafransn Nov 22, 2024
70190ca
feat: bump envio to 2.8.2
vibern0 Nov 25, 2024
bcffc7d
fix: safeTxHash for mint and stream completed
vibern0 Nov 29, 2024
00a54c4
fix: typo
vibern0 Nov 29, 2024
6162578
feat: add migrating avatarType
vibern0 Nov 29, 2024
e7025ff
docs: limit and experyTime note
vibern0 Nov 29, 2024
9773b4b
fix: update avatar type on first trust
vibern0 Dec 2, 2024
a2e6e31
fix: avatar type on invite
vibern0 Dec 2, 2024
b6db467
fix: transfer not flagged as demurrage
vibern0 Dec 3, 2024
df17476
feat: bump envio
vibern0 Dec 3, 2024
8f1f7ca
feat: add v1 profiles (#7)
vibern0 Dec 3, 2024
90fabeb
feat: metri fee (#8)
vibern0 Dec 16, 2024
87f99ba
fix: prevent v1 avatar to override v2 avatar (#9)
vibern0 Dec 16, 2024
9346da9
fix: migrate to v2 (#11)
vibern0 Dec 16, 2024
c54f670
feat: bump deps (#12)
vibern0 Dec 16, 2024
c86f788
feat: update .cache (#13)
vibern0 Dec 16, 2024
3041f74
feat: crc token total supply (#14)
vibern0 Dec 20, 2024
e93e14c
fix: v1 trustee truster (#15)
vibern0 Dec 20, 2024
51b7a94
feat: avatar migrated property (#16)
vibern0 Dec 20, 2024
62f4dfb
fix: v2 isMutual (#17)
vibern0 Dec 20, 2024
0b3e97c
fix: v2 isMutual (#18)
vibern0 Dec 23, 2024
f57e63a
feat: prevent saving empty fields from ipfs (#19)
vibern0 Dec 23, 2024
67a1af3
feat: transfers as part of transaction (#20)
vibern0 Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .cache/cache.db
Binary file not shown.
255 changes: 255 additions & 0 deletions DOCS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
## Entities

### Transfer
A unified view of all transfer transactions within the system, consolidating both v1 and v2 transfers. This entity covers all major transfer events (e.g., `Erc20WrapperTransfer`, `TransferSingle`, `HubTransfer`).

- **Key Fields:**
- `blockNumber`
- `timestamp`
- `transactionIndex`
- `logIndex`
- `batchIndex`
- `transactionHash`
- `version`
- `operator` (v2 only)
- `from`
- `to`
- `id`
- `value`
- `type` (transaction type; e.g., `Erc20WrapperTransfer`, `TransferSingle`, etc.)
- `tokenType` (e.g., `RegisterGroup`, `RegisterHuman`, etc.)

#### Transfers with demurrage

It's possible to get demurrages that happened during transfers or mints.

```graphql
query getUserTransfers($address: String) {
Transfer(
where:{
to: {_eq:$address},
transferType: {_neq:"Demurrage"}
}
order_by: {timestamp: desc}
) {
id
from { id }
to { id }
transferType
timestamp
value
demurrageFrom {
id
value
}
demurrageTo {
id
from
value
}
}
}
```

This would not list demurrages transfers on the list, only within the transfers when they happened.

Normally, it's the `demurrageFrom` that contains the demurrage data. But if `transferType` is `StreamCompleted`, then, there might be the case that the user receiving the transfer will also have some demurrage applied. What is needed in that case to show data correctly is to compare `demurrageTo.from` with the user (on app). If it's the same, show `demurrageTo.value`, otherwise show `demurrageFrom.value`. In any on this cases, `demurrageTo` and `demurrageFrom` can be null.


### TrustRelation
Provides a unified view of active trust relationships, consolidating data from both v1 and v2. A v2 trust won't replace a v1 trust.

- **Key Fields:**
- `blockNumber`
- `timestamp`
- `transactionIndex`
- `logIndex`
- `transactionHash`
- `version`
- `trustee`
- `truster`
- `expiryTime` (v2 only or set to UInt256.MAX in v1)
- `limit` (v1 only or set to `100` in v2)

It's important to note that, when an avatar untrusts another avatar, the trust relation is not deleted, but the `limit` and `expiryTime` are set to `0`.

Trust relations from a group to an avatar represent membership of a group (following the rules on the smart contracts).

Example:
```graphql
query getGroupMembership($groupAddress: String) {
TrustRelation(where: {truster_id: {_eq: $groupAddress}, limit: {_gt: 0}}) {
expiryTime
trustee {
profile {
name
}
}
}
}
```

v1 trusts and v2 trusts are different entities, even between the same users. And there's a truster and trustee, which would make, filtering by two addresses, the possibility of duplicated results. Here's how it can be done

```graphql
query getTrustBetweenAddresses($address: String, $userAddress: String) {
TrustRelation(
where: {
_or: [
{
truster_id: {_eq: $address},
trustee_id: {_eq: $userAddress, _neq: $address}
},
{
truster_id: {_eq: $userAddress},
trustee_id: {_eq: $address, _neq: $userAddress}
}
],
version: { _in: [1, 2] }
}
) {
version
isMutual
truster_id
trustee_id
}
}
```

In case you want only v1 trust that were not migrated, you can query `isMigrated: { _eq: false }`.


### Avatar
A unified view of all humans, groups, and organizations within the system, supporting both v1 and v2 avatars.

- **Key Fields:**
- `blockNumber`
- `timestamp`
- `transactionIndex`
- `logIndex`
- `transactionHash`
- `version`
- `type` (e.g., `RegisterGroup`, `RegisterOrganization`, etc.)
- `invitedBy`
- `avatar`
- `tokenId`
- `name` (for groups only)
- `cidV0Digest` (profile IPFS CID)


### AvatarBalance
This entity tracks token balances for each avatar.

Examples:

Get avatar balances, the token owner for each token and the trust relation between the owner of that token and the user.

```graphql
query verifiedAndUnverifiedCRCTokens($address: String) {
AvatarBalance(where: {avatar_id: {_eq: $address}}) {
balance
token {
id
tokenOwner {
id
profile {
name
}
isVerified
trustsGiven(where: {trustee_id: {_eq: $address}}) {
trustee_id
truster_id
}
trustsReceived(where: {truster_id: {_eq: $address}}) {
trustee_id
truster_id
}
}
}
}
}
```

### Profile
The Profile entity contains descriptive metadata (from IPFS) for avatars, including names, images, and symbols for groups.


### Token
A unified view of tokens in the system, capturing both v1 and v2 token data.

- **Key Fields:**
- `blockNumber`
- `timestamp`
- `transactionIndex`
- `logIndex`
- `transactionHash`
- `version`
- `type` (e.g., `RegisterGroup`, `RegisterHuman`, etc.)
- `token` (token address)
- `tokenOwner`

## Enums

### TransferType
Defines the various types of transfer actions.

- **Values:**
- `Erc20WrapperTransfer`: v2 wrapped transfers.
- `TransferSingle`: v2 single transfers.
- `TransferBatch`: v2 batch transfers.
- `StreamCompleted`: v2 completed streams.
- `HubTransfer`: v1 transfers with pathfinder.
- `Transfer`: v1 transfers.
- `GroupMintSingle`: v2 group mint token single.
- `GroupMintBatch`: v2 group mint token batch.
- `GroupRedeem`: Reserved for future use.
- `GroupRedeemCollateralReturn`: Reserved for future use.
- `GroupRedeemCollateralBurn`: Reserved for future use.

### AvatarType
Defines the type of avatars.

- **Values:**
- `Signup`: v1 user sign-up.
- `OrganizationSignup`: v1 organization sign-up.
- `RegisterHuman`: v2 registered or migrated user (with `invitedBy` if migrated).
- `Invite`: v2 user that is not yet on circles and has at least one invite.
- `RegisterGroup`: v2 group.
- `RegisterOrganization`: v2 organization.
- `Migrating`: v1 user that is migrating to v2.
- `Unknown`: Pending state.

The `Unknown` pending state happens when a user created a v2 profile, but did not yet receive an invite or joined circles. Once the user receives de first invite, then the avatar type is `Invite`.

Suppose you want to get the list of invited users by a given user.

```graphql
query getInvited($address: String, $limit: Int, $offset: Int) {
TrustRelation(
where: {version: {_eq: 2}, truster_id: {_eq: $address}, trustee: {avatarType: {_eq: "Invite"}}}
order_by: {timestamp: desc}
offset: $offset
limit: $limit
) {
version
trustee {
id
version
profile {
name
}
avatarType
}
}
}
```

### TokenType
Describes token types within the system.

- **Values:**
- `RegisterGroup`: v2 group tokens.
- `RegisterHuman`: v2 human tokens.
- `Signup`: v1 human tokens.
- `WrappedDemurrageToken`: v2 demurraged tokens (applicable to humans, groups, or organizations).
- `WrappedStaticToken`: v2 inflationary tokens (applicable to humans, groups, or organizations).
Loading