suidouble 0.0.39 → 0.0.40

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/README.md CHANGED
@@ -216,8 +216,8 @@ If you need to transfer some SUI/coins as part of executing contract method, you
216
216
  // 400000000000 MISTs, if amount is BigInt, it's used in decimal items
217
217
  {type: 'SUI', amount: '0.2'}
218
218
  // 0.2 SUI , if amount is String, it's translated to decimals, using coin metadata in a lazy way
219
- {type: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN', amount: '1'}
220
- // 1 USDC
219
+ {type: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN', amount: '1.0'}
220
+ // 1 USDC, note it should have a dot even if it's '0' after. You may want to use `Number(var).toFixed(decimals)` as a conversion
221
221
  {type: '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN', amount: '99.99'}
222
222
  // 99.99 USDT
223
223
  ```
package/lib/SuiCoin.js CHANGED
@@ -182,7 +182,9 @@ class SuiCoin {
182
182
  }
183
183
 
184
184
  async coinOfAmountToTxCoin(txb, owner, amount, addEmptyCoins = false) {
185
- const expectedAmountAsBigInt = BigInt(amount);
185
+ const normalizedAmount = await this.lazyNormalizeAmount(amount);
186
+
187
+ const expectedAmountAsBigInt = BigInt(normalizedAmount);
186
188
  const coinIds = await this.coinObjectsEnoughForAmount(owner, expectedAmountAsBigInt, addEmptyCoins);
187
189
 
188
190
  if (!coinIds || !coinIds.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suidouble",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "description": "Set of provider, package and object classes for javascript representation of Sui Move smart contracts. Use same code for publishing, upgrading, integration testing, interaction with smart contracts and integration in browser web3 dapps",
5
5
  "main": "index.js",
6
6
  "scripts": {