four-flap-meme-sdk 2.2.19 → 2.2.20
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/dist/__tests__/subpath-exports.test.d.ts +1 -0
- package/dist/__tests__/subpath-exports.test.js +64 -0
- package/dist/abis/common.d.ts +85 -0
- package/dist/abis/common.js +240 -0
- package/dist/abis/contracts/TaxToken.json +969 -0
- package/dist/abis/contracts/TokenManager.json +836 -0
- package/dist/abis/contracts/TokenManager2.json +136 -0
- package/dist/abis/contracts/TokenManagerHelper3.json +993 -0
- package/dist/abis/contracts/index.d.ts +5 -0
- package/dist/abis/contracts/index.js +5 -0
- package/dist/abis/flap/index.d.ts +5 -0
- package/dist/abis/flap/index.js +5 -0
- package/dist/abis/flap/portal-eip7702.d.ts +4 -0
- package/dist/abis/flap/portal-eip7702.js +39 -0
- package/dist/abis/flap/portal-events.d.ts +6 -0
- package/dist/abis/flap/portal-events.js +17 -0
- package/dist/abis/flap/portal-merkle.d.ts +4 -0
- package/dist/abis/flap/portal-merkle.js +25 -0
- package/dist/abis/flap/portal.d.ts +6 -0
- package/dist/abis/flap/portal.js +37 -0
- package/dist/abis/flap/vault.d.ts +171 -0
- package/dist/abis/flap/vault.js +91 -0
- package/dist/abis/index.d.ts +8 -0
- package/dist/abis/index.js +11 -0
- package/dist/bundle-core/__tests__/config-helpers.test.d.ts +1 -0
- package/dist/bundle-core/__tests__/config-helpers.test.js +28 -0
- package/dist/bundle-core/__tests__/facade-parity.test.d.ts +1 -0
- package/dist/bundle-core/__tests__/facade-parity.test.js +33 -0
- package/dist/bundle-core/__tests__/sign-context-helpers.test.d.ts +1 -0
- package/dist/bundle-core/__tests__/sign-context-helpers.test.js +60 -0
- package/dist/bundle-core/__tests__/sign-fixture.test.d.ts +1 -0
- package/dist/bundle-core/__tests__/sign-fixture.test.js +220 -0
- package/dist/bundle-core/__tests__/sign-fixtures.d.ts +10 -0
- package/dist/bundle-core/__tests__/sign-fixtures.js +16 -0
- package/dist/bundle-core/config-helpers.d.ts +37 -0
- package/dist/bundle-core/config-helpers.js +58 -0
- package/dist/bundle-core/errors.d.ts +50 -0
- package/dist/bundle-core/errors.js +38 -0
- package/dist/bundle-core/four-meme/approve-tokenmanager.d.ts +7 -0
- package/dist/bundle-core/four-meme/approve-tokenmanager.js +99 -0
- package/dist/bundle-core/four-meme/core-helpers.d.ts +8 -0
- package/dist/bundle-core/four-meme/core-helpers.js +41 -0
- package/dist/bundle-core/four-meme/core.d.ts +4 -0
- package/dist/bundle-core/four-meme/core.js +515 -0
- package/dist/bundle-core/four-meme/pancake-proxy.d.ts +28 -0
- package/dist/bundle-core/four-meme/pancake-proxy.js +679 -0
- package/dist/bundle-core/four-meme/private.d.ts +27 -0
- package/dist/bundle-core/four-meme/private.js +465 -0
- package/dist/bundle-core/four-meme/sign-context-helpers.d.ts +2 -0
- package/dist/bundle-core/four-meme/sign-context-helpers.js +2 -0
- package/dist/bundle-core/four-meme/swap-buy-first.d.ts +8 -0
- package/dist/bundle-core/four-meme/swap-buy-first.js +456 -0
- package/dist/bundle-core/four-meme/swap-hop-helpers.d.ts +6 -0
- package/dist/bundle-core/four-meme/swap-hop-helpers.js +63 -0
- package/dist/bundle-core/four-meme/swap-internal.d.ts +3 -0
- package/dist/bundle-core/four-meme/swap-internal.js +18 -0
- package/dist/bundle-core/four-meme/swap-sign-helpers.d.ts +28 -0
- package/dist/bundle-core/four-meme/swap-sign-helpers.js +105 -0
- package/dist/bundle-core/four-meme/swap.d.ts +17 -0
- package/dist/bundle-core/four-meme/swap.js +505 -0
- package/dist/bundle-core/four-meme/types/buy-first.d.ts +50 -0
- package/dist/bundle-core/four-meme/types/buy-first.js +1 -0
- package/dist/bundle-core/four-meme/types/core-flow.d.ts +63 -0
- package/dist/bundle-core/four-meme/types/core-flow.js +1 -0
- package/dist/bundle-core/four-meme/types/index.d.ts +600 -0
- package/dist/bundle-core/four-meme/types/index.js +1 -0
- package/dist/bundle-core/four-meme/types/swap-internal.d.ts +19 -0
- package/dist/bundle-core/four-meme/types/swap-internal.js +1 -0
- package/dist/bundle-core/four-meme/types.d.ts +1 -0
- package/dist/bundle-core/four-meme/types.js +1 -0
- package/dist/bundle-core/four-meme/utils-disperse.d.ts +7 -0
- package/dist/bundle-core/four-meme/utils-disperse.js +396 -0
- package/dist/bundle-core/four-meme/utils-pairwise.d.ts +8 -0
- package/dist/bundle-core/four-meme/utils-pairwise.js +328 -0
- package/dist/bundle-core/four-meme/utils-sweep.d.ts +8 -0
- package/dist/bundle-core/four-meme/utils-sweep.js +744 -0
- package/dist/bundle-core/index.d.ts +8 -0
- package/dist/bundle-core/index.js +8 -0
- package/dist/bundle-core/internal.d.ts +16 -0
- package/dist/bundle-core/internal.js +160 -0
- package/dist/bundle-core/sign-context-helpers.d.ts +26 -0
- package/dist/bundle-core/sign-context-helpers.js +63 -0
- package/dist/bundle-core/submit.d.ts +293 -0
- package/dist/bundle-core/submit.js +731 -0
- package/dist/bundle-core/types/index.d.ts +8 -0
- package/dist/bundle-core/types/index.js +1 -0
- package/dist/bundle-core/types.d.ts +1 -0
- package/dist/bundle-core/types.js +1 -0
- package/dist/chains/bsc/four/approve-tokenmanager.d.ts +1 -26
- package/dist/chains/bsc/four/approve-tokenmanager.js +1 -113
- package/dist/chains/bsc/four/config.d.ts +5 -67
- package/dist/chains/bsc/four/config.js +2 -114
- package/dist/chains/bsc/four/core.d.ts +1 -4
- package/dist/chains/bsc/four/core.js +1 -592
- package/dist/chains/bsc/four/index.d.ts +6 -6
- package/dist/chains/bsc/four/index.js +6 -6
- package/dist/chains/bsc/four/internal.d.ts +2 -46
- package/dist/chains/bsc/four/internal.js +2 -239
- package/dist/chains/bsc/four/pancake-proxy.d.ts +1 -28
- package/dist/chains/bsc/four/pancake-proxy.js +1 -687
- package/dist/chains/bsc/four/private.d.ts +1 -27
- package/dist/chains/bsc/four/private.js +1 -477
- package/dist/chains/bsc/four/submit.d.ts +2 -315
- package/dist/chains/bsc/four/submit.js +2 -752
- package/dist/chains/bsc/four/swap-buy-first.d.ts +2 -55
- package/dist/chains/bsc/four/swap-buy-first.js +2 -507
- package/dist/chains/bsc/four/swap-internal.d.ts +1 -3
- package/dist/chains/bsc/four/swap-internal.js +1 -18
- package/dist/chains/bsc/four/swap.d.ts +2 -144
- package/dist/chains/bsc/four/swap.js +2 -766
- package/dist/chains/bsc/four/types.d.ts +1 -476
- package/dist/chains/bsc/four/utils-disperse.d.ts +1 -0
- package/dist/chains/bsc/four/utils-disperse.js +1 -0
- package/dist/chains/bsc/four/utils-pairwise.d.ts +1 -0
- package/dist/chains/bsc/four/utils-pairwise.js +1 -0
- package/dist/chains/bsc/four/utils-sweep.d.ts +1 -0
- package/dist/chains/bsc/four/utils-sweep.js +1 -0
- package/dist/chains/bsc/four/utils.d.ts +5 -18
- package/dist/chains/bsc/four/utils.js +5 -1552
- package/dist/chains/bsc/iro.d.ts +5 -0
- package/dist/chains/bsc/iro.js +4 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +155 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +80 -0
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -91
- package/dist/chains/bsc/pancake/bundle-buy-first.js +98 -213
- package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +241 -0
- package/dist/chains/bsc/pancake/bundle-swap-helpers.js +565 -0
- package/dist/chains/bsc/pancake/bundle-swap.d.ts +1 -79
- package/dist/chains/bsc/pancake/bundle-swap.js +114 -726
- package/dist/chains/bsc/pancake/index.d.ts +4 -2
- package/dist/chains/bsc/pancake/index.js +1 -3
- package/dist/chains/bsc/platforms/iro/factory.d.ts +2 -2
- package/dist/chains/bsc/platforms/iro/factory.js +3 -1
- package/dist/chains/bsc/platforms/iro/index.d.ts +5 -5
- package/dist/chains/bsc/platforms/iro/index.js +3 -3
- package/dist/chains/bsc/platforms/iro/pool.js +31 -10
- package/dist/chains/bsc/platforms/iro/token.js +4 -1
- package/dist/chains/eni/batch-router/bundle-approve.js +4 -3
- package/dist/chains/eni/batch-router/transfer.js +55 -25
- package/dist/chains/eni/batch-router/utils.js +32 -6
- package/dist/chains/eni/bundler/sign.js +5 -6
- package/dist/chains/eni/bundler/submit.js +1 -4
- package/dist/chains/eni/constants.js +1 -1
- package/dist/chains/eni/flat-aliases.d.ts +10 -0
- package/dist/chains/eni/flat-aliases.js +8 -0
- package/dist/chains/eni/index.d.ts +2 -1
- package/dist/chains/eni/index.js +1 -0
- package/dist/chains/eni/platforms/daoaas/create.js +2 -2
- package/dist/chains/eni/platforms/daoaas/index.d.ts +3 -3
- package/dist/chains/eni/platforms/daoaas/index.js +3 -3
- package/dist/chains/eni/platforms/daoaas/meta.js +9 -6
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +28 -44
- package/dist/chains/eni/platforms/daoaas/portal.js +10 -6
- package/dist/chains/eni/platforms/dswap/liquidity.js +58 -26
- package/dist/chains/eni/platforms/fair-launch/index.d.ts +2 -2
- package/dist/chains/eni/platforms/fair-launch/index.js +1 -1
- package/dist/chains/eni/platforms/fair-launch/launcher.js +87 -46
- package/dist/chains/eni/platforms/fair-launch/pool.js +4 -1
- package/dist/chains/eni/platforms/fair-launch/presets.js +2 -2
- package/dist/chains/eni/platforms/iro/factory.d.ts +2 -2
- package/dist/chains/eni/platforms/iro/factory.js +3 -1
- package/dist/chains/eni/platforms/iro/index.d.ts +6 -6
- package/dist/chains/eni/platforms/iro/index.js +4 -4
- package/dist/chains/eni/platforms/iro/pool.js +90 -26
- package/dist/chains/eni/platforms/iro/token.js +107 -31
- package/dist/chains/eni/platforms/iro/whitelist.js +6 -18
- package/dist/chains/eni/submit.d.ts +43 -0
- package/dist/chains/eni/submit.js +287 -0
- package/dist/chains/index.d.ts +13 -0
- package/dist/chains/index.js +13 -0
- package/dist/chains/xlayer/constants.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/bundle-approve.d.ts +2 -26
- package/dist/chains/xlayer/eip7702/bundle-approve.js +11 -21
- package/dist/chains/xlayer/eip7702/bundle-buy.d.ts +2 -6
- package/dist/chains/xlayer/eip7702/bundle-buy.js +13 -51
- package/dist/chains/xlayer/eip7702/bundle-create.js +104 -74
- package/dist/chains/xlayer/eip7702/bundle-sell.d.ts +2 -6
- package/dist/chains/xlayer/eip7702/bundle-sell.js +29 -111
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +3 -65
- package/dist/chains/xlayer/eip7702/bundle-swap.js +51 -245
- package/dist/chains/xlayer/eip7702/constants.d.ts +11 -26
- package/dist/chains/xlayer/eip7702/constants.js +15 -68
- package/dist/chains/xlayer/eip7702/flat-aliases.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/flat-aliases.js +10 -0
- package/dist/chains/xlayer/eip7702/index.d.ts +28 -46
- package/dist/chains/xlayer/eip7702/index.js +28 -81
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.d.ts +79 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.js +1 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +2 -203
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +63 -307
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.d.ts +26 -0
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.js +58 -0
- package/dist/chains/xlayer/eip7702/types.d.ts +88 -0
- package/dist/chains/xlayer/eip7702/utils.d.ts +0 -3
- package/dist/chains/xlayer/eip7702/utils.js +23 -28
- package/dist/chains/xlayer/eip7702/volume-helpers.d.ts +148 -0
- package/dist/chains/xlayer/eip7702/volume-helpers.js +48 -0
- package/dist/chains/xlayer/eip7702/volume.d.ts +6 -184
- package/dist/chains/xlayer/eip7702/volume.js +89 -164
- package/dist/chains/xlayer/eoa/constants.d.ts +1 -1
- package/dist/chains/xlayer/eoa/constants.js +2 -16
- package/dist/chains/xlayer/eoa/dex-helpers.d.ts +1 -1
- package/dist/chains/xlayer/eoa/dex-helpers.js +7 -37
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +126 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +228 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +1 -95
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +66 -299
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +1 -1
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +18 -23
- package/dist/chains/xlayer/eoa/index.d.ts +10 -6
- package/dist/chains/xlayer/eoa/index.js +8 -23
- package/dist/chains/xlayer/eoa/portal-ops.js +7 -2
- package/dist/chains/xlayer/eoa/router-manager.js +5 -4
- package/dist/chains/xlayer/eoa/types.d.ts +2 -2
- package/dist/chains/xlayer/eoa/types.js +1 -3
- package/dist/chains/xlayer/index.d.ts +3 -2
- package/dist/chains/xlayer/index.js +4 -7
- package/dist/contracts/helper3.d.ts +20 -5
- package/dist/contracts/helper3.js +56 -20
- package/dist/contracts/tm-bundle-helpers.d.ts +88 -0
- package/dist/contracts/tm-bundle-helpers.js +73 -0
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.d.ts +1 -26
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +1 -113
- package/dist/contracts/tm-bundle-merkle/config.d.ts +5 -67
- package/dist/contracts/tm-bundle-merkle/config.js +2 -114
- package/dist/contracts/tm-bundle-merkle/core.d.ts +1 -4
- package/dist/contracts/tm-bundle-merkle/core.js +1 -591
- package/dist/contracts/tm-bundle-merkle/index.d.ts +5 -5
- package/dist/contracts/tm-bundle-merkle/index.js +5 -5
- package/dist/contracts/tm-bundle-merkle/internal.d.ts +2 -46
- package/dist/contracts/tm-bundle-merkle/internal.js +2 -238
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +1 -28
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +1 -686
- package/dist/contracts/tm-bundle-merkle/private.d.ts +1 -27
- package/dist/contracts/tm-bundle-merkle/private.js +1 -476
- package/dist/contracts/tm-bundle-merkle/submit.d.ts +3 -314
- package/dist/contracts/tm-bundle-merkle/submit.js +3 -928
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +2 -55
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +2 -506
- package/dist/contracts/tm-bundle-merkle/swap-internal.d.ts +1 -3
- package/dist/contracts/tm-bundle-merkle/swap-internal.js +1 -18
- package/dist/contracts/tm-bundle-merkle/swap.d.ts +2 -144
- package/dist/contracts/tm-bundle-merkle/swap.js +2 -764
- package/dist/contracts/tm-bundle-merkle/types.d.ts +1 -476
- package/dist/contracts/tm-bundle-merkle/utils-disperse.d.ts +1 -0
- package/dist/contracts/tm-bundle-merkle/utils-disperse.js +1 -0
- package/dist/contracts/tm-bundle-merkle/utils-pairwise.d.ts +1 -0
- package/dist/contracts/tm-bundle-merkle/utils-pairwise.js +1 -0
- package/dist/contracts/tm-bundle-merkle/utils-sweep.d.ts +1 -0
- package/dist/contracts/tm-bundle-merkle/utils-sweep.js +1 -0
- package/dist/contracts/tm-bundle-merkle/utils.d.ts +6 -18
- package/dist/contracts/tm-bundle-merkle/utils.js +6 -1501
- package/dist/contracts/tm-bundle.d.ts +3 -51
- package/dist/contracts/tm-bundle.js +120 -187
- package/dist/contracts/tm.d.ts +10 -8
- package/dist/contracts/tm.js +39 -35
- package/dist/contracts/tm1.js +9 -4
- package/dist/contracts/tm2.js +10 -5
- package/dist/dex/direct-router-helpers.d.ts +269 -0
- package/dist/dex/direct-router-helpers.js +536 -0
- package/dist/dex/direct-router.d.ts +3 -125
- package/dist/dex/direct-router.js +244 -672
- package/dist/dex/types.d.ts +81 -0
- package/dist/dex/types.js +1 -0
- package/dist/exports/root-bundle-and-tooling.d.ts +27 -0
- package/dist/exports/root-bundle-and-tooling.js +30 -0
- package/dist/exports/root-eni-and-bsc-iro.d.ts +26 -0
- package/dist/exports/root-eni-and-bsc-iro.js +66 -0
- package/dist/exports/root-foundations.d.ts +35 -0
- package/dist/exports/root-foundations.js +70 -0
- package/dist/exports/root-swap-dex-and-xlayer.d.ts +30 -0
- package/dist/exports/root-swap-dex-and-xlayer.js +78 -0
- package/dist/flap/index.d.ts +11 -0
- package/dist/flap/index.js +9 -0
- package/dist/flows/create.d.ts +2 -1
- package/dist/flows/create.js +6 -6
- package/dist/flows/index.d.ts +9 -0
- package/dist/flows/index.js +9 -0
- package/dist/index.d.ts +20 -88
- package/dist/index.js +20 -218
- package/dist/merkle/index.d.ts +12 -0
- package/dist/merkle/index.js +11 -0
- package/dist/shared/abis/common.d.ts +2 -83
- package/dist/shared/abis/common.js +2 -254
- package/dist/shared/abis/index.d.ts +5 -6
- package/dist/shared/abis/index.js +5 -7
- package/dist/shared/clients/blockrazor.d.ts +4 -8
- package/dist/shared/clients/blockrazor.js +43 -35
- package/dist/shared/clients/club48.d.ts +2 -2
- package/dist/shared/clients/club48.js +36 -30
- package/dist/shared/clients/emitservice.js +2 -0
- package/dist/shared/clients/four.d.ts +21 -6
- package/dist/shared/clients/four.js +29 -24
- package/dist/shared/clients/index.d.ts +8 -0
- package/dist/shared/clients/index.js +8 -0
- package/dist/shared/clients/merkle.d.ts +4 -3
- package/dist/shared/clients/merkle.js +30 -47
- package/dist/shared/constants/addresses.d.ts +27 -1
- package/dist/shared/constants/addresses.js +39 -2
- package/dist/shared/constants/chains.d.ts +1 -1
- package/dist/shared/constants/chains.js +1 -1
- package/dist/shared/constants/gas.d.ts +1 -1
- package/dist/shared/constants/gas.js +2 -6
- package/dist/shared/constants/index.d.ts +4 -1
- package/dist/shared/constants/index.js +2 -1
- package/dist/shared/constants/quote.d.ts +30 -0
- package/dist/shared/constants/quote.js +37 -0
- package/dist/shared/flap/abi.js +1 -1
- package/dist/shared/flap/constants.d.ts +1 -2
- package/dist/shared/flap/constants.js +3 -4
- package/dist/shared/flap/curve.js +3 -0
- package/dist/shared/flap/errors.d.ts +1 -4
- package/dist/shared/flap/errors.js +20 -1
- package/dist/shared/flap/index.d.ts +4 -5
- package/dist/shared/flap/index.js +4 -5
- package/dist/shared/flap/launch-v6.d.ts +0 -5
- package/dist/shared/flap/launch-v6.js +2 -16
- package/dist/shared/flap/meta.d.ts +22 -18
- package/dist/shared/flap/meta.js +32 -24
- package/dist/shared/flap/permit.js +10 -3
- package/dist/shared/flap/pinata.d.ts +22 -6
- package/dist/shared/flap/pinata.js +21 -26
- package/dist/shared/flap/portal-bundle-merkle/config.d.ts +3 -72
- package/dist/shared/flap/portal-bundle-merkle/config.js +4 -124
- package/dist/shared/flap/portal-bundle-merkle/core-helpers.d.ts +32 -0
- package/dist/shared/flap/portal-bundle-merkle/core-helpers.js +83 -0
- package/dist/shared/flap/portal-bundle-merkle/core.d.ts +0 -4
- package/dist/shared/flap/portal-bundle-merkle/core.js +168 -175
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.d.ts +17 -4
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +96 -117
- package/dist/shared/flap/portal-bundle-merkle/curve-to-dex.js +104 -122
- package/dist/shared/flap/portal-bundle-merkle/index.d.ts +11 -7
- package/dist/shared/flap/portal-bundle-merkle/index.js +4 -7
- package/dist/shared/flap/portal-bundle-merkle/pancake-proxy.js +71 -68
- package/dist/shared/flap/portal-bundle-merkle/private.js +61 -114
- package/dist/shared/flap/portal-bundle-merkle/swap-batch.d.ts +8 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-batch.js +227 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +125 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.js +113 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.d.ts +1 -64
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.js +69 -288
- package/dist/shared/flap/portal-bundle-merkle/swap-cross.d.ts +9 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-cross.js +139 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-helpers.d.ts +149 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-helpers.js +259 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-planning.d.ts +70 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-planning.js +182 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-quick-batch.d.ts +16 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-quick-batch.js +327 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-single.d.ts +2 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-single.js +184 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-types.d.ts +101 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-types.js +1 -0
- package/dist/shared/flap/portal-bundle-merkle/swap.d.ts +6 -199
- package/dist/shared/flap/portal-bundle-merkle/swap.js +5 -1357
- package/dist/shared/flap/portal-bundle-merkle/types.d.ts +88 -12
- package/dist/shared/flap/portal-bundle-merkle/utils.d.ts +1 -80
- package/dist/shared/flap/portal-bundle-merkle/utils.js +145 -265
- package/dist/shared/flap/portal-bundle.js +83 -78
- package/dist/shared/flap/portal-create-token.d.ts +39 -21
- package/dist/shared/flap/portal-create-token.js +121 -124
- package/dist/shared/flap/portal.d.ts +1 -2
- package/dist/shared/flap/portal.js +36 -28
- package/dist/shared/flap/vanity.d.ts +6 -6
- package/dist/shared/flap/vanity.js +15 -21
- package/dist/shared/flap/vault.d.ts +25 -93
- package/dist/shared/flap/vault.js +77 -127
- package/dist/shared/foundation/amount/split-by-weight.d.ts +5 -0
- package/dist/shared/foundation/amount/split-by-weight.js +35 -0
- package/dist/shared/foundation/dex/v3-path.d.ts +6 -0
- package/dist/shared/foundation/dex/v3-path.js +35 -0
- package/dist/shared/foundation/erc20/decimals.d.ts +7 -0
- package/dist/shared/foundation/erc20/decimals.js +24 -0
- package/dist/shared/foundation/gas/bundle-gas.d.ts +49 -0
- package/dist/shared/foundation/gas/bundle-gas.js +93 -0
- package/dist/shared/foundation/gas/profit-hop.d.ts +20 -0
- package/dist/shared/foundation/gas/profit-hop.js +72 -0
- package/dist/shared/foundation/index.d.ts +15 -0
- package/dist/shared/foundation/index.js +14 -0
- package/dist/shared/foundation/nonce/nonce-manager.d.ts +19 -0
- package/dist/shared/foundation/nonce/nonce-manager.js +217 -0
- package/dist/shared/foundation/normalize-unknown.d.ts +9 -0
- package/dist/shared/foundation/normalize-unknown.js +29 -0
- package/dist/shared/foundation/sdk-logger.d.ts +13 -0
- package/dist/shared/foundation/sdk-logger.js +12 -0
- package/dist/shared/foundation/tx/build-request.d.ts +17 -0
- package/dist/shared/foundation/tx/build-request.js +25 -0
- package/dist/shared/foundation/tx/sign-batch.d.ts +5 -0
- package/dist/shared/foundation/tx/sign-batch.js +26 -0
- package/dist/shared/foundation/tx/wallet-sign-patch.d.ts +1 -0
- package/dist/shared/foundation/tx/wallet-sign-patch.js +18 -0
- package/dist/shared/foundation/types/airdrop-sweep.d.ts +79 -0
- package/dist/shared/foundation/types/airdrop-sweep.js +1 -0
- package/dist/shared/foundation/types/erc20.d.ts +65 -0
- package/dist/shared/foundation/types/erc20.js +1 -0
- package/dist/shared/foundation/types/holders-maker.d.ts +64 -0
- package/dist/shared/foundation/types/holders-maker.js +1 -0
- package/dist/shared/foundation/types/index.d.ts +7 -0
- package/dist/shared/foundation/types/index.js +1 -0
- package/dist/shared/foundation/types/lp-inspect.d.ts +102 -0
- package/dist/shared/foundation/types/lp-inspect.js +1 -0
- package/dist/shared/foundation/types/multicall.d.ts +5 -0
- package/dist/shared/foundation/types/multicall.js +1 -0
- package/dist/shared/foundation/types/private-sale.d.ts +35 -0
- package/dist/shared/foundation/types/private-sale.js +1 -0
- package/dist/shared/foundation/types/quote-helpers.d.ts +17 -0
- package/dist/shared/foundation/types/quote-helpers.js +1 -0
- package/dist/shared/foundation/wallet/generate.d.ts +5 -0
- package/dist/shared/foundation/wallet/generate.js +8 -0
- package/dist/shared/four/tax-token.d.ts +1 -1
- package/dist/shared/four/tax-token.js +31 -10
- package/dist/shared/index.d.ts +6 -0
- package/dist/shared/index.js +4 -0
- package/dist/types/errors.d.ts +27 -0
- package/dist/types/errors.js +34 -0
- package/dist/utils/airdrop-sweep.d.ts +4 -76
- package/dist/utils/airdrop-sweep.js +42 -55
- package/dist/utils/bundle-helpers.d.ts +9 -243
- package/dist/utils/bundle-helpers.js +10 -584
- package/dist/utils/constants.d.ts +5 -61
- package/dist/utils/constants.js +5 -80
- package/dist/utils/contract-factory.d.ts +2 -4
- package/dist/utils/contract-factory.js +25 -18
- package/dist/utils/erc20.d.ts +7 -89
- package/dist/utils/erc20.js +98 -129
- package/dist/utils/errors.d.ts +12 -1
- package/dist/utils/errors.js +60 -1
- package/dist/utils/holders-maker/addresses.d.ts +12 -0
- package/dist/utils/holders-maker/addresses.js +15 -0
- package/dist/utils/holders-maker/buy-tx.d.ts +44 -0
- package/dist/utils/holders-maker/buy-tx.js +278 -0
- package/dist/utils/holders-maker/constants.d.ts +6 -0
- package/dist/utils/holders-maker/constants.js +7 -0
- package/dist/utils/holders-maker/disperse.d.ts +18 -0
- package/dist/utils/holders-maker/disperse.js +90 -0
- package/dist/utils/holders-maker/routing.d.ts +4 -0
- package/dist/utils/holders-maker/routing.js +45 -0
- package/dist/utils/holders-maker/transfer-tx.d.ts +4 -0
- package/dist/utils/holders-maker/transfer-tx.js +67 -0
- package/dist/utils/holders-maker-helpers.d.ts +9 -0
- package/dist/utils/holders-maker-helpers.js +9 -0
- package/dist/utils/holders-maker.d.ts +2 -138
- package/dist/utils/holders-maker.js +50 -671
- package/dist/utils/hop-chains.d.ts +35 -0
- package/dist/utils/hop-chains.js +215 -0
- package/dist/utils/lp-inspect-helpers.d.ts +9 -0
- package/dist/utils/lp-inspect-helpers.js +109 -0
- package/dist/utils/lp-inspect.d.ts +2 -112
- package/dist/utils/lp-inspect.js +78 -293
- package/dist/utils/mpcExclusive.d.ts +2 -5
- package/dist/utils/mpcExclusive.js +4 -3
- package/dist/utils/pcs-infinity-cl.js +18 -54
- package/dist/utils/private-sale.d.ts +2 -58
- package/dist/utils/private-sale.js +4 -15
- package/dist/utils/provider-factory.d.ts +4 -0
- package/dist/utils/provider-factory.js +10 -0
- package/dist/utils/quote-helpers.d.ts +4 -45
- package/dist/utils/quote-helpers.js +17 -74
- package/dist/utils/stealth-transfer.d.ts +2 -28
- package/dist/utils/stealth-transfer.js +39 -19
- package/dist/utils/swap-helpers.d.ts +2 -15
- package/dist/utils/swap-helpers.js +6 -11
- package/dist/utils/types/airdrop-sweep.d.ts +1 -0
- package/dist/utils/types/airdrop-sweep.js +1 -0
- package/dist/utils/types/contract-factory.d.ts +1 -0
- package/dist/utils/types/contract-factory.js +1 -0
- package/dist/utils/types/erc20.d.ts +1 -0
- package/dist/utils/types/erc20.js +1 -0
- package/dist/utils/types/errors.d.ts +1 -0
- package/dist/utils/types/errors.js +1 -0
- package/dist/utils/types/holders-maker.d.ts +1 -0
- package/dist/utils/types/holders-maker.js +1 -0
- package/dist/utils/types/hop-chains.d.ts +8 -0
- package/dist/utils/types/hop-chains.js +1 -0
- package/dist/utils/types/index.d.ts +13 -0
- package/dist/utils/types/index.js +1 -0
- package/dist/utils/types/lp-inspect.d.ts +1 -0
- package/dist/utils/types/lp-inspect.js +1 -0
- package/dist/utils/types/mpc-exclusive.d.ts +5 -0
- package/dist/utils/types/mpc-exclusive.js +1 -0
- package/dist/utils/types/private-sale.d.ts +1 -0
- package/dist/utils/types/private-sale.js +1 -0
- package/dist/utils/types/quote-helpers.d.ts +1 -0
- package/dist/utils/types/quote-helpers.js +1 -0
- package/dist/utils/types/stealth-transfer.d.ts +44 -0
- package/dist/utils/types/stealth-transfer.js +1 -0
- package/dist/utils/types/wallet.d.ts +25 -0
- package/dist/utils/types/wallet.js +1 -0
- package/dist/utils/wallet.d.ts +4 -25
- package/dist/utils/wallet.js +27 -22
- package/dist/vanity/index.d.ts +5 -0
- package/dist/vanity/index.js +5 -0
- package/package.json +100 -2
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
|
+
import { ZERO_ADDRESS } from '../constants/index.js';
|
|
3
4
|
/**
|
|
4
5
|
* 48.club Bundle 客户端
|
|
5
6
|
*/
|
|
6
7
|
export class Club48Client {
|
|
8
|
+
endpoint;
|
|
9
|
+
explorerEndpoint;
|
|
7
10
|
constructor(config) {
|
|
8
11
|
this.endpoint = config?.endpoint || 'https://puissant-bsc.48.club';
|
|
9
12
|
this.explorerEndpoint = config?.explorerEndpoint || 'https://explore.48.club';
|
|
@@ -18,7 +21,7 @@ export class Club48Client {
|
|
|
18
21
|
*/
|
|
19
22
|
static sign48SoulPoint(privateKey, txs) {
|
|
20
23
|
// 1. 计算每笔交易的哈希
|
|
21
|
-
const txHashes = txs.map(tx => ethers.keccak256(tx));
|
|
24
|
+
const txHashes = txs.map((tx) => ethers.keccak256(tx));
|
|
22
25
|
// 2. 连接所有哈希
|
|
23
26
|
const concatenated = ethers.concat(txHashes);
|
|
24
27
|
// 3. 对连接后的数据进行哈希
|
|
@@ -103,7 +106,7 @@ export class Club48Client {
|
|
|
103
106
|
}
|
|
104
107
|
// 添加 Soul Point 签名(优先:调用方直接提供;否则按 opts 生成)
|
|
105
108
|
if (params.soulPointSignature) {
|
|
106
|
-
bundleParams[
|
|
109
|
+
bundleParams['48spSign'] = params.soulPointSignature;
|
|
107
110
|
}
|
|
108
111
|
else if (opts && opts.spMode && opts.spMode !== 'none') {
|
|
109
112
|
if (!opts.spPrivateKey) {
|
|
@@ -121,17 +124,17 @@ export class Club48Client {
|
|
|
121
124
|
}
|
|
122
125
|
if (opts.spVMode)
|
|
123
126
|
sig = Club48Client.normalizeSignatureV(sig, opts.spVMode);
|
|
124
|
-
bundleParams[
|
|
127
|
+
bundleParams['48spSign'] = sig;
|
|
125
128
|
}
|
|
126
129
|
// 添加 backrun 目标(如果提供)
|
|
127
130
|
if (params.backrunTarget) {
|
|
128
131
|
bundleParams.backrunTarget = params.backrunTarget;
|
|
129
132
|
}
|
|
130
133
|
const response = await axios.post(this.endpoint, {
|
|
131
|
-
jsonrpc:
|
|
134
|
+
jsonrpc: '2.0',
|
|
132
135
|
id: 1,
|
|
133
|
-
method:
|
|
134
|
-
params: [bundleParams]
|
|
136
|
+
method: 'eth_sendBundle',
|
|
137
|
+
params: [bundleParams],
|
|
135
138
|
});
|
|
136
139
|
if (response.data.error) {
|
|
137
140
|
throw new Error(`48.club bundle failed: ${response.data.error.message}`);
|
|
@@ -146,10 +149,10 @@ export class Club48Client {
|
|
|
146
149
|
*/
|
|
147
150
|
async sendPrivateTransaction(signedTx) {
|
|
148
151
|
const response = await axios.post(this.endpoint, {
|
|
149
|
-
jsonrpc:
|
|
152
|
+
jsonrpc: '2.0',
|
|
150
153
|
id: 1,
|
|
151
|
-
method:
|
|
152
|
-
params: [signedTx]
|
|
154
|
+
method: 'eth_sendPrivateRawTransaction',
|
|
155
|
+
params: [signedTx],
|
|
153
156
|
});
|
|
154
157
|
if (response.data.error) {
|
|
155
158
|
throw new Error(`48.club tx failed: ${response.data.error.message}`);
|
|
@@ -168,7 +171,7 @@ export class Club48Client {
|
|
|
168
171
|
async sendPrivateTransactionWith48SP(signedTx, spPrivateKey, opts) {
|
|
169
172
|
// 1) 生成 48SP 签名(默认使用 timestamp personal_sign)
|
|
170
173
|
const mode = opts?.spMode ?? 'timestampPersonalSign';
|
|
171
|
-
let signature
|
|
174
|
+
let signature;
|
|
172
175
|
if (mode === 'timestampPersonalSign') {
|
|
173
176
|
signature = await Club48Client.sign48SoulPointTimestamp(spPrivateKey, opts?.timestamp);
|
|
174
177
|
}
|
|
@@ -179,10 +182,10 @@ export class Club48Client {
|
|
|
179
182
|
signature = Club48Client.normalizeSignatureV(signature, opts.spVMode);
|
|
180
183
|
// 2) 调用 48.club RPC
|
|
181
184
|
const response = await axios.post(this.endpoint, {
|
|
182
|
-
jsonrpc:
|
|
185
|
+
jsonrpc: '2.0',
|
|
183
186
|
id: 1,
|
|
184
|
-
method:
|
|
185
|
-
params: [signedTx, signature]
|
|
187
|
+
method: 'eth_sendPrivateTransactionWith48SP',
|
|
188
|
+
params: [signedTx, signature],
|
|
186
189
|
});
|
|
187
190
|
if (response.data.error) {
|
|
188
191
|
throw new Error(`48.club tx failed: ${response.data.error.message}`);
|
|
@@ -196,9 +199,9 @@ export class Club48Client {
|
|
|
196
199
|
*/
|
|
197
200
|
async getMinGasPrice() {
|
|
198
201
|
const response = await axios.post(this.endpoint, {
|
|
199
|
-
jsonrpc:
|
|
202
|
+
jsonrpc: '2.0',
|
|
200
203
|
id: 1,
|
|
201
|
-
method:
|
|
204
|
+
method: 'eth_gasPrice',
|
|
202
205
|
});
|
|
203
206
|
if (response.data.error) {
|
|
204
207
|
throw new Error(`Get gas price failed: ${response.data.error.message}`);
|
|
@@ -237,12 +240,15 @@ export class Club48Client {
|
|
|
237
240
|
throw new Error(`Bundle failed to execute: ${JSON.stringify(status)}`);
|
|
238
241
|
}
|
|
239
242
|
// 等待 3 秒后重试
|
|
240
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
243
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
241
244
|
}
|
|
242
245
|
catch (error) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
+
const status = axios.isAxiosError(error) ? error.response?.status : undefined;
|
|
247
|
+
const nodeCode = typeof error === 'object' && error !== null && 'code' in error
|
|
248
|
+
? String(error.code ?? '')
|
|
249
|
+
: '';
|
|
250
|
+
if (status === 404 || nodeCode === 'ECONNREFUSED' || nodeCode === 'ENOTFOUND') {
|
|
251
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
246
252
|
continue;
|
|
247
253
|
}
|
|
248
254
|
// 其他错误,如果有最后状态且为 INCLUDED,返回成功
|
|
@@ -266,10 +272,10 @@ export class Club48Client {
|
|
|
266
272
|
hash: bundleHash,
|
|
267
273
|
maxTimestamp: Math.floor(Date.now() / 1000) + 300,
|
|
268
274
|
transaction: {
|
|
269
|
-
from:
|
|
275
|
+
from: ZERO_ADDRESS,
|
|
270
276
|
gasPrice: '0',
|
|
271
|
-
nonce: 0
|
|
272
|
-
}
|
|
277
|
+
nonce: 0,
|
|
278
|
+
},
|
|
273
279
|
};
|
|
274
280
|
}
|
|
275
281
|
}
|
|
@@ -282,11 +288,11 @@ export function createAuctionFeedClient(wsUrl, callbacks) {
|
|
|
282
288
|
// 仅导出接口占位,避免引入 ws 依赖;用户可在应用层实现
|
|
283
289
|
return {
|
|
284
290
|
connect: () => {
|
|
285
|
-
callbacks.onOpen
|
|
291
|
+
callbacks.onOpen?.();
|
|
286
292
|
},
|
|
287
293
|
close: () => {
|
|
288
|
-
callbacks.onClose
|
|
289
|
-
}
|
|
294
|
+
callbacks.onClose?.();
|
|
295
|
+
},
|
|
290
296
|
};
|
|
291
297
|
}
|
|
292
298
|
/**
|
|
@@ -295,7 +301,7 @@ export function createAuctionFeedClient(wsUrl, callbacks) {
|
|
|
295
301
|
export async function sendBatchPrivateTransactions(signedTxs, spPrivateKey, endpoint = 'https://puissant-bsc.48.club', opts) {
|
|
296
302
|
// 1. 生成 48SP 签名
|
|
297
303
|
const mode = opts?.spMode ?? 'timestampPersonalSign';
|
|
298
|
-
let signature
|
|
304
|
+
let signature;
|
|
299
305
|
if (mode === 'timestampPersonalSign') {
|
|
300
306
|
signature = await Club48Client.sign48SoulPointTimestamp(spPrivateKey, opts?.timestamp);
|
|
301
307
|
}
|
|
@@ -306,13 +312,13 @@ export async function sendBatchPrivateTransactions(signedTxs, spPrivateKey, endp
|
|
|
306
312
|
signature = Club48Client.normalizeSignatureV(signature, opts.spVMode);
|
|
307
313
|
// 2. 批量提交
|
|
308
314
|
const response = await axios.post(endpoint, {
|
|
309
|
-
jsonrpc:
|
|
315
|
+
jsonrpc: '2.0',
|
|
310
316
|
id: 1,
|
|
311
|
-
method:
|
|
317
|
+
method: 'eth_sendBatchPrivateTransactionsWith48SP',
|
|
312
318
|
params: [
|
|
313
319
|
signedTxs, // 已签名的交易数组
|
|
314
|
-
signature // 48SP 签名
|
|
315
|
-
]
|
|
320
|
+
signature, // 48SP 签名
|
|
321
|
+
],
|
|
316
322
|
});
|
|
317
323
|
// 注意:批量方法不返回交易哈希,只确认接收
|
|
318
324
|
if (response.data.error) {
|
|
@@ -87,14 +87,26 @@ export type CreateTokenReq = {
|
|
|
87
87
|
funGroup: false;
|
|
88
88
|
clickFun: false;
|
|
89
89
|
};
|
|
90
|
+
export type FourJsonValue = string | number | boolean | null | FourJsonValue[] | {
|
|
91
|
+
[key: string]: FourJsonValue;
|
|
92
|
+
};
|
|
93
|
+
export type FourPublicConfig = {
|
|
94
|
+
[key: string]: FourJsonValue;
|
|
95
|
+
};
|
|
96
|
+
export type FourTokenDetail = {
|
|
97
|
+
[key: string]: FourJsonValue;
|
|
98
|
+
} & {
|
|
99
|
+
address?: string;
|
|
100
|
+
name?: string;
|
|
101
|
+
symbol?: string;
|
|
102
|
+
};
|
|
90
103
|
export type CreateTokenResp = {
|
|
91
104
|
createArg: string;
|
|
92
105
|
signature: string;
|
|
93
106
|
tokenAddr?: string;
|
|
94
107
|
address?: string;
|
|
95
108
|
token?: string;
|
|
96
|
-
|
|
97
|
-
};
|
|
109
|
+
} & Record<string, string | undefined>;
|
|
98
110
|
export declare class FourClient {
|
|
99
111
|
private baseUrl;
|
|
100
112
|
private uploadUrls;
|
|
@@ -124,9 +136,12 @@ export declare class FourClient {
|
|
|
124
136
|
private isCorsOrNetworkError;
|
|
125
137
|
private getFilenameFromBlob;
|
|
126
138
|
createToken(accessToken: string, req: CreateTokenReq): Promise<CreateTokenResp>;
|
|
127
|
-
getPublicConfig(): Promise<
|
|
128
|
-
getTokenByAddress(address: string, accessToken?: string): Promise<
|
|
129
|
-
getTokensByAddresses(addresses: string[], accessToken?: string): Promise<
|
|
130
|
-
|
|
139
|
+
getPublicConfig(): Promise<FourPublicConfig>;
|
|
140
|
+
getTokenByAddress(address: string, accessToken?: string): Promise<FourTokenDetail>;
|
|
141
|
+
getTokensByAddresses(addresses: string[], accessToken?: string): Promise<(FourTokenDetail | {
|
|
142
|
+
address: string;
|
|
143
|
+
error: string;
|
|
144
|
+
})[]>;
|
|
145
|
+
getTokenById(id: string | number, accessToken?: string): Promise<FourTokenDetail>;
|
|
131
146
|
}
|
|
132
147
|
export declare function buildLoginMessage(nonce: string): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getErrorMessageFromUnknown } from '../foundation/index.js';
|
|
1
2
|
// ============================================================================
|
|
2
3
|
// 图片上传缓存(按内容哈希去重,同一张图片只上传一次)
|
|
3
4
|
// ✅ 使用 localStorage 持久化,刷新页面 / 重启浏览器后缓存仍然有效
|
|
@@ -38,7 +39,9 @@ function saveCache() {
|
|
|
38
39
|
return;
|
|
39
40
|
const cache = loadCache();
|
|
40
41
|
const obj = {};
|
|
41
|
-
cache.forEach((v, k) => {
|
|
42
|
+
cache.forEach((v, k) => {
|
|
43
|
+
obj[k] = v;
|
|
44
|
+
});
|
|
42
45
|
localStorage.setItem(UPLOAD_CACHE_KEY, JSON.stringify(obj));
|
|
43
46
|
}
|
|
44
47
|
catch {
|
|
@@ -72,7 +75,7 @@ async function hashBlob(blob) {
|
|
|
72
75
|
const buffer = await blob.arrayBuffer();
|
|
73
76
|
const hashBuffer = await crypto.subtle.digest('SHA-256', buffer);
|
|
74
77
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
75
|
-
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
78
|
+
return hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');
|
|
76
79
|
}
|
|
77
80
|
/** IP 限流错误码 */
|
|
78
81
|
const RATE_LIMIT_CODE = -1038;
|
|
@@ -84,6 +87,8 @@ const RATE_LIMIT_CODE = -1038;
|
|
|
84
87
|
*/
|
|
85
88
|
const FOUR_MEME_OFFICIAL_API = 'https://four.meme/meme-api';
|
|
86
89
|
export class FourClient {
|
|
90
|
+
baseUrl;
|
|
91
|
+
uploadUrls;
|
|
87
92
|
constructor(cfg) {
|
|
88
93
|
// 默认使用 Cloudflare Workers 代理,已配置 CORS,浏览器可直接使用
|
|
89
94
|
this.baseUrl = cfg?.baseUrl || 'https://bscfourapi.emit.tools';
|
|
@@ -135,7 +140,6 @@ export class FourClient {
|
|
|
135
140
|
const hash = await hashBlob(file);
|
|
136
141
|
const cached = getCachedUrl(hash);
|
|
137
142
|
if (cached) {
|
|
138
|
-
console.log(`[FourClient] 图片命中缓存,跳过上传 (hash: ${hash.slice(0, 12)}...)`);
|
|
139
143
|
return cached;
|
|
140
144
|
}
|
|
141
145
|
const finalFilename = filename || this.getFilenameFromBlob(file);
|
|
@@ -148,22 +152,20 @@ export class FourClient {
|
|
|
148
152
|
const imgUrl = await this.doUpload(baseUrl, accessToken, file, finalFilename);
|
|
149
153
|
// 上传成功,写入持久化缓存(localStorage)
|
|
150
154
|
setCachedUrl(hash, imgUrl);
|
|
151
|
-
if (i > 0) {
|
|
152
|
-
console.log(`[FourClient] 使用${isOfficial ? '官方直连' : '备用'}端点上传成功: ${baseUrl}`);
|
|
153
|
-
}
|
|
154
155
|
return imgUrl;
|
|
155
156
|
}
|
|
156
157
|
catch (e) {
|
|
157
|
-
|
|
158
|
+
const err = e instanceof Error ? e : new Error(getErrorMessageFromUnknown(e));
|
|
159
|
+
lastError = err;
|
|
158
160
|
const canRetry = i < this.uploadUrls.length - 1;
|
|
159
|
-
if (this.isRateLimitError(
|
|
161
|
+
if (this.isRateLimitError(err) && canRetry) {
|
|
160
162
|
// IP 限流 → 切下一个端点
|
|
161
163
|
const nextUrl = this.uploadUrls[i + 1];
|
|
162
164
|
const nextLabel = nextUrl === FOUR_MEME_OFFICIAL_API ? '官方直连' : `备用端点 #${i + 2}`;
|
|
163
165
|
console.warn(`[FourClient] 端点 ${baseUrl} 触发 IP 限流(100次/天),切换到${nextLabel}...`);
|
|
164
166
|
continue;
|
|
165
167
|
}
|
|
166
|
-
if (this.isCorsOrNetworkError(
|
|
168
|
+
if (this.isCorsOrNetworkError(err) && canRetry) {
|
|
167
169
|
// CORS/网络错误(常见于浏览器直连官方 API)→ 跳过,继续尝试下一个
|
|
168
170
|
console.warn(`[FourClient] 端点 ${baseUrl} 请求失败(${isOfficial ? 'CORS限制' : '网络错误'}),跳过`);
|
|
169
171
|
continue;
|
|
@@ -177,9 +179,11 @@ export class FourClient {
|
|
|
177
179
|
if (isRateLimit) {
|
|
178
180
|
throw new Error(`图片上传失败:所有端点均触发 IP 限流(每IP每天100次)。` +
|
|
179
181
|
`请等待次日重置,或在 FourConfig.uploadFallbackUrls 中添加不同 IP 的备用代理。` +
|
|
180
|
-
`\n原始错误: ${lastError
|
|
182
|
+
`\n原始错误: ${getErrorMessageFromUnknown(lastError)}`);
|
|
181
183
|
}
|
|
182
|
-
|
|
184
|
+
if (lastError !== null && lastError !== undefined)
|
|
185
|
+
throw lastError;
|
|
186
|
+
throw new Error('upload failed: all endpoints exhausted');
|
|
183
187
|
}
|
|
184
188
|
/**
|
|
185
189
|
* 执行单次上传请求
|
|
@@ -194,9 +198,9 @@ export class FourClient {
|
|
|
194
198
|
});
|
|
195
199
|
const j = await r.json();
|
|
196
200
|
if (j.code !== '0' && j.code !== 0) {
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
throw
|
|
201
|
+
const uploadErr = new Error(`upload failed: ${JSON.stringify(j)}`);
|
|
202
|
+
uploadErr.apiCode = typeof j.code === 'string' ? parseInt(j.code, 10) : Number(j.code);
|
|
203
|
+
throw uploadErr;
|
|
200
204
|
}
|
|
201
205
|
return j.data; // imgUrl
|
|
202
206
|
}
|
|
@@ -204,12 +208,13 @@ export class FourClient {
|
|
|
204
208
|
* 判断是否为 IP 限流错误(code: -1038)
|
|
205
209
|
*/
|
|
206
210
|
isRateLimitError(e) {
|
|
207
|
-
if (e
|
|
211
|
+
if (e !== null &&
|
|
212
|
+
typeof e === 'object' &&
|
|
213
|
+
'apiCode' in e &&
|
|
214
|
+
e.apiCode === RATE_LIMIT_CODE) {
|
|
208
215
|
return true;
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return true;
|
|
212
|
-
return false;
|
|
216
|
+
}
|
|
217
|
+
return getErrorMessageFromUnknown(e).includes('-1038');
|
|
213
218
|
}
|
|
214
219
|
/**
|
|
215
220
|
* 判断是否为 CORS 或网络错误
|
|
@@ -218,7 +223,7 @@ export class FourClient {
|
|
|
218
223
|
isCorsOrNetworkError(e) {
|
|
219
224
|
if (e instanceof TypeError)
|
|
220
225
|
return true; // fetch CORS / network failure
|
|
221
|
-
const msg = e
|
|
226
|
+
const msg = getErrorMessageFromUnknown(e).toLowerCase();
|
|
222
227
|
return msg.includes('failed to fetch') || msg.includes('network') || msg.includes('cors');
|
|
223
228
|
}
|
|
224
229
|
getFilenameFromBlob(blob) {
|
|
@@ -247,7 +252,7 @@ export class FourClient {
|
|
|
247
252
|
}
|
|
248
253
|
async getPublicConfig() {
|
|
249
254
|
const r = await fetch(`${this.baseUrl}/v1/public/config`);
|
|
250
|
-
return await r.json();
|
|
255
|
+
return (await r.json());
|
|
251
256
|
}
|
|
252
257
|
async getTokenByAddress(address, accessToken) {
|
|
253
258
|
const r = await fetch(`${this.baseUrl}/v1/private/token/get?address=${address}`, {
|
|
@@ -257,12 +262,12 @@ export class FourClient {
|
|
|
257
262
|
if (j.code && j.code !== '0' && j.code !== 0) {
|
|
258
263
|
throw new Error(`getTokenByAddress failed: ${JSON.stringify(j)}`);
|
|
259
264
|
}
|
|
260
|
-
return j.data ?? j;
|
|
265
|
+
return (j.data ?? j);
|
|
261
266
|
}
|
|
262
267
|
async getTokensByAddresses(addresses, accessToken) {
|
|
263
268
|
if (!Array.isArray(addresses) || addresses.length === 0)
|
|
264
269
|
return [];
|
|
265
|
-
const tasks = addresses.map((addr) => this.getTokenByAddress(addr, accessToken).catch((e) => ({ address: addr, error:
|
|
270
|
+
const tasks = addresses.map((addr) => this.getTokenByAddress(addr, accessToken).catch((e) => ({ address: addr, error: getErrorMessageFromUnknown(e) })));
|
|
266
271
|
return await Promise.all(tasks);
|
|
267
272
|
}
|
|
268
273
|
async getTokenById(id, accessToken) {
|
|
@@ -273,7 +278,7 @@ export class FourClient {
|
|
|
273
278
|
if (j.code && j.code !== '0' && j.code !== 0) {
|
|
274
279
|
throw new Error(`getTokenById failed: ${JSON.stringify(j)}`);
|
|
275
280
|
}
|
|
276
|
-
return j.data ?? j;
|
|
281
|
+
return (j.data ?? j);
|
|
277
282
|
}
|
|
278
283
|
}
|
|
279
284
|
export function buildLoginMessage(nonce) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP / Bundle 客户端统一出口(不替代根包的扁平别名,仅供子路径导入)
|
|
3
|
+
*/
|
|
4
|
+
export { FourClient, buildLoginMessage, type FourConfig, type GenerateNonceReq, type LoginReq, type CreateTokenReq, type CreateTokenResp, type FourTokenTaxInfo, } from './four.js';
|
|
5
|
+
export { Club48Client, sendBatchPrivateTransactions, sendBackrunBundle, type BundleParams, type BundleStatus, type Club48Config, } from './club48.js';
|
|
6
|
+
export { MerkleClient, createMerkleClient, type MerkleConfig, type BundleParams as MerkleBundleParams, type SendBundleOptions, type BundleResult, type TransactionResult, } from './merkle.js';
|
|
7
|
+
export { BlockRazorClient, createBlockRazorClient, BLOCKRAZOR_BUILDER_EOA, type BlockRazorConfig, type BlockRazorBundleParams, type SendBundleOptions as BlockRazorSendBundleOptions, type BundleResult as BlockRazorBundleResult, type TransactionResult as BlockRazorTransactionResult, type IncentiveTransactionParams, } from './blockrazor.js';
|
|
8
|
+
export { EmitServiceClient, submitToEmitServiceBlockRazor, type EmitServiceClientConfig, type EmitServiceSubmitRequest, type EmitServiceSubmitResponse, type EmitServiceSubmitResponseData, type EmitServiceRouteConfigResponse, } from './emitservice.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP / Bundle 客户端统一出口(不替代根包的扁平别名,仅供子路径导入)
|
|
3
|
+
*/
|
|
4
|
+
export { FourClient, buildLoginMessage, } from './four.js';
|
|
5
|
+
export { Club48Client, sendBatchPrivateTransactions, sendBackrunBundle, } from './club48.js';
|
|
6
|
+
export { MerkleClient, createMerkleClient, } from './merkle.js';
|
|
7
|
+
export { BlockRazorClient, createBlockRazorClient, BLOCKRAZOR_BUILDER_EOA, } from './blockrazor.js';
|
|
8
|
+
export { EmitServiceClient, submitToEmitServiceBlockRazor, } from './emitservice.js';
|
|
@@ -21,14 +21,15 @@
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
import { JsonRpcProvider, Wallet, TransactionLike } from 'ethers';
|
|
24
|
+
import { CHAINS } from '../constants/index.js';
|
|
24
25
|
/**
|
|
25
26
|
* Merkle 客户端配置
|
|
26
27
|
*/
|
|
27
28
|
export interface MerkleConfig {
|
|
28
29
|
/** Merkle API Key (例如: pk_mbs_...) */
|
|
29
30
|
apiKey: string;
|
|
30
|
-
/** 链 ID:
|
|
31
|
-
chainId:
|
|
31
|
+
/** 链 ID: BSC 或 Ethereum */
|
|
32
|
+
chainId: typeof CHAINS.BSC.chainId | typeof CHAINS.ETHEREUM.chainId;
|
|
32
33
|
/** 自定义 RPC URL(可选,默认使用 Merkle 官方 RPC) */
|
|
33
34
|
customRpcUrl?: string;
|
|
34
35
|
}
|
|
@@ -207,4 +208,4 @@ export declare class MerkleClient {
|
|
|
207
208
|
/**
|
|
208
209
|
* 创建 Merkle 客户端的便捷函数
|
|
209
210
|
*/
|
|
210
|
-
export declare function createMerkleClient(apiKey: string, chainId?:
|
|
211
|
+
export declare function createMerkleClient(apiKey: string, chainId?: typeof CHAINS.BSC.chainId | typeof CHAINS.ETHEREUM.chainId): MerkleClient;
|
|
@@ -20,16 +20,21 @@
|
|
|
20
20
|
* });
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
import { JsonRpcProvider, Transaction } from 'ethers';
|
|
23
|
+
import { JsonRpcProvider, Transaction, formatEther } from 'ethers';
|
|
24
24
|
import { CHAINS } from '../constants/index.js';
|
|
25
|
+
import { getErrorMessageFromUnknown } from '../foundation/index.js';
|
|
25
26
|
/**
|
|
26
27
|
* Merkle 客户端
|
|
27
28
|
*/
|
|
28
29
|
export class MerkleClient {
|
|
30
|
+
provider;
|
|
31
|
+
chainId;
|
|
32
|
+
chainName;
|
|
33
|
+
// ✅ 区块号缓存(减少 RPC 调用)
|
|
34
|
+
// 注意:TTL 设为 1 秒,确保区块号尽可能新鲜,减少 "Missed inclusion" 风险
|
|
35
|
+
blockNumberCache = null;
|
|
36
|
+
static BLOCK_CACHE_TTL_MS = 1000; // 1秒缓存(BSC 约 3 秒出块,ETH 约 12 秒)
|
|
29
37
|
constructor(config) {
|
|
30
|
-
// ✅ 区块号缓存(减少 RPC 调用)
|
|
31
|
-
// 注意:TTL 设为 1 秒,确保区块号尽可能新鲜,减少 "Missed inclusion" 风险
|
|
32
|
-
this.blockNumberCache = null;
|
|
33
38
|
this.chainId = config.chainId;
|
|
34
39
|
this.chainName = config.chainId === CHAINS.BSC.chainId ? 'bsc' : 'ethereum';
|
|
35
40
|
// ✅ 修复:移除弃用的 mempool.merkle.io RPC,使用公共 RPC 作为默认值
|
|
@@ -78,23 +83,18 @@ export class MerkleClient {
|
|
|
78
83
|
* 获取网络状态(用于 Bundle 参数优化)
|
|
79
84
|
*/
|
|
80
85
|
async getNetworkStatus() {
|
|
81
|
-
const [currentBlock, feeData] = await Promise.all([
|
|
82
|
-
this.getBlockNumber(),
|
|
83
|
-
this.getFeeData()
|
|
84
|
-
]);
|
|
86
|
+
const [currentBlock, feeData] = await Promise.all([this.getBlockNumber(), this.getFeeData()]);
|
|
85
87
|
// 动态获取 gas price,并计算建议的最小值
|
|
86
88
|
const baseGasPrice = feeData.gasPrice || feeData.maxFeePerGas || 3000000000n;
|
|
87
89
|
// 建议至少提高 80% 以确保交易被打包
|
|
88
90
|
const suggestedMinGasPrice = (baseGasPrice * 180n) / 100n;
|
|
89
91
|
// BSC 平均 3 秒,Ethereum 平均 12 秒
|
|
90
|
-
const avgBlockTime = this.chainId === CHAINS.BSC.chainId
|
|
91
|
-
? CHAINS.BSC.blockTime / 1000
|
|
92
|
-
: CHAINS.ETHEREUM.blockTime / 1000;
|
|
92
|
+
const avgBlockTime = this.chainId === CHAINS.BSC.chainId ? CHAINS.BSC.blockTime / 1000 : CHAINS.ETHEREUM.blockTime / 1000;
|
|
93
93
|
return {
|
|
94
94
|
currentBlock,
|
|
95
95
|
gasPrice: baseGasPrice,
|
|
96
96
|
suggestedMinGasPrice,
|
|
97
|
-
avgBlockTime
|
|
97
|
+
avgBlockTime,
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
@@ -139,9 +139,7 @@ export class MerkleClient {
|
|
|
139
139
|
throw new Error('Invalid bundle result format');
|
|
140
140
|
}
|
|
141
141
|
catch (error) {
|
|
142
|
-
|
|
143
|
-
const errorMsg = error.message || String(error);
|
|
144
|
-
throw new Error(`Send bundle failed: ${errorMsg}`);
|
|
142
|
+
throw new Error(`Send bundle failed: ${getErrorMessageFromUnknown(error)}`);
|
|
145
143
|
}
|
|
146
144
|
}
|
|
147
145
|
/**
|
|
@@ -172,7 +170,7 @@ export class MerkleClient {
|
|
|
172
170
|
if (targetBlock <= currentBlock) {
|
|
173
171
|
if (autoRetry && attempt < maxRetries) {
|
|
174
172
|
attempt++;
|
|
175
|
-
await new Promise(resolve => setTimeout(resolve, 300)); // 短暂延迟
|
|
173
|
+
await new Promise((resolve) => setTimeout(resolve, 300)); // 短暂延迟
|
|
176
174
|
continue;
|
|
177
175
|
}
|
|
178
176
|
throw new Error(`Target block ${targetBlock} has already passed (current block: ${currentBlock})`);
|
|
@@ -194,7 +192,7 @@ export class MerkleClient {
|
|
|
194
192
|
maxTimestamp: options.maxTimestamp,
|
|
195
193
|
});
|
|
196
194
|
// ✅ 优化:并行提取交易哈希(map 比 for 循环更高效)
|
|
197
|
-
const txHashes = options.transactions.map(rawTx => {
|
|
195
|
+
const txHashes = options.transactions.map((rawTx) => {
|
|
198
196
|
try {
|
|
199
197
|
return Transaction.from(rawTx).hash || '';
|
|
200
198
|
}
|
|
@@ -215,10 +213,8 @@ export class MerkleClient {
|
|
|
215
213
|
if (autoRetry && attempt < maxRetries) {
|
|
216
214
|
attempt++;
|
|
217
215
|
// 等待一个区块时间再重试
|
|
218
|
-
const blockTime = this.chainId === CHAINS.BSC.chainId
|
|
219
|
-
|
|
220
|
-
: CHAINS.ETHEREUM.blockTime;
|
|
221
|
-
await new Promise(resolve => setTimeout(resolve, blockTime));
|
|
216
|
+
const blockTime = this.chainId === CHAINS.BSC.chainId ? CHAINS.BSC.blockTime : CHAINS.ETHEREUM.blockTime;
|
|
217
|
+
await new Promise((resolve) => setTimeout(resolve, blockTime));
|
|
222
218
|
continue;
|
|
223
219
|
}
|
|
224
220
|
// 没有重试或已达最大重试次数
|
|
@@ -226,7 +222,10 @@ export class MerkleClient {
|
|
|
226
222
|
}
|
|
227
223
|
}
|
|
228
224
|
// 如果执行到这里,说明所有重试都失败了
|
|
229
|
-
|
|
225
|
+
if (lastError !== null && lastError !== undefined) {
|
|
226
|
+
throw lastError;
|
|
227
|
+
}
|
|
228
|
+
throw new Error('Bundle submission failed after all retries');
|
|
230
229
|
}
|
|
231
230
|
/**
|
|
232
231
|
* 等待 Bundle 中的交易确认
|
|
@@ -250,18 +249,8 @@ export class MerkleClient {
|
|
|
250
249
|
}
|
|
251
250
|
let gasCost;
|
|
252
251
|
if (receipt.gasUsed && receipt.gasPrice) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const costWei = receipt.gasUsed * receipt.gasPrice;
|
|
256
|
-
// 转换为 ETH/BNB(保持精度)
|
|
257
|
-
const costEth = Number(costWei) / 1e18;
|
|
258
|
-
gasCost = costEth.toFixed(8); // 增加精度到 8 位小数
|
|
259
|
-
}
|
|
260
|
-
catch (error) {
|
|
261
|
-
// 如果计算溢出,使用字符串处理
|
|
262
|
-
const costWei = receipt.gasUsed * receipt.gasPrice;
|
|
263
|
-
gasCost = (Number(costWei / 1000000000n) / 1e9).toFixed(8);
|
|
264
|
-
}
|
|
252
|
+
const costWei = receipt.gasUsed * receipt.gasPrice;
|
|
253
|
+
gasCost = formatEther(costWei);
|
|
265
254
|
}
|
|
266
255
|
return {
|
|
267
256
|
index,
|
|
@@ -278,7 +267,7 @@ export class MerkleClient {
|
|
|
278
267
|
index,
|
|
279
268
|
hash,
|
|
280
269
|
success: false,
|
|
281
|
-
error: error
|
|
270
|
+
error: getErrorMessageFromUnknown(error),
|
|
282
271
|
};
|
|
283
272
|
}
|
|
284
273
|
});
|
|
@@ -351,7 +340,6 @@ export class MerkleClient {
|
|
|
351
340
|
*/
|
|
352
341
|
async waitForBlock(targetBlock, maxAttempts = 10, intervalMs = 1000) {
|
|
353
342
|
let attempts = 0;
|
|
354
|
-
let lastError = null;
|
|
355
343
|
while (attempts < maxAttempts) {
|
|
356
344
|
try {
|
|
357
345
|
const currentBlock = await this.getBlockNumber();
|
|
@@ -366,35 +354,30 @@ export class MerkleClient {
|
|
|
366
354
|
return false;
|
|
367
355
|
}
|
|
368
356
|
}
|
|
369
|
-
catch
|
|
370
|
-
|
|
371
|
-
// 继续重试
|
|
357
|
+
catch {
|
|
358
|
+
// RPC 瞬时失败:继续下一轮轮询
|
|
372
359
|
}
|
|
373
360
|
// 等待下一次检查
|
|
374
|
-
await new Promise(resolve => setTimeout(resolve, intervalMs));
|
|
361
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
375
362
|
attempts++;
|
|
376
363
|
}
|
|
377
|
-
// 达到最大尝试次数
|
|
378
|
-
if (lastError) {
|
|
379
|
-
}
|
|
380
364
|
return false;
|
|
381
365
|
}
|
|
382
366
|
/**
|
|
383
367
|
* 获取当前 Provider 的统计信息(用于调试)
|
|
384
368
|
*/
|
|
385
369
|
getProviderInfo() {
|
|
370
|
+
const rpcConnection = this.provider._getConnection?.();
|
|
386
371
|
return {
|
|
387
372
|
chainId: this.chainId,
|
|
388
373
|
chainName: this.chainName,
|
|
389
|
-
|
|
390
|
-
rpcUrl: this.provider._getConnection?.().url || 'unknown',
|
|
374
|
+
rpcUrl: rpcConnection?.url ?? 'unknown',
|
|
391
375
|
};
|
|
392
376
|
}
|
|
393
377
|
}
|
|
394
|
-
MerkleClient.BLOCK_CACHE_TTL_MS = 1000; // 1秒缓存(BSC 约 3 秒出块,ETH 约 12 秒)
|
|
395
378
|
/**
|
|
396
379
|
* 创建 Merkle 客户端的便捷函数
|
|
397
380
|
*/
|
|
398
|
-
export function createMerkleClient(apiKey, chainId =
|
|
381
|
+
export function createMerkleClient(apiKey, chainId = CHAINS.BSC.chainId) {
|
|
399
382
|
return new MerkleClient({ apiKey, chainId });
|
|
400
383
|
}
|