@credenza3/contracts-lib-sui 0.2.11 → 0.2.12
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 +73 -44
- package/dist/cjs/client/index.cjs.map +3 -3
- package/dist/cjs/client/modules/CredenzaLedger/CredenzaMetaLedgerV2.d.ts +3 -1
- package/dist/esm/client/index.mjs +73 -44
- package/dist/esm/client/index.mjs.map +3 -3
- 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
|
@@ -4,7 +4,7 @@ export declare class CredenzaMetaLedgerV2 extends CredenzaSuiModule {
|
|
|
4
4
|
private loyaltyConfig;
|
|
5
5
|
addPoints(userAddress: string, amount: number, eventId: string, meta?: string): Promise<SuiTransactionResult>;
|
|
6
6
|
redeemPoints(amount: number): Promise<SuiTransactionResult>;
|
|
7
|
-
|
|
7
|
+
convertPointsToCoins(amount: number): Promise<SuiTransactionResult>;
|
|
8
8
|
getLoyaltyConfig(): Promise<string>;
|
|
9
9
|
getPointsAmount(userAddress: string): Promise<number>;
|
|
10
10
|
getUserEvents(userAddress: string): Promise<{
|
|
@@ -15,4 +15,6 @@ export declare class CredenzaMetaLedgerV2 extends CredenzaSuiModule {
|
|
|
15
15
|
getPointsPerEvent(userAddress: string, event: string): Promise<number>;
|
|
16
16
|
getOwners(): Promise<string[]>;
|
|
17
17
|
setOwner(recipient: string, isOwner: boolean): Promise<SuiTransactionResult>;
|
|
18
|
+
setCoinForConverting(coinId: string, rate: number): Promise<SuiTransactionResult>;
|
|
19
|
+
getConvertableCoinType(): Promise<string | null>;
|
|
18
20
|
}
|
|
@@ -878,11 +878,11 @@ var require_get = __commonJS({
|
|
|
878
878
|
"node_modules/.pnpm/lodash@4.17.23/node_modules/lodash/get.js"(exports, module) {
|
|
879
879
|
"use strict";
|
|
880
880
|
var baseGet = require_baseGet();
|
|
881
|
-
function
|
|
881
|
+
function get9(object, path, defaultValue) {
|
|
882
882
|
var result = object == null ? void 0 : baseGet(object, path);
|
|
883
883
|
return result === void 0 ? defaultValue : result;
|
|
884
884
|
}
|
|
885
|
-
module.exports =
|
|
885
|
+
module.exports = get9;
|
|
886
886
|
}
|
|
887
887
|
});
|
|
888
888
|
|
|
@@ -3899,7 +3899,7 @@ var require_baseMatchesProperty = __commonJS({
|
|
|
3899
3899
|
"node_modules/.pnpm/lodash@4.17.23/node_modules/lodash/_baseMatchesProperty.js"(exports, module) {
|
|
3900
3900
|
"use strict";
|
|
3901
3901
|
var baseIsEqual = require_baseIsEqual();
|
|
3902
|
-
var
|
|
3902
|
+
var get9 = require_get();
|
|
3903
3903
|
var hasIn = require_hasIn();
|
|
3904
3904
|
var isKey = require_isKey();
|
|
3905
3905
|
var isStrictComparable = require_isStrictComparable();
|
|
@@ -3912,7 +3912,7 @@ var require_baseMatchesProperty = __commonJS({
|
|
|
3912
3912
|
return matchesStrictComparable(toKey(path), srcValue);
|
|
3913
3913
|
}
|
|
3914
3914
|
return function(object) {
|
|
3915
|
-
var objValue =
|
|
3915
|
+
var objValue = get9(object, path);
|
|
3916
3916
|
return objValue === void 0 && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
|
|
3917
3917
|
};
|
|
3918
3918
|
}
|
|
@@ -4244,6 +4244,7 @@ var CredenzaLedger = class extends CredenzaSuiModule {
|
|
|
4244
4244
|
};
|
|
4245
4245
|
|
|
4246
4246
|
// src/client/modules/CredenzaLedger/CredenzaMetaLedgerV2.ts
|
|
4247
|
+
var import_get2 = __toESM(require_get());
|
|
4247
4248
|
import { Transaction as Transaction3 } from "@mysten/sui/transactions";
|
|
4248
4249
|
var CredenzaMetaLedgerV2 = class extends CredenzaSuiModule {
|
|
4249
4250
|
async addPoints(userAddress, amount, eventId, meta = "") {
|
|
@@ -4268,12 +4269,16 @@ var CredenzaMetaLedgerV2 = class extends CredenzaSuiModule {
|
|
|
4268
4269
|
});
|
|
4269
4270
|
return this.client.signAndExecuteTransaction(tx);
|
|
4270
4271
|
}
|
|
4271
|
-
async
|
|
4272
|
+
async convertPointsToCoins(amount) {
|
|
4272
4273
|
const tx = new Transaction3();
|
|
4274
|
+
const coinType = await this.getConvertableCoinType();
|
|
4275
|
+
if (!coinType) {
|
|
4276
|
+
throw new Error(`Ledger Contract does not have coin set to convert points into`);
|
|
4277
|
+
}
|
|
4273
4278
|
tx.moveCall({
|
|
4274
4279
|
target: `${this.client.getPackageId()}::credenza_meta_loyalty_v2::convert_points_to_coins`,
|
|
4275
4280
|
arguments: [tx.object(await this.getLoyaltyConfig()), tx.pure.u64(amount)],
|
|
4276
|
-
typeArguments: [
|
|
4281
|
+
typeArguments: [coinType]
|
|
4277
4282
|
});
|
|
4278
4283
|
return this.client.signAndExecuteTransaction(tx);
|
|
4279
4284
|
}
|
|
@@ -4340,10 +4345,34 @@ var CredenzaMetaLedgerV2 = class extends CredenzaSuiModule {
|
|
|
4340
4345
|
});
|
|
4341
4346
|
return this.client.signAndExecuteTransaction(tx);
|
|
4342
4347
|
}
|
|
4348
|
+
async setCoinForConverting(coinId, rate) {
|
|
4349
|
+
const coin = await this.client.getObjectGrpc(coinId);
|
|
4350
|
+
const coinType = coin.object_type.split("<")[1]?.split(">")[0];
|
|
4351
|
+
let oldCoinType = await this.getConvertableCoinType();
|
|
4352
|
+
if (!oldCoinType) {
|
|
4353
|
+
oldCoinType = coinType;
|
|
4354
|
+
}
|
|
4355
|
+
const tx = new Transaction3();
|
|
4356
|
+
tx.moveCall({
|
|
4357
|
+
target: `${this.client.getPackageId()}::credenza_meta_loyalty_v2::set_coin`,
|
|
4358
|
+
arguments: [tx.object(await this.getLoyaltyConfig()), tx.object(coinId), tx.pure.u64(rate)],
|
|
4359
|
+
typeArguments: [oldCoinType, coinType]
|
|
4360
|
+
});
|
|
4361
|
+
return this.client.signAndExecuteTransaction(tx);
|
|
4362
|
+
}
|
|
4363
|
+
async getConvertableCoinType() {
|
|
4364
|
+
const config = await this.client.getObjectGrpc(await this.getLoyaltyConfig());
|
|
4365
|
+
let ret = null;
|
|
4366
|
+
if (parseInt((0, import_get2.default)(config, "json.coin.size"))) {
|
|
4367
|
+
const fieldData = await this.client.getDynamicFields((0, import_get2.default)(config, "json.coin.id"));
|
|
4368
|
+
ret = (0, import_get2.default)(fieldData, "0.type").split("object::ID,")[1].split("<")[1].split(">")[0];
|
|
4369
|
+
}
|
|
4370
|
+
return ret;
|
|
4371
|
+
}
|
|
4343
4372
|
};
|
|
4344
4373
|
|
|
4345
4374
|
// src/client/modules/CredenzaMembership.ts
|
|
4346
|
-
var
|
|
4375
|
+
var import_get3 = __toESM(require_get());
|
|
4347
4376
|
var import_isNil = __toESM(require_isNil());
|
|
4348
4377
|
import { Transaction as Transaction4 } from "@mysten/sui/transactions";
|
|
4349
4378
|
var CredenzaMembership = class extends CredenzaSuiModule {
|
|
@@ -4458,7 +4487,7 @@ var CredenzaMembership = class extends CredenzaSuiModule {
|
|
|
4458
4487
|
async getOwners() {
|
|
4459
4488
|
const id = await this.getMembershipListId();
|
|
4460
4489
|
const data = await this.client.getObjectGrpc(id);
|
|
4461
|
-
return (0,
|
|
4490
|
+
return (0, import_get3.default)(data, "json.ownership.owners.contents");
|
|
4462
4491
|
}
|
|
4463
4492
|
async setOwner(recipient, isOwner) {
|
|
4464
4493
|
const tx = new Transaction4();
|
|
@@ -4471,7 +4500,7 @@ var CredenzaMembership = class extends CredenzaSuiModule {
|
|
|
4471
4500
|
};
|
|
4472
4501
|
|
|
4473
4502
|
// src/client/modules/CredenzaDecom.ts
|
|
4474
|
-
var
|
|
4503
|
+
var import_get4 = __toESM(require_get());
|
|
4475
4504
|
import { Transaction as Transaction5 } from "@mysten/sui/transactions";
|
|
4476
4505
|
var CredenzaDecom = class extends CredenzaSuiModule {
|
|
4477
4506
|
getDecomType() {
|
|
@@ -4522,12 +4551,12 @@ var CredenzaDecom = class extends CredenzaSuiModule {
|
|
|
4522
4551
|
async getOwnerRenderData() {
|
|
4523
4552
|
const capId = await this.getAdminCap();
|
|
4524
4553
|
const data = await this.client.getObjectGrpc(capId);
|
|
4525
|
-
return (0,
|
|
4554
|
+
return (0, import_get4.default)(data, "json.owner_render_data");
|
|
4526
4555
|
}
|
|
4527
4556
|
async getRenderData() {
|
|
4528
4557
|
const capId = await this.getAdminCap();
|
|
4529
4558
|
const data = await this.client.getObjectGrpc(capId);
|
|
4530
|
-
return (0,
|
|
4559
|
+
return (0, import_get4.default)(data, "json.render_data");
|
|
4531
4560
|
}
|
|
4532
4561
|
async writeRenderData(data) {
|
|
4533
4562
|
const tx = new Transaction5();
|
|
@@ -4581,7 +4610,7 @@ var CredenzaDecom = class extends CredenzaSuiModule {
|
|
|
4581
4610
|
async getOwners() {
|
|
4582
4611
|
const capId = await this.getAdminCap();
|
|
4583
4612
|
const data = await this.client.getObjectGrpc(capId);
|
|
4584
|
-
return (0,
|
|
4613
|
+
return (0, import_get4.default)(data, "json.ownership.owners.contents");
|
|
4585
4614
|
}
|
|
4586
4615
|
async setOwner(recipient, isOwner) {
|
|
4587
4616
|
const tx = new Transaction5();
|
|
@@ -4604,7 +4633,7 @@ var CredenzaDecom = class extends CredenzaSuiModule {
|
|
|
4604
4633
|
|
|
4605
4634
|
// src/client/modules/Sellable.ts
|
|
4606
4635
|
var import_buffer = __toESM(require_buffer());
|
|
4607
|
-
var
|
|
4636
|
+
var import_get5 = __toESM(require_get());
|
|
4608
4637
|
import { Transaction as Transaction6 } from "@mysten/sui/transactions";
|
|
4609
4638
|
var Sellable = class extends CredenzaSuiModule {
|
|
4610
4639
|
async getSellConfig(assetType) {
|
|
@@ -4625,9 +4654,9 @@ var Sellable = class extends CredenzaSuiModule {
|
|
|
4625
4654
|
let oldCoinType = coinType;
|
|
4626
4655
|
const config = await this.client.getObjectGrpc(sellConfig);
|
|
4627
4656
|
const sellableType = await this.getSellableType(sellConfig);
|
|
4628
|
-
if (parseInt((0,
|
|
4629
|
-
const fieldData = await this.client.getDynamicFields((0,
|
|
4630
|
-
oldCoinType = (0,
|
|
4657
|
+
if (parseInt((0, import_get5.default)(config, "json.coin.size"))) {
|
|
4658
|
+
const fieldData = await this.client.getDynamicFields((0, import_get5.default)(config, "json.coin.id"));
|
|
4659
|
+
oldCoinType = (0, import_get5.default)(fieldData, "0.type").split("object::ID,")[1].split("<")[1].split(">")[0];
|
|
4631
4660
|
}
|
|
4632
4661
|
const tx = new Transaction6();
|
|
4633
4662
|
tx.moveCall({
|
|
@@ -4726,14 +4755,14 @@ var Sellable = class extends CredenzaSuiModule {
|
|
|
4726
4755
|
currency
|
|
4727
4756
|
}) {
|
|
4728
4757
|
const obj = await this.client.getObjectGrpc(sellConfig);
|
|
4729
|
-
const fields = await this.client.getDynamicFields((0,
|
|
4758
|
+
const fields = await this.client.getDynamicFields((0, import_get5.default)(obj, "json.asset_prices.id"));
|
|
4730
4759
|
for (const field of fields) {
|
|
4731
4760
|
if (field.name === `${assetId}`) {
|
|
4732
4761
|
if (!currency) {
|
|
4733
|
-
return parseInt((0,
|
|
4762
|
+
return parseInt((0, import_get5.default)(field, "value.price_fiat"));
|
|
4734
4763
|
} else {
|
|
4735
4764
|
const assetPriceForCurrenciesFields = await this.client.getDynamicFields(
|
|
4736
|
-
(0,
|
|
4765
|
+
(0, import_get5.default)(field, "value.price_fiat_for_currency.id")
|
|
4737
4766
|
);
|
|
4738
4767
|
for (const assetPriceForCurrencyField of assetPriceForCurrenciesFields) {
|
|
4739
4768
|
if (import_buffer.Buffer.from(assetPriceForCurrencyField.name, "base64").toString("utf-8") === currency) {
|
|
@@ -4747,10 +4776,10 @@ var Sellable = class extends CredenzaSuiModule {
|
|
|
4747
4776
|
}
|
|
4748
4777
|
async getPriceFiat(sellConfig, currency) {
|
|
4749
4778
|
const obj = await this.client.getObjectGrpc(sellConfig);
|
|
4750
|
-
if (!currency || !(0,
|
|
4751
|
-
return parseInt((0,
|
|
4779
|
+
if (!currency || !(0, import_get5.default)(obj, "json.price_fiat_for_currency.id") && currency === "USD") {
|
|
4780
|
+
return parseInt((0, import_get5.default)(obj, "json.price_fiat")) ?? null;
|
|
4752
4781
|
} else {
|
|
4753
|
-
const fields = await this.client.getDynamicFields((0,
|
|
4782
|
+
const fields = await this.client.getDynamicFields((0, import_get5.default)(obj, "json.price_fiat_for_currency.id"));
|
|
4754
4783
|
for (const field of fields) {
|
|
4755
4784
|
if (import_buffer.Buffer.from(field.name, "base64").toString("utf-8") === currency) {
|
|
4756
4785
|
return parseInt(field.value) ?? 0;
|
|
@@ -4761,20 +4790,20 @@ var Sellable = class extends CredenzaSuiModule {
|
|
|
4761
4790
|
}
|
|
4762
4791
|
async getAssetPriceCoin({ sellConfig, assetId }) {
|
|
4763
4792
|
const obj = await this.client.getObjectGrpc(sellConfig);
|
|
4764
|
-
const fields = await this.client.getDynamicFields((0,
|
|
4793
|
+
const fields = await this.client.getDynamicFields((0, import_get5.default)(obj, "json.asset_prices.id"));
|
|
4765
4794
|
for (const field of fields) {
|
|
4766
4795
|
if (field.name === `${assetId}`) {
|
|
4767
|
-
return parseInt((0,
|
|
4796
|
+
return parseInt((0, import_get5.default)(field, "value.price_coin"));
|
|
4768
4797
|
}
|
|
4769
4798
|
}
|
|
4770
4799
|
return 0;
|
|
4771
4800
|
}
|
|
4772
4801
|
async getAssetPriceSui({ sellConfig, assetId }) {
|
|
4773
4802
|
const obj = await this.client.getObjectGrpc(sellConfig);
|
|
4774
|
-
const fields = await this.client.getDynamicFields((0,
|
|
4803
|
+
const fields = await this.client.getDynamicFields((0, import_get5.default)(obj, "json.asset_prices.id"));
|
|
4775
4804
|
for (const field of fields) {
|
|
4776
4805
|
if (field.name === `${assetId}`) {
|
|
4777
|
-
return parseInt((0,
|
|
4806
|
+
return parseInt((0, import_get5.default)(field, "value.price_sui"));
|
|
4778
4807
|
}
|
|
4779
4808
|
}
|
|
4780
4809
|
return 0;
|
|
@@ -4795,7 +4824,7 @@ var Sellable = class extends CredenzaSuiModule {
|
|
|
4795
4824
|
};
|
|
4796
4825
|
|
|
4797
4826
|
// src/client/modules/CredenzaAssetCollection.ts
|
|
4798
|
-
var
|
|
4827
|
+
var import_get6 = __toESM(require_get());
|
|
4799
4828
|
var import_filter = __toESM(require_filter());
|
|
4800
4829
|
import { Transaction as Transaction7 } from "@mysten/sui/transactions";
|
|
4801
4830
|
var CredenzaAssetCollection = class extends CredenzaSuiModule {
|
|
@@ -4920,7 +4949,7 @@ var CredenzaAssetCollection = class extends CredenzaSuiModule {
|
|
|
4920
4949
|
}
|
|
4921
4950
|
async getAssetMetadata(assetId) {
|
|
4922
4951
|
const collectionMeta = await this.getCollectionMetadata();
|
|
4923
|
-
const tableId = (0,
|
|
4952
|
+
const tableId = (0, import_get6.default)(collectionMeta, "json.assets.contents.id");
|
|
4924
4953
|
const fields = await this.client.getDynamicFields(tableId);
|
|
4925
4954
|
for (const field of fields) {
|
|
4926
4955
|
if (field.name === `${assetId - 1}`) {
|
|
@@ -4933,8 +4962,8 @@ var CredenzaAssetCollection = class extends CredenzaSuiModule {
|
|
|
4933
4962
|
const objects = await this.client.getOwnedObjectsGrpc(user, this.getAssetType());
|
|
4934
4963
|
let balance = 0;
|
|
4935
4964
|
for (const item of objects) {
|
|
4936
|
-
if ((0,
|
|
4937
|
-
balance += parseInt((0,
|
|
4965
|
+
if ((0, import_get6.default)(item, "json.asset_id") === `${assetId}`) {
|
|
4966
|
+
balance += parseInt((0, import_get6.default)(item, "json.balance"));
|
|
4938
4967
|
}
|
|
4939
4968
|
}
|
|
4940
4969
|
return balance;
|
|
@@ -5003,23 +5032,23 @@ var CredenzaAssetCollection = class extends CredenzaSuiModule {
|
|
|
5003
5032
|
}
|
|
5004
5033
|
async getAssetsIds() {
|
|
5005
5034
|
const collectionMeta = await this.getCollectionMetadata();
|
|
5006
|
-
const tableId = (0,
|
|
5035
|
+
const tableId = (0, import_get6.default)(collectionMeta, "json.assets.contents.id");
|
|
5007
5036
|
const fields = await this.client.getDynamicFields(tableId);
|
|
5008
5037
|
return fields.map((field) => parseInt(field.value?.["asset_id"])).sort();
|
|
5009
5038
|
}
|
|
5010
5039
|
async getOwners() {
|
|
5011
5040
|
const collectionMeta = await this.getCollectionMetadata();
|
|
5012
|
-
return (0,
|
|
5041
|
+
return (0, import_get6.default)(collectionMeta, "json.ownership.owners.contents");
|
|
5013
5042
|
}
|
|
5014
5043
|
async sendAsset(assetId, amount, target) {
|
|
5015
5044
|
await this.mergeAssets(assetId);
|
|
5016
5045
|
const objects = await this.client.getOwnedObjectsGrpc(this.client.getSignerAddress(), this.getAssetType());
|
|
5017
|
-
const assets = (0, import_filter.default)(objects, (item) => (0,
|
|
5046
|
+
const assets = (0, import_filter.default)(objects, (item) => (0, import_get6.default)(item, "json.asset_id") === `${assetId}`);
|
|
5018
5047
|
if (assets.length === 0) {
|
|
5019
5048
|
throw new Error("You dont have asset to send");
|
|
5020
5049
|
}
|
|
5021
5050
|
const asset = assets[0];
|
|
5022
|
-
const assetBalance = parseInt((0,
|
|
5051
|
+
const assetBalance = parseInt((0, import_get6.default)(asset, "json.balance") + "");
|
|
5023
5052
|
if (assetBalance < amount) {
|
|
5024
5053
|
throw new Error("Not enough asset balance");
|
|
5025
5054
|
}
|
|
@@ -5043,7 +5072,7 @@ var CredenzaAssetCollection = class extends CredenzaSuiModule {
|
|
|
5043
5072
|
let assets;
|
|
5044
5073
|
do {
|
|
5045
5074
|
const objects = await this.client.getOwnedObjectsGrpc(this.client.getSignerAddress(), this.getAssetType());
|
|
5046
|
-
assets = (0, import_filter.default)(objects, (item) => (0,
|
|
5075
|
+
assets = (0, import_filter.default)(objects, (item) => (0, import_get6.default)(item, "json.asset_id") === `${assetId}`);
|
|
5047
5076
|
if (assets.length > 1) {
|
|
5048
5077
|
const res = await this.join(assets[0].object_id, assets[1].object_id);
|
|
5049
5078
|
await this.client.waitForTransaction(res.digest);
|
|
@@ -5053,7 +5082,7 @@ var CredenzaAssetCollection = class extends CredenzaSuiModule {
|
|
|
5053
5082
|
};
|
|
5054
5083
|
|
|
5055
5084
|
// src/client/modules/CredenzaAirdrop.ts
|
|
5056
|
-
var
|
|
5085
|
+
var import_get7 = __toESM(require_get());
|
|
5057
5086
|
import { Transaction as Transaction8 } from "@mysten/sui/transactions";
|
|
5058
5087
|
var CredenzaAirdrop = class extends CredenzaSuiModule {
|
|
5059
5088
|
async getCreatedConfigs() {
|
|
@@ -5104,9 +5133,9 @@ var CredenzaAirdrop = class extends CredenzaSuiModule {
|
|
|
5104
5133
|
}
|
|
5105
5134
|
async getAirdropCoinType(configId) {
|
|
5106
5135
|
const config = await this.client.getObjectGrpc(configId);
|
|
5107
|
-
const size = parseInt((0,
|
|
5136
|
+
const size = parseInt((0, import_get7.default)(config, "json.items.size") ?? "0");
|
|
5108
5137
|
if (!size) return null;
|
|
5109
|
-
const tableId = (0,
|
|
5138
|
+
const tableId = (0, import_get7.default)(config, "json.items.id");
|
|
5110
5139
|
const fieldData = await this.client.getDynamicFields(tableId);
|
|
5111
5140
|
for (const item of fieldData) {
|
|
5112
5141
|
const objectType = item.type;
|
|
@@ -5118,9 +5147,9 @@ var CredenzaAirdrop = class extends CredenzaSuiModule {
|
|
|
5118
5147
|
}
|
|
5119
5148
|
async getAirdropAssetType(configId) {
|
|
5120
5149
|
const config = await this.client.getObjectGrpc(configId);
|
|
5121
|
-
const size = parseInt((0,
|
|
5150
|
+
const size = parseInt((0, import_get7.default)(config, "json.items.size") ?? "0");
|
|
5122
5151
|
if (!size) return null;
|
|
5123
|
-
const tableId = (0,
|
|
5152
|
+
const tableId = (0, import_get7.default)(config, "json.items.id");
|
|
5124
5153
|
const fieldData = await this.client.getDynamicFields(tableId);
|
|
5125
5154
|
for (const item of fieldData) {
|
|
5126
5155
|
const res = item.type.split("object::ID,")[1];
|
|
@@ -5156,7 +5185,7 @@ var CredenzaAirdrop = class extends CredenzaSuiModule {
|
|
|
5156
5185
|
};
|
|
5157
5186
|
|
|
5158
5187
|
// src/client/modules/CredenzaDeposit.ts
|
|
5159
|
-
var
|
|
5188
|
+
var import_get8 = __toESM(require_get());
|
|
5160
5189
|
import { Transaction as Transaction9 } from "@mysten/sui/transactions";
|
|
5161
5190
|
var CredenzaDeposit = class extends CredenzaSuiModule {
|
|
5162
5191
|
async getCreatedConfigs() {
|
|
@@ -5174,9 +5203,9 @@ var CredenzaDeposit = class extends CredenzaSuiModule {
|
|
|
5174
5203
|
}
|
|
5175
5204
|
async getDepositedCoinType(configId) {
|
|
5176
5205
|
const config = await this.client.getObjectGrpc(configId);
|
|
5177
|
-
const size = parseInt((0,
|
|
5206
|
+
const size = parseInt((0, import_get8.default)(config, "json.coin.size") ?? "0");
|
|
5178
5207
|
if (!size) return null;
|
|
5179
|
-
const tableId = (0,
|
|
5208
|
+
const tableId = (0, import_get8.default)(config, "json.coin.id");
|
|
5180
5209
|
const fieldData = await this.client.getDynamicFields(tableId);
|
|
5181
5210
|
for (const item of fieldData) {
|
|
5182
5211
|
const objectType = item.type;
|
|
@@ -5228,7 +5257,7 @@ var CredenzaDeposit = class extends CredenzaSuiModule {
|
|
|
5228
5257
|
}
|
|
5229
5258
|
async isAuthorizedUser(configId, recipient) {
|
|
5230
5259
|
const config = await this.client.getObjectGrpc(configId);
|
|
5231
|
-
return (0,
|
|
5260
|
+
return (0, import_get8.default)(config, "json.authorized_users.contents").includes(recipient);
|
|
5232
5261
|
}
|
|
5233
5262
|
async requestCoin(configId, amount) {
|
|
5234
5263
|
const coinType = await this.getDepositedCoinType(configId);
|