@haneullabs/haneul 2.5.1 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +129 -0
- package/README.md +36 -36
- package/dist/bcs/bcs.d.mts +6 -7
- package/dist/bcs/bcs.d.mts.map +1 -1
- package/dist/bcs/bcs.mjs.map +1 -1
- package/dist/bcs/effects.mjs.map +1 -1
- package/dist/bcs/index.d.mts +2 -2
- package/dist/bcs/index.d.mts.map +1 -1
- package/dist/bcs/index.mjs +2 -2
- package/dist/bcs/index.mjs.map +1 -1
- package/dist/bcs/pure.d.mts.map +1 -1
- package/dist/bcs/type-tag-serializer.d.mts.map +1 -1
- package/dist/bcs/types.d.mts +0 -1
- package/dist/bcs/types.d.mts.map +1 -1
- package/dist/client/cache.d.mts.map +1 -1
- package/dist/client/client.d.mts.map +1 -1
- package/dist/client/core-resolver.d.mts.map +1 -1
- package/dist/client/core-resolver.mjs +87 -68
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/client/core.d.mts +9 -8
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs +29 -10
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/errors.d.mts.map +1 -1
- package/dist/client/mvr.d.mts +0 -1
- package/dist/client/mvr.d.mts.map +1 -1
- package/dist/client/types.d.mts +110 -24
- package/dist/client/types.d.mts.map +1 -1
- package/dist/client/utils.d.mts.map +1 -1
- package/dist/client/utils.mjs +7 -7
- package/dist/client/utils.mjs.map +1 -1
- package/dist/cryptography/index.d.mts +2 -2
- package/dist/cryptography/index.mjs +2 -2
- package/dist/cryptography/intent.d.mts +2 -2
- package/dist/cryptography/intent.d.mts.map +1 -1
- package/dist/cryptography/intent.mjs +2 -2
- package/dist/cryptography/intent.mjs.map +1 -1
- package/dist/cryptography/keypair.d.mts +3 -3
- package/dist/cryptography/keypair.d.mts.map +1 -1
- package/dist/cryptography/keypair.mjs +3 -3
- package/dist/cryptography/keypair.mjs.map +1 -1
- package/dist/cryptography/mnemonics.d.mts +5 -5
- package/dist/cryptography/mnemonics.d.mts.map +1 -1
- package/dist/cryptography/mnemonics.mjs +7 -7
- package/dist/cryptography/mnemonics.mjs.map +1 -1
- package/dist/cryptography/publickey.d.mts +2 -3
- package/dist/cryptography/publickey.d.mts.map +1 -1
- package/dist/cryptography/publickey.mjs +10 -10
- package/dist/cryptography/publickey.mjs.map +1 -1
- package/dist/cryptography/signature-scheme.d.mts.map +1 -1
- package/dist/cryptography/signature.d.mts +10 -13
- package/dist/cryptography/signature.d.mts.map +1 -1
- package/dist/cryptography/signature.mjs +2 -2
- package/dist/cryptography/signature.mjs.map +1 -1
- package/dist/faucet/faucet.d.mts +2 -2
- package/dist/faucet/faucet.d.mts.map +1 -1
- package/dist/faucet/faucet.mjs +2 -2
- package/dist/faucet/faucet.mjs.map +1 -1
- package/dist/faucet/index.d.mts +2 -2
- package/dist/faucet/index.mjs +2 -2
- package/dist/graphql/client.d.mts +20 -5
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +55 -7
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +6 -5
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +43 -47
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.d.mts +0 -1
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +46 -10
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +706 -98
- package/dist/graphql/generated/tada-env.d.mts.map +1 -1
- package/dist/graphql/index.d.mts +2 -2
- package/dist/graphql/index.mjs +2 -2
- package/dist/graphql/schema/index.d.mts +0 -1
- package/dist/graphql/schema/index.d.mts.map +1 -1
- package/dist/graphql/types.d.mts.map +1 -1
- package/dist/grpc/client.d.mts +20 -5
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +47 -7
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +6 -5
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +35 -34
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/index.d.mts +2 -2
- package/dist/grpc/index.mjs +2 -2
- package/dist/grpc/proto/google/protobuf/any.d.mts +0 -1
- package/dist/grpc/proto/google/protobuf/any.d.mts.map +1 -1
- package/dist/grpc/proto/google/protobuf/duration.d.mts +0 -1
- package/dist/grpc/proto/google/protobuf/duration.d.mts.map +1 -1
- package/dist/grpc/proto/google/protobuf/field_mask.d.mts +0 -1
- package/dist/grpc/proto/google/protobuf/field_mask.d.mts.map +1 -1
- package/dist/grpc/proto/google/protobuf/struct.d.mts +1 -2
- package/dist/grpc/proto/google/protobuf/struct.d.mts.map +1 -1
- package/dist/grpc/proto/google/protobuf/timestamp.d.mts +0 -1
- package/dist/grpc/proto/google/protobuf/timestamp.d.mts.map +1 -1
- package/dist/grpc/proto/google/rpc/status.d.mts +0 -1
- package/dist/grpc/proto/google/rpc/status.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/argument.d.mts +1 -2
- package/dist/grpc/proto/haneul/rpc/v2/argument.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/balance_change.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/balance_change.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/bcs.d.mts +1 -2
- package/dist/grpc/proto/haneul/rpc/v2/bcs.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/bcs.mjs.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/checkpoint.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/checkpoint.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/checkpoint_contents.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/checkpoint_contents.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/checkpoint_summary.d.mts +1 -2
- package/dist/grpc/proto/haneul/rpc/v2/checkpoint_summary.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/effects.d.mts +5 -6
- package/dist/grpc/proto/haneul/rpc/v2/effects.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/epoch.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/epoch.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/error_reason.d.mts +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/error_reason.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/event.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/event.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/executed_transaction.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/executed_transaction.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/execution_status.d.mts +8 -9
- package/dist/grpc/proto/haneul/rpc/v2/execution_status.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/execution_status.mjs +4 -4
- package/dist/grpc/proto/haneul/rpc/v2/execution_status.mjs.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/gas_cost_summary.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/gas_cost_summary.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/input.d.mts +3 -4
- package/dist/grpc/proto/haneul/rpc/v2/input.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/jwk.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/jwk.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/ledger_service.client.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/ledger_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/ledger_service.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/ledger_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/move_package.d.mts +5 -6
- package/dist/grpc/proto/haneul/rpc/v2/move_package.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/move_package_service.client.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/move_package_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/move_package_service.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/move_package_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/name_service.client.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/name_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/name_service.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/name_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/object.d.mts +38 -2
- package/dist/grpc/proto/haneul/rpc/v2/object.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/object.mjs +26 -1
- package/dist/grpc/proto/haneul/rpc/v2/object.mjs.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/object_reference.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/object_reference.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/owner.d.mts +1 -2
- package/dist/grpc/proto/haneul/rpc/v2/owner.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/protocol_config.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/protocol_config.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature.d.mts +1 -2
- package/dist/grpc/proto/haneul/rpc/v2/signature.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature.mjs.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature_scheme.d.mts +2 -2
- package/dist/grpc/proto/haneul/rpc/v2/signature_scheme.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature_scheme.mjs +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature_scheme.mjs.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature_verification_service.client.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/signature_verification_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature_verification_service.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature_verification_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/state_service.client.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/state_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/state_service.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/state_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/subscription_service.client.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/subscription_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/subscription_service.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/subscription_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/system_state.d.mts +3 -4
- package/dist/grpc/proto/haneul/rpc/v2/system_state.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/system_state.mjs +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/system_state.mjs.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/transaction.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/transaction.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.client.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.d.mts +9 -2
- package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.mjs +23 -12
- package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.mjs.map +1 -1
- package/dist/grpc/proto/types.d.mts +2 -2
- package/dist/grpc/proto/types.d.mts.map +1 -1
- package/dist/grpc/proto/types.mjs +2 -1
- package/dist/jsonRpc/client.d.mts +4 -7
- package/dist/jsonRpc/client.d.mts.map +1 -1
- package/dist/jsonRpc/client.mjs +4 -33
- package/dist/jsonRpc/client.mjs.map +1 -1
- package/dist/jsonRpc/core.d.mts +8 -15
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +81 -34
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/jsonRpc/errors.d.mts.map +1 -1
- package/dist/jsonRpc/http-transport.d.mts +1 -17
- package/dist/jsonRpc/http-transport.d.mts.map +1 -1
- package/dist/jsonRpc/http-transport.mjs +0 -23
- package/dist/jsonRpc/http-transport.mjs.map +1 -1
- package/dist/jsonRpc/index.d.mts +3 -3
- package/dist/jsonRpc/network.d.mts.map +1 -1
- package/dist/jsonRpc/types/chain.d.mts.map +1 -1
- package/dist/jsonRpc/types/changes.d.mts.map +1 -1
- package/dist/jsonRpc/types/coins.d.mts.map +1 -1
- package/dist/jsonRpc/types/common.d.mts +1 -2
- package/dist/jsonRpc/types/common.d.mts.map +1 -1
- package/dist/jsonRpc/types/generated.d.mts +101 -129
- package/dist/jsonRpc/types/generated.d.mts.map +1 -1
- package/dist/jsonRpc/types/index.d.mts +1 -1
- package/dist/jsonRpc/types/params.d.mts +9 -14
- package/dist/jsonRpc/types/params.d.mts.map +1 -1
- package/dist/keypairs/ed25519/keypair.d.mts +8 -6
- package/dist/keypairs/ed25519/keypair.d.mts.map +1 -1
- package/dist/keypairs/ed25519/keypair.mjs +13 -9
- package/dist/keypairs/ed25519/keypair.mjs.map +1 -1
- package/dist/keypairs/ed25519/publickey.d.mts +0 -1
- package/dist/keypairs/ed25519/publickey.d.mts.map +1 -1
- package/dist/keypairs/passkey/keypair.d.mts +12 -5
- package/dist/keypairs/passkey/keypair.d.mts.map +1 -1
- package/dist/keypairs/passkey/keypair.mjs +20 -7
- package/dist/keypairs/passkey/keypair.mjs.map +1 -1
- package/dist/keypairs/passkey/publickey.d.mts +0 -1
- package/dist/keypairs/passkey/publickey.d.mts.map +1 -1
- package/dist/keypairs/passkey/types.d.mts.map +1 -1
- package/dist/keypairs/secp256k1/keypair.d.mts +3 -3
- package/dist/keypairs/secp256k1/keypair.d.mts.map +1 -1
- package/dist/keypairs/secp256k1/keypair.mjs +6 -6
- package/dist/keypairs/secp256k1/keypair.mjs.map +1 -1
- package/dist/keypairs/secp256k1/publickey.d.mts +0 -1
- package/dist/keypairs/secp256k1/publickey.d.mts.map +1 -1
- package/dist/keypairs/secp256r1/keypair.d.mts +3 -3
- package/dist/keypairs/secp256r1/keypair.d.mts.map +1 -1
- package/dist/keypairs/secp256r1/keypair.mjs +6 -6
- package/dist/keypairs/secp256r1/keypair.mjs.map +1 -1
- package/dist/keypairs/secp256r1/publickey.d.mts +0 -1
- package/dist/keypairs/secp256r1/publickey.d.mts.map +1 -1
- package/dist/multisig/publickey.d.mts +1 -0
- package/dist/multisig/publickey.d.mts.map +1 -1
- package/dist/multisig/publickey.mjs +8 -8
- package/dist/multisig/publickey.mjs.map +1 -1
- package/dist/multisig/signer.d.mts.map +1 -1
- package/dist/transactions/Arguments.d.mts.map +1 -1
- package/dist/transactions/Commands.d.mts +1 -1
- package/dist/transactions/Commands.d.mts.map +1 -1
- package/dist/transactions/Commands.mjs.map +1 -1
- package/dist/transactions/Inputs.d.mts.map +1 -1
- package/dist/transactions/ObjectCache.d.mts +3 -3
- package/dist/transactions/ObjectCache.d.mts.map +1 -1
- package/dist/transactions/Transaction.d.mts +32 -6
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/Transaction.mjs +23 -1
- package/dist/transactions/Transaction.mjs.map +1 -1
- package/dist/transactions/TransactionData.d.mts.map +1 -1
- package/dist/transactions/TransactionData.mjs +8 -8
- package/dist/transactions/TransactionData.mjs.map +1 -1
- package/dist/transactions/data/internal.d.mts +109 -109
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/internal.mjs.map +1 -1
- package/dist/transactions/data/v1.d.mts +220 -221
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/transactions/data/v2.d.mts.map +1 -1
- package/dist/transactions/data/v2.mjs.map +1 -1
- package/dist/transactions/executor/caching.mjs +2 -2
- package/dist/transactions/executor/caching.mjs.map +1 -1
- package/dist/transactions/executor/parallel.d.mts +1 -1
- package/dist/transactions/executor/parallel.d.mts.map +1 -1
- package/dist/transactions/executor/parallel.mjs +1 -1
- package/dist/transactions/executor/parallel.mjs.map +1 -1
- package/dist/transactions/executor/serial.d.mts +3 -3
- package/dist/transactions/executor/serial.d.mts.map +1 -1
- package/dist/transactions/executor/serial.mjs.map +1 -1
- package/dist/transactions/intents/CoinWithBalance.d.mts.map +1 -1
- package/dist/transactions/intents/CoinWithBalance.mjs +174 -97
- package/dist/transactions/intents/CoinWithBalance.mjs.map +1 -1
- package/dist/transactions/object.d.mts.map +1 -1
- package/dist/transactions/pure.d.mts.map +1 -1
- package/dist/transactions/pure.mjs +12 -12
- package/dist/transactions/pure.mjs.map +1 -1
- package/dist/transactions/resolve.d.mts.map +1 -1
- package/dist/transactions/resolve.mjs +3 -3
- package/dist/transactions/resolve.mjs.map +1 -1
- package/dist/transactions/serializer.d.mts.map +1 -1
- package/dist/transactions/serializer.mjs +15 -15
- package/dist/transactions/serializer.mjs.map +1 -1
- package/dist/transactions/utils.d.mts +0 -1
- package/dist/transactions/utils.d.mts.map +1 -1
- package/dist/utils/coin-reservation.mjs +67 -0
- package/dist/utils/coin-reservation.mjs.map +1 -0
- package/dist/utils/constants.d.mts +2 -1
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +2 -1
- package/dist/utils/constants.mjs.map +1 -1
- package/dist/utils/derived-objects.d.mts +0 -1
- package/dist/utils/derived-objects.d.mts.map +1 -1
- package/dist/utils/dynamic-fields.d.mts.map +1 -1
- package/dist/utils/dynamic-fields.mjs +4 -4
- package/dist/utils/dynamic-fields.mjs.map +1 -1
- package/dist/utils/format.d.mts.map +1 -1
- package/dist/utils/haneul-types.d.mts.map +1 -1
- package/dist/utils/haneul-types.mjs +8 -0
- package/dist/utils/haneul-types.mjs.map +1 -1
- package/dist/utils/haneulns.d.mts.map +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.mjs +2 -2
- package/dist/utils/move-registry.d.mts.map +1 -1
- package/dist/verify/index.d.mts +2 -2
- package/dist/verify/index.mjs +2 -2
- package/dist/verify/verify.d.mts +2 -2
- package/dist/verify/verify.d.mts.map +1 -1
- package/dist/verify/verify.mjs +2 -2
- package/dist/verify/verify.mjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/address.d.mts.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/bcs.d.mts.map +1 -1
- package/dist/zklogin/jwt-decode.d.mts +0 -1
- package/dist/zklogin/jwt-decode.d.mts.map +1 -1
- package/dist/zklogin/jwt-utils.d.mts +0 -1
- package/dist/zklogin/jwt-utils.d.mts.map +1 -1
- package/dist/zklogin/nonce.d.mts.map +1 -1
- package/dist/zklogin/nonce.mjs +1 -1
- package/dist/zklogin/nonce.mjs.map +1 -1
- package/dist/zklogin/poseidon.d.mts.map +1 -1
- package/dist/zklogin/publickey.d.mts +0 -1
- package/dist/zklogin/publickey.d.mts.map +1 -1
- package/dist/zklogin/signature.d.mts.map +1 -1
- package/dist/zklogin/utils.d.mts.map +1 -1
- package/dist/zklogin/utils.mjs +1 -1
- package/dist/zklogin/utils.mjs.map +1 -1
- package/docs/bcs.md +132 -0
- package/docs/clients/core.md +616 -0
- package/docs/clients/graphql.md +99 -0
- package/docs/clients/grpc.md +152 -0
- package/docs/clients/index.md +93 -0
- package/docs/clients/json-rpc.md +235 -0
- package/docs/cryptography/keypairs.md +259 -0
- package/docs/cryptography/multisig.md +192 -0
- package/docs/cryptography/passkey.md +111 -0
- package/docs/cryptography/webcrypto-signer.md +81 -0
- package/docs/executors.md +148 -0
- package/docs/faucet.md +26 -0
- package/docs/hello-haneul.md +115 -0
- package/docs/index.md +56 -0
- package/docs/install.md +61 -0
- package/docs/llm-docs.md +32 -0
- package/docs/llms-index.md +66 -0
- package/docs/migrations/0.38.md +57 -0
- package/docs/migrations/haneul-1.0.md +454 -0
- package/docs/migrations/haneul-2.0/agent-prompt.md +42 -0
- package/docs/migrations/haneul-2.0/dapp-kit.md +350 -0
- package/docs/migrations/haneul-2.0/deepbook-v3.md +33 -0
- package/docs/migrations/haneul-2.0/haneul.md +341 -0
- package/docs/migrations/haneul-2.0/haneulns.md +42 -0
- package/docs/migrations/haneul-2.0/index.md +161 -0
- package/docs/migrations/haneul-2.0/json-rpc-migration.md +399 -0
- package/docs/migrations/haneul-2.0/kiosk.md +120 -0
- package/docs/migrations/haneul-2.0/sdk-maintainers.md +91 -0
- package/docs/migrations/haneul-2.0/seal.md +14 -0
- package/docs/migrations/haneul-2.0/wallet-builders.md +66 -0
- package/docs/migrations/haneul-2.0/walrus.md +41 -0
- package/docs/migrations/haneul-2.0/zksend.md +94 -0
- package/docs/plugins.md +255 -0
- package/docs/sdk-building.md +341 -0
- package/docs/transaction-building/basics.md +297 -0
- package/docs/transaction-building/gas.md +62 -0
- package/docs/transaction-building/intents.md +61 -0
- package/docs/transaction-building/offline.md +71 -0
- package/docs/transaction-building/sponsored-transactions.md +22 -0
- package/docs/utils/derived_objects.md +80 -0
- package/docs/utils/index.md +53 -0
- package/docs/zklogin.md +78 -0
- package/package.json +199 -199
- package/src/bcs/bcs.ts +13 -13
- package/src/bcs/effects.ts +20 -20
- package/src/bcs/index.ts +2 -2
- package/src/client/core-resolver.ts +150 -100
- package/src/client/core.ts +62 -22
- package/src/client/types.ts +109 -24
- package/src/cryptography/index.ts +2 -2
- package/src/cryptography/keypair.ts +2 -2
- package/src/cryptography/mnemonics.ts +7 -7
- package/src/cryptography/publickey.ts +8 -8
- package/src/faucet/faucet.ts +1 -1
- package/src/faucet/index.ts +1 -1
- package/src/graphql/client.ts +100 -8
- package/src/graphql/core.ts +73 -80
- package/src/graphql/generated/queries.ts +301 -51
- package/src/graphql/generated/schema.graphql +407 -104
- package/src/graphql/generated/tada-env.ts +779 -58
- package/src/graphql/index.ts +1 -1
- package/src/graphql/queries/getAllBalances.graphql +1 -1
- package/src/graphql/queries/getBalance.graphql +1 -1
- package/src/graphql/queries/getCoins.graphql +2 -2
- package/src/graphql/queries/getDynamicFields.graphql +9 -1
- package/src/graphql/queries/getMoveFunction.graphql +1 -1
- package/src/graphql/queries/getProtocolConfig.graphql +18 -0
- package/src/graphql/queries/nameService.graphql +1 -1
- package/src/graphql/queries/objects.graphql +11 -1
- package/src/graphql/queries/transactions.graphql +1 -3
- package/src/graphql/queries/verifyZkLoginSignature.graphql +1 -2
- package/src/grpc/client.ts +66 -8
- package/src/grpc/core.ts +74 -35
- package/src/grpc/index.ts +1 -1
- package/src/grpc/proto/haneul/rpc/v2/bcs.ts +1 -1
- package/src/grpc/proto/haneul/rpc/v2/execution_status.ts +4 -4
- package/src/grpc/proto/haneul/rpc/v2/object.ts +44 -0
- package/src/grpc/proto/haneul/rpc/v2/signature.ts +1 -1
- package/src/grpc/proto/haneul/rpc/v2/signature_scheme.ts +1 -1
- package/src/grpc/proto/haneul/rpc/v2/system_state.ts +4 -4
- package/src/grpc/proto/haneul/rpc/v2/transaction_execution_service.ts +16 -0
- package/src/jsonRpc/client.ts +5 -23
- package/src/jsonRpc/core.ts +114 -41
- package/src/jsonRpc/http-transport.ts +0 -52
- package/src/jsonRpc/index.ts +0 -1
- package/src/jsonRpc/types/common.ts +0 -1
- package/src/jsonRpc/types/generated.ts +2 -2
- package/src/jsonRpc/types/params.ts +6 -6
- package/src/keypairs/ed25519/keypair.ts +14 -10
- package/src/keypairs/passkey/keypair.ts +22 -8
- package/src/keypairs/secp256k1/keypair.ts +6 -6
- package/src/keypairs/secp256r1/keypair.ts +6 -6
- package/src/multisig/publickey.ts +1 -1
- package/src/transactions/Commands.ts +1 -1
- package/src/transactions/Transaction.ts +38 -1
- package/src/transactions/TransactionData.ts +3 -3
- package/src/transactions/__tests__/bcs.test.ts +3 -3
- package/src/transactions/data/internal.ts +12 -12
- package/src/transactions/data/v2.ts +6 -6
- package/src/transactions/executor/caching.ts +2 -2
- package/src/transactions/executor/parallel.ts +1 -2
- package/src/transactions/executor/serial.ts +1 -1
- package/src/transactions/intents/CoinWithBalance.ts +247 -121
- package/src/utils/coin-reservation.ts +84 -0
- package/src/utils/constants.ts +2 -0
- package/src/utils/haneul-types.ts +16 -1
- package/src/utils/index.ts +1 -0
- package/src/verify/index.ts +1 -1
- package/src/verify/verify.ts +1 -1
- package/src/version.ts +1 -1
- package/src/zklogin/nonce.ts +1 -1
- package/src/zklogin/utils.ts +1 -1
- package/dist/jsonRpc/rpc-websocket-client.d.mts +0 -26
- package/dist/jsonRpc/rpc-websocket-client.d.mts.map +0 -1
- package/dist/jsonRpc/rpc-websocket-client.mjs +0 -135
- package/dist/jsonRpc/rpc-websocket-client.mjs.map +0 -1
- package/src/jsonRpc/rpc-websocket-client.ts +0 -241
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @haneullabs/walrus
|
|
2
|
+
|
|
3
|
+
> Migrate @haneullabs/walrus to 2.0
|
|
4
|
+
|
|
5
|
+
## Breaking Changes
|
|
6
|
+
|
|
7
|
+
- **Client required**: `WalrusClient` can no longer be created with just an RPC URL. You must pass a
|
|
8
|
+
Haneul client.
|
|
9
|
+
- **Network from client**: The `network` parameter has been removed from `walrus()`. The network is
|
|
10
|
+
now inferred from the client.
|
|
11
|
+
- **Removed deprecated method**: `WalrusClient.experimental_asClientExtension()` has been removed.
|
|
12
|
+
Use the `walrus()` function instead.
|
|
13
|
+
|
|
14
|
+
## Updated Usage
|
|
15
|
+
|
|
16
|
+
If you were creating `WalrusClient` directly:
|
|
17
|
+
|
|
18
|
+
```diff
|
|
19
|
+
- import { WalrusClient } from '@haneullabs/walrus';
|
|
20
|
+
+ import { HaneulGrpcClient } from '@haneullabs/haneul/grpc'; // or HaneulJsonRpcClient, HaneulGraphQLClient
|
|
21
|
+
+ import { walrus } from '@haneullabs/walrus';
|
|
22
|
+
|
|
23
|
+
- const walrusClient = new WalrusClient({
|
|
24
|
+
- haneulRpcUrl: 'https://fullnode.testnet.haneul.io:443',
|
|
25
|
+
- network: 'testnet',
|
|
26
|
+
- });
|
|
27
|
+
+ const client = new HaneulGrpcClient({
|
|
28
|
+
+ baseUrl: 'https://fullnode.testnet.haneul.io:443',
|
|
29
|
+
+ network: 'testnet',
|
|
30
|
+
+ }).$extend(walrus());
|
|
31
|
+
|
|
32
|
+
- await walrusClient.getBlob(blobId);
|
|
33
|
+
+ await client.walrus.getBlob(blobId);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
If you were passing `network` to `walrus()`, remove it:
|
|
37
|
+
|
|
38
|
+
```diff
|
|
39
|
+
- client.$extend(walrus({ network: 'testnet' }));
|
|
40
|
+
+ client.$extend(walrus());
|
|
41
|
+
```
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# @haneullabs/zksend
|
|
2
|
+
|
|
3
|
+
> Migrate @haneullabs/zksend to 2.0
|
|
4
|
+
|
|
5
|
+
This package now exports a client extension that integrates with Haneul clients, enabling
|
|
6
|
+
compatibility with gRPC, GraphQL, and JSON RPC transports.
|
|
7
|
+
|
|
8
|
+
## Breaking Changes
|
|
9
|
+
|
|
10
|
+
- **Client extension**: The zkSend SDK is now a client extension (`client.$extend(zksend())`)
|
|
11
|
+
- **Non-contract links removed**: Only contract-based links are now supported. The `contract` option
|
|
12
|
+
no longer accepts `null`
|
|
13
|
+
- **`isContractLink` removed**: The `isContractLink` option has been removed from `ZkSendLink`
|
|
14
|
+
- **`calculateGas` removed**: The `calculateGas` option has been removed from
|
|
15
|
+
`CreateZkSendLinkOptions`
|
|
16
|
+
- **Data fetching helpers removed**: `getAssetsFromTransaction`, `isOwner`, and `ownedAfterChange`
|
|
17
|
+
are no longer exported
|
|
18
|
+
|
|
19
|
+
## Migration
|
|
20
|
+
|
|
21
|
+
Update your code to use the client extension:
|
|
22
|
+
|
|
23
|
+
```diff
|
|
24
|
+
- import { ZkSendLinkBuilder, ZkSendLink } from '@haneullabs/zksend';
|
|
25
|
+
+ import { zksend } from '@haneullabs/zksend';
|
|
26
|
+
+ import { HaneulGrpcClient } from '@haneullabs/haneul/grpc'; // or HaneulJsonRpcClient, HaneulGraphQLClient
|
|
27
|
+
|
|
28
|
+
+ const client = new HaneulGrpcClient({
|
|
29
|
+
+ baseUrl: 'https://fullnode.testnet.haneul.io:443',
|
|
30
|
+
+ network: 'testnet',
|
|
31
|
+
+ }).$extend(zksend());
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Creating a Link Builder
|
|
35
|
+
|
|
36
|
+
```diff
|
|
37
|
+
- const builder = new ZkSendLinkBuilder({
|
|
38
|
+
- client,
|
|
39
|
+
- sender: address,
|
|
40
|
+
- network: 'testnet',
|
|
41
|
+
- });
|
|
42
|
+
+ const link = client.zksend.linkBuilder({
|
|
43
|
+
+ sender: address,
|
|
44
|
+
+ });
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Loading a Link
|
|
48
|
+
|
|
49
|
+
```diff
|
|
50
|
+
- const link = new ZkSendLink({
|
|
51
|
+
- client,
|
|
52
|
+
- keypair,
|
|
53
|
+
- network: 'testnet',
|
|
54
|
+
- });
|
|
55
|
+
+ const link = await client.zksend.loadLink({
|
|
56
|
+
+ address: linkAddress,
|
|
57
|
+
+ // or: keypair: linkKeypair,
|
|
58
|
+
+ });
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Loading from URL
|
|
62
|
+
|
|
63
|
+
```diff
|
|
64
|
+
- const link = await ZkSendLink.fromUrl(url, {
|
|
65
|
+
- client,
|
|
66
|
+
- network: 'testnet',
|
|
67
|
+
- });
|
|
68
|
+
+ const link = await client.zksend.loadLinkFromUrl(url);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Complete Example
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
// Create client with zkSend extension
|
|
75
|
+
const client = new HaneulGrpcClient({
|
|
76
|
+
baseUrl: 'https://fullnode.testnet.haneul.io:443',
|
|
77
|
+
network: 'testnet',
|
|
78
|
+
}).$extend(zksend());
|
|
79
|
+
|
|
80
|
+
// Create a new link
|
|
81
|
+
const linkBuilder = client.zksend.linkBuilder({
|
|
82
|
+
sender: myAddress,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Add assets to the link
|
|
86
|
+
linkBuilder.addHaneul(1_000_000_000n); // 1 HANEUL
|
|
87
|
+
|
|
88
|
+
// Create the transaction
|
|
89
|
+
const { tx, link } = await linkBuilder.build();
|
|
90
|
+
|
|
91
|
+
// Later, load an existing link
|
|
92
|
+
const existingLink = await client.zksend.loadLinkFromUrl(linkUrl);
|
|
93
|
+
const assets = await existingLink.getAssets();
|
|
94
|
+
```
|
package/docs/plugins.md
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# Transaction Plugins
|
|
2
|
+
|
|
3
|
+
> Extend transaction building with reusable plugins
|
|
4
|
+
|
|
5
|
+
> **Warning:** The `Transaction` plugin API is experimental and may change rapidly as it is being
|
|
6
|
+
> developed.
|
|
7
|
+
|
|
8
|
+
This document describes the plugin API for the `Transaction` builder. It covers internal details
|
|
9
|
+
intended for developers interested in extending the `Transaction` builder. Developers using the
|
|
10
|
+
`Transaction` builder to build transactions do not need this level of detail. The `Transaction`
|
|
11
|
+
builder includes a plugin system designed to extend how transactions are built. The two primary
|
|
12
|
+
goals are:
|
|
13
|
+
|
|
14
|
+
1. Allow developers to customize how data is resolved when building transactions.
|
|
15
|
+
2. Provide a way for developers to extend the core commands that can be added to transactions.
|
|
16
|
+
|
|
17
|
+
The Plugin API consists of three main components: serialization plugins, build plugins, and
|
|
18
|
+
Transaction Intents. Serialization and build plugins act like middleware, allowing developers to
|
|
19
|
+
modify the data and commands added to a transaction before it is serialized to JSON or built into
|
|
20
|
+
BCS bytes. Transaction Intents are custom representations of user intents for a transaction,
|
|
21
|
+
eventually resolved to one or more commands in the transaction.
|
|
22
|
+
|
|
23
|
+
## Contents of a Transaction
|
|
24
|
+
|
|
25
|
+
When a `Transaction` is created (e.g., `new Transaction()`), it is initialized with an empty
|
|
26
|
+
[TransactionDataBuilder](/typedoc/classes/_haneullabs_haneul.transactions.TransactionDataBuilder.html)
|
|
27
|
+
instance which stores the state of the partially built transaction. The full API of the
|
|
28
|
+
`TransactionDataBuilder` won't be covered here, but you can find the available methods and
|
|
29
|
+
properties in the
|
|
30
|
+
[typedoc definition](/typedoc/classes/_haneullabs_haneul.transactions.TransactionDataBuilder.html).
|
|
31
|
+
|
|
32
|
+
As commands are added to the `Transaction`, they are stored in the `TransactionDataBuilder`. The
|
|
33
|
+
`TransactionData` contains a list of commands and their arguments. The exact arguments a command
|
|
34
|
+
takes depend on the command, but they will be one of a few different types:
|
|
35
|
+
|
|
36
|
+
- `GasCoin`: A reference to the coin used to pay for gas.
|
|
37
|
+
- `Input`: An input to the transaction (described below).
|
|
38
|
+
- `Result`: The result of a previous command.
|
|
39
|
+
- `NestedResult`: If a previous command returns a tuple (e.g., `SplitCoin`), a `NestedResult` is
|
|
40
|
+
used to refer to a specific value in that tuple.
|
|
41
|
+
|
|
42
|
+
Transactions also store a list of Inputs, which refer to user-provided values. Inputs can either be
|
|
43
|
+
objects or Pure values and can be represented in several different ways:
|
|
44
|
+
|
|
45
|
+
- `Pure`: An input value serialized to BCS. Pure values are generally scalar values or simple
|
|
46
|
+
wrappers like options or vectors and cannot represent object types.
|
|
47
|
+
- `Object`: A fully resolved object reference, which will be one of the following types:
|
|
48
|
+
- `ImmOrOwnedObject`: A reference to an object, including the object's `id`, `version`, and
|
|
49
|
+
`digest`.
|
|
50
|
+
- `SharedObject`: A reference to a shared object, including the object's `id`,
|
|
51
|
+
`initialSharedVersion`, and whether the shared object is used mutably.
|
|
52
|
+
- `Receiving`: A reference to a receiving object, including the object's `id`, `version`, and
|
|
53
|
+
`digest`.
|
|
54
|
+
- `UnresolvedPure`: A placeholder for a pure value that has not been serialized to BCS.
|
|
55
|
+
- `UnresolvedObject`: A partial reference to an object, often containing just the object's `id`, but
|
|
56
|
+
may also include a version, digest, or initialSharedVersion.
|
|
57
|
+
|
|
58
|
+
## Lifecycle of a Transaction
|
|
59
|
+
|
|
60
|
+
Because transactions can contain `UnresolvedPure` and `UnresolvedObject` inputs, these values need
|
|
61
|
+
to be resolved before the transaction can be serialized to BCS. However, these unresolved inputs can
|
|
62
|
+
be represented in JSON. What may not be able to be represented in JSON are Transaction Intents.
|
|
63
|
+
Transaction Intents represent custom concepts added by plugins or third-party SDKs. To account for
|
|
64
|
+
this, the build process of a transaction is split into two phases: serialization and building.
|
|
65
|
+
Serialization prepares the transaction to be serialized to JSON by running serialization plugins,
|
|
66
|
+
and resolving any unsupported intents. The Build phase then runs, which runs build plugins and
|
|
67
|
+
resolves any UnresolvedPure and UnresolvedObject inputs, before the transaction is serialized to
|
|
68
|
+
BCS.
|
|
69
|
+
|
|
70
|
+
## Serialization Plugins
|
|
71
|
+
|
|
72
|
+
Serialization plugins can be added to a `Transaction` by calling the `addSerializationPlugin` method
|
|
73
|
+
on a `Transaction` instance. Serialization plugins are called in the order they are added and are
|
|
74
|
+
passed the `TransactionDataBuilder` instance of the transaction.
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
const transaction = new Transaction();
|
|
78
|
+
|
|
79
|
+
transaction.addSerializationPlugin(async (transactionData, buildOptions, next) => {
|
|
80
|
+
// Modify the data before running other serialization steps
|
|
81
|
+
await next();
|
|
82
|
+
// Modify the data after running other serialization steps
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Build Plugins
|
|
87
|
+
|
|
88
|
+
The build phase is responsible for taking unresolved objects and unresolved pure values and
|
|
89
|
+
converting them to their resolved versions by querying the RPC API to fetch the missing data. Build
|
|
90
|
+
plugins can hook into this phase to resolve some of this data from a cache instead, avoiding extra
|
|
91
|
+
API calls.
|
|
92
|
+
|
|
93
|
+
Build plugins work just like serialization plugins and can be added to a `Transaction` by calling
|
|
94
|
+
the `addBuildPlugin` method on a `Transaction` instance. Build plugins are called in the order they
|
|
95
|
+
are added and are passed the `TransactionDataBuilder` instance of the transaction.
|
|
96
|
+
|
|
97
|
+
The following example demonstrates a simplified version of the caching plugin used by the
|
|
98
|
+
`SerialTransactionExecutor` and `ParallelTransactionExecutor` classes. This example works by adding
|
|
99
|
+
missing object versions and digest from a cache. Updating the cache (which could be done by looking
|
|
100
|
+
at transaction effects of previous transactions) is not covered in this example.
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
|
|
104
|
+
BuildTransactionOptions,
|
|
105
|
+
Transaction,
|
|
106
|
+
TransactionDataBuilder,
|
|
107
|
+
} from '@haneullabs/haneul/transactions';
|
|
108
|
+
|
|
109
|
+
const objectCache = new Map<string, { objectId: string; version: string; digest: string }>();
|
|
110
|
+
|
|
111
|
+
function simpleObjectCachePlugin(
|
|
112
|
+
transactionData: TransactionDataBuilder,
|
|
113
|
+
_options: BuildTransactionOptions,
|
|
114
|
+
next: () => Promise<void>,
|
|
115
|
+
) {
|
|
116
|
+
for (const input of transactionData.inputs) {
|
|
117
|
+
if (!input.UnresolvedObject) continue;
|
|
118
|
+
|
|
119
|
+
const cached = objectCache.get(input.UnresolvedObject.objectId);
|
|
120
|
+
|
|
121
|
+
if (!cached) continue;
|
|
122
|
+
|
|
123
|
+
if (cached.version && !input.UnresolvedObject.version) {
|
|
124
|
+
input.UnresolvedObject.version = cached.version;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (cached.digest && !input.UnresolvedObject.digest) {
|
|
128
|
+
input.UnresolvedObject.digest = cached.digest;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return next();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Example usage of the build plugin
|
|
136
|
+
const transaction = new Transaction();
|
|
137
|
+
transaction.addBuildPlugin(simpleObjectCachePlugin);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Transaction Intents
|
|
141
|
+
|
|
142
|
+
Transaction Intents consist of two parts: adding the intent to the transaction and resolving the
|
|
143
|
+
intent to standard commands.
|
|
144
|
+
|
|
145
|
+
Adding an intent is similar to adding any other command to a transaction:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
const transaction = new Transaction();
|
|
149
|
+
|
|
150
|
+
transaction.add(
|
|
151
|
+
Commands.Intent({
|
|
152
|
+
name: 'TransferToSender',
|
|
153
|
+
inputs: {
|
|
154
|
+
objects: [transaction.object(someId)],
|
|
155
|
+
},
|
|
156
|
+
}),
|
|
157
|
+
);
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
To make our custom `TransferToSender` intent easier to use, we can write a helper function that
|
|
161
|
+
wraps things up a bit. The `add` method on transactions accepts a function that will be passed the
|
|
162
|
+
current transaction instance. This allows us to create a helper that automatically adds the intent:
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
function transferToSender(objects: TransactionObjectInput[]) {
|
|
166
|
+
return (tx: Transaction) => {
|
|
167
|
+
tx.add(
|
|
168
|
+
Commands.Intent({
|
|
169
|
+
name: 'TransferToSender',
|
|
170
|
+
inputs: {
|
|
171
|
+
objects: objects.map((obj) => tx.object(obj)),
|
|
172
|
+
},
|
|
173
|
+
}),
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const transaction = new Transaction();
|
|
179
|
+
|
|
180
|
+
transaction.add(transferToSender(['0x1234']));
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Now that we've added the intent to the transaction, we need to resolve the intent to standard
|
|
184
|
+
commands. To do this, we'll use the `addIntentResolver` method on the `Transaction` instance. The
|
|
185
|
+
`addIntentResolver` method works like serialization and build plugins but will only be called if the
|
|
186
|
+
intent is present in the transaction.
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
const transaction = new Transaction();
|
|
190
|
+
|
|
191
|
+
transaction.addIntentResolver('TransferToSender', resolveTransferToSender);
|
|
192
|
+
|
|
193
|
+
async function resolveTransferToSender(
|
|
194
|
+
transactionData: TransactionDataBuilder,
|
|
195
|
+
buildOptions: BuildTransactionOptions,
|
|
196
|
+
next: () => Promise<void>,
|
|
197
|
+
) {
|
|
198
|
+
if (!transactionData.sender) {
|
|
199
|
+
throw new Error('Sender must be set to resolve TransferToSender');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Add an input that references the sender's address
|
|
203
|
+
const addressInput = Inputs.Pure(bcs.Address.serialize(transactionData.sender));
|
|
204
|
+
transactionData.inputs.push(addressInput);
|
|
205
|
+
// Get the index of the input to use when adding the TransferObjects command
|
|
206
|
+
const addressIndex = transactionData.inputs.length - 1;
|
|
207
|
+
|
|
208
|
+
for (const [index, transaction] of transactionData.commands.entries()) {
|
|
209
|
+
if (transaction.$kind !== '$Intent' || transaction.$Intent.name !== 'TransferToSender') {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// This will replace the intent command with the correct TransferObjects command
|
|
214
|
+
transactionData.replaceCommand(index, [
|
|
215
|
+
Commands.TransferObjects(
|
|
216
|
+
// The inputs for intents are not currently typed, so we need to cast to the correct type here
|
|
217
|
+
transaction.$Intent.inputs.objects as Extract<
|
|
218
|
+
TransactionObjectArgument,
|
|
219
|
+
{ $kind: 'Input' }
|
|
220
|
+
>,
|
|
221
|
+
// This is a CallArg referencing the addressInput we added above
|
|
222
|
+
{
|
|
223
|
+
Input: addressIndex,
|
|
224
|
+
},
|
|
225
|
+
),
|
|
226
|
+
]);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Plugins always need to call next() to continue the build process
|
|
230
|
+
return next();
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Manually adding intent resolvers to a transaction can be cumbersome, so we can add the resolver
|
|
235
|
+
automatically when our `transferToSender` helper is called:
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
function transferToSender(objects: TransactionObjectInput[]) {
|
|
239
|
+
return (tx: Transaction) => {
|
|
240
|
+
// As long as we are adding the same function reference, it will only be added once
|
|
241
|
+
tx.addIntentResolver('TransferToSender', resolveTransferToSender);
|
|
242
|
+
tx.add(
|
|
243
|
+
Commands.Intent({
|
|
244
|
+
name: 'TransferToSender',
|
|
245
|
+
inputs: {
|
|
246
|
+
objects: objects.map((obj) => tx.object(obj)),
|
|
247
|
+
},
|
|
248
|
+
}),
|
|
249
|
+
);
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const transaction = new Transaction();
|
|
254
|
+
transaction.add(transferToSender(['0x1234']));
|
|
255
|
+
```
|