@rootzero/contracts 1.4.0 → 1.6.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 (68) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/Core.sol +4 -2
  3. package/Endpoints.sol +5 -3
  4. package/Events.sol +2 -1
  5. package/README.md +58 -31
  6. package/Utils.sol +4 -3
  7. package/blocks/Cursors.sol +107 -143
  8. package/blocks/Keys.sol +15 -15
  9. package/blocks/Schema.sol +27 -28
  10. package/blocks/Writers.sol +26 -33
  11. package/commands/Base.sol +2 -2
  12. package/commands/Burn.sol +3 -4
  13. package/commands/Credit.sol +3 -4
  14. package/commands/Debit.sol +4 -5
  15. package/commands/Deposit.sol +8 -10
  16. package/commands/Payout.sol +3 -6
  17. package/commands/Withdraw.sol +3 -4
  18. package/commands/admin/AllowAssets.sol +7 -9
  19. package/commands/admin/Allowance.sol +5 -7
  20. package/commands/admin/Appoint.sol +2 -3
  21. package/commands/admin/Authorize.sol +2 -3
  22. package/commands/admin/Base.sol +9 -0
  23. package/commands/admin/DenyAssets.sol +7 -9
  24. package/commands/admin/Destroy.sol +2 -3
  25. package/commands/admin/Dismiss.sol +2 -3
  26. package/commands/admin/Execute.sol +4 -5
  27. package/commands/admin/Init.sol +2 -3
  28. package/commands/admin/Label.sol +2 -3
  29. package/commands/admin/Unauthorize.sol +2 -3
  30. package/core/Access.sol +2 -2
  31. package/core/Balances.sol +10 -11
  32. package/core/Calls.sol +7 -7
  33. package/core/Commitments.sol +19 -0
  34. package/core/Escrows.sol +34 -0
  35. package/core/Host.sol +2 -2
  36. package/core/Runtime.sol +11 -6
  37. package/core/Types.sol +0 -14
  38. package/docs/Schema.md +29 -10
  39. package/events/Asset.sol +17 -3
  40. package/events/Balance.sol +2 -3
  41. package/events/Commitment.sol +19 -0
  42. package/events/Locked.sol +2 -3
  43. package/events/Position.sol +2 -3
  44. package/events/Received.sol +2 -3
  45. package/events/Spent.sol +2 -3
  46. package/events/Unlocked.sol +2 -3
  47. package/guards/Base.sol +4 -4
  48. package/package.json +1 -1
  49. package/peer/AllowAssets.sol +3 -3
  50. package/peer/Allowance.sol +2 -2
  51. package/peer/Base.sol +4 -4
  52. package/peer/Credit.sol +10 -10
  53. package/peer/Debit.sol +10 -10
  54. package/peer/DenyAssets.sol +3 -3
  55. package/peer/Recover.sol +51 -0
  56. package/peer/Redeem.sol +48 -0
  57. package/peer/Settle.sol +3 -3
  58. package/queries/Assets.sol +7 -8
  59. package/queries/Balances.sol +8 -9
  60. package/queries/Base.sol +4 -4
  61. package/queries/Positions.sol +4 -6
  62. package/utils/Accounts.sol +76 -58
  63. package/utils/Assets.sol +55 -115
  64. package/utils/Ids.sol +33 -233
  65. package/utils/Layout.sol +11 -17
  66. package/utils/Nodes.sol +263 -0
  67. package/utils/Utils.sol +9 -24
  68. package/peer/BalancePull.sol +0 -49
@@ -502,21 +502,19 @@ library Cursors {
502
502
 
503
503
  /// @notice Encode a BALANCE block.
504
504
  /// @param asset Asset identifier.
505
- /// @param meta Asset metadata slot.
506
505
  /// @param amount Token amount.
507
506
  /// @return Encoded BALANCE block bytes.
508
- function toBalanceBlock(bytes32 asset, bytes32 meta, uint amount) internal pure returns (bytes memory) {
509
- return createBlock96(Keys.Balance, asset, meta, bytes32(amount));
507
+ function toBalanceBlock(bytes32 asset, uint amount) internal pure returns (bytes memory) {
508
+ return createBlock64(Keys.Balance, asset, bytes32(amount));
510
509
  }
511
510
 
512
511
  /// @notice Encode a CUSTODY block.
513
512
  /// @param host Host node ID holding the custody.
514
513
  /// @param asset Asset identifier.
515
- /// @param meta Asset metadata slot.
516
514
  /// @param amount Token amount.
517
515
  /// @return Encoded CUSTODY block bytes.
518
- function toCustodyBlock(uint host, bytes32 asset, bytes32 meta, uint amount) internal pure returns (bytes memory) {
519
- return createBlock128(Keys.Custody, bytes32(host), asset, meta, bytes32(amount));
516
+ function toCustodyBlock(uint host, bytes32 asset, uint amount) internal pure returns (bytes memory) {
517
+ return createBlock96(Keys.Custody, bytes32(host), asset, bytes32(amount));
520
518
  }
521
519
 
522
520
  /// @notice Encode a STEP block.
@@ -601,6 +599,30 @@ library Cursors {
601
599
  cur.i += n;
602
600
  }
603
601
 
602
+ /// @notice Read the next byte from the cursor and advance by 1 byte.
603
+ /// @dev Performs no bounds, key, length, or cursor checks.
604
+ /// @param cur Cursor whose current position is advanced by 1 byte.
605
+ /// @return value Loaded bytes1 value.
606
+ function read1(Cur memory cur) internal pure returns (bytes1 value) {
607
+ uint abs = cur.offset + cur.i;
608
+ assembly ("memory-safe") {
609
+ value := calldataload(abs)
610
+ }
611
+ cur.i += 1;
612
+ }
613
+
614
+ /// @notice Read the next 2 bytes from the cursor and advance by 2 bytes.
615
+ /// @dev Performs no bounds, key, length, or cursor checks.
616
+ /// @param cur Cursor whose current position is advanced by 2 bytes.
617
+ /// @return value Loaded bytes2 value.
618
+ function read2(Cur memory cur) internal pure returns (bytes2 value) {
619
+ uint abs = cur.offset + cur.i;
620
+ assembly ("memory-safe") {
621
+ value := calldataload(abs)
622
+ }
623
+ cur.i += 2;
624
+ }
625
+
604
626
  /// @notice Read the next 4 bytes from the cursor and advance by 4 bytes.
605
627
  /// @dev Performs no bounds, key, length, or cursor checks.
606
628
  /// @param cur Cursor whose current position is advanced by 4 bytes.
@@ -813,94 +835,84 @@ library Cursors {
813
835
 
814
836
  // Generic typed-shape decoders
815
837
 
816
- /// @notice Consume a fixed-size asset amount block and return asset, meta, and amount.
838
+ /// @notice Consume a fixed-size asset amount block and return asset and amount.
817
839
  /// @param cur Cursor; advanced past the block.
818
840
  /// @param key Expected block key.
819
841
  /// @return asset Asset identifier.
820
- /// @return meta Asset metadata slot.
821
842
  /// @return amount Scalar amount value.
822
843
  function unpackAssetAmount(
823
844
  Cur memory cur,
824
845
  bytes4 key
825
- ) internal pure returns (bytes32 asset, bytes32 meta, uint amount) {
826
- uint abs = consume(cur, 0, key, 96, 96);
846
+ ) internal pure returns (bytes32 asset, uint amount) {
847
+ uint abs = consume(cur, 0, key, 64, 64);
827
848
  asset = bytes32(msg.data[abs:abs + 32]);
828
- meta = bytes32(msg.data[abs + 32:abs + 64]);
829
- amount = uint(bytes32(msg.data[abs + 64:abs + 96]));
849
+ amount = uint(bytes32(msg.data[abs + 32:abs + 64]));
830
850
  }
831
851
 
832
- /// @notice Consume a fixed-size account amount block and return account, asset, meta, and amount.
852
+ /// @notice Consume a fixed-size account amount block and return account, asset, and amount.
833
853
  /// @param cur Cursor; advanced past the block.
834
854
  /// @param key Expected block key.
835
855
  /// @return account Account identifier.
836
856
  /// @return asset Asset identifier.
837
- /// @return meta Asset metadata slot.
838
857
  /// @return amount Scalar amount value.
839
858
  function unpackAccountAmount(
840
859
  Cur memory cur,
841
860
  bytes4 key
842
- ) internal pure returns (bytes32 account, bytes32 asset, bytes32 meta, uint amount) {
843
- uint abs = consume(cur, 0, key, 128, 128);
861
+ ) internal pure returns (bytes32 account, bytes32 asset, uint amount) {
862
+ uint abs = consume(cur, 0, key, 96, 96);
844
863
  account = bytes32(msg.data[abs:abs + 32]);
845
864
  asset = bytes32(msg.data[abs + 32:abs + 64]);
846
- meta = bytes32(msg.data[abs + 64:abs + 96]);
847
- amount = uint(bytes32(msg.data[abs + 96:abs + 128]));
865
+ amount = uint(bytes32(msg.data[abs + 64:abs + 96]));
848
866
  }
849
867
 
850
- /// @notice Consume a fixed-size host amount block and return host, asset, meta, and amount.
868
+ /// @notice Consume a fixed-size host amount block and return host, asset, and amount.
851
869
  /// @param cur Cursor; advanced past the block.
852
870
  /// @param key Expected block key.
853
871
  /// @return host Host node ID.
854
872
  /// @return asset Asset identifier.
855
- /// @return meta Asset metadata slot.
856
873
  /// @return amount Scalar amount value.
857
874
  function unpackHostAmount(
858
875
  Cur memory cur,
859
876
  bytes4 key
860
- ) internal pure returns (uint host, bytes32 asset, bytes32 meta, uint amount) {
861
- uint abs = consume(cur, 0, key, 128, 128);
877
+ ) internal pure returns (uint host, bytes32 asset, uint amount) {
878
+ uint abs = consume(cur, 0, key, 96, 96);
862
879
  host = uint(bytes32(msg.data[abs:abs + 32]));
863
880
  asset = bytes32(msg.data[abs + 32:abs + 64]);
864
- meta = bytes32(msg.data[abs + 64:abs + 96]);
865
- amount = uint(bytes32(msg.data[abs + 96:abs + 128]));
881
+ amount = uint(bytes32(msg.data[abs + 64:abs + 96]));
866
882
  }
867
883
 
868
- /// @notice Consume a fixed-size host account asset block and return host, account, asset, and meta.
884
+ /// @notice Consume a fixed-size host account asset block and return host, account, and asset.
869
885
  /// @param cur Cursor; advanced past the block.
870
886
  /// @param key Expected block key.
871
887
  /// @return host Host node ID.
872
888
  /// @return account Account identifier.
873
889
  /// @return asset Asset identifier.
874
- /// @return meta Asset metadata slot.
875
890
  function unpackHostAccountAsset(
876
891
  Cur memory cur,
877
892
  bytes4 key
878
- ) internal pure returns (uint host, bytes32 account, bytes32 asset, bytes32 meta) {
879
- uint abs = consume(cur, 0, key, 128, 128);
893
+ ) internal pure returns (uint host, bytes32 account, bytes32 asset) {
894
+ uint abs = consume(cur, 0, key, 96, 96);
880
895
  host = uint(bytes32(msg.data[abs:abs + 32]));
881
896
  account = bytes32(msg.data[abs + 32:abs + 64]);
882
897
  asset = bytes32(msg.data[abs + 64:abs + 96]);
883
- meta = bytes32(msg.data[abs + 96:abs + 128]);
884
898
  }
885
899
 
886
- /// @notice Consume a fixed-size transaction block and return from, to, asset, meta, and amount.
900
+ /// @notice Consume a fixed-size transaction block and return from, to, asset, and amount.
887
901
  /// @param cur Cursor; advanced past the block.
888
902
  /// @param key Expected block key.
889
903
  /// @return from Source account identifier.
890
904
  /// @return to Destination account identifier.
891
905
  /// @return asset Asset identifier.
892
- /// @return meta Asset metadata slot.
893
906
  /// @return amount Scalar amount value.
894
907
  function unpackTransaction(
895
908
  Cur memory cur,
896
909
  bytes4 key
897
- ) internal pure returns (bytes32 from, bytes32 to, bytes32 asset, bytes32 meta, uint amount) {
898
- uint abs = consume(cur, 0, key, 160, 160);
910
+ ) internal pure returns (bytes32 from, bytes32 to, bytes32 asset, uint amount) {
911
+ uint abs = consume(cur, 0, key, 128, 128);
899
912
  from = bytes32(msg.data[abs:abs + 32]);
900
913
  to = bytes32(msg.data[abs + 32:abs + 64]);
901
914
  asset = bytes32(msg.data[abs + 64:abs + 96]);
902
- meta = bytes32(msg.data[abs + 96:abs + 128]);
903
- amount = uint(bytes32(msg.data[abs + 128:abs + 160]));
915
+ amount = uint(bytes32(msg.data[abs + 96:abs + 128]));
904
916
  }
905
917
 
906
918
  // Type-specific fixed-width decoders
@@ -926,31 +938,28 @@ library Cursors {
926
938
  amount = uint(unpack32(cur, Keys.Fee));
927
939
  }
928
940
 
929
- /// @notice Consume an ASSET block and return the asset descriptor fields.
941
+ /// @notice Consume an ASSET block and return the asset identifier.
930
942
  /// @param cur Cursor; advanced past the block.
931
943
  /// @return asset Asset identifier.
932
- /// @return meta Asset metadata slot.
933
- function unpackAsset(Cur memory cur) internal pure returns (bytes32 asset, bytes32 meta) {
934
- (asset, meta) = unpack64(cur, Keys.Asset);
944
+ function unpackAsset(Cur memory cur) internal pure returns (bytes32 asset) {
945
+ asset = unpack32(cur, Keys.Asset);
935
946
  }
936
947
 
937
948
  /// @notice Consume an ACCOUNT_ASSET form block and return its fields as separate values.
938
949
  /// @param cur Cursor; advanced past the block.
939
950
  /// @return account Account identifier.
940
951
  /// @return asset Asset identifier.
941
- /// @return meta Asset metadata slot.
942
- function unpackAccountAsset(Cur memory cur) internal pure returns (bytes32 account, bytes32 asset, bytes32 meta) {
943
- uint abs = consume(cur, 0, Keys.AccountAsset, 96, 96);
952
+ function unpackAccountAsset(Cur memory cur) internal pure returns (bytes32 account, bytes32 asset) {
953
+ uint abs = consume(cur, 0, Keys.AccountAsset, 64, 64);
944
954
  account = bytes32(msg.data[abs:abs + 32]);
945
955
  asset = bytes32(msg.data[abs + 32:abs + 64]);
946
- meta = bytes32(msg.data[abs + 64:abs + 96]);
947
956
  }
948
957
 
949
958
  /// @notice Consume an ACCOUNT_ASSET form block and return its fields as a struct.
950
959
  /// @param cur Cursor; advanced past the block.
951
- /// @return value Decoded account, asset, and meta.
960
+ /// @return value Decoded account and asset.
952
961
  function unpackAccountAssetValue(Cur memory cur) internal pure returns (AccountAsset memory value) {
953
- (value.account, value.asset, value.meta) = unpackAccountAsset(cur);
962
+ (value.account, value.asset) = unpackAccountAsset(cur);
954
963
  }
955
964
 
956
965
  /// @notice Consume a BOUNTY block and return the reward amount and relayer.
@@ -966,33 +975,31 @@ library Cursors {
966
975
  /// @notice Consume an AMOUNT block and return its fields as separate values.
967
976
  /// @param cur Cursor; advanced past the block.
968
977
  /// @return asset Asset identifier.
969
- /// @return meta Asset metadata slot.
970
978
  /// @return amount Token amount.
971
- function unpackAmount(Cur memory cur) internal pure returns (bytes32 asset, bytes32 meta, uint amount) {
979
+ function unpackAmount(Cur memory cur) internal pure returns (bytes32 asset, uint amount) {
972
980
  return unpackAssetAmount(cur, Keys.Amount);
973
981
  }
974
982
 
975
983
  /// @notice Consume an AMOUNT block and return its fields as a struct.
976
984
  /// @param cur Cursor; advanced past the block.
977
- /// @return value Decoded asset, meta, and amount.
985
+ /// @return value Decoded asset and amount.
978
986
  function unpackAmountValue(Cur memory cur) internal pure returns (AssetAmount memory value) {
979
- (value.asset, value.meta, value.amount) = unpackAssetAmount(cur, Keys.Amount);
987
+ (value.asset, value.amount) = unpackAssetAmount(cur, Keys.Amount);
980
988
  }
981
989
 
982
990
  /// @notice Consume a BALANCE block and return its fields as separate values.
983
991
  /// @param cur Cursor; advanced past the block.
984
992
  /// @return asset Asset identifier.
985
- /// @return meta Asset metadata slot.
986
993
  /// @return amount Token amount.
987
- function unpackBalance(Cur memory cur) internal pure returns (bytes32 asset, bytes32 meta, uint amount) {
994
+ function unpackBalance(Cur memory cur) internal pure returns (bytes32 asset, uint amount) {
988
995
  return unpackAssetAmount(cur, Keys.Balance);
989
996
  }
990
997
 
991
998
  /// @notice Consume a BALANCE block and return its fields as a struct.
992
999
  /// @param cur Cursor; advanced past the block.
993
- /// @return value Decoded asset, meta, and amount.
1000
+ /// @return value Decoded asset and amount.
994
1001
  function unpackBalanceValue(Cur memory cur) internal pure returns (AssetAmount memory value) {
995
- (value.asset, value.meta, value.amount) = unpackAssetAmount(cur, Keys.Balance);
1002
+ (value.asset, value.amount) = unpackAssetAmount(cur, Keys.Balance);
996
1003
  }
997
1004
 
998
1005
  /// @notice Consume a HOST_ACCOUNT_ASSET form block and return its fields as separate values.
@@ -1000,92 +1007,87 @@ library Cursors {
1000
1007
  /// @return host Host node ID.
1001
1008
  /// @return account Account identifier.
1002
1009
  /// @return asset Asset identifier.
1003
- /// @return meta Asset metadata slot.
1004
1010
  function unpackHostAccountAsset(
1005
1011
  Cur memory cur
1006
- ) internal pure returns (uint host, bytes32 account, bytes32 asset, bytes32 meta) {
1012
+ ) internal pure returns (uint host, bytes32 account, bytes32 asset) {
1007
1013
  return unpackHostAccountAsset(cur, Keys.HostAccountAsset);
1008
1014
  }
1009
1015
 
1010
1016
  /// @notice Consume a HOST_ACCOUNT_ASSET form block and return its fields as a struct.
1011
1017
  /// @param cur Cursor; advanced past the block.
1012
- /// @return value Decoded host, account, asset, and meta.
1018
+ /// @return value Decoded host, account, and asset.
1013
1019
  function unpackHostAccountAssetValue(Cur memory cur) internal pure returns (HostAccountAsset memory value) {
1014
- (value.host, value.account, value.asset, value.meta) = unpackHostAccountAsset(cur, Keys.HostAccountAsset);
1020
+ (value.host, value.account, value.asset) = unpackHostAccountAsset(cur, Keys.HostAccountAsset);
1015
1021
  }
1016
1022
 
1017
1023
  /// @notice Consume an ACCOUNT_AMOUNT form block and return its fields as separate values.
1018
1024
  /// @param cur Cursor; advanced past the block.
1019
1025
  /// @return account Account identifier.
1020
1026
  /// @return asset Asset identifier.
1021
- /// @return meta Asset metadata slot.
1022
1027
  /// @return amount Token amount.
1023
1028
  function unpackAccountAmount(
1024
1029
  Cur memory cur
1025
- ) internal pure returns (bytes32 account, bytes32 asset, bytes32 meta, uint amount) {
1030
+ ) internal pure returns (bytes32 account, bytes32 asset, uint amount) {
1026
1031
  return unpackAccountAmount(cur, Keys.AccountAmount);
1027
1032
  }
1028
1033
 
1029
1034
  /// @notice Consume an ACCOUNT_AMOUNT form block and return its fields as a struct.
1030
1035
  /// @param cur Cursor; advanced past the block.
1031
- /// @return value Decoded account, asset, meta, and amount.
1036
+ /// @return value Decoded account, asset, and amount.
1032
1037
  function unpackAccountAmountValue(Cur memory cur) internal pure returns (AccountAmount memory value) {
1033
- (value.account, value.asset, value.meta, value.amount) = unpackAccountAmount(cur, Keys.AccountAmount);
1038
+ (value.account, value.asset, value.amount) = unpackAccountAmount(cur, Keys.AccountAmount);
1034
1039
  }
1035
1040
 
1036
1041
  /// @notice Consume an ALLOCATION block and return its fields as separate values.
1037
1042
  /// @param cur Cursor; advanced past the block.
1038
1043
  /// @return host Host node ID.
1039
1044
  /// @return asset Asset identifier.
1040
- /// @return meta Asset metadata slot.
1041
1045
  /// @return amount Token amount.
1042
1046
  function unpackAllocation(
1043
1047
  Cur memory cur
1044
- ) internal pure returns (uint host, bytes32 asset, bytes32 meta, uint amount) {
1048
+ ) internal pure returns (uint host, bytes32 asset, uint amount) {
1045
1049
  return unpackHostAmount(cur, Keys.Allocation);
1046
1050
  }
1047
1051
 
1048
1052
  /// @notice Consume an ALLOCATION block and return its fields as a struct.
1049
1053
  /// @param cur Cursor; advanced past the block.
1050
- /// @return value Decoded host, asset, meta, and amount.
1054
+ /// @return value Decoded host, asset, and amount.
1051
1055
  function unpackAllocationValue(Cur memory cur) internal pure returns (HostAmount memory value) {
1052
- (value.host, value.asset, value.meta, value.amount) = unpackHostAmount(cur, Keys.Allocation);
1056
+ (value.host, value.asset, value.amount) = unpackHostAmount(cur, Keys.Allocation);
1053
1057
  }
1054
1058
 
1055
1059
  /// @notice Consume an ALLOWANCE block and return its fields as separate values.
1056
1060
  /// @param cur Cursor; advanced past the block.
1057
1061
  /// @return host Host node ID.
1058
1062
  /// @return asset Asset identifier.
1059
- /// @return meta Asset metadata slot.
1060
1063
  /// @return amount Token amount.
1061
1064
  function unpackAllowance(
1062
1065
  Cur memory cur
1063
- ) internal pure returns (uint host, bytes32 asset, bytes32 meta, uint amount) {
1066
+ ) internal pure returns (uint host, bytes32 asset, uint amount) {
1064
1067
  return unpackHostAmount(cur, Keys.Allowance);
1065
1068
  }
1066
1069
 
1067
1070
  /// @notice Consume an ALLOWANCE block and return its fields as a struct.
1068
1071
  /// @param cur Cursor; advanced past the block.
1069
- /// @return value Decoded host, asset, meta, and amount.
1072
+ /// @return value Decoded host, asset, and amount.
1070
1073
  function unpackAllowanceValue(Cur memory cur) internal pure returns (HostAmount memory value) {
1071
- (value.host, value.asset, value.meta, value.amount) = unpackHostAmount(cur, Keys.Allowance);
1074
+ (value.host, value.asset, value.amount) = unpackHostAmount(cur, Keys.Allowance);
1072
1075
  }
1073
1076
 
1074
1077
  /// @notice Consume a CUSTODY block and return its fields as separate values.
1075
1078
  /// @param cur Cursor; advanced past the block.
1076
1079
  /// @return host Host node ID.
1077
1080
  /// @return asset Asset identifier.
1078
- /// @return meta Asset metadata slot.
1079
1081
  /// @return amount Token amount.
1080
- function unpackCustody(Cur memory cur) internal pure returns (uint host, bytes32 asset, bytes32 meta, uint amount) {
1082
+ function unpackCustody(Cur memory cur) internal pure returns (uint host, bytes32 asset, uint amount) {
1081
1083
  return unpackHostAmount(cur, Keys.Custody);
1082
1084
  }
1083
1085
 
1084
1086
  /// @notice Consume a CUSTODY block and return its fields as a struct.
1085
1087
  /// @param cur Cursor; advanced past the block.
1086
- /// @return value Decoded host, asset, meta, and amount.
1088
+ /// @return value Decoded host, asset, and amount.
1087
1089
  function unpackCustodyValue(Cur memory cur) internal pure returns (HostAmount memory value) {
1088
- (value.host, value.asset, value.meta, value.amount) = unpackHostAmount(cur, Keys.Custody);
1090
+ (value.host, value.asset, value.amount) = unpackHostAmount(cur, Keys.Custody);
1089
1091
  }
1090
1092
 
1091
1093
  /// @notice Consume a TRANSACTION block and return its fields as separate values.
@@ -1093,19 +1095,18 @@ library Cursors {
1093
1095
  /// @return from Source account identifier.
1094
1096
  /// @return to Destination account identifier.
1095
1097
  /// @return asset Asset identifier.
1096
- /// @return meta Asset metadata slot.
1097
1098
  /// @return amount Token amount.
1098
1099
  function unpackTransaction(
1099
1100
  Cur memory cur
1100
- ) internal pure returns (bytes32 from, bytes32 to, bytes32 asset, bytes32 meta, uint amount) {
1101
+ ) internal pure returns (bytes32 from, bytes32 to, bytes32 asset, uint amount) {
1101
1102
  return unpackTransaction(cur, Keys.Transaction);
1102
1103
  }
1103
1104
 
1104
1105
  /// @notice Consume a TRANSACTION block and return all fields as a struct.
1105
1106
  /// @param cur Cursor; advanced past the block.
1106
- /// @return value Decoded from, to, asset, meta, and amount.
1107
+ /// @return value Decoded from, to, asset, and amount.
1107
1108
  function unpackTxValue(Cur memory cur) internal pure returns (Tx memory value) {
1108
- (value.from, value.to, value.asset, value.meta, value.amount) = unpackTransaction(cur);
1109
+ (value.from, value.to, value.asset, value.amount) = unpackTransaction(cur);
1109
1110
  }
1110
1111
 
1111
1112
  // Type-specific dynamic decoders
@@ -1225,47 +1226,25 @@ library Cursors {
1225
1226
  /// @param cur Cursor; advanced past the block.
1226
1227
  /// @param key Expected block type key.
1227
1228
  /// @param asset Expected asset identifier.
1228
- /// @return meta Metadata slot from the block.
1229
1229
  /// @return amount Amount from the block.
1230
1230
  function requireAssetAmount(
1231
1231
  Cur memory cur,
1232
1232
  bytes4 key,
1233
1233
  bytes32 asset
1234
- ) internal pure returns (bytes32 meta, uint amount) {
1235
- uint abs = consume(cur, 0, key, 96, 96);
1236
- if (bytes32(msg.data[abs:abs + 32]) != asset) revert UnexpectedValue();
1237
- meta = bytes32(msg.data[abs + 32:abs + 64]);
1238
- amount = uint(bytes32(msg.data[abs + 64:abs + 96]));
1239
- }
1240
-
1241
- /// @notice Consume an asset amount block and assert it matches the expected asset and meta.
1242
- /// @param cur Cursor; advanced past the block.
1243
- /// @param key Expected block type key.
1244
- /// @param asset Expected asset identifier.
1245
- /// @param meta Expected metadata slot.
1246
- /// @return amount Amount from the block.
1247
- function requireAssetAmount(
1248
- Cur memory cur,
1249
- bytes4 key,
1250
- bytes32 asset,
1251
- bytes32 meta
1252
1234
  ) internal pure returns (uint amount) {
1253
- uint abs = consume(cur, 0, key, 96, 96);
1235
+ uint abs = consume(cur, 0, key, 64, 64);
1254
1236
  if (bytes32(msg.data[abs:abs + 32]) != asset) revert UnexpectedValue();
1255
- if (bytes32(msg.data[abs + 32:abs + 64]) != meta) revert UnexpectedValue();
1256
- amount = uint(bytes32(msg.data[abs + 64:abs + 96]));
1237
+ amount = uint(bytes32(msg.data[abs + 32:abs + 64]));
1257
1238
  }
1258
1239
 
1259
1240
  /// @notice Consume an asset amount block, assert it matches the expected asset, and require the amount to be 1.
1260
1241
  /// @param cur Cursor; advanced past the block.
1261
1242
  /// @param key Expected block type key.
1262
1243
  /// @param asset Expected asset identifier.
1263
- /// @return meta Metadata slot from the block.
1264
- function requireUnitAssetAmount(Cur memory cur, bytes4 key, bytes32 asset) internal pure returns (bytes32 meta) {
1265
- uint abs = consume(cur, 0, key, 96, 96);
1244
+ function requireUnitAssetAmount(Cur memory cur, bytes4 key, bytes32 asset) internal pure {
1245
+ uint abs = consume(cur, 0, key, 64, 64);
1266
1246
  if (bytes32(msg.data[abs:abs + 32]) != asset) revert UnexpectedValue();
1267
- meta = bytes32(msg.data[abs + 32:abs + 64]);
1268
- if (uint(bytes32(msg.data[abs + 64:abs + 96])) != 1) revert UnexpectedValue();
1247
+ if (uint(bytes32(msg.data[abs + 32:abs + 64])) != 1) revert UnexpectedValue();
1269
1248
  }
1270
1249
 
1271
1250
  /// @notice Consume a host amount block and assert it matches the expected host.
@@ -1273,18 +1252,16 @@ library Cursors {
1273
1252
  /// @param key Expected block type key.
1274
1253
  /// @param host Expected host node ID.
1275
1254
  /// @return asset Asset identifier from the block.
1276
- /// @return meta Metadata slot from the block.
1277
1255
  /// @return amount Amount from the block.
1278
1256
  function requireHostAmount(
1279
1257
  Cur memory cur,
1280
1258
  bytes4 key,
1281
1259
  uint host
1282
- ) internal pure returns (bytes32 asset, bytes32 meta, uint amount) {
1283
- uint abs = consume(cur, 0, key, 128, 128);
1260
+ ) internal pure returns (bytes32 asset, uint amount) {
1261
+ uint abs = consume(cur, 0, key, 96, 96);
1284
1262
  if (uint(bytes32(msg.data[abs:abs + 32])) != host) revert UnexpectedValue();
1285
1263
  asset = bytes32(msg.data[abs + 32:abs + 64]);
1286
- meta = bytes32(msg.data[abs + 64:abs + 96]);
1287
- amount = uint(bytes32(msg.data[abs + 96:abs + 128]));
1264
+ amount = uint(bytes32(msg.data[abs + 64:abs + 96]));
1288
1265
  }
1289
1266
 
1290
1267
  /// @notice Consume a host amount block and assert it matches the expected host and asset.
@@ -1292,19 +1269,17 @@ library Cursors {
1292
1269
  /// @param key Expected block type key.
1293
1270
  /// @param host Expected host node ID.
1294
1271
  /// @param asset Expected asset identifier.
1295
- /// @return meta Metadata slot from the block.
1296
1272
  /// @return amount Amount from the block.
1297
1273
  function requireHostAmount(
1298
1274
  Cur memory cur,
1299
1275
  bytes4 key,
1300
1276
  uint host,
1301
1277
  bytes32 asset
1302
- ) internal pure returns (bytes32 meta, uint amount) {
1303
- uint abs = consume(cur, 0, key, 128, 128);
1278
+ ) internal pure returns (uint amount) {
1279
+ uint abs = consume(cur, 0, key, 96, 96);
1304
1280
  if (uint(bytes32(msg.data[abs:abs + 32])) != host) revert UnexpectedValue();
1305
1281
  if (bytes32(msg.data[abs + 32:abs + 64]) != asset) revert UnexpectedValue();
1306
- meta = bytes32(msg.data[abs + 64:abs + 96]);
1307
- amount = uint(bytes32(msg.data[abs + 96:abs + 128]));
1282
+ amount = uint(bytes32(msg.data[abs + 64:abs + 96]));
1308
1283
  }
1309
1284
 
1310
1285
  /// @notice Consume a host amount block, assert it matches the expected host and asset, and require the amount to be 1.
@@ -1312,18 +1287,16 @@ library Cursors {
1312
1287
  /// @param key Expected block type key.
1313
1288
  /// @param host Expected host node ID.
1314
1289
  /// @param asset Expected asset identifier.
1315
- /// @return meta Metadata slot from the block.
1316
1290
  function requireUnitHostAmount(
1317
1291
  Cur memory cur,
1318
1292
  bytes4 key,
1319
1293
  uint host,
1320
1294
  bytes32 asset
1321
- ) internal pure returns (bytes32 meta) {
1322
- uint abs = consume(cur, 0, key, 128, 128);
1295
+ ) internal pure {
1296
+ uint abs = consume(cur, 0, key, 96, 96);
1323
1297
  if (uint(bytes32(msg.data[abs:abs + 32])) != host) revert UnexpectedValue();
1324
1298
  if (bytes32(msg.data[abs + 32:abs + 64]) != asset) revert UnexpectedValue();
1325
- meta = bytes32(msg.data[abs + 64:abs + 96]);
1326
- if (uint(bytes32(msg.data[abs + 96:abs + 128])) != 1) revert UnexpectedValue();
1299
+ if (uint(bytes32(msg.data[abs + 64:abs + 96])) != 1) revert UnexpectedValue();
1327
1300
  }
1328
1301
 
1329
1302
  /// @notice Consume a host account asset block and assert it matches the expected host and account.
@@ -1332,49 +1305,44 @@ library Cursors {
1332
1305
  /// @param host Expected host node ID.
1333
1306
  /// @param account Expected account identifier.
1334
1307
  /// @return asset Asset identifier from the block.
1335
- /// @return meta Metadata slot from the block.
1336
1308
  function requireHostAccountAsset(
1337
1309
  Cur memory cur,
1338
1310
  bytes4 key,
1339
1311
  uint host,
1340
1312
  bytes32 account
1341
- ) internal pure returns (bytes32 asset, bytes32 meta) {
1342
- uint abs = consume(cur, 0, key, 128, 128);
1313
+ ) internal pure returns (bytes32 asset) {
1314
+ uint abs = consume(cur, 0, key, 96, 96);
1343
1315
  if (uint(bytes32(msg.data[abs:abs + 32])) != host) revert UnexpectedValue();
1344
1316
  if (bytes32(msg.data[abs + 32:abs + 64]) != account) revert UnexpectedValue();
1345
1317
  asset = bytes32(msg.data[abs + 64:abs + 96]);
1346
- meta = bytes32(msg.data[abs + 96:abs + 128]);
1347
1318
  }
1348
1319
 
1349
- /// @notice Consume a host account asset block, assert it targets the expected host, and return account, asset, and meta.
1320
+ /// @notice Consume a host account asset block, assert it targets the expected host, and return account and asset.
1350
1321
  /// @param cur Cursor; advanced past the block.
1351
1322
  /// @param key Expected block key.
1352
1323
  /// @param host Expected host node ID.
1353
1324
  /// @return account Account identifier from the block.
1354
1325
  /// @return asset Asset identifier from the block.
1355
- /// @return meta Metadata slot from the block.
1356
1326
  function requireHostAccountAsset(
1357
1327
  Cur memory cur,
1358
1328
  bytes4 key,
1359
1329
  uint host
1360
- ) internal pure returns (bytes32 account, bytes32 asset, bytes32 meta) {
1361
- uint abs = consume(cur, 0, key, 128, 128);
1330
+ ) internal pure returns (bytes32 account, bytes32 asset) {
1331
+ uint abs = consume(cur, 0, key, 96, 96);
1362
1332
  if (uint(bytes32(msg.data[abs:abs + 32])) != host) revert UnexpectedValue();
1363
1333
  account = bytes32(msg.data[abs + 32:abs + 64]);
1364
1334
  asset = bytes32(msg.data[abs + 64:abs + 96]);
1365
- meta = bytes32(msg.data[abs + 96:abs + 128]);
1366
1335
  }
1367
1336
 
1368
- /// @notice Consume a HOST_ACCOUNT_ASSET form block, assert it targets the expected host, and return account, asset, and meta.
1337
+ /// @notice Consume a HOST_ACCOUNT_ASSET form block, assert it targets the expected host, and return account and asset.
1369
1338
  /// @param cur Cursor; advanced past the block.
1370
1339
  /// @param host Expected host node ID.
1371
1340
  /// @return account Account identifier from the block.
1372
1341
  /// @return asset Asset identifier from the block.
1373
- /// @return meta Metadata slot from the block.
1374
1342
  function requireHostAccountAsset(
1375
1343
  Cur memory cur,
1376
1344
  uint host
1377
- ) internal pure returns (bytes32 account, bytes32 asset, bytes32 meta) {
1345
+ ) internal pure returns (bytes32 account, bytes32 asset) {
1378
1346
  return requireHostAccountAsset(cur, Keys.HostAccountAsset, host);
1379
1347
  }
1380
1348
 
@@ -1395,29 +1363,25 @@ library Cursors {
1395
1363
  /// @notice Consume a BALANCE_LIMIT block and assert all constraint fields match the provided balance.
1396
1364
  /// @param cur Cursor; advanced past the block.
1397
1365
  /// @param asset Expected asset identifier.
1398
- /// @param meta Expected metadata slot.
1399
1366
  /// @param amount Amount that must fall within the encoded min/max range.
1400
- function ensureBalanceLimit(Cur memory cur, bytes32 asset, bytes32 meta, uint amount) internal pure {
1401
- uint abs = consume(cur, 0, Keys.BalanceLimit, 128, 128);
1367
+ function ensureBalanceLimit(Cur memory cur, bytes32 asset, uint amount) internal pure {
1368
+ uint abs = consume(cur, 0, Keys.BalanceLimit, 96, 96);
1402
1369
  if (bytes32(msg.data[abs:abs + 32]) != asset) revert UnexpectedValue();
1403
- if (bytes32(msg.data[abs + 32:abs + 64]) != meta) revert UnexpectedValue();
1404
- if (uint(bytes32(msg.data[abs + 64:abs + 96])) > amount) revert UnexpectedValue();
1405
- if (uint(bytes32(msg.data[abs + 96:abs + 128])) < amount) revert UnexpectedValue();
1370
+ if (uint(bytes32(msg.data[abs + 32:abs + 64])) > amount) revert UnexpectedValue();
1371
+ if (uint(bytes32(msg.data[abs + 64:abs + 96])) < amount) revert UnexpectedValue();
1406
1372
  }
1407
1373
 
1408
1374
  /// @notice Consume a CUSTODY_LIMIT block and assert all constraint fields match the provided custody.
1409
1375
  /// @param cur Cursor; advanced past the block.
1410
1376
  /// @param host Expected host node ID.
1411
1377
  /// @param asset Expected asset identifier.
1412
- /// @param meta Expected metadata slot.
1413
1378
  /// @param amount Amount that must fall within the encoded min/max range.
1414
- function ensureCustodyLimit(Cur memory cur, uint host, bytes32 asset, bytes32 meta, uint amount) internal pure {
1415
- uint abs = consume(cur, 0, Keys.CustodyLimit, 160, 160);
1379
+ function ensureCustodyLimit(Cur memory cur, uint host, bytes32 asset, uint amount) internal pure {
1380
+ uint abs = consume(cur, 0, Keys.CustodyLimit, 128, 128);
1416
1381
  if (uint(bytes32(msg.data[abs:abs + 32])) != host) revert UnexpectedValue();
1417
1382
  if (bytes32(msg.data[abs + 32:abs + 64]) != asset) revert UnexpectedValue();
1418
- if (bytes32(msg.data[abs + 64:abs + 96]) != meta) revert UnexpectedValue();
1419
- if (uint(bytes32(msg.data[abs + 96:abs + 128])) > amount) revert UnexpectedValue();
1420
- if (uint(bytes32(msg.data[abs + 128:abs + 160])) < amount) revert UnexpectedValue();
1383
+ if (uint(bytes32(msg.data[abs + 64:abs + 96])) > amount) revert UnexpectedValue();
1384
+ if (uint(bytes32(msg.data[abs + 96:abs + 128])) < amount) revert UnexpectedValue();
1421
1385
  }
1422
1386
 
1423
1387
  // -------------------------------------------------------------------------