Skip to content

Commit f8533e2

Browse files
chore(cleanup): use better names for default address constants (#283)
* use semantic default address names * named addresses and object ids in bindings * because python 'black' formatter says so * commit changes (fix CI) * const fn Co-authored-by: DaughterOfMars <[email protected]> * const fn 2 Co-authored-by: DaughterOfMars <[email protected]> --------- Co-authored-by: DaughterOfMars <[email protected]>
1 parent 200780f commit f8533e2

File tree

43 files changed

+581
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+581
-124
lines changed

bindings/go/examples/dev_inspect/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import (
1313
func main() {
1414
client := sdk.GraphQlClientNewDevnet()
1515

16-
sender, _ := sdk.AddressFromHex("0x0")
16+
sender := sdk.AddressZero()
1717

1818
iotaNamesPackageAddress, _ := sdk.AddressFromHex("0xb9d617f24c84826bf660a2f4031951678cc80c264aebc4413459fb2a95ada9ba")
1919

2020
iotaNamesObjectId, _ := sdk.ObjectIdFromHex("0x07c59b37bd7d036bf78fa30561a2ab9f7a970837487656ec29466e817f879342")
2121

22-
stdlibAddress, _ := sdk.AddressFromHex("0x1")
22+
stdlibAddress := sdk.AddressStdLib()
2323

2424
name := "name.iota"
2525
fmt.Printf("Looking up name: %s\n", name)

bindings/go/examples/gas_sponsor/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func main() {
1717

1818
builder := sdk.TransactionBuilderInit(sender, client)
1919

20-
packageAddr, _ := sdk.AddressFromHex("0x1")
20+
packageAddr := sdk.AddressStdLib()
2121
moduleName, _ := sdk.NewIdentifier("u8")
2222
functionName, _ := sdk.NewIdentifier("max")
2323

bindings/go/examples/gas_station/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func main() {
1919

2020
builder := sdk.TransactionBuilderInit(sender, client)
2121

22-
package_id, _ := sdk.AddressFromHex("0x1")
22+
package_id := sdk.AddressStdLib()
2323
module_name, _ := sdk.NewIdentifier("u64")
2424
function_name, _ := sdk.NewIdentifier("sqrt")
2525

bindings/go/examples/generic_move_function/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func main() {
2020
addr1, _ := sdk.AddressFromHex("0xde49ea53fbadee67d3e35a097cdbea210b659676fc680a0b0c5f11d0763d375e")
2121
addr2, _ := sdk.AddressFromHex("0xe512234aa4ef6184c52663f09612b68f040dd0c45de037d96190a071ca5525b3")
2222

23-
package_id, _ := sdk.AddressFromHex("0x2")
23+
package_id := sdk.AddressFramework()
2424
module_name, _ := sdk.NewIdentifier("vec_map")
2525
function_name, _ := sdk.NewIdentifier("from_keys_values")
2626

bindings/go/examples/owned_objects/main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ import (
1313
func main() {
1414
client := sdk.GraphQlClientNewDevnet()
1515

16-
address, err := sdk.AddressFromHex("0x0")
17-
if err != nil {
18-
log.Fatalf("Failed to parse address: %v", err)
19-
}
16+
address := sdk.AddressZero()
2017

2118
objectFilter := sdk.ObjectFilter{
2219
Owner: &address,

bindings/go/examples/stake/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ func main() {
3434

3535
coinObjId, _ := sdk.ObjectIdFromHex("0xd04077fe3b6fad13b3d4ed0d535b7ca92afcac8f0f2a0e0925fb9f4f0b30c699")
3636

37-
iotaSystemAddress, _ := sdk.AddressFromHex("0x3")
37+
iotaSystemAddress := sdk.AddressSystem()
3838

39-
iotaSystemId, _ := sdk.ObjectIdFromHex("0x5")
39+
iotaSystemId := sdk.ObjectIdSystem()
4040

4141
iotaSystemModule, _ := sdk.NewIdentifier("iota_system")
4242

bindings/go/examples/unstake/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ func main() {
2222
}
2323
stakedIota := stakedIotas.Data[0]
2424

25-
iotaSystemAddress, _ := sdk.AddressFromHex("0x3")
25+
iotaSystemAddress := sdk.AddressSystem()
2626

27-
iotaSystemId, _ := sdk.ObjectIdFromHex("0x5")
27+
iotaSystemId := sdk.ObjectIdSystem()
2828

2929
iotaSystemModule, _ := sdk.NewIdentifier("iota_system")
3030

bindings/go/iota_sdk_ffi/iota_sdk_ffi.go

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ func uniffiCheckChecksums() {
13521352
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
13531353
return C.uniffi_iota_sdk_ffi_checksum_method_graphqlclient_dynamic_field()
13541354
})
1355-
if checksum != 29988 {
1355+
if checksum != 17199 {
13561356
// If this happens try cleaning and rebuilding your project
13571357
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_graphqlclient_dynamic_field: UniFFI API checksum mismatch")
13581358
}
@@ -4508,6 +4508,15 @@ func uniffiCheckChecksums() {
45084508
}
45094509
}
45104510
{
4511+
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
4512+
return C.uniffi_iota_sdk_ffi_checksum_constructor_address_framework()
4513+
})
4514+
if checksum != 52951 {
4515+
// If this happens try cleaning and rebuilding your project
4516+
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_address_framework: UniFFI API checksum mismatch")
4517+
}
4518+
}
4519+
{
45114520
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
45124521
return C.uniffi_iota_sdk_ffi_checksum_constructor_address_from_bytes()
45134522
})
@@ -4535,6 +4544,33 @@ func uniffiCheckChecksums() {
45354544
}
45364545
}
45374546
{
4547+
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
4548+
return C.uniffi_iota_sdk_ffi_checksum_constructor_address_std_lib()
4549+
})
4550+
if checksum != 35825 {
4551+
// If this happens try cleaning and rebuilding your project
4552+
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_address_std_lib: UniFFI API checksum mismatch")
4553+
}
4554+
}
4555+
{
4556+
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
4557+
return C.uniffi_iota_sdk_ffi_checksum_constructor_address_system()
4558+
})
4559+
if checksum != 4297 {
4560+
// If this happens try cleaning and rebuilding your project
4561+
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_address_system: UniFFI API checksum mismatch")
4562+
}
4563+
}
4564+
{
4565+
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
4566+
return C.uniffi_iota_sdk_ffi_checksum_constructor_address_zero()
4567+
})
4568+
if checksum != 46553 {
4569+
// If this happens try cleaning and rebuilding your project
4570+
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_address_zero: UniFFI API checksum mismatch")
4571+
}
4572+
}
4573+
{
45384574
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
45394575
return C.uniffi_iota_sdk_ffi_checksum_constructor_argument_new_gas()
45404576
})
@@ -5615,6 +5651,15 @@ func uniffiCheckChecksums() {
56155651
}
56165652
}
56175653
{
5654+
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
5655+
return C.uniffi_iota_sdk_ffi_checksum_constructor_objectid_clock()
5656+
})
5657+
if checksum != 14732 {
5658+
// If this happens try cleaning and rebuilding your project
5659+
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_objectid_clock: UniFFI API checksum mismatch")
5660+
}
5661+
}
5662+
{
56185663
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
56195664
return C.uniffi_iota_sdk_ffi_checksum_constructor_objectid_derive_id()
56205665
})
@@ -5642,6 +5687,24 @@ func uniffiCheckChecksums() {
56425687
}
56435688
}
56445689
{
5690+
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
5691+
return C.uniffi_iota_sdk_ffi_checksum_constructor_objectid_system()
5692+
})
5693+
if checksum != 9600 {
5694+
// If this happens try cleaning and rebuilding your project
5695+
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_objectid_system: UniFFI API checksum mismatch")
5696+
}
5697+
}
5698+
{
5699+
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
5700+
return C.uniffi_iota_sdk_ffi_checksum_constructor_objectid_zero()
5701+
})
5702+
if checksum != 40526 {
5703+
// If this happens try cleaning and rebuilding your project
5704+
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_objectid_zero: UniFFI API checksum mismatch")
5705+
}
5706+
}
5707+
{
56455708
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
56465709
return C.uniffi_iota_sdk_ffi_checksum_constructor_objecttype_new_package()
56475710
})
@@ -7363,6 +7426,12 @@ type Address struct {
73637426
}
73647427

