@0xobelisk/sui-client 1.0.2 → 1.0.4

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.
@@ -0,0 +1,63 @@
1
+ import { NetworkType } from 'src/types';
2
+
3
+ export interface NetworkConfig {
4
+ fullNode: string;
5
+ graphql?: string;
6
+ network: string;
7
+ txExplorer: string;
8
+ accountExplorer: string;
9
+ explorer: string;
10
+ }
11
+
12
+ export const getDefaultURL = (
13
+ networkType: NetworkType = 'testnet'
14
+ ): NetworkConfig => {
15
+ switch (networkType) {
16
+ case 'localnet':
17
+ return {
18
+ fullNode: 'http://127.0.0.1:9000',
19
+ graphql: 'http://127.0.0.1:9125',
20
+ network: 'localnet',
21
+ txExplorer:
22
+ 'https://explorer.polymedia.app/txblock/:txHash?network=local',
23
+ accountExplorer:
24
+ 'https://explorer.polymedia.app/address/:address?network=local',
25
+ explorer: 'https://explorer.polymedia.app?network=local',
26
+ };
27
+ case 'devnet':
28
+ return {
29
+ fullNode: 'https://fullnode.devnet.sui.io:443',
30
+ network: 'devnet',
31
+ txExplorer: 'https://suiscan.xyz/devnet/tx/:txHash',
32
+ accountExplorer: 'https://suiscan.xyz/devnet/address/:address',
33
+ explorer: 'https://suiscan.xyz/devnet',
34
+ };
35
+ case 'testnet':
36
+ return {
37
+ fullNode: 'https://fullnode.testnet.sui.io:443',
38
+ graphql: 'https://sui-testnet.mystenlabs.com/graphql',
39
+ network: 'testnet',
40
+ txExplorer: 'https://suiscan.xyz/testnet/tx/:txHash',
41
+ accountExplorer: 'https://suiscan.xyz/testnet/address/:address',
42
+ explorer: 'https://suiscan.xyz/testnet',
43
+ };
44
+ case 'mainnet':
45
+ return {
46
+ fullNode: 'https://fullnode.mainnet.sui.io:443',
47
+ graphql: 'https://sui-mainnet.mystenlabs.com/graphql',
48
+ network: 'mainnet',
49
+ txExplorer: 'https://suiscan.xyz/mainnet/tx/:txHash',
50
+ accountExplorer: 'https://suiscan.xyz/mainnet/address/:address',
51
+ explorer: 'https://suiscan.xyz/mainnet',
52
+ };
53
+ default:
54
+ return {
55
+ fullNode: 'https://fullnode.testnet.sui.io:443',
56
+ graphql: 'https://sui-testnet.mystenlabs.com/graphql',
57
+ network: 'testnet',
58
+ txExplorer: 'https://suiscan.xyz/testnet/tx/:txHash',
59
+ accountExplorer: 'https://suiscan.xyz/testnet/address/:address',
60
+ explorer: 'https://suiscan.xyz/testnet',
61
+ };
62
+ }
63
+ };
@@ -1 +1,3 @@
1
1
  export { SuiInteractor } from './suiInteractor';
2
+ export { getDefaultURL } from './defaultConfig';
3
+ export type { NetworkConfig } from './defaultConfig';
@@ -76,6 +76,32 @@ export class SuiInteractor {
76
76
  throw new Error('Failed to send transaction with all fullnodes');
77
77
  }
78
78
 
79
+ async waitForTransaction({
80
+ digest,
81
+ timeout = 60 * 1000,
82
+ pollInterval = 2 * 1000,
83
+ }: {
84
+ digest: string;
85
+ timeout?: number;
86
+ pollInterval?: number;
87
+ }) {
88
+ for (const clientIdx in this.clients) {
89
+ try {
90
+ return await this.clients[clientIdx].waitForTransaction({
91
+ digest,
92
+ timeout,
93
+ pollInterval,
94
+ });
95
+ } catch (err) {
96
+ console.warn(
97
+ `Failed to wait for transaction with fullnode ${this.fullNodes[clientIdx]}: ${err}`
98
+ );
99
+ await delay(2000);
100
+ }
101
+ }
102
+ throw new Error('Failed to wait for transaction with all fullnodes');
103
+ }
104
+
79
105
  async getObjects(
80
106
  ids: string[],
81
107
  options?: SuiObjectDataOptions
@@ -17,6 +17,8 @@ import type {
17
17
  DisplayFieldsResponse,
18
18
  SuiMoveNormalizedType,
19
19
  MoveStruct,
20
+ SuiMoveNormalizedEnum,
21
+ SuiMoveNormalizedStruct,
20
22
  } from '@mysten/sui/client';
21
23
  import { SuiTx } from '../libs/suiTxBuilder';
22
24
 
@@ -118,24 +120,30 @@ export type MapMessageQuery = Record<string, ContractQuery>;
118
120
  export type MapMoudleFuncTx = Record<string, MapMessageTx>;
119
121
  export type MapMoudleFuncQuery = Record<string, MapMessageQuery>;
120
122
 
121
- export type MoveStructValueType = {
122
- fields: {
123
- type: SuiMoveNormalizedType;
124
- name: string;
125
- }[];
126
- abilities: {
127
- abilities: string[];
128
- };
129
- typeParameters: {
130
- constraints: {
131
- abilities: string[];
132
- };
133
- isPhantom: boolean;
134
- }[];
135
- };
123
+ // export type MoveStructValueType = {
124
+ // fields: {
125
+ // type: SuiMoveNormalizedType;
126
+ // name: string;
127
+ // }[];
128
+ // abilities: {
129
+ // abilities: string[];
130
+ // };
131
+ // typeParameters: {
132
+ // constraints: {
133
+ // abilities: string[];
134
+ // };
135
+ // isPhantom: boolean;
136
+ // }[];
137
+ // };
136
138
  export type MoveStructType = {
137
139
  objectId: string;
138
- objectType: MoveStructValueType;
140
+ objectType: SuiMoveNormalizedStruct;
141
+ objectName: string;
142
+ };
143
+
144
+ export type MoveEnumType = {
145
+ objectId: string;
146
+ objectType: SuiMoveNormalizedEnum;
139
147
  objectName: string;
140
148
  };
141
149