Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions bindings/go/examples/publish_upgrade/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,8 @@ func main() {
}
obj := *objPtr
if obj.AsStructOpt() != nil {
structType := obj.AsStruct().StructType
packageIdent, _ := sdk.NewIdentifier("package")
upgradeCapIdent, _ := sdk.NewIdentifier("UpgradeCap")
upgradeCapType := sdk.NewStructTag(sdk.AddressFramework(), packageIdent, upgradeCapIdent, []*sdk.TypeTag{})
if structType.Eq(upgradeCapType) {
upgradeCapType := sdk.StructTagNewUpgradeCap()
if obj.AsStruct().StructType.Eq(upgradeCapType) {
fmt.Printf("UpgradeCap: %s\n", objectId.ToHex())
fmt.Printf("UpgradeCapOwner: %s\n", objectWrite.Owner.AsAddress().ToHex())
upgradeCap = objectId
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/examples/unstake/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func main() {
client := sdk.GraphQlClientNewDevnet()

stakedIotaType := sdk.StructTagStakedIota().String()
stakedIotaType := sdk.StructTagNewStakedIota().String()
stakedIotas, err := client.Objects(&sdk.ObjectFilter{TypeTag: &stakedIotaType}, nil)
if err.(*sdk.SdkFfiError) != nil {
log.Fatalf("Failed to get staked iota: %v", err)
Expand Down
555 changes: 536 additions & 19 deletions bindings/go/iota_sdk_ffi/iota_sdk_ffi.go

Large diffs are not rendered by default.

430 changes: 406 additions & 24 deletions bindings/go/iota_sdk_ffi/iota_sdk_ffi.h

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions bindings/kotlin/examples/PublishUpgrade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,7 @@ fun main() = runBlocking {
val obj: Object =
client.`object`(objectId, null)
?: throw Exception("Missing object ${objectId.toHex()}")
val upgradeCapType =
StructTag(
address = Address.framework(),
module = Identifier("package"),
name = Identifier("UpgradeCap"),
typeParams = emptyList<TypeTag>()
)
val upgradeCapType = StructTag.newUpgradeCap()
if (obj.asStruct().structType == upgradeCapType) {
println("UpgradeCap: ${objectId.toHex()}")
println(
Expand Down
3 changes: 2 additions & 1 deletion bindings/kotlin/examples/Unstake.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ fun main() = runBlocking {
try {
val client = GraphQlClient.newDevnet()

val stakedIotas = client.objects(ObjectFilter(typeTag = StructTag.stakedIota().toString()))
val stakedIotas =
client.objects(ObjectFilter(typeTag = StructTag.newStakedIota().toString()))
if (stakedIotas.data.isEmpty()) {
throw Exception("no validators found")
}
Expand Down
703 changes: 683 additions & 20 deletions bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion bindings/python/examples/coin_balances.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ async def main():

coins = await client.coins(address)
for coin in coins.data:
print(f"Coin = {coin.id().to_hex()}, Coin Type = {coin.coin_type().as_struct_tag()}, Balance = {coin.balance()}")
print(
f"Coin = {coin.id().to_hex()}, Coin Type = {coin.coin_type().as_struct_tag()}, Balance = {coin.balance()}"
)

balance = await client.balance(address)
print(f"Total Balance = {balance}")
Expand Down
11 changes: 6 additions & 5 deletions bindings/python/examples/publish_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import json
import os


async def main():
try:
# Read and parse the compiled package, or use the default package
Expand All @@ -36,7 +37,7 @@ async def main():
print("No compiled package found in env var. Using default.")
package_data_json = PRECOMPILED_PACKAGE
else:
print("Using custom Move package found in env var.");
print("Using custom Move package found in env var.")

package_data = MovePackageData.from_json(package_data_json)
modules = package_data.modules()
Expand Down Expand Up @@ -96,11 +97,11 @@ async def main():
obj = await client.object(object_id, None)
if obj is None:
raise Exception(f"Missing object {object_id.to_hex()}")
if obj.as_struct().struct_type == StructTag(
Address.framework(), Identifier("package"), Identifier("UpgradeCap")
):
if obj.as_struct().struct_type == StructTag.new_upgrade_cap():
print(f"UpgradeCap: {object_id.to_hex()}")
print(f"UpgradeCapOwner: {changed_obj.output_state.owner.as_address().to_hex()}")
print(
f"UpgradeCapOwner: {changed_obj.output_state.owner.as_address().to_hex()}"
)
upgrade_cap = object_id

elif changed_obj.output_state.is_package_write():
Expand Down
90 changes: 48 additions & 42 deletions bindings/python/examples/tx_command_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,66 @@

import asyncio


async def main():
try:
client = GraphQlClient.new_devnet()
try:
client = GraphQlClient.new_devnet()

sender = Address.from_hex(
"0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c"
)

sender = Address.from_hex("0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c")
builder = await TransactionBuilder.init(sender, client)

builder = await TransactionBuilder.init(sender, client)
package_addr = Address.std_lib()
module_name = Identifier("u64")
function_name = Identifier("max")

package_addr = Address.std_lib()
module_name = Identifier("u64")
function_name = Identifier("max")
builder.move_call(
package_addr,
module_name,
function_name,
[PtbArgument.u64(0), PtbArgument.u64(1000)],
# Assign a name to the result of this command
names=["res0"],
)

builder.move_call(
package_addr,
module_name,
function_name,
[PtbArgument.u64(0), PtbArgument.u64(1000)],
# Assign a name to the result of this command
names=["res0"],
)
builder.move_call(
package_addr,
module_name,
function_name,
[PtbArgument.u64(1000), PtbArgument.u64(2000)],
# Assign a name to the result of this command
names=["res1"],
)

builder.move_call(
package_addr,
module_name,
function_name,
[PtbArgument.u64(1000), PtbArgument.u64(2000)],
# Assign a name to the result of this command
names=["res1"],
)
builder.split_coins(
PtbArgument.gas(),
# Use the named results of previous commands as arguments
[PtbArgument.res("res0"), PtbArgument.res("res1")],
# For nested results, a tuple or vec can be used to name them
["coin0", "coin1"],
)

builder.split_coins(
PtbArgument.gas(),
# Use the named results of previous commands as arguments
[PtbArgument.res("res0"), PtbArgument.res("res1")],
# For nested results, a tuple or vec can be used to name them
["coin0", "coin1"],
)
# Use named results as arguments
builder.transfer_objects(
sender, [PtbArgument.res("coin0"), PtbArgument.res("coin1")]
)

# Use named results as arguments
builder.transfer_objects(sender, [PtbArgument.res("coin0"), PtbArgument.res("coin1")])
txn = await builder.finish()

txn = await builder.finish()
print("Signing Digest:", txn.signing_digest_hex())
print("Txn Bytes:", txn.to_base64())

print("Signing Digest:", txn.signing_digest_hex())
print("Txn Bytes:", txn.to_base64())
res = await client.dry_run_tx(txn, False)
if res.error is not None:
raise Exception("Failed to send tx:", res.error)

res = await client.dry_run_tx(txn, False)
if res.error is not None:
raise Exception("Failed to send tx:", res.error)
print("Tx dry run was successful!")

print("Tx dry run was successful!")
except Exception as e:
print(f"Error: {e}")

except Exception as e:
print(f"Error: {e}")

if __name__ == "__main__":
asyncio.run(main())
asyncio.run(main())
2 changes: 1 addition & 1 deletion bindings/python/examples/unstake.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async def main():
client = GraphQlClient.new_devnet()

staked_iotas = await client.objects(
filter=ObjectFilter(type_tag=str(StructTag.staked_iota()))
filter=ObjectFilter(type_tag=str(StructTag.new_staked_iota()))
)
if len(staked_iotas.data) == 0:
raise Exception("no staked iotas found")
Expand Down
Loading