@geoprotocol/geo-sdk 0.19.0 → 0.20.0-beta.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 +98 -45
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.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.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/api-surface.e2e.test.d.ts +2 -0
- package/dist/src/api-surface.e2e.test.d.ts.map +1 -0
- package/dist/src/{e2e-api-surface.test.js → api-surface.e2e.test.js} +87 -101
- package/dist/src/api-surface.e2e.test.js.map +1 -0
- package/dist/src/client/dao-spaces.d.ts +65 -33
- package/dist/src/client/dao-spaces.d.ts.map +1 -1
- package/dist/src/client/dao-spaces.js +133 -42
- package/dist/src/client/dao-spaces.js.map +1 -1
- package/dist/src/client/dao-spaces.test.js +277 -79
- package/dist/src/client/dao-spaces.test.js.map +1 -1
- package/dist/src/client/personal-spaces.js +2 -2
- package/dist/src/client/personal-spaces.js.map +1 -1
- package/dist/src/client/spaces.test.js +9 -7
- package/dist/src/client/spaces.test.js.map +1 -1
- package/dist/src/client.d.ts +19 -16
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +48 -59
- package/dist/src/client.js.map +1 -1
- package/dist/src/client.test.js +8 -3
- package/dist/src/client.test.js.map +1 -1
- package/dist/src/dao-space/constants.d.ts +10 -0
- package/dist/src/dao-space/constants.d.ts.map +1 -1
- package/dist/src/dao-space/constants.js +10 -0
- package/dist/src/dao-space/constants.js.map +1 -1
- package/dist/src/dao-space/execute-proposal.d.ts +1 -1
- package/dist/src/dao-space/execute-proposal.js +2 -2
- 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.test.js +45 -0
- 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 +22 -4
- 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/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 -1
- package/dist/src/dao-space/vote-proposal.js +2 -2
- 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/encodings/get-create-dao-space-calldata.d.ts +32 -9
- package/dist/src/encodings/get-create-dao-space-calldata.d.ts.map +1 -1
- package/dist/src/encodings/get-create-dao-space-calldata.js +63 -16
- 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/full-flow-test.test.js +5 -2
- package/dist/src/full-flow-test.test.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/{e2e-legacy-api-surface.test.js → legacy-api-surface.e2e.test.js} +91 -71
- package/dist/src/legacy-api-surface.e2e.test.js.map +1 -0
- package/dist/src/personal-space/constants.d.ts +1 -1
- package/dist/src/personal-space/constants.d.ts.map +1 -1
- package/dist/src/personal-space/constants.js +1 -1
- package/dist/src/personal-space/constants.js.map +1 -1
- package/dist/src/personal-space/create-space.d.ts +2 -2
- package/dist/src/personal-space/create-space.d.ts.map +1 -1
- package/dist/src/personal-space/create-space.js +4 -3
- package/dist/src/personal-space/create-space.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/package.json +3 -2
- 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/client/proposals.d.ts +0 -185
- package/dist/src/client/proposals.d.ts.map +0 -1
- package/dist/src/client/proposals.js +0 -294
- package/dist/src/client/proposals.js.map +0 -1
- package/dist/src/client/proposals.test.d.ts +0 -2
- package/dist/src/client/proposals.test.d.ts.map +0 -1
- package/dist/src/client/proposals.test.js +0 -243
- package/dist/src/client/proposals.test.js.map +0 -1
- package/dist/src/contracts-v2/abis.d.ts +0 -196
- package/dist/src/contracts-v2/abis.d.ts.map +0 -1
- package/dist/src/contracts-v2/abis.js +0 -110
- package/dist/src/contracts-v2/abis.js.map +0 -1
- package/dist/src/contracts-v2/actions.d.ts +0 -56
- package/dist/src/contracts-v2/actions.d.ts.map +0 -1
- package/dist/src/contracts-v2/actions.js +0 -83
- package/dist/src/contracts-v2/actions.js.map +0 -1
- package/dist/src/contracts-v2/encoding.d.ts +0 -80
- package/dist/src/contracts-v2/encoding.d.ts.map +0 -1
- package/dist/src/contracts-v2/encoding.js +0 -193
- package/dist/src/contracts-v2/encoding.js.map +0 -1
- package/dist/src/contracts-v2/encoding.test.d.ts +0 -2
- package/dist/src/contracts-v2/encoding.test.d.ts.map +0 -1
- package/dist/src/contracts-v2/encoding.test.js +0 -93
- package/dist/src/contracts-v2/encoding.test.js.map +0 -1
- package/dist/src/contracts-v2/voting-settings.d.ts +0 -48
- package/dist/src/contracts-v2/voting-settings.d.ts.map +0 -1
- package/dist/src/contracts-v2/voting-settings.js +0 -69
- package/dist/src/contracts-v2/voting-settings.js.map +0 -1
- package/dist/src/e2e/local-geobrowser.d.ts +0 -9
- package/dist/src/e2e/local-geobrowser.d.ts.map +0 -1
- package/dist/src/e2e/local-geobrowser.js +0 -35
- package/dist/src/e2e/local-geobrowser.js.map +0 -1
- package/dist/src/e2e/v2-contracts.test.d.ts +0 -2
- package/dist/src/e2e/v2-contracts.test.d.ts.map +0 -1
- package/dist/src/e2e/v2-contracts.test.js +0 -25
- package/dist/src/e2e/v2-contracts.test.js.map +0 -1
- package/dist/src/e2e-api-surface.test.d.ts +0 -2
- package/dist/src/e2e-api-surface.test.d.ts.map +0 -1
- package/dist/src/e2e-api-surface.test.js.map +0 -1
- package/dist/src/e2e-flows.test.d.ts +0 -2
- package/dist/src/e2e-flows.test.d.ts.map +0 -1
- package/dist/src/e2e-flows.test.js +0 -445
- package/dist/src/e2e-flows.test.js.map +0 -1
- package/dist/src/e2e-legacy-api-surface.test.d.ts +0 -2
- package/dist/src/e2e-legacy-api-surface.test.d.ts.map +0 -1
- package/dist/src/e2e-legacy-api-surface.test.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/ops/images.d.ts +0 -37
- package/dist/src/ops/images.d.ts.map +0 -1
- package/dist/src/ops/images.js +0 -69
- package/dist/src/ops/images.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,150 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { defineGeoNetworkConfig, GeoTestnetConfig } from './networks.js';
|
|
3
|
+
const DEFAULT_LOCAL_GEOBROWSER_PRIVATE_KEY = '0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a';
|
|
4
|
+
const INDEXED_LOCAL_GEOBROWSER_DAO_FACTORIES = {
|
|
5
|
+
// First deterministic local-geobrowser deployment. The running hermes-substream
|
|
6
|
+
// may still be compiled against this registry after contracts are redeployed.
|
|
7
|
+
'0xe7f1725e7734ce288f8367e1bb143e90bb3f0512': '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9',
|
|
8
|
+
};
|
|
9
|
+
function requireHexPrivateKey(value, source) {
|
|
10
|
+
if (!value) {
|
|
11
|
+
throw new Error(`${source} is required for e2e tests.`);
|
|
12
|
+
}
|
|
13
|
+
if (!value.startsWith('0x')) {
|
|
14
|
+
throw new Error(`${source} must be a hex string starting with 0x.`);
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
function requireEnv(value, source) {
|
|
19
|
+
if (!value) {
|
|
20
|
+
throw new Error(`${source} is required for local-geobrowser e2e tests. Set GEO_E2E_NETWORK=TESTNET to run against testnet.`);
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
function requireNetworkRpcUrl(network) {
|
|
25
|
+
const rpcUrl = network.chain?.rpcUrl;
|
|
26
|
+
if (!rpcUrl) {
|
|
27
|
+
throw new Error(`Geo network "${network.name}" is missing an RPC URL`);
|
|
28
|
+
}
|
|
29
|
+
return rpcUrl;
|
|
30
|
+
}
|
|
31
|
+
function requireNetworkContract(network, name) {
|
|
32
|
+
const address = network.contracts?.[name];
|
|
33
|
+
if (!address) {
|
|
34
|
+
throw new Error(`Geo network "${network.name}" is missing ${name}`);
|
|
35
|
+
}
|
|
36
|
+
return address;
|
|
37
|
+
}
|
|
38
|
+
function createChain(network, rpcUrl) {
|
|
39
|
+
const chainConfig = network.chain;
|
|
40
|
+
if (!chainConfig) {
|
|
41
|
+
throw new Error(`Geo network "${network.name}" is missing chain config`);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
id: chainConfig.id,
|
|
45
|
+
name: chainConfig.name,
|
|
46
|
+
nativeCurrency: {
|
|
47
|
+
name: 'Ethereum',
|
|
48
|
+
symbol: 'ETH',
|
|
49
|
+
decimals: 18,
|
|
50
|
+
},
|
|
51
|
+
rpcUrls: {
|
|
52
|
+
default: { http: [rpcUrl] },
|
|
53
|
+
public: { http: [rpcUrl] },
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function readLocalGeobrowserDeployments() {
|
|
58
|
+
if (process.env.GEO_E2E_NETWORK === 'TESTNET') {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const localGeobrowserPath = requireEnv(process.env.GEO_LOCAL_GEOBROWSER_PATH, 'GEO_LOCAL_GEOBROWSER_PATH');
|
|
62
|
+
const deploymentsPath = process.env.GEO_LOCAL_GEOBROWSER_DEPLOYMENTS ?? `${localGeobrowserPath}/.deployments.json`;
|
|
63
|
+
try {
|
|
64
|
+
return {
|
|
65
|
+
path: localGeobrowserPath,
|
|
66
|
+
deployments: JSON.parse(readFileSync(deploymentsPath, 'utf8')),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
throw new Error(`Could not read local-geobrowser deployments from ${deploymentsPath}. Set GEO_LOCAL_GEOBROWSER_DEPLOYMENTS to override the path.`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function readIndexedLocalSpaceRegistry(localGeobrowserPath) {
|
|
74
|
+
try {
|
|
75
|
+
const source = readFileSync(`${localGeobrowserPath}/gaia/hermes-substream/src/lib.rs`, 'utf8');
|
|
76
|
+
const match = /\nconst SPACE_REGISTRY_ADDRESS:[\s\S]*?=\s*\[([\s\S]*?)\];/.exec(source);
|
|
77
|
+
const bytes = match?.[1]?.match(/0x[0-9a-fA-F]{2}/g);
|
|
78
|
+
if (!bytes || bytes.length !== 20) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
return `0x${bytes.map(byte => byte.slice(2)).join('')}`;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function createE2ETestEnvironment() {
|
|
88
|
+
const local = readLocalGeobrowserDeployments();
|
|
89
|
+
if (local) {
|
|
90
|
+
const rpcUrl = process.env.GEO_LOCAL_GEOBROWSER_RPC_URL ?? local.deployments.rpcUrl ?? 'http://localhost:8545';
|
|
91
|
+
const apiOrigin = process.env.GEO_LOCAL_GEOBROWSER_API_ORIGIN ?? 'http://localhost:3000';
|
|
92
|
+
const indexedSpaceRegistry = readIndexedLocalSpaceRegistry(local.path);
|
|
93
|
+
const spaceRegistryAddress = process.env.GEO_LOCAL_GEOBROWSER_SPACE_REGISTRY_ADDRESS ??
|
|
94
|
+
indexedSpaceRegistry ??
|
|
95
|
+
local.deployments.spaceRegistry;
|
|
96
|
+
const daoSpaceFactoryAddress = process.env.GEO_LOCAL_GEOBROWSER_DAO_SPACE_FACTORY_ADDRESS ??
|
|
97
|
+
(spaceRegistryAddress.toLowerCase() === local.deployments.spaceRegistry.toLowerCase()
|
|
98
|
+
? local.deployments.daoSpaceFactory
|
|
99
|
+
: (INDEXED_LOCAL_GEOBROWSER_DAO_FACTORIES[spaceRegistryAddress.toLowerCase()] ??
|
|
100
|
+
local.deployments.daoSpaceFactory));
|
|
101
|
+
const network = defineGeoNetworkConfig({
|
|
102
|
+
id: 'LOCAL_GEOBROWSER',
|
|
103
|
+
name: 'Local Geobrowser',
|
|
104
|
+
apiOrigin,
|
|
105
|
+
chain: {
|
|
106
|
+
id: Number(process.env.GEO_LOCAL_GEOBROWSER_CHAIN_ID ?? 1337),
|
|
107
|
+
name: 'Anvil',
|
|
108
|
+
rpcUrl,
|
|
109
|
+
},
|
|
110
|
+
contracts: {
|
|
111
|
+
SPACE_REGISTRY_ADDRESS: spaceRegistryAddress,
|
|
112
|
+
DAO_SPACE_FACTORY_ADDRESS: daoSpaceFactoryAddress,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
network,
|
|
117
|
+
networkish: network,
|
|
118
|
+
privateKey: requireHexPrivateKey(process.env.GEO_LOCAL_GEOBROWSER_PRIVATE_KEY ??
|
|
119
|
+
process.env.GEO_E2E_PRIVATE_KEY ??
|
|
120
|
+
DEFAULT_LOCAL_GEOBROWSER_PRIVATE_KEY, 'GEO_LOCAL_GEOBROWSER_PRIVATE_KEY'),
|
|
121
|
+
rpcUrl,
|
|
122
|
+
apiOrigin,
|
|
123
|
+
chain: createChain(network, rpcUrl),
|
|
124
|
+
contracts: {
|
|
125
|
+
SPACE_REGISTRY_ADDRESS: spaceRegistryAddress,
|
|
126
|
+
DAO_SPACE_FACTORY_ADDRESS: daoSpaceFactoryAddress,
|
|
127
|
+
},
|
|
128
|
+
localGeobrowserPath: local.path,
|
|
129
|
+
localGeobrowserDeployments: local.deployments,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const rpcUrl = process.env.GEO_E2E_RPC_URL ?? requireNetworkRpcUrl(GeoTestnetConfig);
|
|
133
|
+
const network = defineGeoNetworkConfig({
|
|
134
|
+
...GeoTestnetConfig,
|
|
135
|
+
chain: GeoTestnetConfig.chain ? { ...GeoTestnetConfig.chain, rpcUrl } : undefined,
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
network,
|
|
139
|
+
networkish: 'TESTNET',
|
|
140
|
+
privateKey: requireHexPrivateKey(process.env.GEO_E2E_PRIVATE_KEY ?? process.env.PRIVATE_KEY, 'PRIVATE_KEY'),
|
|
141
|
+
rpcUrl,
|
|
142
|
+
apiOrigin: network.apiOrigin,
|
|
143
|
+
chain: createChain(network, rpcUrl),
|
|
144
|
+
contracts: {
|
|
145
|
+
SPACE_REGISTRY_ADDRESS: requireNetworkContract(network, 'SPACE_REGISTRY_ADDRESS'),
|
|
146
|
+
DAO_SPACE_FACTORY_ADDRESS: requireNetworkContract(network, 'DAO_SPACE_FACTORY_ADDRESS'),
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=e2e-test-environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e2e-test-environment.js","sourceRoot":"","sources":["../../src/e2e-test-environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,eAAe,C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EAAE,SAAS;QACrB,UAAU,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,aAAa,CAAC;QAC3G,MAAM;QACN,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,KAAK,EAAE,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC;QACnC,SAAS,EAAE;YACT,sBAAsB,EAAE,sBAAsB,CAAC,OAAO,EAAE,wBAAwB,CAAC;YACjF,yBAAyB,EAAE,sBAAsB,CAAC,OAAO,EAAE,2BAA2B,CAAC;SACxF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -3,32 +3,49 @@
|
|
|
3
3
|
* 100% = 10e6 (10,000,000), so 50% = 5e6 (5,000,000)
|
|
4
4
|
*/
|
|
5
5
|
export declare const RATIO_BASE: bigint;
|
|
6
|
-
/** Minimum voting duration in seconds
|
|
6
|
+
/** Minimum voting duration in seconds, matching the contracts v2 lower bound. */
|
|
7
7
|
export declare const MINIMUM_VOTING_DURATION: bigint;
|
|
8
8
|
/** Minimum voting duration in days */
|
|
9
|
-
export declare const MINIMUM_VOTING_DURATION_DAYS
|
|
9
|
+
export declare const MINIMUM_VOTING_DURATION_DAYS: number;
|
|
10
|
+
/** Minimum execution grace period in seconds, matching the contracts v2 lower bound. */
|
|
11
|
+
export declare const MINIMUM_EXECUTION_GRACE_PERIOD: bigint;
|
|
12
|
+
/** Minimum execution grace period in days */
|
|
13
|
+
export declare const MINIMUM_EXECUTION_GRACE_PERIOD_DAYS: number;
|
|
10
14
|
/**
|
|
11
15
|
* User-friendly voting settings input (using percentages and days)
|
|
12
16
|
*/
|
|
13
17
|
export interface VotingSettingsInput {
|
|
14
|
-
/**
|
|
15
|
-
|
|
18
|
+
/** Partial percentage threshold for slow path late execution (0-100) */
|
|
19
|
+
partialPercentageSupportThreshold: number;
|
|
20
|
+
/** Universal percentage threshold for slow path early execution (0-100) */
|
|
21
|
+
universalPercentageSupportThreshold: number;
|
|
16
22
|
/** Number of editors required for fast path approval */
|
|
17
|
-
|
|
23
|
+
flatSupportThreshold: number;
|
|
18
24
|
/** Minimum number of editors required to vote */
|
|
19
25
|
quorum: number;
|
|
20
|
-
/** Voting duration in days
|
|
26
|
+
/** Voting duration in days */
|
|
21
27
|
durationInDays: number;
|
|
28
|
+
/** Whether newly added members start without fast-path access */
|
|
29
|
+
disableFastPathAccessForNewMembers: boolean;
|
|
30
|
+
/** Execution grace period in days */
|
|
31
|
+
executionGracePeriodInDays: number;
|
|
22
32
|
}
|
|
23
33
|
/**
|
|
24
34
|
* Contract-level voting settings (using raw values)
|
|
25
35
|
*/
|
|
26
36
|
export interface VotingSettings {
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
partialPercentageSupportThreshold: bigint;
|
|
38
|
+
universalPercentageSupportThreshold: bigint;
|
|
39
|
+
flatSupportThreshold: bigint;
|
|
29
40
|
quorum: bigint;
|
|
30
41
|
duration: bigint;
|
|
42
|
+
disableFastPathAccessForNewMembers: boolean;
|
|
43
|
+
executionGracePeriod: bigint;
|
|
31
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Sensible user-friendly defaults for contracts v2 DAO spaces.
|
|
47
|
+
*/
|
|
48
|
+
export declare const DEFAULT_VOTING_SETTINGS: VotingSettingsInput;
|
|
32
49
|
/**
|
|
33
50
|
* Convert a percentage (0-100) to the contract's ratio format.
|
|
34
51
|
*/
|
|
@@ -47,8 +64,14 @@ export declare function toContractVotingSettings(input: VotingSettingsInput): Vo
|
|
|
47
64
|
export declare function validateIpfsUri(uri: string): string | null;
|
|
48
65
|
/**
|
|
49
66
|
* Validate voting settings input.
|
|
67
|
+
*
|
|
68
|
+
* When `totalEditors` is provided, the flat support threshold and quorum are
|
|
69
|
+
* also checked against that known editor count. For existing DAO spaces the
|
|
70
|
+
* current editor count may be unknown client-side, so callers can omit it and
|
|
71
|
+
* still get deterministic local validation for numeric shape, percentages, and
|
|
72
|
+
* duration lower bounds before the contract enforces editor-count limits.
|
|
50
73
|
*/
|
|
51
|
-
export declare function validateVotingSettingsInput(settings: VotingSettingsInput, totalEditors
|
|
74
|
+
export declare function validateVotingSettingsInput(settings: VotingSettingsInput, totalEditors?: number): string | null;
|
|
52
75
|
export type CreateDaoSpaceCalldataParams = {
|
|
53
76
|
/** Voting settings for the DAO space */
|
|
54
77
|
votingSettings: VotingSettingsInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-create-dao-space-calldata.d.ts","sourceRoot":"","sources":["../../../src/encodings/get-create-dao-space-calldata.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,UAAU,QAAe,CAAC;AAEvC,
|
|
1
|
+
{"version":3,"file":"get-create-dao-space-calldata.d.ts","sourceRoot":"","sources":["../../../src/encodings/get-create-dao-space-calldata.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,UAAU,QAAe,CAAC;AAEvC,iFAAiF;AACjF,eAAO,MAAM,uBAAuB,QAAa,CAAC;AAElD,sCAAsC;AACtC,eAAO,MAAM,4BAA4B,QAAc,CAAC;AAExD,wFAAwF;AACxF,eAAO,MAAM,8BAA8B,QAAkB,CAAC;AAE9D,6CAA6C;AAC7C,eAAO,MAAM,mCAAmC,QAAS,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,iCAAiC,EAAE,MAAM,CAAC;IAC1C,2EAA2E;IAC3E,mCAAmC,EAAE,MAAM,CAAC;IAC5C,wDAAwD;IACxD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,iEAAiE;IACjE,kCAAkC,EAAE,OAAO,CAAC;IAC5C,qCAAqC;IACrC,0BAA0B,EAAE,MAAM,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,iCAAiC,EAA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|
|
2
2
|
import { DaoSpaceFactoryAbi } from '../abis/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* The base value for percentage ratios in the contract.
|
|
5
5
|
* 100% = 10e6 (10,000,000), so 50% = 5e6 (5,000,000)
|
|
6
6
|
*/
|
|
7
7
|
export const RATIO_BASE = BigInt(10e6);
|
|
8
|
-
/** Minimum voting duration in seconds
|
|
9
|
-
export const MINIMUM_VOTING_DURATION = BigInt(
|
|
8
|
+
/** Minimum voting duration in seconds, matching the contracts v2 lower bound. */
|
|
9
|
+
export const MINIMUM_VOTING_DURATION = BigInt(60);
|
|
10
10
|
/** Minimum voting duration in days */
|
|
11
|
-
export const MINIMUM_VOTING_DURATION_DAYS =
|
|
11
|
+
export const MINIMUM_VOTING_DURATION_DAYS = 1 / 24 / 60;
|
|
12
|
+
/** Minimum execution grace period in seconds, matching the contracts v2 lower bound. */
|
|
13
|
+
export const MINIMUM_EXECUTION_GRACE_PERIOD = BigInt(60 * 60);
|
|
14
|
+
/** Minimum execution grace period in days */
|
|
15
|
+
export const MINIMUM_EXECUTION_GRACE_PERIOD_DAYS = 1 / 24;
|
|
16
|
+
/**
|
|
17
|
+
* Sensible user-friendly defaults for contracts v2 DAO spaces.
|
|
18
|
+
*/
|
|
19
|
+
export const DEFAULT_VOTING_SETTINGS = {
|
|
20
|
+
partialPercentageSupportThreshold: 50,
|
|
21
|
+
universalPercentageSupportThreshold: 90,
|
|
22
|
+
flatSupportThreshold: 1,
|
|
23
|
+
quorum: 1,
|
|
24
|
+
durationInDays: 2,
|
|
25
|
+
disableFastPathAccessForNewMembers: true,
|
|
26
|
+
executionGracePeriodInDays: 14,
|
|
27
|
+
};
|
|
12
28
|
/**
|
|
13
29
|
* Convert a percentage (0-100) to the contract's ratio format.
|
|
14
30
|
*/
|
|
@@ -26,10 +42,13 @@ export function daysToSeconds(days) {
|
|
|
26
42
|
*/
|
|
27
43
|
export function toContractVotingSettings(input) {
|
|
28
44
|
return {
|
|
29
|
-
|
|
30
|
-
|
|
45
|
+
partialPercentageSupportThreshold: percentageToRatio(input.partialPercentageSupportThreshold),
|
|
46
|
+
universalPercentageSupportThreshold: percentageToRatio(input.universalPercentageSupportThreshold),
|
|
47
|
+
flatSupportThreshold: BigInt(input.flatSupportThreshold),
|
|
31
48
|
quorum: BigInt(input.quorum),
|
|
32
49
|
duration: daysToSeconds(input.durationInDays),
|
|
50
|
+
disableFastPathAccessForNewMembers: input.disableFastPathAccessForNewMembers,
|
|
51
|
+
executionGracePeriod: daysToSeconds(input.executionGracePeriodInDays),
|
|
33
52
|
};
|
|
34
53
|
}
|
|
35
54
|
/**
|
|
@@ -50,22 +69,48 @@ export function validateIpfsUri(uri) {
|
|
|
50
69
|
}
|
|
51
70
|
return null;
|
|
52
71
|
}
|
|
72
|
+
function isNonNegativeInteger(value) {
|
|
73
|
+
return Number.isInteger(value) && value >= 0;
|
|
74
|
+
}
|
|
53
75
|
/**
|
|
54
76
|
* Validate voting settings input.
|
|
77
|
+
*
|
|
78
|
+
* When `totalEditors` is provided, the flat support threshold and quorum are
|
|
79
|
+
* also checked against that known editor count. For existing DAO spaces the
|
|
80
|
+
* current editor count may be unknown client-side, so callers can omit it and
|
|
81
|
+
* still get deterministic local validation for numeric shape, percentages, and
|
|
82
|
+
* duration lower bounds before the contract enforces editor-count limits.
|
|
55
83
|
*/
|
|
56
84
|
export function validateVotingSettingsInput(settings, totalEditors) {
|
|
57
|
-
if (
|
|
58
|
-
|
|
85
|
+
if (!Number.isFinite(settings.partialPercentageSupportThreshold) ||
|
|
86
|
+
settings.partialPercentageSupportThreshold < 0 ||
|
|
87
|
+
settings.partialPercentageSupportThreshold > 100) {
|
|
88
|
+
return 'partialPercentageSupportThreshold must be between 0 and 100';
|
|
89
|
+
}
|
|
90
|
+
if (!Number.isFinite(settings.universalPercentageSupportThreshold) ||
|
|
91
|
+
settings.universalPercentageSupportThreshold < 0 ||
|
|
92
|
+
settings.universalPercentageSupportThreshold > 100) {
|
|
93
|
+
return 'universalPercentageSupportThreshold must be between 0 and 100';
|
|
59
94
|
}
|
|
60
|
-
if (settings.
|
|
61
|
-
return
|
|
95
|
+
if (!isNonNegativeInteger(settings.flatSupportThreshold)) {
|
|
96
|
+
return 'flatSupportThreshold must be a non-negative integer';
|
|
62
97
|
}
|
|
63
|
-
if (
|
|
98
|
+
if (totalEditors !== undefined && settings.flatSupportThreshold > totalEditors) {
|
|
99
|
+
return `flatSupportThreshold must be between 0 and ${totalEditors} (number of initial editors)`;
|
|
100
|
+
}
|
|
101
|
+
if (!isNonNegativeInteger(settings.quorum)) {
|
|
102
|
+
return 'quorum must be a non-negative integer';
|
|
103
|
+
}
|
|
104
|
+
if (totalEditors !== undefined && settings.quorum > totalEditors) {
|
|
64
105
|
return `quorum must be between 0 and ${totalEditors} (number of initial editors)`;
|
|
65
106
|
}
|
|
66
|
-
if (settings.durationInDays < MINIMUM_VOTING_DURATION_DAYS) {
|
|
107
|
+
if (!Number.isFinite(settings.durationInDays) || settings.durationInDays < MINIMUM_VOTING_DURATION_DAYS) {
|
|
67
108
|
return `durationInDays must be at least ${MINIMUM_VOTING_DURATION_DAYS} days`;
|
|
68
109
|
}
|
|
110
|
+
if (!Number.isFinite(settings.executionGracePeriodInDays) ||
|
|
111
|
+
settings.executionGracePeriodInDays < MINIMUM_EXECUTION_GRACE_PERIOD_DAYS) {
|
|
112
|
+
return `executionGracePeriodInDays must be at least ${MINIMUM_EXECUTION_GRACE_PERIOD_DAYS} days`;
|
|
113
|
+
}
|
|
69
114
|
return null;
|
|
70
115
|
}
|
|
71
116
|
/**
|
|
@@ -91,7 +136,7 @@ export function getCreateDaoSpaceCalldata(args) {
|
|
|
91
136
|
if (ipfsError) {
|
|
92
137
|
throw new Error(ipfsError);
|
|
93
138
|
}
|
|
94
|
-
initialEditsContentUri =
|
|
139
|
+
initialEditsContentUri = toHex(args.initialEditsContentUri);
|
|
95
140
|
}
|
|
96
141
|
let initialTopicId = '0x00000000000000000000000000000000';
|
|
97
142
|
if (args.initialTopicId) {
|
|
@@ -102,17 +147,19 @@ export function getCreateDaoSpaceCalldata(args) {
|
|
|
102
147
|
functionName: 'createDAOSpaceProxy',
|
|
103
148
|
args: [
|
|
104
149
|
{
|
|
105
|
-
|
|
106
|
-
|
|
150
|
+
partialPercentageSupportThreshold: contractVotingSettings.partialPercentageSupportThreshold,
|
|
151
|
+
universalPercentageSupportThreshold: contractVotingSettings.universalPercentageSupportThreshold,
|
|
152
|
+
flatSupportThreshold: contractVotingSettings.flatSupportThreshold,
|
|
107
153
|
quorum: contractVotingSettings.quorum,
|
|
108
154
|
duration: contractVotingSettings.duration,
|
|
155
|
+
disableFastPathAccessForNewMembers: contractVotingSettings.disableFastPathAccessForNewMembers,
|
|
156
|
+
executionGracePeriod: contractVotingSettings.executionGracePeriod,
|
|
109
157
|
},
|
|
110
158
|
initialEditorSpaceIds,
|
|
111
159
|
initialMemberSpaceIds,
|
|
112
160
|
initialEditsContentUri,
|
|
113
161
|
'0x',
|
|
114
162
|
initialTopicId,
|
|
115
|
-
'0x',
|
|
116
163
|
],
|
|
117
164
|
});
|
|
118
165
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-create-dao-space-calldata.js","sourceRoot":"","sources":["../../../src/encodings/get-create-dao-space-calldata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"get-create-dao-space-calldata.js","sourceRoot":"","sources":["../../../src/encodings/get-create-dao-space-calldata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAEvC,iFAAiF;AACjF,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAElD,sCAAsC;AACtC,M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 @@
|
|
|
1
|
+
import { decodeFunctionData, hexToString } from 'viem';
|
|
1
2
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
+
import { DaoSpaceFactoryAbi } from '../abis/index.js';
|
|
4
|
+
import { DEFAULT_VOTING_SETTINGS, daysToSeconds, getCreateDaoSpaceCalldata, MINIMUM_EXECUTION_GRACE_PERIOD, MINIMUM_EXECUTION_GRACE_PERIOD_DAYS, MINIMUM_VOTING_DURATION, MINIMUM_VOTING_DURATION_DAYS, percentageToRatio, RATIO_BASE, toContractVotingSettings, validateIpfsUri, validateVotingSettingsInput, } from './get-create-dao-space-calldata.js';
|
|
3
5
|
describe('percentageToRatio', () => {
|
|
4
6
|
it('should convert 100% to RATIO_BASE', () => {
|
|
5
7
|
expect(percentageToRatio(100)).toBe(RATIO_BASE);
|
|
@@ -19,7 +21,10 @@ describe('daysToSeconds', () => {
|
|
|
19
21
|
expect(daysToSeconds(1)).toBe(BigInt(86400));
|
|
20
22
|
});
|
|
21
23
|
it('should convert 2 days to 172800 seconds', () => {
|
|
22
|
-
expect(daysToSeconds(2)).toBe(
|
|
24
|
+
expect(daysToSeconds(2)).toBe(BigInt(172800));
|
|
25
|
+
});
|
|
26
|
+
it('should expose the contracts v2 minimum duration', () => {
|
|
27
|
+
expect(MINIMUM_VOTING_DURATION).toBe(BigInt(60));
|
|
23
28
|
});
|
|
24
29
|
it('should handle fractional days', () => {
|
|
25
30
|
expect(daysToSeconds(0.5)).toBe(BigInt(43200));
|
|
@@ -28,16 +33,22 @@ describe('daysToSeconds', () => {
|
|
|
28
33
|
describe('toContractVotingSettings', () => {
|
|
29
34
|
it('should convert user-friendly settings to contract format', () => {
|
|
30
35
|
const input = {
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
partialPercentageSupportThreshold: 50,
|
|
37
|
+
universalPercentageSupportThreshold: 90,
|
|
38
|
+
flatSupportThreshold: 3,
|
|
33
39
|
quorum: 2,
|
|
34
40
|
durationInDays: 7,
|
|
41
|
+
disableFastPathAccessForNewMembers: true,
|
|
42
|
+
executionGracePeriodInDays: 14,
|
|
35
43
|
};
|
|
36
44
|
const result = toContractVotingSettings(input);
|
|
37
|
-
expect(result.
|
|
38
|
-
expect(result.
|
|
45
|
+
expect(result.partialPercentageSupportThreshold).toBe(percentageToRatio(50));
|
|
46
|
+
expect(result.universalPercentageSupportThreshold).toBe(percentageToRatio(90));
|
|
47
|
+
expect(result.flatSupportThreshold).toBe(BigInt(3));
|
|
39
48
|
expect(result.quorum).toBe(BigInt(2));
|
|
40
49
|
expect(result.duration).toBe(daysToSeconds(7));
|
|
50
|
+
expect(result.disableFastPathAccessForNewMembers).toBe(true);
|
|
51
|
+
expect(result.executionGracePeriod).toBe(daysToSeconds(14));
|
|
41
52
|
});
|
|
42
53
|
});
|
|
43
54
|
describe('validateIpfsUri', () => {
|
|
@@ -62,42 +73,64 @@ describe('validateIpfsUri', () => {
|
|
|
62
73
|
});
|
|
63
74
|
describe('validateVotingSettingsInput', () => {
|
|
64
75
|
const validSettings = {
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
partialPercentageSupportThreshold: 50,
|
|
77
|
+
universalPercentageSupportThreshold: 90,
|
|
78
|
+
flatSupportThreshold: 3,
|
|
67
79
|
quorum: 2,
|
|
68
80
|
durationInDays: 7,
|
|
81
|
+
disableFastPathAccessForNewMembers: true,
|
|
82
|
+
executionGracePeriodInDays: 14,
|
|
69
83
|
};
|
|
70
84
|
it('should return null for valid settings', () => {
|
|
71
85
|
expect(validateVotingSettingsInput(validSettings, 5)).toBeNull();
|
|
72
86
|
});
|
|
73
|
-
it('should reject
|
|
74
|
-
const settings = { ...validSettings,
|
|
75
|
-
expect(validateVotingSettingsInput(settings, 5)).toBe('
|
|
87
|
+
it('should reject partialPercentageSupportThreshold below 0', () => {
|
|
88
|
+
const settings = { ...validSettings, partialPercentageSupportThreshold: -1 };
|
|
89
|
+
expect(validateVotingSettingsInput(settings, 5)).toBe('partialPercentageSupportThreshold must be between 0 and 100');
|
|
90
|
+
});
|
|
91
|
+
it('should reject partialPercentageSupportThreshold above 100', () => {
|
|
92
|
+
const settings = { ...validSettings, partialPercentageSupportThreshold: 101 };
|
|
93
|
+
expect(validateVotingSettingsInput(settings, 5)).toBe('partialPercentageSupportThreshold must be between 0 and 100');
|
|
76
94
|
});
|
|
77
|
-
it('should reject
|
|
78
|
-
const settings = { ...validSettings,
|
|
79
|
-
expect(validateVotingSettingsInput(settings, 5)).toBe('
|
|
95
|
+
it('should reject universalPercentageSupportThreshold above 100', () => {
|
|
96
|
+
const settings = { ...validSettings, universalPercentageSupportThreshold: 101 };
|
|
97
|
+
expect(validateVotingSettingsInput(settings, 5)).toBe('universalPercentageSupportThreshold must be between 0 and 100');
|
|
80
98
|
});
|
|
81
|
-
it('should reject
|
|
82
|
-
const settings = { ...validSettings,
|
|
83
|
-
expect(validateVotingSettingsInput(settings, 5)).toBe('
|
|
99
|
+
it('should reject flatSupportThreshold above total editors', () => {
|
|
100
|
+
const settings = { ...validSettings, flatSupportThreshold: 10 };
|
|
101
|
+
expect(validateVotingSettingsInput(settings, 5)).toBe('flatSupportThreshold must be between 0 and 5 (number of initial editors)');
|
|
84
102
|
});
|
|
85
103
|
it('should reject quorum above total editors', () => {
|
|
86
104
|
const settings = { ...validSettings, quorum: 10 };
|
|
87
105
|
expect(validateVotingSettingsInput(settings, 5)).toBe('quorum must be between 0 and 5 (number of initial editors)');
|
|
88
106
|
});
|
|
107
|
+
it('should allow omitted total editors for existing DAO settings validation', () => {
|
|
108
|
+
const settings = { ...validSettings, flatSupportThreshold: 10, quorum: 10 };
|
|
109
|
+
expect(validateVotingSettingsInput(settings)).toBeNull();
|
|
110
|
+
});
|
|
111
|
+
it('should reject non-integer flatSupportThreshold and quorum', () => {
|
|
112
|
+
expect(validateVotingSettingsInput({ ...validSettings, flatSupportThreshold: 1.5 })).toBe('flatSupportThreshold must be a non-negative integer');
|
|
113
|
+
expect(validateVotingSettingsInput({ ...validSettings, quorum: -1 })).toBe('quorum must be a non-negative integer');
|
|
114
|
+
});
|
|
89
115
|
it('should reject durationInDays below minimum', () => {
|
|
90
|
-
const settings = { ...validSettings, durationInDays:
|
|
116
|
+
const settings = { ...validSettings, durationInDays: MINIMUM_VOTING_DURATION_DAYS / 2 };
|
|
91
117
|
expect(validateVotingSettingsInput(settings, 5)).toBe(`durationInDays must be at least ${MINIMUM_VOTING_DURATION_DAYS} days`);
|
|
92
118
|
});
|
|
119
|
+
it('should reject executionGracePeriodInDays below minimum', () => {
|
|
120
|
+
const settings = { ...validSettings, executionGracePeriodInDays: MINIMUM_EXECUTION_GRACE_PERIOD_DAYS / 2 };
|
|
121
|
+
expect(validateVotingSettingsInput(settings, 5)).toBe(`executionGracePeriodInDays must be at least ${MINIMUM_EXECUTION_GRACE_PERIOD_DAYS} days`);
|
|
122
|
+
});
|
|
93
123
|
});
|
|
94
124
|
describe('getCreateDaoSpaceCalldata', () => {
|
|
95
125
|
const validArgs = {
|
|
96
126
|
votingSettings: {
|
|
97
|
-
|
|
98
|
-
|
|
127
|
+
partialPercentageSupportThreshold: 50,
|
|
128
|
+
universalPercentageSupportThreshold: 90,
|
|
129
|
+
flatSupportThreshold: 2,
|
|
99
130
|
quorum: 1,
|
|
100
131
|
durationInDays: 7,
|
|
132
|
+
disableFastPathAccessForNewMembers: true,
|
|
133
|
+
executionGracePeriodInDays: 14,
|
|
101
134
|
},
|
|
102
135
|
initialEditorSpaceIds: [
|
|
103
136
|
'0x12345678901234567890123456789012',
|
|
@@ -111,6 +144,24 @@ describe('getCreateDaoSpaceCalldata', () => {
|
|
|
111
144
|
expect(calldata).toBeTypeOf('string');
|
|
112
145
|
expect(calldata.startsWith('0x')).toBe(true);
|
|
113
146
|
});
|
|
147
|
+
it('should encode the v2 six-argument factory call', () => {
|
|
148
|
+
const calldata = getCreateDaoSpaceCalldata(validArgs);
|
|
149
|
+
const decoded = decodeFunctionData({
|
|
150
|
+
abi: DaoSpaceFactoryAbi,
|
|
151
|
+
data: calldata,
|
|
152
|
+
});
|
|
153
|
+
expect(decoded.functionName).toBe('createDAOSpaceProxy');
|
|
154
|
+
expect(decoded.args).toHaveLength(6);
|
|
155
|
+
expect(decoded.args[0]).toMatchObject({
|
|
156
|
+
partialPercentageSupportThreshold: percentageToRatio(50),
|
|
157
|
+
universalPercentageSupportThreshold: percentageToRatio(90),
|
|
158
|
+
flatSupportThreshold: 2n,
|
|
159
|
+
quorum: 1n,
|
|
160
|
+
duration: daysToSeconds(7),
|
|
161
|
+
disableFastPathAccessForNewMembers: true,
|
|
162
|
+
executionGracePeriod: daysToSeconds(14),
|
|
163
|
+
});
|
|
164
|
+
});
|
|
114
165
|
it('should throw if no initial editors provided', () => {
|
|
115
166
|
const args = { ...validArgs, initialEditorSpaceIds: [] };
|
|
116
167
|
expect(() => getCreateDaoSpaceCalldata(args)).toThrow('At least one initial editor space ID is required');
|
|
@@ -118,14 +169,14 @@ describe('getCreateDaoSpaceCalldata', () => {
|
|
|
118
169
|
it('should throw if voting settings are invalid', () => {
|
|
119
170
|
const args = {
|
|
120
171
|
...validArgs,
|
|
121
|
-
votingSettings: { ...validArgs.votingSettings,
|
|
172
|
+
votingSettings: { ...validArgs.votingSettings, partialPercentageSupportThreshold: 150 },
|
|
122
173
|
};
|
|
123
|
-
expect(() => getCreateDaoSpaceCalldata(args)).toThrow('
|
|
174
|
+
expect(() => getCreateDaoSpaceCalldata(args)).toThrow('partialPercentageSupportThreshold must be between 0 and 100');
|
|
124
175
|
});
|
|
125
176
|
it('should throw if duration is below minimum', () => {
|
|
126
177
|
const args = {
|
|
127
178
|
...validArgs,
|
|
128
|
-
votingSettings: { ...validArgs.votingSettings, durationInDays:
|
|
179
|
+
votingSettings: { ...validArgs.votingSettings, durationInDays: MINIMUM_VOTING_DURATION_DAYS / 2 },
|
|
129
180
|
};
|
|
130
181
|
expect(() => getCreateDaoSpaceCalldata(args)).toThrow(`durationInDays must be at least ${MINIMUM_VOTING_DURATION_DAYS} days`);
|
|
131
182
|
});
|
|
@@ -155,6 +206,12 @@ describe('getCreateDaoSpaceCalldata', () => {
|
|
|
155
206
|
// Calldata with URI should be longer than without
|
|
156
207
|
const calldataWithoutUri = getCreateDaoSpaceCalldata(validArgs);
|
|
157
208
|
expect(calldata.length).toBeGreaterThan(calldataWithoutUri.length);
|
|
209
|
+
const decoded = decodeFunctionData({
|
|
210
|
+
abi: DaoSpaceFactoryAbi,
|
|
211
|
+
data: calldata,
|
|
212
|
+
});
|
|
213
|
+
expect(hexToString(decoded.args[3])).toBe(args.initialEditsContentUri);
|
|
214
|
+
expect(decoded.args[4]).toBe('0x');
|
|
158
215
|
});
|
|
159
216
|
it('should generate different calldata for different URIs', () => {
|
|
160
217
|
const calldata1 = getCreateDaoSpaceCalldata({
|
|
@@ -167,6 +224,16 @@ describe('getCreateDaoSpaceCalldata', () => {
|
|
|
167
224
|
});
|
|
168
225
|
expect(calldata1).not.toBe(calldata2);
|
|
169
226
|
});
|
|
227
|
+
it('should provide conservative v2 default voting settings', () => {
|
|
228
|
+
const result = toContractVotingSettings(DEFAULT_VOTING_SETTINGS);
|
|
229
|
+
expect(result.partialPercentageSupportThreshold).toBe(percentageToRatio(50));
|
|
230
|
+
expect(result.universalPercentageSupportThreshold).toBe(percentageToRatio(90));
|
|
231
|
+
expect(result.flatSupportThreshold).toBe(1n);
|
|
232
|
+
expect(result.quorum).toBe(1n);
|
|
233
|
+
expect(result.duration).toBe(daysToSeconds(2));
|
|
234
|
+
expect(result.disableFastPathAccessForNewMembers).toBe(true);
|
|
235
|
+
expect(result.executionGracePeriod).toBeGreaterThan(MINIMUM_EXECUTION_GRACE_PERIOD);
|
|
236
|
+
});
|
|
170
237
|
it('should throw for invalid IPFS URI', () => {
|
|
171
238
|
const args = {
|
|
172
239
|
...validArgs,
|