@centrifuge/sdk 1.9.0 → 1.9.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.
- package/dist/Centrifuge.d.ts.map +1 -1
- package/dist/Centrifuge.js +19 -13
- package/dist/Centrifuge.js.map +1 -1
- package/dist/entities/MerkleProofManager.d.ts.map +1 -1
- package/dist/entities/MerkleProofManager.js +3 -0
- package/dist/entities/MerkleProofManager.js.map +1 -1
- package/dist/entities/OnOffRampManager.d.ts.map +1 -1
- package/dist/entities/OnOffRampManager.js +10 -2
- package/dist/entities/OnOffRampManager.js.map +1 -1
- package/dist/entities/Pool.d.ts.map +1 -1
- package/dist/entities/Pool.js +21 -16
- package/dist/entities/Pool.js.map +1 -1
- package/dist/entities/PoolNetwork.d.ts.map +1 -1
- package/dist/entities/PoolNetwork.js +4 -0
- package/dist/entities/PoolNetwork.js.map +1 -1
- package/dist/entities/ShareClass.d.ts.map +1 -1
- package/dist/entities/ShareClass.js +57 -37
- package/dist/entities/ShareClass.js.map +1 -1
- package/dist/entities/Vault.d.ts.map +1 -1
- package/dist/entities/Vault.js +21 -4
- package/dist/entities/Vault.js.map +1 -1
- package/dist/utils/crosschainHotfix.d.ts +13 -0
- package/dist/utils/crosschainHotfix.d.ts.map +1 -0
- package/dist/utils/crosschainHotfix.js +33 -0
- package/dist/utils/crosschainHotfix.js.map +1 -0
- package/dist/utils/crosschainHotfix.test.d.ts +2 -0
- package/dist/utils/crosschainHotfix.test.d.ts.map +1 -0
- package/dist/utils/crosschainHotfix.test.js +25 -0
- package/dist/utils/crosschainHotfix.test.js.map +1 -0
- package/dist/utils/transaction.d.ts.map +1 -1
- package/dist/utils/transaction.js +4 -0
- package/dist/utils/transaction.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ import { MessageType } from '../types/transaction.js';
|
|
|
6
6
|
import { convertToEvmAddress } from '../utils/addresses.js';
|
|
7
7
|
import { AddressMap } from '../utils/AddressMap.js';
|
|
8
8
|
import { Balance, Price } from '../utils/BigInt.js';
|
|
9
|
+
import { addMessageForEnabledTarget, assertCrosschainMessagingEnabled, filterCrosschainEnabledTargets, isCrosschainMessagingDisabled, } from '../utils/crosschainHotfix.js';
|
|
9
10
|
import { addressToBytes32, encode, randomUint } from '../utils/index.js';
|
|
10
11
|
import { repeatOnEvents } from '../utils/rx.js';
|
|
11
12
|
import { wrapTransaction } from '../utils/transaction.js';
|
|
@@ -482,11 +483,6 @@ export class ShareClass extends Entity {
|
|
|
482
483
|
]);
|
|
483
484
|
const batch = [];
|
|
484
485
|
const messages = {};
|
|
485
|
-
function addMessage(centId, message) {
|
|
486
|
-
if (!messages[centId])
|
|
487
|
-
messages[centId] = [];
|
|
488
|
-
messages[centId].push(message);
|
|
489
|
-
}
|
|
490
486
|
batch.push(encodeFunctionData({
|
|
491
487
|
abi: ABI.Hub,
|
|
492
488
|
functionName: 'updateSharePrice',
|
|
@@ -498,8 +494,10 @@ export class ShareClass extends Entity {
|
|
|
498
494
|
],
|
|
499
495
|
}));
|
|
500
496
|
await Promise.all(activeNetworks.map(async (activeNetwork) => {
|
|
501
|
-
const networkDetails = await activeNetwork.details();
|
|
502
497
|
const id = activeNetwork.centrifugeId;
|
|
498
|
+
if (isCrosschainMessagingDisabled(id))
|
|
499
|
+
return;
|
|
500
|
+
const networkDetails = await activeNetwork.details();
|
|
503
501
|
const isShareClassInNetwork = networkDetails.activeShareClasses.find((shareClass) => shareClass.id.equals(self.id));
|
|
504
502
|
if (isShareClassInNetwork) {
|
|
505
503
|
batch.push(encodeFunctionData({
|
|
@@ -507,7 +505,10 @@ export class ShareClass extends Entity {
|
|
|
507
505
|
functionName: 'notifySharePrice',
|
|
508
506
|
args: [self.pool.id.raw, self.id.raw, id, ctx.signingAddress],
|
|
509
507
|
}));
|
|
510
|
-
|
|
508
|
+
addMessageForEnabledTarget(messages, id, {
|
|
509
|
+
type: MessageType.NotifyPricePoolPerShare,
|
|
510
|
+
poolId: self.pool.id,
|
|
511
|
+
});
|
|
511
512
|
}
|
|
512
513
|
}));
|
|
513
514
|
yield* wrapTransaction('Update share price', ctx, {
|
|
@@ -520,6 +521,7 @@ export class ShareClass extends Entity {
|
|
|
520
521
|
setMaxAssetPriceAge(assetId, maxPriceAge) {
|
|
521
522
|
const self = this;
|
|
522
523
|
return this._transact(async function* (ctx) {
|
|
524
|
+
assertCrosschainMessagingEnabled(assetId.centrifugeId);
|
|
523
525
|
const { hub } = await self._root._protocolAddresses(self.pool.centrifugeId);
|
|
524
526
|
yield* wrapTransaction('Set max asset price age', ctx, {
|
|
525
527
|
contract: hub,
|
|
@@ -537,6 +539,7 @@ export class ShareClass extends Entity {
|
|
|
537
539
|
setMaxSharePriceAge(centrifugeId, maxPriceAge) {
|
|
538
540
|
const self = this;
|
|
539
541
|
return this._transact(async function* (ctx) {
|
|
542
|
+
assertCrosschainMessagingEnabled(centrifugeId);
|
|
540
543
|
const { hub } = await self._root._protocolAddresses(self.pool.centrifugeId);
|
|
541
544
|
yield* wrapTransaction('Set max share price age', ctx, {
|
|
542
545
|
contract: hub,
|
|
@@ -554,6 +557,7 @@ export class ShareClass extends Entity {
|
|
|
554
557
|
notifyAssetPrice(assetId) {
|
|
555
558
|
const self = this;
|
|
556
559
|
return this._transact(async function* (ctx) {
|
|
560
|
+
assertCrosschainMessagingEnabled(assetId.centrifugeId);
|
|
557
561
|
const { hub } = await self._root._protocolAddresses(self.pool.centrifugeId);
|
|
558
562
|
yield* wrapTransaction('Notify asset price', ctx, {
|
|
559
563
|
contract: hub,
|
|
@@ -571,6 +575,7 @@ export class ShareClass extends Entity {
|
|
|
571
575
|
notifySharePrice(centrifugeId) {
|
|
572
576
|
const self = this;
|
|
573
577
|
return this._transact(async function* (ctx) {
|
|
578
|
+
assertCrosschainMessagingEnabled(centrifugeId);
|
|
574
579
|
const { hub } = await self._root._protocolAddresses(self.pool.centrifugeId);
|
|
575
580
|
yield* wrapTransaction('Notify share price', ctx, {
|
|
576
581
|
contract: hub,
|
|
@@ -605,9 +610,6 @@ export class ShareClass extends Entity {
|
|
|
605
610
|
}))),
|
|
606
611
|
]);
|
|
607
612
|
const pendingAmounts = pendingAmountsData.byVault;
|
|
608
|
-
const assetsWithApprove = assets.filter((a) => 'approveAssetAmount' in a).length;
|
|
609
|
-
const assetsWithIssue = assets.filter((a) => 'issuePricePerShare' in a).length;
|
|
610
|
-
const gasLimitPerAsset = assetsWithIssue ? GAS_LIMIT / BigInt(assetsWithIssue) : 0n;
|
|
611
613
|
const estimatePerMessage = 700000n;
|
|
612
614
|
const estimatePerMessageIfLocal = 360000n;
|
|
613
615
|
const ordersByAssetId = {};
|
|
@@ -627,14 +629,13 @@ export class ShareClass extends Entity {
|
|
|
627
629
|
if (uniqueAssets.size !== assets.length) {
|
|
628
630
|
throw new Error('Assets array contains multiple entries for the same asset ID');
|
|
629
631
|
}
|
|
632
|
+
const crosschainEnabledAssets = assets.filter((asset) => !isCrosschainMessagingDisabled(asset.assetId.centrifugeId));
|
|
633
|
+
const assetsWithApprove = crosschainEnabledAssets.filter((a) => 'approveAssetAmount' in a).length;
|
|
634
|
+
const assetsWithIssue = crosschainEnabledAssets.filter((a) => 'issuePricePerShare' in a).length;
|
|
635
|
+
const gasLimitPerAsset = assetsWithIssue ? GAS_LIMIT / BigInt(assetsWithIssue) : 0n;
|
|
630
636
|
const batch = [];
|
|
631
637
|
const messages = {};
|
|
632
|
-
|
|
633
|
-
if (!messages[centId])
|
|
634
|
-
messages[centId] = [];
|
|
635
|
-
messages[centId].push(message);
|
|
636
|
-
}
|
|
637
|
-
for (const asset of assets) {
|
|
638
|
+
for (const asset of crosschainEnabledAssets) {
|
|
638
639
|
const gasPerMessage = asset.assetId.centrifugeId === self.pool.centrifugeId ? estimatePerMessageIfLocal : estimatePerMessage;
|
|
639
640
|
let gasLeft = gasLimitPerAsset;
|
|
640
641
|
const pending = pendingAmounts.find((e) => e.assetId.equals(asset.assetId));
|
|
@@ -662,7 +663,10 @@ export class ShareClass extends Entity {
|
|
|
662
663
|
ctx.signingAddress,
|
|
663
664
|
],
|
|
664
665
|
}));
|
|
665
|
-
|
|
666
|
+
addMessageForEnabledTarget(messages, asset.assetId.centrifugeId, {
|
|
667
|
+
type: MessageType.RequestCallback,
|
|
668
|
+
poolId: self.pool.id,
|
|
669
|
+
});
|
|
666
670
|
gasLeft -= gasPerMessage;
|
|
667
671
|
nowDepositEpoch++;
|
|
668
672
|
}
|
|
@@ -693,7 +697,10 @@ export class ShareClass extends Entity {
|
|
|
693
697
|
ctx.signingAddress,
|
|
694
698
|
],
|
|
695
699
|
}));
|
|
696
|
-
|
|
700
|
+
addMessageForEnabledTarget(messages, asset.assetId.centrifugeId, {
|
|
701
|
+
type: MessageType.RequestCallback,
|
|
702
|
+
poolId: self.pool.id,
|
|
703
|
+
});
|
|
697
704
|
gasLeft -= gasPerMessage;
|
|
698
705
|
}
|
|
699
706
|
// If we've issued shares, also notify a number of invest orders
|
|
@@ -714,7 +721,10 @@ export class ShareClass extends Entity {
|
|
|
714
721
|
ctx.signingAddress,
|
|
715
722
|
],
|
|
716
723
|
}));
|
|
717
|
-
|
|
724
|
+
addMessageForEnabledTarget(messages, asset.assetId.centrifugeId, {
|
|
725
|
+
type: MessageType.RequestCallback,
|
|
726
|
+
poolId: self.pool.id,
|
|
727
|
+
});
|
|
718
728
|
}
|
|
719
729
|
});
|
|
720
730
|
}
|
|
@@ -757,9 +767,6 @@ export class ShareClass extends Entity {
|
|
|
757
767
|
}))),
|
|
758
768
|
]);
|
|
759
769
|
const pendingAmounts = pendingAmountsData.byVault;
|
|
760
|
-
const assetsWithApprove = assets.filter((a) => 'approveShareAmount' in a).length;
|
|
761
|
-
const assetsWithRevoke = assets.filter((a) => 'revokePricePerShare' in a).length;
|
|
762
|
-
const gasLimitPerAsset = assetsWithRevoke ? GAS_LIMIT / BigInt(assetsWithRevoke) : 0n;
|
|
763
770
|
const estimatePerMessage = 700000n;
|
|
764
771
|
const estimatePerMessageIfLocal = 360000n;
|
|
765
772
|
const ordersByAssetId = {};
|
|
@@ -779,14 +786,13 @@ export class ShareClass extends Entity {
|
|
|
779
786
|
if (uniqueAssets.size !== assets.length) {
|
|
780
787
|
throw new Error('Assets array contains multiple entries for the same asset ID');
|
|
781
788
|
}
|
|
789
|
+
const crosschainEnabledAssets = assets.filter((asset) => !isCrosschainMessagingDisabled(asset.assetId.centrifugeId));
|
|
790
|
+
const assetsWithApprove = crosschainEnabledAssets.filter((a) => 'approveShareAmount' in a).length;
|
|
791
|
+
const assetsWithRevoke = crosschainEnabledAssets.filter((a) => 'revokePricePerShare' in a).length;
|
|
792
|
+
const gasLimitPerAsset = assetsWithRevoke ? GAS_LIMIT / BigInt(assetsWithRevoke) : 0n;
|
|
782
793
|
const batch = [];
|
|
783
794
|
const messages = {};
|
|
784
|
-
|
|
785
|
-
if (!messages[centId])
|
|
786
|
-
messages[centId] = [];
|
|
787
|
-
messages[centId].push(message);
|
|
788
|
-
}
|
|
789
|
-
for (const asset of assets) {
|
|
795
|
+
for (const asset of crosschainEnabledAssets) {
|
|
790
796
|
const gasPerMessage = asset.assetId.centrifugeId === self.pool.centrifugeId ? estimatePerMessageIfLocal : estimatePerMessage;
|
|
791
797
|
let gasLeft = gasLimitPerAsset;
|
|
792
798
|
const pending = pendingAmounts.find((e) => e.assetId.equals(asset.assetId));
|
|
@@ -842,7 +848,10 @@ export class ShareClass extends Entity {
|
|
|
842
848
|
ctx.signingAddress,
|
|
843
849
|
],
|
|
844
850
|
}));
|
|
845
|
-
|
|
851
|
+
addMessageForEnabledTarget(messages, asset.assetId.centrifugeId, {
|
|
852
|
+
type: MessageType.RequestCallback,
|
|
853
|
+
poolId: self.pool.id,
|
|
854
|
+
});
|
|
846
855
|
gasLeft -= gasPerMessage;
|
|
847
856
|
}
|
|
848
857
|
// If we've revoked shares, also notify a number of redeem orders
|
|
@@ -863,7 +872,10 @@ export class ShareClass extends Entity {
|
|
|
863
872
|
ctx.signingAddress,
|
|
864
873
|
],
|
|
865
874
|
}));
|
|
866
|
-
|
|
875
|
+
addMessageForEnabledTarget(messages, asset.assetId.centrifugeId, {
|
|
876
|
+
type: MessageType.RequestCallback,
|
|
877
|
+
poolId: self.pool.id,
|
|
878
|
+
});
|
|
867
879
|
}
|
|
868
880
|
});
|
|
869
881
|
}
|
|
@@ -893,6 +905,7 @@ export class ShareClass extends Entity {
|
|
|
893
905
|
claimDeposit(assetId, investor) {
|
|
894
906
|
const self = this;
|
|
895
907
|
return this._transact(async function* (ctx) {
|
|
908
|
+
assertCrosschainMessagingEnabled(assetId.centrifugeId);
|
|
896
909
|
const [{ batchRequestManager }, investorOrder] = await Promise.all([
|
|
897
910
|
self._root._protocolAddresses(self.pool.centrifugeId),
|
|
898
911
|
self._investorOrder(assetId, investor),
|
|
@@ -922,6 +935,7 @@ export class ShareClass extends Entity {
|
|
|
922
935
|
claimRedeem(assetId, investor) {
|
|
923
936
|
const self = this;
|
|
924
937
|
return this._transact(async function* (ctx) {
|
|
938
|
+
assertCrosschainMessagingEnabled(assetId.centrifugeId);
|
|
925
939
|
const [{ batchRequestManager }, investorOrder] = await Promise.all([
|
|
926
940
|
self._root._protocolAddresses(self.pool.centrifugeId),
|
|
927
941
|
self._investorOrder(assetId, investor),
|
|
@@ -966,12 +980,7 @@ export class ShareClass extends Entity {
|
|
|
966
980
|
const { hub } = await self._root._protocolAddresses(self.pool.centrifugeId);
|
|
967
981
|
const batch = [];
|
|
968
982
|
const messages = {};
|
|
969
|
-
|
|
970
|
-
if (!messages[centId])
|
|
971
|
-
messages[centId] = [];
|
|
972
|
-
messages[centId].push(message);
|
|
973
|
-
}
|
|
974
|
-
members.forEach((member) => {
|
|
983
|
+
filterCrosschainEnabledTargets(members).forEach((member) => {
|
|
975
984
|
batch.push(encodeFunctionData({
|
|
976
985
|
abi: ABI.Hub,
|
|
977
986
|
functionName: 'updateRestriction',
|
|
@@ -984,7 +993,10 @@ export class ShareClass extends Entity {
|
|
|
984
993
|
ctx.signingAddress,
|
|
985
994
|
],
|
|
986
995
|
}));
|
|
987
|
-
|
|
996
|
+
addMessageForEnabledTarget(messages, member.centrifugeId, {
|
|
997
|
+
type: MessageType.UpdateRestriction,
|
|
998
|
+
poolId: self.pool.id,
|
|
999
|
+
});
|
|
988
1000
|
});
|
|
989
1001
|
if (batch.length === 0) {
|
|
990
1002
|
throw new Error('No data to update members');
|
|
@@ -1195,6 +1207,7 @@ export class ShareClass extends Entity {
|
|
|
1195
1207
|
freezeMember(address, centrifugeId) {
|
|
1196
1208
|
const self = this;
|
|
1197
1209
|
return this._transact(async function* (ctx) {
|
|
1210
|
+
assertCrosschainMessagingEnabled(centrifugeId);
|
|
1198
1211
|
const { hub } = await self._root._protocolAddresses(self.pool.centrifugeId);
|
|
1199
1212
|
const payload = encodePacked(['uint8', 'bytes32'], [/* UpdateRestrictionType.Freeze */ 2, addressToBytes32(address)]);
|
|
1200
1213
|
yield* wrapTransaction('Freeze member', ctx, {
|
|
@@ -1216,6 +1229,7 @@ export class ShareClass extends Entity {
|
|
|
1216
1229
|
unfreezeMember(address, centrifugeId) {
|
|
1217
1230
|
const self = this;
|
|
1218
1231
|
return this._transact(async function* (ctx) {
|
|
1232
|
+
assertCrosschainMessagingEnabled(centrifugeId);
|
|
1219
1233
|
const { hub } = await self._root._protocolAddresses(self.pool.centrifugeId);
|
|
1220
1234
|
const payload = encodePacked(['uint8', 'bytes32'], [/* UpdateRestrictionType.Unfreeze */ 3, addressToBytes32(address)]);
|
|
1221
1235
|
yield* wrapTransaction('Unfreeze member', ctx, {
|
|
@@ -1802,6 +1816,7 @@ export class ShareClass extends Entity {
|
|
|
1802
1816
|
updateValuation(centrifugeId, valuation) {
|
|
1803
1817
|
const self = this;
|
|
1804
1818
|
return this._transact(async function* (ctx) {
|
|
1819
|
+
assertCrosschainMessagingEnabled(centrifugeId);
|
|
1805
1820
|
const [{ hub }, spokeAddresses] = await Promise.all([
|
|
1806
1821
|
self._root._protocolAddresses(self.pool.centrifugeId),
|
|
1807
1822
|
self._root._protocolAddresses(centrifugeId),
|
|
@@ -1833,6 +1848,7 @@ export class ShareClass extends Entity {
|
|
|
1833
1848
|
updateHook(centrifugeId, hook) {
|
|
1834
1849
|
const self = this;
|
|
1835
1850
|
return this._transact(async function* (ctx) {
|
|
1851
|
+
assertCrosschainMessagingEnabled(centrifugeId);
|
|
1836
1852
|
const { hub } = await self._root._protocolAddresses(self.pool.centrifugeId);
|
|
1837
1853
|
yield* wrapTransaction('Update hook', ctx, {
|
|
1838
1854
|
contract: hub,
|
|
@@ -1857,6 +1873,7 @@ export class ShareClass extends Entity {
|
|
|
1857
1873
|
}
|
|
1858
1874
|
const self = this;
|
|
1859
1875
|
return this._transact(async function* (ctx) {
|
|
1876
|
+
assertCrosschainMessagingEnabled(centrifugeId);
|
|
1860
1877
|
const [{ hub }, spokeAddresses] = await Promise.all([
|
|
1861
1878
|
self._root._protocolAddresses(self.pool.centrifugeId),
|
|
1862
1879
|
self._root._protocolAddresses(centrifugeId),
|
|
@@ -1998,6 +2015,8 @@ export class ShareClass extends Entity {
|
|
|
1998
2015
|
crosschainTransferShares(sourceCentrifugeId, destinationCentrifugeId, receiver, amount) {
|
|
1999
2016
|
const self = this;
|
|
2000
2017
|
return this._transact(async function* (ctx) {
|
|
2018
|
+
assertCrosschainMessagingEnabled(sourceCentrifugeId);
|
|
2019
|
+
assertCrosschainMessagingEnabled(destinationCentrifugeId);
|
|
2001
2020
|
const { spoke } = await self._root._protocolAddresses(sourceCentrifugeId);
|
|
2002
2021
|
yield* wrapTransaction('Cross chain transfer shares', ctx, {
|
|
2003
2022
|
contract: spoke,
|
|
@@ -2595,6 +2614,7 @@ export class ShareClass extends Entity {
|
|
|
2595
2614
|
_updateContract(centrifugeId, target, payload) {
|
|
2596
2615
|
const self = this;
|
|
2597
2616
|
return this._transact(async function* (ctx) {
|
|
2617
|
+
assertCrosschainMessagingEnabled(centrifugeId);
|
|
2598
2618
|
const { hub } = await self._root._protocolAddresses(self.pool.centrifugeId);
|
|
2599
2619
|
yield* wrapTransaction('Update contract', ctx, {
|
|
2600
2620
|
contract: hub,
|