@msafe/sui3-sdk 0.0.65 → 0.0.66

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.
@@ -1,4 +1,4 @@
1
- import { appHelpers } from '@msafe/iota-app-store';
1
+ import { appHelpers } from '@msafe/sui-app-store';
2
2
  import {
3
3
  CoinTransferIntention,
4
4
  IGasOption,
@@ -14,11 +14,12 @@ import {
14
14
  TransactionType,
15
15
  buildRejectTxb,
16
16
  isSameAddress,
17
- } from '@msafe/iota-utils';
18
- import { IotaObjectData, IotaObjectResponse } from '@iota/iota-sdk/client';
19
- import { SerializedSignature } from '@iota/iota-sdk/cryptography';
20
- import { TransactionBlock } from '@iota/iota-sdk/transactions';
21
- import { fromHEX, normalizeStructTag, toHEX } from '@iota/iota-sdk/utils';
17
+ } from '@msafe/sui3-utils';
18
+ import { SuiObjectData, SuiObjectResponse } from '@mysten/sui.js/client';
19
+ import { SerializedSignature } from '@mysten/sui.js/cryptography';
20
+ import { TransactionBlock } from '@mysten/sui.js/transactions';
21
+ import { fromHEX, normalizeStructTag, toHEX } from '@mysten/sui.js/utils';
22
+ import { SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN } from '@mysten/wallet-standard';
22
23
 
23
24
  import { MSafeGlobals } from '@/globals/MSafeGlobals';
24
25
  import { Simulator } from '@/simulate/simulator';
@@ -44,7 +45,7 @@ export class MSafeAccount {
44
45
  ownersWithWeight: info.owners,
45
46
  creationNonce: info.creationNonce,
46
47
  });
47
- this.coinHelper = new CoinHelper(this.client);
48
+ this.coinHelper = new CoinHelper(this.suiClient);
48
49
  this.simulator = new Simulator(globals);
49
50
  }
50
51
 
@@ -57,9 +58,9 @@ export class MSafeAccount {
57
58
  }
58
59
 
