@tradeport/sui-trading-sdk 0.0.2 → 0.0.4
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.js +41 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/SuiTradingClient.ts +2 -1
- package/src/helpers/kiosk/getKioskTransferPolicies.ts +16 -13
- package/src/helpers/kiosk/getRulePackageId.ts +2 -1
- package/src/helpers/kiosk/resolveTransferPolicies.ts +3 -2
- package/src/utils/normalizeNftType.ts +7 -0
package/package.json
CHANGED
package/src/SuiTradingClient.ts
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
withdrawKioskProfits,
|
|
29
29
|
type WithdrawKioskProfits,
|
|
30
30
|
} from './methods/withdrawKioskProfits/withdrawKioskProfits';
|
|
31
|
+
import { addLeadingZerosAfter0x } from './utils/addLeadingZerosAfter0x';
|
|
31
32
|
|
|
32
33
|
type ApiConfig = {
|
|
33
34
|
apiUser: string;
|
|
@@ -123,7 +124,7 @@ class SuiTradingClient {
|
|
|
123
124
|
walletAddress,
|
|
124
125
|
});
|
|
125
126
|
|
|
126
|
-
txBlock.setSenderIfNotSet(walletAddress);
|
|
127
|
+
txBlock.setSenderIfNotSet(addLeadingZerosAfter0x(walletAddress));
|
|
127
128
|
const rawTransaction = await txBlock.build({ client: suiClient });
|
|
128
129
|
await suiClient.dryRunTransactionBlock({
|
|
129
130
|
transactionBlock: rawTransaction,
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { addLeadingZerosAfter0x } from '../../utils/addLeadingZerosAfter0x';
|
|
1
|
+
import kioskClient from '../../apiClients/kioskClient';
|
|
2
|
+
import { normalizedNftType } from '../../utils/normalizeNftType';
|
|
4
3
|
|
|
5
|
-
export const getKioskTransferPolicies = async (nftType: string) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const res = await gqlChainRequest({
|
|
10
|
-
chain: 'sui',
|
|
11
|
-
query: fetchTransferPoliciesByType,
|
|
12
|
-
variables: { type: nftTypeSplit?.join('::') },
|
|
4
|
+
export const getKioskTransferPolicies = async (nftType: string) =>
|
|
5
|
+
kioskClient.getTransferPolicies({
|
|
6
|
+
type: normalizedNftType(nftType),
|
|
13
7
|
});
|
|
14
8
|
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
// const rule = transferPolicies
|
|
10
|
+
// .flatMap((policy) => policy.rules)
|
|
11
|
+
// .filter((rule) => rule?.split('::')?.[1] === ruleType)?.[0];
|
|
12
|
+
|
|
13
|
+
// const res = await gqlChainRequest({
|
|
14
|
+
// chain: 'sui',
|
|
15
|
+
// query: fetchTransferPoliciesByType,
|
|
16
|
+
// variables: { type: nftTypeSplit?.join('::') },
|
|
17
|
+
// });
|
|
18
|
+
|
|
19
|
+
// return res?.transfer_policies_by_type?.filter((policy: any) => !policy?.is_origin_byte);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { getNormalizedRuleType } from '@mysten/kiosk';
|
|
2
2
|
import kioskClient from '../../apiClients/kioskClient';
|
|
3
3
|
import { addHexPrefix } from '../../utils/addHexPrefix';
|
|
4
|
+
import { normalizedNftType } from '../../utils/normalizeNftType';
|
|
4
5
|
|
|
5
6
|
type RuleType = 'kiosk_royalty_rule' | 'royalty_rule' | 'personal_kiosk_rule' | 'kiosk_lock_rule';
|
|
6
7
|
|
|
7
8
|
export const getRulePackageId = async (nftType: string, ruleType: RuleType) => {
|
|
8
9
|
const transferPolicies = await kioskClient.getTransferPolicies({
|
|
9
|
-
type: nftType,
|
|
10
|
+
type: normalizedNftType(nftType),
|
|
10
11
|
});
|
|
11
12
|
|
|
12
13
|
const rule = transferPolicies
|
|
@@ -5,6 +5,7 @@ import { resolveFloorPriceRule } from './resolveFloorPriceRule';
|
|
|
5
5
|
import { resolveKioskLockRule } from './resolveKioskLockRule';
|
|
6
6
|
import { resolvePersonalKioskRule } from './resolvePersonalKioskRule';
|
|
7
7
|
import { resolveRoyaltyRule } from './resolveRoyaltyRule';
|
|
8
|
+
import { normalizedNftType } from '../../utils/normalizeNftType';
|
|
8
9
|
|
|
9
10
|
export type Policy = {
|
|
10
11
|
data: any;
|
|
@@ -41,7 +42,7 @@ export const resolveTransferPolicies = async ({
|
|
|
41
42
|
shouldSkipResolvingRoyaltyRule,
|
|
42
43
|
}: Props) => {
|
|
43
44
|
const transferPolicies = await kioskClient.getTransferPolicies({
|
|
44
|
-
type: nftType,
|
|
45
|
+
type: normalizedNftType(nftType),
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
let policies: Policy[] =
|
|
@@ -58,7 +59,7 @@ export const resolveTransferPolicies = async ({
|
|
|
58
59
|
if (customTransferPolicies) {
|
|
59
60
|
for (const customTransferPolicy of customTransferPolicies) {
|
|
60
61
|
const customPolicy = await kioskClient.getTransferPolicies({
|
|
61
|
-
type: customTransferPolicy?.type,
|
|
62
|
+
type: normalizedNftType(customTransferPolicy?.type),
|
|
62
63
|
});
|
|
63
64
|
policies = [
|
|
64
65
|
...policies,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { addLeadingZerosAfter0x } from './addLeadingZerosAfter0x';
|
|
2
|
+
|
|
3
|
+
export const normalizedNftType = (nftType: string): string => {
|
|
4
|
+
const nftTypeSplit = nftType?.split('::');
|
|
5
|
+
if (nftTypeSplit?.[0]) nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
|
|
6
|
+
return nftTypeSplit?.join('::');
|
|
7
|
+
};
|