@geoprotocol/geo-sdk 0.18.3 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +995 -372
- package/dist/contracts.d.ts +0 -11
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +0 -11
- package/dist/contracts.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/lite.d.ts +2 -0
- package/dist/lite.d.ts.map +1 -1
- package/dist/lite.js +2 -0
- package/dist/lite.js.map +1 -1
- package/dist/src/abis/dao-space-factory.d.ts +43 -6
- package/dist/src/abis/dao-space-factory.d.ts.map +1 -1
- package/dist/src/abis/dao-space-factory.js +38 -27
- package/dist/src/abis/dao-space-factory.js.map +1 -1
- package/dist/src/abis/dao-space-v2.test.d.ts +2 -0
- package/dist/src/abis/dao-space-v2.test.d.ts.map +1 -0
- package/dist/src/abis/dao-space-v2.test.js +67 -0
- package/dist/src/abis/dao-space-v2.test.js.map +1 -0
- package/dist/src/abis/dao-space.d.ts +98 -7
- package/dist/src/abis/dao-space.d.ts.map +1 -1
- package/dist/src/abis/dao-space.js +61 -99
- package/dist/src/abis/dao-space.js.map +1 -1
- package/dist/src/abis/index.d.ts +2 -2
- package/dist/src/abis/index.d.ts.map +1 -1
- package/dist/src/abis/index.js +2 -2
- package/dist/src/abis/index.js.map +1 -1
- package/dist/src/abis/space-registry.d.ts +26 -0
- package/dist/src/abis/space-registry.d.ts.map +1 -1
- package/dist/src/abis/space-registry.js +33 -0
- package/dist/src/abis/space-registry.js.map +1 -1
- package/dist/src/api-surface.e2e.test.d.ts +2 -0
- package/dist/src/api-surface.e2e.test.d.ts.map +1 -0
- package/dist/src/api-surface.e2e.test.js +1206 -0
- package/dist/src/api-surface.e2e.test.js.map +1 -0
- package/dist/src/client/api.d.ts +86 -0
- package/dist/src/client/api.d.ts.map +1 -0
- package/dist/src/client/api.js +169 -0
- package/dist/src/client/api.js.map +1 -0
- package/dist/src/client/comments.d.ts +59 -0
- package/dist/src/client/comments.d.ts.map +1 -0
- package/dist/src/client/comments.js +96 -0
- package/dist/src/client/comments.js.map +1 -0
- package/dist/src/client/context.d.ts +20 -0
- package/dist/src/client/context.d.ts.map +1 -0
- package/dist/src/client/context.js +20 -0
- package/dist/src/client/context.js.map +1 -0
- package/dist/src/client/dao-spaces.d.ts +408 -0
- package/dist/src/client/dao-spaces.d.ts.map +1 -0
- package/dist/src/client/dao-spaces.js +626 -0
- package/dist/src/client/dao-spaces.js.map +1 -0
- package/dist/src/client/dao-spaces.test.d.ts +2 -0
- package/dist/src/client/dao-spaces.test.d.ts.map +1 -0
- package/dist/src/client/dao-spaces.test.js +497 -0
- package/dist/src/client/dao-spaces.test.js.map +1 -0
- package/dist/src/client/edits.d.ts +100 -0
- package/dist/src/client/edits.d.ts.map +1 -0
- package/dist/src/client/edits.js +131 -0
- package/dist/src/client/edits.js.map +1 -0
- package/dist/src/client/edits.test.d.ts +2 -0
- package/dist/src/client/edits.test.d.ts.map +1 -0
- package/dist/src/client/edits.test.js +98 -0
- package/dist/src/client/edits.test.js.map +1 -0
- package/dist/src/client/entities.d.ts +23 -0
- package/dist/src/client/entities.d.ts.map +1 -0
- package/dist/src/client/entities.js +88 -0
- package/dist/src/client/entities.js.map +1 -0
- package/dist/src/client/entity-votes.d.ts +141 -0
- package/dist/src/client/entity-votes.d.ts.map +1 -0
- package/dist/src/client/entity-votes.js +168 -0
- package/dist/src/client/entity-votes.js.map +1 -0
- package/dist/src/client/entity-votes.test.d.ts +2 -0
- package/dist/src/client/entity-votes.test.d.ts.map +1 -0
- package/dist/src/client/entity-votes.test.js +93 -0
- package/dist/src/client/entity-votes.test.js.map +1 -0
- package/dist/src/client/graph-workflows.test.d.ts +2 -0
- package/dist/src/client/graph-workflows.test.d.ts.map +1 -0
- package/dist/src/client/graph-workflows.test.js +83 -0
- package/dist/src/client/graph-workflows.test.js.map +1 -0
- package/dist/src/client/images-storage.test.d.ts +2 -0
- package/dist/src/client/images-storage.test.d.ts.map +1 -0
- package/dist/src/client/images-storage.test.js +52 -0
- package/dist/src/client/images-storage.test.js.map +1 -0
- package/dist/src/client/images.d.ts +35 -0
- package/dist/src/client/images.d.ts.map +1 -0
- package/dist/src/client/images.js +90 -0
- package/dist/src/client/images.js.map +1 -0
- package/dist/src/client/personal-spaces.d.ts +229 -0
- package/dist/src/client/personal-spaces.d.ts.map +1 -0
- package/dist/src/client/personal-spaces.js +278 -0
- package/dist/src/client/personal-spaces.js.map +1 -0
- package/dist/src/client/spaces.test.d.ts +2 -0
- package/dist/src/client/spaces.test.d.ts.map +1 -0
- package/dist/src/client/spaces.test.js +175 -0
- package/dist/src/client/spaces.test.js.map +1 -0
- package/dist/src/client/storage.d.ts +52 -0
- package/dist/src/client/storage.d.ts.map +1 -0
- package/dist/src/client/storage.js +53 -0
- package/dist/src/client/storage.js.map +1 -0
- package/dist/src/client.d.ts +338 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +494 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/client.test.d.ts +2 -0
- package/dist/src/client.test.d.ts.map +1 -0
- package/dist/src/client.test.js +125 -0
- package/dist/src/client.test.js.map +1 -0
- package/dist/src/contracts-v2/local-geobrowser.e2e.test.d.ts +2 -0
- package/dist/src/contracts-v2/local-geobrowser.e2e.test.d.ts.map +1 -0
- package/dist/src/contracts-v2/local-geobrowser.e2e.test.js +239 -0
- package/dist/src/contracts-v2/local-geobrowser.e2e.test.js.map +1 -0
- package/dist/src/dao-space/constants.d.ts +16 -3
- package/dist/src/dao-space/constants.d.ts.map +1 -1
- package/dist/src/dao-space/constants.js +16 -5
- package/dist/src/dao-space/constants.js.map +1 -1
- package/dist/src/dao-space/create-space.d.ts +1 -31
- package/dist/src/dao-space/create-space.d.ts.map +1 -1
- package/dist/src/dao-space/create-space.js +5 -70
- package/dist/src/dao-space/create-space.js.map +1 -1
- package/dist/src/dao-space/execute-proposal.d.ts +1 -22
- package/dist/src/dao-space/execute-proposal.d.ts.map +1 -1
- package/dist/src/dao-space/execute-proposal.js +12 -59
- package/dist/src/dao-space/execute-proposal.js.map +1 -1
- package/dist/src/dao-space/index.d.ts +2 -1
- package/dist/src/dao-space/index.d.ts.map +1 -1
- package/dist/src/dao-space/index.js +1 -0
- package/dist/src/dao-space/index.js.map +1 -1
- package/dist/src/dao-space/propose-add-editor.d.ts +1 -20
- package/dist/src/dao-space/propose-add-editor.d.ts.map +1 -1
- package/dist/src/dao-space/propose-add-editor.js +12 -87
- package/dist/src/dao-space/propose-add-editor.js.map +1 -1
- package/dist/src/dao-space/propose-add-editor.test.js +16 -4
- package/dist/src/dao-space/propose-add-editor.test.js.map +1 -1
- package/dist/src/dao-space/propose-add-member.d.ts +1 -20
- package/dist/src/dao-space/propose-add-member.d.ts.map +1 -1
- package/dist/src/dao-space/propose-add-member.js +12 -87
- package/dist/src/dao-space/propose-add-member.js.map +1 -1
- package/dist/src/dao-space/propose-add-member.test.js +13 -0
- package/dist/src/dao-space/propose-add-member.test.js.map +1 -1
- package/dist/src/dao-space/propose-edit.d.ts +1 -30
- package/dist/src/dao-space/propose-edit.d.ts.map +1 -1
- package/dist/src/dao-space/propose-edit.js +12 -108
- package/dist/src/dao-space/propose-edit.js.map +1 -1
- package/dist/src/dao-space/propose-edit.test.js +53 -1
- package/dist/src/dao-space/propose-edit.test.js.map +1 -1
- package/dist/src/dao-space/propose-remove-editor.d.ts +1 -22
- package/dist/src/dao-space/propose-remove-editor.d.ts.map +1 -1
- package/dist/src/dao-space/propose-remove-editor.js +12 -94
- package/dist/src/dao-space/propose-remove-editor.js.map +1 -1
- package/dist/src/dao-space/propose-remove-editor.test.js +24 -11
- package/dist/src/dao-space/propose-remove-editor.test.js.map +1 -1
- package/dist/src/dao-space/propose-remove-member.d.ts +1 -22
- package/dist/src/dao-space/propose-remove-member.d.ts.map +1 -1
- package/dist/src/dao-space/propose-remove-member.js +12 -94
- package/dist/src/dao-space/propose-remove-member.js.map +1 -1
- package/dist/src/dao-space/propose-remove-member.test.js +19 -0
- package/dist/src/dao-space/propose-remove-member.test.js.map +1 -1
- package/dist/src/dao-space/propose-request-membership.d.ts.map +1 -1
- package/dist/src/dao-space/propose-request-membership.js +4 -4
- package/dist/src/dao-space/propose-request-membership.js.map +1 -1
- package/dist/src/dao-space/propose-update-voting-settings.d.ts +8 -0
- package/dist/src/dao-space/propose-update-voting-settings.d.ts.map +1 -0
- package/dist/src/dao-space/propose-update-voting-settings.js +19 -0
- package/dist/src/dao-space/propose-update-voting-settings.js.map +1 -0
- package/dist/src/dao-space/propose-update-voting-settings.test.d.ts +2 -0
- package/dist/src/dao-space/propose-update-voting-settings.test.d.ts.map +1 -0
- package/dist/src/dao-space/propose-update-voting-settings.test.js +118 -0
- package/dist/src/dao-space/propose-update-voting-settings.test.js.map +1 -0
- package/dist/src/dao-space/types.d.ts +72 -11
- package/dist/src/dao-space/types.d.ts.map +1 -1
- package/dist/src/dao-space/vote-proposal.d.ts +1 -24
- package/dist/src/dao-space/vote-proposal.d.ts.map +1 -1
- package/dist/src/dao-space/vote-proposal.js +12 -64
- package/dist/src/dao-space/vote-proposal.js.map +1 -1
- package/dist/src/dao-space/vote-proposal.test.js +54 -0
- package/dist/src/dao-space/vote-proposal.test.js.map +1 -1
- package/dist/src/e2e-test-environment.d.ts +26 -0
- package/dist/src/e2e-test-environment.d.ts.map +1 -0
- package/dist/src/e2e-test-environment.js +150 -0
- package/dist/src/e2e-test-environment.js.map +1 -0
- package/dist/src/encoding.d.ts +3 -0
- package/dist/src/encoding.d.ts.map +1 -1
- package/dist/src/encoding.js +3 -0
- package/dist/src/encoding.js.map +1 -1
- package/dist/src/encodings/get-create-dao-space-calldata.d.ts +34 -97
- package/dist/src/encodings/get-create-dao-space-calldata.d.ts.map +1 -1
- package/dist/src/encodings/get-create-dao-space-calldata.js +66 -109
- package/dist/src/encodings/get-create-dao-space-calldata.js.map +1 -1
- package/dist/src/encodings/get-create-dao-space-calldata.test.js +90 -23
- package/dist/src/encodings/get-create-dao-space-calldata.test.js.map +1 -1
- package/dist/src/encodings/get-create-personal-space-calldata.d.ts +2 -0
- package/dist/src/encodings/get-create-personal-space-calldata.d.ts.map +1 -1
- package/dist/src/encodings/get-create-personal-space-calldata.js +2 -0
- package/dist/src/encodings/get-create-personal-space-calldata.js.map +1 -1
- package/dist/src/full-flow-test.test.js +5 -2
- package/dist/src/full-flow-test.test.js.map +1 -1
- package/dist/src/graph/comment-utils.d.ts +4 -0
- package/dist/src/graph/comment-utils.d.ts.map +1 -1
- package/dist/src/graph/comment-utils.js +4 -0
- package/dist/src/graph/comment-utils.js.map +1 -1
- package/dist/src/graph/constants.d.ts +12 -3
- package/dist/src/graph/constants.d.ts.map +1 -1
- package/dist/src/graph/constants.js +11 -5
- package/dist/src/graph/constants.js.map +1 -1
- package/dist/src/graph/create-comment.d.ts +3 -22
- package/dist/src/graph/create-comment.d.ts.map +1 -1
- package/dist/src/graph/create-comment.js +6 -136
- package/dist/src/graph/create-comment.js.map +1 -1
- package/dist/src/graph/create-comment.test.js +19 -8
- package/dist/src/graph/create-comment.test.js.map +1 -1
- package/dist/src/graph/create-entity.d.ts +2 -0
- package/dist/src/graph/create-entity.d.ts.map +1 -1
- package/dist/src/graph/create-entity.js +2 -0
- package/dist/src/graph/create-entity.js.map +1 -1
- package/dist/src/graph/create-image.d.ts +2 -21
- package/dist/src/graph/create-image.d.ts.map +1 -1
- package/dist/src/graph/create-image.js +7 -69
- package/dist/src/graph/create-image.js.map +1 -1
- package/dist/src/graph/create-property.d.ts +2 -0
- package/dist/src/graph/create-property.d.ts.map +1 -1
- package/dist/src/graph/create-property.js +2 -0
- package/dist/src/graph/create-property.js.map +1 -1
- package/dist/src/graph/create-proposal-review.d.ts +1 -27
- package/dist/src/graph/create-proposal-review.d.ts.map +1 -1
- package/dist/src/graph/create-proposal-review.js +4 -61
- package/dist/src/graph/create-proposal-review.js.map +1 -1
- package/dist/src/graph/create-relation.d.ts +2 -0
- package/dist/src/graph/create-relation.d.ts.map +1 -1
- package/dist/src/graph/create-relation.js +2 -0
- package/dist/src/graph/create-relation.js.map +1 -1
- package/dist/src/graph/create-type.d.ts +2 -0
- package/dist/src/graph/create-type.d.ts.map +1 -1
- package/dist/src/graph/create-type.js +2 -0
- package/dist/src/graph/create-type.js.map +1 -1
- package/dist/src/graph/delete-entity.d.ts +2 -14
- package/dist/src/graph/delete-entity.d.ts.map +1 -1
- package/dist/src/graph/delete-entity.js +5 -78
- package/dist/src/graph/delete-entity.js.map +1 -1
- package/dist/src/graph/delete-entity.test.js +7 -0
- package/dist/src/graph/delete-entity.test.js.map +1 -1
- package/dist/src/graph/delete-relation.d.ts +2 -0
- package/dist/src/graph/delete-relation.d.ts.map +1 -1
- package/dist/src/graph/delete-relation.js +2 -0
- package/dist/src/graph/delete-relation.js.map +1 -1
- package/dist/src/graph/entity-vote.d.ts +3 -3
- package/dist/src/graph/entity-vote.d.ts.map +1 -1
- package/dist/src/graph/entity-vote.js +21 -46
- package/dist/src/graph/entity-vote.js.map +1 -1
- package/dist/src/graph/update-comment.d.ts +3 -0
- package/dist/src/graph/update-comment.d.ts.map +1 -1
- package/dist/src/graph/update-comment.js +3 -0
- package/dist/src/graph/update-comment.js.map +1 -1
- package/dist/src/graph/update-entity.d.ts +2 -0
- package/dist/src/graph/update-entity.d.ts.map +1 -1
- package/dist/src/graph/update-entity.js +2 -0
- package/dist/src/graph/update-entity.js.map +1 -1
- package/dist/src/graph/update-proposal-review.d.ts +2 -27
- package/dist/src/graph/update-proposal-review.d.ts.map +1 -1
- package/dist/src/graph/update-proposal-review.js +4 -50
- package/dist/src/graph/update-proposal-review.js.map +1 -1
- package/dist/src/graph/update-relation.d.ts +2 -0
- package/dist/src/graph/update-relation.d.ts.map +1 -1
- package/dist/src/graph/update-relation.js +2 -0
- package/dist/src/graph/update-relation.js.map +1 -1
- package/dist/src/ipfs-core.d.ts +42 -0
- package/dist/src/ipfs-core.d.ts.map +1 -0
- package/dist/src/ipfs-core.js +165 -0
- package/dist/src/ipfs-core.js.map +1 -0
- package/dist/src/ipfs-core.test.d.ts +2 -0
- package/dist/src/ipfs-core.test.d.ts.map +1 -0
- package/dist/src/ipfs-core.test.js +56 -0
- package/dist/src/ipfs-core.test.js.map +1 -0
- package/dist/src/ipfs.d.ts +7 -52
- package/dist/src/ipfs.d.ts.map +1 -1
- package/dist/src/ipfs.js +27 -170
- package/dist/src/ipfs.js.map +1 -1
- package/dist/src/legacy-api-surface.e2e.test.d.ts +2 -0
- package/dist/src/legacy-api-surface.e2e.test.d.ts.map +1 -0
- package/dist/src/legacy-api-surface.e2e.test.js +860 -0
- package/dist/src/legacy-api-surface.e2e.test.js.map +1 -0
- package/dist/src/networks.d.ts +46 -0
- package/dist/src/networks.d.ts.map +1 -0
- package/dist/src/networks.js +90 -0
- package/dist/src/networks.js.map +1 -0
- package/dist/src/ops/comments.d.ts +80 -0
- package/dist/src/ops/comments.d.ts.map +1 -0
- package/dist/src/ops/comments.js +142 -0
- package/dist/src/ops/comments.js.map +1 -0
- package/dist/src/ops/entities.d.ts +50 -0
- package/dist/src/ops/entities.d.ts.map +1 -0
- package/dist/src/ops/entities.js +51 -0
- package/dist/src/ops/entities.js.map +1 -0
- package/dist/src/ops/index.d.ts +7 -0
- package/dist/src/ops/index.d.ts.map +1 -0
- package/dist/src/ops/index.js +7 -0
- package/dist/src/ops/index.js.map +1 -0
- package/dist/src/ops/index.test.d.ts +2 -0
- package/dist/src/ops/index.test.d.ts.map +1 -0
- package/dist/src/ops/index.test.js +115 -0
- package/dist/src/ops/index.test.js.map +1 -0
- package/dist/src/ops/properties.d.ts +20 -0
- package/dist/src/ops/properties.d.ts.map +1 -0
- package/dist/src/ops/properties.js +20 -0
- package/dist/src/ops/properties.js.map +1 -0
- package/dist/src/ops/proposal-reviews.d.ts +43 -0
- package/dist/src/ops/proposal-reviews.d.ts.map +1 -0
- package/dist/src/ops/proposal-reviews.js +103 -0
- package/dist/src/ops/proposal-reviews.js.map +1 -0
- package/dist/src/ops/relations.d.ts +57 -0
- package/dist/src/ops/relations.d.ts.map +1 -0
- package/dist/src/ops/relations.js +59 -0
- package/dist/src/ops/relations.js.map +1 -0
- package/dist/src/ops/types.d.ts +20 -0
- package/dist/src/ops/types.d.ts.map +1 -0
- package/dist/src/ops/types.js +20 -0
- package/dist/src/ops/types.js.map +1 -0
- package/dist/src/personal-space/constants.d.ts +1 -0
- package/dist/src/personal-space/constants.d.ts.map +1 -1
- package/dist/src/personal-space/constants.js +1 -0
- package/dist/src/personal-space/constants.js.map +1 -1
- package/dist/src/personal-space/create-space.d.ts +3 -20
- package/dist/src/personal-space/create-space.d.ts.map +1 -1
- package/dist/src/personal-space/create-space.js +5 -21
- package/dist/src/personal-space/create-space.js.map +1 -1
- package/dist/src/personal-space/has-space.d.ts +9 -2
- package/dist/src/personal-space/has-space.d.ts.map +1 -1
- package/dist/src/personal-space/has-space.js +9 -13
- package/dist/src/personal-space/has-space.js.map +1 -1
- package/dist/src/personal-space/has-space.test.d.ts +2 -0
- package/dist/src/personal-space/has-space.test.d.ts.map +1 -0
- package/dist/src/personal-space/has-space.test.js +30 -0
- package/dist/src/personal-space/has-space.test.js.map +1 -0
- package/dist/src/personal-space/publish-edit.d.ts +1 -22
- package/dist/src/personal-space/publish-edit.d.ts.map +1 -1
- package/dist/src/personal-space/publish-edit.js +10 -64
- package/dist/src/personal-space/publish-edit.js.map +1 -1
- package/dist/src/personal-space/types.d.ts +4 -1
- package/dist/src/personal-space/types.d.ts.map +1 -1
- package/dist/src/smart-wallet.d.ts +2 -4
- package/dist/src/smart-wallet.d.ts.map +1 -1
- package/dist/src/smart-wallet.js +6 -9
- package/dist/src/smart-wallet.js.map +1 -1
- package/dist/src/types.d.ts +25 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +14 -1
- package/dist/proto.d.ts +0 -5
- package/dist/proto.d.ts.map +0 -1
- package/dist/proto.js +0 -5
- package/dist/proto.js.map +0 -1
- package/dist/src/graph/create-space.d.ts +0 -37
- package/dist/src/graph/create-space.d.ts.map +0 -1
- package/dist/src/graph/create-space.js +0 -67
- package/dist/src/graph/create-space.js.map +0 -1
- package/dist/src/proto/index.d.ts +0 -7
- package/dist/src/proto/index.d.ts.map +0 -1
- package/dist/src/proto/index.js +0 -7
- package/dist/src/proto/index.js.map +0 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import type { Op } from '@geoprotocol/grc-20';
|
|
2
|
+
import { type Address, type Hex } from 'viem';
|
|
3
|
+
import type { Id } from '../id.js';
|
|
4
|
+
import type { PublishEditParams } from '../ipfs-core.js';
|
|
5
|
+
import type { GeoClientContext } from './context.js';
|
|
6
|
+
export type CreatePersonalSpaceParams = {
|
|
7
|
+
name: string;
|
|
8
|
+
accountAddress: Address;
|
|
9
|
+
};
|
|
10
|
+
export type CreatePersonalSpaceResult = {
|
|
11
|
+
to: `0x${string}`;
|
|
12
|
+
calldata: `0x${string}`;
|
|
13
|
+
spaceEntityId: Id;
|
|
14
|
+
accountId: string;
|
|
15
|
+
ops: Op[];
|
|
16
|
+
};
|
|
17
|
+
export type SetPersonalSpaceTopicParams = {
|
|
18
|
+
spaceId: Id | string;
|
|
19
|
+
topicId: Id | string;
|
|
20
|
+
authorSpaceId?: Id | string;
|
|
21
|
+
};
|
|
22
|
+
export type HasSpaceParams = {
|
|
23
|
+
address: Hex;
|
|
24
|
+
rpcUrl?: string;
|
|
25
|
+
};
|
|
26
|
+
export type PublishPersonalSpaceEditParams = PublishEditParams & {
|
|
27
|
+
spaceId: Id | string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Builds the personal-space creation transaction and initial space content ops.
|
|
31
|
+
*
|
|
32
|
+
* The returned calldata registers the caller's address as a personal space.
|
|
33
|
+
* The returned ops create the space entity, the account entity, and the
|
|
34
|
+
* personal-space type relations that should be published after the space ID is
|
|
35
|
+
* available onchain.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const tx = geo.personalSpaces.create({
|
|
40
|
+
* name: 'Alice',
|
|
41
|
+
* accountAddress: account.address,
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* await walletClient.sendTransaction({
|
|
45
|
+
* to: tx.to,
|
|
46
|
+
* data: tx.calldata,
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* // Once the transaction is mined and the space ID is known:
|
|
50
|
+
* await geo.personalSpaces.publishEdit({
|
|
51
|
+
* name: 'Create personal space profile',
|
|
52
|
+
* spaceId,
|
|
53
|
+
* author: spaceId,
|
|
54
|
+
* ops: tx.ops,
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param context Client context containing the target network configuration.
|
|
59
|
+
* @param params Space display name and account address to describe in initial ops.
|
|
60
|
+
* @returns Target registry address, calldata, generated entity IDs, and initial content ops.
|
|
61
|
+
* @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function create(context: GeoClientContext, { name, accountAddress }: CreatePersonalSpaceParams): CreatePersonalSpaceResult;
|
|
64
|
+
/**
|
|
65
|
+
* Builds calldata for setting a personal space topic.
|
|
66
|
+
*
|
|
67
|
+
* Call this right after creating the personal space and publishing its initial
|
|
68
|
+
* profile ops. For personal spaces, `authorSpaceId` defaults to `spaceId`.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const topicTx = geo.personalSpaces.setTopic({
|
|
73
|
+
* spaceId,
|
|
74
|
+
* topicId: createSpace.spaceEntityId,
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* await walletClient.sendTransaction({
|
|
78
|
+
* to: topicTx.to,
|
|
79
|
+
* data: topicTx.calldata,
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @param context Client context containing the target network configuration.
|
|
84
|
+
* @param params Space ID, topic entity ID, and optional author space ID.
|
|
85
|
+
* @returns Target registry address and calldata.
|
|
86
|
+
* @throws When an ID is invalid or the configured network is missing `SPACE_REGISTRY_ADDRESS`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function setTopic(context: GeoClientContext, { spaceId, topicId, authorSpaceId }: SetPersonalSpaceTopicParams): {
|
|
89
|
+
to: `0x${string}`;
|
|
90
|
+
calldata: `0x${string}`;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Builds calldata for archiving the caller's registered personal space.
|
|
94
|
+
*
|
|
95
|
+
* The Space Registry determines the affected space from `msg.sender`, so the
|
|
96
|
+
* transaction must be sent by the account that owns the personal space.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const tx = geo.personalSpaces.archiveSpace();
|
|
101
|
+
*
|
|
102
|
+
* await walletClient.sendTransaction({
|
|
103
|
+
* to: tx.to,
|
|
104
|
+
* data: tx.calldata,
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @param context Client context containing the target network configuration.
|
|
109
|
+
* @returns Target registry address and calldata for `archiveSpaceId()`.
|
|
110
|
+
* @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS`.
|
|
111
|
+
*/
|
|
112
|
+
export declare function archiveSpace(context: GeoClientContext): {
|
|
113
|
+
to: `0x${string}`;
|
|
114
|
+
calldata: `0x${string}`;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Builds calldata for recovering the caller's archived personal space.
|
|
118
|
+
*
|
|
119
|
+
* The Space Registry determines the affected space from `msg.sender`, so the
|
|
120
|
+
* transaction must be sent by the account that owns the archived personal
|
|
121
|
+
* space.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* const tx = geo.personalSpaces.recoverSpace();
|
|
126
|
+
*
|
|
127
|
+
* await walletClient.sendTransaction({
|
|
128
|
+
* to: tx.to,
|
|
129
|
+
* data: tx.calldata,
|
|
130
|
+
* });
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* @param context Client context containing the target network configuration.
|
|
134
|
+
* @returns Target registry address and calldata for `recoverSpaceId()`.
|
|
135
|
+
* @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS`.
|
|
136
|
+
*/
|
|
137
|
+
export declare function recoverSpace(context: GeoClientContext): {
|
|
138
|
+
to: `0x${string}`;
|
|
139
|
+
calldata: `0x${string}`;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Builds calldata for clearing the caller's archived personal space.
|
|
143
|
+
*
|
|
144
|
+
* `clearSpaceId()` permanently unregisters the caller's archived space ID. The
|
|
145
|
+
* transaction must be sent by the account that owns the archived personal
|
|
146
|
+
* space, and the contract requires that space to already be archived.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* const tx = geo.personalSpaces.clearSpace();
|
|
151
|
+
*
|
|
152
|
+
* await walletClient.sendTransaction({
|
|
153
|
+
* to: tx.to,
|
|
154
|
+
* data: tx.calldata,
|
|
155
|
+
* });
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @param context Client context containing the target network configuration.
|
|
159
|
+
* @returns Target registry address and calldata for `clearSpaceId()`.
|
|
160
|
+
* @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS`.
|
|
161
|
+
*/
|
|
162
|
+
export declare function clearSpace(context: GeoClientContext): {
|
|
163
|
+
to: `0x${string}`;
|
|
164
|
+
calldata: `0x${string}`;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Checks whether an address already has a personal space on the configured network.
|
|
168
|
+
*
|
|
169
|
+
* The helper reads `addressToSpaceId(address)` from the configured
|
|
170
|
+
* `SPACE_REGISTRY_ADDRESS`. Pass `rpcUrl` to override the network's configured
|
|
171
|
+
* RPC URL for this lookup.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* const hasExistingSpace = await geo.personalSpaces.hasSpace({
|
|
176
|
+
* address: account.address,
|
|
177
|
+
* });
|
|
178
|
+
*
|
|
179
|
+
* if (!hasExistingSpace) {
|
|
180
|
+
* const tx = geo.personalSpaces.create({
|
|
181
|
+
* name: 'Alice',
|
|
182
|
+
* accountAddress: account.address,
|
|
183
|
+
* });
|
|
184
|
+
* await walletClient.sendTransaction({ to: tx.to, data: tx.calldata });
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @param context Client context containing network and contract configuration.
|
|
189
|
+
* @param params Wallet or smart-account address plus optional RPC URL override.
|
|
190
|
+
* @returns `true` when the registry maps the address to a non-empty space ID.
|
|
191
|
+
* @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS` or no RPC URL is available.
|
|
192
|
+
*/
|
|
193
|
+
export declare function hasSpace(context: GeoClientContext, { address, rpcUrl }: HasSpaceParams): Promise<boolean>;
|
|
194
|
+
/**
|
|
195
|
+
* Publishes an edit and returns calldata for submitting it to a personal space.
|
|
196
|
+
*
|
|
197
|
+
* This is the context-explicit implementation behind
|
|
198
|
+
* `geo.personalSpaces.publishEdit(...)`.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* import * as Ops from '@geoprotocol/geo-sdk/ops';
|
|
203
|
+
*
|
|
204
|
+
* const { ops } = Ops.entities.create({ name: 'Geo entity' });
|
|
205
|
+
* const tx = await geo.personalSpaces.publishEdit({
|
|
206
|
+
* name: 'Create Geo entity',
|
|
207
|
+
* spaceId,
|
|
208
|
+
* author: spaceId,
|
|
209
|
+
* ops,
|
|
210
|
+
* });
|
|
211
|
+
*
|
|
212
|
+
* await walletClient.sendTransaction({
|
|
213
|
+
* to: tx.to,
|
|
214
|
+
* data: tx.calldata,
|
|
215
|
+
* });
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* @param context Client context containing network, contract, API, and fetch configuration.
|
|
219
|
+
* @param params Edit publication params plus the target personal space ID.
|
|
220
|
+
* @returns Edit ID, CID, target registry address, and calldata.
|
|
221
|
+
* @throws When the configured network is missing required contracts or edit publishing fails.
|
|
222
|
+
*/
|
|
223
|
+
export declare function publishEdit(context: GeoClientContext, params: PublishPersonalSpaceEditParams): Promise<{
|
|
224
|
+
editId: Id;
|
|
225
|
+
cid: `ipfs://${string}`;
|
|
226
|
+
to: `0x${string}`;
|
|
227
|
+
calldata: `0x${string}`;
|
|
228
|
+
}>;
|
|
229
|
+
//# sourceMappingURL=personal-spaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"personal-spaces.d.ts","sourceRoot":"","sources":["../../../src/client/personal-spaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,OAAO,EAA0C,KAAK,GAAG,EAAQ,MAAM,MAAM,CAAC;AAQ5F,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAGnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,EAAE,EAAE,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,EAAE,GAAG,MAAM,CAAC;IACrB,OAA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
|
|
|
1
|
+
import { createPublicClient, encodeFunctionData, http } from 'viem';
|
|
2
|
+
import { EMPTY_SPACE_ID } from '../../contracts.js';
|
|
3
|
+
import { SpaceRegistryAbi } from '../abis/index.js';
|
|
4
|
+
import * as Account from '../core/account.js';
|
|
5
|
+
import { PERSON_TYPE, SPACE_TYPE, TYPES_PROPERTY } from '../core/ids/system.js';
|
|
6
|
+
import { getCreatePersonalSpaceCalldata } from '../encodings/get-create-personal-space-calldata.js';
|
|
7
|
+
import { createEntity } from '../graph/create-entity.js';
|
|
8
|
+
import { createRelation } from '../graph/create-relation.js';
|
|
9
|
+
import * as IdUtils from '../id-utils.js';
|
|
10
|
+
import { assertValid } from '../id-utils.js';
|
|
11
|
+
import { requireGeoContract } from '../networks.js';
|
|
12
|
+
import { EMPTY_SIGNATURE, TOPIC_SET } from '../personal-space/constants.js';
|
|
13
|
+
function idToBytes16(id, sourceHint) {
|
|
14
|
+
const normalized = id.startsWith('0x') ? id.slice(2) : id.replaceAll('-', '');
|
|
15
|
+
assertValid(normalized, sourceHint);
|
|
16
|
+
return `0x${normalized.toLowerCase()}`;
|
|
17
|
+
}
|
|
18
|
+
function encodeSpaceRegistryLifecycleCalldata(context, functionName) {
|
|
19
|
+
return {
|
|
20
|
+
to: requireGeoContract(context.network, 'SPACE_REGISTRY_ADDRESS'),
|
|
21
|
+
calldata: encodeFunctionData({
|
|
22
|
+
abi: SpaceRegistryAbi,
|
|
23
|
+
functionName,
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function bytes16ToBytes32LeftAligned(bytes16Hex) {
|
|
28
|
+
return `0x${bytes16Hex.slice(2)}${'0'.repeat(32)}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Builds the personal-space creation transaction and initial space content ops.
|
|
32
|
+
*
|
|
33
|
+
* The returned calldata registers the caller's address as a personal space.
|
|
34
|
+
* The returned ops create the space entity, the account entity, and the
|
|
35
|
+
* personal-space type relations that should be published after the space ID is
|
|
36
|
+
* available onchain.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const tx = geo.personalSpaces.create({
|
|
41
|
+
* name: 'Alice',
|
|
42
|
+
* accountAddress: account.address,
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* await walletClient.sendTransaction({
|
|
46
|
+
* to: tx.to,
|
|
47
|
+
* data: tx.calldata,
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* // Once the transaction is mined and the space ID is known:
|
|
51
|
+
* await geo.personalSpaces.publishEdit({
|
|
52
|
+
* name: 'Create personal space profile',
|
|
53
|
+
* spaceId,
|
|
54
|
+
* author: spaceId,
|
|
55
|
+
* ops: tx.ops,
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @param context Client context containing the target network configuration.
|
|
60
|
+
* @param params Space display name and account address to describe in initial ops.
|
|
61
|
+
* @returns Target registry address, calldata, generated entity IDs, and initial content ops.
|
|
62
|
+
* @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS`.
|
|
63
|
+
*/
|
|
64
|
+
export function create(context, { name, accountAddress }) {
|
|
65
|
+
const spaceEntityId = IdUtils.generate();
|
|
66
|
+
const ops = [];
|
|
67
|
+
const { accountId, ops: accountOps } = Account.make(accountAddress);
|
|
68
|
+
ops.push(...accountOps);
|
|
69
|
+
const { ops: createSpaceEntityOps } = createEntity({
|
|
70
|
+
id: spaceEntityId,
|
|
71
|
+
name,
|
|
72
|
+
types: [SPACE_TYPE],
|
|
73
|
+
});
|
|
74
|
+
ops.push(...createSpaceEntityOps);
|
|
75
|
+
const { ops: personRelationOps } = createRelation({
|
|
76
|
+
fromEntity: spaceEntityId,
|
|
77
|
+
type: TYPES_PROPERTY,
|
|
78
|
+
toEntity: PERSON_TYPE,
|
|
79
|
+
});
|
|
80
|
+
ops.push(...personRelationOps);
|
|
81
|
+
return {
|
|
82
|
+
to: requireGeoContract(context.network, 'SPACE_REGISTRY_ADDRESS'),
|
|
83
|
+
calldata: getCreatePersonalSpaceCalldata(),
|
|
84
|
+
spaceEntityId,
|
|
85
|
+
accountId,
|
|
86
|
+
ops,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Builds calldata for setting a personal space topic.
|
|
91
|
+
*
|
|
92
|
+
* Call this right after creating the personal space and publishing its initial
|
|
93
|
+
* profile ops. For personal spaces, `authorSpaceId` defaults to `spaceId`.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* const topicTx = geo.personalSpaces.setTopic({
|
|
98
|
+
* spaceId,
|
|
99
|
+
* topicId: createSpace.spaceEntityId,
|
|
100
|
+
* });
|
|
101
|
+
*
|
|
102
|
+
* await walletClient.sendTransaction({
|
|
103
|
+
* to: topicTx.to,
|
|
104
|
+
* data: topicTx.calldata,
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @param context Client context containing the target network configuration.
|
|
109
|
+
* @param params Space ID, topic entity ID, and optional author space ID.
|
|
110
|
+
* @returns Target registry address and calldata.
|
|
111
|
+
* @throws When an ID is invalid or the configured network is missing `SPACE_REGISTRY_ADDRESS`.
|
|
112
|
+
*/
|
|
113
|
+
export function setTopic(context, { spaceId, topicId, authorSpaceId = spaceId }) {
|
|
114
|
+
const authorSpaceIdBytes = idToBytes16(authorSpaceId, '`authorSpaceId` in `setTopic`');
|
|
115
|
+
const spaceIdBytes = idToBytes16(spaceId, '`spaceId` in `setTopic`');
|
|
116
|
+
const topicIdBytes = idToBytes16(topicId, '`topicId` in `setTopic`');
|
|
117
|
+
return {
|
|
118
|
+
to: requireGeoContract(context.network, 'SPACE_REGISTRY_ADDRESS'),
|
|
119
|
+
calldata: encodeFunctionData({
|
|
120
|
+
abi: SpaceRegistryAbi,
|
|
121
|
+
functionName: 'enter',
|
|
122
|
+
args: [
|
|
123
|
+
authorSpaceIdBytes,
|
|
124
|
+
spaceIdBytes,
|
|
125
|
+
TOPIC_SET,
|
|
126
|
+
bytes16ToBytes32LeftAligned(topicIdBytes),
|
|
127
|
+
'0x',
|
|
128
|
+
EMPTY_SIGNATURE,
|
|
129
|
+
],
|
|
130
|
+
}),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Builds calldata for archiving the caller's registered personal space.
|
|
135
|
+
*
|
|
136
|
+
* The Space Registry determines the affected space from `msg.sender`, so the
|
|
137
|
+
* transaction must be sent by the account that owns the personal space.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const tx = geo.personalSpaces.archiveSpace();
|
|
142
|
+
*
|
|
143
|
+
* await walletClient.sendTransaction({
|
|
144
|
+
* to: tx.to,
|
|
145
|
+
* data: tx.calldata,
|
|
146
|
+
* });
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @param context Client context containing the target network configuration.
|
|
150
|
+
* @returns Target registry address and calldata for `archiveSpaceId()`.
|
|
151
|
+
* @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS`.
|
|
152
|
+
*/
|
|
153
|
+
export function archiveSpace(context) {
|
|
154
|
+
return encodeSpaceRegistryLifecycleCalldata(context, 'archiveSpaceId');
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Builds calldata for recovering the caller's archived personal space.
|
|
158
|
+
*
|
|
159
|
+
* The Space Registry determines the affected space from `msg.sender`, so the
|
|
160
|
+
* transaction must be sent by the account that owns the archived personal
|
|
161
|
+
* space.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* const tx = geo.personalSpaces.recoverSpace();
|
|
166
|
+
*
|
|
167
|
+
* await walletClient.sendTransaction({
|
|
168
|
+
* to: tx.to,
|
|
169
|
+
* data: tx.calldata,
|
|
170
|
+
* });
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @param context Client context containing the target network configuration.
|
|
174
|
+
* @returns Target registry address and calldata for `recoverSpaceId()`.
|
|
175
|
+
* @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS`.
|
|
176
|
+
*/
|
|
177
|
+
export function recoverSpace(context) {
|
|
178
|
+
return encodeSpaceRegistryLifecycleCalldata(context, 'recoverSpaceId');
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Builds calldata for clearing the caller's archived personal space.
|
|
182
|
+
*
|
|
183
|
+
* `clearSpaceId()` permanently unregisters the caller's archived space ID. The
|
|
184
|
+
* transaction must be sent by the account that owns the archived personal
|
|
185
|
+
* space, and the contract requires that space to already be archived.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* const tx = geo.personalSpaces.clearSpace();
|
|
190
|
+
*
|
|
191
|
+
* await walletClient.sendTransaction({
|
|
192
|
+
* to: tx.to,
|
|
193
|
+
* data: tx.calldata,
|
|
194
|
+
* });
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* @param context Client context containing the target network configuration.
|
|
198
|
+
* @returns Target registry address and calldata for `clearSpaceId()`.
|
|
199
|
+
* @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS`.
|
|
200
|
+
*/
|
|
201
|
+
export function clearSpace(context) {
|
|
202
|
+
return encodeSpaceRegistryLifecycleCalldata(context, 'clearSpaceId');
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Checks whether an address already has a personal space on the configured network.
|
|
206
|
+
*
|
|
207
|
+
* The helper reads `addressToSpaceId(address)` from the configured
|
|
208
|
+
* `SPACE_REGISTRY_ADDRESS`. Pass `rpcUrl` to override the network's configured
|
|
209
|
+
* RPC URL for this lookup.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* const hasExistingSpace = await geo.personalSpaces.hasSpace({
|
|
214
|
+
* address: account.address,
|
|
215
|
+
* });
|
|
216
|
+
*
|
|
217
|
+
* if (!hasExistingSpace) {
|
|
218
|
+
* const tx = geo.personalSpaces.create({
|
|
219
|
+
* name: 'Alice',
|
|
220
|
+
* accountAddress: account.address,
|
|
221
|
+
* });
|
|
222
|
+
* await walletClient.sendTransaction({ to: tx.to, data: tx.calldata });
|
|
223
|
+
* }
|
|
224
|
+
* ```
|
|
225
|
+
*
|
|
226
|
+
* @param context Client context containing network and contract configuration.
|
|
227
|
+
* @param params Wallet or smart-account address plus optional RPC URL override.
|
|
228
|
+
* @returns `true` when the registry maps the address to a non-empty space ID.
|
|
229
|
+
* @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS` or no RPC URL is available.
|
|
230
|
+
*/
|
|
231
|
+
export async function hasSpace(context, { address, rpcUrl }) {
|
|
232
|
+
const resolvedRpcUrl = rpcUrl ?? context.network.chain?.rpcUrl;
|
|
233
|
+
if (!resolvedRpcUrl) {
|
|
234
|
+
throw new Error(`Geo network "${context.network.name}" is missing an RPC URL`);
|
|
235
|
+
}
|
|
236
|
+
const publicClient = createPublicClient({ transport: http(resolvedRpcUrl) });
|
|
237
|
+
const spaceIdHex = (await publicClient.readContract({
|
|
238
|
+
address: requireGeoContract(context.network, 'SPACE_REGISTRY_ADDRESS'),
|
|
239
|
+
abi: SpaceRegistryAbi,
|
|
240
|
+
functionName: 'addressToSpaceId',
|
|
241
|
+
args: [address],
|
|
242
|
+
}));
|
|
243
|
+
return spaceIdHex.toLowerCase() !== EMPTY_SPACE_ID.toLowerCase();
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Publishes an edit and returns calldata for submitting it to a personal space.
|
|
247
|
+
*
|
|
248
|
+
* This is the context-explicit implementation behind
|
|
249
|
+
* `geo.personalSpaces.publishEdit(...)`.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* import * as Ops from '@geoprotocol/geo-sdk/ops';
|
|
254
|
+
*
|
|
255
|
+
* const { ops } = Ops.entities.create({ name: 'Geo entity' });
|
|
256
|
+
* const tx = await geo.personalSpaces.publishEdit({
|
|
257
|
+
* name: 'Create Geo entity',
|
|
258
|
+
* spaceId,
|
|
259
|
+
* author: spaceId,
|
|
260
|
+
* ops,
|
|
261
|
+
* });
|
|
262
|
+
*
|
|
263
|
+
* await walletClient.sendTransaction({
|
|
264
|
+
* to: tx.to,
|
|
265
|
+
* data: tx.calldata,
|
|
266
|
+
* });
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
269
|
+
* @param context Client context containing network, contract, API, and fetch configuration.
|
|
270
|
+
* @param params Edit publication params plus the target personal space ID.
|
|
271
|
+
* @returns Edit ID, CID, target registry address, and calldata.
|
|
272
|
+
* @throws When the configured network is missing required contracts or edit publishing fails.
|
|
273
|
+
*/
|
|
274
|
+
export async function publishEdit(context, params) {
|
|
275
|
+
const { publishToSpace } = await import('./edits.js');
|
|
276
|
+
return publishToSpace(context, params);
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=personal-spaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"personal-spaces.js","sourceRoot":"","sources":["../../../src/client/personal-spaces.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,kBAAkB,EAAE,kBAAkB,EAAY,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oDAAoD,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OA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