@geoprotocol/geo-sdk 0.18.3 → 0.19.0
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 +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- 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-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/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 +348 -0
- package/dist/src/client/dao-spaces.d.ts.map +1 -0
- package/dist/src/client/dao-spaces.js +494 -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 +263 -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 +155 -0
- package/dist/src/client/personal-spaces.d.ts.map +1 -0
- package/dist/src/client/personal-spaces.js +198 -0
- package/dist/src/client/personal-spaces.js.map +1 -0
- package/dist/src/client/proposals.d.ts +185 -0
- package/dist/src/client/proposals.d.ts.map +1 -0
- package/dist/src/client/proposals.js +294 -0
- package/dist/src/client/proposals.js.map +1 -0
- package/dist/src/client/proposals.test.d.ts +2 -0
- package/dist/src/client/proposals.test.d.ts.map +1 -0
- package/dist/src/client/proposals.test.js +243 -0
- package/dist/src/client/proposals.test.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 +155 -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 +325 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +452 -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 +120 -0
- package/dist/src/client.test.js.map +1 -0
- package/dist/src/contracts-v2/abis.d.ts +196 -0
- package/dist/src/contracts-v2/abis.d.ts.map +1 -0
- package/dist/src/contracts-v2/abis.js +110 -0
- package/dist/src/contracts-v2/abis.js.map +1 -0
- package/dist/src/contracts-v2/actions.d.ts +56 -0
- package/dist/src/contracts-v2/actions.d.ts.map +1 -0
- package/dist/src/contracts-v2/actions.js +83 -0
- package/dist/src/contracts-v2/actions.js.map +1 -0
- package/dist/src/contracts-v2/encoding.d.ts +80 -0
- package/dist/src/contracts-v2/encoding.d.ts.map +1 -0
- package/dist/src/contracts-v2/encoding.js +193 -0
- package/dist/src/contracts-v2/encoding.js.map +1 -0
- package/dist/src/contracts-v2/encoding.test.d.ts +2 -0
- package/dist/src/contracts-v2/encoding.test.d.ts.map +1 -0
- package/dist/src/contracts-v2/encoding.test.js +93 -0
- package/dist/src/contracts-v2/encoding.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/contracts-v2/voting-settings.d.ts +48 -0
- package/dist/src/contracts-v2/voting-settings.d.ts.map +1 -0
- package/dist/src/contracts-v2/voting-settings.js +69 -0
- package/dist/src/contracts-v2/voting-settings.js.map +1 -0
- package/dist/src/dao-space/constants.d.ts +6 -3
- package/dist/src/dao-space/constants.d.ts.map +1 -1
- package/dist/src/dao-space/constants.js +6 -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/propose-add-editor.test.js +1 -1
- package/dist/src/dao-space/propose-add-editor.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 +8 -1
- package/dist/src/dao-space/propose-edit.test.js.map +1 -1
- package/dist/src/dao-space/propose-remove-editor.d.ts.map +1 -1
- package/dist/src/dao-space/propose-remove-editor.js +5 -5
- package/dist/src/dao-space/propose-remove-editor.js.map +1 -1
- package/dist/src/dao-space/propose-remove-editor.test.js +3 -8
- package/dist/src/dao-space/propose-remove-editor.test.js.map +1 -1
- package/dist/src/dao-space/propose-remove-member.d.ts.map +1 -1
- package/dist/src/dao-space/propose-remove-member.js +5 -5
- package/dist/src/dao-space/propose-remove-member.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/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/e2e/local-geobrowser.d.ts +9 -0
- package/dist/src/e2e/local-geobrowser.d.ts.map +1 -0
- package/dist/src/e2e/local-geobrowser.js +35 -0
- package/dist/src/e2e/local-geobrowser.js.map +1 -0
- package/dist/src/e2e/v2-contracts.test.d.ts +2 -0
- package/dist/src/e2e/v2-contracts.test.d.ts.map +1 -0
- package/dist/src/e2e/v2-contracts.test.js +25 -0
- package/dist/src/e2e/v2-contracts.test.js.map +1 -0
- package/dist/src/e2e-api-surface.test.d.ts +2 -0
- package/dist/src/e2e-api-surface.test.d.ts.map +1 -0
- package/dist/src/e2e-api-surface.test.js +1021 -0
- package/dist/src/e2e-api-surface.test.js.map +1 -0
- package/dist/src/e2e-flows.test.d.ts +2 -0
- package/dist/src/e2e-flows.test.d.ts.map +1 -0
- package/dist/src/e2e-flows.test.js +445 -0
- package/dist/src/e2e-flows.test.js.map +1 -0
- package/dist/src/e2e-legacy-api-surface.test.d.ts +2 -0
- package/dist/src/e2e-legacy-api-surface.test.d.ts.map +1 -0
- package/dist/src/e2e-legacy-api-surface.test.js +840 -0
- package/dist/src/e2e-legacy-api-surface.test.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 +3 -89
- package/dist/src/encodings/get-create-dao-space-calldata.d.ts.map +1 -1
- package/dist/src/encodings/get-create-dao-space-calldata.js +5 -95
- package/dist/src/encodings/get-create-dao-space-calldata.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/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/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/images.d.ts +37 -0
- package/dist/src/ops/images.d.ts.map +1 -0
- package/dist/src/ops/images.js +69 -0
- package/dist/src/ops/images.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 +1 -18
- package/dist/src/personal-space/create-space.d.ts.map +1 -1
- package/dist/src/personal-space/create-space.js +1 -18
- 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/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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const RATIO_BASE = BigInt(10e6);
|
|
2
|
+
export const MINIMUM_VOTING_DURATION = BigInt(60);
|
|
3
|
+
export const MINIMUM_EXECUTION_GRACE_PERIOD = BigInt(60 * 60);
|
|
4
|
+
export const MINIMUM_VOTING_DURATION_DAYS = MINIMUM_VOTING_DURATION / BigInt(24 * 60 * 60);
|
|
5
|
+
export function percentageToRatio(percentage) {
|
|
6
|
+
return BigInt(Math.floor((percentage * 10e6) / 100));
|
|
7
|
+
}
|
|
8
|
+
export function daysToSeconds(days) {
|
|
9
|
+
return BigInt(Math.floor(days * 24 * 60 * 60));
|
|
10
|
+
}
|
|
11
|
+
export function toContractVotingSettings(input) {
|
|
12
|
+
if ('slowPathPercentageThreshold' in input) {
|
|
13
|
+
return {
|
|
14
|
+
partialPercentageSupportThreshold: percentageToRatio(input.slowPathPercentageThreshold),
|
|
15
|
+
universalPercentageSupportThreshold: percentageToRatio(input.universalPercentageSupportThreshold ?? input.slowPathPercentageThreshold),
|
|
16
|
+
flatSupportThreshold: BigInt(input.fastPathFlatThreshold),
|
|
17
|
+
quorum: BigInt(input.quorum),
|
|
18
|
+
duration: daysToSeconds(input.durationInDays),
|
|
19
|
+
disableFastPathAccessForNewMembers: input.disableFastPathAccessForNewMembers ?? false,
|
|
20
|
+
executionGracePeriod: input.executionGracePeriod !== undefined
|
|
21
|
+
? BigInt(input.executionGracePeriod)
|
|
22
|
+
: daysToSeconds(input.executionGracePeriodInDays ?? 1),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
partialPercentageSupportThreshold: percentageToRatio(input.partialPercentageSupportThreshold),
|
|
27
|
+
universalPercentageSupportThreshold: percentageToRatio(input.universalPercentageSupportThreshold),
|
|
28
|
+
flatSupportThreshold: BigInt(input.flatSupportThreshold),
|
|
29
|
+
quorum: BigInt(input.quorum),
|
|
30
|
+
duration: BigInt(input.duration),
|
|
31
|
+
disableFastPathAccessForNewMembers: input.disableFastPathAccessForNewMembers ?? false,
|
|
32
|
+
executionGracePeriod: BigInt(input.executionGracePeriod ?? 24 * 60 * 60),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function validateVotingSettingsInput(settings, totalEditors) {
|
|
36
|
+
const partial = 'slowPathPercentageThreshold' in settings
|
|
37
|
+
? settings.slowPathPercentageThreshold
|
|
38
|
+
: settings.partialPercentageSupportThreshold;
|
|
39
|
+
const universal = 'slowPathPercentageThreshold' in settings
|
|
40
|
+
? (settings.universalPercentageSupportThreshold ?? settings.slowPathPercentageThreshold)
|
|
41
|
+
: settings.universalPercentageSupportThreshold;
|
|
42
|
+
const flat = 'slowPathPercentageThreshold' in settings ? settings.fastPathFlatThreshold : settings.flatSupportThreshold;
|
|
43
|
+
const duration = 'slowPathPercentageThreshold' in settings ? daysToSeconds(settings.durationInDays) : BigInt(settings.duration);
|
|
44
|
+
const executionGracePeriod = 'slowPathPercentageThreshold' in settings
|
|
45
|
+
? settings.executionGracePeriod !== undefined
|
|
46
|
+
? BigInt(settings.executionGracePeriod)
|
|
47
|
+
: daysToSeconds(settings.executionGracePeriodInDays ?? 1)
|
|
48
|
+
: BigInt(settings.executionGracePeriod ?? 24 * 60 * 60);
|
|
49
|
+
if (partial < 0 || partial > 100) {
|
|
50
|
+
return 'partialPercentageSupportThreshold must be between 0 and 100';
|
|
51
|
+
}
|
|
52
|
+
if (universal < 0 || universal > 100) {
|
|
53
|
+
return 'universalPercentageSupportThreshold must be between 0 and 100';
|
|
54
|
+
}
|
|
55
|
+
if (flat < 0 || flat > totalEditors) {
|
|
56
|
+
return `flatSupportThreshold must be between 0 and ${totalEditors} (number of initial editors)`;
|
|
57
|
+
}
|
|
58
|
+
if (settings.quorum < 0 || settings.quorum > totalEditors) {
|
|
59
|
+
return `quorum must be between 0 and ${totalEditors} (number of initial editors)`;
|
|
60
|
+
}
|
|
61
|
+
if (duration < MINIMUM_VOTING_DURATION) {
|
|
62
|
+
return `duration must be at least ${MINIMUM_VOTING_DURATION.toString()} seconds`;
|
|
63
|
+
}
|
|
64
|
+
if (executionGracePeriod < MINIMUM_EXECUTION_GRACE_PERIOD) {
|
|
65
|
+
return `executionGracePeriod must be at least ${MINIMUM_EXECUTION_GRACE_PERIOD.toString()} seconds`;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=voting-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voting-settings.js","sourceRoot":"","sources":["../../../src/contracts-v2/voting-settings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAClD,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;AAC9D,MAAM,CAAC,MAAM,4BAA4B,GAAG,uBAAuB,GAAG,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AA6C3F,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,KAAoC;IAC3E,IAAI,6BAA6B,IAAI,KAAK,EAAE,CAAC;QAC3C,OAAO;YACL,iCAAiC,EAAE,iBAAiB,CAAC,KAAK,CAAC,2BAA2B,CAAC;YACvF,mCAAmC,EAAE,iBAAiB,CACpD,KAAK,CAAC,mCAAmC,IAAI,KAAK,CAAC,2BAA2B,CAC/E;YACD,oBAAoB,EAAE,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC;YACzD,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;YAC5B,QAAQ,EAAE,aAAa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,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Networkish } from '../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Action hash for GOVERNANCE.PROPOSAL_CREATED
|
|
4
4
|
* Used when creating proposals via SpaceRegistry.enter()
|
|
@@ -59,8 +59,11 @@ export declare function toBytes16(hex32: `0x${string}`): `0x${string}`;
|
|
|
59
59
|
* Converts a bytes16 hex string to bytes32 (left-aligned, right-padded with zeros).
|
|
60
60
|
*/
|
|
61
61
|
export declare function bytes16ToBytes32LeftAligned(bytes16Hex: `0x${string}`): `0x${string}`;
|
|
62
|
+
export type DaoSpaceContractAddresses = {
|
|
63
|
+
SPACE_REGISTRY_ADDRESS: `0x${string}`;
|
|
64
|
+
};
|
|
62
65
|
/**
|
|
63
|
-
* Get
|
|
66
|
+
* Get contract addresses based on network.
|
|
64
67
|
*/
|
|
65
|
-
export declare function getContractAddressesBasedOnNetwork(network:
|
|
68
|
+
export declare function getContractAddressesBasedOnNetwork(network: Networkish): DaoSpaceContractAddresses;
|
|
66
69
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/dao-space/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/dao-space/constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,uBAAuB,eAAkD,CAAC;AAEvF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,eAAgD,CAAC;AAEnF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,eAAsD,CAAC;AAE/F;;;GAGG;AACH,eAAO,MAAM,wBAAwB,eAAmD,CAAC;AAEzF;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;CAIrB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,WAAW,EAAG,oEAA6E,CAAC;AAEzG;;GAEG;AACH,eAAO,MAAM,eAAe,EAAG,IAAa,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAwB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAwB,CAAC;AAEvD;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE,CAE3D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,MAAM,EAAE,GAAG,KAAK,MAAM,EAAE,CAI7D;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,KAAK,MAAM,EAAE,GAAG,KAAK,MAAM,EAAE,CAIpF;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,sBAAsB,EAAE,KAAK,MAAM,EAAE,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,UAAU,GAAG,yBAAyB,CAKjG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { keccak256, toHex } from 'viem';
|
|
2
|
-
import {
|
|
2
|
+
import { requireGeoContract, resolveGeoNetwork } from '../networks.js';
|
|
3
3
|
/**
|
|
4
4
|
* Action hash for GOVERNANCE.PROPOSAL_CREATED
|
|
5
5
|
* Used when creating proposals via SpaceRegistry.enter()
|
|
@@ -75,11 +75,12 @@ export function bytes16ToBytes32LeftAligned(bytes16Hex) {
|
|
|
75
75
|
return `0x${s.slice(2)}${'0'.repeat(32)}`;
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
* Get
|
|
78
|
+
* Get contract addresses based on network.
|
|
79
79
|
*/
|
|
80
80
|
export function getContractAddressesBasedOnNetwork(network) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const config = resolveGeoNetwork(network);
|
|
82
|
+
return {
|
|
83
|
+
SPACE_REGISTRY_ADDRESS: requireGeoContract(config, 'SPACE_REGISTRY_ADDRESS'),
|
|
84
|
+
};
|
|
84
85
|
}
|
|
85
86
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dao-space/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dao-space/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGvE;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC,CAAC;AAEvF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;AAEnF;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,SAAS,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC,CAAC;AAE/F;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAS,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC,CAAC;AAEzF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,GAAG,EAAE,CAAC;IACN,EAAE,EAAE,CAAC;IACL,OAAO,EAAE,CAAC;CACF,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,oEAA6E,CAAC;AAEzG;;GAEG;AACH,MAAM,CAAC,MA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CAAC;IAC1C,OAAO;QACL,sBAAsB,EAAE,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,CAAC;KAC7E,CAAC;AACJ,CAAC"}
|
|
@@ -2,37 +2,7 @@ import type { CreateSpaceParams, CreateSpaceResult } from './types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Get the target address and calldata for creating a DAO space.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* and returns everything needed to submit a transaction that creates
|
|
7
|
-
* a DAO space on the DAO Space Factory contract.
|
|
8
|
-
*
|
|
9
|
-
* @param params - The parameters for creating the DAO space
|
|
10
|
-
* @returns Object containing `to` (contract address), `calldata` for the transaction,
|
|
11
|
-
* `spaceEntityId` for the generated space entity, and `cid` for the IPFS content
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { daoSpace } from '@geoprotocol/geo-sdk';
|
|
16
|
-
* import { createWalletClient, http } from 'viem';
|
|
17
|
-
*
|
|
18
|
-
* const { to, calldata, spaceEntityId, cid } = await daoSpace.createSpace({
|
|
19
|
-
* name: 'My DAO Space',
|
|
20
|
-
* votingSettings: {
|
|
21
|
-
* slowPathPercentageThreshold: 50, // 50% approval needed
|
|
22
|
-
* fastPathFlatThreshold: 3, // 3 editors for fast path
|
|
23
|
-
* quorum: 2, // minimum 2 editors must vote
|
|
24
|
-
* durationInDays: 7, // 7 day voting period
|
|
25
|
-
* },
|
|
26
|
-
* initialEditorSpaceIds: ['0x01234567890abcdef01234567890abcd'],
|
|
27
|
-
* author: 'your-personal-space-id',
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* // Using viem
|
|
31
|
-
* const hash = await walletClient.sendTransaction({
|
|
32
|
-
* to,
|
|
33
|
-
* data: calldata,
|
|
34
|
-
* });
|
|
35
|
-
* ```
|
|
5
|
+
* @deprecated Use `createGeoClient({ network }).daoSpaces.create(...)`.
|
|
36
6
|
*/
|
|
37
7
|
export declare function createSpace(params: CreateSpaceParams): Promise<CreateSpaceResult>;
|
|
38
8
|
//# sourceMappingURL=create-space.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-space.d.ts","sourceRoot":"","sources":["../../../src/dao-space/create-space.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-space.d.ts","sourceRoot":"","sources":["../../../src/dao-space/create-space.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEvE;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAGvF"}
|
|
@@ -1,77 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { getCreateDaoSpaceCalldata } from '../encodings/index.js';
|
|
4
|
-
import { createEntity } from '../graph/create-entity.js';
|
|
5
|
-
import * as IdUtils from '../id-utils.js';
|
|
6
|
-
import { publishEdit } from '../ipfs.js';
|
|
1
|
+
import { createGeoClient } from '../client.js';
|
|
2
|
+
import { resolveGeoNetwork } from '../networks.js';
|
|
7
3
|
/**
|
|
8
4
|
* Get the target address and calldata for creating a DAO space.
|
|
9
5
|
*
|
|
10
|
-
*
|
|
11
|
-
* and returns everything needed to submit a transaction that creates
|
|
12
|
-
* a DAO space on the DAO Space Factory contract.
|
|
13
|
-
*
|
|
14
|
-
* @param params - The parameters for creating the DAO space
|
|
15
|
-
* @returns Object containing `to` (contract address), `calldata` for the transaction,
|
|
16
|
-
* `spaceEntityId` for the generated space entity, and `cid` for the IPFS content
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* import { daoSpace } from '@geoprotocol/geo-sdk';
|
|
21
|
-
* import { createWalletClient, http } from 'viem';
|
|
22
|
-
*
|
|
23
|
-
* const { to, calldata, spaceEntityId, cid } = await daoSpace.createSpace({
|
|
24
|
-
* name: 'My DAO Space',
|
|
25
|
-
* votingSettings: {
|
|
26
|
-
* slowPathPercentageThreshold: 50, // 50% approval needed
|
|
27
|
-
* fastPathFlatThreshold: 3, // 3 editors for fast path
|
|
28
|
-
* quorum: 2, // minimum 2 editors must vote
|
|
29
|
-
* durationInDays: 7, // 7 day voting period
|
|
30
|
-
* },
|
|
31
|
-
* initialEditorSpaceIds: ['0x01234567890abcdef01234567890abcd'],
|
|
32
|
-
* author: 'your-personal-space-id',
|
|
33
|
-
* });
|
|
34
|
-
*
|
|
35
|
-
* // Using viem
|
|
36
|
-
* const hash = await walletClient.sendTransaction({
|
|
37
|
-
* to,
|
|
38
|
-
* data: calldata,
|
|
39
|
-
* });
|
|
40
|
-
* ```
|
|
6
|
+
* @deprecated Use `createGeoClient({ network }).daoSpaces.create(...)`.
|
|
41
7
|
*/
|
|
42
8
|
export async function createSpace(params) {
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
const spaceEntityId = IdUtils.generate();
|
|
46
|
-
// Create ops for the space entity with name and type
|
|
47
|
-
const ops = [];
|
|
48
|
-
const { ops: createSpaceEntityOps } = createEntity({
|
|
49
|
-
id: spaceEntityId,
|
|
50
|
-
name,
|
|
51
|
-
types: [SPACE_TYPE],
|
|
52
|
-
});
|
|
53
|
-
ops.push(...createSpaceEntityOps);
|
|
54
|
-
// Add any additional ops
|
|
55
|
-
ops.push(...additionalOps);
|
|
56
|
-
// Upload ops to IPFS
|
|
57
|
-
const { cid } = await publishEdit({
|
|
58
|
-
name: `Create DAO Space: ${name}`,
|
|
59
|
-
ops,
|
|
60
|
-
author,
|
|
61
|
-
network,
|
|
62
|
-
});
|
|
63
|
-
const calldata = getCreateDaoSpaceCalldata({
|
|
64
|
-
votingSettings: params.votingSettings,
|
|
65
|
-
initialEditorSpaceIds: params.initialEditorSpaceIds,
|
|
66
|
-
initialMemberSpaceIds: params.initialMemberSpaceIds ?? [],
|
|
67
|
-
initialEditsContentUri: cid,
|
|
68
|
-
initialTopicId: params.initialTopicId,
|
|
69
|
-
});
|
|
70
|
-
return {
|
|
71
|
-
to: TESTNET.DAO_SPACE_FACTORY_ADDRESS,
|
|
72
|
-
calldata,
|
|
73
|
-
spaceEntityId,
|
|
74
|
-
cid,
|
|
75
|
-
};
|
|
9
|
+
const { network = 'TESTNET', ...args } = params;
|
|
10
|
+
return createGeoClient({ network: resolveGeoNetwork(network) }).daoSpaces.create(args);
|
|
76
11
|
}
|
|
77
12
|
//# sourceMappingURL=create-space.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-space.js","sourceRoot":"","sources":["../../../src/dao-space/create-space.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-space.js","sourceRoot":"","sources":["../../../src/dao-space/create-space.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAyB;IACzD,MAAM,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IAChD,OAAO,eAAe,CAAC,EAAE,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -2,28 +2,7 @@ import type { ExecuteProposalParams, ExecuteProposalResult } from './types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Creates an execute transaction for a passed DAO space proposal.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* 1. Validates the author, DAO space, and proposal IDs
|
|
7
|
-
* 2. Encodes the proposal ID as the data payload
|
|
8
|
-
* 3. Encodes the SpaceRegistry's `enter()` call with the `PROPOSAL_EXECUTED` action
|
|
9
|
-
*
|
|
10
|
-
* Anyone can execute a proposal once it has passed the support threshold.
|
|
11
|
-
*
|
|
12
|
-
* @param params - The parameters for executing a proposal
|
|
13
|
-
* @returns Object containing `to` (Space Registry address) and `calldata`
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* import { daoSpace } from '@geoprotocol/geo-sdk';
|
|
18
|
-
*
|
|
19
|
-
* const { to, calldata } = daoSpace.executeProposal({
|
|
20
|
-
* authorSpaceId: '0xAuthorBytes16SpaceId...',
|
|
21
|
-
* spaceId: '0xDAOBytes16SpaceId...',
|
|
22
|
-
* proposalId: '0xProposalBytes16Id...',
|
|
23
|
-
* });
|
|
24
|
-
*
|
|
25
|
-
* await walletClient.sendTransaction({ to, data: calldata });
|
|
26
|
-
* ```
|
|
5
|
+
* @deprecated Use `createGeoClient({ network }).daoSpaces.proposals.execute(...)`.
|
|
27
6
|
*/
|
|
28
7
|
export declare function executeProposal(params: ExecuteProposalParams): ExecuteProposalResult;
|
|
29
8
|
//# sourceMappingURL=execute-proposal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-proposal.d.ts","sourceRoot":"","sources":["../../../src/dao-space/execute-proposal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execute-proposal.d.ts","sourceRoot":"","sources":["../../../src/dao-space/execute-proposal.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE/E;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,qBAAqB,CAapF"}
|
|
@@ -1,69 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { bytes16ToBytes32LeftAligned, EMPTY_SIGNATURE, ensure0xPrefix, isBytes16Hex, PROPOSAL_EXECUTED_ACTION, } from './constants.js';
|
|
1
|
+
import { createGeoClient } from '../client.js';
|
|
2
|
+
import { resolveGeoNetwork } from '../networks.js';
|
|
3
|
+
import { ensure0xPrefix, isBytes16Hex } from './constants.js';
|
|
5
4
|
/**
|
|
6
5
|
* Creates an execute transaction for a passed DAO space proposal.
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
* 1. Validates the author, DAO space, and proposal IDs
|
|
10
|
-
* 2. Encodes the proposal ID as the data payload
|
|
11
|
-
* 3. Encodes the SpaceRegistry's `enter()` call with the `PROPOSAL_EXECUTED` action
|
|
12
|
-
*
|
|
13
|
-
* Anyone can execute a proposal once it has passed the support threshold.
|
|
14
|
-
*
|
|
15
|
-
* @param params - The parameters for executing a proposal
|
|
16
|
-
* @returns Object containing `to` (Space Registry address) and `calldata`
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* import { daoSpace } from '@geoprotocol/geo-sdk';
|
|
21
|
-
*
|
|
22
|
-
* const { to, calldata } = daoSpace.executeProposal({
|
|
23
|
-
* authorSpaceId: '0xAuthorBytes16SpaceId...',
|
|
24
|
-
* spaceId: '0xDAOBytes16SpaceId...',
|
|
25
|
-
* proposalId: '0xProposalBytes16Id...',
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* await walletClient.sendTransaction({ to, data: calldata });
|
|
29
|
-
* ```
|
|
7
|
+
* @deprecated Use `createGeoClient({ network }).daoSpaces.proposals.execute(...)`.
|
|
30
8
|
*/
|
|
31
9
|
export function executeProposal(params) {
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const spaceId = ensure0xPrefix(rawSpaceId);
|
|
36
|
-
const proposalId = ensure0xPrefix(rawProposalId);
|
|
37
|
-
// Validate inputs
|
|
38
|
-
if (!isBytes16Hex(authorSpaceId)) {
|
|
39
|
-
throw new Error(`authorSpaceId must be bytes16 hex (32 hex chars). Received: ${rawAuthorSpaceId}`);
|
|
10
|
+
const { network = 'TESTNET', ...args } = params;
|
|
11
|
+
if (!isBytes16Hex(ensure0xPrefix(args.authorSpaceId))) {
|
|
12
|
+
throw new Error(`authorSpaceId must be bytes16 hex (32 hex chars). Received: ${args.authorSpaceId}`);
|
|
40
13
|
}
|
|
41
|
-
if (!isBytes16Hex(spaceId)) {
|
|
42
|
-
throw new Error(`spaceId must be bytes16 hex (32 hex chars). Received: ${
|
|
14
|
+
if (!isBytes16Hex(ensure0xPrefix(args.spaceId))) {
|
|
15
|
+
throw new Error(`spaceId must be bytes16 hex (32 hex chars). Received: ${args.spaceId}`);
|
|
43
16
|
}
|
|
44
|
-
if (!isBytes16Hex(proposalId)) {
|
|
45
|
-
throw new Error(`proposalId must be bytes16 hex (32 hex chars). Received: ${
|
|
17
|
+
if (!isBytes16Hex(ensure0xPrefix(args.proposalId))) {
|
|
18
|
+
throw new Error(`proposalId must be bytes16 hex (32 hex chars). Received: ${args.proposalId}`);
|
|
46
19
|
}
|
|
47
|
-
|
|
48
|
-
const topic = bytes16ToBytes32LeftAligned(proposalId);
|
|
49
|
-
// Encode the execute data: proposalId (matches the contract's abi.decode format)
|
|
50
|
-
const data = encodeAbiParameters([{ type: 'bytes16', name: 'proposalId' }], [proposalId]);
|
|
51
|
-
// Encode the SpaceRegistry.enter() call
|
|
52
|
-
const calldata = encodeFunctionData({
|
|
53
|
-
abi: SpaceRegistryAbi,
|
|
54
|
-
functionName: 'enter',
|
|
55
|
-
args: [
|
|
56
|
-
authorSpaceId, // fromSpaceId
|
|
57
|
-
spaceId, // toSpaceId
|
|
58
|
-
PROPOSAL_EXECUTED_ACTION, // action
|
|
59
|
-
topic, // topic (proposalId left-aligned to bytes32)
|
|
60
|
-
data, // data (encoded proposalId)
|
|
61
|
-
EMPTY_SIGNATURE, // signature (unused when msg.sender == fromSpace)
|
|
62
|
-
],
|
|
63
|
-
});
|
|
64
|
-
return {
|
|
65
|
-
to: TESTNET.SPACE_REGISTRY_ADDRESS,
|
|
66
|
-
calldata,
|
|
67
|
-
};
|
|
20
|
+
return createGeoClient({ network: resolveGeoNetwork(network) }).daoSpaces.proposals.execute(args);
|
|
68
21
|
}
|
|
69
22
|
//# sourceMappingURL=execute-proposal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-proposal.js","sourceRoot":"","sources":["../../../src/dao-space/execute-proposal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"execute-proposal.js","sourceRoot":"","sources":["../../../src/dao-space/execute-proposal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9D;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAA6B;IAC3D,MAAM,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IAChD,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,+DAA+D,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IACvG,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,yDAAyD,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3F,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,4DAA4D,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,eAAe,CAAC,EAAE,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACpG,CAAC"}
|
|
@@ -58,7 +58,7 @@ describe('proposeAddEditor', () => {
|
|
|
58
58
|
});
|
|
59
59
|
expect(result.calldata).toBeTruthy();
|
|
60
60
|
});
|
|
61
|
-
it('should
|
|
61
|
+
it('should preserve legacy FAST voting mode support', () => {
|
|
62
62
|
const result = proposeAddEditor({
|
|
63
63
|
authorSpaceId: validAuthorSpaceId,
|
|
64
64
|
spaceId: validSpaceId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propose-add-editor.test.js","sourceRoot":"","sources":["../../../src/dao-space/propose-add-editor.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,MAAM,kBAAkB,GAAG,oCAA6C,CAAC;IACzE,MAAM,YAAY,GAAG,oCAA6C,CAAC;IACnE,MAAM,qBAAqB,GAAG,oCAA6C,CAAC;IAE5E,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,MAAM,GAAG,gBAAgB,CAAC;YAC9B,aAAa,EAAE,kBAAkB;YACjC,OAAO,EAAE,YAAY;YACrB,gBAAgB,EAAE,qBAAqB;SACxC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6DAA6D,EAAE,GAAG,EAAE;QACrE,MAAM,EAAE,EAAE,EAAE,GAAG,gBAAgB,CAAC;YAC9B,aAAa,EAAE,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D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,CAAC,GAAG,EAAE,CACV,gBAAgB,CAAC;YACf,aAAa,EAAE,kBAAkB;YACjC,OAAO,EAAE,YAA6B;YACtC,gBAAgB,EAAE,qBAAqB;SACxC,CAAC,CACH,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,MAAM,CAAC,GAAG,EAAE,CACV,gBAAgB,CAAC;YACf,aAAa,EAAE,kBAAkB;YACjC,OAAO,EAAE,YAAY;YACrB,gBAAgB,EAAE,WAA4B;SAC/C,CAAC,CACH,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -2,36 +2,7 @@ import type { ProposeEditParams, ProposeEditResult } from './types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Creates a proposal to publish an edit to a DAO space.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* 1. Publishes the ops to IPFS using the GRC-20 binary format
|
|
7
|
-
* 2. Generates a unique proposal ID (or uses the provided one)
|
|
8
|
-
* 3. Encodes the proposal data for the SpaceRegistry's `enter()` function
|
|
9
|
-
*
|
|
10
|
-
* The proposal, when executed, will call the DAO space's `publish()` function
|
|
11
|
-
* to publish the edit. Since `publish()` is a valid fast-path action, with
|
|
12
|
-
* FAST voting mode and sufficient votes, the proposal will auto-execute.
|
|
13
|
-
*
|
|
14
|
-
* @param params - The parameters for creating the proposal
|
|
15
|
-
* @returns Object containing `editId`, `cid`, `to` (Space Registry address),
|
|
16
|
-
* `calldata`, and `proposalId`
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* import { daoSpace, Graph } from '@geoprotocol/geo-sdk';
|
|
21
|
-
*
|
|
22
|
-
* const { ops } = Graph.createEntity({ name: 'New Entity' });
|
|
23
|
-
* const { editId, cid, to, calldata, proposalId } = await daoSpace.proposeEdit({
|
|
24
|
-
* name: 'Add new entity',
|
|
25
|
-
* ops,
|
|
26
|
-
* author: 'your-personal-space-id',
|
|
27
|
-
* daoSpaceAddress: '0xDAOSpaceContractAddress...',
|
|
28
|
-
* callerSpaceId: '0xCallerBytes16SpaceId...',
|
|
29
|
-
* daoSpaceId: '0xDAOBytes16SpaceId...',
|
|
30
|
-
* });
|
|
31
|
-
*
|
|
32
|
-
* // Submit the transaction using viem or another client
|
|
33
|
-
* await walletClient.sendTransaction({ to, data: calldata });
|
|
34
|
-
* ```
|
|
5
|
+
* @deprecated Use `createGeoClient({ network }).daoSpaces.proposeEdit(...)`.
|
|
35
6
|
*/
|
|
36
7
|
export declare function proposeEdit(params: ProposeEditParams): Promise<ProposeEditResult>;
|
|
37
8
|
//# sourceMappingURL=propose-edit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propose-edit.d.ts","sourceRoot":"","sources":["../../../src/dao-space/propose-edit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"propose-edit.d.ts","sourceRoot":"","sources":["../../../src/dao-space/propose-edit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEvE;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAavF"}
|
|
@@ -1,118 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { DaoSpaceAbi, SpaceRegistryAbi } from '../abis/index.js';
|
|
5
|
-
import { assertValid } from '../id-utils.js';
|
|
6
|
-
import * as Ipfs from '../ipfs.js';
|
|
7
|
-
import { bytes16ToBytes32LeftAligned, EMPTY_SIGNATURE, EMPTY_TOPIC, isBytes16Hex, PROPOSAL_CREATED_ACTION, } from './constants.js';
|
|
1
|
+
import { createGeoClient } from '../client.js';
|
|
2
|
+
import { resolveGeoNetwork } from '../networks.js';
|
|
3
|
+
import { isBytes16Hex } from './constants.js';
|
|
8
4
|
/**
|
|
9
5
|
* Creates a proposal to publish an edit to a DAO space.
|
|
10
6
|
*
|
|
11
|
-
*
|
|
12
|
-
* 1. Publishes the ops to IPFS using the GRC-20 binary format
|
|
13
|
-
* 2. Generates a unique proposal ID (or uses the provided one)
|
|
14
|
-
* 3. Encodes the proposal data for the SpaceRegistry's `enter()` function
|
|
15
|
-
*
|
|
16
|
-
* The proposal, when executed, will call the DAO space's `publish()` function
|
|
17
|
-
* to publish the edit. Since `publish()` is a valid fast-path action, with
|
|
18
|
-
* FAST voting mode and sufficient votes, the proposal will auto-execute.
|
|
19
|
-
*
|
|
20
|
-
* @param params - The parameters for creating the proposal
|
|
21
|
-
* @returns Object containing `editId`, `cid`, `to` (Space Registry address),
|
|
22
|
-
* `calldata`, and `proposalId`
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* import { daoSpace, Graph } from '@geoprotocol/geo-sdk';
|
|
27
|
-
*
|
|
28
|
-
* const { ops } = Graph.createEntity({ name: 'New Entity' });
|
|
29
|
-
* const { editId, cid, to, calldata, proposalId } = await daoSpace.proposeEdit({
|
|
30
|
-
* name: 'Add new entity',
|
|
31
|
-
* ops,
|
|
32
|
-
* author: 'your-personal-space-id',
|
|
33
|
-
* daoSpaceAddress: '0xDAOSpaceContractAddress...',
|
|
34
|
-
* callerSpaceId: '0xCallerBytes16SpaceId...',
|
|
35
|
-
* daoSpaceId: '0xDAOBytes16SpaceId...',
|
|
36
|
-
* });
|
|
37
|
-
*
|
|
38
|
-
* // Submit the transaction using viem or another client
|
|
39
|
-
* await walletClient.sendTransaction({ to, data: calldata });
|
|
40
|
-
* ```
|
|
7
|
+
* @deprecated Use `createGeoClient({ network }).daoSpaces.proposeEdit(...)`.
|
|
41
8
|
*/
|
|
42
9
|
export async function proposeEdit(params) {
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (!isBytes16Hex(callerSpaceId)) {
|
|
47
|
-
throw new Error(`callerSpaceId must be bytes16 hex (0x followed by 32 hex chars). Received: ${callerSpaceId}`);
|
|
10
|
+
const { network = 'TESTNET', ...args } = params;
|
|
11
|
+
if (!isBytes16Hex(args.callerSpaceId)) {
|
|
12
|
+
throw new Error(`callerSpaceId must be bytes16 hex (0x followed by 32 hex chars). Received: ${args.callerSpaceId}`);
|
|
48
13
|
}
|
|
49
|
-
if (!isBytes16Hex(daoSpaceId)) {
|
|
50
|
-
throw new Error(`daoSpaceId must be bytes16 hex (0x followed by 32 hex chars). Received: ${daoSpaceId}`);
|
|
14
|
+
if (!isBytes16Hex(args.daoSpaceId)) {
|
|
15
|
+
throw new Error(`daoSpaceId must be bytes16 hex (0x followed by 32 hex chars). Received: ${args.daoSpaceId}`);
|
|
51
16
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
name,
|
|
55
|
-
ops,
|
|
56
|
-
author,
|
|
57
|
-
network,
|
|
58
|
-
});
|
|
59
|
-
// Generate or use provided proposal ID (UUID v4 as bytes16 hex)
|
|
60
|
-
const proposalId = proposalIdInput ?? `0x${uuidv4().replaceAll('-', '')}`;
|
|
61
|
-
if (!isBytes16Hex(proposalId)) {
|
|
62
|
-
throw new Error(`proposalId must be bytes16 hex (0x followed by 32 hex chars). Received: ${proposalId}`);
|
|
17
|
+
if (args.proposalId && !isBytes16Hex(args.proposalId)) {
|
|
18
|
+
throw new Error(`proposalId must be bytes16 hex (0x followed by 32 hex chars). Received: ${args.proposalId}`);
|
|
63
19
|
}
|
|
64
|
-
|
|
65
|
-
const editsContentUri = encodeAbiParameters([{ type: 'string' }], [cid]);
|
|
66
|
-
const editsMetadata = '0x';
|
|
67
|
-
// Encode the publish function call: publish(bytes32 _topic, bytes _editsContentUri, bytes _editsMetadata)
|
|
68
|
-
const proposalActionCalldata = encodeFunctionData({
|
|
69
|
-
abi: DaoSpaceAbi,
|
|
70
|
-
functionName: 'publish',
|
|
71
|
-
args: [EMPTY_TOPIC, editsContentUri, editsMetadata],
|
|
72
|
-
});
|
|
73
|
-
// Create the proposal action (calling publish on the DAO space)
|
|
74
|
-
const proposalActions = [
|
|
75
|
-
{
|
|
76
|
-
to: daoSpaceAddress,
|
|
77
|
-
value: 0n,
|
|
78
|
-
data: proposalActionCalldata,
|
|
79
|
-
},
|
|
80
|
-
];
|
|
81
|
-
// Encode the proposal data: abi.encode(bytes16 proposalId, VotingMode votingMode, Action[] actions)
|
|
82
|
-
const data = encodeAbiParameters([
|
|
83
|
-
{ type: 'bytes16', name: 'proposalId' },
|
|
84
|
-
{ type: 'uint8', name: 'votingMode' },
|
|
85
|
-
{
|
|
86
|
-
type: 'tuple[]',
|
|
87
|
-
name: 'actions',
|
|
88
|
-
components: [
|
|
89
|
-
{ type: 'address', name: 'to' },
|
|
90
|
-
{ type: 'uint256', name: 'value' },
|
|
91
|
-
{ type: 'bytes', name: 'data' },
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
], [proposalId, votingMode === 'FAST' ? 1 : 0, proposalActions]);
|
|
95
|
-
// Convert proposalId to bytes32 for the topic (left-aligned)
|
|
96
|
-
const topic = bytes16ToBytes32LeftAligned(proposalId);
|
|
97
|
-
// Encode the SpaceRegistry.enter() call
|
|
98
|
-
const calldata = encodeFunctionData({
|
|
99
|
-
abi: SpaceRegistryAbi,
|
|
100
|
-
functionName: 'enter',
|
|
101
|
-
args: [
|
|
102
|
-
callerSpaceId, // fromSpaceId
|
|
103
|
-
daoSpaceId, // toSpaceId
|
|
104
|
-
PROPOSAL_CREATED_ACTION, // action
|
|
105
|
-
topic, // topic (proposalId left-aligned to bytes32)
|
|
106
|
-
data, // data (encoded proposal)
|
|
107
|
-
EMPTY_SIGNATURE, // signature (unused when msg.sender == fromSpace)
|
|
108
|
-
],
|
|
109
|
-
});
|
|
110
|
-
return {
|
|
111
|
-
editId,
|
|
112
|
-
cid,
|
|
113
|
-
to: TESTNET.SPACE_REGISTRY_ADDRESS,
|
|
114
|
-
calldata,
|
|
115
|
-
proposalId,
|
|
116
|
-
};
|
|
20
|
+
return createGeoClient({ network: resolveGeoNetwork(network) }).daoSpaces.proposeEdit(args);
|
|
117
21
|
}
|
|
118
22
|
//# sourceMappingURL=propose-edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propose-edit.js","sourceRoot":"","sources":["../../../src/dao-space/propose-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"propose-edit.js","sourceRoot":"","sources":["../../../src/dao-space/propose-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAyB;IACzD,MAAM,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IAChD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,8EAA8E,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IACtH,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,2EAA2E,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAChH,CAAC;IACD,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,2EAA2E,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAChH,CAAC;IAED,OAAO,eAAe,CAAC,EAAE,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC9F,CAAC"}
|