@capxul/sdk 0.1.0-alpha.2 → 0.1.0-alpha.4
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.
- package/CHANGELOG.md +48 -0
- package/dist/{client-D-0KTn8D.d.cts → client-CXRKtbfn.d.cts} +177 -72
- package/dist/{client-CweJSkaY.d.ts → client-CcCtq5XO.d.ts} +177 -72
- package/dist/client.cjs +191 -3
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +191 -3
- package/dist/index.cjs +202 -3
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +201 -4
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -72,9 +72,79 @@ function fromConvexError(error) {
|
|
|
72
72
|
// src/core/accounts.ts
|
|
73
73
|
function createAccountsClient(config = {}) {
|
|
74
74
|
return {
|
|
75
|
-
retrieve: async () =>
|
|
75
|
+
retrieve: async (accountId) => {
|
|
76
|
+
if (!config.data) {
|
|
77
|
+
return stub("accounts.retrieve");
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const account = await config.data.query(
|
|
81
|
+
api.openfort.queries.getMyAccount,
|
|
82
|
+
{}
|
|
83
|
+
);
|
|
84
|
+
if (account.id !== accountId) {
|
|
85
|
+
return [
|
|
86
|
+
new CapxulError({
|
|
87
|
+
code: "PERMISSION_DENIED",
|
|
88
|
+
message: "accounts.retrieve currently supports the authenticated caller's own account only.",
|
|
89
|
+
details: {
|
|
90
|
+
requestedAccountId: accountId,
|
|
91
|
+
authenticatedAccountId: account.id
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
null
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
return [null, account];
|
|
98
|
+
} catch (cause) {
|
|
99
|
+
return [fromConvexError(cause), null];
|
|
100
|
+
}
|
|
101
|
+
},
|
|
76
102
|
lookup: async () => stub("accounts.lookup"),
|
|
77
|
-
update: async () =>
|
|
103
|
+
update: async (input) => {
|
|
104
|
+
if (!config.data) {
|
|
105
|
+
return stub("accounts.update");
|
|
106
|
+
}
|
|
107
|
+
if (input.countryCode !== void 0) {
|
|
108
|
+
return [
|
|
109
|
+
new CapxulError({
|
|
110
|
+
code: "INVALID_INPUT",
|
|
111
|
+
message: "accounts.update does not support countryCode yet \u2014 backend mutation only patches displayName and username.",
|
|
112
|
+
details: { field: "countryCode" }
|
|
113
|
+
}),
|
|
114
|
+
null
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const current = await config.data.query(
|
|
119
|
+
api.openfort.queries.getMyAccount,
|
|
120
|
+
{}
|
|
121
|
+
);
|
|
122
|
+
if (current.id !== input.accountId) {
|
|
123
|
+
return [
|
|
124
|
+
new CapxulError({
|
|
125
|
+
code: "PERMISSION_DENIED",
|
|
126
|
+
message: "accounts.update currently supports the authenticated caller's own account only.",
|
|
127
|
+
details: {
|
|
128
|
+
requestedAccountId: input.accountId,
|
|
129
|
+
authenticatedAccountId: current.id
|
|
130
|
+
}
|
|
131
|
+
}),
|
|
132
|
+
null
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
await config.data.mutation(api.openfort.mutations.updateProfile, {
|
|
136
|
+
displayName: input.name,
|
|
137
|
+
username: input.username
|
|
138
|
+
});
|
|
139
|
+
const updated = await config.data.query(
|
|
140
|
+
api.openfort.queries.getMyAccount,
|
|
141
|
+
{}
|
|
142
|
+
);
|
|
143
|
+
return [null, updated];
|
|
144
|
+
} catch (cause) {
|
|
145
|
+
return [fromConvexError(cause), null];
|
|
146
|
+
}
|
|
147
|
+
},
|
|
78
148
|
provisionPersonal: async (input) => {
|
|
79
149
|
if (!config.data) {
|
|
80
150
|
return stub(
|
|
@@ -697,7 +767,34 @@ function createMeClient(config = {}) {
|
|
|
697
767
|
return [fromConvexError(cause), null];
|
|
698
768
|
}
|
|
699
769
|
},
|
|
700
|
-
update: async () =>
|
|
770
|
+
update: async (input) => {
|
|
771
|
+
if (!config.data) {
|
|
772
|
+
return stub("me.update");
|
|
773
|
+
}
|
|
774
|
+
if (input.countryCode !== void 0) {
|
|
775
|
+
return [
|
|
776
|
+
new CapxulError({
|
|
777
|
+
code: "INVALID_INPUT",
|
|
778
|
+
message: "me.update does not support countryCode yet \u2014 backend mutation only patches displayName and username.",
|
|
779
|
+
details: { field: "countryCode" }
|
|
780
|
+
}),
|
|
781
|
+
null
|
|
782
|
+
];
|
|
783
|
+
}
|
|
784
|
+
try {
|
|
785
|
+
await config.data.mutation(api.openfort.mutations.updateProfile, {
|
|
786
|
+
displayName: input.name,
|
|
787
|
+
username: input.username
|
|
788
|
+
});
|
|
789
|
+
const account = await config.data.query(
|
|
790
|
+
api.openfort.queries.getMyAccount,
|
|
791
|
+
{}
|
|
792
|
+
);
|
|
793
|
+
return [null, account];
|
|
794
|
+
} catch (cause) {
|
|
795
|
+
return [fromConvexError(cause), null];
|
|
796
|
+
}
|
|
797
|
+
}
|
|
701
798
|
};
|
|
702
799
|
}
|
|
703
800
|
|
|
@@ -1506,6 +1603,96 @@ function createSubAccountsClient() {
|
|
|
1506
1603
|
};
|
|
1507
1604
|
}
|
|
1508
1605
|
|
|
1606
|
+
// src/core/token-transfers.ts
|
|
1607
|
+
var toTokenTransferId = (raw) => {
|
|
1608
|
+
if (typeof raw !== "string" || raw.length === 0) {
|
|
1609
|
+
throw new Error(
|
|
1610
|
+
`Invalid tokenTransferId: expected non-empty string, got ${String(raw)}`
|
|
1611
|
+
);
|
|
1612
|
+
}
|
|
1613
|
+
return raw;
|
|
1614
|
+
};
|
|
1615
|
+
function brandRow(row) {
|
|
1616
|
+
return {
|
|
1617
|
+
...row,
|
|
1618
|
+
id: toTokenTransferId(row.id)
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
function createTokenTransfersClient(config = {}) {
|
|
1622
|
+
return {
|
|
1623
|
+
list: async (input) => {
|
|
1624
|
+
if (!config.data) {
|
|
1625
|
+
return stub("tokenTransfers.list");
|
|
1626
|
+
}
|
|
1627
|
+
try {
|
|
1628
|
+
const raw = await config.data.query(
|
|
1629
|
+
api.tokenTransfers.queries.list,
|
|
1630
|
+
{
|
|
1631
|
+
limit: input?.limit,
|
|
1632
|
+
cursor: input?.cursor,
|
|
1633
|
+
direction: input?.direction
|
|
1634
|
+
}
|
|
1635
|
+
);
|
|
1636
|
+
if (!raw) {
|
|
1637
|
+
return [
|
|
1638
|
+
new CapxulError({
|
|
1639
|
+
code: "NOT_AUTHENTICATED",
|
|
1640
|
+
message: "tokenTransfers.list requires an authenticated session."
|
|
1641
|
+
}),
|
|
1642
|
+
null
|
|
1643
|
+
];
|
|
1644
|
+
}
|
|
1645
|
+
return [
|
|
1646
|
+
null,
|
|
1647
|
+
{
|
|
1648
|
+
object: "list",
|
|
1649
|
+
data: raw.items.map(brandRow),
|
|
1650
|
+
page: {
|
|
1651
|
+
hasMore: raw.hasMore,
|
|
1652
|
+
nextCursor: raw.nextCursor
|
|
1653
|
+
},
|
|
1654
|
+
displayCurrency: raw.displayCurrency
|
|
1655
|
+
}
|
|
1656
|
+
];
|
|
1657
|
+
} catch (cause) {
|
|
1658
|
+
return [fromConvexError(cause), null];
|
|
1659
|
+
}
|
|
1660
|
+
},
|
|
1661
|
+
retrieve: async (input) => {
|
|
1662
|
+
if (!config.data) {
|
|
1663
|
+
return stub("tokenTransfers.retrieve");
|
|
1664
|
+
}
|
|
1665
|
+
try {
|
|
1666
|
+
const raw = await config.data.query(
|
|
1667
|
+
api.tokenTransfers.queries.getByTxLogIndex,
|
|
1668
|
+
{
|
|
1669
|
+
txHash: input.txHash,
|
|
1670
|
+
logIndex: input.logIndex,
|
|
1671
|
+
chainId: input.chainId
|
|
1672
|
+
}
|
|
1673
|
+
);
|
|
1674
|
+
if (!raw) {
|
|
1675
|
+
return [
|
|
1676
|
+
new CapxulError({
|
|
1677
|
+
code: "NOT_FOUND",
|
|
1678
|
+
message: `tokenTransfer (txHash=${input.txHash}, logIndex=${input.logIndex}) not found or not visible to caller.`,
|
|
1679
|
+
details: {
|
|
1680
|
+
txHash: input.txHash,
|
|
1681
|
+
logIndex: input.logIndex,
|
|
1682
|
+
chainId: input.chainId
|
|
1683
|
+
}
|
|
1684
|
+
}),
|
|
1685
|
+
null
|
|
1686
|
+
];
|
|
1687
|
+
}
|
|
1688
|
+
return [null, brandRow(raw)];
|
|
1689
|
+
} catch (cause) {
|
|
1690
|
+
return [fromConvexError(cause), null];
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
};
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1509
1696
|
// src/core/virtual-accounts.ts
|
|
1510
1697
|
function createVirtualAccountsClient() {
|
|
1511
1698
|
return {
|
|
@@ -2249,6 +2436,7 @@ function createCapxulClient(config = {}) {
|
|
|
2249
2436
|
organizations: createOrganizationsClient(config),
|
|
2250
2437
|
payments: createPaymentsClient(config),
|
|
2251
2438
|
transfers: createTransfersClient(),
|
|
2439
|
+
tokenTransfers: createTokenTransfersClient(config),
|
|
2252
2440
|
withdrawals: createWithdrawalsClient(config),
|
|
2253
2441
|
documents: createDocumentsClient(),
|
|
2254
2442
|
subAccounts: createSubAccountsClient(),
|
package/dist/client.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'viem';
|
|
2
2
|
import 'xstate';
|
|
3
|
-
export { f as CapxulAuthConfig, C as CapxulClient, g as CapxulConfig, h as CapxulDataClient, i as CapxulFlowFactories, j as CapxulSigningConfig,
|
|
3
|
+
export { f as CapxulAuthConfig, C as CapxulClient, g as CapxulConfig, h as CapxulDataClient, i as CapxulFlowFactories, j as CapxulSigningConfig, K as createCapxulClient } from './client-CXRKtbfn.cjs';
|
|
4
4
|
import './next-action-DkrwXYay.cjs';
|
|
5
5
|
import './errors-GgKrSUKp.cjs';
|
|
6
6
|
import './types-DVWojoy4.cjs';
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'viem';
|
|
2
2
|
import 'xstate';
|
|
3
|
-
export { f as CapxulAuthConfig, C as CapxulClient, g as CapxulConfig, h as CapxulDataClient, i as CapxulFlowFactories, j as CapxulSigningConfig,
|
|
3
|
+
export { f as CapxulAuthConfig, C as CapxulClient, g as CapxulConfig, h as CapxulDataClient, i as CapxulFlowFactories, j as CapxulSigningConfig, K as createCapxulClient } from './client-CcCtq5XO.js';
|
|
4
4
|
import './next-action-DkrwXYay.js';
|
|
5
5
|
import './errors-QHD5Tlok.js';
|
|
6
6
|
import './types-75UokagF.js';
|
package/dist/client.js
CHANGED
|
@@ -70,9 +70,79 @@ function fromConvexError(error) {
|
|
|
70
70
|
// src/core/accounts.ts
|
|
71
71
|
function createAccountsClient(config = {}) {
|
|
72
72
|
return {
|
|
73
|
-
retrieve: async () =>
|
|
73
|
+
retrieve: async (accountId) => {
|
|
74
|
+
if (!config.data) {
|
|
75
|
+
return stub("accounts.retrieve");
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const account = await config.data.query(
|
|
79
|
+
api.openfort.queries.getMyAccount,
|
|
80
|
+
{}
|
|
81
|
+
);
|
|
82
|
+
if (account.id !== accountId) {
|
|
83
|
+
return [
|
|
84
|
+
new CapxulError({
|
|
85
|
+
code: "PERMISSION_DENIED",
|
|
86
|
+
message: "accounts.retrieve currently supports the authenticated caller's own account only.",
|
|
87
|
+
details: {
|
|
88
|
+
requestedAccountId: accountId,
|
|
89
|
+
authenticatedAccountId: account.id
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
null
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
return [null, account];
|
|
96
|
+
} catch (cause) {
|
|
97
|
+
return [fromConvexError(cause), null];
|
|
98
|
+
}
|
|
99
|
+
},
|
|
74
100
|
lookup: async () => stub("accounts.lookup"),
|
|
75
|
-
update: async () =>
|
|
101
|
+
update: async (input) => {
|
|
102
|
+
if (!config.data) {
|
|
103
|
+
return stub("accounts.update");
|
|
104
|
+
}
|
|
105
|
+
if (input.countryCode !== void 0) {
|
|
106
|
+
return [
|
|
107
|
+
new CapxulError({
|
|
108
|
+
code: "INVALID_INPUT",
|
|
109
|
+
message: "accounts.update does not support countryCode yet \u2014 backend mutation only patches displayName and username.",
|
|
110
|
+
details: { field: "countryCode" }
|
|
111
|
+
}),
|
|
112
|
+
null
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
const current = await config.data.query(
|
|
117
|
+
api.openfort.queries.getMyAccount,
|
|
118
|
+
{}
|
|
119
|
+
);
|
|
120
|
+
if (current.id !== input.accountId) {
|
|
121
|
+
return [
|
|
122
|
+
new CapxulError({
|
|
123
|
+
code: "PERMISSION_DENIED",
|
|
124
|
+
message: "accounts.update currently supports the authenticated caller's own account only.",
|
|
125
|
+
details: {
|
|
126
|
+
requestedAccountId: input.accountId,
|
|
127
|
+
authenticatedAccountId: current.id
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
130
|
+
null
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
await config.data.mutation(api.openfort.mutations.updateProfile, {
|
|
134
|
+
displayName: input.name,
|
|
135
|
+
username: input.username
|
|
136
|
+
});
|
|
137
|
+
const updated = await config.data.query(
|
|
138
|
+
api.openfort.queries.getMyAccount,
|
|
139
|
+
{}
|
|
140
|
+
);
|
|
141
|
+
return [null, updated];
|
|
142
|
+
} catch (cause) {
|
|
143
|
+
return [fromConvexError(cause), null];
|
|
144
|
+
}
|
|
145
|
+
},
|
|
76
146
|
provisionPersonal: async (input) => {
|
|
77
147
|
if (!config.data) {
|
|
78
148
|
return stub(
|
|
@@ -695,7 +765,34 @@ function createMeClient(config = {}) {
|
|
|
695
765
|
return [fromConvexError(cause), null];
|
|
696
766
|
}
|
|
697
767
|
},
|
|
698
|
-
update: async () =>
|
|
768
|
+
update: async (input) => {
|
|
769
|
+
if (!config.data) {
|
|
770
|
+
return stub("me.update");
|
|
771
|
+
}
|
|
772
|
+
if (input.countryCode !== void 0) {
|
|
773
|
+
return [
|
|
774
|
+
new CapxulError({
|
|
775
|
+
code: "INVALID_INPUT",
|
|
776
|
+
message: "me.update does not support countryCode yet \u2014 backend mutation only patches displayName and username.",
|
|
777
|
+
details: { field: "countryCode" }
|
|
778
|
+
}),
|
|
779
|
+
null
|
|
780
|
+
];
|
|
781
|
+
}
|
|
782
|
+
try {
|
|
783
|
+
await config.data.mutation(api.openfort.mutations.updateProfile, {
|
|
784
|
+
displayName: input.name,
|
|
785
|
+
username: input.username
|
|
786
|
+
});
|
|
787
|
+
const account = await config.data.query(
|
|
788
|
+
api.openfort.queries.getMyAccount,
|
|
789
|
+
{}
|
|
790
|
+
);
|
|
791
|
+
return [null, account];
|
|
792
|
+
} catch (cause) {
|
|
793
|
+
return [fromConvexError(cause), null];
|
|
794
|
+
}
|
|
795
|
+
}
|
|
699
796
|
};
|
|
700
797
|
}
|
|
701
798
|
|
|
@@ -1504,6 +1601,96 @@ function createSubAccountsClient() {
|
|
|
1504
1601
|
};
|
|
1505
1602
|
}
|
|
1506
1603
|
|
|
1604
|
+
// src/core/token-transfers.ts
|
|
1605
|
+
var toTokenTransferId = (raw) => {
|
|
1606
|
+
if (typeof raw !== "string" || raw.length === 0) {
|
|
1607
|
+
throw new Error(
|
|
1608
|
+
`Invalid tokenTransferId: expected non-empty string, got ${String(raw)}`
|
|
1609
|
+
);
|
|
1610
|
+
}
|
|
1611
|
+
return raw;
|
|
1612
|
+
};
|
|
1613
|
+
function brandRow(row) {
|
|
1614
|
+
return {
|
|
1615
|
+
...row,
|
|
1616
|
+
id: toTokenTransferId(row.id)
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
function createTokenTransfersClient(config = {}) {
|
|
1620
|
+
return {
|
|
1621
|
+
list: async (input) => {
|
|
1622
|
+
if (!config.data) {
|
|
1623
|
+
return stub("tokenTransfers.list");
|
|
1624
|
+
}
|
|
1625
|
+
try {
|
|
1626
|
+
const raw = await config.data.query(
|
|
1627
|
+
api.tokenTransfers.queries.list,
|
|
1628
|
+
{
|
|
1629
|
+
limit: input?.limit,
|
|
1630
|
+
cursor: input?.cursor,
|
|
1631
|
+
direction: input?.direction
|
|
1632
|
+
}
|
|
1633
|
+
);
|
|
1634
|
+
if (!raw) {
|
|
1635
|
+
return [
|
|
1636
|
+
new CapxulError({
|
|
1637
|
+
code: "NOT_AUTHENTICATED",
|
|
1638
|
+
message: "tokenTransfers.list requires an authenticated session."
|
|
1639
|
+
}),
|
|
1640
|
+
null
|
|
1641
|
+
];
|
|
1642
|
+
}
|
|
1643
|
+
return [
|
|
1644
|
+
null,
|
|
1645
|
+
{
|
|
1646
|
+
object: "list",
|
|
1647
|
+
data: raw.items.map(brandRow),
|
|
1648
|
+
page: {
|
|
1649
|
+
hasMore: raw.hasMore,
|
|
1650
|
+
nextCursor: raw.nextCursor
|
|
1651
|
+
},
|
|
1652
|
+
displayCurrency: raw.displayCurrency
|
|
1653
|
+
}
|
|
1654
|
+
];
|
|
1655
|
+
} catch (cause) {
|
|
1656
|
+
return [fromConvexError(cause), null];
|
|
1657
|
+
}
|
|
1658
|
+
},
|
|
1659
|
+
retrieve: async (input) => {
|
|
1660
|
+
if (!config.data) {
|
|
1661
|
+
return stub("tokenTransfers.retrieve");
|
|
1662
|
+
}
|
|
1663
|
+
try {
|
|
1664
|
+
const raw = await config.data.query(
|
|
1665
|
+
api.tokenTransfers.queries.getByTxLogIndex,
|
|
1666
|
+
{
|
|
1667
|
+
txHash: input.txHash,
|
|
1668
|
+
logIndex: input.logIndex,
|
|
1669
|
+
chainId: input.chainId
|
|
1670
|
+
}
|
|
1671
|
+
);
|
|
1672
|
+
if (!raw) {
|
|
1673
|
+
return [
|
|
1674
|
+
new CapxulError({
|
|
1675
|
+
code: "NOT_FOUND",
|
|
1676
|
+
message: `tokenTransfer (txHash=${input.txHash}, logIndex=${input.logIndex}) not found or not visible to caller.`,
|
|
1677
|
+
details: {
|
|
1678
|
+
txHash: input.txHash,
|
|
1679
|
+
logIndex: input.logIndex,
|
|
1680
|
+
chainId: input.chainId
|
|
1681
|
+
}
|
|
1682
|
+
}),
|
|
1683
|
+
null
|
|
1684
|
+
];
|
|
1685
|
+
}
|
|
1686
|
+
return [null, brandRow(raw)];
|
|
1687
|
+
} catch (cause) {
|
|
1688
|
+
return [fromConvexError(cause), null];
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1507
1694
|
// src/core/virtual-accounts.ts
|
|
1508
1695
|
function createVirtualAccountsClient() {
|
|
1509
1696
|
return {
|
|
@@ -2247,6 +2434,7 @@ function createCapxulClient(config = {}) {
|
|
|
2247
2434
|
organizations: createOrganizationsClient(config),
|
|
2248
2435
|
payments: createPaymentsClient(config),
|
|
2249
2436
|
transfers: createTransfersClient(),
|
|
2437
|
+
tokenTransfers: createTokenTransfersClient(config),
|
|
2250
2438
|
withdrawals: createWithdrawalsClient(config),
|
|
2251
2439
|
documents: createDocumentsClient(),
|
|
2252
2440
|
subAccounts: createSubAccountsClient(),
|
package/dist/index.cjs
CHANGED
|
@@ -73,9 +73,79 @@ function fromConvexError(error) {
|
|
|
73
73
|
// src/core/accounts.ts
|
|
74
74
|
function createAccountsClient(config = {}) {
|
|
75
75
|
return {
|
|
76
|
-
retrieve: async () =>
|
|
76
|
+
retrieve: async (accountId) => {
|
|
77
|
+
if (!config.data) {
|
|
78
|
+
return stub("accounts.retrieve");
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const account = await config.data.query(
|
|
82
|
+
api.openfort.queries.getMyAccount,
|
|
83
|
+
{}
|
|
84
|
+
);
|
|
85
|
+
if (account.id !== accountId) {
|
|
86
|
+
return [
|
|
87
|
+
new CapxulError({
|
|
88
|
+
code: "PERMISSION_DENIED",
|
|
89
|
+
message: "accounts.retrieve currently supports the authenticated caller's own account only.",
|
|
90
|
+
details: {
|
|
91
|
+
requestedAccountId: accountId,
|
|
92
|
+
authenticatedAccountId: account.id
|
|
93
|
+
}
|
|
94
|
+
}),
|
|
95
|
+
null
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
return [null, account];
|
|
99
|
+
} catch (cause) {
|
|
100
|
+
return [fromConvexError(cause), null];
|
|
101
|
+
}
|
|
102
|
+
},
|
|
77
103
|
lookup: async () => stub("accounts.lookup"),
|
|
78
|
-
update: async () =>
|
|
104
|
+
update: async (input) => {
|
|
105
|
+
if (!config.data) {
|
|
106
|
+
return stub("accounts.update");
|
|
107
|
+
}
|
|
108
|
+
if (input.countryCode !== void 0) {
|
|
109
|
+
return [
|
|
110
|
+
new CapxulError({
|
|
111
|
+
code: "INVALID_INPUT",
|
|
112
|
+
message: "accounts.update does not support countryCode yet \u2014 backend mutation only patches displayName and username.",
|
|
113
|
+
details: { field: "countryCode" }
|
|
114
|
+
}),
|
|
115
|
+
null
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
const current = await config.data.query(
|
|
120
|
+
api.openfort.queries.getMyAccount,
|
|
121
|
+
{}
|
|
122
|
+
);
|
|
123
|
+
if (current.id !== input.accountId) {
|
|
124
|
+
return [
|
|
125
|
+
new CapxulError({
|
|
126
|
+
code: "PERMISSION_DENIED",
|
|
127
|
+
message: "accounts.update currently supports the authenticated caller's own account only.",
|
|
128
|
+
details: {
|
|
129
|
+
requestedAccountId: input.accountId,
|
|
130
|
+
authenticatedAccountId: current.id
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
null
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
await config.data.mutation(api.openfort.mutations.updateProfile, {
|
|
137
|
+
displayName: input.name,
|
|
138
|
+
username: input.username
|
|
139
|
+
});
|
|
140
|
+
const updated = await config.data.query(
|
|
141
|
+
api.openfort.queries.getMyAccount,
|
|
142
|
+
{}
|
|
143
|
+
);
|
|
144
|
+
return [null, updated];
|
|
145
|
+
} catch (cause) {
|
|
146
|
+
return [fromConvexError(cause), null];
|
|
147
|
+
}
|
|
148
|
+
},
|
|
79
149
|
provisionPersonal: async (input) => {
|
|
80
150
|
if (!config.data) {
|
|
81
151
|
return stub(
|
|
@@ -699,7 +769,34 @@ function createMeClient(config = {}) {
|
|
|
699
769
|
return [fromConvexError(cause), null];
|
|
700
770
|
}
|
|
701
771
|
},
|
|
702
|
-
update: async () =>
|
|
772
|
+
update: async (input) => {
|
|
773
|
+
if (!config.data) {
|
|
774
|
+
return stub("me.update");
|
|
775
|
+
}
|
|
776
|
+
if (input.countryCode !== void 0) {
|
|
777
|
+
return [
|
|
778
|
+
new CapxulError({
|
|
779
|
+
code: "INVALID_INPUT",
|
|
780
|
+
message: "me.update does not support countryCode yet \u2014 backend mutation only patches displayName and username.",
|
|
781
|
+
details: { field: "countryCode" }
|
|
782
|
+
}),
|
|
783
|
+
null
|
|
784
|
+
];
|
|
785
|
+
}
|
|
786
|
+
try {
|
|
787
|
+
await config.data.mutation(api.openfort.mutations.updateProfile, {
|
|
788
|
+
displayName: input.name,
|
|
789
|
+
username: input.username
|
|
790
|
+
});
|
|
791
|
+
const account = await config.data.query(
|
|
792
|
+
api.openfort.queries.getMyAccount,
|
|
793
|
+
{}
|
|
794
|
+
);
|
|
795
|
+
return [null, account];
|
|
796
|
+
} catch (cause) {
|
|
797
|
+
return [fromConvexError(cause), null];
|
|
798
|
+
}
|
|
799
|
+
}
|
|
703
800
|
};
|
|
704
801
|
}
|
|
705
802
|
|
|
@@ -1508,6 +1605,96 @@ function createSubAccountsClient() {
|
|
|
1508
1605
|
};
|
|
1509
1606
|
}
|
|
1510
1607
|
|
|
1608
|
+
// src/core/token-transfers.ts
|
|
1609
|
+
var toTokenTransferId = (raw) => {
|
|
1610
|
+
if (typeof raw !== "string" || raw.length === 0) {
|
|
1611
|
+
throw new Error(
|
|
1612
|
+
`Invalid tokenTransferId: expected non-empty string, got ${String(raw)}`
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1615
|
+
return raw;
|
|
1616
|
+
};
|
|
1617
|
+
function brandRow(row) {
|
|
1618
|
+
return {
|
|
1619
|
+
...row,
|
|
1620
|
+
id: toTokenTransferId(row.id)
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
function createTokenTransfersClient(config = {}) {
|
|
1624
|
+
return {
|
|
1625
|
+
list: async (input) => {
|
|
1626
|
+
if (!config.data) {
|
|
1627
|
+
return stub("tokenTransfers.list");
|
|
1628
|
+
}
|
|
1629
|
+
try {
|
|
1630
|
+
const raw = await config.data.query(
|
|
1631
|
+
api.tokenTransfers.queries.list,
|
|
1632
|
+
{
|
|
1633
|
+
limit: input?.limit,
|
|
1634
|
+
cursor: input?.cursor,
|
|
1635
|
+
direction: input?.direction
|
|
1636
|
+
}
|
|
1637
|
+
);
|
|
1638
|
+
if (!raw) {
|
|
1639
|
+
return [
|
|
1640
|
+
new CapxulError({
|
|
1641
|
+
code: "NOT_AUTHENTICATED",
|
|
1642
|
+
message: "tokenTransfers.list requires an authenticated session."
|
|
1643
|
+
}),
|
|
1644
|
+
null
|
|
1645
|
+
];
|
|
1646
|
+
}
|
|
1647
|
+
return [
|
|
1648
|
+
null,
|
|
1649
|
+
{
|
|
1650
|
+
object: "list",
|
|
1651
|
+
data: raw.items.map(brandRow),
|
|
1652
|
+
page: {
|
|
1653
|
+
hasMore: raw.hasMore,
|
|
1654
|
+
nextCursor: raw.nextCursor
|
|
1655
|
+
},
|
|
1656
|
+
displayCurrency: raw.displayCurrency
|
|
1657
|
+
}
|
|
1658
|
+
];
|
|
1659
|
+
} catch (cause) {
|
|
1660
|
+
return [fromConvexError(cause), null];
|
|
1661
|
+
}
|
|
1662
|
+
},
|
|
1663
|
+
retrieve: async (input) => {
|
|
1664
|
+
if (!config.data) {
|
|
1665
|
+
return stub("tokenTransfers.retrieve");
|
|
1666
|
+
}
|
|
1667
|
+
try {
|
|
1668
|
+
const raw = await config.data.query(
|
|
1669
|
+
api.tokenTransfers.queries.getByTxLogIndex,
|
|
1670
|
+
{
|
|
1671
|
+
txHash: input.txHash,
|
|
1672
|
+
logIndex: input.logIndex,
|
|
1673
|
+
chainId: input.chainId
|
|
1674
|
+
}
|
|
1675
|
+
);
|
|
1676
|
+
if (!raw) {
|
|
1677
|
+
return [
|
|
1678
|
+
new CapxulError({
|
|
1679
|
+
code: "NOT_FOUND",
|
|
1680
|
+
message: `tokenTransfer (txHash=${input.txHash}, logIndex=${input.logIndex}) not found or not visible to caller.`,
|
|
1681
|
+
details: {
|
|
1682
|
+
txHash: input.txHash,
|
|
1683
|
+
logIndex: input.logIndex,
|
|
1684
|
+
chainId: input.chainId
|
|
1685
|
+
}
|
|
1686
|
+
}),
|
|
1687
|
+
null
|
|
1688
|
+
];
|
|
1689
|
+
}
|
|
1690
|
+
return [null, brandRow(raw)];
|
|
1691
|
+
} catch (cause) {
|
|
1692
|
+
return [fromConvexError(cause), null];
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1511
1698
|
// src/core/virtual-accounts.ts
|
|
1512
1699
|
function createVirtualAccountsClient() {
|
|
1513
1700
|
return {
|
|
@@ -1530,6 +1717,15 @@ function createVirtualCardsClient() {
|
|
|
1530
1717
|
};
|
|
1531
1718
|
}
|
|
1532
1719
|
|
|
1720
|
+
// ../observability/src/try-catch.ts
|
|
1721
|
+
async function tryCatch(promise) {
|
|
1722
|
+
try {
|
|
1723
|
+
return [null, await promise];
|
|
1724
|
+
} catch (e) {
|
|
1725
|
+
return [e instanceof Error ? e : new Error(String(e)), null];
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1533
1729
|
// ../observability/src/debug-log.ts
|
|
1534
1730
|
function isDevelopmentBuild() {
|
|
1535
1731
|
if (typeof process === "undefined") {
|
|
@@ -2350,6 +2546,7 @@ function createCapxulClient(config = {}) {
|
|
|
2350
2546
|
organizations: createOrganizationsClient(config),
|
|
2351
2547
|
payments: createPaymentsClient(config),
|
|
2352
2548
|
transfers: createTransfersClient(),
|
|
2549
|
+
tokenTransfers: createTokenTransfersClient(config),
|
|
2353
2550
|
withdrawals: createWithdrawalsClient(config),
|
|
2354
2551
|
documents: createDocumentsClient(),
|
|
2355
2552
|
subAccounts: createSubAccountsClient(),
|
|
@@ -2493,6 +2690,7 @@ exports.toPaymentId = toPaymentId;
|
|
|
2493
2690
|
exports.toPhoneNumber = toPhoneNumber;
|
|
2494
2691
|
exports.toSafeId = toSafeId;
|
|
2495
2692
|
exports.toSubAccountId = toSubAccountId;
|
|
2693
|
+
exports.toTokenTransferId = toTokenTransferId;
|
|
2496
2694
|
exports.toTransferId = toTransferId;
|
|
2497
2695
|
exports.toTreasuryId = toTreasuryId;
|
|
2498
2696
|
exports.toUsername = toUsername;
|
|
@@ -2501,4 +2699,5 @@ exports.toVirtualCardId = toVirtualCardId;
|
|
|
2501
2699
|
exports.toWebhookEndpointId = toWebhookEndpointId;
|
|
2502
2700
|
exports.toWebhookEventId = toWebhookEventId;
|
|
2503
2701
|
exports.toWithdrawalId = toWithdrawalId;
|
|
2702
|
+
exports.tryCatch = tryCatch;
|
|
2504
2703
|
exports.verifyWebhook = verifyWebhook;
|