four-flap-meme-sdk 1.9.49 → 2.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.
- package/README.en.md +41 -6
- package/README.md +31 -0
- package/README.zh-CN.md +41 -6
- package/dist/abis/common.js +74 -68
- package/dist/abis/flap/vault.js +9 -7
- package/dist/abis/index.d.ts +3 -4
- package/dist/abis/index.js +3 -4
- package/dist/bundle-core/__tests__/config-helpers.test.js +28 -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 +36 -0
- package/dist/bundle-core/config-helpers.js +57 -0
- package/dist/bundle-core/errors.d.ts +50 -0
- package/dist/bundle-core/errors.js +34 -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 +40 -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 +493 -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 +27 -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 +21 -0
- package/dist/bundle-core/internal.js +182 -0
- package/dist/bundle-core/sign-context-helpers.d.ts +25 -0
- package/dist/bundle-core/sign-context-helpers.js +67 -0
- package/dist/bundle-core/submit.d.ts +293 -0
- package/dist/bundle-core/submit.js +727 -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 -116
- package/dist/chains/bsc/four/config.d.ts +5 -70
- package/dist/chains/bsc/four/config.js +2 -115
- package/dist/chains/bsc/four/core.d.ts +1 -4
- package/dist/chains/bsc/four/core.js +1 -589
- package/dist/chains/bsc/four/disperse.d.ts +12 -0
- package/dist/chains/bsc/four/disperse.js +470 -0
- 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 -50
- package/dist/chains/bsc/four/internal.js +2 -237
- package/dist/chains/bsc/four/pairwise.d.ts +7 -0
- package/dist/chains/bsc/four/pairwise.js +308 -0
- package/dist/chains/bsc/four/pancake-proxy.d.ts +1 -28
- package/dist/chains/bsc/four/pancake-proxy.js +1 -688
- 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 -746
- package/dist/chains/bsc/four/swap-buy-first.d.ts +2 -55
- package/dist/chains/bsc/four/swap-buy-first.js +2 -506
- 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 -760
- package/dist/chains/bsc/four/sweep.d.ts +13 -0
- package/dist/chains/bsc/four/sweep.js +788 -0
- 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 -1534
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +159 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +117 -0
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -91
- package/dist/chains/bsc/pancake/bundle-buy-first.js +97 -207
- 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 +111 -686
- 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.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 +54 -23
- package/dist/chains/eni/batch-router/utils.js +32 -6
- package/dist/chains/eni/bundler/sign.js +4 -4
- package/dist/chains/eni/bundler/submit.js +1 -4
- package/dist/chains/eni/constants.js +1 -1
- package/dist/chains/eni/index.d.ts +1 -1
- 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 +8 -4
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +28 -43
- 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 -47
- 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.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.js +5 -13
- package/dist/chains/xlayer/eip7702/bundle-approve.d.ts +2 -26
- package/dist/chains/xlayer/eip7702/bundle-approve.js +11 -20
- 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 +93 -56
- package/dist/chains/xlayer/eip7702/bundle-sell.d.ts +2 -6
- package/dist/chains/xlayer/eip7702/bundle-sell.js +26 -74
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +3 -65
- package/dist/chains/xlayer/eip7702/bundle-swap.js +51 -68
- package/dist/chains/xlayer/eip7702/constants.d.ts +1 -16
- package/dist/chains/xlayer/eip7702/constants.js +3 -21
- package/dist/chains/xlayer/eip7702/index.d.ts +27 -46
- package/dist/chains/xlayer/eip7702/index.js +27 -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 +58 -291
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.d.ts +26 -0
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.js +57 -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 +83 -158
- package/dist/chains/xlayer/eoa/constants.js +1 -1
- package/dist/chains/xlayer/eoa/dex-helpers.js +5 -5
- 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 +64 -276
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +1 -1
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +14 -14
- 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 +3 -3
- package/dist/chains/xlayer/eoa/types-core.d.ts +363 -0
- package/dist/chains/xlayer/eoa/types-core.js +53 -0
- package/dist/chains/xlayer/eoa/types-create.d.ts +413 -0
- package/dist/chains/xlayer/eoa/types-create.js +9 -0
- package/dist/chains/xlayer/eoa/types-volume.d.ts +209 -0
- package/dist/chains/xlayer/eoa/types-volume.js +13 -0
- package/dist/chains/xlayer/eoa/types.d.ts +2 -2
- package/dist/chains/xlayer/eoa/types.js +1 -3
- package/dist/contracts/helper3.d.ts +20 -17
- package/dist/contracts/helper3.js +56 -20
- package/dist/contracts/tm-bundle-helpers.d.ts +88 -0
- package/dist/contracts/tm-bundle-helpers.js +72 -0
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.d.ts +1 -26
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +1 -117
- package/dist/contracts/tm-bundle-merkle/config.d.ts +5 -70
- package/dist/contracts/tm-bundle-merkle/config.js +2 -115
- package/dist/contracts/tm-bundle-merkle/core.d.ts +1 -4
- package/dist/contracts/tm-bundle-merkle/core.js +1 -588
- 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 -50
- package/dist/contracts/tm-bundle-merkle/internal.js +2 -236
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +1 -28
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +1 -687
- 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 -919
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +2 -55
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +2 -505
- 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 -757
- 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 +5 -6
- package/dist/contracts/tm-bundle-merkle/utils.js +5 -6
- package/dist/contracts/tm-bundle.d.ts +3 -51
- package/dist/contracts/tm-bundle.js +102 -142
- package/dist/contracts/tm.d.ts +3 -2
- package/dist/contracts/tm.js +36 -32
- package/dist/contracts/tm1.js +9 -4
- package/dist/contracts/tm2.js +9 -4
- package/dist/dex/direct-router-helpers.d.ts +264 -0
- package/dist/dex/direct-router-helpers.js +539 -0
- package/dist/dex/direct-router.d.ts +3 -125
- package/dist/dex/direct-router.js +237 -652
- 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/flows/create.d.ts +2 -2
- package/dist/flows/create.js +6 -6
- package/dist/flows/index.d.ts +1 -0
- package/dist/flows/index.js +1 -0
- package/dist/index.d.ts +20 -91
- package/dist/index.js +20 -215
- package/dist/shared/abis/common.d.ts +2 -83
- package/dist/shared/abis/common.js +2 -252
- package/dist/shared/abis/index.d.ts +5 -6
- package/dist/shared/abis/index.js +5 -7
- package/dist/shared/clients/blockrazor.js +41 -24
- package/dist/shared/clients/club48.js +30 -26
- package/dist/shared/clients/emitservice.js +2 -0
- package/dist/shared/clients/four.js +23 -18
- package/dist/shared/clients/index.d.ts +8 -0
- package/dist/shared/clients/index.js +8 -0
- package/dist/shared/clients/merkle.js +26 -30
- package/dist/shared/constants/addresses.d.ts +1 -1
- package/dist/shared/constants/addresses.js +11 -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 +1 -0
- package/dist/shared/constants/index.js +1 -0
- package/dist/shared/constants/quote.d.ts +30 -0
- package/dist/shared/constants/quote.js +37 -0
- package/dist/shared/flap/__tests__/curve.test.js +3 -3
- package/dist/shared/flap/abi.js +1 -1
- package/dist/shared/flap/constants.d.ts +1 -1
- package/dist/shared/flap/constants.js +2 -2
- package/dist/shared/flap/curve.js +3 -0
- package/dist/shared/flap/errors.d.ts +1 -4
- package/dist/shared/flap/errors.js +21 -3
- package/dist/shared/flap/index.d.ts +2 -2
- package/dist/shared/flap/index.js +2 -2
- package/dist/shared/flap/meta.d.ts +16 -18
- package/dist/shared/flap/meta.js +14 -26
- package/dist/shared/flap/permit.js +6 -5
- package/dist/shared/flap/pinata.d.ts +9 -2
- package/dist/shared/flap/pinata.js +20 -18
- 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 +66 -156
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +81 -86
- package/dist/shared/flap/portal-bundle-merkle/curve-to-dex.js +100 -92
- 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-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 +66 -247
- 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.d.ts +2 -71
- package/dist/shared/flap/portal-bundle-merkle/swap.js +103 -410
- package/dist/shared/flap/portal-bundle-merkle/types.d.ts +73 -3
- package/dist/shared/flap/portal-bundle-merkle/utils-helpers.d.ts +100 -0
- package/dist/shared/flap/portal-bundle-merkle/utils-helpers.js +133 -0
- 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 +54 -42
- package/dist/shared/flap/portal.js +32 -10
- package/dist/shared/flap/vanity.js +4 -7
- package/dist/shared/flap/vault.d.ts +1 -1
- package/dist/shared/flap/vault.js +54 -48
- package/dist/shared/flap 2/__tests__/curve.test.d.ts +1 -0
- package/dist/shared/flap 2/portal-bundle-merkle/types.js +1 -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/gas/bundle-gas.d.ts +39 -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 +13 -0
- package/dist/shared/foundation/index.js +12 -0
- package/dist/shared/foundation/nonce/nonce-manager.d.ts +17 -0
- package/dist/shared/foundation/nonce/nonce-manager.js +180 -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/four/tax-token.d.ts +1 -1
- package/dist/shared/four/tax-token.js +27 -7
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared/index.js +4 -0
- package/dist/types/distribute.d.ts +72 -0
- package/dist/types/distribute.js +1 -0
- package/dist/types 2/errors.d.ts +27 -0
- package/dist/types 2/errors.js +34 -0
- package/dist/utils/airdrop-sweep-types.d.ts +1 -0
- package/dist/utils/airdrop-sweep-types.js +1 -0
- package/dist/utils/airdrop-sweep.d.ts +4 -76
- package/dist/utils/airdrop-sweep.js +38 -52
- 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-types.d.ts +1 -0
- package/dist/utils/erc20-types.js +1 -0
- package/dist/utils/erc20.d.ts +8 -90
- package/dist/utils/erc20.js +94 -153
- package/dist/utils/errors.d.ts +10 -22
- package/dist/utils/errors.js +61 -79
- 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-types.d.ts +1 -0
- package/dist/utils/holders-maker-types.js +1 -0
- package/dist/utils/holders-maker.d.ts +2 -138
- package/dist/utils/holders-maker.js +23 -651
- 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-types.d.ts +1 -0
- package/dist/utils/lp-inspect-types.js +1 -0
- package/dist/utils/lp-inspect.d.ts +2 -112
- package/dist/utils/lp-inspect.js +63 -195
- package/dist/utils/mpcExclusive.d.ts +2 -5
- package/dist/utils/mpcExclusive.js +4 -3
- package/dist/utils/private-sale-types.d.ts +1 -0
- package/dist/utils/private-sale-types.js +1 -0
- package/dist/utils/private-sale.d.ts +2 -58
- package/dist/utils/private-sale.js +2 -7
- package/dist/utils/provider-factory.d.ts +4 -0
- package/dist/utils/provider-factory.js +10 -0
- package/dist/utils/quote-helpers-types.d.ts +1 -0
- package/dist/utils/quote-helpers-types.js +1 -0
- package/dist/utils/quote-helpers.d.ts +4 -45
- package/dist/utils/quote-helpers.js +15 -65
- package/dist/utils/stealth-transfer.d.ts +2 -28
- package/dist/utils/stealth-transfer.js +30 -14
- package/dist/utils/swap-helpers.d.ts +0 -3
- package/dist/utils/swap-helpers.js +6 -9
- 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 +2 -25
- package/dist/utils/wallet.js +9 -10
- package/package.json +55 -2
- package/src/abis/contracts/TaxToken.json +969 -0
- package/src/abis/contracts/TokenManager.json +836 -0
- package/src/abis/contracts/TokenManager2.json +136 -0
- package/src/abis/contracts/TokenManagerHelper3.json +993 -0
- /package/dist/{shared 2/flap/__tests__/curve.test.d.ts → bundle-core/__tests__/config-helpers.test.d.ts} +0 -0
- /package/dist/{shared 2/flap/portal-bundle-merkle/types.js → bundle-core/__tests__/facade-parity.test.d.ts} +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/TaxToken.json +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/TokenManager.json +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/TokenManager2.json +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/TokenManagerHelper3.json +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/common.d.ts +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/common.js +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/index.d.ts +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/index.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/blockrazor.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/blockrazor.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/club48.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/club48.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/emitservice.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/emitservice.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/four.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/four.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/merkle.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/merkle.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/__tests__/curve.test.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/abi.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/abi.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/constants.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/constants.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/curve.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/curve.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/errors.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/errors.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/index.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/index.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/ipfs.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/ipfs.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/meta.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/meta.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/permit.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/permit.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/pinata.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/pinata.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/config.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/config.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/core.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/core.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/create-to-dex.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/create-to-dex.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/curve-to-dex.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/curve-to-dex.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/index.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/index.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/pancake-proxy.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/pancake-proxy.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/private.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/private.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/swap-buy-first.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/swap-buy-first.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/swap.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/swap.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/types.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/utils.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/utils.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/vanity.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/vanity.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/vault.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/vault.js +0 -0
- /package/dist/{shared 2/four → shared/four 2}/index.d.ts +0 -0
- /package/dist/{shared 2/four → shared/four 2}/index.js +0 -0
- /package/dist/{shared 2/four → shared/four 2}/tax-token.d.ts +0 -0
- /package/dist/{shared 2/four → shared/four 2}/tax-token.js +0 -0
- /package/dist/{shared 2/index.d.ts → shared/index 2.js} +0 -0
- /package/dist/{shared 2/index.js → shared/index.d 2.ts} +0 -0
|
@@ -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';
|
|
@@ -147,13 +152,10 @@ export class FourClient {
|
|
|
147
152
|
const imgUrl = await this.doUpload(baseUrl, accessToken, file, finalFilename);
|
|
148
153
|
// 上传成功,写入持久化缓存(localStorage)
|
|
149
154
|
setCachedUrl(hash, imgUrl);
|
|
150
|
-
if (i > 0) {
|
|
151
|
-
console.warn(`[FourClient] 使用${isOfficial ? '官方直连' : '备用'}端点上传成功: ${baseUrl}`);
|
|
152
|
-
}
|
|
153
155
|
return imgUrl;
|
|
154
156
|
}
|
|
155
157
|
catch (e) {
|
|
156
|
-
lastError = e
|
|
158
|
+
lastError = e;
|
|
157
159
|
const canRetry = i < this.uploadUrls.length - 1;
|
|
158
160
|
if (this.isRateLimitError(e) && canRetry) {
|
|
159
161
|
// IP 限流 → 切下一个端点
|
|
@@ -176,9 +178,11 @@ export class FourClient {
|
|
|
176
178
|
if (isRateLimit) {
|
|
177
179
|
throw new Error(`图片上传失败:所有端点均触发 IP 限流(每IP每天100次)。` +
|
|
178
180
|
`请等待次日重置,或在 FourConfig.uploadFallbackUrls 中添加不同 IP 的备用代理。` +
|
|
179
|
-
`\n原始错误: ${lastError
|
|
181
|
+
`\n原始错误: ${getErrorMessageFromUnknown(lastError)}`);
|
|
180
182
|
}
|
|
181
|
-
|
|
183
|
+
if (lastError !== null && lastError !== undefined)
|
|
184
|
+
throw lastError;
|
|
185
|
+
throw new Error('upload failed: all endpoints exhausted');
|
|
182
186
|
}
|
|
183
187
|
/**
|
|
184
188
|
* 执行单次上传请求
|
|
@@ -193,8 +197,9 @@ export class FourClient {
|
|
|
193
197
|
});
|
|
194
198
|
const j = await r.json();
|
|
195
199
|
if (j.code !== '0' && j.code !== 0) {
|
|
196
|
-
const
|
|
197
|
-
|
|
200
|
+
const uploadErr = new Error(`upload failed: ${JSON.stringify(j)}`);
|
|
201
|
+
uploadErr.apiCode = typeof j.code === 'string' ? parseInt(j.code, 10) : Number(j.code);
|
|
202
|
+
throw uploadErr;
|
|
198
203
|
}
|
|
199
204
|
return j.data; // imgUrl
|
|
200
205
|
}
|
|
@@ -202,12 +207,13 @@ export class FourClient {
|
|
|
202
207
|
* 判断是否为 IP 限流错误(code: -1038)
|
|
203
208
|
*/
|
|
204
209
|
isRateLimitError(e) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
210
|
+
if (e !== null &&
|
|
211
|
+
typeof e === 'object' &&
|
|
212
|
+
'apiCode' in e &&
|
|
213
|
+
e.apiCode === RATE_LIMIT_CODE) {
|
|
209
214
|
return true;
|
|
210
|
-
|
|
215
|
+
}
|
|
216
|
+
return getErrorMessageFromUnknown(e).includes('-1038');
|
|
211
217
|
}
|
|
212
218
|
/**
|
|
213
219
|
* 判断是否为 CORS 或网络错误
|
|
@@ -215,9 +221,8 @@ export class FourClient {
|
|
|
215
221
|
*/
|
|
216
222
|
isCorsOrNetworkError(e) {
|
|
217
223
|
if (e instanceof TypeError)
|
|
218
|
-
return true;
|
|
219
|
-
const
|
|
220
|
-
const msg = m.message?.toLowerCase?.() ?? '';
|
|
224
|
+
return true; // fetch CORS / network failure
|
|
225
|
+
const msg = getErrorMessageFromUnknown(e).toLowerCase();
|
|
221
226
|
return msg.includes('failed to fetch') || msg.includes('network') || msg.includes('cors');
|
|
222
227
|
}
|
|
223
228
|
getFilenameFromBlob(blob) {
|
|
@@ -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';
|
|
@@ -22,14 +22,19 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import { JsonRpcProvider, Transaction } 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,11 +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 instanceof Error ? error.message : String(error);
|
|
144
|
-
const enhanced = new Error(`Send bundle failed: ${errorMsg}`);
|
|
145
|
-
Object.assign(enhanced, { cause: error });
|
|
146
|
-
throw enhanced;
|
|
142
|
+
throw new Error(`Send bundle failed: ${getErrorMessageFromUnknown(error)}`);
|
|
147
143
|
}
|
|
148
144
|
}
|
|
149
145
|
/**
|
|
@@ -174,7 +170,7 @@ export class MerkleClient {
|
|
|
174
170
|
if (targetBlock <= currentBlock) {
|
|
175
171
|
if (autoRetry && attempt < maxRetries) {
|
|
176
172
|
attempt++;
|
|
177
|
-
await new Promise(resolve => setTimeout(resolve, 300)); // 短暂延迟
|
|
173
|
+
await new Promise((resolve) => setTimeout(resolve, 300)); // 短暂延迟
|
|
178
174
|
continue;
|
|
179
175
|
}
|
|
180
176
|
throw new Error(`Target block ${targetBlock} has already passed (current block: ${currentBlock})`);
|
|
@@ -196,7 +192,7 @@ export class MerkleClient {
|
|
|
196
192
|
maxTimestamp: options.maxTimestamp,
|
|
197
193
|
});
|
|
198
194
|
// ✅ 优化:并行提取交易哈希(map 比 for 循环更高效)
|
|
199
|
-
const txHashes = options.transactions.map(rawTx => {
|
|
195
|
+
const txHashes = options.transactions.map((rawTx) => {
|
|
200
196
|
try {
|
|
201
197
|
return Transaction.from(rawTx).hash || '';
|
|
202
198
|
}
|
|
@@ -212,15 +208,13 @@ export class MerkleClient {
|
|
|
212
208
|
};
|
|
213
209
|
}
|
|
214
210
|
catch (error) {
|
|
215
|
-
lastError = error
|
|
211
|
+
lastError = error;
|
|
216
212
|
// 如果启用了重试且还有重试次数
|
|
217
213
|
if (autoRetry && attempt < maxRetries) {
|
|
218
214
|
attempt++;
|
|
219
215
|
// 等待一个区块时间再重试
|
|
220
|
-
const blockTime = this.chainId === CHAINS.BSC.chainId
|
|
221
|
-
|
|
222
|
-
: CHAINS.ETHEREUM.blockTime;
|
|
223
|
-
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));
|
|
224
218
|
continue;
|
|
225
219
|
}
|
|
226
220
|
// 没有重试或已达最大重试次数
|
|
@@ -228,7 +222,10 @@ export class MerkleClient {
|
|
|
228
222
|
}
|
|
229
223
|
}
|
|
230
224
|
// 如果执行到这里,说明所有重试都失败了
|
|
231
|
-
|
|
225
|
+
if (lastError !== null && lastError !== undefined) {
|
|
226
|
+
throw lastError;
|
|
227
|
+
}
|
|
228
|
+
throw new Error('Bundle submission failed after all retries');
|
|
232
229
|
}
|
|
233
230
|
/**
|
|
234
231
|
* 等待 Bundle 中的交易确认
|
|
@@ -280,7 +277,7 @@ export class MerkleClient {
|
|
|
280
277
|
index,
|
|
281
278
|
hash,
|
|
282
279
|
success: false,
|
|
283
|
-
error:
|
|
280
|
+
error: getErrorMessageFromUnknown(error),
|
|
284
281
|
};
|
|
285
282
|
}
|
|
286
283
|
});
|
|
@@ -368,27 +365,26 @@ export class MerkleClient {
|
|
|
368
365
|
}
|
|
369
366
|
}
|
|
370
367
|
catch {
|
|
371
|
-
//
|
|
368
|
+
// RPC 瞬时失败:继续下一轮轮询
|
|
372
369
|
}
|
|
373
370
|
// 等待下一次检查
|
|
374
|
-
await new Promise(resolve => setTimeout(resolve, intervalMs));
|
|
371
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
375
372
|
attempts++;
|
|
376
373
|
}
|
|
377
|
-
// 达到最大尝试次数
|
|
378
374
|
return false;
|
|
379
375
|
}
|
|
380
376
|
/**
|
|
381
377
|
* 获取当前 Provider 的统计信息(用于调试)
|
|
382
378
|
*/
|
|
383
379
|
getProviderInfo() {
|
|
380
|
+
const rpcConnection = this.provider._getConnection?.();
|
|
384
381
|
return {
|
|
385
382
|
chainId: this.chainId,
|
|
386
383
|
chainName: this.chainName,
|
|
387
|
-
rpcUrl:
|
|
384
|
+
rpcUrl: rpcConnection?.url ?? 'unknown',
|
|
388
385
|
};
|
|
389
386
|
}
|
|
390
387
|
}
|
|
391
|
-
MerkleClient.BLOCK_CACHE_TTL_MS = 1000; // 1秒缓存(BSC 约 3 秒出块,ETH 约 12 秒)
|
|
392
388
|
/**
|
|
393
389
|
* 创建 Merkle 客户端的便捷函数
|
|
394
390
|
*/
|
|
@@ -127,7 +127,7 @@ export declare const ENI_SPENDERS: {
|
|
|
127
127
|
*/
|
|
128
128
|
export declare function getEniSpenders(mode?: boolean | 'all'): string[];
|
|
129
129
|
export type ChainAddresses = keyof typeof ADDRESSES;
|
|
130
|
-
export type AddressKey<C extends ChainAddresses> = keyof typeof ADDRESSES[C];
|
|
130
|
+
export type AddressKey<C extends ChainAddresses> = keyof (typeof ADDRESSES)[C];
|
|
131
131
|
/**
|
|
132
132
|
* 获取指定链的合约地址
|
|
133
133
|
*/
|
|
@@ -192,12 +192,21 @@ export const ENI_SPENDERS = {
|
|
|
192
192
|
*/
|
|
193
193
|
export function getEniSpenders(mode = false) {
|
|
194
194
|
if (mode === 'all' && ENI_SPENDERS.BATCH_ROUTER) {
|
|
195
|
-
return [
|
|
195
|
+
return [
|
|
196
|
+
ENI_SPENDERS.DIRECT.DAOAAS_PORTAL,
|
|
197
|
+
ENI_SPENDERS.DIRECT.DSWAP_V2_ROUTER,
|
|
198
|
+
ENI_SPENDERS.DIRECT.IROSWAP_V2_ROUTER,
|
|
199
|
+
ENI_SPENDERS.BATCH_ROUTER,
|
|
200
|
+
];
|
|
196
201
|
}
|
|
197
202
|
if (mode === true && ENI_SPENDERS.BATCH_ROUTER) {
|
|
198
203
|
return [ENI_SPENDERS.BATCH_ROUTER];
|
|
199
204
|
}
|
|
200
|
-
return [
|
|
205
|
+
return [
|
|
206
|
+
ENI_SPENDERS.DIRECT.DAOAAS_PORTAL,
|
|
207
|
+
ENI_SPENDERS.DIRECT.DSWAP_V2_ROUTER,
|
|
208
|
+
ENI_SPENDERS.DIRECT.IROSWAP_V2_ROUTER,
|
|
209
|
+
];
|
|
201
210
|
}
|
|
202
211
|
// ============================================================================
|
|
203
212
|
// 工具函数
|
|
@@ -107,7 +107,7 @@ export declare const CHAINS: {
|
|
|
107
107
|
};
|
|
108
108
|
export declare const CHAIN_ID_MAP: Record<string, number>;
|
|
109
109
|
export type ChainKey = keyof typeof CHAINS;
|
|
110
|
-
export type ChainConfig = typeof CHAINS[ChainKey];
|
|
110
|
+
export type ChainConfig = (typeof CHAINS)[ChainKey];
|
|
111
111
|
/**
|
|
112
112
|
* 根据 chainId 获取链配置
|
|
113
113
|
*/
|
|
@@ -132,7 +132,7 @@ export const CHAIN_ID_MAP = {
|
|
|
132
132
|
* 根据 chainId 获取链配置
|
|
133
133
|
*/
|
|
134
134
|
export function getChainById(chainId) {
|
|
135
|
-
return Object.values(CHAINS).find(c => c.chainId === chainId);
|
|
135
|
+
return Object.values(CHAINS).find((c) => c.chainId === chainId);
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
138
|
* 根据 chainId 获取链名称
|
|
@@ -63,7 +63,7 @@ export declare const V3_FEE_TIERS: {
|
|
|
63
63
|
readonly HIGH: 10000;
|
|
64
64
|
};
|
|
65
65
|
export type GasLimitKey = keyof typeof GAS_LIMITS;
|
|
66
|
-
export type V3FeeTier = typeof V3_FEE_TIERS[keyof typeof V3_FEE_TIERS];
|
|
66
|
+
export type V3FeeTier = (typeof V3_FEE_TIERS)[keyof typeof V3_FEE_TIERS];
|
|
67
67
|
/**
|
|
68
68
|
* 根据链和交易类型计算 gas limit
|
|
69
69
|
*/
|
|
@@ -90,9 +90,7 @@ export function calculateGasLimit(chainId, isNative, hasHops = false, hopCount =
|
|
|
90
90
|
}
|
|
91
91
|
// 有多跳时,基础 gas + 每跳额外 gas
|
|
92
92
|
if (hasHops && hopCount > 0) {
|
|
93
|
-
const hopGas = isNative
|
|
94
|
-
? GAS_LIMITS.NATIVE_TRANSFER
|
|
95
|
-
: GAS_LIMITS.ERC20_TRANSFER;
|
|
93
|
+
const hopGas = isNative ? GAS_LIMITS.NATIVE_TRANSFER : GAS_LIMITS.ERC20_TRANSFER;
|
|
96
94
|
return GAS_LIMITS.TRADE + hopGas * BigInt(hopCount);
|
|
97
95
|
}
|
|
98
96
|
// 普通转账
|
|
@@ -108,9 +106,7 @@ export function calculateGasLimit(chainId, isNative, hasHops = false, hopCount =
|
|
|
108
106
|
*/
|
|
109
107
|
export function getTransferGasLimit(chainId, isNative) {
|
|
110
108
|
if (isNative) {
|
|
111
|
-
return chainId === CHAINS.XLAYER.chainId
|
|
112
|
-
? GAS_LIMITS.XLAYER_NATIVE_TRANSFER
|
|
113
|
-
: GAS_LIMITS.NATIVE_TRANSFER;
|
|
109
|
+
return chainId === CHAINS.XLAYER.chainId ? GAS_LIMITS.XLAYER_NATIVE_TRANSFER : GAS_LIMITS.NATIVE_TRANSFER;
|
|
114
110
|
}
|
|
115
111
|
return GAS_LIMITS.ERC20_TRANSFER;
|
|
116
112
|
}
|
|
@@ -10,5 +10,6 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isKnownChain, isBscChain, isXLayerChain, isMonadChain, isEniChain, getConfirmationTimeout, type ChainKey, type ChainConfig, } from './chains.js';
|
|
12
12
|
export { GAS_LIMITS, GAS_CONFIG, V3_FEE_TIERS, calculateGasLimit, getTransferGasLimit, type GasLimitKey, type V3FeeTier, } from './gas.js';
|
|
13
|
+
export { QUOTE_CONFIG, QUOTE_V3_FEE_TIERS, type QuoteConfigChain } from './quote.js';
|
|
13
14
|
export { ZERO_ADDRESS, BLOCKRAZOR_BUILDER_EOA, ADDRESSES, getAddress, getWrappedNativeAddress, getMulticall3Address, getFlapPortalAddress, isZeroAddress, isNativeToken, ENI_SPENDERS, getEniSpenders, type ChainAddresses, type AddressKey, } from './addresses.js';
|
|
14
15
|
export { PROFIT_CONFIG, getProfitRecipient, getAllProfitRecipients, getProfitRateBps, calculateProfitAmount, calculateProfitHopGasCost, type ProfitRateKey, TRANSFER_FEE_PER_ADDRESS, getTransferFeePerAddress, calculateTransferFee, } from './profit.js';
|
|
@@ -16,6 +16,7 @@ export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isK
|
|
|
16
16
|
// Gas 常量
|
|
17
17
|
// ============================================================================
|
|
18
18
|
export { GAS_LIMITS, GAS_CONFIG, V3_FEE_TIERS, calculateGasLimit, getTransferGasLimit, } from './gas.js';
|
|
19
|
+
export { QUOTE_CONFIG, QUOTE_V3_FEE_TIERS } from './quote.js';
|
|
19
20
|
// ============================================================================
|
|
20
21
|
// 合约地址
|
|
21
22
|
// ============================================================================
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** DEX 报价链配置(V2 Router / V3 Quoter / 包装原生币 / 稳定币) */
|
|
2
|
+
export declare const QUOTE_CONFIG: {
|
|
3
|
+
readonly BSC: {
|
|
4
|
+
readonly v2Router: "0x10ED43C718714eb63d5aA57B78B54704E256024E";
|
|
5
|
+
readonly v3Quoter: "0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997";
|
|
6
|
+
readonly wrappedNative: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
|
|
7
|
+
readonly stableCoins: readonly ["0x55d398326f99059fF775485246999027B3197955", "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d", "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56"];
|
|
8
|
+
};
|
|
9
|
+
readonly MONAD: {
|
|
10
|
+
readonly v2Router: "0xb1bc24c34e88f7d43d5923034e3a14b24daacff9";
|
|
11
|
+
readonly v3Quoter: "";
|
|
12
|
+
readonly wrappedNative: "0x3bd359c1119da7da1d913d1c4d2b7c461115433a";
|
|
13
|
+
readonly stableCoins: readonly [];
|
|
14
|
+
};
|
|
15
|
+
readonly XLAYER: {
|
|
16
|
+
readonly v2Router: "0x881fb2f98c13d521009464e7d1cbf16e1b394e8e";
|
|
17
|
+
readonly v3Quoter: "0x5A6f3723346aF54a4D0693bfC1718D64d4915C3e";
|
|
18
|
+
readonly wrappedNative: "0xe538905cf8410324e03a5a23c1c177a474d59b2b";
|
|
19
|
+
readonly stableCoins: readonly ["0x1E4a5963aBFD975d8c9021ce480b42188849D41d", "0x74b7f16337b8972027f6196a17a631ac6de26d22", "0x779ded0c9e1022225f8e0630b35a9b54be713736"];
|
|
20
|
+
};
|
|
21
|
+
readonly ENI: {
|
|
22
|
+
readonly v2Router: "0x97ed8be49d9a8b86247090aa41e908e76b8fcf22";
|
|
23
|
+
readonly v3Quoter: "";
|
|
24
|
+
readonly wrappedNative: "0x6d1e851446f4d004ae2a72f9afed85e8829a205e";
|
|
25
|
+
readonly stableCoins: readonly ["0xDC1a8A35b0BaA3229b13f348ED708a2fd50b5e3a", "0xaFF944b96c1BAEA587159ec446280E468B32ee15"];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/** V3 报价尝试费率列表(与 `gas.V3_FEE_TIERS` 命名对象区分) */
|
|
29
|
+
export declare const QUOTE_V3_FEE_TIERS: readonly [100, 500, 2500, 10000];
|
|
30
|
+
export type QuoteConfigChain = keyof typeof QUOTE_CONFIG;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** DEX 报价链配置(V2 Router / V3 Quoter / 包装原生币 / 稳定币) */
|
|
2
|
+
export const QUOTE_CONFIG = {
|
|
3
|
+
BSC: {
|
|
4
|
+
v2Router: '0x10ED43C718714eb63d5aA57B78B54704E256024E',
|
|
5
|
+
v3Quoter: '0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997',
|
|
6
|
+
wrappedNative: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
|
|
7
|
+
stableCoins: [
|
|
8
|
+
'0x55d398326f99059fF775485246999027B3197955',
|
|
9
|
+
'0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d',
|
|
10
|
+
'0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56',
|
|
11
|
+
],
|
|
12
|
+
},
|
|
13
|
+
MONAD: {
|
|
14
|
+
v2Router: '0xb1bc24c34e88f7d43d5923034e3a14b24daacff9',
|
|
15
|
+
v3Quoter: '',
|
|
16
|
+
wrappedNative: '0x3bd359c1119da7da1d913d1c4d2b7c461115433a',
|
|
17
|
+
stableCoins: [],
|
|
18
|
+
},
|
|
19
|
+
XLAYER: {
|
|
20
|
+
v2Router: '0x881fb2f98c13d521009464e7d1cbf16e1b394e8e',
|
|
21
|
+
v3Quoter: '0x5A6f3723346aF54a4D0693bfC1718D64d4915C3e',
|
|
22
|
+
wrappedNative: '0xe538905cf8410324e03a5a23c1c177a474d59b2b',
|
|
23
|
+
stableCoins: [
|
|
24
|
+
'0x1E4a5963aBFD975d8c9021ce480b42188849D41d',
|
|
25
|
+
'0x74b7f16337b8972027f6196a17a631ac6de26d22',
|
|
26
|
+
'0x779ded0c9e1022225f8e0630b35a9b54be713736',
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
ENI: {
|
|
30
|
+
v2Router: '0x97ed8be49d9a8b86247090aa41e908e76b8fcf22',
|
|
31
|
+
v3Quoter: '',
|
|
32
|
+
wrappedNative: '0x6d1e851446f4d004ae2a72f9afed85e8829a205e',
|
|
33
|
+
stableCoins: ['0xDC1a8A35b0BaA3229b13f348ED708a2fd50b5e3a', '0xaFF944b96c1BAEA587159ec446280E468B32ee15'],
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
/** V3 报价尝试费率列表(与 `gas.V3_FEE_TIERS` 命名对象区分) */
|
|
37
|
+
export const QUOTE_V3_FEE_TIERS = [100, 500, 2500, 10000];
|
|
@@ -28,7 +28,7 @@ describe('CDPV2', () => {
|
|
|
28
28
|
const curve = CDPV2.getCurve(0.1);
|
|
29
29
|
const supply = curve.estimateSupply('1000000');
|
|
30
30
|
expect(supply.toUnsafeFloat()).toBeGreaterThan(0);
|
|
31
|
-
expect(supply.toUnsafeFloat()).toBeLessThan(
|
|
31
|
+
expect(supply.toUnsafeFloat()).toBeLessThan(1_000_000_000);
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
34
|
describe('estimateReserve', () => {
|
|
@@ -51,7 +51,7 @@ describe('CDPV2', () => {
|
|
|
51
51
|
const supply = curve.estimateSupply(initialReserve);
|
|
52
52
|
const reserveBack = curve.estimateReserve(supply.toString());
|
|
53
53
|
// Allow small rounding differences
|
|
54
|
-
const diff = Math.abs(reserveBack.toUnsafeFloat() -
|
|
54
|
+
const diff = Math.abs(reserveBack.toUnsafeFloat() - 1_000_000);
|
|
55
55
|
expect(diff).toBeLessThan(1);
|
|
56
56
|
});
|
|
57
57
|
});
|
|
@@ -74,7 +74,7 @@ describe('CDPV2', () => {
|
|
|
74
74
|
const supply = '500000000';
|
|
75
75
|
const p = curve.price(supply);
|
|
76
76
|
const f = curve.fdv(supply);
|
|
77
|
-
expect(f.toUnsafeFloat()).toBeCloseTo(p.toUnsafeFloat() *
|
|
77
|
+
expect(f.toUnsafeFloat()).toBeCloseTo(p.toUnsafeFloat() * 1_000_000_000, -3);
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
describe('defaultDexSupplyThreshold', () => {
|
package/dist/shared/flap/abi.js
CHANGED
|
@@ -9,5 +9,5 @@ export const PORTAL_EVENTS_ABI = [
|
|
|
9
9
|
'event FlapTokenTaxSet(address token, uint256 tax)',
|
|
10
10
|
'event FlapTokenCirculatingSupplyChanged(address token, uint256 newSupply)',
|
|
11
11
|
'event LaunchedToDEX(address token, address pool, uint256 amount, uint256 eth)',
|
|
12
|
-
'event TokenExtensionEnabled(address token, bytes32 extensionID, address extensionAddress, uint8 version)'
|
|
12
|
+
'event TokenExtensionEnabled(address token, bytes32 extensionID, address extensionAddress, uint8 version)',
|
|
13
13
|
];
|
|
@@ -135,9 +135,9 @@ export const FLAP_DEX_THRESHOLDS = {
|
|
|
135
135
|
/**
|
|
136
136
|
* 代币总供应量(固定为 10 亿)
|
|
137
137
|
*/
|
|
138
|
-
export const FLAP_TOTAL_SUPPLY = BigInt(
|
|
138
|
+
export const FLAP_TOTAL_SUPPLY = BigInt(1_000_000_000) * BigInt(10 ** 18);
|
|
139
139
|
/**
|
|
140
140
|
* 零地址(用于表示原生代币)
|
|
141
141
|
* ✅ 从公共模块重新导出
|
|
142
142
|
*/
|
|
143
|
-
export { ZERO_ADDRESS } from '
|
|
143
|
+
export { ZERO_ADDRESS } from '../constants/index.js';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flap Protocol 错误代码
|
|
3
|
-
*/
|
|
4
1
|
export type FlapErrorCode = 'TOKEN_ALREADY_EXISTS' | 'TOKEN_NOT_FOUND' | 'TOKEN_NOT_TRADABLE' | 'ALREADY_ON_DEX' | 'INSUFFICIENT_BALANCE' | 'SLIPPAGE_EXCEEDED' | 'INVALID_TOKEN' | 'INVALID_QUOTE_TOKEN' | 'INVALID_AMOUNT' | 'TAX_RATE_TOO_HIGH' | 'PERMIT_EXPIRED' | 'PERMIT_INVALID' | 'UNKNOWN_ERROR';
|
|
5
2
|
/**
|
|
6
3
|
* 解析 Flap Protocol 错误信息
|
|
@@ -12,7 +9,7 @@ export type FlapErrorCode = 'TOKEN_ALREADY_EXISTS' | 'TOKEN_NOT_FOUND' | 'TOKEN_
|
|
|
12
9
|
* ```typescript
|
|
13
10
|
* try {
|
|
14
11
|
* await portal.swapExactInput(...);
|
|
15
|
-
* } catch (err
|
|
12
|
+
* } catch (err) {
|
|
16
13
|
* const errorCode = parseFlapError(err);
|
|
17
14
|
* if (errorCode === 'SLIPPAGE_EXCEEDED') {
|
|
18
15
|
* console.log('滑点过大,请调整参数');
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap Protocol 错误代码
|
|
3
|
+
*/
|
|
4
|
+
import { getErrorMessageFromUnknown } from '../foundation/normalize-unknown.js';
|
|
1
5
|
/**
|
|
2
6
|
* 解析 Flap Protocol 错误信息
|
|
3
7
|
*
|
|
@@ -8,7 +12,7 @@
|
|
|
8
12
|
* ```typescript
|
|
9
13
|
* try {
|
|
10
14
|
* await portal.swapExactInput(...);
|
|
11
|
-
* } catch (err
|
|
15
|
+
* } catch (err) {
|
|
12
16
|
* const errorCode = parseFlapError(err);
|
|
13
17
|
* if (errorCode === 'SLIPPAGE_EXCEEDED') {
|
|
14
18
|
* console.log('滑点过大,请调整参数');
|
|
@@ -17,8 +21,7 @@
|
|
|
17
21
|
* ```
|
|
18
22
|
*/
|
|
19
23
|
export function parseFlapError(error) {
|
|
20
|
-
const
|
|
21
|
-
const msg = withMessage.message || withMessage.data?.message || String(error);
|
|
24
|
+
const msg = getFlapErrorText(error);
|
|
22
25
|
const msgLower = msg.toLowerCase();
|
|
23
26
|
// Token 状态相关错误
|
|
24
27
|
if (msgLower.includes('token already exists') || msgLower.includes('already created')) {
|
|
@@ -61,6 +64,21 @@ export function parseFlapError(error) {
|
|
|
61
64
|
// 无法识别的错误
|
|
62
65
|
return null;
|
|
63
66
|
}
|
|
67
|
+
function getFlapErrorText(error) {
|
|
68
|
+
if (error !== null && typeof error === 'object') {
|
|
69
|
+
const record = error;
|
|
70
|
+
const topLevel = record.message;
|
|
71
|
+
if (typeof topLevel === 'string' && topLevel)
|
|
72
|
+
return topLevel;
|
|
73
|
+
const data = record.data;
|
|
74
|
+
if (data !== null && typeof data === 'object') {
|
|
75
|
+
const nestedMessage = data.message;
|
|
76
|
+
if (typeof nestedMessage === 'string' && nestedMessage)
|
|
77
|
+
return nestedMessage;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return getErrorMessageFromUnknown(error);
|
|
81
|
+
}
|
|
64
82
|
/**
|
|
65
83
|
* 获取错误的友好提示信息(中文)
|
|
66
84
|
*
|
|
@@ -11,11 +11,11 @@ type PortalConfig, type TokenStateV2, type TokenStateV3, type TokenStateV4, type
|
|
|
11
11
|
export { CDPV2 } from './curve.js';
|
|
12
12
|
export { buildPermitPiggybackAuto } from './permit.js';
|
|
13
13
|
export { uploadTokenMeta, type TokenMetaInput } from './ipfs.js';
|
|
14
|
-
export { PinataClient, type PinataConfig, pinFileToIPFSWithJWT, pinImageByPath, pinFileToIPFSWithJWTWeb, pinDataURLWithJWTWeb, dataURLToBlob, type PinataPinResp } from './pinata.js';
|
|
14
|
+
export { PinataClient, type PinataConfig, pinFileToIPFSWithJWT, pinImageByPath, pinFileToIPFSWithJWTWeb, pinDataURLWithJWTWeb, dataURLToBlob, type PinataPinResp, } from './pinata.js';
|
|
15
15
|
export { predictVanityTokenAddressByChain, findSaltEndingByChain } from './vanity.js';
|
|
16
16
|
export { getFlapMetaByAddress, getFlapMetasByAddresses } from './meta.js';
|
|
17
17
|
export { parseFlapError, getFlapErrorMessage, getFlapErrorMessageEn, type FlapErrorCode } from './errors.js';
|
|
18
|
-
export { FLAP_DEFAULT_FEE_RATES, FLAP_IPFS_API_URL, FLAP_VANITY_SUFFIX, FLAP_DEX_THRESHOLDS, FLAP_TOTAL_SUPPLY, ZERO_ADDRESS, CHAIN_TAX_SUPPORT, getVanitySuffix, isChainSupportTax, FLAP_PORTAL_ADDRESSES } from './constants.js';
|
|
18
|
+
export { FLAP_DEFAULT_FEE_RATES, FLAP_IPFS_API_URL, FLAP_VANITY_SUFFIX, FLAP_DEX_THRESHOLDS, FLAP_TOTAL_SUPPLY, ZERO_ADDRESS, CHAIN_TAX_SUPPORT, getVanitySuffix, isChainSupportTax, FLAP_PORTAL_ADDRESSES, } from './constants.js';
|
|
19
19
|
export * from './abi.js';
|
|
20
20
|
export { createTokenWithBundleBuy, batchBuyWithBundle, batchSellWithBundle, type FlapBundleConfig, type FlapChainForBundle, type FlapCreateWithBundleBuyParams, type FlapCreateWithBundleBuyResult, type FlapBatchBuyParams, type FlapBatchBuyResult, type FlapBatchSellParams, type FlapBatchSellResult, flapPrivateBuy, flapPrivateSell, flapBatchPrivateBuy, flapBatchPrivateSell, type FlapPrivateBuyParams, type FlapPrivateSellParams, type FlapBatchPrivateBuyParams, type FlapBatchPrivateSellParams, type FlapBatchPrivateSellResult, } from './portal-bundle.js';
|
|
21
21
|
export * from './portal-bundle-merkle/index.js';
|
|
@@ -11,11 +11,11 @@ export { FlapPortal, FlapPortalWriter, validateTaxDistribution, TokenStatus, Tok
|
|
|
11
11
|
export { CDPV2 } from './curve.js';
|
|
12
12
|
export { buildPermitPiggybackAuto } from './permit.js';
|
|
13
13
|
export { uploadTokenMeta } from './ipfs.js';
|
|
14
|
-
export { PinataClient, pinFileToIPFSWithJWT, pinImageByPath, pinFileToIPFSWithJWTWeb, pinDataURLWithJWTWeb, dataURLToBlob } from './pinata.js';
|
|
14
|
+
export { PinataClient, pinFileToIPFSWithJWT, pinImageByPath, pinFileToIPFSWithJWTWeb, pinDataURLWithJWTWeb, dataURLToBlob, } from './pinata.js';
|
|
15
15
|
export { predictVanityTokenAddressByChain, findSaltEndingByChain } from './vanity.js';
|
|
16
16
|
export { getFlapMetaByAddress, getFlapMetasByAddresses } from './meta.js';
|
|
17
17
|
export { parseFlapError, getFlapErrorMessage, getFlapErrorMessageEn } from './errors.js';
|
|
18
|
-
export { FLAP_DEFAULT_FEE_RATES, FLAP_IPFS_API_URL, FLAP_VANITY_SUFFIX, FLAP_DEX_THRESHOLDS, FLAP_TOTAL_SUPPLY, ZERO_ADDRESS, CHAIN_TAX_SUPPORT, getVanitySuffix, isChainSupportTax, FLAP_PORTAL_ADDRESSES } from './constants.js';
|
|
18
|
+
export { FLAP_DEFAULT_FEE_RATES, FLAP_IPFS_API_URL, FLAP_VANITY_SUFFIX, FLAP_DEX_THRESHOLDS, FLAP_TOTAL_SUPPLY, ZERO_ADDRESS, CHAIN_TAX_SUPPORT, getVanitySuffix, isChainSupportTax, FLAP_PORTAL_ADDRESSES, } from './constants.js';
|
|
19
19
|
export * from './abi.js';
|
|
20
20
|
// Bundle 功能
|
|
21
21
|
export { createTokenWithBundleBuy, batchBuyWithBundle, batchSellWithBundle, flapPrivateBuy, flapPrivateSell, flapBatchPrivateBuy, flapBatchPrivateSell, } from './portal-bundle.js';
|