@owneraio/finp2p-sdk-js 0.28.24 → 0.28.26
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/lib/OwneraAPI/finp2p-node-api/data.d.ts +13 -0
- package/lib/OwneraAPI/finp2p-node-api/data.js +58 -0
- package/lib/OwneraAPI/finp2p-node-api/data.js.map +1 -0
- package/lib/OwneraAPI/finp2p-node-api/profiles.js +16 -7
- package/lib/OwneraAPI/finp2p-node-api/profiles.js.map +1 -1
- package/lib/OwneraAPI/index.js +2 -0
- package/lib/OwneraAPI/index.js.map +1 -1
- package/lib/OwneraAPI/oss-api/oss.js +89 -3
- package/lib/OwneraAPI/oss-api/oss.js.map +1 -1
- package/lib/core/intents/createIntent/createMoveIntentReq.d.ts +28 -0
- package/lib/core/intents/createIntent/createMoveIntentReq.js +84 -0
- package/lib/core/intents/createIntent/createMoveIntentReq.js.map +1 -0
- package/lib/core/intents/createIntent/helpers.d.ts +28 -2
- package/lib/core/intents/createIntent/helpers.js +68 -1
- package/lib/core/intents/createIntent/helpers.js.map +1 -1
- package/lib/core/intents/executeMoveIntent.d.ts +19 -0
- package/lib/core/intents/executeMoveIntent.js +134 -0
- package/lib/core/intents/executeMoveIntent.js.map +1 -0
- package/lib/core/intents/getIntent.js +9 -0
- package/lib/core/intents/getIntent.js.map +1 -1
- package/lib/core/intents/index.d.ts +3 -0
- package/lib/core/intents/index.js +7 -1
- package/lib/core/intents/index.js.map +1 -1
- package/lib/core/intents/updateMoveIntentReq.d.ts +27 -0
- package/lib/core/intents/updateMoveIntentReq.js +92 -0
- package/lib/core/intents/updateMoveIntentReq.js.map +1 -0
- package/lib/core/intents/utils.js +1 -0
- package/lib/core/intents/utils.js.map +1 -1
- package/lib/core/user.js +55 -0
- package/lib/core/user.js.map +1 -1
- package/lib/types/AssetData/index.d.ts +142 -0
- package/lib/types/AssetData/index.js +3 -0
- package/lib/types/AssetData/index.js.map +1 -0
- package/lib/types/Core/Intents.d.ts +131 -2
- package/lib/types/Core/OwneraAPI.d.ts +2 -0
- package/lib/types/Core/User.d.ts +34 -1
- package/lib/types/Oss/FinancialAsset.d.ts +21 -5
- package/lib/types/Oss/Oss.d.ts +12 -1
- package/lib/types/Oss/OssSchemas.d.ts +39 -2
- package/lib/types/Oss/OssSchemas.js.map +1 -1
- package/lib/types/Profiles/Accounts.d.ts +32 -0
- package/lib/types/Profiles/Intents.d.ts +45 -2
- package/lib/types/Profiles/Profiles.d.ts +25 -1
- package/lib/types/Tokens/Tokens.d.ts +2 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CoreRequestOptions, CreateMoveIntent, Logger, OwneraAPIInterface } from '../../../types';
|
|
2
|
+
export interface CreateMoveIntentPayload {
|
|
3
|
+
owneraAPI: OwneraAPIInterface;
|
|
4
|
+
logger: Logger;
|
|
5
|
+
publicKey: string;
|
|
6
|
+
createIntentRequest: CreateMoveIntent;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Build and submit a Move intent. Declares an asset-level migration path from a
|
|
10
|
+
* single source asset (`assetId`) to one-or-more destination assets. The intent
|
|
11
|
+
* is created by the source asset's org and executed later by any holder, who
|
|
12
|
+
* picks one of the declared destinations.
|
|
13
|
+
*
|
|
14
|
+
* Destinations come from `destinationAssets` (preferred) or `destinationAsset`
|
|
15
|
+
* (single-destination alias); the resolved list maps to the node's
|
|
16
|
+
* `moveAsset.destinationAssets`. Each entry is a `moveDestination` object
|
|
17
|
+
* (`{ id, ledgerIdentifier }` plus an optional pre-funded pool), and the intent
|
|
18
|
+
* carries no issuer or account — the issuer is derived server-side from the
|
|
19
|
+
* source asset's org.
|
|
20
|
+
*
|
|
21
|
+
* Custody-offered Move adds two optional inputs, both omitted from the payload
|
|
22
|
+
* when unset so the issuer-offered path's wire shape is byte-identical to
|
|
23
|
+
* before: per-destination `fromSegregatedAccount`/`fromSegregatedAccountOwner`
|
|
24
|
+
* (a pre-funded pool the Transfer drains) and `sourceToSegregatedAccount` (the
|
|
25
|
+
* source Release target, instead of burning). Org co-location of these accounts
|
|
26
|
+
* is validated by the node, not here.
|
|
27
|
+
*/
|
|
28
|
+
export declare const createMoveIntentReq: (req: CreateMoveIntentPayload, options?: CoreRequestOptions) => Promise<import("../../../types").IdResponse>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createMoveIntentReq = void 0;
|
|
13
|
+
const helpers_1 = require("./helpers");
|
|
14
|
+
/**
|
|
15
|
+
* Build and submit a Move intent. Declares an asset-level migration path from a
|
|
16
|
+
* single source asset (`assetId`) to one-or-more destination assets. The intent
|
|
17
|
+
* is created by the source asset's org and executed later by any holder, who
|
|
18
|
+
* picks one of the declared destinations.
|
|
19
|
+
*
|
|
20
|
+
* Destinations come from `destinationAssets` (preferred) or `destinationAsset`
|
|
21
|
+
* (single-destination alias); the resolved list maps to the node's
|
|
22
|
+
* `moveAsset.destinationAssets`. Each entry is a `moveDestination` object
|
|
23
|
+
* (`{ id, ledgerIdentifier }` plus an optional pre-funded pool), and the intent
|
|
24
|
+
* carries no issuer or account — the issuer is derived server-side from the
|
|
25
|
+
* source asset's org.
|
|
26
|
+
*
|
|
27
|
+
* Custody-offered Move adds two optional inputs, both omitted from the payload
|
|
28
|
+
* when unset so the issuer-offered path's wire shape is byte-identical to
|
|
29
|
+
* before: per-destination `fromSegregatedAccount`/`fromSegregatedAccountOwner`
|
|
30
|
+
* (a pre-funded pool the Transfer drains) and `sourceToSegregatedAccount` (the
|
|
31
|
+
* source Release target, instead of burning). Org co-location of these accounts
|
|
32
|
+
* is validated by the node, not here.
|
|
33
|
+
*/
|
|
34
|
+
const createMoveIntentReq = (req, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
36
|
+
const { owneraAPI, logger, createIntentRequest } = req;
|
|
37
|
+
const { assetId, start, end, destinationAsset, destinationAssets, sourceToSegregatedAccount, signaturePolicy, intentId, metadata, } = createIntentRequest;
|
|
38
|
+
// `destinationAssets` wins over the single-destination `destinationAsset` alias.
|
|
39
|
+
const destinations = destinationAssets !== null && destinationAssets !== void 0 ? destinationAssets : (destinationAsset ? [destinationAsset] : []);
|
|
40
|
+
if (destinations.length === 0) {
|
|
41
|
+
throw {
|
|
42
|
+
code: 400,
|
|
43
|
+
name: 'createMoveIntentError',
|
|
44
|
+
message: 'A move intent requires at least one destination asset (destinationAsset or destinationAssets).',
|
|
45
|
+
data: createIntentRequest,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (start >= end) {
|
|
49
|
+
throw {
|
|
50
|
+
code: 400,
|
|
51
|
+
name: 'createMoveIntentError',
|
|
52
|
+
message: `Move intent start (${start}) must be before end (${end}).`,
|
|
53
|
+
data: createIntentRequest,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
(0, helpers_1.assertMoveDestinationPools)(destinations, 'createMoveIntentError', createIntentRequest);
|
|
57
|
+
const sourceAssetIdentifier = yield (0, helpers_1.resolveMoveAssetIdentifier)(owneraAPI, assetId);
|
|
58
|
+
const destinationAssetIdentifiers = yield Promise.all(destinations.map((d) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
return (Object.assign(Object.assign(Object.assign({}, (yield (0, helpers_1.resolveMoveAssetIdentifier)(owneraAPI, d.resourceId))), (d.fromSegregatedAccount ? { fromSegregatedAccount: d.fromSegregatedAccount } : {})), (d.fromSegregatedAccountOwner ? { fromSegregatedAccountOwner: d.fromSegregatedAccountOwner } : {})));
|
|
60
|
+
})));
|
|
61
|
+
const intent = {
|
|
62
|
+
type: 'moveIntent',
|
|
63
|
+
asset: Object.assign({ sourceAsset: sourceAssetIdentifier, destinationAssets: destinationAssetIdentifiers }, (sourceToSegregatedAccount ? { sourceToSegregatedAccount } : {})),
|
|
64
|
+
signaturePolicy: signaturePolicy || { type: 'manualPolicy' },
|
|
65
|
+
};
|
|
66
|
+
logger.debug('🔵 [createMoveIntent] FULL CREATION REQUEST (intent):', JSON.stringify(intent, null, 2));
|
|
67
|
+
try {
|
|
68
|
+
return yield owneraAPI.profiles.createIntent(Object.assign({ assetId,
|
|
69
|
+
start,
|
|
70
|
+
end, intent: intent, intentId }, (metadata ? { metadata } : {})), { idempotency: options === null || options === void 0 ? void 0 : options.idempotencyKey });
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
logger.error('Create Move Intent Error', JSON.stringify(e));
|
|
74
|
+
const errorMessage = ((_b = (_a = e === null || e === void 0 ? void 0 : e.data) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.message) || ((_f = (_e = (_d = (_c = e === null || e === void 0 ? void 0 : e.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.message) || (e === null || e === void 0 ? void 0 : e.message) || e;
|
|
75
|
+
throw {
|
|
76
|
+
code: ((_h = (_g = e === null || e === void 0 ? void 0 : e.data) === null || _g === void 0 ? void 0 : _g.error) === null || _h === void 0 ? void 0 : _h.code) || (e === null || e === void 0 ? void 0 : e.code) || 500,
|
|
77
|
+
name: 'createMoveIntentError',
|
|
78
|
+
message: typeof errorMessage === 'string' ? errorMessage : JSON.stringify(errorMessage),
|
|
79
|
+
data: createIntentRequest,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
exports.createMoveIntentReq = createMoveIntentReq;
|
|
84
|
+
//# sourceMappingURL=createMoveIntentReq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createMoveIntentReq.js","sourceRoot":"","sources":["../../../../src/core/intents/createIntent/createMoveIntentReq.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,uCAAmF;AASnF;;;;;;;;;;;;;;;;;;;GAmBG;AACI,MAAM,mBAAmB,GAAG,CAAO,GAA4B,EAAE,OAA4B,EAAE,EAAE;;IACtG,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,GAAG,CAAC;IACvD,MAAM,EACJ,OAAO,EACP,KAAK,EACL,GAAG,EACH,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,EACzB,eAAe,EACf,QAAQ,EACR,QAAQ,GACT,GAAG,mBAAmB,CAAC;IAExB,iFAAiF;IACjF,MAAM,YAAY,GAAG,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACvF,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM;YACJ,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,uBAAuB;YAC7B,OAAO,EAAE,gGAAgG;YACzG,IAAI,EAAE,mBAAmB;SAC1B,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;QACjB,MAAM;YACJ,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,uBAAuB;YAC7B,O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
2
3
|
export type Caip19AssetIdentifier = {
|
|
3
4
|
id: string;
|
|
@@ -8,11 +9,36 @@ export type Caip19AssetIdentifier = {
|
|
|
8
9
|
tokenId: string;
|
|
9
10
|
};
|
|
10
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Assert the node's pool-owner rule for custody-offered Move destinations:
|
|
14
|
+
* `fromSegregatedAccountOwner` (the Transfer seller / debited party) is
|
|
15
|
+
* required whenever `fromSegregatedAccount` is set.
|
|
16
|
+
*
|
|
17
|
+
* Checked client-side because it needs no lookups — unlike the node's other
|
|
18
|
+
* rule (pool and owner must be co-located with the destination asset's org),
|
|
19
|
+
* which stays a server-side 400. `errorName` matches the caller's error name so
|
|
20
|
+
* create and update surface a consistent shape.
|
|
21
|
+
*/
|
|
22
|
+
export declare const assertMoveDestinationPools: (destinations: {
|
|
23
|
+
resourceId: string;
|
|
24
|
+
fromSegregatedAccount?: unknown;
|
|
25
|
+
fromSegregatedAccountOwner?: string;
|
|
26
|
+
}[], errorName: string, data: unknown) => void;
|
|
11
27
|
export declare const buildCaip19Identifier: (ledgerIdentifier: {
|
|
12
28
|
network?: string;
|
|
13
29
|
standard?: string;
|
|
14
30
|
tokenId?: string;
|
|
15
31
|
} | undefined, resourceId: string) => Caip19AssetIdentifier;
|
|
32
|
+
/**
|
|
33
|
+
* Resolve a move-intent asset's node-shaped CAIP-19 identifier.
|
|
34
|
+
*
|
|
35
|
+
* A move intent's `finp2pAsset` must carry a real CAIP-19 ledger identifier —
|
|
36
|
+
* an empty one would be rejected by the node or silently misroute the
|
|
37
|
+
* migration. So unlike the settlement-side builders, this fails loud when the
|
|
38
|
+
* asset can't be found or has no `ledgerIdentifier`, rather than emitting empty
|
|
39
|
+
* network/standard/tokenId. Used by both create and update move-intent paths.
|
|
40
|
+
*/
|
|
41
|
+
export declare const resolveMoveAssetIdentifier: (owneraAPI: OwneraAPIInterface, assetId: string) => Promise<Caip19AssetIdentifier>;
|
|
16
42
|
/**
|
|
17
43
|
* Build a finp2pAssetAccount (v0.28.0 format)
|
|
18
44
|
*/
|
|
@@ -54,6 +80,6 @@ export declare const getCreateIntentReqBase: ({ createIntentRequest, publicKey,
|
|
|
54
80
|
};
|
|
55
81
|
};
|
|
56
82
|
};
|
|
57
|
-
settlementTerm: import("
|
|
58
|
-
signaturePolicy: import("
|
|
83
|
+
settlementTerm: import("../../../types").IntentCreationSettlementTerm;
|
|
84
|
+
signaturePolicy: import("../../../types").ManualSignaturePolicy;
|
|
59
85
|
};
|
|
@@ -1,7 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCreateIntentReqBase = exports.buildFinp2pAssetAccount = exports.buildCaip19Identifier = void 0;
|
|
12
|
+
exports.getCreateIntentReqBase = exports.buildFinp2pAssetAccount = exports.resolveMoveAssetIdentifier = exports.buildCaip19Identifier = exports.assertMoveDestinationPools = void 0;
|
|
4
13
|
const utils_1 = require("../../utils");
|
|
14
|
+
/**
|
|
15
|
+
* Assert the node's pool-owner rule for custody-offered Move destinations:
|
|
16
|
+
* `fromSegregatedAccountOwner` (the Transfer seller / debited party) is
|
|
17
|
+
* required whenever `fromSegregatedAccount` is set.
|
|
18
|
+
*
|
|
19
|
+
* Checked client-side because it needs no lookups — unlike the node's other
|
|
20
|
+
* rule (pool and owner must be co-located with the destination asset's org),
|
|
21
|
+
* which stays a server-side 400. `errorName` matches the caller's error name so
|
|
22
|
+
* create and update surface a consistent shape.
|
|
23
|
+
*/
|
|
24
|
+
const assertMoveDestinationPools = (destinations, errorName, data) => {
|
|
25
|
+
const missingOwner = destinations.find((d) => d.fromSegregatedAccount && !d.fromSegregatedAccountOwner);
|
|
26
|
+
if (missingOwner) {
|
|
27
|
+
throw {
|
|
28
|
+
code: 400,
|
|
29
|
+
name: errorName,
|
|
30
|
+
message: `Move destination ${missingOwner.resourceId} sets fromSegregatedAccount without ` +
|
|
31
|
+
'fromSegregatedAccountOwner; the pool owner (Transfer seller) is required when a pool is set.',
|
|
32
|
+
data,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.assertMoveDestinationPools = assertMoveDestinationPools;
|
|
5
37
|
const buildCaip19Identifier = (ledgerIdentifier, resourceId) => ({
|
|
6
38
|
id: resourceId,
|
|
7
39
|
ledgerIdentifier: {
|
|
@@ -12,6 +44,41 @@ const buildCaip19Identifier = (ledgerIdentifier, resourceId) => ({
|
|
|
12
44
|
},
|
|
13
45
|
});
|
|
14
46
|
exports.buildCaip19Identifier = buildCaip19Identifier;
|
|
47
|
+
/**
|
|
48
|
+
* Resolve a move-intent asset's node-shaped CAIP-19 identifier.
|
|
49
|
+
*
|
|
50
|
+
* A move intent's `finp2pAsset` must carry a real CAIP-19 ledger identifier —
|
|
51
|
+
* an empty one would be rejected by the node or silently misroute the
|
|
52
|
+
* migration. So unlike the settlement-side builders, this fails loud when the
|
|
53
|
+
* asset can't be found or has no `ledgerIdentifier`, rather than emitting empty
|
|
54
|
+
* network/standard/tokenId. Used by both create and update move-intent paths.
|
|
55
|
+
*/
|
|
56
|
+
const resolveMoveAssetIdentifier = (owneraAPI, assetId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
let ledgerIdentifier;
|
|
59
|
+
try {
|
|
60
|
+
const assetsData = yield owneraAPI.query.getAssets({ filter: { assetIds: [assetId] } });
|
|
61
|
+
ledgerIdentifier = (_c = (_b = (_a = assetsData.data) === null || _a === void 0 ? void 0 : _a.find((a) => (a === null || a === void 0 ? void 0 : a.id) === assetId)) === null || _b === void 0 ? void 0 : _b.ledgerAssetInfo) === null || _c === void 0 ? void 0 : _c.ledgerIdentifier;
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
throw {
|
|
65
|
+
code: (e === null || e === void 0 ? void 0 : e.code) || 502,
|
|
66
|
+
name: 'MoveAssetResolutionError',
|
|
67
|
+
message: `Failed to resolve CAIP-19 ledger identifier for move intent asset ${assetId}: ${(e === null || e === void 0 ? void 0 : e.message) || e}`,
|
|
68
|
+
data: { assetId },
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (!ledgerIdentifier) {
|
|
72
|
+
throw {
|
|
73
|
+
code: 400,
|
|
74
|
+
name: 'MoveAssetResolutionError',
|
|
75
|
+
message: `Move intent asset ${assetId} has no CAIP-19 ledger identifier; cannot build a valid destination/source asset.`,
|
|
76
|
+
data: { assetId },
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return (0, exports.buildCaip19Identifier)(ledgerIdentifier, assetId);
|
|
80
|
+
});
|
|
81
|
+
exports.resolveMoveAssetIdentifier = resolveMoveAssetIdentifier;
|
|
15
82
|
/**
|
|
16
83
|
* Build a finp2pAssetAccount (v0.28.0 format)
|
|
17
84
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../src/core/intents/createIntent/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../src/core/intents/createIntent/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAmD;AAcnD;;;;;;;;;GASG;AACI,MAAM,0BAA0B,GAAG,CACxC,YAA4G,EAC5G,SAAiB,E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,EAAE;IACjH,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,mBAAmB,CAAC;IAEvF,OAAO;QACL,IAAI;QACJ,KAAK,EAAE;YACL,SAAS,EAAE;gBACT,MAAM;aACP;YACD,gBAAgB,EAAE;gBAChB,aAAa,EAAE;oBACb,KAAK,EAAE,eAAe;oBACtB,OAAO,EAAE;wBACP,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE,SAAS;wBAChB,KAAK,EAAE,IAAA,4BAAoB,EAAC,OAAO,CAAC;wBACpC,SAAS,EAAE;4BACT,KAAK,EAAE,EAAE;yBACV;qBACF;iBACF;aACF;SACF;QAED,cAAc;QACd,eAAe;KAChB,CAAC;AACJ,CAAC,CAAC;AA3BW,QAAA,sBAAsB,0BA2BjC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ExecuteResponse, Logger, MoveIntentExecutionData, OwneraAPIInterface } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Execute a Move intent. The holder migrates their holding from the intent's
|
|
4
|
+
* source asset to a chosen destination asset (`destinationAssetId`). The
|
|
5
|
+
* executor owns both accounts, so source and destination account fin-ids are
|
|
6
|
+
* the executor's public key; orgs are derived from each asset's resource id.
|
|
7
|
+
*
|
|
8
|
+
* Move is an asset-only migration and carries no settlement leg, so the
|
|
9
|
+
* execution runs through the standard token execution-plan path.
|
|
10
|
+
*/
|
|
11
|
+
export declare const executeMoveIntent: (req: {
|
|
12
|
+
owneraAPI: OwneraAPIInterface;
|
|
13
|
+
logger: Logger;
|
|
14
|
+
data: MoveIntentExecutionData;
|
|
15
|
+
userId: string;
|
|
16
|
+
userPublicKey: string;
|
|
17
|
+
custodianOrgId: string;
|
|
18
|
+
idempotency?: string;
|
|
19
|
+
}) => Promise<ExecuteResponse>;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.executeMoveIntent = void 0;
|
|
13
|
+
const utils_1 = require("../utils");
|
|
14
|
+
const utils_2 = require("./utils");
|
|
15
|
+
const tokens_1 = require("../tokens");
|
|
16
|
+
const helpers_1 = require("./createIntent/helpers");
|
|
17
|
+
/**
|
|
18
|
+
* Execute a Move intent. The holder migrates their holding from the intent's
|
|
19
|
+
* source asset to a chosen destination asset (`destinationAssetId`). The
|
|
20
|
+
* executor owns both accounts, so source and destination account fin-ids are
|
|
21
|
+
* the executor's public key; orgs are derived from each asset's resource id.
|
|
22
|
+
*
|
|
23
|
+
* Move is an asset-only migration and carries no settlement leg, so the
|
|
24
|
+
* execution runs through the standard token execution-plan path.
|
|
25
|
+
*/
|
|
26
|
+
const executeMoveIntent = (req) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
var _a, _b, _c, _d, _e;
|
|
28
|
+
const { owneraAPI, data, userId, userPublicKey, custodianOrgId, idempotency, logger } = req;
|
|
29
|
+
const { assetId, intentId, destinationAssetId } = data;
|
|
30
|
+
// The node requires a non-empty custodian org on each account. Default both
|
|
31
|
+
// sides to the executor's custodian org; allow per-side overrides for
|
|
32
|
+
// multi-custodian setups (mirrors executeLoanIntent).
|
|
33
|
+
const sourceCustodianOrgId = (_a = data.sourceCustodianOrgId) !== null && _a !== void 0 ? _a : custodianOrgId;
|
|
34
|
+
const destinationCustodianOrgId = (_b = data.destinationCustodianOrgId) !== null && _b !== void 0 ? _b : custodianOrgId;
|
|
35
|
+
if (!sourceCustodianOrgId || !destinationCustodianOrgId) {
|
|
36
|
+
throw {
|
|
37
|
+
code: 400,
|
|
38
|
+
name: 'ExecuteMoveIntentError',
|
|
39
|
+
message: 'A custodian org is required to execute a move intent. Provide it via the SDK custodianOrgId or per-side sourceCustodianOrgId/destinationCustodianOrgId.',
|
|
40
|
+
data,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// A resource id must be `org:type:id`; getOrgFromResourceId splits on ':'.
|
|
44
|
+
// Reject a malformed destination up front so we don't derive a bogus org.
|
|
45
|
+
if (!destinationAssetId || !destinationAssetId.includes(':')) {
|
|
46
|
+
throw {
|
|
47
|
+
code: 400,
|
|
48
|
+
name: 'ExecuteMoveIntentError',
|
|
49
|
+
message: `Invalid destinationAssetId '${destinationAssetId}' — expected a finp2p resource id (org:type:id).`,
|
|
50
|
+
data,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// If an amount is supplied it must be a positive number (the node accepts
|
|
54
|
+
// '0', but a zero-unit move is almost certainly a mistake).
|
|
55
|
+
if (data.amount !== undefined && (Number.isNaN(Number(data.amount)) || Number(data.amount) <= 0)) {
|
|
56
|
+
throw {
|
|
57
|
+
code: 400,
|
|
58
|
+
name: 'ExecuteMoveIntentError',
|
|
59
|
+
message: `Invalid amount '${data.amount}' — must be a positive number when provided.`,
|
|
60
|
+
data,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const ossAsset = (yield owneraAPI.query.getAssets({ filter: { assetIds: [assetId] } })).data[0];
|
|
64
|
+
if (!ossAsset) {
|
|
65
|
+
throw {
|
|
66
|
+
code: 400,
|
|
67
|
+
name: 'ExecuteMoveIntentError',
|
|
68
|
+
message: `No Asset Found`,
|
|
69
|
+
data,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// Ensure the intent exists on the source asset before executing.
|
|
73
|
+
const intent = (0, utils_2.getAssetIntentOrThrowError)(ossAsset, intentId);
|
|
74
|
+
// Fail fast: the chosen destination must be one of the intent's declared
|
|
75
|
+
// destination assets. The node enforces this too, but rejecting here avoids
|
|
76
|
+
// a round-trip and returns a clearer error.
|
|
77
|
+
const moveIntent = intent.intent;
|
|
78
|
+
const declaredDestinations = (_c = moveIntent === null || moveIntent === void 0 ? void 0 : moveIntent.destinationAssets) !== null && _c !== void 0 ? _c : [];
|
|
79
|
+
if (!declaredDestinations.some((d) => d.resourceId === destinationAssetId)) {
|
|
80
|
+
throw {
|
|
81
|
+
code: 400,
|
|
82
|
+
name: 'ExecuteMoveIntentError',
|
|
83
|
+
message: `Destination asset ${destinationAssetId} is not one of the move intent's declared destinations: ${declaredDestinations.map((d) => d.resourceId).join(', ') || '(none returned)'}`,
|
|
84
|
+
data,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
// Presigned move intents may require a pre-agreed signature at execution,
|
|
88
|
+
// which this path does not supply (it sends a fresh manual nonce). Warn so a
|
|
89
|
+
// silent policy bypass/rejection is at least visible. See MoveIntentSchemaOss.
|
|
90
|
+
if ((moveIntent === null || moveIntent === void 0 ? void 0 : moveIntent.signaturePolicyType) && moveIntent.signaturePolicyType !== 'manualPolicy') {
|
|
91
|
+
logger.warning(`Move intent ${intentId} has signaturePolicy '${moveIntent.signaturePolicyType}'; executeMoveIntent sends a manual nonce and no signature. The node may reject this.`);
|
|
92
|
+
}
|
|
93
|
+
const nonce = (0, utils_1.generateNonce)().toString('hex');
|
|
94
|
+
const sourceAssetIdentifier = (0, helpers_1.buildCaip19Identifier)((_d = ossAsset.ledgerAssetInfo) === null || _d === void 0 ? void 0 : _d.ledgerIdentifier, assetId);
|
|
95
|
+
// Resolve the chosen destination asset's CAIP-19 identifier. When the
|
|
96
|
+
// destination differs from the source, fetch its ledger info — fail loud
|
|
97
|
+
// rather than silently reusing the source identifier (which would misroute
|
|
98
|
+
// the destination leg).
|
|
99
|
+
let destAssetIdentifier = sourceAssetIdentifier;
|
|
100
|
+
let destOrgId = (0, utils_1.getOrgFromResourceId)(assetId);
|
|
101
|
+
if (destinationAssetId !== assetId) {
|
|
102
|
+
destOrgId = (0, utils_1.getOrgFromResourceId)(destinationAssetId);
|
|
103
|
+
destAssetIdentifier = yield (0, helpers_1.resolveMoveAssetIdentifier)(owneraAPI, destinationAssetId);
|
|
104
|
+
}
|
|
105
|
+
const sourceAccount = (0, helpers_1.buildFinp2pAssetAccount)({
|
|
106
|
+
finId: userPublicKey,
|
|
107
|
+
orgId: (0, utils_1.getOrgFromResourceId)(assetId),
|
|
108
|
+
custodian: { orgId: sourceCustodianOrgId },
|
|
109
|
+
}, sourceAssetIdentifier);
|
|
110
|
+
const destinationAccount = (0, helpers_1.buildFinp2pAssetAccount)({
|
|
111
|
+
finId: userPublicKey,
|
|
112
|
+
orgId: destOrgId,
|
|
113
|
+
custodian: { orgId: destinationCustodianOrgId },
|
|
114
|
+
}, destAssetIdentifier);
|
|
115
|
+
// moveIntentExecution.asset is a sourceDestinationIntentAsset: { term?, instruction }.
|
|
116
|
+
// `term` is optional — include it only when the executor specifies an amount to move.
|
|
117
|
+
const executionIntent = {
|
|
118
|
+
type: 'moveIntentExecution',
|
|
119
|
+
nonce,
|
|
120
|
+
owner: userId,
|
|
121
|
+
asset: Object.assign(Object.assign({}, (data.amount ? { term: { amount: data.amount } } : {})), { instruction: {
|
|
122
|
+
sourceAccount,
|
|
123
|
+
destinationAccount,
|
|
124
|
+
} }),
|
|
125
|
+
};
|
|
126
|
+
const request = Object.assign(Object.assign({ intentId, user: userId, intent: executionIntent, executionId: data.executionId }, (((_e = data.observers) === null || _e === void 0 ? void 0 : _e.length) ? { observers: data.observers } : {})), (data.metadata && Object.keys(data.metadata).length ? { metadata: data.metadata } : {}));
|
|
127
|
+
return yield (0, tokens_1.executeTokenIntent)({
|
|
128
|
+
owneraAPI,
|
|
129
|
+
logger,
|
|
130
|
+
data: request,
|
|
131
|
+
}, { idempotencyKey: idempotency });
|
|
132
|
+
});
|
|
133
|
+
exports.executeMoveIntent = executeMoveIntent;
|
|
134
|
+
//# sourceMappingURL=executeMoveIntent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeMoveIntent.js","sourceRoot":"","sources":["../../../src/core/intents/executeMoveIntent.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA,oCAA+D;AAC/D,mCAAqD;AACrD,sCAA+C;AAC/C,oDAAoH;AAEpH;;;;;;;;GAQG;AACI,MAAM,iBAAiB,GAAG,CAAO,GAQvC,EAA4B,EAAE;;IAC7B,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAC5F,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC;IAEvD,4EAA4E;IAC5E,sEAAsE;IACtE,sDAAsD;IACtD,MAAM,oBAAoB,GAAG,MAAA,IAAI,CAAC,oBAAoB,mCAAI,cAAc,CAAC;IACzE,MAAM,yBAAyB,GAAG,MAAA,IAAI,CAAC,yBAAyB,mCAAI,cAAc,CAAC;IACnF,IAAI,CAAC,oBAAoB,IAAI,CAAC,yBAAyB,EAAE,CAAC;QACxD,MAAM;YACJ,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EACL,yJAAyJ;YAC3J,IAAI;SACL,CAAC;IACJ,CAAC;IAED,2EAA2E;IAC3E,0EAA0E;IAC1E,IAAI,CAAC,kBAAkB,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7D,MAAM;YACJ,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EAAE,+BAA+B,kBAAkB,kDAAkD;YAC5G,IAAI;SACL,CAAC;IACJ,CAAC;IAC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|
42
42
|
}),
|
|
43
|
+
/**
|
|
44
|
+
* Cancel intent
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
cancel: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
return yield owneraAPI.profiles.cancelIntent({ assetId, intentId }, {
|
|
49
|
+
idempotency: (0, utils_1.generateIdempotencyKey)(),
|
|
50
|
+
});
|
|
51
|
+
}),
|
|
43
52
|
};
|
|
44
53
|
};
|
|
45
54
|
exports.getIntent = getIntent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntent.js","sourceRoot":"","sources":["../../../src/core/intents/getIntent.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,oCAAkD;AAElD;;;;;;GAMG;AACI,MAAM,SAAS,GAAG,CAAC,GAKzB,EAAmB,EAAE;IACpB,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;IAE7C,OAAO;QACL,EAAE,EAAE,QAAQ;QACZ;;;WAGG;QACH,MAAM,EAAE,GAAS,EAAE;YACjB,OAAA,MAAM,SAAS,CAAC,QAAQ,CAAC,YAAY,CACnC,EAAE,OAAO,EAAE,QAAQ,EAAE,EACrB;gBACE,WAAW,EAAE,IAAA,8BAAsB,GAAE;aACtC,CACF,CAAA;UAAA;QACH;;;WAGG;QACH,OAAO,EAAE,GAAS,EAAE;YAClB,OAAA,MAAM,SAAS,CAAC,QAAQ,CAAC,aAAa,CACpC,EAAE,OAAO,EAAE,QAAQ,EAAE,EACrB;gBACE,WAAW,EAAE,IAAA,8BAAsB,GAAE;aACtC,CACF,CAAA;UAAA;KACJ,CAAC;AACJ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"getIntent.js","sourceRoot":"","sources":["../../../src/core/intents/getIntent.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,oCAAkD;AAElD;;;;;;GAMG;AACI,MAAM,SAAS,GAAG,CAAC,GAKzB,EAAmB,EAAE;IACpB,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;IAE7C,OAAO;QACL,EAAE,EAAE,QAAQ;QACZ;;;WAGG;QACH,MAAM,EAAE,GAAS,EAAE;YACjB,OAAA,MAAM,SAAS,CAAC,QAAQ,CAAC,YAAY,CACnC,EAAE,OAAO,EAAE,QAAQ,EAAE,EACrB;gBACE,WAAW,EAAE,IAAA,8BAAsB,GAAE;aACtC,CACF,CAAA;UAAA;QACH;;;WAGG;QACH,OAAO,EAAE,GAAS,EAAE;YAClB,OAAA,MAAM,SAAS,CAAC,QAAQ,CAAC,aAAa,CACpC,EAAE,OAAO,EAAE,QAAQ,EAAE,EACrB;gBACE,WAAW,EAAE,IAAA,8BAAsB,GAAE;aACtC,CACF,CAAA;UAAA;QACH;;;WAGG;QACH,MAAM,EAAE,GAAS,EAAE;YACjB,OAAA,MAAM,SAAS,CAAC,QAAQ,CAAC,YAAY,CACnC,EAAE,OAAO,EAAE,QAAQ,EAAE,EACrB;gBACE,WAAW,EAAE,IAAA,8BAAsB,GAAE;aACtC,CACF,CAAA;UAAA;KACJ,CAAC;AACJ,CAAC,CAAC;AA5CW,QAAA,SAAS,aA4CpB"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { createIntent } from './createIntent/createIntent';
|
|
2
|
+
export { createMoveIntentReq } from './createIntent/createMoveIntentReq';
|
|
3
|
+
export { updateMoveIntentReq } from './updateMoveIntentReq';
|
|
2
4
|
export { createTransferRequestIntentReq } from './createIntent/createTransferRequestIntent';
|
|
3
5
|
export { createLoanIntent } from './createLoanIntent';
|
|
4
6
|
export { executeIntent } from './executeIntent';
|
|
@@ -7,3 +9,4 @@ export { executeRedemptionIntent } from './executeRedemptionIntent';
|
|
|
7
9
|
export { getIntent } from './getIntent';
|
|
8
10
|
export { transfer } from './transfer';
|
|
9
11
|
export { executeTransferRequest } from './executeTransferRequest';
|
|
12
|
+
export { executeMoveIntent } from './executeMoveIntent';
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeTransferRequest = exports.transfer = exports.getIntent = exports.executeRedemptionIntent = exports.executeLoanIntent = exports.executeIntent = exports.createLoanIntent = exports.createTransferRequestIntentReq = exports.createIntent = void 0;
|
|
3
|
+
exports.executeMoveIntent = exports.executeTransferRequest = exports.transfer = exports.getIntent = exports.executeRedemptionIntent = exports.executeLoanIntent = exports.executeIntent = exports.createLoanIntent = exports.createTransferRequestIntentReq = exports.updateMoveIntentReq = exports.createMoveIntentReq = exports.createIntent = void 0;
|
|
4
4
|
var createIntent_1 = require("./createIntent/createIntent");
|
|
5
5
|
Object.defineProperty(exports, "createIntent", { enumerable: true, get: function () { return createIntent_1.createIntent; } });
|
|
6
|
+
var createMoveIntentReq_1 = require("./createIntent/createMoveIntentReq");
|
|
7
|
+
Object.defineProperty(exports, "createMoveIntentReq", { enumerable: true, get: function () { return createMoveIntentReq_1.createMoveIntentReq; } });
|
|
8
|
+
var updateMoveIntentReq_1 = require("./updateMoveIntentReq");
|
|
9
|
+
Object.defineProperty(exports, "updateMoveIntentReq", { enumerable: true, get: function () { return updateMoveIntentReq_1.updateMoveIntentReq; } });
|
|
6
10
|
var createTransferRequestIntent_1 = require("./createIntent/createTransferRequestIntent");
|
|
7
11
|
Object.defineProperty(exports, "createTransferRequestIntentReq", { enumerable: true, get: function () { return createTransferRequestIntent_1.createTransferRequestIntentReq; } });
|
|
8
12
|
var createLoanIntent_1 = require("./createLoanIntent");
|
|
@@ -19,4 +23,6 @@ var transfer_1 = require("./transfer");
|
|
|
19
23
|
Object.defineProperty(exports, "transfer", { enumerable: true, get: function () { return transfer_1.transfer; } });
|
|
20
24
|
var executeTransferRequest_1 = require("./executeTransferRequest");
|
|
21
25
|
Object.defineProperty(exports, "executeTransferRequest", { enumerable: true, get: function () { return executeTransferRequest_1.executeTransferRequest; } });
|
|
26
|
+
var executeMoveIntent_1 = require("./executeMoveIntent");
|
|
27
|
+
Object.defineProperty(exports, "executeMoveIntent", { enumerable: true, get: function () { return executeMoveIntent_1.executeMoveIntent; } });
|
|
22
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/intents/index.ts"],"names":[],"mappings":";;;AAAA,4DAA2D;AAAlD,4GAAA,YAAY,OAAA;AACrB,0FAA4F;AAAnF,6IAAA,8BAA8B,OAAA;AACvC,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAChC,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/intents/index.ts"],"names":[],"mappings":";;;AAAA,4DAA2D;AAAlD,4GAAA,YAAY,OAAA;AACrB,0EAAyE;AAAhE,0HAAA,mBAAmB,OAAA;AAC5B,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,0FAA4F;AAAnF,6IAAA,8BAA8B,OAAA;AACvC,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAChC,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CoreRequestOptions, Logger, OwneraAPIInterface, UpdateMoveIntent } from '../../types';
|
|
2
|
+
export interface UpdateMoveIntentPayload {
|
|
3
|
+
owneraAPI: OwneraAPIInterface;
|
|
4
|
+
logger: Logger;
|
|
5
|
+
updateIntentRequest: UpdateMoveIntent;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Edit a Move intent. Supports three kinds of edit, alone or combined:
|
|
9
|
+
* - Replace the allowed destination assets (source immutable). Each CAIP-19
|
|
10
|
+
* identifier is resolved via `resolveMoveAssetIdentifier` (fails loud if an
|
|
11
|
+
* asset can't be resolved), so callers pass SDK-facing `FinP2PAsset`s.
|
|
12
|
+
* - Change the active window via `start` / `end` (epoch ms → seconds).
|
|
13
|
+
* - Reject the intent via `status: 'Rejected'`.
|
|
14
|
+
*
|
|
15
|
+
* Custody-offered seg/pool fields are updatable with **omit = keep, not clear**
|
|
16
|
+
* semantics: `sourceToSegregatedAccount` is only put on the wire when supplied,
|
|
17
|
+
* so omitting it leaves the intent's existing value intact server-side. Never
|
|
18
|
+
* send a clearing value to mean "unchanged". Per-destination pools travel with
|
|
19
|
+
* the destinations that replace the list.
|
|
20
|
+
*
|
|
21
|
+
* At least one editable field is required. A status-only or window-only update
|
|
22
|
+
* sends no `intent` payload (the node's moveIntent update requires
|
|
23
|
+
* `destinationAssets`, so it's only sent when destinations are supplied — which
|
|
24
|
+
* also means changing `sourceToSegregatedAccount` requires re-sending the
|
|
25
|
+
* destination list).
|
|
26
|
+
*/
|
|
27
|
+
export declare const updateMoveIntentReq: (req: UpdateMoveIntentPayload, options?: CoreRequestOptions) => Promise<void>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.updateMoveIntentReq = void 0;
|
|
13
|
+
const helpers_1 = require("./createIntent/helpers");
|
|
14
|
+
/**
|
|
15
|
+
* Edit a Move intent. Supports three kinds of edit, alone or combined:
|
|
16
|
+
* - Replace the allowed destination assets (source immutable). Each CAIP-19
|
|
17
|
+
* identifier is resolved via `resolveMoveAssetIdentifier` (fails loud if an
|
|
18
|
+
* asset can't be resolved), so callers pass SDK-facing `FinP2PAsset`s.
|
|
19
|
+
* - Change the active window via `start` / `end` (epoch ms → seconds).
|
|
20
|
+
* - Reject the intent via `status: 'Rejected'`.
|
|
21
|
+
*
|
|
22
|
+
* Custody-offered seg/pool fields are updatable with **omit = keep, not clear**
|
|
23
|
+
* semantics: `sourceToSegregatedAccount` is only put on the wire when supplied,
|
|
24
|
+
* so omitting it leaves the intent's existing value intact server-side. Never
|
|
25
|
+
* send a clearing value to mean "unchanged". Per-destination pools travel with
|
|
26
|
+
* the destinations that replace the list.
|
|
27
|
+
*
|
|
28
|
+
* At least one editable field is required. A status-only or window-only update
|
|
29
|
+
* sends no `intent` payload (the node's moveIntent update requires
|
|
30
|
+
* `destinationAssets`, so it's only sent when destinations are supplied — which
|
|
31
|
+
* also means changing `sourceToSegregatedAccount` requires re-sending the
|
|
32
|
+
* destination list).
|
|
33
|
+
*/
|
|
34
|
+
const updateMoveIntentReq = (req, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
36
|
+
const { owneraAPI, logger, updateIntentRequest } = req;
|
|
37
|
+
const { assetId, intentId, destinationAsset, destinationAssets, sourceToSegregatedAccount, start, end, status } = updateIntentRequest;
|
|
38
|
+
// `destinationAssets` wins over the single-destination `destinationAsset` alias.
|
|
39
|
+
const destinations = destinationAssets !== null && destinationAssets !== void 0 ? destinationAssets : (destinationAsset ? [destinationAsset] : []);
|
|
40
|
+
const hasDestinations = destinations.length > 0;
|
|
41
|
+
if (!hasDestinations && start === undefined && end === undefined && !status && !sourceToSegregatedAccount) {
|
|
42
|
+
throw {
|
|
43
|
+
code: 400,
|
|
44
|
+
name: 'updateMoveIntentError',
|
|
45
|
+
message: 'Editing a move intent requires at least one of: destinationAsset(s), sourceToSegregatedAccount, start/end, or status.',
|
|
46
|
+
data: updateIntentRequest,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
// The node's moveIntent update payload requires `destinationAssets`, so a
|
|
50
|
+
// seg-account change can't ride on its own — fail here rather than sending a
|
|
51
|
+
// payload the node will reject.
|
|
52
|
+
if (sourceToSegregatedAccount && !hasDestinations) {
|
|
53
|
+
throw {
|
|
54
|
+
code: 400,
|
|
55
|
+
name: 'updateMoveIntentError',
|
|
56
|
+
message: "Updating sourceToSegregatedAccount requires re-sending destinationAsset(s); the node's move intent " +
|
|
57
|
+
'update payload requires a destination list.',
|
|
58
|
+
data: updateIntentRequest,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
(0, helpers_1.assertMoveDestinationPools)(destinations, 'updateMoveIntentError', updateIntentRequest);
|
|
62
|
+
// Resolve CAIP-19 for each destination (fail loud on unresolved assets),
|
|
63
|
+
// carrying each destination's optional pre-funded pool through.
|
|
64
|
+
const destinationAssetIdentifiers = hasDestinations
|
|
65
|
+
? yield Promise.all(destinations.map((d) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
return (Object.assign(Object.assign(Object.assign({}, (yield (0, helpers_1.resolveMoveAssetIdentifier)(owneraAPI, d.resourceId))), (d.fromSegregatedAccount ? { fromSegregatedAccount: d.fromSegregatedAccount } : {})), (d.fromSegregatedAccountOwner ? { fromSegregatedAccountOwner: d.fromSegregatedAccountOwner } : {})));
|
|
67
|
+
})))
|
|
68
|
+
: [];
|
|
69
|
+
logger.debug('🔵 [updateMoveIntent] destinationAssets:', JSON.stringify(destinationAssetIdentifiers, null, 2));
|
|
70
|
+
try {
|
|
71
|
+
return yield owneraAPI.profiles.updateIntent(Object.assign(Object.assign({ assetId,
|
|
72
|
+
intentId,
|
|
73
|
+
start,
|
|
74
|
+
end }, (status ? { status } : {})), (hasDestinations
|
|
75
|
+
? {
|
|
76
|
+
intent: Object.assign({ type: 'moveIntent', destinationAssets: destinationAssetIdentifiers }, (sourceToSegregatedAccount ? { sourceToSegregatedAccount } : {})),
|
|
77
|
+
}
|
|
78
|
+
: {})), { idempotency: options === null || options === void 0 ? void 0 : options.idempotencyKey });
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
logger.error('Update Move Intent Error', JSON.stringify(e));
|
|
82
|
+
const errorMessage = ((_b = (_a = e === null || e === void 0 ? void 0 : e.data) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.message) || ((_f = (_e = (_d = (_c = e === null || e === void 0 ? void 0 : e.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.message) || (e === null || e === void 0 ? void 0 : e.message) || e;
|
|
83
|
+
throw {
|
|
84
|
+
code: ((_h = (_g = e === null || e === void 0 ? void 0 : e.data) === null || _g === void 0 ? void 0 : _g.error) === null || _h === void 0 ? void 0 : _h.code) || (e === null || e === void 0 ? void 0 : e.code) || 500,
|
|
85
|
+
name: 'updateMoveIntentError',
|
|
86
|
+
message: typeof errorMessage === 'string' ? errorMessage : JSON.stringify(errorMessage),
|
|
87
|
+
data: updateIntentRequest,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
exports.updateMoveIntentReq = updateMoveIntentReq;
|
|
92
|
+
//# sourceMappingURL=updateMoveIntentReq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateMoveIntentReq.js","sourceRoot":"","sources":["../../../src/core/intents/updateMoveIntentReq.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oDAAgG;AAQhG;;;;;;;;;;;;;;;;;;;GAmBG;AACI,MAAM,mBAAmB,GAAG,CAAO,GAA4B,EAAE,OAA4B,EAAE,EAAE;;IACtG,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,GAAG,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAC7G,mBAAmB,CAAC;IAEtB,iFAAiF;IACjF,MAAM,YAAY,GAAG,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACvF,MAAM,eAAe,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IAEhD,IAAI,CAAC,eAAe,IAAI,KAAK,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,MAAM,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAC1G,MAAM;YACJ,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,uBAAuB;YAC7B,OAAO,EACL,uHAAuH;YACzH,IAAI,EAAE,mBAAmB;SAC1B,CAAC;IACJ,CAAC;IAED,0EAA0E;IAC1E,6EAA6E;IAC7E,gCAAgC;IAChC,IAAI,yBAAyB,IAAI,CAAC,eAAe,EAAE,CAAC;QAClD,MAAM;YACJ,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,uBAAuB;YAC7B,OAAO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