frankc01 / pysui Goto Github PK
View Code? Open in Web Editor NEWSUI Python Client SDK
License: Apache License 2.0
SUI Python Client SDK
License: Apache License 2.0
With SUI 0.17.0 subscriptions now happen with fullnode URL
Will cover post "Cable Casing" milestone
SuiAsynchClient does not invoke new_sign_secure
Secp256k1 keypair does not implement new_sign_secure
Implement base Sui RPC transaction building, validation using rpc.discover meta data, sign and execute.
Example of SUI transactions:
Eliminate manual parsing of inbound descriptors from various sui_get...
calls
Objectify transaction results
Objectify normalized package, modules, et.
Last review was in 0.0.1 version...
Will analyze....
Add GitHub actions for running tests including linters and actual pytest before merging PRs or before committing to main
.
Fixture will utilize devnet or local and go through the entire suite of RPC API
I have no idea what I am doing here, collaboration is welcome!
There is an incredible amount of redundant/duplicate code. Side effect of pushing catch up capability with evolving SUI RPC.
Primary focus areas:
These changes MUST NOT break SDK class interfaces.
Unlike Coin, there is no predictable type information to infer an NFT from any other object.
Currently, the submission of a transaction, signing and executing transaction all happen in the execute
Client function.
Provide an option to return the TransactionBytes to be signed later.
Change the monolithic source from title into package with multiple source.
For example, from sui_types.py
to:
sui_types
|
--- scalars.py
--- core.py
--- collections.py
--- etc.
When more testing that all scenarios are handled by the new transaction result type, substitute strings for well know SUI Types:
Towards coverage
MystenLabs/sui#7423
Changes to secp256/k/r1 signing see #67
MystenLabs/sui#7790
Programmable transactions
MystenLabs/sui#7372
Deprecation of FIXED in pysui 0.11.0sui_devInspectMoveCall
MystenLabs/sui#7426
build/publish see #66--with-unpublished-dependencies
MystenLabs/sui#7237
This is causing fails in tracing back through object generations
MystenLabs/sui#7318
Dynamic 'type' and 'value' readability (Structural change to sui_getDynamicFields
)
MystenLabs/sui#6989
Change to storing keys on disk (0.21.0) - FIXED in pysui 0.8.0
MystenLabs/sui#7052
This is causing fails in the deserialization of transaction events. Have temporary workaround - FIXED in pysui 0.9.0
Example:
in 0x2::dynamic_object_field
module for function id
has return type of Option<ID>
but only seeing Option
Readying for sphinx doc
A number of new API were added.
sui_executeTransactionSerializedSig
sui_getTransactionAuthSigners
Subsciptions were also added but I'm deferring (see #40)
With the implementation of get_package
(builder: GetPackage
) that provides a richer result.
Enhance usability of SuiClient
for basic queries (get_...
) and executions (i.e. publish
, call
, pay
etc.)
Originally posted by FrankC01 December 28, 2022
On synch or asynch client to get all the gas coins... note GetCoins
this is a more terse result SuiCoinObject
vs. ObjectRead
def get_gas(self, address: SuiAddress) -> list[SuiCoinObject]:
"""."""
coin_type = SuiString("0x2::sui::SUI")
result = self.execute(GetCoinTypeBalance(owner=address, coin_type=coin_type))
if result.is_ok():
limit = SuiInteger(result.result_data.items[0].coin_object_count)
result = self.execute(GetCoins(owner=address, coin_type=coin_type, limit=limit))
if result.is_ok():
return result.result_data.data
return []
Addresses: 4
Total Sui Coin Objects: 25
real 0m2.210s
user 0m0.627s
sys 0m0.079s
Addresses: 4
Total Sui Coin Objects: 25
real 0m0.966s
user 0m0.399s
sys 0m0.065s
Currently only supporting "AddressOwner" and not "ObjectOwner" and fails parse when using builder identified in title.
Stupid paste in haste of status return.
A good example is the new sui_payAllSui
which is specific to SUI coin (i.e. 0x2::sui::SUI
) whereas sui_pay
is in any coin.
During the method execution, it inadvertently instantiates the wrong key-pair class.
Currently, transaction type builder's __init__
with **kwargs
expects all arguments to be satisfied.
Change this to service the intersect of the builders specific keywords if any.
I had assumed that other numeric types would be forthcoming, and they still may, however the semantics of the current type lend itself to an abstract and not concrete type.
This will change in 0.0.11 so that SuiInteger is the concrete class of type SuiNumber the abstract type.
As synchronous RPC client is maturing adding an asynchronous RPC is needed.
Provide call to get gas from SUI faucet.
Example curl:
curl --location --request POST \
> 'http://faucet.devnet.sui.io/gas' \
> --header 'Content-Type: application/json' \
> --data-raw '{
> "FixedAmountRequest": {
> "recipient": "<ADDRESS>"
> }
> }'
While it updates the general 'address' str to SuiAddress dictionary, it neglected to update the 'address' str to keypair dictionary.
Poetry seems like a better alternative instead of using pure venvs manage the dev-requirements
, requirements
and publishing the package to pypi
. It even uses pyproject.toml
which is supported by new versions of python for management of config and dependencies. Also it's dependency resolver is very good. I'm willing to contribute to poetry migration too.
Originally posted by FrankC01 November 1, 2022
Currently, when doing a publish, pysui
consumes all *.mv files in package/build/PACKAGENAME/bytecode_modules/
which may also pick up modules built for testing which will fail the publish.
Wondering if pysui should clean and shell out to clear and rebuild the package without test to ensure successful publish.
I've asked Sui team if there is some other discriminator in the actual compiled files (e.g. *.mv
) to detect and report, so far I haven't heard back on that.
If we initiate SuiAsynchClient
before running the main event loop or in different task, it raised the nested event loop error due to asyncio.get_event_loop()
and loop.run_until_complete()
method being used from asyncio
. The code I've mentioned is used in
class SuiAsynchClient(_ClientMixin):
"""Sui Asyncrhonous Client."""
def __init__(self, config: SuiConfig) -> None:
"""Client initializer."""
super().__init__(config)
self._client = httpx.AsyncClient(http2=True)
self._rpc_api = {}
self._schema_dict = {}
loop = asyncio.get_event_loop()
loop.run_until_complete(self._build_api_descriptors())
Using the synchronous version of self_build_api_descriptors()
rather than loop.run_until_complete()
will fix this issue as the risk of creation of multiple loops will be gone. Also the get_event_loop()
method is deprecated too.
Remove cache dependencies on existing package lookups.
Quite a few changes are introduced with 0.20.0 including new and modified RPC API
The default SDK behavior is to create Rpc connection with devnet.
Extend to support alternate URL points, such as sui-node's 127.0.0.1:9000 to interface with
Readying for sphinx doc
Currently generating a new 'address' uses default derivation path and generates the seed mnemonic.
With reference to feature
Caveats
pysui
re-builds the source move code to ensure no test bits are includedsui keytool
for signing with MultiSign pending Roaring Bitmap sourcingNote: The publish will fail at the RPC level if the base64 encoded binaries contain test bits
Removing redundancies and over complications
Update has two flavors:
balance
(pushed in 0.4.1)And a link to pastebin, in case you need it https://pastebin.com/9CsYNr44
I have to tell you right away that I have the SUI binaries installed.
Right now, only sui_getNormalizedMoveModulesByPackage
is supported.
Need to cover:
sui_getMoveFunctionArgTypes
sui_getNormalizedMoveFunction
sui_getNormalizedMoveModule
sui_getNormalizedMoveStruct
Currently random seed is used. Want to use mnemonics for key recovery as well.
Support existing, new and emerging SUI RPC API
The former produces a 64 byte signature (python secp256k1) whereas the latter produces 65 bytes (rust fastcrypto)
Not sure why they are different. If can't resolve I will fall back to invoking sui keytool ...
and scrapping resulting signature.
Missing coverage causes display of result to fail
Occurs during the type string parsing as it has a package
type that wasn't accounted for...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.