@poa-box/core 0.1.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 +201 -0
- package/dist/abis/DirectDemocracyVotingNew.d.ts +749 -0
- package/dist/abis/DirectDemocracyVotingNew.js +961 -0
- package/dist/abis/ERC20.d.ts +90 -0
- package/dist/abis/ERC20.js +125 -0
- package/dist/abis/EducationHubNew.d.ts +590 -0
- package/dist/abis/EducationHubNew.js +762 -0
- package/dist/abis/EligibilityModuleNew.d.ts +1615 -0
- package/dist/abis/EligibilityModuleNew.js +2082 -0
- package/dist/abis/Executor.d.ts +619 -0
- package/dist/abis/Executor.js +796 -0
- package/dist/abis/HybridVotingNew.d.ts +898 -0
- package/dist/abis/HybridVotingNew.js +1149 -0
- package/dist/abis/ImplementationRegistry.d.ts +270 -0
- package/dist/abis/ImplementationRegistry.js +355 -0
- package/dist/abis/OrgDeployerNew.d.ts +1275 -0
- package/dist/abis/OrgDeployerNew.js +1630 -0
- package/dist/abis/OrgRegistry.d.ts +670 -0
- package/dist/abis/OrgRegistry.js +868 -0
- package/dist/abis/ParticipationToken.d.ts +1086 -0
- package/dist/abis/ParticipationToken.js +1415 -0
- package/dist/abis/PasskeyAccount.d.ts +788 -0
- package/dist/abis/PasskeyAccount.js +1019 -0
- package/dist/abis/PasskeyAccountFactory.d.ts +344 -0
- package/dist/abis/PasskeyAccountFactory.js +449 -0
- package/dist/abis/PaymasterHub.d.ts +1603 -0
- package/dist/abis/PaymasterHub.js +2048 -0
- package/dist/abis/PaymentManager.d.ts +520 -0
- package/dist/abis/PaymentManager.js +671 -0
- package/dist/abis/PoaManager.d.ts +344 -0
- package/dist/abis/PoaManager.js +449 -0
- package/dist/abis/QuickJoinNew.d.ts +855 -0
- package/dist/abis/QuickJoinNew.js +1098 -0
- package/dist/abis/TaskManagerNew.d.ts +1236 -0
- package/dist/abis/TaskManagerNew.js +1573 -0
- package/dist/abis/ToggleModule.d.ts +193 -0
- package/dist/abis/ToggleModule.js +255 -0
- package/dist/abis/UniversalAccountRegistry.d.ts +577 -0
- package/dist/abis/UniversalAccountRegistry.js +750 -0
- package/dist/abis/ZkEmailInvites.d.ts +823 -0
- package/dist/abis/ZkEmailInvites.js +1060 -0
- package/dist/abis/external/AaveGovernanceV2.d.ts +128 -0
- package/dist/abis/external/AaveGovernanceV2.js +177 -0
- package/dist/abis/external/AaveGovernanceV3.d.ts +160 -0
- package/dist/abis/external/AaveGovernanceV3.js +220 -0
- package/dist/abis/external/AragonVoting.d.ts +107 -0
- package/dist/abis/external/AragonVoting.js +150 -0
- package/dist/abis/external/CurveGaugeController.d.ts +95 -0
- package/dist/abis/external/CurveGaugeController.js +130 -0
- package/dist/abis/external/CurveVotingEscrow.d.ts +86 -0
- package/dist/abis/external/CurveVotingEscrow.js +116 -0
- package/dist/abis/external/GovernorAlpha.d.ts +172 -0
- package/dist/abis/external/GovernorAlpha.js +228 -0
- package/dist/abis/external/MakerDAOChief.d.ts +92 -0
- package/dist/abis/external/MakerDAOChief.js +129 -0
- package/dist/abis/external/OZGovernor.d.ts +227 -0
- package/dist/abis/external/OZGovernor.js +317 -0
- package/dist/abis/external/SolidlyVotingEscrow.d.ts +196 -0
- package/dist/abis/external/SolidlyVotingEscrow.js +260 -0
- package/dist/abis/index.d.ts +62 -0
- package/dist/abis/index.js +98 -0
- package/dist/chains.d.ts +150 -0
- package/dist/chains.js +320 -0
- package/dist/context.d.ts +48 -0
- package/dist/context.js +38 -0
- package/dist/contracts.d.ts +24 -0
- package/dist/contracts.js +41 -0
- package/dist/encoding.d.ts +58 -0
- package/dist/encoding.js +243 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.js +4 -0
- package/dist/error-catalog.d.ts +41 -0
- package/dist/error-catalog.js +941 -0
- package/dist/errors.d.ts +27 -0
- package/dist/errors.js +60 -0
- package/dist/execute/ethers.d.ts +93 -0
- package/dist/execute/ethers.js +323 -0
- package/dist/execute/index.d.ts +7 -0
- package/dist/execute/index.js +23 -0
- package/dist/execute/sponsored.d.ts +68 -0
- package/dist/execute/sponsored.js +277 -0
- package/dist/exit-codes.d.ts +18 -0
- package/dist/exit-codes.js +21 -0
- package/dist/format.d.ts +21 -0
- package/dist/format.js +89 -0
- package/dist/graph/client.d.ts +298 -0
- package/dist/graph/client.js +702 -0
- package/dist/graph/documents/activity.d.ts +9 -0
- package/dist/graph/documents/activity.js +164 -0
- package/dist/graph/documents/beacons.d.ts +172 -0
- package/dist/graph/documents/beacons.js +345 -0
- package/dist/graph/documents/index.d.ts +21 -0
- package/dist/graph/documents/index.js +57 -0
- package/dist/graph/documents/infrastructure.d.ts +30 -0
- package/dist/graph/documents/infrastructure.js +34 -0
- package/dist/graph/documents/org.d.ts +15 -0
- package/dist/graph/documents/org.js +249 -0
- package/dist/graph/documents/paymaster.d.ts +95 -0
- package/dist/graph/documents/paymaster.js +101 -0
- package/dist/graph/documents/role.d.ts +6 -0
- package/dist/graph/documents/role.js +41 -0
- package/dist/graph/documents/roles.d.ts +50 -0
- package/dist/graph/documents/roles.js +112 -0
- package/dist/graph/documents/task.d.ts +84 -0
- package/dist/graph/documents/task.js +236 -0
- package/dist/graph/documents/token.d.ts +13 -0
- package/dist/graph/documents/token.js +126 -0
- package/dist/graph/documents/treasury.d.ts +39 -0
- package/dist/graph/documents/treasury.js +136 -0
- package/dist/graph/documents/user.d.ts +120 -0
- package/dist/graph/documents/user.js +302 -0
- package/dist/graph/documents/voting-classes.d.ts +69 -0
- package/dist/graph/documents/voting-classes.js +149 -0
- package/dist/graph/documents/voting.d.ts +28 -0
- package/dist/graph/documents/voting.js +163 -0
- package/dist/graph/documents/vouch.d.ts +79 -0
- package/dist/graph/documents/vouch.js +171 -0
- package/dist/graph/documents/zkemail.d.ts +63 -0
- package/dist/graph/documents/zkemail.js +188 -0
- package/dist/graph/index.d.ts +2 -0
- package/dist/graph/index.js +41 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +92 -0
- package/dist/ipfs.d.ts +39 -0
- package/dist/ipfs.js +214 -0
- package/dist/label-aliases.d.ts +31 -0
- package/dist/label-aliases.js +70 -0
- package/dist/metadata/education.d.ts +30 -0
- package/dist/metadata/education.js +31 -0
- package/dist/metadata/index.d.ts +12 -0
- package/dist/metadata/index.js +48 -0
- package/dist/metadata/org.d.ts +92 -0
- package/dist/metadata/org.js +93 -0
- package/dist/metadata/proposal.d.ts +44 -0
- package/dist/metadata/proposal.js +45 -0
- package/dist/metadata/role.d.ts +38 -0
- package/dist/metadata/role.js +35 -0
- package/dist/metadata/task.d.ts +108 -0
- package/dist/metadata/task.js +81 -0
- package/dist/metadata/token.d.ts +32 -0
- package/dist/metadata/token.js +36 -0
- package/dist/metadata/user.d.ts +63 -0
- package/dist/metadata/user.js +70 -0
- package/dist/multicall.d.ts +32 -0
- package/dist/multicall.js +96 -0
- package/dist/payout.d.ts +59 -0
- package/dist/payout.js +96 -0
- package/dist/perms.d.ts +47 -0
- package/dist/perms.js +120 -0
- package/dist/preflight.d.ts +72 -0
- package/dist/preflight.js +269 -0
- package/dist/reads/education.d.ts +79 -0
- package/dist/reads/education.js +122 -0
- package/dist/reads/eligibility.d.ts +377 -0
- package/dist/reads/eligibility.js +687 -0
- package/dist/reads/index.d.ts +16 -0
- package/dist/reads/index.js +55 -0
- package/dist/reads/org.d.ts +258 -0
- package/dist/reads/org.js +220 -0
- package/dist/reads/paymaster.d.ts +147 -0
- package/dist/reads/paymaster.js +235 -0
- package/dist/reads/project.d.ts +33 -0
- package/dist/reads/project.js +62 -0
- package/dist/reads/resolve.d.ts +34 -0
- package/dist/reads/resolve.js +64 -0
- package/dist/reads/task.d.ts +286 -0
- package/dist/reads/task.js +280 -0
- package/dist/reads/token.d.ts +94 -0
- package/dist/reads/token.js +75 -0
- package/dist/reads/treasury.d.ts +222 -0
- package/dist/reads/treasury.js +241 -0
- package/dist/reads/user.d.ts +229 -0
- package/dist/reads/user.js +155 -0
- package/dist/reads/vote.d.ts +296 -0
- package/dist/reads/vote.js +392 -0
- package/dist/reads/zkemail.d.ts +117 -0
- package/dist/reads/zkemail.js +217 -0
- package/dist/similarity.d.ts +36 -0
- package/dist/similarity.js +67 -0
- package/dist/sponsorship-config.d.ts +47 -0
- package/dist/sponsorship-config.js +41 -0
- package/dist/stats.d.ts +11 -0
- package/dist/stats.js +27 -0
- package/dist/task-lens.d.ts +113 -0
- package/dist/task-lens.js +210 -0
- package/dist/tx/education.d.ts +169 -0
- package/dist/tx/education.js +344 -0
- package/dist/tx/eligibility.d.ts +511 -0
- package/dist/tx/eligibility.js +818 -0
- package/dist/tx/governance.d.ts +85 -0
- package/dist/tx/governance.js +87 -0
- package/dist/tx/index.d.ts +17 -0
- package/dist/tx/index.js +56 -0
- package/dist/tx/intent.d.ts +67 -0
- package/dist/tx/intent.js +48 -0
- package/dist/tx/org.d.ts +321 -0
- package/dist/tx/org.js +544 -0
- package/dist/tx/paymaster.d.ts +140 -0
- package/dist/tx/paymaster.js +251 -0
- package/dist/tx/project.d.ts +146 -0
- package/dist/tx/project.js +217 -0
- package/dist/tx/task.d.ts +480 -0
- package/dist/tx/task.js +1149 -0
- package/dist/tx/token.d.ts +96 -0
- package/dist/tx/token.js +165 -0
- package/dist/tx/treasury.d.ts +474 -0
- package/dist/tx/treasury.js +911 -0
- package/dist/tx/user.d.ts +177 -0
- package/dist/tx/user.js +292 -0
- package/dist/tx/vote.d.ts +332 -0
- package/dist/tx/vote.js +762 -0
- package/dist/tx/zkemail.d.ts +90 -0
- package/dist/tx/zkemail.js +210 -0
- package/dist/validation.d.ts +8 -0
- package/dist/validation.js +39 -0
- package/dist/version.d.ts +142 -0
- package/dist/version.js +257 -0
- package/dist/zkemail.d.ts +161 -0
- package/dist/zkemail.js +299 -0
- package/package.json +130 -0
package/dist/chains.d.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Configuration
|
|
3
|
+
* Mirrors frontend networks.js for full parity on POP-deployed chains.
|
|
4
|
+
*
|
|
5
|
+
* Chains come in two flavors:
|
|
6
|
+
* 1. POP-deployed chains (Gnosis, Arbitrum, Sepolia, BaseSepolia) — full
|
|
7
|
+
* subgraph + deployment support. Set `isExternal: false` (default).
|
|
8
|
+
* 2. External chains (Ethereum mainnet, Optimism, Base, Polygon) — no POP
|
|
9
|
+
* deployment, no POP subgraph. Used by read-only commands like
|
|
10
|
+
* `pop org probe-access` to inspect foreign governance contracts
|
|
11
|
+
* (Compound Governor Bravo, Aave V3, Uniswap, etc). Set
|
|
12
|
+
* `isExternal: true` so subgraph sweepers skip them.
|
|
13
|
+
*
|
|
14
|
+
* Adding an external chain: set `isExternal: true`, leave `subgraphUrl: ''`,
|
|
15
|
+
* and use an empty `bountyTokens` map. Commands that require a POP subgraph
|
|
16
|
+
* (org activity, task lists, proposal history) will refuse to run on external
|
|
17
|
+
* chains — probe-access and other foreign-contract tools work fine.
|
|
18
|
+
*
|
|
19
|
+
* Env-derived resolution (getGatewaySubgraphUrl, resolveNetworkConfig) reads
|
|
20
|
+
* from an injected EnvSource — the CLI passes process.env; browser hosts pass
|
|
21
|
+
* whatever env object they assemble. Pure lookups need no env at all.
|
|
22
|
+
*/
|
|
23
|
+
import { EnvSource } from './env';
|
|
24
|
+
export interface NetworkConfig {
|
|
25
|
+
chainId: number;
|
|
26
|
+
name: string;
|
|
27
|
+
nativeCurrency: {
|
|
28
|
+
name: string;
|
|
29
|
+
symbol: string;
|
|
30
|
+
decimals: number;
|
|
31
|
+
};
|
|
32
|
+
rpcUrl: string;
|
|
33
|
+
blockExplorer: string;
|
|
34
|
+
isTestnet: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* True if POP is NOT deployed on this chain. External chains are
|
|
37
|
+
* useful for read-only contract inspection (probe-access) but
|
|
38
|
+
* cannot be used for POP operations like task management, voting,
|
|
39
|
+
* treasury, or governance. Defaults to false when omitted.
|
|
40
|
+
*/
|
|
41
|
+
isExternal?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Default block range per getLogs chunk for this chain. L2 chains have
|
|
44
|
+
* stricter RPC limits than L1 — Optimism/Base public RPCs reject ranges
|
|
45
|
+
* above ~2000-5000 blocks. Commands like audit-vetoken use this value
|
|
46
|
+
* when the user doesn't pass --chunk. Defaults to 10000 when omitted.
|
|
47
|
+
*/
|
|
48
|
+
defaultLogsChunkBlocks?: number;
|
|
49
|
+
subgraphUrl: string;
|
|
50
|
+
/**
|
|
51
|
+
* Subgraph ID on The Graph's DECENTRALISED network (the "paid" gateway tier).
|
|
52
|
+
*
|
|
53
|
+
* `subgraphUrl` above points at Graph Studio, which is free but capped at
|
|
54
|
+
* 3K queries/day. The same deployment is also published to the gateway,
|
|
55
|
+
* where it is addressed by this base58 subgraph ID and billed against
|
|
56
|
+
* `GRAPH_API_KEY`. lib/subgraph.ts uses Studio first and switches here when
|
|
57
|
+
* the free quota is spent — see `getGatewaySubgraphUrl` below.
|
|
58
|
+
*
|
|
59
|
+
* Leave undefined when the deployment has not been published to the
|
|
60
|
+
* decentralised network; the chain then has no paid tier unless the
|
|
61
|
+
* operator supplies one via `POP_<NET>_SUBGRAPH_GATEWAY` /
|
|
62
|
+
* `POP_<NET>_SUBGRAPH_ID`.
|
|
63
|
+
*/
|
|
64
|
+
gatewaySubgraphId?: string;
|
|
65
|
+
bountyTokens: Record<string, string>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Base URL for The Graph's decentralised gateway. A full endpoint is
|
|
69
|
+
* `${base}/${gatewaySubgraphId}`. Override with POP_GRAPH_GATEWAY_URL to point
|
|
70
|
+
* at a self-hosted or regional gateway.
|
|
71
|
+
*
|
|
72
|
+
* NOTE: the LEGACY gateway form embedded the API key in the path
|
|
73
|
+
* (`/api/<KEY>/subgraphs/id/<ID>`). This modern form does not — the key travels
|
|
74
|
+
* in the Authorization header instead, so the URL is safe to print.
|
|
75
|
+
*/
|
|
76
|
+
export declare const DEFAULT_GRAPH_GATEWAY_URL = "https://gateway.thegraph.com/api/subgraphs/id";
|
|
77
|
+
export declare const NETWORKS: Record<string, NetworkConfig>;
|
|
78
|
+
/** Home chain for accounts/passkeys */
|
|
79
|
+
export declare const HOME_NETWORK = "arbitrum";
|
|
80
|
+
export declare const HOME_CHAIN_ID: number;
|
|
81
|
+
/** Default chain for org deployment */
|
|
82
|
+
export declare const DEFAULT_DEPLOY_NETWORK = "gnosis";
|
|
83
|
+
export declare const DEFAULT_DEPLOY_CHAIN_ID: number;
|
|
84
|
+
export declare function getNetworkByChainId(chainId: number): NetworkConfig | null;
|
|
85
|
+
export declare function getNetworkNameByChainId(chainId: number): string | null;
|
|
86
|
+
export declare function isNetworkSupported(chainId: number): boolean;
|
|
87
|
+
export declare function getSubgraphUrl(chainId: number): string;
|
|
88
|
+
/**
|
|
89
|
+
* UPPER_SNAKE env-var infix for a chain: 84532 -> "BASE_SEPOLIA".
|
|
90
|
+
* Single source of truth for the `POP_<NET>_*` env convention so the RPC,
|
|
91
|
+
* subgraph and gateway lookups can never drift apart.
|
|
92
|
+
*/
|
|
93
|
+
export declare function getEnvInfixByChainId(chainId: number): string | null;
|
|
94
|
+
/**
|
|
95
|
+
* Resolve the PAID (decentralised gateway) subgraph endpoint for a chain, or
|
|
96
|
+
* undefined when none is configured. Requires `GRAPH_API_KEY` at request time —
|
|
97
|
+
* this function only resolves the URL, it does not check for the key.
|
|
98
|
+
*
|
|
99
|
+
* Precedence (first non-empty wins):
|
|
100
|
+
* 1. `POP_<NET>_SUBGRAPH_GATEWAY` — explicit full URL
|
|
101
|
+
* 2. `POP_<NET>_SUBGRAPH_FALLBACK` — legacy name for the same thing
|
|
102
|
+
* 3. `POP_<NET>_SUBGRAPH_ID` — just the base58 ID, joined to the base
|
|
103
|
+
* 4. `NetworkConfig.gatewaySubgraphId` joined to the base
|
|
104
|
+
*
|
|
105
|
+
* The base is `POP_GRAPH_GATEWAY_URL` or DEFAULT_GRAPH_GATEWAY_URL. This
|
|
106
|
+
* replaces the old one-ad-hoc-env-var-per-chain arrangement where only Gnosis
|
|
107
|
+
* could ever reach the gateway.
|
|
108
|
+
*/
|
|
109
|
+
export declare function getGatewaySubgraphUrl(chainId: number, env?: EnvSource): string | undefined;
|
|
110
|
+
export declare function getAllSubgraphUrls(): Array<{
|
|
111
|
+
chainId: number;
|
|
112
|
+
url: string;
|
|
113
|
+
name: string;
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* Resolve the effective network config using env vars + CLI overrides.
|
|
117
|
+
* Priority: CLI flag > per-chain env var > POP_DEFAULT_CHAIN env > error
|
|
118
|
+
*/
|
|
119
|
+
export declare function resolveNetworkConfig(chainIdOverride?: number, env?: EnvSource): NetworkConfig & {
|
|
120
|
+
resolvedRpc: string;
|
|
121
|
+
resolvedSubgraph: string;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Token configuration — decimals and metadata for known tokens.
|
|
125
|
+
* Must match frontend token handling for correct amount encoding.
|
|
126
|
+
*/
|
|
127
|
+
export interface TokenInfo {
|
|
128
|
+
symbol: string;
|
|
129
|
+
decimals: number;
|
|
130
|
+
address: string;
|
|
131
|
+
}
|
|
132
|
+
/** Participation Token is always 18 decimals */
|
|
133
|
+
export declare const PARTICIPATION_TOKEN_DECIMALS = 18;
|
|
134
|
+
export declare function getTokenByAddress(address: string): TokenInfo | null;
|
|
135
|
+
/**
|
|
136
|
+
* Reverse lookup by symbol. Case-insensitive. Returns the first matching
|
|
137
|
+
* token across all chains — if the same symbol exists on multiple chains
|
|
138
|
+
* (e.g. USDC on Gnosis/Arbitrum/Sepolia), the caller should narrow by
|
|
139
|
+
* chain using getTokenByAddress after resolving the chain-specific address
|
|
140
|
+
* via another channel.
|
|
141
|
+
*/
|
|
142
|
+
export declare function getTokenBySymbol(symbol: string): TokenInfo | null;
|
|
143
|
+
/**
|
|
144
|
+
* Resolve a user-supplied token identifier to a checksummed address.
|
|
145
|
+
* If input starts with 0x, returns it unchanged (caller's responsibility
|
|
146
|
+
* to pre-validate). Otherwise treats it as a symbol and resolves via
|
|
147
|
+
* getTokenBySymbol, throwing if unknown.
|
|
148
|
+
*/
|
|
149
|
+
export declare function resolveTokenAddress(input: string): string;
|
|
150
|
+
export declare function getTokenDecimals(address: string): number;
|
package/dist/chains.js
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Network Configuration
|
|
4
|
+
* Mirrors frontend networks.js for full parity on POP-deployed chains.
|
|
5
|
+
*
|
|
6
|
+
* Chains come in two flavors:
|
|
7
|
+
* 1. POP-deployed chains (Gnosis, Arbitrum, Sepolia, BaseSepolia) — full
|
|
8
|
+
* subgraph + deployment support. Set `isExternal: false` (default).
|
|
9
|
+
* 2. External chains (Ethereum mainnet, Optimism, Base, Polygon) — no POP
|
|
10
|
+
* deployment, no POP subgraph. Used by read-only commands like
|
|
11
|
+
* `pop org probe-access` to inspect foreign governance contracts
|
|
12
|
+
* (Compound Governor Bravo, Aave V3, Uniswap, etc). Set
|
|
13
|
+
* `isExternal: true` so subgraph sweepers skip them.
|
|
14
|
+
*
|
|
15
|
+
* Adding an external chain: set `isExternal: true`, leave `subgraphUrl: ''`,
|
|
16
|
+
* and use an empty `bountyTokens` map. Commands that require a POP subgraph
|
|
17
|
+
* (org activity, task lists, proposal history) will refuse to run on external
|
|
18
|
+
* chains — probe-access and other foreign-contract tools work fine.
|
|
19
|
+
*
|
|
20
|
+
* Env-derived resolution (getGatewaySubgraphUrl, resolveNetworkConfig) reads
|
|
21
|
+
* from an injected EnvSource — the CLI passes process.env; browser hosts pass
|
|
22
|
+
* whatever env object they assemble. Pure lookups need no env at all.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.PARTICIPATION_TOKEN_DECIMALS = exports.DEFAULT_DEPLOY_CHAIN_ID = exports.DEFAULT_DEPLOY_NETWORK = exports.HOME_CHAIN_ID = exports.HOME_NETWORK = exports.NETWORKS = exports.DEFAULT_GRAPH_GATEWAY_URL = void 0;
|
|
26
|
+
exports.getNetworkByChainId = getNetworkByChainId;
|
|
27
|
+
exports.getNetworkNameByChainId = getNetworkNameByChainId;
|
|
28
|
+
exports.isNetworkSupported = isNetworkSupported;
|
|
29
|
+
exports.getSubgraphUrl = getSubgraphUrl;
|
|
30
|
+
exports.getEnvInfixByChainId = getEnvInfixByChainId;
|
|
31
|
+
exports.getGatewaySubgraphUrl = getGatewaySubgraphUrl;
|
|
32
|
+
exports.getAllSubgraphUrls = getAllSubgraphUrls;
|
|
33
|
+
exports.resolveNetworkConfig = resolveNetworkConfig;
|
|
34
|
+
exports.getTokenByAddress = getTokenByAddress;
|
|
35
|
+
exports.getTokenBySymbol = getTokenBySymbol;
|
|
36
|
+
exports.resolveTokenAddress = resolveTokenAddress;
|
|
37
|
+
exports.getTokenDecimals = getTokenDecimals;
|
|
38
|
+
const env_1 = require("./env");
|
|
39
|
+
/**
|
|
40
|
+
* Base URL for The Graph's decentralised gateway. A full endpoint is
|
|
41
|
+
* `${base}/${gatewaySubgraphId}`. Override with POP_GRAPH_GATEWAY_URL to point
|
|
42
|
+
* at a self-hosted or regional gateway.
|
|
43
|
+
*
|
|
44
|
+
* NOTE: the LEGACY gateway form embedded the API key in the path
|
|
45
|
+
* (`/api/<KEY>/subgraphs/id/<ID>`). This modern form does not — the key travels
|
|
46
|
+
* in the Authorization header instead, so the URL is safe to print.
|
|
47
|
+
*/
|
|
48
|
+
exports.DEFAULT_GRAPH_GATEWAY_URL = 'https://gateway.thegraph.com/api/subgraphs/id';
|
|
49
|
+
exports.NETWORKS = {
|
|
50
|
+
arbitrum: {
|
|
51
|
+
chainId: 42161,
|
|
52
|
+
name: 'Arbitrum One',
|
|
53
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
|
54
|
+
rpcUrl: 'https://arbitrum-one-rpc.publicnode.com',
|
|
55
|
+
defaultLogsChunkBlocks: 2000,
|
|
56
|
+
blockExplorer: 'https://arbiscan.io',
|
|
57
|
+
isTestnet: false,
|
|
58
|
+
subgraphUrl: 'https://api.studio.thegraph.com/query/73367/poa-arb-v-1/version/latest',
|
|
59
|
+
// No gatewaySubgraphId: the Arbitrum deployment has not been published to
|
|
60
|
+
// the decentralised network (or its ID is not known here), so Arbitrum has
|
|
61
|
+
// no paid tier by default. Set POP_ARBITRUM_SUBGRAPH_ID once it is published.
|
|
62
|
+
bountyTokens: {
|
|
63
|
+
USDC: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
gnosis: {
|
|
67
|
+
chainId: 100,
|
|
68
|
+
name: 'Gnosis',
|
|
69
|
+
nativeCurrency: { name: 'xDAI', symbol: 'xDAI', decimals: 18 },
|
|
70
|
+
rpcUrl: 'https://rpc.gnosischain.com',
|
|
71
|
+
blockExplorer: 'https://gnosisscan.io',
|
|
72
|
+
isTestnet: false,
|
|
73
|
+
subgraphUrl: 'https://api.studio.thegraph.com/query/73367/poa-gnosis-v-1/version/latest',
|
|
74
|
+
// Verified against the live gateway: this ID serves the same deployment as
|
|
75
|
+
// the Studio URL above (identical `_meta.block` within one block).
|
|
76
|
+
gatewaySubgraphId: '576YA6oF16nA2uG5Q9KFfBSvJm4ZNKzWZkwh8eWXaxJs',
|
|
77
|
+
bountyTokens: {
|
|
78
|
+
BREAD: '0xa555d5344f6FB6c65da19e403Cb4c1eC4a1a5Ee3',
|
|
79
|
+
USDC: '0xDDAfbb505ad214D7b80b1f830fcCc89B60fB7A83',
|
|
80
|
+
WXDAI: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d',
|
|
81
|
+
sDAI: '0xaf204776c7245bF4147c2612BF6e5972Ee483701',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
sepolia: {
|
|
85
|
+
chainId: 11155111,
|
|
86
|
+
name: 'Sepolia',
|
|
87
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
|
88
|
+
rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',
|
|
89
|
+
blockExplorer: 'https://sepolia.etherscan.io',
|
|
90
|
+
isTestnet: true,
|
|
91
|
+
// No POP subgraph is deployed here — the Graph Studio deployment was removed (the frontend
|
|
92
|
+
// dropped these endpoints in its PR #441; the URL now answers "deployment does not exist").
|
|
93
|
+
// Empty means "RPC-only chain": getAllSubgraphUrls() filters on truthiness, and
|
|
94
|
+
// lib/subgraph.ts turns a subgraph-backed command into one actionable error.
|
|
95
|
+
subgraphUrl: '',
|
|
96
|
+
bountyTokens: {
|
|
97
|
+
USDC: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
baseSepolia: {
|
|
101
|
+
chainId: 84532,
|
|
102
|
+
name: 'Base Sepolia',
|
|
103
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
|
104
|
+
rpcUrl: 'https://base-sepolia-rpc.publicnode.com',
|
|
105
|
+
blockExplorer: 'https://sepolia.basescan.org',
|
|
106
|
+
isTestnet: true,
|
|
107
|
+
// No POP subgraph deployed — see the Sepolia note above.
|
|
108
|
+
subgraphUrl: '',
|
|
109
|
+
bountyTokens: {
|
|
110
|
+
USDC: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
// ---------------------------------------------------------------------
|
|
114
|
+
// External chains (HB#326, task #341) — read-only probe targets.
|
|
115
|
+
// POP is NOT deployed on any of these. Added so `pop org probe-access
|
|
116
|
+
// --chain <id>` works without the --rpc workaround from HB#336. See
|
|
117
|
+
// the NetworkConfig.isExternal field comment at the top of this file
|
|
118
|
+
// for the semantics.
|
|
119
|
+
// ---------------------------------------------------------------------
|
|
120
|
+
ethereum: {
|
|
121
|
+
chainId: 1,
|
|
122
|
+
name: 'Ethereum',
|
|
123
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
|
124
|
+
rpcUrl: 'https://ethereum.publicnode.com',
|
|
125
|
+
blockExplorer: 'https://etherscan.io',
|
|
126
|
+
isTestnet: false,
|
|
127
|
+
isExternal: true,
|
|
128
|
+
subgraphUrl: '',
|
|
129
|
+
bountyTokens: {},
|
|
130
|
+
},
|
|
131
|
+
optimism: {
|
|
132
|
+
chainId: 10,
|
|
133
|
+
name: 'Optimism',
|
|
134
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
|
135
|
+
rpcUrl: 'https://optimism-rpc.publicnode.com',
|
|
136
|
+
blockExplorer: 'https://optimistic.etherscan.io',
|
|
137
|
+
isTestnet: false,
|
|
138
|
+
isExternal: true,
|
|
139
|
+
defaultLogsChunkBlocks: 2000,
|
|
140
|
+
subgraphUrl: '',
|
|
141
|
+
bountyTokens: {},
|
|
142
|
+
},
|
|
143
|
+
base: {
|
|
144
|
+
chainId: 8453,
|
|
145
|
+
name: 'Base',
|
|
146
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
|
147
|
+
rpcUrl: 'https://base-rpc.publicnode.com',
|
|
148
|
+
blockExplorer: 'https://basescan.org',
|
|
149
|
+
isTestnet: false,
|
|
150
|
+
isExternal: true,
|
|
151
|
+
defaultLogsChunkBlocks: 2000,
|
|
152
|
+
subgraphUrl: '',
|
|
153
|
+
bountyTokens: {},
|
|
154
|
+
},
|
|
155
|
+
polygon: {
|
|
156
|
+
chainId: 137,
|
|
157
|
+
name: 'Polygon',
|
|
158
|
+
nativeCurrency: { name: 'MATIC', symbol: 'MATIC', decimals: 18 },
|
|
159
|
+
rpcUrl: 'https://polygon-bor-rpc.publicnode.com',
|
|
160
|
+
blockExplorer: 'https://polygonscan.com',
|
|
161
|
+
isTestnet: false,
|
|
162
|
+
isExternal: true,
|
|
163
|
+
subgraphUrl: '',
|
|
164
|
+
bountyTokens: {},
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
/** Home chain for accounts/passkeys */
|
|
168
|
+
exports.HOME_NETWORK = 'arbitrum';
|
|
169
|
+
exports.HOME_CHAIN_ID = exports.NETWORKS[exports.HOME_NETWORK].chainId;
|
|
170
|
+
/** Default chain for org deployment */
|
|
171
|
+
exports.DEFAULT_DEPLOY_NETWORK = 'gnosis';
|
|
172
|
+
exports.DEFAULT_DEPLOY_CHAIN_ID = exports.NETWORKS[exports.DEFAULT_DEPLOY_NETWORK].chainId;
|
|
173
|
+
function getNetworkByChainId(chainId) {
|
|
174
|
+
return Object.values(exports.NETWORKS).find(n => n.chainId === chainId) || null;
|
|
175
|
+
}
|
|
176
|
+
function getNetworkNameByChainId(chainId) {
|
|
177
|
+
const entry = Object.entries(exports.NETWORKS).find(([_, config]) => config.chainId === chainId);
|
|
178
|
+
return entry ? entry[0] : null;
|
|
179
|
+
}
|
|
180
|
+
function isNetworkSupported(chainId) {
|
|
181
|
+
return !!getNetworkByChainId(chainId);
|
|
182
|
+
}
|
|
183
|
+
function getSubgraphUrl(chainId) {
|
|
184
|
+
return getNetworkByChainId(chainId)?.subgraphUrl || exports.NETWORKS[exports.HOME_NETWORK].subgraphUrl;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* UPPER_SNAKE env-var infix for a chain: 84532 -> "BASE_SEPOLIA".
|
|
188
|
+
* Single source of truth for the `POP_<NET>_*` env convention so the RPC,
|
|
189
|
+
* subgraph and gateway lookups can never drift apart.
|
|
190
|
+
*/
|
|
191
|
+
function getEnvInfixByChainId(chainId) {
|
|
192
|
+
const name = getNetworkNameByChainId(chainId);
|
|
193
|
+
return name ? name.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase() : null;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Resolve the PAID (decentralised gateway) subgraph endpoint for a chain, or
|
|
197
|
+
* undefined when none is configured. Requires `GRAPH_API_KEY` at request time —
|
|
198
|
+
* this function only resolves the URL, it does not check for the key.
|
|
199
|
+
*
|
|
200
|
+
* Precedence (first non-empty wins):
|
|
201
|
+
* 1. `POP_<NET>_SUBGRAPH_GATEWAY` — explicit full URL
|
|
202
|
+
* 2. `POP_<NET>_SUBGRAPH_FALLBACK` — legacy name for the same thing
|
|
203
|
+
* 3. `POP_<NET>_SUBGRAPH_ID` — just the base58 ID, joined to the base
|
|
204
|
+
* 4. `NetworkConfig.gatewaySubgraphId` joined to the base
|
|
205
|
+
*
|
|
206
|
+
* The base is `POP_GRAPH_GATEWAY_URL` or DEFAULT_GRAPH_GATEWAY_URL. This
|
|
207
|
+
* replaces the old one-ad-hoc-env-var-per-chain arrangement where only Gnosis
|
|
208
|
+
* could ever reach the gateway.
|
|
209
|
+
*/
|
|
210
|
+
function getGatewaySubgraphUrl(chainId, env = env_1.EMPTY_ENV) {
|
|
211
|
+
const infix = getEnvInfixByChainId(chainId);
|
|
212
|
+
if (!infix)
|
|
213
|
+
return undefined;
|
|
214
|
+
const explicit = (env[`POP_${infix}_SUBGRAPH_GATEWAY`] || '').trim()
|
|
215
|
+
|| (env[`POP_${infix}_SUBGRAPH_FALLBACK`] || '').trim();
|
|
216
|
+
if (explicit)
|
|
217
|
+
return explicit;
|
|
218
|
+
const id = (env[`POP_${infix}_SUBGRAPH_ID`] || '').trim()
|
|
219
|
+
|| (getNetworkByChainId(chainId)?.gatewaySubgraphId || '').trim();
|
|
220
|
+
if (!id)
|
|
221
|
+
return undefined;
|
|
222
|
+
const base = ((env.POP_GRAPH_GATEWAY_URL || '').trim() || exports.DEFAULT_GRAPH_GATEWAY_URL).replace(/\/+$/, '');
|
|
223
|
+
return `${base}/${id}`;
|
|
224
|
+
}
|
|
225
|
+
function getAllSubgraphUrls() {
|
|
226
|
+
// External chains (Ethereum mainnet, Optimism, Base, Polygon) have no
|
|
227
|
+
// POP subgraph and are read-only probe targets only. Filter them out
|
|
228
|
+
// here so the subgraph sweeper never tries to query a nonexistent URL.
|
|
229
|
+
return Object.values(exports.NETWORKS)
|
|
230
|
+
.filter(n => !n.isTestnet && !n.isExternal && n.subgraphUrl)
|
|
231
|
+
.map(n => ({ chainId: n.chainId, url: n.subgraphUrl, name: n.name }));
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Resolve the effective network config using env vars + CLI overrides.
|
|
235
|
+
* Priority: CLI flag > per-chain env var > POP_DEFAULT_CHAIN env > error
|
|
236
|
+
*/
|
|
237
|
+
function resolveNetworkConfig(chainIdOverride, env = env_1.EMPTY_ENV) {
|
|
238
|
+
const chainId = chainIdOverride
|
|
239
|
+
|| (env.POP_DEFAULT_CHAIN ? parseInt(env.POP_DEFAULT_CHAIN, 10) : undefined);
|
|
240
|
+
if (!chainId) {
|
|
241
|
+
throw new Error('No chain specified. Set POP_DEFAULT_CHAIN in .env or pass --chain flag.');
|
|
242
|
+
}
|
|
243
|
+
const network = getNetworkByChainId(chainId);
|
|
244
|
+
if (!network) {
|
|
245
|
+
throw new Error(`Unsupported chain ID: ${chainId}. Supported: ${Object.values(exports.NETWORKS).map(n => `${n.name} (${n.chainId})`).join(', ')}`);
|
|
246
|
+
}
|
|
247
|
+
// Convert camelCase to UPPER_SNAKE: baseSepolia → BASE_SEPOLIA
|
|
248
|
+
const networkName = getEnvInfixByChainId(chainId);
|
|
249
|
+
// An override that is present-but-empty (`POP_SUBGRAPH_URL=` on its own line,
|
|
250
|
+
// which is exactly what the shipped .env templates contain) must NOT shadow
|
|
251
|
+
// the built-in default. `''` is already falsy, but trim first so a stray
|
|
252
|
+
// space or CR from a hand-edited .env behaves the same way.
|
|
253
|
+
const envUrl = (name) => {
|
|
254
|
+
const raw = env[name];
|
|
255
|
+
const trimmed = typeof raw === 'string' ? raw.trim() : '';
|
|
256
|
+
return trimmed || undefined;
|
|
257
|
+
};
|
|
258
|
+
const resolvedRpc = envUrl(`POP_${networkName}_RPC`)
|
|
259
|
+
|| (chainIdOverride ? undefined : envUrl('POP_RPC_URL'))
|
|
260
|
+
|| network.rpcUrl;
|
|
261
|
+
const resolvedSubgraph = envUrl(`POP_${networkName}_SUBGRAPH`)
|
|
262
|
+
|| (chainIdOverride ? undefined : envUrl('POP_SUBGRAPH_URL'))
|
|
263
|
+
|| network.subgraphUrl;
|
|
264
|
+
return { ...network, resolvedRpc, resolvedSubgraph };
|
|
265
|
+
}
|
|
266
|
+
/** Participation Token is always 18 decimals */
|
|
267
|
+
exports.PARTICIPATION_TOKEN_DECIMALS = 18;
|
|
268
|
+
/** Known tokens across all chains, keyed by lowercase address */
|
|
269
|
+
const KNOWN_TOKENS = {
|
|
270
|
+
// Arbitrum
|
|
271
|
+
'0xaf88d065e77c8cc2239327c5edb3a432268e5831': { symbol: 'USDC', decimals: 6, address: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' },
|
|
272
|
+
// Gnosis
|
|
273
|
+
'0xa555d5344f6fb6c65da19e403cb4c1ec4a1a5ee3': { symbol: 'BREAD', decimals: 18, address: '0xa555d5344f6FB6c65da19e403Cb4c1eC4a1a5Ee3' },
|
|
274
|
+
'0xddafbb505ad214d7b80b1f830fccc89b60fb7a83': { symbol: 'USDC', decimals: 6, address: '0xDDAfbb505ad214D7b80b1f830fcCc89B60fB7A83' },
|
|
275
|
+
'0xe91d153e0b41518a2ce8dd3d7944fa863463a97d': { symbol: 'WXDAI', decimals: 18, address: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d' },
|
|
276
|
+
// Sepolia
|
|
277
|
+
'0x1c7d4b196cb0c7b01d743fbc6116a902379c7238': { symbol: 'USDC', decimals: 6, address: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238' },
|
|
278
|
+
// Base Sepolia
|
|
279
|
+
'0x036cbd53842c5426634e7929541ec2318f3dcf7e': { symbol: 'USDC', decimals: 6, address: '0x036CbD53842c5426634e7929541eC2318f3dCF7e' },
|
|
280
|
+
};
|
|
281
|
+
function getTokenByAddress(address) {
|
|
282
|
+
return KNOWN_TOKENS[address.toLowerCase()] || null;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Reverse lookup by symbol. Case-insensitive. Returns the first matching
|
|
286
|
+
* token across all chains — if the same symbol exists on multiple chains
|
|
287
|
+
* (e.g. USDC on Gnosis/Arbitrum/Sepolia), the caller should narrow by
|
|
288
|
+
* chain using getTokenByAddress after resolving the chain-specific address
|
|
289
|
+
* via another channel.
|
|
290
|
+
*/
|
|
291
|
+
function getTokenBySymbol(symbol) {
|
|
292
|
+
const want = symbol.toUpperCase();
|
|
293
|
+
for (const t of Object.values(KNOWN_TOKENS)) {
|
|
294
|
+
if (t.symbol.toUpperCase() === want)
|
|
295
|
+
return t;
|
|
296
|
+
}
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Resolve a user-supplied token identifier to a checksummed address.
|
|
301
|
+
* If input starts with 0x, returns it unchanged (caller's responsibility
|
|
302
|
+
* to pre-validate). Otherwise treats it as a symbol and resolves via
|
|
303
|
+
* getTokenBySymbol, throwing if unknown.
|
|
304
|
+
*/
|
|
305
|
+
function resolveTokenAddress(input) {
|
|
306
|
+
if (input.startsWith('0x'))
|
|
307
|
+
return input;
|
|
308
|
+
const token = getTokenBySymbol(input);
|
|
309
|
+
if (!token) {
|
|
310
|
+
throw new Error(`Unknown token symbol: ${input}. Add it to config/tokens.ts or pass a 0x address.`);
|
|
311
|
+
}
|
|
312
|
+
return token.address;
|
|
313
|
+
}
|
|
314
|
+
function getTokenDecimals(address) {
|
|
315
|
+
const token = getTokenByAddress(address);
|
|
316
|
+
if (!token) {
|
|
317
|
+
throw new Error(`Unknown bounty token: ${address}. Add it to config/tokens.ts or use a known token.`);
|
|
318
|
+
}
|
|
319
|
+
return token.decimals;
|
|
320
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PopContext — the bag of injected services that resolved (async) builders and
|
|
3
|
+
* read helpers take as their first argument.
|
|
4
|
+
*
|
|
5
|
+
* Hosts construct it once: the CLI from process.env + its fs-backed tier
|
|
6
|
+
* store, a frontend from its wagmi/Apollo wiring, an integrator from nothing
|
|
7
|
+
* but a chainId. createPop() (index.ts) wraps one of these in a bound facade.
|
|
8
|
+
*/
|
|
9
|
+
import type { ethers } from 'ethers';
|
|
10
|
+
import { GraphClient } from './graph/client';
|
|
11
|
+
import type { GraphClientOptions } from './graph/client';
|
|
12
|
+
import type { IpfsOptions } from './ipfs';
|
|
13
|
+
import type { EnvSource } from './env';
|
|
14
|
+
export interface PopContext {
|
|
15
|
+
/** Subgraph reads (tier-routed). */
|
|
16
|
+
client: GraphClient;
|
|
17
|
+
/** Default chain for reads and address resolution. */
|
|
18
|
+
chainId?: number;
|
|
19
|
+
/** Only builders that feature-detect or preflight need a provider. */
|
|
20
|
+
provider?: ethers.providers.Provider;
|
|
21
|
+
/** Only builders that pin metadata need IPFS options. */
|
|
22
|
+
ipfs?: IpfsOptions;
|
|
23
|
+
/** Never read directly by domain code; passed to helpers that take env. */
|
|
24
|
+
env?: EnvSource;
|
|
25
|
+
}
|
|
26
|
+
export interface CreatePopContextOptions {
|
|
27
|
+
/** Default chain for reads and address resolution. */
|
|
28
|
+
chainId?: number;
|
|
29
|
+
/** Env overrides (endpoint/tier/IPFS vars). Pure defaults when omitted. */
|
|
30
|
+
env?: EnvSource;
|
|
31
|
+
/** Needed only for feature detection / preflight / live decimals reads. */
|
|
32
|
+
provider?: ethers.providers.Provider;
|
|
33
|
+
/** Graph transport overrides (state store, fetch, warn reporter). */
|
|
34
|
+
graph?: Omit<GraphClientOptions, 'env'>;
|
|
35
|
+
/** IPFS endpoints / readonly flag. */
|
|
36
|
+
ipfs?: IpfsOptions;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* One-call setup for integrators:
|
|
40
|
+
*
|
|
41
|
+
* const ctx = createPopContext({ chainId: 100 });
|
|
42
|
+
* const org = await resolveOrgModules(ctx.client, 'my-org');
|
|
43
|
+
* const intent = await createTaskIntent(ctx, { org: 'my-org', ... });
|
|
44
|
+
*
|
|
45
|
+
* Every resolved builder takes this ctx as its first argument; execution is
|
|
46
|
+
* host-chosen (executeIntent for ethers EOA, encodeIntent for anything else).
|
|
47
|
+
*/
|
|
48
|
+
export declare function createPopContext(options?: CreatePopContextOptions): PopContext;
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PopContext — the bag of injected services that resolved (async) builders and
|
|
4
|
+
* read helpers take as their first argument.
|
|
5
|
+
*
|
|
6
|
+
* Hosts construct it once: the CLI from process.env + its fs-backed tier
|
|
7
|
+
* store, a frontend from its wagmi/Apollo wiring, an integrator from nothing
|
|
8
|
+
* but a chainId. createPop() (index.ts) wraps one of these in a bound facade.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.createPopContext = createPopContext;
|
|
12
|
+
const client_1 = require("./graph/client");
|
|
13
|
+
/**
|
|
14
|
+
* One-call setup for integrators:
|
|
15
|
+
*
|
|
16
|
+
* const ctx = createPopContext({ chainId: 100 });
|
|
17
|
+
* const org = await resolveOrgModules(ctx.client, 'my-org');
|
|
18
|
+
* const intent = await createTaskIntent(ctx, { org: 'my-org', ... });
|
|
19
|
+
*
|
|
20
|
+
* Every resolved builder takes this ctx as its first argument; execution is
|
|
21
|
+
* host-chosen (executeIntent for ethers EOA, encodeIntent for anything else).
|
|
22
|
+
*/
|
|
23
|
+
function createPopContext(options = {}) {
|
|
24
|
+
// The context chain is also the client's default chain: reads documented as
|
|
25
|
+
// `fn(ctx.client, …)` must work without repeating the chainId per call.
|
|
26
|
+
const client = new client_1.GraphClient({
|
|
27
|
+
env: options.env,
|
|
28
|
+
defaultChainId: options.chainId,
|
|
29
|
+
...options.graph,
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
client,
|
|
33
|
+
chainId: options.chainId,
|
|
34
|
+
provider: options.provider,
|
|
35
|
+
ipfs: options.ipfs,
|
|
36
|
+
env: options.env,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract Utilities
|
|
3
|
+
* ABI lookup from the generated registry (no fs — browser-pure) and
|
|
4
|
+
* ethers Contract construction helpers.
|
|
5
|
+
*/
|
|
6
|
+
import { ethers } from 'ethers';
|
|
7
|
+
/**
|
|
8
|
+
* Look up an ABI by its historical abi/ file base name (e.g. 'TaskManagerNew').
|
|
9
|
+
* Searches first-party POP ABIs, then the third-party probe-target ABIs.
|
|
10
|
+
*
|
|
11
|
+
* Returns a mutable-typed array (the registry consts are readonly) so ethers v5
|
|
12
|
+
* Interface construction typechecks.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getAbi(name: string): any[];
|
|
15
|
+
/** Back-compat alias — the CLI's fs-based loader was named loadAbi. */
|
|
16
|
+
export declare const loadAbi: typeof getAbi;
|
|
17
|
+
/**
|
|
18
|
+
* Create a read-only contract instance.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createReadContract(address: string, abiName: string, provider: ethers.providers.Provider): ethers.Contract;
|
|
21
|
+
/**
|
|
22
|
+
* Create a writable contract instance (with signer).
|
|
23
|
+
*/
|
|
24
|
+
export declare function createWriteContract(address: string, abiName: string, signer: ethers.Signer): ethers.Contract;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Contract Utilities
|
|
4
|
+
* ABI lookup from the generated registry (no fs — browser-pure) and
|
|
5
|
+
* ethers Contract construction helpers.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.loadAbi = void 0;
|
|
9
|
+
exports.getAbi = getAbi;
|
|
10
|
+
exports.createReadContract = createReadContract;
|
|
11
|
+
exports.createWriteContract = createWriteContract;
|
|
12
|
+
const ethers_1 = require("ethers");
|
|
13
|
+
const abis_1 = require("./abis");
|
|
14
|
+
/**
|
|
15
|
+
* Look up an ABI by its historical abi/ file base name (e.g. 'TaskManagerNew').
|
|
16
|
+
* Searches first-party POP ABIs, then the third-party probe-target ABIs.
|
|
17
|
+
*
|
|
18
|
+
* Returns a mutable-typed array (the registry consts are readonly) so ethers v5
|
|
19
|
+
* Interface construction typechecks.
|
|
20
|
+
*/
|
|
21
|
+
function getAbi(name) {
|
|
22
|
+
const abi = abis_1.ALL_ABIS[name] ?? abis_1.EXTERNAL_ABIS[name];
|
|
23
|
+
if (!abi) {
|
|
24
|
+
throw new Error(`ABI not found: ${name}. Check that packages/core/src/abis exports it (yarn gen-abis).`);
|
|
25
|
+
}
|
|
26
|
+
return abi;
|
|
27
|
+
}
|
|
28
|
+
/** Back-compat alias — the CLI's fs-based loader was named loadAbi. */
|
|
29
|
+
exports.loadAbi = getAbi;
|
|
30
|
+
/**
|
|
31
|
+
* Create a read-only contract instance.
|
|
32
|
+
*/
|
|
33
|
+
function createReadContract(address, abiName, provider) {
|
|
34
|
+
return new ethers_1.ethers.Contract(address, getAbi(abiName), provider);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a writable contract instance (with signer).
|
|
38
|
+
*/
|
|
39
|
+
function createWriteContract(address, abiName, signer) {
|
|
40
|
+
return new ethers_1.ethers.Contract(address, getAbi(abiName), signer);
|
|
41
|
+
}
|