@mysten/sui 2.30.0 → 2.31.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.
Files changed (79) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/bcs/bcs.d.mts.map +1 -1
  4. package/dist/bcs/bcs.mjs +5 -1
  5. package/dist/bcs/bcs.mjs.map +1 -1
  6. package/dist/bcs/index.d.mts +103 -11
  7. package/dist/bcs/index.d.mts.map +1 -1
  8. package/dist/bcs/types.d.mts.map +1 -1
  9. package/dist/client/core-resolver.mjs +2 -1
  10. package/dist/client/core-resolver.mjs.map +1 -1
  11. package/dist/client/transaction-resolver.mjs +35 -8
  12. package/dist/client/transaction-resolver.mjs.map +1 -1
  13. package/dist/cryptography/signature.d.mts +6 -6
  14. package/dist/graphql/generated/tada-env.d.mts +74 -0
  15. package/dist/grpc/proto/sui/rpc/v2/input.d.mts +21 -1
  16. package/dist/grpc/proto/sui/rpc/v2/input.d.mts.map +1 -1
  17. package/dist/grpc/proto/sui/rpc/v2/input.mjs +21 -0
  18. package/dist/grpc/proto/sui/rpc/v2/input.mjs.map +1 -1
  19. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  20. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  21. package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
  22. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  23. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  24. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  25. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  26. package/dist/jsonRpc/core.mjs +1 -1
  27. package/dist/jsonRpc/core.mjs.map +1 -1
  28. package/dist/transactions/Transaction.d.mts +44 -39
  29. package/dist/transactions/Transaction.d.mts.map +1 -1
  30. package/dist/transactions/Transaction.mjs +65 -24
  31. package/dist/transactions/Transaction.mjs.map +1 -1
  32. package/dist/transactions/data/internal.d.mts +12 -0
  33. package/dist/transactions/data/internal.d.mts.map +1 -1
  34. package/dist/transactions/data/internal.mjs +5 -1
  35. package/dist/transactions/data/internal.mjs.map +1 -1
  36. package/dist/transactions/data/v2.d.mts +5 -0
  37. package/dist/transactions/data/v2.d.mts.map +1 -1
  38. package/dist/transactions/index.d.mts +3 -2
  39. package/dist/transactions/intents/AllowanceBalance.mjs +147 -0
  40. package/dist/transactions/intents/AllowanceBalance.mjs.map +1 -0
  41. package/dist/transactions/intents/BalanceIntentNames.mjs +7 -0
  42. package/dist/transactions/intents/BalanceIntentNames.mjs.map +1 -0
  43. package/dist/transactions/intents/BalanceOptions.d.mts +27 -0
  44. package/dist/transactions/intents/BalanceOptions.d.mts.map +1 -0
  45. package/dist/transactions/intents/BalanceOptions.mjs +12 -0
  46. package/dist/transactions/intents/BalanceOptions.mjs.map +1 -0
  47. package/dist/transactions/intents/CoinWithBalance.d.mts.map +1 -1
  48. package/dist/transactions/intents/CoinWithBalance.mjs +31 -10
  49. package/dist/transactions/intents/CoinWithBalance.mjs.map +1 -1
  50. package/dist/transactions/intents/ResolveBalances.mjs +16 -0
  51. package/dist/transactions/intents/ResolveBalances.mjs.map +1 -0
  52. package/dist/transactions/resolve.d.mts.map +1 -1
  53. package/dist/transactions/resolve.mjs +1 -1
  54. package/dist/transactions/resolve.mjs.map +1 -1
  55. package/dist/version.mjs +1 -1
  56. package/dist/version.mjs.map +1 -1
  57. package/dist/zklogin/bcs.d.mts +14 -14
  58. package/docs/llms-index.md +1 -0
  59. package/docs/transactions/allowances.md +176 -0
  60. package/docs/transactions/coins-and-balances.md +12 -9
  61. package/package.json +1 -1
  62. package/src/bcs/bcs.ts +4 -0
  63. package/src/bcs/types.ts +2 -1
  64. package/src/client/core-resolver.ts +6 -4
  65. package/src/client/transaction-resolver.ts +43 -9
  66. package/src/graphql/generated/schema.graphql +87 -42
  67. package/src/graphql/generated/tada-env.ts +84 -0
  68. package/src/grpc/proto/sui/rpc/v2/input.ts +22 -0
  69. package/src/jsonRpc/core.ts +3 -4
  70. package/src/transactions/Transaction.ts +70 -49
  71. package/src/transactions/data/internal.ts +4 -0
  72. package/src/transactions/index.ts +3 -0
  73. package/src/transactions/intents/AllowanceBalance.ts +204 -0
  74. package/src/transactions/intents/BalanceIntentNames.ts +5 -0
  75. package/src/transactions/intents/BalanceOptions.ts +45 -0
  76. package/src/transactions/intents/CoinWithBalance.ts +51 -8
  77. package/src/transactions/intents/ResolveBalances.ts +30 -0
  78. package/src/transactions/resolve.ts +6 -0
  79. package/src/version.ts +1 -1
