@capxul/sdk-react 4.20.0-beta.11 → 4.20.0-beta.13

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 (2) hide show
  1. package/dist/index.mjs +16 -12
  2. package/package.json +5 -5
package/dist/index.mjs CHANGED
@@ -2963,28 +2963,33 @@ function decodeDraft(value, scope) {
2963
2963
  const to = record(item.to);
2964
2964
  const amount = record(item.amount);
2965
2965
  const partyId = toPartyId(identifier(item.partyId));
2966
- if (to.kind !== "party" || to.partyId !== partyId || item.gross !== item.net || typeof amount.asset !== "string" || typeof amount.value !== "string" || typeof item.currency !== "string" || typeof item.decimals !== "number" || !Number.isInteger(item.decimals) || !Array.isArray(item.adjustments) || item.adjustments.length !== 0) throw Errors.invalidInput("payrollDraft", "Invalid draft recipient");
2966
+ if (to.kind !== "party" || to.partyId !== partyId || item.gross !== item.net || typeof amount.asset !== "string" || typeof amount.value !== "string" || "currency" in item || "decimals" in item || !Array.isArray(item.adjustments) || item.adjustments.length !== 0) throw Errors.invalidInput("payrollDraft", "Invalid draft recipient");
2967
2967
  const net = minorAmount(item.net);
2968
+ const selectedAsset = requireAsset(identifier(amount.asset));
2969
+ const selectedAmount = {
2970
+ asset: selectedAsset.assetId,
2971
+ value: amount.value
2972
+ };
2973
+ try {
2974
+ if (toRaw(selectedAmount, selectedAsset).toString() !== net) throw Errors.invalidInput("payrollDraft", "Draft payout units differ from net");
2975
+ } catch {
2976
+ throw Errors.invalidInput("payrollDraft", "Invalid draft payout amount");
2977
+ }
2968
2978
  return {
2969
2979
  to: {
2970
2980
  kind: "party",
2971
2981
  partyId
2972
2982
  },
2973
2983
  partyId,
2974
- amount: {
2975
- asset: requireAsset(amount.asset).assetId,
2976
- value: amount.value
2977
- },
2984
+ amount: selectedAmount,
2978
2985
  gross: net,
2979
2986
  net,
2980
- currency: item.currency,
2981
- decimals: item.decimals,
2982
2987
  adjustments: []
2983
2988
  };
2984
2989
  });
2985
2990
  if (new Set(items.map((item) => item.partyId)).size !== items.length) throw Errors.invalidInput("payrollDraft", "Duplicate draft recipient");
2986
2991
  const exactAsset = requireAsset(identifier(asset.id));
2987
- if (items.some((item) => item.amount.asset !== exactAsset.assetId)) throw Errors.invalidInput("payrollDraft", "Draft item asset does not match the run asset");
2992
+ if (input.asset !== exactAsset.assetId || items.some((item) => item.amount.asset !== exactAsset.assetId)) throw Errors.invalidInput("payrollDraft", "Draft item asset does not match the run asset");
2988
2993
  return {
2989
2994
  version: 1,
2990
2995
  scope,
@@ -3229,6 +3234,7 @@ function freshRunItems(input) {
3229
3234
  const amount = input.amounts[index];
3230
3235
  const terms = input.compensationTerms.get(recipientId);
3231
3236
  if (to === void 0 || amount === void 0 || terms === void 0) throw Errors.unknown();
3237
+ const rawAmount = toRaw(amount, requireAsset(amount.asset)).toString();
3232
3238
  items.push({
3233
3239
  to: {
3234
3240
  kind: "party",
@@ -3236,10 +3242,8 @@ function freshRunItems(input) {
3236
3242
  },
3237
3243
  partyId: recipientId,
3238
3244
  amount,
3239
- gross: terms.rate,
3240
- net: terms.rate,
3241
- currency: terms.currency,
3242
- decimals: terms.decimals,
3245
+ gross: rawAmount,
3246
+ net: rawAmount,
3243
3247
  adjustments: []
3244
3248
  });
3245
3249
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/sdk-react",
3
- "version": "4.20.0-beta.11",
3
+ "version": "4.20.0-beta.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Xelmar-tech/infrastructure.git",
@@ -26,7 +26,7 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "@capxul/sdk": "4.20.0-beta.11"
29
+ "@capxul/sdk": "4.20.0-beta.13"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@tanstack/react-query": "^5.66.9",
@@ -43,10 +43,10 @@
43
43
  "vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
44
44
  "vite-plus": "0.3.0",
45
45
  "vitest": "4.1.11",
46
- "@capxul/config": "0.4.0-beta.0",
47
- "@capxul/errors": "0.3.0",
46
+ "@capxul/config": "0.4.0-beta.1",
48
47
  "@capxul/types": "0.3.0",
49
- "@capxul/typescript-config": "0.0.0"
48
+ "@capxul/typescript-config": "0.0.0",
49
+ "@capxul/errors": "0.3.0"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@tanstack/react-query": "^5.66.9",