@tradeport/sui-trading-sdk 0.1.65 → 0.1.67
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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +92 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/SuiTradingClient.ts +15 -0
- package/src/graphql/queries/fetchWalletKiosks.ts +13 -0
- package/src/methods/claimNfts/addClaimNftsTxs.ts +0 -8
- package/src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts +94 -0
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -140,6 +140,10 @@ type UnlistListings = {
|
|
|
140
140
|
walletAddress: string;
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
+
type WithdrawProfitsFromKiosks = {
|
|
144
|
+
walletAddress: string;
|
|
145
|
+
};
|
|
146
|
+
|
|
143
147
|
type ApiConfig = {
|
|
144
148
|
apiUser: string;
|
|
145
149
|
apiKey: string;
|
|
@@ -171,6 +175,7 @@ declare class SuiTradingClient {
|
|
|
171
175
|
exerciseShortLocks(args: ExerciseShortLocks): Promise<Transaction>;
|
|
172
176
|
buyAndExerciseLongLocks(args: BuyAndExerciseLongLocks): Promise<Transaction>;
|
|
173
177
|
buyAndExerciseShortLocks(args: BuyAndExerciseShortLocks): Promise<Transaction>;
|
|
178
|
+
withdrawProfitsFromKiosks(args: WithdrawProfitsFromKiosks): Promise<Transaction>;
|
|
174
179
|
}
|
|
175
180
|
|
|
176
181
|
export { SuiTradingClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -140,6 +140,10 @@ type UnlistListings = {
|
|
|
140
140
|
walletAddress: string;
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
+
type WithdrawProfitsFromKiosks = {
|
|
144
|
+
walletAddress: string;
|
|
145
|
+
};
|
|
146
|
+
|
|
143
147
|
type ApiConfig = {
|
|
144
148
|
apiUser: string;
|
|
145
149
|
apiKey: string;
|
|
@@ -171,6 +175,7 @@ declare class SuiTradingClient {
|
|
|
171
175
|
exerciseShortLocks(args: ExerciseShortLocks): Promise<Transaction>;
|
|
172
176
|
buyAndExerciseLongLocks(args: BuyAndExerciseLongLocks): Promise<Transaction>;
|
|
173
177
|
buyAndExerciseShortLocks(args: BuyAndExerciseShortLocks): Promise<Transaction>;
|
|
178
|
+
withdrawProfitsFromKiosks(args: WithdrawProfitsFromKiosks): Promise<Transaction>;
|
|
174
179
|
}
|
|
175
180
|
|
|
176
181
|
export { SuiTradingClient };
|
package/dist/index.js
CHANGED
|
@@ -3057,13 +3057,6 @@ var addClaimTradeHoldTx = ({
|
|
|
3057
3057
|
typeArguments: [nftType, "0x2::sui::SUI"]
|
|
3058
3058
|
});
|
|
3059
3059
|
confirmOBTranfer({ tx, sharedObjects, transferRequest, nftType });
|
|
3060
|
-
if (claimableBuyerKiosk) {
|
|
3061
|
-
tx.moveCall({
|
|
3062
|
-
target: `0x2::transfer::public_share_object`,
|
|
3063
|
-
typeArguments: ["0x2::kiosk::Kiosk"],
|
|
3064
|
-
arguments: [tx?.object(claimableBuyerKiosk)]
|
|
3065
|
-
});
|
|
3066
|
-
}
|
|
3067
3060
|
};
|
|
3068
3061
|
var addClaimAcceptedBidNftTx = async ({
|
|
3069
3062
|
tx,
|
|
@@ -4609,6 +4602,89 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
|
|
|
4609
4602
|
return import_transactions20.Transaction.from(tx);
|
|
4610
4603
|
};
|
|
4611
4604
|
|
|
4605
|
+
// src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts
|
|
4606
|
+
var import_kiosk5 = require("@mysten/kiosk");
|
|
4607
|
+
var import_transactions21 = require("@mysten/sui/transactions");
|
|
4608
|
+
|
|
4609
|
+
// src/graphql/queries/fetchWalletKiosks.ts
|
|
4610
|
+
var import_graphql_request20 = require("graphql-request");
|
|
4611
|
+
var fetchWalletKiosks = import_graphql_request20.gql`
|
|
4612
|
+
query fetchWalletKiosks($wallet: String!) {
|
|
4613
|
+
kiosks: kiosks_by_owner_address(owner_address: $wallet) {
|
|
4614
|
+
id
|
|
4615
|
+
is_origin_byte
|
|
4616
|
+
is_personal
|
|
4617
|
+
owner_address
|
|
4618
|
+
profits
|
|
4619
|
+
}
|
|
4620
|
+
}
|
|
4621
|
+
`;
|
|
4622
|
+
|
|
4623
|
+
// src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts
|
|
4624
|
+
async function withdrawProfitsFromKiosks({ walletAddress }, context) {
|
|
4625
|
+
const res = await gqlChainRequest({
|
|
4626
|
+
chain: "sui",
|
|
4627
|
+
query: fetchWalletKiosks,
|
|
4628
|
+
variables: {
|
|
4629
|
+
wallet: addLeadingZerosAfter0x(walletAddress)
|
|
4630
|
+
}
|
|
4631
|
+
});
|
|
4632
|
+
const kiosks = res?.kiosks?.filter((kiosk) => !kiosk?.is_origin_byte);
|
|
4633
|
+
if (kiosks.length === 0) {
|
|
4634
|
+
throw new Error(`No kiosks found for ${walletAddress}`);
|
|
4635
|
+
}
|
|
4636
|
+
const tx = new import_transactions21.Transaction();
|
|
4637
|
+
console.log("kiosks", kiosks);
|
|
4638
|
+
try {
|
|
4639
|
+
for (const kiosk of kiosks) {
|
|
4640
|
+
let kioskTx;
|
|
4641
|
+
if (kiosk.profits > 0) {
|
|
4642
|
+
if (kiosk.is_personal) {
|
|
4643
|
+
const personalKioskCapId = (await gqlChainRequest({
|
|
4644
|
+
chain: "sui",
|
|
4645
|
+
query: fetchPersonalCapByKiosk,
|
|
4646
|
+
variables: { kioskId: kiosk.id }
|
|
4647
|
+
})).personalCap?.id;
|
|
4648
|
+
kioskTx = new import_kiosk5.KioskTransaction({
|
|
4649
|
+
transactionBlock: tx,
|
|
4650
|
+
kioskClient: context.kioskClient,
|
|
4651
|
+
cap: {
|
|
4652
|
+
isPersonal: true,
|
|
4653
|
+
objectId: personalKioskCapId,
|
|
4654
|
+
kioskId: kiosk.id,
|
|
4655
|
+
digest: "",
|
|
4656
|
+
version: ""
|
|
4657
|
+
}
|
|
4658
|
+
});
|
|
4659
|
+
} else if (kiosks.length > 0) {
|
|
4660
|
+
const kioskCapId = (await gqlChainRequest({
|
|
4661
|
+
chain: "sui",
|
|
4662
|
+
query: fetchOwnerCapByKiosk,
|
|
4663
|
+
variables: { kioskId: kiosk.id }
|
|
4664
|
+
})).ownerCap?.id;
|
|
4665
|
+
kioskTx = new import_kiosk5.KioskTransaction({
|
|
4666
|
+
transactionBlock: tx,
|
|
4667
|
+
kioskClient: context.kioskClient,
|
|
4668
|
+
cap: {
|
|
4669
|
+
isPersonal: false,
|
|
4670
|
+
objectId: kioskCapId,
|
|
4671
|
+
kioskId: kiosk.id,
|
|
4672
|
+
digest: "",
|
|
4673
|
+
version: ""
|
|
4674
|
+
}
|
|
4675
|
+
});
|
|
4676
|
+
kioskTx.convertToPersonal(true);
|
|
4677
|
+
}
|
|
4678
|
+
kioskTx.withdraw(addLeadingZerosAfter0x(walletAddress));
|
|
4679
|
+
kioskTx.finalize();
|
|
4680
|
+
}
|
|
4681
|
+
}
|
|
4682
|
+
} catch (err) {
|
|
4683
|
+
console.log("err", err);
|
|
4684
|
+
}
|
|
4685
|
+
return import_transactions21.Transaction.from(tx);
|
|
4686
|
+
}
|
|
4687
|
+
|
|
4612
4688
|
// src/SuiTradingClient.ts
|
|
4613
4689
|
var SuiTradingClient = class {
|
|
4614
4690
|
constructor({ apiUser, apiKey, suiNodeUrl }) {
|
|
@@ -4902,6 +4978,15 @@ var SuiTradingClient = class {
|
|
|
4902
4978
|
};
|
|
4903
4979
|
return buyAndExerciseShortLocks(args, context);
|
|
4904
4980
|
}
|
|
4981
|
+
async withdrawProfitsFromKiosks(args) {
|
|
4982
|
+
const context = {
|
|
4983
|
+
apiUser: this.apiUser,
|
|
4984
|
+
apiKey: this.apiKey,
|
|
4985
|
+
suiClient: this.suiClient,
|
|
4986
|
+
kioskClient: this.kioskClient
|
|
4987
|
+
};
|
|
4988
|
+
return withdrawProfitsFromKiosks(args, context);
|
|
4989
|
+
}
|
|
4905
4990
|
};
|
|
4906
4991
|
var SuiTradingClient_default = SuiTradingClient;
|
|
4907
4992
|
// Annotate the CommonJS export names for ESM import in node:
|