@capxul/sdk 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1670,6 +1670,7 @@ interface InboxItem {
1670
1670
  interface InboxApproveInput {
1671
1671
  readonly requestId: string;
1672
1672
  readonly timing?: PaymentTiming;
1673
+ readonly permissionId?: string;
1673
1674
  }
1674
1675
  interface InboxMethods {
1675
1676
  list(options?: {
@@ -1,5 +1,5 @@
1
1
  import { D as toOrgId, F as isCapxulError, M as CapxulError, N as EXPECTED_OPERATION_OUTCOMES, P as Errors, S as toEmail, _ as toAuthUserId, b as toCurrencyCode, c as BYTES32_RE, d as WEI_RE, f as ZERO_BYTES32, k as toRoleKey, l as EVM_ADDRESS_RE$1, m as toAddress, n as BrowserAuthCacheAdapter, p as toAccountId, s as APP_ID_RE, t as InMemoryAuthCacheAdapter, u as SUPPORTED_CURRENCY_CODES, v as toChainId, y as toCountryCode } from "./InMemoryAuthCacheAdapter-Rc8tCtml.mjs";
2
- import { concat, encodeAbiParameters, encodeFunctionData, encodePacked, formatUnits, getContractAddress, keccak256, padHex, parseUnits, stringToHex, toBytes, toEventSelector, toFunctionSelector } from "viem";
2
+ import { concat, encodeAbiParameters, encodeFunctionData, encodePacked, formatUnits, getContractAddress, keccak256, padHex, parseUnits, stringToHex, toBytes, toEventSelector, toFunctionSelector, toFunctionSignature } from "viem";
3
3
  import { Context, Data, Deferred, Effect, Exit, Fiber, Layer, Queue, Ref, Result, Schema, SchemaGetter, Scope } from "effect";
4
4
  import { makeFunctionReference } from "convex/server";
5
5
  //#region src/domain/identity/model.ts
@@ -591,6 +591,12 @@ const EXEC_TRANSACTION_WITH_ROLE = "zodiac.roles.execTransactionWithRole";
591
591
  const ASSIGN_ROLES = "zodiac.roles.assignRoles";
592
592
  const SCOPE_TARGET = "zodiac.roles.scopeTarget";
593
593
  const OWNER_ROLE_LABEL = "Owner";
594
+ const FOUNDER_BUDGET_ROLE_LABEL = "Founder Budget";
595
+ const FOUNDER_BUDGET_LIMIT = {
596
+ currency: "USD",
597
+ value: "1000000000000",
598
+ decimals: 6
599
+ };
594
600
  function usd(value) {
595
601
  return {
596
602
  currency: "USD",
@@ -630,6 +636,13 @@ function soloOrgRoleTemplate() {
630
636
  label: "Owner",
631
637
  canManageMembers: true,
632
638
  canManageRoles: true
639
+ }, {
640
+ label: FOUNDER_BUDGET_ROLE_LABEL,
641
+ spend: {
642
+ perTx: FOUNDER_BUDGET_LIMIT,
643
+ perDay: FOUNDER_BUDGET_LIMIT,
644
+ toRecipients: "anyone"
645
+ }
633
646
  }];
634
647
  }
635
648
  function startupOrgRoleTemplate() {
@@ -696,6 +709,634 @@ function compileOrgRoleDefinitions(definitions) {
696
709
  }
697
710
  };
698
711
  }
712
+ //#endregion
713
+ //#region ../config/src/capxul-payments-v2.ts
714
+ /** The exact compiled CapxulPaymentsV2 ABI. */
715
+ const CAPXUL_PAYMENTS_V2_ABI = [
716
+ {
717
+ type: "function",
718
+ name: "cancel",
719
+ inputs: [{
720
+ name: "commitmentId",
721
+ type: "uint256",
722
+ internalType: "uint256"
723
+ }, {
724
+ name: "documentHash",
725
+ type: "bytes32",
726
+ internalType: "bytes32"
727
+ }],
728
+ outputs: [],
729
+ stateMutability: "nonpayable"
730
+ },
731
+ {
732
+ type: "function",
733
+ name: "claim",
734
+ inputs: [{
735
+ name: "commitmentId",
736
+ type: "uint256",
737
+ internalType: "uint256"
738
+ }],
739
+ outputs: [],
740
+ stateMutability: "nonpayable"
741
+ },
742
+ {
743
+ type: "function",
744
+ name: "claimableAmount",
745
+ inputs: [{
746
+ name: "commitmentId",
747
+ type: "uint256",
748
+ internalType: "uint256"
749
+ }],
750
+ outputs: [{
751
+ name: "",
752
+ type: "uint256",
753
+ internalType: "uint256"
754
+ }],
755
+ stateMutability: "view"
756
+ },
757
+ {
758
+ type: "function",
759
+ name: "commitments",
760
+ inputs: [{
761
+ name: "",
762
+ type: "uint256",
763
+ internalType: "uint256"
764
+ }],
765
+ outputs: [
766
+ {
767
+ name: "settlementId",
768
+ type: "bytes32",
769
+ internalType: "bytes32"
770
+ },
771
+ {
772
+ name: "creator",
773
+ type: "address",
774
+ internalType: "address"
775
+ },
776
+ {
777
+ name: "recipient",
778
+ type: "address",
779
+ internalType: "address"
780
+ },
781
+ {
782
+ name: "token",
783
+ type: "address",
784
+ internalType: "address"
785
+ },
786
+ {
787
+ name: "totalAmount",
788
+ type: "uint256",
789
+ internalType: "uint256"
790
+ },
791
+ {
792
+ name: "claimed",
793
+ type: "uint256",
794
+ internalType: "uint256"
795
+ },
796
+ {
797
+ name: "startTime",
798
+ type: "uint48",
799
+ internalType: "uint48"
800
+ },
801
+ {
802
+ name: "cliffTime",
803
+ type: "uint48",
804
+ internalType: "uint48"
805
+ },
806
+ {
807
+ name: "endTime",
808
+ type: "uint48",
809
+ internalType: "uint48"
810
+ },
811
+ {
812
+ name: "kind",
813
+ type: "uint16",
814
+ internalType: "uint16"
815
+ },
816
+ {
817
+ name: "documentHash",
818
+ type: "bytes32",
819
+ internalType: "bytes32"
820
+ },
821
+ {
822
+ name: "cancelled",
823
+ type: "bool",
824
+ internalType: "bool"
825
+ }
826
+ ],
827
+ stateMutability: "view"
828
+ },
829
+ {
830
+ type: "function",
831
+ name: "createCommitment",
832
+ inputs: [{
833
+ name: "input",
834
+ type: "tuple",
835
+ internalType: "struct CapxulPaymentsV2.CommitmentInput",
836
+ components: [
837
+ {
838
+ name: "settlementId",
839
+ type: "bytes32",
840
+ internalType: "bytes32"
841
+ },
842
+ {
843
+ name: "recipient",
844
+ type: "address",
845
+ internalType: "address"
846
+ },
847
+ {
848
+ name: "token",
849
+ type: "address",
850
+ internalType: "address"
851
+ },
852
+ {
853
+ name: "totalAmount",
854
+ type: "uint256",
855
+ internalType: "uint256"
856
+ },
857
+ {
858
+ name: "startTime",
859
+ type: "uint48",
860
+ internalType: "uint48"
861
+ },
862
+ {
863
+ name: "cliffTime",
864
+ type: "uint48",
865
+ internalType: "uint48"
866
+ },
867
+ {
868
+ name: "endTime",
869
+ type: "uint48",
870
+ internalType: "uint48"
871
+ },
872
+ {
873
+ name: "kind",
874
+ type: "uint16",
875
+ internalType: "uint16"
876
+ },
877
+ {
878
+ name: "documentHash",
879
+ type: "bytes32",
880
+ internalType: "bytes32"
881
+ }
882
+ ]
883
+ }],
884
+ outputs: [{
885
+ name: "commitmentId",
886
+ type: "uint256",
887
+ internalType: "uint256"
888
+ }],
889
+ stateMutability: "nonpayable"
890
+ },
891
+ {
892
+ type: "function",
893
+ name: "nextCommitmentId",
894
+ inputs: [],
895
+ outputs: [{
896
+ name: "",
897
+ type: "uint256",
898
+ internalType: "uint256"
899
+ }],
900
+ stateMutability: "view"
901
+ },
902
+ {
903
+ type: "function",
904
+ name: "redirect",
905
+ inputs: [
906
+ {
907
+ name: "commitmentId",
908
+ type: "uint256",
909
+ internalType: "uint256"
910
+ },
911
+ {
912
+ name: "recipient",
913
+ type: "address",
914
+ internalType: "address"
915
+ },
916
+ {
917
+ name: "documentHash",
918
+ type: "bytes32",
919
+ internalType: "bytes32"
920
+ }
921
+ ],
922
+ outputs: [],
923
+ stateMutability: "nonpayable"
924
+ },
925
+ {
926
+ type: "function",
927
+ name: "send",
928
+ inputs: [{
929
+ name: "item",
930
+ type: "tuple",
931
+ internalType: "struct CapxulPaymentsV2.PaymentItem",
932
+ components: [
933
+ {
934
+ name: "settlementId",
935
+ type: "bytes32",
936
+ internalType: "bytes32"
937
+ },
938
+ {
939
+ name: "recipient",
940
+ type: "address",
941
+ internalType: "address"
942
+ },
943
+ {
944
+ name: "token",
945
+ type: "address",
946
+ internalType: "address"
947
+ },
948
+ {
949
+ name: "amount",
950
+ type: "uint256",
951
+ internalType: "uint256"
952
+ },
953
+ {
954
+ name: "kind",
955
+ type: "uint16",
956
+ internalType: "uint16"
957
+ },
958
+ {
959
+ name: "documentHash",
960
+ type: "bytes32",
961
+ internalType: "bytes32"
962
+ }
963
+ ]
964
+ }],
965
+ outputs: [],
966
+ stateMutability: "nonpayable"
967
+ },
968
+ {
969
+ type: "function",
970
+ name: "sendBatch",
971
+ inputs: [{
972
+ name: "items",
973
+ type: "tuple[]",
974
+ internalType: "struct CapxulPaymentsV2.PaymentItem[]",
975
+ components: [
976
+ {
977
+ name: "settlementId",
978
+ type: "bytes32",
979
+ internalType: "bytes32"
980
+ },
981
+ {
982
+ name: "recipient",
983
+ type: "address",
984
+ internalType: "address"
985
+ },
986
+ {
987
+ name: "token",
988
+ type: "address",
989
+ internalType: "address"
990
+ },
991
+ {
992
+ name: "amount",
993
+ type: "uint256",
994
+ internalType: "uint256"
995
+ },
996
+ {
997
+ name: "kind",
998
+ type: "uint16",
999
+ internalType: "uint16"
1000
+ },
1001
+ {
1002
+ name: "documentHash",
1003
+ type: "bytes32",
1004
+ internalType: "bytes32"
1005
+ }
1006
+ ]
1007
+ }],
1008
+ outputs: [],
1009
+ stateMutability: "nonpayable"
1010
+ },
1011
+ {
1012
+ type: "function",
1013
+ name: "vestedAmount",
1014
+ inputs: [{
1015
+ name: "commitmentId",
1016
+ type: "uint256",
1017
+ internalType: "uint256"
1018
+ }],
1019
+ outputs: [{
1020
+ name: "",
1021
+ type: "uint256",
1022
+ internalType: "uint256"
1023
+ }],
1024
+ stateMutability: "view"
1025
+ },
1026
+ {
1027
+ type: "event",
1028
+ name: "CommitmentCancelled",
1029
+ inputs: [
1030
+ {
1031
+ name: "commitmentId",
1032
+ type: "uint256",
1033
+ indexed: true,
1034
+ internalType: "uint256"
1035
+ },
1036
+ {
1037
+ name: "settlementId",
1038
+ type: "bytes32",
1039
+ indexed: true,
1040
+ internalType: "bytes32"
1041
+ },
1042
+ {
1043
+ name: "creator",
1044
+ type: "address",
1045
+ indexed: true,
1046
+ internalType: "address"
1047
+ },
1048
+ {
1049
+ name: "vestedUnclaimed",
1050
+ type: "uint256",
1051
+ indexed: false,
1052
+ internalType: "uint256"
1053
+ },
1054
+ {
1055
+ name: "unvestedReturned",
1056
+ type: "uint256",
1057
+ indexed: false,
1058
+ internalType: "uint256"
1059
+ },
1060
+ {
1061
+ name: "documentHash",
1062
+ type: "bytes32",
1063
+ indexed: false,
1064
+ internalType: "bytes32"
1065
+ }
1066
+ ],
1067
+ anonymous: false
1068
+ },
1069
+ {
1070
+ type: "event",
1071
+ name: "CommitmentCreated",
1072
+ inputs: [
1073
+ {
1074
+ name: "commitmentId",
1075
+ type: "uint256",
1076
+ indexed: true,
1077
+ internalType: "uint256"
1078
+ },
1079
+ {
1080
+ name: "settlementId",
1081
+ type: "bytes32",
1082
+ indexed: true,
1083
+ internalType: "bytes32"
1084
+ },
1085
+ {
1086
+ name: "creator",
1087
+ type: "address",
1088
+ indexed: true,
1089
+ internalType: "address"
1090
+ },
1091
+ {
1092
+ name: "recipient",
1093
+ type: "address",
1094
+ indexed: false,
1095
+ internalType: "address"
1096
+ },
1097
+ {
1098
+ name: "token",
1099
+ type: "address",
1100
+ indexed: false,
1101
+ internalType: "address"
1102
+ },
1103
+ {
1104
+ name: "totalAmount",
1105
+ type: "uint256",
1106
+ indexed: false,
1107
+ internalType: "uint256"
1108
+ },
1109
+ {
1110
+ name: "startTime",
1111
+ type: "uint48",
1112
+ indexed: false,
1113
+ internalType: "uint48"
1114
+ },
1115
+ {
1116
+ name: "cliffTime",
1117
+ type: "uint48",
1118
+ indexed: false,
1119
+ internalType: "uint48"
1120
+ },
1121
+ {
1122
+ name: "endTime",
1123
+ type: "uint48",
1124
+ indexed: false,
1125
+ internalType: "uint48"
1126
+ },
1127
+ {
1128
+ name: "kind",
1129
+ type: "uint16",
1130
+ indexed: false,
1131
+ internalType: "uint16"
1132
+ },
1133
+ {
1134
+ name: "documentHash",
1135
+ type: "bytes32",
1136
+ indexed: false,
1137
+ internalType: "bytes32"
1138
+ }
1139
+ ],
1140
+ anonymous: false
1141
+ },
1142
+ {
1143
+ type: "event",
1144
+ name: "CommitmentRedirected",
1145
+ inputs: [
1146
+ {
1147
+ name: "commitmentId",
1148
+ type: "uint256",
1149
+ indexed: true,
1150
+ internalType: "uint256"
1151
+ },
1152
+ {
1153
+ name: "settlementId",
1154
+ type: "bytes32",
1155
+ indexed: true,
1156
+ internalType: "bytes32"
1157
+ },
1158
+ {
1159
+ name: "oldRecipient",
1160
+ type: "address",
1161
+ indexed: true,
1162
+ internalType: "address"
1163
+ },
1164
+ {
1165
+ name: "newRecipient",
1166
+ type: "address",
1167
+ indexed: false,
1168
+ internalType: "address"
1169
+ },
1170
+ {
1171
+ name: "documentHash",
1172
+ type: "bytes32",
1173
+ indexed: false,
1174
+ internalType: "bytes32"
1175
+ }
1176
+ ],
1177
+ anonymous: false
1178
+ },
1179
+ {
1180
+ type: "event",
1181
+ name: "FundsClaimed",
1182
+ inputs: [
1183
+ {
1184
+ name: "commitmentId",
1185
+ type: "uint256",
1186
+ indexed: true,
1187
+ internalType: "uint256"
1188
+ },
1189
+ {
1190
+ name: "settlementId",
1191
+ type: "bytes32",
1192
+ indexed: true,
1193
+ internalType: "bytes32"
1194
+ },
1195
+ {
1196
+ name: "recipient",
1197
+ type: "address",
1198
+ indexed: true,
1199
+ internalType: "address"
1200
+ },
1201
+ {
1202
+ name: "amount",
1203
+ type: "uint256",
1204
+ indexed: false,
1205
+ internalType: "uint256"
1206
+ },
1207
+ {
1208
+ name: "documentHash",
1209
+ type: "bytes32",
1210
+ indexed: false,
1211
+ internalType: "bytes32"
1212
+ }
1213
+ ],
1214
+ anonymous: false
1215
+ },
1216
+ {
1217
+ type: "event",
1218
+ name: "PaymentSent",
1219
+ inputs: [
1220
+ {
1221
+ name: "settlementId",
1222
+ type: "bytes32",
1223
+ indexed: true,
1224
+ internalType: "bytes32"
1225
+ },
1226
+ {
1227
+ name: "sender",
1228
+ type: "address",
1229
+ indexed: true,
1230
+ internalType: "address"
1231
+ },
1232
+ {
1233
+ name: "recipient",
1234
+ type: "address",
1235
+ indexed: true,
1236
+ internalType: "address"
1237
+ },
1238
+ {
1239
+ name: "token",
1240
+ type: "address",
1241
+ indexed: false,
1242
+ internalType: "address"
1243
+ },
1244
+ {
1245
+ name: "amount",
1246
+ type: "uint256",
1247
+ indexed: false,
1248
+ internalType: "uint256"
1249
+ },
1250
+ {
1251
+ name: "kind",
1252
+ type: "uint16",
1253
+ indexed: false,
1254
+ internalType: "uint16"
1255
+ },
1256
+ {
1257
+ name: "documentHash",
1258
+ type: "bytes32",
1259
+ indexed: false,
1260
+ internalType: "bytes32"
1261
+ }
1262
+ ],
1263
+ anonymous: false
1264
+ },
1265
+ {
1266
+ type: "error",
1267
+ name: "AlreadyCancelled",
1268
+ inputs: []
1269
+ },
1270
+ {
1271
+ type: "error",
1272
+ name: "AlreadyClaimed",
1273
+ inputs: []
1274
+ },
1275
+ {
1276
+ type: "error",
1277
+ name: "DocumentHashMismatch",
1278
+ inputs: [{
1279
+ name: "expected",
1280
+ type: "bytes32",
1281
+ internalType: "bytes32"
1282
+ }, {
1283
+ name: "supplied",
1284
+ type: "bytes32",
1285
+ internalType: "bytes32"
1286
+ }]
1287
+ },
1288
+ {
1289
+ type: "error",
1290
+ name: "InvalidTimeParams",
1291
+ inputs: []
1292
+ },
1293
+ {
1294
+ type: "error",
1295
+ name: "NotCreator",
1296
+ inputs: []
1297
+ },
1298
+ {
1299
+ type: "error",
1300
+ name: "NotRecipient",
1301
+ inputs: []
1302
+ },
1303
+ {
1304
+ type: "error",
1305
+ name: "NothingToClaim",
1306
+ inputs: []
1307
+ },
1308
+ {
1309
+ type: "error",
1310
+ name: "SettlementIdConsumed",
1311
+ inputs: [{
1312
+ name: "settlementId",
1313
+ type: "bytes32",
1314
+ internalType: "bytes32"
1315
+ }]
1316
+ },
1317
+ {
1318
+ type: "error",
1319
+ name: "ZeroAddress",
1320
+ inputs: []
1321
+ },
1322
+ {
1323
+ type: "error",
1324
+ name: "ZeroAmount",
1325
+ inputs: []
1326
+ },
1327
+ {
1328
+ type: "error",
1329
+ name: "ZeroDocumentHash",
1330
+ inputs: []
1331
+ },
1332
+ {
1333
+ type: "error",
1334
+ name: "ZeroSettlementId",
1335
+ inputs: []
1336
+ }
1337
+ ];
1338
+ /** Immutable CapxulPaymentsV2 deployment on Base Sepolia. */
1339
+ const CAPXUL_PAYMENTS_V2_ADDRESS = "0xA3ACDD016f706eD432A9a0545C45F0943f996b60";
699
1340
  padHex(stringToHex("FM_DAILY"), {
700
1341
  size: 32,
701
1342
  dir: "right"
@@ -707,6 +1348,16 @@ padHex(concat([MULTI_SEND_CALL_ONLY, "0x8d80ff0a"]), {
707
1348
  dir: "right",
708
1349
  size: 32
709
1350
  });
1351
+ function paymentsV2Signature(name) {
1352
+ const item = CAPXUL_PAYMENTS_V2_ABI.find((candidate) => candidate.type === "function" && candidate.name === name);
1353
+ if (item === void 0) throw new Error(`CapxulPaymentsV2 ABI has no ${name} function`);
1354
+ return toFunctionSignature(item);
1355
+ }
1356
+ paymentsV2Signature("send");
1357
+ paymentsV2Signature("sendBatch");
1358
+ paymentsV2Signature("createCommitment");
1359
+ paymentsV2Signature("cancel");
1360
+ paymentsV2Signature("redirect");
710
1361
  new Map([
711
1362
  ["assignRoles(address,bytes32[],bool[])", "AssignRoles(address,bytes32[],bool[])"],
712
1363
  ["allowTarget(bytes32,address,uint8)", "AllowTarget(bytes32,address,uint8)"],
@@ -718,10 +1369,6 @@ new Map([
718
1369
  ["setAllowance(bytes32,uint128,uint128,uint128,uint64,uint64)", "SetAllowance(bytes32,uint128,uint128,uint128,uint64,uint64)"]
719
1370
  ].map(([functionSignature, eventSignature]) => [toFunctionSelector(functionSignature), toEventSelector(eventSignature)]));
720
1371
  //#endregion
721
- //#region ../config/src/capxul-payments-v2.ts
722
- /** Immutable CapxulPaymentsV2 deployment on Base Sepolia. */
723
- const CAPXUL_PAYMENTS_V2_ADDRESS = "0xA3ACDD016f706eD432A9a0545C45F0943f996b60";
724
- //#endregion
725
1372
  //#region src/telemetry/stack-frame-parser.ts
726
1373
  /**
727
1374
  * Regex for V8/Chrome stack trace frame lines.
@@ -3326,6 +3973,25 @@ const actorScopeContract = {
3326
3973
  inboxDecline: makeFunctionReference(CAPXUL_FUNCTIONS["financialOps/requestsInbox"].decline)
3327
3974
  };
3328
3975
  //#endregion
3976
+ //#region src/domain/money/from-wei.ts
3977
+ /**
3978
+ * Lift an on-chain integer (e.g. USDX 6-decimal) into consumer `Money`.
3979
+ * Canon `account-balance-model.md` §10 — internal at the SDK boundary only.
3980
+ */
3981
+ function fromWei(rawBalance, decimals, currency) {
3982
+ if (!Number.isInteger(decimals) || decimals < 0) throw new Error(`fromWei: decimals must be a non-negative integer, got ${String(decimals)}`);
3983
+ const normalized = rawBalance.trim();
3984
+ if (!/^\d+$/.test(normalized)) {
3985
+ const truncated = normalized.length > 80 ? `${normalized.slice(0, 80)}…` : normalized;
3986
+ throw new Error(`fromWei: rawBalance must be a base-10 integer string, got ${truncated}`);
3987
+ }
3988
+ return {
3989
+ currency: toCurrencyCode(currency),
3990
+ value: formatUnits(BigInt(normalized), decimals),
3991
+ decimals
3992
+ };
3993
+ }
3994
+ //#endregion
3329
3995
  //#region src/surface/contacts.ts
3330
3996
  function makeActorRelationshipMethods(deps) {
3331
3997
  const domain = deps.actor.kind === "account" ? "account" : "org";
@@ -3404,11 +4070,16 @@ function makeActorRelationshipMethods(deps) {
3404
4070
  },
3405
4071
  inbox: {
3406
4072
  list: (options) => mapOk$1(awaitableConvex(options?.signal, "inbox.list", () => convexCall.query(fns.inboxList, { actor })), (items) => items.map(mapInboxItem)),
3407
- approve: (input, options) => mapOk$1(awaitableConvex(options?.signal, "inbox.approve", () => convexCall.mutation(fns.inboxApprove, {
3408
- actor,
3409
- paymentRequestId: input.requestId,
3410
- ...input.timing === void 0 ? {} : { timing: input.timing }
3411
- })), mapApprovedInboxPayment),
4073
+ approve: async (input, options) => {
4074
+ const result = await awaitableConvex(options?.signal, "inbox.approve", () => convexCall.mutation(fns.inboxApprove, {
4075
+ actor,
4076
+ paymentRequestId: input.requestId,
4077
+ ...input.timing === void 0 ? {} : { timing: input.timing },
4078
+ ...input.permissionId === void 0 ? {} : { permissionId: input.permissionId }
4079
+ }));
4080
+ if (!result.ok) return result;
4081
+ return mapApprovedInboxPayment(result.value, input);
4082
+ },
3412
4083
  decline: (requestId, options) => mapOk$1(awaitableConvex(options?.signal, "inbox.decline", () => convexCall.mutation(fns.inboxDecline, {
3413
4084
  actor,
3414
4085
  paymentRequestId: requestId
@@ -3523,50 +4194,45 @@ function mapInboxItem(item) {
3523
4194
  status: mapInboxStatus(item.status)
3524
4195
  };
3525
4196
  }
3526
- function mapApprovedInboxPayment(item) {
3527
- if (item.settledPayment !== void 0) return normalizePaymentTiming$1(item.settledPayment);
3528
- const zero = {
3529
- ...item.amount,
3530
- value: "0"
3531
- };
3532
- const status = item.settledPaymentStatus ?? (item.status === "paid" ? "settled" : "pending");
3533
- const timing = item.settledPaymentTiming ?? { kind: "instant" };
3534
- return {
3535
- id: item.settledPaymentId ?? `payment_${item.id}`,
3536
- status,
3537
- amount: item.amount,
3538
- paymentType: "invoice",
3539
- recipient: paymentRecipientFromRef(item.issuer),
3540
- documents: [],
3541
- timing,
3542
- released: status === "settled" ? item.amount : zero,
3543
- availableToClaim: zero,
3544
- createdAt: item.createdAt ?? 0,
3545
- updatedAt: item.updatedAt ?? item.createdAt ?? 0
4197
+ function mapApprovedInboxPayment(command, input) {
4198
+ const item = command.items[0];
4199
+ if (item === void 0 || item.operation !== "send" && item.operation !== "create_commitment") return {
4200
+ ok: false,
4201
+ error: Errors.providerError("convex", "inbox.approve", "reply has no payment birth item")
3546
4202
  };
3547
- }
3548
- function paymentRecipientFromRef(ref) {
3549
- switch (ref.kind) {
3550
- case "handle": return {
3551
- kind: "handle",
3552
- label: ref.handle
3553
- };
3554
- case "email": return {
3555
- kind: "email",
3556
- label: ref.email
3557
- };
3558
- case "orgHandle": return {
3559
- kind: "org",
3560
- label: ref.orgHandle
4203
+ try {
4204
+ const amount = fromWei(item.operation === "send" ? item.rawAmount : item.totalAmount, 6, "USD");
4205
+ const zero = {
4206
+ ...amount,
4207
+ value: "0"
3561
4208
  };
3562
- case "capxulUserId": return {
3563
- kind: "capxulUserId",
3564
- label: ref.capxulUserId
4209
+ const timing = input.timing ?? { kind: "instant" };
4210
+ return {
4211
+ ok: true,
4212
+ value: {
4213
+ id: item.paymentId,
4214
+ status: timing.kind === "instant" ? "pending" : timing.kind === "scheduled" ? "scheduled" : "streaming",
4215
+ amount,
4216
+ paymentType: "invoice",
4217
+ recipient: {
4218
+ kind: "external_address",
4219
+ label: item.recipientSafe
4220
+ },
4221
+ documents: [{
4222
+ documentHash: item.documentHash,
4223
+ kind: "invoice"
4224
+ }],
4225
+ timing,
4226
+ released: zero,
4227
+ availableToClaim: zero,
4228
+ createdAt: 0,
4229
+ updatedAt: 0
4230
+ }
3565
4231
  };
3566
- case "payeeId": return {
3567
- kind: "payee",
3568
- label: ref.payeeId,
3569
- payeeId: ref.payeeId
4232
+ } catch (cause) {
4233
+ return {
4234
+ ok: false,
4235
+ error: Errors.providerError("convex", "inbox.approve", cause)
3570
4236
  };
3571
4237
  }
3572
4238
  }
@@ -3594,13 +4260,6 @@ function mapInboxStatus(status) {
3594
4260
  default: return "open";
3595
4261
  }
3596
4262
  }
3597
- function normalizePaymentTiming$1(payment) {
3598
- const { release: _release, ...rest } = payment;
3599
- return {
3600
- ...rest,
3601
- timing: payment.timing ?? payment.release ?? { kind: "instant" }
3602
- };
3603
- }
3604
4263
  function normalizeRefForBackend$1(ref, field) {
3605
4264
  try {
3606
4265
  if (typeof ref === "string") throw Errors.invalidInput(field, "recipient must be a typed Ref variant");
@@ -3946,7 +4605,7 @@ function makeAccountMethods(deps) {
3946
4605
  }
3947
4606
  //#endregion
3948
4607
  //#region package.json
3949
- var version = "2.0.0";
4608
+ var version = "2.0.1";
3950
4609
  //#endregion
3951
4610
  //#region src/ports/auth-client.ts
3952
4611
  var AuthClientError = class extends Data.TaggedError("AuthClientError") {};
@@ -4072,25 +4731,6 @@ function accountReadErrorFromCapxul(operation, error, cause = error) {
4072
4731
  }
4073
4732
  var AccountReadPortTag = class extends Context.Service()("@capxul/sdk/ports/AccountReadPort") {};
4074
4733
  //#endregion
4075
- //#region src/domain/money/from-wei.ts
4076
- /**
4077
- * Lift an on-chain integer (e.g. USDX 6-decimal) into consumer `Money`.
4078
- * Canon `account-balance-model.md` §10 — internal at the SDK boundary only.
4079
- */
4080
- function fromWei(rawBalance, decimals, currency) {
4081
- if (!Number.isInteger(decimals) || decimals < 0) throw new Error(`fromWei: decimals must be a non-negative integer, got ${String(decimals)}`);
4082
- const normalized = rawBalance.trim();
4083
- if (!/^\d+$/.test(normalized)) {
4084
- const truncated = normalized.length > 80 ? `${normalized.slice(0, 80)}…` : normalized;
4085
- throw new Error(`fromWei: rawBalance must be a base-10 integer string, got ${truncated}`);
4086
- }
4087
- return {
4088
- currency: toCurrencyCode(currency),
4089
- value: formatUnits(BigInt(normalized), decimals),
4090
- decimals
4091
- };
4092
- }
4093
- //#endregion
4094
4734
  //#region src/ports/smart-account.ts
4095
4735
  var SmartAccountError = class extends Data.TaggedError("SmartAccountError") {};
4096
4736
  function smartAccountErrorFromCapxul(operation, error, cause = error) {
@@ -7992,4 +8632,4 @@ function withHostObservation(actor, snapshot) {
7992
8632
  };
7993
8633
  }
7994
8634
  //#endregion
7995
- export { encodeObservationContextHeader as A, captureExceptionSync as B, ClockPortTag as C, AuthClientPortTag as D, authClientPortFromPromiseAdapter as E, isSettingUpLifecycle as F, destination as G, normalizeBindingEmail as H, formatTraceparent as I, copyInvocationObservation as L, CAPXUL_FUNCTIONS as M, BootstrapEnvelope as N, version as O, EngineeringTelemetryBootstrapPolicy as P, readInvocationObservation as R, ClockError as S, bootstrapErrorFromCapxul as T, BASE_SEPOLIA_CHAIN_ID as U, CAPXUL_PAYMENTS_V2_ADDRESS as V, deriveCapxulSafeAddress as W, wireChainId as _, observeFailedResult as a, ConvexCallPortTag as b, PostHogTelemetryLayer as c, SmartAccountPortTag as d, smartAccountErrorFromCapxul as f, toWei as g, accountReadErrorFromCapxul as h, observationContextProps as i, sanitizeObservationContext as j, OBSERVATION_CONTEXT_HEADER as k, TelemetryPortTag as l, AccountReadPortTag as m, postHogProductTelemetry as n, postHogFailureObservation as o, fromWei as p, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT as r, detectAuthCacheAdapter as s, assembleCapxulClient as t, redactTelemetryEvent as u, IdentityPortTag as v, BootstrapPortTag as w, convexCallErrorFromCapxul as x, identityErrorFromCapxul as y, captureException as z };
8635
+ export { encodeObservationContextHeader as A, captureExceptionSync as B, BootstrapPortTag as C, version as D, AuthClientPortTag as E, isSettingUpLifecycle as F, destination as G, normalizeBindingEmail as H, formatTraceparent as I, copyInvocationObservation as L, CAPXUL_FUNCTIONS as M, BootstrapEnvelope as N, fromWei as O, EngineeringTelemetryBootstrapPolicy as P, readInvocationObservation as R, ClockPortTag as S, authClientPortFromPromiseAdapter as T, BASE_SEPOLIA_CHAIN_ID as U, CAPXUL_PAYMENTS_V2_ADDRESS as V, deriveCapxulSafeAddress as W, IdentityPortTag as _, observeFailedResult as a, convexCallErrorFromCapxul as b, PostHogTelemetryLayer as c, SmartAccountPortTag as d, smartAccountErrorFromCapxul as f, wireChainId as g, toWei as h, observationContextProps as i, sanitizeObservationContext as j, OBSERVATION_CONTEXT_HEADER as k, TelemetryPortTag as l, accountReadErrorFromCapxul as m, postHogProductTelemetry as n, postHogFailureObservation as o, AccountReadPortTag as p, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT as r, detectAuthCacheAdapter as s, assembleCapxulClient as t, redactTelemetryEvent as u, identityErrorFromCapxul as v, bootstrapErrorFromCapxul as w, ClockError as x, ConvexCallPortTag as y, captureException as z };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { $ as CapxulErrorDetails, A as CountryCode, D as AuthUserId, E as AuthSession, I as Money, Q as CapxulErrorCode, R as OrgId, W as RoleKey, X as toCountryCode, Y as toAddress, Z as CapxulError, a as AccountProvider, b as AccountId, c as Eip1193Provider, d as CapxulResult, f as Profile, i as injectedWalletSigner, l as eip1193AccountProvider, m as SmartAccount, n as CapxulSigner, nt as isCapxulError, o as AccountProviderSource, p as Session, r as Eip1193RequestProvider, s as AccountRequirement, t as CapxulDigestSigner, tt as FailureMode, u as localPrivateKeyAccountProvider, x as Address, y as Account } from "./signer-ZijoFiUs.mjs";
2
- import { $ as InboxMethods, $t as WireObservationContext, A as OrganizationPaymentsMethods, At as PaymentDocumentRender, B as AccountMethods, Bt as RecipientResolutionKind, C as ResendInviteTokenInput, Ct as OfframpQuoteInput, D as OrganizationPaymentBatchInput, Dt as Payment, E as RoleView, Et as PayeesMethods, F as PermissionOptions, Ft as PaymentTiming, G as ActorRequestIssueInput, Gt as AccountLifecycle, H as ActorProfileMethods, Ht as ResolvedTarget, I as PermissionReplaceInput, It as PaymentType, J as AddressBookEntry, Jt as IdentityMethods, K as ActorRequestsMethods, Kt as AccountSetupStep, L as PermissionRevokeInput, Lt as PaymentsMethods, M as PermissionChangeInput, Mt as PaymentDocumentsMethods, N as PermissionCreateInput, Nt as PaymentMoney, O as OrganizationPaymentInput, Ot as PaymentDocumentKind, P as PermissionMethods, Pt as PaymentStatus, Q as InboxItem, Qt as OrgSetupStep, R as PermissionReadResult, Rt as PaymentsPayInput, S as OrganizationAuditLogItem, St as OfframpQuote, T as RoleSpendCap, Tt as Payee, U as ActorRelationshipMethods, Ut as TargetReference, V as ActorProfile, Vt as Ref, W as ActorRequest, Wt as TargetsMethods, X as AddressBookMethods, Xt as AuthMethods, Y as AddressBookLabelInput, Yt as SmartAccountMethods, Z as InboxApproveInput, Zt as OrgLifecycle, _ as OrgMethods, _n as IdentityTransition, _t as FinancialOpsMethods, a as IdentityRuntimeSendResult, at as ActivityPage, b as OrgView, bt as MeProfile, c as SystemHealth, cn as TelemetryPort, ct as DepositInstructions, d as CurrentUserMethods, dn as IdentityEvent, dt as DestinationKind, en as CurrentHoldings, et as ActivityAnnotationInput, f as CreateOrgInput, fn as IdentityState, ft as DestinationListInput, g as MemberView, gn as destination, gt as DestinationsMethods, h as MemberStatus, hn as StateLabel, ht as DestinationRemoveInput, i as IdentityRuntime, in as CapxulEnv, it as ActivityMethods, j as PermissionAssignInput, jt as PaymentDocumentVerification, k as OrganizationPaymentItemInput, kt as PaymentDocumentRef, l as MediaMethods, ln as CAPXUL_PAYMENTS_V2_ADDRESS, lt as Destination, m as InviteMemberInput, mn as Readiness, mt as DestinationRail, n as CreateCapxulClientInput, nn as Permission, nt as ActivityItem, o as HoldingsMethods, ot as ActivityReference, p as DetectPendingOrgInvitationsResult, pn as OrgLane, pt as DestinationPayload, q as AddressBookAddInput, qt as isSettingUpLifecycle, r as IdentityProfileDetails, rn as SubmittedPermissionExecution, rt as ActivityListParams, s as SystemMethods, st as ActorReference, t as CapxulClient, tn as MovementAnnotation, tt as ActivityDetail, u as CurrentUserContext, un as Destination$1, ut as DestinationAddInput, v as OrgScopedMethods, vn as InvocationControls, vt as HandlesMethods, w as RoleDefinition, wt as OfframpStatus, x as OrganizationAccount, xt as OfframpMethods, y as OrgTemplate, yt as MeMethods, z as AccountsMethods, zt as RecipientResolution } from "./create-capxul-client-klbklLYW.mjs";
2
+ import { $ as InboxMethods, $t as WireObservationContext, A as OrganizationPaymentsMethods, At as PaymentDocumentRender, B as AccountMethods, Bt as RecipientResolutionKind, C as ResendInviteTokenInput, Ct as OfframpQuoteInput, D as OrganizationPaymentBatchInput, Dt as Payment, E as RoleView, Et as PayeesMethods, F as PermissionOptions, Ft as PaymentTiming, G as ActorRequestIssueInput, Gt as AccountLifecycle, H as ActorProfileMethods, Ht as ResolvedTarget, I as PermissionReplaceInput, It as PaymentType, J as AddressBookEntry, Jt as IdentityMethods, K as ActorRequestsMethods, Kt as AccountSetupStep, L as PermissionRevokeInput, Lt as PaymentsMethods, M as PermissionChangeInput, Mt as PaymentDocumentsMethods, N as PermissionCreateInput, Nt as PaymentMoney, O as OrganizationPaymentInput, Ot as PaymentDocumentKind, P as PermissionMethods, Pt as PaymentStatus, Q as InboxItem, Qt as OrgSetupStep, R as PermissionReadResult, Rt as PaymentsPayInput, S as OrganizationAuditLogItem, St as OfframpQuote, T as RoleSpendCap, Tt as Payee, U as ActorRelationshipMethods, Ut as TargetReference, V as ActorProfile, Vt as Ref, W as ActorRequest, Wt as TargetsMethods, X as AddressBookMethods, Xt as AuthMethods, Y as AddressBookLabelInput, Yt as SmartAccountMethods, Z as InboxApproveInput, Zt as OrgLifecycle, _ as OrgMethods, _n as IdentityTransition, _t as FinancialOpsMethods, a as IdentityRuntimeSendResult, at as ActivityPage, b as OrgView, bt as MeProfile, c as SystemHealth, cn as TelemetryPort, ct as DepositInstructions, d as CurrentUserMethods, dn as IdentityEvent, dt as DestinationKind, en as CurrentHoldings, et as ActivityAnnotationInput, f as CreateOrgInput, fn as IdentityState, ft as DestinationListInput, g as MemberView, gn as destination, gt as DestinationsMethods, h as MemberStatus, hn as StateLabel, ht as DestinationRemoveInput, i as IdentityRuntime, in as CapxulEnv, it as ActivityMethods, j as PermissionAssignInput, jt as PaymentDocumentVerification, k as OrganizationPaymentItemInput, kt as PaymentDocumentRef, l as MediaMethods, ln as CAPXUL_PAYMENTS_V2_ADDRESS, lt as Destination, m as InviteMemberInput, mn as Readiness, mt as DestinationRail, n as CreateCapxulClientInput, nn as Permission, nt as ActivityItem, o as HoldingsMethods, ot as ActivityReference, p as DetectPendingOrgInvitationsResult, pn as OrgLane, pt as DestinationPayload, q as AddressBookAddInput, qt as isSettingUpLifecycle, r as IdentityProfileDetails, rn as SubmittedPermissionExecution, rt as ActivityListParams, s as SystemMethods, st as ActorReference, t as CapxulClient, tn as MovementAnnotation, tt as ActivityDetail, u as CurrentUserContext, un as Destination$1, ut as DestinationAddInput, v as OrgScopedMethods, vn as InvocationControls, vt as HandlesMethods, w as RoleDefinition, wt as OfframpStatus, x as OrganizationAccount, xt as OfframpMethods, y as OrgTemplate, yt as MeMethods, z as AccountsMethods, zt as RecipientResolution } from "./create-capxul-client-BklYjuYQ.mjs";
3
3
  import { Hex } from "viem";
4
4
  import { Context, Effect, Layer } from "effect";
5
5
  import { FunctionReference } from "convex/server";
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as encodeObservationContextHeader, B as captureExceptionSync, C as ClockPortTag, D as AuthClientPortTag, E as authClientPortFromPromiseAdapter, F as isSettingUpLifecycle, G as destination, H as normalizeBindingEmail, I as formatTraceparent, L as copyInvocationObservation, M as CAPXUL_FUNCTIONS, N as BootstrapEnvelope, O as version, P as EngineeringTelemetryBootstrapPolicy, R as readInvocationObservation, S as ClockError, T as bootstrapErrorFromCapxul, U as BASE_SEPOLIA_CHAIN_ID, V as CAPXUL_PAYMENTS_V2_ADDRESS, _ as wireChainId, a as observeFailedResult, b as ConvexCallPortTag, c as PostHogTelemetryLayer, d as SmartAccountPortTag, f as smartAccountErrorFromCapxul, g as toWei, h as accountReadErrorFromCapxul, i as observationContextProps, j as sanitizeObservationContext, k as OBSERVATION_CONTEXT_HEADER, l as TelemetryPortTag, m as AccountReadPortTag, n as postHogProductTelemetry, o as postHogFailureObservation, p as fromWei, r as CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, s as detectAuthCacheAdapter, t as assembleCapxulClient, v as IdentityPortTag, w as BootstrapPortTag, x as convexCallErrorFromCapxul, y as identityErrorFromCapxul, z as captureException } from "./create-capxul-client-N36cHqE2.mjs";
1
+ import { A as encodeObservationContextHeader, B as captureExceptionSync, C as BootstrapPortTag, D as version, E as AuthClientPortTag, F as isSettingUpLifecycle, G as destination, H as normalizeBindingEmail, I as formatTraceparent, L as copyInvocationObservation, M as CAPXUL_FUNCTIONS, N as BootstrapEnvelope, O as fromWei, P as EngineeringTelemetryBootstrapPolicy, R as readInvocationObservation, S as ClockPortTag, T as authClientPortFromPromiseAdapter, U as BASE_SEPOLIA_CHAIN_ID, V as CAPXUL_PAYMENTS_V2_ADDRESS, _ as IdentityPortTag, a as observeFailedResult, b as convexCallErrorFromCapxul, c as PostHogTelemetryLayer, d as SmartAccountPortTag, f as smartAccountErrorFromCapxul, g as wireChainId, h as toWei, i as observationContextProps, j as sanitizeObservationContext, k as OBSERVATION_CONTEXT_HEADER, l as TelemetryPortTag, m as accountReadErrorFromCapxul, n as postHogProductTelemetry, o as postHogFailureObservation, p as AccountReadPortTag, r as CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, s as detectAuthCacheAdapter, t as assembleCapxulClient, v as identityErrorFromCapxul, w as bootstrapErrorFromCapxul, x as ClockError, y as ConvexCallPortTag, z as captureException } from "./create-capxul-client-oqLlUkzI.mjs";
2
2
  import { A as toSessionToken, C as toEpochMs, D as toOrgId, E as toKycTier, F as isCapxulError, M as CapxulError, O as toPublishableKey, P as Errors, S as toEmail, T as toJwtToken, _ as toAuthUserId, b as toCurrencyCode, h as toAllowedOrigin, j as decodeConvexError, k as toRoleKey, m as toAddress, o as AuthCachePortTag, p as toAccountId, v as toChainId, w as toEpochSeconds, x as toDurationMs, y as toCountryCode } from "./InMemoryAuthCacheAdapter-Rc8tCtml.mjs";
3
3
  import { keccak256, recoverAddress, stringToHex } from "viem";
4
4
  import { Cause, Context, Data, Effect, Exit, Layer, Result, SchemaIssue, SchemaParser, Scope, Tracer } from "effect";
@@ -1,4 +1,4 @@
1
- import { _n as IdentityTransition, an as TelemetryEvent, on as TelemetryGroupInput, sn as TelemetryIdentifyInput, t as CapxulClient } from "../create-capxul-client-klbklLYW.mjs";
1
+ import { _n as IdentityTransition, an as TelemetryEvent, on as TelemetryGroupInput, sn as TelemetryIdentifyInput, t as CapxulClient } from "../create-capxul-client-BklYjuYQ.mjs";
2
2
  import { Effect, Layer } from "effect";
3
3
 
4
4
  //#region src/testing/telemetry/RecordingTelemetryAdapter.d.ts
@@ -1,4 +1,4 @@
1
- import { E as authClientPortFromPromiseAdapter, T as bootstrapErrorFromCapxul, W as deriveCapxulSafeAddress, _ as wireChainId, f as smartAccountErrorFromCapxul, g as toWei, h as accountReadErrorFromCapxul, p as fromWei, t as assembleCapxulClient, u as redactTelemetryEvent, x as convexCallErrorFromCapxul, y as identityErrorFromCapxul } from "../create-capxul-client-N36cHqE2.mjs";
1
+ import { O as fromWei, T as authClientPortFromPromiseAdapter, W as deriveCapxulSafeAddress, b as convexCallErrorFromCapxul, f as smartAccountErrorFromCapxul, g as wireChainId, h as toWei, m as accountReadErrorFromCapxul, t as assembleCapxulClient, u as redactTelemetryEvent, v as identityErrorFromCapxul, w as bootstrapErrorFromCapxul } from "../create-capxul-client-oqLlUkzI.mjs";
2
2
  import { A as toSessionToken, C as toEpochMs, E as toKycTier, M as CapxulError, O as toPublishableKey, P as Errors, S as toEmail, T as toJwtToken, _ as toAuthUserId, g as toAppId, h as toAllowedOrigin, m as toAddress, p as toAccountId, t as InMemoryAuthCacheAdapter, v as toChainId, w as toEpochSeconds, x as toDurationMs, y as toCountryCode } from "../InMemoryAuthCacheAdapter-Rc8tCtml.mjs";
3
3
  import { keccak256 } from "viem";
4
4
  import { Effect, Result, Semaphore } from "effect";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/sdk",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Xelmar-tech/infrastructure.git",
@@ -49,7 +49,7 @@
49
49
  "@capxul/config": "0.1.1",
50
50
  "@capxul/errors": "0.0.1",
51
51
  "@capxul/typescript-config": "0.0.0",
52
- "@capxul/observability": "2.0.0",
52
+ "@capxul/observability": "2.0.1",
53
53
  "@capxul/wire": "0.1.0",
54
54
  "@capxul/types": "0.1.0"
55
55
  },