@bolt-liquidity-hq/cosmwasm-client 0.1.0-beta.2 → 0.1.0-beta.3
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/index.cjs +70 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -14
- package/dist/index.d.ts +97 -14
- package/dist/index.js +70 -21
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
package/dist/index.cjs
CHANGED
|
@@ -22,6 +22,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
22
22
|
// src/index.ts
|
|
23
23
|
var index_exports = {};
|
|
24
24
|
__export(index_exports, {
|
|
25
|
+
AllowanceMode: () => AllowanceMode,
|
|
26
|
+
BaseClient: () => BaseClient,
|
|
25
27
|
BoltCosmWasmClient: () => BoltCosmWasmClient,
|
|
26
28
|
BoltSdkErrorBase: () => BoltSdkErrorBase,
|
|
27
29
|
BoltSdkErrorCode: () => BoltSdkErrorCode,
|
|
@@ -255,12 +257,12 @@ var BaseClient = class {
|
|
|
255
257
|
/**
|
|
256
258
|
* Creates a new instance of the BaseClient.
|
|
257
259
|
*
|
|
258
|
-
* @param config - Optional
|
|
259
|
-
* @param config.
|
|
260
|
-
* @param config.
|
|
261
|
-
* @param config.
|
|
262
|
-
* @param config.
|
|
263
|
-
* @param config.
|
|
260
|
+
* @param config - (Optional) Configuration object for the client
|
|
261
|
+
* @param config.customOverride - (Optional) Override configuration for RPC endpoint and contract addresses
|
|
262
|
+
* @param config.customOverride.rpcEndpoint - (Optional) Custom RPC endpoint URL for the blockchain network
|
|
263
|
+
* @param config.customOverride.contracts - (Optional) Custom contract addresses
|
|
264
|
+
* @param config.customOverride.contracts.oracle - (Optional) Custom oracle contract address
|
|
265
|
+
* @param config.customOverride.contracts.router - (Optional) Custom router contract address
|
|
264
266
|
*
|
|
265
267
|
* @throws {InvalidObjectError} Thrown when required configuration fields are missing
|
|
266
268
|
*
|
|
@@ -286,7 +288,7 @@ var BaseClient = class {
|
|
|
286
288
|
* Smart contract addresses for making Bolt queries and transactions in the blockchain
|
|
287
289
|
*/
|
|
288
290
|
__publicField(this, "contracts");
|
|
289
|
-
const {
|
|
291
|
+
const { customOverride: { rpcEndpoint, contracts } = {} } = config ?? {};
|
|
290
292
|
if (!rpcEndpoint || !contracts?.oracle || !contracts.router) {
|
|
291
293
|
throw new InvalidObjectError("ClientConfig is missing fields");
|
|
292
294
|
}
|
|
@@ -305,6 +307,13 @@ var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
|
305
307
|
return Environment2;
|
|
306
308
|
})(Environment || {});
|
|
307
309
|
|
|
310
|
+
// src/common/types/pool.ts
|
|
311
|
+
var AllowanceMode = /* @__PURE__ */ ((AllowanceMode2) => {
|
|
312
|
+
AllowanceMode2["Allow"] = "allow";
|
|
313
|
+
AllowanceMode2["Disallow"] = "disallow";
|
|
314
|
+
return AllowanceMode2;
|
|
315
|
+
})(AllowanceMode || {});
|
|
316
|
+
|
|
308
317
|
// src/config/archway-mainnet.json
|
|
309
318
|
var archway_mainnet_default = {
|
|
310
319
|
chain: {
|
|
@@ -313,8 +322,8 @@ var archway_mainnet_default = {
|
|
|
313
322
|
restEndpoint: "https://api.mainnet.archway.io"
|
|
314
323
|
},
|
|
315
324
|
contracts: {
|
|
316
|
-
oracle: "
|
|
317
|
-
router: "
|
|
325
|
+
oracle: "archway1cr5l0tvhqsdjfzun4jkwqfzv7fadu598hultcra4jrljgwl639wsksmd28",
|
|
326
|
+
router: "archway199r5vm4yzww5hct2z58tz9v3chfcvkpln34sqcav3ldqs7nkwktqc7aeju"
|
|
318
327
|
}
|
|
319
328
|
};
|
|
320
329
|
|
|
@@ -327,7 +336,7 @@ var archway_testnet_default = {
|
|
|
327
336
|
},
|
|
328
337
|
contracts: {
|
|
329
338
|
oracle: "archway1r3ug542dq4arzxsjz4kmpvpez2z830rl0u66k00ft3zrugs8k98qwyxgda",
|
|
330
|
-
router: "
|
|
339
|
+
router: "archway1h5x6upghew9xkfek85q48let2twdxq33sgsnzze5weshla46xd8sttps44"
|
|
331
340
|
}
|
|
332
341
|
};
|
|
333
342
|
|
|
@@ -387,6 +396,17 @@ var parseQueryRouterConfigResponse = (response) => {
|
|
|
387
396
|
settlementCodeId: response.settlement_code_id
|
|
388
397
|
};
|
|
389
398
|
};
|
|
399
|
+
var parseQuerySettlementConfigResponse = (response) => {
|
|
400
|
+
return {
|
|
401
|
+
priceOracleContract: response.price_oracle_contract,
|
|
402
|
+
protocolFeeRecipient: response.protocol_fee_recipient,
|
|
403
|
+
protocolFee: response.protocol_fee,
|
|
404
|
+
lpFee: response.lp_fee,
|
|
405
|
+
allowanceMode: response.allowance_mode,
|
|
406
|
+
lps: response.lps,
|
|
407
|
+
minBaseOut: response.min_base_out
|
|
408
|
+
};
|
|
409
|
+
};
|
|
390
410
|
|
|
391
411
|
// src/lib/helpers/transactions.ts
|
|
392
412
|
var getSignerAddress = async (signer) => {
|
|
@@ -535,6 +555,21 @@ var CosmWasmChain = /* @__PURE__ */ ((CosmWasmChain2) => {
|
|
|
535
555
|
return CosmWasmChain2;
|
|
536
556
|
})(CosmWasmChain || {});
|
|
537
557
|
|
|
558
|
+
// src/lib/settlement/get-settlement-config.ts
|
|
559
|
+
var getSettlementConfig = async (client, contractAddress) => {
|
|
560
|
+
const cosmWasmClient = await client.getCosmWasmClient();
|
|
561
|
+
const response = await cosmWasmClient.queryContractSmart(contractAddress, {
|
|
562
|
+
config: {}
|
|
563
|
+
});
|
|
564
|
+
return parseQuerySettlementConfigResponse(response);
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
// src/lib/settlement/get-settlement-config-for-base.ts
|
|
568
|
+
var getSettlementConfigForBase = async (client, baseAssetSymbol) => {
|
|
569
|
+
const pool = await getPoolForBase(client, baseAssetSymbol);
|
|
570
|
+
return await getSettlementConfig(client, pool.poolAddress);
|
|
571
|
+
};
|
|
572
|
+
|
|
538
573
|
// src/lib/client.ts
|
|
539
574
|
var BoltCosmWasmClient = class extends BaseClient {
|
|
540
575
|
/**
|
|
@@ -546,11 +581,13 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
546
581
|
* @param config - (Optional) Configuration for the client
|
|
547
582
|
* @param config.environment - (Optional) The deployment environment (Mainnet or Testnet). Defaults to Mainnet
|
|
548
583
|
* @param config.chain - (Optional) The specific CosmWasm chain to connect to. Defaults to Archway
|
|
549
|
-
* @param config.
|
|
550
|
-
* @param config.
|
|
551
|
-
* @param config.
|
|
552
|
-
* @param config.
|
|
553
|
-
* @param config.
|
|
584
|
+
* @param config.customOverride - (Optional) Overrides for RPC endpoint and contract addresses
|
|
585
|
+
* @param config.customOverride.rpcEndpoint - (Optional) Custom RPC endpoint URL
|
|
586
|
+
* @param config.customOverride.contracts - (Optional) Custom contract addresses
|
|
587
|
+
* @param config.customOverride.contracts.oracle - (Optional) Custom oracle contract address
|
|
588
|
+
* @param config.customOverride.contracts.router - (Optional) Custom router contract address
|
|
589
|
+
* @param config.customOverride.cosmWasmClient - (Optional) Custom CosmWasmClient to use for blockchain queries
|
|
590
|
+
* @param config.customOverride.signingCosmWasmClient - (Optional) Custom SigningCosmWasmClient to use for blockchain transactions
|
|
554
591
|
*
|
|
555
592
|
* @throws {InvalidTypeError} Thrown when an unsupported chain is specified
|
|
556
593
|
*
|
|
@@ -576,7 +613,9 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
576
613
|
const {
|
|
577
614
|
environment = "mainnet" /* Mainnet */,
|
|
578
615
|
chain = "archway" /* Archway */,
|
|
579
|
-
|
|
616
|
+
customOverride,
|
|
617
|
+
cosmWasmClient,
|
|
618
|
+
signingCosmWasmClient
|
|
580
619
|
} = config ?? {};
|
|
581
620
|
let configJson;
|
|
582
621
|
switch (chain) {
|
|
@@ -587,11 +626,11 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
587
626
|
throw new InvalidTypeError("A valid value of CosmWasmChain", chain);
|
|
588
627
|
}
|
|
589
628
|
super({
|
|
590
|
-
|
|
591
|
-
rpcEndpoint:
|
|
629
|
+
customOverride: {
|
|
630
|
+
rpcEndpoint: customOverride?.rpcEndpoint ?? configJson.chain.rpcEndpoint,
|
|
592
631
|
contracts: {
|
|
593
|
-
oracle:
|
|
594
|
-
router:
|
|
632
|
+
oracle: customOverride?.contracts?.oracle ?? configJson.contracts.oracle,
|
|
633
|
+
router: customOverride?.contracts?.router ?? configJson.contracts.router
|
|
595
634
|
}
|
|
596
635
|
}
|
|
597
636
|
});
|
|
@@ -610,6 +649,8 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
610
649
|
*/
|
|
611
650
|
__publicField(this, "chain");
|
|
612
651
|
this.chain = chain;
|
|
652
|
+
this._cosmWasmClient = cosmWasmClient;
|
|
653
|
+
this._signingCosmWasmClient = signingCosmWasmClient;
|
|
613
654
|
}
|
|
614
655
|
/**
|
|
615
656
|
* Gets or creates a CosmWasm client instance for read-only blockchain operations.
|
|
@@ -700,12 +741,20 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
700
741
|
}
|
|
701
742
|
/** @inheritdoc */
|
|
702
743
|
async getPoolByBaseAsset(baseAssetSymbol) {
|
|
703
|
-
return getPoolForBase(this, baseAssetSymbol);
|
|
744
|
+
return await getPoolForBase(this, baseAssetSymbol);
|
|
704
745
|
}
|
|
705
746
|
/** @inheritdoc */
|
|
706
747
|
async getAllPools() {
|
|
707
748
|
return await getPools(this);
|
|
708
749
|
}
|
|
750
|
+
/** @inheritdoc */
|
|
751
|
+
async getPoolConfig(poolContractAddress) {
|
|
752
|
+
return await getSettlementConfig(this, poolContractAddress);
|
|
753
|
+
}
|
|
754
|
+
/** @inheritdoc */
|
|
755
|
+
async getPoolConfigByBaseAsset(baseAssetSymbol) {
|
|
756
|
+
return await getSettlementConfigForBase(this, baseAssetSymbol);
|
|
757
|
+
}
|
|
709
758
|
/**
|
|
710
759
|
* @inheritdoc
|
|
711
760
|
*
|