@fairmint/canton-node-sdk 0.0.53 → 0.0.55
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.
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { LedgerJsonApiClient } from '../../clients/ledger-json-api';
|
|
2
2
|
import { ValidatorApiClient } from '../../clients/validator-api';
|
|
3
|
+
export interface TransferPreapprovalInfo {
|
|
4
|
+
/** Contract ID of the TransferPreapproval contract */
|
|
5
|
+
contractId: string;
|
|
6
|
+
/** Template ID of the TransferPreapproval contract */
|
|
7
|
+
templateId: string;
|
|
8
|
+
/** Created event blob of the TransferPreapproval contract */
|
|
9
|
+
createdEventBlob: string;
|
|
10
|
+
/** Synchronizer ID where the TransferPreapproval contract resides */
|
|
11
|
+
synchronizerId: string;
|
|
12
|
+
}
|
|
3
13
|
export interface TransferToPreapprovedParams {
|
|
4
14
|
/** Party ID sending the transfer */
|
|
5
15
|
senderPartyId: string;
|
|
6
|
-
/** TransferPreapproval contract
|
|
7
|
-
|
|
16
|
+
/** TransferPreapproval contract information (required for disclosure) */
|
|
17
|
+
transferPreapproval: TransferPreapprovalInfo;
|
|
8
18
|
/** Amount to transfer */
|
|
9
19
|
amount: string;
|
|
10
20
|
/** Optional description for the transfer */
|
|
@@ -14,25 +24,6 @@ export interface TransferToPreapprovedParams {
|
|
|
14
24
|
tag: 'InputAmulet';
|
|
15
25
|
value: string;
|
|
16
26
|
}>;
|
|
17
|
-
/** Contract details for disclosed contracts (optional - will be fetched if not provided) */
|
|
18
|
-
contractDetails?: {
|
|
19
|
-
amuletRules?: {
|
|
20
|
-
createdEventBlob: string;
|
|
21
|
-
synchronizerId: string;
|
|
22
|
-
};
|
|
23
|
-
openMiningRound?: {
|
|
24
|
-
createdEventBlob: string;
|
|
25
|
-
synchronizerId: string;
|
|
26
|
-
};
|
|
27
|
-
issuingMiningRounds?: Array<{
|
|
28
|
-
createdEventBlob: string;
|
|
29
|
-
synchronizerId: string;
|
|
30
|
-
}>;
|
|
31
|
-
featuredAppRight?: {
|
|
32
|
-
createdEventBlob: string;
|
|
33
|
-
synchronizerId: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
27
|
}
|
|
37
28
|
export interface TransferToPreapprovedResult {
|
|
38
29
|
/** Contract ID of the TransferPreapproval contract used */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer-to-preapproved.d.ts","sourceRoot":"","sources":["../../../../src/utils/amulet/transfer-to-preapproved.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"transfer-to-preapproved.d.ts","sourceRoot":"","sources":["../../../../src/utils/amulet/transfer-to-preapproved.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAKjE,MAAM,WAAW,uBAAuB;IACtC,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,gBAAgB,EAAE,MAAM,CAAC;IACzB,qEAAqE;IACrE,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,2BAA2B;IAC1C,oCAAoC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,mBAAmB,EAAE,uBAAuB,CAAC;IAC7C,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gCAAgC;IAChC,MAAM,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,aAAa,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtD;AAED,MAAM,WAAW,2BAA2B;IAC1C,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,cAAc,EAAE,GAAG,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,mBAAmB,EACjC,eAAe,EAAE,kBAAkB,EACnC,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC,2BAA2B,CAAC,CAsFtC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transferToPreapproved = transferToPreapproved;
|
|
4
4
|
const mining_rounds_1 = require("./mining-rounds");
|
|
5
|
+
const disclosed_contracts_1 = require("./disclosed-contracts");
|
|
5
6
|
/**
|
|
6
7
|
* Transfers coins to a party that has pre-approved transfers enabled
|
|
7
8
|
*
|
|
@@ -17,12 +18,12 @@ async function transferToPreapproved(ledgerClient, validatorClient, params) {
|
|
|
17
18
|
(0, mining_rounds_1.getCurrentMiningRoundContext)(validatorClient),
|
|
18
19
|
validatorClient.lookupFeaturedAppRight({ partyId: params.senderPartyId })
|
|
19
20
|
]);
|
|
20
|
-
const { openMiningRound: openMiningRoundContractId,
|
|
21
|
+
const { openMiningRound: openMiningRoundContractId, } = miningRoundContext;
|
|
21
22
|
// Create the transfer command using TransferPreapproval_Send
|
|
22
23
|
const transferCommand = {
|
|
23
24
|
ExerciseCommand: {
|
|
24
25
|
templateId: '#splice-amulet:Splice.AmuletRules:TransferPreapproval',
|
|
25
|
-
contractId: params.
|
|
26
|
+
contractId: params.transferPreapproval.contractId,
|
|
26
27
|
choice: 'TransferPreapproval_Send',
|
|
27
28
|
choiceArgument: {
|
|
28
29
|
context: {
|
|
@@ -41,63 +42,32 @@ async function transferToPreapproved(ledgerClient, validatorClient, params) {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
|
-
// Build disclosed contracts
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
// Add open mining round contract
|
|
58
|
-
if (openMiningRoundContractId && params.contractDetails.openMiningRound) {
|
|
59
|
-
disclosedContracts.push({
|
|
60
|
-
contractId: openMiningRoundContractId,
|
|
61
|
-
createdEventBlob: params.contractDetails.openMiningRound.createdEventBlob,
|
|
62
|
-
synchronizerId: params.contractDetails.openMiningRound.synchronizerId,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
// Add issuing mining rounds contracts
|
|
66
|
-
if (params.contractDetails.issuingMiningRounds) {
|
|
67
|
-
params.contractDetails.issuingMiningRounds.forEach((details, index) => {
|
|
68
|
-
const contractId = issuingMiningRounds[index]?.contractId;
|
|
69
|
-
if (contractId) {
|
|
70
|
-
disclosedContracts.push({
|
|
71
|
-
contractId,
|
|
72
|
-
createdEventBlob: details.createdEventBlob,
|
|
73
|
-
synchronizerId: details.synchronizerId,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
// Add featured app right contract
|
|
79
|
-
if (featuredAppRight.featured_app_right?.contract_id && params.contractDetails.featuredAppRight) {
|
|
80
|
-
disclosedContracts.push({
|
|
81
|
-
contractId: featuredAppRight.featured_app_right.contract_id,
|
|
82
|
-
createdEventBlob: params.contractDetails.featuredAppRight.createdEventBlob,
|
|
83
|
-
synchronizerId: params.contractDetails.featuredAppRight.synchronizerId,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
45
|
+
// Build disclosed contracts (TransferPreapproval contract details are provided explicitly)
|
|
46
|
+
const transferPreapprovalContractInfo = (0, disclosed_contracts_1.createContractInfo)(params.transferPreapproval.contractId, params.transferPreapproval.createdEventBlob, params.transferPreapproval.synchronizerId, params.transferPreapproval.templateId);
|
|
47
|
+
// Build the full disclosed contracts list
|
|
48
|
+
const disclosedContractsParams = {
|
|
49
|
+
amuletRules: (0, disclosed_contracts_1.createContractInfo)(amuletRules.amulet_rules.contract.contract_id, amuletRules.amulet_rules.contract.created_event_blob, amuletRules.amulet_rules.domain_id || '', amuletRules.amulet_rules.contract.template_id),
|
|
50
|
+
openMiningRound: miningRoundContext.openMiningRoundContract,
|
|
51
|
+
};
|
|
52
|
+
if (featuredAppRight.featured_app_right) {
|
|
53
|
+
disclosedContractsParams.featuredAppRight = (0, disclosed_contracts_1.createContractInfo)(featuredAppRight.featured_app_right.contract_id, featuredAppRight.featured_app_right.created_event_blob, featuredAppRight.featured_app_right.domain_id, featuredAppRight.featured_app_right.template_id);
|
|
54
|
+
}
|
|
55
|
+
if (transferPreapprovalContractInfo) {
|
|
56
|
+
disclosedContractsParams.additionalContracts = [transferPreapprovalContractInfo];
|
|
86
57
|
}
|
|
58
|
+
const disclosedContracts = (0, disclosed_contracts_1.buildAmuletDisclosedContracts)(disclosedContractsParams);
|
|
87
59
|
// Submit the command
|
|
88
60
|
const submitParams = {
|
|
89
61
|
commands: [transferCommand],
|
|
90
62
|
commandId: `transfer-preapproved-${Date.now()}`,
|
|
91
63
|
actAs: [params.senderPartyId],
|
|
64
|
+
disclosedContracts,
|
|
92
65
|
};
|
|
93
|
-
if (disclosedContracts) {
|
|
94
|
-
submitParams.disclosedContracts = disclosedContracts;
|
|
95
|
-
}
|
|
96
66
|
const result = await ledgerClient.submitAndWaitForTransactionTree(submitParams);
|
|
97
67
|
return {
|
|
98
|
-
contractId: params.
|
|
68
|
+
contractId: params.transferPreapproval.contractId,
|
|
99
69
|
domainId: amuletRules.amulet_rules.domain_id || '',
|
|
100
|
-
transferResult: result
|
|
70
|
+
transferResult: result,
|
|
101
71
|
};
|
|
102
72
|
}
|
|
103
73
|
//# sourceMappingURL=transfer-to-preapproved.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer-to-preapproved.js","sourceRoot":"","sources":["../../../../src/utils/amulet/transfer-to-preapproved.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"transfer-to-preapproved.js","sourceRoot":"","sources":["../../../../src/utils/amulet/transfer-to-preapproved.ts"],"names":[],"mappings":";;AA+CA,sDA0FC;AAtID,mDAA+D;AAC/D,+DAA0F;AAmC1F;;;;;;;GAOG;AACI,KAAK,UAAU,qBAAqB,CACzC,YAAiC,EACjC,eAAmC,EACnC,MAAmC;IAEnC,0BAA0B;IAC1B,MAAM,CAAC,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC5E,eAAe,CAAC,cAAc,EAAE;QAChC,IAAA,4CAA4B,EAAC,eAAe,CAAC;QAC7C,eAAe,CAAC,sBAAsB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;KAC1E,CAAC,CAAC;IAEH,MAAM,EACJ,eAAe,EAAE,yBAAyB,GAC3C,GAAG,kBAAkB,CAAC;IAEvB,6DAA6D;IAC7D,MAAM,eAAe,GAAoB;QACvC,eAAe,EAAE;YACf,UAAU,EAAE,uDAAuD;YACnE,UAAU,EAAE,MAAM,CAAC,mBAAmB,CAAC,UAAU;YACjD,MAAM,EAAE,0BAA0B;YAClC,cAAc,EAAE;gBACd,OAAO,EAAE;oBACP,WAAW,EAAE,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW;oBAC1D,OAAO,EAAE;wBACP,eAAe,EAAE,yBAAyB;wBAC1C,mBAAmB,EAAE,EAAE;wBACvB,eAAe,EAAE,EAAE;wBACnB,gBAAgB,EAAE,gBAAgB,CAAC,kBAAkB,EAAE,WAAW,IAAI,IAAI;qBAC3E;iBACF;gBACD,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,MAAM,EAAE,MAAM,CAAC,aAAa;gBAC5B,WAAW,EAAE,MAAM,CAAC,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