droplinked-web3-kit 0.0.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/README.md +400 -0
- package/index.d.ts +1 -0
- package/index.js +54 -0
- package/index.mjs +78904 -0
- package/lib/chains/chain-provider.d.ts +18 -0
- package/lib/chains/dto/chains.d.ts +46 -0
- package/lib/chains/dto/configs/chain.config.d.ts +11 -0
- package/lib/chains/dto/configs/chainlink-addresses.d.ts +23 -0
- package/lib/chains/dto/configs/web3-config.d.ts +46 -0
- package/lib/chains/dto/constants/airdrop-abi.d.ts +32 -0
- package/lib/chains/dto/constants/chain-abis.d.ts +323 -0
- package/lib/chains/dto/constants/chain-constants.d.ts +12 -0
- package/lib/chains/dto/constants/chain-structs.d.ts +73 -0
- package/lib/chains/dto/errors/chain-errors.d.ts +119 -0
- package/lib/chains/dto/helpers/get-shop-info.d.ts +33 -0
- package/lib/chains/dto/interfaces/airdrop-token.interface.d.ts +37 -0
- package/lib/chains/dto/interfaces/chain-payment.interface.d.ts +10 -0
- package/lib/chains/dto/interfaces/chain-provider.interface.d.ts +38 -0
- package/lib/chains/dto/interfaces/claim-nft-inputs.d.ts +16 -0
- package/lib/chains/dto/interfaces/deploy-shop.interface.d.ts +6 -0
- package/lib/chains/dto/interfaces/login-result.interface.d.ts +6 -0
- package/lib/chains/dto/interfaces/modal-interface.interface.d.ts +13 -0
- package/lib/chains/dto/interfaces/payment-interface.d.ts +7 -0
- package/lib/chains/dto/interfaces/record-web3-product.interface.d.ts +16 -0
- package/lib/chains/dto/interfaces/web3-context.interface.d.ts +10 -0
- package/lib/chains/providers/evm/evm-airdrop.d.ts +7 -0
- package/lib/chains/providers/evm/evm-claim-nfts.d.ts +6 -0
- package/lib/chains/providers/evm/evm-constants.d.ts +18 -0
- package/lib/chains/providers/evm/evm-deploy-shop.d.ts +6 -0
- package/lib/chains/providers/evm/evm-login.d.ts +18 -0
- package/lib/chains/providers/evm/evm-payments.d.ts +15 -0
- package/lib/chains/providers/evm/evm-provider.d.ts +64 -0
- package/lib/chains/providers/evm/evm-record.d.ts +7 -0
- package/lib/chains/providers/evm/evm.helpers.d.ts +26 -0
- package/lib/chains/providers/solana/solana-provider.d.ts +216 -0
- package/lib/chains/providers/unstoppable/unstoppable-provider.d.ts +50 -0
- package/lib/web3.d.ts +19 -0
- package/package.json +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
# Project Onboarding Guide
|
|
2
|
+
|
|
3
|
+
Welcome to the DropLinked Web3 integration library! This document is designed to bring new developers up to speed on how the system is structured, how its core components interact, and how to extend or maintain functionality. It covers architecture, key abstractions, concrete implementations (with a focus on EVM-compatible chains), error handling, configuration, and end-to-end usage examples.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 0. Project Structure
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
│ index.ts
|
|
11
|
+
│
|
|
12
|
+
└───lib
|
|
13
|
+
│ web3.ts
|
|
14
|
+
│
|
|
15
|
+
├───chains
|
|
16
|
+
│ │ chain-provider.ts
|
|
17
|
+
│ │ README.md
|
|
18
|
+
│ │
|
|
19
|
+
│ ├───dto
|
|
20
|
+
│ │ │ chains.ts
|
|
21
|
+
│ │ │
|
|
22
|
+
│ │ ├───configs
|
|
23
|
+
│ │ │ chain.config.ts
|
|
24
|
+
│ │ │ chainlink-addresses.ts
|
|
25
|
+
│ │ │ README.md
|
|
26
|
+
│ │ │ web3-config.ts
|
|
27
|
+
│ │ │
|
|
28
|
+
│ │ ├───constants
|
|
29
|
+
│ │ │ airdrop-abi.ts
|
|
30
|
+
│ │ │ chain-abis.ts
|
|
31
|
+
│ │ │ chain-constants.ts
|
|
32
|
+
│ │ │ chain-structs.ts
|
|
33
|
+
│ │ │ README.md
|
|
34
|
+
│ │ │
|
|
35
|
+
│ │ ├───errors
|
|
36
|
+
│ │ │ chain-errors.ts
|
|
37
|
+
│ │ │
|
|
38
|
+
│ │ └───interfaces
|
|
39
|
+
│ │ airdrop-token.interface.ts
|
|
40
|
+
│ │ chain-payment.interface.ts
|
|
41
|
+
│ │ chain-provider.interface.ts
|
|
42
|
+
│ │ claim-nft-inputs.ts
|
|
43
|
+
│ │ deploy-shop.interface.ts
|
|
44
|
+
│ │ login-result.interface.ts
|
|
45
|
+
│ │ modal-interface.interface.ts
|
|
46
|
+
│ │ payment-interface.ts
|
|
47
|
+
│ │ record-web3-product.interface.ts
|
|
48
|
+
│ │ web3-context.interface.ts
|
|
49
|
+
│ │
|
|
50
|
+
│ └───providers
|
|
51
|
+
│ ├───evm
|
|
52
|
+
│ │ evm-affiliate.ts
|
|
53
|
+
│ │ evm-airdrop.ts
|
|
54
|
+
│ │ evm-claim-nfts.ts
|
|
55
|
+
│ │ evm-constants.ts
|
|
56
|
+
│ │ evm-deploy-shop.ts
|
|
57
|
+
│ │ evm-login.ts
|
|
58
|
+
│ │ evm-payments.ts
|
|
59
|
+
│ │ evm-provider.ts
|
|
60
|
+
│ │ evm-publish.ts
|
|
61
|
+
│ │ evm-record.ts
|
|
62
|
+
│ │ evm.helpers.ts
|
|
63
|
+
│ │ README.md
|
|
64
|
+
│ │
|
|
65
|
+
│ ├───solana
|
|
66
|
+
│ │ README.md
|
|
67
|
+
│ │ solana-provider.ts
|
|
68
|
+
│ │
|
|
69
|
+
│ └───unstoppable
|
|
70
|
+
│ unstoppable-provider.ts
|
|
71
|
+
│
|
|
72
|
+
└───wallet-providers
|
|
73
|
+
appkit.ts
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 1. High-Level Architecture
|
|
80
|
+
|
|
81
|
+
At the heart of this library is a **factory** class called `DropWeb3`, which, given a chosen network (Testnet, Mainnet, etc.), exposes a **single entry point** (`web3Instance`) to obtain a configured provider that implements the `IChainProvider` interface. Each provider (e.g., `EVMProvider`, `SolanaProvider`, `UnstoppableProvider`) encapsulates all chain-specific logic, from wallet connection through contract interaction and transaction management.
|
|
82
|
+
|
|
83
|
+
The design follows the **Strategy pattern**: calling code never directly references blockchain-specific classes; it only relies on the uniform methods defined by `IChainProvider`. This ensures that adding support for new chains or networks requires zero changes to application-level logic.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 2. Core Interfaces and Types
|
|
88
|
+
|
|
89
|
+
### 2.1 IChainProvider Interface
|
|
90
|
+
|
|
91
|
+
Defines the contract every chain provider must fulfill. Key methods:
|
|
92
|
+
|
|
93
|
+
- **`setAxiosInstance(axiosInstance: KyInstance)`**: Inject a custom HTTP client for backend calls (e.g., metadata upload, address lookup).
|
|
94
|
+
- **`walletLogin()`**: Trigger user login via wallet, returning `{ address, signature, nonce, timestamp }`.
|
|
95
|
+
- **`deployShop(shopDetails: IDeployShop)`**: Deploy a shop smart contract, returning addresses and constructor args.
|
|
96
|
+
- **`recordProduct(productData: IProductDetails, skuData: ISKUDetails[])`**: Mint NFTs and register product metadata with your shop contract.
|
|
97
|
+
- **`publishRequest(productId: Uint256, shopAddress: EthAddress)`**: Request affiliate permission to publish a product.
|
|
98
|
+
- **`approveRequest(requestId: Uint256, shopAddress: EthAddress)`** / **`disapproveRequest(...)`**: Approve or disapprove affiliate requests.
|
|
99
|
+
- **`payment(data: IPaymentInputs)`**: Execute a payment, handling token approvals and transfers.
|
|
100
|
+
- **`customPayment(data: IChainPayment)`**: Low-level payment via proxy contracts.
|
|
101
|
+
- **`paymentWithToken(receiver: string, amount: number, tokenAddress: string)`**: Direct token transfer.
|
|
102
|
+
- **`claimNFTs(data: ClaimNFTInputs)`**: Process NFT claim transactions.
|
|
103
|
+
- **`executeAirdrop(airdropId: string)`**: Run batch airdrops of NFTs or tokens.
|
|
104
|
+
- **Chaining setters**: `setAddress`, `setWallet`, `setModal`, `setNFTContractAddress`, `setShopContractAddress`, `setWalletModal` – provide a *fluent API* to configure context before invoking actions.
|
|
105
|
+
- **`disconnect()`**: Cleanly disconnect from the wallet or provider.
|
|
106
|
+
|
|
107
|
+
All methods return Promises, and setter methods return `this` for easy chaining.
|
|
108
|
+
|
|
109
|
+
### 2.2 Web3ChainConfig & Web3Actions
|
|
110
|
+
|
|
111
|
+
Controls how `DropWeb3.web3Instance()` configures your provider:
|
|
112
|
+
|
|
113
|
+
- **`method: Web3Actions`**: One of `LOGIN`, `DEPLOY`, `RECORD_AFFILIATE`, `PAYMENT`, `CLAIM`, `AIRDROP`.
|
|
114
|
+
- **`chain: Chain`** and **`network: Network`**: Specify which blockchain and sub-network to target.
|
|
115
|
+
- **`preferredWallet: ChainWallet | ChainWallet[]`**: Wallet(s) to prompt (e.g., MetaMask, Phantom, Unstoppable Domains).
|
|
116
|
+
- **`userAddress`, `nftContractAddress`, `shopContractAddress`**: Provide runtime data required by certain actions.
|
|
117
|
+
- **`modalInterface`**: Inject a UI layer for status, confirmations, or error dialogues.
|
|
118
|
+
|
|
119
|
+
The factory interprets these configs to instantiate and configure the correct provider.
|
|
120
|
+
|
|
121
|
+
### 2.3 DroplinkedChainConfig
|
|
122
|
+
|
|
123
|
+
A lightweight internal structure used by helper functions. Contains:
|
|
124
|
+
|
|
125
|
+
- **`provider: ethers.BrowserProvider`** – low-level RPC connection.
|
|
126
|
+
- **`chain: Chain`, `network: Network`, `userAddress: EthAddress`** – routing details.
|
|
127
|
+
- **`axiosInstance: KyInstance`** – API client.
|
|
128
|
+
- **`modalInterface: ModalInterface`** – user feedback hook.
|
|
129
|
+
- **`gasPredictable: boolean`** – hint for gas estimation strategies.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 3. The DropWeb3 Factory
|
|
134
|
+
|
|
135
|
+
Implemented in `chain-provider.ts`, the `DropWeb3` class:
|
|
136
|
+
|
|
137
|
+
1. **Constructor**: Accepts a `Network` enum; initializes a `ky` client pointing to dev or prod API endpoints.
|
|
138
|
+
2. **chainMapping**: A nested dictionary mapping each `Chain` and `Network` combination to a specific provider instance.
|
|
139
|
+
3. **`web3Instance(config: Web3ChainConfig)`**:
|
|
140
|
+
- Validates that an implementation exists for the requested chain/network.
|
|
141
|
+
- Retrieves or constructs a modal via `AppKitProvider`.
|
|
142
|
+
- Calls chaining setters on the provider instance: `.setAddress()`, `.setWallet()`, `.setModal()`, `.setAxiosInstance()`.
|
|
143
|
+
- Returns the configured `IChainProvider`.
|
|
144
|
+
|
|
145
|
+
**Usage Example**:
|
|
146
|
+
```ts
|
|
147
|
+
const factory = new DropWeb3(Network.TESTNET);
|
|
148
|
+
const provider = factory.web3Instance({
|
|
149
|
+
method: Web3Actions.DEPLOY,
|
|
150
|
+
chain: Chain.ETH,
|
|
151
|
+
userAddress: '0xabc...'
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 4. Implementation: EVMProvider
|
|
158
|
+
|
|
159
|
+
Located at `lib/chains/providers/evm/evm-provider.ts`, `EVMProvider`:
|
|
160
|
+
|
|
161
|
+
### 4.1 Construction & Configuration
|
|
162
|
+
|
|
163
|
+
- **Constructor**
|
|
164
|
+
```ts
|
|
165
|
+
constructor(chain: Chain, network: Network, gasPredictable: boolean) { … }
|
|
166
|
+
```
|
|
167
|
+
- Initializes `chain`, `network`, `gasPredictable`.
|
|
168
|
+
- Sets default `axiosInstance`, `modalInterface`, and `address = ZERO_ADDRESS`.
|
|
169
|
+
|
|
170
|
+
- **Chaining Setters**: `setAxiosInstance()`, `setWalletModal()`, `setNFTContractAddress()`, `setShopContractAddress()`, `setWallet()`, `setModal()`, `setAddress()`.
|
|
171
|
+
|
|
172
|
+
### 4.2 Connection Management
|
|
173
|
+
|
|
174
|
+
- **`getEthersProvider()`**:
|
|
175
|
+
1. Checks `modal.getProvider('eip155')`.
|
|
176
|
+
2. Uses `modal.connect('eip155')` if needed.
|
|
177
|
+
3. Returns `ethers.BrowserProvider`.
|
|
178
|
+
|
|
179
|
+
- **`disconnect()`**: Calls `modal.disconnect('eip155')` until none remain.
|
|
180
|
+
|
|
181
|
+
### 4.3 Core Feature Methods
|
|
182
|
+
|
|
183
|
+
#### 4.3.1 Wallet Login
|
|
184
|
+
1. `getEthersProvider()`
|
|
185
|
+
2. Request accounts.
|
|
186
|
+
3. Switch or add chain as needed.
|
|
187
|
+
4. Request SKALE fuel if applicable.
|
|
188
|
+
5. Fetch nonce, sign message.
|
|
189
|
+
6. Return `{ address, signature, nonce, timestamp }`.
|
|
190
|
+
|
|
191
|
+
#### 4.3.2 Shop Deployment
|
|
192
|
+
Delegates to `deployEVMShop()`:
|
|
193
|
+
1. Build constructor args.
|
|
194
|
+
2. Fetch bytecode via `getShopByteCode()`.
|
|
195
|
+
3. Estimate gas and deploy via Ethers.js.
|
|
196
|
+
4. Wait for `ShopDeployed` event.
|
|
197
|
+
5. Return `{ shopAddress, metadataURI }`.
|
|
198
|
+
|
|
199
|
+
#### 4.3.3 Product Recording (NFT Minting)
|
|
200
|
+
Calls `recordProduct()`:
|
|
201
|
+
1. Upload metadata for each SKU.
|
|
202
|
+
2. Prepare data: `{ tokenURI, quantity, price }`.
|
|
203
|
+
3. Batch mint NFTs.
|
|
204
|
+
4. Return `{ transactionHash, mintedIds }`.
|
|
205
|
+
|
|
206
|
+
#### 4.3.4 Affiliate Publishing Workflows
|
|
207
|
+
- **publishRequest()**: Sends `requestAffiliate()` transaction; waits for `AffiliateRequested` event.
|
|
208
|
+
- **approveRequest()/disapproveRequest()**: Executes `approve(requestId)` or `disapprove(requestId)` and handles common errors.
|
|
209
|
+
|
|
210
|
+
#### 4.3.5 Payments Processing
|
|
211
|
+
- **`payment()`**: Validates inputs, builds `DroplinkedChainConfig` and context, calls `droplinked_payment()`, simulates via static call, estimates gas (+5%), sends transaction.
|
|
212
|
+
- **`customPayment()`**: Direct proxy contract call.
|
|
213
|
+
- **`paymentWithToken()`**: Direct ERC20 transfer.
|
|
214
|
+
|
|
215
|
+
#### 4.3.6 NFT Claiming
|
|
216
|
+
`claimNFTs()` calls bulk `claimPurchase()` on shop contract; returns transaction hash.
|
|
217
|
+
|
|
218
|
+
#### 4.3.7 Airdrops
|
|
219
|
+
`executeAirdrop()`:
|
|
220
|
+
1. Fetch recipients and token lists.
|
|
221
|
+
2. Batch-call `airdropTokens()`.
|
|
222
|
+
3. Return list of transaction hashes.
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## 5. Supporting Modules & Utilities
|
|
227
|
+
|
|
228
|
+
### 5.1 Constants & Structs
|
|
229
|
+
- **`chain-constants.ts`**: ZERO_ADDRESS, network IDs.
|
|
230
|
+
- **`chain-structs.ts`**: Types (`EthAddress`, `Uint256`, etc.)
|
|
231
|
+
|
|
232
|
+
### 5.2 ABI Definitions
|
|
233
|
+
- Stored in `chain-abis/`.
|
|
234
|
+
- Helper getters like `getERC20TokenTransferABI()`.
|
|
235
|
+
|
|
236
|
+
### 5.3 Chain Config Fetchers
|
|
237
|
+
In `chain.config.ts`:
|
|
238
|
+
- `getDeployerAddress()`, `getProxyAddress()`, `getFundsProxy()`, `getAirdropAddress()`.
|
|
239
|
+
|
|
240
|
+
### 5.4 Error Classes
|
|
241
|
+
From `chain-errors.ts`:
|
|
242
|
+
- Wallet errors: `MetaMaskNotFoundException`, etc.
|
|
243
|
+
- Chain errors: `ChainNotImplementedException`, etc.
|
|
244
|
+
- Payment errors: `InsufficientBalanceException`, etc.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## 6. Error Handling Patterns
|
|
249
|
+
|
|
250
|
+
1. Wrap external calls in `try/catch`.
|
|
251
|
+
2. Map errors to domain-specific exceptions.
|
|
252
|
+
3. Use `modalInterface.showError()` for UI feedback.
|
|
253
|
+
4. Retry transient failures (up to 2 attempts, exponential backoff).
|
|
254
|
+
5. Validate event logs; throw `UnexpectedContractResponse` if missing.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## 7. Setup, Configuration & Usage Examples
|
|
259
|
+
|
|
260
|
+
**Initialize factory**:
|
|
261
|
+
```ts
|
|
262
|
+
import { DropWeb3 } from './lib/chains/chain-provider';
|
|
263
|
+
import { Network, Web3Actions, Chain, ChainWallet } from './lib/chains/dto/configs/web3-config';
|
|
264
|
+
|
|
265
|
+
const web3Factory = new DropWeb3(Network.TESTNET);
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Login**:
|
|
269
|
+
```ts
|
|
270
|
+
const loginProvider = web3Factory.web3Instance({
|
|
271
|
+
method: Web3Actions.LOGIN,
|
|
272
|
+
preferredWallet: ChainWallet.Metamask
|
|
273
|
+
});
|
|
274
|
+
const { address, signature } = await loginProvider.walletLogin();
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Deploy Shop**:
|
|
278
|
+
```ts
|
|
279
|
+
const web3 = new DropWeb3(appDevelopment ? Network.TESTNET : Network.MAINNET);
|
|
280
|
+
const chainInstance = web3.web3Instance({
|
|
281
|
+
method: Web3Actions.DEPLOY,
|
|
282
|
+
preferredWallet: preferredWallets,
|
|
283
|
+
chain: Chain.BASE,
|
|
284
|
+
userAddress: "0x...",
|
|
285
|
+
});
|
|
286
|
+
const shop = chainInstance.deployShop({
|
|
287
|
+
shopAddress: "...",
|
|
288
|
+
shopDescription: "...",
|
|
289
|
+
shopLogo: "...",
|
|
290
|
+
shopName: "..."
|
|
291
|
+
})
|
|
292
|
+
console.log(shop.deployedNFTAddress, shop.deployedShopAddress, shop.transactionHash);
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## 8. Extending to New Chains
|
|
299
|
+
|
|
300
|
+
1. Create `NewChainProvider implements IChainProvider` under `lib/chains/providers/newchain/`.
|
|
301
|
+
2. Implement all interface methods using the chain's SDK.
|
|
302
|
+
3. Add to `chainMapping` in `chain-provider.ts`.
|
|
303
|
+
4. Include any new ABI or config files.
|
|
304
|
+
5. Write integration tests covering all methods.
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## 9. Best Practices & Recommendations
|
|
309
|
+
|
|
310
|
+
- **Fluent Configuration**: Always chain `.setWallet()`, `.setModal()`, `.setAxiosInstance()` before actions.
|
|
311
|
+
- **Await Confirmations**: Use `tx.wait()` to ensure on-chain finality.
|
|
312
|
+
- **Error Granularity**: Handle domain-specific exceptions for better UX.
|
|
313
|
+
- **Avoid Hardcoding**: Use config fetchers; do not embed addresses in code.
|
|
314
|
+
- **Testing**: Cover actions on both Testnet and Mainnet.
|
|
315
|
+
- **Security**: Always verify signatures server-side.
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
*Welcome aboard! Use this guide as your roadmap to explore, debug, and extend the DropLinked integration library.*
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
## 10. Project Entry Points
|
|
323
|
+
|
|
324
|
+
### 10.1 `index.ts`
|
|
325
|
+
|
|
326
|
+
The entry point of the library re-exports core modules to simplify imports:
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
// index.ts
|
|
330
|
+
export * from './lib/web3';
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
This allows consumers to import everything via:
|
|
334
|
+
|
|
335
|
+
```ts
|
|
336
|
+
import { DropWeb3, Web3Actions, Chain, Network } from 'droplinked-sdk';
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### 10.2 `web3.ts`
|
|
340
|
+
|
|
341
|
+
The `web3.ts` file consolidates and re-exports all sub-modules:
|
|
342
|
+
|
|
343
|
+
```ts
|
|
344
|
+
import { ZERO_ADDRESS } from './chains/dto/constants/chain-constants';
|
|
345
|
+
|
|
346
|
+
export * from './chains/chain-provider';
|
|
347
|
+
export * from './chains/providers/evm/evm-login';
|
|
348
|
+
export * from './chains/dto/errors/chain-errors';
|
|
349
|
+
export * from './chains/dto/constants/chain-structs';
|
|
350
|
+
export * from './chains/dto/chains';
|
|
351
|
+
export * from './chains/dto/interfaces/modal-interface.interface';
|
|
352
|
+
export * from './chains/dto/configs/chain.config';
|
|
353
|
+
export * from './chains/dto/configs/web3-config';
|
|
354
|
+
export * from './chains/dto/interfaces/chain-provider.interface';
|
|
355
|
+
export * from './chains/dto/interfaces/airdrop-token.interface';
|
|
356
|
+
export * from './chains/dto/interfaces/claim-nft-inputs';
|
|
357
|
+
export * from './chains/dto/interfaces/deploy-shop.interface';
|
|
358
|
+
export * from './chains/dto/interfaces/record-web3-product.interface';
|
|
359
|
+
export * from './chains/dto/interfaces/web3-context.interface';
|
|
360
|
+
export { ZERO_ADDRESS };
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
This centralized export ensures that all types, interfaces, and implementations are available through a single import path.
|
|
364
|
+
|
|
365
|
+
## 11. DTO Layer & File Structure
|
|
366
|
+
|
|
367
|
+
Under `lib/chains/dto`, the Data Transfer Objects (DTOs) and configuration files define the structural contracts:
|
|
368
|
+
|
|
369
|
+
```
|
|
370
|
+
lib/chains/dto
|
|
371
|
+
├── chains.ts
|
|
372
|
+
├── configs
|
|
373
|
+
│ ├── chain.config.ts
|
|
374
|
+
│ └── web3-config.ts
|
|
375
|
+
├── constants
|
|
376
|
+
│ ├── chain-constants.ts
|
|
377
|
+
│ └── chain-structs.ts
|
|
378
|
+
├── errors
|
|
379
|
+
│ └── chain-errors.ts
|
|
380
|
+
└── interfaces
|
|
381
|
+
├── airdrop-token.interface.ts
|
|
382
|
+
├── chain-provider.interface.ts
|
|
383
|
+
├── chain-payment.interface.ts
|
|
384
|
+
├── claim-nft-inputs.ts
|
|
385
|
+
├── deploy-shop.interface.ts
|
|
386
|
+
├── modal-interface.interface.ts
|
|
387
|
+
├── record-web3-product.interface.ts
|
|
388
|
+
└── web3-context.interface.ts
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
- **`chains.ts`**: Defines the `Chain` enum (e.g., ETH, POLYGON) and related types.
|
|
392
|
+
- **`chain.config.ts`**: Provides `getDeployerAddress`, `getProxyAddress`, and other address-fetching utilities.
|
|
393
|
+
- **`web3-config.ts`**: Exports `Web3Actions` enum and `Web3ChainConfig` interface used by the `DropWeb3` factory.
|
|
394
|
+
- **`chain-constants.ts`**: Common constants like `ZERO_ADDRESS` and retry settings.
|
|
395
|
+
- **`chain-structs.ts`**: Strong-type wrappers for on-chain data (e.g., `EthAddress`, `Uint256`).
|
|
396
|
+
- **`chain-errors.ts`**: Domain-specific error classes covering wallet, RPC, and contract errors.
|
|
397
|
+
- **Interfaces**: Define method signatures and data shapes for all features (login, deployment, recording, payments, airdrops, modal interactions).
|
|
398
|
+
|
|
399
|
+
By understanding this DTO layer, developers can see how configuration and data shapes flow through the factory into each provider.
|
|
400
|
+
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/web3';
|