@aifinpay/deployments 1.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 +133 -0
- package/USAGE.md +534 -0
- package/dist/artifacts.d.ts +62 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +210 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/build.d.ts +2 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +25 -0
- package/dist/build.js.map +1 -0
- package/dist/grabber.d.ts +42 -0
- package/dist/grabber.d.ts.map +1 -0
- package/dist/grabber.js +379 -0
- package/dist/grabber.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/registry.d.ts +147 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +263 -0
- package/dist/registry.js.map +1 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/package.json +36 -0
- package/registry/abi/evm/B2BSplitterV14/B2BSplitterV14.json +1318 -0
- package/registry/abi/evm/TimelockWrapper/TimelockWrapper.json +277 -0
- package/registry/abi/tron/.gitkeep +0 -0
- package/registry/idl/aptos/.gitkeep +0 -0
- package/registry/idl/casper/.gitkeep +0 -0
- package/registry/idl/casper/aifinpay-casper-schema.json +108 -0
- package/registry/idl/solana/splitter-v14/splitter.devnet.json +1962 -0
- package/registry/idl/solana/splitter-v14/splitter.mainnet.json +1962 -0
- package/registry/splitter/INDEX.md +163 -0
- package/registry/splitter/casper/README.md +101 -0
- package/registry/splitter/casper/deployments.json +110 -0
- package/registry/splitter/evm/v1.1/README.md +32 -0
- package/registry/splitter/evm/v1.1/deployments.json +45 -0
- package/registry/splitter/evm/v1.2/README.md +47 -0
- package/registry/splitter/evm/v1.2/deployments.json +76 -0
- package/registry/splitter/evm/v1.3/README.md +78 -0
- package/registry/splitter/evm/v1.3/deployments.json +280 -0
- package/registry/splitter/evm/v1.4/README.md +75 -0
- package/registry/splitter/evm/v1.4/deployments.json +358 -0
- package/registry/splitter/solana/README.md +49 -0
- package/registry/splitter/solana/deployments.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# @aifinpay/deployments
|
|
2
|
+
|
|
3
|
+
## Deployment registry & artifact manager
|
|
4
|
+
|
|
5
|
+
This package provides a programmatic interface for querying AIFP deployment records and contract artifacts (ABI/IDL).
|
|
6
|
+
|
|
7
|
+
### Quick Start
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { AifinpayRegistry, ArtifactRegistry } from "@aifinpay/deployments";
|
|
11
|
+
|
|
12
|
+
// Load deployment registries
|
|
13
|
+
const evmRegistry = AifinpayRegistry.loadEvm("latest"); // or "1.4", "1.3", etc.
|
|
14
|
+
const solanaRegistry = AifinpayRegistry.loadSolana("latest");
|
|
15
|
+
|
|
16
|
+
// Load contract artifacts
|
|
17
|
+
const artifacts = ArtifactRegistry.load();
|
|
18
|
+
|
|
19
|
+
// Query deployments
|
|
20
|
+
const optimism = evmRegistry.getEvmDeployment(10);
|
|
21
|
+
const splitterAddr = evmRegistry.getSplitterAddress(10);
|
|
22
|
+
const stablecoins = evmRegistry.getStablecoins(10);
|
|
23
|
+
|
|
24
|
+
// Get supported chains
|
|
25
|
+
const chains = evmRegistry.getSupportedChains("enabled"); // [10, 137, ...]
|
|
26
|
+
const networks = evmRegistry.getNetworkList(); // [{ chainId, name, status, ... }]
|
|
27
|
+
|
|
28
|
+
// Export as markdown/json/csv
|
|
29
|
+
const markdown = evmRegistry.exportAsMarkdown("prod");
|
|
30
|
+
const json = evmRegistry.exportAsJson();
|
|
31
|
+
const csv = evmRegistry.exportAsCsv();
|
|
32
|
+
|
|
33
|
+
// Query artifacts
|
|
34
|
+
const abi = artifacts.getEvmAbi("B2BSplitterV14", "1.4");
|
|
35
|
+
const solanaIdl = artifacts.getSolanaIdl("mainnet");
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
See [USAGE.md](./USAGE.md) for complete documentation.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Registry grabber (legacy)
|
|
43
|
+
|
|
44
|
+
`src/grabber.ts` pulls the latest deployment records from the canonical
|
|
45
|
+
upstream repositories and produces per-ecosystem split registry files:
|
|
46
|
+
|
|
47
|
+
- EVM v1.4: `registry/splitter/evm/v1.4/deployments.json`
|
|
48
|
+
- Solana v1.4: `registry/splitter/solana/deployments.json`
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
cd deployments
|
|
52
|
+
npm ci --no-audit --no-fund
|
|
53
|
+
npm run build # compile TypeScript
|
|
54
|
+
npm run registry:build # fetch upstream + write registry/*.json
|
|
55
|
+
npm test # offline unit tests
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Registry layout
|
|
59
|
+
|
|
60
|
+
Per-ecosystem split files are the canonical artifacts. ABI and IDL
|
|
61
|
+
subdirectories are kept for downstream consumers that need raw contract
|
|
62
|
+
artifacts:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
registry/
|
|
66
|
+
├── splitter/ # versioned registry with governance metadata
|
|
67
|
+
│ ├── evm/
|
|
68
|
+
│ │ ├── v1.4/deployments.json # EVM v1.4 full contract suite
|
|
69
|
+
│ │ ├── v1.3/deployments.json # EVM v1.3 route table
|
|
70
|
+
│ │ ├── v1.2/deployments.json # EVM v1.2 legacy
|
|
71
|
+
│ │ └── v1.1/deployments.json # EVM v1.1 legacy
|
|
72
|
+
│ ├── solana/deployments.json # Solana v1.4 program deployments
|
|
73
|
+
│ └── casper/deployments.json # Casper deployments
|
|
74
|
+
├── abi/
|
|
75
|
+
│ ├── evm/ # EVM ABI bundles (B2BSplitterV14, TimelockWrapper)
|
|
76
|
+
│ └── tron/ # Tron ABI bundles when applicable
|
|
77
|
+
└── idl/
|
|
78
|
+
├── solana/ # Solana IDL (splitter-v14 mainnet/devnet)
|
|
79
|
+
├── aptos/ # Aptos IDL artifacts
|
|
80
|
+
└── casper/ # Casper IDL artifacts
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Version history
|
|
84
|
+
|
|
85
|
+
| Registry | Location | Versions | Status |
|
|
86
|
+
|---|---|---|---|
|
|
87
|
+
| Legacy route table | `registry/splitter/evm/v1.3` | v1.2 `legacy`, v1.3 `merchant-aifp1` / `agent-x402` | Superseded; kept for `node/` SDK generation |
|
|
88
|
+
| Legacy v1.2 | `registry/splitter/evm/v1.2` | v1.2 with `paymentId` replay guard | Superseded |
|
|
89
|
+
| Legacy v1.1 | `registry/splitter/evm/v1.1` | v1.1 initial release | Superseded |
|
|
90
|
+
| This package | `registry/splitter/evm/v1.4/deployments.json` | v1.4 EVM | Active grabber output |
|
|
91
|
+
| This package | `registry/splitter/solana/deployments.json` | v1.4 Solana | Active grabber output |
|
|
92
|
+
|
|
93
|
+
## Exports
|
|
94
|
+
|
|
95
|
+
### Deployment Registry
|
|
96
|
+
|
|
97
|
+
- `AifinpayRegistry.loadEvm(version?)` — load EVM deployment registry (default: "latest" = "1.4")
|
|
98
|
+
- `AifinpayRegistry.loadSolana(version?)` — load Solana deployment registry (default: "latest" = "1.4")
|
|
99
|
+
- `getEvmDeployment(chainId)` — O(1) lookup by chain ID
|
|
100
|
+
- `getEvmByNetwork(network)` — lookup by network name
|
|
101
|
+
- `getSplitterAddress(chainId)`, `getTokenListAddress(chainId)`, `getProfilesAddress(chainId)` — contract addresses
|
|
102
|
+
- `getStablecoins(chainId)` — stablecoin list
|
|
103
|
+
- `isSettlementEnabled(chainId)` — settlement status
|
|
104
|
+
- `getGovernanceSafe(env)` — Safe multisig address
|
|
105
|
+
- `filterByStatus(status)`, `getProdDeployments()`, `getTestnetDeployments()` — filtering
|
|
106
|
+
- `getSupportedChains(filter?)` — get list of supported chain IDs (filter: "all" | "prod" | "testnet" | "enabled")
|
|
107
|
+
- `getNetworkList(filter?)` — get network list with metadata
|
|
108
|
+
- `isChainSupported(chainId)` — check if chain is supported
|
|
109
|
+
- `getChainIdByNetwork(network)` — get chain ID by name
|
|
110
|
+
- `getNetworkByChainId(chainId)` — get network name by ID
|
|
111
|
+
- `exportAsMarkdown(filter?)`, `exportAsJson(filter?)`, `exportAsCsv(filter?)` — export formats
|
|
112
|
+
|
|
113
|
+
### Artifact Registry
|
|
114
|
+
|
|
115
|
+
- `ArtifactRegistry.load()` — load all ABI/IDL artifacts
|
|
116
|
+
- `getEvmAbi(contractName, version?)` — EVM ABI
|
|
117
|
+
- `getSolanaIdl(cluster)` — Solana IDL (mainnet/devnet)
|
|
118
|
+
- `getCasperIdl(network)` — Casper IDL (mainnet/testnet)
|
|
119
|
+
- `getAptosIdl(contractName, version?)` — Aptos IDL
|
|
120
|
+
- `getTronAbi(contractName, version?)` — Tron ABI
|
|
121
|
+
|
|
122
|
+
### Legacy grabber (deprecated)
|
|
123
|
+
|
|
124
|
+
- `buildRegistry()` — fetch upstream EVM + Solana records (deprecated: use `AifinpayRegistry.loadEvm()`)
|
|
125
|
+
- `writeSplitRegistries(registry, outDir)` — write split registry files
|
|
126
|
+
- `grabEvmDeployments()` / `grabSolanaDeployments()` — grab one chain family
|
|
127
|
+
- `getEvmDeployment(registry, chainId)` / `getSolanaDeployment(registry, cluster)` — O(1) lookup helpers
|
|
128
|
+
- `isEvmDeployment(d)` / `isSolanaDeployment(d)` — type guards
|
|
129
|
+
|
|
130
|
+
### Types
|
|
131
|
+
|
|
132
|
+
- `DeploymentRegistry`, `EcosystemRegistry`, `Deployment`, `EvmDeployment`, `SolanaDeployment`, `Stablecoin`
|
|
133
|
+
- `EvmDeploymentRecord`, `SolanaDeploymentRecord`, `EvmAbiArtifact`, `SolanaIdlArtifact`
|
package/USAGE.md
ADDED
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
# @aifinpay/deployments — Usage Guide
|
|
2
|
+
|
|
3
|
+
Programmatic interface for querying AIFP deployment records and contract artifacts (ABI/IDL).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @aifinpay/deployments
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { AifinpayRegistry, ArtifactRegistry } from "@aifinpay/deployments";
|
|
15
|
+
|
|
16
|
+
// Load registries
|
|
17
|
+
const evmRegistry = AifinpayRegistry.loadEvm(); // latest = v1.4
|
|
18
|
+
const solanaRegistry = AifinpayRegistry.loadSolana(); // latest = v1.4
|
|
19
|
+
const artifacts = ArtifactRegistry.load();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## AifinpayRegistry — Deployment Records
|
|
25
|
+
|
|
26
|
+
### Load EVM Registry
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
// Load latest version (v1.4)
|
|
30
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
31
|
+
|
|
32
|
+
// Load specific version
|
|
33
|
+
const v14 = AifinpayRegistry.loadEvm("1.4");
|
|
34
|
+
const v13 = AifinpayRegistry.loadEvm("1.3");
|
|
35
|
+
const v12 = AifinpayRegistry.loadEvm("1.2");
|
|
36
|
+
const v11 = AifinpayRegistry.loadEvm("1.1");
|
|
37
|
+
|
|
38
|
+
// Explicit latest
|
|
39
|
+
const latest = AifinpayRegistry.loadEvm("latest");
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Load Solana Registry
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// Load latest version (v1.4)
|
|
46
|
+
const registry = AifinpayRegistry.loadSolana();
|
|
47
|
+
|
|
48
|
+
// Explicit version
|
|
49
|
+
const v14 = AifinpayRegistry.loadSolana("1.4");
|
|
50
|
+
const latest = AifinpayRegistry.loadSolana("latest");
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Query Deployments
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
57
|
+
|
|
58
|
+
// Get deployment by chain ID
|
|
59
|
+
const optimism = registry.getEvmDeployment(10);
|
|
60
|
+
if (optimism) {
|
|
61
|
+
console.log(optimism.chain); // "optimism"
|
|
62
|
+
console.log(optimism.status); // "enabled"
|
|
63
|
+
console.log(optimism.contracts); // { splitter, tokenList, profiles, ... }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Get deployment by network name
|
|
67
|
+
const polygon = registry.getEvmByNetwork("polygon");
|
|
68
|
+
console.log(polygon?.chainId); // 137
|
|
69
|
+
|
|
70
|
+
// Get all deployments
|
|
71
|
+
const all = registry.getAllEvmDeployments();
|
|
72
|
+
|
|
73
|
+
// Filter by status
|
|
74
|
+
const enabled = registry.filterByStatus("enabled");
|
|
75
|
+
const disabled = registry.filterByStatus("disabled");
|
|
76
|
+
|
|
77
|
+
// Get prod/testnet deployments
|
|
78
|
+
const prod = registry.getProdDeployments();
|
|
79
|
+
const testnet = registry.getTestnetDeployments();
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Contract Addresses
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
86
|
+
const chainId = 10; // Optimism
|
|
87
|
+
|
|
88
|
+
// Get contract addresses
|
|
89
|
+
const splitter = registry.getSplitterAddress(chainId);
|
|
90
|
+
const tokenList = registry.getTokenListAddress(chainId);
|
|
91
|
+
const profiles = registry.getProfilesAddress(chainId);
|
|
92
|
+
|
|
93
|
+
// All return null if not found
|
|
94
|
+
const unknown = registry.getSplitterAddress(99999); // null
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Stablecoins
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
101
|
+
const chainId = 10; // Optimism
|
|
102
|
+
|
|
103
|
+
const stablecoins = registry.getStablecoins(chainId);
|
|
104
|
+
// Returns: Array<{ symbol: string, name: string, address: string }>
|
|
105
|
+
|
|
106
|
+
for (const coin of stablecoins) {
|
|
107
|
+
console.log(`${coin.symbol}: ${coin.address}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Empty array if chain not found
|
|
111
|
+
const empty = registry.getStablecoins(99999); // []
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Settlement Status
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
118
|
+
|
|
119
|
+
// Check if settlement is enabled
|
|
120
|
+
const enabled = registry.isSettlementEnabled(10); // true/false
|
|
121
|
+
|
|
122
|
+
// Returns false for unknown chains
|
|
123
|
+
const disabled = registry.isSettlementEnabled(99999); // false
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Governance
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
130
|
+
|
|
131
|
+
// Get Safe multisig addresses
|
|
132
|
+
const prodSafe = registry.getGovernanceSafe("prod");
|
|
133
|
+
const testnetSafe = registry.getGovernanceSafe("testnet");
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Registry Metadata
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
140
|
+
|
|
141
|
+
console.log(registry.getVersion()); // "1.4"
|
|
142
|
+
console.log(registry.getGeneratedAt()); // ISO 8601 timestamp
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Supported Chains
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
149
|
+
|
|
150
|
+
// Get all supported chain IDs
|
|
151
|
+
const allChains = registry.getSupportedChains(); // [1, 10, 137, ...]
|
|
152
|
+
|
|
153
|
+
// Get only production chains
|
|
154
|
+
const prodChains = registry.getSupportedChains("prod");
|
|
155
|
+
|
|
156
|
+
// Get only testnet chains
|
|
157
|
+
const testnetChains = registry.getSupportedChains("testnet");
|
|
158
|
+
|
|
159
|
+
// Get only enabled chains (status = "enabled" AND settlementEnabled = true)
|
|
160
|
+
const enabledChains = registry.getSupportedChains("enabled");
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Network List
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
167
|
+
|
|
168
|
+
// Get network list with metadata
|
|
169
|
+
const networks = registry.getNetworkList();
|
|
170
|
+
// Returns: Array<{ chainId, name, status, settlementEnabled, testnet }>
|
|
171
|
+
|
|
172
|
+
for (const network of networks) {
|
|
173
|
+
console.log(`${network.name} (chainId: ${network.chainId}): ${network.status}`);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Filter by production only
|
|
177
|
+
const prodNetworks = registry.getNetworkList("prod");
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Chain Helpers
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
184
|
+
|
|
185
|
+
// Check if a chain is supported
|
|
186
|
+
const isSupported = registry.isChainSupported(10); // true/false
|
|
187
|
+
|
|
188
|
+
// Get chain ID by network name
|
|
189
|
+
const optimismId = registry.getChainIdByNetwork("optimism"); // 10
|
|
190
|
+
|
|
191
|
+
// Get network name by chain ID
|
|
192
|
+
const networkName = registry.getNetworkByChainId(10); // "optimism"
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Export Formats
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
199
|
+
|
|
200
|
+
// Export as markdown table
|
|
201
|
+
const markdown = registry.exportAsMarkdown();
|
|
202
|
+
console.log(markdown);
|
|
203
|
+
// | Chain ID | Network | Status | Settlement | Testnet |
|
|
204
|
+
// |----------|---------|--------|------------|---------|
|
|
205
|
+
// | 10 | optimism | enabled | ✅ | No |
|
|
206
|
+
// | 137 | polygon | enabled | ✅ | No |
|
|
207
|
+
|
|
208
|
+
// Export filtered markdown
|
|
209
|
+
const prodMarkdown = registry.exportAsMarkdown("prod");
|
|
210
|
+
const enabledMarkdown = registry.exportAsMarkdown("enabled");
|
|
211
|
+
|
|
212
|
+
// Export as JSON
|
|
213
|
+
const json = registry.exportAsJson();
|
|
214
|
+
console.log(json);
|
|
215
|
+
// [{"chainId":10,"name":"optimism","status":"enabled",...}, ...]
|
|
216
|
+
|
|
217
|
+
// Export as CSV
|
|
218
|
+
const csv = registry.exportAsCsv();
|
|
219
|
+
console.log(csv);
|
|
220
|
+
// chainId,name,status,settlementEnabled,testnet
|
|
221
|
+
// 10,optimism,enabled,true,false
|
|
222
|
+
// 137,polygon,enabled,true,false
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## ArtifactRegistry — ABI/IDL Artifacts
|
|
228
|
+
|
|
229
|
+
### Load Artifacts
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
const artifacts = ArtifactRegistry.load();
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### EVM ABI
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
const artifacts = ArtifactRegistry.load();
|
|
239
|
+
|
|
240
|
+
// Get ABI by contract name and version
|
|
241
|
+
const abi = artifacts.getEvmAbi("B2BSplitterV14", "1.4");
|
|
242
|
+
if (abi) {
|
|
243
|
+
console.log(abi.contractName); // "B2BSplitterV14"
|
|
244
|
+
console.log(abi.version); // "1.4"
|
|
245
|
+
console.log(abi.abi); // ABI array
|
|
246
|
+
console.log(abi.bytecode); // Optional bytecode
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Default version (1.4)
|
|
250
|
+
const defaultAbi = artifacts.getEvmAbi("B2BSplitterV14");
|
|
251
|
+
|
|
252
|
+
// Get all ABIs
|
|
253
|
+
const allAbis = artifacts.getAllEvmAbis();
|
|
254
|
+
|
|
255
|
+
// Returns null if not found
|
|
256
|
+
const unknown = artifacts.getEvmAbi("UnknownContract"); // null
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Solana IDL
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
const artifacts = ArtifactRegistry.load();
|
|
263
|
+
|
|
264
|
+
// Get IDL by cluster
|
|
265
|
+
const mainnetIdl = artifacts.getSolanaIdl("mainnet");
|
|
266
|
+
const devnetIdl = artifacts.getSolanaIdl("devnet");
|
|
267
|
+
|
|
268
|
+
if (mainnetIdl) {
|
|
269
|
+
console.log(mainnetIdl.programName); // "splitter"
|
|
270
|
+
console.log(mainnetIdl.version); // "1.4"
|
|
271
|
+
console.log(mainnetIdl.cluster); // "mainnet"
|
|
272
|
+
console.log(mainnetIdl.idl); // Full IDL object
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Get all IDLs
|
|
276
|
+
const allIdls = artifacts.getAllSolanaIdls();
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Casper IDL
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
const artifacts = ArtifactRegistry.load();
|
|
283
|
+
|
|
284
|
+
// Get IDL by network
|
|
285
|
+
const testnetIdl = artifacts.getCasperIdl("testnet");
|
|
286
|
+
const mainnetIdl = artifacts.getCasperIdl("mainnet");
|
|
287
|
+
|
|
288
|
+
// Get all Casper IDLs
|
|
289
|
+
const allIdls = artifacts.getAllCasperIdls();
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Aptos IDL
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
const artifacts = ArtifactRegistry.load();
|
|
296
|
+
|
|
297
|
+
// Get IDL by contract name
|
|
298
|
+
const splitterIdl = artifacts.getAptosIdl("splitter");
|
|
299
|
+
|
|
300
|
+
// Get specific version
|
|
301
|
+
const versionedIdl = artifacts.getAptosIdl("splitter", "1.4");
|
|
302
|
+
|
|
303
|
+
// Get all Aptos IDLs
|
|
304
|
+
const allIdls = artifacts.getAllAptosIdls();
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Tron ABI
|
|
308
|
+
|
|
309
|
+
```typescript
|
|
310
|
+
const artifacts = ArtifactRegistry.load();
|
|
311
|
+
|
|
312
|
+
// Get ABI by contract name
|
|
313
|
+
const splitterAbi = artifacts.getTronAbi("B2BSplitter");
|
|
314
|
+
|
|
315
|
+
// Get specific version
|
|
316
|
+
const versionedAbi = artifacts.getTronAbi("B2BSplitter", "1.4");
|
|
317
|
+
|
|
318
|
+
// Get all Tron ABIs
|
|
319
|
+
const allAbis = artifacts.getAllTronAbis();
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Complete Examples
|
|
325
|
+
|
|
326
|
+
### Setup Payment on Chain
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
import { AifinpayRegistry, ArtifactRegistry } from "@aifinpay/deployments";
|
|
330
|
+
|
|
331
|
+
async function setupPayment(chainId: number) {
|
|
332
|
+
// Load registries
|
|
333
|
+
const evmRegistry = AifinpayRegistry.loadEvm();
|
|
334
|
+
const artifacts = ArtifactRegistry.load();
|
|
335
|
+
|
|
336
|
+
// Get deployment
|
|
337
|
+
const deployment = evmRegistry.getEvmDeployment(chainId);
|
|
338
|
+
if (!deployment) {
|
|
339
|
+
throw new Error(`No deployment for chain ${chainId}`);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Check settlement status
|
|
343
|
+
if (!evmRegistry.isSettlementEnabled(chainId)) {
|
|
344
|
+
throw new Error(`Settlement disabled on chain ${chainId}`);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Get contract addresses
|
|
348
|
+
const splitterAddress = evmRegistry.getSplitterAddress(chainId);
|
|
349
|
+
const tokenListAddress = evmRegistry.getTokenListAddress(chainId);
|
|
350
|
+
|
|
351
|
+
// Get stablecoins
|
|
352
|
+
const stablecoins = evmRegistry.getStablecoins(chainId);
|
|
353
|
+
console.log(`Available stablecoins: ${stablecoins.map(s => s.symbol).join(", ")}`);
|
|
354
|
+
|
|
355
|
+
// Get ABI for contract interaction
|
|
356
|
+
const abi = artifacts.getEvmAbi("B2BSplitterV14", "1.4");
|
|
357
|
+
if (!abi) {
|
|
358
|
+
throw new Error("ABI not found");
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Get governance info
|
|
362
|
+
const prodSafe = evmRegistry.getGovernanceSafe("prod");
|
|
363
|
+
console.log(`Governance Safe: ${prodSafe}`);
|
|
364
|
+
|
|
365
|
+
return {
|
|
366
|
+
deployment,
|
|
367
|
+
splitterAddress,
|
|
368
|
+
tokenListAddress,
|
|
369
|
+
stablecoins,
|
|
370
|
+
abi: abi.abi,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Usage
|
|
375
|
+
const config = await setupPayment(10); // Optimism
|
|
376
|
+
console.log(config);
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### Generate Supported Chains Documentation
|
|
380
|
+
|
|
381
|
+
```typescript
|
|
382
|
+
import { AifinpayRegistry } from "@aifinpay/deployments";
|
|
383
|
+
|
|
384
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
385
|
+
|
|
386
|
+
// Generate markdown table for README
|
|
387
|
+
const markdown = registry.exportAsMarkdown("prod");
|
|
388
|
+
console.log(markdown);
|
|
389
|
+
// | Chain ID | Network | Status | Settlement | Testnet |
|
|
390
|
+
// |----------|-----------|---------|------------|---------|
|
|
391
|
+
// | 10 | optimism | enabled | ✅ | No |
|
|
392
|
+
// | 137 | polygon | enabled | ✅ | No |
|
|
393
|
+
|
|
394
|
+
// Generate JSON for API response
|
|
395
|
+
const json = registry.exportAsJson("enabled");
|
|
396
|
+
console.log(json);
|
|
397
|
+
|
|
398
|
+
// Generate CSV for spreadsheet
|
|
399
|
+
const csv = registry.exportAsCsv();
|
|
400
|
+
console.log(csv);
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### Check Chain Support
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
import { AifinpayRegistry } from "@aifinpay/deployments";
|
|
407
|
+
|
|
408
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
409
|
+
|
|
410
|
+
// Check if specific chains are supported
|
|
411
|
+
const supportedChains = [1, 10, 137, 8453];
|
|
412
|
+
for (const chainId of supportedChains) {
|
|
413
|
+
const name = registry.getNetworkByChainId(chainId);
|
|
414
|
+
const isSupported = registry.isChainSupported(chainId);
|
|
415
|
+
console.log(`Chain ${chainId} (${name}): ${isSupported ? "✅" : "❌"}`);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// Get chain ID for network name
|
|
419
|
+
const optimismId = registry.getChainIdByNetwork("optimism");
|
|
420
|
+
console.log(`Optimism chain ID: ${optimismId}`); // 10
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
## Error Handling
|
|
426
|
+
|
|
427
|
+
```typescript
|
|
428
|
+
const registry = AifinpayRegistry.loadEvm();
|
|
429
|
+
|
|
430
|
+
// Methods return null for not found
|
|
431
|
+
const deployment = registry.getEvmDeployment(99999);
|
|
432
|
+
if (deployment === null) {
|
|
433
|
+
console.log("Chain not supported");
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// Methods return empty arrays for not found
|
|
437
|
+
const stablecoins = registry.getStablecoins(99999);
|
|
438
|
+
if (stablecoins.length === 0) {
|
|
439
|
+
console.log("No stablecoins configured");
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// Settlement returns false for unknown chains
|
|
443
|
+
const enabled = registry.isSettlementEnabled(99999);
|
|
444
|
+
if (!enabled) {
|
|
445
|
+
console.log("Settlement not available");
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
---
|
|
450
|
+
|
|
451
|
+
## TypeScript Types
|
|
452
|
+
|
|
453
|
+
```typescript
|
|
454
|
+
import type {
|
|
455
|
+
EvmDeploymentRecord,
|
|
456
|
+
SolanaDeploymentRecord,
|
|
457
|
+
EvmAbiArtifact,
|
|
458
|
+
SolanaIdlArtifact,
|
|
459
|
+
} from "@aifinpay/deployments";
|
|
460
|
+
|
|
461
|
+
// EVM deployment record
|
|
462
|
+
interface EvmDeploymentRecord {
|
|
463
|
+
chain: string;
|
|
464
|
+
chainId: number;
|
|
465
|
+
environment: "dev" | "prod";
|
|
466
|
+
testnet: boolean;
|
|
467
|
+
status: "enabled" | "disabled" | "invalid" | "retired";
|
|
468
|
+
settlementEnabled: boolean;
|
|
469
|
+
contracts: {
|
|
470
|
+
splitter: string;
|
|
471
|
+
tokenList: string;
|
|
472
|
+
profiles: string;
|
|
473
|
+
admin: string;
|
|
474
|
+
signer: string;
|
|
475
|
+
pauser: string;
|
|
476
|
+
treasury: string;
|
|
477
|
+
};
|
|
478
|
+
assets: Array<{
|
|
479
|
+
symbol: string;
|
|
480
|
+
name: string;
|
|
481
|
+
address: string;
|
|
482
|
+
}>;
|
|
483
|
+
safe: {
|
|
484
|
+
address: string;
|
|
485
|
+
version: string;
|
|
486
|
+
threshold: number;
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// EVM ABI artifact
|
|
491
|
+
interface EvmAbiArtifact {
|
|
492
|
+
contractName: string;
|
|
493
|
+
version: string;
|
|
494
|
+
abi: unknown[];
|
|
495
|
+
bytecode?: string;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// Solana IDL artifact
|
|
499
|
+
interface SolanaIdlArtifact {
|
|
500
|
+
programName: string;
|
|
501
|
+
version: string;
|
|
502
|
+
cluster: "mainnet" | "devnet";
|
|
503
|
+
idl: unknown;
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
---
|
|
508
|
+
|
|
509
|
+
## Registry Structure
|
|
510
|
+
|
|
511
|
+
The package ships with pre-built registry files:
|
|
512
|
+
|
|
513
|
+
```
|
|
514
|
+
registry/
|
|
515
|
+
├── splitter/
|
|
516
|
+
│ ├── evm/
|
|
517
|
+
│ │ ├── v1.4/deployments.json # Latest EVM
|
|
518
|
+
│ │ ├── v1.3/deployments.json # Historical
|
|
519
|
+
│ │ ├── v1.2/deployments.json # Historical
|
|
520
|
+
│ │ └── v1.1/deployments.json # Historical
|
|
521
|
+
│ └── solana/
|
|
522
|
+
│ └── deployments.json # Solana v1.4
|
|
523
|
+
├── abi/
|
|
524
|
+
│ ├── evm/
|
|
525
|
+
│ │ ├── B2BSplitterV14/
|
|
526
|
+
│ │ └── TimelockWrapper/
|
|
527
|
+
│ └── tron/
|
|
528
|
+
└── idl/
|
|
529
|
+
├── solana/splitter-v14/
|
|
530
|
+
├── casper/
|
|
531
|
+
└── aptos/
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
Use `loadEvm("1.4")` for the latest EVM version, or specify an older version for legacy deployments.
|