@otim/utils 0.0.4 → 0.0.6
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/api/index.d.mts +1858 -7
- package/dist/api/index.d.mts.map +1 -0
- package/dist/api/index.d.ts +1857 -6
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1514 -1994
- package/dist/api/index.js.map +1 -7
- package/dist/api/index.mjs +1394 -1962
- package/dist/api/index.mjs.map +1 -7
- package/dist/api-urls-B-GTEiT3.d.mts +49 -0
- package/dist/api-urls-B-GTEiT3.d.mts.map +1 -0
- package/dist/api-urls-Cd20DG4i.js +171 -0
- package/dist/api-urls-Cd20DG4i.js.map +1 -0
- package/dist/api-urls-DJcIKBCy.mjs +135 -0
- package/dist/api-urls-DJcIKBCy.mjs.map +1 -0
- package/dist/api-urls-SKeIQMoZ.d.ts +49 -0
- package/dist/api-urls-SKeIQMoZ.d.ts.map +1 -0
- package/dist/chains/index.d.mts +13568 -16
- package/dist/chains/index.d.mts.map +1 -0
- package/dist/chains/index.d.ts +13567 -15
- package/dist/chains/index.d.ts.map +1 -1
- package/dist/chains/index.js +3615 -424
- package/dist/chains/index.js.map +1 -7
- package/dist/chains/index.mjs +3561 -440
- package/dist/chains/index.mjs.map +1 -7
- package/dist/chunk-kSYXY2_d.js +34 -0
- package/dist/client-factory-7xUSPC9I.mjs +42 -0
- package/dist/client-factory-7xUSPC9I.mjs.map +1 -0
- package/dist/client-factory-C3A4RPdj.d.ts +22 -0
- package/dist/client-factory-C3A4RPdj.d.ts.map +1 -0
- package/dist/client-factory-CTI_Nt35.js +49 -0
- package/dist/client-factory-CTI_Nt35.js.map +1 -0
- package/dist/client-factory-DOL0ZTWy.d.mts +22 -0
- package/dist/client-factory-DOL0ZTWy.d.mts.map +1 -0
- package/dist/constants.d.mts +14 -24
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.d.ts +13 -23
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +31 -46
- package/dist/constants.js.map +1 -7
- package/dist/constants.mjs +22 -26
- package/dist/constants.mjs.map +1 -7
- package/dist/date-CFzrYcjE.js +536 -0
- package/dist/date-CFzrYcjE.js.map +1 -0
- package/dist/date-gBac-Om9.mjs +313 -0
- package/dist/date-gBac-Om9.mjs.map +1 -0
- package/dist/defineProperty-DbMdhrDE.js +49 -0
- package/dist/defineProperty-DzhmunJg.mjs +43 -0
- package/dist/formatters/index.d.mts +1 -2
- package/dist/formatters/index.d.ts +1 -2
- package/dist/formatters/index.js +0 -19
- package/dist/formatters/index.mjs +1 -1
- package/dist/helpers/index.d.mts +562 -19
- package/dist/helpers/index.d.mts.map +1 -0
- package/dist/helpers/index.d.ts +561 -18
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +106 -1344
- package/dist/helpers/index.mjs +3 -1315
- package/dist/helpers-BNiSxjGq.mjs +895 -0
- package/dist/helpers-BNiSxjGq.mjs.map +1 -0
- package/dist/helpers-DoC7Xl12.js +1291 -0
- package/dist/helpers-DoC7Xl12.js.map +1 -0
- package/dist/index-Bv0kUz4w.d.ts +540 -0
- package/dist/index-Bv0kUz4w.d.ts.map +1 -0
- package/dist/index-DartTKk2.d.mts +540 -0
- package/dist/index-DartTKk2.d.mts.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -2
- package/dist/index.mjs +1 -1
- package/dist/instructions/index.d.mts +687 -6
- package/dist/instructions/index.d.mts.map +1 -0
- package/dist/instructions/index.d.ts +686 -5
- package/dist/instructions/index.d.ts.map +1 -1
- package/dist/instructions/index.js +1912 -1091
- package/dist/instructions/index.js.map +1 -7
- package/dist/instructions/index.mjs +1887 -1058
- package/dist/instructions/index.mjs.map +1 -7
- package/dist/payments/index.d.mts +322 -16
- package/dist/payments/index.d.mts.map +1 -0
- package/dist/payments/index.d.ts +321 -15
- package/dist/payments/index.d.ts.map +1 -1
- package/dist/payments/index.js +616 -1258
- package/dist/payments/index.js.map +1 -7
- package/dist/payments/index.mjs +594 -1236
- package/dist/payments/index.mjs.map +1 -7
- package/dist/schemas/index.d.mts +2 -10
- package/dist/schemas/index.d.ts +2 -10
- package/dist/schemas/index.js +350 -393
- package/dist/schemas/index.js.map +1 -7
- package/dist/schemas/index.mjs +283 -371
- package/dist/schemas/index.mjs.map +1 -7
- package/dist/server/index.d.mts +354 -3
- package/dist/server/index.d.mts.map +1 -0
- package/dist/server/index.d.ts +353 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +248 -435
- package/dist/server/index.js.map +1 -7
- package/dist/server/index.mjs +199 -404
- package/dist/server/index.mjs.map +1 -7
- package/dist/server/react.d.mts +16 -0
- package/dist/server/react.d.mts.map +1 -0
- package/dist/server/react.d.ts +16 -0
- package/dist/server/react.d.ts.map +1 -0
- package/dist/server/react.js +30 -0
- package/dist/server/react.js.map +1 -0
- package/dist/server/react.mjs +28 -0
- package/dist/server/react.mjs.map +1 -0
- package/dist/wallet/wagmi/index.d.mts +23 -2
- package/dist/wallet/wagmi/index.d.mts.map +1 -0
- package/dist/wallet/wagmi/index.d.ts +22 -1
- package/dist/wallet/wagmi/index.d.ts.map +1 -1
- package/dist/wallet/wagmi/index.js +86 -417
- package/dist/wallet/wagmi/index.js.map +1 -7
- package/dist/wallet/wagmi/index.mjs +82 -418
- package/dist/wallet/wagmi/index.mjs.map +1 -7
- package/package.json +39 -28
- package/dist/api/api.d.mts +0 -18
- package/dist/api/api.d.ts +0 -18
- package/dist/api/api.d.ts.map +0 -1
- package/dist/api/core/error.d.mts +0 -74
- package/dist/api/core/error.d.ts +0 -74
- package/dist/api/core/error.d.ts.map +0 -1
- package/dist/api/core/index.d.mts +0 -4
- package/dist/api/core/index.d.ts +0 -4
- package/dist/api/core/index.d.ts.map +0 -1
- package/dist/api/core/instance.d.mts +0 -13
- package/dist/api/core/instance.d.ts +0 -13
- package/dist/api/core/instance.d.ts.map +0 -1
- package/dist/api/core/service.d.mts +0 -51
- package/dist/api/core/service.d.ts +0 -51
- package/dist/api/core/service.d.ts.map +0 -1
- package/dist/api/schemas/account.d.mts +0 -44
- package/dist/api/schemas/account.d.ts +0 -44
- package/dist/api/schemas/account.d.ts.map +0 -1
- package/dist/api/schemas/activity.d.mts +0 -277
- package/dist/api/schemas/activity.d.ts +0 -277
- package/dist/api/schemas/activity.d.ts.map +0 -1
- package/dist/api/schemas/auth.d.mts +0 -127
- package/dist/api/schemas/auth.d.ts +0 -127
- package/dist/api/schemas/auth.d.ts.map +0 -1
- package/dist/api/schemas/chain.d.mts +0 -15
- package/dist/api/schemas/chain.d.ts +0 -15
- package/dist/api/schemas/chain.d.ts.map +0 -1
- package/dist/api/schemas/config.d.mts +0 -33
- package/dist/api/schemas/config.d.ts +0 -33
- package/dist/api/schemas/config.d.ts.map +0 -1
- package/dist/api/schemas/contacts.d.mts +0 -27
- package/dist/api/schemas/contacts.d.ts +0 -27
- package/dist/api/schemas/contacts.d.ts.map +0 -1
- package/dist/api/schemas/index.d.mts +0 -12
- package/dist/api/schemas/index.d.ts +0 -12
- package/dist/api/schemas/index.d.ts.map +0 -1
- package/dist/api/schemas/instruction.d.mts +0 -446
- package/dist/api/schemas/instruction.d.ts +0 -446
- package/dist/api/schemas/instruction.d.ts.map +0 -1
- package/dist/api/schemas/integration.d.mts +0 -166
- package/dist/api/schemas/integration.d.ts +0 -166
- package/dist/api/schemas/integration.d.ts.map +0 -1
- package/dist/api/schemas/operating-account.d.mts +0 -11
- package/dist/api/schemas/operating-account.d.ts +0 -11
- package/dist/api/schemas/operating-account.d.ts.map +0 -1
- package/dist/api/schemas/payments.d.mts +0 -234
- package/dist/api/schemas/payments.d.ts +0 -234
- package/dist/api/schemas/payments.d.ts.map +0 -1
- package/dist/api/schemas/transaction.d.mts +0 -37
- package/dist/api/schemas/transaction.d.ts +0 -37
- package/dist/api/schemas/transaction.d.ts.map +0 -1
- package/dist/api/services/account.d.mts +0 -8
- package/dist/api/services/account.d.ts +0 -8
- package/dist/api/services/account.d.ts.map +0 -1
- package/dist/api/services/activity.d.mts +0 -7
- package/dist/api/services/activity.d.ts +0 -7
- package/dist/api/services/activity.d.ts.map +0 -1
- package/dist/api/services/auth.d.mts +0 -12
- package/dist/api/services/auth.d.ts +0 -12
- package/dist/api/services/auth.d.ts.map +0 -1
- package/dist/api/services/base.d.mts +0 -10
- package/dist/api/services/base.d.ts +0 -10
- package/dist/api/services/base.d.ts.map +0 -1
- package/dist/api/services/config.d.mts +0 -10
- package/dist/api/services/config.d.ts +0 -10
- package/dist/api/services/config.d.ts.map +0 -1
- package/dist/api/services/contacts.d.mts +0 -8
- package/dist/api/services/contacts.d.ts +0 -8
- package/dist/api/services/contacts.d.ts.map +0 -1
- package/dist/api/services/developer.d.mts +0 -6
- package/dist/api/services/developer.d.ts +0 -6
- package/dist/api/services/developer.d.ts.map +0 -1
- package/dist/api/services/index.d.mts +0 -13
- package/dist/api/services/index.d.ts +0 -13
- package/dist/api/services/index.d.ts.map +0 -1
- package/dist/api/services/instruction.d.mts +0 -12
- package/dist/api/services/instruction.d.ts +0 -12
- package/dist/api/services/instruction.d.ts.map +0 -1
- package/dist/api/services/integration.d.mts +0 -8
- package/dist/api/services/integration.d.ts +0 -8
- package/dist/api/services/integration.d.ts.map +0 -1
- package/dist/api/services/operating-account.d.mts +0 -8
- package/dist/api/services/operating-account.d.ts +0 -8
- package/dist/api/services/operating-account.d.ts.map +0 -1
- package/dist/api/services/payments.d.mts +0 -14
- package/dist/api/services/payments.d.ts +0 -14
- package/dist/api/services/payments.d.ts.map +0 -1
- package/dist/api/services/transaction.d.mts +0 -8
- package/dist/api/services/transaction.d.ts +0 -8
- package/dist/api/services/transaction.d.ts.map +0 -1
- package/dist/api/services/uniswap-token-list-service.d.mts +0 -66
- package/dist/api/services/uniswap-token-list-service.d.ts +0 -66
- package/dist/api/services/uniswap-token-list-service.d.ts.map +0 -1
- package/dist/api/utils/index.d.mts +0 -2
- package/dist/api/utils/index.d.ts +0 -2
- package/dist/api/utils/index.d.ts.map +0 -1
- package/dist/api/utils/pagination.d.mts +0 -32
- package/dist/api/utils/pagination.d.ts +0 -32
- package/dist/api/utils/pagination.d.ts.map +0 -1
- package/dist/chains/config/all-chains.d.mts +0 -4243
- package/dist/chains/config/all-chains.d.ts +0 -4243
- package/dist/chains/config/all-chains.d.ts.map +0 -1
- package/dist/chains/config/custom-chains.d.mts +0 -49
- package/dist/chains/config/custom-chains.d.ts +0 -49
- package/dist/chains/config/custom-chains.d.ts.map +0 -1
- package/dist/chains/config/mainnet-chains.d.mts +0 -1063
- package/dist/chains/config/mainnet-chains.d.ts +0 -1063
- package/dist/chains/config/mainnet-chains.d.ts.map +0 -1
- package/dist/chains/config/supported-chains.d.mts +0 -2172
- package/dist/chains/config/supported-chains.d.ts +0 -2172
- package/dist/chains/config/supported-chains.d.ts.map +0 -1
- package/dist/chains/config/testnet-chains.d.mts +0 -1110
- package/dist/chains/config/testnet-chains.d.ts +0 -1110
- package/dist/chains/config/testnet-chains.d.ts.map +0 -1
- package/dist/chains/lambda/chain-mapping.d.mts +0 -55
- package/dist/chains/lambda/chain-mapping.d.ts +0 -55
- package/dist/chains/lambda/chain-mapping.d.ts.map +0 -1
- package/dist/chains/lambda/index.d.mts +0 -2
- package/dist/chains/lambda/index.d.ts +0 -2
- package/dist/chains/lambda/index.d.ts.map +0 -1
- package/dist/chains/tokens/chain-tokens.d.mts +0 -6
- package/dist/chains/tokens/chain-tokens.d.ts +0 -6
- package/dist/chains/tokens/chain-tokens.d.ts.map +0 -1
- package/dist/chains/tokens/token-addresses.d.mts +0 -8
- package/dist/chains/tokens/token-addresses.d.ts +0 -8
- package/dist/chains/tokens/token-addresses.d.ts.map +0 -1
- package/dist/chains/tokens/token-metadata.d.mts +0 -5
- package/dist/chains/tokens/token-metadata.d.ts +0 -5
- package/dist/chains/tokens/token-metadata.d.ts.map +0 -1
- package/dist/chains/types.d.mts +0 -23
- package/dist/chains/types.d.ts +0 -23
- package/dist/chains/types.d.ts.map +0 -1
- package/dist/chains/utils/filter-tokens.d.mts +0 -3
- package/dist/chains/utils/filter-tokens.d.ts +0 -3
- package/dist/chains/utils/filter-tokens.d.ts.map +0 -1
- package/dist/chains/utils/stablecoin.d.mts +0 -7
- package/dist/chains/utils/stablecoin.d.ts +0 -7
- package/dist/chains/utils/stablecoin.d.ts.map +0 -1
- package/dist/chains/utils/token-maps.d.mts +0 -10
- package/dist/chains/utils/token-maps.d.ts +0 -10
- package/dist/chains/utils/token-maps.d.ts.map +0 -1
- package/dist/env.d.mts +0 -17
- package/dist/env.d.ts +0 -17
- package/dist/env.d.ts.map +0 -1
- package/dist/formatters/index.d.ts.map +0 -1
- package/dist/formatters/index.js.map +0 -7
- package/dist/formatters/index.mjs.map +0 -7
- package/dist/helpers/address.d.mts +0 -7
- package/dist/helpers/address.d.ts +0 -7
- package/dist/helpers/address.d.ts.map +0 -1
- package/dist/helpers/blockchain.d.mts +0 -41
- package/dist/helpers/blockchain.d.ts +0 -41
- package/dist/helpers/blockchain.d.ts.map +0 -1
- package/dist/helpers/date.d.mts +0 -70
- package/dist/helpers/date.d.ts +0 -70
- package/dist/helpers/date.d.ts.map +0 -1
- package/dist/helpers/datetime.d.mts +0 -57
- package/dist/helpers/datetime.d.ts +0 -57
- package/dist/helpers/datetime.d.ts.map +0 -1
- package/dist/helpers/domain.d.mts +0 -2
- package/dist/helpers/domain.d.ts +0 -2
- package/dist/helpers/domain.d.ts.map +0 -1
- package/dist/helpers/index.js.map +0 -7
- package/dist/helpers/index.mjs.map +0 -7
- package/dist/helpers/intl.d.mts +0 -20
- package/dist/helpers/intl.d.ts +0 -20
- package/dist/helpers/intl.d.ts.map +0 -1
- package/dist/helpers/logger.d.mts +0 -26
- package/dist/helpers/logger.d.ts +0 -26
- package/dist/helpers/logger.d.ts.map +0 -1
- package/dist/helpers/mask-options.d.mts +0 -10
- package/dist/helpers/mask-options.d.ts +0 -10
- package/dist/helpers/mask-options.d.ts.map +0 -1
- package/dist/helpers/num-formatter.d.mts +0 -3
- package/dist/helpers/num-formatter.d.ts +0 -3
- package/dist/helpers/num-formatter.d.ts.map +0 -1
- package/dist/helpers/polling.d.mts +0 -39
- package/dist/helpers/polling.d.ts +0 -39
- package/dist/helpers/polling.d.ts.map +0 -1
- package/dist/helpers/random.d.mts +0 -10
- package/dist/helpers/random.d.ts +0 -10
- package/dist/helpers/random.d.ts.map +0 -1
- package/dist/helpers/sdk-loader.d.mts +0 -25
- package/dist/helpers/sdk-loader.d.ts +0 -25
- package/dist/helpers/sdk-loader.d.ts.map +0 -1
- package/dist/helpers/signatures.d.mts +0 -17
- package/dist/helpers/signatures.d.ts +0 -17
- package/dist/helpers/signatures.d.ts.map +0 -1
- package/dist/helpers/string.d.mts +0 -17
- package/dist/helpers/string.d.ts +0 -17
- package/dist/helpers/string.d.ts.map +0 -1
- package/dist/helpers/types.d.mts +0 -39
- package/dist/helpers/types.d.ts +0 -39
- package/dist/helpers/types.d.ts.map +0 -1
- package/dist/helpers/url.d.mts +0 -11
- package/dist/helpers/url.d.ts +0 -11
- package/dist/helpers/url.d.ts.map +0 -1
- package/dist/helpers/window.d.mts +0 -37
- package/dist/helpers/window.d.ts +0 -37
- package/dist/helpers/window.d.ts.map +0 -1
- package/dist/helpers/zod.d.mts +0 -51
- package/dist/helpers/zod.d.ts +0 -51
- package/dist/helpers/zod.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -7
- package/dist/index.mjs.map +0 -7
- package/dist/instructions/actions/index.d.mts +0 -5
- package/dist/instructions/actions/index.d.ts +0 -5
- package/dist/instructions/actions/index.d.ts.map +0 -1
- package/dist/instructions/actions/refuel/index.d.mts +0 -15
- package/dist/instructions/actions/refuel/index.d.ts +0 -15
- package/dist/instructions/actions/refuel/index.d.ts.map +0 -1
- package/dist/instructions/actions/swap/index.d.mts +0 -19
- package/dist/instructions/actions/swap/index.d.ts +0 -19
- package/dist/instructions/actions/swap/index.d.ts.map +0 -1
- package/dist/instructions/actions/sweep/index.d.mts +0 -16
- package/dist/instructions/actions/sweep/index.d.ts +0 -16
- package/dist/instructions/actions/sweep/index.d.ts.map +0 -1
- package/dist/instructions/actions/transfer/index.d.mts +0 -13
- package/dist/instructions/actions/transfer/index.d.ts +0 -13
- package/dist/instructions/actions/transfer/index.d.ts.map +0 -1
- package/dist/instructions/activate.d.mts +0 -84
- package/dist/instructions/activate.d.ts +0 -84
- package/dist/instructions/activate.d.ts.map +0 -1
- package/dist/instructions/build.d.mts +0 -146
- package/dist/instructions/build.d.ts +0 -146
- package/dist/instructions/build.d.ts.map +0 -1
- package/dist/instructions/constants.d.mts +0 -9
- package/dist/instructions/constants.d.ts +0 -9
- package/dist/instructions/constants.d.ts.map +0 -1
- package/dist/instructions/contracts/artifacts/abi/build-instruction-action-arguments-abi.d.mts +0 -609
- package/dist/instructions/contracts/artifacts/abi/build-instruction-action-arguments-abi.d.ts +0 -609
- package/dist/instructions/contracts/artifacts/abi/build-instruction-action-arguments-abi.d.ts.map +0 -1
- package/dist/instructions/types.d.mts +0 -289
- package/dist/instructions/types.d.ts +0 -289
- package/dist/instructions/types.d.ts.map +0 -1
- package/dist/payments/action-names.d.mts +0 -16
- package/dist/payments/action-names.d.ts +0 -16
- package/dist/payments/action-names.d.ts.map +0 -1
- package/dist/payments/actions/index.d.mts +0 -5
- package/dist/payments/actions/index.d.ts +0 -5
- package/dist/payments/actions/index.d.ts.map +0 -1
- package/dist/payments/actions/sweep-cctp.d.mts +0 -15
- package/dist/payments/actions/sweep-cctp.d.ts +0 -15
- package/dist/payments/actions/sweep-cctp.d.ts.map +0 -1
- package/dist/payments/actions/sweep-erc20.d.mts +0 -12
- package/dist/payments/actions/sweep-erc20.d.ts +0 -12
- package/dist/payments/actions/sweep-erc20.d.ts.map +0 -1
- package/dist/payments/actions/sweep-uniswap-v3.d.mts +0 -17
- package/dist/payments/actions/sweep-uniswap-v3.d.ts +0 -17
- package/dist/payments/actions/sweep-uniswap-v3.d.ts.map +0 -1
- package/dist/payments/actions/sweep.d.mts +0 -12
- package/dist/payments/actions/sweep.d.ts +0 -12
- package/dist/payments/actions/sweep.d.ts.map +0 -1
- package/dist/payments/build.d.mts +0 -28
- package/dist/payments/build.d.ts +0 -28
- package/dist/payments/build.d.ts.map +0 -1
- package/dist/payments/chain-token-config-builder.d.mts +0 -10
- package/dist/payments/chain-token-config-builder.d.ts +0 -10
- package/dist/payments/chain-token-config-builder.d.ts.map +0 -1
- package/dist/payments/comprehensive-payment-request.d.mts +0 -26
- package/dist/payments/comprehensive-payment-request.d.ts +0 -26
- package/dist/payments/comprehensive-payment-request.d.ts.map +0 -1
- package/dist/payments/config/cctp.d.mts +0 -14
- package/dist/payments/config/cctp.d.ts +0 -14
- package/dist/payments/config/cctp.d.ts.map +0 -1
- package/dist/payments/config/index.d.mts +0 -3
- package/dist/payments/config/index.d.ts +0 -3
- package/dist/payments/config/index.d.ts.map +0 -1
- package/dist/payments/config/tokens.d.mts +0 -14
- package/dist/payments/config/tokens.d.ts +0 -14
- package/dist/payments/config/tokens.d.ts.map +0 -1
- package/dist/payments/instruction-registry.d.mts +0 -19
- package/dist/payments/instruction-registry.d.ts +0 -19
- package/dist/payments/instruction-registry.d.ts.map +0 -1
- package/dist/payments/payment-metadata-builder.d.mts +0 -56
- package/dist/payments/payment-metadata-builder.d.ts +0 -56
- package/dist/payments/payment-metadata-builder.d.ts.map +0 -1
- package/dist/payments/payment-metadata.d.mts +0 -15
- package/dist/payments/payment-metadata.d.ts +0 -15
- package/dist/payments/payment-metadata.d.ts.map +0 -1
- package/dist/payments/payment-request-token-resolver.d.mts +0 -25
- package/dist/payments/payment-request-token-resolver.d.ts +0 -25
- package/dist/payments/payment-request-token-resolver.d.ts.map +0 -1
- package/dist/payments/types.d.mts +0 -40
- package/dist/payments/types.d.ts +0 -40
- package/dist/payments/types.d.ts.map +0 -1
- package/dist/payments/validation.d.mts +0 -19
- package/dist/payments/validation.d.ts +0 -19
- package/dist/payments/validation.d.ts.map +0 -1
- package/dist/schemas/account.d.mts +0 -9
- package/dist/schemas/account.d.ts +0 -9
- package/dist/schemas/account.d.ts.map +0 -1
- package/dist/schemas/brand.d.mts +0 -7
- package/dist/schemas/brand.d.ts +0 -7
- package/dist/schemas/brand.d.ts.map +0 -1
- package/dist/schemas/contact.d.mts +0 -18
- package/dist/schemas/contact.d.ts +0 -18
- package/dist/schemas/contact.d.ts.map +0 -1
- package/dist/schemas/index.d.ts.map +0 -1
- package/dist/schemas/instruction.d.mts +0 -248
- package/dist/schemas/instruction.d.ts +0 -248
- package/dist/schemas/instruction.d.ts.map +0 -1
- package/dist/schemas/misc.d.mts +0 -36
- package/dist/schemas/misc.d.ts +0 -36
- package/dist/schemas/misc.d.ts.map +0 -1
- package/dist/schemas/payment.d.mts +0 -64
- package/dist/schemas/payment.d.ts +0 -64
- package/dist/schemas/payment.d.ts.map +0 -1
- package/dist/schemas/token.d.mts +0 -17
- package/dist/schemas/token.d.ts +0 -17
- package/dist/schemas/token.d.ts.map +0 -1
- package/dist/schemas/transaction.d.mts +0 -65
- package/dist/schemas/transaction.d.ts +0 -65
- package/dist/schemas/transaction.d.ts.map +0 -1
- package/dist/schemas/user.d.mts +0 -24
- package/dist/schemas/user.d.ts +0 -24
- package/dist/schemas/user.d.ts.map +0 -1
- package/dist/server/client.d.mts +0 -3
- package/dist/server/client.d.ts +0 -3
- package/dist/server/client.d.ts.map +0 -1
- package/dist/server/routes/account.d.mts +0 -4
- package/dist/server/routes/account.d.ts +0 -4
- package/dist/server/routes/account.d.ts.map +0 -1
- package/dist/server/routes/auth.d.mts +0 -28
- package/dist/server/routes/auth.d.ts +0 -28
- package/dist/server/routes/auth.d.ts.map +0 -1
- package/dist/server/routes/bridge.d.mts +0 -254
- package/dist/server/routes/bridge.d.ts +0 -254
- package/dist/server/routes/bridge.d.ts.map +0 -1
- package/dist/server/routes/config.d.mts +0 -3
- package/dist/server/routes/config.d.ts +0 -3
- package/dist/server/routes/config.d.ts.map +0 -1
- package/dist/server/routes/index.d.mts +0 -8
- package/dist/server/routes/index.d.ts +0 -8
- package/dist/server/routes/index.d.ts.map +0 -1
- package/dist/server/routes/instruction.d.mts +0 -4
- package/dist/server/routes/instruction.d.ts +0 -4
- package/dist/server/routes/instruction.d.ts.map +0 -1
- package/dist/server/routes/integration.d.mts +0 -4
- package/dist/server/routes/integration.d.ts +0 -4
- package/dist/server/routes/integration.d.ts.map +0 -1
- package/dist/server/routes/payments.d.mts +0 -5
- package/dist/server/routes/payments.d.ts +0 -5
- package/dist/server/routes/payments.d.ts.map +0 -1
- package/dist/server/routes/verify.d.mts +0 -3
- package/dist/server/routes/verify.d.ts +0 -3
- package/dist/server/routes/verify.d.ts.map +0 -1
- package/dist/wallet/wagmi/config.d.mts +0 -18
- package/dist/wallet/wagmi/config.d.ts +0 -18
- package/dist/wallet/wagmi/config.d.ts.map +0 -1
|
@@ -0,0 +1,895 @@
|
|
|
1
|
+
import { t as _defineProperty } from "./defineProperty-DzhmunJg.mjs";
|
|
2
|
+
import { T as logger } from "./date-gBac-Om9.mjs";
|
|
3
|
+
import { z as z$1 } from "zod";
|
|
4
|
+
import { hexStringSchema, timeUnitSchema } from "@otim/utils/schemas";
|
|
5
|
+
import { isAddressEqual } from "viem";
|
|
6
|
+
import { maskitoDateOptionsGenerator, maskitoTimeOptionsGenerator } from "@maskito/kit";
|
|
7
|
+
|
|
8
|
+
//#region src/helpers/address.ts
|
|
9
|
+
/**
|
|
10
|
+
* Check if two addresses are equal (case-insensitive)
|
|
11
|
+
* Works with Ethereum addresses and other blockchain addresses
|
|
12
|
+
*/
|
|
13
|
+
const areAddressesEqual = (address1, address2) => {
|
|
14
|
+
if (!address1 || !address2) return false;
|
|
15
|
+
return address1.toLowerCase() === address2.toLowerCase();
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/helpers/activity.ts
|
|
20
|
+
function isTransferActivity(activity) {
|
|
21
|
+
return "transfer" in activity;
|
|
22
|
+
}
|
|
23
|
+
function isSwapActivity(activity) {
|
|
24
|
+
return "swap" in activity;
|
|
25
|
+
}
|
|
26
|
+
function isCctpBurnActivity(activity) {
|
|
27
|
+
return "cctpBurn" in activity;
|
|
28
|
+
}
|
|
29
|
+
function isErc4626DepositActivity(activity) {
|
|
30
|
+
return "erc4626Deposit" in activity;
|
|
31
|
+
}
|
|
32
|
+
function isErc4626WithdrawActivity(activity) {
|
|
33
|
+
return "erc4626Withdraw" in activity;
|
|
34
|
+
}
|
|
35
|
+
function extractBaseActivityDetails(activity) {
|
|
36
|
+
if (isTransferActivity(activity)) return {
|
|
37
|
+
from: activity.transfer.from,
|
|
38
|
+
to: activity.transfer.to,
|
|
39
|
+
amount: activity.transfer.value,
|
|
40
|
+
token: activity.transfer.token
|
|
41
|
+
};
|
|
42
|
+
if (isSwapActivity(activity)) return {
|
|
43
|
+
from: activity.swap.from,
|
|
44
|
+
to: activity.swap.to,
|
|
45
|
+
amount: activity.swap.fromAmount,
|
|
46
|
+
token: activity.swap.fromToken
|
|
47
|
+
};
|
|
48
|
+
if (isCctpBurnActivity(activity)) return {
|
|
49
|
+
from: activity.cctpBurn.from,
|
|
50
|
+
to: activity.cctpBurn.mintRecipient,
|
|
51
|
+
amount: activity.cctpBurn.value,
|
|
52
|
+
token: activity.cctpBurn.token
|
|
53
|
+
};
|
|
54
|
+
if (isErc4626DepositActivity(activity)) return {
|
|
55
|
+
from: activity.erc4626Deposit.from,
|
|
56
|
+
to: activity.erc4626Deposit.vault,
|
|
57
|
+
amount: activity.erc4626Deposit.value,
|
|
58
|
+
token: activity.erc4626Deposit.token
|
|
59
|
+
};
|
|
60
|
+
if (isErc4626WithdrawActivity(activity)) return {
|
|
61
|
+
from: activity.erc4626Withdraw.from,
|
|
62
|
+
to: activity.erc4626Withdraw.to,
|
|
63
|
+
amount: activity.erc4626Withdraw.value,
|
|
64
|
+
token: activity.erc4626Withdraw.token
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
from: "0x0",
|
|
68
|
+
to: "0x0",
|
|
69
|
+
amount: "0",
|
|
70
|
+
token: "0x0"
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Converts a Unix timestamp (seconds) to an ISO date string.
|
|
75
|
+
*
|
|
76
|
+
* @param timestamp - Unix timestamp in seconds
|
|
77
|
+
* @returns ISO date string
|
|
78
|
+
*/
|
|
79
|
+
function timestampToISOString(timestamp) {
|
|
80
|
+
return (/* @__PURE__ */ new Date(timestamp * 1e3)).toISOString();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/helpers/blockchain.ts
|
|
85
|
+
const truncateAddress = (address) => {
|
|
86
|
+
if (!address) return "";
|
|
87
|
+
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Ethereum address regex pattern
|
|
91
|
+
* Matches addresses like 0x1234...abcd (40 hex characters after 0x prefix)
|
|
92
|
+
*/
|
|
93
|
+
const ETHEREUM_ADDRESS_REGEX = /^0x[a-fA-F0-9]{40}$/;
|
|
94
|
+
/**
|
|
95
|
+
* Validates if a string is a valid Ethereum address format
|
|
96
|
+
* @param address - The address string to validate
|
|
97
|
+
* @returns true if the address matches the Ethereum address format
|
|
98
|
+
*/
|
|
99
|
+
const isValidEthereumAddress = (address) => {
|
|
100
|
+
return ETHEREUM_ADDRESS_REGEX.test(address);
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Parses a signature string into its v, r, s components.
|
|
104
|
+
* @param signature - The signature string to parse (must be 0x-prefixed, 132 chars total)
|
|
105
|
+
* @returns VRS object containing v, r, and s values
|
|
106
|
+
*/
|
|
107
|
+
const parseSignatureToVRS = (signature) => {
|
|
108
|
+
if (typeof signature !== "string") throw new Error("Signature must be a string");
|
|
109
|
+
if (!signature.startsWith("0x")) throw new Error("Signature must start with \"0x\"");
|
|
110
|
+
if (signature.length !== 132) throw new Error("Signature must be 65 bytes (130 hex chars) plus \"0x\" = 132 total length");
|
|
111
|
+
const r = signature.slice(2, 66);
|
|
112
|
+
const s = signature.slice(66, 130);
|
|
113
|
+
const vHex = signature.slice(130, 132);
|
|
114
|
+
return {
|
|
115
|
+
v: parseInt(vHex, 16),
|
|
116
|
+
r: `0x${r}`,
|
|
117
|
+
s: `0x${s}`
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
const isValidV = (v) => {
|
|
121
|
+
return v === 0 || v === 1 || v === 27 || v === 28 || v >= 35;
|
|
122
|
+
};
|
|
123
|
+
const normalizeV = (v) => {
|
|
124
|
+
if (!isValidV(v)) return 0;
|
|
125
|
+
const cmp = v <= 1 ? 1 : 0;
|
|
126
|
+
const result = v % 2 === cmp;
|
|
127
|
+
return Number(result) % 2;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Creates an EIP-2098 compact signature from VRS components.
|
|
131
|
+
* @param vrs - The VRS signature components
|
|
132
|
+
* @returns EIP2098Signature object with yParity, r, and s
|
|
133
|
+
*/
|
|
134
|
+
const createEIP2098Signature = (vrs) => {
|
|
135
|
+
const v = vrs.v;
|
|
136
|
+
const r = vrs.r;
|
|
137
|
+
const s = vrs.s;
|
|
138
|
+
return {
|
|
139
|
+
yParity: normalizeV(v),
|
|
140
|
+
r,
|
|
141
|
+
s
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
const getChainRpcUrl = (chainId, chains) => {
|
|
145
|
+
return chains.find((chain) => chain.id === chainId)?.rpcUrls.default;
|
|
146
|
+
};
|
|
147
|
+
const DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
148
|
+
const isNullAddress = (address) => {
|
|
149
|
+
return isAddressEqual(address, DEFAULT_ADDRESS);
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Parses a hex amount string with decimals into a number.
|
|
153
|
+
*
|
|
154
|
+
* @param hexAmount - The hex string (e.g. "0x...")
|
|
155
|
+
* @param decimals - Token decimals
|
|
156
|
+
* @returns The parsed number
|
|
157
|
+
*/
|
|
158
|
+
function parseHexAmount(hexAmount, decimals) {
|
|
159
|
+
try {
|
|
160
|
+
const value = BigInt(hexAmount);
|
|
161
|
+
return Number(value) / 10 ** decimals;
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.warn(`Failed to parse hex amount: ${hexAmount}`, error);
|
|
164
|
+
return 0;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/helpers/datetime.ts
|
|
170
|
+
const timeUnitInputValueSchema = z$1.object({
|
|
171
|
+
unit: timeUnitSchema,
|
|
172
|
+
value: z$1.number().finite(),
|
|
173
|
+
seconds: z$1.number().finite()
|
|
174
|
+
});
|
|
175
|
+
const isTimeUnitInputValue = (value) => {
|
|
176
|
+
if (typeof value !== "object" || value === null) return false;
|
|
177
|
+
const obj = value;
|
|
178
|
+
return "unit" in obj && "value" in obj && "seconds" in obj && typeof obj.unit === "string" && typeof obj.value === "number" && typeof obj.seconds === "number";
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* safely parses a JSON string to TimeUnitInputValue.
|
|
182
|
+
* returns undefined if parsing fails or result is invalid.
|
|
183
|
+
*/
|
|
184
|
+
const parseJsonToTimeUnitValue = (jsonString) => {
|
|
185
|
+
try {
|
|
186
|
+
const parsed = JSON.parse(jsonString);
|
|
187
|
+
return isTimeUnitInputValue(parsed) ? parsed : void 0;
|
|
188
|
+
} catch {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* converts various value formats to TimeUnitInputValue.
|
|
194
|
+
* handles both direct objects and JSON strings from form system.
|
|
195
|
+
*
|
|
196
|
+
* @param value – value from form field (can be object, string, or other)
|
|
197
|
+
* @returns parsed TimeUnitInputValue or undefined if invalid
|
|
198
|
+
*/
|
|
199
|
+
const parseTimeUnitValue = (value) => {
|
|
200
|
+
if (!value) return void 0;
|
|
201
|
+
if (isTimeUnitInputValue(value)) return value;
|
|
202
|
+
if (typeof value === "string") return parseJsonToTimeUnitValue(value);
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* serializes TimeUnitInputValue to JSON string for form compatibility.
|
|
206
|
+
*
|
|
207
|
+
* @param value – TimeUnitInputValue to serialize
|
|
208
|
+
* @returns JSON string representation
|
|
209
|
+
*/
|
|
210
|
+
const serializeTimeUnitValue = (value) => {
|
|
211
|
+
return JSON.stringify(value);
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* validates if a value can be converted to a valid TimeUnitInputValue.
|
|
215
|
+
*
|
|
216
|
+
* @param value – value to validate
|
|
217
|
+
* @returns true if value is valid, false otherwise
|
|
218
|
+
*/
|
|
219
|
+
const isValidTimeUnitValue = (value) => {
|
|
220
|
+
return parseTimeUnitValue(value) !== void 0;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* gets the total seconds from a TimeUnitInputValue or its serialized form.
|
|
224
|
+
*
|
|
225
|
+
* @param value – TimeUnitInputValue or JSON string
|
|
226
|
+
* @returns number of seconds or 0 if invalid
|
|
227
|
+
*/
|
|
228
|
+
const getSecondsFromTimeUnitValue = (value) => {
|
|
229
|
+
return parseTimeUnitValue(value)?.seconds ?? 0;
|
|
230
|
+
};
|
|
231
|
+
const coerceSecondsFromTimeUnitValue = (value) => {
|
|
232
|
+
if (!value) return 0;
|
|
233
|
+
if (typeof value === "object") {
|
|
234
|
+
const seconds = value?.seconds;
|
|
235
|
+
if (typeof seconds === "number" && Number.isFinite(seconds)) return seconds;
|
|
236
|
+
}
|
|
237
|
+
if (typeof value === "string") try {
|
|
238
|
+
const seconds = JSON.parse(value)?.seconds;
|
|
239
|
+
if (typeof seconds === "number" && Number.isFinite(seconds)) return seconds;
|
|
240
|
+
} catch {}
|
|
241
|
+
return 0;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/helpers/domain.ts
|
|
246
|
+
function getBaseDomain(hostname) {
|
|
247
|
+
/**
|
|
248
|
+
* Localhost: Preserve full hostname since WebAuthn allows subdomain RPIDs in
|
|
249
|
+
* development (app.localhost:3000, etc.)
|
|
250
|
+
*/
|
|
251
|
+
if (hostname.includes("localhost")) return hostname;
|
|
252
|
+
const parts = hostname.split(".");
|
|
253
|
+
if (parts.length < 2) return hostname;
|
|
254
|
+
if (parts.length === 2) return hostname;
|
|
255
|
+
const lastTwoParts = parts.slice(-2).join(".");
|
|
256
|
+
if ([
|
|
257
|
+
"co.uk",
|
|
258
|
+
"com.au",
|
|
259
|
+
"co.jp",
|
|
260
|
+
"co.kr",
|
|
261
|
+
"co.za",
|
|
262
|
+
"co.in",
|
|
263
|
+
"com.br",
|
|
264
|
+
"com.mx",
|
|
265
|
+
"com.ar",
|
|
266
|
+
"com.cn",
|
|
267
|
+
"com.tw",
|
|
268
|
+
"org.uk",
|
|
269
|
+
"net.uk",
|
|
270
|
+
"ac.uk",
|
|
271
|
+
"gov.uk"
|
|
272
|
+
].includes(lastTwoParts)) return parts.slice(-3).join(".");
|
|
273
|
+
if ([
|
|
274
|
+
"vercel.app",
|
|
275
|
+
"netlify.app",
|
|
276
|
+
"github.io",
|
|
277
|
+
"gitlab.io"
|
|
278
|
+
].includes(lastTwoParts)) return hostname;
|
|
279
|
+
return parts.slice(-2).join(".");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/helpers/external-account.ts
|
|
284
|
+
/**
|
|
285
|
+
* External account display formatting helpers
|
|
286
|
+
*/
|
|
287
|
+
/**
|
|
288
|
+
* Formats external account information for display
|
|
289
|
+
*
|
|
290
|
+
* @param externalAccount - External account object with optional properties
|
|
291
|
+
* @returns Formatted display name for the external account
|
|
292
|
+
*/
|
|
293
|
+
function formatExternalAccountName(externalAccount) {
|
|
294
|
+
const { accountName, bankName, last_4 } = externalAccount;
|
|
295
|
+
if (accountName) {
|
|
296
|
+
const parts = [];
|
|
297
|
+
if (bankName) parts.push(bankName);
|
|
298
|
+
parts.push(accountName);
|
|
299
|
+
let name = parts.join(" · ");
|
|
300
|
+
if (last_4) name += ` (...${last_4})`;
|
|
301
|
+
return name;
|
|
302
|
+
}
|
|
303
|
+
if (bankName) {
|
|
304
|
+
let name = bankName;
|
|
305
|
+
if (last_4) name += ` (...${last_4})`;
|
|
306
|
+
return name;
|
|
307
|
+
}
|
|
308
|
+
if (last_4) return `Bank Account (...${last_4})`;
|
|
309
|
+
return "Bank Account";
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/helpers/intl.ts
|
|
314
|
+
const locales = ["en", "es"];
|
|
315
|
+
/**
|
|
316
|
+
* Floors a number to a specific number of decimal places.
|
|
317
|
+
* This ensures values are always rounded down, never up.
|
|
318
|
+
*
|
|
319
|
+
* @param value - The number to floor
|
|
320
|
+
* @param decimals - Number of decimal places to keep
|
|
321
|
+
* @returns The floored number
|
|
322
|
+
*/
|
|
323
|
+
const floorToDecimals = (value, decimals) => {
|
|
324
|
+
const multiplier = Math.pow(10, decimals);
|
|
325
|
+
return Math.floor(value * multiplier) / multiplier;
|
|
326
|
+
};
|
|
327
|
+
const i18n = {
|
|
328
|
+
defaultLocale: "en",
|
|
329
|
+
locales: [...locales]
|
|
330
|
+
};
|
|
331
|
+
const localeSchema = z$1.enum(locales);
|
|
332
|
+
const formattedNumber = (num) => {
|
|
333
|
+
if (!Number.isFinite(num)) return "0.00";
|
|
334
|
+
return new Intl.NumberFormat("en-US", {
|
|
335
|
+
minimumFractionDigits: 2,
|
|
336
|
+
maximumFractionDigits: 2
|
|
337
|
+
}).format(num);
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* Formats a token or asset amount with appropriate decimal places
|
|
341
|
+
* based on the magnitude of the value.
|
|
342
|
+
* Values are floored (rounded down) to avoid showing inflated amounts.
|
|
343
|
+
*
|
|
344
|
+
* @param amount - The amount to format
|
|
345
|
+
* @param decimals - Optional maximum decimal places
|
|
346
|
+
*/
|
|
347
|
+
const formatAmount = (amount, decimals) => {
|
|
348
|
+
if (amount === 0) return "0";
|
|
349
|
+
if (amount < 1e-6) return amount.toExponential(2);
|
|
350
|
+
if (amount < 1) return floorToDecimals(amount, decimals ?? 6).toString();
|
|
351
|
+
if (amount < 1e3) return floorToDecimals(amount, decimals ?? 2).toString();
|
|
352
|
+
const decimalPlaces = decimals ?? 2;
|
|
353
|
+
return floorToDecimals(amount, decimalPlaces).toLocaleString("en-US", {
|
|
354
|
+
minimumFractionDigits: 2,
|
|
355
|
+
maximumFractionDigits: decimalPlaces
|
|
356
|
+
});
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* Formats a number as USD currency with proper locale formatting.
|
|
360
|
+
* Values are floored (rounded down) to avoid showing inflated amounts.
|
|
361
|
+
*
|
|
362
|
+
* @param amount – The amount to format
|
|
363
|
+
* @param options – Optional Intl.NumberFormatOptions to customize formatting
|
|
364
|
+
* @returns – Formatted currency string (e.g., "$1,234.56")
|
|
365
|
+
*/
|
|
366
|
+
const formatCurrency = (amount, options) => {
|
|
367
|
+
const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
|
|
368
|
+
if (isNaN(numAmount)) return "$0.00";
|
|
369
|
+
const floored = floorToDecimals(numAmount, 2);
|
|
370
|
+
return new Intl.NumberFormat("en-US", {
|
|
371
|
+
style: "currency",
|
|
372
|
+
currency: "USD",
|
|
373
|
+
minimumFractionDigits: 2,
|
|
374
|
+
maximumFractionDigits: 2,
|
|
375
|
+
...options
|
|
376
|
+
}).format(floored);
|
|
377
|
+
};
|
|
378
|
+
/**
|
|
379
|
+
* Formats a number as USD currency with smart decimal places based on magnitude.
|
|
380
|
+
* Shows more precision for small values to avoid displaying "$0.00" for meaningful amounts.
|
|
381
|
+
* Values are floored (rounded down) to avoid showing inflated amounts.
|
|
382
|
+
*
|
|
383
|
+
* @param amount – The amount to format
|
|
384
|
+
* @returns – Formatted currency string with adaptive decimals
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* formatSmartCurrency(0) // "$0"
|
|
388
|
+
* formatSmartCurrency(0.0000001) // "<$0.000001"
|
|
389
|
+
* formatSmartCurrency(0.003456) // "$0.003456"
|
|
390
|
+
* formatSmartCurrency(0.5678) // "$0.5678"
|
|
391
|
+
* formatSmartCurrency(1234.56) // "$1,234.56"
|
|
392
|
+
*/
|
|
393
|
+
const formatSmartCurrency = (amount) => {
|
|
394
|
+
const num = typeof amount === "string" ? parseFloat(amount) : amount;
|
|
395
|
+
if (isNaN(num) || num === 0) return "$0";
|
|
396
|
+
if (num < 1e-6) return "<$0.000001";
|
|
397
|
+
if (num < .01) return `$${floorToDecimals(num, 6)}`;
|
|
398
|
+
if (num < 1) return `$${floorToDecimals(num, 4)}`;
|
|
399
|
+
const floored = floorToDecimals(num, 2);
|
|
400
|
+
return new Intl.NumberFormat("en-US", {
|
|
401
|
+
style: "currency",
|
|
402
|
+
currency: "USD",
|
|
403
|
+
minimumFractionDigits: 2,
|
|
404
|
+
maximumFractionDigits: 2
|
|
405
|
+
}).format(floored);
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* Alias for formatCurrency specifically for USD
|
|
409
|
+
*/
|
|
410
|
+
const formatUsd = formatCurrency;
|
|
411
|
+
/**
|
|
412
|
+
* Formats a USD amount without the currency symbol.
|
|
413
|
+
* Values are floored (rounded down) to avoid showing inflated amounts.
|
|
414
|
+
*
|
|
415
|
+
* @param amount – The amount to format
|
|
416
|
+
* @param options – Optional Intl.NumberFormatOptions to customize formatting
|
|
417
|
+
* @returns – Formatted amount string (e.g., "1,234.56")
|
|
418
|
+
*/
|
|
419
|
+
const formatUsdAmount = (amount, options) => {
|
|
420
|
+
const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
|
|
421
|
+
if (isNaN(numAmount)) return "0.00";
|
|
422
|
+
return floorToDecimals(numAmount, 2).toLocaleString("en-US", {
|
|
423
|
+
minimumFractionDigits: 2,
|
|
424
|
+
maximumFractionDigits: 2,
|
|
425
|
+
...options
|
|
426
|
+
});
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region src/helpers/mask-options.ts
|
|
431
|
+
const SHORT_FORM_POSTAL_MASK = [
|
|
432
|
+
/\d/,
|
|
433
|
+
/\d/,
|
|
434
|
+
/\d/,
|
|
435
|
+
/\d/,
|
|
436
|
+
/\d/
|
|
437
|
+
];
|
|
438
|
+
const LONG_FORM_POSTAL_MASK = [
|
|
439
|
+
/\d/,
|
|
440
|
+
/\d/,
|
|
441
|
+
/\d/,
|
|
442
|
+
/\d/,
|
|
443
|
+
/\d/,
|
|
444
|
+
"-",
|
|
445
|
+
/\d/,
|
|
446
|
+
/\d/,
|
|
447
|
+
/\d/,
|
|
448
|
+
/\d/
|
|
449
|
+
];
|
|
450
|
+
const postalCodeMaskOptions = { mask: (state) => {
|
|
451
|
+
return state.value.length > 5 ? LONG_FORM_POSTAL_MASK : SHORT_FORM_POSTAL_MASK;
|
|
452
|
+
} };
|
|
453
|
+
const dateMaskOptions = maskitoDateOptionsGenerator({
|
|
454
|
+
mode: "mm/dd/yyyy",
|
|
455
|
+
separator: "/"
|
|
456
|
+
});
|
|
457
|
+
const timeOptions = maskitoTimeOptionsGenerator({ mode: "HH:MM:SS AA" });
|
|
458
|
+
const timeOptionsWithoutMeridiem = maskitoTimeOptionsGenerator({ mode: "HH:MM:SS" });
|
|
459
|
+
const timeMaskOptionsHHMM = maskitoTimeOptionsGenerator({ mode: "HH:MM" });
|
|
460
|
+
const formatUUID = (value) => {
|
|
461
|
+
if (!value) return "";
|
|
462
|
+
const limitedHex = value.replace(/[^0-9a-f-]/gi, "").replace(/-/g, "").slice(0, 32);
|
|
463
|
+
if (limitedHex.length === 32) return [
|
|
464
|
+
limitedHex.slice(0, 8),
|
|
465
|
+
limitedHex.slice(8, 12),
|
|
466
|
+
limitedHex.slice(12, 16),
|
|
467
|
+
limitedHex.slice(16, 20),
|
|
468
|
+
limitedHex.slice(20, 32)
|
|
469
|
+
].join("-");
|
|
470
|
+
let formatted = "";
|
|
471
|
+
let index = 0;
|
|
472
|
+
if (index < limitedHex.length) {
|
|
473
|
+
const group1 = limitedHex.slice(index, Math.min(index + 8, limitedHex.length));
|
|
474
|
+
formatted += group1;
|
|
475
|
+
index += 8;
|
|
476
|
+
if (index <= limitedHex.length && group1.length === 8) formatted += "-";
|
|
477
|
+
}
|
|
478
|
+
if (index < limitedHex.length) {
|
|
479
|
+
const group2 = limitedHex.slice(index, Math.min(index + 4, limitedHex.length));
|
|
480
|
+
formatted += group2;
|
|
481
|
+
index += 4;
|
|
482
|
+
if (index <= limitedHex.length && group2.length === 4) formatted += "-";
|
|
483
|
+
}
|
|
484
|
+
if (index < limitedHex.length) {
|
|
485
|
+
const group3 = limitedHex.slice(index, Math.min(index + 4, limitedHex.length));
|
|
486
|
+
formatted += group3;
|
|
487
|
+
index += 4;
|
|
488
|
+
if (index <= limitedHex.length && group3.length === 4) formatted += "-";
|
|
489
|
+
}
|
|
490
|
+
if (index < limitedHex.length) {
|
|
491
|
+
const group4 = limitedHex.slice(index, Math.min(index + 4, limitedHex.length));
|
|
492
|
+
formatted += group4;
|
|
493
|
+
index += 4;
|
|
494
|
+
if (index <= limitedHex.length && group4.length === 4) formatted += "-";
|
|
495
|
+
}
|
|
496
|
+
if (index < limitedHex.length) formatted += limitedHex.slice(index, Math.min(index + 12, limitedHex.length));
|
|
497
|
+
return formatted;
|
|
498
|
+
};
|
|
499
|
+
const uuidMaskOptions = { mask: /^[0-9a-f-]*$/i };
|
|
500
|
+
const usdCurrencyMaskOptions = {
|
|
501
|
+
mask: /^[0-9., $]*$/,
|
|
502
|
+
postprocessors: [(state) => {
|
|
503
|
+
const selectionEnd = state.selection?.[1] ?? state.value.length;
|
|
504
|
+
const numeric = state.value.replace(/[^0-9]/g, "");
|
|
505
|
+
if (numeric.length === 0) return {
|
|
506
|
+
...state,
|
|
507
|
+
value: "",
|
|
508
|
+
selection: [0, 0]
|
|
509
|
+
};
|
|
510
|
+
const clamped = numeric.slice(0, 11);
|
|
511
|
+
const formatted = formatCurrency(Number(clamped) / 100);
|
|
512
|
+
const nextCaret = Math.min(formatted.length, selectionEnd + (formatted.length - state.value.length));
|
|
513
|
+
return {
|
|
514
|
+
...state,
|
|
515
|
+
value: formatted,
|
|
516
|
+
selection: [nextCaret, nextCaret]
|
|
517
|
+
};
|
|
518
|
+
}]
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region src/helpers/num-formatter.ts
|
|
523
|
+
const numFormatter = (num, round) => {
|
|
524
|
+
if (num >= 1e3 && num < 1e6) return `${(num / 1e3).toFixed(typeof round === "number" ? round : num % 1e3 === 0 ? 0 : 1)}K`;
|
|
525
|
+
if (num >= 1e6 && num < 1e9) return `${(num / 1e6).toFixed(typeof round === "number" ? round : num % 1e6 === 0 ? 0 : 2)}M`;
|
|
526
|
+
if (num > 1e9) return `${(num / 1e9).toFixed(typeof round === "number" ? round : num % 1e9 === 0 ? 0 : 2)}B`;
|
|
527
|
+
return Number(Number(num).toFixed(typeof round === "number" ? round : num * 100 % 100 === 0 ? 0 : 2));
|
|
528
|
+
};
|
|
529
|
+
const formatNumberAsUSStandard = (num) => {
|
|
530
|
+
return num.toLocaleString("en-US", { maximumSignificantDigits: 3 });
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
//#endregion
|
|
534
|
+
//#region src/helpers/window.ts
|
|
535
|
+
const isClient = () => typeof globalThis !== "undefined" && "window" in globalThis;
|
|
536
|
+
const DEFAULT_EMERGENT_WINDOW_CONFIG = {
|
|
537
|
+
width: 480,
|
|
538
|
+
height: 720,
|
|
539
|
+
name: "emergent_window"
|
|
540
|
+
};
|
|
541
|
+
/**
|
|
542
|
+
* Opens an emergent window centered on the screen.
|
|
543
|
+
* Used for authentication flows and external integrations.
|
|
544
|
+
*
|
|
545
|
+
* @param url - The URL to open in the emergent window
|
|
546
|
+
* @param config - Optional configuration for the window
|
|
547
|
+
* @returns The opened window or null if it failed
|
|
548
|
+
*/
|
|
549
|
+
function openCenteredEmergentWindow(url, config = {}) {
|
|
550
|
+
if (!isClient()) return null;
|
|
551
|
+
const { width, height, name } = {
|
|
552
|
+
...DEFAULT_EMERGENT_WINDOW_CONFIG,
|
|
553
|
+
...config
|
|
554
|
+
};
|
|
555
|
+
const screenLeft = window.screenLeft ?? window.screenX ?? 0;
|
|
556
|
+
const screenTop = window.screenTop ?? window.screenY ?? 0;
|
|
557
|
+
const viewportWidth = window.innerWidth || document.documentElement.clientWidth || screen.width;
|
|
558
|
+
const viewportHeight = window.innerHeight || document.documentElement.clientHeight || screen.height;
|
|
559
|
+
const left = Math.max(0, screenLeft + (viewportWidth - width) / 2);
|
|
560
|
+
const top = Math.max(0, screenTop + (viewportHeight - height) / 2);
|
|
561
|
+
const features = [
|
|
562
|
+
"noopener",
|
|
563
|
+
"noreferrer",
|
|
564
|
+
`width=${width}`,
|
|
565
|
+
`height=${height}`,
|
|
566
|
+
`left=${left}`,
|
|
567
|
+
`top=${top}`,
|
|
568
|
+
"menubar=no",
|
|
569
|
+
"toolbar=no",
|
|
570
|
+
"location=no",
|
|
571
|
+
"status=no",
|
|
572
|
+
"scrollbars=yes"
|
|
573
|
+
].join(",");
|
|
574
|
+
const emergentWindow = window.open(url, name, features);
|
|
575
|
+
try {
|
|
576
|
+
emergentWindow?.focus();
|
|
577
|
+
} catch (error) {
|
|
578
|
+
logger.logError(error, { context: openCenteredEmergentWindow.name });
|
|
579
|
+
}
|
|
580
|
+
return emergentWindow ?? null;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Closes an emergent window safely
|
|
584
|
+
*
|
|
585
|
+
* @param emergentWindow - The emergent window to close
|
|
586
|
+
*/
|
|
587
|
+
function closeEmergentWindow(emergentWindow) {
|
|
588
|
+
if (!emergentWindow) return;
|
|
589
|
+
try {
|
|
590
|
+
emergentWindow.close();
|
|
591
|
+
} catch (error) {
|
|
592
|
+
logger.logError(error, { context: closeEmergentWindow.name });
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function focusMainWindow() {
|
|
596
|
+
if (!isClient()) return;
|
|
597
|
+
try {
|
|
598
|
+
window.focus();
|
|
599
|
+
} catch (error) {
|
|
600
|
+
logger.logError(error, { context: focusMainWindow.name });
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Performs a client-side redirect to the specified path
|
|
605
|
+
*
|
|
606
|
+
* @param path - The path to redirect to
|
|
607
|
+
* @param fallbackPath - Optional fallback path if the main path is empty
|
|
608
|
+
*/
|
|
609
|
+
function performRedirect(path, fallbackPath = "/") {
|
|
610
|
+
if (!isClient()) return;
|
|
611
|
+
const redirectPath = path || fallbackPath;
|
|
612
|
+
window.location.href = redirectPath;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
//#endregion
|
|
616
|
+
//#region src/helpers/polling.ts
|
|
617
|
+
const DEFAULT_POLLING_CONFIG = {
|
|
618
|
+
intervalMs: 1e3,
|
|
619
|
+
onComplete: () => {}
|
|
620
|
+
};
|
|
621
|
+
/**
|
|
622
|
+
* Manages polling for emergent window completion status.
|
|
623
|
+
* Generic utility that can be used for any async polling scenario.
|
|
624
|
+
* Follows Single Responsibility Principle - only handles polling logic.
|
|
625
|
+
*/
|
|
626
|
+
var PollingManager = class {
|
|
627
|
+
constructor(config = {}) {
|
|
628
|
+
_defineProperty(this, "emergentWindow", null);
|
|
629
|
+
_defineProperty(this, "pollIntervalId", null);
|
|
630
|
+
_defineProperty(this, "config", void 0);
|
|
631
|
+
this.config = {
|
|
632
|
+
...DEFAULT_POLLING_CONFIG,
|
|
633
|
+
...config
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Starts polling for the given check function
|
|
638
|
+
*
|
|
639
|
+
* @param emergentWindow - The emergent window to monitor (optional)
|
|
640
|
+
* @param checkFn - Function that returns true when polling should stop
|
|
641
|
+
*/
|
|
642
|
+
start(emergentWindow, checkFn) {
|
|
643
|
+
this.emergentWindow = emergentWindow;
|
|
644
|
+
this.stop();
|
|
645
|
+
this.pollIntervalId = window.setInterval(() => {
|
|
646
|
+
(async () => {
|
|
647
|
+
try {
|
|
648
|
+
if (await checkFn()) {
|
|
649
|
+
this.finalize();
|
|
650
|
+
this.config.onComplete();
|
|
651
|
+
}
|
|
652
|
+
} catch (error) {
|
|
653
|
+
logger.logError(error, { context: this.start.name });
|
|
654
|
+
}
|
|
655
|
+
})();
|
|
656
|
+
}, this.config.intervalMs);
|
|
657
|
+
}
|
|
658
|
+
stop() {
|
|
659
|
+
if (this.pollIntervalId !== null) {
|
|
660
|
+
clearInterval(this.pollIntervalId);
|
|
661
|
+
this.pollIntervalId = null;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Finalizes polling by closing emergent window, stopping interval, and returning focus
|
|
666
|
+
*/
|
|
667
|
+
finalize() {
|
|
668
|
+
closeEmergentWindow(this.emergentWindow);
|
|
669
|
+
this.emergentWindow = null;
|
|
670
|
+
this.stop();
|
|
671
|
+
focusMainWindow();
|
|
672
|
+
}
|
|
673
|
+
dispose() {
|
|
674
|
+
this.finalize();
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
//#endregion
|
|
679
|
+
//#region src/helpers/random.ts
|
|
680
|
+
const randomNumber = (opts) => {
|
|
681
|
+
const { value, min, max } = opts;
|
|
682
|
+
let hash = 0;
|
|
683
|
+
for (let i = 0; i < value.length; i++) {
|
|
684
|
+
hash = (hash << 5) - hash + value.charCodeAt(i);
|
|
685
|
+
hash |= 0;
|
|
686
|
+
}
|
|
687
|
+
const normalizedHash = Math.abs(hash);
|
|
688
|
+
return Math.floor(normalizedHash % (max - min + 1)) + min;
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
//#endregion
|
|
692
|
+
//#region src/helpers/sdk-loader.ts
|
|
693
|
+
/**
|
|
694
|
+
* Default timeout for SDK loading (10 seconds)
|
|
695
|
+
*/
|
|
696
|
+
const DEFAULT_SDK_TIMEOUT = 1e4;
|
|
697
|
+
/**
|
|
698
|
+
* Generic SDK loader utility for loading third-party scripts
|
|
699
|
+
* Follows Single Responsibility Principle - only handles script loading
|
|
700
|
+
*
|
|
701
|
+
* @param config - SDK loader configuration
|
|
702
|
+
* @returns Promise that resolves when SDK is loaded
|
|
703
|
+
* @throws Error if SDK fails to load or times out
|
|
704
|
+
*/
|
|
705
|
+
async function loadExternalSdk(config) {
|
|
706
|
+
if (typeof window === "undefined") throw new Error(`${config.name} SDK can only be loaded in the browser`);
|
|
707
|
+
const timeout = config.timeout ?? DEFAULT_SDK_TIMEOUT;
|
|
708
|
+
return new Promise((resolve, reject) => {
|
|
709
|
+
const timeoutId = setTimeout(() => {
|
|
710
|
+
reject(/* @__PURE__ */ new Error(`${config.name} SDK loading timed out after ${timeout}ms`));
|
|
711
|
+
}, timeout);
|
|
712
|
+
const script = document.createElement("script");
|
|
713
|
+
script.src = config.src;
|
|
714
|
+
script.async = true;
|
|
715
|
+
script.onload = () => {
|
|
716
|
+
clearTimeout(timeoutId);
|
|
717
|
+
resolve();
|
|
718
|
+
};
|
|
719
|
+
script.onerror = () => {
|
|
720
|
+
clearTimeout(timeoutId);
|
|
721
|
+
reject(/* @__PURE__ */ new Error(`Failed to load ${config.name} SDK from ${config.src}`));
|
|
722
|
+
};
|
|
723
|
+
document.body.appendChild(script);
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Checks if a script with the given src is already loaded
|
|
728
|
+
*
|
|
729
|
+
* @param src - Script source URL to check
|
|
730
|
+
* @returns true if script is already in the DOM
|
|
731
|
+
*/
|
|
732
|
+
function isScriptLoaded(src) {
|
|
733
|
+
if (typeof window === "undefined") return false;
|
|
734
|
+
const scripts = document.getElementsByTagName("script");
|
|
735
|
+
for (let i = 0; i < scripts.length; i++) if (scripts[i]?.src === src) return true;
|
|
736
|
+
return false;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
//#endregion
|
|
740
|
+
//#region src/helpers/signatures.ts
|
|
741
|
+
/**
|
|
742
|
+
* Converts a standard signature to EIP-2098 format
|
|
743
|
+
*/
|
|
744
|
+
const formatSignatureToEIP2098 = (signature) => {
|
|
745
|
+
const ensureHexPrefix = (value) => value.startsWith("0x") ? value : `0x${value}`;
|
|
746
|
+
const vNum = Number.parseInt(signature.v, 16);
|
|
747
|
+
return {
|
|
748
|
+
yParity: (() => {
|
|
749
|
+
if (Number.isNaN(vNum)) return 0;
|
|
750
|
+
if (vNum <= 1) return vNum;
|
|
751
|
+
return vNum % 2 === 0 ? 1 : 0;
|
|
752
|
+
})(),
|
|
753
|
+
r: ensureHexPrefix(signature.r),
|
|
754
|
+
s: ensureHexPrefix(signature.s)
|
|
755
|
+
};
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
//#endregion
|
|
759
|
+
//#region src/helpers/string.ts
|
|
760
|
+
/**
|
|
761
|
+
* Capitalizes the first letter of a string
|
|
762
|
+
*
|
|
763
|
+
* @param str – The string to capitalize
|
|
764
|
+
* @returns The string with first letter capitalized, or undefined if input is
|
|
765
|
+
* nullish
|
|
766
|
+
*/
|
|
767
|
+
const capitalize = (str) => {
|
|
768
|
+
if (!str) return str;
|
|
769
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
770
|
+
};
|
|
771
|
+
/**
|
|
772
|
+
* Converts a string to title case (capitalizes first letter, lowercase rest)
|
|
773
|
+
*
|
|
774
|
+
* @param str – The string to convert
|
|
775
|
+
* @returns The string in title case, or undefined if input is nullish
|
|
776
|
+
*/
|
|
777
|
+
const toTitleCase = (str) => {
|
|
778
|
+
if (!str) return str;
|
|
779
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
//#endregion
|
|
783
|
+
//#region src/helpers/url.ts
|
|
784
|
+
/**
|
|
785
|
+
* Builds a query string from a params object, skipping undefined/null values.
|
|
786
|
+
* Encodes using encodeURIComponent. Returns empty string if no params.
|
|
787
|
+
*/
|
|
788
|
+
function buildQueryString(params) {
|
|
789
|
+
const usp = new URLSearchParams();
|
|
790
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
791
|
+
if (value === void 0 || value === null) return;
|
|
792
|
+
usp.set(key, String(value));
|
|
793
|
+
});
|
|
794
|
+
const qs = usp.toString();
|
|
795
|
+
return qs ? `?${qs}` : "";
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Build a URL by combining a base path with optional query params.
|
|
799
|
+
*/
|
|
800
|
+
function buildUrl(path, params) {
|
|
801
|
+
return `${path}${params ? buildQueryString(params) : ""}`;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
//#endregion
|
|
805
|
+
//#region src/helpers/zod.ts
|
|
806
|
+
const composeValidators = (validators) => {
|
|
807
|
+
return (data, ctx) => {
|
|
808
|
+
for (const validator of validators) validator(data, ctx);
|
|
809
|
+
};
|
|
810
|
+
};
|
|
811
|
+
const secondsToHumanReadable = (seconds) => {
|
|
812
|
+
if (seconds >= 3600) {
|
|
813
|
+
const hours = seconds / 3600;
|
|
814
|
+
const roundedHours = Math.round(hours * 10) / 10;
|
|
815
|
+
return roundedHours === 1 ? "1 hour" : `${roundedHours} hours`;
|
|
816
|
+
} else if (seconds >= 60) {
|
|
817
|
+
const minutes = seconds / 60;
|
|
818
|
+
const roundedMinutes = Math.round(minutes * 10) / 10;
|
|
819
|
+
return roundedMinutes === 1 ? "1 minute" : `${roundedMinutes} minutes`;
|
|
820
|
+
} else return seconds === 1 ? "1 second" : `${seconds} seconds`;
|
|
821
|
+
};
|
|
822
|
+
/**
|
|
823
|
+
* creates a time unit validator for fields stored as JSON strings.
|
|
824
|
+
* validates both the JSON format and the minimum seconds requirement.
|
|
825
|
+
*
|
|
826
|
+
* @param fieldName – the name of the field for error messages
|
|
827
|
+
* @param options – configuration options
|
|
828
|
+
* @param options.minSeconds – minimum seconds required (default: 60)
|
|
829
|
+
* @param options.allowZero – whether to allow 0 seconds for "None" option (default: false)
|
|
830
|
+
* @param options.useHumanReadable – whether to use human-readable time in error messages (default: true)
|
|
831
|
+
*/
|
|
832
|
+
const createTimeUnitValidator = (fieldName, options = {}) => {
|
|
833
|
+
const { minSeconds = 60, allowZero = false, useHumanReadable = true } = options;
|
|
834
|
+
return z$1.string().optional().refine((value) => {
|
|
835
|
+
if (!value) return true;
|
|
836
|
+
const parsed = parseTimeUnitValue(value);
|
|
837
|
+
if (!parsed) return false;
|
|
838
|
+
const seconds = getSecondsFromTimeUnitValue(parsed);
|
|
839
|
+
return allowZero ? seconds >= 0 : seconds >= minSeconds;
|
|
840
|
+
}, { message: useHumanReadable ? `${fieldName} must be at least ${secondsToHumanReadable(minSeconds)}` : `${fieldName} must be at least ${minSeconds} seconds` });
|
|
841
|
+
};
|
|
842
|
+
/**
|
|
843
|
+
* Parse the input values using the provided schema. If the input values are
|
|
844
|
+
* invalid, throw a ResolverError.
|
|
845
|
+
* @param values - The input values to parse.
|
|
846
|
+
* @param schema - The schema to use to parse the input values.
|
|
847
|
+
* @param error - The error code to use if the input values are invalid.
|
|
848
|
+
* @returns The parsed input values.
|
|
849
|
+
* @throws ResolverError if the input values are invalid.
|
|
850
|
+
*/
|
|
851
|
+
const parseSchema = (values, schema) => {
|
|
852
|
+
const inputValues = schema.safeParse(values);
|
|
853
|
+
if (!inputValues.success) throw new Error(`parseSchema: invalid input values ${JSON.stringify(inputValues.error)}`);
|
|
854
|
+
return inputValues.data;
|
|
855
|
+
};
|
|
856
|
+
/**
|
|
857
|
+
* Creates a permissive decimal string schema that allows empty strings.
|
|
858
|
+
* Converts undefined/null values to empty strings, preventing "expected string, received undefined" errors.
|
|
859
|
+
* Useful for form fields where validation happens in a refine step.
|
|
860
|
+
*/
|
|
861
|
+
const formDecimalStringSchema = () => z$1.preprocess((val) => {
|
|
862
|
+
if (val === void 0 || val === null) return "";
|
|
863
|
+
if (typeof val === "string" || typeof val === "number") return String(val);
|
|
864
|
+
return "";
|
|
865
|
+
}, z$1.string());
|
|
866
|
+
/**
|
|
867
|
+
* Creates a hex string schema with preprocessing that defaults to DEFAULT_ADDRESS.
|
|
868
|
+
* Converts undefined/null/empty values to DEFAULT_ADDRESS before validation.
|
|
869
|
+
* Useful for form fields that expect hex addresses.
|
|
870
|
+
*/
|
|
871
|
+
const formHexStringSchema = () => z$1.preprocess((val) => val === void 0 || val === null || val === "" ? DEFAULT_ADDRESS : val, hexStringSchema);
|
|
872
|
+
/**
|
|
873
|
+
* Checks if an error message is an internal Zod error that shouldn't be shown to users.
|
|
874
|
+
*/
|
|
875
|
+
const isInternalZodError = (error) => {
|
|
876
|
+
return error.includes("expected string, received") || error.includes("Invalid input") || error.includes("Expected string");
|
|
877
|
+
};
|
|
878
|
+
/**
|
|
879
|
+
* Filters out Zod internal errors that shouldn't be shown to users.
|
|
880
|
+
* Only returns user-friendly validation messages.
|
|
881
|
+
*
|
|
882
|
+
* @param errors - Array of error messages from Zod validation, or a single error string
|
|
883
|
+
* @param fieldValue - The field value being validated
|
|
884
|
+
* @returns User-friendly error message or undefined
|
|
885
|
+
*/
|
|
886
|
+
const getDisplayableZodError = (errors, fieldValue) => {
|
|
887
|
+
if (!errors || Array.isArray(errors) && errors.length === 0) return void 0;
|
|
888
|
+
if (!(typeof fieldValue === "string" ? fieldValue.trim() : "")) return void 0;
|
|
889
|
+
const filteredErrors = (Array.isArray(errors) ? errors : [errors]).filter((error) => !isInternalZodError(error));
|
|
890
|
+
return filteredErrors.length > 0 ? filteredErrors.join(", ") : void 0;
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
//#endregion
|
|
894
|
+
export { isValidEthereumAddress as $, uuidMaskOptions as A, formatExternalAccountName as B, dateMaskOptions as C, timeOptions as D, timeMaskOptionsHHMM as E, formatUsd as F, parseTimeUnitValue as G, coerceSecondsFromTimeUnitValue as H, formatUsdAmount as I, DEFAULT_ADDRESS as J, serializeTimeUnitValue as K, formattedNumber as L, formatAmount as M, formatCurrency as N, timeOptionsWithoutMeridiem as O, formatSmartCurrency as P, isNullAddress as Q, i18n as R, numFormatter as S, postalCodeMaskOptions as T, getSecondsFromTimeUnitValue as U, getBaseDomain as V, isValidTimeUnitValue as W, createEIP2098Signature as X, ETHEREUM_ADDRESS_REGEX as Y, getChainRpcUrl as Z, focusMainWindow as _, getDisplayableZodError as a, extractBaseActivityDetails as at, performRedirect as b, buildUrl as c, isErc4626WithdrawActivity as ct, formatSignatureToEIP2098 as d, timestampToISOString as dt, isValidV as et, isScriptLoaded as f, areAddressesEqual as ft, closeEmergentWindow as g, PollingManager as h, formHexStringSchema as i, truncateAddress as it, floorToDecimals as j, usdCurrencyMaskOptions as k, capitalize as l, isSwapActivity as lt, randomNumber as m, createTimeUnitValidator as n, parseHexAmount as nt, parseSchema as o, isCctpBurnActivity as ot, loadExternalSdk as p, timeUnitInputValueSchema as q, formDecimalStringSchema as r, parseSignatureToVRS as rt, buildQueryString as s, isErc4626DepositActivity as st, composeValidators as t, normalizeV as tt, toTitleCase as u, isTransferActivity as ut, isClient as v, formatUUID as w, formatNumberAsUSStandard as x, openCenteredEmergentWindow as y, localeSchema as z };
|
|
895
|
+
//# sourceMappingURL=helpers-BNiSxjGq.mjs.map
|