@msafe/sui3-sdk 0.0.76 → 0.0.78

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.
@@ -5,50 +5,17 @@ import { TransactionBlock } from '@mysten/sui.js/transactions';
5
5
  import { MSafeGlobals } from '@/globals/MSafeGlobals';
6
6
  import { SimulationResult } from '@/types';
7
7
 
8
- // Gas price option can be either a multiplier or a fixed amount
9
- export type GasPriceOption = MultiplierOption | FixedValueOption;
10
-
11
- // Gas budget option can be either a multiplier or a fixed amount
12
- export type GasBudgetOption = MultiplierOption | FixedValueOption;
13
-
14
- export interface MultiplierOption {
15
- multiplier: {
16
- numerator: bigint;
17
- denominator: bigint;
18
- };
19
- }
20
-
21
- export interface FixedValueOption {
22
- fixedVal: bigint;
23
- }
24
-
25
8
  const GAS_SAFE_OVERHEAD = 1000n;
26
- // Default to 120% of the reference gas price
27
- export const DEF_GAS_PRICE_NUM = 120n;
28
- export const DEF_GAS_PRICE_DEN = 100n;
29
-
30
- export const DEF_GAS_PRICE_OPTION: GasPriceOption = {
31
- multiplier: {
32
- numerator: DEF_GAS_PRICE_NUM,
33
- denominator: DEF_GAS_PRICE_DEN,
34
- },
35
- };
36
9
 
37
10
  export class Simulator {
38
11
  constructor(private globals: MSafeGlobals) {}
39
12
 
40
- public async simulate(
41
- input: {
42
- txb: TransactionBlock;
43
- sender: string;
44
- },
45
- gasOption: GasPriceOption = DEF_GAS_PRICE_OPTION,
46
- ): Promise<SimulationResult> {
13
+ public async simulate(input: { txb: TransactionBlock; sender: string }): Promise<SimulationResult> {
47
14
  const tx = this.copyTransactionBlock(input.txb);
48
15
 
49
16
  const { suiClient } = this.globals;
50
17
 
51
- const gasPrice = await this.getGasPrice(gasOption);
18
+ const gasPrice = await this.getGasPrice();
52
19
 
53
20
  tx.setGasPrice(gasPrice);
54
21
 
@@ -77,14 +44,8 @@ export class Simulator {
77
44
  };
78
45
  }
79
46
 
80
- private async getGasPrice(option: GasPriceOption) {
81
- if (this.isFixedValue(option)) {
82
- return option.fixedVal;
83
- }
84
-
85
- const refGasPrice = await this.globals.suiClient.getReferenceGasPrice();
86
-
87
- return this.applyGasOption(refGasPrice, option);
47
+ private async getGasPrice() {
48
+ return this.globals.suiClient.getReferenceGasPrice();
88
49
  }
89
50
 
90
51
  private toGasBudget(gasUsed: GasCostSummary, gasPrice: bigint) {
@@ -100,25 +61,6 @@ export class Simulator {
100
61
  return gasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead;
101
62
  }
102
63
 
103
- private isFixedValue(option: GasPriceOption | GasBudgetOption): option is FixedValueOption {
104
- return 'fixedVal' in option;
105
- }
106
-
107
- private isMultiplier(option: GasPriceOption | GasBudgetOption): option is MultiplierOption {
108
- return 'multiplier' in option;
109
- }
110
-
111
- private applyGasOption(val: bigint, option: GasPriceOption) {
112
- if (this.isFixedValue(option)) {
113
- return option.fixedVal;
114
- }
115
- if (this.isMultiplier(option)) {
116
- const { multiplier } = option;
117
- return (val * multiplier.numerator) / multiplier.denominator;
118
- }
119
- throw new Error('Sanity: Unknown gas price option');
120
- }
121
-
122
64
  private copyTransactionBlock(tx: TransactionBlock): TransactionBlock {
123
65
  return TransactionBlock.from(tx.serialize());
124
66
  }
package/src/utils/sui.ts CHANGED
@@ -50,13 +50,7 @@ function getAddressFromSignatures(serializedSig: SerializedSignature, targetAddr
50
50
  }
51
51
  return undefined;
52
52
  }
53
- case 'ZkLogin': {
54
- if (Formatter.isSuiAddressEqual(decoded.zkLogin.address, targetAddress)) {
55
- throw new Error('ZkLogin wallet cannot be owner');
56
- }
57
- return undefined;
58
- }
59
-
53
+ case 'ZkLogin':
60
54
  case 'ED25519':
61
55
  case 'Secp256k1':
62
56
  case 'Secp256r1': {