@geoprotocol/geo-sdk 0.3.1 → 0.5.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.
Files changed (40) hide show
  1. package/dist/index.d.ts +5 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +5 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/dao-space/constants.d.ts +34 -0
  6. package/dist/src/dao-space/constants.d.ts.map +1 -0
  7. package/dist/src/dao-space/constants.js +47 -0
  8. package/dist/src/dao-space/constants.js.map +1 -0
  9. package/dist/src/dao-space/create-space.d.ts +38 -0
  10. package/dist/src/dao-space/create-space.d.ts.map +1 -0
  11. package/dist/src/dao-space/create-space.js +77 -0
  12. package/dist/src/dao-space/create-space.js.map +1 -0
  13. package/dist/src/dao-space/index.d.ts +4 -0
  14. package/dist/src/dao-space/index.d.ts.map +1 -0
  15. package/dist/src/dao-space/index.js +3 -0
  16. package/dist/src/dao-space/index.js.map +1 -0
  17. package/dist/src/dao-space/propose-edit.d.ts +37 -0
  18. package/dist/src/dao-space/propose-edit.d.ts.map +1 -0
  19. package/dist/src/dao-space/propose-edit.js +116 -0
  20. package/dist/src/dao-space/propose-edit.js.map +1 -0
  21. package/dist/src/dao-space/propose-edit.test.d.ts +2 -0
  22. package/dist/src/dao-space/propose-edit.test.d.ts.map +1 -0
  23. package/dist/src/dao-space/propose-edit.test.js +196 -0
  24. package/dist/src/dao-space/propose-edit.test.js.map +1 -0
  25. package/dist/src/dao-space/types.d.ts +84 -0
  26. package/dist/src/dao-space/types.d.ts.map +1 -0
  27. package/dist/src/dao-space/types.js +2 -0
  28. package/dist/src/dao-space/types.js.map +1 -0
  29. package/dist/src/encoding.test.js +4 -4
  30. package/dist/src/encoding.test.js.map +1 -1
  31. package/dist/src/encodings/get-create-dao-space-calldata.d.ts.map +1 -1
  32. package/dist/src/encodings/get-create-dao-space-calldata.js +3 -2
  33. package/dist/src/encodings/get-create-dao-space-calldata.js.map +1 -1
  34. package/dist/src/full-flow-test.test.js +145 -0
  35. package/dist/src/full-flow-test.test.js.map +1 -1
  36. package/dist/src/graph/update-relation.test.js +2 -2
  37. package/dist/src/graph/update-relation.test.js.map +1 -1
  38. package/dist/src/ipfs.test.js +16 -9
  39. package/dist/src/ipfs.test.js.map +1 -1
  40. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -12,6 +12,10 @@ export { DataBlock, TextBlock } from './src/blocks.js';
12
12
  */
13
13
  export * as Base58 from './src/core/base58.js';
14
14
  export { getChecksumAddress } from './src/core/get-checksum-address.js';
15
+ /**
16
+ * This module provides functions for creating DAO spaces.
17
+ */
18
+ export * as daoSpace from './src/dao-space/index.js';
15
19
  export * as Encoding from './src/encoding.js';
16
20
  export { getAcceptEditorArguments, getAcceptSubspaceArguments, getCalldataForSpaceGovernanceType, getCreateDaoSpaceCalldata, getCreatePersonalSpaceCalldata, getProcessGeoProposalArguments, getRemoveEditorArguments, getRemoveSubspaceArguments, validateIpfsUri, } from './src/encodings/index.js';
17
21
  export * as Graph from './src/graph/index.js';
@@ -46,7 +50,7 @@ export * as Rank from './src/ranks/index.js';
46
50
  * @since 0.0.6
47
51
  */
48
52
  export { GraphUrl } from './src/scheme.js';
49
- export { getSmartAccountWalletClient, getWalletClient } from './src/smart-wallet.js';
53
+ export { getSmartAccountWalletClient, getWalletClient, } from './src/smart-wallet.js';
50
54
  /**
51
55
  * Provides ids for commonly used entities across the Knowledge Graph.
52
56
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,C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QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EACjC,yBAAyB,EACzB,8BAA8B,EAC9B,8BAA8B,EAC9B,wBAAwB,EACxB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC;;;;GAIG;AACH,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C;;;GAGG;AACH,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAE7C;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EACL,2BAA2B,EAC3B,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxE,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -12,6 +12,10 @@ export { DataBlock, TextBlock } from './src/blocks.js';
12
12
  */
