@msafe/sui3-sdk 0.0.63 → 0.0.65

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