Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

suidouble

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

suidouble - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

8

lib/SuiPackageModule.js

@@ -82,3 +82,9 @@ const sui = require('@mysten/sui.js');

for (let param of params) {
callArgs.push(tx.pure(param));
if (param.indexOf && param.indexOf('<SUI>') === 0) {
let amount = BigInt(param.split('>')[1]);
const coin = tx.add(sui.Transactions.SplitCoins(tx.gas, [tx.pure(amount)]));
callArgs.push(coin);
} else {
callArgs.push(tx.pure(param));
}
}

@@ -85,0 +91,0 @@ tx.moveCall({

2

package.json
{
"name": "suidouble",
"version": "0.0.12",
"version": "0.0.13",
"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,0 +5,0 @@ "main": "index.js",

@@ -158,2 +158,10 @@ # suidouble

If you need to transfer some SUI as part of executing contract method, you can use a magic parameter in form of '<SUI>400000000000' where 400000000000 is the amount of MIST you want to send. SuiPackageModule will convert this amount to Coin object using Transactions.SplitCoins method.
```javascript
const moveCallResult = await contract.moveCall('suidouble_chat', 'post_pay', [chatShopObjectId, '<SUI>400000000000', messageText, 'metadata']);
```
@todo: sending other Coins
##### fetching objects

@@ -301,4 +309,5 @@

- subscribe to events
- sending other coins as contract methods execution
- suiobject invalidation/fetching optimization
- better documentation
- unit tests
- unit tests coverage to 90%+

@@ -240,3 +240,3 @@ 'use strict'

const idsInLoopDict = {};
await anotherEventsResponse.forEach(async (event)=>{
await anotherEventsResponse.forEach(async (event)=>{ //
if (!idsInLoopDict[event.parsedJson.id]) {

@@ -251,4 +251,46 @@ idsInLoopDict[event.parsedJson.id] = true;

test('testing move call with coins', async t => {
const balanceWas = await suiMaster.getBalance();
const longMessageYouCanNotPostForFree = ('message ').padEnd(500, 'test');
// can't post it for free (as per contract design)
t.rejects(contract.moveCall('suidouble_chat', 'post', [chatShopObjectId, longMessageYouCanNotPostForFree, 'metadata']));
// but can post with with post_pay function sending some sui to it
const moveCallResult = await contract.moveCall('suidouble_chat', 'post_pay', [chatShopObjectId, '<SUI>400000000000', longMessageYouCanNotPostForFree, 'metadata']);
// there're at least some object created
t.ok(moveCallResult.created.length > 0);
// by suidouble_chat contract design, ChatTopMessage is an object representing a thread,
// it always has at least one ChatResponse (with text of the very first message in thread)
let foundChatTopMessage = null;
let foundChatResponse = null;
let foundText = null;
moveCallResult.created.forEach((obj)=>{
if (obj.typeName == 'ChatTopMessage') {
foundChatTopMessage = true;
}
if (obj.typeName == 'ChatResponse') {
foundChatResponse = true;
foundText = obj.fields.text;
}
});
t.ok(foundChatTopMessage);
t.ok(foundChatResponse);
// messageTextAsBytes = [].slice.call(new TextEncoder().encode(messageText)); // regular array with utf data
// suidouble_chat contract store text a bytes (easier to work with unicode things), let's convert it back to js string
foundText = new TextDecoder().decode(new Uint8Array(foundText));
t.equal(foundText, longMessageYouCanNotPostForFree);
const balanceNow = await suiMaster.getBalance();
t.ok( balanceNow <= (balanceWas - 400000000000n) );
});
test('stops local test node', async t => {
SuiLocalTestValidator.stop();
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc