@rootzero/contracts 1.4.0 → 1.5.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 (56) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/Endpoints.sol +4 -3
  3. package/Events.sol +1 -1
  4. package/README.md +58 -31
  5. package/Utils.sol +4 -3
  6. package/blocks/Cursors.sol +83 -143
  7. package/blocks/Keys.sol +15 -15
  8. package/blocks/Schema.sol +27 -28
  9. package/blocks/Writers.sol +26 -33
  10. package/commands/Base.sol +2 -2
  11. package/commands/Burn.sol +3 -4
  12. package/commands/Credit.sol +3 -4
  13. package/commands/Debit.sol +4 -5
  14. package/commands/Deposit.sol +8 -10
  15. package/commands/Payout.sol +3 -6
  16. package/commands/Withdraw.sol +3 -4
  17. package/commands/admin/AllowAssets.sol +5 -6
  18. package/commands/admin/Allowance.sol +3 -4
  19. package/commands/admin/DenyAssets.sol +5 -6
  20. package/commands/admin/Execute.sol +2 -2
  21. package/core/Access.sol +2 -2
  22. package/core/Balances.sol +10 -11
  23. package/core/Calls.sol +7 -7
  24. package/core/Host.sol +2 -2
  25. package/core/Runtime.sol +3 -3
  26. package/core/Types.sol +0 -14
  27. package/docs/Schema.md +29 -10
  28. package/events/Asset.sol +17 -3
  29. package/events/Balance.sol +2 -3
  30. package/events/Locked.sol +2 -3
  31. package/events/Position.sol +2 -3
  32. package/events/Received.sol +2 -3
  33. package/events/Spent.sol +2 -3
  34. package/events/Unlocked.sol +2 -3
  35. package/guards/Base.sol +4 -4
  36. package/package.json +1 -1
  37. package/peer/AllowAssets.sol +3 -3
  38. package/peer/Allowance.sol +2 -2
  39. package/peer/Base.sol +4 -4
  40. package/peer/Credit.sol +10 -10
  41. package/peer/Debit.sol +10 -10
  42. package/peer/DenyAssets.sol +3 -3
  43. package/peer/Recover.sol +51 -0
  44. package/peer/Redeem.sol +48 -0
  45. package/peer/Settle.sol +3 -3
  46. package/queries/Assets.sol +7 -8
  47. package/queries/Balances.sol +8 -9
  48. package/queries/Base.sol +4 -4
  49. package/queries/Positions.sol +4 -6
  50. package/utils/Accounts.sol +76 -58
  51. package/utils/Assets.sol +55 -115
  52. package/utils/Ids.sol +33 -233
  53. package/utils/Layout.sol +11 -17
  54. package/utils/Nodes.sol +263 -0
  55. package/utils/Utils.sol +9 -24
  56. 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.
@@ -813,94 +811,84 @@ library Cursors {
813
811
 
814
812
  // Generic typed-shape decoders
815
813
 
816
- /// @notice Consume a fixed-size asset amount block and return asset, meta, and amount.
814
+ /// @notice Consume a fixed-size asset amount block and return asset and amount.
817
815
  /// @param cur Cursor; advanced past the block.
818
816
  /// @param key Expected block key.
819
817
  /// @return asset Asset identifier.
820
- /// @return meta Asset metadata slot.
821
818
  /// @return amount Scalar amount value.
822
819
  function unpackAssetAmount(
823
820
  Cur memory cur,
824
821
  bytes4 key
825
- ) internal pure returns (bytes32 asset, bytes32 meta, uint amount) {
826
- uint abs = consume(cur, 0, key, 96, 96);
822
+ ) internal pure returns (bytes32 asset, uint amount) {
823
+ uint abs = consume(cur, 0, key, 64, 64);
827
824
  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]));
825
+ amount = uint(bytes32(msg.data[abs + 32:abs + 64]));
830
826
  }
831
827
 
832
- /// @notice Consume a fixed-size account amount block and return account, asset, meta, and amount.
828
+ /// @notice Consume a fixed-size account amount block and return account, asset, and amount.
833
829
  /// @param cur Cursor; advanced past the block.
834
830
  /// @param key Expected block key.
835
831
  /// @return account Account identifier.
836
832
  /// @return asset Asset identifier.
837
- /// @return meta Asset metadata slot.
838
833
  /// @return amount Scalar amount value.
839
834
  function unpackAccountAmount(
840
835
  Cur memory cur,
841
836
  bytes4 key
842
- ) internal pure returns (bytes32 account, bytes32 asset, bytes32 meta, uint amount) {
843
- uint abs = consume(cur, 0, key, 128, 128);
837
+ ) internal pure returns (bytes32 account, bytes32 asset, uint amount) {
838
+ uint abs = consume(cur, 0, key, 96, 96);
844
839
  account = bytes32(msg.data[abs:abs + 32]);
845
840
  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]));
841
+ amount = uint(bytes32(msg.data[abs + 64:abs + 96]));
848
842
  }
849
843
 
850
- /// @notice Consume a fixed-size host amount block and return host, asset, meta, and amount.
844
+ /// @notice Consume a fixed-size host amount block and return host, asset, and amount.
851
845
  /// @param cur Cursor; advanced past the block.
852
846
  /// @param key Expected block key.
853
847
  /// @return host Host node ID.
854
848
  /// @return asset Asset identifier.
855
- /// @return meta Asset metadata slot.
856
849
  /// @return amount Scalar amount value.
857
850
  function unpackHostAmount(
858
851
  Cur memory cur,
859
852
  bytes4 key
860
- ) internal pure returns (uint host, bytes32 asset, bytes32 meta, uint amount) {
861
- uint abs = consume(cur, 0, key, 128, 128);
853
+ ) internal pure returns (uint host, bytes32 asset, uint amount) {
854
+ uint abs = consume(cur, 0, key, 96, 96);
862
855
  host = uint(bytes32(msg.data[abs:abs + 32]));
863
856
  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]));
857
+ amount = uint(bytes32(msg.data[abs + 64:abs + 96]));
866
858
  }
867
859
 
868
- /// @notice Consume a fixed-size host account asset block and return host, account, asset, and meta.
860
+ /// @notice Consume a fixed-size host account asset block and return host, account, and asset.
869
861
  /// @param cur Cursor; advanced past the block.
870
862
  /// @param key Expected block key.
871
863
  /// @return host Host node ID.
872
864
  /// @return account Account identifier.
873
865
  /// @return asset Asset identifier.
874
- /// @return meta Asset metadata slot.
875
866
  function unpackHostAccountAsset(
876
867
  Cur memory cur,
877
868
  bytes4 key
878
- ) internal pure returns (uint host, bytes32 account, bytes32 asset, bytes32 meta) {
879
- uint abs = consume(cur, 0, key, 128, 128);
869
+ ) internal pure returns (uint host, bytes32 account, bytes32 asset) {
870
+ uint abs = consume(cur, 0, key, 96, 96);
880
871
  host = uint(bytes32(msg.data[abs:abs + 32]));
881
872
  account = bytes32(msg.data[abs + 32:abs + 64]);
882
873
  asset = bytes32(msg.data[abs + 64:abs + 96]);
883
- meta = bytes32(msg.data[abs + 96:abs + 128]);
884
874
  }
885
875
 
886
- /// @notice Consume a fixed-size transaction block and return from, to, asset, meta, and amount.
876
+ /// @notice Consume a fixed-size transaction block and return from, to, asset, and amount.
887
877
  /// @param cur Cursor; advanced past the block.
888
878
  /// @param key Expected block key.
889
879
  /// @return from Source account identifier.
890
880
  /// @return to Destination account identifier.
891
881
  /// @return asset Asset identifier.
892
- /// @return meta Asset metadata slot.
893
882
  /// @return amount Scalar amount value.
894
883
  function unpackTransaction(
895
884
  Cur memory cur,
896
885
  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);
886
+ ) internal pure returns (bytes32 from, bytes32 to, bytes32 asset, uint amount) {
887
+ uint abs = consume(cur, 0, key, 128, 128);
899
888
  from = bytes32(msg.data[abs:abs + 32]);
900
889
  to = bytes32(msg.data[abs + 32:abs + 64]);
901
890
  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]));
891
+ amount = uint(bytes32(msg.data[abs + 96:abs + 128]));
904
892
  }
905
893
 
906
894
  // Type-specific fixed-width decoders
@@ -926,31 +914,28 @@ library Cursors {
926
914
  amount = uint(unpack32(cur, Keys.Fee));
927
915
  }
928
916
 
929
- /// @notice Consume an ASSET block and return the asset descriptor fields.
917
+ /// @notice Consume an ASSET block and return the asset identifier.
930
918
  /// @param cur Cursor; advanced past the block.
931
919
  /// @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);
920
+ function unpackAsset(Cur memory cur) internal pure returns (bytes32 asset) {
921
+ asset = unpack32(cur, Keys.Asset);
935
922
  }
936
923
 
937
924
  /// @notice Consume an ACCOUNT_ASSET form block and return its fields as separate values.
938
925
  /// @param cur Cursor; advanced past the block.
939
926
  /// @return account Account identifier.
940
927
  /// @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);
928
+ function unpackAccountAsset(Cur memory cur) internal pure returns (bytes32 account, bytes32 asset) {
929
+ uint abs = consume(cur, 0, Keys.AccountAsset, 64, 64);
944
930
  account = bytes32(msg.data[abs:abs + 32]);
945
931
  asset = bytes32(msg.data[abs + 32:abs + 64]);
946
- meta = bytes32(msg.data[abs + 64:abs + 96]);
947
932
  }
948
933
 
949
934
  /// @notice Consume an ACCOUNT_ASSET form block and return its fields as a struct.
950
935
  /// @param cur Cursor; advanced past the block.
951
- /// @return value Decoded account, asset, and meta.
936
+ /// @return value Decoded account and asset.
952
937
  function unpackAccountAssetValue(Cur memory cur) internal pure returns (AccountAsset memory value) {
953
- (value.account, value.asset, value.meta) = unpackAccountAsset(cur);
938
+ (value.account, value.asset) = unpackAccountAsset(cur);
954
939
  }
955
940
 
956
941
  /// @notice Consume a BOUNTY block and return the reward amount and relayer.
@@ -966,33 +951,31 @@ library Cursors {
966
951
  /// @notice Consume an AMOUNT block and return its fields as separate values.
967
952
  /// @param cur Cursor; advanced past the block.
968
953
  /// @return asset Asset identifier.
969
- /// @return meta Asset metadata slot.
970
954
  /// @return amount Token amount.
971
- function unpackAmount(Cur memory cur) internal pure returns (bytes32 asset, bytes32 meta, uint amount) {
955
+ function unpackAmount(Cur memory cur) internal pure returns (bytes32 asset, uint amount) {
972
956
  return unpackAssetAmount(cur, Keys.Amount);
973
957
  }
974
958
 
975
959
  /// @notice Consume an AMOUNT block and return its fields as a struct.
976
960
  /// @param cur Cursor; advanced past the block.
977
- /// @return value Decoded asset, meta, and amount.
961
+ /// @return value Decoded asset and amount.
978
962
  function unpackAmountValue(Cur memory cur) internal pure returns (AssetAmount memory value) {
979
- (value.asset, value.meta, value.amount) = unpackAssetAmount(cur, Keys.Amount);
963
+ (value.asset, value.amount) = unpackAssetAmount(cur, Keys.Amount);
980
964
  }
981
965
 
982
966
  /// @notice Consume a BALANCE block and return its fields as separate values.
983
967
  /// @param cur Cursor; advanced past the block.
984
968
  /// @return asset Asset identifier.
985
- /// @return meta Asset metadata slot.
986
969
  /// @return amount Token amount.
987
- function unpackBalance(Cur memory cur) internal pure returns (bytes32 asset, bytes32 meta, uint amount) {
970
+ function unpackBalance(Cur memory cur) internal pure returns (bytes32 asset, uint amount) {
988
971
  return unpackAssetAmount(cur, Keys.Balance);
989
972
  }
990
973
 
991
974
  /// @notice Consume a BALANCE block and return its fields as a struct.
992
975
  /// @param cur Cursor; advanced past the block.
993
- /// @return value Decoded asset, meta, and amount.
976
+ /// @return value Decoded asset and amount.
994
977
  function unpackBalanceValue(Cur memory cur) internal pure returns (AssetAmount memory value) {
995
- (value.asset, value.meta, value.amount) = unpackAssetAmount(cur, Keys.Balance);
978
+ (value.asset, value.amount) = unpackAssetAmount(cur, Keys.Balance);
996
979
  }
997
980
 
998
981
  /// @notice Consume a HOST_ACCOUNT_ASSET form block and return its fields as separate values.
@@ -1000,92 +983,87 @@ library Cursors {
1000
983
  /// @return host Host node ID.
1001
984
  /// @return account Account identifier.
1002
985
  /// @return asset Asset identifier.
1003
- /// @return meta Asset metadata slot.
1004
986
  function unpackHostAccountAsset(
1005
987
  Cur memory cur
1006
- ) internal pure returns (uint host, bytes32 account, bytes32 asset, bytes32 meta) {
988
+ ) internal pure returns (uint host, bytes32 account, bytes32 asset) {
1007
989
  return unpackHostAccountAsset(cur, Keys.HostAccountAsset);
1008
990
  }
1009
991
 
1010
992
  /// @notice Consume a HOST_ACCOUNT_ASSET form block and return its fields as a struct.
1011
993
  /// @param cur Cursor; advanced past the block.
1012
- /// @return value Decoded host, account, asset, and meta.
994
+ /// @return value Decoded host, account, and asset.
1013
995
  function unpackHostAccountAssetValue(Cur memory cur) internal pure returns (HostAccountAsset memory value) {
1014
- (value.host, value.account, value.asset, value.meta) = unpackHostAccountAsset(cur, Keys.HostAccountAsset);
996
+ (value.host, value.account, value.asset) = unpackHostAccountAsset(cur, Keys.HostAccountAsset);
1015
997
  }
1016
998
 
1017
999
  /// @notice Consume an ACCOUNT_AMOUNT form block and return its fields as separate values.
1018
1000
  /// @param cur Cursor; advanced past the block.
1019
1001
  /// @return account Account identifier.
1020
1002
  /// @return asset Asset identifier.
1021
- /// @return meta Asset metadata slot.
1022
1003
  /// @return amount Token amount.
1023
1004
  function unpackAccountAmount(
1024
1005
  Cur memory cur
1025
- ) internal pure returns (bytes32 account, bytes32 asset, bytes32 meta, uint amount) {
1006
+ ) internal pure returns (bytes32 account, bytes32 asset, uint amount) {
1026
1007
  return unpackAccountAmount(cur, Keys.AccountAmount);
1027
1008
  }
1028
1009
 
1029
1010
  /// @notice Consume an ACCOUNT_AMOUNT form block and return its fields as a struct.
1030
1011
  /// @param cur Cursor; advanced past the block.
1031
- /// @return value Decoded account, asset, meta, and amount.
1012
+ /// @return value Decoded account, asset, and amount.
1032
1013
  function unpackAccountAmountValue(Cur memory cur) internal pure returns (AccountAmount memory value) {
1033
- (value.account, value.asset, value.meta, value.amount) = unpackAccountAmount(cur, Keys.AccountAmount);
1014
+ (value.account, value.asset, value.amount) = unpackAccountAmount(cur, Keys.AccountAmount);
1034
1015
  }
1035
1016
 
1036
1017
  /// @notice Consume an ALLOCATION block and return its fields as separate values.
1037
1018
  /// @param cur Cursor; advanced past the block.
1038
1019
  /// @return host Host node ID.
1039
1020
  /// @return asset Asset identifier.
1040
- /// @return meta Asset metadata slot.
1041
1021
  /// @return amount Token amount.
1042
1022
  function unpackAllocation(
1043
1023
  Cur memory cur
1044
- ) internal pure returns (uint host, bytes32 asset, bytes32 meta, uint amount) {
1024
+ ) internal pure returns (uint host, bytes32 asset, uint amount) {
1045
1025
  return unpackHostAmount(cur, Keys.Allocation);
1046
1026
  }
1047
1027
 
1048
1028
  /// @notice Consume an ALLOCATION block and return its fields as a struct.
1049
1029
  /// @param cur Cursor; advanced past the block.
1050
- /// @return value Decoded host, asset, meta, and amount.
1030
+ /// @return value Decoded host, asset, and amount.
1051
1031
  function unpackAllocationValue(Cur memory cur) internal pure returns (HostAmount memory value) {
1052
- (value.host, value.asset, value.meta, value.amount) = unpackHostAmount(cur, Keys.Allocation);
1032
+ (value.host, value.asset, value.amount) = unpackHostAmount(cur, Keys.Allocation);
1053
1033
  }
1054
1034
 
1055
1035
  /// @notice Consume an ALLOWANCE block and return its fields as separate values.
1056
1036
  /// @param cur Cursor; advanced past the block.
1057
1037
  /// @return host Host node ID.
1058
1038
  /// @return asset Asset identifier.
1059
- /// @return meta Asset metadata slot.
1060
1039
  /// @return amount Token amount.
1061
1040
  function unpackAllowance(
1062
1041
  Cur memory cur
1063
- ) internal pure returns (uint host, bytes32 asset, bytes32 meta, uint amount) {
1042
+ ) internal pure returns (uint host, bytes32 asset, uint amount) {
1064
1043
  return unpackHostAmount(cur, Keys.Allowance);
1065
1044
  }
1066
1045
 
1067
1046
  /// @notice Consume an ALLOWANCE block and return its fields as a struct.
1068
1047
  /// @param cur Cursor; advanced past the block.
1069
- /// @return value Decoded host, asset, meta, and amount.
1048
+ /// @return value Decoded host, asset, and amount.
1070
1049
  function unpackAllowanceValue(Cur memory cur) internal pure returns (HostAmount memory value) {
1071
- (value.host, value.asset, value.meta, value.amount) = unpackHostAmount(cur, Keys.Allowance);
1050
+ (value.host, value.asset, value.amount) = unpackHostAmount(cur, Keys.Allowance);
1072
1051
  }
1073
1052
 
1074
1053
  /// @notice Consume a CUSTODY block and return its fields as separate values.
1075
1054
  /// @param cur Cursor; advanced past the block.
1076
1055
  /// @return host Host node ID.
1077
1056
  /// @return asset Asset identifier.
1078
- /// @return meta Asset metadata slot.
1079
1057
  /// @return amount Token amount.
1080
- function unpackCustody(Cur memory cur) internal pure returns (uint host, bytes32 asset, bytes32 meta, uint amount) {
1058
+ function unpackCustody(Cur memory cur) internal pure returns (uint host, bytes32 asset, uint amount) {
1081
1059
  return unpackHostAmount(cur, Keys.Custody);
1082
1060
  }
1083
1061
 
1084
1062
  /// @notice Consume a CUSTODY block and return its fields as a struct.
1085
1063
  /// @param cur Cursor; advanced past the block.
1086
- /// @return value Decoded host, asset, meta, and amount.
1064
+ /// @return value Decoded host, asset, and amount.
1087
1065
  function unpackCustodyValue(Cur memory cur) internal pure returns (HostAmount memory value) {
1088
- (value.host, value.asset, value.meta, value.amount) = unpackHostAmount(cur, Keys.Custody);
1066
+ (value.host, value.asset, value.amount) = unpackHostAmount(cur, Keys.Custody);
1089
1067
  }
1090
1068
 
1091
1069
  /// @notice Consume a TRANSACTION block and return its fields as separate values.
@@ -1093,19 +1071,18 @@ library Cursors {
1093
1071
  /// @return from Source account identifier.
1094
1072
  /// @return to Destination account identifier.
1095
1073
  /// @return asset Asset identifier.
1096
- /// @return meta Asset metadata slot.
1097
1074
  /// @return amount Token amount.
1098
1075
  function unpackTransaction(
1099
1076
  Cur memory cur
1100
- ) internal pure returns (bytes32 from, bytes32 to, bytes32 asset, bytes32 meta, uint amount) {
1077
+ ) internal pure returns (bytes32 from, bytes32 to, bytes32 asset, uint amount) {
1101
1078
  return unpackTransaction(cur, Keys.Transaction);
1102
1079
  }
1103
1080
 
1104
1081
  /// @notice Consume a TRANSACTION block and return all fields as a struct.
1105
1082
  /// @param cur Cursor; advanced past the block.
1106
- /// @return value Decoded from, to, asset, meta, and amount.
1083
+ /// @return value Decoded from, to, asset, and amount.
1107
1084
  function unpackTxValue(Cur memory cur) internal pure returns (Tx memory value) {
1108
- (value.from, value.to, value.asset, value.meta, value.amount) = unpackTransaction(cur);
1085
+ (value.from, value.to, value.asset, value.amount) = unpackTransaction(cur);
1109
1086
  }
1110
1087
 
1111
1088
  // Type-specific dynamic decoders
@@ -1225,47 +1202,25 @@ library Cursors {
1225
1202
  /// @param cur Cursor; advanced past the block.
1226
1203
  /// @param key Expected block type key.
1227
1204
  /// @param asset Expected asset identifier.
1228
- /// @return meta Metadata slot from the block.
1229
1205
  /// @return amount Amount from the block.
1230
1206
  function requireAssetAmount(
1231
1207
  Cur memory cur,
1232
1208
  bytes4 key,
1233
1209
  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
1210
  ) internal pure returns (uint amount) {
1253
- uint abs = consume(cur, 0, key, 96, 96);
1211
+ uint abs = consume(cur, 0, key, 64, 64);
1254
1212
  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]));
1213
+ amount = uint(bytes32(msg.data[abs + 32:abs + 64]));
1257
1214
  }
1258
1215
 
1259
1216
  /// @notice Consume an asset amount block, assert it matches the expected asset, and require the amount to be 1.
1260
1217
  /// @param cur Cursor; advanced past the block.
1261
1218
  /// @param key Expected block type key.
1262
1219
  /// @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);
1220
+ function requireUnitAssetAmount(Cur memory cur, bytes4 key, bytes32 asset) internal pure {
1221
+ uint abs = consume(cur, 0, key, 64, 64);
1266
1222
  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();
1223
+ if (uint(bytes32(msg.data[abs + 32:abs + 64])) != 1) revert UnexpectedValue();
1269
1224
  }
1270
1225
 
1271
1226
  /// @notice Consume a host amount block and assert it matches the expected host.
@@ -1273,18 +1228,16 @@ library Cursors {
1273
1228
  /// @param key Expected block type key.
1274
1229
  /// @param host Expected host node ID.
1275
1230
  /// @return asset Asset identifier from the block.
1276
- /// @return meta Metadata slot from the block.
1277
1231
  /// @return amount Amount from the block.
1278
1232
  function requireHostAmount(
1279
1233
  Cur memory cur,
1280
1234
  bytes4 key,
1281
1235
  uint host
1282
- ) internal pure returns (bytes32 asset, bytes32 meta, uint amount) {
1283
- uint abs = consume(cur, 0, key, 128, 128);
1236
+ ) internal pure returns (bytes32 asset, uint amount) {
1237
+ uint abs = consume(cur, 0, key, 96, 96);
1284
1238
  if (uint(bytes32(msg.data[abs:abs + 32])) != host) revert UnexpectedValue();
1285
1239
  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]));
1240
+ amount = uint(bytes32(msg.data[abs + 64:abs + 96]));
1288
1241
  }
1289
1242
 
1290
1243
  /// @notice Consume a host amount block and assert it matches the expected host and asset.
@@ -1292,19 +1245,17 @@ library Cursors {
1292
1245
  /// @param key Expected block type key.
1293
1246
  /// @param host Expected host node ID.
1294
1247
  /// @param asset Expected asset identifier.
1295
- /// @return meta Metadata slot from the block.
1296
1248
  /// @return amount Amount from the block.
1297
1249
  function requireHostAmount(
1298
1250
  Cur memory cur,
1299
1251
  bytes4 key,
1300
1252
  uint host,
1301
1253
  bytes32 asset
1302
- ) internal pure returns (bytes32 meta, uint amount) {
1303
- uint abs = consume(cur, 0, key, 128, 128);
1254
+ ) internal pure returns (uint amount) {
1255
+ uint abs = consume(cur, 0, key, 96, 96);
1304
1256
  if (uint(bytes32(msg.data[abs:abs + 32])) != host) revert UnexpectedValue();
1305
1257
  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]));
1258
+ amount = uint(bytes32(msg.data[abs + 64:abs + 96]));
1308
1259
  }
1309
1260
 
1310
1261
  /// @notice Consume a host amount block, assert it matches the expected host and asset, and require the amount to be 1.
@@ -1312,18 +1263,16 @@ library Cursors {
1312
1263
  /// @param key Expected block type key.
1313
1264
  /// @param host Expected host node ID.
1314
1265
  /// @param asset Expected asset identifier.
1315
- /// @return meta Metadata slot from the block.
1316
1266
  function requireUnitHostAmount(
1317
1267
  Cur memory cur,
1318
1268
  bytes4 key,
1319
1269
  uint host,
1320
1270
  bytes32 asset
1321
- ) internal pure returns (bytes32 meta) {
1322
- uint abs = consume(cur, 0, key, 128, 128);
1271
+ ) internal pure {
1272
+ uint abs = consume(cur, 0, key, 96, 96);
1323
1273
  if (uint(bytes32(msg.data[abs:abs + 32])) != host) revert UnexpectedValue();
1324
1274
  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();
1275
+ if (uint(bytes32(msg.data[abs + 64:abs + 96])) != 1) revert UnexpectedValue();
1327
1276
  }
1328
1277
 
1329
1278
  /// @notice Consume a host account asset block and assert it matches the expected host and account.
@@ -1332,49 +1281,44 @@ library Cursors {
1332
1281
  /// @param host Expected host node ID.
1333
1282
  /// @param account Expected account identifier.
1334
1283
  /// @return asset Asset identifier from the block.
1335
- /// @return meta Metadata slot from the block.
1336
1284
  function requireHostAccountAsset(
1337
1285
  Cur memory cur,
1338
1286
  bytes4 key,
1339
1287
  uint host,
1340
1288
  bytes32 account
1341
- ) internal pure returns (bytes32 asset, bytes32 meta) {
1342
- uint abs = consume(cur, 0, key, 128, 128);
1289
+ ) internal pure returns (bytes32 asset) {
1290
+ uint abs = consume(cur, 0, key, 96, 96);
1343
1291
  if (uint(bytes32(msg.data[abs:abs + 32])) != host) revert UnexpectedValue();
1344
1292
  if (bytes32(msg.data[abs + 32:abs + 64]) != account) revert UnexpectedValue();
1345
1293
  asset = bytes32(msg.data[abs + 64:abs + 96]);
1346
- meta = bytes32(msg.data[abs + 96:abs + 128]);
1347
1294
  }
1348
1295
 
1349
- /// @notice Consume a host account asset block, assert it targets the expected host, and return account, asset, and meta.
1296
+ /// @notice Consume a host account asset block, assert it targets the expected host, and return account and asset.
1350
1297
  /// @param cur Cursor; advanced past the block.
1351
1298
  /// @param key Expected block key.
1352
1299
  /// @param host Expected host node ID.
1353
1300
  /// @return account Account identifier from the block.
1354
1301
  /// @return asset Asset identifier from the block.
1355
- /// @return meta Metadata slot from the block.
1356
1302
  function requireHostAccountAsset(
1357
1303
  Cur memory cur,
1358
1304
  bytes4 key,
1359
1305
  uint host
1360
- ) internal pure returns (bytes32 account, bytes32 asset, bytes32 meta) {
1361
- uint abs = consume(cur, 0, key, 128, 128);
1306
+ ) internal pure returns (bytes32 account, bytes32 asset) {
1307
+ uint abs = consume(cur, 0, key, 96, 96);
1362
1308
  if (uint(bytes32(msg.data[abs:abs + 32])) != host) revert UnexpectedValue();
1363
1309
  account = bytes32(msg.data[abs + 32:abs + 64]);
1364
1310
  asset = bytes32(msg.data[abs + 64:abs + 96]);
1365
- meta = bytes32(msg.data[abs + 96:abs + 128]);
1366
1311
  }
1367
1312
 
1368
- /// @notice Consume a HOST_ACCOUNT_ASSET form block, assert it targets the expected host, and return account, asset, and meta.
1313
+ /// @notice Consume a HOST_ACCOUNT_ASSET form block, assert it targets the expected host, and return account and asset.
1369
1314
  /// @param cur Cursor; advanced past the block.
1370
1315
  /// @param host Expected host node ID.
1371
1316
  /// @return account Account identifier from the block.
1372
1317
  /// @return asset Asset identifier from the block.
1373
- /// @return meta Metadata slot from the block.
1374
1318
  function requireHostAccountAsset(
1375
1319
  Cur memory cur,
1376
1320
  uint host
1377
- ) internal pure returns (bytes32 account, bytes32 asset, bytes32 meta) {
1321
+ ) internal pure returns (bytes32 account, bytes32 asset) {
1378
1322
  return requireHostAccountAsset(cur, Keys.HostAccountAsset, host);
1379
1323
  }
1380
1324
 
@@ -1395,29 +1339,25 @@ library Cursors {
1395
1339
  /// @notice Consume a BALANCE_LIMIT block and assert all constraint fields match the provided balance.
1396
1340
  /// @param cur Cursor; advanced past the block.
1397
1341
  /// @param asset Expected asset identifier.
1398
- /// @param meta Expected metadata slot.
1399
1342
  /// @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);
1343
+ function ensureBalanceLimit(Cur memory cur, bytes32 asset, uint amount) internal pure {
1344
+ uint abs = consume(cur, 0, Keys.BalanceLimit, 96, 96);
1402
1345
  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();
1346
+ if (uint(bytes32(msg.data[abs + 32:abs + 64])) > amount) revert UnexpectedValue();
1347
+ if (uint(bytes32(msg.data[abs + 64:abs + 96])) < amount) revert UnexpectedValue();
1406
1348
  }
1407
1349
 
1408
1350
  /// @notice Consume a CUSTODY_LIMIT block and assert all constraint fields match the provided custody.
1409
1351
  /// @param cur Cursor; advanced past the block.
1410
1352
  /// @param host Expected host node ID.
1411
1353
  /// @param asset Expected asset identifier.
1412
- /// @param meta Expected metadata slot.
1413
1354
  /// @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);
1355
+ function ensureCustodyLimit(Cur memory cur, uint host, bytes32 asset, uint amount) internal pure {
1356
+ uint abs = consume(cur, 0, Keys.CustodyLimit, 128, 128);
1416
1357
  if (uint(bytes32(msg.data[abs:abs + 32])) != host) revert UnexpectedValue();
1417
1358
  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();
1359
+ if (uint(bytes32(msg.data[abs + 64:abs + 96])) > amount) revert UnexpectedValue();
1360
+ if (uint(bytes32(msg.data[abs + 96:abs + 128])) < amount) revert UnexpectedValue();
1421
1361
  }
1422
1362
 
1423
1363
  // -------------------------------------------------------------------------
package/blocks/Keys.sol CHANGED
@@ -9,19 +9,19 @@ library Keys {
9
9
  bytes4 constant Empty = bytes4(0);
10
10
  /// @dev Wildcard key used in discovery when any block stream is accepted.
11
11
  bytes4 constant Any = 0xffffffff;
12
- /// @dev Input amount - (bytes32 asset, bytes32 meta, uint amount)
12
+ /// @dev Input amount - (bytes32 asset, uint amount)
13
13
  bytes4 constant Amount = bytes4(keccak256("#amount"));
14
- /// @dev Ledger balance - (bytes32 asset, bytes32 meta, uint amount)
14
+ /// @dev Ledger balance - (bytes32 asset, uint amount)
15
15
  bytes4 constant Balance = bytes4(keccak256("#balance"));
16
- /// @dev Balance constraint - (bytes32 asset, bytes32 meta, uint min, uint max)
16
+ /// @dev Balance constraint - (bytes32 asset, uint min, uint max)
17
17
  bytes4 constant BalanceLimit = bytes4(keccak256("#balanceLimit"));
18
- /// @dev Host-scoped request amount - (uint host, bytes32 asset, bytes32 meta, uint amount)
18
+ /// @dev Host-scoped request amount - (uint host, bytes32 asset, uint amount)
19
19
  bytes4 constant Allocation = bytes4(keccak256("#allocation"));
20
- /// @dev Host-scoped allowance cap - (uint host, bytes32 asset, bytes32 meta, uint amount)
20
+ /// @dev Host-scoped allowance cap - (uint host, bytes32 asset, uint amount)
21
21
  bytes4 constant Allowance = bytes4(keccak256("#allowance"));
22
- /// @dev Cross-host custody state - (uint host, bytes32 asset, bytes32 meta, uint amount)
22
+ /// @dev Cross-host custody state - (uint host, bytes32 asset, uint amount)
23
23
  bytes4 constant Custody = bytes4(keccak256("#custody"));
24
- /// @dev Cross-host custody constraint - (uint host, bytes32 asset, bytes32 meta, uint min, uint max)
24
+ /// @dev Cross-host custody constraint - (uint host, bytes32 asset, uint min, uint max)
25
25
  bytes4 constant CustodyLimit = bytes4(keccak256("#custodyLimit"));
26
26
  /// @dev Fee amount - (uint amount)
27
27
  bytes4 constant Fee = bytes4(keccak256("#fee"));
@@ -37,7 +37,7 @@ library Keys {
37
37
  bytes4 constant String = bytes4(keccak256("#string"));
38
38
  /// @dev Account identifier - (bytes32 account)
39
39
  bytes4 constant Account = bytes4(keccak256("#account"));
40
- /// @dev Transfer record passed through the pipeline - (bytes32 from, bytes32 to, bytes32 asset, bytes32 meta, uint amount)
40
+ /// @dev Transfer record passed through the pipeline - (bytes32 from, bytes32 to, bytes32 asset, uint amount)
41
41
  bytes4 constant Transaction = bytes4(keccak256("#transaction"));
42
42
  /// @dev Sub-command invocation - (uint target, uint resources, #bytes as request)
43
43
  bytes4 constant Step = bytes4(keccak256("#step"));
@@ -53,7 +53,7 @@ library Keys {
53
53
  bytes4 constant Pipe = bytes4(keccak256("#pipe"));
54
54
  /// @dev Authentication proof - (uint cid, uint deadline, #bytes as proof); must appear last in its segment
55
55
  bytes4 constant Auth = bytes4(keccak256("#auth"));
56
- /// @dev Asset descriptor without amount - (bytes32 asset, bytes32 meta)
56
+ /// @dev Asset descriptor without amount - (bytes32 asset)
57
57
  bytes4 constant Asset = bytes4(keccak256("#asset"));
58
58
  /// @dev Node identifier - (uint id)
59
59
  bytes4 constant Node = bytes4(keccak256("#node"));
@@ -64,16 +64,16 @@ library Keys {
64
64
 
65
65
  /// @dev Structural status form - (uint code)
66
66
  bytes4 constant Status = bytes4(keccak256("#status"));
67
- /// @dev Structural asset amount form - (bytes32 asset, bytes32 meta, uint amount)
67
+ /// @dev Structural asset amount form - (bytes32 asset, uint amount)
68
68
  bytes4 constant AssetAmount = bytes4(keccak256("#assetAmount"));
69
- /// @dev Structural account asset form - (bytes32 account, bytes32 asset, bytes32 meta)
69
+ /// @dev Structural account asset form - (bytes32 account, bytes32 asset)
70
70
  bytes4 constant AccountAsset = bytes4(keccak256("#accountAsset"));
71
- /// @dev Structural account amount form - (bytes32 account, bytes32 asset, bytes32 meta, uint amount)
71
+ /// @dev Structural account amount form - (bytes32 account, bytes32 asset, uint amount)
72
72
  bytes4 constant AccountAmount = bytes4(keccak256("#accountAmount"));
73
- /// @dev Structural host amount form - (uint host, bytes32 asset, bytes32 meta, uint amount)
73
+ /// @dev Structural host amount form - (uint host, bytes32 asset, uint amount)
74
74
  bytes4 constant HostAmount = bytes4(keccak256("#hostAmount"));
75
- /// @dev Structural host account asset form - (uint host, bytes32 account, bytes32 asset, bytes32 meta)
75
+ /// @dev Structural host account asset form - (uint host, bytes32 account, bytes32 asset)
76
76
  bytes4 constant HostAccountAsset = bytes4(keccak256("#hostAccountAsset"));
77
- /// @dev Structural host account amount form - (uint host, bytes32 account, bytes32 asset, bytes32 meta, uint amount)
77
+ /// @dev Structural host account amount form - (uint host, bytes32 account, bytes32 asset, uint amount)
78
78
  bytes4 constant HostAccountAmount = bytes4(keccak256("#hostAccountAmount"));
79
79
  }