four-flap-meme-sdk 3.0.1 → 4.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/dist/bundle/four-meme/approve-tokenmanager.d.ts +2 -2
- package/dist/bundle/four-meme/approve-tokenmanager.js +3 -3
- package/dist/bundle/four-meme/core/buy-flow.d.ts +5 -0
- package/dist/bundle/four-meme/core/buy-flow.js +147 -0
- package/dist/bundle/four-meme/core/constants.d.ts +6 -0
- package/dist/bundle/four-meme/core/constants.js +15 -0
- package/dist/bundle/four-meme/core/create-token.d.ts +5 -0
- package/dist/bundle/four-meme/core/create-token.js +137 -0
- package/dist/bundle/four-meme/core/index.d.ts +14 -0
- package/dist/bundle/four-meme/core/index.js +14 -0
- package/dist/bundle/four-meme/core/sell-flow.d.ts +5 -0
- package/dist/bundle/four-meme/core/sell-flow.js +240 -0
- package/dist/bundle/four-meme/core-helpers.js +1 -1
- package/dist/bundle/four-meme/core.d.ts +7 -4
- package/dist/bundle/four-meme/core.js +5 -513
- package/dist/bundle/four-meme/pancake-proxy/approve.d.ts +15 -0
- package/dist/bundle/four-meme/pancake-proxy/approve.js +113 -0
- package/dist/bundle/four-meme/pancake-proxy/buy.d.ts +8 -0
- package/dist/bundle/four-meme/pancake-proxy/buy.js +143 -0
- package/dist/bundle/four-meme/pancake-proxy/constants.d.ts +25 -0
- package/dist/bundle/four-meme/pancake-proxy/constants.js +14 -0
- package/dist/bundle/four-meme/pancake-proxy/helpers.d.ts +45 -0
- package/dist/bundle/four-meme/pancake-proxy/helpers.js +232 -0
- package/dist/bundle/four-meme/pancake-proxy/index.d.ts +15 -0
- package/dist/bundle/four-meme/pancake-proxy/index.js +15 -0
- package/dist/bundle/four-meme/pancake-proxy/sell.d.ts +8 -0
- package/dist/bundle/four-meme/pancake-proxy/sell.js +194 -0
- package/dist/bundle/four-meme/pancake-proxy.d.ts +4 -20
- package/dist/bundle/four-meme/pancake-proxy.js +3 -670
- package/dist/bundle/four-meme/private/buy.d.ts +16 -0
- package/dist/bundle/four-meme/private/buy.js +225 -0
- package/dist/bundle/four-meme/private/index.d.ts +11 -0
- package/dist/bundle/four-meme/private/index.js +11 -0
- package/dist/bundle/four-meme/private/sell.d.ts +18 -0
- package/dist/bundle/four-meme/private/sell.js +245 -0
- package/dist/bundle/four-meme/private.d.ts +5 -25
- package/dist/bundle/four-meme/private.js +5 -463
- package/dist/bundle/four-meme/swap/batch.d.ts +8 -0
- package/dist/bundle/four-meme/swap/batch.js +170 -0
- package/dist/bundle/four-meme/swap/bundle.d.ts +8 -0
- package/dist/bundle/four-meme/swap/bundle.js +147 -0
- package/dist/bundle/four-meme/swap/index.d.ts +14 -0
- package/dist/bundle/four-meme/swap/index.js +13 -0
- package/dist/bundle/four-meme/swap/quick-batch.d.ts +8 -0
- package/dist/bundle/four-meme/swap/quick-batch.js +206 -0
- package/dist/bundle/four-meme/swap-buy-first/helpers.d.ts +20 -0
- package/dist/bundle/four-meme/swap-buy-first/helpers.js +39 -0
- package/dist/bundle/four-meme/swap-buy-first/index.d.ts +12 -0
- package/dist/bundle/four-meme/swap-buy-first/index.js +11 -0
- package/dist/bundle/four-meme/swap-buy-first/multi-wallet.d.ts +20 -0
- package/dist/bundle/four-meme/swap-buy-first/multi-wallet.js +198 -0
- package/dist/bundle/four-meme/swap-buy-first/single.d.ts +7 -0
- package/dist/bundle/four-meme/swap-buy-first/single.js +232 -0
- package/dist/bundle/four-meme/swap-buy-first.d.ts +4 -3
- package/dist/bundle/four-meme/swap-buy-first.js +4 -451
- package/dist/bundle/four-meme/swap-hop-helpers.d.ts +2 -2
- package/dist/bundle/four-meme/swap-sign-helpers.d.ts +2 -2
- package/dist/bundle/four-meme/swap-sign-helpers.js +1 -1
- package/dist/bundle/four-meme/swap.d.ts +4 -14
- package/dist/bundle/four-meme/swap.js +4 -502
- package/dist/bundle/four-meme/types/index.d.ts +1 -1
- package/dist/bundle/four-meme/utils-disperse.d.ts +1 -1
- package/dist/bundle/four-meme/utils-disperse.js +1 -1
- package/dist/bundle/four-meme/utils-pairwise.d.ts +1 -1
- package/dist/bundle/four-meme/utils-pairwise.js +1 -1
- package/dist/bundle/four-meme/utils-sweep/context.d.ts +39 -0
- package/dist/bundle/four-meme/utils-sweep/context.js +7 -0
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.d.ts +5 -0
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.js +162 -0
- package/dist/bundle/four-meme/utils-sweep/index.d.ts +13 -0
- package/dist/bundle/four-meme/utils-sweep/index.js +13 -0
- package/dist/bundle/four-meme/utils-sweep/main.d.ts +8 -0
- package/dist/bundle/four-meme/utils-sweep/main.js +114 -0
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.d.ts +5 -0
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.js +156 -0
- package/dist/bundle/four-meme/utils-sweep/with-hops.d.ts +6 -0
- package/dist/bundle/four-meme/utils-sweep/with-hops.js +382 -0
- package/dist/bundle/four-meme/utils-sweep.d.ts +3 -4
- package/dist/bundle/four-meme/utils-sweep.js +3 -740
- package/dist/bundle/internal.d.ts +2 -2
- package/dist/bundle/sign-context-helpers.d.ts +1 -26
- package/dist/bundle/sign-context-helpers.js +1 -63
- package/dist/bundle/submit/blockrazor.d.ts +94 -0
- package/dist/bundle/submit/blockrazor.js +122 -0
- package/dist/bundle/submit/direct.d.ts +118 -0
- package/dist/bundle/submit/direct.js +484 -0
- package/dist/bundle/submit/helpers.d.ts +7 -0
- package/dist/bundle/submit/helpers.js +15 -0
- package/dist/bundle/submit/index.d.ts +14 -0
- package/dist/bundle/submit/index.js +14 -0
- package/dist/bundle/submit/merkle.d.ts +84 -0
- package/dist/bundle/submit/merkle.js +121 -0
- package/dist/bundle/submit.d.ts +3 -286
- package/dist/bundle/submit.js +3 -724
- package/dist/chains/bsc/four/types.d.ts +1 -1
- package/dist/chains/bsc/pancake/bundle-buy-first-build.d.ts +25 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-build.js +177 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-constants.d.ts +30 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-constants.js +24 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +11 -149
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +12 -74
- package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.d.ts +9 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.js +225 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.d.ts +14 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.js +64 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-profit.d.ts +12 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-profit.js +22 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-quote.d.ts +15 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-quote.js +122 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-types.d.ts +179 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-types.js +1 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-validate.d.ts +2 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-validate.js +41 -0
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -1
- package/dist/chains/bsc/pancake/bundle-buy-first.js +8 -578
- package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +11 -239
- package/dist/chains/bsc/pancake/bundle-swap-helpers.js +12 -564
- package/dist/chains/bsc/pancake/bundle-swap-types.d.ts +183 -0
- package/dist/chains/bsc/pancake/bundle-swap-types.js +17 -0
- package/dist/chains/bsc/pancake/bundle-swap.d.ts +10 -132
- package/dist/chains/bsc/pancake/bundle-swap.js +12 -1003
- package/dist/chains/bsc/pancake/hop-chain.d.ts +18 -0
- package/dist/chains/bsc/pancake/hop-chain.js +227 -0
- package/dist/chains/bsc/pancake/quote.d.ts +14 -0
- package/dist/chains/bsc/pancake/quote.js +84 -0
- package/dist/chains/bsc/pancake/swap-batch.d.ts +42 -0
- package/dist/chains/bsc/pancake/swap-batch.js +283 -0
- package/dist/chains/bsc/pancake/swap-build.d.ts +19 -0
- package/dist/chains/bsc/pancake/swap-build.js +226 -0
- package/dist/chains/bsc/pancake/swap-cross.d.ts +42 -0
- package/dist/chains/bsc/pancake/swap-cross.js +140 -0
- package/dist/chains/bsc/pancake/swap-quick.d.ts +54 -0
- package/dist/chains/bsc/pancake/swap-quick.js +424 -0
- package/dist/chains/bsc/pancake/swap-single.d.ts +2 -0
- package/dist/chains/bsc/pancake/swap-single.js +182 -0
- package/dist/chains/bsc/platforms/four/index.d.ts +21 -3
- package/dist/chains/bsc/platforms/four/index.js +28 -3
- package/dist/chains/eni/batch-router/transfer-disperse.d.ts +37 -0
- package/dist/chains/eni/batch-router/transfer-disperse.js +302 -0
- package/dist/chains/eni/batch-router/transfer-shared.d.ts +9 -0
- package/dist/chains/eni/batch-router/transfer-shared.js +10 -0
- package/dist/chains/eni/batch-router/transfer-sweep.d.ts +51 -0
- package/dist/chains/eni/batch-router/transfer-sweep.js +364 -0
- package/dist/chains/eni/batch-router/transfer.d.ts +4 -74
- package/dist/chains/eni/batch-router/transfer.js +2 -647
- package/dist/chains/eni/platforms/daoaas/portal-direct-profit.d.ts +17 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-profit.js +30 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-submit.d.ts +12 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-submit.js +396 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-tx.d.ts +20 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-tx.js +165 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct.d.ts +3 -32
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +3 -571
- package/dist/chains/eni/submit.js +1 -1
- package/dist/chains/xlayer/constants.d.ts +0 -2
- package/dist/chains/xlayer/constants.js +0 -2
- package/dist/chains/xlayer/eip7702/auth.d.ts +16 -0
- package/dist/chains/xlayer/eip7702/auth.js +81 -0
- package/dist/chains/xlayer/eip7702/bundle-create-buy.d.ts +22 -0
- package/dist/chains/xlayer/eip7702/bundle-create-buy.js +201 -0
- package/dist/chains/xlayer/eip7702/bundle-create-helpers.d.ts +114 -0
- package/dist/chains/xlayer/eip7702/bundle-create-helpers.js +139 -0
- package/dist/chains/xlayer/eip7702/bundle-create-to-dex.d.ts +24 -0
- package/dist/chains/xlayer/eip7702/bundle-create-to-dex.js +233 -0
- package/dist/chains/xlayer/eip7702/bundle-create.d.ts +3 -35
- package/dist/chains/xlayer/eip7702/bundle-create.js +3 -746
- package/dist/chains/xlayer/eip7702/bundle-graduate-buy.d.ts +22 -0
- package/dist/chains/xlayer/eip7702/bundle-graduate-buy.js +214 -0
- package/dist/chains/xlayer/eip7702/bundle-sell.js +1 -1
- package/dist/chains/xlayer/eip7702/bundle-swap-batch.d.ts +31 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-batch.js +216 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-helpers.d.ts +21 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-helpers.js +206 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-multi.d.ts +33 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-multi.js +146 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-single.d.ts +31 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-single.js +177 -0
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +6 -61
- package/dist/chains/xlayer/eip7702/bundle-swap.js +3 -712
- package/dist/chains/xlayer/eip7702/bytes.d.ts +4 -0
- package/dist/chains/xlayer/eip7702/bytes.js +31 -0
- package/dist/chains/xlayer/eip7702/gas.d.ts +19 -0
- package/dist/chains/xlayer/eip7702/gas.js +152 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.js +196 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.js +188 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.js +220 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +8 -4
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +5 -591
- package/dist/chains/xlayer/eip7702/profit.d.ts +32 -0
- package/dist/chains/xlayer/eip7702/profit.js +59 -0
- package/dist/chains/xlayer/eip7702/provider.d.ts +3 -0
- package/dist/chains/xlayer/eip7702/provider.js +17 -0
- package/dist/chains/xlayer/eip7702/time.d.ts +2 -0
- package/dist/chains/xlayer/eip7702/time.js +10 -0
- package/dist/chains/xlayer/eip7702/tx-build.d.ts +10 -0
- package/dist/chains/xlayer/eip7702/tx-build.js +128 -0
- package/dist/chains/xlayer/eip7702/utils.d.ts +19 -85
- package/dist/chains/xlayer/eip7702/utils.js +19 -484
- package/dist/chains/xlayer/eip7702/volume-bundle.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/volume-bundle.js +250 -0
- package/dist/chains/xlayer/eip7702/volume-internal.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/volume-internal.js +169 -0
- package/dist/chains/xlayer/eip7702/volume-make.d.ts +8 -0
- package/dist/chains/xlayer/eip7702/volume-make.js +38 -0
- package/dist/chains/xlayer/eip7702/volume-single-round.d.ts +17 -0
- package/dist/chains/xlayer/eip7702/volume-single-round.js +44 -0
- package/dist/chains/xlayer/eip7702/volume-swap.d.ts +18 -0
- package/dist/chains/xlayer/eip7702/volume-swap.js +30 -0
- package/dist/chains/xlayer/eip7702/volume-wash.d.ts +8 -0
- package/dist/chains/xlayer/eip7702/volume-wash.js +191 -0
- package/dist/chains/xlayer/eip7702/volume.d.ts +7 -35
- package/dist/chains/xlayer/eip7702/volume.js +5 -697
- package/dist/chains/xlayer/eip7702/wallet.d.ts +6 -0
- package/dist/chains/xlayer/eip7702/wallet.js +17 -0
- package/dist/chains/xlayer/eoa/aa-types.d.ts +176 -0
- package/dist/chains/xlayer/eoa/aa-types.js +6 -0
- package/dist/chains/xlayer/eoa/constants.d.ts +0 -2
- package/dist/chains/xlayer/eoa/constants.js +0 -2
- package/dist/chains/xlayer/eoa/context.d.ts +8 -0
- package/dist/chains/xlayer/eoa/context.js +23 -0
- package/dist/chains/xlayer/eoa/encoders.d.ts +147 -0
- package/dist/chains/xlayer/eoa/encoders.js +147 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.d.ts +5 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.js +113 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +10 -123
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +10 -225
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.d.ts +50 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.js +170 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.d.ts +5 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.js +257 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.d.ts +99 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.js +11 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +5 -47
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +3 -522
- package/dist/chains/xlayer/eoa/eoa-types.d.ts +776 -0
- package/dist/chains/xlayer/eoa/eoa-types.js +6 -0
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +8 -0
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +8 -0
- package/dist/chains/xlayer/eoa/format.d.ts +34 -0
- package/dist/chains/xlayer/eoa/format.js +56 -0
- package/dist/chains/xlayer/eoa/hop-chain.d.ts +4 -0
- package/dist/chains/xlayer/eoa/hop-chain.js +87 -0
- package/dist/chains/xlayer/eoa/nonce-map.d.ts +20 -0
- package/dist/chains/xlayer/eoa/nonce-map.js +51 -0
- package/dist/chains/xlayer/eoa/portal-ops.d.ts +9 -292
- package/dist/chains/xlayer/eoa/portal-ops.js +9 -486
- package/dist/chains/xlayer/eoa/query.d.ts +117 -0
- package/dist/chains/xlayer/eoa/query.js +285 -0
- package/dist/chains/xlayer/eoa/quote.d.ts +6 -0
- package/dist/chains/xlayer/eoa/quote.js +90 -0
- package/dist/chains/xlayer/eoa/types.d.ts +9 -959
- package/dist/chains/xlayer/eoa/types.js +9 -49
- package/dist/core/clients/blockrazor.js +1 -1
- package/dist/core/clients/merkle.js +1 -1
- package/dist/core/erc20/allowances.d.ts +104 -0
- package/dist/core/erc20/allowances.js +205 -0
- package/dist/core/erc20/approve.d.ts +141 -0
- package/dist/core/erc20/approve.js +325 -0
- package/dist/core/erc20/helpers.d.ts +20 -0
- package/dist/core/erc20/helpers.js +109 -0
- package/dist/core/erc20/index.d.ts +13 -0
- package/dist/core/erc20/index.js +12 -0
- package/dist/core/gas/bundle-gas.d.ts +6 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/quote/index.d.ts +1 -0
- package/dist/core/quote/index.js +1 -0
- package/dist/core/quote/quote-helpers.d.ts +78 -0
- package/dist/core/quote/quote-helpers.js +289 -0
- package/dist/core/quote/types.d.ts +1 -0
- package/dist/core/quote/types.js +1 -0
- package/dist/core/sign-context-helpers.d.ts +29 -0
- package/dist/core/sign-context-helpers.js +63 -0
- package/dist/domains/dex/direct-router-helpers.d.ts +16 -268
- package/dist/domains/dex/direct-router-helpers.js +16 -535
- package/dist/domains/dex/direct-router-types.d.ts +104 -0
- package/dist/domains/dex/direct-router-types.js +81 -0
- package/dist/domains/dex/direct-router-v2-buy.d.ts +2 -0
- package/dist/domains/dex/direct-router-v2-buy.js +249 -0
- package/dist/domains/dex/direct-router-v2-sell.d.ts +5 -0
- package/dist/domains/dex/direct-router-v2-sell.js +270 -0
- package/dist/domains/dex/direct-router-v2.d.ts +9 -0
- package/dist/domains/dex/direct-router-v2.js +9 -0
- package/dist/domains/dex/direct-router-v3.d.ts +17 -0
- package/dist/domains/dex/direct-router-v3.js +432 -0
- package/dist/domains/dex/direct-router.d.ts +11 -26
- package/dist/domains/dex/direct-router.js +10 -977
- package/dist/domains/dex/dyo-encode.d.ts +62 -0
- package/dist/domains/dex/dyo-encode.js +124 -0
- package/dist/domains/dex/profit.d.ts +24 -0
- package/dist/domains/dex/profit.js +86 -0
- package/dist/domains/dex/provider.d.ts +10 -0
- package/dist/domains/dex/provider.js +27 -0
- package/dist/domains/dex/quote.d.ts +7 -0
- package/dist/domains/dex/quote.js +52 -0
- package/dist/domains/dex/router.d.ts +56 -0
- package/dist/domains/dex/router.js +193 -0
- package/dist/domains/flap/portal-bundle/batch.d.ts +9 -0
- package/dist/domains/flap/portal-bundle/batch.js +193 -0
- package/dist/domains/flap/portal-bundle/create.d.ts +5 -0
- package/dist/domains/flap/portal-bundle/create.js +153 -0
- package/dist/domains/flap/portal-bundle/helpers.d.ts +32 -0
- package/dist/domains/flap/portal-bundle/helpers.js +50 -0
- package/dist/domains/flap/portal-bundle/index.d.ts +16 -0
- package/dist/domains/flap/portal-bundle/index.js +15 -0
- package/dist/domains/flap/portal-bundle/private.d.ts +5 -0
- package/dist/domains/flap/portal-bundle/private.js +198 -0
- package/dist/domains/flap/portal-bundle/types.d.ts +102 -0
- package/dist/domains/flap/portal-bundle/types.js +1 -0
- package/dist/domains/flap/portal-bundle-merkle/core-batch.d.ts +13 -0
- package/dist/domains/flap/portal-bundle-merkle/core-batch.js +376 -0
- package/dist/domains/flap/portal-bundle-merkle/core-helpers.d.ts +75 -7
- package/dist/domains/flap/portal-bundle-merkle/core-helpers.js +259 -20
- package/dist/domains/flap/portal-bundle-merkle/core.d.ts +2 -13
- package/dist/domains/flap/portal-bundle-merkle/core.js +12 -629
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.d.ts +70 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.js +90 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.d.ts +15 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.js +432 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.d.ts +113 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.js +4 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -127
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex.js +4 -527
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.d.ts +42 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.js +81 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.d.ts +15 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.js +339 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.d.ts +72 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.js +4 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.d.ts +4 -85
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.js +4 -425
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.js +102 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.d.ts +5 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.js +135 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.d.ts +52 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.js +267 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.d.ts +14 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.js +14 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.d.ts +5 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.js +195 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.d.ts +3 -24
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.js +3 -700
- package/dist/domains/flap/portal-bundle-merkle/private/buy.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/private/buy.js +188 -0
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.d.ts +36 -0
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.js +127 -0
- package/dist/domains/flap/portal-bundle-merkle/private/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/private/index.js +12 -0
- package/dist/domains/flap/portal-bundle-merkle/private/sell.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/private/sell.js +191 -0
- package/dist/domains/flap/portal-bundle-merkle/private.d.ts +5 -15
- package/dist/domains/flap/portal-bundle-merkle/private.js +5 -494
- package/dist/domains/flap/portal-bundle-merkle/swap-batch.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.d.ts +4 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.js +43 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.d.ts +13 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.js +21 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +11 -121
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.js +11 -109
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.d.ts +20 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.js +223 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.d.ts +32 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.js +66 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.d.ts +22 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.js +22 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.d.ts +51 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.js +149 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.d.ts +87 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.js +1 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first.js +5 -404
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.js +0 -7
- package/dist/domains/flap/portal-bundle-merkle/swap-planning.js +1 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-quick-batch.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/swap-single.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/utils/disperse.d.ts +2 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/disperse.js +275 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/index.d.ts +11 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/sweep.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/sweep.js +570 -0
- package/dist/domains/flap/portal-bundle-merkle/utils.d.ts +5 -8
- package/dist/domains/flap/portal-bundle-merkle/utils.js +5 -841
- package/dist/domains/flap/portal-bundle.d.ts +5 -117
- package/dist/domains/flap/portal-bundle.js +5 -587
- package/dist/domains/flap/portal.d.ts +13 -404
- package/dist/domains/flap/portal.js +12 -619
- package/dist/domains/flap/reader.d.ts +51 -0
- package/dist/domains/flap/reader.js +275 -0
- package/dist/domains/flap/types.d.ts +246 -0
- package/dist/domains/flap/types.js +104 -0
- package/dist/domains/flap/vault/constants.d.ts +220 -0
- package/dist/domains/flap/vault/constants.js +173 -0
- package/dist/domains/flap/vault/encode.d.ts +39 -0
- package/dist/domains/flap/vault/encode.js +135 -0
- package/dist/domains/flap/vault/index.d.ts +15 -0
- package/dist/domains/flap/vault/index.js +14 -0
- package/dist/domains/flap/vault/query.d.ts +40 -0
- package/dist/domains/flap/vault/query.js +104 -0
- package/dist/domains/flap/vault/types.d.ts +147 -0
- package/dist/domains/flap/vault/types.js +29 -0
- package/dist/domains/flap/vault.d.ts +3 -413
- package/dist/domains/flap/vault.js +3 -467
- package/dist/domains/flap/writer.d.ts +124 -0
- package/dist/domains/flap/writer.js +255 -0
- package/dist/domains/four/contracts/tm-bundle-batch.d.ts +35 -0
- package/dist/domains/four/contracts/tm-bundle-batch.js +286 -0
- package/dist/domains/four/contracts/tm-bundle-create.d.ts +2 -0
- package/dist/domains/four/contracts/tm-bundle-create.js +304 -0
- package/dist/domains/four/contracts/tm-bundle-helpers.d.ts +2 -1
- package/dist/domains/four/contracts/tm-bundle-helpers.js +3 -0
- package/dist/domains/four/contracts/tm-bundle-private.d.ts +36 -0
- package/dist/domains/four/contracts/tm-bundle-private.js +164 -0
- package/dist/domains/four/contracts/tm-bundle.d.ts +10 -71
- package/dist/domains/four/contracts/tm-bundle.js +9 -738
- package/dist/domains/lp-inspect/inspect-helpers.d.ts +25 -0
- package/dist/domains/lp-inspect/inspect-helpers.js +343 -0
- package/dist/domains/lp-inspect/inspect.d.ts +8 -0
- package/dist/domains/lp-inspect/inspect.js +332 -0
- package/dist/domains/lp-inspect/lp-inspect.d.ts +9 -37
- package/dist/domains/lp-inspect/lp-inspect.js +9 -775
- package/dist/domains/lp-inspect/registry.d.ts +43 -0
- package/dist/domains/lp-inspect/registry.js +127 -0
- package/dist/domains/merkle/index.d.ts +1 -1
- package/dist/exports/root-bundle-and-tooling.d.ts +9 -1
- package/dist/exports/root-bundle-and-tooling.js +8 -1
- package/dist/exports/root-foundations.d.ts +1 -1
- package/dist/exports/root-foundations.js +1 -1
- package/dist/exports/root-swap-dex-and-xlayer.d.ts +4 -4
- package/dist/exports/root-swap-dex-and-xlayer.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/swap-helpers.js +1 -1
- package/package.json +1 -85
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 逐笔广播提交后端(用于 Monad 等不支持 Bundle 的链)
|
|
3
|
+
*/
|
|
4
|
+
import { ethers } from 'ethers';
|
|
5
|
+
import { getErrorMessageFromUnknown, consoleSdkLogger } from '../../core/index.js';
|
|
6
|
+
import { createSignProvider } from '../../core/sign-context-helpers.js';
|
|
7
|
+
const sdkLogger = consoleSdkLogger;
|
|
8
|
+
function shouldTreatBroadcastErrorAsMaybeSent(msg) {
|
|
9
|
+
const m = String(msg || '').toLowerCase();
|
|
10
|
+
return (m.includes('already known') ||
|
|
11
|
+
m.includes('known transaction') ||
|
|
12
|
+
m.includes('already exists') ||
|
|
13
|
+
m.includes('nonce too low') ||
|
|
14
|
+
m.includes('nonce has already been used') ||
|
|
15
|
+
m.includes('nonce expired') ||
|
|
16
|
+
m.includes('replacement transaction underpriced'));
|
|
17
|
+
}
|
|
18
|
+
async function recoverTxHashIfAlreadySeen(provider, signedTx, errorMessage) {
|
|
19
|
+
if (!shouldTreatBroadcastErrorAsMaybeSent(errorMessage))
|
|
20
|
+
return undefined;
|
|
21
|
+
try {
|
|
22
|
+
const hash = ethers.Transaction.from(signedTx).hash;
|
|
23
|
+
if (!hash)
|
|
24
|
+
return undefined;
|
|
25
|
+
const tx = await provider.getTransaction(hash);
|
|
26
|
+
return tx ? hash : undefined;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 并行广播到 RPC(用于不支持 Bundle 的链,如 Monad)
|
|
34
|
+
*
|
|
35
|
+
* ✅ 优化:默认使用并行广播,速度更快
|
|
36
|
+
*
|
|
37
|
+
* @param signedTransactions 签名后的交易数组
|
|
38
|
+
* @param config 直接广播配置
|
|
39
|
+
* @returns 广播结果
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // 服务器端代码(Monad 链)
|
|
44
|
+
* import { submitDirectToRpc } from 'four-flap-meme-sdk';
|
|
45
|
+
*
|
|
46
|
+
* const result = await submitDirectToRpc(signedTransactions, {
|
|
47
|
+
* rpcUrl: 'https://rpc-mainnet.monadinfra.com',
|
|
48
|
+
* chainId: 143,
|
|
49
|
+
* chainName: 'MONAD'
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* if (result.code) {
|
|
53
|
+
* } else {
|
|
54
|
+
* console.error('❌ 全部广播失败:', result.errorSummary);
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export async function submitDirectToRpc(signedTransactions, config) {
|
|
59
|
+
const totalTransactions = signedTransactions?.length ?? 0;
|
|
60
|
+
// 验证输入
|
|
61
|
+
if (!signedTransactions || signedTransactions.length === 0) {
|
|
62
|
+
return {
|
|
63
|
+
code: false,
|
|
64
|
+
totalTransactions: 0,
|
|
65
|
+
successCount: 0,
|
|
66
|
+
failedCount: 0,
|
|
67
|
+
txHashes: [],
|
|
68
|
+
results: [],
|
|
69
|
+
errorSummary: 'signedTransactions cannot be empty',
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (!config.rpcUrl) {
|
|
73
|
+
return {
|
|
74
|
+
code: false,
|
|
75
|
+
totalTransactions,
|
|
76
|
+
successCount: 0,
|
|
77
|
+
failedCount: totalTransactions,
|
|
78
|
+
txHashes: [],
|
|
79
|
+
results: [],
|
|
80
|
+
errorSummary: 'rpcUrl is required in config',
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const chainId = config.chainId ?? 143;
|
|
84
|
+
const chainName = config.chainName ?? 'MONAD';
|
|
85
|
+
const provider = createSignProvider(config.rpcUrl, chainId, chainName);
|
|
86
|
+
// ✅ 并行广播所有交易
|
|
87
|
+
const broadcastPromises = signedTransactions.map(async (signedTx, i) => {
|
|
88
|
+
try {
|
|
89
|
+
const txResponse = await provider.broadcastTransaction(signedTx);
|
|
90
|
+
// 如果需要等待确认
|
|
91
|
+
if (config.waitForConfirmation) {
|
|
92
|
+
try {
|
|
93
|
+
const receipt = await provider.waitForTransaction(txResponse.hash, 1, config.confirmationTimeout ?? 30000);
|
|
94
|
+
if (receipt && receipt.status === 0) {
|
|
95
|
+
console.warn(`⚠️ [${chainName}] 交易 ${txResponse.hash} 执行失败(已上链但状态为0)`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (_waitError) {
|
|
99
|
+
console.warn(`⚠️ [${chainName}] 等待交易确认超时: ${txResponse.hash}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
index: i,
|
|
104
|
+
success: true,
|
|
105
|
+
txHash: txResponse.hash,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
const errorMessage = getErrorMessageFromUnknown(error);
|
|
110
|
+
console.error(`❌ [${chainName}] 交易 ${i + 1}/${totalTransactions} 广播失败:`, errorMessage);
|
|
111
|
+
// ✅ 兼容:nonce too low / already known 等情况下,交易可能已经被接收
|
|
112
|
+
const recovered = await recoverTxHashIfAlreadySeen(provider, signedTx, errorMessage);
|
|
113
|
+
if (recovered) {
|
|
114
|
+
if (config.waitForConfirmation) {
|
|
115
|
+
try {
|
|
116
|
+
await provider.waitForTransaction(recovered, 1, config.confirmationTimeout ?? 30000);
|
|
117
|
+
}
|
|
118
|
+
catch (waitError) {
|
|
119
|
+
sdkLogger.debug?.(`[DirectSubmit] recovered tx waitForTransaction failed: ${recovered}`, getErrorMessageFromUnknown(waitError));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return { index: i, success: true, txHash: recovered, error: errorMessage };
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
index: i,
|
|
126
|
+
success: false,
|
|
127
|
+
error: errorMessage,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
const results = await Promise.all(broadcastPromises);
|
|
132
|
+
// 按索引排序结果
|
|
133
|
+
results.sort((a, b) => a.index - b.index);
|
|
134
|
+
const txHashes = results.filter((r) => r.success && r.txHash).map((r) => r.txHash);
|
|
135
|
+
const errors = results.filter((r) => !r.success).map((r) => `交易 ${r.index + 1}: ${r.error}`);
|
|
136
|
+
const successCount = txHashes.length;
|
|
137
|
+
const failedCount = totalTransactions - successCount;
|
|
138
|
+
return {
|
|
139
|
+
code: successCount > 0,
|
|
140
|
+
totalTransactions,
|
|
141
|
+
successCount,
|
|
142
|
+
failedCount,
|
|
143
|
+
txHashes,
|
|
144
|
+
results,
|
|
145
|
+
errorSummary: errors.length > 0 ? errors.join('; ') : undefined,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* ✅ 顺序广播并等待确认(用于多跳交易等需要顺序执行的场景)
|
|
150
|
+
*
|
|
151
|
+
* 每笔交易广播后会等待上链确认,确保后续交易能正确执行
|
|
152
|
+
*
|
|
153
|
+
* ⚠️ 多跳场景:如果某笔交易失败,会立即停止(因为后续交易肯定也会失败)
|
|
154
|
+
*
|
|
155
|
+
* @param signedTransactions 签名后的交易数组
|
|
156
|
+
* @param config 直接广播配置
|
|
157
|
+
* @returns 广播结果
|
|
158
|
+
*/
|
|
159
|
+
export async function submitDirectToRpcSequential(signedTransactions, config) {
|
|
160
|
+
const totalTransactions = signedTransactions?.length ?? 0;
|
|
161
|
+
if (!signedTransactions || signedTransactions.length === 0) {
|
|
162
|
+
return {
|
|
163
|
+
code: false,
|
|
164
|
+
totalTransactions: 0,
|
|
165
|
+
successCount: 0,
|
|
166
|
+
failedCount: 0,
|
|
167
|
+
txHashes: [],
|
|
168
|
+
results: [],
|
|
169
|
+
errorSummary: 'signedTransactions cannot be empty',
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (!config.rpcUrl) {
|
|
173
|
+
return {
|
|
174
|
+
code: false,
|
|
175
|
+
totalTransactions,
|
|
176
|
+
successCount: 0,
|
|
177
|
+
failedCount: totalTransactions,
|
|
178
|
+
txHashes: [],
|
|
179
|
+
results: [],
|
|
180
|
+
errorSummary: 'rpcUrl is required in config',
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
const chainId = config.chainId ?? 143;
|
|
184
|
+
const chainName = config.chainName ?? 'MONAD';
|
|
185
|
+
// ✅ XLayer 链默认 120 秒超时(网络可能较慢)
|
|
186
|
+
const confirmationTimeout = config.confirmationTimeout ?? (chainId === 196 ? 120000 : 60000);
|
|
187
|
+
const provider = createSignProvider(config.rpcUrl, chainId, chainName);
|
|
188
|
+
const results = [];
|
|
189
|
+
const txHashes = [];
|
|
190
|
+
const errors = [];
|
|
191
|
+
// 顺序广播并等待确认
|
|
192
|
+
for (let i = 0; i < signedTransactions.length; i++) {
|
|
193
|
+
const signedTx = signedTransactions[i];
|
|
194
|
+
try {
|
|
195
|
+
// 广播交易
|
|
196
|
+
const txResponse = await provider.broadcastTransaction(signedTx);
|
|
197
|
+
// ✅ 等待交易确认
|
|
198
|
+
const receipt = await provider.waitForTransaction(txResponse.hash, 1, // 等待1个确认
|
|
199
|
+
confirmationTimeout);
|
|
200
|
+
if (receipt && receipt.status === 1) {
|
|
201
|
+
results.push({
|
|
202
|
+
index: i,
|
|
203
|
+
success: true,
|
|
204
|
+
txHash: txResponse.hash,
|
|
205
|
+
});
|
|
206
|
+
txHashes.push(txResponse.hash);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
const errorMsg = `交易执行失败(status=${receipt?.status})`;
|
|
210
|
+
console.error(`❌ [${chainName}] 交易 ${i + 1}/${totalTransactions} 上链失败: ${errorMsg}`);
|
|
211
|
+
results.push({
|
|
212
|
+
index: i,
|
|
213
|
+
success: false,
|
|
214
|
+
txHash: txResponse.hash,
|
|
215
|
+
error: errorMsg,
|
|
216
|
+
});
|
|
217
|
+
errors.push(`交易 ${i + 1}: ${errorMsg}`);
|
|
218
|
+
// ✅ 多跳场景:如果某笔失败,后续交易肯定也会失败,立即停止
|
|
219
|
+
console.warn(`⚠️ [${chainName}] 多跳模式检测到失败,停止后续 ${totalTransactions - i - 1} 笔交易`);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
const errorMessage = getErrorMessageFromUnknown(error);
|
|
225
|
+
console.error(`❌ [${chainName}] 交易 ${i + 1}/${totalTransactions} 广播/确认失败:`, errorMessage);
|
|
226
|
+
// ✅ 兼容:nonce too low / already known 等情况下,交易可能已经被接收
|
|
227
|
+
const recovered = await recoverTxHashIfAlreadySeen(provider, signedTx, errorMessage);
|
|
228
|
+
if (recovered) {
|
|
229
|
+
// 顺序模式依赖确认:尽量等待一下
|
|
230
|
+
try {
|
|
231
|
+
const receipt = await provider.waitForTransaction(recovered, 1, confirmationTimeout);
|
|
232
|
+
if (receipt && receipt.status === 1) {
|
|
233
|
+
results.push({ index: i, success: true, txHash: recovered, error: errorMessage });
|
|
234
|
+
txHashes.push(recovered);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
const errorMsg = `交易执行失败(status=${receipt?.status})`;
|
|
238
|
+
console.error(`❌ [${chainName}] 交易 ${i + 1} 恢复失败: ${errorMsg}`);
|
|
239
|
+
results.push({ index: i, success: false, txHash: recovered, error: `${errorMessage} | ${errorMsg}` });
|
|
240
|
+
errors.push(`交易 ${i + 1}: ${errorMessage} | ${errorMsg}`);
|
|
241
|
+
// ✅ 多跳场景:失败则停止
|
|
242
|
+
console.warn(`⚠️ [${chainName}] 多跳模式检测到失败,停止后续 ${totalTransactions - i - 1} 笔交易`);
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
catch (waitError) {
|
|
246
|
+
// 等待超时:对于多跳场景,不能假设成功,需要停止
|
|
247
|
+
const waitErrorMsg = getErrorMessageFromUnknown(waitError);
|
|
248
|
+
console.error(`⏱️ [${chainName}] 交易 ${i + 1} 等待确认超时: ${waitErrorMsg}`);
|
|
249
|
+
results.push({
|
|
250
|
+
index: i,
|
|
251
|
+
success: false,
|
|
252
|
+
txHash: recovered,
|
|
253
|
+
error: `${errorMessage} | 等待确认超时: ${waitErrorMsg}`,
|
|
254
|
+
});
|
|
255
|
+
errors.push(`交易 ${i + 1}: ${errorMessage} | 等待确认超时`);
|
|
256
|
+
// ✅ 多跳场景:超时也停止
|
|
257
|
+
console.warn(`⚠️ [${chainName}] 多跳模式检测到超时,停止后续 ${totalTransactions - i - 1} 笔交易`);
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
results.push({
|
|
262
|
+
index: i,
|
|
263
|
+
success: false,
|
|
264
|
+
error: errorMessage,
|
|
265
|
+
});
|
|
266
|
+
errors.push(`交易 ${i + 1}: ${errorMessage}`);
|
|
267
|
+
// ✅ 多跳场景:如果某笔失败,后续交易肯定也会失败,立即停止
|
|
268
|
+
console.warn(`⚠️ [${chainName}] 多跳模式检测到失败,停止后续 ${totalTransactions - i - 1} 笔交易`);
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const successCount = txHashes.length;
|
|
273
|
+
const failedCount = totalTransactions - successCount;
|
|
274
|
+
return {
|
|
275
|
+
code: successCount > 0,
|
|
276
|
+
totalTransactions,
|
|
277
|
+
successCount,
|
|
278
|
+
failedCount,
|
|
279
|
+
txHashes,
|
|
280
|
+
results,
|
|
281
|
+
errorSummary: errors.length > 0 ? errors.join('; ') : undefined,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* ✅ 顺序广播但不等待确认(用于 AA handleOps + tail 等 nonce 连续的场景)
|
|
286
|
+
*
|
|
287
|
+
* 按顺序逐笔发送交易,每笔只等待广播成功(RPC 返回 txHash),不等待链上确认。
|
|
288
|
+
* 这样可以保证交易按顺序进入 mempool,同时避免等待确认超时。
|
|
289
|
+
*
|
|
290
|
+
* @param signedTransactions 签名后的交易数组
|
|
291
|
+
* @param config 直接广播配置
|
|
292
|
+
* @returns 广播结果
|
|
293
|
+
*/
|
|
294
|
+
export async function submitDirectToRpcSequentialNoWait(signedTransactions, config) {
|
|
295
|
+
const totalTransactions = signedTransactions?.length ?? 0;
|
|
296
|
+
if (!signedTransactions || signedTransactions.length === 0) {
|
|
297
|
+
return {
|
|
298
|
+
code: false,
|
|
299
|
+
totalTransactions: 0,
|
|
300
|
+
successCount: 0,
|
|
301
|
+
failedCount: 0,
|
|
302
|
+
txHashes: [],
|
|
303
|
+
results: [],
|
|
304
|
+
errorSummary: 'signedTransactions cannot be empty',
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
if (!config.rpcUrl) {
|
|
308
|
+
return {
|
|
309
|
+
code: false,
|
|
310
|
+
totalTransactions,
|
|
311
|
+
successCount: 0,
|
|
312
|
+
failedCount: totalTransactions,
|
|
313
|
+
txHashes: [],
|
|
314
|
+
results: [],
|
|
315
|
+
errorSummary: 'rpcUrl is required in config',
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
const chainId = config.chainId ?? 143;
|
|
319
|
+
const chainName = config.chainName ?? 'MONAD';
|
|
320
|
+
const provider = createSignProvider(config.rpcUrl, chainId, chainName);
|
|
321
|
+
const results = [];
|
|
322
|
+
const txHashes = [];
|
|
323
|
+
const errors = [];
|
|
324
|
+
// ✅ 顺序广播,每笔只等待广播成功(不等待链上确认)
|
|
325
|
+
for (let i = 0; i < signedTransactions.length; i++) {
|
|
326
|
+
const signedTx = signedTransactions[i];
|
|
327
|
+
try {
|
|
328
|
+
// 广播交易,等待 RPC 返回 txHash
|
|
329
|
+
const txResponse = await provider.broadcastTransaction(signedTx);
|
|
330
|
+
results.push({
|
|
331
|
+
index: i,
|
|
332
|
+
success: true,
|
|
333
|
+
txHash: txResponse.hash,
|
|
334
|
+
});
|
|
335
|
+
txHashes.push(txResponse.hash);
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
const errorMessage = getErrorMessageFromUnknown(error);
|
|
339
|
+
console.error(`❌ [${chainName}] 交易 ${i + 1}/${totalTransactions} 广播失败:`, errorMessage);
|
|
340
|
+
// ✅ 兼容:nonce too low / already known 等情况下,交易可能已经被接收
|
|
341
|
+
const recovered = await recoverTxHashIfAlreadySeen(provider, signedTx, errorMessage);
|
|
342
|
+
if (recovered) {
|
|
343
|
+
results.push({ index: i, success: true, txHash: recovered, error: errorMessage });
|
|
344
|
+
txHashes.push(recovered);
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
results.push({
|
|
348
|
+
index: i,
|
|
349
|
+
success: false,
|
|
350
|
+
error: errorMessage,
|
|
351
|
+
});
|
|
352
|
+
errors.push(`交易 ${i + 1}: ${errorMessage}`);
|
|
353
|
+
// ✅ 如果某笔失败,继续尝试后续交易(可能是 nonce 问题可以自动恢复)
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
const successCount = txHashes.length;
|
|
357
|
+
const failedCount = totalTransactions - successCount;
|
|
358
|
+
return {
|
|
359
|
+
code: successCount > 0,
|
|
360
|
+
totalTransactions,
|
|
361
|
+
successCount,
|
|
362
|
+
failedCount,
|
|
363
|
+
txHashes,
|
|
364
|
+
results,
|
|
365
|
+
errorSummary: errors.length > 0 ? errors.join('; ') : undefined,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* 并行逐笔广播到 RPC(速度更快,但可能有 nonce 冲突)
|
|
370
|
+
*
|
|
371
|
+
* ⚠️ 注意:仅适用于不同钱包的交易,同一钱包的多笔交易应使用顺序广播
|
|
372
|
+
*
|
|
373
|
+
* @param signedTransactions 签名后的交易数组
|
|
374
|
+
* @param config 直接广播配置
|
|
375
|
+
* @returns 广播结果
|
|
376
|
+
*/
|
|
377
|
+
export async function submitDirectToRpcParallel(signedTransactions, config) {
|
|
378
|
+
const totalTransactions = signedTransactions?.length ?? 0;
|
|
379
|
+
if (!signedTransactions || signedTransactions.length === 0) {
|
|
380
|
+
return {
|
|
381
|
+
code: false,
|
|
382
|
+
totalTransactions: 0,
|
|
383
|
+
successCount: 0,
|
|
384
|
+
failedCount: 0,
|
|
385
|
+
txHashes: [],
|
|
386
|
+
results: [],
|
|
387
|
+
errorSummary: 'signedTransactions cannot be empty',
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
if (!config.rpcUrl) {
|
|
391
|
+
return {
|
|
392
|
+
code: false,
|
|
393
|
+
totalTransactions,
|
|
394
|
+
successCount: 0,
|
|
395
|
+
failedCount: totalTransactions,
|
|
396
|
+
txHashes: [],
|
|
397
|
+
results: [],
|
|
398
|
+
errorSummary: 'rpcUrl is required in config',
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
const chainId = config.chainId ?? 143;
|
|
402
|
+
const chainName = config.chainName ?? 'MONAD';
|
|
403
|
+
const provider = createSignProvider(config.rpcUrl, chainId, chainName);
|
|
404
|
+
// 并行广播
|
|
405
|
+
const broadcastPromises = signedTransactions.map(async (signedTx, i) => {
|
|
406
|
+
try {
|
|
407
|
+
const txResponse = await provider.broadcastTransaction(signedTx);
|
|
408
|
+
return {
|
|
409
|
+
index: i,
|
|
410
|
+
success: true,
|
|
411
|
+
txHash: txResponse.hash,
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
return {
|
|
416
|
+
index: i,
|
|
417
|
+
success: false,
|
|
418
|
+
error: getErrorMessageFromUnknown(error),
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
const results = await Promise.all(broadcastPromises);
|
|
423
|
+
const txHashes = results.filter((r) => r.success && r.txHash).map((r) => r.txHash);
|
|
424
|
+
const errors = results.filter((r) => !r.success).map((r) => `交易 ${r.index + 1}: ${r.error}`);
|
|
425
|
+
const successCount = txHashes.length;
|
|
426
|
+
const failedCount = totalTransactions - successCount;
|
|
427
|
+
return {
|
|
428
|
+
code: successCount > 0,
|
|
429
|
+
totalTransactions,
|
|
430
|
+
successCount,
|
|
431
|
+
failedCount,
|
|
432
|
+
txHashes,
|
|
433
|
+
results,
|
|
434
|
+
errorSummary: errors.length > 0 ? errors.join('; ') : undefined,
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* 智能广播到 RPC(自动选择并行或顺序)
|
|
439
|
+
*/
|
|
440
|
+
export async function submitDirectToRpcSmart(signedTransactions, config, options) {
|
|
441
|
+
const emptyFail = (mode) => ({
|
|
442
|
+
code: false,
|
|
443
|
+
totalTransactions: 0,
|
|
444
|
+
successCount: 0,
|
|
445
|
+
failedCount: 0,
|
|
446
|
+
txHashes: [],
|
|
447
|
+
results: [],
|
|
448
|
+
errorSummary: 'signedTransactions cannot be empty',
|
|
449
|
+
mode,
|
|
450
|
+
});
|
|
451
|
+
if (!signedTransactions || signedTransactions.length === 0) {
|
|
452
|
+
return emptyFail('parallel');
|
|
453
|
+
}
|
|
454
|
+
const hasMultipleFromSameWallet = (() => {
|
|
455
|
+
if (signedTransactions.length < 2)
|
|
456
|
+
return false;
|
|
457
|
+
const seen = new Set();
|
|
458
|
+
for (const raw of signedTransactions) {
|
|
459
|
+
if (!raw)
|
|
460
|
+
continue;
|
|
461
|
+
try {
|
|
462
|
+
const tx = ethers.Transaction.from(raw);
|
|
463
|
+
const from = (tx.from || '').toLowerCase();
|
|
464
|
+
if (!from)
|
|
465
|
+
continue;
|
|
466
|
+
if (seen.has(from))
|
|
467
|
+
return true;
|
|
468
|
+
seen.add(from);
|
|
469
|
+
}
|
|
470
|
+
catch {
|
|
471
|
+
// ignore parse errors
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return false;
|
|
475
|
+
})();
|
|
476
|
+
if (hasMultipleFromSameWallet) {
|
|
477
|
+
const result = options?.waitConfirmation
|
|
478
|
+
? await submitDirectToRpcSequential(signedTransactions, config)
|
|
479
|
+
: await submitDirectToRpcSequentialNoWait(signedTransactions, config);
|
|
480
|
+
return { ...result, mode: 'sequential' };
|
|
481
|
+
}
|
|
482
|
+
const result = await submitDirectToRpcParallel(signedTransactions, config);
|
|
483
|
+
return { ...result, mode: 'parallel' };
|
|
484
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundle 提交共享辅助(Merkle / BlockRazor 共用)
|
|
3
|
+
*/
|
|
4
|
+
/** 客户端缓存 TTL(复用连接,减少初始化开销) */
|
|
5
|
+
export declare const CLIENT_CACHE_TTL_MS: number;
|
|
6
|
+
export declare function submitBundlesSequential<T>(bundles: string[][], submitFn: (signedTransactions: string[]) => Promise<T>): Promise<T[]>;
|
|
7
|
+
export declare function submitBundlesParallel<T>(bundles: string[][], submitFn: (signedTransactions: string[]) => Promise<T>): Promise<T[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundle 提交共享辅助(Merkle / BlockRazor 共用)
|
|
3
|
+
*/
|
|
4
|
+
/** 客户端缓存 TTL(复用连接,减少初始化开销) */
|
|
5
|
+
export const CLIENT_CACHE_TTL_MS = 60 * 1000; // 60秒缓存
|
|
6
|
+
export async function submitBundlesSequential(bundles, submitFn) {
|
|
7
|
+
const results = [];
|
|
8
|
+
for (const signedTransactions of bundles) {
|
|
9
|
+
results.push(await submitFn(signedTransactions));
|
|
10
|
+
}
|
|
11
|
+
return results;
|
|
12
|
+
}
|
|
13
|
+
export async function submitBundlesParallel(bundles, submitFn) {
|
|
14
|
+
return Promise.all(bundles.map((signedTransactions) => submitFn(signedTransactions)));
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundle 提交 barrel
|
|
3
|
+
*
|
|
4
|
+
* 原超长文件按提交后端拆分为:
|
|
5
|
+
* - helpers.ts:Merkle / BlockRazor 共用缓存与批量提交辅助
|
|
6
|
+
* - merkle.ts:Merkle 提交后端
|
|
7
|
+
* - blockrazor.ts:BlockRazor 提交后端
|
|
8
|
+
* - direct.ts:逐笔 RPC 广播后端
|
|
9
|
+
*
|
|
10
|
+
* 对外 export 符号与路径保持不变。
|
|
11
|
+
*/
|
|
12
|
+
export { submitBundleToMerkle, submitMultipleBundles, submitMultipleBundlesParallel, type MerkleSubmitConfig, type SubmitBundleResult, } from './merkle.js';
|
|
13
|
+
export { submitBundleToBlockRazor, submitMultipleBundlesToBlockRazor, submitMultipleBundlesToBlockRazorParallel, type BlockRazorSubmitConfig, type BlockRazorSubmitResult, } from './blockrazor.js';
|
|
14
|
+
export { submitDirectToRpc, submitDirectToRpcSequential, submitDirectToRpcSequentialNoWait, submitDirectToRpcParallel, submitDirectToRpcSmart, type DirectSubmitConfig, type DirectTxResult, type DirectSubmitResult, } from './direct.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundle 提交 barrel
|
|
3
|
+
*
|
|
4
|
+
* 原超长文件按提交后端拆分为:
|
|
5
|
+
* - helpers.ts:Merkle / BlockRazor 共用缓存与批量提交辅助
|
|
6
|
+
* - merkle.ts:Merkle 提交后端
|
|
7
|
+
* - blockrazor.ts:BlockRazor 提交后端
|
|
8
|
+
* - direct.ts:逐笔 RPC 广播后端
|
|
9
|
+
*
|
|
10
|
+
* 对外 export 符号与路径保持不变。
|
|
11
|
+
*/
|
|
12
|
+
export { submitBundleToMerkle, submitMultipleBundles, submitMultipleBundlesParallel, } from './merkle.js';
|
|
13
|
+
export { submitBundleToBlockRazor, submitMultipleBundlesToBlockRazor, submitMultipleBundlesToBlockRazorParallel, } from './blockrazor.js';
|
|
14
|
+
export { submitDirectToRpc, submitDirectToRpcSequential, submitDirectToRpcSequentialNoWait, submitDirectToRpcParallel, submitDirectToRpcSmart, } from './direct.js';
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merkle Bundle 提交后端
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 精简的Merkle提交配置(只包含提交需要的字段)
|
|
6
|
+
*/
|
|
7
|
+
export interface MerkleSubmitConfig {
|
|
8
|
+
/** Merkle API Key(必需) */
|
|
9
|
+
apiKey: string;
|
|
10
|
+
/** 自定义RPC URL(可选) */
|
|
11
|
+
customRpcUrl?: string;
|
|
12
|
+
/** 链ID(可选,默认56=BSC) */
|
|
13
|
+
chainId?: 56 | 1;
|
|
14
|
+
/** Bundle区块偏移量(可选,默认3) */
|
|
15
|
+
bundleBlockOffset?: number;
|
|
16
|
+
/** 最小区块偏移量(可选,默认3) */
|
|
17
|
+
minBlockOffset?: number;
|
|
18
|
+
/** 是否自动重试(可选,默认false) */
|
|
19
|
+
autoRetryBundle?: boolean;
|
|
20
|
+
/** 最大重试次数(可选,默认2) */
|
|
21
|
+
maxBundleRetries?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Bundle提交结果
|
|
25
|
+
*/
|
|
26
|
+
export interface SubmitBundleResult {
|
|
27
|
+
/** 提交状态:true=成功,false=失败 */
|
|
28
|
+
code: boolean;
|
|
29
|
+
/** 交易总数(无论成功与否都会返回) */
|
|
30
|
+
totalTransactions: number;
|
|
31
|
+
/** Bundle哈希(成功时返回) */
|
|
32
|
+
bundleHash?: string;
|
|
33
|
+
/** 交易哈希列表(成功时返回) */
|
|
34
|
+
txHashes?: string[];
|
|
35
|
+
/** 目标区块号(成功时返回) */
|
|
36
|
+
targetBlock?: number;
|
|
37
|
+
/** 交易数量(成功时返回) */
|
|
38
|
+
txCount?: number;
|
|
39
|
+
/** 错误信息(失败时返回) */
|
|
40
|
+
error?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 提交已签名的交易到Merkle(服务器端使用)
|
|
44
|
+
*
|
|
45
|
+
* 这个方法接收前端构建和签名好的交易,直接提交到Merkle服务
|
|
46
|
+
*
|
|
47
|
+
* @param signedTransactions 签名后的交易数组
|
|
48
|
+
* @param config Merkle提交配置(精简版,只需要提交相关参数)
|
|
49
|
+
* @returns Bundle提交结果
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* // 服务器端代码
|
|
54
|
+
* import { submitBundleToMerkle } from 'four-flap-meme-sdk';
|
|
55
|
+
*
|
|
56
|
+
* const result = await submitBundleToMerkle(signedTransactions, {
|
|
57
|
+
* apiKey: process.env.MERKLE_API_KEY,
|
|
58
|
+
* customRpcUrl: process.env.MERKLE_RPC_URL,
|
|
59
|
+
* bundleBlockOffset: 5
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* if (result.code) {
|
|
63
|
+
* } else {
|
|
64
|
+
* console.error('❌ Bundle提交失败:', result.error);
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function submitBundleToMerkle(signedTransactions: string[], config: MerkleSubmitConfig): Promise<SubmitBundleResult>;
|
|
69
|
+
/**
|
|
70
|
+
* 批量提交多个Bundle到Merkle(顺序执行)
|
|
71
|
+
*
|
|
72
|
+
* @param bundles 多个Bundle的签名交易数组
|
|
73
|
+
* @param config Merkle提交配置
|
|
74
|
+
* @returns Bundle提交结果数组
|
|
75
|
+
*/
|
|
76
|
+
export declare function submitMultipleBundles(bundles: string[][], config: MerkleSubmitConfig): Promise<SubmitBundleResult[]>;
|
|
77
|
+
/**
|
|
78
|
+
* 并行提交多个Bundle到Merkle(适用于独立的Bundle)
|
|
79
|
+
*
|
|
80
|
+
* @param bundles 多个Bundle的签名交易数组
|
|
81
|
+
* @param config Merkle提交配置
|
|
82
|
+
* @returns Bundle提交结果数组
|
|
83
|
+
*/
|
|
84
|
+
export declare function submitMultipleBundlesParallel(bundles: string[][], config: MerkleSubmitConfig): Promise<SubmitBundleResult[]>;
|