73657428

7429+
func AddressFramework() *Address {
7430+
return FfiConverterAddressINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer {
7431+
return C.uniffi_iota_sdk_ffi_fn_constructor_address_framework(_uniffiStatus)
7432+
}))
7433+
}
7434+
73667435
func AddressFromBytes(bytes []byte) (*Address, error) {
73677436
_uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer {
73687437
return C.uniffi_iota_sdk_ffi_fn_constructor_address_from_bytes(FfiConverterBytesINSTANCE.Lower(bytes),_uniffiStatus)
@@ -7393,6 +7462,24 @@ func AddressGenerate() *Address {
73937462
}))
73947463
}
73957464

7465+
func AddressStdLib() *Address {
7466+
return FfiConverterAddressINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer {
7467+
return C.uniffi_iota_sdk_ffi_fn_constructor_address_std_lib(_uniffiStatus)
7468+
}))
7469+
}
7470+
7471+
func AddressSystem() *Address {
7472+
return FfiConverterAddressINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer {
7473+
return C.uniffi_iota_sdk_ffi_fn_constructor_address_system(_uniffiStatus)
7474+
}))
7475+
}
7476+
7477+
func AddressZero() *Address {
7478+
return FfiConverterAddressINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer {
7479+
return C.uniffi_iota_sdk_ffi_fn_constructor_address_zero(_uniffiStatus)
7480+
}))
7481+
}
7482+
73967483

