@droplinked_inc/web3 1.0.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.
Files changed (65) hide show
  1. package/LICENSE +21 -0
  2. package/MIGRATION.md +152 -0
  3. package/README.md +112 -0
  4. package/THREAT_MODEL.md +115 -0
  5. package/dist/abis/airdrop.d.ts +81 -0
  6. package/dist/abis/airdrop.d.ts.map +1 -0
  7. package/dist/abis/airdrop.js +58 -0
  8. package/dist/abis/airdrop.js.map +1 -0
  9. package/dist/abis/deployer.d.ts +54 -0
  10. package/dist/abis/deployer.d.ts.map +1 -0
  11. package/dist/abis/deployer.js +41 -0
  12. package/dist/abis/deployer.js.map +1 -0
  13. package/dist/abis/erc20.d.ts +102 -0
  14. package/dist/abis/erc20.d.ts.map +1 -0
  15. package/dist/abis/erc20.js +87 -0
  16. package/dist/abis/erc20.js.map +1 -0
  17. package/dist/abis/index.d.ts +5 -0
  18. package/dist/abis/index.d.ts.map +1 -0
  19. package/dist/abis/index.js +5 -0
  20. package/dist/abis/index.js.map +1 -0
  21. package/dist/abis/shop.d.ts +213 -0
  22. package/dist/abis/shop.d.ts.map +1 -0
  23. package/dist/abis/shop.js +162 -0
  24. package/dist/abis/shop.js.map +1 -0
  25. package/dist/contracts/erc20.d.ts +23 -0
  26. package/dist/contracts/erc20.d.ts.map +1 -0
  27. package/dist/contracts/erc20.js +59 -0
  28. package/dist/contracts/erc20.js.map +1 -0
  29. package/dist/contracts/index.d.ts +3 -0
  30. package/dist/contracts/index.d.ts.map +1 -0
  31. package/dist/contracts/index.js +3 -0
  32. package/dist/contracts/index.js.map +1 -0
  33. package/dist/contracts/shop.d.ts +56 -0
  34. package/dist/contracts/shop.d.ts.map +1 -0
  35. package/dist/contracts/shop.js +113 -0
  36. package/dist/contracts/shop.js.map +1 -0
  37. package/dist/drop-web3.d.ts +44 -0
  38. package/dist/drop-web3.d.ts.map +1 -0
  39. package/dist/drop-web3.js +65 -0
  40. package/dist/drop-web3.js.map +1 -0
  41. package/dist/encoders.d.ts +115 -0
  42. package/dist/encoders.d.ts.map +1 -0
  43. package/dist/encoders.js +198 -0
  44. package/dist/encoders.js.map +1 -0
  45. package/dist/errors.d.ts +111 -0
  46. package/dist/errors.d.ts.map +1 -0
  47. package/dist/errors.js +206 -0
  48. package/dist/errors.js.map +1 -0
  49. package/dist/index.d.ts +24 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +29 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/providers/evm-shim.d.ts +77 -0
  54. package/dist/providers/evm-shim.d.ts.map +1 -0
  55. package/dist/providers/evm-shim.js +86 -0
  56. package/dist/providers/evm-shim.js.map +1 -0
  57. package/dist/signing.d.ts +157 -0
  58. package/dist/signing.d.ts.map +1 -0
  59. package/dist/signing.js +187 -0
  60. package/dist/signing.js.map +1 -0
  61. package/dist/types.d.ts +705 -0
  62. package/dist/types.d.ts.map +1 -0
  63. package/dist/types.js +271 -0
  64. package/dist/types.js.map +1 -0
  65. package/package.json +57 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Droplinked Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/MIGRATION.md ADDED
