wowok 1.2.3 → 1.2.5
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/dist/exception.d.ts +2 -1
- package/dist/exception.d.ts.map +1 -1
- package/dist/exception.js +1 -0
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +26 -25
- package/dist/machine.js +7 -6
- package/dist/passport.d.ts.map +1 -1
- package/dist/passport.js +30 -28
- package/dist/permission.d.ts +3 -3
- package/dist/permission.d.ts.map +1 -1
- package/dist/permission.js +5 -4
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +3 -12
- package/dist/protocol.d.ts +6 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +13 -6
- package/dist/repository.d.ts.map +1 -1
- package/dist/repository.js +5 -15
- package/dist/service.d.ts +10 -7
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +48 -42
- package/dist/utils.d.ts +12 -24
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +164 -67
- package/dist/vote.js +8 -7
- package/package.json +1 -1
- package/src/exception.ts +1 -0
- package/src/guard.ts +26 -25
- package/src/machine.ts +7 -7
- package/src/passport.ts +30 -27
- package/src/permission.ts +5 -6
- package/src/progress.ts +4 -12
- package/src/protocol.ts +13 -6
- package/src/repository.ts +5 -14
- package/src/service.ts +51 -41
- package/src/utils.ts +166 -69
- package/src/vote.ts +8 -8
package/dist/protocol.js
CHANGED
|
@@ -57,8 +57,12 @@ export var ValueType;
|
|
|
57
57
|
ValueType[ValueType["TYPE_OPTION_U64"] = 114] = "TYPE_OPTION_U64";
|
|
58
58
|
ValueType[ValueType["TYPE_OPTION_U128"] = 115] = "TYPE_OPTION_U128";
|
|
59
59
|
ValueType[ValueType["TYPE_OPTION_U256"] = 116] = "TYPE_OPTION_U256";
|
|
60
|
-
ValueType[ValueType["
|
|
61
|
-
ValueType[ValueType["
|
|
60
|
+
ValueType[ValueType["TYPE_OPTION_STRING"] = 117] = "TYPE_OPTION_STRING";
|
|
61
|
+
ValueType[ValueType["TYPE_OPTION_VEC_U8"] = 118] = "TYPE_OPTION_VEC_U8";
|
|
62
|
+
ValueType[ValueType["TYPE_VEC_U256"] = 119] = "TYPE_VEC_U256";
|
|
63
|
+
ValueType[ValueType["TYPE_STRING"] = 120] = "TYPE_STRING";
|
|
64
|
+
ValueType[ValueType["TYPE_VEC_STRING"] = 121] = "TYPE_VEC_STRING";
|
|
65
|
+
ValueType[ValueType["TYPE_U256"] = 122] = "TYPE_U256";
|
|
62
66
|
})(ValueType || (ValueType = {}));
|
|
63
67
|
export const OperatorTypeArray = Object.values(OperatorType).filter((v) => typeof (v) === 'number');
|
|
64
68
|
export const ValueTypeArray = Object.values(ValueType).filter((v) => typeof (v) === 'number');
|
|
@@ -69,7 +73,7 @@ export const SER_VALUE = [
|
|
|
69
73
|
{ type: ValueType.TYPE_ADDRESS, name: 'address', description: 'address or object-id. eg:0x6789af' },
|
|
70
74
|
{ type: ValueType.TYPE_U64, name: 'number', description: 'unsigned-64 number. eg:23870233' },
|
|
71
75
|
{ type: ValueType.TYPE_U8, name: 'number', description: 'unsigned-8 number. eg:255' },
|
|
72
|
-
{ type: ValueType.TYPE_VEC_U8, name: '[number]', description: 'unsigned-8 number array. eg:"
|
|
76
|
+
{ type: ValueType.TYPE_VEC_U8, name: '[number]', description: 'unsigned-8 number array. eg:"[1,2,3]"' },
|
|
73
77
|
{ type: ValueType.TYPE_U128, name: 'number', description: 'unsigned-8 number. eg:12348900999' },
|
|
74
78
|
{ type: ValueType.TYPE_VEC_ADDRESS, name: '[address]', description: 'address array. eg:[0x2277f2, 0x3344af]' },
|
|
75
79
|
{ type: ValueType.TYPE_VEC_BOOL, name: '[bool]', description: 'boolean array. eg:[true, false, true]' },
|
|
@@ -83,6 +87,9 @@ export const SER_VALUE = [
|
|
|
83
87
|
{ type: ValueType.TYPE_OPTION_U128, name: 'option', description: 'option of u128. eg:none or u128 value' },
|
|
84
88
|
{ type: ValueType.TYPE_OPTION_U256, name: 'option', description: 'option of u256. eg:none or u256 value' },
|
|
85
89
|
{ type: ValueType.TYPE_VEC_U256, name: '[number]', description: 'unsigned-256 number array. eg:[123, 778888, 42312]' },
|
|
90
|
+
{ type: ValueType.TYPE_VEC_STRING, name: '[string]', description: 'ascii string array. eg:["abc", "hi"]' },
|
|
91
|
+
{ type: ValueType.TYPE_STRING, name: 'string', description: 'ascii string. eg:"wowok"' },
|
|
92
|
+
{ type: ValueType.TYPE_OPTION_STRING, name: 'option', description: 'option of string. eg:none or string value' },
|
|
86
93
|
{ type: ValueType.TYPE_U256, name: 'number', description: 'unsigned-256 number. eg:12345678901233' },
|
|
87
94
|
];
|
|
88
95
|
export var ContextType;
|
|
@@ -127,9 +134,9 @@ export class Protocol {
|
|
|
127
134
|
case ENTRYPOINT.devnet:
|
|
128
135
|
break;
|
|
129
136
|
case ENTRYPOINT.testnet:
|
|
130
|
-
this.package = "
|
|
131
|
-
this.wowok_object = '
|
|
132
|
-
this.entity_object = '
|
|
137
|
+
this.package = "0x10edb3f8e11008c8c5cfe951989d10c353d885377fe6cbdfedea3b315fa6b06c";
|
|
138
|
+
this.wowok_object = '0xb2a940236a1811ff43eaf902e165155687f9c756dcdd1fc70096551bffcb89fc';
|
|
139
|
+
this.entity_object = '0x8dc27895c123c9736649a800fc58e621b7747d56f0b15a560d09a4412c42ae28';
|
|
133
140
|
this.graphql = 'https://sui-testnet.mystenlabs.com/graphql';
|
|
134
141
|
break;
|
|
135
142
|
case ENTRYPOINT.mainnet:
|
package/dist/repository.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAc,SAAS,EAAoB,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAC,MAAM,YAAY,CAAC;AAC9I,OAAO,EAAE,mBAAmB,EAAc,MAAM,cAAc,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AC,EAAC,cAAc;IA2ClF,YAAY,CAAC,QAAQ,EAAC,iBAAiB,EAAE,EAAE,QAAQ,CAAC,EAAC,cAAc;IAwCnE,eAAe,CAAC,WAAW,EAAC,MAAM,EAAE,EAAE,SAAS,CAAC,EAAC,OAAO,EAAE,QAAQ,CAAC,EAAC,cAAc;IAyClF,eAAe,CAAC,WAAW,EAAC,MAAM,EAAE,QAAQ,CAAC,EAAC,cAAc;IAoB5D,eAAe,CAAC,WAAW,EAAC,sBAAsB,EAAE,QAAQ,CAAC,EAAC,cAAc;IAe5E,sBAAsB,CAAC,MAAM,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,EAAE,QAAQ,CAAC,EAAC,cAAc;IAyBlF,qBAAqB,CAAC,MAAM,EAAC,MAAM,EAAE,gBAAgB,CAAC,EAAC,MAAM,EAAE,QAAQ,CAAC,EAAC,cAAc;IA6BvF,iBAAiB,CAAC,cAAc,EAAC,gBAAgB;IAajD,MAAM,CAAC,gBAAgB,SAAQ;IAC/B,MAAM,CAAC,cAAc,SAAO;IAC5B,MAAM,CAAC,gBAAgB,SAAU;IACjC,MAAM,CAAC,WAAW,QAAQ,MAAM,aAE/B;IACD,MAAM,CAAC,YAAY,UAAU,UAAU,aAEtC;CACJ"}
|
package/dist/repository.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BCS } from '@mysten/bcs';
|
|
2
|
-
import { Protocol } from './protocol';
|
|
2
|
+
import { Protocol, ValueType } from './protocol';
|
|
3
3
|
import { Permission } from './permission';
|
|
4
4
|
import { Bcs, array_unique, IsValidDesription, IsValidAddress, IsValidArray, OptionNone, } from './utils';
|
|
5
5
|
import { ERROR, Errors } from './exception';
|
|
@@ -62,16 +62,6 @@ export class Repository {
|
|
|
62
62
|
arguments: [Protocol.TXB_OBJECT(txb, this.object)],
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
/* move to: Entity.mark
|
|
66
|
-
mark(like:'like' | 'unlike', resource:Resource) {
|
|
67
|
-
if (!Protocol.IsValidObjects([this.object])) return false;
|
|
68
|
-
let txb = this.protocol.CurrentSession();
|
|
69
|
-
txb.moveCall({
|
|
70
|
-
target:this.protocol.RepositoryFn(like) as FnCallType,
|
|
71
|
-
arguments: [Protocol.TXB_OBJECT(txb, resource.get_object()), Protocol.TXB_OBJECT(txb, this.object)],
|
|
72
|
-
})
|
|
73
|
-
}
|
|
74
|
-
*/
|
|
75
65
|
add_data(data) {
|
|
76
66
|
if (!Repository.IsValidName(data.key)) {
|
|
77
67
|
ERROR(Errors.IsValidName);
|
|
@@ -212,7 +202,7 @@ export class Repository {
|
|
|
212
202
|
}
|
|
213
203
|
let txb = this.protocol.CurrentSession();
|
|
214
204
|
policies.forEach((policy) => {
|
|
215
|
-
let permission_index = policy?.permission ? txb.pure(Bcs.getInstance().
|
|
205
|
+
let permission_index = policy?.permission ? txb.pure(Bcs.getInstance().ser(ValueType.TYPE_OPTION_U64, policy.permission)) : OptionNone(txb);
|
|
216
206
|
if (passport) {
|
|
217
207
|
txb.moveCall({
|
|
218
208
|
target: this.protocol.RepositoryFn('policy_add_with_passport'),
|
|
@@ -254,7 +244,7 @@ export class Repository {
|
|
|
254
244
|
txb.moveCall({
|
|
255
245
|
target: this.protocol.RepositoryFn('policy_remove_with_passport'),
|
|
256
246
|
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object),
|
|
257
|
-
txb.pure(Bcs.getInstance().
|
|
247
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, array_unique(policy_keys))),
|
|
258
248
|
Protocol.TXB_OBJECT(txb, this.permission)]
|
|
259
249
|
});
|
|
260
250
|
}
|
|
@@ -270,7 +260,7 @@ export class Repository {
|
|
|
270
260
|
txb.moveCall({
|
|
271
261
|
target: this.protocol.RepositoryFn('policy_remove'),
|
|
272
262
|
arguments: [Protocol.TXB_OBJECT(txb, this.object),
|
|
273
|
-
txb.pure(Bcs.getInstance().
|
|
263
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, array_unique(policy_keys))),
|
|
274
264
|
Protocol.TXB_OBJECT(txb, this.permission)]
|
|
275
265
|
});
|
|
276
266
|
}
|
|
@@ -343,7 +333,7 @@ export class Repository {
|
|
|
343
333
|
if (!Permission.IsValidPermissionIndex(permission_index)) {
|
|
344
334
|
ERROR(Errors.IsValidPermissionIndex);
|
|
345
335
|
}
|
|
346
|
-
index = txb.pure(Bcs.getInstance().
|
|
336
|
+
index = txb.pure(Bcs.getInstance().ser(ValueType.TYPE_OPTION_U64, permission_index));
|
|
347
337
|
}
|
|
348
338
|
if (passport) {
|
|
349
339
|
txb.moveCall({
|
package/dist/service.d.ts
CHANGED
|
@@ -30,10 +30,10 @@ export type Customer_RequiredInfo = {
|
|
|
30
30
|
customer_info_crypt: string[];
|
|
31
31
|
};
|
|
32
32
|
export declare enum BuyRequiredEnum {
|
|
33
|
-
address = "
|
|
34
|
-
phone = "
|
|
35
|
-
name = "
|
|
36
|
-
postcode = "
|
|
33
|
+
address = "address",
|
|
34
|
+
phone = "phone",
|
|
35
|
+
name = "name",
|
|
36
|
+
postcode = "postcode"
|
|
37
37
|
}
|
|
38
38
|
export type Service_Buy = {
|
|
39
39
|
item: string;
|
|
@@ -50,11 +50,12 @@ export declare class Service {
|
|
|
50
50
|
protected permission: PermissionObject;
|
|
51
51
|
protected object: TxbObject;
|
|
52
52
|
protected protocol: Protocol;
|
|
53
|
+
static token2coin: (token: string) => string;
|
|
53
54
|
get_pay_type(): string;
|
|
54
55
|
get_object(): TxbObject;
|
|
55
56
|
private constructor();
|
|
56
|
-
static From(protocol: Protocol,
|
|
57
|
-
static New(protocol: Protocol,
|
|
57
|
+
static From(protocol: Protocol, token_type: string, permission: PermissionObject, object: TxbObject): Service;
|
|
58
|
+
static New(protocol: Protocol, token_type: string, permission: PermissionObject, description: string, payee_address: string, endpoint?: string, passport?: PassportObject): Service;
|
|
58
59
|
launch(): ServiceAddress;
|
|
59
60
|
destroy(): void;
|
|
60
61
|
set_description(description: string, passport?: PassportObject): void;
|
|
@@ -63,7 +64,7 @@ export declare class Service {
|
|
|
63
64
|
add_stock(item: string, stock_add: number, bNotFoundAssert?: boolean, passport?: PassportObject): void;
|
|
64
65
|
reduce_stock(item: string, stock_reduce: number, bNotFoundAssert?: boolean, passport?: PassportObject): void;
|
|
65
66
|
set_payee(payee: string, passport?: PassportObject): void;
|
|
66
|
-
repository_add(repository: RepositoryObject, passport?: PassportObject):
|
|
67
|
+
repository_add(repository: RepositoryObject, passport?: PassportObject): void;
|
|
67
68
|
repository_remove(repository_address?: string[], removeall?: boolean, passport?: PassportObject): void;
|
|
68
69
|
add_withdraw_guards(guards: Service_Guard_Percent[], passport?: PassportObject): void;
|
|
69
70
|
remove_withdraw_guards(guard_address?: string[], removeall?: boolean, passport?: PassportObject): void;
|
|
@@ -91,5 +92,7 @@ export declare class Service {
|
|
|
91
92
|
change_permission(new_permission: PermissionObject): void;
|
|
92
93
|
static MAX_DISCOUNT_COUNT_ONCE: number;
|
|
93
94
|
static MAX_DISCOUNT_RECEIVER_COUNT: number;
|
|
95
|
+
static MAX_GUARD_COUNT: number;
|
|
96
|
+
static MAX_REPOSITORY_COUNT: number;
|
|
94
97
|
}
|
|
95
98
|
//# sourceMappingURL=service.d.ts.map
|
package/dist/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAC/G,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAC9E,SAAS,EAAC,MAAM,YAAY,CAAC;AAIjC,MAAM,MAAM,qBAAqB,GAAG;IAChC,KAAK,EAAC,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAA;AACD,MAAM,MAAM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AAE,QAAQ,CAAC,EAAC,cAAc;IAsB9D,4BAA4B,CAAC,KAAK,EAAC,WAAW,EAAE,MAAM,EAAC,MAAM,EAAE,QAAQ,CAAC,EAAC,cAAc;IAyBvF,KAAK,CAAC,KAAK,EAAC,OAAO,EAAE,QAAQ,CAAC,EAAC,cAAc;IAiB7C,eAAe,CAAC,KAAK,EAAC,WAAW,EAAE,QAAQ,CAAC,EAAC,cAAc;IAqB3D,0BAA0B,CAAC,KAAK,EAAC,WAAW,EAAE,oBAAoB,EAAE,qBAAqB;IAoBzF,GAAG,CAAC,SAAS,EAAC,WAAW,EAAE,EAAE,IAAI,EAAC,UAAU,EAAE,QAAQ,CAAC,EAAC,cAAc,EAAE,OAAO,CAAC,EAAC,aAAa,EAC1F,oBAAoB,CAAC,EAAE,qBAAqB,EAAE,QAAQ,CAAC,EAAC,cAAc,GAAI,YAAY;IA8E1F,kBAAkB,CAAC,KAAK,EAAC,WAAW,EAAE,OAAO,EAAC,aAAa;IAa3D,iBAAiB,CAAC,cAAc,EAAC,gBAAgB;IAcjD,MAAM,CAAC,uBAAuB,SAAO;IACrC,MAAM,CAAC,2BAA2B,SAAM;IACxC,MAAM,CAAC,eAAe,SAAM;IAC5B,MAAM,CAAC,oBAAoB,SAAM;CACpC"}
|
package/dist/service.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BCS } from '@mysten/bcs';
|
|
2
2
|
import { IsValidArray, IsValidPercent, IsValidName_AllowEmpty, Bcs, array_unique, IsValidArgType, IsValidDesription, IsValidAddress, IsValidEndpoint, OptionNone, IsValidUint, IsValidInt, IsValidName, } from './utils';
|
|
3
|
-
import { Protocol } from './protocol';
|
|
3
|
+
import { Protocol, ValueType } from './protocol';
|
|
4
4
|
import { ERROR, Errors } from './exception';
|
|
5
5
|
export var Service_Discount_Type;
|
|
6
6
|
(function (Service_Discount_Type) {
|
|
@@ -9,16 +9,17 @@ export var Service_Discount_Type;
|
|
|
9
9
|
})(Service_Discount_Type || (Service_Discount_Type = {}));
|
|
10
10
|
export var BuyRequiredEnum;
|
|
11
11
|
(function (BuyRequiredEnum) {
|
|
12
|
-
BuyRequiredEnum["address"] = "
|
|
13
|
-
BuyRequiredEnum["phone"] = "
|
|
14
|
-
BuyRequiredEnum["name"] = "
|
|
15
|
-
BuyRequiredEnum["postcode"] = "
|
|
12
|
+
BuyRequiredEnum["address"] = "address";
|
|
13
|
+
BuyRequiredEnum["phone"] = "phone";
|
|
14
|
+
BuyRequiredEnum["name"] = "name";
|
|
15
|
+
BuyRequiredEnum["postcode"] = "postcode";
|
|
16
16
|
})(BuyRequiredEnum || (BuyRequiredEnum = {}));
|
|
17
17
|
export class Service {
|
|
18
18
|
pay_token_type;
|
|
19
19
|
permission;
|
|
20
20
|
object;
|
|
21
21
|
protocol;
|
|
22
|
+
static token2coin = (token) => { return '0x2::coin::Coin<' + token + '>'; };
|
|
22
23
|
get_pay_type() { return this.pay_token_type; }
|
|
23
24
|
get_object() { return this.object; }
|
|
24
25
|
constructor(protocol, pay_token_type, permission) {
|
|
@@ -27,17 +28,17 @@ export class Service {
|
|
|
27
28
|
this.permission = permission;
|
|
28
29
|
this.object = '';
|
|
29
30
|
}
|
|
30
|
-
static From(protocol,
|
|
31
|
-
let s = new Service(protocol,
|
|
31
|
+
static From(protocol, token_type, permission, object) {
|
|
32
|
+
let s = new Service(protocol, this.token2coin(token_type), permission);
|
|
32
33
|
s.object = Protocol.TXB_OBJECT(protocol.CurrentSession(), object);
|
|
33
34
|
return s;
|
|
34
35
|
}
|
|
35
|
-
static New(protocol,
|
|
36
|
+
static New(protocol, token_type, permission, description, payee_address, endpoint, passport) {
|
|
36
37
|
if (!Protocol.IsValidObjects([permission])) {
|
|
37
38
|
ERROR(Errors.IsValidObjects);
|
|
38
39
|
}
|
|
39
|
-
if (!IsValidArgType(
|
|
40
|
-
ERROR(Errors.IsValidArgType, '
|
|
40
|
+
if (!IsValidArgType(token_type)) {
|
|
41
|
+
ERROR(Errors.IsValidArgType, 'New: pay_token_type');
|
|
41
42
|
}
|
|
42
43
|
if (!IsValidDesription(description)) {
|
|
43
44
|
ERROR(Errors.IsValidDesription);
|
|
@@ -48,9 +49,10 @@ export class Service {
|
|
|
48
49
|
if (endpoint && !IsValidEndpoint(endpoint)) {
|
|
49
50
|
ERROR(Errors.IsValidEndpoint);
|
|
50
51
|
}
|
|
52
|
+
let pay_token_type = this.token2coin(token_type);
|
|
51
53
|
let s = new Service(protocol, pay_token_type, permission);
|
|
52
54
|
let txb = protocol.CurrentSession();
|
|
53
|
-
let ep = endpoint ? txb.pure(Bcs.getInstance().
|
|
55
|
+
let ep = endpoint ? txb.pure(Bcs.getInstance().ser(ValueType.TYPE_OPTION_STRING, endpoint)) : OptionNone(txb);
|
|
54
56
|
if (passport) {
|
|
55
57
|
s.object = txb.moveCall({
|
|
56
58
|
target: protocol.ServiceFn('new_with_passport'),
|
|
@@ -61,7 +63,7 @@ export class Service {
|
|
|
61
63
|
else {
|
|
62
64
|
s.object = txb.moveCall({
|
|
63
65
|
target: protocol.ServiceFn('new'),
|
|
64
|
-
arguments: [txb.pure(description), txb.pure(payee_address, BCS.ADDRESS), ep, Protocol.TXB_OBJECT(txb, permission)],
|
|
66
|
+
arguments: [txb.pure(description, BCS.STRING), txb.pure(payee_address, BCS.ADDRESS), ep, Protocol.TXB_OBJECT(txb, permission)],
|
|
65
67
|
typeArguments: [pay_token_type],
|
|
66
68
|
});
|
|
67
69
|
}
|
|
@@ -224,10 +226,9 @@ export class Service {
|
|
|
224
226
|
}
|
|
225
227
|
}
|
|
226
228
|
repository_add(repository, passport) {
|
|
227
|
-
if (!Protocol.IsValidObjects([
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return false;
|
|
229
|
+
if (!Protocol.IsValidObjects([repository])) {
|
|
230
|
+
ERROR(Errors.IsValidObjects, 'repository_add');
|
|
231
|
+
}
|
|
231
232
|
let txb = this.protocol.CurrentSession();
|
|
232
233
|
if (passport) {
|
|
233
234
|
txb.moveCall({
|
|
@@ -467,8 +468,8 @@ export class Service {
|
|
|
467
468
|
if (passport) {
|
|
468
469
|
txb.moveCall({
|
|
469
470
|
target: this.protocol.ServiceFn('sales_add_with_passport'),
|
|
470
|
-
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().
|
|
471
|
-
txb.pure(Bcs.getInstance().
|
|
471
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, names)),
|
|
472
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, price)), txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, stock)),
|
|
472
473
|
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
473
474
|
typeArguments: [this.pay_token_type]
|
|
474
475
|
});
|
|
@@ -476,8 +477,8 @@ export class Service {
|
|
|
476
477
|
else {
|
|
477
478
|
txb.moveCall({
|
|
478
479
|
target: this.protocol.ServiceFn('sales_add'),
|
|
479
|
-
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().
|
|
480
|
-
txb.pure(Bcs.getInstance().
|
|
480
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, names)),
|
|
481
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, price)), txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, stock)),
|
|
481
482
|
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
482
483
|
typeArguments: [this.pay_token_type]
|
|
483
484
|
});
|
|
@@ -502,7 +503,7 @@ export class Service {
|
|
|
502
503
|
else {
|
|
503
504
|
txb.moveCall({
|
|
504
505
|
target: this.protocol.ServiceFn('sales_remove_with_passport'),
|
|
505
|
-
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().
|
|
506
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, array_unique(sales))),
|
|
506
507
|
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
507
508
|
typeArguments: [this.pay_token_type]
|
|
508
509
|
});
|
|
@@ -519,7 +520,7 @@ export class Service {
|
|
|
519
520
|
else {
|
|
520
521
|
txb.moveCall({
|
|
521
522
|
target: this.protocol.ServiceFn('sales_remove'),
|
|
522
|
-
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().
|
|
523
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, array_unique(sales))),
|
|
523
524
|
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
524
525
|
typeArguments: [this.pay_token_type]
|
|
525
526
|
});
|
|
@@ -553,9 +554,9 @@ export class Service {
|
|
|
553
554
|
let txb = this.protocol.CurrentSession();
|
|
554
555
|
discount_dispatch.forEach((discount) => {
|
|
555
556
|
let price_greater = discount.discount?.price_greater ?
|
|
556
|
-
txb.pure(Bcs.getInstance().
|
|
557
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_OPTION_U64, discount.discount.price_greater)) : OptionNone(txb);
|
|
557
558
|
let time_start = discount.discount?.time_start ?
|
|
558
|
-
txb.pure(Bcs.getInstance().
|
|
559
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_OPTION_U64, discount.discount.time_start)) : OptionNone(txb);
|
|
559
560
|
if (passport) {
|
|
560
561
|
txb.moveCall({
|
|
561
562
|
target: this.protocol.ServiceFn('dicscount_create_with_passport'),
|
|
@@ -676,7 +677,7 @@ export class Service {
|
|
|
676
677
|
ERROR(Errors.IsValidEndpoint);
|
|
677
678
|
}
|
|
678
679
|
let txb = this.protocol.CurrentSession();
|
|
679
|
-
let ep = endpoint ? txb.pure(Bcs.getInstance().
|
|
680
|
+
let ep = endpoint ? txb.pure(Bcs.getInstance().ser(ValueType.TYPE_OPTION_STRING, endpoint)) : OptionNone(txb);
|
|
680
681
|
if (passport) {
|
|
681
682
|
txb.moveCall({
|
|
682
683
|
target: this.protocol.ServiceFn('endpoint_set_with_passport'),
|
|
@@ -733,13 +734,16 @@ export class Service {
|
|
|
733
734
|
if (!customer_required) {
|
|
734
735
|
ERROR(Errors.InvalidParam, 'customer_required');
|
|
735
736
|
}
|
|
737
|
+
let req = array_unique(customer_required);
|
|
738
|
+
console.log(req);
|
|
739
|
+
console.log(this.pay_token_type);
|
|
736
740
|
let txb = this.protocol.CurrentSession();
|
|
737
741
|
if (passport) {
|
|
738
742
|
txb.moveCall({
|
|
739
743
|
target: this.protocol.ServiceFn('required_set_with_passport'),
|
|
740
744
|
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object),
|
|
741
|
-
txb.pure(Bcs.getInstance().
|
|
742
|
-
txb.pure(pubkey,
|
|
745
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, req)),
|
|
746
|
+
txb.pure(pubkey, BCS.STRING), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
743
747
|
typeArguments: [this.pay_token_type]
|
|
744
748
|
});
|
|
745
749
|
}
|
|
@@ -747,8 +751,8 @@ export class Service {
|
|
|
747
751
|
txb.moveCall({
|
|
748
752
|
target: this.protocol.ServiceFn('required_set'),
|
|
749
753
|
arguments: [Protocol.TXB_OBJECT(txb, this.object),
|
|
750
|
-
txb.pure(Bcs.getInstance().
|
|
751
|
-
txb.pure(pubkey,
|
|
754
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, req)),
|
|
755
|
+
txb.pure(pubkey, BCS.STRING), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
752
756
|
typeArguments: [this.pay_token_type]
|
|
753
757
|
});
|
|
754
758
|
}
|
|
@@ -867,7 +871,7 @@ export class Service {
|
|
|
867
871
|
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, order),
|
|
868
872
|
txb.pure(customer_info_crypto.pubkey, 'vector<u8>'),
|
|
869
873
|
txb.pure(customer_info_crypto.customer_pubkey, 'vector<u8>'),
|
|
870
|
-
txb.pure(Bcs.getInstance().
|
|
874
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_VEC_U8, array_unique(customer_info_crypto.customer_info_crypt)))],
|
|
871
875
|
typeArguments: [this.pay_token_type]
|
|
872
876
|
});
|
|
873
877
|
}
|
|
@@ -901,8 +905,8 @@ export class Service {
|
|
|
901
905
|
if (discount) {
|
|
902
906
|
order = txb.moveCall({
|
|
903
907
|
target: this.protocol.ServiceFn('dicount_buy_with_passport'),
|
|
904
|
-
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().
|
|
905
|
-
txb.pure(Bcs.getInstance().
|
|
908
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, name)),
|
|
909
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, price)), txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, stock)),
|
|
906
910
|
Protocol.TXB_OBJECT(txb, coin), Protocol.TXB_OBJECT(txb, discount), txb.object(Protocol.CLOCK_OBJECT)],
|
|
907
911
|
typeArguments: [this.pay_token_type]
|
|
908
912
|
});
|
|
@@ -910,9 +914,9 @@ export class Service {
|
|
|
910
914
|
else {
|
|
911
915
|
order = txb.moveCall({
|
|
912
916
|
target: this.protocol.ServiceFn('buy_with_passport'),
|
|
913
|
-
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().
|
|
914
|
-
txb.pure(Bcs.getInstance().
|
|
915
|
-
txb.pure(Bcs.getInstance().
|
|
917
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, name)),
|
|
918
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, price)),
|
|
919
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, stock)),
|
|
916
920
|
Protocol.TXB_OBJECT(txb, coin)],
|
|
917
921
|
typeArguments: [this.pay_token_type]
|
|
918
922
|
});
|
|
@@ -922,9 +926,9 @@ export class Service {
|
|
|
922
926
|
if (discount) {
|
|
923
927
|
order = txb.moveCall({
|
|
924
928
|
target: this.protocol.ServiceFn('disoucnt_buy'),
|
|
925
|
-
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().
|
|
926
|
-
txb.pure(Bcs.getInstance().
|
|
927
|
-
txb.pure(Bcs.getInstance().
|
|
929
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, name)),
|
|
930
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, price)),
|
|
931
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, stock)),
|
|
928
932
|
Protocol.TXB_OBJECT(txb, coin),
|
|
929
933
|
Protocol.TXB_OBJECT(txb, discount), txb.object(Protocol.CLOCK_OBJECT)],
|
|
930
934
|
typeArguments: [this.pay_token_type]
|
|
@@ -933,9 +937,9 @@ export class Service {
|
|
|
933
937
|
else {
|
|
934
938
|
order = txb.moveCall({
|
|
935
939
|
target: this.protocol.ServiceFn('buy'),
|
|
936
|
-
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().
|
|
937
|
-
txb.pure(Bcs.getInstance().
|
|
938
|
-
txb.pure(Bcs.getInstance().
|
|
940
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, name)),
|
|
941
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, price)),
|
|
942
|
+
txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, stock)),
|
|
939
943
|
Protocol.TXB_OBJECT(txb, coin)],
|
|
940
944
|
typeArguments: [this.pay_token_type]
|
|
941
945
|
});
|
|
@@ -983,5 +987,7 @@ export class Service {
|
|
|
983
987
|
this.permission = new_permission;
|
|
984
988
|
}
|
|
985
989
|
static MAX_DISCOUNT_COUNT_ONCE = 200;
|
|
986
|
-
static MAX_DISCOUNT_RECEIVER_COUNT =
|
|
990
|
+
static MAX_DISCOUNT_RECEIVER_COUNT = 20;
|
|
991
|
+
static MAX_GUARD_COUNT = 16;
|
|
992
|
+
static MAX_REPOSITORY_COUNT = 16;
|
|
987
993
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { BCS
|
|
1
|
+
import { BCS } from '@mysten/bcs';
|
|
2
2
|
import { TransactionBlock, TransactionArgument } from '@mysten/sui.js/transactions';
|
|
3
|
+
import { ValueType } from './protocol';
|
|
3
4
|
export declare const OPTION_NONE = 0;
|
|
4
|
-
export declare const readOption: (arr: number[], de:
|
|
5
|
+
export declare const readOption: (arr: number[], de: ValueType) => {
|
|
6
|
+
bNone: boolean;
|
|
7
|
+
value: any;
|
|
8
|
+
};
|
|
9
|
+
export declare const readOptionString: (arr: number[]) => {
|
|
5
10
|
bNone: boolean;
|
|
6
11
|
value: any;
|
|
7
12
|
};
|
|
@@ -24,25 +29,8 @@ export declare class Bcs {
|
|
|
24
29
|
private static _instance;
|
|
25
30
|
private constructor();
|
|
26
31
|
static getInstance(): Bcs;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
ser_option_address(data: string): Uint8Array;
|
|
30
|
-
ser_vector_string(data: string[]): Uint8Array;
|
|
31
|
-
ser_vector_vector_u8(data: string[]): Uint8Array;
|
|
32
|
-
ser_vector_u64(data: number[]): Uint8Array;
|
|
33
|
-
ser_vector_u8(data: number[]): Uint8Array;
|
|
34
|
-
ser_vector_address(data: number[]): Uint8Array;
|
|
35
|
-
ser_vector_bool(data: number[]): Uint8Array;
|
|
36
|
-
ser_vector_u128(data: number[]): Uint8Array;
|
|
37
|
-
ser_address(data: string): Uint8Array;
|
|
38
|
-
ser_bool(data: boolean): Uint8Array;
|
|
39
|
-
ser_u8(data: number): Uint8Array;
|
|
40
|
-
ser_u64(data: number): Uint8Array;
|
|
41
|
-
ser_u128(data: number): Uint8Array;
|
|
42
|
-
ser_u256(data: number): Uint8Array;
|
|
43
|
-
ser_string(data: string): Uint8Array;
|
|
44
|
-
ser(type: TypeName | StructTypeDefinition, data: Uint8Array): Uint8Array;
|
|
45
|
-
de(type: TypeName | StructTypeDefinition, data: Uint8Array): any;
|
|
32
|
+
ser(type: ValueType, data: Uint8Array | any): Uint8Array;
|
|
33
|
+
de(type: ValueType, data: Uint8Array | any): any;
|
|
46
34
|
}
|
|
47
35
|
export declare function stringToUint8Array(str: string): Uint8Array;
|
|
48
36
|
export declare function numToUint8Array(num: number): Uint8Array;
|
|
@@ -57,9 +45,9 @@ export declare const IsValidName_AllowEmpty: (name: string) => boolean;
|
|
|
57
45
|
export declare const IsValidEndpoint: (endpoint: string) => boolean;
|
|
58
46
|
export declare const IsValidAddress: (addr: string) => boolean;
|
|
59
47
|
export declare const IsValidArgType: (argType: string) => boolean;
|
|
60
|
-
export declare const IsValidUint: (value: number) => boolean;
|
|
61
|
-
export declare const IsValidInt: (value: number) => boolean;
|
|
62
|
-
export declare const IsValidPercent: (value: number) => boolean;
|
|
48
|
+
export declare const IsValidUint: (value: number | string) => boolean;
|
|
49
|
+
export declare const IsValidInt: (value: number | string) => boolean;
|
|
50
|
+
export declare const IsValidPercent: (value: number | string) => boolean;
|
|
63
51
|
export declare const IsValidArray: (arr: any[], validFunc: any) => boolean;
|
|
64
52
|
export declare const OptionNone: (txb: TransactionBlock) => TransactionArgument;
|
|
65
53
|
export type ArgType = {
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/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