@mysten/sui 1.23.0 → 1.25.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/cjs/client/types/generated.d.ts +24 -3
- package/dist/cjs/client/types/generated.js.map +1 -1
- package/dist/cjs/client/types/params.d.ts +14 -0
- package/dist/cjs/client/types/params.js.map +1 -1
- package/dist/cjs/graphql/generated/latest/tada-env.d.ts +56 -12
- package/dist/cjs/graphql/generated/latest/tada-env.js +64 -13
- package/dist/cjs/graphql/generated/latest/tada-env.js.map +2 -2
- package/dist/cjs/transactions/Arguments.d.ts +2 -2
- package/dist/cjs/transactions/Transaction.d.ts +4 -4
- package/dist/cjs/transactions/TransactionData.d.ts +2 -2
- package/dist/cjs/transactions/data/v1.d.ts +4 -4
- package/dist/cjs/transactions/data/v2.d.ts +4 -4
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.d.ts +5 -7
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js +84 -43
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js.map +3 -3
- package/dist/cjs/transactions/plugins/utils.d.ts +10 -6
- package/dist/cjs/transactions/plugins/utils.js +64 -37
- package/dist/cjs/transactions/plugins/utils.js.map +2 -2
- package/dist/cjs/utils/sui-types.d.ts +1 -2
- package/dist/cjs/utils/sui-types.js +3 -1
- package/dist/cjs/utils/sui-types.js.map +2 -2
- package/dist/cjs/version.d.ts +2 -2
- package/dist/cjs/version.js +2 -2
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/client/types/generated.d.ts +24 -3
- package/dist/esm/client/types/params.d.ts +14 -0
- package/dist/esm/graphql/generated/latest/tada-env.d.ts +56 -12
- package/dist/esm/graphql/generated/latest/tada-env.js +64 -13
- package/dist/esm/graphql/generated/latest/tada-env.js.map +2 -2
- package/dist/esm/transactions/Arguments.d.ts +2 -2
- package/dist/esm/transactions/Transaction.d.ts +4 -4
- package/dist/esm/transactions/TransactionData.d.ts +2 -2
- package/dist/esm/transactions/data/v1.d.ts +4 -4
- package/dist/esm/transactions/data/v2.d.ts +4 -4
- package/dist/esm/transactions/plugins/NamedPackagesPlugin.d.ts +5 -7
- package/dist/esm/transactions/plugins/NamedPackagesPlugin.js +91 -44
- package/dist/esm/transactions/plugins/NamedPackagesPlugin.js.map +3 -3
- package/dist/esm/transactions/plugins/utils.d.ts +10 -6
- package/dist/esm/transactions/plugins/utils.js +64 -37
- package/dist/esm/transactions/plugins/utils.js.map +2 -2
- package/dist/esm/utils/sui-types.d.ts +1 -2
- package/dist/esm/utils/sui-types.js +3 -1
- package/dist/esm/utils/sui-types.js.map +2 -2
- package/dist/esm/version.d.ts +2 -2
- package/dist/esm/version.js +2 -2
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/client/types/generated.ts +31 -5
- package/src/client/types/params.ts +14 -0
- package/src/graphql/generated/latest/schema.graphql +17 -6
- package/src/graphql/generated/latest/tada-env.ts +64 -13
- package/src/transactions/plugins/NamedPackagesPlugin.ts +118 -62
- package/src/transactions/plugins/utils.ts +115 -47
- package/src/utils/sui-types.ts +6 -2
- package/src/version.ts +2 -2
package/package.json
CHANGED
|
@@ -99,11 +99,18 @@ export type CompressedSignature =
|
|
|
99
99
|
}
|
|
100
100
|
| {
|
|
101
101
|
ZkLogin: string;
|
|
102
|
+
}
|
|
103
|
+
| {
|
|
104
|
+
Passkey: string;
|
|
102
105
|
};
|
|
103
106
|
/** Uses an enum to allow for future expansion of the ConsensusDeterminedVersionAssignments. */
|
|
104
|
-
export type ConsensusDeterminedVersionAssignments =
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
export type ConsensusDeterminedVersionAssignments =
|
|
108
|
+
| {
|
|
109
|
+
CancelledTransactions: [string, [string, string][]][];
|
|
110
|
+
}
|
|
111
|
+
| {
|
|
112
|
+
CancelledTransactionsV2: [string, [[string, string], string][]][];
|
|
113
|
+
};
|
|
107
114
|
export type SuiParsedData =
|
|
108
115
|
| {
|
|
109
116
|
dataType: 'moveObject';
|
|
@@ -166,6 +173,7 @@ export interface DryRunTransactionBlockResponse {
|
|
|
166
173
|
balanceChanges: BalanceChange[];
|
|
167
174
|
effects: TransactionEffects;
|
|
168
175
|
events: SuiEvent[];
|
|
176
|
+
executionErrorSource?: string | null;
|
|
169
177
|
input: TransactionBlockData;
|
|
170
178
|
objectChanges: SuiObjectChange[];
|
|
171
179
|
}
|
|
@@ -437,8 +445,8 @@ export interface MultiSig {
|
|
|
437
445
|
sigs: CompressedSignature[];
|
|
438
446
|
}
|
|
439
447
|
/**
|
|
440
|
-
* Deprecated, use [struct MultiSig] instead. The struct that contains signatures and public keys
|
|
441
|
-
* for authenticating a MultiSigLegacy.
|
|
448
|
+
* Deprecated, use [struct MultiSig] instead. The struct that contains signatures and public keys
|
|
449
|
+
* necessary for authenticating a MultiSigLegacy.
|
|
442
450
|
*/
|
|
443
451
|
export interface MultiSigLegacy {
|
|
444
452
|
/** A bitmap that indicates the position of which public key the signature should be authenticated with. */
|
|
@@ -956,6 +964,7 @@ export type SuiEndOfEpochTransactionKind =
|
|
|
956
964
|
| 'AuthenticatorStateCreate'
|
|
957
965
|
| 'RandomnessStateCreate'
|
|
958
966
|
| 'CoinDenyListStateCreate'
|
|
967
|
+
| 'StoreExecutionTimeObservations'
|
|
959
968
|
| {
|
|
960
969
|
ChangeEpoch: SuiChangeEpoch;
|
|
961
970
|
}
|
|
@@ -1466,6 +1475,16 @@ export type SuiTransactionBlockKind =
|
|
|
1466
1475
|
kind: 'ConsensusCommitPrologueV3';
|
|
1467
1476
|
round: string;
|
|
1468
1477
|
sub_dag_index?: string | null;
|
|
1478
|
+
}
|
|
1479
|
+
| {
|
|
1480
|
+
additional_state_digest: string;
|
|
1481
|
+
commit_timestamp_ms: string;
|
|
1482
|
+
consensus_commit_digest: string;
|
|
1483
|
+
consensus_determined_version_assignments: ConsensusDeterminedVersionAssignments;
|
|
1484
|
+
epoch: string;
|
|
1485
|
+
kind: 'ConsensusCommitPrologueV4';
|
|
1486
|
+
round: string;
|
|
1487
|
+
sub_dag_index?: string | null;
|
|
1469
1488
|
};
|
|
1470
1489
|
export interface SuiTransactionBlockResponse {
|
|
1471
1490
|
balanceChanges?: BalanceChange[] | null;
|
|
@@ -1594,9 +1613,16 @@ export interface ZkLoginInputs {
|
|
|
1594
1613
|
issBase64Details: Claim;
|
|
1595
1614
|
proofPoints: ZkLoginProof;
|
|
1596
1615
|
}
|
|
1616
|
+
export type ZkLoginIntentScope = 'TransactionData' | 'PersonalMessage';
|
|
1597
1617
|
/** The struct for zk login proof. */
|
|
1598
1618
|
export interface ZkLoginProof {
|
|
1599
1619
|
a: string[];
|
|
1600
1620
|
b: string[][];
|
|
1601
1621
|
c: string[];
|
|
1602
1622
|
}
|
|
1623
|
+
export interface ZkLoginVerifyResult {
|
|
1624
|
+
/** The errors field captures any verification error */
|
|
1625
|
+
errors: string[];
|
|
1626
|
+
/** The boolean result of the verification. If true, errors should be empty. */
|
|
1627
|
+
success: boolean;
|
|
1628
|
+
}
|
|
@@ -180,6 +180,20 @@ export interface TryMultiGetPastObjectsParams {
|
|
|
180
180
|
/** options for specifying the content to be returned */
|
|
181
181
|
options?: RpcTypes.SuiObjectDataOptions | null | undefined;
|
|
182
182
|
}
|
|
183
|
+
/** Verify a zklogin signature for the given bytes, intent scope and author. */
|
|
184
|
+
export interface VerifyZkLoginSignatureParams {
|
|
185
|
+
/**
|
|
186
|
+
* The Base64 string of bcs bytes for raw transaction data or personal message indicated by
|
|
187
|
+
* intent_scope.
|
|
188
|
+
*/
|
|
189
|
+
bytes: string;
|
|
190
|
+
/** The Base64 string of the zklogin signature to verify. */
|
|
191
|
+
signature: string;
|
|
192
|
+
/** The intent scope, either transaction data or personal message. Used to parse bytes. */
|
|
193
|
+
intentScope: RpcTypes.ZkLoginIntentScope;
|
|
194
|
+
/** The author of the signature. */
|
|
195
|
+
author: string;
|
|
196
|
+
}
|
|
183
197
|
/** Return the total coin balance for all coin type, owned by the address owner. */
|
|
184
198
|
export interface GetAllBalancesParams {
|
|
185
199
|
/** the owner's Sui address */
|
|
@@ -1046,7 +1046,7 @@ type EndOfEpochTransaction {
|
|
|
1046
1046
|
transactions(first: Int, before: String, last: Int, after: String): EndOfEpochTransactionKindConnection!
|
|
1047
1047
|
}
|
|
1048
1048
|
|
|
1049
|
-
union EndOfEpochTransactionKind = ChangeEpochTransaction | AuthenticatorStateCreateTransaction | AuthenticatorStateExpireTransaction | RandomnessStateCreateTransaction | CoinDenyListStateCreateTransaction | BridgeStateCreateTransaction | BridgeCommitteeInitTransaction
|
|
1049
|
+
union EndOfEpochTransactionKind = ChangeEpochTransaction | AuthenticatorStateCreateTransaction | AuthenticatorStateExpireTransaction | RandomnessStateCreateTransaction | CoinDenyListStateCreateTransaction | BridgeStateCreateTransaction | BridgeCommitteeInitTransaction | StoreExecutionTimeObservationsTransaction
|
|
1050
1050
|
|
|
1051
1051
|
type EndOfEpochTransactionKindConnection {
|
|
1052
1052
|
"""
|
|
@@ -2879,7 +2879,7 @@ objects are ones whose
|
|
|
2879
2879
|
|
|
2880
2880
|
- Type matches the `type` filter,
|
|
2881
2881
|
- AND, whose owner matches the `owner` filter,
|
|
2882
|
-
- AND, whose ID is in `objectIds
|
|
2882
|
+
- AND, whose ID is in `objectIds`.
|
|
2883
2883
|
"""
|
|
2884
2884
|
input ObjectFilter {
|
|
2885
2885
|
"""
|
|
@@ -2898,10 +2898,6 @@ input ObjectFilter {
|
|
|
2898
2898
|
Filter for live objects by their IDs.
|
|
2899
2899
|
"""
|
|
2900
2900
|
objectIds: [SuiAddress!]
|
|
2901
|
-
"""
|
|
2902
|
-
Filter for live or potentially historical objects by their ID and version.
|
|
2903
|
-
"""
|
|
2904
|
-
objectKeys: [ObjectKey!]
|
|
2905
2901
|
}
|
|
2906
2902
|
|
|
2907
2903
|
input ObjectKey {
|
|
@@ -3325,6 +3321,10 @@ type Query {
|
|
|
3325
3321
|
"""
|
|
3326
3322
|
transactionBlock(digest: String!): TransactionBlock
|
|
3327
3323
|
"""
|
|
3324
|
+
Fetch a list of objects by their IDs and versions.
|
|
3325
|
+
"""
|
|
3326
|
+
multiGetObjects(keys: [ObjectKey!]!): [Object]!
|
|
3327
|
+
"""
|
|
3328
3328
|
The coin objects that exist in the network.
|
|
3329
3329
|
|
|
3330
3330
|
The type field is a string of the inner type of the coin by which to filter (e.g.
|
|
@@ -3599,6 +3599,10 @@ type ServiceConfig {
|
|
|
3599
3599
|
"""
|
|
3600
3600
|
maxTransactionIds: Int!
|
|
3601
3601
|
"""
|
|
3602
|
+
Maximum number of keys that can be passed to a `multiGetObjects` query.
|
|
3603
|
+
"""
|
|
3604
|
+
maxMultiGetObjectsKeys: Int!
|
|
3605
|
+
"""
|
|
3602
3606
|
Maximum number of candidates to scan when gathering a page of results.
|
|
3603
3607
|
"""
|
|
3604
3608
|
maxScanLimit: Int!
|
|
@@ -3970,6 +3974,13 @@ type StorageFund {
|
|
|
3970
3974
|
nonRefundableBalance: BigInt
|
|
3971
3975
|
}
|
|
3972
3976
|
|
|
3977
|
+
type StoreExecutionTimeObservationsTransaction {
|
|
3978
|
+
"""
|
|
3979
|
+
A workaround to define an empty variant of a GraphQL union.
|
|
3980
|
+
"""
|
|
3981
|
+
_: Boolean
|
|
3982
|
+
}
|
|
3983
|
+
|
|
3973
3984
|
|
|
3974
3985
|
"""
|
|
3975
3986
|
String containing 32B hex-encoded address, with a leading "0x". Leading zeroes can be omitted on input but will always appear in outputs (SuiAddress in output is guaranteed to be 66 characters long).
|
|
@@ -3319,6 +3319,10 @@ const introspection = {
|
|
|
3319
3319
|
{
|
|
3320
3320
|
"kind": "OBJECT",
|
|
3321
3321
|
"name": "RandomnessStateCreateTransaction"
|
|
3322
|
+
},
|
|
3323
|
+
{
|
|
3324
|
+
"kind": "OBJECT",
|
|
3325
|
+
"name": "StoreExecutionTimeObservationsTransaction"
|
|
3322
3326
|
}
|
|
3323
3327
|
]
|
|
3324
3328
|
},
|
|
@@ -8788,19 +8792,6 @@ const introspection = {
|
|
|
8788
8792
|
}
|
|
8789
8793
|
}
|
|
8790
8794
|
}
|
|
8791
|
-
},
|
|
8792
|
-
{
|
|
8793
|
-
"name": "objectKeys",
|
|
8794
|
-
"type": {
|
|
8795
|
-
"kind": "LIST",
|
|
8796
|
-
"ofType": {
|
|
8797
|
-
"kind": "NON_NULL",
|
|
8798
|
-
"ofType": {
|
|
8799
|
-
"kind": "INPUT_OBJECT",
|
|
8800
|
-
"name": "ObjectKey"
|
|
8801
|
-
}
|
|
8802
|
-
}
|
|
8803
|
-
}
|
|
8804
8795
|
}
|
|
8805
8796
|
],
|
|
8806
8797
|
"isOneOf": false
|
|
@@ -10199,6 +10190,38 @@ const introspection = {
|
|
|
10199
10190
|
],
|
|
10200
10191
|
"isDeprecated": false
|
|
10201
10192
|
},
|
|
10193
|
+
{
|
|
10194
|
+
"name": "multiGetObjects",
|
|
10195
|
+
"type": {
|
|
10196
|
+
"kind": "NON_NULL",
|
|
10197
|
+
"ofType": {
|
|
10198
|
+
"kind": "LIST",
|
|
10199
|
+
"ofType": {
|
|
10200
|
+
"kind": "OBJECT",
|
|
10201
|
+
"name": "Object"
|
|
10202
|
+
}
|
|
10203
|
+
}
|
|
10204
|
+
},
|
|
10205
|
+
"args": [
|
|
10206
|
+
{
|
|
10207
|
+
"name": "keys",
|
|
10208
|
+
"type": {
|
|
10209
|
+
"kind": "NON_NULL",
|
|
10210
|
+
"ofType": {
|
|
10211
|
+
"kind": "LIST",
|
|
10212
|
+
"ofType": {
|
|
10213
|
+
"kind": "NON_NULL",
|
|
10214
|
+
"ofType": {
|
|
10215
|
+
"kind": "INPUT_OBJECT",
|
|
10216
|
+
"name": "ObjectKey"
|
|
10217
|
+
}
|
|
10218
|
+
}
|
|
10219
|
+
}
|
|
10220
|
+
}
|
|
10221
|
+
}
|
|
10222
|
+
],
|
|
10223
|
+
"isDeprecated": false
|
|
10224
|
+
},
|
|
10202
10225
|
{
|
|
10203
10226
|
"name": "object",
|
|
10204
10227
|
"type": {
|
|
@@ -10937,6 +10960,18 @@ const introspection = {
|
|
|
10937
10960
|
"args": [],
|
|
10938
10961
|
"isDeprecated": false
|
|
10939
10962
|
},
|
|
10963
|
+
{
|
|
10964
|
+
"name": "maxMultiGetObjectsKeys",
|
|
10965
|
+
"type": {
|
|
10966
|
+
"kind": "NON_NULL",
|
|
10967
|
+
"ofType": {
|
|
10968
|
+
"kind": "SCALAR",
|
|
10969
|
+
"name": "Int"
|
|
10970
|
+
}
|
|
10971
|
+
},
|
|
10972
|
+
"args": [],
|
|
10973
|
+
"isDeprecated": false
|
|
10974
|
+
},
|
|
10940
10975
|
{
|
|
10941
10976
|
"name": "maxOutputNodes",
|
|
10942
10977
|
"type": {
|
|
@@ -12085,6 +12120,22 @@ const introspection = {
|
|
|
12085
12120
|
],
|
|
12086
12121
|
"interfaces": []
|
|
12087
12122
|
},
|
|
12123
|
+
{
|
|
12124
|
+
"kind": "OBJECT",
|
|
12125
|
+
"name": "StoreExecutionTimeObservationsTransaction",
|
|
12126
|
+
"fields": [
|
|
12127
|
+
{
|
|
12128
|
+
"name": "_",
|
|
12129
|
+
"type": {
|
|
12130
|
+
"kind": "SCALAR",
|
|
12131
|
+
"name": "Boolean"
|
|
12132
|
+
},
|
|
12133
|
+
"args": [],
|
|
12134
|
+
"isDeprecated": false
|
|
12135
|
+
}
|
|
12136
|
+
],
|
|
12137
|
+
"interfaces": []
|
|
12138
|
+
},
|
|
12088
12139
|
{
|
|
12089
12140
|
"kind": "SCALAR",
|
|
12090
12141
|
"name": "String"
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { parseStructTag } from '../../utils/sui-types.js';
|
|
5
5
|
import type { BuildTransactionOptions } from '../json-rpc-resolver.js';
|
|
6
6
|
import type { TransactionDataBuilder } from '../TransactionData.js';
|
|
7
|
-
import type { NamedPackagesPluginCache
|
|
8
|
-
import {
|
|
7
|
+
import type { NamedPackagesPluginCache } from './utils.js';
|
|
8
|
+
import {
|
|
9
|
+
batch,
|
|
10
|
+
findNamesInTransaction,
|
|
11
|
+
getFirstLevelNamedTypes,
|
|
12
|
+
populateNamedTypesFromCache,
|
|
13
|
+
replaceNames,
|
|
14
|
+
} from './utils.js';
|
|
9
15
|
|
|
10
16
|
export type NamedPackagesPluginOptions = {
|
|
11
17
|
/**
|
|
12
|
-
* The
|
|
13
|
-
* The endpoint should be the GraphQL endpoint of the network you are targeting.
|
|
14
|
-
* For non-mainnet networks, if the plugin doesn't work as expected, you need to validate that the
|
|
15
|
-
* RPC provider has support for the `packageByName` and `typeByName` queries (using external resolver).
|
|
18
|
+
* The URL of the MVR API to use for resolving names.
|
|
16
19
|
*/
|
|
17
|
-
|
|
20
|
+
url: string;
|
|
18
21
|
/**
|
|
19
22
|
* The number of names to resolve in each batch request.
|
|
20
23
|
* Needs to be calculated based on the GraphQL query limits.
|
|
@@ -24,6 +27,8 @@ export type NamedPackagesPluginOptions = {
|
|
|
24
27
|
* Local overrides for the resolution plugin. Pass this to pre-populate
|
|
25
28
|
* the cache with known packages / types (especially useful for local or CI testing).
|
|
26
29
|
*
|
|
30
|
+
* The type cache expects ONLY first-level types to ensure the cache is more composable.
|
|
31
|
+
*
|
|
27
32
|
* Expected format example:
|
|
28
33
|
* {
|
|
29
34
|
* packages: {
|
|
@@ -53,77 +58,128 @@ export type NamedPackagesPluginOptions = {
|
|
|
53
58
|
* You can also define `overrides` to pre-populate name resolutions locally (removes the GraphQL request).
|
|
54
59
|
*/
|
|
55
60
|
export const namedPackagesPlugin = ({
|
|
56
|
-
|
|
57
|
-
pageSize =
|
|
61
|
+
url,
|
|
62
|
+
pageSize = 50,
|
|
58
63
|
overrides = { packages: {}, types: {} },
|
|
59
64
|
}: NamedPackagesPluginOptions) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
// validate that types are first-level only.
|
|
66
|
+
Object.keys(overrides.types).forEach((type) => {
|
|
67
|
+
if (parseStructTag(type).typeParams.length > 0)
|
|
68
|
+
throw new Error(
|
|
69
|
+
'Type overrides must be first-level only. If you want to supply generic types, just pass each type individually.',
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const cache = overrides;
|
|
64
74
|
|
|
65
75
|
return async (
|
|
66
76
|
transactionData: TransactionDataBuilder,
|
|
67
77
|
_buildOptions: BuildTransactionOptions,
|
|
68
78
|
next: () => Promise<void>,
|
|
69
79
|
) => {
|
|
70
|
-
const names =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const names = findNamesInTransaction(transactionData);
|
|
81
|
+
|
|
82
|
+
const [packages, types] = await Promise.all([
|
|
83
|
+
resolvePackages(
|
|
84
|
+
names.packages.filter((x) => !cache.packages[x]),
|
|
85
|
+
url,
|
|
86
|
+
pageSize,
|
|
87
|
+
),
|
|
88
|
+
resolveTypes(
|
|
89
|
+
[...getFirstLevelNamedTypes(names.types)].filter((x) => !cache.types[x]),
|
|
90
|
+
url,
|
|
91
|
+
pageSize,
|
|
92
|
+
),
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
// save first-level mappings to cache.
|
|
96
|
+
Object.assign(cache.packages, packages);
|
|
97
|
+
Object.assign(cache.types, types);
|
|
98
|
+
|
|
99
|
+
const composedTypes = populateNamedTypesFromCache(names.types, cache.types);
|
|
100
|
+
|
|
101
|
+
// when replacing names, we also need to replace the "composed" types collected above.
|
|
102
|
+
replaceNames(transactionData, {
|
|
103
|
+
packages: { ...cache.packages },
|
|
104
|
+
// we include the "composed" type cache too.
|
|
105
|
+
types: composedTypes,
|
|
83
106
|
});
|
|
84
107
|
|
|
85
|
-
replaceNames(transactionData, cache);
|
|
86
|
-
|
|
87
108
|
await next();
|
|
88
109
|
};
|
|
89
110
|
|
|
90
|
-
async function
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
async function resolvePackages(packages: string[], apiUrl: string, pageSize: number) {
|
|
112
|
+
if (packages.length === 0) return {};
|
|
113
|
+
|
|
114
|
+
const batches = batch(packages, pageSize);
|
|
115
|
+
const results: Record<string, string> = {};
|
|
116
|
+
|
|
117
|
+
await Promise.all(
|
|
118
|
+
batches.map(async (batch) => {
|
|
119
|
+
const response = await fetch(`${apiUrl}/v1/resolution/bulk`, {
|
|
120
|
+
method: 'POST',
|
|
121
|
+
headers: { 'Content-Type': 'application/json' },
|
|
122
|
+
body: JSON.stringify({
|
|
123
|
+
names: batch,
|
|
124
|
+
}),
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
if (!response.ok) {
|
|
128
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
129
|
+
throw new Error(`Failed to resolve packages: ${errorBody?.message}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const data = await response.json();
|
|
133
|
+
|
|
134
|
+
if (!data?.resolution) return;
|
|
135
|
+
|
|
136
|
+
for (const pkg of Object.keys(data?.resolution)) {
|
|
137
|
+
const pkgData = data.resolution[pkg]?.package_id;
|
|
112
138
|
|
|
113
|
-
|
|
139
|
+
if (!pkgData) continue;
|
|
114
140
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
141
|
+
results[pkg] = pkgData;
|
|
142
|
+
}
|
|
143
|
+
}),
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
return results;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function resolveTypes(types: string[], apiUrl: string, pageSize: number) {
|
|
150
|
+
if (types.length === 0) return {};
|
|
151
|
+
|
|
152
|
+
const batches = batch(types, pageSize);
|
|
153
|
+
const results: Record<string, string> = {};
|
|
154
|
+
|
|
155
|
+
await Promise.all(
|
|
156
|
+
batches.map(async (batch) => {
|
|
157
|
+
const response = await fetch(`${apiUrl}/v1/struct-definition/bulk`, {
|
|
158
|
+
method: 'POST',
|
|
159
|
+
headers: { 'Content-Type': 'application/json' },
|
|
160
|
+
body: JSON.stringify({
|
|
161
|
+
types: batch,
|
|
162
|
+
}),
|
|
163
|
+
});
|
|
120
164
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
165
|
+
if (!response.ok) {
|
|
166
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
167
|
+
throw new Error(`Failed to resolve types: ${errorBody?.message}`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const data = await response.json();
|
|
171
|
+
|
|
172
|
+
if (!data?.resolution) return;
|
|
173
|
+
|
|
174
|
+
for (const type of Object.keys(data?.resolution)) {
|
|
175
|
+
const typeData = data.resolution[type]?.type_tag;
|
|
176
|
+
if (!typeData) continue;
|
|
177
|
+
|
|
178
|
+
results[type] = typeData;
|
|
179
|
+
}
|
|
180
|
+
}),
|
|
181
|
+
);
|
|
124
182
|
|
|
125
183
|
return results;
|
|
126
184
|
}
|
|
127
185
|
};
|
|
128
|
-
|
|
129
|
-
const gqlQueryKey = (idx: number) => `key_${idx}`;
|