@0xsequence/catapult 1.2.1 → 1.3.2
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 +42 -14
- package/dist/commands/dry.d.ts.map +1 -1
- package/dist/commands/dry.js +3 -2
- package/dist/commands/dry.js.map +1 -1
- package/dist/commands/etherscan.d.ts.map +1 -1
- package/dist/commands/etherscan.js +24 -36
- package/dist/commands/etherscan.js.map +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +4 -2
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/utils.d.ts.map +1 -1
- package/dist/commands/utils.js +191 -0
- package/dist/commands/utils.js.map +1 -1
- package/dist/lib/__tests__/deployer.spec.js +1 -1
- package/dist/lib/__tests__/deployer.spec.js.map +1 -1
- package/dist/lib/__tests__/network-loader.spec.js +3 -2
- package/dist/lib/__tests__/network-loader.spec.js.map +1 -1
- package/dist/lib/__tests__/network-selection.spec.d.ts +2 -0
- package/dist/lib/__tests__/network-selection.spec.d.ts.map +1 -0
- package/dist/lib/__tests__/network-selection.spec.js +34 -0
- package/dist/lib/__tests__/network-selection.spec.js.map +1 -0
- package/dist/lib/core/__tests__/engine.spec.js +26 -2
- package/dist/lib/core/__tests__/engine.spec.js.map +1 -1
- package/dist/lib/core/__tests__/json-integration.spec.js +1 -1
- package/dist/lib/core/__tests__/json-integration.spec.js.map +1 -1
- package/dist/lib/core/__tests__/multi-platform-verification.spec.js +1 -1
- package/dist/lib/core/__tests__/multi-platform-verification.spec.js.map +1 -1
- package/dist/lib/core/__tests__/static-action.spec.js +1 -1
- package/dist/lib/core/__tests__/static-action.spec.js.map +1 -1
- package/dist/lib/core/engine.d.ts +9 -1
- package/dist/lib/core/engine.d.ts.map +1 -1
- package/dist/lib/core/engine.js +17 -4
- package/dist/lib/core/engine.js.map +1 -1
- package/dist/lib/deployer.d.ts.map +1 -1
- package/dist/lib/deployer.js +56 -2
- package/dist/lib/deployer.js.map +1 -1
- package/dist/lib/events/cli-adapter.d.ts.map +1 -1
- package/dist/lib/events/cli-adapter.js +16 -3
- package/dist/lib/events/cli-adapter.js.map +1 -1
- package/dist/lib/events/types.d.ts +18 -1
- package/dist/lib/events/types.d.ts.map +1 -1
- package/dist/lib/network-loader.d.ts.map +1 -1
- package/dist/lib/network-loader.js +1 -1
- package/dist/lib/network-loader.js.map +1 -1
- package/dist/lib/network-selection.d.ts +4 -0
- package/dist/lib/network-selection.d.ts.map +1 -0
- package/dist/lib/network-selection.js +49 -0
- package/dist/lib/network-selection.js.map +1 -0
- package/package.json +1 -1
- package/src/commands/dry.ts +4 -3
- package/src/commands/etherscan.ts +42 -42
- package/src/commands/run.ts +5 -3
- package/src/commands/utils.ts +163 -0
- package/src/lib/__tests__/deployer.spec.ts +1 -3
- package/src/lib/__tests__/network-loader.spec.ts +3 -2
- package/src/lib/__tests__/network-selection.spec.ts +41 -0
- package/src/lib/core/__tests__/engine.spec.ts +33 -2
- package/src/lib/core/__tests__/json-integration.spec.ts +1 -1
- package/src/lib/core/__tests__/multi-platform-verification.spec.ts +1 -1
- package/src/lib/core/__tests__/static-action.spec.ts +1 -1
- package/src/lib/core/engine.ts +26 -4
- package/src/lib/deployer.ts +68 -3
- package/src/lib/events/cli-adapter.ts +21 -5
- package/src/lib/events/types.ts +23 -0
- package/src/lib/network-loader.ts +2 -1
- package/src/lib/network-selection.ts +73 -0
- package/CONCEPT.md +0 -24
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Network } from './types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parses a comma-separated selector string into chain IDs, supporting numeric IDs and network names.
|
|
5
|
+
* - Numeric tokens (e.g., "1") are treated as chain IDs
|
|
6
|
+
* - String tokens (e.g., "mainnet") are matched against Network.name case-insensitively
|
|
7
|
+
* - When a name matches multiple networks, all of them are included
|
|
8
|
+
* - Order is preserved by token then by appearance order in `networks`
|
|
9
|
+
* - Duplicates are removed
|
|
10
|
+
*
|
|
11
|
+
* Throws if any token cannot be resolved to at least one chain ID.
|
|
12
|
+
*/
|
|
13
|
+
export function resolveSelectedChainIds(
|
|
14
|
+
selectors: string | undefined,
|
|
15
|
+
networks: Network[]
|
|
16
|
+
): number[] | undefined {
|
|
17
|
+
if (selectors == null) return undefined
|
|
18
|
+
const normalized = String(selectors).trim()
|
|
19
|
+
if (normalized.length === 0) return undefined
|
|
20
|
+
|
|
21
|
+
const tokens = normalized
|
|
22
|
+
.split(',')
|
|
23
|
+
.map(t => t.trim())
|
|
24
|
+
.filter(t => t.length > 0)
|
|
25
|
+
|
|
26
|
+
if (tokens.length === 0) return undefined
|
|
27
|
+
|
|
28
|
+
const result: number[] = []
|
|
29
|
+
const seen = new Set<number>()
|
|
30
|
+
|
|
31
|
+
for (const token of tokens) {
|
|
32
|
+
if (/^\d+$/.test(token)) {
|
|
33
|
+
const id = Number(token)
|
|
34
|
+
if (!seen.has(id)) {
|
|
35
|
+
seen.add(id)
|
|
36
|
+
result.push(id)
|
|
37
|
+
}
|
|
38
|
+
continue
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const tokenLc = token.toLowerCase()
|
|
42
|
+
const matches = networks.filter(n => n.name.toLowerCase() === tokenLc)
|
|
43
|
+
if (matches.length === 0) {
|
|
44
|
+
const available = Array.from(new Set(networks.map(n => n.name))).sort()
|
|
45
|
+
throw new Error(
|
|
46
|
+
`Unknown network selector "${token}". Use a chain ID (e.g., 1) or a network name. Available names: ${available.join(', ')}`
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
for (const net of matches) {
|
|
50
|
+
if (!seen.has(net.chainId)) {
|
|
51
|
+
seen.add(net.chainId)
|
|
52
|
+
result.push(net.chainId)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return result
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Resolves a single selector into one chain ID. If a name maps to multiple networks,
|
|
62
|
+
* returns the first matching network in the order provided.
|
|
63
|
+
*/
|
|
64
|
+
export function resolveSingleChainId(
|
|
65
|
+
selector: string | undefined,
|
|
66
|
+
networks: Network[]
|
|
67
|
+
): number | undefined {
|
|
68
|
+
const ids = resolveSelectedChainIds(selector, networks)
|
|
69
|
+
if (!ids || ids.length === 0) return undefined
|
|
70
|
+
return ids[0]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
package/CONCEPT.md
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Concept document - loosely defined idea
|
|
2
|
-
|
|
3
|
-
The idea of this project is to create a contract deployment and management framework. It is not intended to be authenticated; it is intended to replay contract deployments or pre-signed transactions, and more generally unauthenticated actions. The need for this project is that Sequence has a multitude of contracts, migrations, factories, etc., that need to be deployed every time a new chain pops up (or local testing is needed), and keeping track of all these chains and their current deployment status is tricky. This project allows for the creation of a single repository of YAML files that define what needs to be deployed, in what order, and what depends on what.
|
|
4
|
-
|
|
5
|
-
There should be two kinds of “actions” that can be defined for a deployment. One kind is “built-in” actions; these are defined by code. They include things like sending a transaction, sending a pre-signed transaction, calling the key machine, verifying a contract, calling a service, etc. They should be basic and primitive. Actions may return values—for example, a transaction hash when sending a transaction, or an ok/not-ok when verifying a contract, etc.
|
|
6
|
-
|
|
7
|
-
Another primitive should be “modifiers” or “composite values.” These are also implemented with code in the project. They include doing ABI encode, constructor-arg encode, comparing whether a value is high enough, performing math, etc. These are required because sometimes operations depend on a formula derived from another operation (let’s say a universal deployer needs to have X funds to deploy the factory using Nick’s method; you need to compute how much you have to transfer to reach the threshold, etc.). A more common scenario is having to do ABI.encode or constructors.
|
|
8
|
-
|
|
9
|
-
Ideally, these methods are pretty low-level, and most of the heavy lifting is done by “templates.” Templates are also actions, but they can be reused by other actions. For example, Sequence has its own factory contracts and deployers; we don’t want to define them in the project one by one. Instead, it would be best if these could be defined as templates and later reused, so adding more factory kinds does not require modifying this project and doing another release. It should be noted that sometimes factories themselves have to be deployed—for example, when we deploy the Sequence v1 factory we first have to deploy the universal deployer 2, and when we deploy the universal deployer 2 we first need the nano deployer, etc. So templates by themselves have a sort of “setup” factory.
|
|
10
|
-
|
|
11
|
-
Jobs are a collection of actions. Some jobs may depend on other jobs; some actions within a job may depend on actions from within the same job, but no actions from one job can depend on actions from another job (the whole job has to depend). Actions can reference output values from other jobs as long as they depend on them. This defines a sort of order graph on which jobs and actions need to be executed. Some jobs and some actions may be 100% independent of each other.
|
|
12
|
-
|
|
13
|
-
Networks can be defined in a `networks.yaml` file (or a directory with many networks; I am not sure yet). Each network has a name, explorer, chainId, and RPC. Networks may have modifiers, like how much gas has to be sent, etc., but by default the program should try to “guess it” by looking at past blocks. Jobs run by default on all networks unless some networks are excluded (`skip_networks`) or only some networks are requested (`only_networks`). These are arrays of chainIds in the YAML file.
|
|
14
|
-
|
|
15
|
-
Signers are abstracted with the idea that eventually this can run in a browser and a MetaMask-like wallet could perform the transactions (acting as the relayer or the sender), but for now we just implement an EOA signer, a private key that has to be passed, and it is expected to have the funds needed to execute all the transactions and fund everything that needs to be funded. The CLI just takes that as an ENV variable or a CLI argument.
|
|
16
|
-
|
|
17
|
-
One important aspect of the project is that it should simplify dealing with build artifacts, so it does not require too much manual work. The project should be able to reference any build artifact either by using the hash of the artifact (a hash that can be obtained with the command `bin artifacts hashes`) or by using the path to the artifact. Ideally, artifacts can be provided in different formats and the program just takes care of it; they could be JSON files, nested directories, JS files, etc. It should try to be as smart as possible in the sense that it just figures out the format.
|
|
18
|
-
|
|
19
|
-
Running the CLI generates an `output` directory with job results. This contains the latest run date, the list of chainIds where everything has been successful, and the outputs of all actions and templates that ran on those jobs; each job has its own file. If there have been any errors, no output is generated, and instead the CLI fails. The CLI can run any number of jobs at the same time, and it just figures it out.
|
|
20
|
-
|
|
21
|
-
The CLI also has methods to:
|
|
22
|
-
|
|
23
|
-
* dry-run and verify the correctness of the YAML definitions of a project
|
|
24
|
-
* obtain all the artifacts detected and their hashes
|