@credenza3/contracts-lib-sui 0.2.11 → 0.2.14
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/cjs/client/index.cjs +76 -46
- package/dist/cjs/client/index.cjs.map +3 -3
- package/dist/cjs/client/modules/CredenzaAssetCollection.d.ts +1 -1
- package/dist/cjs/client/modules/CredenzaLedger/CredenzaMetaLedgerV2.d.ts +3 -1
- package/dist/esm/client/index.mjs +76 -46
- package/dist/esm/client/index.mjs.map +3 -3
- package/dist/esm/client/modules/CredenzaAssetCollection.d.ts +1 -1
- package/dist/esm/client/modules/CredenzaLedger/CredenzaMetaLedgerV2.d.ts +3 -1
- package/dist/umd/client/index.js +29 -29
- package/dist/umd/client/index.js.map +3 -3
- package/package.json +1 -1
|
@@ -828,11 +828,11 @@ var require_baseGet = __commonJS({
|
|
|
828
828
|
var require_get = __commonJS({
|
|
829
829
|
"node_modules/.pnpm/lodash@4.17.23/node_modules/lodash/get.js"(exports, module2) {
|
|
830
830
|
var baseGet = require_baseGet();
|
|
831
|
-
function
|
|
831
|
+
function get9(object, path, defaultValue) {
|
|
832
832
|
var result = object == null ? void 0 : baseGet(object, path);
|
|
833
833
|
return result === void 0 ? defaultValue : result;
|
|
834
834
|
}
|
|
835
|
-
module2.exports =
|
|
835
|
+
module2.exports = get9;
|
|
836
836
|
}
|
|
837
837
|
});
|
|
838
838
|
|
|
@@ -3784,7 +3784,7 @@ var require_hasIn = __commonJS({
|
|
|
3784
3784
|
var require_baseMatchesProperty = __commonJS({
|
|
3785
3785
|
"node_modules/.pnpm/lodash@4.17.23/node_modules/lodash/_baseMatchesProperty.js"(exports, module2) {
|
|
3786
3786
|
var baseIsEqual = require_baseIsEqual();
|
|
3787
|
-
var
|
|
3787
|
+
var get9 = require_get();
|
|
3788
3788
|
var hasIn = require_hasIn();
|
|
3789
3789
|
var isKey = require_isKey();
|
|
3790
3790
|
var isStrictComparable = require_isStrictComparable();
|
|
@@ -3797,7 +3797,7 @@ var require_baseMatchesProperty = __commonJS({
|
|
|
3797
3797
|
return matchesStrictComparable(toKey(path), srcValue);
|
|
3798
3798
|
}
|
|
3799
3799
|
return function(object) {
|
|
3800
|
-
var objValue =
|
|
3800
|
+
var objValue = get9(object, path);
|
|
3801
3801
|
return objValue === void 0 && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
|
|
3802
3802
|
};
|
|
3803
3803
|
}
|
|
@@ -4133,6 +4133,7 @@ var CredenzaLedger = class extends CredenzaSuiModule {
|
|
|
4133
4133
|
|
|
4134
4134
|
// src/client/modules/CredenzaLedger/CredenzaMetaLedgerV2.ts
|
|
4135
4135
|
var import_transactions3 = require("@mysten/sui/transactions");
|
|
4136
|
+
var import_get2 = __toESM(require_get());
|
|
4136
4137
|
var CredenzaMetaLedgerV2 = class extends CredenzaSuiModule {
|
|
4137
4138
|
async addPoints(userAddress, amount, eventId, meta = "") {
|
|
4138
4139
|
const tx = new import_transactions3.Transaction();
|
|
@@ -4156,12 +4157,16 @@ var CredenzaMetaLedgerV2 = class extends CredenzaSuiModule {
|
|
|
4156
4157
|
});
|
|
4157
4158
|
return this.client.signAndExecuteTransaction(tx);
|
|
4158
4159
|
}
|
|
4159
|
-
async
|
|
4160
|
+
async convertPointsToCoins(amount) {
|
|
4160
4161
|
const tx = new import_transactions3.Transaction();
|
|
4162
|
+
const coinType = await this.getConvertableCoinType();
|
|
4163
|
+
if (!coinType) {
|
|
4164
|
+
throw new Error(`Ledger Contract does not have coin set to convert points into`);
|
|
4165
|
+
}
|
|
4161
4166
|
tx.moveCall({
|
|
4162
4167
|
target: `${this.client.getPackageId()}::credenza_meta_loyalty_v2::convert_points_to_coins`,
|
|
4163
4168
|
arguments: [tx.object(await this.getLoyaltyConfig()), tx.pure.u64(amount)],
|
|
4164
|
-
typeArguments: [
|
|
4169
|
+
typeArguments: [coinType]
|
|
4165
4170
|
});
|
|
4166
4171
|
return this.client.signAndExecuteTransaction(tx);
|
|
4167
4172
|
}
|
|
@@ -4228,11 +4233,35 @@ var CredenzaMetaLedgerV2 = class extends CredenzaSuiModule {
|
|
|
4228
4233
|
});
|
|
4229
4234
|
return this.client.signAndExecuteTransaction(tx);
|
|
4230
4235
|
}
|
|
4236
|
+
async setCoinForConverting(coinId, rate) {
|
|
4237
|
+
const coin = await this.client.getObjectGrpc(coinId);
|
|
4238
|
+
const coinType = coin.object_type.split("<")[1]?.split(">")[0];
|
|
4239
|
+
let oldCoinType = await this.getConvertableCoinType();
|
|
4240
|
+
if (!oldCoinType) {
|
|
4241
|
+
oldCoinType = coinType;
|
|
4242
|
+
}
|
|
4243
|
+
const tx = new import_transactions3.Transaction();
|
|
4244
|
+
tx.moveCall({
|
|
4245
|
+
target: `${this.client.getPackageId()}::credenza_meta_loyalty_v2::set_coin`,
|
|
4246
|
+
arguments: [tx.object(await this.getLoyaltyConfig()), tx.object(coinId), tx.pure.u64(rate)],
|
|
4247
|
+
typeArguments: [oldCoinType, coinType]
|
|
4248
|
+
});
|
|
4249
|
+
return this.client.signAndExecuteTransaction(tx);
|
|
4250
|
+
}
|
|
4251
|
+
async getConvertableCoinType() {
|
|
4252
|
+
const config = await this.client.getObjectGrpc(await this.getLoyaltyConfig());
|
|
4253
|
+
let ret = null;
|
|
4254
|
+
if (parseInt((0, import_get2.default)(config, "json.coin.size"))) {
|
|
4255
|
+
const fieldData = await this.client.getDynamicFields((0, import_get2.default)(config, "json.coin.id"));
|
|
4256
|
+
ret = (0, import_get2.default)(fieldData, "0.type").split("object::ID,")[1].split("<")[1].split(">")[0];
|
|
4257
|
+
}
|
|
4258
|
+
return ret;
|
|
4259
|
+
}
|
|
4231
4260
|
};
|
|
4232
4261
|
|
|
4233
4262
|
// src/client/modules/CredenzaMembership.ts
|
|
4234
4263
|
var import_transactions4 = require("@mysten/sui/transactions");
|
|
4235
|
-
var
|
|
4264
|
+
var import_get3 = __toESM(require_get());
|
|
4236
4265
|
var import_isNil = __toESM(require_isNil());
|
|
4237
4266
|
var CredenzaMembership = class extends CredenzaSuiModule {
|
|
4238
4267
|
async addMembership(userAddress, metadata) {
|
|
@@ -4346,7 +4375,7 @@ var CredenzaMembership = class extends CredenzaSuiModule {
|
|
|
4346
4375
|
async getOwners() {
|
|
4347
4376
|
const id = await this.getMembershipListId();
|
|
4348
4377
|
const data = await this.client.getObjectGrpc(id);
|
|
4349
|
-
return (0,
|
|
4378
|
+
return (0, import_get3.default)(data, "json.ownership.owners.contents");
|
|
4350
4379
|
}
|
|
4351
4380
|
async setOwner(recipient, isOwner) {
|
|
4352
4381
|
const tx = new import_transactions4.Transaction();
|
|
@@ -4360,7 +4389,7 @@ var CredenzaMembership = class extends CredenzaSuiModule {
|
|
|
4360
4389
|
|
|
4361
4390
|
// src/client/modules/CredenzaDecom.ts
|
|
4362
4391
|
var import_transactions5 = require("@mysten/sui/transactions");
|
|
4363
|
-
var
|
|
4392
|
+
var import_get4 = __toESM(require_get());
|
|
4364
4393
|
var CredenzaDecom = class extends CredenzaSuiModule {
|
|
4365
4394
|
getDecomType() {
|
|
4366
4395
|
return `${this.client.getPackageId()}::decom::DECOM`;
|
|
@@ -4410,12 +4439,12 @@ var CredenzaDecom = class extends CredenzaSuiModule {
|
|
|
4410
4439
|
async getOwnerRenderData() {
|
|
4411
4440
|
const capId = await this.getAdminCap();
|
|
4412
4441
|
const data = await this.client.getObjectGrpc(capId);
|
|
4413
|
-
return (0,
|
|
4442
|
+
return (0, import_get4.default)(data, "json.owner_render_data");
|
|
4414
4443
|
}
|
|
4415
4444
|
async getRenderData() {
|
|
4416
4445
|
const capId = await this.getAdminCap();
|
|
4417
4446
|
const data = await this.client.getObjectGrpc(capId);
|
|
4418
|
-
return (0,
|
|
4447
|
+
return (0, import_get4.default)(data, "json.render_data");
|
|
4419
4448
|
}
|
|
4420
4449
|
async writeRenderData(data) {
|
|
4421
4450
|
const tx = new import_transactions5.Transaction();
|
|
@@ -4469,7 +4498,7 @@ var CredenzaDecom = class extends CredenzaSuiModule {
|
|
|
4469
4498
|
async getOwners() {
|
|
4470
4499
|
const capId = await this.getAdminCap();
|
|
4471
4500
|
const data = await this.client.getObjectGrpc(capId);
|
|
4472
|
-
return (0,
|
|
4501
|
+
return (0, import_get4.default)(data, "json.ownership.owners.contents");
|
|
4473
4502
|
}
|
|
4474
4503
|
async setOwner(recipient, isOwner) {
|
|
4475
4504
|
const tx = new import_transactions5.Transaction();
|
|
@@ -4493,7 +4522,7 @@ var CredenzaDecom = class extends CredenzaSuiModule {
|
|
|
4493
4522
|
// src/client/modules/Sellable.ts
|
|
4494
4523
|
var import_transactions6 = require("@mysten/sui/transactions");
|
|
4495
4524
|
var import_buffer = __toESM(require_buffer());
|
|
4496
|
-
var
|
|
4525
|
+
var import_get5 = __toESM(require_get());
|
|
4497
4526
|
var Sellable = class extends CredenzaSuiModule {
|
|
4498
4527
|
async getSellConfig(assetType) {
|
|
4499
4528
|
const id = await this.client.graphqlClient.findSharedObjectByType(
|
|
@@ -4513,9 +4542,9 @@ var Sellable = class extends CredenzaSuiModule {
|
|
|
4513
4542
|
let oldCoinType = coinType;
|
|
4514
4543
|
const config = await this.client.getObjectGrpc(sellConfig);
|
|
4515
4544
|
const sellableType = await this.getSellableType(sellConfig);
|
|
4516
|
-
if (parseInt((0,
|
|
4517
|
-
const fieldData = await this.client.getDynamicFields((0,
|
|
4518
|
-
oldCoinType = (0,
|
|
4545
|
+
if (parseInt((0, import_get5.default)(config, "json.coin.size"))) {
|
|
4546
|
+
const fieldData = await this.client.getDynamicFields((0, import_get5.default)(config, "json.coin.id"));
|
|
4547
|
+
oldCoinType = (0, import_get5.default)(fieldData, "0.type").split("object::ID,")[1].split("<")[1].split(">")[0];
|
|
4519
4548
|
}
|
|
4520
4549
|
const tx = new import_transactions6.Transaction();
|
|
4521
4550
|
tx.moveCall({
|
|
@@ -4614,14 +4643,14 @@ var Sellable = class extends CredenzaSuiModule {
|
|
|
4614
4643
|
currency
|
|
4615
4644
|
}) {
|
|
4616
4645
|
const obj = await this.client.getObjectGrpc(sellConfig);
|
|
4617
|
-
const fields = await this.client.getDynamicFields((0,
|
|
4646
|
+
const fields = await this.client.getDynamicFields((0, import_get5.default)(obj, "json.asset_prices.id"));
|
|
4618
4647
|
for (const field of fields) {
|
|
4619
4648
|
if (field.name === `${assetId}`) {
|
|
4620
4649
|
if (!currency) {
|
|
4621
|
-
return parseInt((0,
|
|
4650
|
+
return parseInt((0, import_get5.default)(field, "value.price_fiat"));
|
|
4622
4651
|
} else {
|
|
4623
4652
|
const assetPriceForCurrenciesFields = await this.client.getDynamicFields(
|
|
4624
|
-
(0,
|
|
4653
|
+
(0, import_get5.default)(field, "value.price_fiat_for_currency.id")
|
|
4625
4654
|
);
|
|
4626
4655
|
for (const assetPriceForCurrencyField of assetPriceForCurrenciesFields) {
|
|
4627
4656
|
if (import_buffer.Buffer.from(assetPriceForCurrencyField.name, "base64").toString("utf-8") === currency) {
|
|
@@ -4635,10 +4664,10 @@ var Sellable = class extends CredenzaSuiModule {
|
|
|
4635
4664
|
}
|
|
4636
4665
|
async getPriceFiat(sellConfig, currency) {
|
|
4637
4666
|
const obj = await this.client.getObjectGrpc(sellConfig);
|
|
4638
|
-
if (!currency || !(0,
|
|
4639
|
-
return parseInt((0,
|
|
4667
|
+
if (!currency || !(0, import_get5.default)(obj, "json.price_fiat_for_currency.id") && currency === "USD") {
|
|
4668
|
+
return parseInt((0, import_get5.default)(obj, "json.price_fiat")) ?? null;
|
|
4640
4669
|
} else {
|
|
4641
|
-
const fields = await this.client.getDynamicFields((0,
|
|
4670
|
+
const fields = await this.client.getDynamicFields((0, import_get5.default)(obj, "json.price_fiat_for_currency.id"));
|
|
4642
4671
|
for (const field of fields) {
|
|
4643
4672
|
if (import_buffer.Buffer.from(field.name, "base64").toString("utf-8") === currency) {
|
|
4644
4673
|
return parseInt(field.value) ?? 0;
|
|
@@ -4649,20 +4678,20 @@ var Sellable = class extends CredenzaSuiModule {
|
|
|
4649
4678
|
}
|
|
4650
4679
|
async getAssetPriceCoin({ sellConfig, assetId }) {
|
|
4651
4680
|
const obj = await this.client.getObjectGrpc(sellConfig);
|
|
4652
|
-
const fields = await this.client.getDynamicFields((0,
|
|
4681
|
+
const fields = await this.client.getDynamicFields((0, import_get5.default)(obj, "json.asset_prices.id"));
|
|
4653
4682
|
for (const field of fields) {
|
|
4654
4683
|
if (field.name === `${assetId}`) {
|
|
4655
|
-
return parseInt((0,
|
|
4684
|
+
return parseInt((0, import_get5.default)(field, "value.price_coin"));
|
|
4656
4685
|
}
|
|
4657
4686
|
}
|
|
4658
4687
|
return 0;
|
|
4659
4688
|
}
|
|
4660
4689
|
async getAssetPriceSui({ sellConfig, assetId }) {
|
|
4661
4690
|
const obj = await this.client.getObjectGrpc(sellConfig);
|
|
4662
|
-
const fields = await this.client.getDynamicFields((0,
|
|
4691
|
+
const fields = await this.client.getDynamicFields((0, import_get5.default)(obj, "json.asset_prices.id"));
|
|
4663
4692
|
for (const field of fields) {
|
|
4664
4693
|
if (field.name === `${assetId}`) {
|
|
4665
|
-
return parseInt((0,
|
|
4694
|
+
return parseInt((0, import_get5.default)(field, "value.price_sui"));
|
|
4666
4695
|
}
|
|
4667
4696
|
}
|
|
4668
4697
|
return 0;
|
|
@@ -4684,7 +4713,7 @@ var Sellable = class extends CredenzaSuiModule {
|
|
|
4684
4713
|
|
|
4685
4714
|
// src/client/modules/CredenzaAssetCollection.ts
|
|
4686
4715
|
var import_transactions7 = require("@mysten/sui/transactions");
|
|
4687
|
-
var
|
|
4716
|
+
var import_get6 = __toESM(require_get());
|
|
4688
4717
|
var import_filter = __toESM(require_filter());
|
|
4689
4718
|
var CredenzaAssetCollection = class extends CredenzaSuiModule {
|
|
4690
4719
|
getAssetCollectionType() {
|
|
@@ -4808,7 +4837,7 @@ var CredenzaAssetCollection = class extends CredenzaSuiModule {
|
|
|
4808
4837
|
}
|
|
4809
4838
|
async getAssetMetadata(assetId) {
|
|
4810
4839
|
const collectionMeta = await this.getCollectionMetadata();
|
|
4811
|
-
const tableId = (0,
|
|
4840
|
+
const tableId = (0, import_get6.default)(collectionMeta, "json.assets.contents.id");
|
|
4812
4841
|
const fields = await this.client.getDynamicFields(tableId);
|
|
4813
4842
|
for (const field of fields) {
|
|
4814
4843
|
if (field.name === `${assetId - 1}`) {
|
|
@@ -4821,8 +4850,8 @@ var CredenzaAssetCollection = class extends CredenzaSuiModule {
|
|
|
4821
4850
|
const objects = await this.client.getOwnedObjectsGrpc(user, this.getAssetType());
|
|
4822
4851
|
let balance = 0;
|
|
4823
4852
|
for (const item of objects) {
|
|
4824
|
-
if ((0,
|
|
4825
|
-
balance += parseInt((0,
|
|
4853
|
+
if ((0, import_get6.default)(item, "json.asset_id") === `${assetId}`) {
|
|
4854
|
+
balance += parseInt((0, import_get6.default)(item, "json.balance"));
|
|
4826
4855
|
}
|
|
4827
4856
|
}
|
|
4828
4857
|
return balance;
|
|
@@ -4848,10 +4877,11 @@ var CredenzaAssetCollection = class extends CredenzaSuiModule {
|
|
|
4848
4877
|
price
|
|
4849
4878
|
});
|
|
4850
4879
|
}
|
|
4851
|
-
async getAssetPriceFiat(assetId) {
|
|
4880
|
+
async getAssetPriceFiat(assetId, currency) {
|
|
4852
4881
|
return await this.client.Sellable.getAssetPriceFiat({
|
|
4853
4882
|
sellConfig: await this.getSellableConfig(),
|
|
4854
|
-
assetId
|
|
4883
|
+
assetId,
|
|
4884
|
+
currency
|
|
4855
4885
|
});
|
|
4856
4886
|
}
|
|
4857
4887
|
async getAssetPriceCoin(assetId) {
|
|
@@ -4891,23 +4921,23 @@ var CredenzaAssetCollection = class extends CredenzaSuiModule {
|
|
|
4891
4921
|
}
|
|
4892
4922
|
async getAssetsIds() {
|
|
4893
4923
|
const collectionMeta = await this.getCollectionMetadata();
|
|
4894
|
-
const tableId = (0,
|
|
4924
|
+
const tableId = (0, import_get6.default)(collectionMeta, "json.assets.contents.id");
|
|
4895
4925
|
const fields = await this.client.getDynamicFields(tableId);
|
|
4896
4926
|
return fields.map((field) => parseInt(field.value?.["asset_id"])).sort();
|
|
4897
4927
|
}
|
|
4898
4928
|
async getOwners() {
|
|
4899
4929
|
const collectionMeta = await this.getCollectionMetadata();
|
|
4900
|
-
return (0,
|
|
4930
|
+
return (0, import_get6.default)(collectionMeta, "json.ownership.owners.contents");
|
|
4901
4931
|
}
|
|
4902
4932
|
async sendAsset(assetId, amount, target) {
|
|
4903
4933
|
await this.mergeAssets(assetId);
|
|
4904
4934
|
const objects = await this.client.getOwnedObjectsGrpc(this.client.getSignerAddress(), this.getAssetType());
|
|
4905
|
-
const assets = (0, import_filter.default)(objects, (item) => (0,
|
|
4935
|
+
const assets = (0, import_filter.default)(objects, (item) => (0, import_get6.default)(item, "json.asset_id") === `${assetId}`);
|
|
4906
4936
|
if (assets.length === 0) {
|
|
4907
4937
|
throw new Error("You dont have asset to send");
|
|
4908
4938
|
}
|
|
4909
4939
|
const asset = assets[0];
|
|
4910
|
-
const assetBalance = parseInt((0,
|
|
4940
|
+
const assetBalance = parseInt((0, import_get6.default)(asset, "json.balance") + "");
|
|
4911
4941
|
if (assetBalance < amount) {
|
|
4912
4942
|
throw new Error("Not enough asset balance");
|
|
4913
4943
|
}
|
|
@@ -4931,7 +4961,7 @@ var CredenzaAssetCollection = class extends CredenzaSuiModule {
|
|
|
4931
4961
|
let assets;
|
|
4932
4962
|
do {
|
|
4933
4963
|
const objects = await this.client.getOwnedObjectsGrpc(this.client.getSignerAddress(), this.getAssetType());
|
|
4934
|
-
assets = (0, import_filter.default)(objects, (item) => (0,
|
|
4964
|
+
assets = (0, import_filter.default)(objects, (item) => (0, import_get6.default)(item, "json.asset_id") === `${assetId}`);
|
|
4935
4965
|
if (assets.length > 1) {
|
|
4936
4966
|
const res = await this.join(assets[0].object_id, assets[1].object_id);
|
|
4937
4967
|
await this.client.waitForTransaction(res.digest);
|
|
@@ -4942,7 +4972,7 @@ var CredenzaAssetCollection = class extends CredenzaSuiModule {
|
|
|
4942
4972
|
|
|
4943
4973
|
// src/client/modules/CredenzaAirdrop.ts
|
|
4944
4974
|
var import_transactions8 = require("@mysten/sui/transactions");
|
|
4945
|
-
var
|
|
4975
|
+
var import_get7 = __toESM(require_get());
|
|
4946
4976
|
var CredenzaAirdrop = class extends CredenzaSuiModule {
|
|
4947
4977
|
async getCreatedConfigs() {
|
|
4948
4978
|
const configs = await this.client.graphqlClient.findSharedObjectsByType(
|
|
@@ -4992,9 +5022,9 @@ var CredenzaAirdrop = class extends CredenzaSuiModule {
|
|
|
4992
5022
|
}
|
|
4993
5023
|
async getAirdropCoinType(configId) {
|
|
4994
5024
|
const config = await this.client.getObjectGrpc(configId);
|
|
4995
|
-
const size = parseInt((0,
|
|
5025
|
+
const size = parseInt((0, import_get7.default)(config, "json.items.size") ?? "0");
|
|
4996
5026
|
if (!size) return null;
|
|
4997
|
-
const tableId = (0,
|
|
5027
|
+
const tableId = (0, import_get7.default)(config, "json.items.id");
|
|
4998
5028
|
const fieldData = await this.client.getDynamicFields(tableId);
|
|
4999
5029
|
for (const item of fieldData) {
|
|
5000
5030
|
const objectType = item.type;
|
|
@@ -5006,9 +5036,9 @@ var CredenzaAirdrop = class extends CredenzaSuiModule {
|
|
|
5006
5036
|
}
|
|
5007
5037
|
async getAirdropAssetType(configId) {
|
|
5008
5038
|
const config = await this.client.getObjectGrpc(configId);
|
|
5009
|
-
const size = parseInt((0,
|
|
5039
|
+
const size = parseInt((0, import_get7.default)(config, "json.items.size") ?? "0");
|
|
5010
5040
|
if (!size) return null;
|
|
5011
|
-
const tableId = (0,
|
|
5041
|
+
const tableId = (0, import_get7.default)(config, "json.items.id");
|
|
5012
5042
|
const fieldData = await this.client.getDynamicFields(tableId);
|
|
5013
5043
|
for (const item of fieldData) {
|
|
5014
5044
|
const res = item.type.split("object::ID,")[1];
|
|
@@ -5045,7 +5075,7 @@ var CredenzaAirdrop = class extends CredenzaSuiModule {
|
|
|
5045
5075
|
|
|
5046
5076
|
// src/client/modules/CredenzaDeposit.ts
|
|
5047
5077
|
var import_transactions9 = require("@mysten/sui/transactions");
|
|
5048
|
-
var
|
|
5078
|
+
var import_get8 = __toESM(require_get());
|
|
5049
5079
|
var CredenzaDeposit = class extends CredenzaSuiModule {
|
|
5050
5080
|
async getCreatedConfigs() {
|
|
5051
5081
|
return await this.client.graphqlClient.findSharedObjectsByType(
|
|
@@ -5062,9 +5092,9 @@ var CredenzaDeposit = class extends CredenzaSuiModule {
|
|
|
5062
5092
|
}
|
|
5063
5093
|
async getDepositedCoinType(configId) {
|
|
5064
5094
|
const config = await this.client.getObjectGrpc(configId);
|
|
5065
|
-
const size = parseInt((0,
|
|
5095
|
+
const size = parseInt((0, import_get8.default)(config, "json.coin.size") ?? "0");
|
|
5066
5096
|
if (!size) return null;
|
|
5067
|
-
const tableId = (0,
|
|
5097
|
+
const tableId = (0, import_get8.default)(config, "json.coin.id");
|
|
5068
5098
|
const fieldData = await this.client.getDynamicFields(tableId);
|
|
5069
5099
|
for (const item of fieldData) {
|
|
5070
5100
|
const objectType = item.type;
|
|
@@ -5116,7 +5146,7 @@ var CredenzaDeposit = class extends CredenzaSuiModule {
|
|
|
5116
5146
|
}
|
|
5117
5147
|
async isAuthorizedUser(configId, recipient) {
|
|
5118
5148
|
const config = await this.client.getObjectGrpc(configId);
|
|
5119
|
-
return (0,
|
|
5149
|
+
return (0, import_get8.default)(config, "json.authorized_users.contents").includes(recipient);
|
|
5120
5150
|
}
|
|
5121
5151
|
async requestCoin(configId, amount) {
|
|
5122
5152
|
const coinType = await this.getDepositedCoinType(configId);
|