13
13
  export * as Base58 from './src/core/base58.js';
14
14
  export { getChecksumAddress } from './src/core/get-checksum-address.js';
15
+ /**
16
+ * This module provides functions for creating DAO spaces.
17
+ */
18
+ export * as daoSpace from './src/dao-space/index.js';
15
19
  export * as Encoding from './src/encoding.js';
16
20
  export { getAcceptEditorArguments, getAcceptSubspaceArguments, getCalldataForSpaceGovernanceType, getCreateDaoSpaceCalldata, getCreatePersonalSpaceCalldata, getProcessGeoProposalArguments, getRemoveEditorArguments, getRemoveSubspaceArguments, validateIpfsUri, } from './src/encodings/index.js';
17
21
  export * as Graph from './src/graph/index.js';
@@ -46,7 +50,7 @@ export * as Rank from './src/ranks/index.js';
46
50
  * @since 0.0.6
47
51
  */
48
52
  export { GraphUrl } from './src/scheme.js';
49
- export { getSmartAccountWalletClient, getWalletClient } from './src/smart-wallet.js';
53
+ export { getSmartAccountWalletClient, getWalletClient, } from './src/smart-wallet.js';
50
54
  /**
51
55
  * Provides ids for commonly used entities across the Knowledge Graph.
52
56
  */
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EACjC,yBAAyB,EACzB,8BAA8B,EAC9B,8BAA8B,EAC9B,wBAAwB,EACxB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC;;;;GAIG;AACH,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C;;;GAGG;AACH,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAE7C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,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EACL,2BAA2B,EAC3B,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxE,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Action hash for GOVERNANCE.PROPOSAL_CREATED
3
+ * Used when creating proposals via SpaceRegistry.enter()
4
+ */
5
+ export declare const PROPOSAL_CREATED_ACTION: `0x${string}`;
6
+ /**
7
+ * Empty topic (bytes32(0)) used for proposals
8
+ */
9
+ export declare const EMPTY_TOPIC: "0x0000000000000000000000000000000000000000000000000000000000000000";
10
+ /**
11
+ * Empty signature used when msg.sender == fromSpace
12
+ */
13
+ export declare const EMPTY_SIGNATURE: "0x";
14
+ /**
15
+ * Regex for bytes16 hex: 0x prefix + 32 hex characters (16 bytes)
16
+ */
17
+ export declare const BYTES16_HEX_REGEX: RegExp;
18
+ /**
19
+ * Regex for bytes32 hex: 0x prefix + 64 hex characters (32 bytes)
20
+ */
21
+ export declare const BYTES32_HEX_REGEX: RegExp;
22
+ /**
23
+ * Checks if a string is a valid bytes16 hex (0x prefix + 32 hex chars).
24
+ */
25
+ export declare function isBytes16Hex(value: string): boolean;
26
+ /**
27
+ * Converts a bytes32 hex string to bytes16 by taking the first 16 bytes.
28
+ */
29
+ export declare function toBytes16(hex32: `0x${string}`): `0x${string}`;
30
+ /**
31
+ * Converts a bytes16 hex string to bytes32 (left-aligned, right-padded with zeros).
32
+ */
33
+ export declare function bytes16ToBytes32LeftAligned(bytes16Hex: `0x${string}`): `0x${string}`;
34
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/dao-space/constants.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,uBAAuB,eAAkD,CAAC;AAEvF;;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,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"}
@@ -0,0 +1,47 @@
1
+ import { keccak256, toHex } from 'viem';
2
+ /**
3
+ * Action hash for GOVERNANCE.PROPOSAL_CREATED
4
+ * Used when creating proposals via SpaceRegistry.enter()
5
+ */
6
+ export const PROPOSAL_CREATED_ACTION = keccak256(toHex('GOVERNANCE.PROPOSAL_CREATED'));
7
+ /**
8
+ * Empty topic (bytes32(0)) used for proposals
9
+ */
10
+ export const EMPTY_TOPIC = '0x0000000000000000000000000000000000000000000000000000000000000000';
11
+ /**
12
+ * Empty signature used when msg.sender == fromSpace
13
+ */
14
+ export const EMPTY_SIGNATURE = '0x';
15
+ /**
16
+ * Regex for bytes16 hex: 0x prefix + 32 hex characters (16 bytes)
17
+ */
18
+ export const BYTES16_HEX_REGEX = /^0x[0-9a-fA-F]{32}$/;
19
+ /**
20
+ * Regex for bytes32 hex: 0x prefix + 64 hex characters (32 bytes)
21
+ */
22
+ export const BYTES32_HEX_REGEX = /^0x[0-9a-fA-F]{64}$/;
23
+ /**
24
+ * Checks if a string is a valid bytes16 hex (0x prefix + 32 hex chars).
25
+ */
26
+ export function isBytes16Hex(value) {
27
+ return BYTES16_HEX_REGEX.test(value);
28
+ }
29
+ /**
30
+ * Converts a bytes32 hex string to bytes16 by taking the first 16 bytes.
31
+ */
32
+ export function toBytes16(hex32) {
33
+ const s = hex32.toLowerCase();
34
+ if (!BYTES32_HEX_REGEX.test(s))
35
+ throw new Error(`Invalid hex32: ${hex32}`);
36
+ return `0x${s.slice(2, 34)}`;
37
+ }
38
+ /**
39
+ * Converts a bytes16 hex string to bytes32 (left-aligned, right-padded with zeros).
40
+ */
41
+ export function bytes16ToBytes32LeftAligned(bytes16Hex) {
42
+ const s = bytes16Hex.toLowerCase();
43
+ if (!BYTES16_HEX_REGEX.test(s))
44
+ throw new Error(`Invalid bytes16 hex: ${bytes16Hex}`);
45
+ return `0x${s.slice(2)}${'0'.repeat(32)}`;
46
+ }
47
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +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;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC,CAAC;AAEvF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,oEAA6E,CAAC;AAEzG;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAEvD;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAEvD;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAoB;IAC5C,MAAM,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAC9B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,EAAE,CAAC,CAAC;IAC3E,OAAO,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAmB,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAAC,UAAyB;IACnE,MAAM,CAAC,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IACnC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,UAAU,EAAE,CAAC,CAAC;IACtF,OAAO,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAmB,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { CreateSpaceParams, CreateSpaceResult } from './types.js';
2
+ /**
3
+ * Get the target address and calldata for creating a DAO space.
4
+ *
5
+ * This function creates the space entity, uploads the initial edit to IPFS,
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: '0x1234567890abcdef1234567890abcdef12345678',
28
+ * });
29
+ *
30
+ * // Using viem
31
+ * const hash = await walletClient.sendTransaction({
32
+ * to,
33
+ * data: calldata,
34
+ * });
35
+ * ```
36
+ */
37
+ export declare function createSpace(params: CreateSpaceParams): Promise<CreateSpaceResult>;
38
+ //# sourceMappingURL=create-space.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-space.d.ts","sourceRoot":"","sources":["../../../src/dao-space/create-space.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAyCvF"}
@@ -0,0 +1,77 @@
1
+ import { TESTNET } from '../../contracts.js';
2
+ import { SPACE_TYPE } from '../core/ids/system.js';
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';
7
+ /**
8
+ * Get the target address and calldata for creating a DAO space.
9
+ *
10
+ * This function creates the space entity, uploads the initial edit to IPFS,
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: '0x1234567890abcdef1234567890abcdef12345678',
33
+ * });
34
+ *
35
+ * // Using viem
36
+ * const hash = await walletClient.sendTransaction({
37
+ * to,
38
+ * data: calldata,
39
+ * });
40
+ * ```
41
+ */
42
+ export async function createSpace(params) {
43
+ const { name, author, ops: additionalOps = [], network = 'TESTNET' } = params;
44
+ // Generate a space entity ID
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
+ };
76
+ }
77
+ //# sourceMappingURL=create-space.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-space.js","sourceRoot":"","sources":["../../../src/dao-space/create-space.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE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a;QACb,GAAG;KACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { createSpace } from './create-space.js';
2
+ export { proposeEdit } from './propose-edit.js';
3
+ export type { CreateSpaceParams, CreateSpaceResult, ProposeEditParams, ProposeEditResult, VotingMode, } from './types.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dao-space/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,GACX,MAAM,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { createSpace } from './create-space.js';
2
+ export { proposeEdit } from './propose-edit.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dao-space/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { ProposeEditParams, ProposeEditResult } from './types.js';
2
+ /**
3
+ * Creates a proposal to publish an edit to a DAO space.
4
+ *
5
+ * This function:
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: '0x1234...',
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
+ * ```
35
+ */
36
+ export declare function proposeEdit(params: ProposeEditParams): Promise<ProposeEditResult>;
37
+ //# sourceMappingURL=propose-edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propose-edit.d.ts","sourceRoot":"","sources":["../../../src/dao-space/propose-edit.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAkGvF"}
@@ -0,0 +1,116 @@
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ import { encodeAbiParameters, encodeFunctionData } from 'viem';
3
+ import { TESTNET } from '../../contracts.js';
4
+ import { DaoSpaceAbi, SpaceRegistryAbi } from '../abis/index.js';
5
+ import * as Ipfs from '../ipfs.js';
6
+ import { bytes16ToBytes32LeftAligned, EMPTY_SIGNATURE, EMPTY_TOPIC, isBytes16Hex, PROPOSAL_CREATED_ACTION, } from './constants.js';
7
+ /**
8
+ * Creates a proposal to publish an edit to a DAO space.
9
+ *
10
+ * This function:
11
+ * 1. Publishes the ops to IPFS using the GRC-20 binary format
12
+ * 2. Generates a unique proposal ID (or uses the provided one)
13
+ * 3. Encodes the proposal data for the SpaceRegistry's `enter()` function
14
+ *
15
+ * The proposal, when executed, will call the DAO space's `publish()` function
16
+ * to publish the edit. Since `publish()` is a valid fast-path action, with
17
+ * FAST voting mode and sufficient votes, the proposal will auto-execute.
18
+ *
19
+ * @param params - The parameters for creating the proposal
20
+ * @returns Object containing `editId`, `cid`, `to` (Space Registry address),
21
+ * `calldata`, and `proposalId`
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { daoSpace, Graph } from '@geoprotocol/geo-sdk';
26
+ *
27
+ * const { ops } = Graph.createEntity({ name: 'New Entity' });
28
+ * const { editId, cid, to, calldata, proposalId } = await daoSpace.proposeEdit({
29
+ * name: 'Add new entity',
30
+ * ops,
31
+ * author: '0x1234...',
32
+ * daoSpaceAddress: '0xDAOSpaceContractAddress...',
33
+ * callerSpaceId: '0xCallerBytes16SpaceId...',
34
+ * daoSpaceId: '0xDAOBytes16SpaceId...',
35
+ * });
36
+ *
37
+ * // Submit the transaction using viem or another client
38
+ * await walletClient.sendTransaction({ to, data: calldata });
39
+ * ```
40
+ */
41
+ export async function proposeEdit(params) {
42
+ const { name, ops, author, daoSpaceAddress, callerSpaceId, daoSpaceId, votingMode = 'FAST', proposalId: proposalIdInput, network = 'TESTNET', } = params;
43
+ // Validate space IDs
44
+ if (!isBytes16Hex(callerSpaceId)) {
45
+ throw new Error(`callerSpaceId must be bytes16 hex (0x followed by 32 hex chars). Received: ${callerSpaceId}`);
46
+ }
47
+ if (!isBytes16Hex(daoSpaceId)) {
48
+ throw new Error(`daoSpaceId must be bytes16 hex (0x followed by 32 hex chars). Received: ${daoSpaceId}`);
49
+ }
50
+ // Publish the edit to IPFS
51
+ const { cid, editId } = await Ipfs.publishEdit({
52
+ name,
53
+ ops,
54
+ author,
55
+ network,
56
+ });
57
+ // Generate or use provided proposal ID (UUID v4 as bytes16 hex)
58
+ const proposalId = proposalIdInput ?? `0x${uuidv4().replaceAll('-', '')}`;
59
+ if (!isBytes16Hex(proposalId)) {
60
+ throw new Error(`proposalId must be bytes16 hex (0x followed by 32 hex chars). Received: ${proposalId}`);
61
+ }
62
+ // Encode the CID as bytes for the editsContentUri parameter
63
+ const editsContentUri = encodeAbiParameters([{ type: 'string' }], [cid]);
64
+ const editsMetadata = '0x';
65
+ // Encode the publish function call: publish(bytes32 _topic, bytes _editsContentUri, bytes _editsMetadata)
66
+ const proposalActionCalldata = encodeFunctionData({
67
+ abi: DaoSpaceAbi,
68
+ functionName: 'publish',
69
+ args: [EMPTY_TOPIC, editsContentUri, editsMetadata],
70
+ });
71
+ // Create the proposal action (calling publish on the DAO space)
72
+ const proposalActions = [
73
+ {
74
+ to: daoSpaceAddress,
75
+ value: 0n,
76
+ data: proposalActionCalldata,
77
+ },
78
+ ];
79
+ // Encode the proposal data: abi.encode(bytes16 proposalId, VotingMode votingMode, Action[] actions)
80
+ const data = encodeAbiParameters([
81
+ { type: 'bytes16', name: 'proposalId' },
82
+ { type: 'uint8', name: 'votingMode' },
83
+ {
84
+ type: 'tuple[]',
85
+ name: 'actions',
86
+ components: [
87
+ { type: 'address', name: 'to' },
88
+ { type: 'uint256', name: 'value' },
89
+ { type: 'bytes', name: 'data' },
90
+ ],
91
+ },
92
+ ], [proposalId, votingMode === 'FAST' ? 1 : 0, proposalActions]);
93
+ // Convert proposalId to bytes32 for the topic (left-aligned)
94
+ const topic = bytes16ToBytes32LeftAligned(proposalId);
95
+ // Encode the SpaceRegistry.enter() call
96
+ const calldata = encodeFunctionData({
97
+ abi: SpaceRegistryAbi,
98
+ functionName: 'enter',
99
+ args: [
100
+ callerSpaceId, // fromSpaceId
101
+ daoSpaceId, // toSpaceId
102
+ PROPOSAL_CREATED_ACTION, // action
103
+ topic, // topic (proposalId left-aligned to bytes32)
104
+ data, // data (encoded proposal)
105
+ EMPTY_SIGNATURE, // signature (unused when msg.sender == fromSpace)
106
+ ],
107
+ });
108
+ return {
109
+ editId,
110
+ cid,
111
+ to: TESTNET.SPACE_REGISTRY_ADDRESS,
112
+ calldata,
113
+ proposalId,
114
+ };
115
+ }
116
+ //# sourceMappingURL=propose-edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propose-edit.js","sourceRoot":"","sources":["../../../src/dao-space/propose-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,2BAA2B,EAC3B,eAAe,EACf,WAAW,EACX,YAAY,EACZ,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAGxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAyB;IACzD,MAAM,EACJ,IAAI,EACJ,GAAG,EACH,MAAM,EACN,eAAe,EACf,aAAa,EACb,UAAU,EACV,UAAU,GAAG,MAAM,EACnB,UAAU,EAAE,eAAe,EAC3B,OAAO,GAAG,SAAS,GACpB,GAAG,MAAM,CAAC;IAEX,qBAAqB;IACrB,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,8EAA8E,aAAa,EAAE,CAAC,CAAC;IACjH,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,2EAA2E,UAAU,EAAE,CAAC,CAAC;IAC3G,CAAC;IAED,2BAA2B;IAC3B,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC;QAC7C,IAAI;QACJ,GAA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CAAC,UAAU,EAAE,UAAU,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAC7D,CAAC;IAEF,6DAA6D;IAC7D,MAAM,KAAK,GAAG,2BAA2B,CAAC,UAAU,CAAC,CAAC;IAEtD,wCAAwC;IACxC,MAAM,QAAQ,GAAG,kBAAkB,CAAC;QAClC,GAAG,EAAE,gBAAgB;QACrB,YAAY,EAAE,OAAO;QACrB,IAAI,EAAE;YACJ,aAAa,EAAE,cAAc;YAC7B,UAAU,EAAE,YAAY;YACxB,uBAAuB,EAAE,SAAS;YAClC,KAAK,EAAE,6CAA6C;YACpD,IAAI,EAAE,0BAA0B;YAChC,eAAe,EAAE,kDAAkD;SACpE;KACF,CAAC,CAAC;IAEH,OAAO;QACL,MAAM;QACN,GAAG;QACH,EAAE,EAAE,OAAO,CAAC,sBAAsB;QAClC,QAAQ;QACR,UAAU;KACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=propose-edit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propose-edit.test.d.ts","sourceRoot":"","sources":["../../../src/dao-space/propose-edit.test.ts"],"names":[],"mappings":""}