@exodus/sui-api 1.0.1 → 1.0.2
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 +10 -0
- package/package.json +2 -2
- package/src/vendors/client/client.js +2 -68
- package/src/vendors/client/errors.js +1 -1
- package/src/vendors/client/http-transport.js +0 -37
- package/src/vendors/experimental/core.js +0 -82
- package/src/vendors/experimental/mvr.js +1 -1
- package/src/vendors/experimental/transports/jsonRPC.js +0 -398
- package/src/vendors/transactions/Commands.js +1 -7
- package/src/vendors/transactions/Transaction.js +0 -14
- package/src/vendors/transactions/data/internal.js +0 -14
- package/src/vendors/transactions/data/v1.js +2 -293
- package/src/vendors/transactions/plugins/NamedPackagesPlugin.js +1 -1
- package/src/vendors/transactions/resolve.js +1 -1
- package/src/vendors/transactions/utils.js +1 -38
- package/src/vendors/valibot.js +357 -7285
- package/src/vendors/client/rpc-websocket-client.js +0 -178
- package/src/vendors/experimental/errors.js +0 -32
- package/src/vendors/experimental/index.js +0 -5
- package/src/vendors/experimental/transports/utils.js +0 -90
- package/src/vendors/transactions/Arguments.js +0 -22
- package/src/vendors/transactions/ObjectCache.js +0 -272
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.2](https://github.com/ExodusMovement/assets/compare/@exodus/sui-api@1.0.1...@exodus/sui-api@1.0.2) (2025-09-09)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* fix: drop getObject from sui vendors (#6427)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
6
16
|
## [1.0.1](https://github.com/ExodusMovement/assets/compare/@exodus/sui-api@1.0.0...@exodus/sui-api@1.0.1) (2025-08-29)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @exodus/sui-api
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/sui-api",
|
|
3
3
|
"packageManager": "yarn@4.3.1",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"description": "Transaction monitors, RPC with the blockchain node, and other networking code for Sui",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "src/index.js",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"type": "git",
|
|
50
50
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "710a76069cae018c0b6dd6f50d0070e5c093937e"
|
|
53
53
|
}
|
|
@@ -19,19 +19,10 @@ const {
|
|
|
19
19
|
normalizeSuiObjectId,
|
|
20
20
|
} = vendorLib.utils
|
|
21
21
|
|
|
22
|
-
const { isValidNamedPackage
|
|
22
|
+
const { isValidNamedPackage } = vendorLib.utils
|
|
23
23
|
|
|
24
|
-
class Signer {
|
|
25
|
-
toSuiAddress() {
|
|
26
|
-
return this.getPublicKey().toSuiAddress()
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
24
|
const SUI_CLIENT_BRAND = Symbol.for('@mysten/SuiClient')
|
|
30
25
|
|
|
31
|
-
function isSuiClient(client) {
|
|
32
|
-
return typeof client === 'object' && client !== null && client[SUI_CLIENT_BRAND] === true
|
|
33
|
-
}
|
|
34
|
-
|
|
35
26
|
class SuiClient extends Experimental_BaseClient {
|
|
36
27
|
/**
|
|
37
28
|
* Establish a connection to a Sui RPC endpoint
|
|
@@ -585,34 +576,6 @@ class SuiClient extends Experimental_BaseClient {
|
|
|
585
576
|
})
|
|
586
577
|
}
|
|
587
578
|
|
|
588
|
-
/**
|
|
589
|
-
* Subscribe to get notifications whenever an event matching the filter occurs
|
|
590
|
-
*
|
|
591
|
-
* @deprecated
|
|
592
|
-
*/
|
|
593
|
-
async subscribeEvent(input) {
|
|
594
|
-
return this.transport.subscribe({
|
|
595
|
-
method: 'suix_subscribeEvent',
|
|
596
|
-
unsubscribe: 'suix_unsubscribeEvent',
|
|
597
|
-
params: [input.filter],
|
|
598
|
-
onMessage: input.onMessage,
|
|
599
|
-
signal: input.signal,
|
|
600
|
-
})
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
* @deprecated
|
|
605
|
-
*/
|
|
606
|
-
async subscribeTransaction(input) {
|
|
607
|
-
return this.transport.subscribe({
|
|
608
|
-
method: 'suix_subscribeTransaction',
|
|
609
|
-
unsubscribe: 'suix_unsubscribeTransaction',
|
|
610
|
-
params: [input.filter],
|
|
611
|
-
onMessage: input.onMessage,
|
|
612
|
-
signal: input.signal,
|
|
613
|
-
})
|
|
614
|
-
}
|
|
615
|
-
|
|
616
579
|
/**
|
|
617
580
|
* Runs the transaction block in dev-inspect mode. Which allows for nearly any
|
|
618
581
|
* transaction (or Move call) with any arguments. Detailed results are
|
|
@@ -812,27 +775,6 @@ class SuiClient extends Experimental_BaseClient {
|
|
|
812
775
|
return toHex(bytes.slice(0, 4))
|
|
813
776
|
}
|
|
814
777
|
|
|
815
|
-
async resolveNameServiceAddress(input) {
|
|
816
|
-
return await this.transport.request({
|
|
817
|
-
method: 'suix_resolveNameServiceAddress',
|
|
818
|
-
params: [input.name],
|
|
819
|
-
signal: input.signal,
|
|
820
|
-
})
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
async resolveNameServiceNames({ format = 'dot', ...input }) {
|
|
824
|
-
const { nextCursor, hasNextPage, data } = await this.transport.request({
|
|
825
|
-
method: 'suix_resolveNameServiceNames',
|
|
826
|
-
params: [input.address, input.cursor, input.limit],
|
|
827
|
-
signal: input.signal,
|
|
828
|
-
})
|
|
829
|
-
return {
|
|
830
|
-
hasNextPage,
|
|
831
|
-
nextCursor,
|
|
832
|
-
data: data.map((name) => normalizeSuiNSName(name, format)),
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
|
|
836
778
|
async getProtocolConfig(input) {
|
|
837
779
|
return await this.transport.request({
|
|
838
780
|
method: 'sui_getProtocolConfig',
|
|
@@ -841,14 +783,6 @@ class SuiClient extends Experimental_BaseClient {
|
|
|
841
783
|
})
|
|
842
784
|
}
|
|
843
785
|
|
|
844
|
-
async verifyZkLoginSignature(input) {
|
|
845
|
-
return await this.transport.request({
|
|
846
|
-
method: 'sui_verifyZkLoginSignature',
|
|
847
|
-
params: [input.bytes, input.signature, input.intentScope, input.author],
|
|
848
|
-
signal: input.signal,
|
|
849
|
-
})
|
|
850
|
-
}
|
|
851
|
-
|
|
852
786
|
/**
|
|
853
787
|
* Wait for a transaction block result to be available over the API.
|
|
854
788
|
* This can be used in conjunction with `executeTransactionBlock` to wait for the transaction to
|
|
@@ -887,5 +821,5 @@ class SuiClient extends Experimental_BaseClient {
|
|
|
887
821
|
}
|
|
888
822
|
}
|
|
889
823
|
}
|
|
890
|
-
export {
|
|
824
|
+
export { SuiClient }
|
|
891
825
|
// # sourceMappingURL=client.js.map
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { JsonRpcError, SuiHTTPStatusError } from './errors.js'
|
|
5
|
-
import { WebsocketClient } from './rpc-websocket-client.js'
|
|
6
5
|
|
|
7
6
|
export const PACKAGE_VERSION = '1.36.1'
|
|
8
7
|
export const TARGETED_RPC_VERSION = '1.55.0'
|
|
@@ -14,7 +13,6 @@ export const TARGETED_RPC_VERSION = '1.55.0'
|
|
|
14
13
|
export class SuiHTTPTransport {
|
|
15
14
|
#requestId = 0
|
|
16
15
|
#options
|
|
17
|
-
#websocketClient
|
|
18
16
|
|
|
19
17
|
constructor(options) {
|
|
20
18
|
this.#options = options
|
|
@@ -32,28 +30,6 @@ export class SuiHTTPTransport {
|
|
|
32
30
|
return fetchFn(input, init)
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
#getWebsocketClient() {
|
|
36
|
-
if (!this.#websocketClient) {
|
|
37
|
-
// eslint-disable-next-line no-undef
|
|
38
|
-
const WebSocketConstructor = this.#options.WebSocketConstructor ?? WebSocket
|
|
39
|
-
if (!WebSocketConstructor) {
|
|
40
|
-
throw new Error(
|
|
41
|
-
'The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.'
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
this.#websocketClient = new WebsocketClient(
|
|
46
|
-
this.#options.websocket?.url ?? this.#options.url,
|
|
47
|
-
{
|
|
48
|
-
WebSocketConstructor,
|
|
49
|
-
...this.#options.websocket,
|
|
50
|
-
}
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return this.#websocketClient
|
|
55
|
-
}
|
|
56
|
-
|
|
57
33
|
async request(input) {
|
|
58
34
|
this.#requestId += 1
|
|
59
35
|
|
|
@@ -92,17 +68,4 @@ export class SuiHTTPTransport {
|
|
|
92
68
|
|
|
93
69
|
return data.result
|
|
94
70
|
}
|
|
95
|
-
|
|
96
|
-
async subscribe(input) {
|
|
97
|
-
const unsubscribe = await this.#getWebsocketClient().subscribe(input)
|
|
98
|
-
|
|
99
|
-
if (input.signal) {
|
|
100
|
-
input.signal.throwIfAborted()
|
|
101
|
-
input.signal.addEventListener('abort', () => {
|
|
102
|
-
unsubscribe()
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return async () => !!(await unsubscribe())
|
|
107
|
-
}
|
|
108
71
|
}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
/* eslint-disable camelcase */
|
|
2
2
|
|
|
3
|
-
import { vendorLib } from '@exodus/sui-lib'
|
|
4
|
-
|
|
5
3
|
import { Experimental_BaseClient } from './client.js'
|
|
6
4
|
import { MvrClient } from './mvr.js'
|
|
7
5
|
|
|
8
|
-
const { TypeTagSerializer } = vendorLib.bcs
|
|
9
|
-
const { deriveDynamicFieldID, normalizeStructTag, parseStructTag, SUI_ADDRESS_LENGTH } =
|
|
10
|
-
vendorLib.utils
|
|
11
|
-
|
|
12
6
|
const DEFAULT_MVR_URLS = {
|
|
13
7
|
mainnet: 'https://mainnet.mvr.mystenlabs.com',
|
|
14
8
|
testnet: 'https://testnet.mvr.mystenlabs.com',
|
|
@@ -25,81 +19,5 @@ class Experimental_CoreClient extends Experimental_BaseClient {
|
|
|
25
19
|
overrides: options.mvr?.overrides,
|
|
26
20
|
})
|
|
27
21
|
}
|
|
28
|
-
|
|
29
|
-
async getObject(options) {
|
|
30
|
-
const { objectId } = options
|
|
31
|
-
const {
|
|
32
|
-
objects: [result],
|
|
33
|
-
} = await this.getObjects({ objectIds: [objectId], signal: options.signal })
|
|
34
|
-
if (result instanceof Error) {
|
|
35
|
-
throw result
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return { object: result }
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async getDynamicField(options) {
|
|
42
|
-
const fieldId = deriveDynamicFieldID(
|
|
43
|
-
options.parentId,
|
|
44
|
-
TypeTagSerializer.parseFromStr(options.name.type),
|
|
45
|
-
options.name.bcs
|
|
46
|
-
)
|
|
47
|
-
const {
|
|
48
|
-
objects: [fieldObject],
|
|
49
|
-
} = await this.getObjects({
|
|
50
|
-
objectIds: [fieldId],
|
|
51
|
-
signal: options.signal,
|
|
52
|
-
})
|
|
53
|
-
if (fieldObject instanceof Error) {
|
|
54
|
-
throw fieldObject
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const fieldType = parseStructTag(fieldObject.type)
|
|
58
|
-
const content = await fieldObject.content
|
|
59
|
-
return {
|
|
60
|
-
dynamicField: {
|
|
61
|
-
id: fieldObject.id,
|
|
62
|
-
digest: fieldObject.digest,
|
|
63
|
-
version: fieldObject.version,
|
|
64
|
-
type: fieldObject.type,
|
|
65
|
-
name: {
|
|
66
|
-
type:
|
|
67
|
-
typeof fieldType.typeParams[0] === 'string'
|
|
68
|
-
? fieldType.typeParams[0]
|
|
69
|
-
: normalizeStructTag(fieldType.typeParams[0]),
|
|
70
|
-
bcs: options.name.bcs,
|
|
71
|
-
},
|
|
72
|
-
value: {
|
|
73
|
-
type:
|
|
74
|
-
typeof fieldType.typeParams[1] === 'string'
|
|
75
|
-
? fieldType.typeParams[1]
|
|
76
|
-
: normalizeStructTag(fieldType.typeParams[1]),
|
|
77
|
-
bcs: content.slice(SUI_ADDRESS_LENGTH + options.name.bcs.length),
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async waitForTransaction({ signal, timeout = 60 * 1e3, ...input }) {
|
|
84
|
-
const abortSignal = signal
|
|
85
|
-
? AbortSignal.any([AbortSignal.timeout(timeout), signal])
|
|
86
|
-
: AbortSignal.timeout(timeout)
|
|
87
|
-
// eslint-disable-next-line promise/param-names
|
|
88
|
-
const abortPromise = new Promise((_, reject) => {
|
|
89
|
-
abortSignal.addEventListener('abort', () => reject(abortSignal.reason))
|
|
90
|
-
})
|
|
91
|
-
abortPromise.catch(() => {})
|
|
92
|
-
while (true) {
|
|
93
|
-
abortSignal.throwIfAborted()
|
|
94
|
-
try {
|
|
95
|
-
return await this.getTransaction({
|
|
96
|
-
...input,
|
|
97
|
-
signal: abortSignal,
|
|
98
|
-
})
|
|
99
|
-
} catch {
|
|
100
|
-
await Promise.race([new Promise((resolve) => setTimeout(resolve, 2e3)), abortPromise])
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
22
|
}
|
|
105
23
|
export { Experimental_CoreClient }
|
|
@@ -439,5 +439,5 @@ function getNamesFromTypeList(types) {
|
|
|
439
439
|
return names
|
|
440
440
|
}
|
|
441
441
|
|
|
442
|
-
export { MvrClient,
|
|
442
|
+
export { MvrClient, findNamesInTransaction, hasMvrName, replaceNames }
|
|
443
443
|
// # sourceMappingURL=mvr.js.map
|