@@ -0,0 +1,152 @@
1
+ # Migrating from `droplinked-web3@5.0.2` to `@droplinked_inc/web3`
2
+
3
+ `droplinked-web3` was published by `k3rn3lpanic`, the same npm identity
4
+ that owns the hostile `droplinked-payment-intent`. Consumers MUST
5
+ migrate to `@droplinked_inc/web3`. This file maps the v5.0.2 API to
6
+ the new one.
7
+
8
+ ## Install
9
+
10
+ ```jsonc
11
+ // package.json
12
+ {
13
+ "dependencies": {
14
+ "@droplinked_inc/web3": "^0.1.0",
15
+ "@droplinked_inc/wallet-connection": "^0.1.0",
16
+ "@droplinked_inc/web3-kit": "^0.1.0"
17
+ }
18
+ }
19
+ ```
20
+
21
+ ```bash
22
+ pnpm remove droplinked-web3
23
+ pnpm add @droplinked_inc/web3 @droplinked_inc/wallet-connection @droplinked_inc/web3-kit
24
+ ```
25
+
26
+ ## API mapping
27
+
28
+ ### Constructor
29
+
30
+ ```diff
31
+ - import { DropWeb3, Network } from 'droplinked-web3';
32
+ - const web3 = new DropWeb3(Network.MAINNET, shopId);
33
+ + import { DropWeb3, Network } from '@droplinked_inc/web3';
34
+ + const web3 = new DropWeb3(Network.MAINNET);
35
+ ```
36
+
37
+ The `shopId` constructor arg has been **removed**. v5.0.2 used it to
38
+ fetch shop + NFT contract addresses from
39
+ `apiv3dev.droplinked.com` — a single point of supply-chain compromise.
40
+ Consumers now pass the addresses explicitly:
41
+
42
+ ```ts
43
+ const inst = web3.web3Instance({
44
+ chain: Chain.POLYGON,
45
+ preferredWallet: ChainWallet.Metamask,
46
+ shopContractAddress: shopAddressFromOurApi, // explicitly passed
47
+ nftContractAddress: nftAddressFromOurApi, // explicitly passed
48
+ });
49
+ ```
50
+
51
+ ### `web3Instance(...)`
52
+
53
+ | v5.0.2 | New |
54
+ |---|---|
55
+ | `web3Instance({ method: 'LOGIN', preferredWallet, modalInterface? })` | Use `@droplinked_inc/wallet-connection` directly: `new EvmConnector({...}).walletLogin()`. The new package does not bundle login. |
56
+ | `web3Instance({ method: 'PAYMENT', chain, userAddress, preferredWallet })` | `web3.web3Instance({ chain, preferredWallet, shopContractAddress })` — returns an `EvmProviderShim`. |
57
+ | `web3Instance({ method: 'DEPLOY', ... })` | Use `encodeDeployShop(...)` directly, then submit via wallet-connection's `submitRawTransaction`. |
58
+ | `web3Instance({ method: 'CLAIM', ... })` | Build the typed-data payload with `buildPurchaseTypedData`, sign with `wallet-connection`, then submit the resulting signature to your backend. Server-side `verifyPurchaseSignature` validates it. |
59
+ | `web3Instance({ method: 'AIRDROP', ... })` | `encodeAirdropErc20(...)` etc., then submit. |
60
+
61
+ ### Payment flow
62
+
63
+ ```diff
64
+ - const inst = web3.web3Instance({ method: Web3Actions.PAYMENT, chain, userAddress, preferredWallet });
65
+ - const { transactionHash } = await inst.payment({ cartID, paymentToken, paymentType });
66
+ + // 1. Fetch payment data from your backend (this stays unchanged).
67
+ + const { paymentData } = await fetchCartPaymentData(cartID);
68
+ +
69
+ + // 2. Build the typed encoded call.
70
+ + const inst = web3.web3Instance({ chain, preferredWallet, shopContractAddress });
71
+ + const call = inst.buildPurchaseCall(paymentData);
72
+ +
73
+ + // 3. SURFACE display-vs-bytes confirmation to the user.
74
+ + const confirm = renderCallForConfirmation(call);
75
+ + // → show `confirm.functionName`, `confirm.argsJson`, `confirm.selector` in UI
76
+ +
77
+ + // 4. Submit via wallet-connection's destination-pinned helper.
78
+ + const txHash = await walletConnector.submitRawTransaction({
79
+ + to: shopContractAddress,
80
+ + data: call.calldata,
81
+ + value: paymentData.totalPrice,
82
+ + });
83
+ ```
84
+
85
+ The new flow surfaces three distinct steps that v5.0.2 hid inside one
86
+ opaque call: fetch, encode, submit. Each is independently auditable.
87
+
88
+ ### Privileged actions
89
+
90
+ `setSigner` and `setManager` now require an explicit acknowledgement:
91
+
92
+ ```ts
93
+ const call = inst.buildSetSignerCall(newSigner, {
94
+ acknowledgePrivilegedAction: true,
95
+ });
96
+ ```
97
+
98
+ Without the boolean literal `true`, the call throws
99
+ `PrivilegedActionNotAcknowledgedError`. This guards against accidental
100
+ encoding from a generic flow (e.g. a test fixture or a code-gen
101
+ helper) and forces every callsite to be reviewable.
102
+
103
+ ### Signature verification (server-side)
104
+
105
+ ```ts
106
+ import {
107
+ verifyPurchaseSignature,
108
+ ShopContract,
109
+ } from '@droplinked_inc/web3';
110
+
111
+ const shop = new ShopContract({ address: shopContractAddress, publicClient });
112
+ const onChainNonce = await shop.readPurchaseNonce(buyer);
113
+
114
+ await verifyPurchaseSignature({
115
+ signature: signaturePayloadFromClient,
116
+ expectedSigner: buyer,
117
+ onChainNonce,
118
+ });
119
+ // throws DeadlineExpiredError, ReplayDetectedError, or
120
+ // SignatureVerificationError on failure
121
+ ```
122
+
123
+ v5.0.2 did NOT bind chain + verifying contract + nonce + deadline into
124
+ the signed payload — every signature was replayable across chains,
125
+ shops, and time. The new package will refuse to verify any signature
126
+ not produced through this exact typed-data path.
127
+
128
+ ### Removed exports
129
+
130
+ | v5.0.2 export | Status | Replacement |
131
+ |---|---|---|
132
+ | `getWalletInfo` | removed | Use `EvmConnector.walletLogin()` from `@droplinked_inc/wallet-connection` |
133
+ | `chainLink` (chainlink-addresses) | removed from this package | Moves to `@droplinked_inc/web3-kit` chain registry |
134
+ | `getDeployerAddress` / `getProxyAddress` / `getFundsProxy` / `getAirdropAddress` | removed | Moves to `@droplinked_inc/web3-kit` chain registry |
135
+ | `getShopByteCode` | removed | Not needed — `deployShop` deployment is server-coordinated |
136
+ | `getCartData` / `uploadMetadata` / `getNonce` / `checkWallet` | removed | These are backend-API calls; consumers should make them directly using a typed `ky` client |
137
+ | `SolanaProvider` / `UnstoppableProvider` | removed | Stubs in v5.0.2; track the dedicated provider packages when available |
138
+ | `Chain.STACKS` / `Chain.NEAR` / `Chain.XRPLSIDECHAIN` / `Chain.CASPER` / `Chain.UNSTOPPABLE` | removed | Were never EVM-compatible; should not have been in the EVM-focused package |
139
+
140
+ ### Numeric vs string enums
141
+
142
+ v5.0.2's `Network` and `NFTType` enums were numeric. The new package
143
+ exports string-valued enums for stability across JSON serialization
144
+ boundaries:
145
+
146
+ ```diff
147
+ - if (network === 0) { // MAINNET
148
+ + if (network === Network.MAINNET) {
149
+ ```
150
+
151
+ If you stored the numeric value in a database, the migration script
152
+ must remap `0 → 'MAINNET'`, `1 → 'TESTNET'`, `2 → 'DEV'`.
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # @droplinked_inc/web3
2
+
3
+ Per-shop EVM contract interactions for droplinked: shop deployment,
4
+ product recording, EIP-712 purchase signing + verification, claim,
5
+ airdrop, ERC-20 token transfers.
6
+
7
+ This package replaces the hostile-published `droplinked-web3@5.0.2`
8
+ (npm author `k3rn3lpanic` — the same identity that owns
9
+ `droplinked-payment-intent`). **Zero code is reused** from the
10
+ original; every export was re-implemented from the published `.d.ts`
11
+ type surface and canonical Solidity signatures.
12
+
13
+ > **MOST security-critical package in the `@droplinked_inc/*` rebuild.**
14
+ > Read [THREAT_MODEL.md](./THREAT_MODEL.md) before any review.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ pnpm add @droplinked_inc/web3 @droplinked_inc/wallet-connection @droplinked_inc/web3-kit
20
+ ```
21
+
22
+ `@droplinked_inc/wallet-connection` and `@droplinked_inc/web3-kit` are
23
+ peer dependencies — they own the wallet protocol and the chain
24
+ registry respectively. This package owns the contract-call surface.
25
+
26
+ ## Usage
27
+
28
+ ### Build a purchase call
29
+
30
+ ```ts
31
+ import {
32
+ DropWeb3,
33
+ Network,
34
+ Chain,
35
+ ChainWallet,
36
+ renderCallForConfirmation,
37
+ } from '@droplinked_inc/web3';
38
+
39
+ const web3 = new DropWeb3(Network.MAINNET);
40
+
41
+ const inst = web3.web3Instance({
42
+ chain: Chain.POLYGON,
43
+ preferredWallet: ChainWallet.Metamask,
44
+ shopContractAddress: '0x...', // pinned at construction; never fetched
45
+ });
46
+
47
+ const call = inst.buildPurchaseCall(paymentDataFromBackend);
48
+
49
+ // SECURITY: always surface the canonical form before passing to a wallet.
50
+ const confirmation = renderCallForConfirmation(call);
51
+ console.log(confirmation.functionName, confirmation.argsJson);
52
+
53
+ // Then submit via @droplinked_inc/wallet-connection.
54
+ ```
55
+
56
+ ### Verify a purchase signature (server-side)
57
+
58
+ ```ts
59
+ import {
60
+ ShopContract,
61
+ verifyPurchaseSignature,
62
+ } from '@droplinked_inc/web3';
63
+
64
+ const shop = new ShopContract({ address: shopAddr, publicClient });
65
+ const onChainNonce = await shop.readPurchaseNonce(buyer);
66
+
67
+ await verifyPurchaseSignature({
68
+ signature: signaturePayload,
69
+ expectedSigner: buyer,
70
+ onChainNonce,
71
+ });
72
+ ```
73
+
74
+ ### Privileged actions
75
+
76
+ ```ts
77
+ const call = inst.buildSetSignerCall(newSigner, {
78
+ acknowledgePrivilegedAction: true, // required literal
79
+ });
80
+ ```
81
+
82
+ ## Security model in one line
83
+
84
+ Every contract call goes through a typed client built from a
85
+ known-good `as const` ABI. Selectors are computed structurally and
86
+ cross-checked at module load. ERC-20 `approve` / `permit` /
87
+ `setApprovalForAll` and NFT `safeTransferFrom` are explicitly on the
88
+ `KNOWN_DRAINER_SELECTORS` list and are NEVER produced by this package.
89
+
90
+ ## Per-method security warnings
91
+
92
+ | Method | Warning |
93
+ |---|---|
94
+ | `encodeErc20Transfer` | Receiver address is taken at face value. Surface the address back to the user via `renderCallForConfirmation` before signing. |
95
+ | `buildSetSigner` / `buildSetManager` | Privileged. Requires `{ acknowledgePrivilegedAction: true }`. A compromised admin EOA that calls this rotates the signer to an attacker — operationally mitigated by hardware-wallet ownership of the admin key. |
96
+ | `encodeDroplinkedPurchase` | The `tokenAddress` is taken at face value. Pin it via `@droplinked_inc/web3-kit`'s registry, do not fetch from a runtime API. |
97
+ | `verifyPurchaseSignature` | MUST be called server-side with a fresh on-chain `nonce` read. Caching the nonce defeats replay protection. |
98
+ | `buildPurchaseTypedData` | Items are explicitly copied (no spread of caller input). The signed payload includes `chainId`, `verifyingContract`, `shopAddress`, `nonce`, and `deadline`. |
99
+
100
+ ## Reviewers
101
+
102
+ - See [THREAT_MODEL.md](./THREAT_MODEL.md) for the per-attack
103
+ mitigation matrix (T1–T17).
104
+ - See [MIGRATION.md](./MIGRATION.md) for the consumer mapping from
105
+ `droplinked-web3@5.0.2`.
106
+ - A formal third-party security audit is recommended BEFORE the first
107
+ consumer migration. Scope is documented at the bottom of
108
+ THREAT_MODEL.md.
109
+
110
+ ## Status
111
+
112
+ `v0.0.0` — initial rebuild. Not yet published to npm.
@@ -0,0 +1,115 @@
1
+ # @droplinked_inc/web3 — Threat Model
2
+
3
+ This package is the **most security-critical** in the
4
+ `@droplinked_inc/*` rebuild. It builds the calldata that EVM wallets
5
+ sign and submit. A compromise here means users sign attacker
6
+ transactions.
7
+
8
+ The original `droplinked-web3@5.0.2` (npm author `k3rn3lpanic`) is
9
+ treated as hostile — the SAME npm identity also owns
10
+ `droplinked-payment-intent`. See the project's nokhodian-case-file for
11
+ background. **Zero code was reused** from the hostile package; only
12
+ the published `.d.ts` type surface was used as an API spec.
13
+
14
+ ## Mitigation matrix
15
+
16
+ | # | Attack | Mitigation |
17
+ |---|---|---|
18
+ | T1 | User signs `approve(attacker, MAX_UINT256)` thinking they're approving a payment | ERC-20 `approve` is NOT in `ERC20_ABI`. The selector `0x095ea7b3` is on `KNOWN_DRAINER_SELECTORS`. `assertCalldataAllowed()` rejects it before the wallet prompt. |
19
+ | T2 | User signs `permit(...)` for the attacker (EIP-2612 drainer) | `permit` is NOT in `ERC20_ABI`. Selector `0xd505accf` is on the drainer list. |
20
+ | T3 | User signs `setApprovalForAll(operator, true)` for an NFT | Selector `0xa22cb465` is on the drainer list. The package never produces this call. |
21
+ | T4 | Cross-chain signature replay (sig from chain 137 used on chain 1) | EIP-712 typed-data domain MUST include `chainId`. `verifyPurchaseSignature` validates the `chainId` field on the wire matches the chain bound into the signature; tampering breaks the recovered signer. Test: `signing.test.ts › "rejects cross-chain replay"`. |
22
+ | T5 | Cross-shop signature replay (sig for shop A used against shop B on the same chain) | EIP-712 domain includes `verifyingContract` AND the signed message body includes `shopAddress`. Both are bound; tampering breaks recovery. Test: `signing.test.ts › "rejects spoofed verifyingContract"`. |
23
+ | T6 | Permit replay (same nonce twice) | Nonces MUST be read from the chain via `shop.readPurchaseNonce(buyer)` immediately before signing. `verifyPurchaseSignature` requires `onChainNonce` and throws `ReplayDetectedError` if they don't match. The SDK refuses to sign with a cached nonce. |
24
+ | T7 | Expired signature accepted | `deadline` is in the EIP-712 message; `verifyPurchaseSignature` rejects with `DeadlineExpiredError` if `deadline < now`. |
25
+ | T7b | Indefinite signature ("approve forever", `deadline = MAX_UINT256`) | `buildPurchaseTypedData` AND `verifyPurchaseSignature` reject any deadline more than `DEFAULT_MAX_DEADLINE_HORIZON_SECONDS` (1 hour) in the future, throwing `DeadlineTooFarError`. Cap is configurable per-call via `maxDeadlineHorizonSeconds` for operator-controlled batch flows. Test: `signing.test.ts › "rejects deadline = MAX_UINT256"`. |
26
+ | T7c | Non-EVM chain silently routed to EVM shim | `Chain` enum enumerates SOLANA and UNSTOPPABLE explicitly; `DropWeb3.web3Instance()` checks both via `NON_EVM_CHAINS` allowlist and throws `ChainNotImplementedException` before constructing the shim. Test: `providers.test.ts › "throws ChainNotImplementedException for UNSTOPPABLE"`. |
27
+ | T8 | ABI mismatch — right selector, wrong arg encoding | `indexAbiSelectors()` uses viem's `toFunctionSignature` which canonicalizes tuple types (the original was hand-rolled and could miss tuple expansion). `encodeFunctionData` runs against the typed `as const` ABI. `buildEncoded` asserts the produced calldata starts with the independently-computed selector. |
28
+ | T9 | Selector collision — two functions, same first 4 bytes | `indexAbiSelectors` throws `AbiSelectorCollisionError` at module load if any selector maps to two distinct full signatures. There is no path where a collision can silently take effect. |
29
+ | T10 | Contract address spoofing (attacker's clone) | Contract addresses are NEVER fetched at runtime. The original v5.0.2 fetched addresses from `apiv3dev.droplinked.com` — a single point of compromise. In this rebuild every address comes from the caller (recommended source: `@droplinked_inc/web3-kit` chain registry, compiled in). `ShopContract.assertAddressIs()` provides a defense-in-depth runtime equality check. |
30
+ | T11 | Privileged action (`setSigner`, `setManager`) accidentally encoded by a generic flow | Both encoders require an explicit `{ acknowledgePrivilegedAction: true }` ack from the caller. Without the boolean literal, they throw `PrivilegedActionNotAcknowledgedError`. |
31
+ | T12 | Display-vs-bytes attack: UI shows "transfer 1 USDC" but bytes encode 10000 USDC | Every encoder returns an `EncodedCall<T>` carrying BOTH the decoded `args` AND the raw `calldata`. `renderCallForConfirmation()` is the canonical UI helper; consumers MUST surface the canonical form before passing to the wallet. |
32
+ | T13 | Compact (EIP-2098) 64-byte signature smuggled in | `PurchaseSignatureSchema` enforces 130 hex chars (= 65 bytes) including `0x`. `verifyPurchaseSignature` re-asserts length 132 with `0x` prefix. |
33
+ | T14 | Prototype pollution via deep spread of user input | `buildPurchaseTypedData` does explicit field copies (no `{ ...args }` of untrusted input). Items are mapped with explicit field extraction. |
34
+ | T15 | RPC response tampering returns bizarre values for `decimals` or `purchaseNonces` | Read methods check the JS type of the response (`typeof === 'bigint'`, decimals integer in `[0,36]`) before returning. |
35
+ | T16 | Compromised checkout API smuggles arbitrary calldata into `submitRawTransaction` | This package's encoders all flow through the typed-ABI path. For the lower-level wallet-connection submit, the selector boundary at `assertCalldataAllowed()` AND the wallet-connection `SUBMIT_RAW_TX_SELECTOR_ALLOWLIST` provide two independent layers — both must permit. |
36
+ | T17 | Late-rotated signer (attacker steals the operator's EOA and calls `setSigner` to an attacker key) | Operational; out of code scope. Mitigation lives at the operator level (HW wallet — see `droplinked-hardware-wallet-2026-05-15` ops note). The PR for this package surfaces `setSigner` as a privileged action so any callsite is auditable. |
37
+
38
+ ## ABI provenance
39
+
40
+ Each ABI in `src/abis/` is currently `.d.ts`-derived (the structural
41
+ type info was the only signal recoverable from the hostile package).
42
+
43
+ **Update (re-audit 2026-05-17):** every selector is now PINNED as a
44
+ hardcoded hex literal in `src/__tests__/abi-integrity.test.ts`. The
45
+ test verifies that `viem.toFunctionSelector(canonicalSig)` matches the
46
+ literal — so a future rename (e.g. `setSigner` → `setSignerV2`) or a
47
+ parameter-type change will fail CI loudly. This closes the
48
+ tautology-test BLOCKER from the first audit pass.
49
+
50
+ Hard-coded selectors prevent name-typo drift but do NOT prove
51
+ correctness vs the deployed contract — they only prove the canonical
52
+ signature in the test table matches the ABI in the bundle.
53
+
54
+ | Contract | Source | Status | Required follow-up |
55
+ |---|---|---|---|
56
+ | `ERC20_ABI` | EIP-20 + EIP-2612 standard | verified vs spec + selector-pinned | none — standard |
57
+ | `SHOP_ABI` | .d.ts-derived | selector-pinned (vs viem keccak); etherscan UNVERIFIED | resolve a known shop contract address on Polygon and cross-check the 9 SHOP pins (`setSigner`/`setManager`/`signer`/`manager`/`owner`/`recordProduct`/`droplinkedPurchase`/`claimNFTs`/`purchaseNonces`) |
58
+ | `DEPLOYER_ABI` | .d.ts-derived | selector-pinned; etherscan UNVERIFIED | resolve the droplinked deployer on Polygon and cross-check `deployShop` pin |
59
+ | `AIRDROP_ABI` | .d.ts-derived | selector-pinned; etherscan UNVERIFIED | resolve the droplinked airdrop contract and cross-check the 3 `airdropERC20/721/1155` pins |
60
+
61
+ **Etherscan cross-check status (2026-05-17):** at re-audit time no
62
+ etherscan-verified droplinked v3 shop deployment URL was accessible
63
+ from this workspace. The hard-coded selectors in
64
+ `abi-integrity.test.ts` therefore reflect the canonical Solidity
65
+ signatures derived from the .d.ts shape, not a live-contract
66
+ cross-reference.
67
+
68
+ **Final etherscan verification REQUIRED before any consumer migration.**
69
+ Once a verified deployment is resolved, paste the explorer URL and
70
+ verification date as a comment block at the top of
71
+ `abi-integrity.test.ts` next to each cross-checked selector. The
72
+ audit recommendation in §"Recommended audit scope" (item 1) is
73
+ reaffirmed.
74
+
75
+ Selectors that would be wrong-on-the-wire (and therefore caught by the
76
+ contract reverting at call time, but only AFTER the user signs) are
77
+ the ones to focus on. Setters with single `address` arguments
78
+ (`setSigner`, `setManager`) are most at risk of name-only ambiguity —
79
+ and are now both pinned (`0x6c19e783` and `0xd0ebdbe7`).
80
+
81
+ ## What is intentionally NOT implemented
82
+
83
+ - `payment()` / `paymentWithToken()` as opaque side-effects. v5.0.2
84
+ combined login + nonce read + signing + tx submission into a single
85
+ call. This package surfaces each step separately so the caller can
86
+ audit each side-effect.
87
+ - `approve()` / `transferFrom()` / `permit()` writers — none of the
88
+ droplinked flows require the SDK to ask the user to grant an
89
+ allowance.
90
+ - Remote address discovery — every contract address comes from the
91
+ caller. There is no DNS or HTTP call in the build/encode path.
92
+ - Solana / Unstoppable — `DropWeb3.web3Instance({ chain: SOLANA })`
93
+ throws `ChainNotImplementedException`. Consumers needing those
94
+ chains use the dedicated provider packages.
95
+
96
+ ## Recommended audit scope
97
+
98
+ Before this package is published or imported by `Next-ShopFront`:
99
+
100
+ 1. **ABI cross-check** — resolve etherscan-verified shop / deployer /
101
+ airdrop contracts and confirm every selector in
102
+ `PACKAGE_SELECTOR_ALLOWLIST` matches a function on the live
103
+ deployment.
104
+ 2. **EIP-712 round-trip** — verify the signed typed-data payload
105
+ round-trips on-chain (call `ecrecover` from a forge script and
106
+ confirm the recovered signer matches the off-chain output).
107
+ 3. **Fuzz the encoders** — property-based test coverage for
108
+ `encodeDroplinkedPurchase` and `encodeAirdropErc20` over the full
109
+ uint256 range.
110
+ 4. **Adversarial review of `assertCalldataAllowed`** — confirm there
111
+ is no input that bypasses both the drainer list and the allowlist.
112
+ 5. **Static taint analysis** — confirm no caller-supplied string flows
113
+ into a `new RegExp` / `eval` / `Function` constructor anywhere in
114
+ the call graph (eslint `security/*` rules + `no-secrets` are
115
+ enabled monorepo-wide).
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Droplinked Airdrop contract ABI.
3
+ *
4
+ * Source: derived from droplinked-web3@5.0.2 `.d.ts` (ITokenDetails
5
+ * discriminated union: ERC20 / ERC721 / ERC1155 + per-receiver
6
+ * (receiver, amount) tuples). Reconstructed from the canonical
7
+ * Solidity signature shape used by droplinked airdrop contracts.
8
+ * NOT etherscan-verified at the time of rebuild — see THREAT_MODEL.md.
9
+ */
10
+ export declare const AIRDROP_ABI: readonly [{
11
+ readonly type: "function";
12
+ readonly name: "airdropERC20";
13
+ readonly stateMutability: "nonpayable";
14
+ readonly inputs: readonly [{
15
+ readonly name: "token";
16
+ readonly type: "address";
17
+ }, {
18
+ readonly name: "receivers";
19
+ readonly type: "address[]";
20
+ }, {
21
+ readonly name: "amounts";
22
+ readonly type: "uint256[]";
23
+ }, {
24
+ readonly name: "airdropId";
25
+ readonly type: "bytes32";
26
+ }];
27
+ readonly outputs: readonly [];
28
+ }, {
29
+ readonly type: "function";
30
+ readonly name: "airdropERC721";
31
+ readonly stateMutability: "nonpayable";
32
+ readonly inputs: readonly [{
33
+ readonly name: "token";
34
+ readonly type: "address";
35
+ }, {
36
+ readonly name: "receivers";
37
+ readonly type: "address[]";
38
+ }, {
39
+ readonly name: "tokenIds";
40
+ readonly type: "uint256[]";
41
+ }, {
42
+ readonly name: "airdropId";
43
+ readonly type: "bytes32";
44
+ }];
45
+ readonly outputs: readonly [];
46
+ }, {
47
+ readonly type: "function";
48
+ readonly name: "airdropERC1155";
49
+ readonly stateMutability: "nonpayable";
50
+ readonly inputs: readonly [{
51
+ readonly name: "token";
52
+ readonly type: "address";
53
+ }, {
54
+ readonly name: "tokenId";
55
+ readonly type: "uint256";
56
+ }, {
57
+ readonly name: "receivers";
58
+ readonly type: "address[]";
59
+ }, {
60
+ readonly name: "amounts";
61
+ readonly type: "uint256[]";
62
+ }, {
63
+ readonly name: "airdropId";
64
+ readonly type: "bytes32";
65
+ }];
66
+ readonly outputs: readonly [];
67
+ }, {
68
+ readonly type: "event";
69
+ readonly name: "AirdropExecuted";
70
+ readonly anonymous: false;
71
+ readonly inputs: readonly [{
72
+ readonly indexed: true;
73
+ readonly name: "airdropId";
74
+ readonly type: "bytes32";
75
+ }, {
76
+ readonly indexed: false;
77
+ readonly name: "receiverCount";
78
+ readonly type: "uint256";
79
+ }];
80
+ }];
81
+ //# sourceMappingURL=airdrop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"airdrop.d.ts","sourceRoot":"","sources":["../../src/abis/airdrop.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+Cd,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Droplinked Airdrop contract ABI.
3
+ *
4
+ * Source: derived from droplinked-web3@5.0.2 `.d.ts` (ITokenDetails
5
+ * discriminated union: ERC20 / ERC721 / ERC1155 + per-receiver
6
+ * (receiver, amount) tuples). Reconstructed from the canonical
7
+ * Solidity signature shape used by droplinked airdrop contracts.
8
+ * NOT etherscan-verified at the time of rebuild — see THREAT_MODEL.md.
9
+ */
10
+ export const AIRDROP_ABI = [
11
+ {
12
+ type: 'function',
13
+ name: 'airdropERC20',
14
+ stateMutability: 'nonpayable',
15
+ inputs: [
16
+ { name: 'token', type: 'address' },
17
+ { name: 'receivers', type: 'address[]' },
18
+ { name: 'amounts', type: 'uint256[]' },
19
+ { name: 'airdropId', type: 'bytes32' },
20
+ ],
21
+ outputs: [],
22
+ },
23
+ {
24
+ type: 'function',
25
+ name: 'airdropERC721',
26
+ stateMutability: 'nonpayable',
27
+ inputs: [
28
+ { name: 'token', type: 'address' },
29
+ { name: 'receivers', type: 'address[]' },
30
+ { name: 'tokenIds', type: 'uint256[]' },
31
+ { name: 'airdropId', type: 'bytes32' },
32
+ ],
33
+ outputs: [],
34
+ },
35
+ {
36
+ type: 'function',
37
+ name: 'airdropERC1155',
38
+ stateMutability: 'nonpayable',
39
+ inputs: [
40
+ { name: 'token', type: 'address' },
41
+ { name: 'tokenId', type: 'uint256' },
42
+ { name: 'receivers', type: 'address[]' },
43
+ { name: 'amounts', type: 'uint256[]' },
44
+ { name: 'airdropId', type: 'bytes32' },
45
+ ],
46
+ outputs: [],
47
+ },
48
+ {
49
+ type: 'event',
50
+ name: 'AirdropExecuted',
51
+ anonymous: false,
52
+ inputs: [
53
+ { indexed: true, name: 'airdropId', type: 'bytes32' },
54
+ { indexed: false, name: 'receiverCount', type: 'uint256' },
55
+ ],
56
+ },
57
+ ];
58
+ //# sourceMappingURL=airdrop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"airdrop.js","sourceRoot":"","sources":["../../src/abis/airdrop.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,cAAc;QACpB,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE;YACxC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE;YACtC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;SACvC;QACD,OAAO,EAAE,EAAE;KACZ;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,eAAe;QACrB,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE;YACxC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE;YACvC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;SACvC;QACD,OAAO,EAAE,EAAE;KACZ;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,gBAAgB;QACtB,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;YACpC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE;YACxC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE;YACtC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;SACvC;QACD,OAAO,EAAE,EAAE;KACZ;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,iBAAiB;QACvB,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE;YACN,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;YACrD,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE;SAC3D;KACF;CACO,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Droplinked Deployer contract ABI.
3
+ *
4
+ * Source: derived from droplinked-web3@5.0.2 `.d.ts` interface
5
+ * (DeployShopResponse) + the per-chain DROPLINKED_MANAGER constant.
6
+ * NOT etherscan-verified at the time of rebuild — see THREAT_MODEL.md.
7
+ */
8
+ export declare const DEPLOYER_ABI: readonly [{
9
+ readonly type: "function";
10
+ readonly name: "deployShop";
11
+ readonly stateMutability: "nonpayable";
12
+ readonly inputs: readonly [{
13
+ readonly name: "shopDetails";
14
+ readonly type: "tuple";
15
+ readonly components: readonly [{
16
+ readonly name: "shopName";
17
+ readonly type: "string";
18
+ }, {
19
+ readonly name: "shopAddress";
20
+ readonly type: "string";
21
+ }, {
22
+ readonly name: "shopLogo";
23
+ readonly type: "string";
24
+ }, {
25
+ readonly name: "shopDescription";
26
+ readonly type: "string";
27
+ }];
28
+ }];
29
+ readonly outputs: readonly [{
30
+ readonly name: "deployedShopAddress";
31
+ readonly type: "address";
32
+ }, {
33
+ readonly name: "deployedNFTAddress";
34
+ readonly type: "address";
35
+ }];
36
+ }, {
37
+ readonly type: "event";
38
+ readonly name: "ShopDeployed";
39
+ readonly anonymous: false;
40
+ readonly inputs: readonly [{
41
+ readonly indexed: true;
42
+ readonly name: "shopOwner";
43
+ readonly type: "address";
44
+ }, {
45
+ readonly indexed: true;
46
+ readonly name: "shopAddress";
47
+ readonly type: "address";
48
+ }, {
49
+ readonly indexed: true;
50
+ readonly name: "nftAddress";
51
+ readonly type: "address";
52
+ }];
53
+ }];
54
+ //# sourceMappingURL=deployer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployer.d.ts","sourceRoot":"","sources":["../../src/abis/deployer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCf,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Droplinked Deployer contract ABI.
3
+ *
4
+ * Source: derived from droplinked-web3@5.0.2 `.d.ts` interface
5
+ * (DeployShopResponse) + the per-chain DROPLINKED_MANAGER constant.
6
+ * NOT etherscan-verified at the time of rebuild — see THREAT_MODEL.md.
7
+ */
8
+ export const DEPLOYER_ABI = [
9
+ {
10
+ type: 'function',
11
+ name: 'deployShop',
12
+ stateMutability: 'nonpayable',
13
+ inputs: [
14
+ {
15
+ name: 'shopDetails',
16
+ type: 'tuple',
17
+ components: [
18
+ { name: 'shopName', type: 'string' },
19
+ { name: 'shopAddress', type: 'string' },
20
+ { name: 'shopLogo', type: 'string' },
21
+ { name: 'shopDescription', type: 'string' },
22
+ ],
23
+ },
24
+ ],
25
+ outputs: [
26
+ { name: 'deployedShopAddress', type: 'address' },
27
+ { name: 'deployedNFTAddress', type: 'address' },
28
+ ],
29
+ },
30
+ {
31
+ type: 'event',
32
+ name: 'ShopDeployed',
33
+ anonymous: false,
34
+ inputs: [
35
+ { indexed: true, name: 'shopOwner', type: 'address' },
36
+ { indexed: true, name: 'shopAddress', type: 'address' },
37
+ { indexed: true, name: 'nftAddress', type: 'address' },
38
+ ],
39
+ },
40
+ ];
41
+ //# sourceMappingURL=deployer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployer.js","sourceRoot":"","sources":["../../src/abis/deployer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,YAAY;QAClB,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,OAAO;gBACb,UAAU,EAAE;oBACV,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACpC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACvC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACpC,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,QAAQ,EAAE;iBAC5C;aACF;SACF;QACD,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,SAAS,EAAE;YAChD,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,SAAS,EAAE;SAChD;KACF;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE;YACN,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;YACrD,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;YACvD,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;SACvD;KACF;CACO,CAAC"}