@akita-protocol/algomd-core 1.0.0-alpha.0 → 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -38,6 +38,7 @@ __export(src_exports, {
38
38
  CONTRACT_SCHEMAS: () => CONTRACT_SCHEMAS,
39
39
  DEFAULT_IPFS_GATEWAY: () => DEFAULT_IPFS_GATEWAY,
40
40
  FAMILIES: () => FAMILIES,
41
+ GUILD_ZERO_ADDRESS: () => GUILD_ZERO_ADDRESS,
41
42
  HttpError: () => HttpError,
42
43
  INTERFACE_NAMESPACE: () => INTERFACE_NAMESPACE,
43
44
  KindRegistry: () => KindRegistry,
@@ -72,9 +73,13 @@ __export(src_exports, {
72
73
  formatAlgo: () => formatAlgo,
73
74
  formatAmount: () => formatAmount,
74
75
  formatDuration: () => formatDuration,
76
+ formatGuildPercent: () => formatGuildPercent,
75
77
  formatRelativeTime: () => formatRelativeTime,
76
78
  fromBase64: () => fromBase64,
77
79
  fromHex: () => fromHex,
80
+ guildBallotOutcome: () => guildBallotOutcome,
81
+ guildProposalStatusLabel: () => guildProposalStatusLabel,
82
+ guildRequirementsText: () => guildRequirementsText,
78
83
  hasRefs: () => hasRefs,
79
84
  interfaceAction: () => interfaceAction,
80
85
  interfaceCards: () => interfaceCards,
@@ -91,6 +96,7 @@ __export(src_exports, {
91
96
  parseProps: () => parseProps,
92
97
  policyFor: () => policyFor,
93
98
  readBox: () => readBox,
99
+ readGuildProposal: () => readGuildProposal,
94
100
  readInterfacePointer: () => readInterfacePointer,
95
101
  readReward: () => readReward,
96
102
  readStakingPool: () => readStakingPool,
@@ -109,9 +115,11 @@ __export(src_exports, {
109
115
  serializeRef: () => serializeRef,
110
116
  shortAddress: () => shortAddress,
111
117
  sizeFromProps: () => sizeFromProps,
118
+ splitGuildProposalId: () => splitGuildProposalId,
112
119
  splitSubscriptionId: () => splitSubscriptionId,
113
120
  stakingPoolFromDecoded: () => stakingPoolFromDecoded,
114
121
  stateFromTeal: () => stateFromTeal,
122
+ summarizeGuildActions: () => summarizeGuildActions,
115
123
  toBase64: () => toBase64,
116
124
  toHex: () => toHex,
117
125
  utf8: () => utf8,
@@ -321,6 +329,21 @@ var BUILT_IN_KINDS = [
321
329
  return i < 0 ? { id, params: {} } : { id: id.slice(i + 1), params: { owner: id.slice(0, i) } };
322
330
  }
323
331
  },
332
+ // A Guild proposal. Proposal ids count per Guild, so the cache id is `<guildAppId>/<proposalId>`.
333
+ {
334
+ kind: "guild-proposal",
335
+ tags: ["GuildProposal"],
336
+ idProps: ["proposalId", "id"],
337
+ params: ["appId"],
338
+ policy: "live",
339
+ sources: ["algod"],
340
+ normalizeId: (id) => /^(\d+\/)?\d+$/.test(id.trim()) ? id.trim() : void 0,
341
+ composeId: (id, params) => params.appId && !id.includes("/") ? `${params.appId}/${id}` : id,
342
+ decomposeId: (id) => {
343
+ const i = id.indexOf("/");
344
+ return i < 0 ? { id, params: {} } : { id: id.slice(i + 1), params: { appId: id.slice(0, i) } };
345
+ }
346
+ },
324
347
  // Title is the author's own label in their post, not chain data.
325
348
  hosted("private-content", "PrivateContent", ["id"], "slow", { params: ["title"] }),
326
349
  // A page inside the same post. The host supplies its preview and navigation.
@@ -7856,226 +7879,1648 @@ var CONTRACT_SCHEMAS = {
7856
7879
  }
7857
7880
  ]
7858
7881
  }
7859
- }
7860
- };
7861
-
7862
- // src/contracts/decode.ts
7863
- function structTuple(name, structs) {
7864
- const fields = structs[name];
7865
- if (!fields) return void 0;
7866
- return `(${fields.map((f) => structTuple(f.type, structs) ?? f.type).join(",")})`;
7867
- }
7868
- function normalize(value, typeName, structs) {
7869
- const fields = structs[typeName];
7870
- if (fields && Array.isArray(value)) {
7871
- const out = {};
7872
- fields.forEach((f, i) => {
7873
- out[f.name] = normalize(value[i], f.type, structs);
7874
- });
7875
- return out;
7876
- }
7877
- if (/^byte\[\d*\]$/.test(typeName) && (Array.isArray(value) || value instanceof Uint8Array)) {
7878
- return toHex(Uint8Array.from(value, (b) => Number(b)));
7879
- }
7880
- if (typeof value === "bigint" || typeof value === "number") return value.toString();
7881
- if (typeof value === "string" || typeof value === "boolean") return value;
7882
- if (value instanceof Uint8Array) return toHex(value);
7883
- if (Array.isArray(value)) return value.map((v) => normalize(v, "", structs));
7884
- if (value && typeof value === "object" && "toString" in value) return String(value);
7885
- return null;
7886
- }
7887
- function decodeValue(type, raw, structs) {
7888
- if (type === "AVMUint64") return (raw.uint ?? (raw.bytes ? bytesToBigInt(raw.bytes) : 0n)).toString();
7889
- const bytes = raw.bytes ?? new Uint8Array();
7890
- if (type === "AVMString") return utf8(bytes);
7891
- if (type === "AVMBytes") return toHex(bytes);
7892
- if (type === "address") return bytes.length === 32 ? import_algosdk.default.encodeAddress(bytes) : toHex(bytes);
7893
- const abi = structTuple(type, structs) ?? type;
7894
- try {
7895
- return normalize(import_algosdk.default.ABIType.from(abi).decode(bytes), type, structs);
7896
- } catch {
7897
- return toHex(bytes);
7898
- }
7899
- }
7900
- function decodeGlobalState(contract2, state) {
7901
- const schema = CONTRACT_SCHEMAS[contract2];
7902
- const structs = schema.structs;
7903
- const out = {};
7904
- for (const [field2, def] of Object.entries(schema.global)) {
7905
- const raw = state.get(def.key);
7906
- if (raw) out[field2] = decodeValue(def.type, raw, structs);
7907
- }
7908
- return out;
7909
- }
7910
- function methodForSelector(contract2, selectorHex) {
7911
- for (const [name, m] of Object.entries(CONTRACT_SCHEMAS[contract2].methods)) {
7912
- if (m.selector === selectorHex) return name;
7913
- }
7914
- return void 0;
7915
- }
7916
- function decodeArgs(contract2, method, args) {
7917
- const m = CONTRACT_SCHEMAS[contract2].methods[method];
7918
- if (!m) return [];
7919
- const structs = CONTRACT_SCHEMAS[contract2].structs;
7920
- const txnTypes = /* @__PURE__ */ new Set(["txn", "pay", "keyreg", "acfg", "axfer", "afrz", "appl"]);
7921
- const out = [];
7922
- let i = 1;
7923
- for (const a of m.args) {
7924
- if (txnTypes.has(a.type)) continue;
7925
- const bytes = args[i++];
7926
- if (!bytes) break;
7927
- try {
7928
- out.push(normalize(import_algosdk.default.ABIType.from(a.type).decode(bytes), a.struct ?? a.type, structs));
7929
- } catch {
7930
- out.push(toHex(bytes));
7931
- }
7932
- }
7933
- return out;
7934
- }
7935
- function decodeEvents(contract2, logs) {
7936
- const events = CONTRACT_SCHEMAS[contract2].events ?? {};
7937
- const bySelector = new Map(Object.entries(events).map(([name, e]) => [e.selector, { name, args: e.args }]));
7938
- const out = [];
7939
- for (const log of logs) {
7940
- const bytes = fromBase64(log);
7941
- if (bytes.length < 4) continue;
7942
- const event = bySelector.get(toHex(bytes.subarray(0, 4)));
7943
- if (!event) continue;
7944
- try {
7945
- const values = import_algosdk.default.ABIType.from(`(${event.args.map((a) => a.type).join(",")})`).decode(bytes.subarray(4));
7946
- const fields = {};
7947
- event.args.forEach((a, i) => {
7948
- fields[a.name] = normalize(values[i], a.type, {});
7949
- });
7950
- out.push({ name: event.name, fields });
7951
- } catch {
7952
- }
7953
- }
7954
- return out;
7955
- }
7956
- function boxDef(contract2, map) {
7957
- const def = CONTRACT_SCHEMAS[contract2].boxes?.[map];
7958
- if (!def) throw new Error(`${contract2} has no box map ${map}`);
7959
- return def;
7960
- }
7961
- function abiTypeFor(type, structs) {
7962
- return structTuple(type, structs) ?? (type === "AVMBytes" ? "byte[]" : type === "AVMString" ? "string" : type === "AVMUint64" ? "uint64" : type);
7963
- }
7964
- function boxName(contract2, map, key) {
7965
- const def = boxDef(contract2, map);
7966
- const structs = CONTRACT_SCHEMAS[contract2].structs;
7967
- const prefix = Uint8Array.from(def.prefix, (c) => c.charCodeAt(0));
7968
- const encoded = import_algosdk.default.ABIType.from(abiTypeFor(def.keyType, structs)).encode(key);
7969
- const out = new Uint8Array(prefix.length + encoded.length);
7970
- out.set(prefix);
7971
- out.set(encoded, prefix.length);
7972
- return out;
7973
- }
7974
- function boxPrefix(contract2, map) {
7975
- return Uint8Array.from(boxDef(contract2, map).prefix, (c) => c.charCodeAt(0));
7976
- }
7977
- function decodeBoxValue(contract2, map, bytes) {
7978
- const def = boxDef(contract2, map);
7979
- return decodeValue(def.valueType, { bytes }, CONTRACT_SCHEMAS[contract2].structs);
7980
- }
7981
- function decodeBoxKey(contract2, map, name) {
7982
- const def = boxDef(contract2, map);
7983
- const structs = CONTRACT_SCHEMAS[contract2].structs;
7984
- return normalize(import_algosdk.default.ABIType.from(abiTypeFor(def.keyType, structs)).decode(name.subarray(def.prefix.length)), def.keyType, structs);
7985
- }
7986
-
7987
- // src/media.ts
7988
- var import_algosdk2 = __toESM(require("algosdk"), 1);
7989
- var import_js_sha256 = require("js-sha256");
7990
- var DEFAULT_IPFS_GATEWAY = "https://ipfs.akita.community/ipfs/";
7991
- var MULTICODEC = { raw: 85, "dag-pb": 112 };
7992
- var MULTIHASH = { "sha2-256": 18 };
7993
- var B32 = "abcdefghijklmnopqrstuvwxyz234567";
7994
- function base32Lower(bytes) {
7995
- let out = "";
7996
- let buffer = 0;
7997
- let bits = 0;
7998
- for (const b of bytes) {
7999
- buffer = buffer << 8 | b;
8000
- bits += 8;
8001
- while (bits >= 5) {
8002
- out += B32[buffer >>> bits - 5 & 31];
8003
- bits -= 5;
8004
- }
8005
- }
8006
- if (bits > 0) out += B32[buffer << 5 - bits & 31];
8007
- return out;
8008
- }
8009
- function resolveArc19(template, reserve) {
8010
- const m = template.match(/^template-ipfs:\/\/\{ipfscid:(\d+):([^:]+):([^:]+):([^}]+)\}(.*)$/);
8011
- if (!m || m[3] !== "reserve" || !reserve || m[1] !== "1") return void 0;
8012
- const codec = MULTICODEC[m[2]];
8013
- const hash = MULTIHASH[m[4]];
8014
- if (codec === void 0 || hash === void 0) return void 0;
8015
- const key = import_algosdk2.default.decodeAddress(reserve).publicKey;
8016
- const cid = new Uint8Array(4 + key.length);
8017
- cid.set([1, codec, hash, 32]);
8018
- cid.set(key, 4);
8019
- return `ipfs://b${base32Lower(cid)}${m[5] ?? ""}`;
8020
- }
8021
- function ipfsToGateway(url, gateway = DEFAULT_IPFS_GATEWAY) {
8022
- return url.startsWith("ipfs://") ? `${gateway.replace(/\/?$/, "/")}${url.slice("ipfs://".length)}` : url;
8023
- }
8024
- var isArc3 = (asset) => Boolean(asset.url?.endsWith("#arc3") || asset.name?.endsWith("@arc3") || asset.url?.split("#")[0].endsWith(".json"));
8025
- async function fetchBytes(fetchFn, url, timeoutMs = 1e4) {
8026
- const controller = new AbortController();
8027
- const timer = setTimeout(() => controller.abort(), timeoutMs);
8028
- try {
8029
- const res = await fetchFn(url, { signal: controller.signal });
8030
- if (!res.ok) return void 0;
8031
- return new Uint8Array(await res.arrayBuffer());
8032
- } catch {
8033
- return void 0;
8034
- } finally {
8035
- clearTimeout(timer);
8036
- }
8037
- }
8038
- function mediaFromJson(json, base) {
8039
- const rel = (v) => {
8040
- if (typeof v !== "string" || !v) return void 0;
8041
- return /^[a-z][a-z0-9+.-]*:/i.test(v) ? v : `${base.replace(/[^/]*$/, "")}${v}`;
8042
- };
8043
- return {
8044
- image: rel(json.image ?? json.media_url ?? json.image_url),
8045
- animation: rel(json.animation_url),
8046
- mimeType: typeof json.image_mimetype === "string" ? json.image_mimetype : typeof json.mime_type === "string" ? json.mime_type : void 0,
8047
- description: typeof json.description === "string" ? json.description : void 0
8048
- };
8049
- }
8050
- function createMediaSource(loadAsset, options = {}) {
8051
- const gateway = options.ipfsGateway ?? DEFAULT_IPFS_GATEWAY;
8052
- return {
8053
- name: "media",
8054
- maxBatch: 1,
8055
- concurrency: 6,
8056
- supports: (kind) => kind === "asset-media",
8057
- async fetch(refs, ctx) {
8058
- const out = /* @__PURE__ */ new Map();
8059
- const ref = refs[0];
8060
- if (!ref) return out;
8061
- const asset = (await loadAsset(ref.id))?.data;
8062
- const now = Date.now();
8063
- const done = (data) => out.set(refKey(ref), { kind: "asset-media", id: ref.id, network: ctx.network, status: "live", data, provenance: { source: "media", fetchedAt: now } });
8064
- if (!asset) return out;
8065
- if (asset.imageUrl) return done({ assetId: ref.id, image: asset.imageUrl, standard: "resolver" }), out;
8066
- let url = asset.url ?? "";
8067
- let standard = "url";
8068
- if (url.startsWith("template-ipfs://")) {
8069
- url = resolveArc19(url, asset.reserve) ?? "";
8070
- standard = "arc19";
7882
+ },
7883
+ "guild": {
7884
+ "name": "Guild",
7885
+ "global": {
7886
+ "state": {
7887
+ "key": "state",
7888
+ "type": "uint8"
7889
+ },
7890
+ "consensus": {
7891
+ "key": "consensus",
7892
+ "type": "AVMUint64"
7893
+ },
7894
+ "version": {
7895
+ "key": "version",
7896
+ "type": "AVMString"
7897
+ },
7898
+ "creator": {
7899
+ "key": "creator",
7900
+ "type": "address"
7901
+ },
7902
+ "wallet": {
7903
+ "key": "wallet",
7904
+ "type": "AVMUint64"
7905
+ },
7906
+ "walletFactory": {
7907
+ "key": "wallet_factory",
7908
+ "type": "AVMUint64"
7909
+ },
7910
+ "proposalActionLimit": {
7911
+ "key": "proposal_action_limit",
7912
+ "type": "AVMUint64"
7913
+ },
7914
+ "proposalID": {
7915
+ "key": "proposal_id",
7916
+ "type": "AVMUint64"
7917
+ },
7918
+ "pluginSetLocked": {
7919
+ "key": "plugins_locked",
7920
+ "type": "AVMUint64"
7921
+ },
7922
+ "reserved": {
7923
+ "key": "reserved",
7924
+ "type": "AVMUint64"
7925
+ },
7926
+ "upgradeAppProposalSettings": {
7927
+ "key": "upgrade_app_ps",
7928
+ "type": "GuildProposalSettings"
7929
+ },
7930
+ "addPluginProposalSettings": {
7931
+ "key": "add_plugin_ps",
7932
+ "type": "GuildProposalSettings"
7933
+ },
7934
+ "removeExecutionProposalSettings": {
7935
+ "key": "remove_execution_ps",
7936
+ "type": "GuildProposalSettings"
7937
+ },
7938
+ "removePluginProposalSettings": {
7939
+ "key": "remove_plugin_ps",
7940
+ "type": "GuildProposalSettings"
7941
+ },
7942
+ "addAllowancesProposalSettings": {
7943
+ "key": "add_allowances_ps",
7944
+ "type": "GuildProposalSettings"
7945
+ },
7946
+ "removeAllowancesProposalSettings": {
7947
+ "key": "remove_allowances_ps",
7948
+ "type": "GuildProposalSettings"
7949
+ },
7950
+ "newEscrowProposalSettings": {
7951
+ "key": "new_escrow_ps",
7952
+ "type": "GuildProposalSettings"
7953
+ },
7954
+ "toggleEscrowLockProposalSettings": {
7955
+ "key": "toggle_escrow_ps",
7956
+ "type": "GuildProposalSettings"
7957
+ },
7958
+ "updateGuildProposalSettings": {
7959
+ "key": "update_guild_ps",
7960
+ "type": "GuildProposalSettings"
8071
7961
  }
8072
- if (url && (isArc3(asset) || url.split("#")[0].endsWith(".json") || standard === "arc19")) {
8073
- const metaUrl = url.split("#")[0];
8074
- const bytes = await fetchBytes(ctx.fetch, ipfsToGateway(metaUrl, gateway));
8075
- const json = bytes ? safeJson(utf8(bytes)) : void 0;
8076
- if (json) {
8077
- const hash = asset.metadataHash ? toHex(fromBase64(asset.metadataHash)) : void 0;
8078
- return done({
7962
+ },
7963
+ "boxes": {
7964
+ "plugins": {
7965
+ "prefix": "g",
7966
+ "keyType": "GuildPluginKey",
7967
+ "valueType": "GuildProposalSettings"
7968
+ },
7969
+ "proposals": {
7970
+ "prefix": "l",
7971
+ "keyType": "uint64",
7972
+ "valueType": "GuildProposal"
7973
+ },
7974
+ "executions": {
7975
+ "prefix": "x",
7976
+ "keyType": "AVMBytes",
7977
+ "valueType": "GuildExecutionMetadata"
7978
+ },
7979
+ "consensusActions": {
7980
+ "prefix": "c",
7981
+ "keyType": "uint64",
7982
+ "valueType": "GuildProposalSettings"
7983
+ }
7984
+ },
7985
+ "methods": {
7986
+ "create": {
7987
+ "signature": "create(string,address,uint64,uint64,(uint64,((uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64))))void",
7988
+ "selector": "06cb2e54",
7989
+ "args": [
7990
+ {
7991
+ "name": "version",
7992
+ "type": "string"
7993
+ },
7994
+ {
7995
+ "name": "creator",
7996
+ "type": "address"
7997
+ },
7998
+ {
7999
+ "name": "walletFactory",
8000
+ "type": "uint64"
8001
+ },
8002
+ {
8003
+ "name": "consensus",
8004
+ "type": "uint64"
8005
+ },
8006
+ {
8007
+ "name": "config",
8008
+ "type": "(uint64,((uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64),(uint64,uint64,uint64,uint64,uint64,uint64)))",
8009
+ "struct": "GuildBaseConfig"
8010
+ }
8011
+ ],
8012
+ "returns": "void",
8013
+ "actions": [
8014
+ "create:NoOp"
8015
+ ]
8016
+ },
8017
+ "consensusConfigurationMbr": {
8018
+ "signature": "consensusConfigurationMbr(byte[])uint64",
8019
+ "selector": "97881e21",
8020
+ "args": [
8021
+ {
8022
+ "name": "config",
8023
+ "type": "byte[]"
8024
+ }
8025
+ ],
8026
+ "returns": "uint64",
8027
+ "actions": [
8028
+ "NoOp"
8029
+ ]
8030
+ },
8031
+ "configureConsensus": {
8032
+ "signature": "configureConsensus(pay,byte[])void",
8033
+ "selector": "5081f793",
8034
+ "args": [
8035
+ {
8036
+ "name": "mbrPayment",
8037
+ "type": "pay"
8038
+ },
8039
+ {
8040
+ "name": "config",
8041
+ "type": "byte[]"
8042
+ }
8043
+ ],
8044
+ "returns": "void",
8045
+ "actions": [
8046
+ "NoOp"
8047
+ ]
8048
+ },
8049
+ "setup": {
8050
+ "signature": "setup(string,byte[32])uint64",
8051
+ "selector": "f8e140aa",
8052
+ "args": [
8053
+ {
8054
+ "name": "nickname",
8055
+ "type": "string"
8056
+ },
8057
+ {
8058
+ "name": "salt",
8059
+ "type": "byte[32]"
8060
+ }
8061
+ ],
8062
+ "returns": "uint64",
8063
+ "actions": [
8064
+ "NoOp"
8065
+ ]
8066
+ },
8067
+ "setProposalSettings": {
8068
+ "signature": "setProposalSettings(uint8,(uint64,uint64,uint64,uint64,uint64,uint64))void",
8069
+ "selector": "ce73147b",
8070
+ "args": [
8071
+ {
8072
+ "name": "actionType",
8073
+ "type": "uint8"
8074
+ },
8075
+ {
8076
+ "name": "settings",
8077
+ "type": "(uint64,uint64,uint64,uint64,uint64,uint64)",
8078
+ "struct": "GuildProposalSettings"
8079
+ }
8080
+ ],
8081
+ "returns": "void",
8082
+ "actions": [
8083
+ "NoOp"
8084
+ ]
8085
+ },
8086
+ "setConsensusActionSettings": {
8087
+ "signature": "setConsensusActionSettings(uint64,(uint64,uint64,uint64,uint64,uint64,uint64))void",
8088
+ "selector": "236cb1bb",
8089
+ "args": [
8090
+ {
8091
+ "name": "code",
8092
+ "type": "uint64"
8093
+ },
8094
+ {
8095
+ "name": "settings",
8096
+ "type": "(uint64,uint64,uint64,uint64,uint64,uint64)",
8097
+ "struct": "GuildProposalSettings"
8098
+ }
8099
+ ],
8100
+ "returns": "void",
8101
+ "actions": [
8102
+ "NoOp"
8103
+ ]
8104
+ },
8105
+ "setProposalActionLimit": {
8106
+ "signature": "setProposalActionLimit(uint64)void",
8107
+ "selector": "78b643e8",
8108
+ "args": [
8109
+ {
8110
+ "name": "limit",
8111
+ "type": "uint64"
8112
+ }
8113
+ ],
8114
+ "returns": "void",
8115
+ "actions": [
8116
+ "NoOp"
8117
+ ]
8118
+ },
8119
+ "lockPluginSet": {
8120
+ "signature": "lockPluginSet()void",
8121
+ "selector": "40988cb9",
8122
+ "args": [],
8123
+ "returns": "void",
8124
+ "actions": [
8125
+ "NoOp"
8126
+ ]
8127
+ },
8128
+ "partiallyInitialize": {
8129
+ "signature": "partiallyInitialize()void",
8130
+ "selector": "53c47566",
8131
+ "args": [],
8132
+ "returns": "void",
8133
+ "actions": [
8134
+ "NoOp"
8135
+ ]
8136
+ },
8137
+ "initialize": {
8138
+ "signature": "initialize()void",
8139
+ "selector": "fd2c93cd",
8140
+ "args": [],
8141
+ "returns": "void",
8142
+ "actions": [
8143
+ "NoOp"
8144
+ ]
8145
+ },
8146
+ "newProposal": {
8147
+ "signature": "newProposal(pay,byte[36],(uint8,byte[])[],byte[])uint64",
8148
+ "selector": "3495781a",
8149
+ "args": [
8150
+ {
8151
+ "name": "payment",
8152
+ "type": "pay"
8153
+ },
8154
+ {
8155
+ "name": "cid",
8156
+ "type": "byte[36]"
8157
+ },
8158
+ {
8159
+ "name": "actions",
8160
+ "type": "(uint8,byte[])[]"
8161
+ },
8162
+ {
8163
+ "name": "evidence",
8164
+ "type": "byte[]"
8165
+ }
8166
+ ],
8167
+ "returns": "uint64",
8168
+ "actions": [
8169
+ "NoOp"
8170
+ ]
8171
+ },
8172
+ "editProposal": {
8173
+ "signature": "editProposal(uint64,byte[36],(uint8,byte[])[],byte[])void",
8174
+ "selector": "d046fb71",
8175
+ "args": [
8176
+ {
8177
+ "name": "id",
8178
+ "type": "uint64"
8179
+ },
8180
+ {
8181
+ "name": "cid",
8182
+ "type": "byte[36]"
8183
+ },
8184
+ {
8185
+ "name": "actions",
8186
+ "type": "(uint8,byte[])[]"
8187
+ },
8188
+ {
8189
+ "name": "evidence",
8190
+ "type": "byte[]"
8191
+ }
8192
+ ],
8193
+ "returns": "void",
8194
+ "actions": [
8195
+ "NoOp"
8196
+ ]
8197
+ },
8198
+ "editProposalWithPayment": {
8199
+ "signature": "editProposalWithPayment(pay,uint64,byte[36],(uint8,byte[])[],byte[])void",
8200
+ "selector": "880950f9",
8201
+ "args": [
8202
+ {
8203
+ "name": "payment",
8204
+ "type": "pay"
8205
+ },
8206
+ {
8207
+ "name": "id",
8208
+ "type": "uint64"
8209
+ },
8210
+ {
8211
+ "name": "cid",
8212
+ "type": "byte[36]"
8213
+ },
8214
+ {
8215
+ "name": "actions",
8216
+ "type": "(uint8,byte[])[]"
8217
+ },
8218
+ {
8219
+ "name": "evidence",
8220
+ "type": "byte[]"
8221
+ }
8222
+ ],
8223
+ "returns": "void",
8224
+ "actions": [
8225
+ "NoOp"
8226
+ ]
8227
+ },
8228
+ "deleteProposal": {
8229
+ "signature": "deleteProposal(uint64)void",
8230
+ "selector": "28f80154",
8231
+ "args": [
8232
+ {
8233
+ "name": "proposalID",
8234
+ "type": "uint64"
8235
+ }
8236
+ ],
8237
+ "returns": "void",
8238
+ "actions": [
8239
+ "NoOp"
8240
+ ]
8241
+ },
8242
+ "submitProposal": {
8243
+ "signature": "submitProposal(uint64,byte[])void",
8244
+ "selector": "a9e1f57b",
8245
+ "args": [
8246
+ {
8247
+ "name": "proposalID",
8248
+ "type": "uint64"
8249
+ },
8250
+ {
8251
+ "name": "evidence",
8252
+ "type": "byte[]"
8253
+ }
8254
+ ],
8255
+ "returns": "void",
8256
+ "actions": [
8257
+ "NoOp"
8258
+ ]
8259
+ },
8260
+ "voteProposal": {
8261
+ "signature": "voteProposal(pay,uint64,uint8,byte[])void",
8262
+ "selector": "3769989f",
8263
+ "args": [
8264
+ {
8265
+ "name": "mbrPayment",
8266
+ "type": "pay"
8267
+ },
8268
+ {
8269
+ "name": "proposalID",
8270
+ "type": "uint64"
8271
+ },
8272
+ {
8273
+ "name": "vote",
8274
+ "type": "uint8"
8275
+ },
8276
+ {
8277
+ "name": "evidence",
8278
+ "type": "byte[]"
8279
+ }
8280
+ ],
8281
+ "returns": "void",
8282
+ "actions": [
8283
+ "NoOp"
8284
+ ]
8285
+ },
8286
+ "finalizeProposal": {
8287
+ "signature": "finalizeProposal(uint64)void",
8288
+ "selector": "62ce9b5b",
8289
+ "args": [
8290
+ {
8291
+ "name": "proposalID",
8292
+ "type": "uint64"
8293
+ }
8294
+ ],
8295
+ "returns": "void",
8296
+ "actions": [
8297
+ "NoOp"
8298
+ ]
8299
+ },
8300
+ "cleanupProposalConsensus": {
8301
+ "signature": "cleanupProposalConsensus(uint64,address[])uint64",
8302
+ "selector": "b57a1ecd",
8303
+ "args": [
8304
+ {
8305
+ "name": "proposalID",
8306
+ "type": "uint64"
8307
+ },
8308
+ {
8309
+ "name": "voters",
8310
+ "type": "address[]"
8311
+ }
8312
+ ],
8313
+ "returns": "uint64",
8314
+ "actions": [
8315
+ "NoOp"
8316
+ ]
8317
+ },
8318
+ "cancelProposal": {
8319
+ "signature": "cancelProposal(uint64)void",
8320
+ "selector": "bfb5248f",
8321
+ "args": [
8322
+ {
8323
+ "name": "proposalID",
8324
+ "type": "uint64"
8325
+ }
8326
+ ],
8327
+ "returns": "void",
8328
+ "actions": [
8329
+ "NoOp"
8330
+ ]
8331
+ },
8332
+ "executeProposal": {
8333
+ "signature": "executeProposal(uint64)void",
8334
+ "selector": "f1ff28aa",
8335
+ "args": [
8336
+ {
8337
+ "name": "proposalID",
8338
+ "type": "uint64"
8339
+ }
8340
+ ],
8341
+ "returns": "void",
8342
+ "actions": [
8343
+ "NoOp"
8344
+ ]
8345
+ },
8346
+ "update": {
8347
+ "signature": "update(string)void",
8348
+ "selector": "ea9180dd",
8349
+ "args": [
8350
+ {
8351
+ "name": "newVersion",
8352
+ "type": "string"
8353
+ }
8354
+ ],
8355
+ "returns": "void",
8356
+ "actions": [
8357
+ "UpdateApplication"
8358
+ ]
8359
+ },
8360
+ "sweep": {
8361
+ "signature": "sweep()uint64",
8362
+ "selector": "bc0d58a7",
8363
+ "args": [],
8364
+ "returns": "uint64",
8365
+ "actions": [
8366
+ "NoOp"
8367
+ ]
8368
+ },
8369
+ "setupCost": {
8370
+ "signature": "setupCost()uint64",
8371
+ "selector": "9699d108",
8372
+ "args": [],
8373
+ "returns": "uint64",
8374
+ "actions": [
8375
+ "NoOp"
8376
+ ]
8377
+ },
8378
+ "proposalCost": {
8379
+ "signature": "proposalCost((uint8,byte[])[])(uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64)",
8380
+ "selector": "8feadadb",
8381
+ "args": [
8382
+ {
8383
+ "name": "actions",
8384
+ "type": "(uint8,byte[])[]"
8385
+ }
8386
+ ],
8387
+ "returns": "(uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64)",
8388
+ "actions": [
8389
+ "NoOp"
8390
+ ]
8391
+ },
8392
+ "getProposal": {
8393
+ "signature": "getProposal(uint64)(uint8,byte[36],address,uint64,uint64,uint64,(uint8,byte[])[])",
8394
+ "selector": "fe0227c9",
8395
+ "args": [
8396
+ {
8397
+ "name": "proposalID",
8398
+ "type": "uint64"
8399
+ }
8400
+ ],
8401
+ "returns": "(uint8,byte[36],address,uint64,uint64,uint64,(uint8,byte[])[])",
8402
+ "actions": [
8403
+ "NoOp"
8404
+ ]
8405
+ },
8406
+ "getBallot": {
8407
+ "signature": "getBallot(uint64)(bool,bool,uint64,uint64,uint64,(uint64,uint64,uint64),(uint64,uint64,uint64))",
8408
+ "selector": "92bb769e",
8409
+ "args": [
8410
+ {
8411
+ "name": "proposalID",
8412
+ "type": "uint64"
8413
+ }
8414
+ ],
8415
+ "returns": "(bool,bool,uint64,uint64,uint64,(uint64,uint64,uint64),(uint64,uint64,uint64))",
8416
+ "actions": [
8417
+ "NoOp"
8418
+ ]
8419
+ },
8420
+ "mustGetExecution": {
8421
+ "signature": "mustGetExecution(byte[32])(uint64,uint64)",
8422
+ "selector": "dbbec6d2",
8423
+ "args": [
8424
+ {
8425
+ "name": "lease",
8426
+ "type": "byte[32]"
8427
+ }
8428
+ ],
8429
+ "returns": "(uint64,uint64)",
8430
+ "actions": [
8431
+ "NoOp"
8432
+ ]
8433
+ },
8434
+ "getConsensusActionSettings": {
8435
+ "signature": "getConsensusActionSettings(uint64)(uint64,uint64,uint64,uint64,uint64,uint64)",
8436
+ "selector": "957c752e",
8437
+ "args": [
8438
+ {
8439
+ "name": "code",
8440
+ "type": "uint64"
8441
+ }
8442
+ ],
8443
+ "returns": "(uint64,uint64,uint64,uint64,uint64,uint64)",
8444
+ "actions": [
8445
+ "NoOp"
8446
+ ]
8447
+ },
8448
+ "voteCost": {
8449
+ "signature": "voteCost(uint64,address)uint64",
8450
+ "selector": "8b5f86e0",
8451
+ "args": [
8452
+ {
8453
+ "name": "proposalID",
8454
+ "type": "uint64"
8455
+ },
8456
+ {
8457
+ "name": "voter",
8458
+ "type": "address"
8459
+ }
8460
+ ],
8461
+ "returns": "uint64",
8462
+ "actions": [
8463
+ "NoOp"
8464
+ ]
8465
+ },
8466
+ "voteMbr": {
8467
+ "signature": "voteMbr()uint64",
8468
+ "selector": "6f9378e3",
8469
+ "args": [],
8470
+ "returns": "uint64",
8471
+ "actions": [
8472
+ "NoOp"
8473
+ ]
8474
+ },
8475
+ "sweepable": {
8476
+ "signature": "sweepable()uint64",
8477
+ "selector": "f1c08e6a",
8478
+ "args": [],
8479
+ "returns": "uint64",
8480
+ "actions": [
8481
+ "NoOp"
8482
+ ]
8483
+ },
8484
+ "canChangePluginSet": {
8485
+ "signature": "canChangePluginSet()bool",
8486
+ "selector": "27adf91f",
8487
+ "args": [],
8488
+ "returns": "bool",
8489
+ "actions": [
8490
+ "NoOp"
8491
+ ]
8492
+ },
8493
+ "opUp": {
8494
+ "signature": "opUp()void",
8495
+ "selector": "854dede0",
8496
+ "args": [],
8497
+ "returns": "void",
8498
+ "actions": [
8499
+ "NoOp"
8500
+ ]
8501
+ }
8502
+ },
8503
+ "events": {},
8504
+ "structs": {
8505
+ "GuildBaseConfig": [
8506
+ {
8507
+ "name": "proposalActionLimit",
8508
+ "type": "uint64"
8509
+ },
8510
+ {
8511
+ "name": "proposalSettings",
8512
+ "type": "GuildProposalSettingsConfig"
8513
+ }
8514
+ ],
8515
+ "GuildConsensusBallot": [
8516
+ {
8517
+ "name": "resolved",
8518
+ "type": "bool"
8519
+ },
8520
+ {
8521
+ "name": "approved",
8522
+ "type": "bool"
8523
+ },
8524
+ {
8525
+ "name": "votingEnd",
8526
+ "type": "uint64"
8527
+ },
8528
+ {
8529
+ "name": "eligiblePower",
8530
+ "type": "uint64"
8531
+ },
8532
+ {
8533
+ "name": "voteCount",
8534
+ "type": "uint64"
8535
+ },
8536
+ {
8537
+ "name": "requirements",
8538
+ "type": "GuildConsensusRequirements"
8539
+ },
8540
+ {
8541
+ "name": "votes",
8542
+ "type": "GuildVoteTotals"
8543
+ }
8544
+ ],
8545
+ "GuildConsensusRequirements": [
8546
+ {
8547
+ "name": "participation",
8548
+ "type": "uint64"
8549
+ },
8550
+ {
8551
+ "name": "approval",
8552
+ "type": "uint64"
8553
+ },
8554
+ {
8555
+ "name": "minimumApprovals",
8556
+ "type": "uint64"
8557
+ }
8558
+ ],
8559
+ "GuildExecutionMetadata": [
8560
+ {
8561
+ "name": "proposalID",
8562
+ "type": "uint64"
8563
+ },
8564
+ {
8565
+ "name": "index",
8566
+ "type": "uint64"
8567
+ }
8568
+ ],
8569
+ "GuildPluginKey": [
8570
+ {
8571
+ "name": "plugin",
8572
+ "type": "uint64"
8573
+ },
8574
+ {
8575
+ "name": "escrow",
8576
+ "type": "string"
8577
+ }
8578
+ ],
8579
+ "GuildProposal": [
8580
+ {
8581
+ "name": "status",
8582
+ "type": "uint8"
8583
+ },
8584
+ {
8585
+ "name": "cid",
8586
+ "type": "byte[36]"
8587
+ },
8588
+ {
8589
+ "name": "creator",
8590
+ "type": "address"
8591
+ },
8592
+ {
8593
+ "name": "votingTs",
8594
+ "type": "uint64"
8595
+ },
8596
+ {
8597
+ "name": "created",
8598
+ "type": "uint64"
8599
+ },
8600
+ {
8601
+ "name": "feesPaid",
8602
+ "type": "uint64"
8603
+ },
8604
+ {
8605
+ "name": "actions",
8606
+ "type": "(uint8,byte[])[]"
8607
+ }
8608
+ ],
8609
+ "GuildProposalCostInfo": [
8610
+ {
8611
+ "name": "total",
8612
+ "type": "uint64"
8613
+ },
8614
+ {
8615
+ "name": "mbr",
8616
+ "type": "uint64"
8617
+ },
8618
+ {
8619
+ "name": "fee",
8620
+ "type": "uint64"
8621
+ },
8622
+ {
8623
+ "name": "power",
8624
+ "type": "uint64"
8625
+ },
8626
+ {
8627
+ "name": "duration",
8628
+ "type": "uint64"
8629
+ },
8630
+ {
8631
+ "name": "participation",
8632
+ "type": "uint64"
8633
+ },
8634
+ {
8635
+ "name": "approval",
8636
+ "type": "uint64"
8637
+ },
8638
+ {
8639
+ "name": "minimumApprovals",
8640
+ "type": "uint64"
8641
+ }
8642
+ ],
8643
+ "GuildProposalSettings": [
8644
+ {
8645
+ "name": "fee",
8646
+ "type": "uint64"
8647
+ },
8648
+ {
8649
+ "name": "power",
8650
+ "type": "uint64"
8651
+ },
8652
+ {
8653
+ "name": "duration",
8654
+ "type": "uint64"
8655
+ },
8656
+ {
8657
+ "name": "participation",
8658
+ "type": "uint64"
8659
+ },
8660
+ {
8661
+ "name": "approval",
8662
+ "type": "uint64"
8663
+ },
8664
+ {
8665
+ "name": "minimumApprovals",
8666
+ "type": "uint64"
8667
+ }
8668
+ ],
8669
+ "GuildProposalSettingsConfig": [
8670
+ {
8671
+ "name": "upgradeApp",
8672
+ "type": "GuildProposalSettings"
8673
+ },
8674
+ {
8675
+ "name": "addPlugin",
8676
+ "type": "GuildProposalSettings"
8677
+ },
8678
+ {
8679
+ "name": "removeExecution",
8680
+ "type": "GuildProposalSettings"
8681
+ },
8682
+ {
8683
+ "name": "removePlugin",
8684
+ "type": "GuildProposalSettings"
8685
+ },
8686
+ {
8687
+ "name": "addAllowances",
8688
+ "type": "GuildProposalSettings"
8689
+ },
8690
+ {
8691
+ "name": "removeAllowances",
8692
+ "type": "GuildProposalSettings"
8693
+ },
8694
+ {
8695
+ "name": "newEscrow",
8696
+ "type": "GuildProposalSettings"
8697
+ },
8698
+ {
8699
+ "name": "toggleEscrowLock",
8700
+ "type": "GuildProposalSettings"
8701
+ },
8702
+ {
8703
+ "name": "updateGuild",
8704
+ "type": "GuildProposalSettings"
8705
+ }
8706
+ ],
8707
+ "GuildVoteTotals": [
8708
+ {
8709
+ "name": "approvals",
8710
+ "type": "uint64"
8711
+ },
8712
+ {
8713
+ "name": "rejections",
8714
+ "type": "uint64"
8715
+ },
8716
+ {
8717
+ "name": "abstains",
8718
+ "type": "uint64"
8719
+ }
8720
+ ]
8721
+ }
8722
+ },
8723
+ "guildConsensus": {
8724
+ "name": "FixedSignerGuildConsensus",
8725
+ "global": {
8726
+ "threshold": {
8727
+ "key": "signer_threshold",
8728
+ "type": "AVMUint64"
8729
+ },
8730
+ "memberCount": {
8731
+ "key": "member_count",
8732
+ "type": "AVMUint64"
8733
+ },
8734
+ "eligiblePower": {
8735
+ "key": "member_power",
8736
+ "type": "AVMUint64"
8737
+ },
8738
+ "membershipLocked": {
8739
+ "key": "members_locked",
8740
+ "type": "AVMUint64"
8741
+ },
8742
+ "weightMode": {
8743
+ "key": "weight_mode",
8744
+ "type": "uint8"
8745
+ },
8746
+ "membershipEpoch": {
8747
+ "key": "membership_epoch",
8748
+ "type": "AVMUint64"
8749
+ },
8750
+ "maximumMemberWeight": {
8751
+ "key": "maximum_member_weight",
8752
+ "type": "AVMUint64"
8753
+ },
8754
+ "guild": {
8755
+ "key": "guild",
8756
+ "type": "AVMUint64"
8757
+ },
8758
+ "activeBallots": {
8759
+ "key": "active_ballots",
8760
+ "type": "AVMUint64"
8761
+ },
8762
+ "activated": {
8763
+ "key": "activated",
8764
+ "type": "AVMUint64"
8765
+ }
8766
+ },
8767
+ "boxes": {
8768
+ "members": {
8769
+ "prefix": "m",
8770
+ "keyType": "address",
8771
+ "valueType": "Object75E64AB9"
8772
+ },
8773
+ "memberHistory": {
8774
+ "prefix": "h",
8775
+ "keyType": "ObjectA760343E",
8776
+ "valueType": "ObjectA68503ED"
8777
+ },
8778
+ "memberSnapshots": {
8779
+ "prefix": "s",
8780
+ "keyType": "uint64",
8781
+ "valueType": "ObjectEEB10897"
8782
+ },
8783
+ "ballots": {
8784
+ "prefix": "b",
8785
+ "keyType": "uint64",
8786
+ "valueType": "GuildConsensusBallot"
8787
+ },
8788
+ "votes": {
8789
+ "prefix": "v",
8790
+ "keyType": "GuildVoteKey",
8791
+ "valueType": "GuildVote"
8792
+ }
8793
+ },
8794
+ "methods": {
8795
+ "memberAdditionMbr": {
8796
+ "signature": "memberAdditionMbr(uint64)uint64",
8797
+ "selector": "aa927d7b",
8798
+ "args": [
8799
+ {
8800
+ "name": "count",
8801
+ "type": "uint64"
8802
+ }
8803
+ ],
8804
+ "returns": "uint64",
8805
+ "actions": [
8806
+ "NoOp"
8807
+ ]
8808
+ },
8809
+ "historyMbr": {
8810
+ "signature": "historyMbr()uint64",
8811
+ "selector": "db28eb21",
8812
+ "args": [],
8813
+ "returns": "uint64",
8814
+ "actions": [
8815
+ "NoOp"
8816
+ ]
8817
+ },
8818
+ "validateSettings": {
8819
+ "signature": "validateSettings((uint64,uint64,uint64,uint64,uint64,uint64))void",
8820
+ "selector": "9140c638",
8821
+ "args": [
8822
+ {
8823
+ "name": "settings",
8824
+ "type": "(uint64,uint64,uint64,uint64,uint64,uint64)",
8825
+ "struct": "GuildProposalSettings"
8826
+ }
8827
+ ],
8828
+ "returns": "void",
8829
+ "actions": [
8830
+ "NoOp"
8831
+ ]
8832
+ },
8833
+ "ballotMbr": {
8834
+ "signature": "ballotMbr()uint64",
8835
+ "selector": "d3d29643",
8836
+ "args": [],
8837
+ "returns": "uint64",
8838
+ "actions": [
8839
+ "NoOp"
8840
+ ]
8841
+ },
8842
+ "memberPowerAt": {
8843
+ "signature": "memberPowerAt(address,uint64,byte[])uint64",
8844
+ "selector": "f12a468e",
8845
+ "args": [
8846
+ {
8847
+ "name": "account",
8848
+ "type": "address"
8849
+ },
8850
+ {
8851
+ "name": "proposalID",
8852
+ "type": "uint64"
8853
+ },
8854
+ {
8855
+ "name": "evidence",
8856
+ "type": "byte[]"
8857
+ }
8858
+ ],
8859
+ "returns": "uint64",
8860
+ "actions": [
8861
+ "NoOp"
8862
+ ]
8863
+ },
8864
+ "cleanupBallot": {
8865
+ "signature": "cleanupBallot(uint64,address[])uint64",
8866
+ "selector": "a9e823cd",
8867
+ "args": [
8868
+ {
8869
+ "name": "proposalID",
8870
+ "type": "uint64"
8871
+ },
8872
+ {
8873
+ "name": "voters",
8874
+ "type": "address[]"
8875
+ }
8876
+ ],
8877
+ "returns": "uint64",
8878
+ "actions": [
8879
+ "NoOp"
8880
+ ]
8881
+ },
8882
+ "validateActivation": {
8883
+ "signature": "validateActivation()void",
8884
+ "selector": "b9865a61",
8885
+ "args": [],
8886
+ "returns": "void",
8887
+ "actions": [
8888
+ "NoOp"
8889
+ ]
8890
+ },
8891
+ "openProposal": {
8892
+ "signature": "openProposal(pay,uint64,uint64,(uint64,uint64,uint64))void",
8893
+ "selector": "68449088",
8894
+ "args": [
8895
+ {
8896
+ "name": "mbrPayment",
8897
+ "type": "pay"
8898
+ },
8899
+ {
8900
+ "name": "proposalID",
8901
+ "type": "uint64"
8902
+ },
8903
+ {
8904
+ "name": "votingEnd",
8905
+ "type": "uint64"
8906
+ },
8907
+ {
8908
+ "name": "requirements",
8909
+ "type": "(uint64,uint64,uint64)",
8910
+ "struct": "GuildConsensusRequirements"
8911
+ }
8912
+ ],
8913
+ "returns": "void",
8914
+ "actions": [
8915
+ "NoOp"
8916
+ ]
8917
+ },
8918
+ "resolveProposal": {
8919
+ "signature": "resolveProposal(uint64)(bool,uint64,uint64,uint64,uint64)",
8920
+ "selector": "5b3a8b00",
8921
+ "args": [
8922
+ {
8923
+ "name": "proposalID",
8924
+ "type": "uint64"
8925
+ }
8926
+ ],
8927
+ "returns": "(bool,uint64,uint64,uint64,uint64)",
8928
+ "actions": [
8929
+ "NoOp"
8930
+ ]
8931
+ },
8932
+ "vote": {
8933
+ "signature": "vote(pay,address,uint64,uint8,byte[])void",
8934
+ "selector": "3d7525e9",
8935
+ "args": [
8936
+ {
8937
+ "name": "mbrPayment",
8938
+ "type": "pay"
8939
+ },
8940
+ {
8941
+ "name": "voter",
8942
+ "type": "address"
8943
+ },
8944
+ {
8945
+ "name": "proposalID",
8946
+ "type": "uint64"
8947
+ },
8948
+ {
8949
+ "name": "vote",
8950
+ "type": "uint8"
8951
+ },
8952
+ {
8953
+ "name": "evidence",
8954
+ "type": "byte[]"
8955
+ }
8956
+ ],
8957
+ "returns": "void",
8958
+ "actions": [
8959
+ "NoOp"
8960
+ ]
8961
+ },
8962
+ "proposalPower": {
8963
+ "signature": "proposalPower(address,byte[],uint64)uint64",
8964
+ "selector": "c3eb7cd4",
8965
+ "args": [
8966
+ {
8967
+ "name": "account",
8968
+ "type": "address"
8969
+ },
8970
+ {
8971
+ "name": "evidence",
8972
+ "type": "byte[]"
8973
+ },
8974
+ {
8975
+ "name": "requiredThrough",
8976
+ "type": "uint64"
8977
+ }
8978
+ ],
8979
+ "returns": "uint64",
8980
+ "actions": [
8981
+ "NoOp"
8982
+ ]
8983
+ },
8984
+ "create": {
8985
+ "signature": "create(byte[])void",
8986
+ "selector": "8e79358d",
8987
+ "args": [
8988
+ {
8989
+ "name": "governanceConfig",
8990
+ "type": "byte[]"
8991
+ }
8992
+ ],
8993
+ "returns": "void",
8994
+ "actions": [
8995
+ "create:NoOp"
8996
+ ]
8997
+ },
8998
+ "configurationMbr": {
8999
+ "signature": "configurationMbr(byte[])uint64",
9000
+ "selector": "aa3e40a8",
9001
+ "args": [
9002
+ {
9003
+ "name": "config",
9004
+ "type": "byte[]"
9005
+ }
9006
+ ],
9007
+ "returns": "uint64",
9008
+ "actions": [
9009
+ "NoOp"
9010
+ ]
9011
+ },
9012
+ "configure": {
9013
+ "signature": "configure(pay,byte[])void",
9014
+ "selector": "8bff8387",
9015
+ "args": [
9016
+ {
9017
+ "name": "mbrPayment",
9018
+ "type": "pay"
9019
+ },
9020
+ {
9021
+ "name": "config",
9022
+ "type": "byte[]"
9023
+ }
9024
+ ],
9025
+ "returns": "void",
9026
+ "actions": [
9027
+ "NoOp"
9028
+ ]
9029
+ },
9030
+ "consensusActionMbr": {
9031
+ "signature": "consensusActionMbr(byte[])uint64",
9032
+ "selector": "857e2717",
9033
+ "args": [
9034
+ {
9035
+ "name": "data",
9036
+ "type": "byte[]"
9037
+ }
9038
+ ],
9039
+ "returns": "uint64",
9040
+ "actions": [
9041
+ "NoOp"
9042
+ ]
9043
+ },
9044
+ "applyConsensusAction": {
9045
+ "signature": "applyConsensusAction(pay,uint64,byte[])void",
9046
+ "selector": "67ed5fed",
9047
+ "args": [
9048
+ {
9049
+ "name": "mbrPayment",
9050
+ "type": "pay"
9051
+ },
9052
+ {
9053
+ "name": "proposalID",
9054
+ "type": "uint64"
9055
+ },
9056
+ {
9057
+ "name": "data",
9058
+ "type": "byte[]"
9059
+ }
9060
+ ],
9061
+ "returns": "void",
9062
+ "actions": [
9063
+ "NoOp"
9064
+ ]
9065
+ },
9066
+ "bindGuild": {
9067
+ "signature": "bindGuild(uint64)void",
9068
+ "selector": "3e87013b",
9069
+ "args": [
9070
+ {
9071
+ "name": "guild",
9072
+ "type": "uint64"
9073
+ }
9074
+ ],
9075
+ "returns": "void",
9076
+ "actions": [
9077
+ "NoOp"
9078
+ ]
9079
+ },
9080
+ "getBallot": {
9081
+ "signature": "getBallot(uint64)(bool,bool,uint64,uint64,uint64,(uint64,uint64,uint64),(uint64,uint64,uint64))",
9082
+ "selector": "92bb769e",
9083
+ "args": [
9084
+ {
9085
+ "name": "proposalID",
9086
+ "type": "uint64"
9087
+ }
9088
+ ],
9089
+ "returns": "(bool,bool,uint64,uint64,uint64,(uint64,uint64,uint64),(uint64,uint64,uint64))",
9090
+ "actions": [
9091
+ "NoOp"
9092
+ ]
9093
+ },
9094
+ "voteMbr": {
9095
+ "signature": "voteMbr()uint64",
9096
+ "selector": "6f9378e3",
9097
+ "args": [],
9098
+ "returns": "uint64",
9099
+ "actions": [
9100
+ "NoOp"
9101
+ ]
9102
+ },
9103
+ "hasVoted": {
9104
+ "signature": "hasVoted(uint64,address)bool",
9105
+ "selector": "f50808ef",
9106
+ "args": [
9107
+ {
9108
+ "name": "proposalID",
9109
+ "type": "uint64"
9110
+ },
9111
+ {
9112
+ "name": "voter",
9113
+ "type": "address"
9114
+ }
9115
+ ],
9116
+ "returns": "bool",
9117
+ "actions": [
9118
+ "NoOp"
9119
+ ]
9120
+ },
9121
+ "opUp": {
9122
+ "signature": "opUp()void",
9123
+ "selector": "854dede0",
9124
+ "args": [],
9125
+ "returns": "void",
9126
+ "actions": [
9127
+ "NoOp"
9128
+ ]
9129
+ }
9130
+ },
9131
+ "events": {},
9132
+ "structs": {
9133
+ "Object75E64AB9": [
9134
+ {
9135
+ "name": "weight",
9136
+ "type": "uint64"
9137
+ },
9138
+ {
9139
+ "name": "since",
9140
+ "type": "uint64"
9141
+ },
9142
+ {
9143
+ "name": "slot",
9144
+ "type": "uint64"
9145
+ }
9146
+ ],
9147
+ "ObjectA68503ED": [
9148
+ {
9149
+ "name": "weight",
9150
+ "type": "uint64"
9151
+ },
9152
+ {
9153
+ "name": "until",
9154
+ "type": "uint64"
9155
+ }
9156
+ ],
9157
+ "ObjectA760343E": [
9158
+ {
9159
+ "name": "account",
9160
+ "type": "address"
9161
+ },
9162
+ {
9163
+ "name": "since",
9164
+ "type": "uint64"
9165
+ }
9166
+ ],
9167
+ "ObjectEEB10897": [
9168
+ {
9169
+ "name": "epoch",
9170
+ "type": "uint64"
9171
+ },
9172
+ {
9173
+ "name": "mode",
9174
+ "type": "uint8"
9175
+ }
9176
+ ],
9177
+ "GuildConsensusBallot": [
9178
+ {
9179
+ "name": "resolved",
9180
+ "type": "bool"
9181
+ },
9182
+ {
9183
+ "name": "approved",
9184
+ "type": "bool"
9185
+ },
9186
+ {
9187
+ "name": "votingEnd",
9188
+ "type": "uint64"
9189
+ },
9190
+ {
9191
+ "name": "eligiblePower",
9192
+ "type": "uint64"
9193
+ },
9194
+ {
9195
+ "name": "voteCount",
9196
+ "type": "uint64"
9197
+ },
9198
+ {
9199
+ "name": "requirements",
9200
+ "type": "GuildConsensusRequirements"
9201
+ },
9202
+ {
9203
+ "name": "votes",
9204
+ "type": "GuildVoteTotals"
9205
+ }
9206
+ ],
9207
+ "GuildConsensusRequirements": [
9208
+ {
9209
+ "name": "participation",
9210
+ "type": "uint64"
9211
+ },
9212
+ {
9213
+ "name": "approval",
9214
+ "type": "uint64"
9215
+ },
9216
+ {
9217
+ "name": "minimumApprovals",
9218
+ "type": "uint64"
9219
+ }
9220
+ ],
9221
+ "GuildConsensusResult": [
9222
+ {
9223
+ "name": "approved",
9224
+ "type": "bool"
9225
+ },
9226
+ {
9227
+ "name": "approvals",
9228
+ "type": "uint64"
9229
+ },
9230
+ {
9231
+ "name": "rejections",
9232
+ "type": "uint64"
9233
+ },
9234
+ {
9235
+ "name": "abstains",
9236
+ "type": "uint64"
9237
+ },
9238
+ {
9239
+ "name": "eligiblePower",
9240
+ "type": "uint64"
9241
+ }
9242
+ ],
9243
+ "GuildProposalSettings": [
9244
+ {
9245
+ "name": "fee",
9246
+ "type": "uint64"
9247
+ },
9248
+ {
9249
+ "name": "power",
9250
+ "type": "uint64"
9251
+ },
9252
+ {
9253
+ "name": "duration",
9254
+ "type": "uint64"
9255
+ },
9256
+ {
9257
+ "name": "participation",
9258
+ "type": "uint64"
9259
+ },
9260
+ {
9261
+ "name": "approval",
9262
+ "type": "uint64"
9263
+ },
9264
+ {
9265
+ "name": "minimumApprovals",
9266
+ "type": "uint64"
9267
+ }
9268
+ ],
9269
+ "GuildVote": [
9270
+ {
9271
+ "name": "type",
9272
+ "type": "uint8"
9273
+ },
9274
+ {
9275
+ "name": "power",
9276
+ "type": "uint64"
9277
+ }
9278
+ ],
9279
+ "GuildVoteKey": [
9280
+ {
9281
+ "name": "proposalID",
9282
+ "type": "uint64"
9283
+ },
9284
+ {
9285
+ "name": "voter",
9286
+ "type": "address"
9287
+ }
9288
+ ],
9289
+ "GuildVoteTotals": [
9290
+ {
9291
+ "name": "approvals",
9292
+ "type": "uint64"
9293
+ },
9294
+ {
9295
+ "name": "rejections",
9296
+ "type": "uint64"
9297
+ },
9298
+ {
9299
+ "name": "abstains",
9300
+ "type": "uint64"
9301
+ }
9302
+ ]
9303
+ }
9304
+ }
9305
+ };
9306
+
9307
+ // src/contracts/decode.ts
9308
+ function structTuple(name, structs) {
9309
+ const fields = structs[name];
9310
+ if (!fields) return void 0;
9311
+ return `(${fields.map((f) => structTuple(f.type, structs) ?? f.type).join(",")})`;
9312
+ }
9313
+ function normalize(value, typeName, structs) {
9314
+ const fields = structs[typeName];
9315
+ if (fields && Array.isArray(value)) {
9316
+ const out = {};
9317
+ fields.forEach((f, i) => {
9318
+ out[f.name] = normalize(value[i], f.type, structs);
9319
+ });
9320
+ return out;
9321
+ }
9322
+ if (/^byte\[\d*\]$/.test(typeName) && (Array.isArray(value) || value instanceof Uint8Array)) {
9323
+ return toHex(Uint8Array.from(value, (b) => Number(b)));
9324
+ }
9325
+ if (typeof value === "bigint" || typeof value === "number") return value.toString();
9326
+ if (typeof value === "string" || typeof value === "boolean") return value;
9327
+ if (value instanceof Uint8Array) return toHex(value);
9328
+ if (Array.isArray(value)) return value.map((v) => normalize(v, "", structs));
9329
+ if (value && typeof value === "object" && "toString" in value) return String(value);
9330
+ return null;
9331
+ }
9332
+ function decodeValue(type, raw, structs) {
9333
+ if (type === "AVMUint64") return (raw.uint ?? (raw.bytes ? bytesToBigInt(raw.bytes) : 0n)).toString();
9334
+ const bytes = raw.bytes ?? new Uint8Array();
9335
+ if (type === "AVMString") return utf8(bytes);
9336
+ if (type === "AVMBytes") return toHex(bytes);
9337
+ if (type === "address") return bytes.length === 32 ? import_algosdk.default.encodeAddress(bytes) : toHex(bytes);
9338
+ const abi = structTuple(type, structs) ?? type;
9339
+ try {
9340
+ return normalize(import_algosdk.default.ABIType.from(abi).decode(bytes), type, structs);
9341
+ } catch {
9342
+ return toHex(bytes);
9343
+ }
9344
+ }
9345
+ function decodeGlobalState(contract2, state) {
9346
+ const schema = CONTRACT_SCHEMAS[contract2];
9347
+ const structs = schema.structs;
9348
+ const out = {};
9349
+ for (const [field3, def] of Object.entries(schema.global)) {
9350
+ const raw = state.get(def.key);
9351
+ if (raw) out[field3] = decodeValue(def.type, raw, structs);
9352
+ }
9353
+ return out;
9354
+ }
9355
+ function methodForSelector(contract2, selectorHex) {
9356
+ for (const [name, m] of Object.entries(CONTRACT_SCHEMAS[contract2].methods)) {
9357
+ if (m.selector === selectorHex) return name;
9358
+ }
9359
+ return void 0;
9360
+ }
9361
+ function decodeArgs(contract2, method, args) {
9362
+ const m = CONTRACT_SCHEMAS[contract2].methods[method];
9363
+ if (!m) return [];
9364
+ const structs = CONTRACT_SCHEMAS[contract2].structs;
9365
+ const txnTypes = /* @__PURE__ */ new Set(["txn", "pay", "keyreg", "acfg", "axfer", "afrz", "appl"]);
9366
+ const out = [];
9367
+ let i = 1;
9368
+ for (const a of m.args) {
9369
+ if (txnTypes.has(a.type)) continue;
9370
+ const bytes = args[i++];
9371
+ if (!bytes) break;
9372
+ try {
9373
+ out.push(normalize(import_algosdk.default.ABIType.from(a.type).decode(bytes), a.struct ?? a.type, structs));
9374
+ } catch {
9375
+ out.push(toHex(bytes));
9376
+ }
9377
+ }
9378
+ return out;
9379
+ }
9380
+ function decodeEvents(contract2, logs) {
9381
+ const events = CONTRACT_SCHEMAS[contract2].events ?? {};
9382
+ const bySelector = new Map(Object.entries(events).map(([name, e]) => [e.selector, { name, args: e.args }]));
9383
+ const out = [];
9384
+ for (const log of logs) {
9385
+ const bytes = fromBase64(log);
9386
+ if (bytes.length < 4) continue;
9387
+ const event = bySelector.get(toHex(bytes.subarray(0, 4)));
9388
+ if (!event) continue;
9389
+ try {
9390
+ const values = import_algosdk.default.ABIType.from(`(${event.args.map((a) => a.type).join(",")})`).decode(bytes.subarray(4));
9391
+ const fields = {};
9392
+ event.args.forEach((a, i) => {
9393
+ fields[a.name] = normalize(values[i], a.type, {});
9394
+ });
9395
+ out.push({ name: event.name, fields });
9396
+ } catch {
9397
+ }
9398
+ }
9399
+ return out;
9400
+ }
9401
+ function boxDef(contract2, map) {
9402
+ const def = CONTRACT_SCHEMAS[contract2].boxes?.[map];
9403
+ if (!def) throw new Error(`${contract2} has no box map ${map}`);
9404
+ return def;
9405
+ }
9406
+ function abiTypeFor(type, structs) {
9407
+ return structTuple(type, structs) ?? (type === "AVMBytes" ? "byte[]" : type === "AVMString" ? "string" : type === "AVMUint64" ? "uint64" : type);
9408
+ }
9409
+ function boxName(contract2, map, key) {
9410
+ const def = boxDef(contract2, map);
9411
+ const structs = CONTRACT_SCHEMAS[contract2].structs;
9412
+ const prefix = Uint8Array.from(def.prefix, (c) => c.charCodeAt(0));
9413
+ const encoded = import_algosdk.default.ABIType.from(abiTypeFor(def.keyType, structs)).encode(key);
9414
+ const out = new Uint8Array(prefix.length + encoded.length);
9415
+ out.set(prefix);
9416
+ out.set(encoded, prefix.length);
9417
+ return out;
9418
+ }
9419
+ function boxPrefix(contract2, map) {
9420
+ return Uint8Array.from(boxDef(contract2, map).prefix, (c) => c.charCodeAt(0));
9421
+ }
9422
+ function decodeBoxValue(contract2, map, bytes) {
9423
+ const def = boxDef(contract2, map);
9424
+ return decodeValue(def.valueType, { bytes }, CONTRACT_SCHEMAS[contract2].structs);
9425
+ }
9426
+ function decodeBoxKey(contract2, map, name) {
9427
+ const def = boxDef(contract2, map);
9428
+ const structs = CONTRACT_SCHEMAS[contract2].structs;
9429
+ return normalize(import_algosdk.default.ABIType.from(abiTypeFor(def.keyType, structs)).decode(name.subarray(def.prefix.length)), def.keyType, structs);
9430
+ }
9431
+
9432
+ // src/media.ts
9433
+ var import_algosdk2 = __toESM(require("algosdk"), 1);
9434
+ var import_js_sha256 = require("js-sha256");
9435
+ var DEFAULT_IPFS_GATEWAY = "https://ipfs.akita.community/ipfs/";
9436
+ var MULTICODEC = { raw: 85, "dag-pb": 112 };
9437
+ var MULTIHASH = { "sha2-256": 18 };
9438
+ var B32 = "abcdefghijklmnopqrstuvwxyz234567";
9439
+ function base32Lower(bytes) {
9440
+ let out = "";
9441
+ let buffer = 0;
9442
+ let bits = 0;
9443
+ for (const b of bytes) {
9444
+ buffer = buffer << 8 | b;
9445
+ bits += 8;
9446
+ while (bits >= 5) {
9447
+ out += B32[buffer >>> bits - 5 & 31];
9448
+ bits -= 5;
9449
+ }
9450
+ }
9451
+ if (bits > 0) out += B32[buffer << 5 - bits & 31];
9452
+ return out;
9453
+ }
9454
+ function resolveArc19(template, reserve) {
9455
+ const m = template.match(/^template-ipfs:\/\/\{ipfscid:(\d+):([^:]+):([^:]+):([^}]+)\}(.*)$/);
9456
+ if (!m || m[3] !== "reserve" || !reserve || m[1] !== "1") return void 0;
9457
+ const codec = MULTICODEC[m[2]];
9458
+ const hash = MULTIHASH[m[4]];
9459
+ if (codec === void 0 || hash === void 0) return void 0;
9460
+ const key = import_algosdk2.default.decodeAddress(reserve).publicKey;
9461
+ const cid = new Uint8Array(4 + key.length);
9462
+ cid.set([1, codec, hash, 32]);
9463
+ cid.set(key, 4);
9464
+ return `ipfs://b${base32Lower(cid)}${m[5] ?? ""}`;
9465
+ }
9466
+ function ipfsToGateway(url, gateway = DEFAULT_IPFS_GATEWAY) {
9467
+ return url.startsWith("ipfs://") ? `${gateway.replace(/\/?$/, "/")}${url.slice("ipfs://".length)}` : url;
9468
+ }
9469
+ var isArc3 = (asset) => Boolean(asset.url?.endsWith("#arc3") || asset.name?.endsWith("@arc3") || asset.url?.split("#")[0].endsWith(".json"));
9470
+ async function fetchBytes(fetchFn, url, timeoutMs = 1e4) {
9471
+ const controller = new AbortController();
9472
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
9473
+ try {
9474
+ const res = await fetchFn(url, { signal: controller.signal });
9475
+ if (!res.ok) return void 0;
9476
+ return new Uint8Array(await res.arrayBuffer());
9477
+ } catch {
9478
+ return void 0;
9479
+ } finally {
9480
+ clearTimeout(timer);
9481
+ }
9482
+ }
9483
+ function mediaFromJson(json, base) {
9484
+ const rel = (v) => {
9485
+ if (typeof v !== "string" || !v) return void 0;
9486
+ return /^[a-z][a-z0-9+.-]*:/i.test(v) ? v : `${base.replace(/[^/]*$/, "")}${v}`;
9487
+ };
9488
+ return {
9489
+ image: rel(json.image ?? json.media_url ?? json.image_url),
9490
+ animation: rel(json.animation_url),
9491
+ mimeType: typeof json.image_mimetype === "string" ? json.image_mimetype : typeof json.mime_type === "string" ? json.mime_type : void 0,
9492
+ description: typeof json.description === "string" ? json.description : void 0
9493
+ };
9494
+ }
9495
+ function createMediaSource(loadAsset, options = {}) {
9496
+ const gateway = options.ipfsGateway ?? DEFAULT_IPFS_GATEWAY;
9497
+ return {
9498
+ name: "media",
9499
+ maxBatch: 1,
9500
+ concurrency: 6,
9501
+ supports: (kind) => kind === "asset-media",
9502
+ async fetch(refs, ctx) {
9503
+ const out = /* @__PURE__ */ new Map();
9504
+ const ref = refs[0];
9505
+ if (!ref) return out;
9506
+ const asset = (await loadAsset(ref.id))?.data;
9507
+ const now = Date.now();
9508
+ const done = (data) => out.set(refKey(ref), { kind: "asset-media", id: ref.id, network: ctx.network, status: "live", data, provenance: { source: "media", fetchedAt: now } });
9509
+ if (!asset) return out;
9510
+ if (asset.imageUrl) return done({ assetId: ref.id, image: asset.imageUrl, standard: "resolver" }), out;
9511
+ let url = asset.url ?? "";
9512
+ let standard = "url";
9513
+ if (url.startsWith("template-ipfs://")) {
9514
+ url = resolveArc19(url, asset.reserve) ?? "";
9515
+ standard = "arc19";
9516
+ }
9517
+ if (url && (isArc3(asset) || url.split("#")[0].endsWith(".json") || standard === "arc19")) {
9518
+ const metaUrl = url.split("#")[0];
9519
+ const bytes = await fetchBytes(ctx.fetch, ipfsToGateway(metaUrl, gateway));
9520
+ const json = bytes ? safeJson(utf8(bytes)) : void 0;
9521
+ if (json) {
9522
+ const hash = asset.metadataHash ? toHex(fromBase64(asset.metadataHash)) : void 0;
9523
+ return done({
8079
9524
  assetId: ref.id,
8080
9525
  standard: standard === "arc19" ? "arc19" : "arc3",
8081
9526
  ...mediaFromJson(json, metaUrl),
@@ -8749,7 +10194,7 @@ async function verifyArchived(entity, options) {
8749
10194
  if (!history.application.deleted) mismatches.push("status");
8750
10195
  const claimed = entity.data ?? {};
8751
10196
  const derived = reduced.data;
8752
- for (const field2 of family.verifyFields) if (!same(claimed[field2], derived[field2])) mismatches.push(field2);
10197
+ for (const field3 of family.verifyFields) if (!same(claimed[field3], derived[field3])) mismatches.push(field3);
8753
10198
  return {
8754
10199
  ...entity,
8755
10200
  status: history.application.deleted ? "archived" : "live",
@@ -9008,8 +10453,180 @@ var PUBLIC_ENDPOINTS = {
9008
10453
  testnet: { algod: "https://testnet-api.4160.nodely.dev", indexer: "https://testnet-idx.4160.nodely.dev" }
9009
10454
  };
9010
10455
 
10456
+ // src/guild.ts
10457
+ var import_algosdk6 = __toESM(require("algosdk"), 1);
10458
+ var STATUS = {
10459
+ "0": "draft",
10460
+ "10": "invalid",
10461
+ "20": "voting",
10462
+ "30": "rejected",
10463
+ "40": "approved",
10464
+ "50": "executed"
10465
+ };
10466
+ var GUILD_ZERO_ADDRESS = import_algosdk6.default.ALGORAND_ZERO_ADDRESS_STRING;
10467
+ function splitGuildProposalId(id) {
10468
+ const match = /^(\d+)\/(\d+)$/.exec(id.trim());
10469
+ return match ? { guildAppId: match[1], proposalId: match[2] } : void 0;
10470
+ }
10471
+ var ACTION_LABELS = {
10472
+ 10: "Upgrade the guild",
10473
+ 20: "Install a plugin",
10474
+ 21: "Install a named plugin",
10475
+ 22: "Change plugin vote settings",
10476
+ 30: "Run a plugin",
10477
+ 31: "Revoke a plugin run",
10478
+ 40: "Remove a plugin",
10479
+ 41: "Remove a named plugin",
10480
+ 50: "Add spending allowances",
10481
+ 60: "Remove spending allowances",
10482
+ 70: "Create an escrow",
10483
+ 71: "Lock or unlock an escrow",
10484
+ 72: "Reclaim from an escrow",
10485
+ 80: "Change proposal rules",
10486
+ 81: "Change the action limit",
10487
+ 82: "Create a wallet",
10488
+ 83: "Change membership",
10489
+ 84: "Change membership vote settings",
10490
+ 86: "Set the chat steward",
10491
+ 90: "Update the wallet",
10492
+ 91: "Hand the wallet to a new admin",
10493
+ 100: "Finish setup",
10494
+ 110: "Lock the plugin set"
10495
+ };
10496
+ function readUint64(data, offset) {
10497
+ if (data.length < offset + 8) return void 0;
10498
+ let value = 0n;
10499
+ for (let i = 0; i < 8; i += 1) value = value << 8n | BigInt(data[offset + i]);
10500
+ return value;
10501
+ }
10502
+ function summarizeGuildActions(actions) {
10503
+ return actions.map(([type, data]) => {
10504
+ const label = ACTION_LABELS[type] ?? `Action ${type}`;
10505
+ if (type !== 20 && type !== 22 && type !== 30 && type !== 40) return { type, label };
10506
+ const plugin = readUint64(data, 0);
10507
+ const action = { type, label, ...plugin !== void 0 && { pluginAppId: plugin.toString() } };
10508
+ if ((type === 20 || type === 40) && data.length >= 40) action.caller = import_algosdk6.default.encodeAddress(data.slice(8, 40));
10509
+ return action;
10510
+ });
10511
+ }
10512
+ var str3 = (v) => typeof v === "string" ? v : v == null ? "" : String(v);
10513
+ var field2 = (v, k) => v && typeof v === "object" && !Array.isArray(v) ? v[k] : void 0;
10514
+ var positive = (v) => str3(v) && str3(v) !== "0" ? str3(v) : void 0;
10515
+ function decodedActions(value) {
10516
+ if (!Array.isArray(value)) return [];
10517
+ return value.flatMap((entry) => {
10518
+ if (!Array.isArray(entry) || entry.length < 2) return [];
10519
+ const type = Number(str3(entry[0]));
10520
+ const raw = entry[1];
10521
+ const data = typeof raw === "string" ? fromHex(raw) : Array.isArray(raw) ? Uint8Array.from(raw, (b) => Number(str3(b))) : new Uint8Array();
10522
+ return Number.isSafeInteger(type) ? [[type, data]] : [];
10523
+ });
10524
+ }
10525
+ function ballotFrom(b) {
10526
+ const req = field2(b, "requirements");
10527
+ const votes = field2(b, "votes");
10528
+ return {
10529
+ resolved: field2(b, "resolved") === true,
10530
+ approved: field2(b, "approved") === true,
10531
+ votingEnd: str3(field2(b, "votingEnd")),
10532
+ eligiblePower: str3(field2(b, "eligiblePower")),
10533
+ voteCount: str3(field2(b, "voteCount")),
10534
+ requirements: {
10535
+ participation: str3(field2(req, "participation")) || "0",
10536
+ approval: str3(field2(req, "approval")) || "0",
10537
+ minimumApprovals: str3(field2(req, "minimumApprovals")) || "0"
10538
+ },
10539
+ votes: {
10540
+ approvals: str3(field2(votes, "approvals")) || "0",
10541
+ rejections: str3(field2(votes, "rejections")) || "0",
10542
+ abstains: str3(field2(votes, "abstains")) || "0"
10543
+ }
10544
+ };
10545
+ }
10546
+ async function readGuildProposal(fetchFn, algod, id) {
10547
+ const parts = splitGuildProposalId(id);
10548
+ if (!parts) return void 0;
10549
+ const { guildAppId, proposalId } = parts;
10550
+ const [app, value] = await Promise.all([
10551
+ requestJson(fetchFn, algod, `/v2/applications/${guildAppId}`),
10552
+ readBox(fetchFn, algod, guildAppId, boxName("guild", "proposals", BigInt(proposalId)))
10553
+ ]);
10554
+ if (!app || !value) return void 0;
10555
+ const guild = decodeGlobalState("guild", stateFromTeal(app.params["global-state"]));
10556
+ const p = decodeBoxValue("guild", "proposals", value);
10557
+ const status = STATUS[str3(field2(p, "status"))] ?? "invalid";
10558
+ const consensusAppId = positive(guild.consensus);
10559
+ const creator = str3(field2(p, "creator"));
10560
+ const data = {
10561
+ guildAppId,
10562
+ proposalId,
10563
+ consensusAppId,
10564
+ walletAppId: positive(guild.wallet),
10565
+ status,
10566
+ creator: creator && creator !== GUILD_ZERO_ADDRESS ? creator : void 0,
10567
+ created: str3(field2(p, "created")),
10568
+ votingTs: str3(field2(p, "votingTs")),
10569
+ actions: summarizeGuildActions(decodedActions(field2(p, "actions")))
10570
+ };
10571
+ if (consensusAppId && status !== "draft" && status !== "invalid") {
10572
+ const ballot = await readBox(fetchFn, algod, consensusAppId, boxName("guildConsensus", "ballots", BigInt(proposalId))).catch(() => void 0);
10573
+ if (ballot) data.ballot = ballotFrom(decodeBoxValue("guildConsensus", "ballots", ballot));
10574
+ }
10575
+ return data;
10576
+ }
10577
+ var HUNDRED = 100000n;
10578
+ function meets(b, approvals, rejections, turnout) {
10579
+ const participation = BigInt(b.requirements.participation);
10580
+ const approval = BigInt(b.requirements.approval);
10581
+ const minimum = BigInt(b.requirements.minimumApprovals);
10582
+ const eligible = BigInt(b.eligiblePower || "0");
10583
+ const decisive = approvals + rejections;
10584
+ return approvals > 0n && (participation === 0n || turnout * HUNDRED >= eligible * participation) && (minimum === 0n || approvals >= minimum) && (approval === 0n || decisive > 0n && approvals * HUNDRED >= decisive * approval);
10585
+ }
10586
+ function guildBallotOutcome(b, now) {
10587
+ if (b.resolved) return void 0;
10588
+ const approvals = BigInt(b.votes.approvals);
10589
+ const rejections = BigInt(b.votes.rejections);
10590
+ const turnout = approvals + rejections + BigInt(b.votes.abstains);
10591
+ const passes = meets(b, approvals, rejections, turnout);
10592
+ if (now > Number(b.votingEnd)) return passes ? "approved" : "rejected";
10593
+ const eligible = BigInt(b.eligiblePower || "0");
10594
+ if (eligible === 0n) return void 0;
10595
+ const remaining = eligible > turnout ? eligible - turnout : 0n;
10596
+ if (passes) return meets(b, approvals, rejections + remaining, turnout) ? "approved" : void 0;
10597
+ return meets(b, approvals + remaining, rejections, turnout + remaining) ? void 0 : "rejected";
10598
+ }
10599
+ function formatGuildPercent(value) {
10600
+ const tenths = Number((BigInt(value || "0") * 1000n + HUNDRED - 1n) / HUNDRED);
10601
+ return `${tenths % 10 === 0 ? tenths / 10 : (tenths / 10).toFixed(1)}%`;
10602
+ }
10603
+ function guildProposalStatusLabel(status) {
10604
+ switch (status) {
10605
+ case "draft":
10606
+ return "Draft";
10607
+ case "invalid":
10608
+ return "Invalid";
10609
+ case "voting":
10610
+ return "Voting";
10611
+ case "rejected":
10612
+ return "Rejected";
10613
+ case "approved":
10614
+ return "Passed";
10615
+ case "executed":
10616
+ return "Done";
10617
+ }
10618
+ }
10619
+ function guildRequirementsText(b) {
10620
+ const { approval, minimumApprovals, participation } = b.requirements;
10621
+ return [
10622
+ approval !== "0" ? `Needs ${formatGuildPercent(approval)} yes` : null,
10623
+ minimumApprovals !== "0" ? `at least ${minimumApprovals} approval${minimumApprovals === "1" ? "" : "s"}` : null,
10624
+ participation !== "0" ? `${formatGuildPercent(participation)} turnout` : null
10625
+ ].filter(Boolean).join(", ");
10626
+ }
10627
+
9011
10628
  // src/sources/algod.ts
9012
- var KINDS2 = /* @__PURE__ */ new Set(["account", "asset", "application"]);
10629
+ var KINDS2 = /* @__PURE__ */ new Set(["account", "asset", "application", "guild-proposal"]);
9013
10630
  function createAlgodSource(endpoint, singletons = {}) {
9014
10631
  const singletonKinds = {
9015
10632
  reward: singletons.rewards,
@@ -9032,6 +10649,11 @@ function createAlgodSource(endpoint, singletons = {}) {
9032
10649
  if (a) out.set(refKey(ref), { ...base, data: accountFromJson(a), provenance: { ...provenance, round: Number(a.round ?? 0) || void 0 } });
9033
10650
  return out;
9034
10651
  }
10652
+ if (ref.kind === "guild-proposal") {
10653
+ const data = await readGuildProposal(ctx.fetch, endpoint, ref.id);
10654
+ if (data) out.set(refKey(ref), { ...base, data, provenance });
10655
+ return out;
10656
+ }
9035
10657
  const singleton = singletonKinds[ref.kind];
9036
10658
  if (singleton) {
9037
10659
  const data = ref.kind === "reward" ? await readReward(ctx.fetch, endpoint, singleton, ref.id) : ref.kind === "subscription" ? await readSubscription(ctx.fetch, endpoint, singleton, ref.id) : await readTrade(ctx.fetch, endpoint, singleton, ref.id);
@@ -9361,6 +10983,7 @@ function createAlgomdClient(config) {
9361
10983
  CONTRACT_SCHEMAS,
9362
10984
  DEFAULT_IPFS_GATEWAY,
9363
10985
  FAMILIES,
10986
+ GUILD_ZERO_ADDRESS,
9364
10987
  HttpError,
9365
10988
  INTERFACE_NAMESPACE,
9366
10989
  KindRegistry,
@@ -9395,9 +11018,13 @@ function createAlgomdClient(config) {
9395
11018
  formatAlgo,
9396
11019
  formatAmount,
9397
11020
  formatDuration,
11021
+ formatGuildPercent,
9398
11022
  formatRelativeTime,
9399
11023
  fromBase64,
9400
11024
  fromHex,
11025
+ guildBallotOutcome,
11026
+ guildProposalStatusLabel,
11027
+ guildRequirementsText,
9401
11028
  hasRefs,
9402
11029
  interfaceAction,
9403
11030
  interfaceCards,
@@ -9414,6 +11041,7 @@ function createAlgomdClient(config) {
9414
11041
  parseProps,
9415
11042
  policyFor,
9416
11043
  readBox,
11044
+ readGuildProposal,
9417
11045
  readInterfacePointer,
9418
11046
  readReward,
9419
11047
  readStakingPool,
@@ -9432,9 +11060,11 @@ function createAlgomdClient(config) {
9432
11060
  serializeRef,
9433
11061
  shortAddress,
9434
11062
  sizeFromProps,
11063
+ splitGuildProposalId,
9435
11064
  splitSubscriptionId,
9436
11065
  stakingPoolFromDecoded,
9437
11066
  stateFromTeal,
11067
+ summarizeGuildActions,
9438
11068
  toBase64,
9439
11069
  toHex,
9440
11070
  utf8,