@zing-protocol/zing-sdk 0.0.1
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 +12 -0
- package/package.json +37 -0
- package/src/_generated/index.js +6 -0
- package/src/_generated/utils/index.ts +181 -0
- package/src/_generated/zing_framework/coin_utils.ts +41 -0
- package/src/_generated/zing_framework/deps/sui/object.ts +16 -0
- package/src/_generated/zing_framework/derived_object_bag.ts +400 -0
- package/src/_generated/zing_framework/derived_table.ts +366 -0
- package/src/_generated/zing_governance/admin.ts +47 -0
- package/src/_generated/zing_governance/deps/sui/object.ts +16 -0
- package/src/_generated/zing_governance/treasury.ts +134 -0
- package/src/_generated/zing_identity/config.ts +191 -0
- package/src/_generated/zing_identity/deps/std/type_name.ts +25 -0
- package/src/_generated/zing_identity/deps/sui/object.ts +16 -0
- package/src/_generated/zing_identity/deps/sui/object_table.ts +26 -0
- package/src/_generated/zing_identity/deps/sui/table.ts +38 -0
- package/src/_generated/zing_identity/deps/sui/vec_set.ts +28 -0
- package/src/_generated/zing_identity/ecdsa.ts +166 -0
- package/src/_generated/zing_identity/identity.ts +661 -0
- package/src/_generated/zing_identity/reclaim.ts +803 -0
- package/src/_generated/zing_studio/app.ts +855 -0
- package/src/_generated/zing_studio/article.ts +598 -0
- package/src/_generated/zing_studio/config.ts +475 -0
- package/src/_generated/zing_studio/deps/std/type_name.ts +25 -0
- package/src/_generated/zing_studio/deps/sui/bag.ts +43 -0
- package/src/_generated/zing_studio/deps/sui/balance.ts +20 -0
- package/src/_generated/zing_studio/deps/sui/coin.ts +21 -0
- package/src/_generated/zing_studio/deps/sui/dynamic_field.ts +272 -0
- package/src/_generated/zing_studio/deps/sui/object.ts +16 -0
- package/src/_generated/zing_studio/deps/sui/table.ts +38 -0
- package/src/_generated/zing_studio/deps/sui/vec_map.ts +39 -0
- package/src/_generated/zing_studio/deps/sui/vec_set.ts +28 -0
- package/src/_generated/zing_studio/deps/walrus/blob.ts +22 -0
- package/src/_generated/zing_studio/deps/walrus/events.ts +124 -0
- package/src/_generated/zing_studio/deps/walrus/metadata.ts +137 -0
- package/src/_generated/zing_studio/deps/walrus/storage_resource.ts +17 -0
- package/src/_generated/zing_studio/deps/zing_framework/derived_object_bag.ts +17 -0
- package/src/_generated/zing_studio/deps/zing_framework/derived_table.ts +17 -0
- package/src/_generated/zing_studio/donation.ts +18 -0
- package/src/_generated/zing_studio/enclave.ts +466 -0
- package/src/_generated/zing_studio/nitro_attestation.ts +308 -0
- package/src/_generated/zing_studio/referral.ts +447 -0
- package/src/_generated/zing_studio/storage.ts +664 -0
- package/src/_generated/zing_studio/studio.ts +682 -0
- package/src/bcs.ts +139 -0
- package/src/client/index.ts +557 -0
- package/src/client/types.ts +28 -0
- package/src/components/index.ts +3 -0
- package/src/components/wallet-provider.tsx +53 -0
- package/src/components/walrus-provider.tsx +212 -0
- package/src/components/zing-provider.tsx +54 -0
- package/src/config/common.ts +82 -0
- package/src/config/index.ts +45 -0
- package/src/config/mainnet.ts +109 -0
- package/src/config/testnet.ts +111 -0
- package/src/config/types.ts +69 -0
- package/src/const.ts +32 -0
- package/src/getters.ts +523 -0
- package/src/hooks/index.ts +14 -0
- package/src/hooks/useGetStudio.ts +22 -0
- package/src/hooks/useGetTierPlan.ts +115 -0
- package/src/hooks/useReclaim.ts +165 -0
- package/src/hooks/useSignAndExecuteTransaction.ts +57 -0
- package/src/hooks/useSignPersonalMessage.ts +28 -0
- package/src/hooks/useZingInfiniteQueries.ts +92 -0
- package/src/hooks/useZingMutation.ts +66 -0
- package/src/hooks/useZingQueries.ts +107 -0
- package/src/hooks/useZingQuery.ts +88 -0
- package/src/index.ts +15 -0
- package/src/lib/utils/colorful-logger.ts +27 -0
- package/src/lib/utils/const.ts +25 -0
- package/src/lib/utils/helpers.ts +78 -0
- package/src/lib/utils/index.ts +5 -0
- package/src/lib/utils/init-app-with-shadow.ts +42 -0
- package/src/lib/utils/quilt.ts +317 -0
- package/src/lib/utils/reclaim.ts +148 -0
- package/src/lib/utils/types.ts +14 -0
- package/src/mutations/index.ts +3 -0
- package/src/mutations/seal.ts +78 -0
- package/src/mutations/signer.ts +241 -0
- package/src/mutations/walrus.ts +862 -0
- package/src/stores/index.ts +3 -0
- package/src/stores/walletStore.ts +360 -0
- package/src/stores/walrusStore.ts +118 -0
- package/src/stores/zkloginStore.ts +53 -0
- package/src/types.ts +120 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import * as type_name from "./deps/std/type_name.js";
|
|
5
|
+
import * as object from "./deps/sui/object.js";
|
|
6
|
+
import * as vec_set from "./deps/sui/vec_set.js";
|
|
7
|
+
import { MoveStruct, normalizeMoveArguments } from "../utils/index.js";
|
|
8
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
9
|
+
import type { RawTransactionArgument } from "../utils/index.js";
|
|
10
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
11
|
+
|
|
12
|
+
const $moduleName = "@local-pkg/zing_identity::config";
|
|
13
|
+
export const Config = new MoveStruct({
|
|
14
|
+
name: `${$moduleName}::Config`,
|
|
15
|
+
fields: {
|
|
16
|
+
id: object.UID,
|
|
17
|
+
registry: vec_set.VecSet(type_name.TypeName),
|
|
18
|
+
versions: vec_set.VecSet(bcs.u64()),
|
|
19
|
+
base_read_fee: bcs.u64(),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
export interface PackageVersionOptions {
|
|
23
|
+
package?: string;
|
|
24
|
+
arguments?: [];
|
|
25
|
+
}
|
|
26
|
+
export function packageVersion(options: PackageVersionOptions = {}) {
|
|
27
|
+
const packageAddress = options.package ?? "@local-pkg/zing_identity";
|
|
28
|
+
return (tx: Transaction) =>
|
|
29
|
+
tx.moveCall({
|
|
30
|
+
package: packageAddress,
|
|
31
|
+
module: "config",
|
|
32
|
+
function: "package_version",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export interface BaseReadFeeArguments {
|
|
36
|
+
self: RawTransactionArgument<string>;
|
|
37
|
+
}
|
|
38
|
+
export interface BaseReadFeeOptions {
|
|
39
|
+
package?: string;
|
|
40
|
+
arguments: BaseReadFeeArguments | [self: RawTransactionArgument<string>];
|
|
41
|
+
}
|
|
42
|
+
export function baseReadFee(options: BaseReadFeeOptions) {
|
|
43
|
+
const packageAddress = options.package ?? "@local-pkg/zing_identity";
|
|
44
|
+
const argumentsTypes = [
|
|
45
|
+
`${packageAddress}::config::Config`,
|
|
46
|
+
] satisfies string[];
|
|
47
|
+
const parameterNames = ["self"];
|
|
48
|
+
return (tx: Transaction) =>
|
|
49
|
+
tx.moveCall({
|
|
50
|
+
package: packageAddress,
|
|
51
|
+
module: "config",
|
|
52
|
+
function: "base_read_fee",
|
|
53
|
+
arguments: normalizeMoveArguments(
|
|
54
|
+
options.arguments,
|
|
55
|
+
argumentsTypes,
|
|
56
|
+
parameterNames,
|
|
57
|
+
),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export interface AddVersionArguments {
|
|
61
|
+
self: RawTransactionArgument<string>;
|
|
62
|
+
Cap: RawTransactionArgument<string>;
|
|
63
|
+
version: RawTransactionArgument<number | bigint>;
|
|
64
|
+
}
|
|
65
|
+
export interface AddVersionOptions {
|
|
66
|
+
package?: string;
|
|
67
|
+
arguments:
|
|
68
|
+
| AddVersionArguments
|
|
69
|
+
| [
|
|
70
|
+
self: RawTransactionArgument<string>,
|
|
71
|
+
Cap: RawTransactionArgument<string>,
|
|
72
|
+
version: RawTransactionArgument<number | bigint>,
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
export function addVersion(options: AddVersionOptions) {
|
|
76
|
+
const packageAddress = options.package ?? "@local-pkg/zing_identity";
|
|
77
|
+
const argumentsTypes = [
|
|
78
|
+
`${packageAddress}::config::Config`,
|
|
79
|
+
`${packageAddress}::admin::AdminCap`,
|
|
80
|
+
"u64",
|
|
81
|
+
] satisfies string[];
|
|
82
|
+
const parameterNames = ["self", "Cap", "version"];
|
|
83
|
+
return (tx: Transaction) =>
|
|
84
|
+
tx.moveCall({
|
|
85
|
+
package: packageAddress,
|
|
86
|
+
module: "config",
|
|
87
|
+
function: "add_version",
|
|
88
|
+
arguments: normalizeMoveArguments(
|
|
89
|
+
options.arguments,
|
|
90
|
+
argumentsTypes,
|
|
91
|
+
parameterNames,
|
|
92
|
+
),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
export interface RemoveVersionArguments {
|
|
96
|
+
self: RawTransactionArgument<string>;
|
|
97
|
+
Cap: RawTransactionArgument<string>;
|
|
98
|
+
version: RawTransactionArgument<number | bigint>;
|
|
99
|
+
}
|
|
100
|
+
export interface RemoveVersionOptions {
|
|
101
|
+
package?: string;
|
|
102
|
+
arguments:
|
|
103
|
+
| RemoveVersionArguments
|
|
104
|
+
| [
|
|
105
|
+
self: RawTransactionArgument<string>,
|
|
106
|
+
Cap: RawTransactionArgument<string>,
|
|
107
|
+
version: RawTransactionArgument<number | bigint>,
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
export function removeVersion(options: RemoveVersionOptions) {
|
|
111
|
+
const packageAddress = options.package ?? "@local-pkg/zing_identity";
|
|
112
|
+
const argumentsTypes = [
|
|
113
|
+
`${packageAddress}::config::Config`,
|
|
114
|
+
`${packageAddress}::admin::AdminCap`,
|
|
115
|
+
"u64",
|
|
116
|
+
] satisfies string[];
|
|
117
|
+
const parameterNames = ["self", "Cap", "version"];
|
|
118
|
+
return (tx: Transaction) =>
|
|
119
|
+
tx.moveCall({
|
|
120
|
+
package: packageAddress,
|
|
121
|
+
module: "config",
|
|
122
|
+
function: "remove_version",
|
|
123
|
+
arguments: normalizeMoveArguments(
|
|
124
|
+
options.arguments,
|
|
125
|
+
argumentsTypes,
|
|
126
|
+
parameterNames,
|
|
127
|
+
),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
export interface UpdateReadFeeArguments {
|
|
131
|
+
self: RawTransactionArgument<string>;
|
|
132
|
+
Cap: RawTransactionArgument<string>;
|
|
133
|
+
fee: RawTransactionArgument<number | bigint>;
|
|
134
|
+
}
|
|
135
|
+
export interface UpdateReadFeeOptions {
|
|
136
|
+
package?: string;
|
|
137
|
+
arguments:
|
|
138
|
+
| UpdateReadFeeArguments
|
|
139
|
+
| [
|
|
140
|
+
self: RawTransactionArgument<string>,
|
|
141
|
+
Cap: RawTransactionArgument<string>,
|
|
142
|
+
fee: RawTransactionArgument<number | bigint>,
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
export function updateReadFee(options: UpdateReadFeeOptions) {
|
|
146
|
+
const packageAddress = options.package ?? "@local-pkg/zing_identity";
|
|
147
|
+
const argumentsTypes = [
|
|
148
|
+
`${packageAddress}::config::Config`,
|
|
149
|
+
`${packageAddress}::admin::AdminCap`,
|
|
150
|
+
"u64",
|
|
151
|
+
] satisfies string[];
|
|
152
|
+
const parameterNames = ["self", "Cap", "fee"];
|
|
153
|
+
return (tx: Transaction) =>
|
|
154
|
+
tx.moveCall({
|
|
155
|
+
package: packageAddress,
|
|
156
|
+
module: "config",
|
|
157
|
+
function: "update_read_fee",
|
|
158
|
+
arguments: normalizeMoveArguments(
|
|
159
|
+
options.arguments,
|
|
160
|
+
argumentsTypes,
|
|
161
|
+
parameterNames,
|
|
162
|
+
),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
export interface DerivedObjectKeyArguments {
|
|
166
|
+
name: RawTransactionArgument<string>;
|
|
167
|
+
}
|
|
168
|
+
export interface DerivedObjectKeyOptions {
|
|
169
|
+
package?: string;
|
|
170
|
+
arguments: DerivedObjectKeyArguments | [name: RawTransactionArgument<string>];
|
|
171
|
+
typeArguments: [string];
|
|
172
|
+
}
|
|
173
|
+
export function derivedObjectKey(options: DerivedObjectKeyOptions) {
|
|
174
|
+
const packageAddress = options.package ?? "@local-pkg/zing_identity";
|
|
175
|
+
const argumentsTypes = [
|
|
176
|
+
"0x0000000000000000000000000000000000000000000000000000000000000001::ascii::String",
|
|
177
|
+
] satisfies string[];
|
|
178
|
+
const parameterNames = ["name"];
|
|
179
|
+
return (tx: Transaction) =>
|
|
180
|
+
tx.moveCall({
|
|
181
|
+
package: packageAddress,
|
|
182
|
+
module: "config",
|
|
183
|
+
function: "derived_object_key",
|
|
184
|
+
arguments: normalizeMoveArguments(
|
|
185
|
+
options.arguments,
|
|
186
|
+
argumentsTypes,
|
|
187
|
+
parameterNames,
|
|
188
|
+
),
|
|
189
|
+
typeArguments: options.typeArguments,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/** Functionality for converting Move types into values. Use with care! */
|
|
6
|
+
|
|
7
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
8
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
9
|
+
|
|
10
|
+
const $moduleName = "std::type_name";
|
|
11
|
+
export const TypeName = new MoveStruct({
|
|
12
|
+
name: `${$moduleName}::TypeName`,
|
|
13
|
+
fields: {
|
|
14
|
+
/**
|
|
15
|
+
* String representation of the type. All types are represented using their source
|
|
16
|
+
* syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types.
|
|
17
|
+
* Struct types are represented as fully qualified type names; e.g.
|
|
18
|
+
* `00000000000000000000000000000001::string::String` or
|
|
19
|
+
* `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2<u64>>`
|
|
20
|
+
* Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or
|
|
21
|
+
* 32 depending on the Move platform)
|
|
22
|
+
*/
|
|
23
|
+
name: bcs.string(),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/** Sui object identifiers */
|
|
6
|
+
|
|
7
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
8
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
9
|
+
|
|
10
|
+
const $moduleName = "0x2::object";
|
|
11
|
+
export const UID = new MoveStruct({
|
|
12
|
+
name: `${$moduleName}::UID`,
|
|
13
|
+
fields: {
|
|
14
|
+
id: bcs.Address,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Similar to `sui::table`, an `ObjectTable<K, V>` is a map-like collection. But
|
|
7
|
+
* unlike `sui::table`, the values bound to these dynamic fields _must_ be objects
|
|
8
|
+
* themselves. This allows for the objects to still exist within in storage, which
|
|
9
|
+
* may be important for external tools. The difference is otherwise not observable
|
|
10
|
+
* from within Move.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import * as object from "./object.js";
|
|
14
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
15
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
16
|
+
|
|
17
|
+
const $moduleName = "0x2::object_table";
|
|
18
|
+
export const ObjectTable = new MoveStruct({
|
|
19
|
+
name: `${$moduleName}::ObjectTable`,
|
|
20
|
+
fields: {
|
|
21
|
+
/** the ID of this table */
|
|
22
|
+
id: object.UID,
|
|
23
|
+
/** the number of key-value pairs in the table */
|
|
24
|
+
size: bcs.u64(),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A table is a map-like collection. But unlike a traditional collection, it's keys
|
|
7
|
+
* and values are not stored within the `Table` value, but instead are stored using
|
|
8
|
+
* Sui's object system. The `Table` struct acts only as a handle into the object
|
|
9
|
+
* system to retrieve those keys and values. Note that this means that `Table`
|
|
10
|
+
* values with exactly the same key-value mapping will not be equal, with `==`, at
|
|
11
|
+
* runtime. For example
|
|
12
|
+
*
|
|
13
|
+
* ```
|
|
14
|
+
* let table1 = table::new<u64, bool>();
|
|
15
|
+
* let table2 = table::new<u64, bool>();
|
|
16
|
+
* table::add(&mut table1, 0, false);
|
|
17
|
+
* table::add(&mut table1, 1, true);
|
|
18
|
+
* table::add(&mut table2, 0, false);
|
|
19
|
+
* table::add(&mut table2, 1, true);
|
|
20
|
+
* // table1 does not equal table2, despite having the same entries
|
|
21
|
+
* assert!(&table1 != &table2);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import * as object from "./object.js";
|
|
26
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
27
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
28
|
+
|
|
29
|
+
const $moduleName = "0x2::table";
|
|
30
|
+
export const Table = new MoveStruct({
|
|
31
|
+
name: `${$moduleName}::Table`,
|
|
32
|
+
fields: {
|
|
33
|
+
/** the ID of this table */
|
|
34
|
+
id: object.UID,
|
|
35
|
+
/** the number of key-value pairs in the table */
|
|
36
|
+
size: bcs.u64(),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
5
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
6
|
+
import type { BcsType } from "@mysten/sui/bcs";
|
|
7
|
+
|
|
8
|
+
const $moduleName = "0x2::vec_set";
|
|
9
|
+
/**
|
|
10
|
+
* A set data structure backed by a vector. The set is guaranteed not to contain
|
|
11
|
+
* duplicate keys. All operations are O(N) in the size of the set
|
|
12
|
+
*
|
|
13
|
+
* - the intention of this data structure is only to provide the convenience of
|
|
14
|
+
* programming against a set API. Sets that need sorted iteration rather than
|
|
15
|
+
* insertion order iteration should be handwritten.
|
|
16
|
+
*/
|
|
17
|
+
export function VecSet<K extends BcsType<any>>(
|
|
18
|
+
...typeParameters: [K]
|
|
19
|
+
): MoveStruct<{
|
|
20
|
+
contents: ReturnType<typeof bcs.vector<K>>;
|
|
21
|
+
}> {
|
|
22
|
+
return new MoveStruct({
|
|
23
|
+
name: `${$moduleName}::VecSet<${typeParameters[0].name as K["name"]}>`,
|
|
24
|
+
fields: {
|
|
25
|
+
contents: bcs.vector(typeParameters[0]),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import * as object from "./deps/sui/object.js";
|
|
5
|
+
import { MoveStruct, normalizeMoveArguments } from "../utils/index.js";
|
|
6
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
7
|
+
import type { RawTransactionArgument } from "../utils/index.js";
|
|
8
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
9
|
+
|
|
10
|
+
const $moduleName = "@local-pkg/zing_identity::ecdsa";
|
|
11
|
+
export const VerifiedEvent = new MoveStruct({
|
|
12
|
+
name: `${$moduleName}::VerifiedEvent`,
|
|
13
|
+
fields: {
|
|
14
|
+
is_verified: bcs.bool(),
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
export const Output = new MoveStruct({
|
|
18
|
+
name: `${$moduleName}::Output`,
|
|
19
|
+
fields: {
|
|
20
|
+
id: object.UID,
|
|
21
|
+
value: bcs.vector(bcs.u8()),
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
export interface Keccak256Arguments {
|
|
25
|
+
data: RawTransactionArgument<number[]>;
|
|
26
|
+
recipient: RawTransactionArgument<string>;
|
|
27
|
+
}
|
|
28
|
+
export interface Keccak256Options {
|
|
29
|
+
package?: string;
|
|
30
|
+
arguments:
|
|
31
|
+
| Keccak256Arguments
|
|
32
|
+
| [
|
|
33
|
+
data: RawTransactionArgument<number[]>,
|
|
34
|
+
recipient: RawTransactionArgument<string>,
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
/** Hash the data using Keccak256, output an object with the hash to recipient. */
|
|
38
|
+
export function keccak256(options: Keccak256Options) {
|
|
39
|
+
const packageAddress = options.package ?? "@local-pkg/zing_identity";
|
|
40
|
+
const argumentsTypes = ["vector<u8>", "address"] satisfies string[];
|
|
41
|
+
const parameterNames = ["data", "recipient"];
|
|
42
|
+
return (tx: Transaction) =>
|
|
43
|
+
tx.moveCall({
|
|
44
|
+
package: packageAddress,
|
|
45
|
+
module: "ecdsa",
|
|
46
|
+
function: "keccak256",
|
|
47
|
+
arguments: normalizeMoveArguments(
|
|
48
|
+
options.arguments,
|
|
49
|
+
argumentsTypes,
|
|
50
|
+
parameterNames,
|
|
51
|
+
),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export interface EcrecoverArguments {
|
|
55
|
+
signature: RawTransactionArgument<number[]>;
|
|
56
|
+
msg: RawTransactionArgument<number[]>;
|
|
57
|
+
recipient: RawTransactionArgument<string>;
|
|
58
|
+
}
|
|
59
|
+
export interface EcrecoverOptions {
|
|
60
|
+
package?: string;
|
|
61
|
+
arguments:
|
|
62
|
+
| EcrecoverArguments
|
|
63
|
+
| [
|
|
64
|
+
signature: RawTransactionArgument<number[]>,
|
|
65
|
+
msg: RawTransactionArgument<number[]>,
|
|
66
|
+
recipient: RawTransactionArgument<string>,
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Recover the public key using the signature and message, assuming the signature
|
|
71
|
+
* was produced over the Keccak256 hash of the message. Output an object with the
|
|
72
|
+
* recovered pubkey to recipient.
|
|
73
|
+
*/
|
|
74
|
+
export function ecrecover(options: EcrecoverOptions) {
|
|
75
|
+
const packageAddress = options.package ?? "@local-pkg/zing_identity";
|
|
76
|
+
const argumentsTypes = [
|
|
77
|
+
"vector<u8>",
|
|
78
|
+
"vector<u8>",
|
|
79
|
+
"address",
|
|
80
|
+
] satisfies string[];
|
|
81
|
+
const parameterNames = ["signature", "msg", "recipient"];
|
|
82
|
+
return (tx: Transaction) =>
|
|
83
|
+
tx.moveCall({
|
|
84
|
+
package: packageAddress,
|
|
85
|
+
module: "ecdsa",
|
|
86
|
+
function: "ecrecover",
|
|
87
|
+
arguments: normalizeMoveArguments(
|
|
88
|
+
options.arguments,
|
|
89
|
+
argumentsTypes,
|
|
90
|
+
parameterNames,
|
|
91
|
+
),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export interface EcrecoverToEthAddressArguments {
|
|
95
|
+
signature: RawTransactionArgument<number[]>;
|
|
96
|
+
msg: RawTransactionArgument<number[]>;
|
|
97
|
+
}
|
|
98
|
+
export interface EcrecoverToEthAddressOptions {
|
|
99
|
+
package?: string;
|
|
100
|
+
arguments:
|
|
101
|
+
| EcrecoverToEthAddressArguments
|
|
102
|
+
| [
|
|
103
|
+
signature: RawTransactionArgument<number[]>,
|
|
104
|
+
msg: RawTransactionArgument<number[]>,
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Recover the Ethereum address using the signature and message, assuming the
|
|
109
|
+
* signature was produced over the Keccak256 hash of the message. Output an object
|
|
110
|
+
* with the recovered address to recipient.
|
|
111
|
+
*/
|
|
112
|
+
export function ecrecoverToEthAddress(options: EcrecoverToEthAddressOptions) {
|
|
113
|
+
const packageAddress = options.package ?? "@local-pkg/zing_identity";
|
|
114
|
+
const argumentsTypes = ["vector<u8>", "vector<u8>"] satisfies string[];
|
|
115
|
+
const parameterNames = ["signature", "msg"];
|
|
116
|
+
return (tx: Transaction) =>
|
|
117
|
+
tx.moveCall({
|
|
118
|
+
package: packageAddress,
|
|
119
|
+
module: "ecdsa",
|
|
120
|
+
function: "ecrecover_to_eth_address",
|
|
121
|
+
arguments: normalizeMoveArguments(
|
|
122
|
+
options.arguments,
|
|
123
|
+
argumentsTypes,
|
|
124
|
+
parameterNames,
|
|
125
|
+
),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
export interface Secp256k1VerifyArguments {
|
|
129
|
+
signature: RawTransactionArgument<number[]>;
|
|
130
|
+
publicKey: RawTransactionArgument<number[]>;
|
|
131
|
+
msg: RawTransactionArgument<number[]>;
|
|
132
|
+
}
|
|
133
|
+
export interface Secp256k1VerifyOptions {
|
|
134
|
+
package?: string;
|
|
135
|
+
arguments:
|
|
136
|
+
| Secp256k1VerifyArguments
|
|
137
|
+
| [
|
|
138
|
+
signature: RawTransactionArgument<number[]>,
|
|
139
|
+
publicKey: RawTransactionArgument<number[]>,
|
|
140
|
+
msg: RawTransactionArgument<number[]>,
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Verified the secp256k1 signature using public key and message assuming Keccak
|
|
145
|
+
* was using when signing. Emit an is_verified event of the verification result.
|
|
146
|
+
*/
|
|
147
|
+
export function secp256k1Verify(options: Secp256k1VerifyOptions) {
|
|
148
|
+
const packageAddress = options.package ?? "@local-pkg/zing_identity";
|
|
149
|
+
const argumentsTypes = [
|
|
150
|
+
"vector<u8>",
|
|
151
|
+
"vector<u8>",
|
|
152
|
+
"vector<u8>",
|
|
153
|
+
] satisfies string[];
|
|
154
|
+
const parameterNames = ["signature", "publicKey", "msg"];
|
|
155
|
+
return (tx: Transaction) =>
|
|
156
|
+
tx.moveCall({
|
|
157
|
+
package: packageAddress,
|
|
158
|
+
module: "ecdsa",
|
|
159
|
+
function: "secp256k1_verify",
|
|
160
|
+
arguments: normalizeMoveArguments(
|
|
161
|
+
options.arguments,
|
|
162
|
+
argumentsTypes,
|
|
163
|
+
parameterNames,
|
|
164
|
+
),
|
|
165
|
+
});
|
|
166
|
+
}
|