59
60
  async ownedCoins(): Promise<OwnedCoin[]> {
60
- const balances = await this.client.getAllBalances({ owner: this.address });
61
+ const balances = await this.suiClient.getAllBalances({ owner: this.address });
61
62
  return Promise.all(
62
- balances.map(async (balance: any): Promise<OwnedCoin> => {
63
+ balances.map(async (balance): Promise<OwnedCoin> => {
63
64
  const meta = await this.coinHelper.getCoinMeta(balance.coinType);
64
65
  const unlockedBalance = balance.lockedBalance.number
65
66
  ? BigInt(balance.totalBalance) - BigInt(balance.lockedBalance.number)
@@ -74,12 +75,12 @@ export class MSafeAccount {
74
75
  );
75
76
  }
76
77
 
77
- async ownedObjects(options?: BatchObjectOptions): Promise<IotaObjectData[]> {
78
+ async ownedObjects(options?: BatchObjectOptions): Promise<SuiObjectData[]> {
78
79
  const filterCoinObjectOptions = {
79
- filter: (objRes: IotaObjectResponse) => !objRes?.data?.type?.startsWith('0x2::coin::Coin'),
80
+ filter: (objRes: SuiObjectResponse) => !objRes?.data?.type?.startsWith('0x2::coin::Coin'),
80
81
  ...options,
81
82
  };
82
- return getAllOwnedObjects(this.client, this.address, filterCoinObjectOptions);
83
+ return getAllOwnedObjects(this.suiClient, this.address, filterCoinObjectOptions);
83
84
  }
84
85
 
85
86
  async pendingTransaction(): Promise<PendingTx | undefined> {
@@ -135,16 +136,17 @@ export class MSafeAccount {
135
136
  if (!appHelper) {
136
137
  throw new Error(`Can't find app helper for application ${request.application}`);
137
138
  }
139
+ // const config = getMSafeConfig(env, options);
138
140
  const txb = await appHelper.build({
139
141
  network: this.globals.config.network,
140
142
  intentionData: request.intention,
141
143
  txType: request.txType,
142
144
  txSubType: request.txSubType,
143
- client: this.globals.client,
145
+ clientUrl: this.globals.config.suiClient.url,
144
146
  account: {
145
147
  address: this.address,
146
148
  publicKey: fromHEX(this.address),
147
- chains: [],
149
+ chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
148
150
  features: [],
149
151
  },
150
152
  });
@@ -182,19 +184,19 @@ export class MSafeAccount {
182
184
  intentionData: input.intention,
183
185
  txType: input.txType,
184
186
  txSubType: input.txSubType,
185
- client: this.globals.client,
187
+ clientUrl: this.globals.config.suiClient.url,
186
188
  account: {
187
189
  address: this.address,
188
190
  publicKey: fromHEX(this.address),
189
- chains: [],
191
+ chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
190
192
  features: [],
191
193
  },
192
194
  });
193
195
  txb.setGasPrice(input.gasPrice);
194
196
  txb.setGasBudget(input.gasBudget);
195
197
  txb.setSender(this.address);
196
- const payload = await txb.build({ client: this.globals.client });
197
- const digest = await txb.getDigest({ client: this.globals.client });
198
+ const payload = await txb.build({ client: this.globals.suiClient });
199
+ const digest = await txb.getDigest({ client: this.globals.suiClient });
198
200
 
199
201
  const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
200
202
 
@@ -310,8 +312,8 @@ export class MSafeAccount {
310
312
  }
311
313
 
312
314
  const rejectTxb = buildRejectTxb(this.address);
313
- const digest = await rejectTxb.getDigest({ client: this.client });
314
- const payload = await rejectTxb.build({ client: this.client });
315
+ const digest = await rejectTxb.getDigest({ client: this.suiClient });
316
+ const payload = await rejectTxb.build({ client: this.suiClient });
315
317
  const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
316
318
  return this.backend.rejectCurrentTx({
317
319
  msafeAddress: this.address,
@@ -332,11 +334,11 @@ export class MSafeAccount {
332
334
  intentionData: intention.intention,
333
335
  txType: intention.txType as TransactionType,
334
336
  txSubType: intention.txSubType,
335
- client: this.globals.client,
337
+ clientUrl: this.globals.config.suiClient.url,
336
338
  account: {
337
339
  address: this.address,
338
340
  publicKey: fromHEX(this.address),
339
- chains: [],
341
+ chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
340
342
  features: [],
341
343
  },
342
344
  });
@@ -375,7 +377,7 @@ export class MSafeAccount {
375
377
  }
376
378
  }
377
379
  const multiSignature = this.multiSig.combinePartialSignatures(sortedSigs);
378
- return this.client.executeTransactionBlock({
380
+ return this.suiClient.executeTransactionBlock({
379
381
  transactionBlock: HexToUint8Array(payload),
380
382
  signature: multiSignature,
381
383
  options: { showEffects: true, showEvents: true },
@@ -420,7 +422,7 @@ export class MSafeAccount {
420
422
  return this.globals.wallet.address();
421
423
  }
422
424
 
423
- private get client() {
424
- return this.globals.client;
425
+ private get suiClient() {
426
+ return this.globals.suiClient;
425
427
  }
426
428
  }
@@ -5,7 +5,7 @@ import {
5
5
  JWTToken,
6
6
  SigningMessageHelper,
7
7
  UserMSafeStatus,
8
- } from '@msafe/iota-utils';
8
+ } from '@msafe/sui3-utils';
9
9
 
10
10
  import { AddressBookSDK } from '@/core/AddressBookSDK';
11
11
  import { CreateHelper } from '@/core/CreateHelper';
@@ -1,6 +1,6 @@
1
- import { isSameAddress } from '@msafe/iota-utils';
2
- import { PublicKey } from '@iota/iota-sdk/cryptography';
3
- import { normalizeIotaAddress } from '@iota/iota-sdk/utils';
1
+ import { isSameAddress } from '@msafe/sui3-utils';
2
+ import { PublicKey } from '@mysten/sui.js/cryptography';
3
+ import { normalizeSuiAddress } from '@mysten/sui.js/utils';
4
4
 
5
5
  import { MSafeGlobals } from '@/globals/MSafeGlobals';
6
6
  import { getPublicKeyFromChain } from '@/utils/sui';
@@ -67,10 +67,10 @@ export class PublicKeyHelper {
67
67
  }
68
68
 
69
69
  addPublicKey(address: string, publicKey: PublicKey) {
70
- if (!isSameAddress(address, publicKey.toIotaAddress())) {
70
+ if (!isSameAddress(address, publicKey.toSuiAddress())) {
71
71
  throw new Error('Invalid public key');
72
72
  }
73
- this.knownPublicKeys.set(normalizeIotaAddress(address), publicKey);
73
+ this.knownPublicKeys.set(normalizeSuiAddress(address), publicKey);
74
74
  }
75
75
 
76
76
  private async _getPublicKey(address: string) {
@@ -95,6 +95,6 @@ export class PublicKeyHelper {
95
95
  }
96
96
 
97
97
  private async getPublicKeyFromChain(address: string): Promise<PublicKey | undefined> {
98
- return getPublicKeyFromChain(this.globals.client, address);
98
+ return getPublicKeyFromChain(this.globals.suiClient, address);
99
99
  }
100
100
  }
@@ -1,4 +1,4 @@
1
- import { Report } from '@msafe/iota-utils';
1
+ import { Report } from '@msafe/sui3-utils';
2
2
 
3
3
  import { MSafeGlobals } from '@/globals';
4
4
 
@@ -1,4 +1,4 @@
1
- import { IotaClient } from '@iota/iota-sdk/client';
1
+ import { SuiClient } from '@mysten/sui.js/client';
2
2
 
3
3
  import { BackendImpl } from '@/backend/BackendImpl';
4
4
  import { IBackend } from '@/backend/interface';
@@ -8,25 +8,25 @@ import { IWallet } from '@/types/wallet';
8
8
  export class MSafeGlobals {
9
9
  public readonly backend: IBackend;
10
10
 
11
- public readonly client: IotaClient;
11
+ public readonly suiClient: SuiClient;
12
12
 
13
13
  public readonly config: MSafeConfig;
14
14
 
15
15
  _wallet: IWallet | undefined;
16
16
 
17
- constructor(input: { backend: IBackend; client: IotaClient; config: MSafeConfig }) {
17
+ constructor(input: { backend: IBackend; suiClient: SuiClient; config: MSafeConfig }) {
18
18
  this.backend = input.backend;
19
- this.client = input.client;
19
+ this.suiClient = input.suiClient;
20
20
  this.config = input.config;
21
21
  }
22
22
 
23
23
  static async New(env: MSafeEnv, options?: MSafeConfigOptions) {
24
24
  const config = getMSafeConfig(env, options);
25
- const client = new IotaClient(config.client);
25
+ const suiClient = new SuiClient(config.suiClient);
26
26
  const backend = new BackendImpl(config.backend.url, options?.mockAddress);
27
27
  return new MSafeGlobals({
28
28
  backend,
29
- client,
29
+ suiClient,
30
30
  config,
31
31
  });
32
32
  }
@@ -7,7 +7,7 @@ export enum MSafeEnv {
7
7
  }
8
8
 
9
9
  export interface MSafeConfig {
10
- client: {
10
+ suiClient: {
11
11
  url: string;
12
12
  };
13
13
  backend: {
@@ -18,7 +18,7 @@ export interface MSafeConfig {
18
18
  }
19
19
 
20
20
  export interface MSafeConfigOptions {
21
- client?: {
21
+ suiClient?: {
22
22
  url?: string;
23
23
  };
24
24
  backend?: {
@@ -44,7 +44,7 @@ export const ENV_CONFIGS = new Map<MSafeEnv, MSafeConfig>([
44
44
  [
45
45
  MSafeEnv.unit,
46
46
  {
47
- client: {
47
+ suiClient: {
48
48
  url: TESTNET_RPC_URL,
49
49
  },
50
50
  backend: {
@@ -57,7 +57,7 @@ export const ENV_CONFIGS = new Map<MSafeEnv, MSafeConfig>([
57
57
  [
58
58
  MSafeEnv.local,
59
59
  {
60
- client: {
60
+ suiClient: {
61
61
  url: TESTNET_RPC_URL,
62
62
  },
63
63
  backend: {
@@ -70,7 +70,7 @@ export const ENV_CONFIGS = new Map<MSafeEnv, MSafeConfig>([
70
70
  [
71
71
  MSafeEnv.dev,
72
72
  {
73
- client: {
73
+ suiClient: {
74
74
  url: TESTNET_RPC_URL,
75
75
  },
76
76
  backend: {
@@ -83,7 +83,7 @@ export const ENV_CONFIGS = new Map<MSafeEnv, MSafeConfig>([
83
83
  [
84
84
  MSafeEnv.prev,
85
85
  {
86
- client: {
86
+ suiClient: {
87
87
  url: MAINNET_RPC_URL,
88
88
  },
89
89
  backend: {
@@ -96,7 +96,7 @@ export const ENV_CONFIGS = new Map<MSafeEnv, MSafeConfig>([
96
96
  [
97
97
  MSafeEnv.prod,
98
98
  {
99
- client: {
99
+ suiClient: {
100
100
  url: MAINNET_RPC_URL,
101
101
  },
102
102
  backend: {
@@ -113,8 +113,8 @@ export function getMSafeConfig(env: MSafeEnv, options?: MSafeConfigOptions) {
113
113
  if (!config) {
114
114
  throw new Error('Unknown environment');
115
115
  }
116
- if (options?.client?.url) {
117
- config.client.url = options.client.url;
116
+ if (options?.suiClient?.url) {
117
+ config.suiClient.url = options.suiClient.url;
118
118
  }
119
119
  if (options?.backend?.url) {
120
120
  config.backend.url = options.backend.url;
@@ -1,5 +1,5 @@
1
- import { GasCostSummary } from '@iota/iota-sdk/client';
2
- import { TransactionBlock } from '@iota/iota-sdk/transactions';
1
+ import { GasCostSummary } from '@mysten/sui.js/client';
2
+ import { TransactionBlock } from '@mysten/sui.js/transactions';
3
3
 
4
4
  // Default to 120% o the reference gas price
5
5
  import { MSafeGlobals } from '@/globals/MSafeGlobals';
@@ -58,14 +58,14 @@ export class Simulator {
58
58
  ): Promise<SimulationResult> {
59
59
  const tx = this.copyTransactionBlock(input.txb);
60
60
 
61
- const { client } = this.globals;
61
+ const { suiClient } = this.globals;
62
62
 
63
63
  const gasPrice = await this.getGasPrice(gasOption);
64
64
  tx.setGasPrice(gasPrice);
65
65
 
66
66
  try {
67
- const inspectResult = await client.dryRunTransactionBlock({
68
- transactionBlock: await tx.build({ client: client }),
67
+ const inspectResult = await suiClient.dryRunTransactionBlock({
68
+ transactionBlock: await tx.build({ client: suiClient }),
69
69
  });
70
70
  const { gasUsed } = inspectResult.effects;
71
71
  const gasBudget = this.toGasBudget(gasUsed, gasPrice);
@@ -110,7 +110,7 @@ export class Simulator {
110
110
  return option.fixedVal;
111
111
  }
112
112
 
113
- const refGasPrice = await this.globals.client.getReferenceGasPrice();
113
+ const refGasPrice = await this.globals.suiClient.getReferenceGasPrice();
114
114
 
115
115
  return this.applyGasOption(refGasPrice, option);
116
116
  }
@@ -1,4 +1,4 @@
1
- import { CoinMetadata } from '@iota/iota-sdk/client';
1
+ import { CoinMetadata } from '@mysten/sui.js/client';
2
2
 
3
3
  export interface OwnedCoin {
4
4
  type: string;
@@ -1,6 +1,6 @@
1
- import { DryRunTransactionBlockResponse, GasCostSummary, IotaObjectRef } from '@iota/iota-sdk/client';
2
- import { SerializedSignature } from '@iota/iota-sdk/cryptography';
3
- import { IGasOption, TransactionType, TxIntention } from '@msafe/iota-utils';
1
+ import { IGasOption, TransactionType, TxIntention } from '@msafe/sui3-utils';
2
+ import { DryRunTransactionBlockResponse, GasCostSummary, SuiObjectRef } from '@mysten/sui.js/client';
3
+ import { SerializedSignature } from '@mysten/sui.js/cryptography';
4
4
 
5
5
  export interface PendingTx {
6
6
  application: string;
@@ -85,7 +85,7 @@ export interface SimulationResult {
85
85
  gasPrice: bigint;
86
86
  gasUsed: GasCostSummary;
87
87
  gasBudget: bigint;
88
- gasObject: IotaObjectRef;
88
+ gasObject: SuiObjectRef;
89
89
  simulationError?: string;
90
90
  response?: DryRunTransactionBlockResponse;
91
91
  }
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  ExecuteTransactionRequestType,
3
- IotaTransactionBlockResponse,
4
- IotaTransactionBlockResponseOptions,
5
- } from '@iota/iota-sdk/client';
6
- import { SignatureWithBytes } from '@iota/iota-sdk/cryptography';
7
- import { TransactionBlock } from '@iota/iota-sdk/transactions';
3
+ SuiTransactionBlockResponseOptions,
4
+ SuiTransactionBlockResponse,
5
+ } from '@mysten/sui.js/client';
6
+ import { SignatureWithBytes } from '@mysten/sui.js/cryptography';
7
+ import { TransactionBlock } from '@mysten/sui.js/transactions';
8
8
 
9
9
  export interface IWallet {
10
10
  walletType: string;
@@ -18,6 +18,6 @@ export interface IWallet {
18
18
  signAndExecuteTransactionBlock(input: {
19
19
  transactionBlock: TransactionBlock;
20
20
  requestType?: ExecuteTransactionRequestType;
21
- options?: IotaTransactionBlockResponseOptions;
22
- }): Promise<IotaTransactionBlockResponse>;
21
+ options?: SuiTransactionBlockResponseOptions;
22
+ }): Promise<SuiTransactionBlockResponse>;
23
23
  }
package/src/utils/coin.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { CoinMetadata, IotaClient, IotaObjectData } from '@iota/iota-sdk/client';
2
- import { normalizeStructTag } from '@iota/iota-sdk/utils';
1
+ import { CoinMetadata, SuiClient, SuiObjectData } from '@mysten/sui.js/client';
2
+ import { normalizeStructTag } from '@mysten/sui.js/utils';
3
3
 
4
4
  // CoinHelper is the coin helper to query for coin metadata.
5
5
  export class CoinHelper {
6
- private _client: IotaClient;
6
+ private _client: SuiClient;
7
7
 
8
8
  private _coinMetaReg: Map<string, CoinMetadata>;
9
9
 
10
- constructor(client: IotaClient) {
10
+ constructor(client: SuiClient) {
11
11
  this._client = client;
12
12
  this._coinMetaReg = new Map();
13
13
  }
@@ -48,7 +48,7 @@ export class Coin {
48
48
  return res || null;
49
49
  }
50
50
 
51
- static getBalance(data: IotaObjectData): bigint | undefined {
51
+ static getBalance(data: SuiObjectData): bigint | undefined {
52
52
  if (!Coin.isCoin(data.type)) {
53
53
  return undefined;
54
54
  }
@@ -1,5 +1,5 @@
1
- import { SerializedSignature } from '@iota/iota-sdk/cryptography';
2
- import { verifyPersonalMessage, verifyTransactionBlock } from '@iota/iota-sdk/verify';
1
+ import { SerializedSignature } from '@mysten/sui.js/cryptography';
2
+ import { verifyPersonalMessage, verifyTransactionBlock } from '@mysten/sui.js/verify';
3
3
 
4
4
  import { stringToBuffer } from '@/utils/buffer';
5
5
  import { Formatter } from '@/utils/format';
@@ -32,7 +32,7 @@ export class SignatureVerifier {
32
32
  targetAddress: string;
33
33
  }) {
34
34
  const publicKey = await SignatureVerifier.getPublicKeyFromSignature(input);
35
- return Formatter.isSuiAddressEqual(publicKey.toIotaAddress(), input.targetAddress);
35
+ return Formatter.isSuiAddressEqual(publicKey.toSuiAddress(), input.targetAddress);
36
36
  }
37
37
 
38
38
  static async verifyPersonalSignature(input: {
@@ -1,10 +1,10 @@
1
- import { normalizeIotaAddress, normalizeStructTag } from '@iota/iota-sdk/utils';
1
+ import { normalizeSuiAddress, normalizeStructTag } from '@mysten/sui.js/utils';
2
2
 
3
3
  import { Coin } from '@/utils/coin';
4
4
 
5
5
  export class Formatter {
6
- static normalizeIotaAddress(addr: string) {
7
- return normalizeIotaAddress(addr);
6
+ static normalizeSuiAddress(addr: string) {
7
+ return normalizeSuiAddress(addr);
8
8
  }
9
9
 
10
10
  static normalizeStructTag(struct: string) {
@@ -12,7 +12,7 @@ export class Formatter {
12
12
  }
13
13
 
14
14
  static isSuiAddressEqual(addr1: string, addr2: string) {
15
- return normalizeIotaAddress(addr1) === normalizeIotaAddress(addr2);
15
+ return normalizeSuiAddress(addr1) === normalizeSuiAddress(addr2);
16
16
  }
17
17
 
18
18
  static isSuiStructEqual(struct1: string, struct2: string) {
@@ -1,11 +1,11 @@
1
- import { IotaObjectResponse, IotaObjectDataOptions, IotaObjectData, IotaClient } from '@iota/iota-sdk/client';
1
+ import { SuiObjectResponse, SuiObjectDataOptions, SuiObjectData, SuiClient } from '@mysten/sui.js/client';
2
2
 
3
3
  import { EntryIterator, getAllFromIterator, REQUEST_PAGE_SIZE, SuiIterator } from './iterator';
4
4
  import { PagedData, Requester } from './requester';
5
5
 
6
6
  // TODO: setup testnet faucet and test this file
7
7
 
8
- export type ObjectFilter = (objRes: IotaObjectResponse) => boolean;
8
+ export type ObjectFilter = (objRes: SuiObjectResponse) => boolean;
9
9
 
10
10
  // OidIter is the iterator to give the list of object ids
11
11
  export type OidIter = SuiIterator<string>;
@@ -13,20 +13,20 @@ export type OidIter = SuiIterator<string>;
13
13
  export interface BatchObjectOptions {
14
14
  filter?: ObjectFilter;
15
15
  pageSize?: number;
16
- objectOptions?: IotaObjectDataOptions;
16
+ objectOptions?: SuiObjectDataOptions;
17
17
  }
18
18
 
19
19
  // getObjectsById get the list of objects by id.
20
20
  // Compared with the multiGetObject method defined by SUI, this method will do the pagination
21
21
  // for get object requests.
22
22
  export async function getObjectsById(
23
- provider: IotaClient,
23
+ provider: SuiClient,
24
24
  ids: string[],
25
25
  options?: BatchObjectOptions,
26
- ): Promise<(IotaObjectData | undefined)[]> {
26
+ ): Promise<(SuiObjectData | undefined)[]> {
27
27
  const oidIter = new ListOidIterator(ids);
28
28
  const iter = new ObjectBatchIterator(provider, oidIter, options);
29
- return (await getAllFromIterator(iter)) as (IotaObjectData | undefined)[];
29
+ return (await getAllFromIterator(iter)) as (SuiObjectData | undefined)[];
30
30
  }
31
31
 
32
32
  // ListOidIterator is the iterator that iterate through a list of ids.
@@ -53,9 +53,9 @@ export class ListOidIterator implements OidIter {
53
53
  }
54
54
  }
55
55
 
56
- export class ObjectBatchIterator extends EntryIterator<IotaObjectData> {
56
+ export class ObjectBatchIterator extends EntryIterator<SuiObjectData> {
57
57
  constructor(
58
- public readonly provider: IotaClient,
58
+ public readonly provider: SuiClient,
59
59
  public readonly idIter: OidIter,
60
60
  public readonly options?: BatchObjectOptions,
61
61
  ) {
@@ -64,15 +64,15 @@ export class ObjectBatchIterator extends EntryIterator<IotaObjectData> {
64
64
  }
65
65
 
66
66
  // TODO: Test with customize objects
67
- export class ObjectBatchRequester implements Requester<IotaObjectData> {
67
+ export class ObjectBatchRequester implements Requester<SuiObjectData> {
68
68
  filter: ObjectFilter | undefined;
69
69
 
70
70
  pageSize: number;
71
71
 
72
- objectOptions: IotaObjectDataOptions;
72
+ objectOptions: SuiObjectDataOptions;
73
73
 
74
74
  constructor(
75
- public readonly provider: IotaClient,
75
+ public readonly provider: SuiClient,
76
76
  public readonly stringIter: OidIter,
77
77
  public options?: BatchObjectOptions,
78
78
  ) {
@@ -84,7 +84,7 @@ export class ObjectBatchRequester implements Requester<IotaObjectData> {
84
84
  };
85
85
  }
86
86
 
87
- async doNextRequest(): Promise<PagedData<IotaObjectData>> {
87
+ async doNextRequest(): Promise<PagedData<SuiObjectData>> {
88
88
  const requestPage: string[] = [];
89
89
  while (requestPage.length < this.pageSize) {
90
90
  const hasNext = await this.stringIter.hasNext();
@@ -96,36 +96,36 @@ export class ObjectBatchRequester implements Requester<IotaObjectData> {
96
96
  requestPage.push(objId);
97
97
  }
98
98
  }
99
- const res: IotaObjectResponse[] = await this.provider.multiGetObjects({
99
+ const res: SuiObjectResponse[] = await this.provider.multiGetObjects({
100
100
  ids: requestPage,
101
101
  options: this.objectOptions,
102
102
  });
103
- let filtered: IotaObjectResponse[];
103
+ let filtered: SuiObjectResponse[];
104
104
  if (this.filter) {
105
105
  const { filter } = this;
106
- filtered = res.filter((r: IotaObjectResponse) => filter?.(r));
106
+ filtered = res.filter((r: SuiObjectResponse) => filter?.(r));
107
107
  } else {
108
108
  filtered = res;
109
109
  }
110
110
  return {
111
- data: filtered.map((objRes) => objRes.data).filter((data) => data) as IotaObjectData[],
111
+ data: filtered.map((objRes) => objRes.data).filter((data) => data) as SuiObjectData[],
112
112
  hasNext: await this.stringIter.hasNext(),
113
113
  };
114
114
  }
115
115
  }
116
116
 
117
117
  export async function getAllOwnedObjects(
118
- provider: IotaClient,
118
+ provider: SuiClient,
119
119
  owner: string,
120
120
  options?: BatchObjectOptions,
121
- ): Promise<IotaObjectData[]> {
121
+ ): Promise<SuiObjectData[]> {
122
122
  const iter = new OwnedObjectIterator(provider, owner, options);
123
- return (await getAllFromIterator(iter)) as IotaObjectData[];
123
+ return (await getAllFromIterator(iter)) as SuiObjectData[];
124
124
  }
125
125
 
126
- export class OwnedObjectIterator extends EntryIterator<IotaObjectData> implements SuiIterator<IotaObjectData> {
126
+ export class OwnedObjectIterator extends EntryIterator<SuiObjectData> implements SuiIterator<SuiObjectData> {
127
127
  constructor(
128
- public readonly provider: IotaClient,
128
+ public readonly provider: SuiClient,
129
129
  public readonly owner: string,
130
130
  public readonly options?: BatchObjectOptions,
131
131
  ) {
@@ -133,17 +133,17 @@ export class OwnedObjectIterator extends EntryIterator<IotaObjectData> implement
133
133
  }
134
134
  }
135
135
 
136
- export class OwnedObjectRequester implements Requester<IotaObjectData> {
136
+ export class OwnedObjectRequester implements Requester<SuiObjectData> {
137
137
  nextCursor: string | null;
138
138
 
139
139
  public filter: ObjectFilter | undefined;
140
140
 
141
141
  public pageSize: number;
142
142
 
143
- public objectOptions: IotaObjectDataOptions;
143
+ public objectOptions: SuiObjectDataOptions;
144
144
 
145
145
  constructor(
146
- public readonly provider: IotaClient,
146
+ public readonly provider: SuiClient,
147
147
  public readonly owner: string,
148
148
  public readonly options?: BatchObjectOptions,
149
149
  ) {
@@ -156,7 +156,7 @@ export class OwnedObjectRequester implements Requester<IotaObjectData> {
156
156
  };
157
157
  }
158
158
 
159
- async doNextRequest(): Promise<PagedData<IotaObjectData>> {
159
+ async doNextRequest(): Promise<PagedData<SuiObjectData>> {
160
160
  const res = await this.provider.getOwnedObjects({
161
161
  owner: this.owner,
162
162
  options: this.objectOptions,
@@ -164,15 +164,15 @@ export class OwnedObjectRequester implements Requester<IotaObjectData> {
164
164
  limit: this.pageSize,
165
165
  });
166
166
  this.nextCursor = res.nextCursor as string;
167
- let filtered: IotaObjectResponse[];
167
+ let filtered: SuiObjectResponse[];
168
168
  if (this.filter) {
169
169
  const { filter } = this;
170
- filtered = res.data.filter((obj: IotaObjectResponse) => filter?.(obj));
170
+ filtered = res.data.filter((obj: SuiObjectResponse) => filter?.(obj));
171
171
  } else {
172
172
  filtered = res.data;
173
173
  }
174
174
  return {
175
- data: filtered.map((r: IotaObjectResponse) => r.data).filter((data) => data) as IotaObjectData[],
175
+ data: filtered.map((r: SuiObjectResponse) => r.data).filter((data) => data) as SuiObjectData[],
176
176
  hasNext: res.hasNextPage,
177
177
  };
178
178
  }