@@ -94,14 +94,15 @@ type Address implements Node & IAddressable {
94
94
  """
95
95
  asTransactionObject(transactionDigest: String): TransactionObject
96
96
  """
97
- Fetch the total balance for coins with marker type `coinType` (e.g. `0x2::sui::SUI`), owned by this address.
97
+ Fetch the balance for `coinType` (e.g. `0x2::sui::SUI`) owned by this address.
98
98
 
99
- Returns `None` when no checkpoint is set in scope (e.g. execution scope).
100
- If the address does not own any coins of that type, a balance of zero is returned.
99
+ The result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. Returns `null` when no checkpoint is set in scope (e.g. execution scope). If this address has no balance of that type, all three values are zero.
101
100
  """
102
101
  balance(coinType: String!): Balance
103
102
  """
104
- Total balance across coins owned by this address, grouped by coin type.
103
+ Balances held by this address, grouped by coin type.
104
+
105
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator.
105
106
  """
106
107
  balances(first: Int, after: String, last: Int, before: String): BalanceConnection
107
108
  """
@@ -131,10 +132,9 @@ type Address implements Node & IAddressable {
131
132
  """
132
133
  id: ID!
133
134
  """
134
- Fetch the total balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
135
+ Fetch balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
135
136
 
136
- Returns `None` when no checkpoint is set in scope (e.g. execution scope).
137
- If the address does not own any coins of a given type, a balance of zero is returned for that type.
137
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. Returns `null` when no checkpoint is set in scope (e.g. execution scope). If this address has no balance of a given type, all three values are zero for that type.
138
138
  """
139
139
  multiGetBalances(keys: [String!]!): [Balance!]
140
140
  """
@@ -279,15 +279,17 @@ type AvailableRange {
279
279
  }
280
280
 
281
281
  """
282
- The total balance for a particular coin type.
282
+ The balance of a particular coin type held by an address.
283
+
284
+ Balances can be held in coin objects, in the address's balance accumulator, or both.
283
285
  """
284
286
  type Balance {
285
287
  """
286
- The balance as tracked by the accumulator object for the address.
288
+ The balance held in the address's balance accumulator.
287
289
  """
288
290
  addressBalance: BigInt
289
291
  """
290
- Total balance across all owned coin objects of the coin type.
292
+ The balance held in coin objects owned by the address.
291
293
  """
292
294
  coinBalance: BigInt
293
295
  """
@@ -295,7 +297,7 @@ type Balance {
295
297
  """
296
298
  coinType: MoveType
297
299
  """
298
- The sum total of the accumulator balance and individual coin balances owned by the address.
300
+ The sum of `coinBalance` and `addressBalance`.
299
301
  """
300
302
  totalBalance: BigInt
301
303
  }
@@ -376,10 +378,32 @@ type BalanceEdge {
376
378
  node: Balance!
377
379
  }
378
380
 
381
+ """
382
+ Identifies the balance for one coin type owned by an address.
383
+ """
384
+ input BalanceKey {
385
+ """
386
+ The address that owns the balance.
387
+ """
388
+ address: SuiAddress!
389
+ """
390
+ The coin type of the balance.
391
+ """
392
+ coinType: String!
393
+ }
394
+
379
395
  """
380
396
  Input for withdrawing funds from an accumulator.
381
397
  """
382
398
  type BalanceWithdraw {
399
+ """
400
+ The allowance authorizing the withdrawal, if `withdrawFrom` is `SENDER_ALLOWANCE`. Use `asTransactionObject` to see it as this transaction referenced it.
401
+ """
402
+ allowance: Address
403
+ """
404
+ The account whose funds are withdrawn, if `withdrawFrom` is `SENDER_ALLOWANCE`.
405
+ """
406
+ funder: Address
383
407
  """
384
408
  How much to withdraw from the accumulator.
385
409
  """
@@ -637,13 +661,15 @@ type CoinMetadata implements IAddressable & IMoveObject & IObject {
637
661
  """
638
662
  asTransactionObject(transactionDigest: String): TransactionObject
639
663
  """
640
- Fetch the total balance for coins with marker type `coinType` (e.g. `0x2::sui::SUI`), owned by this address.
664
+ Fetch the balance for `coinType` (e.g. `0x2::sui::SUI`) owned by this address.
641
665
 
642
- If the address does not own any coins of that type, a balance of zero is returned.
666
+ The result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. If this address has no balance of that type, all three values are zero.
643
667
  """
644
668
  balance(coinType: String!): Balance
645
669
  """
646
- Total balance across coins owned by this address, grouped by coin type.
670
+ Balances held by this address, grouped by coin type.
671
+
672
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator.
647
673
  """
648
674
  balances(first: Int, after: String, last: Int, before: String): BalanceConnection
649
675
  """
@@ -703,9 +729,9 @@ type CoinMetadata implements IAddressable & IMoveObject & IObject {
703
729
  """
704
730
  moveObjectBcs: Base64
705
731
  """
706
- Fetch the total balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
732
+ Fetch balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
707
733
 
708
- If the address does not own any coins of a given type, a balance of zero is returned for that type.
734
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. Returns `null` when no checkpoint is set in scope (e.g. execution scope). If this address has no balance of a given type, all three values are zero for that type.
709
735
  """
710
736
  multiGetBalances(keys: [String!]!): [Balance!]
711
737
  """
@@ -1016,13 +1042,15 @@ type DynamicField implements Node & IAddressable & IMoveObject & IObject {
1016
1042
  """
1017
1043
  asTransactionObject(transactionDigest: String): TransactionObject
1018
1044
  """
1019
- Fetch the total balance for coins with marker type `coinType` (e.g. `0x2::sui::SUI`), owned by this address.
1045
+ Fetch the balance for `coinType` (e.g. `0x2::sui::SUI`) owned by this address.
1020
1046
 
1021
- If the address does not own any coins of that type, a balance of zero is returned.
1047
+ The result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. If this address has no balance of that type, all three values are zero.
1022
1048
  """
1023
1049
  balance(coinType: String!): Balance
1024
1050
  """
1025
- Total balance across coins owned by this address, grouped by coin type.
1051
+ Balances held by this address, grouped by coin type.
1052
+
1053
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator.
1026
1054
  """
1027
1055
  balances(first: Int, after: String, last: Int, before: String): BalanceConnection
1028
1056
  """
@@ -1070,9 +1098,9 @@ type DynamicField implements Node & IAddressable & IMoveObject & IObject {
1070
1098
  """
1071
1099
  moveObjectBcs: Base64
1072
1100
  """
1073
- Fetch the total balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
1101
+ Fetch balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
1074
1102
 
1075
- If the address does not own any coins of a given type, a balance of zero is returned for that type.
1103
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. Returns `null` when no checkpoint is set in scope (e.g. execution scope). If this address has no balance of a given type, all three values are zero for that type.
1076
1104
  """
1077
1105
  multiGetBalances(keys: [String!]!): [Balance!]
1078
1106
  """
@@ -1691,13 +1719,15 @@ interface IAddressable {
1691
1719
  """
1692
1720
  asTransactionObject(transactionDigest: String): TransactionObject
1693
1721
  """
1694
- Fetch the total balance for coins with marker type `coinType` (e.g. `0x2::sui::SUI`), owned by this address.
1722
+ Fetch the balance for `coinType` (e.g. `0x2::sui::SUI`) owned by this address.
1695
1723
 
1696
- If the address does not own any coins of that type, a balance of zero is returned.
1724
+ The result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. Returns `null` when no checkpoint is set in scope (e.g. execution scope). If this address has no balance of that type, all three values are zero.
1697
1725
  """
1698
1726
  balance(coinType: String!): Balance
1699
1727
  """
1700
- Total balance across coins owned by this address, grouped by coin type.
1728
+ Balances held by this address, grouped by coin type.
1729
+
1730
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator.
1701
1731
  """
1702
1732
  balances(first: Int, after: String, last: Int, before: String): BalanceConnection
1703
1733
  """
@@ -1705,9 +1735,9 @@ interface IAddressable {
1705
1735
  """
1706
1736
  defaultNameRecord: NameRecord
1707
1737
  """
1708
- Fetch the total balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
1738
+ Fetch balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
1709
1739
 
1710
- Returns `null` when no checkpoint is set in scope (e.g. execution scope). If the address does not own any coins of a given type, a balance of zero is returned for that type.
1740
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. Returns `null` when no checkpoint is set in scope (e.g. execution scope). If this address has no balance of a given type, all three values are zero for that type.
1711
1741
  """
1712
1742
  multiGetBalances(keys: [String!]!): [Balance!]
1713
1743
  """
@@ -2335,13 +2365,15 @@ type MoveObject implements Node & IAddressable & IMoveObject & IObject {
2335
2365
  """
2336
2366
  asTransactionObject(transactionDigest: String): TransactionObject
2337
2367
  """
2338
- Fetch the total balance for coins with marker type `coinType` (e.g. `0x2::sui::SUI`), owned by this address.
2368
+ Fetch the balance for `coinType` (e.g. `0x2::sui::SUI`) owned by this address.
2339
2369
 
2340
- If the address does not own any coins of that type, a balance of zero is returned.
2370
+ The result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. If this address has no balance of that type, all three values are zero.
2341
2371
  """
2342
2372
  balance(coinType: String!): Balance
2343
2373
  """
2344
- Total balance across coins owned by this address, grouped by coin type.
2374
+ Balances held by this address, grouped by coin type.
2375
+
2376
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator.
2345
2377
  """
2346
2378
  balances(first: Int, after: String, last: Int, before: String): BalanceConnection
2347
2379
  """
@@ -2389,9 +2421,9 @@ type MoveObject implements Node & IAddressable & IMoveObject & IObject {
2389
2421
  """
2390
2422
  moveObjectBcs: Base64
2391
2423
  """
2392
- Fetch the total balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
2424
+ Fetch balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
2393
2425
 
2394
- If the address does not own any coins of a given type, a balance of zero is returned for that type.
2426
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. Returns `null` when no checkpoint is set in scope (e.g. execution scope). If this address has no balance of a given type, all three values are zero for that type.
2395
2427
  """
2396
2428
  multiGetBalances(keys: [String!]!): [Balance!]
2397
2429
  """
@@ -2504,13 +2536,15 @@ type MovePackage implements Node & IAddressable & IObject {
2504
2536
  """
2505
2537
  asTransactionObject(transactionDigest: String): TransactionObject
2506
2538
  """
2507
- Fetch the total balance for coins with marker type `coinType` (e.g. `0x2::sui::SUI`), owned by this address.
2539
+ Fetch the balance for `coinType` (e.g. `0x2::sui::SUI`) owned by this address.
2508
2540
 
2509
- If the address does not own any coins of that type, a balance of zero is returned.
2541
+ The result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. If this address has no balance of that type, all three values are zero.
2510
2542
  """
2511
2543
  balance(coinType: String!): Balance
2512
2544
  """
2513
- Total balance across coins owned by this address, grouped by coin type.
2545
+ Balances held by this address, grouped by coin type.
2546
+
2547
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator.
2514
2548
  """
2515
2549
  balances(first: Int, after: String, last: Int, before: String): BalanceConnection
2516
2550
  """
@@ -2542,9 +2576,9 @@ type MovePackage implements Node & IAddressable & IObject {
2542
2576
  """
2543
2577
  modules(first: Int, after: String, last: Int, before: String): MoveModuleConnection
2544
2578
  """
2545
- Fetch the total balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
2579
+ Fetch balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
2546
2580
 
2547
- If the address does not own any coins of a given type, a balance of zero is returned for that type.
2581
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. Returns `null` when no checkpoint is set in scope (e.g. execution scope). If this address has no balance of a given type, all three values are zero for that type.
2548
2582
  """
2549
2583
  multiGetBalances(keys: [String!]!): [Balance!]
2550
2584
  """
@@ -3035,13 +3069,15 @@ type Object implements Node & IAddressable & IObject {
3035
3069
  """
3036
3070
  asTransactionObject(transactionDigest: String): TransactionObject
3037
3071
  """
3038
- Fetch the total balance for coins with marker type `coinType` (e.g. `0x2::sui::SUI`), owned by this address.
3072
+ Fetch the balance for `coinType` (e.g. `0x2::sui::SUI`) owned by this address.
3039
3073
 
3040
- If the address does not own any coins of that type, a balance of zero is returned.
3074
+ The result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. If this address has no balance of that type, all three values are zero.
3041
3075
  """
3042
3076
  balance(coinType: String!): Balance
3043
3077
  """
3044
- Total balance across coins owned by this address, grouped by coin type.
3078
+ Balances held by this address, grouped by coin type.
3079
+
3080
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator.
3045
3081
  """
3046
3082
  balances(first: Int, after: String, last: Int, before: String): BalanceConnection
3047
3083
  """
@@ -3073,10 +3109,9 @@ type Object implements Node & IAddressable & IObject {
3073
3109
  """
3074
3110
  id: ID!
3075
3111
  """
3076
- Fetch the total balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
3112
+ Fetch balances keyed by coin types (e.g. `0x2::sui::SUI`) owned by this address.
3077
3113
 
3078
- Returns `None` when no checkpoint is set in scope (e.g. execution scope).
3079
- If the address does not own any coins of a given type, a balance of zero is returned for that type.
3114
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. Returns `null` when no checkpoint is set in scope (e.g. execution scope). If this address has no balance of a given type, all three values are zero for that type.
3080
3115
  """
3081
3116
  multiGetBalances(keys: [String!]!): [Balance!]
3082
3117
  """
@@ -3618,6 +3653,12 @@ type Query {
3618
3653
  """
3619
3654
  multiGetAddresses(keys: [AddressKey!]!): [Address]!
3620
3655
  """
3656
+ Fetch balances by their addresses and coin types.
3657
+
3658
+ Each result includes the total balance, the balance held in coin objects, and the balance held in the address's balance accumulator. Returns a list that is guaranteed to be the same length as `keys`. If an address has no balance of a given type, all three values are zero for that key.
3659
+ """
3660
+ multiGetBalances(keys: [BalanceKey!]!): [Balance!]!
3661
+ """
3621
3662
  Fetch checkpoints by their sequence numbers.
3622
3663
 
3623
3664
  Returns a list of checkpoints that is guaranteed to be the same length as `keys`. If a checkpoint in `keys` could not be found in the store, its corresponding entry in the result will be `null`. This could be because the checkpoint does not exist yet, or because it was pruned.
@@ -4638,6 +4679,10 @@ enum WithdrawFrom {
4638
4679
  The funds are withdrawn from the sponsor's account.
4639
4680
  """
4640
4681
  SPONSOR
4682
+ """
4683
+ The funds are withdrawn from the account of an allowance's funder, under an allowance granted to the transaction sender. See `BalanceWithdraw.funder` and `BalanceWithdraw.allowance`.
4684
+ """
4685
+ SENDER_ALLOWANCE
4641
4686
  }
4642
4687
 
4643
4688
  type WithdrawMaxAmountU64 {
@@ -1100,10 +1100,55 @@ const introspection = {
1100
1100
  ],
1101
1101
  "interfaces": []
1102
1102
  },
1103
+ {
1104
+ "kind": "INPUT_OBJECT",
1105
+ "name": "BalanceKey",
1106
+ "inputFields": [
1107
+ {
1108
+ "name": "address",
1109
+ "type": {
1110
+ "kind": "NON_NULL",
1111
+ "ofType": {
1112
+ "kind": "SCALAR",
1113
+ "name": "SuiAddress"
1114
+ }
1115
+ }
1116
+ },
1117
+ {
1118
+ "name": "coinType",
1119
+ "type": {
1120
+ "kind": "NON_NULL",
1121
+ "ofType": {
1122
+ "kind": "SCALAR",
1123
+ "name": "String"
1124
+ }
1125
+ }
1126
+ }
1127
+ ],
1128
+ "isOneOf": false
1129
+ },
1103
1130
  {
1104
1131
  "kind": "OBJECT",
1105
1132
  "name": "BalanceWithdraw",
1106
1133
  "fields": [
1134
+ {
1135
+ "name": "allowance",
1136
+ "type": {
1137
+ "kind": "OBJECT",
1138
+ "name": "Address"
1139
+ },
1140
+ "args": [],
1141
+ "isDeprecated": false
1142
+ },
1143
+ {
1144
+ "name": "funder",
1145
+ "type": {
1146
+ "kind": "OBJECT",
1147
+ "name": "Address"
1148
+ },
1149
+ "args": [],
1150
+ "isDeprecated": false
1151
+ },
1107
1152
  {
1108
1153
  "name": "reservation",
1109
1154
  "type": {
@@ -10922,6 +10967,41 @@ const introspection = {
10922
10967
  ],
10923
10968
  "isDeprecated": false
10924
10969
  },
10970
+ {
10971
+ "name": "multiGetBalances",
10972
+ "type": {
10973
+ "kind": "NON_NULL",
10974
+ "ofType": {
10975
+ "kind": "LIST",
10976
+ "ofType": {
10977
+ "kind": "NON_NULL",
10978
+ "ofType": {
10979
+ "kind": "OBJECT",
10980
+ "name": "Balance"
10981
+ }
10982
+ }
10983
+ }
10984
+ },
10985
+ "args": [
10986
+ {
10987
+ "name": "keys",
10988
+ "type": {
10989
+ "kind": "NON_NULL",
10990
+ "ofType": {
10991
+ "kind": "LIST",
10992
+ "ofType": {
10993
+ "kind": "NON_NULL",
10994
+ "ofType": {
10995
+ "kind": "INPUT_OBJECT",
10996
+ "name": "BalanceKey"
10997
+ }
10998
+ }
10999
+ }
11000
+ }
11001
+ }
11002
+ ],
11003
+ "isDeprecated": false
11004
+ },
10925
11005
  {
10926
11006
  "name": "multiGetCheckpoints",
10927
11007
  "type": {
@@ -13773,6 +13853,10 @@ const introspection = {
13773
13853
  {
13774
13854
  "name": "SPONSOR",
13775
13855
  "isDeprecated": false
13856
+ },
13857
+ {
13858
+ "name": "SENDER_ALLOWANCE",
13859
+ "isDeprecated": false
13776
13860
  }
13777
13861
  ]
13778
13862
  },
@@ -161,6 +161,19 @@ export interface FundsWithdrawal {
161
161
  * @generated from protobuf field: optional sui.rpc.v2.FundsWithdrawal.Source source = 3;
162
162
  */
163
163
  source?: FundsWithdrawal_Source;
164
+ /**
165
+ * The address whose balance is debited if `source` is `SENDER_ALLOWANCE`.
166
+ *
167
+ * @generated from protobuf field: optional string funder = 4;
168
+ */
169
+ funder?: string;
170
+ /**
171
+ * `ObjectId` of the allowance object authorizing the withdrawal if `source`
172
+ * is `SENDER_ALLOWANCE`.
173
+ *
174
+ * @generated from protobuf field: optional string allowance = 5;
175
+ */
176
+ allowance?: string;
164
177
  }
165
178
  /**
166
179
  * @generated from protobuf enum sui.rpc.v2.FundsWithdrawal.Source
@@ -178,6 +191,13 @@ export enum FundsWithdrawal_Source {
178
191
  * @generated from protobuf enum value: SPONSOR = 2;
179
192
  */
180
193
  SPONSOR = 2,
194
+ /**
195
+ * Withdraw from `funder`'s balance under the `allowance` object, granted
196
+ * to the sender of the transaction.
197
+ *
198
+ * @generated from protobuf enum value: SENDER_ALLOWANCE = 3;
199
+ */
200
+ SENDER_ALLOWANCE = 3,
181
201
  }
182
202
  // @generated message type with reflection information, may provide speed optimized methods
183
203
  class Input$Type extends MessageType<Input> {
@@ -238,6 +258,8 @@ class FundsWithdrawal$Type extends MessageType<FundsWithdrawal> {
238
258
  opt: true,
239
259
  T: () => ['sui.rpc.v2.FundsWithdrawal.Source', FundsWithdrawal_Source],
240
260
  },
261
+ { no: 4, name: 'funder', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },
262
+ { no: 5, name: 'allowance', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },
241
263
  ]);
242
264
  }
243
265
  }
@@ -1187,10 +1187,9 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
1187
1187
 
1188
1188
  if (transaction.rawTransaction) {
1189
1189
  const parsedTx = bcs.SenderSignedData.parse(fromBase64(transaction.rawTransaction))[0];
1190
- // The genesis transaction's raw data carries a placeholder signature that
1191
- // other transports do not report
1192
- signatures =
1193
- parsedTx.intentMessage.value.V1.kind.$kind === 'Genesis' ? [] : parsedTx.txSignatures;
1190
+ // System transactions, including genesis, carry a placeholder signature that gRPC and
1191
+ // GraphQL report as-is.
1192
+ signatures = parsedTx.txSignatures;
1194
1193
 
1195
1194
  if (include?.transaction || include?.bcs) {
1196
1195
  const bytes = bcs.TransactionData.serialize(parsedTx.intentMessage.value).toBytes();
@@ -31,12 +31,20 @@ 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 {
35
- COIN_WITH_BALANCE,
36
- resolveCoinBalance,
37
- coinWithBalance,
38
- createBalance,
39
- } from './intents/CoinWithBalance.js';
34
+ import { ALLOWANCE_BALANCE, allowanceBalance } from './intents/AllowanceBalance.js';
35
+ import { resolveBalances } from './intents/ResolveBalances.js';
36
+ import type { BalanceOptions } from './intents/BalanceOptions.js';
37
+ import { normalizeBalance } from './intents/BalanceOptions.js';
38
+ import { COIN_WITH_BALANCE, coinWithBalance, createBalance } from './intents/CoinWithBalance.js';
39
+
40
+ export type WithdrawalOptions = {
41
+ amount: number | bigint | string;
42
+ type?: string | null;
43
+ } & (
44
+ | { from?: 'sender'; allowance?: never; funder?: never }
45
+ | { from: 'sponsor'; allowance?: never; funder?: never }
46
+ | { from: 'allowance'; allowance: string; funder: string }
47
+ );
40
48
 
41
49
  export type TransactionObjectArgument =
42
50
  | Exclude<InferInput<typeof ArgumentSchema>, { Input: unknown; type?: 'pure' }>
@@ -214,7 +222,8 @@ export class Transaction {
214
222
  // Built-in intents are resolvable by default. Caller-supplied resolvers cover custom intents,
215
223
  // and take precedence so a built-in resolver can be overridden if needed.
216
224
  const intentResolvers = new Map<string, TransactionPlugin>([
217
- [COIN_WITH_BALANCE, resolveCoinBalance],
225
+ [COIN_WITH_BALANCE, resolveBalances],
226
+ [ALLOWANCE_BALANCE, resolveBalances],
218
227
  ...Object.entries(options.intentResolvers ?? {}),
219
228
  ]);
220
229
 
@@ -342,35 +351,33 @@ export class Transaction {
342
351
  }
343
352
 
344
353
  /**
345
- * Creates a coin of the specified type and balance.
354
+ * Creates a Coin<T> of the specified type and amount (defaults to SUI).
346
355
  * Sourced from address balance when available, falling back to owned coins.
356
+ * With `allowance`, spends only from the funder's address balance under that allowance.
357
+ * Allowance IDs are resolved using the build client; app-bound allowances also require an app type and SpendPermit.
347
358
  */
348
- coin({
349
- type,
350
- balance,
351
- useGasCoin,
352
- }: {
353
- balance: bigint | number;
354
- type?: string;
355
- useGasCoin?: boolean;
356
- }): TransactionResult {
357
- return this.add(coinWithBalance({ type, balance, useGasCoin }));
359
+ coin(options: BalanceOptions): TransactionResult {
360
+ const amount = normalizeBalance(options);
361
+ return this.add(
362
+ options.allowance !== undefined
363
+ ? allowanceBalance({ ...options, amount, outputKind: 'coin' })
364
+ : coinWithBalance({ ...options, balance: amount }),
365
+ );
358
366
  }
359
367
 
360
368
  /**
361
- * Creates a Balance object of the specified type and balance.
369
+ * Creates a Balance<T> of the specified type and amount (defaults to SUI).
362
370
  * Sourced from address balance when available, falling back to owned coins.
371
+ * With `allowance`, spends only from the funder's address balance under that allowance.
372
+ * Allowance IDs are resolved using the build client; app-bound allowances also require an app type and SpendPermit.
363
373
  */
364
- balance({
365
- type,
366
- balance,
367
- useGasCoin,
368
- }: {
369
- balance: bigint | number;
370
- type?: string;
371
- useGasCoin?: boolean;
372
- }): TransactionResult {
373
- return this.add(createBalance({ type, balance, useGasCoin }));
374
+ balance(options: BalanceOptions): TransactionResult {
375
+ const amount = normalizeBalance(options);
376
+ return this.add(
377
+ options.allowance !== undefined
378
+ ? allowanceBalance({ ...options, amount, outputKind: 'balance' })
379
+ : createBalance({ ...options, balance: amount }),
380
+ );
374
381
  }
375
382
 
376
383
  /**
@@ -677,13 +684,15 @@ export class Transaction {
677
684
  }
678
685
 
679
686
  /**
680
- * Create a FundsWithdrawal input for withdrawing Balance<T> from an address balance accumulator.
681
- * This is used for gas payments from address balances.
687
+ * Creates a FundsWithdrawal input for withdrawing Balance<T> from an address balance.
682
688
  *
683
- * @param options.amount - The Amount to withdraw (u64).
684
- * @param options.type - The balance type (e.g., "0x2::sui::SUI"). Defaults to SUI.
689
+ * @param options.amount - The amount to withdraw (u64).
690
+ * @param options.type - The coin type T (e.g., "0x2::sui::SUI"), not Balance<T>. Defaults to SUI.
691
+ * @param options.from - The withdrawal source. Defaults to the transaction sender.
692
+ * @param options.allowance - The allowance ID, required when from is 'allowance'.
693
+ * @param options.funder - The funder's address, required when from is 'allowance'.
685
694
  */
686
- withdrawal({ amount, type }: { amount: number | bigint | string; type?: string | null }): {
695
+ withdrawal(options: WithdrawalOptions): {
687
696
  $kind: 'Input';
688
697
  Input: number;
689
698
  type?: 'object';
@@ -692,13 +701,20 @@ export class Transaction {
692
701
  $kind: 'FundsWithdrawal',
693
702
  FundsWithdrawal: {
694
703
  // TODO: support entire balance withdrawals once supported
695
- reservation: { $kind: 'MaxAmountU64', MaxAmountU64: String(amount) },
696
- typeArg: { $kind: 'Balance', Balance: type ?? '0x2::sui::SUI' },
704
+ reservation: { $kind: 'MaxAmountU64', MaxAmountU64: String(options.amount) },
705
+ typeArg: { $kind: 'Balance', Balance: options.type ?? '0x2::sui::SUI' },
697
706
  withdrawFrom:
698
- // fromSponsor === true
699
- // ? { $kind: 'Sponsor', Sponsor: true } :
700
- // TODO: currently only supporting withdrawals from sender
701
- { $kind: 'Sender', Sender: true },
707
+ options.from === 'allowance'
708
+ ? {
709
+ $kind: 'SenderAllowance',
710
+ SenderAllowance: {
711
+ funder: normalizeSuiAddress(options.funder),
712
+ allowance: normalizeSuiAddress(options.allowance),
713
+ },
714
+ }
715
+ : options.from === 'sponsor'
716
+ ? { $kind: 'Sponsor', Sponsor: true }
717
+ : { $kind: 'Sender', Sender: true },
702
718
  },
703
719
  };
704
720
 
@@ -964,16 +980,21 @@ export class Transaction {
964
980
 
965
981
  const steps = [...this.#serializationPlugins];
966
982
 
983
+ // A resolver may handle several intent names; run it once with its assigned intents.
984
+ const resolverIntents = new Map<TransactionPlugin, string[]>();
967
985
  for (const intent of intents) {
968
- if (options.supportedIntents?.includes(intent)) {
969
- continue;
970
- }
971
-
972
- if (!this.#intentResolvers.has(intent)) {
973
- throw new Error(`Missing intent resolver for ${intent}`);
974
- }
975
-
976
- steps.push(this.#intentResolvers.get(intent)!);
986
+ if (options.supportedIntents?.includes(intent)) continue;
987
+ const resolver = this.#intentResolvers.get(intent);
988
+ if (!resolver) throw new Error(`Missing intent resolver for ${intent}`);
989
+ const names = resolverIntents.get(resolver) ?? [];
990
+ names.push(intent);
991
+ resolverIntents.set(resolver, names);
992
+ }
993
+ for (const [resolver, intentNames] of resolverIntents) {
994
+ steps.push((data, buildOptions, next) => {
995
+ const resolverOptions = { ...buildOptions, intentNames };
996
+ return resolver(data, resolverOptions, next);
997
+ });
977
998
  }
978
999
 
979
1000
  steps.push(namedPackagesPlugin());
@@ -294,6 +294,10 @@ export type WithdrawalTypeArg = InferOutput<typeof WithdrawalTypeArgSchema>;
294
294
  export const WithdrawFromSchema = safeEnum({
295
295
  Sender: literal(true),
296
296
  Sponsor: literal(true),
297
+ SenderAllowance: object({
298
+ funder: SuiAddress,
299
+ allowance: ObjectID,
300
+ }),
297
301
  });
298
302
  export type WithdrawFrom = InferOutput<typeof WithdrawFromSchema>;
299
303