wowok 2.2.3 → 2.2.5
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/cjs/_deps/bcs/bcs-type.d.ts +127 -0
- package/dist/cjs/_deps/bcs/bcs-type.js +1 -0
- package/dist/cjs/_deps/bcs/bcs.d.ts +49 -0
- package/dist/cjs/_deps/bcs/bcs.js +1 -0
- package/dist/cjs/_deps/bcs/index.d.ts +16 -0
- package/dist/cjs/_deps/bcs/index.js +1 -0
- package/dist/cjs/_deps/bcs/reader.d.ts +15 -0
- package/dist/cjs/_deps/bcs/reader.js +1 -0
- package/dist/cjs/_deps/bcs/types.d.ts +24 -0
- package/dist/cjs/_deps/bcs/uleb.d.ts +5 -0
- package/dist/cjs/_deps/bcs/uleb.js +1 -0
- package/dist/cjs/_deps/bcs/utils.d.ts +4 -0
- package/dist/cjs/_deps/bcs/utils.js +1 -0
- package/dist/cjs/_deps/bcs/writer.d.ts +28 -0
- package/dist/cjs/_deps/bcs/writer.js +1 -0
- package/dist/cjs/_deps/utils/b58.d.ts +2 -0
- package/dist/cjs/_deps/utils/b58.js +1 -0
- package/dist/cjs/_deps/utils/b64.d.ts +2 -0
- package/dist/cjs/_deps/utils/b64.js +1 -0
- package/dist/cjs/_deps/utils/chunk.d.ts +1 -0
- package/dist/cjs/_deps/utils/chunk.js +1 -0
- package/dist/cjs/_deps/utils/dataloader.d.ts +43 -0
- package/dist/cjs/_deps/utils/dataloader.js +1 -0
- package/dist/cjs/_deps/utils/hex.d.ts +2 -0
- package/dist/cjs/_deps/utils/hex.js +1 -0
- package/dist/cjs/_deps/utils/index.d.ts +7 -0
- package/dist/cjs/_deps/utils/index.js +1 -0
- package/dist/cjs/_deps/utils/types.d.ts +4 -0
- package/dist/cjs/_deps/utils/with-resolver.d.ts +6 -0
- package/dist/cjs/_deps/utils/with-resolver.js +1 -0
- package/dist/cjs/bcs/bcs.d.ts +275 -313
- package/dist/cjs/bcs/bcs.js +1 -1
- package/dist/cjs/bcs/effects.d.ts +193 -193
- package/dist/cjs/bcs/effects.js +1 -1
- package/dist/cjs/bcs/index.d.ts +1 -1
- package/dist/cjs/bcs/index.js +1 -1
- package/dist/cjs/bcs/pure.d.ts +1 -1
- package/dist/cjs/bcs/pure.js +1 -1
- package/dist/cjs/bcs/type-tag-serializer.js +1 -1
- package/dist/cjs/cryptography/index.d.ts +1 -1
- package/dist/cjs/cryptography/index.js +1 -1
- package/dist/cjs/cryptography/intent.js +1 -1
- package/dist/cjs/cryptography/keypair.d.ts +2 -2
- package/dist/cjs/cryptography/keypair.js +1 -1
- package/dist/cjs/cryptography/mnemonics.js +1 -1
- package/dist/cjs/cryptography/publickey.d.ts +1 -1
- package/dist/cjs/cryptography/publickey.js +1 -1
- package/dist/cjs/cryptography/signature-scheme.d.ts +4 -15
- package/dist/cjs/cryptography/signature-scheme.js +1 -1
- package/dist/cjs/cryptography/signature.d.ts +1 -9
- package/dist/cjs/cryptography/signature.js +1 -1
- package/dist/cjs/experimental/client.d.ts +1 -1
- package/dist/cjs/grpc/client.d.ts +0 -2
- package/dist/cjs/grpc/client.js +1 -1
- package/dist/cjs/grpc/core.js +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/any.d.ts +7 -0
- package/dist/cjs/grpc/proto/google/protobuf/any.js +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/duration.d.ts +8 -0
- package/dist/cjs/grpc/proto/google/protobuf/duration.js +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/empty.d.ts +8 -0
- package/dist/cjs/grpc/proto/google/protobuf/empty.js +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/field_mask.d.ts +8 -0
- package/dist/cjs/grpc/proto/google/protobuf/field_mask.js +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/struct.d.ts +15 -0
- package/dist/cjs/grpc/proto/google/protobuf/struct.js +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/timestamp.d.ts +8 -0
- package/dist/cjs/grpc/proto/google/protobuf/timestamp.js +1 -1
- package/dist/cjs/grpc/proto/google/rpc/error_details.d.ts +48 -0
- package/dist/cjs/grpc/proto/google/rpc/error_details.js +1 -1
- package/dist/cjs/grpc/proto/google/rpc/status.d.ts +8 -0
- package/dist/cjs/grpc/proto/google/rpc/status.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/effects.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/event.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.d.ts +2 -2
- package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/object.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature.d.ts +9 -87
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.d.ts +2 -6
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.d.ts +0 -2
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.d.ts +2 -2
- package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.d.ts +13 -51
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.js +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.js +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/jsonRpc/client.js +1 -1
- package/dist/cjs/jsonRpc/core.js +1 -1
- package/dist/cjs/jsonRpc/json-rpc-resolver.js +1 -1
- package/dist/cjs/jsonRpc/types/chain.d.ts +0 -5
- package/dist/cjs/jsonRpc/types/generated.d.ts +5 -57
- package/dist/cjs/jsonRpc/types/params.d.ts +0 -17
- package/dist/cjs/keypairs/falcon512/index.d.ts +2 -0
- package/dist/cjs/keypairs/falcon512/index.js +1 -0
- package/dist/cjs/keypairs/falcon512/keypair.d.ts +19 -0
- package/dist/cjs/keypairs/falcon512/keypair.js +1 -0
- package/dist/{esm/keypairs/ed25519 → cjs/keypairs/falcon512}/publickey.d.ts +2 -2
- package/dist/cjs/keypairs/falcon512/publickey.js +1 -0
- package/dist/cjs/keypairs/index.d.ts +1 -4
- package/dist/cjs/keypairs/index.js +1 -1
- package/dist/cjs/multisig/publickey.js +1 -1
- package/dist/cjs/multisig/signer.js +1 -1
- package/dist/cjs/transactions/Commands.js +1 -1
- package/dist/cjs/transactions/Inputs.d.ts +1 -1
- package/dist/cjs/transactions/Inputs.js +1 -1
- package/dist/cjs/transactions/Transaction.d.ts +5 -5
- package/dist/cjs/transactions/Transaction.js +1 -1
- package/dist/cjs/transactions/TransactionData.js +1 -1
- package/dist/cjs/transactions/__tests__/Transaction.test.js +1 -1
- package/dist/cjs/transactions/__tests__/bcs.test.js +1 -1
- package/dist/cjs/transactions/data/internal.d.ts +2 -2
- package/dist/cjs/transactions/data/v1.d.ts +2 -2
- package/dist/cjs/transactions/data/v1.js +1 -1
- package/dist/cjs/transactions/data/v2.d.ts +1 -1
- package/dist/cjs/transactions/executor/parallel.js +1 -1
- package/dist/cjs/transactions/executor/serial.js +1 -1
- package/dist/cjs/transactions/pure.d.ts +1 -1
- package/dist/cjs/transactions/pure.js +1 -1
- package/dist/cjs/transactions/serializer.d.ts +1 -1
- package/dist/cjs/utils/dynamic-fields.js +1 -1
- package/dist/cjs/utils/index.d.ts +1 -1
- package/dist/cjs/utils/index.js +1 -1
- package/dist/cjs/utils/move-registry.js +1 -1
- package/dist/cjs/utils/sui-types.js +1 -1
- package/dist/cjs/verify/verify.js +1 -1
- package/dist/cjs/w/call/arbitration.js +1 -1
- package/dist/cjs/w/call/base.js +1 -1
- package/dist/cjs/w/call/contact.js +1 -1
- package/dist/cjs/w/call/demand.js +1 -1
- package/dist/cjs/w/call/guard.js +1 -1
- package/dist/cjs/w/call/machine.js +1 -1
- package/dist/cjs/w/call/personal.js +1 -1
- package/dist/cjs/w/call/proof.d.ts +3 -3
- package/dist/cjs/w/call/proof.js +1 -1
- package/dist/cjs/w/call/repository.js +1 -1
- package/dist/cjs/w/call/reward.js +1 -1
- package/dist/cjs/w/call/service.js +1 -1
- package/dist/cjs/w/call/treasury.js +1 -1
- package/dist/cjs/w/local/account.d.ts +11 -4
- package/dist/cjs/w/local/account.js +1 -1
- package/dist/cjs/w/local/storage.js +1 -1
- package/dist/cjs/w/local/util.js +1 -1
- package/dist/cjs/w/local/wip.d.ts +1 -1
- package/dist/cjs/w/local/wip.js +1 -1
- package/dist/cjs/w/messenger/crypto.d.ts +1 -3
- package/dist/cjs/w/messenger/crypto.js +1 -1
- package/dist/cjs/w/messenger/messenger-api.js +1 -1
- package/dist/cjs/w/messenger/messenger-manager.js +1 -1
- package/dist/cjs/w/messenger/messenger.js +1 -1
- package/dist/cjs/w/messenger/pq/crypto.d.ts +6 -6
- package/dist/cjs/w/messenger/pq/crypto.js +1 -1
- package/dist/cjs/w/messenger/pq/pqxdh.d.ts +3 -6
- package/dist/cjs/w/messenger/pq/pqxdh.js +1 -1
- package/dist/cjs/w/messenger/pq/session.d.ts +6 -4
- package/dist/cjs/w/messenger/pq/session.js +1 -1
- package/dist/cjs/w/messenger/pq/spqr.js +1 -1
- package/dist/cjs/w/messenger/pq/store-adapter.d.ts +1 -3
- package/dist/cjs/w/messenger/pq/store-adapter.js +1 -1
- package/dist/cjs/w/messenger/pq/types.d.ts +4 -5
- package/dist/cjs/w/messenger/pq/types.js +1 -1
- package/dist/cjs/w/messenger/session.d.ts +4 -5
- package/dist/cjs/w/messenger/session.js +1 -1
- package/dist/cjs/w/messenger/storage.js +1 -1
- package/dist/cjs/w/messenger/types.d.ts +7 -10
- package/dist/cjs/w/messenger/types.js +1 -1
- package/dist/cjs/w/query/object.js +1 -1
- package/dist/esm/_deps/bcs/bcs-type.d.ts +127 -0
- package/dist/esm/_deps/bcs/bcs-type.js +1 -0
- package/dist/esm/_deps/bcs/bcs.d.ts +49 -0
- package/dist/esm/_deps/bcs/bcs.js +1 -0
- package/dist/esm/_deps/bcs/index.d.ts +16 -0
- package/dist/esm/_deps/bcs/index.js +1 -0
- package/dist/esm/_deps/bcs/reader.d.ts +15 -0
- package/dist/esm/_deps/bcs/reader.js +1 -0
- package/dist/esm/_deps/bcs/types.d.ts +24 -0
- package/dist/esm/_deps/bcs/types.js +1 -0
- package/dist/esm/_deps/bcs/uleb.d.ts +5 -0
- package/dist/esm/_deps/bcs/uleb.js +1 -0
- package/dist/esm/_deps/bcs/utils.d.ts +4 -0
- package/dist/esm/_deps/bcs/utils.js +1 -0
- package/dist/esm/_deps/bcs/writer.d.ts +28 -0
- package/dist/esm/_deps/bcs/writer.js +1 -0
- package/dist/esm/_deps/utils/b58.d.ts +2 -0
- package/dist/esm/_deps/utils/b58.js +1 -0
- package/dist/esm/_deps/utils/b64.d.ts +2 -0
- package/dist/esm/_deps/utils/b64.js +1 -0
- package/dist/esm/_deps/utils/chunk.d.ts +1 -0
- package/dist/esm/_deps/utils/chunk.js +1 -0
- package/dist/esm/_deps/utils/dataloader.d.ts +43 -0
- package/dist/esm/_deps/utils/dataloader.js +1 -0
- package/dist/esm/_deps/utils/hex.d.ts +2 -0
- package/dist/esm/_deps/utils/hex.js +1 -0
- package/dist/esm/_deps/utils/index.d.ts +7 -0
- package/dist/esm/_deps/utils/index.js +1 -0
- package/dist/esm/_deps/utils/types.d.ts +4 -0
- package/dist/esm/_deps/utils/types.js +1 -0
- package/dist/esm/_deps/utils/with-resolver.d.ts +6 -0
- package/dist/esm/_deps/utils/with-resolver.js +1 -0
- package/dist/esm/bcs/bcs.d.ts +275 -313
- package/dist/esm/bcs/bcs.js +1 -1
- package/dist/esm/bcs/effects.d.ts +193 -193
- package/dist/esm/bcs/effects.js +1 -1
- package/dist/esm/bcs/index.d.ts +1 -1
- package/dist/esm/bcs/index.js +1 -1
- package/dist/esm/bcs/pure.d.ts +1 -1
- package/dist/esm/bcs/pure.js +1 -1
- package/dist/esm/bcs/type-tag-serializer.js +1 -1
- package/dist/esm/cryptography/index.d.ts +1 -1
- package/dist/esm/cryptography/index.js +1 -1
- package/dist/esm/cryptography/intent.js +1 -1
- package/dist/esm/cryptography/keypair.d.ts +2 -2
- package/dist/esm/cryptography/keypair.js +1 -1
- package/dist/esm/cryptography/mnemonics.js +1 -1
- package/dist/esm/cryptography/publickey.d.ts +1 -1
- package/dist/esm/cryptography/publickey.js +1 -1
- package/dist/esm/cryptography/signature-scheme.d.ts +4 -15
- package/dist/esm/cryptography/signature-scheme.js +1 -1
- package/dist/esm/cryptography/signature.d.ts +1 -9
- package/dist/esm/cryptography/signature.js +1 -1
- package/dist/esm/experimental/client.d.ts +1 -1
- package/dist/esm/grpc/client.d.ts +0 -2
- package/dist/esm/grpc/client.js +1 -1
- package/dist/esm/grpc/core.js +1 -1
- package/dist/esm/grpc/proto/google/protobuf/any.d.ts +7 -0
- package/dist/esm/grpc/proto/google/protobuf/any.js +1 -1
- package/dist/esm/grpc/proto/google/protobuf/duration.d.ts +8 -0
- package/dist/esm/grpc/proto/google/protobuf/duration.js +1 -1
- package/dist/esm/grpc/proto/google/protobuf/empty.d.ts +8 -0
- package/dist/esm/grpc/proto/google/protobuf/empty.js +1 -1
- package/dist/esm/grpc/proto/google/protobuf/field_mask.d.ts +8 -0
- package/dist/esm/grpc/proto/google/protobuf/field_mask.js +1 -1
- package/dist/esm/grpc/proto/google/protobuf/struct.d.ts +15 -0
- package/dist/esm/grpc/proto/google/protobuf/struct.js +1 -1
- package/dist/esm/grpc/proto/google/protobuf/timestamp.d.ts +8 -0
- package/dist/esm/grpc/proto/google/protobuf/timestamp.js +1 -1
- package/dist/esm/grpc/proto/google/rpc/error_details.d.ts +48 -0
- package/dist/esm/grpc/proto/google/rpc/error_details.js +1 -1
- package/dist/esm/grpc/proto/google/rpc/status.d.ts +8 -0
- package/dist/esm/grpc/proto/google/rpc/status.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_contents.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_summary.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/effects.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/event.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/executed_transaction.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/execution_status.d.ts +2 -2
- package/dist/esm/grpc/proto/sui/rpc/v2/execution_status.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/object.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/signature.d.ts +9 -87
- package/dist/esm/grpc/proto/sui/rpc/v2/signature.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_scheme.d.ts +2 -6
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_scheme.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.d.ts +0 -2
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/state_service.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/system_state.d.ts +2 -2
- package/dist/esm/grpc/proto/sui/rpc/v2/system_state.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction.d.ts +13 -51
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction.js +1 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.js +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/jsonRpc/client.js +1 -1
- package/dist/esm/jsonRpc/core.js +1 -1
- package/dist/esm/jsonRpc/json-rpc-resolver.js +1 -1
- package/dist/esm/jsonRpc/types/chain.d.ts +0 -5
- package/dist/esm/jsonRpc/types/generated.d.ts +5 -57
- package/dist/esm/jsonRpc/types/params.d.ts +0 -17
- package/dist/esm/keypairs/falcon512/index.d.ts +2 -0
- package/dist/esm/keypairs/falcon512/index.js +1 -0
- package/dist/esm/keypairs/falcon512/keypair.d.ts +19 -0
- package/dist/esm/keypairs/falcon512/keypair.js +1 -0
- package/dist/{cjs/keypairs/ed25519 → esm/keypairs/falcon512}/publickey.d.ts +2 -2
- package/dist/esm/keypairs/falcon512/publickey.js +1 -0
- package/dist/esm/keypairs/index.d.ts +1 -4
- package/dist/esm/keypairs/index.js +1 -1
- package/dist/esm/multisig/publickey.js +1 -1
- package/dist/esm/multisig/signer.js +1 -1
- package/dist/esm/transactions/Commands.js +1 -1
- package/dist/esm/transactions/Inputs.d.ts +1 -1
- package/dist/esm/transactions/Inputs.js +1 -1
- package/dist/esm/transactions/Transaction.d.ts +5 -5
- package/dist/esm/transactions/Transaction.js +1 -1
- package/dist/esm/transactions/TransactionData.js +1 -1
- package/dist/esm/transactions/__tests__/Transaction.test.js +1 -1
- package/dist/esm/transactions/__tests__/bcs.test.js +1 -1
- package/dist/esm/transactions/data/internal.d.ts +2 -2
- package/dist/esm/transactions/data/v1.d.ts +2 -2
- package/dist/esm/transactions/data/v1.js +1 -1
- package/dist/esm/transactions/data/v2.d.ts +1 -1
- package/dist/esm/transactions/executor/parallel.js +1 -1
- package/dist/esm/transactions/executor/serial.js +1 -1
- package/dist/esm/transactions/pure.d.ts +1 -1
- package/dist/esm/transactions/pure.js +1 -1
- package/dist/esm/transactions/serializer.d.ts +1 -1
- package/dist/esm/utils/dynamic-fields.js +1 -1
- package/dist/esm/utils/index.d.ts +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/move-registry.js +1 -1
- package/dist/esm/utils/sui-types.js +1 -1
- package/dist/esm/verify/verify.js +1 -1
- package/dist/esm/w/call/arbitration.js +1 -1
- package/dist/esm/w/call/base.js +1 -1
- package/dist/esm/w/call/contact.js +1 -1
- package/dist/esm/w/call/demand.js +1 -1
- package/dist/esm/w/call/guard.js +1 -1
- package/dist/esm/w/call/machine.js +1 -1
- package/dist/esm/w/call/personal.js +1 -1
- package/dist/esm/w/call/proof.d.ts +3 -3
- package/dist/esm/w/call/proof.js +1 -1
- package/dist/esm/w/call/repository.js +1 -1
- package/dist/esm/w/call/reward.js +1 -1
- package/dist/esm/w/call/service.js +1 -1
- package/dist/esm/w/call/treasury.js +1 -1
- package/dist/esm/w/local/account.d.ts +11 -4
- package/dist/esm/w/local/account.js +1 -1
- package/dist/esm/w/local/storage.js +1 -1
- package/dist/esm/w/local/util.js +1 -1
- package/dist/esm/w/local/wip.d.ts +1 -1
- package/dist/esm/w/local/wip.js +1 -1
- package/dist/esm/w/messenger/crypto.d.ts +1 -3
- package/dist/esm/w/messenger/crypto.js +1 -1
- package/dist/esm/w/messenger/messenger-api.js +1 -1
- package/dist/esm/w/messenger/messenger-manager.js +1 -1
- package/dist/esm/w/messenger/messenger.js +1 -1
- package/dist/esm/w/messenger/pq/crypto.d.ts +6 -6
- package/dist/esm/w/messenger/pq/crypto.js +1 -1
- package/dist/esm/w/messenger/pq/pqxdh.d.ts +3 -6
- package/dist/esm/w/messenger/pq/pqxdh.js +1 -1
- package/dist/esm/w/messenger/pq/session.d.ts +6 -4
- package/dist/esm/w/messenger/pq/session.js +1 -1
- package/dist/esm/w/messenger/pq/spqr.js +1 -1
- package/dist/esm/w/messenger/pq/store-adapter.d.ts +1 -3
- package/dist/esm/w/messenger/pq/store-adapter.js +1 -1
- package/dist/esm/w/messenger/pq/types.d.ts +4 -5
- package/dist/esm/w/messenger/pq/types.js +1 -1
- package/dist/esm/w/messenger/session.d.ts +4 -5
- package/dist/esm/w/messenger/session.js +1 -1
- package/dist/esm/w/messenger/storage.js +1 -1
- package/dist/esm/w/messenger/types.d.ts +7 -10
- package/dist/esm/w/messenger/types.js +1 -1
- package/dist/esm/w/query/object.js +1 -1
- package/package.json +22 -24
- package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.d.ts +0 -20
- package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.js +0 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.d.ts +0 -23
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.js +0 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.d.ts +0 -47
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.js +0 -1
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.d.ts +0 -8
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +0 -1
- package/dist/cjs/keypairs/ed25519/index.d.ts +0 -2
- package/dist/cjs/keypairs/ed25519/index.js +0 -1
- package/dist/cjs/keypairs/ed25519/keypair.d.ts +0 -22
- package/dist/cjs/keypairs/ed25519/keypair.js +0 -1
- package/dist/cjs/keypairs/ed25519/publickey.js +0 -1
- package/dist/cjs/keypairs/passkey/index.d.ts +0 -3
- package/dist/cjs/keypairs/passkey/index.js +0 -1
- package/dist/cjs/keypairs/passkey/keypair.d.ts +0 -33
- package/dist/cjs/keypairs/passkey/keypair.js +0 -1
- package/dist/cjs/keypairs/passkey/publickey.d.ts +0 -25
- package/dist/cjs/keypairs/passkey/publickey.js +0 -1
- package/dist/cjs/keypairs/passkey/types.d.ts +0 -6
- package/dist/cjs/keypairs/secp256k1/index.d.ts +0 -2
- package/dist/cjs/keypairs/secp256k1/index.js +0 -1
- package/dist/cjs/keypairs/secp256k1/keypair.d.ts +0 -22
- package/dist/cjs/keypairs/secp256k1/keypair.js +0 -1
- package/dist/cjs/keypairs/secp256k1/publickey.d.ts +0 -11
- package/dist/cjs/keypairs/secp256k1/publickey.js +0 -1
- package/dist/cjs/keypairs/secp256r1/index.d.ts +0 -2
- package/dist/cjs/keypairs/secp256r1/index.js +0 -1
- package/dist/cjs/keypairs/secp256r1/keypair.d.ts +0 -22
- package/dist/cjs/keypairs/secp256r1/keypair.js +0 -1
- package/dist/cjs/keypairs/secp256r1/publickey.d.ts +0 -11
- package/dist/cjs/keypairs/secp256r1/publickey.js +0 -1
- package/dist/cjs/utils/suins.d.ts +0 -2
- package/dist/cjs/utils/suins.js +0 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/jwk.d.ts +0 -20
- package/dist/esm/grpc/proto/sui/rpc/v2/jwk.js +0 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.client.d.ts +0 -23
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.client.js +0 -1
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.d.ts +0 -47
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.js +0 -1
- package/dist/esm/keypairs/ed25519/ed25519-hd-key.d.ts +0 -8
- package/dist/esm/keypairs/ed25519/ed25519-hd-key.js +0 -1
- package/dist/esm/keypairs/ed25519/index.d.ts +0 -2
- package/dist/esm/keypairs/ed25519/index.js +0 -1
- package/dist/esm/keypairs/ed25519/keypair.d.ts +0 -22
- package/dist/esm/keypairs/ed25519/keypair.js +0 -1
- package/dist/esm/keypairs/ed25519/publickey.js +0 -1
- package/dist/esm/keypairs/passkey/index.d.ts +0 -3
- package/dist/esm/keypairs/passkey/index.js +0 -1
- package/dist/esm/keypairs/passkey/keypair.d.ts +0 -33
- package/dist/esm/keypairs/passkey/keypair.js +0 -1
- package/dist/esm/keypairs/passkey/publickey.d.ts +0 -25
- package/dist/esm/keypairs/passkey/publickey.js +0 -1
- package/dist/esm/keypairs/passkey/types.d.ts +0 -6
- package/dist/esm/keypairs/secp256k1/index.d.ts +0 -2
- package/dist/esm/keypairs/secp256k1/index.js +0 -1
- package/dist/esm/keypairs/secp256k1/keypair.d.ts +0 -22
- package/dist/esm/keypairs/secp256k1/keypair.js +0 -1
- package/dist/esm/keypairs/secp256k1/publickey.d.ts +0 -11
- package/dist/esm/keypairs/secp256k1/publickey.js +0 -1
- package/dist/esm/keypairs/secp256r1/index.d.ts +0 -2
- package/dist/esm/keypairs/secp256r1/index.js +0 -1
- package/dist/esm/keypairs/secp256r1/keypair.d.ts +0 -22
- package/dist/esm/keypairs/secp256r1/keypair.js +0 -1
- package/dist/esm/keypairs/secp256r1/publickey.d.ts +0 -11
- package/dist/esm/keypairs/secp256r1/publickey.js +0 -1
- package/dist/esm/utils/suins.d.ts +0 -2
- package/dist/esm/utils/suins.js +0 -1
- /package/dist/cjs/{keypairs/passkey → _deps/bcs}/types.js +0 -0
- /package/dist/{esm/keypairs/passkey → cjs/_deps/utils}/types.js +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { BcsReader } from "./reader.js";
|
|
2
|
+
import type { BcsWriterOptions } from "./writer.js";
|
|
3
|
+
import { BcsWriter } from "./writer.js";
|
|
4
|
+
import type { EnumInputShape, EnumOutputShape, JoinString } from "./types.js";
|
|
5
|
+
export interface BcsTypeOptions<T, Input = T, Name extends string = string> {
|
|
6
|
+
name?: Name;
|
|
7
|
+
validate?: (value: Input) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare class BcsType<T, Input = T, const Name extends string = string> {
|
|
10
|
+
#private;
|
|
11
|
+
$inferType: T;
|
|
12
|
+
$inferInput: Input;
|
|
13
|
+
name: Name;
|
|
14
|
+
read: (reader: BcsReader) => T;
|
|
15
|
+
serializedSize: (value: Input, options?: BcsWriterOptions) => number | null;
|
|
16
|
+
validate: (value: Input) => void;
|
|
17
|
+
constructor(options: {
|
|
18
|
+
name: Name;
|
|
19
|
+
read: (reader: BcsReader) => T;
|
|
20
|
+
write: (value: Input, writer: BcsWriter) => void;
|
|
21
|
+
serialize?: (value: Input, options?: BcsWriterOptions) => Uint8Array<ArrayBuffer>;
|
|
22
|
+
serializedSize?: (value: Input) => number | null;
|
|
23
|
+
validate?: (value: Input) => void;
|
|
24
|
+
} & BcsTypeOptions<T, Input, Name>);
|
|
25
|
+
write(value: Input, writer: BcsWriter): void;
|
|
26
|
+
serialize(value: Input, options?: BcsWriterOptions): SerializedBcs<T, Input>;
|
|
27
|
+
parse(bytes: Uint8Array): T;
|
|
28
|
+
fromHex(hex: string): T;
|
|
29
|
+
fromBase58(b64: string): T;
|
|
30
|
+
fromBase64(b64: string): T;
|
|
31
|
+
transform<T2 = T, Input2 = Input, NewName extends string = Name>({ name, input, output, validate, }: {
|
|
32
|
+
input?: (val: Input2) => Input;
|
|
33
|
+
output?: (value: T) => T2;
|
|
34
|
+
} & BcsTypeOptions<T2, Input2, NewName>): BcsType<T2, Input2, NewName>;
|
|
35
|
+
}
|
|
36
|
+
declare const SERIALIZED_BCS_BRAND: never;
|
|
37
|
+
export declare function isSerializedBcs(obj: unknown): obj is SerializedBcs<unknown>;
|
|
38
|
+
export declare class SerializedBcs<T, Input = T> {
|
|
39
|
+
#private;
|
|
40
|
+
[SERIALIZED_BCS_BRAND]: boolean;
|
|
41
|
+
constructor(schema: BcsType<T, Input>, bytes: Uint8Array<ArrayBuffer>);
|
|
42
|
+
toBytes(): Uint8Array<ArrayBuffer>;
|
|
43
|
+
toHex(): string;
|
|
44
|
+
toBase64(): string;
|
|
45
|
+
toBase58(): string;
|
|
46
|
+
parse(): T;
|
|
47
|
+
}
|
|
48
|
+
export declare function fixedSizeBcsType<T, Input = T, const Name extends string = string>({ size, ...options }: {
|
|
49
|
+
name: Name;
|
|
50
|
+
size: number;
|
|
51
|
+
read: (reader: BcsReader) => T;
|
|
52
|
+
write: (value: Input, writer: BcsWriter) => void;
|
|
53
|
+
} & BcsTypeOptions<T, Input, Name>): BcsType<T, Input, Name>;
|
|
54
|
+
export declare function uIntBcsType<const Name extends string = string>({ readMethod, writeMethod, ...options }: {
|
|
55
|
+
name: Name;
|
|
56
|
+
size: number;
|
|
57
|
+
readMethod: `read${8 | 16 | 32}`;
|
|
58
|
+
writeMethod: `write${8 | 16 | 32}`;
|
|
59
|
+
maxValue: number;
|
|
60
|
+
} & BcsTypeOptions<number, number, Name>): BcsType<number, number, Name>;
|
|
61
|
+
export declare function bigUIntBcsType<const Name extends string = string>({ readMethod, writeMethod, ...options }: {
|
|
62
|
+
name: Name;
|
|
63
|
+
size: number;
|
|
64
|
+
readMethod: `read${64 | 128 | 256}`;
|
|
65
|
+
writeMethod: `write${64 | 128 | 256}`;
|
|
66
|
+
maxValue: bigint;
|
|
67
|
+
} & BcsTypeOptions<string, string | number | bigint>): BcsType<string, string | number | bigint, Name>;
|
|
68
|
+
export declare function dynamicSizeBcsType<T, Input = T, const Name extends string = string>({ serialize, ...options }: {
|
|
69
|
+
name: Name;
|
|
70
|
+
read: (reader: BcsReader) => T;
|
|
71
|
+
serialize: (value: Input, options?: BcsWriterOptions) => Uint8Array<ArrayBuffer>;
|
|
72
|
+
} & BcsTypeOptions<T, Input>): BcsType<T, Input, string>;
|
|
73
|
+
export declare function stringLikeBcsType<const Name extends string = string>({ toBytes, fromBytes, ...options }: {
|
|
74
|
+
name: Name;
|
|
75
|
+
toBytes: (value: string) => Uint8Array;
|
|
76
|
+
fromBytes: (bytes: Uint8Array) => string;
|
|
77
|
+
serializedSize?: (value: string) => number | null;
|
|
78
|
+
} & BcsTypeOptions<string, string, Name>): BcsType<string, string, Name>;
|
|
79
|
+
export declare function lazyBcsType<T, Input>(cb: () => BcsType<T, Input>): BcsType<T, Input, string>;
|
|
80
|
+
export interface BcsStructOptions<T extends Record<string, BcsType<any>>, Name extends string = string> extends Omit<BcsTypeOptions<{
|
|
81
|
+
[K in keyof T]: T[K] extends BcsType<infer U, any> ? U : never;
|
|
82
|
+
}, {
|
|
83
|
+
[K in keyof T]: T[K] extends BcsType<any, infer U> ? U : never;
|
|
84
|
+
}, Name>, "name"> {
|
|
85
|
+
name: Name;
|
|
86
|
+
fields: T;
|
|
87
|
+
}
|
|
88
|
+
export declare class BcsStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsType<{
|
|
89
|
+
[K in keyof T]: T[K] extends BcsType<infer U, any> ? U : never;
|
|
90
|
+
}, {
|
|
91
|
+
[K in keyof T]: T[K] extends BcsType<any, infer U> ? U : never;
|
|
92
|
+
}, Name> {
|
|
93
|
+
constructor({ name, fields, ...options }: BcsStructOptions<T, Name>);
|
|
94
|
+
}
|
|
95
|
+
export interface BcsEnumOptions<T extends Record<string, BcsType<any> | null>, Name extends string = string> extends Omit<BcsTypeOptions<EnumOutputShape<{
|
|
96
|
+
[K in keyof T]: T[K] extends BcsType<infer U, any, any> ? U : true;
|
|
97
|
+
}>, EnumInputShape<{
|
|
98
|
+
[K in keyof T]: T[K] extends BcsType<any, infer U, any> ? U : boolean | object | null;
|
|
99
|
+
}>, Name>, "name"> {
|
|
100
|
+
name: Name;
|
|
101
|
+
fields: T;
|
|
102
|
+
}
|
|
103
|
+
export declare class BcsEnum<T extends Record<string, BcsType<any> | null>, const Name extends string = string> extends BcsType<EnumOutputShape<{
|
|
104
|
+
[K in keyof T]: T[K] extends BcsType<infer U, any> ? U : true;
|
|
105
|
+
}>, EnumInputShape<{
|
|
106
|
+
[K in keyof T]: T[K] extends BcsType<any, infer U, any> ? U : boolean | object | null;
|
|
107
|
+
}>, Name> {
|
|
108
|
+
constructor({ fields, ...options }: BcsEnumOptions<T, Name>);
|
|
109
|
+
}
|
|
110
|
+
export interface BcsTupleOptions<T extends readonly BcsType<any>[], Name extends string> extends Omit<BcsTypeOptions<{
|
|
111
|
+
-readonly [K in keyof T]: T[K] extends BcsType<infer T, any> ? T : never;
|
|
112
|
+
}, {
|
|
113
|
+
[K in keyof T]: T[K] extends BcsType<any, infer T> ? T : never;
|
|
114
|
+
}, Name>, "name"> {
|
|
115
|
+
name?: Name;
|
|
116
|
+
fields: T;
|
|
117
|
+
}
|
|
118
|
+
export declare class BcsTuple<const T extends readonly BcsType<any>[], const Name extends string = `(${JoinString<{
|
|
119
|
+
[K in keyof T]: T[K] extends BcsType<any, any, infer T> ? T : never;
|
|
120
|
+
}, ", ">})`> extends BcsType<{
|
|
121
|
+
-readonly [K in keyof T]: T[K] extends BcsType<infer T, any> ? T : never;
|
|
122
|
+
}, {
|
|
123
|
+
[K in keyof T]: T[K] extends BcsType<any, infer T> ? T : never;
|
|
124
|
+
}, Name> {
|
|
125
|
+
constructor({ fields, name, ...options }: BcsTupleOptions<T, Name>);
|
|
126
|
+
}
|
|
127
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fromBase58,fromBase64,toBase58,toBase64,fromHex,toHex}from'../utils/index.js';import{BcsReader}from'./reader.js';import{ulebEncode}from'./uleb.js';import{BcsWriter}from'./writer.js';export class BcsType{['$inferType'];['$inferInput'];['name'];['read'];['serializedSize'];['validate'];#write;#serialize;constructor(a){this['name']=a['name'],this['read']=a['read'],this['serializedSize']=a['serializedSize']??(()=>null),this.#write=a['write'],this.#serialize=a['serialize']??((b,c)=>{const d=new BcsWriter({'initialSize':this['serializedSize'](b)??undefined,...c});return this.#write(b,d),d['toBytes']();}),this['validate']=a['validate']??(()=>{});}['write'](a,b){this['validate'](a),this.#write(a,b);}['serialize'](a,b){return this['validate'](a),new SerializedBcs(this,this.#serialize(a,b));}['parse'](a){const b=new BcsReader(a);return this['read'](b);}['fromHex'](a){return this['parse'](fromHex(a));}['fromBase58'](a){return this['parse'](fromBase58(a));}['fromBase64'](a){return this['parse'](fromBase64(a));}['transform']({name:a,input:b,output:c,validate:d}){return new BcsType({'name':a??this['name'],'read':e=>c?c(this['read'](e)):this['read'](e),'write':(e,f)=>this.#write(b?b(e):e,f),'serializedSize':e=>this['serializedSize'](b?b(e):e),'serialize':(e,f)=>this.#serialize(b?b(e):e,f),'validate':e=>{d?.(e),this['validate'](b?b(e):e);}});}}const SERIALIZED_BCS_BRAND=Symbol['for']('@mysten/serialized-bcs');export function isSerializedBcs(a){return!!a&&typeof a==='object'&&a[SERIALIZED_BCS_BRAND]===!![];}export class SerializedBcs{#schema;#bytes;get[SERIALIZED_BCS_BRAND](){return!![];}constructor(a,b){this.#schema=a,this.#bytes=b;}['toBytes'](){return this.#bytes;}['toHex'](){return toHex(this.#bytes);}['toBase64'](){return toBase64(this.#bytes);}['toBase58'](){return toBase58(this.#bytes);}['parse'](){return this.#schema['parse'](this.#bytes);}}export function fixedSizeBcsType({size:a,...b}){return new BcsType({...b,'serializedSize':()=>a});}export function uIntBcsType({readMethod:a,writeMethod:b,...c}){return fixedSizeBcsType({...c,'read':d=>d[a](),'write':(d,e)=>e[b](d),'validate':d=>{if(d<0x0||d>c['maxValue'])throw new TypeError('Invalid\x20'+c['name']+'\x20value:\x20'+d+'.\x20Expected\x20value\x20in\x20range\x200-'+c['maxValue']);c['validate']?.(d);}});}export function bigUIntBcsType({readMethod:a,writeMethod:b,...c}){return fixedSizeBcsType({...c,'read':d=>d[a](),'write':(d,e)=>e[b](BigInt(d)),'validate':d=>{const e=BigInt(d);if(e<0x0||e>c['maxValue'])throw new TypeError('Invalid\x20'+c['name']+'\x20value:\x20'+e+'.\x20Expected\x20value\x20in\x20range\x200-'+c['maxValue']);c['validate']?.(e);}});}export function dynamicSizeBcsType({serialize:a,...b}){const c=new BcsType({...b,'serialize':a,'write':(d,e)=>{for(const f of c['serialize'](d)['toBytes']()){e['write8'](f);}}});return c;}export function stringLikeBcsType({toBytes:a,fromBytes:b,...c}){return new BcsType({...c,'read':d=>{const e=d['readULEB'](),f=d['readBytes'](e);return b(f);},'write':(d,e)=>{const f=a(d);e['writeULEB'](f['length']);for(let g=0x0;g<f['length'];g++){e['write8'](f[g]);}},'serialize':d=>{const e=a(d),f=ulebEncode(e['length']),g=new Uint8Array(f['length']+e['length']);return g['set'](f,0x0),g['set'](e,f['length']),g;},'validate':d=>{if(typeof d!=='string')throw new TypeError('Invalid\x20'+c['name']+'\x20value:\x20'+d+'.\x20Expected\x20string');c['validate']?.(d);}});}export function lazyBcsType(a){let b=null;function c(){return!b&&(b=a()),b;}return new BcsType({'name':'lazy','read':d=>c()['read'](d),'serializedSize':d=>c()['serializedSize'](d),'write':(d,e)=>c()['write'](d,e),'serialize':(d,e)=>c()['serialize'](d,e)['toBytes']()});}export class BcsStruct extends BcsType{constructor({name:a,fields:b,...c}){const d=Object['entries'](b);super({'name':a,'serializedSize':e=>{let f=0x0;for(const [g,h]of d){const i=h['serializedSize'](e[g]);if(i==null)return null;f+=i;}return f;},'read':e=>{const f={};for(const [g,h]of d){f[g]=h['read'](e);}return f;},'write':(e,f)=>{for(const [g,h]of d){h['write'](e[g],f);}},...c,'validate':e=>{c?.['validate']?.(e);if(typeof e!=='object'||e==null)throw new TypeError('Expected\x20object,\x20found\x20'+typeof e);}});}}export class BcsEnum extends BcsType{constructor({fields:a,...b}){const c=Object['entries'](a);super({'read':d=>{const e=d['readULEB'](),f=c[e];if(!f)throw new TypeError('Unknown\x20value\x20'+e+'\x20for\x20enum\x20'+b['name']);const [g,h]=f;return{[g]:h?.['read'](d)??!![],'$kind':g};},'write':(d,e)=>{const [f,g]=Object['entries'](d)['filter'](([h])=>Object['hasOwn'](a,h))[0x0];for(let h=0x0;h<c['length'];h++){const [j,k]=c[h];if(j===f){e['writeULEB'](h),k?.['write'](g,e);return;}}},...b,'validate':d=>{b?.['validate']?.(d);if(typeof d!=='object'||d==null)throw new TypeError('Expected\x20object,\x20found\x20'+typeof d);const e=Object['keys'](d)['filter'](g=>d[g]!==undefined&&Object['hasOwn'](a,g));if(e['length']!==0x1)throw new TypeError('Expected\x20object\x20with\x20one\x20key,\x20but\x20found\x20'+e['length']+'\x20for\x20type\x20'+b['name']+'}');const [f]=e;if(!Object['hasOwn'](a,f))throw new TypeError('Invalid\x20enum\x20variant\x20'+f);}});}}export class BcsTuple extends BcsType{constructor({fields:a,name:b,...c}){super({'name':b??'('+a['map'](d=>d['name'])['join'](',\x20')+')','serializedSize':d=>{let e=0x0;for(let f=0x0;f<a['length'];f++){const g=a[f]['serializedSize'](d[f]);if(g==null)return null;e+=g;}return e;},'read':d=>{const e=[];for(const f of a){e['push'](f['read'](d));}return e;},'write':(d,e)=>{for(let f=0x0;f<a['length'];f++){a[f]['write'](d[f],e);}},...c,'validate':d=>{c?.['validate']?.(d);if(!Array['isArray'](d))throw new TypeError('Expected\x20array,\x20found\x20'+typeof d);if(d['length']!==a['length'])throw new TypeError('Expected\x20array\x20of\x20length\x20'+a['length']+',\x20found\x20'+d['length']);}});}}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { BcsTypeOptions } from "./bcs-type.js";
|
|
2
|
+
import { BcsEnum, BcsStruct, BcsTuple, BcsType } from "./bcs-type.js";
|
|
3
|
+
import type { EnumInputShape, EnumOutputShape, InferBcsInput, InferBcsType, JoinString } from "./types.js";
|
|
4
|
+
declare function fixedArray<T extends BcsType<any>, Name extends string = string>(size: number, type: T, options?: BcsTypeOptions<InferBcsType<T>[], Iterable<InferBcsInput<T>> & {
|
|
5
|
+
length: number;
|
|
6
|
+
}, Name>): BcsType<InferBcsType<T>[], Iterable<InferBcsInput<T>> & {
|
|
7
|
+
length: number;
|
|
8
|
+
}, Name>;
|
|
9
|
+
declare function fixedArray<T, Input, Name extends string = string>(size: number, type: BcsType<T, Input>, options?: BcsTypeOptions<T[], Iterable<Input> & {
|
|
10
|
+
length: number;
|
|
11
|
+
}, Name>): BcsType<T[], Iterable<Input> & {
|
|
12
|
+
length: number;
|
|
13
|
+
}, Name>;
|
|
14
|
+
declare function option<T extends BcsType<any>>(type: T): BcsType<InferBcsType<T> | null, InferBcsInput<T> | null | undefined, `Option<${T["name"]}>`>;
|
|
15
|
+
declare function option<T, Input, Name extends string = string>(type: BcsType<T, Input, Name>): BcsType<T | null, Input | null | undefined>;
|
|
16
|
+
declare function vector<T extends BcsType<any>, Name extends string = `vector<${T["name"]}>`>(type: T, options?: BcsTypeOptions<InferBcsType<T>[], Iterable<InferBcsInput<T>> & {
|
|
17
|
+
length: number;
|
|
18
|
+
}, Name>): BcsType<InferBcsType<T>[], Iterable<InferBcsInput<T>> & {
|
|
19
|
+
length: number;
|
|
20
|
+
}, Name>;
|
|
21
|
+
declare function vector<T, Input, Name extends string = string>(type: BcsType<T, Input, Name>, options?: BcsTypeOptions<T[], Iterable<Input> & {
|
|
22
|
+
length: number;
|
|
23
|
+
}, `vector<${Name}>`>): BcsType<T[], Iterable<Input> & {
|
|
24
|
+
length: number;
|
|
25
|
+
}, `vector<${Name}>`>;
|
|
26
|
+
declare function map<K extends BcsType<any>, V extends BcsType<any>>(keyType: K, valueType: V): BcsType<Map<InferBcsType<K>, InferBcsType<V>>, Map<InferBcsInput<K>, InferBcsInput<V>>, `Map<${K["name"]}, ${V["name"]}>`>;
|
|
27
|
+
declare function map<K, V, InputK = K, InputV = V>(keyType: BcsType<K, InputK>, valueType: BcsType<V, InputV>): BcsType<Map<K, V>, Map<InputK, InputV>, `Map<${string}, ${string}>`>;
|
|
28
|
+
export declare const bcs: {
|
|
29
|
+
u8(options?: BcsTypeOptions<number>): BcsType<number, number, "u8">;
|
|
30
|
+
u16(options?: BcsTypeOptions<number>): BcsType<number, number, "u16">;
|
|
31
|
+
u32(options?: BcsTypeOptions<number>): BcsType<number, number, "u32">;
|
|
32
|
+
u64(options?: BcsTypeOptions<string, number | bigint | string>): BcsType<string, string | number | bigint, "u64">;
|
|
33
|
+
u128(options?: BcsTypeOptions<string, number | bigint | string>): BcsType<string, string | number | bigint, "u128">;
|
|
34
|
+
u256(options?: BcsTypeOptions<string, number | bigint | string>): BcsType<string, string | number | bigint, "u256">;
|
|
35
|
+
bool(options?: BcsTypeOptions<boolean>): BcsType<boolean, boolean, "bool">;
|
|
36
|
+
uleb128(options?: BcsTypeOptions<number>): BcsType<number, number, string>;
|
|
37
|
+
bytes<T extends number>(size: T, options?: BcsTypeOptions<Uint8Array, Iterable<number>>): BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, `bytes[${T}]`>;
|
|
38
|
+
byteVector(options?: BcsTypeOptions<Uint8Array, Iterable<number>>): BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
|
|
39
|
+
string(options?: BcsTypeOptions<string>): BcsType<string, string, "string">;
|
|
40
|
+
fixedArray: typeof fixedArray;
|
|
41
|
+
option: typeof option;
|
|
42
|
+
vector: typeof vector;
|
|
43
|
+
tuple<const T extends readonly BcsType<any, any>[], const Name extends string = `(${JoinString<{ [K in keyof T]: T[K] extends BcsType<any, any, infer T_1 extends string> ? T_1 : never; }, ", ">})`>(fields: T, options?: BcsTypeOptions<{ -readonly [K_1 in keyof T]: T[K_1] extends BcsType<infer T_1, any> ? T_1 : never; }, { [K_1 in keyof T]: T[K_1] extends BcsType<any, infer T_1> ? T_1 : never; }, Name>): BcsTuple<T, Name>;
|
|
44
|
+
struct<T extends Record<string, BcsType<any>>, const Name extends string = string>(name: Name, fields: T, options?: Omit<BcsTypeOptions<{ [K in keyof T]: T[K] extends BcsType<infer U, any> ? U : never; }, { [K in keyof T]: T[K] extends BcsType<any, infer U> ? U : never; }>, "name">): BcsStruct<T, string>;
|
|
45
|
+
enum<T extends Record<string, BcsType<any> | null>, const Name extends string = string>(name: Name, fields: T, options?: Omit<BcsTypeOptions<EnumOutputShape<{ [K in keyof T]: T[K] extends BcsType<infer U, any, any> ? U : true; }>, EnumInputShape<{ [K in keyof T]: T[K] extends BcsType<any, infer U, any> ? U : boolean | object | null; }>, Name>, "name">): BcsEnum<T, Name>;
|
|
46
|
+
map: typeof map;
|
|
47
|
+
lazy<T extends BcsType<any>>(cb: () => T): T;
|
|
48
|
+
};
|
|
49
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{BcsEnum,BcsStruct,BcsTuple,BcsType,bigUIntBcsType,dynamicSizeBcsType,fixedSizeBcsType,lazyBcsType,stringLikeBcsType,uIntBcsType}from'./bcs-type.js';import{ulebEncode}from'./uleb.js';function fixedArray(a,b,c){return new BcsType({'read':d=>{const e=new Array(a);for(let f=0x0;f<a;f++){e[f]=b['read'](d);}return e;},'write':(d,e)=>{for(const f of d){b['write'](f,e);}},...c,'name':c?.['name']??b['name']+'['+a+']','validate':d=>{c?.['validate']?.(d);if(!d||typeof d!=='object'||!('length'in d))throw new TypeError('Expected\x20array,\x20found\x20'+typeof d);if(d['length']!==a)throw new TypeError('Expected\x20array\x20of\x20length\x20'+a+',\x20found\x20'+d['length']);}});}function option(a){return bcs['enum']('Option<'+a['name']+'>',{'None':null,'Some':a})['transform']({'input':b=>{if(b==null)return{'None':!![]};return{'Some':b};},'output':b=>{if(b['$kind']==='Some')return b['Some'];return null;}});}function vector(a,b){return new BcsType({'read':c=>{const d=c['readULEB'](),e=new Array(d);for(let f=0x0;f<d;f++){e[f]=a['read'](c);}return e;},'write':(c,d)=>{d['writeULEB'](c['length']);for(const e of c){a['write'](e,d);}},...b,'name':b?.['name']??'vector<'+a['name']+'>','validate':c=>{b?.['validate']?.(c);if(!c||typeof c!=='object'||!('length'in c))throw new TypeError('Expected\x20array,\x20found\x20'+typeof c);}});}function map(a,b){return bcs['vector'](bcs['tuple']([a,b]))['transform']({'name':'Map<'+a['name']+',\x20'+b['name']+'>','input':c=>{return[...c['entries']()];},'output':c=>{const d=new Map();for(const [e,f]of c){d['set'](e,f);}return d;}});}export const bcs={'u8'(a){return uIntBcsType({'readMethod':'read8','writeMethod':'write8','size':0x1,'maxValue':0x2**0x8-0x1,...a,'name':a?.['name']??'u8'});},'u16'(a){return uIntBcsType({'readMethod':'read16','writeMethod':'write16','size':0x2,'maxValue':0x2**0x10-0x1,...a,'name':a?.['name']??'u16'});},'u32'(a){return uIntBcsType({'readMethod':'read32','writeMethod':'write32','size':0x4,'maxValue':0x2**0x20-0x1,...a,'name':a?.['name']??'u32'});},'u64'(a){return bigUIntBcsType({'readMethod':'read64','writeMethod':'write64','size':0x8,'maxValue':0x2n**0x40n-0x1n,...a,'name':a?.['name']??'u64'});},'u128'(a){return bigUIntBcsType({'readMethod':'read128','writeMethod':'write128','size':0x10,'maxValue':0x2n**0x80n-0x1n,...a,'name':a?.['name']??'u128'});},'u256'(a){return bigUIntBcsType({'readMethod':'read256','writeMethod':'write256','size':0x20,'maxValue':0x2n**0x100n-0x1n,...a,'name':a?.['name']??'u256'});},'bool'(a){return fixedSizeBcsType({'size':0x1,'read':b=>b['read8']()===0x1,'write':(b,c)=>c['write8'](b?0x1:0x0),...a,'name':a?.['name']??'bool','validate':b=>{a?.['validate']?.(b);if(typeof b!=='boolean')throw new TypeError('Expected\x20boolean,\x20found\x20'+typeof b);}});},'uleb128'(a){return dynamicSizeBcsType({'read':b=>b['readULEB'](),'serialize':b=>{return Uint8Array['from'](ulebEncode(b));},...a,'name':a?.['name']??'uleb128'});},'bytes'(a,b){return fixedSizeBcsType({'size':a,'read':c=>c['readBytes'](a),'write':(c,d)=>{d['writeBytes'](new Uint8Array(c));},...b,'name':b?.['name']??'bytes['+a+']','validate':c=>{b?.['validate']?.(c);if(!c||typeof c!=='object'||!('length'in c))throw new TypeError('Expected\x20array,\x20found\x20'+typeof c);if(c['length']!==a)throw new TypeError('Expected\x20array\x20of\x20length\x20'+a+',\x20found\x20'+c['length']);}});},'byteVector'(a){return new BcsType({'read':b=>{const c=b['readULEB']();return b['readBytes'](c);},'write':(b,c)=>{const d=new Uint8Array(b);c['writeULEB'](d['length']),c['writeBytes'](d);},...a,'name':a?.['name']??'vector<u8>','serializedSize':b=>{const c='length'in b?b['length']:null;return c==null?null:ulebEncode(c)['length']+c;},'validate':b=>{a?.['validate']?.(b);if(!b||typeof b!=='object'||!('length'in b))throw new TypeError('Expected\x20array,\x20found\x20'+typeof b);}});},'string'(a){return stringLikeBcsType({'toBytes':b=>new TextEncoder()['encode'](b),'fromBytes':b=>new TextDecoder()['decode'](b),...a,'name':a?.['name']??'string'});},'fixedArray':fixedArray,'option':option,'vector':vector,'tuple'(a,b){return new BcsTuple({'fields':a,...b});},'struct'(a,b,c){return new BcsStruct({'name':a,'fields':b,...c});},'enum'(a,b,c){return new BcsEnum({'name':a,'fields':b,...c});},'map':map,'lazy'(a){return lazyBcsType(a);}};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { toBase58, fromBase58, toBase64, fromBase64, toHex, fromHex } from "../utils/index.js";
|
|
2
|
+
import type { BcsTypeOptions } from "./bcs-type.js";
|
|
3
|
+
import { BcsType, BcsStruct, BcsEnum, BcsTuple, isSerializedBcs, SerializedBcs } from "./bcs-type.js";
|
|
4
|
+
import { bcs } from "./bcs.js";
|
|
5
|
+
import { BcsReader } from "./reader.js";
|
|
6
|
+
import type { EnumInputShape, EnumOutputShape, EnumOutputShapeWithKeys, InferBcsInput, InferBcsType } from "./types.js";
|
|
7
|
+
import { decodeStr, encodeStr, splitGenericParameters } from "./utils.js";
|
|
8
|
+
import type { BcsWriterOptions } from "./writer.js";
|
|
9
|
+
import { BcsWriter } from "./writer.js";
|
|
10
|
+
export { bcs, BcsType, BcsStruct, BcsEnum, BcsTuple, type BcsTypeOptions, SerializedBcs, isSerializedBcs, toBase58, fromBase58, toBase64, fromBase64, toHex, fromHex, encodeStr, decodeStr, splitGenericParameters, BcsReader, BcsWriter, type BcsWriterOptions, type InferBcsInput, type InferBcsType, type EnumOutputShape, type EnumInputShape, type EnumOutputShapeWithKeys, };
|
|
11
|
+
export declare const toB58: (buffer: Uint8Array) => string;
|
|
12
|
+
export declare const fromB58: (str: string) => Uint8Array<ArrayBuffer>;
|
|
13
|
+
export declare const toB64: typeof toBase64;
|
|
14
|
+
export declare const fromB64: typeof fromBase64;
|
|
15
|
+
export declare const toHEX: typeof toHex;
|
|
16
|
+
export declare const fromHEX: typeof fromHex;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{toBase58,fromBase58,toBase64,fromBase64,toHex,fromHex}from'../utils/index.js';import{BcsType,BcsStruct,BcsEnum,BcsTuple,isSerializedBcs,SerializedBcs}from'./bcs-type.js';import{bcs}from'./bcs.js';import{BcsReader}from'./reader.js';import{decodeStr,encodeStr,splitGenericParameters}from'./utils.js';import{BcsWriter}from'./writer.js';export{bcs,BcsType,BcsStruct,BcsEnum,BcsTuple,SerializedBcs,isSerializedBcs,toBase58,fromBase58,toBase64,fromBase64,toHex,fromHex,encodeStr,decodeStr,splitGenericParameters,BcsReader,BcsWriter};export const toB58=toBase58;export const fromB58=fromBase58;export const toB64=toBase64;export const fromB64=fromBase64;export const toHEX=toHex;export const fromHEX=fromHex;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class BcsReader {
|
|
2
|
+
private dataView;
|
|
3
|
+
private bytePosition;
|
|
4
|
+
constructor(data: Uint8Array);
|
|
5
|
+
shift(bytes: number): this;
|
|
6
|
+
read8(): number;
|
|
7
|
+
read16(): number;
|
|
8
|
+
read32(): number;
|
|
9
|
+
read64(): string;
|
|
10
|
+
read128(): string;
|
|
11
|
+
read256(): string;
|
|
12
|
+
readBytes(num: number): Uint8Array;
|
|
13
|
+
readULEB(): number;
|
|
14
|
+
readVec(cb: (reader: BcsReader, i: number, length: number) => any): any[];
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ulebDecode}from'./uleb.js';export class BcsReader{['dataView'];['bytePosition']=0x0;constructor(a){this['dataView']=new DataView(a['buffer'],a['byteOffset'],a['byteLength']);}['shift'](a){return this['bytePosition']+=a,this;}['read8'](){const a=this['dataView']['getUint8'](this['bytePosition']);return this['shift'](0x1),a;}['read16'](){const a=this['dataView']['getUint16'](this['bytePosition'],!![]);return this['shift'](0x2),a;}['read32'](){const a=this['dataView']['getUint32'](this['bytePosition'],!![]);return this['shift'](0x4),a;}['read64'](){const a=this['read32'](),b=this['read32'](),c=b['toString'](0x10)+a['toString'](0x10)['padStart'](0x8,'0');return BigInt('0x'+c)['toString'](0xa);}['read128'](){const a=BigInt(this['read64']()),b=BigInt(this['read64']()),c=b['toString'](0x10)+a['toString'](0x10)['padStart'](0x10,'0');return BigInt('0x'+c)['toString'](0xa);}['read256'](){const a=BigInt(this['read128']()),b=BigInt(this['read128']()),c=b['toString'](0x10)+a['toString'](0x10)['padStart'](0x20,'0');return BigInt('0x'+c)['toString'](0xa);}['readBytes'](a){const b=this['bytePosition']+this['dataView']['byteOffset'],c=new Uint8Array(this['dataView']['buffer'],b,a);return this['shift'](a),c;}['readULEB'](){const a=this['bytePosition']+this['dataView']['byteOffset'],b=new Uint8Array(this['dataView']['buffer'],a),{value:c,length:d}=ulebDecode(b);return this['shift'](d),c;}['readVec'](a){const b=this['readULEB'](),c=[];for(let d=0x0;d<b;d++){c['push'](a(this,d,b));}return c;}}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Simplify } from "../utils/index.js";
|
|
2
|
+
import type { BcsType } from "./bcs-type.js";
|
|
3
|
+
export type Encoding = "base58" | "base64" | "hex";
|
|
4
|
+
export type InferBcsType<T extends BcsType<any>> = T extends BcsType<infer U, any> ? U : never;
|
|
5
|
+
export type InferBcsInput<T extends BcsType<any, any>> = T extends BcsType<any, infer U> ? U : never;
|
|
6
|
+
export type EnumOutputShape<T extends Record<string, unknown>, Keys extends string = Extract<keyof T, string>, Values = T[keyof T] extends infer Type ? Type extends BcsType<infer U> ? U : never : never> = 0 extends Values ? EnumOutputShapeWithKeys<T, never> : 0n extends Values ? EnumOutputShapeWithKeys<T, never> : "" extends Values ? EnumOutputShapeWithKeys<T, never> : false extends Values ? EnumOutputShapeWithKeys<T, never> : EnumOutputShapeWithKeys<T, Keys>;
|
|
7
|
+
export type EnumOutputShapeWithKeys<T extends Record<string, unknown>, Keys extends string> = {
|
|
8
|
+
[K in keyof T]: Exclude<Keys, K> extends infer Empty extends string ? Simplify<{
|
|
9
|
+
[K2 in K]: T[K];
|
|
10
|
+
} & {
|
|
11
|
+
[K in Empty]?: never;
|
|
12
|
+
} & {
|
|
13
|
+
$kind: K;
|
|
14
|
+
}> : never;
|
|
15
|
+
}[keyof T];
|
|
16
|
+
export type EnumInputShape<T extends Record<string, unknown>> = {
|
|
17
|
+
[K in keyof T]: {
|
|
18
|
+
[K2 in K]: T[K];
|
|
19
|
+
};
|
|
20
|
+
}[keyof T];
|
|
21
|
+
export type JoinString<T, Sep extends string> = T extends readonly [
|
|
22
|
+
infer F extends string,
|
|
23
|
+
...infer R extends string[]
|
|
24
|
+
] ? [] extends R ? F : `${F}${Sep}${JoinString<R, Sep>}` : "";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function ulebEncode(a){let b=BigInt(a);const c=[];let d=0x0;if(b===0x0n)return[0x0];while(b>0x0){c[d]=Number(b&0x7fn),b>>=0x7n,b>0x0n&&(c[d]|=0x80),d+=0x1;}return c;}export function ulebDecode(a){let b=0x0n,c=0x0n,d=0x0;while(!![]){if(d>=a['length'])throw new Error('ULEB\x20decode\x20error:\x20buffer\x20overflow');const e=a[d];d+=0x1,b+=BigInt(e&0x7f)<<c;if((e&0x80)===0x0)break;c+=0x7n;}if(b>BigInt(Number['MAX_SAFE_INTEGER']))throw new Error('ULEB\x20decode\x20error:\x20value\x20exceeds\x20MAX_SAFE_INTEGER');return{'value':Number(b),'length':d};}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Encoding } from "./types.js";
|
|
2
|
+
export declare function encodeStr(data: Uint8Array, encoding: Encoding): string;
|
|
3
|
+
export declare function decodeStr(data: string, encoding: Encoding): Uint8Array;
|
|
4
|
+
export declare function splitGenericParameters(str: string, genericSeparators?: [string, string]): any[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fromBase58,fromBase64,fromHex,toBase58,toBase64,toHex}from'../utils/index.js';export function encodeStr(a,b){switch(b){case'base58':return toBase58(a);case'base64':return toBase64(a);case'hex':return toHex(a);default:throw new Error('Unsupported\x20encoding,\x20supported\x20values\x20are:\x20base64,\x20hex');}}export function decodeStr(a,b){switch(b){case'base58':return fromBase58(a);case'base64':return fromBase64(a);case'hex':return fromHex(a);default:throw new Error('Unsupported\x20encoding,\x20supported\x20values\x20are:\x20base64,\x20hex');}}export function splitGenericParameters(a,b=['<','>']){const [c,d]=b,e=[];let f='',g=0x0;for(let h=0x0;h<a['length'];h++){const j=a[h];j===c&&g++;j===d&&g--;if(g===0x0&&j===','){e['push'](f['trim']()),f='';continue;}f+=j;}return e['push'](f['trim']()),e;}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Encoding } from "./types.js";
|
|
2
|
+
export interface BcsWriterOptions {
|
|
3
|
+
initialSize?: number;
|
|
4
|
+
maxSize?: number;
|
|
5
|
+
allocateSize?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class BcsWriter {
|
|
8
|
+
private dataView;
|
|
9
|
+
private bytePosition;
|
|
10
|
+
private size;
|
|
11
|
+
private maxSize;
|
|
12
|
+
private allocateSize;
|
|
13
|
+
constructor({ initialSize, maxSize, allocateSize, }?: BcsWriterOptions);
|
|
14
|
+
private ensureSizeOrGrow;
|
|
15
|
+
shift(bytes: number): this;
|
|
16
|
+
write8(value: number | bigint): this;
|
|
17
|
+
writeBytes(bytes: Uint8Array): this;
|
|
18
|
+
write16(value: number | bigint): this;
|
|
19
|
+
write32(value: number | bigint): this;
|
|
20
|
+
write64(value: number | bigint): this;
|
|
21
|
+
write128(value: number | bigint): this;
|
|
22
|
+
write256(value: number | bigint): this;
|
|
23
|
+
writeULEB(value: number): this;
|
|
24
|
+
writeVec(vector: any[], cb: (writer: BcsWriter, el: any, i: number, len: number) => void): this;
|
|
25
|
+
[Symbol.iterator](): Iterator<number, Iterable<number>>;
|
|
26
|
+
toBytes(): Uint8Array<ArrayBuffer>;
|
|
27
|
+
toString(encoding: Encoding): string;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ulebEncode}from'./uleb.js';import{encodeStr}from'./utils.js';export class BcsWriter{['dataView'];['bytePosition']=0x0;['size'];['maxSize'];['allocateSize'];constructor({initialSize:initialSize=0x400,maxSize:maxSize=Infinity,allocateSize:allocateSize=0x400}={}){this['size']=initialSize,this['maxSize']=maxSize,this['allocateSize']=allocateSize,this['dataView']=new DataView(new ArrayBuffer(initialSize));}['ensureSizeOrGrow'](a){const b=this['bytePosition']+a;if(b>this['size']){const c=Math['min'](this['maxSize'],Math['max'](this['size']+b,this['size']+this['allocateSize']));if(b>c)throw new Error('Attempting\x20to\x20serialize\x20to\x20BCS,\x20but\x20buffer\x20does\x20not\x20have\x20enough\x20size.\x20Allocated\x20size:\x20'+this['size']+',\x20Max\x20size:\x20'+this['maxSize']+',\x20Required\x20size:\x20'+b);this['size']=c;const d=new ArrayBuffer(this['size']);new Uint8Array(d)['set'](new Uint8Array(this['dataView']['buffer'])),this['dataView']=new DataView(d);}}['shift'](a){return this['bytePosition']+=a,this;}['write8'](a){return this['ensureSizeOrGrow'](0x1),this['dataView']['setUint8'](this['bytePosition'],Number(a)),this['shift'](0x1);}['writeBytes'](a){this['ensureSizeOrGrow'](a['length']);for(let b=0x0;b<a['length'];b++){this['dataView']['setUint8'](this['bytePosition']+b,a[b]);}return this['shift'](a['length']);}['write16'](a){return this['ensureSizeOrGrow'](0x2),this['dataView']['setUint16'](this['bytePosition'],Number(a),!![]),this['shift'](0x2);}['write32'](a){return this['ensureSizeOrGrow'](0x4),this['dataView']['setUint32'](this['bytePosition'],Number(a),!![]),this['shift'](0x4);}['write64'](a){return toLittleEndian(BigInt(a),0x8)['forEach'](b=>this['write8'](b)),this;}['write128'](a){return toLittleEndian(BigInt(a),0x10)['forEach'](b=>this['write8'](b)),this;}['write256'](a){return toLittleEndian(BigInt(a),0x20)['forEach'](b=>this['write8'](b)),this;}['writeULEB'](a){return ulebEncode(a)['forEach'](b=>this['write8'](b)),this;}['writeVec'](a,b){return this['writeULEB'](a['length']),Array['from'](a)['forEach']((c,d)=>b(this,c,d,a['length'])),this;}*[Symbol['iterator']](){for(let a=0x0;a<this['bytePosition'];a++){yield this['dataView']['getUint8'](a);}return this['toBytes']();}['toBytes'](){return new Uint8Array(this['dataView']['buffer']['slice'](0x0,this['bytePosition']));}['toString'](a){return encodeStr(this['toBytes'](),a);}}function toLittleEndian(a,b){const c=new Uint8Array(b);let d=0x0;while(a>0x0){c[d]=Number(a%BigInt(0x100)),a=a/BigInt(0x100),d+=0x1;}return c;}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{base58}from'@scure/base';export const toBase58=a=>base58['encode'](a);export const fromBase58=a=>base58['decode'](a);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function fromBase64(a){return Uint8Array['from'](atob(a),b=>b['charCodeAt'](0x0));}const CHUNK_SIZE=0x2000;export function toBase64(a){if(a['length']<CHUNK_SIZE)return btoa(String['fromCharCode'](...a));let b='';for(var c=0x0;c<a['length'];c+=CHUNK_SIZE){const d=a['slice'](c,c+CHUNK_SIZE);b+=String['fromCharCode'](...d);}return btoa(b);}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function chunk<T>(array: readonly T[], size: number): T[][];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function chunk(a,b){return Array['from']({'length':Math['ceil'](a['length']/b)},(c,d)=>{return a['slice'](d*b,(d+0x1)*b);});}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare class DataLoader<K, V, C = K> {
|
|
2
|
+
constructor(batchLoadFn: DataLoader.BatchLoadFn<K, V>, options?: DataLoader.Options<K, V, C>);
|
|
3
|
+
_batchLoadFn: DataLoader.BatchLoadFn<K, V>;
|
|
4
|
+
_maxBatchSize: number;
|
|
5
|
+
_batchScheduleFn: (cb: () => void) => void;
|
|
6
|
+
_cacheKeyFn: (key: K) => C;
|
|
7
|
+
_cacheMap: DataLoader.CacheMap<C, Promise<V>> | null;
|
|
8
|
+
_batch: Batch<K, V> | null;
|
|
9
|
+
load(key: K): Promise<V>;
|
|
10
|
+
loadMany(keys: ReadonlyArray<K>): Promise<Array<V | Error>>;
|
|
11
|
+
clear(key: K): this;
|
|
12
|
+
clearAll(): this;
|
|
13
|
+
prime(key: K, value: V | Promise<V> | Error): this;
|
|
14
|
+
name: string | null;
|
|
15
|
+
}
|
|
16
|
+
type Batch<K, V> = {
|
|
17
|
+
hasDispatched: boolean;
|
|
18
|
+
keys: Array<K>;
|
|
19
|
+
callbacks: Array<{
|
|
20
|
+
resolve: (value: V) => void;
|
|
21
|
+
reject: (error: Error) => void;
|
|
22
|
+
}>;
|
|
23
|
+
cacheHits?: Array<() => void>;
|
|
24
|
+
};
|
|
25
|
+
export declare namespace DataLoader {
|
|
26
|
+
type CacheMap<K, V> = {
|
|
27
|
+
get(key: K): V | void;
|
|
28
|
+
set(key: K, value: V): any;
|
|
29
|
+
delete(key: K): any;
|
|
30
|
+
clear(): any;
|
|
31
|
+
};
|
|
32
|
+
type BatchLoadFn<K, V> = (keys: ReadonlyArray<K>) => PromiseLike<ArrayLike<V | Error>>;
|
|
33
|
+
type Options<K, V, C = K> = {
|
|
34
|
+
batch?: boolean;
|
|
35
|
+
maxBatchSize?: number;
|
|
36
|
+
batchScheduleFn?: (callback: () => void) => void;
|
|
37
|
+
cache?: boolean;
|
|
38
|
+
cacheKeyFn?: (key: K) => C;
|
|
39
|
+
cacheMap?: CacheMap<C, Promise<V>> | null;
|
|
40
|
+
name?: string | null;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class DataLoader{constructor(a,b){if(typeof a!=='function')throw new TypeError('DataLoader\x20must\x20be\x20constructed\x20with\x20a\x20function\x20which\x20accepts\x20'+('Array<key>\x20and\x20returns\x20Promise<Array<value>>,\x20but\x20got:\x20'+a+'.'));this['_batchLoadFn']=a,this['_maxBatchSize']=getValidMaxBatchSize(b),this['_batchScheduleFn']=getValidBatchScheduleFn(b),this['_cacheKeyFn']=getValidCacheKeyFn(b),this['_cacheMap']=getValidCacheMap(b),this['_batch']=null,this['name']=getValidName(b);}['_batchLoadFn'];['_maxBatchSize'];['_batchScheduleFn'];['_cacheKeyFn'];['_cacheMap'];['_batch'];['load'](a){if(a===null||a===undefined)throw new TypeError('The\x20loader.load()\x20function\x20must\x20be\x20called\x20with\x20a\x20value,\x20but\x20got:\x20'+String(a)+'.');const b=getCurrentBatch(this),c=this['_cacheMap'];let d;if(c){d=this['_cacheKeyFn'](a);const f=c['get'](d);if(f){const g=b['cacheHits']||(b['cacheHits']=[]);return new Promise(h=>{g['push'](()=>{h(f);});});}}b['keys']['push'](a);const e=new Promise((h,i)=>{b['callbacks']['push']({'resolve':h,'reject':i});});return c&&c['set'](d,e),e;}['loadMany'](a){if(!isArrayLike(a))throw new TypeError('The\x20loader.loadMany()\x20function\x20must\x20be\x20called\x20with\x20Array<key>,\x20but\x20got:\x20'+a+'.');const b=[];for(let c=0x0;c<a['length'];c++){b['push'](this['load'](a[c])['catch'](d=>d));}return Promise['all'](b);}['clear'](a){const b=this['_cacheMap'];if(b){const c=this['_cacheKeyFn'](a);b['delete'](c);}return this;}['clearAll'](){const a=this['_cacheMap'];return a&&a['clear'](),this;}['prime'](a,b){const c=this['_cacheMap'];if(c){const d=this['_cacheKeyFn'](a);if(c['get'](d)===undefined){let e;b instanceof Error?(e=Promise['reject'](b),e['catch'](()=>{})):e=Promise['resolve'](b),c['set'](d,e);}}return this;}['name'];}const enqueuePostPromiseJob=typeof process==='object'&&typeof process['nextTick']==='function'?function(a){!resolvedPromise&&(resolvedPromise=Promise['resolve']()),resolvedPromise['then'](()=>{process['nextTick'](a);});}:typeof setImmediate==='function'?function(a){setImmediate(a);}:function(a){setTimeout(a);};let resolvedPromise;function getCurrentBatch(a){const b=a['_batch'];if(b!==null&&!b['hasDispatched']&&b['keys']['length']<a['_maxBatchSize'])return b;const c={'hasDispatched':![],'keys':[],'callbacks':[]};return a['_batch']=c,a['_batchScheduleFn'](()=>{dispatchBatch(a,c);}),c;}function dispatchBatch(a,b){b['hasDispatched']=!![];if(b['keys']['length']===0x0){resolveCacheHits(b);return;}let c;try{c=a['_batchLoadFn'](b['keys']);}catch(d){return failedDispatch(a,b,new TypeError('DataLoader\x20must\x20be\x20constructed\x20with\x20a\x20function\x20which\x20accepts\x20'+'Array<key>\x20and\x20returns\x20Promise<Array<value>>,\x20but\x20the\x20function\x20'+('errored\x20synchronously:\x20'+String(d)+'.')));}if(!c||typeof c['then']!=='function')return failedDispatch(a,b,new TypeError('DataLoader\x20must\x20be\x20constructed\x20with\x20a\x20function\x20which\x20accepts\x20'+'Array<key>\x20and\x20returns\x20Promise<Array<value>>,\x20but\x20the\x20function\x20did\x20'+('not\x20return\x20a\x20Promise:\x20'+String(c)+'.')));Promise['resolve'](c)['then'](f=>{if(!isArrayLike(f))throw new TypeError('DataLoader\x20must\x20be\x20constructed\x20with\x20a\x20function\x20which\x20accepts\x20'+'Array<key>\x20and\x20returns\x20Promise<Array<value>>,\x20but\x20the\x20function\x20did\x20'+('not\x20return\x20a\x20Promise\x20of\x20an\x20Array:\x20'+String(f)+'.'));if(f['length']!==b['keys']['length'])throw new TypeError('DataLoader\x20must\x20be\x20constructed\x20with\x20a\x20function\x20which\x20accepts\x20'+'Array<key>\x20and\x20returns\x20Promise<Array<value>>,\x20but\x20the\x20function\x20did\x20'+'not\x20return\x20a\x20Promise\x20of\x20an\x20Array\x20of\x20the\x20same\x20length\x20as\x20the\x20Array\x20'+'of\x20keys.'+('\x0a\x0aKeys:\x0a'+String(b['keys']))+('\x0a\x0aValues:\x0a'+String(f)));resolveCacheHits(b);for(let g=0x0;g<b['callbacks']['length'];g++){const h=f[g];h instanceof Error?b['callbacks'][g]['reject'](h):b['callbacks'][g]['resolve'](h);}})['catch'](f=>{failedDispatch(a,b,f);});}function failedDispatch(a,b,c){resolveCacheHits(b);for(let d=0x0;d<b['keys']['length'];d++){a['clear'](b['keys'][d]),b['callbacks'][d]['reject'](c);}}function resolveCacheHits(a){if(a['cacheHits'])for(let b=0x0;b<a['cacheHits']['length'];b++){a['cacheHits'][b]();}}function getValidMaxBatchSize(a){const b=!a||a['batch']!==![];if(!b)return 0x1;const c=a&&a['maxBatchSize'];if(c===undefined)return Infinity;if(typeof c!=='number'||c<0x1)throw new TypeError('maxBatchSize\x20must\x20be\x20a\x20positive\x20number:\x20'+c);return c;}function getValidBatchScheduleFn(a){const b=a&&a['batchScheduleFn'];if(b===undefined)return enqueuePostPromiseJob;if(typeof b!=='function')throw new TypeError('batchScheduleFn\x20must\x20be\x20a\x20function:\x20'+b);return b;}function getValidCacheKeyFn(a){const b=a&&a['cacheKeyFn'];if(b===undefined)return c=>c;if(typeof b!=='function')throw new TypeError('cacheKeyFn\x20must\x20be\x20a\x20function:\x20'+b);return b;}function getValidCacheMap(a){const b=!a||a['cache']!==![];if(!b)return null;const c=a&&a['cacheMap'];if(c===undefined)return new Map();if(c!==null){const d=['get','set','delete','clear'],e=d['filter'](f=>c&&typeof c[f]!=='function');if(e['length']!==0x0)throw new TypeError('Custom\x20cacheMap\x20missing\x20methods:\x20'+e['join'](',\x20'));}return c;}function getValidName(a){if(a&&a['name'])return a['name'];return null;}function isArrayLike(a){return typeof a==='object'&&a!==null&&'length'in a&&typeof a['length']==='number'&&(a['length']===0x0||a['length']>0x0&&Object['prototype']['hasOwnProperty']['call'](a,a['length']-0x1));}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function fromHex(a){const b=a['startsWith']('0x')?a['slice'](0x2):a,c=b['length']%0x2===0x0?b:'0'+b,d=c['match'](/[0-9a-fA-F]{2}/g)?.['map'](e=>parseInt(e,0x10))??[];if(d['length']!==c['length']/0x2)throw new Error('Invalid\x20hex\x20string\x20'+a);return Uint8Array['from'](d);}export function toHex(a){return a['reduce']((b,c)=>b+c['toString'](0x10)['padStart'](0x2,'0'),'');}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { fromBase58, toBase58 } from "./b58.js";
|
|
2
|
+
export { fromBase64, toBase64 } from "./b64.js";
|
|
3
|
+
export { fromHex, toHex } from "./hex.js";
|
|
4
|
+
export type { Simplify, UnionToIntersection } from "./types.js";
|
|
5
|
+
export { chunk } from "./chunk.js";
|
|
6
|
+
export { promiseWithResolvers, type PromiseWithResolvers, } from "./with-resolver.js";
|
|
7
|
+
export { DataLoader } from "./dataloader.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{fromBase58,toBase58}from'./b58.js';export{fromBase64,toBase64}from'./b64.js';export{fromHex,toHex}from'./hex.js';export{chunk}from'./chunk.js';export{promiseWithResolvers}from'./with-resolver.js';export{DataLoader}from'./dataloader.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function promiseWithResolvers(){let a,b;const c=new Promise((d,e)=>{a=d,b=e;});return{'promise':c,'resolve':a,'reject':b};}
|