@haneullabs/haneulns 0.1.0 → 1.0.2
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 +125 -53
- package/README.md +3 -3
- package/dist/constants.d.mts +16 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +90 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/contracts/haneulns/controller.mjs +62 -0
- package/dist/contracts/haneulns/controller.mjs.map +1 -0
- package/dist/contracts/haneulns/deps/haneul/balance.mjs +21 -0
- package/dist/contracts/haneulns/deps/haneul/balance.mjs.map +1 -0
- package/dist/contracts/haneulns/deps/haneul/vec_map.mjs +37 -0
- package/dist/contracts/haneulns/deps/haneul/vec_map.mjs.map +1 -0
- package/dist/contracts/haneulns/deps/std/type_name.mjs +17 -0
- package/dist/contracts/haneulns/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/haneulns/domain.mjs +23 -0
- package/dist/contracts/haneulns/domain.mjs.map +1 -0
- package/dist/contracts/haneulns/haneulns.mjs +68 -0
- package/dist/contracts/haneulns/haneulns.mjs.map +1 -0
- package/dist/contracts/haneulns/name_record.mjs +27 -0
- package/dist/contracts/haneulns/name_record.mjs.map +1 -0
- package/dist/contracts/haneulns/payment.mjs +162 -0
- package/dist/contracts/haneulns/payment.mjs.map +1 -0
- package/dist/contracts/haneulns/pricing_config.mjs +25 -0
- package/dist/contracts/haneulns/pricing_config.mjs.map +1 -0
- package/dist/contracts/haneulns_coupons/coupon_house.mjs +59 -0
- package/dist/contracts/haneulns_coupons/coupon_house.mjs.map +1 -0
- package/dist/contracts/haneulns_coupons/data.mjs +16 -0
- package/dist/contracts/haneulns_coupons/data.mjs.map +1 -0
- package/dist/contracts/haneulns_coupons/deps/haneul/bag.mjs +43 -0
- package/dist/contracts/haneulns_coupons/deps/haneul/bag.mjs.map +1 -0
- package/dist/contracts/haneulns_discounts/deps/haneul/linked_table.mjs +27 -0
- package/dist/contracts/haneulns_discounts/deps/haneul/linked_table.mjs.map +1 -0
- package/dist/contracts/haneulns_discounts/deps/haneulns/pricing_config.mjs +16 -0
- package/dist/contracts/haneulns_discounts/deps/haneulns/pricing_config.mjs.map +1 -0
- package/dist/contracts/haneulns_discounts/discounts.mjs +51 -0
- package/dist/contracts/haneulns_discounts/discounts.mjs.map +1 -0
- package/dist/contracts/haneulns_discounts/free_claims.mjs +60 -0
- package/dist/contracts/haneulns_discounts/free_claims.mjs.map +1 -0
- package/dist/contracts/haneulns_payments/deps/haneul/vec_map.mjs +37 -0
- package/dist/contracts/haneulns_payments/deps/haneul/vec_map.mjs.map +1 -0
- package/dist/contracts/haneulns_payments/deps/std/type_name.mjs +17 -0
- package/dist/contracts/haneulns_payments/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/haneulns_payments/payments.mjs +145 -0
- package/dist/contracts/haneulns_payments/payments.mjs.map +1 -0
- package/dist/contracts/pyth/data_source.mjs +20 -0
- package/dist/contracts/pyth/data_source.mjs.map +1 -0
- package/dist/contracts/pyth/deps/0x0000000000000000000000000000000000000000000000000000000000000002/package.mjs +21 -0
- package/dist/contracts/pyth/deps/0x0000000000000000000000000000000000000000000000000000000000000002/package.mjs.map +1 -0
- package/dist/contracts/pyth/deps/0x0000000000000000000000000000000000000000000000000000000000000002/table.mjs +19 -0
- package/dist/contracts/pyth/deps/0x0000000000000000000000000000000000000000000000000000000000000002/table.mjs.map +1 -0
- package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/bytes32.mjs +16 -0
- package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/bytes32.mjs.map +1 -0
- package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/consumed_vaas.mjs +16 -0
- package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/consumed_vaas.mjs.map +1 -0
- package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/external_address.mjs +16 -0
- package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/external_address.mjs.map +1 -0
- package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/set.mjs +16 -0
- package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/set.mjs.map +1 -0
- package/dist/contracts/pyth/state.mjs +28 -0
- package/dist/contracts/pyth/state.mjs.map +1 -0
- package/dist/contracts/utils/index.mjs +120 -0
- package/dist/contracts/utils/index.mjs.map +1 -0
- package/dist/contracts/wormhole/bytes32.mjs +16 -0
- package/dist/contracts/wormhole/bytes32.mjs.map +1 -0
- package/dist/contracts/wormhole/consumed_vaas.mjs +16 -0
- package/dist/contracts/wormhole/consumed_vaas.mjs.map +1 -0
- package/dist/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs +16 -0
- package/dist/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs.map +1 -0
- package/dist/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/package.mjs +21 -0
- package/dist/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/package.mjs.map +1 -0
- package/dist/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/table.mjs +19 -0
- package/dist/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/table.mjs.map +1 -0
- package/dist/contracts/wormhole/external_address.mjs +16 -0
- package/dist/contracts/wormhole/external_address.mjs.map +1 -0
- package/dist/contracts/wormhole/fee_collector.mjs +20 -0
- package/dist/contracts/wormhole/fee_collector.mjs.map +1 -0
- package/dist/contracts/wormhole/set.mjs +16 -0
- package/dist/contracts/wormhole/set.mjs.map +1 -0
- package/dist/contracts/wormhole/state.mjs +31 -0
- package/dist/contracts/wormhole/state.mjs.map +1 -0
- package/dist/haneulns-client.d.mts +76 -0
- package/dist/haneulns-client.d.mts.map +1 -0
- package/dist/haneulns-client.mjs +205 -0
- package/dist/haneulns-client.mjs.map +1 -0
- package/dist/haneulns-transaction.d.mts +144 -0
- package/dist/haneulns-transaction.d.mts.map +1 -0
- package/dist/haneulns-transaction.mjs +384 -0
- package/dist/haneulns-transaction.mjs.map +1 -0
- package/dist/helpers.d.mts +22 -0
- package/dist/helpers.d.mts.map +1 -0
- package/dist/helpers.mjs +45 -0
- package/dist/helpers.mjs.map +1 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +6 -0
- package/dist/pyth/PriceServiceConnection.mjs +35 -0
- package/dist/pyth/PriceServiceConnection.mjs.map +1 -0
- package/dist/pyth/pyth-helpers.mjs +18 -0
- package/dist/pyth/pyth-helpers.mjs.map +1 -0
- package/dist/pyth/pyth.mjs +219 -0
- package/dist/pyth/pyth.mjs.map +1 -0
- package/dist/types.d.mts +88 -0
- package/dist/types.d.mts.map +1 -0
- package/package.json +27 -23
- package/src/contracts/haneulns/admin.ts +114 -0
- package/src/contracts/haneulns/auction.ts +341 -0
- package/src/contracts/haneulns/config.ts +225 -0
- package/src/contracts/haneulns/constants.ts +167 -0
- package/src/contracts/haneulns/controller.ts +269 -0
- package/src/contracts/haneulns/core_config.ts +208 -0
- package/src/contracts/haneulns/deps/haneul/balance.ts +19 -0
- package/src/contracts/haneulns/deps/haneul/coin.ts +20 -0
- package/src/contracts/haneulns/deps/haneul/linked_table.ts +27 -0
- package/src/contracts/haneulns/deps/haneul/table.ts +36 -0
- package/src/contracts/haneulns/deps/haneul/vec_map.ts +33 -0
- package/src/contracts/haneulns/deps/haneul/vec_set.ts +22 -0
- package/src/contracts/haneulns/deps/std/type_name.ts +24 -0
- package/src/contracts/haneulns/domain.ts +230 -0
- package/src/contracts/haneulns/haneulns.ts +456 -0
- package/src/contracts/haneulns/haneulns_registration.ts +200 -0
- package/src/contracts/haneulns/name_record.ts +315 -0
- package/src/contracts/haneulns/payment.ts +444 -0
- package/src/contracts/haneulns/pricing_config.ts +190 -0
- package/src/contracts/haneulns/registry.ts +514 -0
- package/src/contracts/haneulns/subdomain_registration.ts +63 -0
- package/src/contracts/haneulns/update_image.ts +15 -0
- package/src/contracts/haneulns_coupons/constants.ts +45 -0
- package/src/contracts/haneulns_coupons/coupon.ts +15 -0
- package/src/contracts/haneulns_coupons/coupon_house.ts +412 -0
- package/src/contracts/haneulns_coupons/data.ts +12 -0
- package/src/contracts/haneulns_coupons/deps/haneul/bag.ts +41 -0
- package/src/contracts/haneulns_coupons/range.ts +101 -0
- package/src/contracts/haneulns_coupons/rules.ts +342 -0
- package/src/contracts/haneulns_discounts/deps/haneul/linked_table.ts +27 -0
- package/src/contracts/haneulns_discounts/deps/haneulns/pricing_config.ts +10 -0
- package/src/contracts/haneulns_discounts/discounts.ts +156 -0
- package/src/contracts/haneulns_discounts/free_claims.ts +161 -0
- package/src/contracts/haneulns_discounts/house.ts +47 -0
- package/src/contracts/haneulns_payments/deps/haneul/vec_map.ts +33 -0
- package/src/contracts/haneulns_payments/deps/std/type_name.ts +24 -0
- package/src/contracts/haneulns_payments/payments.ts +257 -0
- package/src/contracts/haneulns_temp_subdomain_proxy/subdomain_proxy.ts +343 -0
- package/src/contracts/pyth/data_source.ts +15 -0
- package/src/contracts/pyth/deps/0x0000000000000000000000000000000000000000000000000000000000000002/package.ts +15 -0
- package/src/contracts/pyth/deps/0x0000000000000000000000000000000000000000000000000000000000000002/table.ts +13 -0
- package/src/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/bytes32.ts +12 -0
- package/src/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/consumed_vaas.ts +13 -0
- package/src/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/external_address.ts +13 -0
- package/src/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/set.ts +12 -0
- package/src/contracts/pyth/state.ts +22 -0
- package/src/contracts/utils/index.ts +234 -0
- package/src/contracts/wormhole/bytes32.ts +12 -0
- package/src/contracts/wormhole/consumed_vaas.ts +13 -0
- package/src/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.ts +12 -0
- package/src/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/package.ts +15 -0
- package/src/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/table.ts +13 -0
- package/src/contracts/wormhole/external_address.ts +13 -0
- package/src/contracts/wormhole/fee_collector.ts +15 -0
- package/src/contracts/wormhole/set.ts +12 -0
- package/src/contracts/wormhole/state.ts +25 -0
- package/src/haneulns-client.ts +115 -160
- package/src/haneulns-transaction.ts +142 -116
- package/src/index.ts +3 -3
- package/src/pyth/pyth.ts +55 -71
- package/src/types.ts +5 -7
- package/dist/cjs/constants.d.ts +0 -11
- package/dist/cjs/constants.js +0 -120
- package/dist/cjs/constants.js.map +0 -7
- package/dist/cjs/haneulns-client.d.ts +0 -40
- package/dist/cjs/haneulns-client.js +0 -261
- package/dist/cjs/haneulns-client.js.map +0 -7
- package/dist/cjs/haneulns-transaction.d.ts +0 -105
- package/dist/cjs/haneulns-transaction.js +0 -465
- package/dist/cjs/haneulns-transaction.js.map +0 -7
- package/dist/cjs/helpers.d.ts +0 -18
- package/dist/cjs/helpers.js +0 -63
- package/dist/cjs/helpers.js.map +0 -7
- package/dist/cjs/index.d.ts +0 -5
- package/dist/cjs/index.js +0 -39
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/package.json +0 -5
- package/dist/cjs/pyth/PriceServiceConnection.d.ts +0 -26
- package/dist/cjs/pyth/PriceServiceConnection.js +0 -68
- package/dist/cjs/pyth/PriceServiceConnection.js.map +0 -7
- package/dist/cjs/pyth/pyth-helpers.d.ts +0 -7
- package/dist/cjs/pyth/pyth-helpers.js +0 -36
- package/dist/cjs/pyth/pyth-helpers.js.map +0 -7
- package/dist/cjs/pyth/pyth.d.ts +0 -66
- package/dist/cjs/pyth/pyth.js +0 -270
- package/dist/cjs/pyth/pyth.js.map +0 -7
- package/dist/cjs/types.d.ts +0 -89
- package/dist/cjs/types.js +0 -17
- package/dist/cjs/types.js.map +0 -7
- package/dist/esm/constants.d.ts +0 -11
- package/dist/esm/constants.js +0 -100
- package/dist/esm/constants.js.map +0 -7
- package/dist/esm/haneulns-client.d.ts +0 -40
- package/dist/esm/haneulns-client.js +0 -249
- package/dist/esm/haneulns-client.js.map +0 -7
- package/dist/esm/haneulns-transaction.d.ts +0 -105
- package/dist/esm/haneulns-transaction.js +0 -445
- package/dist/esm/haneulns-transaction.js.map +0 -7
- package/dist/esm/helpers.d.ts +0 -18
- package/dist/esm/helpers.js +0 -43
- package/dist/esm/helpers.js.map +0 -7
- package/dist/esm/index.d.ts +0 -5
- package/dist/esm/index.js +0 -28
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/package.json +0 -5
- package/dist/esm/pyth/PriceServiceConnection.d.ts +0 -26
- package/dist/esm/pyth/PriceServiceConnection.js +0 -38
- package/dist/esm/pyth/PriceServiceConnection.js.map +0 -7
- package/dist/esm/pyth/pyth-helpers.d.ts +0 -7
- package/dist/esm/pyth/pyth-helpers.js +0 -16
- package/dist/esm/pyth/pyth-helpers.js.map +0 -7
- package/dist/esm/pyth/pyth.d.ts +0 -66
- package/dist/esm/pyth/pyth.js +0 -250
- package/dist/esm/pyth/pyth.js.map +0 -7
- package/dist/esm/types.d.ts +0 -89
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -7
- package/dist/tsconfig.esm.tsbuildinfo +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
|
|
5
|
+
import { bcs } from '@haneullabs/haneul/bcs';
|
|
6
|
+
import { type Transaction } from '@haneullabs/haneul/transactions';
|
|
7
|
+
import * as range from './range.js';
|
|
8
|
+
const $moduleName = '@haneulns/coupons::rules';
|
|
9
|
+
export const CouponRules = new MoveStruct({
|
|
10
|
+
name: `${$moduleName}::CouponRules`,
|
|
11
|
+
fields: {
|
|
12
|
+
length: bcs.option(range.Range),
|
|
13
|
+
available_claims: bcs.option(bcs.u64()),
|
|
14
|
+
user: bcs.option(bcs.Address),
|
|
15
|
+
expiration: bcs.option(bcs.u64()),
|
|
16
|
+
years: bcs.option(range.Range),
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
export interface NewCouponRulesArguments {
|
|
20
|
+
length: RawTransactionArgument<string | null>;
|
|
21
|
+
availableClaims: RawTransactionArgument<number | bigint | null>;
|
|
22
|
+
user: RawTransactionArgument<string | null>;
|
|
23
|
+
expiration: RawTransactionArgument<number | bigint | null>;
|
|
24
|
+
years: RawTransactionArgument<string | null>;
|
|
25
|
+
}
|
|
26
|
+
export interface NewCouponRulesOptions {
|
|
27
|
+
package?: string;
|
|
28
|
+
arguments:
|
|
29
|
+
| NewCouponRulesArguments
|
|
30
|
+
| [
|
|
31
|
+
length: RawTransactionArgument<string | null>,
|
|
32
|
+
availableClaims: RawTransactionArgument<number | bigint | null>,
|
|
33
|
+
user: RawTransactionArgument<string | null>,
|
|
34
|
+
expiration: RawTransactionArgument<number | bigint | null>,
|
|
35
|
+
years: RawTransactionArgument<string | null>,
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* This is used in a PTB when creating a coupon. Creates a CouponRules object to be
|
|
40
|
+
* used to create a coupon. All rules are optional, and can be chained (`AND`)
|
|
41
|
+
* format.
|
|
42
|
+
*
|
|
43
|
+
* 1. Length: The name has to be in range [from, to]
|
|
44
|
+
* 2. Max available claims
|
|
45
|
+
* 3. Only for a specific address
|
|
46
|
+
* 4. Might have an expiration date.
|
|
47
|
+
* 5. Might be valid only for registrations in a range [from, to]
|
|
48
|
+
*/
|
|
49
|
+
export function newCouponRules(options: NewCouponRulesOptions) {
|
|
50
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
51
|
+
const argumentsTypes = [
|
|
52
|
+
'0x1::option::Option<null>',
|
|
53
|
+
'0x1::option::Option<u64>',
|
|
54
|
+
'0x1::option::Option<address>',
|
|
55
|
+
'0x1::option::Option<u64>',
|
|
56
|
+
'0x1::option::Option<null>',
|
|
57
|
+
] satisfies (string | null)[];
|
|
58
|
+
const parameterNames = ['length', 'availableClaims', 'user', 'expiration', 'years'];
|
|
59
|
+
return (tx: Transaction) =>
|
|
60
|
+
tx.moveCall({
|
|
61
|
+
package: packageAddress,
|
|
62
|
+
module: 'rules',
|
|
63
|
+
function: 'new_coupon_rules',
|
|
64
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export interface NewEmptyRulesOptions {
|
|
68
|
+
package?: string;
|
|
69
|
+
arguments?: [];
|
|
70
|
+
}
|
|
71
|
+
export function newEmptyRules(options: NewEmptyRulesOptions = {}) {
|
|
72
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
73
|
+
return (tx: Transaction) =>
|
|
74
|
+
tx.moveCall({
|
|
75
|
+
package: packageAddress,
|
|
76
|
+
module: 'rules',
|
|
77
|
+
function: 'new_empty_rules',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export interface DecreaseAvailableClaimsArguments {
|
|
81
|
+
rules: RawTransactionArgument<string>;
|
|
82
|
+
}
|
|
83
|
+
export interface DecreaseAvailableClaimsOptions {
|
|
84
|
+
package?: string;
|
|
85
|
+
arguments: DecreaseAvailableClaimsArguments | [rules: RawTransactionArgument<string>];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* If the rules count `available_claims`, we decrease it. Aborts if there are no
|
|
89
|
+
* more available claims on that coupon. We shouldn't get here ever, as we're
|
|
90
|
+
* checking this on the coupon creation, but keeping it as a sanity check (e.g.
|
|
91
|
+
* created a coupon with 0 available claims).
|
|
92
|
+
*/
|
|
93
|
+
export function decreaseAvailableClaims(options: DecreaseAvailableClaimsOptions) {
|
|
94
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
95
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
96
|
+
const parameterNames = ['rules'];
|
|
97
|
+
return (tx: Transaction) =>
|
|
98
|
+
tx.moveCall({
|
|
99
|
+
package: packageAddress,
|
|
100
|
+
module: 'rules',
|
|
101
|
+
function: 'decrease_available_claims',
|
|
102
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
export interface HasAvailableClaimsArguments {
|
|
106
|
+
rules: RawTransactionArgument<string>;
|
|
107
|
+
}
|
|
108
|
+
export interface HasAvailableClaimsOptions {
|
|
109
|
+
package?: string;
|
|
110
|
+
arguments: HasAvailableClaimsArguments | [rules: RawTransactionArgument<string>];
|
|
111
|
+
}
|
|
112
|
+
export function hasAvailableClaims(options: HasAvailableClaimsOptions) {
|
|
113
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
114
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
115
|
+
const parameterNames = ['rules'];
|
|
116
|
+
return (tx: Transaction) =>
|
|
117
|
+
tx.moveCall({
|
|
118
|
+
package: packageAddress,
|
|
119
|
+
module: 'rules',
|
|
120
|
+
function: 'has_available_claims',
|
|
121
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
export interface AssertCouponValidForDomainYearsArguments {
|
|
125
|
+
rules: RawTransactionArgument<string>;
|
|
126
|
+
target: RawTransactionArgument<number>;
|
|
127
|
+
}
|
|
128
|
+
export interface AssertCouponValidForDomainYearsOptions {
|
|
129
|
+
package?: string;
|
|
130
|
+
arguments:
|
|
131
|
+
| AssertCouponValidForDomainYearsArguments
|
|
132
|
+
| [rules: RawTransactionArgument<string>, target: RawTransactionArgument<number>];
|
|
133
|
+
}
|
|
134
|
+
export function assertCouponValidForDomainYears(options: AssertCouponValidForDomainYearsOptions) {
|
|
135
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
136
|
+
const argumentsTypes = [null, 'u8'] satisfies (string | null)[];
|
|
137
|
+
const parameterNames = ['rules', 'target'];
|
|
138
|
+
return (tx: Transaction) =>
|
|
139
|
+
tx.moveCall({
|
|
140
|
+
package: packageAddress,
|
|
141
|
+
module: 'rules',
|
|
142
|
+
function: 'assert_coupon_valid_for_domain_years',
|
|
143
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
export interface IsCouponValidForDomainYearsArguments {
|
|
147
|
+
rules: RawTransactionArgument<string>;
|
|
148
|
+
target: RawTransactionArgument<number>;
|
|
149
|
+
}
|
|
150
|
+
export interface IsCouponValidForDomainYearsOptions {
|
|
151
|
+
package?: string;
|
|
152
|
+
arguments:
|
|
153
|
+
| IsCouponValidForDomainYearsArguments
|
|
154
|
+
| [rules: RawTransactionArgument<string>, target: RawTransactionArgument<number>];
|
|
155
|
+
}
|
|
156
|
+
export function isCouponValidForDomainYears(options: IsCouponValidForDomainYearsOptions) {
|
|
157
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
158
|
+
const argumentsTypes = [null, 'u8'] satisfies (string | null)[];
|
|
159
|
+
const parameterNames = ['rules', 'target'];
|
|
160
|
+
return (tx: Transaction) =>
|
|
161
|
+
tx.moveCall({
|
|
162
|
+
package: packageAddress,
|
|
163
|
+
module: 'rules',
|
|
164
|
+
function: 'is_coupon_valid_for_domain_years',
|
|
165
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
export interface AssertIsValidDiscountTypeArguments {
|
|
169
|
+
type: RawTransactionArgument<number>;
|
|
170
|
+
}
|
|
171
|
+
export interface AssertIsValidDiscountTypeOptions {
|
|
172
|
+
package?: string;
|
|
173
|
+
arguments: AssertIsValidDiscountTypeArguments | [type: RawTransactionArgument<number>];
|
|
174
|
+
}
|
|
175
|
+
export function assertIsValidDiscountType(options: AssertIsValidDiscountTypeOptions) {
|
|
176
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
177
|
+
const argumentsTypes = ['u8'] satisfies (string | null)[];
|
|
178
|
+
const parameterNames = ['type'];
|
|
179
|
+
return (tx: Transaction) =>
|
|
180
|
+
tx.moveCall({
|
|
181
|
+
package: packageAddress,
|
|
182
|
+
module: 'rules',
|
|
183
|
+
function: 'assert_is_valid_discount_type',
|
|
184
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
export interface AssertIsValidAmountArguments {
|
|
188
|
+
_: RawTransactionArgument<number>;
|
|
189
|
+
amount: RawTransactionArgument<number | bigint>;
|
|
190
|
+
}
|
|
191
|
+
export interface AssertIsValidAmountOptions {
|
|
192
|
+
package?: string;
|
|
193
|
+
arguments:
|
|
194
|
+
| AssertIsValidAmountArguments
|
|
195
|
+
| [_: RawTransactionArgument<number>, amount: RawTransactionArgument<number | bigint>];
|
|
196
|
+
}
|
|
197
|
+
export function assertIsValidAmount(options: AssertIsValidAmountOptions) {
|
|
198
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
199
|
+
const argumentsTypes = ['u8', 'u64'] satisfies (string | null)[];
|
|
200
|
+
const parameterNames = ['_', 'amount'];
|
|
201
|
+
return (tx: Transaction) =>
|
|
202
|
+
tx.moveCall({
|
|
203
|
+
package: packageAddress,
|
|
204
|
+
module: 'rules',
|
|
205
|
+
function: 'assert_is_valid_amount',
|
|
206
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
export interface AssertCouponValidForDomainSizeArguments {
|
|
210
|
+
rules: RawTransactionArgument<string>;
|
|
211
|
+
length: RawTransactionArgument<number>;
|
|
212
|
+
}
|
|
213
|
+
export interface AssertCouponValidForDomainSizeOptions {
|
|
214
|
+
package?: string;
|
|
215
|
+
arguments:
|
|
216
|
+
| AssertCouponValidForDomainSizeArguments
|
|
217
|
+
| [rules: RawTransactionArgument<string>, length: RawTransactionArgument<number>];
|
|
218
|
+
}
|
|
219
|
+
export function assertCouponValidForDomainSize(options: AssertCouponValidForDomainSizeOptions) {
|
|
220
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
221
|
+
const argumentsTypes = [null, 'u8'] satisfies (string | null)[];
|
|
222
|
+
const parameterNames = ['rules', 'length'];
|
|
223
|
+
return (tx: Transaction) =>
|
|
224
|
+
tx.moveCall({
|
|
225
|
+
package: packageAddress,
|
|
226
|
+
module: 'rules',
|
|
227
|
+
function: 'assert_coupon_valid_for_domain_size',
|
|
228
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
export interface IsCouponValidForDomainSizeArguments {
|
|
232
|
+
rules: RawTransactionArgument<string>;
|
|
233
|
+
length: RawTransactionArgument<number>;
|
|
234
|
+
}
|
|
235
|
+
export interface IsCouponValidForDomainSizeOptions {
|
|
236
|
+
package?: string;
|
|
237
|
+
arguments:
|
|
238
|
+
| IsCouponValidForDomainSizeArguments
|
|
239
|
+
| [rules: RawTransactionArgument<string>, length: RawTransactionArgument<number>];
|
|
240
|
+
}
|
|
241
|
+
/** We check the length of the name based on the domain length rule */
|
|
242
|
+
export function isCouponValidForDomainSize(options: IsCouponValidForDomainSizeOptions) {
|
|
243
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
244
|
+
const argumentsTypes = [null, 'u8'] satisfies (string | null)[];
|
|
245
|
+
const parameterNames = ['rules', 'length'];
|
|
246
|
+
return (tx: Transaction) =>
|
|
247
|
+
tx.moveCall({
|
|
248
|
+
package: packageAddress,
|
|
249
|
+
module: 'rules',
|
|
250
|
+
function: 'is_coupon_valid_for_domain_size',
|
|
251
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
export interface AssertCouponValidForAddressArguments {
|
|
255
|
+
rules: RawTransactionArgument<string>;
|
|
256
|
+
user: RawTransactionArgument<string>;
|
|
257
|
+
}
|
|
258
|
+
export interface AssertCouponValidForAddressOptions {
|
|
259
|
+
package?: string;
|
|
260
|
+
arguments:
|
|
261
|
+
| AssertCouponValidForAddressArguments
|
|
262
|
+
| [rules: RawTransactionArgument<string>, user: RawTransactionArgument<string>];
|
|
263
|
+
}
|
|
264
|
+
/** Throws `EInvalidUser` error if it has expired. */
|
|
265
|
+
export function assertCouponValidForAddress(options: AssertCouponValidForAddressOptions) {
|
|
266
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
267
|
+
const argumentsTypes = [null, 'address'] satisfies (string | null)[];
|
|
268
|
+
const parameterNames = ['rules', 'user'];
|
|
269
|
+
return (tx: Transaction) =>
|
|
270
|
+
tx.moveCall({
|
|
271
|
+
package: packageAddress,
|
|
272
|
+
module: 'rules',
|
|
273
|
+
function: 'assert_coupon_valid_for_address',
|
|
274
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
export interface IsCouponValidForAddressArguments {
|
|
278
|
+
rules: RawTransactionArgument<string>;
|
|
279
|
+
user: RawTransactionArgument<string>;
|
|
280
|
+
}
|
|
281
|
+
export interface IsCouponValidForAddressOptions {
|
|
282
|
+
package?: string;
|
|
283
|
+
arguments:
|
|
284
|
+
| IsCouponValidForAddressArguments
|
|
285
|
+
| [rules: RawTransactionArgument<string>, user: RawTransactionArgument<string>];
|
|
286
|
+
}
|
|
287
|
+
/** Check that the domain is valid for the specified address */
|
|
288
|
+
export function isCouponValidForAddress(options: IsCouponValidForAddressOptions) {
|
|
289
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
290
|
+
const argumentsTypes = [null, 'address'] satisfies (string | null)[];
|
|
291
|
+
const parameterNames = ['rules', 'user'];
|
|
292
|
+
return (tx: Transaction) =>
|
|
293
|
+
tx.moveCall({
|
|
294
|
+
package: packageAddress,
|
|
295
|
+
module: 'rules',
|
|
296
|
+
function: 'is_coupon_valid_for_address',
|
|
297
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
export interface AssertCouponIsNotExpiredArguments {
|
|
301
|
+
rules: RawTransactionArgument<string>;
|
|
302
|
+
}
|
|
303
|
+
export interface AssertCouponIsNotExpiredOptions {
|
|
304
|
+
package?: string;
|
|
305
|
+
arguments: AssertCouponIsNotExpiredArguments | [rules: RawTransactionArgument<string>];
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Simple assertion for the coupon expiration. Throws `ECouponExpired` error if it
|
|
309
|
+
* has expired.
|
|
310
|
+
*/
|
|
311
|
+
export function assertCouponIsNotExpired(options: AssertCouponIsNotExpiredOptions) {
|
|
312
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
313
|
+
const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
314
|
+
const parameterNames = ['rules'];
|
|
315
|
+
return (tx: Transaction) =>
|
|
316
|
+
tx.moveCall({
|
|
317
|
+
package: packageAddress,
|
|
318
|
+
module: 'rules',
|
|
319
|
+
function: 'assert_coupon_is_not_expired',
|
|
320
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
export interface IsCouponExpiredArguments {
|
|
324
|
+
rules: RawTransactionArgument<string>;
|
|
325
|
+
}
|
|
326
|
+
export interface IsCouponExpiredOptions {
|
|
327
|
+
package?: string;
|
|
328
|
+
arguments: IsCouponExpiredArguments | [rules: RawTransactionArgument<string>];
|
|
329
|
+
}
|
|
330
|
+
/** Check whether a coupon has expired */
|
|
331
|
+
export function isCouponExpired(options: IsCouponExpiredOptions) {
|
|
332
|
+
const packageAddress = options.package ?? '@haneulns/coupons';
|
|
333
|
+
const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
334
|
+
const parameterNames = ['rules'];
|
|
335
|
+
return (tx: Transaction) =>
|
|
336
|
+
tx.moveCall({
|
|
337
|
+
package: packageAddress,
|
|
338
|
+
module: 'rules',
|
|
339
|
+
function: 'is_coupon_expired',
|
|
340
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
341
|
+
});
|
|
342
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Similar to `haneul::table` but the values are linked together, allowing for ordered
|
|
7
|
+
* insertion and removal
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { type BcsType, bcs } from '@haneullabs/haneul/bcs';
|
|
11
|
+
import { MoveStruct } from '../../../utils/index.js';
|
|
12
|
+
const $moduleName = '0x2::linked_table';
|
|
13
|
+
export function LinkedTable<K extends BcsType<any>>(...typeParameters: [K]) {
|
|
14
|
+
return new MoveStruct({
|
|
15
|
+
name: `${$moduleName}::LinkedTable<${typeParameters[0].name as K['name']}, phantom V>`,
|
|
16
|
+
fields: {
|
|
17
|
+
/** the ID of this table */
|
|
18
|
+
id: bcs.Address,
|
|
19
|
+
/** the number of key-value pairs in the table */
|
|
20
|
+
size: bcs.u64(),
|
|
21
|
+
/** the front of the table, i.e. the key of the first entry */
|
|
22
|
+
head: bcs.option(typeParameters[0]),
|
|
23
|
+
/** the back of the table, i.e. the key of the last entry */
|
|
24
|
+
tail: bcs.option(typeParameters[0]),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveTuple } from '../../../utils/index.js';
|
|
5
|
+
import { bcs } from '@haneullabs/haneul/bcs';
|
|
6
|
+
const $moduleName = 'haneulns::pricing_config';
|
|
7
|
+
export const Range = new MoveTuple({
|
|
8
|
+
name: `${$moduleName}::Range`,
|
|
9
|
+
fields: [bcs.u64(), bcs.u64()],
|
|
10
|
+
});
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A module that allows purchasing names in a different price by presenting a
|
|
7
|
+
* reference of type T. Each `T` can have a separate configuration for a discount
|
|
8
|
+
* percentage. If a `T` doesn't exist, registration will fail.
|
|
9
|
+
*
|
|
10
|
+
* Can be called only when promotions are active for a specific type T. Activation
|
|
11
|
+
* / deactivation happens through PTBs.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { MoveTuple, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
|
|
15
|
+
import { bcs, type BcsType } from '@haneullabs/haneul/bcs';
|
|
16
|
+
import { type Transaction } from '@haneullabs/haneul/transactions';
|
|
17
|
+
const $moduleName = '@haneulns/discounts::discounts';
|
|
18
|
+
export const RegularDiscountsApp = new MoveTuple({
|
|
19
|
+
name: `${$moduleName}::RegularDiscountsApp`,
|
|
20
|
+
fields: [bcs.bool()],
|
|
21
|
+
});
|
|
22
|
+
export const DiscountKey = new MoveTuple({
|
|
23
|
+
name: `${$moduleName}::DiscountKey<phantom T>`,
|
|
24
|
+
fields: [bcs.bool()],
|
|
25
|
+
});
|
|
26
|
+
export interface ApplyPercentageDiscountArguments<T extends BcsType<any>> {
|
|
27
|
+
self: RawTransactionArgument<string>;
|
|
28
|
+
intent: RawTransactionArgument<string>;
|
|
29
|
+
haneulns: RawTransactionArgument<string>;
|
|
30
|
+
_: RawTransactionArgument<T>;
|
|
31
|
+
}
|
|
32
|
+
export interface ApplyPercentageDiscountOptions<T extends BcsType<any>> {
|
|
33
|
+
package?: string;
|
|
34
|
+
arguments:
|
|
35
|
+
| ApplyPercentageDiscountArguments<T>
|
|
36
|
+
| [
|
|
37
|
+
self: RawTransactionArgument<string>,
|
|
38
|
+
intent: RawTransactionArgument<string>,
|
|
39
|
+
haneulns: RawTransactionArgument<string>,
|
|
40
|
+
_: RawTransactionArgument<T>,
|
|
41
|
+
];
|
|
42
|
+
typeArguments: [string];
|
|
43
|
+
}
|
|
44
|
+
/** A function to register a name with a discount using type `T`. */
|
|
45
|
+
export function applyPercentageDiscount<T extends BcsType<any>>(
|
|
46
|
+
options: ApplyPercentageDiscountOptions<T>,
|
|
47
|
+
) {
|
|
48
|
+
const packageAddress = options.package ?? '@haneulns/discounts';
|
|
49
|
+
const argumentsTypes = [null, null, null, `${options.typeArguments[0]}`] satisfies (
|
|
50
|
+
| string
|
|
51
|
+
| null
|
|
52
|
+
)[];
|
|
53
|
+
const parameterNames = ['self', 'intent', 'haneulns', '_'];
|
|
54
|
+
return (tx: Transaction) =>
|
|
55
|
+
tx.moveCall({
|
|
56
|
+
package: packageAddress,
|
|
57
|
+
module: 'discounts',
|
|
58
|
+
function: 'apply_percentage_discount',
|
|
59
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
60
|
+
typeArguments: options.typeArguments,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
export interface ApplyDayOneDiscountArguments {
|
|
64
|
+
self: RawTransactionArgument<string>;
|
|
65
|
+
intent: RawTransactionArgument<string>;
|
|
66
|
+
haneulns: RawTransactionArgument<string>;
|
|
67
|
+
dayOne: RawTransactionArgument<string>;
|
|
68
|
+
}
|
|
69
|
+
export interface ApplyDayOneDiscountOptions {
|
|
70
|
+
package?: string;
|
|
71
|
+
arguments:
|
|
72
|
+
| ApplyDayOneDiscountArguments
|
|
73
|
+
| [
|
|
74
|
+
self: RawTransactionArgument<string>,
|
|
75
|
+
intent: RawTransactionArgument<string>,
|
|
76
|
+
haneulns: RawTransactionArgument<string>,
|
|
77
|
+
dayOne: RawTransactionArgument<string>,
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A special function for DayOne registration. We separate it from the normal
|
|
82
|
+
* registration flow because we only want it to be usable for activated DayOnes.
|
|
83
|
+
*/
|
|
84
|
+
export function applyDayOneDiscount(options: ApplyDayOneDiscountOptions) {
|
|
85
|
+
const packageAddress = options.package ?? '@haneulns/discounts';
|
|
86
|
+
const argumentsTypes = [null, null, null, null] satisfies (string | null)[];
|
|
87
|
+
const parameterNames = ['self', 'intent', 'haneulns', 'dayOne'];
|
|
88
|
+
return (tx: Transaction) =>
|
|
89
|
+
tx.moveCall({
|
|
90
|
+
package: packageAddress,
|
|
91
|
+
module: 'discounts',
|
|
92
|
+
function: 'apply_day_one_discount',
|
|
93
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
export interface AuthorizeTypeArguments {
|
|
97
|
+
self: RawTransactionArgument<string>;
|
|
98
|
+
_: RawTransactionArgument<string>;
|
|
99
|
+
pricingConfig: RawTransactionArgument<string>;
|
|
100
|
+
}
|
|
101
|
+
export interface AuthorizeTypeOptions {
|
|
102
|
+
package?: string;
|
|
103
|
+
arguments:
|
|
104
|
+
| AuthorizeTypeArguments
|
|
105
|
+
| [
|
|
106
|
+
self: RawTransactionArgument<string>,
|
|
107
|
+
_: RawTransactionArgument<string>,
|
|
108
|
+
pricingConfig: RawTransactionArgument<string>,
|
|
109
|
+
];
|
|
110
|
+
typeArguments: [string];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* An admin action to authorize a type T for special pricing.
|
|
114
|
+
*
|
|
115
|
+
* When authorizing, we reuse the core `PricingConfig` struct, and only accept it
|
|
116
|
+
* if all the values are in the [0, 100] range. make sure that all the percentages
|
|
117
|
+
* are in the [0, 99] range. We can use `free_claims` to giveaway free names.
|
|
118
|
+
*/
|
|
119
|
+
export function authorizeType(options: AuthorizeTypeOptions) {
|
|
120
|
+
const packageAddress = options.package ?? '@haneulns/discounts';
|
|
121
|
+
const argumentsTypes = [null, null, null] satisfies (string | null)[];
|
|
122
|
+
const parameterNames = ['self', '_', 'pricingConfig'];
|
|
123
|
+
return (tx: Transaction) =>
|
|
124
|
+
tx.moveCall({
|
|
125
|
+
package: packageAddress,
|
|
126
|
+
module: 'discounts',
|
|
127
|
+
function: 'authorize_type',
|
|
128
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
129
|
+
typeArguments: options.typeArguments,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
export interface DeauthorizeTypeArguments {
|
|
133
|
+
_: RawTransactionArgument<string>;
|
|
134
|
+
self: RawTransactionArgument<string>;
|
|
135
|
+
}
|
|
136
|
+
export interface DeauthorizeTypeOptions {
|
|
137
|
+
package?: string;
|
|
138
|
+
arguments:
|
|
139
|
+
| DeauthorizeTypeArguments
|
|
140
|
+
| [_: RawTransactionArgument<string>, self: RawTransactionArgument<string>];
|
|
141
|
+
typeArguments: [string];
|
|
142
|
+
}
|
|
143
|
+
/** An admin action to deauthorize type T from getting discounts. */
|
|
144
|
+
export function deauthorizeType(options: DeauthorizeTypeOptions) {
|
|
145
|
+
const packageAddress = options.package ?? '@haneulns/discounts';
|
|
146
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
147
|
+
const parameterNames = ['_', 'self'];
|
|
148
|
+
return (tx: Transaction) =>
|
|
149
|
+
tx.moveCall({
|
|
150
|
+
package: packageAddress,
|
|
151
|
+
module: 'discounts',
|
|
152
|
+
function: 'deauthorize_type',
|
|
153
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
154
|
+
typeArguments: options.typeArguments,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A module that allows claiming names of a set length for free by presenting an
|
|
7
|
+
* object T. Each `T` can have a separate configuration for a discount percentage.
|
|
8
|
+
* If a `T` doesn't exist, registration will fail.
|
|
9
|
+
*
|
|
10
|
+
* Can be called only when promotions are active for a specific type T. Activation
|
|
11
|
+
* / deactivation happens through PTBs.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
MoveTuple,
|
|
16
|
+
MoveStruct,
|
|
17
|
+
normalizeMoveArguments,
|
|
18
|
+
type RawTransactionArgument,
|
|
19
|
+
} from '../utils/index.js';
|
|
20
|
+
import { bcs, type BcsType } from '@haneullabs/haneul/bcs';
|
|
21
|
+
import { type Transaction } from '@haneullabs/haneul/transactions';
|
|
22
|
+
import * as pricing_config from './deps/haneulns/pricing_config.js';
|
|
23
|
+
import * as linked_table from './deps/haneul/linked_table.js';
|
|
24
|
+
const $moduleName = '@haneulns/discounts::free_claims';
|
|
25
|
+
export const FreeClaimsApp = new MoveTuple({
|
|
26
|
+
name: `${$moduleName}::FreeClaimsApp`,
|
|
27
|
+
fields: [bcs.bool()],
|
|
28
|
+
});
|
|
29
|
+
export const FreeClaimsKey = new MoveTuple({
|
|
30
|
+
name: `${$moduleName}::FreeClaimsKey<phantom T>`,
|
|
31
|
+
fields: [bcs.bool()],
|
|
32
|
+
});
|
|
33
|
+
export const FreeClaimsConfig = new MoveStruct({
|
|
34
|
+
name: `${$moduleName}::FreeClaimsConfig`,
|
|
35
|
+
fields: {
|
|
36
|
+
domain_length_range: pricing_config.Range,
|
|
37
|
+
used_objects: linked_table.LinkedTable(bcs.Address),
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
export interface FreeClaimArguments<T extends BcsType<any>> {
|
|
41
|
+
self: RawTransactionArgument<string>;
|
|
42
|
+
haneulns: RawTransactionArgument<string>;
|
|
43
|
+
intent: RawTransactionArgument<string>;
|
|
44
|
+
object: RawTransactionArgument<T>;
|
|
45
|
+
}
|
|
46
|
+
export interface FreeClaimOptions<T extends BcsType<any>> {
|
|
47
|
+
package?: string;
|
|
48
|
+
arguments:
|
|
49
|
+
| FreeClaimArguments<T>
|
|
50
|
+
| [
|
|
51
|
+
self: RawTransactionArgument<string>,
|
|
52
|
+
haneulns: RawTransactionArgument<string>,
|
|
53
|
+
intent: RawTransactionArgument<string>,
|
|
54
|
+
object: RawTransactionArgument<T>,
|
|
55
|
+
];
|
|
56
|
+
typeArguments: [string];
|
|
57
|
+
}
|
|
58
|
+
/** A function to register a name with a discount using type `T`. */
|
|
59
|
+
export function freeClaim<T extends BcsType<any>>(options: FreeClaimOptions<T>) {
|
|
60
|
+
const packageAddress = options.package ?? '@haneulns/discounts';
|
|
61
|
+
const argumentsTypes = [null, null, null, `${options.typeArguments[0]}`] satisfies (
|
|
62
|
+
| string
|
|
63
|
+
| null
|
|
64
|
+
)[];
|
|
65
|
+
const parameterNames = ['self', 'haneulns', 'intent', 'object'];
|
|
66
|
+
return (tx: Transaction) =>
|
|
67
|
+
tx.moveCall({
|
|
68
|
+
package: packageAddress,
|
|
69
|
+
module: 'free_claims',
|
|
70
|
+
function: 'free_claim',
|
|
71
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
72
|
+
typeArguments: options.typeArguments,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export interface FreeClaimWithDayOneArguments {
|
|
76
|
+
self: RawTransactionArgument<string>;
|
|
77
|
+
haneulns: RawTransactionArgument<string>;
|
|
78
|
+
intent: RawTransactionArgument<string>;
|
|
79
|
+
dayOne: RawTransactionArgument<string>;
|
|
80
|
+
}
|
|
81
|
+
export interface FreeClaimWithDayOneOptions {
|
|
82
|
+
package?: string;
|
|
83
|
+
arguments:
|
|
84
|
+
| FreeClaimWithDayOneArguments
|
|
85
|
+
| [
|
|
86
|
+
self: RawTransactionArgument<string>,
|
|
87
|
+
haneulns: RawTransactionArgument<string>,
|
|
88
|
+
intent: RawTransactionArgument<string>,
|
|
89
|
+
dayOne: RawTransactionArgument<string>,
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
export function freeClaimWithDayOne(options: FreeClaimWithDayOneOptions) {
|
|
93
|
+
const packageAddress = options.package ?? '@haneulns/discounts';
|
|
94
|
+
const argumentsTypes = [null, null, null, null] satisfies (string | null)[];
|
|
95
|
+
const parameterNames = ['self', 'haneulns', 'intent', 'dayOne'];
|
|
96
|
+
return (tx: Transaction) =>
|
|
97
|
+
tx.moveCall({
|
|
98
|
+
package: packageAddress,
|
|
99
|
+
module: 'free_claims',
|
|
100
|
+
function: 'free_claim_with_day_one',
|
|
101
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
export interface AuthorizeTypeArguments {
|
|
105
|
+
self: RawTransactionArgument<string>;
|
|
106
|
+
_: RawTransactionArgument<string>;
|
|
107
|
+
domainLengthRange: RawTransactionArgument<string>;
|
|
108
|
+
}
|
|
109
|
+
export interface AuthorizeTypeOptions {
|
|
110
|
+
package?: string;
|
|
111
|
+
arguments:
|
|
112
|
+
| AuthorizeTypeArguments
|
|
113
|
+
| [
|
|
114
|
+
self: RawTransactionArgument<string>,
|
|
115
|
+
_: RawTransactionArgument<string>,
|
|
116
|
+
domainLengthRange: RawTransactionArgument<string>,
|
|
117
|
+
];
|
|
118
|
+
typeArguments: [string];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* An admin action to authorize a type T for free claiming of names by presenting
|
|
122
|
+
* an object of type `T`.
|
|
123
|
+
*/
|
|
124
|
+
export function authorizeType(options: AuthorizeTypeOptions) {
|
|
125
|
+
const packageAddress = options.package ?? '@haneulns/discounts';
|
|
126
|
+
const argumentsTypes = [null, null, null] satisfies (string | null)[];
|
|
127
|
+
const parameterNames = ['self', '_', 'domainLengthRange'];
|
|
128
|
+
return (tx: Transaction) =>
|
|
129
|
+
tx.moveCall({
|
|
130
|
+
package: packageAddress,
|
|
131
|
+
module: 'free_claims',
|
|
132
|
+
function: 'authorize_type',
|
|
133
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
134
|
+
typeArguments: options.typeArguments,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
export interface DeauthorizeTypeArguments {
|
|
138
|
+
self: RawTransactionArgument<string>;
|
|
139
|
+
_: RawTransactionArgument<string>;
|
|
140
|
+
}
|
|
141
|
+
export interface DeauthorizeTypeOptions {
|
|
142
|
+
package?: string;
|
|
143
|
+
arguments:
|
|
144
|
+
| DeauthorizeTypeArguments
|
|
145
|
+
| [self: RawTransactionArgument<string>, _: RawTransactionArgument<string>];
|
|
146
|
+
typeArguments: [string];
|
|
147
|
+
}
|
|
148
|
+
/** Force-deauthorize type T from free claims. Drops the linked_table. */
|
|
149
|
+
export function deauthorizeType(options: DeauthorizeTypeOptions) {
|
|
150
|
+
const packageAddress = options.package ?? '@haneulns/discounts';
|
|
151
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
152
|
+
const parameterNames = ['self', '_'];
|
|
153
|
+
return (tx: Transaction) =>
|
|
154
|
+
tx.moveCall({
|
|
155
|
+
package: packageAddress,
|
|
156
|
+
module: 'free_claims',
|
|
157
|
+
function: 'deauthorize_type',
|
|
158
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
159
|
+
typeArguments: options.typeArguments,
|
|
160
|
+
});
|
|
161
|
+
}
|