@mysten/sui 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/client/client.d.mts.map +1 -1
- package/dist/client/client.mjs +13 -3
- package/dist/client/client.mjs.map +1 -1
- package/dist/client/core.d.mts +1 -0
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/types.d.mts +18 -0
- package/dist/client/types.d.mts.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/graphql/client.d.mts +1 -0
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +3 -0
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +1 -0
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +18 -1
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +13 -1
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/grpc/client.d.mts +1 -0
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +3 -0
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +1 -0
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +18 -0
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
- package/dist/jsonRpc/core.d.mts +1 -0
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +16 -0
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +7 -7
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/data/internal.d.mts +109 -109
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/v1.d.mts +220 -220
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/transactions/data/v2.d.mts.map +1 -1
- package/dist/version.mjs +2 -2
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/bcs.d.mts.map +1 -1
- package/package.json +3 -3
- package/src/client/client.ts +23 -8
- package/src/client/core.ts +4 -0
- package/src/client/types.ts +22 -0
- package/src/graphql/client.ts +6 -0
- package/src/graphql/core.ts +31 -0
- package/src/graphql/generated/queries.ts +20 -1
- package/src/graphql/queries/getCoinMetadata.graphql +13 -0
- package/src/grpc/client.ts +6 -0
- package/src/grpc/core.ts +30 -0
- package/src/jsonRpc/core.ts +26 -0
- package/src/version.ts +2 -2
package/dist/zklogin/bcs.d.mts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _mysten_bcs1118 from "@mysten/bcs";
|
|
2
2
|
import { InferBcsInput } from "@mysten/bcs";
|
|
3
3
|
|
|
4
4
|
//#region src/zklogin/bcs.d.ts
|
|
5
|
-
declare const zkLoginSignature:
|
|
6
|
-
inputs:
|
|
7
|
-
proofPoints:
|
|
8
|
-
a:
|
|
5
|
+
declare const zkLoginSignature: _mysten_bcs1118.BcsStruct<{
|
|
6
|
+
inputs: _mysten_bcs1118.BcsStruct<{
|
|
7
|
+
proofPoints: _mysten_bcs1118.BcsStruct<{
|
|
8
|
+
a: _mysten_bcs1118.BcsType<string[], Iterable<string> & {
|
|
9
9
|
length: number;
|
|
10
10
|
}, string>;
|
|
11
|
-
b:
|
|
11
|
+
b: _mysten_bcs1118.BcsType<string[][], Iterable<Iterable<string> & {
|
|
12
12
|
length: number;
|
|
13
13
|
}> & {
|
|
14
14
|
length: number;
|
|
15
15
|
}, string>;
|
|
16
|
-
c:
|
|
16
|
+
c: _mysten_bcs1118.BcsType<string[], Iterable<string> & {
|
|
17
17
|
length: number;
|
|
18
18
|
}, string>;
|
|
19
19
|
}, string>;
|
|
20
|
-
issBase64Details:
|
|
21
|
-
value:
|
|
22
|
-
indexMod4:
|
|
20
|
+
issBase64Details: _mysten_bcs1118.BcsStruct<{
|
|
21
|
+
value: _mysten_bcs1118.BcsType<string, string, "string">;
|
|
22
|
+
indexMod4: _mysten_bcs1118.BcsType<number, number, "u8">;
|
|
23
23
|
}, string>;
|
|
24
|
-
headerBase64:
|
|
25
|
-
addressSeed:
|
|
24
|
+
headerBase64: _mysten_bcs1118.BcsType<string, string, "string">;
|
|
25
|
+
addressSeed: _mysten_bcs1118.BcsType<string, string, "string">;
|
|
26
26
|
}, string>;
|
|
27
|
-
maxEpoch:
|
|
28
|
-
userSignature:
|
|
27
|
+
maxEpoch: _mysten_bcs1118.BcsType<string, string | number | bigint, "u64">;
|
|
28
|
+
userSignature: _mysten_bcs1118.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
|
|
29
29
|
}, string>;
|
|
30
30
|
type ZkLoginSignature = InferBcsInput<typeof zkLoginSignature>;
|
|
31
31
|
type ZkLoginSignatureInputs = ZkLoginSignature['inputs'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bcs.d.mts","names":[],"sources":["../../src/zklogin/bcs.ts"],"sourcesContent":[],"mappings":";;;;cAMa,
|
|
1
|
+
{"version":3,"file":"bcs.d.mts","names":[],"sources":["../../src/zklogin/bcs.ts"],"sourcesContent":[],"mappings":";;;;cAMa,kCAAgB;;;MAAhB,CAAA,yBAgBX,CAAA,MAAA,EAAA,UAAA,CAAA,MAAA,CAAA,GAAA;;;;;;;;;;;;;;;;;;;;eAhB2B,yBAAA,WAAA,gBAAA,CAAA,UAAA,CAAA,MAAA,CAAA,EAAA,YAAA,CAAA;CAAA,EAAA,MAAA,CAAA;AAkBjB,KAAA,gBAAA,GAAmB,aAAqB,CAAA,OAAA,gBAAR,CAAA;AAChC,KAAA,sBAAA,GAAyB,gBAAA,CAAA,QAAgB,CAAA"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
4
4
|
"description": "Sui TypeScript API",
|
|
5
5
|
"homepage": "https://sdk.mystenlabs.com",
|
|
6
|
-
"version": "2.0
|
|
6
|
+
"version": "2.2.0",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"files": [
|
|
@@ -151,8 +151,8 @@
|
|
|
151
151
|
"graphql": "^16.12.0",
|
|
152
152
|
"poseidon-lite": "0.2.1",
|
|
153
153
|
"valibot": "^1.2.0",
|
|
154
|
-
"@mysten/
|
|
155
|
-
"@mysten/
|
|
154
|
+
"@mysten/utils": "^0.3.0",
|
|
155
|
+
"@mysten/bcs": "^2.0.1"
|
|
156
156
|
},
|
|
157
157
|
"scripts": {
|
|
158
158
|
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|
package/src/client/client.ts
CHANGED
|
@@ -26,14 +26,29 @@ export abstract class BaseClient {
|
|
|
26
26
|
$extend<const Registrations extends SuiClientRegistration<this>[]>(
|
|
27
27
|
...registrations: Registrations
|
|
28
28
|
) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
const extensions: Record<string, unknown> = Object.fromEntries(
|
|
30
|
+
registrations.map((registration) => {
|
|
31
|
+
return [registration.name, registration.register(this)];
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const methodCache = new Map<string | symbol, Function>();
|
|
36
|
+
|
|
37
|
+
return new Proxy(this, {
|
|
38
|
+
get(target, prop) {
|
|
39
|
+
if (typeof prop === 'string' && prop in extensions) {
|
|
40
|
+
return extensions[prop];
|
|
41
|
+
}
|
|
42
|
+
const value = Reflect.get(target, prop, target);
|
|
43
|
+
if (typeof value === 'function') {
|
|
44
|
+
if (!methodCache.has(prop)) {
|
|
45
|
+
methodCache.set(prop, value.bind(target));
|
|
46
|
+
}
|
|
47
|
+
return methodCache.get(prop);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
},
|
|
51
|
+
}) as ClientWithExtensions<
|
|
37
52
|
Simplify<
|
|
38
53
|
UnionToIntersection<
|
|
39
54
|
{
|
package/src/client/core.ts
CHANGED
|
@@ -76,6 +76,10 @@ export abstract class CoreClient extends BaseClient implements SuiClientTypes.Tr
|
|
|
76
76
|
options: SuiClientTypes.ListBalancesOptions,
|
|
77
77
|
): Promise<SuiClientTypes.ListBalancesResponse>;
|
|
78
78
|
|
|
79
|
+
abstract getCoinMetadata(
|
|
80
|
+
options: SuiClientTypes.GetCoinMetadataOptions,
|
|
81
|
+
): Promise<SuiClientTypes.GetCoinMetadataResponse>;
|
|
82
|
+
|
|
79
83
|
abstract getTransaction<Include extends SuiClientTypes.TransactionInclude = object>(
|
|
80
84
|
options: SuiClientTypes.GetTransactionOptions<Include>,
|
|
81
85
|
): Promise<SuiClientTypes.TransactionResult<Include>>;
|
package/src/client/types.ts
CHANGED
|
@@ -235,6 +235,28 @@ export namespace SuiClientTypes {
|
|
|
235
235
|
cursor: string | null;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
/** Coin metadata methods */
|
|
239
|
+
export interface TransportMethods {
|
|
240
|
+
getCoinMetadata: (options: GetCoinMetadataOptions) => Promise<GetCoinMetadataResponse>;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface GetCoinMetadataOptions extends CoreClientMethodOptions {
|
|
244
|
+
coinType: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export interface CoinMetadata {
|
|
248
|
+
id: string | null;
|
|
249
|
+
decimals: number;
|
|
250
|
+
name: string;
|
|
251
|
+
symbol: string;
|
|
252
|
+
description: string;
|
|
253
|
+
iconUrl: string | null;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface GetCoinMetadataResponse {
|
|
257
|
+
coinMetadata: CoinMetadata | null;
|
|
258
|
+
}
|
|
259
|
+
|
|
238
260
|
/** Transaction methods */
|
|
239
261
|
export interface TransportMethods {
|
|
240
262
|
getTransaction: <Include extends TransactionInclude = {}>(
|
package/src/graphql/client.ts
CHANGED
|
@@ -180,6 +180,12 @@ export class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> =
|
|
|
180
180
|
return this.core.listBalances(input);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
getCoinMetadata(
|
|
184
|
+
input: SuiClientTypes.GetCoinMetadataOptions,
|
|
185
|
+
): Promise<SuiClientTypes.GetCoinMetadataResponse> {
|
|
186
|
+
return this.core.getCoinMetadata(input);
|
|
187
|
+
}
|
|
188
|
+
|
|
183
189
|
getTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
184
190
|
input: SuiClientTypes.GetTransactionOptions<Include>,
|
|
185
191
|
): Promise<SuiClientTypes.TransactionResult<Include>> {
|
package/src/graphql/core.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
GetAllBalancesDocument,
|
|
21
21
|
GetBalanceDocument,
|
|
22
22
|
GetChainIdentifierDocument,
|
|
23
|
+
GetCoinMetadataDocument,
|
|
23
24
|
GetCoinsDocument,
|
|
24
25
|
GetCurrentSystemStateDocument,
|
|
25
26
|
GetDynamicFieldsDocument,
|
|
@@ -269,6 +270,36 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
269
270
|
},
|
|
270
271
|
};
|
|
271
272
|
}
|
|
273
|
+
async getCoinMetadata(
|
|
274
|
+
options: SuiClientTypes.GetCoinMetadataOptions,
|
|
275
|
+
): Promise<SuiClientTypes.GetCoinMetadataResponse> {
|
|
276
|
+
const coinType = (await this.mvr.resolveType({ type: options.coinType })).type;
|
|
277
|
+
|
|
278
|
+
const { data, errors } = await this.#graphqlClient.query({
|
|
279
|
+
query: GetCoinMetadataDocument,
|
|
280
|
+
variables: {
|
|
281
|
+
coinType,
|
|
282
|
+
},
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
handleGraphQLErrors(errors);
|
|
286
|
+
|
|
287
|
+
if (!data?.coinMetadata) {
|
|
288
|
+
return { coinMetadata: null };
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return {
|
|
292
|
+
coinMetadata: {
|
|
293
|
+
id: data.coinMetadata.address!,
|
|
294
|
+
decimals: data.coinMetadata.decimals!,
|
|
295
|
+
name: data.coinMetadata.name!,
|
|
296
|
+
symbol: data.coinMetadata.symbol!,
|
|
297
|
+
description: data.coinMetadata.description!,
|
|
298
|
+
iconUrl: data.coinMetadata.iconUrl ?? null,
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
272
303
|
async listBalances(
|
|
273
304
|
options: SuiClientTypes.ListBalancesOptions,
|
|
274
305
|
): Promise<SuiClientTypes.ListBalancesResponse> {
|
|
@@ -3587,7 +3587,7 @@ export type Query = {
|
|
|
3587
3587
|
* If the address is fetched by name and the name does not resolve to an address (e.g. the name does not exist or has expired), `null` is returned.
|
|
3588
3588
|
*/
|
|
3589
3589
|
address?: Maybe<Address>;
|
|
3590
|
-
/**
|
|
3590
|
+
/** The network's genesis checkpoint digest (uniquely identifies the network), Base58-encoded. */
|
|
3591
3591
|
chainIdentifier: Scalars['String']['output'];
|
|
3592
3592
|
/**
|
|
3593
3593
|
* Fetch a checkpoint by its sequence number, or the latest checkpoint if no sequence number is provided.
|
|
@@ -4612,6 +4612,13 @@ export type GetChainIdentifierQueryVariables = Exact<{ [key: string]: never; }>;
|
|
|
4612
4612
|
|
|
4613
4613
|
export type GetChainIdentifierQuery = { __typename?: 'Query', checkpoint?: { __typename?: 'Checkpoint', digest?: string | null } | null };
|
|
4614
4614
|
|
|
4615
|
+
export type GetCoinMetadataQueryVariables = Exact<{
|
|
4616
|
+
coinType: Scalars['String']['input'];
|
|
4617
|
+
}>;
|
|
4618
|
+
|
|
4619
|
+
|
|
4620
|
+
export type GetCoinMetadataQuery = { __typename?: 'Query', coinMetadata?: { __typename?: 'CoinMetadata', address: string, decimals?: number | null, name?: string | null, symbol?: string | null, description?: string | null, iconUrl?: string | null } | null };
|
|
4621
|
+
|
|
4615
4622
|
export type GetCoinsQueryVariables = Exact<{
|
|
4616
4623
|
owner: Scalars['SuiAddress']['input'];
|
|
4617
4624
|
first?: InputMaybe<Scalars['Int']['input']>;
|
|
@@ -5042,6 +5049,18 @@ export const GetChainIdentifierDocument = new TypedDocumentString(`
|
|
|
5042
5049
|
}
|
|
5043
5050
|
}
|
|
5044
5051
|
`) as unknown as TypedDocumentString<GetChainIdentifierQuery, GetChainIdentifierQueryVariables>;
|
|
5052
|
+
export const GetCoinMetadataDocument = new TypedDocumentString(`
|
|
5053
|
+
query getCoinMetadata($coinType: String!) {
|
|
5054
|
+
coinMetadata(coinType: $coinType) {
|
|
5055
|
+
address
|
|
5056
|
+
decimals
|
|
5057
|
+
name
|
|
5058
|
+
symbol
|
|
5059
|
+
description
|
|
5060
|
+
iconUrl
|
|
5061
|
+
}
|
|
5062
|
+
}
|
|
5063
|
+
`) as unknown as TypedDocumentString<GetCoinMetadataQuery, GetCoinMetadataQueryVariables>;
|
|
5045
5064
|
export const GetCoinsDocument = new TypedDocumentString(`
|
|
5046
5065
|
query getCoins($owner: SuiAddress!, $first: Int, $cursor: String, $type: String = "0x2::coin::Coin<0x2::sui::SUI>") {
|
|
5047
5066
|
address(address: $owner) {
|
package/src/grpc/client.ts
CHANGED
|
@@ -108,6 +108,12 @@ export class SuiGrpcClient extends BaseClient implements SuiClientTypes.Transpor
|
|
|
108
108
|
return this.core.listBalances(input);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
getCoinMetadata(
|
|
112
|
+
input: SuiClientTypes.GetCoinMetadataOptions,
|
|
113
|
+
): Promise<SuiClientTypes.GetCoinMetadataResponse> {
|
|
114
|
+
return this.core.getCoinMetadata(input);
|
|
115
|
+
}
|
|
116
|
+
|
|
111
117
|
getTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
112
118
|
input: SuiClientTypes.GetTransactionOptions<Include>,
|
|
113
119
|
): Promise<SuiClientTypes.TransactionResult<Include>> {
|
package/src/grpc/core.ts
CHANGED
|
@@ -235,6 +235,36 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
async getCoinMetadata(
|
|
239
|
+
options: SuiClientTypes.GetCoinMetadataOptions,
|
|
240
|
+
): Promise<SuiClientTypes.GetCoinMetadataResponse> {
|
|
241
|
+
const coinType = (await this.mvr.resolveType({ type: options.coinType })).type;
|
|
242
|
+
|
|
243
|
+
let response;
|
|
244
|
+
try {
|
|
245
|
+
({ response } = await this.#client.stateService.getCoinInfo({
|
|
246
|
+
coinType,
|
|
247
|
+
}));
|
|
248
|
+
} catch {
|
|
249
|
+
return { coinMetadata: null };
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (!response.metadata) {
|
|
253
|
+
return { coinMetadata: null };
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
coinMetadata: {
|
|
258
|
+
id: response.metadata.id ?? null,
|
|
259
|
+
decimals: response.metadata.decimals ?? 0,
|
|
260
|
+
name: response.metadata.name ?? '',
|
|
261
|
+
symbol: response.metadata.symbol ?? '',
|
|
262
|
+
description: response.metadata.description ?? '',
|
|
263
|
+
iconUrl: response.metadata.iconUrl ?? null,
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
238
268
|
async listBalances(
|
|
239
269
|
options: SuiClientTypes.ListBalancesOptions,
|
|
240
270
|
): Promise<SuiClientTypes.ListBalancesResponse> {
|
package/src/jsonRpc/core.ts
CHANGED
|
@@ -239,6 +239,32 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
239
239
|
},
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
|
+
async getCoinMetadata(
|
|
243
|
+
options: SuiClientTypes.GetCoinMetadataOptions,
|
|
244
|
+
): Promise<SuiClientTypes.GetCoinMetadataResponse> {
|
|
245
|
+
const coinType = (await this.mvr.resolveType({ type: options.coinType })).type;
|
|
246
|
+
|
|
247
|
+
const result = await this.#jsonRpcClient.getCoinMetadata({
|
|
248
|
+
coinType,
|
|
249
|
+
signal: options.signal,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
if (!result) {
|
|
253
|
+
return { coinMetadata: null };
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
coinMetadata: {
|
|
258
|
+
id: result.id ?? null,
|
|
259
|
+
decimals: result.decimals,
|
|
260
|
+
name: result.name,
|
|
261
|
+
symbol: result.symbol,
|
|
262
|
+
description: result.description,
|
|
263
|
+
iconUrl: result.iconUrl ?? null,
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
242
268
|
async listBalances(options: SuiClientTypes.ListBalancesOptions) {
|
|
243
269
|
const balances = await this.#jsonRpcClient.getAllBalances({
|
|
244
270
|
owner: options.owner,
|
package/src/version.ts
CHANGED