@mysten/payment-kit 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -0
- package/dist/cjs/calls.d.ts +26 -0
- package/dist/cjs/calls.js +90 -0
- package/dist/cjs/calls.js.map +7 -0
- package/dist/cjs/client.d.ts +17 -2
- package/dist/cjs/client.js +61 -12
- package/dist/cjs/client.js.map +3 -3
- package/dist/cjs/constants.d.ts +4 -0
- package/dist/cjs/constants.js +9 -2
- package/dist/cjs/constants.js.map +2 -2
- package/dist/cjs/contracts/payment_kit/config.d.ts +1 -1
- package/dist/cjs/contracts/payment_kit/config.js +1 -1
- package/dist/cjs/contracts/payment_kit/config.js.map +1 -1
- package/dist/cjs/contracts/payment_kit/payment_kit.d.ts +10 -10
- package/dist/cjs/contracts/payment_kit/payment_kit.js +10 -10
- package/dist/cjs/contracts/payment_kit/payment_kit.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/transactions.d.ts +28 -0
- package/dist/cjs/transactions.js +66 -0
- package/dist/cjs/transactions.js.map +7 -0
- package/dist/cjs/types.d.ts +32 -6
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils.d.ts +1 -0
- package/dist/cjs/utils.js +33 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/esm/calls.d.ts +26 -0
- package/dist/esm/calls.js +73 -0
- package/dist/esm/calls.js.map +7 -0
- package/dist/esm/client.d.ts +17 -2
- package/dist/esm/client.js +61 -12
- package/dist/esm/client.js.map +2 -2
- package/dist/esm/constants.d.ts +4 -0
- package/dist/esm/constants.js +9 -2
- package/dist/esm/constants.js.map +2 -2
- package/dist/esm/contracts/payment_kit/config.d.ts +1 -1
- package/dist/esm/contracts/payment_kit/config.js +1 -1
- package/dist/esm/contracts/payment_kit/config.js.map +1 -1
- package/dist/esm/contracts/payment_kit/payment_kit.d.ts +10 -10
- package/dist/esm/contracts/payment_kit/payment_kit.js +10 -10
- package/dist/esm/contracts/payment_kit/payment_kit.js.map +1 -1
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/transactions.d.ts +28 -0
- package/dist/esm/transactions.js +46 -0
- package/dist/esm/transactions.js.map +7 -0
- package/dist/esm/types.d.ts +32 -6
- package/dist/esm/utils.d.ts +1 -0
- package/dist/esm/utils.js +13 -0
- package/dist/esm/utils.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# `@mysten/payment-kit`
|
|
2
|
+
|
|
3
|
+
> ⚠️ **Warning** - This package is in active development. APIs are experimental and subject to
|
|
4
|
+
> breaking changes without notice. We recommend thoroughly testing any implementation before using
|
|
5
|
+
> in production environments.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save @mysten/payment-kit @mysten/sui
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
|
|
15
|
+
In order to use the Payment Kit SDK you will first need to create an instance of SuiClient from the
|
|
16
|
+
Typescript SDK, and a client instance of the Payment Kit SDK.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
|
|
20
|
+
import { PaymentKitClient } from '@mysten/payment-kit';
|
|
21
|
+
|
|
22
|
+
const client = new SuiClient({
|
|
23
|
+
url: getFullnodeUrl('testnet'),
|
|
24
|
+
network: 'testnet',
|
|
25
|
+
}).$extend(PaymentKitClient.asClientExtension());
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The Payment Kit SDK already includes all relevant package and object IDs to operate against
|
|
29
|
+
`mainnet` and `testnet`. No other environments are currently supported. By default, all registry
|
|
30
|
+
based payments are routed through a default payment registry, but more on that later.
|
|
31
|
+
|
|
32
|
+
## SDK Overview
|
|
33
|
+
|
|
34
|
+
The Payment Kit SDK is designed to allow for direct interactions with the
|
|
35
|
+
[sui-payment-kit](https://github.com/MystenLabs/sui-payment-kit) Move Package. This includes:
|
|
36
|
+
|
|
37
|
+
- Processing payments
|
|
38
|
+
- Creating and managing `PaymentRegistry` instances
|
|
39
|
+
- Claiming `PaymentRecord` storage fees
|
|
40
|
+
- Querying the state of a `PaymentRecord`
|
|
41
|
+
- Constructing relevant Object IDs
|
|
42
|
+
|
|
43
|
+
These operations are exposed via a `PaymentKitClient` which provides relevant APIs so an application
|
|
44
|
+
doesn't need to know how payments are processed, receipts are created and registry configurations
|
|
45
|
+
are stored.
|
|
46
|
+
|
|
47
|
+
### Payment Processing
|
|
48
|
+
|
|
49
|
+
There are two distinct ways in which payments are processed. Registry based payments and Ephemeral
|
|
50
|
+
payments.
|
|
51
|
+
|
|
52
|
+
#### Registry Processed Payments
|
|
53
|
+
|
|
54
|
+
When using a `PaymentRegistry` to process a payment a registry must always be specified. A registry
|
|
55
|
+
has the ability to specify where funds must be sent and how long a `PaymentRecord` can live before
|
|
56
|
+
being eligible for deletion. In addition to registry configurations, a `PaymentRecord` is always
|
|
57
|
+
created when using a registry to process a payment. A `PaymentRecord` enforces that a payment
|
|
58
|
+
request cannot be fulfilled more than once. The existence of a `PaymentRecord` also guarantees that
|
|
59
|
+
a payment has been made. Once a payment has been fulfilled a `PaymentReceipt` is emitted that can be
|
|
60
|
+
used as you please.
|
|
61
|
+
|
|
62
|
+
#### Ephemeral Payments
|
|
63
|
+
|
|
64
|
+
Unlike Registry processed payments, an ephemeral payment does not leverage a registry and does not
|
|
65
|
+
write a `PaymentRecord`. This means duplicate payments are not implicitly prevented. Although, a
|
|
66
|
+
`PaymentReceipt` is still emitted once completed, similar to registry based payments.
|
|
67
|
+
|
|
68
|
+
### Payment Registries
|
|
69
|
+
|
|
70
|
+
At the core of Payment Kit is the `PaymentRegistry`. Currently, a registry is used to process
|
|
71
|
+
one-time payments, manage how funds are collected and specify the expiration of a `PaymentRecord`.
|
|
72
|
+
While there is a default registry to leverage, entities are encouraged to create and manage their
|
|
73
|
+
own registries. This enables easier indexing of relevant payments and reduces the potential for
|
|
74
|
+
object congestion. Registries are created via personalized name. This name is then used to derive an
|
|
75
|
+
Object ID. This means registry names must be unique.
|
|
76
|
+
|
|
77
|
+
#### Registry Configuration
|
|
78
|
+
|
|
79
|
+
Configurations are applied to an instance of a `PaymentRegistry`. There are currently two
|
|
80
|
+
configurations offered:
|
|
81
|
+
|
|
82
|
+
1. Receipt Epoch Expiration: The number of epochs that must elapse before a `PaymentReceipt` is
|
|
83
|
+
eligible to be deleted. Deleting expired receipts is a permissionless operation that anyone can
|
|
84
|
+
perform and will result in a small storage rebate for each deleted record, incentivizing
|
|
85
|
+
automatic cleanup up of registries.
|
|
86
|
+
|
|
87
|
+
2. Registry Managed Funds: A configuration that specifies if payment funds must be sent to the
|
|
88
|
+
registry itself. If a `PaymentRegistry` has set this configuration, the `receiver` must be the
|
|
89
|
+
registry itself. Funds can later be claimed by the registry admin. An added benefit to this
|
|
90
|
+
configuration is avoiding complicated coin merging, when dealing with high thoroughput payments.
|
|
91
|
+
This is because the destination is always the same coin object when the registry is set as the
|
|
92
|
+
fund manager.
|
|
93
|
+
|
|
94
|
+
### Payment Records
|
|
95
|
+
|
|
96
|
+
As mentioned above, a `PaymentRecord` is only written when using a registry to process a payment.
|
|
97
|
+
This payment record is used to guarantee a payment has been made. But note records can be deleted
|
|
98
|
+
based on a registries epoch expiration duration (the default expiration is 30 epochs after
|
|
99
|
+
creation).
|
|
100
|
+
|
|
101
|
+
#### Payment Keys
|
|
102
|
+
|
|
103
|
+
A `PaymentRecord` is a Dynamic Field owned by the `PaymentRegistry`. This record is derived via a
|
|
104
|
+
`PaymentKey`. A `PaymentKey` is a hash of request payment. This includes the `nonce`,
|
|
105
|
+
`PaymentAmount`, `CoinType`, and `ReceiverAddress`.
|
|
106
|
+
|
|
107
|
+
### Payment Receipts
|
|
108
|
+
|
|
109
|
+
When processing an ephemeral, or registry based, payment a `PaymentReceipt` is always emitted and
|
|
110
|
+
returned. This payment receipt can be stored, off-chain, for whateve purpose it may serve to your
|
|
111
|
+
application.
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
type PaymentReceipt = {
|
|
115
|
+
paymentType: PaymentType;
|
|
116
|
+
nonce: string;
|
|
117
|
+
amount: number;
|
|
118
|
+
receiver: string;
|
|
119
|
+
coinType: string;
|
|
120
|
+
timestampMs: number;
|
|
121
|
+
};
|
|
122
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PaymentKitPackageConfig, ProcessEphemeralPaymentParams, ProcessRegistryPaymentParams } 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
|
+
* @usage
|
|
12
|
+
* ```ts
|
|
13
|
+
* tx.add(lient.paymentKit.call.processRegistryPayment({ nonce, coinType, sender, amount, receiver, registryName }));
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
processRegistryPayment: (params: ProcessRegistryPaymentParams) => (tx: import("@mysten/sui/transactions").Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a `processRegistryPayment` transaction
|
|
19
|
+
*
|
|
20
|
+
* @usage
|
|
21
|
+
* ```ts
|
|
22
|
+
* tx.add(client.paymentKit.call.processEphemeralPayment({ nonce, coinType, sender, amount, receiver }));
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
processEphemeralPayment: (params: ProcessEphemeralPaymentParams) => (tx: import("@mysten/sui/transactions").Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
26
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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 calls_exports = {};
|
|
27
|
+
__export(calls_exports, {
|
|
28
|
+
PaymentKitCalls: () => PaymentKitCalls
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(calls_exports);
|
|
31
|
+
var import_transactions = require("@mysten/sui/transactions");
|
|
32
|
+
var import_payment_kit = require("./contracts/payment_kit/payment_kit.js");
|
|
33
|
+
var import_utils = require("./utils.js");
|
|
34
|
+
var _packageConfig;
|
|
35
|
+
class PaymentKitCalls {
|
|
36
|
+
constructor(options) {
|
|
37
|
+
__privateAdd(this, _packageConfig);
|
|
38
|
+
/**
|
|
39
|
+
* Creates a `processRegistryPayment` transaction
|
|
40
|
+
*
|
|
41
|
+
* @usage
|
|
42
|
+
* ```ts
|
|
43
|
+
* tx.add(lient.paymentKit.call.processRegistryPayment({ nonce, coinType, sender, amount, receiver, registryName }));
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
this.processRegistryPayment = (params) => {
|
|
47
|
+
const { nonce, coinType, amount, receiver, registryName, registryId } = params;
|
|
48
|
+
const registryIdToUse = registryId ?? (0, import_utils.getRegistryIdFromName)(registryName, __privateGet(this, _packageConfig).namespaceId);
|
|
49
|
+
return (0, import_payment_kit.processRegistryPayment)({
|
|
50
|
+
arguments: {
|
|
51
|
+
registry: registryIdToUse,
|
|
52
|
+
nonce,
|
|
53
|
+
paymentAmount: amount,
|
|
54
|
+
coin: (0, import_transactions.coinWithBalance)({
|
|
55
|
+
type: coinType,
|
|
56
|
+
balance: amount
|
|
57
|
+
}),
|
|
58
|
+
receiver
|
|
59
|
+
},
|
|
60
|
+
typeArguments: [coinType]
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Creates a `processRegistryPayment` transaction
|
|
65
|
+
*
|
|
66
|
+
* @usage
|
|
67
|
+
* ```ts
|
|
68
|
+
* tx.add(client.paymentKit.call.processEphemeralPayment({ nonce, coinType, sender, amount, receiver }));
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
this.processEphemeralPayment = (params) => {
|
|
72
|
+
const { nonce, coinType, amount, receiver } = params;
|
|
73
|
+
return (0, import_payment_kit.processEphemeralPayment)({
|
|
74
|
+
arguments: {
|
|
75
|
+
nonce,
|
|
76
|
+
paymentAmount: amount,
|
|
77
|
+
coin: (0, import_transactions.coinWithBalance)({
|
|
78
|
+
type: coinType,
|
|
79
|
+
balance: amount
|
|
80
|
+
}),
|
|
81
|
+
receiver
|
|
82
|
+
},
|
|
83
|
+
typeArguments: [coinType]
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
__privateSet(this, _packageConfig, options.packageConfig);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
_packageConfig = new WeakMap();
|
|
90
|
+
//# sourceMappingURL=calls.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/calls.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { coinWithBalance } from '@mysten/sui/transactions';\nimport type {\n\tPaymentKitPackageConfig,\n\tProcessEphemeralPaymentParams,\n\tProcessRegistryPaymentParams,\n} from './types.js';\nimport {\n\tprocessEphemeralPayment,\n\tprocessRegistryPayment,\n} from './contracts/payment_kit/payment_kit.js';\nimport { getRegistryIdFromName } from './utils.js';\n\nexport interface PaymentKitCallOptions {\n\tpackageConfig: PaymentKitPackageConfig;\n}\n\nexport class PaymentKitCalls {\n\t#packageConfig: PaymentKitPackageConfig;\n\n\tconstructor(options: PaymentKitCallOptions) {\n\t\tthis.#packageConfig = options.packageConfig;\n\t}\n\n\t/**\n\t * Creates a `processRegistryPayment` transaction\n\t *\n\t * @usage\n\t * ```ts\n\t * tx.add(lient.paymentKit.call.processRegistryPayment({ nonce, coinType, sender, amount, receiver, registryName }));\n\t * ```\n\t */\n\tprocessRegistryPayment = (params: ProcessRegistryPaymentParams) => {\n\t\tconst { nonce, coinType, amount, receiver, registryName, registryId } = params;\n\t\tconst registryIdToUse =\n\t\t\tregistryId ?? getRegistryIdFromName(registryName, this.#packageConfig.namespaceId);\n\n\t\treturn processRegistryPayment({\n\t\t\targuments: {\n\t\t\t\tregistry: registryIdToUse,\n\t\t\t\tnonce,\n\t\t\t\tpaymentAmount: amount,\n\t\t\t\tcoin: coinWithBalance({\n\t\t\t\t\ttype: coinType,\n\t\t\t\t\tbalance: amount,\n\t\t\t\t}),\n\t\t\t\treceiver,\n\t\t\t},\n\t\t\ttypeArguments: [coinType],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a `processRegistryPayment` transaction\n\t *\n\t * @usage\n\t * ```ts\n\t * tx.add(client.paymentKit.call.processEphemeralPayment({ nonce, coinType, sender, amount, receiver }));\n\t * ```\n\t */\n\tprocessEphemeralPayment = (params: ProcessEphemeralPaymentParams) => {\n\t\tconst { nonce, coinType, amount, receiver } = params;\n\n\t\treturn processEphemeralPayment({\n\t\t\targuments: {\n\t\t\t\tnonce: nonce,\n\t\t\t\tpaymentAmount: amount,\n\t\t\t\tcoin: coinWithBalance({\n\t\t\t\t\ttype: coinType,\n\t\t\t\t\tbalance: amount,\n\t\t\t\t}),\n\t\t\t\treceiver,\n\t\t\t},\n\t\t\ttypeArguments: [coinType],\n\t\t});\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAgC;AAMhC,yBAGO;AACP,mBAAsC;AAbtC;AAmBO,MAAM,gBAAgB;AAAA,EAG5B,YAAY,SAAgC;AAF5C;AAcA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAAyB,CAAC,WAAyC;AAClE,YAAM,EAAE,OAAO,UAAU,QAAQ,UAAU,cAAc,WAAW,IAAI;AACxE,YAAM,kBACL,kBAAc,oCAAsB,cAAc,mBAAK,gBAAe,WAAW;AAElF,iBAAO,2CAAuB;AAAA,QAC7B,WAAW;AAAA,UACV,UAAU;AAAA,UACV;AAAA,UACA,eAAe;AAAA,UACf,UAAM,qCAAgB;AAAA,YACrB,MAAM;AAAA,YACN,SAAS;AAAA,UACV,CAAC;AAAA,UACD;AAAA,QACD;AAAA,QACA,eAAe,CAAC,QAAQ;AAAA,MACzB,CAAC;AAAA,IACF;AAUA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mCAA0B,CAAC,WAA0C;AACpE,YAAM,EAAE,OAAO,UAAU,QAAQ,SAAS,IAAI;AAE9C,iBAAO,4CAAwB;AAAA,QAC9B,WAAW;AAAA,UACV;AAAA,UACA,eAAe;AAAA,UACf,UAAM,qCAAgB;AAAA,YACrB,MAAM;AAAA,YACN,SAAS;AAAA,UACV,CAAC;AAAA,UACD;AAAA,QACD;AAAA,QACA,eAAe,CAAC,QAAQ;AAAA,MACzB,CAAC;AAAA,IACF;AAtDC,uBAAK,gBAAiB,QAAQ;AAAA,EAC/B;AAsDD;AA1DC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/cjs/client.d.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PaymentKitCompatibleClient, GetPaymentRecordParams, GetPaymentRecordResponse } from './types.js';
|
|
2
|
+
import type { SuiClientRegistration } from '@mysten/sui/experimental';
|
|
3
|
+
import { PaymentKitTransactions } from './transactions.js';
|
|
4
|
+
import { PaymentKitCalls } from './calls.js';
|
|
2
5
|
export declare class PaymentKitClient {
|
|
3
6
|
#private;
|
|
7
|
+
calls: PaymentKitCalls;
|
|
8
|
+
tx: PaymentKitTransactions;
|
|
4
9
|
private constructor();
|
|
5
|
-
|
|
10
|
+
static asClientExtension(): SuiClientRegistration<PaymentKitCompatibleClient, 'paymentKit', PaymentKitClient>;
|
|
11
|
+
/**
|
|
12
|
+
* Query for a payment record in a registry.
|
|
13
|
+
* Returns the payment record data if it exists, null otherwise.
|
|
14
|
+
*
|
|
15
|
+
* @usage
|
|
16
|
+
* ```ts
|
|
17
|
+
* const paymentRecord = await client.getPaymentRecord({ registry, nonce, amount, receiver, coinType });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
getPaymentRecord(params: GetPaymentRecordParams): Promise<GetPaymentRecordResponse | null>;
|
|
6
21
|
}
|
package/dist/cjs/client.js
CHANGED
|
@@ -30,18 +30,22 @@ __export(client_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(client_exports);
|
|
31
31
|
var import_error = require("./error.js");
|
|
32
32
|
var import_constants = require("./constants.js");
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
var import_payment_kit = require("./contracts/payment_kit/payment_kit.js");
|
|
34
|
+
var import_utils = require("@mysten/sui/utils");
|
|
35
|
+
var import_transactions = require("./transactions.js");
|
|
36
|
+
var import_calls = require("./calls.js");
|
|
37
|
+
var import_utils2 = require("./utils.js");
|
|
38
|
+
var _packageConfig, _client;
|
|
39
|
+
const _PaymentKitClient = class _PaymentKitClient {
|
|
40
|
+
constructor(options) {
|
|
36
41
|
__privateAdd(this, _packageConfig);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
__privateSet(this, _suiClient, config.suiClient);
|
|
42
|
+
__privateAdd(this, _client);
|
|
43
|
+
if (options.client) {
|
|
44
|
+
__privateSet(this, _client, options.client);
|
|
41
45
|
} else {
|
|
42
46
|
throw new import_error.PaymentKitClientError("suiClient must be provided");
|
|
43
47
|
}
|
|
44
|
-
const network =
|
|
48
|
+
const network = options.client.network;
|
|
45
49
|
switch (network) {
|
|
46
50
|
case "testnet":
|
|
47
51
|
__privateSet(this, _packageConfig, import_constants.TESTNET_PAYMENT_KIT_PACKAGE_CONFIG);
|
|
@@ -52,11 +56,56 @@ class PaymentKitClient {
|
|
|
52
56
|
default:
|
|
53
57
|
throw new import_error.PaymentKitClientError(`Unsupported network: ${network}`);
|
|
54
58
|
}
|
|
59
|
+
this.calls = new import_calls.PaymentKitCalls({ packageConfig: __privateGet(this, _packageConfig) });
|
|
60
|
+
this.tx = new import_transactions.PaymentKitTransactions({
|
|
61
|
+
calls: this.calls
|
|
62
|
+
});
|
|
55
63
|
}
|
|
56
|
-
|
|
57
|
-
return
|
|
64
|
+
static asClientExtension() {
|
|
65
|
+
return {
|
|
66
|
+
name: "paymentKit",
|
|
67
|
+
register: (client) => {
|
|
68
|
+
return new _PaymentKitClient({ client });
|
|
69
|
+
}
|
|
70
|
+
};
|
|
58
71
|
}
|
|
59
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Query for a payment record in a registry.
|
|
74
|
+
* Returns the payment record data if it exists, null otherwise.
|
|
75
|
+
*
|
|
76
|
+
* @usage
|
|
77
|
+
* ```ts
|
|
78
|
+
* const paymentRecord = await client.getPaymentRecord({ registry, nonce, amount, receiver, coinType });
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
async getPaymentRecord(params) {
|
|
82
|
+
const { coinType, registryId, registryName, nonce, amount, receiver } = params;
|
|
83
|
+
const normalizedCoinType = (0, import_utils.normalizeStructTag)(coinType);
|
|
84
|
+
const paymentKeyType = `${import_payment_kit.PaymentKey.name}<${normalizedCoinType}>`;
|
|
85
|
+
const registryIdToUse = registryId ?? (0, import_utils2.getRegistryIdFromName)(registryName, __privateGet(this, _packageConfig).namespaceId);
|
|
86
|
+
const result = await __privateGet(this, _client).core.getDynamicField({
|
|
87
|
+
parentId: registryIdToUse,
|
|
88
|
+
name: {
|
|
89
|
+
type: paymentKeyType,
|
|
90
|
+
bcs: import_payment_kit.PaymentKey.serialize({
|
|
91
|
+
nonce,
|
|
92
|
+
payment_amount: amount,
|
|
93
|
+
receiver
|
|
94
|
+
}).toBytes()
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
if (!result?.dynamicField) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const decoded = import_payment_kit.PaymentRecord.parse(result.dynamicField.value.bcs);
|
|
101
|
+
return {
|
|
102
|
+
key: result.dynamicField.id,
|
|
103
|
+
paymentTransactionDigest: result.dynamicField.previousTransaction,
|
|
104
|
+
epochAtTimeOfRecord: decoded.epoch_at_time_of_record
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
};
|
|
60
108
|
_packageConfig = new WeakMap();
|
|
61
|
-
|
|
109
|
+
_client = new WeakMap();
|
|
110
|
+
let PaymentKitClient = _PaymentKitClient;
|
|
62
111
|
//# sourceMappingURL=client.js.map
|
package/dist/cjs/client.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/client.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { PaymentKitClientError } from './error.js';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAsC;
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { PaymentKitClientError } from './error.js';\nimport {\n\tMAINNET_PAYMENT_KIT_PACKAGE_CONFIG,\n\tTESTNET_PAYMENT_KIT_PACKAGE_CONFIG,\n} from './constants.js';\nimport { PaymentKey, PaymentRecord } from './contracts/payment_kit/payment_kit.js';\nimport type {\n\tPaymentKitCompatibleClient,\n\tPaymentKitPackageConfig,\n\tPaymentKitClientOptions,\n\tGetPaymentRecordParams,\n\tGetPaymentRecordResponse,\n} from './types.js';\nimport type { SuiClientRegistration } from '@mysten/sui/experimental';\nimport { normalizeStructTag } from '@mysten/sui/utils';\nimport { PaymentKitTransactions } from './transactions.js';\nimport { PaymentKitCalls } from './calls.js';\nimport { getRegistryIdFromName } from './utils.js';\n\nexport class PaymentKitClient {\n\t#packageConfig: PaymentKitPackageConfig;\n\t#client: PaymentKitCompatibleClient;\n\n\tcalls: PaymentKitCalls;\n\ttx: PaymentKitTransactions;\n\n\tprivate constructor(options: PaymentKitClientOptions) {\n\t\tif (options.client) {\n\t\t\tthis.#client = options.client;\n\t\t} else {\n\t\t\tthrow new PaymentKitClientError('suiClient must be provided');\n\t\t}\n\n\t\tconst network = options.client.network;\n\t\tswitch (network) {\n\t\t\tcase 'testnet':\n\t\t\t\tthis.#packageConfig = TESTNET_PAYMENT_KIT_PACKAGE_CONFIG;\n\t\t\t\tbreak;\n\t\t\tcase 'mainnet':\n\t\t\t\tthis.#packageConfig = MAINNET_PAYMENT_KIT_PACKAGE_CONFIG;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new PaymentKitClientError(`Unsupported network: ${network}`);\n\t\t}\n\n\t\tthis.calls = new PaymentKitCalls({ packageConfig: this.#packageConfig });\n\t\tthis.tx = new PaymentKitTransactions({\n\t\t\tcalls: this.calls,\n\t\t});\n\t}\n\n\tstatic asClientExtension(): SuiClientRegistration<\n\t\tPaymentKitCompatibleClient,\n\t\t'paymentKit',\n\t\tPaymentKitClient\n\t> {\n\t\treturn {\n\t\t\tname: 'paymentKit' as const,\n\t\t\tregister: (client) => {\n\t\t\t\treturn new PaymentKitClient({ client });\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Query for a payment record in a registry.\n\t * Returns the payment record data if it exists, null otherwise.\n\t *\n\t * @usage\n\t * ```ts\n\t * const paymentRecord = await client.getPaymentRecord({ registry, nonce, amount, receiver, coinType });\n\t * ```\n\t */\n\tasync getPaymentRecord(params: GetPaymentRecordParams): Promise<GetPaymentRecordResponse | null> {\n\t\tconst { coinType, registryId, registryName, nonce, amount, receiver } = params;\n\t\tconst normalizedCoinType = normalizeStructTag(coinType);\n\t\tconst paymentKeyType = `${PaymentKey.name}<${normalizedCoinType}>`;\n\n\t\tconst registryIdToUse =\n\t\t\tregistryId ?? getRegistryIdFromName(registryName, this.#packageConfig.namespaceId);\n\t\tconst result = await this.#client.core.getDynamicField({\n\t\t\tparentId: registryIdToUse,\n\t\t\tname: {\n\t\t\t\ttype: paymentKeyType,\n\t\t\t\tbcs: PaymentKey.serialize({\n\t\t\t\t\tnonce,\n\t\t\t\t\tpayment_amount: amount,\n\t\t\t\t\treceiver,\n\t\t\t\t}).toBytes(),\n\t\t\t},\n\t\t});\n\n\t\tif (!result?.dynamicField) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst decoded = PaymentRecord.parse(result.dynamicField.value.bcs);\n\n\t\treturn {\n\t\t\tkey: result.dynamicField.id,\n\t\t\tpaymentTransactionDigest: result.dynamicField.previousTransaction,\n\t\t\tepochAtTimeOfRecord: decoded.epoch_at_time_of_record,\n\t\t};\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAsC;AACtC,uBAGO;AACP,yBAA0C;AAS1C,mBAAmC;AACnC,0BAAuC;AACvC,mBAAgC;AAChC,IAAAA,gBAAsC;AApBtC;AAsBO,MAAM,oBAAN,MAAM,kBAAiB;AAAA,EAOrB,YAAY,SAAkC;AANtD;AACA;AAMC,QAAI,QAAQ,QAAQ;AACnB,yBAAK,SAAU,QAAQ;AAAA,IACxB,OAAO;AACN,YAAM,IAAI,mCAAsB,4BAA4B;AAAA,IAC7D;AAEA,UAAM,UAAU,QAAQ,OAAO;AAC/B,YAAQ,SAAS;AAAA,MAChB,KAAK;AACJ,2BAAK,gBAAiB;AACtB;AAAA,MACD,KAAK;AACJ,2BAAK,gBAAiB;AACtB;AAAA,MACD;AACC,cAAM,IAAI,mCAAsB,wBAAwB,OAAO,EAAE;AAAA,IACnE;AAEA,SAAK,QAAQ,IAAI,6BAAgB,EAAE,eAAe,mBAAK,gBAAe,CAAC;AACvE,SAAK,KAAK,IAAI,2CAAuB;AAAA,MACpC,OAAO,KAAK;AAAA,IACb,CAAC;AAAA,EACF;AAAA,EAEA,OAAO,oBAIL;AACD,WAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU,CAAC,WAAW;AACrB,eAAO,IAAI,kBAAiB,EAAE,OAAO,CAAC;AAAA,MACvC;AAAA,IACD;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,iBAAiB,QAA0E;AAChG,UAAM,EAAE,UAAU,YAAY,cAAc,OAAO,QAAQ,SAAS,IAAI;AACxE,UAAM,yBAAqB,iCAAmB,QAAQ;AACtD,UAAM,iBAAiB,GAAG,8BAAW,IAAI,IAAI,kBAAkB;AAE/D,UAAM,kBACL,kBAAc,qCAAsB,cAAc,mBAAK,gBAAe,WAAW;AAClF,UAAM,SAAS,MAAM,mBAAK,SAAQ,KAAK,gBAAgB;AAAA,MACtD,UAAU;AAAA,MACV,MAAM;AAAA,QACL,MAAM;AAAA,QACN,KAAK,8BAAW,UAAU;AAAA,UACzB;AAAA,UACA,gBAAgB;AAAA,UAChB;AAAA,QACD,CAAC,EAAE,QAAQ;AAAA,MACZ;AAAA,IACD,CAAC;AAED,QAAI,CAAC,QAAQ,cAAc;AAC1B,aAAO;AAAA,IACR;AAEA,UAAM,UAAU,iCAAc,MAAM,OAAO,aAAa,MAAM,GAAG;AAEjE,WAAO;AAAA,MACN,KAAK,OAAO,aAAa;AAAA,MACzB,0BAA0B,OAAO,aAAa;AAAA,MAC9C,qBAAqB,QAAQ;AAAA,IAC9B;AAAA,EACD;AACD;AApFC;AACA;AAFM,IAAM,mBAAN;",
|
|
6
|
+
"names": ["import_utils"]
|
|
7
7
|
}
|
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export declare const TESTNET_PAYMENT_KIT_PACKAGE_CONFIG: {
|
|
2
2
|
packageId: string;
|
|
3
|
+
namespaceId: string;
|
|
3
4
|
};
|
|
4
5
|
export declare const MAINNET_PAYMENT_KIT_PACKAGE_CONFIG: {
|
|
5
6
|
packageId: string;
|
|
7
|
+
namespaceId: string;
|
|
6
8
|
};
|
|
9
|
+
export declare const SUI_COIN_TYPE: string;
|
|
10
|
+
export declare const DEFAULT_REGISTRY_NAME = "default-payment-registry";
|
package/dist/cjs/constants.js
CHANGED
|
@@ -18,14 +18,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var constants_exports = {};
|
|
20
20
|
__export(constants_exports, {
|
|
21
|
+
DEFAULT_REGISTRY_NAME: () => DEFAULT_REGISTRY_NAME,
|
|
21
22
|
MAINNET_PAYMENT_KIT_PACKAGE_CONFIG: () => MAINNET_PAYMENT_KIT_PACKAGE_CONFIG,
|
|
23
|
+
SUI_COIN_TYPE: () => SUI_COIN_TYPE,
|
|
22
24
|
TESTNET_PAYMENT_KIT_PACKAGE_CONFIG: () => TESTNET_PAYMENT_KIT_PACKAGE_CONFIG
|
|
23
25
|
});
|
|
24
26
|
module.exports = __toCommonJS(constants_exports);
|
|
27
|
+
var import_utils = require("@mysten/sui/utils");
|
|
25
28
|
const TESTNET_PAYMENT_KIT_PACKAGE_CONFIG = {
|
|
26
|
-
packageId: "
|
|
29
|
+
packageId: "0x7e069abe383e80d32f2aec17b3793da82aabc8c2edf84abbf68dd7b719e71497",
|
|
30
|
+
namespaceId: "0xa5016862fdccba7cc576b56cc5a391eda6775200aaa03a6b3c97d512312878db"
|
|
27
31
|
};
|
|
28
32
|
const MAINNET_PAYMENT_KIT_PACKAGE_CONFIG = {
|
|
29
|
-
packageId: "
|
|
33
|
+
packageId: "0xbc126f1535fba7d641cb9150ad9eae93b104972586ba20f3c60bfe0e53b69bc6",
|
|
34
|
+
namespaceId: "0xccd3e4c7802921991cd9ce488c4ca0b51334ba75483702744242284ccf3ae7c2"
|
|
30
35
|
};
|
|
36
|
+
const SUI_COIN_TYPE = (0, import_utils.normalizeStructTag)(import_utils.SUI_TYPE_ARG);
|
|
37
|
+
const DEFAULT_REGISTRY_NAME = "default-payment-registry";
|
|
31
38
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/constants.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { PaymentKitPackageConfig } from './types.js';\n\nexport const TESTNET_PAYMENT_KIT_PACKAGE_CONFIG = {\n\tpackageId: '
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PaymentKitPackageConfig } from './types.js';\nimport { SUI_TYPE_ARG, normalizeStructTag } from '@mysten/sui/utils';\n\nexport const TESTNET_PAYMENT_KIT_PACKAGE_CONFIG = {\n\tpackageId: '0x7e069abe383e80d32f2aec17b3793da82aabc8c2edf84abbf68dd7b719e71497',\n\tnamespaceId: '0xa5016862fdccba7cc576b56cc5a391eda6775200aaa03a6b3c97d512312878db',\n} satisfies PaymentKitPackageConfig;\n\nexport const MAINNET_PAYMENT_KIT_PACKAGE_CONFIG = {\n\tpackageId: '0xbc126f1535fba7d641cb9150ad9eae93b104972586ba20f3c60bfe0e53b69bc6',\n\tnamespaceId: '0xccd3e4c7802921991cd9ce488c4ca0b51334ba75483702744242284ccf3ae7c2',\n} satisfies PaymentKitPackageConfig;\n\nexport const SUI_COIN_TYPE = normalizeStructTag(SUI_TYPE_ARG);\nexport const DEFAULT_REGISTRY_NAME = 'default-payment-registry';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAAiD;AAE1C,MAAM,qCAAqC;AAAA,EACjD,WAAW;AAAA,EACX,aAAa;AACd;AAEO,MAAM,qCAAqC;AAAA,EACjD,WAAW;AAAA,EACX,aAAa;AACd;AAEO,MAAM,oBAAgB,iCAAmB,yBAAY;AACrD,MAAM,wBAAwB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -11,4 +11,4 @@ export declare const Value: MoveEnum<{
|
|
|
11
11
|
Type: import("../utils/index.js").MoveStruct<{
|
|
12
12
|
name: import("@mysten/sui/bcs").BcsType<string, string, "string">;
|
|
13
13
|
}, "std::type_name::TypeName">;
|
|
14
|
-
}, "@
|
|
14
|
+
}, "@mysten/payment-kit::config::Value">;
|
|
@@ -34,7 +34,7 @@ module.exports = __toCommonJS(config_exports);
|
|
|
34
34
|
var import_utils = require("../utils/index.js");
|
|
35
35
|
var import_bcs = require("@mysten/sui/bcs");
|
|
36
36
|
var type_name = __toESM(require("./deps/std/type_name.js"));
|
|
37
|
-
const $moduleName = "@
|
|
37
|
+
const $moduleName = "@mysten/payment-kit::config";
|
|
38
38
|
const Value = new import_utils.MoveEnum({
|
|
39
39
|
name: `${$moduleName}::Value`,
|
|
40
40
|
fields: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/contracts/payment_kit/config.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { MoveEnum } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport * as type_name from './deps/std/type_name.js';\nconst $moduleName = '@
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { MoveEnum } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport * as type_name from './deps/std/type_name.js';\nconst $moduleName = '@mysten/payment-kit::config';\nexport const Value = new MoveEnum({\n\tname: `${$moduleName}::Value`,\n\tfields: {\n\t\tU64: bcs.u64(),\n\t\tAddress: bcs.Address,\n\t\tString: bcs.string(),\n\t\tAsciiString: bcs.string(),\n\t\tBool: bcs.bool(),\n\t\tBytes: bcs.vector(bcs.u8()),\n\t\tType: type_name.TypeName,\n\t},\n});\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAyB;AACzB,iBAAoB;AACpB,gBAA2B;AAC3B,MAAM,cAAc;AACb,MAAM,QAAQ,IAAI,sBAAS;AAAA,EACjC,MAAM,GAAG,WAAW;AAAA,EACpB,QAAQ;AAAA,IACP,KAAK,eAAI,IAAI;AAAA,IACb,SAAS,eAAI;AAAA,IACb,QAAQ,eAAI,OAAO;AAAA,IACnB,aAAa,eAAI,OAAO;AAAA,IACxB,MAAM,eAAI,KAAK;AAAA,IACf,OAAO,eAAI,OAAO,eAAI,GAAG,CAAC;AAAA,IAC1B,MAAM,UAAU;AAAA,EACjB;AACD,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,7 +5,7 @@ export declare const Namespace: MoveStruct<{
|
|
|
5
5
|
id: MoveStruct<{
|
|
6
6
|
id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
7
7
|
}, "0x2::object::UID">;
|
|
8
|
-
}, "@
|
|
8
|
+
}, "@mysten/payment-kit::payment_kit::Namespace">;
|
|
9
9
|
export declare const PaymentRegistry: MoveStruct<{
|
|
10
10
|
id: MoveStruct<{
|
|
11
11
|
id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
@@ -43,15 +43,15 @@ export declare const PaymentRegistry: MoveStruct<{
|
|
|
43
43
|
}> & {
|
|
44
44
|
length: number;
|
|
45
45
|
}, string>;
|
|
46
|
-
}, "0x2::vec_map::VecMap<string, @
|
|
46
|
+
}, "0x2::vec_map::VecMap<string, @mysten/payment-kit::config::Value>">;
|
|
47
47
|
version: import("@mysten/sui/bcs").BcsType<number, number, "u16">;
|
|
48
|
-
}, "@
|
|
48
|
+
}, "@mysten/payment-kit::payment_kit::PaymentRegistry">;
|
|
49
49
|
export declare const RegistryAdminCap: MoveStruct<{
|
|
50
50
|
id: MoveStruct<{
|
|
51
51
|
id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
52
52
|
}, "0x2::object::UID">;
|
|
53
53
|
registry_id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
54
|
-
}, "@
|
|
54
|
+
}, "@mysten/payment-kit::payment_kit::RegistryAdminCap">;
|
|
55
55
|
/**
|
|
56
56
|
* Enum representing the type of payment: Ephemeral (one-time) or Registry (tracked
|
|
57
57
|
* in a registry).
|
|
@@ -59,27 +59,27 @@ export declare const RegistryAdminCap: MoveStruct<{
|
|
|
59
59
|
export declare const PaymentType: MoveEnum<{
|
|
60
60
|
Ephemeral: null;
|
|
61
61
|
Registry: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
62
|
-
}, "@
|
|
62
|
+
}, "@mysten/payment-kit::payment_kit::PaymentType">;
|
|
63
63
|
export declare const PaymentReceipt: MoveStruct<{
|
|
64
64
|
payment_type: MoveEnum<{
|
|
65
65
|
Ephemeral: null;
|
|
66
66
|
Registry: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
67
|
-
}, "@
|
|
67
|
+
}, "@mysten/payment-kit::payment_kit::PaymentType">;
|
|
68
68
|
nonce: import("@mysten/sui/bcs").BcsType<string, string, "string">;
|
|
69
69
|
payment_amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
70
70
|
receiver: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
71
71
|
coin_type: import("@mysten/sui/bcs").BcsType<string, string, "string">;
|
|
72
72
|
timestamp_ms: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
73
|
-
}, "@
|
|
73
|
+
}, "@mysten/payment-kit::payment_kit::PaymentReceipt">;
|
|
74
74
|
export declare const PaymentKey: MoveStruct<{
|
|
75
75
|
nonce: import("@mysten/sui/bcs").BcsType<string, string, "string">;
|
|
76
76
|
payment_amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
77
77
|
receiver: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
78
|
-
}, "@
|
|
78
|
+
}, "@mysten/payment-kit::payment_kit::PaymentKey">;
|
|
79
79
|
export declare const PaymentRecord: MoveStruct<{
|
|
80
80
|
epoch_at_time_of_record: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
81
|
-
}, "@
|
|
82
|
-
export declare const BalanceKey: MoveTuple<import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">[], "@
|
|
81
|
+
}, "@mysten/payment-kit::payment_kit::PaymentRecord">;
|
|
82
|
+
export declare const BalanceKey: MoveTuple<import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">[], "@mysten/payment-kit::payment_kit::BalanceKey">;
|
|
83
83
|
export interface CreateRegistryArguments {
|
|
84
84
|
namespace: RawTransactionArgument<string>;
|
|
85
85
|
name: RawTransactionArgument<string>;
|
|
@@ -52,7 +52,7 @@ var import_bcs = require("@mysten/sui/bcs");
|
|
|
52
52
|
var object = __toESM(require("./deps/sui/object.js"));
|
|
53
53
|
var vec_map = __toESM(require("./deps/sui/vec_map.js"));
|
|
54
54
|
var config = __toESM(require("./config.js"));
|
|
55
|
-
const $moduleName = "@
|
|
55
|
+
const $moduleName = "@mysten/payment-kit::payment_kit";
|
|
56
56
|
const Namespace = new import_utils.MoveStruct({
|
|
57
57
|
name: `${$moduleName}::Namespace`,
|
|
58
58
|
fields: {
|
|
@@ -112,7 +112,7 @@ const BalanceKey = new import_utils.MoveTuple({
|
|
|
112
112
|
fields: [import_bcs.bcs.bool()]
|
|
113
113
|
});
|
|
114
114
|
function createRegistry(options) {
|
|
115
|
-
const packageAddress = options.package ?? "@
|
|
115
|
+
const packageAddress = options.package ?? "@mysten/payment-kit";
|
|
116
116
|
const argumentsTypes = [
|
|
117
117
|
`${packageAddress}::payment_kit::Namespace`,
|
|
118
118
|
"0x0000000000000000000000000000000000000000000000000000000000000001::ascii::String"
|
|
@@ -126,7 +126,7 @@ function createRegistry(options) {
|
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
function processEphemeralPayment(options) {
|
|
129
|
-
const packageAddress = options.package ?? "@
|
|
129
|
+
const packageAddress = options.package ?? "@mysten/payment-kit";
|
|
130
130
|
const argumentsTypes = [
|
|
131
131
|
"0x0000000000000000000000000000000000000000000000000000000000000001::ascii::String",
|
|
132
132
|
"u64",
|
|
@@ -144,7 +144,7 @@ function processEphemeralPayment(options) {
|
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
function processRegistryPayment(options) {
|
|
147
|
-
const packageAddress = options.package ?? "@
|
|
147
|
+
const packageAddress = options.package ?? "@mysten/payment-kit";
|
|
148
148
|
const argumentsTypes = [
|
|
149
149
|
`${packageAddress}::payment_kit::PaymentRegistry`,
|
|
150
150
|
"0x0000000000000000000000000000000000000000000000000000000000000001::ascii::String",
|
|
@@ -163,7 +163,7 @@ function processRegistryPayment(options) {
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
function withdrawFromRegistry(options) {
|
|
166
|
-
const packageAddress = options.package ?? "@
|
|
166
|
+
const packageAddress = options.package ?? "@mysten/payment-kit";
|
|
167
167
|
const argumentsTypes = [
|
|
168
168
|
`${packageAddress}::payment_kit::PaymentRegistry`,
|
|
169
169
|
`${packageAddress}::payment_kit::RegistryAdminCap`
|
|
@@ -178,7 +178,7 @@ function withdrawFromRegistry(options) {
|
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
function deletePaymentRecord(options) {
|
|
181
|
-
const packageAddress = options.package ?? "@
|
|
181
|
+
const packageAddress = options.package ?? "@mysten/payment-kit";
|
|
182
182
|
const argumentsTypes = [
|
|
183
183
|
`${packageAddress}::payment_kit::PaymentRegistry`,
|
|
184
184
|
`${packageAddress}::payment_kit::PaymentKey<${options.typeArguments[0]}>`
|
|
@@ -193,7 +193,7 @@ function deletePaymentRecord(options) {
|
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
195
|
function createPaymentKey(options) {
|
|
196
|
-
const packageAddress = options.package ?? "@
|
|
196
|
+
const packageAddress = options.package ?? "@mysten/payment-kit";
|
|
197
197
|
const argumentsTypes = [
|
|
198
198
|
"0x0000000000000000000000000000000000000000000000000000000000000001::ascii::String",
|
|
199
199
|
"u64",
|
|
@@ -209,7 +209,7 @@ function createPaymentKey(options) {
|
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
function setConfigEpochExpirationDuration(options) {
|
|
212
|
-
const packageAddress = options.package ?? "@
|
|
212
|
+
const packageAddress = options.package ?? "@mysten/payment-kit";
|
|
213
213
|
const argumentsTypes = [
|
|
214
214
|
`${packageAddress}::payment_kit::PaymentRegistry`,
|
|
215
215
|
`${packageAddress}::payment_kit::RegistryAdminCap`,
|
|
@@ -224,7 +224,7 @@ function setConfigEpochExpirationDuration(options) {
|
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
226
|
function setConfigRegistryManagedFunds(options) {
|
|
227
|
-
const packageAddress = options.package ?? "@
|
|
227
|
+
const packageAddress = options.package ?? "@mysten/payment-kit";
|
|
228
228
|
const argumentsTypes = [
|
|
229
229
|
`${packageAddress}::payment_kit::PaymentRegistry`,
|
|
230
230
|
`${packageAddress}::payment_kit::RegistryAdminCap`,
|
|
@@ -239,7 +239,7 @@ function setConfigRegistryManagedFunds(options) {
|
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
241
|
function share(options) {
|
|
242
|
-
const packageAddress = options.package ?? "@
|
|
242
|
+
const packageAddress = options.package ?? "@mysten/payment-kit";
|
|
243
243
|
const argumentsTypes = [`${packageAddress}::payment_kit::PaymentRegistry`];
|
|
244
244
|
const parameterNames = ["registry"];
|
|
245
245
|
return (tx) => tx.moveCall({
|