@mysten/sui 2.12.1 → 2.13.1
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 +26 -0
- package/dist/bcs/bcs.d.mts +0 -1
- package/dist/bcs/bcs.d.mts.map +1 -1
- package/dist/bcs/index.d.mts +20 -20
- package/dist/bcs/index.d.mts.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 +96 -82
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/client/core.d.mts.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.map +1 -1
- package/dist/client/utils.d.mts.map +1 -1
- package/dist/cryptography/intent.d.mts.map +1 -1
- package/dist/cryptography/keypair.d.mts.map +1 -1
- package/dist/cryptography/mnemonics.d.mts.map +1 -1
- package/dist/cryptography/publickey.d.mts +0 -1
- package/dist/cryptography/publickey.d.mts.map +1 -1
- package/dist/cryptography/signature-scheme.d.mts.map +1 -1
- package/dist/cryptography/signature.d.mts +16 -19
- package/dist/cryptography/signature.d.mts.map +1 -1
- package/dist/faucet/faucet.d.mts.map +1 -1
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/core.d.mts.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/tada-env.d.mts.map +1 -1
- 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.map +1 -1
- package/dist/grpc/core.d.mts.map +1 -1
- 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/sui/rpc/v2/argument.d.mts +1 -2
- package/dist/grpc/proto/sui/rpc/v2/argument.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/balance_change.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/balance_change.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/bcs.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/bcs.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/checkpoint.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/checkpoint.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/checkpoint_contents.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/checkpoint_contents.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/checkpoint_summary.d.mts +1 -2
- package/dist/grpc/proto/sui/rpc/v2/checkpoint_summary.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/effects.d.mts +5 -6
- package/dist/grpc/proto/sui/rpc/v2/effects.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/epoch.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/epoch.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts +1 -1
- package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/event.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/event.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/execution_status.d.mts +4 -5
- package/dist/grpc/proto/sui/rpc/v2/execution_status.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/gas_cost_summary.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/gas_cost_summary.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/input.d.mts +3 -4
- package/dist/grpc/proto/sui/rpc/v2/input.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/jwk.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/jwk.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -5
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package.d.mts +5 -6
- package/dist/grpc/proto/sui/rpc/v2/move_package.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -5
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/name_service.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/name_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/object.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/object.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/object_reference.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/object_reference.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/owner.d.mts +1 -2
- package/dist/grpc/proto/sui/rpc/v2/owner.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/protocol_config.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/protocol_config.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/signature.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -5
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -5
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/state_service.d.mts +4 -5
- package/dist/grpc/proto/sui/rpc/v2/state_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -5
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/system_state.d.mts +0 -1
- package/dist/grpc/proto/sui/rpc/v2/system_state.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts +4 -5
- package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -5
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +1 -2
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts.map +1 -1
- package/dist/grpc/proto/types.d.mts.map +1 -1
- package/dist/jsonRpc/client.d.mts +2 -5
- package/dist/jsonRpc/client.d.mts.map +1 -1
- package/dist/jsonRpc/client.mjs +1 -30
- package/dist/jsonRpc/client.mjs.map +1 -1
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +11 -4
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/jsonRpc/errors.d.mts.map +1 -1
- package/dist/jsonRpc/http-transport.d.mts.map +1 -1
- 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.map +1 -1
- package/dist/jsonRpc/types/generated.d.mts +99 -127
- package/dist/jsonRpc/types/generated.d.mts.map +1 -1
- package/dist/jsonRpc/types/params.d.mts +4 -9
- package/dist/jsonRpc/types/params.d.mts.map +1 -1
- package/dist/keypairs/ed25519/keypair.d.mts.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.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.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.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/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/Inputs.d.mts.map +1 -1
- package/dist/transactions/ObjectCache.d.mts.map +1 -1
- package/dist/transactions/Transaction.d.mts +29 -3
- 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/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/v1.d.mts +0 -1
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts.map +1 -1
- package/dist/transactions/executor/parallel.d.mts.map +1 -1
- package/dist/transactions/executor/serial.d.mts.map +1 -1
- package/dist/transactions/intents/CoinWithBalance.d.mts.map +1 -1
- package/dist/transactions/intents/CoinWithBalance.mjs +169 -92
- 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/resolve.d.mts.map +1 -1
- package/dist/transactions/serializer.d.mts.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.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/format.d.mts.map +1 -1
- package/dist/utils/move-registry.d.mts.map +1 -1
- package/dist/utils/sui-types.d.mts.map +1 -1
- package/dist/utils/suins.d.mts.map +1 -1
- package/dist/verify/verify.d.mts.map +1 -1
- package/dist/version.mjs +2 -2
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/address.d.mts.map +1 -1
- 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/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/package.json +3 -3
- package/src/client/core-resolver.ts +166 -125
- package/src/jsonRpc/client.ts +1 -19
- package/src/jsonRpc/core.ts +15 -14
- package/src/transactions/Transaction.ts +38 -1
- package/src/transactions/intents/CoinWithBalance.ts +243 -117
- package/src/utils/coin-reservation.ts +84 -0
- package/src/version.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-utils.d.mts","names":[],"sources":["../../src/zklogin/jwt-utils.ts"],"
|
|
1
|
+
{"version":3,"file":"jwt-utils.d.mts","names":[],"sources":["../../src/zklogin/jwt-utils.ts"],"mappings":";;;iBAsHgB,SAAA,CAAU,GAAA,WAAc,IAAA,CAAK,UAAA;EAC5C,GAAA;EACA,GAAA;EACA,GAAA;EACA,MAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nonce.d.mts","names":[],"sources":["../../src/zklogin/nonce.ts"],"
|
|
1
|
+
{"version":3,"file":"nonce.d.mts","names":[],"sources":["../../src/zklogin/nonce.ts"],"mappings":";;;iBAqBgB,kBAAA,CAAA;AAAA,iBAKA,aAAA,CAAc,SAAA,EAAW,SAAA,EAAW,QAAA,UAAkB,UAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poseidon.d.mts","names":[],"sources":["../../src/zklogin/poseidon.ts"],"
|
|
1
|
+
{"version":3,"file":"poseidon.d.mts","names":[],"sources":["../../src/zklogin/poseidon.ts"],"mappings":";iBA4CgB,YAAA,CAAa,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publickey.d.mts","names":[],"sources":["../../src/zklogin/publickey.ts"],"
|
|
1
|
+
{"version":3,"file":"publickey.d.mts","names":[],"sources":["../../src/zklogin/publickey.ts"],"mappings":";;;;;;AAoBA;;cAAa,uBAAA,SAAgC,SAAA;EAAA;EASJ;;;;cAA5B,KAAA,EAAO,iBAAA;IAAqB;EAAA;IAAY,MAAA,GAAS,iBAAA;EAAA;EAAA,OAmBtD,SAAA,CACN,KAAA,EAAO,UAAA;IAEN,MAAA;IACA,OAAA;IACA;EAAA;IACI,MAAA,GAAS,iBAAA;IAAmB,OAAA;IAAkB,aAAA;EAAA,IAA8B,uBAAA;EAAA,OAmC3E,SAAA,CAAU,OAAA,UAAiB,KAAA,EAAO,sBAAA,GAAsB,uBAAA;EAiExC;;;EAvCd,MAAA,CAAO,SAAA,EAAW,uBAAA;EAIlB,YAAA,CAAA;EA0CmE;;;EArB5E,UAAA,CAAA,GAAc,UAAA,CAAW,WAAA;EAxHmB;;;EA+H5C,IAAA,CAAA;;;;EAOM,MAAA,CAAO,QAAA,EAAU,UAAA,EAAY,UAAA,EAAY,UAAA,YAAsB,OAAA;EA7H7B;;;EAoIxC,qBAAA,CAAsB,OAAA,EAAS,UAAA,EAAY,SAAA,EAAW,UAAA,YAAsB,OAAA;EAjHrE;;;EAiIP,iBAAA,CAAkB,WAAA,EAAa,UAAA,EAAY,SAAA,EAAW,UAAA,YAAsB,OAAA;EA9H1E;;;EA6IO,aAAA,CAAc,OAAA;AAAA;AAAA,iBAMR,yBAAA,CACf,WAAA,UACA,GAAA,UACA,OAAA;EAAW,MAAA,GAAS,iBAAA;EAAmB,aAAA;AAAA,IACrC,uBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.d.mts","names":[],"sources":["../../src/zklogin/signature.ts"],"
|
|
1
|
+
{"version":3,"file":"signature.d.mts","names":[],"sources":["../../src/zklogin/signature.ts"],"mappings":";;;UASU,wBAAA,SAAiC,IAAA,CAAK,gBAAA;EAC/C,aAAA,WAAwB,gBAAA;AAAA;AAAA,iBAiBT,mBAAA,CAAA;EAAsB,MAAA;EAAQ,QAAA;EAAU;AAAA,GAAiB,wBAAA;AAAA,iBAQzD,qBAAA,CAAsB,SAAA,WAAoB,UAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.mts","names":[],"sources":["../../src/zklogin/utils.ts"],"
|
|
1
|
+
{"version":3,"file":"utils.d.mts","names":[],"sources":["../../src/zklogin/utils.ts"],"mappings":";;;iBAwBgB,sBAAA,CAAuB,GAAA,UAAa,KAAA,WAAgB,UAAA;AAAA,iBAMpD,gBAAA,CAAiB,GAAA,UAAa,KAAA,WAAgB,UAAA;AAAA,iBAY9C,6BAAA,CAA8B,SAAA,EAAW,SAAA;AAAA,iBA8BzC,mBAAA,CAAoB,GAAA,UAAa,OAAA;AAAA,iBAiBjC,cAAA,CACf,IAAA,mBACA,IAAA,UACA,KAAA,UACA,GAAA,UACA,eAAA,WACA,gBAAA,WACA,cAAA"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
4
4
|
"description": "Sui TypeScript API",
|
|
5
5
|
"homepage": "https://sdk.mystenlabs.com",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.13.1",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"files": [
|
|
@@ -167,8 +167,8 @@
|
|
|
167
167
|
"graphql": "^16.12.0",
|
|
168
168
|
"poseidon-lite": "0.2.1",
|
|
169
169
|
"valibot": "^1.2.0",
|
|
170
|
-
"@mysten/
|
|
171
|
-
"@mysten/
|
|
170
|
+
"@mysten/utils": "^0.3.1",
|
|
171
|
+
"@mysten/bcs": "^2.0.3"
|
|
172
172
|
},
|
|
173
173
|
"scripts": {
|
|
174
174
|
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import {
|
|
5
|
+
normalizeSuiAddress,
|
|
6
|
+
normalizeSuiObjectId,
|
|
7
|
+
normalizeStructTag,
|
|
8
|
+
SUI_TYPE_ARG,
|
|
9
|
+
} from '../utils/index.js';
|
|
10
|
+
import { createCoinReservationRef } from '../utils/coin-reservation.js';
|
|
7
11
|
import type { ClientWithCoreApi } from './core.js';
|
|
8
|
-
import { ObjectRefSchema } from '../transactions/data/internal.js';
|
|
9
12
|
import type { CallArg, Command } from '../transactions/data/internal.js';
|
|
10
13
|
import type { SuiClientTypes } from './types.js';
|
|
11
14
|
import { SimulationError } from './errors.js';
|
|
@@ -22,6 +25,20 @@ const MAX_OBJECTS_PER_FETCH = 50;
|
|
|
22
25
|
const GAS_SAFE_OVERHEAD = 1000n;
|
|
23
26
|
const MAX_GAS = 50_000_000_000;
|
|
24
27
|
|
|
28
|
+
/** Compute a gas budget from gasUsed effects data. */
|
|
29
|
+
export function computeGasBudget(
|
|
30
|
+
gasUsed: { computationCost: string; storageCost: string; storageRebate: string },
|
|
31
|
+
gasPrice: bigint | string = 1n,
|
|
32
|
+
): string {
|
|
33
|
+
const safeOverhead = GAS_SAFE_OVERHEAD * BigInt(gasPrice);
|
|
34
|
+
const baseComputationCostWithOverhead = BigInt(gasUsed.computationCost) + safeOverhead;
|
|
35
|
+
const gasBudget =
|
|
36
|
+
baseComputationCostWithOverhead + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);
|
|
37
|
+
return String(
|
|
38
|
+
gasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
25
42
|
function getClient(options: BuildTransactionOptions): ClientWithCoreApi {
|
|
26
43
|
if (!options.client) {
|
|
27
44
|
throw new Error(
|
|
@@ -38,36 +55,89 @@ export async function coreClientResolveTransactionPlugin(
|
|
|
38
55
|
) {
|
|
39
56
|
const client = getClient(options);
|
|
40
57
|
|
|
41
|
-
|
|
42
|
-
|
|
58
|
+
const needsGasPrice = !options.onlyTransactionKind && !transactionData.gasData.price;
|
|
59
|
+
const needsPayment = !options.onlyTransactionKind && !transactionData.gasData.payment;
|
|
60
|
+
const gasPayer = transactionData.gasData.owner ?? transactionData.sender;
|
|
43
61
|
|
|
44
|
-
|
|
45
|
-
|
|
62
|
+
let usesGasCoin = false;
|
|
63
|
+
let withdrawals = 0n;
|
|
64
|
+
|
|
65
|
+
transactionData.mapArguments((arg) => {
|
|
66
|
+
if (arg.$kind === 'GasCoin') usesGasCoin = true;
|
|
67
|
+
return arg;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const normalizedGasPayer = gasPayer ? normalizeSuiAddress(gasPayer) : null;
|
|
71
|
+
for (const input of transactionData.inputs) {
|
|
72
|
+
if (input.$kind !== 'FundsWithdrawal' || !normalizedGasPayer) continue;
|
|
73
|
+
if (normalizeStructTag(input.FundsWithdrawal.typeArg.Balance) !== SUI_TYPE_ARG) continue;
|
|
74
|
+
|
|
75
|
+
const withdrawalOwner = input.FundsWithdrawal.withdrawFrom.Sender
|
|
76
|
+
? transactionData.sender
|
|
77
|
+
: gasPayer;
|
|
78
|
+
if (
|
|
79
|
+
withdrawalOwner &&
|
|
80
|
+
normalizeSuiAddress(withdrawalOwner) === normalizedGasPayer &&
|
|
81
|
+
input.FundsWithdrawal.reservation.$kind === 'MaxAmountU64'
|
|
82
|
+
) {
|
|
83
|
+
withdrawals += BigInt(input.FundsWithdrawal.reservation.MaxAmountU64);
|
|
84
|
+
}
|
|
46
85
|
}
|
|
47
86
|
|
|
48
|
-
|
|
49
|
-
|
|
87
|
+
const needsSystemState = needsGasPrice || (needsPayment && usesGasCoin);
|
|
88
|
+
const [, systemStateResult, balanceResult, coinsResult, protocolConfigResult, chainIdResult] =
|
|
89
|
+
await Promise.all([
|
|
90
|
+
normalizeInputs(transactionData, client),
|
|
91
|
+
needsSystemState ? client.core.getCurrentSystemState() : null,
|
|
92
|
+
needsPayment && gasPayer ? client.core.getBalance({ owner: gasPayer }) : null,
|
|
93
|
+
needsPayment && gasPayer
|
|
94
|
+
? client.core.listCoins({ owner: gasPayer, coinType: SUI_TYPE_ARG })
|
|
95
|
+
: null,
|
|
96
|
+
needsPayment && usesGasCoin ? client.core.getProtocolConfig() : null,
|
|
97
|
+
needsPayment && usesGasCoin ? client.core.getChainIdentifier() : null,
|
|
98
|
+
]);
|
|
50
99
|
|
|
51
|
-
|
|
52
|
-
epoch: string;
|
|
53
|
-
referenceGasPrice: string;
|
|
54
|
-
}
|
|
100
|
+
await resolveObjectReferences(transactionData, client);
|
|
55
101
|
|
|
56
|
-
|
|
57
|
-
|
|
102
|
+
if (!options.onlyTransactionKind) {
|
|
103
|
+
const systemState = systemStateResult?.systemState ?? null;
|
|
58
104
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
transactionData.gasData.price = systemState.referenceGasPrice;
|
|
63
|
-
}
|
|
105
|
+
if (systemState && !transactionData.gasData.price) {
|
|
106
|
+
transactionData.gasData.price = systemState.referenceGasPrice;
|
|
107
|
+
}
|
|
64
108
|
|
|
65
|
-
|
|
66
|
-
|
|
109
|
+
await setGasBudget(transactionData, client);
|
|
110
|
+
|
|
111
|
+
if (needsPayment) {
|
|
112
|
+
if (!balanceResult || !coinsResult) {
|
|
113
|
+
throw new Error(
|
|
114
|
+
'Could not resolve gas payment: a gas owner or sender must be set to fetch balance and coins.',
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
setGasPayment({
|
|
118
|
+
transactionData,
|
|
119
|
+
balance: balanceResult,
|
|
120
|
+
coins: coinsResult,
|
|
121
|
+
usesGasCoin,
|
|
122
|
+
withdrawals,
|
|
123
|
+
protocolConfig: protocolConfigResult?.protocolConfig,
|
|
124
|
+
gasPayer: gasPayer!,
|
|
125
|
+
chainIdentifier: chainIdResult?.chainIdentifier ?? null,
|
|
126
|
+
epoch: systemState?.epoch ?? null,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
67
129
|
|
|
68
|
-
|
|
69
|
-
|
|
130
|
+
if (!transactionData.expiration && transactionData.gasData.payment?.length === 0) {
|
|
131
|
+
await setExpiration(
|
|
132
|
+
transactionData,
|
|
133
|
+
client,
|
|
134
|
+
systemState,
|
|
135
|
+
chainIdResult?.chainIdentifier ?? null,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
70
138
|
}
|
|
139
|
+
|
|
140
|
+
return await next();
|
|
71
141
|
}
|
|
72
142
|
|
|
73
143
|
async function setGasBudget(transactionData: TransactionDataBuilder, client: ClientWithCoreApi) {
|
|
@@ -96,113 +166,95 @@ async function setGasBudget(transactionData: TransactionDataBuilder, client: Cli
|
|
|
96
166
|
});
|
|
97
167
|
}
|
|
98
168
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const baseComputationCostWithOverhead = BigInt(gasUsed.computationCost) + safeOverhead;
|
|
103
|
-
|
|
104
|
-
const gasBudget =
|
|
105
|
-
baseComputationCostWithOverhead + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);
|
|
106
|
-
|
|
107
|
-
transactionData.gasData.budget = String(
|
|
108
|
-
gasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead,
|
|
169
|
+
transactionData.gasData.budget = computeGasBudget(
|
|
170
|
+
simulateResult.Transaction.effects!.gasUsed,
|
|
171
|
+
transactionData.gasData.price ? String(transactionData.gasData.price) : undefined,
|
|
109
172
|
);
|
|
110
173
|
}
|
|
111
174
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
175
|
+
function setGasPayment({
|
|
176
|
+
transactionData,
|
|
177
|
+
balance,
|
|
178
|
+
coins,
|
|
179
|
+
usesGasCoin,
|
|
180
|
+
withdrawals,
|
|
181
|
+
protocolConfig,
|
|
182
|
+
gasPayer,
|
|
183
|
+
chainIdentifier,
|
|
184
|
+
epoch,
|
|
185
|
+
}: {
|
|
186
|
+
transactionData: TransactionDataBuilder;
|
|
187
|
+
balance: SuiClientTypes.GetBalanceResponse;
|
|
188
|
+
coins: SuiClientTypes.ListCoinsResponse;
|
|
189
|
+
usesGasCoin: boolean;
|
|
190
|
+
withdrawals: bigint;
|
|
191
|
+
protocolConfig: SuiClientTypes.ProtocolConfig | undefined;
|
|
192
|
+
gasPayer: string;
|
|
193
|
+
chainIdentifier: string | null;
|
|
194
|
+
epoch: string | null;
|
|
195
|
+
}) {
|
|
196
|
+
const budget = BigInt(transactionData.gasData.budget!);
|
|
197
|
+
const addressBalance = BigInt(balance.balance.addressBalance);
|
|
198
|
+
|
|
199
|
+
if (budget === 0n || (!usesGasCoin && addressBalance >= budget + withdrawals)) {
|
|
200
|
+
transactionData.gasData.payment = [];
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
119
203
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
transactionData.mapArguments((arg) => {
|
|
125
|
-
if (arg.$kind === 'GasCoin') {
|
|
126
|
-
usesGasCoin = true;
|
|
127
|
-
} else if (arg.$kind === 'Input') {
|
|
128
|
-
const input = transactionData.inputs[arg.Input];
|
|
129
|
-
|
|
130
|
-
if (input.$kind === 'FundsWithdrawal') {
|
|
131
|
-
const withdrawalOwner = input.FundsWithdrawal.withdrawFrom.Sender
|
|
132
|
-
? transactionData.sender
|
|
133
|
-
: gasPayer;
|
|
134
|
-
|
|
135
|
-
if (withdrawalOwner && normalizeSuiAddress(withdrawalOwner) === normalizedGasPayer) {
|
|
136
|
-
if (input.FundsWithdrawal.reservation.$kind === 'MaxAmountU64') {
|
|
137
|
-
withdrawals += BigInt(input.FundsWithdrawal.reservation.MaxAmountU64);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
204
|
+
const filteredCoins = coins.objects.filter((coin) => {
|
|
205
|
+
const matchingInput = transactionData.inputs.find((input) => {
|
|
206
|
+
if (input.Object?.ImmOrOwnedObject) {
|
|
207
|
+
return coin.objectId === input.Object.ImmOrOwnedObject.objectId;
|
|
141
208
|
}
|
|
142
209
|
|
|
143
|
-
return
|
|
210
|
+
return false;
|
|
144
211
|
});
|
|
145
212
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
client.core.listCoins({
|
|
149
|
-
owner: gasPayer,
|
|
150
|
-
coinType: SUI_TYPE_ARG,
|
|
151
|
-
}),
|
|
152
|
-
]);
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
suiBalance?.balance.addressBalance &&
|
|
156
|
-
BigInt(suiBalance.balance.addressBalance) >=
|
|
157
|
-
BigInt(transactionData.gasData.budget || '0') + withdrawals
|
|
158
|
-
) {
|
|
159
|
-
transactionData.gasData.payment = [];
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const paymentCoins = coins.objects
|
|
164
|
-
// Filter out coins that are also used as input:
|
|
165
|
-
.filter((coin) => {
|
|
166
|
-
const matchingInput = transactionData.inputs.find((input) => {
|
|
167
|
-
if (input.Object?.ImmOrOwnedObject) {
|
|
168
|
-
return coin.objectId === input.Object.ImmOrOwnedObject.objectId;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return false;
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
return !matchingInput;
|
|
175
|
-
})
|
|
176
|
-
.map((coin) =>
|
|
177
|
-
parse(ObjectRefSchema, {
|
|
178
|
-
objectId: coin.objectId,
|
|
179
|
-
digest: coin.digest,
|
|
180
|
-
version: coin.version,
|
|
181
|
-
}),
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
if (!paymentCoins.length) {
|
|
185
|
-
throw new Error('No valid gas coins found for the transaction.');
|
|
186
|
-
}
|
|
213
|
+
return !matchingInput;
|
|
214
|
+
});
|
|
187
215
|
|
|
216
|
+
const paymentCoins = filteredCoins.map((coin) => ({
|
|
217
|
+
objectId: coin.objectId,
|
|
218
|
+
digest: coin.digest,
|
|
219
|
+
version: coin.version,
|
|
220
|
+
}));
|
|
221
|
+
|
|
222
|
+
const reservationAmount = addressBalance - withdrawals;
|
|
223
|
+
|
|
224
|
+
if (
|
|
225
|
+
usesGasCoin &&
|
|
226
|
+
reservationAmount > 0n &&
|
|
227
|
+
protocolConfig?.featureFlags?.['enable_coin_reservation_obj_refs'] &&
|
|
228
|
+
chainIdentifier &&
|
|
229
|
+
epoch
|
|
230
|
+
) {
|
|
231
|
+
transactionData.gasData.payment = [
|
|
232
|
+
createCoinReservationRef(reservationAmount, gasPayer, chainIdentifier, epoch),
|
|
233
|
+
...paymentCoins,
|
|
234
|
+
];
|
|
235
|
+
} else if (!filteredCoins.length) {
|
|
236
|
+
throw new Error('No valid gas coins found for the transaction.');
|
|
237
|
+
} else {
|
|
188
238
|
transactionData.gasData.payment = paymentCoins;
|
|
189
239
|
}
|
|
190
240
|
}
|
|
191
241
|
|
|
242
|
+
interface SystemStateData {
|
|
243
|
+
epoch: string;
|
|
244
|
+
referenceGasPrice: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
192
247
|
async function setExpiration(
|
|
193
248
|
transactionData: TransactionDataBuilder,
|
|
194
249
|
client: ClientWithCoreApi,
|
|
195
|
-
|
|
250
|
+
systemState: SystemStateData | null,
|
|
251
|
+
existingChainIdentifier: string | null = null,
|
|
196
252
|
) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const [systemState, { chainIdentifier }] = await Promise.all([
|
|
202
|
-
existingSystemState ?? client.core.getCurrentSystemState().then((r) => r.systemState),
|
|
203
|
-
client.core.getChainIdentifier(),
|
|
253
|
+
const [chainIdentifier, resolvedSystemState] = await Promise.all([
|
|
254
|
+
existingChainIdentifier ?? client.core.getChainIdentifier().then((r) => r.chainIdentifier),
|
|
255
|
+
systemState ?? client.core.getCurrentSystemState().then((r) => r.systemState),
|
|
204
256
|
]);
|
|
205
|
-
const currentEpoch = BigInt(
|
|
257
|
+
const currentEpoch = BigInt(resolvedSystemState.epoch);
|
|
206
258
|
|
|
207
259
|
transactionData.expiration = {
|
|
208
260
|
$kind: 'ValidDuring',
|
|
@@ -217,17 +269,6 @@ async function setExpiration(
|
|
|
217
269
|
};
|
|
218
270
|
}
|
|
219
271
|
|
|
220
|
-
function hasVersionedInputs(transactionData: TransactionDataBuilder): boolean {
|
|
221
|
-
if (transactionData.gasData.payment?.length) {
|
|
222
|
-
return true;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return transactionData.inputs.some(
|
|
226
|
-
(input) =>
|
|
227
|
-
input.Object?.ImmOrOwnedObject || (input.UnresolvedObject && input.UnresolvedObject.version),
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
272
|
async function resolveObjectReferences(
|
|
232
273
|
transactionData: TransactionDataBuilder,
|
|
233
274
|
client: ClientWithCoreApi,
|
package/src/jsonRpc/client.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { fromBase58, toBase64, toHex } from '@mysten/bcs';
|
|
|
5
5
|
import type { Signer } from '../cryptography/index.js';
|
|
6
6
|
import { BaseClient } from '../client/client.js';
|
|
7
7
|
import type { SuiClientTypes } from '../client/types.js';
|
|
8
|
+
import { isCoinReservationDigest } from '../utils/coin-reservation.js';
|
|
8
9
|
import type { Transaction } from '../transactions/Transaction.js';
|
|
9
10
|
import { isTransaction } from '../transactions/Transaction.js';
|
|
10
11
|
import {
|
|
@@ -128,25 +129,6 @@ type NetworkOrTransport =
|
|
|
128
129
|
|
|
129
130
|
const SUI_CLIENT_BRAND = Symbol.for('@mysten/SuiJsonRpcClient') as never;
|
|
130
131
|
|
|
131
|
-
// Magic number used to identify fake address balance coins (last 20 bytes of the digest)
|
|
132
|
-
// See: sui/crates/sui-types/src/coin_reservation.rs
|
|
133
|
-
const COIN_RESERVATION_MAGIC = new Uint8Array([
|
|
134
|
-
0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
|
|
135
|
-
0xac, 0xac, 0xac, 0xac,
|
|
136
|
-
]);
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Checks if a digest indicates a fake address balance coin.
|
|
140
|
-
* These "coins" are created by the JSON RPC to represent address balances
|
|
141
|
-
* and should be filtered out from coin listings.
|
|
142
|
-
*/
|
|
143
|
-
function isCoinReservationDigest(digestBase58: string): boolean {
|
|
144
|
-
const digestBytes = fromBase58(digestBase58);
|
|
145
|
-
// Check if the last 20 bytes match the magic number
|
|
146
|
-
const last20Bytes = digestBytes.slice(12, 32);
|
|
147
|
-
return last20Bytes.every((byte, i) => byte === COIN_RESERVATION_MAGIC[i]);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
132
|
export function isSuiJsonRpcClient(client: unknown): client is SuiJsonRpcClient {
|
|
151
133
|
return (
|
|
152
134
|
typeof client === 'object' && client !== null && (client as any)[SUI_CLIENT_BRAND] === true
|
package/src/jsonRpc/core.ts
CHANGED
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
TransactionEffects,
|
|
21
21
|
} from './types/index.js';
|
|
22
22
|
import { Transaction } from '../transactions/Transaction.js';
|
|
23
|
-
import { coreClientResolveTransactionPlugin } from '../client/core-resolver.js';
|
|
23
|
+
import { computeGasBudget, coreClientResolveTransactionPlugin } from '../client/core-resolver.js';
|
|
24
24
|
import { TransactionDataBuilder } from '../transactions/TransactionData.js';
|
|
25
25
|
import { chunk } from '@mysten/utils';
|
|
26
26
|
import { normalizeSuiAddress, normalizeStructTag } from '../utils/sui-types.js';
|
|
@@ -395,9 +395,19 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
395
395
|
|
|
396
396
|
const { effects, objectTypes } = parseTransactionEffectsJson({
|
|
397
397
|
effects: effectsSource.effects,
|
|
398
|
-
objectChanges: dryRunResult?.objectChanges ?? [],
|
|
398
|
+
objectChanges: (!dryRunFailed ? dryRunResult?.objectChanges : null) ?? [],
|
|
399
399
|
});
|
|
400
400
|
|
|
401
|
+
let parsedTransaction: SuiClientTypes.TransactionData | undefined;
|
|
402
|
+
if (options.include?.transaction) {
|
|
403
|
+
parsedTransaction = parseTransactionBcs(transactionBytes);
|
|
404
|
+
if (data && !dryRunFailed && effects.gasUsed) {
|
|
405
|
+
if (!data.gasData.budget) {
|
|
406
|
+
parsedTransaction.gasData.budget = computeGasBudget(effects.gasUsed);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
401
411
|
const transactionData: SuiClientTypes.Transaction<Include> = {
|
|
402
412
|
digest: TransactionDataBuilder.getDigestFromBytes(transactionBytes),
|
|
403
413
|
epoch: null,
|
|
@@ -409,21 +419,12 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
409
419
|
? objectTypes
|
|
410
420
|
: undefined) as SuiClientTypes.Transaction<Include>['objectTypes'],
|
|
411
421
|
signatures: [],
|
|
412
|
-
transaction: (
|
|
413
|
-
|
|
414
|
-
options.transaction instanceof Uint8Array
|
|
415
|
-
? options.transaction
|
|
416
|
-
: await options.transaction
|
|
417
|
-
.build({
|
|
418
|
-
client: this,
|
|
419
|
-
})
|
|
420
|
-
.catch(() => null as never),
|
|
421
|
-
)
|
|
422
|
-
: undefined) as SuiClientTypes.Transaction<Include>['transaction'],
|
|
422
|
+
transaction: (parsedTransaction ??
|
|
423
|
+
undefined) as SuiClientTypes.Transaction<Include>['transaction'],
|
|
423
424
|
bcs: (options.include?.bcs
|
|
424
425
|
? transactionBytes
|
|
425
426
|
: undefined) as SuiClientTypes.Transaction<Include>['bcs'],
|
|
426
|
-
balanceChanges: (options.include?.balanceChanges && dryRunResult
|
|
427
|
+
balanceChanges: (options.include?.balanceChanges && dryRunResult && !dryRunFailed
|
|
427
428
|
? dryRunResult.balanceChanges.map((change) => ({
|
|
428
429
|
coinType: normalizeStructTag(change.coinType),
|
|
429
430
|
address: parseOwnerAddress(change.owner)!,
|
|
@@ -31,7 +31,12 @@ import { createPure } from './pure.js';
|
|
|
31
31
|
import { TransactionDataBuilder } from './TransactionData.js';
|
|
32
32
|
import { getIdFromCallArg } from './utils.js';
|
|
33
33
|
import { namedPackagesPlugin } from './plugins/NamedPackagesPlugin.js';
|
|
34
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
COIN_WITH_BALANCE,
|
|
36
|
+
resolveCoinBalance,
|
|
37
|
+
coinWithBalance,
|
|
38
|
+
createBalance,
|
|
39
|
+
} from './intents/CoinWithBalance.js';
|
|
35
40
|
import type { ClientWithCoreApi } from '../client/core.js';
|
|
36
41
|
|
|
37
42
|
export type TransactionObjectArgument =
|
|
@@ -307,6 +312,38 @@ export class Transaction {
|
|
|
307
312
|
return { $kind: 'GasCoin' as const, GasCoin: true as const };
|
|
308
313
|
}
|
|
309
314
|
|
|
315
|
+
/**
|
|
316
|
+
* Creates a coin of the specified type and balance.
|
|
317
|
+
* Sourced from address balance when available, falling back to owned coins.
|
|
318
|
+
*/
|
|
319
|
+
coin({
|
|
320
|
+
type,
|
|
321
|
+
balance,
|
|
322
|
+
useGasCoin,
|
|
323
|
+
}: {
|
|
324
|
+
balance: bigint | number;
|
|
325
|
+
type?: string;
|
|
326
|
+
useGasCoin?: boolean;
|
|
327
|
+
}): TransactionResult {
|
|
328
|
+
return this.add(coinWithBalance({ type, balance, useGasCoin }));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Creates a Balance object of the specified type and balance.
|
|
333
|
+
* Sourced from address balance when available, falling back to owned coins.
|
|
334
|
+
*/
|
|
335
|
+
balance({
|
|
336
|
+
type,
|
|
337
|
+
balance,
|
|
338
|
+
useGasCoin,
|
|
339
|
+
}: {
|
|
340
|
+
balance: bigint | number;
|
|
341
|
+
type?: string;
|
|
342
|
+
useGasCoin?: boolean;
|
|
343
|
+
}): TransactionResult {
|
|
344
|
+
return this.add(createBalance({ type, balance, useGasCoin }));
|
|
345
|
+
}
|
|
346
|
+
|
|
310
347
|
/**
|
|
311
348
|
* Add a new object input to the transaction.
|
|
312
349
|
*/
|