suidouble 0.0.39 → 0.0.41

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
@@ -131,7 +131,11 @@ class SuiCoin {
131
131
  }
132
132
 
133
133
  isSUI() {
134
- return this._coinType.toLowerCase().indexOf('sui') > -1;
134
+ const lc = this._coinType.toLowerCase();
135
+ if (lc == 'sui' || lc.indexOf(':sui:') !== -1) {
136
+ return true;
137
+ }
138
+ return false;
135
139
  }
136
140
 
137
141
  async getMetadata() {
@@ -182,7 +186,9 @@ class SuiCoin {
182
186
  }
183
187
 
184
188
  async coinOfAmountToTxCoin(txb, owner, amount, addEmptyCoins = false) {
185
- const expectedAmountAsBigInt = BigInt(amount);
189
+ const normalizedAmount = await this.lazyNormalizeAmount(amount);
190
+
191
+ const expectedAmountAsBigInt = BigInt(normalizedAmount);
186
192
  const coinIds = await this.coinObjectsEnoughForAmount(owner, expectedAmountAsBigInt, addEmptyCoins);
187
193
 
188
194
  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.41",
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": {
@@ -21,7 +21,7 @@
21
21
  "author": "Jeka Kiselyov <jeka911@gmail.com> (https://github.com/jeka-kiselyov)",
22
22
  "license": "Apache-2.0",
23
23
  "dependencies": {
24
- "@mysten/sui.js": "^0.39.0",
24
+ "@mysten/sui.js": "^0.41.0",
25
25
  "@wallet-standard/core": "^1.0.3"
26
26
  },
27
27
  "devDependencies": {
@@ -2,6 +2,8 @@
2
2
 
3
3
  [move]
4
4
  version = 0
5
+ manifest_digest = "F8C73BB1CA5B2EEF078E6FD0C793EF387322A4AD49DECCFE6AAD9F5F81C198C8"
6
+ deps_digest = "112928C94A84031C09CD9B9D1D44B149B73FC0EEA5FA8D8B2D7CA4D91936335A"
5
7
 
6
8
  dependencies = [
7
9
  { name = "Sui" },