73977484

73987485
func (_self *Address) ToBytes() []byte {
@@ -11997,7 +12084,7 @@ type GraphQlClientInterface interface {
1199712084
// ```rust,ignore
1199812085
//
1199912086
// let client = iota_graphql_client::Client::new_devnet();
12000-
// let address = Address::from_str("0x5").unwrap();
12087+
// let address = ObjectId::SYSTEM.into();
1200112088
// let df = client.dynamic_field_with_name(address, "u64", 2u64).await.unwrap();
1200212089
//
1200312090
// # alternatively, pass in the bcs bytes
@@ -12535,7 +12622,7 @@ func (_self *GraphQlClient) DryRunTxKind(txKind *TransactionKind, txMeta Transac
1253512622
// ```rust,ignore
1253612623
//
1253712624
// let client = iota_graphql_client::Client::new_devnet();
12538-
// let address = Address::from_str("0x5").unwrap();
12625+
// let address = ObjectId::SYSTEM.into();
1253912626
// let df = client.dynamic_field_with_name(address, "u64", 2u64).await.unwrap();
1254012627
//
1254112628
// # alternatively, pass in the bcs bytes
@@ -17016,6 +17103,12 @@ type ObjectId struct {
1701617103
}
1701717104

1701817105

17106+
func ObjectIdClock() *ObjectId {
17107+
return FfiConverterObjectIdINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer {
17108+
return C.uniffi_iota_sdk_ffi_fn_constructor_objectid_clock(_uniffiStatus)
17109+
}))
17110+
}
17111+
1701917112
// Create an ObjectId from a transaction digest and the number of objects
1702017113
// that have been created during a transactions.
1702117114
func ObjectIdDeriveId(digest *Digest, count uint64) *ObjectId {
@@ -17048,6 +17141,18 @@ func ObjectIdFromHex(hex string) (*ObjectId, error) {
1704817141
}
1704917142
}
1705017143

17144+
func ObjectIdSystem() *ObjectId {
17145+
return FfiConverterObjectIdINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer {
17146+
return C.uniffi_iota_sdk_ffi_fn_constructor_objectid_system(_uniffiStatus)
17147+
}))
17148+
}
17149+
17150+
func ObjectIdZero() *ObjectId {
17151+
return FfiConverterObjectIdINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer {
17152+
return C.uniffi_iota_sdk_ffi_fn_constructor_objectid_zero(_uniffiStatus)
17153+
}))
17154+
}
17155+
1705117156

1705217157

1705317158
// Derive an ObjectId for a Dynamic Child Object.

0 commit comments

Comments
 (0)