@mysten/sui 0.0.0-experimental-20240529040124
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 +905 -0
- package/LICENSE +201 -0
- package/README.md +520 -0
- package/bcs/package.json +6 -0
- package/client/package.json +6 -0
- package/cryptography/package.json +6 -0
- package/dist/cjs/bcs/bcs.d.ts +2283 -0
- package/dist/cjs/bcs/bcs.js +306 -0
- package/dist/cjs/bcs/bcs.js.map +7 -0
- package/dist/cjs/bcs/effects.d.ts +793 -0
- package/dist/cjs/bcs/effects.js +203 -0
- package/dist/cjs/bcs/effects.js.map +7 -0
- package/dist/cjs/bcs/index.d.ts +3081 -0
- package/dist/cjs/bcs/index.js +73 -0
- package/dist/cjs/bcs/index.js.map +7 -0
- package/dist/cjs/bcs/type-tag-serializer.d.ts +6 -0
- package/dist/cjs/bcs/type-tag-serializer.js +113 -0
- package/dist/cjs/bcs/type-tag-serializer.js.map +7 -0
- package/dist/cjs/bcs/types.d.ts +114 -0
- package/dist/cjs/bcs/types.js +27 -0
- package/dist/cjs/bcs/types.js.map +7 -0
- package/dist/cjs/client/client.d.ts +229 -0
- package/dist/cjs/client/client.js +582 -0
- package/dist/cjs/client/client.js.map +7 -0
- package/dist/cjs/client/errors.d.ts +12 -0
- package/dist/cjs/client/errors.js +60 -0
- package/dist/cjs/client/errors.js.map +7 -0
- package/dist/cjs/client/http-transport.d.ts +40 -0
- package/dist/cjs/client/http-transport.js +125 -0
- package/dist/cjs/client/http-transport.js.map +7 -0
- package/dist/cjs/client/index.d.ts +5 -0
- package/dist/cjs/client/index.js +36 -0
- package/dist/cjs/client/index.js.map +7 -0
- package/dist/cjs/client/network.d.ts +1 -0
- package/dist/cjs/client/network.js +38 -0
- package/dist/cjs/client/network.js.map +7 -0
- package/dist/cjs/client/rpc-websocket-client.d.ts +49 -0
- package/dist/cjs/client/rpc-websocket-client.js +206 -0
- package/dist/cjs/client/rpc-websocket-client.js.map +7 -0
- package/dist/cjs/client/types/chain.d.ts +99 -0
- package/dist/cjs/client/types/chain.js +17 -0
- package/dist/cjs/client/types/chain.js.map +7 -0
- package/dist/cjs/client/types/changes.d.ts +19 -0
- package/dist/cjs/client/types/changes.js +17 -0
- package/dist/cjs/client/types/changes.js.map +7 -0
- package/dist/cjs/client/types/coins.d.ts +6 -0
- package/dist/cjs/client/types/coins.js +17 -0
- package/dist/cjs/client/types/coins.js.map +7 -0
- package/dist/cjs/client/types/common.d.ts +2 -0
- package/dist/cjs/client/types/common.js +17 -0
- package/dist/cjs/client/types/common.js.map +7 -0
- package/dist/cjs/client/types/generated.d.ts +1376 -0
- package/dist/cjs/client/types/generated.js +17 -0
- package/dist/cjs/client/types/generated.js.map +7 -0
- package/dist/cjs/client/types/index.d.ts +6 -0
- package/dist/cjs/client/types/index.js +24 -0
- package/dist/cjs/client/types/index.js.map +7 -0
- package/dist/cjs/client/types/params.d.ts +585 -0
- package/dist/cjs/client/types/params.js +17 -0
- package/dist/cjs/client/types/params.js.map +7 -0
- package/dist/cjs/cryptography/index.d.ts +7 -0
- package/dist/cjs/cryptography/index.js +47 -0
- package/dist/cjs/cryptography/index.js.map +7 -0
- package/dist/cjs/cryptography/intent.d.ts +6 -0
- package/dist/cjs/cryptography/intent.js +35 -0
- package/dist/cjs/cryptography/intent.js.map +7 -0
- package/dist/cjs/cryptography/keypair.d.ts +63 -0
- package/dist/cjs/cryptography/keypair.js +105 -0
- package/dist/cjs/cryptography/keypair.js.map +7 -0
- package/dist/cjs/cryptography/mnemonics.d.ts +27 -0
- package/dist/cjs/cryptography/mnemonics.js +47 -0
- package/dist/cjs/cryptography/mnemonics.js.map +7 -0
- package/dist/cjs/cryptography/publickey.d.ts +56 -0
- package/dist/cjs/cryptography/publickey.js +112 -0
- package/dist/cjs/cryptography/publickey.js.map +7 -0
- package/dist/cjs/cryptography/signature-scheme.d.ts +21 -0
- package/dist/cjs/cryptography/signature-scheme.js +45 -0
- package/dist/cjs/cryptography/signature-scheme.js.map +7 -0
- package/dist/cjs/cryptography/signature.d.ts +60 -0
- package/dist/cjs/cryptography/signature.js +75 -0
- package/dist/cjs/cryptography/signature.js.map +7 -0
- package/dist/cjs/faucet/faucet.d.ts +42 -0
- package/dist/cjs/faucet/faucet.js +103 -0
- package/dist/cjs/faucet/faucet.js.map +7 -0
- package/dist/cjs/faucet/index.d.ts +1 -0
- package/dist/cjs/faucet/index.js +29 -0
- package/dist/cjs/faucet/index.js.map +7 -0
- package/dist/cjs/graphql/client.d.ts +42 -0
- package/dist/cjs/graphql/client.js +93 -0
- package/dist/cjs/graphql/client.js.map +7 -0
- package/dist/cjs/graphql/generated/2024-01/tada-env.d.js +17 -0
- package/dist/cjs/graphql/generated/2024-01/tada-env.d.js.map +7 -0
- package/dist/cjs/graphql/generated/2024.1/tada-env.d.js +17 -0
- package/dist/cjs/graphql/generated/2024.1/tada-env.d.js.map +7 -0
- package/dist/cjs/graphql/generated/2024.1/tsconfig.tada.js +12 -0
- package/dist/cjs/graphql/generated/2024.1/tsconfig.tada.js.map +7 -0
- package/dist/cjs/graphql/generated/2024.4/tada-env.d.js +17 -0
- package/dist/cjs/graphql/generated/2024.4/tada-env.d.js.map +7 -0
- package/dist/cjs/graphql/generated/2024.4/tsconfig.tada.js +12 -0
- package/dist/cjs/graphql/generated/2024.4/tsconfig.tada.js.map +7 -0
- package/dist/cjs/graphql/index.d.ts +1 -0
- package/dist/cjs/graphql/index.js +26 -0
- package/dist/cjs/graphql/index.js.map +7 -0
- package/dist/cjs/graphql/schemas/2024.1/index.d.ts +8971 -0
- package/dist/cjs/graphql/schemas/2024.1/index.js +31 -0
- package/dist/cjs/graphql/schemas/2024.1/index.js.map +7 -0
- package/dist/cjs/graphql/schemas/2024.4/index.d.ts +8995 -0
- package/dist/cjs/graphql/schemas/2024.4/index.js +31 -0
- package/dist/cjs/graphql/schemas/2024.4/index.js.map +7 -0
- package/dist/cjs/graphql/types.d.ts +70 -0
- package/dist/cjs/graphql/types.js +17 -0
- package/dist/cjs/graphql/types.js.map +7 -0
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.d.ts +13 -0
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +101 -0
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js.map +7 -0
- package/dist/cjs/keypairs/ed25519/index.d.ts +2 -0
- package/dist/cjs/keypairs/ed25519/index.js +28 -0
- package/dist/cjs/keypairs/ed25519/index.js.map +7 -0
- package/dist/cjs/keypairs/ed25519/keypair.d.ts +74 -0
- package/dist/cjs/keypairs/ed25519/keypair.js +151 -0
- package/dist/cjs/keypairs/ed25519/keypair.js.map +7 -0
- package/dist/cjs/keypairs/ed25519/publickey.d.ts +30 -0
- package/dist/cjs/keypairs/ed25519/publickey.js +99 -0
- package/dist/cjs/keypairs/ed25519/publickey.js.map +7 -0
- package/dist/cjs/keypairs/secp256k1/index.d.ts +2 -0
- package/dist/cjs/keypairs/secp256k1/index.js +28 -0
- package/dist/cjs/keypairs/secp256k1/index.js.map +7 -0
- package/dist/cjs/keypairs/secp256k1/keypair.d.ts +73 -0
- package/dist/cjs/keypairs/secp256k1/keypair.js +143 -0
- package/dist/cjs/keypairs/secp256k1/keypair.js.map +7 -0
- package/dist/cjs/keypairs/secp256k1/publickey.d.ts +30 -0
- package/dist/cjs/keypairs/secp256k1/publickey.js +94 -0
- package/dist/cjs/keypairs/secp256k1/publickey.js.map +7 -0
- package/dist/cjs/keypairs/secp256r1/index.d.ts +2 -0
- package/dist/cjs/keypairs/secp256r1/index.js +28 -0
- package/dist/cjs/keypairs/secp256r1/index.js.map +7 -0
- package/dist/cjs/keypairs/secp256r1/keypair.d.ts +73 -0
- package/dist/cjs/keypairs/secp256r1/keypair.js +137 -0
- package/dist/cjs/keypairs/secp256r1/keypair.js.map +7 -0
- package/dist/cjs/keypairs/secp256r1/publickey.d.ts +30 -0
- package/dist/cjs/keypairs/secp256r1/publickey.js +94 -0
- package/dist/cjs/keypairs/secp256r1/publickey.js.map +7 -0
- package/dist/cjs/multisig/index.d.ts +2 -0
- package/dist/cjs/multisig/index.js +28 -0
- package/dist/cjs/multisig/index.js.map +7 -0
- package/dist/cjs/multisig/publickey.d.ts +110 -0
- package/dist/cjs/multisig/publickey.js +260 -0
- package/dist/cjs/multisig/publickey.js.map +7 -0
- package/dist/cjs/multisig/signer.d.ts +19 -0
- package/dist/cjs/multisig/signer.js +115 -0
- package/dist/cjs/multisig/signer.js.map +7 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/transactions/Commands.d.ts +110 -0
- package/dist/cjs/transactions/Commands.js +140 -0
- package/dist/cjs/transactions/Commands.js.map +7 -0
- package/dist/cjs/transactions/Inputs.d.ts +22 -0
- package/dist/cjs/transactions/Inputs.js +80 -0
- package/dist/cjs/transactions/Inputs.js.map +7 -0
- package/dist/cjs/transactions/ObjectCache.d.ts +85 -0
- package/dist/cjs/transactions/ObjectCache.js +246 -0
- package/dist/cjs/transactions/ObjectCache.js.map +7 -0
- package/dist/cjs/transactions/Transaction.d.ts +672 -0
- package/dist/cjs/transactions/Transaction.js +459 -0
- package/dist/cjs/transactions/Transaction.js.map +7 -0
- package/dist/cjs/transactions/TransactionData.d.ts +64 -0
- package/dist/cjs/transactions/TransactionData.js +249 -0
- package/dist/cjs/transactions/TransactionData.js.map +7 -0
- package/dist/cjs/transactions/__tests__/Transaction.test.d.ts +1 -0
- package/dist/cjs/transactions/__tests__/bcs.test.d.ts +1 -0
- package/dist/cjs/transactions/data/internal.d.ts +2689 -0
- package/dist/cjs/transactions/data/internal.js +210 -0
- package/dist/cjs/transactions/data/internal.js.map +7 -0
- package/dist/cjs/transactions/data/v1.d.ts +1839 -0
- package/dist/cjs/transactions/data/v1.js +440 -0
- package/dist/cjs/transactions/data/v1.js.map +7 -0
- package/dist/cjs/transactions/data/v2.d.ts +450 -0
- package/dist/cjs/transactions/data/v2.js +123 -0
- package/dist/cjs/transactions/data/v2.js.map +7 -0
- package/dist/cjs/transactions/executor/caching.d.ts +29 -0
- package/dist/cjs/transactions/executor/caching.js +109 -0
- package/dist/cjs/transactions/executor/caching.js.map +7 -0
- package/dist/cjs/transactions/executor/parallel.d.ts +22 -0
- package/dist/cjs/transactions/executor/parallel.js +316 -0
- package/dist/cjs/transactions/executor/parallel.js.map +7 -0
- package/dist/cjs/transactions/executor/queue.d.ts +11 -0
- package/dist/cjs/transactions/executor/queue.js +92 -0
- package/dist/cjs/transactions/executor/queue.js.map +7 -0
- package/dist/cjs/transactions/executor/serial.d.ts +27 -0
- package/dist/cjs/transactions/executor/serial.js +140 -0
- package/dist/cjs/transactions/executor/serial.js.map +7 -0
- package/dist/cjs/transactions/hash.d.ts +7 -0
- package/dist/cjs/transactions/hash.js +32 -0
- package/dist/cjs/transactions/hash.js.map +7 -0
- package/dist/cjs/transactions/index.d.ts +13 -0
- package/dist/cjs/transactions/index.js +47 -0
- package/dist/cjs/transactions/index.js.map +7 -0
- package/dist/cjs/transactions/intents/CoinWithBalance.d.ts +6 -0
- package/dist/cjs/transactions/intents/CoinWithBalance.js +168 -0
- package/dist/cjs/transactions/intents/CoinWithBalance.js.map +7 -0
- package/dist/cjs/transactions/json-rpc-resolver.d.ts +12 -0
- package/dist/cjs/transactions/json-rpc-resolver.js +353 -0
- package/dist/cjs/transactions/json-rpc-resolver.js.map +7 -0
- package/dist/cjs/transactions/pure.d.ts +185 -0
- package/dist/cjs/transactions/pure.js +41 -0
- package/dist/cjs/transactions/pure.js.map +7 -0
- package/dist/cjs/transactions/serializer.d.ts +7 -0
- package/dist/cjs/transactions/serializer.js +176 -0
- package/dist/cjs/transactions/serializer.js.map +7 -0
- package/dist/cjs/transactions/utils.d.ts +8 -0
- package/dist/cjs/transactions/utils.js +66 -0
- package/dist/cjs/transactions/utils.js.map +7 -0
- package/dist/cjs/utils/constants.d.ts +9 -0
- package/dist/cjs/utils/constants.js +42 -0
- package/dist/cjs/utils/constants.js.map +7 -0
- package/dist/cjs/utils/format.d.ts +2 -0
- package/dist/cjs/utils/format.js +36 -0
- package/dist/cjs/utils/format.js.map +7 -0
- package/dist/cjs/utils/index.d.ts +5 -0
- package/dist/cjs/utils/index.js +53 -0
- package/dist/cjs/utils/index.js.map +7 -0
- package/dist/cjs/utils/sui-types.d.ts +27 -0
- package/dist/cjs/utils/sui-types.js +90 -0
- package/dist/cjs/utils/sui-types.js.map +7 -0
- package/dist/cjs/utils/suins.d.ts +2 -0
- package/dist/cjs/utils/suins.js +57 -0
- package/dist/cjs/utils/suins.js.map +7 -0
- package/dist/cjs/verify/index.d.ts +1 -0
- package/dist/cjs/verify/index.js +29 -0
- package/dist/cjs/verify/index.js.map +7 -0
- package/dist/cjs/verify/verify.d.ts +11 -0
- package/dist/cjs/verify/verify.js +101 -0
- package/dist/cjs/verify/verify.js.map +7 -0
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/version.js +27 -0
- package/dist/cjs/version.js.map +7 -0
- package/dist/cjs/zklogin/address.d.ts +1 -0
- package/dist/cjs/zklogin/address.js +44 -0
- package/dist/cjs/zklogin/address.js.map +7 -0
- package/dist/cjs/zklogin/bcs.d.ts +46 -0
- package/dist/cjs/zklogin/bcs.js +42 -0
- package/dist/cjs/zklogin/bcs.js.map +7 -0
- package/dist/cjs/zklogin/index.d.ts +5 -0
- package/dist/cjs/zklogin/index.js +33 -0
- package/dist/cjs/zklogin/index.js.map +7 -0
- package/dist/cjs/zklogin/jwt-utils.d.ts +5 -0
- package/dist/cjs/zklogin/jwt-utils.js +102 -0
- package/dist/cjs/zklogin/jwt-utils.js.map +7 -0
- package/dist/cjs/zklogin/publickey.d.ts +69 -0
- package/dist/cjs/zklogin/publickey.js +197 -0
- package/dist/cjs/zklogin/publickey.js.map +7 -0
- package/dist/cjs/zklogin/signature.d.ts +23 -0
- package/dist/cjs/zklogin/signature.js +48 -0
- package/dist/cjs/zklogin/signature.js.map +7 -0
- package/dist/cjs/zklogin/utils.d.ts +2 -0
- package/dist/cjs/zklogin/utils.js +46 -0
- package/dist/cjs/zklogin/utils.js.map +7 -0
- package/dist/esm/bcs/bcs.d.ts +2283 -0
- package/dist/esm/bcs/bcs.js +286 -0
- package/dist/esm/bcs/bcs.js.map +7 -0
- package/dist/esm/bcs/effects.d.ts +793 -0
- package/dist/esm/bcs/effects.js +183 -0
- package/dist/esm/bcs/effects.js.map +7 -0
- package/dist/esm/bcs/index.d.ts +3081 -0
- package/dist/esm/bcs/index.js +83 -0
- package/dist/esm/bcs/index.js.map +7 -0
- package/dist/esm/bcs/type-tag-serializer.d.ts +6 -0
- package/dist/esm/bcs/type-tag-serializer.js +93 -0
- package/dist/esm/bcs/type-tag-serializer.js.map +7 -0
- package/dist/esm/bcs/types.d.ts +114 -0
- package/dist/esm/bcs/types.js +7 -0
- package/dist/esm/bcs/types.js.map +7 -0
- package/dist/esm/client/client.d.ts +229 -0
- package/dist/esm/client/client.js +568 -0
- package/dist/esm/client/client.js.map +7 -0
- package/dist/esm/client/errors.d.ts +12 -0
- package/dist/esm/client/errors.js +40 -0
- package/dist/esm/client/errors.js.map +7 -0
- package/dist/esm/client/http-transport.d.ts +40 -0
- package/dist/esm/client/http-transport.js +105 -0
- package/dist/esm/client/http-transport.js.map +7 -0
- package/dist/esm/client/index.d.ts +5 -0
- package/dist/esm/client/index.js +20 -0
- package/dist/esm/client/index.js.map +7 -0
- package/dist/esm/client/network.d.ts +1 -0
- package/dist/esm/client/network.js +18 -0
- package/dist/esm/client/network.js.map +7 -0
- package/dist/esm/client/rpc-websocket-client.d.ts +49 -0
- package/dist/esm/client/rpc-websocket-client.js +186 -0
- package/dist/esm/client/rpc-websocket-client.js.map +7 -0
- package/dist/esm/client/types/chain.d.ts +99 -0
- package/dist/esm/client/types/chain.js +1 -0
- package/dist/esm/client/types/chain.js.map +7 -0
- package/dist/esm/client/types/changes.d.ts +19 -0
- package/dist/esm/client/types/changes.js +1 -0
- package/dist/esm/client/types/changes.js.map +7 -0
- package/dist/esm/client/types/coins.d.ts +6 -0
- package/dist/esm/client/types/coins.js +1 -0
- package/dist/esm/client/types/coins.js.map +7 -0
- package/dist/esm/client/types/common.d.ts +2 -0
- package/dist/esm/client/types/common.js +1 -0
- package/dist/esm/client/types/common.js.map +7 -0
- package/dist/esm/client/types/generated.d.ts +1376 -0
- package/dist/esm/client/types/generated.js +1 -0
- package/dist/esm/client/types/generated.js.map +7 -0
- package/dist/esm/client/types/index.d.ts +6 -0
- package/dist/esm/client/types/index.js +7 -0
- package/dist/esm/client/types/index.js.map +7 -0
- package/dist/esm/client/types/params.d.ts +585 -0
- package/dist/esm/client/types/params.js +1 -0
- package/dist/esm/client/types/params.js.map +7 -0
- package/dist/esm/cryptography/index.d.ts +7 -0
- package/dist/esm/cryptography/index.js +47 -0
- package/dist/esm/cryptography/index.js.map +7 -0
- package/dist/esm/cryptography/intent.d.ts +6 -0
- package/dist/esm/cryptography/intent.js +15 -0
- package/dist/esm/cryptography/intent.js.map +7 -0
- package/dist/esm/cryptography/keypair.d.ts +63 -0
- package/dist/esm/cryptography/keypair.js +85 -0
- package/dist/esm/cryptography/keypair.js.map +7 -0
- package/dist/esm/cryptography/mnemonics.d.ts +27 -0
- package/dist/esm/cryptography/mnemonics.js +27 -0
- package/dist/esm/cryptography/mnemonics.js.map +7 -0
- package/dist/esm/cryptography/publickey.d.ts +56 -0
- package/dist/esm/cryptography/publickey.js +92 -0
- package/dist/esm/cryptography/publickey.js.map +7 -0
- package/dist/esm/cryptography/signature-scheme.d.ts +21 -0
- package/dist/esm/cryptography/signature-scheme.js +25 -0
- package/dist/esm/cryptography/signature-scheme.js.map +7 -0
- package/dist/esm/cryptography/signature.d.ts +60 -0
- package/dist/esm/cryptography/signature.js +59 -0
- package/dist/esm/cryptography/signature.js.map +7 -0
- package/dist/esm/faucet/faucet.d.ts +42 -0
- package/dist/esm/faucet/faucet.js +83 -0
- package/dist/esm/faucet/faucet.js.map +7 -0
- package/dist/esm/faucet/index.d.ts +1 -0
- package/dist/esm/faucet/index.js +15 -0
- package/dist/esm/faucet/index.js.map +7 -0
- package/dist/esm/graphql/client.d.ts +42 -0
- package/dist/esm/graphql/client.js +73 -0
- package/dist/esm/graphql/client.js.map +7 -0
- package/dist/esm/graphql/generated/2024-01/tada-env.d.js +1 -0
- package/dist/esm/graphql/generated/2024-01/tada-env.d.js.map +7 -0
- package/dist/esm/graphql/generated/2024.1/tada-env.d.js +1 -0
- package/dist/esm/graphql/generated/2024.1/tada-env.d.js.map +7 -0
- package/dist/esm/graphql/generated/2024.1/tsconfig.tada.js +17 -0
- package/dist/esm/graphql/generated/2024.1/tsconfig.tada.js.map +7 -0
- package/dist/esm/graphql/generated/2024.4/tada-env.d.js +1 -0
- package/dist/esm/graphql/generated/2024.4/tada-env.d.js.map +7 -0
- package/dist/esm/graphql/generated/2024.4/tsconfig.tada.js +17 -0
- package/dist/esm/graphql/generated/2024.4/tsconfig.tada.js.map +7 -0
- package/dist/esm/graphql/index.d.ts +1 -0
- package/dist/esm/graphql/index.js +9 -0
- package/dist/esm/graphql/index.js.map +7 -0
- package/dist/esm/graphql/schemas/2024.1/index.d.ts +8971 -0
- package/dist/esm/graphql/schemas/2024.1/index.js +10 -0
- package/dist/esm/graphql/schemas/2024.1/index.js.map +7 -0
- package/dist/esm/graphql/schemas/2024.4/index.d.ts +8995 -0
- package/dist/esm/graphql/schemas/2024.4/index.js +10 -0
- package/dist/esm/graphql/schemas/2024.4/index.js.map +7 -0
- package/dist/esm/graphql/types.d.ts +70 -0
- package/dist/esm/graphql/types.js +1 -0
- package/dist/esm/graphql/types.js.map +7 -0
- package/dist/esm/keypairs/ed25519/ed25519-hd-key.d.ts +13 -0
- package/dist/esm/keypairs/ed25519/ed25519-hd-key.js +71 -0
- package/dist/esm/keypairs/ed25519/ed25519-hd-key.js.map +7 -0
- package/dist/esm/keypairs/ed25519/index.d.ts +2 -0
- package/dist/esm/keypairs/ed25519/index.js +11 -0
- package/dist/esm/keypairs/ed25519/index.js.map +7 -0
- package/dist/esm/keypairs/ed25519/keypair.d.ts +74 -0
- package/dist/esm/keypairs/ed25519/keypair.js +121 -0
- package/dist/esm/keypairs/ed25519/keypair.js.map +7 -0
- package/dist/esm/keypairs/ed25519/publickey.d.ts +30 -0
- package/dist/esm/keypairs/ed25519/publickey.js +69 -0
- package/dist/esm/keypairs/ed25519/publickey.js.map +7 -0
- package/dist/esm/keypairs/secp256k1/index.d.ts +2 -0
- package/dist/esm/keypairs/secp256k1/index.js +11 -0
- package/dist/esm/keypairs/secp256k1/index.js.map +7 -0
- package/dist/esm/keypairs/secp256k1/keypair.d.ts +73 -0
- package/dist/esm/keypairs/secp256k1/keypair.js +123 -0
- package/dist/esm/keypairs/secp256k1/keypair.js.map +7 -0
- package/dist/esm/keypairs/secp256k1/publickey.d.ts +30 -0
- package/dist/esm/keypairs/secp256k1/publickey.js +74 -0
- package/dist/esm/keypairs/secp256k1/publickey.js.map +7 -0
- package/dist/esm/keypairs/secp256r1/index.d.ts +2 -0
- package/dist/esm/keypairs/secp256r1/index.js +11 -0
- package/dist/esm/keypairs/secp256r1/index.js.map +7 -0
- package/dist/esm/keypairs/secp256r1/keypair.d.ts +73 -0
- package/dist/esm/keypairs/secp256r1/keypair.js +117 -0
- package/dist/esm/keypairs/secp256r1/keypair.js.map +7 -0
- package/dist/esm/keypairs/secp256r1/publickey.d.ts +30 -0
- package/dist/esm/keypairs/secp256r1/publickey.js +74 -0
- package/dist/esm/keypairs/secp256r1/publickey.js.map +7 -0
- package/dist/esm/multisig/index.d.ts +2 -0
- package/dist/esm/multisig/index.js +8 -0
- package/dist/esm/multisig/index.js.map +7 -0
- package/dist/esm/multisig/publickey.d.ts +110 -0
- package/dist/esm/multisig/publickey.js +243 -0
- package/dist/esm/multisig/publickey.js.map +7 -0
- package/dist/esm/multisig/signer.d.ts +19 -0
- package/dist/esm/multisig/signer.js +95 -0
- package/dist/esm/multisig/signer.js.map +7 -0
- package/dist/esm/package.json +5 -0
- package/dist/esm/transactions/Commands.d.ts +110 -0
- package/dist/esm/transactions/Commands.js +120 -0
- package/dist/esm/transactions/Commands.js.map +7 -0
- package/dist/esm/transactions/Inputs.d.ts +22 -0
- package/dist/esm/transactions/Inputs.js +60 -0
- package/dist/esm/transactions/Inputs.js.map +7 -0
- package/dist/esm/transactions/ObjectCache.d.ts +85 -0
- package/dist/esm/transactions/ObjectCache.js +226 -0
- package/dist/esm/transactions/ObjectCache.js.map +7 -0
- package/dist/esm/transactions/Transaction.d.ts +672 -0
- package/dist/esm/transactions/Transaction.js +439 -0
- package/dist/esm/transactions/Transaction.js.map +7 -0
- package/dist/esm/transactions/TransactionData.d.ts +64 -0
- package/dist/esm/transactions/TransactionData.js +229 -0
- package/dist/esm/transactions/TransactionData.js.map +7 -0
- package/dist/esm/transactions/__tests__/Transaction.test.d.ts +1 -0
- package/dist/esm/transactions/__tests__/bcs.test.d.ts +1 -0
- package/dist/esm/transactions/data/internal.d.ts +2689 -0
- package/dist/esm/transactions/data/internal.js +208 -0
- package/dist/esm/transactions/data/internal.js.map +7 -0
- package/dist/esm/transactions/data/v1.d.ts +1839 -0
- package/dist/esm/transactions/data/v1.js +437 -0
- package/dist/esm/transactions/data/v1.js.map +7 -0
- package/dist/esm/transactions/data/v2.d.ts +450 -0
- package/dist/esm/transactions/data/v2.js +118 -0
- package/dist/esm/transactions/data/v2.js.map +7 -0
- package/dist/esm/transactions/executor/caching.d.ts +29 -0
- package/dist/esm/transactions/executor/caching.js +89 -0
- package/dist/esm/transactions/executor/caching.js.map +7 -0
- package/dist/esm/transactions/executor/parallel.d.ts +22 -0
- package/dist/esm/transactions/executor/parallel.js +296 -0
- package/dist/esm/transactions/executor/parallel.js.map +7 -0
- package/dist/esm/transactions/executor/queue.d.ts +11 -0
- package/dist/esm/transactions/executor/queue.js +72 -0
- package/dist/esm/transactions/executor/queue.js.map +7 -0
- package/dist/esm/transactions/executor/serial.d.ts +27 -0
- package/dist/esm/transactions/executor/serial.js +120 -0
- package/dist/esm/transactions/executor/serial.js.map +7 -0
- package/dist/esm/transactions/hash.d.ts +7 -0
- package/dist/esm/transactions/hash.js +12 -0
- package/dist/esm/transactions/hash.js.map +7 -0
- package/dist/esm/transactions/index.d.ts +13 -0
- package/dist/esm/transactions/index.js +33 -0
- package/dist/esm/transactions/index.js.map +7 -0
- package/dist/esm/transactions/intents/CoinWithBalance.d.ts +6 -0
- package/dist/esm/transactions/intents/CoinWithBalance.js +148 -0
- package/dist/esm/transactions/intents/CoinWithBalance.js.map +7 -0
- package/dist/esm/transactions/json-rpc-resolver.d.ts +12 -0
- package/dist/esm/transactions/json-rpc-resolver.js +333 -0
- package/dist/esm/transactions/json-rpc-resolver.js.map +7 -0
- package/dist/esm/transactions/pure.d.ts +185 -0
- package/dist/esm/transactions/pure.js +21 -0
- package/dist/esm/transactions/pure.js.map +7 -0
- package/dist/esm/transactions/serializer.d.ts +7 -0
- package/dist/esm/transactions/serializer.js +156 -0
- package/dist/esm/transactions/serializer.js.map +7 -0
- package/dist/esm/transactions/utils.d.ts +8 -0
- package/dist/esm/transactions/utils.js +46 -0
- package/dist/esm/transactions/utils.js.map +7 -0
- package/dist/esm/utils/constants.d.ts +9 -0
- package/dist/esm/utils/constants.js +22 -0
- package/dist/esm/utils/constants.js.map +7 -0
- package/dist/esm/utils/format.d.ts +2 -0
- package/dist/esm/utils/format.js +16 -0
- package/dist/esm/utils/format.js.map +7 -0
- package/dist/esm/utils/index.d.ts +5 -0
- package/dist/esm/utils/index.js +52 -0
- package/dist/esm/utils/index.js.map +7 -0
- package/dist/esm/utils/sui-types.d.ts +27 -0
- package/dist/esm/utils/sui-types.js +70 -0
- package/dist/esm/utils/sui-types.js.map +7 -0
- package/dist/esm/utils/suins.d.ts +2 -0
- package/dist/esm/utils/suins.js +37 -0
- package/dist/esm/utils/suins.js.map +7 -0
- package/dist/esm/verify/index.d.ts +1 -0
- package/dist/esm/verify/index.js +15 -0
- package/dist/esm/verify/index.js.map +7 -0
- package/dist/esm/verify/verify.d.ts +11 -0
- package/dist/esm/verify/verify.js +81 -0
- package/dist/esm/verify/verify.js.map +7 -0
- package/dist/esm/version.d.ts +2 -0
- package/dist/esm/version.js +7 -0
- package/dist/esm/version.js.map +7 -0
- package/dist/esm/zklogin/address.d.ts +1 -0
- package/dist/esm/zklogin/address.js +24 -0
- package/dist/esm/zklogin/address.js.map +7 -0
- package/dist/esm/zklogin/bcs.d.ts +46 -0
- package/dist/esm/zklogin/bcs.js +22 -0
- package/dist/esm/zklogin/bcs.js.map +7 -0
- package/dist/esm/zklogin/index.d.ts +5 -0
- package/dist/esm/zklogin/index.js +13 -0
- package/dist/esm/zklogin/index.js.map +7 -0
- package/dist/esm/zklogin/jwt-utils.d.ts +5 -0
- package/dist/esm/zklogin/jwt-utils.js +82 -0
- package/dist/esm/zklogin/jwt-utils.js.map +7 -0
- package/dist/esm/zklogin/publickey.d.ts +69 -0
- package/dist/esm/zklogin/publickey.js +177 -0
- package/dist/esm/zklogin/publickey.js.map +7 -0
- package/dist/esm/zklogin/signature.d.ts +23 -0
- package/dist/esm/zklogin/signature.js +28 -0
- package/dist/esm/zklogin/signature.js.map +7 -0
- package/dist/esm/zklogin/utils.d.ts +2 -0
- package/dist/esm/zklogin/utils.js +26 -0
- package/dist/esm/zklogin/utils.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/faucet/package.json +6 -0
- package/graphql/package.json +6 -0
- package/graphql/schemas/2024.1/package.json +6 -0
- package/graphql/schemas/2024.4/package.json +6 -0
- package/keypairs/ed25519/package.json +6 -0
- package/keypairs/secp256k1/package.json +6 -0
- package/keypairs/secp256r1/package.json +6 -0
- package/multisig/package.json +6 -0
- package/package.json +160 -0
- package/src/bcs/bcs.ts +300 -0
- package/src/bcs/effects.ts +200 -0
- package/src/bcs/index.ts +87 -0
- package/src/bcs/type-tag-serializer.ts +106 -0
- package/src/bcs/types.ts +113 -0
- package/src/client/client.ts +814 -0
- package/src/client/errors.ts +45 -0
- package/src/client/http-transport.ts +130 -0
- package/src/client/index.ts +21 -0
- package/src/client/network.ts +17 -0
- package/src/client/rpc-websocket-client.ts +234 -0
- package/src/client/types/chain.ts +122 -0
- package/src/client/types/changes.ts +11 -0
- package/src/client/types/coins.ts +9 -0
- package/src/client/types/common.ts +5 -0
- package/src/client/types/generated.ts +1508 -0
- package/src/client/types/index.ts +9 -0
- package/src/client/types/params.ts +584 -0
- package/src/cryptography/index.ts +36 -0
- package/src/cryptography/intent.ts +22 -0
- package/src/cryptography/keypair.ts +130 -0
- package/src/cryptography/mnemonics.ts +49 -0
- package/src/cryptography/publickey.ts +133 -0
- package/src/cryptography/signature-scheme.ts +28 -0
- package/src/cryptography/signature.ts +86 -0
- package/src/faucet/faucet.ts +130 -0
- package/src/faucet/index.ts +10 -0
- package/src/graphql/client.ts +110 -0
- package/src/graphql/generated/2024-01/tada-env.d.ts +202 -0
- package/src/graphql/generated/2024.1/schema.graphql +4168 -0
- package/src/graphql/generated/2024.1/tada-env.d.ts +201 -0
- package/src/graphql/generated/2024.1/tsconfig.tada.json +11 -0
- package/src/graphql/generated/2024.4/schema.graphql +4183 -0
- package/src/graphql/generated/2024.4/tada-env.d.ts +202 -0
- package/src/graphql/generated/2024.4/tsconfig.tada.json +11 -0
- package/src/graphql/index.ts +12 -0
- package/src/graphql/schemas/2024.1/index.ts +17 -0
- package/src/graphql/schemas/2024.4/index.ts +17 -0
- package/src/graphql/types.ts +86 -0
- package/src/keypairs/ed25519/ed25519-hd-key.ts +93 -0
- package/src/keypairs/ed25519/index.ts +9 -0
- package/src/keypairs/ed25519/keypair.ts +151 -0
- package/src/keypairs/ed25519/publickey.ts +86 -0
- package/src/keypairs/secp256k1/index.ts +9 -0
- package/src/keypairs/secp256k1/keypair.ts +151 -0
- package/src/keypairs/secp256k1/publickey.ts +91 -0
- package/src/keypairs/secp256r1/index.ts +9 -0
- package/src/keypairs/secp256r1/keypair.ts +147 -0
- package/src/keypairs/secp256r1/publickey.ts +91 -0
- package/src/multisig/index.ts +5 -0
- package/src/multisig/publickey.ts +356 -0
- package/src/multisig/signer.ts +92 -0
- package/src/transactions/Commands.ts +178 -0
- package/src/transactions/Inputs.ts +68 -0
- package/src/transactions/ObjectCache.ts +296 -0
- package/src/transactions/Transaction.ts +553 -0
- package/src/transactions/TransactionData.ts +296 -0
- package/src/transactions/__tests__/Transaction.test.ts +184 -0
- package/src/transactions/__tests__/bcs.test.ts +205 -0
- package/src/transactions/data/internal.ts +321 -0
- package/src/transactions/data/v1.ts +501 -0
- package/src/transactions/data/v2.ts +146 -0
- package/src/transactions/executor/caching.ts +94 -0
- package/src/transactions/executor/parallel.ts +335 -0
- package/src/transactions/executor/queue.ts +65 -0
- package/src/transactions/executor/serial.ts +131 -0
- package/src/transactions/hash.ts +20 -0
- package/src/transactions/index.ts +41 -0
- package/src/transactions/intents/CoinWithBalance.ts +204 -0
- package/src/transactions/json-rpc-resolver.ts +482 -0
- package/src/transactions/pure.ts +32 -0
- package/src/transactions/serializer.ts +205 -0
- package/src/transactions/utils.ts +66 -0
- package/src/utils/constants.ts +15 -0
- package/src/utils/format.ts +19 -0
- package/src/utils/index.ts +29 -0
- package/src/utils/sui-types.ts +110 -0
- package/src/utils/suins.ts +43 -0
- package/src/verify/index.ts +11 -0
- package/src/verify/verify.ts +111 -0
- package/src/version.ts +7 -0
- package/src/zklogin/address.ts +27 -0
- package/src/zklogin/bcs.ts +26 -0
- package/src/zklogin/index.ts +8 -0
- package/src/zklogin/jwt-utils.ts +113 -0
- package/src/zklogin/publickey.ts +190 -0
- package/src/zklogin/signature.ts +37 -0
- package/src/zklogin/utils.ts +33 -0
- package/transactions/package.json +6 -0
- package/utils/package.json +6 -0
- package/verify/package.json +6 -0
- package/zklogin/package.json +6 -0
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { SerializedBcs } from '@mysten/bcs';
|
|
5
|
+
import { fromB64, isSerializedBcs } from '@mysten/bcs';
|
|
6
|
+
import type { Input } from 'valibot';
|
|
7
|
+
import { is, parse } from 'valibot';
|
|
8
|
+
|
|
9
|
+
import type { SuiClient } from '../client/index.js';
|
|
10
|
+
import type { SignatureWithBytes, Signer } from '../cryptography/index.js';
|
|
11
|
+
import { normalizeSuiAddress } from '../utils/sui-types.js';
|
|
12
|
+
import type { TransactionArgument } from './Commands.js';
|
|
13
|
+
import { Commands } from './Commands.js';
|
|
14
|
+
import type { CallArg, Command } from './data/internal.js';
|
|
15
|
+
import { Argument, NormalizedCallArg, ObjectRef, TransactionExpiration } from './data/internal.js';
|
|
16
|
+
import { serializeV1TransactionData } from './data/v1.js';
|
|
17
|
+
import { SerializedTransactionDataV2 } from './data/v2.js';
|
|
18
|
+
import { Inputs } from './Inputs.js';
|
|
19
|
+
import type {
|
|
20
|
+
BuildTransactionOptions,
|
|
21
|
+
SerializeTransactionOptions,
|
|
22
|
+
TransactionPlugin,
|
|
23
|
+
} from './json-rpc-resolver.js';
|
|
24
|
+
import { resolveTransactionData } from './json-rpc-resolver.js';
|
|
25
|
+
import { createPure } from './pure.js';
|
|
26
|
+
import { TransactionDataBuilder } from './TransactionData.js';
|
|
27
|
+
import { getIdFromCallArg } from './utils.js';
|
|
28
|
+
|
|
29
|
+
export type TransactionObjectArgument =
|
|
30
|
+
| Exclude<Input<typeof Argument>, { Input: unknown; type?: 'pure' }>
|
|
31
|
+
| ((tx: Transaction) => Exclude<Input<typeof Argument>, { Input: unknown; type?: 'pure' }>);
|
|
32
|
+
|
|
33
|
+
export type TransactionResult = Extract<Argument, { Result: unknown }> &
|
|
34
|
+
Extract<Argument, { NestedResult: unknown }>[];
|
|
35
|
+
|
|
36
|
+
function createTransactionResult(index: number) {
|
|
37
|
+
const baseResult = { $kind: 'Result' as const, Result: index };
|
|
38
|
+
|
|
39
|
+
const nestedResults: {
|
|
40
|
+
$kind: 'NestedResult';
|
|
41
|
+
NestedResult: [number, number];
|
|
42
|
+
}[] = [];
|
|
43
|
+
const nestedResultFor = (
|
|
44
|
+
resultIndex: number,
|
|
45
|
+
): {
|
|
46
|
+
$kind: 'NestedResult';
|
|
47
|
+
NestedResult: [number, number];
|
|
48
|
+
} =>
|
|
49
|
+
(nestedResults[resultIndex] ??= {
|
|
50
|
+
$kind: 'NestedResult' as const,
|
|
51
|
+
NestedResult: [index, resultIndex],
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return new Proxy(baseResult, {
|
|
55
|
+
set() {
|
|
56
|
+
throw new Error(
|
|
57
|
+
'The transaction result is a proxy, and does not support setting properties directly',
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
// TODO: Instead of making this return a concrete argument, we should ideally
|
|
61
|
+
// make it reference-based (so that this gets resolved at build-time), which
|
|
62
|
+
// allows re-ordering transactions.
|
|
63
|
+
get(target, property) {
|
|
64
|
+
// This allows this transaction argument to be used in the singular form:
|
|
65
|
+
if (property in target) {
|
|
66
|
+
return Reflect.get(target, property);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Support destructuring:
|
|
70
|
+
if (property === Symbol.iterator) {
|
|
71
|
+
return function* () {
|
|
72
|
+
let i = 0;
|
|
73
|
+
while (true) {
|
|
74
|
+
yield nestedResultFor(i);
|
|
75
|
+
i++;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (typeof property === 'symbol') return;
|
|
81
|
+
|
|
82
|
+
const resultIndex = parseInt(property, 10);
|
|
83
|
+
if (Number.isNaN(resultIndex) || resultIndex < 0) return;
|
|
84
|
+
return nestedResultFor(resultIndex);
|
|
85
|
+
},
|
|
86
|
+
}) as TransactionResult;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const TRANSACTION_BRAND = Symbol.for('@mysten/transaction');
|
|
90
|
+
|
|
91
|
+
interface SignOptions extends BuildTransactionOptions {
|
|
92
|
+
signer: Signer;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function isTransaction(obj: unknown): obj is Transaction {
|
|
96
|
+
return !!obj && typeof obj === 'object' && (obj as any)[TRANSACTION_BRAND] === true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export type TransactionObjectInput = string | CallArg | TransactionObjectArgument;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Transaction Builder
|
|
103
|
+
*/
|
|
104
|
+
export class Transaction {
|
|
105
|
+
#serializationPlugins: TransactionPlugin[] = [];
|
|
106
|
+
#buildPlugins: TransactionPlugin[] = [];
|
|
107
|
+
#intentResolvers = new Map<string, TransactionPlugin>();
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Converts from a serialize transaction kind (built with `build({ onlyTransactionKind: true })`) to a `Transaction` class.
|
|
111
|
+
* Supports either a byte array, or base64-encoded bytes.
|
|
112
|
+
*/
|
|
113
|
+
static fromKind(serialized: string | Uint8Array) {
|
|
114
|
+
const tx = new Transaction();
|
|
115
|
+
|
|
116
|
+
tx.#data = TransactionDataBuilder.fromKindBytes(
|
|
117
|
+
typeof serialized === 'string' ? fromB64(serialized) : serialized,
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
return tx;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Converts from a serialized transaction format to a `Transaction` class.
|
|
125
|
+
* There are two supported serialized formats:
|
|
126
|
+
* - A string returned from `Transaction#serialize`. The serialized format must be compatible, or it will throw an error.
|
|
127
|
+
* - A byte array (or base64-encoded bytes) containing BCS transaction data.
|
|
128
|
+
*/
|
|
129
|
+
static from(transaction: string | Uint8Array | Transaction) {
|
|
130
|
+
const newTransaction = new Transaction();
|
|
131
|
+
|
|
132
|
+
if (isTransaction(transaction)) {
|
|
133
|
+
newTransaction.#data = new TransactionDataBuilder(transaction.getData());
|
|
134
|
+
} else if (typeof transaction !== 'string' || !transaction.startsWith('{')) {
|
|
135
|
+
newTransaction.#data = TransactionDataBuilder.fromBytes(
|
|
136
|
+
typeof transaction === 'string' ? fromB64(transaction) : transaction,
|
|
137
|
+
);
|
|
138
|
+
} else {
|
|
139
|
+
newTransaction.#data = TransactionDataBuilder.restore(JSON.parse(transaction));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return newTransaction;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
addSerializationPlugin(step: TransactionPlugin) {
|
|
146
|
+
this.#serializationPlugins.push(step);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
addBuildPlugin(step: TransactionPlugin) {
|
|
150
|
+
this.#buildPlugins.push(step);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
addIntentResolver(intent: string, resolver: TransactionPlugin) {
|
|
154
|
+
if (this.#intentResolvers.has(intent) && this.#intentResolvers.get(intent) !== resolver) {
|
|
155
|
+
throw new Error(`Intent resolver for ${intent} already exists`);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
this.#intentResolvers.set(intent, resolver);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
setSender(sender: string) {
|
|
162
|
+
this.#data.sender = sender;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Sets the sender only if it has not already been set.
|
|
166
|
+
* This is useful for sponsored transaction flows where the sender may not be the same as the signer address.
|
|
167
|
+
*/
|
|
168
|
+
setSenderIfNotSet(sender: string) {
|
|
169
|
+
if (!this.#data.sender) {
|
|
170
|
+
this.#data.sender = sender;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
setExpiration(expiration?: Input<typeof TransactionExpiration> | null) {
|
|
174
|
+
this.#data.expiration = expiration ? parse(TransactionExpiration, expiration) : null;
|
|
175
|
+
}
|
|
176
|
+
setGasPrice(price: number | bigint) {
|
|
177
|
+
this.#data.gasConfig.price = String(price);
|
|
178
|
+
}
|
|
179
|
+
setGasBudget(budget: number | bigint) {
|
|
180
|
+
this.#data.gasConfig.budget = String(budget);
|
|
181
|
+
}
|
|
182
|
+
setGasOwner(owner: string) {
|
|
183
|
+
this.#data.gasConfig.owner = owner;
|
|
184
|
+
}
|
|
185
|
+
setGasPayment(payments: ObjectRef[]) {
|
|
186
|
+
this.#data.gasConfig.payment = payments.map((payment) => parse(ObjectRef, payment));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
#data: TransactionDataBuilder;
|
|
190
|
+
|
|
191
|
+
/** @deprecated Use `getData()` instead. */
|
|
192
|
+
get blockData() {
|
|
193
|
+
return serializeV1TransactionData(this.#data.snapshot());
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Get a snapshot of the transaction data, in JSON form: */
|
|
197
|
+
getData() {
|
|
198
|
+
return this.#data.snapshot();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Used to brand transaction classes so that they can be identified, even between multiple copies
|
|
202
|
+
// of the builder.
|
|
203
|
+
get [TRANSACTION_BRAND]() {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Temporary workaround for the wallet interface accidentally serializing transactions via postMessage
|
|
208
|
+
get pure(): ReturnType<typeof createPure> {
|
|
209
|
+
Object.defineProperty(this, 'pure', {
|
|
210
|
+
enumerable: false,
|
|
211
|
+
value: createPure((value): Argument => {
|
|
212
|
+
if (isSerializedBcs(value)) {
|
|
213
|
+
return this.#data.addInput('pure', {
|
|
214
|
+
$kind: 'Pure',
|
|
215
|
+
Pure: {
|
|
216
|
+
bytes: value.toBase64(),
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// TODO: we can also do some deduplication here
|
|
222
|
+
return this.#data.addInput(
|
|
223
|
+
'pure',
|
|
224
|
+
is(NormalizedCallArg, value)
|
|
225
|
+
? parse(NormalizedCallArg, value)
|
|
226
|
+
: value instanceof Uint8Array
|
|
227
|
+
? Inputs.Pure(value)
|
|
228
|
+
: { $kind: 'UnresolvedPure', UnresolvedPure: { value } },
|
|
229
|
+
);
|
|
230
|
+
}),
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
return this.pure;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
constructor() {
|
|
237
|
+
this.#data = new TransactionDataBuilder();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** Returns an argument for the gas coin, to be used in a transaction. */
|
|
241
|
+
get gas() {
|
|
242
|
+
return { $kind: 'GasCoin' as const, GasCoin: true as const };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Add a new object input to the transaction.
|
|
247
|
+
*/
|
|
248
|
+
object(value: TransactionObjectInput): { $kind: 'Input'; Input: number; type?: 'object' } {
|
|
249
|
+
if (typeof value === 'function') {
|
|
250
|
+
return this.object(value(this));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (typeof value === 'object' && is(Argument, value)) {
|
|
254
|
+
return value as { $kind: 'Input'; Input: number; type?: 'object' };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const id = getIdFromCallArg(value);
|
|
258
|
+
|
|
259
|
+
const inserted = this.#data.inputs.find((i) => id === getIdFromCallArg(i));
|
|
260
|
+
|
|
261
|
+
// Upgrade shared object inputs to mutable if needed:
|
|
262
|
+
if (inserted?.Object?.SharedObject && typeof value === 'object' && value.Object?.SharedObject) {
|
|
263
|
+
inserted.Object.SharedObject.mutable =
|
|
264
|
+
inserted.Object.SharedObject.mutable || value.Object.SharedObject.mutable;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return inserted
|
|
268
|
+
? { $kind: 'Input', Input: this.#data.inputs.indexOf(inserted), type: 'object' }
|
|
269
|
+
: this.#data.addInput(
|
|
270
|
+
'object',
|
|
271
|
+
typeof value === 'string'
|
|
272
|
+
? {
|
|
273
|
+
$kind: 'UnresolvedObject',
|
|
274
|
+
UnresolvedObject: { objectId: normalizeSuiAddress(value) },
|
|
275
|
+
}
|
|
276
|
+
: value,
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Add a new object input to the transaction using the fully-resolved object reference.
|
|
282
|
+
* If you only have an object ID, use `builder.object(id)` instead.
|
|
283
|
+
*/
|
|
284
|
+
objectRef(...args: Parameters<(typeof Inputs)['ObjectRef']>) {
|
|
285
|
+
return this.object(Inputs.ObjectRef(...args));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Add a new receiving input to the transaction using the fully-resolved object reference.
|
|
290
|
+
* If you only have an object ID, use `builder.object(id)` instead.
|
|
291
|
+
*/
|
|
292
|
+
receivingRef(...args: Parameters<(typeof Inputs)['ReceivingRef']>) {
|
|
293
|
+
return this.object(Inputs.ReceivingRef(...args));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Add a new shared object input to the transaction using the fully-resolved shared object reference.
|
|
298
|
+
* If you only have an object ID, use `builder.object(id)` instead.
|
|
299
|
+
*/
|
|
300
|
+
sharedObjectRef(...args: Parameters<(typeof Inputs)['SharedObjectRef']>) {
|
|
301
|
+
return this.object(Inputs.SharedObjectRef(...args));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** Add a transaction to the transaction */
|
|
305
|
+
add(command: Command | ((tx: Transaction) => TransactionResult)): TransactionResult {
|
|
306
|
+
if (typeof command === 'function') {
|
|
307
|
+
return command(this);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const index = this.#data.commands.push(command);
|
|
311
|
+
return createTransactionResult(index - 1);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
#normalizeTransactionArgument(arg: TransactionArgument | SerializedBcs<any>) {
|
|
315
|
+
if (isSerializedBcs(arg)) {
|
|
316
|
+
return this.pure(arg);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return this.#resolveArgument(arg as TransactionArgument);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
#resolveArgument(arg: TransactionArgument): Argument {
|
|
323
|
+
if (typeof arg === 'function') {
|
|
324
|
+
return parse(Argument, arg(this));
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return parse(Argument, arg);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Method shorthands:
|
|
331
|
+
|
|
332
|
+
splitCoins(
|
|
333
|
+
coin: TransactionObjectArgument | string,
|
|
334
|
+
amounts: (TransactionArgument | SerializedBcs<any> | number | string | bigint)[],
|
|
335
|
+
) {
|
|
336
|
+
return this.add(
|
|
337
|
+
Commands.SplitCoins(
|
|
338
|
+
typeof coin === 'string' ? this.object(coin) : this.#resolveArgument(coin),
|
|
339
|
+
amounts.map((amount) =>
|
|
340
|
+
typeof amount === 'number' || typeof amount === 'bigint' || typeof amount === 'string'
|
|
341
|
+
? this.pure.u64(amount)
|
|
342
|
+
: this.#normalizeTransactionArgument(amount),
|
|
343
|
+
),
|
|
344
|
+
),
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
mergeCoins(
|
|
348
|
+
destination: TransactionObjectArgument | string,
|
|
349
|
+
sources: (TransactionObjectArgument | string)[],
|
|
350
|
+
) {
|
|
351
|
+
return this.add(
|
|
352
|
+
Commands.MergeCoins(
|
|
353
|
+
this.object(destination),
|
|
354
|
+
sources.map((src) => this.object(src)),
|
|
355
|
+
),
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
publish({ modules, dependencies }: { modules: number[][] | string[]; dependencies: string[] }) {
|
|
359
|
+
return this.add(
|
|
360
|
+
Commands.Publish({
|
|
361
|
+
modules,
|
|
362
|
+
dependencies,
|
|
363
|
+
}),
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
upgrade({
|
|
367
|
+
modules,
|
|
368
|
+
dependencies,
|
|
369
|
+
package: packageId,
|
|
370
|
+
ticket,
|
|
371
|
+
}: {
|
|
372
|
+
modules: number[][] | string[];
|
|
373
|
+
dependencies: string[];
|
|
374
|
+
package: string;
|
|
375
|
+
ticket: TransactionObjectArgument | string;
|
|
376
|
+
}) {
|
|
377
|
+
return this.add(
|
|
378
|
+
Commands.Upgrade({
|
|
379
|
+
modules,
|
|
380
|
+
dependencies,
|
|
381
|
+
package: packageId,
|
|
382
|
+
ticket: this.object(ticket),
|
|
383
|
+
}),
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
moveCall({
|
|
387
|
+
arguments: args,
|
|
388
|
+
...input
|
|
389
|
+
}:
|
|
390
|
+
| {
|
|
391
|
+
package: string;
|
|
392
|
+
module: string;
|
|
393
|
+
function: string;
|
|
394
|
+
arguments?: (TransactionArgument | SerializedBcs<any>)[];
|
|
395
|
+
typeArguments?: string[];
|
|
396
|
+
}
|
|
397
|
+
| {
|
|
398
|
+
target: string;
|
|
399
|
+
arguments?: (TransactionArgument | SerializedBcs<any>)[];
|
|
400
|
+
typeArguments?: string[];
|
|
401
|
+
}) {
|
|
402
|
+
return this.add(
|
|
403
|
+
Commands.MoveCall({
|
|
404
|
+
...input,
|
|
405
|
+
arguments: args?.map((arg) => this.#normalizeTransactionArgument(arg)),
|
|
406
|
+
} as Parameters<typeof Commands.MoveCall>[0]),
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
transferObjects(
|
|
410
|
+
objects: (TransactionObjectArgument | string)[],
|
|
411
|
+
address: TransactionArgument | SerializedBcs<any> | string,
|
|
412
|
+
) {
|
|
413
|
+
return this.add(
|
|
414
|
+
Commands.TransferObjects(
|
|
415
|
+
objects.map((obj) => this.object(obj)),
|
|
416
|
+
typeof address === 'string'
|
|
417
|
+
? this.pure.address(address)
|
|
418
|
+
: this.#normalizeTransactionArgument(address),
|
|
419
|
+
),
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
makeMoveVec({
|
|
423
|
+
type,
|
|
424
|
+
elements,
|
|
425
|
+
}: {
|
|
426
|
+
elements: (TransactionObjectArgument | string)[];
|
|
427
|
+
type?: string;
|
|
428
|
+
}) {
|
|
429
|
+
return this.add(
|
|
430
|
+
Commands.MakeMoveVec({
|
|
431
|
+
type,
|
|
432
|
+
elements: elements.map((obj) => this.object(obj)),
|
|
433
|
+
}),
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* @deprecated Use toJSON instead.
|
|
439
|
+
* For synchronous serialization, you can use `getData()`
|
|
440
|
+
* */
|
|
441
|
+
serialize() {
|
|
442
|
+
return JSON.stringify(serializeV1TransactionData(this.#data.snapshot()));
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
async toJSON(options: SerializeTransactionOptions = {}): Promise<string> {
|
|
446
|
+
await this.prepareForSerialization(options);
|
|
447
|
+
return JSON.stringify(
|
|
448
|
+
parse(SerializedTransactionDataV2, this.#data.snapshot()),
|
|
449
|
+
(_key, value) => (typeof value === 'bigint' ? value.toString() : value),
|
|
450
|
+
2,
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/** Build the transaction to BCS bytes, and sign it with the provided keypair. */
|
|
455
|
+
async sign(options: SignOptions): Promise<SignatureWithBytes> {
|
|
456
|
+
const { signer, ...buildOptions } = options;
|
|
457
|
+
const bytes = await this.build(buildOptions);
|
|
458
|
+
return signer.signTransaction(bytes);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** Build the transaction to BCS bytes. */
|
|
462
|
+
async build(options: BuildTransactionOptions = {}): Promise<Uint8Array> {
|
|
463
|
+
await this.prepareForSerialization(options);
|
|
464
|
+
await this.#prepareBuild(options);
|
|
465
|
+
return this.#data.build({
|
|
466
|
+
onlyTransactionKind: options.onlyTransactionKind,
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/** Derive transaction digest */
|
|
471
|
+
async getDigest(
|
|
472
|
+
options: {
|
|
473
|
+
client?: SuiClient;
|
|
474
|
+
} = {},
|
|
475
|
+
): Promise<string> {
|
|
476
|
+
await this.#prepareBuild(options);
|
|
477
|
+
return this.#data.getDigest();
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Prepare the transaction by validating the transaction data and resolving all inputs
|
|
482
|
+
* so that it can be built into bytes.
|
|
483
|
+
*/
|
|
484
|
+
async #prepareBuild(options: BuildTransactionOptions) {
|
|
485
|
+
if (!options.onlyTransactionKind && !this.#data.sender) {
|
|
486
|
+
throw new Error('Missing transaction sender');
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
await this.#runPlugins([...this.#buildPlugins, resolveTransactionData], options);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
async #runPlugins(plugins: TransactionPlugin[], options: SerializeTransactionOptions) {
|
|
493
|
+
const createNext = (i: number) => {
|
|
494
|
+
if (i >= plugins.length) {
|
|
495
|
+
return () => {};
|
|
496
|
+
}
|
|
497
|
+
const plugin = plugins[i];
|
|
498
|
+
|
|
499
|
+
return async () => {
|
|
500
|
+
const next = createNext(i + 1);
|
|
501
|
+
let calledNext = false;
|
|
502
|
+
let nextResolved = false;
|
|
503
|
+
|
|
504
|
+
await plugin(this.#data, options, async () => {
|
|
505
|
+
if (calledNext) {
|
|
506
|
+
throw new Error(`next() was call multiple times in TransactionPlugin ${i}`);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
calledNext = true;
|
|
510
|
+
|
|
511
|
+
await next();
|
|
512
|
+
|
|
513
|
+
nextResolved = true;
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
if (!calledNext) {
|
|
517
|
+
throw new Error(`next() was not called in TransactionPlugin ${i}`);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
if (!nextResolved) {
|
|
521
|
+
throw new Error(`next() was not awaited in TransactionPlugin ${i}`);
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
await createNext(0)();
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
async prepareForSerialization(options: SerializeTransactionOptions) {
|
|
530
|
+
const intents = new Set<string>();
|
|
531
|
+
for (const command of this.#data.commands) {
|
|
532
|
+
if (command.$Intent && options.supportedIntents) {
|
|
533
|
+
intents.add(command.$Intent.name);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
const steps = [...this.#serializationPlugins];
|
|
538
|
+
|
|
539
|
+
for (const intent of intents) {
|
|
540
|
+
if (options.supportedIntents?.includes(intent)) {
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
if (!this.#intentResolvers.has(intent)) {
|
|
545
|
+
throw new Error(`Missing intent resolver for ${intent}`);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
steps.push(this.#intentResolvers.get(intent)!);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
await this.#runPlugins(steps, options);
|
|
552
|
+
}
|
|
553
|
+
}
|