@haneullabs/payment-kit 0.1.0
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/README.md +123 -0
- package/dist/cjs/calls.d.ts +71 -0
- package/dist/cjs/calls.js +207 -0
- package/dist/cjs/calls.js.map +7 -0
- package/dist/cjs/client.d.ts +36 -0
- package/dist/cjs/client.js +123 -0
- package/dist/cjs/client.js.map +7 -0
- package/dist/cjs/constants.d.ts +11 -0
- package/dist/cjs/constants.js +40 -0
- package/dist/cjs/constants.js.map +7 -0
- package/dist/cjs/contracts/payment_kit/config.d.ts +14 -0
- package/dist/cjs/contracts/payment_kit/config.js +50 -0
- package/dist/cjs/contracts/payment_kit/config.js.map +7 -0
- package/dist/cjs/contracts/payment_kit/deps/std/type_name.d.ts +14 -0
- package/dist/cjs/contracts/payment_kit/deps/std/type_name.js +42 -0
- package/dist/cjs/contracts/payment_kit/deps/std/type_name.js.map +7 -0
- package/dist/cjs/contracts/payment_kit/deps/sui/object.d.ts +5 -0
- package/dist/cjs/contracts/payment_kit/deps/sui/object.js +33 -0
- package/dist/cjs/contracts/payment_kit/deps/sui/object.js.map +7 -0
- package/dist/cjs/contracts/payment_kit/deps/sui/vec_map.d.ts +27 -0
- package/dist/cjs/contracts/payment_kit/deps/sui/vec_map.js +45 -0
- package/dist/cjs/contracts/payment_kit/deps/sui/vec_map.js.map +7 -0
- package/dist/cjs/contracts/payment_kit/payment_kit.d.ts +233 -0
- package/dist/cjs/contracts/payment_kit/payment_kit.js +252 -0
- package/dist/cjs/contracts/payment_kit/payment_kit.js.map +7 -0
- package/dist/cjs/contracts/utils/index.d.ts +12 -0
- package/dist/cjs/contracts/utils/index.js +151 -0
- package/dist/cjs/contracts/utils/index.js.map +7 -0
- package/dist/cjs/error.d.ts +4 -0
- package/dist/cjs/error.js +29 -0
- package/dist/cjs/error.js.map +7 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/transactions.d.ts +73 -0
- package/dist/cjs/transactions.js +131 -0
- package/dist/cjs/transactions.js.map +7 -0
- package/dist/cjs/types.d.ts +62 -0
- package/dist/cjs/types.js +17 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/cjs/uri.d.ts +27 -0
- package/dist/cjs/uri.js +131 -0
- package/dist/cjs/uri.js.map +7 -0
- package/dist/cjs/utils.d.ts +1 -0
- package/dist/cjs/utils.js +34 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/esm/calls.d.ts +71 -0
- package/dist/esm/calls.js +196 -0
- package/dist/esm/calls.js.map +7 -0
- package/dist/esm/client.d.ts +36 -0
- package/dist/esm/client.js +106 -0
- package/dist/esm/client.js.map +7 -0
- package/dist/esm/constants.d.ts +11 -0
- package/dist/esm/constants.js +20 -0
- package/dist/esm/constants.js.map +7 -0
- package/dist/esm/contracts/payment_kit/config.d.ts +14 -0
- package/dist/esm/contracts/payment_kit/config.js +20 -0
- package/dist/esm/contracts/payment_kit/config.js.map +7 -0
- package/dist/esm/contracts/payment_kit/deps/std/type_name.d.ts +14 -0
- package/dist/esm/contracts/payment_kit/deps/std/type_name.js +22 -0
- package/dist/esm/contracts/payment_kit/deps/std/type_name.js.map +7 -0
- package/dist/esm/contracts/payment_kit/deps/sui/object.d.ts +5 -0
- package/dist/esm/contracts/payment_kit/deps/sui/object.js +13 -0
- package/dist/esm/contracts/payment_kit/deps/sui/object.js.map +7 -0
- package/dist/esm/contracts/payment_kit/deps/sui/vec_map.d.ts +27 -0
- package/dist/esm/contracts/payment_kit/deps/sui/vec_map.js +25 -0
- package/dist/esm/contracts/payment_kit/deps/sui/vec_map.js.map +7 -0
- package/dist/esm/contracts/payment_kit/payment_kit.d.ts +233 -0
- package/dist/esm/contracts/payment_kit/payment_kit.js +222 -0
- package/dist/esm/contracts/payment_kit/payment_kit.js.map +7 -0
- package/dist/esm/contracts/utils/index.d.ts +12 -0
- package/dist/esm/contracts/utils/index.js +131 -0
- package/dist/esm/contracts/utils/index.js.map +7 -0
- package/dist/esm/error.d.ts +4 -0
- package/dist/esm/error.js +9 -0
- package/dist/esm/error.js.map +7 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +5 -0
- package/dist/esm/transactions.d.ts +73 -0
- package/dist/esm/transactions.js +111 -0
- package/dist/esm/transactions.js.map +7 -0
- package/dist/esm/types.d.ts +62 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/esm/uri.d.ts +27 -0
- package/dist/esm/uri.js +111 -0
- package/dist/esm/uri.js.map +7 -0
- package/dist/esm/utils.d.ts +1 -0
- package/dist/esm/utils.js +14 -0
- package/dist/esm/utils.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Transaction } from '@haneullabs/haneul/transactions';
|
|
2
|
+
import type { CreateRegistryOptions, DeletePaymentRecordOptions, ProcessEphemeralPaymentOptions, ProcessRegistryPaymentOptions, SetEpochExpirationDurationOptions, SetRegistryManagedFundsOptions, WithdrawFromRegistryOptions } from './types.js';
|
|
3
|
+
import type { PaymentKitCalls } from './calls.js';
|
|
4
|
+
export interface PaymentKitTransactionsOptions {
|
|
5
|
+
calls: PaymentKitCalls;
|
|
6
|
+
}
|
|
7
|
+
export declare class PaymentKitTransactions {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(options: PaymentKitTransactionsOptions);
|
|
10
|
+
/**
|
|
11
|
+
* Creates a `processRegistryPayment` transaction
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const tx = client.paymentKit.tx.processRegistryPayment({ nonce, coinType, sender, amount, receiver, registryName });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
processRegistryPayment(options: ProcessRegistryPaymentOptions): Transaction;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a `processEphemeralPayment` transaction
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const tx = client.paymentKit.tx.processEphemeralPayment({ nonce, coinType, sender, amount, receiver });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
processEphemeralPayment(options: ProcessEphemeralPaymentOptions): Transaction;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a `createRegistry` transaction
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const tx = client.paymentKit.tx.createRegistry({ registryName });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
createRegistry(options: CreateRegistryOptions): Transaction;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a `setConfigEpochExpirationDuration` transaction
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const tx = client.paymentKit.tx.setConfigEpochExpirationDuration({ registryName, epochExpirationDuration, adminCapId });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
setConfigEpochExpirationDuration(options: SetEpochExpirationDurationOptions): Transaction;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a `setConfigRegistryManagedFunds` transaction
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const tx = client.paymentKit.tx.setConfigRegistryManagedFunds({ registryName, registryManagedFunds, adminCapId });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
setConfigRegistryManagedFunds(options: SetRegistryManagedFundsOptions): Transaction;
|
|
55
|
+
/**
|
|
56
|
+
* Creates a `withdrawFromRegistry` transaction
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const tx = client.paymentKit.tx.withdrawFromRegistry({ coinType, registryName, adminCapId });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
withdrawFromRegistry(options: WithdrawFromRegistryOptions): Transaction;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a `deletePaymentRecord` transaction
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const tx = client.paymentKit.tx.deletePaymentRecord({ coinType, nonce, amount, receiver, registryName });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
deletePaymentRecord(options: DeletePaymentRecordOptions): Transaction;
|
|
73
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __typeError = (msg) => {
|
|
7
|
+
throw TypeError(msg);
|
|
8
|
+
};
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
23
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
24
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
25
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
26
|
+
var transactions_exports = {};
|
|
27
|
+
__export(transactions_exports, {
|
|
28
|
+
PaymentKitTransactions: () => PaymentKitTransactions
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(transactions_exports);
|
|
31
|
+
var import_transactions = require("@haneullabs/haneul/transactions");
|
|
32
|
+
var _calls;
|
|
33
|
+
class PaymentKitTransactions {
|
|
34
|
+
constructor(options) {
|
|
35
|
+
__privateAdd(this, _calls);
|
|
36
|
+
__privateSet(this, _calls, options.calls);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates a `processRegistryPayment` transaction
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const tx = client.paymentKit.tx.processRegistryPayment({ nonce, coinType, sender, amount, receiver, registryName });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
processRegistryPayment(options) {
|
|
47
|
+
const tx = new import_transactions.Transaction();
|
|
48
|
+
tx.add(__privateGet(this, _calls).processRegistryPayment(options));
|
|
49
|
+
return tx;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates a `processEphemeralPayment` transaction
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const tx = client.paymentKit.tx.processEphemeralPayment({ nonce, coinType, sender, amount, receiver });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
processEphemeralPayment(options) {
|
|
60
|
+
const tx = new import_transactions.Transaction();
|
|
61
|
+
tx.add(__privateGet(this, _calls).processEphemeralPayment(options));
|
|
62
|
+
return tx;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Creates a `createRegistry` transaction
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const tx = client.paymentKit.tx.createRegistry({ registryName });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
createRegistry(options) {
|
|
73
|
+
const tx = new import_transactions.Transaction();
|
|
74
|
+
tx.add(__privateGet(this, _calls).createRegistry(options));
|
|
75
|
+
return tx;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Creates a `setConfigEpochExpirationDuration` transaction
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const tx = client.paymentKit.tx.setConfigEpochExpirationDuration({ registryName, epochExpirationDuration, adminCapId });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
setConfigEpochExpirationDuration(options) {
|
|
86
|
+
const tx = new import_transactions.Transaction();
|
|
87
|
+
tx.add(__privateGet(this, _calls).setConfigEpochExpirationDuration(options));
|
|
88
|
+
return tx;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Creates a `setConfigRegistryManagedFunds` transaction
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* const tx = client.paymentKit.tx.setConfigRegistryManagedFunds({ registryName, registryManagedFunds, adminCapId });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
setConfigRegistryManagedFunds(options) {
|
|
99
|
+
const tx = new import_transactions.Transaction();
|
|
100
|
+
tx.add(__privateGet(this, _calls).setConfigRegistryManagedFunds(options));
|
|
101
|
+
return tx;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Creates a `withdrawFromRegistry` transaction
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const tx = client.paymentKit.tx.withdrawFromRegistry({ coinType, registryName, adminCapId });
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
withdrawFromRegistry(options) {
|
|
112
|
+
const tx = new import_transactions.Transaction();
|
|
113
|
+
tx.add(__privateGet(this, _calls).withdrawFromRegistry(options));
|
|
114
|
+
return tx;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Creates a `deletePaymentRecord` transaction
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* const tx = client.paymentKit.tx.deletePaymentRecord({ coinType, nonce, amount, receiver, registryName });
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
deletePaymentRecord(options) {
|
|
125
|
+
const tx = new import_transactions.Transaction();
|
|
126
|
+
tx.add(__privateGet(this, _calls).deletePaymentRecord(options));
|
|
127
|
+
return tx;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
_calls = new WeakMap();
|
|
131
|
+
//# sourceMappingURL=transactions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/transactions.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Transaction } from '@haneullabs/haneul/transactions';\nimport type {\n\tCreateRegistryOptions,\n\tDeletePaymentRecordOptions,\n\tProcessEphemeralPaymentOptions,\n\tProcessRegistryPaymentOptions,\n\tSetEpochExpirationDurationOptions,\n\tSetRegistryManagedFundsOptions,\n\tWithdrawFromRegistryOptions,\n} from './types.js';\nimport type { PaymentKitCalls } from './calls.js';\n\nexport interface PaymentKitTransactionsOptions {\n\tcalls: PaymentKitCalls;\n}\n\nexport class PaymentKitTransactions {\n\t#calls: PaymentKitCalls;\n\n\tconstructor(options: PaymentKitTransactionsOptions) {\n\t\tthis.#calls = options.calls;\n\t}\n\n\t/**\n\t * Creates a `processRegistryPayment` transaction\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.paymentKit.tx.processRegistryPayment({ nonce, coinType, sender, amount, receiver, registryName });\n\t * ```\n\t */\n\tprocessRegistryPayment(options: ProcessRegistryPaymentOptions) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#calls.processRegistryPayment(options));\n\n\t\treturn tx;\n\t}\n\n\t/**\n\t * Creates a `processEphemeralPayment` transaction\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.paymentKit.tx.processEphemeralPayment({ nonce, coinType, sender, amount, receiver });\n\t * ```\n\t */\n\tprocessEphemeralPayment(options: ProcessEphemeralPaymentOptions) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#calls.processEphemeralPayment(options));\n\n\t\treturn tx;\n\t}\n\n\t/**\n\t * Creates a `createRegistry` transaction\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.paymentKit.tx.createRegistry({ registryName });\n\t * ```\n\t */\n\tcreateRegistry(options: CreateRegistryOptions) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#calls.createRegistry(options));\n\n\t\treturn tx;\n\t}\n\n\t/**\n\t * Creates a `setConfigEpochExpirationDuration` transaction\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.paymentKit.tx.setConfigEpochExpirationDuration({ registryName, epochExpirationDuration, adminCapId });\n\t * ```\n\t */\n\tsetConfigEpochExpirationDuration(options: SetEpochExpirationDurationOptions) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#calls.setConfigEpochExpirationDuration(options));\n\n\t\treturn tx;\n\t}\n\n\t/**\n\t * Creates a `setConfigRegistryManagedFunds` transaction\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.paymentKit.tx.setConfigRegistryManagedFunds({ registryName, registryManagedFunds, adminCapId });\n\t * ```\n\t */\n\tsetConfigRegistryManagedFunds(options: SetRegistryManagedFundsOptions) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#calls.setConfigRegistryManagedFunds(options));\n\n\t\treturn tx;\n\t}\n\n\t/**\n\t * Creates a `withdrawFromRegistry` transaction\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.paymentKit.tx.withdrawFromRegistry({ coinType, registryName, adminCapId });\n\t * ```\n\t */\n\twithdrawFromRegistry(options: WithdrawFromRegistryOptions) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#calls.withdrawFromRegistry(options));\n\n\t\treturn tx;\n\t}\n\n\t/**\n\t * Creates a `deletePaymentRecord` transaction\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = client.paymentKit.tx.deletePaymentRecord({ coinType, nonce, amount, receiver, registryName });\n\t * ```\n\t */\n\tdeletePaymentRecord(options: DeletePaymentRecordOptions) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#calls.deletePaymentRecord(options));\n\n\t\treturn tx;\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAA4B;AAH5B;AAmBO,MAAM,uBAAuB;AAAA,EAGnC,YAAY,SAAwC;AAFpD;AAGC,uBAAK,QAAS,QAAQ;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,uBAAuB,SAAwC;AAC9D,UAAM,KAAK,IAAI,gCAAY;AAC3B,OAAG,IAAI,mBAAK,QAAO,uBAAuB,OAAO,CAAC;AAElD,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,wBAAwB,SAAyC;AAChE,UAAM,KAAK,IAAI,gCAAY;AAC3B,OAAG,IAAI,mBAAK,QAAO,wBAAwB,OAAO,CAAC;AAEnD,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,eAAe,SAAgC;AAC9C,UAAM,KAAK,IAAI,gCAAY;AAC3B,OAAG,IAAI,mBAAK,QAAO,eAAe,OAAO,CAAC;AAE1C,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,iCAAiC,SAA4C;AAC5E,UAAM,KAAK,IAAI,gCAAY;AAC3B,OAAG,IAAI,mBAAK,QAAO,iCAAiC,OAAO,CAAC;AAE5D,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,8BAA8B,SAAyC;AACtE,UAAM,KAAK,IAAI,gCAAY;AAC3B,OAAG,IAAI,mBAAK,QAAO,8BAA8B,OAAO,CAAC;AAEzD,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,qBAAqB,SAAsC;AAC1D,UAAM,KAAK,IAAI,gCAAY;AAC3B,OAAG,IAAI,mBAAK,QAAO,qBAAqB,OAAO,CAAC;AAEhD,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,oBAAoB,SAAqC;AACxD,UAAM,KAAK,IAAI,gCAAY;AAC3B,OAAG,IAAI,mBAAK,QAAO,oBAAoB,OAAO,CAAC;AAE/C,WAAO;AAAA,EACR;AACD;AA9GC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { TransactionResult } from '@haneullabs/haneul/transactions';
|
|
2
|
+
import type { ClientWithCoreApi } from '@haneullabs/haneul/experimental';
|
|
3
|
+
export type PaymentKitPackageConfig = {
|
|
4
|
+
packageId: string;
|
|
5
|
+
namespaceId: string;
|
|
6
|
+
};
|
|
7
|
+
export interface PaymentKitCompatibleClient extends ClientWithCoreApi {
|
|
8
|
+
}
|
|
9
|
+
export interface PaymentKitClientOptions {
|
|
10
|
+
client: PaymentKitCompatibleClient;
|
|
11
|
+
}
|
|
12
|
+
export type Registry = {
|
|
13
|
+
registryName?: string;
|
|
14
|
+
registryId?: never;
|
|
15
|
+
} | {
|
|
16
|
+
registryName?: never;
|
|
17
|
+
registryId: string;
|
|
18
|
+
};
|
|
19
|
+
export type RegistryAndAdminCap = {
|
|
20
|
+
adminCapId: string;
|
|
21
|
+
} & Registry;
|
|
22
|
+
export type PaymentKeyArgs = {
|
|
23
|
+
coinType: string;
|
|
24
|
+
nonce: string;
|
|
25
|
+
amount: number | bigint;
|
|
26
|
+
receiver: string;
|
|
27
|
+
};
|
|
28
|
+
export type GetPaymentRecordOptions = PaymentKeyArgs & Registry;
|
|
29
|
+
export interface GetPaymentRecordResponse {
|
|
30
|
+
key: string;
|
|
31
|
+
paymentTransactionDigest: string | null;
|
|
32
|
+
epochAtTimeOfRecord: string;
|
|
33
|
+
}
|
|
34
|
+
export type ProcessEphemeralPaymentOptions = {
|
|
35
|
+
sender: string;
|
|
36
|
+
sourceCoin?: TransactionResult;
|
|
37
|
+
} & PaymentKeyArgs;
|
|
38
|
+
export type ProcessRegistryPaymentOptions = ProcessEphemeralPaymentOptions & Registry;
|
|
39
|
+
export type CreateRegistryOptions = {
|
|
40
|
+
registryName: string;
|
|
41
|
+
};
|
|
42
|
+
export type SetEpochExpirationDurationOptions = {
|
|
43
|
+
epochExpirationDuration: number | bigint;
|
|
44
|
+
} & RegistryAndAdminCap;
|
|
45
|
+
export type SetRegistryManagedFundsOptions = {
|
|
46
|
+
registryManagedFunds: boolean;
|
|
47
|
+
} & RegistryAndAdminCap;
|
|
48
|
+
export type WithdrawFromRegistryOptions = {
|
|
49
|
+
coinType: string;
|
|
50
|
+
} & RegistryAndAdminCap;
|
|
51
|
+
export type DeletePaymentRecordOptions = {
|
|
52
|
+
coinType: string;
|
|
53
|
+
} & PaymentKeyArgs & Registry;
|
|
54
|
+
export type PaymentUriParams = {
|
|
55
|
+
receiverAddress: string;
|
|
56
|
+
amount: bigint;
|
|
57
|
+
coinType: string;
|
|
58
|
+
nonce: string;
|
|
59
|
+
label?: string;
|
|
60
|
+
message?: string;
|
|
61
|
+
iconUrl?: string;
|
|
62
|
+
} & Partial<Registry>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { TransactionResult } from '@haneullabs/haneul/transactions';\nimport type { ClientWithCoreApi } from '@haneullabs/haneul/experimental';\n\nexport type PaymentKitPackageConfig = {\n\tpackageId: string;\n\tnamespaceId: string;\n};\n\nexport interface PaymentKitCompatibleClient extends ClientWithCoreApi {}\n\nexport interface PaymentKitClientOptions {\n\tclient: PaymentKitCompatibleClient;\n}\n\nexport type Registry =\n\t| { registryName?: string; registryId?: never }\n\t| { registryName?: never; registryId: string };\n\nexport type RegistryAndAdminCap = {\n\tadminCapId: string;\n} & Registry;\n\nexport type PaymentKeyArgs = {\n\tcoinType: string;\n\tnonce: string;\n\tamount: number | bigint;\n\treceiver: string;\n};\n\nexport type GetPaymentRecordOptions = PaymentKeyArgs & Registry;\n\nexport interface GetPaymentRecordResponse {\n\tkey: string;\n\tpaymentTransactionDigest: string | null;\n\tepochAtTimeOfRecord: string;\n}\n\nexport type ProcessEphemeralPaymentOptions = {\n\tsender: string;\n\tsourceCoin?: TransactionResult;\n} & PaymentKeyArgs;\n\nexport type ProcessRegistryPaymentOptions = ProcessEphemeralPaymentOptions & Registry;\n\nexport type CreateRegistryOptions = {\n\tregistryName: string;\n};\n\nexport type SetEpochExpirationDurationOptions = {\n\tepochExpirationDuration: number | bigint;\n} & RegistryAndAdminCap;\n\nexport type SetRegistryManagedFundsOptions = {\n\tregistryManagedFunds: boolean;\n} & RegistryAndAdminCap;\n\nexport type WithdrawFromRegistryOptions = {\n\tcoinType: string;\n} & RegistryAndAdminCap;\n\nexport type DeletePaymentRecordOptions = {\n\tcoinType: string;\n} & PaymentKeyArgs &\n\tRegistry;\n\nexport type PaymentUriParams = {\n\treceiverAddress: string;\n\tamount: bigint;\n\tcoinType: string;\n\tnonce: string;\n\tlabel?: string;\n\tmessage?: string;\n\ticonUrl?: string;\n} & Partial<Registry>;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PaymentUriParams } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create a payment transaction URI from the given parameters.
|
|
4
|
+
* Returns the constructed URI string.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const uri = createPaymentTransactionUri({
|
|
9
|
+
* receiverAddress: "0x...",
|
|
10
|
+
* amount: "10000000", (0.01 SUI)
|
|
11
|
+
* coinType: "0x2::haneul::HANEUL",
|
|
12
|
+
* nonce: <nonce>,
|
|
13
|
+
* registryName: "my-registry"
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const createPaymentTransactionUri: (params: PaymentUriParams) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Parse a payment transaction URI into its components.
|
|
20
|
+
* Returns the parsed payment URI parameters.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const params = parsePaymentTransactionUri("sui:0x...?amount=1000000&coinType=0x...&nonce=...");
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const parsePaymentTransactionUri: (uri: string) => PaymentUriParams;
|
package/dist/cjs/uri.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var uri_exports = {};
|
|
20
|
+
__export(uri_exports, {
|
|
21
|
+
createPaymentTransactionUri: () => createPaymentTransactionUri,
|
|
22
|
+
parsePaymentTransactionUri: () => parsePaymentTransactionUri
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(uri_exports);
|
|
25
|
+
var import_utils = require("@haneullabs/haneul/utils");
|
|
26
|
+
var import_error = require("./error.js");
|
|
27
|
+
var import_constants = require("./constants.js");
|
|
28
|
+
const isValidNonce = (nonce) => {
|
|
29
|
+
return nonce.length <= 36;
|
|
30
|
+
};
|
|
31
|
+
const isValidAmount = (amount) => {
|
|
32
|
+
return amount > 0n;
|
|
33
|
+
};
|
|
34
|
+
const isValidCoinType = (coinType) => {
|
|
35
|
+
return (0, import_utils.isValidNamedType)(coinType);
|
|
36
|
+
};
|
|
37
|
+
const createPaymentTransactionUri = (params) => {
|
|
38
|
+
const { receiverAddress, amount, coinType, nonce, registryId, registryName } = params;
|
|
39
|
+
const uri = new URL(import_constants.SUI_PAYMENT_KIT_PROTOCOL);
|
|
40
|
+
if ((0, import_utils.isValidHaneulAddress)(receiverAddress)) {
|
|
41
|
+
uri.searchParams.append("receiver", receiverAddress);
|
|
42
|
+
} else {
|
|
43
|
+
throw new import_error.PaymentKitUriError("Invalid Haneul address");
|
|
44
|
+
}
|
|
45
|
+
if (isValidAmount(amount)) {
|
|
46
|
+
uri.searchParams.append("amount", amount.toString());
|
|
47
|
+
} else {
|
|
48
|
+
throw new import_error.PaymentKitUriError("Amount must be a positive numeric string");
|
|
49
|
+
}
|
|
50
|
+
if (isValidCoinType(coinType)) {
|
|
51
|
+
uri.searchParams.append("coinType", coinType);
|
|
52
|
+
} else {
|
|
53
|
+
throw new import_error.PaymentKitUriError("Invalid Coin Type");
|
|
54
|
+
}
|
|
55
|
+
if (isValidNonce(nonce)) {
|
|
56
|
+
uri.searchParams.append("nonce", nonce);
|
|
57
|
+
} else {
|
|
58
|
+
throw new import_error.PaymentKitUriError("Nonce length exceeds maximum of 36 characters");
|
|
59
|
+
}
|
|
60
|
+
if (registryId) {
|
|
61
|
+
if ((0, import_utils.isValidHaneulObjectId)(registryId)) {
|
|
62
|
+
uri.searchParams.append("registry", registryId);
|
|
63
|
+
} else {
|
|
64
|
+
throw new import_error.PaymentKitUriError("Invalid Haneul Object Id for Registry Id");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (registryName) {
|
|
68
|
+
uri.searchParams.append("registry", registryName);
|
|
69
|
+
}
|
|
70
|
+
if (params.label) {
|
|
71
|
+
uri.searchParams.append("label", params.label);
|
|
72
|
+
}
|
|
73
|
+
if (params.message) {
|
|
74
|
+
uri.searchParams.append("message", params.message);
|
|
75
|
+
}
|
|
76
|
+
if (params.iconUrl) {
|
|
77
|
+
uri.searchParams.append("iconUrl", params.iconUrl);
|
|
78
|
+
}
|
|
79
|
+
return uri.toString();
|
|
80
|
+
};
|
|
81
|
+
const parsePaymentTransactionUri = (uri) => {
|
|
82
|
+
if (!uri.startsWith(import_constants.SUI_PAYMENT_KIT_PROTOCOL + "?")) {
|
|
83
|
+
throw new import_error.PaymentKitUriError("Invalid URI: Must start with sui:pay?");
|
|
84
|
+
}
|
|
85
|
+
const url = new URL(uri);
|
|
86
|
+
const params = url.searchParams;
|
|
87
|
+
const receiver = params.get("receiver");
|
|
88
|
+
const amount = params.get("amount");
|
|
89
|
+
const coinType = params.get("coinType");
|
|
90
|
+
const nonce = params.get("nonce");
|
|
91
|
+
if (!receiver || !amount || !coinType || !nonce) {
|
|
92
|
+
throw new import_error.PaymentKitUriError("Invalid URI: Missing required parameters");
|
|
93
|
+
}
|
|
94
|
+
if (!(0, import_utils.isValidHaneulAddress)(receiver)) {
|
|
95
|
+
throw new import_error.PaymentKitUriError("Invalid URI: Receiver address is not valid");
|
|
96
|
+
}
|
|
97
|
+
if (!isValidCoinType(coinType)) {
|
|
98
|
+
throw new import_error.PaymentKitUriError("Invalid URI: Coin Type is not valid");
|
|
99
|
+
}
|
|
100
|
+
if (!isValidNonce(nonce)) {
|
|
101
|
+
throw new import_error.PaymentKitUriError("Invalid URI: Nonce length exceeds maximum of 36 characters");
|
|
102
|
+
}
|
|
103
|
+
const bigIntAmount = BigInt(amount);
|
|
104
|
+
if (!isValidAmount(bigIntAmount)) {
|
|
105
|
+
throw new import_error.PaymentKitUriError("Invalid URI: Amount must be a positive number");
|
|
106
|
+
}
|
|
107
|
+
const registry = params.get("registry") ?? void 0;
|
|
108
|
+
let registryId;
|
|
109
|
+
let registryName;
|
|
110
|
+
if (registry) {
|
|
111
|
+
if ((0, import_utils.isValidHaneulObjectId)(registry)) {
|
|
112
|
+
registryId = registry;
|
|
113
|
+
} else {
|
|
114
|
+
registryName = registry;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const baseParams = {
|
|
118
|
+
receiverAddress: receiver,
|
|
119
|
+
amount: bigIntAmount,
|
|
120
|
+
coinType,
|
|
121
|
+
nonce,
|
|
122
|
+
label: params.get("label") ?? void 0,
|
|
123
|
+
message: params.get("message") ?? void 0,
|
|
124
|
+
iconUrl: params.get("icon") ?? void 0
|
|
125
|
+
};
|
|
126
|
+
if (registryId) {
|
|
127
|
+
return { ...baseParams, registryId };
|
|
128
|
+
}
|
|
129
|
+
return { ...baseParams, registryName };
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=uri.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/uri.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { isValidNamedType, isValidHaneulAddress, isValidHaneulObjectId } from '@haneullabs/haneul/utils';\nimport type { PaymentUriParams } from './types.js';\nimport { PaymentKitUriError } from './error.js';\nimport { SUI_PAYMENT_KIT_PROTOCOL } from './constants.js';\n\nconst isValidNonce = (nonce: string) => {\n\treturn nonce.length <= 36;\n};\n\nconst isValidAmount = (amount: bigint) => {\n\treturn amount > 0n;\n};\n\nconst isValidCoinType = (coinType: string) => {\n\treturn isValidNamedType(coinType);\n};\n\n/**\n * Create a payment transaction URI from the given parameters.\n * Returns the constructed URI string.\n *\n * @example\n * ```ts\n * const uri = createPaymentTransactionUri({\n * receiverAddress: \"0x...\",\n * amount: \"10000000\", (0.01 SUI)\n * coinType: \"0x2::haneul::HANEUL\",\n * nonce: <nonce>,\n * registryName: \"my-registry\"\n * });\n * ```\n */\nexport const createPaymentTransactionUri = (params: PaymentUriParams): string => {\n\tconst { receiverAddress, amount, coinType, nonce, registryId, registryName } = params;\n\n\tconst uri = new URL(SUI_PAYMENT_KIT_PROTOCOL);\n\n\tif (isValidHaneulAddress(receiverAddress)) {\n\t\turi.searchParams.append('receiver', receiverAddress);\n\t} else {\n\t\tthrow new PaymentKitUriError('Invalid Haneul address');\n\t}\n\n\tif (isValidAmount(amount)) {\n\t\turi.searchParams.append('amount', amount.toString());\n\t} else {\n\t\tthrow new PaymentKitUriError('Amount must be a positive numeric string');\n\t}\n\n\tif (isValidCoinType(coinType)) {\n\t\turi.searchParams.append('coinType', coinType);\n\t} else {\n\t\tthrow new PaymentKitUriError('Invalid Coin Type');\n\t}\n\n\tif (isValidNonce(nonce)) {\n\t\turi.searchParams.append('nonce', nonce);\n\t} else {\n\t\tthrow new PaymentKitUriError('Nonce length exceeds maximum of 36 characters');\n\t}\n\n\tif (registryId) {\n\t\tif (isValidHaneulObjectId(registryId)) {\n\t\t\turi.searchParams.append('registry', registryId);\n\t\t} else {\n\t\t\tthrow new PaymentKitUriError('Invalid Haneul Object Id for Registry Id');\n\t\t}\n\t}\n\n\tif (registryName) {\n\t\turi.searchParams.append('registry', registryName);\n\t}\n\n\tif (params.label) {\n\t\turi.searchParams.append('label', params.label);\n\t}\n\n\tif (params.message) {\n\t\turi.searchParams.append('message', params.message);\n\t}\n\n\tif (params.iconUrl) {\n\t\turi.searchParams.append('iconUrl', params.iconUrl);\n\t}\n\n\treturn uri.toString();\n};\n\n/**\n * Parse a payment transaction URI into its components.\n * Returns the parsed payment URI parameters.\n *\n * @example\n * ```ts\n * const params = parsePaymentTransactionUri(\"sui:0x...?amount=1000000&coinType=0x...&nonce=...\");\n * ```\n */\nexport const parsePaymentTransactionUri = (uri: string): PaymentUriParams => {\n\tif (!uri.startsWith(SUI_PAYMENT_KIT_PROTOCOL + '?')) {\n\t\tthrow new PaymentKitUriError('Invalid URI: Must start with sui:pay?');\n\t}\n\n\tconst url = new URL(uri);\n\n\t// Extract query parameters\n\tconst params = url.searchParams;\n\tconst receiver = params.get('receiver');\n\tconst amount = params.get('amount');\n\tconst coinType = params.get('coinType');\n\tconst nonce = params.get('nonce');\n\n\t// Amount and CoinType are required\n\tif (!receiver || !amount || !coinType || !nonce) {\n\t\tthrow new PaymentKitUriError('Invalid URI: Missing required parameters');\n\t}\n\n\t// Validate the receiver address\n\tif (!isValidHaneulAddress(receiver)) {\n\t\tthrow new PaymentKitUriError('Invalid URI: Receiver address is not valid');\n\t}\n\n\tif (!isValidCoinType(coinType)) {\n\t\tthrow new PaymentKitUriError('Invalid URI: Coin Type is not valid');\n\t}\n\n\tif (!isValidNonce(nonce)) {\n\t\tthrow new PaymentKitUriError('Invalid URI: Nonce length exceeds maximum of 36 characters');\n\t}\n\n\t// Validate amount is a valid numeric string (int or float) and positive\n\tconst bigIntAmount = BigInt(amount);\n\tif (!isValidAmount(bigIntAmount)) {\n\t\tthrow new PaymentKitUriError('Invalid URI: Amount must be a positive number');\n\t}\n\n\t// Extract optional registry parameter\n\tconst registry = params.get('registry') ?? undefined;\n\n\t// Determine if registry is an ID or name\n\tlet registryId: string | undefined;\n\tlet registryName: string | undefined;\n\n\tif (registry) {\n\t\tif (isValidHaneulObjectId(registry)) {\n\t\t\tregistryId = registry;\n\t\t} else {\n\t\t\tregistryName = registry;\n\t\t}\n\t}\n\n\tconst baseParams = {\n\t\treceiverAddress: receiver,\n\t\tamount: bigIntAmount,\n\t\tcoinType,\n\t\tnonce: nonce,\n\t\tlabel: params.get('label') ?? undefined,\n\t\tmessage: params.get('message') ?? undefined,\n\t\ticonUrl: params.get('icon') ?? undefined,\n\t};\n\n\tif (registryId) {\n\t\treturn { ...baseParams, registryId };\n\t}\n\n\treturn { ...baseParams, registryName };\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getRegistryIdFromName: (registryName: string | undefined, namespaceId: string) => string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
getRegistryIdFromName: () => getRegistryIdFromName
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(utils_exports);
|
|
24
|
+
var import_bcs = require("@haneullabs/haneul/bcs");
|
|
25
|
+
var import_utils = require("@haneullabs/haneul/utils");
|
|
26
|
+
var import_constants = require("./constants.js");
|
|
27
|
+
const getRegistryIdFromName = (registryName = import_constants.DEFAULT_REGISTRY_NAME, namespaceId) => {
|
|
28
|
+
return (0, import_utils.deriveObjectID)(
|
|
29
|
+
namespaceId,
|
|
30
|
+
"0x1::ascii::String",
|
|
31
|
+
import_bcs.bcs.String.serialize(registryName).toBytes()
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@haneullabs/haneul/bcs';\nimport { deriveObjectID } from '@haneullabs/haneul/utils';\nimport { DEFAULT_REGISTRY_NAME } from './constants.js';\n\nexport const getRegistryIdFromName = (\n\tregistryName: string = DEFAULT_REGISTRY_NAME,\n\tnamespaceId: string,\n) => {\n\treturn deriveObjectID(\n\t\tnamespaceId,\n\t\t'0x1::ascii::String',\n\t\tbcs.String.serialize(registryName).toBytes(),\n\t);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAoB;AACpB,mBAA+B;AAC/B,uBAAsC;AAE/B,MAAM,wBAAwB,CACpC,eAAuB,wCACvB,gBACI;AACJ,aAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,eAAI,OAAO,UAAU,YAAY,EAAE,QAAQ;AAAA,EAC5C;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { CreateRegistryOptions, DeletePaymentRecordOptions, PaymentKitPackageConfig, ProcessEphemeralPaymentOptions, ProcessRegistryPaymentOptions, SetEpochExpirationDurationOptions, SetRegistryManagedFundsOptions, WithdrawFromRegistryOptions } from './types.js';
|
|
2
|
+
export interface PaymentKitCallOptions {
|
|
3
|
+
packageConfig: PaymentKitPackageConfig;
|
|
4
|
+
}
|
|
5
|
+
export declare class PaymentKitCalls {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(options: PaymentKitCallOptions);
|
|
8
|
+
/**
|
|
9
|
+
* Creates a `processRegistryPayment` transaction
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* tx.add(lient.paymentKit.call.processRegistryPayment({ nonce, coinType, sender, amount, receiver, registryName }));
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
processRegistryPayment: (options: ProcessRegistryPaymentOptions) => (tx: import("@haneullabs/haneul/transactions").Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a `processRegistryPayment` transaction
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* tx.add(client.paymentKit.call.processEphemeralPayment({ nonce, coinType, sender, amount, receiver }));
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
processEphemeralPayment: (options: ProcessEphemeralPaymentOptions) => (tx: import("@haneullabs/haneul/transactions").Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a `createRegistry` transaction
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* tx.add(client.paymentKit.call.createRegistry(registryName));
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
createRegistry: ({ registryName }: CreateRegistryOptions) => (tx: import("@haneullabs/haneul/transactions").Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a `setConfigEpochExpirationDuration` transaction
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* tx.add(client.paymentKit.call.setConfigEpochExpirationDuration({registryName, epochExpirationDuration, adminCapId}));
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
setConfigEpochExpirationDuration: ({ registryName, registryId, epochExpirationDuration, adminCapId, }: SetEpochExpirationDurationOptions) => (tx: import("@haneullabs/haneul/transactions").Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a `setConfigRegistryManagedFunds` transaction
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* tx.add(client.paymentKit.call.setConfigRegistryManagedFunds({registryName, registryManagedFunds, adminCapId}));
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
setConfigRegistryManagedFunds: ({ registryName, registryId, registryManagedFunds, adminCapId, }: SetRegistryManagedFundsOptions) => (tx: import("@haneullabs/haneul/transactions").Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a `withdrawFromRegistry` transaction
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* tx.add(client.paymentKit.call.withdrawFromRegistry({coinType, registryName, adminCapId}));
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
withdrawFromRegistry: ({ coinType, registryName, registryId, adminCapId, }: WithdrawFromRegistryOptions) => (tx: import("@haneullabs/haneul/transactions").Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a `deletePaymentRecord` transaction
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* tx.add(client.paymentKit.call.deletePaymentRecord({coinType, nonce, amount, receiver, registryName}));
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
deletePaymentRecord: ({ coinType, nonce, amount, receiver, registryName, registryId, }: DeletePaymentRecordOptions) => (tx: import("@haneullabs/haneul/transactions").Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
71
|
+
}
|