@pyxisjs/chains 0.2.1 → 0.2.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.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +83 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -7123,8 +7123,10 @@ declare class EthereumChainAdapter extends BaseChainAdapter<PublicClient> implem
|
|
|
7123
7123
|
buildWithdrawTx(args: BuildWithdrawTxArgs): Promise<TransactionPayload>;
|
|
7124
7124
|
buildReclaimWithdrawalRequestTx(args: BuildReclaimWithdrawalRequestTxArgs): Promise<TransactionPayload>;
|
|
7125
7125
|
buildCancelWithdrawalRequestTx(args: BuildCancelWithdrawalRequestTxArgs): Promise<TransactionPayload>;
|
|
7126
|
-
getMinimumRequestAge(
|
|
7127
|
-
getUserWithdrawalRequests(
|
|
7126
|
+
getMinimumRequestAge(_args: GetMinimumRequestAgeArgs): Promise<number>;
|
|
7127
|
+
getUserWithdrawalRequests({ userAddress, flag, matchAll, }: GetWithdrawalRequestsOfUserArgs): Promise<PyxisWithdrawalRequest[]>;
|
|
7128
|
+
private mapEVMWithdrawalRequest;
|
|
7129
|
+
private viewSolveData;
|
|
7128
7130
|
}
|
|
7129
7131
|
|
|
7130
7132
|
interface ContractConfig {
|
package/dist/index.d.ts
CHANGED
|
@@ -7123,8 +7123,10 @@ declare class EthereumChainAdapter extends BaseChainAdapter<PublicClient> implem
|
|
|
7123
7123
|
buildWithdrawTx(args: BuildWithdrawTxArgs): Promise<TransactionPayload>;
|
|
7124
7124
|
buildReclaimWithdrawalRequestTx(args: BuildReclaimWithdrawalRequestTxArgs): Promise<TransactionPayload>;
|
|
7125
7125
|
buildCancelWithdrawalRequestTx(args: BuildCancelWithdrawalRequestTxArgs): Promise<TransactionPayload>;
|
|
7126
|
-
getMinimumRequestAge(
|
|
7127
|
-
getUserWithdrawalRequests(
|
|
7126
|
+
getMinimumRequestAge(_args: GetMinimumRequestAgeArgs): Promise<number>;
|
|
7127
|
+
getUserWithdrawalRequests({ userAddress, flag, matchAll, }: GetWithdrawalRequestsOfUserArgs): Promise<PyxisWithdrawalRequest[]>;
|
|
7128
|
+
private mapEVMWithdrawalRequest;
|
|
7129
|
+
private viewSolveData;
|
|
7128
7130
|
}
|
|
7129
7131
|
|
|
7130
7132
|
interface ContractConfig {
|
package/dist/index.js
CHANGED
|
@@ -6759,12 +6759,14 @@ var CONTRACTS = {
|
|
|
6759
6759
|
cancel_withdrawal_request: "{address}::atomic_queue::cancel_atomic_request"
|
|
6760
6760
|
},
|
|
6761
6761
|
[import_core.ChainType.EVM]: {
|
|
6762
|
-
get_minimum_request_age: "
|
|
6763
|
-
|
|
6764
|
-
reclaim_withdrawal_request: "reclaimWithdrawalRequest",
|
|
6762
|
+
get_minimum_request_age: "minimumRequestAge",
|
|
6763
|
+
cancel_atomic_request: "cancelAtomicRequest",
|
|
6765
6764
|
update_atomic_request: "updateAtomicRequest",
|
|
6766
6765
|
get_request_updated_at: "getRequestUpdatedAt",
|
|
6767
|
-
get_user_atomic_requests: "getUserAtomicRequests"
|
|
6766
|
+
get_user_atomic_requests: "getUserAtomicRequests",
|
|
6767
|
+
get_all_atomic_requests: "getAtomicRequests",
|
|
6768
|
+
// Private functions
|
|
6769
|
+
view_solve_metadata: "viewSolveMetaData"
|
|
6768
6770
|
}
|
|
6769
6771
|
}
|
|
6770
6772
|
},
|
|
@@ -7447,6 +7449,7 @@ var AptosAnalyticsClient = class {
|
|
|
7447
7449
|
var import_core4 = require("@pyxisjs/core");
|
|
7448
7450
|
var import_viem = require("viem");
|
|
7449
7451
|
var import_chains = require("viem/chains");
|
|
7452
|
+
var import_dayjs2 = __toESM(require_dayjs_min());
|
|
7450
7453
|
var viemChainMap = {
|
|
7451
7454
|
[import_core4.ChainId.ETHEREUM_MAINNET]: import_chains.mainnet,
|
|
7452
7455
|
[import_core4.ChainId.ETHEREUM_SEPOLIA]: import_chains.sepolia,
|
|
@@ -7713,11 +7716,18 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
7713
7716
|
to: this.getContractAddress("atomicQueue"),
|
|
7714
7717
|
function: functionSignature,
|
|
7715
7718
|
arguments: [
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7719
|
+
[
|
|
7720
|
+
args.user,
|
|
7721
|
+
args.offerAsset,
|
|
7722
|
+
args.wantAsset,
|
|
7723
|
+
Number(args.deadline),
|
|
7724
|
+
Number(args.price),
|
|
7725
|
+
Number(args.offerAmount),
|
|
7726
|
+
false,
|
|
7727
|
+
// inSolve: Default false
|
|
7728
|
+
(0, import_dayjs2.default)().unix()
|
|
7729
|
+
// UpdatedAt: current unix timestamp
|
|
7730
|
+
]
|
|
7721
7731
|
],
|
|
7722
7732
|
abi
|
|
7723
7733
|
});
|
|
@@ -7725,7 +7735,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
7725
7735
|
async buildReclaimWithdrawalRequestTx(args) {
|
|
7726
7736
|
const functionSignature = this.getFunctionSignature(
|
|
7727
7737
|
"atomicQueue",
|
|
7728
|
-
"
|
|
7738
|
+
"cancel_atomic_request"
|
|
7729
7739
|
);
|
|
7730
7740
|
const abi = this.getContractABI("atomicQueue");
|
|
7731
7741
|
return await this.buildPayload({
|
|
@@ -7738,7 +7748,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
7738
7748
|
async buildCancelWithdrawalRequestTx(args) {
|
|
7739
7749
|
const functionSignature = this.getFunctionSignature(
|
|
7740
7750
|
"atomicQueue",
|
|
7741
|
-
"
|
|
7751
|
+
"cancel_atomic_request"
|
|
7742
7752
|
);
|
|
7743
7753
|
const abi = this.getContractABI("atomicQueue");
|
|
7744
7754
|
return await this.buildPayload({
|
|
@@ -7748,7 +7758,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
7748
7758
|
abi
|
|
7749
7759
|
});
|
|
7750
7760
|
}
|
|
7751
|
-
async getMinimumRequestAge(
|
|
7761
|
+
async getMinimumRequestAge(_args) {
|
|
7752
7762
|
const functionSignature = this.getFunctionSignature(
|
|
7753
7763
|
"atomicQueue",
|
|
7754
7764
|
"get_minimum_request_age"
|
|
@@ -7756,13 +7766,71 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
7756
7766
|
const result = await this.viewContract({
|
|
7757
7767
|
address: this.getContractAddress("atomicQueue"),
|
|
7758
7768
|
function: functionSignature,
|
|
7759
|
-
arguments: [
|
|
7769
|
+
arguments: [],
|
|
7760
7770
|
abi: this.getContractABI("atomicQueue")
|
|
7761
7771
|
});
|
|
7762
7772
|
return Number(result);
|
|
7763
7773
|
}
|
|
7764
|
-
async getUserWithdrawalRequests(
|
|
7765
|
-
|
|
7774
|
+
async getUserWithdrawalRequests({
|
|
7775
|
+
userAddress,
|
|
7776
|
+
flag,
|
|
7777
|
+
matchAll
|
|
7778
|
+
}) {
|
|
7779
|
+
const requestFlag = import_core4.PyxisUtils.buildRequestFlags(flag);
|
|
7780
|
+
const getAllWithdrawalRequestFn = this.getFunctionSignature(
|
|
7781
|
+
"atomicQueue",
|
|
7782
|
+
"get_all_atomic_requests"
|
|
7783
|
+
);
|
|
7784
|
+
const withdrawalRequests = await this.viewContract({
|
|
7785
|
+
address: this.getContractAddress("atomicQueue"),
|
|
7786
|
+
function: getAllWithdrawalRequestFn,
|
|
7787
|
+
arguments: [0, Number.MAX_SAFE_INTEGER, requestFlag, matchAll],
|
|
7788
|
+
abi: this.getContractABI("atomicQueue")
|
|
7789
|
+
});
|
|
7790
|
+
const userRequests = withdrawalRequests.filter(
|
|
7791
|
+
(request) => request.user === userAddress
|
|
7792
|
+
);
|
|
7793
|
+
return Promise.all(
|
|
7794
|
+
userRequests.map((request) => this.mapEVMWithdrawalRequest(request))
|
|
7795
|
+
);
|
|
7796
|
+
}
|
|
7797
|
+
async mapEVMWithdrawalRequest(request) {
|
|
7798
|
+
const solveData = await this.viewSolveData({
|
|
7799
|
+
offerAsset: request.offerToken,
|
|
7800
|
+
wantAsset: request.wantToken,
|
|
7801
|
+
user: request.user
|
|
7802
|
+
});
|
|
7803
|
+
return {
|
|
7804
|
+
atomicPrice: request.atomicPrice,
|
|
7805
|
+
deadline: request.deadline,
|
|
7806
|
+
flags: import_core4.PyxisUtils.parseRequestFlags(solveData.flags),
|
|
7807
|
+
offerAmount: request.offerAmount,
|
|
7808
|
+
offerToken: request.offerToken,
|
|
7809
|
+
userAddress: request.user,
|
|
7810
|
+
wantToken: request.wantToken,
|
|
7811
|
+
wantAmount: String(solveData.assetsForWant),
|
|
7812
|
+
updatedAt: request.updatedAt
|
|
7813
|
+
};
|
|
7814
|
+
}
|
|
7815
|
+
async viewSolveData({
|
|
7816
|
+
offerAsset,
|
|
7817
|
+
wantAsset,
|
|
7818
|
+
user
|
|
7819
|
+
}) {
|
|
7820
|
+
const functionSignature = this.getFunctionSignature(
|
|
7821
|
+
"atomicQueue",
|
|
7822
|
+
"view_solve_metadata"
|
|
7823
|
+
);
|
|
7824
|
+
const [requestMetadata] = await this.viewContract({
|
|
7825
|
+
address: this.getContractAddress("atomicQueue"),
|
|
7826
|
+
function: functionSignature,
|
|
7827
|
+
arguments: [offerAsset, wantAsset, [user]],
|
|
7828
|
+
abi: this.getContractABI("atomicQueue")
|
|
7829
|
+
});
|
|
7830
|
+
if (!requestMetadata[0]) {
|
|
7831
|
+
throw new Error("Solve metadata not found");
|
|
7832
|
+
}
|
|
7833
|
+
return requestMetadata[0];
|
|
7766
7834
|
}
|
|
7767
7835
|
};
|
|
7768
7836
|
// Annotate the CommonJS export names for ESM import in node:
|